You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. /* Based on node-formidable by Felix Geisendörfer
  2. * Igor Afonov - afonov@gmail.com - 2012
  3. * MIT License - http://www.opensource.org/licenses/mit-license.php
  4. */
  5. #ifndef _multipart_parser_h
  6. #define _multipart_parser_h
  7. #ifdef __cplusplus
  8. extern "C"
  9. {
  10. #endif
  11. #include <stdlib.h>
  12. #include <ctype.h>
  13. typedef struct multipart_parser multipart_parser;
  14. typedef struct multipart_parser_settings multipart_parser_settings;
  15. typedef struct multipart_parser_state multipart_parser_state;
  16. typedef int (*multipart_data_cb) (multipart_parser*, const char *at, size_t length);
  17. typedef int (*multipart_notify_cb) (multipart_parser*);
  18. struct multipart_parser_settings {
  19. multipart_data_cb on_header_field;
  20. multipart_data_cb on_header_value;
  21. multipart_data_cb on_part_data;
  22. multipart_notify_cb on_part_data_begin;
  23. multipart_notify_cb on_headers_complete;
  24. multipart_notify_cb on_part_data_end;
  25. multipart_notify_cb on_body_end;
  26. };
  27. multipart_parser* multipart_parser_init
  28. (const char *boundary, const multipart_parser_settings* settings);
  29. void multipart_parser_free(multipart_parser* p);
  30. size_t multipart_parser_execute(multipart_parser* p, const char *buf, size_t len);
  31. void multipart_parser_set_data(multipart_parser* p, void* data);
  32. void * multipart_parser_get_data(multipart_parser* p);
  33. #ifdef __cplusplus
  34. } /* extern "C" */
  35. #endif
  36. #endif