Annotation of libwww/Library/src/HTFormat.html, revision 2.79

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

Webmaster