Subject: RL driver update, setvbuf(3) arrives in 2BSD, rdist fix (#380) Index: sys/pdpuba/rl*,lib/libc/stdio/set*buf.c,ucb/rdist 2.11BSD Description: 1) 'autoconfig' only recognizes the RL controller if drive 0 is connected to the system at boot time. The RL01/02 driver does not allow reads from a RL drive that has the "WRITE PROTECT" button on. 2) setvbuf(3) does not exist. This means there is no method of setting linebuffering with a static buffer other than fiddling with stdio's structures behind its back. 3) The libc.a modules sibuf.c and sobuf.c wasted 1kb each in programs that used them. 4) Rdist used setbuf in an attempt to reduce the amount of malloc'd memory used. Unfortunately this a) was not line buffered which delayed seeing what rdist was doing, b) caused rdist to coredump (if it was the slave system) because rdist apparently made the assumption that output was line buffered and could change the buffering scheme on the fly. Repeat-By: 1) Boot a system with multiple RL drives, but with drive 0 not present. 'autoconfig' will not see an interrupt from the RL subsystem during its probe of drive 0, and as a result the rl driver will not be attached. Attempt to access a RL drive with "write protect" in. You'll get the messages: rl0: !status cs=205 da=13 /dev/rrl0a: Device not configured 2) Attempt to use a local buffer with 'setbuf(file, buf);' and notice that the output is no longer linebuffered. Using 'setlinebuf()' causes a BUFSIZ (1kb) buffer to be malloc'd which defeats the intent of using a local small buffer. 3) Observation. Note that both lib/libc/stdio/{sibuf,sobuf}.c are nothing more than "char _sibuf[BUFSIZ];" declarations. 4) This may not be easy to repeat. I noticed it while using 'rdist' to another 2.11BSD system. On the remote (slave) system 'rdist' became confused and coredumped in a stdio routine. Analysis of the stack backtrace pointed at the buffering style as the problem. Fix: 1) Modify /sys/autoconfig/rlauto.c so it tests only for the presence of the RL controller CSR, and doesn't wait for an interrupt. This is the same thing which is done in the TS11 probe routine because TS controllers can not be made to interrupt reliably if a tape is not at the load point and the drive is not online. The RL driver was looking at the WRITE LOCK bit from the controller as if it was an error bit. This confusion was made worse by the fact that this bit was assigned to the symble WLE in rlreg.h, implying that this is a "Write Lock Error". Rename WLE to WL, and mask off the WRITE LOCK bit so it is ignored in an error check. The changes to the RL driver and the RL probe route are from Tim Shoppa (shoppa@alph02.triumf.ca). Many thanks! 2) Port the 4.4BSD setvbuf, setbuf and setlinebuf.c modules to 2.11BSD 3) Remove sibuf.c and sobuf.c from libc.a and update the small number of (old) programs that still referenced the symbols _sibuf and _sobuf. Programs should have simply declared a local buffer (on the stack) and used that rather than using a global buffer. 4) Modify rdist to use the newly available setvbuf(). To install this update cut where indicated saving to a file (/tmp/380). The contents of the patchkit are: 380.patch - a patch file to update files in the system 380.remove - a shell script to remove files that are either no longer needed in the system _or_ files which are being replaced with 4.4BSD counterparts. 380.shar - a shar archive of new files being added to the system 380.libc - a shell script to incrementally update the C library. It is of course possible to just recompile the entire thing from sources. 380.utils - a shell script to recompile and install the updated applications and manpages as well as those programs affected by the removal of modules in libc.a NOTE: Technically speaking any program that calls setbuf(), setbuffer() or setlinebuf() is "affected" by the replacement of these functions in libc.a but it was not judged to be worth a "make world" of the system at this time. Feel free to do so if you have about 20+ hours or so to spare ;) NOTE: The 380.remove script *MUST* be run before unpacking 380.shar. This is because the act of unpacking shar files will not over write existing files. As always it's a good idea to read over destructive scripts (unless you're a real trusting person ;)). cd /tmp sh 380 sh -x 380.remove sh 380.shar patch -p0 < /tmp/380.patch Next the autoconfigure program is built and installed. cd /sys/autoconfig make make install make clean If you have RL02 devices configured into your kernel then the kernel is rebuilt. If there are no RL devices configured this step is not necessary. cd /sys/YOUR_KERNEL make mv /unix /ounix mv /netnix /onetnix mv unix netnix / chmod 744 /unix /netnix (if you do not have a networking kernel then leave out the '/netnix') reboot It is a good idea to have a 'GENERIC' kernel around to fall back on. If you keep a generic kernel in /genunix then: cd /sys/GENERIC make mv unix /genunix The next step is to update the C library. There is a script provided or you may simply build the whole C library (takes about 1 hour) by "cd /usr/src/lib/libc; make install". If you would rather do it the fast way: sh -x /tmp/380.libc The last step is to recompile and install a few applications. There is a script provided which can be used or the steps can be performed manually (to improve your typing skills ;-)): sh -x /tmp/380.utils Congratulations - you're finished. As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. --------------------------------cut here---------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # 380.patch # 380.remove # 380.shar # 380.libc # 380.utils # This archive created: Fri Aug 1 21:35:51 1997 export PATH; PATH=/bin:/usr/bin:$PATH if test -f '380.patch' then echo shar: "will not over-write existing file '380.patch'" else sed 's/^Z//' << \SHAR_EOF > '380.patch' Z*** /usr/src/sys/pdpuba/rlreg.h.old Wed Apr 24 20:44:13 1991 Z--- /usr/src/sys/pdpuba/rlreg.h Sun Jul 20 11:03:23 1997 Z*************** Z*** 3,9 **** Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rlreg.h 1.1 (2.10BSD Berkeley) 12/1/86 Z */ Z Z struct rldevice Z--- 3,9 ---- Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rlreg.h 1.2 (2.11BSD) 1997/7/20 Z */ Z Z struct rldevice Z*************** Z*** 56,62 **** Z /* bits in rlmp */ Z #define RLMP_WDE 0100000 /* write data error */ Z #define RLMP_HCE 0040000 /* head current error */ Z! #define RLMP_WLE 0020000 /* write lock */ Z #define RLMP_STIMO 0010000 /* seek timeout */ Z #define RLMP_SPE 0004000 /* spin error */ Z #define RLMP_WGE 0002000 /* write gate error */ Z--- 56,62 ---- Z /* bits in rlmp */ Z #define RLMP_WDE 0100000 /* write data error */ Z #define RLMP_HCE 0040000 /* head current error */ Z! #define RLMP_WL 0020000 /* write lock */ Z #define RLMP_STIMO 0010000 /* seek timeout */ Z #define RLMP_SPE 0004000 /* spin error */ Z #define RLMP_WGE 0002000 /* write gate error */ Z*** /usr/src/sys/pdpuba/rl.c.old Sun Jan 19 11:21:01 1997 Z--- /usr/src/sys/pdpuba/rl.c Sun Jul 20 11:37:47 1997 Z*************** Z*** 3,14 **** Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rl.c 1.9 (2.11BSD GTE) 1997/1/19 Z */ Z Z /* Z * RL01/RL02 disk driver Z * Z * Date: January 7, 1996 Z * Fix broken UCB_METER statistics gathering. Z * Z--- 3,19 ---- Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rl.c 1.10 (2.11BSD GTE) 1997/7/20 Z */ Z Z /* Z * RL01/RL02 disk driver Z * Z+ * Date: July 19, 1996 Z+ * The driver was taking the WRITE LOCK (RLMP_WL) bit to indicate Z+ * an error, when all it really does is indicate that the disk is Z+ * write protected. Set up RLMP_MASK to ignore this bit. (Tim Shoppa) Z+ * Z * Date: January 7, 1996 Z * Fix broken UCB_METER statistics gathering. Z * Z*************** Z*** 60,65 **** Z--- 65,72 ---- Z Z #define rlwait(r) while (((r)->rlcs & RL_CRDY) == 0) Z #define RLUNIT(x) ((minor(x) >> 3) & 7) Z+ #define RLMP_MASK ( ~( RLMP_WL | RLMP_DTYP | RLMP_HSEL ) ) Z+ #define RLMP_OK ( RLMP_HO | RLMP_BH | RLMP_LCKON ) Z Z struct rldevice *RLADDR; Z Z*************** Z*** 449,455 **** Z if (rladdr->rlcs & RL_CERR) { Z if (rladdr->rlcs & RL_HARDERR && rltab.b_errcnt > 2) { Z harderr(bp, "rl"); Z! printf("cs=%b da=%b\n", rladdr->rlcs, RL_BITS, Z rladdr->rlda, RLDA_BITS); Z } Z if (rladdr->rlcs & RL_DRE) { Z--- 456,462 ---- Z if (rladdr->rlcs & RL_CERR) { Z if (rladdr->rlcs & RL_HARDERR && rltab.b_errcnt > 2) { Z harderr(bp, "rl"); Z! log(LOG_ERR, "cs=%b da=%b\n", rladdr->rlcs, RL_BITS, Z rladdr->rlda, RLDA_BITS); Z } Z if (rladdr->rlcs & RL_DRE) { Z*************** Z*** 459,465 **** Z status = rladdr->rlmp; Z if(rltab.b_errcnt > 2) { Z harderr(bp, "rl"); Z! printf("mp=%b da=%b\n", status, RLMP_BITS, Z rladdr->rlda, RLDA_BITS); Z } Z rladdr->rlda = RLDA_RESET | RLDA_GS; Z--- 466,472 ---- Z status = rladdr->rlmp; Z if(rltab.b_errcnt > 2) { Z harderr(bp, "rl"); Z! log(LOG_ERR, "mp=%b da=%b\n", status, RLMP_BITS, Z rladdr->rlda, RLDA_BITS); Z } Z rladdr->rlda = RLDA_RESET | RLDA_GS; Z*************** Z*** 705,711 **** Z if(rladdr->rlcs & RL_CERR) { Z if(rladdr->rlcs & RL_NXM) Z return(0); /* End of memory */ Z! printf("rl%d: dmp err, cs=%b da=%b mp=%b\n", Z dev,rladdr->rlcs,RL_BITS,rladdr->rlda, Z RLDA_BITS, rladdr->rlmp, RLMP_BITS); Z return(EIO); Z--- 712,718 ---- Z if(rladdr->rlcs & RL_CERR) { Z if(rladdr->rlcs & RL_NXM) Z return(0); /* End of memory */ Z! log(LOG_ERR, "rl%d: dmp err, cs=%b da=%b mp=%b\n", Z dev,rladdr->rlcs,RL_BITS,rladdr->rlda, Z RLDA_BITS, rladdr->rlmp, RLMP_BITS); Z return(EIO); Z*************** Z*** 775,784 **** Z rp->rlda = RLDA_RESET | RLDA_GS; Z rp->rlcs = (drive << 8) | RL_GETSTATUS; /* set up csr */ Z rlwait(rp); Z! } while (((rp->rlmp & 0177477) != 035) && (++ctr < 16)); Z if (ctr >= 16) Z { Z! printf("rl%d: !status cs=%b da=%b\n", drive, Z rp->rlcs, RL_BITS, rp->rlda, RLDA_BITS); Z rl_dk[drive].dk_flags &= ~DKF_ALIVE; Z return(-1); Z--- 782,791 ---- Z rp->rlda = RLDA_RESET | RLDA_GS; Z rp->rlcs = (drive << 8) | RL_GETSTATUS; /* set up csr */ Z rlwait(rp); Z! } while (((rp->rlmp & RLMP_MASK) != RLMP_OK) && (++ctr < 16)); Z if (ctr >= 16) Z { Z! log(LOG_ERR, "rl%d: !status cs=%b da=%b\n", drive, Z rp->rlcs, RL_BITS, rp->rlda, RLDA_BITS); Z rl_dk[drive].dk_flags &= ~DKF_ALIVE; Z return(-1); Z*** /usr/src/sys/autoconfig/rlauto.c.old Wed Dec 30 17:56:56 1992 Z--- /usr/src/sys/autoconfig/rlauto.c Sun Jul 20 10:58:37 1997 Z*************** Z*** 3,25 **** Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rlauto.c 2.1 (2.11BSD GTE) 12/30/92 Z */ Z Z #include "param.h" Z #include "../machine/autoconfig.h" Z #include "../machine/machparam.h" Z- Z #include "rlreg.h" Z Z rlprobe(addr,vector) Z struct rldevice *addr; Z int vector; Z { Z- stuff(RLDA_RESET | RLDA_GS, (&(addr->rlda))); Z- DELAY(10L); Z- stuff(RL_GETSTATUS | RL_IE , (&(addr->rlcs))); Z- DELAY(10L); Z stuff(RL_CRDY, (&(addr->rlcs))); Z! return(ACP_IFINTR); Z } Z--- 3,24 ---- Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)rlauto.c 2.2 (2.11BSD GTE) 1997/7/20 Z */ Z Z #include "param.h" Z #include "../machine/autoconfig.h" Z #include "../machine/machparam.h" Z #include "rlreg.h" Z Z+ extern int errno; Z+ Z rlprobe(addr,vector) Z struct rldevice *addr; Z int vector; Z { Z stuff(RL_CRDY, (&(addr->rlcs))); Z! if (errno) /* paranoia */ Z! return(ACP_NXDEV); Z! return(ACP_EXISTS); Z } Z*** /usr/include/stdio.h.old Mon Jan 15 21:53:03 1996 Z--- /usr/include/stdio.h Tue Jul 29 20:03:32 1997 Z*************** Z*** 3,9 **** Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)stdio.h 5.3.1 (2.11BSD) 1996/1/15 Z */ Z Z # ifndef FILE Z--- 3,9 ---- Z * All rights reserved. The Berkeley software License Agreement Z * specifies the terms and conditions for redistribution. Z * Z! * @(#)stdio.h 5.3.2 (2.11BSD) 1997/7/29 Z */ Z Z # ifndef FILE Z*************** Z*** 26,31 **** Z--- 26,40 ---- Z #define _IOSTRG 0100 Z #define _IOLBF 0200 Z #define _IORW 0400 Z+ Z+ /* Z+ * The following definition is for ANSI C, which took them Z+ * from System V, which brilliantly took internal interface macros and Z+ * made them official arguments to setvbuf(), without renaming them. Z+ * Hence, these ugly _IOxxx names are *supposed* to appear in user code. Z+ */ Z+ #define _IOFBF 0 /* setvbuf should set fully buffered */ Z+ /* _IONBF and _IOLBF are used from the flags above */ Z Z #ifndef NULL Z #define NULL 0 Z*** /usr/src/bin/who.c.old Sat Nov 16 18:06:48 1996 Z--- /usr/src/bin/who.c Tue Jul 29 19:48:22 1997 Z*************** Z*** 9,15 **** Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z Z! static char sccsid[] = "@(#)who.c 5.1.2 (2.11BSD GTE) 1996/11/16"; Z #endif Z Z #include Z--- 9,15 ---- Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z Z! static char sccsid[] = "@(#)who.c 5.1.3 (2.11BSD GTE) 1997/7/29"; Z #endif Z Z #include Z*************** Z*** 17,22 **** Z--- 17,25 ---- Z #include Z #include Z #include /* for MAXHOSTNAMELEN */ Z+ #include Z+ #include Z+ #include Z Z #define NMAX sizeof(utmp.ut_name) Z #define LMAX sizeof(utmp.ut_line) Z*************** Z*** 24,34 **** Z Z struct utmp utmp; Z struct passwd *pw; Z- struct passwd *getpwuid(); Z char hostname[MAXHOSTNAMELEN]; Z Z- char *ttyname(), *rindex(), *ctime(), *strcpy(); Z- Z main(argc, argv) Z int argc; Z char **argv; Z--- 27,34 ---- Z*************** Z*** 35,43 **** Z { Z register char *tp, *s; Z register FILE *fi; Z- extern char _sobuf[]; Z Z- setbuf(stdout, _sobuf); Z s = _PATH_UTMP; Z if(argc == 2) Z s = argv[1]; Z--- 35,41 ---- Z*** /usr/src/games/snake/snake.c.old Thu May 30 08:45:19 1985 Z--- /usr/src/games/snake/snake.c Tue Jul 29 19:51:18 1997 Z*************** Z*** 4,18 **** Z * specifies the terms and conditions for redistribution. Z */ Z Z! #ifndef lint Z char copyright[] = Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z- #endif not lint Z Z! #ifndef lint Z! static char sccsid[] = "@(#)snake.c 5.1 (Berkeley) 5/30/85"; Z! #endif not lint Z Z /* Z * snake - crt hack game. Z--- 4,16 ---- Z * specifies the terms and conditions for redistribution. Z */ Z Z! #if !defined(lint) && defined(DOSCCS) Z char copyright[] = Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z Z! static char sccsid[] = "@(#)snake.c 5.1.1 (2.11BSD) 1997/7/29"; Z! #endif Z Z /* Z * snake - crt hack game. Z*************** Z*** 94,100 **** Z int j; Z long time(); Z int stop(); Z! extern char _sobuf[]; Z Z argcount = argc; Z argval = argv; Z--- 92,98 ---- Z int j; Z long time(); Z int stop(); Z! char stdbuf[BUFSIZ]; Z Z argcount = argc; Z argval = argv; Z*************** Z*** 124,130 **** Z } Z Z srand((int)tv); Z! setbuf(stdout,_sobuf); Z i = ((lcnt < ccnt) ? lcnt : ccnt); /* min screen edge */ Z if (i < 4) { Z printf("Screen too small for a fair game\n"); Z--- 122,128 ---- Z } Z Z srand((int)tv); Z! setbuf(stdout, stdbuf); Z i = ((lcnt < ccnt) ? lcnt : ccnt); /* min screen edge */ Z if (i < 4) { Z printf("Screen too small for a fair game\n"); Z*** /usr/src/games/sail/main.c.old Wed May 29 16:04:20 1985 Z--- /usr/src/games/sail/main.c Tue Jul 29 19:55:36 1997 Z*************** Z*** 4,18 **** Z * specifies the terms and conditions for redistribution. Z */ Z Z! #ifndef lint Z char copyright[] = Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z- #endif not lint Z Z! #ifndef lint Z! static char sccsid[] = "@(#)main.c 5.1 (Berkeley) 5/29/85"; Z! #endif not lint Z Z #include "externs.h" Z Z--- 4,16 ---- Z * specifies the terms and conditions for redistribution. Z */ Z Z! #if !defined(lint) && defined(DOSCCS) Z char copyright[] = Z "@(#) Copyright (c) 1980 Regents of the University of California.\n\ Z All rights reserved.\n"; Z Z! static char sccsid[] = "@(#)main.c 5.1.1 (2.11BSD) 1997/7/29"; Z! #endif Z Z #include "externs.h" Z Z*************** Z*** 23,31 **** Z { Z register char *p; Z int i; Z! extern char _sobuf[]; Z Z! setbuf(stdout, _sobuf); Z (void) srand(getpid()); Z issetuid = getuid() != geteuid(); Z if (p = rindex(*argv, '/')) Z--- 21,29 ---- Z { Z register char *p; Z int i; Z! char stdobuf[BUFSIZ]; Z Z! setbuf(stdout, stdobuf); Z (void) srand(getpid()); Z issetuid = getuid() != geteuid(); Z if (p = rindex(*argv, '/')) Z*** /usr/src/games/Makefile.old Mon Jan 18 08:55:57 1993 Z--- /usr/src/games/Makefile Sat Jul 26 21:06:07 1997 Z*************** Z*** 3,9 **** Z # All rights reserved. The Berkeley software License Agreement Z # specifies the terms and conditions for redistribution. Z # Z! # @(#)Makefile 5.4 (Berkeley) 2/1/86 Z # Z DESTDIR= Z CFLAGS= -O Z--- 3,9 ---- Z # All rights reserved. The Berkeley software License Agreement Z # specifies the terms and conditions for redistribution. Z # Z! # @(#)Makefile 5.5 (2.11BSD) 1997/7/26 Z # Z DESTDIR= Z CFLAGS= -O Z*************** Z*** 12,17 **** Z--- 12,18 ---- Z # Programs that live in subdirectories, and have makefiles of their own. Z # Z SUBDIR= adventure backgammon battlestar boggle btlgammon cribbage fortune \ Z+ hack \ Z hangman hunt mille monop pdp phantasia quiz robots sail snake \ Z trek warp words Z Z*** /usr/src/lib/libc/stdio/Makefile.old Mon May 15 00:02:27 1989 Z--- /usr/src/lib/libc/stdio/Makefile Tue Jul 29 20:17:17 1997 Z*************** Z*** 3,9 **** Z # All rights reserved. The Berkeley software License Agreement Z # specifies the terms and conditions for redistribution. Z # Z! # @(#)Makefile 5.4 (Berkeley) 9/5/85 Z # Z # Several routines have been rewritten in assembly language for the VAX and Z # PDP. If you are not running on a VAX or PDP, you should use the original Z--- 3,9 ---- Z # All rights reserved. The Berkeley software License Agreement Z # specifies the terms and conditions for redistribution. Z # Z! # @(#)Makefile 5.4.1 (2.11BSD) 1997/7/29 Z # Z # Several routines have been rewritten in assembly language for the VAX and Z # PDP. If you are not running on a VAX or PDP, you should use the original Z*************** Z*** 10,34 **** Z # C sources which are included in this directory. Regretably we do not have Z # a C version of doprnt(). Z # Z- #if !defined(vax) && !defined(pdp11) Z #SRCS= ${STDSRC} ${VAXSRC} Z #OBJS= ${STDOBJ} ${VAXOBJ} Z- #else Z SRCS= ${STDSRC} puts.c fputs.c Z OBJS= ${STDOBJ} puts.o fputs.o Z- #endif not vax && not pdp11 Z Z CFLAGS= -O ${DEFS} Z Z STDSRC= clrerr.c doscan.c exit.c fdopen.c filbuf.c findiop.c flsbuf.c fopen.c \ Z fprintf.c fread.c freopen.c fseek.c ftell.c fwrite.c getchar.c getw.c \ Z! printf.c putchar.c putw.c rew.c scanf.c setbuf.c setbuffer.c sibuf.c \ Z! sobuf.c sprintf.c strout.c ungetc.c vfprintf.c vprintf.c vsprintf.c Z VAXSRC= fgetc.c fgets.c fputc.c fputs.c gets.c puts.c Z STDOBJ= clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o flsbuf.o fopen.o \ Z fprintf.o fread.o freopen.o fseek.o ftell.o fwrite.o getchar.o getw.o \ Z! printf.o putchar.o putw.o rew.o scanf.o setbuf.o setbuffer.o sibuf.o \ Z! sobuf.o sprintf.o strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o Z VAXOBJ= fgetc.o fgets.o fputc.o fputs.o gets.o puts.o Z TAGSFILE=tags Z Z--- 10,31 ---- Z # C sources which are included in this directory. Regretably we do not have Z # a C version of doprnt(). Z # Z #SRCS= ${STDSRC} ${VAXSRC} Z #OBJS= ${STDOBJ} ${VAXOBJ} Z SRCS= ${STDSRC} puts.c fputs.c Z OBJS= ${STDOBJ} puts.o fputs.o Z Z CFLAGS= -O ${DEFS} Z Z STDSRC= clrerr.c doscan.c exit.c fdopen.c filbuf.c findiop.c flsbuf.c fopen.c \ Z fprintf.c fread.c freopen.c fseek.c ftell.c fwrite.c getchar.c getw.c \ Z! printf.c putchar.c putw.c rew.c scanf.c setbuf.c setbuffer.c setvbuf.c \ Z! sprintf.c strout.c ungetc.c vfprintf.c vprintf.c vsprintf.c Z VAXSRC= fgetc.c fgets.c fputc.c fputs.c gets.c puts.c Z STDOBJ= clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o flsbuf.o fopen.o \ Z fprintf.o fread.o freopen.o fseek.o ftell.o fwrite.o getchar.o getw.o \ Z! printf.o putchar.o putw.o rew.o scanf.o setbuf.o setbuffer.o setvbuf.o \ Z! sprintf.o strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o Z VAXOBJ= fgetc.o fgets.o fputc.o fputs.o gets.o puts.o Z TAGSFILE=tags Z Z*************** Z*** 102,109 **** Z scanf.o: scanf.c /usr/include/stdio.h Z setbuf.o: setbuf.c /usr/include/stdio.h Z setbuffer.o: setbuffer.c /usr/include/stdio.h Z- sibuf.o: sibuf.c /usr/include/stdio.h Z- sobuf.o: sobuf.c /usr/include/stdio.h Z sprintf.o: sprintf.c /usr/include/stdio.h Z strout.o: strout.c /usr/include/stdio.h Z ungetc.o: ungetc.c /usr/include/stdio.h Z--- 99,104 ---- Z*** /usr/src/man/man3/Makefile.old Fri Jun 27 19:48:56 1997 Z--- /usr/src/man/man3/Makefile Tue Jul 29 20:26:19 1997 Z*************** Z*** 14,20 **** Z # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED Z # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. Z # Z! # @(#)Makefile 5.4.11 (2.11BSD) 1997/6/27 Z # Z MDIR= /usr/man/cat3 Z SRCS1= abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \ Z--- 14,20 ---- Z # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED Z # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. Z # Z! # @(#)Makefile 5.4.12 (2.11BSD) 1997/7/29 Z # Z MDIR= /usr/man/cat3 Z SRCS1= abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \ Z*************** Z*** 86,92 **** Z sprintf.0 vfprintf.0 vprintf.0 vsprintf.0 alphasort.0 bcmp.0 bcopy.0 \ Z bzero.0 clearerr.0 feof.0 fflush.0 ffs.0 fileno.0 fprintf.0 gamma.0 \ Z getdiskbyname.0 isatty.0 moncontrol.0 monstartup.0 setbuffer.0 \ Z! setlinebuf.0 sys_siglist.0 ttyslot.0 endfsent.0 endgrent.0 \ Z endpwent.0 getfsfile.0 getfsspec.0 getfstype.0 getgrgid.0 Z Z REMO3= getgrnam.0 getpwnam.0 getpwuid.0 setfsent.0 setgrent.0 setpwent.0 \ Z--- 86,92 ---- Z sprintf.0 vfprintf.0 vprintf.0 vsprintf.0 alphasort.0 bcmp.0 bcopy.0 \ Z bzero.0 clearerr.0 feof.0 fflush.0 ffs.0 fileno.0 fprintf.0 gamma.0 \ Z getdiskbyname.0 isatty.0 moncontrol.0 monstartup.0 setbuffer.0 \ Z! setlinebuf.0 setvbuf.o sys_siglist.0 ttyslot.0 endfsent.0 endgrent.0 \ Z endpwent.0 getfsfile.0 getfsspec.0 getfstype.0 getgrgid.0 Z Z REMO3= getgrnam.0 getpwnam.0 getpwuid.0 setfsent.0 setgrent.0 setpwent.0 \ Z*************** Z*** 317,322 **** Z--- 317,323 ---- Z ln ${DESTDIR}${MDIR}/monitor.0 ${DESTDIR}${MDIR}/monstartup.0 Z ln ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setbuffer.0 Z ln ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setlinebuf.0 Z+ ln ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setvbuf.0 Z ln ${DESTDIR}${MDIR}/psignal.0 ${DESTDIR}${MDIR}/sys_siglist.0 Z ln ${DESTDIR}${MDIR}/ttyname.0 ${DESTDIR}${MDIR}/ttyslot.0 Z ln ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/endfsent.0 Z*** /usr/src/old/num.c.old Wed Oct 13 20:22:05 1982 Z--- /usr/src/old/num.c Tue Jul 29 20:09:05 1997 Z*************** Z*** 1,4 **** Z! static char *sccsid = "@(#)num.c 4.2 (Berkeley) 10/13/82"; Z #include Z #define formfeed 0xc Z Z--- 1,7 ---- Z! #if !defined(lint) && defined(DOSCCS) Z! static char *sccsid = "@(#)num.c 4.2.1 (2.11BSD) 1997/7/29"; Z! #endif Z! Z #include Z #define formfeed 0xc Z Z*************** Z*** 9,14 **** Z--- 12,18 ---- Z * Z * Original Version by William Joy, June 1977 Z * Updated October 1979 by M. Kirk McKusick Z+ * Updated to version 4.2 10/13/82 Z */ Z main(ac, av) Z int ac; Z*************** Z*** 21,33 **** Z register FILE *STDOUT = stdout; Z register FILE *STDIN = stdin; Z char line[512]; Z! extern char _sibuf[], _sobuf[]; Z Z argv++; Z argc--; Z lino = 1; Z! setbuf(STDIN,_sibuf); Z! setbuf(STDOUT,_sobuf); Z do Z { Z if (argc) Z--- 25,37 ---- Z register FILE *STDOUT = stdout; Z register FILE *STDIN = stdin; Z char line[512]; Z! char stdobuf[BUFSIZ], stdibuf[BUFSIZ]; Z Z argv++; Z argc--; Z lino = 1; Z! setbuf(STDIN,stdibuf); Z! setbuf(STDOUT,stdobuf); Z do Z { Z if (argc) Z*** /usr/src/ucb/rdist/main.c.old Thu Jul 3 09:00:31 1997 Z--- /usr/src/ucb/rdist/main.c Tue Jul 29 20:34:54 1997 Z*************** Z*** 55,62 **** Z char ebuf[128], obuf[256], ibuf[256]; Z Z setbuffer(stdin, ibuf, sizeof ibuf); Z! setbuffer(stdout, obuf, sizeof obuf); Z! setbuffer(stderr, ebuf, sizeof ebuf); Z Z pw = getpwuid(userid = getuid()); Z if (pw == NULL) { Z--- 55,62 ---- Z char ebuf[128], obuf[256], ibuf[256]; Z Z setbuffer(stdin, ibuf, sizeof ibuf); Z! setvbuf(stdout, obuf, _IOLBF, sizeof obuf); Z! setvbuf(stderr, ebuf, _IOLBF, sizeof ebuf); Z Z pw = getpwuid(userid = getuid()); Z if (pw == NULL) { Z*** /usr/src/usr.bin/Makefile.old Fri Jun 27 19:44:59 1997 Z--- /usr/src/usr.bin/Makefile Sat Jul 26 20:59:29 1997 Z*************** Z*** 1,4 **** Z! # Makefile 1.8 (2.11BSD GTE) 1997/6/27 Z # Z DESTDIR= Z CFLAGS= -O Z--- 1,4 ---- Z! # Makefile 1.9 (2.11BSD GTE) 1997/7/26 Z # Z DESTDIR= Z CFLAGS= -O Z*************** Z*** 6,12 **** Z Z # Programs that live in subdirectories, and have makefiles of their own. Z # Z! SUBDIR= at calendar dc diction diff3 eqn fstat f77 find graph id learn Z lex lint \ Z m4 neqn plot printf prof ranlib ratfor refer roff spell struct tbl \ Z mkerrlst patch \ Z--- 6,12 ---- Z Z # Programs that live in subdirectories, and have makefiles of their own. Z # Z! SUBDIR= at calendar dc diction diff3 eqn fstat f77 find graph id learn \ Z lex lint \ Z m4 neqn plot printf prof ranlib ratfor refer roff spell struct tbl \ Z mkerrlst patch \ Z*** /usr/src/usr.bin/file.c.old Fri Mar 22 21:07:16 1996 Z--- /usr/src/usr.bin/file.c Tue Jul 29 20:15:50 1997 Z*************** Z*** 1,5 **** Z #if !defined(lint) && defined(DOSCCS) Z! static char sccsid[] = "@(#)file.c 4.12.2 (2.11BSD) 1996/3/22"; Z #endif Z /* Z * file - determine type of file Z--- 1,5 ---- Z #if !defined(lint) && defined(DOSCCS) Z! static char sccsid[] = "@(#)file.c 4.12.3 (2.11BSD) 1997/7/29"; Z #endif Z /* Z * file - determine type of file Z*************** Z*** 38,47 **** Z main(argc, argv) Z char **argv; Z { Z! FILE *fl; Z register char *p; Z char ap[MAXPATHLEN + 1]; Z- extern char _sobuf[]; Z Z if (argc < 2) { Z fprintf(stderr, "usage: %s file ...\n", argv[0]); Z--- 38,46 ---- Z main(argc, argv) Z char **argv; Z { Z! register FILE *fl; Z register char *p; Z char ap[MAXPATHLEN + 1]; Z Z if (argc < 2) { Z fprintf(stderr, "usage: %s file ...\n", argv[0]); Z*************** Z*** 79,85 **** Z type(file) Z char *file; Z { Z! int j,nl; Z char ch; Z struct stat mbuf; Z char slink[MAXPATHLEN + 1]; Z--- 78,85 ---- Z type(file) Z char *file; Z { Z! register int j; Z! int nl; Z char ch; Z struct stat mbuf; Z char slink[MAXPATHLEN + 1]; Z*** /usr/src/usr.sbin/lpr/filters/necf.c.old Wed Feb 18 01:10:39 1987 Z--- /usr/src/usr.sbin/lpr/filters/necf.c Tue Jul 29 20:19:32 1997 Z*************** Z*** 4,27 **** Z * specifies the terms and conditions for redistribution. Z */ Z Z! #ifndef lint Z! static char sccsid[] = "@(#)necf.c 5.1 (Berkeley) 5/15/85"; Z! #endif not lint Z Z #include Z #include Z Z #define PAGESIZE 66 Z Z main() Z { Z! extern char _sobuf[BUFSIZ]; Z! extern char *rindex(); Z! char line[256]; Z register char c, *cp; Z register lnumber; Z Z! setbuf(stdout, _sobuf); Z #ifdef SHEETFEEDER Z printf("\033=\033\033\033O\f"); Z #else Z--- 4,26 ---- Z * specifies the terms and conditions for redistribution. Z */ Z Z! #if !defined(lint) && defined(DOSCCS) Z! static char sccsid[] = "@(#)necf.c 5.1.1 (2.11BSD) 1997/7/29"; Z! #endif Z Z #include Z #include Z+ #include Z Z #define PAGESIZE 66 Z Z main() Z { Z! char line[256], stdobuf[BUFSIZ]; Z register char c, *cp; Z register lnumber; Z Z! setbuf(stdout, stdobuf); Z #ifdef SHEETFEEDER Z printf("\033=\033\033\033O\f"); Z #else Z*** /VERSION.old Sun Jul 20 11:16:32 1997 Z--- /VERSION Sun Jul 20 11:16:46 1997 Z*************** Z*** 1,5 **** Z! Current Patch Level: 379 Z! Date: July 8, 1997 Z Z 2.11 BSD Z ============ Z--- 1,5 ---- Z! Current Patch Level: 380 Z! Date: July 20, 1997 Z Z 2.11 BSD Z ============ SHAR_EOF chmod 644 '380.patch' fi if test -f '380.remove' then echo shar: "will not over-write existing file '380.remove'" else sed 's/^Z//' << \SHAR_EOF > '380.remove' Z#!/bin/sh Z Zrm /usr/src/lib/libc/stdio/sibuf.c Zrm /usr/src/lib/libc/stdio/sobuf.c Zrm /usr/src/lib/libc/stdio/setbuf.c Zrm /usr/src/lib/libc/stdio/setbuffer.c Zrm /usr/src/man/man3/setbuf.3 SHAR_EOF chmod 755 '380.remove' fi if test -f '380.shar' then echo shar: "will not over-write existing file '380.shar'" else sed 's/^Z//' << \SHAR_EOF > '380.shar' Z#! /bin/sh Z# This is a shell archive, meaning: Z# 1. Remove everything above the #! /bin/sh line. Z# 2. Save the resulting text in a file. Z# 3. Execute the file with /bin/sh (not csh) to create: Z# /usr/src/lib/libc/stdio/setvbuf.c Z# /usr/src/lib/libc/stdio/setbuf.c Z# /usr/src/lib/libc/stdio/setbuffer.c Z# /usr/src/man/man3/setbuf.3 Z# This archive created: Fri Aug 1 18:38:14 1997 Zexport PATH; PATH=/bin:/usr/bin:$PATH Zif test -f '/usr/src/lib/libc/stdio/setvbuf.c' Zthen Z echo shar: "will not over-write existing file '/usr/src/lib/libc/stdio/setvbuf.c'" Zelse Zsed 's/^V//' << \SHAR_EOF > '/usr/src/lib/libc/stdio/setvbuf.c' ZV/*- ZV * Copyright (c) 1990, 1993 ZV * The Regents of the University of California. All rights reserved. ZV * ZV * This code is derived from software contributed to Berkeley by ZV * Chris Torek. ZV * ZV * Redistribution and use in source and binary forms, with or without ZV * modification, are permitted provided that the following conditions ZV * are met: ZV * 1. Redistributions of source code must retain the above copyright ZV * notice, this list of conditions and the following disclaimer. ZV * 2. Redistributions in binary form must reproduce the above copyright ZV * notice, this list of conditions and the following disclaimer in the ZV * documentation and/or other materials provided with the distribution. ZV * 3. All advertising materials mentioning features or use of this software ZV * must display the following acknowledgement: ZV * This product includes software developed by the University of ZV * California, Berkeley and its contributors. ZV * 4. Neither the name of the University nor the names of its contributors ZV * may be used to endorse or promote products derived from this software ZV * without specific prior written permission. ZV * ZV * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ZV * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ZV * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ZV * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ZV * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ZV * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ZV * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ZV * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ZV * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ZV * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ZV * SUCH DAMAGE. ZV */ ZV ZV#if defined(LIBC_SCCS) && !defined(lint) ZVstatic char sccsid[] = "@(#)setvbuf.c 8.1.1 (2.11BSD) 1997/7/27"; ZV#endif /* LIBC_SCCS and not lint */ ZV ZV#include ZV#include ZV#include ZV ZV/* ZV * This has been slightly trimmed from the 4.4BSD version for use with 2.11BSD. ZV * In particular 1) the flag names were changed back to the original ones ZV * since I didn't feel like porting all of 4.4's stdio package right now and ZV * 2) The constant BUFSIZ is used rather than importing the "optimum buffer ZV * size selection" logic from 4.4 (besides, a PDP11 can't afford more than 1kb ZV * most of the time anyhow). ZV * ZV * Set one of the three kinds of buffering, optionally including ZV * a buffer. ZV */ ZVsetvbuf(fp, buf, mode, size) ZV register FILE *fp; ZV char *buf; ZV register int mode; ZV size_t size; ZV{ ZV int ret; ZV register int flags; ZV ZV/* ZV * Verify arguments. Note, buf and size are ignored when setting _IONBF. ZV */ ZV if (mode != _IONBF) ZV if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0) ZV return (EOF); ZV ZV /* ZV * Write current buffer, if any. Discard unread input, cancel ZV * line buffering, and free old buffer if malloc()ed. ZV */ ZV (void)fflush(fp); ZV fp->_cnt = fp->_bufsiz = 0; ZV flags = fp->_flag; ZV if (flags & _IOMYBUF) ZV free((void *)fp->_base); ZV flags &= ~(_IOLBF | _IONBF | _IOMYBUF); ZV ret = 0; ZV ZV /* If setting unbuffered mode, skip all the hard work. */ ZV if (mode == _IONBF) ZV goto nbf; ZV ZV if (size == 0) { ZV buf = NULL; /* force local allocation */ ZV size = BUFSIZ; ZV } ZV ZV /* Allocate buffer if needed. */ ZV if (buf == NULL) { ZV if ((buf = (char *)malloc(size)) == NULL) { ZV /* ZV * Unable to honor user's request. We will return ZV * failure, but try again with file system size. ZV */ ZV ret = EOF; ZV if (size != BUFSIZ) { ZV size = BUFSIZ; ZV buf = (char *)malloc(size); ZV } ZV } ZV if (buf == NULL) { ZV /* No luck; switch to unbuffered I/O. */ ZVnbf: ZV fp->_flag = flags | _IONBF; ZV fp->_base = fp->_ptr = NULL; ZV return (ret); ZV } ZV flags |= _IOMYBUF; ZV } ZV ZV /* ZV * Fix up the FILE fields. If in r/w mode, go to the unknown state ZV * so that the the first read performs its initial call to _filbuf and ZV * the first write has an empty buffer to fill. ZV */ ZV if (mode == _IOLBF) ZV flags |= _IOLBF; ZV if (flags & _IORW) ZV flags &= ~(_IOREAD | _IOWRT); ZV fp->_flag = flags; ZV fp->_base = fp->_ptr = (char *)buf; ZV fp->_bufsiz = size; ZV return (ret); ZV} ZSHAR_EOF Zfi Zif test -f '/usr/src/lib/libc/stdio/setbuf.c' Zthen Z echo shar: "will not over-write existing file '/usr/src/lib/libc/stdio/setbuf.c'" Zelse Zsed 's/^V//' << \SHAR_EOF > '/usr/src/lib/libc/stdio/setbuf.c' ZV/*- ZV * Copyright (c) 1990, 1993 ZV * The Regents of the University of California. All rights reserved. ZV * ZV * This code is derived from software contributed to Berkeley by ZV * Chris Torek. ZV * ZV * Redistribution and use in source and binary forms, with or without ZV * modification, are permitted provided that the following conditions ZV * are met: ZV * 1. Redistributions of source code must retain the above copyright ZV * notice, this list of conditions and the following disclaimer. ZV * 2. Redistributions in binary form must reproduce the above copyright ZV * notice, this list of conditions and the following disclaimer in the ZV * documentation and/or other materials provided with the distribution. ZV * 3. All advertising materials mentioning features or use of this software ZV * must display the following acknowledgement: ZV * This product includes software developed by the University of ZV * California, Berkeley and its contributors. ZV * 4. Neither the name of the University nor the names of its contributors ZV * may be used to endorse or promote products derived from this software ZV * without specific prior written permission. ZV * ZV * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ZV * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ZV * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ZV * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ZV * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ZV * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ZV * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ZV * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ZV * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ZV * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ZV * SUCH DAMAGE. ZV */ ZV ZV#if defined(LIBC_SCCS) && !defined(lint) ZVstatic char sccsid[] = "@(#)setbuf.c 8.1.1 (2.11BSD) 1997/7/29"; ZV#endif /* LIBC_SCCS and not lint */ ZV ZV#include ZV ZVvoid ZVsetbuf(fp, buf) ZV FILE *fp; ZV char *buf; ZV{ ZV (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); ZV} ZSHAR_EOF Zfi Zif test -f '/usr/src/lib/libc/stdio/setbuffer.c' Zthen Z echo shar: "will not over-write existing file '/usr/src/lib/libc/stdio/setbuffer.c'" Zelse Zsed 's/^V//' << \SHAR_EOF > '/usr/src/lib/libc/stdio/setbuffer.c' ZV/*- ZV * Copyright (c) 1990, 1993 ZV * The Regents of the University of California. All rights reserved. ZV * ZV * This code is derived from software contributed to Berkeley by ZV * Chris Torek. ZV * ZV * Redistribution and use in source and binary forms, with or without ZV * modification, are permitted provided that the following conditions ZV * are met: ZV * 1. Redistributions of source code must retain the above copyright ZV * notice, this list of conditions and the following disclaimer. ZV * 2. Redistributions in binary form must reproduce the above copyright ZV * notice, this list of conditions and the following disclaimer in the ZV * documentation and/or other materials provided with the distribution. ZV * 3. All advertising materials mentioning features or use of this software ZV * must display the following acknowledgement: ZV * This product includes software developed by the University of ZV * California, Berkeley and its contributors. ZV * 4. Neither the name of the University nor the names of its contributors ZV * may be used to endorse or promote products derived from this software ZV * without specific prior written permission. ZV * ZV * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ZV * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ZV * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ZV * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ZV * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ZV * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ZV * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ZV * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ZV * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ZV * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ZV * SUCH DAMAGE. ZV */ ZV ZV#if defined(LIBC_SCCS) && !defined(lint) ZVstatic char sccsid[] = "@(#)setbuffer.c 8.1.1 (2.11BSD) 1997/7/29"; ZV#endif /* LIBC_SCCS and not lint */ ZV ZV#include ZV#include ZV ZVvoid ZVsetbuffer(fp, buf, size) ZV register FILE *fp; ZV char *buf; ZV int size; ZV{ ZV ZV (void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size); ZV} ZV ZV/* ZV * set line buffering ZV */ ZVint ZVsetlinebuf(fp) ZV FILE *fp; ZV{ ZV ZV return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0)); ZV} ZSHAR_EOF Zfi Zif test -f '/usr/src/man/man3/setbuf.3' Zthen Z echo shar: "will not over-write existing file '/usr/src/man/man3/setbuf.3'" Zelse Zsed 's/^V//' << \SHAR_EOF > '/usr/src/man/man3/setbuf.3' ZV.\" Copyright (c) 1980, 1991, 1993 ZV.\" The Regents of the University of California. All rights reserved. ZV.\" ZV.\" This code is derived from software contributed to Berkeley by ZV.\" the American National Standards Committee X3, on Information ZV.\" Processing Systems. ZV.\" ZV.\" Redistribution and use in source and binary forms, with or without ZV.\" modification, are permitted provided that the following conditions ZV.\" are met: ZV.\" 1. Redistributions of source code must retain the above copyright ZV.\" notice, this list of conditions and the following disclaimer. ZV.\" 2. Redistributions in binary form must reproduce the above copyright ZV.\" notice, this list of conditions and the following disclaimer in the ZV.\" documentation and/or other materials provided with the distribution. ZV.\" 3. All advertising materials mentioning features or use of this software ZV.\" must display the following acknowledgement: ZV.\" This product includes software developed by the University of ZV.\" California, Berkeley and its contributors. ZV.\" 4. Neither the name of the University nor the names of its contributors ZV.\" may be used to endorse or promote products derived from this software ZV.\" without specific prior written permission. ZV.\" ZV.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ZV.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ZV.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ZV.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ZV.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ZV.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ZV.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ZV.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ZV.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ZV.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ZV.\" SUCH DAMAGE. ZV.\" ZV.\" @(#)setbuf.3 8.1.1 (2.11BSD) 1997/7/28 ZV.\" ZV.TH SETBUF 3 "July 28, 1997" ZV.UC 4 ZV.SH NAME ZV.BR setbuf , ZV.BR setbuffer , ZV.BR setlinebuf , ZV.BR setvbuf ZV\-stream buffering operations ZV.SH SYNOPSIS ZV.nf ZV.B #include ZV.B #include ZV.sp ZV.B void ZV\fBsetbuf\fP(\fIstream\fP, \fIbuf\fP) ZV.SM ZV\ \ \ \ \ \ \ FILE\ *stream; ZV\ \ \ \ \ \ \ char\ *buf; ZV.sp ZV.B void ZV\fBsetbuffer\fP(\fIstream\fP, \fIbuf\fP, \fIsize\fP) ZV.SM ZV\ \ \ \ \ \ \ FILE\ *stream; ZV\ \ \ \ \ \ \ char\ *buf; ZV\ \ \ \ \ \ \ size_t\ size; ZV.sp ZV.B int ZV\fBsetlinebuf\fP(\fIstream\fP) ZV.SM ZV\ \ \ \ \ \ \ FILE\ *stream; ZV.sp ZV.B int ZV.br ZV\fBsetvbuf\fP(\fIstream\fP, \fIbuf\fP, \fImode\fP, \fIsize\fP) ZV.SM ZV\ \ \ \ \ \ \ FILE\ *stream; ZV\ \ \ \ \ \ \ char\ *buf; ZV\ \ \ \ \ \ \ int\ mode; ZV\ \ \ \ \ \ \ size_t\ size ZV.fi ZV.SH DESCRIPTION ZVThe three types of buffering available are unbuffered, block buffered, ZVand line buffered. ZVWhen an output stream is unbuffered, information appears on the ZVdestination file or terminal as soon as written; ZVwhen it is block buffered many characters are saved up and written as a block; ZVwhen it is line buffered characters are saved up until a newline is ZVoutput or input is read from any stream attached to a terminal device ZV(typically stdin). ZVThe function ZVfflush(3) ZVmay be used to force the block out early. ZV(See fclose(3).) ZV.PP ZVNormally all files are block buffered. ZVWhen the first ZVI/O ZVoperation occurs on a file, ZVmalloc(3) ZVis called, ZVand an optimally-sized buffer is obtained. ZVIf a stream refers to a terminal ZV(as ZV.I stdout ZVnormally does) it is line buffered. ZVThe standard error stream ZV.I stderr ZVis always unbuffered. ZV.PP ZVThe ZV.B setvbuf ZVfunction ZVmay be used to alter the buffering behavior of a stream. ZVThe ZV.I mode ZVparameter must be one of the following three macros: ZV.PP ZV.nf ZV.ta .5i 1.5i ZV _IONBF unbuffered ZV.sp ZV _IOLBF line buffered ZV.sp ZV _IOFBF fully buffered ZV.fi ZV.PP ZVThe ZV.I size ZVparameter may be given as zero ZVto obtain deferred optimal-size buffer allocation as usual. ZVIf it is not zero, ZVthen except for unbuffered files, the ZV.I buf ZVargument should point to a buffer at least ZV.I size ZVbytes long; ZVthis buffer will be used instead of the current buffer. ZV(If the ZV.I size ZVargument ZVis not zero but ZV.I buf ZVis ZVNULL, ZVa buffer of the given size will be allocated immediately, ZVand released on close. ZVThis is an extension to ANSI C; ZVportable code should use a size of 0 with any ZVNULL buffer.) ZV.PP ZVThe ZV.B setvbuf ZVfunction may be used at any time, ZVbut may have peculiar side effects ZV(such as discarding input or flushing output) ZVif the stream is ``active''. ZVPortable applications should call it only once on any given stream, ZVand before any ZVI/O ZVis performed. ZV.PP ZVThe other three calls are, in effect, simply aliases for calls to ZV.BR setvbuf . ZVExcept for the lack of a return value, the ZV.B setbuf ZVfunction is exactly equivalent to the call ZV.PP ZV.in +0.5i ZVsetvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); ZV.in -0.5i ZV.PP ZVThe ZV.B setbuffer ZVfunction ZVis the same, except that the size of the buffer is up to the caller, ZVrather than being determined by the default ZVBUFSIZ. ZVThe ZV.B setlinebuf ZVfunction ZVis exactly equivalent to the call: ZV.PP ZV.in +0.5i ZVsetvbuf(stream, (char *)NULL, _IOLBF, 0); ZV.in -0.5i ZV.SH RETURN VALUES ZVThe ZV.B setvbuf ZVfunction returns 0 on success, or EOF ZVif the request cannot be honored ZV(note that the stream is still functional in this case). ZV.PP ZVThe ZV.B setlinebuf ZVfunction returns what the equivalent ZV.B setvbuf ZVwould have returned. ZV.SH SEE ALSO ZVfopen(3), ZVfclose(3), ZVfread(3), ZVmalloc(3), ZVputs(3), ZVprintf(3) ZV.SH STANDARDS ZVThe ZV.B setbuf ZVand ZV.B setvbuf ZVfunctions ZVconform to ZVANSI C X3.159\-1989 (``ANSI C''). ZV.SH BUGS ZVThe ZV.B setbuffer ZVand ZV.B setlinebuf ZVfunctions are not portable to versions of ZVBSD ZVbefore ZV4.2BSD. ZVOn ZV2BSD ZVsystems, ZV.B setbuf ZValways uses a 1kb buffer size. ZSHAR_EOF Zfi Zexit 0 Z# End of shell archive SHAR_EOF chmod 644 '380.shar' fi if test -f '380.libc' then echo shar: "will not over-write existing file '380.libc'" else sed 's/^Z//' << \SHAR_EOF > '380.libc' Z#!/bin/sh Z Zcd /usr/src/lib/libc/stdio Zmake clean Zmake Zar dv /lib/libc.a sibuf.o sobuf.o Zar dv /usr/lib/libc_p.a sibuf.o sobuf.o Zar rv /lib/libc.a *.o Zcd profiled Zar rv /usr/lib/libc_p.a *.o Zcd .. Zmake clean Zranlib /lib/libc.a /usr/lib/libc_p.a SHAR_EOF chmod 755 '380.libc' fi if test -f '380.utils' then echo shar: "will not over-write existing file '380.utils'" else sed 's/^Z//' << \SHAR_EOF > '380.utils' Z#!/bin/sh Z Zcd /usr/src/bin Zmake who Zinstall -s -m 755 -o root -g bin who /bin/who Z Zcd /usr/src/games/sail Zmake Zmake install Zmake clean Z Zcd ../snake Zmake Zmake install Zmake clean Z Zcd /usr/src/man/man3 Z/usr/man/manroff setbuf.3 > setbuf.0 Zrm -f /usr/man/cat3/setbuf.0 /usr/man/cat3/setbuffer.0 Zrm -f /usr/man/cat3/setlinebuf.0 /usr/man/cat3/setvbuf.0 Zinstall -m 444 -o root -g bin setbuf.0 /usr/man/cat3/setbuf.0 Zln /usr/man/cat3/setbuf.0 /usr/man/cat3/setvbuf.0 Zln /usr/man/cat3/setbuf.0 /usr/man/cat3/setbuffer.0 Zln /usr/man/cat3/setbuf.0 /usr/man/cat3/setlinebuf.0 Z/usr/sbin/makewhatis Z Zcd /usr/src/old Zcc -O -o num num.c Zinstall -s -m 755 num /usr/old Z Zcd /usr/src/ucb/rdist Zmake Zmake install Zmake clean Z Zcd /usr/src/usr.bin Zmake file Zinstall -s -m 755 -o root -g bin file /usr/bin/file Z Zcd /usr/src/usr.sbin/lpr/filters Zmake necf Zinstall -s -m 755 -o root -g bin necf /usr/libexec/lpr/necf SHAR_EOF chmod 755 '380.utils' fi exit 0 # End of shell archive