1 /*
2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3 Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
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 <osipparser2/internal.h>
21
22 #include <osipparser2/osip_port.h>
23 #include <osipparser2/osip_message.h>
24 #include <osipparser2/osip_parser.h>
25 #include "parser.h"
26
27 #ifndef MINISIZE
28
osip_message_set_error_info(osip_message_t * sip,const char * hvalue)29 int osip_message_set_error_info(osip_message_t *sip, const char *hvalue) {
30 osip_error_info_t *error_info;
31 int i;
32
33 if (hvalue == NULL || hvalue[0] == '\0')
34 return OSIP_SUCCESS;
35
36 i = osip_error_info_init(&error_info);
37
38 if (i != 0)
39 return i;
40
41 i = osip_error_info_parse(error_info, hvalue);
42
43 if (i != 0) {
44 osip_error_info_free(error_info);
45 return i;
46 }
47
48 sip->message_property = 2;
49 osip_list_add(&sip->error_infos, error_info, -1);
50 return OSIP_SUCCESS;
51 }
52
osip_message_get_error_info(const osip_message_t * sip,int pos,osip_error_info_t ** dest)53 int osip_message_get_error_info(const osip_message_t *sip, int pos, osip_error_info_t **dest) {
54 osip_error_info_t *error_info;
55
56 *dest = NULL;
57
58 if (osip_list_size(&sip->error_infos) <= pos)
59 return OSIP_UNDEFINED_ERROR; /* does not exist */
60
61 error_info = (osip_error_info_t *) osip_list_get(&sip->error_infos, pos);
62 *dest = error_info;
63 return pos;
64 }
65
66 #endif
67