http  1.12.11devel
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
http_header.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef HTTP_HEADER_H
26 
27 #define HTTP_HEADER_H
28 
38 #ifndef SU_ALLOC_H
39 #include <sofia-sip/su_alloc.h>
40 #endif
41 
42 #ifndef SU_TAG_H
43 #include <sofia-sip/su_tag.h>
44 #endif
45 
46 #ifndef HTTP_H
47 #include <sofia-sip/http.h>
48 #endif
49 
50 #ifndef MSG_HEADER_H
51 #include <sofia-sip/msg_header.h>
52 #endif
53 
54 SOFIA_BEGIN_DECLS
55 
56 /* ----------------------------------------------------------------------
57  * 1) Macros
58  */
59 
61 #define HTTP_HEADER_INIT(h, http_class, size) \
62  ((void)memset((h), 0, (size)), \
63  (void)(((msg_common_t *)(h))->h_class = (http_class)), \
64  (h))
65 
66 #define HTTP_METHOD_NAME(method, name) \
67  ((method) == http_method_unknown ? (name) : http_method_name(method, name))
68 
69 /* ----------------------------------------------------------------------
70  * 2) Variables
71  */
72 
73 SOFIAPUBVAR char const http_method_name_get[];
74 SOFIAPUBVAR char const http_method_name_post[];
75 SOFIAPUBVAR char const http_method_name_head[];
76 SOFIAPUBVAR char const http_method_name_options[];
77 SOFIAPUBVAR char const http_method_name_put[];
78 SOFIAPUBVAR char const http_method_name_delete[];
79 SOFIAPUBVAR char const http_method_name_trace[];
80 SOFIAPUBVAR char const http_method_name_connect[];
81 
83 SOFIAPUBVAR char const http_version_0_9[];
84 
86 SOFIAPUBVAR char const http_version_1_0[];
87 
89 SOFIAPUBVAR char const http_version_1_1[];
90 
91 #define HTTP_VERSION_CURRENT http_version_1_1
92 
93 /* ----------------------------------------------------------------------
94  * 3) Prototypes
95  */
96 
99 
102 
105 
108 
110 SOFIAPUBFUN int http_add_make(msg_t *msg, http_t *http,
111  msg_hclass_t *hc, char const *s);
112 
115  char const *fmt, ...);
116 
118 SOFIAPUBFUN int http_add_tl(msg_t *msg, http_t *http,
119  tag_type_t tag, tag_value_t value, ...);
120 
123 
126  int status, char const *phrase,
127  http_t const *request);
128 
130 SOFIAPUBFUN char const *http_method_name(http_method_t method,
131  char const *name);
132 
134 SOFIAPUBFUN http_method_t http_method_code(char const *name);
135 
136 #if !SU_HAVE_INLINE
140 SOFIAPUBFUN char const *http_header_name(http_header_t const *h, int compact);
142 SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home,
143  uint32_t n);
144 SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home,
145  void const *data, usize_t len);
146 SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
147 #endif
148 
149 SOFIAPUBFUN http_header_t *http_header_format(su_home_t *home, msg_hclass_t *,
150  char const *fmt, ...);
151 
152 
155  http_method_t method,
156  const char *name,
157  url_string_t const *url,
158  char const *version);
159 
162  unsigned status,
163  char const *phrase,
164  char const *version);
165 
168  char const *host,
169  char const *port);
170 
173 
176  http_time_t delta);
177 
179 SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
180 
182 SOFIAPUBFUN issize_t http_query_parse(char *query,
183  /* char const *key, char **return_value, */
184  ...);
185 
186 /* ----------------------------------------------------------------------
187  * 4) Inlined functions
188  */
189 
190 #if SU_HAVE_INLINE
191 
192 su_inline
194 {
195  return (http_t *)msg_public(msg, HTTP_PROTOCOL_TAG);
196 }
197 
216 su_inline
218 {
219  return msg_header_insert(msg, (msg_pub_t *)http, (msg_header_t *)h);
220 }
221 
223 su_inline
225 {
226  return msg_header_remove(msg, (msg_pub_t *)http, (msg_header_t *)h);
227 }
228 
230 su_inline
231 char const *http_header_name(http_header_t const *h, int compact)
232 {
233  if (compact && h->sh_class->hc_short[0])
234  return h->sh_class->hc_short;
235  else
236  return h->sh_class->hc_name;
237 }
238 
240 su_inline
242 {
243  return h && h != HTTP_NONE ? h->sh_class->hc_size + (char *)h : NULL;
244 }
245 
246 su_inline
247 http_content_length_t *http_content_length_create(su_home_t *home, uint32_t n)
248 {
249  return msg_content_length_create(home, n);
250 }
251 
252 su_inline
253 http_payload_t *http_payload_create(su_home_t *home, void const *data, isize_t len)
254 {
255  return msg_payload_create(home, data, len);
256 }
257 
258 su_inline
259 http_separator_t *http_separator_create(su_home_t *home)
260 {
261  return msg_separator_create(home);
262 }
263 #endif
264 
265 SOFIA_END_DECLS
266 
267 #ifndef HTTP_PROTOS_H
268 #include <sofia-sip/http_protos.h>
269 #endif
270 
271 #endif /* !defined(HTTP_HEADER_H) */

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.