1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
|
5 * |
|
6 * THE BSD LICENSE |
|
7 * |
|
8 * Redistribution and use in source and binary forms, with or without |
|
9 * modification, are permitted provided that the following conditions are met: |
|
10 * |
|
11 * Redistributions of source code must retain the above copyright notice, this |
|
12 * list of conditions and the following disclaimer. |
|
13 * Redistributions in binary form must reproduce the above copyright notice, |
|
14 * this list of conditions and the following disclaimer in the documentation |
|
15 * and/or other materials provided with the distribution. |
|
16 * |
|
17 * Neither the name of the nor the names of its contributors may be |
|
18 * used to endorse or promote products derived from this software without |
|
19 * specific prior written permission. |
|
20 * |
|
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
|
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 */ |
|
33 |
|
34 #ifndef PUBLIC_NSAPI_H |
|
35 #define PUBLIC_NSAPI_H |
|
36 |
|
37 /* |
|
38 * File: nsapi.h |
|
39 * |
|
40 * Description: |
|
41 * |
|
42 * This file defines an interface for extending the server with |
|
43 * in-process plug-ins. |
|
44 */ |
|
45 |
|
46 #ifdef __cplusplus |
|
47 extern "C" { |
|
48 #endif |
|
49 |
|
50 /* NSAPI version defined by this header file */ |
|
51 #define NSAPI_VERSION 303 |
|
52 |
|
53 /* Define USE_NSAPI_VERSION to use a specific NSAPI version at compile time */ |
|
54 #ifdef USE_NSAPI_VERSION |
|
55 #if USE_NSAPI_VERSION < 300 || USE_NSAPI_VERSION > NSAPI_VERSION |
|
56 #error This header file does not support the requested NSAPI version |
|
57 #else |
|
58 #undef NSAPI_VERSION |
|
59 #define NSAPI_VERSION USE_NSAPI_VERSION |
|
60 #endif |
|
61 #endif |
|
62 |
|
63 /* --- Begin native platform configuration definitions --- */ |
|
64 |
|
65 #if !defined(XP_WIN32) && !defined(XP_UNIX) |
|
66 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) |
|
67 #define XP_WIN32 |
|
68 #else |
|
69 #define XP_UNIX |
|
70 #endif |
|
71 #endif |
|
72 |
|
73 #ifdef XP_UNIX |
|
74 #define NSAPI_PUBLIC |
|
75 #define ZERO(ptr, len) memset(ptr, 0, len) |
|
76 #ifdef AIX |
|
77 #define TCPLEN_T size_t |
|
78 #endif |
|
79 #ifdef HPUX |
|
80 #define TCPLEN_T int |
|
81 #endif |
|
82 #ifndef TCPLEN_T |
|
83 #define TCPLEN_T socklen_t |
|
84 #endif |
|
85 #endif /* XP_UNIX */ |
|
86 |
|
87 #ifdef XP_WIN32 |
|
88 #define NSAPI_PUBLIC __declspec(dllexport) |
|
89 struct iovec { |
|
90 char *iov_base; |
|
91 unsigned iov_len; |
|
92 }; |
|
93 #ifndef S_ISDIR |
|
94 #define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) |
|
95 #endif |
|
96 #ifndef S_ISREG |
|
97 #define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) |
|
98 #endif |
|
99 #ifndef S_ISLNK |
|
100 #define S_ISLNK(x) (0) |
|
101 #endif |
|
102 #define caddr_t PCHAR |
|
103 #define NEED_STRCASECMP |
|
104 #define NEED_STRNCASECMP |
|
105 #define ZERO(ptr, len) ZeroMemory(ptr, len) |
|
106 #define TCPLEN_T int |
|
107 #endif /* XP_WIN32 */ |
|
108 |
|
109 /* --- End native platform configuration definitions --- */ |
|
110 |
|
111 /* --- Begin miscellaneous definitions --- */ |
|
112 |
|
113 /* Used in some places as a length limit on error messages */ |
|
114 #define MAGNUS_ERROR_LEN 1024 |
|
115 |
|
116 /* Carriage return and line feed */ |
|
117 #define CR 13 |
|
118 #define LF 10 |
|
119 #ifdef XP_WIN32 |
|
120 #define ENDLINE "\r\n" |
|
121 #else |
|
122 #define ENDLINE "\n" |
|
123 #endif |
|
124 |
|
125 /* mime.types file identification line */ |
|
126 #define NCC_MT_MAGIC "#--Netscape Communications Corporation MIME Information" |
|
127 #define NCC_MT_MAGIC_LEN 55 |
|
128 |
|
129 /* The character which separates extensions with cinfo_find */ |
|
130 #define CINFO_SEPARATOR '.' |
|
131 |
|
132 /* The maximum length of a line in a mime.types file */ |
|
133 #define CINFO_MAX_LEN 1024 |
|
134 |
|
135 /* The maximum length of an error message */ |
|
136 #define MAX_ERROR_LEN 4096 |
|
137 |
|
138 /* |
|
139 * A warning is a minor mishap, such as a 404 being issued. |
|
140 */ |
|
141 #define LOG_WARN 0 |
|
142 |
|
143 /* |
|
144 * A misconfig is when there is a syntax error or permission violation in |
|
145 * a config file. |
|
146 */ |
|
147 #define LOG_MISCONFIG 1 |
|
148 |
|
149 /* |
|
150 * Security warnings are issued when authentication fails, or a host is |
|
151 * given a 403 return code. |
|
152 */ |
|
153 #define LOG_SECURITY 2 |
|
154 |
|
155 /* |
|
156 * A failure is when a request could not be fulfilled due to an internal |
|
157 * problem, such as a CGI script exiting prematurely, or a filesystem |
|
158 * permissions problem. |
|
159 */ |
|
160 #define LOG_FAILURE 3 |
|
161 |
|
162 /* |
|
163 * A catastrophe is a fatal server error such as running out of |
|
164 * memory or processes, or a system call failing, or even a server crash. |
|
165 * The server child cannot recover from a catastrophe. |
|
166 */ |
|
167 #define LOG_CATASTROPHE 4 |
|
168 |
|
169 /* |
|
170 * Informational message, of no concern. |
|
171 */ |
|
172 #define LOG_INFORM 5 |
|
173 |
|
174 /* |
|
175 * Internal diagnostic message. |
|
176 */ |
|
177 #define LOG_VERBOSE 6 |
|
178 |
|
179 /* |
|
180 * The time format to use in the error log |
|
181 */ |
|
182 #define ERR_TIMEFMT "[%d/%b/%Y:%H:%M:%S]" |
|
183 |
|
184 |
|
185 /* The fd you will get if you are reporting errors to SYSLOG */ |
|
186 #define ERRORS_TO_SYSLOG NULL |
|
187 |
|
188 /* Return codes from file I/O routines */ |
|
189 #define IO_OKAY 1 |
|
190 #define IO_ERROR -1 |
|
191 #define IO_EOF 0 |
|
192 #define NETBUF_EOF -1 |
|
193 #define NETBUF_ERROR -2 |
|
194 #define NETBUF_FULL -3 |
|
195 |
|
196 /* The disk page size on this machine. */ |
|
197 #define FILE_BUFFERSIZE 4096 |
|
198 |
|
199 #ifdef XP_UNIX |
|
200 |
|
201 #define FILE_PATHSEP '/' |
|
202 #define FILE_PARENT "../" |
|
203 |
|
204 #elif defined(XP_WIN32) |
|
205 |
|
206 #define FILE_PATHSEP '/' |
|
207 #define FILE_PARENT "..\\" |
|
208 |
|
209 #endif /* XP_WIN32 */ |
|
210 |
|
211 #define NET_INFINITE_TIMEOUT 0 |
|
212 #define NET_ZERO_TIMEOUT -1 |
|
213 |
|
214 #ifdef USE_REGEX |
|
215 /* WILDPAT uses regular expressions */ |
|
216 #define WILDPAT_VALID(exp) regexp_valid(exp) |
|
217 #define WILDPAT_MATCH(str, exp) regexp_match(str, exp) |
|
218 #define WILDPAT_CMP(str, exp) regexp_cmp(str, exp) |
|
219 #define WILDPAT_CASECMP(str, exp) regexp_casecmp(str, exp) |
|
220 #define WILDPAT_USES_REGEXP 1 |
|
221 #else |
|
222 /* WILDPAT uses shell expressions */ |
|
223 #define WILDPAT_VALID(exp) shexp_valid(exp) |
|
224 #define WILDPAT_MATCH(str, exp) shexp_match(str, exp) |
|
225 #define WILDPAT_CMP(str, exp) shexp_cmp(str, exp) |
|
226 #define WILDPAT_CASECMP(str, exp) shexp_casecmp(str, exp) |
|
227 #define WILDPAT_USES_SHEXP 1 |
|
228 #endif |
|
229 |
|
230 /* Define return codes from WILDPAT_VALID */ |
|
231 #define NON_WILDPAT -1 /* exp is ordinary string */ |
|
232 #define INVALID_WILDPAT -2 /* exp is an invalid pattern */ |
|
233 #define VALID_WILDPAT 1 /* exp is a valid pattern */ |
|
234 |
|
235 /* Define return codes from regexp_valid and shexp_valid */ |
|
236 #define NON_SXP NON_WILDPAT /* exp is an ordinary string */ |
|
237 #define INVALID_SXP INVALID_WILDPAT /* exp is an invalid shell exp */ |
|
238 #define VALID_SXP VALID_WILDPAT /* exp is a valid shell exp */ |
|
239 |
|
240 #define NON_REGEXP NON_SXP |
|
241 #define INVALID_REGEXP INVALID_SXP |
|
242 #define VALID_REGEXP VALID_SXP |
|
243 |
|
244 #define SYSTHREAD_DEFAULT_PRIORITY 16 |
|
245 |
|
246 /* The longest line in the configuration file */ |
|
247 #define CONF_MAXLEN 16384 |
|
248 |
|
249 #define HTTP_DATE_LEN 30 |
|
250 #define HTTP_DATE_FMT "%a, %d %b %Y %T GMT" |
|
251 |
|
252 /* HTTP status codes */ |
|
253 #define PROTOCOL_CONTINUE 100 |
|
254 #define PROTOCOL_SWITCHING 101 |
|
255 #define PROTOCOL_OK 200 |
|
256 #define PROTOCOL_CREATED 201 |
|
257 #define PROTOCOL_ACCEPTED 202 |
|
258 #define PROTOCOL_NONAUTHORITATIVE 203 |
|
259 #define PROTOCOL_NO_RESPONSE 204 |
|
260 #define PROTOCOL_NO_CONTENT 204 |
|
261 #define PROTOCOL_RESET_CONTENT 205 |
|
262 #define PROTOCOL_PARTIAL_CONTENT 206 |
|
263 #define PROTOCOL_MULTI_STATUS 207 |
|
264 #define PROTOCOL_MULTIPLE_CHOICES 300 |
|
265 #define PROTOCOL_MOVED_PERMANENTLY 301 |
|
266 #define PROTOCOL_REDIRECT 302 |
|
267 #define PROTOCOL_SEE_OTHER 303 |
|
268 #define PROTOCOL_NOT_MODIFIED 304 |
|
269 #define PROTOCOL_USE_PROXY 305 |
|
270 #define PROTOCOL_TEMPORARY_REDIRECT 307 |
|
271 #define PROTOCOL_BAD_REQUEST 400 |
|
272 #define PROTOCOL_UNAUTHORIZED 401 |
|
273 #define PROTOCOL_PAYMENT_REQUIRED 402 |
|
274 #define PROTOCOL_FORBIDDEN 403 |
|
275 #define PROTOCOL_NOT_FOUND 404 |
|
276 #define PROTOCOL_METHOD_NOT_ALLOWED 405 |
|
277 #define PROTOCOL_NOT_ACCEPTABLE 406 |
|
278 #define PROTOCOL_PROXY_UNAUTHORIZED 407 |
|
279 #define PROTOCOL_REQUEST_TIMEOUT 408 |
|
280 #define PROTOCOL_CONFLICT 409 |
|
281 #define PROTOCOL_GONE 410 |
|
282 #define PROTOCOL_LENGTH_REQUIRED 411 |
|
283 #define PROTOCOL_PRECONDITION_FAIL 412 |
|
284 #define PROTOCOL_ENTITY_TOO_LARGE 413 |
|
285 #define PROTOCOL_URI_TOO_LARGE 414 |
|
286 #define PROTOCOL_UNSUPPORTED_MEDIA_TYPE 415 |
|
287 #define PROTOCOL_REQUESTED_RANGE_NOT_SATISFIABLE 416 |
|
288 #define PROTOCOL_EXPECTATION_FAILED 417 |
|
289 #define PROTOCOL_LOCKED 423 |
|
290 #define PROTOCOL_FAILED_DEPENDENCY 424 |
|
291 #define PROTOCOL_SERVER_ERROR 500 |
|
292 #define PROTOCOL_NOT_IMPLEMENTED 501 |
|
293 #define PROTOCOL_BAD_GATEWAY 502 |
|
294 #define PROTOCOL_SERVICE_UNAVAILABLE 503 |
|
295 #define PROTOCOL_GATEWAY_TIMEOUT 504 |
|
296 #define PROTOCOL_VERSION_NOT_SUPPORTED 505 |
|
297 #define PROTOCOL_INSUFFICIENT_STORAGE 507 |
|
298 |
|
299 #define PROTOCOL_VERSION_HTTP09 9 |
|
300 #define PROTOCOL_VERSION_HTTP10 100 |
|
301 #define PROTOCOL_VERSION_HTTP11 101 |
|
302 #define CURRENT_PROTOCOL_VERSION PROTOCOL_VERSION_HTTP11 |
|
303 |
|
304 /* Definitions for HTTP over SSL */ |
|
305 #define HTTPS_PORT 443 |
|
306 #define HTTPS_URL "https" |
|
307 |
|
308 /* Definitions for HTTP over TCP */ |
|
309 #define HTTP_PORT 80 |
|
310 #define HTTP_URL "http" |
|
311 |
|
312 |
|
313 #define REQ_MAX_LINE 4096 |
|
314 |
|
315 /* |
|
316 * The REQ_ return codes. These codes are used to determine what the server |
|
317 * should do after a particular module completes its task. |
|
318 * |
|
319 * Func type functions return these as do many internal functions. |
|
320 */ |
|
321 |
|
322 /* The function performed its task, proceed with the request */ |
|
323 #define REQ_PROCEED 0 |
|
324 /* The entire request should be aborted: An error occurred */ |
|
325 #define REQ_ABORTED -1 |
|
326 /* The function performed no task, but proceed anyway */ |
|
327 #define REQ_NOACTION -2 |
|
328 /* Tear down the session and exit */ |
|
329 #define REQ_EXIT -3 |
|
330 /* Restart the entire request-response process */ |
|
331 #define REQ_RESTART -4 |
|
332 /* Too busy to execute this now */ |
|
333 #define REQ_TOOBUSY -5 |
|
334 |
|
335 |
|
336 /**** NSAPI extensions ****/ |
|
337 |
|
338 /* The function is still in progress (async extension) */ |
|
339 #define REQ_PROCESSING -8 |
|
340 |
|
341 /**** END NSAPI extensions ****/ |
|
342 |
|
343 |
|
344 /* --- End miscellaneous definitions --- */ |
|
345 |
|
346 /* --- Begin native platform includes --- */ |
|
347 |
|
348 #ifdef XP_UNIX |
|
349 #include <unistd.h> |
|
350 #include <sys/file.h> |
|
351 #include <alloca.h> /* new */ |
|
352 #ifndef HPUX |
|
353 #include <sys/select.h> |
|
354 #endif |
|
355 #include <sys/socket.h> |
|
356 #include <sys/time.h> |
|
357 #include <sys/types.h> |
|
358 #include <sys/uio.h> |
|
359 #include <fcntl.h> |
|
360 #include <dirent.h> |
|
361 #include <pwd.h> |
|
362 #include <netinet/in.h> |
|
363 #endif /* XP_UNIX */ |
|
364 |
|
365 #ifdef XP_WIN32 |
|
366 #include <wtypes.h> |
|
367 #include <winbase.h> |
|
368 #include <direct.h> |
|
369 #include <winsock.h> |
|
370 #endif /* XP_WIN32 */ |
|
371 |
|
372 #include <sys/stat.h> |
|
373 #include <ctype.h> |
|
374 #include <stdio.h> |
|
375 #include <stdarg.h> |
|
376 #include <stdlib.h> |
|
377 #include <string.h> |
|
378 #include <errno.h> |
|
379 #include <time.h> |
|
380 |
|
381 /* --- End native platform includes --- */ |
|
382 |
|
383 /* --- Begin type definitions --- */ |
|
384 |
|
385 /* NOTE: both SYS_FILE and SYS_NETFD are actually NSPR PRFileDesc * and can */ |
|
386 /* be used with NSPR API calls (after casting them to PRFileDesc *) */ |
|
387 |
|
388 #ifndef SYS_FILE_T |
|
389 typedef void *SYS_FILE; |
|
390 #define SYS_FILE_T void * |
|
391 #endif /* !SYS_FILE_T */ |
|
392 |
|
393 #define SYS_ERROR_FD ((SYS_FILE)-1) |
|
394 |
|
395 #ifndef SYS_NETFD_T |
|
396 typedef void *SYS_NETFD; |
|
397 #define SYS_NETFD_T void * |
|
398 #endif /* !SYS_NETFD_T */ |
|
399 |
|
400 /* Error value for a SYS_NETFD */ |
|
401 #ifndef SYS_NET_ERRORFD |
|
402 #define SYS_NET_ERRORFD ((SYS_NETFD)-1) |
|
403 #endif /* !SYS_NET_ERRORFD */ |
|
404 |
|
405 /* |
|
406 * These structures were originally defined in nsapi.h, but those definitions |
|
407 * were removed in iPlanet Web Server 4.0. The contents of these structures |
|
408 * are now private to the server implementation and must not be accessed |
|
409 * directly. Instead, use the objset_*, object_*, directive_table_*, and |
|
410 * directive_* accessor functions. |
|
411 */ |
|
412 typedef struct directive directive; |
|
413 typedef struct dtable dtable; |
|
414 typedef struct httpd_object httpd_object; |
|
415 typedef struct httpd_objset httpd_objset; |
|
416 |
|
417 /* |
|
418 * Type: filebuffer, filebuf_t |
|
419 * |
|
420 * Description: |
|
421 * |
|
422 * This structure is used to represent a buffered file. On some |
|
423 * systems the file may be memory-mapped. A filebuffer is created |
|
424 * by filebuf_open(), and destroyed by filebuf_close(). |
|
425 * |
|
426 * Notes: |
|
427 * |
|
428 * Direct access to the members of this structure, not using |
|
429 * macros defined here, is discouraged. |
|
430 * |
|
431 * The filebuf alias that used to be defined for this type was |
|
432 * found to conflict with a C++ class of the same name, so it |
|
433 * has been renamed to filebuf_t. |
|
434 */ |
|
435 typedef struct filebuffer filebuffer; |
|
436 |
|
437 /* Version of filebuffer when memory-mapped files are supported */ |
|
438 struct filebuffer { |
|
439 SYS_FILE fd; |
|
440 #ifdef XP_WIN32 |
|
441 HANDLE fdmap; |
|
442 #endif |
|
443 caddr_t fp; |
|
444 int len; |
|
445 |
|
446 unsigned char *inbuf; |
|
447 int cursize; |
|
448 |
|
449 int pos; |
|
450 const char *errmsg; |
|
451 }; |
|
452 |
|
453 /* Return next character or IO_EOF */ |
|
454 #define filebuf_getc(b) ((b)->pos == (b)->len ? IO_EOF : (int)((b)->fp)[(b)->pos++]) |
|
455 |
|
456 #define filebuf_iseof(b) ((b)->pos == (b)->len) |
|
457 |
|
458 /* C++ streamio defines a filebuf class. */ |
|
459 typedef filebuffer filebuf_t; |
|
460 |
|
461 #ifdef XP_WIN32 |
|
462 /* Use a filebuffer to read data from a pipe */ |
|
463 #define pipebuf_getc(b) \ |
|
464 ((b)->pos != (b)->cursize ? (int)((b)->inbuf[(b)->pos++]) : pipebuf_next(b,1)) |
|
465 #endif /* XP_WIN32 */ |
|
466 |
|
467 /* |
|
468 * Type: netbuf |
|
469 * |
|
470 * Description: |
|
471 * |
|
472 * This structure is used to represent a buffered network socket. |
|
473 * It is created by netbuf_open(), and destroyed by netbuf_close(). |
|
474 * |
|
475 * Notes: |
|
476 * |
|
477 * Direct access to the members of this structure, not using |
|
478 * macros defined here, is discouraged. |
|
479 * |
|
480 * The inbuf field used to be (unsigned char *), but is now |
|
481 * simply (char *). The value returned by the netbuf_getc() |
|
482 * macro is (int). |
|
483 */ |
|
484 typedef struct netbuf netbuf; |
|
485 struct netbuf { |
|
486 SYS_NETFD sd; |
|
487 |
|
488 int pos, cursize, maxsize, rdtimeout; |
|
489 #ifdef XP_WIN32 |
|
490 CHAR address[64]; |
|
491 #endif /* XP_WIN32 */ |
|
492 unsigned char *inbuf; |
|
493 char *errmsg; |
|
494 #ifndef XP_WIN32 |
|
495 char address[64]; |
|
496 #endif /* !XP_WIN32 */ |
|
497 }; |
|
498 |
|
499 /* |
|
500 * netbuf_getc gets a character from the given network buffer and returns |
|
501 * it (as an integer). |
|
502 * |
|
503 * It will return (int) IO_ERROR for an error and (int) IO_EOF for |
|
504 * an error condition or EOF respectively. |
|
505 */ |
|
506 #define netbuf_getc(b) \ |
|
507 ((b)->pos != (b)->cursize ? (int)((b)->inbuf[(b)->pos++]) : netbuf_next(b,1)) |
|
508 |
|
509 /* |
|
510 * buffer_error returns the last error that occurred with buffer. Don't use |
|
511 * this unless you know an error occurred. Independent of network/file type. |
|
512 */ |
|
513 #define buffer_error(b) ((b)->errmsg) |
|
514 |
|
515 /* |
|
516 * Type: sendfiledata |
|
517 * |
|
518 * Description: |
|
519 * |
|
520 * This structure is used to pass arguments to the net_sendfile() |
|
521 * function. offset and len may be set to 0 to transmit a file in its |
|
522 * entirety. |
|
523 */ |
|
524 typedef struct sendfiledata sendfiledata; |
|
525 struct sendfiledata { |
|
526 SYS_FILE fd; /* file to send */ |
|
527 size_t offset; /* offset in file to start sending from */ |
|
528 size_t len; /* number of bytes to send from file */ |
|
529 const void *header; /* data to send before file */ |
|
530 int hlen; /* number of bytes to send before file */ |
|
531 const void *trailer; /* data to send after file */ |
|
532 int tlen; /* number of bytes to send after file */ |
|
533 }; |
|
534 |
|
535 /* |
|
536 * Type: NSAPIIOVec |
|
537 * |
|
538 * Description: |
|
539 * |
|
540 * This structure is used to pass arguments to the net_writev() |
|
541 * and FilterWritevFunc() functions. |
|
542 */ |
|
543 #ifdef _LP64 |
|
544 typedef struct NSAPIIOVec NSAPIIOVec; |
|
545 struct NSAPIIOVec { |
|
546 char *iov_base; |
|
547 int iov_len; |
|
548 }; |
|
549 #else |
|
550 typedef struct iovec NSAPIIOVec; |
|
551 #endif /* _LP64 */ |
|
552 |
|
553 |
|
554 /* |
|
555 * Type: cinfo |
|
556 * |
|
557 * Description: |
|
558 * |
|
559 * This is a structure that captures the information in the name/value |
|
560 * pairs on one line of a mime.types file. A cinfo structure is |
|
561 * stored in the memory-resident database, indexed by each of the |
|
562 * file extensions specified in the "exts" name/value pair. It |
|
563 * defines various attributes of resources with names containing |
|
564 * the specified file extensions. |
|
565 * |
|
566 * Notes: |
|
567 * |
|
568 * Pointers to cinfo structures returned by this API may or may not |
|
569 * need to freed by the caller. See the individual function |
|
570 * descriptions. |
|
571 * |
|
572 * The strings referenced by the fields of cinfo structures returned |
|
573 * by this API should be considered read-only, and do not need to be |
|
574 * freed by the caller, even when the cinfo structure does. |
|
575 */ |
|
576 typedef struct cinfo cinfo; |
|
577 struct cinfo { |
|
578 char *type; |
|
579 char *encoding; |
|
580 char *language; |
|
581 }; |
|
582 |
|
583 |
|
584 typedef void* CONDVAR; |
|
585 typedef void *COUNTING_SEMAPHORE; |
|
586 typedef void* CRITICAL; |
|
587 |
|
588 #ifdef XP_UNIX |
|
589 typedef DIR* SYS_DIR; |
|
590 typedef struct dirent SYS_DIRENT; |
|
591 #endif /* XP_UNIX */ |
|
592 |
|
593 #ifdef XP_WIN32 |
|
594 |
|
595 typedef struct dirent_s dirent_s; |
|
596 struct dirent_s { |
|
597 char *d_name; |
|
598 }; |
|
599 |
|
600 typedef struct dir_s dir_s; |
|
601 struct dir_s { |
|
602 HANDLE dp; |
|
603 WIN32_FIND_DATA fdata; |
|
604 dirent_s de; |
|
605 }; |
|
606 |
|
607 typedef dir_s* SYS_DIR; |
|
608 typedef dirent_s SYS_DIRENT; |
|
609 |
|
610 #endif /* XP_WIN32 */ |
|
611 |
|
612 typedef struct pb_param pb_param; |
|
613 struct pb_param { |
|
614 char *name,*value; |
|
615 }; |
|
616 |
|
617 typedef struct pb_entry pb_entry; |
|
618 struct pb_entry { |
|
619 pb_param *param; |
|
620 struct pb_entry *next; |
|
621 }; |
|
622 |
|
623 typedef struct pblock pblock; |
|
624 struct pblock { |
|
625 int hsize; |
|
626 struct pb_entry **ht; |
|
627 }; |
|
628 |
|
629 #ifndef POOL_HANDLE_T |
|
630 #define POOL_HANDLE_T |
|
631 typedef void *pool_handle_t; |
|
632 #endif |
|
633 |
|
634 #ifndef SEMAPHORE_T |
|
635 typedef void *SEMAPHORE; |
|
636 #define SEMAPHORE_T void * |
|
637 #endif /* !SEMAPHORE_T */ |
|
638 |
|
639 #define SESSION_HASHSIZE 5 |
|
640 |
|
641 typedef struct PListStruct_s PListStruct_s; |
|
642 typedef struct ACLListHandle ACLListHandle; |
|
643 |
|
644 #ifndef PR_AF_INET |
|
645 typedef union PRNetAddr PRNetAddr; |
|
646 #endif |
|
647 |
|
648 typedef struct Session Session; |
|
649 typedef struct Request Request; |
|
650 struct Session { |
|
651 pblock *client; /* client-specific information */ |
|
652 |
|
653 SYS_NETFD csd; /* client file descriptor */ |
|
654 netbuf *inbuf; /* input buffer */ |
|
655 int csd_open; |
|
656 |
|
657 struct in_addr iaddr; |
|
658 |
|
659 pool_handle_t *pool; |
|
660 |
|
661 void *clauth; /* v2 ACL client authentication information */ |
|
662 struct Session *next; |
|
663 int fill; |
|
664 struct sockaddr_in local_addr; /* local addr for this session */ |
|
665 |
|
666 PListStruct_s *subject; |
|
667 int ssl; /* 0 = SSL OFF, 1 = SSL ON */ |
|
668 int clientauth; /* 0 = client auth OFF, 1 = client auth ON */ |
|
669 |
|
670 PRNetAddr *pr_client_addr; |
|
671 PRNetAddr *pr_local_addr; |
|
672 }; |
|
673 |
|
674 /* |
|
675 * FuncPtr is a pointer to an NSAPI SAF function |
|
676 */ |
|
677 |
|
678 #ifdef XP_UNIX |
|
679 typedef int Func(pblock *, Session *, Request *); |
|
680 #else /* XP_WIN32 */ |
|
681 typedef int _cdecl Func(pblock *, Session *, Request *); |
|
682 #endif /* XP_WIN32 */ |
|
683 |
|
684 typedef Func *FuncPtr; |
|
685 |
|
686 /* |
|
687 * FuncStruct is a structure used in the static declaration of the |
|
688 * functions. This static declaration is parsed into a hash table at |
|
689 * startup. |
|
690 */ |
|
691 |
|
692 typedef struct FuncStruct FuncStruct; |
|
693 |
|
694 struct FuncStruct { |
|
695 const char * name; |
|
696 FuncPtr func; |
|
697 struct FuncStruct *next; |
|
698 unsigned flags; |
|
699 unsigned poolID; |
|
700 unsigned pool_resolved; |
|
701 }; |
|
702 |
|
703 /* |
|
704 * VSInitFunc, VSDestroyFunc, VSDirectiveInitFunc and VSDirectiveDestroyFunc |
|
705 */ |
|
706 typedef struct VirtualServer VirtualServer; |
|
707 typedef int VSInitFunc(VirtualServer *incoming, const VirtualServer *current); |
|
708 typedef void VSDestroyFunc(VirtualServer *outgoing); |
|
709 typedef VSInitFunc *VSInitFuncPtr; |
|
710 typedef VSDestroyFunc *VSDestroyFuncPtr; |
|
711 typedef int VSDirectiveInitFunc(const directive *dir, VirtualServer *incoming, const VirtualServer *current); |
|
712 typedef void VSDirectiveDestroyFunc(const directive *dir, VirtualServer *outgoing); |
|
713 typedef VSDirectiveInitFunc *VSDirectiveInitFuncPtr; |
|
714 typedef VSDirectiveDestroyFunc *VSDirectiveDestroyFuncPtr; |
|
715 |
|
716 /* |
|
717 * Filter is an opaque filter identifier |
|
718 */ |
|
719 typedef struct Filter Filter; |
|
720 |
|
721 /* |
|
722 * FilterContext stores context associated with a particular filter layer |
|
723 */ |
|
724 |
|
725 typedef struct FilterContext FilterContext; |
|
726 |
|
727 struct FilterContext { |
|
728 pool_handle_t *pool; /* pool context was allocated from */ |
|
729 Session *sn; /* session being processed */ |
|
730 Request *rq; /* request being processed */ |
|
731 void *data; /* filter-defined private data */ |
|
732 }; |
|
733 |
|
734 /* |
|
735 * FilterLayer represents one layer of a filter stack |
|
736 */ |
|
737 |
|
738 typedef struct FilterLayer FilterLayer; |
|
739 |
|
740 struct FilterLayer { |
|
741 Filter *filter; /* the filter at this layer in the filter stack */ |
|
742 FilterContext *context; /* context for the filter */ |
|
743 SYS_NETFD lower; /* access to the next filter layer in the stack */ |
|
744 }; |
|
745 |
|
746 /* |
|
747 * Function prototypes for filter methods |
|
748 */ |
|
749 typedef int (FilterInsertFunc)(FilterLayer *layer, pblock *pb); |
|
750 typedef void (FilterRemoveFunc)(FilterLayer *layer); |
|
751 typedef int (FilterFlushFunc)(FilterLayer *layer); |
|
752 typedef int (FilterReadFunc)(FilterLayer *layer, void *buf, int amount, int timeout); |
|
753 typedef int (FilterWriteFunc)(FilterLayer *layer, const void *buf, int amount); |
|
754 typedef int (FilterWritevFunc)(FilterLayer *layer, const NSAPIIOVec *iov, int iov_size); |
|
755 typedef int (FilterSendfileFunc)(FilterLayer *layer, sendfiledata *sfd); |
|
756 |
|
757 /* |
|
758 * FilterMethods is passed to filter_create() to declare the filter methods for |
|
759 * a new filter. Each instance of the FilterMethods structure should be |
|
760 * initialized using the FILTER_METHODS_INITIALIZER macro. |
|
761 */ |
|
762 |
|
763 typedef struct FilterMethods FilterMethods; |
|
764 |
|
765 struct FilterMethods { |
|
766 size_t size; |
|
767 #if NSAPI_VERSION >= 302 |
|
768 FilterInsertFunc *insert; |
|
769 FilterRemoveFunc *remove; |
|
770 FilterFlushFunc *flush; |
|
771 FilterReadFunc *read; |
|
772 FilterWriteFunc *write; |
|
773 FilterWritevFunc *writev; |
|
774 FilterSendfileFunc *sendfile; |
|
775 #else |
|
776 void *reserved1; |
|
777 void *reserved2; |
|
778 void *reserved3; |
|
779 void *reserved4; |
|
780 void *reserved5; |
|
781 void *reserved6; |
|
782 void *reserved7; |
|
783 #endif /* NSAPI_VERSION >= 302 */ |
|
784 }; |
|
785 |
|
786 #define FILTER_METHODS_INITIALIZER \ |
|
787 { \ |
|
788 sizeof(FilterMethods), \ |
|
789 NULL, /* insert */ \ |
|
790 NULL, /* remove */ \ |
|
791 NULL, /* flush */ \ |
|
792 NULL, /* read */ \ |
|
793 NULL, /* write */ \ |
|
794 NULL, /* writev */ \ |
|
795 NULL /* sendfile */ \ |
|
796 } |
|
797 |
|
798 /* |
|
799 * Filter order definitions for filter_create() |
|
800 */ |
|
801 #define FILTER_CONTENT_GENERATION 0xf0000 |
|
802 #define FILTER_CONTENT_TRANSLATION_HIGH 0xa0000 |
|
803 #define FILTER_CONTENT_TRANSLATION 0x90000 |
|
804 #define FILTER_CONTENT_TRANSLATION_LOW 0x80000 |
|
805 #define FILTER_CONTENT_CODING 0x50000 |
|
806 #define FILTER_TRANSFER_CODING 0x40000 |
|
807 #define FILTER_MESSAGE_CODING 0x30000 |
|
808 #define FILTER_TRANSPORT_CODING 0x20000 |
|
809 #define FILTER_NETWORK 0x10000 |
|
810 |
|
811 typedef struct shmem_s shmem_s; |
|
812 struct shmem_s { |
|
813 void *data; /* the data */ |
|
814 #ifdef XP_WIN32 |
|
815 HANDLE fdmap; |
|
816 #endif /* XP_WIN32 */ |
|
817 int size; /* the maximum length of the data */ |
|
818 |
|
819 char *name; /* internal use: filename to unlink if exposed */ |
|
820 SYS_FILE fd; /* internal use: file descriptor for region */ |
|
821 }; |
|
822 |
|
823 /* Define a handle for a thread */ |
|
824 typedef void* SYS_THREAD; |
|
825 |
|
826 /* Define an error value for the thread handle */ |
|
827 #define SYS_THREAD_ERROR NULL |
|
828 |
|
829 |
|
830 typedef struct conf_global_vars_s conf_global_vars_s; |
|
831 struct conf_global_vars_s { |
|
832 |
|
833 /* What port we listen to */ |
|
834 int Vport; /* OBSOLETE */ |
|
835 #define server_portnum 80 |
|
836 |
|
837 /* What address to bind to */ |
|
838 char *Vaddr; /* OBSOLETE */ |
|
839 |
|
840 /* User to run as */ |
|
841 struct passwd *Vuserpw; |
|
842 |
|
843 /* Directory to chroot to */ |
|
844 char *Vchr; |
|
845 |
|
846 /* Where to log our pid to */ |
|
847 char *Vpidfn; |
|
848 |
|
849 #define pool_max conf_getglobals()->Vpool_max |
|
850 int Vpool_max; |
|
851 #define pool_min conf_getglobals()->Vpool_min |
|
852 int Vpool_min; /* OBSOLETE */ |
|
853 #define pool_life conf_getglobals()->Vpool_life |
|
854 int Vpool_life; /* OBSOLETE */ |
|
855 |
|
856 /* For multiprocess UNIX servers, the maximum threads per process */ |
|
857 #define pool_maxthreads conf_getglobals()->Vpool_maxthreads |
|
858 int Vpool_maxthreads; |
|
859 |
|
860 #define pool_minthreads conf_getglobals()->Vpool_minthreads |
|
861 int Vpool_minthreads; /* OBSOLETE */ |
|
862 |
|
863 char *Vsecure_keyfn; /* OBSOLETE */ |
|
864 char *Vsecure_certfn; /* OBSOLETE */ |
|
865 |
|
866 #define security_active 0 |
|
867 int Vsecurity_active; |
|
868 int Vssl3_active; /* OBSOLETE */ |
|
869 int Vssl2_active; /* OBSOLETE */ |
|
870 int Vsecure_auth; /* OBSOLETE */ |
|
871 int Vsecurity_session_timeout; |
|
872 long Vssl3_session_timeout; |
|
873 |
|
874 /* The server's hostname as should be reported in self-ref URLs */ |
|
875 #define server_hostname "x4" |
|
876 char *Vserver_hostname; |
|
877 |
|
878 /* The main object from which all are derived */ |
|
879 #define root_object conf_getglobals()->Vroot_object |
|
880 char *Vroot_object; |
|
881 |
|
882 /* The object set the administrator has asked us to load */ |
|
883 #define std_os conf_getglobals()->Vstd_os |
|
884 httpd_objset *Vstd_os; |
|
885 |
|
886 /* The root of ACL data structures */ |
|
887 void *Vacl_root; |
|
888 |
|
889 /* The main error log, where all errors are logged */ |
|
890 char *Vmaster_error_log; |
|
891 |
|
892 /* The server root directory (contains instance subdirectories) */ |
|
893 #define server_root conf_getglobals()->Vserver_root |
|
894 char *Vserver_root; |
|
895 |
|
896 /* This server's id */ |
|
897 #define server_id conf_getglobals()->Vserver_id |
|
898 char *Vserver_id; |
|
899 |
|
900 /* Admin server users file */ |
|
901 char *Vadmin_users; |
|
902 |
|
903 /* The installation directory (contains bin and lib subdirectories) */ |
|
904 char *Vnetsite_root; |
|
905 |
|
906 /* Digest authentication stale nonce timeout value */ |
|
907 int digest_stale_timeout; |
|
908 |
|
909 int single_accept; /* OBSOLETE */ |
|
910 int num_keep_alives; /* OBSOLETE */ |
|
911 int log_verbose; /* OBSOLETE */ |
|
912 int mmap_flags; /* OBSOLETE */ |
|
913 int mmap_prots; /* OBSOLETE */ |
|
914 int unused1; |
|
915 int unused2; |
|
916 |
|
917 /* Begin Enterprise 3.0 fields */ |
|
918 int accept_language; /* turn accept-language on/off */ |
|
919 |
|
920 char *mtahost; |
|
921 char *nntphost; /* OBSOLETE */ |
|
922 |
|
923 /* The root of ACL data structures */ |
|
924 void *Vacl_root_30; |
|
925 |
|
926 char *agentFilePath; /* OBSOLETE */ |
|
927 |
|
928 int Allowed; /* OBSOLETE */ |
|
929 |
|
930 pblock *genericGlobals; /* OBSOLETE */ |
|
931 |
|
932 char *agentsACLFile; /* OBSOLETE */ |
|
933 |
|
934 int wait_for_cgi; /* OBSOLETE */ |
|
935 int cgiwatch_timeout; /* OBSOLETE */ |
|
936 int started_by_watchdog; |
|
937 int restarted_by_watchdog; |
|
938 int old_accel_cache_enabled; /* OBSOLETE */ |
|
939 int Vssl_cache_entries; |
|
940 int blocking_listen_socket; /* OBSOLETE */ |
|
941 pblock **initfns; |
|
942 char *vs_config_file; /* OBSOLETE */ |
|
943 }; |
|
944 |
|
945 /* Type used for Request rq_attr bit flags */ |
|
946 #ifdef AIX |
|
947 #define RQATTR unsigned |
|
948 #else |
|
949 #define RQATTR unsigned long |
|
950 #endif |
|
951 |
|
952 struct Request { |
|
953 /* Server working variables */ |
|
954 pblock *vars; |
|
955 |
|
956 /* The method, URI, and protocol revision of this request */ |
|
957 pblock *reqpb; |
|
958 /* Protocol specific headers */ |
|
959 int loadhdrs; |
|
960 pblock *headers; |
|
961 |
|
962 /* Server's response headers */ |
|
963 int senthdrs; |
|
964 pblock *srvhdrs; |
|
965 |
|
966 /* The object set constructed to fulfill this request */ |
|
967 httpd_objset *os; |
|
968 /* Array of objects that were created from .nsconfig files */ |
|
969 httpd_objset *tmpos; |
|
970 |
|
971 /* The stat last returned by request_stat_path */ |
|
972 char *statpath; |
|
973 char *staterr; |
|
974 struct stat *finfo; |
|
975 |
|
976 /* access control state */ |
|
977 int aclstate; /* ACL decision state */ |
|
978 int acldirno; /* deciding ACL directive number */ |
|
979 char *aclname; /* name of deciding ACL */ |
|
980 pblock *aclpb; /* OBSOLETE */ |
|
981 /* 3.0 ACL list pointer */ |
|
982 ACLListHandle *acllist; |
|
983 |
|
984 int request_is_cacheable; /* */ |
|
985 int directive_is_cacheable; /* set by SAFs with no external side effects that make decisions based solely on URI and path */ |
|
986 |
|
987 char *cached_headers; /* OBSOLETE */ |
|
988 int cached_headers_len; /* OBSOLETE */ |
|
989 char *unused; |
|
990 |
|
991 /* HTTP/1.1 features */ |
|
992 #define REQ_TIME(x) (x)->req_start |
|
993 time_t req_start; /* time request arrived - used for selecting weak or strong cache validation */ |
|
994 short protv_num; /* protocol version number */ |
|
995 short method_num; /* method number */ |
|
996 struct rq_attr { |
|
997 RQATTR abs_uri:1; /* set if absolute URI was used */ |
|
998 RQATTR chunked:1; /* chunked transfer-coding */ |
|
999 RQATTR keep_alive:1; /* connection keep-alive */ |
|
1000 RQATTR pipelined:1; /* request packet is pipelined */ |
|
1001 RQATTR internal_req:1; /* this was an internal request */ |
|
1002 RQATTR perm_req:1; /* don't FREE() this request */ |
|
1003 RQATTR header_file_present:1; /* OBSOLETE */ |
|
1004 RQATTR footer_file_present:1; /* OBSOLETE */ |
|
1005 RQATTR jvm_attached:1; /* OBSOLETE */ |
|
1006 RQATTR req_restarted:1; /* request was restarted */ |
|
1007 RQATTR jvm_request_locked:1; /* used for first-request serialization on some platforms */ |
|
1008 RQATTR default_type_set:1; /* set if default types were set using set-default-type objecttype function */ |
|
1009 RQATTR is_web_app:1; /* OBSOLETE */ |
|
1010 RQATTR ssl_unclean_shutdown:1; /* set if browser requires unclean SSL shutdown */ |
|
1011 RQATTR vary_accept_language:1; /* set if request was restarted based on an accept-language header */ |
|
1012 RQATTR reserved:17; /* if you add a flag, make sure to subtract from this */ |
|
1013 } rq_attr; |
|
1014 char *hostname; /* hostname used to access server (always non-NULL) */ |
|
1015 int allowed; /* OBSOLETE */ |
|
1016 int byterange; /* OBSOLETE */ |
|
1017 short status_num; /* HTTP status code */ |
|
1018 |
|
1019 int staterrno; /* used for rqstat */ |
|
1020 Request *orig_rq; /* original Request - used for internal redirects */ |
|
1021 }; |
|
1022 |
|
1023 /* Request attribute macros */ |
|
1024 #define ABS_URI(x) (x)->rq_attr.abs_uri |
|
1025 #define CHUNKED(x) (x)->rq_attr.chunked |
|
1026 #define KEEP_ALIVE(x) (x)->rq_attr.keep_alive |
|
1027 #define PIPELINED(x) (x)->rq_attr.pipelined |
|
1028 #define INTERNAL_REQUEST(x) (x)->rq_attr.internal_req |
|
1029 #define RESTARTED_REQUEST(x) (x)->rq_attr.req_restarted |
|
1030 #define PERM_REQUEST(x) (x)->rq_attr.perm_req |
|
1031 #define JVM_REQUEST_LOCKED(x) (x)->rq_attr.jvm_request_locked |
|
1032 #define SSL_UNCLEAN_SHUTDOWN(x) (x)->rq_attr.ssl_unclean_shutdown |
|
1033 #define VARY_ACCEPT_LANGUAGE(x) (x)->rq_attr.vary_accept_language |
|
1034 |
|
1035 /* Define methods for HTTP/1.1 */ |
|
1036 #define METHOD_HEAD 0 |
|
1037 #define METHOD_GET 1 |
|
1038 #define METHOD_PUT 2 |
|
1039 #define METHOD_POST 3 |
|
1040 #define METHOD_DELETE 4 |
|
1041 #define METHOD_TRACE 5 |
|
1042 #define METHOD_OPTIONS 6 |
|
1043 /* The following methods are Netscape method extensions */ |
|
1044 #define METHOD_MOVE 7 |
|
1045 #define METHOD_INDEX 8 |
|
1046 #define METHOD_MKDIR 9 |
|
1047 #define METHOD_RMDIR 10 |
|
1048 #define METHOD_COPY 11 |
|
1049 #define METHOD_MAX 12 /* Number of methods available on this server */ |
|
1050 |
|
1051 #define ISMGET(r) ((r)->method_num == METHOD_GET) |
|
1052 #define ISMHEAD(r) ((r)->method_num == METHOD_HEAD) |
|
1053 #define ISMPUT(r) ((r)->method_num == METHOD_PUT) |
|
1054 #define ISMPOST(r) ((r)->method_num == METHOD_POST) |
|
1055 #define ISMDELETE(r) ((r)->method_num == METHOD_DELETE) |
|
1056 #define ISMMOVE(r) ((r)->method_num == METHOD_MOVE) |
|
1057 #define ISMINDEX(r) ((r)->method_num == METHOD_INDEX) |
|
1058 #define ISMMKDIR(r) ((r)->method_num == METHOD_MKDIR) |
|
1059 #define ISMRMDIR(r) ((r)->method_num == METHOD_RMDIR) |
|
1060 #define ISMCOPY(r) ((r)->method_num == METHOD_COPY) |
|
1061 #define ISMTRACE(r) ((r)->method_num == METHOD_TRACE) |
|
1062 #define ISMOPTIONS(r) ((r)->method_num == METHOD_OPTIONS) |
|
1063 |
|
1064 |
|
1065 /* --- End type definitions --- */ |
|
1066 |
|
1067 /* --- Begin dispatch vector table definition --- */ |
|
1068 /* --- End dispatch vector table definition --- */ |
|
1069 |
|
1070 /* --- Begin API macro definitions --- */ |
|
1071 |
|
1072 #ifndef INTNSAPI |
|
1073 |
|
1074 #if NSAPI_VERSION >= 301 |
|
1075 |
|
1076 /* |
|
1077 * In Sun ONE Web Server 6.1 and higher, http_parse_request("", NULL, NULL) |
|
1078 * returns the NSAPI version. In previous releases, it returns -1. |
|
1079 */ |
|
1080 #define __NSAPI_RUNTIME_VERSION \ |
|
1081 ((*__nsapi30_table->f_http_parse_request)("", NULL, NULL)) |
|
1082 |
|
1083 /* |
|
1084 * NSAPI_RUNTIME_VERSION returns the NSAPI version the server implements. The |
|
1085 * returned NSAPI version number is reliable only in iPlanet Web Server 6.0, |
|
1086 * Netscape Enterprise Server 6.0, and Sun ONE Web Server 6.0 and higher. |
|
1087 */ |
|
1088 #define NSAPI_RUNTIME_VERSION \ |
|
1089 (__NSAPI_RUNTIME_VERSION > 0 ? __NSAPI_RUNTIME_VERSION : 301) |
|
1090 |
|
1091 #endif /* NSAPI_VERSION >= 301 */ |
|
1092 |
|
1093 #define system_version (*__nsapi30_table->f_system_version) |
|
1094 |
|
1095 /* |
|
1096 * Depending on the system, memory allocated via these macros may come from |
|
1097 * an arena. If these functions are called from within an Init function, they |
|
1098 * will be allocated from permanent storage. Otherwise, they will be freed |
|
1099 * when the current request is finished. |
|
1100 */ |
|
1101 |
|
1102 |
|
1103 |
|
1104 #endif /* !INTNSAPI */ |
|
1105 |
|
1106 #ifdef XP_UNIX |
|
1107 #define dir_open opendir |
|
1108 #define dir_read readdir |
|
1109 #define dir_close closedir |
|
1110 #define dir_create(path) mkdir(path, 0755) |
|
1111 #define dir_remove rmdir |
|
1112 #define system_chdir chdir |
|
1113 #define file_unix2local(path,p2) strcpy(p2,path) |
|
1114 #endif /* XP_UNIX */ |
|
1115 |
|
1116 #ifdef XP_WIN32 |
|
1117 #define dir_create _mkdir |
|
1118 #define dir_remove _rmdir |
|
1119 #define system_chdir SetCurrentDirectory |
|
1120 #endif /* XP_WIN32 */ |
|
1121 |
|
1122 /* |
|
1123 * Thread-safe variants of localtime and gmtime |
|
1124 */ |
|
1125 #define system_localtime(curtime, ret) util_localtime(curtime, ret) |
|
1126 #define system_gmtime(curtime, ret) util_gmtime(curtime, ret) |
|
1127 |
|
1128 /* |
|
1129 * pblock_find finds the entry with the given name in pblock pb. |
|
1130 * |
|
1131 * If it is successful, it returns the param block. If not, it returns NULL. |
|
1132 */ |
|
1133 #define pblock_find(name, pb) (pblock_fr(name,pb,0)) |
|
1134 |
|
1135 /* |
|
1136 * pblock_remove behaves exactly like pblock_find, but removes the given |
|
1137 * entry from pb. |
|
1138 */ |
|
1139 #define pblock_remove(name, pb) (pblock_fr(name,pb,1)) |
|
1140 |
|
1141 /* |
|
1142 * session_dns returns the DNS hostname of the client of this session, |
|
1143 * and inserts it into the client pblock. Returns NULL if unavailable. |
|
1144 */ |
|
1145 #define session_dns(sn) session_dns_lookup(sn, 0) |
|
1146 |
|
1147 /* |
|
1148 * session_maxdns looks up a hostname from an IP address, and then verifies |
|
1149 * that the host is really who they claim to be. |
|
1150 */ |
|
1151 #define session_maxdns(sn) session_dns_lookup(sn, 1) |
|
1152 |
|
1153 |
|
1154 /* nsapi functions */ |
|
1155 |
|
1156 ssize_t net_write(SYS_NETFD fd, void *buf, size_t nbytes); |
|
1157 |
|
1158 NSAPI_PUBLIC pb_param *INTparam_create(const char *name, const char *value); |
|
1159 |
|
1160 NSAPI_PUBLIC int INTparam_free(pb_param *pp); |
|
1161 |
|
1162 NSAPI_PUBLIC pblock *INTpblock_create(int n); |
|
1163 |
|
1164 NSAPI_PUBLIC void INTpblock_free(pblock *pb); |
|
1165 |
|
1166 NSAPI_PUBLIC char *INTpblock_findval(const char *name, const pblock *pb); |
|
1167 |
|
1168 NSAPI_PUBLIC pb_param *INTpblock_nvinsert(const char *name, const char *value, pblock *pb); |
|
1169 |
|
1170 NSAPI_PUBLIC pb_param *pblock_nvlinsert(const char *name, int namelen, const char *value, int valuelen, pblock *pb); |
|
1171 |
|
1172 NSAPI_PUBLIC pb_param *INTpblock_nninsert(const char *name, int value, pblock *pb); |
|
1173 |
|
1174 NSAPI_PUBLIC void INTpblock_pinsert(pb_param *pp, pblock *pb); |
|
1175 |
|
1176 NSAPI_PUBLIC int INTpblock_str2pblock(const char *str, pblock *pb); |
|
1177 |
|
1178 NSAPI_PUBLIC char *INTpblock_pblock2str(const pblock *pb, char *str); |
|
1179 |
|
1180 NSAPI_PUBLIC int INTpblock_copy(const pblock *src, pblock *dst); |
|
1181 |
|
1182 NSAPI_PUBLIC pblock *INTpblock_dup(const pblock *src); |
|
1183 |
|
1184 NSAPI_PUBLIC char **INTpblock_pb2env(const pblock *pb, char **env); |
|
1185 |
|
1186 NSAPI_PUBLIC void pblock_nvreplace (const char *name, const char *value, pblock *pb); |
|
1187 |
|
1188 NSAPI_PUBLIC pb_param *pblock_param_create(pblock *pb, const char *name, const char *value); |
|
1189 |
|
1190 NSAPI_PUBLIC pblock *pblock_create_pool(pool_handle_t *pool_handle, int n); |
|
1191 |
|
1192 NSAPI_PUBLIC pb_param *INTpblock_fr(const char *name, pblock *pb, int remove); |
|
1193 |
|
1194 NSAPI_PUBLIC char *INTpblock_replace(const char *name,char * new_value,pblock *pb); |
|
1195 |
|
1196 NSAPI_PUBLIC int INTpblock_str2pblock_lowercasename(const char *str, pblock *pb); |
|
1197 |
|
1198 //NSAPI_PUBLIC pb_param *pblock_removeone(pblock *pb); |
|
1199 |
|
1200 //NSAPI_PUBLIC const pb_key *pblock_key(const char *name); |
|
1201 |
|
1202 //NSAPI_PUBLIC pb_param *pblock_key_param_create(pblock *pb, const pb_key *key, const char *value, int valuelen); |
|
1203 |
|
1204 //NSAPI_PUBLIC char *pblock_findkeyval(const pb_key *key, const pblock *pb); |
|
1205 |
|
1206 //NSAPI_PUBLIC pb_param *pblock_findkey(const pb_key *key, const pblock *pb); |
|
1207 |
|
1208 //NSAPI_PUBLIC pb_param *pblock_removekey(const pb_key *key, pblock *pb); |
|
1209 |
|
1210 //NSAPI_PUBLIC pb_param *pblock_kvinsert(const pb_key *key, const char *value, int valuelen, pblock *pb); |
|
1211 |
|
1212 //NSAPI_PUBLIC void pblock_kpinsert(const pb_key *key, pb_param *pp, pblock *pb); |
|
1213 |
|
1214 //NSAPI_PUBLIC void pblock_kvreplace(const pb_key *key, const char *value, int valuelen, pblock *pb); |
|
1215 |
|
1216 //NSAPI_PUBLIC pb_param *pblock_kninsert(const pb_key *key, int value, pblock *pb); |
|
1217 |
|
1218 //NSAPI_PUBLIC pb_param *pblock_kllinsert(const pb_key *key, PRInt64 value, pblock *pb); |
|
1219 |
|
1220 #define param_create INTparam_create |
|
1221 #define param_free INTparam_free |
|
1222 #define pblock_create INTpblock_create |
|
1223 #define pblock_free INTpblock_free |
|
1224 #define pblock_findval INTpblock_findval |
|
1225 #define pblock_nvinsert INTpblock_nvinsert |
|
1226 #define pblock_nninsert INTpblock_nninsert |
|
1227 #define pblock_pinsert INTpblock_pinsert |
|
1228 #define pblock_str2pblock INTpblock_str2pblock |
|
1229 #define pblock_pblock2str INTpblock_pblock2str |
|
1230 #define pblock_copy INTpblock_copy |
|
1231 #define pblock_dup INTpblock_dup |
|
1232 #define pblock_pb2env INTpblock_pb2env |
|
1233 #define pblock_fr INTpblock_fr |
|
1234 #define pblock_replace INTpblock_replace |
|
1235 |
|
1236 |
|
1237 |
|
1238 void protocol_status(Session *sn, Request *rq, int n, const char *m); |
|
1239 |
|
1240 int http_start_response(Session *sn, Request *rq); |
|
1241 #define protocol_start_response http_start_response |
|
1242 int request_header(char *name, char **value, Session *sn, Request *rq); |
|
1243 |
|
1244 typedef void (*thrstartfunc)(void *); |
|
1245 SYS_THREAD INTsysthread_start(int prio, int stksz, thrstartfunc fn, void *arg); |
|
1246 NSAPI_PUBLIC void INTsysthread_sleep(int milliseconds); |
|
1247 |
|
1248 #define systhread_start INTsysthread_start |
|
1249 #define systhread_sleep INTsysthread_sleep |
|
1250 |
|
1251 |
|
1252 void webserver_atrestart(void (*fn)(void *), void *data); |
|
1253 #define magnus_atrestart webserver_atrestart |
|
1254 |
|
1255 |
|
1256 NSAPI_PUBLIC int INTshexp_match(const char *str, const char *exp); |
|
1257 #define shexp_match INTshexp_match |
|
1258 |
|
1259 |
|
1260 |
|
1261 NSAPI_PUBLIC char *session_dns_lookup(Session *s, int verify); |
|
1262 |
|
1263 |
|
1264 /* --- OBSOLETE ---------------------------------------------------------- |
|
1265 * The following macros/functions are obsolete and are only maintained for |
|
1266 * compatibility. Do not use them. |
|
1267 * ----------------------------------------------------------------------- |
|
1268 */ |
|
1269 |
|
1270 |
|
1271 /* new macro and function definitions begin */ |
|
1272 |
|
1273 /* netbuf functions */ |
|
1274 NSAPI_PUBLIC netbuf *netbuf_open(SYS_NETFD sd, int sz); |
|
1275 |
|
1276 NSAPI_PUBLIC void netbuf_close(netbuf *buf); |
|
1277 |
|
1278 NSAPI_PUBLIC unsigned char * netbuf_replace(netbuf *buf, |
|
1279 unsigned char *inbuf, int pos, int cursize, int maxsize); |
|
1280 |
|
1281 NSAPI_PUBLIC int netbuf_next(netbuf *buf, int advance); |
|
1282 |
|
1283 NSAPI_PUBLIC int netbuf_getbytes(netbuf *buf, char *buffer, int size); |
|
1284 |
|
1285 NSAPI_PUBLIC int netbuf_grab(netbuf *buf, int sz); |
|
1286 |
|
1287 /* end new macro and function definitions */ |
|
1288 |
|
1289 #define SYS_STDERR STDERR_FILENO |
|
1290 |
|
1291 #ifdef XP_WIN32 |
|
1292 |
|
1293 typedef HANDLE pid_t; |
|
1294 |
|
1295 #define ERROR_PIPE \ |
|
1296 (ERROR_BROKEN_PIPE | ERROR_BAD_PIPE | \ |
|
1297 ERROR_PIPE_BUSY | ERROR_PIPE_LISTENING | ERROR_PIPE_NOT_CONNECTED) |
|
1298 #define CONVERT_TO_PRINTABLE_FORMAT(Filename) \ |
|
1299 { \ |
|
1300 register char *s; \ |
|
1301 if (Filename) \ |
|
1302 for (s = Filename; *s; s++) \ |
|
1303 if ( *s == '\\') \ |
|
1304 *s = '/'; \ |
|
1305 } |
|
1306 #define CONVERT_TO_NATIVE_FS(Filename) \ |
|
1307 { \ |
|
1308 register char *s; \ |
|
1309 if (Filename) \ |
|
1310 for (s = Filename; *s; s++) \ |
|
1311 if ( *s == '/') \ |
|
1312 *s = '\\'; \ |
|
1313 } |
|
1314 |
|
1315 #ifdef INTNSAPI |
|
1316 NSAPI_PUBLIC extern nsapi_dispatch_t *__nsapi30_table; |
|
1317 #if NSAPI_VERSION >= 302 |
|
1318 NSAPI_PUBLIC extern nsapi302_dispatch_t *__nsapi302_table; |
|
1319 #endif /* NSAPI_VERSION >= 302 */ |
|
1320 #if NSAPI_VERSION >= 303 |
|
1321 NSAPI_PUBLIC extern nsapi303_dispatch_t *__nsapi303_table; |
|
1322 #endif /* NSAPI_VERSION >= 303 */ |
|
1323 #else |
|
1324 __declspec(dllimport) nsapi_dispatch_t *__nsapi30_table; |
|
1325 #if NSAPI_VERSION >= 302 |
|
1326 __declspec(dllimport) nsapi302_dispatch_t *__nsapi302_table; |
|
1327 #endif /* NSAPI_VERSION >= 302 */ |
|
1328 #if NSAPI_VERSION >= 303 |
|
1329 __declspec(dllimport) nsapi303_dispatch_t *__nsapi303_table; |
|
1330 #endif /* NSAPI_VERSION >= 303 */ |
|
1331 #endif /* INTNSAPI */ |
|
1332 |
|
1333 #else /* !XP_WIN32 */ |
|
1334 |
|
1335 |
|
1336 #endif /* XP_WIN32 */ |
|
1337 |
|
1338 #ifdef __cplusplus |
|
1339 } |
|
1340 #endif |
|
1341 |
|
1342 #endif /* !PUBLIC_NSAPI_H */ |
|