and added files
[bcm963xx.git] / userapps / opensource / libosip2 / include / osipparser2 / headers / osip_from.h
1 /*
2   The oSIP library implements the Session Initiation Protocol (SIP -rfc2543-)
3   Copyright (C) 2001  Aymeric MOIZARD jack@atosc.org
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14   
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20
21 #ifndef _OSIP_FROM_H_
22 #define _OSIP_FROM_H_
23
24 #include <osipparser2/osip_list.h>
25 #include <osipparser2/osip_uri.h>
26
27 /**
28  * @file osip_from.h
29  * @brief oSIP osip_from header definition.
30  */
31
32 /**
33  * @defgroup oSIP_FROM oSIP from header definition.
34  * @ingroup oSIP_HEADERS
35  * @{
36  */
37
38 /**
39  * Structure for From headers.
40  * @defvar osip_from_t
41  */
42   typedef struct osip_from osip_from_t;
43
44   struct osip_from
45   {
46     char *displayname;
47     osip_uri_t *url;                    /* could contain various urischeme_t ? only in the future */
48     osip_list_t *gen_params;
49   };
50
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55
56 /**
57  * Allocate a From element.
58  * @param header The element to work on.
59  */
60   int osip_from_init (osip_from_t ** header);
61 /**
62  * Free a From element.
63  * @param header The element to work on.
64  */
65   void osip_from_free (osip_from_t * header);
66 /**
67  * Parse a From element.
68  * @param header The element to work on.
69  * @param hvalue The string to parse.
70  */
71   int osip_from_parse (osip_from_t * header, const char *hvalue);
72 /**
73  * Get a string representation of a From element.
74  * @param header The element to work on.
75  * @param dest A pointer on the new allocated string.
76  */
77   int osip_from_to_str (const osip_from_t * header, char **dest);
78 /**
79  * Clone a From element.
80  * @param header The element to work on.
81  * @param dest A pointer on the copy of the element.
82  */
83   int osip_from_clone (const osip_from_t * header, osip_from_t ** dest);
84 /**
85  * Set the displayname in the From element.
86  * @param header The element to work on.
87  * @param value The value of the element.
88  */
89   void osip_from_set_displayname (osip_from_t * header, char *value);
90 /**
91  * Get the displayname from a From header.
92  * @param header The element to work on.
93  */
94   char *osip_from_get_displayname (osip_from_t * header);
95 /**
96  * Set the url in the From element.
97  * @param header The element to work on.
98  * @param url The value of the element.
99  */
100   void osip_from_set_url (osip_from_t * header, osip_uri_t * url);
101 /**
102  * Get the url from a From header.
103  * @param header The element to work on.
104  */
105   osip_uri_t *osip_from_get_url (osip_from_t * header);
106 /**
107  * Get a header parameter from a From element.
108  * @param header The element to work on.
109  * @param pos The index of the element to get.
110  * @param dest A pointer on the element found.
111  */
112   int osip_from_param_get (osip_from_t * header, int pos, osip_generic_param_t ** dest);
113 /**
114  * Allocate and add a generic parameter element in a list.
115  * @param header The element to work on.
116  * @param name The token name.
117  * @param value The token value.
118  */
119 #define osip_from_param_add(header,name,value)      osip_generic_param_add((header)->gen_params,name,value)
120 /**
121  * Find a header parameter in a From element.
122  * @param header The element to work on.
123  * @param name The token name to search.
124  * @param dest A pointer on the element found.
125  */
126 #define osip_from_param_get_byname(header,name,dest) osip_generic_param_get_byname((header)->gen_params,name,dest)
127
128 /**
129  * Find the tag parameter in a From element.
130  * @param header The element to work on.
131  * @param dest A pointer on the element found.
132  */
133 #define osip_from_get_tag(header,dest)    osip_generic_param_get_byname((header)->gen_params, "tag",dest)
134 /**
135  * Allocate and add a tag parameter element in a Contact element.
136  * @param header The element to work on.
137  * @param value The token value.
138  */
139 #define osip_from_set_tag(header,value)     osip_generic_param_add((header)->gen_params, osip_strdup("tag"),value)
140
141 #ifndef DOXYGEN                 /* avoid DOXYGEN warning */
142 /* Compare the username, host and tag part (if exist) of the two froms */
143   int osip_from_compare (osip_from_t * header1, osip_from_t * header2);
144 #endif
145
146 /**
147  * Check if the tags in the From headers match.
148  * NOTE: THIS IS AN INTERNAL METHOD ONLY
149  * @param from1 The first From header.
150  * @param from2 The second From header.
151  */
152   int osip_from_tag_match (osip_from_t * from1, osip_from_t * from2);
153
154
155 #ifdef __cplusplus
156 }
157 #endif
158
159 /** @} */
160
161 #endif