![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "nilorea/n_common.h"#include "nilorea/n_http_form.h"#include "nilorea/n_log.h"#include "nilorea/n_str.h"Go to the source code of this file.
Macros | |
| #define | BND(ct) |
| boundary of a NUL-terminated Content-Type literal, into b | |
Functions | |
| static int | decodes_to (const char *in, int flags, const char *want) |
| decode a NUL-terminated literal and compare with the expected result | |
| static void | expect_true (const char *what, int ok) |
| count a failed check | |
| int | main (int argc, char **argv) |
| run the checks | |
| static N_HTTP_FORM_MULTIPART * | mp_parse (const char *body, size_t max) |
| parse a NUL-terminated multipart body | |
| static int | part_body_is (const char *buf, const N_HTTP_FORM_PART *p, const char *want) |
| body of a part as a string comparison | |
| static int | process_args (int argc, char **argv) |
| read -V | |
| static void | test_decode (void) |
| percent-decoding | |
| static void | test_form (void) |
| query strings and urlencoded bodies | |
| static void | test_multipart (void) |
| multipart/form-data | |
Variables | |
| static int | failures = 0 |
| failed checks | |
| static int | log_level = 3 |
| log level from -V | |
| #define BND | ( | ct | ) |
boundary of a NUL-terminated Content-Type literal, into b
Definition at line 195 of file ex_http_form.c.
Referenced by test_multipart().
|
static |
decode a NUL-terminated literal and compare with the expected result
| in | encoded text |
| flags | decode flags |
| want | expected decoded text, or NULL when decoding must fail |
Definition at line 79 of file ex_http_form.c.
References N_STR::data, free_nstr, n_http_percent_decode(), and N_STR::written.
Referenced by test_decode().
|
static |
| int main | ( | int | argc, |
| char ** | argv ) |
run the checks
| argc | argument count |
| argv | arguments |
Definition at line 306 of file ex_http_form.c.
References failures, LOG_ERR, log_level, LOG_NOTICE, n_log, process_args(), set_log_level(), test_decode(), test_form(), and test_multipart().
|
static |
parse a NUL-terminated multipart body
| body | the body |
| max | most parts |
Definition at line 190 of file ex_http_form.c.
References n_http_form_multipart_parse().
Referenced by test_multipart().
|
static |
body of a part as a string comparison
| buf | the parsed buffer |
| p | the part |
| want | expected body |
Definition at line 182 of file ex_http_form.c.
References N_HTTP_FORM_PART::body_len, and N_HTTP_FORM_PART::body_off.
Referenced by test_multipart().
|
static |
read -V
| argc | argument count |
| argv | arguments |
Definition at line 61 of file ex_http_form.c.
References log_level.
|
static |
percent-decoding
Definition at line 92 of file ex_http_form.c.
References char_to_nstr(), N_STR::data, decodes_to(), expect_true(), free_nstr, N_HTTP_FORM_PLUS_SPACE, N_HTTP_FORM_RAW_BYTES, n_http_percent_decode(), and N_STR::written.
Referenced by main().
|
static |
query strings and urlencoded bodies
Definition at line 122 of file ex_http_form.c.
References expect_true(), N_HTTP_FORM::fields, n_http_form_count(), n_http_form_free(), n_http_form_get(), n_http_form_parse(), N_HTTP_FORM_RAW_BYTES, N_HTTP_FORM_SKIP_INVALID, N_HTTP_FIELD::name, N_HTTP_FORM::nb_fields, N_HTTP_FIELD::value, and N_HTTP_FIELD::value_len.
Referenced by main().
|
static |
multipart/form-data
Definition at line 198 of file ex_http_form.c.
References BND, N_HTTP_FORM_PART::body_len, N_HTTP_FORM_PART::body_off, N_HTTP_FORM_PART::content_type, expect_true(), N_HTTP_FORM_PART::filename, N_HTTP_FORM_PART::has_filename, mp_parse(), N_HTTP_FORM_BOUNDARY_MAX, n_http_form_multipart_count(), n_http_form_multipart_free(), n_http_form_multipart_get(), n_http_form_multipart_parse(), N_HTTP_FORM_PART_HEAD_MAX, N_HTTP_FORM_PART_NAME_MAX, N_HTTP_FORM_PART::name, N_HTTP_FORM_MULTIPART::nb_parts, part_body_is(), and N_HTTP_FORM_MULTIPART::parts.
Referenced by main().
|
static |
failed checks
Definition at line 43 of file ex_http_form.c.
|
static |
log level from -V
Definition at line 41 of file ex_http_form.c.