free((s)->cwd);
#ifdef TSRM_WIN32
-CWD_API int php_sys_stat(const char *path, struct stat *buf)
+CWD_API int php_sys_stat(const char *path, struct stat *buf) /* {{{ */
{
WIN32_FILE_ATTRIBUTE_DATA data;
__int64 t;
buf->st_mtime = (unsigned long)((t / 10000000) - 11644473600);
return 0;
}
+/* }}} */
#endif
-static int php_is_dir_ok(const cwd_state *state)
+static int php_is_dir_ok(const cwd_state *state) /* {{{ */
{
struct stat buf;
return (1);
}
+/* }}} */
-static int php_is_file_ok(const cwd_state *state)
+static int php_is_file_ok(const cwd_state *state) /* {{{ */
{
struct stat buf;
return (1);
}
+/* }}} */
-static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals TSRMLS_DC)
+static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */
{
CWD_STATE_COPY(&cwd_globals->cwd, &main_cwd_state);
cwd_globals->realpath_cache_size = 0;
cwd_globals->realpath_cache_ttl = REALPATH_CACHE_TTL;
memset(cwd_globals->realpath_cache, 0, sizeof(cwd_globals->realpath_cache));
}
+/* }}} */
-static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals TSRMLS_DC)
+static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */
{
CWD_STATE_FREE(&cwd_globals->cwd);
realpath_cache_clean(TSRMLS_C);
}
+/* }}} */
-static char *tsrm_strndup(const char *s, size_t length)
+static char *tsrm_strndup(const char *s, size_t length) /* {{{ */
{
char *p;
p[length]=0;
return p;
}
+/* }}} */
-CWD_API void virtual_cwd_startup(void)
+CWD_API void virtual_cwd_startup(void) /* {{{ */
{
char cwd[MAXPATHLEN];
char *result;
cwd_mutex = tsrm_mutex_alloc();
#endif
}
+/* }}} */
-CWD_API void virtual_cwd_shutdown(void)
+CWD_API void virtual_cwd_shutdown(void) /* {{{ */
{
#ifndef ZTS
cwd_globals_dtor(&cwd_globals TSRMLS_CC);
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 TSRMLS_DC)
+CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC) /* {{{ */
{
cwd_state *state;
*length = state->cwd_length;
return strdup(state->cwd);
}
-
+/* }}} */
/* Same semantics as UNIX getcwd() */
-CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC)
+CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */
{
size_t length;
char *cwd;
free(cwd);
return buf;
}
+/* }}} */
-static inline unsigned long realpath_cache_key(const char *path, int path_len)
+static inline unsigned long realpath_cache_key(const char *path, int path_len) /* {{{ */
{
register unsigned long h;
const char *e = path + path_len;
return h;
}
+/* }}} */
-CWD_API void realpath_cache_clean(TSRMLS_D)
+CWD_API void realpath_cache_clean(TSRMLS_D) /* {{{ */
{
int i;
}
CWDG(realpath_cache_size) = 0;
}
+/* }}} */
-CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC)
+CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ */
{
unsigned long key = realpath_cache_key(path, path_len);
unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
}
}
}
+/* }}} */
-static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, time_t t TSRMLS_DC)
+static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, time_t t TSRMLS_DC) /* {{{ */
{
long size = sizeof(realpath_cache_bucket) + path_len + 1 + realpath_len + 1;
if (CWDG(realpath_cache_size) + size <= CWDG(realpath_cache_size_limit)) {
CWDG(realpath_cache_size) += size;
}
}
+/* }}} */
-static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC)
+static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */
{
unsigned long key = realpath_cache_key(path, path_len);
unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
}
return NULL;
}
-
+/* }}} */
/* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */
-CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)
+CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
{
int path_length = strlen(path);
cwd_state old_state;
#endif
return (ret);
}
+/* }}} */
-CWD_API int virtual_chdir(const char *path TSRMLS_DC)
+CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */
{
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0;
}
+/* }}} */
-CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC)
+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;
tsrm_free_alloca(temp);
return retval;
}
+/* }}} */
-CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC)
+CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
char *retval;
return retval;
}
+/* }}} */
-CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC)
+CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
return retval;
}
+/* }}} */
-CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC)
+CWD_API int virtual_filepath(const char *path, char **filepath TSRMLS_DC) /* {{{ */
{
return virtual_filepath_ex(path, filepath, php_is_file_ok TSRMLS_CC);
}
+/* }}} */
-CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC)
+CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
FILE *f;
CWD_STATE_FREE(&new_state);
return f;
}
+/* }}} */
-CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC)
+CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int ret;
return ret;
}
-
+/* }}} */
#if HAVE_UTIME
-CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC)
+CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int ret;
CWD_STATE_FREE(&new_state);
return ret;
}
+/* }}} */
#endif
-CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC)
+CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int ret;
CWD_STATE_FREE(&new_state);
return ret;
}
+/* }}} */
#if !defined(TSRM_WIN32) && !defined(NETWARE)
-CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC)
+CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int ret;
CWD_STATE_FREE(&new_state);
return ret;
}
+/* }}} */
#endif
-CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...)
+CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */
{
cwd_state new_state;
int f;
CWD_STATE_FREE(&new_state);
return f;
}
+/* }}} */
-CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC)
+CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int f;
CWD_STATE_FREE(&new_state);
return f;
}
+/* }}} */
-CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
+CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC) /* {{{ */
{
cwd_state old_state;
cwd_state new_state;
return retval;
}
+/* }}} */
-CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
+CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
#if !defined(TSRM_WIN32)
-CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)
+CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
#endif
-CWD_API int virtual_unlink(const char *path TSRMLS_DC)
+CWD_API int virtual_unlink(const char *path TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
-CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC)
+CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
-CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC)
+CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
#ifdef TSRM_WIN32
DIR *opendir(const char *name);
#endif
-CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC)
+CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
DIR *retval;
CWD_STATE_FREE(&new_state);
return retval;
}
+/* }}} */
#ifdef TSRM_WIN32
-
-CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
{
return popen_ex(command, type, CWDG(cwd).cwd, NULL);
}
-
+/* }}} */
#elif defined(NETWARE)
-
/* On NetWare, the trick of prepending "cd cwd; " doesn't work so we need to perform
a VCWD_CHDIR() and mutex it
*/
-CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
{
char prev_cwd[MAXPATHLEN];
char *getcwd_result;
return retval;
}
-
+/* }}} */
#else /* Unix */
-
-CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC)
+CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
{
int command_length;
int dir_length, extra = 0;
free(command_line);
return retval;
}
-
+/* }}} */
#endif
-CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC)
+CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
char cwd[MAXPATHLEN];
return new_state.cwd;
}
}
-
+/* }}} */
/*
* Local variables: