Index: cups/dir.c =================================================================== --- cups/dir.c.orig 2006-09-05 15:45:47.000000000 -0500 +++ cups/dir.c 2006-10-01 22:21:27.472196000 -0500 @@ -40,6 +40,26 @@ * Include necessary headers... */ +#include + +/* + * If readdir_r() requires -D_POSIX_PTHREAD_SEMANTICS to work + * correctly. Solaris requires this. + */ +#ifdef READDIR_R_NEEDS__POSIX_PTHREAD_SEMANTICS +#define _POSIX_PTHREAD_SEMANTICS +#endif + +/* + * If readdir_r() requires -D_REENTRANT to work correctly. HP-UX + * 10.20 requires this. + */ + +#ifdef READDIR_R_NEEDS__REENTRANT +#define _REENTRANT +#endif + + #include "dir.h" #include "string.h" #include "debug.h" @@ -353,6 +373,10 @@ char filename[1024]; /* Full filename */ +#if READDIR_R_NARGS == 2 + entry = (struct dirent *)buffer; +#endif + DEBUG_printf(("cupsDirRead(dp=%p)\n", dp)); /* @@ -368,7 +392,11 @@ for (;;) { +#if READDIR_R_NARGS == 2 + if (readdir_r(dp->dir, entry)) +#elif READDIR_R_NARGS == 3 if (readdir_r(dp->dir, (struct dirent *)buffer, &entry)) +#endif { DEBUG_printf((" readdir_r() failed - %s\n", strerror(errno))); return (NULL); Index: config-scripts/cups-common.m4 =================================================================== --- config-scripts/cups-common.m4.orig 2006-09-29 18:39:06.296919000 -0500 +++ config-scripts/cups-common.m4 2006-10-01 21:46:47.641275000 -0500 @@ -176,6 +176,67 @@ AC_DEFINE(HAVE_TM_GMTOFF), AC_MSG_RESULT(no)) +dnl Number of arguments to readdir_r(). HP-UX 10.20 uses the older +dnl CMA threads with a readdir_r() accepting two arguments. It +dnl also requires -D_REENTRANT to expose the readdir_r() prototype. +AC_MSG_CHECKING(if readdir_r() takes 2 arguments) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _REENTRANT +#include +#include +#include + +extern int readdir_r(DIR *, struct dirent *);]],[[DIR *dir; + struct dirent entry; + + dir = opendir ("."); + if (!dir) + exit (1); + + exit (readdir_r(dir, &entry));]])],[ + AC_MSG_RESULT(yes) + AC_DEFINE(READDIR_R_NARGS, 2) + AC_DEFINE(READDIR_R_NEEDS__REENTRANT)],[ + AC_DEFINE(READDIR_R_NARGS, 3) + AC_MSG_RESULT(no)]) + +dnl See if -D_POSIX_PTHREAD_SEMANTICS required for readdir_r() +dnl to work correctly. Solaris needs this. +AC_MSG_CHECKING(if readdir_r() needs -D_POSIX_PTHREAD_SEMANTICS) +AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include +#include +#include ]],[[DIR *dir; + char buffer[sizeof(struct dirent) + 1024]; + struct dirent *entry; + + dir = opendir ("."); + if (!dir) + exit (1); + + #if READDIR_R_NARGS == 3 + exit (readdir_r(dir, (struct dirent *)buffer, &entry)); + #endif]])],[ + AC_MSG_RESULT(no)],[ + save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" + AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include +#include +#include ]],[[DIR *dir; + char buffer[sizeof(struct dirent) + 1024]; + struct dirent *entry; + + dir = opendir ("."); + if (!dir) + exit (1); + + #if READDIR_R_NARGS == 3 + exit (readdir_r(dir, (struct dirent *)buffer, &entry)); + #endif]])],[ + AC_MSG_RESULT(yes) + AC_DEFINE(READDIR_R_NEEDS__POSIX_PTHREAD_SEMANTICS)],[ + AC_MSG_RESULT(unknown) + AC_MSG_ERROR(readdir_r() non-functional)]) + CPPFLAGS=$save_CPPFLAGS]) + dnl Flags for "ar" command... case $uname in Darwin* | *BSD*) Index: config.h.in =================================================================== --- config.h.in.orig 2006-09-29 18:39:05.067860000 -0500 +++ config.h.in 2006-10-01 21:21:30.122501000 -0500 @@ -442,6 +442,27 @@ #undef ENABLE_IPV6 +/* + * If readdir_r() requires -D_POSIX_PTHREAD_SEMANTICS to work + * correctly. Solaris requires this. + */ + +#undef READDIR_R_NEEDS__POSIX_PTHREAD_SEMANTICS + +/* + * If readdir_r() requires -D_REENTRANT to work correctly. HP-UX + * 10.20 requires this. + */ + +#undef READDIR_R_NEEDS__REENTRANT + +/* + * Number of arguments to readdir_r(). HP-UX 10.20 uses the older + * CMA threads with a readdir_r() accepting two arguments. + */ + +#undef READDIR_R_NARGS + #endif /* !_CUPS_CONFIG_H_ */ /*