Annotation of libwww/Library/src/HTFormat.html, revision 2.86
2.10 timbl 1: <HTML>
2: <HEAD>
2.71 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 15-Jul-1996 -->
2.75 frystyk 4: <TITLE>W3C Sample Code Library libwww Stream Pipe Manager</TITLE>
2.10 timbl 5: </HEAD>
2.1 timbl 6: <BODY>
2.67 frystyk 7: <H1>
2.68 frystyk 8: The Stream Pipe Manager
2.67 frystyk 9: </H1>
2.33 frystyk 10: <PRE>
11: /*
2.41 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.33 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.67 frystyk 16: <P>
2.68 frystyk 17: The Stream Pipe Manager is responsible for setting up the stream pipe from
18: the <A HREF="HTChannl.html">Channel Object</A> to the
19: <A HREF="HTReq.html">Request Object</A> when data is arriving, for example
20: as a response to s <A HREF="HTTP.html">HTTP</A> <B>Get</B> request. As data
21: arrives, we start to parse it and the more we know the more we can build
22: up our stream pipe. For example, in the case of HTTP, we first have a stream
23: that can parse the HTTP response line containing "<CODE>200 OK</CODE>". Then
24: we have a <A HREF="HTMIME.html">MIME parser</A> for handling the MIME headers.
25: When the MIME headers have been parsed, we know the content type and any
26: encoding of the MIME body. If we need to decode a chunked encoding then we
27: set up a chunked decoder, and if we have to parse a HTML object then we set
28: up a HTML parser.
2.67 frystyk 29: <P>
30: The Format Manager is also responsible for keeping track of the
31: "<I>preferences</I>" of the application and/or user. It is an integral part
32: of the Web and HTTP, that the client application can express its preferences
33: as a set of "accept" headers in a HTTP request. This task is highly related
34: to the task mentioned above as we there use the modules that are registered
35: and here tell the remote server what we are capable of doing and what we
36: would prefer.
37: <P>
38: <B>Note</B>: The library <B>core</B> does not define any default decoders
39: or parsers - they are all considered part of the application. The library
40: comes with a default set of parsers including the ones mentioned above which
41: can be initiated using the functions in <A HREF="HTInit.html">HTInit
42: module</A>. There are different initialization functions for content type
43: parsers and content encodings respectively.
44: <P>
45: <UL>
46: <LI>
47: <A HREF="#type">Content Type Converters and Presenters</A>
48: <LI>
49: <A HREF="#encoding">Content Encoders and Decoders</A>
50: <LI>
51: <A HREF="#charset">Content Charsets</A>
52: <LI>
53: <A HREF="#language">Natural Languages</A>
54: </UL>
55: <P>
56: The application can assign its preferences in two ways: either <I>locally</I>
57: to a single request or <I>globally</I> to all requests. The local assignment
58: can either <I>add to </I>or <I>override</I> the global settings depending
59: on how they are registered. All local registration is handled by the
60: <A HREF="HTReq.html">Request Object</A> and the global registration is handled
2.73 frystyk 61: by the Format Manager.
2.67 frystyk 62: <P>
63: This module is implemented by <A HREF="HTFormat.c">HTFormat.c</A>, and it
2.80 frystyk 64: is a part of the <A HREF="http://www.w3.org/Library/">W3C Sample Code
2.67 frystyk 65: Library</A>.
2.31 frystyk 66: <PRE>
67: #ifndef HTFORMAT_H
2.1 timbl 68: #define HTFORMAT_H
69:
2.63 frystyk 70: #include "<A HREF="HTUtils.html">HTUtils.h</A>"
71: #include "<A HREF="HTStream.html">HTStream.h</A>"
72: #include "<A HREF="HTAtom.html">HTAtom.h</A>"
73: #include "<A HREF="HTList.html">HTList.h</A>"
74: #include "<A HREF="HTAnchor.html">HTAnchor.h</A>"
75: #include "<A HREF="HTReq.html">HTReq.h</A>"
2.86 ! vbancrof 76:
! 77: #ifdef __cplusplus
! 78: extern "C" {
! 79: #endif
2.31 frystyk 80: </PRE>
2.67 frystyk 81: <H2>
2.73 frystyk 82: <A NAME="type">Converters and Presenters</A>
2.67 frystyk 83: </H2>
84: <P>
85: All content type converters are subclassed from the Generic stream objetc.
86: That way, we allow the application to do very fast progressive display of
87: incoming data. In other words, the stream model of the Library provides data
88: as soon as it arrives from the network, the application does not have to
89: wait until the whole document has been down loaded before it starts parsing
90: it.
91: <H3>
92: Predefined Content Types
93: </H3>
94: <P>
95: These macros (which used to be constants) define some basic internally referenced
96: representations. The <CODE>www/xxx</CODE> ones are of course not MIME standard.
97: They are internal representations used in the Library but they can't be exported
98: to other apps!
2.28 frystyk 99: <PRE>
2.82 frystyk 100: #define WWW_INTERNAL HTAtom_for("www/*") /* All internal formats */
101: </PRE>
102: <P>
103: <CODE>WWW_INTERNAL</CODE> represent all internal formats. This can for example
104: be used to match using the <A HREF="HTWWWStr.html">HTMIMEMatch(...)</A>.
105: <PRE>
2.57 frystyk 106: #define WWW_RAW HTAtom_for("www/void") /* Raw output from Protocol */
2.28 frystyk 107: </PRE>
2.67 frystyk 108: <P>
109: <CODE>WWW_RAW</CODE> is an output format which leaves the input untouched
110: <EM>exactly</EM> as it is received by the protocol module. For example, in
111: the case of FTP, this format returns raw ASCII objects for directory listings;
112: for HTTP, everything including the header is returned, for Gopher, a raw
113: ASCII object is returned for a menu etc.
114: <PRE>
115: #define WWW_SOURCE HTAtom_for("*/*")
116: </PRE>
117: <P>
118: <CODE>WWW_SOURCE</CODE> is an output format which leaves the input untouched
119: <EM>exactly</EM> as it is received by the protocol module <B>IF</B> not a
120: suitable converter has been registered with a quality factor higher than
121: 1 (for example 2). In this case the <EM>SUPER CONVERTER</EM> is preferred
122: for the raw output. This can be used as a filter effect that allows conversion
123: from, for example raw FTPdirectory listings into HTML but passes a MIME body
124: untouched.
125: <PRE>
126: #define WWW_PRESENT HTAtom_for("www/present")
127: </PRE>
128: <P>
129: <CODE>WWW_PRESENT</CODE> represents the user's perception of the document.
130: If you convert to <CODE>WWW_PRESENT</CODE>, you present the material to the
131: user.
2.58 frystyk 132: <PRE>
133: #define WWW_DEBUG HTAtom_for("www/debug")
134: </PRE>
2.67 frystyk 135: <P>
136: <CODE>WWW_DEBUG</CODE> represents the user's perception of debug information,
137: for example sent as a HTML document in a HTTP redirection message.
2.28 frystyk 138: <PRE>
2.52 frystyk 139: #define WWW_UNKNOWN HTAtom_for("www/unknown")
2.28 frystyk 140: </PRE>
2.67 frystyk 141: <P>
142: <CODE>WWW_UNKNOWN</CODE> is a really unknown type. It differs from the real
143: MIME type <EM>"application/octet-stream"</EM> in that we haven't even tried
144: to figure out the content type at this point.
2.71 frystyk 145: <PRE>
2.72 frystyk 146: #define WWW_CACHE HTAtom_for("www/cache")
147: #define WWW_CACHE_APPEND HTAtom_for("www/cache-append")
2.71 frystyk 148: </PRE>
149: <P>
150: <CODE>WWW_CACHE</CODE> is the internal content-type designated for a persistent
2.72 frystyk 151: cache module which can store the object to local storage. The cache append
152: format is special in that we append information to an already existing cache
153: entry. This can happen if we have issued a <CODE>If-Range </CODE>request
154: and got back a "206 Partial response".
2.67 frystyk 155: <P>
2.31 frystyk 156: These are regular MIME types defined. Others can be added!
2.28 frystyk 157: <PRE>
2.52 frystyk 158: #define WWW_HTML HTAtom_for("text/html")
2.28 frystyk 159: #define WWW_PLAINTEXT HTAtom_for("text/plain")
2.69 frystyk 160: #define WWW_FORM HTAtom_for("application/x-www-form-urlencoded")
2.52 frystyk 161:
162: #define WWW_MIME HTAtom_for("message/rfc822")
2.60 frystyk 163: #define WWW_MIME_HEAD HTAtom_for("message/x-rfc822-head")
2.65 frystyk 164: #define WWW_MIME_FOOT HTAtom_for("message/x-rfc822-foot")
2.72 frystyk 165: #define WWW_MIME_PART HTAtom_for("message/x-rfc822-partial")
2.76 frystyk 166: #define WWW_MIME_CONT HTAtom_for("message/x-rfc822-cont")
2.84 frystyk 167: #define WWW_MIME_UPGRADE HTAtom_for("message/x-rfc822-upgrade")
2.52 frystyk 168:
2.85 kahan 169: #define WWW_MIME_COPYHEADERS HTAtom_for("www/x-rfc822-headers")
170:
2.10 timbl 171: #define WWW_AUDIO HTAtom_for("audio/basic")
2.52 frystyk 172:
2.26 frystyk 173: #define WWW_VIDEO HTAtom_for("video/mpeg")
2.52 frystyk 174:
2.70 frystyk 175: #define WWW_GIF HTAtom_for("image/gif")
2.63 frystyk 176: #define WWW_JPEG HTAtom_for("image/jpeg")
177: #define WWW_TIFF HTAtom_for("image/tiff")
2.52 frystyk 178: #define WWW_PNG HTAtom_for("image/png")
179:
180: #define WWW_BINARY HTAtom_for("application/octet-stream")
181: #define WWW_POSTSCRIPT HTAtom_for("application/postscript")
182: #define WWW_RICHTEXT HTAtom_for("application/rtf")
2.48 frystyk 183: </PRE>
2.67 frystyk 184: <P>
185: We also have some MIME types that come from the various protocols when we
186: convert from ASCII to HTML.
2.48 frystyk 187: <PRE>
188: #define WWW_GOPHER_MENU HTAtom_for("text/x-gopher")
2.53 frystyk 189: #define WWW_CSO_SEARCH HTAtom_for("text/x-cso")
2.48 frystyk 190:
191: #define WWW_FTP_LNST HTAtom_for("text/x-ftp-lnst")
192: #define WWW_FTP_LIST HTAtom_for("text/x-ftp-list")
193:
194: #define WWW_NNTP_LIST HTAtom_for("text/x-nntp-list")
195: #define WWW_NNTP_OVER HTAtom_for("text/x-nntp-over")
196: #define WWW_NNTP_HEAD HTAtom_for("text/x-nntp-head")
2.59 frystyk 197:
198: #define WWW_HTTP HTAtom_for("text/x-http")
2.55 frystyk 199: </PRE>
2.67 frystyk 200: <P>
201: Finally we have defined a special format for our RULE files as they can be
202: handled by a special converter.
2.73 frystyk 203: <PRE>#define WWW_RULES HTAtom_for("application/x-www-rules")
204: </PRE>
205: <H3>
206: The Quality Factor
207: </H3>
208: <P>
209: Characteristic for all preferences is that there is a quality factor associated
210: with each member. The quality factor is a real number between 0 and 1 with
211: 0 meaning "very bad" and 1 means "perfect". By registering a natural language
212: or any or other preference in this group together with a quality factor you
213: can specify "how well the preference is handled" either by the application
214: or by the user. In the case of the user the quality factor of a natural language
215: is how well the user understands the language. In my case, the quality factors
216: for, for example Greek would be close to zero and 1 for Danish (nothing bad
217: said about Greek!).
218: <P>
219: It is a bit different for converters where it is often the application's
220: ability of handling the data format rather than the user's perception. As
221: an example it is often faster to use a converter than a presenter as it takes
222: time to launch the external application and libwww can not use progressive
223: display mechanisms which is often the case for converters. Therefore, as
224: an example, if we capable of handling an image in <EM>png</EM> format inline
225: but rely on an external viewer for presenting postscript, we might set up
226: the following list:
227: <P>
228: <SAMP>HTConversion_add (converters, "image", "www/present", GifPresenter,
229: <B>1.0</B>, 0.0, 0.0);<BR>
230: HTPresentation_add (presenters, "application/postscript", "ghostview %s",
231: NULL, <B>0.5</B>, 0.0, 0.0);></SAMP>
232: <P>
233: where the gif converter is registered with a quality factor of <B>1.0</B>
234: and the postscript presenter with a quality factor of <B>0.5</B>.Register
235: Presenters
236: <H3>
237: The Converter Class
238: </H3>
239: <P>
240: A <CODE>converter</CODE> is a stream with a special set of parameters and
241: which is registered as capable of converting from a MIME type to something
242: else (maybe another MIME-type). A converter is defined to be a function returning
243: a stream and accepting the following parameters. The content type elements
244: are atoms for which we have defined a prototype.
2.55 frystyk 245: <PRE>
2.73 frystyk 246: typedef HTStream * HTConverter (HTRequest * request,
247: void * param,
248: HTFormat input_format,
249: HTFormat output_format,
250: HTStream * output_stream);
251:
252: extern void HTConversion_add (HTList * conversions,
253: const char * rep_in,
254: const char * rep_out,
255: HTConverter * converter,
256: double quality,
257: double secs,
258: double secs_per_byte);
259:
260: extern void HTConversion_deleteAll (HTList * list);
2.28 frystyk 261: </PRE>
2.67 frystyk 262: <H3>
2.73 frystyk 263: The Presenter Class
2.67 frystyk 264: </H3>
265: <P>
2.73 frystyk 266: A <CODE>presenter</CODE> is a module (possibly an external program) which
267: can present a graphic object of a certain MIME type to the user. That is,
268: <CODE>presenters</CODE> are normally used to present objects that the
269: <CODE>converters</CODE> are not able to handle. Data is transferred to the
2.83 frystyk 270: external program using a special "presenter stream" which for example can
271: use the local disk to transfer the data from libwww to the external program.
272: <P>
273: Libwww provides a default <A HREF="HTFWrite.html">HTSaveAndExecute</A>
274: stream which you may want to use for this purpose. However, any stream
275: that is of type <CODE>HTConverter</CODE> will do. You can manage the
276: special presenter stream using the following methods:
277: <PRE>
278: extern void HTPresentation_setConverter (HTConverter * pconv);
279: extern HTConverter * HTPresentation_converter (void);
280: </PRE>
281: Both presenters and converters are of the type
2.73 frystyk 282: <A HREF="#converter">HTConverter</A>.
2.31 frystyk 283: <PRE>
2.49 frystyk 284: extern void HTPresentation_add (HTList * conversions,
2.83 frystyk 285: const char * representation,
2.61 frystyk 286: const char * command,
287: const char * test_command,
2.49 frystyk 288: double quality,
289: double secs,
290: double secs_per_byte);
2.1 timbl 291:
2.50 frystyk 292: extern void HTPresentation_deleteAll (HTList * list);
293: </PRE>
2.67 frystyk 294: <H3>
2.73 frystyk 295: Basic Converters
2.67 frystyk 296: </H3>
297: <P>
2.73 frystyk 298: We have a small set of basic converters that can be hooked in anywhere. They
299: don't "convert" anything but are nice to have.
2.79 frystyk 300: <PRE>
301: extern HTConverter HTThroughLine;
2.73 frystyk 302: extern HTConverter HTBlackHoleConverter;
2.79 frystyk 303: extern HTConverter HTSaveConverter;
2.42 frystyk 304: </PRE>
2.67 frystyk 305: <H2>
306: <A NAME="encoding">Content and Transfer Encoders and Decoders</A>
307: </H2>
308: <P>
309: Content codins are transformations applied to an entity object after it was
310: created in its original form. The Library handles two types of codings:
2.64 frystyk 311: <DL>
2.67 frystyk 312: <DT>
313: <B>Content Codings</B>
314: <DD>
315: Content codings values indicate an encoding transformation that has been
316: applied to a resource. Content cosings are primarily used to allow a document
317: to be compressed or encrypted without loosing the identity of its underlying
318: media type.
319: <DT>
320: <B>Content Transfer Codings</B>
321: <DD>
322: Content transfer codings values are used to indicate an encoding transformation
323: that has been, can be, or may be need to be applied to an enity body in order
324: to ensure safe transport through the network. This differs from a content
325: coding in that the transfer coding is a property of the message, not the
326: original message.
2.64 frystyk 327: </DL>
2.67 frystyk 328: <P>
329: Both types of encodings use the same registration mechanism in the Library
330: which we describe below:
331: <H3>
332: Encoders and Decoders
333: </H3>
334: <P>
335: <EM>Encoders</EM> and <EM>decoders</EM> are subclassed from the
336: <A HREF="HTStream.html">generic stream class</A>. <EM>Encoders</EM> are capable
337: of adding a content coding to a data object and <EM>decoders</EM> can remove
338: a content coding.
2.50 frystyk 339: <PRE>
2.64 frystyk 340: typedef HTStream * HTCoder (HTRequest * request,
341: void * param,
342: HTEncoding coding,
343: HTStream * target);
2.50 frystyk 344: </PRE>
2.67 frystyk 345: <P>
346: The <EM>encoding</EM> is the name of the encoding mechanism reporesented
347: as an <A HREF="HTAtom.html">atom</A>, for example "zip", "chunked", etc.
348: Encodings are registered in lists and content encodings are separated from
349: transfer encodings by registering them in different lists.
350: <H3>
2.81 frystyk 351: Basic Encoders
352: </H3>
353: <P>
354: We have a small set of basic coders that can be hooked in anywhere.
355: <PRE>
356: extern HTCoder HTIdentityCoding;
357: </PRE>
358: <H3>
2.67 frystyk 359: The HTCoding Object
360: </H3>
361: <P>
362: The <EM>HTCoding</EM> object represents a registered encoding together with
363: a encoder and a decoder.
2.63 frystyk 364: <PRE>
2.64 frystyk 365: typedef struct _HTCoding HTCoding;
2.63 frystyk 366: </PRE>
2.67 frystyk 367: <P>
368: Predefined Coding Types We have a set of pre defined atoms for various types
369: of content encodings and transfer encodings. "chunked" is not exactly in
370: the same group as the other encodings such as "binary" but it really doesn't
371: make any difference as it is just a matter of how the words are chosen. The
372: first three transfer encodings are actually not encodings - they are just
373: left overs from brain dead mail systems.
2.42 frystyk 374: <PRE>
2.79 frystyk 375: #define WWW_CODING_7BIT HTAtom_for("7bit")
376: #define WWW_CODING_8BIT HTAtom_for("8bit")
377: #define WWW_CODING_BINARY HTAtom_for("binary")
378: #define WWW_CODING_IDENTITY HTAtom_for("identity")
2.64 frystyk 379:
2.79 frystyk 380: #define WWW_CODING_BASE64 HTAtom_for("base64")
381: #define WWW_CODING_MACBINHEX HTAtom_for("macbinhex")
382: #define WWW_CODING_CHUNKED HTAtom_for("chunked")
2.63 frystyk 383:
2.79 frystyk 384: #define WWW_CODING_COMPRESS HTAtom_for("compress")
385: #define WWW_CODING_GZIP HTAtom_for("gzip")
386: #define WWW_CODING_DEFLATE HTAtom_for("deflate")
2.42 frystyk 387: </PRE>
2.67 frystyk 388: <H3>
389: Register Content Coders
390: </H3>
391: <P>
2.73 frystyk 392: Some documents are not send in their original data obejct but is encoded
393: in some way. On the Web this is mostly some kind of compression but other
394: encodings for example base 64 can be encountered when talking to NNTP servers
395: etc. Just as for the other preferences, an application can register a supported
396: encoders or decodes as a list. Encoders and decoders are registered in the
397: same way with no differentiation whether it is a encoder or a decoder:
2.42 frystyk 398: <PRE>
2.64 frystyk 399: extern BOOL HTCoding_add (HTList * list,
400: const char * encoding,
401: HTCoder * encoder,
402: HTCoder * decoder,
403: double quality);
2.63 frystyk 404:
2.64 frystyk 405: extern void HTCoding_deleteAll (HTList * list);
2.42 frystyk 406:
2.64 frystyk 407: extern const char * HTCoding_name (HTCoding * me);
2.77 frystyk 408:
409: extern double HTCoding_quality (HTCoding * me);
2.42 frystyk 410: </PRE>
2.67 frystyk 411: <H2>
412: <A NAME="charset">Content Charsets</A>
413: </H2>
2.73 frystyk 414: <P>
415: As the Web reaches all parts of the Internet there are more and more documents
416: written in languages which contains characters not included in the ISO-8859-1
417: character set. A consequence of this the set of characters sets is often
418: tightly connected with the natural language. libwww does not directly support
419: other character sets but in case an application is capable of handling
420: alternative sets it can register these as preferred character sets along
421: with a quality factor just as all the other preferences in this section.
422: <PRE>extern void HTCharset_add (HTList * list, const char * charset, double quality);
2.42 frystyk 423: </PRE>
2.73 frystyk 424: <PRE>typedef struct _HTAcceptNode {
2.63 frystyk 425: HTAtom * atom;
426: double quality;
427: } HTAcceptNode;
428: </PRE>
429: <PRE>
2.50 frystyk 430: extern void HTCharset_deleteAll (HTList * list);
431: </PRE>
2.67 frystyk 432: <H2>
433: <A NAME="language">Content Languages</A>
434: </H2>
2.73 frystyk 435: <P>
436: The preferred natural language or languages is in almost all situations dependent
437: on the individual user and an application should therefore give the user
438: the opportunity to change the setup. When specifying a natural language
439: preference, libwww will send this preference along with all HTTP requests.
440: The remote server will then (it if supports this feature) look for a version
441: in the language or languages mentioned. If it finds a matching document then
442: it returns this one, otherwise it uses the best alternative. If no language
443: is specified the remote server may whatever version it finds.
444: <PRE>extern void HTLanguage_add (HTList * list, const char * lang, double quality);
2.51 frystyk 445: extern void HTLanguage_deleteAll (HTList * list);
2.50 frystyk 446: </PRE>
2.67 frystyk 447: <H2>
448: <A NAME="global">Global Preferences</A>
449: </H2>
450: <P>
2.50 frystyk 451: There are two places where these preferences can be registered: in a
2.67 frystyk 452: <EM>global</EM> list valid for <B>all</B> requests and a <EM>local</EM> list
453: valid for a particular request only. These are valid for <EM>all</EM> requests.
454: See the <A HREF="HTReq.html">Request Manager</A> fro local sets.
455: <H3>
2.73 frystyk 456: Global Converters and Presenters
2.67 frystyk 457: </H3>
458: <P>
459: The <EM>global</EM> list of specific conversions which the format manager
460: can do in order to fulfill the request. There is also a
461: <A HREF="HTReq.html"><EM>local</EM></A> list of conversions which contains
462: a generic set of possible conversions.
2.73 frystyk 463: <PRE>extern void HTFormat_setConversion (HTList * list);
2.50 frystyk 464: extern HTList * HTFormat_conversion (void);
2.69 frystyk 465:
466: extern void HTFormat_addConversion (const char * input_format,
467: const char * output_format,
468: HTConverter * converter,
469: double quality,
470: double secs,
471: double secs_per_byte);
2.31 frystyk 472: </PRE>
2.67 frystyk 473: <H3>
2.73 frystyk 474: Global Content Codings
2.67 frystyk 475: </H3>
2.73 frystyk 476: <PRE>extern void HTFormat_setContentCoding (HTList * list);
2.64 frystyk 477: extern HTList * HTFormat_contentCoding (void);
2.69 frystyk 478:
479: extern BOOL HTFormat_addCoding ( char * encoding,
480: HTCoder * encoder,
481: HTCoder * decoder,
482: double quality);
2.50 frystyk 483: </PRE>
2.74 frystyk 484: <P>
2.82 frystyk 485: We also define a macro to find out whether a content encoding is really an
486: encoding or whether it is a unity encoder.
2.74 frystyk 487: <PRE>
488: #define HTFormat_isUnityContent(me) \
2.79 frystyk 489: ((me)==NULL || \
490: (me)==WWW_CODING_BINARY || (me)==WWW_CODING_IDENTITY || \
491: (me)==WWW_CODING_7BIT || (me)==WWW_CODING_8BIT)
2.74 frystyk 492: </PRE>
2.67 frystyk 493: <H3>
2.77 frystyk 494: Global Transfer Codings
2.67 frystyk 495: </H3>
2.73 frystyk 496: <PRE>extern void HTFormat_setTransferCoding (HTList * list);
2.64 frystyk 497: extern HTList * HTFormat_transferCoding (void);
2.69 frystyk 498:
499: extern BOOL HTFormat_addTransferCoding ( char * encoding,
500: HTCoder * encoder,
501: HTCoder * decoder,
502: double quality);
2.64 frystyk 503: </PRE>
2.67 frystyk 504: <P>
505: We also define a macro to find out whether a transfer encoding is really
506: an encoding or whether it is just a "dummy" as for example 7bit, 8bit, and
507: binary.
2.64 frystyk 508: <PRE>
509: #define HTFormat_isUnityTransfer(me) \
2.79 frystyk 510: ((me)==NULL || \
511: (me)==WWW_CODING_BINARY || (me)==WWW_CODING_IDENTITY || \
512: (me)==WWW_CODING_7BIT || (me)==WWW_CODING_8BIT)
2.64 frystyk 513: </PRE>
2.67 frystyk 514: <H3>
2.73 frystyk 515: Global Content Languages
2.67 frystyk 516: </H3>
2.73 frystyk 517: <PRE>extern void HTFormat_setLanguage (HTList * list);
2.50 frystyk 518: extern HTList * HTFormat_language (void);
519: </PRE>
2.67 frystyk 520: <H3>
2.73 frystyk 521: Global Content Charsets
2.67 frystyk 522: </H3>
2.73 frystyk 523: <PRE>extern void HTFormat_setCharset (HTList * list);
2.50 frystyk 524: extern HTList * HTFormat_charset (void);
2.31 frystyk 525: </PRE>
2.67 frystyk 526: <H3>
527: Delete All Global Lists
528: </H3>
529: <P>
2.50 frystyk 530: This is a convenience function that might make life easier.
2.73 frystyk 531: <PRE>extern void HTFormat_deleteAll (void);
2.34 frystyk 532: </PRE>
2.67 frystyk 533: <H2>
534: <A NAME="CTStack">The Content Type Stream Stack</A>
535: </H2>
536: <P>
537: This is the routine which actually sets up the content type conversion. It
538: currently checks only for direct conversions, but multi-stage conversions
539: are forseen. It takes a stream into which the output should be sent in the
540: final format, builds the conversion stack, and returns a stream into which
541: the data in the input format should be fed. If <CODE>guess</CODE> is true
542: and input format is <CODE>www/unknown</CODE>, try to guess the format by
543: looking at the first few bytes of the stream.
2.31 frystyk 544: <PRE>
2.52 frystyk 545: extern HTStream * HTStreamStack (HTFormat rep_in,
546: HTFormat rep_out,
547: HTStream * output_stream,
548: HTRequest * request,
549: BOOL guess);
2.1 timbl 550: </PRE>
2.67 frystyk 551: <H3>
552: Cost of a Stream Stack
553: </H3>
554: <P>
555: Must return the cost of the same stack which HTStreamStack would set up.
2.31 frystyk 556: <PRE>
2.52 frystyk 557: extern double HTStackValue (HTList * conversions,
558: HTFormat format_in,
559: HTFormat format_out,
560: double initial_value,
561: long int length);
2.64 frystyk 562: </PRE>
2.67 frystyk 563: <H2>
564: <A NAME="CEStack">Content Encoding Stream Stack</A>
565: </H2>
566: <P>
567: When creating a coding stream stack, it is important that we keep the right
568: order of encoders and decoders. As an example, the HTTP spec specifies that
569: the list in the <EM>Content-Encoding</EM> header follows the order in which
570: the encodings have been applied to the object. Internally, we represent the
571: content encodings as <A HREF="HTAtom.html">atoms</A> in a linked
572: <A HREF="HTList.html">list object</A>.
573: <P>
574: The creation of the content coding stack is not based on quality factors
575: as we don't have the freedom as with content types. When using content codings
576: we <EM>must</EM> apply the codings specified or fail.
2.64 frystyk 577: <PRE>
578: extern HTStream * HTContentCodingStack (HTEncoding coding,
579: HTStream * target,
580: HTRequest * request,
581: void * param,
582: BOOL encoding);
583: </PRE>
2.67 frystyk 584: <P>
585: Here you can provide a complete list instead of a single token. The list
586: has to be filled up in the order the _encodings_ are to be applied
2.64 frystyk 587: <PRE>
588: extern HTStream * HTContentEncodingStack (HTList * encodings,
589: HTStream * target,
590: HTRequest * request,
591: void * param);
592: </PRE>
2.67 frystyk 593: <P>
594: Here you can provide a complete list instead of a single token. The list
595: has to be in the order the _encodings_ were applied - that is, the same way
596: that _encodings_ are to be applied. This is all consistent with the order
597: of the Content-Encoding header.
2.64 frystyk 598: <PRE>
599: extern HTStream * HTContentDecodingStack (HTList * encodings,
600: HTStream * target,
601: HTRequest * request,
602: void * param);
603: </PRE>
2.67 frystyk 604: <H2>
2.79 frystyk 605: <A NAME="TEStack">Transfer Encoding Stream Stack</A>
606: </H2>
607: <P>
608: When creating a coding stream stack, it is important that we keep the right
609: order of encoders and decoders. As an example, the HTTP spec specifies that
610: the list in the <EM>Transfer-Encoding</EM> header follows the order in which
611: the encodings have been applied to the object. Internally, we represent the
612: content encodings as <A HREF="HTAtom.html">atoms</A> in a linked
613: <A HREF="HTList.html">list object</A>.
614: <P>
615: The creation of the content coding stack is not based on quality factors
616: as we don't have the freedom as with content types. When using content codings
617: we <EM>must</EM> apply the codings specified or fail.
618: <PRE>
619: extern HTStream * HTTransferCodingStack (HTEncoding coding,
620: HTStream * target,
621: HTRequest * request,
622: void * param,
623: BOOL encoding);
624: </PRE>
625: <P>
626: Here you can provide a complete list instead of a single token. The list
627: has to be filled up in the order the _encodings_ are to be applied
628: <PRE>
629: extern HTStream * HTTransferEncodingStack (HTList * encodings,
630: HTStream * target,
631: HTRequest * request,
632: void * param);
633: </PRE>
634: <P>
635: Here you can provide a complete list instead of a single token. The list
636: has to be in the order the _encodings_ were applied - that is, the same way
637: that _encodings_ are to be applied. This is all consistent with the order
638: of the Transfer-Encoding header.
639: <PRE>
640: extern HTStream * HTTransferDecodingStack (HTList * encodings,
641: HTStream * target,
642: HTRequest * request,
643: void * param);
644: </PRE>
645: <H2>
2.77 frystyk 646: <A NAME="CTEStack">Transfer Encoding Stream Stack</A>
2.67 frystyk 647: </H2>
648: <P>
649: Creating the transfer content encoding stream stack is not based on quality
650: factors as we don't have the freedom as with content types. Specify whether
651: you you want encoding or decoding using the BOOL "encode" flag.
2.64 frystyk 652: <PRE>
2.79 frystyk 653: extern HTStream * HTContentTransferCodingStack (HTEncoding encoding,
654: HTStream * target,
655: HTRequest * request,
656: void * param,
657: BOOL encode);
2.64 frystyk 658: </PRE>
2.73 frystyk 659: <H3>
660: Presentation Object
661: </H3>
662: <P>
663: This object is not to be used - it should have been hidden
664: <PRE>typedef struct _HTPresentation {
665: HTFormat rep; /* representation name atomized */
666: HTFormat rep_out; /* resulting representation */
667: HTConverter *converter; /* The routine to gen the stream stack */
668: char * command; /* MIME-format string */
669: char * test_command; /* MIME-format string */
670: double quality; /* Between 0 (bad) and 1 (good) */
671: double secs;
672: double secs_per_byte;
673: } HTPresentation;
674: </PRE>
2.64 frystyk 675: <PRE>
2.86 ! vbancrof 676: #ifdef __cplusplus
! 677: }
! 678: #endif
! 679:
2.42 frystyk 680: #endif /* HTFORMAT */
2.38 frystyk 681: </PRE>
2.67 frystyk 682: <P>
683: <HR>
2.63 frystyk 684: <ADDRESS>
2.86 ! vbancrof 685: @(#) $Id: HTFormat.html,v 2.85 2000/12/18 17:00:56 kahan Exp $
2.63 frystyk 686: </ADDRESS>
2.67 frystyk 687: </BODY></HTML>
Webmaster