AC_CHECK_HEADERS(security/pam_modules.h ucontext.h regex.h sys/statvfs.h sys/statfs.h sys/bitypes.h)
AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h errno.h time.h syslog.h)
AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>])
-AC_CHECK_HEADERS(et/com_err.h)
+AC_CHECK_HEADERS(et/com_err.h stdio_ext.h)
AC_CHECK_TYPES([fsblkcnt_t],,,[
#include <sys/types.h>
struct volumeHeader *);
extern int FindVolTrailer2(char *, afs_int32, afs_int32 *, char *, afs_int32,
afs_int32 *, struct volumeHeader *);
-extern int GetResponseKey(int, char *);
-
/* recoverDb.c */
extern afs_int32 Ask(char *);
start = time(0);
while (1) {
-#ifdef AFS_PTHREAD_ENV
- code = GetResponseKey(5, &ch); /* ch stores key pressed */
-#else
code = LWP_GetResponseKey(5, &ch); /* ch stores key pressed */
-#endif
if (code == 1)
break; /* input is available */
#define BELLTIME 60 /* 60 seconds before a bell rings */
#define BELLCHAR 7 /* ascii for bell */
-
-#ifdef AFS_PTHREAD_ENV
-#ifdef AFS_NT40_ENV
-/* WaitForKeystroke : Wait until a key has been struck or time (secconds)
- * runs out and return to caller. The NT version of this function will return
- * immediately after a key has been pressed (doesn't wait for cr).
- * Input:
- * seconds: wait for <seconds> seconds before returning. If seconds < 0,
- * wait infinitely.
- * Return Value:
- * 1: Keyboard input available
- * 0: seconds elapsed. Timeout.
- *
- * STOLEN FROM LWP_WaitForKeystroke()
- */
-int
-WaitForKeystroke(int seconds)
-{
- time_t startTime, nowTime;
- double timeleft = 1;
- struct timeval twait;
-
- time(&startTime);
- twait.tv_sec = 0;
- twait.tv_usec = 250;
- if (seconds >= 0)
- timeleft = seconds;
-
- do {
- /* check if we have a keystroke */
- if (_kbhit())
- return 1;
- if (timeleft == 0)
- break;
-
- /* sleep for LWP_KEYSTROKE_DELAY ms and let other
- * process run some*/
- select(0, 0, 0, 0, &twait);
-
- if (seconds > 0) { /* we only worry about elapsed time if
- * not looping forever (seconds < 0) */
- time(&nowTime);
- timeleft = seconds - difftime(nowTime, startTime);
- }
- } while (timeleft > 0);
- return 0;
-}
-#else /* AFS_NT40)ENV */
-extern int WaitForKeystroke(int);
-/*
- * STOLEN FROM LWP_WaitForKeystroke()
- */
-int
-WaitForKeystroke(int seconds)
-{
- fd_set rdfds;
- int code;
- struct timeval twait;
- struct timeval *tp = NULL;
-
-#ifdef AFS_LINUX20_ENV
- if (stdin->_IO_read_ptr < stdin->_IO_read_end)
- return 1;
-#else
- if (stdin->_cnt > 0)
- return 1;
-#endif
- FD_ZERO(&rdfds);
- FD_SET(fileno(stdin), &rdfds);
-
- if (seconds >= 0) {
- twait.tv_sec = seconds;
- twait.tv_usec = 0;
- tp = &twait;
- }
- code = select(1 + fileno(stdin), &rdfds, NULL, NULL, tp);
- return (code == 1) ? 1 : 0;
-}
-#endif
-
-/* GetResponseKey() - Waits for a specified period of time and
- * returns a char when one has been typed by the user.
- * Input:
- * seconds - how long to wait for a key press.
- * *key - char entered by user
- * Return Values:
- * 0 - Time ran out before the user typed a key.
- * 1 - Valid char is being returned.
- *
- * STOLEN FROM LWP_GetResponseKey();
- */
-int
-GetResponseKey(int seconds, char *key)
-{
- int rc;
-
- if (key == NULL)
- return 0; /* need space to store char */
- fflush(stdin); /* flush all existing data and start anew */
-
- rc = WaitForKeystroke(seconds);
- if (rc == 0) { /* time ran out */
- *key = 0;
- return rc;
- }
-
- /* now read the char. */
-#ifdef AFS_NT40_ENV
- *key = getche(); /* get char and echo it to screen */
-#else
- *key = getchar();
-#endif
- return rc;
-}
-#endif /* AFS_PTHREAD_ENV */
-
/*
* FFlushInput
* flush all input
fflush(stdin);
while (1) {
-#ifdef AFS_PTHREAD_ENV
- w = WaitForKeystroke(0);
-#else
w = LWP_WaitForKeystroke(0);
-#endif /* AFS_PTHREAD_ENV */
-
if (w) {
#ifdef AFS_NT40_ENV
getche();
putchar(BELLCHAR);
fflush(stdout);
}
-#ifdef AFS_PTHREAD_ENV
- wcode = GetResponseKey(5, &inchr); /* inchr stores key read */
-#else
wcode = LWP_GetResponseKey(5, &inchr); /* inchr stores key read */
-#endif
if (wcode == 1) { /* keyboard input is available */
if ((inchr == 'a') || (inchr == 'A')) {
extern void IOMGR_FreeFDSet(fd_set * fds);
extern int IOMGR_SoftSig(void *(*aproc) (void *), void *arock);
-extern int LWP_WaitForKeystroke(int seconds); /* -1 => forever */
-extern int LWP_GetResponseKey(int seconds, char *key);
-extern int LWP_GetLine(char *linebuf, int len);
#ifdef AFS_NT40_ENV
/* lwp.c */
extern int LWP_InitializeProcessSupport(int priority, PROCESS * pid);
/* max time we spend on a select in a Win95 DOS box */
#define IOMGR_WIN95WAITTIME 5000 /* microseconds */
-#endif
-#endif /* __LWP_INCLUDE_ */
+#endif /* !AFS_PTHREAD_ENV */
+
+extern int LWP_WaitForKeystroke(int seconds); /* -1 => forever */
+extern int LWP_GetResponseKey(int seconds, char *key);
+extern int LWP_GetLine(char *linebuf, int len);
#endif /* !KERNEL && !_KMEMUSER */
+#endif /* __LWP_INCLUDE_ */
selsubs.o: selsubs.c seltest.h
test_key: test_key.o
- $(AFS_LDRULE) test_key.o ../liblwp.a $(DESTDIR)/lib/afs/util.a
+ $(AFS_LDRULE) test_key.o ${LIBS} ${TOP_LIBDIR}/util.a
clean:
- -$(RM) -f *.o *.a test testlwp selclient selserver core
+ -$(RM) -f *.o *.a test test_key selclient selserver core
!INCLUDE ..\..\config\NTMakefile.version
LIBS = $(DESTDIR)\lib\afslwp.lib \
- $(DESTDIR)lib\afs\afsutil.lib
+ $(DESTDIR)\lib\afs\afsutil.lib
# build testkey.exe
#include <stdio.h>
+#ifdef HAVE_STDIO_EXT_H
+#include <stdio_ext.h>
+#endif
#include <sys/types.h>
#ifdef AFS_NT40_ENV
#include <time.h>
/* sleep for LWP_KEYSTROKE_DELAY ms and let other
* process run some*/
+#ifdef AFS_PTHREAD_ENV
+ select(0, 0, 0, 0, &twait);
+#else
IOMGR_Select(0, 0, 0, 0, &twait);
+#endif
if (seconds > 0) { /* we only worry about elapsed time if
* not looping forever (seconds < 0) */
struct timeval twait;
struct timeval *tp = NULL;
-#ifdef AFS_LINUX20_ENV
+#if defined(HAVE_STDIO_EXT_H)
+ if (__fbufsize(stdin) > 0)
+ return 1;
+#elif defined(AFS_LINUX20_ENV)
if (stdin->_IO_read_ptr < stdin->_IO_read_end)
return 1;
-#else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-#if defined(AFS_DFBSD_ENV)
+#elif (defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)) && defined(AFS_DFBSD_ENV)
struct appx_sbuf {
unsigned char *_base;
int _size;
struct APPX_FILE *appx_stdin = (struct APPX_FILE *) stdin;
if (appx_stdin->_bf._size > 0)
return 1;
-#else
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
if (stdin->_bf._size > 0)
return 1;
-#endif
#else
if (stdin->_cnt > 0)
return 1;
#endif
-#endif
FD_ZERO(&rdfds);
FD_SET(fileno(stdin), &rdfds);
tp = &twait;
}
+#ifdef AFS_PTHREAD_ENV
+ code = select(1 + fileno(stdin), &rdfds, NULL, NULL, tp);
+#else
code = IOMGR_Select(1 + fileno(stdin), &rdfds, NULL, NULL, tp);
+#endif
return (code == 1) ? 1 : 0;
}
VOLSEROBJS=vsprocs.o vsutils.o lockprocs.o
VOLSERLIBS=${TOP_LIBDIR}/libvosadmin.a ${TOP_LIBDIR}/libafsadminutil.a
-LWPOBJS =lock.o
+LWPOBJS =lock.o waitkey.o
BUTCOBJS =dbentries.o tcprocs.o lwps.o tcmain.o list.o recoverDb.o \
tcudbprocs.o dump.o tcstatus.o butc_xbsa.o afsxbsa.o \
lock.o: ${LWP}/lock.c
$(AFS_CCRULE) ${LWP}/lock.c
+waitkey.o: ${LWP}/waitkey.c
+ $(AFS_CCRULE) ${LWP}/waitkey.c
+
file_tm.o: ${BUTM}/file_tm.c ${BUTMINCLS}
$(AFS_CCRULE) ${BUTM}/file_tm.c
$(OUT)\$(BUCOORD)\status.obj \
$(OUT)\$(BUCOORD)\bucoord_errs.obj
-LWPOBJS = $(OUT)\lock.obj
+LWPOBJS = $(OUT)\lock.obj $(OUT)\waitkey.obj
BUTMOBJS = $(OUT)\file_tm.obj \
$(OUT)\AFS_component_version_number.obj
$(OUT)\lock.obj: $(LWP)/lock.c
$(C2OBJ) $**
+$(OUT)\waitkey.obj: $(LWP)/waitkey.c
+ $(C2OBJ) $**
+
#----------------------------------------------- BUTC
$(OUT)\file_tm.obj: $(BUTM)/file_tm.c