File:  [Public] / libwww / Library / src / HTRules.html
Revision 2.28: download - view: text, annotated - select for diffs
Thu Nov 16 18:23:53 1995 UTC (28 years, 6 months ago) by frystyk
Branches: MAIN
CVS tags: v4/0pre6, v4/0D, v4/0C, v4/0B, v4/0, autoconf, HEAD
pre and post callback

<HTML>
<HEAD>
<TITLE>Configuration Manager</TITLE>
<!-- Changed by: Henrik Frystyk Nielsen, 15-Nov-1995 -->
</HEAD>
<BODY>

<H1>Configuration File Manager</H1>

<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>

The W3C Library provides this module for handling configuration files
(a.k.a.  rule files). Rule files can be used to initialize as much as
the application desires including setting up new protocol modules
etc. Also the rules file do not have to be a fil - it can be a
database or any other way of storage information. This implementation
is not used by the Library at all and is part of the <A
HREF="WWWApp.html">WWWApp.h</A> interface. <P>

This module is implemented by <A HREF="HTRules.c">HTRules.c</A>, and
it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C
Reference Library</A>.

<PRE>
#ifndef HTRULE_H
#define HTRULE_H

#include "HTList.h"
#include "HTReq.h"
#include "HTFormat.h"
</PRE>

<H2>Parse a Whole Rule File</H2>

Parsing a whole rule file is done using a converter stream. This means
that a rule file can come from anywhere, even accross the network. We
have defined a special content type for rule files called
<CODE>WWW_RULES</CODE> in <A HREF="HTFormat.html">HTFormat</A>.

<PRE>
extern HTConverter HTRules;
</PRE>

<H2>Parse a single line from a Rules File</H2>

This routine may be used for loading configuration information from
sources other than the rule file, for example INI files for X
resources. <CODE>config</CODE> is a string in the syntax of a rule
file line.

<PRE>
extern BOOL HTRule_parseLine (HTList * list, CONST char * config);
</PRE>

<H2>Add a Rule to the List</H2>

This function adds a rule to the list of rules. The
<CODE>pattern</CODE> is a 0-terminated string containing a single
"*". <CODE>equiv</CODE> points to the equivalent string with * for the
place where the text matched by * goes.

<PRE>
typedef struct _HTRule HTRule;

typedef enum _HTRuleOp {
    HT_Invalid, 
    HT_Map, 
    HT_Pass, 
    HT_Fail,
    HT_DefProt,
    HT_Protect,
    HT_Exec,
    HT_Redirect,
    HT_UseProxy
} HTRuleOp;

extern BOOL HTRule_add (HTList * list, HTRuleOp op,
			CONST char * pattern, CONST char * replace);
</PRE>

<H2>Delete all Registered Rules</H2>

This function clears all rules registered

<PRE>
extern BOOL HTRule_deleteAll (HTList *list);
</PRE>

<H2>Global Rules</H2>

Rules are handled as list as everything else that has to do with
preferences. We provide two functions for getting and setting the
global rules:

<PRE>
extern HTList * HTRule_global	(void);
extern BOOL HTRule_setGlobal	(HTList * list);
</PRE>

<H2>Translate by rules</H2>

This function walks through the list of rules and translates the
reference when matches are found. The list is traversed in order
starting from the head of the list. It returns the address of the
equivalent string allocated from the heap which the CALLER MUST
FREE. If no translation occured, then it is a copy of the original.

<PRE>
extern char * HTRule_translate (HTList * list, CONST char * token,
				BOOL ignore_case);
</PRE>

<PRE>
#endif
</PRE>

End of declaration
</BODY>
</HTMl>

Webmaster