home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htparse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.0 KB  |  155 lines

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