home *** CD-ROM | disk | FTP | other *** search
/ Programming with VisualAge for Java / IBMVJAVA.ISO / icswin95 / httpdw32.z / object.h < prev    next >
C/C++ Source or Header  |  1997-04-07  |  4KB  |  161 lines

  1. /*
  2.  **************************************************************************
  3.  * Netscape Compatibility Applications Programming Interface
  4.  **************************************************************************
  5.  */
  6.  
  7.  
  8. /*
  9.  * object.h: Handle httpd objects
  10.  *
  11.  * Manages information about a document from config. files. Called mainly
  12.  * by objset.c.
  13.  *
  14.  * This module does not assume anything about the directives being parsed.
  15.  * That is handled by objset.c.
  16.  *
  17.  * This module requires the pblock module from the base library.
  18.  *
  19.  * Rob McPool
  20.  *
  21.  */
  22.  
  23.  
  24. #ifndef NS_OBJECT_H
  25. #define NS_OBJECT_H
  26.  
  27.  
  28. #include "netsite.h"
  29. #include "base/pblock.h"
  30. #include "base/session.h"
  31.  
  32.  
  33.  
  34. /* ------------------------------ Constants ------------------------------- */
  35.  
  36. /* The maximum directive length unabbreviated, plus one space */
  37. #define MAX_DNAME_LEN 11
  38. #define NUM_DIRECTIVES 7
  39.  
  40.  
  41. /* ------------------------------ Structures ------------------------------ */
  42.  
  43.  
  44.  
  45. /*
  46.  * NETSCAPE SAYS:
  47.  *
  48.  * "Hierarchy of httpd_object
  49.  *
  50.  * An object contains dtables.
  51.  *
  52.  * Each dtable is a table of directives that were entered of a certain type.
  53.  * There is one dtable for each unique type of directive.
  54.  *
  55.  * Each dtable contains an array of directives, each of which is equivalent
  56.  * to one directive that occurred in a config. file.
  57.  *
  58.  * It is up to the caller to determine how many dtables will be allocated
  59.  * and to keep track of which of their directive types maps to which dtable
  60.  * number."
  61.  */
  62.  
  63.  
  64. /*
  65.  * directive is a structure containing the protection and parameters to an
  66.  * instance of a directive within an httpd_object.
  67.  *
  68.  * param is the parameters, client is the protection.
  69.  */
  70.  
  71. typedef struct {
  72.     pblock *param;
  73.     pblock *client;
  74. } directive;
  75.  
  76. /*
  77.  * dtable is a structure for creating tables of directives
  78.  */
  79.  
  80. typedef struct {
  81.     int ni;
  82.     directive *inst;
  83. } dtable;
  84.  
  85. /*
  86.  * The httpd_object structure.
  87.  *
  88.  * The name pblock array contains the names for this object, such as its
  89.  * virtual location, its physical location, or its identifier.
  90.  *
  91.  * tmpl contains any templates allocated to this object.
  92.  */
  93.  
  94. typedef struct {
  95.     pblock *name;
  96.  
  97.     int nd;
  98.     dtable *dt;
  99. } httpd_object;
  100.  
  101.  
  102.  
  103.  
  104. /* ------------------------------ Prototypes ------------------------------ */
  105.  
  106.  
  107. /*
  108.  * directive_name2num will return the position of the abbreviated directive
  109.  * dir in the directive table.
  110.  *
  111.  * If dir does not exist in the table, it will return -1.
  112.  */
  113.  
  114. int directive_name2num(char *dir);
  115.  
  116.  
  117. /*
  118.  * directive_num2name returns a string describing directive number num.
  119.  */
  120.  
  121. const char *directive_num2name(int num);
  122.  
  123.  
  124. /*
  125.  * object_create will create a new object and return a pointer to it.
  126.  * It will allocate space for nd directive types and set name accordingly.
  127.  */
  128.  
  129. httpd_object *object_create(int nd, pblock *name);
  130.  
  131. /*
  132.  * object_free will free an object and any data associated with it.
  133.  */
  134.  
  135. void object_free(httpd_object *obj);
  136.  
  137. /*
  138.  * object_add_directive will add a new directive to the dtable for
  139.  * the directive class at position iDirClass.
  140.  */
  141.  
  142. void object_add_directive(int iDirClass, pblock *pParms, pblock *pClient,
  143.                           httpd_object *pObj);
  144.  
  145.  
  146. /*
  147.  * object_findnext finds the object configured to follow the given object,
  148.  * and stores the variables in rq->vars. It returns REQ_PROCEED if more
  149.  * objects should be processed, or REQ_NOACTION if it did not find any
  150.  * further objects to process. If something bad happens, REQ_ABORTED is
  151.  * returned.
  152.  *
  153.  * Handles all DIRECTIVE_CONSTRUCT type directives such as NameTrans and
  154.  * AuthType.
  155.  */
  156.  
  157.  
  158. /* --------- Prototype moved to req.h because of interdependency ---------- */
  159.  
  160. #endif
  161.