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

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
        !            96: NAME="z4" HREF="HTFormat.html#z17">global list of converters</A>.
2.10      timbl      97: <PRE>struct _HTRequest {
2.11    ! timbl      98:        HTList *        <A
        !            99: NAME="z5">conversions</A>;     /* conversions allowed in this case */
2.9       timbl     100:        char *          from;           /* On behalf of whom? */
                    101:        HTStream*       output_stream;  /* For non-interactive, set this */ 
2.10      timbl     102:        HTAtom *        output_format;  /* To convert on load, set this */
2.9       timbl     103:        BOOL            (*callback) PARAMS((
                    104:                                struct _HTRequest* request,
                    105:                                void *param));
                    106:        void *          context;        /* caller data -- HTAccess unaware */
                    107: 
                    108:        HTParentAnchor* anchor;         /* Set by HTAccess */
                    109:        /* To be added: authentication, etc */
2.10      timbl     110: };
2.9       timbl     111: 
                    112: </PRE>The elements of the request structure
                    113: are as follows.
                    114: <DL>
                    115: <DT>conversions
2.10      timbl     116: <DD> NULL, or a list of conversions
2.9       timbl     117: which the format manager can do in
                    118: order to fulfill the request.  This
                    119: is set by the caller of HTAccess.
2.10      timbl     120: Typically points to a list set up
2.9       timbl     121: an initialisation time for example
                    122: by HTInit.
                    123: <DT>from
2.10      timbl     124: <DD> Email format adderss of person
2.9       timbl     125: responible for request
                    126: <DT>output_stream
2.10      timbl     127: <DD> NULL or if a specific
2.9       timbl     128: output stream is required, te stream.
                    129: <DT>output_format
2.10      timbl     130: <DD> The output format required,
2.9       timbl     131: or a generic format such as www/present
                    132: (present to user). 
                    133: <DT>anchor
2.10      timbl     134: <DD> The anchor for teh object
                    135: in question.  NOTE: Set by HTAcesss.
2.9       timbl     136: </DL>
                    137: Just to make things easier especially
                    138: for clients, here is a function to
                    139: return a new blank request:
                    140: <H2>Create blank request</H2>This request has defaults in -- in
                    141: most cases it will need some information
                    142: added before being passed to HTAccess,
                    143: but it will work as is for a simple
                    144: request.
                    145: <PRE>extern HTRequest * HTRequest_new NOPARAMS;
1.1       timbl     146: 
2.9       timbl     147: 
2.5       timbl     148: </PRE>
                    149: <H2>Flags which may be set to control
                    150: this module</H2>
                    151: <PRE>extern int HTDiag;                        /* Flag: load source as plain text */
1.1       timbl     152: extern char * HTClientHost;            /* Name or number of telnetting host */
                    153: extern FILE * logfile;                 /* File to output one-liners to */
2.7       timbl     154: extern BOOL HTSecure;                  /* Disable security holes? */
1.1       timbl     155: 
                    156: 
                    157: 
2.5       timbl     158: </PRE>
                    159: <H2>Load a document from relative name</H2>
                    160: <H3>On Entry,</H3>
                    161: <DL>
                    162: <DT>relative_name
2.6       timbl     163: <DD> The relative address
2.5       timbl     164: of the file to be accessed.
                    165: <DT>here
2.6       timbl     166: <DD> The anchor of the object being
2.5       timbl     167: searched
2.9       timbl     168: <DT>request->anchor
                    169: <DD> not filled in yet
2.5       timbl     170: </DL>
                    171: 
                    172: <H3>On Exit,</H3>
                    173: <DL>
                    174: <DT>returns    YES
2.6       timbl     175: <DD> Success in opening
2.5       timbl     176: file
                    177: <DT>NO
2.6       timbl     178: <DD> Failure 
2.5       timbl     179: </DL>
1.1       timbl     180: 
2.5       timbl     181: <PRE>extern  BOOL HTLoadRelative PARAMS((
1.1       timbl     182:                CONST char *            relative_name,
2.9       timbl     183:                HTParentAnchor *        here,
                    184:                HTRequest *             request));
