From c6b4e558387aae58d1bff9c61fe274fb570a904c Mon Sep 17 00:00:00 2001 From: Daniel Beulshausen Date: Mon, 11 Jun 2001 15:14:04 +0000 Subject: [PATCH] PHPAPIize url function to make them available to the outside (i.e. mbstring) --- ext/standard/ftp_fopen_wrapper.c | 22 +++++++++++----------- ext/standard/http_fopen_wrapper.c | 14 +++++++------- ext/standard/url.c | 18 +++++++++--------- ext/standard/url.h | 12 ++++++------ 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index f777a7518a..1478970b02 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -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; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index db5735e9a7..86e0f5a197 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -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: { diff --git a/ext/standard/url.c b/ext/standard/url.c index 45d69b5dc1..b7710fb738 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -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; diff --git a/ext/standard/url.h b/ext/standard/url.h index 489975df26..6bf0f4fc08 100644 --- a/ext/standard/url.h +++ b/ext/standard/url.h @@ -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); -- 2.50.1