From b11b1c52280f172ebfa42c3da906ea9aa3ea8799 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Wed, 6 Nov 2019 20:18:29 +0300 Subject: [magi] FastCGI is comming. --- src/utils.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/utils.h (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..a6c0aff --- /dev/null +++ b/src/utils.h @@ -0,0 +1,38 @@ +#ifndef MAGI_INCLUDED_UTILS +#define MAGI_INCLUDED_UTILS + + +static void lowercase(char *str) +{ + if (str) { + while (*str) { + *str = tolower(*str); + ++str; + } + } +} + +static char *create_str(const char *begin, const char *end) +{ + char *res; + res = malloc(end - begin + 1); + if (res) { + memcpy(res, begin, end - begin); + res[end - begin] = 0; + } + return res; +} + +static char *str_alloc(int len) +{ + char *str = malloc(len + 1); + if (str) { + str[len] = 0; + } else { + magi_log("[request] Cannot allocate string."); + } + return str; +} + + +#endif -- cgit v1.2.3