home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nsfast / root.9 / usr / ns-home / nsapi / include / frame / objset.h / objset
Text File  |  1998-08-19  |  7KB  |  248 lines

  1. /*
  2.  * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
  3.  * rights reserved.
  4.  * 
  5.  * Use of this software is governed by the terms of the license agreement for
  6.  * the Netscape FastTrack or Netscape Enterprise Server between the
  7.  * parties.
  8.  */
  9.  
  10.  
  11. /* ------------------------------------------------------------------------ */
  12.  
  13.  
  14. /*
  15.  * objset.h: Handles object sets
  16.  * 
  17.  * Each object is produced by reading a config file of some form. See the
  18.  * server documentation for descriptions of the directives that are 
  19.  * recognized, what they do, and how they are parsed.
  20.  * 
  21.  * This module requires the pblock and buffer modules from the base library.
  22.  *
  23.  * Rob McCool
  24.  */
  25.  
  26.  
  27. #ifndef OBJSET_H
  28. #define OBJSET_H
  29.  
  30. #include "netsite.h"
  31. #include "base/pblock.h"
  32. #include "base/buffer.h"
  33. #include "frame/object.h"
  34.  
  35.  
  36.  
  37. /* ------------------------------ Constants ------------------------------- */
  38.  
  39.  
  40. /* 
  41.  * The default number of objects to leave room for in an object set,
  42.  * and the number of new entries by which to increase the size when that 
  43.  * room is filled.
  44.  */
  45.  
  46. #define OBJSET_INCSIZE 8
  47.  
  48. /*
  49.  * When parsing config. files, httpd will put a limit on how long
  50.  * the parameters to a directive can be (in characters).
  51.  * 
  52.  * Currently set to 10 lines (80 chars/line).
  53.  */
  54.  
  55. #ifdef MCC_PROXY
  56. #define MAX_DIRECTIVE_LEN 100000
  57. #else
  58. #define MAX_DIRECTIVE_LEN 800
  59. #endif /* MCC_PROXY */
  60.  
  61. /*
  62.  * The size of the hash tables that store a directive's parameters
  63.  */
  64.  
  65. #define PARAMETER_HASH_SIZE 3
  66.  
  67.  
  68. /* ------------------------------ Structures ------------------------------ */
  69.  
  70.  
  71. /*
  72.  * httpd_objset is a container for a bunch of objects. obj is a 
  73.  * NULL-terminated array of objects. pos points to the entry after the last
  74.  * one in the array. You should not mess with pos, but can read it to find
  75.  * the last entry.
  76.  *
  77.  * The initfns array is a NULL-terminated array of the Init functions 
  78.  * associated with this object set. If there are no Init functions associated
  79.  * with this object set, initfns can be NULL. Each pblock specifies the
  80.  * parameters which are passed to the function when it's executed.
  81.  */
  82.  
  83. typedef struct {
  84.     int pos;
  85.     httpd_object **obj;
  86.  
  87.     pblock **initfns;
  88. } httpd_objset;
  89.  
  90.  
  91. /* ------------------------------ Prototypes ------------------------------ */
  92.  
  93.  
  94. /*
  95.  * objset_scan_buffer will scan through buffer, looking for object 
  96.  * configuration information, and adding them to the object set os if it 
  97.  * finds any. If os is NULL it will allocate a new object set.
  98.  *
  99.  * If any error occurs (syntax error, premature EOF) this function will
  100.  * free os, print an error message into errstr, and return NULL.
  101.  * This is because a config. file error is viewed as a catastrophic error
  102.  * from which httpd should not try to recover. If httpd were to continue
  103.  * after an error, it would not behave as the admin. expected and he/she
  104.  * may not notice until it's too late.
  105.  *
  106.  * Upon EOF the file will not be closed.
  107.  */
  108.  
  109. NSAPI_PUBLIC httpd_objset *objset_scan_buffer(filebuffer *buf, char *errstr, 
  110.                                               httpd_objset *os);
  111.  
  112. /*
  113.  * objset_create creates a new object set and returns a pointer to it.
  114.  */
  115.  
  116. NSAPI_PUBLIC httpd_objset *objset_create(void);
  117.  
  118. /*
  119.  * objset_free will free an object set, any associated objects, and any
  120.  * associated Init functions.
  121.  */
  122.  
  123. NSAPI_PUBLIC void objset_free(httpd_objset *os);
  124.  
  125. /*
  126.  * objset_free_setonly frees only the object set, and not the associated
  127.  * objects or init functions.
  128.  */
  129. NSAPI_PUBLIC void objset_free_setonly(httpd_objset *os);
  130.  
  131. /*
  132.  * objset_new_object will add a new object to objset with the specified
  133.  * name. It returns a pointer to the new object (which may be anywhere in 
  134.  * the objset).
  135.  */
  136.  
  137. NSAPI_PUBLIC httpd_object *objset_new_object(pblock *name, httpd_objset *os);
  138.  
  139. /*
  140.  * objset_add_object will add the existing object to os.
  141.  */
  142.  
  143. NSAPI_PUBLIC void objset_add_object(httpd_object *obj, httpd_objset *os);
  144.  
  145.  
  146. /*
  147.  * objset_add_init will add the initialization function specified by 
  148.  * initfn to the given object set. Modifies os->initfns.
  149.  */
  150. NSAPI_PUBLIC void objset_add_init(pblock *initfn, httpd_objset *os);
  151.  
  152. /*
  153.  * objset_findbyname will find the object in objset having the given name,
  154.  * and return the object if found, and NULL otherwise.
  155.  * ign is a set of objects to ignore.
  156.  */
  157.  
  158. NSAPI_PUBLIC httpd_object *objset_findbyname(char *name, httpd_objset *ign, 
  159.                                              httpd_objset *os);
  160.  
  161. /*
  162.  * objset_findbyppath will find the object in objset having the given 
  163.  * partial path entry. Returns object if found, NULL otherwise.
  164.  * ign is a set of objects to ignore.
  165.  */
  166.  
  167. NSAPI_PUBLIC httpd_object *objset_findbyppath(char *ppath, httpd_objset *ign, 
  168.                                               httpd_objset *os);
  169.  
  170. /*
  171.  * objset_copydirs takes a given objset and copies all of the 
  172.  * directive in directive set <dir> into a new objset, dst_os.  If 
  173.  * dst_os is NULL, it creates a new objset.
  174.  * The newly created objset only has one object in it.
  175.  */
  176. httpd_objset *objset_copydirs(httpd_objset *dst_os, httpd_objset *os, int dir);
  177.  
  178. #ifdef XP_WIN32
  179.  
  180. /* Read the registry configuration parameters into memory */
  181.  
  182. NSAPI_PUBLIC 
  183. httpd_objset *objset_scan_registry(char *errstr, httpd_objset *os, 
  184.                                    char *product_key);
  185.  
  186. /* Recursively scan the object key */
  187.  
  188. NSAPI_PUBLIC VOID 
  189. ProcessObject(
  190.     httpd_objset *nos, HKEY hObjectKey,
  191.     CHAR *Object, DWORD ObjectIndex
  192.     );
  193.  
  194. /* Recursively scan the client key */
  195.  
  196. NSAPI_PUBLIC BOOLEAN
  197. ProcessClient(
  198.     httpd_object *cobj, HKEY hObjectKey,
  199.     CHAR *Client, DWORD ObjectIndex
  200.     );
  201.  
  202. /* Recursively scan the directive key */
  203.  
  204. NSAPI_PUBLIC BOOLEAN
  205. ProcessDirective (
  206.     httpd_object *cobj, pblock *param, pblock *client, HKEY hObjectKey,
  207.     CHAR *Directive, DWORD ObjectIndex, DWORD DirectiveIndex, DWORD *clrefs,
  208.     BOOLEAN IsObject
  209.     );
  210.  
  211. /* Recursively scan the function key */
  212.  
  213. NSAPI_PUBLIC BOOLEAN
  214. ProcessFunction(
  215.     pblock **param, HKEY hDirectiveKey, CHAR *Function,
  216.     DWORD ObjectIndex, DWORD DirectiveIndex, DWORD FunctionIndex);
  217.  
  218. /* Verify the name value pair */
  219.  
  220. NSAPI_PUBLIC int _ntverify_parameter(char *str);
  221.  
  222. /* Enter name value pair into pblock */
  223. NSAPI_PUBLIC
  224. int ntpblock_str2pblock(int ParameterIndex, char *name, char *value, 
  225.     int namelength, int valuelength, pblock *pb);
  226.  
  227. /* Get name value pair from a pblock entry */
  228. NSAPI_PUBLIC
  229. int ntpblock_pblock2str(struct pb_entry *p, PCHAR *ParameterName, 
  230.     PCHAR *ParameterValue);
  231.  
  232. /* Given a key and its parent, delete the key recursively */
  233. NSAPI_PUBLIC
  234. BOOLEAN ClearConfigurationParameters(
  235.     HKEY hParentKey, 
  236.     PCHAR CompleteKeyName, 
  237.     PCHAR KeyName);
  238.  
  239. /* Look at the hidden file in the server's directory structure to 
  240.  * figure out the name of this server */
  241. NSAPI_PUBLIC
  242. char *GetProductKey();
  243.  
  244. #endif /* XP_WIN32 */
  245.  
  246.  
  247. #endif
  248.