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

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.17    ! frystyk    63:   Next Name-value Parameter
        !            64: </H3>
        !            65: <P>
        !            66: This is the same as <CODE>HTNextPair</CODE> but it does not look for ','
        !            67: as a separator so if there is a name-value pair then both parts are returned.
        !            68: Returns a pointer to the first word or NULL on error
        !            69: <PRE>
        !            70: extern char * HTNextParam (char ** pstr);
        !            71: </PRE>
        !            72: <H3>
2.13      frystyk    73:   Next LWS Delimited Token
                     74: </H3>
2.16      frystyk    75: <P>
                     76: A simpler version of the above that only looks for linear white space as
                     77: the delimiter.
2.13      frystyk    78: <PRE>
                     79: extern char * HTNextLWSToken (char ** pstr);
                     80: </PRE>
                     81: <H3>
                     82:   Find next "/" Delimited Segment
2.12      frystyk    83: </H3>
2.16      frystyk    84: <P>
                     85: This is the same as HTNextField but it includes "/" as a delimiter. Returns
                     86: a pointer to the first segment or NULL on error
2.12      frystyk    87: <PRE>
                     88: extern char * HTNextSegment (char ** pstr);
                     89: </PRE>
2.16      frystyk    90: <H3>
                     91:   Next Comma Separated String (or Element)
                     92: </H3>
                     93: <P>
                     94: This is the same as HTNextPair but it does not look for anything else than
                     95: ',' as separator Returns a pointer to the first word or NULL on error
                     96: <PRE>
                     97: extern char * HTNextElement (char ** pstr);
                     98: </PRE>
                     99: <H3>
2.8       frystyk   100:   Next S-expression
2.16      frystyk   101: </H3>
2.8       frystyk   102: <P>
                    103: Find the next s-expression token from a string of characters. We return the
                    104: <CODE>name</CODE> of this expression and the <CODE>param</CODE> points to
                    105: the parameters. Note, that the string has been mutilated by a 0 terminator!
                    106: <PRE>
                    107: extern char * HTNextSExp (char ** exp, char ** param);
                    108: </PRE>
                    109: <H2>
2.5       frystyk   110:   Reading CRLF
                    111: </H2>
                    112: <P>
                    113: The Library provides a default set of read routines that can handle the most
                    114: common situations. However, before we start we make following definition
                    115: is to make life easier when having a state machine looking for a
                    116: <CODE>&lt;CRLF&gt;</CODE> sequence.
                    117: <PRE>
                    118: typedef enum _HTEOLState {
                    119:     EOL_ERR = -1,
                    120:     EOL_BEGIN = 0,
                    121:     EOL_FCR,
                    122:     EOL_FLF,
                    123:     EOL_DOT,
                    124:     EOL_SCR,
2.6       eric      125:     EOL_SLF,
                    126:     /* intermediate states */
                    127:     EOL_END,
                    128:     EOL_FOLD,
                    129:     EOL_LINE
2.5       frystyk   130: } HTEOLState;
                    131: </PRE>
                    132: <H2>
                    133:   RFC1123 Date/Time Stamp String
                    134: </H2>
                    135: <P>
2.10      frystyk   136: Returns a string containing a date/time stamp string in RFC-1123 format.
                    137: The string is in static memory so be aware!
2.1       frystyk   138: <PRE>
2.10      frystyk   139: extern const char * HTDateTimeStr (time_t *calendar, BOOL local);
2.1       frystyk   140: </PRE>
2.5       frystyk   141: <H2>
                    142:   Date used for directory listings
                    143: </H2>
2.10      frystyk   144: <P>
                    145: Generates a date/time stamp string used in directory listings. There is nothing
                    146: special about this format, it is just to make directory listings look alike.
2.1       frystyk   147: <PRE>
                    148: extern BOOL HTDateDirStr (time_t * time, char * str, int len);
                    149: </PRE>
2.5       frystyk   150: <H2>
                    151:   Parse a Date/Time String
                    152: </H2>
                    153: <P>
