cvs: php4 /main/ php.h php_virtual_cwd.c php_virtual_cwd.h

From: Date: Mon, 12 Jun 2000 18:48:18 +0000
Subject: cvs: php4 /main/ php.h php_virtual_cwd.c php_virtual_cwd.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-194@lists.php.net to get a copy of this message
andi Mon Jun 12 11:48:18 2000 EDT Modified files: /php4/main php.h php_virtual_cwd.c php_virtual_cwd.h Log: - Start of popen() fix for UNIX. Still unclear what we'll do on Windows. Index: php4/main/php.h diff -u php4/main/php.h:1.103 php4/main/php.h:1.104 --- php4/main/php.h:1.103 Wed Jun 7 23:16:22 2000 +++ php4/main/php.h Mon Jun 12 11:48:18 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.103 2000/06/08 06:16:22 sas Exp $ */ +/* $Id: php.h,v 1.104 2000/06/12 18:48:18 andi Exp $ */ #ifndef _PHP_H #define _PHP_H @@ -307,6 +307,7 @@ #define V_MKDIR(pathname, mode) virtual_mkdir(pathname, mode) #define V_RMDIR(pathname) virtual_rmdir(pathname) #define V_OPENDIR(pathname) virtual_opendir(pathname) +#define V_POPEN(command, type) virtual_popen(command, type) #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) @@ -321,6 +322,7 @@ #define V_MKDIR(pathname, mode) mkdir(pathname, mode) #define V_RMDIR(pathname) rmdir(pathname) #define V_OPENDIR(pathname) opendir(pathname) +#define V_POPEN(command, type) popen(command, type) #endif #include "zend_constants.h" Index: php4/main/php_virtual_cwd.c diff -u php4/main/php_virtual_cwd.c:1.52 php4/main/php_virtual_cwd.c:1.53 --- php4/main/php_virtual_cwd.c:1.52 Sat Jun 10 08:15:28 2000 +++ php4/main/php_virtual_cwd.c Mon Jun 12 11:48:18 2000 @@ -555,6 +555,40 @@ return retval; } +CWD_API FILE *virtual_popen(const char *command, const char *type) +{ + int command_length; + char *command_line; + char *ptr; + FILE *retval; + CWDLS_FETCH(); + + command_length = strlen(command); + + ptr = command_line = (char *) malloc(command_length + sizeof("cd ; ") + CWDG(cwd).cwd_length+1); + if (!command_line) { + return NULL; + } + memcpy(ptr, "cd ", sizeof("cd ")-1); + ptr += sizeof("cd "); + + if (CWDG(cwd).cwd_length == 0) { + *ptr++ = DEFAULT_SLASH; + } else { + memcpy(ptr, CWDG(cwd).cwd, CWDG(cwd).cwd_length); + ptr += CWDG(cwd).cwd_length; + } + + *ptr++ = ' '; + *ptr++ = ';'; + *ptr++ = ' '; + + memcpy(ptr, command, command_length+1); + retval = popen(command_line, type); + free(command_line); + return retval; +} + #if 0 main(void) Index: php4/main/php_virtual_cwd.h diff -u php4/main/php_virtual_cwd.h:1.24 php4/main/php_virtual_cwd.h:1.25 --- php4/main/php_virtual_cwd.h:1.24 Sun Jun 4 01:29:11 2000 +++ php4/main/php_virtual_cwd.h Mon Jun 12 11:48:18 2000 @@ -59,6 +59,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode); CWD_API int virtual_rmdir(const char *pathname); CWD_API DIR *virtual_opendir(const char *pathname); +CWD_API FILE *virtual_popen(const char *command, const char *type); CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);

« previous php.cvs (#194) next »