Annotation of libwww/Library/src/HTWWWStr.html, revision 2.16

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.7       frystyk     3:   <!-- Changed by: Henrik Frystyk Nielsen, 18-May-1996 -->
                      4:   <!-- Changed by: Eric Prud'hommeaux, 28-May-1996 -->
2.11      frystyk     5:   <TITLE>W3C Sample Code Library libwww WWW String Utilities</TITLE>
2.1       frystyk     6: </HEAD>
                      7: <BODY>
2.5       frystyk     8: <H1>
                      9:   WWW Related String Management
                     10: </H1>
2.1       frystyk    11: <PRE>
                     12: /*
                     13: **     (c) COPYRIGHT MIT 1995.
                     14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
2.5       frystyk    17: <P>
2.1       frystyk    18: This module is like the <A HREF="HTString.html">generic string utility
2.5       frystyk    19: module</A> but it contains more Web related string utility functions. Examples
                     20: are functions that return a <I>date string</I>, a <I>Message ID string</I>
                     21: etc.
                     22: <P>
                     23: This module is implemented by <A HREF="HTWWWStr.c">HTWWWStr.c</A>, and it
2.14      frystyk    24: is a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
2.5       frystyk    25: Library</A>.
2.1       frystyk    26: <PRE>
                     27: #ifndef HTWWWSTR_H
                     28: #define HTWWWSTR_H
2.5       frystyk    29: 
                     30: #include "HTUser.h"
2.7       frystyk    31: #include "HTAtom.h"
2.1       frystyk    32: </PRE>
2.5       frystyk    33: <H2>
2.16    ! frystyk    34:   MIME Parsing and other String Based Utilities
        !            35: </H2>
        !            36: <P>
        !            37: A bunch of "finding the next whatever" functions.
        !            38: <H3>
2.5       frystyk    39:   Next word or quoted string
2.16    ! frystyk    40: </H3>
2.5       frystyk    41: <P>
                     42: This function returns a RFC822 word separated by space, comma, or semi-colons.
                     43: <CODE>pstr</CODE> points to a string containing a word separated by white
                     44: white space "," ";" or "=". The word can optionally be quoted using
                     45: <"> or "<" ">" Comments surrrounded by '(' ')' are filtered out. On exit,
                     46: <CODE>pstr</CODE> has been moved to the first delimiter past the field THE
                     47: STRING HAS BEEN MUTILATED by a 0 terminator. The function returns a pointer
                     48: to the first word or NULL on error
2.1       frystyk    49: <PRE>
                     50: extern char * HTNextField (char** pstr);
                     51: </PRE>
2.16    ! frystyk    52: <H3>
2.9       frystyk    53:   Next Name-value Pair
2.16    ! frystyk    54: </H3>
2.9       frystyk    55: <P>
                     56: This is the same as <CODE>HTNextField</CODE> but it does not look for '='
                     57: as a separator so if there is a name-value pair then both parts are returned.
                     58: Returns a pointer to the first word or NULL on error
                     59: <PRE>
                     60: extern char * HTNextPair (char ** pstr);
                     61: </PRE>
2.12      frystyk    62: <H3>
2.13      frystyk    63:   Next LWS Delimited Token
                     64: </H3>
2.16    ! frystyk    65: <P>
        !            66: A simpler version of the above that only looks for linear white space as
        !            67: the delimiter.
2.13      frystyk    68: <PRE>
                     69: extern char * HTNextLWSToken (char ** pstr);
                     70: </PRE>
                     71: <H3>
                     72:   Find next "/" Delimited Segment
2.12      frystyk    73: </H3>
2.16    ! frystyk    74: <P>
        !            75: This is the same as HTNextField but it includes "/" as a delimiter. Returns
        !            76: a pointer to the first segment or NULL on error
2.12      frystyk    77: <PRE>
                     78: extern char * HTNextSegment (char ** pstr);
                     79: </PRE>
2.16    ! frystyk    80: <H3>
        !            81:   Next Comma Separated String (or Element)
        !            82: </H3>
        !            83: <P>
        !            84: This is the same as HTNextPair but it does not look for anything else than
        !            85: ',' as separator Returns a pointer to the first word or NULL on error
        !            86: <PRE>
        !            87: extern char * HTNextElement (char ** pstr);
        !            88: </PRE>
        !            89: <H3>
2.8       frystyk    90:   Next S-expression
2.16    ! frystyk    91: </H3>
2.8       frystyk    92: <P>
                     93: Find the next s-expression token from a string of characters. We return the
                     94: <CODE>name</CODE> of this expression and the <CODE>param</CODE> points to
                     95: the parameters. Note, that the string has been mutilated by a 0 terminator!
                     96: <PRE>
                     97: extern char * HTNextSExp (char ** exp, char ** param);
                     98: </PRE>
                     99: <H2>
2.5       frystyk   100:   Reading CRLF
                    101: </H2>
                    102: <P>
                    103: The Library provides a default set of read routines that can handle the most
                    104: common situations. However, before we start we make following definition
                    105: is to make life easier when having a state machine looking for a
                    106: <CODE>&lt;CRLF&gt;</CODE> sequence.
                    107: <PRE>
                    108: typedef enum _HTEOLState {
                    109:     EOL_ERR = -1,
                    110:     EOL_BEGIN = 0,
                    111:     EOL_FCR,
                    112:     EOL_FLF,
                    113:     EOL_DOT,
                    114:     EOL_SCR,
2.6       eric      115:     EOL_SLF,
                    116:     /* intermediate states */
                    117:     EOL_END,
                    118:     EOL_FOLD,
                    119:     EOL_LINE
