Annotation of libwww/Library/src/HTBind.html, revision 2.19
2.1 frystyk 1: <HTML>
2: <HEAD>
2.14 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 5-Jun-1996 -->
2.15 frystyk 4: <TITLE>W3C Sample Code Library libwww File Suffix Binding</TITLE>
2.1 frystyk 5: </HEAD>
6: <BODY>
2.12 frystyk 7: <H1>
8: File Suffix Binding Manager
9: </H1>
2.1 frystyk 10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.12 frystyk 16: <P>
2.18 frystyk 17: The preferences that we described in section
18: <A HREF="../User/Using/Prefs.html">Request Preferences</A> did not mention
19: what libwww should do if it doesn't know the data format of a document. In
20: many protocols this information is provided by the remote server. Typical
21: examples are MIME like protocols where the metainformation such as the
22: <EM>Content-Type</EM> and the <EM>Content-Language</EM> is provided together
23: with the document. However, applications often have access to the local file
24: system using <B>file</B> URLs which in general do not keep any or at least
25: very little information of the file type. It is therefore required to have
26: some kind of binding between the file system and the preferences registered
27: in the Library which provides this mateinformation about the object.
28: <P>
29: Often files in a file system is classified by some sort of a suffix, for
30: example, <TT>GIF</TT> files are often ending in <EM>.gif</EM>, text files
31: in <EM>.txt</EM> etc. This binding is not static and it is therefore required
32: to have a dynamic binding just like the preferences themselves. An example
33: of the latter is HTML files which on most Unix systems end in <EM>.html</EM>
34: whereas they on many MS-DOS based systems end in <EM>.htm</EM>.
35: <P>
36: This module provides a generic binding mechanism between a file and its
37: representation internally in libwww. It is not limited to simple file suffix
38: classification but can also be used in more advanced environments using data
39: bases etc. However, at this point we are interested in how we can register
40: bindings between file suffixes and for example content types, content languages
41: etc. The Bind manager is born with a certain knowledge about the set of
42: delimiters but more can be added to provide the functionality desired.
43: <P>
44: All the binding management could of course be replaced by a database interface.
2.12 frystyk 45: <P>
46: This module is implemented by <A HREF="HTBind.c">HTBind.c</A>, and it is
2.17 frystyk 47: a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
2.12 frystyk 48: Library</A>.
2.1 frystyk 49: <PRE>
50: #ifndef HTBIND_H
51: #define HTBIND_H
52:
53: #include "HTFormat.h"
54: #include "HTAnchor.h"
2.19 ! vbancrof 55:
! 56: #ifdef __cplusplus
! 57: extern "C" {
! 58: #endif
! 59:
2.1 frystyk 60: </PRE>
2.12 frystyk 61: <H2>
62: Initialization of the Module
63: </H2>
64: <P>
65: These functions must be called on startup and termination of the application.
66: This is done automatically by <A HREF="HTReq.html#Library">HTLibInit() and
67: HTLibTerminate()</A>.
2.1 frystyk 68: <PRE>
2.6 frystyk 69: extern BOOL HTBind_init (void);
70: extern BOOL HTBind_deleteAll (void);
2.1 frystyk 71: </PRE>
2.12 frystyk 72: <H2>
73: Case Sensitivity
74: </H2>
75: <P>
76: Should the search for suffixes be case sensitive or not? The default value
77: is <EM>case sensitive</EM>.
2.1 frystyk 78: <PRE>
2.6 frystyk 79: extern void HTBind_caseSensitive (BOOL sensitive);
2.1 frystyk 80: </PRE>
2.12 frystyk 81: <H2>
82: Suffix Delimiters
83: </H2>
84: <P>
85: Change the set of suffix delimiters. The default is a platform dependent
2.16 frystyk 86: set defined in the <A HREF="wwwsys.html">tcp module</A>.
2.1 frystyk 87: <PRE>
2.8 frystyk 88: extern const char *HTBind_delimiters (void);
89: extern void HTBind_setDelimiters (const char * new_suffixes);
2.1 frystyk 90: </PRE>
2.12 frystyk 91: <H2>
92: Set up Bindings Associated with a File Suffix
93: </H2>
94: <P>
2.10 frystyk 95: There are four types of bindings:
2.1 frystyk 96: <UL>
2.12 frystyk 97: <LI>
98: Content Type (media type)
99: <LI>
100: Language
101: <LI>
102: Content Encoding
103: <LI>
104: Content Transfer Encoding
2.1 frystyk 105: </UL>
2.12 frystyk 106: <P>
2.1 frystyk 107: And the associated set of methods is defined as:
108: <PRE>
2.8 frystyk 109: extern BOOL HTBind_add (const char * suffix,
110: const char * representation,
111: const char * encoding,
2.10 frystyk 112: const char * transfer,
2.8 frystyk 113: const char * language,
2.6 frystyk 114: double value);
115:
2.8 frystyk 116: extern BOOL HTBind_addType (const char * suffix,
117: const char * format,
2.6 frystyk 118: double value);
119:
2.8 frystyk 120: extern BOOL HTBind_addEncoding (const char * suffix,
121: const char * encoding,
2.6 frystyk 122: double value);
123:
2.10 frystyk 124: extern BOOL HTBind_addTransfer (const char * suffix,
125: const char * transfer,
126: double value);
127:
2.8 frystyk 128: extern BOOL HTBind_addLanguage (const char * suffix,
129: const char * language,
2.6 frystyk 130: double value);
2.1 frystyk 131: </PRE>
2.12 frystyk 132: <P>
133: The first method is a "super" method for binding information to a file suffic.
134: Any of the string values can be <CODE>NULL</CODE>. If filename suffix is
135: already defined its previous definition is overridden or modified. For example,
136: a <CODE>HTBind_setType</CODE> and <CODE>HTBind_setEncoding</CODE> can be
137: called with the same suffix.
138: <P>
139: Calling this with suffix set to "*" will set the default representation.
140: Calling this with suffix set to "*.*" will set the default representation
141: for unknown suffix files which contain a "."
142: <P>
143: <B>NOTE:</B> The suffixes <EM>can</EM> contain characters that must be escaped
144: in a URL. However, they should <EM>not</EM> be encoded when parsed as the
145: <CODE>suffix</CODE> parameter.
146: <H2>
147: Determine a suitable suffix
148: </H2>
149: <P>
150: Use the set of bindings to find a suitable suffix (or index) for a certain
151: combination of language, media type and encoding given in the anchor. Returns
152: a pointer to a suitable suffix string that must be freed by the caller. If
153: more than one suffix is found they are all concatenated. If no suffix is
154: found, NULL is returned.
2.1 frystyk 155: <PRE>
2.6 frystyk 156: extern char * HTBind_getSuffix (HTParentAnchor * anchor);
2.1 frystyk 157: </PRE>
2.12 frystyk 158: <H2>
159: Determine the content of an Anchor
160: </H2>
161: <P>
162: Use the set of bindings to find the combination of language, media type and
163: encoding of a given anchor. If more than one suffix is found they are all
164: searched. The last suffix has highest priority, the first one lowest. Returns
2.14 frystyk 165: the <A HREF="HTAnchor.html">HTAnchor object</A> with the representations
166: found. See also <CODE>HTBind_getFormat</CODE>
2.1 frystyk 167: <PRE>
2.14 frystyk 168: extern BOOL HTBind_getAnchorBindings (HTParentAnchor * anchor);
169: </PRE>
170: <H2>
171: Determine the content of a Response
172: </H2>
173: <P>
174: Use the set of bindings to find the combination of language, media type and
175: encoding of a given anchor. If more than one suffix is found they are all
176: searched. The last suffix has highest priority, the first one lowest. Returns
177: the <A HREF="HTResponse.html">HTResponse object</A> with the representations
178: found. See also <CODE>HTBind_getFormat</CODE>
179: <PRE>
180: extern BOOL HTBind_getResponseBindings (HTResponse * response,
181: const char * url);
2.1 frystyk 182: </PRE>
2.12 frystyk 183: <H2>
184: Determine the content of File
185: </H2>
186: <P>
187: Use the set of bindings to find the combination of language, media type and
188: encoding of a given anchor. If more than one suffix is found they are all
189: searched. The last suffix has highest priority, the first one lowest. Returns
190: the format, encoding, and language found. See also
2.1 frystyk 191: <CODE>HTBind_getBindings</CODE>.
192: <PRE>
2.10 frystyk 193: extern BOOL HTBind_getFormat (const char * filename,
194: HTFormat * format,
195: HTEncoding * enc,
2.11 frystyk 196: HTEncoding * cte,
2.10 frystyk 197: HTLanguage * lang,
198: double * quality);
2.1 frystyk 199: </PRE>
2.12 frystyk 200: <P>
2.1 frystyk 201: End of declaration module
202: <PRE>
2.19 ! vbancrof 203: #ifdef __cplusplus
! 204: }
! 205: #endif
! 206:
2.1 frystyk 207: #endif /* HTBIND_H */
208: </PRE>
2.12 frystyk 209: <P>
210: <HR>
2.10 frystyk 211: <ADDRESS>
2.19 ! vbancrof 212: @(#) $Id: HTBind.html,v 2.18 1999/06/30 21:05:13 frystyk Exp $
2.10 frystyk 213: </ADDRESS>
2.12 frystyk 214: </BODY></HTML>
Webmaster