2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3 Copyright (C) 2001,2002,2003 Aymeric MOIZARD jack@atosc.org
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.
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.
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
23 #include <osipparser2/osip_port.h>
24 #include <osipparser2/osip_message.h>
25 #include <osipparser2/osip_parser.h>
29 osip_route_init2 (osip_route_t ** route)
32 osip_route_init (osip_route_t ** route)
35 return osip_from_init ((osip_from_t **) route);
38 /* adds the route header to message. */
39 /* INPUT : const char *hvalue | value of header. */
40 /* OUTPUT: osip_message_t *sip | structure to save results. */
41 /* returns -1 on error. */
43 osip_message_set_route (osip_message_t * sip, const char *hvalue)
48 if (hvalue == NULL || hvalue[0] == '\0')
52 i = osip_route_init2 (&route);
54 i = osip_route_init (&route);
58 i = osip_route_parse (route, hvalue);
61 osip_route_free (route);
64 sip->message_property = 2;
65 osip_list_add (sip->routes, route, -1);
69 /* returns the route header. */
70 /* INPUT : osip_message_t *sip | sip message. */
71 /* returns null on error. */
73 osip_message_get_route (const osip_message_t * sip, int pos,
79 if (osip_list_size (sip->routes) <= pos)
80 return -1; /* does not exist */
81 route = (osip_route_t *) osip_list_get (sip->routes, pos);
87 osip_route_parse (osip_route_t * route, const char *hvalue)
89 return osip_from_parse ((osip_from_t *) route, hvalue);
92 /* returns the route header as a string. */
93 /* INPUT : osip_route_t *route | route header. */
94 /* returns null on error. */
96 osip_route_to_str (const osip_route_t * route, char **dest)
98 /* we can't use osip_from_to_str(): route and record_route */
99 /* always use brackets. */
100 return osip_record_route_to_str ((osip_record_route_t *) route, dest);
103 /* deallocates a osip_route_t structure. */
104 /* INPUT : osip_route_t *route | route header. */
106 osip_route_free (osip_route_t * route)
108 osip_from_free ((osip_from_t *) route);