|
1 |
|
2 /* ============================================================================ |
|
3 * Name : isoutils.h |
|
4 * Part of : isolation server. |
|
5 * Version : %version: 8 % |
|
6 * |
|
7 * Copyright © 2007-2008 Nokia. All rights reserved. |
|
8 * All rights reserved. |
|
9 * Redistribution and use in source and binary forms, with or without modification, |
|
10 * are permitted provided that the following conditions are met: |
|
11 * Redistributions of source code must retain the above copyright notice, this list |
|
12 * of conditions and the following disclaimer.Redistributions in binary form must |
|
13 * reproduce the above copyright notice, this list of conditions and the following |
|
14 * disclaimer in the documentation and/or other materials provided with the distribution. |
|
15 * Neither the name of the Nokia Corporation nor the names of its contributors may be used |
|
16 * to endorse or promote products derived from this software without specific prior written |
|
17 * permission. |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
|
21 * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
|
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
27 * ============================================================================ |
|
28 * Template version: 1.0 |
|
29 */ |
|
30 |
|
31 /*! |
|
32 * /def To avoid multiple inclusion of header |
|
33 */ |
|
34 #ifndef __ISOUTILS_H__ |
|
35 #define __ISOUTILS_H__ |
|
36 |
|
37 /* |
|
38 *! /file |
|
39 * Header file for the isolation utilities. |
|
40 * client anywhere in the documentation refers to anyone |
|
41 * using the isoserver |
|
42 */ |
|
43 #include "msg_enums.h" |
|
44 |
|
45 |
|
46 /* |
|
47 * ! /brief Function for to log the messages. Ultimately uses fprintf and putc to |
|
48 * write to file. This function takes variable no of arguments. |
|
49 * |
|
50 * /param fmt format specifier. |
|
51 * /return void |
|
52 */ |
|
53 void iso_logger ( gchar* fmt, ... ); |
|
54 |
|
55 /* |
|
56 *! /brief parses a buffer into an array of strings. Message buffer |
|
57 * test.ximp@gmail.com/0ximp.telepathy@gmail.com/0/0 |
|
58 * ^ ^ |
|
59 * contact1------------|contact2-----------------| |
|
60 * str will have contact1 for 1st time, contact2 on 2nd call |
|
61 * |
|
62 * /param message buffer : Buffer to be parsed |
|
63 * /param str : str will have pointer to a string |
|
64 * /param len : Len returns the number of bytes read |
|
65 * /param msg_len : no. of bytes in msg_buf |
|
66 * /return gint : error if any on failure, else no. of strings read from buffer |
|
67 */ |
|
68 gint parse_a_string( gchar* msg_buf, gchar** str, gint* len, gint msg_len ); |
|
69 |
|
70 /* |
|
71 *! |
|
72 * /brief parses a buffer into an array of strings |
|
73 * |
|
74 * /param message buffer : Buffer to be parsed |
|
75 * /param arr_str : Parsed strings are returned in this array of strings |
|
76 * /param len : Len returns the number of bytes read |
|
77 * /param len : msg_len no. of bytes in msg_buf |
|
78 * /param cntidscount : no. of contacts |
|
79 * /return gint : error if any on failure, else no. of strings read from buffer |
|
80 * example |
|
81 * test.ximp@gmail.com/0ximp.telepathy@gmail.com/0/0 |
|
82 * ^ ^ ^ ^ |
|
83 * contact1------------|contact2-----------------|-| |
|
84 * is parsed into |
|
85 * arr_str[0] = test.ximp@gmail.com/0 |
|
86 * arr_str[1] = ximp.telepathy@gmail.com/0 |
|
87 */ |
|
88 gint parse_into_array_of_strings( gchar* msg_buf, |
|
89 gchar*** arr_str, gint* len, gint msg_len, |
|
90 gint* cntidscount ) ; |
|
91 |
|
92 /* |
|
93 *! /brief Frees the memory allocated to the array of string and to the message |
|
94 * |
|
95 * /param contactid : array of string to be freed. |
|
96 * /param contacts_count : no of contacts |
|
97 * /param sendmsg : msg to be freed |
|
98 */ |
|
99 void free_msg_args( gchar** contactid, gint contacts_count, gchar* sendmsg ); |
|
100 |
|
101 |
|
102 /* |
|
103 *! /brief Send the response for the porcessing of request to the client |
|
104 * |
|
105 * /param hdr_req : message request header |
|
106 * /param error : error code |
|
107 * /param response : whether the processing of request successful |
|
108 * |
|
109 */ |
|
110 gint send_response_to_client( message_hdr_req* hdr_req, gint error, |
|
111 gboolean response ); |
|
112 |
|
113 #endif //__ISOUTILS_H__ |
|
114 |