Orcania: include/orcania.h Source File

Orcania Potluck with different functions for different purposes that can be shared among C programs

orcania.h
Go to the documentation of this file.
1
28#ifndef __ORCANIA_H__
29#define __ORCANIA_H__
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif
35
36#include "orcania-cfg.h"
37
38#include <stdio.h>
39#include <stdlib.h>
40
61char * str_replace(const char * source, const char * str_old, const char * str_new);
62
70char * o_strdup(const char * source);
71
80char * o_strndup(const char * source, size_t len);
81
89int o_strcmp(const char * p1, const char * p2);
90
99int o_strncmp(const char * p1, const char * p2, size_t n);
100
108char * o_strcpy(char * p1, const char * p2);
109
118char * o_strncpy(char * p1, const char * p2, size_t n);
119
127int o_strcasecmp(const char * p1, const char * p2);
128
137int o_strncasecmp(const char * p1, const char * p2, size_t n);
138
146char * o_strstr(const char * haystack, const char * needle);
147
156char * o_strnstr(const char * haystack, const char * needle, size_t len);
157
165char * o_strcasestr(const char * haystack, const char * needle);
166
174char * o_strchr(const char * haystack, int c);
175
184const char * o_strnchr(const char * haystack, size_t len, char c);
185
193char * o_strrchr(const char * haystack, int c);
194
203const char * o_strrnchr(const char * haystack, size_t len, char c);
204
209int o_strnullempty(const char * s);
210
217size_t o_strlen(const char * s);
218
225const char * trimwhitespace(char * str);
226
233char * trimcharacter(char * str, char to_remove);
234
247char * msprintf(const char * message, ...);
248
259char * mstrcatf(char * source, const char * message, ...);
260
283size_t split_string(const char * string, const char * separator, char *** return_array);
284
290void free_string_array(char ** array);
291
297size_t string_array_size(char ** array);
298
305int string_array_has_value(const char ** array, const char * needle);
306
313int string_array_has_value_case(const char ** array, const char * needle);
314
321int string_array_has_value_n(const char ** array, const char * needle, size_t len);
322
329int string_array_has_value_ncase(const char ** array, const char * needle, size_t len);
330
337int string_array_has_trimmed_value(const char ** array, const char * needle);
338
345char * string_array_join(const char ** array, const char * separator);
346
355 struct _pointer_list {
356 size_t size; /* size of the list */
357 void ** list; /* list of pointers */
358};
359
365void pointer_list_init(struct _pointer_list * pointer_list);
366
372void pointer_list_clean(struct _pointer_list * pointer_list);
373
381void pointer_list_clean_free(struct _pointer_list * pointer_list, void (* free_function)(void * elt));
382
388size_t pointer_list_size(struct _pointer_list * pointer_list);
389
397int pointer_list_append(struct _pointer_list * pointer_list, void * element);
398
405void * pointer_list_get_at(struct _pointer_list * pointer_list, size_t index);
406
414int pointer_list_remove_at(struct _pointer_list * pointer_list, size_t index);
415
425int pointer_list_remove_at_free(struct _pointer_list * pointer_list, size_t index, void (* free_function)(void * elt));
426
435int pointer_list_insert_at(struct _pointer_list * pointer_list, void * element, size_t index);
436
444int pointer_list_remove_pointer(struct _pointer_list * pointer_list, void * element);
445
455int pointer_list_remove_pointer_free(struct _pointer_list * pointer_list, void * element, void (* free_function)(void * elt));
456
466/* C89 allows these to be macros */
467#undef malloc
468#undef realloc
469#undef free
470
474 typedef void *(*o_malloc_t)(size_t);
475 typedef void *(*o_realloc_t)(void *, size_t);
476 typedef void (*o_free_t)(void *);
477
483void * o_malloc(size_t size);
484
491void * o_realloc(void * ptr, size_t size);
492
496void o_free(void * ptr);
497
504void o_set_alloc_funcs(o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t free_fn);
505
512void o_get_alloc_funcs(o_malloc_t * malloc_fn, o_realloc_t * realloc_fn, o_free_t * free_fn);
513
533int o_base64_encode(const unsigned char * src, size_t len, unsigned char * out, size_t * out_len);
534
545int o_base64_decode(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len);
546
557int o_base64url_encode(const unsigned char * src, size_t len, unsigned char * out, size_t * out_len);
558
569int o_base64url_decode(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len);
570
582int o_base64url_2_base64(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len);
583
595int o_base64_2_base64url(const unsigned char *src, size_t len, unsigned char * out, size_t * out_len);
596
601#ifdef __cplusplus
602}
603#endif
604
605#endif // __ORCANIA_H__
o_base64url_encode
int o_base64url_encode(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:212
o_base64url_decode
int o_base64url_decode(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:226
o_base64_encode
int o_base64_encode(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:184
o_base64_decode
int o_base64_decode(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:198
o_base64url_2_base64
int o_base64url_2_base64(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:241
o_base64_2_base64url
int o_base64_2_base64url(const unsigned char *src, size_t len, unsigned char *out, size_t *out_len)
Definition: base64.c:279
o_malloc_t
void *(* o_malloc_t)(size_t)
Definition: orcania.h:474
o_set_alloc_funcs
void o_set_alloc_funcs(o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t free_fn)
Definition: memory.c:43
o_realloc
void * o_realloc(void *ptr, size_t size)
Definition: memory.c:27
o_malloc
void * o_malloc(size_t size)
Definition: memory.c:19
o_free
void o_free(void *ptr)
Definition: memory.c:35
o_realloc_t
void *(* o_realloc_t)(void *, size_t)
Definition: orcania.h:475
o_free_t
void(* o_free_t)(void *)
Definition: orcania.h:476
o_get_alloc_funcs
void o_get_alloc_funcs(o_malloc_t *malloc_fn, o_realloc_t *realloc_fn, o_free_t *free_fn)
Definition: memory.c:49
pointer_list_remove_at
int pointer_list_remove_at(struct _pointer_list *pointer_list, size_t index)
Definition: orcania.c:760
pointer_list_remove_pointer
int pointer_list_remove_pointer(struct _pointer_list *pointer_list, void *element)
Definition: orcania.c:823
pointer_list_get_at
void * pointer_list_get_at(struct _pointer_list *pointer_list, size_t index)
Definition: orcania.c:747
pointer_list_append
int pointer_list_append(struct _pointer_list *pointer_list, void *element)
Definition: orcania.c:726
pointer_list_clean_free
void pointer_list_clean_free(struct _pointer_list *pointer_list, void(*free_function)(void *elt))
Definition: orcania.c:699
pointer_list_size
size_t pointer_list_size(struct _pointer_list *pointer_list)
Definition: orcania.c:713
pointer_list_remove_at_free
int pointer_list_remove_at_free(struct _pointer_list *pointer_list, size_t index, void(*free_function)(void *elt))
Definition: orcania.c:785
pointer_list_remove_pointer_free
int pointer_list_remove_pointer_free(struct _pointer_list *pointer_list, void *element, void(*free_function)(void *elt))
Definition: orcania.c:843
pointer_list_insert_at
int pointer_list_insert_at(struct _pointer_list *pointer_list, void *element, size_t index)
Definition: orcania.c:799
pointer_list_init
void pointer_list_init(struct _pointer_list *pointer_list)
Definition: orcania.c:674
pointer_list_clean
void pointer_list_clean(struct _pointer_list *pointer_list)
Definition: orcania.c:685
string_array_has_value
int string_array_has_value(const char **array, const char *needle)
Definition: orcania.c:576
string_array_has_value_case
int string_array_has_value_case(const char **array, const char *needle)
Definition: orcania.c:593
string_array_size
size_t string_array_size(char **array)
Definition: orcania.c:496
string_array_join
char * string_array_join(const char **array, const char *separator)
Definition: orcania.c:507
split_string
size_t split_string(const char *string, const char *separator, char ***return_array)
Definition: orcania.c:445
free_string_array
void free_string_array(char **array)
Definition: orcania.c:482
string_array_has_value_n
int string_array_has_value_n(const char **array, const char *needle, size_t len)
Definition: orcania.c:610
string_array_has_value_ncase
int string_array_has_value_ncase(const char **array, const char *needle, size_t len)
Definition: orcania.c:627
string_array_has_trimmed_value
int string_array_has_trimmed_value(const char **array, const char *needle)
Definition: orcania.c:644
o_strncpy
char * o_strncpy(char *p1, const char *p2, size_t n)
Definition: orcania.c:250
o_strrchr
char * o_strrchr(const char *haystack, int c)
Definition: orcania.c:334
o_strndup
char * o_strndup(const char *source, size_t len)
Definition: orcania.c:185
o_strcmp
int o_strcmp(const char *p1, const char *p2)
Definition: orcania.c:206
o_strcasestr
char * o_strcasestr(const char *haystack, const char *needle)
Definition: orcania.c:409
msprintf
char * msprintf(const char *message,...)
Definition: orcania.c:107
o_strcpy
char * o_strcpy(char *p1, const char *p2)
Definition: orcania.c:238
o_strstr
char * o_strstr(const char *haystack, const char *needle)
Definition: orcania.c:294
o_strlen
size_t o_strlen(const char *s)
Definition: orcania.c:421
o_strrnchr
const char * o_strrnchr(const char *haystack, size_t len, char c)
Definition: orcania.c:346
mstrcatf
char * mstrcatf(char *source, const char *message,...)
Definition: orcania.c:135
trimcharacter
char * trimcharacter(char *str, char to_remove)
Definition: orcania.c:552
o_strcasecmp
int o_strcasecmp(const char *p1, const char *p2)
Definition: orcania.c:262
trimwhitespace
const char * trimwhitespace(char *str)
Definition: orcania.c:528
o_strdup
char * o_strdup(const char *source)
Definition: orcania.c:176
o_strchr
char * o_strchr(const char *haystack, int c)
Definition: orcania.c:306
o_strnullempty
int o_strnullempty(const char *s)
Definition: orcania.c:433
o_strncasecmp
int o_strncasecmp(const char *p1, const char *p2, size_t n)
Definition: orcania.c:278
str_replace
char * str_replace(const char *source, const char *str_old, const char *str_new)
Definition: orcania.c:57
o_strnchr
const char * o_strnchr(const char *haystack, size_t len, char c)
Definition: orcania.c:318
o_strncmp
int o_strncmp(const char *p1, const char *p2, size_t n)
Definition: orcania.c:222
o_strnstr
char * o_strnstr(const char *haystack, const char *needle, size_t len)
Definition: orcania.c:397
_pointer_list
Definition: orcania.h:355
_pointer_list::size
size_t size
Definition: orcania.h:356
_pointer_list::list
void ** list
Definition: orcania.h:357