Annotation of libwww/Library/src/HTWWWStr.html, revision 2.10
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><CRLF></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.10 ! frystyk 94: Returns a string containing a date/time stamp string in RFC-1123 format.
! 95: The string is in static memory so be aware!
2.1 frystyk 96: <PRE>
2.10 ! frystyk 97: extern const char * HTDateTimeStr (time_t *calendar, BOOL local);
2.1 frystyk 98: </PRE>
2.5 frystyk 99: <H2>
100: Date used for directory listings
101: </H2>
2.10 ! frystyk 102: <P>
! 103: Generates a date/time stamp string used in directory listings. There is nothing
! 104: special about this format, it is just to make directory listings look alike.
2.1 frystyk 105: <PRE>
106: extern BOOL HTDateDirStr (time_t * time, char * str, int len);
107: </PRE>
2.5 frystyk 108: <H2>
109: Parse a Date/Time String
110: </H2>
111: <P>
2.10 ! frystyk 112: Converts a variety of different string representations of date time stamps
! 113: in GMT to a local representation of localtime <CODE>time_t</CODE>. The local
! 114: <I>time zone</I> is taken from the <A HREF="HTUser.html">user profile</A>
! 115: information or directly from the system if <CODE>NULL</CODE> is passed as
! 116: user profile . If the time is relative (for example in the <CODE>Age</CODE>
! 117: header) then you can indicate whether it should be expanded to local time
! 118: or not by using the <CODE>expand</CODE> argument.
2.5 frystyk 119: <PRE>
2.9 frystyk 120: extern time_t HTParseTime (const char * str, HTUserProfile * up, BOOL expand);
2.5 frystyk 121: </PRE>
122: <H2>
123: Unique Message-ID String
124: </H2>
125: <P>
126: The message ID string can for example be use as a RFC 822 header. The content
127: is based on the information taken from the <A HREF="HTUser.html">user
2.10 ! frystyk 128: profile</A> which can be supplied by the application.
2.5 frystyk 129: <PRE>extern const char * HTMessageIdStr (HTUserProfile * up);
130: </PRE>
131: <H2>
2.7 frystyk 132: Matching MIME Content-Types
133: </H2>
134: <P>
135: Matches MIME constructions for <I>content-types</I> and others like them,
136: for example "text/html", "text/plain". It can also match wild cards like
137: "text/<star>" and "<star>/<star>. We use <star> instead of * in order note
138: to make C like comments :-)
139: <PRE>
140: extern BOOL HTMIMEMatch (HTAtom * tmplate, HTAtom * actual);
141: </PRE>
142: <H2>
2.5 frystyk 143: Converts an Integer to a String using Prefix
144: </H2>
145: <P>
146: In computer-world 1K is 1024 bytes and 1M is 1024K -- however, sprintf()
147: still formats in base-10. Therefore I output only until 999, and then start
148: using the next unit. This doesn't work wrong, it's just a feature. The conversion
149: is done in "str" which must be large enough to contain the result.
2.1 frystyk 150: <PRE>
151: extern void HTNumToStr (unsigned long n, char *str, int len);
152: </PRE>
2.5 frystyk 153: <H2>
154: Conversion between URLs and Local File Names
155: </H2>
156: <P>
157: These are two functions that separate the URL naming syntax from platform
158: dependent file naming schemes. If you are porting the code to a new platform,
159: you probably have to do some translation here.
160: <H3>
161: Convert file URLs into a local representation
162: </H3>
163: <P>
164: The URL has already been translated through the rules in get_physical in
165: HTAccess.c and all we need to do now is to map the path to a local
166: representation, for example if must translate '/' to the ones that turn the
167: wrong way ;-) Returns local file (that must be freed by caller) if OK, else
168: NULL.
169: <PRE>
170: extern char * HTWWWToLocal (const char * url, const char * base,
171: HTUserProfile * up);
172: </PRE>
173: <H3>
174: Convert a local file name into a URL
175: </H3>
176: <P>
177: Generates a WWW URL name from a local file name or NULL if error. Returns
178: URL (that must be freed by caller) if OK, else NULL.
2.1 frystyk 179: <PRE>
2.2 frystyk 180: extern char * HTLocalToWWW (const char * local);
2.1 frystyk 181: </PRE>
182: <PRE>
183: #endif
184: </PRE>
2.5 frystyk 185: <P>
186: <HR>
2.4 frystyk 187: <ADDRESS>
2.10 ! frystyk 188: @(#) $Id: HTWWWStr.html,v 2.9 1996/09/08 22:08:52 frystyk Exp $
2.4 frystyk 189: </ADDRESS>
2.5 frystyk 190: </BODY></HTML>
Webmaster