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

2.9       timbl       1: <HTML>
                      2: <HEAD>
2.45      frystyk     3: <TITLE>Access manager  for libwww</TITLE>
2.55      frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  7-Jul-1995 -->
2.19      timbl       5: <NEXTID N="z11">
2.9       timbl       6: </HEAD>
2.5       timbl       7: <BODY>
2.39      frystyk     8: 
2.33      frystyk     9: <H1>Access Manager</H1>
2.39      frystyk    10: 
2.41      frystyk    11: <PRE>
                     12: /*
2.50      frystyk    13: **     (c) COPYRIGHT MIT 1995.
2.41      frystyk    14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
                     17: 
2.39      frystyk    18: This module keeps a list of valid protocol (naming scheme) specifiers
                     19: with associated access code.  It allows documents to be loaded given
                     20: various combinations of parameters.  New access protocols may be
                     21: registered at any time.<P>
                     22: 
                     23: This module is implemented by <A HREF="HTAccess.c">HTAccess.c</A>, and
                     24: it is a part of the <A NAME="z10"
2.56    ! frystyk    25: HREF="http://www.w3.org/hypertext/WWW/Library/">
        !            26: W3C Reference Library</A>. <P>
2.39      frystyk    27: 
                     28: The module contains a lot of stuff but the main topics are:
                     29: 
                     30: <UL>
2.41      frystyk    31: <LI><A HREF="#Library">Initializing and Terminating the Library</A>
2.52      frystyk    32: <LI><A HREF="#Addresses">Default Directories and URLs</A> 
                     33: <LI><A HREF="#flags">Global Flags</A><P>
                     34: 
                     35: <LI><A HREF="#z100">Management of the HTRequest Object</A>
2.55      frystyk    36: <LI><A HREF="#headers">Handling HTTP headers</A><P>
2.52      frystyk    37: 
2.39      frystyk    38: <LI><A HREF="#LoadDoc">Functions for loading a document</A>
                     39: <LI><A HREF="#ClientHelp">Help functions for clients to get started</A>
2.52      frystyk    40: <LI><A HREF="#PostDoc">Functions for posting a document</A> <P>
                     41: 
                     42: <LI><A HREF="#Int">Internal Data Structures</A>
2.39      frystyk    43: </UL>
                     44: 
2.33      frystyk    45: 
                     46: <PRE>
                     47: #ifndef HTACCESS_H
1.1       timbl      48: #define HTACCESS_H
2.44      roeber     49: 
2.52      frystyk    50: #include "<A HREF="HTList.html">HTList.h</A>"
                     51: #include "<A HREF="HTChunk.html">HTChunk.h</A>"
                     52: #include "<A HREF="HTAnchor.html">HTAnchor.h</A>"
                     53: #include "<A HREF="HTStream.html">HTStream.h</A>"
                     54: #include "<A HREF="HTAssoc.html">HTAssoc.h</A>"
2.54      frystyk    55: #include "<A HREF="HTMethod.html">HTMethod.h</A>"
2.52      frystyk    56: </PRE>
                     57: 
                     58: <A NAME="Library"><H2>Initializing and Terminating the Library</H2></A>
                     59: 
                     60: <IMG SRC="http://www.w3.org/hypertext/WWW/Icons/32x32/warning.gif">
                     61: These two functions initiates memory and settings for the Library and
                     62: cleans up memory kept by the Library when about to exit the
                     63: application. It is highly recommended that they are used!
                     64: 
                     65: <PRE>
                     66: extern BOOL HTLibInit NOPARAMS;
                     67: extern BOOL HTLibTerminate NOPARAMS;
                     68: </PRE>
                     69: 
                     70: <A NAME="Addresses"><H2>Default WWW Addresses</H2></A>
                     71: 
                     72: These control the home page selection. To mess with these for normal browses
                     73: is asking for user confusion.
                     74: <PRE>
                     75: #define LOGICAL_DEFAULT "WWW_HOME"           /* Defined to be the home page */
                     76: 
                     77: #ifndef PERSONAL_DEFAULT
                     78: #define PERSONAL_DEFAULT "WWW/default.html"            /* in home directory */
                     79: #endif
                     80: 
                     81: /* If the home page isn't found, use this file: */
                     82: #ifndef LAST_RESORT
                     83: #define LAST_RESORT    "http://www.w3.org/"
                     84: #endif
                     85: 
                     86: /* If one telnets to an access point it will look in this file for home page */
                     87: #ifndef REMOTE_POINTER
                     88: #define REMOTE_POINTER  "/etc/www-remote.url"              /* can't be file */
                     89: #endif
                     90: 
                     91: /* and if that fails it will use this. */
                     92: #ifndef REMOTE_ADDRESS
                     93: #define REMOTE_ADDRESS  "http://www.w3.org/"               /* can't be file */
                     94: #endif
                     95: 
                     96: /* Default log file name */
                     97: #ifndef DEFAULT_LOGFILE
                     98: #define DEFAULT_LOGFILE                "www-log"
                     99: #endif
                    100: 
                    101: #ifndef LOCAL_DEFAULT_FILE
                    102: #define LOCAL_DEFAULT_FILE "/usr/local/lib/WWW/default.html"
                    103: #endif
                    104: 
                    105: /* This is the default cache directory: */
                    106: #ifndef HT_CACHE_ROOT
                    107: #define HT_CACHE_ROOT          "/tmp"
                    108: #endif
                    109: 
                    110: /* The default directory for "save locally" and "save and execute" files: */
                    111: #ifndef HT_TMP_ROOT
                    112: #define HT_TMP_ROOT            "/tmp"
                    113: #endif
