]> granicus.if.org Git - php/commitdiff
PHPAPIize url function to make them available to the outside (i.e. mbstring)
authorDaniel Beulshausen <dbeu@php.net>
Mon, 11 Jun 2001 15:14:04 +0000 (15:14 +0000)
committerDaniel Beulshausen <dbeu@php.net>
Mon, 11 Jun 2001 15:14:04 +0000 (15:14 +0000)
ext/standard/ftp_fopen_wrapper.c
ext/standard/http_fopen_wrapper.c
ext/standard/url.c
ext/standard/url.h

index f777a7518a9a6c8abb172effb41dfbaf861f11b6..1478970b02a9369b1730909d2e6c08d3d3b22dff 100644 (file)
@@ -90,14 +90,14 @@ FILE *php_fopen_url_wrap_ftp(char *path, char *mode, int options, int *issock, i
        int i;
        char *tpath, *ttpath;
        
-       resource = url_parse((char *) path);
+       resource = php_url_parse((char *) path);
        if (resource == NULL) {
                php_error(E_WARNING, "Invalid URL specified, %s", path);
                *issock = BAD_URL;
                return NULL;
        } else if (resource->path == NULL) {
                php_error(E_WARNING, "No file-path specified");
-               free_url(resource);
+               php_url_free(resource);
                *issock = BAD_URL;
                return NULL;
        }
@@ -110,12 +110,12 @@ FILE *php_fopen_url_wrap_ftp(char *path, char *mode, int options, int *issock, i
                goto errexit;
 #if 0
        if ((fpc = fdopen(*socketd, "r+")) == NULL) {
-               free_url(resource);
+               php_url_free(resource);
                return NULL;
        }
 #ifdef HAVE_SETVBUF
        if ((setvbuf(fpc, NULL, _IONBF, 0)) != 0) {
-               free_url(resource);
+               php_url_free(resource);
                fclose(fpc);
                return NULL;
        }
@@ -180,7 +180,7 @@ FILE *php_fopen_url_wrap_ftp(char *path, char *mode, int options, int *issock, i
                /* when reading file, it must exist */
                if (result > 299 || result < 200) {
                        php_error(E_WARNING, "File not found");
-                       free_url(resource);
+                       php_url_free(resource);
                        SOCK_FCLOSE(*socketd);
                        *socketd = 0;
                        errno = ENOENT;
@@ -190,7 +190,7 @@ FILE *php_fopen_url_wrap_ftp(char *path, char *mode, int options, int *issock, i
                /* when writing file, it must NOT exist */
                if (result <= 299 && result >= 200) {
                        php_error(E_WARNING, "File already exists");
-                       free_url(resource);
+                       php_url_free(resource);
                        SOCK_FCLOSE(*socketd);
                        *socketd = 0;
                        errno = EEXIST;
@@ -285,29 +285,29 @@ FILE *php_fopen_url_wrap_ftp(char *path, char *mode, int options, int *issock, i
 #if 0
        if (mode[0] == 'r') {
                if ((fp = fdopen(*socketd, "r+")) == NULL) {
-                       free_url(resource);
+                       php_url_free(resource);
                        return NULL;
                }
        } else {
                if ((fp = fdopen(*socketd, "w+")) == NULL) {
-                       free_url(resource);
+                       php_url_free(resource);
                        return NULL;
                }
        }
 #ifdef HAVE_SETVBUF
        if ((setvbuf(fp, NULL, _IONBF, 0)) != 0) {
-               free_url(resource);
+               php_url_free(resource);
                fclose(fp);
                return NULL;
        }
 #endif
 #endif
-       free_url(resource);
+       php_url_free(resource);
        *issock = 1;
        return (fp);
 
  errexit:
-       free_url(resource);
+       php_url_free(resource);
        SOCK_FCLOSE(*socketd);
        *socketd = 0;
        return NULL;
index db5735e9a7f770d5aaac063ca2381ee36ac15344..86e0f5a197f17558ec69a55aaf33e68186b3a65a 100644 (file)
@@ -86,7 +86,7 @@ FILE *php_fopen_url_wrap_http(char *path, char *mode, int options, int *issock,
        char *http_header_line;
        int http_header_line_length, http_header_line_size;
 
-       resource = url_parse((char *) path);
+       resource = php_url_parse((char *) path);
        if (resource == NULL) {
                php_error(E_WARNING, "Invalid URL specified, %s", path);
                *issock = BAD_URL;
@@ -101,17 +101,17 @@ FILE *php_fopen_url_wrap_http(char *path, char *mode, int options, int *issock,
        if (*socketd == -1) {
                SOCK_FCLOSE(*socketd);
                *socketd = 0;
-               free_url(resource);
+               php_url_free(resource);
                return NULL;
        }
 #if 0
        if ((fp = fdopen(*socketd, "r+")) == NULL) {
-               free_url(resource);
+               php_url_free(resource);
                return NULL;
        }
 #ifdef HAVE_SETVBUF
        if ((setvbuf(fp, NULL, _IONBF, 0)) != 0) {
-               free_url(resource);
+               php_url_free(resource);
                return NULL;
        }
 #endif
@@ -137,7 +137,7 @@ FILE *php_fopen_url_wrap_http(char *path, char *mode, int options, int *issock,
        if (resource->user != NULL && resource->pass != NULL) {
                scratch = (char *) emalloc(strlen(resource->user) + strlen(resource->pass) + 2);
                if (!scratch) {
-                       free_url(resource);
+                       php_url_free(resource);
                        return NULL;
                }
                strcpy(scratch, resource->user);
@@ -271,7 +271,7 @@ FILE *php_fopen_url_wrap_http(char *path, char *mode, int options, int *issock,
        if (!reqok) {
                SOCK_FCLOSE(*socketd);
                *socketd = 0;
-               free_url(resource);
+               php_url_free(resource);
                if (location[0] != '\0') {
                        zval **response_header_new, *entry, **entryp;
                        ELS_FETCH();
@@ -295,7 +295,7 @@ FILE *php_fopen_url_wrap_http(char *path, char *mode, int options, int *issock,
                        goto out;
                }
        }
-       free_url(resource);
+       php_url_free(resource);
        *issock = 1;
  out:
        {
index 45d69b5dc11cdc38a5bc0f57dcfc4daa2b60ff29..b7710fb738813e5c360d39396ecf18b77c76d4bb 100644 (file)
@@ -38,7 +38,7 @@
 
 /* {{{ free_url
  */
-void free_url(php_url * theurl)
+PHPAPI void php_url_free(php_url * theurl)
 {
        if (theurl->scheme)
                efree(theurl->scheme);
@@ -60,7 +60,7 @@ void free_url(php_url * theurl)
 
 /* {{{ url_parse
  */
-php_url *url_parse(char *str)
+PHPAPI php_url *php_url_parse(char *str)
 {
        regex_t re;
        regmatch_t subs[11];
@@ -175,7 +175,7 @@ PHP_FUNCTION(parse_url)
        }
        convert_to_string_ex(str);
 
-       resource = url_parse((*str)->value.str.val);
+       resource = php_url_parse((*str)->value.str.val);
 
        if (resource == NULL) {
                php_error(E_WARNING, "unable to parse url (%s)", (*str)->value.str.val);
@@ -183,7 +183,7 @@ PHP_FUNCTION(parse_url)
        }
        /* allocate an array for return */
        if (array_init(return_value) == FAILURE) {
-               free_url(resource);
+               php_url_free(resource);
                RETURN_FALSE;
        }
        /* add the various elements to the array */
@@ -203,7 +203,7 @@ PHP_FUNCTION(parse_url)
                add_assoc_string(return_value, "query", resource->query, 1);
        if (resource->fragment != NULL)
                add_assoc_string(return_value, "fragment", resource->fragment, 1);
-       free_url(resource);
+       php_url_free(resource);
 }
 /* }}} */
 
@@ -245,7 +245,7 @@ static unsigned char hexchars[] = "0123456789ABCDEF";
 
 /* {{{ php_url_encode
  */
-char *php_url_encode(char *s, int len)
+PHPAPI char *php_url_encode(char *s, int len)
 {
        register int x, y;
        unsigned char *str;
@@ -327,7 +327,7 @@ PHP_FUNCTION(urldecode)
 
 /* {{{ php_url_decode
  */
-int php_url_decode(char *str, int len)
+PHPAPI int php_url_decode(char *str, int len)
 {
        char *dest = str;
        char *data = str;
@@ -355,7 +355,7 @@ int php_url_decode(char *str, int len)
 
 /* {{{ php_raw_url_encode
  */
-char *php_raw_url_encode(char *s, int len)
+PHPAPI char *php_raw_url_encode(char *s, int len)
 {
        register int x, y;
        unsigned char *str;
@@ -430,7 +430,7 @@ PHP_FUNCTION(rawurldecode)
 
 /* {{{ php_raw_url_decode
  */
-int php_raw_url_decode(char *str, int len)
+PHPAPI int php_raw_url_decode(char *str, int len)
 {
        char *dest = str;
        char *data = str;
index 489975df26a2645e0be926e282ebf11ef8141233..6bf0f4fc08dfaacb4503024ca930e48043999a8b 100644 (file)
@@ -31,12 +31,12 @@ typedef struct php_url {
        char *fragment;
 } php_url;
 
-void free_url(php_url *);
-extern php_url *url_parse(char *);
-extern int php_url_decode(char *, int); /* return value: length of decoded string */
-extern char *php_url_encode(char *, int);
-extern int php_raw_url_decode(char *, int); /* return value: length of decoded string */
-extern char *php_raw_url_encode(char *, int);
+PHPAPI void php_url_free(php_url *);
+PHPAPI extern php_url *php_url_parse(char *);
+PHPAPI extern int php_url_decode(char *, int); /* return value: length of decoded string */
+PHPAPI extern char *php_url_encode(char *, int);
+PHPAPI extern int php_raw_url_decode(char *, int); /* return value: length of decoded string */
+PHPAPI extern char *php_raw_url_encode(char *, int);
 
 PHP_FUNCTION(parse_url);
 PHP_FUNCTION(urlencode);