HTRules.h
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:3k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. /*                                                                      Configuration Manager
  2.                                 CONFIGURATION FILE MANAGER
  3.                                              
  4.  */
  5. /*
  6. **      (c) COPYRIGHT MIT 1995.
  7. **      Please first read the full copyright statement in the file COPYRIGH.
  8. */
  9. /*
  10.    The W3C Library provides this module for handling configuration files (a.k.a.  rule
  11.    files). Rule files can be used to initialize as much as the application desires
  12.    including setting up new protocol modules etc. Also the rules file do not have to be a
  13.    fil - it can be a database or any other way of storage information. This implementation
  14.    is not used by the Library at all and is part of the WWWApp.h interface.
  15.    
  16.    This module is implemented by HTRules.c, and it is a part of the  W3C Reference
  17.    Library.
  18.    
  19.  */
  20. #ifndef HTRULE_H
  21. #define HTRULE_H
  22. #include "HTList.h"
  23. #include "HTReq.h"
  24. #include "HTFormat.h"
  25. /*
  26. Parse a Whole Rule File
  27.    Parsing a whole rule file is done using a converter stream. This means that a rule file
  28.    can come from anywhere, even accross the network. We have defined a special content
  29.    type for rule files called WWW_RULES in HTFormat.
  30.    
  31.  */
  32. extern HTConverter HTRules;
  33. /*
  34. Parse a single line from a Rules File
  35.    This routine may be used for loading configuration information from sources other than
  36.    the rule file, for example INI files for X resources. config is a string in the syntax
  37.    of a rule file line.
  38.    
  39.  */
  40. extern BOOL HTRule_parseLine (HTList * list, CONST char * config);
  41. /*
  42. Add a Rule to the List
  43.    This function adds a rule to the list of rules. The pattern is a 0-terminated string
  44.    containing a single "*". equiv points to the equivalent string with * for the place
  45.    where the text matched by * goes.
  46.    
  47.  */
  48. typedef struct _HTRule HTRule;
  49. typedef enum _HTRuleOp {
  50.     HT_Invalid,
  51.     HT_Map,
  52.     HT_Pass,
  53.     HT_Fail,
  54.     HT_DefProt,
  55.     HT_Protect,
  56.     HT_Exec,
  57.     HT_Redirect,
  58.     HT_UseProxy
  59. } HTRuleOp;
  60. extern BOOL HTRule_add (HTList * list, HTRuleOp op,
  61.                         CONST char * pattern, CONST char * replace);
  62. /*
  63. Delete all Registered Rules
  64.    This function clears all rules registered
  65.    
  66.  */
  67. extern BOOL HTRule_deleteAll (HTList *list);
  68. /*
  69. Global Rules
  70.    Rules are handled as list as everything else that has to do with preferences. We
  71.    provide two functions for getting and setting the global rules:
  72.    
  73.  */
  74. extern HTList * HTRule_global   (void);
  75. extern BOOL HTRule_setGlobal    (HTList * list);
  76. /*
  77. Translate by rules
  78.    This function walks through the list of rules and translates the reference when matches
  79.    are found. The list is traversed in order starting from the head of the list. It
  80.    returns the address of the equivalent string allocated from the heap which the CALLER
  81.    MUST FREE. If no translation occured, then it is a copy of the original.
  82.    
  83.  */
  84. extern char * HTRule_translate (HTList * list, CONST char * token,
  85.                                 BOOL ignore_case);
  86. /*
  87.  */
  88. #endif
  89. /*
  90.    End of declaration */