Move function definition to aul header
[platform/core/appfw/aul-1.git] / src / aul_proc_group.cc
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "include/aul_proc_group.h"
18
19 #include <fcntl.h>
20 #include <stdio.h>
21 #include <sys/stat.h>
22 #include <sys/types.h>
23 #include <unistd.h>
24
25 #include "app_request.h"
26 #include "aul_api.h"
27 #include "aul_util.h"
28 #include "include/aul_error.h"
29 #include "include/aul_sock.h"
30
31 using namespace aul;
32 using namespace aul::internal;
33
34 extern "C" API int aul_proc_group_add(pid_t pid) {
35   if (pid < 1) {
36     _E("Invalid parameter");
37     return AUL_R_EINVAL;
38   }
39
40   int ret = AppRequest(PROC_GROUP_ADD, getuid())
41       .SetPid(pid)
42       .SendSimply();
43   if (ret < 0) {
44     _E("Failed to send the request. error(%d)", ret);
45     return aul_error_convert(ret);
46   }
47
48   return AUL_R_OK;
49 }
50
51 extern "C" API int aul_proc_group_remove(pid_t pid) {
52   if (pid < 1) {
53     _E("Invalid parameter");
54     return AUL_R_EINVAL;
55   }
56
57   int ret = AppRequest(PROC_GROUP_REMOVE, getuid())
58       .SetPid(pid)
59       .SendSimply();
60   if (ret < 0) {
61     _E("Failed to send the request. error(%d)", ret);
62     return aul_error_convert(ret);
63   }
64
65   return AUL_R_OK;
66 }