diff options
Diffstat (limited to 'src/ot_urlencoded.h')
| -rw-r--r-- | src/ot_urlencoded.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ot_urlencoded.h b/src/ot_urlencoded.h new file mode 100644 index 0000000..9882468 --- /dev/null +++ b/src/ot_urlencoded.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ | ||
| 3 | |||
| 4 | #ifndef SCAN_URLENCODED_QUERY_H__ | ||
| 5 | #define SCAN_URLENCODED_QUERY_H__ | ||
| 6 | |||
| 7 | #include <stddef.h> | ||
| 8 | #include <stdint.h> | ||
| 9 | #include <sys/types.h> | ||
| 10 | |||
| 11 | typedef struct { | ||
| 12 | const char *key; | ||
| 13 | int value; | ||
| 14 | } ot_keywords; | ||
| 15 | |||
| 16 | typedef enum { | ||
| 17 | SCAN_PATH = 1, | ||
| 18 | SCAN_SEARCHPATH_PARAM = 2, | ||
| 19 | SCAN_SEARCHPATH_VALUE = 4, | ||
| 20 | SCAN_SEARCHPATH_TERMINATOR = 8 | ||
| 21 | } SCAN_SEARCHPATH_FLAG; | ||
| 22 | |||
| 23 | /* string in: pointer to source | ||
| 24 | out: pointer to next scan position | ||
| 25 | deststring pointer to destination | ||
| 26 | flags determines, what to parse | ||
| 27 | returns number of valid converted characters in deststring | ||
| 28 | or -1 for parse error | ||
| 29 | or -2 for terminator found | ||
| 30 | */ | ||
| 31 | ssize_t urlencoded_parse(char **string, char *deststring, SCAN_SEARCHPATH_FLAG flags); | ||
| 32 | |||
| 33 | /* string in: pointer to source | ||
| 34 | out: pointer to next scan position | ||
| 35 | flags determines, what to parse | ||
| 36 | returns value for matched keyword | ||
| 37 | or -1 for parse error | ||
| 38 | or -2 for terminator found | ||
| 39 | or -3 for no keyword matched | ||
| 40 | */ | ||
| 41 | int urlencoded_match_keyword(const ot_keywords *keywords, char **string, SCAN_SEARCHPATH_FLAG flags); | ||
| 42 | |||
| 43 | /* string in: pointer to value of a param=value pair to skip | ||
| 44 | out: pointer to next scan position on return | ||
| 45 | */ | ||
| 46 | void urlencoded_skip_value(char **string); | ||
| 47 | |||
| 48 | |||
| 49 | /* The other direction: percent encode len bytes from src into dest and return | ||
| 50 | how many characters were written. dest needs room for three times len. */ | ||
| 51 | size_t urlencoded_format(char *dest, const uint8_t *src, size_t len); | ||
| 52 | |||
| 53 | #endif | ||
