home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Runimage / Delphi50 / Source / Rtl / Win / NSAPI.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  100.1 KB  |  3,000 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Runtime Library                  }
  5. {       Structure definitions and prototypes for the    }
  6. {       Netscape Internet Server API (NSAPI)            }
  7. {                                                       }
  8. {       Copyright (C) 1997,99 Inprise Corporation       }
  9. {                                                       }
  10. {*******************************************************}
  11.  
  12. unit NSApi;
  13.  
  14. {$WEAKPACKAGEUNIT}
  15.  
  16. interface
  17.  
  18. uses Windows, WinSock;
  19.  
  20. {*****************************************************************************}
  21. {* From version.h                                                             }
  22. {*****************************************************************************}
  23. {
  24.  
  25.   This file is included from both C source and the NT installation compiler.
  26.   Because of that, no ifdefs are allowed, and strings must be simple strings
  27.   (not concatenated).
  28.  
  29.   Because macros called PERSONAL_VERSION and ENTERPRISE_VERSION already
  30.   exist, the PRODUCT_VERSION define has _DEF appended.
  31. }
  32.  
  33. const
  34.   PROXY_VERSION_DEF = '2.0b4';
  35.   PROXY_VERSION_STRING = 'Netscape-Proxy/2.0b4';
  36.  
  37.   ADMSERV_VERSION_DEF = '2.0';
  38.   ADMSERV_VERSION_STRING = 'Netscape-Administrator/2.0';
  39.  
  40.   PERSONAL_VERSION_DEF = '2.0b4';
  41.   PERSONAL_VERSION_STRING = 'Netscape-FastTrack/2.0b4';
  42.  
  43.   CATALOG_VERSION_DEF = '1.0b2';
  44.   CATALOG_VERSION_STRING = 'Netscape-Catalog/1.0b2';
  45.  
  46.   RDS_VERSION_DEF = '1.0b2';
  47.   RDS_VERSION_STRING = 'Netscape-RDS/1.0b2';
  48.  
  49.   ENTERPRISE_VERSION_DEF = '2.0b4';
  50.   ENTERPRISE_VERSION_STRING = 'Netscape-Enterprise/2.0b4';
  51.  
  52.   NEWS_VERSION_STRING = 'Netscape 1.1';
  53.  
  54.   BATMAN_VERSION_DEF = '1.0a1';
  55.   BATMAN_VERSION_STRING = 'Batman/1.0a1';
  56.  
  57. {*****************************************************************************}
  58. {* From systems.h                                                             }
  59. {*****************************************************************************}
  60. {
  61.   Lists of defines for systems
  62.   This sets what general flavor the system is (UNIX, etc.),
  63.   and defines what extra functions your particular system needs.
  64. }
  65.  
  66.   DAEMON_LISTEN_SIZE = 100;
  67.  
  68. function strcasecmp(s1, s2: PChar): Integer; cdecl;
  69. function strncasecmp(s1, s2: PChar; n: Integer): Integer; cdecl;
  70. function util_strcasecmp(s1, s2: PChar): Integer; cdecl;
  71. function util_strncasecmp(s1, s2: PChar; n: Integer): Integer; cdecl;
  72.  
  73. type
  74.   PASSWD = Pointer;
  75.   PPASSWD = ^PASSWD;
  76.   TCAddr = PChar; {caddr_t}
  77.   caddr_t = TCAddr;
  78.   TAtRestart = procedure (Data: Pointer) cdecl;
  79.   TMagnusAtRestart = TAtRestart;
  80.   TDaemonAtRestart = TAtRestart;
  81.  
  82. {*****************************************************************************}
  83. {* From netsite.h                                                             }
  84. {*****************************************************************************}
  85. {
  86.    Standard defs for NetSite servers.
  87. }
  88.  
  89. const
  90.   {* Used in some places as a length limit on error messages *}
  91.   MAGNUS_ERROR_LEN = 8192;
  92.  
  93.   {* Carraige return and line feed *}
  94.   CR = 13;
  95.   LF = 10;
  96.   ENDLINE = #13#10;
  97.  
  98.   {* -------------------------- System version on NT------------------------- *}
  99.  
  100.   {* Encode the server version as a number to be able to provide inexpensive
  101.    * dynamic checks on server version - this isn't added in yet. *}
  102.  
  103.   ENTERPRISE_VERSION = 1;
  104.   PERSONAL_VERSION = 2;
  105.   CATALOG_VERSION = 3;
  106.   RDS_VERSION = 4;
  107.  
  108. {* Return server version *}
  109. function system_version: PChar; cdecl;
  110. function MAGNUS_VERSION_STRING: PChar; cdecl;
  111.  
  112. function server_fasttrack: Boolean;
  113. function server_enterprise: Boolean;
  114.  
  115. {* Set server's version dynamically *}
  116. procedure system_version_set(ptr: PChar); cdecl;
  117.  
  118. {* -------------------------- Memory allocation --------------------------- *}
  119.  
  120.  
  121. {*
  122.    Depending on the system, memory allocated via these macros may come from
  123.    an arena. If these functions are called from within an Init function, they
  124.    will be allocated from permanent storage. Otherwise, they will be freed
  125.    when the current request is finished.
  126. *}
  127.  
  128. function MALLOC(size: Integer): Pointer; cdecl;
  129. function system_malloc(size: Integer): Pointer; cdecl;
  130.  
  131. function CALLOC(size: Integer): Pointer; cdecl;
  132. function system_calloc(size: Integer): Pointer; cdecl;
  133.  
  134. function REALLOC(ptr: Pointer; size: Integer): Pointer; cdecl;
  135. function system_realloc(ptr: Pointer; size: Integer): Pointer; cdecl;
  136.  
  137. procedure FREE(ptr: Pointer); cdecl;
  138. procedure system_free(ptr: Pointer); cdecl;
  139.  
  140. function STRDUP(ptr: PChar): PChar; cdecl;
  141. function system_strdup(ptr: PChar): PChar; cdecl;
  142.  
  143. {*
  144.    These macros always provide permanent storage, for use in global variables
  145.    and such. They are checked at runtime to prevent them from returning NULL.
  146. *}
  147.  
  148. function PERM_MALLOC(size: Integer): Pointer; cdecl;
  149. function system_malloc_perm(size: Integer): Pointer; cdecl;
  150.  
  151. function PERM_CALLOC(size: Integer): Pointer; cdecl;
  152. function system_calloc_perm(size: Integer): Pointer; cdecl;
  153.  
  154. function PERM_REALLOC(ptr: Pointer; size: Integer): Pointer; cdecl;
  155. function system_realloc_perm(ptr: Pointer; size: Integer): Pointer; cdecl;
  156.  
  157. procedure PERM_FREE(ptr: Pointer); cdecl;
  158. procedure system_free_perm(ptr: Pointer); cdecl;
  159.  
  160. function PERM_STRDUP(ptr: PChar): PChar; cdecl;
  161. function system_strdup_perm(ptr: PChar): PChar; cdecl;
  162.  
  163. {* Not sure where to put this. *}
  164. procedure magnus_atrestart(fn: TMagnusAtRestart; data: Pointer); cdecl;
  165.  
  166. {*****************************************************************************}
  167. {* From pool.h                                                                }
  168. {*****************************************************************************}
  169. {
  170.   Module for handling memory allocations.
  171.  
  172.   Notes:
  173.   This module is used instead of the NSPR prarena module because the prarenas
  174.   did not fit as cleanly into the existing server.
  175. }
  176.  
  177. type
  178.   pool_handle_t = Pointer;
  179.   TPoolHandle = pool_handle_t;
  180.   PPoolHandle = ^TPoolHandle;
  181.  
  182. { pool_create
  183.   Function to create a new pool.
  184.   Returns non-NULL on success, NULL on failure.
  185. }
  186. function pool_create: PPoolHandle; cdecl;
  187.  
  188. { pool_destroy
  189.   Frees all memory associated with a pool and destroys the pool.
  190. }
  191. procedure pool_destroy(pool_handle: PPoolHandle); cdecl;
  192.  
  193. { pool_enabled
  194.   Check if the pools are enabled and a pool is currently set
  195.   for this thread.  Return 1 if enabled, 0 if not enabled.
  196. }
  197. function pool_enabled: BOOL; cdecl;
  198. function pool_malloc(pool_handle: PPoolHandle; size: Integer): Pointer; cdecl;
  199. procedure pool_free(pool_handle: PPoolHandle; ptr: Pointer); cdecl;
  200. function pool_calloc(pool_handle: PPoolHandle; nelem, elsize: Integer): Pointer; cdecl;
  201. function pool_realloc(pool_handle: PPoolHandle; ptr: Pointer; size: Integer): Pointer; cdecl;
  202. function pool_strdup(pool_handle: PPoolHandle; orig_str: PChar): PChar; cdecl;
  203.  
  204. {*****************************************************************************}
  205. {* From sem.h                                                                 }
  206. {*****************************************************************************}
  207. {
  208.   Attempt to provide multi-process semaphores across platforms
  209. }
  210.  
  211. type
  212.   Semaphore = THandle;
  213.  
  214. const
  215.   SEM_ERROR    = 0;
  216.   {* That oughta hold them (I hope) *}
  217.   SEM_MAXVALUE = 32767;
  218.  
  219. {
  220.   sem_init creates a semaphore using the given name and unique
  221.   identification number. filename should be a file accessible to the
  222.   process. Returns SEM_ERROR on error.
  223. }
  224. function sem_init(name: PChar; Number: Integer): Semaphore; cdecl;
  225.  
  226. {
  227.   sem_terminate de-allocates the given semaphore.
  228. }
  229. procedure sem_terminate(id: Semaphore); cdecl;
  230.  
  231. {
  232.   sem_grab attempts to gain exclusive access to the given semaphore. If
  233.   it can't get it, the caller will block. Returns -1 on error.
  234. }
  235. function sem_grab(id: Semaphore): Integer; cdecl;
  236. function sem_tgrab(id: Semaphore): Integer; cdecl;
  237.  
  238. {
  239.   sem_release releases this process's exclusive control over the given
  240.   semaphore. Returns -1 on error.
  241. }
  242. function sem_release(id: Semaphore): Integer; cdecl;
  243.  
  244. {*****************************************************************************}
  245. {* From crit.h                                                                }
  246. {*****************************************************************************}
  247. {
  248.   Critical section abstraction. Used in threaded servers to protect
  249.   areas where two threads can interfere with each other.
  250.  
  251.   Condvars are condition variables that are used for thread-thread
  252.   synchronization.
  253. }
  254.  
  255. type
  256.   CRITICAL = Pointer;
  257.  
  258. {
  259.   crit_init creates and returns a new critical section variable. At the
  260.   time of creation no one has entered it.
  261. }
  262. function crit_init: CRITICAL; cdecl;
  263.  
  264. {
  265.   crit_enter enters a critical section. If someone is already in the
  266.   section, the calling thread is blocked until that thread exits.
  267. }
  268. procedure crit_enter(id: CRITICAL); cdecl;
  269.  
  270. {
  271.   crit_exit exits a critical section. If another thread is blocked waiting
  272.   to enter, it will be unblocked and given ownership of the section.
  273. }
  274. procedure crit_exit(id: CRITICAL); cdecl;
  275.  
  276. {
  277.   crit_terminate removes a previously allocated critical section variable.
  278. }
  279. procedure crit_terminate(id: CRITICAL); cdecl;
  280.  
  281. type
  282.   CONDVAR = Pointer;
  283.  
  284. {
  285.   condvar_init initializes and returns a new condition variable. You
  286.   must provide a critical section to be associated with this condition
  287.   variable.
  288. }
  289. function condvar_init(id: CRITICAL): CONDVAR; cdecl;
  290.  
  291. {
  292.   condvar_wait blocks on the given condition variable. The calling thread
  293.   will be blocked until another thread calls condvar_notify on this variable.
  294.   The caller must have entered the critical section associated with this
  295.   condition variable prior to waiting for it.
  296. }
  297. procedure condvar_wait(cv: CONDVAR); cdecl;
  298.  
  299. {
  300.   condvar_notify awakens any threads blocked on the given condition
  301.   variable. The caller must have entered the critical section associated
  302.   with this variable first.
  303. }
  304. procedure condvar_notify(cv: CONDVAR); cdecl;
  305.  
  306. {
  307.   condvar_terminate frees the given previously allocated condition variable
  308. }
  309. procedure condvar_terminate(cv: CONDVAR); cdecl;
  310.  
  311. {*****************************************************************************}
  312. {* From file.h                                                                }
  313. {*****************************************************************************}
  314. {
  315.   system specific functions for reading/writing files
  316. }
  317.  
  318. {
  319.   I cheat: These are set up such that system_read can be a macro for read
  320.   under UNIX. IO_OKAY is anything positive.
  321. }
  322.  
  323. const
  324.   IO_OKAY = 1;
  325.   IO_ERROR = -1;
  326.   IO_EOF = 0;
  327.  
  328. {* -------------------------- File related defs --------------------------- *}
  329.  
  330. {* The disk page size on this machine. *}
  331.   FILE_BUFFERSIZE = 4096;
  332.  
  333. {
  334.   The fd data type for this system.
  335. }
  336.  
  337. type
  338.   SYS_FILE = ^TFile;
  339.   TFile = record
  340.     fh: THandle;
  341.     fname: PChar;
  342.     flsem: Semaphore;
  343.   end;
  344.   file_s = TFile;
  345.  
  346. const
  347.   SYS_ERROR_FD = nil;
  348.   SYS_STDERR = nil;
  349.  
  350. type
  351.   pid_t = THandle;
  352.   TPid = pid_t;
  353.  
  354. const
  355.   ERROR_PIPE = ERROR_BROKEN_PIPE or ERROR_BAD_PIPE or ERROR_PIPE_BUSY or
  356.     ERROR_PIPE_LISTENING or ERROR_PIPE_NOT_CONNECTED;
  357.  
  358. procedure CONVERT_TO_PRINTABLE_FORMAT(Filename: PChar);
  359. procedure CONVERT_TO_NATIVE_FS(Filename: PChar);
  360.  
  361. {!!! uses errno from C RTL }
  362. { #define rtfile_notfound() ((errno == ENOENT) || (errno == ESRCH)) }
  363.  
  364. const
  365.   FILE_PATHSEP = '/';
  366.   FILE_PARENT  = '..\';
  367.  
  368. function system_chdir(Path: PChar): BOOL; stdcall;
  369.  
  370. {
  371.   Wrapper for stat system call
  372. }
  373. type
  374.   PStat = ^TStat;
  375.   TStat = record
  376.     st_dev: Word;
  377.     st_ino: Word;
  378.     st_mode: Word;
  379.     st_nlink: SmallInt;
  380.     st_uid: SmallInt;
  381.     st_gid: SmallInt;
  382.     st_rdev: Word;
  383.     st_size: Longint;
  384.     st_atime: Longint;
  385.     st_mtime: Longint;
  386.     st_ctime: Longint;
  387.   end;
  388.   Stat = TStat;
  389.  
  390. function system_stat(name: PChar; var finfo: TStat): Integer; cdecl;
  391.  
  392. {
  393.   Wrapper for rename system call
  394. }
  395. function system_rename(Old, New: PChar): BOOL;
  396.  
  397. {
  398.   Wrapper to remove file
  399. }
  400. function system_unlink(path: PChar): BOOL;
  401.  
  402. {
  403.   system_fread reads sz bytes from fd into to buf, return number of bytes
  404.   read, or IO_EOF if EOF, or IO_ERROR if error.
  405. }
  406. function system_fread(fd: SYS_FILE; buf: Pointer; sz: Integer): Integer; cdecl;
  407. function system_pread(fd: SYS_FILE; buf: Pointer; sz: Integer): Integer; cdecl;
  408.  
  409. {
  410.   system_fopenRO opens a given file for reading only
  411.   system_fopenWA opens a given file for writing, appending new output
  412. }
  413. function system_fopenRO(path: PChar): SYS_FILE; cdecl;
  414. function system_fopenWA(path: PChar): SYS_FILE; cdecl;
  415. function system_fopenRW(path: PChar): SYS_FILE; cdecl;
  416. function system_fopenWT(path: PChar): SYS_FILE; cdecl;
  417.  
  418. {
  419.   system_fclose closes the file fd
  420. }
  421. procedure system_fclose(fd: SYS_FILE); cdecl;
  422.  
  423. {
  424.   This call stops core dumps in a portable way. Returns -1 on error.
  425. }
  426. function system_nocoredumps: Integer; cdecl;
  427.  
  428. function system_winsockerr: PChar; cdecl;
  429. function system_winerr: PChar; cdecl;
  430. function system_lseek(fd: SYS_FILE; off: Longint; wh: Longint): Longint;
  431.  
  432. {
  433.   system_write writes sz bytes from buf to fd. The handler function should
  434.   handle partial writes and anything else like that. Returns IO_*
  435. }
  436. function system_fwrite(fd: SYS_FILE; buf: Pointer; sz: Integer): Integer; cdecl;
  437.  
  438. {
  439.   system_fwrite_atomic locks the given fd before writing to it. This avoids
  440.   interference between simultaneous writes. Returns IO_*
  441. }
  442. function system_fwrite_atomic(fd: SYS_FILE; buf: Pointer; sz: Integer): Integer; cdecl;
  443.  
  444. {
  445.   system_errmsg returns the last error that occured while processing file
  446.   descriptor fd. fd does not have to be specified (if the error is a global
  447.   such as in UNIX systems). PPS: Rob is a halfwit. This parameter is useless.
  448. }
  449. function file_notfound: Integer; cdecl;
  450. function system_errmsg: PChar; cdecl; {system_errmsg_fn}
  451. function system_errmsg_fn: PChar; cdecl;
  452.  
  453. {
  454.   flock locks a file against interference from other processes
  455.   ulock unlocks it.
  456. }
  457. function system_initlock(fd: SYS_FILE): Integer; cdecl;
  458. function system_flock(fd: SYS_FILE): Integer;
  459. function system_ulock(fd: SYS_FILE): Integer;
  460.  
  461. {
  462.   setinherit sets whether the file descriptor fd can be inherited by child
  463.   processes. A non-zero value means they can. Return of -1 means error.
  464. }
  465. function file_setinherit(fd: SYS_FILE; value: Integer): Integer; cdecl;
  466.  
  467. {
  468.   unix2local converts a unix-style pathname to a local one
  469. }
  470. procedure file_unix2local(path, p2: PChar); cdecl;
  471.  
  472. {* -------------------------- Dir related defs ---------------------------- *}
  473.  
  474.  
  475. type
  476.   PDirEnt = ^TDirEnt;
  477.   TDirEnt = packed record
  478.     d_name: PChar;
  479.   end;
  480.   dirent_s = TDirEnt;
  481.  
  482.   PDir = ^TDir;
  483.   TDir = record
  484.     dp: THandle;
  485.     fdata: TWin32FindData;
  486.     de: dirent_s;
  487.   end;
  488.   dir_s = TDir;
  489.  
  490.   SYS_DIR = PDir;
  491.   SYS_DIRENT = TDir;
  492.  
  493. function dir_open(path: PChar): SYS_DIR; cdecl;
  494. function dir_read(ds: SYS_DIR): PDirEnt; cdecl;
  495. procedure dir_close(ds: SYS_DIR); cdecl;
  496. function dir_create(Path: PChar): Integer;
  497. function dir_remove(Path: PChar): Integer;
  498.  
  499. {
  500.   create a directory and any of its parents
  501. }
  502. function dir_create_all(dir: PChar): Integer; cdecl;
  503.  
  504. {
  505.   Thread-safe variants of localtime and gmtime
  506. }
  507. type
  508.   tm = record
  509.     tm_sec: Integer;
  510.     tm_min: Integer;
  511.     tm_hour: Integer;
  512.     tm_mday: Integer;
  513.     tm_mon: Integer;
  514.     tm_year: Integer;
  515.     tm_wday: Integer;
  516.     tm_yday: Integer;
  517.     tm_isdst: Integer;
  518.   end;
  519.   ptm = ^tm;
  520.  
  521. {!!! need conversion }
  522. {function system_localtime(curtime: Longint) localtime(curtime)
  523. function system_gmtime(curtime: Longint) gmtime(curtime) }
  524.  
  525. {*****************************************************************************}
  526. {* From pblock.h                                                              }
  527. {*****************************************************************************}
  528. {
  529.   pblock.h: Header for Parameter Block handling functions
  530.  
  531.   A parameter block is a set of name=value pairs which are generally used
  532.   as parameters, but can be anything. They are kept in a hash table for
  533.   reasonable speed, but if you are doing any intensive modification or
  534.   access of them you should probably make a local copy of each parameter
  535.   while working.
  536.  
  537.   When creating a pblock, you specify the hash table size for that pblock.
  538.   You should set this size larger if you know that many items will be in
  539.   that pblock, and smaller if only a few will be used or if speed is not
  540.   a concern.
  541.  
  542.   The hashing function is very simple right now, and only looks at the
  543.   first character of name.
  544.  
  545. }
  546.  
  547. {* ------------------------------ Structures ------------------------------ *}
  548.  
  549.  
  550. type
  551.   PPbParam = ^TPbParam;
  552.   TPbParam = record
  553.     name: PChar;
  554.     value: PChar;
  555.   end;
  556.   pb_param = TPbParam;
  557.  
  558.   PPbEntry = ^TPbEntry;
  559.   TPbEntry = record
  560.     param: PPbParam;
  561.     next: PPbEntry;
  562.   end;
  563.   pb_entry = TPbEntry;
  564.   PPPbEntry = ^PPbEntry;
  565.  
  566.   PPblock = ^TPblock;
  567.   TPblock = record
  568.     hsize: Integer;
  569.     ht: PPPbEntry;
  570.   end;
  571.   pblock = TPblock;
  572.  
  573.   TPCharArray = array[0..MaxInt div 16 - 1] of PChar;
  574.   PPCharArray = ^TPCharArray;
  575.  
  576. {* ------------------------------ Prototypes ------------------------------ *}
  577.  
  578.  
  579. {
  580.   param_create creates a parameter with the given name and value. If name
  581.   and value are non-NULL, they are copied and placed into the new pb_param
  582.   struct.
  583. }
  584. function param_create(name, value: PChar): PPbParam; cdecl;
  585.  
  586. {
  587.   param_free frees a given parameter if it's non-NULL, and returns 1 if
  588.   p was non-NULL, and 0 if p was NULL.
  589.  
  590.   Useful for error checking pblock_remove.
  591. }
  592. function param_free(pp: PPbParam): Integer; cdecl;
  593.  
  594. {
  595.   pblock_create creates a new pblock with hash table size n.
  596.  
  597.   It returns the newly allocated pblock.
  598. }
  599. function pblock_create(n: Integer): PPblock; cdecl;
  600.  
  601. {
  602.   pblock_free frees the given pblock and any entries inside it.
  603.  
  604.   If you want to save anything in a pblock, remove its entities with
  605.   pblock_remove first and save the pointers you get.
  606. }
  607. procedure pblock_free(pb: PPblock); cdecl;
  608.  
  609. {
  610.   pblock_find finds the entry with the given name in pblock pb.
  611.  
  612.   If it is successful, it returns the param block. If not, it returns NULL.
  613. }
  614. function pblock_find(name: PChar; pb: PPblock): PPbParam;
  615.  
  616. {
  617.   pblock_findval finds the entry with the given name in pblock pb, and
  618.   returns its value, otherwise returns NULL.
  619. }
  620. function pblock_findval(name: PChar; pb: PPblock): PChar; cdecl;
  621.  
  622. {
  623.   pblock_remove behaves exactly like pblock_find, but removes the given
  624.   entry from pb.
  625. }
  626. function pblock_remove(name: PChar; pb: PPblock): PPbParam;
  627.  
  628. {
  629.   pblock_nvinsert creates a new parameter with the given name and value
  630.   and inserts it into pblock pb. The name and value in the parameter are
  631.   also newly allocated. Returns the pb_param it allocated (in case you
  632.   need it).
  633.  
  634.   pblock_nninsert inserts a numerical value.
  635. }
  636. function pblock_nvinsert(name, value: PChar; pb: PPblock): PPbParam; cdecl;
  637. function pblock_nninsert(name: PChar; value: Integer; pb: PPblock): PPbParam; cdecl;
  638.  
  639. {
  640.   pblock_pinsert inserts a pb_param into a pblock.
  641. }
  642. procedure pblock_pinsert(pp: PPbParam; pb: PPblock); cdecl;
  643.  
  644. {
  645.   pblock_str2pblock scans the given string str for parameter pairs
  646.   name=value, or name="value". Any \ must be followed by a literal
  647.   character. If a string value is found, with no unescaped = signs, it
  648.   will be added with the name 1, 2, 3, etc. depending on whether it was
  649.   first, second, third, etc. in the stream (zero doesn't count).
  650.  
  651.   Returns the number of parameters added to the table, or -1 upon error.
  652. }
  653. function pblock_str2pblock(str: PChar; pb: PPblock): Integer; cdecl;
  654.  
  655. {
  656.   pblock_pblock2str places all of the parameters in the given pblock
  657.   into the given string (NULL if it needs creation). It will re-allocate
  658.   more space for the string. Each parameter is separated by a space and of
  659.   the form name="value"
  660. }
  661. function pblock_pblock2str(pb: PPblock; str: PChar): PChar; cdecl;
  662.  
  663. {
  664.   pblock_copy copies the entries in the given source pblock to the
  665.   destination one. The entries are newly allocated so that the original
  666.   pblock may be freed or the new one changed without affecting the other.
  667. }
  668. procedure pblock_copy(src, dst: PPblock); cdecl;
  669.  
  670. {
  671.   pblock_dup creates a new pblock and copies the given source pblock
  672.   into it.  The entries are newly allocated so that the original pblock
  673.   may be freed or the new one changed without affecting the other.
  674. }
  675. function pblock_dup(src: PPblock): PPblock; cdecl;
  676.  
  677. {
  678.   pblock_pb2env copies the given pblock into the given environment, with
  679.   one new env entry for each name/value pair in the pblock.
  680. }
  681. function pblock_pb2env(pb: PPblock; env: PPCharArray): PPCharArray;
  682.  
  683. {* --------------------------- Internal things ---------------------------- *}
  684. function _pblock_fr(name: PChar; pb: PPblock; remove: BOOL): PPbParam; cdecl;
  685.  
  686. {*****************************************************************************}
  687. {* From net.h                                                                 }
  688. {*****************************************************************************}
  689. {
  690.   system specific networking definitions
  691. }
  692.  
  693. const
  694. {* This should be a user-given parameter later *}
  695.   NET_BUFFERSIZE = 8192;
  696. {* So should this. *}
  697.   NET_READ_TIMEOUT = 120;
  698.   NET_WRITE_TIMEOUT = 300;
  699.   NET_INFINITE_TIMEOUT = 0;
  700.   NET_ZERO_TIMEOUT = -1;
  701.  
  702.   SSL_HANDSHAKE_TIMEOUT = 300;
  703.  
  704. {* ------------------------------ Data types ------------------------------ *}
  705. type
  706.   SYS_NETFD = Integer;
  707.  
  708. const
  709.   SYS_NET_ERRORFD = (-1);
  710.  
  711. {* -------------------------------- Global -------------------------------- *}
  712.  
  713. {!!!
  714. extern int net_enabledns;
  715. extern int net_listenqsize;
  716.  
  717.  
  718. int net_accept_init(int port);
  719. void net_accept_terminate(void);
  720. void net_accept_enter(void);
  721. int net_accept_tenter(void);
  722. void net_accept_exit(void);
  723. void net_accept_texit(void);
  724. }
  725.  
  726. {* ------------------------------ Prototypes ------------------------------ *}
  727.  
  728.  
  729. function net_socket(domain, nettype, protocol: Integer): SYS_NETFD; cdecl;
  730. function net_getsockopt(s: SYS_NETFD; level, optname: Integer; optval: Pointer;
  731.   var optlen: Integer): Integer; cdecl;
  732. function net_setsockopt(s: SYS_NETFD; level, optname: Integer; optval: Pointer;
  733.   optlen: Integer): Integer; cdecl;
  734. function net_listen(s: SYS_NETFD; backlog: Integer): Integer; cdecl;
  735. function net_create_listener(ipaddr: PChar; port: Integer): SYS_NETFD; cdecl;
  736. function net_select(nfds: Integer; r, w, e: PFDSet; timeout: PTimeVal): Integer; cdecl;
  737. function net_connect(s: SYS_NETFD; sockaddr: Pointer; namelen: Integer): Integer; cdecl;
  738. function net_ioctl(s: SYS_NETFD; tag: Integer; result: Pointer): Integer; cdecl;
  739. function net_getpeername(s: SYS_NETFD; var name: TSockAddr; var namelen: Integer): Integer; cdecl;
  740. function net_close(s: SYS_NETFD): Integer; cdecl;
  741. function net_bind(s: SYS_NETFD; var name: TSockAddr; namelen: Integer): Integer; cdecl;
  742. function net_accept(s: SYS_NETFD; addr: PSockAddr; addrlen: PInteger): SYS_NETFD; cdecl;
  743. function net_read(sd: SYS_NETFD; buf: PChar; sz, timeout: Integer): Integer; cdecl;
  744. function net_write(sd: SYS_NETFD; buf: PChar; sz: Integer): Integer; cdecl;
  745. {!!! what is iovec???? }
  746. // function _net_writev(sd: SYS_NETFD; struct iovec *iov, int iovlen);
  747.  
  748. {
  749.   net_isalive checks to see if the given sd is still connected to a remote
  750.   host. It returns 0 if the socket is no longer connected, or 1 if it is
  751.   still there. The remote host will not see any side effects.
  752. }
  753. function net_isalive(sd: SYS_NETFD): BOOL; cdecl;
  754.  
  755. {!!! what is iovec???
  756. int _net_simulated_writev(SYS_NETFD sd, struct iovec *iov, int iovlen);
  757. NSAPI_PUBLIC extern int
  758. (*net_writev)(SYS_NETFD sd, struct iovec *iov, int iovlen);
  759. }
  760.  
  761. {
  762.   net_ip2host transforms the given textual IP number into a FQDN. If it
  763.   can't find a FQDN, it will return what it can get. Otherwise, NULL.
  764.  
  765.   verify is whether or not the function should verify the hostname it
  766.   gets. This takes an extra query but is safer for use in access control.
  767. }
  768. function net_ip2host(ip: PChar; verify: BOOL): PChar; cdecl;
  769.  
  770. {*****************************************************************************}
  771. {* From buffer.h                                                              }
  772. {*****************************************************************************}
  773. {
  774.   For performing buffered I/O on a file or socket descriptor.
  775.  
  776.   This is an abstraction to allow I/O to be performed regardless of the
  777.   current system. That way, an integer file descriptor can be used under
  778.   UNIX but a stdio FILE structure could be used on systems which don't
  779.   support that or don't support it as efficiently.
  780.  
  781.   Two abstractions are defined: A file buffer, and a network buffer. A
  782.   distinction is made so that mmap() can be used on files (but is not
  783.   required). Also, the file buffer takes a file name as the object to
  784.   open instead of a file descriptor. A lot of the network buffering
  785.   is almost an exact duplicate of the non-mmap file buffering.
  786.  
  787.   If an error occurs, system-independent means to obtain an error string
  788.   are also provided. However, if the underlying system is UNIX the error
  789.   may not be accurate in a threaded environment.
  790. }
  791.  
  792. {* ------------------------------ Structures ------------------------------ *}
  793.  
  794. type
  795.   PFileBuffer = ^TFileBuffer;
  796.   TFileBuffer = record
  797.     fd: SYS_FILE;
  798.     fdmap: THandle;
  799.     fp: PChar;
  800.     len: Integer;
  801.     inbuf: PChar;   // for buffer_grab
  802.     cursize: Integer;
  803.     pos: Integer;
  804.     errmsg: PChar;
  805.   end;
  806.   filebuffer = TFileBuffer;
  807.   filebuf = filebuffer;
  808.  
  809.   PNetBuf = ^TNetBuf;
  810.   TNetBuf = record
  811.     sd: SYS_NETFD;
  812.     pos,
  813.     cursize,
  814.     maxsize,
  815.     rdtimeout: Integer;
  816.     address: array[0..63] of Char;
  817.     inbuf: PChar;
  818.     errmsg: PChar;
  819.   end;
  820.   netbuf = TNetBuf;
  821.  
  822.  
  823. {* -------------------------------- Macros -------------------------------- *}
  824.  
  825. {
  826.   netbuf_getc gets a character from the given network buffer and returns
  827.   it. (as an integer).
  828.  
  829.   It will return (int) IO_ERROR for an error and (int) IO_EOF for
  830.   an error condition or EOF respectively.
  831. }
  832. function netbuf_getc(b: PNetBuf): Integer;
  833. function filebuf_getc(b: PFileBuffer): Integer;
  834. function pipebuf_getc(b: PFileBuffer): Integer;
  835.  
  836. {
  837.   buffer_error returns the last error that occurred with buffer. Don't use
  838.   this unless you know an error occurred. Independent of network/file type.
  839. }
  840. //!!! #define buffer_error(b) ((b)->errmsg)
  841.  
  842. {* ------------------------------ Prototypes ------------------------------ *}
  843.  
  844.  
  845. {
  846.   buffer_open opens a new buffer reading the specified file, with an I/O
  847.   buffer of size sz, and returns a new buffer structure which will hold
  848.   the data.
  849.  
  850.   If FILE_UNIX_MMAP is defined, this may return NULL. If it does, check
  851.   system_errmsg to get a message about the error.
  852. }
  853.  
  854. function filebuf_open(fd: SYS_FILE; sz: Integer): PFileBuffer; cdecl;
  855. function netbuf_open(sd: SYS_NETFD; sz: Integer): PNetBuf; cdecl;
  856.  
  857. {
  858.   filebuf_create is a convenience function if the file is already open
  859.   or mmap'd.  It creates a new filebuf for use with the mmap'd file.
  860.   If mmap_ptr is NULL, or MMAP is not supported on this system, it
  861.   creates a buffer with buffer size bufsz.
  862. }
  863.  
  864. function filebuf_create(fd: SYS_FILE; mmap_ptr: caddr_t; mmap_len,
  865.   bufsz: Integer): PFileBuffer; cdecl;
  866.  
  867. {
  868.   filebuf_close_buffer is provided to cleanup a filebuf without closing
  869.   the underlying file.  If clean_mmap is 1, and the file is memory mapped,
  870.   the file will be unmapped.  If clean_mmap is 0, the file will not
  871.   be unmapped.
  872. }
  873. procedure filebuf_close_buffer(buf: PFileBuffer; clean_mmap: BOOL); cdecl;
  874.  
  875. {
  876.   filebuf_open_nostat is a convenience function for mmap() buffer opens,
  877.   if you happen to have the stat structure already.
  878. }
  879. function filebuf_open_nostat(fd: SYS_FILE; sz: Integer; var finfo: TStat): PFileBuffer; cdecl;
  880. function pipebuf_open(fd: SYS_FILE; sz: Integer; var finfo: TStat): PFileBuffer; cdecl;
  881.  
  882. {
  883.   buffer_next loads size more bytes into the given buffer and returns the
  884.   first one, or BUFFER_EOF on EOF and BUFFER_ERROR on error.
  885. }
  886. function filebuf_next(buf: PFileBuffer; advance: Integer): Integer; cdecl;
  887. function netbuf_next(buf: PNetBuf; advance: Integer): Integer; cdecl;
  888. function pipebuf_next(buf: PFileBuffer; advance: Integer): Integer; cdecl;
  889.  
  890. {
  891.   buffer_close deallocates a buffer and closes its associated files
  892.   (does not close a network socket).
  893. }
  894. procedure filebuf_close(buf: PFileBuffer); cdecl;
  895. procedure netbuf_close(buf: PNetBuf); cdecl;
  896. procedure pipebuf_close(buf: PFileBuffer); cdecl;
  897.  
  898. {
  899.   buffer_grab will set the buffer's inbuf array to an array of sz bytes
  900.   from the buffer's associated object. It returns the number of bytes
  901.   actually read (between 1 and sz). It returns IO_EOF upon EOF or IO_ERROR
  902.   upon error. The cursize entry of the structure will reflect the size
  903.   of the iobuf array.
  904.  
  905.   The buffer will take care of allocation and deallocation of this array.
  906. }
  907. function filebuf_grab(buf: PFileBuffer; sz: Integer): Integer; cdecl;
  908. function netbuf_grab(buf: PNetBuf; sz: Integer): Integer; cdecl;
  909. function pipebuf_grab(buf: PFileBuffer; sz: Integer): Integer; cdecl;
  910.  
  911. {
  912.   netbuf_buf2sd will send n bytes from the (probably previously read)
  913.   buffer and send them to sd. If sd is -1, they are discarded. If n is
  914.   -1, it will continue until EOF is recieved. Returns IO_ERROR on error
  915.   and the number of bytes sent any other time.
  916. }
  917. function netbuf_buf2sd(buf: PNetBuf; sd: SYS_NETFD; len: Integer): Integer; cdecl;
  918.  
  919. {
  920.   filebuf_buf2sd assumes that nothing has been read from the filebuf,
  921.   and just sends the file out to the given socket. Returns IO_ERROR on error
  922.   and the number of bytes sent otherwise.
  923.  
  924.   Does not currently support you having read from the buffer previously. This
  925.   can be changed transparently.
  926. }
  927. function filebuf_buf2sd(buf: PFileBuffer; sd: SYS_NETFD): Integer; cdecl;
  928.  
  929. {
  930.   NT pipe version of filebuf_buf2sd.
  931. }
  932. function pipebuf_buf2sd(buf: PFileBuffer; sd: SYS_NETFD; len: Integer): Integer; cdecl;
  933.  
  934. {
  935.   NT pipe version of netbuf_buf2sd.
  936. }
  937. function pipebuf_netbuf2sd(buf: PNetBuf; sd: SYS_FILE; len: Integer): Integer; cdecl;
  938.  
  939. {*****************************************************************************}
  940. {* From session.h                                                             }
  941. {*****************************************************************************}
  942. {
  943.   Deals with virtual sessions
  944.  
  945.   A session is the time between when a client connects and when it
  946.   disconnects. Several requests may be handled in one session.
  947. }
  948.  
  949. {* ------------------------------ Structures ------------------------------ *}
  950.  
  951. const
  952.   SESSION_HASHSIZE = 5;
  953.  
  954. type
  955.   PSession = ^TSession;
  956.   TSession = record
  957.     {* Client-specific information *}
  958.     client: PPblock;
  959.     csd: SYS_NETFD;
  960.     inbuf: PNetBuf;
  961.     csd_open: Integer;
  962.     iaddr: TInAddr;
  963.     pool: PPoolHandle;
  964.     clauth: Pointer;   {* ACL client authentication information *}
  965.   end;
  966.   Session = TSession;
  967.  
  968. {* ------------------------------ Prototypes ------------------------------ *}
  969.  
  970. {
  971.   session_create creates a new request structure for the client with the
  972.   given socket descriptor and sockaddr.
  973. }
  974. function session_create(csd: SYS_NETFD; sac: PSockAddrIn): PSession; cdecl;
  975.  
  976. {
  977.   session_free frees the given session
  978. }
  979. procedure session_free(sn: PSession);
  980.  
  981. {
  982.   session_dns returns the DNS hostname of the client of this session,
  983.   and inserts it into the client pblock. Returns NULL if unavailable.
  984. }
  985. function session_dns(sn: PSession): PChar;
  986.  
  987. {
  988.   session_maxdns looks up a hostname from an IP address, and then verifies
  989.   that the host is really who they claim to be.
  990. }
  991. function session_maxdns(sn: PSession): PChar;
  992.  
  993. function session_dns_lookup(sn: PSession; verify: BOOL): PChar; cdecl;
  994.  
  995. {*****************************************************************************}
  996. {* From cinfo.h                                                               }
  997. {*****************************************************************************}
  998. {
  999.   Content Information for a file, i.e. its type, etc.
  1000. }
  1001.  
  1002. {* ------------------------------ Constants ------------------------------- *}
  1003.  
  1004. {
  1005.   This will be the first string in the file, followed by x.x version
  1006.   where x is an integer.
  1007.  
  1008.   Updated due to trendy name change
  1009. }
  1010. const
  1011.   MCC_MT_MAGIC = '#--Mosaic Communications Corporation MIME Information';
  1012.   MCC_MT_MAGIC_LEN = 53;
  1013.   NCC_MT_MAGIC = '#--Netscape Communications Corporation MIME Information';
  1014.   NCC_MT_MAGIC_LEN = 55;
  1015.  
  1016. {* The character which separates extensions with cinfo_find *}
  1017.  
  1018.   CINFO_SEPARATOR = '.';
  1019.  
  1020. {* The maximum length of a line in this file *}
  1021.  
  1022.   CINFO_MAX_LEN = 1024;
  1023.  
  1024. {* The hash table size for that function *}
  1025.   CINFO_HASHSIZE = 27;
  1026.  
  1027. {* The hash function for the database. Hashed on extension. *}
  1028. function CINFO_HASH(s: PChar): Char;
  1029.  
  1030. {* ------------------------------ Structures ------------------------------ *}
  1031. {
  1032.   The ContentInfo structure.
  1033.  
  1034.   Currently, we support the following attributes:
  1035.  
  1036.   1. Type: This identifies what kind of data is in the file.
  1037.   2. Encoding: Identifies any compression or otherwise content-independent
  1038.      transformation which has been applied to the file (uuencode, etc.)
  1039.   3. Language: Identifies the language a text document is in.
  1040.   4. Description: A text string describing the file.
  1041.   5. Viewer: The program to use to view the file.
  1042.  
  1043.   Multiple items are separated with a comma, e.g.
  1044.   encoding="x-gzip, x-uuencode"
  1045. }
  1046.  
  1047. type
  1048.   PCInfo = ^TCInfo;
  1049.   TCInfo = record
  1050.     ctype: PChar;
  1051.     encoding: PChar;
  1052.     language: PChar;
  1053.   end;
  1054.   cinfo = TCInfo;
  1055.  
  1056. {* ------------------------------ Prototypes ------------------------------ *}
  1057.  
  1058. {
  1059.   cinfo_init initializes the content info system. Call this before
  1060.   cinfo_merge.
  1061. }
  1062. procedure cinfo_init; cdecl;
  1063.  
  1064. {
  1065.   cinfo_terminate frees the database for shutdown.
  1066. }
  1067. procedure cinfo_terminate; cdecl;
  1068.  
  1069. {
  1070.   cinfo_merge merges the contents of the given filename with the current
  1071.   cinfo database. It returns NULL upon success and a string (which you
  1072.   must deallocate) upon error.
  1073. }
  1074. function cinfo_merge(fn: PChar): PChar; cdecl;
  1075.  
  1076. {
  1077.   cinfo_find finds any content information for the given uri. The file name
  1078.   is the string following the last / in the uri. Multiple extensions are
  1079.   separated by CINFO_SEPARATOR. You may pass in a filename instead of uri.
  1080.  
  1081.   Returns a newly allocated cinfo structure with the information it
  1082.   finds. The elements of this structure are coming right out of the types
  1083.   database and so if you change it or want to keep it around for long you
  1084.   should strdup it. You should free only the structure itself when finished
  1085.   with it.
  1086.  
  1087.   If there is no information for any one of the extensions it
  1088.   finds, it will ignore that extension. If it cannot find information for
  1089.   any of the extensions, it will return NULL.
  1090. }
  1091. function cinfo_find(uri: PChar): PCInfo; cdecl;
  1092.  
  1093. {
  1094.   cinfo_lookup finds the information about the given content-type, and
  1095.   returns a cinfo structure so you can look up description and icon.
  1096. }
  1097. function cinfo_lookup(ctype: PChar): PCInfo; cdecl;
  1098.  
  1099. {
  1100.   cinfo_dump_database dumps the current database to the given file desc.
  1101. }
  1102. {!!! requires C RTL _iobuf or FILE }
  1103. // NSAPI_PUBLIC void cinfo_dump_database(FILE *dump);
  1104.  
  1105. {*****************************************************************************}
  1106. {* From ereport.h                                                             }
  1107. {*****************************************************************************}
  1108. {
  1109.   Records transactions, reports errors to administrators, etc.
  1110. }
  1111.  
  1112. {* ------------------------------ Constants ------------------------------- *}
  1113.  
  1114. const
  1115. {
  1116.   The maximum length of an error message. NOT RUN-TIME CHECKED
  1117. }
  1118.   MAX_ERROR_LEN = 8192;
  1119.  
  1120. {* A warning is a minor mishap, such as a 404 being issued. *}
  1121.   LOG_WARN = 0;
  1122.  
  1123. {
  1124.   A misconfig is when there is a syntax error or permission violation in
  1125.   a config. file.
  1126. }
  1127.   LOG_MISCONFIG = 1;
  1128.  
  1129. {
  1130.   Security warnings are issued when authentication fails, or a host is
  1131.   given a 403 return code.
  1132. }
  1133.   LOG_SECURITY = 2;
  1134.  
  1135. {
  1136.   A failure is when a request could not be fulfilled due to an internal
  1137.   problem, such as a CGI script exiting prematurely, or a filesystem
  1138.   permissions problem.
  1139. }
  1140.   LOG_FAILURE = 3;
  1141.  
  1142. {
  1143.   A catastrophe is a fatal server error such as running out of
  1144.   memory or processes, or a system call failing, or even a server crash.
  1145.   The server child cannot recover from a catastrophe.
  1146. }
  1147.   LOG_CATASTROPHE = 4;
  1148.  
  1149. {
  1150.   Informational message, of no concern.
  1151. }
  1152.   LOG_INFORM = 5;
  1153.  
  1154. {
  1155.   The time format to use in the error log
  1156. }
  1157.   ERR_TIMEFMT = '[%d/%b/%Y:%H:%M:%S]';
  1158.  
  1159.  
  1160. {* The fd you will get if you are reporting errors to SYSLOG *}
  1161.  
  1162.   ERRORS_TO_SYSLOG = -1;
  1163.  
  1164. {* ------------------------------ Prototypes ------------------------------ *}
  1165.  
  1166. {
  1167.   ereport logs an error of the given degree and formats the arguments with
  1168.   the printf() style fmt. Returns whether the log was successful. Records
  1169.   the current date.
  1170. }
  1171. {!!! require C/C++ varargs support !!!}
  1172. //NSAPI_PUBLIC int ereport(int degree, char *fmt, ...);
  1173.  
  1174. {
  1175.   ereport_init initializes the error logging subsystem and opens the static
  1176.   file descriptors. It returns NULL upon success and an error string upon
  1177.   error. If a userpw is given, the logs will be chowned to that user.
  1178.  
  1179.   email is the address of a person to mail upon catastrophic error. It
  1180.   can be NULL if no e-mail is desired. ereport_init will not duplicate
  1181.   its own copy of this string; you must make sure it stays around and free
  1182.   it when you shut down the server.
  1183. }
  1184. function ereport_init(err_fn, email: PChar; var pw: PASSWD): PChar; cdecl;
  1185.  
  1186. {
  1187.   log_terminate closes the error and common log file descriptors.
  1188. }
  1189. procedure ereport_terminate; cdecl;
  1190.  
  1191. {* For restarts *}
  1192. function ereport_getfd: SYS_FILE; cdecl;
  1193.  
  1194. {*****************************************************************************}
  1195. {* From shexp.h                                                               }
  1196. {*****************************************************************************}
  1197. {
  1198.   Defines and prototypes for shell exp. match routines
  1199.  
  1200.  
  1201.   This routine will match a string with a shell expression. The expressions
  1202.   accepted are based loosely on the expressions accepted by zsh.
  1203.  
  1204.   o * matches anything
  1205.   o ? matches one character
  1206.   o \ will escape a special character
  1207.   o $ matches the end of the string
  1208.   o [abc] matches one occurence of a, b, or c. The only character that needs
  1209.           to be escaped in this is ], all others are not special.
  1210.   o [a-z] matches any character between a and z
  1211.   o [^az] matches any character except a or z
  1212.   o ~ followed by another shell expression will remove any pattern
  1213.       matching the shell expression from the match list
  1214.   o (foo|bar) will match either the substring foo, or the substring bar.
  1215.               These can be shell expressions as well.
  1216.  
  1217.   The public interface to these routines is documented below.
  1218. }
  1219.  
  1220. {* --------------------------- Public routines ---------------------------- *}
  1221.  
  1222. {
  1223.   shexp_valid takes a shell expression exp as input. It returns:
  1224.  
  1225.    NON_SXP      if exp is a standard string
  1226.    INVALID_SXP  if exp is a shell expression, but invalid
  1227.    VALID_SXP    if exp is a valid shell expression
  1228. }
  1229.  
  1230. const
  1231.    NON_SXP = -1;
  1232.    INVALID_SXP = -2;
  1233.    VALID_SXP = 1;
  1234.  
  1235. {* and generic shexp/regexp versions *}
  1236.    NON_WILDPAT     = NON_SXP;
  1237.    INVALID_WILDPAT = INVALID_SXP;
  1238.    VALID_WILDPAT   = VALID_SXP;
  1239.  
  1240. {* and regexp versions *}
  1241.    NON_REGEXP      = NON_SXP;
  1242.    INVALID_REGEXP  = INVALID_SXP;
  1243.    VALID_REGEXP    = VALID_SXP;
  1244.  
  1245. function shexp_valid(exp: PChar): Integer; cdecl;
  1246.  
  1247. {
  1248.   shexp_match
  1249.  
  1250.   Takes a prevalidated shell expression exp, and a string str.
  1251.  
  1252.   Returns 0 on match and 1 on non-match.
  1253. }
  1254. function shexp_match(str, exp: PChar): Integer; cdecl;
  1255.  
  1256. {
  1257.   shexp_cmp
  1258.  
  1259.   Same as above, but validates the exp first. 0 on match, 1 on non-match,
  1260.   -1 on invalid exp. shexp_casecmp does the same thing but is case
  1261.   insensitive.
  1262. }
  1263. function shexp_cmp(str, exp: PChar): Integer; cdecl;
  1264. function shexp_casecmp(str, exp: PChar): Integer; cdecl;
  1265.  
  1266. {*****************************************************************************}
  1267. {* From shmem.h                                                               }
  1268. {*****************************************************************************}
  1269. {
  1270.   Portable abstraction for memory shared among a server's workers
  1271. }
  1272.  
  1273. {* --------------------------- Data structures ---------------------------- *}
  1274.  
  1275. type
  1276.   PShMem = ^TShMem;
  1277.   TShMem = record
  1278.     data: Pointer;   {* the data *}
  1279.     fdmap: THandle;
  1280.     size: Integer;   {* the maximum length of the data *}
  1281.     name: PChar;     {* internal use: filename to unlink if exposed *}
  1282.     fd: SYS_FILE;    {* internal use: file descriptor for region *}
  1283.   end;
  1284.   shmem_s = TShMem;
  1285.  
  1286. {* ------------------------------ Prototypes ------------------------------ *}
  1287.  
  1288. {
  1289.   shmem_alloc allocates a region of shared memory of the given size, using
  1290.   the given name to avoid conflicts between multiple regions within the
  1291.   program. The region will not be automatically grown if its boundaries
  1292.   are over-run, use shmem_realloc for that.
  1293.  
  1294.   If expose is non-zero and the underlying system supports it, the
  1295.   file used to create the shared region will be visible to other processes
  1296.   running on the system.
  1297.  
  1298.   name should be unique to the program which calls this routine, otherwise
  1299.   conflicts will arise.
  1300.  
  1301.   Returns a new shared memory region, with the data element being a
  1302.   pointer to the shared memory. This function must be called before any
  1303.   daemon workers are spawned, in order for the handle to the shared region
  1304.   to be inherited by the children.
  1305.  
  1306.   Because of the requirement that the region must be inherited by the
  1307.   children, the region cannot be re-allocated with a larger size when
  1308.   necessary.
  1309. }
  1310. function shmem_alloc(name: PChar; size: Integer; expose: BOOL): PShMem; cdecl;
  1311.  
  1312. {
  1313.   shmem_free de-allocates the specified region of shared memory.
  1314. }
  1315. procedure shmem_free(region: PShMem); cdecl;
  1316.  
  1317. {*****************************************************************************}
  1318. {* From systhr.h                                                              }
  1319. {*****************************************************************************}
  1320. {
  1321.   Abstracted threading mechanisms
  1322. }
  1323.  
  1324. type
  1325.   SYS_THREAD = Pointer;
  1326.   TSysThreadFunc = procedure (Arg: Pointer) cdecl;
  1327.  
  1328. const
  1329.   SYS_THREAD_ERROR = nil;
  1330.   SYSTHREAD_DEFAULT_PRIORITY = 16;
  1331.  
  1332. {
  1333.   systhread_start creates a thread with the given priority, will allocate
  1334.   a stack of stksz bytes, and calls fn with arg as its argument. stksz
  1335.   of zero will allocate a default stack size.
  1336.  
  1337.   Returns a new SYS_THREAD pointer on success, SYS_THREAD_ERROR on failure.
  1338.   XXX Priorities are system dependent
  1339. }
  1340. function systhread_start(prio, stksz: Integer; fn: TSysThreadFunc; arg: Pointer): SYS_THREAD; cdecl;
  1341.  
  1342. {
  1343.   systhread_current returns a pointer to the current thread.
  1344. }
  1345. function systhread_current: SYS_THREAD;
  1346.  
  1347. {
  1348.   systhread_yield yields the processor to another thread
  1349. }
  1350. procedure systhread_yield; cdecl;
  1351.  
  1352. {
  1353.   systhread_attach makes an existing thread an NSPR thread.
  1354. }
  1355. function systhread_attach: SYS_THREAD; cdecl;
  1356.  
  1357. {
  1358.   systhread_terminate terminates the thread that is passed in.
  1359. }
  1360. procedure systhread_terminate(thr: SYS_THREAD);
  1361.  
  1362. {
  1363.   systhread_sleep puts the calling thread to sleep for the given number
  1364.   of milliseconds.
  1365. }
  1366. procedure systhread_sleep(milliseconds: Integer); cdecl;
  1367.  
  1368. {
  1369.   systhread_init initializes the threading system. name is a name for the
  1370.   program for debugging.
  1371. }
  1372. procedure systhread_init(name: PChar); cdecl;
  1373.  
  1374. {
  1375.   systhread_timerset starts or re-sets the interrupt timer for a thread
  1376.   system. This should be considered a suggestion as most systems don't allow
  1377.   the timer interval to be changed.
  1378. }
  1379. procedure systhread_timerset(usec: Integer); cdecl;
  1380.  
  1381. {
  1382.   newkey allocates a new integer id for thread-private data. Use this
  1383.   key to identify a variable which you want to appear differently
  1384.   between threads, and then use setdata to associate a value with this
  1385.   key for each thread.
  1386. }
  1387. function systhread_newkey: Integer; cdecl;
  1388.  
  1389. {
  1390.   Get data that has been previously associated with key in this thread.
  1391.   Returns NULL if setkey has not been called with this key by this
  1392.   thread previously, or the data that was previously used with setkey
  1393.   by this thread with this key.
  1394. }
  1395. function systhread_getdata(key: Integer): Pointer; cdecl;
  1396.  
  1397. {
  1398.   Associate data with the given key number in this thread.
  1399. }
  1400. procedure systhread_setdata(key: Integer; data: Pointer); cdecl;
  1401.  
  1402. {*****************************************************************************}
  1403. {* From daemon.h                                                              }
  1404. {*****************************************************************************}
  1405. {
  1406.   Things related to the accepting connections
  1407. }
  1408.  
  1409. {* ------------------------------- Defines -------------------------------- *}
  1410.  
  1411. // NSAPI_PUBLIC void child_exit(int status);
  1412.  
  1413. const
  1414. {* Codes for child_status *}
  1415.   CHILD_EMPTY_SLOT = $fe;
  1416.   CHILD_AWAIT_CONNECT = $ff;
  1417.   CHILD_PROCESSING = $00;
  1418.   CHILD_READING = $01;
  1419.   CHILD_WRITING = $02;
  1420.   CHILD_RESOLVING = $03;
  1421. {* Need completors to handle async IO *}
  1422.   CHILD_DONE_PROCESSING = $14;
  1423.   CHILD_DONE_READING = $15;
  1424.   CHILD_DONE_WRITING = $16;
  1425.   CHILD_DONE_RESOLVING = $17;
  1426.  
  1427.   MAX_IP_DOMAINS = 256;
  1428.  
  1429. type
  1430.   PMultipleDomains = ^TMultipleDomains;
  1431.   TMultipleDomains = record
  1432.     address: PChar;
  1433.     docroot: PChar;
  1434.     sd: SYS_NETFD;
  1435.     threads: Integer;
  1436.     AddressNumber: Integer;
  1437.   end;
  1438.   multiple_domains = TMultipleDomains;
  1439.  
  1440.   TChildCallback = procedure (sn: PSession) cdecl;
  1441.   TRotateCallback = procedure cdecl;
  1442.   TRCBack = procedure (Param: Integer) cdecl;
  1443.  
  1444.   PDaemon = ^TDaemon;
  1445.   TDaemon = record
  1446.     ipstr: PChar;
  1447.     port: Integer;
  1448.     child_callback: TChildCallback;
  1449.     rotate_callback: TRotateCallback;
  1450.     servid: PChar;
  1451.     domains: PMultipleDomains;
  1452.     rcback: TRCBack;
  1453.     maxprocs: Integer;
  1454.     minprocs: Integer;
  1455.     proclife: Integer;
  1456.     maxthreads: Integer;
  1457.     minthreads: Integer;
  1458. {$ifdef NET_SSL}
  1459.     char *secure_keyfn;
  1460.     char *secure_certfn;
  1461.     int secure_auth;
  1462.     int secure_session_timeout;
  1463.     long ssl3_secure_session_timeout;
  1464.     int security;
  1465.     int ssl3;
  1466.     int ssl2;
  1467. {$endif}
  1468.   end;
  1469.   daemon_s = TDaemon;
  1470.  
  1471. {* ------------------------------ Prototypes ------------------------------ *}
  1472.  
  1473. {
  1474.   daemon_run accepts whether or not it should detach from its parent process,
  1475.   and a daemon structure as its arguments. The daemon structure contains
  1476.   a port number, a root directory to chroot to (can be NULL), a filename to
  1477.   log the daemon pid to (can be NULL). daemon_run never returns.
  1478.  
  1479.   child_callback is a function which will be called every time a new
  1480.   connection is recieved. Session is a new session ID.
  1481.  
  1482.   rcback is a function which is a restart function: When SIGHUP is received,
  1483.   this function will be called. You may give SIG_DFL if you don't want to
  1484.   support restarting. The rcback will be passed SIGHUP.
  1485.  
  1486.   pw is the passwd entry to run the daemon as. If the effective user id is
  1487.   root, daemon_run will try to set its uid and gid to the user pointed
  1488.   to by this structure. You may pass NULL.
  1489. }
  1490. procedure _ntdaemon_run(Param: Pointer); cdecl;
  1491.  
  1492. {
  1493.   daemon_atrestart registers a function to be called fn, with the given
  1494.   void pointer as an argument, when the server is restarted.
  1495. }
  1496. procedure daemon_atrestart(fn: TDaemonAtRestart; data: Pointer); cdecl;
  1497.  
  1498. {
  1499.   fork is a wrapper for the system's fork function. This closes the listen
  1500.   socket for the mob. This also makes sure that a threaded daemon only gets
  1501.   the calling thread and not all of them.
  1502. }
  1503. function child_fork: pid_t;
  1504.  
  1505. {* servssl_init is in base/servssl.c *}
  1506. {$ifdef NET_SSL}
  1507. procedure servssl_init(keyfn, certfn: PChar; stimeout: Integer; ssl3timeout: Longint;
  1508.   servid: PChar); cdecl;
  1509. {$endif NET_SSL}
  1510.  
  1511. {*****************************************************************************}
  1512. {* From util.h                                                                }
  1513. {*****************************************************************************}
  1514. {
  1515.   A hodge podge of utility functions and standard functions which
  1516.   are unavailable on certain systems
  1517. }
  1518.  
  1519. {* ------------------------------ Prototypes ------------------------------ *}
  1520.  
  1521.  
  1522. {
  1523.   getline scans in buf until it finds a LF or CRLF, storing the string in
  1524.   l. It will terminate the string and return:
  1525.  
  1526.    0 when done, with the scanned line (minus CR or LF) in l
  1527.    1 upon EOF, with the scanned line (minus CR or LF) in l
  1528.   -1 on error with the error description in l (uses lineno for information)
  1529. }
  1530. function util_getline(buf: PFileBuffer; lineno, maxlen: Integer; l: PChar): Integer; cdecl;
  1531.  
  1532. {
  1533.   env_create creates a new environment with the given env, with n new
  1534.   entries, and places the current position that you should add your
  1535.   entries with at pos.
  1536.  
  1537.   If env is NULL, it will allocate a new one. If not, it will reallocate
  1538.   that one.
  1539. }
  1540. function util_env_create(env: PPCharArray; n: Integer; var pos: Integer): PPCharArray; cdecl;
  1541.  
  1542. {
  1543.   util_env_str allocates a string from the given name and value and
  1544.   returns it. It does not check for things like = signs in name.
  1545. }
  1546. function util_env_str(name, value: PChar): PChar; cdecl;
  1547.  
  1548. {
  1549.   env_replace replaces the occurrence of the given variable with the
  1550.   value you give.
  1551. }
  1552. procedure util_env_replace(env: PPCharArray; name, value: PChar); cdecl;
  1553.  
  1554. {
  1555.   util_env_free frees an environment.
  1556. }
  1557. procedure util_env_free(env: PPCharArray); cdecl;
  1558.  
  1559. {
  1560.   util_env_copy copies an env
  1561. }
  1562. function util_env_copy(src, dst: PPCharArray): PPCharArray; cdecl;
  1563.  
  1564. {
  1565.   util_env_find looks through env for the named string. Returns the
  1566.   corresponding value if the named string is found, or NULL if not.
  1567. }
  1568. function util_env_find(env: PPCharArray; name: PChar): PChar; cdecl;
  1569.  
  1570. {
  1571.   hostname gets the local hostname. Returns NULL if it can't find a FQDN.
  1572.   You are free to realloc or free this string.
  1573. }
  1574. function util_hostname: PChar; cdecl;
  1575.  
  1576. {
  1577.   chdir2path changes the current directory to the one that the file
  1578.   path is in. path should point to a file. Caveat: path must be a writable
  1579.   string. It won't get modified permanently.
  1580. }
  1581. function util_chdir2path(path: PChar): Integer;
  1582.  
  1583. {
  1584.   is_mozilla checks if the given user-agent is mozilla, of at least
  1585.   the given major and minor revisions. These are strings to avoid
  1586.   ambiguities like 1.56 > 1.5
  1587. }
  1588. function util_is_mozilla(ua, major, minor: PChar): BOOL; cdecl;
  1589.  
  1590. {
  1591.   is_url will return 1 if the given string seems to be a URL, or will
  1592.   return 0 otherwise.
  1593.  
  1594.   Because of stupid news URLs, this will return 1 if the string has
  1595.   all alphabetic characters up to the first colon and will not check for
  1596.   the double slash.
  1597. }
  1598. function util_is_url(url: PChar): BOOL; cdecl;
  1599.  
  1600. {
  1601.   util_later_than checks the date in the string ims, and if that date is
  1602.   later than or equal to the one in the tm struct lms, then it returns 1.
  1603.  
  1604.   util_time_equal is above, but checks for exact equality.
  1605.  
  1606.   Handles RFC 822, 850, and ctime formats.
  1607. }
  1608.  
  1609. function util_later_than(var lms: tm; ims: PChar): BOOL; cdecl;
  1610. function util_time_equal(var lms: tm; ims: PChar): BOOL; cdecl;
  1611.  
  1612. {
  1613.   util_str_time_equal checks the character-string dates are equal.
  1614.   Supports rfc1123 and rfc850 formats.  t1 must be rfc1123
  1615.   Returns 0 if equal, -1 otherwise
  1616. }
  1617. function util_str_time_equal(t1, t2: PChar): Integer; cdecl;
  1618.  
  1619. {
  1620.   util_uri_is_evil returns 1 if a URL has ../ or // in it.
  1621. }
  1622. function util_uri_is_evil(t: PChar): BOOL; cdecl;
  1623.  
  1624. {
  1625.   util_uri_parse gets rid of /../, /./, and //.
  1626.  
  1627.   Assumes that either the string starts with a /, or the string will
  1628.   not .. right off of its beginning.  As such, ../foo.gif will
  1629.   not be changed, although /../foo.gif will become /foo.gif.
  1630. }
  1631. procedure util_uri_parse(uri: PChar); cdecl;
  1632.  
  1633. {
  1634.   util_uri_unescape unescapes the given URI in place (% conversions only).
  1635. }
  1636. procedure util_uri_unescape(s: PChar); cdecl;
  1637.  
  1638. {
  1639.   util_uri_escape escapes any nasty chars in s and copies the string into d.
  1640.   If d is NULL, it will allocate and return a properly sized string.
  1641.   Warning: does not check bounds on a given d.
  1642.  
  1643.   util_url_escape does the same thing but does it for a url, i.e. ?:+ is
  1644.   not escaped.
  1645. }
  1646. function util_uri_escape(d, s: PChar): PChar; cdecl;
  1647. function util_url_escape(d, s: PChar): PChar; cdecl;
  1648.  
  1649. {
  1650.   util_sh_escape places a \ in front of any shell-special characters.
  1651.   Returns a newly-allocated copy of the string.
  1652. }
  1653. function util_sh_escape(s: PChar): PChar cdecl;
  1654.  
  1655. {
  1656.   util_mime_separator generates a new MIME separator into the given buffer.
  1657.   The buffer should be more than 4 + 3*10 + 1 bytes long. A CRLF is prepended
  1658.   to the beginning of the string, along with two dashes. The string is null
  1659.   terminated, with no CRLF. The intent is that you create your content-type
  1660.   header by accessing &sep[4], and afterwards print sep followed by CRLF
  1661.   for message boundaries.
  1662.  
  1663.   Returns the length of the string.
  1664. }
  1665. function util_mime_separator(sep: PChar): Integer;
  1666.  
  1667. {
  1668.   util_itoa converts the given integer to a string into a.
  1669. }
  1670. function util_itoa(i: Integer; a: PChar): Integer;
  1671.  
  1672. {
  1673.   util_vsprintf and util_sprintf are simplified clones of the System V
  1674.   vsprintf and sprintf routines.
  1675.  
  1676.   Returns the number of characters printed. Only handles %d and %s,
  1677.   does not handle any width or precision.
  1678. }
  1679. {!!! requires vararg support !!!
  1680. #include <stdarg.h>
  1681.  
  1682. NSAPI_PUBLIC int util_vsprintf(char *s, register char *fmt, va_list args);
  1683. NSAPI_PUBLIC int util_sprintf(char *s, char *fmt, ...);
  1684.  
  1685. /* These routines perform bounds checks. */
  1686. NSAPI_PUBLIC int util_vsnprintf(char *s, int n, register char *fmt,
  1687.                                 va_list args);
  1688. NSAPI_PUBLIC int util_snprintf(char *s, int n, char *fmt, ...);
  1689. }
  1690.  
  1691. { util_delete_directory()
  1692.   This routine deletes all the files in a directory.  If delete_directory is
  1693.   TRUE it will also delete the directory itself.
  1694. }
  1695. procedure util_delete_directory(FileName: PChar; delete_directory: BOOL); cdecl;
  1696.  
  1697. { util_strftime()
  1698.   Thread safe version of strftime.
  1699.   No bounds checking is done s.  t must be a valid tm structure.
  1700. }
  1701. function util_strftime(s: PChar; format: PChar; var t: tm): Integer; cdecl;
  1702.  
  1703. {*****************************************************************************}
  1704. {* From object.h                                                              }
  1705. {*****************************************************************************}
  1706. {
  1707.   Handle httpd objects
  1708.  
  1709.   Manages information about a document from config. files. Called mainly
  1710.   by objset.c.
  1711.  
  1712.   This module does not assume anything about the directives being parsed.
  1713.   That is handled by objset.c.
  1714.  
  1715.   This module requires the pblock module from the base library.
  1716. }
  1717.  
  1718. {* ------------------------------ Structures ------------------------------ *}
  1719.  
  1720. {
  1721.   Hierarchy of httpd_object
  1722.  
  1723.   An object contains dtables.
  1724.  
  1725.   Each dtable is a table of directives that were entered of a certain type.
  1726.   There is one dtable for each unique type of directive.
  1727.  
  1728.   Each dtable contains an array of directives, each of which is equivalent
  1729.   to one directive that occurred in a config. file.
  1730.  
  1731.   It is up to the caller to determine how many dtables will be allocated
  1732.   and to keep track of which of their directive types maps to which dtable
  1733.   number.
  1734. }
  1735.  
  1736. type
  1737. {
  1738.   directive is a structure containing the protection and parameters to an
  1739.   instance of a directive within an httpd_object.
  1740.  
  1741.   param is the parameters, client is the protection.
  1742. }
  1743.   PDirective = ^TDirective;
  1744.   TDirective = record
  1745.     param: PPblock;
  1746.     client: PPblock;
  1747.   end;
  1748.   directive = TDirective;
  1749.  
  1750. {
  1751.   dtable is a structure for creating tables of directives
  1752. }
  1753.   PDtable = ^TDtable;
  1754.   TDtable = record
  1755.     ni: Integer;
  1756.     inst: PDirective;
  1757.   end;
  1758.   dtable = TDtable;
  1759.  
  1760. {
  1761.   The httpd_object structure.
  1762.  
  1763.   The name pblock array contains the names for this object, such as its
  1764.   virtual location, its physical location, or its identifier.
  1765.  
  1766.   tmpl contains any templates allocated to this object.
  1767. }
  1768.   PHttpdObject = ^THttpdObject;
  1769.   THttpdObject = record
  1770.     name: PPblock;
  1771.     nd: Integer;
  1772.     dt: PDtable;
  1773.   end;
  1774.   httpd_object = THttpdObject;
  1775.  
  1776. {* ------------------------------ Prototypes ------------------------------ *}
  1777.  
  1778. {
  1779.   object_create will create a new object and return a pointer to it.
  1780.   It will allocate space for nd directive types and set name accordingly.
  1781. }
  1782. function object_create(nd: Integer; name: PPblock): PHttpdObject; cdecl;
  1783.  
  1784. {
  1785.   object_free will free an object and any data associated with it.
  1786. }
  1787. procedure object_free(obj: PHttpdObject); cdecl;
  1788.  
  1789. {
  1790.   object_add_directive will add a new directive to the dtable for
  1791.   the directive class at position dc.
  1792. }
  1793. procedure object_add_directive(dc: Integer; p: PPblock; c: PPblock;
  1794.   obj: PHttpdObject); cdecl;
  1795.  
  1796. {
  1797.   Executes the directive specified by inst within the context of the
  1798.   given session and request structures. Returns what the executed function
  1799.   returned (one of the REQ_* codes defined in req.h).
  1800.  
  1801.   This prototype uses void * for Request * in order to avoid including
  1802.   all of req.h.
  1803. }
  1804. function object_execute(inst: PDirective; sn: PSession; rq: Pointer): Integer; cdecl;
  1805.  
  1806. {*****************************************************************************}
  1807. {* From objset.h                                                              }
  1808. {*****************************************************************************}
  1809. {
  1810.   Handles object sets
  1811.  
  1812.   Each object is produced by reading a config file of some form. See the
  1813.   server documentation for descriptions of the directives that are
  1814.   recognized, what they do, and how they are parsed.
  1815.  
  1816.   This module requires the pblock and buffer modules from the base library.
  1817. }
  1818.  
  1819. {* ------------------------------ Constants ------------------------------- *}
  1820.  
  1821. const
  1822. {
  1823.   The default number of objects to leave room for in an object set,
  1824.   and the number of new entries by which to increase the size when that
  1825.   room is filled.
  1826. }
  1827.   OBJSET_INCSIZE = 8;
  1828.  
  1829. {
  1830.   When parsing config. files, httpd will put a limit on how long
  1831.   the parameters to a directive can be (in characters).
  1832.  
  1833.   Currently set to 10 lines (80 chars/line).
  1834. }
  1835.   MAX_DIRECTIVE_LEN = 800;
  1836.  
  1837. {
  1838.   The size of the hash tables that store a directive's parameters
  1839. }
  1840.   PARAMETER_HASH_SIZE = 3;
  1841.  
  1842. {* ------------------------------ Structures ------------------------------ *}
  1843.  
  1844. {
  1845.   httpd_objset is a container for a bunch of objects. obj is a
  1846.   NULL-terminated array of objects. pos points to the entry after the last
  1847.   one in the array. You should not mess with pos, but can read it to find
  1848.   the last entry.
  1849.  
  1850.   The initfns array is a NULL-terminated array of the Init functions
  1851.   associated with this object set. If there are no Init functions associated
  1852.   with this object set, initfns can be NULL. Each pblock specifies the
  1853.   parameters which are passed to the function when it's executed.
  1854. }
  1855.  
  1856. type
  1857.   PHttpdObjSet = ^THttpdObjSet;
  1858.   THttpdObjSet = record
  1859.     pos: Integer;
  1860.     obj: ^PHttpdObject;
  1861.     initfns: ^PPblock;
  1862.   end;
  1863.   httpd_objset = THttpdObjSet;
  1864.  
  1865. {* ------------------------------ Prototypes ------------------------------ *}
  1866.  
  1867.  
  1868. {
  1869.   objset_scan_buffer will scan through buffer, looking for object
  1870.   configuration information, and adding them to the object set os if it
  1871.   finds any. If os is NULL it will allocate a new object set.
  1872.  
  1873.   If any error occurs (syntax error, premature EOF) this function will
  1874.   free os, print an error message into errstr, and return NULL.
  1875.   This is because a config. file error is viewed as a catastrophic error
  1876.   from which httpd should not try to recover. If httpd were to continue
  1877.   after an error, it would not behave as the admin. expected and he/she
  1878.   may not notice until it's too late.
  1879.  
  1880.   Upon EOF the file will not be closed.
  1881. }
  1882. function objset_scan_buffer(buf: PFileBuffer; errstr: PChar;
  1883.   os: PHttpdObjSet): PHttpdObjSet; cdecl;
  1884.  
  1885. {
  1886.   objset_create creates a new object set and returns a pointer to it.
  1887. }
  1888. function objset_create: PHttpdObjSet; cdecl;
  1889.  
  1890. {
  1891.   objset_free will free an object set, any associated objects, and any
  1892.   associated Init functions.
  1893. }
  1894. procedure objset_free(os: PHttpdObjSet); cdecl;
  1895.  
  1896. {
  1897.   objset_free_setonly frees only the object set, and not the associated
  1898.   objects or init functions.
  1899. }
  1900. procedure objset_free_setonly(os: PHttpdObjSet); cdecl;
  1901.  
  1902. {
  1903.   objset_new_object will add a new object to objset with the specified
  1904.   name. It returns a pointer to the new object (which may be anywhere in
  1905.   the objset).
  1906. }
  1907. function objset_new_object(name: PPblock; os: PHttpdObjSet): PHttpdObjSet; cdecl;
  1908.  
  1909. {
  1910.   objset_add_object will add the existing object to os.
  1911. }
  1912. procedure objset_add_object(obj: PHttpdObject; os: PHttpdObjSet); cdecl;
  1913.  
  1914. {
  1915.   objset_add_init will add the initialization function specified by
  1916.   initfn to the given object set. Modifies os->initfns.
  1917. }
  1918. procedure objset_add_init(initfn: PPblock; os: PHttpdObjSet); cdecl;
  1919.  
  1920. {
  1921.   objset_findbyname will find the object in objset having the given name,
  1922.   and return the object if found, and NULL otherwise.
  1923.   ign is a set of objects to ignore.
  1924. }
  1925. function objset_findbyname(name: PChar; ign, os: PHttpdObjSet): PHttpdObject; cdecl;
  1926.  
  1927. {
  1928.   objset_findbyppath will find the object in objset having the given
  1929.   partial path entry. Returns object if found, NULL otherwise.
  1930.   ign is a set of objects to ignore.
  1931. }
  1932. function objset_findbyppath(ppath: Pchar; ign, os: PHttpdObjSet): PHttpdObject; cdecl;
  1933.  
  1934. {
  1935.   objset_copydirs takes a given objset and copies all of the
  1936.   directive in directive set <dir> into a new objset, dst_os.  If
  1937.   dst_os is NULL, it creates a new objset.
  1938.   The newly created objset only has one object in it.
  1939. }
  1940. function objset_copydirs(dst_os, os: PHttpdObjSet; dir: Integer): PHttpdObjSet; cdecl;
  1941.  
  1942. {* Read the registry configuration parameters into memory *}
  1943. function objset_scan_registry(errstr: PChar; os: PHttpdObjSet;
  1944.   product_key: PChar): PHttpdObjSet; cdecl;
  1945.  
  1946. {* Recursively scan the object key *}
  1947.  
  1948. procedure ProcessObject(nos: PHttpdObjSet; hObjectKey: HKEY; Obj: PChar;
  1949.   ObjectIndex: DWORD); cdecl;
  1950.  
  1951. {* Recursively scan the client key *}
  1952.  
  1953. function ProcessClient(cobj: PHttpdObject; hObjectKey: HKEY; Client: PChar;
  1954.   ObjectIndex: DWORD): BOOL; cdecl;
  1955.  
  1956. {* Recursively scan the directive key *}
  1957.  
  1958. function ProcessDirective(cobj: PHttpdObject; param, client: PPblock;
  1959.   hObjectKey: HKEY; Directive: PChar; ObjectIndex, DirectiveIndex: DWORD;
  1960.   var clrefs: DWORD; IsObject: BOOL): BOOL; cdecl;
  1961.  
  1962. {* Recursively scan the function key *}
  1963.  
  1964. function ProcessFunction(var param: PPblock; hDirectiveKey: HKEY; Func: PChar;
  1965.   ObjectIndex, DirectiveIndex, FunctionIndex: DWORD): BOOL; cdecl;
  1966.  
  1967. {* Verify the name value pair *}
  1968.  
  1969. function _ntverify_parameter(str: PChar): Integer; cdecl;
  1970.  
  1971. {* Enter name value pair into pblock *}
  1972. function ntpblock_str2pblock(ParameterIndex: Integer; name, value: PChar;
  1973.   namelength, valuelength: Integer; pb: PPblock): Integer; cdecl;
  1974.  
  1975. {* Get name value pair from a pblock entry *}
  1976. function ntpblock_pblock2str(p: PPbEntry; var ParameterName,
  1977.     ParameterValue: PChar): Integer; cdecl;
  1978.  
  1979. {* Given a key and its parent, delete the key recursively *}
  1980. function ClearConfigurationParameters(hParentKey: HKEY; CompleteKeyName,
  1981.   KeyName: PChar): BOOL; cdecl;
  1982.  
  1983. { Look at the hidden file in the server's directory structure to
  1984.   figure out the name of this server }
  1985. function GetProductKey: PChar; cdecl;
  1986.  
  1987. {*****************************************************************************}
  1988. {* From conf.h                                                                }
  1989. {*****************************************************************************}
  1990. {
  1991.   conf.h: Deals with the server configuration file.
  1992.  
  1993.   Object configuration is an entirely different matter. This deals with
  1994.   things like what port the server runs on, how many children it spawns,
  1995.   and other server-related issues. Information related configuration is
  1996.   handled by the object conf.
  1997. }
  1998.  
  1999. {* ------------------------------ Constants ------------------------------- *}
  2000.  
  2001. const
  2002. {* The longest line in the configuration file *}
  2003.   CONF_MAXLEN = 16384;
  2004.   DEFAULT_PORT = 80;
  2005.   DEFAULT_POOL_MAX = 50;
  2006.  
  2007. {* ------------------------------- Globals -------------------------------- *}
  2008.  
  2009. {
  2010.   These server parameters are made global because they really don't
  2011.   belong anywhere else.
  2012. }
  2013.  
  2014. {* These can't be macros because they're used in daemon.h. */
  2015. extern char *pidfn;
  2016. extern int port;
  2017. extern char *chr;
  2018.  
  2019. #ifdef NET_SSL
  2020. extern char *secure_keyfn;
  2021. extern char *secure_certfn;
  2022. extern int secure_auth;
  2023. #endif}
  2024.  
  2025. type
  2026.   PConfGlobalVars = ^TConfGlobalVars;
  2027.   TConfGlobalVars = record
  2028.     {* What port we listen to *}
  2029.     Vport: Integer;
  2030.     {* What address to bind to *}
  2031.     Vaddr: PChar;
  2032.     {* User to run as *}
  2033.     Vuserpw: PPASSWD;
  2034.     {* Directory to chroot to *}
  2035.     Vchr: PChar;
  2036.     {* Where to log our pid to *}
  2037.     Vpidfn: PChar;
  2038.     {* The maximum number of processes to keep in the pool *}
  2039.     Vpool_max: Integer;
  2040.     {* The minimum number of processes to keep in the pool *}
  2041.     Vpool_min: Integer;
  2042.     {* The maximum number of requests each process should handle. -1=default *}
  2043.     Vpool_life: Integer;
  2044.     {* For multiprocess UNIX servers, the maximum threads per process *}
  2045.     Vpool_maxthreads: Integer;
  2046.     {* For multiprocess UNIX servers, the minimum threads per process *}
  2047.     Vpool_minthreads: Integer;
  2048. {$ifdef NET_SSL}
  2049.     Vsecure_keyfn: PChar;
  2050.     Vsecure_certfn: PChar;
  2051.     Vsecurity_active: Integer;
  2052.     Vssl3_active: Integer;
  2053.     Vssl2_active: Integer;
  2054.     Vsecure_auth: Integer;
  2055.     Vsecurity_session_timeout: Integer;
  2056.     Vssl3_session_timeout: Longint;
  2057. {$endif} {* NET_SSL *}
  2058.     {* The server's hostname as should be reported in self-ref URLs *}
  2059.     Vserver_hostname: PChar;
  2060.     {* The main object from which all are derived *}
  2061.     Vroot_object: PChar;
  2062.     {* The object set the administrator has asked us to load *}
  2063.     Vstd_os: PHttpdObjSet;
  2064.     {* The root of ACL data structures *}
  2065.     Vacl_root: Pointer;
  2066.     {* The main error log, where all errors are logged *}
  2067.     Vmaster_error_log: PChar;
  2068.     {* The server root ( in which the server sits while executing ) *}
  2069.     Vserver_root: PChar;
  2070.     {* This server's id *}
  2071.     Vserver_id: PChar;
  2072.   end;
  2073.   conf_global_vars_s = TConfGlobalVars;
  2074.  
  2075. function userpw: PPASSWD;
  2076. function pool_max: Integer;
  2077. function pool_min: Integer;
  2078. function pool_life: Integer;
  2079. function pool_maxthreads: Integer;
  2080. function pool_minthreads: Integer;
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087. function server_hostname: PChar;
  2088. function root_object: PChar;
  2089. function std_os: PHttpdObjSet;
  2090. function acl_root: Pointer;
  2091. function master_error_log: PChar;
  2092. function server_root: PChar;
  2093. function server_id: PChar;
  2094.  
  2095. {* ------------------------------ Prototypes ------------------------------ *}
  2096.  
  2097. {
  2098.   conf_init reads the given configuration file and sets any non-default
  2099.   parameters to their given setting.
  2100. }
  2101. function conf_init(cfn: PChar): PChar; cdecl;
  2102.  
  2103. {
  2104.   conf_terminate frees any data the conf routines may be holding.
  2105. }
  2106. procedure conf_terminate; cdecl;
  2107.  
  2108. {
  2109.   Get a structure with the global variables for this server.
  2110. }
  2111. function conf_getglobals: PConfGlobalVars; cdecl;
  2112.  
  2113. {
  2114.   conf_vars2daemon transfers these globals to a daemon structure
  2115. }
  2116. procedure conf_vars2daemon(d: PDaemon); cdecl;
  2117.  
  2118. function GetDomainAddresses(ErrMsg: PChar): BOOL; cdecl;
  2119.  
  2120. {*****************************************************************************}
  2121. {* From req.h                                                                 }
  2122. {*****************************************************************************}
  2123. {
  2124.   Request-specific data structures and functions
  2125. }
  2126.  
  2127. {* ------------------------------ Constants ------------------------------- *}
  2128.  
  2129. const
  2130.   REQ_HASHSIZE = 10;
  2131.   REQ_MAX_LINE = 4096;
  2132.  
  2133. {
  2134.   The REQ_ return codes. These codes are used to determine what the server
  2135.   should do after a particular module completes its task.
  2136.  
  2137.   Func type functions return these as do many internal functions.
  2138. }
  2139.  
  2140. {* The function performed its task, proceed with the request *}
  2141.   REQ_PROCEED = 0;
  2142. {* The entire request should be aborted: An error occurred *}
  2143.   REQ_ABORTED = -1;
  2144. {* The function performed no task, but proceed anyway. *}
  2145.   REQ_NOACTION = -2;
  2146. {* Tear down the session and exit *}
  2147.   REQ_EXIT = -3;
  2148. {* Restart the entire request-response process *}
  2149.   REQ_RESTART = -4;
  2150.  
  2151.  
  2152. {* ------------------------------ Structures ------------------------------ *}
  2153.  
  2154.  
  2155. type
  2156.   PRequest = ^TRequest;
  2157.   TRequest = record
  2158.     {* Server working variables *}
  2159.     vars: PPblock;
  2160.     {* The method, URI, and protocol revision of this request *}
  2161.     reqpb: PPblock;
  2162.     {* Protocol specific headers *}
  2163.     loadhdrs: Integer;
  2164.     headers: PPblock;
  2165.     {* Server's response headers *}
  2166.     senthdrs: Integer;
  2167.     srvhdrs: PPblock;
  2168.     {* The object set constructed to fulfill this request *}
  2169.     os: PHttpdObjSet;
  2170.     {* Array of objects that were created from .nsconfig files *}
  2171.     tmpos: PHttpdObjSet;
  2172.     {* The stat last returned by request_stat_path *}
  2173.     statpath: PChar;
  2174.     staterr: PChar;
  2175.     finfo: PStat;
  2176.     {* access control state *}
  2177.     aclstate: Integer;    {* ACL decision state *}
  2178.     acldirno: Integer;    {* deciding ACL directive number *}
  2179.     aclname: PChar;        {* name of deciding ACL *}
  2180.     aclpb: PPblock;     {* parameter block for ACL PathCheck *}
  2181.     request_is_cacheable: BOOL;   {* default TRUE *}
  2182.     directive_is_cacheable: BOOL; {* default FALSE *}
  2183.  
  2184.     cached_headers: PChar;
  2185.     cached_headers_len: Integer;  {* length of the valid headers *}
  2186.     cached_date_header: PChar;
  2187.   end;
  2188.   Request = TRequest;
  2189.  
  2190. {* ------------------------------ Prototypes ------------------------------ *}
  2191.  
  2192. {
  2193.   request_create creates a new request structure.
  2194. }
  2195. function request_create: PRequest; cdecl;
  2196.  
  2197. {
  2198.   request_free destroys a request structure.
  2199. }
  2200. procedure request_free(req: PRequest); cdecl;
  2201.  
  2202. {
  2203.   Restarts a request for a given URI internally. If rq is non-NULL, the
  2204.   function will keep the old request's headers and protocol, but with a new
  2205.   URI and method of GET. If the previous method was HEAD, this is preserved.
  2206.   Any other method becomes GET. You may assume that if you give it a request
  2207.   structure that it will use the same structure.
  2208.  
  2209.   Once you have this new Request, you must then do what you want with
  2210.   it (e.g. send the object back, perform uri2path translation, etc.)
  2211. }
  2212. function request_restart_internal(uri: PChar; rq: PRequest): PRequest; cdecl;
  2213.  
  2214. {
  2215.   request_header finds the named header depending on the requesting
  2216.   protocol. If possible, it will not load headers until the first is
  2217.   requested. You have to watch out because this can return REQ_ABORTED.
  2218. }
  2219. function request_header(name: PChar; value: PPCharArray; sn: PSession;
  2220.   rq: PRequest): Integer; cdecl;
  2221.  
  2222. {
  2223.   request_loadheaders just makes sure the headers have been loaded.
  2224. }
  2225. function request_loadheaders(sn: PSession; rq: PRequest): Integer;
  2226.  
  2227. {
  2228.   request_stat_path tries to stat path. If path is NULL, it will look in
  2229.   the vars pblock for "path". If the stat is successful, it returns the stat
  2230.   structure. If not, returns NULL and leaves a message in rq->staterr. If a
  2231.   previous call to this function was successful, and path is the same, the
  2232.   function will simply return the previously found value.
  2233.  
  2234.   User functions should not free this structure.
  2235. }
  2236. function request_stat_path(path: PChar; rq: PRequest): PStat; cdecl;
  2237.  
  2238. {
  2239.   request_handle handles one request from the session's inbuf.
  2240. }
  2241. procedure request_handle(sn: PSession); cdecl;
  2242.  
  2243. {
  2244.   request_translate_uri performs virtual to physical mapping on
  2245.   a specified URI during a specified session.
  2246. }
  2247. function request_translate_uri(uri: PChar; sn: PSession): PChar; cdecl;
  2248.  
  2249. (*$HPPEMIT 'namespace Nsapi'*)
  2250. (*$HPPEMIT '{'*)
  2251. (*$HPPEMIT '    struct TSession;'*)
  2252. (*$HPPEMIT '    char *servact_translate_uri(char *uri, TSession *sn);'*)
  2253. (*$HPPEMIT '}'*)
  2254.  
  2255. (* XXXrobm temporary compatibility */
  2256. #define request_uri2path servact_uri2path
  2257. #define request_pathchecks servact_pathchecks
  2258. #define request_fileinfo servact_fileinfo
  2259. #define request_service servact_service
  2260.  
  2261. #define request_handle_processed servact_handle_processed
  2262. #define request_translate_uri servact_translate_uri
  2263. #define request_finderror servact_finderror *)
  2264.  
  2265. {*****************************************************************************}
  2266. {* From http.h                                                                }
  2267. {*****************************************************************************}
  2268. {
  2269.   Deals with HTTP-related issues
  2270. }
  2271.  
  2272. {* ------------------------------ Constants ------------------------------- *}
  2273.  
  2274. const
  2275.   HTTP_DATE_LEN = 128;
  2276.   HTTP_DATE_FMT = '%A, %d-%b-%y %H:%M:%S GMT';
  2277.  
  2278. { Number of seconds to allow a second request to come over a persistent
  2279.   connection, zero to disable *}
  2280.   HTTP_DEFAULT_KEEPALIVE_TIMEOUT = 15;
  2281.  
  2282. {* The maximum number of RFC-822 headers we'll allow *}
  2283. {* This would be smaller if a certain browser wasn't so damn stupid. *}
  2284.   HTTP_MAX_HEADERS = 200;
  2285.  
  2286. {* HTTP status codes *}
  2287.   PROTOCOL_OK = 200;
  2288.   PROTOCOL_CREATED = 201;
  2289.   PROTOCOL_NO_RESPONSE = 204;
  2290.   PROTOCOL_PARTIAL_CONTENT = 206;
  2291.   PROTOCOL_REDIRECT = 302;
  2292.   PROTOCOL_NOT_MODIFIED = 304;
  2293.   PROTOCOL_BAD_REQUEST = 400;
  2294.   PROTOCOL_UNAUTHORIZED = 401;
  2295.   PROTOCOL_FORBIDDEN = 403;
  2296.   PROTOCOL_NOT_FOUND = 404;
  2297.   PROTOCOL_PROXY_UNAUTHORIZED = 407;
  2298.   PROTOCOL_SERVER_ERROR = 500;
  2299.   PROTOCOL_NOT_IMPLEMENTED = 501;
  2300.  
  2301. {$ifdef NET_SSL}
  2302.   HTTPS_PORT = 443;
  2303.   HTTPS_URL = 'https';
  2304. {$endif}
  2305.   HTTP_PORT = 80;
  2306.   HTTP_URL = 'http';
  2307.  
  2308. {* -------------------------- http_scan_headers --------------------------- *}
  2309.  
  2310. {
  2311.   gets the first line of an HTTP request
  2312. }
  2313. function protocol_find_request(buf: PNetBuf; sn: PSession; var reply: Integer): PRequest; cdecl;
  2314. function http_find_request(buf: PNetBuf; sn: PSession; var reply: Integer): PRequest; cdecl;
  2315.  
  2316. {
  2317.   parses the first line of an HTTP request
  2318. }
  2319. function protocol_parse_request(t: PChar; rq: PRequest; sn: PSession): Integer; cdecl;
  2320. function http_parse_request(t: PChar; rq: PRequest; sn: PSession): Integer; cdecl;
  2321.  
  2322. {
  2323.   Scans HTTP headers from the given netbuf, and places them in headers.
  2324.   If netbuf is NULL, the session's inbuf is used.
  2325.  
  2326.   Folded lines are joined and the linefeed removed (but not the whitespace).
  2327.   If there are any repeat headers they are joined and the two field bodies
  2328.   separated by a comma and space.
  2329.  
  2330.   t should be a string of length REQ_MAX_LINE. This is a convenience to
  2331.   req.c so that we don't use too much runtime stack.
  2332.  
  2333.   Session is an optional parameter. Use NULL if you wish. It's used for
  2334.   error logs.
  2335. }
  2336. function protocol_scan_headers(sn: PSession; buf: PNetBuf; t: PChar;
  2337.   headers: PPblock): Integer; cdecl;
  2338. function http_scan_headers(sn: PSession; buf: PNetBuf; t: PChar;
  2339.   headers: PPblock): Integer; cdecl;
  2340.  
  2341. {
  2342.   Starts the HTTP response. If HTTP/0.9, does nothing. If 1.0, sends header.
  2343.   If this returns REQ_NOACTION, the method was head and no body should be
  2344.   sent. Otherwise, it will return REQ_PROCEED.
  2345. }
  2346. function protocol_start_response(sn: PSession; rq: PRequest): Integer; cdecl;
  2347. function http_start_response(sn: PSession; rq: PRequest): Integer; cdecl;
  2348.  
  2349. {
  2350.   http_hdrs2env takes the entries from the given pblock and converts them
  2351.   to an environment.
  2352.  
  2353.   Each name entry will be made uppercase, prefixed with HTTP_ and any
  2354.   occurrence of - will be converted to _.
  2355. }
  2356. function http_hdrs2env(pb: PPblock): PPCharArray; cdecl;
  2357.  
  2358. {
  2359.   http_status sets status to the code n, with reason string r. If r is
  2360.   NULL, the server will attempt to find one for the given status code.
  2361.   If it finds none, it will give "Because I felt like it."
  2362. }
  2363. procedure protocol_status(sn: PSession; rq: PRequest; n: Integer; r: PChar); cdecl;
  2364. procedure http_status(sn: PSession; rq: PRequest; n: Integer; r: PChar); cdecl;
  2365.  
  2366. {
  2367.   http_set_finfo sets content-length and last-modified
  2368. }
  2369. function protocol_set_finfo(sn: PSession; rq: PRequest; var finfo: TStat): Integer; cdecl;
  2370. function http_set_finfo(sn: PSession; rq: PRequest; var finfo: TStat): Integer; cdecl;
  2371.  
  2372. {
  2373.   Takes the given pblock and prints headers into the given buffer at
  2374.   position pos. Returns the buffer, reallocated if needed. Modifies pos.
  2375. }
  2376. function http_dump822(pb: PPblock; t: PChar; var pos: Integer; tsz: Integer): Pchar; cdecl;
  2377.  
  2378. {
  2379.   Finishes a request. For HTTP, this just closes the socket.
  2380. }
  2381. procedure protocol_finish_request(sn: PSession; rq: PRequest); cdecl;
  2382. procedure http_finish_request(sn: PSession; rq: PRequest); cdecl;
  2383.  
  2384. {
  2385.   http_handle_session processes each request generated by Session
  2386. }
  2387. procedure protocol_handle_session(sn: PSession); cdecl;
  2388. procedure http_handle_session(sn: PSession); cdecl;
  2389.  
  2390. {
  2391.   http_uri2url takes the give URI prefix and URI suffix and creates a
  2392.   newly-allocated full URL from them of the form
  2393.   http://(server):(port)(prefix)(suffix)
  2394.  
  2395.   If you want either prefix or suffix to be skipped, use "" instead of NULL.
  2396.  
  2397.   Normally, the server hostname is taken from the ServerName parameter in
  2398.   magnus.conf. The newer function http_uri2url_dynamic should be used when
  2399.   a Session and Request structure are available, to ensure that the browser
  2400.   gets redirected to the exact host they were originally referencing.
  2401. }
  2402. function protocol_uri2url(prefix, suffix: PChar): PChar; cdecl;
  2403. function protocol_uri2url_dynamic(prefix, suffix: PChar; sn: PSession;
  2404.   rq: PRequest): PChar; cdecl;
  2405. function http_uri2url(prefix, suffix: PChar): PChar; cdecl;
  2406. function http_uri2url_dynamic(prefix, suffix: PChar; sn: PSession;
  2407.   rq: PRequest): PChar; cdecl;
  2408.  
  2409. {
  2410.   http_set_keepalive_timeout sets the number of seconds to wait for a new
  2411.   request to come from a persistent connection. Returns nothing. Intended
  2412.   to be called at server startup only.
  2413.  
  2414.   Specifying a timeout of zero will disable persistent connections and allow
  2415.   browsers to request only one file per connection.
  2416. }
  2417. procedure protocol_set_keepalive_timeout(secs: Integer); cdecl;
  2418. procedure http_set_keepalive_timeout(secs: Integer); cdecl;
  2419.  
  2420. {*****************************************************************************}
  2421. {* From func.h                                                                }
  2422. {*****************************************************************************}
  2423. {
  2424.   func.h: Handles the function hash table
  2425.  
  2426.   httpd uses a table of internal functions hashed by a name string such that
  2427.   users can reference specific functions from the configuration files.
  2428.  
  2429.   Any function referenced by configuration files will be passed a
  2430.   parameter, a Request structure. The functions do not return anything.
  2431. }
  2432.  
  2433. {* -------------------------- Structure and Type -------------------------- *}
  2434.  
  2435.  
  2436. {
  2437.   FuncPtr is a pointer to our kind of functions
  2438. }
  2439.  
  2440. type
  2441.   TFunction = function (pb: PPblock; sn: PSession; rq: PRequest): Integer cdecl;
  2442.  
  2443. {
  2444.   FuncStruct is a structure used in the static declaration of the
  2445.   functions. This static declaration is parsed into a hash table at
  2446.   startup. You should initialize the next entry to NULL.
  2447. }
  2448.  
  2449.   PFuncStruct = ^TFuncStruct;
  2450.   TFuncStruct = record
  2451.     name: PChar;
  2452.     func: TFunction;
  2453.     next: PFuncStruct;
  2454.   end;
  2455.  
  2456. {* --------------------------- Hash definitions --------------------------- *}
  2457.  
  2458. {
  2459.   This is a primitive hash function. Once more is known about the names of
  2460.   the functions, this will be optimized.
  2461. }
  2462. const
  2463.   NUM_HASH = 20;
  2464.  
  2465. // #define FUNC_HASH(s) (s[0] % NUM_HASH)
  2466.  
  2467. {* ------------------------------ Prototypes ------------------------------ *}
  2468.  
  2469. {
  2470.   func_init reads the static FuncStruct arrays and creates the global
  2471.   function table from them.
  2472.  
  2473.   func_init will only read from the static arrays defined in func.c.
  2474. }
  2475. procedure func_init; cdecl;
  2476.  
  2477. {
  2478.   func_find returns a pointer to the function named name, or NULL if none
  2479.   exists.
  2480. }
  2481. function func_find(name: PChar): TFunction; cdecl;
  2482.  
  2483. {
  2484.   func_exec will try to execute the function whose name is the "fn" entry
  2485.   in the given pblock. If name is not found, it will log a misconfig of
  2486.   missing fn parameter. If it can't find it, it will log that. In these
  2487.   cases it will return REQ_ABORTED. Otherwise, it will return what the
  2488.   function being executed returns.
  2489. }
  2490. function func_exec(pb: PPblock; sn: PSession; rq: PRequest): Integer; cdecl;
  2491.  
  2492. {
  2493.   func_insert dynamically inserts a named function into the server's
  2494.   table of functions. Returns the FuncStruct it keeps in internal
  2495.   databases, because on server restart you are responsible for freeing
  2496.   (or not) its contents.
  2497. }
  2498. function func_insert(name: PChar; fn: TFunction): PFuncStruct;
  2499.  
  2500. function NSstr2String(nsStr: PChar): string;
  2501.  
  2502. implementation
  2503.  
  2504. uses SysUtils;
  2505.  
  2506. const
  2507.   nshttp = 'ns-httpd20.dll';
  2508.  
  2509. function server_fasttrack: Boolean;
  2510. begin
  2511.   Result := StrComp(MAGNUS_VERSION_STRING, PERSONAL_VERSION_STRING) = 0;
  2512. end;
  2513.  
  2514. function server_enterprise: Boolean;
  2515. begin
  2516.   Result := StrComp(MAGNUS_VERSION_STRING, ENTERPRISE_VERSION_STRING) = 0;
  2517. end;
  2518.  
  2519. procedure CONVERT_TO_PRINTABLE_FORMAT(Filename: PChar);
  2520. var
  2521.   S: PChar;
  2522. begin
  2523.   if Filename = nil then
  2524.   begin
  2525.     S := FileName;
  2526.     while S^ <> #0 do
  2527.     begin
  2528.       if S^ = '\' then
  2529.         S^ := '/';
  2530.       Inc(S);
  2531.     end;
  2532.   end;
  2533. end;
  2534.  
  2535. procedure CONVERT_TO_NATIVE_FS(Filename: PChar);
  2536. var
  2537.   S: PChar;
  2538. begin
  2539.   if Filename = nil then
  2540.   begin
  2541.     S := FileName;
  2542.     while S^ <> #0 do
  2543.     begin
  2544.       if S^ = '/' then
  2545.         S^ := '\';
  2546.       Inc(S);
  2547.     end;
  2548.   end;
  2549. end;
  2550.  
  2551. function system_rename(Old, New: PChar): BOOL;
  2552. begin
  2553.   Result := MoveFile(old, new);
  2554. end;
  2555.  
  2556. function system_unlink(path: PChar): BOOL;
  2557. begin
  2558.   Result := DeleteFile(path);
  2559. end;
  2560.  
  2561. function system_lseek(fd: SYS_FILE; off: Longint; wh: Longint): Longint;
  2562. begin
  2563.   Result := SetFilePointer(fd.fh, Off, nil, wh);
  2564. end;
  2565.  
  2566. function system_flock(fd: SYS_FILE): Integer;
  2567. begin
  2568.   Result := sem_grab(fd.flsem);
  2569. end;
  2570.  
  2571. function system_ulock(fd: SYS_FILE): Integer;
  2572. begin
  2573.   Result := sem_release(fd.flsem);
  2574. end;
  2575.  
  2576. function dir_create(Path: PChar): Integer;
  2577. begin
  2578.   if CreateDirectory(Path, nil) then
  2579.     Result := 0
  2580.   else Result := -1;
  2581. end;
  2582.  
  2583. function dir_remove(Path: PChar): Integer;
  2584. begin
  2585.   if RemoveDirectory(Path) then
  2586.     Result := 0
  2587.   else Result := -1;
  2588. end;
  2589.  
  2590. function pblock_find(name: PChar; pb: PPblock): PPbParam;
  2591. begin
  2592.   Result := _pblock_fr(name,pb,False);
  2593. end;
  2594.  
  2595. function pblock_remove(name: PChar; pb: PPblock): PPbParam;
  2596. begin
  2597.   Result := _pblock_fr(name,pb,True);
  2598. end;
  2599.  
  2600. function netbuf_getc(b: PNetBuf): Integer;
  2601. begin
  2602.   with b^ do
  2603.     if pos <> cursize then
  2604.     begin
  2605.       Result := Integer(Byte(inbuf[pos]));
  2606.       Inc(pos);
  2607.     end else Result := netbuf_next(b, 1);
  2608. end;
  2609.  
  2610. function filebuf_getc(b: PFileBuffer): Integer;
  2611. begin
  2612.   with b^ do
  2613.     if pos = len then
  2614.       Result := IO_EOF
  2615.     else
  2616.     begin
  2617.       Result := Integer(Byte(fp[pos]));
  2618.       Inc(pos);
  2619.     end;
  2620. end;
  2621.  
  2622. function pipebuf_getc(b: PFileBuffer): Integer;
  2623. begin
  2624.   with b^ do
  2625.     if pos <> cursize then
  2626.     begin
  2627.       Result := Integer(Byte(inbuf[pos]));
  2628.       Inc(pos);
  2629.     end else Result := pipebuf_next(b, 1);
  2630. end;
  2631.  
  2632. function session_dns(sn: PSession): PChar;
  2633. begin
  2634.   Result := session_dns_lookup(sn, False);
  2635. end;
  2636.  
  2637. function session_maxdns(sn: PSession): PChar;
  2638. begin
  2639.   Result := session_dns_lookup(sn, True);
  2640. end;
  2641.  
  2642. function CINFO_HASH(s: PChar): Char;
  2643. begin
  2644.   if IsCharAlpha(s[0]) then
  2645.     Result := Char(Byte(CharLower(PChar(s[0]))) - Ord('a'))
  2646.   else Result := #26;
  2647. end;
  2648.  
  2649. function request_loadheaders(sn: PSession; rq: PRequest): Integer;
  2650. begin
  2651.   Result := REQ_PROCEED;
  2652. end;
  2653.  
  2654. function userpw: PPASSWD;
  2655. begin
  2656.   Result := conf_getglobals.Vuserpw;
  2657. end;
  2658.  
  2659. function pool_max: Integer;
  2660. begin
  2661.   Result := conf_getglobals.Vpool_max;
  2662. end;
  2663.  
  2664. function pool_min: Integer;
  2665. begin
  2666.   Result := conf_getglobals.Vpool_min;
  2667. end;
  2668.  
  2669. function pool_life: Integer;
  2670. begin
  2671.   Result := conf_getglobals.Vpool_life;
  2672. end;
  2673.  
  2674. function pool_maxthreads: Integer;
  2675. begin
  2676.   Result := conf_getglobals.Vpool_maxthreads;
  2677. end;
  2678.  
  2679. function pool_minthreads: Integer;
  2680. begin
  2681.   Result := conf_getglobals.Vpool_minthreads;
  2682. end;
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711. function server_hostname: PChar;
  2712. begin
  2713.   Result := conf_getglobals.Vserver_hostname;
  2714. end;
  2715.  
  2716. function root_object: PChar;
  2717. begin
  2718.   Result := conf_getglobals.Vroot_object;
  2719. end;
  2720.  
  2721. function std_os: PHttpdObjSet;
  2722. begin
  2723.   Result := conf_getglobals.Vstd_os;
  2724. end;
  2725.  
  2726. function acl_root: Pointer;
  2727. begin
  2728.   Result := conf_getglobals.Vacl_root;
  2729. end;
  2730.  
  2731. function master_error_log: PChar;
  2732. begin
  2733.   Result := conf_getglobals.Vmaster_error_log;
  2734. end;
  2735.  
  2736. function server_root: PChar;
  2737. begin
  2738.   Result := conf_getglobals.Vserver_root;
  2739. end;
  2740.  
  2741. function server_id: PChar;
  2742. begin
  2743.   Result := conf_getglobals.Vserver_id;
  2744. end;
  2745.  
  2746. function NSstr2String(nsStr: PChar): string;
  2747. begin
  2748.   Result := nsStr;
  2749.   system_free(nsStr);
  2750. end;
  2751.  
  2752. { imports }
  2753.  
  2754. function strcasecmp; external nshttp name 'strcasecmp';
  2755. function strncasecmp; external nshttp name 'strncasecmp';
  2756. function util_strcasecmp; external nshttp name 'util_strcasecmp';
  2757. function util_strncasecmp; external nshttp name 'util_strncasecmp';
  2758. function system_version; external nshttp name 'system_version';
  2759. function MAGNUS_VERSION_STRING; external nshttp name 'MAGNUS_VERSION_STRING';
  2760. procedure system_version_set; external nshttp name 'system_version_set';
  2761. function MALLOC; external nshttp name 'system_malloc';
  2762. function system_malloc; external nshttp name 'system_malloc';
  2763. function CALLOC; external nshttp name 'system_calloc';
  2764. function system_calloc; external nshttp name 'system_calloc';
  2765. function REALLOC; external nshttp name 'system_realloc';
  2766. function system_realloc; external nshttp name 'system_realloc';
  2767. procedure FREE; external nshttp name 'system_free';
  2768. procedure system_free; external nshttp name 'system_free';
  2769. function STRDUP; external nshttp name 'system_strdup';
  2770. function system_strdup; external nshttp name 'system_strdup';
  2771. function PERM_MALLOC; external nshttp name 'system_malloc_perm';
  2772. function system_malloc_perm; external nshttp name 'system_malloc_perm';
  2773. function PERM_CALLOC; external nshttp name 'system_calloc_perm';
  2774. function system_calloc_perm; external nshttp name 'system_calloc_perm';
  2775. function PERM_REALLOC; external nshttp name 'system_realloc_perm';
  2776. function system_realloc_perm; external nshttp name 'system_realloc_perm';
  2777. procedure PERM_FREE; external nshttp name 'system_free_perm';
  2778. procedure system_free_perm; external nshttp name 'system_free_perm';
  2779. function PERM_STRDUP; external nshttp name 'system_strdup_perm';
  2780. function system_strdup_perm; external nshttp name 'system_strdup_perm';
  2781. procedure magnus_atrestart; external nshttp name 'magnus_atrestart';
  2782. function pool_create; external nshttp name 'pool_create';
  2783. procedure pool_destroy; external nshttp name 'pool_destroy';
  2784. function pool_enabled; external nshttp name 'pool_enabled';
  2785. function pool_malloc; external nshttp name 'pool_malloc';
  2786. procedure pool_free; external nshttp name 'pool_free';
  2787. function pool_calloc; external nshttp name 'pool_calloc';
  2788. function pool_realloc; external nshttp name 'pool_realloc';
  2789. function pool_strdup; external nshttp name 'pool_strdup';
  2790. function sem_init; external nshttp name 'sem_init';
  2791. procedure sem_terminate; external nshttp name 'sem_terminate';
  2792. function sem_grab; external nshttp name 'sem_grab';
  2793. function sem_tgrab; external nshttp name 'sem_tgrab';
  2794. function sem_release; external nshttp name 'sem_release';
  2795. function crit_init; external nshttp name 'crit_init';
  2796. procedure crit_enter; external nshttp name 'crit_enter';
  2797. procedure crit_exit; external nshttp name 'crit_exit';
  2798. procedure crit_terminate; external nshttp name 'crit_terminate';
  2799. function condvar_init; external nshttp name 'condvar_init';
  2800. procedure condvar_wait; external nshttp name 'condvar_wait';
  2801. procedure condvar_notify; external nshttp name 'condvar_notify';
  2802. procedure condvar_terminate; external nshttp name 'condvar_terminate';
  2803. function system_chdir; external 'kernel32.dll' name 'SetCurrentDirectory';
  2804. function system_stat; external nshttp name 'system_stat';
  2805. function system_fread; external nshttp name 'system_fread';
  2806. function system_pread; external nshttp name 'system_pread';
  2807. function system_fopenRO; external nshttp name 'system_fopenRO';
  2808. function system_fopenWA; external nshttp name 'system_fopenWA';
  2809. function system_fopenRW; external nshttp name 'system_fopenRW';
  2810. function system_fopenWT; external nshttp name 'system_fopenWT';
  2811. procedure system_fclose; external nshttp name 'system_fclose';
  2812. function system_nocoredumps; external nshttp name 'system_nocoredumps';
  2813. function system_winsockerr; external nshttp name 'system_winsockerr';
  2814. function system_winerr; external nshttp name 'system_winerr';
  2815. function system_fwrite; external nshttp name 'system_fwrite';
  2816. function system_fwrite_atomic; external nshttp name 'system_fwrite_atomic';
  2817. function file_notfound; external nshttp name 'file_notfound';
  2818. function system_errmsg; external nshttp name 'system_errmsg_fn';
  2819. function system_errmsg_fn; external nshttp name 'system_errmsg_fn';
  2820. function system_initlock; external nshttp name 'system_initlock';
  2821. function file_setinherit; external nshttp name 'file_setinherit';
  2822. procedure file_unix2local; external nshttp name 'file_unix2local';
  2823. function dir_open; external nshttp name 'dir_open';
  2824. function dir_read; external nshttp name 'dir_read';
  2825. procedure dir_close; external nshttp name 'dir_close';
  2826. function dir_create_all; external nshttp name 'dir_create_all';
  2827. function param_create; external nshttp name 'param_create';
  2828. function param_free; external nshttp name 'param_free';
  2829. function pblock_create; external nshttp name 'pblock_create';
  2830. procedure pblock_free; external nshttp name 'pblock_free';
  2831. function pblock_findval; external nshttp name 'pblock_findval';
  2832. function pblock_nvinsert; external nshttp name 'pblock_nvinsert';
  2833. function pblock_nninsert; external nshttp name 'pblock_nninsert';
  2834. procedure pblock_pinsert; external nshttp name 'pblock_pinsert';
  2835. function pblock_str2pblock; external nshttp name 'pblock_str2pblock';
  2836. function pblock_pblock2str; external nshttp name 'pblock_pblock2str';
  2837. procedure pblock_copy; external nshttp name 'pblock_copy';
  2838. function pblock_dup; external nshttp name 'pblock_dup';
  2839. function pblock_pb2env; external nshttp name 'pblock_pb2env';
  2840. function _pblock_fr; external nshttp name '_pblock_fr';
  2841. function net_socket; external nshttp name 'net_socket';
  2842. function net_getsockopt; external nshttp name 'net_getsockopt';
  2843. function net_setsockopt; external nshttp name 'net_setsockopt';
  2844. function net_listen; external nshttp name 'net_listen';
  2845. function net_create_listener; external nshttp name 'net_create_listener';
  2846. function net_select; external nshttp name 'net_select';
  2847. function net_connect; external nshttp name 'net_connect';
  2848. function net_ioctl; external nshttp name 'net_ioctl';
  2849. function net_getpeername; external nshttp name 'net_getpeername';
  2850. function net_close; external nshttp name 'net_close';
  2851. function net_bind; external nshttp name 'net_bind';
  2852. function net_accept; external nshttp name 'net_accept';
  2853. function net_read; external nshttp name 'net_read';
  2854. function net_write; external nshttp name 'net_write';
  2855. function net_isalive; external nshttp name 'net_isalive';
  2856. function net_ip2host; external nshttp name 'net_ip2host';
  2857. function filebuf_open; external nshttp name 'filebuf_open';
  2858. function netbuf_open; external nshttp name 'netbuf_open';
  2859. function filebuf_create; external nshttp name 'filebuf_create';
  2860. procedure filebuf_close_buffer; external nshttp name 'filebuf_close_buffer';
  2861. function filebuf_open_nostat; external nshttp name 'filebuf_open_nostat';
  2862. function pipebuf_open; external nshttp name 'pipebuf_open';
  2863. function filebuf_next; external nshttp name 'filebuf_next';
  2864. function netbuf_next; external nshttp name 'netbuf_next';
  2865. function pipebuf_next; external nshttp name 'pipebuf_next';
  2866. procedure filebuf_close; external nshttp name 'filebuf_close';
  2867. procedure netbuf_close; external nshttp name 'netbuf_close';
  2868. procedure pipebuf_close; external nshttp name 'pipebuf_close';
  2869. function filebuf_grab; external nshttp name 'filebuf_grab';
  2870. function netbuf_grab; external nshttp name 'netbuf_grab';
  2871. function pipebuf_grab; external nshttp name 'pipebuf_grab';
  2872. function netbuf_buf2sd; external nshttp name 'netbuf_buf2sd';
  2873. function filebuf_buf2sd; external nshttp name 'filebuf_buf2sd';
  2874. function pipebuf_buf2sd; external nshttp name 'pipebuf_buf2sd';
  2875. function pipebuf_netbuf2sd; external nshttp name 'pipebuf_netbuf2sd';
  2876. function session_create; external nshttp name 'session_create';
  2877. procedure session_free; external nshttp name 'session_free';
  2878. function session_dns_lookup; external nshttp name 'session_dns_lookup';
  2879. procedure cinfo_init; external nshttp name 'cinfo_init';
  2880. procedure cinfo_terminate; external nshttp name 'cinfo_terminate';
  2881. function cinfo_merge; external nshttp name 'cinfo_merge';
  2882. function cinfo_find; external nshttp name 'cinfo_find';
  2883. function cinfo_lookup; external nshttp name 'cinfo_lookup';
  2884. function ereport_init; external nshttp name 'ereport_init';
  2885. procedure ereport_terminate; external nshttp name 'ereport_terminate';
  2886. function ereport_getfd; external nshttp name 'ereport_getfd';
  2887. function shexp_valid; external nshttp name 'shexp_valid';
  2888. function shexp_match; external nshttp name 'shexp_match';
  2889. function shexp_cmp; external nshttp name 'shexp_cmp';
  2890. function shexp_casecmp; external nshttp name 'shexp_casecmp';
  2891. function shmem_alloc; external nshttp name 'shmem_alloc';
  2892. procedure shmem_free; external nshttp name 'shmem_free';
  2893. function systhread_start; external nshttp name 'systhread_start';
  2894. function systhread_current; external nshttp name 'systhread_current';
  2895. procedure systhread_yield; external nshttp name 'systhread_yield';
  2896. function systhread_attach; external nshttp name 'systhread_attach';
  2897. procedure systhread_terminate; external nshttp name 'systhread_terminate';
  2898. procedure systhread_sleep; external nshttp name 'systhread_sleep';
  2899. procedure systhread_init; external nshttp name 'systhread_init';
  2900. procedure systhread_timerset; external nshttp name 'systhread_timerset';
  2901. function systhread_newkey; external nshttp name 'systhread_newkey';
  2902. function systhread_getdata; external nshttp name 'systhread_getdata';
  2903. procedure systhread_setdata; external nshttp name 'systhread_setdata';
  2904. procedure _ntdaemon_run; external nshttp name '_ntdaemon_run';
  2905. procedure daemon_atrestart; external nshttp name 'daemon_atrestart';
  2906. function child_fork; external nshttp name 'child_fork';
  2907. {$ifdef NET_SSL}
  2908. procedure servssl_init; external nshttp name 'servssl_init';
  2909. {$endif NET_SSL}
  2910. function util_getline; external nshttp name 'util_getline';
  2911. function util_env_create; external nshttp name 'util_env_create';
  2912. function util_env_str; external nshttp name 'util_env_str';
  2913. procedure util_env_replace; external nshttp name 'util_env_replace';
  2914. procedure util_env_free; external nshttp name 'util_env_free';
  2915. function util_env_copy; external nshttp name 'util_env_copy';
  2916. function util_env_find; external nshttp name 'util_env_find';
  2917. function util_hostname; external nshttp name 'util_hostname';
  2918. function util_chdir2path; external nshttp name 'util_chdir2path';
  2919. function util_is_mozilla; external nshttp name 'util_is_mozilla';
  2920. function util_is_url; external nshttp name 'util_is_url';
  2921. function util_later_than; external nshttp name 'util_later_than';
  2922. function util_time_equal; external nshttp name 'util_time_equal';
  2923. function util_str_time_equal; external nshttp name 'util_str_time_equal';
  2924. function util_uri_is_evil; external nshttp name 'util_uri_is_evil';
  2925. procedure util_uri_parse; external nshttp name 'util_uri_parse';
  2926. procedure util_uri_unescape; external nshttp name 'util_uri_unescape';
  2927. function util_uri_escape; external nshttp name 'util_uri_escape';
  2928. function util_url_escape; external nshttp name 'util_url_escape';
  2929. function util_sh_escape; external nshttp name 'util_sh_escape';
  2930. function util_mime_separator; external nshttp name 'util_mime_separator';
  2931. function util_itoa; external nshttp name 'util_itoa';
  2932. procedure util_delete_directory; external nshttp name 'util_delete_directory';
  2933. function util_strftime; external nshttp name 'util_strftime';
  2934. function object_create; external nshttp name 'object_create';
  2935. procedure object_free; external nshttp name 'object_free';
  2936. procedure object_add_directive; external nshttp name 'object_add_directive';
  2937. function object_execute; external nshttp name 'object_execute';
  2938. function objset_scan_buffer; external nshttp name 'objset_scan_buffer';
  2939. function objset_create; external nshttp name 'objset_create';
  2940. procedure objset_free; external nshttp name 'objset_free';
  2941. procedure objset_free_setonly; external nshttp name 'objset_free_setonly';
  2942. function objset_new_object; external nshttp name 'objset_new_object';
  2943. procedure objset_add_object; external nshttp name 'objset_add_object';
  2944. procedure objset_add_init; external nshttp name 'objset_add_init';
  2945. function objset_findbyname; external nshttp name 'objset_findbyname';
  2946. function objset_findbyppath; external nshttp name 'objset_findbyppath';
  2947. function objset_copydirs; external nshttp name 'objset_copydirs';
  2948. function objset_scan_registry; external nshttp name 'objset_scan_registry';
  2949. procedure ProcessObject; external nshttp name 'ProcessObject';
  2950. function ProcessClient; external nshttp name 'ProcessClient';
  2951. function ProcessDirective; external nshttp name 'ProcessDirective';
  2952. function ProcessFunction; external nshttp name 'ProcessFunction';
  2953. function _ntverify_parameter; external nshttp name '_ntverify_parameter';
  2954. function ntpblock_str2pblock; external nshttp name 'ntpblock_str2pblock';
  2955. function ntpblock_pblock2str; external nshttp name 'ntpblock_pblock2str';
  2956. function ClearConfigurationParameters; external nshttp name 'ClearConfigurationParameters';
  2957. function GetProductKey; external nshttp name 'GetProductKey';
  2958. function conf_init; external nshttp name 'conf_init';
  2959. procedure conf_terminate; external nshttp name 'conf_terminate';
  2960. function conf_getglobals; external nshttp name 'conf_getglobals';
  2961. procedure conf_vars2daemon; external nshttp name 'conf_vars2daemon';
  2962. function GetDomainAddresses; external nshttp name 'GetDomainAddresses';
  2963. function request_create; external nshttp name 'request_create';
  2964. procedure request_free; external nshttp name 'request_free';
  2965. function request_restart_internal; external nshttp name 'request_restart_internal';
  2966. function request_header; external nshttp name 'request_header';
  2967. function request_stat_path; external nshttp name 'request_stat_path';
  2968. procedure request_handle; external nshttp name 'request_handle';
  2969. function request_translate_uri; external nshttp name 'servact_translate_uri';
  2970. function protocol_find_request; external nshttp name 'http_find_request';
  2971. function http_find_request; external nshttp name 'http_find_request';
  2972. function protocol_parse_request; external nshttp name 'http_parse_request';
  2973. function http_parse_request; external nshttp name 'http_parse_request';
  2974. function protocol_scan_headers; external nshttp name 'http_scan_headers';
  2975. function http_scan_headers; external nshttp name 'http_scan_headers';
  2976. function protocol_start_response; external nshttp name 'http_start_response';
  2977. function http_start_response; external nshttp name 'http_start_response';
  2978. function http_hdrs2env; external nshttp name 'http_hdrs2env';
  2979. procedure protocol_status; external nshttp name 'http_status';
  2980. procedure http_status; external nshttp name 'http_status';
  2981. function protocol_set_finfo; external nshttp name 'http_set_finfo';
  2982. function http_set_finfo; external nshttp name 'http_set_finfo';
  2983. function http_dump822; external nshttp name 'http_dump822';
  2984. procedure protocol_finish_request; external nshttp name 'http_finish_request';
  2985. procedure http_finish_request; external nshttp name 'http_finish_request';
  2986. procedure protocol_handle_session; external nshttp name 'http_handle_session';
  2987. procedure http_handle_session; external nshttp name 'http_handle_session';
  2988. function protocol_uri2url; external nshttp name 'http_uri2url';
  2989. function protocol_uri2url_dynamic; external nshttp name 'http_uri2url_dynamic';
  2990. function http_uri2url; external nshttp name 'http_uri2url';
  2991. function http_uri2url_dynamic; external nshttp name 'http_uri2url_dynamic';
  2992. procedure protocol_set_keepalive_timeout; external nshttp name 'http_set_keepalive_timeout';
  2993. procedure http_set_keepalive_timeout; external nshttp name 'http_set_keepalive_timeout';
  2994. procedure func_init; external nshttp name 'func_init';
  2995. function func_find; external nshttp name 'func_find';
  2996. function func_exec; external nshttp name 'func_exec';
  2997. function func_insert; external nshttp name 'func_insert';
  2998.  
  2999. end.
  3000.