From ba2c80c91cfd8390ced743f8ee899612acb72b24 Mon Sep 17 00:00:00 2001 From: Bryan Jurish Date: Thu, 14 May 2009 19:30:51 +0000 Subject: + win32 fixes: check for dirent.d_type and DT_* decls + minor improvements: report errors with pd_error() instead of error() + todo (maybe): use stat() to get file types when dirent.d_type is unavailable? - mabe better delegate this to a different external entirely (e.g. 'stat') svn path=/trunk/externals/moocow/; revision=11365 --- readdir/configure | 609 +++++++++++++++++++++++++++++++++++++++++++- readdir/configure.ac | 21 +- readdir/src/config.h.in | 31 +++ readdir/src/readdir-help.pd | 51 ++-- readdir/src/readdir.c | 53 ++-- 5 files changed, 708 insertions(+), 57 deletions(-) (limited to 'readdir') diff --git a/readdir/configure b/readdir/configure index d52ec3a..8d2276e 100755 --- a/readdir/configure +++ b/readdir/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for readdir 0.02-2. +# Generated by GNU Autoconf 2.61 for readdir 0.03-0. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='readdir' PACKAGE_TARNAME='readdir' -PACKAGE_VERSION='0.02-2' -PACKAGE_STRING='readdir 0.02-2' +PACKAGE_VERSION='0.03-0' +PACKAGE_STRING='readdir 0.03-0' PACKAGE_BUGREPORT='moocow@ling.uni-potsdam.de' ac_default_prefix=/usr/local @@ -1190,7 +1190,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures readdir 0.02-2 to adapt to many kinds of systems. +\`configure' configures readdir 0.03-0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1256,7 +1256,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of readdir 0.02-2:";; + short | recursive ) echo "Configuration of readdir 0.03-0:";; esac cat <<\_ACEOF @@ -1352,7 +1352,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -readdir configure 0.02-2 +readdir configure 0.03-0 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1366,7 +1366,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by readdir $as_me 0.02-2, which was +It was created by readdir $as_me 0.03-0, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2126,7 +2126,7 @@ fi # Define the identity of the package. PACKAGE=readdir - VERSION=0.02-2 + VERSION=0.03-0 cat >>confdefs.h <<_ACEOF @@ -3967,6 +3967,595 @@ done ## /local: headers ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +## Local: structs + +##-- check for 'd_type' field in struct dirent +{ echo "$as_me:$LINENO: checking for struct dirent.d_type" >&5 +echo $ECHO_N "checking for struct dirent.d_type... $ECHO_C" >&6; } +if test "${ac_cv_member_struct_dirent_d_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +static struct dirent ac_aggr; +if (ac_aggr.d_type) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_member_struct_dirent_d_type=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +static struct dirent ac_aggr; +if (sizeof ac_aggr.d_type) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_member_struct_dirent_d_type=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_member_struct_dirent_d_type=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_dirent_d_type" >&5 +echo "${ECHO_T}$ac_cv_member_struct_dirent_d_type" >&6; } +if test $ac_cv_member_struct_dirent_d_type = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_DIRENT_D_TYPE 1 +_ACEOF + +HAVE_STRUCT_DIRENT_D_TYPE=yes +else + HAVE_STRUCT_DIRENT_D_TYPE=no +fi + + +##-- check for dirent d_type decls +{ echo "$as_me:$LINENO: checking whether DT_REG is declared" >&5 +echo $ECHO_N "checking whether DT_REG is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_REG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_REG + (void) DT_REG; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_REG=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_REG=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_REG" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_REG" >&6; } +if test $ac_cv_have_decl_DT_REG = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_REG 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_REG 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_DIR is declared" >&5 +echo $ECHO_N "checking whether DT_DIR is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_DIR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_DIR + (void) DT_DIR; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_DIR=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_DIR=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_DIR" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_DIR" >&6; } +if test $ac_cv_have_decl_DT_DIR = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_DIR 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_DIR 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_FIFO is declared" >&5 +echo $ECHO_N "checking whether DT_FIFO is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_FIFO+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_FIFO + (void) DT_FIFO; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_FIFO=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_FIFO=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_FIFO" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_FIFO" >&6; } +if test $ac_cv_have_decl_DT_FIFO = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_FIFO 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_FIFO 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_SOCK is declared" >&5 +echo $ECHO_N "checking whether DT_SOCK is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_SOCK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_SOCK + (void) DT_SOCK; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_SOCK=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_SOCK=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_SOCK" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_SOCK" >&6; } +if test $ac_cv_have_decl_DT_SOCK = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_SOCK 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_SOCK 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_CHR is declared" >&5 +echo $ECHO_N "checking whether DT_CHR is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_CHR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_CHR + (void) DT_CHR; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_CHR=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_CHR=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_CHR" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_CHR" >&6; } +if test $ac_cv_have_decl_DT_CHR = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_CHR 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_CHR 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_BLK is declared" >&5 +echo $ECHO_N "checking whether DT_BLK is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_BLK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_BLK + (void) DT_BLK; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_BLK=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_BLK=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_BLK" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_BLK" >&6; } +if test $ac_cv_have_decl_DT_BLK = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_BLK 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_BLK 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether DT_UNKNOWN is declared" >&5 +echo $ECHO_N "checking whether DT_UNKNOWN is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_DT_UNKNOWN+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef DT_UNKNOWN + (void) DT_UNKNOWN; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_DT_UNKNOWN=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_DT_UNKNOWN=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_DT_UNKNOWN" >&5 +echo "${ECHO_T}$ac_cv_have_decl_DT_UNKNOWN" >&6; } +if test $ac_cv_have_decl_DT_UNKNOWN = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_UNKNOWN 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_DT_UNKNOWN 0 +_ACEOF + + +fi + + + + +## /local: structs +##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ## Local: debug @@ -4479,7 +5068,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by readdir $as_me 0.02-2, which was +This file was extended by readdir $as_me 0.03-0, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4532,7 +5121,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -readdir config.status 0.02-2 +readdir config.status 0.03-0 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/readdir/configure.ac b/readdir/configure.ac index ab8d734..62a7f7d 100644 --- a/readdir/configure.ac +++ b/readdir/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ(2.5) dnl Some handy macros define([THE_PACKAGE_NAME], [readdir]) -define([THE_PACKAGE_VERSION], [0.02-2]) +define([THE_PACKAGE_VERSION], [0.03-0]) define([THE_PACKAGE_AUTHOR], [moocow@ling.uni-potsdam.de]) AC_INIT(THE_PACKAGE_NAME, THE_PACKAGE_VERSION, THE_PACKAGE_AUTHOR) @@ -49,6 +49,7 @@ AX_PD_EXTERNAL ## Local: headers dnl AC_HEADER_STDC +dnl sys/stat.h AC_CHECK_HEADERS([dirent.h fcntl.h string.h errno.h], [], AC_MSG_WARN([-----------------------------------------------------------------]) @@ -59,6 +60,24 @@ AC_CHECK_HEADERS([dirent.h fcntl.h string.h errno.h], ## /local: headers ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +## Local: structs + +##-- check for 'd_type' field in struct dirent +AC_CHECK_MEMBERS([struct dirent.d_type], + [HAVE_STRUCT_DIRENT_D_TYPE=yes],[HAVE_STRUCT_DIRENT_D_TYPE=no], + [#include ]) + +##-- check for dirent d_type decls +AC_CHECK_DECLS([DT_REG,DT_DIR,DT_FIFO,DT_SOCK,DT_CHR,DT_BLK,DT_UNKNOWN], + [],[], + [#include ]) + + +## /local: structs +##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ## Local: debug diff --git a/readdir/src/config.h.in b/readdir/src/config.h.in index 4496bb9..5e86779 100644 --- a/readdir/src/config.h.in +++ b/readdir/src/config.h.in @@ -1,5 +1,33 @@ /* src/config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if you have the declaration of `DT_BLK', and to 0 if you don't. + */ +#undef HAVE_DECL_DT_BLK + +/* Define to 1 if you have the declaration of `DT_CHR', and to 0 if you don't. + */ +#undef HAVE_DECL_DT_CHR + +/* Define to 1 if you have the declaration of `DT_DIR', and to 0 if you don't. + */ +#undef HAVE_DECL_DT_DIR + +/* Define to 1 if you have the declaration of `DT_FIFO', and to 0 if you + don't. */ +#undef HAVE_DECL_DT_FIFO + +/* Define to 1 if you have the declaration of `DT_REG', and to 0 if you don't. + */ +#undef HAVE_DECL_DT_REG + +/* Define to 1 if you have the declaration of `DT_SOCK', and to 0 if you + don't. */ +#undef HAVE_DECL_DT_SOCK + +/* Define to 1 if you have the declaration of `DT_UNKNOWN', and to 0 if you + don't. */ +#undef HAVE_DECL_DT_UNKNOWN + /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H @@ -12,6 +40,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if `d_type' is member of `struct dirent'. */ +#undef HAVE_STRUCT_DIRENT_D_TYPE + /* Name of package */ #undef PACKAGE diff --git a/readdir/src/readdir-help.pd b/readdir/src/readdir-help.pd index 65d3239..81335e7 100644 --- a/readdir/src/readdir-help.pd +++ b/readdir/src/readdir-help.pd @@ -1,41 +1,46 @@ -#N canvas 438 13 535 566 10; +#N canvas 438 13 543 650 10; #X msg 89 227 close; #X msg 52 79 bang; #X msg 83 160 tell; #X obj 38 322 print dir-entry; #X obj 82 294 print end-of-directory; #X text 130 8 readdir : simple directory accessor; -#X text 231 543 Bryan Jurish ; +#X text 245 617 Bryan Jurish ; #X text 157 46 open DIR : opens the directory DIR; -#X text 185 75 bang : outlet next directory entry; -#X text 185 91 next : ditto; +#X text 185 80 bang : outlet next directory entry; +#X text 185 101 next : ditto; #X msg 59 101 next; #X msg 71 137 rewind; #X text 173 137 rewind : return to beginning of directory; -#X text 188 158 tell : output current position; -#X text 146 182 seek FLOAT : goto position FLOAT; +#X text 187 160 tell : output current position; +#X text 146 185 seek FLOAT : goto position FLOAT; #X msg 86 184 seek 0; -#X text 181 223 close : close directory; +#X text 181 229 close : close directory; #X text 258 295 2nd outlet bangs at end of directory; #X text 260 325 Directory entries go to 1st outlet; #X text 39 370 Directory entries appear as messages of the form TYPE NAME \, where NAME is the name of the entry \, and TYPE is one of the following:; -#X text 65 515 unknown : something else; -#X text 87 419 file : regular file; -#X text 93 434 dir : subdirectory; -#X text 86 450 fifo : named pipe; -#X text 85 466 sock : local-domain socket; -#X text 71 482 chrdev : character device; -#X text 71 498 blkdev : block device; +#X text 87 416 file : regular file; +#X text 94 429 dir : subdirectory; +#X text 87 442 fifo : named pipe; +#X text 87 455 sock : local-domain socket; +#X text 73 468 chrdev : character device; +#X text 73 482 blkdev : block device; #X obj 38 267 readdir; #X msg 39 47 open /tmp; -#X connect 0 0 27 0; -#X connect 1 0 27 0; -#X connect 2 0 27 0; -#X connect 10 0 27 0; -#X connect 11 0 27 0; -#X connect 15 0 27 0; -#X connect 27 0 3 0; -#X connect 27 1 4 0; -#X connect 28 0 27 0; +#X text 66 495 unknown : something else (maybe a symlink); +#X text 45 530 WARNING:; +#X text 59 544 Recognition of directory entry types does NOT work on +windows or any other system whose `dirent' struct is missing the `d_type' +field. On such systems \, the TYPE selector on the first outlet is +always the symbol `unknown'.; +#X connect 0 0 26 0; +#X connect 1 0 26 0; +#X connect 2 0 26 0; +#X connect 10 0 26 0; +#X connect 11 0 26 0; +#X connect 15 0 26 0; +#X connect 26 0 3 0; +#X connect 26 1 4 0; +#X connect 27 0 26 0; diff --git a/readdir/src/readdir.c b/readdir/src/readdir.c index a2bdbb8..0dbd73d 100644 --- a/readdir/src/readdir.c +++ b/readdir/src/readdir.c @@ -93,7 +93,7 @@ static void readdir_close(t_readdir *x) { if (!x->x_dir) return; if (0 != closedir(x->x_dir)) { - error("readdir: cannot close %s: %s", x->x_dirname->s_name, strerror(errno)); + pd_error(x, "readdir: cannot close %s: %s", x->x_dirname->s_name, strerror(errno)); return; } x->x_dir = NULL; @@ -111,7 +111,7 @@ static void readdir_open(t_readdir *x, t_symbol *dirname) if (x->x_dir) readdir_close(x); if ( !(x->x_dir = opendir(dirname->s_name)) ) { - error("readdir: cannot open %s: %s", dirname->s_name, strerror(errno)); + pd_error(x, "readdir: cannot open %s: %s", dirname->s_name, strerror(errno)); return; } x->x_dirname = dirname; @@ -127,7 +127,7 @@ static void readdir_next(t_readdir *x) if ( !x->x_dir || !(result = readdir(x->x_dir)) ) { if (errno == EBADF) { //-- real error - error("readdir: cannot read from %s: %s", x->x_dirname->s_name, strerror(errno)); + pd_error(x, "readdir: cannot read from %s: %s", x->x_dirname->s_name, strerror(errno)); } else { //-- end of directory @@ -136,37 +136,44 @@ static void readdir_next(t_readdir *x) return; } - //-- get type +#if HAVE_STRUCT_DIRENT_D_TYPE + //-- get type (if this OS supports it, e.g. if we're not on windoof) switch (result->d_type) { - case DT_REG: - sel = sp_file; - break; +#if HAVE_DECL_DT_REG + case DT_REG: sel = sp_file; break; +#endif - case DT_DIR: - sel = sp_dir; - break; +#if HAVE_DECL_DT_DIR + case DT_DIR: sel = sp_dir; break; +#endif - case DT_FIFO: - sel = sp_fifo; - break; +#if HAVE_DECL_DT_FIFO + case DT_FIFO: sel = sp_fifo; break; +#endif - case DT_SOCK: - sel = sp_sock; - break; +#if HAVE_DECL_DT_SOCK + case DT_SOCK: sel = sp_sock; break; +#endif - case DT_CHR: - sel = sp_chrdev; - break; +#if HAVE_DECL_DT_CHR + case DT_CHR: sel = sp_chrdev; break; +#endif - case DT_BLK: - sel = sp_blkdev; - break; +#if HAVE_DECL_DT_BLK + case DT_BLK: sel = sp_blkdev; break; +#endif +#if HAVE_DECL_DT_UNKNOWN + case DT_UNKNOWN: +#endif default: sel = sp_unknown; break; } +#else /* if !HAVE_STRUCT_DIRENT_D_TYPE */ + sel = sp_unknown; +#endif /* HAVE_STRUCT_DIRENT_D_TYPE */ x->x_eatom.a_w.w_symbol = gensym(result->d_name); outlet_anything(x->x_ent_outlet, sel, 1, &x->x_eatom); @@ -199,7 +206,7 @@ static void readdir_tell(t_readdir *x) static void readdir_seek(t_readdir *x, t_floatarg pos) { if (!x->x_dir) { - error("readdir: seek %f: no directory opened!", pos); + pd_error(x, "readdir: seek %g: no directory opened!", pos); return; } seekdir(x->x_dir, (off_t)pos); -- cgit v1.2.1