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_content_encoding.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
#include "parser.h"
26
27
#ifndef MINISIZE
28
29
/* content-Encoding = token
30
   token possible values are gzip,compress,deflate
31
*/
32
5.92k
int osip_message_set_content_encoding(osip_message_t *sip, const char *hvalue) {
33
5.92k
  osip_content_encoding_t *content_encoding;
34
5.92k
  int i;
35
36
5.92k
  if (hvalue == NULL || hvalue[0] == '\0')
37
562
    return OSIP_SUCCESS;
38
39
5.36k
  i = osip_content_encoding_init(&content_encoding);
40
41
5.36k
  if (i != 0)
42
0
    return i;
43
44
5.36k
  i = osip_content_encoding_parse(content_encoding, hvalue);
45
46
5.36k
  if (i != 0) {
47
0
    osip_content_encoding_free(content_encoding);
48
0
    return i;
49
0
  }
50
51
5.36k
  sip->message_property = 2;
52
5.36k
  osip_list_add(&sip->content_encodings, content_encoding, -1);
53
5.36k
  return OSIP_SUCCESS;
54
5.36k
}
55
56
0
int osip_message_get_content_encoding(const osip_message_t *sip, int pos, osip_content_encoding_t **dest) {
57
0
  osip_content_encoding_t *ce;
58
59
0
  *dest = NULL;
60
61
0
  if (osip_list_size(&sip->content_encodings) <= pos)
62
0
    return OSIP_UNDEFINED_ERROR; /* does not exist */
63
64
0
  ce = (osip_content_encoding_t *) osip_list_get(&sip->content_encodings, pos);
65
0
  *dest = ce;
66
0
  return pos;
67
0
}
68
69
#endif