http  1.12.11devel
http_protos.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_PROTOS_H
27 #define HTTP_PROTOS_H
28 
38 #include <sofia-sip/su_config.h>
39 
40 #ifndef HTTP_HEADER_H
41 #include <sofia-sip/http_header.h>
42 #endif
43 #ifndef HTTP_HCLASSES_H
45 #endif
46 
47 #define http_header_make(h, c, s) \
48  ((http_header_t *)msg_header_make((h), (c), (s)))
49 #define http_header_vformat(h, c, f, a) \
50  ((http_header_t *)msg_header_vformat((h), (c), (f), (a)))
51 
52 SOFIA_BEGIN_DECLS
53 
54 /* Declare internal prototypes for request line */
55 
58 enum {
61 };
62 
72 
73 #ifndef HTTP_HCLASSES_ONLY
74 
77 
80 
92 #define HTTP_REQUEST_INIT() HTTP_HDR_INIT(request)
93 
107 #if SU_HAVE_INLINE
109 {
111 }
112 #else
113 #define http_request_init(x) \
114  HTTP_HEADER_INIT(x, http_request_class, sizeof(http_request_t))
115 #endif
116 
130 #if SU_HAVE_INLINE
131 su_inline
132 int http_is_request(http_header_t const *header)
133 {
134  return header && header->sh_class->hc_hash == http_request_hash;
135 }
136 #else
137 #define http_is_request(h) \
138  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_request_hash)
139 #endif
140 
168 #if SU_HAVE_INLINE
169 su_inline
170 #endif
172  http_request_t const *hdr)
173  __attribute__((__malloc__));
174 
203 #if SU_HAVE_INLINE
204 su_inline
205 #endif
207  http_request_t const *hdr)
208  __attribute__((__malloc__));
209 
228 #if SU_HAVE_INLINE
229 su_inline
230 #endif
231 http_request_t *http_request_make(su_home_t *home, char const *s)
232  __attribute__((__malloc__));
233 
256 #if SU_HAVE_INLINE
257 su_inline
258 #endif
259 http_request_t *http_request_format(su_home_t *home, char const *fmt, ...)
260  __attribute__((__malloc__, __format__ (printf, 2, 3)));
261 
262 
263 /* Inlined functions */
264 #if SU_HAVE_INLINE
265 su_inline
266 http_request_t *http_request_format(su_home_t *home, char const *fmt, ...)
267 {
268  http_header_t *h;
269  va_list ap;
270 
271  va_start(ap, fmt);
272  h = http_header_vformat(home, http_request_class, fmt, ap);
273  va_end(ap);
274 
275  return (http_request_t *)h;
276 }
277 
278 su_inline
280 {
281  return (http_request_t *)
283 }
284 
285 su_inline
287 {
288  return (http_request_t *)
290 }
291 
292 su_inline
294 {
295  return (http_request_t *)http_header_make(home, http_request_class, s);
296 }
297 #endif
298 
299 #endif /* !define HTTP_HCLASSES_ONLY */
300 
304 /* Declare internal prototypes for status line */
305 
308 enum {
310  http_status_hash = -2
311 };
312 
322 
323 #ifndef HTTP_HCLASSES_ONLY
324 
327 
330 
342 #define HTTP_STATUS_INIT() HTTP_HDR_INIT(status)
343 
357 #if SU_HAVE_INLINE
359 {
361 }
362 #else
363 #define http_status_init(x) \
364  HTTP_HEADER_INIT(x, http_status_class, sizeof(http_status_t))
365 #endif
366 
380 #if SU_HAVE_INLINE
381 su_inline
382 int http_is_status(http_header_t const *header)
383 {
384  return header && header->sh_class->hc_hash == http_status_hash;
385 }
386 #else
387 #define http_is_status(h) \
388  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_status_hash)
389 #endif
390 
418 #if SU_HAVE_INLINE
419 su_inline
420 #endif
422  http_status_t const *hdr)
423  __attribute__((__malloc__));
424 
453 #if SU_HAVE_INLINE
454 su_inline
455 #endif
457  http_status_t const *hdr)
458  __attribute__((__malloc__));
459 
478 #if SU_HAVE_INLINE
479 su_inline
480 #endif
481 http_status_t *http_status_make(su_home_t *home, char const *s)
482  __attribute__((__malloc__));
483 
506 #if SU_HAVE_INLINE
507 su_inline
508 #endif
509 http_status_t *http_status_format(su_home_t *home, char const *fmt, ...)
510  __attribute__((__malloc__, __format__ (printf, 2, 3)));
511 
512 
513 /* Inlined functions */
514 #if SU_HAVE_INLINE
515 su_inline
516 http_status_t *http_status_format(su_home_t *home, char const *fmt, ...)
517 {
518  http_header_t *h;
519  va_list ap;
520 
521  va_start(ap, fmt);
522  h = http_header_vformat(home, http_status_class, fmt, ap);
523  va_end(ap);
524 
525  return (http_status_t *)h;
526 }
527 
528 su_inline
530 {
531  return (http_status_t *)
533 }
534 
535 su_inline
537 {
538  return (http_status_t *)
540 }
541 
542 su_inline
544 {
545  return (http_status_t *)http_header_make(home, http_status_class, s);
546 }
547 #endif
548 
549 #endif /* !define HTTP_HCLASSES_ONLY */
550 
554 /* Declare internal prototypes for Accept header */
555 
558 enum {
560  http_accept_hash = 29344
561 };
562 
572 
573 #ifndef HTTP_HCLASSES_ONLY
574 
577 
580 
592 #define HTTP_ACCEPT_INIT() HTTP_HDR_INIT(accept)
593 
607 #if SU_HAVE_INLINE
609 {
611 }
612 #else
613 #define http_accept_init(x) \
614  HTTP_HEADER_INIT(x, http_accept_class, sizeof(http_accept_t))
615 #endif
616 
630 #if SU_HAVE_INLINE
631 su_inline
632 int http_is_accept(http_header_t const *header)
633 {
634  return header && header->sh_class->hc_hash == http_accept_hash;
635 }
636 #else
637 #define http_is_accept(h) \
638  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_accept_hash)
639 #endif
640 
668 #if SU_HAVE_INLINE
669 su_inline
670 #endif
672  http_accept_t const *hdr)
673  __attribute__((__malloc__));
674 
703 #if SU_HAVE_INLINE
704 su_inline
705 #endif
707  http_accept_t const *hdr)
708  __attribute__((__malloc__));
709 
728 #if SU_HAVE_INLINE
729 su_inline
730 #endif
731 http_accept_t *http_accept_make(su_home_t *home, char const *s)
732  __attribute__((__malloc__));
733 
756 #if SU_HAVE_INLINE
757 su_inline
758 #endif
759 http_accept_t *http_accept_format(su_home_t *home, char const *fmt, ...)
760  __attribute__((__malloc__, __format__ (printf, 2, 3)));
761 
762 
763 /* Inlined functions */
764 #if SU_HAVE_INLINE
765 su_inline
766 http_accept_t *http_accept_format(su_home_t *home, char const *fmt, ...)
767 {
768  http_header_t *h;
769  va_list ap;
770 
771  va_start(ap, fmt);
772  h = http_header_vformat(home, http_accept_class, fmt, ap);
773  va_end(ap);
774 
775  return (http_accept_t *)h;
776 }
777 
778 su_inline
780 {
781  return (http_accept_t *)
783 }
784 
785 su_inline
787 {
788  return (http_accept_t *)
790 }
791 
792 su_inline
794 {
795  return (http_accept_t *)http_header_make(home, http_accept_class, s);
796 }
797 #endif
798 
799 #endif /* !define HTTP_HCLASSES_ONLY */
800 
804 /* Declare internal prototypes for Accept-Charset header */
805 
808 enum {
811 };
812 
822 
823 #ifndef HTTP_HCLASSES_ONLY
824 
827 
830 
842 #define HTTP_ACCEPT_CHARSET_INIT() HTTP_HDR_INIT(accept_charset)
843 
857 #if SU_HAVE_INLINE
858 su_inline http_accept_charset_t *http_accept_charset_init(http_accept_charset_t x[1])
859 {
860  return HTTP_HEADER_INIT(x, http_accept_charset_class, sizeof(http_accept_charset_t));
861 }
862 #else
863 #define http_accept_charset_init(x) \
864  HTTP_HEADER_INIT(x, http_accept_charset_class, sizeof(http_accept_charset_t))
865 #endif
866 
880 #if SU_HAVE_INLINE
881 su_inline
883 {
884  return header && header->sh_class->hc_hash == http_accept_charset_hash;
885 }
886 #else
887 #define http_is_accept_charset(h) \
888  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_accept_charset_hash)
889 #endif
890 
918 #if SU_HAVE_INLINE
919 su_inline
920 #endif
921 http_accept_charset_t *http_accept_charset_dup(su_home_t *home,
922  http_accept_charset_t const *hdr)
923  __attribute__((__malloc__));
924 
953 #if SU_HAVE_INLINE
954 su_inline
955 #endif
956 http_accept_charset_t *http_accept_charset_copy(su_home_t *home,
957  http_accept_charset_t const *hdr)
958  __attribute__((__malloc__));
959 
978 #if SU_HAVE_INLINE
979 su_inline
980 #endif
981 http_accept_charset_t *http_accept_charset_make(su_home_t *home, char const *s)
982  __attribute__((__malloc__));
983 
1006 #if SU_HAVE_INLINE
1007 su_inline
1008 #endif
1009 http_accept_charset_t *http_accept_charset_format(su_home_t *home, char const *fmt, ...)
1010  __attribute__((__malloc__, __format__ (printf, 2, 3)));
1011 
1012 
1013 /* Inlined functions */
1014 #if SU_HAVE_INLINE
1015 su_inline
1016 http_accept_charset_t *http_accept_charset_format(su_home_t *home, char const *fmt, ...)
1017 {
1018  http_header_t *h;
1019  va_list ap;
1020 
1021  va_start(ap, fmt);
1022  h = http_header_vformat(home, http_accept_charset_class, fmt, ap);
1023  va_end(ap);
1024 
1025  return (http_accept_charset_t *)h;
1026 }
1027 
1028 su_inline
1029 http_accept_charset_t *http_accept_charset_dup(su_home_t *home, http_accept_charset_t const *o)
1030 {
1031  return (http_accept_charset_t *)
1033 }
1034 
1035 su_inline
1036 http_accept_charset_t *http_accept_charset_copy(su_home_t *home, http_accept_charset_t const *o)
1037 {
1038  return (http_accept_charset_t *)
1040 }
1041 
1042 su_inline
1043 http_accept_charset_t *http_accept_charset_make(su_home_t *home, char const *s)
1044 {
1045  return (http_accept_charset_t *)http_header_make(home, http_accept_charset_class, s);
1046 }
1047 #endif
1048 
1049 #endif /* !define HTTP_HCLASSES_ONLY */
1050 
1054 /* Declare internal prototypes for Accept-Encoding header */
1055 
1058 enum {
1061 };
1062 
1072 
1073 #ifndef HTTP_HCLASSES_ONLY
1074 
1077 
1080 
1092 #define HTTP_ACCEPT_ENCODING_INIT() HTTP_HDR_INIT(accept_encoding)
1093 
1107 #if SU_HAVE_INLINE
1108 su_inline http_accept_encoding_t *http_accept_encoding_init(http_accept_encoding_t x[1])
1109 {
1110  return HTTP_HEADER_INIT(x, http_accept_encoding_class, sizeof(http_accept_encoding_t));
1111 }
1112 #else
1113 #define http_accept_encoding_init(x) \
1114  HTTP_HEADER_INIT(x, http_accept_encoding_class, sizeof(http_accept_encoding_t))
1115 #endif
1116 
1130 #if SU_HAVE_INLINE
1131 su_inline
1133 {
1134  return header && header->sh_class->hc_hash == http_accept_encoding_hash;
1135 }
1136 #else
1137 #define http_is_accept_encoding(h) \
1138  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_accept_encoding_hash)
1139 #endif
1140 
1168 #if SU_HAVE_INLINE
1169 su_inline
1170 #endif
1171 http_accept_encoding_t *http_accept_encoding_dup(su_home_t *home,
1172  http_accept_encoding_t const *hdr)
1173  __attribute__((__malloc__));
1174 
1203 #if SU_HAVE_INLINE
1204 su_inline
1205 #endif
1206 http_accept_encoding_t *http_accept_encoding_copy(su_home_t *home,
1207  http_accept_encoding_t const *hdr)
1208  __attribute__((__malloc__));
1209 
1228 #if SU_HAVE_INLINE
1229 su_inline
1230 #endif
1231 http_accept_encoding_t *http_accept_encoding_make(su_home_t *home, char const *s)
1232  __attribute__((__malloc__));
1233 
1256 #if SU_HAVE_INLINE
1257 su_inline
1258 #endif
1259 http_accept_encoding_t *http_accept_encoding_format(su_home_t *home, char const *fmt, ...)
1260  __attribute__((__malloc__, __format__ (printf, 2, 3)));
1261 
1262 
1263 /* Inlined functions */
1264 #if SU_HAVE_INLINE
1265 su_inline
1266 http_accept_encoding_t *http_accept_encoding_format(su_home_t *home, char const *fmt, ...)
1267 {
1268  http_header_t *h;
1269  va_list ap;
1270 
1271  va_start(ap, fmt);
1272  h = http_header_vformat(home, http_accept_encoding_class, fmt, ap);
1273  va_end(ap);
1274 
1275  return (http_accept_encoding_t *)h;
1276 }
1277 
1278 su_inline
1279 http_accept_encoding_t *http_accept_encoding_dup(su_home_t *home, http_accept_encoding_t const *o)
1280 {
1281  return (http_accept_encoding_t *)
1283 }
1284 
1285 su_inline
1286 http_accept_encoding_t *http_accept_encoding_copy(su_home_t *home, http_accept_encoding_t const *o)
1287 {
1288  return (http_accept_encoding_t *)
1290 }
1291 
1292 su_inline
1293 http_accept_encoding_t *http_accept_encoding_make(su_home_t *home, char const *s)
1294 {
1295  return (http_accept_encoding_t *)http_header_make(home, http_accept_encoding_class, s);
1296 }
1297 #endif
1298 
1299 #endif /* !define HTTP_HCLASSES_ONLY */
1300 
1304 /* Declare internal prototypes for Accept-Language header */
1305 
1308 enum {
1311 };
1312 
1322 
1323 #ifndef HTTP_HCLASSES_ONLY
1324 
1327 
1330 
1342 #define HTTP_ACCEPT_LANGUAGE_INIT() HTTP_HDR_INIT(accept_language)
1343 
1357 #if SU_HAVE_INLINE
1358 su_inline http_accept_language_t *http_accept_language_init(http_accept_language_t x[1])
1359 {
1360  return HTTP_HEADER_INIT(x, http_accept_language_class, sizeof(http_accept_language_t));
1361 }
1362 #else
1363 #define http_accept_language_init(x) \
1364  HTTP_HEADER_INIT(x, http_accept_language_class, sizeof(http_accept_language_t))
1365 #endif
1366 
1380 #if SU_HAVE_INLINE
1381 su_inline
1383 {
1384  return header && header->sh_class->hc_hash == http_accept_language_hash;
1385 }
1386 #else
1387 #define http_is_accept_language(h) \
1388  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_accept_language_hash)
1389 #endif
1390 
1418 #if SU_HAVE_INLINE
1419 su_inline
1420 #endif
1421 http_accept_language_t *http_accept_language_dup(su_home_t *home,
1422  http_accept_language_t const *hdr)
1423  __attribute__((__malloc__));
1424 
1453 #if SU_HAVE_INLINE
1454 su_inline
1455 #endif
1456 http_accept_language_t *http_accept_language_copy(su_home_t *home,
1457  http_accept_language_t const *hdr)
1458  __attribute__((__malloc__));
1459 
1478 #if SU_HAVE_INLINE
1479 su_inline
1480 #endif
1481 http_accept_language_t *http_accept_language_make(su_home_t *home, char const *s)
1482  __attribute__((__malloc__));
1483 
1506 #if SU_HAVE_INLINE
1507 su_inline
1508 #endif
1509 http_accept_language_t *http_accept_language_format(su_home_t *home, char const *fmt, ...)
1510  __attribute__((__malloc__, __format__ (printf, 2, 3)));
1511 
1512 
1513 /* Inlined functions */
1514 #if SU_HAVE_INLINE
1515 su_inline
1516 http_accept_language_t *http_accept_language_format(su_home_t *home, char const *fmt, ...)
1517 {
1518  http_header_t *h;
1519  va_list ap;
1520 
1521  va_start(ap, fmt);
1522  h = http_header_vformat(home, http_accept_language_class, fmt, ap);
1523  va_end(ap);
1524 
1525  return (http_accept_language_t *)h;
1526 }
1527 
1528 su_inline
1529 http_accept_language_t *http_accept_language_dup(su_home_t *home, http_accept_language_t const *o)
1530 {
1531  return (http_accept_language_t *)
1533 }
1534 
1535 su_inline
1536 http_accept_language_t *http_accept_language_copy(su_home_t *home, http_accept_language_t const *o)
1537 {
1538  return (http_accept_language_t *)
1540 }
1541 
1542 su_inline
1543 http_accept_language_t *http_accept_language_make(su_home_t *home, char const *s)
1544 {
1545  return (http_accept_language_t *)http_header_make(home, http_accept_language_class, s);
1546 }
1547 #endif
1548 
1549 #endif /* !define HTTP_HCLASSES_ONLY */
1550 
1554 /* Declare internal prototypes for Accept-Ranges header */
1555 
1558 enum {
1560  http_accept_ranges_hash = 59733
1561 };
1562 
1572 
1573 #ifndef HTTP_HCLASSES_ONLY
1574 
1577 
1580 
1592 #define HTTP_ACCEPT_RANGES_INIT() HTTP_HDR_INIT(accept_ranges)
1593 
1607 #if SU_HAVE_INLINE
1609 {
1611 }
1612 #else
1613 #define http_accept_ranges_init(x) \
1614  HTTP_HEADER_INIT(x, http_accept_ranges_class, sizeof(http_accept_ranges_t))
1615 #endif
1616 
1630 #if SU_HAVE_INLINE
1631 su_inline
1633 {
1634  return header && header->sh_class->hc_hash == http_accept_ranges_hash;
1635 }
1636 #else
1637 #define http_is_accept_ranges(h) \
1638  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_accept_ranges_hash)
1639 #endif
1640 
1668 #if SU_HAVE_INLINE
1669 su_inline
1670 #endif
1672  http_accept_ranges_t const *hdr)
1673  __attribute__((__malloc__));
1674 
1703 #if SU_HAVE_INLINE
1704 su_inline
1705 #endif
1707  http_accept_ranges_t const *hdr)
1708  __attribute__((__malloc__));
1709 
1728 #if SU_HAVE_INLINE
1729 su_inline
1730 #endif
1732  __attribute__((__malloc__));
1733 
1756 #if SU_HAVE_INLINE
1757 su_inline
1758 #endif
1759 http_accept_ranges_t *http_accept_ranges_format(su_home_t *home, char const *fmt, ...)
1760  __attribute__((__malloc__, __format__ (printf, 2, 3)));
1761 
1762 
1763 /* Inlined functions */
1764 #if SU_HAVE_INLINE
1765 su_inline
1767 {
1768  http_header_t *h;
1769  va_list ap;
1770 
1771  va_start(ap, fmt);
1772  h = http_header_vformat(home, http_accept_ranges_class, fmt, ap);
1773  va_end(ap);
1774 
1775  return (http_accept_ranges_t *)h;
1776 }
1777 
1778 su_inline
1780 {
1781  return (http_accept_ranges_t *)
1783 }
1784 
1785 su_inline
1787 {
1788  return (http_accept_ranges_t *)
1790 }
1791 
1792 su_inline
1794 {
1795  return (http_accept_ranges_t *)http_header_make(home, http_accept_ranges_class, s);
1796 }
1797 #endif
1798 
1799 #endif /* !define HTTP_HCLASSES_ONLY */
1800 
1804 /* Declare internal prototypes for Allow header */
1805 
1808 enum {
1810  http_allow_hash = 44519
1811 };
1812 
1822 
1823 #ifndef HTTP_HCLASSES_ONLY
1824 
1827 
1830 
1842 #define HTTP_ALLOW_INIT() HTTP_HDR_INIT(allow)
1843 
1857 #if SU_HAVE_INLINE
1859 {
1860  return HTTP_HEADER_INIT(x, http_allow_class, sizeof(http_allow_t));
1861 }
1862 #else
1863 #define http_allow_init(x) \
1864  HTTP_HEADER_INIT(x, http_allow_class, sizeof(http_allow_t))
1865 #endif
1866 
1880 #if SU_HAVE_INLINE
1881 su_inline
1882 int http_is_allow(http_header_t const *header)
1883 {
1884  return header && header->sh_class->hc_hash == http_allow_hash;
1885 }
1886 #else
1887 #define http_is_allow(h) \
1888  ((h) && ((msg_common_t *)(h))->h_class->hc_hash == http_allow_hash)
1889 #endif
1890 
1918 #if SU_HAVE_INLINE
1919 su_inline
1920 #endif
1922  http_allow_t const *hdr)
1923  __attribute__((__malloc__));
1924 
1953 #if SU_HAVE_INLINE
1954 su_inline
1955 #endif
1957  http_allow_t const *hdr)
1958  __attribute__((__malloc__));
1959 
1978 #if SU_HAVE_INLINE
1979 su_inline
1980 #endif
1981 http_allow_t *http_allow_make(su_home_t *home, char const *s)
1982  __attribute__((__malloc__));
1983 
2006 #if SU_HAVE_INLINE
2007 su_inline
2008 #endif
2009 http_allow_t *http_allow_format(su_home_t *home, char const *fmt, ...)
2010  __attribute__((__malloc__, __format__ (printf, 2, 3)));
2011 
2012 
2013 /* Inlined functions */
2014 #if SU_HAVE_INLINE
2015 su_inline
2016 http_allow_t *http_allow_format(su_home_t *home, char const *fmt, ...)
2017 {
2018  http_header_t *h;
2019  va_list ap;
2020 
2021  va_start(ap, fmt);
2022  h = http_header_vformat(home, http_allow_class, fmt, ap);
2023  va_end(ap);
2024 
2025  return (http_allow_t *)h;
2026 }
2027 
2028 su_inline
2030 {
2031  return (http_allow_t *)
2032  msg_header_dup_as(home, http_allow_class, (msg_header_t const *)o);
2033 }
2034 
2035 su_inline
2037 {
2038  return (http_allow_t *)
2040 }
2041 
2042 su_inline
2044 {
2045  return (http_allow_t *)http_header_make(home, http_allow_class, s);
2046 }
2047 #endif
2048 
2049 #endif /* !define HTTP_HCLASSES_ONLY */
2050 
2054 /* Declare internal prototypes for Authentication-Info header */
2055 
2058 enum {
2061 };
2062 
2072 
2073 #ifndef HTTP_HCLASSES_ONLY
2074 
2077