cvs: php4 / php.h php_virtual_cwd.c php_virtual_cwd.h /dl/log/ log_db.c /ext/standard/ file.c
[email protected] ("Andi Gutmans")
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <cvsandi959101341@cvsserver> |
andi Tue May 23 19:02:22 2000 EDT
Modified files:
/php4 php.h php_virtual_cwd.c php_virtual_cwd.h
/php4/dl/log log_db.c
/php4/ext/standard file.c
Log:
- Virtual current working directory is now enabled
- Added support for mkdir()/rmdir() and more
Index: php4/php.h
diff -u php4/php.h:1.94 php4/php.h:1.95
--- php4/php.h:1.94 Tue May 23 16:36:26 2000
+++ php4/php.h Tue May 23 19:02:21 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.94 2000/05/23 14:36:26 andi Exp $ */
+/* $Id: php.h,v 1.95 2000/05/23 17:02:21 andi Exp $ */
#ifndef _PHP_H
#define _PHP_H
@@ -289,7 +289,7 @@
#define PUTS_H(str) php_header_write((str), strlen((str)))
#define PUTC_H(c) (php_header_write(&(c), 1), (c))
-/* #define VIRTUAL_DIR */
+#define VIRTUAL_DIR
#include "php_virtual_cwd.h"
/* Virtual current directory support */
@@ -309,6 +309,8 @@
#define V_LSTAT(path, buff) virtual_lstat(path, buff)
#endif
#define V_UNLINK(path) virtual_unlink(path)
+#define V_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
+#define V_RMDIR(pathname) virtual_rmdir(pathname)
#else
#define V_GETCWD(buff, size) getcwd(buff,size)
#define V_FOPEN(path, mode) fopen(path, mode)
@@ -320,6 +322,8 @@
#define V_STAT(path, buff) stat(path, buff)
#define V_LSTAT(path, buff) lstat(path, buff)
#define V_UNLINK(path) unlink(path)
+#define V_MKDIR(pathname, mode) mkdir(pathname, mode)
+#define V_RMDIR(pathname) rmdir(pathname)
#endif
#include "zend_constants.h"
Index: php4/php_virtual_cwd.c
diff -u php4/php_virtual_cwd.c:1.45 php4/php_virtual_cwd.c:1.46
--- php4/php_virtual_cwd.c:1.45 Tue May 23 16:36:26 2000
+++ php4/php_virtual_cwd.c Tue May 23 19:02:21 2000
@@ -373,9 +373,10 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
retval = virtual_file_ex(&new_state, path, php_is_file_ok);
+
*filepath = new_state.cwd;
+
return retval;
}
@@ -386,10 +387,10 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
f = fopen(new_state.cwd, mode);
+
CWD_STATE_FREE(&new_state);
return f;
}
@@ -401,7 +402,6 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
if (flags & O_CREAT) {
@@ -427,7 +427,6 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
f = open(new_state.cwd, O_CREAT | O_TRUNC, mode);
@@ -444,10 +443,10 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
retval = stat(new_state.cwd, buf);
+
CWD_STATE_FREE(&new_state);
return retval;
}
@@ -461,10 +460,10 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
retval = lstat(new_state.cwd, buf);
+
CWD_STATE_FREE(&new_state);
return retval;
}
@@ -478,10 +477,40 @@
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
-
virtual_file_ex(&new_state, path, NULL);
retval = unlink(new_state.cwd);
+
+ CWD_STATE_FREE(&new_state);
+ return retval;
+}
+
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode)
+{
+ cwd_state new_state;
+ int retval;
+ CWDLS_FETCH();
+
+ CWD_STATE_COPY(&new_state, &CWDG(cwd));
+ virtual_file_ex(&new_state, pathname, NULL);
+
+ retval = mkdir(new_state.cwd, mode);
+
+ CWD_STATE_FREE(&new_state);
+ return retval;
+}
+
+CWD_API int virtual_rmdir(const char *pathname)
+{
+ cwd_state new_state;
+ int retval;
+ CWDLS_FETCH();
+
+ CWD_STATE_COPY(&new_state, &CWDG(cwd));
+ virtual_file_ex(&new_state, pathname, NULL);
+
+ retval = rmdir(new_state.cwd);
+
CWD_STATE_FREE(&new_state);
return retval;
}
Index: php4/php_virtual_cwd.h
diff -u php4/php_virtual_cwd.h:1.22 php4/php_virtual_cwd.h:1.23
--- php4/php_virtual_cwd.h:1.22 Tue May 23 16:36:26 2000
+++ php4/php_virtual_cwd.h Tue May 23 19:02:21 2000
@@ -49,6 +49,8 @@
CWD_API int virtual_lstat(const char *path, struct stat *buf);
#endif
CWD_API int virtual_unlink(const char *path);
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode);
+CWD_API int virtual_rmdir(const char *pathname);
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
Index: php4/dl/log/log_db.c
diff -u php4/dl/log/log_db.c:1.5 php4/dl/log/log_db.c:1.6
--- php4/dl/log/log_db.c:1.5 Thu Apr 20 19:23:59 2000
+++ php4/dl/log/log_db.c Tue May 23 19:02:21 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: log_db.c,v 1.5 2000/04/20 17:23:59 zeev Exp $ */
+/* $Id: log_db.c,v 1.6 2000/05/23 17:02:21 andi Exp $ */
#include "phpdl.h"
#include "log.h"
@@ -77,7 +77,7 @@
/* SAFE_MODE concern: should make sure that the user is
logging somewhere safe */
if (V_STAT(log_conf.dbm_log_dir, &sb) == -1) {
- if (mkdir(log_conf.dbm_log_dir, 0755)==-1) {
+ if (V_MKDIR(log_conf.dbm_log_dir, 0755)==-1) {
php_error(E_WARNING, "Trying to create main log directory [%s]: %d [%s]",log_conf.dbm_log_dir,errno,strerror(errno));
return;
}
@@ -86,7 +86,7 @@
/* see if the log directory exists for this page-owner's uid */
sprintf(path, "%s/%ld", log_conf.dbm_log_dir, php_getuid());
if (V_STAT(path, &sb) == -1) {
- if (mkdir(path, 0755)==-1) {
+ if (V_MKDIR(path, 0755)==-1) {
php_error(E_WARNING, "Trying to create user log directory [%s]: %d [%s]",path,errno,strerror(errno));
return;
}
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.79 php4/ext/standard/file.c:1.80
--- php4/ext/standard/file.c:1.79 Tue May 23 16:36:27 2000
+++ php4/ext/standard/file.c Tue May 23 19:02:21 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.79 2000/05/23 14:36:27 andi Exp $ */
+/* $Id: file.c,v 1.80 2000/05/23 17:02:21 andi Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -1232,7 +1232,7 @@
if (PG(safe_mode) &&(!php_checkuid((*arg1)->value.str.val,3))) {
RETURN_FALSE;
}
- ret = mkdir((*arg1)->value.str.val,mode);
+ ret = V_MKDIR((*arg1)->value.str.val,mode);
if (ret < 0) {
php_error(E_WARNING,"MkDir failed (%s)", strerror(errno));
RETURN_FALSE;