forked from iafonov/multipart-parser-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultipart_parser.h
38 lines (29 loc) · 1.15 KB
/
multipart_parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Based on node-formidable by Felix Geisendörfer
* Igor Afonov - [email protected] - 2012
* MIT License - http://www.opensource.org/licenses/mit-license.php
*/
#ifndef _multipart_parser_h
#define _multipart_parser_h
#include <sys/types.h>
typedef struct multipart_parser multipart_parser;
typedef struct multipart_parser_settings multipart_parser_settings;
typedef struct multipart_parser_state multipart_parser_state;
typedef int (*multipart_data_cb) (multipart_parser*, const char *at, size_t length);
typedef int (*multipart_notify_cb) (multipart_parser*);
struct multipart_parser {
void* data;
multipart_parser_state* _s;
};
struct multipart_parser_settings {
multipart_data_cb on_header_field;
multipart_data_cb on_header_value;
multipart_data_cb on_part_data;
multipart_notify_cb on_part_data_begin;
multipart_notify_cb on_headers_complete;
multipart_notify_cb on_part_data_end;
multipart_notify_cb on_body_end;
};
multipart_parser* init_multipart_parser(char *boundary, multipart_parser_settings* settings);
void free_multipart_parser(multipart_parser* p);
int multipart_parser_execute(multipart_parser* p, const char *buf, size_t len);
#endif