Annotation of libwww/Library/src/HTAccess.html, revision 2.12

2.9       timbl       1: <HTML>
                      2: <HEAD>
2.6       timbl       3: <TITLE>HTAccess:  Access manager  for libwww</TITLE>
2.11      timbl       4: <NEXTID N="z6">
2.9       timbl       5: </HEAD>
2.5       timbl       6: <BODY>
                      7: <H1>Access Manager</H1>This module keeps a list of valid
                      8: protocol (naming scheme) specifiers
                      9: with associated access code.  It
                     10: allows documents to be loaded given
                     11: various combinations of parameters.
                     12: New access protocols may be registered
                     13: at any time.<P>
2.9       timbl      14: Note: HTRequest defined and request
                     15: parametsr added to almost all calls
                     16: 18 Nov 1993.<P>
2.5       timbl      17: Part of the <A
2.9       timbl      18: NAME="z0" HREF="Overview.html">libwww library</A> .
2.5       timbl      19: <PRE>#ifndef HTACCESS_H
1.1       timbl      20: #define HTACCESS_H
                     21: 
                     22: /*     Definition uses:
                     23: */
                     24: #include "HTUtils.h"
                     25: #include "tcp.h"
                     26: 
                     27: #ifdef SHORT_NAMES
2.8       timbl      28: #define HTClientHost           HTClHost
                     29: #define HTSearchAbsolute       HTSeAbso
                     30: #define HTOutputStream         HTOuStre
                     31: #define HTOutputFormat         HTOuForm
1.1       timbl      32: #endif
                     33: 
2.10      timbl      34: </PRE>The following have to be defined
                     35: in advance of the other include files
                     36: because of circular references.
                     37: <PRE>typedef struct _HTRequest HTRequest;
                     38: 
                     39: #include "HTAnchor.h"
                     40: #include <A
                     41: NAME="z3" HREF="HTFormat.html">"HTFormat.h"</A>
                     42: 
                     43: 
1.1       timbl      44: /*     Return codes from load routines:
                     45: **
                     46: **     These codes may be returned by the protocol modules,
                     47: **     and by the HTLoad routines.
                     48: **     In general, positive codes are OK and negative ones are bad.
                     49: */
                     50: 
                     51: #define HT_NO_DATA -9999       /* return code: OK but no data was loaded */
                     52:                                /* Typically, other app started or forked */
                     53: 
2.5       timbl      54: </PRE>
2.6       timbl      55: <H2>Default Addresses</H2>These control the home page selection.
2.8       timbl      56: To mess with these for normal browses
2.6       timbl      57: is asking for user confusion.
                     58: <PRE>#define LOGICAL_DEFAULT "WWW_HOME"  /* Defined to be the home page */
1.1       timbl      59: 
2.6       timbl      60: #ifndef PERSONAL_DEFAULT
                     61: #define PERSONAL_DEFAULT "WWW/default.html"    /* in home directory */
                     62: #endif
                     63: #ifndef LOCAL_DEFAULT_FILE
1.1       timbl      64: #define LOCAL_DEFAULT_FILE "/usr/local/lib/WWW/default.html"
2.6       timbl      65: #endif
2.7       timbl      66: /*  If one telnets to a www access point,
                     67:     it will look in this file for home page */
                     68: #ifndef REMOTE_POINTER
                     69: #define REMOTE_POINTER  "/etc/www-remote.url"  /* can't be file */
                     70: #endif
                     71: /* and if that fails it will use this. */
2.6       timbl      72: #ifndef REMOTE_ADDRESS
1.1       timbl      73: #define REMOTE_ADDRESS  "http://info.cern.ch/remote.html"  /* can't be file */
                     74: #endif
                     75: 
                     76: /* If run from telnet daemon and no -l specified, use this file:
                     77: */
                     78: #ifndef DEFAULT_LOGFILE
                     79: #define DEFAULT_LOGFILE        "/usr/adm/www-log/www-log"
                     80: #endif
                     81: 
                     82: /*     If the home page isn't found, use this file:
                     83: */
                     84: #ifndef LAST_RESORT
2.6       timbl      85: #define LAST_RESORT    "http://info.cern.ch/default.html"
1.1       timbl      86: #endif
                     87: 
