diff options
author | Andi Gutmans <andi@php.net> | 2000-04-30 16:32:36 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2000-04-30 16:32:36 +0000 |
commit | e13285ded79f94c9349763f59014eb467357cefc (patch) | |
tree | d777a222d182ac6f6fbace611e27d7cddf06f478 | |
parent | 8e7a5098dd31cc768c34c046820822dfeb9d048d (diff) | |
download | php-git-e13285ded79f94c9349763f59014eb467357cefc.tar.gz |
- Take Sascha's advice and create on V_OPEN() which replaces open().
- Unlike the other macros its argument has to have braces around it, for
- example, open(filename, flags) becomse V_OPEN((filename, flags))
- Made small conversion to new Zend macros. The ugly (*foo)->value.str.val
- now becomes Z_STRVAL_PP(foo). PP means pointer pointer, there also exist
- single P's for example foo->value.str.val becomes Z_STRVAL_P(foo).
-rw-r--r-- | ext/standard/file.c | 14 | ||||
-rw-r--r-- | main/php.h | 7 |
2 files changed, 10 insertions, 11 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index 847b574c85..37bd5c233b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1559,26 +1559,26 @@ PHP_FUNCTION(copy) } #ifdef PHP_WIN32 - if ((fd_s=open((*source)->value.str.val,O_RDONLY|_O_BINARY))==-1) { + if ((fd_s=V_OPEN((Z_STRVAL_PP(source),O_RDONLY|_O_BINARY)))==-1) { #else - if ((fd_s=open((*source)->value.str.val,O_RDONLY))==-1) { + if ((fd_s=V_OPEN((Z_STRVAL_PP(source),O_RDONLY)))==-1) { #endif - php_error(E_WARNING,"Unable to open '%s' for reading: %s",(*source)->value.str.val,strerror(errno)); + php_error(E_WARNING,"Unable to open '%s' for reading: %s", Z_STRVAL_PP(source), strerror(errno)); RETURN_FALSE; } #ifdef PHP_WIN32 - if ((fd_t=open((*target)->value.str.val,_O_WRONLY|_O_CREAT|_O_TRUNC|_O_BINARY,_S_IREAD|_S_IWRITE))==-1){ + if ((fd_t=V_OPEN((Z_STRVAL_PP(target),_O_WRONLY|_O_CREAT|_O_TRUNC|_O_BINARY,_S_IREAD|_S_IWRITE)))==-1){ #else - if ((fd_t=creat((*target)->value.str.val,0777))==-1) { + if ((fd_t=V_CREAT(Z_STRVAL_PP(target),0777))==-1) { #endif - php_error(E_WARNING,"Unable to create '%s': %s", (*target)->value.str.val,strerror(errno)); + php_error(E_WARNING,"Unable to create '%s': %s", Z_STRVAL_PP(target), strerror(errno)); close(fd_s); RETURN_FALSE; } while ((read_bytes=read(fd_s,buffer,8192))!=-1 && read_bytes!=0) { if (write(fd_t,buffer,read_bytes)==-1) { - php_error(E_WARNING,"Unable to write to '%s': %s",(*target)->value.str.val,strerror(errno)); + php_error(E_WARNING,"Unable to write to '%s': %s", Z_STRVAL_PP(target), strerror(errno)); close(fd_s); close(fd_t); RETURN_FALSE; diff --git a/main/php.h b/main/php.h index 75facd3895..64d6b3f782 100644 --- a/main/php.h +++ b/main/php.h @@ -298,8 +298,8 @@ PHPAPI int cfg_get_string(char *varname, char **result); #ifdef VIRTUAL_DIR #define V_GETCWD(buff, size) virtual_getcwd(buff,size) #define V_FOPEN(path, mode) virtual_fopen(path, mode) -#define V_OPEN(path, flags) virtual_open(path, flags) -#define V_OPEN_CREAT(path, flags, mode) virtual_open(path, flags, mode) +/* The V_OPEN macro will need to be used as V_OPEN((path, flags, ...)) */ +#define V_OPEN(open_args) virtual_open open_args #define V_CREAT(path, mode) virtual_creat(path, mode) #define V_CHDIR(path) virtual_chdir(path) #define V_CHDIR_FILE(path) virtual_chdir_file(path) @@ -313,8 +313,7 @@ PHPAPI int cfg_get_string(char *varname, char **result); #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) -#define V_OPEN(path, flags) open(path, flags) -#define V_OPEN_CREAT(path, flags, mode) open(path, flags, mode) +#define V_OPEN(open_args) open open_args #define V_CREAT(path, mode) creat(path, mode) #define V_CHDIR(path) chdir(path) #define V_CHDIR_FILE(path) chdir_file(path) |