| 1 |
/** BEGIN COPYRIGHT BLOCK |
| 2 |
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. |
| 3 |
* Copyright (C) 2005 Red Hat, Inc. |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* License: GPL (version 3 or any later version). |
| 7 |
* See LICENSE for details. |
| 8 |
* END COPYRIGHT BLOCK **/ |
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include <config.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef PUBLIC_NSAPI_H |
| 15 |
#define PUBLIC_NSAPI_H |
| 16 |
|
| 17 |
/* |
| 18 |
* File: nsapi.h |
| 19 |
* |
| 20 |
* Description: |
| 21 |
* |
| 22 |
* This file defines an interface for extending the server with |
| 23 |
* in-process plug-ins. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "base/systems.h" |
| 27 |
|
| 28 |
#if defined(FILE_UNIX_MMAP) |
| 29 |
#define FILE_MMAP |
| 30 |
#endif |
| 31 |
|
| 32 |
/* --- Begin miscellaneous definitions --- */ |
| 33 |
|
| 34 |
/* Used in some places as a length limit on error messages */ |
| 35 |
#define MAGNUS_ERROR_LEN 1024 |
| 36 |
|
| 37 |
#define ENDLINE "\n" |
| 38 |
|
| 39 |
/* |
| 40 |
* The maximum length of an error message. NOT RUN-TIME CHECKED |
| 41 |
*/ |
| 42 |
|
| 43 |
#define MAX_ERROR_LEN 1024 |
| 44 |
|
| 45 |
/* A warning is a minor mishap, such as a 404 being issued. */ |
| 46 |
#define LOG_WARN 0 |
| 47 |
|
| 48 |
/* |
| 49 |
* A misconfig is when there is a syntax error or permission violation in |
| 50 |
* a config. file. |
| 51 |
*/ |
| 52 |
#define LOG_MISCONFIG 1 |
| 53 |
|
| 54 |
/* |
| 55 |
* Security warnings are issued when authentication fails, or a host is |
| 56 |
* given a 403 return code. |
| 57 |
*/ |
| 58 |
#define LOG_SECURITY 2 |
| 59 |
|
| 60 |
/* |
| 61 |
* A failure is when a request could not be fulfilled due to an internal |
| 62 |
* problem, such as a CGI script exiting prematurely, or a filesystem |
| 63 |
* permissions problem. |
| 64 |
*/ |
| 65 |
#define LOG_FAILURE 3 |
| 66 |
|
| 67 |
/* |
| 68 |
* A catastrophe is a fatal server error such as running out of |
| 69 |
* memory or processes, or a system call failing, or even a server crash. |
| 70 |
* The server child cannot recover from a catastrophe. |
| 71 |
*/ |
| 72 |
#define LOG_CATASTROPHE 4 |
| 73 |
|
| 74 |
/* |
| 75 |
* Informational message, of no concern. |
| 76 |
*/ |
| 77 |
#define LOG_INFORM 5 |
| 78 |
|
| 79 |
/* |
| 80 |
* Internal log messages to be logged. Internal use only. |
| 81 |
* Enable with "LogVerbose on" in magnus.conf |
| 82 |
*/ |
| 83 |
#define LOG_VERBOSE 6 |
| 84 |
|
| 85 |
/* |
| 86 |
* The time format to use in the error log |
| 87 |
*/ |
| 88 |
|
| 89 |
#define ERR_TIMEFMT "[%d/%b/%Y:%H:%M:%S]" |
| 90 |
|
| 91 |
|
| 92 |
/* The fd you will get if you are reporting errors to SYSLOG */ |
| 93 |
|
| 94 |
#define ERRORS_TO_SYSLOG -1 |
| 95 |
|
| 96 |
/* Return codes from file I/O routines */ |
| 97 |
#define IO_OKAY 1 |
| 98 |
#define IO_ERROR -1 |
| 99 |
#define IO_EOF 0 |
| 100 |
|
| 101 |
/* The disk page size on this machine. */ |
| 102 |
#define FILE_BUFFERSIZE 4096 |
| 103 |
|
| 104 |
#define FILE_PATHSEP '/' |
| 105 |
#define FILE_PARENT "../" |
| 106 |
|
| 107 |
|
| 108 |
/* WILDPAT uses shell expressions */ |
| 109 |
#define WILDPAT_VALID(exp) shexp_valid(exp) |
| 110 |
#define WILDPAT_MATCH(str, exp) shexp_match(str, exp) |
| 111 |
#define WILDPAT_CMP(str, exp) shexp_cmp(str, exp) |
| 112 |
#define WILDPAT_CASECMP(str, exp) shexp_casecmp(str, exp) |
| 113 |
#define WILDPAT_USES_SHEXP 1 |
| 114 |
|
| 115 |
/* Define return codes from WILDPAT_VALID */ |
| 116 |
#define NON_WILDPAT -1 /* exp is ordinary string */ |
| 117 |
#define INVALID_WILDPAT -2 /* exp is an invalid pattern */ |
| 118 |
#define VALID_WILDPAT 1 /* exp is a valid pattern */ |
| 119 |
|
| 120 |
/* Define return codes from regexp_valid and shexp_valid */ |
| 121 |
#define NON_SXP NON_WILDPAT /* exp is an ordinary string */ |
| 122 |
#define INVALID_SXP INVALID_WILDPAT /* exp is an invalid shell exp */ |
| 123 |
#define VALID_SXP VALID_WILDPAT /* exp is a valid shell exp */ |
| 124 |
|
| 125 |
#define SYSTHREAD_DEFAULT_PRIORITY 16 |
| 126 |
|
| 127 |
/* --- Begin native platform includes --- */ |
| 128 |
|
| 129 |
#if defined(FILE_UNIX) || defined(FILE_UNIX_MMAP) |
| 130 |
#include <sys/types.h> /* caddr_t */ |
| 131 |
#include <sys/file.h> |
| 132 |
#include <fcntl.h> |
| 133 |
#include <unistd.h> |
| 134 |
#endif |
| 135 |
|
| 136 |
#if !defined(SUNOS4) && !defined(HPUX) && !defined(LINUX) |
| 137 |
#include <sys/select.h> |
| 138 |
#endif |
| 139 |
#include <sys/time.h> /* struct timeval */ |
| 140 |
#include <sys/socket.h> |
| 141 |
#include <netinet/in.h> /* sockaddr and in_addr */ |
| 142 |
#include <sys/uio.h> |
| 143 |
#include <sys/stat.h> |
| 144 |
#include <ctype.h> /* isspace */ |
| 145 |
#include <stdio.h> |
| 146 |
#include <stdarg.h> |
| 147 |
#include <stdlib.h> |
| 148 |
#include <string.h> |
| 149 |
#include <errno.h> |
| 150 |
#include <time.h> |
| 151 |
#include <dirent.h> |
| 152 |
#include <pwd.h> /* struct passwd */ |
| 153 |
|
| 154 |
#ifndef BIG_LINE |
| 155 |
#define BIG_LINE 1024 |
| 156 |
#endif |
| 157 |
|
| 158 |
|
| 159 |
/* --- End native platform includes --- */ |
| 160 |
|
| 161 |
/* --- Begin type definitions --- */ |
| 162 |
|
| 163 |
#ifndef SYS_FILE_T |
| 164 |
typedef void *SYS_FILE; |
| 165 |
#define SYS_FILE_T void * |
| 166 |
#endif /* !SYS_FILE_T */ |
| 167 |
|
| 168 |
#define SYS_ERROR_FD ((SYS_FILE)-1) |
| 169 |
|
| 170 |
typedef void *CONDVAR; |
| 171 |
typedef void *COUNTING_SEMAPHORE; |
| 172 |
typedef void *CRITICAL; |
| 173 |
typedef DIR *SYS_DIR; |
| 174 |
typedef struct dirent SYS_DIRENT; |
| 175 |
|
| 176 |
typedef struct |
| 177 |
{ |
| 178 |
char *name, *value; |
| 179 |
} pb_param; |
| 180 |
|
| 181 |
struct pb_entry |
| 182 |
{ |
| 183 |
pb_param *param; |
| 184 |
struct pb_entry *next; |
| 185 |
}; |
| 186 |
|
| 187 |
typedef struct |
| 188 |
{ |
| 189 |
int hsize; |
| 190 |
struct pb_entry **ht; |
| 191 |
} pblock; |
| 192 |
|
| 193 |
#ifndef POOL_HANDLE_T |
| 194 |
#define POOL_HANDLE_T |
| 195 |
typedef void *pool_handle_t; |
| 196 |
#endif |
| 197 |
|
| 198 |
typedef struct PListStruct_s PListStruct_s; |
| 199 |
typedef struct ACLListHandle ACLListHandle; |
| 200 |
|
| 201 |
/* Define a handle for a thread */ |
| 202 |
typedef void *SYS_THREAD; |
| 203 |
|
| 204 |
/* Define an error value for the thread handle */ |
| 205 |
#define SYS_THREAD_ERROR NULL |
| 206 |
|
| 207 |
/* |
| 208 |
* Hierarchy of httpd_object |
| 209 |
* |
| 210 |
* An object contains dtables. |
| 211 |
* |
| 212 |
* Each dtable is a table of directives that were entered of a certain type. |
| 213 |
* There is one dtable for each unique type of directive. |
| 214 |
* |
| 215 |
* Each dtable contains an array of directives, each of which is equivalent |
| 216 |
* to one directive that occurred in a config. file. |
| 217 |
* |
| 218 |
* It is up to the caller to determine how many dtables will be allocated |
| 219 |
* and to keep track of which of their directive types maps to which dtable |
| 220 |
* number. |
| 221 |
*/ |
| 222 |
|
| 223 |
|
| 224 |
/* |
| 225 |
* directive is a structure containing the protection and parameters to an |
| 226 |
* instance of a directive within an httpd_object. |
| 227 |
* |
| 228 |
* param is the parameters, client is the protection. |
| 229 |
*/ |
| 230 |
|
| 231 |
typedef struct |
| 232 |
{ |
| 233 |
pblock *param; |
| 234 |
pblock *client; |
| 235 |
} directive; |
| 236 |
|
| 237 |
/* --- End type definitions --- */ |
| 238 |
|
| 239 |
#ifdef NEED_STRCASECMP |
| 240 |
#define strcasecmp(s1, s2) util_strcasecmp(s1, s2) |
| 241 |
#endif /* NEED_STRCASECMP */ |
| 242 |
|
| 243 |
#ifdef NEED_STRNCASECMP |
| 244 |
#define strncasecmp(s1, s2, n) util_strncasecmp(s1, s2, n) |
| 245 |
#endif /* NEED_STRNCASECMP */ |
| 246 |
|
| 247 |
#define dir_open opendir |
| 248 |
#define dir_read readdir |
| 249 |
#define dir_close closedir |
| 250 |
#define dir_create(path) mkdir(path, 0755) |
| 251 |
#define dir_remove rmdir |
| 252 |
#define system_chdir chdir |
| 253 |
#define file_unix2local(path, p2) strcpy(p2, path) |
| 254 |
|
| 255 |
/* |
| 256 |
* Thread-safe variant of localtime |
| 257 |
*/ |
| 258 |
#define system_localtime(curtime, ret) util_localtime(curtime, ret) |
| 259 |
|
| 260 |
#endif /* !PUBLIC_NSAPI_H */ |