2.35      frystyk   114: </PRE>
1.1       timbl     115: 
2.52      frystyk   116: <A NAME="flags"><H2>Global Flags</H2></A>
2.46      frystyk   117: 
                    118: Flags and variables which may be set to control the Library
                    119: 
2.52      frystyk   120: <H3>Maximum Number of Redirections</H3>
2.46      frystyk   121: 
                    122: The maximum number of redirections is pr. default 10. This prevents
                    123: the library from going into an infinite loop which is kind of nice :-)
2.52      frystyk   124: It is normally not necessary to change the default value.
2.46      frystyk   125: 
2.35      frystyk   126: <PRE>
2.46      frystyk   127: extern int HTMaxRedirections;
2.33      frystyk   128: </PRE>
1.1       timbl     129: 
2.52      frystyk   130: <H3>Allow Accss to Local File System</H3>
                    131: 
                    132: This flag can be used to deny an application to get access to the
                    133: local file system (through cache, file URLs etc.)
                    134: 
                    135: <PRE>
                    136: extern BOOL HTSecure;                  /* Disable security holes? */
                    137: </PRE>
                    138: 
                    139: <H3>Name of Remote login Host</H3>
                    140: 
                    141: If an application is used for remote access (allowing telnet access,
                    142: like for example the Line Mode Browser), then set this variable to the
                    143: name of the remote host.
2.36      frystyk   144: 
                    145: <PRE>
                    146: extern char * HTClientHost;            /* Name or number of telnetting host */
2.52      frystyk   147: </PRE>
                    148: 
                    149: <H3>Server Specific Flags</H3>
                    150: 
                    151: These two flags are set by a proxy and a server application
                    152: respectfully. They tell the Library to skip some of the client
                    153: application specific things.
2.46      frystyk   154: 
2.52      frystyk   155: <PRE>
2.36      frystyk   156: extern char * HTImServer;              /* If I'm cern_httpd */
                    157: extern BOOL HTImProxy;                 /* If I'm cern_httpd as a proxy */
                    158: </PRE>
                    159: 
2.52      frystyk   160: <H2><A NAME="z100">Functions to Manipulate a HTRequest Structure</A></H2>
                    161: 
                    162: Just to make things easier especially for clients, here are some functions to
                    163: manipulate the request structure:
                    164: 
                    165: <PRE>
                    166: typedef struct _HTRequest HTRequest;
                    167: </PRE>
                    168: 
                    169: <H3>Create blank request</H3>
                    170: 
                    171: This request has defaults in -- in most cases it will need some
                    172: information added before being passed to HTAccess, but it will work as
                    173: is for a simple request.
                    174: 
                    175: <PRE>
                    176: extern HTRequest * HTRequest_new NOPARAMS;
                    177: </PRE>
                    178: 
                    179: <H3>Delete request structure</H3>
                    180: 
                    181: Frees also conversion list hanging from req->conversions.
                    182: 
                    183: <PRE>
                    184: extern void HTRequest_delete PARAMS((HTRequest * req));
                    185: </PRE>
                    186: 
2.54      frystyk   187: <H3>Post Web Management</H3>
2.16      luotonen  188: 
2.33      frystyk   189: <PRE>
2.54      frystyk   190: extern BOOL HTRequest_addDestination           PARAMS((HTRequest * src,
                    191:                                                        HTRequest * dest));
                    192: extern BOOL HTRequest_removeDestination                PARAMS((HTRequest * dest));
                    193: 
                    194: extern BOOL HTRequest_linkDestination          PARAMS((HTRequest * dest));
                    195: extern BOOL HTRequest_unlinkDestination                PARAMS((HTRequest * dest));
                    196: 
                    197: extern BOOL HTRequest_removePostWeb            PARAMS((HTRequest * me));
                    198: extern BOOL HTRequest_killPostWeb              PARAMS((HTRequest * me));
                    199: 
                    200: #define        HTRequest_mainDestination(me) \
                    201:        ((me) &amp;&amp; (me)->source ? (me)->source->mainDestination : NULL)
                    202: #define HTRequest_isDestination(me) \
                    203:        ((me) &amp;&amp; (me)->source &amp;&amp; (me) != (me)->source)
                    204: #define HTRequest_isMainDestination(me) \
                    205:        ((me) &amp;&amp; (me)->source &amp;&amp; \
                    206:        (me) == (me)->source->mainDestination)
                    207: #define HTRequest_isSource(me) \
                    208:        ((me) &amp;&amp; (me)->source &amp;&amp; (me) == (me)->source)
                    209: #define HTRequest_isPostWeb(me) \
                    210:        ((me) &amp;&amp; (me)->source)
2.16      luotonen  211: </PRE>
2.33      frystyk   212: 
2.55      frystyk   213: <A NAME="headers"><H2>HTTP/MIME Header Methods</H2></A>
2.10      timbl     214: 
2.52      frystyk   215: These enumerations set up the headers that are used in a HTTP request
                    216: <EM>OR</EM> a HTTP response.
2.10      timbl     217: 
2.52      frystyk   218: <A NAME="HeaderMask"><H3>General HTTP Header Mask</H3></A>
2.46      frystyk   219: 
2.51      frystyk   220: There are a few header fields which have general applicability for
                    221: both request and response mesages, but which do not apply to the
                    222: communication parties or theentity being transferred. This mask
                    223: enables and disables these headers. If the bit is not turned on they
2.52      frystyk   224: are not sent. All headers are optional and the default value is <EM>NO
                    225: GENERAL HEADERS</EM>
2.46      frystyk   226: 
                    227: <PRE>
2.51      frystyk   228: typedef enum _GenHeaderEnum {
2.46      frystyk   229:     HT_DATE            = 0x1,
2.51      frystyk   230:     HT_FORWARDED       = 0x2,
                    231:     HT_MESSAGE_ID      = 0x4,
                    232:     HT_MIME            = 0x8
                    233: } GenHeaderEnum;
                    234: 
                    235: #define <A NAME="DEF_HEAD">DEFAULT_GENERAL_HEADERS</A> 0
                    236: </PRE>
                    237: 
