From: Michael Poole Date: Mon, 12 Apr 2004 03:25:03 +0000 (+0000) Subject: fix compile errors on readdir()-deficient platforms X-Git-Tag: v1.4.0-rc1~226 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=f8dd4fc662c0a192f777bc426b37336300670b9b fix compile errors on readdir()-deficient platforms * Cygwin does not have "struct dirent.d_type". Check for that in the configure script and use stat() to test for directory-ness instead. git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-50 --- diff --git a/ChangeLog b/ChangeLog index fb2dad9..7433ad9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,20 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3 # +2004-04-12 03:25:03 GMT Michael Poole patch-50 + + Summary: + fix compile errors on readdir()-deficient platforms + Revision: + srvx--devo--1.3--patch-50 + + * Cygwin does not have "struct dirent.d_type". Check for that in the + configure script and use stat() to test for directory-ness instead. + + modified files: + ChangeLog configure.in src/helpfile.c + + 2004-04-10 23:04:21 GMT Michael Poole patch-49 Summary: diff --git a/configure.in b/configure.in index 203ecfa..26ef7dd 100644 --- a/configure.in +++ b/configure.in @@ -66,7 +66,11 @@ AC_HEADER_TIME AC_STRUCT_TM dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi -AC_CHECK_HEADERS(fcntl.h malloc.h netdb.h netinet/in.h sys/resource.h sys/timeb.h sys/times.h sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h unistd.h getopt.h memory.h regex.h arpa/inet.h sys/mman.h sys/stat.h,,) +AC_CHECK_HEADERS(fcntl.h malloc.h netdb.h netinet/in.h sys/resource.h sys/timeb.h sys/times.h sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h unistd.h getopt.h memory.h regex.h arpa/inet.h sys/mman.h sys/stat.h dirent.h,,) + +dnl Cygwin does not have d_type in struct dirent. We use stat() as a fallback. +AC_CHECK_MEMBER([struct dirent.d_type], + [AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [Define if struct dirent exists and includes the d_type element.])],,[#include ]) dnl portability stuff, hurray! -Jedi AC_CHECK_FUNCS(gettimeofday) diff --git a/src/helpfile.c b/src/helpfile.c index 466ec33..a08c7b7 100644 --- a/src/helpfile.c +++ b/src/helpfile.c @@ -24,7 +24,13 @@ #include "modcmd.h" #include "nickserv.h" +#if defined(HAVE_DIRENT_H) #include +#endif + +#if defined(HAVE_SYS_STAT_H) +#include +#endif static const struct message_entry msgtab[] = { { "HFMSG_MISSING_HELPFILE", "The help file could not be found. Sorry!" }, @@ -224,8 +230,20 @@ static void language_read_list(void) while ((dirent = readdir(dir))) { if (dirent->d_name[0] == '.') continue; +#ifdef HAVE_DIRENT_D_TYPE if (dirent->d_type != DT_DIR) continue; +#else + { + char namebuf[MAXLEN]; + struct stat sbuf; + snprintf(namebuf, sizeof(namebuf), "languages/%s", dirent->d_name); + if (stat(namebuf, &sbuf) < 0) + continue; + if (!S_ISDIR(sbuf.st_mode)) + continue; + } +#endif language_alloc(dirent->d_name); } closedir(dir);