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);
548 if ( (
NULL != start_value) &&
559 if (
NULL == end_value)
560 end_value = &post_data[poff];
561 if ( (
NULL != last_escape) &&
562 (2 < (end_value - last_escape)) )
603 *suffix = strdup (&line[prefix_len]);
633 char *buf = (
char *) &pp[1];
643 if ( (0 != memcmp (
"--",
646 (0 != memcmp (&buf[2],
663 else if (dash == buf)
666 (*ioffptr) += (size_t) (dash - buf);
671 (*ioffptr) += 2 +
blen;
674 pp->
state = next_state;
697 if (
NULL != *destination)
701 while (
NULL != (spos = strstr (bpos, key)))
703 if ( (spos[klen] !=
'=') ||
705 (spos[-1] !=
' ') ) )
711 if (spos[klen + 1] !=
'"')
713 if (
NULL == (endv = strchr (&spos[klen + 2],
716 vlen = (size_t) (endv - spos) - klen - 1;
717 *destination = malloc (vlen);
718 if (
NULL == *destination)
720 (*destination)[vlen - 1] =
'\0';
721 memcpy (*destination,
749 char *buf = (
char *) &pp[1];
754 (buf[newline] !=
'\r') &&
755 (buf[newline] !=
'\n') )
768 pp->
state = next_state;
772 if (buf[newline] ==
'\r')
797 (*ioffptr) += newline + 1;
826 char *buf = (
char *) &pp[1];
837 r = memchr (&buf[newline],
845 newline = (size_t) (r - buf);
846 if (0 == memcmp (
"\r\n--",
855 if (0 != memcmp (&buf[newline + 4],
868 pp->
state = next_state;
870 (*ioffptr) +=
blen + 4;
880 if ( (0 == newline) &&
909 (*ioffptr) += newline;
958 const char *post_data,
959 size_t post_data_len)
967 buf = (
char *) &pp[1];
971 while ( (poff < post_data_len) ||
973 (0 != state_changed) ) )
978 if (max > post_data_len - poff)
979 max = post_data_len - poff;
986 (0 == state_changed) &&
987 (poff < post_data_len) )
1257 if (poff < post_data_len)
1268 const char *post_data,
1269 size_t post_data_len)
1271 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