Annotation of libwww/Library/src/HTBind.html, revision 2.7
2.1 frystyk 1: <HTML>
2: <HEAD>
3: <TITLE>File Suffix Bind Manager</TITLE>
2.6 frystyk 4: <!-- Changed by: Henrik Frystyk Nielsen, 31-Oct-1995 -->
2.1 frystyk 5: </HEAD>
6: <BODY>
7:
8: <H1>File Suffix Bind Manager</H1>
9:
10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16:
17: This module sets up the binding between a file Bind and a media type,
18: language, encoding etc. In a client application the Binds are used in
19: protocols that does not support media types etc., like FTP, and in
20: server applications they are used to make the bindings between the
21: server and the local file store that the server can serve to the rest
22: of the world (well almost). The <A HREF="HTFormat.html">HTFormat
23: module</A> holds this information against the accept headers received
24: in a request and uses if for format negotiation. All the binding
25: management can all be replace by a database interface. <P>
26:
27: This module is implemented by <A HREF="HTBind.c">HTBind.c</A>, and it
2.6 frystyk 28: is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C
29: 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
2.5 frystyk 43: HREF="HTReq.html#Library">HTLibInit() and HTLibTerminate()</A>.
2.1 frystyk 44:
45: <PRE>
2.6 frystyk 46: extern BOOL HTBind_init (void);
47: extern BOOL HTBind_deleteAll (void);
2.1 frystyk 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>
2.6 frystyk 56: extern void HTBind_caseSensitive (BOOL sensitive);
2.1 frystyk 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>
2.6 frystyk 65: extern CONST char *HTBind_delimiters (void);
66: extern void HTBind_setDelimiters (CONST char * new_suffixes);
2.1 frystyk 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>
2.6 frystyk 82: extern BOOL HTBind_add (CONST char * suffix,
83: CONST char * representation,
84: CONST char * encoding,
85: CONST char * language,
86: double value);
87:
88: extern BOOL HTBind_addType (CONST char * suffix,
2.7 ! frystyk 89: CONST char * format,
2.6 frystyk 90: double value);
91:
92: extern BOOL HTBind_addEncoding (CONST char * suffix,
93: CONST char * encoding,
94: double value);
95:
96: extern BOOL HTBind_addLanguage (CONST char * suffix,
97: CONST char * language,
98: double value);
2.1 frystyk 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.6 frystyk 124: extern char * HTBind_getSuffix (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>
2.6 frystyk 137: extern BOOL HTBind_getBindings (HTParentAnchor * anchor);
2.1 frystyk 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>
2.6 frystyk 149: extern BOOL HTBind_getFormat (CONST char * filename,
150: HTFormat * format,
151: HTEncoding * encoding,
152: HTLanguage * language,
153: double * quality);
2.1 frystyk 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:
2.6 frystyk 168: extern HTContentDescription * HTBind_getDescription (char * file);
2.1 frystyk 169: </PRE>
170:
171: End of declaration module
172:
173: <PRE>
174: #endif /* HTBIND_H */
175: </PRE>
176:
177: </BODY>
178: </HTML>
Webmaster