Annotation of libwww/Library/src/HTParse.html, revision 2.7

2.2       timbl       1: <HEADER>
2.6       timbl       2: <TITLE>HTParse:  URL parsing in the WWW Library</TITLE>
                      3: <NEXTID N="1">
                      4: </HEADER>
2.2       timbl       5: <BODY>
                      6: <H1>HTParse</H1>This module of the WWW library contains
                      7: code to parse URLs and various related
2.6       timbl       8: things.  Implemented by <A
2.7     ! timbl       9: NAME=z0 HREF="HTParse.c">HTParse.c</A>
        !            10: .
2.2       timbl      11: <PRE>#ifndef HTPARSE_H
                     12: #define HTPARSE_H
                     13: #include "HTUtils.h"
                     14: 
                     15: </PRE>The following are flag bits which
                     16: may be ORed together to form a number
                     17: to give the 'wanted' argument to
                     18: HTParse.
                     19: <PRE>#define PARSE_ACCESS              16
2.1       timbl      20: #define PARSE_HOST              8
                     21: #define PARSE_PATH              4
                     22: #define PARSE_ANCHOR            2
                     23: #define PARSE_PUNCTUATION       1
                     24: #define PARSE_ALL              31
                     25: 
2.2       timbl      26: 
                     27: </PRE>
2.6       timbl      28: <H2>HTParse:  Parse a URL relative to
                     29: another URL</H2>This returns those parts of a name
2.2       timbl      30: which are given (and requested) substituting
                     31: bits from the related name where
                     32: necessary.
                     33: <H3>On entry</H3>
                     34: <DL>
                     35: <DT>aName
                     36: <DD> A filename given
                     37: <DT>relatedName
                     38: <DD> A name relative to which
                     39: aName is to be parsed
                     40: <DT>wanted
                     41: <DD> A mask for the bits which
                     42: are wanted.
                     43: </DL>
                     44: 
                     45: <H3>On exit,</H3>
                     46: <DL>
                     47: <DT>returns
                     48: <DD> A pointer to a malloc'd string
                     49: which MUST BE FREED
                     50: </DL>
                     51: 
                     52: <PRE>
                     53: extern char * HTParse  PARAMS((const char * aName, const char * relatedName, int wanted));
                     54: 
2.1       timbl      55: 
2.2       timbl      56: </PRE>
                     57: <H2>HTStrip: Strip white space off a
                     58: string</H2>
                     59: <H3>On exit</H3>Return value points to first non-white
                     60: character, or to 0 if none.<P>
                     61: All trailing white space is OVERWRITTEN
                     62: with zero.
                     63: <PRE>#ifdef __STDC__
2.1       timbl      64: extern char * HTStrip(char * s);
                     65: #else
                     66: extern char * HTStrip();
                     67: #endif
                     68: 
2.2       timbl      69: </PRE>
2.6       timbl      70: <H2>HTSimplify: Simplify a UTL</H2>A URL is allowed to contain the seqeunce
2.2       timbl      71: xxx/../ which may be replaced by
                     72: "" , and the seqeunce "/./" which
                     73: may be replaced by "/". Simplification
                     74: helps us recognize duplicate filenames.
                     75: It doesn't deal with soft links,
                     76: though. The new (shorter) filename
                     77: overwrites the old.
                     78: <PRE>/*
2.1       timbl      79: **     Thus,   /etc/junk/../fred       becomes /etc/fred
                     80: **             /etc/junk/./fred        becomes /etc/junk/fred
                     81: */
                     82: #ifdef __STDC__
                     83: extern void HTSimplify(char * filename);
                     84: #else
                     85: extern void HTSimplify();
                     86: #endif
                     87: 
2.6       timbl      88: 
2.2       timbl      89: </PRE>
2.6       timbl      90: <H2>HTRelative:  Make Relative (Partial)
                     91: URL</H2>This function creates and returns
2.2       timbl      92: a string which gives an expression
                     93: of one address as related to another.
                     94: Where there is no relation, an absolute
                     95: address is retured.
                     96: <H3>On entry,</H3>Both names must be absolute, fully
                     97: qualified names of nodes (no anchor
                     98: bits)
                     99: <H3>On exit,</H3>The return result points to a newly
                    100: allocated name which, if parsed by
                    101: HTParse relative to relatedName,
                    102: will yield aName. The caller is responsible
                    103: for freeing the resulting name later.
                    104: <PRE>#ifdef __STDC__
2.1       timbl     105: extern char * HTRelative(const char * aName, const char *relatedName);
                    106: #else
                    107: extern char * HTRelative();
                    108: #endif
2.2       timbl     109: 
2.6       timbl     110: 
                    111: </PRE>
                    112: <H2>HTEscape:  Encode unacceptable characters
                    113: in string</H2>This funtion takes a string containing
                    114: any sequence of ASCII characters,
                    115: and returns a malloced string containing
                    116: the same infromation but with all
                    117: "unacceptable" characters represented
                    118: in the form %xy where X and Y are
                    119: two hex digits.
2.7     ! timbl     120: <PRE>extern char * HTEscape PARAMS((CONST char * str, unsigned char mask));
2.6       timbl     121: 
                    122: </PRE>The following are valid mask values.
2.7     ! timbl     123: The terms are the BNF names in the
2.6       timbl     124: URL document.
                    125: <PRE>#define URL_XALPHAS       (unsigned char) 1
                    126: #define URL_XPALPHAS   (unsigned char) 2
                    127: #define URL_PATH       (unsigned char) 4
                    128: 
                    129: 
2.1       timbl     130: </PRE>
2.2       timbl     131: <H2>HTUnEscape: Decode %xx escaped characters</H2>This function takes a pointer to
                    132: a string in which character smay
                    133: have been encoded in %xy form, where
                    134: xy is the acsii hex code for character
                    135: 16x+y. The string is converted in
                    136: place, as it will never grow.
                    137: <PRE>extern char * HTUnEscape PARAMS(( char * str));
                    138: 
                    139: 
2.6       timbl     140: #endif /* HTPARSE_H */
2.2       timbl     141: 
                    142: 
2.7     ! timbl     143: </PRE>end of HTParse</A><P>
        !           144: </BODY>

Webmaster