administrativa; [ci ignore]
[m6w6/ext-http] / php_http_message_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_MESSAGE_PARSER_H
14 #define PHP_HTTP_MESSAGE_PARSER_H
15
16 #include "php_http_header_parser.h"
17 #include "php_http_encoding.h"
18 #include "php_http_message.h"
19
20 typedef enum php_http_message_parser_state {
21 PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE = FAILURE,
22 PHP_HTTP_MESSAGE_PARSER_STATE_START = 0,
23 PHP_HTTP_MESSAGE_PARSER_STATE_HEADER,
24 PHP_HTTP_MESSAGE_PARSER_STATE_HEADER_DONE,
25 PHP_HTTP_MESSAGE_PARSER_STATE_BODY,
26 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_DUMB,
27 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_LENGTH,
28 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_CHUNKED,
29 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_DONE,
30 PHP_HTTP_MESSAGE_PARSER_STATE_UPDATE_CL,
31 PHP_HTTP_MESSAGE_PARSER_STATE_DONE
32 } php_http_message_parser_state_t;
33
34 #define PHP_HTTP_MESSAGE_PARSER_CLEANUP 0x1
35 #define PHP_HTTP_MESSAGE_PARSER_DUMB_BODIES 0x2
36 #define PHP_HTTP_MESSAGE_PARSER_EMPTY_REDIRECTS 0x4
37 #define PHP_HTTP_MESSAGE_PARSER_GREEDY 0x8
38
39 typedef struct php_http_message_parser {
40 php_http_header_parser_t header;
41 zend_ptr_stack stack;
42 size_t body_length;
43 php_http_message_t *message;
44 php_http_encoding_stream_t *dechunk;
45 php_http_encoding_stream_t *inflate;
46 #ifdef ZTS
47 void ***ts;
48 #endif
49 } php_http_message_parser_t;
50
51 PHP_HTTP_API php_http_message_parser_t *php_http_message_parser_init(php_http_message_parser_t *parser TSRMLS_DC);
52 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_push(php_http_message_parser_t *parser, unsigned argc, ...);
53 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_is(php_http_message_parser_t *parser);
54 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_pop(php_http_message_parser_t *parser);
55 PHP_HTTP_API void php_http_message_parser_dtor(php_http_message_parser_t *parser);
56 PHP_HTTP_API void php_http_message_parser_free(php_http_message_parser_t **parser);
57 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, php_http_message_t **message);
58 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse_stream(php_http_message_parser_t *parser, php_http_buffer_t *buffer, php_stream *s, unsigned flags, php_http_message_t **message);
59
60 typedef struct php_http_message_parser_object {
61 zend_object zo;
62 zend_object_value zv;
63 php_http_buffer_t *buffer;
64 php_http_message_parser_t *parser;
65 } php_http_message_parser_object_t;
66
67 PHP_HTTP_API zend_class_entry *php_http_message_parser_class_entry;
68
69 PHP_MINIT_FUNCTION(http_message_parser);
70
71 zend_object_value php_http_message_parser_object_new(zend_class_entry *ce TSRMLS_DC);
72 zend_object_value php_http_message_parser_object_new_ex(zend_class_entry *ce, php_http_message_parser_t *parser, php_http_message_parser_object_t **ptr TSRMLS_DC);
73 void php_http_message_parser_object_free(void *object TSRMLS_DC);
74
75 #endif
76
77 /*
78 * Local variables:
79 * tab-width: 4
80 * c-basic-offset: 4
81 * End:
82 * vim600: noet sw=4 ts=4 fdm=marker
83 * vim<600: noet sw=4 ts=4
84 */
85