2.10      timbl      88: 
2.9       timbl      89: </PRE>
                     90: <H2><A
                     91: NAME="z1">The Request structure</A></H2>When a request is handled, all kinds
                     92: of things about it need to be passed
                     93: along.  These are all put into a
2.11      timbl      94: HTRequest structure.  Note there
                     95: is also a <A
2.12    ! timbl      96: NAME="z4" HREF="HTFormat.html#z17">global list of converters</A>
        !            97: .
2.10      timbl      98: <PRE>struct _HTRequest {
2.11      timbl      99:        HTList *        <A
2.12    ! timbl     100: NAME="z5">conversions</A> ;    /* conversions allowed in this case */
2.9       timbl     101:        char *          from;           /* On behalf of whom? */
                    102:        HTStream*       output_stream;  /* For non-interactive, set this */ 
2.10      timbl     103:        HTAtom *        output_format;  /* To convert on load, set this */
2.9       timbl     104:        BOOL            (*callback) PARAMS((
                    105:                                struct _HTRequest* request,
                    106:                                void *param));
                    107:        void *          context;        /* caller data -- HTAccess unaware */
                    108: 
                    109:        HTParentAnchor* anchor;         /* Set by HTAccess */
2.12    ! timbl     110: 
        !           111:        void *          using_cache;    /* pointer to cache element if cache hit */
        !           112: 
2.9       timbl     113:        /* To be added: authentication, etc */
2.10      timbl     114: };
2.9       timbl     115: 
                    116: </PRE>The elements of the request structure
                    117: are as follows.
                    118: <DL>
                    119: <DT>conversions
2.10      timbl     120: <DD> NULL, or a list of conversions
2.9       timbl     121: which the format manager can do in
                    122: order to fulfill the request.  This
                    123: is set by the caller of HTAccess.
2.10      timbl     124: Typically points to a list set up
2.9       timbl     125: an initialisation time for example
                    126: by HTInit.
                    127: <DT>from
2.10      timbl     128: <DD> Email format adderss of person
2.9       timbl     129: responible for request
                    130: <DT>output_stream
2.10      timbl     131: <DD> NULL or if a specific
2.9       timbl     132: output stream is required, te stream.
                    133: <DT>output_format
2.10      timbl     134: <DD> The output format required,
2.9       timbl     135: or a generic format such as www/present
                    136: (present to user). 
                    137: <DT>anchor
2.10      timbl     138: <DD> The anchor for teh object
                    139: in question.  NOTE: Set by HTAcesss.
2.9       timbl     140: </DL>
                    141: Just to make things easier especially
                    142: for clients, here is a function to
                    143: return a new blank request:
                    144: <H2>Create blank request</H2>This request has defaults in -- in
                    145: most cases it will need some information
                    146: added before being passed to HTAccess,
                    147: but it will work as is for a simple
                    148: request.
                    149: <PRE>extern HTRequest * HTRequest_new NOPARAMS;
1.1       timbl     150: 
2.9       timbl     151: 
2.5       timbl     152: </PRE>
                    153: <H2>Flags which may be set to control
                    154: this module</H2>
                    155: <PRE>extern int HTDiag;                        /* Flag: load source as plain text */
1.1       timbl     156: extern char * HTClientHost;            /* Name or number of telnetting host */
                    157: extern FILE * logfile;                 /* File to output one-liners to */
2.7       timbl     158: extern BOOL HTSecure;                  /* Disable security holes? */
1.1       timbl     159: 
                    160: 
                    161: 
2.5       timbl     162: </PRE>
                    163: <H2>Load a document from relative name</H2>
                    164: <H3>On Entry,</H3>
                    165: <DL>
                    166: <DT>relative_name
2.6       timbl     167: <DD> The relative address
2.5       timbl     168: of the file to be accessed.
                    169: <DT>here
2.6       timbl     170: <DD> The anchor of the object being
2.5       timbl     171: searched
2.9       timbl     172: <DT>request->anchor
                    173: <DD> not filled in yet
2.5       timbl     174: </DL>
                    175: 
                    176: <H3>On Exit,</H3>
                    177: <DL>
                    178: <DT>returns    YES
2.6       timbl     179: <DD> Success in opening
2.5       timbl     180: file
                    181: <DT>NO
