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 #ifndef _OSIP_HEADER_H_
21 #define _OSIP_HEADER_H_
22 
23 #include <osipparser2/osip_uri.h>
24 
25 /**
26  * @file osip_header.h
27  * @brief oSIP osip_header definition.
28  *
29  */
30 
31 /**
32  * @defgroup oSIP_HEADER oSIP header definition.
33  * @ingroup oSIP_HEADERS
34  * @{
35  */
36 
37 /**
38  * Structure for 'unknown' headers.
39  * NOTE: 'unknown' header' are used in oSIP for all header that are not
40  * defined by oSIP in the osip_message_t structure. This means that all
41  * 'unknown' header has to be handled with the API related to this
42  * structure.
43  * @var osip_header_t
44  */
45 typedef struct osip_header osip_header_t;
46 
47 /**
48  * Definition of a generic sip header.
49  * @struct osip_header
50  */
51 struct osip_header {
52   char *hname;  /**< Name of header */
53   char *hvalue; /**< Value for header */
54 };
55 
56 /**
57  * Structure for generic parameter headers.
58  * Generic parameter are used in a lot of headers. (To, From, Route,
59  * Record-Route...) All those headers use a common API but this is
60  * hidden by MACROs that you can be found in smsg.h.
61  * @var osip_generic_param_t
62  */
63 typedef osip_uri_param_t osip_generic_param_t;
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /**
70  * Allocate a header element.
71  * @param header The element to work on.
72  */
73 int osip_header_init(osip_header_t **header);
74 /**
75  * Free a header element.
76  * @param header The element to work on.
77  */
78 void osip_header_free(osip_header_t *header);
79 /**
80  * Get a string representation of a header element.
81  * @param header The element to work on.
82  * @param dest A pointer on the new allocated buffer.
83  */
84 int osip_header_to_str(const osip_header_t *header, char **dest);
85 /**
86  * Get the token name a header element.
87  * @param header The element to work on.
88  */
89 char *osip_header_get_name(const osip_header_t *header);
90 /**
91  * Set the token name a header element.
92  * @param header The element to work on.
93  * @param pname The token name to set.
94  */
95 void osip_header_set_name(osip_header_t *header, char *pname);
96 /**
97  * Get the token value a header element.
98  * @param header The element to work on.
99  */
100 char *osip_header_get_value(const osip_header_t *header);
101 /**
102  * Set the token value a header element.
103  * @param header The element to work on.
104  * @param pvalue The token value to set.
105  */
106 void osip_header_set_value(osip_header_t *header, char *pvalue);
107 /**
108  * Clone a header element.
109  * @param header The element to work on.
110  * @param dest A pointer on the copy of the element.
111  */
112 int osip_header_clone(const osip_header_t *header, osip_header_t **dest);
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 /** @} */
119 
120 #endif
121