Add new functions for RPC-Port
[platform/core/appfw/aul-1.git] / include / aul_rpc_port.h
1 /*
2  * Copyright (c) 2018 - 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 #ifndef __AUL_RPC_PORT_H__
18 #define __AUL_RPC_PORT_H__
19
20 #include <sys/types.h>
21 #include <unistd.h>
22
23 #include <aul.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #ifndef AUL_K_RPC_PORT
30 #define AUL_K_RPC_PORT "__K_RPC_PORT"
31 #endif
32
33 typedef void *aul_rpc_port_watch_h;
34
35 typedef void (*aul_rpc_port_appeared_cb)(const char *app_id,
36                 const char *port_name, int pid, void *user_data);
37
38 typedef void (*aul_rpc_port_vanished_cb)(const char *app_id,
39                 const char *port_name, int pid, void *user_data);
40
41 int aul_rpc_port_prepare_stub(const char *app_id, const char *port_name);
42
43 int aul_rpc_port_usr_prepare_stub(const char *app_id, const char *port_name,
44                 uid_t uid);
45
46 int aul_rpc_port_create_socket_pair(const char *app_id, const char *port_name,
47                 int (*fds)[2]);
48
49 int aul_rpc_port_notify_rpc_finished(void);
50
51 int aul_rpc_port_set_private_sharing(const char *app_id, const char *paths[],
52                 unsigned int size);
53
54 int aul_rpc_port_unset_private_sharing(const char *app_id);
55
56 int aul_rpc_port_create(const char *port_name, int *fd);
57
58 int aul_rpc_port_usr_create(const char *port_name, uid_t uid, int *fd);
59
60 int aul_rpc_port_destroy(const char *port_name);
61
62 int aul_rpc_port_usr_destroy(const char *port_name, uid_t uid);
63
64 int aul_rpc_port_add_watch(const char *app_id, const char *port_name,
65                 aul_rpc_port_appeared_cb appeared_cb,
66                 aul_rpc_port_vanished_cb vanished_cb,
67                 void *user_data,
68                 aul_rpc_port_watch_h *handle);
69
70 int aul_rpc_port_usr_add_watch(const char *app_id, const char *port_name,
71                 aul_rpc_port_appeared_cb appeared_cb,
72                 aul_rpc_port_vanished_cb vanished_cb,
73                 void *user_data, uid_t uid,
74                 aul_rpc_port_watch_h *handle);
75
76
77 int aul_rpc_port_remove_watch(aul_rpc_port_watch_h handle);
78
79 int aul_rpc_port_exist(const char *appid, const char *port_name, bool *exist);
80
81 int aul_rpc_port_usr_exist(const char *appid, const char *port_name, uid_t uid,
82                 bool *exist);
83
84 int aul_rpc_port_get_path(const char *appid, const char *port_name,
85                 char **path);
86
87 int aul_rpc_port_usr_get_path(const char *appid, const char *port_name,
88                 uid_t uid, char **path);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* __AUL_RPC_PORT_H__ */