#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "dynstuff.h"
#include "dynstuff_inline.h"
#include "xmalloc.h"
Definicje | |
#define | unhex(x) |
Funkcje | |
void * | list_add_sorted (list_t *list, void *data, int(*comparision)(void *, void *)) |
void * | list_add_beginning (list_t *list, void *data) |
void * | list_add (list_t *list, void *data) |
void * | list_add_sorted3 (list_t *list, list_t new_, int(*comparision)(void *, void *)) |
void * | list_add_beginning3 (list_t *list, list_t new_) |
void * | list_add3 (list_t *list, list_t new_) |
int | list_remove_safe (list_t *list, void *data, int free_data) |
void | list_cleanup (list_t *list) |
int | list_remove2 (list_t *list, void *data, void(*func)(void *data)) |
void * | list_remove3 (list_t *list, list_t elem, void(*func)(list_t data)) |
void * | list_remove3i (list_t *list, list_t elem, void(*func)(list_t data)) |
void * | list_unlink3 (list_t *list, list_t elem) |
int | list_remove (list_t *list, void *data, int free_data) |
void * | list_get_nth (list_t list, int id) |
void * | list_get_nth3 (list_t list, int id) |
void | list_resort (list_t *list, int(*comparision)(void *, void *)) |
void | list_resort3 (list_t *list, int(*comparision)(void *, void *)) |
int | list_count (list_t list) |
int | list_destroy2 (list_t list, void(*func)(void *)) |
int | list_destroy3 (list_t list, void(*func)(void *)) |
int | list_destroy (list_t list, int free_data) |
static void | string_realloc (string_t s, int count) |
int | string_append_c (string_t s, char c) |
int | string_append_n (string_t s, const char *str, int count) |
int | string_append_format (string_t s, const char *format,...) |
int | string_append_raw (string_t s, const char *str, int count) |
int | string_append (string_t s, const char *str) |
void | string_insert_n (string_t s, int index, const char *str, int count) |
void | string_insert (string_t s, int index, const char *str) |
string_t | string_init (const char *value) |
string_t | string_init_n (int n) |
void | string_remove (string_t s, int count) |
void | string_clear (string_t s) |
char * | string_free (string_t s, int free_string) |
const char * | itoa (long int i) |
char ** | array_make (const char *string, const char *sep, int max, int trim, int quotes) |
int | array_count (char **array) |
int | array_add (char ***array, char *string) |
int | array_add_check (char ***array, char *string, int casesensitive) |
char * | array_join (char **array, const char *sep) |
char * | array_join_count (char **array, const char *sep, int count) |
int | array_contains (char **array, const char *string, int casesensitive) |
int | array_item_contains (char **array, const char *string, int casesensitive) |
char * | array_shift (char ***array) |
void | array_free (char **array) |
void | array_free_count (char **array, int count) |
const char * | cssfind (const char *haystack, const char *needle, const char sep, int caseinsensitive) |
char * | escape (const char *src) |
char * | unescape (const char *src) |
static int | private_data_cmp (private_data_t *item1, private_data_t *item2) |
static | LIST_FREE_ITEM (private_data_free, private_data_t *) |
DYNSTUFF_LIST_DECLARE_SORTED (private_items, private_data_t, private_data_cmp, private_data_free, static __DYNSTUFF_ADD_SORTED, static __DYNSTUFF_REMOVE_SAFE, __DYNSTUFF_DESTROY) static private_data_t *private_item_find(private_data_t **data |
#define unhex | ( | x | ) |
(unsigned char) ((x >= '0' && x <= '9') ? (x - '0') : \ (x >= 'A' && x <= 'F') ? (x - 'A' + 10) : \ (x >= 'a' && x <= 'f') ? (x - 'a' + 10) : 0)
int array_add | ( | char *** | array, | |
char * | string | |||
) |
int array_add_check | ( | char *** | array, | |
char * | string, | |||
int | casesensitive | |||
) |
int array_contains | ( | char ** | array, | |
const char * | string, | |||
int | casesensitive | |||
) |
int array_count | ( | char ** | array | ) |
void array_free | ( | char ** | array | ) |
void array_free_count | ( | char ** | array, | |
int | count | |||
) |
int array_item_contains | ( | char ** | array, | |
const char * | string, | |||
int | casesensitive | |||
) |
char* array_join | ( | char ** | array, | |
const char * | sep | |||
) |
char* array_join_count | ( | char ** | array, | |
const char * | sep, | |||
int | count | |||
) |
char** array_make | ( | const char * | string, | |
const char * | sep, | |||
int | max, | |||
int | trim, | |||
int | quotes | |||
) |
char* array_shift | ( | char *** | array | ) |
const char* cssfind | ( | const char * | haystack, | |
const char * | needle, | |||
const char | sep, | |||
int | caseinsensitive | |||
) |
Short for comma-separated string find, does check whether given string contains given element. It's works like array_make()+array_contains(), but it's hell simpler and faster.
haystack | - comma-separated string to search. | |
needle | - element to search for. | |
sep | - separator. | |
caseinsensitive | - take a wild guess. |
DYNSTUFF_LIST_DECLARE_SORTED | ( | private_items | , | |
private_data_t | , | |||
private_data_cmp | , | |||
private_data_free | , | |||
static | __DYNSTUFF_ADD_SORTED, | |||
static | __DYNSTUFF_REMOVE_SAFE, | |||
__DYNSTUFF_DESTROY | ||||
) |
char* escape | ( | const char * | src | ) |
const char* itoa | ( | long int | i | ) |
void* list_add | ( | list_t * | list, | |
void * | data | |||
) |
Add item data to list without sorting
Item will be added at end of list - as last item
Wrapper to: list_add_sorted(list, data, alloc_size, NULL)
void* list_add_beginning | ( | list_t * | list, | |
void * | data | |||
) |
Add item data to the begining of the list
(Once again), item will be added at begining of the list - as first item
void* list_add_sorted | ( | list_t * | list, | |
void * | data, | |||
int(*)(void *, void *) | comparision | |||
) |
void list_cleanup | ( | list_t * | list | ) |
Remove from list_t all items with l->data set to NULL.
Use with list_remove_safe() after list is not in use.
int list_count | ( | list_t | list | ) |
int list_destroy | ( | list_t | list, | |
int | free_data | |||
) |
Destroy all items from list_t list
list_destroy(my_list, free_data); my_list = NULL;
list | - list_t | |
free_data | - if set we will call xfree() on each item data |
int list_destroy2 | ( | list_t | list, | |
void(*)(void *) | func | |||
) |
int list_destroy3 | ( | list_t | list, | |
void(*)(void *) | func | |||
) |
static LIST_FREE_ITEM | ( | private_data_free | , | |
private_data_t * | ||||
) | [static] |
void* list_get_nth | ( | list_t | list, | |
int | id | |||
) |
Get n'th item from list_t
list | - list_t | |
id | - n'th item [list items are numerated from 1] |
void* list_get_nth3 | ( | list_t | list, | |
int | id | |||
) |
int list_remove | ( | list_t * | list, | |
void * | data, | |||
int | free_data | |||
) |
Remove item data from list_t pointed by list
list | - pointer to list_t | |
data | - data to remove from list | |
free_data | - if set and item was found it'll call xfree() on it. |
int list_remove2 | ( | list_t * | list, | |
void * | data, | |||
void(*)(void *data) | func | |||
) |
int list_remove_safe | ( | list_t * | list, | |
void * | data, | |||
int | free_data | |||
) |
Remove item data from list_t pointed by list.
Don't free whole list_t item struct. only set item_list_t->data to NULL
list | - pointer to list_t | |
data | - data to remove from list | |
free_data | -if set and item was found it'll call xfree() on it. |
void list_resort | ( | list_t * | list, | |
int(*)(void *, void *) | comparision | |||
) |
void list_resort3 | ( | list_t * | list, | |
int(*)(void *, void *) | comparision | |||
) |
static int private_data_cmp | ( | private_data_t * | item1, | |
private_data_t * | item2 | |||
) | [static] |
int string_append | ( | string_t | s, | |
const char * | str | |||
) |
Append to string_t s, NUL terminated string pointed by str
Wrapper to:string_append_n(s, str, -1)
int string_append_c | ( | string_t | s, | |
char | c | |||
) |
Append to string_t s char c.
s | - string_t | |
c | - char to append |
int string_append_format | ( | string_t | s, | |
const char * | format, | |||
... | ||||
) |
Append to string_t s, formatted output of format + params
Equivalent to:
char *tmp = saprintf(format, ...);
string_append(s, tmp);
xfree(tmp);
int string_append_n | ( | string_t | s, | |
const char * | str, | |||
int | count | |||
) |
Append to string_t s, first count chars, from str
s | - string_t | |
str | - buffer to append. | |
count | - how many chars copy copy from str, or -1 to copy whole. |
count = xstrnlen(str, count);
?int string_append_raw | ( | string_t | s, | |
const char * | str, | |||
int | count | |||
) |
Append to string_t s, count bytes from memory pointed by str
void string_clear | ( | string_t | s | ) |
Clear s->str (s->str[0] == '\0')
If memory allocated by string_t s was larger than 160, than decrease to 80
s | - string_t |
char* string_free | ( | string_t | s, | |
int | free_string | |||
) |
Cleanup memory after string_t s, and perhaps (if free_string set) cleanup memory after char buffer.
s | - string_t which we want to free. | |
free_string | - do we want to free memory after char buffer? |
string_t string_init | ( | const char * | value | ) |
init string_t struct, allocating memory for string passed by value, and setting internal string_t data.
value | - if NULL char buffer will be inited with "", otherwise with given value. |
string_t string_init_n | ( | int | n | ) |
init string_t struct, allocating memory string of length n
n | - number of bytes to allocate |
void string_insert | ( | string_t | s, | |
int | index, | |||
const char * | str | |||
) |
Insert given text (str) to given string_t (s) at given pos (index)
Wrapper to: string_insert_t(s, index, str, -1)
s | - string_t | |
index | - pos | |
str | - text |
void string_insert_n | ( | string_t | s, | |
int | index, | |||
const char * | str, | |||
int | count | |||
) |
static void string_realloc | ( | string_t | s, | |
int | count | |||
) | [static] |
void string_remove | ( | string_t | s, | |
int | count | |||
) |
Remove first count chars from string.
char* unescape | ( | const char * | src | ) |