2.5       frystyk   120: } HTEOLState;
                    121: </PRE>
                    122: <H2>
                    123:   RFC1123 Date/Time Stamp String
                    124: </H2>
                    125: <P>
2.10      frystyk   126: Returns a string containing a date/time stamp string in RFC-1123 format.
                    127: The string is in static memory so be aware!
2.1       frystyk   128: <PRE>
2.10      frystyk   129: extern const char * HTDateTimeStr (time_t *calendar, BOOL local);
2.1       frystyk   130: </PRE>
2.5       frystyk   131: <H2>
                    132:   Date used for directory listings
                    133: </H2>
2.10      frystyk   134: <P>
                    135: Generates a date/time stamp string used in directory listings. There is nothing
                    136: special about this format, it is just to make directory listings look alike.
2.1       frystyk   137: <PRE>
                    138: extern BOOL HTDateDirStr (time_t * time, char * str, int len);
                    139: </PRE>
2.5       frystyk   140: <H2>
                    141:   Parse a Date/Time String
                    142: </H2>
                    143: <P>
2.10      frystyk   144: Converts a variety of different string representations of date time stamps
                    145: in GMT to a local representation of localtime <CODE>time_t</CODE>. The local
                    146: <I>time zone</I> is taken from the <A HREF="HTUser.html">user profile</A>
                    147: information or directly from the system if <CODE>NULL</CODE> is passed as
                    148: user profile . If the time is relative (for example in the <CODE>Age</CODE>
                    149: header) then you can indicate whether it should be expanded to local time
                    150: or not by using the <CODE>expand</CODE> argument.
2.5       frystyk   151: <PRE>
2.9       frystyk   152: extern time_t HTParseTime (const char * str, HTUserProfile * up, BOOL expand);
2.5       frystyk   153: </PRE>
                    154: <H2>
                    155:   Unique Message-ID String
                    156: </H2>
                    157: <P>
                    158: The message ID string can for example be use as a RFC 822 header. The content
                    159: is based on the information taken from the <A HREF="HTUser.html">user
2.10      frystyk   160: profile</A> which can be supplied by the application.
2.5       frystyk   161: <PRE>extern const char * HTMessageIdStr (HTUserProfile * up);
                    162: </PRE>
                    163: <H2>
2.7       frystyk   164:   Matching MIME Content-Types
                    165: </H2>
                    166: <P>
                    167: Matches MIME constructions for <I>content-types</I> and others like them,
                    168: for example "text/html", "text/plain". It can also match wild cards like
                    169: "text/<star>" and "<star>/<star>. We use <star> instead of * in order note
                    170: to make C like comments :-)
                    171: <PRE>
                    172: extern BOOL HTMIMEMatch (HTAtom * tmplate, HTAtom * actual);
                    173: </PRE>
                    174: <H2>
2.5       frystyk   175:   Converts an Integer to a String using Prefix
                    176: </H2>
                    177: <P>
                    178: In computer-world 1K is 1024 bytes and 1M is 1024K -- however, sprintf()
                    179: still formats in base-10. Therefore I output only until 999, and then start
                    180: using the next unit. This doesn't work wrong, it's just a feature. The conversion
                    181: is done in "str" which must be large enough to contain the result.
2.1       frystyk   182: <PRE>
                    183: extern void HTNumToStr (unsigned long n, char *str, int len);
                    184: </PRE>
2.5       frystyk   185: <H2>
                    186:   Conversion between URLs and Local File Names
                    187: </H2>
                    188: <P>
                    189: These are two functions that separate the URL naming syntax from platform
                    190: dependent file naming schemes. If you are porting the code to a new platform,
                    191: you probably have to do some translation here.
                    192: <H3>
                    193:   Convert file URLs into a local representation
                    194: </H3>
                    195: <P>
                    196: The URL has already been translated through the rules in get_physical in
                    197: HTAccess.c and all we need to do now is to map the path to a local
                    198: representation, for example if must translate '/' to the ones that turn the
                    199: wrong way ;-) Returns local file (that must be freed by caller) if OK, else
                    200: NULL.
                    201: <PRE>
                    202: extern char * HTWWWToLocal (const char * url, const char * base,
                    203:                            HTUserProfile * up);
                    204: </PRE>
                    205: <H3>
                    206:   Convert a local file name into a URL
                    207: </H3>
                    208: <P>
2.16    ! frystyk   209: Generates a WWW URL name from a local file name or NULL if error. Returns
        !           210: URL (that must be freed by caller) if OK, else NULL. The access parameter
        !           211: can be used to indicate any special scheme used for local file access. If
        !           212: NULL then "<CODE>file:</CODE>" is used.
2.1       frystyk   213: <PRE>
2.15      frystyk   214: extern char * HTLocalToWWW (const char * local, const char * access);
2.1       frystyk   215: </PRE>
                    216: <PRE>
                    217: #endif
                    218: </PRE>
2.5       frystyk   219: <P>
                    220:   <HR>
2.4       frystyk   221: <ADDRESS>
2.16    ! frystyk   222:   @(#) $Id: HTWWWStr.html,v 2.15 1999/02/03 16:32:06 frystyk Exp $
2.4       frystyk   223: </ADDRESS>
2.5       frystyk   224: </BODY></HTML>

Webmaster