Annotation of libwww/Library/src/HTString.html, revision 2.36

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 (&amp;(dest), src)
                     40: #define StrAllocCat(dest, src)  HTSACat  (&amp;(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>
                     67:   String Comparison with Wild Card Match
                     68: </H2>
                     69: <P>
                     70: String comparison function for file names with one wildcard * in the template.
                     71: Arguments are:
2.24      frystyk    72: <DL>
2.32      frystyk    73:   <DT>
                     74:     tmpl
                     75:   <DD>
                     76:     is a template string to match the name against. agaist, may contain a single
                     77:     wildcard character * which matches zero or more arbitrary characters.
                     78:   <DT>
                     79:     name
                     80:   <DD>
                     81:     is the name to be matched agaist the template.
2.24      frystyk    82: </DL>
2.32      frystyk    83: <P>
                     84: Returns empty string ("") if perfect match, pointer to part matched by wildcard
                     85: if any, or NULL if no match. This is basically the same as YES if match,
                     86: else NO.
2.24      frystyk    87: <PRE>
2.28      frystyk    88: extern char * HTStrMatch       (const char * tmpl, const char * name);
                     89: extern char * HTStrCaseMatch   (const char * tmpl, const char * name);
2.24      frystyk    90: </PRE>
2.32      frystyk    91: <H2>
                     92:   Case-insensitive strstr
                     93: </H2>
                     94: <P>
2.9       frystyk    95: This works like <CODE>strstr()</CODE> but is not case-sensitive.
                     96: <PRE>
2.24      frystyk    97: extern char * strcasestr (char * s1, char * s2);
2.17      frystyk    98: </PRE>
2.32      frystyk    99: <H2>
                    100:   Strip white space off a string
                    101: </H2>
                    102: <P>
                    103: Return value points to first non-white character, or to '/0' if none. All
                    104: trailing white space is OVERWRITTEN with zero.
2.17      frystyk   105: <PRE>
2.24      frystyk   106: extern char * HTStrip (char * s);
2.6       timbl     107: </PRE>
2.14      frystyk   108: <PRE>
2.33      frystyk   109: #endif /* !HTSTRING_H */
2.9       frystyk   110: </PRE>
2.32      frystyk   111: <P>
                    112:   <HR>
2.31      frystyk   113: <ADDRESS>
2.36    ! frystyk   114:   @(#) $Id: HTString.html,v 2.35 1998/05/04 19:37:23 frystyk Exp $
2.31      frystyk   115: </ADDRESS>
2.32      frystyk   116: </BODY></HTML>

Webmaster