2.6       timbl     182: <DD> Failure 
2.5       timbl     183: </DL>
1.1       timbl     184: 
2.5       timbl     185: <PRE>extern  BOOL HTLoadRelative PARAMS((
1.1       timbl     186:                CONST char *            relative_name,
2.9       timbl     187:                HTParentAnchor *        here,
                    188:                HTRequest *             request));
1.1       timbl     189: 
                    190: 
2.5       timbl     191: </PRE>
                    192: <H2>Load a document from absolute name</H2>
                    193: <H3>On Entry,</H3>
                    194: <DL>
                    195: <DT>addr
2.6       timbl     196: <DD> The absolute address of the
                    197: document to be accessed.
2.5       timbl     198: <DT>filter
2.6       timbl     199: <DD> if YES, treat document as
                    200: HTML
2.9       timbl     201: <DT>request->anchor
                    202: <DD> not filled in yet
2.5       timbl     203: </DL>
1.1       timbl     204: 
2.5       timbl     205: <PRE>
                    206: </PRE>
                    207: <H3>On Exit,</H3>
                    208: <PRE>
                    209: </PRE>
                    210: <DL>
                    211: <DT>returns YES
2.6       timbl     212: <DD> Success in opening document
2.5       timbl     213: <DT>NO
2.6       timbl     214: <DD> Failure 
2.5       timbl     215: </DL>
1.1       timbl     216: 
2.9       timbl     217: <PRE>extern BOOL HTLoadAbsolute PARAMS((CONST char * addr,
                    218:                HTRequest *             request));
1.1       timbl     219: 
                    220: 
2.5       timbl     221: </PRE>
                    222: <H2>Load a document from absolute name
                    223: to a stream</H2>
                    224: <H3>On Entry,</H3>
                    225: <DL>
                    226: <DT>addr
2.6       timbl     227: <DD> The absolute address of the
                    228: document to be accessed.
2.5       timbl     229: <DT>filter
2.6       timbl     230: <DD> if YES, treat document as
                    231: HTML
2.9       timbl     232: <DT>request->anchor
                    233: <DD> not filled in yet
2.5       timbl     234: </DL>
                    235: 
                    236: <H3>On Exit,</H3>
                    237: <DL>
                    238: <DT>returns YES
2.6       timbl     239: <DD> Success in opening document
2.5       timbl     240: <DT>NO
2.6       timbl     241: <DD> Failure 
2.5       timbl     242: </DL>
                    243: Note: This is equivalent to HTLoadDocument
2.9       timbl     244: <PRE>extern BOOL HTLoadToStream PARAMS((
                    245:                CONST char *            addr,
                    246:                BOOL                    filter,
                    247:                HTRequest *             request));
1.1       timbl     248: 
                    249: 
2.5       timbl     250: </PRE>
                    251: <H2>Load if necessary, and select an
2.9       timbl     252: anchor</H2>The anchor parameter may be a child
                    253: anchor. The anchor in the request
                    254: is set to the parent anchor.
2.5       timbl     255: <H3>On Entry,</H3>
                    256: <DL>
2.9       timbl     257: <DT>anchor
                    258: <DD> may be a child or parenet
                    259: anchor or 0 in which case there is
                    260: no effect.
                    261: <DT>request->anchor      
                    262: <DD>    Not set
                    263: yet.
2.5       timbl     264: </DL>
                    265: 
                    266: <H3>On Exit,</H3>
                    267: <PRE>
                    268: </PRE>
                    269: <DL>
                    270: <DT>returns YES
2.6       timbl     271: <DD> Success
2.5       timbl     272: <DT>returns NO
2.6       timbl     273: <DD> Failure 
2.9       timbl     274: <DT>request->anchor
                    275: <DD> The parenet anchor.
2.5       timbl     276: </DL>
                    277: 
2.9       timbl     278: <PRE>extern BOOL HTLoadAnchor PARAMS((HTAnchor * a,
                    279:                        HTRequest *             request));
1.1       timbl     280: 
                    281: 
2.5       timbl     282: </PRE>
                    283: <H2>Make a stream for Saving object back</H2>
                    284: <H3>On Entry,</H3>
                    285: <DL>
2.9       timbl     286: <DT>request->anchor
                    287: <DD> is valid anchor which
                    288: has previously beeing loaded
