Skip to content
Browse files

Fix the possible conflicts with other libs (like libc-client)

  • Loading branch information...
1 parent 8e3f23e commit ec11fe04e9f0c1d34051efdac8d8ce106878f319 foobar committed Feb 19, 2003
Showing with 61 additions and 15 deletions.
  1. +4 −5 main/php_ini.c
  2. +22 −4 main/php_scandir.c
  3. +35 −6 main/php_scandir.h
View
9 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 <dirent.h>
+#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
+#include <dirent.h>
#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"))) {
View
26 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 <sys/types.h>
+#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
@@ -38,19 +43,23 @@
#include <stdlib.h>
#include <search.h>
-#endif
+
+#endif /* HAVE_SCANDIR */
#ifndef HAVE_ALPHASORT
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#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 @@ int scandir(const char *dirname, struct dirent **namelist[], int (*selector) (co
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
+ */
View
41 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 <shane@caraveo.com> |
+ | Ilia Alshanetsky <ilia@prohost.org> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_SCANDIR_H
+#define PHP_SCANDIR_H
+
#include <sys/types.h>
#ifdef PHP_WIN32
@@ -7,14 +31,19 @@
#include "php_config.h"
#endif
+#ifdef HAVE_SCANDIR
#ifdef HAVE_DIRENT_H
-# include <dirent.h>
+#include <dirent.h>
#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 */

0 comments on commit ec11fe0

Please sign in to comment.
Something went wrong with that request. Please try again.