Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / include / common / util / util.h
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef UTIL_H_
19 #define UTIL_H_
20
21 /*lib*/
22 #include <stdio.h>
23 #include <assert.h>
24 #include <errno.h>
25 #include <string.h>
26 #include <stdbool.h>
27
28 /*dm-agent*/
29 #include "common/dm_common.h"
30
31 #define errno_abort(text) do {\
32         fprintf(stderr, "%s at \"%s\":%d: %s\n", text, __FILE__, __LINE__, strerror(errno));\
33         abort();\
34         } while(0)
35
36 #define assert_condition(condition) do{\
37         if (!(condition)) {\
38                 fprintf(stderr, "assert at \"%s\":%d: %s\n", __FILE__, __LINE__, strerror(errno));\
39                 abort();\
40         }\
41         } while(0)
42
43 /**
44  * @par Description: API to free string
45  *
46  *
47  * @par Purpose:
48  * @par Typical use case:
49  * @par Method of function operation:
50  * @par Important notes:
51  * @param[in] string
52  *
53  * @return
54  *
55  *
56  * @par Errors:
57  *
58  * @pre None.
59  * @post
60  * @see
61  * @remarks None.
62  *
63  * @par Sample Code:
64  * @code
65  * @endcode
66  */
67 void str_free(char **str);
68
69 /**
70  * @par Description: API to exchange char to int
71  *
72  *
73  * @par Purpose:
74  * @par Typical use case:
75  * @par Method of function operation:
76  * @par Important notes:
77  * @param[in] string
78  * @param[out] int
79  *
80  * @return                      1 success
81  *                                      0 error
82  *
83  *
84  * @par Errors:
85  *
86  * @pre None.
87  * @post
88  * @see
89  * @remarks None.
90  *
91  * @par Sample Code:
92  * @code
93  * @endcode
94  */
95 int chartoint(char *data, int *value);
96
97 /**
98  * @par Description: API to launch oma dm fumo ui
99  *
100  *
101  * @par Purpose:
102  * @par Typical use case:
103  * @par Method of function operation:
104  * @par Important notes:
105  *
106  * @return                              1 success
107  *                                              0 error
108  *
109  *
110  * @par Errors:
111  *
112  * @pre None.
113  * @post
114  * @see
115  * @remarks None.
116  *
117  * @par Sample Code:
118  * @code
119  * @endcode
120  */
121 int launch_oma_dm_fumo_ui();
122
123 /**
124  * @par Description: API to launch oma dm fumo noti ui
125  *
126  *
127  * @par Purpose:
128  * @par Typical use case:
129  * @par Method of function operation:
130  * @par Important notes:
131  * @param[in] noti type ( user interaction, imformative, background )
132  * @param[in] session id
133  * @param[in] server id
134  *
135  * @return                              1 success
136  *                                              0 error
137  *
138  *
139  * @par Errors:
140  *
141  * @pre None.
142  * @post
143  * @see
144  * @remarks None.
145  *
146  * @par Sample Code:
147  * @code
148  * @endcode
149  */
150 int launch_om_dm_fumo_noti_ui(int noti_data, char *session_id, char *server_id);
151
152 /**
153  * @par Description: API to launch oma dm alert ui
154  *
155  *
156  * @par Purpose:
157  * @par Typical use case:
158  * @par Method of function operation:
159  * @par Important notes:
160  *
161  * @return                              1 success
162  *                                              0 error
163  *
164  *
165  * @par Errors:
166  *
167  * @pre None.
168  * @post
169  * @see
170  * @remarks None.
171  *
172  * @par Sample Code:
173  * @code
174  * @endcode
175  */
176 int launch_om_dm_fumo_alert_ui();
177
178 /**
179  * @par Description: API to launch oma dm cp ui
180  *
181  *
182  * @par Purpose:
183  * @par Typical use case:
184  * @par Method of function operation:
185  * @par Important notes:
186  * @param[in] pin type
187  * @param[in] ext id
188  *
189  * @return                              1 success
190  *                                              0 error
191  *
192  *
193  * @par Errors:
194  *
195  * @pre None.
196  * @post
197  * @see
198  * @remarks None.
199  *
200  * @par Sample Code:
201  * @code
202  * @endcode
203  */
204 int launch_oma_dm_cp_ui(int sec_type, int ext_id);
205
206 /**
207  * @par Description: API to terminate oma dm ui
208  *
209  *
210  * @par Purpose:
211  * @par Typical use case:
212  * @par Method of function operation:
213  * @par Important notes:
214  * @param[in] return result
215  * @param[in] service engine id
216  *
217  * @return
218  *
219  *
220  *
221  * @par Errors:
222  *
223  * @pre None.
224  * @post
225  * @see
226  * @remarks None.
227  *
228  * @par Sample Code:
229  * @code
230  * @endcode
231  */
232 void terminate_oma_dm_ui(int ret, ENGINE_ID service_engine_id);
233
234 /**
235  * @par Description: API to terminate ui status
236  *
237  *
238  * @par Purpose:
239  * @par Typical use case:
240  * @par Method of function operation:
241  * @par Important notes:
242  * @param[in] noty type
243  * @param[in] ui mode
244  * @param[in] return result
245  *
246  * @return
247  *
248  *
249  *
250  * @par Errors:
251  *
252  * @pre None.
253  * @post
254  * @see
255  * @remarks None.
256  *
257  * @par Sample Code:
258  * @code
259  * @endcode
260  */
261 void terminate_ui_status(int noti_type, char *ui_mode, int ret);
262
263 /**
264  * @par Description: API to terminate ui status
265  *
266  *
267  * @par Purpose:
268  * @par Typical use case:
269  * @par Method of function operation:
270  * @par Important notes:
271  *
272  * @return                              1 success
273  *                                              0 error
274  *
275  *
276  * @par Errors:
277  *
278  * @pre None.
279  * @post
280  * @see
281  * @remarks None.
282  *
283  * @par Sample Code:
284  * @code
285  * @endcode
286  */
287 int check_csc();
288
289 /**
290  * @par Description: API to get wifi state
291  *
292  *
293  * @par Purpose:
294  * @par Typical use case:
295  * @par Method of function operation:
296  * @par Important notes:
297  *
298  * @return                              1 success
299  *
300  *
301  *
302  * @par Errors:
303  *
304  * @pre None.
305  * @post
306  * @see
307  * @remarks None.
308  *
309  * @par Sample Code:
310  * @code
311  * @endcode
312  */
313 int get_wifi_state();
314
315 /**
316  * @par Description: API to nonce decode
317  *
318  *
319  * @par Purpose:
320  * @par Typical use case:
321  * @par Method of function operation:
322  * @par Important notes:
323  * @param[in] nextNonce
324  * @param[out] nextNonceDecode
325  * @param[out] out_len
326  *
327  * @return                              DM_OK success
328  *
329  *
330  *
331  * @par Errors:
332  *
333  * @pre None.
334  * @post
335  * @see
336  * @remarks None.
337  *
338  * @par Sample Code:
339  * @code
340  * @endcode
341  */
342 DM_ERROR nonce_decode(char *nextNonce, unsigned char **nextNonceDecode, unsigned int *out_len);
343
344 /* hex2char*/
345 /*bool hex2char(char const* szHex, unsigned char* rch);*/
346
347 #endif                          /* UTIL_H_ */