- 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).
This commit is contained in:
Andi Gutmans 2000-04-30 16:32:36 +00:00
parent 8e7a5098dd
commit e13285ded7
2 changed files with 10 additions and 11 deletions

View file

@ -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;

View file

@ -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)