From: foobar Date: Wed, 19 Feb 2003 09:25:16 +0000 (+0000) Subject: Fix the possible conflicts with other libs (like libc-client) X-Git-Tag: RELEASE_0_5~881 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec11fe04e9f0c1d34051efdac8d8ce106878f319;p=php Fix the possible conflicts with other libs (like libc-client) --- diff --git a/main/php_ini.c b/main/php_ini.c index 6e599ebcaf..1288774c93 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -30,11 +30,10 @@ #include "zend_highlight.h" #include "SAPI.h" #include "php_main.h" +#include "php_scandir.h" -#if !HAVE_SCANDIR || !HAVE_ALPHASORT - #include "php_scandir.h" -#else - #include +#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H +#include #endif #ifndef S_ISREG @@ -432,7 +431,7 @@ int php_init_config() struct dirent **namelist; int ndir, i; - if ((ndir = scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, alphasort)) > 0) { + if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) { for (i = 0; i < ndir; i++) { /* check for a .ini extension */ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { diff --git a/main/php_scandir.c b/main/php_scandir.c index 148c8828a3..15d4febf4a 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -17,6 +17,8 @@ +----------------------------------------------------------------------+ */ +/* $Id$ */ + #ifdef PHP_WIN32 #include "config.w32.h" #else @@ -26,7 +28,10 @@ #include "php_scandir.h" #ifndef HAVE_SCANDIR + +#ifdef HAVE_SYS_TYPES_H #include +#endif #ifdef HAVE_DIRENT_H #include @@ -38,19 +43,23 @@ #include #include -#endif + +#endif /* HAVE_SCANDIR */ #ifndef HAVE_ALPHASORT + +#ifdef HAVE_STRING_H #include +#endif -int alphasort(const struct dirent **a, const struct dirent **b) +int php_alphasort(const struct dirent **a, const struct dirent **b) { return strcoll((*a)->d_name,(*b)->d_name); } -#endif +#endif /* HAVE_ALPHASORT */ #ifndef HAVE_SCANDIR -int scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)) +int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)) { DIR *dirp = NULL; struct dirent **vector = NULL; @@ -117,3 +126,12 @@ fail: return -1; } #endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/main/php_scandir.h b/main/php_scandir.h index fc3b191dfb..4a8b57ed3f 100644 --- a/main/php_scandir.h +++ b/main/php_scandir.h @@ -1,3 +1,27 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2003 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Shane Caraveo | + | Ilia Alshanetsky | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_SCANDIR_H +#define PHP_SCANDIR_H + #include #ifdef PHP_WIN32 @@ -7,14 +31,19 @@ #include "php_config.h" #endif +#ifdef HAVE_SCANDIR #ifdef HAVE_DIRENT_H -# include +#include #endif - -#ifndef HAVE_ALPHASORT -int alphasort(const struct dirent **a, const struct dirent **b); +#define php_scandir scandir +#else +int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)); #endif -#ifndef HAVE_SCANDIR -int scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)); +#ifdef HAVE_ALPHASORT +#define php_alphasort alphasort +#else +int php_alphasort(const struct dirent **a, const struct dirent **b); #endif + +#endif /* PHP_SCANDIR_H */