From 07a13ae6af039060f346a651ef3f97ad8f183459 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 11 May 2002 09:09:57 +0000 Subject: [PATCH] make dirent sys/types and sys/stat autoconfable .... git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@137 a5681a0c-68f1-0310-ab6d-d61299d08faa --- configure.ac | 3 ++- src/rrd_tool.c | 4 ++-- src/rrd_tool.h | 31 ++++++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index ea2c839..9c9fe25 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 41cf3cd..4a6c8cd 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -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); } } diff --git a/src/rrd_tool.h b/src/rrd_tool.h index 780cd05..7280e74 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -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 -#include -#include -/* + +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif #endif -*/ + +#if HAVE_SYS_TYPES_H +# include +#endif + +#if HAVE_SYS_STAT_H +# include +#endif + + #if HAVE_UNISTD_H # include #endif -- 2.11.0