rasdaman complete source
defs.h
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 /*------------------------------------------------------------------------*/
24 /* defs.h - Global defines and typedefs. */
25 /*------------------------------------------------------------------------*/
26 
27 
28 #ifndef _DEFS_H
29 #define _DEFS_H
30 
31 
32 /* Name of this daemon
33  */
34 
35 #define PROGRAM_NAME "httpserver"
36 #define PROGRAM_VERSION "1.0"
37 #define DAEMONNAME PROGRAM_NAME "/" PROGRAM_VERSION
38 #define SERVERFIELD "Server: " DAEMONNAME "\r\n"
39 
40 
41 /* These constants *may* be changed
42  */
43 
44 #define BUFFSIZE 8192
45 #define MAXLINELEN 4096
46 #define PIPE_BUFFSIZE 4096
47 #define DATE_BUFFSIZE 40
48 #define IO_BUFFSIZE 65536
49 #define DEFAULT_MAXURLLENGTH 1000000
50 // #define IO_BUFFSIZE 1024
51 
52 /* TimeOut values are given in seconds
53  */
54 
55  /* Timeout when talking with subservers and client */
56 #define DIALOG_TIMEOUT 30
57  /* Timeout when trying to get an unspecified mesage body, for example */
58  /* dynamically generated output (typically CGI output). */
59  /* You may have to *really* wait for it, so don't make it too small! */
60 #define MSGBODY_TIMEOUT 30
61 
62 
63 /* Misc. defines
64  */
65 
66 #ifndef TRUE
67 #define TRUE 1
68 #endif
69 #ifndef FALSE
70 #define FALSE 0
71 #endif
72 
73 #ifdef SOCKLENNOTDEFINED
74 typedef int socklen_t;
75 #endif
76 
77 #define max(a,b) (a > b ? a : b)
78 #define min(a,b) (a < b ? a : b)
79 
80 #define FOREGROUND 0
81 #define BACKGROUND 1
82 
83 /* Std.-Zugriffsberechtigung für neue Dateien */
84 #define FILE_MODE ( S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH )
85 
86 /* Filetypes: */
87 #define FT_NOFILE 0
88 #define FT_CONFFILE 1
89 #define FT_ACCESSLOG 2
90 #define FT_SERVERLOG 3
91 #define FT_COMMLOG 4
92 #define FT_PIDFILE 5
93 #define FT_CACHEFILE 6
94 
95 /* Stringtypes: */
96 #define ST_NOSTRING 0
97 #define ST_HOSTNAME 1
98 #define ST_MAILADDRESS 2
99 
100 
101 /* Pipe Status:
102  */
103 
104 #define PIPE_OPEN 1
105 #define PIPE_CLOSED 0
106 
107 /* LogFile Status:
108  */
109 
110 #define FILE_OPEN 1
111 #define FILE_CLOSED 0
112 
113 /* Logging Modes:
114  * FILE (0) ServerLog und AccessLog einrichten und oeffnen
115  * STDIO (1) ServerLog -> stderr; AccessLog -> stdout
116  * DEBUG (2) Detaillierte Meldungen
117  */
118 
119 #define LF_VERB 0x0001
120 #define LF_STDERR 0x0002
121 
122 #define LM_NORMAL 0 /* Not Verbose, write into log files */
123 #define LM_VERBOSE 1 /* Verbose, write into log files */
124 #define LM_STDERR 2 /* Not Verbose, use STDOUT/STDERR */
125 #define LM_VERBOSE_STDERR 3 /* Verbose, use STDOUT/STDERR */
126 
127 
128 /* LogLevels / ReturnCodes:
129  * DEBUG (1) Detaillierte Aktionsmeldungen
130  * INFO (2) Statusmeldungen
131  * NOTE (3) Hinweise auf besondere Situationen
132  * WARN (5) Behebbare Fehlersituationen
133  * ERROR (10) Fehler die zu Aktionsabbruch fuehren
134  * FAIL (20) Fehler die zum Programmabbruch fuehren
135  */
136 
137 #define OK 0
138 #define DEBUG 1
139 #define INFO 2
140 #define NOTE 3
141 #define WARN 5
142 #define ERROR 10
143 #define FAIL 20
144 #define DUMP 50
145 
146 #define SYS_ERROR -1
147 
148 /* Logging sub-systems:
149  * LG_SERVER generic server logfile
150  * LG_ACCESS HTTP request logfile
151  */
152 
153 #define LG_SERVER 1
154 #define LG_ACCESS 2
155 #define LG_COMM 3
156 
157 /* Error-Type flags:
158  * SYS TRUE System Error: strerror(errno)
159  * PRIV FALSE Application Error
160  */
161 
162 #define E_SYS TRUE
163 #define E_PRIV FALSE
164 
165 /* Configuration Keyword Keys:
166  */
167 
168 #define KEY_ACCESSLOG 1
169 #define KEY_COMMLOG 2
170 #define KEY_INDEXFILE 3
171 #define KEY_MAXURLLENGTH 4
172 #define KEY_PIDFILE 5
173 #define KEY_PORT 6
174 #define KEY_SERVERADMIN 7
175 #define KEY_SERVERLOG 8
176 #define KEY_SERVERNAME 9
177 #define KEY_SERVERROOT 10
178 #define NUM_KEYS 11
179 
180 /* SubServer Communication Status Codes:
181  */
182 
183 #define COMM_UNSUPPORTED -3 /* don't know how to handle comm state */
184 #define COMM_UNEXPECTED -2 /* unexpected data received */
185 #define COMM_FAILED -1 /* trouble while communicating, protocol failure */
186 #define COMM_IDLE 0 /* not connected and ready */
187 #define COMM_CONNECTING 1 /* trying to connect or "Keep-Alive" connection */
188 #define COMM_GET_RESPHEAD 2 /* reading and processing response header */
189 #define COMM_GET_RESPBODY 3 /* reading response body */
190 #define COMM_MAY_GET_BODY 4 /* have to check for response body */
191 #define COMM_HERE_IS_MORE 5 /* select() indicated that there IS more data */
192 #define COMM_DONE 9 /* communication done, protocol OK */
193 /* Currently not in use: */
194 #define COMM_RECONNECTING 10 /* trying to reconnect for authorization */
195 #define COMM_VERIFYING 11 /* analysing response: add. processing required */
196 #define COMM_SENDINGAUTH 12 /* (re-)sending request with authorization */
197 
198 /* Connection Mode Codes:
199  */
200 
201 #define CONN_FAILURE -3 /* Failure when setting up connection */
202 #define CONN_BROKEN -2 /* Connection broken while communicating */
203 #define CONN_UNDEFINED -1 /* Connection not initiated */
204 #define CONN_CLOSE 0 /* Connection will be closed ASAP */
205 #define CONN_OPEN 1 /* Connection is ready for communication */
206 #define CONN_ERROR 2 /* Error condition in communication */
207 
208 /* ToDo Action Codes:
209  */
210 
211 #define DO_NOTHING 0
212 #define DO_SINGLE_SERVER 1
213 #define DO_REWRITE 2
214 #define DO_SEND_RESPONSE 3
215 #define DO_SEND_ERROR 4
216 #define DO_SHUTDOWN 5
217 
218 /* Client Types */
219 #define BROWSER 1
220 #define RASCLIENT 2
221 
222 /* ToDo Argument Codes:
223  */
224 
225 /* - DO_REWRITE: */
226 #define MODE_HTTP_1_0 1
227 #define MODE_HTTP_1_1 2
228 
229 /* - INTERPRETE_POST_REQUEST: - */
230 #define REQU_OK 1
231 #define REQU_UNKNOWN_PARAMETER 2
232 #define REQU_UNKNOWN_CLIENT 3
233 
234 /* - Result Types: Error, MDD, Skalar - */
235 #define RESULT_ERROR 1
236 #define RESULT_MDD 2
237 #define RESULT_SKALAR 3
238 
239 /* - DO_SEND_ERROR: */
240 /* -> use HTTP Status Codes (see http-defs.h) */
241 
242 /* - DO_SHUTDOWN: */
243 #define CLOSE_ALL 1
244 #define CLOSE_CLIENT_ONLY 2 /* Currently not used */
245 
246 /* - DO_NOTHING: */
247 #define REALLY_NOTHING 0
248 
249 #endif /* _DEFS_H not defined */