1.1       timbl     185: 
                    186: 
2.5       timbl     187: </PRE>
                    188: <H2>Load a document from absolute name</H2>
                    189: <H3>On Entry,</H3>
                    190: <DL>
                    191: <DT>addr
2.6       timbl     192: <DD> The absolute address of the
                    193: document to be accessed.
2.5       timbl     194: <DT>filter
2.6       timbl     195: <DD> if YES, treat document as
                    196: HTML
2.9       timbl     197: <DT>request->anchor
                    198: <DD> not filled in yet
2.5       timbl     199: </DL>
1.1       timbl     200: 
2.5       timbl     201: <PRE>
                    202: </PRE>
                    203: <H3>On Exit,</H3>
                    204: <PRE>
                    205: </PRE>
                    206: <DL>
                    207: <DT>returns YES
2.6       timbl     208: <DD> Success in opening document
2.5       timbl     209: <DT>NO
2.6       timbl     210: <DD> Failure 
2.5       timbl     211: </DL>
1.1       timbl     212: 
2.9       timbl     213: <PRE>extern BOOL HTLoadAbsolute PARAMS((CONST char * addr,
                    214:                HTRequest *             request));
1.1       timbl     215: 
                    216: 
2.5       timbl     217: </PRE>
                    218: <H2>Load a document from absolute name
                    219: to a stream</H2>
                    220: <H3>On Entry,</H3>
                    221: <DL>
                    222: <DT>addr
2.6       timbl     223: <DD> The absolute address of the
                    224: document to be accessed.
2.5       timbl     225: <DT>filter
2.6       timbl     226: <DD> if YES, treat document as
                    227: HTML
2.9       timbl     228: <DT>request->anchor
                    229: <DD> not filled in yet
2.5       timbl     230: </DL>
                    231: 
                    232: <H3>On Exit,</H3>
                    233: <DL>
                    234: <DT>returns YES
2.6       timbl     235: <DD> Success in opening document
2.5       timbl     236: <DT>NO
2.6       timbl     237: <DD> Failure 
2.5       timbl     238: </DL>
                    239: Note: This is equivalent to HTLoadDocument
2.9       timbl     240: <PRE>extern BOOL HTLoadToStream PARAMS((
                    241:                CONST char *            addr,
                    242:                BOOL                    filter,
                    243:                HTRequest *             request));
1.1       timbl     244: 
                    245: 
2.5       timbl     246: </PRE>
                    247: <H2>Load if necessary, and select an
2.9       timbl     248: anchor</H2>The anchor parameter may be a child
                    249: anchor. The anchor in the request
                    250: is set to the parent anchor.
2.5       timbl     251: <H3>On Entry,</H3>
                    252: <DL>
2.9       timbl     253: <DT>anchor
                    254: <DD> may be a child or parenet
                    255: anchor or 0 in which case there is
                    256: no effect.
                    257: <DT>request->anchor      
                    258: <DD>    Not set
                    259: yet.
2.5       timbl     260: </DL>
                    261: 
                    262: <H3>On Exit,</H3>
                    263: <PRE>
                    264: </PRE>
                    265: <DL>
                    266: <DT>returns YES
2.6       timbl     267: <DD> Success
2.5       timbl     268: <DT>returns NO
2.6       timbl     269: <DD> Failure 
2.9       timbl     270: <DT>request->anchor
                    271: <DD> The parenet anchor.
2.5       timbl     272: </DL>
                    273: 
2.9       timbl     274: <PRE>extern BOOL HTLoadAnchor PARAMS((HTAnchor * a,
                    275:                        HTRequest *             request));
1.1       timbl     276: 
                    277: 
2.5       timbl     278: </PRE>
                    279: <H2>Make a stream for Saving object back</H2>
                    280: <H3>On Entry,</H3>
                    281: <DL>
2.9       timbl     282: <DT>request->anchor
                    283: <DD> is valid anchor which
                    284: has previously beeing loaded
2.5       timbl     285: </DL>
                    286: 
                    287: <H3>On exit,</H3>
                    288: <DL>
                    289: <DT>returns
