diff options
Diffstat (limited to 'pc')
-rw-r--r-- | pc/ChangeLog | 14 | ||||
-rw-r--r-- | pc/config.h | 28 | ||||
-rw-r--r-- | pc/gawkmisc.pc | 25 |
3 files changed, 56 insertions, 11 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog index 62290d7e..2268234b 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,17 @@ +2012-08-08 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_isreadable): Take IOBUF_PUBLIC instead of fd and + use passed in info. + +2012-07-29 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_isreadable): Add isdir pointer parameter to be + set to true if fd is for a directory. + +2012-07-26 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_isreadable): New function. + 2012-05-14 Arnold D. Robbins <arnold@skeeve.com> * Makefile: Remove second mingw32-readline target. Bad diff --git a/pc/config.h b/pc/config.h index 8b39a640..50cd750e 100644 --- a/pc/config.h +++ b/pc/config.h @@ -170,7 +170,7 @@ #undef HAVE_MEMSET_ULONG /* Define to 1 if you have the `mkstemp' function. */ -#ifdef DJGPP +#ifdef __DJGPP__ #define HAVE_MKSTEMP 1 #endif @@ -213,6 +213,9 @@ /* Define to 1 if you have the <stdarg.h> header file. */ #define HAVE_STDARG_H 1 +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + /* Define to 1 if you have the <stddef.h> header file. */ #ifdef __GNUC__ #define HAVE_STDDEF_H 1 @@ -301,7 +304,7 @@ #endif /* Define to 1 if you have the <sys/time.h> header file. */ -#if defined(DJGPP) || defined(__MINGW32__) +#if defined(__DJGPP__) || defined(__MINGW32__) #define HAVE_SYS_TIME_H 1 #endif @@ -339,15 +342,15 @@ #define HAVE_TZSET 1 /* Define to 1 if the system has the type `uintmax_t'. */ -#if defined(DJGPP) || defined(__MINGW32__) +#if defined(__DJGPP__) || defined(__MINGW32__) #define HAVE_UINTMAX_T 1 -#ifdef DJGPP +#ifdef __DJGPP__ #define uintmax_t unsigned long long #endif #endif /* Define to 1 if you have the <unistd.h> header file. */ -#if defined(DJGPP) || defined(__MINGW32__) +#if defined(__DJGPP__) || defined(__MINGW32__) #define HAVE_UNISTD_H 1 #endif @@ -355,7 +358,7 @@ #undef HAVE_UNSIGNED_LONG_LONG_INT /* Define to 1 if you have the `usleep' function. */ -#if defined(DJGPP) || defined(__MINGW32__) +#if defined(__DJGPP__) || defined(__MINGW32__) #define HAVE_USLEEP 1 #endif @@ -397,6 +400,9 @@ #define HAVE_WINT_T 1 #endif +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + /* disable lint checks */ #undef NO_LINT @@ -427,7 +433,7 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void -#if defined(DJGPP) || defined(__MINGW32__) +#if defined(__DJGPP__) || defined(__MINGW32__) #include <limits.h> #endif @@ -538,7 +544,7 @@ /* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do not define. */ -#ifdef DJGPP +#ifdef __DJGPP__ #define intmax_t long long #endif @@ -548,7 +554,7 @@ /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ -#ifdef DJGPP +#ifdef __DJGPP__ #define restrict #endif /* Work around a bug in Sun C++: it does not support _Restrict or @@ -575,7 +581,7 @@ /* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h> do not define. */ -#ifdef DJGPP +#ifdef __DJGPP__ #define uintmax_t unsigned long long #endif @@ -587,7 +593,7 @@ # define DEFPATH ".;c:/lib/awk;c:/gnu/lib/awk" #endif -#ifndef DJGPP +#ifndef __DJGPP__ #define HAVE_POPEN_H 1 #endif diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index b368e81f..e2f114e4 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -232,6 +232,31 @@ int fd; return (fstat(fd, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)); } +/* os_isreadable --- fd can be read from */ + +int +os_isreadable(const IOBUF_PUBLIC *iobuf, bool *isdir) +{ + *isdir = false; + + switch (iobuf->sbuf.st_mode & S_IFMT) { + case S_IFREG: + case S_IFCHR: /* ttys, /dev/null, .. */ +#ifdef S_IFSOCK + case S_IFSOCK: +#endif +#ifdef S_IFIFO + case S_IFIFO: +#endif + return true; + case S_IFDIR: + *isdir = true; + /* fall through */ + default: + return false; + } +} + /* os_is_setuid --- true if running setuid root */ int |