From ad541c67761b8aa6da1566802c347cac4018d0c2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 20:50:24 +0100 Subject: Move the build sources into src/ --- src/ot_urlencoded.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/ot_urlencoded.h (limited to 'src/ot_urlencoded.h') 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 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#ifndef SCAN_URLENCODED_QUERY_H__ +#define SCAN_URLENCODED_QUERY_H__ + +#include +#include +#include + +typedef struct { + const char *key; + int value; +} ot_keywords; + +typedef enum { + SCAN_PATH = 1, + SCAN_SEARCHPATH_PARAM = 2, + SCAN_SEARCHPATH_VALUE = 4, + SCAN_SEARCHPATH_TERMINATOR = 8 +} SCAN_SEARCHPATH_FLAG; + +/* string in: pointer to source + out: pointer to next scan position + deststring pointer to destination + flags determines, what to parse + returns number of valid converted characters in deststring + or -1 for parse error + or -2 for terminator found +*/ +ssize_t urlencoded_parse(char **string, char *deststring, SCAN_SEARCHPATH_FLAG flags); + +/* string in: pointer to source + out: pointer to next scan position + flags determines, what to parse + returns value for matched keyword + or -1 for parse error + or -2 for terminator found + or -3 for no keyword matched + */ +int urlencoded_match_keyword(const ot_keywords *keywords, char **string, SCAN_SEARCHPATH_FLAG flags); + +/* string in: pointer to value of a param=value pair to skip + out: pointer to next scan position on return +*/ +void urlencoded_skip_value(char **string); + + +/* The other direction: percent encode len bytes from src into dest and return + how many characters were written. dest needs room for three times len. */ +size_t urlencoded_format(char *dest, const uint8_t *src, size_t len); + +#endif -- cgit v1.3