tizen 2.3 release
[framework/appfw/com-core.git] / include / com-core.h
1 /*
2  * Copyright (c) 2000 - 2013 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
18 #ifndef _COM_CORE_H
19 #define _COM_CORE_H
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 enum com_core_event_type {
26         CONNECTOR_CONNECTED,
27         CONNECTOR_DISCONNECTED
28 };
29
30 /*!
31  * \brief
32  * \details N/A
33  * \remarks N/A
34  * \param[in] addr
35  * \param[in] is_sync
36  * \param[in] service_cb
37  * \param[in] data
38  * \return int
39  * \retval
40  * \sa
41  */
42 extern int com_core_server_create(const char *addr, int is_sync, int (*service_cb)(int fd, void *data), void *data);
43
44 /*!
45  * \brief
46  * \details N/A
47  * \remarks N/A
48  * \param[in] addr
49  * \param[in] is_sync
50  * \param[in] service_cb
51  * \param[in] data
52  * \return int
53  * \retval
54  * \sa
55  */
56 extern int com_core_client_create(const char *addr, int is_sync, int (*service_cb)(int fd, void *data), void *data);
57
58 /*!
59  * \brief
60  * \details N/A
61  * \remarks N/A
62  * \param[in] handle
63  * \return int
64  * \retval
65  * \sa
66  */
67 extern int com_core_server_destroy(int handle);
68
69 /*!
70  * \brief
71  * \details N/A
72  * \remarks N/A
73  * \param[in] handle
74  * \return int
75  * \retval
76  * \sa
77  */
78 extern int com_core_client_destroy(int handle);
79
80 /*!
81  * \brief Used to handling the changing event of connection status.
82  *        These two functions can be work with com_core_thread series functions.
83  * \details N/A
84  * \remarks N/A
85  * \param[in] type
86  * \param[in] service_cb
87  * \param[in] data
88  * \return int
89  * \retval
90  * \sa
91  */
92 extern int com_core_add_event_callback(enum com_core_event_type type, int (*service_cb)(int handle, void *data), void *data);
93
94 /*!
95  * \brief
96  * \details N/A
97  * \remarks N/A
98  * \param[in] type
99  * \param[in] service_cb
100  * \param[in] data
101  * \return void *
102  * \retval
103  * \sa
104  */
105 extern void *com_core_del_event_callback(enum com_core_event_type type, int (*service_cb)(int handle, void *data), void *data);
106
107 /*!
108  * \brief If the connection is lost, this recv function will call the disconnected callback.
109  * \details N/A
110  * \remarks N/A
111  * \param[in] handle
112  * \param[in] buffer
113  * \param[in] size
114  * \param[in] sender_pid
115  * \param[in] timeout
116  * \return int
117  * \retval
118  * \sa
119  */
120 extern int com_core_recv(int handle, char *buffer, int size, int *sender_pid, double timeout);
121
122 /*!
123  * \brief
124  * \details N/A
125  * \remarks N/A
126  * \param[in] handle
127  * \param[in] buffer
128  * \param[in] size
129  * \param[in] timeout
130  * \return int
131  * \retval
132  * \sa
133  */
134 extern int com_core_send(int handle, const char *buffer, int size, double timeout);
135
136 /**
137  * @brief
138  * @details
139  * @remarks
140  * @param[in] handle
141  * @param[in] buffer
142  * @param[in] size
143  * @param[in] timeout
144  * @param[in] fd
145  * @return int
146  * @retval
147  * @sa
148  */
149 extern int com_core_send_with_fd(int handle, const char *buffer, int size, double timeout, int fd);
150
151 /**
152  * @brief
153  * @details
154  * @remarks
155  * @param[in] handle
156  * @param[out] buffer
157  * @param[in] size
158  * @param[out] sender_pid
159  * @param[in] timeout
160  * @param[out] fd
161  */
162 extern int com_core_recv_with_fd(int handle, char *buffer, int size, int *sender_pid, double timeout, int *fd);
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif
169 /* End of a file */