|
htils 1
A small set of utilities for C programming.
|
#include <ctype.h>#include <stdarg.h>#include <time.h>#include <h2o/memory.h>#include <htils/assert.h>#include <htils/basictypes.h>#include <h2otils/cookie.h>#include <h2otils/darray.h>#include <h2otils/string.h>Data Structures | |
| struct | known_attr |
Macros | |
| #define | APPEND(str, str_len) |
Typedefs | |
| typedef struct known_attr | known_attr_t |
Functions | |
| static void | to_lower (h2o_string *str) |
| static i32 | parse_3let_month (const cstr *month_cstr) |
| static i32 | parse_str_to_num (const cstr *str, i32 max_digits) |
| static b32 | parse_imf_fixdate (const cstr *date_str, time_t *result) |
| static b32 | parse_http_date (const cstr *date_cstr, time_t *result) |
| static b32 | validate_expires (const cstr *expires_str, i64 *expires) |
| h2o_cookie_t * | h2o_cookie_new (h2o_mem_pool_t *pool, const h2o_string **names, const h2o_string **values, const u64 amount) |
| Creates a new cookie with values. | |
| h2o_cookie_t * | h2o_cookie_from_string (h2o_mem_pool_t *pool, const h2o_string *str) |
| Creates a new cookie from a string. | |
| void | h2o_cookie_add_param (h2o_mem_pool_t *pool, h2o_cookie_t *cookie, h2o_cookie_param_t param,...) |
| Adds a parameter to the cookie. | |
| void | h2o_cookie_append (h2o_cookie_t *cookie, const h2o_string *key, const h2o_string *value) |
| Appends a key-value pair to the cookie. | |
| h2o_string * | h2o_cookie_to_string (h2o_mem_pool_t *pool, h2o_cookie_t *cookie) |
| Converts a cookie to a h2o_string. | |
| h2o_string * | h2o_cookie_get_value (h2o_cookie_t *cookie, const h2o_string *key) |
| Gets a value from the cookie. | |
| #define APPEND | ( | str, | |
| str_len | |||
| ) |
| typedef struct known_attr known_attr_t |
| void h2o_cookie_add_param | ( | h2o_mem_pool_t * | pool, |
| h2o_cookie_t * | cookie, | ||
| h2o_cookie_param_t | param, | ||
| ... | |||
| ) |
Adds a parameter to the cookie.
Checks the parameter, and appends the modifier according to Set-Cookie syntax.
| pool | The memory pool to allocate the cookie from. |
| cookie | The cookie to add the parameter to. |
| param | The parameter to add. |
| ... | The value of the parameter, as provided by variadic args. |
pool, cookie, and val must be valid and cannot be null.param must be a valid parameter. | void h2o_cookie_append | ( | h2o_cookie_t * | cookie, |
| const h2o_string * | key, | ||
| const h2o_string * | value | ||
| ) |
Appends a key-value pair to the cookie.
Appends a key-value pair to the cookie, if the key already exists, its updated, otherwise it will be created.
| cookie | The cookie to append to. |
| key | The key to append. |
| value | The value to append. |
cookie, key, and value must be valid and cannot be null. | h2o_cookie_t * h2o_cookie_from_string | ( | h2o_mem_pool_t * | pool, |
| const h2o_string * | str | ||
| ) |
Creates a new cookie from a string.
Parses the string and creates a new cookie from it.
| pool | The memory pool to allocate the cookie from. |
| str | The string to parse. |
pool and str must be valid and cannot be null.| h2o_string * h2o_cookie_get_value | ( | h2o_cookie_t * | cookie, |
| const h2o_string * | key | ||
| ) |
Gets a value from the cookie.
Gets a value from the cookie, if the key doesn't exist, it will return null.
| cookie | The cookie to get the value from. |
| key | The key to get the value from. |
cookie and key must be valid and cannot be null.| h2o_cookie_t * h2o_cookie_new | ( | h2o_mem_pool_t * | pool, |
| const h2o_string ** | names, | ||
| const h2o_string ** | values, | ||
| const u64 | amount | ||
| ) |
Creates a new cookie with values.
Allocates a new cookie with the given values to conform to the Set-Cookie syntax.
| pool | The memory pool to allocate the cookie from. |
| names | The names of each cookie field. |
| values | The values of each cookie field. |
| amount | The amount of cookie keys and values within the cookie. |
pool, names, and values must be valid and cannot be null. | h2o_string * h2o_cookie_to_string | ( | h2o_mem_pool_t * | pool, |
| h2o_cookie_t * | cookie | ||
| ) |
Converts a cookie to a h2o_string.
Converts the cookie to a h2o_string, according to the Set-Cookie syntax.
| pool | The memory pool to allocate the string from. |
| cookie | The cookie to convert. |
pool and cookie must be valid and cannot be null.
|
inlinestatic |