diff -uNr queue-1.10/ChangeLog queue-1.11/ChangeLog --- queue-1.10/ChangeLog Wed Jan 13 11:15:45 1999 +++ queue-1.11/ChangeLog Fri Jan 22 13:15:41 1999 @@ -1,3 +1,64 @@ +*January 22, 1999 Werner G. Krebs + + Version 1.11 Jan 1999 + + Modified apparent load average to compute expected load average + AFTER job starts. New formula is: + + load = (avg[0] + 1.0)/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); + + Old formula was: + + load = avg[0]/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); + + We can think of the effective load average as being the inverse of + the computing power of the loaded machine AFTER the next CPU + guzzling job starts, i.e., 1/ (MIPS/(jobs)), where jobs = load + 1. + The old formula computed 1/(MIPS/(jobs - 1)). In an unloaded + cluster (load == 0), pfactor (MIPS) would not be taken into + consideration. The new formula remedies this, sending the + job to the fastest machine (highest pfactor) if all machines + are unloaded. + + Added sigsetmask.c as REPLACE_FUNC for SunOS. + Added defines to queue.h and changes to configure.in for SunOS. + Merged getopt.c and getopt1.c and renamed getopt_long.c, added + to configure.in as REPLACE_FUNC so they won't get compiled in + when not needed. -lbsd should no longer be necessary for SunOS + (although it is still in configure.in). + + Replaced _cleanup() with fflush(NULL) as suggested by + Nick Burrett . + + Fixed the NO_ROOT hack on non-GNU/Linux machines (really + on machines without /proc; have to detect this in ./configure + someday....) that calls uptime and scanfs the load-averages in. + +*Mon Jan 18 16:27:31 1999 Nick Burrett + + * queued.c (waitforchild): Change wait status union type to int. + Cast status to void* for calls to `wait3'. + +*January 14, 1999 Werner G. Krebs + + Version 1.10 patchlevel 3 Jan 1999 + + Added rlimits for Alpha platform. + + +*January 14, 1999 Werner G. Krebs + + Version 1.10 patchelevel 2 Jan 1999 + + Missing strdup in queued.c code caused hostname weirdness on + the Digital Alpha platform. + +*January 13, 1999 Werner G. Krebs + + Version 1.10 patchlevel 1 Jan 1999 + + Misplaced bracket in qlib was causing a malloc error on some systems. + *January 13, 1999 Werner G. Krebs Version 1.10 Jan 1999 diff -uNr queue-1.10/MANIFEST queue-1.11/MANIFEST --- queue-1.10/MANIFEST Sat Dec 26 22:48:25 1998 +++ queue-1.11/MANIFEST Fri Jan 22 13:14:09 1999 @@ -1,54 +1,56 @@ -total 533 --rw-r--r-- 1 wkrebs wkrebs 835 Dec 25 12:25 ACKNOWLEDGEMENTS --rw-r--r-- 1 wkrebs wkrebs 237 Dec 13 22:01 AUTHORS --rw-r--r-- 1 wkrebs wkrebs 17982 Nov 26 19:08 COPYING --rw-r--r-- 1 wkrebs wkrebs 7298 Dec 25 12:33 ChangeLog --rw-r--r-- 1 wkrebs wkrebs 11696 Dec 26 22:44 INSTALL --rw-r--r-- 1 wkrebs wkrebs 3246 Dec 26 22:48 MANIFEST --rw-r--r-- 1 wkrebs wkrebs 1591 Dec 26 22:34 Makefile.am --rw-r--r-- 1 wkrebs wkrebs 12905 Dec 26 22:34 Makefile.in --rw-r--r-- 1 wkrebs wkrebs 3235 Dec 26 22:37 NEWS --rw-r--r-- 1 wkrebs wkrebs 4301 Dec 26 22:40 README --rw-r--r-- 1 wkrebs wkrebs 1021 Dec 18 20:51 TODO --rw-r--r-- 1 wkrebs wkrebs 1742 Dec 25 12:03 acconfig.h --rw-r--r-- 1 wkrebs wkrebs 3675 Dec 26 22:34 aclocal.m4 --rw-rw-r-- 1 wkrebs wkrebs 7870 Dec 25 12:10 config.h.in --rwxr-xr-x 1 wkrebs wkrebs 93517 Dec 26 22:34 configure --rw-r--r-- 1 wkrebs wkrebs 4728 Dec 25 12:06 configure.in --rw-r--r-- 1 wkrebs wkrebs 2652 Dec 23 21:29 define.h -drwxr-xr-x 2 wkrebs wkrebs 1024 Dec 26 22:47 doc --rw-r--r-- 1 wkrebs wkrebs 18001 Dec 23 21:51 getopt.c --r--r--r-- 1 wkrebs wkrebs 4485 Dec 23 21:29 getopt.h --rw-r--r-- 1 wkrebs wkrebs 30414 Dec 25 12:09 handle.c --rw-r--r-- 1 wkrebs wkrebs 2994 Dec 25 12:06 ident.c --rwxr-xr-x 1 wkrebs wkrebs 5584 Nov 26 19:08 install-sh --rw-r--r-- 1 wkrebs wkrebs 13983 Dec 26 22:38 lex.c --rw-r--r-- 1 wkrebs wkrebs 398 Nov 26 19:08 lex.h --rw-r--r-- 1 wkrebs wkrebs 1626 Nov 26 19:08 lex.l --rwxr-xr-x 1 wkrebs wkrebs 4650 Nov 26 19:08 missing --rwxr-xr-x 1 wkrebs wkrebs 733 Nov 26 19:08 mkinstalldirs --rw-r--r-- 1 wkrebs wkrebs 3450 Dec 23 22:57 profile.in --rw-r--r-- 1 wkrebs wkrebs 3559 Nov 26 19:08 pty.c --rw-r--r-- 1 wkrebs wkrebs 1834 Nov 26 19:08 putenv.c --rw-r--r-- 1 wkrebs wkrebs 4995 Dec 24 19:05 qlib.c --rwxrwxr-x 1 wkrebs wkrebs 85826 Dec 24 19:18 qsh --rw-r--r-- 1 wkrebs wkrebs 39830 Dec 25 22:41 queue.c --rw-r--r-- 1 wkrebs wkrebs 4233 Dec 23 12:33 queue.h --rw-r--r-- 1 wkrebs wkrebs 102696 Dec 25 12:01 queued.c --rw-r--r-- 1 wkrebs wkrebs 4666 Nov 26 19:08 setenv.c --rw-r--r-- 1 wkrebs wkrebs 0 Dec 26 22:38 stamp-h.in --rw-rw-r-- 1 wkrebs wkrebs 143 Dec 20 15:28 strdup.c --rw-r--r-- 1 wkrebs wkrebs 4345 Dec 20 12:15 wakeup.c +total 784 +-rw-r--r-- 1 wkrebs gerstein 835 Jan 14 11:14 ACKNOWLEDGEMENTS +-rw-r--r-- 1 wkrebs gerstein 237 Jan 14 11:14 AUTHORS +-rw-r--r-- 1 wkrebs gerstein 17982 Jan 14 11:14 COPYING +-rw-r--r-- 1 wkrebs gerstein 12007 Jan 19 17:54 ChangeLog +-rw-r--r-- 1 wkrebs gerstein 11697 Jan 14 11:14 INSTALL +-rw-r--r-- 1 wkrebs gerstein 3409 Jan 22 13:14 MANIFEST +-rw-r--r-- 1 wkrebs gerstein 2563 Jan 19 14:05 Makefile.am +-rw-r--r-- 1 wkrebs gerstein 13343 Jan 22 13:13 Makefile.in +-rw-r--r-- 1 wkrebs gerstein 7172 Jan 22 13:13 NEWS +-rw-r--r-- 1 wkrebs gerstein 4301 Jan 14 11:14 README +-rw-r--r-- 1 wkrebs gerstein 1021 Jan 14 11:14 TODO +-rw-r--r-- 1 wkrebs gerstein 1763 Jan 14 11:14 acconfig.h +-rw-r--r-- 1 wkrebs gerstein 2621 Jan 22 13:13 aclocal.m4 +-rw-r--r-- 1 wkrebs gerstein 8112 Jan 19 16:33 config.h.in +-rwxr-xr-x 1 wkrebs gerstein 94845 Jan 22 13:13 configure* +-rw-r--r-- 1 wkrebs gerstein 4952 Jan 22 13:12 configure.in +-rw-r--r-- 1 wkrebs gerstein 2816 Jan 22 13:12 define.h +drwxr-xr-x 2 wkrebs gerstein 4096 Jan 14 11:14 doc/ +-rw-r--r-- 1 wkrebs gerstein 22547 Jan 19 13:59 getopt_long.c +-r--r--r-- 1 wkrebs gerstein 4485 Jan 14 11:14 getopt_long.h +-rw-r--r-- 1 wkrebs gerstein 30484 Jan 19 16:20 handle.c +-rw-r--r-- 1 wkrebs gerstein 2994 Jan 14 11:14 ident.c +-rwxr-xr-x 1 wkrebs gerstein 5584 Jan 14 11:14 install-sh* +-rw-r--r-- 1 wkrebs gerstein 11534 Jan 14 13:32 lex.c +-rw-r--r-- 1 wkrebs gerstein 430 Jan 14 13:43 lex.h +-rw-r--r-- 1 wkrebs gerstein 1760 Jan 14 13:30 lex.l +-rwxr-xr-x 1 wkrebs gerstein 4650 Jan 14 11:14 missing* +-rwxr-xr-x 1 wkrebs gerstein 733 Jan 14 11:14 mkinstalldirs* +-rw-r--r-- 1 wkrebs gerstein 3450 Jan 14 11:14 profile.in +-rw-r--r-- 1 wkrebs gerstein 3559 Jan 14 11:14 pty.c +-rw-r--r-- 1 wkrebs gerstein 1834 Jan 14 11:14 putenv.c +-rw-r--r-- 1 wkrebs gerstein 5158 Jan 19 14:21 qlib.c +-rw-r--r-- 1 wkrebs gerstein 39964 Jan 22 13:11 queue.c +-rw-r--r-- 1 wkrebs gerstein 4692 Jan 19 17:29 queue.h +-rw-r--r-- 1 wkrebs gerstein 104792 Jan 22 13:11 queued.c +-rw-r--r-- 1 wkrebs gerstein 4666 Jan 14 11:14 setenv.c +-rw-r--r-- 1 wkrebs gerstein 2077 Jan 19 17:52 sigsetmask.c +-rw-r--r-- 1 wkrebs gerstein 0 Jan 22 13:14 stamp-h.in +-rw-r--r-- 1 wkrebs gerstein 143 Jan 14 11:14 strdup.c +-rw-r--r-- 1 wkrebs gerstein 4345 Jan 14 11:14 wakeup.c doc: -total 858 --rw-r--r-- 1 wkrebs wkrebs 19 Dec 18 23:47 QueueVN.texi --rw-r--r-- 1 wkrebs wkrebs 18360 Dec 18 23:40 gpl.texinfo --rw-rw-r-- 1 wkrebs wkrebs 16053 Dec 25 22:32 queue.1 --rw-rw-r-- 1 wkrebs wkrebs 110660 Dec 26 22:47 queue.dvi --rw-rw-r-- 1 wkrebs wkrebs 68507 Dec 26 21:34 queue.html --rw-rw-r-- 1 wkrebs wkrebs 63324 Dec 26 21:34 queue.info --rw-rw-r-- 1 wkrebs wkrebs 16053 Dec 25 22:32 queue.man --rw-rw-r-- 1 wkrebs wkrebs 525535 Dec 26 22:47 queue.ps --rw-r--r-- 1 wkrebs wkrebs 43053 Dec 26 21:34 queue.texinfo --rw-rw-r-- 1 wkrebs wkrebs 1984 Dec 26 21:34 queue_toc.html +total 884 +-rw-r--r-- 1 wkrebs gerstein 18 Jan 14 11:14 QueueVN.texi +-rw-r--r-- 1 wkrebs gerstein 23 Jan 14 11:14 QueueVN.texi.in +-rw-r--r-- 1 wkrebs gerstein 18360 Jan 14 11:14 gpl.texinfo +-rw-r--r-- 1 wkrebs gerstein 16074 Jan 14 11:14 queue.1 +-rw-r--r-- 1 wkrebs gerstein 111128 Jan 14 11:14 queue.dvi +-rw-r--r-- 1 wkrebs gerstein 67245 Jan 14 11:14 queue.html +-rw-r--r-- 1 wkrebs gerstein 63524 Jan 14 11:14 queue.info +-rw-r--r-- 1 wkrebs gerstein 16074 Jan 14 11:14 queue.man +-rw-r--r-- 1 wkrebs gerstein 16081 Jan 14 11:14 queue.man.in +-rw-r--r-- 1 wkrebs gerstein 525844 Jan 14 11:14 queue.ps +-rw-r--r-- 1 wkrebs gerstein 43290 Jan 14 11:14 queue.texinfo +-rw-r--r-- 1 wkrebs gerstein 1981 Jan 14 11:14 queue_toc.html diff -uNr queue-1.10/Makefile.am queue-1.11/Makefile.am --- queue-1.10/Makefile.am Tue Jan 12 18:21:13 1999 +++ queue-1.11/Makefile.am Tue Jan 19 14:05:39 1999 @@ -5,9 +5,9 @@ sbin_PROGRAMS = queued bin_PROGRAMS = queue -queued_SOURCES = queued.c lex.l handle.c ident.c pty.c qlib.c getopt.c getopt1.c +queued_SOURCES = queued.c lex.l handle.c ident.c pty.c qlib.c queued_LDADD = @LEXLIB@ @LIBOBJS@ -queue_SOURCES = queue.c wakeup.c ident.c qlib.c getopt.c getopt1.c +queue_SOURCES = queue.c wakeup.c ident.c qlib.c queue_LDADD = @LIBOBJS@ install-exec-local: install-local-stuff diff -uNr queue-1.10/Makefile.in queue-1.11/Makefile.in --- queue-1.10/Makefile.in Wed Jan 13 11:17:25 1999 +++ queue-1.11/Makefile.in Fri Jan 22 13:18:34 1999 @@ -65,9 +65,9 @@ sbin_PROGRAMS = queued bin_PROGRAMS = queue -queued_SOURCES = queued.c lex.l handle.c ident.c pty.c qlib.c getopt.c getopt1.c +queued_SOURCES = queued.c lex.l handle.c ident.c pty.c qlib.c queued_LDADD = @LEXLIB@ @LIBOBJS@ -queue_SOURCES = queue.c wakeup.c ident.c qlib.c getopt.c getopt1.c +queue_SOURCES = queue.c wakeup.c ident.c qlib.c queue_LDADD = @LIBOBJS@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -80,11 +80,10 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -queue_OBJECTS = queue.o wakeup.o ident.o qlib.o getopt.o getopt1.o +queue_OBJECTS = queue.o wakeup.o ident.o qlib.o queue_DEPENDENCIES = @LIBOBJS@ queue_LDFLAGS = -queued_OBJECTS = queued.o lex.o handle.o ident.o pty.o qlib.o getopt.o \ -getopt1.o +queued_OBJECTS = queued.o lex.o handle.o ident.o pty.o qlib.o queued_DEPENDENCIES = @LIBOBJS@ queued_LDFLAGS = LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ @@ -94,17 +93,18 @@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ Makefile.in NEWS TODO acconfig.h aclocal.m4 config.h.in configure \ -configure.in install-sh lex.c missing mkinstalldirs profile.in putenv.c \ -setenv.c stamp-h.in strdup.c +configure.in getopt_long.c install-sh lex.c missing mkinstalldirs \ +profile.in putenv.c setenv.c sigsetmask.c stamp-h.in strdup.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP = --best -DEP_FILES = .deps/getopt.P .deps/getopt1.P .deps/handle.P .deps/ident.P \ +DEP_FILES = .deps/getopt_long.P .deps/handle.P .deps/ident.P \ .deps/lex.P .deps/pty.P .deps/putenv.P .deps/qlib.P .deps/queue.P \ -.deps/queued.P .deps/setenv.P .deps/strdup.P .deps/wakeup.P +.deps/queued.P .deps/setenv.P .deps/sigsetmask.P .deps/strdup.P \ +.deps/wakeup.P SOURCES = $(queue_SOURCES) $(queued_SOURCES) OBJECTS = $(queue_OBJECTS) $(queued_OBJECTS) diff -uNr queue-1.10/NEWS queue-1.11/NEWS --- queue-1.10/NEWS Wed Jan 13 11:11:38 1999 +++ queue-1.11/NEWS Fri Jan 22 13:13:18 1999 @@ -1,9 +1,73 @@ +*January 19, 1999 Werner G. Krebs + + Version 1.10 patchlevel 4 Jan 1999 + + Modified apparent load average to compute expected load average + AFTER job starts. New formula is: + + load = (avg[0] + 1.0)/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); + + Old formula was: + + load = avg[0]/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); + + We can think of the effective load average as being the inverse of + the computing power of the loaded machine AFTER the next CPU + guzzling job starts, i.e., 1/ (MIPS/(jobs)), where jobs = load + 1. + The old formula computed 1/(MIPS/(jobs - 1)). In an unloaded + cluster (load == 0), pfactor (MIPS) would not be taken into + consideration. The new formula remedies this, sending the + job to the fastest machine (highest pfactor) if all machines + are unloaded. + + Added sigsetmask.c as REPLACE_FUNC for SunOS. + Added defines to queue.h and changes to configure.in for SunOS. + Merged getopt.c and getopt1.c and renamed getopt_long.c, added + to configure.in as REPLACE_FUNC so they won't get compiled in + when not needed. -lbsd should no longer be necessary for SunOS + (although it is still in configure.in). + + Replaced _cleanup() with fflush(NULL) as suggested by + Nick Burrett . + + Fixed the NO_ROOT hack on non-GNU/Linux machines (really + on machines without /proc; have to detect this in ./configure + someday....) that calls uptime and scanfs the load-averages in. + +*Mon Jan 18 16:27:31 1999 Nick Burrett + + * queued.c (waitforchild): Change wait status union type to int. + Cast status to void* for calls to `wait3'. + +*January 14, 1999 Werner G. Krebs + + Version 1.10 patchlevel 3 Jan 1999 + + Added rlimits for Alpha platform. + + +*January 14, 1999 Werner G. Krebs + + Version 1.10 patchelevel 2 Jan 1999 + + Missing strdup in queued.c code caused hostname weirdness on + the Digital Alpha platform. + +*January 13, 1999 Werner G. Krebs + + Version 1.10 patchlevel 1 Jan 1999 + + Misplaced bracket in qlib was causing a malloc error on some systems. + *January 13, 1999 Werner G. Krebs Version 1.10 Jan 1999 - Primarily, compilation patches for Digital Alpha Unix OSF/1. - + Primarily, compilation and Makefile + patches for Digital Alpha Unix OSF/1; thanks + to Piergiorgio Alotto for providing an + account on his Alpha for the port. + Added missing getopt1.c code that would have prevented compilated on platforms missing getopt_long in their libc. @@ -27,10 +91,8 @@ Version 1.099p2 - Makefile bugfix (didn't add name of local machine to qhostsfile correctly; also problem with install-info. Bug fix courtesy of Carlo Strozzi.) - Fix to queued.c to send output of batched jobs properly. Bug spotted - by Carlo Strozzi. + by Carlo Strozzi . Fix to queued.c to allow sendmail to work with NO_ROOT (paranoid sendmails ignored outgoing mail with NO_ROOT.) @@ -39,6 +101,12 @@ Fix to queue.c to allow crypt() to compile properly with ONE_WAY. +*January 1, 1998 Carlo Strozzi . + + Makefile bugfix (didn't add name of local machine to qhostsfile + correctly; also problem with install-info. Bug fix courtesy of + Carlo Strozzi.) + *December 29, 1998 Werner G. Krebs Version 1.099p1 @@ -125,3 +193,5 @@ but it makes starting queued more intuitive. To restart, you just SIGTERM and run again now. (Or, invoke with full pathname and send the traditional re-start sigal.) + + diff -uNr queue-1.10/config.h.in queue-1.11/config.h.in --- queue-1.10/config.h.in Tue Jan 12 18:27:46 1999 +++ queue-1.11/config.h.in Fri Jan 22 13:18:32 1999 @@ -93,12 +93,18 @@ /* Define if you have the gethostname function. */ #undef HAVE_GETHOSTNAME +/* Define if you have the getopt_long function. */ +#undef HAVE_GETOPT_LONG + /* Define if you have the getrlimit function. */ #undef HAVE_GETRLIMIT /* Define if you have the getwd function. */ #undef HAVE_GETWD +/* Define if you have the herror function. */ +#undef HAVE_HERROR + /* Define if you have the insque function. */ #undef HAVE_INSQUE @@ -155,6 +161,9 @@ /* Define if you have the header file. */ #undef HAVE_FSTAB_H + +/* Define if you have the header file. */ +#undef HAVE_GETOPT_H /* Define if you have the header file. */ #undef HAVE_I386_VMPARAM_H diff -uNr queue-1.10/configure queue-1.11/configure --- queue-1.10/configure Wed Jan 13 11:17:24 1999 +++ queue-1.11/configure Fri Jan 22 13:18:33 1999 @@ -522,7 +522,7 @@ -VERSION="1.10" +VERSION="1.11" MANDATE="01/1999" @@ -1615,7 +1615,7 @@ fi -for ac_hdr in arpa/inet.h ctype.h dirent.h errno.h fcntl.h fstab.h i386/vmparam.h machine/param.h mntent.h ndir.h netdb.h netinet/in.h nlist.h pwd.h signal.h stdio.h stdlib.h string.h strings.h sys/audit.h sys/dir.h sys/file.h sys/fixpoint.h sys/ioctl.h sys/ndir.h sys/param.h sys/pstat.h sys/resource.h sys/signal.h sys/socket.h sys/sockio.h sys/stat.h sys/statvfs.h sys/statfs.h sys/sysmp.h sys/time.h sys/types.h sys/un.h sys/vfs.h sys/wait.h syslog.h termios.h time.h ulimit.h unistd.h ustat.h utmp.h varargs.h vfork.h limits.h sys/times.h +for ac_hdr in arpa/inet.h ctype.h dirent.h errno.h fcntl.h fstab.h i386/vmparam.h machine/param.h mntent.h ndir.h netdb.h netinet/in.h nlist.h pwd.h signal.h stdio.h stdlib.h string.h strings.h sys/audit.h sys/dir.h sys/file.h sys/fixpoint.h sys/ioctl.h sys/ndir.h sys/param.h sys/pstat.h sys/resource.h sys/signal.h sys/socket.h sys/sockio.h sys/stat.h sys/statvfs.h sys/statfs.h sys/sysmp.h sys/time.h sys/types.h sys/un.h sys/vfs.h sys/wait.h syslog.h termios.h time.h ulimit.h unistd.h ustat.h utmp.h varargs.h vfork.h limits.h sys/times.h getopt.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -2710,7 +2710,7 @@ fi -for ac_func in getcwd gethostname getwd mkdir select socket getrlimit sigblock sigsetmask setsid setlinebuf insque setresuid setresgid +for ac_func in getcwd gethostname getwd mkdir select socket getrlimit sigblock sigsetmask setsid setlinebuf insque setresuid setresgid herror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2717: checking for $ac_func" >&5 @@ -2765,7 +2765,7 @@ fi done -for ac_func in putenv setenv strdup +for ac_func in putenv setenv strdup sigsetmask getopt_long do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2772: checking for $ac_func" >&5 diff -uNr queue-1.10/configure.in queue-1.11/configure.in --- queue-1.10/configure.in Wed Jan 13 11:16:18 1999 +++ queue-1.11/configure.in Fri Jan 22 13:17:44 1999 @@ -8,7 +8,7 @@ AC_CONFIG_HEADER(config.h) dnl Global version variable -VERSION="1.10" +VERSION="1.11" MANDATE="01/1999" AC_SUBST(VERSION) AC_SUBST(MANDATE) @@ -36,7 +36,7 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h errno.h fcntl.h fstab.h i386/vmparam.h machine/param.h mntent.h ndir.h netdb.h netinet/in.h nlist.h pwd.h signal.h stdio.h stdlib.h string.h strings.h sys/audit.h sys/dir.h sys/file.h sys/fixpoint.h sys/ioctl.h sys/ndir.h sys/param.h sys/pstat.h sys/resource.h sys/signal.h sys/socket.h sys/sockio.h sys/stat.h sys/statvfs.h sys/statfs.h sys/sysmp.h sys/time.h sys/types.h sys/un.h sys/vfs.h sys/wait.h syslog.h termios.h time.h ulimit.h unistd.h ustat.h utmp.h varargs.h vfork.h limits.h sys/times.h) +AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h errno.h fcntl.h fstab.h i386/vmparam.h machine/param.h mntent.h ndir.h netdb.h netinet/in.h nlist.h pwd.h signal.h stdio.h stdlib.h string.h strings.h sys/audit.h sys/dir.h sys/file.h sys/fixpoint.h sys/ioctl.h sys/ndir.h sys/param.h sys/pstat.h sys/resource.h sys/signal.h sys/socket.h sys/sockio.h sys/stat.h sys/statvfs.h sys/statfs.h sys/sysmp.h sys/time.h sys/types.h sys/un.h sys/vfs.h sys/wait.h syslog.h termios.h time.h ulimit.h unistd.h ustat.h utmp.h varargs.h vfork.h limits.h sys/times.h getopt.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -60,8 +60,8 @@ AC_FUNC_VFORK AC_FUNC_VPRINTF AC_FUNC_WAIT3 -AC_CHECK_FUNCS(getcwd gethostname getwd mkdir select socket getrlimit sigblock sigsetmask setsid setlinebuf insque setresuid setresgid) -AC_REPLACE_FUNCS(putenv setenv strdup) +AC_CHECK_FUNCS(getcwd gethostname getwd mkdir select socket getrlimit sigblock sigsetmask setsid setlinebuf insque setresuid setresgid herror) +AC_REPLACE_FUNCS(putenv setenv strdup sigsetmask getopt_long) dnl Local check for ut_addr/ut_host -WGK AC_CACHE_CHECK(for ut_addr in utmp.h, queue_cv_header_ut_addr,AC_EGREP_HEADER(ut_addr,utmp.h,queue_cv_header_ut_addr=yup,queue_cv_header_ut_addr=nope)) diff -uNr queue-1.10/define.h queue-1.11/define.h --- queue-1.10/define.h Sat Jan 2 18:17:24 1999 +++ queue-1.11/define.h Fri Jan 22 13:12:22 1999 @@ -159,5 +159,10 @@ #ifdef HAVE_LIMITS_H #include #endif +#ifndef HAVE_GETOPT_LONG +#include "getopt_long.h" +#else +#ifdef HAVE_GETOPT_H #include "getopt.h" - +#endif +#endif diff -uNr queue-1.10/getopt.c queue-1.11/getopt.c --- queue-1.10/getopt.c Wed Dec 23 21:51:08 1998 +++ queue-1.11/getopt.c Wed Dec 31 19:00:00 1969 @@ -1,621 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, June 1992, for - Taylor UUCP. */ - - -#include "queue.h" - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#undef GETOPT_COMPAT - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = 0; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -int optind = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -static void -exchange (argv) - char **argv; -{ - size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) malloc (nonopts_size); - - if (temp == NULL) - abort (); - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &argv[first_nonopt + optind - last_nonopt], - nonopts_size); - - free (temp); - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns `EOF'. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - optarg = 0; - - /* Initialize the internal data when the first call is made. - Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - if (optind == 0) - { - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - if (nextchar == NULL || *nextchar == '\0') - { - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Now skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - optind++; - last_nonopt = optind; - } - - /* Special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return EOF; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if ((argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - if (ordering == REQUIRE_ORDER) - return EOF; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Start decoding its characters. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound = 0; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, (size_t) (s - nextchar))) - { - if (s - nextchar == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - } - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], (unsigned char) (c)); - else - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); - } - return '?'; - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = 0; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == EOF) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff -uNr queue-1.10/getopt.h queue-1.11/getopt.h --- queue-1.10/getopt.h Wed Dec 23 21:29:00 1998 +++ queue-1.11/getopt.h Wed Dec 31 19:00:00 1969 @@ -1,133 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, November 1992, - for Taylor UUCP, and again in June, 1995. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* Ian Lance Taylor added the following defines for - Taylor UUCP. This avoids reported conflicts with system getopt - definitions. */ -#define getopt gnu_getopt -#define optarg gnu_optarg -#define optind gnu_optind -#define opterr gnu_opterr - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ - const char *name; - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#ifndef P -/* On some systems, includes getopt.h before P is defined by - uucp.h, and the -I arguments cause this version of getopt.h to be - included. Work around that here. */ -#define P(x) () -#define UNDEFINE_P -#endif - -extern int getopt P((int argc, char *const *argv, const char *shortopts)); -extern int getopt_long P((int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind)); -extern int getopt_long_only P((int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind)); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal P((int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only)); - -#ifdef UNDEFINE_P -#undef P -#undef UNDEFINE_P -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff -uNr queue-1.10/getopt1.c queue-1.11/getopt1.c --- queue-1.10/getopt1.c Tue Jan 12 12:57:29 1999 +++ queue-1.11/getopt1.c Wed Dec 31 19:00:00 1969 @@ -1,187 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this program; if not, write to the Free Software - Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ -#include -#else -#include "config.h" -#endif -#endif - -#include "getopt.h" - -#ifndef __STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#else -char *getenv (); -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#endif /* _LIBC or not __GNU_LIBRARY__. */ - -#ifdef TEST - -#include - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == EOF) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff -uNr queue-1.10/getopt_long.c queue-1.11/getopt_long.c --- queue-1.10/getopt_long.c Wed Dec 31 19:00:00 1969 +++ queue-1.11/getopt_long.c Tue Jan 19 13:59:48 1999 @@ -0,0 +1,808 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + This file was modified slightly by Ian Lance Taylor, June 1992, for + Taylor UUCP. */ + + +#include "queue.h" + +/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a + long-named option. Because this is not POSIX.2 compliant, it is + being phased out. */ +#undef GETOPT_COMPAT + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt_long.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = 0; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +#define my_index strchr +#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (argv) + char **argv; +{ + size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); + char **temp = (char **) malloc (nonopts_size); + + if (temp == NULL) + abort (); + + /* Interchange the two blocks of data in ARGV. */ + + my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); + my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], + (optind - last_nonopt) * sizeof (char *)); + my_bcopy ((char *) temp, + (char *) &argv[first_nonopt + optind - last_nonopt], + nonopts_size); + + free (temp); + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int option_index; + + optarg = 0; + + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + if (optind == 0) + { + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("POSIXLY_CORRECT") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + } + + if (nextchar == NULL || *nextchar == '\0') + { + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + optind++; + last_nonopt = optind; + } + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + if (longopts != NULL + && ((argv[optind][0] == '-' + && (argv[optind][1] == '-' || long_only)) +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + )) + { + const struct option *p; + char *s = nextchar; + int exact = 0; + int ambig = 0; + const struct option *pfound = NULL; + int indfound = 0; + + while (*s && *s != '=') + s++; + + /* Test all options for either exact match or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; + p++, option_index++) + if (!strncmp (p->name, nextchar, (size_t) (s - nextchar))) + { + if (s - nextchar == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*s) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = s + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + return '?'; + } + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (c < 040 || c >= 0177) + fprintf (stderr, "%s: unrecognized option, character code 0%o\n", + argv[0], (unsigned char) (c)); + else + fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); + } + return '?'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = 0; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + fprintf (stderr, "%s: option `-%c' requires an argument\n", + argv[0], c); + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else +#include "config.h" +#endif +#endif + +#include "getopt_long.h" + +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#else +char *getenv (); +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + +#ifdef TEST + +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == EOF) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff -uNr queue-1.10/getopt_long.h queue-1.11/getopt_long.h --- queue-1.10/getopt_long.h Wed Dec 31 19:00:00 1969 +++ queue-1.11/getopt_long.h Thu Jan 14 11:14:51 1999 @@ -0,0 +1,133 @@ +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + This file was modified slightly by Ian Lance Taylor, November 1992, + for Taylor UUCP, and again in June, 1995. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Ian Lance Taylor added the following defines for + Taylor UUCP. This avoids reported conflicts with system getopt + definitions. */ +#define getopt gnu_getopt +#define optarg gnu_optarg +#define optind gnu_optind +#define opterr gnu_opterr + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ + const char *name; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +enum _argtype +{ + no_argument, + required_argument, + optional_argument +}; + +#ifndef P +/* On some systems, includes getopt.h before P is defined by + uucp.h, and the -I arguments cause this version of getopt.h to be + included. Work around that here. */ +#define P(x) () +#define UNDEFINE_P +#endif + +extern int getopt P((int argc, char *const *argv, const char *shortopts)); +extern int getopt_long P((int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind)); +extern int getopt_long_only P((int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind)); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal P((int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only)); + +#ifdef UNDEFINE_P +#undef P +#undef UNDEFINE_P +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff -uNr queue-1.10/handle.c queue-1.11/handle.c --- queue-1.10/handle.c Tue Jan 12 13:36:32 1999 +++ queue-1.11/handle.c Tue Jan 19 16:20:34 1999 @@ -210,7 +210,8 @@ if ((donthang==0)&&(!dead)) send(fdsock2, &nine, sizeof(nine), MSG_OOB); /*Cleanup, as SIGKILL to process group may kill ourselves.*/ if(ttyinput||ttyoutput) deallocpty(); -_cleanup(); + /*_cleanup();*/ + fflush(NULL); kill(-pid,SIGKILL); raise(SIGKILL); } @@ -1139,7 +1140,8 @@ signal(WTERMSIG(mywait),SIG_DFL); sigsetmask(~sigmask(WTERMSIG(mywait))); /*Make sure everything gets flushed out.*/ - _cleanup(); + /*_cleanup();*/ + fflush(NULL); raise(WTERMSIG(mywait)); } exit(2); diff -uNr queue-1.10/lex.c queue-1.11/lex.c --- queue-1.10/lex.c Sat Dec 26 22:38:46 1998 +++ queue-1.11/lex.c Thu Jan 14 13:32:19 1999 @@ -1,26 +1,19 @@ -#include -#include -# define U(x) x +# include "stdio.h" +# define U(x) ((unsigned char)(x)) # define NLSTATE yyprevious=YYNEWLINE # define BEGIN yybgin = yysvec + 1 + # define INITIAL 0 # define YYLERR yysvec # define YYSTATE (yyestate-yysvec-1) # define YYOPTIM 1 -# ifndef YYLMAX -# define YYLMAX BUFSIZ -# endif -#ifndef __cplusplus +# define YYLMAX 2048 # define output(c) (void)putc(c,yyout) -#else -# define lex_output(c) (void)putc(c,yyout) -#endif - #if defined(__cplusplus) || defined(__STDC__) -#if defined(__cplusplus) && defined(__EXTERN_C__) +#ifdef __cplusplus extern "C" { #endif + int yylex(void); int yyback(int *, int); int yyinput(void); int yylook(void); @@ -28,46 +21,24 @@ int yyracc(int); int yyreject(void); void yyunput(int); - int yylex(void); -#ifdef YYLEX_E - void yywoutput(wchar_t); - wchar_t yywinput(void); -#endif #ifndef yyless - int yyless(int); + void yyless(long int); #endif #ifndef yywrap int yywrap(void); #endif -#ifdef LEXDEBUG - void allprint(char); - void sprint(char *); -#endif -#if defined(__cplusplus) && defined(__EXTERN_C__) -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - void exit(int); #ifdef __cplusplus } #endif #endif + +# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} # define yymore() (yymorfg=1) -#ifndef __cplusplus -# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -#else -# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -#endif -#define ECHO fprintf(yyout, "%s",yytext) +# define ECHO (void)fprintf(yyout, "%s",yytext) # define REJECT { nstr = yyreject(); goto yyfussy;} -int yyleng; -#define YYISARRAY -char yytext[YYLMAX]; +int yyleng; extern char yytext[]; int yymorfg; extern char *yysptr, yysbuf[]; int yytchar; @@ -80,34 +51,12 @@ struct yysvf *yyestate; extern struct yysvf yysvec[], *yybgin; +# line 2 "lex.l" + # line 3 "lex.l" /* - * $Header: /Net/aragorn/u3/wkrebs/prg/cvs/queue/lex.c,v 1.1.1.2 1998/08/18 03:43:18 wkrebs Exp $ - * $Log: lex.c,v $ - * Revision 1.1.1.2 1998/08/18 03:43:18 wkrebs - * * Version 0.22b August, 1998 - * - * Upgraded to beta after large numbers of downloads without bug reports - * (I know there are bugs left. :-) But, the code is obviously usable. ) - * - * Fixed Makefile install bugs :-) Added uninstall option. - * - * Increased SLEEPTIME to 120 to work better on larger clusters. - * - * Added setuid() in queue to correspond to principle of least privilege; - * also allows users to send queue signals via KILL instead of just via - * the keyboard (I.e., this was a bugfix) :-) - * - * Added Solaris support courtesy of Igor Schein. - * - * Minor changes to documentation. - * - * Announced queue-tips list (write to - * queue-tips-request@bioinfo.mbb.yale.edu to join.) - * - * Revision 1.1 86/12/31 17:32:46 sahayman - * Revision 1.2q 98/08/13 wkrebs for queue system - * +$Revision + */ #include "lex.h" @@ -144,17 +93,15 @@ "rlimitstack", K_RLIMITSTACK, "rlimitcore", K_RLIMITCORE, "rlimitrss", K_RLIMITRSS, + "rlimitnofile", K_RLIMITNOFILE, + "rlimitvmem", K_RLIMITVMEM, + "rlimitas", K_RLIMITVMEM, /*synonym for vmem*/ 0 }; # define YYNEWLINE 10 -yylex(){ +yylex(void){ int nstr; extern int yyprevious; -#ifdef __cplusplus -/* to avoid CC and lint complaining yyfussy not being used ...*/ -static int __lex_hack = 0; -if (__lex_hack) goto yyfussy; -#endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: @@ -233,44 +180,44 @@ 0, 6, -0, +0, 4, 6, -0, +0, 3, -0, +0, 2, 6, -0, +0, 2, 6, -0, +0, 1, 2, 6, -0, +0, 6, -5, -0, +0, 2, -0, +0, 1, 2, -0, +0, -5, -0, +0, 5, -0, +0, 0}; # define YYTYPE unsigned char struct yywork { YYTYPE verify, advance; } yycrank[] = { @@ -333,55 +280,49 @@ 0, 0, 0}; struct yywork *yytop = yycrank+158; struct yysvf *yybgin = yysvec+1; -char yymatch[] = { - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 9, 10, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 9, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 44, 44, 44, 44, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 1, 1, 1, 1, 1, 1, - 1, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 1, 1, 1, 1, 44, - 1, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, +unsigned char yymatch[] = { +00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,',' ,',' ,',' ,',' , +'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , +'0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,01 ,01 ,01 ,01 ,',' , +01 ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,',' ,',' ,',' ,',' ,',' , +',' ,',' ,',' ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , +01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , 0}; char yyextra[] = { 0,0,0,0,0,1,0,0, 0}; -/* Copyright (c) 1989 AT&T */ -/* All Rights Reserved */ - -/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ -/* The copyright notice above does not evidence any */ -/* actual or intended publication of such source code. */ - -#pragma ident "@(#)ncform 6.11 97/01/06 SMI" +#ident "$Revision: 1.9 $" int yylineno =1; # define YYU(x) x # define NLSTATE yyprevious=YYNEWLINE +char yytext[YYLMAX]; struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; char yysbuf[YYLMAX]; char *yysptr = yysbuf; @@ -428,34 +369,12 @@ if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } -#ifndef __cplusplus *yylastch++ = yych = input(); -#else - *yylastch++ = yych = lex_input(); -#endif -#ifdef YYISARRAY +#ifndef LONGLINES if(yylastch > &yytext[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } -#else - if (yylastch >= &yytext[ yytextsz ]) { - int x = yylastch - yytext; - - yytextsz += YYTEXTSZINC; - if (yytext == yy_tbuf) { - yytext = (char *) malloc(yytextsz); - memcpy(yytext, yy_tbuf, sizeof (yy_tbuf)); - } - else - yytext = (char *) realloc(yytext, yytextsz); - if (!yytext) { - fprintf(yyout, - "Cannot realloc yytext\n"); - exit(1); - } - yylastch = yytext + x; - } #endif yyfirst=0; tryagain: @@ -467,21 +386,23 @@ } # endif yyr = yyt; - if ( (int)yyt > (int)yycrank){ + if ( (void *)yyt > (void *)yycrank){ yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; +#ifndef LONGLINES if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } +#endif goto contin; } } # ifdef YYOPTIM - else if((int)yyt < (int)yycrank) { /* r < yycrank */ + else if((void *)yyt < (void *)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state\n"); @@ -491,10 +412,12 @@ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; +#ifndef LONGLINES if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } +#endif goto contin; } yyt = yyr + YYU(yymatch[yych]); @@ -509,10 +432,12 @@ if(yyt->advance+yysvec == YYLERR) /* error transition */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; +#ifndef LONGLINES if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } +#endif goto contin; } } @@ -554,7 +479,7 @@ } yyprevious = YYU(*yylastch); yylsp = lsp; - yyleng = yylastch-yytext+1; + yyleng = (int)(yylastch-yytext+1); yytext[yyleng] = 0; # ifdef LEXDEBUG if(debug){ @@ -572,15 +497,9 @@ yysptr=yysbuf; return(0); } -#ifndef __cplusplus yyprevious = yytext[0] = input(); if (yyprevious>0) output(yyprevious); -#else - yyprevious = yytext[0] = lex_input(); - if (yyprevious>0) - lex_output(yyprevious); -#endif yylastch=yytext; # ifdef LEXDEBUG if(debug)putchar('\n'); @@ -608,11 +527,7 @@ yyinput() #endif { -#ifndef __cplusplus return(input()); -#else - return(lex_input()); -#endif } #if defined(__cplusplus) || defined(__STDC__) void yyoutput(int c) @@ -621,11 +536,7 @@ int c; #endif { -#ifndef __cplusplus output(c); -#else - lex_output(c); -#endif } #if defined(__cplusplus) || defined(__STDC__) void yyunput(int c) diff -uNr queue-1.10/lex.h queue-1.11/lex.h --- queue-1.10/lex.h Thu Nov 26 19:08:45 1998 +++ queue-1.11/lex.h Thu Jan 14 13:43:29 1999 @@ -11,5 +11,7 @@ K_RLIMITDATA, K_RLIMITSTACK, K_RLIMITCORE, - K_RLIMITRSS + K_RLIMITRSS, + K_RLIMITNOFILE, + K_RLIMITVMEM }; diff -uNr queue-1.10/lex.l queue-1.11/lex.l --- queue-1.10/lex.l Thu Nov 26 19:08:45 1998 +++ queue-1.11/lex.l Thu Jan 14 13:30:31 1999 @@ -1,3 +1,4 @@ +%{ /* $Revision @@ -37,6 +38,9 @@ "rlimitstack", K_RLIMITSTACK, "rlimitcore", K_RLIMITCORE, "rlimitrss", K_RLIMITRSS, + "rlimitnofile", K_RLIMITNOFILE, + "rlimitvmem", K_RLIMITVMEM, + "rlimitas", K_RLIMITVMEM, /*synonym for vmem*/ 0 }; diff -uNr queue-1.10/qlib.c queue-1.11/qlib.c --- queue-1.10/qlib.c Tue Jan 12 13:01:58 1999 +++ queue-1.11/qlib.c Tue Jan 19 14:21:45 1999 @@ -77,9 +77,10 @@ if(Hosts) { for(i = 0;i < NHosts;i++) if(Hosts[i].host) free (Hosts[i].host); free(Hosts); - NHosts = 0; } + NHosts = 0; + for(;;) { if(fgets(TmpStr,TmpStrSize - 2,QHosts) == NULL) @@ -146,7 +147,7 @@ i++; } - fclose(QHosts); + return(fclose(QHosts)); } char *localhost(host) diff -uNr queue-1.10/queue.c queue-1.11/queue.c --- queue-1.10/queue.c Tue Jan 12 21:57:36 1999 +++ queue-1.11/queue.c Fri Jan 22 14:53:32 1999 @@ -30,6 +30,7 @@ **************************************************************************/ #include "queue.h" + #define SPOOLDIR QUEUEDIR char* canonicalhost (char *); @@ -235,7 +236,7 @@ donthang = 0; } -while ((i = getopt_long(argc, argv, optionstring, longopts)) != EOF) +while ((i = getopt_long(argc, argv, optionstring, longopts,NULL)) != EOF) switch (i) { case 'l': { @@ -310,7 +311,7 @@ } case 'v': { - fprintf(stderr,"GNU Queue version %s Copyright 1998 Werner G. Krebs \n",VERSION); + fprintf(stderr,"GNU Queue version %s\n Copyright 1998,1999 Werner G. Krebs . All rights reserved.\n",VERSION); fprintf(stderr,"GNU Queue comes with absolutely no warranty; see file\nCOPYING for details.\n\n"); fprintf(stderr,"Bug reports to bug-queue@gnu.org.\n"); exit(0); diff -uNr queue-1.10/queue.h queue-1.11/queue.h --- queue-1.10/queue.h Tue Jan 12 13:00:12 1999 +++ queue-1.11/queue.h Tue Jan 19 17:29:54 1999 @@ -2,7 +2,7 @@ */ -#include +#include "config.h" #include "define.h" #ifndef _QUEUE @@ -185,6 +185,22 @@ #define error2(fmt,a1,a2) { sprintf(errstr,fmt,a1,a2); error(errstr); } #define syserror1(fmt,a1) { sprintf(errstr,fmt,a1); syserror(errstr); } + +/*WGK 1999/01/19 The following defines are needed for SUN-OS 5.x*/ + +#ifndef sigmask +#define sigmask(sig) \ + (((unsigned long) 1) << (((sig) - 1) % (8 * sizeof (unsigned long +int)))) +#endif /*sigmask*/ + +#ifndef HAVE_HERROR + /*WGK Not sure if this is correct, but it will cause it compile, +and since it is only used once as an error diagnostic, it is not essential +that this work.*/ +#define herror perror +#endif /*HAVE_HERROR*/ +/*WGK End SUN-OS stuff.*/ #endif /*_QUEUE*/ diff -uNr queue-1.10/queued.c queue-1.11/queued.c --- queue-1.10/queued.c Tue Jan 12 18:13:16 1999 +++ queue-1.11/queued.c Fri Jan 22 14:54:25 1999 @@ -35,6 +35,7 @@ #include "queue.h" + #define SPOOLDIR QUEUEDIR @@ -393,7 +394,7 @@ #endif /*NO_ROOT*/ - while ((i = getopt_long(argc, argv, "d:p:t:Dv",longopts)) != EOF) + while ((i = getopt_long(argc, argv, "d:p:t:Dv",longopts,NULL)) != EOF) switch (i) { case 'd': /* -d spooldir */ spooldir = optarg; @@ -410,7 +411,7 @@ debug++; break; case 'v': - fprintf(stderr,"Queued from GNU Queue version %s Copyright Werner G. Krebs \n GNU Queue comes with absolutely no warranty; see COPYING for details.\n\nBug reports to \n",VERSION); + fprintf(stderr,"Queued from GNU Queue version %s\n Copyright 1998, 1999 Werner G. Krebs \n GNU Queue comes with absolutely no warranty; see COPYING for details.\n\nBug reports to \n",VERSION); exit(0); default: @@ -433,7 +434,7 @@ { int flag = 1; - char *cannonhost = canonicalhost(myhostname()); + char *cannonhost = strdup(canonicalhost(myhostname())); if(!Hosts) ReadHosts(QHOSTSFILE); for (i=0;i 0) { + while ((pid = wait3((void *)&wait_status, WNOHANG, &rusage)) > 0) { totalcpu = (double)( rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec ) + (double)( rusage.ru_utime.tv_usec @@ -928,9 +929,9 @@ (void) times(&tms); oldtotalcpu = (DOUBLE)tms.tms_cutime + tms.tms_cstime; #ifdef __hpux - while ((pid = wait3(&status, WNOHANG, NULL)) > 0) { + while ((pid = wait3((void *)&wait_status, WNOHANG, NULL)) > 0) { #else - while ((pid = wait(&status)) > 0) { + while ((pid = wait((void *)&wait_status)) > 0) { #endif (void) times(&tms); newtotalcpu = (DOUBLE)tms.tms_cutime + tms.tms_cstime; @@ -938,8 +939,8 @@ oldtotalcpu = newtotalcpu; #endif /*HAVE_WAIT3*/ mdebug3("wait exit pid=%d, stat=0%o, cpu=%.1f\n", - pid, status.w_status, totalcpu); - terminated(pid, status.w_status, totalcpu); + pid, wait_status, totalcpu); + terminated(pid, wait_status, totalcpu); #ifdef __hpux /* * If "terminated" couldn't find the job, and "hpuxsystemflag" @@ -1026,7 +1027,8 @@ sprintf(str, "QUEUED fatal error; queued terminating:\n - %s", s); merror(str); - _cleanup(); + /* _cleanup();*/ + fflush(NULL); abort(); exit(1); } @@ -1486,6 +1488,8 @@ case K_RLIMITSTACK: case K_RLIMITCORE: case K_RLIMITRSS: + case K_RLIMITNOFILE: + case K_RLIMITVMEM: /* If only one number is given, we set only the * current limit. If two numbers, we set current and * maximum limits. @@ -2668,14 +2672,30 @@ int r; enum keyword kwd; } rtab[] = { +#ifdef RLIMIT_CPU RLIMIT_CPU, K_RLIMITCPU, +#endif +#ifdef RLIMIT_FSIZE RLIMIT_FSIZE, K_RLIMITFSIZE, +#endif +#ifdef RLIMIT_DATA RLIMIT_DATA, K_RLIMITDATA, +#endif +#ifdef RLIMIT_STACK RLIMIT_STACK, K_RLIMITSTACK, +#endif +#ifdef RLIMIT_CORE RLIMIT_CORE, K_RLIMITCORE, -#ifndef sun +#endif +#ifdef RLIMIT_RSS RLIMIT_RSS, K_RLIMITRSS, #endif +#ifdef RLIMIT_NOFILE + RLIMIT_NOFILE, K_RLIMITNOFILE, +#endif +#ifdef RLIMIT_VMEM + RLIMIT_VMEM, K_RLIMITVMEM, +#endif }; /* Turn RLIMIT manifest number into a small Integer 0 <= i < RLIM_NLIMITS @@ -3225,28 +3245,30 @@ /*To access kmem we need privileges; if we don't have them we need a kludge.*/ -{ int pid, status, pipe[2]; +{ int pid, status, mypipe[2]; FILE *in; char junk[255]; - char *command; float aves[3]; - if (command == 0) - return 1; + if(pipe(mypipe)<0) { + perror("pipe"); + exit(1); + } pid = fork(); if (pid == 0) { - dup2(pipe[1],1); + dup2(mypipe[1],1); + close(mypipe[1]); execve("/bin/sh", "uptime", environ); exit(127); } + close(mypipe[1]); waitpid(pid, &status, 0); - in = fdopen(pipe[0],"r"); + in = fdopen(mypipe[0],"r"); fscanf(in,"%s average %f, %f, %f", junk,&aves[0],&aves[1],&aves[2]); - close(pipe[1]); - fclose(in); - close(pipe[0]); + fclose(in); + close(mypipe[0]); for (i = 0; i < 3; i++) a[i] = aves[i]; @@ -3831,7 +3853,7 @@ if(!qp->q_status) load = 1e08; else { getloadf(avg); - load = avg[0]/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); + load = (avg[0] + 1.0)/((max(0, qp->q_vmaxexec - qp->q_nexec)+1)*qp->q_pfactor); } /*This is a hack. We really shouldn't be using a single stream to do input/output on a socket. So, we only use one stream. We probably diff -uNr queue-1.10/sigsetmask.c queue-1.11/sigsetmask.c --- queue-1.10/sigsetmask.c Wed Dec 31 19:00:00 1969 +++ queue-1.11/sigsetmask.c Tue Jan 19 17:52:57 1999 @@ -0,0 +1,74 @@ +/* Copyright (C) 1993 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +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. */ + +/*Modified 1999/01/18 by WGK to work with GNU Queue on systems which +lack sigsetmask but have sigprocmask*/ + +#include "queue.h" + +#undef __sigmask +#define __sigmask(sig) \ + (((unsigned long) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int)))) + +#undef __sigaddset +#define __sigaddset(set, sig) ((*(set) |= __sigmask (sig)), 0) + +#undef __sigemptyset +#define __sigemptyset(set) ((*(set) = 0L), 0) + +#undef __sigismember +#define __sigismember(set, sig) ((*(set) & __sigmask (sig)) ? 1 : 0) + +/* Set the mask of blocked signals to MASK, returning the old mask. */ + +int sigsetmask(mask) +int mask; +{ + register int sig; + sigset_t set, oset; + + if (sizeof (mask) == sizeof (set)) + set = *((sigset_t*) &mask); + else + { + if (__sigemptyset((unsigned long*) &set) < 0) + return -1; + + for (sig = 1; sig < NSIG; ++sig) + if ((mask & __sigmask(sig)) && + __sigaddset((unsigned long*) &set, sig) < 0) + return -1; + } + + if (sigprocmask(SIG_SETMASK, &set, &oset) < 0) + return -1; + + if (sizeof (mask) == sizeof (oset)) + mask = *((int*) &oset); + else + { + mask = (int) 0; + for (sig = 1; sig < NSIG; ++sig) + if (__sigismember((unsigned long*) &oset, sig) == 1) + mask |= __sigmask(sig); + } + + return mask; +} + +