add some error logging
[m6w6/ext-http] / php_http_header_parser.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifndef PHP_HTTP_HEADER_PARSER_H
14 #define PHP_HTTP_HEADER_PARSER_H
15
16 #include "php_http_info.h"
17
18 typedef enum php_http_header_parser_state {
19 PHP_HTTP_HEADER_PARSER_STATE_FAILURE = FAILURE,
20 PHP_HTTP_HEADER_PARSER_STATE_START = 0,
21 PHP_HTTP_HEADER_PARSER_STATE_KEY,
22 PHP_HTTP_HEADER_PARSER_STATE_VALUE,
23 PHP_HTTP_HEADER_PARSER_STATE_VALUE_EX,
24 PHP_HTTP_HEADER_PARSER_STATE_HEADER_DONE,
25 PHP_HTTP_HEADER_PARSER_STATE_DONE
26 } php_http_header_parser_state_t;
27
28 #define PHP_HTTP_HEADER_PARSER_CLEANUP 0x1
29
30 typedef struct php_http_header_parser {
31 zend_ptr_stack stack;
32 php_http_info_t info;
33 struct {
34 char *str;
35 size_t len;
36 } _key;
37 struct {
38 char *str;
39 size_t len;
40 } _val;
41 #ifdef ZTS
42 void ***ts;
43 #endif
44 } php_http_header_parser_t;
45
46 PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_DC);
47 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_push(php_http_header_parser_t *parser, unsigned argc, ...);
48 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_is(php_http_header_parser_t *parser);
49 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_pop(php_http_header_parser_t *parser);
50 PHP_HTTP_API void php_http_header_parser_dtor(php_http_header_parser_t *parser);
51 PHP_HTTP_API void php_http_header_parser_free(php_http_header_parser_t **parser);
52 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg);
53 PHP_HTTP_API php_http_header_parser_state_t php_http_headerparser_parse_stream(php_http_header_parser_t *parser, php_http_buffer_t *buffer, php_stream *s, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg);
54
55 typedef struct php_http_header_parser_object {
56 zend_object zo;
57 zend_object_value zv;
58 php_http_buffer_t *buffer;
59 php_http_header_parser_t *parser;
60 } php_http_header_parser_object_t;
61
62 PHP_HTTP_API zend_class_entry *php_http_header_parser_class_entry;
63
64 PHP_MINIT_FUNCTION(http_header_parser);
65
66 zend_object_value php_http_header_parser_object_new(zend_class_entry *ce TSRMLS_DC);
67 zend_object_value php_http_header_parser_object_new_ex(zend_class_entry *ce, php_http_header_parser_t *parser, php_http_header_parser_object_t **ptr TSRMLS_DC);
68 void php_http_header_parser_object_free(void *object TSRMLS_DC);
69
70 #endif /* PHP_HTTP_HEADER_PARSER_H */
71
72 /*
73 * Local variables:
74 * tab-width: 4
75 * c-basic-offset: 4
76 * End:
77 * vim600: noet sw=4 ts=4 fdm=marker
78 * vim<600: noet sw=4 ts=4
79 */
80