[PATCH] Added list.h with the needed definitions to manage double linked list. Added...
[MonkeyD.git] / src / include / utils.h
blob307276304df76dc7a04902659905f17efaf30262
1 /* Monkey HTTP Daemon
2 * ------------------
3 * Copyright (C) 2001-2010, Eduardo Silva P. <edsiper@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef MK_UTILS_H
21 #define MK_UTILS_H
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <sys/sysctl.h>
26 #include <unistd.h>
28 #define TRUE 1
29 #define FALSE 0
31 #define MK_UTILS_INT2MKP_BUFFER_LEN 16 /* Maximum buffer length when
32 * converting an int to mk_pointer */
34 #define MK_UTILS_SOMAXCONN_DEFAULT 1024 /* Default for SOMAXCONN value */
36 #include "request.h"
37 #include "memory.h"
38 #include "list.h"
40 #define INTSIZE sizeof(int)
42 #ifdef TRACE
44 #define MK_TRACE_CORE 0
45 #define MK_TRACE_PLUGIN 1
46 #define MK_TRACE_COMP_CORE "core"
48 #define MK_TRACE(...) mk_utils_trace(MK_TRACE_COMP_CORE, MK_TRACE_CORE, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
49 #define PLUGIN_TRACE(...) mk_api->trace(_shortname, MK_TRACE_PLUGIN, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
51 #define ANSI_BOLD "\033[1m"
52 #define ANSI_CYAN "\033[36m"
53 #define ANSI_MAGENTA "\033[35m"
54 #define ANSI_RED "\033[31m"
55 #define ANSI_YELLOW "\033[33m"
56 #define ANSI_BLUE "\033[34m"
57 #define ANSI_GREEN "\033[32m"
58 #define ANSI_WHITE "\033[37m"
59 #define ANSI_RESET "\033[0m"
61 char *envtrace;
62 pthread_mutex_t mutex_trace;
64 #endif
66 /* utils.c */
67 int hex2int(char *pChars);
69 int mk_utils_utime2gmt(mk_pointer **p, time_t date);
70 time_t PutDate_unix(char *date);
72 int mk_buffer_cat(mk_pointer * p, char *buf1, int len1, char *buf2, int len2);
74 int mk_utils_set_daemon();
75 char *mk_utils_hexuri_to_ascii(mk_pointer req_uri);
77 #ifdef TRACE
78 void mk_utils_trace(const char *component, int color, const char *function,
79 char *file, int line, const char* format, ...);
80 #endif
82 int mk_utils_get_somaxconn();
83 int mk_utils_register_pid();
84 int mk_utils_remove_pid();
86 #endif