summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2010-09-13 09:08:42 +0000
committerPierre Joye <pajoye@php.net>2010-09-13 09:08:42 +0000
commit3a2f5c221985c5a9a0141dd0c5085379c573b612 (patch)
treeb7d2d8627f27e7ea1f4fd2e250168f7c5fec7c10 /TSRM
parenta7da07a15f057f7109ba3f4adc1a3455b88c1d2f (diff)
downloadphp-git-3a2f5c221985c5a9a0141dd0c5085379c573b612.tar.gz
- WS
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_virtual_cwd.c86
-rw-r--r--TSRM/tsrm_virtual_cwd.h8
2 files changed, 47 insertions, 47 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 49ca126770..0c062c40e3 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -88,14 +88,14 @@ cwd_state main_cwd_state; /* True global */
#include <tchar.h>
#define tsrm_strtok_r(a,b,c) _tcstok((a),(b))
#define TOKENIZER_STRING "/\\"
-
-static int php_check_dots(const char *element, int n)
+
+static int php_check_dots(const char *element, int n)
{
while (n-- > 0) if (element[n] != '.') break;
return (n != -1);
}
-
+
#define IS_DIRECTORY_UP(element, len) \
(len >= 2 && !php_check_dots(element, len))
@@ -129,7 +129,7 @@ static int php_check_dots(const char *element, int n)
/* define this to check semantics */
#define IS_DIR_OK(s) (1)
-
+
#ifndef IS_DIR_OK
#define IS_DIR_OK(state) (php_is_dir_ok(state) == 0)
#endif
@@ -142,7 +142,7 @@ static int php_check_dots(const char *element, int n)
#define CWD_STATE_FREE(s) \
free((s)->cwd);
-
+
#ifdef TSRM_WIN32
#ifdef CTL_CODE
@@ -436,7 +436,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */
}
}
#else
- result = getcwd(cwd, sizeof(cwd));
+ result = getcwd(cwd, sizeof(cwd));
#endif
if (!result) {
cwd[0] = '\0';
@@ -487,7 +487,7 @@ CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC) /* {{{ */
*length = 1;
retval = (char *) malloc(2);
retval[0] = DEFAULT_SLASH;
- retval[1] = '\0';
+ retval[1] = '\0';
return retval;
}
@@ -614,7 +614,7 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
{
long size = sizeof(realpath_cache_bucket) + path_len + 1;
int same = 1;
-
+
if (realpath_len != path_len ||
memcmp(path, realpath, path_len) != 0) {
size += realpath_len + 1;
@@ -690,17 +690,17 @@ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_
}
/* }}} */
-CWD_API int realpath_cache_size(TSRMLS_D)
+CWD_API int realpath_cache_size(TSRMLS_D)
{
return CWDG(realpath_cache_size);
}
-CWD_API int realpath_cache_max_buckets(TSRMLS_D)
+CWD_API int realpath_cache_max_buckets(TSRMLS_D)
{
return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
}
-CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D)
+CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D)
{
return CWDG(realpath_cache);
}
@@ -759,7 +759,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
path[4] = '.';
path[5] = DEFAULT_SLASH;
j = 5;
- } else if (j > 0 &&
+ } else if (j > 0 &&
path[j+1] == '.' && path[j+2] == '.' &&
IS_SLASH(path[j+3])) {
j += 4;
@@ -777,7 +777,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
}
return j;
}
-
+
path[len] = 0;
save = (use_realpath != CWD_EXPAND);
@@ -810,7 +810,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
/* continue resolution anyway but don't save result in the cache */
save = 0;
}
-
+
if (save) {
FindClose(hFind);
}
@@ -855,7 +855,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
- if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
+ if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR),
printname_len + 1,
printname, MAX_PATH, NULL, NULL
@@ -867,7 +867,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
printname[printname_len] = 0;
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
- if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
+ if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
substitutename_len + 1,
substitutename, MAX_PATH, NULL, NULL
@@ -881,7 +881,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
isabsolute = 1;
reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
- if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
+ if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR),
printname_len + 1,
printname, MAX_PATH, NULL, NULL
@@ -892,7 +892,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
printname[pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)] = 0;
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
- if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
+ if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
substitutename_len + 1,
substitutename, MAX_PATH, NULL, NULL
@@ -907,14 +907,14 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
}
if(isabsolute && substitutename_len > 4) {
- /* Do not resolve volumes (for now). A mounted point can
+ /* Do not resolve volumes (for now). A mounted point can
target a volume without a drive, it is not certain that
- all IO functions we use in php and its deps support
+ all IO functions we use in php and its deps support
path with volume GUID instead of the DOS way, like:
d:\test\mnt\foo
\\?\Volume{62d1c3f8-83b9-11de-b108-806e6f6e6963}\foo
*/
- if (strncmp(substitutename, "\\??\\Volume{",11) == 0
+ if (strncmp(substitutename, "\\??\\Volume{",11) == 0
|| strncmp(substitutename, "\\\\?\\Volume{",11) == 0
|| strncmp(substitutename, "\\??\\UNC\\", 8) == 0
) {
@@ -922,7 +922,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
substitutename_off = 0;
} else
/* do not use the \??\ and \\?\ prefix*/
- if (strncmp(substitutename, "\\??\\", 4) == 0
+ if (strncmp(substitutename, "\\??\\", 4) == 0
|| strncmp(substitutename, "\\\\?\\", 4) == 0) {
substitutename_off = 4;
}
@@ -1006,7 +1006,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
memcpy(tmp, path, len+1);
if (save && S_ISLNK(st.st_mode)) {
- if (++(*ll) > LINK_MAX || (j = readlink(tmp, path, MAXPATHLEN)) < 0) {
+ if (++(*ll) > LINK_MAX || (j = php_sys_readlink(tmp, path, MAXPATHLEN)) < 0) {
/* too many links or broken symlinks */
tsrm_free_alloca(tmp, use_heap);
return -1;
@@ -1144,18 +1144,18 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
state_cwd_length = 2;
while (IS_SLASH(state->cwd[state_cwd_length])) {
state_cwd_length++;
- }
+ }
while (state->cwd[state_cwd_length] &&
!IS_SLASH(state->cwd[state_cwd_length])) {
state_cwd_length++;
- }
+ }
while (IS_SLASH(state->cwd[state_cwd_length])) {
state_cwd_length++;
- }
+ }
while (state->cwd[state_cwd_length] &&
!IS_SLASH(state->cwd[state_cwd_length])) {
state_cwd_length++;
- }
+ }
}
}
#endif
@@ -1167,7 +1167,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
path_length += state_cwd_length + 1;
}
- } else {
+ } else {
#ifdef TSRM_WIN32
if (path_length > 2 && path[1] == ':' && !IS_SLASH(path[2])) {
resolved_path[0] = path[0];
@@ -1178,7 +1178,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
} else
#endif
memcpy(resolved_path, path, path_length + 1);
- }
+ }
#ifdef TSRM_WIN32
if (memchr(resolved_path, '*', path_length) ||
@@ -1232,12 +1232,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]);
t = CWDG(realpath_cache_ttl) ? 0 : -1;
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL TSRMLS_CC);
-
+
if (path_length < 0) {
errno = ENOENT;
return 1;
}
-
+
if (!start && !path_length) {
resolved_path[path_length++] = '.';
}
@@ -1290,7 +1290,7 @@ verify:
memcpy(state->cwd, resolved_path, state->cwd_length+1);
ret = 0;
}
-
+
#if VIRTUAL_CWD_DEBUG
fprintf (stderr, "virtual_file_ex() = %s\n",state->cwd);
#endif
@@ -1348,7 +1348,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
if (!*path) {
new_state.cwd = (char*)malloc(1);
new_state.cwd[0] = '\0';
- new_state.cwd_length = 0;
+ new_state.cwd_length = 0;
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
path = cwd;
}
@@ -1357,7 +1357,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
} else {
new_state.cwd = (char*)malloc(1);
new_state.cwd[0] = '\0';
- new_state.cwd_length = 0;
+ new_state.cwd_length = 0;
}
if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)==0) {
@@ -1423,7 +1423,7 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int ret;
-
+
CWD_STATE_COPY(&new_state, &CWDG(cwd));
if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
CWD_STATE_FREE(&new_state);
@@ -1435,9 +1435,9 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
#else
ret = access(new_state.cwd, mode);
#endif
-
+
CWD_STATE_FREE(&new_state);
-
+
return ret;
}
/* }}} */
@@ -1458,12 +1458,12 @@ static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
{
FILETIME mtime, atime;
- HANDLE hFile;
+ HANDLE hFile;
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
+ /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
the CreateFile operation succeeds */
if (GetLastError() == ERROR_ALREADY_EXISTS) {
SetLastError(0);
@@ -1583,7 +1583,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */
f = open(new_state.cwd, flags, mode);
} else {
f = open(new_state.cwd, flags);
- }
+ }
CWD_STATE_FREE(&new_state);
return f;
}
@@ -1842,7 +1842,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
}
*ptr++ = '\'';
}
-
+
*ptr++ = ' ';
*ptr++ = ';';
*ptr++ = ' ';
@@ -1865,7 +1865,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
if (!*path) {
new_state.cwd = (char*)malloc(1);
new_state.cwd[0] = '\0';
- new_state.cwd_length = 0;
+ new_state.cwd_length = 0;
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
path = cwd;
}
@@ -1876,7 +1876,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
} else {
new_state.cwd = (char*)malloc(1);
new_state.cwd[0] = '\0';
- new_state.cwd_length = 0;
+ new_state.cwd_length = 0;
}
if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index f80e5c7e6b..2949f27159 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -108,7 +108,7 @@ typedef unsigned short mode_t;
#define COPY_WHEN_ABSOLUTE(path) 0
#endif
-#ifndef IS_ABSOLUTE_PATH
+#ifndef IS_ABSOLUTE_PATH
#define IS_ABSOLUTE_PATH(path, len) \
(IS_SLASH(path[0]))
#endif
@@ -194,7 +194,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC);
#endif
-/* One of the following constants must be used as the last argument
+/* One of the following constants must be used as the last argument
in virtual_file_ex() call. */
#define CWD_EXPAND 0 /* expand "." and ".." but dont resolve symlinks */
@@ -222,7 +222,7 @@ typedef struct _realpath_cache_bucket {
unsigned char is_wvalid;
unsigned char is_writable;
#endif
- struct _realpath_cache_bucket *next;
+ struct _realpath_cache_bucket *next;
} realpath_cache_bucket;
typedef struct _virtual_cwd_globals {
@@ -250,7 +250,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
/* The actual macros to be used in programs using TSRM
* If the program defines VIRTUAL_DIR it will use the
- * virtual_* functions
+ * virtual_* functions
*/
#ifdef VIRTUAL_DIR