You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by fi...@apache.org on 2001/05/22 03:22:06 UTC

cvs commit: apr-util/uri Makefile.in apr_uri.c

fielding    01/05/21 18:22:06

  Modified:    include  apr_uri.h
               uri      Makefile.in apr_uri.c
  Log:
  Basic changes in apr_uri.c:
  1) Rename from apr_parse_uri_components to apr_uri_parse_components
     and others along this vein to make all of the functions of the
     form apr_uri_*.  I dropped the second uri in the parse components
     because it seemed too redundant.
  2) uri_components -> apr_uri_components
  3) Removed the ap_default_port_for_request function.  No one seems to
     use it anyway.
  4) APU_DECLARE added
  
  - I imagine that this might break a bunch of stuff in Win32 or other OS
    builds with foreign dependency files.  Any help here is appreciated.
  
  This is a start...  -- justin
  
  Submitted by:	Justin Erenkrantz
  Reviewed by:	Roy Fielding
  
  Revision  Changes    Path
  1.2       +36 -30    apr-util/include/apr_uri.h
  
  Index: apr_uri.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_uri.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_uri.h	2001/05/22 01:07:43	1.1
  +++ apr_uri.h	2001/05/22 01:22:03	1.2
  @@ -57,12 +57,16 @@
    */
   
   /*
  - * util_uri.h: External Interface of util_uri.c
  + * apr_uri.h: External Interface of apr_uri.c
    */
   
  -#ifndef UTIL_URI_H
  -#define UTIL_URI_H
  +#ifndef APR_URI_H
  +#define APR_URI_H
   
  +#include "apu.h"
  +
  +#include <apr_network_io.h>
  +
   #ifdef __cplusplus
   extern "C" {
   #endif
  @@ -84,8 +88,14 @@
   #define	DEFAULT_FTP_DATA_PORT	20
   #define	DEFAULT_FTP_PORT	21
   #define	DEFAULT_GOPHER_PORT	70
  +#ifndef DEFAULT_HTTP_PORT
  +#define	DEFAULT_HTTP_PORT	80
  +#endif
   #define	DEFAULT_NNTP_PORT	119
   #define	DEFAULT_WAIS_PORT	210
  +#ifndef DEFAULT_HTTPS_PORT
  +#define	DEFAULT_HTTPS_PORT	443
  +#endif
   #define	DEFAULT_SNEWS_PORT	563
   #define	DEFAULT_PROSPERO_PORT	1525	/* WARNING: conflict w/Oracle */
   
  @@ -98,12 +108,12 @@
   #define UNP_OMITPATHINFO	(1U<<4)	/* Show "scheme://user@site:port" only */
   #define UNP_OMITQUERY	        (1U<<5)	/* Omit the "?queryarg" from the path */
   
  -typedef struct uri_components uri_components;
  +typedef struct apr_uri_components apr_uri_components;
   
   /**
    * A structure to encompass all of the fields in a uri
    */
  -struct uri_components {
  +struct apr_uri_components {
       /** scheme ("http"/"ftp"/...) */
       char *scheme;
       /** combined [user[:password]@]host[:port] */
  @@ -139,29 +149,21 @@
       unsigned dns_resolved:1;
   };
   
  -/* util_uri.c */
  +/* apr_uri.c */
   /**
    * Return the default port for a given scheme.  The schemes recognized are
    * http, ftp, https, gopher, wais, nntp, snews, and prospero
    * @param scheme_str The string that contains the current scheme
    * @return The default port for this scheme
  - * @deffunc apr_port_t ap_default_port_for_scheme(const char *scheme_str)
  + * @deffunc apr_port_t apr_uri_default_port_for_scheme(const char *scheme_str)
    */ 
  -AP_DECLARE(apr_port_t) ap_default_port_for_scheme(const char *scheme_str);
  -
  -/**
  - * Return the default for the current request
  - * @param r The current request
  - * @return The default port
  - * @deffunc apr_port_t ap_default_port_for_request(const request_rec *r)
  - */
  -AP_DECLARE(apr_port_t) ap_default_port_for_request(const request_rec *r);
  +APU_DECLARE(apr_port_t) apr_uri_default_port_for_scheme(const char *scheme_str);
   
   /**
  - * Unparse a uri_components structure to an URI string.  Optionally suppress 
  - * the password for security reasons.
  + * Unparse a apr_uri_components structure to an URI string.  Optionally 
  + * suppress the password for security reasons.
    * @param p The pool to allocate out of
  - * @param uri_components All of the parts of the uri
  + * @param uptr All of the parts of the uri
    * @param flags How to unparse the uri.  One of:
    * <PRE>
    *    UNP_OMITSITEPART        suppress "scheme://user@site:port" 
  @@ -173,35 +175,39 @@
    *    UNP_OMITQUERY           Omit the "?queryarg" from the path 
    * </PRE>
    * @return The uri as a string
  - * @deffunc char * ap_unparse_uri_components(apr_pool_t *p, const uri_components *uptr, unsigned flags)
  + * @deffunc char * apr_uri_unparse_components(apr_pool_t *p, const apr_uri_components *uptr, unsigned flags)
    */
  -AP_DECLARE(char *) ap_unparse_uri_components(apr_pool_t *p, const uri_components *uptr,
  -    unsigned flags);
  +APU_DECLARE(char *) apr_uri_unparse_components(apr_pool_t *p, 
  +                                               const apr_uri_components *uptr,
  +                                               unsigned flags);
   
   /**
  - * Parse a given URI, fill in all supplied fields of a uri_components
  + * Parse a given URI, fill in all supplied fields of a apr_uri_components
    * structure. This eliminates the necessity of extracting host, port,
    * path, query info repeatedly in the modules.
    * @param p The pool to allocate out of
    * @param uri The uri to parse
  - * @param uptr The uri_components to fill out
  + * @param uptr The apr_uri_components to fill out
    * @return An HTTP status code
  - * @deffunc int ap_parse_uri_components(apr_pool_t *p, const char *uri, uri_components *uptr)
  + * @deffunc int apr_uri_parse_components(apr_pool_t *p, const char *uri, apr_uri_components *uptr)
    */
  -AP_DECLARE(int) ap_parse_uri_components(apr_pool_t *p, const char *uri, uri_components *uptr);
  +APU_DECLARE(int) apr_uri_parse_components(apr_pool_t *p, const char *uri, 
  +                                          apr_uri_components *uptr);
   
   /**
    * Special case for CONNECT parsing: it comes with the hostinfo part only
    * @param p The pool to allocate out of
    * @param hostinfo The hostinfo string to parse
  - * @param uptr The uri_components to fill out
  + * @param uptr The apr_uri_components to fill out
    * @return An HTTP status code
  - * @deffunc int ap_parse_hostinfo_components(apr_pool_t *p, const char *hostinfo, uri_components *uptr)
  + * @deffunc int apr_parse_hostinfo_components(apr_pool_t *p, const char *hostinfo, apr_uri_components *uptr)
    */
  -AP_DECLARE(int) ap_parse_hostinfo_components(apr_pool_t *p, const char *hostinfo, uri_components *uptr);
  +APU_DECLARE(int) apr_uri_parse_hostinfo_components(apr_pool_t *p, 
  +                                                   const char *hostinfo, 
  +                                                   apr_uri_components *uptr);
   
   #ifdef __cplusplus
   }
   #endif
   
  -#endif /*UTIL_URI_H*/
  +#endif /*APR_URI_H*/
  
  
  
  1.4       +10 -0     apr-util/uri/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr-util/uri/Makefile.in,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile.in	2001/01/07 01:35:51	1.3
  +++ Makefile.in	2001/05/22 01:22:05	1.4
  @@ -1,2 +1,12 @@
  +TARGETS = uri_delims.h apr_uri.lo
  +CLEAN_TARGETS = gen_uri_delims uri_delims.h
  +
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  +
  +gen_uri_delims_OBJECTS = gen_uri_delims.o
  +gen_uri_delims: $(gen_uri_delims_OBJECTS)
  +	$(LINK) $(EXTRA_LDFLAGS) $(gen_uri_delims_OBJECTS) $(EXTRA_LIBS)
  +
  +uri_delims.h: gen_uri_delims
  +	./gen_uri_delims > uri_delims.h
  
  
  
  1.2       +26 -29    apr-util/uri/apr_uri.c
  
  Index: apr_uri.c
  ===================================================================
  RCS file: /home/cvs/apr-util/uri/apr_uri.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_uri.c	2001/05/22 01:07:44	1.1
  +++ apr_uri.c	2001/05/22 01:22:05	1.2
  @@ -57,20 +57,20 @@
    */
   
   /*
  - * util_uri.c: URI related utility things
  + * apr_uri.c: URI related utility things
    * 
    */
   
  +#include <stdlib.h>
  +
  +#include "apu.h"
   #include "apr.h"
   #include "apr_strings.h"
   
   #define APR_WANT_STRFUNC
   #include "apr_want.h"
   
  -#include "ap_config.h"
  -#include "httpd.h"
  -#include "http_log.h"
  -#include "util_uri.h"
  +#include "apr_uri.h"
   
   /* Some WWW schemes and their default ports; this is basically /etc/services */
   /* This will become global when the protocol abstraction comes */
  @@ -88,9 +88,8 @@
       {"prospero", DEFAULT_PROSPERO_PORT},
       { NULL, 0xFFFF }			/* unknown port */
   };
  -
   
  -AP_DECLARE(apr_port_t) ap_default_port_for_scheme(const char *scheme_str)
  +APU_DECLARE(apr_port_t) apr_uri_default_port_for_scheme(const char *scheme_str)
   {
       schemes_t *scheme;
   
  @@ -100,18 +99,13 @@
   
       return 0;
   }
  -
  -AP_DECLARE(apr_port_t) ap_default_port_for_request(const request_rec *r)
  -{
  -    return (r->parsed_uri.scheme)
  -	? ap_default_port_for_scheme(r->parsed_uri.scheme)
  -	: 0;
  -}
   
  -/* Unparse a uri_components structure to an URI string.
  +/* Unparse a apr_uri_components structure to an URI string.
    * Optionally suppress the password for security reasons.
    */
  -AP_DECLARE(char *) ap_unparse_uri_components(apr_pool_t *p, const uri_components *uptr, unsigned flags)
  +APU_DECLARE(char *) apr_uri_unparse_components(apr_pool_t *p, 
  +                                               const apr_uri_components *uptr, 
  +                                               unsigned flags)
   {
       char *ret = "";
   
  @@ -135,7 +129,7 @@
   	    is_default_port =
   		(uptr->port_str == NULL ||
   		 uptr->port == 0 ||
  -		 uptr->port == ap_default_port_for_scheme(uptr->scheme));
  +		 uptr->port == apr_uri_default_port_for_scheme(uptr->scheme));
   
   	    ret = apr_pstrcat (p,
   			uptr->scheme, "://", ret, 
  @@ -202,7 +196,8 @@
    *  - fills in fields of uri_components *uptr
    *  - none on any of the r->* fields
    */
  -AP_DECLARE(int) ap_parse_uri_components(apr_pool_t *p, const char *uri, uri_components *uptr)
  +APU_DECLARE(int) apr_uri_parse_components(apr_pool_t *p, const char *uri, 
  +                                          apr_uri_components *uptr)
   {
       const char *s;
       const char *s1;
  @@ -233,11 +228,11 @@
   	    uptr->path = apr_pstrndup(p, uri, s - uri);
   	}
   	if (*s == 0) {
  -	    return HTTP_OK;
  +	    return APR_SUCCESS;
   	}
   	if (*s == '?') {
   	    ++s;
  -	    s1 = ap_strchr_c(s, '#');
  +	    s1 = strchr(s, '#');
   	    if (s1) {
   		uptr->fragment = apr_pstrdup(p, s1 + 1);
   		uptr->query = apr_pstrndup(p, s, s1 - s);
  @@ -245,11 +240,11 @@
   	    else {
   		uptr->query = apr_pstrdup(p, s);
   	    }
  -	    return HTTP_OK;
  +	    return APR_SUCCESS;
   	}
   	/* otherwise it's a fragment */
   	uptr->fragment = apr_pstrdup(p, s + 1);
  -	return HTTP_OK;
  +	return APR_SUCCESS;
       }
   
       /* find the scheme: */
  @@ -301,9 +296,9 @@
   		goto deal_with_path;
   	    }
   	    /* Invalid characters after ':' found */
  -	    return HTTP_BAD_REQUEST;
  +	    return APR_EGENERAL;
   	}
  -	uptr->port = ap_default_port_for_scheme(uptr->scheme);
  +	uptr->port = apr_uri_default_port_for_scheme(uptr->scheme);
   	goto deal_with_path;
       }
   
  @@ -326,7 +321,9 @@
    * currently at http://www.mcom.com/newsref/std/tunneling_ssl.html
    * for the format of the "CONNECT host:port HTTP/1.0" request
    */
  -AP_DECLARE(int) ap_parse_hostinfo_components(apr_pool_t *p, const char *hostinfo, uri_components *uptr)
  +APU_DECLARE(int) apr_uri_parse_hostinfo_components(apr_pool_t *p, 
  +                                                   const char *hostinfo, 
  +                                                   apr_uri_components *uptr)
   {
       const char *s;
       char *endstr;
  @@ -341,9 +338,9 @@
       /* We expect hostinfo to point to the first character of
        * the hostname.  There must be a port, separated by a colon
        */
  -    s = ap_strchr_c(hostinfo, ':');
  +    s = strchr(hostinfo, ':');
       if (s == NULL) {
  -	return HTTP_BAD_REQUEST;
  +	return APR_EGENERAL;
       }
       uptr->hostname = apr_pstrndup(p, hostinfo, s - hostinfo);
       ++s;
  @@ -351,9 +348,9 @@
       if (*s != '\0') {
   	uptr->port = (unsigned short) strtol(uptr->port_str, &endstr, 10);
   	if (*endstr == '\0') {
  -	    return HTTP_OK;
  +	    return APR_SUCCESS;
   	}
   	/* Invalid characters after ':' found */
       }
  -    return HTTP_BAD_REQUEST;
  +    return APR_EGENERAL;
   }