Annotation of libwww/Library/src/HTBind.html, revision 2.3

2.1       frystyk     1: <HTML>
                      2: <HEAD>
                      3: <TITLE>File Suffix Bind Manager</TITLE>
                      4: </HEAD>
                      5: <BODY>
                      6: 
                      7: <H1>File Suffix Bind Manager</H1>
                      8: 
                      9: <PRE>
                     10: /*
                     11: **     (c) COPYRIGHT MIT 1995.
                     12: **     Please first read the full copyright statement in the file COPYRIGH.
                     13: */
                     14: </PRE>
                     15: 
                     16: This module sets up the binding between a file Bind and a media type,
                     17: language, encoding etc. In a client application the Binds are used in
                     18: protocols that does not support media types etc., like FTP, and in
                     19: server applications they are used to make the bindings between the
                     20: server and the local file store that the server can serve to the rest
                     21: of the world (well almost). The <A HREF="HTFormat.html">HTFormat
                     22: module</A> holds this information against the accept headers received
                     23: in a request and uses if for format negotiation. All the binding
                     24: management can all be replace by a database interface. <P>
                     25: 
                     26: This module is implemented by <A HREF="HTBind.c">HTBind.c</A>, and it
                     27: is a part of the <A
2.3     ! frystyk    28: HREF="http://www.w3.org/hypertext/WWW/Library/">
        !            29: W3C Reference Library</A>.
2.1       frystyk    30: 
                     31: <PRE>
                     32: #ifndef HTBIND_H
                     33: #define HTBIND_H
                     34: 
                     35: #include "HTFormat.h"
                     36: #include "HTAnchor.h"
                     37: </PRE>
                     38: 
                     39: <H2>Initialization of the Module</H2>
                     40: 
                     41: These functions must be called on startup and termination of the
                     42: application. This is done automatically by <A
                     43: HREF="HTAccess.html#Library">HTLibInit() and HTLibTerminate()</A>.
                     44: 
                     45: <PRE>
                     46: extern BOOL HTBind_init                NOPARAMS;
                     47: extern BOOL HTBind_deleteAll   NOPARAMS;
                     48: </PRE>
                     49: 
                     50: <H2>Case Sensitivity</H2>
                     51: 
                     52: Should the search for suffixes be case sensitive or not? The default
                     53: value is <EM>case sensitive</EM>.
                     54: 
                     55: <PRE>
                     56: extern void HTBind_setCaseSensitive    PARAMS((BOOL sensitive));
                     57: </PRE>
                     58: 
                     59: <H2>Suffix Delimiters</H2>
                     60: 
                     61: Change the set of suffix delimiters. The default is a platform
                     62: dependent set defined in the <A HREF="tcp.html">tcp module</A>.
                     63: 
                     64: <PRE>
                     65: extern CONST char *HTBind_getDelimiters        NOPARAMS;
                     66: extern void HTBind_setDelimiters       PARAMS((CONST char * new_suffixes));
                     67: </PRE>
                     68: 
                     69: <H2>Set up Bindings Associated with a File Suffix</H2>
                     70: 
                     71: There are three types of bindings:
                     72: 
                     73: <UL>
                     74: <LI>Content Type (media type)
                     75: <LI>Language
                     76: <LI>Content Encoding
                     77: </UL>
                     78: 
                     79: And the associated set of methods is defined as:
                     80: 
                     81: <PRE>
                     82: extern BOOL HTBind_setBinding  PARAMS((CONST char *    suffix,
                     83:                                        CONST char *    representation,
                     84:                                        CONST char *    encoding,
                     85:                                        CONST char *    language,
                     86:                                        double          value));
                     87: 
                     88: extern BOOL HTBind_setType     PARAMS((CONST char *    suffix,
                     89:                                        CONST char *    encoding,
                     90:                                        double          value));
                     91: 
                     92: extern BOOL HTBind_setEncoding PARAMS((CONST char *    suffix,
                     93:                                        CONST char *    encoding,
                     94:                                        double          value));
                     95: 
                     96: extern BOOL HTBind_setLanguage PARAMS((CONST char *    suffix,
                     97:                                        CONST char *    language,
                     98:                                        double          value));
                     99: </PRE>
                    100: 
                    101: The first method is a "super" method for binding information to a file
                    102: suffic. Any of the string values can be <CODE>NULL</CODE>. If filename
                    103: suffix is already defined its previous definition is overridden or
                    104: modified. For example, a <CODE>HTBind_setType</CODE> and
                    105: <CODE>HTBind_setEncoding</CODE> can be called with the same suffix.<P>
                    106: 
                    107: Calling this with suffix set to "*" will set the default
                    108: representation. Calling this with suffix set to "*.*" will set the
                    109: default representation for unknown suffix files which contain a "." <P>
                    110: 
                    111: <B>NOTE:</B> The suffixes <EM>can</EM> contain characters that must be
                    112: escaped in a URL. However, they should <EM>not</EM> be encoded when
                    113: parsed as the <CODE>suffix</CODE> parameter.
                    114: 
                    115: <H2>Determine a suitable suffix</H2>
                    116: 
                    117: Use the set of bindings to find a suitable suffix (or index) for a
                    118: certain combination of language, media type and encoding given in the
                    119: anchor. Returns a pointer to a suitable suffix string that must be freed 
                    120: by the caller. If more than one suffix is found they are all
                    121: concatenated. If no suffix is found, NULL is returned.
                    122: 
                    123: <PRE>
