56 MHD_PANIC (
_ (
"libmicrohttpd API violation.\n"));
138 const char *value_start,
139 const char *value_end,
140 const char *last_escape)
157 if ( (
NULL != last_escape) &&
158 (((
size_t) (value_end - last_escape)) <
sizeof (pp->
xbuf)) )
161 pp->
xbuf_pos = (size_t) (value_end - last_escape);
164 (
size_t) (value_end - last_escape));
165 value_end = last_escape;
167 while ( (value_start != value_end) ||
171 size_t delta = (size_t) (value_end - value_start);
186 value_start += delta;
192 (
'%' ==
xbuf[xoff - 1]) )
209 else if ( (xoff > 1) &&
210 (
'%' ==
xbuf[xoff - 2]) )
243 (
const char *) &pp[1],
280 const char *post_data,
281 size_t post_data_len)
283 char *kbuf = (
char *) &pp[1];
285 const char *start_key =
NULL;
286 const char *end_key =
NULL;
287 const char *start_value =
NULL;
288 const char *end_value =
NULL;
289 const char *last_escape =
NULL;
294 while ( ( (poff < post_data_len) ||
310 switch (post_data[poff])
331 start_key = &post_data[poff];
344 switch (post_data[poff])
349 end_key = &post_data[poff];
356 end_key = &post_data[poff];
364 end_key = &post_data[poff];
371 start_key = post_data;
378 if (
NULL == start_value)
379 start_value = &post_data[poff];
380 switch (post_data[poff])
388 end_value = &post_data[poff];
391 (start_value != end_value) )
407 end_value = &post_data[poff];
409 (start_value != end_value) )
418 last_escape = &post_data[poff];
442 switch (post_data[poff])
456 const size_t key_len = (size_t) (end_key - start_key);
526 if (
NULL != start_key)
531 end_key = &post_data[poff];
533 key_len = (size_t) (end_key - start_key);
549 if ( (
NULL != start_value) &&
560 if (
NULL == end_value)
561 end_value = &post_data[poff];
562 if ( (
NULL != last_escape) &&
563 (2 < (end_value - last_escape)) )
602 *suffix = strdup (&line[prefix_len]);
630 char *buf = (
char *) &pp[1];
640 if ( (0 != memcmp (
"--",
643 (0 != memcmp (&buf[2],
660 else if (dash == buf)
663 (*ioffptr) += (size_t) (dash - buf);
668 (*ioffptr) += 2 +
blen;
671 pp->
state = next_state;
694 if (
NULL != *destination)
698 while (
NULL != (spos = strstr (bpos, key)))
700 if ( (spos[klen] !=
'=') ||
702 (spos[-1] !=
' ') ) )
708 if (spos[klen + 1] !=
'"')
710 if (
NULL == (endv = strchr (&spos[klen + 2],
713 vlen = (size_t) (endv - spos) - klen - 1;
714 *destination = malloc (vlen);
715 if (
NULL == *destination)
717 (*destination)[vlen - 1] =
'\0';
718 memcpy (*destination,
746 char *buf = (
char *) &pp[1];
751 (buf[newline] !=
'\r') &&
752 (buf[newline] !=
'\n') )
765 pp->
state = next_state;
769 if (buf[newline] ==
'\r')
794 (*ioffptr) += newline + 1;
823 char *buf = (
char *) &pp[1];
834 r = memchr (&buf[newline],
842 newline = (size_t) (r - buf);
843 if (0 == memcmp (
"\r\n--",
852 if (0 != memcmp (&buf[newline + 4],
865 pp->
state = next_state;
867 (*ioffptr) +=
blen + 4;
877 if ( (0 == newline) &&
906 (*ioffptr) += newline;
955 const char *post_data,
956 size_t post_data_len)
964 buf = (
char *) &pp[1];
968 while ( (poff < post_data_len) ||
970 (0 != state_changed) ) )
975 if (max > post_data_len - poff)
976 max = post_data_len - poff;
983 (0 == state_changed) &&
984 (poff < post_data_len) )
1254 if (poff < post_data_len)
1265 const char *post_data,
1266 size_t post_data_len)
1268 if (0 == post_data_len)
#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA
#define MHD_HTTP_POST_ENCODING_FORM_URLENCODED
_MHD_EXTERN enum MHD_Result MHD_destroy_post_processor(struct MHD_PostProcessor *pp)
_MHD_EXTERN enum MHD_Result MHD_post_process(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
_MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor(struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls)
_MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr)
void MHD_unescape_plus(char *arg)
MHD internal shared structures.
#define mhd_assert(ignore)
void * MHD_calloc_(size_t nelem, size_t elsize)
Header for platform missing functions.
int MHD_str_equal_caseless_n_(const char *const str1, const char *const str2, size_t maxlen)
Header for string manipulating helpers.
#define MHD_STATICSTR_LEN_(macro)
_MHD_EXTERN size_t MHD_http_unescape(char *val)
enum MHD_Result(* MHD_PostDataIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size)
static enum MHD_Result post_process_multipart(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
static int try_match_header(const char *prefix, size_t prefix_len, char *line, char **suffix)
static int find_boundary(struct MHD_PostProcessor *pp, const char *boundary, size_t blen, size_t *ioffptr, enum PP_State next_state, enum PP_State next_dash_state)
static int process_value_to_boundary(struct MHD_PostProcessor *pp, size_t *ioffptr, const char *boundary, size_t blen, enum PP_State next_state, enum PP_State next_dash_state)
static void process_value(struct MHD_PostProcessor *pp, const char *value_start, const char *value_end, const char *last_escape)
static void try_get_value(const char *buf, const char *key, char **destination)
static enum MHD_Result post_process_urlencoded(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
static void free_unmarked(struct MHD_PostProcessor *pp)
static int process_multipart_headers(struct MHD_PostProcessor *pp, size_t *ioffptr, enum PP_State next_state)
Declarations for parsing POST data.
@ NE_content_transfer_encoding
@ PP_Nested_PerformMarking
@ PP_PerformCheckMultipart
@ PP_Nested_ProcessEntryHeaders
@ PP_Nested_PerformCleanup
@ PP_ProcessValueToBoundary
@ PP_Nested_ProcessValueToBoundary
MHD_PostDataIterator ikvi
struct MHD_Connection * connection
char * content_transfer_encoding