diff options
author | Xinchen Hui <laruence@php.net> | 2011-12-07 10:33:13 +0000 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2011-12-07 10:33:13 +0000 |
commit | 5aa1fb6074efec67f7b27e720cc5853d3e505433 (patch) | |
tree | 09b25e0ec59687b30c907a6e252d14a735beada5 /main/php_ini.c | |
parent | 321172e479872b5aec998d2a39290e3055ca997a (diff) | |
download | php-git-5aa1fb6074efec67f7b27e720cc5853d3e505433.tar.gz |
Implemented FR #54514 (Get php binary path during script execution).
Diffstat (limited to 'main/php_ini.c')
-rw-r--r-- | main/php_ini.c | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/main/php_ini.c b/main/php_ini.c index 1ffc08b187..dd7435bb32 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -393,7 +393,6 @@ int php_init_config(TSRMLS_D) int search_path_size; char *default_location; char *env_location; - char *binary_location; static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 }; #ifdef PHP_WIN32 char *reg_location; @@ -472,51 +471,11 @@ int php_init_config(TSRMLS_D) strlcat(php_ini_search_path, ".", search_path_size); } - /* Add binary directory */ -#ifdef PHP_WIN32 - binary_location = (char *) emalloc(MAXPATHLEN); - if (GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) { - efree(binary_location); - binary_location = NULL; - } -#else - if (sapi_module.executable_location) { - binary_location = (char *)emalloc(MAXPATHLEN); - if (!strchr(sapi_module.executable_location, '/')) { - char *envpath, *path; - int found = 0; - - if ((envpath = getenv("PATH")) != NULL) { - char *search_dir, search_path[MAXPATHLEN]; - char *last = NULL; - - path = estrdup(envpath); - search_dir = php_strtok_r(path, ":", &last); - - while (search_dir) { - snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location); - if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) { - found = 1; - break; - } - search_dir = php_strtok_r(NULL, ":", &last); - } - efree(path); - } - if (!found) { - efree(binary_location); - binary_location = NULL; - } - } else if (!VCWD_REALPATH(sapi_module.executable_location, binary_location) || VCWD_ACCESS(binary_location, X_OK)) { - efree(binary_location); - binary_location = NULL; - } - } else { - binary_location = NULL; - } -#endif - if (binary_location) { - char *separator_location = strrchr(binary_location, DEFAULT_SLASH); + if (PG(php_binary)) { + char *separator_location, *binary_location; + + binary_location = estrdup(PG(php_binary)); + separator_location = strrchr(binary_location, DEFAULT_SLASH); if (separator_location && separator_location != binary_location) { *(separator_location) = 0; |