|
Wapcaplet
|
#include <sys/types.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <assert.h>Go to the source code of this file.
Classes | |
| struct | lwc_string_s |
Macros | |
| #define | lwc_string_unref(str) |
| #define | lwc_string_isequal(str1, str2, ret) ((*(ret) = ((str1) == (str2))), lwc_error_ok) |
| #define | lwc__assert_and_expr(str, expr) (expr) |
| #define | lwc_string_data(str) lwc__assert_and_expr(str, (const char *)((str)+1)) |
| #define | lwc_string_length(str) lwc__assert_and_expr(str, (str)->len) |
| #define | lwc_string_hash_value(str) lwc__assert_and_expr(str, (str)->hash) |
Typedefs | |
| typedef uint32_t | lwc_refcounter |
| typedef uint32_t | lwc_hash |
| typedef struct lwc_string_s | lwc_string |
| typedef void(* | lwc_iteration_callback_fn) (lwc_string *str, void *pw) |
| typedef enum lwc_error_e | lwc_error |
Enumerations | |
| enum | lwc_error_e { lwc_error_ok = 0 , lwc_error_oom = 1 , lwc_error_range = 2 } |
Functions | |
| lwc_error | lwc_intern_string (const char *s, size_t slen, lwc_string **ret) |
| lwc_error | lwc_intern_substring (lwc_string *str, size_t ssoffset, size_t sslen, lwc_string **ret) |
| lwc_error | lwc_string_tolower (lwc_string *str, lwc_string **ret) |
| void | lwc_string_destroy (lwc_string *str) |
| lwc_error | lwc__intern_caseless_string (lwc_string *str) |
| void | lwc_iterate_strings (lwc_iteration_callback_fn cb, void *pw) |
| #define lwc__assert_and_expr | ( | str, | |
| expr | |||
| ) | (expr) |
Definition at line 261 of file libwapcaplet.h.
| #define lwc_string_data | ( | str | ) | lwc__assert_and_expr(str, (const char *)((str)+1)) |
Retrieve the data pointer for an interned string.
| str | The string to retrieve the data pointer for. |
Definition at line 276 of file libwapcaplet.h.
| #define lwc_string_hash_value | ( | str | ) | lwc__assert_and_expr(str, (str)->hash) |
Retrieve (or compute if unavailable) a hash value for the content of the string.
| str | The string to get the hash for. |
Definition at line 298 of file libwapcaplet.h.
| #define lwc_string_isequal | ( | str1, | |
| str2, | |||
| ret | |||
| ) | ((*(ret) = ((str1) == (str2))), lwc_error_ok) |
Check if two interned strings are equal.
| str1 | The first string in the comparison. |
| str2 | The second string in the comparison. |
| ret | A pointer to a boolean to be filled out with the result. |
Definition at line 188 of file libwapcaplet.h.
| #define lwc_string_length | ( | str | ) | lwc__assert_and_expr(str, (str)->len) |
Retrieve the data length for an interned string.
| str | The string to retrieve the length of. |
Definition at line 284 of file libwapcaplet.h.
| #define lwc_string_unref | ( | str | ) |
Release a reference on an lwc_string.
This decreases the reference count on the given lwc_string.
| str | The string to unref. |
Definition at line 159 of file libwapcaplet.h.
| typedef enum lwc_error_e lwc_error |
Result codes which libwapcaplet might return.
| typedef uint32_t lwc_hash |
The type of a hash value used in libwapcaplet.
Definition at line 31 of file libwapcaplet.h.
| typedef void(* lwc_iteration_callback_fn) (lwc_string *str, void *pw) |
String iteration function
| str | A string which has been interned. |
| pw | The private pointer for the allocator. |
Definition at line 56 of file libwapcaplet.h.
| typedef uint32_t lwc_refcounter |
The type of a reference counter used in libwapcaplet.
Definition at line 26 of file libwapcaplet.h.
| typedef struct lwc_string_s lwc_string |
An interned string.
NOTE: The contents of this struct are considered PRIVATE and may change in future revisions. Do not rely on them whatsoever. They're only here at all so that the ref, unref and matches etc can use them.
| enum lwc_error_e |
Result codes which libwapcaplet might return.
| Enumerator | |
|---|---|
| lwc_error_ok | No error. |
| lwc_error_oom | Out of memory. |
| lwc_error_range | Substring internment out of range. |
Definition at line 61 of file libwapcaplet.h.
|
extern |
Intern a caseless copy of the passed string.
| str | The string to intern the caseless copy of. |
Definition at line 255 of file libwapcaplet.c.
|
extern |
Intern a string.
Take a copy of the string data referred to by s and slen and intern it. The resulting lwc_string can be used for simple and caseless comparisons by lwc_string_isequal and lwc_string_caseless_isequal respectively.
| s | Pointer to the start of the string to intern. |
| slen | Length of the string in characters. (Not including any terminators) |
| ret | Pointer to lwc_string pointer to fill out. |
Definition at line 143 of file libwapcaplet.c.
|
extern |
Intern a substring.
Intern a subsequence of the provided lwc_string.
| str | String to acquire substring from. |
| ssoffset | Substring offset into str. |
| sslen | Substring length. |
| ret | Pointer to pointer to lwc_string to fill out. |
Definition at line 152 of file libwapcaplet.c.
|
extern |
Iterate the context and return every string in it.
If there are no strings found in the context, then this has the side effect of removing the global context which will reduce the chances of false-positives on leak checkers.
| cb | The callback to give the string to. |
| pw | The private word for the callback. |
Definition at line 270 of file libwapcaplet.c.
|
extern |
Destroy an unreffed lwc_string.
This destroys an lwc_string whose reference count indicates that it should be.
| str | The string to unref. |
Definition at line 187 of file libwapcaplet.c.
|
extern |
Optain a lowercased lwc_string from given lwc_string.
| str | String to create lowercase string from. |
| ret | Pointer to lwc_string pointer to fill out. |
Definition at line 168 of file libwapcaplet.c.