From 6474c9faccc6b1435c0250a0b0ff3e2dd26fcfb0 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@137 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/configure.ac | 3 ++- program/src/rrd_tool.c | 4 ++-- program/src/rrd_tool.h | 31 ++++++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/program/configure.ac b/program/configure.ac index ea2c8390..9c9fe258 100644 --- a/program/configure.ac +++ b/program/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/program/src/rrd_tool.c b/program/src/rrd_tool.c index 41cf3cde..4a6c8cd7 100644 --- a/program/src/rrd_tool.c +++ b/program/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/program/src/rrd_tool.h b/program/src/rrd_tool.h index 780cd05e..7280e744 100644 --- a/program/src/rrd_tool.h +++ b/program/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.30.2