Add Eduardo's email to copyright header files
[MonkeyD.git] / src / include / utils.h
blob41b425648cffef1bc4b5ad48564047cb6efd6012
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 /* Defining TRUE and FALSE */
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #define TRUE 1
28 #define FALSE 0
30 /* Tipo de envio de datos en fdprintf(...) */
31 #define CHUNKED 0
32 #define NO_CHUNKED 1
34 #include "request.h"
35 #include "memory.h"
37 #ifdef TRACE
39 #define MK_TRACE_CORE 0
40 #define MK_TRACE_PLUGIN 1
41 #define MK_TRACE_COMP_CORE "core"
43 #define MK_TRACE(...) mk_utils_trace(MK_TRACE_COMP_CORE, MK_TRACE_CORE, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
44 #define PLUGIN_TRACE(...) mk_api->trace(_shortname, MK_TRACE_PLUGIN, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
46 #define ANSI_BOLD "\033[1m"
47 #define ANSI_CYAN "\033[36m"
48 #define ANSI_MAGENTA "\033[35m"
49 #define ANSI_RED "\033[31m"
50 #define ANSI_YELLOW "\033[33m"
51 #define ANSI_BLUE "\033[34m"
52 #define ANSI_GREEN "\033[32m"
53 #define ANSI_WHITE "\033[37m"
54 #define ANSI_RESET "\033[0m"
56 #endif
58 /* utils.c */
59 int SendFile(int socket, struct client_request *cr, struct request *request);
60 int AccessFile(struct stat file);
61 int ExecFile(char *pathfile);
62 int hex2int(char *pChars);
63 char *strstr2(char *s, char *t);
65 mk_pointer PutDate_string(time_t date);
67 time_t PutDate_unix(char *date);
69 char *get_real_string(mk_pointer req_uri);
71 char *get_name_protocol(int remote_protocol);
73 char *m_build_buffer(char **buffer, unsigned long *len, const char *format,
74 ...);
76 int mk_buffer_cat(mk_pointer * p, char *buf1, char *buf2);
78 #define SYML_NOT -1
79 #define SYML_OK 0
80 #define SYML_VAR_OFF 1
81 #define SYML_ERR_NOTFOUND 2
82 #define SYML_ERR_FORBIDDEN 3
84 int Check_symlink(const char *path);
85 char *get_end_position(char *buf);
87 int mk_utils_set_daemon();
88 mk_pointer mk_utils_int2mkp(int n);
90 #ifdef TRACE
91 void mk_utils_trace(const char *component, int color, const char *function,
92 char *file, int line, const char* format, ...);
93 #endif
95 #endif