2005-04-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mod_mono.git] / src / mod_mono.h
blob0e0c92945654fef5ad70d6b77b8d956cfcb0f078
1 /*
2 * mod_mono.h
3 *
4 * Authors:
5 * Daniel Lopez Ridruejo
6 * Gonzalo Paniagua Javier
8 * Copyright (c) 2002 Daniel Lopez Ridruejo
9 * (c) 2002-2005 Novell, Inc.
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 #ifndef __MOD_MONO_H
24 #define __MOD_MONO_H
26 #include <errno.h>
27 #include <sys/stat.h>
28 #include <sys/types.h>
30 #ifndef WIN32
31 #include <sys/select.h>
32 #include <sys/un.h>
33 #endif
35 #ifdef HAVE_UNISTD_H
36 #include <unistd.h>
37 #endif
39 #ifdef HAVE_NETDB_H
40 #include <netdb.h>
41 #endif
43 #ifdef HAVE_SYS_WAIT_H
44 #include <sys/wait.h>
45 #endif
47 #include "httpd.h"
48 #include "http_core.h"
49 #include "http_log.h"
50 #include "http_config.h"
53 #ifdef APACHE13
54 /* Functions needed for making Apache 1.3 module as similar
55 as possible to Apache 2 module, reducing ifdefs in the code itself*/
56 #ifdef HAVE_HTTP_PROTOCOL_H
57 #include "http_protocol.h"
58 #endif
59 #define STATUS_AND_SERVER NULL
60 #ifndef TRUE
61 #define TRUE 1
62 #define FALSE 0
63 #endif
65 #include "multithread.h"
67 #define apr_uri_t uri_components
68 #define apr_pool_t ap_pool
69 #define apr_pcalloc_t ap_pcalloc_t
70 #define apr_pcalloc ap_pcalloc
72 #define apr_table_setn ap_table_setn
73 #define apr_table_setn ap_table_addn
74 #define apr_table_get ap_table_get
75 #define apr_table_elts ap_table_elts
76 #define apr_table_entry_t table_entry
78 #define apr_array_header array_header
79 #define apr_array_header_t array_header
80 #define apr_pstrdup ap_pstrdup
81 #define apr_pstrcat ap_pstrcat
82 #define apr_psprintf ap_psprintf
83 #define apr_status_t int
84 #define apr_os_sock_t int
85 #define APR_SUCCESS 0
86 #define apr_os_sock_get(fdptr, sock) (*(fdptr) = (sock)->fd)
87 #define apr_socket_timeout_set(sock, t) ((sock)->timeout = t)
88 #define apr_socket_close(sock) (ap_pclosesocket ((sock)->pool, (sock)->fd))
89 #define APR_INET PF_INET
90 #define apr_time_from_sec(x) (x * 1000000)
91 #define APR_OFFSET(p_type,field) \
92 ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
94 #define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
97 typedef time_t apr_interval_time_t;
98 typedef size_t apr_size_t;
99 typedef struct apr_socket apr_socket_t;
100 struct apr_socket {
101 apr_pool_t *pool;
102 int fd;
103 time_t timeout;
106 typedef struct mysockaddr apr_sockaddr_t;
107 struct mysockaddr {
108 apr_pool_t *pool;
109 size_t addrlen;
110 struct sockaddr *addr;
113 static apr_status_t
114 apr_socket_send (apr_socket_t *sock, const char *buf, apr_size_t *len);
116 static apr_status_t
117 apr_socket_recv (apr_socket_t *sock, char *buf, apr_size_t *len);
119 extern int ap_standalone;
120 extern time_t ap_restart_time;
122 #include <ap_alloc.h>
123 /* End Apache 1.3 only */
124 #else
125 /* Apache 2 only */
126 #define STATUS_AND_SERVER 0, NULL
127 #include <http_protocol.h>
128 #include <util_script.h>
129 #include <apr_strings.h>
130 #include <apr_support.h>
131 /* End Apache 2 only */
132 #endif
134 /* Some defaults */
135 #ifndef MONO_PREFIX
136 #define MONO_PREFIX "/usr"
137 #endif
139 #ifdef WIN32
140 #define DIRECTORY_SEPARATOR ";"
141 #else
142 #define DIRECTORY_SEPARATOR ":"
143 #endif
145 #define EXECUTABLE_PATH MONO_PREFIX "/bin/mono"
146 #define MONO_PATH MONO_PREFIX "/lib"
147 #define MODMONO_SERVER_PATH MONO_PREFIX "/lib/mono/1.0/mod-mono-server.exe"
148 #define WAPIDIR "/tmp"
149 #define DOCUMENT_ROOT NULL
150 #define APPCONFIG_FILE NULL
151 #define APPCONFIG_DIR NULL
152 #define SOCKET_FILE "/tmp/mod_mono_server"
153 #define LISTEN_ADDRESS "127.0.0.1"
155 /* Converts every int sent into little endian */
156 #ifdef MODMONO_BIGENDIAN
157 #define INT_FROM_LE(val) LE_FROM_INT (val)
158 #define LE_FROM_INT(val) ((unsigned int) ( \
159 (((unsigned int) (val) & (unsigned int) 0x000000ffU) << 24) | \
160 (((unsigned int) (val) & (unsigned int) 0x0000ff00U) << 8) | \
161 (((unsigned int) (val) & (unsigned int) 0x00ff0000U) >> 8) | \
162 (((unsigned int) (val) & (unsigned int) 0xff000000U) >> 24)))
164 #else
165 #define LE_FROM_INT(val) val
166 #define INT_FROM_LE(val) val
167 #endif
169 /* Commands */
170 enum Cmd {
171 FIRST_COMMAND,
172 SEND_FROM_MEMORY = 0,
173 GET_SERVER_VARIABLE,
174 SET_RESPONSE_HEADER,
175 GET_LOCAL_PORT,
176 FLUSH,
177 CLOSE,
178 SHOULD_CLIENT_BLOCK,
179 SETUP_CLIENT_BLOCK,
180 GET_CLIENT_BLOCK,
181 SET_STATUS,
182 DECLINE_REQUEST,
183 MYNOT_FOUND, /* apache 1.3 already defines NOT_FOUND */
184 LAST_COMMAND
187 static char *cmdNames [] = {
188 "SEND_FROM_MEMORY",
189 "GET_SERVER_VARIABLE",
190 "SET_RESPONSE_HEADER",
191 "GET_LOCAL_PORT",
192 "FLUSH",
193 "CLOSE",
194 "SHOULD_CLIENT_BLOCK",
195 "SETUP_CLIENT_BLOCK",
196 "GET_CLIENT_BLOCK",
197 "SET_STATUS",
198 "DECLINE_REQUEST",
199 "NOT_FOUND"
202 /* Module definition */
203 #ifdef APACHE13
204 #define DEFINE_MODULE(x) module MODULE_VAR_EXPORT x
205 #else
206 #define DEFINE_MODULE(x) module AP_MODULE_DECLARE_DATA x
207 #endif
209 /* Directives */
210 #ifdef APACHE13
211 #define MAKE_CMD_ACCESS(name, function_name, description) \
212 { #name, function_name, NULL, ACCESS_CONF, TAKE1, description }
214 #define MAKE_CMD12(name, field_name, description) \
215 { #name, store_config_xsp, (void *) APR_OFFSETOF (xsp_data, field_name), \
216 RSRC_CONF, TAKE12, description }
218 #define MAKE_CMD_ITERATE2(name, field_name, description) \
219 { #name, store_config_xsp, (void *) APR_OFFSETOF (xsp_data, field_name), \
220 RSRC_CONF, ITERATE2, description }
222 #else /* APACHE2 */
224 #define MAKE_CMD_ACCESS(name, function_name, description) \
225 AP_INIT_TAKE1 (#name, function_name, NULL, ACCESS_CONF, description)
227 #define MAKE_CMD12(name, field_name, description) \
228 AP_INIT_TAKE12 (#name, store_config_xsp, \
229 (void *) APR_OFFSETOF (xsp_data, field_name), RSRC_CONF, description)
231 #define MAKE_CMD_ITERATE2(name, field_name, description) \
232 AP_INIT_ITERATE2 (#name, store_config_xsp, \
233 (void *) APR_OFFSETOF (xsp_data, field_name), RSRC_CONF, description)
234 #endif
236 /* Debugging */
237 #ifdef DEBUG
238 #define DEBUG_PRINT(a,...) \
239 if (a >= DEBUG_LEVEL) { \
240 errno = 0; \
241 ap_log_error (APLOG_MARK, APLOG_WARNING, STATUS_AND_SERVER, \
242 __VA_ARGS__); \
244 #else
245 #define DEBUG_PRINT dummy_print
246 static void
247 dummy_print (int a, ...)
250 #endif /* DEBUG */
252 #endif /* __MOD_MONO_H */