Blame WWW/Library/Implementation/HTRules.h

Packit f574b8
/*                                             Configuration Manager for libwww
Packit f574b8
 *                            CONFIGURATION MANAGER
Packit f574b8
 *
Packit f574b8
 * Author Tim Berners-Lee/CERN.  Public domain.  Please mail changes to
Packit f574b8
 * timbl@info.cern.ch.
Packit f574b8
 *
Packit f574b8
 * The configuration information loaded includes tables (file suffixes,
Packit f574b8
 * presentation methods) in other modules.  The most likely routines needed by
Packit f574b8
 * developers will be:
Packit f574b8
 *
Packit f574b8
 * HTSetConfiguration	to load configuration information.
Packit f574b8
 *
Packit f574b8
 * HTLoadRules		to load a whole file of configuration information
Packit f574b8
 *
Packit f574b8
 * HTTranslate		to translate a URL using the rule table.
Packit f574b8
 *
Packit f574b8
 */
Packit f574b8
#ifndef HTRULE_H
Packit f574b8
#define HTRULE_H
Packit f574b8
Packit f574b8
#ifndef HTUTILS_H
Packit f574b8
#include <HTUtils.h>
Packit f574b8
#endif
Packit f574b8
Packit f574b8
#ifdef __cplusplus
Packit f574b8
extern "C" {
Packit f574b8
#endif
Packit f574b8
    typedef enum {
Packit f574b8
	HT_Invalid,
Packit f574b8
	HT_Map,
Packit f574b8
	HT_Pass,
Packit f574b8
	HT_Fail,
Packit f574b8
	HT_DefProt,
Packit f574b8
	HT_Protect,
Packit f574b8
	HT_Progress,
Packit f574b8
	HT_InfoMsg,
Packit f574b8
	HT_UserMsg,
Packit f574b8
	HT_Alert,
Packit f574b8
	HT_AlwaysAlert,
Packit f574b8
	HT_Redirect,
Packit f574b8
	HT_RedirectPerm,
Packit f574b8
	HT_PermitRedir,
Packit f574b8
	HT_UseProxy
Packit f574b8
    } HTRuleOp;
Packit f574b8
Packit f574b8
#ifndef NO_RULES
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
Server Side Script Execution
Packit f574b8
Packit f574b8
   If a URL starts with /htbin/ it is understood to mean a script execution request on
Packit f574b8
   server.  This feature needs to be turned on by setting HTBinDir by the htbin rule.
Packit f574b8
   Index searching is enabled by setting HTSearchScript into the name of script in BinDir
Packit f574b8
   doing the actual search by search rule (BinDir must also be set in this case, of
Packit f574b8
   course).
Packit f574b8
Packit f574b8
 */
Packit f574b8
Packit f574b8
    extern char *HTBinDir;	/* Physical /htbin location */
Packit f574b8
    extern char *HTSearchScript;	/* Search script name */
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
HTAddRule:  Add rule to the list
Packit f574b8
Packit f574b8
  ON ENTRY,
Packit f574b8
Packit f574b8
  pattern                points to 0-terminated string containing a single "*"
Packit f574b8
Packit f574b8
  equiv                  points to the equivalent string with * for the place where the
Packit f574b8
                         text matched by * goes; or to other 2nd parameter
Packit f574b8
                         meaning depends on op).			 
Packit f574b8
Packit f574b8
  cond_op,               additional condition for applying rule; cond_op should
Packit f574b8
  cond                   be either NULL (no additional condition), or one of
Packit f574b8
                         the strings "if" or "unless"; if cond_op is not NULL,
Packit f574b8
                         cond should point to a recognized condition keyword
Packit f574b8
                         (as a string) such as "userspec", "redirected".
Packit f574b8
Packit f574b8
  ON EXIT,
Packit f574b8
Packit f574b8
  returns                0 if success, -1 if error.
Packit f574b8
Packit f574b8
   Note that if BYTE_ADDRESSING is set, the three blocks required are allocated and
Packit f574b8
   deallocated as one.  This will save time and storage, when malloc's allocation units are
Packit f574b8
   large.
Packit f574b8
Packit f574b8
 */
Packit f574b8
    extern int HTAddRule(HTRuleOp op, const char *pattern,
Packit f574b8
			 const char *equiv,
Packit f574b8
			 const char *cond_op,
Packit f574b8
			 const char *cond);
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
HTClearRules: Clear all rules
Packit f574b8
Packit f574b8
  ON EXIT,
Packit f574b8
Packit f574b8
  Rule file               There are no rules
Packit f574b8
Packit f574b8
 */
Packit f574b8
Packit f574b8
    extern void HTClearRules(void);
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
HTTranslate: Translate by rules
Packit f574b8
Packit f574b8
 */
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
  ON ENTRY,
Packit f574b8
Packit f574b8
  required                points to a string whose equivalent value is neeed
Packit f574b8
Packit f574b8
  ON EXIT,
Packit f574b8
Packit f574b8
  returns                 the address of the equivalent string allocated from the heap
Packit f574b8
                         which the CALLER MUST FREE. If no translation occurred, then it is
Packit f574b8
                         a copy of the original.
Packit f574b8
Packit f574b8
 */
Packit f574b8
    extern char *HTTranslate(const char *required);
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
HTSetConfiguration:  Load one line of configuration information
Packit f574b8
Packit f574b8
  ON ENTRY,
Packit f574b8
Packit f574b8
  config                  is a string in the syntax of a rule file line.
Packit f574b8
Packit f574b8
   This routine may be used for loading configuration information from sources other than
Packit f574b8
   the  rule file, for example INI files for X resources.
Packit f574b8
Packit f574b8
 */
Packit f574b8
    extern int HTSetConfiguration(char *config);
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
HtLoadRules:  Load the rules from a file
Packit f574b8
Packit f574b8
  ON ENTRY,
Packit f574b8
Packit f574b8
  Rule table              Rules can be in any state
Packit f574b8
Packit f574b8
  ON EXIT,
Packit f574b8
Packit f574b8
  Rule table              Any existing rules will have been kept.  Any new rules will have
Packit f574b8
                         been loaded on top, so as to be tried first.
Packit f574b8
Packit f574b8
  Returns                 0 if no error.
Packit f574b8
Packit f574b8
 */
Packit f574b8
Packit f574b8
    extern int HTLoadRules(const char *filename);
Packit f574b8
Packit f574b8
/*
Packit f574b8
Packit f574b8
 */
Packit f574b8
Packit f574b8
#endif				/* NO_RULES */
Packit f574b8
#ifdef __cplusplus
Packit f574b8
}
Packit f574b8
#endif
Packit f574b8
#endif				/* HTRULE_H */