cvs: /php4 php_virtual_cwd.c php_virtual_cwd.h

From: Date: Sat, 01 Apr 2000 18:21:33 +0000
Subject: cvs: /php4 php_virtual_cwd.c php_virtual_cwd.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-12996@lists.php.net to get a copy of this message
andi Sat Apr 1 10:21:33 2000 EDT Modified files: /php4 php_virtual_cwd.c php_virtual_cwd.h Log: - More virtual_cwd work Index: php4/php_virtual_cwd.c diff -u php4/php_virtual_cwd.c:1.17 php4/php_virtual_cwd.c:1.18 --- php4/php_virtual_cwd.c:1.17 Sat Apr 1 10:11:08 2000 +++ php4/php_virtual_cwd.c Sat Apr 1 10:21:03 2000 @@ -16,6 +16,8 @@ cwd_globals_struct cwd_globals; #endif +cwd_state true_global_cwd_state; + #ifndef PHP_WIN32 #include <unistd.h> #endif @@ -108,9 +110,29 @@ return (1); } -void virtual_cwd_init() +static void cwd_globals_ctor(cwd_globals_struct *cwd_globals) { - /* Initialize the true global cwd */ + cwd_globals->cwd.cwd = (char *) malloc(true_global_cwd_state.cwd_length+1); + memcpy(cwd_globals->cwd.cwd, true_global_cwd_state.cwd, true_global_cwd_state.cwd_length+1); + cwd_globals->cwd.cwd_length = true_global_cwd_state.cwd_length; +} + +void virtual_cwd_startup() +{ + char cwd[1024]; /* Should probably use system define here */ + char *result; + + result = getcwd(cwd, sizeof(cwd)); + if (!result) { + cwd[0] = '\0'; + } + true_global_cwd_state.cwd = strdup(cwd); + true_global_cwd_state.cwd_length = strlen(cwd); +#ifdef ZTS + cwd_globals_id = ts_allocate_id(sizeof(cwd_globals_struct), (ts_allocate_ctor) cwd_globals_ctor, NULL); +#else + cwd_globals_ctor(&cwd_globals); +#endif } char *virtual_getcwd_ex(int *length) Index: php4/php_virtual_cwd.h diff -u php4/php_virtual_cwd.h:1.3 php4/php_virtual_cwd.h:1.4 --- php4/php_virtual_cwd.h:1.3 Sat Apr 1 10:11:08 2000 +++ php4/php_virtual_cwd.h Sat Apr 1 10:21:03 2000 @@ -20,7 +20,7 @@ typedef int (*verify_path_func)(const cwd_state *); -void virtual_cwd_init(); +void virtual_cwd_startup(); char *virtual_getcwd_ex(int *length); char *virtual_getcwd(char *buf, size_t size); int virtual_chdir(char *path);

« previous php.version4 (#12996) next »