2.10      frystyk   154: Converts a variety of different string representations of date time stamps
                    155: in GMT to a local representation of localtime <CODE>time_t</CODE>. The local
                    156: <I>time zone</I> is taken from the <A HREF="HTUser.html">user profile</A>
                    157: information or directly from the system if <CODE>NULL</CODE> is passed as
                    158: user profile . If the time is relative (for example in the <CODE>Age</CODE>
                    159: header) then you can indicate whether it should be expanded to local time
                    160: or not by using the <CODE>expand</CODE> argument.
2.5       frystyk   161: <PRE>
2.9       frystyk   162: extern time_t HTParseTime (const char * str, HTUserProfile * up, BOOL expand);
2.5       frystyk   163: </PRE>
                    164: <H2>
                    165:   Unique Message-ID String
                    166: </H2>
                    167: <P>
                    168: The message ID string can for example be use as a RFC 822 header. The content
                    169: is based on the information taken from the <A HREF="HTUser.html">user
2.10      frystyk   170: profile</A> which can be supplied by the application.
2.5       frystyk   171: <PRE>extern const char * HTMessageIdStr (HTUserProfile * up);
                    172: </PRE>
                    173: <H2>
2.7       frystyk   174:   Matching MIME Content-Types
                    175: </H2>
                    176: <P>
                    177: Matches MIME constructions for <I>content-types</I> and others like them,
                    178: for example "text/html", "text/plain". It can also match wild cards like
                    179: "text/<star>" and "<star>/<star>. We use <star> instead of * in order note
                    180: to make C like comments :-)
                    181: <PRE>
                    182: extern BOOL HTMIMEMatch (HTAtom * tmplate, HTAtom * actual);
                    183: </PRE>
                    184: <H2>
2.5       frystyk   185:   Converts an Integer to a String using Prefix
                    186: </H2>
                    187: <P>
                    188: In computer-world 1K is 1024 bytes and 1M is 1024K -- however, sprintf()
                    189: still formats in base-10. Therefore I output only until 999, and then start
                    190: using the next unit. This doesn't work wrong, it's just a feature. The conversion
                    191: is done in "str" which must be large enough to contain the result.
2.1       frystyk   192: <PRE>
                    193: extern void HTNumToStr (unsigned long n, char *str, int len);
                    194: </PRE>
2.5       frystyk   195: <H2>
                    196:   Conversion between URLs and Local File Names
                    197: </H2>
                    198: <P>
                    199: These are two functions that separate the URL naming syntax from platform
                    200: dependent file naming schemes. If you are porting the code to a new platform,
                    201: you probably have to do some translation here.
                    202: <H3>
                    203:   Convert file URLs into a local representation
                    204: </H3>
                    205: <P>
                    206: The URL has already been translated through the rules in get_physical in
                    207: HTAccess.c and all we need to do now is to map the path to a local
                    208: representation, for example if must translate '/' to the ones that turn the
                    209: wrong way ;-) Returns local file (that must be freed by caller) if OK, else
                    210: NULL.
                    211: <PRE>
                    212: extern char * HTWWWToLocal (const char * url, const char * base,
                    213:                            HTUserProfile * up);
                    214: </PRE>
                    215: <H3>
                    216:   Convert a local file name into a URL
                    217: </H3>
                    218: <P>
2.16      frystyk   219: Generates a WWW URL name from a local file name or NULL if error. Returns
                    220: URL (that must be freed by caller) if OK, else NULL. The access parameter
                    221: can be used to indicate any special scheme used for local file access. If
                    222: NULL then "<CODE>file:</CODE>" is used.
2.1       frystyk   223: <PRE>
2.15      frystyk   224: extern char * HTLocalToWWW (const char * local, const char * access);
2.1       frystyk   225: </PRE>
                    226: <PRE>
                    227: #endif
                    228: </PRE>
2.5       frystyk   229: <P>
                    230:   <HR>
2.4       frystyk   231: <ADDRESS>
2.17    ! frystyk   232:   @(#) $Id: HTWWWStr.html,v 2.16 1999/02/13 18:33:49 frystyk Exp $
2.4       frystyk   233: </ADDRESS>
2.5       frystyk   234: </BODY></HTML>

Webmaster