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