2.52      frystyk   238: <H3>Request Headers</H3>
2.46      frystyk   239: 
2.51      frystyk   240: The request header fields allow the client to pass additional
                    241: information about the request (and about the client itself) to the
                    242: server. All headers are optional but the default value is all request
                    243: headers if present <EM>except</EM> <CODE>From</CODE> and
                    244: <CODE>Pragma</CODE>.
                    245: 
                    246: <PRE>
                    247: typedef enum _ReqHeaderEnum {
                    248:     HT_ACCEPT_TYPE     = 0x1,
                    249:     HT_ACCEPT_CHAR     = 0x2,
                    250:     HT_ACCEPT_ENC      = 0x4,
                    251:     HT_ACCEPT_LAN      = 0x8,
2.46      frystyk   252:     HT_FROM            = 0x10,
                    253:     HT_PRAGMA          = 0x20,
                    254:     HT_REFERER         = 0x40,
                    255:     HT_USER_AGENT      = 0x80
2.51      frystyk   256: } ReqHeaderEnum;
2.46      frystyk   257: 
2.51      frystyk   258: #define <A NAME="DEF_REQ">DEFAULT_REQUEST_HEADERS</A> \
                    259: HT_ACCEPT_TYPE+HT_ACCEPT_CHAR+HT_ACCEPT_ENC+HT_ACCEPT_LAN+HT_REFERER+HT_USER_AGENT
2.46      frystyk   260: </PRE>
                    261: 
2.52      frystyk   262: <H3>Entity Header Mask</H3>
2.46      frystyk   263: 
                    264: The entity headers contain information about the object sent in the
                    265: HTTP transaction. See the <A HREF="HTAnchor.html">Anchor module</A>,
                    266: for the storage of entity headers. This flag defines which headers are
                    267: to be sent in a request together with an entity body (the <B>O</B>
2.51      frystyk   268: stands for <EM>object</EM>). All headers are optional but the default
                    269: value is <EM>ALL ENTITY HEADERS IF PRESENT</EM>
2.46      frystyk   270: 
                    271: <PRE>
                    272: typedef enum _EntityHeaderEnum {
                    273:     HT_ALLOW           = 0x1,
                    274:     HT_CONTENT_ENCODING        = 0x2,
                    275:     HT_CONTENT_LANGUAGE        = 0x4,
                    276:     HT_CONTENT_LENGTH  = 0x8,
                    277:     HT_CTE             = 0x10,                 /* Content-Transfer-Encoding */
                    278:     HT_CONTENT_TYPE    = 0x20,
                    279:     HT_DERIVED_FROM    = 0x40,
                    280:     HT_EXPIRES         = 0x80,
                    281:     HT_LAST_MODIFIED   = 0x200,
                    282:     HT_LINK            = 0x400,
                    283:     HT_TITLE           = 0x800,
                    284:     HT_URI             = 0x1000,
                    285:     HT_VERSION         = 0x2000
                    286: } EntityHeaderEnum;
                    287: 
2.51      frystyk   288: #define <A NAME="DEF_ENTITY">DEFAULT_ENTITY_HEADERS</A> 0xFFFF
2.46      frystyk   289: </PRE>
                    290: 
2.52      frystyk   291: <H3>User Defined Headers</H3>
2.10      timbl     292: 
2.52      frystyk   293: Extra header can be generated when initializing the <A
                    294: HREF="#ExtraHeaders">ExtraHeaders field</A>.
1.1       timbl     295: 
2.52      frystyk   296: <A NAME="LoadDoc"><H2>Functions for Loading a Document</H2></A>
2.33      frystyk   297: 
2.52      frystyk   298: There are several different ways of loading a document. However, the
                    299: major difference between them is whether the document is referenced by
2.33      frystyk   300: 
2.52      frystyk   301: <UL>
                    302: <LI><A HREF="#Relative">Relative URI</A>
                    303: <LI><A HREF="#Absolute">Absolute URI</A>
                    304: <LI><A HREF="#Anchor">Anchor element</A> or
                    305: <LI>Contains keywords for <A HREF="#RelSearch">searching an relative URI</A>
                    306: <LI>Contains keywords for <A HREF="#AbsSearch">searching an absolute URI</A>
                    307: </UL>
2.33      frystyk   308: 
2.52      frystyk   309: <B>NOTE:</B> From release 3.0 of the Library, the return codes from
                    310: the loading functions are no mode <CODE>BOOL</CODE>, that is
                    311: <CODE>YES</CODE> or <CODE>NO</CODE>. Insted they have been replaced
                    312: with the following set of return codes defined in the <A
                    313: HREF="HTUtils.html#ReturnCodes">Utility module</A>:
1.1       timbl     314: 
2.52      frystyk   315: <DL>
                    316: <DT>HT_WOULD_BLOCK
                    317: <DD>An I/O operation would block
1.1       timbl     318: 
2.52      frystyk   319: <DT>HT_ERROR
                    320: <DD>Error has occured
1.1       timbl     321: 
2.52      frystyk   322: <DT>HT_LOADED
                    323: <DD>Success
2.23      frystyk   324: 
2.52      frystyk   325: <DT>HT_NO_DATA
                    326: <DD>Success, but no document loaded. This might be the situation when a 
                    327: telnet sesssion is started etc.
2.10      timbl     328: 
2.52      frystyk   329: <DT>HT_RETRY
                    330: <DD>The remote server is down but will serve documents from the
                    331: calendar time indicated in HTRequest-&gt;retry_after.
