On Sat, 2003-01-25 at 20:39, Shane Caraveo wrote:
> shane         Sat Jan 25 20:39:18 2003 EDT
> 
>   Modified files:              
>     /php4/main        php_ini.c 
>     /php4/win32       readdir.c readdir.h 
>   Log:
>   Fix broken build by adding scandir and alphasort for win32
>   

make alphasort a static?

-Sterling

>   
> Index: php4/main/php_ini.c
> diff -u php4/main/php_ini.c:1.110 php4/main/php_ini.c:1.111
> --- php4/main/php_ini.c:1.110 Sat Jan 25 16:13:00 2003
> +++ php4/main/php_ini.c       Sat Jan 25 20:39:18 2003
> @@ -16,7 +16,7 @@
>     +----------------------------------------------------------------------+
>   */
>  
> -/* $Id: php_ini.c,v 1.110 2003/01/25 21:13:00 iliaa Exp $ */
> +/* $Id: php_ini.c,v 1.111 2003/01/26 01:39:18 shane Exp $ */
>  
>  /* Check CWD for php.ini */
>  #define INI_CHECK_CWD
> @@ -31,7 +31,13 @@
>  #include "SAPI.h"
>  #include "php_main.h"
>  
> +#ifdef PHP_WIN32
> +#include "readdir.h"
> +/* this makes no sence, vc6 errors if this declaration is not here */
> +extern int alphasort(const struct dirent **a, const struct dirent **b);
> +#else
>  #include "dirent.h"
> +#endif
>  
>  #ifndef S_ISREG
>  #define S_ISREG(mode)   (((mode) & S_IFMT) == S_IFREG)
> Index: php4/win32/readdir.c
> diff -u php4/win32/readdir.c:1.8 php4/win32/readdir.c:1.9
> --- php4/win32/readdir.c:1.8  Mon Jul 29 09:12:57 2002
> +++ php4/win32/readdir.c      Sat Jan 25 20:39:18 2003
> @@ -141,3 +141,83 @@
>  
>  return 0;
>  }
> +
> +int alphasort(const struct dirent **a, const struct dirent **b)
> +{
> +     return strcoll((*a)->d_name,(*b)->d_name);
> +}
> +
> +int 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;
> +     struct dirent *dp = NULL;
> +     int vector_size = 0;
> +
> +     int nfiles = 0;
> +     int fail = 0;
> +
> +     if (namelist == NULL)
> +             return -1;
> +
> +     dirp = opendir(dirname);
> +     if (dirp == NULL)
> +             return -1;
> +
> +     for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
> +     {
> +             int dsize = 0;
> +             struct dirent *newdp = NULL;
> +
> +             if (selector && (*selector)(dp) == 0)
> +                     continue;
> +
> +             if (nfiles == vector_size)
> +             {
> +                     struct dirent **newv;
> +                     if (vector_size == 0)
> +                             vector_size = 10;
> +                     else
> +                             vector_size *= 2;
> +
> +                     newv = (struct dirent **) realloc (vector, vector_size * 
>sizeof (struct dirent *));
> +                     if (newv == NULL)
> +                     {
> +                             fail = 1;
> +                             break;
> +                     }
> +                     vector = newv;
> +             }
> +
> +             dsize = sizeof (struct dirent) + ((strlen(dp->d_name) + 1) * 
>sizeof(char));
> +             newdp = (struct dirent *) malloc(dsize);
> +
> +             if (newdp == NULL)
> +             {
> +                     fail = 1;
> +                     break;
> +             }
> +
> +             vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
> +     }
> +
> +     closedir(dirp);
> +
> +     if (fail)
> +     {
> +             while (nfiles-- > 0) free(vector[nfiles]);
> +             free(vector);
> +             return -1;
> +     }
> +
> +
> +     *namelist = vector;
> +
> +     if (compare)
> +             qsort (*namelist,nfiles,sizeof (struct dirent *),compare);
> +
> +     return nfiles;
> +}
> Index: php4/win32/readdir.h
> diff -u php4/win32/readdir.h:1.6 php4/win32/readdir.h:1.7
> --- php4/win32/readdir.h:1.6  Mon Jul 29 09:12:57 2002
> +++ php4/win32/readdir.h      Sat Jan 25 20:39:18 2003
> @@ -39,6 +39,10 @@
>  int readdir_r(DIR *, struct dirent *, struct dirent **);
>  int closedir(DIR *);
>  int rewinddir(DIR *);
> -
> +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 alphasort(const struct dirent **a, const struct dirent **b);
>  
>  #endif /* READDIR_H */
-- 
"Science is like sex: sometimes something useful comes out, 
but that is not the reason we are doing it." 
    - Richard Feynman


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to