#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)
#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"
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)
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);