2.51      frystyk   332: 
2.52      frystyk   333: </DL>
2.51      frystyk   334: 
2.52      frystyk   335: However, a general rule about the return codes is that <B>ERRORS</B>
                    336: have a <EM>negative</EM> value whereas <B>SUCCESS</B> has a
                    337: <EM>positive</EM> value. <P>
2.51      frystyk   338: 
2.52      frystyk   339: There are also some functions to help the client getting started with
                    340: <A HREF="#ClientHelp">the first URI</A>.
2.51      frystyk   341: 
2.52      frystyk   342: <A NAME="Relative"><H3>Load a document from relative URL</H3></A>
2.34      frystyk   343: 
                    344: <PRE>
2.52      frystyk   345: extern int HTLoadRelative      PARAMS((CONST char *    relative_name,
                    346:                                        HTParentAnchor* here,
                    347:                                        HTRequest *     request));
2.34      frystyk   348: </PRE>
                    349: 
2.52      frystyk   350: <A NAME="Absolute"></A><H3>Load a document from absolute URL</H3>
2.39      frystyk   351: 
                    352: <PRE>
2.52      frystyk   353: extern int HTLoadAbsolute      PARAMS((CONST char *    addr,
                    354:                                        HTRequest *     request));
2.39      frystyk   355: </PRE>
2.19      timbl     356: 
2.52      frystyk   357: <H3>Load a document from absolute name to a stream</H3>
2.19      timbl     358: 
2.39      frystyk   359: <PRE>
2.52      frystyk   360: extern int HTLoadToStream      PARAMS((CONST char *    addr,
                    361:                                        BOOL            filter,
                    362:                                        HTRequest *     request));
2.39      frystyk   363: </PRE>
                    364: 
2.52      frystyk   365: <A NAME="Anchor"><H3>Load a document from anchor</H3></A>
2.46      frystyk   366: 
2.52      frystyk   367: The anchor parameter may be a child anchor. The anchor in the request
                    368: is set to the parent anchor. The recursive function keeps the error
                    369: stack in the request structure so that no information is lost having
                    370: more than one call. See also <A HREF="#BindAnchor">HTBindAnchor()</A>.
2.39      frystyk   371: 
                    372: <PRE>
2.52      frystyk   373: extern int HTLoadAnchor                PARAMS((HTAnchor  *     a,
                    374:                                        HTRequest *     request));
                    375: extern int HTLoadAnchorRecursive PARAMS((HTAnchor *    a,
                    376:                                        HTRequest *     request));
2.39      frystyk   377: </PRE>
                    378: 
2.52      frystyk   379: <H3>Load a Document</H3>
2.39      frystyk   380: 
2.52      frystyk   381: These are two internal routines for loading a document which has an
                    382: address AND a matching anchor.  (The public routines are called with
                    383: one OR the other.)  This is recursively called from file load module
                    384: to try ftp (though this will be obsolete in the next major
                    385: release).<P>
2.39      frystyk   386: 
2.52      frystyk   387: If <CODE>keep_error_stack</CODE> is YES then the error (or info) stack
                    388: is not cleared from the previous call.
2.39      frystyk   389: 
                    390: <PRE>
2.52      frystyk   391: extern int HTLoad              PARAMS((HTRequest * request,
                    392:                                        BOOL keep_error_stack));
2.39      frystyk   393: </PRE>
                    394: 
                    395: <PRE>
2.52      frystyk   396: extern BOOL HTLoadTerminate    PARAMS((HTRequest * request, int status));
2.51      frystyk   397: </PRE>
                    398: 
2.52      frystyk   399: <A NAME="RelSearch"><H3>Search Using Relative URL</H3></A>
                    400: 
                    401: Performs a search on word given by the user. Adds the search words to
                    402: the end of the current address and attempts to open the new address.
2.51      frystyk   403: 
                    404: <PRE>
2.52      frystyk   405: extern int HTSearch            PARAMS((CONST char *    keywords,
                    406:                                        HTParentAnchor* here,
                    407:                                        HTRequest *     request));
2.46      frystyk   408: </PRE>
                    409: 
2.52      frystyk   410: <A NAME="AbsSearch"><H3>Search using Absolute URL</H3></A>
                    411: 
                    412: Performs a keyword search on word given by the user. Adds the keyword
                    413: to the end of the current address and attempts to open the new
                    414: address.
2.46      frystyk   415: 
                    416: <PRE>
2.52      frystyk   417: extern int HTSearchAbsolute    PARAMS((CONST char *    keywords,
                    418:                                        CONST char *    indexname,
                    419:                                        HTRequest *     request));
2.46      frystyk   420: </PRE>
                    421: 
                    422: 
2.52      frystyk   423: <A NAME="ClientHelp"><H2>Help Function for Clients to get started</H2></A>
2.39      frystyk   424: 
2.52      frystyk   425: These function helps the client to load the first document. They are
                    426: not mandatory to use - but they make life easier!
2.46      frystyk   427: 
2.52      frystyk   428: <A NAME="BindAnchor"><H3>Bind an anchor to a request structure without
                    429: loading</H3></A>
2.39      frystyk   430: 
                    431: <PRE>
2.52      frystyk   432: extern BOOL HTBindAnchor PARAMS((HTAnchor *anchor, HTRequest *request));
2.39      frystyk   433: </PRE>
                    434: 
2.52      frystyk   435: <A NAME="HomePage"><H3>Generate the Anchor for the Home Page</H3></A>
                    436: 
                    437: As it involves file access, this should only be done once when the
                    438: program first runs. This is a default algorithm using the
                    439: <CODE>WWW_HOME</CODE> environment variable.
2.39      frystyk   440: 
                    441: <PRE>
