|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
URL path splitting and percent-decoding utilities. More...
#include <ctype.h>#include <stdlib.h>#include <string.h>#include "context_internal.h"#include "csilk/core/internal.h"#include "csilk/csilk.h"
Functions | |
| static int | hex_to_int (char c) |
| Helper: convert a hexadecimal character to its integer value. | |
| size_t | csilk_url_decode (char *str) |
| URL-decode a percent-encoded string in-place. | |
| void | csilk_split_url (const char *url, char **path, char **query) |
| Split a full URL into its path and query string components. | |
URL path splitting and percent-decoding utilities.
Provides the two fundamental URL operations needed by the HTTP server:
These are used by the HTTP parser during request finalization to populate the request context's path and query_params fields.
| void csilk_split_url | ( | const char * | url, |
| char ** | path, | ||
| char ** | query | ||
| ) |
Split a full URL into its path and query string components.
Split a URL into path and query-string components.
Finds the first '?' separator. The path portion is URL-decoded and returned in path. The query portion (everything after '?') is returned raw in query (NOT URL-decoded — use csilk_parse_query() for that). If there is no '?', the entire URL is treated as the path and query is set to NULL.
| url | Full URL string (e.g., "/foo/bar?key=val"). |
| path | [out] Receives a malloc'd, URL-decoded path string. |
| query | [out] Receives a malloc'd raw query string, or NULL if no query was present. |
| size_t csilk_url_decode | ( | char * | str | ) |
URL-decode a percent-encoded string in-place.
Replaces XX sequences with the corresponding byte value and '+' with space. The decoding is done in-place so the output is never longer than the input.
| str | Null-terminated string to decode (modified in-place). |
str contains invalid % sequences (e.g., "%ZZ"), they are left as-is.
|
static |
Helper: convert a hexadecimal character to its integer value.
Handles both uppercase ('A'-'F') and lowercase ('a'-'f') hex digits.
| c | Hex character ('0'-'9', 'a'-'f', or 'A'-'F'). |
c is not a valid hex digit.