Annotation of libwww/Library/src/HTBind.html, revision 2.16
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>
17: This module sets up the binding between a file suffix and a media type, language,
18: encoding etc. In a client application the suffixes are used in protocols
19: that does not directly support media types etc., like FTP, and in server
20: applications they are used to make the bindings between the server and the
21: local file store that the server can serve to the rest of the world (well
22: almost). The <A HREF="HTFormat.html">HTFormat module</A> holds this information
23: against the accept headers received in a request and uses if for format
24: negotiation. All the binding management can all be replace by a database
25: interface.
26: <P>
27: This module is implemented by <A HREF="HTBind.c">HTBind.c</A>, and it is
2.15 frystyk 28: a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Sample Code
2.12 frystyk 29: Library</A>.
2.1 frystyk 30: <PRE>
31: #ifndef HTBIND_H
32: #define HTBIND_H
33:
34: #include "HTFormat.h"
35: #include "HTAnchor.h"
36: </PRE>
2.12 frystyk 37: <H2>
38: Initialization of the Module
39: </H2>
40: <P>
41: These functions must be called on startup and termination of the application.
42: This is done automatically by <A HREF="HTReq.html#Library">HTLibInit() and
43: HTLibTerminate()</A>.
2.1 frystyk 44: <PRE>
2.6 frystyk 45: extern BOOL HTBind_init (void);
46: extern BOOL HTBind_deleteAll (void);
2.1 frystyk 47: </PRE>
2.12 frystyk 48: <H2>
49: Case Sensitivity
50: </H2>
51: <P>
52: Should the search for suffixes be case sensitive or not? The default value
53: is <EM>case sensitive</EM>.
2.1 frystyk 54: <PRE>
2.6 frystyk 55: extern void HTBind_caseSensitive (BOOL sensitive);
2.1 frystyk 56: </PRE>
2.12 frystyk 57: <H2>
58: Suffix Delimiters
59: </H2>
60: <P>
61: Change the set of suffix delimiters. The default is a platform dependent
2.16 ! frystyk 62: set defined in the <A HREF="wwwsys.html">tcp module</A>.
2.1 frystyk 63: <PRE>
2.8 frystyk 64: extern const char *HTBind_delimiters (void);
65: extern void HTBind_setDelimiters (const char * new_suffixes);
2.1 frystyk 66: </PRE>
2.12 frystyk 67: <H2>
68: Set up Bindings Associated with a File Suffix
69: </H2>
70: <P>
2.10 frystyk 71: There are four types of bindings:
2.1 frystyk 72: <UL>
2.12 frystyk 73: <LI>
74: Content Type (media type)
75: <LI>
76: Language
77: <LI>
78: Content Encoding
79: <LI>
80: Content Transfer Encoding
2.1 frystyk 81: </UL>
2.12 frystyk 82: <P>
2.1 frystyk 83: And the associated set of methods is defined as:
84: <PRE>
2.8 frystyk 85: extern BOOL HTBind_add (const char * suffix,
86: const char * representation,
87: const char * encoding,
2.10 frystyk 88: const char * transfer,
2.8 frystyk 89: const char * language,
2.6 frystyk 90: double value);
91:
2.8 frystyk 92: extern BOOL HTBind_addType (const char * suffix,
93: const char * format,
2.6 frystyk 94: double value);
95:
2.8 frystyk 96: extern BOOL HTBind_addEncoding (const char * suffix,
97: const char * encoding,
2.6 frystyk 98: double value);
99:
2.10 frystyk 100: extern BOOL HTBind_addTransfer (const char * suffix,
101: const char * transfer,
102: double value);
103:
2.8 frystyk 104: extern BOOL HTBind_addLanguage (const char * suffix,
105: const char * language,
2.6 frystyk 106: double value);
2.1 frystyk 107: </PRE>
2.12 frystyk 108: <P>
109: The first method is a "super" method for binding information to a file suffic.
110: Any of the string values can be <CODE>NULL</CODE>. If filename suffix is
111: already defined its previous definition is overridden or modified. For example,
112: a <CODE>HTBind_setType</CODE> and <CODE>HTBind_setEncoding</CODE> can be
113: called with the same suffix.
114: <P>
115: Calling this with suffix set to "*" will set the default representation.
116: Calling this with suffix set to "*.*" will set the default representation
117: for unknown suffix files which contain a "."
118: <P>
119: <B>NOTE:</B> The suffixes <EM>can</EM> contain characters that must be escaped
120: in a URL. However, they should <EM>not</EM> be encoded when parsed as the
121: <CODE>suffix</CODE> parameter.
122: <H2>
123: Determine a suitable suffix
124: </H2>
125: <P>
126: Use the set of bindings to find a suitable suffix (or index) for a certain
127: combination of language, media type and encoding given in the anchor. Returns
128: a pointer to a suitable suffix string that must be freed by the caller. If
129: more than one suffix is found they are all concatenated. If no suffix is
130: found, NULL is returned.
2.1 frystyk 131: <PRE>
2.6 frystyk 132: extern char * HTBind_getSuffix (HTParentAnchor * anchor);
2.1 frystyk 133: </PRE>
2.12 frystyk 134: <H2>
135: Determine the content of an Anchor
136: </H2>
137: <P>
138: Use the set of bindings to find the combination of language, media type and
139: encoding of a given anchor. If more than one suffix is found they are all
140: searched. The last suffix has highest priority, the first one lowest. Returns
2.14 frystyk 141: the <A HREF="HTAnchor.html">HTAnchor object</A> with the representations
142: found. See also <CODE>HTBind_getFormat</CODE>
2.1 frystyk 143: <PRE>
2.14 frystyk 144: extern BOOL HTBind_getAnchorBindings (HTParentAnchor * anchor);
145: </PRE>
146: <H2>
147: Determine the content of a Response
148: </H2>
149: <P>
150: Use the set of bindings to find the combination of language, media type and
151: encoding of a given anchor. If more than one suffix is found they are all
152: searched. The last suffix has highest priority, the first one lowest. Returns
153: the <A HREF="HTResponse.html">HTResponse object</A> with the representations
154: found. See also <CODE>HTBind_getFormat</CODE>
155: <PRE>
156: extern BOOL HTBind_getResponseBindings (HTResponse * response,
157: const char * url);
2.1 frystyk 158: </PRE>
2.12 frystyk 159: <H2>
160: Determine the content of File
161: </H2>
162: <P>
163: Use the set of bindings to find the combination of language, media type and
164: encoding of a given anchor. If more than one suffix is found they are all
165: searched. The last suffix has highest priority, the first one lowest. Returns
166: the format, encoding, and language found. See also
2.1 frystyk 167: <CODE>HTBind_getBindings</CODE>.
168: <PRE>
2.10 frystyk 169: extern BOOL HTBind_getFormat (const char * filename,
170: HTFormat * format,
171: HTEncoding * enc,
2.11 frystyk 172: HTEncoding * cte,
2.10 frystyk 173: HTLanguage * lang,
174: double * quality);
2.1 frystyk 175: </PRE>
2.12 frystyk 176: <P>
2.1 frystyk 177: End of declaration module
178: <PRE>
179: #endif /* HTBIND_H */
180: </PRE>
2.12 frystyk 181: <P>
182: <HR>
2.10 frystyk 183: <ADDRESS>
2.16 ! frystyk 184: @(#) $Id: HTBind.html,v 2.15 1997/02/16 18:42:01 frystyk Exp $
2.10 frystyk 185: </ADDRESS>
2.12 frystyk 186: </BODY></HTML>
Webmaster