2.52      frystyk   442: extern HTParentAnchor * HTHomeAnchor NOPARAMS;
2.39      frystyk   443: </PRE>
                    444: 
2.52      frystyk   445: <H3>Find Related Name</H3>
2.45      frystyk   446: 
2.52      frystyk   447: Creates a local file URI that can be used as a relative name when
                    448: calling HTParse() to expand a relative file name to an absolute
                    449: one. <P>
2.45      frystyk   450: 
2.52      frystyk   451: The code for this routine originates from the Line Mode Browser and
2.53      frystyk   452: was moved here by <EM>howcome@w3.org</EM> in order for all
2.52      frystyk   453: clients to take advantage.<P>
2.39      frystyk   454: 
2.47      frystyk   455: <PRE>
2.52      frystyk   456: extern char *  HTFindRelatedName NOPARAMS;
2.47      frystyk   457: </PRE>
                    458: 
2.52      frystyk   459: <A NAME="PostDoc"><H2>Functions for Posting a Document</H2></A>
                    460: 
                    461: <B>NOTE:</B> The Posting functions are used to send a data object
                    462: along with the request. The functions have the same set of return
                    463: codes as for the <A HREF="#LoadDoc">Load Functions</A>.
2.47      frystyk   464: 
2.52      frystyk   465: <H3>Get a Save Stream</H3>
2.46      frystyk   466: 
2.52      frystyk   467: <H4>On Entry,</H4>
                    468: <DL>
                    469: <DT>request->anchor
                    470: <DD> is valid anchor which
                    471: has previously beeing loaded
                    472: </DL>
2.46      frystyk   473: 
2.52      frystyk   474: <H4>On exit,</H4>
                    475: <DL>
                    476: <DT>returns
                    477: <DD> 0 if error else a stream
                    478: to save the object to.
                    479: </DL>
2.46      frystyk   480: 
                    481: <PRE>
2.52      frystyk   482: extern HTStream * HTSaveStream PARAMS((HTRequest * request));
2.46      frystyk   483: </PRE>
                    484: 
2.52      frystyk   485: <H3>Copy an Anchor</H3>
                    486: 
                    487: Fetch the URL (possibly local file URL) and send it using either
                    488: <B>PUT</B> or <B>POST</B> directly to the remote destination using
                    489: HTTP, that is remote copy of object <EM>O</EM> from <EM>A</EM> to
                    490: <EM>B</EM> where <EM>A</EM> might be the host of the application. The
                    491: caller can decide the exact method used and which HTTP header fields
                    492: to transmit by setting the user fields in the destination request
                    493: structure.
2.46      frystyk   494: 
                    495: <PRE>
2.52      frystyk   496: extern int HTCopyAnchor                PARAMS((HTAnchor *      src_anchor,
                    497:                                        HTRequest *     dest_req));
2.39      frystyk   498: </PRE>
                    499: 
2.46      frystyk   500: 
2.52      frystyk   501: <H3>Upload an Anchor</H3>
2.39      frystyk   502: 
2.52      frystyk   503: Send the contents (in hyperdoc) of the source anchor using either
                    504: <B>PUT</B> or <B>POST</B> to the remote destination using HTTP. The
                    505: caller can decide the exact method used and which HTTP header fields
                    506: to transmit by setting the user fields in the request structure.
                    507: <EM>Format conversion</EM> can be made on the fly by setting the <A
                    508: HREF="#input_format">input_format field</A> in the destination request
                    509: structure. If the content-length is unknown (-1) then a <A
                    510: HREF="HTConLen.html">content-length counter</A> is automaticly put
                    511: into the stream pipe.
2.43      frystyk   512: 
                    513: 
                    514: <PRE>
2.52      frystyk   515: extern int HTUploadAnchor      PARAMS((HTAnchor *      src_anchor,
                    516:                                        HTParentAnchor *dest_anchor,
                    517:                                        HTRequest *     dest_req));
2.46      frystyk   518: </PRE>
                    519: 
2.52      frystyk   520: <A NAME="Int"><H2>Internal Data Structures</H2></A>
                    521: 
                    522: These are internal to the Library and should not normally be accessed
                    523: directly.
2.46      frystyk   524: 
2.52      frystyk   525: <H3>Access Authentication</H3>
2.39      frystyk   526: 
2.52      frystyk   527: We need to define the following structures as they are used in the
                    528: HTRequest structure. The AA module is declared in <A
                    529: HREF="HTAAUtil.html">HTAAUtil</A> and <A HREF="HTAABrow.html">
                    530: HTAABrow</A>. The enumeration <CODE>HTAAScheme </CODE>represents the
                    531: possible authentication schemes used by the WWW Access Authorization.
2.19      timbl     532: 
2.25      luotonen  533: <PRE>
2.52      frystyk   534: typedef enum {
                    535:     HTAA_UNKNOWN,
                    536:     HTAA_NONE,
                    537:     HTAA_BASIC,
                    538:     HTAA_PUBKEY,
                    539:     HTAA_KERBEROS_V4,
                    540:     HTAA_KERBEROS_V5,
                    541:     HTAA_MAX_SCHEMES                           /* THIS MUST ALWAYS BE LAST! */
                    542: } HTAAScheme;
                    543: 
                    544: typedef struct _HTAARealm HTAARealm;
                    545: typedef struct _HTAASetup HTAASetup;
2.46      frystyk   546: </PRE>
2.25      luotonen  547: 
2.52      frystyk   548: <A NAME="socket"><H3>Buffering for the network</H3></A>
                    549: 
                    550: This structure provides buffering for READ (and future WRITE) to the
                    551: network. It is used by all the protocol modules. The size of the
                    552: buffer, <CODE>INPUT_BUFFER_SIZE</CODE>, is a compromis between speed
                    553: and memory.