2.5       timbl     289: </DL>
                    290: 
                    291: <H3>On exit,</H3>
                    292: <DL>
                    293: <DT>returns
2.6       timbl     294: <DD> 0 if error else a stream
                    295: to save the object to.
2.5       timbl     296: </DL>
                    297: 
                    298: <PRE>
                    299: 
2.9       timbl     300: extern HTStream * HTSaveStream PARAMS((HTParentAnchor* anchor,
                    301:                        HTRequest *             request));
1.1       timbl     302: 
                    303: 
2.5       timbl     304: </PRE>
                    305: <H2>Search</H2>Performs a search on word given by
                    306: the user. Adds the search words to
                    307: the end of the current address and
                    308: attempts to open the new address.
                    309: <H3>On Entry,</H3>
                    310: <DL>
                    311: <DT>*keywords
2.6       timbl     312: <DD> space-separated keyword
2.5       timbl     313: list or similar search list
                    314: <DT>here
2.6       timbl     315: <DD> The anchor of the object being
2.5       timbl     316: searched
                    317: </DL>
1.1       timbl     318: 
2.9       timbl     319: <PRE>extern BOOL HTSearch PARAMS((
                    320:                CONST char *            keywords,
                    321:                HTParentAnchor*         here,
                    322:                HTRequest *             request));
1.1       timbl     323: 
                    324: 
2.5       timbl     325: </PRE>
                    326: <H2>Search Given Indexname</H2>Performs a keyword search on word
                    327: given by the user. Adds the keyword
                    328: to  the end of the current address
                    329: and attempts to open the new address.
                    330: <H3>On Entry,</H3>
                    331: <DL>
                    332: <DT>*keywords
2.6       timbl     333: <DD> space-separated keyword
2.5       timbl     334: list or similar search list
                    335: <DT>*indexname
2.6       timbl     336: <DD> is name of object search
2.5       timbl     337: is to be done on.
                    338: </DL>
1.1       timbl     339: 
2.5       timbl     340: <PRE>extern BOOL HTSearchAbsolute PARAMS((
2.9       timbl     341:        CONST char *            keywords,
                    342:        CONST char *            indexname,
                    343:        HTRequest *             request));
1.1       timbl     344: 
                    345: 
2.5       timbl     346: </PRE>
2.9       timbl     347: <H2>Register an access method</H2>An access method is defined by an
                    348: HTProtocol structure which point
                    349: to the routines for performing the
                    350: various logical operations on an
                    351: object: in HTTP terms,  GET, PUT,
                    352: and POST.<P>
                    353: Each of these routine takes as a
                    354: parameter a <A
                    355: NAME="z2" HREF="#z1">request structure</A> containing
                    356: details ofthe request.  When the
                    357: protocol class routine is called,
                    358: the anchor elemnt in the request
                    359: is already valid (made valid by HTAccess).
                    360: <PRE>typedef struct _HTProtocol {
1.1       timbl     361:        char * name;
                    362:        
2.11      timbl     363:        int (*load)PARAMS((HTRequest *  request));
1.1       timbl     364:                
2.11      timbl     365:        HTStream* (*saveStream)PARAMS((HTRequest *      request));
                    366: 
2.9       timbl     367:        HTStream* (*postStream)PARAMS((
                    368:                                HTRequest *     request,
                    369:                                HTParentAnchor* postTo));
1.1       timbl     370: 
                    371: } HTProtocol;
                    372: 
                    373: extern BOOL HTRegisterProtocol PARAMS((HTProtocol * protocol));
                    374: 
                    375: 
2.5       timbl     376: </PRE>
                    377: <H2>Generate the anchor for the home
                    378: page</H2>
                    379: <PRE>
                    380: </PRE>As it involves file access, this
                    381: should only be done once when the
                    382: program first runs. This is a default
                    383: algorithm -- browser don't HAVE to
                    384: use this.
                    385: <PRE>extern HTParentAnchor * HTHomeAnchor NOPARAMS;
1.1       timbl     386: 
                    387: #endif /* HTACCESS_H */
2.11      timbl     388: 
2.12    ! timbl     389: </PRE>end of HTAccess</BODY>
2.9       timbl     390: </HTML>

Webmaster