Coverage Report

Created: 2026-10-28 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/osip/src/osipparser2/osip_mime_version.c
Line
Count
Source
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
26
/* adds the mime_version header to message.       */
27
/* INPUT : const char *hvalue | value of header.    */
28
/* OUTPUT: osip_message_t *sip | structure to save results.  */
29
/* returns -1 on error. */
30
3.21k
int osip_message_set_mime_version(osip_message_t *sip, const char *hvalue) {
31
3.21k
  int i;
32
33
3.21k
  if (hvalue == NULL || hvalue[0] == '\0')
34
3.01k
    return OSIP_SUCCESS;
35
36
203
  if (sip->mime_version != NULL)
37
194
    return OSIP_SYNTAXERROR;
38
39
9
  i = osip_mime_version_init(&(sip->mime_version));
40
41
9
  if (i != 0)
42
0
    return i;
43
44
9
  sip->message_property = 2;
45
9
  i = osip_mime_version_parse(sip->mime_version, hvalue);
46
47
9
  if (i != 0) {
48
0
    osip_mime_version_free(sip->mime_version);
49
0
    sip->mime_version = NULL;
50
0
    return i;
51
0
  }
52
53
9
  return OSIP_SUCCESS;
54
9
}
55
56
#ifndef MINISIZE
57
/* returns the mime_version header.            */
58
/* INPUT : osip_message_t *sip | sip message.   */
59
/* returns null on error. */
60
0
osip_mime_version_t *osip_message_get_mime_version(const osip_message_t *sip) {
61
0
  return sip->mime_version;
62
0
}
63
#endif