summaryrefslogtreecommitdiff
path: root/source3/lib/replace/repdir.m4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-09-18 22:49:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:52:03 -0500
commit8f153c6128dd15fb132d8ddb1752e793bd6a5985 (patch)
tree0e2314019948ef0fdfcce1a15a63c0a4828e6bb7 /source3/lib/replace/repdir.m4
parentf2e7b8d1449b9f8a7177a19842d25440950f733f (diff)
downloadsamba-8f153c6128dd15fb132d8ddb1752e793bd6a5985.tar.gz
samba-8f153c6128dd15fb132d8ddb1752e793bd6a5985.tar.bz2
samba-8f153c6128dd15fb132d8ddb1752e793bd6a5985.zip
r18644: bring in libreplace in lib/replace
metze (This used to be commit 596cbe73dd268742acf456fccd8a234376fb0c97)
Diffstat (limited to 'source3/lib/replace/repdir.m4')
-rw-r--r--source3/lib/replace/repdir.m477
1 files changed, 77 insertions, 0 deletions
diff --git a/source3/lib/replace/repdir.m4 b/source3/lib/replace/repdir.m4
new file mode 100644
index 0000000000..93bf4ec911
--- /dev/null
+++ b/source3/lib/replace/repdir.m4
@@ -0,0 +1,77 @@
+AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[
+ AC_TRY_RUN([
+#define test_readdir_os2_delete main
+#include "$libreplacedir/test/os2_delete.c"],
+ [libreplace_READDIR_NEEDED=no],
+ [libreplace_READDIR_NEEDED=yes],
+ [libreplace_READDIR_NEEDED="assuming not"])
+])
+
+#
+# try to replace with getdents() if needed
+#
+if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
+AC_CHECK_FUNCS(getdents)
+AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[
+ AC_TRY_RUN([
+#define _LIBREPLACE_REPLACE_H
+#include "$libreplacedir/repdir_getdents.c"
+#define test_readdir_os2_delete main
+#include "$libreplacedir/test/os2_delete.c"],
+ [libreplace_READDIR_GETDENTS=yes],
+ [libreplace_READDIR_GETDENTS=no])
+])
+fi
+if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then
+ AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
+ AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
+ LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o"
+ libreplace_READDIR_NEEDED=no
+fi
+
+#
+# try to replace with getdirentries() if needed
+#
+if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
+AC_CHECK_FUNCS(getdirentries)
+AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
+ [
+ return 0;
+ ],[
+ AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
+ ],[],[
+ #include <dirent.h>
+ ])
+
+AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
+ [
+ return 0;
+ ],[
+ AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
+ ],[],[
+ #include <dirent.h>
+ ])
+AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[
+ AC_TRY_RUN([
+#define _LIBREPLACE_REPLACE_H
+#include "$libreplacedir/repdir_getdirentries.c"
+#define test_readdir_os2_delete main
+#include "$libreplacedir/test/os2_delete.c"],
+ [libreplace_READDIR_GETDIRENTRIES=yes],
+ [libreplace_READDIR_GETDIRENTRIES=no])
+])
+fi
+if test x"$libreplace_READDIR_GETDIRENTRIES" = x"yes"; then
+ AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
+ AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
+ LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o"
+ libreplace_READDIR_NEEDED=no
+fi
+
+AC_MSG_CHECKING([a usable readdir()])
+if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
+ AC_MSG_RESULT(no)
+ AC_MSG_WARN([the provided readdir() is broken])
+else
+ AC_MSG_RESULT(yes)
+fi