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

2.11      frystyk     1: <HTML>
                      2: <HEAD>
2.19      frystyk     3: <TITLE>String Handling</TITLE>
2.23    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  2-Oct-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 (&amp;(dest), src)
                     44: #define StrAllocCat(dest, src)  HTSACat  (&amp;(dest), src)
                     45: extern char * HTSACopy PARAMS ((char **dest, CONST char *src));
                     46: extern char * HTSACat  PARAMS ((char **dest, CONST char *src));
2.6       timbl      47: </PRE>
2.1       timbl      48: 
2.17      frystyk    49: <H2><A NAME="utils">Case-insensitive String Comparison</A></H2>
2.9       frystyk    50: 
                     51: The usual routines (comp instead of cmp) had some problem.
2.7       luotonen   52: 
                     53: <PRE>
2.23    ! frystyk    54: extern int strcasecomp  (CONST char *a, CONST char *b);
        !            55: extern int strncasecomp (CONST char *a, CONST char *b, int n);
2.7       luotonen   56: </PRE>
                     57: 
2.9       frystyk    58: <H2>Case-insensitive strstr</H2>
2.7       luotonen   59: 
2.9       frystyk    60: This works like <CODE>strstr()</CODE> but is not case-sensitive.
2.1       timbl      61: 
2.9       frystyk    62: <PRE>
2.10      frystyk    63: extern char * strcasestr PARAMS((char *        s1, char * s2));
2.17      frystyk    64: </PRE>
                     65: 
                     66: <H2>Strip white space off a string</H2>
                     67: 
                     68: Return value points to first non-white character, or to '/0' if
                     69: none. All trailing white space is OVERWRITTEN with zero.
                     70: 
                     71: <PRE>
                     72: extern char * HTStrip PARAMS((char * s));
2.6       timbl      73: </PRE>
2.9       frystyk    74: 
2.6       timbl      75: <H2>Next word or quoted string</H2>
2.14      frystyk    76: 
                     77: This function returns a RFC822 word separated by space, comma, or
                     78: semi-colons.
                     79: 
2.9       frystyk    80: <PRE>
                     81: extern char * HTNextField PARAMS ((char** pstr));
2.14      frystyk    82: </PRE>
                     83: 
                     84: <H2>RFC1123 Date/Time Stamp String</H2>
                     85: 
                     86: Returns a pointer to a static area!
                     87: 
                     88: <PRE>
2.23    ! frystyk    89: extern CONST char *HTDateTimeStr       (time_t *calendar, BOOL local);
2.14      frystyk    90: </PRE>
                     91: 
2.23    ! frystyk    92: <H2>Date used for directory listings</H2>
        !            93: 
        !            94: <PRE>
        !            95: extern BOOL HTDateDirStr               (time_t * time, char * str, int len);
        !            96: </PRE>
2.14      frystyk    97: 
                     98: <H2>Timezone Offset</H2>
                     99: 
                    100: Calculates the offset from GMT in seconds. This is called from <A
2.22      frystyk   101: HREF="HTReq.html#Library">HTLibInit()</A>.
2.14      frystyk   102: 
                    103: <PRE>
                    104: extern long HTGetTimeZoneOffset NOPARAMS;
                    105: </PRE>
                    106: 
                    107: <H2>Parse a Date/Time String</H2>
                    108: 
                    109: Converts a string representation in GMT to a local representation of
                    110: localtime <CODE>time_t</CODE>.
                    111: 
                    112: <PRE>
                    113: extern time_t HTParseTime PARAMS((CONST char * str));
                    114: </PRE>
                    115: 
                    116: 
                    117: <H2>Unique Message-ID String</H2>
                    118: 
                    119: <PRE>
                    120: extern CONST char *HTMessageIdStr NOPARAMS;
2.9       frystyk   121: #endif
2.20      frystyk   122: </PRE>
                    123: 
                    124: <H2>Converts an Integer to a String using Prefix</H2>
                    125: 
                    126: In computer-world 1K is 1024 bytes and 1M is 1024K -- however,
                    127: sprintf() still formats in base-10.  Therefore I output only until
                    128: 999, and then start using the next unit.  This doesn't work wrong,
                    129: it's just a feature.  The conversion is done in "str" which must be
                    130: large enough to contain the result.
                    131: 
                    132: <PRE>
2.23    ! frystyk   133: extern void HTNumToStr (unsigned long n, char *str, int len);
        !           134: </PRE>
        !           135: 
        !           136: <H2>Conversion between URLs and Local File Names</H2>
        !           137: 
        !           138: These are two functions that separate the URL naming syntax from
        !           139: platform dependent file naming schemes. If you are porting the code to
        !           140: a new platform, you probably have to do some translation here.
        !           141: 
        !           142: <H3>Convert file URLs into a local representation</H3>
        !           143: 
        !           144: The URL has already been translated through the rules in get_physical
        !           145: in HTAccess.c and all we need to do now is to map the path to a local
        !           146: representation, for example if must translate '/' to the ones that
        !           147: turn the wrong way ;-) Returns local file (that must be freed by
        !           148: caller) if OK, else NULL.
        !           149: 
        !           150: <PRE>
        !           151: extern char * HTWWWToLocal (CONST char * url, CONST char * base);
        !           152: </PRE>
        !           153: 
        !           154: <H3>Convert a local file name into a URL</H3>
        !           155: 
        !           156: Generates a WWW URL name from a local file name or NULL if error.
        !           157: Returns URL (that must be freed by caller) if OK, else NULL.
        !           158: 
        !           159: <PRE>
        !           160: extern char * HTLocalToWWW (CONST char * local);
2.9       frystyk   161: </PRE>
2.14      frystyk   162: 
                    163: End of declaration module
2.1       timbl     164: 
2.6       timbl     165: </BODY>
2.9       frystyk   166: </HTML>

Webmaster