Add helper function for percent encoding
This commit is contained in:
parent
23c2911ce0
commit
a52cc51ed8
|
@ -114,6 +114,14 @@ char * httplib_request_get_query_value(http_request * self, char * key);
|
|||
*/
|
||||
int httplib_is_valid_header(const char * key, const char * value);
|
||||
|
||||
/**
|
||||
* Helper function to decode a percent encoded character.
|
||||
* @param encoded a pointer to the first of the two characters in the string
|
||||
* after the percent symbol, which make up the encoded character
|
||||
* @return the decoded character
|
||||
*/
|
||||
char httplib_decode_hex(const char * encoded);
|
||||
|
||||
#define SOCKET_ERROR -1
|
||||
#define BIND_ERROR -2
|
||||
#define LISTEN_ERROR -3
|
||||
|
|
|
@ -167,4 +167,12 @@ void httplib_tmp_increase(struct tmp * tmp) {
|
|||
void httplib_tmp_reset(struct tmp * tmp) {
|
||||
tmp->pos = 0;
|
||||
bzero(tmp->buf, tmp->size);
|
||||
}
|
||||
|
||||
char httplib_decode_hex(const char * encoded) {
|
||||
char input[3];
|
||||
input[0] = encoded[0];
|
||||
input[1] = encoded[1];
|
||||
input[2] = '\0';
|
||||
return (char) strtoul(input, 0, 16);
|
||||
}
|
Loading…
Reference in a new issue