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

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

Webmaster