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