http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / userapps / opensource / libosip2 / src / osipparser2 / osip_mime_version.c
1 /*
2   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3   Copyright (C) 2001,2002,2003  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 #include <stdlib.h>
21 #include <stdio.h>
22
23 #include <osipparser2/osip_port.h>
24 #include <osipparser2/osip_message.h>
25 #include <osipparser2/osip_parser.h>
26
27
28 /* adds the mime_version header to message.       */
29 /* INPUT : const char *hvalue | value of header.    */
30 /* OUTPUT: osip_message_t *sip | structure to save results.  */
31 /* returns -1 on error. */
32 int
33 osip_message_set_mime_version (osip_message_t * sip, const char *hvalue)
34 {
35   int i;
36
37   if (hvalue == NULL || hvalue[0] == '\0')
38     return 0;
39
40   if (sip->mime_version != NULL)
41     return -1;
42   i = osip_mime_version_init (&(sip->mime_version));
43   if (i != 0)
44     return -1;
45   sip->message_property = 2;
46   i = osip_mime_version_parse (sip->mime_version, hvalue);
47   if (i != 0)
48     {
49       osip_mime_version_free (sip->mime_version);
50       sip->mime_version = NULL;
51       return -1;
52     }
53   return 0;
54 }
55
56 /* returns the mime_version header.            */
57 /* INPUT : osip_message_t *sip | sip message.   */
58 /* returns null on error. */
59 osip_mime_version_t *
60 osip_message_get_mime_version (const osip_message_t * sip)
61 {
62   return sip->mime_version;
63 }