dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already
dnl defined.
m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
+
+dnl check if the prototype in the header matches the given one
+dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders])
+AC_DEFUN(AC_VERIFY_C_PROTOTYPE,
+[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]),
+ AC_COMPILE_IFELSE([
+ AC_INCLUDES_DEFAULT
+ $5
+ $1
+ {
+ $2
+ }
+ ],[
+ AS_TR_SH([ac_cv_c_prototype_$1])=yes
+ $3
+ ],[
+ AS_TR_SH([ac_cv_c_prototype_$1])=no
+ $4
+ ])
+)])
AC_CHECK_FUNCS(getdents)
AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[
AC_TRY_RUN([
-#include "confdefs.h"
+#define _LIBREPLACE_REPLACE_H
#include "$libreplacedir/repdir_getdents.c"
#define test_readdir_os2_delete main
#include "$libreplacedir/test/os2_delete.c"],
#
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([
-#include "confdefs.h"
+#define _LIBREPLACE_REPLACE_H
#include "$libreplacedir/repdir_getdirentries.c"
#define test_readdir_os2_delete main
#include "$libreplacedir/test/os2_delete.c"],
well. Contact the author.
*/
+#include "replace.h"
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
return de;
}
-#define TELLDIR_TAKES_CONST_DIR
-
#ifdef TELLDIR_TAKES_CONST_DIR
long telldir(const DIR *dir)
#else
return d->seekpos + d->ofs;
}
+#ifdef SEEKDIR_RETURNS_INT
+int seekdir(DIR *dir, long ofs)
+#else
void seekdir(DIR *dir, long ofs)
+#endif
{
struct dir_buf *d = (struct dir_buf *)dir;
long pos;
while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
if (readdir(dir) == NULL) break;
}
+#ifdef SEEKDIR_RETURNS_INT
+ return -1;
+#endif
}
void rewinddir(DIR *dir)