make dirent sys/types and sys/stat autoconfable ....
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sat, 11 May 2002 09:09:57 +0000 (09:09 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sat, 11 May 2002 09:09:57 +0000 (09:09 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@137 a5681a0c-68f1-0310-ab6d-d61299d08faa

configure.ac
src/rrd_tool.c
src/rrd_tool.h

index ea2c839..9c9fe25 100644 (file)
@@ -230,7 +230,8 @@ AC_PROG_LIBTOOL
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h time.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/time.h sys/times.h sys/param.h sys/resource.h float.h)
+AC_HEADER_DIRENT
+AC_CHECK_HEADERS(sys/stat.h sys/types.h fcntl.h time.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/time.h sys/times.h sys/param.h sys/resource.h float.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
index 41cf3cd..4a6c8cd 100644 (file)
@@ -422,8 +422,8 @@ int HandleInputLine(int argc, char **argv, FILE* out)
                       printf("d %s\n",dent->d_name);
                    }
                    if (strlen(dent->d_name)>4 && S_ISREG(st.st_mode)){
-                      if (!strcmp(dent->d_name+strlen(dent->d_name)-4,".rrd") ||
-                          !strcmp(dent->d_name+strlen(dent->d_name)-4,".RRD")){
+                      if (!strcmp(dent->d_name+NAMLEN(dent)-4,".rrd") ||
+                          !strcmp(dent->d_name+NAMLEN(dent)-4,".RRD")){
                          printf("- %s\n",dent->d_name);
                       }
                    }
index 780cd05..7280e74 100644 (file)
@@ -48,12 +48,33 @@ extern "C" {
 /* Sorry: don't know autoconf as well how to check the exist of
    dirent.h ans sys/stat.h
 */
-#include <sys/stat.h>
-#include <dirent.h>
-#include <sys/types.h>
-/*
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+#  include <ndir.h>
+# endif
 #endif
-*/
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+
 #if HAVE_UNISTD_H
 # include <unistd.h>
 #endif