2.6       timbl     290: <DD> 0 if error else a stream
                    291: to save the object to.
2.5       timbl     292: </DL>
                    293: 
                    294: <PRE>
                    295: 
2.9       timbl     296: extern HTStream * HTSaveStream PARAMS((HTParentAnchor* anchor,
                    297:                        HTRequest *             request));
1.1       timbl     298: 
                    299: 
2.5       timbl     300: </PRE>
                    301: <H2>Search</H2>Performs a search on word given by
                    302: the user. Adds the search words to
                    303: the end of the current address and
                    304: attempts to open the new address.
                    305: <H3>On Entry,</H3>
                    306: <DL>
                    307: <DT>*keywords
2.6       timbl     308: <DD> space-separated keyword
2.5       timbl     309: list or similar search list
                    310: <DT>here
2.6       timbl     311: <DD> The anchor of the object being
2.5       timbl     312: searched
                    313: </DL>
1.1       timbl     314: 
2.9       timbl     315: <PRE>extern BOOL HTSearch PARAMS((
                    316:                CONST char *            keywords,
                    317:                HTParentAnchor*         here,
                    318:                HTRequest *             request));
1.1       timbl     319: 
                    320: 
2.5       timbl     321: </PRE>
                    322: <H2>Search Given Indexname</H2>Performs a keyword search on word
                    323: given by the user. Adds the keyword
                    324: to  the end of the current address
                    325: and attempts to open the new address.
                    326: <H3>On Entry,</H3>
                    327: <DL>
                    328: <DT>*keywords
2.6       timbl     329: <DD> space-separated keyword
2.5       timbl     330: list or similar search list
                    331: <DT>*indexname
2.6       timbl     332: <DD> is name of object search
2.5       timbl     333: is to be done on.
                    334: </DL>
1.1       timbl     335: 
2.5       timbl     336: <PRE>extern BOOL HTSearchAbsolute PARAMS((
2.9       timbl     337:        CONST char *            keywords,
                    338:        CONST char *            indexname,
                    339:        HTRequest *             request));
1.1       timbl     340: 
                    341: 
2.5       timbl     342: </PRE>
2.9       timbl     343: <H2>Register an access method</H2>An access method is defined by an
                    344: HTProtocol structure which point
                    345: to the routines for performing the
                    346: various logical operations on an
                    347: object: in HTTP terms,  GET, PUT,
                    348: and POST.<P>
                    349: Each of these routine takes as a
                    350: parameter a <A
                    351: NAME="z2" HREF="#z1">request structure</A> containing
                    352: details ofthe request.  When the
                    353: protocol class routine is called,
                    354: the anchor elemnt in the request
                    355: is already valid (made valid by HTAccess).
                    356: <PRE>typedef struct _HTProtocol {
1.1       timbl     357:        char * name;
                    358:        
2.11    ! timbl     359:        int (*load)PARAMS((HTRequest *  request));
1.1       timbl     360:                
2.11    ! timbl     361:        HTStream* (*saveStream)PARAMS((HTRequest *      request));
        !           362: 
2.9       timbl     363:        HTStream* (*postStream)PARAMS((
                    364:                                HTRequest *     request,
                    365:                                HTParentAnchor* postTo));
1.1       timbl     366: 
                    367: } HTProtocol;
                    368: 
                    369: extern BOOL HTRegisterProtocol PARAMS((HTProtocol * protocol));
                    370: 
                    371: 
2.5       timbl     372: </PRE>
                    373: <H2>Generate the anchor for the home
                    374: page</H2>
                    375: <PRE>
                    376: </PRE>As it involves file access, this
                    377: should only be done once when the
                    378: program first runs. This is a default
                    379: algorithm -- browser don't HAVE to
                    380: use this.
                    381: <PRE>extern HTParentAnchor * HTHomeAnchor NOPARAMS;
1.1       timbl     382: 
                    383: #endif /* HTACCESS_H */
2.11    ! timbl     384: 
        !           385: </PRE>end of HTAccess</A></BODY>
2.9       timbl     386: </HTML>

Webmaster