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