Annotation of libwww/Library/src/HTString.html, revision 2.39
2.11 frystyk 1: <HTML>
2: <HEAD>
2.32 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 6-Apr-1996 -->
2.34 frystyk 4: <TITLE>W3C Sample Code Library libwww Generic String Management</TITLE>
2.11 frystyk 5: </HEAD>
2.6 timbl 6: <BODY>
2.32 frystyk 7: <H1>
8: Generic String Management
9: </H1>
2.11 frystyk 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.32 frystyk 16: <P>
17: These functions provide functionality for case-independent string comparison
18: and allocations with copies etc.
19: <P>
20: This module is implemented by <A HREF="HTString.c">HTString.c</A>, and it
2.36 frystyk 21: is a part of the <A NAME="z10" HREF="http://www.w3.org/Library/">W3C
2.34 frystyk 22: Sample Code Library</A>.
2.8 frystyk 23: <PRE>
24: #ifndef HTSTRING_H
2.1 timbl 25: #define HTSTRING_H
2.39 ! vbancrof 26:
! 27: #ifdef __cplusplus
! 28: extern "C" {
! 29: #endif
2.9 frystyk 30: </PRE>
2.32 frystyk 31: <H2>
32: <A NAME="dyn">Dynamic String Manipulation</A>
33: </H2>
34: <P>
2.9 frystyk 35: These two functions are dynamic versions of <CODE>strcpy</CODE> and
2.32 frystyk 36: <CODE>strcat</CODE>. They use <CODE>malloc</CODE> for allocating space for
37: the string. If <CODE>StrAllocCopy</CODE> is called with a non-NULL dest,
38: then this is freed before the new value is assigned so that only the
39: <EM>last</EM> string created has to be freed by the user. If
40: <CODE>StrAllocCat</CODE> is called with a NULL pointer as destination then
41: it is equivalent to <CODE>StrAllocCopy</CODE>. <A NAME="HTSACopy"></A>
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:
2.28 frystyk 46: extern char * HTSACopy (char **dest, const char *src);
47: extern char * HTSACat (char **dest, const char *src);
2.6 timbl 48: </PRE>
2.32 frystyk 49: <P>
2.35 frystyk 50: The next two functions take a variable number of strings and cats them together
51: using dynamic memory. This is basically like a simple form for sprintf where
52: the only argument is <CODE>char *</CODE>. One day we should turn this into
53: a real dynamic <CODE>sprintf()</CODE>.
54: <PRE>
55: extern char * StrAllocMCopy (char ** dest, ...);
56: extern char * StrAllocMCat (char ** dest, ...);
57: </PRE>
58: <P>
59: The last argument MUST be NULL as we otherwise don't know when the argument
60: list stops.
2.32 frystyk 61: <H2>
62: <A NAME="utils">Case-insensitive String Comparison</A>
63: </H2>
64: <P>
2.9 frystyk 65: The usual routines (comp instead of cmp) had some problem.
2.7 luotonen 66: <PRE>
2.28 frystyk 67: extern int strcasecomp (const char *a, const char *b);
68: extern int strncasecomp (const char *a, const char *b, int n);
2.7 luotonen 69: </PRE>
2.32 frystyk 70: <H2>
2.38 raff 71: <A NAME="cookies">Tail String Comparison</A>
72: </H2>
73: <P>
74: Like strcmp, but match the tail of s2 (used for cookie domain comparison)
75: <PRE>
76: extern int tailcomp(const char * s1, const char * s2);
77: extern int tailcasecomp(const char * s1, const char * s2);
78: </PRE>
79: <H2>
2.32 frystyk 80: String Comparison with Wild Card Match
81: </H2>
82: <P>
83: String comparison function for file names with one wildcard * in the template.
84: Arguments are:
2.24 frystyk 85: <DL>
2.32 frystyk 86: <DT>
87: tmpl
88: <DD>
89: is a template string to match the name against. agaist, may contain a single
90: wildcard character * which matches zero or more arbitrary characters.
91: <DT>
92: name
93: <DD>
94: is the name to be matched agaist the template.
2.24 frystyk 95: </DL>
2.32 frystyk 96: <P>
97: Returns empty string ("") if perfect match, pointer to part matched by wildcard
98: if any, or NULL if no match. This is basically the same as YES if match,
99: else NO.
2.24 frystyk 100: <PRE>
2.28 frystyk 101: extern char * HTStrMatch (const char * tmpl, const char * name);
102: extern char * HTStrCaseMatch (const char * tmpl, const char * name);
2.24 frystyk 103: </PRE>
2.32 frystyk 104: <H2>
105: Case-insensitive strstr
106: </H2>
107: <P>
2.9 frystyk 108: This works like <CODE>strstr()</CODE> but is not case-sensitive.
109: <PRE>
2.37 frystyk 110: extern char * HTStrCaseStr (char * s1, char * s2);
2.17 frystyk 111: </PRE>
2.32 frystyk 112: <H2>
113: Strip white space off a string
114: </H2>
115: <P>
116: Return value points to first non-white character, or to '/0' if none. All
117: trailing white space is OVERWRITTEN with zero.
2.17 frystyk 118: <PRE>
2.24 frystyk 119: extern char * HTStrip (char * s);
2.6 timbl 120: </PRE>
2.14 frystyk 121: <PRE>
2.39 ! vbancrof 122: #ifdef __cplusplus
! 123: }
! 124: #endif
! 125:
2.33 frystyk 126: #endif /* !HTSTRING_H */
2.9 frystyk 127: </PRE>
2.32 frystyk 128: <P>
129: <HR>
2.31 frystyk 130: <ADDRESS>
2.39 ! vbancrof 131: @(#) $Id: HTString.html,v 2.38 1999/07/31 01:27:55 raff Exp $
2.31 frystyk 132: </ADDRESS>
2.32 frystyk 133: </BODY></HTML>
Webmaster