2.46      frystyk   554: 
                    555: <PRE>
2.52      frystyk   556: #define INPUT_BUFFER_SIZE 8192
                    557: 
                    558: typedef struct _HTInputSocket HTInputSocket;
2.34      frystyk   559: </PRE>
2.46      frystyk   560: 
2.52      frystyk   561: <H3><A NAME="HTNetInfo">Protocol Specific Information</A></H3>
                    562: 
                    563: This structure contains information about socket number, input buffer
                    564: for reading from the network etc. The structure is used through out
                    565: the protocol modules and is the reference point for introducing multi
                    566: threaded execution into the library, see specifications on <A
2.54      frystyk   567: HREF="http://www.w3.org/hypertext/WWW/Library/User/Architecture/Threads.html">Multiple
2.52      frystyk   568: Threads</A>.
2.46      frystyk   569: 
2.34      frystyk   570: <PRE>
2.52      frystyk   571: typedef enum _SocAction {
                    572:     SOC_INVALID = -1,
                    573:     SOC_WRITE = 0,                             /* By default ready to write */
                    574:     SOC_READ,
                    575:     SOC_INTERRUPT
                    576: } SocAction;
                    577: 
                    578: typedef struct _HTNetInfo {
                    579:     SOCKFD             sockfd;                         /* Socket descripter */
                    580:     SockA              sock_addr;              /* SockA is defined in tcp.h */
                    581:     HTInputSocket *    isoc;                                /* Input buffer */
                    582:     SocAction          action;                 /* Result of the select call */
                    583:     HTStream *         target;                             /* Target stream */
                    584:     int                addressCount;        /* Attempts if multi-homed host */
                    585:     time_t             connecttime;             /* Used on multihomed hosts */
                    586:     struct _HTRequest *        request;           /* Link back to request structure */
                    587: } HTNetInfo;
2.25      luotonen  588: </PRE>
2.39      frystyk   589: 
2.52      frystyk   590: <EM><B>Note:</B> The AddressCount varaible is used to count the number
                    591: of attempt to connect to a multi-homed host so we know when to stop
                    592: trying new IP-addresses.</EM>
                    593: 
                    594: <H3><A NAME="z1">The Request structure</A></H3>
2.46      frystyk   595: 
2.52      frystyk   596: When a request is handled, all kinds of things about it need to be
                    597: passed along.  These are all put into a HTRequest structure. This is
                    598: the most essential structure in the library. It contains two main
                    599: categories of information regarding a request:
2.39      frystyk   600: 
2.52      frystyk   601: <UL>
                    602: <LI>Application dependent information
                    603: <LI>Library dependent information
                    604: </UL>
2.46      frystyk   605: 
2.52      frystyk   606: Applications using the Library should <EM>never</EM> use the internal
                    607: library dependent information. It's only because we dont have real
                    608: classes that we can't hide it. <P>
2.46      frystyk   609: 
2.52      frystyk   610: <B>Note:</B> If you reuse the request structure for more than one
                    611: request then make sure that the request is re-initialized, so that no
                    612: `old' data is reused, see <A HREF="#z100">functions to manipulate
                    613: HTRequest Structure</A>. The library handles its own internal
                    614: information from request to request but the information set by the
                    615: caller is untouched. <P>
2.46      frystyk   616: 
2.52      frystyk   617: The elements of the request structure are as follows:
2.49      frystyk   618: 
                    619: <PRE>
2.52      frystyk   620: struct _HTRequest {
2.49      frystyk   621: </PRE>
                    622: 
2.52      frystyk   623: <H4>Application Dependent - Set by the caller of HTAccess</H4>
                    624: 
2.19      timbl     625: <PRE>
2.52      frystyk   626:     <A HREF="#Methods">HTMethod</A>    method;
2.31      frystyk   627: </PRE>
                    628: 
2.52      frystyk   629: An enum used to specify the HTTP <A NAME="z7"
                    630: HREF="../../Protocols/HTTP/Methods.html">method</A> used for the
                    631: actual request. The default value is <A
                    632: HREF="#Methods"><CODE>GET</CODE></A>.
2.31      frystyk   633: 
2.52      frystyk   634: <H5>HTTP Header Information</H5>
2.31      frystyk   635: 
2.14      luotonen  636: <PRE>
2.52      frystyk   637:     HTList *   conversions;
2.31      frystyk   638: </PRE>
2.14      luotonen  639: 
2.52      frystyk   640: NULL, or a <EM>local</EM> list of specific conversions which the
                    641: format manager can do in order to fulfill the request.  It typically
                    642: points to a list set up on initialisation time for example by <A
                    643: HREF="HTInit.html">HTInit()</A>. There is also a <A
                    644: HREF="HTFormat.html#z17"><EM>global</EM></A> list of conversions which
                    645: contains a generic set of possible conversions.
                    646: 
2.14      luotonen  647: <PRE>
2.52      frystyk   648:     HTList *   encodings;
2.31      frystyk   649: </PRE>
1.1       timbl     650: 
2.52      frystyk   651: The list of encodings acceptable in the output stream.
2.46      frystyk   652: 
2.52      frystyk   653: <PRE>
                    654:     HTList *   languages;
                    655: </PRE>
2.46      frystyk   656: 
2.52      frystyk   657: The list of (human) language values acceptable in the response. The default
                    658: is all languages.
2.46      frystyk   659: 
2.31      frystyk   660: <PRE>
2.52      frystyk   661:     HTList *   charsets;
2.31      frystyk   662: </PRE>
2.9       timbl     663: 
2.52      frystyk   664: The list of charsets accepted by the application
2.39      frystyk   665: 
2.52      frystyk   666: <PRE>
                    667:     GenHeaderEnum      GenMask;
                    668:     ReqHeaderEnum      RequestMask;
                    669:     EntityHeaderEnum   EntityMask;
                    670: </PRE>
2.39      frystyk   671: 
2.52      frystyk   672: These bitmask variables defines which headers to include in a HTTP
                    673: request (or any other MIME-like protocol). See <A
                    674: HREF="#HeaderMask">header masks</A> for more information on default
                    675: values.
2.39      frystyk   676: 
2.52      frystyk   677: <PRE>
                    678:     HTParentAnchor *parentAnchor;
                    679: </PRE>
2.39      frystyk   680: 
2.52      frystyk   681: If this parameter is set then a `Referer: &lt;parent address&gt; can
                    682: be generated in the request to the server, see <A
                    683: HREF="http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRQ_Headers.html#z14">
                    684: Referer field in a HTTP Request</A>
