http_parser.h 3.43 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

Pekka Pessi's avatar
Pekka Pessi committed
25 26
#ifndef HTTP_PARSER_H
/**Defined when <sofia-sip/http_parser.h> has been included.*/
Pekka Pessi's avatar
Pekka Pessi committed
27
#define HTTP_PARSER_H 
Pekka Pessi's avatar
Pekka Pessi committed
28
/**@file sofia-sip/http_parser.h
Pekka Pessi's avatar
Pekka Pessi committed
29 30 31 32 33 34 35 36
 * @brief Typedefs and prototypes used by HTTP parser.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Tue Jun 13 02:58:26 2000 ppessi
 */

#ifndef SU_ALLOC_H
37
#include <sofia-sip/su_alloc.h>
Pekka Pessi's avatar
Pekka Pessi committed
38 39 40
#endif

#ifndef MSG_H
41
#include <sofia-sip/msg.h>
Pekka Pessi's avatar
Pekka Pessi committed
42 43 44
#endif

#ifndef MSG_PARSER_H
45
#include <sofia-sip/msg_parser.h>
Pekka Pessi's avatar
Pekka Pessi committed
46 47 48
#endif

#ifndef HTTP_H
49
#include <sofia-sip/http.h>
Pekka Pessi's avatar
Pekka Pessi committed
50 51 52
#endif

#ifndef HTTP_HEADER_H
53
#include <sofia-sip/http_header.h>
Pekka Pessi's avatar
Pekka Pessi committed
54 55
#endif

56 57
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
58 59 60 61 62 63 64 65 66 67
/* ---------------------------------------------------------------------------
 * 1) Macros for defining boilerplate functions and structures for each header
 */

#define HTTP_HCLASS_TAG     HTTP_PROTOCOL_TAG
#define HTTP_HCLASS_TEST(x) ((x) && (x)->hc_tag == HTTP_PROTOCOL_TAG)
#define HTTP_HDR_TEST(x)    ((x)->sh_class && HTTP_HCLASS_TEST((x)->sh_class))

/** Define a header class for a HTTP header. */
#define HTTP_HEADER_CLASS(c, l, params, kind, dup) \
68
  MSG_HEADER_CLASS(http_, c, l, "", params, kind, http_ ## dup, http_no)
Pekka Pessi's avatar
Pekka Pessi committed
69 70 71

/** This is used by headers with no extra data in copy */
#define HTTP_HEADER_CLASS_G(c, l, kind) \
72
  MSG_HEADER_CLASS(http_, c, l, "", g_common, kind, msg_generic, http_no)
Pekka Pessi's avatar
Pekka Pessi committed
73 74 75

/** Define a header class for a msg_list_t kind of header */
#define HTTP_HEADER_CLASS_LIST(c, l, kind) \
76
  MSG_HEADER_CLASS(http_, c, l, "", k_items, kind, msg_list, http_no)
Pekka Pessi's avatar
Pekka Pessi committed
77 78 79

/** Define a authorization header class */
#define HTTP_HEADER_CLASS_AUTH(c, l, kind) \
80
  MSG_HEADER_CLASS(http_, c, l, "", au_params, kind, msg_auth, http_no)
Pekka Pessi's avatar
Pekka Pessi committed
81

Pekka Pessi's avatar
Pekka Pessi committed
82 83 84 85 86 87 88
#define http_numeric_dup_xtra msg_default_dup_xtra
#define http_numeric_dup_one  msg_default_dup_one

#define http_default_dup_xtra msg_default_dup_xtra
#define http_default_dup_one  msg_default_dup_one

#define http_no_update NULL
Pekka Pessi's avatar
Pekka Pessi committed
89 90 91 92 93 94

/* ---------------------------------------------------------------------------
 * 2) Prototypes for HTTP-specific decoding/encoding functions
 */

/* Version strings */
Pekka Pessi's avatar
Pekka Pessi committed
95
SOFIAPUBFUN int http_version_d(char **ss, char const **ver);
96
SOFIAPUBFUN isize_t http_version_xtra(char const *version);
Pekka Pessi's avatar
Pekka Pessi committed
97
SOFIAPUBFUN void http_version_dup(char **pp, char const **dd, char const *s);
Pekka Pessi's avatar
Pekka Pessi committed
98 99

/* Method */
Pekka Pessi's avatar
Pekka Pessi committed
100 101 102
SOFIAPUBFUN http_method_t http_method_d(char **ss, char const **nname);
SOFIAPUBFUN char const *http_method_name(http_method_t method,
					 char const *name);
Pekka Pessi's avatar
Pekka Pessi committed
103 104

/** Extract HTTP message body */
105 106
SOFIAPUBFUN issize_t http_extract_body(msg_t *, http_t *, 
				       char b[], isize_t bsiz, int eos);
Pekka Pessi's avatar
Pekka Pessi committed
107

108 109 110
SOFIA_END_DECLS

#endif /* !defined(HTTP_PARSER_H) */