Annotation of libwww/Library/src/HTString.html, revision 2.24
2.11 frystyk 1: <HTML>
2: <HEAD>
2.19 frystyk 3: <TITLE>String Handling</TITLE>
2.24 ! frystyk 4: <!-- Changed by: Henrik Frystyk Nielsen, 2-Nov-1995 -->
2.11 frystyk 5: </HEAD>
2.6 timbl 6: <BODY>
2.9 frystyk 7:
8: <H1>String Management</H1>
2.11 frystyk 9:
10: <PRE>
11: /*
2.15 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.11 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.9 frystyk 16:
17: These functions provide functionality for case-independent string
18: comparison and allocations with copies etc. <P>
19:
20: This module is implemented by <A HREF="HTString.c">HTString.c</A>, and
21: it is a part of the <A NAME="z10"
2.21 frystyk 22: HREF="http://www.w3.org/pub/WWW/Library/">
2.18 frystyk 23: W3C Reference Library</A>. <P>
2.9 frystyk 24:
2.8 frystyk 25: <PRE>
26: #ifndef HTSTRING_H
2.1 timbl 27: #define HTSTRING_H
28:
29: extern CONST char * HTLibraryVersion; /* String for help screen etc */
2.9 frystyk 30: </PRE>
31:
2.17 frystyk 32: <H2><A NAME="dyn">Dynamic String Manipulation</A></H2>
2.9 frystyk 33:
34: These two functions are dynamic versions of <CODE>strcpy</CODE> and
35: <CODE>strcat</CODE>. They use <CODE>malloc</CODE> for allocating space
36: for the string. If <CODE>StrAllocCopy</CODE> is called with a non-NULL
37: dest, then this is freed before the new value is assigned so that only
38: the <EM>last</EM> string created has to be freed by the user. If
39: <CODE>StrAllocCat</CODE> is called with a NULL pointer as destination
40: then it is equivalent to <CODE>StrAllocCopy</CODE>.
2.1 timbl 41:
2.9 frystyk 42: <PRE>
43: #define StrAllocCopy(dest, src) HTSACopy (&(dest), src)
44: #define StrAllocCat(dest, src) HTSACat (&(dest), src)
2.24 ! frystyk 45:
! 46: extern char * HTSACopy (char **dest, CONST char *src);
! 47: extern char * HTSACat (char **dest, CONST char *src);
2.6 timbl 48: </PRE>
2.1 timbl 49:
2.17 frystyk 50: <H2><A NAME="utils">Case-insensitive String Comparison</A></H2>
2.9 frystyk 51:
52: The usual routines (comp instead of cmp) had some problem.
2.7 luotonen 53:
54: <PRE>
2.23 frystyk 55: extern int strcasecomp (CONST char *a, CONST char *b);
56: extern int strncasecomp (CONST char *a, CONST char *b, int n);
2.7 luotonen 57: </PRE>
58:
2.24 ! frystyk 59: <H2>String Comparison with Wild Card Match</H2>
! 60:
! 61: String comparison function for file names with one wildcard * in the
! 62: template. Arguments are:
! 63:
! 64: <DL>
! 65: <DT>tmpl
! 66: <DD>is a template string to match the name against. agaist, may
! 67: contain a single wildcard character * which matches zero or more
! 68: arbitrary characters.
! 69: <DT>name
! 70: <DD>is the name to be matched agaist the template.
! 71: </DL>
! 72:
! 73: returns YES, if filename matches the template, else NO
! 74:
! 75: <PRE>
! 76: extern BOOL HTStringMatch (CONST char * tmpl, CONST char * name);
! 77: extern BOOL HTStringCaseMatch (CONST char * tmpl, CONST char * name);
! 78: </PRE>
! 79:
2.9 frystyk 80: <H2>Case-insensitive strstr</H2>
2.7 luotonen 81:
2.9 frystyk 82: This works like <CODE>strstr()</CODE> but is not case-sensitive.
2.1 timbl 83:
2.9 frystyk 84: <PRE>
2.24 ! frystyk 85: extern char * strcasestr (char * s1, char * s2);
2.17 frystyk 86: </PRE>
87:
88: <H2>Strip white space off a string</H2>
89:
90: Return value points to first non-white character, or to '/0' if
91: none. All trailing white space is OVERWRITTEN with zero.
92:
93: <PRE>
2.24 ! frystyk 94: extern char * HTStrip (char * s);
2.6 timbl 95: </PRE>
2.9 frystyk 96:
2.6 timbl 97: <H2>Next word or quoted string</H2>
2.14 frystyk 98:
99: This function returns a RFC822 word separated by space, comma, or
100: semi-colons.
101:
2.9 frystyk 102: <PRE>
2.24 ! frystyk 103: extern char * HTNextField (char** pstr);
2.14 frystyk 104: </PRE>
105:
106: <H2>RFC1123 Date/Time Stamp String</H2>
107:
108: Returns a pointer to a static area!
109:
110: <PRE>
2.24 ! frystyk 111: extern CONST char *HTDateTimeStr (time_t *calendar, BOOL local);
2.14 frystyk 112: </PRE>
113:
2.23 frystyk 114: <H2>Date used for directory listings</H2>
115:
116: <PRE>
2.24 ! frystyk 117: extern BOOL HTDateDirStr (time_t * time, char * str, int len);
2.23 frystyk 118: </PRE>
2.14 frystyk 119:
120: <H2>Timezone Offset</H2>
121:
122: Calculates the offset from GMT in seconds. This is called from <A
2.22 frystyk 123: HREF="HTReq.html#Library">HTLibInit()</A>.
2.14 frystyk 124:
125: <PRE>
2.24 ! frystyk 126: extern long HTGetTimeZoneOffset (void);
2.14 frystyk 127: </PRE>
128:
129: <H2>Parse a Date/Time String</H2>
130:
131: Converts a string representation in GMT to a local representation of
132: localtime <CODE>time_t</CODE>.
133:
134: <PRE>
2.24 ! frystyk 135: extern time_t HTParseTime (CONST char * str);
2.14 frystyk 136: </PRE>
137:
138:
139: <H2>Unique Message-ID String</H2>
140:
141: <PRE>
2.24 ! frystyk 142: extern CONST char *HTMessageIdStr (void);
2.9 frystyk 143: #endif
2.20 frystyk 144: </PRE>
145:
146: <H2>Converts an Integer to a String using Prefix</H2>
147:
148: In computer-world 1K is 1024 bytes and 1M is 1024K -- however,
149: sprintf() still formats in base-10. Therefore I output only until
150: 999, and then start using the next unit. This doesn't work wrong,
151: it's just a feature. The conversion is done in "str" which must be
152: large enough to contain the result.
153:
154: <PRE>
2.23 frystyk 155: extern void HTNumToStr (unsigned long n, char *str, int len);
156: </PRE>
157:
158: <H2>Conversion between URLs and Local File Names</H2>
159:
160: These are two functions that separate the URL naming syntax from
161: platform dependent file naming schemes. If you are porting the code to
162: a new platform, you probably have to do some translation here.
163:
164: <H3>Convert file URLs into a local representation</H3>
165:
166: The URL has already been translated through the rules in get_physical
167: in HTAccess.c and all we need to do now is to map the path to a local
168: representation, for example if must translate '/' to the ones that
169: turn the wrong way ;-) Returns local file (that must be freed by
170: caller) if OK, else NULL.
171:
172: <PRE>
173: extern char * HTWWWToLocal (CONST char * url, CONST char * base);
174: </PRE>
175:
176: <H3>Convert a local file name into a URL</H3>
177:
178: Generates a WWW URL name from a local file name or NULL if error.
179: Returns URL (that must be freed by caller) if OK, else NULL.
180:
181: <PRE>
182: extern char * HTLocalToWWW (CONST char * local);
2.9 frystyk 183: </PRE>
2.14 frystyk 184:
185: End of declaration module
2.1 timbl 186:
2.6 timbl 187: </BODY>
2.9 frystyk 188: </HTML>
Webmaster