2.39      frystyk   685: 
2.52      frystyk   686: <PRE>
                    687:    <A NAME="ExtraHeaders">char * ExtraHeaders;</A>
                    688: </PRE>
2.39      frystyk   689: 
2.52      frystyk   690: Extra header information can be send along with a request using this
                    691: variable. The text is sent as is so it must be preformatted with
                    692: &lt;CRLF&gt; line terminators.
2.47      frystyk   693: 
2.52      frystyk   694: <H5>Streams From Network to Application</H5>
1.1       timbl     695: 
2.39      frystyk   696: <PRE>
2.52      frystyk   697:     HTStream * output_stream; 
2.5       timbl     698: </PRE>
2.39      frystyk   699: 
2.52      frystyk   700: The output stream is to be used to put data down to as they come in
                    701: <B>from</B> the network and back to the application. The default value
                    702: is <CODE>NULL</CODE> which means that the stream goes to the user
                    703: (display).
1.1       timbl     704: 
2.5       timbl     705: <PRE>
2.52      frystyk   706:     HTAtom *   output_format;
2.5       timbl     707: </PRE>
2.39      frystyk   708: 
2.52      frystyk   709: The desired format of the output stream. This can be used to get
                    710: unconverted data etc. from the library. If <CODE>NULL</CODE>, then <A
                    711: HREF="HTFormat.html#FormatTypes">WWW_PRESENT</A> is default value.
2.39      frystyk   712: 
2.5       timbl     713: <PRE>
2.52      frystyk   714:     HTStream*  error_stream;
2.5       timbl     715: </PRE>
1.1       timbl     716: 
2.52      frystyk   717: All object bodies sent from the server with status codes different
                    718: from <CODE>200 OK</CODE> will be put down this stream. This can be
                    719: used as a debug window etc. If the value is NULL (default) then the
                    720: stream used is <A HREF="HTFormat.html#BlackHole">HTBlackHole</A>.
1.1       timbl     721: 
2.39      frystyk   722: <PRE>
2.52      frystyk   723:     HTAtom *   error_format;
2.5       timbl     724: </PRE>
                    725: 
2.52      frystyk   726: The desired format of the error stream. This can be used to get
                    727: unconverted data etc. from the library. The default value if
                    728: <CODE>WWW_HTML</CODE> as a character based only has one WWW_PRESENT.
1.1       timbl     729: 
2.52      frystyk   730: <H5>Streams From Application to Network</H5>
1.1       timbl     731: 
2.39      frystyk   732: <PRE>
2.52      frystyk   733:     HTStream * input_stream; 
2.41      frystyk   734: </PRE>
                    735: 
2.52      frystyk   736: The input stream is to be used by the <CODE>PostCallBack</CODE>
                    737: function to put data out on the network. The user should not
                    738: initialize this field.
                    739: 
2.41      frystyk   740: <PRE>
2.52      frystyk   741:     HTAtom *   input_format;
2.5       timbl     742: </PRE>
                    743: 
2.52      frystyk   744: The desired format of the output stream. This can be used to upload
                    745: converted data to a remote server. If <CODE>NULL</CODE>, then <A
                    746: HREF="HTFormat.html#FormatTypes">WWW_SOURCE</A> is default value.
2.39      frystyk   747: 
2.5       timbl     748: <PRE>
2.52      frystyk   749:     int (*PostCallBack)                PARAMS((struct _HTRequest *     request,
                    750:                                        HTStream *              target));
2.5       timbl     751: </PRE>
2.39      frystyk   752: 
2.52      frystyk   753: The call back function which is called when the current request is
                    754: ready for sending (posting) the data object. The request is the
                    755: current request so that the application knows which post we are
                    756: handling. The function must have the same return values as the other
                    757: <A HREF="#LoadDoc">Load functions</A>.
2.39      frystyk   758: 
2.52      frystyk   759: <H5>Other Flags</H5>
2.5       timbl     760: 
2.33      frystyk   761: <PRE>
2.52      frystyk   762:     BOOL BlockingIO;
                    763:     BOOL ForceReload;
                    764:     BOOL ContentNegotiation;
2.5       timbl     765: </PRE>
2.24      luotonen  766: 
2.52      frystyk   767: <CODE>BlockingIO</CODE> can be set to override if a protocol module is
                    768: registered as using non-blocking IO, <CODE>ForceReload</CODE> will
                    769: cancel any cached element, and <CODE>ContentNegotioation</CODE> will
                    770: force content negotiation when looking for a local file. This is the
                    771: default!
2.24      luotonen  772: 
                    773: <PRE>
2.52      frystyk   774:     BOOL (*<A NAME="z9"> callback</A> ) PARAMS((struct _HTRequest* request,
                    775:                                                void *param));
2.24      luotonen  776: </PRE>
                    777: 
2.52      frystyk   778: A function to be called back in the event that a file has been saved
                    779: to disk by HTSaveAndCallBack for example.
