nsapi.h 8.7 KB

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