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

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.5       frystyk     5:   <TITLE>W3C Reference 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
                     24: is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Reference
                     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>
        !            57: <H2>
2.8       frystyk    58:   Next S-expression
                     59: </H2>
                     60: <P>
                     61: Find the next s-expression token from a string of characters. We return the
                     62: <CODE>name</CODE> of this expression and the <CODE>param</CODE> points to
                     63: the parameters. Note, that the string has been mutilated by a 0 terminator!
                     64: <PRE>
                     65: extern char * HTNextSExp (char ** exp, char ** param);
                     66: </PRE>
                     67: <H2>
2.5       frystyk    68:   Reading CRLF
                     69: </H2>
                     70: <P>
                     71: The Library provides a default set of read routines that can handle the most
                     72: common situations. However, before we start we make following definition
                     73: is to make life easier when having a state machine looking for a
                     74: <CODE>&lt;CRLF&gt;</CODE> sequence.
                     75: <PRE>
                     76: typedef enum _HTEOLState {
                     77:     EOL_ERR = -1,
                     78:     EOL_BEGIN = 0,
                     79:     EOL_FCR,
                     80:     EOL_FLF,
                     81:     EOL_DOT,
                     82:     EOL_SCR,
2.6       eric       83:     EOL_SLF,
                     84:     /* intermediate states */
                     85:     EOL_END,
                     86:     EOL_FOLD,
                     87:     EOL_LINE
2.5       frystyk    88: } HTEOLState;
                     89: </PRE>
                     90: <H2>
                     91:   RFC1123 Date/Time Stamp String
                     92: </H2>
                     93: <P>
2.1       frystyk    94: Returns a pointer to a static area!
                     95: <PRE>
2.2       frystyk    96: extern const char *HTDateTimeStr (time_t *calendar, BOOL local);
2.1       frystyk    97: </PRE>
2.5       frystyk    98: <H2>
                     99:   Date used for directory listings
                    100: </H2>
2.1       frystyk   101: <PRE>
                    102: extern BOOL HTDateDirStr (time_t * time, char * str, int len);
                    103: </PRE>
2.5       frystyk   104: <H2>
                    105:   Parse a Date/Time String
                    106: </H2>
                    107: <P>
                    108: Converts a string representation in GMT to a local representation of localtime
                    109: <CODE>time_t</CODE>. The local time zone is taken from the
2.9     ! frystyk   110: <A HREF="HTUser.html">user profile</A> information. If the time is relative
        !           111: (for example in the <CODE>Age</CODE> header) then you can indicate whether
        !           112: it should be expanded to local time or not by using the <CODE>expand</CODE>
        !           113: argument.
2.5       frystyk   114: <PRE>
2.9     ! frystyk   115: extern time_t HTParseTime (const char * str, HTUserProfile * up, BOOL expand);
2.5       frystyk   116: </PRE>
                    117: <H2>
                    118:   Unique Message-ID String
                    119: </H2>
                    120: <P>
                    121: The message ID string can for example be use as a RFC 822 header. The content
                    122: is based on the information taken from the <A HREF="HTUser.html">user
                    123: profile</A> which can be supplied by the applciation.
                    124: <PRE>extern const char * HTMessageIdStr (HTUserProfile * up);
                    125: </PRE>
                    126: <H2>
2.7       frystyk   127:   Matching MIME Content-Types
                    128: </H2>
                    129: <P>
                    130: Matches MIME constructions for <I>content-types</I> and others like them,
                    131: for example "text/html", "text/plain". It can also match wild cards like
                    132: "text/<star>" and "<star>/<star>. We use <star> instead of * in order note
                    133: to make C like comments :-)
                    134: <PRE>
                    135: extern BOOL HTMIMEMatch (HTAtom * tmplate, HTAtom * actual);
                    136: </PRE>
                    137: <H2>
2.5       frystyk   138:   Converts an Integer to a String using Prefix
                    139: </H2>
                    140: <P>
                    141: In computer-world 1K is 1024 bytes and 1M is 1024K -- however, sprintf()
                    142: still formats in base-10. Therefore I output only until 999, and then start
                    143: using the next unit. This doesn't work wrong, it's just a feature. The conversion
                    144: is done in "str" which must be large enough to contain the result.
2.1       frystyk   145: <PRE>
                    146: extern void HTNumToStr (unsigned long n, char *str, int len);
                    147: </PRE>
2.5       frystyk   148: <H2>
                    149:   Conversion between URLs and Local File Names
                    150: </H2>
                    151: <P>
                    152: These are two functions that separate the URL naming syntax from platform
                    153: dependent file naming schemes. If you are porting the code to a new platform,
                    154: you probably have to do some translation here.
                    155: <H3>
                    156:   Convert file URLs into a local representation
                    157: </H3>
                    158: <P>
                    159: The URL has already been translated through the rules in get_physical in
                    160: HTAccess.c and all we need to do now is to map the path to a local
                    161: representation, for example if must translate '/' to the ones that turn the
                    162: wrong way ;-) Returns local file (that must be freed by caller) if OK, else
                    163: NULL.
                    164: <PRE>
                    165: extern char * HTWWWToLocal (const char * url, const char * base,
                    166:                            HTUserProfile * up);
                    167: </PRE>
                    168: <H3>
                    169:   Convert a local file name into a URL
                    170: </H3>
                    171: <P>
                    172: Generates a WWW URL name from a local file name or NULL if error. Returns
                    173: URL (that must be freed by caller) if OK, else NULL.
2.1       frystyk   174: <PRE>
2.2       frystyk   175: extern char * HTLocalToWWW (const char * local);
2.1       frystyk   176: </PRE>
                    177: <PRE>
                    178: #endif
                    179: </PRE>
2.5       frystyk   180: <P>
                    181:   <HR>
2.4       frystyk   182: <ADDRESS>
2.9     ! frystyk   183:   @(#) $Id: HTWWWStr.html,v 2.8 1996/08/19 18:31:26 frystyk Exp $
2.4       frystyk   184: </ADDRESS>
2.5       frystyk   185: </BODY></HTML>

Webmaster