2.2       frystyk   124: extern char * HTBind_getSuffix PARAMS((HTParentAnchor * anchor));
2.1       frystyk   125: </PRE>
                    126: 
                    127: 
                    128: <H2>Determine the content of an Anchor</H2>
                    129: 
                    130: Use the set of bindings to find the combination of language, media
                    131: type and encoding of a given anchor. If more than one suffix is found
                    132: they are all searched. The last suffix has highest priority, the first
                    133: one lowest. Returns the anchor object with the representations
                    134: found. See also <CODE>HTBind_getFormat</CODE>
                    135: 
                    136: <PRE>
                    137: extern BOOL HTBind_getBindings         PARAMS((HTParentAnchor * anchor));
                    138: </PRE>
                    139: 
                    140: <H2>Determine the content of File</H2>
                    141: 
                    142: Use the set of bindings to find the combination of language, media
                    143: type and encoding of a given anchor. If more than one suffix is found
                    144: they are all searched. The last suffix has highest priority, the first
                    145: one lowest. Returns the format, encoding, and language found. See also
                    146: <CODE>HTBind_getBindings</CODE>.
                    147: 
                    148: <PRE>
                    149: extern BOOL HTBind_getFormat   PARAMS((CONST char *    filename,
                    150:                                        HTFormat *      format,
                    151:                                        HTEncoding *    encoding,
                    152:                                        HTLanguage *    language,
                    153:                                        double *        quality));
                    154: </PRE>
                    155: 
                    156: <H2>Multi Format Management</H2>
                    157: 
                    158: Use the set of bindings to find the combination of language, media
                    159: type and encoding of a given anchor. If more than one suffix is found
                    160: they are all searched. The last suffix has highest priority, the first
                    161: one lowest. Returns the format, encoding, and language found. See also
                    162: <CODE>HTBind_getBindings</CODE>, and <CODE>HTBind_getFormat</CODE>.
                    163: 
                    164: <PRE>
                    165: #define MULTI_SUFFIX ".multi"   /* Extension for scanning formats */
                    166: #define MAX_SUFF 15            /* Maximum number of suffixes for a file */
                    167: 
                    168: extern HTContentDescription * HTBind_getDescription PARAMS((char * file));
                    169: </PRE>
                    170: 
                    171: End of declaration module
                    172: 
                    173: <PRE>
                    174: #endif /* HTBIND_H */
                    175: </PRE>
                    176: 
                    177: </BODY>
                    178: </HTML>

Webmaster