Justtechjobs.com Find a programming school near you






Online Campus Both


php4-beta | 200004

[PHP4BETA] cvs: /php4 php.h /php4/ext/standard file.c From: Andi Gutmans (andi <email protected>)
Date: 04/30/00

andi Sun Apr 30 09:32:37 2000 EDT

  Modified files:
    /php4 php.h
    /php4/ext/standard file.c
  Log:
  - 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).
  
  
Index: php4/php.h
diff -u php4/php.h:1.90 php4/php.h:1.91
--- php4/php.h:1.90 Sat Apr 29 12:01:58 2000
+++ php4/php.h Sun Apr 30 09:32:36 2000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php.h,v 1.90 2000/04/29 19:01:58 andi Exp $ */
+/* $Id: php.h,v 1.91 2000/04/30 16:32:36 andi Exp $ */
 
 #ifndef _PHP_H
 #define _PHP_H
@@ -298,8 +298,8 @@
 #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 @@
 #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)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.76 php4/ext/standard/file.c:1.77
--- php4/ext/standard/file.c:1.76 Mon Apr 24 07:19:21 2000
+++ php4/ext/standard/file.c Sun Apr 30 09:32:36 2000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.76 2000/04/24 14:19:21 andrei Exp $ */
+/* $Id: file.c,v 1.77 2000/04/30 16:32:36 andi Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1559,26 +1559,26 @@
         }
         
 #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;

-- 
PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
To unsubscribe, e-mail: php4beta-unsubscribe <email protected>
For additional commands, e-mail: php4beta-help <email protected>
To contact the list administrators, e-mail: php4beta-admin <email protected>