2.20      frystyk   780: 
                    781: <PRE>
2.52      frystyk   782:     void *     context;
2.39      frystyk   783: </PRE>
                    784: 
2.52      frystyk   785: An arbitrary pointer passed to HTAccess and passed back as a parameter
                    786: to the <A NAME="z10" HREF="#z9">callback</A>.
2.39      frystyk   787: 
2.52      frystyk   788: <H4>Library Dependent - Set by Library</H4>
2.39      frystyk   789: 
2.52      frystyk   790: None of the bits below may be looked at by a WWW application. The
                    791: Library handles the cleanup by itself.
2.39      frystyk   792: 
2.20      frystyk   793: <PRE>
2.52      frystyk   794:     HTParentAnchor*    anchor;
2.39      frystyk   795: </PRE>
                    796: 
2.52      frystyk   797: The anchor for the object in question.  Set immediately by HTAcesss.
                    798: Used by the protocol and parsing modules.  Valid thoughout the access.
2.39      frystyk   799: 
2.52      frystyk   800: <PRE>
                    801:     HTChildAnchor *    childAnchor;    /* For element within the object  */
                    802: </PRE>
2.20      frystyk   803: 
2.52      frystyk   804: The anchor for the sub object if any.  The object builder should
                    805: ensure that is is selected, highlighted, etc when the object is
                    806: loaded.
2.20      frystyk   807: 
2.52      frystyk   808: <PRE>
                    809:     void *     using_cache;
                    810:     BOOL       using_proxy;
                    811: </PRE>
2.5       timbl     812: 
2.52      frystyk   813: Pointer to cache element if cache hit anfd if using proxy
2.5       timbl     814: 
                    815: <PRE>
2.52      frystyk   816:     BOOL       error_block;            /* YES if stream has been used    */
                    817:     HTList *   error_stack;            /* List of errors                 */
2.46      frystyk   818: </PRE>
                    819: 
2.52      frystyk   820: These two fields are used by the error reporting system to keep a
                    821: stack of messages.
2.46      frystyk   822: 
                    823: <PRE>
2.54      frystyk   824:     char *     redirect;               /* Location or URI */
2.52      frystyk   825:     int                redirections;           /* Number of redirections */
                    826:     time_t     retry_after;            /* Absolut time for a retry */
2.46      frystyk   827: </PRE>
                    828: 
2.54      frystyk   829: We keep track of the number of redirections and also register if we
                    830: have to repeat a request (if we received "5xx Retry After")
                    831: 
                    832: <PRE>
                    833:     HTNetInfo *        net_info;               /* Information about socket etc. */
                    834: </PRE>
                    835: 
                    836: This structure contains protocol specific information, socket number etc.
                    837: 
                    838: <PRE>
                    839:     HTRequest *        source;                 /* Source for request or itself */
                    840:     HTRequest * mainDestination;       /* For the typical case */
                    841:     HTList *   destinations;           /* List of related requests */
                    842:     int                destRequests;           /* Number of destination requests */
                    843:     int                destStreams;            /* Number of destination streams */
                    844: </PRE>
                    845: 
                    846: A simple model to bind related request structures together, for
                    847: example the source and destination request in a PUT.
2.46      frystyk   848: 
2.52      frystyk   849: <PRE>
                    850:     char *     WWWAAScheme;            /* WWW-Authenticate scheme */
                    851:     char *     WWWAARealm;             /* WWW-Authenticate realm */
                    852:     char *     WWWprotection;          /* WWW-Protection-Template */
2.54      frystyk   853:     char *     authorization;          /* Authorization: field */
                    854:     HTAAScheme scheme;                 /* Authentication scheme used */
2.52      frystyk   855: </PRE>
2.46      frystyk   856: 
2.54      frystyk   857: Access Authentication specific information.
2.46      frystyk   858: 
                    859: <PRE>
2.52      frystyk   860:     HTInputSocket *    isoc;           /* InputSocket object for reading */
2.39      frystyk   861: </PRE>
2.5       timbl     862: 
2.54      frystyk   863: This header is only used by the server and will be removed at some point.
1.1       timbl     864: 
2.52      frystyk   865: <PRE>
                    866:     HTList *   valid_schemes;          /* Valid auth.schemes             */
                    867:     HTAssocList **     scheme_specifics;/* Scheme-specific parameters    */
                    868:     char *     authenticate;           /* WWW-authenticate: field */
                    869:     char *     prot_template;          /* WWW-Protection-Template: field */
                    870:     HTAASetup *        setup;                  /* Doc protection info            */
                    871:     HTAARealm *        realm;                  /* Password realm                 */
                    872:     char *     dialog_msg;             /* Authentication prompt (client) */
                    873: </PRE>
1.1       timbl     874: 
2.52      frystyk   875: These fields are used by the HTTP access authentication used by a
                    876: client application.
2.39      frystyk   877: 
2.52      frystyk   878: <H4>Windows Specific Information</H4>
2.39      frystyk   879: 
                    880: <PRE>
2.52      frystyk   881: #ifdef _WINDOWS 
                    882:        HWND            hwnd;           /* Windows handle for MSWindows   */
                    883:        unsigned long   winMsg;         /* msg number of Windows eloop    */
                    884: #endif /* _WINDOWS */
2.5       timbl     885: </PRE>
1.1       timbl     886: 
2.38      howcome   887: <PRE>
2.52      frystyk   888: };
2.38      howcome   889: </PRE>
                    890: 
2.52      frystyk   891: End of Declaration
2.25      luotonen  892: 
                    893: <PRE>
1.1       timbl     894: #endif /* HTACCESS_H */
2.25      luotonen  895: </PRE>
                    896: end of HTAccess
                    897: </BODY>
2.9       timbl     898: </HTML>

Webmaster