diff options
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..b2836eb --- /dev/null +++ b/src/util.h @@ -0,0 +1,29 @@ +#ifndef H_UTIL +#define H_UTIL + +#include <inttypes.h> +#include <sds/sds.h> +#include <arpa/inet.h> +#include <regex.h> + +/* Networking */ +uint16_t atop(const char *port); +struct in_addr aton(const char* cp, int* output); + +/* Error handling */ +void herr(int output, const char* funcName); +void herrc(int output, const char* funcName); + +/* sds string substition */ +sds gsub(sds str, const regex_t* regex, const char* repl); +sds gsub_getm(sds str, const regex_t *regex, const char* repl, int* *matches, int *matchesCount); + +/* Other */ +#define clear_arr(arr) memset(arr, 0, sizeof(arr)/sizeof(*arr)) +int digits(int num); +int streq(const char* first, const char* second); +void shiftLeft(char* str, size_t size, size_t shift); +int isNumber(char* str); +int charCount(char* str, char cmp); + +#endif |
