diff --git a/include/sane/config.h.in b/include/sane/config.h.in index 7071785..0fb5424 100644 --- a/include/sane/config.h.in +++ b/include/sane/config.h.in @@ -118,12 +118,18 @@ /* Define if you have the getcwd function. */ #undef HAVE_GETCWD +/* Define if you have the getenv function. */ +#undef HAVE_GETENV + /* Define if you have the getpagesize function. */ #undef HAVE_GETPAGESIZE /* Define if you have the atexit function. */ #undef HAVE_ATEXIT +/* Define if you have the isfdtype function. */ +#undef HAVE_ISFDTYPE + /* Define if you have the mkdir function. */ #undef HAVE_MKDIR @@ -178,6 +184,9 @@ /* Define if you have the valloc function. */ #undef HAVE_VALLOC +/* Define if you have the vsyslog function. */ +#undef HAVE_VSYSLOG + /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF diff --git a/lib/Makefile.in b/lib/Makefile.in index 67028b4..c40d5f5 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -40,9 +40,11 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @SET_MAKE@ LIBLIB_OBJS = alloca.o getopt.o getopt1.o strndup.o \ - strdup.o strsep.o snprintf.o usleep.o + strdup.o strsep.o snprintf.o usleep.o isfdtype.o \ + vsyslog.o getenv.o LIBLIB_LTOBJS = alloca.lo getopt.lo getopt1.lo strndup.lo \ - strdup.lo strsep.lo snprintf.lo usleep.lo + strdup.lo strsep.lo snprintf.lo usleep.lo isfdtype.lo \ + vsyslog.lo getenv.lo TARGETS = $(LIBLIB_OBJS) TARGETS = liblib.a diff --git a/lib/alloca.c b/lib/alloca.c index 16f7e86..b7424cd 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -22,7 +22,7 @@ your main control loop, etc. to force garbage collection. */ #ifdef HAVE_CONFIG_H -#include +#include <../include/sane/config.h> #endif #ifndef HAVE_ALLOCA diff --git a/lib/getenv.c b/lib/getenv.c new file mode 100644 index 0000000..c450659 --- /dev/null +++ b/lib/getenv.c @@ -0,0 +1,18 @@ +#include "../include/sane/config.h" + +#ifndef HAVE_GETENV + +char * +getenv(const char *name) +{ + char *retval = 0; +#ifdef HAVE_OS2_H + if (0 != DosScanEnv (buf, &retval)) + retval = 0; +#else +# error "Missing getenv() on this platform. Please implement." +#endif + return retval; +} + +#endif /* !HAVE_GETENV */ diff --git a/lib/getopt.c b/lib/getopt.c index 91f00b5..8b42321 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -27,7 +27,7 @@ #endif #ifdef HAVE_CONFIG_H -#include +#include <../include/sane/config.h> #endif #if !defined (__STDC__) || !__STDC__ diff --git a/lib/getopt1.c b/lib/getopt1.c index 7cf0bfb..140ea10 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -17,7 +17,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H -#include +#include <../include/sane/config.h> #endif #include "getopt.h" diff --git a/lib/isfdtype.c b/lib/isfdtype.c new file mode 100644 index 0000000..8e51516 --- /dev/null +++ b/lib/isfdtype.c @@ -0,0 +1,25 @@ +#include "../include/sane/config.h" + +#ifndef HAVE_ISFDTYPE + +#include + +int +isfdtype(int fd, int fdtype) +{ + struct stat st; + + if (fstat(fd, &st) == -1) return 0; /* couldn't stat fd */ + + if (st.st_mode == 0) + return 1; /* At least Irix doesn't seem to know socket type */ +#if defined(S_ISSOCK) + return S_ISSOCK(st.st_mode) != 0; +#elif defined(S_IFSOCK) && defined(S_IFMT) + return (st.st_mode & S_IFMT) == S_IFSOCK; +#else + return 0; +#endif +} + +#endif /* !HAVE_ISFDTYPE */ diff --git a/lib/snprintf.c b/lib/snprintf.c index 059d48c..cbe846d 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -1,4 +1,4 @@ -#include +#include <../include/sane/config.h> #ifndef HAVE_SNPRINTF diff --git a/lib/strdup.c b/lib/strdup.c index 62f2976..1286b8e 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -16,7 +16,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include <../include/sane/config.h> #include #include diff --git a/lib/strndup.c b/lib/strndup.c index b02355e..35c0597 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -16,7 +16,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include <../include/sane/config.h> #ifndef HAVE_STRNDUP diff --git a/lib/strsep.c b/lib/strsep.c index c3e05e3..5ac58ae 100644 --- a/lib/strsep.c +++ b/lib/strsep.c @@ -16,7 +16,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include <../include/sane/config.h> #include diff --git a/lib/usleep.c b/lib/usleep.c index 4f63df4..60dfdbc 100644 --- a/lib/usleep.c +++ b/lib/usleep.c @@ -16,7 +16,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include <../include/sane/config.h> #ifndef HAVE_USLEEP diff --git a/lib/vsyslog.c b/lib/vsyslog.c new file mode 100644 index 0000000..ce86301 --- /dev/null +++ b/lib/vsyslog.c @@ -0,0 +1,17 @@ +#include "../include/sane/config.h" + +#include "stdio.h" +#include +#include + +#ifndef HAVE_VSYSLOG + +void +vsyslog(int priority, const char *format, va_list args) +{ + char buf[1024]; + vsnprintf(buf, sizeof(buf), format, args); + syslog(priority, "%s", buf); +} + +#endif /* !HAVE_VSYSLOG */