File:  [Public] / libwww / Library / src / HTBind.html
Revision 2.13: download - view: text, annotated - select for diffs
Sat Jun 8 01:52:02 1996 UTC (27 years, 11 months ago) by frystyk
Branches: MAIN
CVS tags: Release-5-0, Release-4-1b5, Release-4-1b4, Release-4-1b3, Release-4-1b1, HEAD
Version 4.1beta1

<HTML>
<HEAD>
<!-- Changed by: Henrik Frystyk Nielsen,  5-Jun-1996 -->
  <TITLE>W3C Reference Library libwww File Suffix Binding</TITLE>
</HEAD>
<BODY>
<H1>
  File Suffix Binding Manager
</H1>
<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
This module sets up the binding between a file suffix and a media type, language,
encoding etc. In a client application the suffixes are used in protocols
that does not directly support media types etc., like FTP, and in server
applications they are used to make the bindings between the server and the
local file store that the server can serve to the rest of the world (well
almost). The <A HREF="HTFormat.html">HTFormat module</A> holds this information
against the accept headers received in a request and uses if for format
negotiation. All the binding management can all be replace by a database
interface.
<P>
This module is implemented by <A HREF="HTBind.c">HTBind.c</A>, and it is
a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Reference
Library</A>.
<PRE>
#ifndef HTBIND_H
#define HTBIND_H

#include "HTFormat.h"
#include "HTAnchor.h"
</PRE>
<H2>
  Initialization of the Module
</H2>
<P>
These functions must be called on startup and termination of the application.
This is done automatically by <A HREF="HTReq.html#Library">HTLibInit() and
HTLibTerminate()</A>.
<PRE>
extern BOOL HTBind_init		(void);
extern BOOL HTBind_deleteAll	(void);
</PRE>
<H2>
  Case Sensitivity
</H2>
<P>
Should the search for suffixes be case sensitive or not? The default value
is <EM>case sensitive</EM>.
<PRE>
extern void HTBind_caseSensitive	(BOOL sensitive);
</PRE>
<H2>
  Suffix Delimiters
</H2>
<P>
Change the set of suffix delimiters. The default is a platform dependent
set defined in the <A HREF="sysdep.html">tcp module</A>.
<PRE>
extern const char *HTBind_delimiters	(void);
extern void HTBind_setDelimiters	(const char * new_suffixes);
</PRE>
<H2>
  Set up Bindings Associated with a File Suffix
</H2>
<P>
There are four types of bindings:
<UL>
  <LI>
    Content Type (media type)
  <LI>
    Language
  <LI>
    Content Encoding
  <LI>
    Content Transfer Encoding
</UL>
<P>
And the associated set of methods is defined as:
<PRE>
extern BOOL HTBind_add		(const char *	suffix,
				 const char *	representation,
				 const char *	encoding,
				 const char *	transfer,
				 const char *	language,
				 double		value);

extern BOOL HTBind_addType	(const char *	suffix,
				 const char *	format,
				 double		value);

extern BOOL HTBind_addEncoding	(const char *	suffix,
				 const char *	encoding,
				 double		value);

extern BOOL HTBind_addTransfer	(const char *	suffix,
				 const char *	transfer,
				 double		value);

extern BOOL HTBind_addLanguage	(const char *	suffix,
				 const char *	language,
				 double		value);
</PRE>
<P>
The first method is a "super" method for binding information to a file suffic.
Any of the string values can be <CODE>NULL</CODE>. If filename suffix is
already defined its previous definition is overridden or modified. For example,
a <CODE>HTBind_setType</CODE> and <CODE>HTBind_setEncoding</CODE> can be
called with the same suffix.
<P>
Calling this with suffix set to "*" will set the default representation.
Calling this with suffix set to "*.*" will set the default representation
for unknown suffix files which contain a "."
<P>
<B>NOTE:</B> The suffixes <EM>can</EM> contain characters that must be escaped
in a URL. However, they should <EM>not</EM> be encoded when parsed as the
<CODE>suffix</CODE> parameter.
<H2>
  Determine a suitable suffix
</H2>
<P>
Use the set of bindings to find a suitable suffix (or index) for a certain
combination of language, media type and encoding given in the anchor. Returns
a pointer to a suitable suffix string that must be freed by the caller. If
more than one suffix is found they are all concatenated. If no suffix is
found, NULL is returned.
<PRE>
extern char * HTBind_getSuffix	(HTParentAnchor * anchor);
</PRE>
<H2>
  Determine the content of an Anchor
</H2>
<P>
Use the set of bindings to find the combination of language, media type and
encoding of a given anchor. If more than one suffix is found they are all
searched. The last suffix has highest priority, the first one lowest. Returns
the anchor object with the representations found. See also
<CODE>HTBind_getFormat</CODE>
<PRE>
extern BOOL HTBind_getBindings	(HTParentAnchor * anchor);
</PRE>
<H2>
  Determine the content of File
</H2>
<P>
Use the set of bindings to find the combination of language, media type and
encoding of a given anchor. If more than one suffix is found they are all
searched. The last suffix has highest priority, the first one lowest. Returns
the format, encoding, and language found. See also
<CODE>HTBind_getBindings</CODE>.
<PRE>
extern BOOL HTBind_getFormat (const char *	filename,
			      HTFormat *	format,
			      HTEncoding *	enc,
			      HTEncoding *	cte,
			      HTLanguage *	lang,
			      double *		quality);
</PRE>
<P>
End of declaration module
<PRE>
#endif /* HTBIND_H */
</PRE>
<P>
  <HR>
<ADDRESS>
  @(#) $Id: HTBind.html,v 2.13 1996/06/08 01:52:02 frystyk Exp $
</ADDRESS>
</BODY></HTML>

Webmaster