summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2001-08-05 01:34:40 +0000
committerZeev Suraski <zeev@php.net>2001-08-05 01:34:40 +0000
commit1f3faae3523071c45fbe074c51804a43c05aa55b (patch)
treef8b1e9530eadcd79d0533ecabbd7a6841bcca203 /TSRM
parent2361160cc5264bcb2ff5a71c06d1e6744916b0cf (diff)
downloadphp-git-1f3faae3523071c45fbe074c51804a43c05aa55b.tar.gz
Nukre most TSRMLS_FETCH()'s in TSRM
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_virtual_cwd.c70
-rw-r--r--TSRM/tsrm_virtual_cwd.h105
-rw-r--r--TSRM/tsrm_win32.c12
3 files changed, 88 insertions, 99 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 39c825ff75..3db3c4cf9d 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -198,10 +198,9 @@ CWD_API void virtual_cwd_shutdown(void)
free(main_cwd_state.cwd); /* Don't use CWD_STATE_FREE because the non global states will probably use emalloc()/efree() */
}
-CWD_API char *virtual_getcwd_ex(size_t *length)
+CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC)
{
cwd_state *state;
- TSRMLS_FETCH();
state = &CWDG(cwd);
@@ -234,12 +233,12 @@ CWD_API char *virtual_getcwd_ex(size_t *length)
/* Same semantics as UNIX getcwd() */
-CWD_API char *virtual_getcwd(char *buf, size_t size)
+CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
{
size_t length;
char *cwd;
- cwd = virtual_getcwd_ex(&length);
+ cwd = virtual_getcwd_ex(&length TSRMLS_CC);
if (buf == NULL) {
return cwd;
@@ -403,14 +402,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
return (ret);
}
-CWD_API int virtual_chdir(const char *path)
+CWD_API int virtual_chdir(const char *path TSRMLS_DC)
{
- TSRMLS_FETCH();
-
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0;
}
-CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path))
+CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC)
{
int length = strlen(path);
char *temp;
@@ -437,16 +434,15 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
#if VIRTUAL_CWD_DEBUG
fprintf (stderr, "Changing directory to %s\n", temp);
#endif
- retval = p_chdir(temp);
+ retval = p_chdir(temp TSRMLS_CC);
tsrm_free_alloca(temp);
return retval;
}
-CWD_API char *virtual_realpath(const char *path, char *real_path)
+CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, NULL);
@@ -461,11 +457,10 @@ CWD_API char *virtual_realpath(const char *path, char *real_path)
return NULL;
}
-CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path)
+CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, verify_path);
@@ -476,16 +471,15 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
}
-CWD_API int virtual_filepath(const char *path, char **filepath)
+CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC)
{
- return virtual_filepath_ex(path, filepath, php_is_file_ok);
+ return virtual_filepath_ex(path, filepath, php_is_file_ok TSRMLS_CC);
}
-CWD_API FILE *virtual_fopen(const char *path, const char *mode)
+CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
{
cwd_state new_state;
FILE *f;
- TSRMLS_FETCH();
if (path[0] == '\0') { /* Fail to open empty path */
return NULL;
@@ -501,11 +495,10 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode)
}
#if HAVE_UTIME
-CWD_API int virtual_utime(const char *filename, struct utimbuf *buf)
+CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
{
cwd_state new_state;
int ret;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, filename, NULL);
@@ -517,11 +510,10 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf)
}
#endif
-CWD_API int virtual_chmod(const char *filename, mode_t mode)
+CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
{
cwd_state new_state;
int ret;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, filename, NULL);
@@ -533,11 +525,10 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode)
}
#ifndef TSRM_WIN32
-CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group)
+CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC)
{
cwd_state new_state;
int ret;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, filename, NULL);
@@ -549,11 +540,10 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group)
}
#endif
-CWD_API int virtual_open(const char *path, int flags, ...)
+CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...)
{
cwd_state new_state;
int f;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
@@ -574,11 +564,10 @@ CWD_API int virtual_open(const char *path, int flags, ...)
return f;
}
-CWD_API int virtual_creat(const char *path, mode_t mode)
+CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC)
{
cwd_state new_state;
int f;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
@@ -589,12 +578,11 @@ CWD_API int virtual_creat(const char *path, mode_t mode)
return f;
}
-CWD_API int virtual_rename(char *oldname, char *newname)
+CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
{
cwd_state old_state;
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&old_state, &CWDG(cwd));
virtual_file_ex(&old_state, oldname, NULL);
@@ -612,11 +600,10 @@ CWD_API int virtual_rename(char *oldname, char *newname)
return retval;
}
-CWD_API int virtual_stat(const char *path, struct stat *buf)
+CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
@@ -629,11 +616,10 @@ CWD_API int virtual_stat(const char *path, struct stat *buf)
#ifndef TSRM_WIN32
-CWD_API int virtual_lstat(const char *path, struct stat *buf)
+CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
@@ -646,11 +632,10 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf)
#endif
-CWD_API int virtual_unlink(const char *path)
+CWD_API int virtual_unlink(const char *path TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
@@ -661,11 +646,10 @@ CWD_API int virtual_unlink(const char *path)
return retval;
}
-CWD_API int virtual_mkdir(const char *pathname, mode_t mode)
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, pathname, NULL);
@@ -679,11 +663,10 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode)
return retval;
}
-CWD_API int virtual_rmdir(const char *pathname)
+CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC)
{
cwd_state new_state;
int retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, pathname, NULL);
@@ -698,11 +681,10 @@ CWD_API int virtual_rmdir(const char *pathname)
DIR *opendir(const char *name);
#endif
-CWD_API DIR *virtual_opendir(const char *pathname)
+CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
{
cwd_state new_state;
DIR *retval;
- TSRMLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, pathname, NULL);
@@ -715,13 +697,12 @@ CWD_API DIR *virtual_opendir(const char *pathname)
#ifndef TSRM_WIN32
-CWD_API FILE *virtual_popen(const char *command, const char *type)
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
{
int command_length;
char *command_line;
char *ptr;
FILE *retval;
- TSRMLS_FETCH();
command_length = strlen(command);
@@ -755,12 +736,11 @@ CWD_API FILE *virtual_popen(const char *command, const char *type)
/* On Windows the trick of prepending "cd cwd; " doesn't work so we need to perform
a real chdir() and mutex it
*/
-CWD_API FILE *virtual_popen(const char *command, const char *type)
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
{
char prev_cwd[MAXPATHLEN];
char *getcwd_result;
FILE *retval;
- TSRMLS_FETCH();
getcwd_result = getcwd(prev_cwd, MAXPATHLEN);
if (!getcwd_result) {
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index d1b27eb513..dbc1038ee7 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -22,6 +22,7 @@
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
+#include "TSRM.h"
#include "tsrm_config_common.h"
#include <sys/types.h>
@@ -99,32 +100,32 @@ typedef int (*verify_path_func)(const cwd_state *);
CWD_API void virtual_cwd_startup(void);
CWD_API void virtual_cwd_shutdown(void);
-CWD_API char *virtual_getcwd_ex(size_t *length);
-CWD_API char *virtual_getcwd(char *buf, size_t size);
-CWD_API int virtual_chdir(const char *path);
-CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path));
-CWD_API int virtual_filepath(const char *path, char **filepath);
-CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path);
-CWD_API char *virtual_realpath(const char *path, char *real_path);
-CWD_API FILE *virtual_fopen(const char *path, const char *mode);
-CWD_API int virtual_open(const char *path, int flags, ...);
-CWD_API int virtual_creat(const char *path, mode_t mode);
-CWD_API int virtual_rename(char *oldname, char *newname);
-CWD_API int virtual_stat(const char *path, struct stat *buf);
+CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC);
+CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC);
+CWD_API int virtual_chdir(const char *path TSRMLS_DC);
+CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC);
+CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC);
+CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC);
+CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC);
+CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
+CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
+CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
+CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
+CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
#ifndef TSRM_WIN32
-CWD_API int virtual_lstat(const char *path, struct stat *buf);
+CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
#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 DIR *virtual_opendir(const char *pathname);
-CWD_API FILE *virtual_popen(const char *command, const char *type);
+CWD_API int virtual_unlink(const char *path TSRMLS_DC);
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
+CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
+CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC);
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC);
#if HAVE_UTIME
-CWD_API int virtual_utime(const char *filename, struct utimbuf *buf);
+CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
#endif
-CWD_API int virtual_chmod(const char *filename, mode_t mode);
+CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
#ifndef TSRM_WIN32
-CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group);
+CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC);
#endif
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
@@ -146,42 +147,44 @@ typedef struct _virtual_cwd_globals {
#ifdef VIRTUAL_DIR
-#define VCWD_GETCWD(buff, size) virtual_getcwd(buff,size)
-#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode)
-/* The VCWD_OPEN macro will need to be used as VCWD_OPEN((path, flags, ...)) */
-#define VCWD_OPEN(open_args) virtual_open open_args
-#define VCWD_CREAT(path, mode) virtual_creat(path, mode)
-#define VCWD_CHDIR(path) virtual_chdir(path)
-#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir)
+#define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size TSRMLS_CC)
+#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode TSRMLS_CC)
+/* Because open() has two modes, we have to macros to replace it */
+#define VCWD_OPEN(path, flags) virtual_open(path TSRMLS_CC, flags)
+#define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path TSRMLS_CC, flags, mode)
+#define VCWD_CREAT(path, mode) virtual_creat(path, mode TSRMLS_CC)
+#define VCWD_CHDIR(path) virtual_chdir(path TSRMLS_CC)
+#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir TSRMLS_CC)
#define VCWD_GETWD(buf)
-#define VCWD_REALPATH(path,real_path) virtual_realpath(path,real_path)
-#define VCWD_RENAME(oldname,newname) virtual_rename(oldname,newname)
-#define VCWD_STAT(path, buff) virtual_stat(path, buff)
+#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
+#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
+#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
#ifdef TSRM_WIN32
-#define VCWD_LSTAT(path, buff) virtual_stat(path, buff)
+#define VCWD_LSTAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
#else
-#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff)
+#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
#endif
-#define VCWD_UNLINK(path) virtual_unlink(path)
-#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
-#define VCWD_RMDIR(pathname) virtual_rmdir(pathname)
-#define VCWD_OPENDIR(pathname) virtual_opendir(pathname)
-#define VCWD_POPEN(command, type) virtual_popen(command, type)
+#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
+#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC)
+#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
+#define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC)
+#define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC)
#if HAVE_UTIME
-#define VCWD_UTIME(path,time) virtual_utime(path,time)
+#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
#endif
-#define VCWD_CHMOD(path,mode) virtual_chmod(path,mode)
+#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC)
#ifndef TSRM_WIN32
-#define VCWD_CHOWN(path,owner,group) virtual_chown(path,owner,group)
+#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group TSRMLS_CC)
#endif
#else
-#define VCWD_GETCWD(buff, size) getcwd(buff,size)
+#define VCWD_GETCWD(buff, size) getcwd(buff, size)
#define VCWD_FOPEN(path, mode) fopen(path, mode)
-#define VCWD_OPEN(open_args) open open_args
+#define VCWD_OPEN(path, flags) open(path, flags)
+#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
#define VCWD_CREAT(path, mode) creat(path, mode)
-#define VCWD_RENAME(oldname,newname) rename(oldname,newname)
+#define VCWD_RENAME(oldname, newname) rename(oldname, newname)
#define VCWD_CHDIR(path) chdir(path)
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
#define VCWD_GETWD(buf) getwd(buf)
@@ -192,13 +195,19 @@ typedef struct _virtual_cwd_globals {
#define VCWD_RMDIR(pathname) rmdir(pathname)
#define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type)
-#define VCWD_REALPATH(path,real_path) realpath(path,real_path)
+
+#ifndef TSRM_WIN32
+#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
+#else
+#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
+#endif
+
#if HAVE_UTIME
-#define VCWD_UTIME(path,time) utime(path,time)
+#define VCWD_UTIME(path, time) utime(path, time)
#endif
-#define VCWD_CHMOD(path,mode) chmod(path,mode)
+#define VCWD_CHMOD(path, mode) chmod(path, mode)
#ifndef TSRM_WIN32
-#define VCWD_CHOWN(path,owner,group) chown(path,owner,group)
+#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
#endif
#endif
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index f8d2b7d741..5dfc2d60f8 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -67,11 +67,10 @@ TSRM_API void tsrm_win32_shutdown(void)
#endif
}
-static ProcessPair* process_get(FILE *stream)
+static ProcessPair* process_get(FILE *stream TSRMLS_DC)
{
ProcessPair* ptr;
ProcessPair* newptr;
- TSRMLS_FETCH();
for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
if (ptr->stream == stream) {
@@ -102,7 +101,7 @@ static HANDLE dupHandle(HANDLE fh, BOOL inherit) {
return copy;
}
-TSRM_API FILE* popen(const char *command, const char *type)
+TSRM_API FILE *popen(const char *command, const char *type)
{
FILE *stream = NULL;
int fno, str_len = strlen(type), read, mode;
@@ -151,7 +150,7 @@ TSRM_API FILE* popen(const char *command, const char *type)
free(cmd);
CloseHandle(process.hThread);
- proc = process_get(NULL);
+ proc = process_get(NULL TSRMLS_CC);
if (read) {
fno = _open_osfhandle((long)in, _O_RDONLY | mode);
@@ -167,12 +166,13 @@ TSRM_API FILE* popen(const char *command, const char *type)
return stream;
}
-TSRM_API int pclose(FILE* stream)
+TSRM_API int pclose(FILE *stream)
{
DWORD termstat = 0;
ProcessPair* process;
+ TSRMLS_FETCH();
- if ((process = process_get(stream)) == NULL) {
+ if ((process = process_get(stream TSRMLS_CC)) == NULL) {
return 0;
}