[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev 2.8.2dev.14 patch 2 - rules
From: |
Klaus Weide |
Subject: |
lynx-dev 2.8.2dev.14 patch 2 - rules |
Date: |
Sat, 23 Jan 1999 09:29:42 -0600 (CST) |
As most of you will not be aware, lynx had support for applying
"rules" to URLs before they are accessed. The code was always there
(or at least since I have been looking at Lynx code, and probably
since lynx went CERN-lib), and compiled in. There was just no way
to actually specify rules.
A more reasonable person might have said "let's throw it out",
instead I said "let's see what it can do".
As you can see below the changes are minimal. Unfortunately
there is no sample rules file or further explanation, beyond
a few examples I added to lynx.cfg. Eventually I may write
a sample file (or someone else might. :) The syntax will be
familiar to those familar with the CERN httpd, it's basically
the same old code, "Fail", "Pass", and "Map" should work
(always use full URLs), some other rules may be recognized
but I don't know yet what they do. (So pretend only those
three are implemented, unles you feel in an experimental mood.)
Check it out. But don't rely on it for restricting access for
others.
Klaus
* Enabled CERN-style rules, there are two new lynx.cfg options,
RULESFILE and RULE. No example file or documentation yet
beyond comments in lynx.cfg. The rules mechanism itself is
unchanged from what was present for a long time (but never used),
except for some memory cleanup. Use -DNO_RULES at compile time
to disable.
*** lynx2-8-2.old/lynx.cfg Mon Jan 18 06:29:20 1999
--- lynx2-8-2/lynx.cfg Sat Jan 23 08:55:05 1999
***************
*** 1865,1867 ****
--- 1865,1885 ----
#
# EXTERNAL:ftp:wget %s &:TRUE
+ # CERN-style rules, *EXPERIMENTAL* - URL-specific rules
+ #
+ # A CERN-style rules file can be given with RULESFILE. Use the system's
+ # native format for filenames, on Unix '~' is also recognized. If a filename
+ # is given, the file must exist.
+ #
+ # Single CERN-style rules can be specified with RULES.
+ #
+ # Both options can be repeated, rules accumulate in the order
+ # given, they will be applied in first-to-last order.
+ #
+ # Examples:
+ # RULESFILE:/etc/lynx/cernrules
+ # RULE:Fail file://localhost/etc/passwd* # Don't rely on it!
+ # RULE:Fail gopher:* # reject by scheme
+ # RULE:Pass finger://address@hidden/ # allow this,
+ # RULE:Fail finger:* # but not others
+ # RULE:Map http://old.server/* http://new.server/*
*** lynx2-8-2.old/src/LYReadCFG.c Wed Jan 13 05:37:34 1999
--- lynx2-8-2/src/LYReadCFG.c Sat Jan 23 07:54:30 1999
***************
*** 1,4 ****
--- 1,8 ----
+ #ifndef NO_RULES
+ #include <HTRules.h>
+ #else
#include <HTUtils.h>
+ #endif
#include <HTFile.h>
#include <UCMap.h>
***************
*** 708,713 ****
--- 712,752 ----
return 0;
}
+ #ifndef NO_RULES
+ static int cern_rulesfile_fun ARGS1(
+ char *, value)
+ {
+ char *rulesfile1 = NULL;
+ char *rulesfile2 = NULL;
+ if (HTLoadRules(value) >= 0) {
+ return 0;
+ }
+ StrAllocCopy(rulesfile1, value);
+ LYTrimLeading(value);
+ LYTrimTrailing(value);
+ if (!strncmp(value, "~/", 2)) {
+ StrAllocCopy(rulesfile2, Home_Dir());
+ StrAllocCat(rulesfile2, value+1);
+ }
+ else {
+ StrAllocCopy(rulesfile2, value);
+ }
+ if (strcmp(rulesfile1, rulesfile2) &&
+ HTLoadRules(rulesfile2) >= 0) {
+ FREE(rulesfile1);
+ FREE(rulesfile2);
+ return 0;
+ }
+ fprintf(stderr,
+ gettext(
+ "Lynx: cannot start, CERN rules file %s is not available\n"
+ ),
+ (rulesfile2 && *rulesfile2) ? rulesfile2 : gettext("(no name)"));
+ exit_immediately(69); /* EX_UNAVAILABLE in sysexits.h */
+ return 0; /* though redundant, for compiler-warnings */
+ }
+ #endif /* NO_RULES */
+
static int printer_fun ARGS1(
char *, value)
{
***************
*** 929,934 ****
--- 968,977 ----
PARSE_SET("prepend_charset_to_source", CONF_BOOL,
LYPrependCharsetToSource),
PARSE_FUN("printer", CONF_FUN, printer_fun),
PARSE_SET("quit_default_yes", CONF_BOOL, LYQuitDefaultYes),
+ #ifndef NO_RULES
+ PARSE_STR("rule", CONF_FUN, HTSetConfiguration),
+ PARSE_STR("rulesfile", CONF_FUN, cern_rulesfile_fun),
+ #endif /* NO_RULES */
PARSE_STR("save_space", CONF_STR, lynx_save_space),
PARSE_SET("scan_for_buried_news_refs", CONF_BOOL,
scan_for_buried_news_references),
PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, LYSeekFragAREAinCur),
*** lynx2-8-2.old/WWW/Library/Implementation/HTRules.c Thu Dec 24 05:27:22 1998
--- lynx2-8-2/WWW/Library/Implementation/HTRules.c Sun Jan 17 07:40:18 1999
***************
*** 100,105 ****
--- 100,108 ----
CTRACE(tfp, "Rule: For `%s' op %d\n", pattern, op);
}
+ if (!rules) {
+ atexit(HTClearRules);
+ }
#ifdef PUT_ON_HEAD
temp->next = rules;
rules = temp;
***************
*** 120,131 ****
**
** On exit,
** There are no rules
- ** returns 0 if success, -1 if error.
**
** See also
** HTAddRule()
*/
! int HTClearRules NOARGS
{
while (rules) {
rule * temp = rules;
--- 123,133 ----
**
** On exit,
** There are no rules
**
** See also
** HTAddRule()
*/
! void HTClearRules NOARGS
{
while (rules) {
rule * temp = rules;
***************
*** 137,144 ****
#ifndef PUT_ON_HEAD
rule_tail = 0;
#endif
-
- return 0;
}
--- 139,144 ----
***************
*** 271,276 ****
--- 271,277 ----
case HT_Fail: /* Unauthorised */
CTRACE(tfp, "HTRule: *** FAIL `%s'\n",
current);
+ FREE(current);
return (char *)0;
} /* if tail matches ... switch operation */
*** lynx2-8-2.old/WWW/Library/Implementation/HTRules.h Sat Dec 12 22:10:36 1998
--- lynx2-8-2/WWW/Library/Implementation/HTRules.h Sun Jan 17 07:40:16 1999
***************
*** 79,90 ****
Rule file There are no rules
- returns
- 0 if success, -1 if error.
-
*/
! extern int HTClearRules PARAMS((void));
/*
--- 79,87 ----
Rule file There are no rules
*/
! extern void HTClearRules PARAMS((void));
/*
- lynx-dev 2.8.2dev.14 patch 2 - rules,
Klaus Weide <=