From 6065a0be1165c4cd506d8eb4a71f22af440fef64 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sat, 30 Dec 1995 19:02:48 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r13122, which included commits to RCS files with non-trunk default branches. --- bin/ed/test/ascii.d | Bin 256 -> 0 bytes bin/ed/test/ascii.r | Bin 256 -> 0 bytes etc/etc.i386/fstab.wd | 3 - etc/man.conf | 34 - etc/namedb/localhost.rev | 10 - gnu/lib/libg++/include/regex.h | 272 - gnu/usr.bin/awk/gawk.texi | 11270 ------------- gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info | 1659 -- gnu/usr.bin/cvs/cvs/config.h | 217 - gnu/usr.bin/cvs/cvs/version.c | 11 - gnu/usr.bin/cvs/doc/cvs.ms | 1073 -- gnu/usr.bin/cvs/lib/Makefile.in | 91 - gnu/usr.bin/cvs/lib/regex.c | 4948 ------ gnu/usr.bin/cvs/lib/y.tab.h | 18 - gnu/usr.bin/cvs/mkmodules/xxx | 5320 ------- gnu/usr.bin/dc/dc.info | 330 - gnu/usr.bin/dc/dc.texinfo | 381 - gnu/usr.bin/diff/fnmatch.h | 69 - gnu/usr.bin/diff3/COPYING | 339 - gnu/usr.bin/diff3/diff3.c | 1693 -- gnu/usr.bin/diff3/getopt.c | 731 - gnu/usr.bin/diff3/getopt.h | 129 - gnu/usr.bin/diff3/getopt1.c | 176 - gnu/usr.bin/diff3/system.h | 159 - gnu/usr.bin/diff3/version.c | 3 - gnu/usr.bin/grep/tests/regress.sh | 30 - gnu/usr.bin/groff/eqn/eqn.cc | 1162 -- gnu/usr.bin/groff/eqn/eqn.tab.h | 67 - gnu/usr.bin/groff/pic/pic.cc | 5166 ------ gnu/usr.bin/groff/pic/pic.tab.h | 129 - gnu/usr.bin/groff/refer/label.cc | 1593 -- gnu/usr.bin/gzip/zcmp | 67 - gnu/usr.bin/pr/COPYING | 339 - gnu/usr.bin/pr/getopt.h | 129 - gnu/usr.bin/pr/version.h | 1 - gnu/usr.bin/ptx/ptx.info | 496 - gnu/usr.bin/ptx/ptx.texinfo | 554 - gnu/usr.bin/tar/regex.h | 490 - gnu/usr.bin/tar/y.tab.h | 18 - gnu/usr.bin/texinfo/info-files/info-stnd.info | 1259 -- gnu/usr.bin/texinfo/info-files/info.info | 777 - gnu/usr.bin/texinfo/info-files/makeinfo.info | 224 - .../texinfo/info-files/texi-files/info-stnd.texi | 1359 -- .../texinfo/info-files/texi-files/info.texi | 861 - .../texinfo/info-files/texi-files/makeinfo.texi | 285 - .../texinfo/info-files/texi-files/texi.texi | 15626 ------------------- .../texinfo/info-files/texi-files/userdoc.texi | 1263 -- gnu/usr.bin/texinfo/info-files/texi.info | 297 - gnu/usr.bin/texinfo/info-files/texi.info-1 | 1131 -- gnu/usr.bin/texinfo/info-files/texi.info-10 | 1165 -- gnu/usr.bin/texinfo/info-files/texi.info-11 | 451 - gnu/usr.bin/texinfo/info-files/texi.info-2 | 1289 -- gnu/usr.bin/texinfo/info-files/texi.info-3 | 1262 -- gnu/usr.bin/texinfo/info-files/texi.info-4 | 1412 -- gnu/usr.bin/texinfo/info-files/texi.info-5 | 1433 -- gnu/usr.bin/texinfo/info-files/texi.info-6 | 1461 -- gnu/usr.bin/texinfo/info-files/texi.info-7 | 1307 -- gnu/usr.bin/texinfo/info-files/texi.info-8 | 1056 -- gnu/usr.bin/texinfo/info-files/texi.info-9 | 1210 -- gnu/usr.bin/texinfo/info/info-stnd.info | 1259 -- gnu/usr.bin/texinfo/info/info.info | 777 - gnu/usr.bin/texinfo/misc/texindex.c | 1700 -- include/tzfile.h | 151 - lib/csu/i386/gprof.ex | 3 - lib/libc/compat-43/setregid.2 | 93 - lib/libc/compat-43/setregid.c | 62 - lib/libc/compat-43/setreuid.2 | 91 - lib/libc/compat-43/setreuid.c | 62 - lib/libc/gen/ctime.3 | 258 - lib/libc/gen/ctime.c | 1381 -- lib/libc/gen/difftime.c | 45 - lib/libc/gen/sigsetjmp.c | 61 - lib/libc/i386/gen/_setjmp.s | 78 - lib/libc/i386/gen/alloca.s | 57 - lib/libc/i386/gen/divsi3.s | 46 - lib/libc/i386/gen/fabs.s | 46 - lib/libc/i386/gen/fixdfsi.s | 46 - lib/libc/i386/gen/fixunsdfsi.s | 60 - lib/libc/i386/gen/modf.s | 75 - lib/libc/i386/gen/setjmp.s | 86 - lib/libc/i386/gen/udivsi3.s | 46 - lib/libc/i386/net/htonl.s | 50 - lib/libc/i386/net/htons.s | 48 - lib/libc/i386/net/ntohl.s | 50 - lib/libc/i386/net/ntohs.s | 48 - lib/libc/i386/stdlib/abs.s | 48 - lib/libc/i386/string/bzero.s | 53 - lib/libc/i386/sys/Ovfork.s | 70 - lib/libc/i386/sys/brk.s | 65 - lib/libc/i386/sys/cerror.s | 47 - lib/libc/i386/sys/exect.s | 52 - lib/libc/i386/sys/fork.s | 48 - lib/libc/i386/sys/mount.s | 45 - lib/libc/i386/sys/pipe.s | 48 - lib/libc/i386/sys/ptrace.s | 51 - lib/libc/i386/sys/reboot.s | 44 - lib/libc/i386/sys/sbrk.s | 65 - lib/libc/i386/sys/setlogin.s | 47 - lib/libc/i386/sys/sigpending.s | 47 - lib/libc/i386/sys/sigprocmask.s | 64 - lib/libc/i386/sys/sigreturn.s | 54 - lib/libc/i386/sys/sigsuspend.s | 54 - lib/libc/i386/sys/syscall.s | 51 - lib/libc/net/getnetbyname.c | 62 - lib/libc/net/getnetent.c | 121 - lib/libc/net/sethostent.c | 56 - lib/libc/stdlib/free.3 | 81 - lib/libc/stdlib/realloc.3 | 99 - lib/libc/stdtime/localtime.c.ORIG | 1530 -- lib/libc/string/strftime.3 | 186 - lib/libc/string/strftime.c | 292 - lib/libcompat/regexp/regexp.h | 21 - lib/libedit/histedit.h | 172 - lib/libedit/termcap.h | 52 - lib/librpc/DISCLAIMER | 28 - lib/librpc/Makefile | 30 - lib/librpc/README | 233 - lib/librpc/demo/Makefile | 25 - lib/librpc/demo/dir/Makefile | 26 - lib/librpc/demo/dir/dir.x | 37 - lib/librpc/demo/dir/dir_proc.c | 55 - lib/librpc/demo/dir/rls.c | 81 - lib/librpc/demo/msg/Makefile | 36 - lib/librpc/demo/msg/msg.x | 9 - lib/librpc/demo/msg/msg_proc.c | 28 - lib/librpc/demo/msg/printmsg.c | 43 - lib/librpc/demo/msg/rprintmsg.c | 74 - lib/librpc/demo/sort/Makefile | 36 - lib/librpc/demo/sort/rsort.c | 43 - lib/librpc/demo/sort/sort.x | 19 - lib/librpc/demo/sort/sort_proc.c | 27 - lib/librpc/doc/Makefile | 84 - lib/librpc/doc/nfs.rfc.ms | 1372 -- lib/librpc/doc/rpc.prog.ms | 2684 ---- lib/librpc/doc/rpc.rfc.ms | 1302 -- lib/librpc/doc/rpcgen.ms | 1299 -- lib/librpc/doc/xdr.nts.ms | 1966 --- lib/librpc/doc/xdr.rfc.ms | 1058 -- lib/librpc/etc/Makefile | 74 - lib/librpc/etc/getopt.c | 75 - lib/librpc/etc/portmap.c | 481 - lib/librpc/etc/rpc | 33 - lib/librpc/etc/rpcinfo.c | 665 - lib/librpc/man/man1/rpcgen.1 | 197 - lib/librpc/man/man1/rstat.1 | 57 - lib/librpc/man/man3/bindresvport.3n | 27 - lib/librpc/man/man3/getrpcent.3n | 109 - lib/librpc/man/man3/getrpcport.3r | 31 - lib/librpc/man/man3/rpc.3n | 1729 -- lib/librpc/man/man3/xdr.3n | 823 - lib/librpc/man/man5/rpc.5 | 71 - lib/librpc/man/man8/portmap.8c | 53 - lib/librpc/man/man8/rpcinfo.8c | 183 - lib/librpc/man/man8/rstat_svc.8c | 21 - lib/librpc/rpc/auth.h | 166 - lib/librpc/rpc/auth_none.c | 133 - lib/librpc/rpc/auth_unix.c | 337 - lib/librpc/rpc/auth_unix.h | 72 - lib/librpc/rpc/authunix_prot.c | 66 - lib/librpc/rpc/bindresvport.c | 79 - lib/librpc/rpc/clnt.h | 331 - lib/librpc/rpc/clnt_generic.c | 110 - lib/librpc/rpc/clnt_perror.c | 302 - lib/librpc/rpc/clnt_raw.c | 238 - lib/librpc/rpc/clnt_simple.c | 112 - lib/librpc/rpc/clnt_tcp.c | 466 - lib/librpc/rpc/clnt_udp.c | 442 - lib/librpc/rpc/get_myaddress.c | 96 - lib/librpc/rpc/getrpcent.c | 235 - lib/librpc/rpc/getrpcport.c | 55 - lib/librpc/rpc/pmap_clnt.c | 115 - lib/librpc/rpc/pmap_clnt.h | 65 - lib/librpc/rpc/pmap_getmaps.c | 84 - lib/librpc/rpc/pmap_getport.c | 87 - lib/librpc/rpc/pmap_prot.c | 57 - lib/librpc/rpc/pmap_prot.h | 94 - lib/librpc/rpc/pmap_prot2.c | 116 - lib/librpc/rpc/pmap_rmt.c | 395 - lib/librpc/rpc/pmap_rmt.h | 53 - lib/librpc/rpc/rpc.h | 80 - lib/librpc/rpc/rpc_callmsg.c | 190 - lib/librpc/rpc/rpc_commondata.c | 41 - lib/librpc/rpc/rpc_dtablesize.c | 46 - lib/librpc/rpc/rpc_msg.h | 187 - lib/librpc/rpc/rpc_prot.c | 289 - lib/librpc/rpc/svc.c | 479 - lib/librpc/rpc/svc.h | 280 - lib/librpc/rpc/svc_auth.c | 114 - lib/librpc/rpc/svc_auth.h | 42 - lib/librpc/rpc/svc_auth_unix.c | 134 - lib/librpc/rpc/svc_raw.c | 166 - lib/librpc/rpc/svc_run.c | 72 - lib/librpc/rpc/svc_simple.c | 143 - lib/librpc/rpc/svc_tcp.c | 419 - lib/librpc/rpc/svc_udp.c | 477 - lib/librpc/rpc/types.h | 63 - lib/librpc/rpc/xdr.c | 576 - lib/librpc/rpc/xdr.h | 270 - lib/librpc/rpc/xdr_array.c | 153 - lib/librpc/rpc/xdr_float.c | 267 - lib/librpc/rpc/xdr_mem.c | 184 - lib/librpc/rpc/xdr_rec.c | 583 - lib/librpc/rpc/xdr_reference.c | 132 - lib/librpc/rpc/xdr_stdio.c | 189 - lib/librpc/rpcgen/Makefile | 60 - lib/librpc/rpcgen/rpc_clntout.c | 126 - lib/librpc/rpcgen/rpc_cout.c | 350 - lib/librpc/rpcgen/rpc_hout.c | 370 - lib/librpc/rpcgen/rpc_main.c | 433 - lib/librpc/rpcgen/rpc_parse.c | 419 - lib/librpc/rpcgen/rpc_parse.h | 157 - lib/librpc/rpcgen/rpc_scan.c | 473 - lib/librpc/rpcgen/rpc_scan.h | 101 - lib/librpc/rpcgen/rpc_svcout.c | 275 - lib/librpc/rpcgen/rpc_util.c | 436 - lib/librpc/rpcgen/rpc_util.h | 114 - lib/librpc/rpcsvc/Makefile | 80 - lib/librpc/rpcsvc/bootparam_prot.x | 97 - lib/librpc/rpcsvc/klm_prot.x | 132 - lib/librpc/rpcsvc/mount.x | 161 - lib/librpc/rpcsvc/nfs_prot.x | 355 - lib/librpc/rpcsvc/nlm_prot.x | 179 - lib/librpc/rpcsvc/rex.x | 229 - lib/librpc/rpcsvc/rnusers.x | 86 - lib/librpc/rpcsvc/rquota.x | 61 - lib/librpc/rpcsvc/rstat.c | 85 - lib/librpc/rpcsvc/rstat.x | 145 - lib/librpc/rpcsvc/rstat_proc.c | 352 - lib/librpc/rpcsvc/sm_inter.x | 116 - lib/librpc/rpcsvc/spray.x | 84 - lib/librpc/rpcsvc/yp.x | 291 - lib/librpc/rpcsvc/yppasswd.x | 63 - lib/librpc/secure_rpc/README | 92 - lib/librpc/secure_rpc/bin/Makefile | 50 - lib/librpc/secure_rpc/bin/chkey.c | 302 - lib/librpc/secure_rpc/bin/keylogin.c | 66 - lib/librpc/secure_rpc/demo/Makefile | 28 - lib/librpc/secure_rpc/demo/rme.c | 96 - lib/librpc/secure_rpc/demo/whoami.x | 33 - lib/librpc/secure_rpc/demo/whoami_proc.c | 95 - lib/librpc/secure_rpc/des/des.h | 68 - lib/librpc/secure_rpc/des/des_crypt.c | 138 - lib/librpc/secure_rpc/des/des_crypt.h | 101 - lib/librpc/secure_rpc/des/des_soft.c | 67 - lib/librpc/secure_rpc/doc/Makefile | 40 - lib/librpc/secure_rpc/doc/nfs.secure.ms | 934 -- lib/librpc/secure_rpc/keyserv/Makefile | 49 - lib/librpc/secure_rpc/keyserv/detach.c | 69 - lib/librpc/secure_rpc/keyserv/keyenvoy.c | 213 - lib/librpc/secure_rpc/keyserv/keyserv.c | 458 - lib/librpc/secure_rpc/keyserv/mp.c | 145 - lib/librpc/secure_rpc/keyserv/setkey.c | 514 - lib/librpc/secure_rpc/man/chkey.1 | 19 - lib/librpc/secure_rpc/man/des_crypt.3 | 126 - lib/librpc/secure_rpc/man/keyenvoy.8c | 22 - lib/librpc/secure_rpc/man/keylogin.1 | 32 - lib/librpc/secure_rpc/man/keyserv.8c | 52 - lib/librpc/secure_rpc/man/publickey.3r | 44 - lib/librpc/secure_rpc/man/publickey.5 | 37 - lib/librpc/secure_rpc/man/rpc_secure.3n | 330 - lib/librpc/secure_rpc/man/rtime.3n | 43 - lib/librpc/secure_rpc/rpc/Makefile | 109 - lib/librpc/secure_rpc/rpc/auth_des.c | 411 - lib/librpc/secure_rpc/rpc/auth_des.h | 105 - lib/librpc/secure_rpc/rpc/authdes_prot.c | 82 - lib/librpc/secure_rpc/rpc/key_call.c | 228 - lib/librpc/secure_rpc/rpc/key_prot.c | 165 - lib/librpc/secure_rpc/rpc/key_prot.h | 114 - lib/librpc/secure_rpc/rpc/key_prot.x | 151 - lib/librpc/secure_rpc/rpc/netname.c | 239 - lib/librpc/secure_rpc/rpc/openchild.c | 133 - lib/librpc/secure_rpc/rpc/publickey.c | 129 - lib/librpc/secure_rpc/rpc/rtime.c | 141 - lib/librpc/secure_rpc/rpc/svc_auth.c | 116 - lib/librpc/secure_rpc/rpc/svcauth_des.c | 519 - lib/librpc/secure_rpc/rpc/xcrypt.c | 183 - lib/libtelnet/auth-proto.h | 96 - lib/libtelnet/auth.c | 658 - lib/libtelnet/auth.h | 87 - lib/libtelnet/enc-proto.h | 125 - lib/libtelnet/enc_des.c | 724 - lib/libtelnet/encrypt.c | 999 -- lib/libtelnet/encrypt.h | 108 - lib/libtelnet/kerberos.c | 554 - lib/libtelnet/kerberos5.c | 762 - lib/libtelnet/key-proto.h | 71 - lib/libtelnet/krb4encpwd.c | 446 - lib/libtelnet/read_password.c | 145 - lib/libtelnet/rsaencpwd.c | 492 - lib/libtelnet/spx.c | 588 - lib/libterm/TEST/tc1.c | 63 - lib/libterm/TEST/tc2.c | 90 - lib/libterm/TEST/tc3.c | 112 - lib/libterm/pathnames.h | 36 - lib/libterm/termcap.3 | 254 - lib/libterm/termcap.c | 208 - lib/libterm/tgoto.c | 207 - lib/libterm/tputs.c | 123 - libexec/bugfiler/bug.h | 92 - libexec/bugfiler/bugfiler.8 | 290 - libexec/bugfiler/bugfiler.c | 167 - libexec/bugfiler/bugformat | 32 - libexec/bugfiler/error.c | 89 - libexec/bugfiler/extern.h | 41 - libexec/bugfiler/gethead.c | 165 - libexec/bugfiler/pathnames.h | 38 - libexec/bugfiler/process.c | 115 - libexec/bugfiler/redist.c | 131 - libexec/bugfiler/reply.c | 118 - libexec/bugfiler/sendbug.1 | 85 - libexec/bugfiler/sendbug.sh | 66 - libexec/getty/extern.h | 56 - libexec/getty/ttydefaults.c | 54 - libexec/kpasswdd/kpasswdd.8 | 60 - libexec/kpasswdd/kpasswdd.c | 271 - libexec/telnetd/authenc.c | 91 - sbin/disklabel/disklabel.5.5 | 384 - sbin/fastboot/fastboot.8 | 69 - sbin/scsiformat/scsiformat.c | 664 - secure/usr.bin/telnet/krb4-proto.h | 207 - share/doc/psd/00.contents | 191 - share/doc/psd/Title | 131 - share/doc/smm/00.contents | 161 - share/doc/smm/Title | 203 - share/doc/usd/00.contents | 262 - share/doc/usd/Title | 120 - share/man/man8/adduser.8 | 115 - share/tabset/3101 | 1 - share/tabset/9837 | 1 - share/tabset/aa | 1 - share/tabset/aed512 | 1 - share/tabset/beehive | 2 - share/tabset/diablo | 3 - share/tabset/dtc382 | 1 - share/tabset/hp700-wy | Bin 105 -> 0 bytes share/tabset/ibm3101 | 1 - share/tabset/std | 1 - share/tabset/stdcrt | 1 - share/tabset/tandem653 | 1 - share/tabset/teleray | 1 - share/tabset/vt100 | 1 - share/tabset/vt100-w | 1 - share/tabset/wyse-adds | 3 - share/tabset/xerox1720 | 1 - share/tabset/zenith29 | 1 - share/tmac/README | 145 - share/tmac/doc | 3456 ---- share/tmac/doc-common | 432 - share/tmac/doc-ditroff | 269 - share/tmac/doc-nroff | 225 - share/tmac/doc-syms | 238 - share/tmac/strip.sed | 44 - share/tmac/tmac.andoc | 54 - share/tmac/tmac.doc.old | 1833 --- share/tmac/tmac.e | 41 - share/tmac/tmac.s | 41 - share/tmac/tmac.sU | 46 - sys/i386/ibcs2/ibcs2_timeb.h | 45 - usr.bin/apropos/Makefile | 7 - usr.bin/apropos/apropos.1 | 120 - usr.bin/apropos/apropos.c | 223 - usr.bin/ar/ar.5.5 | 145 - usr.bin/bdes/Makefile | 5 - usr.bin/bdes/bdes.1 | 304 - usr.bin/bdes/bdes.c | 1046 -- usr.bin/bdes/bdes.ps | 2945 ---- usr.bin/chat/fix-cua | 16 - usr.bin/compress/zcat.sh | 37 - usr.bin/diff/diff/diff.1 | 387 - usr.bin/diff/diff3/diff3.1 | 172 - usr.bin/ee/ee.msg | 170 - usr.bin/grep/egrep/egrep.c | 924 -- usr.bin/grep/egrep/grep.1 | 250 - usr.bin/grep/egrep/pathnames.h | 40 - usr.bin/ld/Makefile | 7 - usr.bin/ld/cplus-dem.c | 970 -- usr.bin/ld/ld.c | 4718 ------ usr.bin/ld/symseg.h | 358 - usr.bin/lex/flex.1 | 1001 -- usr.bin/lex/flexdoc.1 | 3045 ---- usr.bin/m4/serv.c | 475 - usr.bin/man/Makefile | 8 - usr.bin/man/config.c | 174 - usr.bin/man/config.h | 57 - usr.bin/man/man.1 | 188 - usr.bin/man/man.c | 712 - usr.bin/man/man.conf | 46 - usr.bin/man/man.conf.5 | 195 - usr.bin/man/pathnames.h | 39 - usr.bin/mklocale/Japanese | 158 - usr.bin/ncftp/Makefile.ORIG | 287 - usr.bin/ncftp/v2_Note | 35 - usr.bin/passwd/kpasswd_proto.h | 54 - usr.bin/passwd/krb_passwd.c | 319 - usr.bin/patch/EXTERN.h | 15 - usr.bin/patch/INTERN.h | 15 - usr.bin/patch/Makefile | 6 - usr.bin/patch/README | 79 - usr.bin/patch/common.h | 138 - usr.bin/patch/config.h | 16 - usr.bin/patch/inp.c | 313 - usr.bin/patch/inp.h | 18 - usr.bin/patch/patch.1 | 446 - usr.bin/patch/patch.c | 800 - usr.bin/patch/patchlevel.h | 1 - usr.bin/patch/pch.c | 1108 -- usr.bin/patch/pch.h | 36 - usr.bin/patch/util.c | 339 - usr.bin/patch/util.h | 74 - usr.bin/patch/version.c | 28 - usr.bin/patch/version.h | 9 - usr.bin/ranlib/ranlib.5.5 | 70 - usr.bin/rlogin/des_rw.c | 203 - usr.bin/sccs/Makefile | 5 - usr.bin/sccs/PSD.doc/Makefile | 10 - usr.bin/sccs/PSD.doc/sccs.me | 1608 -- usr.bin/sccs/PSD.doc/spell.ok | 77 - usr.bin/sccs/pathnames.h | 51 - usr.bin/sccs/sccs.1 | 398 - usr.bin/sccs/sccs.c | 1621 -- usr.bin/sort/sort.1 | 310 - usr.bin/tip/acu.c | 196 - usr.bin/tip/aculib/biz22.c | 187 - usr.bin/tip/aculib/biz31.c | 248 - usr.bin/tip/aculib/courier.c | 380 - usr.bin/tip/aculib/df.c | 132 - usr.bin/tip/aculib/dn11.c | 142 - usr.bin/tip/aculib/hayes.c | 305 - usr.bin/tip/aculib/t3000.c | 408 - usr.bin/tip/aculib/v3451.c | 214 - usr.bin/tip/aculib/v831.c | 259 - usr.bin/tip/aculib/ventel.c | 251 - usr.bin/tip/acutab.c | 97 - usr.bin/tip/cmds.c | 888 -- usr.bin/tip/cmdtab.c | 64 - usr.bin/tip/cu.c | 132 - usr.bin/tip/hunt.c | 93 - usr.bin/tip/log.c | 86 - usr.bin/tip/partab.c | 58 - usr.bin/tip/remcap.c | 426 - usr.bin/tip/remote.c | 226 - usr.bin/tip/tip.1 | 451 - usr.bin/tip/value.c | 353 - usr.bin/tip/vars.c | 112 - usr.bin/uucp/acucntrl/acucntrl.c | 814 - usr.bin/uucp/uupoll/uupoll.8 | 111 - usr.bin/uucp/uupoll/uupoll.c | 129 - usr.bin/uucp/uuq/Makefile | 9 - usr.bin/uucp/uuq/uuq.1 | 126 - usr.bin/uucp/uuq/uuq.c | 435 - usr.bin/uucp/uusend/Makefile | 6 - usr.bin/uucp/uusend/uusend.1 | 96 - usr.bin/uucp/uusend/uusend.c | 403 - usr.bin/uucp/uusnap/uusnap.8 | 80 - usr.bin/uucp/uusnap/uusnap.c | 348 - usr.bin/whatis/Makefile | 7 - usr.bin/whatis/whatis.1 | 105 - usr.bin/whatis/whatis.c | 218 - usr.bin/which/which.sh | 62 - usr.sbin/arp/arp4.4 | 124 - usr.sbin/bootpd/Announce | 63 - usr.sbin/bootpd/Changes | 245 - usr.sbin/bootpd/ConvOldTab.sh | 141 - usr.sbin/bootpd/Installation | 29 - usr.sbin/bootpd/Makefile.UNIX | 184 - usr.sbin/bootpd/Problems | 47 - usr.sbin/bootpd/README | 133 - usr.sbin/bootpd/bootp.h | 147 - usr.sbin/bootpd/bootpd.8 | 305 - usr.sbin/bootpd/bootpd.c | 1380 -- usr.sbin/bootpd/bootpd.h | 211 - usr.sbin/bootpd/bootpef.8 | 52 - usr.sbin/bootpd/bootpef.c | 347 - usr.sbin/bootpd/bootpgw.c | 675 - usr.sbin/bootpd/bootptab.5 | 395 - usr.sbin/bootpd/bootptab.cmu | 124 - usr.sbin/bootpd/bootptab.mcs | 92 - usr.sbin/bootpd/bootptest.8 | 74 - usr.sbin/bootpd/bootptest.c | 500 - usr.sbin/bootpd/bootptest.h | 30 - usr.sbin/bootpd/bptypes.h | 23 - usr.sbin/bootpd/dovend.c | 413 - usr.sbin/bootpd/dovend.h | 13 - usr.sbin/bootpd/dumptab.c | 382 - usr.sbin/bootpd/getif.c | 145 - usr.sbin/bootpd/getif.h | 7 - usr.sbin/bootpd/hash.c | 425 - usr.sbin/bootpd/hash.h | 158 - usr.sbin/bootpd/hwaddr.h | 39 - usr.sbin/bootpd/lookup.c | 126 - usr.sbin/bootpd/lookup.h | 15 - usr.sbin/bootpd/patchlevel.h | 3 - usr.sbin/bootpd/print-bootp.c | 493 - usr.sbin/bootpd/readfile.c | 2097 --- usr.sbin/bootpd/readfile.h | 19 - usr.sbin/bootpd/report.c | 154 - usr.sbin/bootpd/report.h | 13 - usr.sbin/bootpd/syslog.conf | 63 - usr.sbin/bootpd/trygetea.c | 46 - usr.sbin/bootpd/trygetif.c | 68 - usr.sbin/bootpd/trylook.c | 50 - usr.sbin/bootpd/tzone.c | 44 - usr.sbin/bootpd/tzone.h | 3 - usr.sbin/sliplogin/slip.hosts | 11 - usr.sbin/sliplogin/slip.login | 12 - usr.sbin/tcpdump/tcpdump/bpf_image.c | 282 - usr.sbin/tcpdump/tcpdump/etherent.c | 144 - usr.sbin/tcpdump/tcpdump/etherent.h | 34 - usr.sbin/tcpdump/tcpdump/etherproto.h | 70 - usr.sbin/tcpdump/tcpdump/gencode.c | 1384 -- usr.sbin/tcpdump/tcpdump/gencode.h | 156 - usr.sbin/tcpdump/tcpdump/inet.c | 172 - usr.sbin/tcpdump/tcpdump/md.c | 35 - usr.sbin/tcpdump/tcpdump/nametoaddr.c | 258 - usr.sbin/tcpdump/tcpdump/nametoaddr.h | 43 - usr.sbin/tcpdump/tcpdump/optimize.c | 1871 --- usr.sbin/tcpdump/tcpdump/os.c | 26 - usr.sbin/tcpdump/tcpdump/pcap.c | 209 - usr.sbin/tcpdump/tcpdump/savefile.c | 303 - usr.sbin/tcpdump/tcpdump/savefile.h | 75 - usr.sbin/tcpdump/tcpdump/tcpgram.y | 232 - usr.sbin/update/Makefile | 6 - usr.sbin/update/update.8 | 74 - usr.sbin/update/update.c | 75 - usr.sbin/xntpd/Config | 200 - usr.sbin/xntpd/Config.local | 198 - usr.sbin/xntpd/Config.local.dist | 198 - usr.sbin/xntpd/Config.sed | 14 - usr.sbin/xntpd/adjtime/Makefile.tmpl | 53 - usr.sbin/xntpd/adjtime/README | 23 - usr.sbin/xntpd/adjtime/adjtime.c | 101 - usr.sbin/xntpd/adjtime/adjtime.h | 63 - usr.sbin/xntpd/adjtime/adjtimed.c | 496 - usr.sbin/xntpd/authstuff/Makefile.tmpl | 92 - usr.sbin/xntpd/clockstuff/Makefile.tmpl | 60 - usr.sbin/xntpd/compilers/README | 5 - usr.sbin/xntpd/compilers/aux2.gcc | 1 - usr.sbin/xntpd/compilers/aux3.gcc | 1 - usr.sbin/xntpd/compilers/decosf1.gcc | 1 - usr.sbin/xntpd/compilers/domainos.cc | 1 - usr.sbin/xntpd/compilers/hpux-adj.cc | 1 - usr.sbin/xntpd/compilers/hpux-adj.gcc | 1 - usr.sbin/xntpd/compilers/hpux.cc | 1 - usr.sbin/xntpd/compilers/hpux.gcc | 1 - usr.sbin/xntpd/compilers/hpux10+.cc | 1 - usr.sbin/xntpd/compilers/irix4.cc | 2 - usr.sbin/xntpd/compilers/linux.gcc | 2 - usr.sbin/xntpd/compilers/mips.cc | 1 - usr.sbin/xntpd/compilers/sinix-m.cc | 1 - usr.sbin/xntpd/compilers/sinix-m.gcc | 2 - usr.sbin/xntpd/compilers/sunos4.bsd.cc | 1 - usr.sbin/xntpd/compilers/sunos4.bsd.gcc | 1 - usr.sbin/xntpd/compilers/sunos4.posix.gcc | 1 - usr.sbin/xntpd/compilers/sunos5.1.gcc | 2 - usr.sbin/xntpd/compilers/sunos5.2.gcc | 2 - usr.sbin/xntpd/compilers/ultrix.bsd.cc | 2 - usr.sbin/xntpd/compilers/ultrix.bsd.gcc | 1 - usr.sbin/xntpd/compilers/ultrix.posix.cc | 2 - usr.sbin/xntpd/compilers/ultrix.posix.gcc | 1 - usr.sbin/xntpd/gadget/README | 84 - usr.sbin/xntpd/gadget/adt0127.lpr | 1427 -- usr.sbin/xntpd/gadget/art01.lpr | 890 -- usr.sbin/xntpd/gadget/art02.lpr | 893 -- usr.sbin/xntpd/gadget/dd0124.lpr | 813 - usr.sbin/xntpd/gadget/gadget.lst | 332 - usr.sbin/xntpd/gadget/gadget.s01 | 2277 --- usr.sbin/xntpd/gadget/gadget.s02 | 288 - usr.sbin/xntpd/gadget/gen0102.lpr | 1973 --- usr.sbin/xntpd/gadget/sm0228.lpr | 744 - usr.sbin/xntpd/gadget/sst0126.lpr | 1118 -- usr.sbin/xntpd/hints/README | 12 - usr.sbin/xntpd/hints/aux | 159 - usr.sbin/xntpd/hints/bsdi | 61 - usr.sbin/xntpd/hints/decosf1 | 40 - usr.sbin/xntpd/hints/hpux | 92 - usr.sbin/xntpd/hints/linux | 9 - usr.sbin/xntpd/hints/notes-xntp-v3 | 119 - usr.sbin/xntpd/hints/parse | 105 - usr.sbin/xntpd/hints/refclocks | 32 - usr.sbin/xntpd/hints/rs6000 | 56 - usr.sbin/xntpd/hints/sgi | 74 - usr.sbin/xntpd/hints/solaris | 87 - usr.sbin/xntpd/hints/sun4 | 17 - usr.sbin/xntpd/hints/svr4-dell | 6 - usr.sbin/xntpd/kernel/Makefile.tmpl | 59 - usr.sbin/xntpd/kernel/README | 90 - usr.sbin/xntpd/kernel/README.streams | 86 - usr.sbin/xntpd/kernel/tty_chu.c | 276 - usr.sbin/xntpd/kernel/tty_chu_STREAMS.c | 603 - usr.sbin/xntpd/kernel/tty_clk.c | 317 - usr.sbin/xntpd/kernel/tty_clk_STREAMS.c | 266 - usr.sbin/xntpd/lib/Makefile.tmpl | 75 - usr.sbin/xntpd/lib/authdes.c | 845 - usr.sbin/xntpd/machines/README | 5 - usr.sbin/xntpd/machines/aix3.2 | 10 - usr.sbin/xntpd/machines/aux2 | 9 - usr.sbin/xntpd/machines/aux3 | 9 - usr.sbin/xntpd/machines/bsdi | 8 - usr.sbin/xntpd/machines/convexos10 | 10 - usr.sbin/xntpd/machines/convexos9 | 9 - usr.sbin/xntpd/machines/decosf1 | 9 - usr.sbin/xntpd/machines/dell.svr4 | 9 - usr.sbin/xntpd/machines/domainos | 7 - usr.sbin/xntpd/machines/freebsd | 8 - usr.sbin/xntpd/machines/hpux | 8 - usr.sbin/xntpd/machines/hpux-adj | 8 - usr.sbin/xntpd/machines/hpux10+ | 8 - usr.sbin/xntpd/machines/i386 | 7 - usr.sbin/xntpd/machines/i386svr4 | 9 - usr.sbin/xntpd/machines/irix4 | 9 - usr.sbin/xntpd/machines/irix5 | 9 - usr.sbin/xntpd/machines/linux | 8 - usr.sbin/xntpd/machines/mips | 9 - usr.sbin/xntpd/machines/netbsd | 8 - usr.sbin/xntpd/machines/next | 9 - usr.sbin/xntpd/machines/ptx | 8 - usr.sbin/xntpd/machines/sequent | 8 - usr.sbin/xntpd/machines/sinix-m | 11 - usr.sbin/xntpd/machines/sony | 6 - usr.sbin/xntpd/machines/sunos4.bsd | 11 - usr.sbin/xntpd/machines/sunos4.posix | 11 - usr.sbin/xntpd/machines/sunos5.1 | 11 - usr.sbin/xntpd/machines/sunos5.2 | 11 - usr.sbin/xntpd/machines/svr4 | 10 - usr.sbin/xntpd/machines/ultrix.bsd | 7 - usr.sbin/xntpd/machines/ultrix.posix | 7 - usr.sbin/xntpd/machines/univel | 10 - usr.sbin/xntpd/machines/unixware1 | 10 - usr.sbin/xntpd/machines/vax | 6 - usr.sbin/xntpd/ntpdate/Makefile.tmpl | 70 - usr.sbin/xntpd/ntpq/Makefile.tmpl | 68 - usr.sbin/xntpd/ntptrace/Makefile.tmpl | 70 - usr.sbin/xntpd/parse/Makefile.kernel | 76 - usr.sbin/xntpd/parse/Makefile.tmpl | 111 - usr.sbin/xntpd/patches/patch.1 | 790 - usr.sbin/xntpd/patches/patch.10 | 1925 --- usr.sbin/xntpd/patches/patch.11 | 536 - usr.sbin/xntpd/patches/patch.12 | 66 - usr.sbin/xntpd/patches/patch.13 | 68 - usr.sbin/xntpd/patches/patch.14 | 116 - usr.sbin/xntpd/patches/patch.15 | 39 - usr.sbin/xntpd/patches/patch.16 | 267 - usr.sbin/xntpd/patches/patch.17 | 50 - usr.sbin/xntpd/patches/patch.18 | 99 - usr.sbin/xntpd/patches/patch.19 | 599 - usr.sbin/xntpd/patches/patch.2 | 129 - usr.sbin/xntpd/patches/patch.20 | 1031 -- usr.sbin/xntpd/patches/patch.21 | 54 - usr.sbin/xntpd/patches/patch.22 | 296 - usr.sbin/xntpd/patches/patch.23 | 80 - usr.sbin/xntpd/patches/patch.24 | 474 - usr.sbin/xntpd/patches/patch.25 | 474 - usr.sbin/xntpd/patches/patch.26 | 36 - usr.sbin/xntpd/patches/patch.27 | 86 - usr.sbin/xntpd/patches/patch.28 | 454 - usr.sbin/xntpd/patches/patch.29 | 52 - usr.sbin/xntpd/patches/patch.3 | 3032 ---- usr.sbin/xntpd/patches/patch.30 | 73 - usr.sbin/xntpd/patches/patch.31 | 83 - usr.sbin/xntpd/patches/patch.32 | 89 - usr.sbin/xntpd/patches/patch.33 | 75 - usr.sbin/xntpd/patches/patch.34 | 303 - usr.sbin/xntpd/patches/patch.35 | 914 -- usr.sbin/xntpd/patches/patch.36 | 42 - usr.sbin/xntpd/patches/patch.37 | 204 - usr.sbin/xntpd/patches/patch.38 | 226 - usr.sbin/xntpd/patches/patch.39 | 78 - usr.sbin/xntpd/patches/patch.4 | 4719 ------ usr.sbin/xntpd/patches/patch.40 | 92 - usr.sbin/xntpd/patches/patch.41 | 50 - usr.sbin/xntpd/patches/patch.42 | 38 - usr.sbin/xntpd/patches/patch.43 | 48 - usr.sbin/xntpd/patches/patch.5 | 49 - usr.sbin/xntpd/patches/patch.6 | 550 - usr.sbin/xntpd/patches/patch.7 | 274 - usr.sbin/xntpd/patches/patch.8 | 44 - usr.sbin/xntpd/patches/patch.9 | 83 - usr.sbin/xntpd/scripts/hpadjtime.sh | 18 - usr.sbin/xntpd/util/Makefile.tmpl | 62 - usr.sbin/xntpd/xntpd/Makefile.tmpl | 168 - usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c | 593 - usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c | 999 -- .../xntpd/xntpd/refclock_new/refclock_leitch.c | 718 - .../xntpd/xntpd/refclock_new/refclock_msfees.c | 1575 -- .../xntpd/xntpd/refclock_new/refclock_mx4200.c | 977 -- usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c | 999 -- usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c | 3617 ----- usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c | 645 - usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c | 998 -- .../xntpd/xntpd/refclock_old/refclock_leitch.c | 709 - .../xntpd/xntpd/refclock_old/refclock_msfees.c | 1575 -- .../xntpd/xntpd/refclock_old/refclock_mx4200.c | 1342 -- usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c | 999 -- usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c | 3605 ----- usr.sbin/xntpd/xntpdc/Makefile.tmpl | 68 - usr.sbin/xntpd/xntpres/Makefile.tmpl | 68 - usr.sbin/xntpd/xntpres/README | 6 - usr.sbin/xntpd/xntpres/xntpres.c | 850 - 698 files changed, 248540 deletions(-) delete mode 100644 bin/ed/test/ascii.d delete mode 100644 bin/ed/test/ascii.r delete mode 100644 etc/etc.i386/fstab.wd delete mode 100644 etc/man.conf delete mode 100644 etc/namedb/localhost.rev delete mode 100644 gnu/lib/libg++/include/regex.h delete mode 100644 gnu/usr.bin/awk/gawk.texi delete mode 100644 gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info delete mode 100644 gnu/usr.bin/cvs/cvs/config.h delete mode 100644 gnu/usr.bin/cvs/cvs/version.c delete mode 100644 gnu/usr.bin/cvs/doc/cvs.ms delete mode 100644 gnu/usr.bin/cvs/lib/Makefile.in delete mode 100644 gnu/usr.bin/cvs/lib/regex.c delete mode 100644 gnu/usr.bin/cvs/lib/y.tab.h delete mode 100644 gnu/usr.bin/cvs/mkmodules/xxx delete mode 100644 gnu/usr.bin/dc/dc.info delete mode 100644 gnu/usr.bin/dc/dc.texinfo delete mode 100644 gnu/usr.bin/diff/fnmatch.h delete mode 100644 gnu/usr.bin/diff3/COPYING delete mode 100644 gnu/usr.bin/diff3/diff3.c delete mode 100644 gnu/usr.bin/diff3/getopt.c delete mode 100644 gnu/usr.bin/diff3/getopt.h delete mode 100644 gnu/usr.bin/diff3/getopt1.c delete mode 100644 gnu/usr.bin/diff3/system.h delete mode 100644 gnu/usr.bin/diff3/version.c delete mode 100644 gnu/usr.bin/grep/tests/regress.sh delete mode 100644 gnu/usr.bin/groff/eqn/eqn.cc delete mode 100644 gnu/usr.bin/groff/eqn/eqn.tab.h delete mode 100644 gnu/usr.bin/groff/pic/pic.cc delete mode 100644 gnu/usr.bin/groff/pic/pic.tab.h delete mode 100644 gnu/usr.bin/groff/refer/label.cc delete mode 100644 gnu/usr.bin/gzip/zcmp delete mode 100644 gnu/usr.bin/pr/COPYING delete mode 100644 gnu/usr.bin/pr/getopt.h delete mode 100644 gnu/usr.bin/pr/version.h delete mode 100644 gnu/usr.bin/ptx/ptx.info delete mode 100644 gnu/usr.bin/ptx/ptx.texinfo delete mode 100644 gnu/usr.bin/tar/regex.h delete mode 100644 gnu/usr.bin/tar/y.tab.h delete mode 100644 gnu/usr.bin/texinfo/info-files/info-stnd.info delete mode 100644 gnu/usr.bin/texinfo/info-files/info.info delete mode 100644 gnu/usr.bin/texinfo/info-files/makeinfo.info delete mode 100644 gnu/usr.bin/texinfo/info-files/texi-files/info-stnd.texi delete mode 100644 gnu/usr.bin/texinfo/info-files/texi-files/info.texi delete mode 100644 gnu/usr.bin/texinfo/info-files/texi-files/makeinfo.texi delete mode 100644 gnu/usr.bin/texinfo/info-files/texi-files/texi.texi delete mode 100644 gnu/usr.bin/texinfo/info-files/texi-files/userdoc.texi delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-1 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-10 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-11 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-2 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-3 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-4 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-5 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-6 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-7 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-8 delete mode 100644 gnu/usr.bin/texinfo/info-files/texi.info-9 delete mode 100644 gnu/usr.bin/texinfo/info/info-stnd.info delete mode 100644 gnu/usr.bin/texinfo/info/info.info delete mode 100644 gnu/usr.bin/texinfo/misc/texindex.c delete mode 100644 include/tzfile.h delete mode 100644 lib/csu/i386/gprof.ex delete mode 100644 lib/libc/compat-43/setregid.2 delete mode 100644 lib/libc/compat-43/setregid.c delete mode 100644 lib/libc/compat-43/setreuid.2 delete mode 100644 lib/libc/compat-43/setreuid.c delete mode 100644 lib/libc/gen/ctime.3 delete mode 100644 lib/libc/gen/ctime.c delete mode 100644 lib/libc/gen/difftime.c delete mode 100644 lib/libc/gen/sigsetjmp.c delete mode 100644 lib/libc/i386/gen/_setjmp.s delete mode 100644 lib/libc/i386/gen/alloca.s delete mode 100644 lib/libc/i386/gen/divsi3.s delete mode 100644 lib/libc/i386/gen/fabs.s delete mode 100644 lib/libc/i386/gen/fixdfsi.s delete mode 100644 lib/libc/i386/gen/fixunsdfsi.s delete mode 100644 lib/libc/i386/gen/modf.s delete mode 100644 lib/libc/i386/gen/setjmp.s delete mode 100644 lib/libc/i386/gen/udivsi3.s delete mode 100644 lib/libc/i386/net/htonl.s delete mode 100644 lib/libc/i386/net/htons.s delete mode 100644 lib/libc/i386/net/ntohl.s delete mode 100644 lib/libc/i386/net/ntohs.s delete mode 100644 lib/libc/i386/stdlib/abs.s delete mode 100644 lib/libc/i386/string/bzero.s delete mode 100644 lib/libc/i386/sys/Ovfork.s delete mode 100644 lib/libc/i386/sys/brk.s delete mode 100644 lib/libc/i386/sys/cerror.s delete mode 100644 lib/libc/i386/sys/exect.s delete mode 100644 lib/libc/i386/sys/fork.s delete mode 100644 lib/libc/i386/sys/mount.s delete mode 100644 lib/libc/i386/sys/pipe.s delete mode 100644 lib/libc/i386/sys/ptrace.s delete mode 100644 lib/libc/i386/sys/reboot.s delete mode 100644 lib/libc/i386/sys/sbrk.s delete mode 100644 lib/libc/i386/sys/setlogin.s delete mode 100644 lib/libc/i386/sys/sigpending.s delete mode 100644 lib/libc/i386/sys/sigprocmask.s delete mode 100644 lib/libc/i386/sys/sigreturn.s delete mode 100644 lib/libc/i386/sys/sigsuspend.s delete mode 100644 lib/libc/i386/sys/syscall.s delete mode 100644 lib/libc/net/getnetbyname.c delete mode 100644 lib/libc/net/getnetent.c delete mode 100644 lib/libc/net/sethostent.c delete mode 100644 lib/libc/stdlib/free.3 delete mode 100644 lib/libc/stdlib/realloc.3 delete mode 100644 lib/libc/stdtime/localtime.c.ORIG delete mode 100644 lib/libc/string/strftime.3 delete mode 100644 lib/libc/string/strftime.c delete mode 100644 lib/libcompat/regexp/regexp.h delete mode 100644 lib/libedit/histedit.h delete mode 100644 lib/libedit/termcap.h delete mode 100644 lib/librpc/DISCLAIMER delete mode 100644 lib/librpc/Makefile delete mode 100644 lib/librpc/README delete mode 100644 lib/librpc/demo/Makefile delete mode 100644 lib/librpc/demo/dir/Makefile delete mode 100644 lib/librpc/demo/dir/dir.x delete mode 100644 lib/librpc/demo/dir/dir_proc.c delete mode 100644 lib/librpc/demo/dir/rls.c delete mode 100644 lib/librpc/demo/msg/Makefile delete mode 100644 lib/librpc/demo/msg/msg.x delete mode 100644 lib/librpc/demo/msg/msg_proc.c delete mode 100644 lib/librpc/demo/msg/printmsg.c delete mode 100644 lib/librpc/demo/msg/rprintmsg.c delete mode 100644 lib/librpc/demo/sort/Makefile delete mode 100644 lib/librpc/demo/sort/rsort.c delete mode 100644 lib/librpc/demo/sort/sort.x delete mode 100644 lib/librpc/demo/sort/sort_proc.c delete mode 100644 lib/librpc/doc/Makefile delete mode 100644 lib/librpc/doc/nfs.rfc.ms delete mode 100644 lib/librpc/doc/rpc.prog.ms delete mode 100644 lib/librpc/doc/rpc.rfc.ms delete mode 100644 lib/librpc/doc/rpcgen.ms delete mode 100644 lib/librpc/doc/xdr.nts.ms delete mode 100644 lib/librpc/doc/xdr.rfc.ms delete mode 100644 lib/librpc/etc/Makefile delete mode 100644 lib/librpc/etc/getopt.c delete mode 100644 lib/librpc/etc/portmap.c delete mode 100644 lib/librpc/etc/rpc delete mode 100644 lib/librpc/etc/rpcinfo.c delete mode 100644 lib/librpc/man/man1/rpcgen.1 delete mode 100644 lib/librpc/man/man1/rstat.1 delete mode 100644 lib/librpc/man/man3/bindresvport.3n delete mode 100644 lib/librpc/man/man3/getrpcent.3n delete mode 100644 lib/librpc/man/man3/getrpcport.3r delete mode 100644 lib/librpc/man/man3/rpc.3n delete mode 100644 lib/librpc/man/man3/xdr.3n delete mode 100644 lib/librpc/man/man5/rpc.5 delete mode 100644 lib/librpc/man/man8/portmap.8c delete mode 100644 lib/librpc/man/man8/rpcinfo.8c delete mode 100644 lib/librpc/man/man8/rstat_svc.8c delete mode 100644 lib/librpc/rpc/auth.h delete mode 100644 lib/librpc/rpc/auth_none.c delete mode 100644 lib/librpc/rpc/auth_unix.c delete mode 100644 lib/librpc/rpc/auth_unix.h delete mode 100644 lib/librpc/rpc/authunix_prot.c delete mode 100644 lib/librpc/rpc/bindresvport.c delete mode 100644 lib/librpc/rpc/clnt.h delete mode 100644 lib/librpc/rpc/clnt_generic.c delete mode 100644 lib/librpc/rpc/clnt_perror.c delete mode 100644 lib/librpc/rpc/clnt_raw.c delete mode 100644 lib/librpc/rpc/clnt_simple.c delete mode 100644 lib/librpc/rpc/clnt_tcp.c delete mode 100644 lib/librpc/rpc/clnt_udp.c delete mode 100644 lib/librpc/rpc/get_myaddress.c delete mode 100644 lib/librpc/rpc/getrpcent.c delete mode 100644 lib/librpc/rpc/getrpcport.c delete mode 100644 lib/librpc/rpc/pmap_clnt.c delete mode 100644 lib/librpc/rpc/pmap_clnt.h delete mode 100644 lib/librpc/rpc/pmap_getmaps.c delete mode 100644 lib/librpc/rpc/pmap_getport.c delete mode 100644 lib/librpc/rpc/pmap_prot.c delete mode 100644 lib/librpc/rpc/pmap_prot.h delete mode 100644 lib/librpc/rpc/pmap_prot2.c delete mode 100644 lib/librpc/rpc/pmap_rmt.c delete mode 100644 lib/librpc/rpc/pmap_rmt.h delete mode 100644 lib/librpc/rpc/rpc.h delete mode 100644 lib/librpc/rpc/rpc_callmsg.c delete mode 100644 lib/librpc/rpc/rpc_commondata.c delete mode 100644 lib/librpc/rpc/rpc_dtablesize.c delete mode 100644 lib/librpc/rpc/rpc_msg.h delete mode 100644 lib/librpc/rpc/rpc_prot.c delete mode 100644 lib/librpc/rpc/svc.c delete mode 100644 lib/librpc/rpc/svc.h delete mode 100644 lib/librpc/rpc/svc_auth.c delete mode 100644 lib/librpc/rpc/svc_auth.h delete mode 100644 lib/librpc/rpc/svc_auth_unix.c delete mode 100644 lib/librpc/rpc/svc_raw.c delete mode 100644 lib/librpc/rpc/svc_run.c delete mode 100644 lib/librpc/rpc/svc_simple.c delete mode 100644 lib/librpc/rpc/svc_tcp.c delete mode 100644 lib/librpc/rpc/svc_udp.c delete mode 100644 lib/librpc/rpc/types.h delete mode 100644 lib/librpc/rpc/xdr.c delete mode 100644 lib/librpc/rpc/xdr.h delete mode 100644 lib/librpc/rpc/xdr_array.c delete mode 100644 lib/librpc/rpc/xdr_float.c delete mode 100644 lib/librpc/rpc/xdr_mem.c delete mode 100644 lib/librpc/rpc/xdr_rec.c delete mode 100644 lib/librpc/rpc/xdr_reference.c delete mode 100644 lib/librpc/rpc/xdr_stdio.c delete mode 100644 lib/librpc/rpcgen/Makefile delete mode 100644 lib/librpc/rpcgen/rpc_clntout.c delete mode 100644 lib/librpc/rpcgen/rpc_cout.c delete mode 100644 lib/librpc/rpcgen/rpc_hout.c delete mode 100644 lib/librpc/rpcgen/rpc_main.c delete mode 100644 lib/librpc/rpcgen/rpc_parse.c delete mode 100644 lib/librpc/rpcgen/rpc_parse.h delete mode 100644 lib/librpc/rpcgen/rpc_scan.c delete mode 100644 lib/librpc/rpcgen/rpc_scan.h delete mode 100644 lib/librpc/rpcgen/rpc_svcout.c delete mode 100644 lib/librpc/rpcgen/rpc_util.c delete mode 100644 lib/librpc/rpcgen/rpc_util.h delete mode 100644 lib/librpc/rpcsvc/Makefile delete mode 100644 lib/librpc/rpcsvc/bootparam_prot.x delete mode 100644 lib/librpc/rpcsvc/klm_prot.x delete mode 100644 lib/librpc/rpcsvc/mount.x delete mode 100644 lib/librpc/rpcsvc/nfs_prot.x delete mode 100644 lib/librpc/rpcsvc/nlm_prot.x delete mode 100644 lib/librpc/rpcsvc/rex.x delete mode 100644 lib/librpc/rpcsvc/rnusers.x delete mode 100644 lib/librpc/rpcsvc/rquota.x delete mode 100644 lib/librpc/rpcsvc/rstat.c delete mode 100644 lib/librpc/rpcsvc/rstat.x delete mode 100644 lib/librpc/rpcsvc/rstat_proc.c delete mode 100644 lib/librpc/rpcsvc/sm_inter.x delete mode 100644 lib/librpc/rpcsvc/spray.x delete mode 100644 lib/librpc/rpcsvc/yp.x delete mode 100644 lib/librpc/rpcsvc/yppasswd.x delete mode 100644 lib/librpc/secure_rpc/README delete mode 100644 lib/librpc/secure_rpc/bin/Makefile delete mode 100644 lib/librpc/secure_rpc/bin/chkey.c delete mode 100644 lib/librpc/secure_rpc/bin/keylogin.c delete mode 100644 lib/librpc/secure_rpc/demo/Makefile delete mode 100644 lib/librpc/secure_rpc/demo/rme.c delete mode 100644 lib/librpc/secure_rpc/demo/whoami.x delete mode 100644 lib/librpc/secure_rpc/demo/whoami_proc.c delete mode 100644 lib/librpc/secure_rpc/des/des.h delete mode 100644 lib/librpc/secure_rpc/des/des_crypt.c delete mode 100644 lib/librpc/secure_rpc/des/des_crypt.h delete mode 100644 lib/librpc/secure_rpc/des/des_soft.c delete mode 100644 lib/librpc/secure_rpc/doc/Makefile delete mode 100644 lib/librpc/secure_rpc/doc/nfs.secure.ms delete mode 100644 lib/librpc/secure_rpc/keyserv/Makefile delete mode 100644 lib/librpc/secure_rpc/keyserv/detach.c delete mode 100644 lib/librpc/secure_rpc/keyserv/keyenvoy.c delete mode 100644 lib/librpc/secure_rpc/keyserv/keyserv.c delete mode 100644 lib/librpc/secure_rpc/keyserv/mp.c delete mode 100644 lib/librpc/secure_rpc/keyserv/setkey.c delete mode 100644 lib/librpc/secure_rpc/man/chkey.1 delete mode 100644 lib/librpc/secure_rpc/man/des_crypt.3 delete mode 100644 lib/librpc/secure_rpc/man/keyenvoy.8c delete mode 100644 lib/librpc/secure_rpc/man/keylogin.1 delete mode 100644 lib/librpc/secure_rpc/man/keyserv.8c delete mode 100644 lib/librpc/secure_rpc/man/publickey.3r delete mode 100644 lib/librpc/secure_rpc/man/publickey.5 delete mode 100644 lib/librpc/secure_rpc/man/rpc_secure.3n delete mode 100644 lib/librpc/secure_rpc/man/rtime.3n delete mode 100644 lib/librpc/secure_rpc/rpc/Makefile delete mode 100644 lib/librpc/secure_rpc/rpc/auth_des.c delete mode 100644 lib/librpc/secure_rpc/rpc/auth_des.h delete mode 100644 lib/librpc/secure_rpc/rpc/authdes_prot.c delete mode 100644 lib/librpc/secure_rpc/rpc/key_call.c delete mode 100644 lib/librpc/secure_rpc/rpc/key_prot.c delete mode 100644 lib/librpc/secure_rpc/rpc/key_prot.h delete mode 100644 lib/librpc/secure_rpc/rpc/key_prot.x delete mode 100644 lib/librpc/secure_rpc/rpc/netname.c delete mode 100644 lib/librpc/secure_rpc/rpc/openchild.c delete mode 100644 lib/librpc/secure_rpc/rpc/publickey.c delete mode 100644 lib/librpc/secure_rpc/rpc/rtime.c delete mode 100644 lib/librpc/secure_rpc/rpc/svc_auth.c delete mode 100644 lib/librpc/secure_rpc/rpc/svcauth_des.c delete mode 100644 lib/librpc/secure_rpc/rpc/xcrypt.c delete mode 100644 lib/libtelnet/auth-proto.h delete mode 100644 lib/libtelnet/auth.c delete mode 100644 lib/libtelnet/auth.h delete mode 100644 lib/libtelnet/enc-proto.h delete mode 100644 lib/libtelnet/enc_des.c delete mode 100644 lib/libtelnet/encrypt.c delete mode 100644 lib/libtelnet/encrypt.h delete mode 100644 lib/libtelnet/kerberos.c delete mode 100644 lib/libtelnet/kerberos5.c delete mode 100644 lib/libtelnet/key-proto.h delete mode 100644 lib/libtelnet/krb4encpwd.c delete mode 100644 lib/libtelnet/read_password.c delete mode 100644 lib/libtelnet/rsaencpwd.c delete mode 100644 lib/libtelnet/spx.c delete mode 100644 lib/libterm/TEST/tc1.c delete mode 100644 lib/libterm/TEST/tc2.c delete mode 100644 lib/libterm/TEST/tc3.c delete mode 100644 lib/libterm/pathnames.h delete mode 100644 lib/libterm/termcap.3 delete mode 100644 lib/libterm/termcap.c delete mode 100644 lib/libterm/tgoto.c delete mode 100644 lib/libterm/tputs.c delete mode 100644 libexec/bugfiler/bug.h delete mode 100644 libexec/bugfiler/bugfiler.8 delete mode 100644 libexec/bugfiler/bugfiler.c delete mode 100644 libexec/bugfiler/bugformat delete mode 100644 libexec/bugfiler/error.c delete mode 100644 libexec/bugfiler/extern.h delete mode 100644 libexec/bugfiler/gethead.c delete mode 100644 libexec/bugfiler/pathnames.h delete mode 100644 libexec/bugfiler/process.c delete mode 100644 libexec/bugfiler/redist.c delete mode 100644 libexec/bugfiler/reply.c delete mode 100644 libexec/bugfiler/sendbug.1 delete mode 100644 libexec/bugfiler/sendbug.sh delete mode 100644 libexec/getty/extern.h delete mode 100644 libexec/getty/ttydefaults.c delete mode 100644 libexec/kpasswdd/kpasswdd.8 delete mode 100644 libexec/kpasswdd/kpasswdd.c delete mode 100644 libexec/telnetd/authenc.c delete mode 100644 sbin/disklabel/disklabel.5.5 delete mode 100644 sbin/fastboot/fastboot.8 delete mode 100644 sbin/scsiformat/scsiformat.c delete mode 100644 secure/usr.bin/telnet/krb4-proto.h delete mode 100644 share/doc/psd/00.contents delete mode 100644 share/doc/psd/Title delete mode 100644 share/doc/smm/00.contents delete mode 100644 share/doc/smm/Title delete mode 100644 share/doc/usd/00.contents delete mode 100644 share/doc/usd/Title delete mode 100644 share/man/man8/adduser.8 delete mode 100644 share/tabset/3101 delete mode 100644 share/tabset/9837 delete mode 100644 share/tabset/aa delete mode 100644 share/tabset/aed512 delete mode 100644 share/tabset/beehive delete mode 100644 share/tabset/diablo delete mode 100644 share/tabset/dtc382 delete mode 100644 share/tabset/hp700-wy delete mode 100644 share/tabset/ibm3101 delete mode 100644 share/tabset/std delete mode 100644 share/tabset/stdcrt delete mode 100644 share/tabset/tandem653 delete mode 100644 share/tabset/teleray delete mode 100644 share/tabset/vt100 delete mode 100644 share/tabset/vt100-w delete mode 100644 share/tabset/wyse-adds delete mode 100644 share/tabset/xerox1720 delete mode 100644 share/tabset/zenith29 delete mode 100644 share/tmac/README delete mode 100644 share/tmac/doc delete mode 100644 share/tmac/doc-common delete mode 100644 share/tmac/doc-ditroff delete mode 100644 share/tmac/doc-nroff delete mode 100644 share/tmac/doc-syms delete mode 100644 share/tmac/strip.sed delete mode 100644 share/tmac/tmac.andoc delete mode 100644 share/tmac/tmac.doc.old delete mode 100644 share/tmac/tmac.e delete mode 100644 share/tmac/tmac.s delete mode 100644 share/tmac/tmac.sU delete mode 100644 sys/i386/ibcs2/ibcs2_timeb.h delete mode 100644 usr.bin/apropos/Makefile delete mode 100644 usr.bin/apropos/apropos.1 delete mode 100644 usr.bin/apropos/apropos.c delete mode 100644 usr.bin/ar/ar.5.5 delete mode 100644 usr.bin/bdes/Makefile delete mode 100644 usr.bin/bdes/bdes.1 delete mode 100644 usr.bin/bdes/bdes.c delete mode 100644 usr.bin/bdes/bdes.ps delete mode 100644 usr.bin/chat/fix-cua delete mode 100644 usr.bin/compress/zcat.sh delete mode 100644 usr.bin/diff/diff/diff.1 delete mode 100644 usr.bin/diff/diff3/diff3.1 delete mode 100644 usr.bin/ee/ee.msg delete mode 100644 usr.bin/grep/egrep/egrep.c delete mode 100644 usr.bin/grep/egrep/grep.1 delete mode 100644 usr.bin/grep/egrep/pathnames.h delete mode 100644 usr.bin/ld/Makefile delete mode 100644 usr.bin/ld/cplus-dem.c delete mode 100644 usr.bin/ld/ld.c delete mode 100644 usr.bin/ld/symseg.h delete mode 100644 usr.bin/lex/flex.1 delete mode 100644 usr.bin/lex/flexdoc.1 delete mode 100644 usr.bin/m4/serv.c delete mode 100644 usr.bin/man/Makefile delete mode 100644 usr.bin/man/config.c delete mode 100644 usr.bin/man/config.h delete mode 100644 usr.bin/man/man.1 delete mode 100644 usr.bin/man/man.c delete mode 100644 usr.bin/man/man.conf delete mode 100644 usr.bin/man/man.conf.5 delete mode 100644 usr.bin/man/pathnames.h delete mode 100644 usr.bin/mklocale/Japanese delete mode 100644 usr.bin/ncftp/Makefile.ORIG delete mode 100644 usr.bin/ncftp/v2_Note delete mode 100644 usr.bin/passwd/kpasswd_proto.h delete mode 100644 usr.bin/passwd/krb_passwd.c delete mode 100644 usr.bin/patch/EXTERN.h delete mode 100644 usr.bin/patch/INTERN.h delete mode 100644 usr.bin/patch/Makefile delete mode 100644 usr.bin/patch/README delete mode 100644 usr.bin/patch/common.h delete mode 100644 usr.bin/patch/config.h delete mode 100644 usr.bin/patch/inp.c delete mode 100644 usr.bin/patch/inp.h delete mode 100644 usr.bin/patch/patch.1 delete mode 100644 usr.bin/patch/patch.c delete mode 100644 usr.bin/patch/patchlevel.h delete mode 100644 usr.bin/patch/pch.c delete mode 100644 usr.bin/patch/pch.h delete mode 100644 usr.bin/patch/util.c delete mode 100644 usr.bin/patch/util.h delete mode 100644 usr.bin/patch/version.c delete mode 100644 usr.bin/patch/version.h delete mode 100644 usr.bin/ranlib/ranlib.5.5 delete mode 100644 usr.bin/rlogin/des_rw.c delete mode 100644 usr.bin/sccs/Makefile delete mode 100644 usr.bin/sccs/PSD.doc/Makefile delete mode 100644 usr.bin/sccs/PSD.doc/sccs.me delete mode 100644 usr.bin/sccs/PSD.doc/spell.ok delete mode 100644 usr.bin/sccs/pathnames.h delete mode 100644 usr.bin/sccs/sccs.1 delete mode 100644 usr.bin/sccs/sccs.c delete mode 100644 usr.bin/sort/sort.1 delete mode 100644 usr.bin/tip/acu.c delete mode 100644 usr.bin/tip/aculib/biz22.c delete mode 100644 usr.bin/tip/aculib/biz31.c delete mode 100644 usr.bin/tip/aculib/courier.c delete mode 100644 usr.bin/tip/aculib/df.c delete mode 100644 usr.bin/tip/aculib/dn11.c delete mode 100644 usr.bin/tip/aculib/hayes.c delete mode 100644 usr.bin/tip/aculib/t3000.c delete mode 100644 usr.bin/tip/aculib/v3451.c delete mode 100644 usr.bin/tip/aculib/v831.c delete mode 100644 usr.bin/tip/aculib/ventel.c delete mode 100644 usr.bin/tip/acutab.c delete mode 100644 usr.bin/tip/cmds.c delete mode 100644 usr.bin/tip/cmdtab.c delete mode 100644 usr.bin/tip/cu.c delete mode 100644 usr.bin/tip/hunt.c delete mode 100644 usr.bin/tip/log.c delete mode 100644 usr.bin/tip/partab.c delete mode 100644 usr.bin/tip/remcap.c delete mode 100644 usr.bin/tip/remote.c delete mode 100644 usr.bin/tip/tip.1 delete mode 100644 usr.bin/tip/value.c delete mode 100644 usr.bin/tip/vars.c delete mode 100644 usr.bin/uucp/acucntrl/acucntrl.c delete mode 100644 usr.bin/uucp/uupoll/uupoll.8 delete mode 100644 usr.bin/uucp/uupoll/uupoll.c delete mode 100644 usr.bin/uucp/uuq/Makefile delete mode 100644 usr.bin/uucp/uuq/uuq.1 delete mode 100644 usr.bin/uucp/uuq/uuq.c delete mode 100644 usr.bin/uucp/uusend/Makefile delete mode 100644 usr.bin/uucp/uusend/uusend.1 delete mode 100644 usr.bin/uucp/uusend/uusend.c delete mode 100644 usr.bin/uucp/uusnap/uusnap.8 delete mode 100644 usr.bin/uucp/uusnap/uusnap.c delete mode 100644 usr.bin/whatis/Makefile delete mode 100644 usr.bin/whatis/whatis.1 delete mode 100644 usr.bin/whatis/whatis.c delete mode 100755 usr.bin/which/which.sh delete mode 100644 usr.sbin/arp/arp4.4 delete mode 100644 usr.sbin/bootpd/Announce delete mode 100644 usr.sbin/bootpd/Changes delete mode 100644 usr.sbin/bootpd/ConvOldTab.sh delete mode 100644 usr.sbin/bootpd/Installation delete mode 100644 usr.sbin/bootpd/Makefile.UNIX delete mode 100644 usr.sbin/bootpd/Problems delete mode 100644 usr.sbin/bootpd/README delete mode 100644 usr.sbin/bootpd/bootp.h delete mode 100644 usr.sbin/bootpd/bootpd.8 delete mode 100644 usr.sbin/bootpd/bootpd.c delete mode 100644 usr.sbin/bootpd/bootpd.h delete mode 100644 usr.sbin/bootpd/bootpef.8 delete mode 100644 usr.sbin/bootpd/bootpef.c delete mode 100644 usr.sbin/bootpd/bootpgw.c delete mode 100644 usr.sbin/bootpd/bootptab.5 delete mode 100644 usr.sbin/bootpd/bootptab.cmu delete mode 100644 usr.sbin/bootpd/bootptab.mcs delete mode 100644 usr.sbin/bootpd/bootptest.8 delete mode 100644 usr.sbin/bootpd/bootptest.c delete mode 100644 usr.sbin/bootpd/bootptest.h delete mode 100644 usr.sbin/bootpd/bptypes.h delete mode 100644 usr.sbin/bootpd/dovend.c delete mode 100644 usr.sbin/bootpd/dovend.h delete mode 100644 usr.sbin/bootpd/dumptab.c delete mode 100644 usr.sbin/bootpd/getif.c delete mode 100644 usr.sbin/bootpd/getif.h delete mode 100644 usr.sbin/bootpd/hash.c delete mode 100644 usr.sbin/bootpd/hash.h delete mode 100644 usr.sbin/bootpd/hwaddr.h delete mode 100644 usr.sbin/bootpd/lookup.c delete mode 100644 usr.sbin/bootpd/lookup.h delete mode 100644 usr.sbin/bootpd/patchlevel.h delete mode 100644 usr.sbin/bootpd/print-bootp.c delete mode 100644 usr.sbin/bootpd/readfile.c delete mode 100644 usr.sbin/bootpd/readfile.h delete mode 100644 usr.sbin/bootpd/report.c delete mode 100644 usr.sbin/bootpd/report.h delete mode 100644 usr.sbin/bootpd/syslog.conf delete mode 100644 usr.sbin/bootpd/trygetea.c delete mode 100644 usr.sbin/bootpd/trygetif.c delete mode 100644 usr.sbin/bootpd/trylook.c delete mode 100644 usr.sbin/bootpd/tzone.c delete mode 100644 usr.sbin/bootpd/tzone.h delete mode 100644 usr.sbin/sliplogin/slip.hosts delete mode 100644 usr.sbin/sliplogin/slip.login delete mode 100644 usr.sbin/tcpdump/tcpdump/bpf_image.c delete mode 100644 usr.sbin/tcpdump/tcpdump/etherent.c delete mode 100644 usr.sbin/tcpdump/tcpdump/etherent.h delete mode 100644 usr.sbin/tcpdump/tcpdump/etherproto.h delete mode 100644 usr.sbin/tcpdump/tcpdump/gencode.c delete mode 100644 usr.sbin/tcpdump/tcpdump/gencode.h delete mode 100644 usr.sbin/tcpdump/tcpdump/inet.c delete mode 100644 usr.sbin/tcpdump/tcpdump/md.c delete mode 100644 usr.sbin/tcpdump/tcpdump/nametoaddr.c delete mode 100644 usr.sbin/tcpdump/tcpdump/nametoaddr.h delete mode 100644 usr.sbin/tcpdump/tcpdump/optimize.c delete mode 100644 usr.sbin/tcpdump/tcpdump/os.c delete mode 100644 usr.sbin/tcpdump/tcpdump/pcap.c delete mode 100644 usr.sbin/tcpdump/tcpdump/savefile.c delete mode 100644 usr.sbin/tcpdump/tcpdump/savefile.h delete mode 100644 usr.sbin/tcpdump/tcpdump/tcpgram.y delete mode 100644 usr.sbin/update/Makefile delete mode 100644 usr.sbin/update/update.8 delete mode 100644 usr.sbin/update/update.c delete mode 100644 usr.sbin/xntpd/Config delete mode 100644 usr.sbin/xntpd/Config.local delete mode 100644 usr.sbin/xntpd/Config.local.dist delete mode 100644 usr.sbin/xntpd/Config.sed delete mode 100644 usr.sbin/xntpd/adjtime/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/adjtime/README delete mode 100644 usr.sbin/xntpd/adjtime/adjtime.c delete mode 100644 usr.sbin/xntpd/adjtime/adjtime.h delete mode 100644 usr.sbin/xntpd/adjtime/adjtimed.c delete mode 100644 usr.sbin/xntpd/authstuff/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/clockstuff/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/compilers/README delete mode 100644 usr.sbin/xntpd/compilers/aux2.gcc delete mode 100644 usr.sbin/xntpd/compilers/aux3.gcc delete mode 100644 usr.sbin/xntpd/compilers/decosf1.gcc delete mode 100644 usr.sbin/xntpd/compilers/domainos.cc delete mode 100644 usr.sbin/xntpd/compilers/hpux-adj.cc delete mode 100644 usr.sbin/xntpd/compilers/hpux-adj.gcc delete mode 100644 usr.sbin/xntpd/compilers/hpux.cc delete mode 100644 usr.sbin/xntpd/compilers/hpux.gcc delete mode 100644 usr.sbin/xntpd/compilers/hpux10+.cc delete mode 100644 usr.sbin/xntpd/compilers/irix4.cc delete mode 100644 usr.sbin/xntpd/compilers/linux.gcc delete mode 100644 usr.sbin/xntpd/compilers/mips.cc delete mode 100644 usr.sbin/xntpd/compilers/sinix-m.cc delete mode 100644 usr.sbin/xntpd/compilers/sinix-m.gcc delete mode 100644 usr.sbin/xntpd/compilers/sunos4.bsd.cc delete mode 100644 usr.sbin/xntpd/compilers/sunos4.bsd.gcc delete mode 100644 usr.sbin/xntpd/compilers/sunos4.posix.gcc delete mode 100644 usr.sbin/xntpd/compilers/sunos5.1.gcc delete mode 100644 usr.sbin/xntpd/compilers/sunos5.2.gcc delete mode 100644 usr.sbin/xntpd/compilers/ultrix.bsd.cc delete mode 100644 usr.sbin/xntpd/compilers/ultrix.bsd.gcc delete mode 100644 usr.sbin/xntpd/compilers/ultrix.posix.cc delete mode 100644 usr.sbin/xntpd/compilers/ultrix.posix.gcc delete mode 100644 usr.sbin/xntpd/gadget/README delete mode 100644 usr.sbin/xntpd/gadget/adt0127.lpr delete mode 100644 usr.sbin/xntpd/gadget/art01.lpr delete mode 100644 usr.sbin/xntpd/gadget/art02.lpr delete mode 100644 usr.sbin/xntpd/gadget/dd0124.lpr delete mode 100644 usr.sbin/xntpd/gadget/gadget.lst delete mode 100644 usr.sbin/xntpd/gadget/gadget.s01 delete mode 100644 usr.sbin/xntpd/gadget/gadget.s02 delete mode 100644 usr.sbin/xntpd/gadget/gen0102.lpr delete mode 100644 usr.sbin/xntpd/gadget/sm0228.lpr delete mode 100644 usr.sbin/xntpd/gadget/sst0126.lpr delete mode 100644 usr.sbin/xntpd/hints/README delete mode 100644 usr.sbin/xntpd/hints/aux delete mode 100644 usr.sbin/xntpd/hints/bsdi delete mode 100644 usr.sbin/xntpd/hints/decosf1 delete mode 100644 usr.sbin/xntpd/hints/hpux delete mode 100644 usr.sbin/xntpd/hints/linux delete mode 100644 usr.sbin/xntpd/hints/notes-xntp-v3 delete mode 100644 usr.sbin/xntpd/hints/parse delete mode 100644 usr.sbin/xntpd/hints/refclocks delete mode 100644 usr.sbin/xntpd/hints/rs6000 delete mode 100644 usr.sbin/xntpd/hints/sgi delete mode 100644 usr.sbin/xntpd/hints/solaris delete mode 100644 usr.sbin/xntpd/hints/sun4 delete mode 100644 usr.sbin/xntpd/hints/svr4-dell delete mode 100644 usr.sbin/xntpd/kernel/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/kernel/README delete mode 100644 usr.sbin/xntpd/kernel/README.streams delete mode 100644 usr.sbin/xntpd/kernel/tty_chu.c delete mode 100644 usr.sbin/xntpd/kernel/tty_chu_STREAMS.c delete mode 100644 usr.sbin/xntpd/kernel/tty_clk.c delete mode 100644 usr.sbin/xntpd/kernel/tty_clk_STREAMS.c delete mode 100644 usr.sbin/xntpd/lib/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/lib/authdes.c delete mode 100644 usr.sbin/xntpd/machines/README delete mode 100644 usr.sbin/xntpd/machines/aix3.2 delete mode 100644 usr.sbin/xntpd/machines/aux2 delete mode 100644 usr.sbin/xntpd/machines/aux3 delete mode 100644 usr.sbin/xntpd/machines/bsdi delete mode 100644 usr.sbin/xntpd/machines/convexos10 delete mode 100644 usr.sbin/xntpd/machines/convexos9 delete mode 100644 usr.sbin/xntpd/machines/decosf1 delete mode 100644 usr.sbin/xntpd/machines/dell.svr4 delete mode 100644 usr.sbin/xntpd/machines/domainos delete mode 100644 usr.sbin/xntpd/machines/freebsd delete mode 100644 usr.sbin/xntpd/machines/hpux delete mode 100644 usr.sbin/xntpd/machines/hpux-adj delete mode 100644 usr.sbin/xntpd/machines/hpux10+ delete mode 100644 usr.sbin/xntpd/machines/i386 delete mode 100644 usr.sbin/xntpd/machines/i386svr4 delete mode 100644 usr.sbin/xntpd/machines/irix4 delete mode 100644 usr.sbin/xntpd/machines/irix5 delete mode 100644 usr.sbin/xntpd/machines/linux delete mode 100644 usr.sbin/xntpd/machines/mips delete mode 100644 usr.sbin/xntpd/machines/netbsd delete mode 100644 usr.sbin/xntpd/machines/next delete mode 100644 usr.sbin/xntpd/machines/ptx delete mode 100644 usr.sbin/xntpd/machines/sequent delete mode 100644 usr.sbin/xntpd/machines/sinix-m delete mode 100644 usr.sbin/xntpd/machines/sony delete mode 100644 usr.sbin/xntpd/machines/sunos4.bsd delete mode 100644 usr.sbin/xntpd/machines/sunos4.posix delete mode 100644 usr.sbin/xntpd/machines/sunos5.1 delete mode 100644 usr.sbin/xntpd/machines/sunos5.2 delete mode 100644 usr.sbin/xntpd/machines/svr4 delete mode 100644 usr.sbin/xntpd/machines/ultrix.bsd delete mode 100644 usr.sbin/xntpd/machines/ultrix.posix delete mode 100644 usr.sbin/xntpd/machines/univel delete mode 100644 usr.sbin/xntpd/machines/unixware1 delete mode 100644 usr.sbin/xntpd/machines/vax delete mode 100644 usr.sbin/xntpd/ntpdate/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/ntpq/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/ntptrace/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/parse/Makefile.kernel delete mode 100644 usr.sbin/xntpd/parse/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/patches/patch.1 delete mode 100644 usr.sbin/xntpd/patches/patch.10 delete mode 100644 usr.sbin/xntpd/patches/patch.11 delete mode 100644 usr.sbin/xntpd/patches/patch.12 delete mode 100644 usr.sbin/xntpd/patches/patch.13 delete mode 100644 usr.sbin/xntpd/patches/patch.14 delete mode 100644 usr.sbin/xntpd/patches/patch.15 delete mode 100644 usr.sbin/xntpd/patches/patch.16 delete mode 100644 usr.sbin/xntpd/patches/patch.17 delete mode 100644 usr.sbin/xntpd/patches/patch.18 delete mode 100644 usr.sbin/xntpd/patches/patch.19 delete mode 100644 usr.sbin/xntpd/patches/patch.2 delete mode 100644 usr.sbin/xntpd/patches/patch.20 delete mode 100644 usr.sbin/xntpd/patches/patch.21 delete mode 100644 usr.sbin/xntpd/patches/patch.22 delete mode 100644 usr.sbin/xntpd/patches/patch.23 delete mode 100644 usr.sbin/xntpd/patches/patch.24 delete mode 100644 usr.sbin/xntpd/patches/patch.25 delete mode 100644 usr.sbin/xntpd/patches/patch.26 delete mode 100644 usr.sbin/xntpd/patches/patch.27 delete mode 100644 usr.sbin/xntpd/patches/patch.28 delete mode 100644 usr.sbin/xntpd/patches/patch.29 delete mode 100644 usr.sbin/xntpd/patches/patch.3 delete mode 100644 usr.sbin/xntpd/patches/patch.30 delete mode 100644 usr.sbin/xntpd/patches/patch.31 delete mode 100644 usr.sbin/xntpd/patches/patch.32 delete mode 100644 usr.sbin/xntpd/patches/patch.33 delete mode 100644 usr.sbin/xntpd/patches/patch.34 delete mode 100644 usr.sbin/xntpd/patches/patch.35 delete mode 100644 usr.sbin/xntpd/patches/patch.36 delete mode 100644 usr.sbin/xntpd/patches/patch.37 delete mode 100644 usr.sbin/xntpd/patches/patch.38 delete mode 100644 usr.sbin/xntpd/patches/patch.39 delete mode 100644 usr.sbin/xntpd/patches/patch.4 delete mode 100644 usr.sbin/xntpd/patches/patch.40 delete mode 100644 usr.sbin/xntpd/patches/patch.41 delete mode 100644 usr.sbin/xntpd/patches/patch.42 delete mode 100644 usr.sbin/xntpd/patches/patch.43 delete mode 100644 usr.sbin/xntpd/patches/patch.5 delete mode 100644 usr.sbin/xntpd/patches/patch.6 delete mode 100644 usr.sbin/xntpd/patches/patch.7 delete mode 100644 usr.sbin/xntpd/patches/patch.8 delete mode 100644 usr.sbin/xntpd/patches/patch.9 delete mode 100644 usr.sbin/xntpd/scripts/hpadjtime.sh delete mode 100644 usr.sbin/xntpd/util/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/xntpd/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_leitch.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_msfees.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_mx4200.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_leitch.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_msfees.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_mx4200.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c delete mode 100644 usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c delete mode 100644 usr.sbin/xntpd/xntpdc/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/xntpres/Makefile.tmpl delete mode 100644 usr.sbin/xntpd/xntpres/README delete mode 100644 usr.sbin/xntpd/xntpres/xntpres.c diff --git a/bin/ed/test/ascii.d b/bin/ed/test/ascii.d deleted file mode 100644 index c86626638e0b..000000000000 Binary files a/bin/ed/test/ascii.d and /dev/null differ diff --git a/bin/ed/test/ascii.r b/bin/ed/test/ascii.r deleted file mode 100644 index c86626638e0b..000000000000 Binary files a/bin/ed/test/ascii.r and /dev/null differ diff --git a/etc/etc.i386/fstab.wd b/etc/etc.i386/fstab.wd deleted file mode 100644 index 95483135ee52..000000000000 --- a/etc/etc.i386/fstab.wd +++ /dev/null @@ -1,3 +0,0 @@ -/dev/wd0a / ufs rw 1 1 -#/dev/wd0d /var ufs rw 1 2 -#/dev/wd0h /usr ufs rw 1 3 diff --git a/etc/man.conf b/etc/man.conf deleted file mode 100644 index e7c5a994e813..000000000000 --- a/etc/man.conf +++ /dev/null @@ -1,34 +0,0 @@ -# @(#)man.conf 5.4 (Berkeley) 6/30/90 - -# sheer, raging paranoia... -_version BSD.1 - -# whatis/apropos database -_whatdb /usr/share/man/whatis.db - -# subdirectories for paths ending in '/'; note order -_subdir cat1 cat8 cat6 cat2 cat3 cat4 cat5 cat7 cat3f - -# sections and their directories -# paths ending in '/' are the equivalent of entries specifying that directory -# with all of the subdirectories listed for the keyword _order. - -# default -_default /usr/share/man/ /usr/share/man/old/ /usr/contrib/man/ /usr/local/man/ - -# section directory -1 /usr/share/man/cat1 -2 /usr/share/man/cat2 -3 /usr/share/man/cat3 -3F /usr/share/man/cat3f -3f /usr/share/man/cat3f -4 /usr/share/man/cat4 -5 /usr/share/man/cat5 -6 /usr/share/man/cat6 -7 /usr/share/man/cat7 -8 /usr/share/man/cat8 - -contrib /usr/contrib/man/ -local /usr/local/man/ -new /usr/contrib/man/ -old /usr/share/man/old/ diff --git a/etc/namedb/localhost.rev b/etc/namedb/localhost.rev deleted file mode 100644 index d6e59658d28b..000000000000 --- a/etc/namedb/localhost.rev +++ /dev/null @@ -1,10 +0,0 @@ -; @(#)localhost.rev 5.1 (Berkeley) 6/30/90 - -@ IN SOA ucbvax.Berkeley.EDU. rwh.ucbvax.Berkeley.EDU. ( - 1.4 ; Serial - 3600 ; Refresh - 300 ; Retry - 3600000 ; Expire - 3600 ) ; Minimum - IN NS ucbvax.Berkeley.EDU. -1 IN PTR localhost.Berkeley.EDU. diff --git a/gnu/lib/libg++/include/regex.h b/gnu/lib/libg++/include/regex.h deleted file mode 100644 index 9e404e8da100..000000000000 --- a/gnu/lib/libg++/include/regex.h +++ /dev/null @@ -1,272 +0,0 @@ -/* Definitions for data structures callers pass the regex library. - - Copyright (C) 1985, 1989-92 Free Software Foundation, Inc. - -This file is part of the GNU C++ Library. This 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. This 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 this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __REGEXP_LIBRARY -#define __REGEXP_LIBRARY - -#if defined(SHORT_NAMES) || defined(VMS) -#define re_compile_pattern recmppat -#define re_pattern_buffer repatbuf -#define re_registers reregs -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Define number of parens for which we record the beginnings and ends. - This affects how much space the `struct re_registers' type takes up. */ -#ifndef RE_NREGS -#define RE_NREGS 10 -#endif - -#define BYTEWIDTH 8 - - -/* Maximum number of duplicates an interval can allow. */ -#ifndef RE_DUP_MAX /* kludge for AIX, which defines it */ -#define RE_DUP_MAX ((1 << 15) - 1) -#endif - -/* This defines the various regexp syntaxes. */ -extern int obscure_syntax; - - -/* The following bits are used in the obscure_syntax variable to choose among - alternative regexp syntaxes. */ - -/* If this bit is set, plain parentheses serve as grouping, and backslash - parentheses are needed for literal searching. - If not set, backslash-parentheses are grouping, and plain parentheses - are for literal searching. */ -#define RE_NO_BK_PARENS 1 - -/* If this bit is set, plain | serves as the `or'-operator, and \| is a - literal. - If not set, \| serves as the `or'-operator, and | is a literal. */ -#define RE_NO_BK_VBAR (1 << 1) - -/* If this bit is not set, plain + or ? serves as an operator, and \+, \? are - literals. - If set, \+, \? are operators and plain +, ? are literals. */ -#define RE_BK_PLUS_QM (1 << 2) - -/* If this bit is set, | binds tighter than ^ or $. - If not set, the contrary. */ -#define RE_TIGHT_VBAR (1 << 3) - -/* If this bit is set, then treat newline as an OR operator. - If not set, treat it as a normal character. */ -#define RE_NEWLINE_OR (1 << 4) - -/* If this bit is set, then special characters may act as normal - characters in some contexts. Specifically, this applies to: - ^ -- only special at the beginning, or after ( or |; - $ -- only special at the end, or before ) or |; - *, +, ? -- only special when not after the beginning, (, or |. - If this bit is not set, special characters (such as *, ^, and $) - always have their special meaning regardless of the surrounding - context. */ -#define RE_CONTEXT_INDEP_OPS (1 << 5) - -/* If this bit is not set, then \ before anything inside [ and ] is taken as - a real \. - If set, then such a \ escapes the following character. This is a - special case for awk. */ -#define RE_AWK_CLASS_HACK (1 << 6) - -/* If this bit is set, then \{ and \} or { and } serve as interval operators. - If not set, then \{ and \} and { and } are treated as literals. */ -#define RE_INTERVALS (1 << 7) - -/* If this bit is not set, then \{ and \} serve as interval operators and - { and } are literals. - If set, then { and } serve as interval operators and \{ and \} are - literals. */ -#define RE_NO_BK_CURLY_BRACES (1 << 8) - -/* If this bit is set, then character classes are supported; they are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -#define RE_CHAR_CLASSES (1 << 9) - -/* If this bit is set, then the dot re doesn't match a null byte. - If not set, it does. */ -#define RE_DOT_NOT_NULL (1 << 10) - -/* If this bit is set, then [^...] doesn't match a newline. - If not set, it does. */ -#define RE_HAT_NOT_NEWLINE (1 << 11) - -/* If this bit is set, back references are recognized. - If not set, they aren't. */ -#define RE_NO_BK_REFS (1 << 12) - -/* If this bit is set, back references must refer to a preceding - subexpression. If not set, a back reference to a nonexistent - subexpression is treated as literal characters. */ -#define RE_NO_EMPTY_BK_REF (1 << 13) - -/* If this bit is set, bracket expressions can't be empty. - If it is set, they can be empty. */ -#define RE_NO_EMPTY_BRACKETS (1 << 14) - -/* If this bit is set, then *, +, ? and { cannot be first in an re or - immediately after a |, or a (. Furthermore, a | cannot be first or - last in an re, or immediately follow another | or a (. Also, a ^ - cannot appear in a nonleading position and a $ cannot appear in a - nontrailing position (outside of bracket expressions, that is). */ -#define RE_CONTEXTUAL_INVALID_OPS (1 << 15) - -/* If this bit is set, then +, ? and | aren't recognized as operators. - If it's not, they are. */ -#define RE_LIMITED_OPS (1 << 16) - -/* If this bit is set, then an ending range point has to collate higher - or equal to the starting range point. - If it's not set, then when the ending range point collates higher - than the starting range point, the range is just considered empty. */ -#define RE_NO_EMPTY_RANGES (1 << 17) - -/* If this bit is set, then a hyphen (-) can't be an ending range point. - If it isn't, then it can. */ -#define RE_NO_HYPHEN_RANGE_END (1 << 18) - - -/* Define combinations of bits for the standard possibilities. */ -#define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK) -#define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 -#define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \ - | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \ - | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \ - | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \ - | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END) - -#define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \ - | RE_NO_BK_VBAR | RE_NO_BK_PARENS \ - | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \ - | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \ - | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \ - | RE_NO_HYPHEN_RANGE_END) - - -/* This data structure is used to represent a compiled pattern. */ - -struct re_pattern_buffer - { - char *buffer; /* Space holding the compiled pattern commands. */ - long allocated; /* Size of space that `buffer' points to. */ - long used; /* Length of portion of buffer actually occupied */ - char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ - /* re_search uses the fastmap, if there is one, - to skip over totally implausible characters. */ - char *translate; /* Translate table to apply to all characters before - comparing, or zero for no translation. - The translation is applied to a pattern when it is - compiled and to data when it is matched. */ - char fastmap_accurate; - /* Set to zero when a new pattern is stored, - set to one when the fastmap is updated from it. */ - char can_be_null; /* Set to one by compiling fastmap - if this pattern might match the null string. - It does not necessarily match the null string - in that case, but if this is zero, it cannot. - 2 as value means can match null string - but at end of range or before a character - listed in the fastmap. */ - }; - - -/* search.c (search_buffer) needs this one value. It is defined both in - regex.c and here. */ -#define RE_EXACTN_VALUE 1 - - -/* Structure to store register contents data in. - - Pass the address of such a structure as an argument to re_match, etc., - if you want this information back. - - For i from 1 to RE_NREGS - 1, start[i] records the starting index in - the string of where the ith subexpression matched, and end[i] records - one after the ending index. start[0] and end[0] are analogous, for - the entire pattern. */ - -struct re_registers - { - int start[RE_NREGS]; - int end[RE_NREGS]; - }; - - - -#if defined(__STDC__) || defined(__cplusplus) - -extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *); -/* Is this really advertised? */ -extern void re_compile_fastmap (struct re_pattern_buffer *); -extern int re_search (struct re_pattern_buffer *, char*, int, int, int, - struct re_registers *); -extern int re_search_2 (struct re_pattern_buffer *, char *, int, - char *, int, int, int, - struct re_registers *, int); -extern int re_match (struct re_pattern_buffer *, char *, int, int, - struct re_registers *); -extern int re_match_2 (struct re_pattern_buffer *, char *, int, - char *, int, int, struct re_registers *, int); - -#if 0 -/* 4.2 bsd compatibility. */ -extern char *re_comp (char *); -extern int re_exec (char *); -#endif - -#else /* !__STDC__ */ - -#define const /* nothing */ -extern char *re_compile_pattern (); -/* Is this really advertised? */ -extern void re_compile_fastmap (); -extern int re_search (), re_search_2 (); -extern int re_match (), re_match_2 (); - -#if 0 -/* 4.2 bsd compatibility. */ -extern char *re_comp (); -extern int re_exec (); -#endif - -#endif /* __STDC__ */ - - -#ifdef SYNTAX_TABLE -extern char *re_syntax_table; -#endif - -#ifdef __cplusplus -extern int re_max_failures; -} -#endif - -#endif /* !__REGEXP_LIBRARY */ diff --git a/gnu/usr.bin/awk/gawk.texi b/gnu/usr.bin/awk/gawk.texi deleted file mode 100644 index b2802623136d..000000000000 --- a/gnu/usr.bin/awk/gawk.texi +++ /dev/null @@ -1,11270 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header (This is for running Texinfo on a region.) -@setfilename gawk.info -@settitle The GAWK Manual -@c @smallbook -@c %**end of header (This is for running Texinfo on a region.) - -@ifinfo -@synindex fn cp -@synindex vr cp -@end ifinfo -@iftex -@syncodeindex fn cp -@syncodeindex vr cp -@end iftex - -@c If "finalout" is commented out, the printed output will show -@c black boxes that mark lines that are too long. Thus, it is -@c unwise to comment it out when running a master in case there are -@c overfulls which are deemed okay. - -@iftex -@finalout -@end iftex - -@c ===> NOTE! <== -@c Determine the edition number in *four* places by hand: -@c 1. First ifinfo section 2. title page 3. copyright page 4. top node -@c To find the locations, search for !!set - -@ifinfo -This file documents @code{awk}, a program that you can use to select -particular records in a file and perform operations upon them. - -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -Copyright (C) 1989, 1991, 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end ifinfo - -@setchapternewpage odd - -@c !!set edition, date, version -@titlepage -@title The GAWK Manual -@subtitle Edition 0.15 -@subtitle April 1993 -@author Diane Barlow Close -@author Arnold D. Robbins -@author Paul H. Rubin -@author Richard Stallman - -@c Include the Distribution inside the titlepage environment so -@c that headings are turned off. Headings on and off do not work. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1991, 1992, 1993 Free Software Foundation, Inc. -@sp 2 - -@c !!set edition, date, version -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -@sp 2 -Published by the Free Software Foundation @* -675 Massachusetts Avenue @* -Cambridge, MA 02139 USA @* -Printed copies are available for $20 each. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end titlepage - -@ifinfo -@node Top, Preface, (dir), (dir) -@comment node-name, next, previous, up -@top General Introduction -@c Preface or Licensing nodes should come right after the Top -@c node, in `unnumbered' sections, then the chapter, `What is gawk'. - -This file documents @code{awk}, a program that you can use to select -particular records in a file and perform operations upon them. - -@c !!set edition, date, version -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -@end ifinfo - -@menu -* Preface:: What you can do with @code{awk}; brief history - and acknowledgements. -* Copying:: Your right to copy and distribute @code{gawk}. -* This Manual:: Using this manual. - Includes sample input files that you can use. -* Getting Started:: A basic introduction to using @code{awk}. - How to run an @code{awk} program. - Command line syntax. -* Reading Files:: How to read files and manipulate fields. -* Printing:: How to print using @code{awk}. Describes the - @code{print} and @code{printf} statements. - Also describes redirection of output. -* One-liners:: Short, sample @code{awk} programs. -* Patterns:: The various types of patterns - explained in detail. -* Actions:: The various types of actions are - introduced here. Describes - expressions and the various operators in - detail. Also describes comparison expressions. -* Expressions:: Expressions are the basic building - blocks of statements. -* Statements:: The various control statements are - described in detail. -* Arrays:: The description and use of arrays. - Also includes array-oriented control - statements. -* Built-in:: The built-in functions are summarized here. -* User-defined:: User-defined functions are described in detail. -* Built-in Variables:: Built-in Variables -* Command Line:: How to run @code{gawk}. -* Language History:: The evolution of the @code{awk} language. -* Installation:: Installing @code{gawk} under - various operating systems. -* Gawk Summary:: @code{gawk} Options and Language Summary. -* Sample Program:: A sample @code{awk} program with a - complete explanation. -* Bugs:: Reporting Problems and Bugs. -* Notes:: Something about the - implementation of @code{gawk}. -* Glossary:: An explanation of some unfamiliar terms. -* Index:: -@end menu - -@node Preface, Copying, Top, Top -@comment node-name, next, previous, up -@unnumbered Preface - -@iftex -@cindex what is @code{awk} -@end iftex -If you are like many computer users, you would frequently like to make -changes in various text files wherever certain patterns appear, or -extract data from parts of certain lines while discarding the rest. To -write a program to do this in a language such as C or Pascal is a -time-consuming inconvenience that may take many lines of code. The job -may be easier with @code{awk}. - -The @code{awk} utility interprets a special-purpose programming language -that makes it possible to handle simple data-reformatting jobs easily -with just a few lines of code. - -The GNU implementation of @code{awk} is called @code{gawk}; it is fully -upward compatible with the System V Release 4 version of -@code{awk}. @code{gawk} is also upward compatible with the @sc{posix} -(draft) specification of the @code{awk} language. This means that all -properly written @code{awk} programs should work with @code{gawk}. -Thus, we usually don't distinguish between @code{gawk} and other @code{awk} -implementations in this manual.@refill - -@cindex uses of @code{awk} -This manual teaches you what @code{awk} does and how you can use -@code{awk} effectively. You should already be familiar with basic -system commands such as @code{ls}. Using @code{awk} you can: @refill - -@itemize @bullet -@item -manage small, personal databases - -@item -generate reports - -@item -validate data -@item -produce indexes, and perform other document preparation tasks - -@item -even experiment with algorithms that can be adapted later to other computer -languages -@end itemize - -@iftex -This manual has the difficult task of being both tutorial and reference. -If you are a novice, feel free to skip over details that seem too complex. -You should also ignore the many cross references; they are for the -expert user, and for the on-line Info version of the manual. -@end iftex - -@menu -* History:: The history of @code{gawk} and - @code{awk}. Acknowledgements. -@end menu - -@node History, , Preface, Preface -@comment node-name, next, previous, up -@unnumberedsec History of @code{awk} and @code{gawk} - -@cindex acronym -@cindex history of @code{awk} -The name @code{awk} comes from the initials of its designers: Alfred V. -Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version of -@code{awk} was written in 1977. In 1985 a new version made the programming -language more powerful, introducing user-defined functions, multiple input -streams, and computed regular expressions. -This new version became generally available with System V Release 3.1. -The version in System V Release 4 added some new features and also cleaned -up the behavior in some of the ``dark corners'' of the language. -The specification for @code{awk} in the @sc{posix} Command Language -and Utilities standard further clarified the language based on feedback -from both the @code{gawk} designers, and the original @code{awk} -designers.@refill - -The GNU implementation, @code{gawk}, was written in 1986 by Paul Rubin -and Jay Fenlason, with advice from Richard Stallman. John Woods -contributed parts of the code as well. In 1988 and 1989, David Trueman, with -help from Arnold Robbins, thoroughly reworked @code{gawk} for compatibility -with the newer @code{awk}. Current development (1992) focuses on bug fixes, -performance improvements, and standards compliance. - -We need to thank many people for their assistance in producing this -manual. Jay Fenlason contributed many ideas and sample programs. Richard -Mlynarik and Robert J. Chassell gave helpful comments on early drafts of this -manual. The paper @cite{A Supplemental Document for @code{awk}} by John W. -Pierce of the Chemistry Department at UC San Diego, pinpointed several -issues relevant both to @code{awk} implementation and to this manual, that -would otherwise have escaped us. David Trueman, Pat Rankin, and Michal -Jaegermann also contributed sections of the manual.@refill - -The following people provided many helpful comments on this edition of -the manual: Rick Adams, Michael Brennan, Rich Burridge, Diane Close, -Christopher (``Topher'') Eliot, Michael Lijewski, Pat Rankin, Miriam Robbins, -and Michal Jaegermann. Robert J. Chassell provided much valuable advice on -the use of Texinfo. - -Finally, we would like to thank Brian Kernighan of Bell Labs for invaluable -assistance during the testing and debugging of @code{gawk}, and for -help in clarifying numerous points about the language.@refill - -@node Copying, This Manual, Preface, Top -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@c fakenode --- for prepinfo -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@c fakenode --- for prepinfo -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end enumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@enumerate a -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end enumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@c fakenode --- for prepinfo -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@c fakenode --- for prepinfo -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@c fakenode --- for prepinfo -@unnumberedsec How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end smallexample - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - -@node This Manual, Getting Started, Copying, Top -@chapter Using this Manual -@cindex manual, using this -@cindex using this manual -@cindex language, @code{awk} -@cindex program, @code{awk} -@cindex @code{awk} language -@cindex @code{awk} program - -The term @code{awk} refers to a particular program, and to the language you -use to tell this program what to do. When we need to be careful, we call -the program ``the @code{awk} utility'' and the language ``the @code{awk} -language.'' The term @code{gawk} refers to a version of @code{awk} developed -as part the GNU project. The purpose of this manual is to explain -both the -@code{awk} language and how to run the @code{awk} utility.@refill - -While concentrating on the features of @code{gawk}, the manual will also -attempt to describe important differences between @code{gawk} and other -@code{awk} implementations. In particular, any features that are not -in the @sc{posix} standard for @code{awk} will be noted. @refill - -The term @dfn{@code{awk} program} refers to a program written by you in -the @code{awk} programming language.@refill - -@xref{Getting Started, ,Getting Started with @code{awk}}, for the bare -essentials you need to know to start using @code{awk}. - -Some useful ``one-liners'' are included to give you a feel for the -@code{awk} language (@pxref{One-liners, ,Useful ``One-liners''}). - -@ignore -@strong{I deleted four paragraphs here because they would confuse the -beginner more than help him. They mention terms such as ``field,'' -``pattern,'' ``action,'' ``built-in function'' which the beginner -doesn't know.} - -@strong{If you can find a way to introduce several of these concepts here, -enough to give the reader a map of what is to follow, that might -be useful. I'm not sure that can be done without taking up more -space than ought to be used here. There may be no way to win.} - -@strong{ADR: I'd like to tackle this in phase 2 of my editing.} -@end ignore - -A sample @code{awk} program has been provided for you -(@pxref{Sample Program}).@refill - -If you find terms that you aren't familiar with, try looking them -up in the glossary (@pxref{Glossary}).@refill - -The entire @code{awk} language is summarized for quick reference in -@ref{Gawk Summary, ,@code{gawk} Summary}. Look there if you just need -to refresh your memory about a particular feature.@refill - -Most of the time complete @code{awk} programs are used as examples, but in -some of the more advanced sections, only the part of the @code{awk} program -that illustrates the concept being described is shown.@refill - -@menu -* Sample Data Files:: Sample data files for use in the @code{awk} - programs illustrated in this manual. -@end menu - -@node Sample Data Files, , This Manual, This Manual -@section Data Files for the Examples - -@cindex input file, sample -@cindex sample input file -@cindex @file{BBS-list} file -Many of the examples in this manual take their input from two sample -data files. The first, called @file{BBS-list}, represents a list of -computer bulletin board systems together with information about those systems. -The second data file, called @file{inventory-shipped}, contains -information about shipments on a monthly basis. Each line of these -files is one @dfn{record}. - -In the file @file{BBS-list}, each record contains the name of a computer -bulletin board, its phone number, the board's baud rate, and a code for -the number of hours it is operational. An @samp{A} in the last column -means the board operates 24 hours a day. A @samp{B} in the last -column means the board operates evening and weekend hours, only. A -@samp{C} means the board operates only on weekends. - -@example -aardvark 555-5553 1200/300 B -alpo-net 555-3412 2400/1200/300 A -barfly 555-7685 1200/300 A -bites 555-1675 2400/1200/300 A -camelot 555-0542 300 C -core 555-2912 1200/300 C -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sdace 555-3430 2400/1200/300 A -sabafoo 555-2127 1200/300 C -@end example - -@cindex @file{inventory-shipped} file -The second data file, called @file{inventory-shipped}, represents -information about shipments during the year. -Each record contains the month of the year, the number -of green crates shipped, the number of red boxes shipped, the number of -orange bags shipped, and the number of blue packages shipped, -respectively. There are 16 entries, covering the 12 months of one year -and 4 months of the next year.@refill - -@example -Jan 13 25 15 115 -Feb 15 32 24 226 -Mar 15 24 34 228 -Apr 31 52 63 420 -May 16 34 29 208 -Jun 31 42 75 492 -Jul 24 34 67 436 -Aug 15 34 47 316 -Sep 13 55 37 277 -Oct 29 54 68 525 -Nov 20 87 82 577 -Dec 17 35 61 401 - -Jan 21 36 64 620 -Feb 26 58 80 652 -Mar 24 75 70 495 -Apr 21 70 74 514 -@end example - -@ifinfo -If you are reading this in GNU Emacs using Info, you can copy the regions -of text showing these sample files into your own test files. This way you -can try out the examples shown in the remainder of this document. You do -this by using the command @kbd{M-x write-region} to copy text from the Info -file into a file for use with @code{awk} -(@xref{Misc File Ops, , , emacs, GNU Emacs Manual}, -for more information). Using this information, create your own -@file{BBS-list} and @file{inventory-shipped} files, and practice what you -learn in this manual. -@end ifinfo - -@node Getting Started, Reading Files, This Manual, Top -@chapter Getting Started with @code{awk} -@cindex script, definition of -@cindex rule, definition of -@cindex program, definition of -@cindex basic function of @code{gawk} - -The basic function of @code{awk} is to search files for lines (or other -units of text) that contain certain patterns. When a line matches one -of the patterns, @code{awk} performs specified actions on that line. -@code{awk} keeps processing input lines in this way until the end of the -input file is reached.@refill - -When you run @code{awk}, you specify an @code{awk} @dfn{program} which -tells @code{awk} what to do. The program consists of a series of -@dfn{rules}. (It may also contain @dfn{function definitions}, but that -is an advanced feature, so we will ignore it for now. -@xref{User-defined, ,User-defined Functions}.) Each rule specifies one -pattern to search for, and one action to perform when that pattern is found. - -Syntactically, a rule consists of a pattern followed by an action. The -action is enclosed in curly braces to separate it from the pattern. -Rules are usually separated by newlines. Therefore, an @code{awk} -program looks like this: - -@example -@var{pattern} @{ @var{action} @} -@var{pattern} @{ @var{action} @} -@dots{} -@end example - -@menu -* Very Simple:: A very simple example. -* Two Rules:: A less simple one-line example with two rules. -* More Complex:: A more complex example. -* Running gawk:: How to run @code{gawk} programs; - includes command line syntax. -* Comments:: Adding documentation to @code{gawk} programs. -* Statements/Lines:: Subdividing or combining statements into lines. -* When:: When to use @code{gawk} and - when to use other things. -@end menu - -@node Very Simple, Two Rules, Getting Started, Getting Started -@section A Very Simple Example - -@cindex @samp{print $0} -The following command runs a simple @code{awk} program that searches the -input file @file{BBS-list} for the string of characters: @samp{foo}. (A -string of characters is usually called, a @dfn{string}. -The term @dfn{string} is perhaps based on similar usage in English, such -as ``a string of pearls,'' or, ``a string of cars in a train.'') - -@example -awk '/foo/ @{ print $0 @}' BBS-list -@end example - -@noindent -When lines containing @samp{foo} are found, they are printed, because -@w{@samp{print $0}} means print the current line. (Just @samp{print} by -itself means the same thing, so we could have written that -instead.) - -You will notice that slashes, @samp{/}, surround the string @samp{foo} -in the actual @code{awk} program. The slashes indicate that @samp{foo} -is a pattern to search for. This type of pattern is called a -@dfn{regular expression}, and is covered in more detail later -(@pxref{Regexp, ,Regular Expressions as Patterns}). There are -single-quotes around the @code{awk} program so that the shell won't -interpret any of it as special shell characters.@refill - -Here is what this program prints: - -@example -@group -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sabafoo 555-2127 1200/300 C -@end group -@end example - -@cindex action, default -@cindex pattern, default -@cindex default action -@cindex default pattern -In an @code{awk} rule, either the pattern or the action can be omitted, -but not both. If the pattern is omitted, then the action is performed -for @emph{every} input line. If the action is omitted, the default -action is to print all lines that match the pattern. - -Thus, we could leave out the action (the @code{print} statement and the curly -braces) in the above example, and the result would be the same: all -lines matching the pattern @samp{foo} would be printed. By comparison, -omitting the @code{print} statement but retaining the curly braces makes an -empty action that does nothing; then no lines would be printed. - -@node Two Rules, More Complex, Very Simple, Getting Started -@section An Example with Two Rules -@cindex how @code{awk} works - -The @code{awk} utility reads the input files one line at a -time. For each line, @code{awk} tries the patterns of each of the rules. -If several patterns match then several actions are run, in the order in -which they appear in the @code{awk} program. If no patterns match, then -no actions are run. - -After processing all the rules (perhaps none) that match the line, -@code{awk} reads the next line (however, -@pxref{Next Statement, ,The @code{next} Statement}). This continues -until the end of the file is reached.@refill - -For example, the @code{awk} program: - -@example -/12/ @{ print $0 @} -/21/ @{ print $0 @} -@end example - -@noindent -contains two rules. The first rule has the string @samp{12} as the -pattern and @samp{print $0} as the action. The second rule has the -string @samp{21} as the pattern and also has @samp{print $0} as the -action. Each rule's action is enclosed in its own pair of braces. - -This @code{awk} program prints every line that contains the string -@samp{12} @emph{or} the string @samp{21}. If a line contains both -strings, it is printed twice, once by each rule. - -If we run this program on our two sample data files, @file{BBS-list} and -@file{inventory-shipped}, as shown here: - -@example -awk '/12/ @{ print $0 @} - /21/ @{ print $0 @}' BBS-list inventory-shipped -@end example - -@noindent -we get the following output: - -@example -aardvark 555-5553 1200/300 B -alpo-net 555-3412 2400/1200/300 A -barfly 555-7685 1200/300 A -bites 555-1675 2400/1200/300 A -core 555-2912 1200/300 C -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sdace 555-3430 2400/1200/300 A -sabafoo 555-2127 1200/300 C -sabafoo 555-2127 1200/300 C -Jan 21 36 64 620 -Apr 21 70 74 514 -@end example - -@noindent -Note how the line in @file{BBS-list} beginning with @samp{sabafoo} -was printed twice, once for each rule. - -@node More Complex, Running gawk, Two Rules, Getting Started -@comment node-name, next, previous, up -@section A More Complex Example - -Here is an example to give you an idea of what typical @code{awk} -programs do. This example shows how @code{awk} can be used to -summarize, select, and rearrange the output of another utility. It uses -features that haven't been covered yet, so don't worry if you don't -understand all the details. - -@example -ls -l | awk '$5 == "Nov" @{ sum += $4 @} - END @{ print sum @}' -@end example - -This command prints the total number of bytes in all the files in the -current directory that were last modified in November (of any year). -(In the C shell you would need to type a semicolon and then a backslash -at the end of the first line; in a @sc{posix}-compliant shell, such as the -Bourne shell or the Bourne-Again shell, you can type the example as shown.) - -The @w{@samp{ls -l}} part of this example is a command that gives you a -listing of the files in a directory, including file size and date. -Its output looks like this:@refill - -@example --rw-r--r-- 1 close 1933 Nov 7 13:05 Makefile --rw-r--r-- 1 close 10809 Nov 7 13:03 gawk.h --rw-r--r-- 1 close 983 Apr 13 12:14 gawk.tab.h --rw-r--r-- 1 close 31869 Jun 15 12:20 gawk.y --rw-r--r-- 1 close 22414 Nov 7 13:03 gawk1.c --rw-r--r-- 1 close 37455 Nov 7 13:03 gawk2.c --rw-r--r-- 1 close 27511 Dec 9 13:07 gawk3.c --rw-r--r-- 1 close 7989 Nov 7 13:03 gawk4.c -@end example - -@noindent -The first field contains read-write permissions, the second field contains -the number of links to the file, and the third field identifies the owner of -the file. The fourth field contains the size of the file in bytes. The -fifth, sixth, and seventh fields contain the month, day, and time, -respectively, that the file was last modified. Finally, the eighth field -contains the name of the file. - -The @code{$5 == "Nov"} in our @code{awk} program is an expression that -tests whether the fifth field of the output from @w{@samp{ls -l}} -matches the string @samp{Nov}. Each time a line has the string -@samp{Nov} in its fifth field, the action @samp{@{ sum += $4 @}} is -performed. This adds the fourth field (the file size) to the variable -@code{sum}. As a result, when @code{awk} has finished reading all the -input lines, @code{sum} is the sum of the sizes of files whose -lines matched the pattern. (This works because @code{awk} variables -are automatically initialized to zero.)@refill - -After the last line of output from @code{ls} has been processed, the -@code{END} rule is executed, and the value of @code{sum} is -printed. In this example, the value of @code{sum} would be 80600.@refill - -These more advanced @code{awk} techniques are covered in later sections -(@pxref{Actions, ,Overview of Actions}). Before you can move on to more -advanced @code{awk} programming, you have to know how @code{awk} interprets -your input and displays your output. By manipulating fields and using -@code{print} statements, you can produce some very useful and spectacular -looking reports.@refill - -@node Running gawk, Comments, More Complex, Getting Started -@section How to Run @code{awk} Programs - -@ignore -Date: Mon, 26 Aug 91 09:48:10 +0200 -From: gatech!vsoc07.cern.ch!matheys (Jean-Pol Matheys (CERN - ECP Division)) -To: uunet.UU.NET!skeeve!arnold -Subject: RE: status check - -The introduction of Chapter 2 (i.e. before 2.1) should include -the whole of section 2.4 - it's better to tell people how to run awk programs -before giving any examples - -ADR --- he's right. but for now, don't do this because the rest of the -chapter would need some rewriting. -@end ignore - -@cindex command line formats -@cindex running @code{awk} programs -There are several ways to run an @code{awk} program. If the program is -short, it is easiest to include it in the command that runs @code{awk}, -like this: - -@example -awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} -@end example - -@noindent -where @var{program} consists of a series of patterns and actions, as -described earlier. - -When the program is long, it is usually more convenient to put it in a file -and run it with a command like this: - -@example -awk -f @var{program-file} @var{input-file1} @var{input-file2} @dots{} -@end example - -@menu -* One-shot:: Running a short throw-away @code{awk} program. -* Read Terminal:: Using no input files (input from - terminal instead). -* Long:: Putting permanent @code{awk} programs in files. -* Executable Scripts:: Making self-contained @code{awk} programs. -@end menu - -@node One-shot, Read Terminal, Running gawk, Running gawk -@subsection One-shot Throw-away @code{awk} Programs - -Once you are familiar with @code{awk}, you will often type simple -programs at the moment you want to use them. Then you can write the -program as the first argument of the @code{awk} command, like this: - -@example -awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} -@end example - -@noindent -where @var{program} consists of a series of @var{patterns} and -@var{actions}, as described earlier. - -@cindex single quotes, why needed -This command format instructs the shell to start @code{awk} and use the -@var{program} to process records in the input file(s). There are single -quotes around @var{program} so that the shell doesn't interpret any -@code{awk} characters as special shell characters. They also cause the -shell to treat all of @var{program} as a single argument for -@code{awk} and allow @var{program} to be more than one line long.@refill - -This format is also useful for running short or medium-sized @code{awk} -programs from shell scripts, because it avoids the need for a separate -file for the @code{awk} program. A self-contained shell script is more -reliable since there are no other files to misplace. - -@node Read Terminal, Long, One-shot, Running gawk -@subsection Running @code{awk} without Input Files - -@cindex standard input -@cindex input, standard -You can also run @code{awk} without any input files. If you type the -command line:@refill - -@example -awk '@var{program}' -@end example - -@noindent -then @code{awk} applies the @var{program} to the @dfn{standard input}, -which usually means whatever you type on the terminal. This continues -until you indicate end-of-file by typing @kbd{Control-d}. - -For example, if you execute this command: - -@example -awk '/th/' -@end example - -@noindent -whatever you type next is taken as data for that @code{awk} -program. If you go on to type the following data: - -@example -Kathy -Ben -Tom -Beth -Seth -Karen -Thomas -@kbd{Control-d} -@end example - -@noindent -then @code{awk} prints this output: - -@example -Kathy -Beth -Seth -@end example - -@noindent -@cindex case sensitivity -@cindex pattern, case sensitive -as matching the pattern @samp{th}. Notice that it did not recognize -@samp{Thomas} as matching the pattern. The @code{awk} language is -@dfn{case sensitive}, and matches patterns exactly. (However, you can -override this with the variable @code{IGNORECASE}. -@xref{Case-sensitivity, ,Case-sensitivity in Matching}.) - -@node Long, Executable Scripts, Read Terminal, Running gawk -@subsection Running Long Programs - -@cindex running long programs -@cindex @samp{-f} option -@cindex program file -@cindex file, @code{awk} program -Sometimes your @code{awk} programs can be very long. In this case it is -more convenient to put the program into a separate file. To tell -@code{awk} to use that file for its program, you type:@refill - -@example -awk -f @var{source-file} @var{input-file1} @var{input-file2} @dots{} -@end example - -The @samp{-f} instructs the @code{awk} utility to get the @code{awk} program -from the file @var{source-file}. Any file name can be used for -@var{source-file}. For example, you could put the program:@refill - -@example -/th/ -@end example - -@noindent -into the file @file{th-prog}. Then this command: - -@example -awk -f th-prog -@end example - -@noindent -does the same thing as this one: - -@example -awk '/th/' -@end example - -@noindent -which was explained earlier (@pxref{Read Terminal, ,Running @code{awk} without Input Files}). -Note that you don't usually need single quotes around the file name that you -specify with @samp{-f}, because most file names don't contain any of the shell's -special characters. Notice that in @file{th-prog}, the @code{awk} -program did not have single quotes around it. The quotes are only needed -for programs that are provided on the @code{awk} command line. - -If you want to identify your @code{awk} program files clearly as such, -you can add the extension @file{.awk} to the file name. This doesn't -affect the execution of the @code{awk} program, but it does make -``housekeeping'' easier. - -@node Executable Scripts, , Long, Running gawk -@c node-name, next, previous, up -@subsection Executable @code{awk} Programs -@cindex executable scripts -@cindex scripts, executable -@cindex self contained programs -@cindex program, self contained -@cindex @samp{#!} - -Once you have learned @code{awk}, you may want to write self-contained -@code{awk} scripts, using the @samp{#!} script mechanism. You can do -this on many Unix systems @footnote{The @samp{#!} mechanism works on -Unix systems derived from Berkeley Unix, System V Release 4, and some System -V Release 3 systems.} (and someday on GNU).@refill - -For example, you could create a text file named @file{hello}, containing -the following (where @samp{BEGIN} is a feature we have not yet -discussed): - -@example -#! /bin/awk -f - -# a sample awk program -BEGIN @{ print "hello, world" @} -@end example - -@noindent -After making this file executable (with the @code{chmod} command), you -can simply type: - -@example -hello -@end example - -@noindent -at the shell, and the system will arrange to run @code{awk} @footnote{The -line beginning with @samp{#!} lists the full pathname of an interpreter -to be run, and an optional initial command line argument to pass to that -interpreter. The operating system then runs the interpreter with the given -argument and the full argument list of the executed program. The first argument -in the list is the full pathname of the @code{awk} program. The rest of the -argument list will either be options to @code{awk}, or data files, -or both.} as if you had typed:@refill - -@example -awk -f hello -@end example - -@noindent -Self-contained @code{awk} scripts are useful when you want to write a -program which users can invoke without knowing that the program is -written in @code{awk}. - -@cindex shell scripts -@cindex scripts, shell -If your system does not support the @samp{#!} mechanism, you can get a -similar effect using a regular shell script. It would look something -like this: - -@example -: The colon makes sure this script is executed by the Bourne shell. -awk '@var{program}' "$@@" -@end example - -Using this technique, it is @emph{vital} to enclose the @var{program} in -single quotes to protect it from interpretation by the shell. If you -omit the quotes, only a shell wizard can predict the results. - -The @samp{"$@@"} causes the shell to forward all the command line -arguments to the @code{awk} program, without interpretation. The first -line, which starts with a colon, is used so that this shell script will -work even if invoked by a user who uses the C shell. -@c Someday: (See @cite{The Bourne Again Shell}, by ??.) - -@node Comments, Statements/Lines, Running gawk, Getting Started -@section Comments in @code{awk} Programs -@cindex @samp{#} -@cindex comments -@cindex use of comments -@cindex documenting @code{awk} programs -@cindex programs, documenting - -A @dfn{comment} is some text that is included in a program for the sake -of human readers, and that is not really part of the program. Comments -can explain what the program does, and how it works. Nearly all -programming languages have provisions for comments, because programs are -typically hard to understand without their extra help. - -In the @code{awk} language, a comment starts with the sharp sign -character, @samp{#}, and continues to the end of the line. The -@code{awk} language ignores the rest of a line following a sharp sign. -For example, we could have put the following into @file{th-prog}:@refill - -@smallexample -# This program finds records containing the pattern @samp{th}. This is how -# you continue comments on additional lines. -/th/ -@end smallexample - -You can put comment lines into keyboard-composed throw-away @code{awk} -programs also, but this usually isn't very useful; the purpose of a -comment is to help you or another person understand the program at -a later time.@refill - -@node Statements/Lines, When, Comments, Getting Started -@section @code{awk} Statements versus Lines - -Most often, each line in an @code{awk} program is a separate statement or -separate rule, like this: - -@example -awk '/12/ @{ print $0 @} - /21/ @{ print $0 @}' BBS-list inventory-shipped -@end example - -But sometimes statements can be more than one line, and lines can -contain several statements. You can split a statement into multiple -lines by inserting a newline after any of the following:@refill - -@example -, @{ ? : || && do else -@end example - -@noindent -A newline at any other point is considered the end of the statement. -(Splitting lines after @samp{?} and @samp{:} is a minor @code{gawk} -extension. The @samp{?} and @samp{:} referred to here is the -three operand conditional expression described in -@ref{Conditional Exp, ,Conditional Expressions}.)@refill - -@cindex backslash continuation -@cindex continuation of lines -If you would like to split a single statement into two lines at a point -where a newline would terminate it, you can @dfn{continue} it by ending the -first line with a backslash character, @samp{\}. This is allowed -absolutely anywhere in the statement, even in the middle of a string or -regular expression. For example: - -@example -awk '/This program is too long, so continue it\ - on the next line/ @{ print $1 @}' -@end example - -@noindent -We have generally not used backslash continuation in the sample programs in -this manual. Since in @code{gawk} there is no limit on the length of a line, -it is never strictly necessary; it just makes programs prettier. We have -preferred to make them even more pretty by keeping the statements short. -Backslash continuation is most useful when your @code{awk} program is in a -separate source file, instead of typed in on the command line. You should -also note that many @code{awk} implementations are more picky about where -you may use backslash continuation. For maximal portability of your @code{awk} -programs, it is best not to split your lines in the middle of a regular -expression or a string.@refill - -@strong{Warning: backslash continuation does not work as described above -with the C shell.} Continuation with backslash works for @code{awk} -programs in files, and also for one-shot programs @emph{provided} you -are using a @sc{posix}-compliant shell, such as the Bourne shell or the -Bourne-again shell. But the C shell used on Berkeley Unix behaves -differently! There, you must use two backslashes in a row, followed by -a newline.@refill - -@cindex multiple statements on one line -When @code{awk} statements within one rule are short, you might want to put -more than one of them on a line. You do this by separating the statements -with a semicolon, @samp{;}. -This also applies to the rules themselves. -Thus, the previous program could have been written:@refill - -@example -/12/ @{ print $0 @} ; /21/ @{ print $0 @} -@end example - -@noindent -@strong{Note:} the requirement that rules on the same line must be -separated with a semicolon is a recent change in the @code{awk} -language; it was done for consistency with the treatment of statements -within an action. - -@node When, , Statements/Lines, Getting Started -@section When to Use @code{awk} - -@cindex when to use @code{awk} -@cindex applications of @code{awk} -You might wonder how @code{awk} might be useful for you. Using additional -utility programs, more advanced patterns, field separators, arithmetic -statements, and other selection criteria, you can produce much more -complex output. The @code{awk} language is very useful for producing -reports from large amounts of raw data, such as summarizing information -from the output of other utility programs like @code{ls}. -(@xref{More Complex, ,A More Complex Example}.) - -Programs written with @code{awk} are usually much smaller than they would -be in other languages. This makes @code{awk} programs easy to compose and -use. Often @code{awk} programs can be quickly composed at your terminal, -used once, and thrown away. Since @code{awk} programs are interpreted, you -can avoid the usually lengthy edit-compile-test-debug cycle of software -development. - -Complex programs have been written in @code{awk}, including a complete -retargetable assembler for 8-bit microprocessors (@pxref{Glossary}, for -more information) and a microcode assembler for a special purpose Prolog -computer. However, @code{awk}'s capabilities are strained by tasks of -such complexity. - -If you find yourself writing @code{awk} scripts of more than, say, a few -hundred lines, you might consider using a different programming -language. Emacs Lisp is a good choice if you need sophisticated string -or pattern matching capabilities. The shell is also good at string and -pattern matching; in addition, it allows powerful use of the system -utilities. More conventional languages, such as C, C++, and Lisp, offer -better facilities for system programming and for managing the complexity -of large programs. Programs in these languages may require more lines -of source code than the equivalent @code{awk} programs, but they are -easier to maintain and usually run more efficiently.@refill - -@node Reading Files, Printing, Getting Started, Top -@chapter Reading Input Files - -@cindex reading files -@cindex input -@cindex standard input -@vindex FILENAME -In the typical @code{awk} program, all input is read either from the -standard input (by default the keyboard, but often a pipe from another -command) or from files whose names you specify on the @code{awk} command -line. If you specify input files, @code{awk} reads them in order, reading -all the data from one before going on to the next. The name of the current -input file can be found in the built-in variable @code{FILENAME} -(@pxref{Built-in Variables}).@refill - -The input is read in units called records, and processed by the -rules one record at a time. By default, each record is one line. Each -record is split automatically into fields, to make it more -convenient for a rule to work on its parts. - -On rare occasions you will need to use the @code{getline} command, -which can do explicit input from any number of files -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@menu -* Records:: Controlling how data is split into records. -* Fields:: An introduction to fields. -* Non-Constant Fields:: Non-constant Field Numbers. -* Changing Fields:: Changing the Contents of a Field. -* Field Separators:: The field separator and how to change it. -* Constant Size:: Reading constant width data. -* Multiple Line:: Reading multi-line records. -* Getline:: Reading files under explicit program control - using the @code{getline} function. -* Close Input:: Closing an input file (so you can read from - the beginning once more). -@end menu - -@node Records, Fields, Reading Files, Reading Files -@section How Input is Split into Records - -@cindex record separator -The @code{awk} language divides its input into records and fields. -Records are separated by a character called the @dfn{record separator}. -By default, the record separator is the newline character, defining -a record to be a single line of text.@refill - -@iftex -@cindex changing the record separator -@end iftex -@vindex RS -Sometimes you may want to use a different character to separate your -records. You can use a different character by changing the built-in -variable @code{RS}. The value of @code{RS} is a string that says how -to separate records; the default value is @code{"\n"}, the string containing -just a newline character. This is why records are, by default, single lines. - -@code{RS} can have any string as its value, but only the first character -of the string is used as the record separator. The other characters are -ignored. @code{RS} is exceptional in this regard; @code{awk} uses the -full value of all its other built-in variables.@refill - -@ignore -Someday this should be true! - -The value of @code{RS} is not limited to a one-character string. It can -be any regular expression (@pxref{Regexp, ,Regular Expressions as Patterns}). -In general, each record -ends at the next string that matches the regular expression; the next -record starts at the end of the matching string. This general rule is -actually at work in the usual case, where @code{RS} contains just a -newline: a record ends at the beginning of the next matching string (the -next newline in the input) and the following record starts just after -the end of this string (at the first character of the following line). -The newline, since it matches @code{RS}, is not part of either record.@refill -@end ignore - -You can change the value of @code{RS} in the @code{awk} program with the -assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}). -The new record-separator character should be enclosed in quotation marks to make -a string constant. Often the right time to do this is at the beginning -of execution, before any input has been processed, so that the very -first record will be read with the proper separator. To do this, use -the special @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). For -example:@refill - -@example -awk 'BEGIN @{ RS = "/" @} ; @{ print $0 @}' BBS-list -@end example - -@noindent -changes the value of @code{RS} to @code{"/"}, before reading any input. -This is a string whose first character is a slash; as a result, records -are separated by slashes. Then the input file is read, and the second -rule in the @code{awk} program (the action with no pattern) prints each -record. Since each @code{print} statement adds a newline at the end of -its output, the effect of this @code{awk} program is to copy the input -with each slash changed to a newline. - -Another way to change the record separator is on the command line, -using the variable-assignment feature -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@example -awk '@{ print $0 @}' RS="/" BBS-list -@end example - -@noindent -This sets @code{RS} to @samp{/} before processing @file{BBS-list}. - -Reaching the end of an input file terminates the current input record, -even if the last character in the file is not the character in @code{RS}. - -@ignore -@c merge the preceding paragraph and this stuff into one paragraph -@c and put it in an `expert info' section. -This produces correct behavior in the vast majority of cases, although -the following (extreme) pipeline prints a surprising @samp{1}. (There -is one field, consisting of a newline.) - -@example -echo | awk 'BEGIN @{ RS = "a" @} ; @{ print NF @}' -@end example - -@end ignore - -The empty string, @code{""} (a string of no characters), has a special meaning -as the value of @code{RS}: it means that records are separated only -by blank lines. @xref{Multiple Line, ,Multiple-Line Records}, for more details. - -@cindex number of records, @code{NR} or @code{FNR} -@vindex NR -@vindex FNR -The @code{awk} utility keeps track of the number of records that have -been read so far from the current input file. This value is stored in a -built-in variable called @code{FNR}. It is reset to zero when a new -file is started. Another built-in variable, @code{NR}, is the total -number of input records read so far from all files. It starts at zero -but is never automatically reset to zero. - -If you change the value of @code{RS} in the middle of an @code{awk} run, -the new value is used to delimit subsequent records, but the record -currently being processed (and records already processed) are not -affected. - -@node Fields, Non-Constant Fields, Records, Reading Files -@section Examining Fields - -@cindex examining fields -@cindex fields -@cindex accessing fields -When @code{awk} reads an input record, the record is -automatically separated or @dfn{parsed} by the interpreter into chunks -called @dfn{fields}. By default, fields are separated by whitespace, -like words in a line. -Whitespace in @code{awk} means any string of one or more spaces and/or -tabs; other characters such as newline, formfeed, and so on, that are -considered whitespace by other languages are @emph{not} considered -whitespace by @code{awk}.@refill - -The purpose of fields is to make it more convenient for you to refer to -these pieces of the record. You don't have to use them---you can -operate on the whole record if you wish---but fields are what make -simple @code{awk} programs so powerful. - -@cindex @code{$} (field operator) -@cindex operators, @code{$} -To refer to a field in an @code{awk} program, you use a dollar-sign, -@samp{$}, followed by the number of the field you want. Thus, @code{$1} -refers to the first field, @code{$2} to the second, and so on. For -example, suppose the following is a line of input:@refill - -@example -This seems like a pretty nice example. -@end example - -@noindent -Here the first field, or @code{$1}, is @samp{This}; the second field, or -@code{$2}, is @samp{seems}; and so on. Note that the last field, -@code{$7}, is @samp{example.}. Because there is no space between the -@samp{e} and the @samp{.}, the period is considered part of the seventh -field.@refill - -No matter how many fields there are, the last field in a record can be -represented by @code{$NF}. So, in the example above, @code{$NF} would -be the same as @code{$7}, which is @samp{example.}. Why this works is -explained below (@pxref{Non-Constant Fields, ,Non-constant Field Numbers}). -If you try to refer to a field beyond the last one, such as @code{$8} -when the record has only 7 fields, you get the empty string.@refill - -@vindex NF -@cindex number of fields, @code{NF} -Plain @code{NF}, with no @samp{$}, is a built-in variable whose value -is the number of fields in the current record. - -@code{$0}, which looks like an attempt to refer to the zeroth field, is -a special case: it represents the whole input record. This is what you -would use if you weren't interested in fields. - -Here are some more examples: - -@example -awk '$1 ~ /foo/ @{ print $0 @}' BBS-list -@end example - -@noindent -This example prints each record in the file @file{BBS-list} whose first -field contains the string @samp{foo}. The operator @samp{~} is called a -@dfn{matching operator} (@pxref{Comparison Ops, ,Comparison Expressions}); -it tests whether a string (here, the field @code{$1}) matches a given regular -expression.@refill - -By contrast, the following example: - -@example -awk '/foo/ @{ print $1, $NF @}' BBS-list -@end example - -@noindent -looks for @samp{foo} in @emph{the entire record} and prints the first -field and the last field for each input record containing a -match.@refill - -@node Non-Constant Fields, Changing Fields, Fields, Reading Files -@section Non-constant Field Numbers - -The number of a field does not need to be a constant. Any expression in -the @code{awk} language can be used after a @samp{$} to refer to a -field. The value of the expression specifies the field number. If the -value is a string, rather than a number, it is converted to a number. -Consider this example:@refill - -@example -awk '@{ print $NR @}' -@end example - -@noindent -Recall that @code{NR} is the number of records read so far: 1 in the -first record, 2 in the second, etc. So this example prints the first -field of the first record, the second field of the second record, and so -on. For the twentieth record, field number 20 is printed; most likely, -the record has fewer than 20 fields, so this prints a blank line. - -Here is another example of using expressions as field numbers: - -@example -awk '@{ print $(2*2) @}' BBS-list -@end example - -The @code{awk} language must evaluate the expression @code{(2*2)} and use -its value as the number of the field to print. The @samp{*} sign -represents multiplication, so the expression @code{2*2} evaluates to 4. -The parentheses are used so that the multiplication is done before the -@samp{$} operation; they are necessary whenever there is a binary -operator in the field-number expression. This example, then, prints the -hours of operation (the fourth field) for every line of the file -@file{BBS-list}.@refill - -If the field number you compute is zero, you get the entire record. -Thus, @code{$(2-2)} has the same value as @code{$0}. Negative field -numbers are not allowed. - -The number of fields in the current record is stored in the built-in -variable @code{NF} (@pxref{Built-in Variables}). The expression -@code{$NF} is not a special feature: it is the direct consequence of -evaluating @code{NF} and using its value as a field number. - -@node Changing Fields, Field Separators, Non-Constant Fields, Reading Files -@section Changing the Contents of a Field - -@cindex field, changing contents of -@cindex changing contents of a field -@cindex assignment to fields -You can change the contents of a field as seen by @code{awk} within an -@code{awk} program; this changes what @code{awk} perceives as the -current input record. (The actual input is untouched: @code{awk} never -modifies the input file.) - -Consider this example: - -@smallexample -awk '@{ $3 = $2 - 10; print $2, $3 @}' inventory-shipped -@end smallexample - -@noindent -The @samp{-} sign represents subtraction, so this program reassigns -field three, @code{$3}, to be the value of field two minus ten, -@code{$2 - 10}. (@xref{Arithmetic Ops, ,Arithmetic Operators}.) -Then field two, and the new value for field three, are printed. - -In order for this to work, the text in field @code{$2} must make sense -as a number; the string of characters must be converted to a number in -order for the computer to do arithmetic on it. The number resulting -from the subtraction is converted back to a string of characters which -then becomes field three. -@xref{Conversion, ,Conversion of Strings and Numbers}.@refill - -When you change the value of a field (as perceived by @code{awk}), the -text of the input record is recalculated to contain the new field where -the old one was. Therefore, @code{$0} changes to reflect the altered -field. Thus, - -@smallexample -awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped -@end smallexample - -@noindent -prints a copy of the input file, with 10 subtracted from the second -field of each line. - -You can also assign contents to fields that are out of range. For -example: - -@smallexample -awk '@{ $6 = ($5 + $4 + $3 + $2) ; print $6 @}' inventory-shipped -@end smallexample - -@noindent -We've just created @code{$6}, whose value is the sum of fields -@code{$2}, @code{$3}, @code{$4}, and @code{$5}. The @samp{+} sign -represents addition. For the file @file{inventory-shipped}, @code{$6} -represents the total number of parcels shipped for a particular month. - -Creating a new field changes the internal @code{awk} copy of the current -input record---the value of @code{$0}. Thus, if you do @samp{print $0} -after adding a field, the record printed includes the new field, with -the appropriate number of field separators between it and the previously -existing fields. - -This recomputation affects and is affected by several features not yet -discussed, in particular, the @dfn{output field separator}, @code{OFS}, -which is used to separate the fields (@pxref{Output Separators}), and -@code{NF} (the number of fields; @pxref{Fields, ,Examining Fields}). -For example, the value of @code{NF} is set to the number of the highest -field you create.@refill - -Note, however, that merely @emph{referencing} an out-of-range field -does @emph{not} change the value of either @code{$0} or @code{NF}. -Referencing an out-of-range field merely produces a null string. For -example:@refill - -@smallexample -if ($(NF+1) != "") - print "can't happen" -else - print "everything is normal" -@end smallexample - -@noindent -should print @samp{everything is normal}, because @code{NF+1} is certain -to be out of range. (@xref{If Statement, ,The @code{if} Statement}, -for more information about @code{awk}'s @code{if-else} statements.)@refill - -It is important to note that assigning to a field will change the -value of @code{$0}, but will not change the value of @code{NF}, -even when you assign the null string to a field. For example: - -@smallexample -echo a b c d | awk '@{ OFS = ":"; $2 = "" ; print ; print NF @}' -@end smallexample - -@noindent -prints - -@smallexample -a::c:d -4 -@end smallexample - -@noindent -The field is still there, it just has an empty value. You can tell -because there are two colons in a row. - -@node Field Separators, Constant Size, Changing Fields, Reading Files -@section Specifying how Fields are Separated -@vindex FS -@cindex fields, separating -@cindex field separator, @code{FS} -@cindex @samp{-F} option - -(This section is rather long; it describes one of the most fundamental -operations in @code{awk}. If you are a novice with @code{awk}, we -recommend that you re-read this section after you have studied the -section on regular expressions, @ref{Regexp, ,Regular Expressions as Patterns}.) - -The way @code{awk} splits an input record into fields is controlled by -the @dfn{field separator}, which is a single character or a regular -expression. @code{awk} scans the input record for matches for the -separator; the fields themselves are the text between the matches. For -example, if the field separator is @samp{oo}, then the following line: - -@smallexample -moo goo gai pan -@end smallexample - -@noindent -would be split into three fields: @samp{m}, @samp{@ g} and @samp{@ gai@ -pan}. - -The field separator is represented by the built-in variable @code{FS}. -Shell programmers take note! @code{awk} does not use the name @code{IFS} -which is used by the shell.@refill - -You can change the value of @code{FS} in the @code{awk} program with the -assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}). -Often the right time to do this is at the beginning of execution, -before any input has been processed, so that the very first record -will be read with the proper separator. To do this, use the special -@code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). -For example, here we set the value of @code{FS} to the string -@code{","}:@refill - -@smallexample -awk 'BEGIN @{ FS = "," @} ; @{ print $2 @}' -@end smallexample - -@noindent -Given the input line, - -@smallexample -John Q. Smith, 29 Oak St., Walamazoo, MI 42139 -@end smallexample - -@noindent -this @code{awk} program extracts the string @samp{@ 29 Oak St.}. - -@cindex field separator, choice of -@cindex regular expressions as field separators -Sometimes your input data will contain separator characters that don't -separate fields the way you thought they would. For instance, the -person's name in the example we've been using might have a title or -suffix attached, such as @samp{John Q. Smith, LXIX}. From input -containing such a name: - -@smallexample -John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139 -@end smallexample - -@noindent -the previous sample program would extract @samp{@ LXIX}, instead of -@samp{@ 29 Oak St.}. If you were expecting the program to print the -address, you would be surprised. So choose your data layout and -separator characters carefully to prevent such problems. - -As you know, by default, fields are separated by whitespace sequences -(spaces and tabs), not by single spaces: two spaces in a row do not -delimit an empty field. The default value of the field separator is a -string @w{@code{" "}} containing a single space. If this value were -interpreted in the usual way, each space character would separate -fields, so two spaces in a row would make an empty field between them. -The reason this does not happen is that a single space as the value of -@code{FS} is a special case: it is taken to specify the default manner -of delimiting fields. - -If @code{FS} is any other single character, such as @code{","}, then -each occurrence of that character separates two fields. Two consecutive -occurrences delimit an empty field. If the character occurs at the -beginning or the end of the line, that too delimits an empty field. The -space character is the only single character which does not follow these -rules. - -More generally, the value of @code{FS} may be a string containing any -regular expression. Then each match in the record for the regular -expression separates fields. For example, the assignment:@refill - -@smallexample -FS = ", \t" -@end smallexample - -@noindent -makes every area of an input line that consists of a comma followed by a -space and a tab, into a field separator. (@samp{\t} stands for a -tab.)@refill - -For a less trivial example of a regular expression, suppose you want -single spaces to separate fields the way single commas were used above. -You can set @code{FS} to @w{@code{"[@ ]"}}. This regular expression -matches a single space and nothing else. - -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex field separator: on command line -@cindex command line, setting @code{FS} on -@code{FS} can be set on the command line. You use the @samp{-F} argument to -do so. For example: - -@smallexample -awk -F, '@var{program}' @var{input-files} -@end smallexample - -@noindent -sets @code{FS} to be the @samp{,} character. Notice that the argument uses -a capital @samp{F}. Contrast this with @samp{-f}, which specifies a file -containing an @code{awk} program. Case is significant in command options: -the @samp{-F} and @samp{-f} options have nothing to do with each other. -You can use both options at the same time to set the @code{FS} argument -@emph{and} get an @code{awk} program from a file.@refill - -@c begin expert info -The value used for the argument to @samp{-F} is processed in exactly the -same way as assignments to the built-in variable @code{FS}. This means that -if the field separator contains special characters, they must be escaped -appropriately. For example, to use a @samp{\} as the field separator, you -would have to type: - -@smallexample -# same as FS = "\\" -awk -F\\\\ '@dots{}' files @dots{} -@end smallexample - -@noindent -Since @samp{\} is used for quoting in the shell, @code{awk} will see -@samp{-F\\}. Then @code{awk} processes the @samp{\\} for escape -characters (@pxref{Constants, ,Constant Expressions}), finally yielding -a single @samp{\} to be used for the field separator. -@c end expert info - -As a special case, in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), if the -argument to @samp{-F} is @samp{t}, then @code{FS} is set to the tab -character. (This is because if you type @samp{-F\t}, without the quotes, -at the shell, the @samp{\} gets deleted, so @code{awk} figures that you -really want your fields to be separated with tabs, and not @samp{t}s. -Use @samp{-v FS="t"} on the command line if you really do want to separate -your fields with @samp{t}s.)@refill - -For example, let's use an @code{awk} program file called @file{baud.awk} -that contains the pattern @code{/300/}, and the action @samp{print $1}. -Here is the program: - -@smallexample -/300/ @{ print $1 @} -@end smallexample - -Let's also set @code{FS} to be the @samp{-} character, and run the -program on the file @file{BBS-list}. The following command prints a -list of the names of the bulletin boards that operate at 300 baud and -the first three digits of their phone numbers:@refill - -@smallexample -awk -F- -f baud.awk BBS-list -@end smallexample - -@noindent -It produces this output: - -@smallexample -aardvark 555 -alpo -barfly 555 -bites 555 -camelot 555 -core 555 -fooey 555 -foot 555 -macfoo 555 -sdace 555 -sabafoo 555 -@end smallexample - -@noindent -Note the second line of output. If you check the original file, you will -see that the second line looked like this: - -@smallexample -alpo-net 555-3412 2400/1200/300 A -@end smallexample - -The @samp{-} as part of the system's name was used as the field -separator, instead of the @samp{-} in the phone number that was -originally intended. This demonstrates why you have to be careful in -choosing your field and record separators. - -The following program searches the system password file, and prints -the entries for users who have no password: - -@smallexample -awk -F: '$2 == ""' /etc/passwd -@end smallexample - -@noindent -Here we use the @samp{-F} option on the command line to set the field -separator. Note that fields in @file{/etc/passwd} are separated by -colons. The second field represents a user's encrypted password, but if -the field is empty, that user has no password. - -@c begin expert info -According to the @sc{posix} standard, @code{awk} is supposed to behave -as if each record is split into fields at the time that it is read. -In particular, this means that you can change the value of @code{FS} -after a record is read, but before any of the fields are referenced. -The value of the fields (i.e. how they were split) should reflect the -old value of @code{FS}, not the new one. - -However, many implementations of @code{awk} do not do this. Instead, -they defer splitting the fields until a field reference actually happens, -using the @emph{current} value of @code{FS}! This behavior can be difficult -to diagnose. The following example illustrates the results of the two methods. -(The @code{sed} command prints just the first line of @file{/etc/passwd}.) - -@smallexample -sed 1q /etc/passwd | awk '@{ FS = ":" ; print $1 @}' -@end smallexample - -@noindent -will usually print - -@smallexample -root -@end smallexample - -@noindent -on an incorrect implementation of @code{awk}, while @code{gawk} -will print something like - -@smallexample -root:nSijPlPhZZwgE:0:0:Root:/: -@end smallexample -@c end expert info - -@c begin expert info -There is an important difference between the two cases of @samp{FS = @w{" "}} -(a single blank) and @samp{FS = @w{"[ \t]+"}} (which is a regular expression -matching one or more blanks or tabs). For both values of @code{FS}, fields -are separated by runs of blanks and/or tabs. However, when the value of -@code{FS} is @code{" "}, @code{awk} will strip leading and trailing whitespace -from the record, and then decide where the fields are. - -For example, the following expression prints @samp{b}: - -@smallexample -echo ' a b c d ' | awk '@{ print $2 @}' -@end smallexample - -@noindent -However, the following prints @samp{a}: - -@smallexample -echo ' a b c d ' | awk 'BEGIN @{ FS = "[ \t]+" @} ; @{ print $2 @}' -@end smallexample - -@noindent -In this case, the first field is null. - -The stripping of leading and trailing whitespace also comes into -play whenever @code{$0} is recomputed. For instance, this pipeline - -@smallexample -echo ' a b c d' | awk '@{ print; $2 = $2; print @}' -@end smallexample - -@noindent -produces this output: - -@smallexample - a b c d -a b c d -@end smallexample - -@noindent -The first @code{print} statement prints the record as it was read, -with leading whitespace intact. The assignment to @code{$2} rebuilds -@code{$0} by concatenating @code{$1} through @code{$NF} together, -separated by the value of @code{OFS}. Since the leading whitespace -was ignored when finding @code{$1}, it is not part of the new @code{$0}. -Finally, the last @code{print} statement prints the new @code{$0}. -@c end expert info - -The following table summarizes how fields are split, based on the -value of @code{FS}. - -@table @code -@item FS == " " -Fields are separated by runs of whitespace. Leading and trailing -whitespace are ignored. This is the default. - -@item FS == @var{any single character} -Fields are separated by each occurrence of the character. Multiple -successive occurrences delimit empty fields, as do leading and -trailing occurrences. - -@item FS == @var{regexp} -Fields are separated by occurrences of characters that match @var{regexp}. -Leading and trailing matches of @var{regexp} delimit empty fields. -@end table - -@node Constant Size, Multiple Line, Field Separators, Reading Files -@section Reading Fixed-width Data - -(This section discusses an advanced, experimental feature. If you are -a novice @code{awk} user, you may wish to skip it on the first reading.) - -@code{gawk} 2.13 introduced a new facility for dealing with fixed-width fields -with no distinctive field separator. Data of this nature arises typically -in one of at least two ways: the input for old FORTRAN programs where -numbers are run together, and the output of programs that did not anticipate -the use of their output as input for other programs. - -An example of the latter is a table where all the columns are lined up by -the use of a variable number of spaces and @emph{empty fields are just -spaces}. Clearly, @code{awk}'s normal field splitting based on @code{FS} -will not work well in this case. (Although a portable @code{awk} program -can use a series of @code{substr} calls on @code{$0}, this is awkward and -inefficient for a large number of fields.)@refill - -The splitting of an input record into fixed-width fields is specified by -assigning a string containing space-separated numbers to the built-in -variable @code{FIELDWIDTHS}. Each number specifies the width of the field -@emph{including} columns between fields. If you want to ignore the columns -between fields, you can specify the width as a separate field that is -subsequently ignored. - -The following data is the output of the @code{w} utility. It is useful -to illustrate the use of @code{FIELDWIDTHS}. - -@smallexample - 10:06pm up 21 days, 14:04, 23 users -User tty login@ idle JCPU PCPU what -hzuo ttyV0 8:58pm 9 5 vi p24.tex -hzang ttyV3 6:37pm 50 -csh -eklye ttyV5 9:53pm 7 1 em thes.tex -dportein ttyV6 8:17pm 1:47 -csh -gierd ttyD3 10:00pm 1 elm -dave ttyD4 9:47pm 4 4 w -brent ttyp0 26Jun91 4:46 26:46 4:41 bash -dave ttyq4 26Jun9115days 46 46 wnewmail -@end smallexample - -The following program takes the above input, converts the idle time to -number of seconds and prints out the first two fields and the calculated -idle time. (This program uses a number of @code{awk} features that -haven't been introduced yet.)@refill - -@smallexample -BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @} -NR > 2 @{ - idle = $4 - sub(/^ */, "", idle) # strip leading spaces - if (idle == "") idle = 0 - if (idle ~ /:/) @{ split(idle, t, ":"); idle = t[1] * 60 + t[2] @} - if (idle ~ /days/) @{ idle *= 24 * 60 * 60 @} - - print $1, $2, idle -@} -@end smallexample - -Here is the result of running the program on the data: - -@smallexample -hzuo ttyV0 0 -hzang ttyV3 50 -eklye ttyV5 0 -dportein ttyV6 107 -gierd ttyD3 1 -dave ttyD4 0 -brent ttyp0 286 -dave ttyq4 1296000 -@end smallexample - -Another (possibly more practical) example of fixed-width input data -would be the input from a deck of balloting cards. In some parts of -the United States, voters make their choices by punching holes in computer -cards. These cards are then processed to count the votes for any particular -candidate or on any particular issue. Since a voter may choose not to -vote on some issue, any column on the card may be empty. An @code{awk} -program for processing such data could use the @code{FIELDWIDTHS} feature -to simplify reading the data.@refill - -@c of course, getting gawk to run on a system with card readers is -@c another story! - -This feature is still experimental, and will likely evolve over time. - -@node Multiple Line, Getline, Constant Size, Reading Files -@section Multiple-Line Records - -@cindex multiple line records -@cindex input, multiple line records -@cindex reading files, multiple line records -@cindex records, multiple line -In some data bases, a single line cannot conveniently hold all the -information in one entry. In such cases, you can use multi-line -records. - -The first step in doing this is to choose your data format: when records -are not defined as single lines, how do you want to define them? -What should separate records? - -One technique is to use an unusual character or string to separate -records. For example, you could use the formfeed character (written -@code{\f} in @code{awk}, as in C) to separate them, making each record -a page of the file. To do this, just set the variable @code{RS} to -@code{"\f"} (a string containing the formfeed character). Any -other character could equally well be used, as long as it won't be part -of the data in a record.@refill - -@ignore -Another technique is to have blank lines separate records. The string -@code{"^\n+"} is a regular expression that matches any sequence of -newlines starting at the beginning of a line---in other words, it -matches a sequence of blank lines. If you set @code{RS} to this string, -a record always ends at the first blank line encountered. In -addition, a regular expression always matches the longest possible -sequence when there is a choice. So the next record doesn't start until -the first nonblank line that follows---no matter how many blank lines -appear in a row, they are considered one record-separator. -@end ignore - -Another technique is to have blank lines separate records. By a special -dispensation, a null string as the value of @code{RS} indicates that -records are separated by one or more blank lines. If you set @code{RS} -to the null string, a record always ends at the first blank line -encountered. And the next record doesn't start until the first nonblank -line that follows---no matter how many blank lines appear in a row, they -are considered one record-separator. (End of file is also considered -a record separator.)@refill -@c !!! This use of `end of file' is confusing. Needs to be clarified. - -The second step is to separate the fields in the record. One way to do -this is to put each field on a separate line: to do this, just set the -variable @code{FS} to the string @code{"\n"}. (This simple regular -expression matches a single newline.) - -Another way to separate fields is to divide each of the lines into fields -in the normal manner. This happens by default as a result of a special -feature: when @code{RS} is set to the null string, the newline character -@emph{always} acts as a field separator. This is in addition to whatever -field separations result from @code{FS}. - -The original motivation for this special exception was probably so that -you get useful behavior in the default case (i.e., @w{@code{FS == " "}}). -This feature can be a problem if you really don't want the -newline character to separate fields, since there is no way to -prevent it. However, you can work around this by using the @code{split} -function to break up the record manually -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@ignore -Here are two ways to use records separated by blank lines and break each -line into fields normally: - -@example -awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list - -@exdent @r{or} - -awk 'BEGIN @{ RS = "^\n+"; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list -@end example -@end ignore - -@ignore -Here is how to use records separated by blank lines and break each -line into fields normally: - -@example -awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} ; @{ print $1 @}' BBS-list -@end example -@end ignore - -@node Getline, Close Input, Multiple Line, Reading Files -@section Explicit Input with @code{getline} - -@findex getline -@cindex input, explicit -@cindex explicit input -@cindex input, @code{getline} command -@cindex reading files, @code{getline} command -So far we have been getting our input files from @code{awk}'s main -input stream---either the standard input (usually your terminal) or the -files specified on the command line. The @code{awk} language has a -special built-in command called @code{getline} that -can be used to read input under your explicit control.@refill - -This command is quite complex and should @emph{not} be used by -beginners. It is covered here because this is the chapter on input. -The examples that follow the explanation of the @code{getline} command -include material that has not been covered yet. Therefore, come back -and study the @code{getline} command @emph{after} you have reviewed the -rest of this manual and have a good knowledge of how @code{awk} works. - -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@code{getline} returns 1 if it finds a record, and 0 if the end of the -file is encountered. If there is some error in getting a record, such -as a file that cannot be opened, then @code{getline} returns @minus{}1. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -In the following examples, @var{command} stands for a string value that -represents a shell command. - -@table @code -@item getline -The @code{getline} command can be used without arguments to read input -from the current input file. All it does in this case is read the next -input record and split it up into fields. This is useful if you've -finished processing the current record, but you want to do some special -processing @emph{right now} on the next record. Here's an -example:@refill - -@example -awk '@{ - if (t = index($0, "/*")) @{ - if (t > 1) - tmp = substr($0, 1, t - 1) - else - tmp = "" - u = index(substr($0, t + 2), "*/") - while (u == 0) @{ - getline - t = -1 - u = index($0, "*/") - @} - if (u <= length($0) - 2) - $0 = tmp substr($0, t + u + 3) - else - $0 = tmp - @} - print $0 -@}' -@end example - -This @code{awk} program deletes all C-style comments, @samp{/* @dots{} -*/}, from the input. By replacing the @samp{print $0} with other -statements, you could perform more complicated processing on the -decommented input, like searching for matches of a regular -expression. (This program has a subtle problem---can you spot it?) - -@c the program to remove comments doesn't work if one -@c comment ends and another begins on the same line. (Your -@c idea for restart would be useful here). --- brennan@boeing.com - -This form of the @code{getline} command sets @code{NF} (the number of -fields; @pxref{Fields, ,Examining Fields}), @code{NR} (the number of -records read so far; @pxref{Records, ,How Input is Split into Records}), -@code{FNR} (the number of records read from this input file), and the -value of @code{$0}. - -@strong{Note:} the new value of @code{$0} is used in testing -the patterns of any subsequent rules. The original value -of @code{$0} that triggered the rule which executed @code{getline} -is lost. By contrast, the @code{next} statement reads a new record -but immediately begins processing it normally, starting with the first -rule in the program. @xref{Next Statement, ,The @code{next} Statement}. - -@item getline @var{var} -This form of @code{getline} reads a record into the variable @var{var}. -This is useful when you want your program to read the next record from -the current input file, but you don't want to subject the record to the -normal input processing. - -For example, suppose the next line is a comment, or a special string, -and you want to read it, but you must make certain that it won't trigger -any rules. This version of @code{getline} allows you to read that line -and store it in a variable so that the main -read-a-line-and-check-each-rule loop of @code{awk} never sees it. - -The following example swaps every two lines of input. For example, given: - -@example -wan -tew -free -phore -@end example - -@noindent -it outputs: - -@example -tew -wan -phore -free -@end example - -@noindent -Here's the program: - -@example -@group -awk '@{ - if ((getline tmp) > 0) @{ - print tmp - print $0 - @} else - print $0 -@}' -@end group -@end example - -The @code{getline} function used in this way sets only the variables -@code{NR} and @code{FNR} (and of course, @var{var}). The record is not -split into fields, so the values of the fields (including @code{$0}) and -the value of @code{NF} do not change.@refill - -@item getline < @var{file} -@cindex input redirection -@cindex redirection of input -This form of the @code{getline} function takes its input from the file -@var{file}. Here @var{file} is a string-valued expression that -specifies the file name. @samp{< @var{file}} is called a @dfn{redirection} -since it directs input to come from a different place. - -This form is useful if you want to read your input from a particular -file, instead of from the main input stream. For example, the following -program reads its input record from the file @file{foo.input} when it -encounters a first field with a value equal to 10 in the current input -file.@refill - -@example -awk '@{ - if ($1 == 10) @{ - getline < "foo.input" - print - @} else - print -@}' -@end example - -Since the main input stream is not used, the values of @code{NR} and -@code{FNR} are not changed. But the record read is split into fields in -the normal manner, so the values of @code{$0} and other fields are -changed. So is the value of @code{NF}. - -This does not cause the record to be tested against all the patterns -in the @code{awk} program, in the way that would happen if the record -were read normally by the main processing loop of @code{awk}. However -the new record is tested against any subsequent rules, just as when -@code{getline} is used without a redirection. - -@item getline @var{var} < @var{file} -This form of the @code{getline} function takes its input from the file -@var{file} and puts it in the variable @var{var}. As above, @var{file} -is a string-valued expression that specifies the file from which to read. - -In this version of @code{getline}, none of the built-in variables are -changed, and the record is not split into fields. The only variable -changed is @var{var}. - -For example, the following program copies all the input files to the -output, except for records that say @w{@samp{@@include @var{filename}}}. -Such a record is replaced by the contents of the file -@var{filename}.@refill - -@example -awk '@{ - if (NF == 2 && $1 == "@@include") @{ - while ((getline line < $2) > 0) - print line - close($2) - @} else - print -@}' -@end example - -Note here how the name of the extra input file is not built into -the program; it is taken from the data, from the second field on -the @samp{@@include} line.@refill - -The @code{close} function is called to ensure that if two identical -@samp{@@include} lines appear in the input, the entire specified file is -included twice. @xref{Close Input, ,Closing Input Files and Pipes}.@refill - -One deficiency of this program is that it does not process nested -@samp{@@include} statements the way a true macro preprocessor would. - -@item @var{command} | getline -You can @dfn{pipe} the output of a command into @code{getline}. A pipe is -simply a way to link the output of one program to the input of another. In -this case, the string @var{command} is run as a shell command and its output -is piped into @code{awk} to be used as input. This form of @code{getline} -reads one record from the pipe. - -For example, the following program copies input to output, except for lines -that begin with @samp{@@execute}, which are replaced by the output produced by -running the rest of the line as a shell command: - -@example -awk '@{ - if ($1 == "@@execute") @{ - tmp = substr($0, 10) - while ((tmp | getline) > 0) - print - close(tmp) - @} else - print -@}' -@end example - -@noindent -The @code{close} function is called to ensure that if two identical -@samp{@@execute} lines appear in the input, the command is run for -each one. @xref{Close Input, ,Closing Input Files and Pipes}. - -Given the input: - -@example -foo -bar -baz -@@execute who -bletch -@end example - -@noindent -the program might produce: - -@example -foo -bar -baz -hack ttyv0 Jul 13 14:22 -hack ttyp0 Jul 13 14:23 (gnu:0) -hack ttyp1 Jul 13 14:23 (gnu:0) -hack ttyp2 Jul 13 14:23 (gnu:0) -hack ttyp3 Jul 13 14:23 (gnu:0) -bletch -@end example - -@noindent -Notice that this program ran the command @code{who} and printed the result. -(If you try this program yourself, you will get different results, showing -you who is logged in on your system.) - -This variation of @code{getline} splits the record into fields, sets the -value of @code{NF} and recomputes the value of @code{$0}. The values of -@code{NR} and @code{FNR} are not changed. - -@item @var{command} | getline @var{var} -The output of the command @var{command} is sent through a pipe to -@code{getline} and into the variable @var{var}. For example, the -following program reads the current date and time into the variable -@code{current_time}, using the @code{date} utility, and then -prints it.@refill - -@example -awk 'BEGIN @{ - "date" | getline current_time - close("date") - print "Report printed on " current_time -@}' -@end example - -In this version of @code{getline}, none of the built-in variables are -changed, and the record is not split into fields. -@end table - -@node Close Input, , Getline, Reading Files -@section Closing Input Files and Pipes -@cindex closing input files and pipes -@findex close - -If the same file name or the same shell command is used with -@code{getline} more than once during the execution of an @code{awk} -program, the file is opened (or the command is executed) only the first time. -At that time, the first record of input is read from that file or command. -The next time the same file or command is used in @code{getline}, another -record is read from it, and so on. - -This implies that if you want to start reading the same file again from -the beginning, or if you want to rerun a shell command (rather than -reading more output from the command), you must take special steps. -What you must do is use the @code{close} function, as follows: - -@example -close(@var{filename}) -@end example - -@noindent -or - -@example -close(@var{command}) -@end example - -The argument @var{filename} or @var{command} can be any expression. Its -value must exactly equal the string that was used to open the file or -start the command---for example, if you open a pipe with this: - -@example -"sort -r names" | getline foo -@end example - -@noindent -then you must close it with this: - -@example -close("sort -r names") -@end example - -Once this function call is executed, the next @code{getline} from that -file or command will reopen the file or rerun the command. - -@iftex -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@end iftex -@code{close} returns a value of zero if the close succeeded. -Otherwise, the value will be non-zero. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -@node Printing, One-liners, Reading Files, Top -@chapter Printing Output - -@cindex printing -@cindex output -One of the most common things that actions do is to output or @dfn{print} -some or all of the input. For simple output, use the @code{print} -statement. For fancier formatting use the @code{printf} statement. -Both are described in this chapter. - -@menu -* Print:: The @code{print} statement. -* Print Examples:: Simple examples of @code{print} statements. -* Output Separators:: The output separators and how to change them. -* OFMT:: Controlling Numeric Output With @code{print}. -* Printf:: The @code{printf} statement. -* Redirection:: How to redirect output to multiple - files and pipes. -* Special Files:: File name interpretation in @code{gawk}. - @code{gawk} allows access to - inherited file descriptors. -@end menu - -@node Print, Print Examples, Printing, Printing -@section The @code{print} Statement -@cindex @code{print} statement - -The @code{print} statement does output with simple, standardized -formatting. You specify only the strings or numbers to be printed, in a -list separated by commas. They are output, separated by single spaces, -followed by a newline. The statement looks like this: - -@example -print @var{item1}, @var{item2}, @dots{} -@end example - -@noindent -The entire list of items may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions uses a -relational operator; otherwise it could be confused with a redirection -(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}). -The relational operators are @samp{==}, -@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and -@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill - -The items printed can be constant strings or numbers, fields of the -current record (such as @code{$1}), variables, or any @code{awk} -expressions. The @code{print} statement is completely general for -computing @emph{what} values to print. With two exceptions, -you cannot specify @emph{how} to print them---how many -columns, whether to use exponential notation or not, and so on. -(@xref{Output Separators}, and -@ref{OFMT, ,Controlling Numeric Output with @code{print}}.) -For that, you need the @code{printf} statement -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -The simple statement @samp{print} with no items is equivalent to -@samp{print $0}: it prints the entire current record. To print a blank -line, use @samp{print ""}, where @code{""} is the null, or empty, -string. - -To print a fixed piece of text, use a string constant such as -@w{@code{"Hello there"}} as one item. If you forget to use the -double-quote characters, your text will be taken as an @code{awk} -expression, and you will probably get an error. Keep in mind that a -space is printed between any two items. - -Most often, each @code{print} statement makes one line of output. But it -isn't limited to one line. If an item value is a string that contains a -newline, the newline is output along with the rest of the string. A -single @code{print} can make any number of lines this way. - -@node Print Examples, Output Separators, Print, Printing -@section Examples of @code{print} Statements - -Here is an example of printing a string that contains embedded newlines: - -@example -awk 'BEGIN @{ print "line one\nline two\nline three" @}' -@end example - -@noindent -produces output like this: - -@example -line one -line two -line three -@end example - -Here is an example that prints the first two fields of each input record, -with a space between them: - -@example -awk '@{ print $1, $2 @}' inventory-shipped -@end example - -@noindent -Its output looks like this: - -@example -Jan 13 -Feb 15 -Mar 15 -@dots{} -@end example - -A common mistake in using the @code{print} statement is to omit the comma -between two items. This often has the effect of making the items run -together in the output, with no space. The reason for this is that -juxtaposing two string expressions in @code{awk} means to concatenate -them. For example, without the comma: - -@example -awk '@{ print $1 $2 @}' inventory-shipped -@end example - -@noindent -prints: - -@example -@group -Jan13 -Feb15 -Mar15 -@dots{} -@end group -@end example - -Neither example's output makes much sense to someone unfamiliar with the -file @file{inventory-shipped}. A heading line at the beginning would make -it clearer. Let's add some headings to our table of months (@code{$1}) and -green crates shipped (@code{$2}). We do this using the @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}) to force the headings to be printed only once: - -@example -awk 'BEGIN @{ print "Month Crates" - print "----- ------" @} - @{ print $1, $2 @}' inventory-shipped -@end example - -@noindent -Did you already guess what happens? This program prints the following: - -@example -@group -Month Crates ------ ------ -Jan 13 -Feb 15 -Mar 15 -@dots{} -@end group -@end example - -@noindent -The headings and the table data don't line up! We can fix this by printing -some spaces between the two fields: - -@example -awk 'BEGIN @{ print "Month Crates" - print "----- ------" @} - @{ print $1, " ", $2 @}' inventory-shipped -@end example - -You can imagine that this way of lining up columns can get pretty -complicated when you have many columns to fix. Counting spaces for two -or three columns can be simple, but more than this and you can get -``lost'' quite easily. This is why the @code{printf} statement was -created (@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}); -one of its specialties is lining up columns of data.@refill - -@node Output Separators, OFMT, Print Examples, Printing -@section Output Separators - -@cindex output field separator, @code{OFS} -@vindex OFS -@vindex ORS -@cindex output record separator, @code{ORS} -As mentioned previously, a @code{print} statement contains a list -of items, separated by commas. In the output, the items are normally -separated by single spaces. But they do not have to be spaces; a -single space is only the default. You can specify any string of -characters to use as the @dfn{output field separator} by setting the -built-in variable @code{OFS}. The initial value of this variable -is the string @w{@code{" "}}, that is, just a single space.@refill - -The output from an entire @code{print} statement is called an -@dfn{output record}. Each @code{print} statement outputs one output -record and then outputs a string called the @dfn{output record separator}. -The built-in variable @code{ORS} specifies this string. The initial -value of the variable is the string @code{"\n"} containing a newline -character; thus, normally each @code{print} statement makes a separate line. - -You can change how output fields and records are separated by assigning -new values to the variables @code{OFS} and/or @code{ORS}. The usual -place to do this is in the @code{BEGIN} rule -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}), so -that it happens before any input is processed. You may also do this -with assignments on the command line, before the names of your input -files.@refill - -The following example prints the first and second fields of each input -record separated by a semicolon, with a blank line added after each -line:@refill - -@example -@group -awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @} - @{ print $1, $2 @}' BBS-list -@end group -@end example - -If the value of @code{ORS} does not contain a newline, all your output -will be run together on a single line, unless you output newlines some -other way. - -@node OFMT, Printf, Output Separators, Printing -@section Controlling Numeric Output with @code{print} -@vindex OFMT -When you use the @code{print} statement to print numeric values, -@code{awk} internally converts the number to a string of characters, -and prints that string. @code{awk} uses the @code{sprintf} function -to do this conversion. For now, it suffices to say that the @code{sprintf} -function accepts a @dfn{format specification} that tells it how to format -numbers (or strings), and that there are a number of different ways that -numbers can be formatted. The different format specifications are discussed -more fully in -@ref{Printf, ,Using @code{printf} Statements for Fancier Printing}.@refill - -The built-in variable @code{OFMT} contains the default format specification -that @code{print} uses with @code{sprintf} when it wants to convert a -number to a string for printing. By supplying different format specifications -as the value of @code{OFMT}, you can change how @code{print} will print -your numbers. As a brief example: - -@example -@group -awk 'BEGIN @{ OFMT = "%d" # print numbers as integers - print 17.23 @}' -@end group -@end example - -@noindent -will print @samp{17}. - -@node Printf, Redirection, OFMT, Printing -@section Using @code{printf} Statements for Fancier Printing -@cindex formatted output -@cindex output, formatted - -If you want more precise control over the output format than -@code{print} gives you, use @code{printf}. With @code{printf} you can -specify the width to use for each item, and you can specify various -stylistic choices for numbers (such as what radix to use, whether to -print an exponent, whether to print a sign, and how many digits to print -after the decimal point). You do this by specifying a string, called -the @dfn{format string}, which controls how and where to print the other -arguments. - -@menu -* Basic Printf:: Syntax of the @code{printf} statement. -* Control Letters:: Format-control letters. -* Format Modifiers:: Format-specification modifiers. -* Printf Examples:: Several examples. -@end menu - -@node Basic Printf, Control Letters, Printf, Printf -@subsection Introduction to the @code{printf} Statement - -@cindex @code{printf} statement, syntax of -The @code{printf} statement looks like this:@refill - -@example -printf @var{format}, @var{item1}, @var{item2}, @dots{} -@end example - -@noindent -The entire list of arguments may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions uses a -relational operator; otherwise it could be confused with a redirection -(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}). -The relational operators are @samp{==}, -@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and -@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill - -@cindex format string -The difference between @code{printf} and @code{print} is the argument -@var{format}. This is an expression whose value is taken as a string; it -specifies how to output each of the other arguments. It is called -the @dfn{format string}. - -The format string is the same as in the @sc{ansi} C library function -@code{printf}. Most of @var{format} is text to be output verbatim. -Scattered among this text are @dfn{format specifiers}, one per item. -Each format specifier says to output the next item at that place in the -format.@refill - -The @code{printf} statement does not automatically append a newline to its -output. It outputs only what the format specifies. So if you want -a newline, you must include one in the format. The output separator -variables @code{OFS} and @code{ORS} have no effect on @code{printf} -statements.@refill - -@node Control Letters, Format Modifiers, Basic Printf, Printf -@subsection Format-Control Letters -@cindex @code{printf}, format-control characters -@cindex format specifier - -A format specifier starts with the character @samp{%} and ends with a -@dfn{format-control letter}; it tells the @code{printf} statement how -to output one item. (If you actually want to output a @samp{%}, write -@samp{%%}.) The format-control letter specifies what kind of value to -print. The rest of the format specifier is made up of optional -@dfn{modifiers} which are parameters such as the field width to use.@refill - -Here is a list of the format-control letters: - -@table @samp -@item c -This prints a number as an ASCII character. Thus, @samp{printf "%c", -65} outputs the letter @samp{A}. The output for a string value is -the first character of the string. - -@item d -This prints a decimal integer. - -@item i -This also prints a decimal integer. - -@item e -This prints a number in scientific (exponential) notation. -For example, - -@example -printf "%4.3e", 1950 -@end example - -@noindent -prints @samp{1.950e+03}, with a total of four significant figures of -which three follow the decimal point. The @samp{4.3} are @dfn{modifiers}, -discussed below. - -@item f -This prints a number in floating point notation. - -@item g -This prints a number in either scientific notation or floating point -notation, whichever uses fewer characters. -@ignore -From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin) - -In the description of printf formats (p.43), the information for %g -is incorrect (mainly, it's too much of an oversimplification). It's -wrong in the AWK book too, and in the gawk man page. I suggested to -David Trueman before 2.13 was released that the latter be revised, so -that it matched gawk's behavior (rather than trying to change gawk to -match the docs ;-). The documented description is nice and simple, but -it doesn't match the actual underlying behavior of %g in the various C -run-time libraries that gawk relies on. The precision value for g format -is different than for f and e formats, so it's inaccurate to say 'g' is -the shorter of 'e' or 'f'. For 'g', precision represents the number of -significant digits rather than the number of decimal places, and it has -special rules about how to format numbers with range between 10E-1 and -10E-4. All in all, it's pretty messy, and I had to add that clumsy -GFMT_WORKAROUND code because the VMS run-time library doesn't conform to -the ANSI-C specifications. -@end ignore - -@item o -This prints an unsigned octal integer. - -@item s -This prints a string. - -@item x -This prints an unsigned hexadecimal integer. - -@item X -This prints an unsigned hexadecimal integer. However, for the values 10 -through 15, it uses the letters @samp{A} through @samp{F} instead of -@samp{a} through @samp{f}. - -@item % -This isn't really a format-control letter, but it does have a meaning -when used after a @samp{%}: the sequence @samp{%%} outputs one -@samp{%}. It does not consume an argument. -@end table - -@node Format Modifiers, Printf Examples, Control Letters, Printf -@subsection Modifiers for @code{printf} Formats - -@cindex @code{printf}, modifiers -@cindex modifiers (in format specifiers) -A format specification can also include @dfn{modifiers} that can control -how much of the item's value is printed and how much space it gets. The -modifiers come between the @samp{%} and the format-control letter. Here -are the possible modifiers, in the order in which they may appear: - -@table @samp -@item - -The minus sign, used before the width modifier, says to left-justify -the argument within its specified width. Normally the argument -is printed right-justified in the specified width. Thus, - -@example -printf "%-4s", "foo" -@end example - -@noindent -prints @samp{foo }. - -@item @var{width} -This is a number representing the desired width of a field. Inserting any -number between the @samp{%} sign and the format control character forces the -field to be expanded to this width. The default way to do this is to -pad with spaces on the left. For example, - -@example -printf "%4s", "foo" -@end example - -@noindent -prints @samp{ foo}. - -The value of @var{width} is a minimum width, not a maximum. If the item -value requires more than @var{width} characters, it can be as wide as -necessary. Thus, - -@example -printf "%4s", "foobar" -@end example - -@noindent -prints @samp{foobar}. - -Preceding the @var{width} with a minus sign causes the output to be -padded with spaces on the right, instead of on the left. - -@item .@var{prec} -This is a number that specifies the precision to use when printing. -This specifies the number of digits you want printed to the right of the -decimal point. For a string, it specifies the maximum number of -characters from the string that should be printed. -@end table - -The C library @code{printf}'s dynamic @var{width} and @var{prec} -capability (for example, @code{"%*.*s"}) is supported. Instead of -supplying explicit @var{width} and/or @var{prec} values in the format -string, you pass them in the argument list. For example:@refill - -@example -w = 5 -p = 3 -s = "abcdefg" -printf "<%*.*s>\n", w, p, s -@end example - -@noindent -is exactly equivalent to - -@example -s = "abcdefg" -printf "<%5.3s>\n", s -@end example - -@noindent -Both programs output @samp{@w{<@bullet{}@bullet{}abc>}}. (We have -used the bullet symbol ``@bullet{}'' to represent a space, to clearly -show you that there are two spaces in the output.)@refill - -Earlier versions of @code{awk} did not support this capability. You may -simulate it by using concatenation to build up the format string, -like so:@refill - -@example -w = 5 -p = 3 -s = "abcdefg" -printf "<%" w "." p "s>\n", s -@end example - -@noindent -This is not particularly easy to read, however. - -@node Printf Examples, , Format Modifiers, Printf -@subsection Examples of Using @code{printf} - -Here is how to use @code{printf} to make an aligned table: - -@example -awk '@{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end example - -@noindent -prints the names of bulletin boards (@code{$1}) of the file -@file{BBS-list} as a string of 10 characters, left justified. It also -prints the phone numbers (@code{$2}) afterward on the line. This -produces an aligned two-column table of names and phone numbers:@refill - -@example -@group -aardvark 555-5553 -alpo-net 555-3412 -barfly 555-7685 -bites 555-1675 -camelot 555-0542 -core 555-2912 -fooey 555-1234 -foot 555-6699 -macfoo 555-6480 -sdace 555-3430 -sabafoo 555-2127 -@end group -@end example - -Did you notice that we did not specify that the phone numbers be printed -as numbers? They had to be printed as strings because the numbers are -separated by a dash. This dash would be interpreted as a minus sign if -we had tried to print the phone numbers as numbers. This would have led -to some pretty confusing results. - -We did not specify a width for the phone numbers because they are the -last things on their lines. We don't need to put spaces after them. - -We could make our table look even nicer by adding headings to the tops -of the columns. To do this, use the @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}) -to force the header to be printed only once, at the beginning of -the @code{awk} program:@refill - -@example -@group -awk 'BEGIN @{ print "Name Number" - print "---- ------" @} - @{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end group -@end example - -Did you notice that we mixed @code{print} and @code{printf} statements in -the above example? We could have used just @code{printf} statements to get -the same results: - -@example -@group -awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number" - printf "%-10s %s\n", "----", "------" @} - @{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end group -@end example - -@noindent -By outputting each column heading with the same format specification -used for the elements of the column, we have made sure that the headings -are aligned just like the columns. - -The fact that the same format specification is used three times can be -emphasized by storing it in a variable, like this: - -@example -awk 'BEGIN @{ format = "%-10s %s\n" - printf format, "Name", "Number" - printf format, "----", "------" @} - @{ printf format, $1, $2 @}' BBS-list -@end example - -See if you can use the @code{printf} statement to line up the headings and -table data for our @file{inventory-shipped} example covered earlier in the -section on the @code{print} statement -(@pxref{Print, ,The @code{print} Statement}).@refill - -@node Redirection, Special Files, Printf, Printing -@section Redirecting Output of @code{print} and @code{printf} - -@cindex output redirection -@cindex redirection of output -So far we have been dealing only with output that prints to the standard -output, usually your terminal. Both @code{print} and @code{printf} can -also send their output to other places. -This is called @dfn{redirection}.@refill - -A redirection appears after the @code{print} or @code{printf} statement. -Redirections in @code{awk} are written just like redirections in shell -commands, except that they are written inside the @code{awk} program. - -@menu -* File/Pipe Redirection:: Redirecting Output to Files and Pipes. -* Close Output:: How to close output files and pipes. -@end menu - -@node File/Pipe Redirection, Close Output, Redirection, Redirection -@subsection Redirecting Output to Files and Pipes - -Here are the three forms of output redirection. They are all shown for -the @code{print} statement, but they work identically for @code{printf} -also.@refill - -@table @code -@item print @var{items} > @var{output-file} -This type of redirection prints the items onto the output file -@var{output-file}. The file name @var{output-file} can be any -expression. Its value is changed to a string and then used as a -file name (@pxref{Expressions, ,Expressions as Action Statements}).@refill - -When this type of redirection is used, the @var{output-file} is erased -before the first output is written to it. Subsequent writes do not -erase @var{output-file}, but append to it. If @var{output-file} does -not exist, then it is created.@refill - -For example, here is how one @code{awk} program can write a list of -BBS names to a file @file{name-list} and a list of phone numbers to a -file @file{phone-list}. Each output file contains one name or number -per line. - -@smallexample -awk '@{ print $2 > "phone-list" - print $1 > "name-list" @}' BBS-list -@end smallexample - -@item print @var{items} >> @var{output-file} -This type of redirection prints the items onto the output file -@var{output-file}. The difference between this and the -single-@samp{>} redirection is that the old contents (if any) of -@var{output-file} are not erased. Instead, the @code{awk} output is -appended to the file. - -@cindex pipes for output -@cindex output, piping -@item print @var{items} | @var{command} -It is also possible to send output through a @dfn{pipe} instead of into a -file. This type of redirection opens a pipe to @var{command} and writes -the values of @var{items} through this pipe, to another process created -to execute @var{command}.@refill - -The redirection argument @var{command} is actually an @code{awk} -expression. Its value is converted to a string, whose contents give the -shell command to be run. - -For example, this produces two files, one unsorted list of BBS names -and one list sorted in reverse alphabetical order: - -@smallexample -awk '@{ print $1 > "names.unsorted" - print $1 | "sort -r > names.sorted" @}' BBS-list -@end smallexample - -Here the unsorted list is written with an ordinary redirection while -the sorted list is written by piping through the @code{sort} utility. - -Here is an example that uses redirection to mail a message to a mailing -list @samp{bug-system}. This might be useful when trouble is encountered -in an @code{awk} script run periodically for system maintenance. - -@smallexample -report = "mail bug-system" -print "Awk script failed:", $0 | report -print "at record number", FNR, "of", FILENAME | report -close(report) -@end smallexample - -We call the @code{close} function here because it's a good idea to close -the pipe as soon as all the intended output has been sent to it. -@xref{Close Output, ,Closing Output Files and Pipes}, for more information -on this. This example also illustrates the use of a variable to represent -a @var{file} or @var{command}: it is not necessary to always -use a string constant. Using a variable is generally a good idea, -since @code{awk} requires you to spell the string value identically -every time. -@end table - -Redirecting output using @samp{>}, @samp{>>}, or @samp{|} asks the system -to open a file or pipe only if the particular @var{file} or @var{command} -you've specified has not already been written to by your program, or if -it has been closed since it was last written to.@refill - -@node Close Output, , File/Pipe Redirection, Redirection -@subsection Closing Output Files and Pipes -@cindex closing output files and pipes -@findex close - -When a file or pipe is opened, the file name or command associated with -it is remembered by @code{awk} and subsequent writes to the same file or -command are appended to the previous writes. The file or pipe stays -open until @code{awk} exits. This is usually convenient. - -Sometimes there is a reason to close an output file or pipe earlier -than that. To do this, use the @code{close} function, as follows: - -@example -close(@var{filename}) -@end example - -@noindent -or - -@example -close(@var{command}) -@end example - -The argument @var{filename} or @var{command} can be any expression. -Its value must exactly equal the string used to open the file or pipe -to begin with---for example, if you open a pipe with this: - -@example -print $1 | "sort -r > names.sorted" -@end example - -@noindent -then you must close it with this: - -@example -close("sort -r > names.sorted") -@end example - -Here are some reasons why you might need to close an output file: - -@itemize @bullet -@item -To write a file and read it back later on in the same @code{awk} -program. Close the file when you are finished writing it; then -you can start reading it with @code{getline} -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@item -To write numerous files, successively, in the same @code{awk} -program. If you don't close the files, eventually you may exceed a -system limit on the number of open files in one process. So close -each one when you are finished writing it. - -@item -To make a command finish. When you redirect output through a pipe, -the command reading the pipe normally continues to try to read input -as long as the pipe is open. Often this means the command cannot -really do its work until the pipe is closed. For example, if you -redirect output to the @code{mail} program, the message is not -actually sent until the pipe is closed. - -@item -To run the same program a second time, with the same arguments. -This is not the same thing as giving more input to the first run! - -For example, suppose you pipe output to the @code{mail} program. If you -output several lines redirected to this pipe without closing it, they make -a single message of several lines. By contrast, if you close the pipe -after each line of output, then each line makes a separate message. -@end itemize - -@iftex -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@end iftex -@code{close} returns a value of zero if the close succeeded. -Otherwise, the value will be non-zero. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -@node Special Files, , Redirection, Printing -@section Standard I/O Streams -@cindex standard input -@cindex standard output -@cindex standard error output -@cindex file descriptors - -Running programs conventionally have three input and output streams -already available to them for reading and writing. These are known as -the @dfn{standard input}, @dfn{standard output}, and @dfn{standard error -output}. These streams are, by default, terminal input and output, but -they are often redirected with the shell, via the @samp{<}, @samp{<<}, -@samp{>}, @samp{>>}, @samp{>&} and @samp{|} operators. Standard error -is used only for writing error messages; the reason we have two separate -streams, standard output and standard error, is so that they can be -redirected separately. - -@iftex -@cindex differences: @code{gawk} and @code{awk} -@end iftex -In other implementations of @code{awk}, the only way to write an error -message to standard error in an @code{awk} program is as follows: - -@smallexample -print "Serious error detected!\n" | "cat 1>&2" -@end smallexample - -@noindent -This works by opening a pipeline to a shell command which can access the -standard error stream which it inherits from the @code{awk} process. -This is far from elegant, and is also inefficient, since it requires a -separate process. So people writing @code{awk} programs have often -neglected to do this. Instead, they have sent the error messages to the -terminal, like this: - -@smallexample -@group -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/tty" -@} -@end group -@end smallexample - -@noindent -This has the same effect most of the time, but not always: although the -standard error stream is usually the terminal, it can be redirected, and -when that happens, writing to the terminal is not correct. In fact, if -@code{awk} is run from a background job, it may not have a terminal at all. -Then opening @file{/dev/tty} will fail. - -@code{gawk} provides special file names for accessing the three standard -streams. When you redirect input or output in @code{gawk}, if the file name -matches one of these special names, then @code{gawk} directly uses the -stream it stands for. - -@cindex @file{/dev/stdin} -@cindex @file{/dev/stdout} -@cindex @file{/dev/stderr} -@cindex @file{/dev/fd/} -@table @file -@item /dev/stdin -The standard input (file descriptor 0). - -@item /dev/stdout -The standard output (file descriptor 1). - -@item /dev/stderr -The standard error output (file descriptor 2). - -@item /dev/fd/@var{N} -The file associated with file descriptor @var{N}. Such a file must have -been opened by the program initiating the @code{awk} execution (typically -the shell). Unless you take special pains, only descriptors 0, 1 and 2 -are available. -@end table - -The file names @file{/dev/stdin}, @file{/dev/stdout}, and @file{/dev/stderr} -are aliases for @file{/dev/fd/0}, @file{/dev/fd/1}, and @file{/dev/fd/2}, -respectively, but they are more self-explanatory. - -The proper way to write an error message in a @code{gawk} program -is to use @file{/dev/stderr}, like this: - -@smallexample -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/stderr" -@} -@end smallexample - -@code{gawk} also provides special file names that give access to information -about the running @code{gawk} process. Each of these ``files'' provides -a single record of information. To read them more than once, you must -first close them with the @code{close} function -(@pxref{Close Input, ,Closing Input Files and Pipes}). -The filenames are: - -@cindex @file{/dev/pid} -@cindex @file{/dev/pgrpid} -@cindex @file{/dev/ppid} -@cindex @file{/dev/user} -@table @file -@item /dev/pid -Reading this file returns the process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/ppid -Reading this file returns the parent process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/pgrpid -Reading this file returns the process group ID of the current process, -in decimal, terminated with a newline. - -@item /dev/user -Reading this file returns a single record terminated with a newline. -The fields are separated with blanks. The fields represent the -following information: - -@table @code -@item $1 -The value of the @code{getuid} system call. - -@item $2 -The value of the @code{geteuid} system call. - -@item $3 -The value of the @code{getgid} system call. - -@item $4 -The value of the @code{getegid} system call. -@end table - -If there are any additional fields, they are the group IDs returned by -@code{getgroups} system call. -(Multiple groups may not be supported on all systems.)@refill -@end table - -These special file names may be used on the command line as data -files, as well as for I/O redirections within an @code{awk} program. -They may not be used as source files with the @samp{-f} option. - -Recognition of these special file names is disabled if @code{gawk} is in -compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}). - -@quotation -@strong{Caution}: Unless your system actually has a @file{/dev/fd} directory -(or any of the other above listed special files), -the interpretation of these file names is done by @code{gawk} itself. -For example, using @samp{/dev/fd/4} for output will actually write on -file descriptor 4, and not on a new file descriptor that was @code{dup}'ed -from file descriptor 4. Most of the time this does not matter; however, it -is important to @emph{not} close any of the files related to file descriptors -0, 1, and 2. If you do close one of these files, unpredictable behavior -will result. -@end quotation - -@node One-liners, Patterns, Printing, Top -@chapter Useful ``One-liners'' - -@cindex one-liners -Useful @code{awk} programs are often short, just a line or two. Here is a -collection of useful, short programs to get you started. Some of these -programs contain constructs that haven't been covered yet. The description -of the program will give you a good idea of what is going on, but please -read the rest of the manual to become an @code{awk} expert! - -@c Per suggestions from Michal Jaegermann -@ifinfo -Since you are reading this in Info, each line of the example code is -enclosed in quotes, to represent text that you would type literally. -The examples themselves represent shell commands that use single quotes -to keep the shell from interpreting the contents of the program. -When reading the examples, focus on the text between the open and close -quotes. -@end ifinfo - -@table @code -@item awk '@{ if (NF > max) max = NF @} -@itemx @ @ @ @ @ END @{ print max @}' -This program prints the maximum number of fields on any input line. - -@item awk 'length($0) > 80' -This program prints every line longer than 80 characters. The sole -rule has a relational expression as its pattern, and has no action (so the -default action, printing the record, is used). - -@item awk 'NF > 0' -This program prints every line that has at least one field. This is an -easy way to delete blank lines from a file (or rather, to create a new -file similar to the old file but from which the blank lines have been -deleted). - -@item awk '@{ if (NF > 0) print @}' -This program also prints every line that has at least one field. Here we -allow the rule to match every line, then decide in the action whether -to print. - -@item awk@ 'BEGIN@ @{@ for (i = 1; i <= 7; i++) -@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ print int(101 * rand()) @}' -This program prints 7 random numbers from 0 to 100, inclusive. - -@item ls -l @var{files} | awk '@{ x += $4 @} ; END @{ print "total bytes: " x @}' -This program prints the total number of bytes used by @var{files}. - -@item expand@ @var{file}@ |@ awk@ '@{ if (x < length()) x = length() @} -@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ END @{ print "maximum line length is " x @}' -This program prints the maximum line length of @var{file}. The input -is piped through the @code{expand} program to change tabs into spaces, -so the widths compared are actually the right-margin columns. - -@item awk 'BEGIN @{ FS = ":" @} -@itemx @ @ @ @ @ @{ print $1 | "sort" @}' /etc/passwd -This program prints a sorted list of the login names of all users. - -@item awk '@{ nlines++ @} -@itemx @ @ @ @ @ END@ @{ print nlines @}' -This programs counts lines in a file. - -@item awk 'END @{ print NR @}' -This program also counts lines in a file, but lets @code{awk} do the work. - -@item awk '@{ print NR, $0 @}' -This program adds line numbers to all its input files, -similar to @samp{cat -n}. -@end table - -@node Patterns, Actions, One-liners, Top -@chapter Patterns -@cindex pattern, definition of - -Patterns in @code{awk} control the execution of rules: a rule is -executed when its pattern matches the current input record. This -chapter tells all about how to write patterns. - -@menu -* Kinds of Patterns:: A list of all kinds of patterns. - The following subsections describe - them in detail. -* Regexp:: Regular expressions such as @samp{/foo/}. -* Comparison Patterns:: Comparison expressions such as @code{$1 > 10}. -* Boolean Patterns:: Combining comparison expressions. -* Expression Patterns:: Any expression can be used as a pattern. -* Ranges:: Pairs of patterns specify record ranges. -* BEGIN/END:: Specifying initialization and cleanup rules. -* Empty:: The empty pattern, which matches every record. -@end menu - -@node Kinds of Patterns, Regexp, Patterns, Patterns -@section Kinds of Patterns -@cindex patterns, types of - -Here is a summary of the types of patterns supported in @code{awk}. -@c At the next rewrite, check to see that this order matches the -@c order in the text. It might not matter to a reader, but it's good -@c style. Also, it might be nice to mention all the topics of sections -@c that follow in this list; that way people can scan and know when to -@c expect a specific topic. Specifically please also make an entry -@c for Boolean operators as patterns in the right place. --mew - -@table @code -@item /@var{regular expression}/ -A regular expression as a pattern. It matches when the text of the -input record fits the regular expression. -(@xref{Regexp, ,Regular Expressions as Patterns}.)@refill - -@item @var{expression} -A single expression. It matches when its value, converted to a number, -is nonzero (if a number) or nonnull (if a string). -(@xref{Expression Patterns, ,Expressions as Patterns}.)@refill - -@item @var{pat1}, @var{pat2} -A pair of patterns separated by a comma, specifying a range of records. -(@xref{Ranges, ,Specifying Record Ranges with Patterns}.) - -@item BEGIN -@itemx END -Special patterns to supply start-up or clean-up information to -@code{awk}. (@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}.) - -@item @var{null} -The empty pattern matches every input record. -(@xref{Empty, ,The Empty Pattern}.)@refill -@end table - - -@node Regexp, Comparison Patterns, Kinds of Patterns, Patterns -@section Regular Expressions as Patterns -@cindex pattern, regular expressions -@cindex regexp -@cindex regular expressions as patterns - -A @dfn{regular expression}, or @dfn{regexp}, is a way of describing a -class of strings. A regular expression enclosed in slashes (@samp{/}) -is an @code{awk} pattern that matches every input record whose text -belongs to that class. - -The simplest regular expression is a sequence of letters, numbers, or -both. Such a regexp matches any string that contains that sequence. -Thus, the regexp @samp{foo} matches any string containing @samp{foo}. -Therefore, the pattern @code{/foo/} matches any input record containing -@samp{foo}. Other kinds of regexps let you specify more complicated -classes of strings. - -@menu -* Regexp Usage:: How to Use Regular Expressions -* Regexp Operators:: Regular Expression Operators -* Case-sensitivity:: How to do case-insensitive matching. -@end menu - -@node Regexp Usage, Regexp Operators, Regexp, Regexp -@subsection How to Use Regular Expressions - -A regular expression can be used as a pattern by enclosing it in -slashes. Then the regular expression is matched against the -entire text of each record. (Normally, it only needs -to match some part of the text in order to succeed.) For example, this -prints the second field of each record that contains @samp{foo} anywhere: - -@example -awk '/foo/ @{ print $2 @}' BBS-list -@end example - -@cindex regular expression matching operators -@cindex string-matching operators -@cindex operators, string-matching -@cindex operators, regexp matching -@cindex regexp search operators -Regular expressions can also be used in comparison expressions. Then -you can specify the string to match against; it need not be the entire -current input record. These comparison expressions can be used as -patterns or in @code{if}, @code{while}, @code{for}, and @code{do} statements. - -@table @code -@item @var{exp} ~ /@var{regexp}/ -This is true if the expression @var{exp} (taken as a character string) -is matched by @var{regexp}. The following example matches, or selects, -all input records with the upper-case letter @samp{J} somewhere in the -first field:@refill - -@example -awk '$1 ~ /J/' inventory-shipped -@end example - -So does this: - -@example -awk '@{ if ($1 ~ /J/) print @}' inventory-shipped -@end example - -@item @var{exp} !~ /@var{regexp}/ -This is true if the expression @var{exp} (taken as a character string) -is @emph{not} matched by @var{regexp}. The following example matches, -or selects, all input records whose first field @emph{does not} contain -the upper-case letter @samp{J}:@refill - -@example -awk '$1 !~ /J/' inventory-shipped -@end example -@end table - -@cindex computed regular expressions -@cindex regular expressions, computed -@cindex dynamic regular expressions -The right hand side of a @samp{~} or @samp{!~} operator need not be a -constant regexp (i.e., a string of characters between slashes). It may -be any expression. The expression is evaluated, and converted if -necessary to a string; the contents of the string are used as the -regexp. A regexp that is computed in this way is called a @dfn{dynamic -regexp}. For example: - -@example -identifier_regexp = "[A-Za-z_][A-Za-z_0-9]+" -$0 ~ identifier_regexp -@end example - -@noindent -sets @code{identifier_regexp} to a regexp that describes @code{awk} -variable names, and tests if the input record matches this regexp. - -@node Regexp Operators, Case-sensitivity, Regexp Usage, Regexp -@subsection Regular Expression Operators -@cindex metacharacters -@cindex regular expression metacharacters - -You can combine regular expressions with the following characters, -called @dfn{regular expression operators}, or @dfn{metacharacters}, to -increase the power and versatility of regular expressions. - -Here is a table of metacharacters. All characters not listed in the -table stand for themselves. - -@table @code -@item ^ -This matches the beginning of the string or the beginning of a line -within the string. For example: - -@example -^@@chapter -@end example - -@noindent -matches the @samp{@@chapter} at the beginning of a string, and can be used -to identify chapter beginnings in Texinfo source files. - -@item $ -This is similar to @samp{^}, but it matches only at the end of a string -or the end of a line within the string. For example: - -@example -p$ -@end example - -@noindent -matches a record that ends with a @samp{p}. - -@item . -This matches any single character except a newline. For example: - -@example -.P -@end example - -@noindent -matches any single character followed by a @samp{P} in a string. Using -concatenation we can make regular expressions like @samp{U.A}, which -matches any three-character sequence that begins with @samp{U} and ends -with @samp{A}. - -@item [@dots{}] -This is called a @dfn{character set}. It matches any one of the -characters that are enclosed in the square brackets. For example: - -@example -[MVX] -@end example - -@noindent -matches any one of the characters @samp{M}, @samp{V}, or @samp{X} in a -string.@refill - -Ranges of characters are indicated by using a hyphen between the beginning -and ending characters, and enclosing the whole thing in brackets. For -example:@refill - -@example -[0-9] -@end example - -@noindent -matches any digit. - -To include the character @samp{\}, @samp{]}, @samp{-} or @samp{^} in a -character set, put a @samp{\} in front of it. For example: - -@example -[d\]] -@end example - -@noindent -matches either @samp{d}, or @samp{]}.@refill - -This treatment of @samp{\} is compatible with other @code{awk} -implementations, and is also mandated by the @sc{posix} Command Language -and Utilities standard. The regular expressions in @code{awk} are a superset -of the @sc{posix} specification for Extended Regular Expressions (EREs). -@sc{posix} EREs are based on the regular expressions accepted by the -traditional @code{egrep} utility. - -In @code{egrep} syntax, backslash is not syntactically special within -square brackets. This means that special tricks have to be used to -represent the characters @samp{]}, @samp{-} and @samp{^} as members of a -character set. - -In @code{egrep} syntax, to match @samp{-}, write it as @samp{---}, -which is a range containing only @w{@samp{-}.} You may also give @samp{-} -as the first or last character in the set. To match @samp{^}, put it -anywhere except as the first character of a set. To match a @samp{]}, -make it the first character in the set. For example:@refill - -@example -[]d^] -@end example - -@noindent -matches either @samp{]}, @samp{d} or @samp{^}.@refill - -@item [^ @dots{}] -This is a @dfn{complemented character set}. The first character after -the @samp{[} @emph{must} be a @samp{^}. It matches any characters -@emph{except} those in the square brackets (or newline). For example: - -@example -[^0-9] -@end example - -@noindent -matches any character that is not a digit. - -@item | -This is the @dfn{alternation operator} and it is used to specify -alternatives. For example: - -@example -^P|[0-9] -@end example - -@noindent -matches any string that matches either @samp{^P} or @samp{[0-9]}. This -means it matches any string that contains a digit or starts with @samp{P}. - -The alternation applies to the largest possible regexps on either side. -@item (@dots{}) -Parentheses are used for grouping in regular expressions as in -arithmetic. They can be used to concatenate regular expressions -containing the alternation operator, @samp{|}. - -@item * -This symbol means that the preceding regular expression is to be -repeated as many times as possible to find a match. For example: - -@example -ph* -@end example - -@noindent -applies the @samp{*} symbol to the preceding @samp{h} and looks for matches -to one @samp{p} followed by any number of @samp{h}s. This will also match -just @samp{p} if no @samp{h}s are present. - -The @samp{*} repeats the @emph{smallest} possible preceding expression. -(Use parentheses if you wish to repeat a larger expression.) It finds -as many repetitions as possible. For example: - -@example -awk '/\(c[ad][ad]*r x\)/ @{ print @}' sample -@end example - -@noindent -prints every record in the input containing a string of the form -@samp{(car x)}, @samp{(cdr x)}, @samp{(cadr x)}, and so on.@refill - -@item + -This symbol is similar to @samp{*}, but the preceding expression must be -matched at least once. This means that: - -@example -wh+y -@end example - -@noindent -would match @samp{why} and @samp{whhy} but not @samp{wy}, whereas -@samp{wh*y} would match all three of these strings. This is a simpler -way of writing the last @samp{*} example: - -@example -awk '/\(c[ad]+r x\)/ @{ print @}' sample -@end example - -@item ? -This symbol is similar to @samp{*}, but the preceding expression can be -matched once or not at all. For example: - -@example -fe?d -@end example - -@noindent -will match @samp{fed} and @samp{fd}, but nothing else.@refill - -@item \ -This is used to suppress the special meaning of a character when -matching. For example: - -@example -\$ -@end example - -@noindent -matches the character @samp{$}. - -The escape sequences used for string constants -(@pxref{Constants, ,Constant Expressions}) are -valid in regular expressions as well; they are also introduced by a -@samp{\}.@refill -@end table - -In regular expressions, the @samp{*}, @samp{+}, and @samp{?} operators have -the highest precedence, followed by concatenation, and finally by @samp{|}. -As in arithmetic, parentheses can change how operators are grouped.@refill - -@node Case-sensitivity, , Regexp Operators, Regexp -@subsection Case-sensitivity in Matching - -Case is normally significant in regular expressions, both when matching -ordinary characters (i.e., not metacharacters), and inside character -sets. Thus a @samp{w} in a regular expression matches only a lower case -@samp{w} and not an upper case @samp{W}. - -The simplest way to do a case-independent match is to use a character -set: @samp{[Ww]}. However, this can be cumbersome if you need to use it -often; and it can make the regular expressions harder for humans to -read. There are two other alternatives that you might prefer. - -One way to do a case-insensitive match at a particular point in the -program is to convert the data to a single case, using the -@code{tolower} or @code{toupper} built-in string functions (which we -haven't discussed yet; -@pxref{String Functions, ,Built-in Functions for String Manipulation}). -For example:@refill - -@example -tolower($1) ~ /foo/ @{ @dots{} @} -@end example - -@noindent -converts the first field to lower case before matching against it. - -Another method is to set the variable @code{IGNORECASE} to a nonzero -value (@pxref{Built-in Variables}). When @code{IGNORECASE} is not zero, -@emph{all} regexp operations ignore case. Changing the value of -@code{IGNORECASE} dynamically controls the case sensitivity of your -program as it runs. Case is significant by default because -@code{IGNORECASE} (like most variables) is initialized to zero. - -@example -x = "aB" -if (x ~ /ab/) @dots{} # this test will fail - -IGNORECASE = 1 -if (x ~ /ab/) @dots{} # now it will succeed -@end example - -In general, you cannot use @code{IGNORECASE} to make certain rules -case-insensitive and other rules case-sensitive, because there is no way -to set @code{IGNORECASE} just for the pattern of a particular rule. To -do this, you must use character sets or @code{tolower}. However, one -thing you can do only with @code{IGNORECASE} is turn case-sensitivity on -or off dynamically for all the rules at once.@refill - -@code{IGNORECASE} can be set on the command line, or in a @code{BEGIN} -rule. Setting @code{IGNORECASE} from the command line is a way to make -a program case-insensitive without having to edit it. - -The value of @code{IGNORECASE} has no effect if @code{gawk} is in -compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}). -Case is always significant in compatibility mode.@refill - -@node Comparison Patterns, Boolean Patterns, Regexp, Patterns -@section Comparison Expressions as Patterns -@cindex comparison expressions as patterns -@cindex pattern, comparison expressions -@cindex relational operators -@cindex operators, relational - -@dfn{Comparison patterns} test relationships such as equality between -two strings or numbers. They are a special case of expression patterns -(@pxref{Expression Patterns, ,Expressions as Patterns}). They are written -with @dfn{relational operators}, which are a superset of those in C. -Here is a table of them:@refill - -@table @code -@item @var{x} < @var{y} -True if @var{x} is less than @var{y}. - -@item @var{x} <= @var{y} -True if @var{x} is less than or equal to @var{y}. - -@item @var{x} > @var{y} -True if @var{x} is greater than @var{y}. - -@item @var{x} >= @var{y} -True if @var{x} is greater than or equal to @var{y}. - -@item @var{x} == @var{y} -True if @var{x} is equal to @var{y}. - -@item @var{x} != @var{y} -True if @var{x} is not equal to @var{y}. - -@item @var{x} ~ @var{y} -True if @var{x} matches the regular expression described by @var{y}. - -@item @var{x} !~ @var{y} -True if @var{x} does not match the regular expression described by @var{y}. -@end table - -The operands of a relational operator are compared as numbers if they -are both numbers. Otherwise they are converted to, and compared as, -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}, -for the detailed rules). Strings are compared by comparing the first -character of each, then the second character of each, -and so on, until there is a difference. If the two strings are equal until -the shorter one runs out, the shorter one is considered to be less than the -longer one. Thus, @code{"10"} is less than @code{"9"}, and @code{"abc"} -is less than @code{"abcd"}.@refill - -The left operand of the @samp{~} and @samp{!~} operators is a string. -The right operand is either a constant regular expression enclosed in -slashes (@code{/@var{regexp}/}), or any expression, whose string value -is used as a dynamic regular expression -(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill - -The following example prints the second field of each input record -whose first field is precisely @samp{foo}. - -@example -awk '$1 == "foo" @{ print $2 @}' BBS-list -@end example - -@noindent -Contrast this with the following regular expression match, which would -accept any record with a first field that contains @samp{foo}: - -@example -awk '$1 ~ "foo" @{ print $2 @}' BBS-list -@end example - -@noindent -or, equivalently, this one: - -@example -awk '$1 ~ /foo/ @{ print $2 @}' BBS-list -@end example - -@node Boolean Patterns, Expression Patterns, Comparison Patterns, Patterns -@section Boolean Operators and Patterns -@cindex patterns, boolean -@cindex boolean patterns - -A @dfn{boolean pattern} is an expression which combines other patterns -using the @dfn{boolean operators} ``or'' (@samp{||}), ``and'' -(@samp{&&}), and ``not'' (@samp{!}). Whether the boolean pattern -matches an input record depends on whether its subpatterns match. - -For example, the following command prints all records in the input file -@file{BBS-list} that contain both @samp{2400} and @samp{foo}.@refill - -@example -awk '/2400/ && /foo/' BBS-list -@end example - -The following command prints all records in the input file -@file{BBS-list} that contain @emph{either} @samp{2400} or @samp{foo}, or -both.@refill - -@example -awk '/2400/ || /foo/' BBS-list -@end example - -The following command prints all records in the input file -@file{BBS-list} that do @emph{not} contain the string @samp{foo}. - -@example -awk '! /foo/' BBS-list -@end example - -Note that boolean patterns are a special case of expression patterns -(@pxref{Expression Patterns, ,Expressions as Patterns}); they are -expressions that use the boolean operators. -@xref{Boolean Ops, ,Boolean Expressions}, for complete information -on the boolean operators.@refill - -The subpatterns of a boolean pattern can be constant regular -expressions, comparisons, or any other @code{awk} expressions. Range -patterns are not expressions, so they cannot appear inside boolean -patterns. Likewise, the special patterns @code{BEGIN} and @code{END}, -which never match any input record, are not expressions and cannot -appear inside boolean patterns. - -@node Expression Patterns, Ranges, Boolean Patterns, Patterns -@section Expressions as Patterns - -Any @code{awk} expression is also valid as an @code{awk} pattern. -Then the pattern ``matches'' if the expression's value is nonzero (if a -number) or nonnull (if a string). - -The expression is reevaluated each time the rule is tested against a new -input record. If the expression uses fields such as @code{$1}, the -value depends directly on the new input record's text; otherwise, it -depends only on what has happened so far in the execution of the -@code{awk} program, but that may still be useful. - -Comparison patterns are actually a special case of this. For -example, the expression @code{$5 == "foo"} has the value 1 when the -value of @code{$5} equals @code{"foo"}, and 0 otherwise; therefore, this -expression as a pattern matches when the two values are equal. - -Boolean patterns are also special cases of expression patterns. - -A constant regexp as a pattern is also a special case of an expression -pattern. @code{/foo/} as an expression has the value 1 if @samp{foo} -appears in the current input record; thus, as a pattern, @code{/foo/} -matches any record containing @samp{foo}. - -Other implementations of @code{awk} that are not yet @sc{posix} compliant -are less general than @code{gawk}: they allow comparison expressions, and -boolean combinations thereof (optionally with parentheses), but not -necessarily other kinds of expressions. - -@node Ranges, BEGIN/END, Expression Patterns, Patterns -@section Specifying Record Ranges with Patterns - -@cindex range pattern -@cindex patterns, range -A @dfn{range pattern} is made of two patterns separated by a comma, of -the form @code{@var{begpat}, @var{endpat}}. It matches ranges of -consecutive input records. The first pattern @var{begpat} controls -where the range begins, and the second one @var{endpat} controls where -it ends. For example,@refill - -@example -awk '$1 == "on", $1 == "off"' -@end example - -@noindent -prints every record between @samp{on}/@samp{off} pairs, inclusive. - -A range pattern starts out by matching @var{begpat} -against every input record; when a record matches @var{begpat}, the -range pattern becomes @dfn{turned on}. The range pattern matches this -record. As long as it stays turned on, it automatically matches every -input record read. It also matches @var{endpat} against -every input record; when that succeeds, the range pattern is turned -off again for the following record. Now it goes back to checking -@var{begpat} against each record. - -The record that turns on the range pattern and the one that turns it -off both match the range pattern. If you don't want to operate on -these records, you can write @code{if} statements in the rule's action -to distinguish them. - -It is possible for a pattern to be turned both on and off by the same -record, if both conditions are satisfied by that record. Then the action is -executed for just that record. - -@node BEGIN/END, Empty, Ranges, Patterns -@section @code{BEGIN} and @code{END} Special Patterns - -@cindex @code{BEGIN} special pattern -@cindex patterns, @code{BEGIN} -@cindex @code{END} special pattern -@cindex patterns, @code{END} -@code{BEGIN} and @code{END} are special patterns. They are not used to -match input records. Rather, they are used for supplying start-up or -clean-up information to your @code{awk} script. A @code{BEGIN} rule is -executed, once, before the first input record has been read. An @code{END} -rule is executed, once, after all the input has been read. For -example:@refill - -@example -awk 'BEGIN @{ print "Analysis of `foo'" @} - /foo/ @{ ++foobar @} - END @{ print "`foo' appears " foobar " times." @}' BBS-list -@end example - -This program finds the number of records in the input file @file{BBS-list} -that contain the string @samp{foo}. The @code{BEGIN} rule prints a title -for the report. There is no need to use the @code{BEGIN} rule to -initialize the counter @code{foobar} to zero, as @code{awk} does this -for us automatically (@pxref{Variables}). - -The second rule increments the variable @code{foobar} every time a -record containing the pattern @samp{foo} is read. The @code{END} rule -prints the value of @code{foobar} at the end of the run.@refill - -The special patterns @code{BEGIN} and @code{END} cannot be used in ranges -or with boolean operators (indeed, they cannot be used with any operators). - -An @code{awk} program may have multiple @code{BEGIN} and/or @code{END} -rules. They are executed in the order they appear, all the @code{BEGIN} -rules at start-up and all the @code{END} rules at termination. - -Multiple @code{BEGIN} and @code{END} sections are useful for writing -library functions, since each library can have its own @code{BEGIN} or -@code{END} rule to do its own initialization and/or cleanup. Note that -the order in which library functions are named on the command line -controls the order in which their @code{BEGIN} and @code{END} rules are -executed. Therefore you have to be careful to write such rules in -library files so that the order in which they are executed doesn't matter. -@xref{Command Line, ,Invoking @code{awk}}, for more information on -using library functions. - -If an @code{awk} program only has a @code{BEGIN} rule, and no other -rules, then the program exits after the @code{BEGIN} rule has been run. -(Older versions of @code{awk} used to keep reading and ignoring input -until end of file was seen.) However, if an @code{END} rule exists as -well, then the input will be read, even if there are no other rules in -the program. This is necessary in case the @code{END} rule checks the -@code{NR} variable. - -@code{BEGIN} and @code{END} rules must have actions; there is no default -action for these rules since there is no current record when they run. - -@node Empty, , BEGIN/END, Patterns -@comment node-name, next, previous, up -@section The Empty Pattern - -@cindex empty pattern -@cindex pattern, empty -An empty pattern is considered to match @emph{every} input record. For -example, the program:@refill - -@example -awk '@{ print $1 @}' BBS-list -@end example - -@noindent -prints the first field of every record. - -@node Actions, Expressions, Patterns, Top -@chapter Overview of Actions -@cindex action, definition of -@cindex curly braces -@cindex action, curly braces -@cindex action, separating statements - -An @code{awk} program or script consists of a series of -rules and function definitions, interspersed. (Functions are -described later. @xref{User-defined, ,User-defined Functions}.) - -A rule contains a pattern and an action, either of which may be -omitted. The purpose of the @dfn{action} is to tell @code{awk} what to do -once a match for the pattern is found. Thus, the entire program -looks somewhat like this: - -@example -@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]} -@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]} -@dots{} -function @var{name} (@var{args}) @{ @dots{} @} -@dots{} -@end example - -An action consists of one or more @code{awk} @dfn{statements}, enclosed -in curly braces (@samp{@{} and @samp{@}}). Each statement specifies one -thing to be done. The statements are separated by newlines or -semicolons. - -The curly braces around an action must be used even if the action -contains only one statement, or even if it contains no statements at -all. However, if you omit the action entirely, omit the curly braces as -well. (An omitted action is equivalent to @samp{@{ print $0 @}}.) - -Here are the kinds of statements supported in @code{awk}: - -@itemize @bullet -@item -Expressions, which can call functions or assign values to variables -(@pxref{Expressions, ,Expressions as Action Statements}). Executing -this kind of statement simply computes the value of the expression and -then ignores it. This is useful when the expression has side effects -(@pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -Control statements, which specify the control flow of @code{awk} -programs. The @code{awk} language gives you C-like constructs -(@code{if}, @code{for}, @code{while}, and so on) as well as a few -special ones (@pxref{Statements, ,Control Statements in Actions}).@refill - -@item -Compound statements, which consist of one or more statements enclosed in -curly braces. A compound statement is used in order to put several -statements together in the body of an @code{if}, @code{while}, @code{do} -or @code{for} statement. - -@item -Input control, using the @code{getline} command -(@pxref{Getline, ,Explicit Input with @code{getline}}), and the @code{next} -statement (@pxref{Next Statement, ,The @code{next} Statement}). - -@item -Output statements, @code{print} and @code{printf}. -@xref{Printing, ,Printing Output}.@refill - -@item -Deletion statements, for deleting array elements. -@xref{Delete, ,The @code{delete} Statement}.@refill -@end itemize - -@iftex -The next two chapters cover in detail expressions and control -statements, respectively. We go on to treat arrays and built-in -functions, both of which are used in expressions. Then we proceed -to discuss how to define your own functions. -@end iftex - -@node Expressions, Statements, Actions, Top -@chapter Expressions as Action Statements -@cindex expression - -Expressions are the basic building block of @code{awk} actions. An -expression evaluates to a value, which you can print, test, store in a -variable or pass to a function. But beyond that, an expression can assign a new value to a variable -or a field, with an assignment operator. - -An expression can serve as a statement on its own. Most other kinds of -statements contain one or more expressions which specify data to be -operated on. As in other languages, expressions in @code{awk} include -variables, array references, constants, and function calls, as well as -combinations of these with various operators. - -@menu -* Constants:: String, numeric, and regexp constants. -* Variables:: Variables give names to values for later use. -* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-}, etc.) -* Concatenation:: Concatenating strings. -* Comparison Ops:: Comparison of numbers and strings - with @samp{<}, etc. -* Boolean Ops:: Combining comparison expressions - using boolean operators - @samp{||} (``or''), @samp{&&} (``and'') and @samp{!} (``not''). - -* Assignment Ops:: Changing the value of a variable or a field. -* Increment Ops:: Incrementing the numeric value of a variable. - -* Conversion:: The conversion of strings to numbers - and vice versa. -* Values:: The whole truth about numbers and strings. -* Conditional Exp:: Conditional expressions select - between two subexpressions under control - of a third subexpression. -* Function Calls:: A function call is an expression. -* Precedence:: How various operators nest. -@end menu - -@node Constants, Variables, Expressions, Expressions -@section Constant Expressions -@cindex constants, types of -@cindex string constants - -The simplest type of expression is the @dfn{constant}, which always has -the same value. There are three types of constants: numeric constants, -string constants, and regular expression constants. - -@cindex numeric constant -@cindex numeric value -A @dfn{numeric constant} stands for a number. This number can be an -integer, a decimal fraction, or a number in scientific (exponential) -notation. Note that all numeric values are represented within -@code{awk} in double-precision floating point. Here are some examples -of numeric constants, which all have the same value: - -@example -105 -1.05e+2 -1050e-1 -@end example - -A string constant consists of a sequence of characters enclosed in -double-quote marks. For example: - -@example -"parrot" -@end example - -@noindent -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex -represents the string whose contents are @samp{parrot}. Strings in -@code{gawk} can be of any length and they can contain all the possible -8-bit ASCII characters including ASCII NUL. Other @code{awk} -implementations may have difficulty with some character codes.@refill - -@cindex escape sequence notation -Some characters cannot be included literally in a string constant. You -represent them instead with @dfn{escape sequences}, which are character -sequences beginning with a backslash (@samp{\}). - -One use of an escape sequence is to include a double-quote character in -a string constant. Since a plain double-quote would end the string, you -must use @samp{\"} to represent a single double-quote character as a -part of the string. -The -backslash character itself is another character that cannot be -included normally; you write @samp{\\} to put one backslash in the -string. Thus, the string whose contents are the two characters -@samp{"\} must be written @code{"\"\\"}. - -Another use of backslash is to represent unprintable characters -such as newline. While there is nothing to stop you from writing most -of these characters directly in a string constant, they may look ugly. - -Here is a table of all the escape sequences used in @code{awk}: - -@table @code -@item \\ -Represents a literal backslash, @samp{\}. - -@item \a -Represents the ``alert'' character, control-g, ASCII code 7. - -@item \b -Represents a backspace, control-h, ASCII code 8. - -@item \f -Represents a formfeed, control-l, ASCII code 12. - -@item \n -Represents a newline, control-j, ASCII code 10. - -@item \r -Represents a carriage return, control-m, ASCII code 13. - -@item \t -Represents a horizontal tab, control-i, ASCII code 9. - -@item \v -Represents a vertical tab, control-k, ASCII code 11. - -@item \@var{nnn} -Represents the octal value @var{nnn}, where @var{nnn} are one to three -digits between 0 and 7. For example, the code for the ASCII ESC -(escape) character is @samp{\033}.@refill - -@item \x@var{hh}@dots{} -Represents the hexadecimal value @var{hh}, where @var{hh} are hexadecimal -digits (@samp{0} through @samp{9} and either @samp{A} through @samp{F} or -@samp{a} through @samp{f}). Like the same construct in @sc{ansi} C, the escape -sequence continues until the first non-hexadecimal digit is seen. However, -using more than two hexadecimal digits produces undefined results. (The -@samp{\x} escape sequence is not allowed in @sc{posix} @code{awk}.)@refill -@end table - -A @dfn{constant regexp} is a regular expression description enclosed in -slashes, such as @code{/^beginning and end$/}. Most regexps used in -@code{awk} programs are constant, but the @samp{~} and @samp{!~} -operators can also match computed or ``dynamic'' regexps -(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill - -Constant regexps may be used like simple expressions. When a -constant regexp is not on the right hand side of the @samp{~} or -@samp{!~} operators, it has the same meaning as if it appeared -in a pattern, i.e. @samp{($0 ~ /foo/)} -(@pxref{Expression Patterns, ,Expressions as Patterns}). -This means that the two code segments,@refill - -@example -if ($0 ~ /barfly/ || $0 ~ /camelot/) - print "found" -@end example - -@noindent -and - -@example -if (/barfly/ || /camelot/) - print "found" -@end example - -@noindent -are exactly equivalent. One rather bizarre consequence of this rule is -that the following boolean expression is legal, but does not do what the user -intended:@refill - -@example -if (/foo/ ~ $1) print "found foo" -@end example - -This code is ``obviously'' testing @code{$1} for a match against the regexp -@code{/foo/}. But in fact, the expression @code{(/foo/ ~ $1)} actually means -@code{(($0 ~ /foo/) ~ $1)}. In other words, first match the input record -against the regexp @code{/foo/}. The result will be either a 0 or a 1, -depending upon the success or failure of the match. Then match that result -against the first field in the record.@refill - -Since it is unlikely that you would ever really wish to make this kind of -test, @code{gawk} will issue a warning when it sees this construct in -a program.@refill - -Another consequence of this rule is that the assignment statement - -@example -matches = /foo/ -@end example - -@noindent -will assign either 0 or 1 to the variable @code{matches}, depending -upon the contents of the current input record. - -Constant regular expressions are also used as the first argument for -the @code{sub} and @code{gsub} functions -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -This feature of the language was never well documented until the -@sc{posix} specification. - -You may be wondering, when is - -@example -$1 ~ /foo/ @{ @dots{} @} -@end example - -@noindent -preferable to - -@example -$1 ~ "foo" @{ @dots{} @} -@end example - -Since the right-hand sides of both @samp{~} operators are constants, -it is more efficient to use the @samp{/foo/} form: @code{awk} can note -that you have supplied a regexp and store it internally in a form that -makes pattern matching more efficient. In the second form, @code{awk} -must first convert the string into this internal form, and then perform -the pattern matching. The first form is also better style; it shows -clearly that you intend a regexp match. - -@node Variables, Arithmetic Ops, Constants, Expressions -@section Variables -@cindex variables, user-defined -@cindex user-defined variables -@c there should be more than one subsection, ideally. Not a big deal. -@c But usually there are supposed to be at least two. One way to get -@c around this is to write the info in the subsection as the info in the -@c section itself and not have any subsections.. --mew - -Variables let you give names to values and refer to them later. You have -already seen variables in many of the examples. The name of a variable -must be a sequence of letters, digits and underscores, but it may not begin -with a digit. Case is significant in variable names; @code{a} and @code{A} -are distinct variables. - -A variable name is a valid expression by itself; it represents the -variable's current value. Variables are given new values with -@dfn{assignment operators} and @dfn{increment operators}. -@xref{Assignment Ops, ,Assignment Expressions}. - -A few variables have special built-in meanings, such as @code{FS}, the -field separator, and @code{NF}, the number of fields in the current -input record. @xref{Built-in Variables}, for a list of them. These -built-in variables can be used and assigned just like all other -variables, but their values are also used or changed automatically by -@code{awk}. Each built-in variable's name is made entirely of upper case -letters. - -Variables in @code{awk} can be assigned either numeric or string -values. By default, variables are initialized to the null string, which -is effectively zero if converted to a number. There is no need to -``initialize'' each variable explicitly in @code{awk}, the way you would in C or most other traditional languages. - -@menu -* Assignment Options:: Setting variables on the command line - and a summary of command line syntax. - This is an advanced method of input. -@end menu - -@node Assignment Options, , Variables, Variables -@subsection Assigning Variables on the Command Line - -You can set any @code{awk} variable by including a @dfn{variable assignment} -among the arguments on the command line when you invoke @code{awk} -(@pxref{Command Line, ,Invoking @code{awk}}). Such an assignment has -this form:@refill - -@example -@var{variable}=@var{text} -@end example - -@noindent -With it, you can set a variable either at the beginning of the -@code{awk} run or in between input files. - -If you precede the assignment with the @samp{-v} option, like this: - -@example --v @var{variable}=@var{text} -@end example - -@noindent -then the variable is set at the very beginning, before even the -@code{BEGIN} rules are run. The @samp{-v} option and its assignment -must precede all the file name arguments, as well as the program text. - -Otherwise, the variable assignment is performed at a time determined by -its position among the input file arguments: after the processing of the -preceding input file argument. For example: - -@example -awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list -@end example - -@noindent -prints the value of field number @code{n} for all input records. Before -the first file is read, the command line sets the variable @code{n} -equal to 4. This causes the fourth field to be printed in lines from -the file @file{inventory-shipped}. After the first file has finished, -but before the second file is started, @code{n} is set to 2, so that the -second field is printed in lines from @file{BBS-list}. - -Command line arguments are made available for explicit examination by -the @code{awk} program in an array named @code{ARGV} -(@pxref{Built-in Variables}).@refill - -@code{awk} processes the values of command line assignments for escape -sequences (@pxref{Constants, ,Constant Expressions}). - -@node Arithmetic Ops, Concatenation, Variables, Expressions -@section Arithmetic Operators -@cindex arithmetic operators -@cindex operators, arithmetic -@cindex addition -@cindex subtraction -@cindex multiplication -@cindex division -@cindex remainder -@cindex quotient -@cindex exponentiation - -The @code{awk} language uses the common arithmetic operators when -evaluating expressions. All of these arithmetic operators follow normal -precedence rules, and work as you would expect them to. This example -divides field three by field four, adds field two, stores the result -into field one, and prints the resulting altered input record: - -@example -awk '@{ $1 = $2 + $3 / $4; print @}' inventory-shipped -@end example - -The arithmetic operators in @code{awk} are: - -@table @code -@item @var{x} + @var{y} -Addition. - -@item @var{x} - @var{y} -Subtraction. - -@item - @var{x} -Negation. - -@item + @var{x} -Unary plus. No real effect on the expression. - -@item @var{x} * @var{y} -Multiplication. - -@item @var{x} / @var{y} -Division. Since all numbers in @code{awk} are double-precision -floating point, the result is not rounded to an integer: @code{3 / 4} -has the value 0.75. - -@item @var{x} % @var{y} -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex -Remainder. The quotient is rounded toward zero to an integer, -multiplied by @var{y} and this result is subtracted from @var{x}. -This operation is sometimes known as ``trunc-mod.'' The following -relation always holds: - -@example -b * int(a / b) + (a % b) == a -@end example - -One possibly undesirable effect of this definition of remainder is that -@code{@var{x} % @var{y}} is negative if @var{x} is negative. Thus, - -@example --17 % 8 = -1 -@end example - -In other @code{awk} implementations, the signedness of the remainder -may be machine dependent. - -@item @var{x} ^ @var{y} -@itemx @var{x} ** @var{y} -Exponentiation: @var{x} raised to the @var{y} power. @code{2 ^ 3} has -the value 8. The character sequence @samp{**} is equivalent to -@samp{^}. (The @sc{posix} standard only specifies the use of @samp{^} -for exponentiation.) -@end table - -@node Concatenation, Comparison Ops, Arithmetic Ops, Expressions -@section String Concatenation - -@cindex string operators -@cindex operators, string -@cindex concatenation -There is only one string operation: concatenation. It does not have a -specific operator to represent it. Instead, concatenation is performed by -writing expressions next to one another, with no operator. For example: - -@example -awk '@{ print "Field number one: " $1 @}' BBS-list -@end example - -@noindent -produces, for the first record in @file{BBS-list}: - -@example -Field number one: aardvark -@end example - -Without the space in the string constant after the @samp{:}, the line -would run together. For example: - -@example -awk '@{ print "Field number one:" $1 @}' BBS-list -@end example - -@noindent -produces, for the first record in @file{BBS-list}: - -@example -Field number one:aardvark -@end example - -Since string concatenation does not have an explicit operator, it is -often necessary to insure that it happens where you want it to by -enclosing the items to be concatenated in parentheses. For example, the -following code fragment does not concatenate @code{file} and @code{name} -as you might expect: - -@example -file = "file" -name = "name" -print "something meaningful" > file name -@end example - -@noindent -It is necessary to use the following: - -@example -print "something meaningful" > (file name) -@end example - -We recommend you use parentheses around concatenation in all but the -most common contexts (such as in the right-hand operand of @samp{=}). - -@ignore -@code{gawk} actually now allows a concatenation on the right hand -side of a @code{>} redirection, but other @code{awk}s don't. So for -now we won't mention that fact. -@end ignore - -@node Comparison Ops, Boolean Ops, Concatenation, Expressions -@section Comparison Expressions -@cindex comparison expressions -@cindex expressions, comparison -@cindex relational operators -@cindex operators, relational -@cindex regexp operators - -@dfn{Comparison expressions} compare strings or numbers for -relationships such as equality. They are written using @dfn{relational -operators}, which are a superset of those in C. Here is a table of -them: - -@table @code -@item @var{x} < @var{y} -True if @var{x} is less than @var{y}. - -@item @var{x} <= @var{y} -True if @var{x} is less than or equal to @var{y}. - -@item @var{x} > @var{y} -True if @var{x} is greater than @var{y}. - -@item @var{x} >= @var{y} -True if @var{x} is greater than or equal to @var{y}. - -@item @var{x} == @var{y} -True if @var{x} is equal to @var{y}. - -@item @var{x} != @var{y} -True if @var{x} is not equal to @var{y}. - -@item @var{x} ~ @var{y} -True if the string @var{x} matches the regexp denoted by @var{y}. - -@item @var{x} !~ @var{y} -True if the string @var{x} does not match the regexp denoted by @var{y}. - -@item @var{subscript} in @var{array} -True if array @var{array} has an element with the subscript @var{subscript}. -@end table - -Comparison expressions have the value 1 if true and 0 if false. - -The rules @code{gawk} uses for performing comparisons are based on those -in draft 11.2 of the @sc{posix} standard. The @sc{posix} standard introduced -the concept of a @dfn{numeric string}, which is simply a string that looks -like a number, for example, @code{@w{" +2"}}. - -@vindex CONVFMT -When performing a relational operation, @code{gawk} considers the type of an -operand to be the type it received on its last @emph{assignment}, rather -than the type of its last @emph{use} -(@pxref{Values, ,Numeric and String Values}). -This type is @emph{unknown} when the operand is from an ``external'' source: -field variables, command line arguments, array elements resulting from a -@code{split} operation, and the value of an @code{ENVIRON} element. -In this case only, if the operand is a numeric string, then it is -considered to be of both string type and numeric type. If at least one -operand of a comparison is of string type only, then a string -comparison is performed. Any numeric operand will be converted to a -string using the value of @code{CONVFMT} -(@pxref{Conversion, ,Conversion of Strings and Numbers}). -If one operand of a comparison is numeric, and the other operand is -either numeric or both numeric and string, then @code{gawk} does a -numeric comparison. If both operands have both types, then the -comparison is numeric. Strings are compared -by comparing the first character of each, then the second character of each, -and so on. Thus @code{"10"} is less than @code{"9"}. If there are two -strings where one is a prefix of the other, the shorter string is less than -the longer one. Thus @code{"abc"} is less than @code{"abcd"}.@refill - -Here are some sample expressions, how @code{gawk} compares them, and what -the result of the comparison is. - -@table @code -@item 1.5 <= 2.0 -numeric comparison (true) - -@item "abc" >= "xyz" -string comparison (false) - -@item 1.5 != " +2" -string comparison (true) - -@item "1e2" < "3" -string comparison (true) - -@item a = 2; b = "2" -@itemx a == b -string comparison (true) -@end table - -@example -echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}' -@end example - -@noindent -prints @samp{false} since both @code{$1} and @code{$2} are numeric -strings and thus have both string and numeric types, thus dictating -a numeric comparison. - -The purpose of the comparison rules and the use of numeric strings is -to attempt to produce the behavior that is ``least surprising,'' while -still ``doing the right thing.'' - -String comparisons and regular expression comparisons are very different. -For example, - -@example -$1 == "foo" -@end example - -@noindent -has the value of 1, or is true, if the first field of the current input -record is precisely @samp{foo}. By contrast, - -@example -$1 ~ /foo/ -@end example - -@noindent -has the value 1 if the first field contains @samp{foo}, such as @samp{foobar}. - -The right hand operand of the @samp{~} and @samp{!~} operators may be -either a constant regexp (@code{/@dots{}/}), or it may be an ordinary -expression, in which case the value of the expression as a string is a -dynamic regexp (@pxref{Regexp Usage, ,How to Use Regular Expressions}). - -@cindex regexp as expression -In very recent implementations of @code{awk}, a constant regular -expression in slashes by itself is also an expression. The regexp -@code{/@var{regexp}/} is an abbreviation for this comparison expression: - -@example -$0 ~ /@var{regexp}/ -@end example - -In some contexts it may be necessary to write parentheses around the -regexp to avoid confusing the @code{gawk} parser. For example, -@code{(/x/ - /y/) > threshold} is not allowed, but @code{((/x/) - (/y/)) -> threshold} parses properly. - -One special place where @code{/foo/} is @emph{not} an abbreviation for -@code{$0 ~ /foo/} is when it is the right-hand operand of @samp{~} or -@samp{!~}! @xref{Constants, ,Constant Expressions}, where this is -discussed in more detail. - -@node Boolean Ops, Assignment Ops, Comparison Ops, Expressions -@section Boolean Expressions -@cindex expressions, boolean -@cindex boolean expressions -@cindex operators, boolean -@cindex boolean operators -@cindex logical operations -@cindex and operator -@cindex or operator -@cindex not operator - -A @dfn{boolean expression} is a combination of comparison expressions or -matching expressions, using the boolean operators ``or'' -(@samp{||}), ``and'' (@samp{&&}), and ``not'' (@samp{!}), along with -parentheses to control nesting. The truth of the boolean expression is -computed by combining the truth values of the component expressions. - -Boolean expressions can be used wherever comparison and matching -expressions can be used. They can be used in @code{if}, @code{while} -@code{do} and @code{for} statements. They have numeric values (1 if true, -0 if false), which come into play if the result of the boolean expression -is stored in a variable, or used in arithmetic.@refill - -In addition, every boolean expression is also a valid boolean pattern, so -you can use it as a pattern to control the execution of rules. - -Here are descriptions of the three boolean operators, with an example of -each. It may be instructive to compare these examples with the -analogous examples of boolean patterns -(@pxref{Boolean Patterns, ,Boolean Operators and Patterns}), which -use the same boolean operators in patterns instead of expressions.@refill - -@table @code -@item @var{boolean1} && @var{boolean2} -True if both @var{boolean1} and @var{boolean2} are true. For example, -the following statement prints the current input record if it contains -both @samp{2400} and @samp{foo}.@refill - -@smallexample -if ($0 ~ /2400/ && $0 ~ /foo/) print -@end smallexample - -The subexpression @var{boolean2} is evaluated only if @var{boolean1} -is true. This can make a difference when @var{boolean2} contains -expressions that have side effects: in the case of @code{$0 ~ /foo/ && -($2 == bar++)}, the variable @code{bar} is not incremented if there is -no @samp{foo} in the record. - -@item @var{boolean1} || @var{boolean2} -True if at least one of @var{boolean1} or @var{boolean2} is true. -For example, the following command prints all records in the input -file @file{BBS-list} that contain @emph{either} @samp{2400} or -@samp{foo}, or both.@refill - -@smallexample -awk '@{ if ($0 ~ /2400/ || $0 ~ /foo/) print @}' BBS-list -@end smallexample - -The subexpression @var{boolean2} is evaluated only if @var{boolean1} -is false. This can make a difference when @var{boolean2} contains -expressions that have side effects. - -@item !@var{boolean} -True if @var{boolean} is false. For example, the following program prints -all records in the input file @file{BBS-list} that do @emph{not} contain the -string @samp{foo}. - -@smallexample -awk '@{ if (! ($0 ~ /foo/)) print @}' BBS-list -@end smallexample -@end table - -@node Assignment Ops, Increment Ops, Boolean Ops, Expressions -@section Assignment Expressions -@cindex assignment operators -@cindex operators, assignment -@cindex expressions, assignment - -An @dfn{assignment} is an expression that stores a new value into a -variable. For example, let's assign the value 1 to the variable -@code{z}:@refill - -@example -z = 1 -@end example - -After this expression is executed, the variable @code{z} has the value 1. -Whatever old value @code{z} had before the assignment is forgotten. - -Assignments can store string values also. For example, this would store -the value @code{"this food is good"} in the variable @code{message}: - -@example -thing = "food" -predicate = "good" -message = "this " thing " is " predicate -@end example - -@noindent -(This also illustrates concatenation of strings.) - -The @samp{=} sign is called an @dfn{assignment operator}. It is the -simplest assignment operator because the value of the right-hand -operand is stored unchanged. - -@cindex side effect -Most operators (addition, concatenation, and so on) have no effect -except to compute a value. If you ignore the value, you might as well -not use the operator. An assignment operator is different; it does -produce a value, but even if you ignore the value, the assignment still -makes itself felt through the alteration of the variable. We call this -a @dfn{side effect}. - -@cindex lvalue -The left-hand operand of an assignment need not be a variable -(@pxref{Variables}); it can also be a field -(@pxref{Changing Fields, ,Changing the Contents of a Field}) or -an array element (@pxref{Arrays, ,Arrays in @code{awk}}). -These are all called @dfn{lvalues}, -which means they can appear on the left-hand side of an assignment operator. -The right-hand operand may be any expression; it produces the new value -which the assignment stores in the specified variable, field or array -element.@refill - -It is important to note that variables do @emph{not} have permanent types. -The type of a variable is simply the type of whatever value it happens -to hold at the moment. In the following program fragment, the variable -@code{foo} has a numeric value at first, and a string value later on: - -@example -foo = 1 -print foo -foo = "bar" -print foo -@end example - -@noindent -When the second assignment gives @code{foo} a string value, the fact that -it previously had a numeric value is forgotten. - -An assignment is an expression, so it has a value: the same value that -is assigned. Thus, @code{z = 1} as an expression has the value 1. -One consequence of this is that you can write multiple assignments together: - -@example -x = y = z = 0 -@end example - -@noindent -stores the value 0 in all three variables. It does this because the -value of @code{z = 0}, which is 0, is stored into @code{y}, and then -the value of @code{y = z = 0}, which is 0, is stored into @code{x}. - -You can use an assignment anywhere an expression is called for. For -example, it is valid to write @code{x != (y = 1)} to set @code{y} to 1 -and then test whether @code{x} equals 1. But this style tends to make -programs hard to read; except in a one-shot program, you should -rewrite it to get rid of such nesting of assignments. This is never very -hard. - -Aside from @samp{=}, there are several other assignment operators that -do arithmetic with the old value of the variable. For example, the -operator @samp{+=} computes a new value by adding the right-hand value -to the old value of the variable. Thus, the following assignment adds -5 to the value of @code{foo}: - -@example -foo += 5 -@end example - -@noindent -This is precisely equivalent to the following: - -@example -foo = foo + 5 -@end example - -@noindent -Use whichever one makes the meaning of your program clearer. - -Here is a table of the arithmetic assignment operators. In each -case, the right-hand operand is an expression whose value is converted -to a number. - -@table @code -@item @var{lvalue} += @var{increment} -Adds @var{increment} to the value of @var{lvalue} to make the new value -of @var{lvalue}. - -@item @var{lvalue} -= @var{decrement} -Subtracts @var{decrement} from the value of @var{lvalue}. - -@item @var{lvalue} *= @var{coefficient} -Multiplies the value of @var{lvalue} by @var{coefficient}. - -@item @var{lvalue} /= @var{quotient} -Divides the value of @var{lvalue} by @var{quotient}. - -@item @var{lvalue} %= @var{modulus} -Sets @var{lvalue} to its remainder by @var{modulus}. - -@item @var{lvalue} ^= @var{power} -@itemx @var{lvalue} **= @var{power} -Raises @var{lvalue} to the power @var{power}. -(Only the @code{^=} operator is specified by @sc{posix}.) -@end table - -@ignore -From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin) - In the discussion of assignment operators, it states that -``foo += 5'' "is precisely equivalent to" ``foo = foo + 5'' (p.77). That -may be true for simple variables, but it's not true for expressions with -side effects, like array references. For proof, try - BEGIN { - foo[rand()] += 5; for (x in foo) print x, foo[x] - bar[rand()] = bar[rand()] + 5; for (x in bar) print x, bar[x] - } -I suspect that the original statement is simply untrue--that '+=' is more -efficient in all cases. - -ADR --- Try to add something about this here for the next go 'round. -@end ignore - -@node Increment Ops, Conversion, Assignment Ops, Expressions -@section Increment Operators - -@cindex increment operators -@cindex operators, increment -@dfn{Increment operators} increase or decrease the value of a variable -by 1. You could do the same thing with an assignment operator, so -the increment operators add no power to the @code{awk} language; but they -are convenient abbreviations for something very common. - -The operator to add 1 is written @samp{++}. It can be used to increment -a variable either before or after taking its value. - -To pre-increment a variable @var{v}, write @code{++@var{v}}. This adds -1 to the value of @var{v} and that new value is also the value of this -expression. The assignment expression @code{@var{v} += 1} is completely -equivalent. - -Writing the @samp{++} after the variable specifies post-increment. This -increments the variable value just the same; the difference is that the -value of the increment expression itself is the variable's @emph{old} -value. Thus, if @code{foo} has the value 4, then the expression @code{foo++} -has the value 4, but it changes the value of @code{foo} to 5. - -The post-increment @code{foo++} is nearly equivalent to writing @code{(foo -+= 1) - 1}. It is not perfectly equivalent because all numbers in -@code{awk} are floating point: in floating point, @code{foo + 1 - 1} does -not necessarily equal @code{foo}. But the difference is minute as -long as you stick to numbers that are fairly small (less than a trillion). - -Any lvalue can be incremented. Fields and array elements are incremented -just like variables. (Use @samp{$(i++)} when you wish to do a field reference -and a variable increment at the same time. The parentheses are necessary -because of the precedence of the field reference operator, @samp{$}.) -@c expert information in the last parenthetical remark - -The decrement operator @samp{--} works just like @samp{++} except that -it subtracts 1 instead of adding. Like @samp{++}, it can be used before -the lvalue to pre-decrement or after it to post-decrement. - -Here is a summary of increment and decrement expressions. - -@table @code -@item ++@var{lvalue} -This expression increments @var{lvalue} and the new value becomes the -value of this expression. - -@item @var{lvalue}++ -This expression causes the contents of @var{lvalue} to be incremented. -The value of the expression is the @emph{old} value of @var{lvalue}. - -@item --@var{lvalue} -Like @code{++@var{lvalue}}, but instead of adding, it subtracts. It -decrements @var{lvalue} and delivers the value that results. - -@item @var{lvalue}-- -Like @code{@var{lvalue}++}, but instead of adding, it subtracts. It -decrements @var{lvalue}. The value of the expression is the @emph{old} -value of @var{lvalue}. -@end table - -@node Conversion, Values, Increment Ops, Expressions -@section Conversion of Strings and Numbers - -@cindex conversion of strings and numbers -Strings are converted to numbers, and numbers to strings, if the context -of the @code{awk} program demands it. For example, if the value of -either @code{foo} or @code{bar} in the expression @code{foo + bar} -happens to be a string, it is converted to a number before the addition -is performed. If numeric values appear in string concatenation, they -are converted to strings. Consider this:@refill - -@example -two = 2; three = 3 -print (two three) + 4 -@end example - -@noindent -This eventually prints the (numeric) value 27. The numeric values of -the variables @code{two} and @code{three} are converted to strings and -concatenated together, and the resulting string is converted back to the -number 23, to which 4 is then added. - -If, for some reason, you need to force a number to be converted to a -string, concatenate the null string with that number. To force a string -to be converted to a number, add zero to that string. - -A string is converted to a number by interpreting a numeric prefix -of the string as numerals: -@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"} -has a numeric value of 25. -Strings that can't be interpreted as valid numbers are converted to -zero. - -@vindex CONVFMT -The exact manner in which numbers are converted into strings is controlled -by the @code{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}). -Numbers are converted using a special version of the @code{sprintf} function -(@pxref{Built-in, ,Built-in Functions}) with @code{CONVFMT} as the format -specifier.@refill - -@code{CONVFMT}'s default value is @code{"%.6g"}, which prints a value with -at least six significant digits. For some applications you will want to -change it to specify more precision. Double precision on most modern -machines gives you 16 or 17 decimal digits of precision. - -Strange results can happen if you set @code{CONVFMT} to a string that doesn't -tell @code{sprintf} how to format floating point numbers in a useful way. -For example, if you forget the @samp{%} in the format, all numbers will be -converted to the same constant string.@refill - -As a special case, if a number is an integer, then the result of converting -it to a string is @emph{always} an integer, no matter what the value of -@code{CONVFMT} may be. Given the following code fragment: - -@example -CONVFMT = "%2.2f" -a = 12 -b = a "" -@end example - -@noindent -@code{b} has the value @code{"12"}, not @code{"12.00"}. - -@ignore -For the 2.14 version, describe the ``stickyness'' of conversions. Right now -the manual assumes everywhere that variables are either numbers or strings; -in fact both kinds of values may be valid. If both happen to be valid, a -conversion isn't necessary and isn't done. Revising the manual to be -consistent with this, though, is too big a job to tackle at the moment. - -7/92: This has sort of been done, only the section isn't completely right! - What to do? -7/92: Pretty much fixed, at least for the short term, thanks to text - from David. -@end ignore - -@vindex OFMT -Prior to the @sc{posix} standard, @code{awk} specified that the value -of @code{OFMT} was used for converting numbers to strings. @code{OFMT} -specifies the output format to use when printing numbers with @code{print}. -@code{CONVFMT} was introduced in order to separate the semantics of -conversions from the semantics of printing. Both @code{CONVFMT} and -@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority -of cases, old @code{awk} programs will not change their behavior. -However, this use of @code{OFMT} is something to keep in mind if you must -port your program to other implementations of @code{awk}; we recommend -that instead of changing your programs, you just port @code{gawk} itself!@refill - -@node Values, Conditional Exp, Conversion, Expressions -@section Numeric and String Values -@cindex conversion of strings and numbers - -Through most of this manual, we present @code{awk} values (such as constants, -fields, or variables) as @emph{either} numbers @emph{or} strings. This is -a convenient way to think about them, since typically they are used in only -one way, or the other. - -In truth though, @code{awk} values can be @emph{both} string and -numeric, at the same time. Internally, @code{awk} represents values -with a string, a (floating point) number, and an indication that one, -the other, or both representations of the value are valid. - -Keeping track of both kinds of values is important for execution -efficiency: a variable can acquire a string value the first time it -is used as a string, and then that string value can be used until the -variable is assigned a new value. Thus, if a variable with only a numeric -value is used in several concatenations in a row, it only has to be given -a string representation once. The numeric value remains valid, so that -no conversion back to a number is necessary if the variable is later used -in an arithmetic expression. - -Tracking both kinds of values is also important for precise numerical -calculations. Consider the following: - -@smallexample -a = 123.321 -CONVFMT = "%3.1f" -b = a " is a number" -c = a + 1.654 -@end smallexample - -@noindent -The variable @code{a} receives a string value in the concatenation and -assignment to @code{b}. The string value of @code{a} is @code{"123.3"}. -If the numeric value was lost when it was converted to a string, then the -numeric use of @code{a} in the last statement would lose information. -@code{c} would be assigned the value 124.954 instead of 124.975. -Such errors accumulate rapidly, and very adversely affect numeric -computations.@refill - -Once a numeric value acquires a corresponding string value, it stays valid -until a new assignment is made. If @code{CONVFMT} -(@pxref{Conversion, ,Conversion of Strings and Numbers}) changes in the -meantime, the old string value will still be used. For example:@refill - -@smallexample -BEGIN @{ - CONVFMT = "%2.2f" - a = 123.456 - b = a "" # force `a' to have string value too - printf "a = %s\n", a - CONVFMT = "%.6g" - printf "a = %s\n", a - a += 0 # make `a' numeric only again - printf "a = %s\n", a # use `a' as string -@} -@end smallexample - -@noindent -This program prints @samp{a = 123.46} twice, and then prints -@samp{a = 123.456}. - -@xref{Conversion, ,Conversion of Strings and Numbers}, for the rules that -specify how string values are made from numeric values. - -@node Conditional Exp, Function Calls, Values, Expressions -@section Conditional Expressions -@cindex conditional expression -@cindex expression, conditional - -A @dfn{conditional expression} is a special kind of expression with -three operands. It allows you to use one expression's value to select -one of two other expressions. - -The conditional expression looks the same as in the C language: - -@example -@var{selector} ? @var{if-true-exp} : @var{if-false-exp} -@end example - -@noindent -There are three subexpressions. The first, @var{selector}, is always -computed first. If it is ``true'' (not zero and not null) then -@var{if-true-exp} is computed next and its value becomes the value of -the whole expression. Otherwise, @var{if-false-exp} is computed next -and its value becomes the value of the whole expression.@refill - -For example, this expression produces the absolute value of @code{x}: - -@example -x > 0 ? x : -x -@end example - -Each time the conditional expression is computed, exactly one of -@var{if-true-exp} and @var{if-false-exp} is computed; the other is ignored. -This is important when the expressions contain side effects. For example, -this conditional expression examines element @code{i} of either array -@code{a} or array @code{b}, and increments @code{i}. - -@example -x == y ? a[i++] : b[i++] -@end example - -@noindent -This is guaranteed to increment @code{i} exactly once, because each time -one or the other of the two increment expressions is executed, -and the other is not. - -@node Function Calls, Precedence, Conditional Exp, Expressions -@section Function Calls -@cindex function call -@cindex calling a function - -A @dfn{function} is a name for a particular calculation. Because it has -a name, you can ask for it by name at any point in the program. For -example, the function @code{sqrt} computes the square root of a number. - -A fixed set of functions are @dfn{built-in}, which means they are -available in every @code{awk} program. The @code{sqrt} function is one -of these. @xref{Built-in, ,Built-in Functions}, for a list of built-in -functions and their descriptions. In addition, you can define your own -functions in the program for use elsewhere in the same program. -@xref{User-defined, ,User-defined Functions}, for how to do this.@refill - -@cindex arguments in function call -The way to use a function is with a @dfn{function call} expression, -which consists of the function name followed by a list of -@dfn{arguments} in parentheses. The arguments are expressions which -give the raw materials for the calculation that the function will do. -When there is more than one argument, they are separated by commas. If -there are no arguments, write just @samp{()} after the function name. -Here are some examples: - -@example -sqrt(x^2 + y^2) # @r{One argument} -atan2(y, x) # @r{Two arguments} -rand() # @r{No arguments} -@end example - -@strong{Do not put any space between the function name and the -open-parenthesis!} A user-defined function name looks just like the name of -a variable, and space would make the expression look like concatenation -of a variable with an expression inside parentheses. Space before the -parenthesis is harmless with built-in functions, but it is best not to get -into the habit of using space to avoid mistakes with user-defined -functions. - -Each function expects a particular number of arguments. For example, the -@code{sqrt} function must be called with a single argument, the number -to take the square root of: - -@example -sqrt(@var{argument}) -@end example - -Some of the built-in functions allow you to omit the final argument. -If you do so, they use a reasonable default. -@xref{Built-in, ,Built-in Functions}, for full details. If arguments -are omitted in calls to user-defined functions, then those arguments are -treated as local variables, initialized to the null string -(@pxref{User-defined, ,User-defined Functions}).@refill - -Like every other expression, the function call has a value, which is -computed by the function based on the arguments you give it. In this -example, the value of @code{sqrt(@var{argument})} is the square root of the -argument. A function can also have side effects, such as assigning the -values of certain variables or doing I/O. - -Here is a command to read numbers, one number per line, and print the -square root of each one: - -@example -awk '@{ print "The square root of", $1, "is", sqrt($1) @}' -@end example - -@node Precedence, , Function Calls, Expressions -@section Operator Precedence (How Operators Nest) -@cindex precedence -@cindex operator precedence - -@dfn{Operator precedence} determines how operators are grouped, when -different operators appear close by in one expression. For example, -@samp{*} has higher precedence than @samp{+}; thus, @code{a + b * c} -means to multiply @code{b} and @code{c}, and then add @code{a} to the -product (i.e., @code{a + (b * c)}). - -You can overrule the precedence of the operators by using parentheses. -You can think of the precedence rules as saying where the -parentheses are assumed if you do not write parentheses yourself. In -fact, it is wise to always use parentheses whenever you have an unusual -combination of operators, because other people who read the program may -not remember what the precedence is in this case. You might forget, -too; then you could make a mistake. Explicit parentheses will help prevent -any such mistake. - -When operators of equal precedence are used together, the leftmost -operator groups first, except for the assignment, conditional and -exponentiation operators, which group in the opposite order. -Thus, @code{a - b + c} groups as @code{(a - b) + c}; -@code{a = b = c} groups as @code{a = (b = c)}.@refill - -The precedence of prefix unary operators does not matter as long as only -unary operators are involved, because there is only one way to parse -them---innermost first. Thus, @code{$++i} means @code{$(++i)} and -@code{++$x} means @code{++($x)}. However, when another operator follows -the operand, then the precedence of the unary operators can matter. -Thus, @code{$x^2} means @code{($x)^2}, but @code{-x^2} means -@code{-(x^2)}, because @samp{-} has lower precedence than @samp{^} -while @samp{$} has higher precedence. - -Here is a table of the operators of @code{awk}, in order of increasing -precedence: - -@table @asis -@item assignment -@samp{=}, @samp{+=}, @samp{-=}, @samp{*=}, @samp{/=}, @samp{%=}, -@samp{^=}, @samp{**=}. These operators group right-to-left. -(The @samp{**=} operator is not specified by @sc{posix}.) - -@item conditional -@samp{?:}. This operator groups right-to-left. - -@item logical ``or''. -@samp{||}. - -@item logical ``and''. -@samp{&&}. - -@item array membership -@samp{in}. - -@item matching -@samp{~}, @samp{!~}. - -@item relational, and redirection -The relational operators and the redirections have the same precedence -level. Characters such as @samp{>} serve both as relationals and as -redirections; the context distinguishes between the two meanings. - -The relational operators are @samp{<}, @samp{<=}, @samp{==}, @samp{!=}, -@samp{>=} and @samp{>}. - -The I/O redirection operators are @samp{<}, @samp{>}, @samp{>>} and -@samp{|}. - -Note that I/O redirection operators in @code{print} and @code{printf} -statements belong to the statement level, not to expressions. The -redirection does not produce an expression which could be the operand of -another operator. As a result, it does not make sense to use a -redirection operator near another operator of lower precedence, without -parentheses. Such combinations, for example @samp{print foo > a ? b : -c}, result in syntax errors. - -@item concatenation -No special token is used to indicate concatenation. -The operands are simply written side by side. - -@item add, subtract -@samp{+}, @samp{-}. - -@item multiply, divide, mod -@samp{*}, @samp{/}, @samp{%}. - -@item unary plus, minus, ``not'' -@samp{+}, @samp{-}, @samp{!}. - -@item exponentiation -@samp{^}, @samp{**}. These operators group right-to-left. -(The @samp{**} operator is not specified by @sc{posix}.) - -@item increment, decrement -@samp{++}, @samp{--}. - -@item field -@samp{$}. -@end table - -@node Statements, Arrays, Expressions, Top -@chapter Control Statements in Actions -@cindex control statement - -@dfn{Control statements} such as @code{if}, @code{while}, and so on -control the flow of execution in @code{awk} programs. Most of the -control statements in @code{awk} are patterned on similar statements in -C. - -All the control statements start with special keywords such as @code{if} -and @code{while}, to distinguish them from simple expressions. - -Many control statements contain other statements; for example, the -@code{if} statement contains another statement which may or may not be -executed. The contained statement is called the @dfn{body}. If you -want to include more than one statement in the body, group them into a -single compound statement with curly braces, separating them with -newlines or semicolons. - -@menu -* If Statement:: Conditionally execute - some @code{awk} statements. -* While Statement:: Loop until some condition is satisfied. -* Do Statement:: Do specified action while looping until some - condition is satisfied. -* For Statement:: Another looping statement, that provides - initialization and increment clauses. -* Break Statement:: Immediately exit the innermost enclosing loop. -* Continue Statement:: Skip to the end of the innermost - enclosing loop. -* Next Statement:: Stop processing the current input record. -* Next File Statement:: Stop processing the current file. -* Exit Statement:: Stop execution of @code{awk}. -@end menu - -@node If Statement, While Statement, Statements, Statements -@section The @code{if} Statement - -@cindex @code{if} statement -The @code{if}-@code{else} statement is @code{awk}'s decision-making -statement. It looks like this:@refill - -@example -if (@var{condition}) @var{then-body} @r{[}else @var{else-body}@r{]} -@end example - -@noindent -@var{condition} is an expression that controls what the rest of the -statement will do. If @var{condition} is true, @var{then-body} is -executed; otherwise, @var{else-body} is executed (assuming that the -@code{else} clause is present). The @code{else} part of the statement is -optional. The condition is considered false if its value is zero or -the null string, and true otherwise.@refill - -Here is an example: - -@example -if (x % 2 == 0) - print "x is even" -else - print "x is odd" -@end example - -In this example, if the expression @code{x % 2 == 0} is true (that is, -the value of @code{x} is divisible by 2), then the first @code{print} -statement is executed, otherwise the second @code{print} statement is -performed.@refill - -If the @code{else} appears on the same line as @var{then-body}, and -@var{then-body} is not a compound statement (i.e., not surrounded by -curly braces), then a semicolon must separate @var{then-body} from -@code{else}. To illustrate this, let's rewrite the previous example: - -@example -awk '@{ if (x % 2 == 0) print "x is even"; else - print "x is odd" @}' -@end example - -@noindent -If you forget the @samp{;}, @code{awk} won't be able to parse the -statement, and you will get a syntax error. - -We would not actually write this example this way, because a human -reader might fail to see the @code{else} if it were not the first thing -on its line. - -@node While Statement, Do Statement, If Statement, Statements -@section The @code{while} Statement -@cindex @code{while} statement -@cindex loop -@cindex body of a loop - -In programming, a @dfn{loop} means a part of a program that is (or at least can -be) executed two or more times in succession. - -The @code{while} statement is the simplest looping statement in -@code{awk}. It repeatedly executes a statement as long as a condition is -true. It looks like this: - -@example -while (@var{condition}) - @var{body} -@end example - -@noindent -Here @var{body} is a statement that we call the @dfn{body} of the loop, -and @var{condition} is an expression that controls how long the loop -keeps running. - -The first thing the @code{while} statement does is test @var{condition}. -If @var{condition} is true, it executes the statement @var{body}. -(@var{condition} is true when the value -is not zero and not a null string.) After @var{body} has been executed, -@var{condition} is tested again, and if it is still true, @var{body} is -executed again. This process repeats until @var{condition} is no longer -true. If @var{condition} is initially false, the body of the loop is -never executed.@refill - -This example prints the first three fields of each record, one per line. - -@example -awk '@{ i = 1 - while (i <= 3) @{ - print $i - i++ - @} -@}' -@end example - -@noindent -Here the body of the loop is a compound statement enclosed in braces, -containing two statements. - -The loop works like this: first, the value of @code{i} is set to 1. -Then, the @code{while} tests whether @code{i} is less than or equal to -three. This is the case when @code{i} equals one, so the @code{i}-th -field is printed. Then the @code{i++} increments the value of @code{i} -and the loop repeats. The loop terminates when @code{i} reaches 4. - -As you can see, a newline is not required between the condition and the -body; but using one makes the program clearer unless the body is a -compound statement or is very simple. The newline after the open-brace -that begins the compound statement is not required either, but the -program would be hard to read without it. - -@node Do Statement, For Statement, While Statement, Statements -@section The @code{do}-@code{while} Statement - -The @code{do} loop is a variation of the @code{while} looping statement. -The @code{do} loop executes the @var{body} once, then repeats @var{body} -as long as @var{condition} is true. It looks like this: - -@example -do - @var{body} -while (@var{condition}) -@end example - -Even if @var{condition} is false at the start, @var{body} is executed at -least once (and only once, unless executing @var{body} makes -@var{condition} true). Contrast this with the corresponding -@code{while} statement: - -@example -while (@var{condition}) - @var{body} -@end example - -@noindent -This statement does not execute @var{body} even once if @var{condition} -is false to begin with. - -Here is an example of a @code{do} statement: - -@example -awk '@{ i = 1 - do @{ - print $0 - i++ - @} while (i <= 10) -@}' -@end example - -@noindent -prints each input record ten times. It isn't a very realistic example, -since in this case an ordinary @code{while} would do just as well. But -this reflects actual experience; there is only occasionally a real use -for a @code{do} statement.@refill - -@node For Statement, Break Statement, Do Statement, Statements -@section The @code{for} Statement -@cindex @code{for} statement - -The @code{for} statement makes it more convenient to count iterations of a -loop. The general form of the @code{for} statement looks like this:@refill - -@example -for (@var{initialization}; @var{condition}; @var{increment}) - @var{body} -@end example - -@noindent -This statement starts by executing @var{initialization}. Then, as long -as @var{condition} is true, it repeatedly executes @var{body} and then -@var{increment}. Typically @var{initialization} sets a variable to -either zero or one, @var{increment} adds 1 to it, and @var{condition} -compares it against the desired number of iterations. - -Here is an example of a @code{for} statement: - -@example -@group -awk '@{ for (i = 1; i <= 3; i++) - print $i -@}' -@end group -@end example - -@noindent -This prints the first three fields of each input record, one field per -line. - -In the @code{for} statement, @var{body} stands for any statement, but -@var{initialization}, @var{condition} and @var{increment} are just -expressions. You cannot set more than one variable in the -@var{initialization} part unless you use a multiple assignment statement -such as @code{x = y = 0}, which is possible only if all the initial values -are equal. (But you can initialize additional variables by writing -their assignments as separate statements preceding the @code{for} loop.) - -The same is true of the @var{increment} part; to increment additional -variables, you must write separate statements at the end of the loop. -The C compound expression, using C's comma operator, would be useful in -this context, but it is not supported in @code{awk}. - -Most often, @var{increment} is an increment expression, as in the -example above. But this is not required; it can be any expression -whatever. For example, this statement prints all the powers of 2 -between 1 and 100: - -@example -for (i = 1; i <= 100; i *= 2) - print i -@end example - -Any of the three expressions in the parentheses following the @code{for} may -be omitted if there is nothing to be done there. Thus, @w{@samp{for (;x -> 0;)}} is equivalent to @w{@samp{while (x > 0)}}. If the -@var{condition} is omitted, it is treated as @var{true}, effectively -yielding an @dfn{infinite loop} (i.e., a loop that will never -terminate).@refill - -In most cases, a @code{for} loop is an abbreviation for a @code{while} -loop, as shown here: - -@example -@var{initialization} -while (@var{condition}) @{ - @var{body} - @var{increment} -@} -@end example - -@noindent -The only exception is when the @code{continue} statement -(@pxref{Continue Statement, ,The @code{continue} Statement}) is used -inside the loop; changing a @code{for} statement to a @code{while} -statement in this way can change the effect of the @code{continue} -statement inside the loop.@refill - -There is an alternate version of the @code{for} loop, for iterating over -all the indices of an array: - -@example -for (i in array) - @var{do something with} array[i] -@end example - -@noindent -@xref{Arrays, ,Arrays in @code{awk}}, for more information on this -version of the @code{for} loop. - -The @code{awk} language has a @code{for} statement in addition to a -@code{while} statement because often a @code{for} loop is both less work to -type and more natural to think of. Counting the number of iterations is -very common in loops. It can be easier to think of this counting as part -of looping rather than as something to do inside the loop. - -The next section has more complicated examples of @code{for} loops. - -@node Break Statement, Continue Statement, For Statement, Statements -@section The @code{break} Statement -@cindex @code{break} statement -@cindex loops, exiting - -The @code{break} statement jumps out of the innermost @code{for}, -@code{while}, or @code{do}-@code{while} loop that encloses it. The -following example finds the smallest divisor of any integer, and also -identifies prime numbers:@refill - -@smallexample -awk '# find smallest divisor of num - @{ num = $1 - for (div = 2; div*div <= num; div++) - if (num % div == 0) - break - if (num % div == 0) - printf "Smallest divisor of %d is %d\n", num, div - else - printf "%d is prime\n", num @}' -@end smallexample - -When the remainder is zero in the first @code{if} statement, @code{awk} -immediately @dfn{breaks out} of the containing @code{for} loop. This means -that @code{awk} proceeds immediately to the statement following the loop -and continues processing. (This is very different from the @code{exit} -statement which stops the entire @code{awk} program. -@xref{Exit Statement, ,The @code{exit} Statement}.)@refill - -Here is another program equivalent to the previous one. It illustrates how -the @var{condition} of a @code{for} or @code{while} could just as well be -replaced with a @code{break} inside an @code{if}: - -@smallexample -@group -awk '# find smallest divisor of num - @{ num = $1 - for (div = 2; ; div++) @{ - if (num % div == 0) @{ - printf "Smallest divisor of %d is %d\n", num, div - break - @} - if (div*div > num) @{ - printf "%d is prime\n", num - break - @} - @} -@}' -@end group -@end smallexample - -@node Continue Statement, Next Statement, Break Statement, Statements -@section The @code{continue} Statement - -@cindex @code{continue} statement -The @code{continue} statement, like @code{break}, is used only inside -@code{for}, @code{while}, and @code{do}-@code{while} loops. It skips -over the rest of the loop body, causing the next cycle around the loop -to begin immediately. Contrast this with @code{break}, which jumps out -of the loop altogether. Here is an example:@refill - -@example -# print names that don't contain the string "ignore" - -# first, save the text of each line -@{ names[NR] = $0 @} - -# print what we're interested in -END @{ - for (x in names) @{ - if (names[x] ~ /ignore/) - continue - print names[x] - @} -@} -@end example - -If one of the input records contains the string @samp{ignore}, this -example skips the print statement for that record, and continues back to -the first statement in the loop. - -This is not a practical example of @code{continue}, since it would be -just as easy to write the loop like this: - -@example -for (x in names) - if (names[x] !~ /ignore/) - print names[x] -@end example - -@ignore -from brennan@boeing.com: - -page 90, section 9.6. The example is too artificial as -the one line program - - !/ignore/ - -does the same thing. -@end ignore -@c ADR --- he's right, but don't worry about this for now - -The @code{continue} statement in a @code{for} loop directs @code{awk} to -skip the rest of the body of the loop, and resume execution with the -increment-expression of the @code{for} statement. The following program -illustrates this fact:@refill - -@example -awk 'BEGIN @{ - for (x = 0; x <= 20; x++) @{ - if (x == 5) - continue - printf ("%d ", x) - @} - print "" -@}' -@end example - -@noindent -This program prints all the numbers from 0 to 20, except for 5, for -which the @code{printf} is skipped. Since the increment @code{x++} -is not skipped, @code{x} does not remain stuck at 5. Contrast the -@code{for} loop above with the @code{while} loop: - -@example -awk 'BEGIN @{ - x = 0 - while (x <= 20) @{ - if (x == 5) - continue - printf ("%d ", x) - x++ - @} - print "" -@}' -@end example - -@noindent -This program loops forever once @code{x} gets to 5. - -As described above, the @code{continue} statement has no meaning when -used outside the body of a loop. However, although it was never documented, -historical implementations of @code{awk} have treated the @code{continue} -statement outside of a loop as if it were a @code{next} statement -(@pxref{Next Statement, ,The @code{next} Statement}). -By default, @code{gawk} silently supports this usage. However, if -@samp{-W posix} has been specified on the command line -(@pxref{Command Line, ,Invoking @code{awk}}), -it will be treated as an error, since the @sc{posix} standard specifies -that @code{continue} should only be used inside the body of a loop.@refill - -@node Next Statement, Next File Statement, Continue Statement, Statements -@section The @code{next} Statement -@cindex @code{next} statement - -The @code{next} statement forces @code{awk} to immediately stop processing -the current record and go on to the next record. This means that no -further rules are executed for the current record. The rest of the -current rule's action is not executed either. - -Contrast this with the effect of the @code{getline} function -(@pxref{Getline, ,Explicit Input with @code{getline}}). That too causes -@code{awk} to read the next record immediately, but it does not alter the -flow of control in any way. So the rest of the current action executes -with a new input record. - -At the highest level, @code{awk} program execution is a loop that reads -an input record and then tests each rule's pattern against it. If you -think of this loop as a @code{for} statement whose body contains the -rules, then the @code{next} statement is analogous to a @code{continue} -statement: it skips to the end of the body of this implicit loop, and -executes the increment (which reads another record). - -For example, if your @code{awk} program works only on records with four -fields, and you don't want it to fail when given bad input, you might -use this rule near the beginning of the program: - -@smallexample -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields", FNR) > "/dev/stderr" - next -@} -@end smallexample - -@noindent -so that the following rules will not see the bad record. The error -message is redirected to the standard error output stream, as error -messages should be. @xref{Special Files, ,Standard I/O Streams}. - -According to the @sc{posix} standard, the behavior is undefined if -the @code{next} statement is used in a @code{BEGIN} or @code{END} rule. -@code{gawk} will treat it as a syntax error. - -If the @code{next} statement causes the end of the input to be reached, -then the code in the @code{END} rules, if any, will be executed. -@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}. - -@node Next File Statement, Exit Statement, Next Statement, Statements -@section The @code{next file} Statement - -@cindex @code{next file} statement -The @code{next file} statement is similar to the @code{next} statement. -However, instead of abandoning processing of the current record, the -@code{next file} statement instructs @code{awk} to stop processing the -current data file. - -Upon execution of the @code{next file} statement, @code{FILENAME} is -updated to the name of the next data file listed on the command line, -@code{FNR} is reset to 1, and processing starts over with the first -rule in the progam. @xref{Built-in Variables}. - -If the @code{next file} statement causes the end of the input to be reached, -then the code in the @code{END} rules, if any, will be executed. -@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}. - -The @code{next file} statement is a @code{gawk} extension; it is not -(currently) available in any other @code{awk} implementation. You can -simulate its behavior by creating a library file named @file{nextfile.awk}, -with the following contents. (This sample program uses user-defined -functions, a feature that has not been presented yet. -@xref{User-defined, ,User-defined Functions}, -for more information.)@refill - -@smallexample -# nextfile --- function to skip remaining records in current file - -# this should be read in before the "main" awk program - -function nextfile() @{ _abandon_ = FILENAME; next @} - -_abandon_ == FILENAME && FNR > 1 @{ next @} -_abandon_ == FILENAME && FNR == 1 @{ _abandon_ = "" @} -@end smallexample - -The @code{nextfile} function simply sets a ``private'' variable@footnote{Since -all variables in @code{awk} are global, this program uses the common -practice of prefixing the variable name with an underscore. In fact, it -also suffixes the variable name with an underscore, as extra insurance -against using a variable name that might be used in some other library -file.} to the name of the current data file, and then retrieves the next -record. Since this file is read before the main @code{awk} program, -the rules that follows the function definition will be executed before the -rules in the main program. The first rule continues to skip records as long as -the name of the input file has not changed, and this is not the first -record in the file. This rule is sufficient most of the time. But what if -the @emph{same} data file is named twice in a row on the command line? -This rule would not process the data file the second time. The second rule -catches this case: If the data file name is what was being skipped, but -@code{FNR} is 1, then this is the second time the file is being processed, -and it should not be skipped. - -The @code{next file} statement would be useful if you have many data -files to process, and due to the nature of the data, you expect that you -would not want to process every record in the file. In order to move on to -the next data file, you would have to continue scanning the unwanted -records (as described above). The @code{next file} statement accomplishes -this much more efficiently. - -@ignore -Would it make sense down the road to nuke `next file' in favor of -semantics that would make this work? - - function nextfile() { ARGIND++ ; next } -@end ignore - -@node Exit Statement, , Next File Statement, Statements -@section The @code{exit} Statement - -@cindex @code{exit} statement -The @code{exit} statement causes @code{awk} to immediately stop -executing the current rule and to stop processing input; any remaining input -is ignored.@refill - -If an @code{exit} statement is executed from a @code{BEGIN} rule the -program stops processing everything immediately. No input records are -read. However, if an @code{END} rule is present, it is executed -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). - -If @code{exit} is used as part of an @code{END} rule, it causes -the program to stop immediately. - -An @code{exit} statement that is part of an ordinary rule (that is, not part -of a @code{BEGIN} or @code{END} rule) stops the execution of any further -automatic rules, but the @code{END} rule is executed if there is one. -If you do not want the @code{END} rule to do its job in this case, you -can set a variable to nonzero before the @code{exit} statement, and check -that variable in the @code{END} rule. - -If an argument is supplied to @code{exit}, its value is used as the exit -status code for the @code{awk} process. If no argument is supplied, -@code{exit} returns status zero (success).@refill - -For example, let's say you've discovered an error condition you really -don't know how to handle. Conventionally, programs report this by -exiting with a nonzero status. Your @code{awk} program can do this -using an @code{exit} statement with a nonzero argument. Here's an -example of this:@refill - -@example -@group -BEGIN @{ - if (("date" | getline date_now) < 0) @{ - print "Can't get system date" > "/dev/stderr" - exit 4 - @} -@} -@end group -@end example - -@node Arrays, Built-in, Statements, Top -@chapter Arrays in @code{awk} - -An @dfn{array} is a table of values, called @dfn{elements}. The -elements of an array are distinguished by their indices. @dfn{Indices} -may be either numbers or strings. Each array has a name, which looks -like a variable name, but must not be in use as a variable name in the -same @code{awk} program. - -@menu -* Array Intro:: Introduction to Arrays -* Reference to Elements:: How to examine one element of an array. -* Assigning Elements:: How to change an element of an array. -* Array Example:: Basic Example of an Array -* Scanning an Array:: A variation of the @code{for} statement. - It loops through the indices of - an array's existing elements. -* Delete:: The @code{delete} statement removes - an element from an array. -* Numeric Array Subscripts:: How to use numbers as subscripts in @code{awk}. -* Multi-dimensional:: Emulating multi-dimensional arrays in @code{awk}. -* Multi-scanning:: Scanning multi-dimensional arrays. -@end menu - -@node Array Intro, Reference to Elements, Arrays, Arrays -@section Introduction to Arrays - -@cindex arrays -The @code{awk} language has one-dimensional @dfn{arrays} for storing groups -of related strings or numbers. - -Every @code{awk} array must have a name. Array names have the same -syntax as variable names; any valid variable name would also be a valid -array name. But you cannot use one name in both ways (as an array and -as a variable) in one @code{awk} program. - -Arrays in @code{awk} superficially resemble arrays in other programming -languages; but there are fundamental differences. In @code{awk}, you -don't need to specify the size of an array before you start to use it. -Additionally, any number or string in @code{awk} may be used as an -array index. - -In most other languages, you have to @dfn{declare} an array and specify -how many elements or components it contains. In such languages, the -declaration causes a contiguous block of memory to be allocated for that -many elements. An index in the array must be a positive integer; for -example, the index 0 specifies the first element in the array, which is -actually stored at the beginning of the block of memory. Index 1 -specifies the second element, which is stored in memory right after the -first element, and so on. It is impossible to add more elements to the -array, because it has room for only as many elements as you declared. - -A contiguous array of four elements might look like this, -conceptually, if the element values are @code{8}, @code{"foo"}, -@code{""} and @code{30}:@refill - -@example -+---------+---------+--------+---------+ -| 8 | "foo" | "" | 30 | @r{value} -+---------+---------+--------+---------+ - 0 1 2 3 @r{index} -@end example - -@noindent -Only the values are stored; the indices are implicit from the order of -the values. @code{8} is the value at index 0, because @code{8} appears in the -position with 0 elements before it. - -@cindex arrays, definition of -@cindex associative arrays -Arrays in @code{awk} are different: they are @dfn{associative}. This means -that each array is a collection of pairs: an index, and its corresponding -array element value: - -@example -@r{Element} 4 @r{Value} 30 -@r{Element} 2 @r{Value} "foo" -@r{Element} 1 @r{Value} 8 -@r{Element} 3 @r{Value} "" -@end example - -@noindent -We have shown the pairs in jumbled order because their order is irrelevant. - -One advantage of an associative array is that new pairs can be added -at any time. For example, suppose we add to the above array a tenth element -whose value is @w{@code{"number ten"}}. The result is this: - -@example -@r{Element} 10 @r{Value} "number ten" -@r{Element} 4 @r{Value} 30 -@r{Element} 2 @r{Value} "foo" -@r{Element} 1 @r{Value} 8 -@r{Element} 3 @r{Value} "" -@end example - -@noindent -Now the array is @dfn{sparse} (i.e., some indices are missing): it has -elements 1--4 and 10, but doesn't have elements 5, 6, 7, 8, or 9.@refill - -Another consequence of associative arrays is that the indices don't -have to be positive integers. Any number, or even a string, can be -an index. For example, here is an array which translates words from -English into French: - -@example -@r{Element} "dog" @r{Value} "chien" -@r{Element} "cat" @r{Value} "chat" -@r{Element} "one" @r{Value} "un" -@r{Element} 1 @r{Value} "un" -@end example - -@noindent -Here we decided to translate the number 1 in both spelled-out and -numeric form---thus illustrating that a single array can have both -numbers and strings as indices. - -When @code{awk} creates an array for you, e.g., with the @code{split} -built-in function, -that array's indices are consecutive integers starting at 1. -(@xref{String Functions, ,Built-in Functions for String Manipulation}.) - -@node Reference to Elements, Assigning Elements, Array Intro, Arrays -@section Referring to an Array Element -@cindex array reference -@cindex element of array -@cindex reference to array - -The principal way of using an array is to refer to one of its elements. -An array reference is an expression which looks like this: - -@example -@var{array}[@var{index}] -@end example - -@noindent -Here, @var{array} is the name of an array. The expression @var{index} is -the index of the element of the array that you want. - -The value of the array reference is the current value of that array -element. For example, @code{foo[4.3]} is an expression for the element -of array @code{foo} at index 4.3. - -If you refer to an array element that has no recorded value, the value -of the reference is @code{""}, the null string. This includes elements -to which you have not assigned any value, and elements that have been -deleted (@pxref{Delete, ,The @code{delete} Statement}). Such a reference -automatically creates that array element, with the null string as its value. -(In some cases, this is unfortunate, because it might waste memory inside -@code{awk}). - -@cindex arrays, presence of elements -You can find out if an element exists in an array at a certain index with -the expression: - -@example -@var{index} in @var{array} -@end example - -@noindent -This expression tests whether or not the particular index exists, -without the side effect of creating that element if it is not present. -The expression has the value 1 (true) if @code{@var{array}[@var{index}]} -exists, and 0 (false) if it does not exist.@refill - -For example, to test whether the array @code{frequencies} contains the -index @code{"2"}, you could write this statement:@refill - -@smallexample -if ("2" in frequencies) print "Subscript \"2\" is present." -@end smallexample - -Note that this is @emph{not} a test of whether or not the array -@code{frequencies} contains an element whose @emph{value} is @code{"2"}. -(There is no way to do that except to scan all the elements.) Also, this -@emph{does not} create @code{frequencies["2"]}, while the following -(incorrect) alternative would do so:@refill - -@smallexample -if (frequencies["2"] != "") print "Subscript \"2\" is present." -@end smallexample - -@node Assigning Elements, Array Example, Reference to Elements, Arrays -@section Assigning Array Elements -@cindex array assignment -@cindex element assignment - -Array elements are lvalues: they can be assigned values just like -@code{awk} variables: - -@example -@var{array}[@var{subscript}] = @var{value} -@end example - -@noindent -Here @var{array} is the name of your array. The expression -@var{subscript} is the index of the element of the array that you want -to assign a value. The expression @var{value} is the value you are -assigning to that element of the array.@refill - -@node Array Example, Scanning an Array, Assigning Elements, Arrays -@section Basic Example of an Array - -The following program takes a list of lines, each beginning with a line -number, and prints them out in order of line number. The line numbers are -not in order, however, when they are first read: they are scrambled. This -program sorts the lines by making an array using the line numbers as -subscripts. It then prints out the lines in sorted order of their numbers. -It is a very simple program, and gets confused if it encounters repeated -numbers, gaps, or lines that don't begin with a number.@refill - -@example -@{ - if ($1 > max) - max = $1 - arr[$1] = $0 -@} - -END @{ - for (x = 1; x <= max; x++) - print arr[x] -@} -@end example - -The first rule keeps track of the largest line number seen so far; -it also stores each line into the array @code{arr}, at an index that -is the line's number. - -The second rule runs after all the input has been read, to print out -all the lines. - -When this program is run with the following input: - -@example -5 I am the Five man -2 Who are you? The new number two! -4 . . . And four on the floor -1 Who is number one? -3 I three you. -@end example - -@noindent -its output is this: - -@example -1 Who is number one? -2 Who are you? The new number two! -3 I three you. -4 . . . And four on the floor -5 I am the Five man -@end example - -If a line number is repeated, the last line with a given number overrides -the others. - -Gaps in the line numbers can be handled with an easy improvement to the -program's @code{END} rule: - -@example -END @{ - for (x = 1; x <= max; x++) - if (x in arr) - print arr[x] -@} -@end example - -@node Scanning an Array, Delete, Array Example, Arrays -@section Scanning all Elements of an Array -@cindex @code{for (x in @dots{})} -@cindex arrays, special @code{for} statement -@cindex scanning an array - -In programs that use arrays, often you need a loop that executes -once for each element of an array. In other languages, where arrays are -contiguous and indices are limited to positive integers, this is -easy: the largest index is one less than the length of the array, and you can -find all the valid indices by counting from zero up to that value. This -technique won't do the job in @code{awk}, since any number or string -may be an array index. So @code{awk} has a special kind of @code{for} -statement for scanning an array: - -@example -for (@var{var} in @var{array}) - @var{body} -@end example - -@noindent -This loop executes @var{body} once for each different value that your -program has previously used as an index in @var{array}, with the -variable @var{var} set to that index.@refill - -Here is a program that uses this form of the @code{for} statement. The -first rule scans the input records and notes which words appear (at -least once) in the input, by storing a 1 into the array @code{used} with -the word as index. The second rule scans the elements of @code{used} to -find all the distinct words that appear in the input. It prints each -word that is more than 10 characters long, and also prints the number of -such words. @xref{Built-in, ,Built-in Functions}, for more information -on the built-in function @code{length}. - -@smallexample -# Record a 1 for each word that is used at least once. -@{ - for (i = 1; i <= NF; i++) - used[$i] = 1 -@} - -# Find number of distinct words more than 10 characters long. -END @{ - for (x in used) - if (length(x) > 10) @{ - ++num_long_words - print x - @} - print num_long_words, "words longer than 10 characters" -@} -@end smallexample - -@noindent -@xref{Sample Program}, for a more detailed example of this type. - -The order in which elements of the array are accessed by this statement -is determined by the internal arrangement of the array elements within -@code{awk} and cannot be controlled or changed. This can lead to -problems if new elements are added to @var{array} by statements in -@var{body}; you cannot predict whether or not the @code{for} loop will -reach them. Similarly, changing @var{var} inside the loop can produce -strange results. It is best to avoid such things.@refill - -@node Delete, Numeric Array Subscripts, Scanning an Array, Arrays -@section The @code{delete} Statement -@cindex @code{delete} statement -@cindex deleting elements of arrays -@cindex removing elements of arrays -@cindex arrays, deleting an element - -You can remove an individual element of an array using the @code{delete} -statement: - -@example -delete @var{array}[@var{index}] -@end example - -You can not refer to an array element after it has been deleted; -it is as if you had never referred -to it and had never given it any value. You can no longer obtain any -value the element once had. - -Here is an example of deleting elements in an array: - -@example -for (i in frequencies) - delete frequencies[i] -@end example - -@noindent -This example removes all the elements from the array @code{frequencies}. - -If you delete an element, a subsequent @code{for} statement to scan the array -will not report that element, and the @code{in} operator to check for -the presence of that element will return 0: - -@example -delete foo[4] -if (4 in foo) - print "This will never be printed" -@end example - -It is not an error to delete an element which does not exist. - -@node Numeric Array Subscripts, Multi-dimensional, Delete, Arrays -@section Using Numbers to Subscript Arrays - -An important aspect of arrays to remember is that array subscripts -are @emph{always} strings. If you use a numeric value as a subscript, -it will be converted to a string value before it is used for subscripting -(@pxref{Conversion, ,Conversion of Strings and Numbers}). - -@cindex conversions, during subscripting -@cindex numbers, used as subscripts -@vindex CONVFMT -This means that the value of the @code{CONVFMT} can potentially -affect how your program accesses elements of an array. For example: - -@example -a = b = 12.153 -data[a] = 1 -CONVFMT = "%2.2f" -if (b in data) - printf "%s is in data", b -else - printf "%s is not in data", b -@end example - -@noindent -should print @samp{12.15 is not in data}. The first statement gives -both @code{a} and @code{b} the same numeric value. Assigning to -@code{data[a]} first gives @code{a} the string value @code{"12.153"} -(using the default conversion value of @code{CONVFMT}, @code{"%.6g"}), -and then assigns 1 to @code{data["12.153"]}. The program then changes -the value of @code{CONVFMT}. The test @samp{(b in data)} forces @code{b} -to be converted to a string, this time @code{"12.15"}, since the value of -@code{CONVFMT} only allows two significant digits. This test fails, -since @code{"12.15"} is a different string from @code{"12.153"}.@refill - -According to the rules for conversions -(@pxref{Conversion, ,Conversion of Strings and Numbers}), integer -values are always converted to strings as integers, no matter what the -value of @code{CONVFMT} may happen to be. So the usual case of@refill - -@example -for (i = 1; i <= maxsub; i++) - @i{do something with} array[i] -@end example - -@noindent -will work, no matter what the value of @code{CONVFMT}. - -Like many things in @code{awk}, the majority of the time things work -as you would expect them to work. But it is useful to have a precise -knowledge of the actual rules, since sometimes they can have a subtle -effect on your programs. - -@node Multi-dimensional, Multi-scanning, Numeric Array Subscripts, Arrays -@section Multi-dimensional Arrays - -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex subscripts in arrays -@cindex arrays, multi-dimensional subscripts -@cindex multi-dimensional subscripts -A multi-dimensional array is an array in which an element is identified -by a sequence of indices, not a single index. For example, a -two-dimensional array requires two indices. The usual way (in most -languages, including @code{awk}) to refer to an element of a -two-dimensional array named @code{grid} is with -@code{grid[@var{x},@var{y}]}. - -@vindex SUBSEP -Multi-dimensional arrays are supported in @code{awk} through -concatenation of indices into one string. What happens is that -@code{awk} converts the indices into strings -(@pxref{Conversion, ,Conversion of Strings and Numbers}) and -concatenates them together, with a separator between them. This creates -a single string that describes the values of the separate indices. The -combined string is used as a single index into an ordinary, -one-dimensional array. The separator used is the value of the built-in -variable @code{SUBSEP}.@refill - -For example, suppose we evaluate the expression @code{foo[5,12]="value"} -when the value of @code{SUBSEP} is @code{"@@"}. The numbers 5 and 12 are -converted to strings and -concatenated with an @samp{@@} between them, yielding @code{"5@@12"}; thus, -the array element @code{foo["5@@12"]} is set to @code{"value"}.@refill - -Once the element's value is stored, @code{awk} has no record of whether -it was stored with a single index or a sequence of indices. The two -expressions @code{foo[5,12]} and @w{@code{foo[5 SUBSEP 12]}} always have -the same value. - -The default value of @code{SUBSEP} is the string @code{"\034"}, -which contains a nonprinting character that is unlikely to appear in an -@code{awk} program or in the input data. - -The usefulness of choosing an unlikely character comes from the fact -that index values that contain a string matching @code{SUBSEP} lead to -combined strings that are ambiguous. Suppose that @code{SUBSEP} were -@code{"@@"}; then @w{@code{foo["a@@b", "c"]}} and @w{@code{foo["a", -"b@@c"]}} would be indistinguishable because both would actually be -stored as @code{foo["a@@b@@c"]}. Because @code{SUBSEP} is -@code{"\034"}, such confusion can arise only when an index -contains the character with ASCII code 034, which is a rare -event.@refill - -You can test whether a particular index-sequence exists in a -``multi-dimensional'' array with the same operator @code{in} used for single -dimensional arrays. Instead of a single index as the left-hand operand, -write the whole sequence of indices, separated by commas, in -parentheses:@refill - -@example -(@var{subscript1}, @var{subscript2}, @dots{}) in @var{array} -@end example - -The following example treats its input as a two-dimensional array of -fields; it rotates this array 90 degrees clockwise and prints the -result. It assumes that all lines have the same number of -elements. - -@example -awk '@{ - if (max_nf < NF) - max_nf = NF - max_nr = NR - for (x = 1; x <= NF; x++) - vector[x, NR] = $x -@} - -END @{ - for (x = 1; x <= max_nf; x++) @{ - for (y = max_nr; y >= 1; --y) - printf("%s ", vector[x, y]) - printf("\n") - @} -@}' -@end example - -@noindent -When given the input: - -@example -@group -1 2 3 4 5 6 -2 3 4 5 6 1 -3 4 5 6 1 2 -4 5 6 1 2 3 -@end group -@end example - -@noindent -it produces: - -@example -@group -4 3 2 1 -5 4 3 2 -6 5 4 3 -1 6 5 4 -2 1 6 5 -3 2 1 6 -@end group -@end example - -@node Multi-scanning, , Multi-dimensional, Arrays -@section Scanning Multi-dimensional Arrays - -There is no special @code{for} statement for scanning a -``multi-dimensional'' array; there cannot be one, because in truth there -are no multi-dimensional arrays or elements; there is only a -multi-dimensional @emph{way of accessing} an array. - -However, if your program has an array that is always accessed as -multi-dimensional, you can get the effect of scanning it by combining -the scanning @code{for} statement -(@pxref{Scanning an Array, ,Scanning all Elements of an Array}) with the -@code{split} built-in function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -It works like this:@refill - -@example -for (combined in @var{array}) @{ - split(combined, separate, SUBSEP) - @dots{} -@} -@end example - -@noindent -This finds each concatenated, combined index in the array, and splits it -into the individual indices by breaking it apart where the value of -@code{SUBSEP} appears. The split-out indices become the elements of -the array @code{separate}. - -Thus, suppose you have previously stored in @code{@var{array}[1, -"foo"]}; then an element with index @code{"1\034foo"} exists in -@var{array}. (Recall that the default value of @code{SUBSEP} contains -the character with code 034.) Sooner or later the @code{for} statement -will find that index and do an iteration with @code{combined} set to -@code{"1\034foo"}. Then the @code{split} function is called as -follows: - -@example -split("1\034foo", separate, "\034") -@end example - -@noindent -The result of this is to set @code{separate[1]} to 1 and @code{separate[2]} -to @code{"foo"}. Presto, the original sequence of separate indices has -been recovered. - -@node Built-in, User-defined, Arrays, Top -@chapter Built-in Functions - -@cindex built-in functions -@dfn{Built-in} functions are functions that are always available for -your @code{awk} program to call. This chapter defines all the built-in -functions in @code{awk}; some of them are mentioned in other sections, -but they are summarized here for your convenience. (You can also define -new functions yourself. @xref{User-defined, ,User-defined Functions}.) - -@menu -* Calling Built-in:: How to call built-in functions. -* Numeric Functions:: Functions that work with numbers, - including @code{int}, @code{sin} and @code{rand}. -* String Functions:: Functions for string manipulation, - such as @code{split}, @code{match}, and @code{sprintf}. -* I/O Functions:: Functions for files and shell commands. -* Time Functions:: Functions for dealing with time stamps. -@end menu - -@node Calling Built-in, Numeric Functions, Built-in, Built-in -@section Calling Built-in Functions - -To call a built-in function, write the name of the function followed -by arguments in parentheses. For example, @code{atan2(y + z, 1)} -is a call to the function @code{atan2}, with two arguments. - -Whitespace is ignored between the built-in function name and the -open-parenthesis, but we recommend that you avoid using whitespace -there. User-defined functions do not permit whitespace in this way, and -you will find it easier to avoid mistakes by following a simple -convention which always works: no whitespace after a function name. - -Each built-in function accepts a certain number of arguments. In most -cases, any extra arguments given to built-in functions are ignored. The -defaults for omitted arguments vary from function to function and are -described under the individual functions. - -When a function is called, expressions that create the function's actual -parameters are evaluated completely before the function call is performed. -For example, in the code fragment: - -@example -i = 4 -j = sqrt(i++) -@end example - -@noindent -the variable @code{i} is set to 5 before @code{sqrt} is called -with a value of 4 for its actual parameter. - -@node Numeric Functions, String Functions, Calling Built-in, Built-in -@section Numeric Built-in Functions -@c I didn't make all the examples small because a couple of them were -@c short already. --mew 29jan1992 - -Here is a full list of built-in functions that work with numbers: - -@table @code -@item int(@var{x}) -This gives you the integer part of @var{x}, truncated toward 0. This -produces the nearest integer to @var{x}, located between @var{x} and 0. - -For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} -is @minus{}3, and @code{int(-3)} is @minus{}3 as well.@refill - -@item sqrt(@var{x}) -This gives you the positive square root of @var{x}. It reports an error -if @var{x} is negative. Thus, @code{sqrt(4)} is 2.@refill - -@item exp(@var{x}) -This gives you the exponential of @var{x}, or reports an error if -@var{x} is out of range. The range of values @var{x} can have depends -on your machine's floating point representation.@refill - -@item log(@var{x}) -This gives you the natural logarithm of @var{x}, if @var{x} is positive; -otherwise, it reports an error.@refill - -@item sin(@var{x}) -This gives you the sine of @var{x}, with @var{x} in radians. - -@item cos(@var{x}) -This gives you the cosine of @var{x}, with @var{x} in radians. - -@item atan2(@var{y}, @var{x}) -This gives you the arctangent of @code{@var{y} / @var{x}} in radians. - -@item rand() -This gives you a random number. The values of @code{rand} are -uniformly-distributed between 0 and 1. The value is never 0 and never -1. - -Often you want random integers instead. Here is a user-defined function -you can use to obtain a random nonnegative integer less than @var{n}: - -@example -function randint(n) @{ - return int(n * rand()) -@} -@end example - -@noindent -The multiplication produces a random real number greater than 0 and less -than @var{n}. We then make it an integer (using @code{int}) between 0 -and @code{@var{n} @minus{} 1}. - -Here is an example where a similar function is used to produce -random integers between 1 and @var{n}. Note that this program will -print a new random number for each input record. - -@smallexample -awk ' -# Function to roll a simulated die. -function roll(n) @{ return 1 + int(rand() * n) @} - -# Roll 3 six-sided dice and print total number of points. -@{ - printf("%d points\n", roll(6)+roll(6)+roll(6)) -@}' -@end smallexample - -@strong{Note:} @code{rand} starts generating numbers from the same -point, or @dfn{seed}, each time you run @code{awk}. This means that -a program will produce the same results each time you run it. -The numbers are random within one @code{awk} run, but predictable -from run to run. This is convenient for debugging, but if you want -a program to do different things each time it is used, you must change -the seed to a value that will be different in each run. To do this, -use @code{srand}. - -@item srand(@var{x}) -The function @code{srand} sets the starting point, or @dfn{seed}, -for generating random numbers to the value @var{x}. - -Each seed value leads to a particular sequence of ``random'' numbers. -Thus, if you set the seed to the same value a second time, you will get -the same sequence of ``random'' numbers again. - -If you omit the argument @var{x}, as in @code{srand()}, then the current -date and time of day are used for a seed. This is the way to get random -numbers that are truly unpredictable. - -The return value of @code{srand} is the previous seed. This makes it -easy to keep track of the seeds for use in consistently reproducing -sequences of random numbers. -@end table - -@node String Functions, I/O Functions, Numeric Functions, Built-in -@section Built-in Functions for String Manipulation - -The functions in this section look at or change the text of one or more -strings. - -@table @code -@item index(@var{in}, @var{find}) -@findex match -This searches the string @var{in} for the first occurrence of the string -@var{find}, and returns the position in characters where that occurrence -begins in the string @var{in}. For example:@refill - -@smallexample -awk 'BEGIN @{ print index("peanut", "an") @}' -@end smallexample - -@noindent -prints @samp{3}. If @var{find} is not found, @code{index} returns 0. -(Remember that string indices in @code{awk} start at 1.) - -@item length(@var{string}) -@findex length -This gives you the number of characters in @var{string}. If -@var{string} is a number, the length of the digit string representing -that number is returned. For example, @code{length("abcde")} is 5. By -contrast, @code{length(15 * 35)} works out to 3. How? Well, 15 * 35 = -525, and 525 is then converted to the string @samp{"525"}, which has -three characters. - -If no argument is supplied, @code{length} returns the length of @code{$0}. - -In older versions of @code{awk}, you could call the @code{length} function -without any parentheses. Doing so is marked as ``deprecated'' in the -@sc{posix} standard. This means that while you can do this in your -programs, it is a feature that can eventually be removed from a future -version of the standard. Therefore, for maximal portability of your -@code{awk} programs you should always supply the parentheses. - -@item match(@var{string}, @var{regexp}) -@findex match -The @code{match} function searches the string, @var{string}, for the -longest, leftmost substring matched by the regular expression, -@var{regexp}. It returns the character position, or @dfn{index}, of -where that substring begins (1, if it starts at the beginning of -@var{string}). If no match if found, it returns 0. - -@vindex RSTART -@vindex RLENGTH -The @code{match} function sets the built-in variable @code{RSTART} to -the index. It also sets the built-in variable @code{RLENGTH} to the -length in characters of the matched substring. If no match is found, -@code{RSTART} is set to 0, and @code{RLENGTH} to @minus{}1. - -For example: - -@smallexample -awk '@{ - if ($1 == "FIND") - regex = $2 - else @{ - where = match($0, regex) - if (where) - print "Match of", regex, "found at", where, "in", $0 - @} -@}' -@end smallexample - -@noindent -This program looks for lines that match the regular expression stored in -the variable @code{regex}. This regular expression can be changed. If the -first word on a line is @samp{FIND}, @code{regex} is changed to be the -second word on that line. Therefore, given: - -@smallexample -FIND fo*bar -My program was a foobar -But none of it would doobar -FIND Melvin -JF+KM -This line is property of The Reality Engineering Co. -This file created by Melvin. -@end smallexample - -@noindent -@code{awk} prints: - -@smallexample -Match of fo*bar found at 18 in My program was a foobar -Match of Melvin found at 26 in This file created by Melvin. -@end smallexample - -@item split(@var{string}, @var{array}, @var{fieldsep}) -@findex split -This divides @var{string} into pieces separated by @var{fieldsep}, -and stores the pieces in @var{array}. The first piece is stored in -@code{@var{array}[1]}, the second piece in @code{@var{array}[2]}, and so -forth. The string value of the third argument, @var{fieldsep}, is -a regexp describing where to split @var{string} (much as @code{FS} can -be a regexp describing where to split input records). If -the @var{fieldsep} is omitted, the value of @code{FS} is used. -@code{split} returns the number of elements created.@refill - -The @code{split} function, then, splits strings into pieces in a -manner similar to the way input lines are split into fields. For example: - -@smallexample -split("auto-da-fe", a, "-") -@end smallexample - -@noindent -splits the string @samp{auto-da-fe} into three fields using @samp{-} as the -separator. It sets the contents of the array @code{a} as follows: - -@smallexample -a[1] = "auto" -a[2] = "da" -a[3] = "fe" -@end smallexample - -@noindent -The value returned by this call to @code{split} is 3. - -As with input field-splitting, when the value of @var{fieldsep} is -@code{" "}, leading and trailing whitespace is ignored, and the elements -are separated by runs of whitespace. - -@item sprintf(@var{format}, @var{expression1},@dots{}) -@findex sprintf -This returns (without printing) the string that @code{printf} would -have printed out with the same arguments -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}). -For example:@refill - -@smallexample -sprintf("pi = %.2f (approx.)", 22/7) -@end smallexample - -@noindent -returns the string @w{@code{"pi = 3.14 (approx.)"}}. - -@item sub(@var{regexp}, @var{replacement}, @var{target}) -@findex sub -The @code{sub} function alters the value of @var{target}. -It searches this value, which should be a string, for the -leftmost substring matched by the regular expression, @var{regexp}, -extending this match as far as possible. Then the entire string is -changed by replacing the matched text with @var{replacement}. -The modified string becomes the new value of @var{target}. - -This function is peculiar because @var{target} is not simply -used to compute a value, and not just any expression will do: it -must be a variable, field or array reference, so that @code{sub} can -store a modified value there. If this argument is omitted, then the -default is to use and alter @code{$0}. - -For example:@refill - -@smallexample -str = "water, water, everywhere" -sub(/at/, "ith", str) -@end smallexample - -@noindent -sets @code{str} to @w{@code{"wither, water, everywhere"}}, by replacing the -leftmost, longest occurrence of @samp{at} with @samp{ith}. - -The @code{sub} function returns the number of substitutions made (either -one or zero). - -If the special character @samp{&} appears in @var{replacement}, it -stands for the precise substring that was matched by @var{regexp}. (If -the regexp can match more than one string, then this precise substring -may vary.) For example:@refill - -@smallexample -awk '@{ sub(/candidate/, "& and his wife"); print @}' -@end smallexample - -@noindent -changes the first occurrence of @samp{candidate} to @samp{candidate -and his wife} on each input line. - -Here is another example: - -@smallexample -awk 'BEGIN @{ - str = "daabaaa" - sub(/a*/, "c&c", str) - print str -@}' -@end smallexample - -@noindent -prints @samp{dcaacbaaa}. This show how @samp{&} can represent a non-constant -string, and also illustrates the ``leftmost, longest'' rule. - -The effect of this special character (@samp{&}) can be turned off by putting a -backslash before it in the string. As usual, to insert one backslash in -the string, you must write two backslashes. Therefore, write @samp{\\&} -in a string constant to include a literal @samp{&} in the replacement. -For example, here is how to replace the first @samp{|} on each line with -an @samp{&}:@refill - -@smallexample -awk '@{ sub(/\|/, "\\&"); print @}' -@end smallexample - -@strong{Note:} as mentioned above, the third argument to @code{sub} must -be an lvalue. Some versions of @code{awk} allow the third argument to -be an expression which is not an lvalue. In such a case, @code{sub} -would still search for the pattern and return 0 or 1, but the result of -the substitution (if any) would be thrown away because there is no place -to put it. Such versions of @code{awk} accept expressions like -this:@refill - -@smallexample -sub(/USA/, "United States", "the USA and Canada") -@end smallexample - -@noindent -But that is considered erroneous in @code{gawk}. - -@item gsub(@var{regexp}, @var{replacement}, @var{target}) -@findex gsub -This is similar to the @code{sub} function, except @code{gsub} replaces -@emph{all} of the longest, leftmost, @emph{nonoverlapping} matching -substrings it can find. The @samp{g} in @code{gsub} stands for -``global,'' which means replace everywhere. For example:@refill - -@smallexample -awk '@{ gsub(/Britain/, "United Kingdom"); print @}' -@end smallexample - -@noindent -replaces all occurrences of the string @samp{Britain} with @samp{United -Kingdom} for all input records.@refill - -The @code{gsub} function returns the number of substitutions made. If -the variable to be searched and altered, @var{target}, is -omitted, then the entire input record, @code{$0}, is used.@refill - -As in @code{sub}, the characters @samp{&} and @samp{\} are special, and -the third argument must be an lvalue. - -@item substr(@var{string}, @var{start}, @var{length}) -@findex substr -This returns a @var{length}-character-long substring of @var{string}, -starting at character number @var{start}. The first character of a -string is character number one. For example, -@code{substr("washington", 5, 3)} returns @code{"ing"}.@refill - -If @var{length} is not present, this function returns the whole suffix of -@var{string} that begins at character number @var{start}. For example, -@code{substr("washington", 5)} returns @code{"ington"}. This is also -the case if @var{length} is greater than the number of characters remaining -in the string, counting from character number @var{start}. - -@item tolower(@var{string}) -@findex tolower -This returns a copy of @var{string}, with each upper-case character -in the string replaced with its corresponding lower-case character. -Nonalphabetic characters are left unchanged. For example, -@code{tolower("MiXeD cAsE 123")} returns @code{"mixed case 123"}. - -@item toupper(@var{string}) -@findex toupper -This returns a copy of @var{string}, with each lower-case character -in the string replaced with its corresponding upper-case character. -Nonalphabetic characters are left unchanged. For example, -@code{toupper("MiXeD cAsE 123")} returns @code{"MIXED CASE 123"}. -@end table - -@node I/O Functions, Time Functions, String Functions, Built-in -@section Built-in Functions for Input/Output - -@table @code -@item close(@var{filename}) -Close the file @var{filename}, for input or output. The argument may -alternatively be a shell command that was used for redirecting to or -from a pipe; then the pipe is closed. - -@xref{Close Input, ,Closing Input Files and Pipes}, regarding closing -input files and pipes. @xref{Close Output, ,Closing Output Files and Pipes}, -regarding closing output files and pipes.@refill - -@item system(@var{command}) -@findex system -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex interaction, @code{awk} and other programs -The system function allows the user to execute operating system commands -and then return to the @code{awk} program. The @code{system} function -executes the command given by the string @var{command}. It returns, as -its value, the status returned by the command that was executed. - -For example, if the following fragment of code is put in your @code{awk} -program: - -@smallexample -END @{ - system("mail -s 'awk run done' operator < /dev/null") -@} -@end smallexample - -@noindent -the system operator will be sent mail when the @code{awk} program -finishes processing input and begins its end-of-input processing. - -Note that much the same result can be obtained by redirecting -@code{print} or @code{printf} into a pipe. However, if your @code{awk} -program is interactive, @code{system} is useful for cranking up large -self-contained programs, such as a shell or an editor.@refill - -Some operating systems cannot implement the @code{system} function. -@code{system} causes a fatal error if it is not supported. -@end table - -@c fakenode --- for prepinfo -@subheading Controlling Output Buffering with @code{system} -@cindex flushing buffers -@cindex buffers, flushing -@cindex buffering output -@cindex output, buffering - -Many utility programs will @dfn{buffer} their output; they save information -to be written to a disk file or terminal in memory, until there is enough -to be written in one operation. This is often more efficient than writing -every little bit of information as soon as it is ready. However, sometimes -it is necessary to force a program to @dfn{flush} its buffers; that is, -write the information to its destination, even if a buffer is not full. -You can do this from your @code{awk} program by calling @code{system} -with a null string as its argument: - -@example -system("") # flush output -@end example - -@noindent -@code{gawk} treats this use of the @code{system} function as a special -case, and is smart enough not to run a shell (or other command -interpreter) with the empty command. Therefore, with @code{gawk}, this -idiom is not only useful, it is efficient. While this idiom should work -with other @code{awk} implementations, it will not necessarily avoid -starting an unnecessary shell. -@ignore -Need a better explanation, perhaps in a separate paragraph. Explain that -for - -awk 'BEGIN { print "hi" - system("echo hello") - print "howdy" }' - -that the output had better be - - hi - hello - howdy - -and not - - hello - hi - howdy - -which it would be if awk did not flush its buffers before calling system. -@end ignore - -@node Time Functions, , I/O Functions, Built-in -@section Functions for Dealing with Time Stamps - -@cindex time stamps -@cindex time of day -A common use for @code{awk} programs is the processing of log files. -Log files often contain time stamp information, indicating when a -particular log record was written. Many programs log their time stamp -in the form returned by the @code{time} system call, which is the -number of seconds since a particular epoch. On @sc{posix} systems, -it is the number of seconds since Midnight, January 1, 1970, @sc{utc}. - -In order to make it easier to process such log files, and to easily produce -useful reports, @code{gawk} provides two functions for working with time -stamps. Both of these are @code{gawk} extensions; they are not specified -in the @sc{posix} standard, nor are they in any other known version -of @code{awk}. - -@table @code -@item systime() -@findex systime -This function returns the current time as the number of seconds since -the system epoch. On @sc{posix} systems, this is the number of seconds -since Midnight, January 1, 1970, @sc{utc}. It may be a different number on -other systems. - -@item strftime(@var{format}, @var{timestamp}) -@findex strftime -This function returns a string. It is similar to the function of the -same name in the @sc{ansi} C standard library. The time specified by -@var{timestamp} is used to produce a string, based on the contents -of the @var{format} string. -@end table - -The @code{systime} function allows you to compare a time stamp from a -log file with the current time of day. In particular, it is easy to -determine how long ago a particular record was logged. It also allows -you to produce log records using the ``seconds since the epoch'' format. - -The @code{strftime} function allows you to easily turn a time stamp -into human-readable information. It is similar in nature to the @code{sprintf} -function, copying non-format specification characters verbatim to the -returned string, and substituting date and time values for format -specifications in the @var{format} string. If no @var{timestamp} argument -is supplied, @code{gawk} will use the current time of day as the -time stamp.@refill - -@code{strftime} is guaranteed by the @sc{ansi} C standard to support -the following date format specifications: - -@table @code -@item %a -The locale's abbreviated weekday name. - -@item %A -The locale's full weekday name. - -@item %b -The locale's abbreviated month name. - -@item %B -The locale's full month name. - -@item %c -The locale's ``appropriate'' date and time representation. - -@item %d -The day of the month as a decimal number (01--31). - -@item %H -The hour (24-hour clock) as a decimal number (00--23). - -@item %I -The hour (12-hour clock) as a decimal number (01--12). - -@item %j -The day of the year as a decimal number (001--366). - -@item %m -The month as a decimal number (01--12). - -@item %M -The minute as a decimal number (00--59). - -@item %p -The locale's equivalent of the AM/PM designations associated -with a 12-hour clock. - -@item %S -The second as a decimal number (00--61). (Occasionally there are -minutes in a year with one or two leap seconds, which is why the -seconds can go from 0 all the way to 61.) - -@item %U -The week number of the year (the first Sunday as the first day of week 1) -as a decimal number (00--53). - -@item %w -The weekday as a decimal number (0--6). Sunday is day 0. - -@item %W -The week number of the year (the first Monday as the first day of week 1) -as a decimal number (00--53). - -@item %x -The locale's ``appropriate'' date representation. - -@item %X -The locale's ``appropriate'' time representation. - -@item %y -The year without century as a decimal number (00--99). - -@item %Y -The year with century as a decimal number. - -@item %Z -The time zone name or abbreviation, or no characters if -no time zone is determinable. - -@item %% -A literal @samp{%}. -@end table - -@c The parenthetical remark here should really be a footnote, but -@c it gave formatting problems at the FSF. So for now put it in -@c parentheses. -If a conversion specifier is not one of the above, the behavior is -undefined. (This is because the @sc{ansi} standard for C leaves the -behavior of the C version of @code{strftime} undefined, and @code{gawk} -will use the system's version of @code{strftime} if it's there. -Typically, the conversion specifier will either not appear in the -returned string, or it will appear literally.) - -Informally, a @dfn{locale} is the geographic place in which a program -is meant to run. For example, a common way to abbreviate the date -September 4, 1991 in the United States would be ``9/4/91''. -In many countries in Europe, however, it would be abbreviated ``4.9.91''. -Thus, the @samp{%x} specification in a @code{"US"} locale might produce -@samp{9/4/91}, while in a @code{"EUROPE"} locale, it might produce -@samp{4.9.91}. The @sc{ansi} C standard defines a default @code{"C"} -locale, which is an environment that is typical of what most C programmers -are used to. - -A public-domain C version of @code{strftime} is shipped with @code{gawk} -for systems that are not yet fully @sc{ansi}-compliant. If that version is -used to compile @code{gawk} (@pxref{Installation, ,Installing @code{gawk}}), -then the following additional format specifications are available:@refill - -@table @code -@item %D -Equivalent to specifying @samp{%m/%d/%y}. - -@item %e -The day of the month, padded with a blank if it is only one digit. - -@item %h -Equivalent to @samp{%b}, above. - -@item %n -A newline character (ASCII LF). - -@item %r -Equivalent to specifying @samp{%I:%M:%S %p}. - -@item %R -Equivalent to specifying @samp{%H:%M}. - -@item %T -Equivalent to specifying @samp{%H:%M:%S}. - -@item %t -A TAB character. - -@item %k -is replaced by the hour (24-hour clock) as a decimal number (0-23). -Single digit numbers are padded with a blank. - -@item %l -is replaced by the hour (12-hour clock) as a decimal number (1-12). -Single digit numbers are padded with a blank. - -@item %C -The century, as a number between 00 and 99. - -@item %u -is replaced by the weekday as a decimal number -[1 (Monday)--7]. - -@item %V -is replaced by the week number of the year (the first Monday as the first -day of week 1) as a decimal number (01--53). -The method for determining the week number is as specified by ISO 8601 -(to wit: if the week containing January 1 has four or more days in the -new year, then it is week 1, otherwise it is week 53 of the previous year -and the next week is week 1).@refill - -@item %Ec %EC %Ex %Ey %EY %Od %Oe %OH %OI -@itemx %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy -These are ``alternate representations'' for the specifications -that use only the second letter (@samp{%c}, @samp{%C}, and so on). -They are recognized, but their normal representations are used. -(These facilitate compliance with the @sc{posix} @code{date} -utility.)@refill - -@item %v -The date in VMS format (e.g. 20-JUN-1991). -@end table - -Here are two examples that use @code{strftime}. The first is an -@code{awk} version of the C @code{ctime} function. (This is a -user defined function, which we have not discussed yet. -@xref{User-defined, ,User-defined Functions}, for more information.) - -@smallexample -# ctime.awk -# -# awk version of C ctime(3) function - -function ctime(ts, format) -@{ - format = "%a %b %e %H:%M:%S %Z %Y" - if (ts == 0) - ts = systime() # use current time as default - return strftime(format, ts) -@} -@end smallexample - -This next example is an @code{awk} implementation of the @sc{posix} -@code{date} utility. Normally, the @code{date} utility prints the -current date and time of day in a well known format. However, if you -provide an argument to it that begins with a @samp{+}, @code{date} -will copy non-format specifier characters to the standard output, and -will interpret the current time according to the format specifiers in -the string. For example: - -@smallexample -date '+Today is %A, %B %d, %Y.' -@end smallexample - -@noindent -might print - -@smallexample -Today is Thursday, July 11, 1991. -@end smallexample - -Here is the @code{awk} version of the @code{date} utility. - -@smallexample -#! /usr/bin/gawk -f -# -# date --- implement the P1003.2 Draft 11 'date' command -# -# Bug: does not recognize the -u argument. - -BEGIN \ -@{ - format = "%a %b %e %H:%M:%S %Z %Y" - exitval = 0 - - if (ARGC > 2) - exitval = 1 - else if (ARGC == 2) @{ - format = ARGV[1] - if (format ~ /^\+/) - format = substr(format, 2) # remove leading + - @} - print strftime(format) - exit exitval -@} -@end smallexample - -@node User-defined, Built-in Variables, Built-in, Top -@chapter User-defined Functions - -@cindex user-defined functions -@cindex functions, user-defined -Complicated @code{awk} programs can often be simplified by defining -your own functions. User-defined functions can be called just like -built-in ones (@pxref{Function Calls}), but it is up to you to define -them---to tell @code{awk} what they should do. - -@menu -* Definition Syntax:: How to write definitions and what they mean. -* Function Example:: An example function definition and - what it does. -* Function Caveats:: Things to watch out for. -* Return Statement:: Specifying the value a function returns. -@end menu - -@node Definition Syntax, Function Example, User-defined, User-defined -@section Syntax of Function Definitions -@cindex defining functions -@cindex function definition - -Definitions of functions can appear anywhere between the rules of the -@code{awk} program. Thus, the general form of an @code{awk} program is -extended to include sequences of rules @emph{and} user-defined function -definitions. - -The definition of a function named @var{name} looks like this: - -@example -function @var{name} (@var{parameter-list}) @{ - @var{body-of-function} -@} -@end example - -@noindent -@var{name} is the name of the function to be defined. A valid function -name is like a valid variable name: a sequence of letters, digits and -underscores, not starting with a digit. Functions share the same pool -of names as variables and arrays. - -@var{parameter-list} is a list of the function's arguments and local -variable names, separated by commas. When the function is called, -the argument names are used to hold the argument values given in -the call. The local variables are initialized to the null string. - -The @var{body-of-function} consists of @code{awk} statements. It is the -most important part of the definition, because it says what the function -should actually @emph{do}. The argument names exist to give the body a -way to talk about the arguments; local variables, to give the body -places to keep temporary values. - -Argument names are not distinguished syntactically from local variable -names; instead, the number of arguments supplied when the function is -called determines how many argument variables there are. Thus, if three -argument values are given, the first three names in @var{parameter-list} -are arguments, and the rest are local variables. - -It follows that if the number of arguments is not the same in all calls -to the function, some of the names in @var{parameter-list} may be -arguments on some occasions and local variables on others. Another -way to think of this is that omitted arguments default to the -null string. - -Usually when you write a function you know how many names you intend to -use for arguments and how many you intend to use as locals. By -convention, you should write an extra space between the arguments and -the locals, so other people can follow how your function is -supposed to be used. - -During execution of the function body, the arguments and local variable -values hide or @dfn{shadow} any variables of the same names used in the -rest of the program. The shadowed variables are not accessible in the -function definition, because there is no way to name them while their -names have been taken away for the local variables. All other variables -used in the @code{awk} program can be referenced or set normally in the -function definition. - -The arguments and local variables last only as long as the function body -is executing. Once the body finishes, the shadowed variables come back. - -The function body can contain expressions which call functions. They -can even call this function, either directly or by way of another -function. When this happens, we say the function is @dfn{recursive}. - -There is no need in @code{awk} to put the definition of a function -before all uses of the function. This is because @code{awk} reads the -entire program before starting to execute any of it. - -In many @code{awk} implementations, the keyword @code{function} may be -abbreviated @code{func}. However, @sc{posix} only specifies the use of -the keyword @code{function}. This actually has some practical implications. -If @code{gawk} is in @sc{posix}-compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then the following -statement will @emph{not} define a function:@refill - -@example -func foo() @{ a = sqrt($1) ; print a @} -@end example - -@noindent -Instead it defines a rule that, for each record, concatenates the value -of the variable @samp{func} with the return value of the function @samp{foo}, -and based on the truth value of the result, executes the corresponding action. -This is probably not what was desired. (@code{awk} accepts this input as -syntactically valid, since functions may be used before they are defined -in @code{awk} programs.) - -@node Function Example, Function Caveats, Definition Syntax, User-defined -@section Function Definition Example - -Here is an example of a user-defined function, called @code{myprint}, that -takes a number and prints it in a specific format. - -@example -function myprint(num) -@{ - printf "%6.3g\n", num -@} -@end example - -@noindent -To illustrate, here is an @code{awk} rule which uses our @code{myprint} -function: - -@example -$3 > 0 @{ myprint($3) @} -@end example - -@noindent -This program prints, in our special format, all the third fields that -contain a positive number in our input. Therefore, when given: - -@example - 1.2 3.4 5.6 7.8 - 9.10 11.12 -13.14 15.16 -17.18 19.20 21.22 23.24 -@end example - -@noindent -this program, using our function to format the results, prints: - -@example - 5.6 - 21.2 -@end example - -Here is a rather contrived example of a recursive function. It prints a -string backwards: - -@example -function rev (str, len) @{ - if (len == 0) @{ - printf "\n" - return - @} - printf "%c", substr(str, len, 1) - rev(str, len - 1) -@} -@end example - -@node Function Caveats, Return Statement, Function Example, User-defined -@section Calling User-defined Functions - -@dfn{Calling a function} means causing the function to run and do its job. -A function call is an expression, and its value is the value returned by -the function. - -A function call consists of the function name followed by the arguments -in parentheses. What you write in the call for the arguments are -@code{awk} expressions; each time the call is executed, these -expressions are evaluated, and the values are the actual arguments. For -example, here is a call to @code{foo} with three arguments (the first -being a string concatenation): - -@example -foo(x y, "lose", 4 * z) -@end example - -@quotation -@strong{Caution:} whitespace characters (spaces and tabs) are not allowed -between the function name and the open-parenthesis of the argument list. -If you write whitespace by mistake, @code{awk} might think that you mean -to concatenate a variable with an expression in parentheses. However, it -notices that you used a function name and not a variable name, and reports -an error. -@end quotation - -@cindex call by value -When a function is called, it is given a @emph{copy} of the values of -its arguments. This is called @dfn{call by value}. The caller may use -a variable as the expression for the argument, but the called function -does not know this: it only knows what value the argument had. For -example, if you write this code: - -@example -foo = "bar" -z = myfunc(foo) -@end example - -@noindent -then you should not think of the argument to @code{myfunc} as being -``the variable @code{foo}.'' Instead, think of the argument as the -string value, @code{"bar"}. - -If the function @code{myfunc} alters the values of its local variables, -this has no effect on any other variables. In particular, if @code{myfunc} -does this: - -@example -function myfunc (win) @{ - print win - win = "zzz" - print win -@} -@end example - -@noindent -to change its first argument variable @code{win}, this @emph{does not} -change the value of @code{foo} in the caller. The role of @code{foo} in -calling @code{myfunc} ended when its value, @code{"bar"}, was computed. -If @code{win} also exists outside of @code{myfunc}, the function body -cannot alter this outer value, because it is shadowed during the -execution of @code{myfunc} and cannot be seen or changed from there. - -@cindex call by reference -However, when arrays are the parameters to functions, they are @emph{not} -copied. Instead, the array itself is made available for direct manipulation -by the function. This is usually called @dfn{call by reference}. -Changes made to an array parameter inside the body of a function @emph{are} -visible outside that function. -@ifinfo -This can be @strong{very} dangerous if you do not watch what you are -doing. For example:@refill -@end ifinfo -@iftex -@emph{This can be very dangerous if you do not watch what you are -doing.} For example:@refill -@end iftex - -@example -function changeit (array, ind, nvalue) @{ - array[ind] = nvalue -@} - -BEGIN @{ - a[1] = 1 ; a[2] = 2 ; a[3] = 3 - changeit(a, 2, "two") - printf "a[1] = %s, a[2] = %s, a[3] = %s\n", a[1], a[2], a[3] - @} -@end example - -@noindent -prints @samp{a[1] = 1, a[2] = two, a[3] = 3}, because calling -@code{changeit} stores @code{"two"} in the second element of @code{a}. - -@node Return Statement, , Function Caveats, User-defined -@section The @code{return} Statement -@cindex @code{return} statement - -The body of a user-defined function can contain a @code{return} statement. -This statement returns control to the rest of the @code{awk} program. It -can also be used to return a value for use in the rest of the @code{awk} -program. It looks like this:@refill - -@example -return @var{expression} -@end example - -The @var{expression} part is optional. If it is omitted, then the returned -value is undefined and, therefore, unpredictable. - -A @code{return} statement with no value expression is assumed at the end of -every function definition. So if control reaches the end of the function -body, then the function returns an unpredictable value. @code{awk} -will not warn you if you use the return value of such a function; you will -simply get unpredictable or unexpected results. - -Here is an example of a user-defined function that returns a value -for the largest number among the elements of an array:@refill - -@example -@group -function maxelt (vec, i, ret) @{ - for (i in vec) @{ - if (ret == "" || vec[i] > ret) - ret = vec[i] - @} - return ret -@} -@end group -@end example - -@noindent -You call @code{maxelt} with one argument, which is an array name. The local -variables @code{i} and @code{ret} are not intended to be arguments; -while there is nothing to stop you from passing two or three arguments -to @code{maxelt}, the results would be strange. The extra space before -@code{i} in the function parameter list is to indicate that @code{i} and -@code{ret} are not supposed to be arguments. This is a convention which -you should follow when you define functions. - -Here is a program that uses our @code{maxelt} function. It loads an -array, calls @code{maxelt}, and then reports the maximum number in that -array:@refill - -@example -@group -awk ' -function maxelt (vec, i, ret) @{ - for (i in vec) @{ - if (ret == "" || vec[i] > ret) - ret = vec[i] - @} - return ret -@} -@end group - -@group -# Load all fields of each record into nums. -@{ - for(i = 1; i <= NF; i++) - nums[NR, i] = $i -@} - -END @{ - print maxelt(nums) -@}' -@end group -@end example - -Given the following input: - -@example -@group - 1 5 23 8 16 -44 3 5 2 8 26 -256 291 1396 2962 100 --6 467 998 1101 -99385 11 0 225 -@end group -@end example - -@noindent -our program tells us (predictably) that: - -@example -99385 -@end example - -@noindent -is the largest number in our array. - -@node Built-in Variables, Command Line, User-defined, Top -@chapter Built-in Variables -@cindex built-in variables - -Most @code{awk} variables are available for you to use for your own -purposes; they never change except when your program assigns values to -them, and never affect anything except when your program examines them. - -A few variables have special built-in meanings. Some of them @code{awk} -examines automatically, so that they enable you to tell @code{awk} how -to do certain things. Others are set automatically by @code{awk}, so -that they carry information from the internal workings of @code{awk} to -your program. - -This chapter documents all the built-in variables of @code{gawk}. Most -of them are also documented in the chapters where their areas of -activity are described. - -@menu -* User-modified:: Built-in variables that you change - to control @code{awk}. -* Auto-set:: Built-in variables where @code{awk} - gives you information. -@end menu - -@node User-modified, Auto-set, Built-in Variables, Built-in Variables -@section Built-in Variables that Control @code{awk} -@cindex built-in variables, user modifiable - -This is a list of the variables which you can change to control how -@code{awk} does certain things. - -@table @code -@iftex -@vindex CONVFMT -@end iftex -@item CONVFMT -This string is used by @code{awk} to control conversion of numbers to -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}). -It works by being passed, in effect, as the first argument to the -@code{sprintf} function. Its default value is @code{"%.6g"}. -@code{CONVFMT} was introduced by the @sc{posix} standard.@refill - -@iftex -@vindex FIELDWIDTHS -@end iftex -@item FIELDWIDTHS -This is a space separated list of columns that tells @code{gawk} -how to manage input with fixed, columnar boundaries. It is an -experimental feature that is still evolving. Assigning to @code{FIELDWIDTHS} -overrides the use of @code{FS} for field splitting. -@xref{Constant Size, ,Reading Fixed-width Data}, for more information.@refill - -If @code{gawk} is in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then @code{FIELDWIDTHS} -has no special meaning, and field splitting operations are done based -exclusively on the value of @code{FS}.@refill - -@iftex -@vindex FS -@end iftex -@item FS -@code{FS} is the input field separator -(@pxref{Field Separators, ,Specifying how Fields are Separated}). -The value is a single-character string or a multi-character regular -expression that matches the separations between fields in an input -record.@refill - -The default value is @w{@code{" "}}, a string consisting of a single -space. As a special exception, this value actually means that any -sequence of spaces and tabs is a single separator. It also causes -spaces and tabs at the beginning or end of a line to be ignored. - -You can set the value of @code{FS} on the command line using the -@samp{-F} option: - -@example -awk -F, '@var{program}' @var{input-files} -@end example - -If @code{gawk} is using @code{FIELDWIDTHS} for field-splitting, -assigning a value to @code{FS} will cause @code{gawk} to return to -the normal, regexp-based, field splitting. - -@item IGNORECASE -@iftex -@vindex IGNORECASE -@end iftex -If @code{IGNORECASE} is nonzero, then @emph{all} regular expression -matching is done in a case-independent fashion. In particular, regexp -matching with @samp{~} and @samp{!~}, and the @code{gsub} @code{index}, -@code{match}, @code{split} and @code{sub} functions all ignore case when -doing their particular regexp operations. @strong{Note:} since field -splitting with the value of the @code{FS} variable is also a regular -expression operation, that too is done with case ignored. -@xref{Case-sensitivity, ,Case-sensitivity in Matching}. - -If @code{gawk} is in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then @code{IGNORECASE} has -no special meaning, and regexp operations are always case-sensitive.@refill - -@item OFMT -@iftex -@vindex OFMT -@end iftex -This string is used by @code{awk} to control conversion of numbers to -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}) for -printing with the @code{print} statement. -It works by being passed, in effect, as the first argument to the -@code{sprintf} function. Its default value is @code{"%.6g"}. -Earlier versions of @code{awk} also used @code{OFMT} to specify the -format for converting numbers to strings in general expressions; this -has been taken over by @code{CONVFMT}.@refill - -@item OFS -@iftex -@vindex OFS -@end iftex -This is the output field separator (@pxref{Output Separators}). It is -output between the fields output by a @code{print} statement. Its -default value is @w{@code{" "}}, a string consisting of a single space. - -@item ORS -@iftex -@vindex ORS -@end iftex -This is the output record separator. It is output at the end of every -@code{print} statement. Its default value is a string containing a -single newline character, which could be written as @code{"\n"}. -(@xref{Output Separators}.)@refill - -@item RS -@iftex -@vindex RS -@end iftex -This is @code{awk}'s input record separator. Its default value is a string -containing a single newline character, which means that an input record -consists of a single line of text. -(@xref{Records, ,How Input is Split into Records}.)@refill - -@item SUBSEP -@iftex -@vindex SUBSEP -@end iftex -@code{SUBSEP} is the subscript separator. It has the default value of -@code{"\034"}, and is used to separate the parts of the name of a -multi-dimensional array. Thus, if you access @code{foo[12,3]}, it -really accesses @code{foo["12\0343"]} -(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill -@end table - -@node Auto-set, , User-modified, Built-in Variables -@section Built-in Variables that Convey Information - -This is a list of the variables that are set automatically by @code{awk} -on certain occasions so as to provide information to your program. - -@table @code -@item ARGC -@itemx ARGV -@iftex -@vindex ARGC -@vindex ARGV -@end iftex -The command-line arguments available to @code{awk} programs are stored in -an array called @code{ARGV}. @code{ARGC} is the number of command-line -arguments present. @xref{Command Line, ,Invoking @code{awk}}. -@code{ARGV} is indexed from zero to @w{@code{ARGC - 1}}. For example:@refill - -@example -awk 'BEGIN @{ - for (i = 0; i < ARGC; i++) - print ARGV[i] - @}' inventory-shipped BBS-list -@end example - -@noindent -In this example, @code{ARGV[0]} contains @code{"awk"}, @code{ARGV[1]} -contains @code{"inventory-shipped"}, and @code{ARGV[2]} contains -@code{"BBS-list"}. The value of @code{ARGC} is 3, one more than the -index of the last element in @code{ARGV} since the elements are numbered -from zero.@refill - -The names @code{ARGC} and @code{ARGV}, as well the convention of indexing -the array from 0 to @w{@code{ARGC - 1}}, are derived from the C language's -method of accessing command line arguments.@refill - -Notice that the @code{awk} program is not entered in @code{ARGV}. The -other special command line options, with their arguments, are also not -entered. But variable assignments on the command line @emph{are} -treated as arguments, and do show up in the @code{ARGV} array. - -Your program can alter @code{ARGC} and the elements of @code{ARGV}. -Each time @code{awk} reaches the end of an input file, it uses the next -element of @code{ARGV} as the name of the next input file. By storing a -different string there, your program can change which files are read. -You can use @code{"-"} to represent the standard input. By storing -additional elements and incrementing @code{ARGC} you can cause -additional files to be read. - -If you decrease the value of @code{ARGC}, that eliminates input files -from the end of the list. By recording the old value of @code{ARGC} -elsewhere, your program can treat the eliminated arguments as -something other than file names. - -To eliminate a file from the middle of the list, store the null string -(@code{""}) into @code{ARGV} in place of the file's name. As a -special feature, @code{awk} ignores file names that have been -replaced with the null string. - -@ignore -see getopt.awk in the examples... -@end ignore - -@item ARGIND -@vindex ARGIND -The index in @code{ARGV} of the current file being processed. -Every time @code{gawk} opens a new data file for processing, it sets -@code{ARGIND} to the index in @code{ARGV} of the file name. Thus, the -condition @samp{FILENAME == ARGV[ARGIND]} is always true. - -This variable is useful in file processing; it allows you to tell how far -along you are in the list of data files, and to distinguish between -multiple successive instances of the same filename on the command line. - -While you can change the value of @code{ARGIND} within your @code{awk} -program, @code{gawk} will automatically set it to a new value when the -next file is opened. - -This variable is a @code{gawk} extension; in other @code{awk} implementations -it is not special. - -@item ENVIRON -@vindex ENVIRON -This is an array that contains the values of the environment. The array -indices are the environment variable names; the values are the values of -the particular environment variables. For example, -@code{ENVIRON["HOME"]} might be @file{/u/close}. Changing this array -does not affect the environment passed on to any programs that -@code{awk} may spawn via redirection or the @code{system} function. -(In a future version of @code{gawk}, it may do so.) - -Some operating systems may not have environment variables. -On such systems, the array @code{ENVIRON} is empty. - -@item ERRNO -@iftex -@vindex ERRNO -@end iftex -If a system error occurs either doing a redirection for @code{getline}, -during a read for @code{getline}, or during a @code{close} operation, -then @code{ERRNO} will contain a string describing the error. - -This variable is a @code{gawk} extension; in other @code{awk} implementations -it is not special. - -@item FILENAME -@iftex -@vindex FILENAME -@end iftex -This is the name of the file that @code{awk} is currently reading. -If @code{awk} is reading from the standard input (in other words, -there are no files listed on the command line), -@code{FILENAME} is set to @code{"-"}. -@code{FILENAME} is changed each time a new file is read -(@pxref{Reading Files, ,Reading Input Files}).@refill - -@item FNR -@iftex -@vindex FNR -@end iftex -@code{FNR} is the current record number in the current file. @code{FNR} is -incremented each time a new record is read -(@pxref{Getline, ,Explicit Input with @code{getline}}). It is reinitialized -to 0 each time a new input file is started.@refill - -@item NF -@iftex -@vindex NF -@end iftex -@code{NF} is the number of fields in the current input record. -@code{NF} is set each time a new record is read, when a new field is -created, or when @code{$0} changes (@pxref{Fields, ,Examining Fields}).@refill - -@item NR -@iftex -@vindex NR -@end iftex -This is the number of input records @code{awk} has processed since -the beginning of the program's execution. -(@pxref{Records, ,How Input is Split into Records}). -@code{NR} is set each time a new record is read.@refill - -@item RLENGTH -@iftex -@vindex RLENGTH -@end iftex -@code{RLENGTH} is the length of the substring matched by the -@code{match} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -@code{RLENGTH} is set by invoking the @code{match} function. Its value -is the length of the matched string, or @minus{}1 if no match was found.@refill - -@item RSTART -@iftex -@vindex RSTART -@end iftex -@code{RSTART} is the start-index in characters of the substring matched by the -@code{match} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -@code{RSTART} is set by invoking the @code{match} function. Its value -is the position of the string where the matched substring starts, or 0 -if no match was found.@refill -@end table - -@node Command Line, Language History, Built-in Variables, Top -@c node-name, next, previous, up -@chapter Invoking @code{awk} -@cindex command line -@cindex invocation of @code{gawk} -@cindex arguments, command line -@cindex options, command line -@cindex long options -@cindex options, long - -There are two ways to run @code{awk}: with an explicit program, or with -one or more program files. Here are templates for both of them; items -enclosed in @samp{@r{[}@dots{}@r{]}} in these templates are optional. - -Besides traditional one-letter @sc{posix}-style options, @code{gawk} also -supports GNU long named options. - -@example -awk @r{[@var{POSIX or GNU style options}]} -f progfile @r{[@code{--}]} @var{file} @dots{} -awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{} -@end example - -@menu -* Options:: Command line options and their meanings. -* Other Arguments:: Input file names and variable assignments. -* AWKPATH Variable:: Searching directories for @code{awk} programs. -* Obsolete:: Obsolete Options and/or features. -* Undocumented:: Undocumented Options and Features. -@end menu - -@node Options, Other Arguments, Command Line, Command Line -@section Command Line Options - -Options begin with a minus sign, and consist of a single character. -GNU style long named options consist of two minus signs and -a keyword that can be abbreviated if the abbreviation allows the option -to be uniquely identified. If the option takes an argument, then the -keyword is immediately followed by an equals sign (@samp{=}) and the -argument's value. For brevity, the discussion below only refers to the -traditional short options; however the long and short options are -interchangeable in all contexts. - -Each long named option for @code{gawk} has a corresponding -@sc{posix}-style option. The options and their meanings are as follows: - -@table @code -@item -F @var{fs} -@itemx --field-separator=@var{fs} -@iftex -@cindex @code{-F} option -@end iftex -@cindex @code{--field-separator} option -Sets the @code{FS} variable to @var{fs} -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill - -@item -f @var{source-file} -@itemx --file=@var{source-file} -@iftex -@cindex @code{-f} option -@end iftex -@cindex @code{--file} option -Indicates that the @code{awk} program is to be found in @var{source-file} -instead of in the first non-option argument. - -@item -v @var{var}=@var{val} -@itemx --assign=@var{var}=@var{val} -@cindex @samp{-v} option -@cindex @code{--assign} option -Sets the variable @var{var} to the value @var{val} @emph{before} -execution of the program begins. Such variable values are available -inside the @code{BEGIN} rule (see below for a fuller explanation). - -The @samp{-v} option can only set one variable, but you can use -it more than once, setting another variable each time, like this: -@samp{@w{-v foo=1} @w{-v bar=2}}. - -@item -W @var{gawk-opt} -@cindex @samp{-W} option -Following the @sc{posix} standard, options that are implementation -specific are supplied as arguments to the @samp{-W} option. With @code{gawk}, -these arguments may be separated by commas, or quoted and separated by -whitespace. Case is ignored when processing these options. These options -also have corresponding GNU style long named options. The following -@code{gawk}-specific options are available: - -@table @code -@item -W compat -@itemx --compat -@cindex @code{--compat} option -Specifies @dfn{compatibility mode}, in which the GNU extensions in -@code{gawk} are disabled, so that @code{gawk} behaves just like Unix -@code{awk}. -@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}}, -which summarizes the extensions. Also see -@ref{Compatibility Mode, ,Downward Compatibility and Debugging}.@refill - -@item -W copyleft -@itemx -W copyright -@itemx --copyleft -@itemx --copyright -@cindex @code{--copyleft} option -@cindex @code{--copyright} option -Print the short version of the General Public License. -This option may disappear in a future version of @code{gawk}. - -@item -W help -@itemx -W usage -@itemx --help -@itemx --usage -@cindex @code{--help} option -@cindex @code{--usage} option -Print a ``usage'' message summarizing the short and long style options -that @code{gawk} accepts, and then exit. - -@item -W lint -@itemx --lint -@cindex @code{--lint} option -Provide warnings about constructs that are dubious or non-portable to -other @code{awk} implementations. -Some warnings are issued when @code{gawk} first reads your program. Others -are issued at run-time, as your program executes. - -@item -W posix -@itemx --posix -@cindex @code{--posix} option -Operate in strict @sc{posix} mode. This disables all @code{gawk} -extensions (just like @code{-W compat}), and adds the following additional -restrictions: - -@itemize @bullet{} -@item -@code{\x} escape sequences are not recognized -(@pxref{Constants, ,Constant Expressions}).@refill - -@item -The synonym @code{func} for the keyword @code{function} is not -recognized (@pxref{Definition Syntax, ,Syntax of Function Definitions}). - -@item -The operators @samp{**} and @samp{**=} cannot be used in -place of @samp{^} and @samp{^=} (@pxref{Arithmetic Ops, ,Arithmetic Operators}, -and also @pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -Specifying @samp{-Ft} on the command line does not set the value -of @code{FS} to be a single tab character -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill -@end itemize - -Although you can supply both @samp{-W compat} and @samp{-W posix} on the -command line, @samp{-W posix} will take precedence. - -@item -W source=@var{program-text} -@itemx --source=@var{program-text} -@cindex @code{--source} option -Program source code is taken from the @var{program-text}. This option -allows you to mix @code{awk} source code in files with program source -code that you would enter on the command line. This is particularly useful -when you have library functions that you wish to use from your command line -programs (@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}). - -@item -W version -@itemx --version -@cindex @code{--version} option -Prints version information for this particular copy of @code{gawk}. -This is so you can determine if your copy of @code{gawk} is up to date -with respect to whatever the Free Software Foundation is currently -distributing. This option may disappear in a future version of @code{gawk}. -@end table - -@item -- -Signals the end of the command line options. The following arguments -are not treated as options even if they begin with @samp{-}. This -interpretation of @samp{--} follows the @sc{posix} argument parsing -conventions. - -This is useful if you have file names that start with @samp{-}, -or in shell scripts, if you have file names that will be specified -by the user which could start with @samp{-}. -@end table - -Any other options are flagged as invalid with a warning message, but -are otherwise ignored. - -In compatibility mode, as a special case, if the value of @var{fs} supplied -to the @samp{-F} option is @samp{t}, then @code{FS} is set to the tab -character (@code{"\t"}). This is only true for @samp{-W compat}, and not -for @samp{-W posix} -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill - -If the @samp{-f} option is @emph{not} used, then the first non-option -command line argument is expected to be the program text. - -The @samp{-f} option may be used more than once on the command line. -If it is, @code{awk} reads its program source from all of the named files, as -if they had been concatenated together into one big file. This is -useful for creating libraries of @code{awk} functions. Useful functions -can be written once, and then retrieved from a standard place, instead -of having to be included into each individual program. You can still -type in a program at the terminal and use library functions, by specifying -@samp{-f /dev/tty}. @code{awk} will read a file from the terminal -to use as part of the @code{awk} program. After typing your program, -type @kbd{Control-d} (the end-of-file character) to terminate it. -(You may also use @samp{-f -} to read program source from the standard -input, but then you will not be able to also use the standard input as a -source of data.) - -Because it is clumsy using the standard @code{awk} mechanisms to mix source -file and command line @code{awk} programs, @code{gawk} provides the -@samp{--source} option. This does not require you to pre-empt the standard -input for your source code, and allows you to easily mix command line -and library source code -(@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}). - -If no @samp{-f} or @samp{--source} option is specified, then @code{gawk} -will use the first non-option command line argument as the text of the -program source code. - -@node Other Arguments, AWKPATH Variable, Options, Command Line -@section Other Command Line Arguments - -Any additional arguments on the command line are normally treated as -input files to be processed in the order specified. However, an -argument that has the form @code{@var{var}=@var{value}}, means to assign -the value @var{value} to the variable @var{var}---it does not specify a -file at all. - -@vindex ARGV -All these arguments are made available to your @code{awk} program in the -@code{ARGV} array (@pxref{Built-in Variables}). Command line options -and the program text (if present) are omitted from the @code{ARGV} -array. All other arguments, including variable assignments, are -included. - -The distinction between file name arguments and variable-assignment -arguments is made when @code{awk} is about to open the next input file. -At that point in execution, it checks the ``file name'' to see whether -it is really a variable assignment; if so, @code{awk} sets the variable -instead of reading a file. - -Therefore, the variables actually receive the specified values after all -previously specified files have been read. In particular, the values of -variables assigned in this fashion are @emph{not} available inside a -@code{BEGIN} rule -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}), -since such rules are run before @code{awk} begins scanning the argument list. -The values given on the command line are processed for escape sequences -(@pxref{Constants, ,Constant Expressions}).@refill - -In some earlier implementations of @code{awk}, when a variable assignment -occurred before any file names, the assignment would happen @emph{before} -the @code{BEGIN} rule was executed. Some applications came to depend -upon this ``feature.'' When @code{awk} was changed to be more consistent, -the @samp{-v} option was added to accommodate applications that depended -upon this old behavior. - -The variable assignment feature is most useful for assigning to variables -such as @code{RS}, @code{OFS}, and @code{ORS}, which control input and -output formats, before scanning the data files. It is also useful for -controlling state if multiple passes are needed over a data file. For -example:@refill - -@cindex multiple passes over data -@cindex passes, multiple -@smallexample -awk 'pass == 1 @{ @var{pass 1 stuff} @} - pass == 2 @{ @var{pass 2 stuff} @}' pass=1 datafile pass=2 datafile -@end smallexample - -Given the variable assignment feature, the @samp{-F} option is not -strictly necessary. It remains for historical compatibility. - -@node AWKPATH Variable, Obsolete, Other Arguments, Command Line -@section The @code{AWKPATH} Environment Variable -@cindex @code{AWKPATH} environment variable -@cindex search path -@cindex directory search -@cindex path, search -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex - -The previous section described how @code{awk} program files can be named -on the command line with the @samp{-f} option. In some @code{awk} -implementations, you must supply a precise path name for each program -file, unless the file is in the current directory. - -But in @code{gawk}, if the file name supplied in the @samp{-f} option -does not contain a @samp{/}, then @code{gawk} searches a list of -directories (called the @dfn{search path}), one by one, looking for a -file with the specified name. - -The search path is actually a string consisting of directory names -separated by colons. @code{gawk} gets its search path from the -@code{AWKPATH} environment variable. If that variable does not exist, -@code{gawk} uses the default path, which is -@samp{.:/usr/lib/awk:/usr/local/lib/awk}. (Programs written by -system administrators should use an @code{AWKPATH} variable that -does not include the current directory, @samp{.}.)@refill - -The search path feature is particularly useful for building up libraries -of useful @code{awk} functions. The library files can be placed in a -standard directory that is in the default path, and then specified on -the command line with a short file name. Otherwise, the full file name -would have to be typed for each file. - -By combining the @samp{--source} and @samp{-f} options, your command line -@code{awk} programs can use facilities in @code{awk} library files. - -Path searching is not done if @code{gawk} is in compatibility mode. -This is true for both @samp{-W compat} and @samp{-W posix}. -@xref{Options, ,Command Line Options}. - -@strong{Note:} if you want files in the current directory to be found, -you must include the current directory in the path, either by writing -@file{.} as an entry in the path, or by writing a null entry in the -path. (A null entry is indicated by starting or ending the path with a -colon, or by placing two colons next to each other (@samp{::}).) If the -current directory is not included in the path, then files cannot be -found in the current directory. This path search mechanism is identical -to the shell's. -@c someday, @cite{The Bourne Again Shell}.... - -@node Obsolete, Undocumented, AWKPATH Variable, Command Line -@section Obsolete Options and/or Features - -@cindex deprecated options -@cindex obsolete options -@cindex deprecated features -@cindex obsolete features -This section describes features and/or command line options from the -previous release of @code{gawk} that are either not available in the -current version, or that are still supported but deprecated (meaning that -they will @emph{not} be in the next release). - -@c update this section for each release! - -For version 2.15 of @code{gawk}, the following command line options -from version 2.11.1 are no longer recognized. - -@table @samp -@ignore -@item -nostalgia -Use @samp{-W nostalgia} instead. -@end ignore - -@item -c -Use @samp{-W compat} instead. - -@item -V -Use @samp{-W version} instead. - -@item -C -Use @samp{-W copyright} instead. - -@item -a -@itemx -e -These options produce an ``unrecognized option'' error message but have -no effect on the execution of @code{gawk}. The @sc{posix} standard now -specifies traditional @code{awk} regular expressions for the @code{awk} utility. -@end table - -The public-domain version of @code{strftime} that is distributed with -@code{gawk} changed for the 2.14 release. The @samp{%V} conversion specifier -that used to generate the date in VMS format was changed to @samp{%v}. -This is because the @sc{posix} standard for the @code{date} utility now -specifies a @samp{%V} conversion specifier. -@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for details. - -@node Undocumented, , Obsolete, Command Line -@section Undocumented Options and Features - -This section intentionally left blank. - -@c Read The Source, Luke! - -@ignore -@c If these came out in the Info file or TeX manual, then they wouldn't -@c be undocumented, would they? - -@code{gawk} has one undocumented option: - -@table @samp -@item -W nostalgia -Print the message @code{"awk: bailing out near line 1"} and dump core. -This option was inspired by the common behavior of very early versions of -Unix @code{awk}, and by a t--shirt. -@end table - -Early versions of @code{awk} used to not require any separator (either -a newline or @samp{;}) between the rules in @code{awk} programs. Thus, -it was common to see one-line programs like: - -@example -awk '@{ sum += $1 @} END @{ print sum @}' -@end example - -@code{gawk} actually supports this, but it is purposely undocumented -since it is considered bad style. The correct way to write such a program -is either - -@example -awk '@{ sum += $1 @} ; END @{ print sum @}' -@end example - -@noindent -or - -@example -awk '@{ sum += $1 @} - END @{ print sum @}' data -@end example - -@noindent -@xref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a fuller -explanation.@refill - -As an accident of the implementation of the original Unix @code{awk}, if -a built-in function used @code{$0} as its default argument, it was possible -to call that function without the parentheses. In particular, it was -common practice to use the @code{length} function in this fashion. -For example, the pipeline: - -@example -echo abcdef | awk '@{ print length @}' -@end example - -@noindent -would print @samp{6}. - -For backwards compatibility with old programs, @code{gawk} supports -this usage, but only for the @code{length} function. New programs should -@emph{not} call the @code{length} function this way. In particular, -this usage will not be portable to other @sc{posix} compliant versions -of @code{awk}. It is also poor style. - -@end ignore - -@node Language History, Installation, Command Line, Top -@chapter The Evolution of the @code{awk} Language - -This manual describes the GNU implementation of @code{awk}, which is patterned -after the @sc{posix} specification. Many @code{awk} users are only familiar -with the original @code{awk} implementation in Version 7 Unix, which is also -the basis for the version in Berkeley Unix (through 4.3--Reno). This chapter -briefly describes the evolution of the @code{awk} language. - -@menu -* V7/S5R3.1:: The major changes between V7 and - System V Release 3.1. -* S5R4:: Minor changes between System V - Releases 3.1 and 4. -* POSIX:: New features from the @sc{posix} standard. -* POSIX/GNU:: The extensions in @code{gawk} - not in @sc{posix} @code{awk}. -@end menu - -@node V7/S5R3.1, S5R4, Language History, Language History -@section Major Changes between V7 and S5R3.1 - -The @code{awk} language evolved considerably between the release of -Version 7 Unix (1978) and the new version first made widely available in -System V Release 3.1 (1987). This section summarizes the changes, with -cross-references to further details. - -@itemize @bullet -@item -The requirement for @samp{;} to separate rules on a line -(@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}). - -@item -User-defined functions, and the @code{return} statement -(@pxref{User-defined, ,User-defined Functions}). - -@item -The @code{delete} statement (@pxref{Delete, ,The @code{delete} Statement}). - -@item -The @code{do}-@code{while} statement -(@pxref{Do Statement, ,The @code{do}-@code{while} Statement}).@refill - -@item -The built-in functions @code{atan2}, @code{cos}, @code{sin}, @code{rand} and -@code{srand} (@pxref{Numeric Functions, ,Numeric Built-in Functions}). - -@item -The built-in functions @code{gsub}, @code{sub}, and @code{match} -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). - -@item -The built-in functions @code{close}, which closes an open file, and -@code{system}, which allows the user to execute operating system -commands (@pxref{I/O Functions, ,Built-in Functions for Input/Output}).@refill -@c Does the above verbiage prevents an overfull hbox? --mew, rjc 24jan1992 - -@item -The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART}, -and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}). - -@item -The conditional expression using the operators @samp{?} and @samp{:} -(@pxref{Conditional Exp, ,Conditional Expressions}).@refill - -@item -The exponentiation operator @samp{^} -(@pxref{Arithmetic Ops, ,Arithmetic Operators}) and its assignment operator -form @samp{^=} (@pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -C-compatible operator precedence, which breaks some old @code{awk} -programs (@pxref{Precedence, ,Operator Precedence (How Operators Nest)}). - -@item -Regexps as the value of @code{FS} -(@pxref{Field Separators, ,Specifying how Fields are Separated}), and as the -third argument to the @code{split} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@item -Dynamic regexps as operands of the @samp{~} and @samp{!~} operators -(@pxref{Regexp Usage, ,How to Use Regular Expressions}). - -@item -Escape sequences (@pxref{Constants, ,Constant Expressions}) in regexps.@refill - -@item -The escape sequences @samp{\b}, @samp{\f}, and @samp{\r} -(@pxref{Constants, ,Constant Expressions}). - -@item -Redirection of input for the @code{getline} function -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@item -Multiple @code{BEGIN} and @code{END} rules -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}).@refill - -@item -Simulated multi-dimensional arrays -(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill -@end itemize - -@node S5R4, POSIX, V7/S5R3.1, Language History -@section Changes between S5R3.1 and S5R4 - -The System V Release 4 version of Unix @code{awk} added these features -(some of which originated in @code{gawk}): - -@itemize @bullet -@item -The @code{ENVIRON} variable (@pxref{Built-in Variables}). - -@item -Multiple @samp{-f} options on the command line -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{-v} option for assigning variables before program execution begins -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{--} option for terminating command line options. - -@item -The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences -(@pxref{Constants, ,Constant Expressions}).@refill - -@item -A defined return value for the @code{srand} built-in function -(@pxref{Numeric Functions, ,Numeric Built-in Functions}). - -@item -The @code{toupper} and @code{tolower} built-in string functions -for case translation -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@item -A cleaner specification for the @samp{%c} format-control letter in the -@code{printf} function -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -@item -The ability to dynamically pass the field width and precision (@code{"%*.*d"}) -in the argument list of the @code{printf} function -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -@item -The use of constant regexps such as @code{/foo/} as expressions, where -they are equivalent to use of the matching operator, as in @code{$0 ~ -/foo/} (@pxref{Constants, ,Constant Expressions}). -@end itemize - -@node POSIX, POSIX/GNU, S5R4, Language History -@section Changes between S5R4 and POSIX @code{awk} - -The @sc{posix} Command Language and Utilities standard for @code{awk} -introduced the following changes into the language: - -@itemize @bullet{} -@item -The use of @samp{-W} for implementation-specific options. - -@item -The use of @code{CONVFMT} for controlling the conversion of numbers -to strings (@pxref{Conversion, ,Conversion of Strings and Numbers}). - -@item -The concept of a numeric string, and tighter comparison rules to go -with it (@pxref{Comparison Ops, ,Comparison Expressions}). - -@item -More complete documentation of many of the previously undocumented -features of the language. -@end itemize - -@node POSIX/GNU, , POSIX, Language History -@section Extensions in @code{gawk} not in POSIX @code{awk} - -The GNU implementation, @code{gawk}, adds these features: - -@itemize @bullet -@item -The @code{AWKPATH} environment variable for specifying a path search for -the @samp{-f} command line option -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The various @code{gawk} specific features available via the @samp{-W} -command line option (@pxref{Command Line, ,Invoking @code{awk}}). - -@item -The @code{ARGIND} variable, that tracks the movement of @code{FILENAME} -through @code{ARGV}. (@pxref{Built-in Variables}). - -@item -The @code{ERRNO} variable, that contains the system error message when -@code{getline} returns @minus{}1, or when @code{close} fails. -(@pxref{Built-in Variables}). - -@item -The @code{IGNORECASE} variable and its effects -(@pxref{Case-sensitivity, ,Case-sensitivity in Matching}).@refill - -@item -The @code{FIELDWIDTHS} variable and its effects -(@pxref{Constant Size, ,Reading Fixed-width Data}).@refill - -@item -The @code{next file} statement for skipping to the next data file -(@pxref{Next File Statement, ,The @code{next file} Statement}).@refill - -@item -The @code{systime} and @code{strftime} built-in functions for obtaining -and printing time stamps -(@pxref{Time Functions, ,Functions for Dealing with Time Stamps}).@refill - -@item -The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr}, and -@file{/dev/fd/@var{n}} file name interpretation -(@pxref{Special Files, ,Standard I/O Streams}).@refill - -@item -The @samp{-W compat} option to turn off these extensions -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{-W posix} option for full @sc{posix} compliance -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@end itemize - -@node Installation, Gawk Summary, Language History, Top -@chapter Installing @code{gawk} - -This chapter provides instructions for installing @code{gawk} on the -various platforms that are supported by the developers. The primary -developers support Unix (and one day, GNU), while the other ports were -contributed. The file @file{ACKNOWLEDGMENT} in the @code{gawk} -distribution lists the electronic mail addresses of the people who did -the respective ports.@refill - -@menu -* Gawk Distribution:: What is in the @code{gawk} distribution. -* Unix Installation:: Installing @code{gawk} under various versions - of Unix. -* VMS Installation:: Installing @code{gawk} on VMS. -* MS-DOS Installation:: Installing @code{gawk} on MS-DOS. -* Atari Installation:: Installing @code{gawk} on the Atari ST. -@end menu - -@node Gawk Distribution, Unix Installation, Installation, Installation -@section The @code{gawk} Distribution - -This section first describes how to get and extract the @code{gawk} -distribution, and then discusses what is in the various files and -subdirectories. - -@menu -* Extracting:: How to get and extract the distribution. -* Distribution contents:: What is in the distribution. -@end menu - -@node Extracting, Distribution contents, Gawk Distribution, Gawk Distribution -@subsection Getting the @code{gawk} Distribution - -@cindex getting gawk -@cindex anonymous ftp -@cindex anonymous uucp -@cindex ftp, anonymous -@cindex uucp, anonymous -@code{gawk} is distributed as a @code{tar} file compressed with the -GNU Zip program, @code{gzip}. You can -get it via anonymous @code{ftp} to the Internet host @code{prep.ai.mit.edu}. -Like all GNU software, it will be archived at other well known systems, -from which it will be possible to use some sort of anonymous @code{uucp} to -obtain the distribution as well. -You can also order @code{gawk} on tape or CD-ROM directly from the -Free Software Foundation. (The address is on the copyright page.) -Doing so directly contributes to the support of the foundation and to -the production of more free software. - -Once you have the distribution (for example, -@file{gawk-2.15.0.tar.z}), first use @code{gzip} to expand the -file, and then use @code{tar} to extract it. You can use the following -pipeline to produce the @code{gawk} distribution: - -@example -# Under System V, add 'o' to the tar flags -gzip -d -c gawk-2.15.0.tar.z | tar -xvpf - -@end example - -@noindent -This will create a directory named @file{gawk-2.15} in the current -directory. - -The distribution file name is of the form @file{gawk-2.15.@var{n}.tar.Z}. -The @var{n} represents a @dfn{patchlevel}, meaning that minor bugs have -been fixed in the major release. The current patchlevel is 0, but when -retrieving distributions, you should get the version with the highest -patchlevel.@refill - -If you are not on a Unix system, you will need to make other arrangements -for getting and extracting the @code{gawk} distribution. You should consult -a local expert. - -@node Distribution contents, , Extracting, Gawk Distribution -@subsection Contents of the @code{gawk} Distribution - -@code{gawk} has a number of C source files, documentation files, -subdirectories and files related to the configuration process -(@pxref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}), -and several subdirectories related to different, non-Unix, -operating systems.@refill - -@table @asis -@item various @samp{.c}, @samp{.y}, and @samp{.h} files - -The C and YACC source files are the actual @code{gawk} source code. -@end table - -@table @file -@item README -@itemx README.VMS -@itemx README.dos -@itemx README.rs6000 -@itemx README.ultrix -Descriptive files: @file{README} for @code{gawk} under Unix, and the -rest for the various hardware and software combinations. - -@item PORTS -A list of systems to which @code{gawk} has been ported, and which -have successfully run the test suite. - -@item ACKNOWLEDGMENT -A list of the people who contributed major parts of the code or documentation. - -@item NEWS -A list of changes to @code{gawk} since the last release or patch. - -@item COPYING -The GNU General Public License. - -@item FUTURES -A brief list of features and/or changes being contemplated for future -releases, with some indication of the time frame for the feature, based -on its difficulty. - -@item LIMITATIONS -A list of those factors that limit @code{gawk}'s performance. -Most of these depend on the hardware or operating system software, and -are not limits in @code{gawk} itself.@refill - -@item PROBLEMS -A file describing known problems with the current release. - -@item gawk.1 -The @code{troff} source for a manual page describing @code{gawk}. - -@item gawk.texinfo -@ifinfo -The @code{texinfo} source file for this Info file. -It should be processed with @TeX{} to produce a printed manual, and -with @code{makeinfo} to produce the Info file.@refill -@end ifinfo -@iftex -The @code{texinfo} source file for this manual. -It should be processed with @TeX{} to produce a printed manual, and -with @code{makeinfo} to produce the Info file.@refill -@end iftex - -@item Makefile.in -@itemx config -@itemx config.in -@itemx configure -@itemx missing -@itemx mungeconf -These files and subdirectories are used when configuring @code{gawk} -for various Unix systems. They are explained in detail in -@ref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}.@refill - -@item atari -Files needed for building @code{gawk} on an Atari ST. -@xref{Atari Installation, ,Installing @code{gawk} on the Atari ST}, for details. - -@item pc -Files needed for building @code{gawk} under MS-DOS. -@xref{MS-DOS Installation, ,Installing @code{gawk} on MS-DOS}, for details. - -@item vms -Files needed for building @code{gawk} under VMS. -@xref{VMS Installation, ,Compiling Installing and Running @code{gawk} on VMS}, for details. - -@item test -Many interesting @code{awk} programs, provided as a test suite for -@code{gawk}. You can use @samp{make test} from the top level @code{gawk} -directory to run your version of @code{gawk} against the test suite. -@c There are many programs here that are useful in their own right. -If @code{gawk} successfully passes @samp{make test} then you can -be confident of a successful port.@refill -@end table - -@node Unix Installation, VMS Installation, Gawk Distribution, Installation -@section Compiling and Installing @code{gawk} on Unix - -Often, you can compile and install @code{gawk} by typing only two -commands. However, if you do not use a supported system, you may need -to configure @code{gawk} for your system yourself. - -@menu -* Quick Installation:: Compiling @code{gawk} on a - supported Unix version. -* Configuration Philosophy:: How it's all supposed to work. -* New Configurations:: What to do if there is no supplied - configuration for your system. -@end menu - -@node Quick Installation, Configuration Philosophy, Unix Installation, Unix Installation -@subsection Compiling @code{gawk} for a Supported Unix Version - -@cindex installation, unix -After you have extracted the @code{gawk} distribution, @code{cd} -to @file{gawk-2.15}. Look in the @file{config} subdirectory for a -file that matches your hardware/software combination. In general, -only the software is relevant; for example @code{sunos41} is used -for SunOS 4.1, on both Sun 3 and Sun 4 hardware.@refill - -If you find such a file, run the command: - -@example -# assume you have SunOS 4.1 -./configure sunos41 -@end example - -This produces a @file{Makefile} and @file{config.h} tailored to your -system. You may wish to edit the @file{Makefile} to use a different -C compiler, such as @code{gcc}, the GNU C compiler, if you have it. -You may also wish to change the @code{CFLAGS} variable, which controls -the command line options that are passed to the C compiler (such as -optimization levels, or compiling for debugging).@refill - -After you have configured @file{Makefile} and @file{config.h}, type: - -@example -make -@end example - -@noindent -and shortly thereafter, you should have an executable version of @code{gawk}. -That's all there is to it! - -@node Configuration Philosophy, New Configurations, Quick Installation, Unix Installation -@subsection The Configuration Process - -(This section is of interest only if you know something about using the -C language and the Unix operating system.) - -The source code for @code{gawk} generally attempts to adhere to industry -standards wherever possible. This means that @code{gawk} uses library -routines that are specified by the @sc{ansi} C standard and by the @sc{posix} -operating system interface standard. When using an @sc{ansi} C compiler, -function prototypes are provided to help improve the compile-time checking. - -Many older Unix systems do not support all of either the @sc{ansi} or the -@sc{posix} standards. The @file{missing} subdirectory in the @code{gawk} -distribution contains replacement versions of those subroutines that are -most likely to be missing. - -The @file{config.h} file that is created by the @code{configure} program -contains definitions that describe features of the particular operating -system where you are attempting to compile @code{gawk}. For the most -part, it lists which standard subroutines are @emph{not} available. -For example, if your system lacks the @samp{getopt} routine, then -@samp{GETOPT_MISSING} would be defined. - -@file{config.h} also defines constants that describe facts about your -variant of Unix. For example, there may not be an @samp{st_blksize} -element in the @code{stat} structure. In this case @samp{BLKSIZE_MISSING} -would be defined. - -Based on the list in @file{config.h} of standard subroutines that are -missing, @file{missing.c} will do a @samp{#include} of the appropriate -file(s) from the @file{missing} subdirectory.@refill - -Conditionally compiled code in the other source files relies on the -other definitions in the @file{config.h} file. - -Besides creating @file{config.h}, @code{configure} produces a @file{Makefile} -from @file{Makefile.in}. There are a number of lines in @file{Makefile.in} -that are system or feature specific. For example, there is line that begins -with @samp{##MAKE_ALLOCA_C##}. This is normally a comment line, since -it starts with @samp{#}. If a configuration file has @samp{MAKE_ALLOCA_C} -in it, then @code{configure} will delete the @samp{##MAKE_ALLOCA_C##} -from the beginning of the line. This will enable the rules in the -@file{Makefile} that use a C version of @samp{alloca}. There are several -similar features that work in this fashion.@refill - -@node New Configurations, , Configuration Philosophy, Unix Installation -@subsection Configuring @code{gawk} for a New System - -(This section is of interest only if you know something about using the -C language and the Unix operating system, and if you have to install -@code{gawk} on a system that is not supported by the @code{gawk} distribution. -If you are a C or Unix novice, get help from a local expert.) - -If you need to configure @code{gawk} for a Unix system that is not -supported in the distribution, first see -@ref{Configuration Philosophy, ,The Configuration Process}. -Then, copy @file{config.in} to @file{config.h}, and copy -@file{Makefile.in} to @file{Makefile}.@refill - -Next, edit both files. Both files are liberally commented, and the -necessary changes should be straightforward. - -While editing @file{config.h}, you need to determine what library -routines you do or do not have by consulting your system documentation, or -by perusing your actual libraries using the @code{ar} or @code{nm} utilities. -In the worst case, simply do not define @emph{any} of the macros for missing -subroutines. When you compile @code{gawk}, the final link-editing step -will fail. The link editor will provide you with a list of unresolved external -references---these are the missing subroutines. Edit @file{config.h} again -and recompile, and you should be set.@refill - -Editing the @file{Makefile} should also be straightforward. Enable or -disable the lines that begin with @samp{##MAKE_@var{whatever}##}, as -appropriate. Select the correct C compiler and @code{CFLAGS} for it. -Then run @code{make}. - -Getting a correct configuration is likely to be an iterative process. -Do not be discouraged if it takes you several tries. If you have no -luck whatsoever, please report your system type, and the steps you took. -Once you do have a working configuration, please send it to the maintainers -so that support for your system can be added to the official release. - -@xref{Bugs, ,Reporting Problems and Bugs}, for information on how to report -problems in configuring @code{gawk}. You may also use the same mechanisms -for sending in new configurations.@refill - -@node VMS Installation, MS-DOS Installation, Unix Installation, Installation -@section Compiling, Installing, and Running @code{gawk} on VMS - -@c based on material from -@c Pat Rankin - -@cindex installation, vms -This section describes how to compile and install @code{gawk} under VMS. - -@menu -* VMS Compilation:: How to compile @code{gawk} under VMS. -* VMS Installation Details:: How to install @code{gawk} under VMS. -* VMS Running:: How to run @code{gawk} under VMS. -* VMS POSIX:: Alternate instructions for VMS POSIX. -@end menu - -@node VMS Compilation, VMS Installation Details, VMS Installation, VMS Installation -@subsection Compiling @code{gawk} under VMS - -To compile @code{gawk} under VMS, there is a @code{DCL} command procedure that -will issue all the necessary @code{CC} and @code{LINK} commands, and there is -also a @file{Makefile} for use with the @code{MMS} utility. From the source -directory, use either - -@smallexample -$ @@[.VMS]VMSBUILD.COM -@end smallexample - -@noindent -or - -@smallexample -$ MMS/DESCRIPTION=[.VMS]DECSRIP.MMS GAWK -@end smallexample - -Depending upon which C compiler you are using, follow one of the sets -of instructions in this table: - -@table @asis -@item VAX C V3.x -Use either @file{vmsbuild.com} or @file{descrip.mms} as is. These use -@code{CC/OPTIMIZE=NOLINE}, which is essential for Version 3.0. - -@item VAX C V2.x -You must have Version 2.3 or 2.4; older ones won't work. Edit either -@file{vmsbuild.com} or @file{descrip.mms} according to the comments in them. -For @file{vmsbuild.com}, this just entails removing two @samp{!} delimiters. -Also edit @file{config.h} (which is a copy of file @file{[.config]vms-conf.h}) -and comment out or delete the two lines @samp{#define __STDC__ 0} and -@samp{#define VAXC_BUILTINS} near the end.@refill - -@item GNU C -Edit @file{vmsbuild.com} or @file{descrip.mms}; the changes are different -from those for VAX C V2.x, but equally straightforward. No changes to -@file{config.h} should be needed. - -@item DEC C -Edit @file{vmsbuild.com} or @file{descrip.mms} according to their comments. -No changes to @file{config.h} should be needed. -@end table - -@code{gawk} 2.15 has been tested under VAX/VMS 5.5-1 using VAX C V3.2, -GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up. - -@node VMS Installation Details, VMS Running, VMS Compilation, VMS Installation -@subsection Installing @code{gawk} on VMS - -To install @code{gawk}, all you need is a ``foreign'' command, which is -a @code{DCL} symbol whose value begins with a dollar sign. - -@smallexample -$ GAWK :== $device:[directory]GAWK -@end smallexample - -@noindent -(Substitute the actual location of @code{gawk.exe} for -@samp{device:[directory]}.) The symbol should be placed in the -@file{login.com} of any user who wishes to run @code{gawk}, -so that it will be defined every time the user logs on. -Alternatively, the symbol may be placed in the system-wide -@file{sylogin.com} procedure, which will allow all users -to run @code{gawk}.@refill - -Optionally, the help entry can be loaded into a VMS help library: - -@smallexample -$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP -@end smallexample - -@noindent -(You may want to substitute a site-specific help library rather than -the standard VMS library @samp{HELPLIB}.) After loading the help text, - -@c this is so tiny, but `should' be smallexample for consistency sake... -@c I didn't because it was so short. --mew 29jan1992 -@example -$ HELP GAWK -@end example - -@noindent -will provide information about both the @code{gawk} implementation and the -@code{awk} programming language. - -The logical name @samp{AWK_LIBRARY} can designate a default location -for @code{awk} program files. For the @samp{-f} option, if the specified -filename has no device or directory path information in it, @code{gawk} -will look in the current directory first, then in the directory specified -by the translation of @samp{AWK_LIBRARY} if the file was not found. -If after searching in both directories, the file still is not found, -then @code{gawk} appends the suffix @samp{.awk} to the filename and the -file search will be re-tried. If @samp{AWK_LIBRARY} is not defined, that -portion of the file search will fail benignly.@refill - -@node VMS Running, VMS POSIX, VMS Installation Details, VMS Installation -@subsection Running @code{gawk} on VMS - -Command line parsing and quoting conventions are significantly different -on VMS, so examples in this manual or from other sources often need minor -changes. They @emph{are} minor though, and all @code{awk} programs -should run correctly. - -Here are a couple of trivial tests: - -@smallexample -$ gawk -- "BEGIN @{print ""Hello, World!""@}" -$ gawk -"W" version ! could also be -"W version" or "-W version" -@end smallexample - -@noindent -Note that upper-case and mixed-case text must be quoted. - -The VMS port of @code{gawk} includes a @code{DCL}-style interface in addition -to the original shell-style interface (see the help entry for details). -One side-effect of dual command line parsing is that if there is only a -single parameter (as in the quoted string program above), the command -becomes ambiguous. To work around this, the normally optional @samp{--} -flag is required to force Unix style rather than @code{DCL} parsing. If any -other dash-type options (or multiple parameters such as data files to be -processed) are present, there is no ambiguity and @samp{--} can be omitted. - -The default search path when looking for @code{awk} program files specified -by the @samp{-f} option is @code{"SYS$DISK:[],AWK_LIBRARY:"}. The logical -name @samp{AWKPATH} can be used to override this default. The format -of @samp{AWKPATH} is a comma-separated list of directory specifications. -When defining it, the value should be quoted so that it retains a single -translation, and not a multi-translation @code{RMS} searchlist. - -@node VMS POSIX, , VMS Running, VMS Installation -@subsection Building and using @code{gawk} under VMS POSIX - -Ignore the instructions above, although @file{vms/gawk.hlp} should still -be made available in a help library. Make sure that the two scripts, -@file{configure} and @file{mungeconf}, are executable; use @samp{chmod +x} -on them if necessary. Then execute the following commands: - -@smallexample -$ POSIX -psx> configure vms-posix -psx> make awktab.c gawk -@end smallexample - -@noindent -The first command will construct files @file{config.h} and @file{Makefile} -out of templates. The second command will compile and link @code{gawk}. -Due to a @code{make} bug in VMS POSIX V1.0 and V1.1, -the file @file{awktab.c} must be given as an explicit target or it will -not be built and the final link step will fail. Ignore the warning -@samp{"Could not find lib m in lib list"}; it is harmless, caused by the -explicit use of @samp{-lm} as a linker option which is not needed -under VMS POSIX. Under V1.1 (but not V1.0) a problem with the @code{yacc} -skeleton @file{/etc/yyparse.c} will cause a compiler warning for -@file{awktab.c}, followed by a linker warning about compilation warnings -in the resulting object module. These warnings can be ignored.@refill - -Once built, @code{gawk} will work like any other shell utility. Unlike -the normal VMS port of @code{gawk}, no special command line manipulation is -needed in the VMS POSIX environment. - -@node MS-DOS Installation, Atari Installation, VMS Installation, Installation -@section Installing @code{gawk} on MS-DOS - -@cindex installation, ms-dos -The first step is to get all the files in the @code{gawk} distribution -onto your PC. Move all the files from the @file{pc} directory into -the main directory where the other files are. Edit the file -@file{make.bat} so that it will be an acceptable MS-DOS batch file. -This means making sure that all lines are terminated with the ASCII -carriage return and line feed characters. -restrictions. - -@code{gawk} has only been compiled with version 5.1 of the Microsoft -C compiler. The file @file{make.bat} from the @file{pc} directory -assumes that you have this compiler. - -Copy the file @file{setargv.obj} from the library directory where it -resides to the @code{gawk} source code directory. - -Run @file{make.bat}. This will compile @code{gawk} for you, and link it. -That's all there is to it! - -@node Atari Installation, , MS-DOS Installation, Installation -@section Installing @code{gawk} on the Atari ST - -@c based on material from -@c Michal Jaegermann - -@cindex installation, atari -This section assumes that you are running TOS. It applies to other Atari -models (STe, TT) as well. - -In order to use @code{gawk}, you need to have a shell, either text or -graphics, that does not map all the characters of a command line to -upper case. Maintaining case distinction in option flags is very -important (@pxref{Command Line, ,Invoking @code{awk}}). Popular shells -like @code{gulam} or @code{gemini} will work, as will newer versions of -@code{desktop}. Support for I/O redirection is necessary to make it easy -to import @code{awk} programs from other environments. Pipes are nice to have, -but not vital. - -If you have received an executable version of @code{gawk}, place it, -as usual, anywhere in your @code{PATH} where your shell will find it. - -While executing, @code{gawk} creates a number of temporary files. -@code{gawk} looks for either of the environment variables @code{TEMP} -or @code{TMPDIR}, in that order. If either one is found, its value -is assumed to be a directory for temporary files. This directory -must exist, and if you can spare the memory, it is a good idea to -put it on a @sc{ram} drive. If neither @code{TEMP} nor @code{TMPDIR} -are found, then @code{gawk} uses the current directory for its -temporary files. - -The ST version of @code{gawk} searches for its program files as -described in @ref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}. -On the ST, the default value for the @code{AWKPATH} variable is -@code{@w{".,c:\lib\awk,c:\gnu\lib\awk"}}. -The search path can be modified by explicitly setting @code{AWKPATH} to -whatever you wish. Note that colons cannot be used on the ST to separate -elements in the @code{AWKPATH} variable, since they have another, reserved, -meaning. Instead, you must use a comma to separate elements in the path. -If you are recompiling @code{gawk} on the ST, then you can choose a new -default search path, by setting the value of @samp{DEFPATH} in the file -@file{...\config\atari}. You may choose a different separator character -by setting the value of @samp{ENVSEP} in the same file. The new values will -be used when creating the header file @file{config.h}.@refill - -@ignore -As a last resort, small -adjustments can be made directly on the executable version of @code{gawk} -using a binary editor.@refill -@end ignore - -Although @code{awk} allows great flexibility in doing I/O redirections -from within a program, this facility should be used with care on the ST. -In some circumstances the OS routines for file handle pool processing -lose track of certain events, causing the computer to crash, and requiring -a reboot. Often a warm reboot is sufficient. Fortunately, this happens -infrequently, and in rather esoteric situations. In particular, avoid -having one part of an @code{awk} program using @code{print} -statements explicitly redirected to @code{"/dev/stdout"}, while other -@code{print} statements use the default standard output, and a -calling shell has redirected standard output to a file.@refill -@c whew! - -When @code{gawk} is compiled with the ST version of @code{gcc} and its -usual libraries, it will accept both @samp{/} and @samp{\} as path separators. -While this is convenient, it should be remembered that this removes one, -technically legal, character (@samp{/}) from your file names, and that -it may create problems for external programs, called via the @code{system()} -function, which may not support this convention. Whenever it is possible -that a file created by @code{gawk} will be used by some other program, -use only backslashes. Also remember that in @code{awk}, backslashes in -strings have to be doubled in order to get literal backslashes. - -The initial port of @code{gawk} to the ST was done with @code{gcc}. -If you wish to recompile @code{gawk} from scratch, you will need to use -a compiler that accepts @sc{ansi} standard C (such as @code{gcc}, Turbo C, -or Prospero C). If @code{sizeof(int) != @w{sizeof(int *)}}, the correctness -of the generated code depends heavily on the fact that all function calls -have function prototypes in the current scope. If your compiler does -not accept function prototypes, you will probably have to add a -number of casts to the code.@refill - -If you are using @code{gcc}, make sure that you have up-to-date libraries. -Older versions have problems with some library functions (@code{atan2()}, -@code{strftime()}, the @samp{%g} conversion in @code{sprintf()}) which -may affect the operation of @code{gawk}. - -In the @file{atari} subdirectory of the @code{gawk} distribution is -a version of the @code{system()} function that has been tested with -@code{gulam} and @code{msh}; it should work with other shells as well. -With @code{gulam}, it passes the string to be executed without spawning -an extra copy of a shell. It is possible to replace this version of -@code{system()} with a similar function from a library or from some other -source if that version would be a better choice for the shell you prefer. - -The files needed to recompile @code{gawk} on the ST can be found in -the @file{atari} directory. The provided files and instructions below -assume that you have the GNU C compiler (@code{gcc}), the @code{gulam} shell, -and an ST version of @code{sed}. The @file{Makefile} is set up to use -@file{byacc} as a @file{yacc} replacement. With a different set of tools some -adjustments and/or editing will be needed.@refill - -@code{cd} to the @file{atari} directory. Copy @file{Makefile.st} to -@file{makefile} in the source (parent) directory. Possibly adjust -@file{../config/atari} to suit your system. Execute the script @file{mkconf.g} -which will create the header file @file{../config.h}. Go back to the source -directory. If you are not using @code{gcc}, check the file @file{missing.c}. -It may be necessary to change forward slashes in the references to files -from the @file{atari} subdirectory into backslashes. Type @code{make} and -enjoy.@refill - -Compilation with @code{gcc} of some of the bigger modules, like -@file{awk_tab.c}, may require a full four megabytes of memory. On smaller -machines you would need to cut down on optimizations, or you would have to -switch to another, less memory hungry, compiler.@refill - -@node Gawk Summary, Sample Program, Installation, Top -@appendix @code{gawk} Summary - -This appendix provides a brief summary of the @code{gawk} command line and the -@code{awk} language. It is designed to serve as ``quick reference.'' It is -therefore terse, but complete. - -@menu -* Command Line Summary:: Recapitulation of the command line. -* Language Summary:: A terse review of the language. -* Variables/Fields:: Variables, fields, and arrays. -* Rules Summary:: Patterns and Actions, and their - component parts. -* Functions Summary:: Defining and calling functions. -* Historical Features:: Some undocumented but supported ``features''. -@end menu - -@node Command Line Summary, Language Summary, Gawk Summary, Gawk Summary -@appendixsec Command Line Options Summary - -The command line consists of options to @code{gawk} itself, the -@code{awk} program text (if not supplied via the @samp{-f} option), and -values to be made available in the @code{ARGC} and @code{ARGV} -predefined @code{awk} variables: - -@example -awk @r{[@var{POSIX or GNU style options}]} -f source-file @r{[@code{--}]} @var{file} @dots{} -awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{} -@end example - -The options that @code{gawk} accepts are: - -@table @code -@item -F @var{fs} -@itemx --field-separator=@var{fs} -Use @var{fs} for the input field separator (the value of the @code{FS} -predefined variable). - -@item -f @var{program-file} -@itemx --file=@var{program-file} -Read the @code{awk} program source from the file @var{program-file}, instead -of from the first command line argument. - -@item -v @var{var}=@var{val} -@itemx --assign=@var{var}=@var{val} -Assign the variable @var{var} the value @var{val} before program execution -begins. - -@item -W compat -@itemx --compat -Specifies compatibility mode, in which @code{gawk} extensions are turned -off. - -@item -W copyleft -@itemx -W copyright -@itemx --copyleft -@itemx --copyright -Print the short version of the General Public License on the error -output. This option may disappear in a future version of @code{gawk}. - -@item -W help -@itemx -W usage -@itemx --help -@itemx --usage -Print a relatively short summary of the available options on the error output. - -@item -W lint -@itemx --lint -Give warnings about dubious or non-portable @code{awk} constructs. - -@item -W posix -@itemx --posix -Specifies @sc{posix} compatibility mode, in which @code{gawk} extensions -are turned off and additional restrictions apply. - -@item -W source=@var{program-text} -@itemx --source=@var{program-text} -Use @var{program-text} as @code{awk} program source code. This option allows -mixing command line source code with source code from files, and is -particularly useful for mixing command line programs with library functions. - -@item -W version -@itemx --version -Print version information for this particular copy of @code{gawk} on the error -output. This option may disappear in a future version of @code{gawk}. - -@item -- -Signal the end of options. This is useful to allow further arguments to the -@code{awk} program itself to start with a @samp{-}. This is mainly for -consistency with the argument parsing conventions of @sc{posix}. -@end table - -Any other options are flagged as invalid, but are otherwise ignored. -@xref{Command Line, ,Invoking @code{awk}}, for more details. - -@node Language Summary, Variables/Fields, Command Line Summary, Gawk Summary -@appendixsec Language Summary - -An @code{awk} program consists of a sequence of pattern-action statements -and optional function definitions. - -@example -@var{pattern} @{ @var{action statements} @} - -function @var{name}(@var{parameter list}) @{ @var{action statements} @} -@end example - -@code{gawk} first reads the program source from the -@var{program-file}(s) if specified, or from the first non-option -argument on the command line. The @samp{-f} option may be used multiple -times on the command line. @code{gawk} reads the program text from all -the @var{program-file} files, effectively concatenating them in the -order they are specified. This is useful for building libraries of -@code{awk} functions, without having to include them in each new -@code{awk} program that uses them. To use a library function in a file -from a program typed in on the command line, specify @samp{-f /dev/tty}; -then type your program, and end it with a @kbd{Control-d}. -@xref{Command Line, ,Invoking @code{awk}}.@refill - -The environment variable @code{AWKPATH} specifies a search path to use -when finding source files named with the @samp{-f} option. The default -path, which is -@samp{.:/usr/lib/awk:/usr/local/lib/awk} is used if @code{AWKPATH} is not set. -If a file name given to the @samp{-f} option contains a @samp{/} character, -no path search is performed. -@xref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}, -for a full description of the @code{AWKPATH} environment variable.@refill - -@code{gawk} compiles the program into an internal form, and then proceeds to -read each file named in the @code{ARGV} array. If there are no files named -on the command line, @code{gawk} reads the standard input. - -If a ``file'' named on the command line has the form -@samp{@var{var}=@var{val}}, it is treated as a variable assignment: the -variable @var{var} is assigned the value @var{val}. -If any of the files have a value that is the null string, that -element in the list is skipped.@refill - -For each line in the input, @code{gawk} tests to see if it matches any -@var{pattern} in the @code{awk} program. For each pattern that the line -matches, the associated @var{action} is executed. - -@node Variables/Fields, Rules Summary, Language Summary, Gawk Summary -@appendixsec Variables and Fields - -@code{awk} variables are dynamic; they come into existence when they are -first used. Their values are either floating-point numbers or strings. -@code{awk} also has one-dimension arrays; multiple-dimensional arrays -may be simulated. There are several predefined variables that -@code{awk} sets as a program runs; these are summarized below. - -@menu -* Fields Summary:: Input field splitting. -* Built-in Summary:: @code{awk}'s built-in variables. -* Arrays Summary:: Using arrays. -* Data Type Summary:: Values in @code{awk} are numbers or strings. -@end menu - -@node Fields Summary, Built-in Summary, Variables/Fields, Variables/Fields -@appendixsubsec Fields - -As each input line is read, @code{gawk} splits the line into -@var{fields}, using the value of the @code{FS} variable as the field -separator. If @code{FS} is a single character, fields are separated by -that character. Otherwise, @code{FS} is expected to be a full regular -expression. In the special case that @code{FS} is a single blank, -fields are separated by runs of blanks and/or tabs. Note that the value -of @code{IGNORECASE} (@pxref{Case-sensitivity, ,Case-sensitivity in Matching}) -also affects how fields are split when @code{FS} is a regular expression.@refill - -Each field in the input line may be referenced by its position, @code{$1}, -@code{$2}, and so on. @code{$0} is the whole line. The value of a field may -be assigned to as well. Field numbers need not be constants: - -@example -n = 5 -print $n -@end example - -@noindent -prints the fifth field in the input line. The variable @code{NF} is set to -the total number of fields in the input line. - -References to nonexistent fields (i.e., fields after @code{$NF}) return -the null-string. However, assigning to a nonexistent field (e.g., -@code{$(NF+2) = 5}) increases the value of @code{NF}, creates any -intervening fields with the null string as their value, and causes the -value of @code{$0} to be recomputed, with the fields being separated by -the value of @code{OFS}.@refill - -@xref{Reading Files, ,Reading Input Files}, for a full description of the -way @code{awk} defines and uses fields. - -@node Built-in Summary, Arrays Summary, Fields Summary, Variables/Fields -@appendixsubsec Built-in Variables - -@code{awk}'s built-in variables are: - -@table @code -@item ARGC -The number of command line arguments (not including options or the -@code{awk} program itself). - -@item ARGIND -The index in @code{ARGV} of the current file being processed. -It is always true that @samp{FILENAME == ARGV[ARGIND]}. - -@item ARGV -The array of command line arguments. The array is indexed from 0 to -@code{ARGC} @minus{} 1. Dynamically changing the contents of @code{ARGV} -can control the files used for data.@refill - -@item CONVFMT -The conversion format to use when converting numbers to strings. - -@item FIELDWIDTHS -A space separated list of numbers describing the fixed-width input data. - -@item ENVIRON -An array containing the values of the environment variables. The array -is indexed by variable name, each element being the value of that -variable. Thus, the environment variable @code{HOME} would be in -@code{ENVIRON["HOME"]}. Its value might be @file{/u/close}. - -Changing this array does not affect the environment seen by programs -which @code{gawk} spawns via redirection or the @code{system} function. -(This may change in a future version of @code{gawk}.) - -Some operating systems do not have environment variables. -The array @code{ENVIRON} is empty when running on these systems. - -@item ERRNO -The system error message when an error occurs using @code{getline} -or @code{close}. - -@item FILENAME -The name of the current input file. If no files are specified on the command -line, the value of @code{FILENAME} is @samp{-}. - -@item FNR -The input record number in the current input file. - -@item FS -The input field separator, a blank by default. - -@item IGNORECASE -The case-sensitivity flag for regular expression operations. If -@code{IGNORECASE} has a nonzero value, then pattern matching in rules, -field splitting with @code{FS}, regular expression matching with -@samp{~} and @samp{!~}, and the @code{gsub}, @code{index}, @code{match}, -@code{split} and @code{sub} predefined functions all ignore case -when doing regular expression operations.@refill - -@item NF -The number of fields in the current input record. - -@item NR -The total number of input records seen so far. - -@item OFMT -The output format for numbers for the @code{print} statement, -@code{"%.6g"} by default. - -@item OFS -The output field separator, a blank by default. - -@item ORS -The output record separator, by default a newline. - -@item RS -The input record separator, by default a newline. @code{RS} is exceptional -in that only the first character of its string value is used for separating -records. If @code{RS} is set to the null string, then records are separated by -blank lines. When @code{RS} is set to the null string, then the newline -character always acts as a field separator, in addition to whatever value -@code{FS} may have.@refill - -@item RSTART -The index of the first character matched by @code{match}; 0 if no match. - -@item RLENGTH -The length of the string matched by @code{match}; @minus{}1 if no match. - -@item SUBSEP -The string used to separate multiple subscripts in array elements, by -default @code{"\034"}. -@end table - -@xref{Built-in Variables}, for more information. - -@node Arrays Summary, Data Type Summary, Built-in Summary, Variables/Fields -@appendixsubsec Arrays - -Arrays are subscripted with an expression between square brackets -(@samp{[} and @samp{]}). Array subscripts are @emph{always} strings; -numbers are converted to strings as necessary, following the standard -conversion rules -(@pxref{Conversion, ,Conversion of Strings and Numbers}).@refill - -If you use multiple expressions separated by commas inside the square -brackets, then the array subscript is a string consisting of the -concatenation of the individual subscript values, converted to strings, -separated by the subscript separator (the value of @code{SUBSEP}). - -The special operator @code{in} may be used in an @code{if} or -@code{while} statement to see if an array has an index consisting of a -particular value. - -@example -if (val in array) - print array[val] -@end example - -If the array has multiple subscripts, use @code{(i, j, @dots{}) in array} -to test for existence of an element. - -The @code{in} construct may also be used in a @code{for} loop to iterate -over all the elements of an array. -@xref{Scanning an Array, ,Scanning all Elements of an Array}.@refill - -An element may be deleted from an array using the @code{delete} statement. - -@xref{Arrays, ,Arrays in @code{awk}}, for more detailed information. - -@node Data Type Summary, , Arrays Summary, Variables/Fields -@appendixsubsec Data Types - -The value of an @code{awk} expression is always either a number -or a string. - -Certain contexts (such as arithmetic operators) require numeric -values. They convert strings to numbers by interpreting the text -of the string as a numeral. If the string does not look like a -numeral, it converts to 0. - -Certain contexts (such as concatenation) require string values. -They convert numbers to strings by effectively printing them -with @code{sprintf}. -@xref{Conversion, ,Conversion of Strings and Numbers}, for the details.@refill - -To force conversion of a string value to a number, simply add 0 -to it. If the value you start with is already a number, this -does not change it. - -To force conversion of a numeric value to a string, concatenate it with -the null string. - -The @code{awk} language defines comparisons as being done numerically if -both operands are numeric, or if one is numeric and the other is a numeric -string. Otherwise one or both operands are converted to strings and a -string comparison is performed. - -Uninitialized variables have the string value @code{""} (the null, or -empty, string). In contexts where a number is required, this is -equivalent to 0. - -@xref{Variables}, for more information on variable naming and initialization; -@pxref{Conversion, ,Conversion of Strings and Numbers}, for more information -on how variable values are interpreted.@refill - -@node Rules Summary, Functions Summary, Variables/Fields, Gawk Summary -@appendixsec Patterns and Actions - -@menu -* Pattern Summary:: Quick overview of patterns. -* Regexp Summary:: Quick overview of regular expressions. -* Actions Summary:: Quick overview of actions. -@end menu - -An @code{awk} program is mostly composed of rules, each consisting of a -pattern followed by an action. The action is enclosed in @samp{@{} and -@samp{@}}. Either the pattern may be missing, or the action may be -missing, but, of course, not both. If the pattern is missing, the -action is executed for every single line of input. A missing action is -equivalent to this action, - -@example -@{ print @} -@end example - -@noindent -which prints the entire line. - -Comments begin with the @samp{#} character, and continue until the end of the -line. Blank lines may be used to separate statements. Normally, a statement -ends with a newline, however, this is not the case for lines ending in a -@samp{,}, @samp{@{}, @samp{?}, @samp{:}, @samp{&&}, or @samp{||}. Lines -ending in @code{do} or @code{else} also have their statements automatically -continued on the following line. In other cases, a line can be continued by -ending it with a @samp{\}, in which case the newline is ignored.@refill - -Multiple statements may be put on one line by separating them with a @samp{;}. -This applies to both the statements within the action part of a rule (the -usual case), and to the rule statements. - -@xref{Comments, ,Comments in @code{awk} Programs}, for information on -@code{awk}'s commenting convention; -@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a -description of the line continuation mechanism in @code{awk}.@refill - -@node Pattern Summary, Regexp Summary, Rules Summary, Rules Summary -@appendixsubsec Patterns - -@code{awk} patterns may be one of the following: - -@example -/@var{regular expression}/ -@var{relational expression} -@var{pattern} && @var{pattern} -@var{pattern} || @var{pattern} -@var{pattern} ? @var{pattern} : @var{pattern} -(@var{pattern}) -! @var{pattern} -@var{pattern1}, @var{pattern2} -BEGIN -END -@end example - -@code{BEGIN} and @code{END} are two special kinds of patterns that are not -tested against the input. The action parts of all @code{BEGIN} rules are -merged as if all the statements had been written in a single @code{BEGIN} -rule. They are executed before any of the input is read. Similarly, all the -@code{END} rules are merged, and executed when all the input is exhausted (or -when an @code{exit} statement is executed). @code{BEGIN} and @code{END} -patterns cannot be combined with other patterns in pattern expressions. -@code{BEGIN} and @code{END} rules cannot have missing action parts.@refill - -For @samp{/@var{regular-expression}/} patterns, the associated statement is -executed for each input line that matches the regular expression. Regular -expressions are extensions of those in @code{egrep}, and are summarized below. - -A @var{relational expression} may use any of the operators defined below in -the section on actions. These generally test whether certain fields match -certain regular expressions. - -The @samp{&&}, @samp{||}, and @samp{!} operators are logical ``and,'' -logical ``or,'' and logical ``not,'' respectively, as in C. They do -short-circuit evaluation, also as in C, and are used for combining more -primitive pattern expressions. As in most languages, parentheses may be -used to change the order of evaluation. - -The @samp{?:} operator is like the same operator in C. If the first -pattern matches, then the second pattern is matched against the input -record; otherwise, the third is matched. Only one of the second and -third patterns is matched. - -The @samp{@var{pattern1}, @var{pattern2}} form of a pattern is called a -range pattern. It matches all input lines starting with a line that -matches @var{pattern1}, and continuing until a line that matches -@var{pattern2}, inclusive. A range pattern cannot be used as an operand -to any of the pattern operators. - -@xref{Patterns}, for a full description of the pattern part of @code{awk} -rules. - -@node Regexp Summary, Actions Summary, Pattern Summary, Rules Summary -@appendixsubsec Regular Expressions - -Regular expressions are the extended kind found in @code{egrep}. -They are composed of characters as follows: - -@table @code -@item @var{c} -matches the character @var{c} (assuming @var{c} is a character with no -special meaning in regexps). - -@item \@var{c} -matches the literal character @var{c}. - -@item . -matches any character except newline. - -@item ^ -matches the beginning of a line or a string. - -@item $ -matches the end of a line or a string. - -@item [@var{abc}@dots{}] -matches any of the characters @var{abc}@dots{} (character class). - -@item [^@var{abc}@dots{}] -matches any character except @var{abc}@dots{} and newline (negated -character class). - -@item @var{r1}|@var{r2} -matches either @var{r1} or @var{r2} (alternation). - -@item @var{r1r2} -matches @var{r1}, and then @var{r2} (concatenation). - -@item @var{r}+ -matches one or more @var{r}'s. - -@item @var{r}* -matches zero or more @var{r}'s. - -@item @var{r}? -matches zero or one @var{r}'s. - -@item (@var{r}) -matches @var{r} (grouping). -@end table - -@xref{Regexp, ,Regular Expressions as Patterns}, for a more detailed -explanation of regular expressions. - -The escape sequences allowed in string constants are also valid in -regular expressions (@pxref{Constants, ,Constant Expressions}). - -@node Actions Summary, , Regexp Summary, Rules Summary -@appendixsubsec Actions - -Action statements are enclosed in braces, @samp{@{} and @samp{@}}. -Action statements consist of the usual assignment, conditional, and looping -statements found in most languages. The operators, control statements, -and input/output statements available are patterned after those in C. - -@menu -* Operator Summary:: @code{awk} operators. -* Control Flow Summary:: The control statements. -* I/O Summary:: The I/O statements. -* Printf Summary:: A summary of @code{printf}. -* Special File Summary:: Special file names interpreted internally. -* Numeric Functions Summary:: Built-in numeric functions. -* String Functions Summary:: Built-in string functions. -* Time Functions Summary:: Built-in time functions. -* String Constants Summary:: Escape sequences in strings. -@end menu - -@node Operator Summary, Control Flow Summary, Actions Summary, Actions Summary -@appendixsubsubsec Operators - -The operators in @code{awk}, in order of increasing precedence, are: - -@table @code -@item = += -= *= /= %= ^= -Assignment. Both absolute assignment (@code{@var{var}=@var{value}}) -and operator assignment (the other forms) are supported. - -@item ?: -A conditional expression, as in C. This has the form @code{@var{expr1} ? -@var{expr2} : @var{expr3}}. If @var{expr1} is true, the value of the -expression is @var{expr2}; otherwise it is @var{expr3}. Only one of -@var{expr2} and @var{expr3} is evaluated.@refill - -@item || -Logical ``or''. - -@item && -Logical ``and''. - -@item ~ !~ -Regular expression match, negated match. - -@item < <= > >= != == -The usual relational operators. - -@item @var{blank} -String concatenation. - -@item + - -Addition and subtraction. - -@item * / % -Multiplication, division, and modulus. - -@item + - ! -Unary plus, unary minus, and logical negation. - -@item ^ -Exponentiation (@samp{**} may also be used, and @samp{**=} for the assignment -operator, but they are not specified in the @sc{posix} standard). - -@item ++ -- -Increment and decrement, both prefix and postfix. - -@item $ -Field reference. -@end table - -@xref{Expressions, ,Expressions as Action Statements}, for a full -description of all the operators listed above. -@xref{Fields, ,Examining Fields}, for a description of the field -reference operator.@refill - -@node Control Flow Summary, I/O Summary, Operator Summary, Actions Summary -@appendixsubsubsec Control Statements - -The control statements are as follows: - -@example -if (@var{condition}) @var{statement} @r{[} else @var{statement} @r{]} -while (@var{condition}) @var{statement} -do @var{statement} while (@var{condition}) -for (@var{expr1}; @var{expr2}; @var{expr3}) @var{statement} -for (@var{var} in @var{array}) @var{statement} -break -continue -delete @var{array}[@var{index}] -exit @r{[} @var{expression} @r{]} -@{ @var{statements} @} -@end example - -@xref{Statements, ,Control Statements in Actions}, for a full description -of all the control statements listed above. - -@node I/O Summary, Printf Summary, Control Flow Summary, Actions Summary -@appendixsubsubsec I/O Statements - -The input/output statements are as follows: - -@table @code -@item getline -Set @code{$0} from next input record; set @code{NF}, @code{NR}, @code{FNR}. - -@item getline <@var{file} -Set @code{$0} from next record of @var{file}; set @code{NF}. - -@item getline @var{var} -Set @var{var} from next input record; set @code{NF}, @code{FNR}. - -@item getline @var{var} <@var{file} -Set @var{var} from next record of @var{file}. - -@item next -Stop processing the current input record. The next input record is read and -processing starts over with the first pattern in the @code{awk} program. -If the end of the input data is reached, the @code{END} rule(s), if any, -are executed. - -@item next file -Stop processing the current input file. The next input record read comes -from the next input file. @code{FILENAME} is updated, @code{FNR} is set to 1, -and processing starts over with the first pattern in the @code{awk} program. -If the end of the input data is reached, the @code{END} rule(s), if any, -are executed. - -@item print -Prints the current record. - -@item print @var{expr-list} -Prints expressions. - -@item print @var{expr-list} > @var{file} -Prints expressions on @var{file}. - -@item printf @var{fmt, expr-list} -Format and print. - -@item printf @var{fmt, expr-list} > file -Format and print on @var{file}. -@end table - -Other input/output redirections are also allowed. For @code{print} and -@code{printf}, @samp{>> @var{file}} appends output to the @var{file}, -and @samp{| @var{command}} writes on a pipe. In a similar fashion, -@samp{@var{command} | getline} pipes input into @code{getline}. -@code{getline} returns 0 on end of file, and @minus{}1 on an error.@refill - -@xref{Getline, ,Explicit Input with @code{getline}}, for a full description -of the @code{getline} statement. -@xref{Printing, ,Printing Output}, for a full description of @code{print} and -@code{printf}. Finally, @pxref{Next Statement, ,The @code{next} Statement}, -for a description of how the @code{next} statement works.@refill - -@node Printf Summary, Special File Summary, I/O Summary, Actions Summary -@appendixsubsubsec @code{printf} Summary - -The @code{awk} @code{printf} statement and @code{sprintf} function -accept the following conversion specification formats: - -@table @code -@item %c -An ASCII character. If the argument used for @samp{%c} is numeric, it is -treated as a character and printed. Otherwise, the argument is assumed to -be a string, and the only first character of that string is printed. - -@item %d -@itemx %i -A decimal number (the integer part). - -@item %e -A floating point number of the form -@samp{@r{[}-@r{]}d.ddddddE@r{[}+-@r{]}dd}.@refill - -@item %f -A floating point number of the form -@r{[}@code{-}@r{]}@code{ddd.dddddd}. - -@item %g -Use @samp{%e} or @samp{%f} conversion, whichever produces a shorter string, -with nonsignificant zeros suppressed. - -@item %o -An unsigned octal number (again, an integer). - -@item %s -A character string. - -@item %x -An unsigned hexadecimal number (an integer). - -@item %X -Like @samp{%x}, except use @samp{A} through @samp{F} instead of @samp{a} -through @samp{f} for decimal 10 through 15.@refill - -@item %% -A single @samp{%} character; no argument is converted. -@end table - -There are optional, additional parameters that may lie between the @samp{%} -and the control letter: - -@table @code -@item - -The expression should be left-justified within its field. - -@item @var{width} -The field should be padded to this width. If @var{width} has a leading zero, -then the field is padded with zeros. Otherwise it is padded with blanks. - -@item .@var{prec} -A number indicating the maximum width of strings or digits to the right -of the decimal point. -@end table - -Either or both of the @var{width} and @var{prec} values may be specified -as @samp{*}. In that case, the particular value is taken from the argument -list. - -@xref{Printf, ,Using @code{printf} Statements for Fancier Printing}, for -examples and for a more detailed description. - -@node Special File Summary, Numeric Functions Summary, Printf Summary, Actions Summary -@appendixsubsubsec Special File Names - -When doing I/O redirection from either @code{print} or @code{printf} into a -file, or via @code{getline} from a file, @code{gawk} recognizes certain special -file names internally. These file names allow access to open file descriptors -inherited from @code{gawk}'s parent process (usually the shell). The -file names are: - -@table @file -@item /dev/stdin -The standard input. - -@item /dev/stdout -The standard output. - -@item /dev/stderr -The standard error output. - -@item /dev/fd/@var{n} -The file denoted by the open file descriptor @var{n}. -@end table - -In addition the following files provide process related information -about the running @code{gawk} program. - -@table @file -@item /dev/pid -Reading this file returns the process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/ppid -Reading this file returns the parent process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/pgrpid -Reading this file returns the process group ID of the current process, -in decimal, terminated with a newline. - -@item /dev/user -Reading this file returns a single record terminated with a newline. -The fields are separated with blanks. The fields represent the -following information: - -@table @code -@item $1 -The value of the @code{getuid} system call. - -@item $2 -The value of the @code{geteuid} system call. - -@item $3 -The value of the @code{getgid} system call. - -@item $4 -The value of the @code{getegid} system call. -@end table - -If there are any additional fields, they are the group IDs returned by -@code{getgroups} system call. -(Multiple groups may not be supported on all systems.)@refill -@end table - -@noindent -These file names may also be used on the command line to name data files. -These file names are only recognized internally if you do not -actually have files by these names on your system. - -@xref{Special Files, ,Standard I/O Streams}, for a longer description that -provides the motivation for this feature. - -@node Numeric Functions Summary, String Functions Summary, Special File Summary, Actions Summary -@appendixsubsubsec Numeric Functions - -@code{awk} has the following predefined arithmetic functions: - -@table @code -@item atan2(@var{y}, @var{x}) -returns the arctangent of @var{y/x} in radians. - -@item cos(@var{expr}) -returns the cosine in radians. - -@item exp(@var{expr}) -the exponential function. - -@item int(@var{expr}) -truncates to integer. - -@item log(@var{expr}) -the natural logarithm function. - -@item rand() -returns a random number between 0 and 1. - -@item sin(@var{expr}) -returns the sine in radians. - -@item sqrt(@var{expr}) -the square root function. - -@item srand(@var{expr}) -use @var{expr} as a new seed for the random number generator. If no @var{expr} -is provided, the time of day is used. The return value is the previous -seed for the random number generator. -@end table - -@node String Functions Summary, Time Functions Summary, Numeric Functions Summary, Actions Summary -@appendixsubsubsec String Functions - -@code{awk} has the following predefined string functions: - -@table @code -@item gsub(@var{r}, @var{s}, @var{t}) -for each substring matching the regular expression @var{r} in the string -@var{t}, substitute the string @var{s}, and return the number of substitutions. -If @var{t} is not supplied, use @code{$0}. - -@item index(@var{s}, @var{t}) -returns the index of the string @var{t} in the string @var{s}, or 0 if -@var{t} is not present. - -@item length(@var{s}) -returns the length of the string @var{s}. The length of @code{$0} -is returned if no argument is supplied. - -@item match(@var{s}, @var{r}) -returns the position in @var{s} where the regular expression @var{r} -occurs, or 0 if @var{r} is not present, and sets the values of @code{RSTART} -and @code{RLENGTH}. - -@item split(@var{s}, @var{a}, @var{r}) -splits the string @var{s} into the array @var{a} on the regular expression -@var{r}, and returns the number of fields. If @var{r} is omitted, @code{FS} -is used instead. - -@item sprintf(@var{fmt}, @var{expr-list}) -prints @var{expr-list} according to @var{fmt}, and returns the resulting string. - -@item sub(@var{r}, @var{s}, @var{t}) -this is just like @code{gsub}, but only the first matching substring is -replaced. - -@item substr(@var{s}, @var{i}, @var{n}) -returns the @var{n}-character substring of @var{s} starting at @var{i}. -If @var{n} is omitted, the rest of @var{s} is used. - -@item tolower(@var{str}) -returns a copy of the string @var{str}, with all the upper-case characters in -@var{str} translated to their corresponding lower-case counterparts. -Nonalphabetic characters are left unchanged. - -@item toupper(@var{str}) -returns a copy of the string @var{str}, with all the lower-case characters in -@var{str} translated to their corresponding upper-case counterparts. -Nonalphabetic characters are left unchanged. - -@item system(@var{cmd-line}) -Execute the command @var{cmd-line}, and return the exit status. -@end table - -@node Time Functions Summary, String Constants Summary, String Functions Summary, Actions Summary -@appendixsubsubsec Built-in time functions - -The following two functions are available for getting the current -time of day, and for formatting time stamps. - -@table @code -@item systime() -returns the current time of day as the number of seconds since a particular -epoch (Midnight, January 1, 1970 @sc{utc}, on @sc{posix} systems). - -@item strftime(@var{format}, @var{timestamp}) -formats @var{timestamp} according to the specification in @var{format}. -The current time of day is used if no @var{timestamp} is supplied. -@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for the -details on the conversion specifiers that @code{strftime} accepts.@refill -@end table - -@iftex -@xref{Built-in, ,Built-in Functions}, for a description of all of -@code{awk}'s built-in functions. -@end iftex - -@node String Constants Summary, , Time Functions Summary, Actions Summary -@appendixsubsubsec String Constants - -String constants in @code{awk} are sequences of characters enclosed -between double quotes (@code{"}). Within strings, certain @dfn{escape sequences} -are recognized, as in C. These are: - -@table @code -@item \\ -A literal backslash. - -@item \a -The ``alert'' character; usually the ASCII BEL character. - -@item \b -Backspace. - -@item \f -Formfeed. - -@item \n -Newline. - -@item \r -Carriage return. - -@item \t -Horizontal tab. - -@item \v -Vertical tab. - -@item \x@var{hex digits} -The character represented by the string of hexadecimal digits following -the @samp{\x}. As in @sc{ansi} C, all following hexadecimal digits are -considered part of the escape sequence. (This feature should tell us -something about language design by committee.) E.g., @code{"\x1B"} is a -string containing the ASCII ESC (escape) character. (The @samp{\x} -escape sequence is not in @sc{posix} @code{awk}.) - -@item \@var{ddd} -The character represented by the 1-, 2-, or 3-digit sequence of octal -digits. Thus, @code{"\033"} is also a string containing the ASCII ESC -(escape) character. - -@item \@var{c} -The literal character @var{c}. -@end table - -The escape sequences may also be used inside constant regular expressions -(e.g., the regexp @code{@w{/[@ \t\f\n\r\v]/}} matches whitespace -characters).@refill - -@xref{Constants, ,Constant Expressions}. - -@node Functions Summary, Historical Features, Rules Summary, Gawk Summary -@appendixsec Functions - -Functions in @code{awk} are defined as follows: - -@example -function @var{name}(@var{parameter list}) @{ @var{statements} @} -@end example - -Actual parameters supplied in the function call are used to instantiate -the formal parameters declared in the function. Arrays are passed by -reference, other variables are passed by value. - -If there are fewer arguments passed than there are names in @var{parameter-list}, -the extra names are given the null string as value. Extra names have the -effect of local variables. - -The open-parenthesis in a function call of a user-defined function must -immediately follow the function name, without any intervening white space. -This is to avoid a syntactic ambiguity with the concatenation operator. - -The word @code{func} may be used in place of @code{function} (but not in -@sc{posix} @code{awk}). - -Use the @code{return} statement to return a value from a function. - -@xref{User-defined, ,User-defined Functions}, for a more complete description. - -@node Historical Features, , Functions Summary, Gawk Summary -@appendixsec Historical Features - -There are two features of historical @code{awk} implementations that -@code{gawk} supports. First, it is possible to call the @code{length} -built-in function not only with no arguments, but even without parentheses! - -@example -a = length -@end example - -@noindent -is the same as either of - -@example -a = length() -a = length($0) -@end example - -@noindent -This feature is marked as ``deprecated'' in the @sc{posix} standard, and -@code{gawk} will issue a warning about its use if @samp{-W lint} is -specified on the command line. - -The other feature is the use of the @code{continue} statement outside the -body of a @code{while}, @code{for}, or @code{do} loop. Traditional -@code{awk} implementations have treated such usage as equivalent to the -@code{next} statement. @code{gawk} will support this usage if @samp{-W posix} -has not been specified. - -@node Sample Program, Bugs, Gawk Summary, Top -@appendix Sample Program - -The following example is a complete @code{awk} program, which prints -the number of occurrences of each word in its input. It illustrates the -associative nature of @code{awk} arrays by using strings as subscripts. It -also demonstrates the @samp{for @var{x} in @var{array}} construction. -Finally, it shows how @code{awk} can be used in conjunction with other -utility programs to do a useful task of some complexity with a minimum of -effort. Some explanations follow the program listing.@refill - -@example -awk ' -# Print list of word frequencies -@{ - for (i = 1; i <= NF; i++) - freq[$i]++ -@} - -END @{ - for (word in freq) - printf "%s\t%d\n", word, freq[word] -@}' -@end example - -The first thing to notice about this program is that it has two rules. The -first rule, because it has an empty pattern, is executed on every line of -the input. It uses @code{awk}'s field-accessing mechanism -(@pxref{Fields, ,Examining Fields}) to pick out the individual words from -the line, and the built-in variable @code{NF} (@pxref{Built-in Variables}) -to know how many fields are available.@refill - -For each input word, an element of the array @code{freq} is incremented to -reflect that the word has been seen an additional time.@refill - -The second rule, because it has the pattern @code{END}, is not executed -until the input has been exhausted. It prints out the contents of the -@code{freq} table that has been built up inside the first action.@refill - -Note that this program has several problems that would prevent it from being -useful by itself on real text files:@refill - -@itemize @bullet -@item -Words are detected using the @code{awk} convention that fields are -separated by whitespace and that other characters in the input (except -newlines) don't have any special meaning to @code{awk}. This means that -punctuation characters count as part of words.@refill - -@item -The @code{awk} language considers upper and lower case characters to be -distinct. Therefore, @samp{foo} and @samp{Foo} are not treated by this -program as the same word. This is undesirable since in normal text, words -are capitalized if they begin sentences, and a frequency analyzer should not -be sensitive to that.@refill - -@item -The output does not come out in any useful order. You're more likely to be -interested in which words occur most frequently, or having an alphabetized -table of how frequently each word occurs.@refill -@end itemize - -The way to solve these problems is to use some of the more advanced -features of the @code{awk} language. First, we use @code{tolower} to remove -case distinctions. Next, we use @code{gsub} to remove punctuation -characters. Finally, we use the system @code{sort} utility to process the -output of the @code{awk} script. First, here is the new version of -the program:@refill - -@example -awk ' -# Print list of word frequencies -@{ - $0 = tolower($0) # remove case distinctions - gsub(/[^a-z0-9_ \t]/, "", $0) # remove punctuation - for (i = 1; i <= NF; i++) - freq[$i]++ -@} - -END @{ - for (word in freq) - printf "%s\t%d\n", word, freq[word] -@}' -@end example - -Assuming we have saved this program in a file named @file{frequency.awk}, -and that the data is in @file{file1}, the following pipeline - -@example -awk -f frequency.awk file1 | sort +1 -nr -@end example - -@noindent -produces a table of the words appearing in @file{file1} in order of -decreasing frequency. - -The @code{awk} program suitably massages the data and produces a word -frequency table, which is not ordered. - -The @code{awk} script's output is then sorted by the @code{sort} command and -printed on the terminal. The options given to @code{sort} in this example -specify to sort using the second field of each input line (skipping one field), -that the sort keys should be treated as numeric quantities (otherwise -@samp{15} would come before @samp{5}), and that the sorting should be done -in descending (reverse) order.@refill - -We could have even done the @code{sort} from within the program, by -changing the @code{END} action to: - -@example -END @{ - sort = "sort +1 -nr" - for (word in freq) - printf "%s\t%d\n", word, freq[word] | sort - close(sort) -@}' -@end example - -See the general operating system documentation for more information on how -to use the @code{sort} command.@refill - -@ignore -@strong{ADR: I have some more substantial programs courtesy of Rick Adams -at UUNET. I am planning on incorporating those either in addition to or -instead of this program.} - -@strong{I would also like to incorporate the general @code{translate} -function that I have written.} - -@strong{I have a ton of other sample programs to include too.} -@end ignore - -@node Bugs, Notes, Sample Program, Top -@appendix Reporting Problems and Bugs - -@c This chapter stolen shamelessly from the GNU m4 manual. -@c This chapter has been unshamelessly altered to emulate changes made to -@c make.texi from whence it was originally shamelessly stolen! :-} --mew - -If you have problems with @code{gawk} or think that you have found a bug, -please report it to the developers; we cannot promise to do anything -but we might well want to fix it. - -Before reporting a bug, make sure you have actually found a real bug. -Carefully reread the documentation and see if it really says you can do -what you're trying to do. If it's not clear whether you should be able -to do something or not, report that too; it's a bug in the documentation! - -Before reporting a bug or trying to fix it yourself, try to isolate it -to the smallest possible @code{awk} program and input data file that -reproduces the problem. Then send us the program and data file, -some idea of what kind of Unix system you're using, and the exact results -@code{gawk} gave you. Also say what you expected to occur; this will help -us decide whether the problem was really in the documentation. - -Once you have a precise problem, send e-mail to (Internet) -@samp{bug-gnu-utils@@prep.ai.mit.edu} or (UUCP) -@samp{mit-eddie!prep.ai.mit.edu!bug-gnu-utils}. Please include the -version number of @code{gawk} you are using. You can get this information -with the command @samp{gawk -W version '@{@}' /dev/null}. -You should send carbon copies of your mail to David Trueman at -@samp{david@@cs.dal.ca}, and to Arnold Robbins, who can be reached at -@samp{arnold@@skeeve.atl.ga.us}. David is most likely to fix code -problems, while Arnold is most likely to fix documentation problems.@refill - -Non-bug suggestions are always welcome as well. If you have questions -about things that are unclear in the documentation or are just obscure -features, ask Arnold Robbins; he will try to help you out, although he -may not have the time to fix the problem. You can send him electronic mail at the Internet address -above. - -If you find bugs in one of the non-Unix ports of @code{gawk}, please send -an electronic mail message to the person who maintains that port. They -are listed below, and also in the @file{README} file in the @code{gawk} -distribution. Information in the @code{README} file should be considered -authoritative if it conflicts with this manual. - -The people maintaining the non-Unix ports of @code{gawk} are: - -@table @asis -@item MS-DOS -The port to MS-DOS is maintained by Scott Deifik. -His electronic mail address is @samp{scottd@@amgen.com}. - -@item VMS -The port to VAX VMS is maintained by Pat Rankin. -His electronic mail address is @samp{rankin@@eql.caltech.edu}. - -@item Atari ST -The port to the Atari ST is maintained by Michal Jaegermann. -His electronic mail address is @samp{ntomczak@@vm.ucs.ualberta.ca}. - -@end table - -If your bug is also reproducible under Unix, please send copies of your -report to the general GNU bug list, as well as to Arnold Robbins and David -Trueman, at the addresses listed above. - -@node Notes, Glossary, Bugs, Top -@appendix Implementation Notes - -This appendix contains information mainly of interest to implementors and -maintainers of @code{gawk}. Everything in it applies specifically to -@code{gawk}, and not to other implementations. - -@menu -* Compatibility Mode:: How to disable certain @code{gawk} extensions. -* Future Extensions:: New features we may implement soon. -* Improvements:: Suggestions for improvements by volunteers. -@end menu - -@node Compatibility Mode, Future Extensions, Notes, Notes -@appendixsec Downward Compatibility and Debugging - -@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}}, -for a summary of the GNU extensions to the @code{awk} language and program. -All of these features can be turned off by invoking @code{gawk} with the -@samp{-W compat} option, or with the @samp{-W posix} option.@refill - -If @code{gawk} is compiled for debugging with @samp{-DDEBUG}, then there -is one more option available on the command line: - -@table @samp -@item -W parsedebug -Print out the parse stack information as the program is being parsed. -@end table - -This option is intended only for serious @code{gawk} developers, -and not for the casual user. It probably has not even been compiled into -your version of @code{gawk}, since it slows down execution. - -@node Future Extensions, Improvements, Compatibility Mode, Notes -@appendixsec Probable Future Extensions - -This section briefly lists extensions that indicate the directions we are -currently considering for @code{gawk}. The file @file{FUTURES} in the -@code{gawk} distributions lists these extensions, as well as several others. - -@table @asis -@item @code{RS} as a regexp -The meaning of @code{RS} may be generalized along the lines of @code{FS}. - -@item Control of subprocess environment -Changes made in @code{gawk} to the array @code{ENVIRON} may be -propagated to subprocesses run by @code{gawk}. - -@item Databases -It may be possible to map a GDBM/NDBM/SDBM file into an @code{awk} array. - -@item Single-character fields -The null string, @code{""}, as a field separator, will cause field -splitting and the @code{split} function to separate individual characters. -Thus, @code{split(a, "abcd", "")} would yield @code{a[1] == "a"}, -@code{a[2] == "b"}, and so on. - -@item More @code{lint} warnings -There are more things that could be checked for portability. - -@item @code{RECLEN} variable for fixed length records -Along with @code{FIELDWIDTHS}, this would speed up the processing of -fixed-length records. - -@item @code{RT} variable to hold the record terminator -It is occasionally useful to have access to the actual string of -characters that matched the @code{RS} variable. The @code{RT} -variable would hold these characters. - -@item A @code{restart} keyword -After modifying @code{$0}, @code{restart} would restart the pattern -matching loop, without reading a new record from the input. - -@item A @samp{|&} redirection -The @samp{|&} redirection, in place of @samp{|}, would open a two-way -pipeline for communication with a sub-process (via @code{getline} and -@code{print} and @code{printf}). - -@item @code{IGNORECASE} affecting all comparisons -The effects of the @code{IGNORECASE} variable may be generalized to -all string comparisons, and not just regular expression operations. - -@item A way to mix command line source code and library files -There may be a new option that would make it possible to easily use library -functions from a program entered on the command line. -@c probably a @samp{-s} option... - -@item GNU-style long options -We will add GNU-style long options -to @code{gawk} for compatibility with other GNU programs. -(For example, @samp{--field-separator=:} would be equivalent to -@samp{-F:}.)@refill - -@c this is @emph{very} long term --- not worth including right now. -@ignore -@item The C Comma Operator -We may add the C comma operator, which takes the form -@code{@var{expr1},@var{expr2}}. The first expression is evaluated, and the -result is thrown away. The value of the full expression is the value of -@var{expr2}.@refill -@end ignore -@end table - -@node Improvements, , Future Extensions, Notes -@appendixsec Suggestions for Improvements - -Here are some projects that would-be @code{gawk} hackers might like to take -on. They vary in size from a few days to a few weeks of programming, -depending on which one you choose and how fast a programmer you are. Please -send any improvements you write to the maintainers at the GNU -project.@refill - -@enumerate -@item -Compilation of @code{awk} programs: @code{gawk} uses a Bison (YACC-like) -parser to convert the script given it into a syntax tree; the syntax -tree is then executed by a simple recursive evaluator. This method incurs -a lot of overhead, since the recursive evaluator performs many procedure -calls to do even the simplest things.@refill - -It should be possible for @code{gawk} to convert the script's parse tree -into a C program which the user would then compile, using the normal -C compiler and a special @code{gawk} library to provide all the needed -functions (regexps, fields, associative arrays, type coercion, and so -on).@refill - -An easier possibility might be for an intermediate phase of @code{awk} to -convert the parse tree into a linear byte code form like the one used -in GNU Emacs Lisp. The recursive evaluator would then be replaced by -a straight line byte code interpreter that would be intermediate in speed -between running a compiled program and doing what @code{gawk} does -now.@refill - -This may actually happen for the 3.0 version of @code{gawk}. - -@item -An error message section has not been included in this version of the -manual. Perhaps some nice beta testers will document some of the messages -for the future. - -@item -The programs in the test suite could use documenting in this manual. - -@item -The programs and data files in the manual should be available in -separate files to facilitate experimentation. - -@item -See the @file{FUTURES} file for more ideas. Contact us if you would -seriously like to tackle any of the items listed there. -@end enumerate - -@node Glossary, Index, Notes, Top -@appendix Glossary - -@table @asis -@item Action -A series of @code{awk} statements attached to a rule. If the rule's -pattern matches an input record, the @code{awk} language executes the -rule's action. Actions are always enclosed in curly braces. -@xref{Actions, ,Overview of Actions}.@refill - -@item Amazing @code{awk} Assembler -Henry Spencer at the University of Toronto wrote a retargetable assembler -completely as @code{awk} scripts. It is thousands of lines long, including -machine descriptions for several 8-bit microcomputers. -@c It is distributed with @code{gawk} (as part of the test suite) and -It is a good example of a -program that would have been better written in another language.@refill - -@item @sc{ansi} -The American National Standards Institute. This organization produces -many standards, among them the standard for the C programming language. - -@item Assignment -An @code{awk} expression that changes the value of some @code{awk} -variable or data object. An object that you can assign to is called an -@dfn{lvalue}. @xref{Assignment Ops, ,Assignment Expressions}.@refill - -@item @code{awk} Language -The language in which @code{awk} programs are written. - -@item @code{awk} Program -An @code{awk} program consists of a series of @dfn{patterns} and -@dfn{actions}, collectively known as @dfn{rules}. For each input record -given to the program, the program's rules are all processed in turn. -@code{awk} programs may also contain function definitions.@refill - -@item @code{awk} Script -Another name for an @code{awk} program. - -@item Built-in Function -The @code{awk} language provides built-in functions that perform various -numerical, time stamp related, and string computations. Examples are -@code{sqrt} (for the square root of a number) and @code{substr} (for a -substring of a string). @xref{Built-in, ,Built-in Functions}.@refill - -@item Built-in Variable -@code{ARGC}, @code{ARGIND}, @code{ARGV}, @code{CONVFMT}, @code{ENVIRON}, -@code{ERRNO}, @code{FIELDWIDTHS}, @code{FILENAME}, @code{FNR}, @code{FS}, -@code{IGNORECASE}, @code{NF}, @code{NR}, @code{OFMT}, @code{OFS}, @code{ORS}, -@code{RLENGTH}, @code{RSTART}, @code{RS}, and @code{SUBSEP}, -are the variables that have special -meaning to @code{awk}. Changing some of them affects @code{awk}'s running -environment. @xref{Built-in Variables}.@refill - -@item Braces -See ``Curly Braces.'' - -@item C -The system programming language that most GNU software is written in. The -@code{awk} programming language has C-like syntax, and this manual -points out similarities between @code{awk} and C when appropriate.@refill - -@item CHEM -A preprocessor for @code{pic} that reads descriptions of molecules -and produces @code{pic} input for drawing them. It was written by -Brian Kernighan, and is available from @code{netlib@@research.att.com}.@refill - -@item Compound Statement -A series of @code{awk} statements, enclosed in curly braces. Compound -statements may be nested. -@xref{Statements, ,Control Statements in Actions}.@refill - -@item Concatenation -Concatenating two strings means sticking them together, one after another, -giving a new string. For example, the string @samp{foo} concatenated with -the string @samp{bar} gives the string @samp{foobar}. -@xref{Concatenation, ,String Concatenation}.@refill - -@item Conditional Expression -An expression using the @samp{?:} ternary operator, such as -@code{@var{expr1} ? @var{expr2} : @var{expr3}}. The expression -@var{expr1} is evaluated; if the result is true, the value of the whole -expression is the value of @var{expr2} otherwise the value is -@var{expr3}. In either case, only one of @var{expr2} and @var{expr3} -is evaluated. @xref{Conditional Exp, ,Conditional Expressions}.@refill - -@item Constant Regular Expression -A constant regular expression is a regular expression written within -slashes, such as @samp{/foo/}. This regular expression is chosen -when you write the @code{awk} program, and cannot be changed doing -its execution. @xref{Regexp Usage, ,How to Use Regular Expressions}. - -@item Comparison Expression -A relation that is either true or false, such as @code{(a < b)}. -Comparison expressions are used in @code{if}, @code{while}, and @code{for} -statements, and in patterns to select which input records to process. -@xref{Comparison Ops, ,Comparison Expressions}.@refill - -@item Curly Braces -The characters @samp{@{} and @samp{@}}. Curly braces are used in -@code{awk} for delimiting actions, compound statements, and function -bodies.@refill - -@item Data Objects -These are numbers and strings of characters. Numbers are converted into -strings and vice versa, as needed. -@xref{Conversion, ,Conversion of Strings and Numbers}.@refill - -@item Dynamic Regular Expression -A dynamic regular expression is a regular expression written as an -ordinary expression. It could be a string constant, such as -@code{"foo"}, but it may also be an expression whose value may vary. -@xref{Regexp Usage, ,How to Use Regular Expressions}. - -@item Escape Sequences -A special sequence of characters used for describing nonprinting -characters, such as @samp{\n} for newline, or @samp{\033} for the ASCII -ESC (escape) character. @xref{Constants, ,Constant Expressions}. - -@item Field -When @code{awk} reads an input record, it splits the record into pieces -separated by whitespace (or by a separator regexp which you can -change by setting the built-in variable @code{FS}). Such pieces are -called fields. If the pieces are of fixed length, you can use the built-in -variable @code{FIELDWIDTHS} to describe their lengths. -@xref{Records, ,How Input is Split into Records}.@refill - -@item Format -Format strings are used to control the appearance of output in the -@code{printf} statement. Also, data conversions from numbers to strings -are controlled by the format string contained in the built-in variable -@code{CONVFMT}. @xref{Control Letters, ,Format-Control Letters}.@refill - -@item Function -A specialized group of statements often used to encapsulate general -or program-specific tasks. @code{awk} has a number of built-in -functions, and also allows you to define your own. -@xref{Built-in, ,Built-in Functions}. -Also, see @ref{User-defined, ,User-defined Functions}.@refill - -@item @code{gawk} -The GNU implementation of @code{awk}. - -@item GNU -``GNU's not Unix''. An on-going project of the Free Software Foundation -to create a complete, freely distributable, @sc{posix}-compliant computing -environment. - -@item Input Record -A single chunk of data read in by @code{awk}. Usually, an @code{awk} input -record consists of one line of text. -@xref{Records, ,How Input is Split into Records}.@refill - -@item Keyword -In the @code{awk} language, a keyword is a word that has special -meaning. Keywords are reserved and may not be used as variable names. - -@code{awk}'s keywords are: -@code{if}, -@code{else}, -@code{while}, -@code{do@dots{}while}, -@code{for}, -@code{for@dots{}in}, -@code{break}, -@code{continue}, -@code{delete}, -@code{next}, -@code{function}, -@code{func}, -and @code{exit}.@refill - -@item Lvalue -An expression that can appear on the left side of an assignment -operator. In most languages, lvalues can be variables or array -elements. In @code{awk}, a field designator can also be used as an -lvalue.@refill - -@item Number -A numeric valued data object. The @code{gawk} implementation uses double -precision floating point to represent numbers.@refill - -@item Pattern -Patterns tell @code{awk} which input records are interesting to which -rules. - -A pattern is an arbitrary conditional expression against which input is -tested. If the condition is satisfied, the pattern is said to @dfn{match} -the input record. A typical pattern might compare the input record against -a regular expression. @xref{Patterns}.@refill - -@item @sc{posix} -The name for a series of standards being developed by the @sc{ieee} -that specify a Portable Operating System interface. The ``IX'' denotes -the Unix heritage of these standards. The main standard of interest for -@code{awk} users is P1003.2, the Command Language and Utilities standard. - -@item Range (of input lines) -A sequence of consecutive lines from the input file. A pattern -can specify ranges of input lines for @code{awk} to process, or it can -specify single lines. @xref{Patterns}.@refill - -@item Recursion -When a function calls itself, either directly or indirectly. -If this isn't clear, refer to the entry for ``recursion.'' - -@item Redirection -Redirection means performing input from other than the standard input -stream, or output to other than the standard output stream. - -You can redirect the output of the @code{print} and @code{printf} statements -to a file or a system command, using the @samp{>}, @samp{>>}, and @samp{|} -operators. You can redirect input to the @code{getline} statement using -the @samp{<} and @samp{|} operators. -@xref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}.@refill - -@item Regular Expression -See ``regexp.'' - -@item Regexp -Short for @dfn{regular expression}. A regexp is a pattern that denotes a -set of strings, possibly an infinite set. For example, the regexp -@samp{R.*xp} matches any string starting with the letter @samp{R} -and ending with the letters @samp{xp}. In @code{awk}, regexps are -used in patterns and in conditional expressions. Regexps may contain -escape sequences. @xref{Regexp, ,Regular Expressions as Patterns}.@refill - -@item Rule -A segment of an @code{awk} program, that specifies how to process single -input records. A rule consists of a @dfn{pattern} and an @dfn{action}. -@code{awk} reads an input record; then, for each rule, if the input record -satisfies the rule's pattern, @code{awk} executes the rule's action. -Otherwise, the rule does nothing for that input record.@refill - -@item Side Effect -A side effect occurs when an expression has an effect aside from merely -producing a value. Assignment expressions, increment expressions and -function calls have side effects. @xref{Assignment Ops, ,Assignment Expressions}. - -@item Special File -A file name interpreted internally by @code{gawk}, instead of being handed -directly to the underlying operating system. For example, @file{/dev/stdin}. -@xref{Special Files, ,Standard I/O Streams}. - -@item Stream Editor -A program that reads records from an input stream and processes them one -or more at a time. This is in contrast with batch programs, which may -expect to read their input files in entirety before starting to do -anything, and with interactive programs, which require input from the -user.@refill - -@item String -A datum consisting of a sequence of characters, such as @samp{I am a -string}. Constant strings are written with double-quotes in the -@code{awk} language, and may contain escape sequences. -@xref{Constants, ,Constant Expressions}. - -@item Whitespace -A sequence of blank or tab characters occurring inside an input record or a -string.@refill -@end table - -@node Index, , Glossary, Top -@unnumbered Index -@printindex cp - -@summarycontents -@contents -@bye - -Unresolved Issues: ------------------- -1. From: ntomczak@vm.ucs.ualberta.ca (Michal Jaegermann) - Examples of usage tend to suggest that /../ and ".." delimiters - can be used for regular expressions, even if definition is consistently - using /../. I am not sure what the real rules are and in particular - what of the following is a bug and what is a feature: - # This program matches everything - '"\(" { print }' - # This one complains about mismatched parenthesis - '$0 ~ "\(" { print }' - # This one behaves in an expected manner - '/\(/ { print }' - You may also try to use "\(" as an argument to match() to see what - will happen. - -2. From ADR. - - The posix (and original Unix!) notion of awk values as both number - and string values needs to be put into the manual. This involves - major and minor rewrites of most of the manual, but should help in - clarifying many of the weirder points of the language. - -3. From ADR. - - The manual should be reorganized. Expressions should be introduced - early, building up to regexps as expressions, and from there to their - use as patterns and then in actions. Built-in vars should come earlier - in the manual too. The 'expert info' sections marked with comments - should get their own sections or subsections with nodes and titles. - The manual should be gone over thoroughly for indexing. - -4. From ADR. - - Robert J. Chassell points out that awk programs should have some indication - of how to use them. It would be useful to perhaps have a "programming - style" section of the manual that would include this and other tips. - -5. From ADR in response to moraes@uunet.ca - (This would make the beginnings of a good "puzzles" section...) - - Date: Mon, 2 Dec 91 10:08:05 EST - From: gatech!cc!arnold (Arnold Robbins) - To: cs.dal.ca!david, uunet.ca!moraes - Subject: redirecting to /dev/stderr - Cc: skeeve!arnold, boeing.com!brennan, research.att.com!bwk - - In 2.13.3 the following program no longer dumps core: - - BEGIN { print "hello" > /dev/stderr ; exit(1) } - - Instead, it creates a file named `0' with the word `hello' in it. AWK - semantics strikes again. The meaning of the statement is - - print "hello" > (($0 ~ /dev/) stderr) - - /dev/ tests $0 for the pattern `dev'. This yields a 0. The variable stderr, - having never been used, has a null string in it. The concatenation yields - a string value of "0" which is used as the file name. Sigh. - - I think with some more time I can come up with a decent fix, but it will - probably only print a diagnostic with -Wlint. - - Arnold - diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info deleted file mode 100644 index 060d9325e33a..000000000000 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info +++ /dev/null @@ -1,1659 +0,0 @@ -This is Info file pcl-cvs, produced by Makeinfo-1.49 from the input -file pcl-cvs.texinfo. - - Copyright (C) 1992 Per Cederqvist - - Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided also -that the section entitled "GNU General Public License" is included -exactly as in the original, and provided that the entire resulting -derived work is distributed under the terms of a permission notice -identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that the section entitled "GNU General Public -License" and this permission notice may be included in translations -approved by the Free Software Foundation instead of in the original -English. - - -File: pcl-cvs, Node: Top, Next: Copying, Prev: (dir), Up: (dir) - - This info manual describes pcl-cvs which is a GNU Emacs front-end -to CVS. It works with CVS version 1.3. This manual is updated to -release 1.05 of pcl-cvs. - -* Menu: - -* Copying:: GNU General Public License -* Installation:: How to install pcl-cvs on your system. -* About pcl-cvs:: Authors and ftp sites. - -* Getting started:: An introduction with a walk-through example. -* Buffer contents:: An explanation of the buffer contents. -* Commands:: All commands, grouped by type. - -* Customization:: How you can tailor pcl-cvs to suit your needs. -* Future enhancements:: Future enhancements of pcl-cvs. -* Bugs:: Bugs (known and unknown). -* Function and Variable Index:: List of functions and variables. -* Concept Index:: List of concepts. -* Key Index:: List of keystrokes. - - -- The Detailed Node Listing -- - -Installation - -* Pcl-cvs installation:: How to install pcl-cvs on your system. -* On-line manual installation:: How to install the on-line manual. -* Typeset manual installation:: How to create typeset documentation - about pcl-cvs. - -About pcl-cvs - -* Contributors:: Contributors to pcl-cvs. -* Archives:: Where can I get a copy of Pcl-Cvs? - -Buffer contents - -* File status:: The meaning of the second field. -* Selected files:: How selection works. - -Commands - -* Updating the directory:: Commands to update the local directory -* Movement commands:: How to move up and down in the buffer -* Marking files:: How to mark files that other commands - will later operate on. -* Committing changes:: Checking in your modifications to the - CVS repository. -* Editing files:: Loading files into Emacs. -* Getting info about files:: Display the log and status of files. -* Adding and removing files:: Adding and removing files -* Undoing changes:: Undoing changes -* Removing handled entries:: Uninteresting lines can easily be removed. -* Ignoring files:: Telling CVS to ignore generated files. -* Viewing differences:: Commands to `diff' different versions. -* Emerge:: -* Reverting your buffers:: Reverting your buffers -* Miscellaneous commands:: Miscellaneous commands - - -File: pcl-cvs, Node: Copying, Next: Installation, Prev: Top, Up: Top - -GNU GENERAL PUBLIC LICENSE -************************** - - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Preamble -======== - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, -and (2) offer you this license which gives you legal permission to -copy, distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make -certain that everyone understands that there is no warranty for this -free software. If the software is modified by someone else and -passed on, we want its recipients to know that what they have is not -the original, so that any problems introduced by others will not -reflect on the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at -all. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 1. This License applies to any program or other work which contains - a notice placed by the copyright holder saying it may be - distributed under the terms of this General Public License. The - "Program", below, refers to any such program or work, and a - "work based on the Program" means either the Program or any - derivative work under copyright law: that is to say, a work - containing the Program or a portion of it, either verbatim or - with modifications and/or translated into another language. - (Hereinafter, translation is included without limitation in the - term "modification".) Each licensee is addressed as "you". - - Activities other than copying, distribution and modification are - not covered by this License; they are outside its scope. The - act of running the Program is not restricted, and the output - from the Program is covered only if its contents constitute a - work based on the Program (independent of having been made by - running the Program). Whether that is true depends on what the - Program does. - - 2. You may copy and distribute verbatim copies of the Program's - source code as you receive it, in any medium, provided that you - conspicuously and appropriately publish on each copy an - appropriate copyright notice and disclaimer of warranty; keep - intact all the notices that refer to this License and to the - absence of any warranty; and give any other recipients of the - Program a copy of this License along with the Program. - - You may charge a fee for the physical act of transferring a - copy, and you may at your option offer warranty protection in - exchange for a fee. - - 3. You may modify your copy or copies of the Program or any portion - of it, thus forming a work based on the Program, and copy and - distribute such modifications or work under the terms of Section - 1 above, provided that you also meet all of these conditions: - - a. You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any - change. - - b. You must cause any work that you distribute or publish, - that in whole or in part contains or is derived from the - Program or any part thereof, to be licensed as a whole at - no charge to all third parties under the terms of this - License. - - c. If the modified program normally reads commands - interactively when run, you must cause it, when started - running for such interactive use in the most ordinary way, - to print or display an announcement including an - appropriate copyright notice and a notice that there is no - warranty (or else, saying that you provide a warranty) and - that users may redistribute the program under these - conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive - but does not normally print such an announcement, your work - based on the Program is not required to print an - announcement.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the - Program, and can be reasonably considered independent and - separate works in themselves, then this License, and its terms, - do not apply to those sections when you distribute them as - separate works. But when you distribute the same sections as - part of a whole which is a work based on the Program, the - distribution of the whole must be on the terms of this License, - whose permissions for other licensees extend to the entire - whole, and thus to each and every part regardless of who wrote - it. - - Thus, it is not the intent of this section to claim rights or - contest your rights to work written entirely by you; rather, the - intent is to exercise the right to control the distribution of - derivative or collective works based on the Program. - - In addition, mere aggregation of another work not based on the - Program with the Program (or with a work based on the Program) - on a volume of a storage or distribution medium does not bring - the other work under the scope of this License. - - 4. You may copy and distribute the Program (or a work based on it, - under Section 2) in object code or executable form under the - terms of Sections 1 and 2 above provided that you also do one of - the following: - - a. Accompany it with the complete corresponding - machine-readable source code, which must be distributed - under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - b. Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than - your cost of physically performing source distribution, a - complete machine-readable copy of the corresponding source - code, to be distributed under the terms of Sections 1 and 2 - above on a medium customarily used for software - interchange; or, - - c. Accompany it with the information you received as to the - offer to distribute corresponding source code. (This - alternative is allowed only for noncommercial distribution - and only if you received the program in object code or - executable form with such an offer, in accord with - Subsection b above.) - - The source code for a work means the preferred form of the work - for making modifications to it. For an executable work, - complete source code means all the source code for all modules - it contains, plus any associated interface definition files, - plus the scripts used to control compilation and installation of - the executable. However, as a special exception, the source - code distributed need not include anything that is normally - distributed (in either source or binary form) with the major - components (compiler, kernel, and so on) of the operating system - on which the executable runs, unless that component itself - accompanies the executable. - - If distribution of executable or object code is made by offering - access to copy from a designated place, then offering equivalent - access to copy the source code from the same place counts as - distribution of the source code, even though third parties are - not compelled to copy the source along with the object code. - - 5. You may not copy, modify, sublicense, or distribute the Program - except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense or distribute the Program - is void, and will automatically terminate your rights under this - License. However, parties who have received copies, or rights, - from you under this License will not have their licenses - terminated so long as such parties remain in full compliance. - - 6. You are not required to accept this License, since you have not - signed it. However, nothing else grants you permission to - modify or distribute the Program or its derivative works. These - actions are prohibited by law if you do not accept this License. - Therefore, by modifying or distributing the Program (or any - work based on the Program), you indicate your acceptance of this - License to do so, and all its terms and conditions for copying, - distributing or modifying the Program or works based on it. - - 7. Each time you redistribute the Program (or any work based on the - Program), the recipient automatically receives a license from the - original licensor to copy, distribute or modify the Program - subject to these terms and conditions. You may not impose any - further restrictions on the recipients' exercise of the rights - granted herein. You are not responsible for enforcing compliance - by third parties to this License. - - 8. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent - issues), conditions are imposed on you (whether by court order, - agreement or otherwise) that contradict the conditions of this - License, they do not excuse you from the conditions of this - License. If you cannot distribute so as to satisfy - simultaneously your obligations under this License and any other - pertinent obligations, then as a consequence you may not - distribute the Program at all. For example, if a patent license - would not permit royalty-free redistribution of the Program by - all those who receive copies directly or indirectly through you, - then the only way you could satisfy both it and this License - would be to refrain entirely from distribution of the Program. - - If any portion of this section is held invalid or unenforceable - under any particular circumstance, the balance of the section is - intended to apply and the section as a whole is intended to - apply in other circumstances. - - It is not the purpose of this section to induce you to infringe - any patents or other property right claims or to contest - validity of any such claims; this section has the sole purpose - of protecting the integrity of the free software distribution - system, which is implemented by public license practices. Many - people have made generous contributions to the wide range of - software distributed through that system in reliance on - consistent application of that system; it is up to the - author/donor to decide if he or she is willing to distribute - software through any other system and a licensee cannot impose - that choice. - - This section is intended to make thoroughly clear what is - believed to be a consequence of the rest of this License. - - 9. If the distribution and/or use of the Program is restricted in - certain countries either by patents or by copyrighted - interfaces, the original copyright holder who places the Program - under this License may add an explicit geographical distribution - limitation excluding those countries, so that distribution is - permitted only in or among countries not thus excluded. In such - case, this License incorporates the limitation as if written in - the body of this License. - - 10. The Free Software Foundation may publish revised and/or new - versions of the General Public License from time to time. Such - new versions will be similar in spirit to the present version, - but may differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the - Program specifies a version number of this License which applies - to it and "any later version", you have the option of following - the terms and conditions either of that version or of any later - version published by the Free Software Foundation. If the - Program does not specify a version number of this License, you - may choose any version ever published by the Free Software - Foundation. - - 11. If you wish to incorporate parts of the Program into other free - programs whose distribution conditions are different, write to - the author to ask for permission. For software which is - copyrighted by the Free Software Foundation, write to the Free - Software Foundation; we sometimes make exceptions for this. Our - decision will be guided by the two goals of preserving the free - status of all derivatives of our free software and of promoting - the sharing and reuse of software generally. - - NO WARRANTY - - 12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO - WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE - LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT - WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE - QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE - PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY - SERVICING, REPAIR OR CORRECTION. - - 13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY - MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE - LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, - INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR - INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS - OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY - YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH - ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - -Appendix: How to Apply These Terms to Your New Programs -======================================================= - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is -safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. - Copyright (C) 19YY NAME OF AUTHOR - - 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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Also add information on how to contact you by electronic and paper -mail. - - If the program is interactive, make it output a short notice like -this when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - - The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and -`show c'; they could even be mouse-clicks or menu items--whatever -suits your program. - - You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the -program, if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - SIGNATURE OF TY COON, 1 April 1989 - Ty Coon, President of Vice - - This General Public License does not permit incorporating your -program into proprietary programs. If your program is a subroutine -library, you may consider it more useful to permit linking -proprietary applications with the library. If this is what you want -to do, use the GNU Library General Public License instead of this -License. - - -File: pcl-cvs, Node: Installation, Next: About pcl-cvs, Prev: Copying, Up: Top - -Installation -************ - - This section describes the installation of pcl-cvs, the GNU Emacs -CVS front-end. You should install not only the elisp files -themselves, but also the on-line documentation so that your users -will know how to use it. You can create typeset documentation from -the file `pcl-cvs.texinfo' as well as an on-line info file. The -following steps are also described in the file `INSTALL' in the source -directory. - -* Menu: - -* Pcl-cvs installation:: How to install pcl-cvs on your system. -* On-line manual installation:: How to install the on-line manual. -* Typeset manual installation:: How to create typeset documentation - about pcl-cvs. - - -File: pcl-cvs, Node: Pcl-cvs installation, Next: On-line manual installation, Prev: Installation, Up: Installation - -Installation of the pcl-cvs program -=================================== - - 1. Edit the file `Makefile' to reflect the situation at your site. - The only things you have to change is the definition of `lispdir' - and `infodir'. The elisp files will be copied to `lispdir', and - the info file to `infodir'. - - 2. Configure pcl-cvs.el - - There are a couple of paths that you have to check to make sure - that they match you system. They appear early in the file - pcl-cvs.el. - - *NOTE:* If your system is running emacs 18.57 or earlier you - MUST uncomment the line that says: - - (setq delete-exited-processes nil) - - Setting `delete-exited-processes' to `nil' works around a bug in - emacs that causes it to dump core. The bug was fixed in emacs - 18.58. - - 3. Release 1.05 and later of pcl-cvs requires parts of the Elib - library, version 0.07 or later. Elib is available via anonymous - ftp from prep.ai.mit.edu in `pub/gnu/elib-0.07.tar.z', and from - a lot of other sites that mirrors prep. Get Elib, and install - it, before proceeding. - - 4. Type `make install' in the source directory. This will - byte-compile all `.el' files and copy both the `.el' and the - `.elc' into the directory you specified in step 1. - - If you don't want to install the `.el' files but only the `.elc' - files (the byte-compiled files), you can type ``make - install_elc'' instead of ``make install''. - - If you only want to create the compiled elisp files, but don't - want to install them, you can type `make elcfiles' instead. - This is what happens if you only type `make' without parameters. - - 5. Edit the file `default.el' in your emacs lisp directory (usually - `/usr/gnu/emacs/lisp' or something similar) and enter the - contents of the file `pcl-cvs-startup.el' into it. It contains - a couple of `auto-load's that facilitates the use of pcl-cvs. - - - -File: pcl-cvs, Node: On-line manual installation, Next: Typeset manual installation, Prev: Pcl-cvs installation, Up: Installation - -Installation of the on-line manual. -=================================== - - 1. Create the info file `pcl-cvs' from `pcl-cvs.texinfo' by typing - `make info'. If you don't have the program `makeinfo' you can - get it by anonymous ftp from e.g. `ftp.gnu.ai.mit.edu' as - `pub/gnu/texinfo-2.14.tar.Z' (there might be a newer version - there when you read this), or you could use the preformatted - info file `pcl-cvs.info' that is included in the distribution - (type `cp pcl-cvs.info pcl-cvs'). - - 2. Move the info file `pcl-cvs' to your standard info directory. - This might be called something like `/usr/gnu/emacs/info'. - - 3. Edit the file `dir' in the info directory and enter one line to - contain a pointer to the info file `pcl-cvs'. The line can, for - instance, look like this: - - * Pcl-cvs: (pcl-cvs). An Emacs front-end to CVS. - - -File: pcl-cvs, Node: Typeset manual installation, Prev: On-line manual installation, Up: Installation - -How to make typeset documentation from pcl-cvs.texinfo -====================================================== - - If you have TeX installed at your site, you can make a typeset -manual from `pcl-cvs.texinfo'. - - 1. Run TeX by typing ``make pcl-cvs.dvi''. You will not get the - indices unless you have the `texindex' program. - - 2. Convert the resulting device independent file `pcl-cvs.dvi' to a - form which your printer can output and print it. If you have a - postscript printer there is a program, `dvi2ps', which does. - There is also a program which comes together with TeX, `dvips', - which you can use. - - - -File: pcl-cvs, Node: About pcl-cvs, Next: Getting started, Prev: Installation, Up: Top - -About pcl-cvs -************* - - Pcl-cvs is a front-end to CVS version 1.3. It integrates the most -frequently used CVS commands into emacs. - -* Menu: - -* Contributors:: Contributors to pcl-cvs. -* Archives:: Where can I get a copy of Pcl-Cvs? - - -File: pcl-cvs, Node: Contributors, Next: Archives, Prev: About pcl-cvs, Up: About pcl-cvs - -Contributors to pcl-cvs -======================= - - Contributions to the package are welcome. I have limited time to -work on this project, but I will gladly add any code that you -contribute to me to this package (*note Bugs::.). - - The following persons have made contributions to pcl-cvs. - - * Brian Berliner wrote CVS, together with some other contributors. - Without his work on CVS this package would be useless... - - * Per Cederqvist wrote most of the otherwise unattributed - functions in pcl-cvs as well as all documentation. - - * Inge Wallin (`inge@lysator.liu.se') wrote the skeleton to - `pcl-cvs.texinfo', and gave useful comments on it. He also wrote - the files `elib-node.el' and `compile-all.el'. The file - `cookie.el' was inspired by Inge. - - * Linus Tolke (`linus@lysator.liu.se') contributed useful comments - on both the functionality and the documentation. - - * Jamie Zawinski (`jwz@lucid.com') contributed `pcl-cvs-lucid.el'. - - * Leif Lonnblad contributed RCVS support. - - Apart from these, a lot of people have send me suggestions, ideas, -requests, bug reports and encouragement. Thanks a lot! Without your -there would be no new releases of pcl-cvs. - - -File: pcl-cvs, Node: Archives, Prev: Contributors, Up: About pcl-cvs - -Where can I get pcl-cvs? -======================== - - The latest release of pcl-cvs can be fetched via anonymous ftp from -`ftp.lysator.liu.se', (IP no. 130.236.254.1) in the directory -`pub/emacs'. If you don't live in Scandinavia you should probably -check with archie to see if there is a site closer to you that -archives pcl-cvs. - - New releases will be announced to appropriate newsgroups. If you -send your email address to me I will add you to my list of people to -mail when I make a new release. - - -File: pcl-cvs, Node: Getting started, Next: Buffer contents, Prev: About pcl-cvs, Up: Top - -Getting started -*************** - - This document assumes that you know what CVS is, and that you at -least knows the fundamental concepts of CVS. If that is not the case -you should read the man page for CVS. - - Pcl-cvs is only useful once you have checked out a module. So -before you invoke it you must have a copy of a module somewhere in -the file system. - - You invoke pcl-cvs by typing `M-x cvs-update RET'. If your emacs -responds with `[No match]' your system administrator has not -installed pcl-cvs properly. Try `M-x load-library RET pcl-cvs RET'. -If that also fails - talk to your root. If it succeeds you might put -this line in your `.emacs' file so that you don't have to type the -`load-library' command every time you wish to use pcl-cvs: - - (autoload 'cvs-update "pcl-cvs" nil t) - - The function `cvs-update' will ask for a directory. The command -`cvs update' will be run in that directory. (It should contain files -that have been checked out from a CVS archive.) The output from -`cvs' will be parsed and presented in a table in a buffer called -`*cvs*'. It might look something like this: - - PCL-CVS release 1.05. - - In directory /users/ceder/FOO/test: - Updated bar - Updated file.txt - Modified ci namechange - Updated newer - - In directory /users/ceder/FOO/test/sub: - Modified ci ChangeLog - ---------- End ----- - - In this example the three files (`bar', `file.txt' and `newer') -that are marked with `Updated' have been copied from the CVS -repository to `/users/ceder/FOO/test/' since someone else have -checked in newer versions of them. Two files (`namechange' and -`sub/ChangeLog') have been modified locally, and needs to be checked -in. - - You can move the cursor up and down in the buffer with `C-n' and -`C-p' or `n' and `p'. If you press `c' on one of the `Modified' -files that file will be checked in to the CVS repository. *Note -Committing changes::. You can press `x' to get rid of the -"uninteresting" files that have only been `Updated' (and don't -require any further action from you). - - You can also easily get a `diff' between your modified file and the -base version that you started from, and you can get the output from -`cvs log' and `cvs status' on the listed files simply by pressing a -key (*note Getting info about files::.). - - -File: pcl-cvs, Node: Buffer contents, Next: Commands, Prev: Getting started, Up: Top - -Buffer contents -*************** - - The display contains four columns. They contain, from left to -right: - - * An asterisk when the file is "marked" (*note Selected files::.). - - * The status of the file. See *Note File status::, for more - information. - - * A "need to be checked in"-marker (`ci'). - - * The file name. - -* Menu: - -* File status:: The meaning of the second field. -* Selected files:: How selection works. - - -File: pcl-cvs, Node: File status, Next: Selected files, Prev: Buffer contents, Up: Buffer contents - -File status -=========== - - The `file status' field can have the following values: - -`Updated' - The file was brought up to date with respect to the repository. - This is done for any file that exists in the repository but not - in your source, and for files that you haven't changed but are - not the most recent versions available in the repository. - -`Modified' - The file is modified in your working directory, and there was - no modification to the same file in the repository. - -`Merged' - The file is modified in your working directory, and there were - modifications in the repository as well as in your copy, but - they were merged successfully, without conflict, in your working - directory. - -`Conflict' - A conflict was detected while trying to merge your changes to - FILE with changes from the source repository. FILE (the copy in - your working directory) is now the output of the `rcsmerge' - command on the two versions; an unmodified copy of your file is - also in your working directory, with the name `.#FILE.VERSION', - where VERSION is the RCS revision that your modified file started - from. *Note Viewing differences::, for more details. - -`Added' - The file has been added by you, but it still needs to be checked - in to the repository. - -`Removed' - The file has been removed by you, but it needs to be checked in - to the repository. You can resurrect it by typing `a' (*note - Adding and removing files::.). - -`Unknown' - A file that was detected in your directory, but that neither - appears in the repository, nor is present on the list of files - that CVS should ignore. - - There are also a few special cases, that rarely occur, which have -longer strings in the fields: - -`Removed from repository' - The file has been removed from your directory since someone has - removed it from the repository. (It is still present in the - Attic directory, so no permanent loss has occurred). This, - unlike the other entries in this table, is not an error - condition. - -`Removed from repository, changed by you' - You have modified a file that someone have removed from the - repository. You can correct this situation by removing the file - manually (see *note Adding and removing files::.). - -`Removed by you, changed in repository' - You have removed a file, and before you committed the removal - someone committed a change to that file. You could use `a' to - resurrect the file (see *note Adding and removing files::.). - -`Move away FILE - it is in the way' - For some reason CVS does not like the file FILE. Rename or - remove it. - -`This repository is missing! Remove this dir manually.' - It is impossible to remove a directory in the CVS repository in - a clean way. Someone have tried to remove one, and CVS gets - confused. Remove your copy of the directory. - - -File: pcl-cvs, Node: Selected files, Prev: File status, Up: Buffer contents - -Selected files -============== - - Many of the commands works on the current set of "selected" files. - - * If there are any files that are marked they constitute the set of - selected files. - - * Otherwise, if the cursor points to a file, that file is the - selected file. - - * Otherwise, if the cursor points to a directory, all the files in - that directory that appears in the buffer are the selected files. - - This scheme might seem a little complicated, but once one get used -to it, it is quite powerful. - - *Note Marking files:: tells how you mark and unmark files. - - -File: pcl-cvs, Node: Commands, Next: Customization, Prev: Buffer contents, Up: Top - -Commands -******** - - The nodes in this menu contains explanations about all the -commands that you can use in pcl-cvs. They are grouped together by -type. - -* Menu: - -* Updating the directory:: Commands to update the local directory -* Movement commands:: How to move up and down in the buffer -* Marking files:: How to mark files that other commands - will later operate on. -* Committing changes:: Checking in your modifications to the - CVS repository. -* Editing files:: Loading files into Emacs. -* Getting info about files:: Display the log and status of files. -* Adding and removing files:: Adding and removing files -* Undoing changes:: Undoing changes -* Removing handled entries:: Uninteresting lines can easily be removed. -* Ignoring files:: Telling CVS to ignore generated files. -* Viewing differences:: Commands to `diff' different versions. -* Emerge:: -* Reverting your buffers:: Reverting your buffers -* Miscellaneous commands:: Miscellaneous commands - - -File: pcl-cvs, Node: Updating the directory, Next: Movement commands, Prev: Commands, Up: Commands - -Updating the directory -====================== - -`M-x cvs-update' - Run a `cvs update' command. You will be asked for the directory - in which the `cvs update' will be run. The output will be - parsed by pcl-cvs, and the result printed in the `*cvs*' buffer - (see *note Buffer contents::. for a description of the contents). - - By default, `cvs-update' will descend recursively into - subdirectories. You can avoid that behavior by giving a prefix - argument to it (e.g., by typing `C-u M-x cvs-update RET'). - - All other commands in pcl-cvs requires that you have a `*cvs*' - buffer. This is the command that you use to get one. - - CVS uses lock files in the repository to ensure the integrity of - the data files in the repository. They might be left behind - i.e. if a workstation crashes in the middle of a CVS operation. - CVS outputs a message when it is waiting for a lock file to go - away. Pcl-cvs will show the same message in the *cvs* buffer, - together with instructions for deleting the lock files. You - should normally not have to delete them manually -- just wait a - little while and the problem should fix itself. But if the lock - files doesn't disappear you can delete them with `M-x - cvs-delete-lock RET'. - -`g' - This will run `cvs update' again. It will always use the same - buffer that was used with the previous `cvs update'. Give a - prefix argument to avoid descending into subdirectories. This - runs the command `cvs-mode-update-no-prompt'. - - -File: pcl-cvs, Node: Movement commands, Next: Marking files, Prev: Updating the directory, Up: Commands - -Movement Commands -================= - - You can use most normal Emacs commands to move forward and -backward in the buffer. Some keys are rebound to functions that take -advantage of the fact that the buffer is a pcl-cvs buffer: - -`SPC' -`C-n' -`n' - These keys move the cursor one file forward, towards the end of - the buffer (`cookie-next-cookie'). - -`C-p' -`p' - These keys move one file backward, towards the beginning of the - buffer (`cookie-previous-cookie'). - - -File: pcl-cvs, Node: Marking files, Next: Committing changes, Prev: Movement commands, Up: Commands - -Marking files -============= - - Pcl-cvs works on a set of "selected files" (*note Selected -files::.). You can mark and unmark files with these commands: - -`m' - This marks the file that the cursor is positioned on. If the - cursor is positioned on a directory all files in that directory - will be marked. (`cvs-mode-mark'). - -`u' - Unmark the file that the cursor is positioned on. If the cursor - is on a directory, all files in that directory will be unmarked. - (`cvs-mode-unmark'). - -`M' - Mark *all* files in the buffer (`cvs-mode-mark-all-files'). - -`ESC DEL' - Unmark *all* files (`cvs-mode-unmark-all-files'). - -`DEL' - Unmark the file on the previous line, and move point to that line - (`cvs-mode-unmark-up'). - - -File: pcl-cvs, Node: Committing changes, Next: Editing files, Prev: Marking files, Up: Commands - -Committing changes -================== - -`c' - All files that have a "need to be checked in"-marker (*note - Buffer contents::.) can be checked in with the `c' command. It - checks in all selected files (*note Selected files::.) (except - those who lack the "ci"-marker - they are ignored). Pressing - `c' causes `cvs-mode-commit' to be run. - - When you press `c' you will get a buffer called - `*cvs-commit-message*'. Enter the log message for the file(s) in - it. When you are ready you should press `C-c C-c' to actually - commit the files (using `cvs-edit-done'). - - Normally the `*cvs-commit-message*' buffer will retain the log - message from the previous commit, but if the variable - `cvs-erase-input-buffer' is set to a non-`nil' value the buffer - will be erased. Point and mark will always be located around the - entire buffer so that you can easily erase it with `C-w' - (`kill-region'). - - If you are editing the files in your emacs an automatic - `revert-buffer' will be performed. (If the file contains `$Id$' - keywords `cvs commit' will write a new file with the new values - substituted. The auto-revert makes sure that you get them into - your buffer). The revert will not occur if you have modified - your buffer, or if `cvs-auto-revert-after-commit' is set to - `nil'. - - -File: pcl-cvs, Node: Editing files, Next: Getting info about files, Prev: Committing changes, Up: Commands - -Editing files -============= - - There are currently three commands that can be used to find a file -(that is, load it into a buffer and start editing it there). These -commands work on the line that the cursor is situated at. They -ignore any marked files. - -`f' - Find the file that the cursor points to. Run `dired' (*note - Dired: (Emacs)Dired.) if the cursor points to a directory - (`cvs-mode-find-file'). - -`o' - Like `f', but use another window - (`cvs-mode-find-file-other-window'). - -`A' - Invoke `add-change-log-entry-other-window' to edit a `ChangeLog' - file. The `ChangeLog' will be found in the directory of the - file the cursor points to. - (`cvs-mode-add-change-log-entry-other-window'). - - -File: pcl-cvs, Node: Getting info about files, Next: Adding and removing files, Prev: Editing files, Up: Commands - -Getting info about files -======================== - - Both of the following commands can be customized. *Note -Customization::. - -`l' - Run `cvs log' on all selected files, and show the result in a - temporary buffer (`cvs-mode-log'). - -`s' - Run `cvs status' on all selected files, and show the result in a - temporary buffer (`cvs-mode-status'). - - -File: pcl-cvs, Node: Adding and removing files, Next: Undoing changes, Prev: Getting info about files, Up: Commands - -Adding and removing files -========================= - - The following commands are available to make it easy to add and -remove files from the CVS repository. - -`a' - Add all selected files. This command can be used on `Unknown' - files (see *note File status::.). The status of the file will - change to `Added', and you will have to use `c' - (`cvs-mode-commit', see *note Committing changes::.) to really - add the file to the repository. - - This command can also be used on `Removed' files (before you - commit them) to resurrect them. - - Selected files that are neither `Unknown' nor `Removed' will be - ignored by this command. - - The command that is run is `cvs-mode-add'. - -`r' - This command removes the selected files (after prompting for - confirmation). The files are `rm'ed from your directory and - (unless the status was `Unknown'; *note File status::.) they will - also be `cvs remove'd. If the files were `Unknown' they will - disappear from the buffer. Otherwise their status will change to - `Removed', and you must use `c' (`cvs-mode-commit', *note - Committing changes::.) to commit the removal. - - The command that is run is `cvs-mode-remove-file'. - - -File: pcl-cvs, Node: Undoing changes, Next: Removing handled entries, Prev: Adding and removing files, Up: Commands - -Undoing changes -=============== - -`U' - If you have modified a file, and for some reason decide that you - don't want to keep the changes, you can undo them with this - command. It works by removing your working copy of the file and - then getting the latest version from the repository - (`cvs-mode-undo-local-changes'. - - -File: pcl-cvs, Node: Removing handled entries, Next: Ignoring files, Prev: Undoing changes, Up: Commands - -Removing handled entries -======================== - -`x' - This command allows you to remove all entries that you have - processed. More specifically, the lines for `Updated' files - (*note File status::. and files that have been checked in (*note - Committing changes::.) are removed from the buffer. If a - directory becomes empty the heading for that directory is also - removed. This makes it easier to get an overview of what needs - to be done. - - The command is called `cvs-mode-remove-handled'. If - `cvs-auto-remove-handled' is set to non-`nil' this will - automatically be performed after every commit. - -`C-k' - This command can be used for lines that - `cvs-mode-remove-handled' would not delete, but that you want to - delete (`cvs-mode-acknowledge'). - - -File: pcl-cvs, Node: Ignoring files, Next: Viewing differences, Prev: Removing handled entries, Up: Commands - -Ignoring files -============== - -`i' - Arrange so that CVS will ignore the selected files. The file - names are added to the `.cvsignore' file in the corresponding - directory. If the `.cvsignore' doesn't exist it will be created. - - The `.cvsignore' file should normally be added to the repository, - but you could ignore it also if you like it better that way. - - This runs `cvs-mode-ignore'. - - -File: pcl-cvs, Node: Viewing differences, Next: Emerge, Prev: Ignoring files, Up: Commands - -Viewing differences -=================== - -`d' - Display a `cvs diff' between the selected files and the RCS - version that they are based on. *Note Customization:: describes - how you can send flags to `cvs diff'. If CVS-DIFF-IGNORE-MARKS - is set to a non-`nil' value or if a prefix argument is given - (but not both) any marked files will not be considered to be - selected. (`cvs-mode-diff-cvs'). - -`b' - If CVS finds a conflict while merging two versions of a file - (during a `cvs update', *note Updating the directory::.) it will - save the original file in a file called `.#FILE.VERSION' where - FILE is the name of the file, and VERSION is the RCS version - number that your file was based on. - - With the `b' command you can run a `diff' on the files - `.#FILE.VERSION' and `FILE'. You can get a context- or Unidiff - by setting `cvs-diff-flags' - *note Customization::.. This - command only works on files that have status `Conflict' or - `Merged'. - - If CVS-DIFF-IGNORE-MARKS is set to a non-`nil' value or if a - prefix argument is given (but not both) any marked files will - not be considered to be selected. (`cvs-mode-diff-backup'). - - -File: pcl-cvs, Node: Emerge, Next: Reverting your buffers, Prev: Viewing differences, Up: Commands - -Running emerge -============== - -`e' - Invoke `emerge' on one file. This command works slightly - different depending on the file status. - - `Modified' - Run `emerge-files' with your working file as file A, and - the latest revision in the repository as file B. - - `Merged' - `Conflict' - Run `emerge-files-with-ancestor' with your working file (as - it was prior to your invocation of `cvs-update') as file A, - the latest revision in the repository as file B, and the - revision that you based your local modifications on as - ancestor. - - *Note:* CVS has already performed a merge. The resulting file is - not used in any way if you use this command. If you use the `q' - command inside `emerge' (to successfully terminate the merge) the - file that CVS created will be overwritten. - - -File: pcl-cvs, Node: Reverting your buffers, Next: Miscellaneous commands, Prev: Emerge, Up: Commands - -Reverting your buffers -====================== - -`R' - If you are editing (or just viewing) a file in a buffer, and - that file is changed by CVS during a `cvs-update', all you have - to do is type `R' in the *cvs* buffer to read in the new - versions of the files. - - All files that are `Updated', `Merged' or in `Conflict' are - reverted from the disk. Any other files are ignored. Only files - that you were already editing are read. - - An error is signalled if you have modified the buffer since it - was last changed. (`cvs-mode-revert-updated-buffers'). - - -File: pcl-cvs, Node: Miscellaneous commands, Prev: Reverting your buffers, Up: Commands - -Miscellaneous commands -====================== - -`M-x cvs-byte-compile-files' - Byte compile all selected files that end in .el. - -`M-x cvs-delete-lock' - This command can be used in any buffer, and deletes the lock - files that the *cvs* buffer informs you about. You should - normally never have to use this command since CVS tries very - carefully to always remove the lock files itself. - - You can only use this command when a message in the *cvs* buffer - tells you so. You should wait a while before using this command - in case someone else is running a cvs command. - -`q' - Bury the *cvs* buffer. (`bury-buffer'). - - -File: pcl-cvs, Node: Customization, Next: Future enhancements, Prev: Commands, Up: Top - -Customization -************* - - If you have an idea about any customization that would be handy but -isn't present in this list, please tell me! *Note Bugs:: for info on -how to reach me. - -`cvs-erase-input-buffer' - If set to anything else than `nil' the edit buffer will be erased - before you write the log message (*note Committing changes::.). - -`cvs-inhibit-copyright-message' - The copyright message that is displayed on startup can be - annoying after a while. Set this variable to `t' if you want to - get rid of it. (But don't set this to `t' in the system defaults - file - new users should see this message at least once). - -`cvs-diff-flags' - A list of strings to pass as arguments to the `cvs diff' and - `diff' programs. This is used by `cvs-mode-diff-cvs' and - `cvs-mode-diff-backup' (key `b', *note Viewing differences::.). - If you prefer the Unidiff format you could add this line to your - `.emacs' file: - - (setq cvs-diff-flags '("-u")) - -`cvs-diff-ignore-marks' - If this variable is non-`nil' or if a prefix argument is given - (but not both) to `cvs-mode-diff-cvs' or `cvs-mode-diff-backup' - marked files are not considered selected. - -`cvs-log-flags' - List of strings to send to `cvs log'. Used by `cvs-mode-log' - (key `l', *note Getting info about files::.). - -`cvs-status-flags' - List of strings to send to `cvs status'. Used by - `cvs-mode-status' (key `s', *note Getting info about files::.). - -`cvs-auto-remove-handled' - If this variable is set to any non-`nil' value - `cvs-mode-remove-handled' will be called every time you check in - files, after the check-in is ready. *Note Removing handled - entries::. - -`cvs-auto-revert-after-commit' - If this variable is set to any non-`nil' value any buffers you - have that visit a file that is committed will be automatically - reverted. This variable is default `t'. *Note Committing - changes::. - -`cvs-update-prog-output-skip-regexp' - The `-u' flag in the `modules' file can be used to run a command - whenever a `cvs update' is performed (see cvs(5)). This regexp - is used to search for the last line in that output. It is - normally set to `"$"'. That setting is only correct if the - command outputs nothing. Note that pcl-cvs will get very - confused if the command outputs *anything* to `stderr'. - -`cvs-cvsroot' - This variable can be set to override `CVSROOT'. It should be a - string. If it is set then everytime a cvs command is run it will - be called as `cvs -d CVS-CVSROOT...' This can be useful if your - site has several repositories. - -`TMPDIR' - Pcl-cvs uses this *environment variable* to decide where to put - the temporary files it needs. It defaults to `/tmp' if it is - not set. - -`cvs-commit-buffer-require-final-newline' - When you enter a log message in the `*cvs-commit-message*' buffer - pcl-cvs will normally automatically insert a trailing newline, - unless there already is one. This behavior can be controlled via - `cvs-commit-buffer-require-final-newline'. If it is `t' (the - default behavior), a newline will always be appended. If it is - `nil', newlines will never be appended. Any other value causes - pcl-cvs to ask the user whenever there is no trailing newline in - the commit message buffer. - -`cvs-sort-ignore-file' - If this variable is set to any non-`nil' value the `.cvsignore' - will always be sorted whenever you use `cvs-mode-ignore' to add - a file to it. This option is on by default. - - -File: pcl-cvs, Node: Future enhancements, Next: Bugs, Prev: Customization, Up: Top - -Future enhancements -******************* - - Pcl-cvs is still under development and needs a number of -enhancements to be called complete. Below is my current wish-list -for future releases of pcl-cvs. Please, let me know which of these -features you want most. They are listed below in approximately the -order that I currently think I will implement them in. - - * Rewritten parser code. There are many situations where pcl-cvs - will fail to recognize the output from CVS. The situation could - be greatly increased. - - * `cvs-status'. This will run `cvs status' in a directory and - produce a buffer that looks pretty much like the current *cvs* - buffer. That buffer will include information for all - version-controlled files. (There will be a simple keystroke to - remove all "uninteresting" files, that is, files that are - "Up-to-date"). In this new buffer you will be able to update a - file, commit a file, et c. The big win with this is that you - will be able to watch the differences between your current - working file and the head revision in the repository before you - update the file, and you can then choose to update it or let it - wait for a while longer. - - * Log mode. When this mode is finished you will be able to move - around (using `n' and `p') between the revisions of a file, mark - two of them, and run a diff between them. You will be able to - hide branches (similar to the way you can hide sub-paragraphs in - outline-mode) and do merges between revisions. Other ideas - about this are welcome. - - * The current model for marks in the *cvs* buffer seems to be - confusing. I am considering to use the VM model instead, where - marks are normally inactive. To activate the mark, you issue a - command like `cvs-mode-next-command-uses-marks'. I might - implement a flag so that you can use either version. Feedback - on this before I start coding it is very welcome. - - * It should be possible to run commands such as `cvs log', `cvs - status' and `cvs commit' directly from a buffer containing a - file, instead of having to `cvs-update'. If the directory - contains many files the `cvs-update' can take quite some time, - especially on a slow machine. I planed to put these kind of - commands on the prefix `C-c C-v', but that turned out to be used - by for instance c++-mode. If you have any suggestions for a - better prefix key, please let me know. - - * Increased robustness. For instance, you can not currently press - `C-g' when you are entering the description of a file that you - are adding without confusing pcl-cvs. - - * Support for multiple active *cvs* buffers. - - * Dired support. I have an experimental `dired-cvs.el' that works - together with CVS 1.2. Unfortunately I wrote it on top of a - non-standard `dired.el', so it must be rewritten. - - * An ability to send user-supplied options to all the cvs commands. - - * Pcl-cvs is not at all clever about what it should do when `cvs - update' runs a program (due to the `-u' option in the `modules' - file -- see `cvs(5)'). The current release uses a regexp to - search for the end. At the very least that regexp should be - configured for different modules. Tell me if you have any idea - about what is the right thing to do. In a perfect world the - program should also be allowed to print to `stderr' without - causing pcl-cvs to crash. - - If you miss something in this wish-list, let me know! I don't -promise that I will write it, but I will at least try to coordinate -the efforts of making a good Emacs front end to CVS. See *Note -Bugs:: for information about how to reach me. - - So far, I have written most of pcl-cvs in my all-to-rare spare -time. If you want pcl-cvs to be developed faster you can write a -contract with Signum Support to do the extension. You can reach -Signum Support by email to `info@signum.se' or via mail to Signum -Support AB, Box 2044, S-580 02 Linkoping, Sweden. Phone: +46 (0) 13 - -21 46 00. Fax: +46 (0) 13 - 21 47 00. - - -File: pcl-cvs, Node: Bugs, Next: Function and Variable Index, Prev: Future enhancements, Up: Top - -Bugs (known and unknown) -************************ - - If you find a bug or misfeature, don't hesitate to tell me! Send -email to `ceder@lysator.liu.se'. - - If you have ideas for improvements, or if you have written some -extensions to this package, I would like to hear from you. I hope -that you find this package useful! - - Below is a partial list of currently known problems with pcl-cvs -version 1.05. - -Commit causes Emacs to hang - Emacs waits for the `cvs commit' command to finish before you can - do anything. If you start a background job from the loginfo - file you must take care that it closes `stdout' and `stderr' if - you do not want to wait for it. (You do that with - `background-command &>- 2&>- &' if you are starting - `background-command' from a `/bin/sh' shell script). - - Your emacs will also hang if there was a lock file in the - repository. In this case you can type `C-g' to get control over - your emacs again. - -Name clash in Emacs 19 - This is really a bug in Elib or the Emacs 19 distribution. Both - Elib and Emacs 19.6 through at least 19.10 contains a file named - `cookie.el'. One of the files will have to be renamed, and we - are currently negotiating about which of the files to rename. - -Commands while cvs-update is running - It is possible to type commands in the *cvs* buffer while the - update is running, but error messages is all that you will get. - The error messages should be better. - -Unexpected output from CVS - Unexpected output from CVS confuses pcl-cvs. It will currently - create a bug report that you can mail to me. It should do - something more civilized. - - -File: pcl-cvs, Node: Function and Variable Index, Next: Concept Index, Prev: Bugs, Up: Top - -Function and Variable Index -*************************** - -* Menu: - -* bury-buffer: Miscellaneous commands. -* cookie-next-cookie: Movement commands. -* cookie-previous-cookie: Movement commands. -* cvs-auto-remove-handled (variable): Customization. -* cvs-auto-revert-after-commit (variable): Customization. -* cvs-auto-revert-after-commit (variable): Committing changes. -* cvs-byte-compile-files: Miscellaneous commands. -* cvs-commit-buffer-require-final-newline (variable): Customization. -* cvs-cvsroot (variable): Customization. -* cvs-delete-lock: Updating the directory. -* cvs-diff-flags (variable): Customization. -* cvs-diff-ignore-marks (variable): Customization. -* cvs-diff-ignore-marks (variable): Viewing differences. -* cvs-erase-input-buffer (variable): Customization. -* cvs-erase-input-buffer (variable): Committing changes. -* cvs-inhibit-copyright-message (variable): Customization. -* cvs-log-flags (variable): Customization. -* cvs-mode-acknowledge: Removing handled entries. -* cvs-mode-add: Adding and removing files. -* cvs-mode-add-change-log-entry-other-window: Editing files. -* cvs-mode-commit: Committing changes. -* cvs-mode-diff-backup: Viewing differences. -* cvs-mode-diff-cvs: Viewing differences. -* cvs-mode-emerge: Emerge. -* cvs-mode-find-file: Editing files. -* cvs-mode-find-file-other-window: Editing files. -* cvs-mode-ignore: Removing handled entries. -* cvs-mode-log: Getting info about files. -* cvs-mode-mark: Marking files. -* cvs-mode-mark-all-files: Marking files. -* cvs-mode-remove-file: Adding and removing files. -* cvs-mode-remove-handled: Removing handled entries. -* cvs-mode-revert-updated-buffers: Reverting your buffers. -* cvs-mode-status: Getting info about files. -* cvs-mode-undo-local-changes: Undoing changes. -* cvs-mode-unmark: Marking files. -* cvs-mode-unmark-all-files: Marking files. -* cvs-mode-unmark-up: Marking files. -* cvs-mode-update-no-prompt: Updating the directory. -* cvs-sort-ignore-file (variable): Customization. -* cvs-status-flags (variable): Customization. -* cvs-update: Updating the directory. -* cvs-update-prog-output-skip-regexp (variable): Customization. -* TMPDIR (environment variable): Customization. - - -File: pcl-cvs, Node: Concept Index, Next: Key Index, Prev: Function and Variable Index, Up: Top - -Concept Index -************* - -* Menu: - -* -u option in modules file: Customization. -* .cvsignore file, sorting: Customization. -* About pcl-cvs: About pcl-cvs. -* Active files: Selected files. -* Added (file status): File status. -* Adding files: Adding and removing files. -* Archives: Archives. -* Author, how to reach: Bugs. -* Authors: Contributors. -* Automatically inserting newline: Customization. -* Automatically remove handled files: Customization. -* Automatically sorting .cvsignore: Customization. -* Buffer contents: Buffer contents. -* Bugs, how to report them: Bugs. -* Bugs, known: Bugs. -* Byte compilation: Miscellaneous commands. -* Ci: Committing changes. -* Commit buffer: Committing changes. -* Commit message, inserting newline: Customization. -* Committing changes: Committing changes. -* Conflict (file status): File status. -* Conflicts, how to resolve them: Viewing differences. -* Conflicts, resolving: Emerge. -* Context diff, how to get: Customization. -* Contributors: Contributors. -* Copyright message, getting rid of it: Customization. -* Customization: Customization. -* Deleting files: Adding and removing files. -* Diff: Viewing differences. -* Dired: Editing files. -* Edit buffer: Committing changes. -* Editing files: Editing files. -* Email archives: Archives. -* Email to the author: Bugs. -* Emerge: Emerge. -* Enhancements: Future enhancements. -* Erasing commit message: Committing changes. -* Erasing the input buffer: Customization. -* Example run: Getting started. -* Expunging uninteresting entries: Removing handled entries. -* FAQ: Bugs. -* File selection: Selected files. -* File status: File status. -* Finding files: Editing files. -* Flush changes: Undoing changes. -* Ftp-sites: Archives. -* Generating a typeset manual: Typeset manual installation. -* Generating the on-line manual: On-line manual installation. -* Getting pcl-cvs: Archives. -* Getting rid of lock files: Miscellaneous commands. -* Getting rid of the Copyright message.: Customization. -* Getting rid of uninteresting lines: Removing handled entries. -* Getting status: Getting info about files. -* Getting the *cvs* buffer: Updating the directory. -* Handled lines, removing them: Removing handled entries. -* Info-file (how to generate): On-line manual installation. -* Inhibiting the Copyright message.: Customization. -* Installation: Installation. -* Installation of elisp files: Pcl-cvs installation. -* Installation of on-line manual: On-line manual installation. -* Installation of typeset manual: Typeset manual installation. -* Introduction: Getting started. -* Invoking dired: Editing files. -* Invoking emerge: Emerge. -* Known bugs: Bugs. -* Loading files: Editing files. -* Lock files: Miscellaneous commands. -* Log (RCS/cvs command): Getting info about files. -* Manual installation (on-line): On-line manual installation. -* Manual installation (typeset): Typeset manual installation. -* Marked files: Selected files. -* Marking files: Marking files. -* Merged (file status): File status. -* Modified (file status): File status. -* Modules file (-u option): Customization. -* Move away FILE - it is in the way (file status): File status. -* Movement Commands: Movement commands. -* On-line manual (how to generate): On-line manual installation. -* Printing a manual: Typeset manual installation. -* Problems, list of common: Bugs. -* Putting files under CVS control: Adding and removing files. -* Recompiling elisp files: Miscellaneous commands. -* Removed (file status): File status. -* Removed by you, changed in repository (file status): File status. -* Removed from repository (file status): File status. -* Removed from repository, changed by you (file status): File status. -* Removing files: Adding and removing files. -* Removing uninteresting (processed) lines: Removing handled entries. -* Reporting bugs and ideas: Bugs. -* Require final newline: Customization. -* Resolving conflicts: Emerge. -* Resurrecting files: Adding and removing files. -* Reverting buffers: Reverting your buffers. -* Reverting buffers after commit: Committing changes. -* Reverting buffers after commit: Customization. -* Selected files: Selected files. -* Selecting files (commands to mark files): Marking files. -* Sites: Archives. -* Sorting the .cvsignore file: Customization. -* Status (cvs command): Getting info about files. -* Syncing buffers: Reverting your buffers. -* TeX - generating a typeset manual: Typeset manual installation. -* This repository is missing!... (file status): File status. -* Undo changes: Undoing changes. -* Unidiff, how to get: Customization. -* Uninteresting entries, getting rid of them: Removing handled entries. -* Unknown (file status): File status. -* Update program (-u option in modules file): Customization. -* Updated (file status): File status. -* Variables, list of all: Customization. -* Viewing differences: Viewing differences. - - -File: pcl-cvs, Node: Key Index, Prev: Concept Index, Up: Top - -Key Index -********* - -* Menu: - -* a - add a file: Adding and removing files. -* A - add ChangeLog entry: Editing files. -* b - diff backup file: Viewing differences. -* c - commit files: Committing changes. -* C-k - remove selected entries: Removing handled entries. -* C-n - Move down one file: Movement commands. -* C-p - Move up one file: Movement commands. -* d - run cvs diff: Viewing differences. -* DEL - unmark previous file: Marking files. -* e - invoke emerge: Emerge. -* ESC DEL - unmark all files: Marking files. -* f - find file or directory: Editing files. -* g - Rerun cvs update: Updating the directory. -* l - run cvs log: Getting info about files. -* m - marking a file: Marking files. -* M - marking all files: Marking files. -* n - Move down one file: Movement commands. -* o - find file in other window: Editing files. -* p - Move up on file: Movement commands. -* q - bury the *cvs* buffer: Miscellaneous commands. -* r - remove a file: Adding and removing files. -* R - revert buffers: Reverting your buffers. -* s - run cvs status: Getting info about files. -* SPC - Move down one file: Movement commands. -* U - undo changes: Undoing changes. -* u - unmark a file: Marking files. -* x - remove processed entries: Removing handled entries. - - - -Tag Table: -Node: Top1007 -Node: Copying3571 -Node: Installation22803 -Node: Pcl-cvs installation23593 -Node: On-line manual installation25654 -Node: Typeset manual installation26672 -Node: About pcl-cvs27411 -Node: Contributors27780 -Node: Archives29083 -Node: Getting started29662 -Node: Buffer contents32105 -Node: File status32654 -Node: Selected files35679 -Node: Commands36347 -Node: Updating the directory37558 -Node: Movement commands39217 -Node: Marking files39803 -Node: Committing changes40658 -Node: Editing files42124 -Node: Getting info about files42969 -Node: Adding and removing files43448 -Node: Undoing changes44799 -Node: Removing handled entries45259 -Node: Ignoring files46176 -Node: Viewing differences46706 -Node: Emerge48014 -Node: Reverting your buffers48988 -Node: Miscellaneous commands49685 -Node: Customization50427 -Node: Future enhancements54107 -Node: Bugs58298 -Node: Function and Variable Index60079 -Node: Concept Index62872 -Node: Key Index69468 - -End Tag Table diff --git a/gnu/usr.bin/cvs/cvs/config.h b/gnu/usr.bin/cvs/cvs/config.h deleted file mode 100644 index b3bee5f97b09..000000000000 --- a/gnu/usr.bin/cvs/cvs/config.h +++ /dev/null @@ -1,217 +0,0 @@ -/* @(#)config.h 1.19 92/03/31 */ - -/* - * Copyright (c) 1992, Brian Berliner and Jeff Polk - * Copyright (c) 1989-1992, Brian Berliner - * - * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. - * - * This file holds (most of) the configuration tweaks that can be made to - * customize CVS for your site. CVS comes configured for a typical SunOS 4.x - * environment. The comments for each configurable item are intended to be - * self-explanatory. All #defines are tested first to see if an over-riding - * option was specified on the "make" command line. - * - * If special libraries are needed, you will have to edit the Makefile.in file - * or the configure script directly. Sorry. - */ - -/* - * CVS provides the most features when used in conjunction with the Version-5 - * release of RCS. Thus, it is the default. This also assumes that GNU diff - * Version-1.15 is being used as well -- you will have to configure your RCS - * V5 release separately to make this the case. If you do not have RCS V5 and - * GNU diff V1.15, comment out this define. You should not try mixing and - * matching other combinations of these tools. - */ -#ifndef HAVE_RCS5 -#define HAVE_RCS5 -#endif - -/* - * If, before installing this version of CVS, you were running RCS V4 AND you - * are installing this CVS and RCS V5 and GNU diff 1.15 all at the same time, - * you should turn on the following define. It only exists to try to do - * reasonable things with your existing checked out files when you upgrade to - * RCS V5, since the keyword expansion formats have changed with RCS V5. - * - * If you already have been running with RCS5, or haven't been running with CVS - * yet at all, or are sticking with RCS V4 for now, leave the commented out. - */ -#ifndef HAD_RCS4 -/* #define HAD_RCS4 */ -#endif - -/* - * For portability and heterogeneity reasons, CVS is shipped by default using - * my own text-file version of the ndbm database library in the src/myndbm.c - * file. If you want better performance and are not concerned about - * heterogeneous hosts accessing your modules file, turn this option off. - */ -#ifndef MY_NDBM -#define MY_NDBM -#endif - -/* - * The "diff" program to execute when creating patch output. This "diff" - * must support the "-c" option for context diffing. Specify a full pathname - * if your site wants to use a particular diff. If you are using the GNU - * version of diff (version 1.15 or later), this should be "diff -a". - * - * NOTE: this program is only used for the ``patch'' sub-command. The other - * commands use rcsdiff which will use whatever version of diff was specified - * when rcsdiff was built on your system. - */ -#ifndef DIFF -#define DIFF "diff" -#endif - -/* - * The "grep" program to execute when checking to see if a merged file had - * any conflicts. This "grep" must support the "-s" option and a standard - * regular expression as an argument. Specify a full pathname if your site - * wants to use a particular grep. - */ -#ifndef GREP -#define GREP "grep" -#endif - -/* - * The "rm" program to execute when pruning directories that are not part of - * a release. This "rm" must support the "-fr" options. Specify a full - * pathname if your site wants to use a particular rm. - */ -#ifndef RM -#define RM "rm" -#endif - -/* - * The "sort" program to execute when displaying the module database. Specify - * a full pathname if your site wants to use a particular sort. - */ -#ifndef SORT -#define SORT "sort" -#endif - -/* - * By default, RCS programs are executed with the shell or through execlp(), - * so the user's PATH environment variable is searched. If you'd like to - * bind all RCS programs to a certain directory (perhaps one not in most - * people's PATH) then set the default in RCSBIN_DFLT. Note that setting - * this here will cause all RCS programs to be executed from this directory, - * unless the user overrides the default with the RCSBIN environment variable - * or the "-b" option to CVS. - * - * This define should be either the empty string ("") or a full pathname to the - * directory containing all the installed programs from the RCS distribution. - */ -#ifndef RCSBIN_DFLT -#define RCSBIN_DFLT "" -#endif - -/* - * The default editor to use, if one does not specify the "-e" option to cvs, - * or does not have an EDITOR environment variable. I set this to just "vi", - * and use the shell to find where "vi" actually is. This allows sites with - * /usr/bin/vi or /usr/ucb/vi to work equally well (assuming that your PATH - * is reasonable). - */ -#ifndef EDITOR_DFLT -#define EDITOR_DFLT "vi" -#endif - -/* - * The Repository file holds the path to the directory within the source - * repository that contains the RCS ,v files for each CVS working directory. - * This path is either a full-path or a path relative to CVSROOT. - * - * The only advantage that I can see to having a relative path is that One can - * change the physical location of the master source repository, change one's - * CVSROOT environment variable, and CVS will work without problems. I - * recommend using full-paths. - */ -#ifndef RELATIVE_REPOS -/* #define RELATIVE_REPOS */ -#endif - -/* - * When committing or importing files, you must enter a log message. - * Normally, you can do this either via the -m flag on the command line or an - * editor will be started for you. If you like to use logging templates (the - * rcsinfo file within the $CVSROOT/CVSROOT directory), you might want to - * force people to use the editor even if they specify a message with -m. - * Enabling FORCE_USE_EDITOR will cause the -m message to be appended to the - * temp file when the editor is started. - */ -#ifndef FORCE_USE_EDITOR -/* #define FORCE_USE_EDITOR */ -#endif - -/* - * When locking the repository, some sites like to remove locks and assume - * the program that created them went away if the lock has existed for a long - * time. This used to be the default for previous versions of CVS. CVS now - * attempts to be much more robust, so lock files should not be left around - * by mistake. The new behaviour will never remove old locks (they must now - * be removed by hand). Enabling CVS_FUDGELOCKS will cause CVS to remove - * locks that are older than CVSLCKAGE seconds. - * Use of this option is NOT recommended. - */ -#ifndef CVS_FUDGELOCKS -/* #define CVS_FUDGELOCKS */ -#endif - -/* - * When committing a permanent change, CVS and RCS make a log entry of - * who committed the change. If you are committing the change logged in - * as "root" (not under "su" or other root-priv giving program), CVS/RCS - * cannot determine who is actually making the change. - * - * As such, by default, CVS disallows changes to be committed by users - * logged in as "root". You can disable this option by commenting - * out the lines below. - */ -#ifndef CVS_BADROOT -#define CVS_BADROOT -#endif - -/* - * The "cvs diff" command accepts all the single-character options that GNU - * diff (1.15) accepts. Except -D. GNU diff uses -D as a way to put - * cpp-style #define's around the output differences. CVS, by default, uses - * -D to specify a free-form date (like "cvs diff -D '1 week ago'"). If - * you would prefer that the -D option of "cvs diff" work like the GNU diff - * option, then comment out this define. - */ -#ifndef CVS_DIFFDATE -#define CVS_DIFFDATE -#endif - -/* End of CVS configuration section */ - -/* - * Externs that are included in libc, but are used frequently enough to - * warrant defining here. - */ -#ifndef STDC_HEADERS -extern void exit (); -#endif - -#ifndef getwd -extern char *getwd (); -#endif - -/* - * Some UNIX distributions don't include these in their stat.h Defined here - * because "config.h" is always included last. - */ -#ifndef S_IWRITE -#define S_IWRITE 0000200 /* write permission, owner */ -#endif -#ifndef S_IWGRP -#define S_IWGRP 0000020 /* write permission, grougroup */ -#endif -#ifndef S_IWOTH -#define S_IWOTH 0000002 /* write permission, other */ -#endif diff --git a/gnu/usr.bin/cvs/cvs/version.c b/gnu/usr.bin/cvs/cvs/version.c deleted file mode 100644 index 18a9d14f2b3d..000000000000 --- a/gnu/usr.bin/cvs/cvs/version.c +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 1992, Brian Berliner and Jeff Polk - * Copyright (c) 1989-1992, Brian Berliner - * - * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. - * - * version.c - the CVS version number - */ - -char *version_string = "\nConcurrent Versions System (CVS) 1.3\n"; diff --git a/gnu/usr.bin/cvs/doc/cvs.ms b/gnu/usr.bin/cvs/doc/cvs.ms deleted file mode 100644 index 567179b393f8..000000000000 --- a/gnu/usr.bin/cvs/doc/cvs.ms +++ /dev/null @@ -1,1073 +0,0 @@ -.\" soelim cvs.ms | pic | tbl | troff -ms -.\" @(#)cvs.ms 1.2 92/01/30 -.\" -.\" troff source to the cvs USENIX article, Winter 1990, Washington, D.C. -.\" Copyright (c) 1989, Brian Berliner -.\" -.\" 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 1, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -.\" -.\" The author can be reached at: berliner@prisma.com -.\" -.de SP -.if n .sp -.if t .sp .5 -.. -.de hl -.br -.in +0.5i -\l'\\n(LLu-1i' -.in -0.5i -.sp -.. -.OH "" -.nr PS 11 -.nr PO 1.25i -.pl -0.2i -.TL -.ps 14 -.ft B -.nf -CVS II: -Parallelizing Software Development -.fi -.ft -.ps -.AU -.ps 12 -.ft I -Brian Berliner -.ft -.ps -.AI -.ps 12 -.ft I -Prisma, Inc. -5465 Mark Dabling Blvd. -Colorado Springs, CO 80918 -berliner@prisma.com -.ft -.ps -.AB -The program described in this paper fills a need in the UNIX -community for a freely available tool to manage software revision and -release control in a multi-developer, multi-directory, multi-group -environment. -This tool also addresses the increasing need for tracking third-party vendor -source distributions while trying to maintain local modifications to -earlier releases. -.AE -.NH -Background -.PP -In large software development projects, it is usually necessary for more -than one software developer to be modifying (usually different) modules of the -code at the same time. -Some of these code modifications are done in an -experimental sense, at least until the code functions correctly, and some -testing of the entire program is usually necessary. -Then, the modifications are returned to a master source repository -so that others in the project can -enjoy the new bug-fix or functionality. -In order to manage such a project, some sort of revision control system is -necessary. -.PP -Specifically, UNIX\** -.FS -UNIX is a registered trademark of AT&T. -.FE -kernel development is an excellent example of the -problems that an adequate revision control system must address. -The SunOS\** -.FS -SunOS is a trademark of Sun Microsystems, Inc. -.FE -kernel is composed of over a thousand files spread across a -hierarchy of dozens of directories.\** -.FS -Yes, the SunOS 4.0 kernel is composed of over a \fIthousand\fP files! -.FE -Pieces of the kernel must be edited -by many software developers within an organization. -While undesirable in -theory, it is not uncommon to have two or more people making -modifications to the same file within the kernel sources in -order to facilitate a desired change. -Existing revision control systems like -.SM -RCS -.LG -[Tichy] or -.SM -SCCS -.LG -[Bell] serialize file modifications by -allowing only one developer to have a writable copy of a particular file at -any one point in time. -That developer is said to -have \*Qlocked\*U the file for his exclusive use, and no other developer is -allowed to check out a writable copy of the file until the locking -developer has finished impeding others' productivity. -Development pressures of productivity and deadlines -often force organizations to require that multiple developers be able to -simultaneously edit -copies of the same revision controlled file. -.PP -The necessity for multiple developers to modify the same file concurrently -questions the value of serialization-based policies in traditional revision -control. -This paper discusses the approach that -Prisma took in adapting a standard revision control system, -.SM -RCS\c -.LG -, along with an existing public-domain collection of shell scripts that sits -atop -.SM -RCS -.LG -and provides the basic conflict-resolution algorithms. -The resulting -program, \fBcvs\fP, addresses not only the issue of conflict-resolution in -a multi-developer open-editing environment, but also the issues of -software release control and vendor source support and integration. -.NH -The CVS Program -.PP -\fBcvs\fP -(Concurrent Versions System) -is a front end to the -.SM -RCS -.LG -revision control system which extends -the notion of revision control from a collection of files in a single -directory to a hierarchical collection of directories each containing -revision controlled files. -Directories and files in the \fBcvs\fP system can be combined together in -many ways to form a software release. -\fBcvs\fP -provides the functions necessary to manage these software releases and to -control the concurrent editing of source files among multiple software -developers. -.PP -The six major features of \fBcvs\fP are listed below, and will be -described in more detail in the following sections: -.RS -.IP 1. -Concurrent access and conflict-resolution algorithms to guarantee that -source changes are not \*Qlost.\*U -.IP 2. -Support for tracking third-party vendor source distributions while -maintaining the local modifications made to those sources. -.IP 3. -A flexible module database that provides a symbolic mapping of names to -components of a larger software distribution. -This symbolic mapping provides for location independence within the software -release and, for example, allows one to check out a copy of the \*Qdiff\*U -program without ever knowing that the sources to \*Qdiff\*U actually reside -in the \*Qbin/diff\*U directory. -.IP 4. -Configurable logging support allows all \*Qcommitted\*U source file changes -to be logged using an arbitrary program to save the log messages in a file, -notesfile, or news database. -.IP 5. -A software release can be symbolically tagged and checked out at any time -based on that tag. -An exact copy of a previous software release can be checked out at -any time, \fIregardless\fP of whether files or directories have been -added/removed from the \*Qcurrent\*U software release. -As well, -a \*Qdate\*U can be used to check out the \fIexact\fP version of the software -release as of the specified date. -.IP 6. -A \*Qpatch\*U format file [Wall] can be produced between two software -releases, even if the releases span multiple directories. -.RE -.PP -The sources maintained by \fBcvs\fP are kept within a single directory -hierarchy known as the \*Qsource repository.\*U -This \*Qsource repository\*U holds the actual -.SM -RCS -.LG -\*Q,v\*U files directly, as well as a special per-repository directory -(\c -.SM -CVSROOT.adm\c -.LG -) which contains a small number of administrative files that describe the -repository and how it can be accessed. -See Figure 1 for a picture of the \fBcvs\fP tree. -.KF -.hl -.DS B -.PS -line from 4.112,9.200 to 5.550,8.887 -line from 5.447,8.884 to 5.550,8.887 to 5.458,8.933 -line from 4.112,9.200 to 4.550,8.950 -line from 4.451,8.978 to 4.550,8.950 to 4.476,9.021 -line from 4.112,9.200 to 3.737,8.887 -line from 3.798,8.971 to 3.737,8.887 to 3.830,8.932 -line from 3.612,8.762 to 4.737,8.137 -line from 4.638,8.164 to 4.737,8.137 to 4.662,8.208 -line from 3.612,8.762 to 3.737,8.137 -line from 3.693,8.231 to 3.737,8.137 to 3.742,8.240 -line from 3.612,8.762 to 2.612,8.200 -line from 2.687,8.271 to 2.612,8.200 to 2.712,8.227 -line from 2.362,9.262 to 2.737,8.950 -line from 2.645,8.995 to 2.737,8.950 to 2.677,9.033 -line from 2.362,9.262 to 1.925,8.950 -line from 1.992,9.028 to 1.925,8.950 to 2.021,8.988 -line from 3.362,9.762 to 4.050,9.387 -line from 3.950,9.413 to 4.050,9.387 to 3.974,9.457 -line from 3.362,9.762 to 2.487,9.387 -line from 2.570,9.450 to 2.487,9.387 to 2.589,9.404 -.ps 11 -"newfs.c,v" at 4.487,8.043 ljust -.ps 11 -"mkfs.c,v" at 3.487,8.043 ljust -.ps 11 -"Makefile,v" at 2.237,8.043 ljust -.ps 11 -"newfs" at 3.487,8.793 ljust -.ps 11 -"halt.c,v" at 5.487,8.793 ljust -.ps 11 -"Makefile,v" at 4.237,8.793 ljust -.ps 11 -"modules,v" at 2.487,8.793 ljust -.ps 11 -"loginfo,v" at 1.488,8.793 ljust -.ps 11 -"etc" at 3.987,9.293 ljust -.ps 11 -"CVSROOT.adm" at 1.988,9.293 ljust -.ps 11 -"/src/master" at 2.987,9.793 ljust -.PE -.DE -.hl -.ce 100 -.LG -\fBFigure 1.\fP -.SM -\fBcvs\fP Source Repository -.ce 0 -.sp -.KE -.NH 2 -Software Conflict Resolution\** -.FS -The basic conflict-resolution algorithms -used in the \fBcvs\fP program find their roots -in the original work done by Dick Grune at Vrije Universiteit in Amsterdam -and posted to \fBcomp.sources.unix\fP in the volume 6 release sometime in 1986. -This original version of \fBcvs\fP was a collection of shell scripts that -combined to form a front end to the -.SM -RCS -.LG -programs. -.FE -.PP -\fBcvs\fP allows several software developers to edit personal copies of a -revision controlled file concurrently. -The revision number of each checked out file is maintained independently -for each user, and \fBcvs\fP forces the checked out file to be current with -the \*Qhead\*U revision before it can be \*Qcommitted\*U as a permanent change. -A checked out file is brought up-to-date with the \*Qhead\*U revision using -the \*Qupdate\*U command of \fBcvs\fP. -This command compares the \*Qhead\*U revision number with that of the user's -file and performs an -.SM -RCS -.LG -merge operation if they are not the same. -The result of the merge is a file that contains the user's modifications -and those modifications that were \*Qcommitted\*U after the user -checked out his version of the file (as well as a backup copy of the -user's original file). -\fBcvs\fP points out any conflicts during the merge. -It is the user's responsibility to resolve these conflicts -and to \*Qcommit\*U his/her changes when ready. -.PP -Although the \fBcvs\fP conflict-resolution algorithm was defined in 1986, -it is remarkably similar to the \*QCopy-Modify-Merge\*U scenario included -with NSE\** -.FS -NSE is the Network Software Environment, a product of Sun Microsystems, Inc. -.FE -and described in [Honda] and [Courington]. -The following explanation from [Honda] also applies to \fBcvs\fP: -.QP -Simply stated, a developer copies an object without locking it, modifies -the copy, and then merges the modified copy with the original. -This paradigm allows developers to work in isolation from one another since -changes are made to copies of objects. -Because locks are not used, development is not serialized and can proceed -in parallel. -Developers, however, must merge objects after the changes have been made. -In particular, a developer must resolve conflicts when the same object has -been modified by someone else. -.PP -In practice, Prisma has found that conflicts that occur when the same -object has been modified by someone else are quite rare. -When they do happen, the changes made by the other developer are usually -easily resolved. -This practical use has shown that the \*QCopy-Modify-Merge\*U paradigm is a -correct and useful one. -.NH 2 -Tracking Third-Party Source Distributions -.PP -Currently, a large amount of software is based on source -distributions from a third-party distributor. -It is often the case that local modifications are to be made to this -distribution, \fIand\fP that the vendor's future releases should be -tracked. -Rolling your local modifications forward into the new vendor release is a -time-consuming task, but \fBcvs\fP can ease this burden somewhat. -The \fBcheckin\fP program of \fBcvs\fP initially sets up a source -repository by integrating the source modules directly from the vendor's -release, preserving the directory hierarchy of the vendor's distribution. -The branch support of -.SM -RCS -.LG -is used to build this vendor release as a branch of the main -.SM -RCS -.LG -trunk. -Figure 2 shows how the \*Qhead\*U tracks a sample vendor -branch when no local modifications have been made to the file. -.KF -.hl -.DS B -.PS -ellipse at 3.237,6.763 wid 1.000 ht 0.500 -dashwid = 0.050i -line dashed from 3.237,7.513 to 3.737,7.513 to 3.737,9.762 to 4.237,9.762 -line from 4.138,9.737 to 4.237,9.762 to 4.138,9.787 -line dashed from 2.237,8.262 to 3.237,8.262 to 3.237,7.013 -line from 3.212,7.112 to 3.237,7.013 to 3.262,7.112 -line from 3.737,6.763 to 4.237,6.763 -line from 4.138,6.737 to 4.237,6.763 to 4.138,6.788 -line from 2.237,6.763 to 2.737,6.763 -line from 2.637,6.737 to 2.737,6.763 to 2.637,6.788 -line from 1.738,6.013 to 1.738,6.513 -line from 1.762,6.413 to 1.738,6.513 to 1.713,6.413 -line from 1.238,7.013 to 2.237,7.013 to 2.237,6.513 to 1.238,6.513 to 1.238,7.013 -line from 4.237,9.012 to 5.237,9.012 to 5.237,8.512 to 4.237,8.512 to 4.237,9.012 -line from 4.237,8.012 to 5.237,8.012 to 5.237,7.513 to 4.237,7.513 to 4.237,8.012 -line from 4.237,7.013 to 5.237,7.013 to 5.237,6.513 to 4.237,6.513 to 4.237,7.013 -line from 4.737,7.013 to 4.737,7.513 -line from 4.763,7.413 to 4.737,7.513 to 4.712,7.413 -line from 4.737,8.012 to 4.737,8.512 -line from 4.763,8.412 to 4.737,8.512 to 4.712,8.412 -line from 4.237,10.012 to 5.237,10.012 to 5.237,9.512 to 4.237,9.512 to 4.237,10.012 -line from 4.737,9.012 to 4.737,9.512 -line from 4.763,9.412 to 4.737,9.512 to 4.712,9.412 -line from 5.987,5.013 to 5.987,6.013 to 0.988,6.013 to 0.988,5.013 to 5.987,5.013 -.ps 11 -"\"HEAD\"" at 1.550,8.231 ljust -.ps 11 -"'SunOS'" at 2.987,6.293 ljust -.ps 11 -"1.1.1" at 3.050,6.793 ljust -.ps 11 -"1.1" at 1.613,6.793 ljust -.ps 11 -"1.1.1.1" at 4.487,6.793 ljust -.ps 11 -"1.1.1.2" at 4.487,7.793 ljust -.ps 11 -"1.1.1.3" at 4.487,8.793 ljust -.ps 11 -"1.1.1.4" at 4.487,9.793 ljust -.ps 11 -"'SunOS_4_0'" at 5.487,6.793 ljust -.ps 11 -"'SunOS_4_0_1'" at 5.487,7.793 ljust -.ps 11 -"'YAPT_5_5C'" at 5.487,8.793 ljust -.ps 11 -"'SunOS_4_0_3'" at 5.487,9.793 ljust -.ps 11 -"rcsfile.c,v" at 2.987,5.543 ljust -.PE -.DE -.hl -.ce 100 -.LG -\fBFigure 2.\fP -.SM -\fBcvs\fP Vendor Branch Example -.ce 0 -.sp .3 -.KE -Once this is done, developers can check out files and make local changes to -the vendor's source distribution. -These local changes form a new branch to the tree which is then used as the -source for future check outs. -Figure 3 shows how the \*Qhead\*U moves to the main -.SM -RCS -.LG -trunk when a local modification is made. -.KF -.hl -.DS B -.PS -ellipse at 3.237,6.763 wid 1.000 ht 0.500 -dashwid = 0.050i -line dashed from 2.800,9.075 to 1.738,9.075 to 1.738,8.012 -line from 1.713,8.112 to 1.738,8.012 to 1.762,8.112 -line from 1.738,7.013 to 1.738,7.513 -line from 1.762,7.413 to 1.738,7.513 to 1.713,7.413 -line from 1.238,8.012 to 2.237,8.012 to 2.237,7.513 to 1.238,7.513 to 1.238,8.012 -line from 3.737,6.763 to 4.237,6.763 -line from 4.138,6.737 to 4.237,6.763 to 4.138,6.788 -line from 2.237,6.763 to 2.737,6.763 -line from 2.637,6.737 to 2.737,6.763 to 2.637,6.788 -line from 1.738,6.013 to 1.738,6.513 -line from 1.762,6.413 to 1.738,6.513 to 1.713,6.413 -line from 1.238,7.013 to 2.237,7.013 to 2.237,6.513 to 1.238,6.513 to 1.238,7.013 -line from 4.237,9.012 to 5.237,9.012 to 5.237,8.512 to 4.237,8.512 to 4.237,9.012 -line from 4.237,8.012 to 5.237,8.012 to 5.237,7.513 to 4.237,7.513 to 4.237,8.012 -line from 4.237,7.013 to 5.237,7.013 to 5.237,6.513 to 4.237,6.513 to 4.237,7.013 -line from 4.737,7.013 to 4.737,7.513 -line from 4.763,7.413 to 4.737,7.513 to 4.712,7.413 -line from 4.737,8.012 to 4.737,8.512 -line from 4.763,8.412 to 4.737,8.512 to 4.712,8.412 -line from 4.237,10.012 to 5.237,10.012 to 5.237,9.512 to 4.237,9.512 to 4.237,10.012 -line from 4.737,9.012 to 4.737,9.512 -line from 4.763,9.412 to 4.737,9.512 to 4.712,9.412 -line from 5.987,5.013 to 5.987,6.013 to 0.988,6.013 to 0.988,5.013 to 5.987,5.013 -.ps 11 -"1.2" at 1.613,7.793 ljust -.ps 11 -"\"HEAD\"" at 2.862,9.043 ljust -.ps 11 -"'SunOS'" at 2.987,6.293 ljust -.ps 11 -"1.1.1" at 3.050,6.793 ljust -.ps 11 -"1.1" at 1.613,6.793 ljust -.ps 11 -"1.1.1.1" at 4.487,6.793 ljust -.ps 11 -"1.1.1.2" at 4.487,7.793 ljust -.ps 11 -"1.1.1.3" at 4.487,8.793 ljust -.ps 11 -"1.1.1.4" at 4.487,9.793 ljust -.ps 11 -"'SunOS_4_0'" at 5.487,6.793 ljust -.ps 11 -"'SunOS_4_0_1'" at 5.487,7.793 ljust -.ps 11 -"'YAPT_5_5C'" at 5.487,8.793 ljust -.ps 11 -"'SunOS_4_0_3'" at 5.487,9.793 ljust -.ps 11 -"rcsfile.c,v" at 2.987,5.543 ljust -.PE -.DE -.hl -.ce 100 -.LG -\fBFigure 3.\fP -.SM -\fBcvs\fP Local Modification to Vendor Branch -.ce 0 -.sp -.KE -.PP -When a new version of the vendor's source distribution arrives, the -\fBcheckin\fP program adds the new and changed vendor's files to the -already existing source repository. -For files that have not been changed locally, the new file from the -vendor becomes the current \*Qhead\*U revision. -For files that have been modified locally, \fBcheckin\fP warns that the -file must be merged with the new vendor release. -The \fBcvs\fP \*Qjoin\*U command is a useful tool that aids this process by -performing the necessary -.SM -RCS -.LG -merge, as is done above when performing an \*Qupdate.\*U -.PP -There is also limited support for \*Qdual\*U derivations for source files. -See Figure 4 for a sample dual-derived file. -.KF -.hl -.DS B -.PS -ellipse at 2.337,8.575 wid 0.700 ht 0.375 -ellipse at 2.312,9.137 wid 0.700 ht 0.375 -line from 1.225,9.012 to 1.225,9.363 -line from 1.250,9.263 to 1.225,9.363 to 1.200,9.263 -line from 0.875,9.725 to 1.600,9.725 to 1.600,9.363 to 0.875,9.363 to 0.875,9.725 -line from 0.875,9.012 to 1.600,9.012 to 1.600,8.650 to 0.875,8.650 to 0.875,9.012 -line from 4.050,10.200 to 4.775,10.200 to 4.775,9.850 to 4.050,9.850 to 4.050,10.200 -line from 4.050,9.475 to 4.775,9.475 to 4.775,9.113 to 4.050,9.113 to 4.050,9.475 -line from 4.050,8.762 to 4.775,8.762 to 4.775,8.400 to 4.050,8.400 to 4.050,8.762 -line from 4.425,8.762 to 4.425,9.113 -line from 4.450,9.013 to 4.425,9.113 to 4.400,9.013 -line from 4.425,9.475 to 4.425,9.850 -line from 4.450,9.750 to 4.425,9.850 to 4.400,9.750 -line from 3.050,10.000 to 3.775,10.000 to 3.775,9.637 to 3.050,9.637 to 3.050,10.000 -line from 3.050,9.312 to 3.775,9.312 to 3.775,8.950 to 3.050,8.950 to 3.050,9.312 -line from 0.713,7.325 to 0.713,8.075 to 4.925,8.075 to 4.925,7.325 to 0.713,7.325 -line from 1.238,8.075 to 1.238,8.637 -line from 1.262,8.537 to 1.238,8.637 to 1.213,8.537 -line from 1.613,8.825 to 1.975,8.575 -line from 1.878,8.611 to 1.975,8.575 to 1.907,8.652 -line from 2.675,8.575 to 4.050,8.575 -line from 3.950,8.550 to 4.050,8.575 to 3.950,8.600 -line from 2.675,9.137 to 3.050,9.137 -line from 2.950,9.112 to 3.050,9.137 to 2.950,9.162 -line from 3.425,9.325 to 3.425,9.637 -line from 3.450,9.537 to 3.425,9.637 to 3.400,9.537 -line from 1.613,8.825 to 1.925,9.137 -line from 1.872,9.049 to 1.925,9.137 to 1.837,9.084 -.ps 11 -"'BSD'" at 2.138,9.481 ljust -.ps 11 -"1.2" at 1.113,9.543 ljust -.ps 11 -"1.1" at 1.125,8.831 ljust -.ps 11 -"1.1.1.1" at 4.175,8.543 ljust -.ps 11 -"1.1.1.2" at 4.175,9.281 ljust -.ps 11 -"1.1.1.3" at 4.175,9.993 ljust -.ps 11 -"1.1.2.2" at 3.175,9.793 ljust -.ps 11 -"1.1.2.1" at 3.175,9.106 ljust -.ps 11 -"rcsfile.c,v" at 2.425,7.706 ljust -.ps 11 -"1.1.1" at 2.175,8.568 ljust -.ps 11 -"'SunOS'" at 2.125,8.243 ljust -.ps 11 -"1.1.2" at 2.163,9.131 ljust -.PE -.DE -.hl -.ce 100 -.LG -\fBFigure 4.\fP -.SM -\fBcvs\fP Support For \*QDual\*U Derivations -.ce 0 -.sp -.KE -This example tracks the SunOS distribution but includes major changes from -Berkeley. -These BSD files are saved directly in the -.SM -RCS -.LG -file off a new branch. -.NH 2 -Location Independent Module Database -.PP -\fBcvs\fP contains support for a simple, yet powerful, \*Qmodule\*U database. -For reasons of efficiency, this database is stored in \fBndbm\fP\|(3) format. -The module database is used to apply names to collections of directories -and files as a matter of convenience for checking out pieces of a large -software distribution. -The database records the physical location of the sources as a form of -information hiding, allowing one to check out whole directory hierarchies -or individual files without regard for their actual location within the -global source distribution. -.PP -Consider the following small sample of a module database, which must be -tailored manually to each specific source repository environment: -.DS -\f(CW #key [-option argument] directory [files...] - diff bin/diff - libc lib/libc - sys -o sys/tools/make_links sys - modules -i mkmodules CVSROOT.adm modules - kernel -a sys lang/adb - ps bin Makefile ps.c\fP -.DE -.PP -The \*Qdiff\*U and \*Qlibc\*U modules refer to whole directory hierarchies that -are extracted on check out. -The \*Qsys\*U module extracts the \*Qsys\*U hierarchy, and runs the -\*Qmake_links\*U program at the end of the check out process (the \fI-o\fP -option specifies a program to run on check\fIo\fPut). -The \*Qmodules\*U module allows one to edit the module database file and -runs the \*Qmkmodules\*U program on check\fIi\fPn to regenerate the -\fBndbm\fP database that \fBcvs\fP uses. -The \*Qkernel\*U module is an alias (as the \fI-a\fP option specifies) -which causes the remaining arguments after the \fI-a\fP to be interpreted -exactly as if they had been specified on the command line. -This is useful for objects that require shared pieces of code from far away -places to be compiled (as is the case with the kernel debugger, \fBkadb\fP, -which shares code with the standard \fBadb\fP debugger). -The \*Qps\*U module shows that the source for \*Qps\*U lives in the \*Qbin\*U -directory, but only \fIMakefile\fP and \fIps.c\fP are required to build the -object. -.PP -The module database at Prisma is now populated for the entire UNIX -distribution and thereby allows us to issue the -following convenient commands to check out components of the UNIX -distribution without regard for their actual location within the master source -repository: -.DS -\f(CW example% cvs checkout diff - example% cvs checkout libc ps - example% cd diff; make\fP -.DE -.PP -In building the module database file, it is quite possible to have name -conflicts within a global software distribution. -For example, SunOS provides two \fBcat\fP programs: -one for the standard environment, \fI/bin/cat\fP, and one for the System V -environment, \fI/usr/5bin/cat\fP. -We resolved this conflict by naming the standard \fBcat\fP module -\*Qcat\*U, and the System V \fBcat\fP module \*Q5cat\*U. -Similar name modifications must be applied to other conflicting names, as -might be found between a utility program and a library function, though -Prisma chose not to include individual library functions within the module -database at this time. -.NH 2 -Configurable Logging Support -.PP -The \fBcvs\fP \*Qcommit\*U command is used to make a permanent change to the -master source repository (where the -.SM -RCS -.LG -\*Q,v\*U files live). -Whenever a \*Qcommit\*U is done, the log message for the change is carefully -logged by an arbitrary program (in a file, notesfile, news database, or -mail). -For example, a collection of these updates can be used to produce release -notices. -\fBcvs\fP can be configured to send log updates through one or more filter -programs, based on a regular expression match on the directory that is -being changed. -This allows multiple related or unrelated projects to exist within a single -\fBcvs\fP source repository tree, with each different project sending its -\*Qcommit\*U reports to a unique log device. -.PP -A sample logging configuration file might look as follows: -.DS -\f(CW #regex filter-program - DEFAULT /usr/local/bin/nfpipe -t %s utils.updates - ^diag /usr/local/bin/nfpipe -t %s diag.updates - ^local /usr/local/bin/nfpipe -t %s local.updates - ^perf /usr/local/bin/nfpipe -t %s perf.updates - ^sys /usr/local/bin/nfpipe -t %s kernel.updates\fP -.DE -.PP -This sample allows the diagnostics and performance groups to -share the same source repository with the kernel and utilities groups. -Changes that they make are sent directly to their own notesfile [Essick] -through the \*Qnfpipe\*U program. -A sufficiently simple title is substituted for the \*Q%s\*U argument before -the filter program is executed. -This logging configuration file is tailored manually to each specific -source repository environment. -.NH 2 -Tagged Releases and Dates -.PP -Any release can be given a symbolic tag name that is stored directly in the -.SM -RCS -.LG -files. -This tag can be used at any time to get an exact copy of any previous -release. -With equal ease, one can also extract an exact copy of the source files as -of any arbitrary date in the past as well. -Thus, all that's required to tag the current kernel, and to tag the kernel -as of the Fourth of July is: -.DS -\f(CW example% cvs tag TEST_KERNEL kernel - example% cvs tag -D 'July 4' PATRIOTIC_KERNEL kernel\fP -.DE -The following command would retrieve an exact copy of the test kernel at -some later date: -.DS -\f(CW example% cvs checkout -fp -rTEST_KERNEL kernel\fP -.DE -The \fI-f\fP option causes only files that match the specified tag to be -extracted, while the \fI-p\fP option automatically prunes empty directories. -Consequently, directories added to the kernel after the test kernel was -tagged are not included in the newly extracted copy of the test kernel. -.PP -The \fBcvs\fP date support has exactly the same interface as that provided -with -.SM -RCS\c -.LG -, however \fBcvs\fP must process the \*Q,v\*U files directly due to the -special handling required by the vendor branch support. -The standard -.SM -RCS -.LG -date handling only processes one branch (or the main trunk) when checking -out based on a date specification. -\fBcvs\fP must instead process the current \*Qhead\*U branch and, if a -match is not found, proceed to look for a match on the vendor branch. -This, combined with reasons of performance, is why \fBcvs\fP processes -revision (symbolic and numeric) and date specifications directly from the -\*Q,v\*U files. -.NH 2 -Building \*Qpatch\*U Source Distributions -.PP -\fBcvs\fP can produce a \*Qpatch\*U format [Wall] output file which can be -used to bring a previously released software distribution current with the -newest release. -This patch file supports an entire directory hierarchy within a single -patch, as well as being able to add whole new files to the previous -release. -One can combine symbolic revisions and dates together to display changes in -a very generic way: -.DS -\f(CW example% cvs patch -D 'December 1, 1988' \e - -D 'January 1, 1989' sys\fP -.DE -This example displays the kernel changes made in the month of December, -1988. -To release a patch file, for example, to take the \fBcvs\fP distribution -from version 1.0 to version 1.4 might be done as follows: -.DS -\f(CW example% cvs patch -rCVS_1_0 -rCVS_1_4 cvs\fP -.DE -.NH -CVS Experience -.NH 2 -Statistics -.PP -A quick summary of the scale that \fBcvs\fP is addressing today -can be found in Table 1. -.KF -.TS -box center tab(:); -c s -c s -c | c -l | n . -\fB\s+2Revision Control Statistics at Prisma -as of 11/11/89\fP\s-2 -_ -How Many...:Total -= -Files:17243 -Directories:1005 -Lines of code:3927255 -Removed files:131 -Software developers:14 -Software groups:6 -Megabytes of source:128 -.TE -.ce 100 -.LG -\fBTable 1.\fP -.SM -\fBcvs\fP Statistics -.ce 0 -.sp .3 -.KE -Table 2 shows the history of files changed or added and the number -of source lines affected by the change at Prisma. -Only changes made to the kernel sources are included. -.KF -.TS -box center tab(:); -c s s s s -c s s s s -c || c | c || c | c -c || c | c || c | c -l || n | n || n | n. -\fB\s+2Prisma Kernel Source File Changes -By Month, 1988-1989\fP\s-2 -_ -Month:# Changed:# Lines:# Added:# Lines -\^:Files:Changed:Files:Added -= -Dec:87:3619:68:9266 -Jan:39:4324:0:0 -Feb:73:1578:5:3550 -Mar:99:5301:18:11461 -Apr:112:7333:11:5759 -May:138:5371:17:13986 -Jun:65:2261:27:12875 -Jul:34:2000:1:58 -Aug:65:6378:8:4724 -Sep:266:23410:113:39965 -Oct:22:621:1:155 -Total:1000:62196:269:101799 -.TE -.ce 100 -.LG -\fBTable 2.\fP -.SM -\fBcvs\fP Usage History for the Kernel -.ce 0 -.sp -.KE -The large number of source file changes made in September are the result of -merging the SunOS 4.0.3 sources into the kernel. -This merge process is described in section 3.3. -.NH 2 -Performance -.PP -The performance of \fBcvs\fP is currently quite reasonable. -Little effort has been expended on tuning \fBcvs\fP, although performance -related decisions were made during the \fBcvs\fP design. -For example, \fBcvs\fP parses the -.SM -RCS -.LG -\*Q,v\*U files directly instead of running an -.SM -RCS -.LG -process. -This includes following branches as well as integrating with the vendor -source branches and the main trunk when checking out files based on a date. -.PP -Checking out the entire kernel source tree (1223 files/59 directories) -currently takes 16 wall clock minutes on a Sun-4/280. -However, bringing the tree up-to-date with the current kernel sources, once -it has been checked out, takes only 1.5 wall clock minutes. -Updating the \fIcomplete\fP 128 MByte source tree under \fBcvs\fP control -(17243 files/1005 directories) takes roughly 28 wall clock minutes and -utilizes one-third of the machine. -For now this is entirely acceptable; improvements on these numbers will -possibly be made in the future. -.NH 2 -The SunOS 4.0.3 Merge -.PP -The true test of the \fBcvs\fP vendor branch support came with the arrival -of the SunOS 4.0.3 source upgrade tape. -As described above, the \fBcheckin\fP program was used to install the new -sources and the resulting output file listed the files that had been -locally modified, needing to be merged manually. -For the kernel, there were 94 files in conflict. -The \fBcvs\fP \*Qjoin\*U command was used on each of the 94 conflicting -files, and the remaining conflicts were resolved. -.PP -The \*Qjoin\*U command performs an \fBrcsmerge\fP operation. -This in turn uses \fI/usr/lib/diff3\fP to produce a three-way diff file. -As it happens, the \fBdiff3\fP program has a hard-coded limit of 200 -source-file changes maximum. -This proved to be too small for a few of the kernel files that needed -merging by hand, due to the large number of local changes that Prisma had -made. -The \fBdiff3\fP problem was solved by increasing the hard-coded limit by an -order of magnitude. -.PP -The SunOS 4.0.3 kernel source upgrade distribution contained -346 files, 233 of which were modifications to previously released files, -and 113 of which were newly added files. -\fBcheckin\fP added the 113 new files to the source repository -without intervention. -Of the 233 modified files, 139 dropped in cleanly by \fBcheckin\fP, since -Prisma had not made any local changes to them, and 94 required manual -merging due to local modifications. -The 233 modified files consisted of 20,766 lines of differences. -It took one developer two days to manually merge the 94 files using the -\*Qjoin\*U command and resolving conflicts manually. -An additional day was required for kernel debugging. -The entire process of merging over 20,000 lines of differences was -completed in less than a week. -This one time-savings alone was justification enough for the \fBcvs\fP -development effort; we expect to gain even more when tracking future SunOS -releases. -.NH -Future Enhancements and Current Bugs -.PP -Since \fBcvs\fP was designed to be incomplete, for reasons of design -simplicity, there are naturally a good -number of enhancements that can be made to make it more useful. -As well, some nuisances exist in the current implementation. -.RS -.IP \(bu 3 -\fBcvs\fP does not currently \*Qremember\*U who has a checked out a copy of a -module. -As a result, it is impossible to know who might be working on the same -module that you are. -A simple-minded database that is updated nightly would likely suffice. -.IP \(bu 3 -Signal processing, keyboard interrupt handling in particular, is currently -somewhat weak. -This is due to the heavy use of the \fBsystem\fP\|(3) library -function to execute -.SM -RCS -.LG -programs like \fBco\fP and \fBci\fP. -It sometimes takes multiple interrupts to make \fBcvs\fP quit. -This can be fixed by using a home-grown \fBsystem\fP\|() replacement. -.IP \(bu 3 -Security of the source repository is currently not dealt with directly. -The usual UNIX approach of user-group-other security permissions through -the file system is utilized, but nothing else. -\fBcvs\fP could likely be a set-group-id executable that checks a -protected database to verify user access permissions for particular objects -before allowing any operations to affect those objects. -.IP \(bu 3 -With every checked-out directory, \fBcvs\fP maintains some administrative -files that record the current revision numbers of the checked-out files as -well as the location of the respective source repository. -\fBcvs\fP does not recover nicely at all if these administrative files are -removed. -.IP \(bu 3 -The source code for \fBcvs\fP has been tested extensively on Sun-3 and -Sun-4 systems, all running SunOS 4.0 or later versions of the operating -system. -Since the code has not yet been compiled under other platforms, the overall -portability of the code is still questionable. -.IP \(bu 3 -As witnessed in the previous section, the \fBcvs\fP method for tracking -third party vendor source distributions can work quite nicely. -However, if the vendor changes the directory structure or the file names -within the source distribution, \fBcvs\fP has no way of matching the old -release with the new one. -It is currently unclear as to how to solve this, though it is certain to -happen in practice. -.RE -.NH -Availability -.PP -The \fBcvs\fP program sources can be found in a recent posting to the -\fBcomp.sources.unix\fP newsgroup. -It is also currently available via anonymous ftp from \*Qprisma.com\*U. -Copying rights for \fBcvs\fP will be covered by the GNU General Public -License. -.NH -Summary -.PP -Prisma has used \fBcvs\fP since December, 1988. -It has evolved to meet our specific needs of revision and release control. -We will make our code freely available so that others can -benefit from our work, and can enhance \fBcvs\fP to meet broader needs yet. -.PP -Many of the other software release and revision control systems, like the -one described in [Glew], appear to use a collection of tools that are -geared toward specific environments \(em one set of tools for the kernel, -one set for \*Qgeneric\*U software, one set for utilities, and one set for -kernel and utilities. -Each of these tool sets apparently handle some specific aspect of the -problem uniquely. -\fBcvs\fP took a somewhat different approach. -File sharing through symbolic or hard links is not addressed; instead, the -disk space is simply burned since it is \*Qcheap.\*U -Support for producing objects for multiple architectures is not addressed; -instead, a parallel checked-out source tree must be used for each -architecture, again wasting disk space to simplify complexity and ease of -use \(em punting on this issue allowed \fIMakefile\fPs to remain -unchanged, unlike the approach taken in [Mahler], thereby maintaining closer -compatibility with the third-party vendor sources. -\fBcvs\fP is essentially a source-file server, making no assumptions or -special handling of the sources that it controls. -To \fBcvs\fP: -.QP -A source is a source, of course, of course, unless of course the source is -Mr. Ed.\** -.FS -\fBcvs\fP, of course, does not really discriminate against Mr. Ed.\** -.FE -.FS -Yet. -.FE -.LP -Sources are maintained, saved, and retrievable at any time based on -symbolic or numeric revision or date in the past. -It is entirely up to \fBcvs\fP wrapper programs to provide for release -environments and such. -.PP -The major advantage of \fBcvs\fP over the -many other similar systems that have already been designed is the -simplicity of \fBcvs\fP. -\fBcvs\fP contains only three programs that do all the work of release -and revision control, and two manually-maintained administrative -files for each source repository. -Of course, the deciding factor of any tool is whether people use it, and if -they even \fIlike\fP to use it. -At Prisma, \fBcvs\fP prevented members of the kernel -group from killing each other. -.NH -Acknowledgements -.PP -Many thanks to Dick Grune at Vrije Universiteit in Amsterdam for his work -on the original version of \fBcvs\fP and for making it available to the -world. -Thanks to Jeff Polk of Prisma for helping with the design of the module -database, vendor branch support, and for writing the \fBcheckin\fP shell -script. -Thanks also to the entire software group at Prisma for taking the -time to review the paper and correct my grammar. -.NH -References -.IP [Bell] 12 -Bell Telephone Laboratories. -\*QSource Code Control System User's Guide.\*U -\fIUNIX System III Programmer's Manual\fP, October 1981. -.IP [Courington] 12 -Courington, W. -\fIThe Network Software Environment\fP, -Sun Technical Report FE197-0, Sun Microsystems Inc, February 1989. -.IP [Essick] 12 -Essick, Raymond B. and Robert Bruce Kolstad. -\fINotesfile Reference Manual\fP, -Department of Computer Science Technical Report #1081, -University of Illinois at Urbana-Champaign, Urbana, Illinois, -1982, p. 26. -.IP [Glew] 12 -Glew, Andy. -\*QBoxes, Links, and Parallel Trees: -Elements of a Configuration Management System.\*U -\fIWorkshop Proceedings of the Software Management Conference\fP, USENIX, -New Orleans, April 1989. -.IP [Grune] 12 -Grune, Dick. -Distributed the original shell script version of \fBcvs\fP in the -\fBcomp.sources.unix\fP volume 6 release in 1986. -.IP [Honda] 12 -Honda, Masahiro and Terrence Miller. -\*QSoftware Management Using a CASE Environment.\*U -\fIWorkshop Proceedings of the Software Management Conference\fP, USENIX, -New Orleans, April 1989. -.IP [Mahler] 12 -Mahler, Alex and Andreas Lampen. -\*QAn Integrated Toolset for Engineering Software Configurations.\*U -\fIProceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium on -Practical Software Development Environments\fP, ACM, Boston, November 1988. -Described is the \fBshape\fP toolkit posted to the -\fBcomp.sources.unix\fP newsgroup in the volume 19 release. -.IP [Tichy] 12 -Tichy, Walter F. -\*QDesign, Implementation, and Evaluation of a Revision Control System.\*U -\fIProceedings of the 6th International Conference on Software -Engineering\fP, IEEE, Tokyo, September 1982. -.IP [Wall] 12 -Wall, Larry. -The \fBpatch\fP program is an indispensable tool for applying a diff file -to an original. -Can be found on uunet.uu.net in ~ftp/pub/patch.tar. diff --git a/gnu/usr.bin/cvs/lib/Makefile.in b/gnu/usr.bin/cvs/lib/Makefile.in deleted file mode 100644 index a8309f2fc00d..000000000000 --- a/gnu/usr.bin/cvs/lib/Makefile.in +++ /dev/null @@ -1,91 +0,0 @@ -# Makefile for library files used by GNU CVS. -# Do not use this makefile directly, but only from `../Makefile'. -# Copyright (C) 1986, 1988-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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# @(#)Makefile.in 1.12 92/03/31 - -SHELL = /bin/sh - -srcdir = @srcdir@ -@VPATH@ - -SOURCES = argmatch.c \ -error.c getopt.c getopt1.c \ -sighandle.c \ -strippath.c stripslash.c yesno.c \ -getdate.y \ -hostname.c fnmatch.c ftruncate.c mkdir.c rename.c regex.c \ -strdup.c getwd.c alloca.c - -OBJECTS = argmatch.o \ -error.o getopt.o getopt1.o \ -sighandle.o \ -strippath.o stripslash.o yesno.o \ -getdate.o \ -@LIBOBJS@ - -DISTFILES = Makefile.in getopt.h \ -fnmatch.h regex.h system.h wait.h $(SOURCES) - -xxx: - @cd ..; $(MAKE) all SUBDIRS=lib - -all: libcvs.a -.PHONY: all - -install: all -.PHONY: install - -tags: $(DISTFILES) - ctags $(DISTFILES) - -TAGS: $(DISTFILES) - etags $(DISTFILES) - -ls: - @echo $(DISTFILES) -.PHONY: ls - -clean: - rm -f *.a *.o *.tab.c getdate.c -.PHONY: clean - -distclean: clean - rm -f tags TAGS Makefile -.PHONY: distclean - -realclean: distclean -.PHONY: realclean - -dist: - ln $(DISTFILES) ../`cat ../.fname`/lib -.PHONY: dist - -libcvs.a: $(OBJECTS) - $(AR) cr $@ $(OBJECTS) - -$(RANLIB) $@ - -getdate.c: getdate.y - @echo expect 8 shift/reduce conflicts - $(YACC) $(srcdir)/getdate.y - -if test -f y.tab.c ; then mv y.tab.c getdate.c ; fi - -if test -f getdate.tab.c ; then mv getdate.tab.c getdate.c ; fi - -fnmatch.o: fnmatch.h -getopt1.o: getopt.h -regex.o: regex.h -getwd.o: system.h diff --git a/gnu/usr.bin/cvs/lib/regex.c b/gnu/usr.bin/cvs/lib/regex.c deleted file mode 100644 index 8169880d7e4f..000000000000 --- a/gnu/usr.bin/cvs/lib/regex.c +++ /dev/null @@ -1,4948 +0,0 @@ -/* Extended regular expression matching and search library, - version 0.12. - (Implements POSIX draft P10003.2/D11.2, except for - internationalization features.) - - Copyright (C) 1993 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (REGEX_MALLOC) - #pragma alloca -#endif - -#define _GNU_SOURCE - -/* We need this for `regex.h', and perhaps for the Emacs include files. */ -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* The `emacs' switch turns on certain matching commands - that make sense only in Emacs. */ -#ifdef emacs - -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -/* Emacs uses `NULL' as a predicate. */ -#undef NULL - -#else /* not emacs */ - -/* We used to test for `BSTRING' here, but only GCC and Emacs define - `BSTRING', as far as I know, and neither of them use this code. */ -#if HAVE_STRING_H || STDC_HEADERS -#include -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif -#else -#include -#endif - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - - -/* Define the syntax stuff for \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#ifdef SYNTAX_TABLE - -extern char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -/* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 - -static char re_syntax_table[CHAR_SET_SIZE]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - re_syntax_table['_'] = Sword; - - done = 1; -} - -#endif /* not SYNTAX_TABLE */ - -#define SYNTAX(c) re_syntax_table[c] - -#endif /* not emacs */ - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - -/* isalpha etc. are used for the character classes. */ -#include - -#ifndef isascii -#define isascii(c) 1 -#endif - -#ifdef isblank -#define ISBLANK(c) (isascii (c) && isblank (c)) -#else -#define ISBLANK(c) ((c) == ' ' || (c) == '\t') -#endif -#ifdef isgraph -#define ISGRAPH(c) (isascii (c) && isgraph (c)) -#else -#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) -#endif - -#define ISPRINT(c) (isascii (c) && isprint (c)) -#define ISDIGIT(c) (isascii (c) && isdigit (c)) -#define ISALNUM(c) (isascii (c) && isalnum (c)) -#define ISALPHA(c) (isascii (c) && isalpha (c)) -#define ISCNTRL(c) (isascii (c) && iscntrl (c)) -#define ISLOWER(c) (isascii (c) && islower (c)) -#define ISPUNCT(c) (isascii (c) && ispunct (c)) -#define ISSPACE(c) (isascii (c) && isspace (c)) -#define ISUPPER(c) (isascii (c) && isupper (c)) -#define ISXDIGIT(c) (isascii (c) && isxdigit (c)) - -#ifndef NULL -#define NULL 0 -#endif - -/* We remove any previous definition of `SIGN_EXTEND_CHAR', - since ours (we hope) works properly with all combinations of - machines, compilers, `char' and `unsigned char' argument types. - (Per Bothner suggested the basic approach.) */ -#undef SIGN_EXTEND_CHAR -#if __STDC__ -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) -#else /* not __STDC__ */ -/* As in Harbison and Steele. */ -#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) -#endif - -/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we - use `alloca' instead of `malloc'. This is because using malloc in - re_search* or re_match* could cause memory leaks when C-g is used in - Emacs; also, malloc is slower and causes storage fragmentation. On - the other hand, malloc is more portable, and easier to debug. - - Because we sometimes use alloca, some routines have to be macros, - not functions -- `alloca'-allocated space disappears at the end of the - function it is called in. */ - -#ifdef REGEX_MALLOC - -#define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) - -#else /* not REGEX_MALLOC */ - -/* Emacs already defines alloca, sometimes. */ -#ifndef alloca - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not __GNUC__ or HAVE_ALLOCA_H */ -#ifndef _AIX /* Already did AIX, up at the top. */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -#endif /* not alloca */ - -#define REGEX_ALLOCATE alloca - -/* Assumes a `char *destination' variable. */ -#define REGEX_REALLOCATE(source, osize, nsize) \ - (destination = (char *) alloca (nsize), \ - bcopy (source, destination, osize), \ - destination) - -#endif /* not REGEX_MALLOC */ - - -/* True if `size1' is non-NULL and PTR is pointing anywhere inside - `string1' or just past its end. This works if PTR is NULL, which is - a good thing. */ -#define FIRST_STRING_P(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) -#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) -#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) - -#define BYTEWIDTH 8 /* In bits. */ - -#define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -typedef char boolean; -#define false 0 -#define true 1 - -/* These are the command codes that appear in compiled regular - expressions. Some opcodes are followed by argument bytes. A - command code can specify any interpretation whatsoever for its - arguments. Zero bytes may appear in the compiled regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in Emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -typedef enum -{ - no_op = 0, - - /* Followed by one byte giving n, then by n literal bytes. */ - exactn = 1, - - /* Matches any (more or less) character. */ - anychar, - - /* Matches any one char belonging to specified set. First - following byte is number of bitmap bytes. Then come bytes - for a bitmap saying which chars are in. Bits in each byte - are ordered low-bit-first. A character is in the set if its - bit is 1. A character too large to have a bit in the map is - automatically not in the set. */ - charset, - - /* Same parameters as charset, but match any character that is - not one of those specified. */ - charset_not, - - /* Start remembering the text that is matched, for storing in a - register. Followed by one byte with the register number, in - the range 0 to one less than the pattern buffer's re_nsub - field. Then followed by one byte with the number of groups - inner to this one. (This last has to be part of the - start_memory only because we need it in the on_failure_jump - of re_match_2.) */ - start_memory, - - /* Stop remembering the text that is matched and store it in a - memory register. Followed by one byte with the register - number, in the range 0 to one less than `re_nsub' in the - pattern buffer, and one byte with the number of inner groups, - just like `start_memory'. (We need the number of inner - groups here because we don't have any easy way of finding the - corresponding start_memory when we're at a stop_memory.) */ - stop_memory, - - /* Match a duplicate of something remembered. Followed by one - byte containing the register number. */ - duplicate, - - /* Fail unless at beginning of line. */ - begline, - - /* Fail unless at end of line. */ - endline, - - /* Succeeds if at beginning of buffer (if emacs) or at beginning - of string to be matched (if not). */ - begbuf, - - /* Analogously, for end of buffer/string. */ - endbuf, - - /* Followed by two byte relative address to which to jump. */ - jump, - - /* Same as jump, but marks the end of an alternative. */ - jump_past_alt, - - /* Followed by two-byte relative address of place to resume at - in case of failure. */ - on_failure_jump, - - /* Like on_failure_jump, but pushes a placeholder instead of the - current string position when executed. */ - on_failure_keep_string_jump, - - /* Throw away latest failure point and then jump to following - two-byte relative address. */ - pop_failure_jump, - - /* Change to pop_failure_jump if know won't have to backtrack to - match; otherwise change to jump. This is used to jump - back to the beginning of a repeat. If what follows this jump - clearly won't match what the repeat does, such that we can be - sure that there is no use backtracking out of repetitions - already matched, then we change it to a pop_failure_jump. - Followed by two-byte address. */ - maybe_pop_jump, - - /* Jump to following two-byte address, and push a dummy failure - point. This failure point will be thrown away if an attempt - is made to use it for a failure. A `+' construct makes this - before the first repeat. Also used as an intermediary kind - of jump when compiling an alternative. */ - dummy_failure_jump, - - /* Push a dummy failure point and continue. Used at the end of - alternatives. */ - push_dummy_failure, - - /* Followed by two-byte relative address and two-byte number n. - After matching N times, jump to the address upon failure. */ - succeed_n, - - /* Followed by two-byte relative address, and two-byte number n. - Jump to the address N times, then fail. */ - jump_n, - - /* Set the following two-byte relative address to the - subsequent two-byte number. The address *includes* the two - bytes of number. */ - set_number_at, - - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - - wordbound, /* Succeeds if at a word boundary. */ - notwordbound /* Succeeds if not at a word boundary. */ - -#ifdef emacs - ,before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - - /* Matches any character whose syntax is specified. Followed by - a byte which contains a syntax code, e.g., Sword. */ - syntaxspec, - - /* Matches any character whose syntax is not that specified. */ - notsyntaxspec -#endif /* emacs */ -} re_opcode_t; - -/* Common operations on the compiled pattern. */ - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ - -#define STORE_NUMBER(destination, number) \ - do { \ - (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; \ - } while (0) - -/* Same as STORE_NUMBER, except increment DESTINATION to - the byte after where the number is stored. Therefore, DESTINATION - must be an lvalue. */ - -#define STORE_NUMBER_AND_INCR(destination, number) \ - do { \ - STORE_NUMBER (destination, number); \ - (destination) += 2; \ - } while (0) - -/* Put into DESTINATION a number stored in two contiguous bytes starting - at SOURCE. */ - -#define EXTRACT_NUMBER(destination, source) \ - do { \ - (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ - } while (0) - -#ifdef DEBUG -static void -extract_number (dest, source) - int *dest; - unsigned char *source; -{ - int temp = SIGN_EXTEND_CHAR (*(source + 1)); - *dest = *source & 0377; - *dest += temp << 8; -} - -#ifndef EXTRACT_MACROS /* To debug the macros. */ -#undef EXTRACT_NUMBER -#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. - SOURCE must be an lvalue. */ - -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - do { \ - EXTRACT_NUMBER (destination, source); \ - (source) += 2; \ - } while (0) - -#ifdef DEBUG -static void -extract_number_and_incr (destination, source) - int *destination; - unsigned char **source; -{ - extract_number (destination, *source); - *source += 2; -} - -#ifndef EXTRACT_MACROS -#undef EXTRACT_NUMBER_AND_INCR -#define EXTRACT_NUMBER_AND_INCR(dest, src) \ - extract_number_and_incr (&dest, &src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* If DEBUG is defined, Regex prints many voluminous messages about what - it is doing (if the variable `debug' is nonzero). If linked with the - main program in `iregex.c', you can enter patterns and strings - interactively. And if linked with the main program in `main.c' and - the other test files, you can run the already-written tests. */ - -#ifdef DEBUG - -/* We use standard I/O for debugging. */ -#include - -/* It is useful to test things that ``must'' be true when debugging. */ -#include - -static int debug = 0; - -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ - if (debug) print_partial_compiled_pattern (s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ - if (debug) print_double_string (w, s1, sz1, s2, sz2) - - -extern void printchar (); - -/* Print the fastmap in human-readable form. */ - -void -print_fastmap (fastmap) - char *fastmap; -{ - unsigned was_a_range = 0; - unsigned i = 0; - - while (i < (1 << BYTEWIDTH)) - { - if (fastmap[i++]) - { - was_a_range = 0; - printchar (i - 1); - while (i < (1 << BYTEWIDTH) && fastmap[i]) - { - was_a_range = 1; - i++; - } - if (was_a_range) - { - printf ("-"); - printchar (i - 1); - } - } - } - putchar ('\n'); -} - - -/* Print a compiled pattern string in human-readable form, starting at - the START pointer into it and ending just before the pointer END. */ - -void -print_partial_compiled_pattern (start, end) - unsigned char *start; - unsigned char *end; -{ - int mcnt, mcnt2; - unsigned char *p = start; - unsigned char *pend = end; - - if (start == NULL) - { - printf ("(null)\n"); - return; - } - - /* Loop over pattern commands. */ - while (p < pend) - { - switch ((re_opcode_t) *p++) - { - case no_op: - printf ("/no_op"); - break; - - case exactn: - mcnt = *p++; - printf ("/exactn/%d", mcnt); - do - { - putchar ('/'); - printchar (*p++); - } - while (--mcnt); - break; - - case start_memory: - mcnt = *p++; - printf ("/start_memory/%d/%d", mcnt, *p++); - break; - - case stop_memory: - mcnt = *p++; - printf ("/stop_memory/%d/%d", mcnt, *p++); - break; - - case duplicate: - printf ("/duplicate/%d", *p++); - break; - - case anychar: - printf ("/anychar"); - break; - - case charset: - case charset_not: - { - register int c; - - printf ("/charset%s", - (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); - - assert (p + *p < pend); - - for (c = 0; c < *p; c++) - { - unsigned bit; - unsigned char map_byte = p[1 + c]; - - putchar ('/'); - - for (bit = 0; bit < BYTEWIDTH; bit++) - if (map_byte & (1 << bit)) - printchar (c * BYTEWIDTH + bit); - } - p += 1 + *p; - break; - } - - case begline: - printf ("/begline"); - break; - - case endline: - printf ("/endline"); - break; - - case on_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_jump/0/%d", mcnt); - break; - - case on_failure_keep_string_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_keep_string_jump/0/%d", mcnt); - break; - - case dummy_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/dummy_failure_jump/0/%d", mcnt); - break; - - case push_dummy_failure: - printf ("/push_dummy_failure"); - break; - - case maybe_pop_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/maybe_pop_jump/0/%d", mcnt); - break; - - case pop_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/pop_failure_jump/0/%d", mcnt); - break; - - case jump_past_alt: - extract_number_and_incr (&mcnt, &p); - printf ("/jump_past_alt/0/%d", mcnt); - break; - - case jump: - extract_number_and_incr (&mcnt, &p); - printf ("/jump/0/%d", mcnt); - break; - - case succeed_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case jump_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case set_number_at: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2); - break; - - case wordbound: - printf ("/wordbound"); - break; - - case notwordbound: - printf ("/notwordbound"); - break; - - case wordbeg: - printf ("/wordbeg"); - break; - - case wordend: - printf ("/wordend"); - -#ifdef emacs - case before_dot: - printf ("/before_dot"); - break; - - case at_dot: - printf ("/at_dot"); - break; - - case after_dot: - printf ("/after_dot"); - break; - - case syntaxspec: - printf ("/syntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; - - case notsyntaxspec: - printf ("/notsyntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; -#endif /* emacs */ - - case wordchar: - printf ("/wordchar"); - break; - - case notwordchar: - printf ("/notwordchar"); - break; - - case begbuf: - printf ("/begbuf"); - break; - - case endbuf: - printf ("/endbuf"); - break; - - default: - printf ("?%d", *(p-1)); - } - } - printf ("/\n"); -} - - -void -print_compiled_pattern (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *buffer = bufp->buffer; - - print_partial_compiled_pattern (buffer, buffer + bufp->used); - printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); - - if (bufp->fastmap_accurate && bufp->fastmap) - { - printf ("fastmap: "); - print_fastmap (bufp->fastmap); - } - - printf ("re_nsub: %d\t", bufp->re_nsub); - printf ("regs_alloc: %d\t", bufp->regs_allocated); - printf ("can_be_null: %d\t", bufp->can_be_null); - printf ("newline_anchor: %d\n", bufp->newline_anchor); - printf ("no_sub: %d\t", bufp->no_sub); - printf ("not_bol: %d\t", bufp->not_bol); - printf ("not_eol: %d\t", bufp->not_eol); - printf ("syntax: %d\n", bufp->syntax); - /* Perhaps we should print the translate table? */ -} - - -void -print_double_string (where, string1, size1, string2, size2) - const char *where; - const char *string1; - const char *string2; - int size1; - int size2; -{ - unsigned this_char; - - if (where == NULL) - printf ("(null)"); - else - { - if (FIRST_STRING_P (where)) - { - for (this_char = where - string1; this_char < size1; this_char++) - printchar (string1[this_char]); - - where = string2; - } - - for (this_char = where - string2; this_char < size2; this_char++) - printchar (string2[this_char]); - } -} - -#else /* not DEBUG */ - -#undef assert -#define assert(e) - -#define DEBUG_STATEMENT(e) -#define DEBUG_PRINT1(x) -#define DEBUG_PRINT2(x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) - -#endif /* not DEBUG */ - -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. */ - -static const char *re_error_msg[] = - { NULL, /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\(", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ - "Unmatched ) or \\)", /* REG_ERPAREN */ - }; - -/* Subroutine declarations and macros for regex_compile. */ - -static void store_op1 (), store_op2 (); -static void insert_op1 (), insert_op2 (); -static boolean at_begline_loc_p (), at_endline_loc_p (); -static boolean group_in_compile_stack (); -static reg_errcode_t compile_range (); - -/* Fetch the next character in the uncompiled pattern---translating it - if necessary. Also cast from a signed character in the constant - string passed to us by the user to an unsigned char that we can use - as an array index (in, e.g., `translate'). */ -#define PATFETCH(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - if (translate) c = translate[c]; \ - } while (0) - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - } while (0) - -/* Go backwards one character in the pattern. */ -#define PATUNFETCH p-- - - -/* If `translate' is non-null, return translate[D], else just D. We - cast the subscript to translate because some data is declared as - `char *', to avoid warnings when a string constant is passed. But - when we use a character as a subscript we must make it unsigned. */ -#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) - - -/* Macros for outputting the compiled pattern into `buffer'. */ - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 32 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - while (b - bufp->buffer + (n) > bufp->allocated) \ - EXTEND_BUFFER () - -/* Make sure we have one more byte of buffer space and then add C to it. */ -#define BUF_PUSH(c) \ - do { \ - GET_BUFFER_SPACE (1); \ - *b++ = (unsigned char) (c); \ - } while (0) - - -/* Ensure we have two more bytes of buffer space and then append C1 and C2. */ -#define BUF_PUSH_2(c1, c2) \ - do { \ - GET_BUFFER_SPACE (2); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - } while (0) - - -/* As with BUF_PUSH_2, except for three bytes. */ -#define BUF_PUSH_3(c1, c2, c3) \ - do { \ - GET_BUFFER_SPACE (3); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - *b++ = (unsigned char) (c3); \ - } while (0) - - -/* Store a jump with opcode OP at LOC to location TO. We store a - relative address offset by the three bytes the jump itself occupies. */ -#define STORE_JUMP(op, loc, to) \ - store_op1 (op, loc, (to) - (loc) - 3) - -/* Likewise, for a two-argument jump. */ -#define STORE_JUMP2(op, loc, to, arg) \ - store_op2 (op, loc, (to) - (loc) - 3, arg) - -/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP(op, loc, to) \ - insert_op1 (op, loc, (to) - (loc) - 3, b) - -/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP2(op, loc, to, arg) \ - insert_op2 (op, loc, (to) - (loc) - 3, arg, b) - - -/* This is not an arbitrary limit: the arguments which represent offsets - into the pattern are two bytes long. So if 2^16 bytes turns out to - be too small, many things would have to change. */ -#define MAX_BUF_SIZE (1L << 16) - - -/* Extend the buffer by twice its current size via realloc and - reset the pointers that pointed into the old block to point to the - correct places in the new one. If extending the buffer results in it - being larger than MAX_BUF_SIZE, then flag memory exhausted. */ -#define EXTEND_BUFFER() \ - do { \ - unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ - return REG_ESIZE; \ - bufp->allocated <<= 1; \ - if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ - if (bufp->buffer == NULL) \ - return REG_ESPACE; \ - /* If the buffer moved, move all the pointers into it. */ \ - if (old_buffer != bufp->buffer) \ - { \ - b = (b - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (fixup_alt_jump) \ - fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } \ - } while (0) - - -/* Since we have one byte reserved for the register number argument to - {start,stop}_memory, the maximum number of groups we can report - things about is what fits in that byte. */ -#define MAX_REGNUM 255 - -/* But patterns can have more than `MAX_REGNUM' registers. We just - ignore the excess. */ -typedef unsigned regnum_t; - - -/* Macros for the compile stack. */ - -/* Since offsets can go either forwards or backwards, this type needs to - be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ -typedef int pattern_offset_t; - -typedef struct -{ - pattern_offset_t begalt_offset; - pattern_offset_t fixup_alt_jump; - pattern_offset_t inner_group_offset; - pattern_offset_t laststart_offset; - regnum_t regnum; -} compile_stack_elt_t; - - -typedef struct -{ - compile_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} compile_stack_type; - - -#define INIT_COMPILE_STACK_SIZE 32 - -#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) -#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) - -/* The next available element. */ -#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) - - -/* Set the bit for character C in a list. */ -#define SET_LIST_BIT(c) \ - (b[((unsigned char) (c)) / BYTEWIDTH] \ - |= 1 << (((unsigned char) c) % BYTEWIDTH)) - - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (ISDIGIT (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ - -#define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) - -/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. - Returns one of error codes defined in `regex.h', or zero for success. - - Assumes the `allocated' (and perhaps `buffer') and `translate' - fields are set in BUFP on entry. - - If it succeeds, results are put in BUFP (if it returns an error, the - contents of BUFP are undefined): - `buffer' is the compiled pattern; - `syntax' is set to SYNTAX; - `used' is set to the length of the compiled pattern; - `fastmap_accurate' is zero; - `re_nsub' is the number of subexpressions in PATTERN; - `not_bol' and `not_eol' are zero; - - The `fastmap' and `newline_anchor' fields are neither - examined nor set. */ - -static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - const char *pattern; - int size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; -{ - /* We fetch characters from PATTERN here. Even though PATTERN is - `char *' (i.e., signed), we declare these variables as unsigned, so - they can be reliably used as array indices. */ - register unsigned char c, c1; - - /* A random tempory spot in PATTERN. */ - const char *p1; - - /* Points to the end of the buffer, where we should append. */ - register unsigned char *b; - - /* Keeps track of unclosed groups. */ - compile_stack_type compile_stack; - - /* Points to the current (ending) position in the pattern. */ - const char *p = pattern; - const char *pend = pattern + size; - - /* How to translate the characters in the pattern. */ - char *translate = bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell if a new exact-match - character can be added to that command or if the character requires - a new `exactn' command. */ - unsigned char *pending_exact = 0; - - /* Address of start of the most recently finished expression. - This tells, e.g., postfix * where to find the start of its - operand. Reset at the beginning of groups and alternatives. */ - unsigned char *laststart = 0; - - /* Address of beginning of regexp, or inside of last group. */ - unsigned char *begalt; - - /* Place in the uncompiled pattern (i.e., the {) to - which to go back if the interval is invalid. */ - const char *beg_interval; - - /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or' -- except the - last -- ends with a forward jump of this sort. */ - unsigned char *fixup_alt_jump = 0; - - /* Counts open-groups as they are encountered. Remembered for the - matching close-group on the compile stack, so the same register - number is put in the stop_memory as the start_memory. */ - regnum_t regnum = 0; - -#ifdef DEBUG - DEBUG_PRINT1 ("\nCompiling pattern: "); - if (debug) - { - unsigned debug_count; - - for (debug_count = 0; debug_count < size; debug_count++) - printchar (pattern[debug_count]); - putchar ('\n'); - } -#endif /* DEBUG */ - - /* Initialize the compile stack. */ - compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); - if (compile_stack.stack == NULL) - return REG_ESPACE; - - compile_stack.size = INIT_COMPILE_STACK_SIZE; - compile_stack.avail = 0; - - /* Initialize the pattern buffer. */ - bufp->syntax = syntax; - bufp->fastmap_accurate = 0; - bufp->not_bol = bufp->not_eol = 0; - - /* Set `used' to zero, so that if we return an error, the pattern - printer (for debugging) will think there's no pattern. We reset it - at the end. */ - bufp->used = 0; - - /* Always count groups, whether or not bufp->no_sub is set. */ - bufp->re_nsub = 0; - -#if !defined (emacs) && !defined (SYNTAX_TABLE) - /* Initialize the syntax table. */ - init_syntax_once (); -#endif - - if (bufp->allocated == 0) - { - if (bufp->buffer) - { /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ - RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); - } - else - { /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); - } - if (!bufp->buffer) return REG_ESPACE; - - bufp->allocated = INIT_BUF_SIZE; - } - - begalt = b = bufp->buffer; - - /* Loop through the uncompiled pattern until we're at the end. */ - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '^': - { - if ( /* If at start of pattern, it's an operator. */ - p == pattern + 1 - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's come before. */ - || at_begline_loc_p (pattern, p, syntax)) - BUF_PUSH (begline); - else - goto normal_char; - } - break; - - - case '$': - { - if ( /* If at end of pattern, it's an operator. */ - p == pend - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's next. */ - || at_endline_loc_p (p, pend, syntax)) - BUF_PUSH (endline); - else - goto normal_char; - } - break; - - - case '+': - case '?': - if ((syntax & RE_BK_PLUS_QM) - || (syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern... */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (!(syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - - { - /* Are we optimizing this jump? */ - boolean keep_string_p = false; - - /* 1 means zero (many) matches is allowed. */ - char zero_times_ok = 0, many_times_ok = 0; - - /* If there is a sequence of repetition chars, collapse it - down to just one (the right one). We can't combine - interval operators with these because of, e.g., `a{2}*', - which should only match an even number of `a's. */ - - for (;;) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - - if (p == pend) - break; - - PATFETCH (c); - - if (c == '*' - || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) - ; - - else if (syntax & RE_BK_PLUS_QM && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - - c = c1; - } - else - { - PATUNFETCH; - break; - } - - /* If we get here, we found another repeat character. */ - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { /* More than one repetition is allowed, so put in at the - end a backward relative jump from `b' to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). - - But if we are at the `*' in the exact sequence `.*\n', - insert an unconditional jump backwards to the ., - instead of the beginning of the loop. This way we only - push a failure point once, instead of every time - through the loop. */ - assert (p - 1 > pattern); - - /* Allocate the space for the jump. */ - GET_BUFFER_SPACE (3); - - /* We know we are not at the first character of the pattern, - because laststart was nonzero. And we've already - incremented `p', by the way, to be the character after - the `*'. Do we have to do something analogous here - for null bytes, because of RE_DOT_NOT_NULL? */ - if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') - && zero_times_ok - && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') - && !(syntax & RE_DOT_NEWLINE)) - { /* We have .*\n. */ - STORE_JUMP (jump, b, laststart); - keep_string_p = true; - } - else - /* Anything else. */ - STORE_JUMP (maybe_pop_jump, b, laststart - 3); - - /* We've added more stuff to the buffer. */ - b += 3; - } - - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump - : on_failure_jump, - laststart, b + 3); - pending_exact = 0; - b += 3; - - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - `dummy_failure_jump' before the initial - `on_failure_jump' instruction of the loop. This - effects a skip over that instruction the first time - we hit that loop. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); - b += 3; - } - } - break; - - - case '.': - laststart = b; - BUF_PUSH (anychar); - break; - - - case '[': - { - boolean had_char_class = false; - - if (p == pend) return REG_EBRACK; - - /* Ensure that we have enough space to push a charset: the - opcode, the length count, and the bitset; 34 bytes in all. */ - GET_BUFFER_SPACE (34); - - laststart = b; - - /* We test `*p == '^' twice, instead of using an if - statement, so we only need one BUF_PUSH. */ - BUF_PUSH (*p == '^' ? charset_not : charset); - if (*p == '^') - p++; - - /* Remember the first position in the bracket expression. */ - p1 = p; - - /* Push the number of bytes in the bitmap. */ - BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - - /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - - /* charset_not matches newline according to a syntax bit. */ - if ((re_opcode_t) b[-2] == charset_not - && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) - SET_LIST_BIT ('\n'); - - /* Read in characters and ranges, setting map bits. */ - for (;;) - { - if (p == pend) return REG_EBRACK; - - PATFETCH (c); - - /* \ might escape characters inside [...] and [^...]. */ - if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - SET_LIST_BIT (c1); - continue; - } - - /* Could be the end of the bracket expression. If it's - not (i.e., when the bracket expression is `[]' so - far), the ']' character bit gets set way below. */ - if (c == ']' && p != p1 + 1) - break; - - /* Look ahead to see if it's a range when the last thing - was a character class. */ - if (had_char_class && c == '-' && *p != ']') - return REG_ERANGE; - - /* Look ahead to see if it's a range when the last thing - was a character: if this is a hyphen not at the - beginning or the end of a list, then it's the range - operator. */ - if (c == '-' - && !(p - 2 >= pattern && p[-2] == '[') - && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') - && *p != ']') - { - reg_errcode_t ret - = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - else if (p[0] == '-' && p[1] != ']') - { /* This handles ranges made up of characters only. */ - reg_errcode_t ret; - - /* Move past the `-'. */ - PATFETCH (c1); - - ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - /* See if we're at the beginning of a possible character - class. */ - - else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') - { /* Leave room for the null. */ - char str[CHAR_CLASS_MAX_LENGTH + 1]; - - PATFETCH (c); - c1 = 0; - - /* If pattern is `[[:'. */ - if (p == pend) return REG_EBRACK; - - for (;;) - { - PATFETCH (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - - /* If isn't a word bracketed by `[:' and:`]': - undo the ending character, the letters, and leave - the leading `:' and `[' (but set bits for them). */ - if (c == ':' && *p == ']') - { - int ch; - boolean is_alnum = STREQ (str, "alnum"); - boolean is_alpha = STREQ (str, "alpha"); - boolean is_blank = STREQ (str, "blank"); - boolean is_cntrl = STREQ (str, "cntrl"); - boolean is_digit = STREQ (str, "digit"); - boolean is_graph = STREQ (str, "graph"); - boolean is_lower = STREQ (str, "lower"); - boolean is_print = STREQ (str, "print"); - boolean is_punct = STREQ (str, "punct"); - boolean is_space = STREQ (str, "space"); - boolean is_upper = STREQ (str, "upper"); - boolean is_xdigit = STREQ (str, "xdigit"); - - if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; - - /* Throw away the ] at the end of the character - class. */ - PATFETCH (c); - - if (p == pend) return REG_EBRACK; - - for (ch = 0; ch < 1 << BYTEWIDTH; ch++) - { - if ( (is_alnum && ISALNUM (ch)) - || (is_alpha && ISALPHA (ch)) - || (is_blank && ISBLANK (ch)) - || (is_cntrl && ISCNTRL (ch)) - || (is_digit && ISDIGIT (ch)) - || (is_graph && ISGRAPH (ch)) - || (is_lower && ISLOWER (ch)) - || (is_print && ISPRINT (ch)) - || (is_punct && ISPUNCT (ch)) - || (is_space && ISSPACE (ch)) - || (is_upper && ISUPPER (ch)) - || (is_xdigit && ISXDIGIT (ch))) - SET_LIST_BIT (ch); - } - had_char_class = true; - } - else - { - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - had_char_class = false; - } - } - else - { - had_char_class = false; - SET_LIST_BIT (c); - } - } - - /* Discard any (non)matching list bytes that are all 0 at the - end of the map. Decrease the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - } - break; - - - case '(': - if (syntax & RE_NO_BK_PARENS) - goto handle_open; - else - goto normal_char; - - - case ')': - if (syntax & RE_NO_BK_PARENS) - goto handle_close; - else - goto normal_char; - - - case '\n': - if (syntax & RE_NEWLINE_ALT) - goto handle_alt; - else - goto normal_char; - - - case '|': - if (syntax & RE_NO_BK_VBAR) - goto handle_alt; - else - goto normal_char; - - - case '{': - if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) - goto handle_interval; - else - goto normal_char; - - - case '\\': - if (p == pend) return REG_EESCAPE; - - /* Do not translate the character after the \, so that we can - distinguish, e.g., \B from \b, even if we normally would - translate, e.g., B to b. */ - PATFETCH_RAW (c); - - switch (c) - { - case '(': - if (syntax & RE_NO_BK_PARENS) - goto normal_backslash; - - handle_open: - bufp->re_nsub++; - regnum++; - - if (COMPILE_STACK_FULL) - { - RETALLOC (compile_stack.stack, compile_stack.size << 1, - compile_stack_elt_t); - if (compile_stack.stack == NULL) return REG_ESPACE; - - compile_stack.size <<= 1; - } - - /* These are the values to restore when we hit end of this - group. They are all relative offsets, so that if the - whole pattern moves because of realloc, they will still - be valid. */ - COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; - COMPILE_STACK_TOP.fixup_alt_jump - = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; - COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; - COMPILE_STACK_TOP.regnum = regnum; - - /* We will eventually replace the 0 with the number of - groups inner to this one. But do not push a - start_memory for groups beyond the last one we can - represent in the compiled pattern. */ - if (regnum <= MAX_REGNUM) - { - COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; - BUF_PUSH_3 (start_memory, regnum, 0); - } - - compile_stack.avail++; - - fixup_alt_jump = 0; - laststart = 0; - begalt = b; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - break; - - - case ')': - if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_backslash; - else - return REG_ERPAREN; - - handle_close: - if (fixup_alt_jump) - { /* Push a dummy failure point at the end of the - alternative for a possible future - `pop_failure_jump' to pop. See comments at - `push_dummy_failure' in `re_match_2'. */ - BUF_PUSH (push_dummy_failure); - - /* We allocated space for this jump when we assigned - to `fixup_alt_jump', in the `handle_alt' case below. */ - STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); - } - - /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_char; - else - return REG_ERPAREN; - - /* Since we just checked for an empty stack above, this - ``can't happen''. */ - assert (compile_stack.avail != 0); - { - /* We don't just want to restore into `regnum', because - later groups should continue to be numbered higher, - as in `(ab)c(de)' -- the second group is #2. */ - regnum_t this_group_regnum; - - compile_stack.avail--; - begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; - fixup_alt_jump - = COMPILE_STACK_TOP.fixup_alt_jump - ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 - : 0; - laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; - this_group_regnum = COMPILE_STACK_TOP.regnum; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - - /* We're at the end of the group, so now we know how many - groups were inside this one. */ - if (this_group_regnum <= MAX_REGNUM) - { - unsigned char *inner_group_loc - = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; - - *inner_group_loc = regnum - this_group_regnum; - BUF_PUSH_3 (stop_memory, this_group_regnum, - regnum - this_group_regnum); - } - } - break; - - - case '|': /* `\|'. */ - if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) - goto normal_backslash; - handle_alt: - if (syntax & RE_LIMITED_OPS) - goto normal_char; - - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (on_failure_jump, begalt, b + 6); - pending_exact = 0; - b += 3; - - /* The alternative before this one has a jump after it - which gets executed if it gets matched. Adjust that - jump so it will jump to this alternative's analogous - jump (put in below, which in turn will jump to the next - (if any) alternative's such jump, etc.). The last such - jump jumps to the correct final destination. A picture: - _____ _____ - | | | | - | v | v - a | b | c - - If we are at `b', then fixup_alt_jump right now points to a - three-byte space after `a'. We'll put in the jump, set - fixup_alt_jump to right after `b', and leave behind three - bytes which we'll fill in when we get to after `c'. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - /* Mark and leave space for a jump after this alternative, - to be filled in later either by next alternative or - when know we're at the end of a series of alternatives. */ - fixup_alt_jump = b; - GET_BUFFER_SPACE (3); - b += 3; - - laststart = 0; - begalt = b; - break; - - - case '{': - /* If \{ is a literal. */ - if (!(syntax & RE_INTERVALS) - /* If we're at `\{' and it's not the open-interval - operator. */ - || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - || (p - 2 == pattern && p == pend)) - goto normal_backslash; - - handle_interval: - { - /* If got here, then the syntax allows intervals. */ - - /* At least (most) this many matches must be made. */ - int lower_bound = -1, upper_bound = -1; - - beg_interval = p - 1; - - if (p == pend) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_EBRACE; - } - - GET_UNSIGNED_NUMBER (lower_bound); - - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; - } - else - /* Interval such as `{1}' => match exactly once. */ - upper_bound = lower_bound; - - if (lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (c != '\\') return REG_EBRACE; - - PATFETCH (c); - } - - if (c != '}') - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - /* We just parsed a valid interval. */ - - /* If it's invalid to have no preceding re. */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (syntax & RE_CONTEXT_INDEP_OPS) - laststart = b; - else - goto unfetch_interval; - } - - /* If the upper bound is zero, don't want to succeed at - all; jump from `laststart' to `b + 3', which will be - the end of the buffer after we insert the jump. */ - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - INSERT_JUMP (jump, laststart, b + 3); - b += 3; - } - - /* Otherwise, we have a nontrivial interval. When - we're all done, the pattern will look like: - set_number_at - set_number_at - succeed_n - - jump_n - (The upper bound and `jump_n' are omitted if - `upper_bound' is 1, though.) */ - else - { /* If the upper bound is > 1, we need to insert - more at the end of the loop. */ - unsigned nbytes = 10 + (upper_bound > 1) * 10; - - GET_BUFFER_SPACE (nbytes); - - /* Initialize lower bound of the `succeed_n', even - though it will be set during matching by its - attendant `set_number_at' (inserted next), - because `re_compile_fastmap' needs to know. - Jump to the `jump_n' we might insert below. */ - INSERT_JUMP2 (succeed_n, laststart, - b + 5 + (upper_bound > 1) * 5, - lower_bound); - b += 5; - - /* Code to initialize the lower bound. Insert - before the `succeed_n'. The `5' is the last two - bytes of this `set_number_at', plus 3 bytes of - the following `succeed_n'. */ - insert_op2 (set_number_at, laststart, 5, lower_bound, b); - b += 5; - - if (upper_bound > 1) - { /* More than one repetition is allowed, so - append a backward jump to the `succeed_n' - that starts this interval. - - When we've reached this during matching, - we'll have matched the interval once, so - jump back only `upper_bound - 1' times. */ - STORE_JUMP2 (jump_n, b, laststart + 5, - upper_bound - 1); - b += 5; - - /* The location we want to set is the second - parameter of the `jump_n'; that is `b-2' as - an absolute address. `laststart' will be - the `set_number_at' we're about to insert; - `laststart+3' the number to set, the source - for the relative address. But we are - inserting into the middle of the pattern -- - so everything is getting moved up by 5. - Conclusion: (b - 2) - (laststart + 3) + 5, - i.e., b - laststart. - - We insert this at the beginning of the loop - so that if we fail during matching, we'll - reinitialize the bounds. */ - insert_op2 (set_number_at, laststart, b - laststart, - upper_bound - 1, b); - b += 5; - } - } - pending_exact = 0; - beg_interval = NULL; - } - break; - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - assert (beg_interval); - p = beg_interval; - beg_interval = NULL; - - /* normal_char and normal_backslash need `c'. */ - PATFETCH (c); - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (p > pattern && p[-1] == '\\') - goto normal_backslash; - } - goto normal_char; - -#ifdef emacs - /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ - case '=': - BUF_PUSH (at_dot); - break; - - case 's': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); - break; -#endif /* emacs */ - - - case 'w': - laststart = b; - BUF_PUSH (wordchar); - break; - - - case 'W': - laststart = b; - BUF_PUSH (notwordchar); - break; - - - case '<': - BUF_PUSH (wordbeg); - break; - - case '>': - BUF_PUSH (wordend); - break; - - case 'b': - BUF_PUSH (wordbound); - break; - - case 'B': - BUF_PUSH (notwordbound); - break; - - case '`': - BUF_PUSH (begbuf); - break; - - case '\'': - BUF_PUSH (endbuf); - break; - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (syntax & RE_NO_BK_REFS) - goto normal_char; - - c1 = c - '0'; - - if (c1 > regnum) - return REG_ESUBREG; - - /* Can't back reference to a subexpression if inside of it. */ - if (group_in_compile_stack (compile_stack, c1)) - goto normal_char; - - laststart = b; - BUF_PUSH_2 (duplicate, c1); - break; - - - case '+': - case '?': - if (syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backslash; - - default: - normal_backslash: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - c = TRANSLATE (c); - goto normal_char; - } - break; - - - default: - /* Expects the character in `c'. */ - normal_char: - /* If no exactn currently being built. */ - if (!pending_exact - - /* If last exactn not at current position. */ - || pending_exact + *pending_exact + 1 != b - - /* We have only one byte following the exactn for the count. */ - || *pending_exact == (1 << BYTEWIDTH) - 1 - - /* If followed by a repetition operator. */ - || *p == '*' || *p == '^' - || ((syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((syntax & RE_INTERVALS) - && ((syntax & RE_NO_BK_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - /* Start building a new exactn. */ - - laststart = b; - - BUF_PUSH_2 (exactn, 0); - pending_exact = b - 1; - } - - BUF_PUSH (c); - (*pending_exact)++; - break; - } /* switch (c) */ - } /* while p != pend */ - - - /* Through the pattern now. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - if (!COMPILE_STACK_EMPTY) - return REG_EPAREN; - - free (compile_stack.stack); - - /* We have succeeded; set the length of the buffer. */ - bufp->used = b - bufp->buffer; - -#ifdef DEBUG - if (debug) - { - DEBUG_PRINT1 ("\nCompiled pattern: "); - print_compiled_pattern (bufp); - } -#endif /* DEBUG */ - - return REG_NOERROR; -} /* regex_compile */ - -/* Subroutines for `regex_compile'. */ - -/* Store OP at LOC followed by two-byte integer parameter ARG. */ - -static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg); -} - - -/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg1); - STORE_NUMBER (loc + 3, arg2); -} - - -/* Copy the bytes from LOC to END to open up three bytes of space at LOC - for OP followed by two-byte integer parameter ARG. */ - -static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 3; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op1 (op, loc, arg); -} - - -/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 5; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op2 (op, loc, arg1, arg2); -} - - -/* P points to just after a ^ in PATTERN. Return true if that ^ comes - after an alternative or a begin-subexpression. We assume there is at - least one character before the ^. */ - -static boolean -at_begline_loc_p (pattern, p, syntax) - const char *pattern, *p; - reg_syntax_t syntax; -{ - const char *prev = p - 2; - boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - - return - /* After a subexpression? */ - (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) - /* After an alternative? */ - || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); -} - - -/* The dual of at_begline_loc_p. This one is for $. We assume there is - at least one character after the $, i.e., `P < PEND'. */ - -static boolean -at_endline_loc_p (p, pend, syntax) - const char *p, *pend; - int syntax; -{ - const char *next = p; - boolean next_backslash = *next == '\\'; - const char *next_next = p + 1 < pend ? p + 1 : NULL; - - return - /* Before a subexpression? */ - (syntax & RE_NO_BK_PARENS ? *next == ')' - : next_backslash && next_next && *next_next == ')') - /* Before an alternative? */ - || (syntax & RE_NO_BK_VBAR ? *next == '|' - : next_backslash && next_next && *next_next == '|'); -} - - -/* Returns true if REGNUM is in one of COMPILE_STACK's elements and - false if it's not. */ - -static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; -{ - int this_element; - - for (this_element = compile_stack.avail - 1; - this_element >= 0; - this_element--) - if (compile_stack.stack[this_element].regnum == regnum) - return true; - - return false; -} - - -/* Read the ending character of a range (in a bracket expression) from the - uncompiled pattern *P_PTR (which ends at PEND). We assume the - starting character is in `P[-2]'. (`P[-1]' is the character `-'.) - Then we set the translation of all bits between the starting and - ending characters (inclusive) in the compiled pattern B. - - Return an error code. - - We use these short variable names so we can use the same macros as - `regex_compile' itself. */ - -static reg_errcode_t -compile_range (p_ptr, pend, translate, syntax, b) - const char **p_ptr, *pend; - char *translate; - reg_syntax_t syntax; - unsigned char *b; -{ - unsigned this_char; - - const char *p = *p_ptr; - int range_start, range_end; - - if (p == pend) - return REG_ERANGE; - - /* Even though the pattern is a signed `char *', we need to fetch - with unsigned char *'s; if the high bit of the pattern character - is set, the range endpoints will be negative if we fetch using a - signed char *. - - We also want to fetch the endpoints without translating them; the - appropriate translation is done in the bit-setting loop below. */ - range_start = ((unsigned char *) p)[-2]; - range_end = ((unsigned char *) p)[0]; - - /* Have to increment the pointer into the pattern string, so the - caller isn't still at the ending character. */ - (*p_ptr)++; - - /* If the start is after the end, the range is empty. */ - if (range_start > range_end) - return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; - - /* Here we see why `this_char' has to be larger than an `unsigned - char' -- the range is inclusive, so if `range_end' == 0xff - (assuming 8-bit characters), we would otherwise go into an infinite - loop, since all characters <= 0xff. */ - for (this_char = range_start; this_char <= range_end; this_char++) - { - SET_LIST_BIT (TRANSLATE (this_char)); - } - - return REG_NOERROR; -} - -/* Failure stack declarations and macros; both re_compile_fastmap and - re_match_2 use a failure stack. These have to be macros because of - REGEX_ALLOCATE. */ - - -/* Number of failure points for which to initially allocate space - when matching. If this number is exceeded, we allocate more - space, so it is not a hard limit. */ -#ifndef INIT_FAILURE_ALLOC -#define INIT_FAILURE_ALLOC 5 -#endif - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always used MAX_FAILURE_SPACE each time we failed. - This is a variable only so users of regex can assign to it; we never - change it ourselves. */ -int re_max_failures = 2000; - -typedef const unsigned char *fail_stack_elt_t; - -typedef struct -{ - fail_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} fail_stack_type; - -#define FAIL_STACK_EMPTY() (fail_stack.avail == 0) -#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) -#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) -#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) - - -/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ - -#define INIT_FAIL_STACK() \ - do { \ - fail_stack.stack = (fail_stack_elt_t *) \ - REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ - \ - if (fail_stack.stack == NULL) \ - return -2; \ - \ - fail_stack.size = INIT_FAILURE_ALLOC; \ - fail_stack.avail = 0; \ - } while (0) - - -/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. - - Return 1 if succeeds, and 0 if either ran out of memory - allocating space for it or it was already too large. - - REGEX_REALLOCATE requires `destination' be declared. */ - -#define DOUBLE_FAIL_STACK(fail_stack) \ - ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ - ? 0 \ - : ((fail_stack).stack = (fail_stack_elt_t *) \ - REGEX_REALLOCATE ((fail_stack).stack, \ - (fail_stack).size * sizeof (fail_stack_elt_t), \ - ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ - \ - (fail_stack).stack == NULL \ - ? 0 \ - : ((fail_stack).size <<= 1, \ - 1))) - - -/* Push PATTERN_OP on FAIL_STACK. - - Return 1 if was able to do so and 0 if ran out of memory allocating - space to do so. */ -#define PUSH_PATTERN_OP(pattern_op, fail_stack) \ - ((FAIL_STACK_FULL () \ - && !DOUBLE_FAIL_STACK (fail_stack)) \ - ? 0 \ - : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ - 1)) - -/* This pushes an item onto the failure stack. Must be a four-byte - value. Assumes the variable `fail_stack'. Probably should only - be called from within `PUSH_FAILURE_POINT'. */ -#define PUSH_FAILURE_ITEM(item) \ - fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item - -/* The complement operation. Assumes `fail_stack' is nonempty. */ -#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] - -/* Used to omit pushing failure point id's when we're not debugging. */ -#ifdef DEBUG -#define DEBUG_PUSH PUSH_FAILURE_ITEM -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () -#else -#define DEBUG_PUSH(item) -#define DEBUG_POP(item_addr) -#endif - - -/* Push the information about the state we will need - if we ever fail back to it. - - Requires variables fail_stack, regstart, regend, reg_info, and - num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be - declared. - - Does `return FAILURE_CODE' if runs out of memory. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ - do { \ - char *destination; \ - /* Must be int, so when we don't save any registers, the arithmetic \ - of 0 + -1 isn't done as unsigned. */ \ - int this_reg; \ - \ - DEBUG_STATEMENT (failure_id++); \ - DEBUG_STATEMENT (nfailure_points_pushed++); \ - DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ - DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ - \ - DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ - DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ - \ - /* Ensure we have enough space allocated for what we will push. */ \ - while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ - { \ - if (!DOUBLE_FAIL_STACK (fail_stack)) \ - return failure_code; \ - \ - DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ - (fail_stack).size); \ - DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ - } \ - \ - /* Push the info, starting with the registers. */ \ - DEBUG_PRINT1 ("\n"); \ - \ - for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ - this_reg++) \ - { \ - DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ - DEBUG_STATEMENT (num_regs_pushed++); \ - \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - PUSH_FAILURE_ITEM (regstart[this_reg]); \ - \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - PUSH_FAILURE_ITEM (regend[this_reg]); \ - \ - DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ - DEBUG_PRINT2 (" match_null=%d", \ - REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ - DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ - DEBUG_PRINT2 (" matched_something=%d", \ - MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT2 (" ever_matched=%d", \ - EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT1 ("\n"); \ - PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ - } \ - \ - DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ - PUSH_FAILURE_ITEM (lowest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ - PUSH_FAILURE_ITEM (highest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ - PUSH_FAILURE_ITEM (pattern_place); \ - \ - DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ - DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ - size2); \ - DEBUG_PRINT1 ("'\n"); \ - PUSH_FAILURE_ITEM (string_place); \ - \ - DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ - DEBUG_PUSH (failure_id); \ - } while (0) - -/* This is the number of items that are pushed and popped on the stack - for each register. */ -#define NUM_REG_ITEMS 3 - -/* Individual items aside from the registers. */ -#ifdef DEBUG -#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ -#else -#define NUM_NONREG_ITEMS 4 -#endif - -/* We push at most this many items on the stack. */ -#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) - -/* We actually push this many items. */ -#define NUM_FAILURE_ITEMS \ - ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ - + NUM_NONREG_ITEMS) - -/* How many items can still be added to the stack without overflowing it. */ -#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) - - -/* Pops what PUSH_FAIL_STACK pushes. - - We restore into the parameters, all of which should be lvalues: - STR -- the saved data position. - PAT -- the saved pattern position. - LOW_REG, HIGH_REG -- the highest and lowest active registers. - REGSTART, REGEND -- arrays of string positions. - REG_INFO -- array of information about each subexpression. - - Also assumes the variables `fail_stack' and (if debugging), `bufp', - `pend', `string1', `size1', `string2', and `size2'. */ - -#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ -{ \ - DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ - int this_reg; \ - const unsigned char *string_temp; \ - \ - assert (!FAIL_STACK_EMPTY ()); \ - \ - /* Remove failure points and point to how many regs pushed. */ \ - DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ - DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ - \ - assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ - \ - DEBUG_POP (&failure_id); \ - DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ - \ - /* If the saved string location is NULL, it came from an \ - on_failure_keep_string_jump opcode, and we want to throw away the \ - saved NULL, thus retaining our current position in the string. */ \ - string_temp = POP_FAILURE_ITEM (); \ - if (string_temp != NULL) \ - str = (const char *) string_temp; \ - \ - DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ - DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ - DEBUG_PRINT1 ("'\n"); \ - \ - pat = (unsigned char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ - \ - /* Restore register info. */ \ - high_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ - \ - low_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ - \ - for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ - { \ - DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ - \ - reg_info[this_reg].word = POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ - \ - regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - \ - regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - } \ - \ - DEBUG_STATEMENT (nfailure_points_popped++); \ -} /* POP_FAILURE_POINT */ - -/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in - BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible - characters can start a string that matches the pattern. This fastmap - is used by re_search to skip quickly over impossible starting points. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as BUFP->fastmap. - - We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in - the pattern buffer. - - Returns 0 if we succeed, -2 if an internal error. */ - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - int j, k; - fail_stack_type fail_stack; -#ifndef REGEX_MALLOC - char *destination; -#endif - /* We don't push any register information onto the failure stack. */ - unsigned num_regs = 0; - - register char *fastmap = bufp->fastmap; - unsigned char *pattern = bufp->buffer; - unsigned long size = bufp->used; - const unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - - /* Assume that each path through the pattern can be null until - proven otherwise. We set this false at the bottom of switch - statement, to which we get only if a particular path doesn't - match the empty string. */ - boolean path_can_be_null = true; - - /* We aren't doing a `succeed_n' to begin with. */ - boolean succeed_n_p = false; - - assert (fastmap != NULL && p != NULL); - - INIT_FAIL_STACK (); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ - bufp->fastmap_accurate = 1; /* It will be when we're done. */ - bufp->can_be_null = 0; - - while (p != pend || !FAIL_STACK_EMPTY ()) - { - if (p == pend) - { - bufp->can_be_null |= path_can_be_null; - - /* Reset for next path. */ - path_can_be_null = true; - - p = fail_stack.stack[--fail_stack.avail]; - } - - /* We should never be about to go beyond the end of the pattern. */ - assert (p < pend); - -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - - /* I guess the idea here is to simply not bother with a fastmap - if a backreference is used, since it's too hard to figure out - the fastmap for the corresponding group. Setting - `can_be_null' stops `re_search_2' from using the fastmap, so - that is all we do. */ - case duplicate: - bufp->can_be_null = 1; - return 0; - - - /* Following are the cases which match a character. These end - with `break'. */ - - case exactn: - fastmap[p[1]] = 1; - break; - - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - fastmap[j] = 1; - break; - - - case charset_not: - /* Chars beyond end of map must be allowed. */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - fastmap[j] = 1; - break; - - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - - - case anychar: - /* `.' matches anything ... */ - for (j = 0; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - /* ... except perhaps newline. */ - if (!(bufp->syntax & RE_DOT_NEWLINE)) - fastmap['\n'] = 0; - - /* Return if we have already set `can_be_null'; if we have, - then the fastmap is irrelevant. Something's wrong here. */ - else if (bufp->can_be_null) - return 0; - - /* Otherwise, have to check alternative paths. */ - break; - - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - /* All cases after this match the empty string. These end with - `continue'. */ - - - case before_dot: - case at_dot: - case after_dot: - continue; -#endif /* not emacs */ - - - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - case push_dummy_failure: - continue; - - - case jump_n: - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case jump_past_alt: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - - /* Jump backward implies we just went through the body of a - loop and matched nothing. Opcode jumped to should be - `on_failure_jump' or `succeed_n'. Just treat it like an - ordinary jump. For a * loop, it has pushed its failure - point already; if so, discard that as redundant. */ - if ((re_opcode_t) *p != on_failure_jump - && (re_opcode_t) *p != succeed_n) - continue; - - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - - /* If what's on the stack is where we are now, pop it. */ - if (!FAIL_STACK_EMPTY () - && fail_stack.stack[fail_stack.avail - 1] == p) - fail_stack.avail--; - - continue; - - - case on_failure_jump: - case on_failure_keep_string_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - - /* For some patterns, e.g., `(a?)?', `p+j' here points to the - end of the pattern. We don't want to push such a point, - since when we restore it above, entering the switch will - increment `p' past the end of the pattern. We don't need - to push such a point since we obviously won't find any more - fastmap entries beyond `pend'. Such a pattern can match - the null string, though. */ - if (p + j < pend) - { - if (!PUSH_PATTERN_OP (p + j, fail_stack)) - return -2; - } - else - bufp->can_be_null = 1; - - if (succeed_n_p) - { - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - succeed_n_p = false; - } - - continue; - - - case succeed_n: - /* Get to the number of times to succeed. */ - p += 2; - - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - succeed_n_p = true; /* Spaghetti code alert. */ - goto handle_on_failure_jump; - } - continue; - - - case set_number_at: - p += 4; - continue; - - - case start_memory: - case stop_memory: - p += 2; - continue; - - - default: - abort (); /* We have listed all the cases. */ - } /* switch *p++ */ - - /* Getting here means we have found the possible starting - characters for one path of the pattern -- and that the empty - string does not match. We need not follow this path further. - Instead, look at the next alternative (remembered on the - stack), or quit if no more. The test at the top of the loop - does these things. */ - path_can_be_null = false; - p = pend; - } /* while p */ - - /* Set `can_be_null' for the last path (also the first path, if the - pattern is empty). */ - bufp->can_be_null |= path_can_be_null; - return 0; -} /* re_compile_fastmap */ - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = (regoff_t) 0; - } -} - -/* Searching routines. */ - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (bufp, NULL, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in BUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. - - STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. - - RANGE is how far to scan while trying to match. RANGE = 0 means try - only at STARTPOS; in general, the last start tried is STARTPOS + - RANGE. - - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire BUFP->buffer and its contained - subexpressions. - - Do not consider matching one past the index STOP in the virtual - concatenation of STRING1 and STRING2. - - We return either the position in the strings at which the match was - found, -1 if no match, or -2 if error (such as failure - stack overflow). */ - -int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; -{ - int val; - register char *fastmap = bufp->fastmap; - register char *translate = bufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - - /* Check for out-of-range STARTPOS. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up RANGE if it might eventually take us outside - the virtual concatenation of STRING1 and STRING2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* If the search isn't to be a backwards one, don't waste time in a - search for a pattern that must be anchored. */ - if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - /* Update the fastmap now if not correct already. */ - if (fastmap && !bufp->fastmap_accurate) - if (re_compile_fastmap (bufp) == -2) - return -2; - - /* Loop through the string, looking for a place to start matching. */ - for (;;) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot be the start of a match. If the pattern can match the - null string, however, we don't need to skip characters; we want - the first null string. */ - if (fastmap && startpos < total_size && !bufp->can_be_null) - { - if (range > 0) /* Searching forwards. */ - { - register const char *d; - register int lim = 0; - int irange = range; - - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - d = (startpos >= size1 ? string2 - size1 : string1) + startpos; - - /* Written out as an if-else to avoid testing `translate' - inside the loop. */ - if (translate) - while (range > lim - && !fastmap[(unsigned char) - translate[(unsigned char) *d++]]) - range--; - else - while (range > lim && !fastmap[(unsigned char) *d++]) - range--; - - startpos += irange - range; - } - else /* Searching backwards. */ - { - register char c = (size1 == 0 || startpos >= size1 - ? string2[startpos - size1] - : string1[startpos]); - - if (!fastmap[(unsigned char) TRANSLATE (c)]) - goto advance; - } - } - - /* If can't match the null string, and that's all we have left, fail. */ - if (range >= 0 && startpos == total_size && fastmap - && !bufp->can_be_null) - return -1; - - val = re_match_2 (bufp, string1, size1, string2, size2, - startpos, regs, stop); - if (val >= 0) - return startpos; - - if (val == -2) - return -2; - - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} /* re_search_2 */ - -/* Declarations and macros for re_match_2. */ - -static int bcmp_translate (); -static boolean alt_match_null_string_p (), - common_op_match_null_string_p (), - group_match_null_string_p (); - -/* Structure for per-register (a.k.a. per-group) information. - This must not be longer than one word, because we push this value - onto the failure stack. Other register information, such as the - starting and ending positions (which are addresses), and the list of - inner groups (which is a bits list) are maintained in separate - variables. - - We are making a (strictly speaking) nonportable assumption here: that - the compiler will pack our bit fields into something that fits into - the type of `word', i.e., is something that fits into one item on the - failure stack. */ -typedef union -{ - fail_stack_elt_t word; - struct - { - /* This field is one if this group can match the empty string, - zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ -#define MATCH_NULL_UNSET_VALUE 3 - unsigned match_null_string_p : 2; - unsigned is_active : 1; - unsigned matched_something : 1; - unsigned ever_matched_something : 1; - } bits; -} register_info_type; - -#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) -#define IS_ACTIVE(R) ((R).bits.is_active) -#define MATCHED_SOMETHING(R) ((R).bits.matched_something) -#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) - - -/* Call this when have matched a real character; it sets `matched' flags - for the subexpressions which we are currently inside. Also records - that those subexprs have matched. */ -#define SET_REGS_MATCHED() \ - do \ - { \ - unsigned r; \ - for (r = lowest_active_reg; r <= highest_active_reg; r++) \ - { \ - MATCHED_SOMETHING (reg_info[r]) \ - = EVER_MATCHED_SOMETHING (reg_info[r]) \ - = 1; \ - } \ - } \ - while (0) - - -/* This converts PTR, a pointer into one of the search strings `string1' - and `string2' into an offset from the beginning of that string. */ -#define POINTER_TO_OFFSET(ptr) \ - (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) - -/* Registers are set to a sentinel when they haven't yet matched. */ -#define REG_UNSET_VALUE ((char *) -1) -#define REG_UNSET(e) ((e) == REG_UNSET_VALUE) - - -/* Macros for dealing with the split strings in re_match_2. */ - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ -#define PREFETCH() \ - while (d == dend) \ - { \ - /* End of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* End of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Test if at very beginning or at very end of the virtual concatenation - of `string1' and `string2'. If only one string, it's `string2'. */ -#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END(d) ((d) == end2) - - -/* Test if D points to a character which is word-constituent. We have - two special cases to check for: if past the end of string1, look at - the first character in string2; and if before the beginning of - string2, look at the last character in string1. */ -#define WORDCHAR_P(d) \ - (SYNTAX ((d) == end1 ? *string2 \ - : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ - == Sword) - -/* Test if the character before D and the one at D differ with respect - to being word-constituent. */ -#define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ - || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) - - -/* Free everything we malloc. */ -#ifdef REGEX_MALLOC -#define FREE_VAR(var) if (var) free (var); var = NULL -#define FREE_VARIABLES() \ - do { \ - FREE_VAR (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ - } while (0) -#else /* not REGEX_MALLOC */ -/* Some MIPS systems (at least) want this to free alloca'd storage. */ -#define FREE_VARIABLES() alloca (0) -#endif /* not REGEX_MALLOC */ - - -/* These values must meet several constraints. They must not be valid - register values; since we have a limit of 255 registers (because - we use only one byte in the pattern for the register number), we can - use numbers larger than 255. They must differ by 1, because of - NUM_FAILURE_ITEMS above. And the value for the lowest register must - be larger than the value for the highest register, so we do not try - to actually save any registers when none are active. */ -#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) -#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) - -/* Matching routines. */ - -#ifndef emacs /* Emacs never uses this. */ -/* re_match is like re_match_2 except it takes only a single string. */ - -int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; - { - return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* re_match_2 matches the compiled pattern in BUFP against the - the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 - and SIZE2, respectively). We start matching at POS, and stop - matching at STOP. - - If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. See the - documentation for exactly how many groups we fill. - - We return -1 if no match, -2 if an internal error (such as the - failure stack overflowing). Otherwise, we return the length of the - matched substring. */ - -int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; -{ - /* General temporaries. */ - int mcnt; - unsigned char *p1; - - /* Just past the end of the corresponding string. */ - const char *end1, *end2; - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - const char *end_match_1, *end_match_2; - - /* Where we are in the data, and the end of the current string. */ - const char *d, *dend; - - /* Where we are in the pattern, and the end of the pattern. */ - unsigned char *p = bufp->buffer; - register unsigned char *pend = p + bufp->used; - - /* We use this to map every character in the string. */ - char *translate = bufp->translate; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to - the subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where - to resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is - a ``dummy''; if a failure happens and the failure point is a dummy, - it gets discarded and the next next one is tried. */ - fail_stack_type fail_stack; -#ifdef DEBUG - static unsigned failure_id = 0; - unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; -#endif - - /* We fill all the registers internally, independent of what we - return, for use in backreferences. The number here includes - an element for register zero. */ - unsigned num_regs = bufp->re_nsub + 1; - - /* The currently active registers. */ - unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; - unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - const char **regstart, **regend; - - /* If a group that's operated upon by a repetition operator fails to - match anything, then the register for its start will need to be - restored because it will have been set to wherever in the string we - are when we last see its open-group operator. Similarly for a - register's end. */ - const char **old_regstart, **old_regend; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - register_info_type *reg_info; - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = false; - const char **best_regstart, **best_regend; - - /* Logically, this is `best_regend[0]'. But we don't want to have to - allocate space for that if we're not allocating space for anything - else (see below). Also, we never need info about register 0 for - any of the other register vectors, and it seems rather a kludge to - treat `best_regend' differently than the rest. So we keep track of - the end of the best match so far in a separate variable. We - initialize this to NULL so that when we backtrack the first time - and need to test it, it's not garbage. */ - const char *match_end = NULL; - - /* Used when we pop values we don't care about. */ - const char **reg_dummy; - register_info_type *reg_info_dummy; - -#ifdef DEBUG - /* Counts the total number of registers pushed. */ - unsigned num_regs_pushed = 0; -#endif - - DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); - - INIT_FAIL_STACK (); - - /* Do not bother to initialize all the register variables if there are - no groups in the pattern, as it takes a fair amount of time. If - there are groups, we include space for register 0 (the whole - pattern), even though we never use it, since it simplifies the - array indexing. We should fix this. */ - if (bufp->re_nsub) - { - regstart = REGEX_TALLOC (num_regs, const char *); - regend = REGEX_TALLOC (num_regs, const char *); - old_regstart = REGEX_TALLOC (num_regs, const char *); - old_regend = REGEX_TALLOC (num_regs, const char *); - best_regstart = REGEX_TALLOC (num_regs, const char *); - best_regend = REGEX_TALLOC (num_regs, const char *); - reg_info = REGEX_TALLOC (num_regs, register_info_type); - reg_dummy = REGEX_TALLOC (num_regs, const char *); - reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); - - if (!(regstart && regend && old_regstart && old_regend && reg_info - && best_regstart && best_regend && reg_dummy && reg_info_dummy)) - { - FREE_VARIABLES (); - return -2; - } - } -#ifdef REGEX_MALLOC - else - { - /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ - regstart = regend = old_regstart = old_regend = best_regstart - = best_regend = reg_dummy = NULL; - reg_info = reg_info_dummy = (register_info_type *) NULL; - } -#endif /* REGEX_MALLOC */ - - /* The starting position is bogus. */ - if (pos < 0 || pos > size1 + size2) - { - FREE_VARIABLES (); - return -1; - } - - /* Initialize subexpression text positions to -1 to mark ones that no - start_memory/stop_memory has been seen for. Also initialize the - register information struct. */ - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = regend[mcnt] - = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; - - REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - /* We move `string1' into `string2' if the latter's empty -- but not if - `string1' is null. */ - if (size2 == 0 && string1 != NULL) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (stop <= size1) - { - end_match_1 = string1 + stop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + stop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. `d' - is advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal `string2'. */ - if (size1 > 0 && pos <= size1) - { - d = string1 + pos; - dend = end_match_1; - } - else - { - d = string2 + pos - size1; - dend = end_match_2; - } - - DEBUG_PRINT1 ("The compiled pattern is: "); - DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); - DEBUG_PRINT1 ("The string to match is: `"); - DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); - - /* This loops over pattern commands. It exits by returning from the - function if the match is complete, or it drops through if the match - fails at this starting point in the input data. */ - for (;;) - { - DEBUG_PRINT2 ("\n0x%x: ", p); - - if (p == pend) - { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("end of pattern ... "); - - /* If we haven't matched the entire string, and we want the - longest match, try backtracking. */ - if (d != end_match_2) - { - DEBUG_PRINT1 ("backtracking.\n"); - - if (!FAIL_STACK_EMPTY ()) - { /* More failure points to try. */ - boolean same_str_p = (FIRST_STRING_P (match_end) - == MATCHING_IN_FIRST_STRING); - - /* If exceeds best match so far, save it. */ - if (!best_regs_set - || (same_str_p && d > match_end) - || (!same_str_p && !MATCHING_IN_FIRST_STRING)) - { - best_regs_set = true; - match_end = d; - - DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. It may happen that `dend == - end_match_1' while the restored d is in string2. - For example, the pattern `x.*y.*z' against the - strings `x-' and `y-z-', if the two strings are - not consecutive in memory. */ - DEBUG_PRINT1 ("Restoring best registers.\n"); - - d = match_end; - dend = ((d >= string1 && d <= end1) - ? end_match_1 : end_match_2); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } /* d != end_match_2 */ - - DEBUG_PRINT1 ("Accepting match.\n"); - - /* If caller wants register contents data back, do it. */ - if (regs && !bufp->no_sub) - { - /* Have the register data arrays been allocated? */ - if (bufp->regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. We need one - extra element beyond `num_regs' for the `-1' marker - GNU code uses. */ - regs->num_regs = MAX (RE_NREGS, num_regs + 1); - regs->start = TALLOC (regs->num_regs, regoff_t); - regs->end = TALLOC (regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - bufp->regs_allocated = REGS_REALLOCATE; - } - else if (bufp->regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (regs->num_regs < num_regs + 1) - { - regs->num_regs = num_regs + 1; - RETALLOC (regs->start, regs->num_regs, regoff_t); - RETALLOC (regs->end, regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - } - } - else - assert (bufp->regs_allocated == REGS_FIXED); - - /* Convert the pointer data in `regstart' and `regend' to - indices. Register zero has to be set differently, - since we haven't kept track of any info for it. */ - if (regs->num_regs > 0) - { - regs->start[0] = pos; - regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 - : d - string2 + size1); - } - - /* Go through the first `min (num_regs, regs->num_regs)' - registers, since that is all we initialized. */ - for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) - { - if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) - regs->start[mcnt] = regs->end[mcnt] = -1; - else - { - regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); - regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); - } - } - - /* If the regs structure we return has more elements than - were in the pattern, set the extra elements to -1. If - we (re)allocated the registers, this is the case, - because we always allocate enough to have at least one - -1 at the end. */ - for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - } /* regs && !bufp->no_sub */ - - FREE_VARIABLES (); - DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", - nfailure_points_pushed, nfailure_points_popped, - nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); - - mcnt = d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); - - DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - - return mcnt; - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case no_op: - DEBUG_PRINT1 ("EXECUTING no_op.\n"); - break; - - - /* Match the next n pattern characters exactly. The following - byte in the pattern defines n, and the n bytes after that - are the characters to match. */ - case exactn: - mcnt = *p++; - DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); - - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH (); - if (translate[(unsigned char) *d++] != (char) *p++) - goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH (); - if (*d++ != (char) *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED (); - break; - - - /* Match any character except possibly a newline or a null. */ - case anychar: - DEBUG_PRINT1 ("EXECUTING anychar.\n"); - - PREFETCH (); - - if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') - || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) - goto fail; - - SET_REGS_MATCHED (); - DEBUG_PRINT2 (" Matched `%d'.\n", *d); - d++; - break; - - - case charset: - case charset_not: - { - register unsigned char c; - boolean not = (re_opcode_t) *(p - 1) == charset_not; - - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - - PREFETCH (); - c = TRANSLATE (*d); /* The character to match. */ - - /* Cast to `unsigned' instead of `unsigned char' in case the - bit list is a full 32 bytes long. */ - if (c < (unsigned) (*p * BYTEWIDTH) - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - - SET_REGS_MATCHED (); - d++; - break; - } - - - /* The beginning of a group is represented by start_memory. - The arguments are the register number in the next byte, and the - number of groups inner to this one in the next. The text - matched within the group is recorded (in the internal - registers data structure) under the register number. */ - case start_memory: - DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); - - /* Find out if this group can match the empty string. */ - p1 = p; /* To send to group_match_null_string_p. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[*p]) - = group_match_null_string_p (&p1, pend, reg_info); - - /* Save the position in the string where we were the last time - we were at this open-group operator in case the group is - operated upon by a repetition operator, e.g., with `(a*)*b' - against `ab'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regstart[*p]) ? d : regstart[*p] - : regstart[*p]; - DEBUG_PRINT2 (" old_regstart: %d\n", - POINTER_TO_OFFSET (old_regstart[*p])); - - regstart[*p] = d; - DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); - - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* This is the new highest active register. */ - highest_active_reg = *p; - - /* If nothing was active before, this is the new lowest active - register. */ - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *p; - - /* Move past the register number and inner group count. */ - p += 2; - break; - - - /* The stop_memory opcode represents the end of a group. Its - arguments are the same as start_memory's: the register - number, and the number of inner groups. */ - case stop_memory: - DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); - - /* We need to save the string position the last time we were at - this close-group operator in case the group is operated - upon by a repetition operator, e.g., with `((a*)*(b*)*)*' - against `aba'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regend[*p]) ? d : regend[*p] - : regend[*p]; - DEBUG_PRINT2 (" old_regend: %d\n", - POINTER_TO_OFFSET (old_regend[*p])); - - regend[*p] = d; - DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); - - /* This register isn't active anymore. */ - IS_ACTIVE (reg_info[*p]) = 0; - - /* If this was the only register active, nothing is active - anymore. */ - if (lowest_active_reg == highest_active_reg) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - { /* We must scan for the new highest active register, since - it isn't necessarily one less than now: consider - (a(b)c(d(e)f)g). When group 3 ends, after the f), the - new highest active register is 1. */ - unsigned char r = *p - 1; - while (r > 0 && !IS_ACTIVE (reg_info[r])) - r--; - - /* If we end up at register zero, that means that we saved - the registers as the result of an `on_failure_jump', not - a `start_memory', and we jumped to past the innermost - `stop_memory'. For example, in ((.)*) we save - registers 1 and 2 as a result of the *, but when we pop - back to the second ), we are at the stop_memory 1. - Thus, nothing is active. */ - if (r == 0) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - highest_active_reg = r; - } - - /* If just failed to match something this time around with a - group that's operated on by a repetition operator, try to - force exit from the ``loop'', and restore the register - information for this group that we had before trying this - last match. */ - if ((!MATCHED_SOMETHING (reg_info[*p]) - || (re_opcode_t) p[-3] == start_memory) - && (p + 2) < pend) - { - boolean is_a_jump_n = false; - - p1 = p + 2; - mcnt = 0; - switch ((re_opcode_t) *p1++) - { - case jump_n: - is_a_jump_n = true; - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (is_a_jump_n) - p1 += 2; - break; - - default: - /* do nothing */ ; - } - p1 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump right before the start_memory - corresponding to this stop_memory, exit from the loop - by forcing a failure after pushing on the stack the - on_failure_jump's jump in the pattern, and d. */ - if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump - && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) - { - /* If this group ever matched anything, then restore - what its registers were before trying this last - failed match, e.g., with `(a*)*b' against `ab' for - regstart[1], and, e.g., with `((a*)*(b*)*)*' - against `aba' for regend[3]. - - Also restore the registers for inner groups for, - e.g., `((a*)(b*))*' against `aba' (register 3 would - otherwise get trashed). */ - - if (EVER_MATCHED_SOMETHING (reg_info[*p])) - { - unsigned r; - - EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* Restore this and inner groups' (if any) registers. */ - for (r = *p; r < *p + *(p + 1); r++) - { - regstart[r] = old_regstart[r]; - - /* xx why this test? */ - if ((int) old_regend[r] >= (int) regstart[r]) - regend[r] = old_regend[r]; - } - } - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - PUSH_FAILURE_POINT (p1 + mcnt, d, -2); - - goto fail; - } - } - - /* Move past the register number and the inner group count. */ - p += 2; - break; - - - /* \ has been turned into a `duplicate' command which is - followed by the numeric value of as the register number. */ - case duplicate: - { - register const char *d2, *dend2; - int regno = *p++; /* Get which register to match against. */ - DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); - - /* Can't back reference a group which we've never matched. */ - if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) - goto fail; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((FIRST_STRING_P (regstart[regno]) - == FIRST_STRING_P (regend[regno])) - ? regend[regno] : end_match_1); - for (;;) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - - /* End of string1 => advance to string2. */ - d2 = string2; - dend2 = regend[regno]; - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH (); - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - - /* begline matches the empty string at the beginning of the string - (unless `not_bol' is set in `bufp'), and, if - `newline_anchor' is set, after newlines. */ - case begline: - DEBUG_PRINT1 ("EXECUTING begline.\n"); - - if (AT_STRINGS_BEG (d)) - { - if (!bufp->not_bol) break; - } - else if (d[-1] == '\n' && bufp->newline_anchor) - { - break; - } - /* In all other cases, we fail. */ - goto fail; - - - /* endline is the dual of begline. */ - case endline: - DEBUG_PRINT1 ("EXECUTING endline.\n"); - - if (AT_STRINGS_END (d)) - { - if (!bufp->not_eol) break; - } - - /* We have to ``prefetch'' the next character. */ - else if ((d == end1 ? *string2 : *d) == '\n' - && bufp->newline_anchor) - { - break; - } - goto fail; - - - /* Match at the very beginning of the data. */ - case begbuf: - DEBUG_PRINT1 ("EXECUTING begbuf.\n"); - if (AT_STRINGS_BEG (d)) - break; - goto fail; - - - /* Match at the very end of the data. */ - case endbuf: - DEBUG_PRINT1 ("EXECUTING endbuf.\n"); - if (AT_STRINGS_END (d)) - break; - goto fail; - - - /* on_failure_keep_string_jump is used to optimize `.*\n'. It - pushes NULL as the value for the string on the stack. Then - `pop_failure_point' will keep the current value for the - string, instead of restoring it. To see why, consider - matching `foo\nbar' against `.*\n'. The .* matches the foo; - then the . fails against the \n. But the next thing we want - to do is match the \n against the \n; if we restored the - string value, we would be back at the foo. - - Because this is used only in specific cases, we don't need to - check all the things that `on_failure_jump' does, to make - sure the right things get saved on the stack. Hence we don't - share its code. The only reason to push anything on the - stack at all is that otherwise we would have to change - `anychar's code to do something besides goto fail in this - case; that seems worse than this. */ - case on_failure_keep_string_jump: - DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); - - PUSH_FAILURE_POINT (p + mcnt, NULL, -2); - break; - - - /* Uses of on_failure_jump: - - Each alternative starts with an on_failure_jump that points - to the beginning of the next alternative. Each alternative - except the last ends with a jump that in effect jumps past - the rest of the alternatives. (They really jump to the - ending jump of the following alternative, because tensioning - these jumps is a hassle.) - - Repeats start with an on_failure_jump that points past both - the repetition text and either the following jump or - pop_failure_jump back to this on_failure_jump. */ - case on_failure_jump: - on_failure: - DEBUG_PRINT1 ("EXECUTING on_failure_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); - - /* If this on_failure_jump comes right before a group (i.e., - the original * applied to a group), save the information - for that group and all inner ones, so that if we fail back - to this point, the group's information will be correct. - For example, in \(a*\)*\1, we need the preceding group, - and in \(\(a*\)b*\)\2, we need the inner group. */ - - /* We can't use `p' to check ahead because we push - a failure point to `p + mcnt' after we do this. */ - p1 = p; - - /* We need to skip no_op's before we look for the - start_memory in case this on_failure_jump is happening as - the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 - against aba. */ - while (p1 < pend && (re_opcode_t) *p1 == no_op) - p1++; - - if (p1 < pend && (re_opcode_t) *p1 == start_memory) - { - /* We have a new highest active register now. This will - get reset at the start_memory we are about to get to, - but we will have saved all the registers relevant to - this repetition op, as described above. */ - highest_active_reg = *(p1 + 1) + *(p1 + 2); - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *(p1 + 1); - } - - DEBUG_PRINT1 (":\n"); - PUSH_FAILURE_POINT (p + mcnt, d, -2); - break; - - - /* A smart repeat ends with `maybe_pop_jump'. - We change it to either `pop_failure_jump' or `jump'. */ - case maybe_pop_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); - { - register unsigned char *p2 = p; - - /* Compare the beginning of the repeat with what in the - pattern follows its end. If we can establish that there - is nothing that they would both match, i.e., that we - would have to backtrack because of (as in, e.g., `a*a') - then we can change to pop_failure_jump, because we'll - never have to backtrack. - - This is not true in the case of alternatives: in - `(a|ab)*' we do need to backtrack to the `ab' alternative - (e.g., if the string was `ab'). But instead of trying to - detect that here, the alternative has put on a dummy - failure point which is what we will end up popping. */ - - /* Skip over open/close-group commands. */ - while (p2 + 2 < pend - && ((re_opcode_t) *p2 == stop_memory - || (re_opcode_t) *p2 == start_memory)) - p2 += 3; /* Skip over args, too. */ - - /* If we're at the end of the pattern, we can change. */ - if (p2 == pend) - { - /* Consider what happens when matching ":\(.*\)" - against ":/". I don't really understand this code - yet. */ - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 - (" End of pattern: change to `pop_failure_jump'.\n"); - } - - else if ((re_opcode_t) *p2 == exactn - || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) - { - register unsigned char c - = *p2 == (unsigned char) endline ? '\n' : p2[2]; - p1 = p + mcnt; - - /* p1[0] ... p1[2] are the `on_failure_jump' corresponding - to the `maybe_finalize_jump' of this case. Examine what - follows. */ - if ((re_opcode_t) p1[3] == exactn && p1[5] != c) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", - c, p1[5]); - } - - else if ((re_opcode_t) p1[3] == charset - || (re_opcode_t) p1[3] == charset_not) - { - int not = (re_opcode_t) p1[3] == charset_not; - - if (c < (unsigned char) (p1[4] * BYTEWIDTH) - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - /* `not' is equal to 1 if c would match, which means - that we can't change to pop_failure_jump. */ - if (!not) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); - } - } - } - } - p -= 2; /* Point at relative address again. */ - if ((re_opcode_t) p[-1] != pop_failure_jump) - { - p[-1] = (unsigned char) jump; - DEBUG_PRINT1 (" Match => jump.\n"); - goto unconditional_jump; - } - /* Note fall through. */ - - - /* The end of a simple repeat has a pop_failure_jump back to - its matching on_failure_jump, where the latter will push a - failure point. The pop_failure_jump takes off failure - points put on by this pop_failure_jump's matching - on_failure_jump; we got through the pattern to here from the - matching on_failure_jump, so didn't fail. */ - case pop_failure_jump: - { - /* We need to pass separate storage for the lowest and - highest registers, even though we don't care about the - actual values. Otherwise, we will restore only one - register from the stack, since lowest will == highest in - `pop_failure_point'. */ - unsigned dummy_low_reg, dummy_high_reg; - unsigned char *pdummy; - const char *sdummy; - - DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); - POP_FAILURE_POINT (sdummy, pdummy, - dummy_low_reg, dummy_high_reg, - reg_dummy, reg_dummy, reg_info_dummy); - } - /* Note fall through. */ - - - /* Unconditionally jump (without popping any failure points). */ - case jump: - unconditional_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); - p += mcnt; /* Do the jump. */ - DEBUG_PRINT2 ("(to 0x%x).\n", p); - break; - - - /* We need this opcode so we can detect where alternatives end - in `group_match_null_string_p' et al. */ - case jump_past_alt: - DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); - goto unconditional_jump; - - - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at pop_failure_jump. We will end up at - pop_failure_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for pop_failure_jump to pop. */ - case dummy_failure_jump: - DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); - /* It doesn't matter what we push for the string here. What - the code at `fail' tests is the value for the pattern. */ - PUSH_FAILURE_POINT (0, 0, -2); - goto unconditional_jump; - - - /* At the end of an alternative, we need to push a dummy failure - point in case we are followed by a `pop_failure_jump', because - we don't want the failure point for the alternative to be - popped. For example, matching `(a|ab)*' against `aab' - requires that we match the `ab' alternative. */ - case push_dummy_failure: - DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); - /* See comments just above at `dummy_failure_jump' about the - two zeroes. */ - PUSH_FAILURE_POINT (0, 0, -2); - break; - - /* Have to succeed matching what follows at least n times. - After that, handle like `on_failure_jump'. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); - - assert (mcnt >= 0); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt > 0) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); - } - else if (mcnt == 0) - { - DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); - p[2] = (unsigned char) no_op; - p[3] = (unsigned char) no_op; - goto on_failure; - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); - - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER (p + 2, mcnt); - goto unconditional_jump; - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); - STORE_NUMBER (p1, mcnt); - break; - } - - case wordbound: - DEBUG_PRINT1 ("EXECUTING wordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - break; - goto fail; - - case notwordbound: - DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - goto fail; - break; - - case wordbeg: - DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) - break; - goto fail; - - case wordend: - DEBUG_PRINT1 ("EXECUTING wordend.\n"); - if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) - && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) - break; - goto fail; - -#ifdef emacs -#ifdef emacs19 - case before_dot: - DEBUG_PRINT1 ("EXECUTING before_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) >= point) - goto fail; - break; - - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) != point) - goto fail; - break; - - case after_dot: - DEBUG_PRINT1 ("EXECUTING after_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) <= point) - goto fail; - break; -#else /* not emacs19 */ - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) - goto fail; - break; -#endif /* not emacs19 */ - - case syntaxspec: - DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchsyntax; - - case wordchar: - DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); - mcnt = (int) Sword; - matchsyntax: - PREFETCH (); - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - - case notsyntaxspec: - DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchnotsyntax; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); - mcnt = (int) Sword; - matchnotsyntax: - PREFETCH (); - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - -#else /* not emacs */ - case wordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH (); - if (!WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH (); - if (WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; -#endif /* not emacs */ - - default: - abort (); - } - continue; /* Successfully executed one pattern command; keep going. */ - - - /* We goto here if a matching operation fails. */ - fail: - if (!FAIL_STACK_EMPTY ()) - { /* A restart point is known. Restore to that state. */ - DEBUG_PRINT1 ("\nFAIL:\n"); - POP_FAILURE_POINT (d, p, - lowest_active_reg, highest_active_reg, - regstart, regend, reg_info); - - /* If this failure point is a dummy, try the next one. */ - if (!p) - goto fail; - - /* If we failed to the end of the pattern, don't examine *p. */ - assert (p <= pend); - if (p < pend) - { - boolean is_a_jump_n = false; - - /* If failed to a backwards jump that's part of a repetition - loop, need to pop this failure point and use the next one. */ - switch ((re_opcode_t) *p) - { - case jump_n: - is_a_jump_n = true; - case maybe_pop_jump: - case pop_failure_jump: - case jump: - p1 = p + 1; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - - if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) - || (!is_a_jump_n - && (re_opcode_t) *p1 == on_failure_jump)) - goto fail; - break; - default: - /* do nothing */ ; - } - } - - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else - break; /* Matching at this starting point really fails. */ - } /* for (;;) */ - - if (best_regs_set) - goto restore_best_regs; - - FREE_VARIABLES (); - - return -1; /* Failure to match. */ -} /* re_match_2 */ - -/* Subroutine definitions for re_match_2. */ - - -/* We are passed P pointing to a register number after a start_memory. - - Return true if the pattern up to the corresponding stop_memory can - match the empty string, and false otherwise. - - If we find the matching stop_memory, sets P to point to one past its number. - Otherwise, sets P to an undefined byte less than or equal to END. - - We don't handle duplicates properly (yet). */ - -static boolean -group_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - /* Point to after the args to the start_memory. */ - unsigned char *p1 = *p + 2; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and return true or - false, as appropriate, when we get to one that can't, or to the - matching stop_memory. */ - - switch ((re_opcode_t) *p1) - { - /* Could be either a loop or a series of alternatives. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - /* If the next operation is not a jump backwards in the - pattern. */ - - if (mcnt >= 0) - { - /* Go through the on_failure_jumps of the alternatives, - seeing if any of the alternatives cannot match nothing. - The last alternative starts with only a jump, - whereas the rest start with on_failure_jump and end - with a jump, e.g., here is the pattern for `a|b|c': - - /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 - /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 - /exactn/1/c - - So, we have to first go through the first (n-1) - alternatives and then deal with the last one separately. */ - - - /* Deal with the first (n-1) alternatives, which start - with an on_failure_jump (see above) that jumps to right - past a jump_past_alt. */ - - while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) - { - /* `mcnt' holds how many bytes long the alternative - is, including the ending `jump_past_alt' and - its number. */ - - if (!alt_match_null_string_p (p1, p1 + mcnt - 3, - reg_info)) - return false; - - /* Move to right after this alternative, including the - jump_past_alt. */ - p1 += mcnt; - - /* Break if it's the beginning of an n-th alternative - that doesn't begin with an on_failure_jump. */ - if ((re_opcode_t) *p1 != on_failure_jump) - break; - - /* Still have to check that it's not an n-th - alternative that starts with an on_failure_jump. */ - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) - { - /* Get to the beginning of the n-th alternative. */ - p1 -= 3; - break; - } - } - - /* Deal with the last alternative: go back and get number - of the `jump_past_alt' just before it. `mcnt' contains - the length of the alternative. */ - EXTRACT_NUMBER (mcnt, p1 - 2); - - if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) - return false; - - p1 += mcnt; /* Get past the n-th alternative. */ - } /* if mcnt > 0 */ - break; - - - case stop_memory: - assert (p1[1] == **p); - *p = p1 + 2; - return true; - - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return false; -} /* group_match_null_string_p */ - - -/* Similar to group_match_null_string_p, but doesn't deal with alternatives: - It expects P to be the first byte of a single alternative and END one - byte past the last. The alternative can contain groups. */ - -static boolean -alt_match_null_string_p (p, end, reg_info) - unsigned char *p, *end; - register_info_type *reg_info; -{ - int mcnt; - unsigned char *p1 = p; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and break when we get - to one that can't. */ - - switch ((re_opcode_t) *p1) - { - /* It's a loop. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - break; - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return true; -} /* alt_match_null_string_p */ - - -/* Deals with the ops common to group_match_null_string_p and - alt_match_null_string_p. - - Sets P to one after the op and its arguments, if any. */ - -static boolean -common_op_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - boolean ret; - int reg_no; - unsigned char *p1 = *p; - - switch ((re_opcode_t) *p1++) - { - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbeg: - case wordend: - case wordbound: - case notwordbound: -#ifdef emacs - case before_dot: - case at_dot: - case after_dot: -#endif - break; - - case start_memory: - reg_no = *p1; - assert (reg_no > 0 && reg_no <= MAX_REGNUM); - ret = group_match_null_string_p (&p1, end, reg_info); - - /* Have to set this here in case we're checking a group which - contains a group and a back reference to it. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; - - if (!ret) - return false; - break; - - /* If this is an optimized succeed_n for zero times, make the jump. */ - case jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (mcnt >= 0) - p1 += mcnt; - else - return false; - break; - - case succeed_n: - /* Get to the number of times to succeed. */ - p1 += 2; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - if (mcnt == 0) - { - p1 -= 4; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - } - else - return false; - break; - - case duplicate: - if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) - return false; - break; - - case set_number_at: - p1 += 4; - - default: - /* All other opcodes mean we cannot match the empty string. */ - return false; - } - - *p = p1; - return true; -} /* common_op_match_null_string_p */ - - -/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN - bytes; nonzero otherwise. */ - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate[*p1++] != translate[*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length SIZE) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the `allocated' (and perhaps `buffer') and `translate' fields - are set in BUFP on entry. - - We call regex_compile to do the actual compilation. */ - -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - int length; - struct re_pattern_buffer *bufp; -{ - reg_errcode_t ret; - - /* GNU code is written to assume at least RE_NREGS registers will be set - (and at least one extra will be -1). */ - bufp->regs_allocated = REGS_UNALLOCATED; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub. */ - bufp->no_sub = 0; - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = regex_compile (pattern, length, re_syntax_options, bufp); - - return re_error_msg[(int) ret]; -} - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them if this is an Emacs or POSIX compilation. */ - -#if !defined (emacs) && !defined (_POSIX_SOURCE) - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - re_comp_buf.buffer = (unsigned char *) malloc (200); - if (re_comp_buf.buffer == NULL) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - - re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); - if (re_comp_buf.fastmap == NULL) - return "Memory exhausted"; - } - - /* Since `re_exec' always passes NULL for the `regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); - - /* Yes, we're discarding `const' here. */ - return (char *) re_error_msg[(int) ret]; -} - - -int -re_exec (s) - const char *s; -{ - const int len = strlen (s); - return - 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); -} -#endif /* not emacs and not _POSIX_SOURCE */ - -/* POSIX.2 functions. Don't define these for Emacs. */ - -#ifndef emacs - -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - `buffer' to the compiled pattern; - `used' to the length of the compiled pattern; - `syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; - `re_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *preg; - const char *pattern; - int cflags; -{ - reg_errcode_t ret; - unsigned syntax - = (cflags & REG_EXTENDED) ? - RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; - - /* regex_compile will allocate the space for the compiled pattern. */ - preg->buffer = 0; - preg->allocated = 0; - - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; - - if (cflags & REG_ICASE) - { - unsigned i; - - preg->translate = (char *) malloc (CHAR_SET_SIZE); - if (preg->translate == NULL) - return (int) REG_ESPACE; - - /* Map uppercase characters to corresponding lowercase ones. */ - for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = ISUPPER (i) ? tolower (i) : i; - } - else - preg->translate = NULL; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - - preg->no_sub = !!(cflags & REG_NOSUB); - - /* POSIX says a null character in the pattern terminates it, so we - can use strlen here in compiling the pattern. */ - ret = regex_compile (pattern, strlen (pattern), syntax, preg); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) ret = REG_EPAREN; - - return (int) ret; -} - - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies `execution flags' which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *preg; - const char *string; - size_t nmatch; - regmatch_t pmatch[]; - int eflags; -{ - int ret; - struct re_registers regs; - regex_t private_preg; - int len = strlen (string); - boolean want_reg_info = !preg->no_sub && nmatch > 0; - - private_preg = *preg; - - private_preg.not_bol = !!(eflags & REG_NOTBOL); - private_preg.not_eol = !!(eflags & REG_NOTEOL); - - /* The user has told us exactly how many registers to return - information about, via `nmatch'. We have to pass that on to the - matching routines. */ - private_preg.regs_allocated = REGS_FIXED; - - if (want_reg_info) - { - regs.num_regs = nmatch; - regs.start = TALLOC (nmatch, regoff_t); - regs.end = TALLOC (nmatch, regoff_t); - if (regs.start == NULL || regs.end == NULL) - return (int) REG_NOMATCH; - } - - /* Perform the searching operation. */ - ret = re_search (&private_preg, string, len, - /* start: */ 0, /* range: */ len, - want_reg_info ? ®s : (struct re_registers *) 0); - - /* Copy the register information to the POSIX structure. */ - if (want_reg_info) - { - if (ret >= 0) - { - unsigned r; - - for (r = 0; r < nmatch; r++) - { - pmatch[r].rm_so = regs.start[r]; - pmatch[r].rm_eo = regs.end[r]; - } - } - - /* If we needed the temporary register info, free the space now. */ - free (regs.start); - free (regs.end); - } - - /* We want zero return to mean success, unlike `re_search'. */ - return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; -} - - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; -{ - const char *msg; - size_t msg_size; - - if (errcode < 0 - || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - - msg = re_error_msg[errcode]; - - /* POSIX doesn't require that we do anything in this case, but why - not be nice. */ - if (! msg) - msg = "Success"; - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (errbuf_size != 0) - { - if (msg_size > errbuf_size) - { - strncpy (errbuf, msg, errbuf_size - 1); - errbuf[errbuf_size - 1] = 0; - } - else - strcpy (errbuf, msg); - } - - return msg_size; -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - if (preg->buffer != NULL) - free (preg->buffer); - preg->buffer = NULL; - - preg->allocated = 0; - preg->used = 0; - - if (preg->fastmap != NULL) - free (preg->fastmap); - preg->fastmap = NULL; - preg->fastmap_accurate = 0; - - if (preg->translate != NULL) - free (preg->translate); - preg->translate = NULL; -} - -#endif /* not emacs */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/usr.bin/cvs/lib/y.tab.h b/gnu/usr.bin/cvs/lib/y.tab.h deleted file mode 100644 index 4a541d2c97f7..000000000000 --- a/gnu/usr.bin/cvs/lib/y.tab.h +++ /dev/null @@ -1,18 +0,0 @@ -#define tAGO 257 -#define tDAY 258 -#define tDAYZONE 259 -#define tID 260 -#define tMERIDIAN 261 -#define tMINUTE_UNIT 262 -#define tMONTH 263 -#define tMONTH_UNIT 264 -#define tSEC_UNIT 265 -#define tSNUMBER 266 -#define tUNUMBER 267 -#define tZONE 268 -#define tDST 269 -typedef union { - time_t Number; - enum _MERIDIAN Meridian; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/cvs/mkmodules/xxx b/gnu/usr.bin/cvs/mkmodules/xxx deleted file mode 100644 index f0dd87dee7e7..000000000000 --- a/gnu/usr.bin/cvs/mkmodules/xxx +++ /dev/null @@ -1,5320 +0,0 @@ -# 1 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" - - - - - - - - - - - - - -# 1 "/usr/include/sys/syslimits.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 14 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 1 - - -# 1 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 1 - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; - -typedef char * caddr_t; -typedef long daddr_t; -typedef short dev_t; -typedef u_long ino_t; -typedef long off_t; -typedef u_short nlink_t; -typedef long swblk_t; -typedef long segsz_t; -typedef u_short uid_t; -typedef u_short gid_t; -typedef short pid_t; -typedef u_short mode_t; -typedef u_long fixpt_t; - - -typedef struct _uquad { u_long val[2]; } u_quad; -typedef struct _quad { long val[2]; } quad; -typedef long * qaddr_t; - - - - - - -# 1 "/usr/include/machine/ansi.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 69 "/usr/include/sys/types.h" 2 - - -# 1 "/usr/include/machine/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -typedef struct _physadr { - int r[1]; -} *physadr; - -typedef struct label_t { - int val[6]; -} label_t; - -typedef u_long vm_offset_t; -typedef u_long vm_size_t; - - -# 71 "/usr/include/sys/types.h" 2 - - - - -typedef unsigned long clock_t; - - - - -typedef unsigned int size_t; - - - - -typedef long time_t; - - - - - - - - - - - - - - - - -typedef long fd_mask; - - - - - - -typedef struct fd_set { - fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ]; -} fd_set; - - - - - - -# 132 "/usr/include/sys/types.h" - - - - -# 20 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - -# 1 "/usr/include/sys/stat.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct stat -{ - dev_t st_dev; - ino_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - time_t st_atime; - long st_spare1; - time_t st_mtime; - long st_spare2; - time_t st_ctime; - long st_spare3; - long st_blksize; - long st_blocks; - u_long st_flags; - u_long st_gen; -}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 76 "/usr/include/sys/cdefs.h" - - - -# 114 "/usr/include/sys/stat.h" 2 - - - -mode_t umask (mode_t) ; -int chmod (const char *, mode_t) ; -int fstat (int, struct stat *) ; -int mkdir (const char *, mode_t) ; -int mkfifo (const char *, mode_t) ; -int stat (const char *, struct stat *) ; - -int fchmod (int, mode_t) ; -int lstat (const char *, struct stat *) ; - - - -# 21 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -off_t lseek (); - - - - - -# 1 "/usr/include/time.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/machine/ansi.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 57 "/usr/include/machine/ansi.h" - -# 39 "/usr/include/time.h" 2 - - - - - - - - - - - - - - - - - - - - - -struct tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - long tm_gmtoff; - char *tm_zone; -}; - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 74 "/usr/include/time.h" 2 - - - -char *asctime (const struct tm *) ; -clock_t clock (void) ; -char *ctime (const time_t *) ; -double difftime (time_t, time_t) ; -struct tm *gmtime (const time_t *) ; -struct tm *localtime (const time_t *) ; -time_t mktime (struct tm *) ; -size_t strftime (char *, size_t, const char *, const struct tm *) ; -time_t time (time_t *) ; - - -void tzset (void) ; - - - -char *timezone (int, int) ; -void tzsetwall (void) ; - - - - -# 72 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - -# 86 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" - -# 1 "/usr/include/sys/timeb.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct timeb { - time_t time; - unsigned short millitm; - short timezone; - short dstflag; -}; -# 87 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - - - - - - - - -# 1 "/usr/include/sys/param.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 135 "/usr/include/sys/types.h" - -# 46 "/usr/include/sys/param.h" 2 - - - - - - - - - - -# 1 "/usr/include/sys/syslimits.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 56 "/usr/include/sys/param.h" 2 - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/signal.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/machine/trap.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 42 "/usr/include/sys/signal.h" 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 90 "/usr/include/sys/signal.h" 2 - - - -typedef void (*sig_t) (int) ; - - -typedef void (*__sighandler_t) (int) ; -typedef unsigned int sigset_t; - - -int sigaddset (sigset_t *, int) ; -int sigdelset (sigset_t *, int) ; -int sigemptyset (sigset_t *) ; -int sigfillset (sigset_t *) ; -int sigismember (const sigset_t *, int) ; - - - - - - - - - - - -struct sigaction { - __sighandler_t sa_handler; - sigset_t sa_mask; - int sa_flags; -}; - - - - - - - - - - - - - - - - - - -struct sigvec { - void (*sv_handler)(); - int sv_mask; - int sv_flags; -}; - - - - - - - -struct sigaltstack { - char *ss_base; - int ss_len; - int ss_onstack; -}; - - - - -struct sigstack { - char *ss_sp; - int ss_onstack; -}; - - - - - - - - -struct sigcontext { - int sc_onstack; - int sc_mask; - int sc_sp; - int sc_fp; - int sc_ap; - int sc_pc; - int sc_ps; -}; - - - - - - - - - - - - - - -# 1 "/usr/include/sys/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 135 "/usr/include/sys/types.h" - -# 195 "/usr/include/sys/signal.h" 2 - - - - -__sighandler_t signal (int, __sighandler_t) ; -int raise (int) ; - -int kill (pid_t, int) ; -int sigaction (int, const struct sigaction *, struct sigaction *) ; -int sigpending (sigset_t *) ; -int sigprocmask (int, const sigset_t *, sigset_t *) ; -int sigsuspend (const sigset_t *) ; - - -int killpg (pid_t, int) ; -void psignal (unsigned, const char *) ; -int sigblock (int) ; -int siginterrupt (int, int) ; -int sigpause (int) ; -int sigreturn (struct sigcontext *) ; -int sigsetmask (int) ; -int sigstack (const struct sigstack *, struct sigstack *) ; -int sigvec (int, struct sigvec *, struct sigvec *) ; - - - - - -# 79 "/usr/include/sys/param.h" 2 - - - -# 1 "/usr/include/machine/param.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 82 "/usr/include/sys/param.h" 2 - -# 1 "/usr/include/machine/endian.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 55 "/usr/include/machine/endian.h" 2 - - - - - - - - - -# 77 "/usr/include/machine/endian.h" - - - - - - - - - - - - - - - - - - -# 106 "/usr/include/machine/endian.h" - - - - - - - - - - - - -# 83 "/usr/include/sys/param.h" 2 - -# 1 "/usr/include/machine/limits.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 84 "/usr/include/sys/param.h" 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 97 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - - - - - - - - - - - - - - - - - -struct utimbuf -{ - long actime; - long modtime; -}; - -int utime (); - - -# 145 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" - -# 1 "/usr/include/strings.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/string.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/machine/ansi.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 57 "/usr/include/machine/ansi.h" - -# 38 "/usr/include/string.h" 2 - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 49 "/usr/include/string.h" 2 - - - -void *memchr (const void *, int, size_t) ; -int memcmp (const void *, const void *, size_t) ; -void *memcpy (void *, const void *, size_t) ; -void *memmove (void *, const void *, size_t) ; -void *memset (void *, int, size_t) ; -char *strcat (char *, const char *) ; -char *strchr (const char *, int) ; -int strcmp (const char *, const char *) ; -int strcoll (const char *, const char *) ; -char *strcpy (char *, const char *) ; -size_t strcspn (const char *, const char *) ; -char *strerror (int) ; -size_t strlen (const char *) ; -char *strncat (char *, const char *, size_t) ; -int strncmp (const char *, const char *, size_t) ; -char *strncpy (char *, const char *, size_t) ; -char *strpbrk (const char *, const char *) ; -char *strrchr (const char *, int) ; -size_t strspn (const char *, const char *) ; -char *strstr (const char *, const char *) ; -char *strtok (char *, const char *) ; -size_t strxfrm (char *, const char *, size_t) ; - - - -int bcmp (const void *, const void *, size_t) ; -void bcopy (const void *, void *, size_t) ; -void bzero (void *, size_t) ; -int ffs (int) ; -char *index (const char *, int) ; -void *memccpy (void *, const void *, int, size_t) ; -char *rindex (const char *, int) ; -int strcasecmp (const char *, const char *) ; -char *strdup (const char *) ; -void strmode (int, char *) ; -int strncasecmp (const char *, const char *, size_t) ; -char *strsep (char **, const char *) ; -void swab (const void *, void *, size_t) ; - - - - -# 36 "/usr/include/strings.h" 2 - -# 146 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - -# 1 "/usr/include/errno.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -extern int errno; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 149 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - - -char *getenv (); -char *malloc (); -char *realloc (); -char *calloc (); -extern int errno; - - - - - - -# 173 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" - - - - - - -# 1 "/usr/include/sys/file.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/fcntl.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 135 "/usr/include/sys/types.h" - -# 46 "/usr/include/sys/fcntl.h" 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 99 "/usr/include/sys/fcntl.h" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct flock { - short l_type; - short l_whence; - off_t l_start; - off_t l_len; - pid_t l_pid; -}; - - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 169 "/usr/include/sys/fcntl.h" 2 - - - -int open (const char *, int, ...) ; -int creat (const char *, mode_t) ; -int fcntl (int, int, ...) ; - -int flock (int, int) ; - - - - - -# 36 "/usr/include/sys/file.h" 2 - -# 1 "/usr/include/sys/unistd.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 37 "/usr/include/sys/file.h" 2 - - -# 73 "/usr/include/sys/file.h" - -# 179 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - -char *getwd (); - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/dir.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/dirent.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct dirent { - u_long d_fileno; - u_short d_reclen; - u_short d_namlen; - - - - - char d_name[255 + 1]; - -}; - - - - - - - - - - - -typedef struct _dirdesc { - int dd_fd; - long dd_loc; - long dd_size; - char *dd_buf; - int dd_len; - long dd_seek; -} DIR; - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 88 "/usr/include/dirent.h" 2 - - - -DIR *opendir (const char *) ; -struct dirent *readdir (DIR *) ; -void rewinddir (DIR *) ; -int closedir (DIR *) ; - -long telldir (const DIR *) ; -void seekdir (DIR *, long) ; -int scandir (const char *, struct dirent ***, - int (*)(struct dirent *), int (*)(const void *, const void *)) ; -int alphasort (const void *, const void *) ; -int getdirentries (int, char *, int, long *) ; - - - - - - -# 44 "/usr/include/sys/dir.h" 2 - - - - - - - - - - - - - - - - - - -# 208 "/usr/src/gnu/cvs/mkmodules/../lib/system.h" 2 - - - - - - - - - - - - - - - - -# 3 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/include/stdio.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 42 "/usr/include/stdio.h" 2 - - -# 1 "/usr/include/machine/ansi.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 57 "/usr/include/machine/ansi.h" - -# 44 "/usr/include/stdio.h" 2 - - - - - - - - - - -typedef long fpos_t; - - - - - - - - - - -struct __sbuf { - unsigned char *_base; - int _size; -}; - - - - - - - - - - - - - - - - - - - - - - - - - -typedef struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - - void *_cookie; - int (*_close) (void *) ; - int (*_read) (void *, char *, int) ; - fpos_t (*_seek) (void *, fpos_t, int) ; - int (*_write) (void *, const char *, int) ; - - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - - struct __sbuf _lb; - - - int _blksize; - int _offset; -} FILE; - - -extern FILE __sF[]; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void clearerr (FILE *) ; -int fclose (FILE *) ; -int feof (FILE *) ; -int ferror (FILE *) ; -int fflush (FILE *) ; -int fgetc (FILE *) ; -int fgetpos (FILE *, fpos_t *) ; -char *fgets (char *, size_t, FILE *) ; -FILE *fopen (const char *, const char *) ; -int fprintf (FILE *, const char *, ...) ; -int fputc (int, FILE *) ; -int fputs (const char *, FILE *) ; -int fread (void *, size_t, size_t, FILE *) ; -FILE *freopen (const char *, const char *, FILE *) ; -int fscanf (FILE *, const char *, ...) ; -int fseek (FILE *, long, int) ; -int fsetpos (FILE *, const fpos_t *) ; -long ftell (const FILE *) ; -int fwrite (const void *, size_t, size_t, FILE *) ; -int getc (FILE *) ; -int getchar (void) ; -char *gets (char *) ; - -extern int sys_nerr; -extern char *sys_errlist[]; - -void perror (const char *) ; -int printf (const char *, ...) ; -int putc (int, FILE *) ; -int putchar (int) ; -int puts (const char *) ; -int remove (const char *) ; -int rename (const char *, const char *) ; -void rewind (FILE *) ; -int scanf (const char *, ...) ; -void setbuf (FILE *, char *) ; -int setvbuf (FILE *, char *, int, size_t) ; -int sprintf (char *, const char *, ...) ; -int sscanf (char *, const char *, ...) ; -FILE *tmpfile (void) ; -char *tmpnam (char *) ; -int ungetc (int, FILE *) ; -int vfprintf (FILE *, const char *, char * ) ; -int vprintf (const char *, char * ) ; -int vsprintf (char *, const char *, char * ) ; - - - - - - - - - - -char *ctermid (char *) ; -FILE *fdopen (int, const char *) ; -int fileno (FILE *) ; - - - - - - - - -char *fgetline (FILE *, size_t *) ; -int fpurge (FILE *) ; -int getw (FILE *) ; -int pclose (FILE *) ; -FILE *popen (const char *, const char *) ; -int putw (int, FILE *) ; -void setbuffer (FILE *, char *, int) ; -int setlinebuf (FILE *) ; -char *tempnam (const char *, const char *) ; -int snprintf (char *, size_t, const char *, ...) ; -int vsnprintf (char *, size_t, const char *, char * ) ; -int vscanf (const char *, char * ) ; -int vsscanf (const char *, const char *, char * ) ; - - - - - - - - - - - - - -FILE *funopen (const void *, - int (*)(void *, char *, int), - int (*)(void *, const char *, int), - fpos_t (*)(void *, fpos_t, int), - int (*)(void *)) ; - - - - - - - - - -int __srget (FILE *) ; -int __svfscanf (FILE *, const char *, char * ) ; -int __swbuf (int, FILE *) ; - - - - - - - - -static inline int __sputc(int _c, FILE *_p) { - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf(_c, _p)); -} -# 331 "/usr/include/stdio.h" - - - - - - - - - - - - - - - - - - - - - - - -# 4 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/include/ctype.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -extern char _ctype_[]; - - - - - - - - - - - - - - - - - - -# 5 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/include/pwd.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1 "/usr/include/sys/types.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 135 "/usr/include/sys/types.h" - -# 39 "/usr/include/pwd.h" 2 - - - - - - - - - - - - - - - - - - - - -struct passwd { - char *pw_name; - char *pw_passwd; - int pw_uid; - int pw_gid; - time_t pw_change; - char *pw_class; - char *pw_gecos; - char *pw_dir; - char *pw_shell; - time_t pw_expire; -}; - -# 1 "/usr/include/sys/cdefs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 78 "/usr/include/sys/cdefs.h" - -# 72 "/usr/include/pwd.h" 2 - - - -struct passwd *getpwuid (uid_t) ; -struct passwd *getpwnam (const char *) ; - -struct passwd *getpwent (void) ; -int setpassent (int) ; -int setpwent (void) ; -void endpwent (void) ; - - - - -# 6 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/include/signal.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 222 "/usr/include/signal.h" - -# 7 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/hash.h" 1 - - - - - - - - - - - - - - - - - - -enum ntype -{ - UNKNOWN, HEADER, ENTRIES, FILES, LIST, RCSNODE, - RCSVERS, DIRS, UPDATE, LOCK, NDBMNODE -}; -typedef enum ntype Ntype; - -struct node -{ - Ntype type; - struct node *next; - struct node *prev; - struct node *hashnext; - struct node *hashprev; - char *key; - char *data; - void (*delproc) (); -}; -typedef struct node Node; - -struct list -{ - Node *list; - Node *hasharray[151 ]; - struct list *next; -}; -typedef struct list List; - -struct entnode -{ - char *version; - char *timestamp; - char *options; - char *tag; - char *date; -}; -typedef struct entnode Entnode; - - -List *getlist (void); -Node *findnode (List * list, char *key); -Node *getnode (void); -int addnode (List * list, Node * p); -int walklist (List * list, int (*proc) ()); -void dellist (List ** listp); -void delnode (Node * p); -void freenode (Node * p); -void sortlist (List * list, int (*comp) ()); -# 77 "/usr/src/gnu/cvs/mkmodules/../cvs/hash.h" - -# 8 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/rcs.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct rcsnode -{ - int refcount; - int flags; - char *path; - char *head; - char *branch; - List *symbols; - List *versions; - List *dates; -}; -typedef struct rcsnode RCSNode; - -struct rcsversnode -{ - char *version; - char *date; - char *next; - List *branches; -}; -typedef struct rcsversnode RCSVers; - - - - - - - - - - - - - - -List *RCS_parsefiles (List * files, char *xrepos); -RCSNode *RCS_parse (char *file, char *repos); -RCSNode *RCS_parsercsfile (char *rcsfile); -char *RCS_check_kflag (char *arg); -char *RCS_getdate (RCSNode * rcs, char *date, int force_tag_match); -char *RCS_gettag (RCSNode * rcs, char *tag, int force_tag_match); -char *RCS_getversion (RCSNode * rcs, char *tag, char *date, - int force_tag_match); -char *RCS_magicrev (RCSNode *rcs, char *rev); -int RCS_isbranch (char *file, char *rev, List *srcfiles); -char *RCS_whatbranch (char *file, char *tag, List *srcfiles); -char *RCS_head (RCSNode * rcs); -int RCS_datecmp (char *date1, char *date2); -time_t RCS_getrevtime (RCSNode * rcs, char *rev, char *date, int fudge); -void RCS_check_tag (char *tag); -void freercsnode (RCSNode ** rnodep); -# 102 "/usr/src/gnu/cvs/mkmodules/../cvs/rcs.h" - -# 9 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../lib/regex.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -typedef unsigned reg_syntax_t; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -extern reg_syntax_t obscure_syntax; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -typedef enum -{ - REG_NOERROR = 0, - REG_NOMATCH, - - - - REG_BADPAT, - REG_ECOLLATE, - REG_ECTYPE, - REG_EESCAPE, - REG_ESUBREG, - REG_EBRACK, - REG_EPAREN, - REG_EBRACE, - REG_BADBR, - REG_ERANGE, - REG_ESPACE, - REG_BADRPT, - - - REG_EEND, - REG_ESIZE, - REG_ERPAREN -} reg_errcode_t; - - - - - - - - - - -struct re_pattern_buffer -{ - - - - - unsigned char *buffer; - - - unsigned long allocated; - - - unsigned long used; - - - reg_syntax_t syntax; - - - - - char *fastmap; - - - - - - char *translate; - - - size_t re_nsub; - - - - - - - unsigned can_be_null : 2; - - - - unsigned fastmap_accurate : 1; - - - - unsigned no_sub : 1; - - - - unsigned not_bol : 1; - - - unsigned not_eol : 1; - - - unsigned newline_anchor : 1; - - - - - unsigned caller_allocated_regs : 1; - -}; - -typedef struct re_pattern_buffer regex_t; - - - - - - - - - - - -typedef int regoff_t; - - - - -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - - - - - - - - - - - -typedef struct -{ - regoff_t rm_so; - regoff_t rm_eo; -} regmatch_t; - - - - - - - - - - -extern reg_syntax_t re_set_syntax (reg_syntax_t syntax); - - - - -extern const char *re_compile_pattern (const char *pattern, int length, - struct re_pattern_buffer *buffer); - - - - - -extern int re_compile_fastmap (struct re_pattern_buffer *buffer); - - - - - - - -extern int re_search (struct re_pattern_buffer *buffer, - const char *string, int length, - int start, int range, - struct re_registers *regs); - - - - -extern int re_search_2 (struct re_pattern_buffer *buffer, - const char *string1, int length1, - const char *string2, int length2, - int start, int range, - struct re_registers *regs, - int stop); - - - - -extern int re_match (const struct re_pattern_buffer *buffer, - const char *string, int length, - int start, struct re_registers *regs); - - - -extern int re_match_2 (const struct re_pattern_buffer *buffer, - const char *string1, int length1, - const char *string2, int length2, - int start, - struct re_registers *regs, - int stop); - - - - - - - - - - - -extern int regcomp (regex_t *preg, const char *pattern, int cflags); -extern int regexec (const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags); -extern size_t regerror (int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size); -extern void regfree (regex_t *preg); - -# 468 "/usr/src/gnu/cvs/mkmodules/../lib/regex.h" - - - - - - - - - - - - -# 10 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../lib/fnmatch.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -extern int fnmatch (const char *pattern, const char *string, int flags); - - - - - -# 11 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../lib/getopt.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - -extern char *optarg; - - - - - - - - - - - - - -extern int optind; - - - - -extern int opterr; - - - - - - - - - - - - - - - - - - - - - -struct option -{ - char *name; - int has_arg; - int *flag; - int val; -}; - - -extern const struct option *_getopt_long_options; - - - - - - - -extern int _getopt_long_only; - - - - - -extern int option_index; - - -int gnu_getopt (int argc, char **argv, const char *shortopts); -int gnu_getopt_long (int argc, char **argv, const char *shortopts, - const struct option *longopts, int *longind); -int gnu_getopt_long_only (int argc, char **argv, const char *shortopts, - const struct option *longopts, int *longind); - - - - - -# 12 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../lib/wait.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 13 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - -# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/config.h" 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -extern void exit (); - - - -extern char *getwd (); - - - - - - - - - - - - - - - -# 14 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - - -# 1 "/usr/src/gnu/cvs/mkmodules/../cvs/myndbm.h" 1 - - - - - - -typedef struct -{ - List *dbm_list; - Node *dbm_next; -} DBM; - -typedef struct -{ - char *dptr; - int dsize; -} datum; - - - - - - - - - - - - - -DBM *mydbm_open (char *file, int flags, int mode); -void mydbm_close (DBM * db); -datum mydbm_fetch (DBM * db, datum key); -datum mydbm_firstkey (DBM * db); -datum mydbm_nextkey (DBM * db); - - - - - - - - - -# 16 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -enum mtype -{ - CHECKOUT, TAG, PATCH -}; - - - - - - -enum classify_type -{ - T_UNKNOWN = 1, - T_CONFLICT, - T_NEEDS_MERGE, - T_MODIFIED, - T_CHECKOUT, - T_ADDED, - T_REMOVED, - T_REMOVE_ENTRY, - T_UPTODATE, - T_TITLE -}; -typedef enum classify_type Ctype; - - - - - - - - -struct vers_ts -{ - char *vn_user; - - - - - - char *vn_rcs; - - char *ts_user; - char *ts_rcs; - char *options; - - char *tag; - char *date; - Entnode *entdata; - RCSNode *srcfile; -}; -typedef struct vers_ts Vers_TS; - - - - - -struct stickydirtag -{ - int aflag; - char *tag; - char *date; - char *options; -}; - - - - - - - - - - - - - - - - -enum direnter_type -{ - R_PROCESS = 1, - R_SKIP_FILES, - R_SKIP_DIRS, - R_SKIP_ALL -}; -typedef enum direnter_type Dtype; - -extern char *program_name, *command_name; -extern char *Rcsbin, *Editor, *CVSroot; -extern char *CurDir; -extern int really_quiet, quiet; -extern int use_editor; -extern int cvswrite; - -extern int trace; -extern int noexec; -extern int logoff; - - - -int Reader_Lock (char *xrepository); -DBM *open_module (void); -FILE *Fopen (char *name, char *mode); -FILE *open_file (char *name, char *mode); -List *Find_Dirs (char *repository, int which); -List *ParseEntries (int aflag); -char *Make_Date (char *rawdate); -char *Name_Repository (char *dir, char *update_dir); -char *Short_Repository (char *repository); -char *getcaller (void); -char *time_stamp (char *file); -char *xmalloc (int bytes); -char *xrealloc (char *ptr, int bytes); -char *xstrdup (char *str); -int No_Difference (char *file, Vers_TS * vers, List * entries); -int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all); -int Reader_Lock (char *xrepository); -int SIG_register (int sig, void (*fn) ()); -int Writer_Lock (List * list); -int gethostname (char *name, int namelen); -int ign_name (char *name); -int isdir (char *file); -int isfile (char *file); -int islink (char *file); -int isreadable (char *file); -int iswritable (char *file); -int link_file (char *from, char *to); -int numdots (char *s); -int run_exec (char *stin, char *stout, char *sterr, int flags); -int unlink_file (char *f); -int update (int argc, char *argv[]); -int xcmp (char *file1, char *file2); -int yesno (void); -time_t get_date (char *date, struct timeb *now); -void Create_Admin (char *dir, char *repository, char *tag, char *date); -void Lock_Cleanup (void); -void ParseTag (char **tagp, char **datep); -void Scratch_Entry (List * list, char *fname); -void WriteTag (char *dir, char *tag, char *date); -void cat_module (int status); -void check_entries (char *dir); -void close_module (DBM * db); -void copy_file (char *from, char *to); -void error (int status, int errnum, char *message,...); -void fperror (FILE * fp, int status, int errnum, char *message,...); -void free_names (int *pargc, char *argv[]); -void freevers_ts (Vers_TS ** versp); -void ign_add (char *ign, int hold); -void ign_add_file (char *file, int hold); -void ign_setup (void); -void line2argv (int *pargc, char *argv[], char *line); -void make_directories (char *name); -void make_directory (char *name); -void rename_file (char *from, char *to); -void run_arg (char *s); -void run_args (char *fmt,...); -void run_print (FILE * fp); -void run_setup (char *fmt,...); -void strip_path (char *path); -void update_delproc (Node * p); -void usage (char **cpp); -void xchmod (char *fname, int writable); -int Checkin (int type, char *file, char *repository, char *rcs, char *rev, - char *tag, char *message, List * entries); -Ctype Classify_File (char *file, char *tag, char *date, char *options, - int force_tag_match, int aflag, char *repository, - List *entries, List *srcfiles, Vers_TS **versp); -List *Find_Names (char *repository, int which, int aflag, - List ** optentries); -void Register (List * list, char *fname, char *vn, char *ts, - char *options, char *tag, char *date); -void Update_Logfile (char *repository, char *xmessage, char *xrevision, - FILE * xlogfp, List * xchanges); -Vers_TS *Version_TS (char *repository, char *options, char *tag, - char *date, char *user, int force_tag_match, - int set_time, List * entries, List * xfiles); -void do_editor (char *dir, char *message, char *repository, - List * changes); -int do_module (DBM * db, char *mname, enum mtype m_type, char *msg, - int (*callback_proc) (), char *where, int shorten, - int local_specified, int run_module_prog, char *extra_arg); -int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (), - Dtype (*xdirentproc) (), int (*xdirleaveproc) (), - Dtype xflags, int xwhich, int xaflag, int xreadlock, - int xdosrcs); -int do_update (int argc, char *argv[], char *xoptions, char *xtag, - char *xdate, int xforce, int local, int xbuild, - int xaflag, int xprune, int xpipeout, int which, - char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir); -void history_write (int type, char *update_dir, char *revs, char *name, - char *repository); -int start_recursion (int (*fileproc) (), int (*filesdoneproc) (), - Dtype (*direntproc) (), int (*dirleaveproc) (), - int argc, char *argv[], int local, int which, - int aflag, int readlock, char *update_preload, - int dosrcs); -void SIG_beginCrSect (); -void SIG_endCrSect (); -# 438 "/usr/src/gnu/cvs/mkmodules/../cvs/cvs.h" - -# 15 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" 2 - - - - - - -PATH_MAX +2 - - -static char rcsid[] = "@(#)mkmodules.c 1.39 92/03/31"; - - - - - - -char *program_name, *command_name; - -char *Rcsbin = "" ; -int noexec = 0; -int trace = 0; - - -static int checkout_file (char *file, char *temp); -static void make_tempfile (char *temp); -static void mkmodules_usage (void); -static void rename_rcsfile (char *temp, char *real); - - - - - - -# 60 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" - - -int -main (argc, argv) - int argc; - char *argv[]; -{ - extern char *getenv (); - char temp[PATH_MAX +2 ]; - char *cp; - - DBM *db; - - - - - - if ((program_name = rindex (argv[0], '/')) == 0 ) - program_name = argv[0]; - else - program_name++; - - if (argc != 2) - mkmodules_usage (); - - if ((cp = getenv ("RCSBIN" )) != 0 ) - Rcsbin = cp; - - - - - - if (Rcsbin[0] != '\0') - { - int len = strlen (Rcsbin); - char *rcsbin; - - if (Rcsbin[len - 1] != '/') - { - rcsbin = Rcsbin; - Rcsbin = xmalloc (len + 2); - (void) strcpy (Rcsbin, rcsbin); - (void) strcat (Rcsbin, "/"); - } - } - - if (chdir (argv[1]) < 0) - error (1, errno, "cannot chdir to %s", argv[1]); - - - - - make_tempfile (temp); - switch (checkout_file ("modules" , temp)) - { - - case 0: - - - if ((db = mydbm_open (temp, 0x0000 , 0666)) != 0 ) - mydbm_close (db); - - - - - rename_rcsfile (temp, "modules" ); - break; - - case -1: - (void) unlink_file (temp); - exit (1); - - - default: - error (0, 0, - "'cvs checkout' is less functional without a %s file", - "modules" ); - break; - } - - (void) unlink_file (temp); - - - - - - make_tempfile (temp); - if (checkout_file ("loginfo" , temp) == 0) - rename_rcsfile (temp, "loginfo" ); - else - error (0, 0, - "no logging of 'cvs commit' messages is done without a %s file", - "loginfo" ); - (void) unlink_file (temp); - - - - - - make_tempfile (temp); - if (checkout_file ("rcsinfo" , temp) == 0) - rename_rcsfile (temp, "rcsinfo" ); - else - error (0, 0, - "a %s file can be used to configure 'cvs commit' templates", - "rcsinfo" ); - (void) unlink_file (temp); - - - - - - make_tempfile (temp); - if (checkout_file ("editinfo" , temp) == 0) - rename_rcsfile (temp, "editinfo" ); - else - error (0, 0, - "a %s file can be used to validate log messages", - "editinfo" ); - (void) unlink_file (temp); - - - - - - make_tempfile (temp); - if (checkout_file ("commitinfo" , temp) == 0) - rename_rcsfile (temp, "commitinfo" ); - else - error (0, 0, - "a %s file can be used to configure 'cvs commit' checking", - "commitinfo" ); - (void) unlink_file (temp); - return (0); -} - - - - -static void -make_tempfile (temp) - char *temp; -{ - static int seed = 0; - int fd; - - if (seed == 0) - seed = getpid (); - while (1) - { - (void) sprintf (temp, "%s%d", ".#" , seed++); - if ((fd = open (temp, 0x0200 | 0x0800 | 0x0002 , 0666)) != -1) - break; - if (errno != 17 ) - error (1, errno, "cannot create temporary file %s", temp); - } - if (close(fd) < 0) - error(1, errno, "cannot close temporary file %s", temp); -} - -static int -checkout_file (file, temp) - char *file; - char *temp; -{ - char rcs[PATH_MAX +2 ]; - int retcode = 0; - - (void) sprintf (rcs, "%s%s", file, ",v" ); - if (!isfile (rcs)) - return (1); - run_setup ("%s%s -q -p", Rcsbin, "co" ); - run_arg (rcs); - if ((retcode = run_exec ( (char *)0 , temp, (char *)0 , 0x0000 )) != 0) - { - error (0, retcode == -1 ? errno : 0, "failed to check out %s file", file); - } - return (retcode); -} - -# 369 "/usr/src/gnu/cvs/mkmodules/mkmodules.c" - - -static void -rename_rcsfile (temp, real) - char *temp; - char *real; -{ - char bak[50]; - - if (chmod (temp, 0444) < 0) - error (0, errno, "warning: cannot chmod %s", temp); - (void) sprintf (bak, "%s%s", ".#" , real); - (void) unlink_file (bak); - (void) rename (real, bak); - (void) rename (temp, real); -} - - - - -void -Lock_Cleanup () -{ -} - -static void -mkmodules_usage () -{ - (void) fprintf ((&__sF[2]) , "Usage: %s modules-directory\n", program_name); - exit (1); -} diff --git a/gnu/usr.bin/dc/dc.info b/gnu/usr.bin/dc/dc.info deleted file mode 100644 index a30fea9f5555..000000000000 --- a/gnu/usr.bin/dc/dc.info +++ /dev/null @@ -1,330 +0,0 @@ -This is Info file dc.info, produced by Makeinfo-1.52 from the input -file dc.texinfo. - - This file documents DC, an arbitrary precision calculator. - - Published by the Free Software Foundation, 675 Massachusetts Avenue, -Cambridge, MA 02139 USA - - Copyright (C) 1984 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: dc.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) - -* Menu: - -* Introduction:: Introduction -* Printing Commands:: Printing Commands -* Arithmetic:: Arithmetic -* Stack Control:: Stack Control -* Registers:: Registers -* Parameters:: Parameters -* Strings:: Strings -* Status Inquiry:: Status Inquiry -* Notes:: Notes - - -File: dc.info, Node: Introduction, Next: Printing Commands, Prev: Top, Up: Top - -Introduction -************ - - DC is a reverse-polish desk calculator which supports unlimited -precision arithmetic. It also allows you to define and call macros. -Normally DC reads from the standard input; if any command arguments are -given to it, they are filenames, and DC reads and executes the contents -of the files before reading from standard input. All output is to -standard output. - - To exit, use `q'. `C-c' does not exit; it is used to abort macros -that are looping, etc. (Currently this is not true; `C-c' does exit.) - - A reverse-polish calculator stores numbers on a stack. Entering a -number pushes it on the stack. Arithmetic operations pop arguments off -the stack and push the results. - - To enter a number in DC, type the digits, with an optional decimal -point. Exponential notation is not supported. To enter a negative -number, begin the number with `_'. `-' cannot be used for this, as it -is a binary operator for subtraction instead. To enter two numbers in -succession, separate them with spaces or newlines. These have no -meaning as commands. - - -File: dc.info, Node: Printing Commands, Next: Arithmetic, Prev: Introduction, Up: Top - -Printing Commands -***************** - -`p' - Prints the value on the top of the stack, without altering the - stack. A newline is printed after the value. - -`P' - Prints the value on the top of the stack, popping it off, and does - not print a newline after. - -`f' - Prints the entire contents of the stack and the contents of all of - the registers, without altering anything. This is a good command - to use if you are lost or want to figure out what the effect of - some command has been. - - -File: dc.info, Node: Arithmetic, Next: Stack Control, Prev: Printing Commands, Up: Top - -Arithmetic -********** - -`+' - Pops two values off the stack, adds them, and pushes the result. - The precision of the result is determined only by the values of - the arguments, and is enough to be exact. - -`-' - Pops two values, subtracts the first one popped from the second - one popped, and pushes the result. - -`*' - Pops two values, multiplies them, and pushes the result. The - number of fraction digits in the result is controlled by the - current precision flag (see below) and does not depend on the - values being multiplied. - -`/' - Pops two values, divides the second one popped from the first one - popped, and pushes the result. The number of fraction digits is - specified by the precision flag. - -`%' - Pops two values, computes the remainder of the division that the - `/' command would do, and pushes that. The division is done with - as many fraction digits as the precision flag specifies, and the - remainder is also computed with that many fraction digits. - -`^' - Pops two values and exponentiates, using the first value popped as - the exponent and the second popped as the base. The fraction part - of the exponent is ignored. The precision flag specifies the - number of fraction digits in the result. - -`v' - Pops one value, computes its square root, and pushes that. The - precision flag specifies the number of fraction digits in the - result. - - Most arithmetic operations are affected by the "precision flag", -which you can set with the `k' command. The default precision value is -zero, which means that all arithmetic except for addition and -subtraction produces integer results. - - The remainder operation (`%') requires some explanation: applied to -arguments `a' and `b' it produces `a - (b * (a / b))', where `a / b' is -computed in the current precision. - - -File: dc.info, Node: Stack Control, Next: Registers, Prev: Arithmetic, Up: Top - -Stack Control -************* - -`c' - Clears the stack, rendering it empty. - -`d' - Duplicates the value on the top of the stack, pushing another copy - of it. Thus, `4d*p' computes 4 squared and prints it. - - -File: dc.info, Node: Registers, Next: Parameters, Prev: Stack Control, Up: Top - -Registers -********* - - DC provides 128 memory registers, each named by a single ASCII -character. You can store a number in a register and retrieve it later. - -`sR' - Pop the value off the top of the stack and store it into register - R. - -`lR' - Copy the value in register R, and push it onto the stack. This - does not alter the contents of R. - - Each register also contains its own stack. The current register - value is the top of the register's stack. - -`SR' - Pop the value off the top of the (main) stack and push it onto the - stack of register R. The previous value of the register becomes - inaccessible. - -`LR' - Pop the value off the top of register R's stack and push it onto - the main stack. The previous value in register R's stack, if any, - is now accessible via the `lR' command. - - The `f' command prints a list of all registers that have contents -stored in them, together with their contents. Only the current -contents of each register (the top of its stack) is printed. - - -File: dc.info, Node: Parameters, Next: Strings, Prev: Registers, Up: Top - -Parameters -********** - - DC has three parameters that control its operation: the precision, -the input radix, and the output radix. The precision specifies the -number of fraction digits to keep in the result of most arithmetic -operations. The input radix controls the interpretation of numbers -typed in; *all* numbers typed in use this radix. The output radix is -used for printing numbers. - - The input and output radices are separate parameters; you can make -them unequal, which can be useful or confusing. Each radix must be -between 2 and 36 inclusive. The precision must be zero or greater. -The precision is always measured in decimal digits, regardless of the -current input or output radix. - -`i' - Pops the value off the top of the stack and uses it to set the - input radix. - -`o' -`k' - Similarly set the output radix and the precision. - -`I' - Pushes the current input radix on the stack. - -`O' -`K' - Similarly push the current output radix and the current precision. - - -File: dc.info, Node: Strings, Next: Status Inquiry, Prev: Parameters, Up: Top - -Strings -******* - - DC can operate on strings as well as on numbers. The only things you -can do with strings are print them and execute them as macros (which -means that the contents of the string are processed as DC commands). -Both registers and the stack can hold strings, and DC always knows -whether any given object is a string or a number. Some commands such as -arithmetic operations demand numbers as arguments and print errors if -given strings. Other commands can accept either a number or a string; -for example, the `p' command can accept either and prints the object -according to its type. - -`[CHARACTERS]' - Makes a string containing CHARACTERS and pushes it on the stack. - For example, `[foo]P' prints the characters `foo' (with no - newline). - -`x' - Pops a value off the stack and executes it as a macro. Normally - it should be a string; if it is a number, it is simply pushed back - onto the stack. For example, `[1p]x' executes the macro `1p', - which pushes 1 on the stack and prints `1' on a separate line. - - Macros are most often stored in registers; `[1p]sa' stores a macro - to print `1' into register `a', and `lax' invokes the macro. - -`>R' - Pops two values off the stack and compares them assuming they are - numbers, executing the contents of register R as a macro if the - original top-of-stack is greater. Thus, `1 2>a' will invoke - register `a''s contents and `2 1>a' will not. - -`@var{r} -Pops two values off the stack and compares them -assuming they are numbers, executing the contents -of register @var{r} as a macro if the original top-of-stack -is greater. Thus, @samp{1 2>a} will invoke register @samp{a}'s contents -and @samp{2 1>a} will not. - -@item <@var{r} -Similar but invokes the macro if the original top-of-stack -is less. - -@item =@var{r} -Similar but invokes the macro if the two numbers popped -are equal. This can also be validly used to compare two -strings for equality. - -@item ? -Reads a line from the terminal and executes it. -This command allows a macro to request input from the user. - -@item q -During the execution of a macro, this comand -does not exit DC. Instead, it exits from that -macro and also from the macro which invoked it (if any). - -@item Q -Pops a value off the stack and uses it as a count -of levels of macro execution to be exited. Thus, -@samp{3Q} exits three levels. -@end table - -@node Status Inquiry, Notes, Strings, Top -@chapter Status Inquiry - -@table @samp -@item Z -Pops a value off the stack, calculates the number of -digits it has (or number of characters, if it is a string) -and pushes that number. - -@item X -Pops a value off the stack, calculates the number of -fraction digits it has, and pushes that number. -For a string, the value pushed is -1. - -@item z -Pushes the current stack depth; the number of -objects on the stack before the execution of the @samp{z} command. - -@item I -Pushes the current value of the input radix. - -@item O -Pushes the current value of the output radix. - -@item K -Pushes the current value of the precision. -@end table - -@node Notes, , Status Inquiry, Top -@chapter Notes - -The @samp{:} and @samp{;} commands of the Unix DC program are -not supported, as the documentation does not say what they do. -The @samp{!} command is not supported, but will be supported -as soon as a library for executing a line as a command exists. - -@contents -@bye diff --git a/gnu/usr.bin/diff/fnmatch.h b/gnu/usr.bin/diff/fnmatch.h deleted file mode 100644 index 1a653ab6314b..000000000000 --- a/gnu/usr.bin/diff/fnmatch.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. - -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. - -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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _FNMATCH_H - -#define _FNMATCH_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) -#undef __P -#define __P(args) args -#else /* Not C++ or ANSI C. */ -#undef __P -#define __P(args) () -/* We can get away without defining `const' here only because in this file - it is used only inside the prototype for `fnmatch', which is elided in - non-ANSI C where `const' is problematical. */ -#endif /* C++ or ANSI C. */ - - -/* We #undef these before defining them because some losing systems - (HP-UX A.08.07 for example) define these in . */ -#undef FNM_PATHNAME -#undef FNM_NOESCAPE -#undef FNM_PERIOD - -/* Bits set in the FLAGS argument to `fnmatch'. */ -#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ - -#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) -#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ -#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ -#endif - -/* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 - -/* Match STRING against the filename pattern PATTERN, - returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch __P ((const char *__pattern, const char *__string, - int __flags)); - -#ifdef __cplusplus -} -#endif - -#endif /* fnmatch.h */ diff --git a/gnu/usr.bin/diff3/COPYING b/gnu/usr.bin/diff3/COPYING deleted file mode 100644 index a43ea2126fb6..000000000000 --- a/gnu/usr.bin/diff3/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/gnu/usr.bin/diff3/diff3.c b/gnu/usr.bin/diff3/diff3.c deleted file mode 100644 index b9952fc0a04f..000000000000 --- a/gnu/usr.bin/diff3/diff3.c +++ /dev/null @@ -1,1693 +0,0 @@ -/* Three way file comparison program (diff3) for Project GNU. - Copyright (C) 1988, 1989, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written by Randy Smith */ - -#if __STDC__ -#define VOID void -#else -#define VOID char -#endif - -#include -#include -#include "getopt.h" -#include "system.h" - -/* - * Internal data structures and macros for the diff3 program; includes - * data structures for both diff3 diffs and normal diffs. - */ - -/* Different files within a three way diff. */ -#define FILE0 0 -#define FILE1 1 -#define FILE2 2 - -/* - * A three way diff is built from two two-way diffs; the file which - * the two two-way diffs share is: - */ -#define FILEC FILE2 - -/* - * Different files within a two way diff. - * FC is the common file, FO the other file. - */ -#define FO 0 -#define FC 1 - -/* The ranges are indexed by */ -#define START 0 -#define END 1 - -enum diff_type { - ERROR, /* Should not be used */ - ADD, /* Two way diff add */ - CHANGE, /* Two way diff change */ - DELETE, /* Two way diff delete */ - DIFF_ALL, /* All three are different */ - DIFF_1ST, /* Only the first is different */ - DIFF_2ND, /* Only the second */ - DIFF_3RD /* Only the third */ -}; - -/* Two way diff */ -struct diff_block { - int ranges[2][2]; /* Ranges are inclusive */ - char **lines[2]; /* The actual lines (may contain nulls) */ - int *lengths[2]; /* Line lengths (including newlines, if any) */ - struct diff_block *next; -}; - -/* Three way diff */ - -struct diff3_block { - enum diff_type correspond; /* Type of diff */ - int ranges[3][2]; /* Ranges are inclusive */ - char **lines[3]; /* The actual lines (may contain nulls) */ - int *lengths[3]; /* Line lengths (including newlines, if any) */ - struct diff3_block *next; -}; - -/* - * Access the ranges on a diff block. - */ -#define D_LOWLINE(diff, filenum) \ - ((diff)->ranges[filenum][START]) -#define D_HIGHLINE(diff, filenum) \ - ((diff)->ranges[filenum][END]) -#define D_NUMLINES(diff, filenum) \ - (D_HIGHLINE (diff, filenum) - D_LOWLINE (diff, filenum) + 1) - -/* - * Access the line numbers in a file in a diff by relative line - * numbers (i.e. line number within the diff itself). Note that these - * are lvalues and can be used for assignment. - */ -#define D_RELNUM(diff, filenum, linenum) \ - ((diff)->lines[filenum][linenum]) -#define D_RELLEN(diff, filenum, linenum) \ - ((diff)->lengths[filenum][linenum]) - -/* - * And get at them directly, when that should be necessary. - */ -#define D_LINEARRAY(diff, filenum) \ - ((diff)->lines[filenum]) -#define D_LENARRAY(diff, filenum) \ - ((diff)->lengths[filenum]) - -/* - * Next block. - */ -#define D_NEXT(diff) ((diff)->next) - -/* - * Access the type of a diff3 block. - */ -#define D3_TYPE(diff) ((diff)->correspond) - -/* - * Line mappings based on diffs. The first maps off the top of the - * diff, the second off of the bottom. - */ -#define D_HIGH_MAPLINE(diff, fromfile, tofile, lineno) \ - ((lineno) \ - - D_HIGHLINE ((diff), (fromfile)) \ - + D_HIGHLINE ((diff), (tofile))) - -#define D_LOW_MAPLINE(diff, fromfile, tofile, lineno) \ - ((lineno) \ - - D_LOWLINE ((diff), (fromfile)) \ - + D_LOWLINE ((diff), (tofile))) - -/* - * General memory allocation function. - */ -#define ALLOCATE(number, type) \ - (type *) xmalloc ((number) * sizeof (type)) - -/* Options variables for flags set on command line. */ - -/* If nonzero, treat all files as text files, never as binary. */ -static int always_text; - -/* If nonzero, write out an ed script instead of the standard diff3 format. */ -static int edscript; - -/* If nonzero, in the case of overlapping diffs (type DIFF_ALL), - preserve the lines which would normally be deleted from - file 1 with a special flagging mechanism. */ -static int flagging; - -/* Number of lines to keep in identical prefix and suffix. */ -static int horizon_lines = 10; - -/* If nonzero, do not output information for overlapping diffs. */ -static int simple_only; - -/* If nonzero, do not output information for non-overlapping diffs. */ -static int overlap_only; - -/* If nonzero, show information for DIFF_2ND diffs. */ -static int show_2nd; - -/* If nonzero, include `:wq' at the end of the script - to write out the file being edited. */ -static int finalwrite; - -/* If nonzero, output a merged file. */ -static int merge; - -static char *argv0; - -/* - * Forward function declarations. - */ -static int myread (); -static void fatal (); -static void perror_with_exit (); -static struct diff_block *process_diff (); -static struct diff3_block *make_3way_diff (); -static void output_diff3 (); -static int output_diff3_edscript (); -static int output_diff3_merge (); -static void usage (); - -static struct diff3_block *using_to_diff3_block (); -static int copy_stringlist (); -static struct diff3_block *create_diff3_block (); -static int compare_line_list (); - -static char *read_diff (); -static enum diff_type process_diff_control (); -static char *scan_diff_line (); - -static struct diff3_block *reverse_diff3_blocklist (); - -VOID *xmalloc (); -static VOID *xrealloc (); - -static char diff_program[] = DIFF_PROGRAM; - -static struct option longopts[] = -{ - {"text", 0, NULL, 'a'}, - {"show-all", 0, NULL, 'A'}, - {"ed", 0, NULL, 'e'}, - {"show-overlap", 0, NULL, 'E'}, - {"label", 1, NULL, 'L'}, - {"merge", 0, NULL, 'm'}, - {"overlap-only", 0, NULL, 'x'}, - {"easy-only", 0, NULL, '3'}, - {"version", 0, NULL, 'v'}, - {0, 0, 0, 0} -}; - -/* - * Main program. Calls diff twice on two pairs of input files, - * combines the two diffs, and outputs them. - */ -int -main (argc, argv) - int argc; - char **argv; -{ - extern char *version_string; - int c, i; - int mapping[3]; - int rev_mapping[3]; - int incompat; - int conflicts_found; - struct diff_block *thread0, *thread1, *last_block; - struct diff3_block *diff3; - int tag_count = 0; - char *tag_strings[3]; - extern char *optarg; - char *commonname; - char **file; - struct stat statb; - - incompat = 0; - - argv0 = argv[0]; - - while ((c = getopt_long (argc, argv, "aeimvx3AEXL:", longopts, (int *) 0)) - != EOF) - { - switch (c) - { - case 'a': - always_text = 1; - break; - case 'A': - show_2nd = 1; - flagging = 1; - incompat++; - break; - case 'x': - overlap_only = 1; - incompat++; - break; - case '3': - simple_only = 1; - incompat++; - break; - case 'i': - finalwrite = 1; - break; - case 'm': - merge = 1; - break; - case 'X': - overlap_only = 1; - /* Falls through */ - case 'E': - flagging = 1; - /* Falls through */ - case 'e': - incompat++; - break; - case 'v': - fprintf (stderr, "GNU diff3 version %s\n", version_string); - break; - case 'L': - /* Handle up to three -L options. */ - if (tag_count < 3) - { - tag_strings[tag_count++] = optarg; - break; - } - /* Falls through */ - default: - usage (); - /* NOTREACHED */ - } - } - - edscript = incompat & ~merge; /* -AeExX3 without -m implies ed script. */ - show_2nd |= ~incompat & merge; /* -m without -AeExX3 implies -A. */ - flagging |= ~incompat & merge; - - if (incompat > 1 /* Ensure at most one of -AeExX3. */ - || finalwrite & merge /* -i -m would rewrite input file. */ - || (tag_count && ! flagging) /* -L requires one of -AEX. */ - || argc - optind != 3) - usage (); - - file = &argv[optind]; - - for (i = tag_count; i < 3; i++) - tag_strings[i] = file[i]; - - /* Always compare file1 to file2, even if file2 is "-". - This is needed for -mAeExX3. Using the file0 as - the common file would produce wrong results, because if the - file0-file1 diffs didn't line up with the file0-file2 diffs - (which is entirely possible since we don't use diff's -n option), - diff3 might report phantom changes from file1 to file2. */ - - if (strcmp (file[2], "-") == 0) - { - /* Sigh. We've got standard input as the last arg. We can't - call diff twice on stdin. Use the middle arg as the common - file instead. */ - if (strcmp (file[0], "-") == 0 || strcmp (file[1], "-") == 0) - fatal ("`-' specified for more than one input file"); - mapping[0] = 0; - mapping[1] = 2; - mapping[2] = 1; - } - else - { - /* Normal, what you'd expect */ - mapping[0] = 0; - mapping[1] = 1; - mapping[2] = 2; - } - - for (i = 0; i < 3; i++) - rev_mapping[mapping[i]] = i; - - for (i = 0; i < 3; i++) - if (strcmp (file[i], "-") != 0) - if (stat (file[i], &statb) < 0) - perror_with_exit (file[i]); - else if (S_ISDIR(statb.st_mode)) - { - fprintf (stderr, "%s: %s: Is a directory\n", argv0, file[i]); - exit (2); - } - - - commonname = file[rev_mapping[FILEC]]; - thread1 = process_diff (file[rev_mapping[FILE1]], commonname, &last_block); - if (thread1) - for (i = 0; i < 2; i++) - { - horizon_lines = max (horizon_lines, D_NUMLINES (thread1, i)); - horizon_lines = max (horizon_lines, D_NUMLINES (last_block, i)); - } - thread0 = process_diff (file[rev_mapping[FILE0]], commonname, &last_block); - diff3 = make_3way_diff (thread0, thread1); - if (edscript) - conflicts_found - = output_diff3_edscript (stdout, diff3, mapping, rev_mapping, - tag_strings[0], tag_strings[1], tag_strings[2]); - else if (merge) - { - if (! freopen (file[rev_mapping[FILE0]], "r", stdin)) - perror_with_exit (file[rev_mapping[FILE0]]); - conflicts_found - = output_diff3_merge (stdin, stdout, diff3, mapping, rev_mapping, - tag_strings[0], tag_strings[1], tag_strings[2]); - if (ferror (stdin)) - fatal ("read error"); - } - else - { - output_diff3 (stdout, diff3, mapping, rev_mapping); - conflicts_found = 0; - } - - if (ferror (stdout) || fclose (stdout) != 0) - fatal ("write error"); - exit (conflicts_found); - return conflicts_found; -} - -/* - * Explain, patiently and kindly, how to use this program. Then exit. - */ -static void -usage () -{ - fprintf (stderr, "\ -Usage: %s [options] my-file older-file your-file\n\ -Options:\n\ - [-exAEX3v] [-i|-m] [-L label1 [-L label2 [-L label3]]] [--text] [--ed]\n\ - [--merge] [--show-all] [--show-overlap] [--overlap-only] [--easy-only]\n\ - [--label=label1 [--label=label2 [--label=label3]]] [--version]\n\ - Only one of [exAEX3] is allowed\n", argv0); - exit (2); -} - -/* - * Routines that combine the two diffs together into one. The - * algorithm used follows: - * - * File2 is shared in common between the two diffs. - * Diff02 is the diff between 0 and 2. - * Diff12 is the diff between 1 and 2. - * - * 1) Find the range for the first block in File2. - * a) Take the lowest of the two ranges (in File2) in the two - * current blocks (one from each diff) as being the low - * water mark. Assign the upper end of this block as - * being the high water mark and move the current block up - * one. Mark the block just moved over as to be used. - * b) Check the next block in the diff that the high water - * mark is *not* from. - * - * *If* the high water mark is above - * the low end of the range in that block, - * - * mark that block as to be used and move the current - * block up. Set the high water mark to the max of - * the high end of this block and the current. Repeat b. - * - * 2) Find the corresponding ranges in File0 (from the blocks - * in diff02; line per line outside of diffs) and in File1. - * Create a diff3_block, reserving space as indicated by the ranges. - * - * 3) Copy all of the pointers for file2 in. At least for now, - * do bcmp's between corresponding strings in the two diffs. - * - * 4) Copy all of the pointers for file0 and 1 in. Get what you - * need from file2 (when there isn't a diff block, it's - * identical to file2 within the range between diff blocks). - * - * 5) If the diff blocks you used came from only one of the two - * strings of diffs, then that file (i.e. the one other than - * the common file in that diff) is the odd person out. If you used - * diff blocks from both sets, check to see if files 0 and 1 match: - * - * Same number of lines? If so, do a set of bcmp's (if a - * bcmp matches; copy the pointer over; it'll be easier later - * if you have to do any compares). If they match, 0 & 1 are - * the same. If not, all three different. - * - * Then you do it again, until you run out of blocks. - * - */ - -/* - * This routine makes a three way diff (chain of diff3_block's) from two - * two way diffs (chains of diff_block's). It is assumed that each of - * the two diffs passed are onto the same file (i.e. that each of the - * diffs were made "to" the same file). The three way diff pointer - * returned will have numbering FILE0--the other file in diff02, - * FILE1--the other file in diff12, and FILEC--the common file. - */ -static struct diff3_block * -make_3way_diff (thread0, thread1) - struct diff_block *thread0, *thread1; -{ -/* - * This routine works on the two diffs passed to it as threads. - * Thread number 0 is diff02, thread number 1 is diff12. The USING - * array is set to the base of the list of blocks to be used to - * construct each block of the three way diff; if no blocks from a - * particular thread are to be used, that element of the using array - * is set to 0. The elements LAST_USING array are set to the last - * elements on each of the using lists. - * - * The HIGH_WATER_MARK is set to the highest line number in the common file - * described in any of the diffs in either of the USING lists. The - * HIGH_WATER_THREAD names the thread. Similarly the BASE_WATER_MARK - * and BASE_WATER_THREAD describe the lowest line number in the common file - * described in any of the diffs in either of the USING lists. The - * HIGH_WATER_DIFF is the diff from which the HIGH_WATER_MARK was - * taken. - * - * The HIGH_WATER_DIFF should always be equal to LAST_USING - * [HIGH_WATER_THREAD]. The OTHER_DIFF is the next diff to check for - * higher water, and should always be equal to - * CURRENT[HIGH_WATER_THREAD ^ 0x1]. The OTHER_THREAD is the thread - * in which the OTHER_DIFF is, and hence should always be equal to - * HIGH_WATER_THREAD ^ 0x1. - * - * The variable LAST_DIFF is kept set to the last diff block produced - * by this routine, for line correspondence purposes between that diff - * and the one currently being worked on. It is initialized to - * ZERO_DIFF before any blocks have been created. - */ - - struct diff_block - *using[2], - *last_using[2], - *current[2]; - - int - high_water_mark; - - int - high_water_thread, - base_water_thread, - other_thread; - - struct diff_block - *high_water_diff, - *other_diff; - - struct diff3_block - *result, - *tmpblock, - **result_end, - *last_diff3; - - static struct diff3_block zero_diff3 = { - ERROR, - { {0, 0}, {0, 0}, {0, 0} }, - { (char **) 0, (char **) 0, (char **) 0 }, - { (int *) 0, (int *) 0, (int *) 0 }, - (struct diff3_block *) 0 - }; - - /* Initialization */ - result = 0; - result_end = &result; - current[0] = thread0; current[1] = thread1; - last_diff3 = &zero_diff3; - - /* Sniff up the threads until we reach the end */ - - while (current[0] || current[1]) - { - using[0] = using[1] = last_using[0] = last_using[1] = - (struct diff_block *) 0; - - /* Setup low and high water threads, diffs, and marks. */ - if (!current[0]) - base_water_thread = 1; - else if (!current[1]) - base_water_thread = 0; - else - base_water_thread = - (D_LOWLINE (current[0], FC) > D_LOWLINE (current[1], FC)); - - high_water_thread = base_water_thread; - - high_water_diff = current[high_water_thread]; - -#if 0 - /* low and high waters start off same diff */ - base_water_mark = D_LOWLINE (high_water_diff, FC); -#endif - - high_water_mark = D_HIGHLINE (high_water_diff, FC); - - /* Make the diff you just got info from into the using class */ - using[high_water_thread] - = last_using[high_water_thread] - = high_water_diff; - current[high_water_thread] = high_water_diff->next; - last_using[high_water_thread]->next - = (struct diff_block *) 0; - - /* And mark the other diff */ - other_thread = high_water_thread ^ 0x1; - other_diff = current[other_thread]; - - /* Shuffle up the ladder, checking the other diff to see if it - needs to be incorporated. */ - while (other_diff - && D_LOWLINE (other_diff, FC) <= high_water_mark + 1) - { - - /* Incorporate this diff into the using list. Note that - this doesn't take it off the current list */ - if (using[other_thread]) - last_using[other_thread]->next = other_diff; - else - using[other_thread] = other_diff; - last_using[other_thread] = other_diff; - - /* Take it off the current list. Note that this following - code assumes that other_diff enters it equal to - current[high_water_thread ^ 0x1] */ - current[other_thread] - = current[other_thread]->next; - other_diff->next - = (struct diff_block *) 0; - - /* Set the high_water stuff - If this comparison is equal, then this is the last pass - through this loop; since diff blocks within a given - thread cannot overlap, the high_water_mark will be - *below* the range_start of either of the next diffs. */ - - if (high_water_mark < D_HIGHLINE (other_diff, FC)) - { - high_water_thread ^= 1; - high_water_diff = other_diff; - high_water_mark = D_HIGHLINE (other_diff, FC); - } - - /* Set the other diff */ - other_thread = high_water_thread ^ 0x1; - other_diff = current[other_thread]; - } - - /* The using lists contain a list of all of the blocks to be - included in this diff3_block. Create it. */ - - tmpblock = using_to_diff3_block (using, last_using, - base_water_thread, high_water_thread, - last_diff3); - - if (!tmpblock) - fatal ("internal error: screwup in format of diff blocks"); - - /* Put it on the list. */ - *result_end = tmpblock; - result_end = &tmpblock->next; - - /* Set up corresponding lines correctly. */ - last_diff3 = tmpblock; - } - return result; -} - -/* - * using_to_diff3_block: - * This routine takes two lists of blocks (from two separate diff - * threads) and puts them together into one diff3 block. - * It then returns a pointer to this diff3 block or 0 for failure. - * - * All arguments besides using are for the convenience of the routine; - * they could be derived from the using array. - * LAST_USING is a pair of pointers to the last blocks in the using - * structure. - * LOW_THREAD and HIGH_THREAD tell which threads contain the lowest - * and highest line numbers for File0. - * last_diff3 contains the last diff produced in the calling routine. - * This is used for lines mappings which would still be identical to - * the state that diff ended in. - * - * A distinction should be made in this routine between the two diffs - * that are part of a normal two diff block, and the three diffs that - * are part of a diff3_block. - */ -static struct diff3_block * -using_to_diff3_block (using, last_using, low_thread, high_thread, last_diff3) - struct diff_block - *using[2], - *last_using[2]; - int low_thread, high_thread; - struct diff3_block *last_diff3; -{ - int low[2], high[2]; - struct diff3_block *result; - struct diff_block *ptr; - int d, i; - - /* Find the range in the common file. */ - int lowc = D_LOWLINE (using[low_thread], FC); - int highc = D_HIGHLINE (last_using[high_thread], FC); - - /* Find the ranges in the other files. - If using[d] is null, that means that the file to which that diff - refers is equivalent to the common file over this range. */ - - for (d = 0; d < 2; d++) - if (using[d]) - { - low[d] = D_LOW_MAPLINE (using[d], FC, FO, lowc); - high[d] = D_HIGH_MAPLINE (last_using[d], FC, FO, highc); - } - else - { - low[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, lowc); - high[d] = D_HIGH_MAPLINE (last_diff3, FILEC, FILE0 + d, highc); - } - - /* Create a block with the appropriate sizes */ - result = create_diff3_block (low[0], high[0], low[1], high[1], lowc, highc); - - /* Copy information for the common file. - Return with a zero if any of the compares failed. */ - - for (d = 0; d < 2; d++) - for (ptr = using[d]; ptr; ptr = D_NEXT (ptr)) - { - int result_offset = D_LOWLINE (ptr, FC) - lowc; - - if (!copy_stringlist (D_LINEARRAY (ptr, FC), - D_LENARRAY (ptr, FC), - D_LINEARRAY (result, FILEC) + result_offset, - D_LENARRAY (result, FILEC) + result_offset, - D_NUMLINES (ptr, FC))) - return 0; - } - - /* Copy information for file d. First deal with anything that might be - before the first diff. */ - - for (d = 0; d < 2; d++) - { - struct diff_block *u = using[d]; - int lo = low[d], hi = high[d]; - - for (i = 0; - i + lo < (u ? D_LOWLINE (u, FO) : hi + 1); - i++) - { - D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, i); - D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, i); - } - - for (ptr = u; ptr; ptr = D_NEXT (ptr)) - { - int result_offset = D_LOWLINE (ptr, FO) - lo; - int linec; - - if (!copy_stringlist (D_LINEARRAY (ptr, FO), - D_LENARRAY (ptr, FO), - D_LINEARRAY (result, FILE0 + d) + result_offset, - D_LENARRAY (result, FILE0 + d) + result_offset, - D_NUMLINES (ptr, FO))) - return 0; - - /* Catch the lines between here and the next diff */ - linec = D_HIGHLINE (ptr, FC) + 1 - lowc; - for (i = D_HIGHLINE (ptr, FO) + 1 - lo; - i < (D_NEXT (ptr) ? D_LOWLINE (D_NEXT (ptr), FO) : hi + 1) - lo; - i++) - { - D_RELNUM (result, FILE0 + d, i) = D_RELNUM (result, FILEC, linec); - D_RELLEN (result, FILE0 + d, i) = D_RELLEN (result, FILEC, linec); - linec++; - } - } - } - - /* Set correspond */ - if (!using[0]) - D3_TYPE (result) = DIFF_2ND; - else if (!using[1]) - D3_TYPE (result) = DIFF_1ST; - else - { - int nl0 = D_NUMLINES (result, FILE0); - int nl1 = D_NUMLINES (result, FILE1); - - if (nl0 != nl1 - || !compare_line_list (D_LINEARRAY (result, FILE0), - D_LENARRAY (result, FILE0), - D_LINEARRAY (result, FILE1), - D_LENARRAY (result, FILE1), - nl0)) - D3_TYPE (result) = DIFF_ALL; - else - D3_TYPE (result) = DIFF_3RD; - } - - return result; -} - -/* - * This routine copies pointers from a list of strings to a different list - * of strings. If a spot in the second list is already filled, it - * makes sure that it is filled with the same string; if not it - * returns 0, the copy incomplete. - * Upon successful completion of the copy, it returns 1. - */ -static int -copy_stringlist (fromptrs, fromlengths, toptrs, tolengths, copynum) - char *fromptrs[], *toptrs[]; - int *fromlengths, *tolengths; - int copynum; -{ - register char - **f = fromptrs, - **t = toptrs; - register int - *fl = fromlengths, - *tl = tolengths; - - while (copynum--) - { - if (*t) - { if (*fl != *tl || bcmp (*f, *t, *fl)) return 0; } - else - { *t = *f ; *tl = *fl; } - - t++; f++; tl++; fl++; - } - return 1; -} - -/* - * Create a diff3_block, with ranges as specified in the arguments. - * Allocate the arrays for the various pointers (and zero them) based - * on the arguments passed. Return the block as a result. - */ -static struct diff3_block * -create_diff3_block (low0, high0, low1, high1, low2, high2) - register int low0, high0, low1, high1, low2, high2; -{ - struct diff3_block *result = ALLOCATE (1, struct diff3_block); - int numlines; - - D3_TYPE (result) = ERROR; - D_NEXT (result) = 0; - - /* Assign ranges */ - D_LOWLINE (result, FILE0) = low0; - D_HIGHLINE (result, FILE0) = high0; - D_LOWLINE (result, FILE1) = low1; - D_HIGHLINE (result, FILE1) = high1; - D_LOWLINE (result, FILE2) = low2; - D_HIGHLINE (result, FILE2) = high2; - - /* Allocate and zero space */ - numlines = D_NUMLINES (result, FILE0); - if (numlines) - { - D_LINEARRAY (result, FILE0) = ALLOCATE (numlines, char *); - D_LENARRAY (result, FILE0) = ALLOCATE (numlines, int); - bzero (D_LINEARRAY (result, FILE0), (numlines * sizeof (char *))); - bzero (D_LENARRAY (result, FILE0), (numlines * sizeof (int))); - } - else - { - D_LINEARRAY (result, FILE0) = (char **) 0; - D_LENARRAY (result, FILE0) = (int *) 0; - } - - numlines = D_NUMLINES (result, FILE1); - if (numlines) - { - D_LINEARRAY (result, FILE1) = ALLOCATE (numlines, char *); - D_LENARRAY (result, FILE1) = ALLOCATE (numlines, int); - bzero (D_LINEARRAY (result, FILE1), (numlines * sizeof (char *))); - bzero (D_LENARRAY (result, FILE1), (numlines * sizeof (int))); - } - else - { - D_LINEARRAY (result, FILE1) = (char **) 0; - D_LENARRAY (result, FILE1) = (int *) 0; - } - - numlines = D_NUMLINES (result, FILE2); - if (numlines) - { - D_LINEARRAY (result, FILE2) = ALLOCATE (numlines, char *); - D_LENARRAY (result, FILE2) = ALLOCATE (numlines, int); - bzero (D_LINEARRAY (result, FILE2), (numlines * sizeof (char *))); - bzero (D_LENARRAY (result, FILE2), (numlines * sizeof (int))); - } - else - { - D_LINEARRAY (result, FILE2) = (char **) 0; - D_LENARRAY (result, FILE2) = (int *) 0; - } - - /* Return */ - return result; -} - -/* - * Compare two lists of lines of text. - * Return 1 if they are equivalent, 0 if not. - */ -static int -compare_line_list (list1, lengths1, list2, lengths2, nl) - char *list1[], *list2[]; - int *lengths1, *lengths2; - int nl; -{ - char - **l1 = list1, - **l2 = list2; - int - *lgths1 = lengths1, - *lgths2 = lengths2; - - while (nl--) - if (!*l1 || !*l2 || *lgths1 != *lgths2++ - || bcmp (*l1++, *l2++, *lgths1++)) - return 0; - return 1; -} - -/* - * Routines to input and parse two way diffs. - */ - -extern char **environ; - -#define DIFF_CHUNK_SIZE 10000 - -static struct diff_block * -process_diff (filea, fileb, last_block) - char *filea, *fileb; - struct diff_block **last_block; -{ - char *diff_contents; - char *diff_limit; - char *scan_diff; - enum diff_type dt; - int i; - struct diff_block *block_list, **block_list_end, *bptr; - - diff_limit = read_diff (filea, fileb, &diff_contents); - scan_diff = diff_contents; - block_list_end = &block_list; - - while (scan_diff < diff_limit) - { - bptr = ALLOCATE (1, struct diff_block); - bptr->lines[0] = bptr->lines[1] = (char **) 0; - bptr->lengths[0] = bptr->lengths[1] = (int *) 0; - - dt = process_diff_control (&scan_diff, bptr); - if (dt == ERROR || *scan_diff != '\n') - { - fprintf (stderr, "%s: diff error: ", argv0); - do - { - putc (*scan_diff, stderr); - } - while (*scan_diff++ != '\n'); - exit (2); - } - scan_diff++; - - /* Force appropriate ranges to be null, if necessary */ - switch (dt) - { - case ADD: - bptr->ranges[0][0]++; - break; - case DELETE: - bptr->ranges[1][0]++; - break; - case CHANGE: - break; - default: - fatal ("internal error: invalid diff type in process_diff"); - break; - } - - /* Allocate space for the pointers for the lines from filea, and - parcel them out among these pointers */ - if (dt != ADD) - { - int numlines = D_NUMLINES (bptr, 0); - bptr->lines[0] = ALLOCATE (numlines, char *); - bptr->lengths[0] = ALLOCATE (numlines, int); - for (i = 0; i < numlines; i++) - scan_diff = scan_diff_line (scan_diff, - &(bptr->lines[0][i]), - &(bptr->lengths[0][i]), - diff_limit, - '<'); - } - - /* Get past the separator for changes */ - if (dt == CHANGE) - { - if (strncmp (scan_diff, "---\n", 4)) - fatal ("invalid diff format; invalid change separator"); - scan_diff += 4; - } - - /* Allocate space for the pointers for the lines from fileb, and - parcel them out among these pointers */ - if (dt != DELETE) - { - int numlines = D_NUMLINES (bptr, 1); - bptr->lines[1] = ALLOCATE (numlines, char *); - bptr->lengths[1] = ALLOCATE (numlines, int); - for (i = 0; i < numlines; i++) - scan_diff = scan_diff_line (scan_diff, - &(bptr->lines[1][i]), - &(bptr->lengths[1][i]), - diff_limit, - '>'); - } - - /* Place this block on the blocklist. */ - *block_list_end = bptr; - block_list_end = &bptr->next; - } - - *block_list_end = 0; - *last_block = bptr; - return block_list; -} - -/* - * This routine will parse a normal format diff control string. It - * returns the type of the diff (ERROR if the format is bad). All of - * the other important information is filled into to the structure - * pointed to by db, and the string pointer (whose location is passed - * to this routine) is updated to point beyond the end of the string - * parsed. Note that only the ranges in the diff_block will be set by - * this routine. - * - * If some specific pair of numbers has been reduced to a single - * number, then both corresponding numbers in the diff block are set - * to that number. In general these numbers are interpetted as ranges - * inclusive, unless being used by the ADD or DELETE commands. It is - * assumed that these will be special cased in a superior routine. - */ - -static enum diff_type -process_diff_control (string, db) - char **string; - struct diff_block *db; -{ - char *s = *string; - int holdnum; - enum diff_type type; - -/* These macros are defined here because they can use variables - defined in this function. Don't try this at home kids, we're - trained professionals! - - Also note that SKIPWHITE only recognizes tabs and spaces, and - that READNUM can only read positive, integral numbers */ - -#define SKIPWHITE(s) { while (*s == ' ' || *s == '\t') s++; } -#define READNUM(s, num) \ - { if (!isdigit (*s)) return ERROR; holdnum = 0; \ - do { holdnum = (*s++ - '0' + holdnum * 10); } \ - while (isdigit (*s)); (num) = holdnum; } - - /* Read first set of digits */ - SKIPWHITE (s); - READNUM (s, db->ranges[0][START]); - - /* Was that the only digit? */ - SKIPWHITE (s); - if (*s == ',') - { - /* Get the next digit */ - s++; - READNUM (s, db->ranges[0][END]); - } - else - db->ranges[0][END] = db->ranges[0][START]; - - /* Get the letter */ - SKIPWHITE (s); - switch (*s) - { - case 'a': - type = ADD; - break; - case 'c': - type = CHANGE; - break; - case 'd': - type = DELETE; - break; - default: - return ERROR; /* Bad format */ - } - s++; /* Past letter */ - - /* Read second set of digits */ - SKIPWHITE (s); - READNUM (s, db->ranges[1][START]); - - /* Was that the only digit? */ - SKIPWHITE (s); - if (*s == ',') - { - /* Get the next digit */ - s++; - READNUM (s, db->ranges[1][END]); - SKIPWHITE (s); /* To move to end */ - } - else - db->ranges[1][END] = db->ranges[1][START]; - - *string = s; - return type; -} - -static char * -read_diff (filea, fileb, output_placement) - char *filea, *fileb; - char **output_placement; -{ - char *argv[7]; - char horizon_arg[256]; - char **ap; - int fds[2]; - char *diff_result; - int current_chunk_size; - int bytes; - int total; - int pid, w; - int wstatus; - - ap = argv; - *ap++ = diff_program; - if (always_text) - *ap++ = "-a"; - sprintf (horizon_arg, "--horizon-lines=%d", horizon_lines); - *ap++ = horizon_arg; - *ap++ = "--"; - *ap++ = filea; - *ap++ = fileb; - *ap = (char *) 0; - - if (pipe (fds) < 0) - perror_with_exit ("pipe failed"); - - pid = vfork (); - if (pid == 0) - { - /* Child */ - close (fds[0]); - if (fds[1] != fileno (stdout)) - { - dup2 (fds[1], fileno (stdout)); - close (fds[1]); - } - execve (diff_program, argv, environ); - /* Avoid stdio, because the parent process's buffers are inherited. */ - write (fileno (stderr), diff_program, strlen (diff_program)); - write (fileno (stderr), ": not found\n", 12); - _exit (2); - } - - if (pid == -1) - perror_with_exit ("fork failed"); - - close (fds[1]); /* Prevent erroneous lack of EOF */ - current_chunk_size = DIFF_CHUNK_SIZE; - diff_result = (char *) xmalloc (current_chunk_size); - total = 0; - do { - bytes = myread (fds[0], - diff_result + total, - current_chunk_size - total); - total += bytes; - if (total == current_chunk_size) - diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2)); - } while (bytes); - - if (total != 0 && diff_result[total-1] != '\n') - fatal ("invalid diff format; incomplete last line"); - - *output_placement = diff_result; - - do - if ((w = wait (&wstatus)) == -1) - perror_with_exit ("wait failed"); - while (w != pid); - - if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2)) - fatal ("subsidiary diff failed"); - - return diff_result + total; -} - - -/* - * Scan a regular diff line (consisting of > or <, followed by a - * space, followed by text (including nulls) up to a newline. - * - * This next routine began life as a macro and many parameters in it - * are used as call-by-reference values. - */ -static char * -scan_diff_line (scan_ptr, set_start, set_length, limit, firstchar) - char *scan_ptr, **set_start; - int *set_length; - char *limit; - char firstchar; -{ - char *line_ptr; - - if (!(scan_ptr[0] == (firstchar) - && scan_ptr[1] == ' ')) - fatal ("invalid diff format; incorrect leading line chars"); - - *set_start = line_ptr = scan_ptr + 2; - while (*line_ptr++ != '\n') - ; - - /* Include newline if the original line ended in a newline, - or if an edit script is being generated. - Copy any missing newline message to stderr if an edit script is being - generated, because edit scripts cannot handle missing newlines. - Return the beginning of the next line. */ - *set_length = line_ptr - *set_start; - if (line_ptr < limit && *line_ptr == '\\') - { - if (edscript) - fprintf (stderr, "%s:", argv0); - else - --*set_length; - line_ptr++; - do - { - if (edscript) - putc (*line_ptr, stderr); - } - while (*line_ptr++ != '\n'); - } - - return line_ptr; -} - -/* - * This routine outputs a three way diff passed as a list of - * diff3_block's. - * The argument MAPPING is indexed by external file number (in the - * argument list) and contains the internal file number (from the - * diff passed). This is important because the user expects his - * outputs in terms of the argument list number, and the diff passed - * may have been done slightly differently (if the last argument - * was "-", for example). - * REV_MAPPING is the inverse of MAPPING. - */ -static void -output_diff3 (outputfile, diff, mapping, rev_mapping) - FILE *outputfile; - struct diff3_block *diff; - int mapping[3], rev_mapping[3]; -{ - int i; - int oddoneout; - char *cp; - struct diff3_block *ptr; - int line; - int length; - int dontprint; - static int skew_increment[3] = { 2, 3, 1 }; /* 0==>2==>1==>3 */ - - for (ptr = diff; ptr; ptr = D_NEXT (ptr)) - { - char x[2]; - - switch (ptr->correspond) - { - case DIFF_ALL: - x[0] = '\0'; - dontprint = 3; /* Print them all */ - oddoneout = 3; /* Nobody's odder than anyone else */ - break; - case DIFF_1ST: - case DIFF_2ND: - case DIFF_3RD: - oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST]; - - x[0] = oddoneout + '1'; - x[1] = '\0'; - dontprint = oddoneout==0; - break; - default: - fatal ("internal error: invalid diff type passed to output"); - } - fprintf (outputfile, "====%s\n", x); - - /* Go 0, 2, 1 if the first and third outputs are equivalent. */ - for (i = 0; i < 3; - i = (oddoneout == 1 ? skew_increment[i] : i + 1)) - { - int realfile = mapping[i]; - int - lowt = D_LOWLINE (ptr, realfile), - hight = D_HIGHLINE (ptr, realfile); - - fprintf (outputfile, "%d:", i + 1); - switch (lowt - hight) - { - case 1: - fprintf (outputfile, "%da\n", lowt - 1); - break; - case 0: - fprintf (outputfile, "%dc\n", lowt); - break; - default: - fprintf (outputfile, "%d,%dc\n", lowt, hight); - break; - } - - if (i == dontprint) continue; - - for (line = 0; line < hight - lowt + 1; line++) - { - fprintf (outputfile, " "); - cp = D_RELNUM (ptr, realfile, line); - length = D_RELLEN (ptr, realfile, line); - fwrite (cp, sizeof (char), length, outputfile); - } - if (line != 0 && cp[length - 1] != '\n') - fprintf (outputfile, "\n\\ No newline at end of file\n"); - } - } -} - - -/* - * Output to OUTPUTFILE the lines of B taken from FILENUM. - * Double any initial '.'s; yield nonzero if any initial '.'s were doubled. - */ -static int -dotlines (outputfile, b, filenum) - FILE *outputfile; - struct diff3_block *b; - int filenum; -{ - int i; - int leading_dot = 0; - - for (i = 0; - i < D_NUMLINES (b, filenum); - i++) - { - char *line = D_RELNUM (b, filenum, i); - if (line[0] == '.') - { - leading_dot = 1; - fprintf (outputfile, "."); - } - fwrite (line, sizeof (char), - D_RELLEN (b, filenum, i), outputfile); - } - - return leading_dot; -} - -/* - * Output to OUTPUTFILE a '.' line. If LEADING_DOT is nonzero, - * also output a command that removes initial '.'s - * starting with line START and continuing for NUM lines. - */ -static void -undotlines (outputfile, leading_dot, start, num) - FILE *outputfile; - int leading_dot, start, num; -{ - fprintf (outputfile, ".\n"); - if (leading_dot) - if (num == 1) - fprintf (outputfile, "%ds/^\\.//\n", start); - else - fprintf (outputfile, "%d,%ds/^\\.//\n", start, start + num - 1); -} - -/* - * This routine outputs a diff3 set of blocks as an ed script. This - * script applies the changes between file's 2 & 3 to file 1. It - * takes the precise format of the ed script to be output from global - * variables set during options processing. Note that it does - * destructive things to the set of diff3 blocks it is passed; it - * reverses their order (this gets around the problems involved with - * changing line numbers in an ed script). - * - * Note that this routine has the same problem of mapping as the last - * one did; the variable MAPPING maps from file number according to - * the argument list to file number according to the diff passed. All - * files listed below are in terms of the argument list. - * REV_MAPPING is the inverse of MAPPING. - * - * The arguments FILE0, FILE1 and FILE2 are the strings to print - * as the names of the three files. These may be the actual names, - * or may be the arguments specified with -L. - * - * Returns 1 if conflicts were found. - */ - -static int -output_diff3_edscript (outputfile, diff, mapping, rev_mapping, - file0, file1, file2) - FILE *outputfile; - struct diff3_block *diff; - int mapping[3], rev_mapping[3]; - char *file0, *file1, *file2; -{ - int leading_dot; - int conflicts_found = 0, conflict; - struct diff3_block *b; - - for (b = reverse_diff3_blocklist (diff); b; b = b->next) - { - /* Must do mapping correctly. */ - enum diff_type type - = ((b->correspond == DIFF_ALL) ? - DIFF_ALL : - ((enum diff_type) - (((int) DIFF_1ST) - + rev_mapping[(int) b->correspond - (int) DIFF_1ST]))); - - /* If we aren't supposed to do this output block, skip it. */ - switch (type) - { - default: continue; - case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break; - case DIFF_3RD: if (overlap_only) continue; conflict = 0; break; - case DIFF_ALL: if (simple_only) continue; conflict = flagging; break; - } - - if (conflict) - { - conflicts_found = 1; - - - /* Mark end of conflict. */ - - fprintf (outputfile, "%da\n", D_HIGHLINE (b, mapping[FILE0])); - leading_dot = 0; - if (type == DIFF_ALL) - { - if (show_2nd) - { - /* Append lines from FILE1. */ - fprintf (outputfile, "||||||| %s\n", file1); - leading_dot = dotlines (outputfile, b, mapping[FILE1]); - } - /* Append lines from FILE2. */ - fprintf (outputfile, "=======\n"); - leading_dot |= dotlines (outputfile, b, mapping[FILE2]); - } - fprintf (outputfile, ">>>>>>> %s\n", file2); - undotlines (outputfile, leading_dot, - D_HIGHLINE (b, mapping[FILE0]) + 2, - (D_NUMLINES (b, mapping[FILE1]) - + D_NUMLINES (b, mapping[FILE2]) + 1)); - - - /* Mark start of conflict. */ - - fprintf (outputfile, "%da\n<<<<<<< %s\n", - D_LOWLINE (b, mapping[FILE0]) - 1, - type == DIFF_ALL ? file0 : file1); - leading_dot = 0; - if (type == DIFF_2ND) - { - /* Prepend lines from FILE1. */ - leading_dot = dotlines (outputfile, b, mapping[FILE1]); - fprintf (outputfile, "=======\n"); - } - undotlines (outputfile, leading_dot, - D_LOWLINE (b, mapping[FILE0]) + 1, - D_NUMLINES (b, mapping[FILE1])); - } - else if (D_NUMLINES (b, mapping[FILE2]) == 0) - /* Write out a delete */ - { - if (D_NUMLINES (b, mapping[FILE0]) == 1) - fprintf (outputfile, "%dd\n", - D_LOWLINE (b, mapping[FILE0])); - else - fprintf (outputfile, "%d,%dd\n", - D_LOWLINE (b, mapping[FILE0]), - D_HIGHLINE (b, mapping[FILE0])); - } - else - /* Write out an add or change */ - { - switch (D_NUMLINES (b, mapping[FILE0])) - { - case 0: - fprintf (outputfile, "%da\n", - D_HIGHLINE (b, mapping[FILE0])); - break; - case 1: - fprintf (outputfile, "%dc\n", - D_HIGHLINE (b, mapping[FILE0])); - break; - default: - fprintf (outputfile, "%d,%dc\n", - D_LOWLINE (b, mapping[FILE0]), - D_HIGHLINE (b, mapping[FILE0])); - break; - } - - undotlines (outputfile, dotlines (outputfile, b, mapping[FILE2]), - D_LOWLINE (b, mapping[FILE0]), - D_NUMLINES (b, mapping[FILE2])); - } - } - if (finalwrite) fprintf (outputfile, "w\nq\n"); - return conflicts_found; -} - -/* - * Read from INFILE and output to OUTPUTFILE a set of diff3_ blocks DIFF - * as a merged file. This acts like 'ed file0 <[output_diff3_edscript]', - * except that it works even for binary data or incomplete lines. - * - * As before, MAPPING maps from arg list file number to diff file number, - * REV_MAPPING is its inverse, - * and FILE0, FILE1, and FILE2 are the names of the files. - * - * Returns 1 if conflicts were found. - */ - -static int -output_diff3_merge (infile, outputfile, diff, mapping, rev_mapping, - file0, file1, file2) - FILE *infile, *outputfile; - struct diff3_block *diff; - int mapping[3], rev_mapping[3]; - char *file0, *file1, *file2; -{ - int c, i; - int conflicts_found = 0, conflict; - struct diff3_block *b; - int linesread = 0; - - for (b = diff; b; b = b->next) - { - /* Must do mapping correctly. */ - enum diff_type type - = ((b->correspond == DIFF_ALL) ? - DIFF_ALL : - ((enum diff_type) - (((int) DIFF_1ST) - + rev_mapping[(int) b->correspond - (int) DIFF_1ST]))); - char *format_2nd = "<<<<<<< %s\n"; - - /* If we aren't supposed to do this output block, skip it. */ - switch (type) - { - default: continue; - case DIFF_2ND: if (!show_2nd) continue; conflict = 1; break; - case DIFF_3RD: if (overlap_only) continue; conflict = 0; break; - case DIFF_ALL: if (simple_only) continue; conflict = flagging; - format_2nd = "||||||| %s\n"; - break; - } - - /* Copy I lines from file 0. */ - i = D_LOWLINE (b, FILE0) - linesread - 1; - linesread += i; - while (0 <= --i) - do - { - c = getc (infile); - if (c == EOF) - if (ferror (infile)) - perror_with_exit ("input file"); - else if (feof (infile)) - fatal ("input file shrank"); - putc (c, outputfile); - } - while (c != '\n'); - - if (conflict) - { - conflicts_found = 1; - - if (type == DIFF_ALL) - { - /* Put in lines from FILE0 with bracket. */ - fprintf (outputfile, "<<<<<<< %s\n", file0); - for (i = 0; - i < D_NUMLINES (b, mapping[FILE0]); - i++) - fwrite (D_RELNUM (b, mapping[FILE0], i), sizeof (char), - D_RELLEN (b, mapping[FILE0], i), outputfile); - } - - if (show_2nd) - { - /* Put in lines from FILE1 with bracket. */ - fprintf (outputfile, format_2nd, file1); - for (i = 0; - i < D_NUMLINES (b, mapping[FILE1]); - i++) - fwrite (D_RELNUM (b, mapping[FILE1], i), sizeof (char), - D_RELLEN (b, mapping[FILE1], i), outputfile); - } - - fprintf (outputfile, "=======\n"); - } - - /* Put in lines from FILE2. */ - for (i = 0; - i < D_NUMLINES (b, mapping[FILE2]); - i++) - fwrite (D_RELNUM (b, mapping[FILE2], i), sizeof (char), - D_RELLEN (b, mapping[FILE2], i), outputfile); - - if (conflict) - fprintf (outputfile, ">>>>>>> %s\n", file2); - - /* Skip I lines in file 0. */ - i = D_NUMLINES (b, FILE0); - linesread += i; - while (0 <= --i) - while ((c = getc (infile)) != '\n') - if (c == EOF) - if (ferror (infile)) - perror_with_exit ("input file"); - else if (feof (infile)) - { - if (i || b->next) - fatal ("input file shrank"); - return conflicts_found; - } - } - /* Copy rest of common file. */ - while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile))) - putc (c, outputfile); - return conflicts_found; -} - -/* - * Reverse the order of the list of diff3 blocks. - */ -static struct diff3_block * -reverse_diff3_blocklist (diff) - struct diff3_block *diff; -{ - register struct diff3_block *tmp, *next, *prev; - - for (tmp = diff, prev = (struct diff3_block *) 0; - tmp; tmp = next) - { - next = tmp->next; - tmp->next = prev; - prev = tmp; - } - - return prev; -} - -static int -myread (fd, ptr, size) - int fd, size; - char *ptr; -{ - int result = read (fd, ptr, size); - if (result < 0) - perror_with_exit ("read failed"); - return result; -} - -VOID * -xmalloc (size) - unsigned size; -{ - VOID *result = (VOID *) malloc (size ? size : 1); - if (!result) - fatal ("virtual memory exhausted"); - return result; -} - -static VOID * -xrealloc (ptr, size) - VOID *ptr; - unsigned size; -{ - VOID *result = (VOID *) realloc (ptr, size ? size : 1); - if (!result) - fatal ("virtual memory exhausted"); - return result; -} - -static void -fatal (string) - char *string; -{ - fprintf (stderr, "%s: %s\n", argv0, string); - exit (2); -} - -static void -perror_with_exit (string) - char *string; -{ - int e = errno; - fprintf (stderr, "%s: ", argv0); - errno = e; - perror (string); - exit (2); -} diff --git a/gnu/usr.bin/diff3/getopt.c b/gnu/usr.bin/diff3/getopt.c deleted file mode 100644 index a59a01339835..000000000000 --- a/gnu/usr.bin/diff3/getopt.c +++ /dev/null @@ -1,731 +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, 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 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* NOTE!!! AIX requires this to be the first thing in the file. - Do not put ANYTHING before it! */ -#if !defined (__GNUC__) && defined (_AIX) - #pragma alloca -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#include -#else -#ifndef _AIX -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif - -/* This tells Alpha OSF/1 not to define a getopt prototype in . */ -#ifndef _NO_PROTO -#define _NO_PROTO -#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__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -/* 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. */ -/* #define 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. */ - -/* XXX 1003.2 says this must be 1 before any call. */ -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; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* 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; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - const char *from; - char *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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; -{ - int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) __alloca (nonopts_size); - - /* 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); - - /* 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; - - 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, 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 optstring[0] == ':' ? ':' : '?'; - } - } - 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 0 - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], c); - else - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); -#endif - } - optopt = 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) - { -#if 0 - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: option requires an argument -- %c\n", - argv[0], c); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - 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); -} - -#endif /* _LIBC or not __GNU_LIBRARY__. */ - -#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 --git a/gnu/usr.bin/diff3/getopt.h b/gnu/usr.bin/diff3/getopt.h deleted file mode 100644 index 45541f5ac0f9..000000000000 --- a/gnu/usr.bin/diff3/getopt.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* 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'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if __STDC__ -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (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 (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/diff3/getopt1.c b/gnu/usr.bin/diff3/getopt1.c deleted file mode 100644 index a32615ce36e7..000000000000 --- a/gnu/usr.bin/diff3/getopt1.c +++ /dev/null @@ -1,176 +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 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "getopt.h" - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#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 --git a/gnu/usr.bin/diff3/system.h b/gnu/usr.bin/diff3/system.h deleted file mode 100644 index b17d39a08af8..000000000000 --- a/gnu/usr.bin/diff3/system.h +++ /dev/null @@ -1,159 +0,0 @@ -/* System dependent declarations. - Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc. - -This file is part of GNU DIFF. - -GNU DIFF 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. - -GNU DIFF 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 GNU DIFF; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include - -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#endif -#ifndef S_ISREG -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) -#endif - -#if HAVE_UNISTD_H -#include -#endif - -#if HAVE_TIME_H -#include -#else -#include -#endif - -#if HAVE_FCNTL_H -#include -#else -#include -#endif - -#if !HAVE_DUP2 -#define dup2(f,t) (close (t), fcntl (f,F_DUPFD,t)) -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - -#if HAVE_SYS_WAIT_H -#ifndef _POSIX_VERSION -/* Prevent the NeXT prototype using union wait from causing problems. */ -#define wait system_wait -#endif -#include -#ifndef _POSIX_VERSION -#undef wait -#endif -#endif /* HAVE_SYS_WAIT_H */ - -#ifndef WEXITSTATUS -#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix. */ -#endif -#ifndef WIFEXITED -#define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif - -#if HAVE_ST_BLKSIZE -#define STAT_BLOCKSIZE(s) (s).st_blksize -#else -#define STAT_BLOCKSIZE(s) (S_ISREG ((s).st_mode) ? 8192 : 4096) -#endif - -#if DIRENT || defined (_POSIX_VERSION) -#include -#ifdef direct -#undef direct -#endif -#define direct dirent -#else /* ! (DIRENT || defined (_POSIX_VERSION)) */ -#if SYSNDIR -#include -#else -#if SYSDIR -#include -#else -#include -#endif -#endif -#endif /* ! (DIRENT || defined (_POSIX_VERSION)) */ - -#if HAVE_VFORK_H -#include -#endif - -#if HAVE_STRING_H || STDC_HEADERS -#include -#ifndef index -#define index strchr -#endif -#ifndef rindex -#define rindex strrchr -#endif -#ifndef bcopy -#define bcopy(s,d,n) memcpy (d,s,n) -#endif -#ifndef bcmp -#define bcmp(s1,s2,n) memcmp (s1,s2,n) -#endif -#ifndef bzero -#define bzero(s,n) memset (s,0,n) -#endif -#else -#include -#endif -#if !HAVE_MEMCHR && !STDC_HEADERS -char *memchr (); -#endif - -#if STDC_HEADERS -#include -#include -#else -char *getenv (); -char *malloc (); -char *realloc (); -#if __STDC__ || __GNUC__ -#include "limits.h" -#else -#define INT_MAX 2147483647 -#define CHAR_BIT 8 -#endif -#endif - -#include -#if !STDC_HEADERS -extern int errno; -#endif - -#ifdef TRUE -#undef TRUE -#endif -#ifdef FALSE -#undef FALSE -#endif -#define TRUE 1 -#define FALSE 0 - -#if !__STDC__ -#define volatile -#endif - -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) diff --git a/gnu/usr.bin/diff3/version.c b/gnu/usr.bin/diff3/version.c deleted file mode 100644 index cb9d3b9c45c0..000000000000 --- a/gnu/usr.bin/diff3/version.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Version number of GNU diff. */ - -char *version_string = "2.3"; diff --git a/gnu/usr.bin/grep/tests/regress.sh b/gnu/usr.bin/grep/tests/regress.sh deleted file mode 100644 index b947036467e0..000000000000 --- a/gnu/usr.bin/grep/tests/regress.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# Regression test for GNU e?grep. -# Usage: regress.sh [dir-containing-egrep] - -builddir=${1-..} - -failures=0 - -# The Khadafy test is brought to you by Scott Anderson . . . -$builddir/egrep -f khadafy.regexp khadafy.lines > khadafy.out -if cmp khadafy.lines khadafy.out -then - rm khadafy.out -else - echo Khadafy test failed -- output left on khadafy.out - failures=1 -fi - -# . . . and the following by Henry Spencer. - -awk -F: -f scriptgen.awk spencer.tests > tmp.script - -if sh tmp.script $builddir -then - rm tmp.script - exit $failures -else - rm tmp.script - exit 1 -fi diff --git a/gnu/usr.bin/groff/eqn/eqn.cc b/gnu/usr.bin/groff/eqn/eqn.cc deleted file mode 100644 index 744a7555afd0..000000000000 --- a/gnu/usr.bin/groff/eqn/eqn.cc +++ /dev/null @@ -1,1162 +0,0 @@ -#ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; -#endif -#define YYBYACC 1 -#line 20 "/u/jjc/groff/eqn/eqn.y" -#include -#include -#include - -#include "lib.h" -#include "box.h" -extern int non_empty_flag; -char *strsave(const char *); -int yylex(); -void yyerror(const char *); -#line 32 "/u/jjc/groff/eqn/eqn.y" -typedef union { - char *str; - box *b; - pile_box *pb; - matrix_box *mb; - int n; - column *col; -} YYSTYPE; -#line 26 "y.tab.c" -#define OVER 257 -#define SMALLOVER 258 -#define SQRT 259 -#define SUB 260 -#define SUP 261 -#define LPILE 262 -#define RPILE 263 -#define CPILE 264 -#define PILE 265 -#define LEFT 266 -#define RIGHT 267 -#define TO 268 -#define FROM 269 -#define SIZE 270 -#define FONT 271 -#define ROMAN 272 -#define BOLD 273 -#define ITALIC 274 -#define FAT 275 -#define ACCENT 276 -#define BAR 277 -#define UNDER 278 -#define ABOVE 279 -#define TEXT 280 -#define QUOTED_TEXT 281 -#define FWD 282 -#define BACK 283 -#define DOWN 284 -#define UP 285 -#define MATRIX 286 -#define COL 287 -#define LCOL 288 -#define RCOL 289 -#define CCOL 290 -#define MARK 291 -#define LINEUP 292 -#define TYPE 293 -#define VCENTER 294 -#define PRIME 295 -#define SPLIT 296 -#define NOSPLIT 297 -#define UACCENT 298 -#define SPECIAL 299 -#define SPACE 300 -#define GFONT 301 -#define GSIZE 302 -#define DEFINE 303 -#define NDEFINE 304 -#define TDEFINE 305 -#define SDEFINE 306 -#define UNDEF 307 -#define IFDEF 308 -#define INCLUDE 309 -#define DELIM 310 -#define CHARTYPE 311 -#define SET 312 -#define GRFONT 313 -#define GBFONT 314 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 0, 6, 6, 1, 1, 1, 2, 2, 2, - 2, 2, 3, 3, 3, 3, 4, 4, 7, 7, - 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 8, 11, 11, 12, 12, 13, - 13, 16, 16, 15, 15, 14, 14, 14, 14, 9, - 9, 10, 10, 10, -}; -short yylen[] = { 2, - 0, 1, 1, 2, 1, 2, 2, 1, 3, 3, - 5, 5, 1, 2, 3, 3, 1, 3, 1, 3, - 5, 1, 1, 2, 2, 1, 1, 1, 3, 2, - 2, 2, 2, 4, 5, 3, 2, 2, 2, 3, - 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 2, 3, 1, 1, 3, 3, 4, 1, - 2, 1, 3, 3, 4, 2, 2, 2, 2, 1, - 1, 1, 1, 1, -}; -short yydefred[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 22, 23, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 26, 27, 28, 0, - 0, 3, 5, 0, 13, 0, 0, 17, 14, 70, - 71, 0, 0, 55, 31, 32, 33, 30, 73, 74, - 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 7, 0, 0, 24, 25, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 37, 38, - 39, 0, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, - 0, 29, 15, 16, 9, 0, 0, 20, 18, 40, - 41, 0, 58, 0, 0, 0, 0, 66, 67, 68, - 69, 34, 61, 0, 0, 0, 0, 59, 35, 0, - 0, 0, 11, 12, 21, 0, 64, 0, 0, 65, -}; -short yydgoto[] = { 31, - 32, 33, 34, 35, 36, 84, 38, 43, 44, 52, - 85, 45, 98, 99, 118, 131, -}; -short yysindex[] = { 1488, - 1527, -120, -120, -120, -120, -123, -249, -249, 1566, 1566, - 1566, 1566, 0, 0, -249, -249, -249, -249, -115, 1488, - 1488, -249, 1566, -256, -251, -249, 0, 0, 0, 1488, - 0, 0, 0, -221, 0, -233, 1488, 0, 0, 0, - 0, 1488, -85, 0, 0, 0, 0, 0, 0, 0, - 0, 1488, 1566, 1566, -195, -195, -195, -195, 1566, 1566, - 1566, 1566, -272, 0, 0, 1566, -195, 0, 0, 1566, - 1402, 1527, 1527, 1527, 1527, 1566, 1566, 1566, 0, 0, - 0, 1566, 0, 1488, -113, 1488, 1444, -195, -195, -195, - -195, -195, -195, -117, -117, -117, -117, -118, 0, -195, - -195, 0, 0, 0, 0, -167, -189, 0, 0, 0, - 0, 1488, 0, -106, -123, 1488, -83, 0, 0, 0, - 0, 0, 0, 1527, 1527, 1566, 1488, 0, 0, 1488, - -105, 1488, 0, 0, 0, 1488, 0, -104, 1488, 0, -}; -short yyrindex[] = { 41, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 1220, 46, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 85, 128, 363, 406, 0, 0, - 0, 0, 0, 0, 0, 0, 449, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -103, 0, 0, 185, 492, 727, 770, - 813, 856, 1091, 0, 0, 0, 0, 0, 0, 1134, - 1177, 0, 0, 0, 0, 42, 1220, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -102, 0, 0, -101, - 0, 0, 0, 0, 0, 0, 0, 0, -99, 0, -}; -short yygindex[] = { 0, - -7, -69, 3, -66, 458, 9, -26, 52, 27, -63, - -32, 54, 0, -35, 2, -59, -}; -#define YYTABLESIZE 1865 -short yytable[] = { 49, - 8, 50, 42, 39, 105, 116, 122, 63, 37, 8, - 109, 113, 64, 65, 94, 95, 96, 97, 128, 137, - 140, 56, 57, 62, 68, 63, 76, 77, 69, 83, - 40, 41, 51, 53, 54, 72, 73, 86, 71, 132, - 1, 10, 78, 79, 80, 2, 74, 75, 66, 108, - 10, 129, 70, 114, 133, 134, 46, 47, 48, 135, - 87, 81, 123, 83, 82, 0, 59, 60, 61, 62, - 76, 126, 138, 0, 103, 104, 83, 106, 0, 83, - 78, 79, 80, 0, 42, 0, 78, 79, 80, 72, - 73, 0, 0, 42, 8, 0, 119, 120, 121, 81, - 124, 125, 82, 0, 0, 81, 0, 0, 82, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, - 127, 0, 83, 8, 130, 8, 8, 43, 0, 0, - 0, 83, 0, 0, 0, 10, 43, 0, 0, 0, - 130, 51, 0, 0, 139, 117, 117, 117, 117, 0, - 0, 0, 0, 0, 0, 0, 40, 41, 0, 40, - 41, 0, 40, 41, 10, 112, 10, 10, 94, 95, - 96, 97, 112, 136, 136, 56, 57, 62, 42, 63, - 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 42, 0, 42, - 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 43, 0, 43, 43, 0, 0, 0, 0, 0, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, - 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 36, - 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, - 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 0, 0, 44, 42, 42, 42, 42, 42, 42, 42, - 42, 44, 0, 0, 0, 42, 42, 42, 42, 0, - 42, 42, 0, 42, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 0, 0, 45, 43, 43, 43, 43, - 43, 43, 43, 43, 45, 0, 0, 0, 43, 43, - 43, 43, 0, 43, 43, 0, 43, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 36, 36, 0, 36, 36, 0, 0, 53, 0, - 0, 0, 36, 36, 0, 0, 44, 53, 0, 0, - 36, 36, 36, 36, 0, 0, 55, 56, 57, 58, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, - 67, 0, 36, 0, 0, 44, 0, 44, 44, 0, - 0, 47, 0, 0, 0, 0, 0, 0, 0, 45, - 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 88, 89, 0, 0, 0, 0, 90, 91, 92, 93, - 0, 0, 0, 100, 0, 0, 0, 101, 45, 0, - 45, 45, 0, 107, 0, 110, 0, 0, 0, 111, - 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 53, 0, 53, 53, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 47, 0, 47, 47, 0, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 0, 0, - 0, 44, 44, 44, 44, 44, 44, 44, 44, 0, - 0, 0, 0, 44, 44, 44, 44, 0, 44, 44, - 0, 44, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 0, 0, 0, 45, 45, 45, 45, 45, 45, - 45, 45, 0, 0, 0, 0, 45, 45, 45, 45, - 0, 45, 45, 0, 45, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 0, 0, 46, 53, 53, 53, - 53, 53, 53, 53, 53, 46, 0, 0, 0, 53, - 53, 53, 53, 0, 53, 53, 0, 53, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 0, 0, 48, - 47, 47, 47, 47, 47, 47, 47, 47, 48, 0, - 0, 0, 47, 47, 47, 47, 0, 47, 47, 0, - 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, - 46, 49, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 0, 46, 46, 0, 0, 51, 0, 0, 0, 0, - 0, 0, 0, 48, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 48, 0, 48, 48, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 49, 0, 49, 49, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, - 51, 51, 0, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 0, 0, 0, 46, 46, 46, 46, 46, - 46, 46, 46, 0, 0, 0, 0, 46, 46, 46, - 46, 0, 46, 46, 0, 46, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 0, 0, 0, 48, 48, - 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, - 48, 48, 48, 48, 0, 48, 48, 0, 48, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, - 50, 49, 49, 49, 49, 49, 49, 49, 49, 50, - 0, 0, 0, 49, 49, 49, 49, 0, 49, 49, - 0, 49, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 0, 0, 52, 51, 51, 51, 51, 51, 51, - 51, 51, 52, 0, 0, 0, 51, 51, 51, 51, - 0, 51, 51, 0, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, - 0, 0, 0, 0, 50, 54, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 50, 0, 50, 50, 0, 0, 19, - 0, 0, 0, 0, 0, 0, 0, 52, 19, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 52, 0, 52, 52, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, - 0, 54, 54, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 19, 0, 19, 19, 0, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 0, 0, 0, 50, - 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, - 0, 50, 50, 50, 50, 0, 50, 50, 0, 50, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 0, - 29, 0, 52, 52, 52, 52, 52, 52, 52, 52, - 0, 0, 0, 0, 52, 52, 52, 52, 0, 52, - 52, 0, 52, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 29, 0, 0, 54, 54, 54, 54, 54, - 54, 54, 54, 0, 0, 0, 0, 54, 54, 54, - 54, 0, 54, 54, 0, 54, 19, 19, 19, 0, - 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 27, 29, 0, 19, 19, - 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, - 19, 19, 19, 19, 0, 19, 19, 0, 19, 0, - 0, 0, 0, 0, 30, 0, 102, 28, 0, 0, - 0, 0, 0, 0, 0, 29, 0, 27, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 30, 0, 0, 28, - 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, - 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 30, 0, 0, 28, 0, 0, 0, 0, 0, 0, - 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, - 0, 0, 28, 0, 0, 0, 0, 0, 0, 27, - 1, 0, 0, 2, 3, 4, 5, 6, 0, 0, - 0, 7, 8, 9, 10, 11, 12, 0, 0, 0, - 0, 13, 14, 15, 16, 17, 18, 19, 30, 0, - 0, 28, 20, 21, 22, 23, 0, 24, 25, 0, - 26, 0, 1, 0, 0, 2, 3, 4, 5, 6, - 115, 0, 0, 7, 8, 9, 10, 11, 12, 0, - 0, 0, 0, 13, 14, 15, 16, 17, 18, 19, - 0, 0, 0, 0, 20, 21, 22, 23, 0, 24, - 25, 0, 26, 0, 0, 0, 1, 0, 0, 2, - 3, 4, 5, 6, 0, 0, 0, 7, 8, 9, - 10, 11, 12, 0, 0, 0, 0, 13, 14, 15, - 16, 17, 18, 19, 0, 0, 0, 0, 20, 21, - 22, 23, 0, 24, 25, 1, 26, 0, 2, 3, - 4, 5, 6, 0, 0, 0, 7, 8, 9, 10, - 11, 12, 0, 0, 0, 0, 13, 14, 15, 16, - 17, 18, 19, 0, 0, 0, 0, 0, 0, 22, - 23, 0, 24, 25, 0, 26, 0, 2, 3, 4, - 5, 6, 0, 0, 0, 7, 8, 9, 10, 11, - 12, 0, 0, 0, 0, 13, 14, 15, 16, 17, - 18, 19, 0, 0, 0, 0, 0, 0, 22, 23, - 0, 24, 25, 0, 26, -}; -short yycheck[] = { 123, - 0, 125, 123, 1, 74, 123, 125, 123, 0, 9, - 77, 125, 20, 21, 287, 288, 289, 290, 125, 125, - 125, 125, 125, 125, 281, 125, 260, 261, 280, 37, - 280, 281, 6, 7, 8, 257, 258, 123, 30, 123, - 0, 0, 276, 277, 278, 0, 268, 269, 22, 76, - 9, 115, 26, 86, 124, 125, 3, 4, 5, 126, - 52, 295, 98, 71, 298, -1, 15, 16, 17, 18, - 260, 261, 132, -1, 72, 73, 84, 75, -1, 87, - 276, 277, 278, -1, 0, -1, 276, 277, 278, 257, - 258, -1, -1, 9, 94, -1, 95, 96, 97, 295, - 268, 269, 298, -1, -1, 295, -1, -1, 298, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 127, - 112, -1, 130, 123, 116, 125, 126, 0, -1, -1, - -1, 139, -1, -1, -1, 94, 9, -1, -1, -1, - 132, 115, -1, -1, 136, 94, 95, 96, 97, -1, - -1, -1, -1, -1, -1, -1, 280, 281, -1, 280, - 281, -1, 280, 281, 123, 279, 125, 126, 287, 288, - 289, 290, 279, 279, 279, 279, 279, 279, 94, 279, - -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 123, -1, 125, - 126, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 94, -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, - 123, -1, 125, 126, -1, -1, -1, -1, -1, 259, - 260, 261, 262, 263, 264, 265, 266, 267, -1, -1, - 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, - 280, 281, 282, 283, 284, 285, 286, -1, -1, -1, - -1, 291, 292, 293, 294, 295, 296, 297, 298, 299, - 259, 260, 261, 262, 263, 264, 265, 266, 267, 125, - -1, 270, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, 281, 282, 283, 284, 285, 286, -1, -1, - -1, -1, 291, 292, 293, 294, 295, 296, 297, 298, - 299, 257, 258, 259, 260, 261, 262, 263, 264, 265, - 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, - -1, -1, 0, 279, 280, 281, 282, 283, 284, 285, - 286, 9, -1, -1, -1, 291, 292, 293, 294, -1, - 296, 297, -1, 299, 257, 258, 259, 260, 261, 262, - 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, - 273, 274, 275, -1, -1, 0, 279, 280, 281, 282, - 283, 284, 285, 286, 9, -1, -1, -1, 291, 292, - 293, 294, -1, 296, 297, -1, 299, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 257, 258, -1, 260, 261, -1, -1, 0, -1, - -1, -1, 268, 269, -1, -1, 94, 9, -1, -1, - 276, 277, 278, 279, -1, -1, 9, 10, 11, 12, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 295, - 23, -1, 298, -1, -1, 123, -1, 125, 126, -1, - -1, 0, -1, -1, -1, -1, -1, -1, -1, 94, - 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 53, 54, -1, -1, -1, -1, 59, 60, 61, 62, - -1, -1, -1, 66, -1, -1, -1, 70, 123, -1, - 125, 126, -1, 76, -1, 78, -1, -1, -1, 82, - -1, -1, 94, -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, 123, -1, 125, 126, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 94, -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, 123, -1, 125, 126, -1, 257, - 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, 273, 274, 275, -1, -1, - -1, 279, 280, 281, 282, 283, 284, 285, 286, -1, - -1, -1, -1, 291, 292, 293, 294, -1, 296, 297, - -1, 299, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, -1, -1, -1, 279, 280, 281, 282, 283, 284, - 285, 286, -1, -1, -1, -1, 291, 292, 293, 294, - -1, 296, 297, -1, 299, 257, 258, 259, 260, 261, - 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 273, 274, 275, -1, -1, 0, 279, 280, 281, - 282, 283, 284, 285, 286, 9, -1, -1, -1, 291, - 292, 293, 294, -1, 296, 297, -1, 299, 257, 258, - 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, 273, 274, 275, -1, -1, 0, - 279, 280, 281, 282, 283, 284, 285, 286, 9, -1, - -1, -1, 291, 292, 293, 294, -1, 296, 297, -1, - 299, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, - 94, 9, -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, 123, - -1, 125, 126, -1, -1, 0, -1, -1, -1, -1, - -1, -1, -1, 94, 9, -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, 123, -1, 125, 126, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 94, -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, 123, -1, 125, 126, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 94, - -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, 123, -1, - 125, 126, -1, 257, 258, 259, 260, 261, 262, 263, - 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, - 274, 275, -1, -1, -1, 279, 280, 281, 282, 283, - 284, 285, 286, -1, -1, -1, -1, 291, 292, 293, - 294, -1, 296, 297, -1, 299, 257, 258, 259, 260, - 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, 273, 274, 275, -1, -1, -1, 279, 280, - 281, 282, 283, 284, 285, 286, -1, -1, -1, -1, - 291, 292, 293, 294, -1, 296, 297, -1, 299, 257, - 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, 273, 274, 275, -1, -1, - 0, 279, 280, 281, 282, 283, 284, 285, 286, 9, - -1, -1, -1, 291, 292, 293, 294, -1, 296, 297, - -1, 299, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, -1, -1, 0, 279, 280, 281, 282, 283, 284, - 285, 286, 9, -1, -1, -1, 291, 292, 293, 294, - -1, 296, 297, -1, 299, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, - -1, -1, -1, -1, 94, 9, -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, 123, -1, 125, 126, -1, -1, 0, - -1, -1, -1, -1, -1, -1, -1, 94, 9, -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, 123, -1, 125, 126, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 94, -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, 123, - -1, 125, 126, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 94, -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, 123, -1, 125, 126, -1, 257, 258, 259, - 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 274, 275, -1, -1, -1, 279, - 280, 281, 282, 283, 284, 285, 286, -1, -1, -1, - -1, 291, 292, 293, 294, -1, 296, 297, -1, 299, - 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 268, 269, 270, 271, 272, 273, 274, 275, -1, - 9, -1, 279, 280, 281, 282, 283, 284, 285, 286, - -1, -1, -1, -1, 291, 292, 293, 294, -1, 296, - 297, -1, 299, 257, 258, 259, 260, 261, 262, 263, - 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, - 274, 275, 9, -1, -1, 279, 280, 281, 282, 283, - 284, 285, 286, -1, -1, -1, -1, 291, 292, 293, - 294, -1, 296, 297, -1, 299, 257, 258, 259, -1, - -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, 273, 274, 275, 94, 9, -1, 279, 280, - 281, 282, 283, 284, 285, 286, -1, -1, -1, -1, - 291, 292, 293, 294, -1, 296, 297, -1, 299, -1, - -1, -1, -1, -1, 123, -1, 125, 126, -1, -1, - -1, -1, -1, -1, -1, 9, -1, 94, -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, 123, -1, -1, 126, - -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, - -1, 94, -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, - 123, -1, -1, 126, -1, -1, -1, -1, -1, -1, - 94, -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, 123, - -1, -1, 126, -1, -1, -1, -1, -1, -1, 94, - 259, -1, -1, 262, 263, 264, 265, 266, -1, -1, - -1, 270, 271, 272, 273, 274, 275, -1, -1, -1, - -1, 280, 281, 282, 283, 284, 285, 286, 123, -1, - -1, 126, 291, 292, 293, 294, -1, 296, 297, -1, - 299, -1, 259, -1, -1, 262, 263, 264, 265, 266, - 267, -1, -1, 270, 271, 272, 273, 274, 275, -1, - -1, -1, -1, 280, 281, 282, 283, 284, 285, 286, - -1, -1, -1, -1, 291, 292, 293, 294, -1, 296, - 297, -1, 299, -1, -1, -1, 259, -1, -1, 262, - 263, 264, 265, 266, -1, -1, -1, 270, 271, 272, - 273, 274, 275, -1, -1, -1, -1, 280, 281, 282, - 283, 284, 285, 286, -1, -1, -1, -1, 291, 292, - 293, 294, -1, 296, 297, 259, 299, -1, 262, 263, - 264, 265, 266, -1, -1, -1, 270, 271, 272, 273, - 274, 275, -1, -1, -1, -1, 280, 281, 282, 283, - 284, 285, 286, -1, -1, -1, -1, -1, -1, 293, - 294, -1, 296, 297, -1, 299, -1, 262, 263, 264, - 265, 266, -1, -1, -1, 270, 271, 272, 273, 274, - 275, -1, -1, -1, -1, 280, 281, 282, 283, 284, - 285, 286, -1, -1, -1, -1, -1, -1, 293, 294, - -1, 296, 297, -1, 299, -}; -#define YYFINAL 31 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 314 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,"'\\t'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'","'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"OVER", -"SMALLOVER","SQRT","SUB","SUP","LPILE","RPILE","CPILE","PILE","LEFT","RIGHT", -"TO","FROM","SIZE","FONT","ROMAN","BOLD","ITALIC","FAT","ACCENT","BAR","UNDER", -"ABOVE","TEXT","QUOTED_TEXT","FWD","BACK","DOWN","UP","MATRIX","COL","LCOL", -"RCOL","CCOL","MARK","LINEUP","TYPE","VCENTER","PRIME","SPLIT","NOSPLIT", -"UACCENT","SPECIAL","SPACE","GFONT","GSIZE","DEFINE","NDEFINE","TDEFINE", -"SDEFINE","UNDEF","IFDEF","INCLUDE","DELIM","CHARTYPE","SET","GRFONT","GBFONT", -}; -char *yyrule[] = { -"$accept : top", -"top :", -"top : equation", -"equation : mark", -"equation : equation mark", -"mark : from_to", -"mark : MARK mark", -"mark : LINEUP mark", -"from_to : sqrt_over", -"from_to : sqrt_over TO from_to", -"from_to : sqrt_over FROM sqrt_over", -"from_to : sqrt_over FROM sqrt_over TO from_to", -"from_to : sqrt_over FROM sqrt_over FROM from_to", -"sqrt_over : script", -"sqrt_over : SQRT sqrt_over", -"sqrt_over : sqrt_over OVER sqrt_over", -"sqrt_over : sqrt_over SMALLOVER sqrt_over", -"script : nonsup", -"script : simple SUP script", -"nonsup : simple", -"nonsup : simple SUB nonsup", -"nonsup : simple SUB simple SUP script", -"simple : TEXT", -"simple : QUOTED_TEXT", -"simple : SPLIT QUOTED_TEXT", -"simple : NOSPLIT TEXT", -"simple : '^'", -"simple : '~'", -"simple : '\\t'", -"simple : '{' equation '}'", -"simple : PILE pile_arg", -"simple : LPILE pile_arg", -"simple : RPILE pile_arg", -"simple : CPILE pile_arg", -"simple : MATRIX '{' column_list '}'", -"simple : LEFT delim equation RIGHT delim", -"simple : LEFT delim equation", -"simple : simple BAR", -"simple : simple UNDER", -"simple : simple PRIME", -"simple : simple ACCENT simple", -"simple : simple UACCENT simple", -"simple : ROMAN simple", -"simple : BOLD simple", -"simple : ITALIC simple", -"simple : FAT simple", -"simple : FONT text simple", -"simple : SIZE text simple", -"simple : FWD number simple", -"simple : BACK number simple", -"simple : UP number simple", -"simple : DOWN number simple", -"simple : TYPE text simple", -"simple : VCENTER simple", -"simple : SPECIAL text simple", -"number : text", -"pile_element_list : equation", -"pile_element_list : pile_element_list ABOVE equation", -"pile_arg : '{' pile_element_list '}'", -"pile_arg : number '{' pile_element_list '}'", -"column_list : column", -"column_list : column_list column", -"column_element_list : equation", -"column_element_list : column_element_list ABOVE equation", -"column_arg : '{' column_element_list '}'", -"column_arg : number '{' column_element_list '}'", -"column : COL column_arg", -"column : LCOL column_arg", -"column : RCOL column_arg", -"column : CCOL column_arg", -"text : TEXT", -"text : QUOTED_TEXT", -"delim : text", -"delim : '{'", -"delim : '}'", -}; -#endif -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#ifdef YYSTACKSIZE -#ifndef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#endif -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#define YYABORT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", yystate, - yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, shifting to state %d\n", - yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, error recovery shifting\ - to state %d\n", *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("yydebug: error recovery discarding state %d\n", - *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, error recovery discards token %d (%s)\n", - yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, reducing by rule %d (%s)\n", - yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 2: -#line 126 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].b->top_level(); non_empty_flag = 1; } -break; -case 3: -#line 131 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 4: -#line 133 "/u/jjc/groff/eqn/eqn.y" -{ - list_box *lb = yyvsp[-1].b->to_list_box(); - if (!lb) - lb = new list_box(yyvsp[-1].b); - lb->append(yyvsp[0].b); - yyval.b = lb; - } -break; -case 5: -#line 144 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 6: -#line 146 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_mark_box(yyvsp[0].b); } -break; -case 7: -#line 148 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_lineup_box(yyvsp[0].b); } -break; -case 8: -#line 153 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 9: -#line 155 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_limit_box(yyvsp[-2].b, 0, yyvsp[0].b); } -break; -case 10: -#line 157 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_limit_box(yyvsp[-2].b, yyvsp[0].b, 0); } -break; -case 11: -#line 159 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_limit_box(yyvsp[-4].b, yyvsp[-2].b, yyvsp[0].b); } -break; -case 12: -#line 161 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_limit_box(yyvsp[-4].b, make_limit_box(yyvsp[-2].b, yyvsp[0].b, 0), 0); } -break; -case 13: -#line 166 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 14: -#line 168 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_sqrt_box(yyvsp[0].b); } -break; -case 15: -#line 170 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_over_box(yyvsp[-2].b, yyvsp[0].b); } -break; -case 16: -#line 172 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_small_over_box(yyvsp[-2].b, yyvsp[0].b); } -break; -case 17: -#line 177 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 18: -#line 179 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_script_box(yyvsp[-2].b, 0, yyvsp[0].b); } -break; -case 19: -#line 184 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[0].b; } -break; -case 20: -#line 186 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_script_box(yyvsp[-2].b, yyvsp[0].b, 0); } -break; -case 21: -#line 188 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_script_box(yyvsp[-4].b, yyvsp[-2].b, yyvsp[0].b); } -break; -case 22: -#line 193 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = split_text(yyvsp[0].str); } -break; -case 23: -#line 195 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new quoted_text_box(yyvsp[0].str); } -break; -case 24: -#line 197 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = split_text(yyvsp[0].str); } -break; -case 25: -#line 199 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new quoted_text_box(yyvsp[0].str); } -break; -case 26: -#line 201 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new half_space_box; } -break; -case 27: -#line 203 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new space_box; } -break; -case 28: -#line 205 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new tab_box; } -break; -case 29: -#line 207 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[-1].b; } -break; -case 30: -#line 209 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].pb->set_alignment(CENTER_ALIGN); yyval.b = yyvsp[0].pb; } -break; -case 31: -#line 211 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].pb->set_alignment(LEFT_ALIGN); yyval.b = yyvsp[0].pb; } -break; -case 32: -#line 213 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].pb->set_alignment(RIGHT_ALIGN); yyval.b = yyvsp[0].pb; } -break; -case 33: -#line 215 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].pb->set_alignment(CENTER_ALIGN); yyval.b = yyvsp[0].pb; } -break; -case 34: -#line 217 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = yyvsp[-1].mb; } -break; -case 35: -#line 219 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_delim_box(yyvsp[-3].str, yyvsp[-2].b, yyvsp[0].str); } -break; -case 36: -#line 221 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_delim_box(yyvsp[-1].str, yyvsp[0].b, 0); } -break; -case 37: -#line 223 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_overline_box(yyvsp[-1].b); } -break; -case 38: -#line 225 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_underline_box(yyvsp[-1].b); } -break; -case 39: -#line 227 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_prime_box(yyvsp[-1].b); } -break; -case 40: -#line 229 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_accent_box(yyvsp[-2].b, yyvsp[0].b); } -break; -case 41: -#line 231 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_uaccent_box(yyvsp[-2].b, yyvsp[0].b); } -break; -case 42: -#line 233 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new font_box(strsave(get_grfont()), yyvsp[0].b); } -break; -case 43: -#line 235 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new font_box(strsave(get_gbfont()), yyvsp[0].b); } -break; -case 44: -#line 237 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new font_box(strsave(get_gfont()), yyvsp[0].b); } -break; -case 45: -#line 239 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new fat_box(yyvsp[0].b); } -break; -case 46: -#line 241 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new font_box(yyvsp[-1].str, yyvsp[0].b); } -break; -case 47: -#line 243 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new size_box(yyvsp[-1].str, yyvsp[0].b); } -break; -case 48: -#line 245 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new hmotion_box(yyvsp[-1].n, yyvsp[0].b); } -break; -case 49: -#line 247 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new hmotion_box(-yyvsp[-1].n, yyvsp[0].b); } -break; -case 50: -#line 249 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new vmotion_box(yyvsp[-1].n, yyvsp[0].b); } -break; -case 51: -#line 251 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new vmotion_box(-yyvsp[-1].n, yyvsp[0].b); } -break; -case 52: -#line 253 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].b->set_spacing_type(yyvsp[-1].str); yyval.b = yyvsp[0].b; } -break; -case 53: -#line 255 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = new vcenter_box(yyvsp[0].b); } -break; -case 54: -#line 257 "/u/jjc/groff/eqn/eqn.y" -{ yyval.b = make_special_box(yyvsp[-1].str, yyvsp[0].b); } -break; -case 55: -#line 262 "/u/jjc/groff/eqn/eqn.y" -{ - int n; - if (sscanf(yyvsp[0].str, "%d", &n) == 1) - yyval.n = n; - a_delete yyvsp[0].str; - } -break; -case 56: -#line 272 "/u/jjc/groff/eqn/eqn.y" -{ yyval.pb = new pile_box(yyvsp[0].b); } -break; -case 57: -#line 274 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[-2].pb->append(yyvsp[0].b); yyval.pb = yyvsp[-2].pb; } -break; -case 58: -#line 279 "/u/jjc/groff/eqn/eqn.y" -{ yyval.pb = yyvsp[-1].pb; } -break; -case 59: -#line 281 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[-1].pb->set_space(yyvsp[-3].n); yyval.pb = yyvsp[-1].pb; } -break; -case 60: -#line 286 "/u/jjc/groff/eqn/eqn.y" -{ yyval.mb = new matrix_box(yyvsp[0].col); } -break; -case 61: -#line 288 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[-1].mb->append(yyvsp[0].col); yyval.mb = yyvsp[-1].mb; } -break; -case 62: -#line 293 "/u/jjc/groff/eqn/eqn.y" -{ yyval.col = new column(yyvsp[0].b); } -break; -case 63: -#line 295 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[-2].col->append(yyvsp[0].b); yyval.col = yyvsp[-2].col; } -break; -case 64: -#line 300 "/u/jjc/groff/eqn/eqn.y" -{ yyval.col = yyvsp[-1].col; } -break; -case 65: -#line 302 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[-1].col->set_space(yyvsp[-3].n); yyval.col = yyvsp[-1].col; } -break; -case 66: -#line 307 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].col->set_alignment(CENTER_ALIGN); yyval.col = yyvsp[0].col; } -break; -case 67: -#line 309 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].col->set_alignment(LEFT_ALIGN); yyval.col = yyvsp[0].col; } -break; -case 68: -#line 311 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].col->set_alignment(RIGHT_ALIGN); yyval.col = yyvsp[0].col; } -break; -case 69: -#line 313 "/u/jjc/groff/eqn/eqn.y" -{ yyvsp[0].col->set_alignment(CENTER_ALIGN); yyval.col = yyvsp[0].col; } -break; -case 70: -#line 317 "/u/jjc/groff/eqn/eqn.y" -{ yyval.str = yyvsp[0].str; } -break; -case 71: -#line 319 "/u/jjc/groff/eqn/eqn.y" -{ yyval.str = yyvsp[0].str; } -break; -case 72: -#line 324 "/u/jjc/groff/eqn/eqn.y" -{ yyval.str = yyvsp[0].str; } -break; -case 73: -#line 326 "/u/jjc/groff/eqn/eqn.y" -{ yyval.str = strsave("{"); } -break; -case 74: -#line 328 "/u/jjc/groff/eqn/eqn.y" -{ yyval.str = strsave("}"); } -break; -#line 1107 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state 0 to\ - state %d\n", YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", - YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state %d \ -to state %d\n", *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/gnu/usr.bin/groff/eqn/eqn.tab.h b/gnu/usr.bin/groff/eqn/eqn.tab.h deleted file mode 100644 index 9a8b3cb22595..000000000000 --- a/gnu/usr.bin/groff/eqn/eqn.tab.h +++ /dev/null @@ -1,67 +0,0 @@ -#define OVER 257 -#define SMALLOVER 258 -#define SQRT 259 -#define SUB 260 -#define SUP 261 -#define LPILE 262 -#define RPILE 263 -#define CPILE 264 -#define PILE 265 -#define LEFT 266 -#define RIGHT 267 -#define TO 268 -#define FROM 269 -#define SIZE 270 -#define FONT 271 -#define ROMAN 272 -#define BOLD 273 -#define ITALIC 274 -#define FAT 275 -#define ACCENT 276 -#define BAR 277 -#define UNDER 278 -#define ABOVE 279 -#define TEXT 280 -#define QUOTED_TEXT 281 -#define FWD 282 -#define BACK 283 -#define DOWN 284 -#define UP 285 -#define MATRIX 286 -#define COL 287 -#define LCOL 288 -#define RCOL 289 -#define CCOL 290 -#define MARK 291 -#define LINEUP 292 -#define TYPE 293 -#define VCENTER 294 -#define PRIME 295 -#define SPLIT 296 -#define NOSPLIT 297 -#define UACCENT 298 -#define SPECIAL 299 -#define SPACE 300 -#define GFONT 301 -#define GSIZE 302 -#define DEFINE 303 -#define NDEFINE 304 -#define TDEFINE 305 -#define SDEFINE 306 -#define UNDEF 307 -#define IFDEF 308 -#define INCLUDE 309 -#define DELIM 310 -#define CHARTYPE 311 -#define SET 312 -#define GRFONT 313 -#define GBFONT 314 -typedef union { - char *str; - box *b; - pile_box *pb; - matrix_box *mb; - int n; - column *col; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/groff/pic/pic.cc b/gnu/usr.bin/groff/pic/pic.cc deleted file mode 100644 index a85ff8ba1c2b..000000000000 --- a/gnu/usr.bin/groff/pic/pic.cc +++ /dev/null @@ -1,5166 +0,0 @@ -#ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; -#endif -#define YYBYACC 1 -#line 20 "/u/jjc/groff/pic/pic.y" -#include "pic.h" -#include "ptable.h" -#include "object.h" - -extern int delim_flag; -extern void do_copy(const char *); -extern void copy_rest_thru(const char *, const char *); -extern void copy_file_thru(const char *, const char *, const char *); -extern void push_body(const char *); -extern void do_for(char *var, double from, double to, - int by_is_multiplicative, double by, char *body); -extern void do_lookahead(); - -#undef fmod -#undef rand - -extern "C" { - double fmod(double, double); - int rand(); -} - -/* Maximum number of characters produced by printf("%g") */ -#define GDIGITS 14 - -int yylex(); -void yyerror(const char *); - -void reset(const char *nm); -void reset_all(); - -place *lookup_label(const char *); -void define_label(const char *label, const place *pl); - -direction current_direction; -position current_position; - -implement_ptable(place) - -PTABLE(place) top_table; - -PTABLE(place) *current_table = &top_table; -saved_state *current_saved_state = 0; - -object_list olist; - -const char *ordinal_postfix(int n); -const char *object_type_name(object_type type); -char *format_number(const char *form, double n); -char *do_sprintf(const char *form, const double *v, int nv); - -#line 73 "/u/jjc/groff/pic/pic.y" -typedef union { - char *str; - int n; - double x; - struct { double x, y; } pair; - struct { double x; char *body; } if_data; - struct { char *str; const char *filename; int lineno; } lstr; - struct { double *v; int nv; int maxv; } dv; - struct { double val; int is_multiplicative; } by; - place pl; - object *obj; - corner crn; - path *pth; - object_spec *spec; - saved_state *pstate; - graphics_state state; - object_type obtype; -} YYSTYPE; -#line 76 "y.tab.c" -#define LABEL 257 -#define VARIABLE 258 -#define NUMBER 259 -#define TEXT 260 -#define COMMAND_LINE 261 -#define DELIMITED 262 -#define ORDINAL 263 -#define TH 264 -#define LEFT_ARROW_HEAD 265 -#define RIGHT_ARROW_HEAD 266 -#define DOUBLE_ARROW_HEAD 267 -#define LAST 268 -#define UP 269 -#define DOWN 270 -#define LEFT 271 -#define RIGHT 272 -#define BOX 273 -#define CIRCLE 274 -#define ELLIPSE 275 -#define ARC 276 -#define LINE 277 -#define ARROW 278 -#define MOVE 279 -#define SPLINE 280 -#define HEIGHT 281 -#define RADIUS 282 -#define WIDTH 283 -#define DIAMETER 284 -#define FROM 285 -#define TO 286 -#define AT 287 -#define WITH 288 -#define BY 289 -#define THEN 290 -#define DOTTED 291 -#define DASHED 292 -#define CHOP 293 -#define SAME 294 -#define INVISIBLE 295 -#define LJUST 296 -#define RJUST 297 -#define ABOVE 298 -#define BELOW 299 -#define OF 300 -#define THE 301 -#define WAY 302 -#define BETWEEN 303 -#define AND 304 -#define HERE 305 -#define DOT_N 306 -#define DOT_E 307 -#define DOT_W 308 -#define DOT_S 309 -#define DOT_NE 310 -#define DOT_SE 311 -#define DOT_NW 312 -#define DOT_SW 313 -#define DOT_C 314 -#define DOT_START 315 -#define DOT_END 316 -#define DOT_X 317 -#define DOT_Y 318 -#define DOT_HT 319 -#define DOT_WID 320 -#define DOT_RAD 321 -#define SIN 322 -#define COS 323 -#define ATAN2 324 -#define LOG 325 -#define EXP 326 -#define SQRT 327 -#define K_MAX 328 -#define K_MIN 329 -#define INT 330 -#define RAND 331 -#define COPY 332 -#define THRU 333 -#define TOP 334 -#define BOTTOM 335 -#define UPPER 336 -#define LOWER 337 -#define SH 338 -#define PRINT 339 -#define CW 340 -#define CCW 341 -#define FOR 342 -#define DO 343 -#define IF 344 -#define ELSE 345 -#define ANDAND 346 -#define OROR 347 -#define NOTEQUAL 348 -#define EQUALEQUAL 349 -#define LESSEQUAL 350 -#define GREATEREQUAL 351 -#define LEFT_CORNER 352 -#define RIGHT_CORNER 353 -#define CENTER 354 -#define END 355 -#define START 356 -#define RESET 357 -#define UNTIL 358 -#define PLOT 359 -#define THICKNESS 360 -#define FILL 361 -#define ALIGNED 362 -#define SPRINTF 363 -#define COMMAND 364 -#define DEFINE 365 -#define UNDEF 366 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 0, 16, 17, 17, 28, 28, 29, 29, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 31, 30, - 30, 32, 33, 30, 34, 35, 30, 36, 30, 30, - 37, 30, 30, 30, 38, 38, 38, 26, 26, 27, - 27, 27, 39, 7, 23, 23, 2, 2, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, - 15, 15, 15, 15, 40, 42, 15, 15, 41, 41, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 43, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 25, 25, 24, 24, 19, 19, - 6, 6, 6, 6, 6, 6, 44, 44, 5, 5, - 13, 13, 13, 13, 13, 14, 14, 14, 22, 22, - 21, 21, 8, 8, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 11, 11, 12, 12, 12, 10, 10, - 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 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, -}; -short yylen[] = { 2, - 1, 1, 3, 1, 3, 0, 1, 1, 2, 3, - 4, 1, 1, 1, 1, 1, 2, 2, 0, 3, - 2, 0, 0, 7, 0, 0, 6, 0, 10, 1, - 0, 4, 1, 1, 2, 2, 3, 1, 2, 1, - 1, 1, 0, 5, 0, 2, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 2, 0, 2, 3, - 1, 4, 4, 4, 0, 0, 6, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 3, 0, 4, 3, 3, 3, 3, 2, 2, 3, - 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, - 3, 2, 2, 3, 2, 3, 2, 3, 2, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 3, 2, 1, 5, 0, 3, 1, 1, - 1, 3, 3, 5, 5, 6, 1, 4, 3, 3, - 1, 2, 2, 3, 1, 1, 1, 3, 1, 3, - 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 2, 3, 1, 1, 2, 1, 4, - 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, - 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, - 3, 3, 3, 3, 2, 3, 4, 4, 6, 4, - 4, 4, 6, 6, 4, 4, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 2, -}; -short yydefred[] = { 0, - 8, 0, 2, 0, 0, 0, 0, 125, 16, 12, - 13, 14, 15, 71, 72, 73, 74, 75, 76, 77, - 78, 0, 19, 0, 0, 0, 0, 0, 0, 0, - 65, 82, 0, 4, 0, 0, 79, 68, 0, 9, - 0, 0, 0, 0, 25, 0, 146, 202, 203, 149, - 151, 187, 188, 145, 174, 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 185, 186, 0, 0, 193, - 194, 199, 201, 200, 0, 0, 0, 0, 0, 131, - 129, 147, 0, 0, 0, 0, 0, 0, 41, 0, - 38, 0, 0, 0, 0, 0, 0, 0, 0, 35, - 0, 0, 0, 0, 0, 31, 3, 0, 113, 114, - 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 102, 0, 0, 0, 111, 112, - 119, 120, 121, 122, 116, 117, 0, 0, 124, 0, - 118, 36, 0, 0, 10, 0, 22, 0, 20, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, - 191, 195, 197, 190, 192, 196, 198, 0, 0, 0, - 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 204, 205, 206, 207, 208, 0, - 142, 0, 0, 163, 155, 156, 157, 158, 159, 160, - 161, 0, 154, 152, 153, 39, 0, 0, 57, 0, - 0, 0, 43, 0, 0, 0, 0, 81, 127, 0, - 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 166, 100, 0, 169, 0, 0, 101, 0, 0, 0, - 0, 0, 37, 0, 0, 0, 0, 0, 0, 62, - 0, 11, 0, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 227, 0, 216, 140, 0, 150, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 148, 132, - 133, 162, 0, 0, 53, 0, 0, 0, 0, 0, - 51, 0, 0, 50, 49, 0, 66, 83, 32, 173, - 0, 0, 0, 164, 0, 168, 0, 0, 23, 0, - 217, 218, 0, 220, 221, 222, 0, 0, 225, 226, - 0, 0, 0, 0, 0, 44, 0, 126, 0, 0, - 172, 171, 165, 0, 0, 27, 0, 0, 0, 134, - 138, 0, 0, 0, 0, 70, 67, 170, 24, 46, - 219, 223, 224, 136, 0, 0, 0, 0, 28, 0, - 0, 29, -}; -short yydgoto[] = { 2, - 105, 179, 107, 396, 90, 91, 33, 92, 93, 262, - 263, 264, 108, 95, 34, 3, 35, 36, 96, 223, - 97, 98, 376, 336, 109, 100, 101, 241, 5, 38, - 46, 283, 374, 158, 350, 401, 243, 39, 329, 114, - 387, 369, 115, 202, -}; -short yysindex[] = { -52, - 0, 0, 0, 5088, -25, -11, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -243, 0,10878, -206,11047, -204,11505, 19,10878, - 0, 0, -275, 0, -52,10742, 0, 0, -42, 0, - -52,11047, 16, -239, 0, -165, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 71, 93, 98, 106, 108, - 120, 139, 147, 153, 156, 0, 0, -110, 44, 0, - 0, 0, 0, 0,11177,11047,11505,11505, 1055, 0, - 0, 0, -45, -61, 2441, -19, 747, 312, 0,10878, - 0, 152,11047,11047, 1515, -89, -228, -61, -98, 0, - 637, -38,10878, -52, -52, 0, 0, 9673, 0, 0, - 0,11829,11829,11829,11829,11505,11505,11505,11505,11621, -11621,11621, 2099,11726, 0,11829,11829,11829, 0, 0, - 0, 0, 0, 0, 0, 0,11505,11829, 0, 1527, - 0, 0, -41,10520, 0,11047, 0, -32, 0,11047, -11047,11047,11047,11047,11047,11047,11047,11047, 9002, 0, - 0, 0, 0, 0, 0, 0, 0, 1494, 183, 187, - -4, -30, 143, 143, -53, 0,11505,11505,11505,11505, -11505,11505,11505,11621,11505,11505,11505,11505,11505,11505, -11505,11621, -43, 199, 0, 0, 0, 0, 0, -17, - 0,11726,11726, 0, 0, 0, 0, 0, 0, 0, - 0, 168, 0, 0, 0, 0,11505, 143, 0,11047, -11047,11505, 0,11047,11047, -229, -229, 0, 0, 148, - 5088, 171, 15, 0, 1527, 1527, 1527, 1527, 1527, 1527, - 1527, 1527, 1055, -19, -19, -19, 1989, 699, 747, 23, - 0, 0, 2428, 0,11284, 648, 0, 1527, 1527, 1527, - 1527, 1527, 0, -11, 21, 0, 0, 0, -61, 0, - -19, 0, 17, 0, 240, 244, 242, 249, 255, 257, - 256, 258, 260, 0, 262, 0, 0,11621, 0, -9, - -27, 184, 252, 252, 1, 1, 1527, -34, 40, 1, - 155, 155, 143, 143, 143, 143, -22, 199, 0, 0, - 0, 0, 1088, -27, 0, 1048, -40, 1, 42, -27, - 0, 1048, -40, 0, 0, 47, 0, 0, 0, 0, - 747, 1989, 1989, 0, 48, 0, 1076, 187, 0, -51, - 0, 0,11047, 0, 0, 0,11047,11047, 0, 0, - 100, 5,11621,11621,11505, 0,11505, 0, 5088, 1989, - 0, 0, 0, -51, 49, 0, 272, 284, 287, 0, - 0, 30, -19, 1487, 1527, 0, 0, 0, 0, 0, - 0, 0, 0, 0,11385, -14,11505, 1527, 0, 1527, - 72, 0, -}; -short yyrindex[] = { 219, - 0, 0, 0, 344, 109, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, - 0, 0, 57, 0, 65, 58, 0, 0, 390, 0, -10629, 0, 0, 412, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 9146, 0, - 0, 0, 0, 4421, 8691, 9247, 0, 0, 0, 500, - 0, 0, 0, 0, 411, 0, 564, 0, 0, 0, -10123, 0, 508, 5512, 5512, 0, 0, 122, 0, 0, - 0, 66, 9595, 9353, 9486, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9700, 9804, 9909, 0, 0, - 0, 0, 0, 0, 0, 0, 0,10013, 0, 4967, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 304, 0, 227, - 0, 0, 469, 577, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3104, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0,10455, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5284, 5391, 5708, 5815, 6132, 6239, - 6556, 6663, 0, 6980, 7087, 7404, 0, 0, 0, 0, - 0, 0, 8873, 0, 0, 0, 0, 7511, 7828, 7935, - 8252, 8359, 0,10222, 1933, 1729, 3046, 919, 947, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3982, 4089, 3211, 3543, 2226, 2333, 4860, 8766, 0, 2665, - 1787, 1894, 909, 1016, 1348, 1455, 0, 3650, 0, 0, - 0, 0, 0, 8845, 0, 27, 28, 2772, 0, 140, - 0, 194, 195, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 304, 0, 0, 547, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 575, 0, - 0, 0, 0, 547, 0, 0, 0, 0, 0, 0, - 0, 0, 4528, 33, 52, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 50, 0, 51, - 0, 0, -}; -short yygindex[] = { 0, - -24, 498, -99, 0, -56, 237, 0, 0, -59, 0, - 0, -215, 515, -74, -117, 161, 0, 0, 1810, -73, - 0, 0, 18, 0, 26, 368, -68, 14, 364, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -}; -#define YYTABLESIZE 12185 -short yytable[] = { 89, - 244, 153, 200, 111, 229, 89, 1, 198, 196, 200, - 197, 150, 199, 4, 198, 196, 44, 197, 204, 199, - 212, 34, 213, 212, 225, 213, 235, 56, 180, 37, - 8, 226, 232, 40, 195, 211, 280, 200, 212, 298, - 213, 340, 198, 196, 226, 197, 41, 199, 117, 99, - 86, 102, 86, 110, 154, 99, 30, 61, 112, 201, - 178, 151, 183, 184, 6, 89, 201, 235, 56, 116, - 235, 56, 212, 261, 213, 89, 156, 267, 43, 228, - 34, 42, 212, 363, 213, 235, 56, 368, 89, 45, - 367, 394, 128, 157, 201, 128, 159, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 253, 253, 7, 266, - 160, 268, 269, 270, 34, 30, 61, 234, 235, 235, - 56, 7, 271, 272, 89, 99, 371, 372, 318, 253, - 325, 327, 161, 29, 331, 333, 238, 162, 99, 52, - 380, 7, 212, 37, 213, 163, 34, 164, 7, 30, - 61, 235, 56, 7, 388, 320, 321, 6, 89, 165, - 170, 171, 301, 302, 303, 304, 305, 306, 307, 308, - 310, 311, 312, 313, 314, 315, 316, 253, 166, 37, - 52, 30, 61, 52, 342, 343, 167, 266, 266, 6, - 89, 200, 168, 55, 54, 169, 198, 261, 52, 7, - 233, 199, 323, 346, 7, 324, 326, 328, 348, 330, - 332, 47, 227, 47, 7, 152, 273, 50, 6, 50, - 200, 239, 51, 296, 51, 198, 196, 297, 197, 284, - 199, 7, 52, 299, 55, 54, 201, 55, 54, 319, - 347, 172, 173, 232, 210, 195, 7, 300, 201, 236, - 237, 386, 55, 54, 203, 205, 206, 207, 208, 209, - 322, 334, 335, 338, 52, 185, 37, 370, 186, 131, - 131, 131, 337, 253, 240, 242, 339, 201, 349, 344, - 351, 364, 261, 261, 352, 353, 55, 54, 200, 354, - 235, 56, 362, 198, 196, 355, 197, 356, 199, 357, - 359, 358, 360, 366, 373, 234, 375, 381, 390, 6, - 261, 232, 391, 195, 174, 175, 235, 56, 55, 54, - 189, 190, 191, 192, 392, 89, 235, 393, 399, 235, - 89, 89, 89, 402, 89, 89, 89, 89, 253, 253, - 384, 6, 385, 1, 47, 201, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 7, 7, 7, 7, 7, - 398, 7, 400, 235, 56, 58, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 33, - 278, 389, 59, 60, 37, 176, 177, 113, 118, 0, - 0, 0, 222, 52, 0, 89, 89, 0, 0, 0, - 47, 21, 0, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 89, 89, 89, 89, 52, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 0, 7, 7, 7, 7, 7, 7, 33, 0, - 7, 47, 7, 0, 47, 0, 0, 55, 54, 0, - 7, 7, 7, 7, 7, 7, 0, 7, 215, 47, - 21, 7, 7, 0, 0, 6, 6, 0, 6, 6, - 0, 0, 33, 55, 54, 52, 52, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 18, - 0, 215, 0, 47, 21, 215, 0, 17, 215, 215, - 215, 215, 215, 215, 33, 215, 0, 0, 0, 0, - 0, 0, 0, 106, 0, 0, 0, 215, 215, 187, - 215, 189, 190, 191, 192, 47, 21, 0, 94, 155, - 55, 54, 0, 0, 94, 0, 45, 0, 0, 0, - 6, 0, 0, 0, 0, 0, 6, 6, 18, 0, - 6, 215, 6, 48, 215, 0, 17, 0, 0, 0, - 0, 214, 0, 0, 69, 6, 236, 6, 0, 224, - 0, 6, 6, 182, 215, 216, 217, 218, 219, 220, - 0, 221, 18, 215, 0, 0, 0, 0, 0, 94, - 17, 191, 192, 0, 48, 45, 0, 48, 0, 236, - 0, 0, 0, 236, 94, 0, 236, 236, 236, 236, - 236, 236, 48, 236, 18, 0, 0, 94, 0, 0, - 0, 0, 17, 69, 0, 236, 236, 0, 236, 45, - 0, 0, 0, 0, 94, 94, 94, 0, 0, 0, - 0, 0, 0, 282, 0, 0, 48, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 295, 69, 279, 236, - 0, 45, 236, 200, 47, 0, 0, 0, 198, 196, - 0, 197, 0, 199, 200, 0, 0, 0, 48, 198, - 196, 193, 197, 0, 199, 0, 232, 0, 195, 69, - 47, 236, 0, 0, 0, 0, 0, 232, 94, 195, - 0, 0, 0, 0, 0, 0, 94, 0, 0, 0, - 0, 0, 0, 0, 0, 215, 215, 215, 215, 0, - 201, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 201, 0, 0, 0, 0, 0, 0, 0, 215, - 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 215, 215, 215, 215, 0, - 0, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 0, 0, 0, 0, 222, - 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 0, 0, 215, 215, 215, 215, 0, 0, 215, 215, - 0, 215, 94, 0, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 0, 0, 48, 215, 215, - 215, 215, 0, 236, 236, 236, 236, 222, 0, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 0, - 377, 0, 0, 48, 378, 379, 0, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 94, 94, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 0, 0, 0, 8, 0, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 211, 0, - 236, 236, 236, 236, 0, 0, 236, 236, 63, 236, - 0, 0, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 0, 0, 0, 236, 236, 236, 236, - 0, 211, 0, 0, 0, 211, 64, 0, 211, 211, - 211, 211, 211, 211, 0, 211, 0, 0, 214, 0, - 0, 129, 0, 129, 0, 0, 341, 211, 211, 0, - 211, 215, 216, 217, 218, 219, 220, 63, 221, 0, - 0, 0, 187, 188, 189, 190, 191, 192, 0, 130, - 0, 130, 0, 187, 188, 189, 190, 191, 192, 29, - 0, 211, 0, 0, 211, 64, 214, 0, 0, 0, - 0, 63, 0, 0, 0, 212, 0, 0, 0, 215, - 216, 217, 218, 219, 220, 0, 221, 0, 0, 0, - 0, 0, 0, 211, 0, 0, 0, 0, 0, 64, - 0, 0, 0, 63, 0, 0, 0, 0, 212, 0, - 0, 0, 212, 0, 0, 212, 212, 212, 212, 212, - 212, 0, 212, 0, 0, 0, 0, 0, 0, 0, - 0, 64, 0, 0, 212, 212, 0, 212, 0, 0, - 0, 0, 0, 0, 200, 0, 0, 0, 0, 198, - 196, 200, 197, 0, 199, 0, 198, 196, 193, 197, - 0, 199, 0, 0, 0, 0, 0, 232, 212, 195, - 0, 212, 200, 0, 194, 0, 195, 198, 196, 193, - 197, 0, 199, 0, 200, 0, 0, 0, 0, 198, - 196, 0, 197, 0, 199, 232, 0, 195, 0, 0, - 212, 201, 0, 0, 0, 0, 0, 232, 201, 195, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 211, 211, 211, 211, 201, - 0, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 211, 201, 0, 0, 0, 0, 0, 0, 0, 211, - 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 211, 211, 211, 211, 0, - 0, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 0, 0, 0, 0, 0, - 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 0, 0, 211, 211, 211, 211, 0, 0, 211, 211, - 0, 211, 0, 0, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 0, 0, 0, 211, 211, - 211, 211, 212, 212, 212, 212, 0, 0, 212, 212, - 212, 212, 212, 212, 212, 212, 212, 212, 0, 0, - 0, 0, 0, 0, 0, 0, 212, 212, 212, 212, - 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, - 212, 212, 212, 212, 212, 212, 0, 0, 212, 212, - 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, - 212, 212, 0, 0, 0, 0, 0, 212, 212, 212, - 212, 212, 212, 212, 212, 212, 212, 213, 0, 212, - 212, 212, 212, 0, 185, 212, 212, 186, 212, 0, - 0, 212, 212, 212, 212, 212, 212, 212, 212, 212, - 212, 212, 0, 365, 0, 212, 212, 212, 212, 0, - 213, 0, 0, 0, 213, 0, 0, 213, 213, 213, - 213, 213, 213, 230, 213, 189, 190, 191, 192, 0, - 187, 188, 189, 190, 191, 192, 213, 213, 0, 213, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 230, 231, 189, 190, 191, 192, 0, 0, 0, - 0, 0, 0, 187, 188, 189, 190, 191, 192, 0, - 213, 0, 0, 213, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 214, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 213, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, - 0, 214, 0, 0, 214, 214, 214, 214, 214, 214, - 0, 214, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 214, 214, 0, 214, 0, 0, 0, - 0, 0, 0, 200, 0, 0, 0, 0, 198, 196, - 200, 197, 0, 199, 0, 198, 196, 193, 197, 0, - 199, 0, 0, 0, 0, 0, 232, 214, 195, 0, - 214, 200, 0, 194, 0, 195, 198, 196, 0, 197, - 0, 199, 0, 200, 0, 0, 0, 0, 198, 196, - 0, 197, 0, 199, 232, 0, 195, 0, 0, 214, - 201, 0, 0, 0, 0, 0, 232, 201, 195, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 213, 213, 213, 213, 201, 0, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 201, 0, 0, 0, 0, 0, 0, 0, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 0, 0, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 0, 0, 0, 0, 0, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 0, - 0, 213, 213, 213, 213, 0, 0, 213, 213, 0, - 213, 0, 0, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 0, 0, 0, 213, 213, 213, - 213, 214, 214, 214, 214, 0, 0, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 0, 14, 0, - 0, 0, 0, 0, 0, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 0, 0, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 0, 0, 0, 0, 395, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 209, 14, 214, 214, - 214, 214, 0, 185, 214, 214, 186, 214, 0, 0, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 0, 0, 0, 214, 214, 214, 214, 0, 209, - 0, 14, 0, 0, 187, 0, 209, 209, 0, 209, - 209, 209, 187, 188, 189, 190, 191, 192, 0, 230, - 231, 189, 190, 191, 192, 209, 209, 0, 209, 0, - 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, - 230, 231, 189, 190, 191, 192, 0, 0, 0, 0, - 0, 0, 187, 188, 189, 190, 191, 192, 0, 209, - 0, 0, 209, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 210, 181, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 210, 0, 0, 0, - 0, 0, 0, 210, 210, 0, 210, 210, 210, 254, - 255, 256, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 210, 210, 0, 210, 0, 0, 0, 0, - 0, 0, 0, 281, 0, 0, 0, 0, 0, 202, - 0, 0, 0, 0, 202, 202, 202, 202, 0, 202, - 0, 0, 0, 0, 0, 187, 210, 0, 0, 210, - 0, 187, 202, 0, 202, 0, 187, 0, 0, 0, - 0, 0, 0, 309, 0, 0, 0, 0, 0, 0, - 0, 317, 0, 0, 0, 0, 0, 0, 210, 0, - 0, 0, 0, 0, 0, 0, 202, 0, 187, 0, - 0, 0, 0, 0, 260, 0, 0, 0, 0, 0, - 0, 0, 0, 209, 209, 209, 209, 0, 0, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 0, - 0, 0, 0, 0, 0, 0, 0, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 0, 0, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 0, 0, 0, 0, 361, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 0, 0, - 209, 209, 209, 209, 0, 0, 209, 209, 0, 209, - 0, 0, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 0, 260, 0, 209, 209, 209, 209, - 210, 210, 210, 210, 0, 0, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 0, 0, 0, 0, - 0, 0, 382, 383, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 0, 0, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 0, 0, 0, 0, 0, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 229, 0, 210, 210, 210, - 210, 0, 202, 210, 210, 202, 210, 0, 0, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 0, 0, 0, 210, 210, 210, 210, 0, 229, 52, - 53, 0, 0, 0, 0, 229, 229, 0, 0, 229, - 0, 0, 0, 0, 0, 0, 0, 0, 202, 202, - 202, 202, 202, 202, 229, 229, 0, 229, 0, 0, - 0, 0, 0, 0, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 229, 0, - 0, 229, 76, 77, 78, 79, 0, 0, 0, 0, - 0, 0, 231, 0, 0, 0, 0, 0, 0, 0, - 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, - 229, 0, 0, 0, 0, 257, 0, 0, 0, 0, - 0, 258, 0, 0, 0, 231, 259, 0, 0, 52, - 53, 0, 231, 231, 0, 0, 231, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 231, 231, 0, 231, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 231, 0, 0, 231, 0, - 0, 0, 76, 77, 78, 79, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 81, 82, 83, 84, 0, 0, 231, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 345, 0, 0, 0, 0, 0, 0, - 0, 0, 229, 229, 229, 229, 210, 0, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 0, 0, - 0, 0, 0, 0, 0, 0, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 0, 0, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 0, 0, 0, 0, 0, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 0, 0, 229, - 229, 229, 229, 0, 0, 229, 229, 0, 229, 0, - 0, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 0, 0, 0, 229, 229, 229, 229, 231, - 231, 231, 231, 0, 0, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 0, 0, 0, 0, 0, - 0, 0, 0, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 0, 0, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 0, - 0, 0, 0, 0, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 230, 0, 231, 231, 231, 231, - 0, 0, 231, 231, 0, 231, 0, 0, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 0, - 0, 0, 231, 231, 231, 231, 0, 230, 52, 53, - 0, 0, 0, 0, 230, 230, 0, 0, 230, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 230, 230, 0, 230, 0, 0, 0, - 0, 0, 0, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 0, 0, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 230, 0, 0, - 230, 76, 77, 78, 79, 0, 0, 0, 0, 0, - 0, 228, 0, 0, 76, 77, 78, 79, 0, 80, - 81, 82, 83, 84, 0, 0, 0, 0, 0, 230, - 0, 0, 80, 81, 82, 83, 84, 0, 0, 0, - 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, - 0, 228, 228, 0, 0, 228, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 228, 228, 0, 228, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 228, 0, 0, 228, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 230, 230, 230, 230, 0, 0, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 0, 0, 0, - 0, 0, 0, 0, 0, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 0, 0, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 0, 0, 0, 0, 0, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 0, 0, 230, 230, - 230, 230, 0, 0, 230, 230, 0, 230, 0, 0, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 0, 0, 0, 230, 230, 230, 230, 228, 228, - 228, 228, 0, 0, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 0, 15, 0, 0, 0, 0, - 0, 0, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 0, 0, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 0, 0, - 0, 0, 0, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 143, 15, 228, 228, 228, 228, 0, - 0, 228, 228, 0, 228, 0, 0, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 0, 0, - 0, 228, 228, 228, 228, 0, 143, 0, 15, 0, - 0, 188, 0, 143, 143, 0, 143, 143, 143, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 143, 0, 0, 143, 0, 0, 0, 0, - 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 143, 0, 0, 143, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 143, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 233, 0, 0, 0, 0, 0, 0, - 233, 233, 0, 0, 233, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 188, 233, 0, 0, 233, 0, 188, 0, - 0, 0, 0, 188, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 233, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 188, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 143, 143, 143, 143, 0, 0, 143, 0, 143, 143, - 143, 143, 143, 143, 143, 143, 0, 0, 0, 0, - 0, 0, 0, 0, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 0, 0, 0, 0, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 0, 0, 143, 143, 143, - 143, 0, 0, 143, 143, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 143, 143, 143, 143, 143, - 0, 0, 0, 143, 143, 143, 143, 233, 233, 233, - 233, 0, 0, 233, 233, 233, 233, 233, 233, 233, - 233, 233, 233, 0, 0, 0, 0, 0, 0, 0, - 0, 233, 233, 233, 233, 233, 233, 233, 233, 233, - 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, - 233, 0, 0, 233, 233, 233, 233, 233, 233, 233, - 233, 233, 233, 233, 233, 233, 233, 0, 0, 0, - 0, 0, 233, 233, 233, 233, 233, 233, 233, 233, - 233, 233, 232, 0, 233, 233, 233, 233, 0, 0, - 233, 233, 0, 233, 0, 0, 233, 233, 233, 233, - 0, 0, 233, 233, 233, 233, 233, 0, 0, 0, - 233, 233, 233, 233, 0, 232, 0, 0, 0, 0, - 0, 0, 232, 232, 0, 0, 232, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 232, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 232, 0, 0, 232, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 232, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 144, 0, 0, 0, 0, 0, 0, 144, - 144, 0, 144, 144, 144, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 144, 0, - 0, 144, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 144, 0, 0, 144, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 144, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, - 232, 232, 232, 0, 0, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 0, 0, 0, 0, 0, - 0, 0, 0, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 0, 0, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, 232, 0, - 0, 0, 0, 0, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 0, 0, 232, 232, 232, 232, - 0, 0, 232, 232, 0, 232, 0, 0, 232, 232, - 232, 232, 0, 0, 232, 232, 232, 232, 232, 0, - 0, 0, 232, 232, 232, 232, 144, 144, 144, 144, - 0, 0, 144, 0, 144, 144, 144, 144, 144, 144, - 144, 144, 0, 0, 0, 0, 0, 0, 0, 0, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 0, - 0, 0, 0, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 234, 0, 144, 144, 144, 144, 0, 0, 144, - 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 144, 144, 144, 144, 144, 0, 0, 0, 144, - 144, 144, 144, 0, 234, 0, 0, 0, 0, 0, - 0, 234, 234, 0, 0, 234, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 234, 0, 0, 234, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 235, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 234, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 235, 0, 0, 0, 0, 0, 0, 235, 235, - 0, 0, 235, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 235, 0, 0, 235, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 235, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 234, 234, - 234, 234, 0, 0, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 0, 0, 0, 0, 0, 0, - 0, 0, 234, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 0, 0, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 0, 0, - 0, 0, 0, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 0, 0, 234, 234, 234, 234, 0, - 0, 234, 234, 0, 234, 0, 0, 234, 234, 0, - 0, 0, 0, 234, 234, 234, 234, 234, 0, 0, - 0, 234, 234, 234, 234, 235, 235, 235, 235, 0, - 0, 235, 235, 235, 235, 235, 235, 235, 235, 235, - 235, 0, 0, 0, 0, 0, 0, 0, 0, 235, - 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, - 235, 235, 235, 235, 235, 235, 235, 235, 235, 0, - 0, 235, 235, 235, 235, 235, 235, 235, 235, 235, - 235, 235, 235, 235, 235, 0, 0, 0, 0, 0, - 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, - 130, 0, 235, 235, 235, 235, 0, 0, 235, 235, - 0, 235, 0, 0, 0, 235, 0, 0, 0, 0, - 235, 235, 235, 235, 235, 0, 0, 0, 235, 235, - 235, 235, 0, 130, 0, 0, 0, 0, 0, 0, - 130, 130, 0, 130, 130, 130, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, - 0, 0, 130, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 130, 0, 0, 130, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 135, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 130, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 135, 0, 0, 0, 0, 0, 0, 135, 135, 0, - 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 135, 0, 0, 135, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 135, 0, 0, 135, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 130, 130, 130, - 130, 0, 0, 130, 0, 130, 130, 130, 130, 130, - 130, 130, 130, 0, 0, 0, 0, 0, 0, 0, - 0, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 0, 0, 0, 0, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 0, 0, 0, - 0, 0, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 0, 0, 130, 130, 130, 130, 0, 0, - 130, 130, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 130, 130, 130, 130, 130, 0, 0, 0, - 130, 130, 130, 130, 135, 135, 135, 135, 0, 0, - 135, 0, 135, 135, 135, 135, 135, 135, 135, 135, - 0, 0, 0, 0, 0, 0, 0, 0, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 0, 0, 0, - 0, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 0, 0, 0, 0, 0, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 139, - 0, 135, 135, 135, 135, 0, 0, 135, 135, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, - 135, 135, 135, 135, 0, 0, 0, 135, 135, 135, - 135, 0, 139, 0, 0, 0, 0, 0, 0, 139, - 139, 0, 0, 139, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 139, 0, 0, 139, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 139, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, - 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, - 0, 0, 88, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 139, 139, 139, 139, - 0, 0, 139, 0, 139, 139, 139, 139, 139, 139, - 139, 139, 0, 0, 0, 0, 0, 0, 0, 0, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 0, - 0, 0, 0, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 0, 0, 32, 0, - 0, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 0, 0, 139, 139, 139, 139, 0, 0, 139, - 139, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 31, 139, 139, 139, 139, 139, 0, 0, 0, 139, - 139, 139, 139, 88, 88, 88, 88, 0, 0, 88, - 0, 88, 88, 88, 88, 88, 88, 88, 88, 0, - 0, 0, 0, 0, 0, 0, 0, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 0, 0, 0, 0, - 0, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 90, 0, 0, 0, 0, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 0, 0, - 88, 88, 88, 88, 0, 0, 88, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 90, 0, 88, 88, - 88, 88, 88, 90, 0, 0, 88, 88, 88, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 90, 0, 6, 7, 0, 8, 9, 0, - 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 90, 0, 0, 90, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 90, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, - 0, 0, 0, 92, 0, 23, 24, 0, 0, 25, - 92, 26, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 27, 0, 28, 0, 0, 92, - 29, 30, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 92, 0, 0, 92, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 92, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 90, 90, 90, 90, 0, 0, 90, 0, 90, 90, - 90, 90, 90, 90, 90, 90, 0, 0, 0, 0, - 0, 0, 0, 0, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 0, 0, 0, 0, 0, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 0, 0, 6, 0, 0, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 0, 0, 90, 90, 90, - 90, 0, 0, 90, 90, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 90, 90, 90, 90, 90, - 0, 0, 0, 90, 90, 90, 90, 92, 92, 92, - 92, 0, 0, 92, 0, 92, 92, 92, 92, 92, - 92, 92, 92, 0, 0, 0, 0, 0, 0, 0, - 0, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 0, 0, 0, 0, 0, 92, 92, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 92, 96, 0, 0, - 0, 0, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 0, 0, 92, 92, 92, 92, 0, 0, - 92, 92, 0, 0, 0, 0, 0, 0, 0, 0, - 96, 0, 92, 92, 92, 92, 92, 96, 0, 0, - 92, 92, 92, 92, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 96, 0, 6, 6, - 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, - 96, 0, 0, 96, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 94, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 0, 0, 0, 94, 0, 6, - 6, 0, 0, 6, 94, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, - 6, 0, 0, 94, 6, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, - 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 96, 96, 96, 96, 0, 0, - 96, 0, 96, 96, 96, 96, 96, 96, 96, 96, - 0, 0, 0, 0, 0, 0, 0, 0, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 0, 0, 0, - 0, 0, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 0, 0, 0, 0, 0, 96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 0, - 0, 96, 96, 96, 96, 0, 0, 96, 96, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, - 96, 96, 96, 96, 0, 0, 0, 96, 96, 96, - 96, 94, 94, 94, 94, 0, 0, 94, 0, 94, - 94, 94, 94, 94, 94, 94, 94, 0, 0, 0, - 0, 0, 0, 0, 0, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 0, 0, 0, 0, 0, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 84, 0, 0, 0, 0, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 0, 0, 94, 94, - 94, 94, 0, 0, 94, 94, 0, 0, 0, 0, - 0, 0, 0, 0, 84, 0, 94, 94, 94, 94, - 94, 84, 0, 0, 94, 94, 94, 94, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 84, 0, 0, 84, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 85, 0, 0, 0, 0, 0, 0, 85, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 85, 0, 0, 85, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 84, 84, - 84, 84, 0, 0, 84, 0, 84, 84, 84, 84, - 84, 84, 84, 84, 0, 0, 0, 0, 0, 0, - 0, 0, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 0, 0, 0, 0, 0, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 0, 0, - 0, 0, 0, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 0, 0, 84, 84, 84, 84, 0, - 0, 84, 84, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 84, 84, 84, 84, 84, 0, 0, - 0, 84, 84, 84, 84, 85, 85, 85, 85, 0, - 0, 85, 0, 85, 85, 85, 85, 85, 85, 85, - 85, 0, 0, 0, 0, 0, 0, 0, 0, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 0, 0, - 0, 0, 0, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 86, 0, 0, 0, 0, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 0, 0, 85, 85, 85, 85, 0, 0, 85, 85, - 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, - 85, 85, 85, 85, 85, 86, 0, 0, 85, 85, - 85, 85, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, - 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, - 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 87, 0, 0, 87, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 86, 86, 86, 86, 0, 0, 86, 0, - 86, 86, 86, 86, 86, 86, 86, 86, 0, 0, - 0, 0, 0, 0, 0, 0, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 0, 0, 0, 0, 0, - 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 86, 86, 0, 0, 0, 0, 0, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 0, 0, 86, - 86, 86, 86, 0, 0, 86, 86, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 86, 86, 86, - 86, 86, 0, 0, 0, 86, 86, 86, 86, 87, - 87, 87, 87, 0, 0, 87, 0, 87, 87, 87, - 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 0, 0, 0, 0, 0, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 97, - 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 0, 0, 87, 87, 87, 87, - 0, 0, 87, 87, 0, 0, 0, 0, 0, 0, - 0, 0, 97, 0, 87, 87, 87, 87, 87, 97, - 0, 0, 87, 87, 87, 87, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 97, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 97, 0, 0, 97, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 98, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 97, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, - 0, 0, 0, 0, 0, 0, 98, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 98, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, - 0, 0, 98, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 98, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 97, 97, 97, 97, - 0, 0, 97, 0, 97, 97, 97, 97, 97, 97, - 97, 97, 0, 0, 0, 0, 0, 0, 0, 0, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 0, - 0, 0, 0, 0, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 0, 0, 0, 0, - 0, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 0, 0, 97, 97, 97, 97, 0, 0, 97, - 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 97, 97, 97, 97, 97, 0, 0, 0, 97, - 97, 97, 97, 98, 98, 98, 98, 0, 0, 98, - 0, 98, 98, 98, 98, 98, 98, 98, 98, 0, - 0, 0, 0, 0, 0, 0, 0, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 0, 0, 0, 0, - 0, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 99, 0, 0, 0, 0, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 0, 0, - 98, 98, 98, 98, 0, 0, 98, 98, 0, 0, - 0, 0, 0, 0, 0, 0, 99, 0, 98, 98, - 98, 98, 98, 99, 0, 0, 98, 98, 98, 98, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 99, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 99, 0, 0, 99, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 99, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, - 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 104, 0, 0, 104, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 99, 99, 99, 99, 0, 0, 99, 0, 99, 99, - 99, 99, 99, 99, 99, 99, 0, 0, 0, 0, - 0, 0, 0, 0, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 0, 0, 0, 0, 0, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 0, 0, 0, 0, 0, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 0, 0, 99, 99, 99, - 99, 0, 0, 99, 99, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 99, 99, 99, 99, 99, - 0, 0, 0, 99, 99, 99, 99, 104, 104, 104, - 104, 0, 0, 104, 0, 104, 104, 104, 104, 104, - 104, 104, 104, 0, 0, 0, 0, 0, 0, 0, - 0, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 0, 0, 0, 0, 0, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 106, 0, 0, - 0, 0, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 0, 0, 104, 104, 104, 104, 0, 0, - 104, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 106, 0, 104, 104, 104, 104, 104, 106, 0, 0, - 104, 104, 104, 104, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 106, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 106, 0, 0, 106, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 106, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, - 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, - 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 106, 106, 106, 106, 0, 0, - 106, 0, 106, 106, 106, 106, 106, 106, 106, 106, - 0, 0, 0, 0, 0, 0, 0, 0, 106, 106, - 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - 106, 106, 106, 106, 106, 106, 106, 0, 0, 0, - 0, 0, 106, 106, 106, 106, 106, 106, 106, 106, - 106, 106, 106, 106, 0, 0, 0, 0, 0, 106, - 106, 106, 106, 106, 106, 106, 106, 106, 106, 0, - 0, 106, 106, 106, 106, 0, 0, 106, 106, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, - 106, 106, 106, 106, 0, 0, 0, 106, 106, 106, - 106, 110, 110, 110, 110, 0, 0, 110, 0, 110, - 110, 110, 110, 110, 110, 110, 110, 0, 0, 0, - 0, 0, 0, 0, 0, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 0, 0, 0, 0, 0, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 123, 0, 0, 0, 0, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 0, 0, 110, 110, - 110, 110, 0, 0, 110, 110, 0, 0, 0, 0, - 0, 0, 0, 0, 123, 0, 110, 110, 110, 110, - 110, 123, 0, 0, 110, 110, 110, 110, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 123, 0, 0, 123, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 108, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 108, 0, 0, 0, 0, 0, 0, 108, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 108, 0, 0, 108, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 123, 123, - 123, 123, 0, 0, 123, 0, 123, 123, 123, 123, - 123, 123, 123, 123, 0, 0, 0, 0, 0, 0, - 0, 0, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 0, 0, 0, 0, 0, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 0, 0, - 0, 0, 0, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 0, 0, 123, 123, 123, 123, 0, - 0, 123, 123, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 123, 123, 123, 123, 123, 0, 0, - 0, 123, 123, 123, 123, 108, 108, 108, 108, 0, - 0, 108, 0, 108, 108, 108, 108, 108, 108, 108, - 108, 0, 0, 0, 0, 0, 0, 0, 0, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 0, 0, - 0, 0, 0, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 0, 0, 0, 0, 0, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 141, 0, 108, 108, 108, 108, 0, 0, 108, 108, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 108, 108, 108, 108, 108, 0, 0, 0, 108, 108, - 108, 108, 0, 141, 0, 0, 0, 0, 0, 0, - 141, 141, 0, 141, 141, 141, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, - 0, 0, 141, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 141, 0, 0, 141, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, - 0, 0, 0, 0, 0, 228, 228, 0, 0, 228, - 0, 0, 0, 0, 0, 141, 0, 0, 0, 0, - 0, 0, 0, 0, 228, 228, 0, 228, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 234, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, - 0, 228, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 167, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 234, 0, 0, 234, 0, - 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 234, 0, 167, 0, 0, 0, 0, - 0, 0, 167, 0, 0, 0, 0, 167, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 167, 0, 0, 0, 0, 0, 234, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 141, 141, 141, - 141, 0, 0, 141, 0, 141, 141, 141, 141, 141, - 141, 141, 141, 0, 0, 167, 0, 0, 167, 234, - 0, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 0, 0, 0, 0, 141, 141, 0, 167, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 228, 228, 228, 228, 0, 0, 228, 0, - 141, 141, 0, 228, 104, 0, 228, 228, 0, 0, - 0, 103, 294, 0, 0, 0, 87, 0, 0, 0, - 141, 141, 141, 141, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 0, 0, 0, 0, 0, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 86, 0, 228, - 228, 228, 228, 0, 0, 0, 0, 0, 234, 0, - 0, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 0, 0, 0, 0, 0, 0, 228, 167, - 167, 167, 167, 0, 234, 167, 0, 167, 167, 167, - 167, 167, 167, 0, 234, 40, 0, 234, 0, 0, - 0, 0, 0, 167, 167, 167, 167, 167, 167, 167, - 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, - 167, 167, 0, 0, 0, 0, 0, 167, 40, 0, - 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, - 234, 234, 0, 0, 167, 167, 167, 167, 167, 167, - 167, 167, 167, 167, 40, 0, 0, 0, 0, 0, - 0, 0, 167, 167, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 167, 167, 167, 167, 0, 0, 40, 0, - 0, 40, 0, 0, 0, 0, 42, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 47, 48, - 49, 8, 0, 0, 50, 0, 0, 0, 0, 51, - 40, 0, 52, 53, 0, 0, 0, 0, 0, 42, - 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 42, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, - 0, 0, 0, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 0, 0, 76, 77, 78, 79, 42, - 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 95, 80, 81, 82, 83, 84, 0, 0, - 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, - 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 40, 40, 40, 40, 0, 0, 40, 0, - 0, 95, 0, 40, 0, 0, 40, 40, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 0, 0, 0, 0, 0, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 95, 0, 40, - 40, 40, 40, 0, 0, 93, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 40, 40, 40, - 40, 40, 0, 42, 42, 42, 42, 0, 40, 42, - 0, 0, 0, 0, 42, 0, 0, 42, 42, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 93, 0, 0, 0, 0, 0, - 0, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 0, 0, 0, 0, 0, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 93, 0, - 42, 42, 42, 42, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 91, 0, 0, 0, 42, 42, - 42, 42, 42, 0, 0, 0, 0, 0, 0, 42, - 93, 0, 95, 0, 0, 0, 0, 95, 95, 95, - 0, 95, 95, 95, 95, 0, 0, 0, 0, 0, - 0, 0, 0, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 187, 91, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 91, 0, 0, - 0, 0, 95, 95, 0, 0, 0, 0, 0, 103, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 95, 95, 95, 95, 0, 0, 0, 91, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, - 93, 93, 93, 0, 93, 93, 93, 93, 103, 0, - 0, 0, 0, 32, 0, 0, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 188, 0, 0, 0, 0, - 0, 0, 103, 0, 0, 31, 0, 0, 0, 0, - 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 103, 93, 93, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 93, 93, 93, 93, 0, - 0, 0, 0, 0, 91, 0, 0, 0, 0, 91, - 91, 91, 105, 91, 91, 91, 91, 0, 0, 0, - 0, 0, 0, 0, 0, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 0, 0, 105, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 109, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 105, 6, - 7, 0, 8, 9, 91, 91, 0, 0, 0, 0, - 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 0, 91, 91, 91, 91, 0, 103, - 0, 0, 0, 0, 103, 103, 103, 109, 103, 103, - 103, 103, 0, 0, 0, 0, 0, 0, 0, 0, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, - 0, 109, 0, 0, 22, 0, 0, 0, 0, 0, - 23, 24, 107, 0, 25, 0, 26, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, - 0, 28, 0, 109, 0, 29, 30, 0, 0, 103, - 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, - 103, 103, 103, 105, 0, 0, 0, 0, 105, 105, - 105, 107, 105, 105, 105, 105, 0, 0, 0, 0, - 0, 0, 0, 0, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 0, 0, 107, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 107, 0, 0, - 0, 0, 0, 105, 105, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, - 0, 0, 80, 105, 105, 105, 105, 0, 109, 0, - 0, 0, 0, 109, 109, 109, 0, 109, 109, 109, - 109, 80, 0, 0, 0, 0, 0, 0, 0, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 0, 80, 0, - 0, 146, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 109, 109, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 146, 0, 146, 146, 109, 109, - 109, 109, 107, 0, 0, 0, 0, 107, 107, 107, - 146, 107, 107, 107, 107, 0, 0, 0, 0, 0, - 0, 0, 0, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 0, 0, 146, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, - 0, 0, 107, 107, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 107, 107, 107, 107, 0, 0, 0, 80, - 80, 80, 0, 0, 0, 80, 0, 80, 80, 80, - 80, 80, 80, 80, 80, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 0, 0, 0, 0, 0, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 0, - 0, 0, 0, 0, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 236, 0, 80, 80, 80, 80, - 0, 0, 80, 80, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 80, 80, 80, 80, 80, 0, - 0, 0, 80, 80, 80, 0, 0, 0, 0, 0, - 0, 236, 146, 146, 0, 236, 236, 236, 236, 236, - 0, 236, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 236, 236, 0, 236, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 146, 146, 146, - 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, - 146, 146, 146, 0, 0, 0, 0, 236, 0, 0, - 0, 0, 88, 0, 0, 146, 146, 146, 146, 85, - 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 146, 146, 146, 146, 146, 0, 236, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 32, 0, 0, 0, 0, 86, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 6, 0, 0, 0, 0, 0, 0, 6, 0, - 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 236, 6, - 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 236, 0, 0, 0, 0, 0, - 0, 6, 0, 0, 236, 0, 0, 236, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 88, 0, 274, 275, 49, 8, - 9, 103, 50, 0, 0, 0, 87, 51, 10, 11, - 276, 277, 14, 15, 16, 17, 18, 19, 20, 21, - 236, 236, 236, 236, 236, 236, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 0, 86, 0, 0, - 0, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 22, 0, 76, 77, 78, 79, 23, 24, 0, - 0, 25, 0, 26, 0, 0, 0, 0, 0, 0, - 0, 80, 81, 82, 83, 84, 27, 0, 28, 0, - 0, 0, 29, 30, 0, 6, 6, 6, 6, 6, - 0, 6, 0, 0, 0, 0, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, - 88, 0, 0, 0, 0, 0, 0, 85, 0, 0, - 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 0, 6, 6, 6, 6, 6, 6, 0, 0, - 6, 0, 6, 86, 0, 0, 0, 0, 0, 0, - 6, 6, 6, 6, 6, 6, 0, 6, 0, 0, - 0, 6, 6, 0, 0, 0, 0, 0, 47, 48, - 49, 8, 0, 0, 50, 0, 119, 120, 121, 51, - 122, 123, 124, 125, 0, 0, 0, 0, 0, 0, - 0, 0, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 0, 0, 0, 0, 0, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, - 0, 0, 0, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 0, 0, 76, 77, 78, 79, 104, - 0, 145, 146, 0, 0, 0, 103, 0, 0, 0, - 0, 87, 0, 80, 81, 82, 83, 84, 0, 0, - 0, 147, 148, 149, 29, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 47, 48, 49, 8, 0, 0, - 50, 0, 86, 0, 0, 51, 0, 0, 52, 53, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 0, 0, 0, 0, 0, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 104, - 0, 76, 77, 78, 79, 0, 85, 0, 0, 0, - 0, 87, 0, 0, 0, 0, 0, 0, 0, 80, - 81, 82, 83, 84, 0, 0, 0, 0, 0, 0, - 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 47, 48, 49, 8, 0, 0, 50, - 0, 0, 0, 0, 51, 0, 104, 52, 53, 0, - 0, 0, 0, 265, 0, 0, 0, 0, 87, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 0, 0, 0, 0, 0, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 0, 86, - 76, 77, 78, 79, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 81, - 82, 83, 84, 0, 0, 0, 0, 0, 0, 29, - 0, 0, 0, 0, 0, 0, 0, 88, 0, 0, - 0, 0, 0, 0, 103, 0, 397, 0, 0, 87, - 0, 0, 0, 47, 48, 49, 8, 0, 0, 50, - 0, 0, 0, 0, 51, 0, 0, 52, 53, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 86, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 0, 0, 0, 0, 0, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 0, 0, - 76, 77, 78, 79, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 81, - 82, 83, 84, 0, 0, 0, 0, 88, 0, 29, - 47, 48, 49, 8, 103, 0, 50, 0, 0, 87, - 0, 51, 0, 0, 52, 53, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 86, 0, 0, 0, 0, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 0, 0, 76, 77, 78, - 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 81, 82, 83, 84, - 0, 47, 48, 49, 0, 0, 29, 50, 0, 0, - 0, 0, 51, 88, 0, 52, 53, 0, 0, 0, - 85, 0, 0, 0, 0, 87, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 0, 0, 0, 0, 0, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 86, 0, 76, 77, - 78, 79, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 81, 82, 83, - 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, - 0, 47, 48, 49, 0, 265, 0, 50, 0, 0, - 87, 0, 51, 0, 0, 52, 53, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 86, 0, 0, 0, 0, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 0, 0, 76, 77, - 78, 79, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 81, 82, 83, - 84, 88, 0, 0, 0, 0, 0, 0, 103, 0, - 0, 0, 0, 87, 0, 0, 0, 47, 48, 49, - 0, 0, 0, 50, 0, 0, 0, 0, 51, 0, - 0, 52, 53, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 86, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, - 0, 0, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 0, 0, 76, 77, 78, 79, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 80, 81, 82, 83, 84, 0, 0, 0, - 0, 0, 47, 48, 49, 0, 0, 0, 50, 0, - 0, 0, 0, 51, 0, 0, 52, 53, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 0, 0, 0, 0, 0, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 0, 0, 76, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 81, 82, - 83, 84, 0, 0, 0, 47, 48, 49, 0, 0, - 0, 50, 0, 0, 0, 0, 51, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 0, 0, 76, 77, 78, 79, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 81, 82, 83, 84, -}; -short yycheck[] = { 24, - 118, 44, 37, 28, 104, 30, 59, 42, 43, 37, - 45, 36, 47, 0, 42, 43, 260, 45, 93, 47, - 43, 0, 45, 43, 98, 45, 0, 0, 85, 4, - 260, 100, 60, 59, 62, 95, 154, 37, 43, 44, - 45, 257, 42, 43, 113, 45, 58, 47, 35, 24, - 96, 258, 96, 258, 41, 30, 0, 0, 40, 94, - 85, 36, 87, 88, 0, 0, 94, 41, 41, 345, - 44, 44, 43, 133, 45, 100, 61, 134, 58, 104, - 59, 61, 43, 44, 45, 59, 59, 41, 113, 333, - 44, 62, 41, 333, 94, 44, 262, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 0, 134, - 40, 136, 137, 138, 93, 59, 59, 346, 347, 93, - 93, 0, 147, 148, 59, 100, 342, 343, 203, 154, - 230, 231, 40, 363, 234, 235, 111, 40, 113, 0, - 41, 33, 43, 118, 45, 40, 125, 40, 40, 93, - 93, 125, 125, 45, 370, 212, 213, 93, 93, 40, - 271, 272, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 40, 154, - 41, 125, 125, 44, 258, 259, 40, 212, 213, 125, - 125, 37, 40, 0, 0, 40, 42, 257, 59, 91, - 290, 47, 227, 263, 96, 230, 231, 232, 265, 234, - 235, 257, 61, 257, 93, 258, 258, 263, 0, 263, - 37, 260, 268, 41, 268, 42, 43, 41, 45, 262, - 47, 123, 93, 264, 41, 41, 94, 44, 44, 257, - 265, 352, 353, 60, 46, 62, 125, 301, 94, 348, - 349, 369, 59, 59, 300, 317, 318, 319, 320, 321, - 93, 236, 237, 93, 125, 300, 241, 341, 303, 43, - 44, 45, 125, 298, 114, 115, 262, 94, 262, 257, - 41, 304, 342, 343, 41, 44, 93, 93, 37, 41, - 264, 264, 302, 42, 43, 41, 45, 41, 47, 44, - 41, 44, 41, 262, 257, 346, 358, 303, 260, 91, - 370, 60, 41, 62, 271, 272, 290, 290, 125, 125, - 348, 349, 350, 351, 41, 260, 300, 41, 343, 303, - 265, 266, 267, 262, 269, 270, 271, 272, 363, 364, - 365, 123, 367, 0, 41, 94, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 257, 258, 259, 260, 261, - 395, 263, 397, 347, 347, 343, 268, 269, 270, 271, - 272, 273, 274, 275, 276, 277, 278, 279, 280, 0, - 154, 374, 343, 343, 369, 352, 353, 30, 35, -1, - -1, -1, 91, 264, -1, 340, 341, -1, -1, -1, - 0, 0, -1, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, 360, 361, 362, 363, 290, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, -1, 334, 335, 336, 337, 338, 339, 59, -1, - 342, 41, 344, -1, 44, -1, -1, 264, 264, -1, - 352, 353, 354, 355, 356, 357, -1, 359, 0, 59, - 59, 363, 364, -1, -1, 257, 258, -1, 260, 261, - -1, -1, 93, 290, 290, 346, 347, 269, 270, 271, - 272, 273, 274, 275, 276, 277, 278, 279, 280, 0, - -1, 33, -1, 93, 93, 37, -1, 0, 40, 41, - 42, 43, 44, 45, 125, 47, -1, -1, -1, -1, - -1, -1, -1, 26, -1, -1, -1, 59, 60, 346, - 62, 348, 349, 350, 351, 125, 125, -1, 24, 42, - 347, 347, -1, -1, 30, -1, 0, -1, -1, -1, - 332, -1, -1, -1, -1, -1, 338, 339, 59, -1, - 342, 93, 344, 0, 96, -1, 59, -1, -1, -1, - -1, 260, -1, -1, 0, 357, 0, 359, -1, 268, - -1, 363, 364, 86, 273, 274, 275, 276, 277, 278, - -1, 280, 93, 125, -1, -1, -1, -1, -1, 85, - 93, 350, 351, -1, 41, 59, -1, 44, -1, 33, - -1, -1, -1, 37, 100, -1, 40, 41, 42, 43, - 44, 45, 59, 47, 125, -1, -1, 113, -1, -1, - -1, -1, 125, 59, -1, 59, 60, -1, 62, 93, - -1, -1, -1, -1, 130, 131, 132, -1, -1, -1, - -1, -1, -1, 156, -1, -1, 93, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 93, 154, 93, - -1, 125, 96, 37, 264, -1, -1, -1, 42, 43, - -1, 45, -1, 47, 37, -1, -1, -1, 125, 42, - 43, 44, 45, -1, 47, -1, 60, -1, 62, 125, - 290, 125, -1, -1, -1, -1, -1, 60, 194, 62, - -1, -1, -1, -1, -1, -1, 202, -1, -1, -1, - -1, -1, -1, -1, -1, 257, 258, 259, 260, -1, - 94, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 94, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, 300, -1, - -1, 303, 304, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, 91, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - -1, -1, 334, 335, 336, 337, -1, -1, 340, 341, - -1, 343, 298, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, 264, 360, 361, - 362, 363, -1, 257, 258, 259, 260, 91, -1, 263, - 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, - 353, -1, -1, 290, 357, 358, -1, 281, 282, 283, - 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, - 294, 295, 296, 297, 298, 299, 300, 363, 364, 303, - 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, -1, -1, -1, 260, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 0, -1, - 334, 335, 336, 337, -1, -1, 340, 341, 0, 343, - -1, -1, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 360, 361, 362, 363, - -1, 33, -1, -1, -1, 37, 0, -1, 40, 41, - 42, 43, 44, 45, -1, 47, -1, -1, 260, -1, - -1, 43, -1, 45, -1, -1, 268, 59, 60, -1, - 62, 273, 274, 275, 276, 277, 278, 59, 280, -1, - -1, -1, 346, 347, 348, 349, 350, 351, -1, 43, - -1, 45, -1, 346, 347, 348, 349, 350, 351, 363, - -1, 93, -1, -1, 96, 59, 260, -1, -1, -1, - -1, 93, -1, -1, -1, 0, -1, -1, -1, 273, - 274, 275, 276, 277, 278, -1, 280, -1, -1, -1, - -1, -1, -1, 125, -1, -1, -1, -1, -1, 93, - -1, -1, -1, 125, -1, -1, -1, -1, 33, -1, - -1, -1, 37, -1, -1, 40, 41, 42, 43, 44, - 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, - -1, 125, -1, -1, 59, 60, -1, 62, -1, -1, - -1, -1, -1, -1, 37, -1, -1, -1, -1, 42, - 43, 37, 45, -1, 47, -1, 42, 43, 44, 45, - -1, 47, -1, -1, -1, -1, -1, 60, 93, 62, - -1, 96, 37, -1, 60, -1, 62, 42, 43, 44, - 45, -1, 47, -1, 37, -1, -1, -1, -1, 42, - 43, -1, 45, -1, 47, 60, -1, 62, -1, -1, - 125, 94, -1, -1, -1, -1, -1, 60, 94, 62, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 257, 258, 259, 260, 94, - -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 94, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, 300, -1, - -1, 303, 304, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - -1, -1, 334, 335, 336, 337, -1, -1, 340, 341, - -1, 343, -1, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, 360, 361, - 362, 363, 257, 258, 259, 260, -1, -1, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, - -1, -1, -1, -1, -1, -1, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, -1, -1, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 0, -1, 334, - 335, 336, 337, -1, 300, 340, 341, 303, 343, -1, - -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, -1, 286, -1, 360, 361, 362, 363, -1, - 33, -1, -1, -1, 37, -1, -1, 40, 41, 42, - 43, 44, 45, 346, 47, 348, 349, 350, 351, -1, - 346, 347, 348, 349, 350, 351, 59, 60, -1, 62, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 346, 347, 348, 349, 350, 351, -1, -1, -1, - -1, -1, -1, 346, 347, 348, 349, 350, 351, -1, - 93, -1, -1, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 125, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, - -1, 37, -1, -1, 40, 41, 42, 43, 44, 45, - -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 59, 60, -1, 62, -1, -1, -1, - -1, -1, -1, 37, -1, -1, -1, -1, 42, 43, - 37, 45, -1, 47, -1, 42, 43, 44, 45, -1, - 47, -1, -1, -1, -1, -1, 60, 93, 62, -1, - 96, 37, -1, 60, -1, 62, 42, 43, -1, 45, - -1, 47, -1, 37, -1, -1, -1, -1, 42, 43, - -1, 45, -1, 47, 60, -1, 62, -1, -1, 125, - 94, -1, -1, -1, -1, -1, 60, 94, 62, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 257, 258, 259, 260, 94, -1, - 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, - 94, -1, -1, -1, -1, -1, -1, -1, 281, 282, - 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, 300, -1, -1, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, -1, -1, -1, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, -1, - -1, 334, 335, 336, 337, -1, -1, 340, 341, -1, - 343, -1, -1, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, -1, -1, -1, 360, 361, 362, - 363, 257, 258, 259, 260, -1, -1, 263, 264, 265, - 266, 267, 268, 269, 270, 271, 272, -1, 0, -1, - -1, -1, -1, -1, -1, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 296, 297, 298, 299, 300, -1, -1, 303, 304, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, -1, -1, -1, -1, 289, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 0, 59, 334, 335, - 336, 337, -1, 300, 340, 341, 303, 343, -1, -1, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 360, 361, 362, 363, -1, 33, - -1, 93, -1, -1, 96, -1, 40, 41, -1, 43, - 44, 45, 346, 347, 348, 349, 350, 351, -1, 346, - 347, 348, 349, 350, 351, 59, 60, -1, 62, -1, - -1, -1, -1, 125, -1, -1, -1, -1, -1, -1, - 346, 347, 348, 349, 350, 351, -1, -1, -1, -1, - -1, -1, 346, 347, 348, 349, 350, 351, -1, 93, - -1, -1, 96, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 0, 85, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 125, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, - -1, -1, -1, 40, 41, -1, 43, 44, 45, 130, - 131, 132, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 59, 60, -1, 62, -1, -1, -1, -1, - -1, -1, -1, 154, -1, -1, -1, -1, -1, 37, - -1, -1, -1, -1, 42, 43, 44, 45, -1, 47, - -1, -1, -1, -1, -1, 257, 93, -1, -1, 96, - -1, 263, 60, -1, 62, -1, 268, -1, -1, -1, - -1, -1, -1, 194, -1, -1, -1, -1, -1, -1, - -1, 202, -1, -1, -1, -1, -1, -1, 125, -1, - -1, -1, -1, -1, -1, -1, 94, -1, 300, -1, - -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, - -1, -1, -1, 257, 258, 259, 260, -1, -1, 263, - 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, - -1, -1, -1, -1, -1, -1, -1, 281, 282, 283, - 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, - 294, 295, 296, 297, 298, 299, 300, -1, -1, 303, - 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, -1, -1, -1, -1, 298, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, -1, -1, - 334, 335, 336, 337, -1, -1, 340, 341, -1, 343, - -1, -1, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, 46, -1, 360, 361, 362, 363, - 257, 258, 259, 260, -1, -1, 263, 264, 265, 266, - 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, - -1, -1, 363, 364, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, 300, -1, -1, 303, 304, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - -1, -1, -1, -1, -1, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, 0, -1, 334, 335, 336, - 337, -1, 300, 340, 341, 303, 343, -1, -1, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - -1, -1, -1, 360, 361, 362, 363, -1, 33, 271, - 272, -1, -1, -1, -1, 40, 41, -1, -1, 44, - -1, -1, -1, -1, -1, -1, -1, -1, 346, 347, - 348, 349, 350, 351, 59, 60, -1, 62, -1, -1, - -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, - -1, 96, 334, 335, 336, 337, -1, -1, -1, -1, - -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, - 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - 125, -1, -1, -1, -1, 257, -1, -1, -1, -1, - -1, 263, -1, -1, -1, 33, 268, -1, -1, 271, - 272, -1, 40, 41, -1, -1, 44, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 59, 60, -1, 62, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 93, -1, -1, 96, -1, - -1, -1, 334, 335, 336, 337, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 352, 353, 354, 355, 356, -1, -1, 125, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, - -1, -1, 257, 258, 259, 260, 46, -1, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, - -1, -1, -1, -1, -1, -1, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, -1, -1, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, -1, -1, 334, - 335, 336, 337, -1, -1, 340, 341, -1, 343, -1, - -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, -1, -1, -1, 360, 361, 362, 363, 257, - 258, 259, 260, -1, -1, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, -1, -1, 303, 304, 305, 306, 307, - 308, 309, 310, 311, 312, 313, 314, 315, 316, -1, - -1, -1, -1, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 0, -1, 334, 335, 336, 337, - -1, -1, 340, 341, -1, 343, -1, -1, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, 360, 361, 362, 363, -1, 33, 271, 272, - -1, -1, -1, -1, 40, 41, -1, -1, 44, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 59, 60, -1, 62, -1, -1, -1, - -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, 93, -1, -1, - 96, 334, 335, 336, 337, -1, -1, -1, -1, -1, - -1, 0, -1, -1, 334, 335, 336, 337, -1, 352, - 353, 354, 355, 356, -1, -1, -1, -1, -1, 125, - -1, -1, 352, 353, 354, 355, 356, -1, -1, -1, - -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, - -1, 40, 41, -1, -1, 44, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, 60, -1, 62, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 257, 258, 259, 260, -1, -1, 263, 264, 265, - 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, - -1, -1, -1, -1, -1, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 296, 297, 298, 299, 300, -1, -1, 303, 304, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, -1, -1, -1, -1, -1, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, -1, -1, 334, 335, - 336, 337, -1, -1, 340, 341, -1, 343, -1, -1, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, 360, 361, 362, 363, 257, 258, - 259, 260, -1, -1, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, -1, 0, -1, -1, -1, -1, - -1, -1, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, 300, -1, -1, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 0, 59, 334, 335, 336, 337, -1, - -1, 340, 341, -1, 343, -1, -1, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, - -1, 360, 361, 362, 363, -1, 33, -1, 93, -1, - -1, 96, -1, 40, 41, -1, 43, 44, 45, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 59, -1, -1, 62, -1, -1, -1, -1, - 125, -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, 93, -1, -1, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 125, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, - 40, 41, -1, -1, 44, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - -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, 257, 93, -1, -1, 96, -1, 263, -1, - -1, -1, -1, 268, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 125, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 300, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 257, 258, 259, 260, -1, -1, 263, -1, 265, 266, - 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, - -1, -1, -1, -1, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, -1, -1, -1, -1, 304, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, -1, -1, 334, 335, 336, - 337, -1, -1, 340, 341, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 352, 353, 354, 355, 356, - -1, -1, -1, 360, 361, 362, 363, 257, 258, 259, - 260, -1, -1, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, -1, -1, -1, -1, -1, -1, -1, - -1, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - 300, -1, -1, 303, 304, 305, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, -1, -1, -1, - -1, -1, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 0, -1, 334, 335, 336, 337, -1, -1, - 340, 341, -1, 343, -1, -1, 346, 347, 348, 349, - -1, -1, 352, 353, 354, 355, 356, -1, -1, -1, - 360, 361, 362, 363, -1, 33, -1, -1, -1, -1, - -1, -1, 40, 41, -1, -1, 44, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 59, -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, 93, -1, -1, 96, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 125, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 33, -1, -1, -1, -1, -1, -1, 40, - 41, -1, 43, 44, 45, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, - -1, 62, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, - 258, 259, 260, -1, -1, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, -1, -1, 303, 304, 305, 306, 307, - 308, 309, 310, 311, 312, 313, 314, 315, 316, -1, - -1, -1, -1, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, 331, -1, -1, 334, 335, 336, 337, - -1, -1, 340, 341, -1, 343, -1, -1, 346, 347, - 348, 349, -1, -1, 352, 353, 354, 355, 356, -1, - -1, -1, 360, 361, 362, 363, 257, 258, 259, 260, - -1, -1, 263, -1, 265, 266, 267, 268, 269, 270, - 271, 272, -1, -1, -1, -1, -1, -1, -1, -1, - 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, - 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, - -1, -1, -1, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, 0, -1, 334, 335, 336, 337, -1, -1, 340, - 341, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 352, 353, 354, 355, 356, -1, -1, -1, 360, - 361, 362, 363, -1, 33, -1, -1, -1, -1, -1, - -1, 40, 41, -1, -1, 44, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, -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, 93, -1, -1, 96, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 125, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 33, -1, -1, -1, -1, -1, -1, 40, 41, - -1, -1, 44, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 59, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, - 259, 260, -1, -1, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, -1, -1, -1, -1, -1, -1, - -1, -1, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, 300, -1, -1, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, -1, -1, 334, 335, 336, 337, -1, - -1, 340, 341, -1, 343, -1, -1, 346, 347, -1, - -1, -1, -1, 352, 353, 354, 355, 356, -1, -1, - -1, 360, 361, 362, 363, 257, 258, 259, 260, -1, - -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, -1, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, 300, -1, - -1, 303, 304, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 0, -1, 334, 335, 336, 337, -1, -1, 340, 341, - -1, 343, -1, -1, -1, 347, -1, -1, -1, -1, - 352, 353, 354, 355, 356, -1, -1, -1, 360, 361, - 362, 363, -1, 33, -1, -1, -1, -1, -1, -1, - 40, 41, -1, 43, 44, 45, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - -1, -1, 62, -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, 93, -1, -1, 96, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 125, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 33, -1, -1, -1, -1, -1, -1, 40, 41, -1, - -1, 44, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -1, -1, 62, - -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, - 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, - 260, -1, -1, 263, -1, 265, 266, 267, 268, 269, - 270, 271, 272, -1, -1, -1, -1, -1, -1, -1, - -1, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - -1, -1, -1, -1, 304, 305, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, -1, -1, -1, - -1, -1, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, -1, -1, 334, 335, 336, 337, -1, -1, - 340, 341, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 352, 353, 354, 355, 356, -1, -1, -1, - 360, 361, 362, 363, 257, 258, 259, 260, -1, -1, - 263, -1, 265, 266, 267, 268, 269, 270, 271, 272, - -1, -1, -1, -1, -1, -1, -1, -1, 281, 282, - 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, - -1, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, -1, -1, -1, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, 0, - -1, 334, 335, 336, 337, -1, -1, 340, 341, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 352, - 353, 354, 355, 356, -1, -1, -1, 360, 361, 362, - 363, -1, 33, -1, -1, -1, -1, -1, -1, 40, - 41, -1, -1, 44, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -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, 93, -1, -1, 96, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 125, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, - -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 59, -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, 93, - -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, - -1, -1, 263, -1, 265, 266, 267, 268, 269, 270, - 271, 272, -1, -1, -1, -1, -1, -1, -1, -1, - 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, - 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, - -1, -1, -1, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, -1, -1, 91, -1, - -1, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, -1, -1, 334, 335, 336, 337, -1, -1, 340, - 341, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 123, 352, 353, 354, 355, 356, -1, -1, -1, 360, - 361, 362, 363, 257, 258, 259, 260, -1, -1, 263, - -1, 265, 266, 267, 268, 269, 270, 271, 272, -1, - -1, -1, -1, -1, -1, -1, -1, 281, 282, 283, - 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, - 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, - -1, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, 0, -1, -1, -1, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, -1, -1, - 334, 335, 336, 337, -1, -1, 340, 341, -1, -1, - -1, -1, -1, -1, -1, -1, 33, -1, 352, 353, - 354, 355, 356, 40, -1, -1, 360, 361, 362, 363, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 59, -1, 257, 258, -1, 260, 261, -1, - -1, -1, -1, -1, -1, -1, 269, 270, 271, 272, - 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, - -1, -1, -1, -1, -1, -1, 93, -1, -1, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 125, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 332, - -1, -1, -1, 33, -1, 338, 339, -1, -1, 342, - 40, 344, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 357, -1, 359, -1, -1, 59, - 363, 364, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 257, 258, 259, 260, -1, -1, 263, -1, 265, 266, - 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, - -1, -1, -1, -1, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, -1, -1, -1, -1, -1, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - -1, -1, 91, -1, -1, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, -1, -1, 334, 335, 336, - 337, -1, -1, 340, 341, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 123, 352, 353, 354, 355, 356, - -1, -1, -1, 360, 361, 362, 363, 257, 258, 259, - 260, -1, -1, 263, -1, 265, 266, 267, 268, 269, - 270, 271, 272, -1, -1, -1, -1, -1, -1, -1, - -1, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - -1, -1, -1, -1, -1, 305, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, 0, -1, -1, - -1, -1, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, -1, -1, 334, 335, 336, 337, -1, -1, - 340, 341, -1, -1, -1, -1, -1, -1, -1, -1, - 33, -1, 352, 353, 354, 355, 356, 40, -1, -1, - 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -1, 257, 258, - -1, 260, 261, -1, -1, -1, -1, -1, -1, -1, - 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, -1, -1, -1, -1, -1, -1, -1, -1, - 93, -1, -1, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 125, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 332, -1, -1, -1, 33, -1, 338, - 339, -1, -1, 342, 40, 344, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 357, -1, - 359, -1, -1, 59, 363, 364, -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, 93, -1, -1, - 96, -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, 125, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 257, 258, 259, 260, -1, -1, - 263, -1, 265, 266, 267, 268, 269, 270, 271, 272, - -1, -1, -1, -1, -1, -1, -1, -1, 281, 282, - 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, - -1, -1, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, -1, -1, -1, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, -1, - -1, 334, 335, 336, 337, -1, -1, 340, 341, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 352, - 353, 354, 355, 356, -1, -1, -1, 360, 361, 362, - 363, 257, 258, 259, 260, -1, -1, 263, -1, 265, - 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, - -1, -1, -1, -1, -1, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 296, 297, 298, 299, -1, -1, -1, -1, -1, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, 0, -1, -1, -1, -1, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, -1, -1, 334, 335, - 336, 337, -1, -1, 340, 341, -1, -1, -1, -1, - -1, -1, -1, -1, 33, -1, 352, 353, 354, 355, - 356, 40, -1, -1, 360, 361, 362, 363, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, -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, 93, -1, -1, 96, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 125, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 33, -1, -1, -1, -1, -1, -1, 40, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 59, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, - 259, 260, -1, -1, 263, -1, 265, 266, 267, 268, - 269, 270, 271, 272, -1, -1, -1, -1, -1, -1, - -1, -1, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, -1, -1, -1, -1, -1, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, -1, -1, 334, 335, 336, 337, -1, - -1, 340, 341, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 352, 353, 354, 355, 356, -1, -1, - -1, 360, 361, 362, 363, 257, 258, 259, 260, -1, - -1, 263, -1, 265, 266, 267, 268, 269, 270, 271, - 272, -1, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, - -1, -1, -1, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, 0, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - -1, -1, 334, 335, 336, 337, -1, -1, 340, 341, - -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, - 352, 353, 354, 355, 356, 40, -1, -1, 360, 361, - 362, 363, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 59, -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, 93, -1, - -1, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 125, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, - -1, -1, 40, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 59, -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, 93, -1, -1, 96, -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, 125, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 257, 258, 259, 260, -1, -1, 263, -1, - 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, - -1, -1, -1, -1, -1, -1, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, -1, -1, 334, - 335, 336, 337, -1, -1, 340, 341, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 352, 353, 354, - 355, 356, -1, -1, -1, 360, 361, 362, 363, 257, - 258, 259, 260, -1, -1, 263, -1, 265, 266, 267, - 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, -1, -1, -1, -1, -1, 305, 306, 307, - 308, 309, 310, 311, 312, 313, 314, 315, 316, 0, - -1, -1, -1, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, 331, -1, -1, 334, 335, 336, 337, - -1, -1, 340, 341, -1, -1, -1, -1, -1, -1, - -1, -1, 33, -1, 352, 353, 354, 355, 356, 40, - -1, -1, 360, 361, 362, 363, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -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, 93, -1, -1, 96, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 125, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, - -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 59, -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, 93, - -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, - -1, -1, 263, -1, 265, 266, 267, 268, 269, 270, - 271, 272, -1, -1, -1, -1, -1, -1, -1, -1, - 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, - 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, - -1, -1, -1, -1, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, -1, -1, -1, -1, - -1, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, -1, -1, 334, 335, 336, 337, -1, -1, 340, - 341, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 352, 353, 354, 355, 356, -1, -1, -1, 360, - 361, 362, 363, 257, 258, 259, 260, -1, -1, 263, - -1, 265, 266, 267, 268, 269, 270, 271, 272, -1, - -1, -1, -1, -1, -1, -1, -1, 281, 282, 283, - 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, - 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, - -1, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, 0, -1, -1, -1, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, -1, -1, - 334, 335, 336, 337, -1, -1, 340, 341, -1, -1, - -1, -1, -1, -1, -1, -1, 33, -1, 352, 353, - 354, 355, 356, 40, -1, -1, 360, 361, 362, 363, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 59, -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, 93, -1, -1, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 125, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, - 40, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 257, 258, 259, 260, -1, -1, 263, -1, 265, 266, - 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, - -1, -1, -1, -1, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, -1, -1, -1, -1, -1, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - -1, -1, -1, -1, -1, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, -1, -1, 334, 335, 336, - 337, -1, -1, 340, 341, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 352, 353, 354, 355, 356, - -1, -1, -1, 360, 361, 362, 363, 257, 258, 259, - 260, -1, -1, 263, -1, 265, 266, 267, 268, 269, - 270, 271, 272, -1, -1, -1, -1, -1, -1, -1, - -1, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - -1, -1, -1, -1, -1, 305, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, 0, -1, -1, - -1, -1, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, -1, -1, 334, 335, 336, 337, -1, -1, - 340, 341, -1, -1, -1, -1, -1, -1, -1, -1, - 33, -1, 352, 353, 354, 355, 356, 40, -1, -1, - 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -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, - 93, -1, -1, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 125, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, - -1, -1, -1, -1, 40, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 59, -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, 93, -1, -1, - 96, -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, 125, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 257, 258, 259, 260, -1, -1, - 263, -1, 265, 266, 267, 268, 269, 270, 271, 272, - -1, -1, -1, -1, -1, -1, -1, -1, 281, 282, - 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, - -1, -1, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, -1, -1, -1, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, -1, - -1, 334, 335, 336, 337, -1, -1, 340, 341, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 352, - 353, 354, 355, 356, -1, -1, -1, 360, 361, 362, - 363, 257, 258, 259, 260, -1, -1, 263, -1, 265, - 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, - -1, -1, -1, -1, -1, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 296, 297, 298, 299, -1, -1, -1, -1, -1, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, 0, -1, -1, -1, -1, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, -1, -1, 334, 335, - 336, 337, -1, -1, 340, 341, -1, -1, -1, -1, - -1, -1, -1, -1, 33, -1, 352, 353, 354, 355, - 356, 40, -1, -1, 360, 361, 362, 363, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, -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, 93, -1, -1, 96, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 125, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 33, -1, -1, -1, -1, -1, -1, 40, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 59, -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, 93, -1, -1, 96, -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, 125, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, - 259, 260, -1, -1, 263, -1, 265, 266, 267, 268, - 269, 270, 271, 272, -1, -1, -1, -1, -1, -1, - -1, -1, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, -1, -1, -1, -1, -1, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, -1, -1, 334, 335, 336, 337, -1, - -1, 340, 341, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 352, 353, 354, 355, 356, -1, -1, - -1, 360, 361, 362, 363, 257, 258, 259, 260, -1, - -1, 263, -1, 265, 266, 267, 268, 269, 270, 271, - 272, -1, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, - -1, -1, -1, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 0, -1, 334, 335, 336, 337, -1, -1, 340, 341, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 352, 353, 354, 355, 356, -1, -1, -1, 360, 361, - 362, 363, -1, 33, -1, -1, -1, -1, -1, -1, - 40, 41, -1, 43, 44, 45, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, - -1, -1, 62, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 93, -1, -1, 96, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, - -1, -1, -1, -1, -1, 40, 41, -1, -1, 44, - -1, -1, -1, -1, -1, 125, -1, -1, -1, -1, - -1, -1, -1, -1, 59, 60, -1, 62, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, - -1, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 41, -1, -1, 44, -1, - 125, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 59, -1, 33, -1, -1, -1, -1, - -1, -1, 40, -1, -1, -1, -1, 45, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 59, -1, -1, -1, -1, -1, 93, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, - 260, -1, -1, 263, -1, 265, 266, 267, 268, 269, - 270, 271, 272, -1, -1, 93, -1, -1, 96, 125, - -1, 281, 282, 283, 284, 285, 286, 287, 288, 289, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - -1, -1, -1, -1, 304, 305, -1, 125, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 317, 318, 319, - 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 257, 258, 259, 260, -1, -1, 263, -1, - 340, 341, -1, 268, 33, -1, 271, 272, -1, -1, - -1, 40, 41, -1, -1, -1, 45, -1, -1, -1, - 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 96, -1, 334, - 335, 336, 337, -1, -1, -1, -1, -1, 264, -1, - -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, -1, -1, -1, -1, -1, -1, 363, 257, - 258, 259, 260, -1, 290, 263, -1, 265, 266, 267, - 268, 269, 270, -1, 300, 0, -1, 303, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, -1, -1, -1, -1, -1, 305, 33, -1, - -1, -1, -1, -1, -1, 40, -1, -1, -1, -1, - 346, 347, -1, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 59, -1, -1, -1, -1, -1, - -1, -1, 340, 341, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 360, 361, 362, 363, -1, -1, 93, -1, - -1, 96, -1, -1, -1, -1, 0, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, - 259, 260, -1, -1, 263, -1, -1, -1, -1, 268, - 125, -1, 271, 272, -1, -1, -1, -1, -1, 33, - -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 59, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, -1, -1, 334, 335, 336, 337, 93, - -1, -1, 96, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, 352, 353, 354, 355, 356, -1, -1, - -1, -1, -1, -1, 363, -1, -1, -1, -1, -1, - -1, 125, -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, 257, 258, 259, 260, -1, -1, 263, -1, - -1, 59, -1, 268, -1, -1, 271, 272, -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, 93, -1, -1, -1, -1, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 125, -1, 334, - 335, 336, 337, -1, -1, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 352, 353, 354, - 355, 356, -1, 257, 258, 259, 260, -1, 363, 263, - -1, -1, -1, -1, 268, -1, -1, 271, 272, -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, 59, -1, -1, -1, -1, -1, - -1, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, -1, -1, -1, -1, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 93, -1, - 334, 335, 336, 337, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, -1, -1, 352, 353, - 354, 355, 356, -1, -1, -1, -1, -1, -1, 363, - 125, -1, 260, -1, -1, -1, -1, 265, 266, 267, - -1, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, 59, -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, 93, -1, -1, - -1, -1, 340, 341, -1, -1, -1, -1, -1, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 360, 361, 362, 363, -1, -1, -1, 125, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 59, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 260, -1, -1, -1, -1, - 265, 266, 267, -1, 269, 270, 271, 272, 59, -1, - -1, -1, -1, 91, -1, -1, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, -1, -1, -1, -1, - -1, -1, 93, -1, -1, 123, -1, -1, -1, -1, - -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 125, 340, 341, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 360, 361, 362, 363, -1, - -1, -1, -1, -1, 260, -1, -1, -1, -1, 265, - 266, 267, 59, 269, 270, 271, 272, -1, -1, -1, - -1, -1, -1, -1, -1, 281, 282, 283, 284, 285, - 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, - 296, 297, 298, 299, -1, -1, 93, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 125, 257, - 258, -1, 260, 261, 340, 341, -1, -1, -1, -1, - -1, 269, 270, 271, 272, 273, 274, 275, 276, 277, - 278, 279, 280, -1, 360, 361, 362, 363, -1, 260, - -1, -1, -1, -1, 265, 266, 267, 59, 269, 270, - 271, 272, -1, -1, -1, -1, -1, -1, -1, -1, - 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, - 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, - -1, 93, -1, -1, 332, -1, -1, -1, -1, -1, - 338, 339, 0, -1, 342, -1, 344, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 357, - -1, 359, -1, 125, -1, 363, 364, -1, -1, 340, - 341, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, - 361, 362, 363, 260, -1, -1, -1, -1, 265, 266, - 267, 59, 269, 270, 271, 272, -1, -1, -1, -1, - -1, -1, -1, -1, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, -1, -1, 93, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 125, -1, -1, - -1, -1, -1, 340, 341, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, - -1, -1, 40, 360, 361, 362, 363, -1, 260, -1, - -1, -1, -1, 265, 266, 267, -1, 269, 270, 271, - 272, 59, -1, -1, -1, -1, -1, -1, -1, 281, - 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, - -1, -1, -1, -1, -1, 93, -1, -1, 96, -1, - -1, 0, -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, 125, 340, 341, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 43, -1, 45, 46, 360, 361, - 362, 363, 260, -1, -1, -1, -1, 265, 266, 267, - 59, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, -1, -1, 93, -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, 125, -1, -1, -1, - -1, -1, 340, 341, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 360, 361, 362, 363, -1, -1, -1, 257, - 258, 259, -1, -1, -1, 263, -1, 265, 266, 267, - 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, - -1, -1, -1, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, -1, -1, -1, -1, -1, 305, 306, 307, - 308, 309, 310, 311, 312, 313, 314, 315, 316, -1, - -1, -1, -1, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 0, -1, 334, 335, 336, 337, - -1, -1, 340, 341, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 352, 353, 354, 355, 356, -1, - -1, -1, 360, 361, 362, -1, -1, -1, -1, -1, - -1, 37, 271, 272, -1, 41, 42, 43, 44, 45, - -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 59, 60, -1, 62, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, - 319, 320, 321, -1, -1, -1, -1, 93, -1, -1, - -1, -1, 33, -1, -1, 334, 335, 336, 337, 40, - -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, - -1, -1, -1, 352, 353, 354, 355, 356, -1, 125, - -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, - 91, -1, -1, -1, -1, 96, -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, 123, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 33, -1, -1, -1, -1, -1, -1, 40, -1, - -1, -1, -1, 45, -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, 264, 91, - -1, -1, -1, -1, 96, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 290, -1, -1, -1, -1, -1, - -1, 123, -1, -1, 300, -1, -1, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 33, -1, 257, 258, 259, 260, - 261, 40, 263, -1, -1, -1, 45, 268, 269, 270, - 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, - 346, 347, 348, 349, 350, 351, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, -1, 96, -1, -1, - -1, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, 332, -1, 334, 335, 336, 337, 338, 339, -1, - -1, 342, -1, 344, -1, -1, -1, -1, -1, -1, - -1, 352, 353, 354, 355, 356, 357, -1, 359, -1, - -1, -1, 363, 364, -1, 257, 258, 259, 260, 261, - -1, 263, -1, -1, -1, -1, 268, 269, 270, 271, - 272, 273, 274, 275, 276, 277, 278, 279, 280, -1, - 33, -1, -1, -1, -1, -1, -1, 40, -1, -1, - -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, -1, 334, 335, 336, 337, 338, 339, -1, -1, - 342, -1, 344, 96, -1, -1, -1, -1, -1, -1, - 352, 353, 354, 355, 356, 357, -1, 359, -1, -1, - -1, 363, 364, -1, -1, -1, -1, -1, 257, 258, - 259, 260, -1, -1, 263, -1, 265, 266, 267, 268, - 269, 270, 271, 272, -1, -1, -1, -1, -1, -1, - -1, -1, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, -1, -1, -1, -1, -1, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, -1, -1, - -1, -1, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, -1, -1, 334, 335, 336, 337, 33, - -1, 340, 341, -1, -1, -1, 40, -1, -1, -1, - -1, 45, -1, 352, 353, 354, 355, 356, -1, -1, - -1, 360, 361, 362, 363, -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, 257, 258, 259, 260, -1, -1, - 263, -1, 96, -1, -1, 268, -1, -1, 271, 272, - -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, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, -1, -1, -1, -1, -1, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, 33, - -1, 334, 335, 336, 337, -1, 40, -1, -1, -1, - -1, 45, -1, -1, -1, -1, -1, -1, -1, 352, - 353, 354, 355, 356, -1, -1, -1, -1, -1, -1, - 363, -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, 96, -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, 257, 258, 259, 260, -1, -1, 263, - -1, -1, -1, -1, 268, -1, 33, 271, 272, -1, - -1, -1, -1, 40, -1, -1, -1, -1, 45, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, -1, -1, -1, -1, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, -1, 96, - 334, 335, 336, 337, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 352, 353, - 354, 355, 356, -1, -1, -1, -1, -1, -1, 363, - -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, - -1, -1, -1, -1, 40, -1, 42, -1, -1, 45, - -1, -1, -1, 257, 258, 259, 260, -1, -1, 263, - -1, -1, -1, -1, 268, -1, -1, 271, 272, -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, - 96, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, -1, -1, -1, -1, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, -1, -1, - 334, 335, 336, 337, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 33, -1, 363, - 257, 258, 259, 260, 40, -1, 263, -1, -1, 45, - -1, 268, -1, -1, 271, 272, -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, 305, 306, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - 96, -1, -1, -1, -1, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, -1, -1, 334, 335, 336, - 337, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 352, 353, 354, 355, 356, - -1, 257, 258, 259, -1, -1, 363, 263, -1, -1, - -1, -1, 268, 33, -1, 271, 272, -1, -1, -1, - 40, -1, -1, -1, -1, 45, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, -1, -1, -1, -1, -1, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 96, -1, 334, 335, - 336, 337, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 352, 353, 354, 355, - 356, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, - -1, 257, 258, 259, -1, 40, -1, 263, -1, -1, - 45, -1, 268, -1, -1, 271, 272, -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, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, 96, -1, -1, -1, -1, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, -1, -1, 334, 335, - 336, 337, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 352, 353, 354, 355, - 356, 33, -1, -1, -1, -1, -1, -1, 40, -1, - -1, -1, -1, 45, -1, -1, -1, 257, 258, 259, - -1, -1, -1, 263, -1, -1, -1, -1, 268, -1, - -1, 271, 272, -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, 96, 305, 306, 307, 308, 309, - 310, 311, 312, 313, 314, 315, 316, -1, -1, -1, - -1, -1, 322, 323, 324, 325, 326, 327, 328, 329, - 330, 331, -1, -1, 334, 335, 336, 337, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 352, 353, 354, 355, 356, -1, -1, -1, - -1, -1, 257, 258, 259, -1, -1, -1, 263, -1, - -1, -1, -1, 268, -1, -1, 271, 272, -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, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, -1, -1, -1, -1, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, -1, -1, 334, - 335, 336, 337, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 352, 353, 354, - 355, 356, -1, -1, -1, 257, 258, 259, -1, -1, - -1, 263, -1, -1, -1, -1, 268, -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, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, - -1, -1, 334, 335, 336, 337, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 352, 353, 354, 355, 356, -}; -#define YYFINAL 2 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 366 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -"'!'",0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0, -0,0,0,0,0,"':'","';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,"'`'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"LABEL","VARIABLE","NUMBER", -"TEXT","COMMAND_LINE","DELIMITED","ORDINAL","TH","LEFT_ARROW_HEAD", -"RIGHT_ARROW_HEAD","DOUBLE_ARROW_HEAD","LAST","UP","DOWN","LEFT","RIGHT","BOX", -"CIRCLE","ELLIPSE","ARC","LINE","ARROW","MOVE","SPLINE","HEIGHT","RADIUS", -"WIDTH","DIAMETER","FROM","TO","AT","WITH","BY","THEN","DOTTED","DASHED","CHOP", -"SAME","INVISIBLE","LJUST","RJUST","ABOVE","BELOW","OF","THE","WAY","BETWEEN", -"AND","HERE","DOT_N","DOT_E","DOT_W","DOT_S","DOT_NE","DOT_SE","DOT_NW", -"DOT_SW","DOT_C","DOT_START","DOT_END","DOT_X","DOT_Y","DOT_HT","DOT_WID", -"DOT_RAD","SIN","COS","ATAN2","LOG","EXP","SQRT","K_MAX","K_MIN","INT","RAND", -"COPY","THRU","TOP","BOTTOM","UPPER","LOWER","SH","PRINT","CW","CCW","FOR","DO", -"IF","ELSE","ANDAND","OROR","NOTEQUAL","EQUALEQUAL","LESSEQUAL","GREATEREQUAL", -"LEFT_CORNER","RIGHT_CORNER","CENTER","END","START","RESET","UNTIL","PLOT", -"THICKNESS","FILL","ALIGNED","SPRINTF","COMMAND","DEFINE","UNDEF", -}; -char *yyrule[] = { -"$accept : top", -"top : optional_separator", -"top : element_list", -"element_list : optional_separator middle_element_list optional_separator", -"middle_element_list : element", -"middle_element_list : middle_element_list separator element", -"optional_separator :", -"optional_separator : separator", -"separator : ';'", -"separator : separator ';'", -"placeless_element : VARIABLE '=' any_expr", -"placeless_element : VARIABLE ':' '=' any_expr", -"placeless_element : UP", -"placeless_element : DOWN", -"placeless_element : LEFT", -"placeless_element : RIGHT", -"placeless_element : COMMAND_LINE", -"placeless_element : COMMAND print_args", -"placeless_element : PRINT print_args", -"$$1 :", -"placeless_element : SH $$1 DELIMITED", -"placeless_element : COPY TEXT", -"$$2 :", -"$$3 :", -"placeless_element : COPY TEXT THRU $$2 DELIMITED $$3 until", -"$$4 :", -"$$5 :", -"placeless_element : COPY THRU $$4 DELIMITED $$5 until", -"$$6 :", -"placeless_element : FOR VARIABLE '=' expr TO expr optional_by DO $$6 DELIMITED", -"placeless_element : simple_if", -"$$7 :", -"placeless_element : simple_if ELSE $$7 DELIMITED", -"placeless_element : reset_variables", -"placeless_element : RESET", -"reset_variables : RESET VARIABLE", -"reset_variables : reset_variables VARIABLE", -"reset_variables : reset_variables ',' VARIABLE", -"print_args : print_arg", -"print_args : print_args print_arg", -"print_arg : expr", -"print_arg : text", -"print_arg : position", -"$$8 :", -"simple_if : IF any_expr THEN $$8 DELIMITED", -"until :", -"until : UNTIL TEXT", -"any_expr : expr", -"any_expr : text_expr", -"text_expr : text EQUALEQUAL text", -"text_expr : text NOTEQUAL text", -"text_expr : text_expr ANDAND text_expr", -"text_expr : text_expr ANDAND expr", -"text_expr : expr ANDAND text_expr", -"text_expr : text_expr OROR text_expr", -"text_expr : text_expr OROR expr", -"text_expr : expr OROR text_expr", -"text_expr : '!' text_expr", -"optional_by :", -"optional_by : BY expr", -"optional_by : BY '*' expr", -"element : object_spec", -"element : LABEL ':' optional_separator element", -"element : LABEL ':' optional_separator position_not_place", -"element : LABEL ':' optional_separator place", -"$$9 :", -"$$10 :", -"element : '{' $$9 element_list '}' $$10 optional_element", -"element : placeless_element", -"optional_element :", -"optional_element : element", -"object_spec : BOX", -"object_spec : CIRCLE", -"object_spec : ELLIPSE", -"object_spec : ARC", -"object_spec : LINE", -"object_spec : ARROW", -"object_spec : MOVE", -"object_spec : SPLINE", -"object_spec : text", -"object_spec : PLOT expr", -"object_spec : PLOT expr text", -"$$11 :", -"object_spec : '[' $$11 element_list ']'", -"object_spec : object_spec HEIGHT expr", -"object_spec : object_spec RADIUS expr", -"object_spec : object_spec WIDTH expr", -"object_spec : object_spec DIAMETER expr", -"object_spec : object_spec expr", -"object_spec : object_spec UP", -"object_spec : object_spec UP expr", -"object_spec : object_spec DOWN", -"object_spec : object_spec DOWN expr", -"object_spec : object_spec RIGHT", -"object_spec : object_spec RIGHT expr", -"object_spec : object_spec LEFT", -"object_spec : object_spec LEFT expr", -"object_spec : object_spec FROM position", -"object_spec : object_spec TO position", -"object_spec : object_spec AT position", -"object_spec : object_spec WITH path", -"object_spec : object_spec BY expr_pair", -"object_spec : object_spec THEN", -"object_spec : object_spec DOTTED", -"object_spec : object_spec DOTTED expr", -"object_spec : object_spec DASHED", -"object_spec : object_spec DASHED expr", -"object_spec : object_spec FILL", -"object_spec : object_spec FILL expr", -"object_spec : object_spec CHOP", -"object_spec : object_spec CHOP expr", -"object_spec : object_spec SAME", -"object_spec : object_spec INVISIBLE", -"object_spec : object_spec LEFT_ARROW_HEAD", -"object_spec : object_spec RIGHT_ARROW_HEAD", -"object_spec : object_spec DOUBLE_ARROW_HEAD", -"object_spec : object_spec CW", -"object_spec : object_spec CCW", -"object_spec : object_spec text", -"object_spec : object_spec LJUST", -"object_spec : object_spec RJUST", -"object_spec : object_spec ABOVE", -"object_spec : object_spec BELOW", -"object_spec : object_spec THICKNESS expr", -"object_spec : object_spec ALIGNED", -"text : TEXT", -"text : SPRINTF '(' TEXT sprintf_args ')'", -"sprintf_args :", -"sprintf_args : sprintf_args ',' expr", -"position : position_not_place", -"position : place", -"position_not_place : expr_pair", -"position_not_place : position '+' expr_pair", -"position_not_place : position '-' expr_pair", -"position_not_place : '(' position ',' position ')'", -"position_not_place : expr between position AND position", -"position_not_place : expr '<' position ',' position '>'", -"between : BETWEEN", -"between : OF THE WAY BETWEEN", -"expr_pair : expr ',' expr", -"expr_pair : '(' expr_pair ')'", -"place : label", -"place : label corner", -"place : corner label", -"place : corner OF label", -"place : HERE", -"label : LABEL", -"label : nth_primitive", -"label : label '.' LABEL", -"ordinal : ORDINAL", -"ordinal : '`' any_expr TH", -"optional_ordinal_last : LAST", -"optional_ordinal_last : ordinal LAST", -"nth_primitive : ordinal object_type", -"nth_primitive : optional_ordinal_last object_type", -"object_type : BOX", -"object_type : CIRCLE", -"object_type : ELLIPSE", -"object_type : ARC", -"object_type : LINE", -"object_type : ARROW", -"object_type : SPLINE", -"object_type : '[' ']'", -"object_type : TEXT", -"label_path : '.' LABEL", -"label_path : label_path '.' LABEL", -"relative_path : corner", -"relative_path : label_path", -"relative_path : label_path corner", -"path : relative_path", -"path : ORDINAL LAST object_type relative_path", -"path : LAST object_type relative_path", -"path : ORDINAL object_type relative_path", -"path : LABEL relative_path", -"corner : DOT_N", -"corner : DOT_E", -"corner : DOT_W", -"corner : DOT_S", -"corner : DOT_NE", -"corner : DOT_SE", -"corner : DOT_NW", -"corner : DOT_SW", -"corner : DOT_C", -"corner : DOT_START", -"corner : DOT_END", -"corner : TOP", -"corner : BOTTOM", -"corner : LEFT", -"corner : RIGHT", -"corner : UPPER LEFT", -"corner : LOWER LEFT", -"corner : UPPER RIGHT", -"corner : LOWER RIGHT", -"corner : LEFT_CORNER", -"corner : RIGHT_CORNER", -"corner : UPPER LEFT_CORNER", -"corner : LOWER LEFT_CORNER", -"corner : UPPER RIGHT_CORNER", -"corner : LOWER RIGHT_CORNER", -"corner : CENTER", -"corner : START", -"corner : END", -"expr : VARIABLE", -"expr : NUMBER", -"expr : place DOT_X", -"expr : place DOT_Y", -"expr : place DOT_HT", -"expr : place DOT_WID", -"expr : place DOT_RAD", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '^' expr", -"expr : '-' expr", -"expr : '(' any_expr ')'", -"expr : SIN '(' any_expr ')'", -"expr : COS '(' any_expr ')'", -"expr : ATAN2 '(' any_expr ',' any_expr ')'", -"expr : LOG '(' any_expr ')'", -"expr : EXP '(' any_expr ')'", -"expr : SQRT '(' any_expr ')'", -"expr : K_MAX '(' any_expr ',' any_expr ')'", -"expr : K_MIN '(' any_expr ',' any_expr ')'", -"expr : INT '(' any_expr ')'", -"expr : RAND '(' any_expr ')'", -"expr : RAND '(' ')'", -"expr : expr '<' expr", -"expr : expr LESSEQUAL expr", -"expr : expr '>' expr", -"expr : expr GREATEREQUAL expr", -"expr : expr EQUALEQUAL expr", -"expr : expr NOTEQUAL expr", -"expr : expr ANDAND expr", -"expr : expr OROR expr", -"expr : '!' expr", -}; -#endif -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#ifdef YYSTACKSIZE -#ifndef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#endif -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#line 1514 "/u/jjc/groff/pic/pic.y" - -/* bison defines const to be empty unless __STDC__ is defined, which it -isn't under cfront */ - -#ifdef const -#undef const -#endif - -static struct { - const char *name; - double val; - int scaled; // non-zero if val should be multiplied by scale -} defaults_table[] = { - { "arcrad", .25, 1 }, - { "arrowht", .1, 1 }, - { "arrowwid", .05, 1 }, - { "circlerad", .25, 1 }, - { "boxht", .5, 1 }, - { "boxwid", .75, 1 }, - { "boxrad", 0.0, 1 }, - { "dashwid", .05, 1 }, - { "ellipseht", .5, 1 }, - { "ellipsewid", .75, 1 }, - { "moveht", .5, 1 }, - { "movewid", .5, 1 }, - { "lineht", .5, 1 }, - { "linewid", .5, 1 }, - { "textht", 0.0, 1 }, - { "textwid", 0.0, 1 }, - { "scale", 1.0, 0 }, - { "linethick", -1.0, 0 }, // in points - { "fillval", .5, 0 }, - { "arrowhead", 1.0, 0 }, - { "maxpswid", 8.5, 0 }, - { "maxpsht", 11.0, 0 }, -}; - -place *lookup_label(const char *label) -{ - saved_state *state = current_saved_state; - PTABLE(place) *tbl = current_table; - for (;;) { - place *pl = tbl->lookup(label); - if (pl) - return pl; - if (!state) - return 0; - tbl = state->tbl; - state = state->prev; - } -} - -void define_label(const char *label, const place *pl) -{ - place *p = new place; - *p = *pl; - current_table->define(label, p); -} - -int lookup_variable(const char *name, double *val) -{ - place *pl = lookup_label(name); - if (pl) { - *val = pl->x; - return 1; - } - return 0; -} - -void define_variable(const char *name, double val) -{ - place *p = new place; - p->obj = 0; - p->x = val; - p->y = 0.0; - current_table->define(name, p); - if (strcmp(name, "scale") == 0) { - // When the scale changes, reset all scaled pre-defined variables to - // their default values. - for (int i = 0; i < sizeof(defaults_table)/sizeof(defaults_table[0]); i++) - if (defaults_table[i].scaled) - define_variable(defaults_table[i].name, val*defaults_table[i].val); - } -} - -// called once only (not once per parse) - -void parse_init() -{ - current_direction = RIGHT_DIRECTION; - current_position.x = 0.0; - current_position.y = 0.0; - // This resets everything to its default value. - reset_all(); -} - -void reset(const char *nm) -{ - for (int i = 0; i < sizeof(defaults_table)/sizeof(defaults_table[0]); i++) - if (strcmp(nm, defaults_table[i].name) == 0) { - double val = defaults_table[i].val; - if (defaults_table[i].scaled) { - double scale; - lookup_variable("scale", &scale); - val *= scale; - } - define_variable(defaults_table[i].name, val); - return; - } - lex_error("`%1' is not a predefined variable", nm); -} - -void reset_all() -{ - // We only have to explicitly reset the pre-defined variables that - // aren't scaled because `scale' is not scaled, and changing the - // value of `scale' will reset all the pre-defined variables that - // are scaled. - for (int i = 0; i < sizeof(defaults_table)/sizeof(defaults_table[0]); i++) - if (!defaults_table[i].scaled) - define_variable(defaults_table[i].name, defaults_table[i].val); -} - -// called after each parse - -void parse_cleanup() -{ - while (current_saved_state != 0) { - delete current_table; - current_table = current_saved_state->tbl; - saved_state *tem = current_saved_state; - current_saved_state = current_saved_state->prev; - delete tem; - } - assert(current_table == &top_table); - PTABLE_ITERATOR(place) iter(current_table); - const char *key; - place *pl; - while (iter.next(&key, &pl)) - if (pl->obj != 0) { - position pos = pl->obj->origin(); - pl->obj = 0; - pl->x = pos.x; - pl->y = pos.y; - } - while (olist.head != 0) { - object *tem = olist.head; - olist.head = olist.head->next; - delete tem; - } - olist.tail = 0; - current_direction = RIGHT_DIRECTION; - current_position.x = 0.0; - current_position.y = 0.0; -} - -const char *ordinal_postfix(int n) -{ - if (n < 10 || n > 20) - switch (n % 10) { - case 1: - return "st"; - case 2: - return "nd"; - case 3: - return "rd"; - } - return "th"; -} - -const char *object_type_name(object_type type) -{ - switch (type) { - case BOX_OBJECT: - return "box"; - case CIRCLE_OBJECT: - return "circle"; - case ELLIPSE_OBJECT: - return "ellipse"; - case ARC_OBJECT: - return "arc"; - case SPLINE_OBJECT: - return "spline"; - case LINE_OBJECT: - return "line"; - case ARROW_OBJECT: - return "arrow"; - case MOVE_OBJECT: - return "move"; - case TEXT_OBJECT: - return "\"\""; - case BLOCK_OBJECT: - return "[]"; - case OTHER_OBJECT: - case MARK_OBJECT: - default: - break; - } - return "object"; -} - -static char sprintf_buf[1024]; - -char *format_number(const char *form, double n) -{ - if (form == 0) - form = "%g"; - else { - // this is a fairly feeble attempt at validation of the format - int nspecs = 0; - for (const char *p = form; *p != '\0'; p++) - if (*p == '%') { - if (p[1] == '%') - p++; - else - nspecs++; - } - if (nspecs > 1) { - lex_error("bad format `%1'", form); - return strsave(form); - } - } - sprintf(sprintf_buf, form, n); - return strsave(sprintf_buf); -} - -char *do_sprintf(const char *form, const double *v, int nv) -{ - string result; - int i = 0; - string one_format; - while (*form) { - if (*form == '%') { - one_format += *form++; - for (; *form != '\0' && strchr("#-+ 0123456789.", *form) != 0; form++) - one_format += *form; - if (*form == '\0' || strchr("eEfgG%", *form) == 0) { - lex_error("bad sprintf format"); - result += one_format; - result += form; - break; - } - if (*form == '%') { - one_format += *form++; - one_format += '\0'; - sprintf(sprintf_buf, one_format.contents()); - } - else { - if (i >= nv) { - lex_error("too few arguments to sprintf"); - result += one_format; - result += form; - break; - } - one_format += *form++; - one_format += '\0'; - sprintf(sprintf_buf, one_format.contents(), v[i++]); - } - one_format.clear(); - result += sprintf_buf; - } - else - result += *form++; - } - result += '\0'; - return strsave(result.contents()); -} -#line 3387 "y.tab.c" -#define YYABORT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", yystate, - yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, shifting to state %d\n", - yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, error recovery shifting\ - to state %d\n", *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("yydebug: error recovery discarding state %d\n", - *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, error recovery discards token %d (%s)\n", - yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, reducing by rule %d (%s)\n", - yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 2: -#line 272 "/u/jjc/groff/pic/pic.y" -{ - if (olist.head) - print_picture(olist.head); - } -break; -case 3: -#line 281 "/u/jjc/groff/pic/pic.y" -{ yyval.pl = yyvsp[-1].pl; } -break; -case 4: -#line 286 "/u/jjc/groff/pic/pic.y" -{ yyval.pl = yyvsp[0].pl; } -break; -case 5: -#line 288 "/u/jjc/groff/pic/pic.y" -{ yyval.pl = yyvsp[-2].pl; } -break; -case 10: -#line 303 "/u/jjc/groff/pic/pic.y" -{ - define_variable(yyvsp[-2].str, yyvsp[0].x); - a_delete yyvsp[-2].str; - } -break; -case 11: -#line 308 "/u/jjc/groff/pic/pic.y" -{ - place *p = lookup_label(yyvsp[-3].str); - if (!p) { - lex_error("variable `%1' not defined", yyvsp[-3].str); - YYABORT; - } - p->obj = 0; - p->x = yyvsp[0].x; - p->y = 0.0; - a_delete yyvsp[-3].str; - } -break; -case 12: -#line 320 "/u/jjc/groff/pic/pic.y" -{ current_direction = UP_DIRECTION; } -break; -case 13: -#line 322 "/u/jjc/groff/pic/pic.y" -{ current_direction = DOWN_DIRECTION; } -break; -case 14: -#line 324 "/u/jjc/groff/pic/pic.y" -{ current_direction = LEFT_DIRECTION; } -break; -case 15: -#line 326 "/u/jjc/groff/pic/pic.y" -{ current_direction = RIGHT_DIRECTION; } -break; -case 16: -#line 328 "/u/jjc/groff/pic/pic.y" -{ - olist.append(make_command_object(yyvsp[0].lstr.str, yyvsp[0].lstr.filename, - yyvsp[0].lstr.lineno)); - } -break; -case 17: -#line 333 "/u/jjc/groff/pic/pic.y" -{ - olist.append(make_command_object(yyvsp[0].lstr.str, yyvsp[0].lstr.filename, - yyvsp[0].lstr.lineno)); - } -break; -case 18: -#line 338 "/u/jjc/groff/pic/pic.y" -{ - fprintf(stderr, "%s\n", yyvsp[0].lstr.str); - a_delete yyvsp[0].lstr.str; - fflush(stderr); - } -break; -case 19: -#line 344 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 1; } -break; -case 20: -#line 346 "/u/jjc/groff/pic/pic.y" -{ - delim_flag = 0; - system(yyvsp[0].str); - a_delete yyvsp[0].str; - } -break; -case 21: -#line 352 "/u/jjc/groff/pic/pic.y" -{ - if (yychar < 0) - do_lookahead(); - do_copy(yyvsp[0].lstr.str); - /* do not delete the filename*/ - } -break; -case 22: -#line 359 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 2; } -break; -case 23: -#line 361 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 0; } -break; -case 24: -#line 363 "/u/jjc/groff/pic/pic.y" -{ - if (yychar < 0) - do_lookahead(); - copy_file_thru(yyvsp[-5].lstr.str, yyvsp[-2].str, yyvsp[0].str); - /* do not delete the filename*/ - a_delete yyvsp[-2].str; - a_delete yyvsp[0].str; - } -break; -case 25: -#line 372 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 2; } -break; -case 26: -#line 374 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 0; } -break; -case 27: -#line 376 "/u/jjc/groff/pic/pic.y" -{ - if (yychar < 0) - do_lookahead(); - copy_rest_thru(yyvsp[-2].str, yyvsp[0].str); - a_delete yyvsp[-2].str; - a_delete yyvsp[0].str; - } -break; -case 28: -#line 384 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 1; } -break; -case 29: -#line 386 "/u/jjc/groff/pic/pic.y" -{ - delim_flag = 0; - if (yychar < 0) - do_lookahead(); - do_for(yyvsp[-8].str, yyvsp[-6].x, yyvsp[-4].x, yyvsp[-3].by.is_multiplicative, yyvsp[-3].by.val, yyvsp[0].str); - } -break; -case 30: -#line 393 "/u/jjc/groff/pic/pic.y" -{ - if (yychar < 0) - do_lookahead(); - if (yyvsp[0].if_data.x != 0.0) - push_body(yyvsp[0].if_data.body); - a_delete yyvsp[0].if_data.body; - } -break; -case 31: -#line 401 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 1; } -break; -case 32: -#line 403 "/u/jjc/groff/pic/pic.y" -{ - delim_flag = 0; - if (yychar < 0) - do_lookahead(); - if (yyvsp[-3].if_data.x != 0.0) - push_body(yyvsp[-3].if_data.body); - else - push_body(yyvsp[0].str); - a_delete yyvsp[-3].if_data.body; - a_delete yyvsp[0].str; - } -break; -case 34: -#line 416 "/u/jjc/groff/pic/pic.y" -{ define_variable("scale", 1.0); } -break; -case 35: -#line 421 "/u/jjc/groff/pic/pic.y" -{ reset(yyvsp[0].str); a_delete yyvsp[0].str; } -break; -case 36: -#line 423 "/u/jjc/groff/pic/pic.y" -{ reset(yyvsp[0].str); a_delete yyvsp[0].str; } -break; -case 37: -#line 425 "/u/jjc/groff/pic/pic.y" -{ reset(yyvsp[0].str); a_delete yyvsp[0].str; } -break; -case 38: -#line 430 "/u/jjc/groff/pic/pic.y" -{ yyval.lstr = yyvsp[0].lstr; } -break; -case 39: -#line 432 "/u/jjc/groff/pic/pic.y" -{ - yyval.lstr.str = new char[strlen(yyvsp[-1].lstr.str) + strlen(yyvsp[0].lstr.str) + 1]; - strcpy(yyval.lstr.str, yyvsp[-1].lstr.str); - strcat(yyval.lstr.str, yyvsp[0].lstr.str); - a_delete yyvsp[-1].lstr.str; - a_delete yyvsp[0].lstr.str; - if (yyvsp[-1].lstr.filename) { - yyval.lstr.filename = yyvsp[-1].lstr.filename; - yyval.lstr.lineno = yyvsp[-1].lstr.lineno; - } - else if (yyvsp[0].lstr.filename) { - yyval.lstr.filename = yyvsp[0].lstr.filename; - yyval.lstr.lineno = yyvsp[0].lstr.lineno; - } - } -break; -case 40: -#line 451 "/u/jjc/groff/pic/pic.y" -{ - yyval.lstr.str = new char[GDIGITS + 1]; - sprintf(yyval.lstr.str, "%g", yyvsp[0].x); - yyval.lstr.filename = 0; - yyval.lstr.lineno = 0; - } -break; -case 41: -#line 458 "/u/jjc/groff/pic/pic.y" -{ yyval.lstr = yyvsp[0].lstr; } -break; -case 42: -#line 460 "/u/jjc/groff/pic/pic.y" -{ - yyval.lstr.str = new char[GDIGITS + 2 + GDIGITS + 1]; - sprintf(yyval.lstr.str, "%g, %g", yyvsp[0].pair.x, yyvsp[0].pair.y); - yyval.lstr.filename = 0; - yyval.lstr.lineno = 0; - } -break; -case 43: -#line 469 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 1; } -break; -case 44: -#line 471 "/u/jjc/groff/pic/pic.y" -{ delim_flag = 0; yyval.if_data.x = yyvsp[-3].x; yyval.if_data.body = yyvsp[0].str; } -break; -case 45: -#line 476 "/u/jjc/groff/pic/pic.y" -{ yyval.str = 0; } -break; -case 46: -#line 478 "/u/jjc/groff/pic/pic.y" -{ yyval.str = yyvsp[0].lstr.str; } -break; -case 47: -#line 483 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[0].x; } -break; -case 48: -#line 485 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[0].x; } -break; -case 49: -#line 490 "/u/jjc/groff/pic/pic.y" -{ - yyval.x = strcmp(yyvsp[-2].lstr.str, yyvsp[0].lstr.str) == 0; - a_delete yyvsp[-2].lstr.str; - a_delete yyvsp[0].lstr.str; - } -break; -case 50: -#line 496 "/u/jjc/groff/pic/pic.y" -{ - yyval.x = strcmp(yyvsp[-2].lstr.str, yyvsp[0].lstr.str) != 0; - a_delete yyvsp[-2].lstr.str; - a_delete yyvsp[0].lstr.str; - } -break; -case 51: -#line 502 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 && yyvsp[0].x != 0.0); } -break; -case 52: -#line 504 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 && yyvsp[0].x != 0.0); } -break; -case 53: -#line 506 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 && yyvsp[0].x != 0.0); } -break; -case 54: -#line 508 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 || yyvsp[0].x != 0.0); } -break; -case 55: -#line 510 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 || yyvsp[0].x != 0.0); } -break; -case 56: -#line 512 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 || yyvsp[0].x != 0.0); } -break; -case 57: -#line 514 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[0].x == 0.0); } -break; -case 58: -#line 520 "/u/jjc/groff/pic/pic.y" -{ yyval.by.val = 1.0; yyval.by.is_multiplicative = 0; } -break; -case 59: -#line 522 "/u/jjc/groff/pic/pic.y" -{ yyval.by.val = yyvsp[0].x; yyval.by.is_multiplicative = 0; } -break; -case 60: -#line 524 "/u/jjc/groff/pic/pic.y" -{ yyval.by.val = yyvsp[0].x; yyval.by.is_multiplicative = 1; } -break; -case 61: -#line 529 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl.obj = yyvsp[0].spec->make_object(¤t_position, - ¤t_direction); - if (yyval.pl.obj == 0) - YYABORT; - delete yyvsp[0].spec; - if (yyval.pl.obj) - olist.append(yyval.pl.obj); - else { - yyval.pl.x = current_position.x; - yyval.pl.y = current_position.y; - } - } -break; -case 62: -#line 543 "/u/jjc/groff/pic/pic.y" -{ yyval.pl = yyvsp[0].pl; define_label(yyvsp[-3].str, & yyval.pl); a_delete yyvsp[-3].str; } -break; -case 63: -#line 545 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl.obj = 0; - yyval.pl.x = yyvsp[0].pair.x; - yyval.pl.y = yyvsp[0].pair.y; - define_label(yyvsp[-3].str, & yyval.pl); - a_delete yyvsp[-3].str; - } -break; -case 64: -#line 553 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl = yyvsp[0].pl; - define_label(yyvsp[-3].str, & yyval.pl); - a_delete yyvsp[-3].str; - } -break; -case 65: -#line 559 "/u/jjc/groff/pic/pic.y" -{ - yyval.state.x = current_position.x; - yyval.state.y = current_position.y; - yyval.state.dir = current_direction; - } -break; -case 66: -#line 565 "/u/jjc/groff/pic/pic.y" -{ - current_position.x = yyvsp[-2].state.x; - current_position.y = yyvsp[-2].state.y; - current_direction = yyvsp[-2].state.dir; - } -break; -case 67: -#line 571 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl = yyvsp[-3].pl; - } -break; -case 68: -#line 575 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl.obj = 0; - yyval.pl.x = current_position.x; - yyval.pl.y = current_position.y; - } -break; -case 69: -#line 584 "/u/jjc/groff/pic/pic.y" -{} -break; -case 70: -#line 586 "/u/jjc/groff/pic/pic.y" -{} -break; -case 71: -#line 591 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(BOX_OBJECT); - } -break; -case 72: -#line 595 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(CIRCLE_OBJECT); - } -break; -case 73: -#line 599 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(ELLIPSE_OBJECT); - } -break; -case 74: -#line 603 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(ARC_OBJECT); - yyval.spec->dir = current_direction; - } -break; -case 75: -#line 608 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(LINE_OBJECT); - lookup_variable("lineht", & yyval.spec->segment_height); - lookup_variable("linewid", & yyval.spec->segment_width); - yyval.spec->dir = current_direction; - } -break; -case 76: -#line 615 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(ARROW_OBJECT); - lookup_variable("lineht", & yyval.spec->segment_height); - lookup_variable("linewid", & yyval.spec->segment_width); - yyval.spec->dir = current_direction; - } -break; -case 77: -#line 622 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(MOVE_OBJECT); - lookup_variable("moveht", & yyval.spec->segment_height); - lookup_variable("movewid", & yyval.spec->segment_width); - yyval.spec->dir = current_direction; - } -break; -case 78: -#line 629 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(SPLINE_OBJECT); - lookup_variable("lineht", & yyval.spec->segment_height); - lookup_variable("linewid", & yyval.spec->segment_width); - yyval.spec->dir = current_direction; - } -break; -case 79: -#line 636 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(TEXT_OBJECT); - yyval.spec->text = new text_item(yyvsp[0].lstr.str, yyvsp[0].lstr.filename, yyvsp[0].lstr.lineno); - } -break; -case 80: -#line 641 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(TEXT_OBJECT); - yyval.spec->text = new text_item(format_number(0, yyvsp[0].x), 0, -1); - } -break; -case 81: -#line 646 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = new object_spec(TEXT_OBJECT); - yyval.spec->text = new text_item(format_number(yyvsp[0].lstr.str, yyvsp[-1].x), - yyvsp[0].lstr.filename, yyvsp[0].lstr.lineno); - a_delete yyvsp[0].lstr.str; - } -break; -case 82: -#line 653 "/u/jjc/groff/pic/pic.y" -{ - saved_state *p = new saved_state; - yyval.pstate = p; - p->x = current_position.x; - p->y = current_position.y; - p->dir = current_direction; - p->tbl = current_table; - p->prev = current_saved_state; - current_position.x = 0.0; - current_position.y = 0.0; - current_table = new PTABLE(place); - current_saved_state = p; - olist.append(make_mark_object()); - } -break; -case 83: -#line 668 "/u/jjc/groff/pic/pic.y" -{ - current_position.x = yyvsp[-2].pstate->x; - current_position.y = yyvsp[-2].pstate->y; - current_direction = yyvsp[-2].pstate->dir; - yyval.spec = new object_spec(BLOCK_OBJECT); - olist.wrap_up_block(& yyval.spec->oblist); - yyval.spec->tbl = current_table; - current_table = yyvsp[-2].pstate->tbl; - current_saved_state = yyvsp[-2].pstate->prev; - delete yyvsp[-2].pstate; - } -break; -case 84: -#line 680 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->height = yyvsp[0].x; - yyval.spec->flags |= HAS_HEIGHT; - } -break; -case 85: -#line 686 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->radius = yyvsp[0].x; - yyval.spec->flags |= HAS_RADIUS; - } -break; -case 86: -#line 692 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->width = yyvsp[0].x; - yyval.spec->flags |= HAS_WIDTH; - } -break; -case 87: -#line 698 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->radius = yyvsp[0].x/2.0; - yyval.spec->flags |= HAS_RADIUS; - } -break; -case 88: -#line 704 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= HAS_SEGMENT; - switch (yyval.spec->dir) { - case UP_DIRECTION: - yyval.spec->segment_pos.y += yyvsp[0].x; - break; - case DOWN_DIRECTION: - yyval.spec->segment_pos.y -= yyvsp[0].x; - break; - case RIGHT_DIRECTION: - yyval.spec->segment_pos.x += yyvsp[0].x; - break; - case LEFT_DIRECTION: - yyval.spec->segment_pos.x -= yyvsp[0].x; - break; - } - } -break; -case 89: -#line 723 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->dir = UP_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.y += yyval.spec->segment_height; - } -break; -case 90: -#line 730 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->dir = UP_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.y += yyvsp[0].x; - } -break; -case 91: -#line 737 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->dir = DOWN_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.y -= yyval.spec->segment_height; - } -break; -case 92: -#line 744 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->dir = DOWN_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.y -= yyvsp[0].x; - } -break; -case 93: -#line 751 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->dir = RIGHT_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x += yyval.spec->segment_width; - } -break; -case 94: -#line 758 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->dir = RIGHT_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x += yyvsp[0].x; - } -break; -case 95: -#line 765 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->dir = LEFT_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x -= yyval.spec->segment_width; - } -break; -case 96: -#line 772 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->dir = LEFT_DIRECTION; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x -= yyvsp[0].x; - } -break; -case 97: -#line 779 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= HAS_FROM; - yyval.spec->from.x = yyvsp[0].pair.x; - yyval.spec->from.y = yyvsp[0].pair.y; - } -break; -case 98: -#line 786 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - if (yyval.spec->flags & HAS_SEGMENT) - yyval.spec->segment_list = new segment(yyval.spec->segment_pos, - yyval.spec->segment_is_absolute, - yyval.spec->segment_list); - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x = yyvsp[0].pair.x; - yyval.spec->segment_pos.y = yyvsp[0].pair.y; - yyval.spec->segment_is_absolute = 1; - yyval.spec->flags |= HAS_TO; - yyval.spec->to.x = yyvsp[0].pair.x; - yyval.spec->to.y = yyvsp[0].pair.y; - } -break; -case 99: -#line 801 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= HAS_AT; - yyval.spec->at.x = yyvsp[0].pair.x; - yyval.spec->at.y = yyvsp[0].pair.y; - if (yyval.spec->type != ARC_OBJECT) { - yyval.spec->flags |= HAS_FROM; - yyval.spec->from.x = yyvsp[0].pair.x; - yyval.spec->from.y = yyvsp[0].pair.y; - } - } -break; -case 100: -#line 813 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= HAS_WITH; - yyval.spec->with = yyvsp[0].pth; - } -break; -case 101: -#line 819 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= HAS_SEGMENT; - yyval.spec->segment_pos.x += yyvsp[0].pair.x; - yyval.spec->segment_pos.y += yyvsp[0].pair.y; - } -break; -case 102: -#line 826 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - if (yyval.spec->flags & HAS_SEGMENT) { - yyval.spec->segment_list = new segment(yyval.spec->segment_pos, - yyval.spec->segment_is_absolute, - yyval.spec->segment_list); - yyval.spec->flags &= ~HAS_SEGMENT; - yyval.spec->segment_pos.x = yyval.spec->segment_pos.y = 0.0; - yyval.spec->segment_is_absolute = 0; - } - } -break; -case 103: -#line 838 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_DOTTED; - lookup_variable("dashwid", & yyval.spec->dash_width); - } -break; -case 104: -#line 844 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= IS_DOTTED; - yyval.spec->dash_width = yyvsp[0].x; - } -break; -case 105: -#line 850 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_DASHED; - lookup_variable("dashwid", & yyval.spec->dash_width); - } -break; -case 106: -#line 856 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= IS_DASHED; - yyval.spec->dash_width = yyvsp[0].x; - } -break; -case 107: -#line 862 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_DEFAULT_FILLED; - } -break; -case 108: -#line 867 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= IS_FILLED; - yyval.spec->fill = yyvsp[0].x; - } -break; -case 109: -#line 873 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - /* line chop chop means line chop 0 chop 0*/ - if (yyval.spec->flags & IS_DEFAULT_CHOPPED) { - yyval.spec->flags |= IS_CHOPPED; - yyval.spec->flags &= ~IS_DEFAULT_CHOPPED; - yyval.spec->start_chop = yyval.spec->end_chop = 0.0; - } - else if (yyval.spec->flags & IS_CHOPPED) { - yyval.spec->end_chop = 0.0; - } - else { - yyval.spec->flags |= IS_DEFAULT_CHOPPED; - } - } -break; -case 110: -#line 889 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - if (yyval.spec->flags & IS_DEFAULT_CHOPPED) { - yyval.spec->flags |= IS_CHOPPED; - yyval.spec->flags &= ~IS_DEFAULT_CHOPPED; - yyval.spec->start_chop = 0.0; - yyval.spec->end_chop = yyvsp[0].x; - } - else if (yyval.spec->flags & IS_CHOPPED) { - yyval.spec->end_chop = yyvsp[0].x; - } - else { - yyval.spec->start_chop = yyval.spec->end_chop = yyvsp[0].x; - yyval.spec->flags |= IS_CHOPPED; - } - } -break; -case 111: -#line 906 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_SAME; - } -break; -case 112: -#line 911 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_INVISIBLE; - } -break; -case 113: -#line 916 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= HAS_LEFT_ARROW_HEAD; - } -break; -case 114: -#line 921 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= HAS_RIGHT_ARROW_HEAD; - } -break; -case 115: -#line 926 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= (HAS_LEFT_ARROW_HEAD|HAS_RIGHT_ARROW_HEAD); - } -break; -case 116: -#line 931 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_CLOCKWISE; - } -break; -case 117: -#line 936 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags &= ~IS_CLOCKWISE; - } -break; -case 118: -#line 941 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - for (text_item **p = & yyval.spec->text; *p; p = &(*p)->next) - ; - *p = new text_item(yyvsp[0].lstr.str, yyvsp[0].lstr.filename, yyvsp[0].lstr.lineno); - } -break; -case 119: -#line 948 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - if (yyval.spec->text) { - for (text_item *p = yyval.spec->text; p->next; p = p->next) - ; - p->adj.h = LEFT_ADJUST; - } - } -break; -case 120: -#line 957 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - if (yyval.spec->text) { - for (text_item *p = yyval.spec->text; p->next; p = p->next) - ; - p->adj.h = RIGHT_ADJUST; - } - } -break; -case 121: -#line 966 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - if (yyval.spec->text) { - for (text_item *p = yyval.spec->text; p->next; p = p->next) - ; - p->adj.v = ABOVE_ADJUST; - } - } -break; -case 122: -#line 975 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - if (yyval.spec->text) { - for (text_item *p = yyval.spec->text; p->next; p = p->next) - ; - p->adj.v = BELOW_ADJUST; - } - } -break; -case 123: -#line 984 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-2].spec; - yyval.spec->flags |= HAS_THICKNESS; - yyval.spec->thickness = yyvsp[0].x; - } -break; -case 124: -#line 990 "/u/jjc/groff/pic/pic.y" -{ - yyval.spec = yyvsp[-1].spec; - yyval.spec->flags |= IS_ALIGNED; - } -break; -case 125: -#line 998 "/u/jjc/groff/pic/pic.y" -{ - yyval.lstr = yyvsp[0].lstr; - } -break; -case 126: -#line 1002 "/u/jjc/groff/pic/pic.y" -{ - yyval.lstr.filename = yyvsp[-2].lstr.filename; - yyval.lstr.lineno = yyvsp[-2].lstr.lineno; - yyval.lstr.str = do_sprintf(yyvsp[-2].lstr.str, yyvsp[-1].dv.v, yyvsp[-1].dv.nv); - a_delete yyvsp[-1].dv.v; - a_delete yyvsp[-2].lstr.str; - } -break; -case 127: -#line 1013 "/u/jjc/groff/pic/pic.y" -{ - yyval.dv.v = 0; - yyval.dv.nv = 0; - yyval.dv.maxv = 0; - } -break; -case 128: -#line 1019 "/u/jjc/groff/pic/pic.y" -{ - yyval.dv = yyvsp[-2].dv; - if (yyval.dv.nv >= yyval.dv.maxv) { - if (yyval.dv.nv == 0) { - yyval.dv.v = new double[4]; - yyval.dv.maxv = 4; - } - else { - double *oldv = yyval.dv.v; - yyval.dv.maxv *= 2; - yyval.dv.v = new double[yyval.dv.maxv]; - memcpy(yyval.dv.v, oldv, yyval.dv.nv*sizeof(double)); - a_delete oldv; - } - } - yyval.dv.v[yyval.dv.nv] = yyvsp[0].x; - yyval.dv.nv += 1; - } -break; -case 129: -#line 1041 "/u/jjc/groff/pic/pic.y" -{ yyval.pair = yyvsp[0].pair; } -break; -case 130: -#line 1043 "/u/jjc/groff/pic/pic.y" -{ - position pos = yyvsp[0].pl; - yyval.pair.x = pos.x; - yyval.pair.y = pos.y; - } -break; -case 131: -#line 1052 "/u/jjc/groff/pic/pic.y" -{ yyval.pair = yyvsp[0].pair; } -break; -case 132: -#line 1054 "/u/jjc/groff/pic/pic.y" -{ - yyval.pair.x = yyvsp[-2].pair.x + yyvsp[0].pair.x; - yyval.pair.y = yyvsp[-2].pair.y + yyvsp[0].pair.y; - } -break; -case 133: -#line 1059 "/u/jjc/groff/pic/pic.y" -{ - yyval.pair.x = yyvsp[-2].pair.x - yyvsp[0].pair.x; - yyval.pair.y = yyvsp[-2].pair.y - yyvsp[0].pair.y; - } -break; -case 134: -#line 1064 "/u/jjc/groff/pic/pic.y" -{ - yyval.pair.x = yyvsp[-3].pair.x; - yyval.pair.y = yyvsp[-1].pair.y; - } -break; -case 135: -#line 1069 "/u/jjc/groff/pic/pic.y" -{ - yyval.pair.x = (1.0 - yyvsp[-4].x)*yyvsp[-2].pair.x + yyvsp[-4].x*yyvsp[0].pair.x; - yyval.pair.y = (1.0 - yyvsp[-4].x)*yyvsp[-2].pair.y + yyvsp[-4].x*yyvsp[0].pair.y; - } -break; -case 136: -#line 1074 "/u/jjc/groff/pic/pic.y" -{ - yyval.pair.x = (1.0 - yyvsp[-5].x)*yyvsp[-3].pair.x + yyvsp[-5].x*yyvsp[-1].pair.x; - yyval.pair.y = (1.0 - yyvsp[-5].x)*yyvsp[-3].pair.y + yyvsp[-5].x*yyvsp[-1].pair.y; - } -break; -case 139: -#line 1087 "/u/jjc/groff/pic/pic.y" -{ yyval.pair.x = yyvsp[-2].x; yyval.pair.y = yyvsp[0].x; } -break; -case 140: -#line 1089 "/u/jjc/groff/pic/pic.y" -{ yyval.pair = yyvsp[-1].pair; } -break; -case 141: -#line 1094 "/u/jjc/groff/pic/pic.y" -{ yyval.pl = yyvsp[0].pl; } -break; -case 142: -#line 1096 "/u/jjc/groff/pic/pic.y" -{ - path pth(yyvsp[0].crn); - if (!pth.follow(yyvsp[-1].pl, & yyval.pl)) - YYABORT; - } -break; -case 143: -#line 1102 "/u/jjc/groff/pic/pic.y" -{ - path pth(yyvsp[-1].crn); - if (!pth.follow(yyvsp[0].pl, & yyval.pl)) - YYABORT; - } -break; -case 144: -#line 1108 "/u/jjc/groff/pic/pic.y" -{ - path pth(yyvsp[-2].crn); - if (!pth.follow(yyvsp[0].pl, & yyval.pl)) - YYABORT; - } -break; -case 145: -#line 1114 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl.x = current_position.x; - yyval.pl.y = current_position.y; - yyval.pl.obj = 0; - } -break; -case 146: -#line 1123 "/u/jjc/groff/pic/pic.y" -{ - place *p = lookup_label(yyvsp[0].str); - if (!p) { - lex_error("there is no place `%1'", yyvsp[0].str); - YYABORT; - } - yyval.pl = *p; - a_delete yyvsp[0].str; - } -break; -case 147: -#line 1133 "/u/jjc/groff/pic/pic.y" -{ - yyval.pl.obj = yyvsp[0].obj; - } -break; -case 148: -#line 1137 "/u/jjc/groff/pic/pic.y" -{ - path pth(yyvsp[0].str); - if (!pth.follow(yyvsp[-2].pl, & yyval.pl)) - YYABORT; - } -break; -case 149: -#line 1146 "/u/jjc/groff/pic/pic.y" -{ yyval.n = yyvsp[0].n; } -break; -case 150: -#line 1148 "/u/jjc/groff/pic/pic.y" -{ - /* XXX Check for overflow (and non-integers?).*/ - yyval.n = (int)yyvsp[-1].x; - } -break; -case 151: -#line 1156 "/u/jjc/groff/pic/pic.y" -{ yyval.n = 1; } -break; -case 152: -#line 1158 "/u/jjc/groff/pic/pic.y" -{ yyval.n = yyvsp[-1].n; } -break; -case 153: -#line 1163 "/u/jjc/groff/pic/pic.y" -{ - int count = 0; - for (object *p = olist.head; p != 0; p = p->next) - if (p->type() == yyvsp[0].obtype && ++count == yyvsp[-1].n) { - yyval.obj = p; - break; - } - if (p == 0) { - lex_error("there is no %1%2 %3", yyvsp[-1].n, ordinal_postfix(yyvsp[-1].n), - object_type_name(yyvsp[0].obtype)); - YYABORT; - } - } -break; -case 154: -#line 1177 "/u/jjc/groff/pic/pic.y" -{ - int count = 0; - for (object *p = olist.tail; p != 0; p = p->prev) - if (p->type() == yyvsp[0].obtype && ++count == yyvsp[-1].n) { - yyval.obj = p; - break; - } - if (p == 0) { - lex_error("there is no %1%2 last %3", yyvsp[-1].n, - ordinal_postfix(yyvsp[-1].n), object_type_name(yyvsp[0].obtype)); - YYABORT; - } - } -break; -case 155: -#line 1194 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = BOX_OBJECT; } -break; -case 156: -#line 1196 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = CIRCLE_OBJECT; } -break; -case 157: -#line 1198 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = ELLIPSE_OBJECT; } -break; -case 158: -#line 1200 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = ARC_OBJECT; } -break; -case 159: -#line 1202 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = LINE_OBJECT; } -break; -case 160: -#line 1204 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = ARROW_OBJECT; } -break; -case 161: -#line 1206 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = SPLINE_OBJECT; } -break; -case 162: -#line 1208 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = BLOCK_OBJECT; } -break; -case 163: -#line 1210 "/u/jjc/groff/pic/pic.y" -{ yyval.obtype = TEXT_OBJECT; } -break; -case 164: -#line 1215 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = new path(yyvsp[0].str); - } -break; -case 165: -#line 1219 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = yyvsp[-2].pth; - yyval.pth->append(yyvsp[0].str); - } -break; -case 166: -#line 1227 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = new path(yyvsp[0].crn); - } -break; -case 167: -#line 1234 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = yyvsp[0].pth; - } -break; -case 168: -#line 1238 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = yyvsp[-1].pth; - yyval.pth->append(yyvsp[0].crn); - } -break; -case 169: -#line 1246 "/u/jjc/groff/pic/pic.y" -{ - yyval.pth = yyvsp[0].pth; - } -break; -case 170: -#line 1251 "/u/jjc/groff/pic/pic.y" -{ - lex_warning("`%1%2 last %3' in `with' argument ignored", - yyvsp[-3].n, ordinal_postfix(yyvsp[-3].n), object_type_name(yyvsp[-1].obtype)); - yyval.pth = yyvsp[0].pth; - } -break; -case 171: -#line 1257 "/u/jjc/groff/pic/pic.y" -{ - lex_warning("`last %1' in `with' argument ignored", - object_type_name(yyvsp[-1].obtype)); - yyval.pth = yyvsp[0].pth; - } -break; -case 172: -#line 1263 "/u/jjc/groff/pic/pic.y" -{ - lex_warning("`%1%2 %3' in `with' argument ignored", - yyvsp[-2].n, ordinal_postfix(yyvsp[-2].n), object_type_name(yyvsp[-1].obtype)); - yyval.pth = yyvsp[0].pth; - } -break; -case 173: -#line 1269 "/u/jjc/groff/pic/pic.y" -{ - lex_warning("initial `%1' in `with' argument ignored", yyvsp[-1].str); - a_delete yyvsp[-1].str; - yyval.pth = yyvsp[0].pth; - } -break; -case 174: -#line 1278 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north; } -break; -case 175: -#line 1280 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::east; } -break; -case 176: -#line 1282 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::west; } -break; -case 177: -#line 1284 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south; } -break; -case 178: -#line 1286 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_east; } -break; -case 179: -#line 1288 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object:: south_east; } -break; -case 180: -#line 1290 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_west; } -break; -case 181: -#line 1292 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south_west; } -break; -case 182: -#line 1294 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::center; } -break; -case 183: -#line 1296 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::start; } -break; -case 184: -#line 1298 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::end; } -break; -case 185: -#line 1300 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north; } -break; -case 186: -#line 1302 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south; } -break; -case 187: -#line 1304 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::west; } -break; -case 188: -#line 1306 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::east; } -break; -case 189: -#line 1308 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_west; } -break; -case 190: -#line 1310 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south_west; } -break; -case 191: -#line 1312 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_east; } -break; -case 192: -#line 1314 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south_east; } -break; -case 193: -#line 1316 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::west; } -break; -case 194: -#line 1318 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::east; } -break; -case 195: -#line 1320 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_west; } -break; -case 196: -#line 1322 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south_west; } -break; -case 197: -#line 1324 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::north_east; } -break; -case 198: -#line 1326 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::south_east; } -break; -case 199: -#line 1328 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::center; } -break; -case 200: -#line 1330 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::start; } -break; -case 201: -#line 1332 "/u/jjc/groff/pic/pic.y" -{ yyval.crn = &object::end; } -break; -case 202: -#line 1337 "/u/jjc/groff/pic/pic.y" -{ - if (!lookup_variable(yyvsp[0].str, & yyval.x)) { - lex_error("there is no variable `%1'", yyvsp[0].str); - YYABORT; - } - a_delete yyvsp[0].str; - } -break; -case 203: -#line 1345 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[0].x; } -break; -case 204: -#line 1347 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[-1].pl.obj != 0) - yyval.x = yyvsp[-1].pl.obj->origin().x; - else - yyval.x = yyvsp[-1].pl.x; - } -break; -case 205: -#line 1354 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[-1].pl.obj != 0) - yyval.x = yyvsp[-1].pl.obj->origin().y; - else - yyval.x = yyvsp[-1].pl.y; - } -break; -case 206: -#line 1361 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[-1].pl.obj != 0) - yyval.x = yyvsp[-1].pl.obj->height(); - else - yyval.x = 0.0; - } -break; -case 207: -#line 1368 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[-1].pl.obj != 0) - yyval.x = yyvsp[-1].pl.obj->width(); - else - yyval.x = 0.0; - } -break; -case 208: -#line 1375 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[-1].pl.obj != 0) - yyval.x = yyvsp[-1].pl.obj->radius(); - else - yyval.x = 0.0; - } -break; -case 209: -#line 1382 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-2].x + yyvsp[0].x; } -break; -case 210: -#line 1384 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-2].x - yyvsp[0].x; } -break; -case 211: -#line 1386 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-2].x * yyvsp[0].x; } -break; -case 212: -#line 1388 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[0].x == 0.0) { - lex_error("division by zero"); - YYABORT; - } - yyval.x = yyvsp[-2].x/yyvsp[0].x; - } -break; -case 213: -#line 1396 "/u/jjc/groff/pic/pic.y" -{ - if (yyvsp[0].x == 0.0) { - lex_error("modulus by zero"); - YYABORT; - } - yyval.x = fmod(yyvsp[-2].x, yyvsp[0].x); - } -break; -case 214: -#line 1404 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = pow(yyvsp[-2].x, yyvsp[0].x); - if (errno == EDOM) { - lex_error("arguments to `^' operator out of domain"); - YYABORT; - } - if (errno == ERANGE) { - lex_error("result of `^' operator out of range"); - YYABORT; - } - } -break; -case 215: -#line 1417 "/u/jjc/groff/pic/pic.y" -{ yyval.x = -yyvsp[0].x; } -break; -case 216: -#line 1419 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-1].x; } -break; -case 217: -#line 1421 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = sin(yyvsp[-1].x); - if (errno == ERANGE) { - lex_error("sin result out of range"); - YYABORT; - } - } -break; -case 218: -#line 1430 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = cos(yyvsp[-1].x); - if (errno == ERANGE) { - lex_error("cos result out of range"); - YYABORT; - } - } -break; -case 219: -#line 1439 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = atan2(yyvsp[-3].x, yyvsp[-1].x); - if (errno == EDOM) { - lex_error("atan2 argument out of domain"); - YYABORT; - } - if (errno == ERANGE) { - lex_error("atan2 result out of range"); - YYABORT; - } - } -break; -case 220: -#line 1452 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = log10(yyvsp[-1].x); - if (errno == ERANGE) { - lex_error("log result out of range"); - YYABORT; - } - } -break; -case 221: -#line 1461 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = pow(10.0, yyvsp[-1].x); - if (errno == ERANGE) { - lex_error("exp result out of range"); - YYABORT; - } - } -break; -case 222: -#line 1470 "/u/jjc/groff/pic/pic.y" -{ - errno = 0; - yyval.x = sqrt(yyvsp[-1].x); - if (errno == EDOM) { - lex_error("sqrt argument out of domain"); - YYABORT; - } - } -break; -case 223: -#line 1479 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-3].x > yyvsp[-1].x ? yyvsp[-3].x : yyvsp[-1].x; } -break; -case 224: -#line 1481 "/u/jjc/groff/pic/pic.y" -{ yyval.x = yyvsp[-3].x < yyvsp[-1].x ? yyvsp[-3].x : yyvsp[-1].x; } -break; -case 225: -#line 1483 "/u/jjc/groff/pic/pic.y" -{ yyval.x = floor(yyvsp[-1].x); } -break; -case 226: -#line 1485 "/u/jjc/groff/pic/pic.y" -{ yyval.x = 1.0 + floor(((rand()&0x7fff)/double(0x7fff))*yyvsp[-1].x); } -break; -case 227: -#line 1487 "/u/jjc/groff/pic/pic.y" -{ - /* return a random number in the range [0,1) */ - /* portable, but not very random */ - yyval.x = (rand() & 0x7fff) / double(0x8000); - } -break; -case 228: -#line 1493 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x < yyvsp[0].x); } -break; -case 229: -#line 1495 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x <= yyvsp[0].x); } -break; -case 230: -#line 1497 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x > yyvsp[0].x); } -break; -case 231: -#line 1499 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x >= yyvsp[0].x); } -break; -case 232: -#line 1501 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x == yyvsp[0].x); } -break; -case 233: -#line 1503 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != yyvsp[0].x); } -break; -case 234: -#line 1505 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 && yyvsp[0].x != 0.0); } -break; -case 235: -#line 1507 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[-2].x != 0.0 || yyvsp[0].x != 0.0); } -break; -case 236: -#line 1509 "/u/jjc/groff/pic/pic.y" -{ yyval.x = (yyvsp[0].x == 0.0); } -break; -#line 5111 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state 0 to\ - state %d\n", YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", - YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state %d \ -to state %d\n", *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/gnu/usr.bin/groff/pic/pic.tab.h b/gnu/usr.bin/groff/pic/pic.tab.h deleted file mode 100644 index c71bdfd2cd3e..000000000000 --- a/gnu/usr.bin/groff/pic/pic.tab.h +++ /dev/null @@ -1,129 +0,0 @@ -#define LABEL 257 -#define VARIABLE 258 -#define NUMBER 259 -#define TEXT 260 -#define COMMAND_LINE 261 -#define DELIMITED 262 -#define ORDINAL 263 -#define TH 264 -#define LEFT_ARROW_HEAD 265 -#define RIGHT_ARROW_HEAD 266 -#define DOUBLE_ARROW_HEAD 267 -#define LAST 268 -#define UP 269 -#define DOWN 270 -#define LEFT 271 -#define RIGHT 272 -#define BOX 273 -#define CIRCLE 274 -#define ELLIPSE 275 -#define ARC 276 -#define LINE 277 -#define ARROW 278 -#define MOVE 279 -#define SPLINE 280 -#define HEIGHT 281 -#define RADIUS 282 -#define WIDTH 283 -#define DIAMETER 284 -#define FROM 285 -#define TO 286 -#define AT 287 -#define WITH 288 -#define BY 289 -#define THEN 290 -#define DOTTED 291 -#define DASHED 292 -#define CHOP 293 -#define SAME 294 -#define INVISIBLE 295 -#define LJUST 296 -#define RJUST 297 -#define ABOVE 298 -#define BELOW 299 -#define OF 300 -#define THE 301 -#define WAY 302 -#define BETWEEN 303 -#define AND 304 -#define HERE 305 -#define DOT_N 306 -#define DOT_E 307 -#define DOT_W 308 -#define DOT_S 309 -#define DOT_NE 310 -#define DOT_SE 311 -#define DOT_NW 312 -#define DOT_SW 313 -#define DOT_C 314 -#define DOT_START 315 -#define DOT_END 316 -#define DOT_X 317 -#define DOT_Y 318 -#define DOT_HT 319 -#define DOT_WID 320 -#define DOT_RAD 321 -#define SIN 322 -#define COS 323 -#define ATAN2 324 -#define LOG 325 -#define EXP 326 -#define SQRT 327 -#define K_MAX 328 -#define K_MIN 329 -#define INT 330 -#define RAND 331 -#define COPY 332 -#define THRU 333 -#define TOP 334 -#define BOTTOM 335 -#define UPPER 336 -#define LOWER 337 -#define SH 338 -#define PRINT 339 -#define CW 340 -#define CCW 341 -#define FOR 342 -#define DO 343 -#define IF 344 -#define ELSE 345 -#define ANDAND 346 -#define OROR 347 -#define NOTEQUAL 348 -#define EQUALEQUAL 349 -#define LESSEQUAL 350 -#define GREATEREQUAL 351 -#define LEFT_CORNER 352 -#define RIGHT_CORNER 353 -#define CENTER 354 -#define END 355 -#define START 356 -#define RESET 357 -#define UNTIL 358 -#define PLOT 359 -#define THICKNESS 360 -#define FILL 361 -#define ALIGNED 362 -#define SPRINTF 363 -#define COMMAND 364 -#define DEFINE 365 -#define UNDEF 366 -typedef union { - char *str; - int n; - double x; - struct { double x, y; } pair; - struct { double x; char *body; } if_data; - struct { char *str; const char *filename; int lineno; } lstr; - struct { double *v; int nv; int maxv; } dv; - struct { double val; int is_multiplicative; } by; - place pl; - object *obj; - corner crn; - path *pth; - object_spec *spec; - saved_state *pstate; - graphics_state state; - object_type obtype; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/groff/refer/label.cc b/gnu/usr.bin/groff/refer/label.cc deleted file mode 100644 index 44254650d414..000000000000 --- a/gnu/usr.bin/groff/refer/label.cc +++ /dev/null @@ -1,1593 +0,0 @@ -#ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; -#endif -#define YYBYACC 1 -#line 22 "/u/jjc/groff/refer/label.y" - -#include "refer.h" -#include "refid.h" -#include "ref.h" -#include "token.h" - -int yylex(); -void yyerror(const char *); -int yyparse(); - -static const char *format_serial(char c, int n); - -struct label_info { - int start; - int length; - int count; - int total; - label_info(const string &); -}; - -label_info *lookup_label(const string &label); - -struct expression { - enum { - /* Does the tentative label depend on the reference?*/ - CONTAINS_VARIABLE = 01, - CONTAINS_STAR = 02, - CONTAINS_FORMAT = 04, - CONTAINS_AT = 010 - }; - virtual ~expression() { } - virtual void evaluate(int, const reference &, string &, - substring_position &) = 0; - virtual unsigned analyze() { return 0; } -}; - -class at_expr : public expression { -public: - at_expr() { } - void evaluate(int, const reference &, string &, substring_position &); - unsigned analyze() { return CONTAINS_VARIABLE|CONTAINS_AT; } -}; - -class format_expr : public expression { - char type; - int width; - int first_number; -public: - format_expr(char c, int w = 0, int f = 1) - : type(c), width(w), first_number(f) { } - void evaluate(int, const reference &, string &, substring_position &); - unsigned analyze() { return CONTAINS_FORMAT; } -}; - -class field_expr : public expression { - int number; - char name; -public: - field_expr(char nm, int num) : name(nm), number(num) { } - void evaluate(int, const reference &, string &, substring_position &); - unsigned analyze() { return CONTAINS_VARIABLE; } -}; - -class literal_expr : public expression { - string s; -public: - literal_expr(const char *ptr, int len) : s(ptr, len) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class unary_expr : public expression { -protected: - expression *expr; -public: - unary_expr(expression *e) : expr(e) { } - ~unary_expr() { delete expr; } - void evaluate(int, const reference &, string &, substring_position &) = 0; - unsigned analyze() { return expr ? expr->analyze() : 0; } -}; - -/* This caches the analysis of an expression.*/ - -class analyzed_expr : public unary_expr { - unsigned flags; -public: - analyzed_expr(expression *); - void evaluate(int, const reference &, string &, substring_position &); - unsigned analyze() { return flags; } -}; - -class star_expr : public unary_expr { -public: - star_expr(expression *e) : unary_expr(e) { } - void evaluate(int, const reference &, string &, substring_position &); - unsigned analyze() { - return ((expr ? (expr->analyze() & ~CONTAINS_VARIABLE) : 0) - | CONTAINS_STAR); - } -}; - -typedef void map_func(const char *, const char *, string &); - -class map_expr : public unary_expr { - map_func *func; -public: - map_expr(expression *e, map_func *f) : unary_expr(e), func(f) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -typedef const char *extractor_func(const char *, const char *, const char **); - -class extractor_expr : public unary_expr { - int part; - extractor_func *func; -public: - enum { BEFORE = +1, MATCH = 0, AFTER = -1 }; - extractor_expr(expression *e, extractor_func *f, int pt) - : unary_expr(e), func(f), part(pt) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class truncate_expr : public unary_expr { - int n; -public: - truncate_expr(expression *e, int i) : n(i), unary_expr(e) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class separator_expr : public unary_expr { -public: - separator_expr(expression *e) : unary_expr(e) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class binary_expr : public expression { -protected: - expression *expr1; - expression *expr2; -public: - binary_expr(expression *e1, expression *e2) : expr1(e1), expr2(e2) { } - ~binary_expr() { delete expr1; delete expr2; } - void evaluate(int, const reference &, string &, substring_position &) = 0; - unsigned analyze() { - return (expr1 ? expr1->analyze() : 0) | (expr2 ? expr2->analyze() : 0); - } -}; - -class alternative_expr : public binary_expr { -public: - alternative_expr(expression *e1, expression *e2) : binary_expr(e1, e2) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class list_expr : public binary_expr { -public: - list_expr(expression *e1, expression *e2) : binary_expr(e1, e2) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class substitute_expr : public binary_expr { -public: - substitute_expr(expression *e1, expression *e2) : binary_expr(e1, e2) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -class ternary_expr : public expression { -protected: - expression *expr1; - expression *expr2; - expression *expr3; -public: - ternary_expr(expression *e1, expression *e2, expression *e3) - : expr1(e1), expr2(e2), expr3(e3) { } - ~ternary_expr() { delete expr1; delete expr2; delete expr3; } - void evaluate(int, const reference &, string &, substring_position &) = 0; - unsigned analyze() { - return ((expr1 ? expr1->analyze() : 0) - | (expr2 ? expr2->analyze() : 0) - | (expr3 ? expr3->analyze() : 0)); - } -}; - -class conditional_expr : public ternary_expr { -public: - conditional_expr(expression *e1, expression *e2, expression *e3) - : ternary_expr(e1, e2, e3) { } - void evaluate(int, const reference &, string &, substring_position &); -}; - -static expression *parsed_label = 0; -static expression *parsed_date_label = 0; -static expression *parsed_short_label = 0; - -static expression *parse_result; - -string literals; - -#line 221 "/u/jjc/groff/refer/label.y" -typedef union { - int num; - expression *expr; - struct { int ndigits; int val; } dig; - struct { int start; int len; } str; -} YYSTYPE; -#line 211 "y.tab.c" -#define TOKEN_LETTER 257 -#define TOKEN_LITERAL 258 -#define TOKEN_DIGIT 259 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 1, 1, 6, 6, 2, 2, 2, 3, 3, - 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 9, 9, 7, 7, 8, 8, - 10, 10, 10, -}; -short yylen[] = { 2, - 1, 1, 5, 0, 1, 1, 3, 3, 1, 2, - 1, 3, 1, 1, 1, 2, 2, 2, 5, 3, - 3, 2, 3, 3, 0, 1, 1, 2, 1, 2, - 0, 1, 1, -}; -short yydefred[] = { 0, - 0, 14, 13, 0, 0, 0, 0, 5, 0, 0, - 0, 0, 1, 27, 0, 17, 29, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 22, 0, 28, - 30, 23, 24, 0, 0, 0, 32, 33, 0, 0, - 0, 0, 0, 0, 3, 0, 19, -}; -short yydgoto[] = { 7, - 8, 9, 10, 11, 12, 13, 15, 18, 47, 39, -}; -short yysindex[] = { -32, - -257, 0, 0, -240, -32, -32, 0, 0, -18, -32, - -36, -114, 0, 0, -246, 0, 0, -241, -14, -39, - -32, -32, -32, -114, -21, -257, -257, 0, -32, 0, - 0, 0, 0, -25, -32, -32, 0, 0, -223, -246, - -246, -36, -32, -257, 0, -246, 0, -}; -short yyrindex[] = { 35, - 1, 0, 0, 0, -5, -4, 0, 0, 14, 208, - 159, 224, 0, 0, 11, 0, 0, 40, 0, 0, - 2, 0, 0, 253, -220, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 263, 281, 0, 0, 0, 50, - 105, 214, 0, 115, 0, 149, 0, -}; -short yygindex[] = { 0, - 19, 0, 7, 37, -10, 10, -23, 0, 0, 0, -}; -#define YYTABLESIZE 511 -short yytable[] = { 24, - 15, 14, 40, 41, 4, 28, 26, 5, 27, 25, - 16, 29, 30, 2, 19, 20, 16, 31, 17, 23, - 46, 37, 33, 38, 24, 24, 32, 6, 35, 36, - 34, 3, 43, 44, 4, 4, 31, 15, 15, 18, - 15, 15, 15, 15, 21, 15, 15, 16, 16, 20, - 16, 16, 16, 16, 2, 16, 16, 4, 15, 4, - 15, 45, 15, 15, 15, 42, 0, 0, 16, 0, - 16, 2, 16, 16, 16, 2, 18, 18, 0, 18, - 18, 18, 18, 0, 18, 18, 20, 20, 0, 20, - 20, 20, 20, 0, 20, 20, 0, 18, 0, 18, - 0, 18, 18, 18, 21, 22, 0, 20, 0, 20, - 0, 20, 20, 20, 25, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 15, 0, 15, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 16, 0, 0, 0, - 0, 21, 21, 0, 21, 21, 21, 21, 26, 21, - 21, 25, 25, 0, 25, 25, 25, 25, 11, 25, - 25, 0, 21, 18, 21, 18, 21, 21, 21, 0, - 0, 0, 25, 20, 25, 20, 25, 25, 25, 0, - 0, 0, 0, 0, 0, 26, 26, 0, 26, 26, - 26, 26, 0, 26, 26, 11, 11, 0, 11, 11, - 0, 0, 0, 0, 0, 0, 26, 6, 26, 0, - 26, 26, 26, 12, 0, 0, 11, 0, 11, 0, - 11, 11, 11, 9, 1, 2, 0, 0, 21, 0, - 21, 0, 0, 0, 0, 0, 0, 0, 25, 0, - 25, 0, 0, 0, 0, 6, 0, 0, 6, 0, - 12, 12, 10, 12, 12, 0, 0, 15, 15, 0, - 9, 9, 7, 9, 9, 6, 0, 16, 16, 6, - 6, 12, 26, 12, 26, 12, 12, 12, 0, 0, - 8, 9, 11, 9, 11, 9, 9, 9, 0, 10, - 10, 0, 10, 10, 0, 0, 18, 18, 0, 0, - 7, 0, 0, 7, 0, 0, 20, 20, 0, 0, - 10, 0, 10, 0, 10, 10, 10, 0, 8, 0, - 7, 8, 0, 0, 7, 7, 0, 0, 0, 0, - 0, 6, 0, 0, 0, 0, 0, 12, 8, 12, - 0, 0, 8, 8, 0, 0, 0, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 25, 25, 0, 0, 0, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8, 26, 26, 0, 0, 0, - 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, - 10, -}; -short yycheck[] = { 10, - 0, 259, 26, 27, 37, 42, 43, 40, 45, 46, - 0, 126, 259, 0, 5, 6, 257, 259, 259, 38, - 44, 43, 62, 45, 35, 36, 41, 60, 22, 23, - 21, 64, 58, 257, 0, 41, 257, 37, 38, 0, - 40, 41, 42, 43, 63, 45, 46, 37, 38, 0, - 40, 41, 42, 43, 41, 45, 46, 62, 58, 58, - 60, 43, 62, 63, 64, 29, -1, -1, 58, -1, - 60, 58, 62, 63, 64, 62, 37, 38, -1, 40, - 41, 42, 43, -1, 45, 46, 37, 38, -1, 40, - 41, 42, 43, -1, 45, 46, -1, 58, -1, 60, - -1, 62, 63, 64, 0, 124, -1, 58, -1, 60, - -1, 62, 63, 64, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 124, -1, 126, -1, -1, -1, - -1, -1, -1, -1, 124, -1, 126, -1, -1, -1, - -1, 37, 38, -1, 40, 41, 42, 43, 0, 45, - 46, 37, 38, -1, 40, 41, 42, 43, 0, 45, - 46, -1, 58, 124, 60, 126, 62, 63, 64, -1, - -1, -1, 58, 124, 60, 126, 62, 63, 64, -1, - -1, -1, -1, -1, -1, 37, 38, -1, 40, 41, - 42, 43, -1, 45, 46, 37, 38, -1, 40, 41, - -1, -1, -1, -1, -1, -1, 58, 0, 60, -1, - 62, 63, 64, 0, -1, -1, 58, -1, 60, -1, - 62, 63, 64, 0, 257, 258, -1, -1, 124, -1, - 126, -1, -1, -1, -1, -1, -1, -1, 124, -1, - 126, -1, -1, -1, -1, 38, -1, -1, 41, -1, - 37, 38, 0, 40, 41, -1, -1, 257, 258, -1, - 37, 38, 0, 40, 41, 58, -1, 257, 258, 62, - 63, 58, 124, 60, 126, 62, 63, 64, -1, -1, - 0, 58, 124, 60, 126, 62, 63, 64, -1, 37, - 38, -1, 40, 41, -1, -1, 257, 258, -1, -1, - 38, -1, -1, 41, -1, -1, 257, 258, -1, -1, - 58, -1, 60, -1, 62, 63, 64, -1, 38, -1, - 58, 41, -1, -1, 62, 63, -1, -1, -1, -1, - -1, 124, -1, -1, -1, -1, -1, 124, 58, 126, - -1, -1, 62, 63, -1, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 257, 258, -1, -1, -1, -1, -1, -1, -1, - -1, 257, 258, -1, -1, -1, 124, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 124, 257, 258, -1, -1, -1, - -1, -1, -1, -1, -1, 257, 258, -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, - 257, 258, -1, -1, -1, -1, -1, -1, -1, -1, - 257, 258, -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, 257, - 258, -}; -#define YYFINAL 7 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'","'.'",0,0,0,0,0,0,0,0,0,0,0, -"':'",0,"'<'",0,"'>'","'?'","'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0, -"'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,"TOKEN_LETTER","TOKEN_LITERAL","TOKEN_DIGIT", -}; -char *yyrule[] = { -"$accept : expr", -"expr : optional_conditional", -"conditional : alternative", -"conditional : alternative '?' optional_conditional ':' conditional", -"optional_conditional :", -"optional_conditional : conditional", -"alternative : list", -"alternative : alternative '|' list", -"alternative : alternative '&' list", -"list : substitute", -"list : list substitute", -"substitute : string", -"substitute : substitute '~' string", -"string : '@'", -"string : TOKEN_LITERAL", -"string : TOKEN_LETTER", -"string : TOKEN_LETTER number", -"string : '%' TOKEN_LETTER", -"string : '%' digits", -"string : string '.' flag TOKEN_LETTER optional_number", -"string : string '+' number", -"string : string '-' number", -"string : string '*'", -"string : '(' optional_conditional ')'", -"string : '<' optional_conditional '>'", -"optional_number :", -"optional_number : number", -"number : TOKEN_DIGIT", -"number : number TOKEN_DIGIT", -"digits : TOKEN_DIGIT", -"digits : digits TOKEN_DIGIT", -"flag :", -"flag : '+'", -"flag : '-'", -}; -#endif -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#ifdef YYSTACKSIZE -#ifndef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#endif -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#line 397 "/u/jjc/groff/refer/label.y" - -/* bison defines const to be empty unless __STDC__ is defined, which it -isn't under cfront */ - -#ifdef const -#undef const -#endif - -const char *spec_ptr; -const char *spec_end; -const char *spec_cur; - -int yylex() -{ - while (spec_ptr < spec_end && csspace(*spec_ptr)) - spec_ptr++; - spec_cur = spec_ptr; - if (spec_ptr >= spec_end) - return 0; - unsigned char c = *spec_ptr++; - if (csalpha(c)) { - yylval.num = c; - return TOKEN_LETTER; - } - if (csdigit(c)) { - yylval.num = c - '0'; - return TOKEN_DIGIT; - } - if (c == '\'') { - yylval.str.start = literals.length(); - for (; spec_ptr < spec_end; spec_ptr++) { - if (*spec_ptr == '\'') { - if (++spec_ptr < spec_end && *spec_ptr == '\'') - literals += '\''; - else { - yylval.str.len = literals.length() - yylval.str.start; - return TOKEN_LITERAL; - } - } - else - literals += *spec_ptr; - } - yylval.str.len = literals.length() - yylval.str.start; - return TOKEN_LITERAL; - } - return c; -} - -int set_label_spec(const char *label_spec) -{ - spec_cur = spec_ptr = label_spec; - spec_end = strchr(label_spec, '\0'); - literals.clear(); - if (yyparse()) - return 0; - delete parsed_label; - parsed_label = parse_result; - return 1; -} - -int set_date_label_spec(const char *label_spec) -{ - spec_cur = spec_ptr = label_spec; - spec_end = strchr(label_spec, '\0'); - literals.clear(); - if (yyparse()) - return 0; - delete parsed_date_label; - parsed_date_label = parse_result; - return 1; -} - -int set_short_label_spec(const char *label_spec) -{ - spec_cur = spec_ptr = label_spec; - spec_end = strchr(label_spec, '\0'); - literals.clear(); - if (yyparse()) - return 0; - delete parsed_short_label; - parsed_short_label = parse_result; - return 1; -} - -void yyerror(const char *message) -{ - if (spec_cur < spec_end) - command_error("label specification %1 before `%2'", message, spec_cur); - else - command_error("label specification %1 at end of string", - message, spec_cur); -} - -void at_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &) -{ - if (tentative) - ref.canonicalize_authors(result); - else { - const char *end, *start = ref.get_authors(&end); - if (start) - result.append(start, end - start); - } -} - -void format_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &) -{ - if (tentative) - return; - const label_info *lp = ref.get_label_ptr(); - int num = lp == 0 ? ref.get_number() : lp->count; - if (type != '0') - result += format_serial(type, num + 1); - else { - const char *ptr = itoa(num + first_number); - int pad = width - strlen(ptr); - while (--pad >= 0) - result += '0'; - result += ptr; - } -} - -static const char *format_serial(char c, int n) -{ - assert(n > 0); - static char buf[128]; // more than enough. - switch (c) { - case 'i': - case 'I': - { - char *p = buf; - // troff uses z and w to represent 10000 and 5000 in Roman - // numerals; I can find no historical basis for this usage - const char *s = c == 'i' ? "zwmdclxvi" : "ZWMDCLXVI"; - if (n >= 40000) - return itoa(n); - while (n >= 10000) { - *p++ = s[0]; - n -= 10000; - } - for (int i = 1000; i > 0; i /= 10, s += 2) { - int m = n/i; - n -= m*i; - switch (m) { - case 3: - *p++ = s[2]; - /* falls through */ - case 2: - *p++ = s[2]; - /* falls through */ - case 1: - *p++ = s[2]; - break; - case 4: - *p++ = s[2]; - *p++ = s[1]; - break; - case 8: - *p++ = s[1]; - *p++ = s[2]; - *p++ = s[2]; - *p++ = s[2]; - break; - case 7: - *p++ = s[1]; - *p++ = s[2]; - *p++ = s[2]; - break; - case 6: - *p++ = s[1]; - *p++ = s[2]; - break; - case 5: - *p++ = s[1]; - break; - case 9: - *p++ = s[2]; - *p++ = s[0]; - } - } - *p = 0; - break; - } - case 'a': - case 'A': - { - char *p = buf; - // this is derived from troff/reg.c - while (n > 0) { - int d = n % 26; - if (d == 0) - d = 26; - n -= d; - n /= 26; - *p++ = c + d - 1; // ASCII dependent - } - *p-- = 0; - // Reverse it. - char *q = buf; - while (q < p) { - char temp = *q; - *q = *p; - *p = temp; - --p; - ++q; - } - break; - } - default: - assert(0); - } - return buf; -} - -void field_expr::evaluate(int, const reference &ref, - string &result, substring_position &) -{ - const char *end; - const char *start = ref.get_field(name, &end); - if (start) { - start = nth_field(number, start, &end); - if (start) - result.append(start, end - start); - } -} - -void literal_expr::evaluate(int, const reference &, - string &result, substring_position &) -{ - result += s; -} - -analyzed_expr::analyzed_expr(expression *e) -: unary_expr(e), flags(e ? e->analyze() : 0) -{ -} - -void analyzed_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - if (expr) - expr->evaluate(tentative, ref, result, pos); -} - -void star_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - const label_info *lp = ref.get_label_ptr(); - if (!tentative - && (lp == 0 || lp->total > 1) - && expr) - expr->evaluate(tentative, ref, result, pos); -} - -void separator_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - int start_length = result.length(); - int is_first = pos.start < 0; - if (expr) - expr->evaluate(tentative, ref, result, pos); - if (is_first) { - pos.start = start_length; - pos.length = result.length() - start_length; - } -} - -void map_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &) -{ - if (expr) { - string temp; - substring_position temp_pos; - expr->evaluate(tentative, ref, temp, temp_pos); - (*func)(temp.contents(), temp.contents() + temp.length(), result); - } -} - -void extractor_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &) -{ - if (expr) { - string temp; - substring_position temp_pos; - expr->evaluate(tentative, ref, temp, temp_pos); - const char *end, *start = (*func)(temp.contents(), - temp.contents() + temp.length(), - &end); - switch (part) { - case BEFORE: - if (start) - result.append(temp.contents(), start - temp.contents()); - else - result += temp; - break; - case MATCH: - if (start) - result.append(start, end - start); - break; - case AFTER: - if (start) - result.append(end, temp.contents() + temp.length() - end); - break; - default: - assert(0); - } - } -} - -static void first_part(int len, const char *ptr, const char *end, - string &result) -{ - for (;;) { - const char *token_start = ptr; - if (!get_token(&ptr, end)) - break; - const token_info *ti = lookup_token(token_start, ptr); - int counts = ti->sortify_non_empty(token_start, ptr); - if (counts && --len < 0) - break; - if (counts || ti->is_accent()) - result.append(token_start, ptr - token_start); - } -} - -static void last_part(int len, const char *ptr, const char *end, - string &result) -{ - const char *start = ptr; - int count = 0; - for (;;) { - const char *token_start = ptr; - if (!get_token(&ptr, end)) - break; - const token_info *ti = lookup_token(token_start, ptr); - if (ti->sortify_non_empty(token_start, ptr)) - count++; - } - ptr = start; - int skip = count - len; - if (skip > 0) { - for (;;) { - const char *token_start = ptr; - if (!get_token(&ptr, end)) - assert(0); - const token_info *ti = lookup_token(token_start, ptr); - if (ti->sortify_non_empty(token_start, ptr) && --skip < 0) { - ptr = token_start; - break; - } - } - } - first_part(len, ptr, end, result); -} - -void truncate_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &) -{ - if (expr) { - string temp; - substring_position temp_pos; - expr->evaluate(tentative, ref, temp, temp_pos); - const char *start = temp.contents(); - const char *end = start + temp.length(); - if (n > 0) - first_part(n, start, end, result); - else if (n < 0) - last_part(-n, start, end, result); - } -} - -void alternative_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - int start_length = result.length(); - if (expr1) - expr1->evaluate(tentative, ref, result, pos); - if (result.length() == start_length && expr2) - expr2->evaluate(tentative, ref, result, pos); -} - -void list_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - if (expr1) - expr1->evaluate(tentative, ref, result, pos); - if (expr2) - expr2->evaluate(tentative, ref, result, pos); -} - -void substitute_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - int start_length = result.length(); - if (expr1) - expr1->evaluate(tentative, ref, result, pos); - if (result.length() > start_length && result[result.length() - 1] == '-') { - // ought to see if pos covers the - - result.set_length(result.length() - 1); - if (expr2) - expr2->evaluate(tentative, ref, result, pos); - } -} - -void conditional_expr::evaluate(int tentative, const reference &ref, - string &result, substring_position &pos) -{ - string temp; - substring_position temp_pos; - if (expr1) - expr1->evaluate(tentative, ref, temp, temp_pos); - if (temp.length() > 0) { - if (expr2) - expr2->evaluate(tentative, ref, result, pos); - } - else { - if (expr3) - expr3->evaluate(tentative, ref, result, pos); - } -} - -void reference::pre_compute_label() -{ - if (parsed_label != 0 - && (parsed_label->analyze() & expression::CONTAINS_VARIABLE)) { - label.clear(); - substring_position temp_pos; - parsed_label->evaluate(1, *this, label, temp_pos); - label_ptr = lookup_label(label); - } -} - -void reference::compute_label() -{ - label.clear(); - if (parsed_label) - parsed_label->evaluate(0, *this, label, separator_pos); - if (short_label_flag && parsed_short_label) - parsed_short_label->evaluate(0, *this, short_label, short_separator_pos); - if (date_as_label) { - string new_date; - if (parsed_date_label) { - substring_position temp_pos; - parsed_date_label->evaluate(0, *this, new_date, temp_pos); - } - set_date(new_date); - } - if (label_ptr) - label_ptr->count += 1; -} - -void reference::immediate_compute_label() -{ - if (label_ptr) - label_ptr->total = 2; // force use of disambiguator - compute_label(); -} - -int reference::merge_labels(reference **v, int n, label_type type, - string &result) -{ - if (abbreviate_label_ranges) - return merge_labels_by_number(v, n, type, result); - else - return merge_labels_by_parts(v, n, type, result); -} - -int reference::merge_labels_by_number(reference **v, int n, label_type type, - string &result) -{ - if (n <= 1) - return 0; - int num = get_number(); - // Only merge three or more labels. - if (v[0]->get_number() != num + 1 - || v[1]->get_number() != num + 2) - return 0; - for (int i = 2; i < n; i++) - if (v[i]->get_number() != num + i + 1) - break; - result = get_label(type); - result += label_range_indicator; - result += v[i - 1]->get_label(type); - return i; -} - -const substring_position &reference::get_separator_pos(label_type type) const -{ - if (type == SHORT_LABEL && short_label_flag) - return short_separator_pos; - else - return separator_pos; -} - -const string &reference::get_label(label_type type) const -{ - if (type == SHORT_LABEL && short_label_flag) - return short_label; - else - return label; -} - -int reference::merge_labels_by_parts(reference **v, int n, label_type type, - string &result) -{ - if (n <= 0) - return 0; - const string &lb = get_label(type); - const substring_position &sp = get_separator_pos(type); - if (sp.start < 0 - || sp.start != v[0]->get_separator_pos(type).start - || memcmp(lb.contents(), v[0]->get_label(type).contents(), - sp.start) != 0) - return 0; - result = lb; - int i = 0; - do { - result += separate_label_second_parts; - const substring_position &s = v[i]->get_separator_pos(type); - int sep_end_pos = s.start + s.length; - result.append(v[i]->get_label(type).contents() + sep_end_pos, - v[i]->get_label(type).length() - sep_end_pos); - } while (++i < n - && sp.start == v[i]->get_separator_pos(type).start - && memcmp(lb.contents(), v[i]->get_label(type).contents(), - sp.start) == 0); - return i; -} - -string label_pool; - -label_info::label_info(const string &s) -: count(0), total(1), length(s.length()), start(label_pool.length()) -{ - label_pool += s; -} - -static label_info **label_table = 0; -static int label_table_size = 0; -static int label_table_used = 0; - -label_info *lookup_label(const string &label) -{ - if (label_table == 0) { - label_table = new label_info *[17]; - label_table_size = 17; - for (int i = 0; i < 17; i++) - label_table[i] = 0; - } - unsigned h = hash_string(label.contents(), label.length()) % label_table_size; - for (label_info **ptr = label_table + h; - *ptr != 0; - (ptr == label_table) - ? (ptr = label_table + label_table_size - 1) - : ptr--) - if ((*ptr)->length == label.length() - && memcmp(label_pool.contents() + (*ptr)->start, label.contents(), - label.length()) == 0) { - (*ptr)->total += 1; - return *ptr; - } - label_info *result = *ptr = new label_info(label); - if (++label_table_used * 2 > label_table_size) { - // Rehash the table. - label_info **old_table = label_table; - int old_size = label_table_size; - label_table_size = next_size(label_table_size); - label_table = new label_info *[label_table_size]; - int i; - for (i = 0; i < label_table_size; i++) - label_table[i] = 0; - for (i = 0; i < old_size; i++) - if (old_table[i]) { - unsigned h = hash_string(label_pool.contents() + old_table[i]->start, - old_table[i]->length); - for (label_info **p = label_table + (h % label_table_size); - *p != 0; - (p == label_table) - ? (p = label_table + label_table_size - 1) - : --p) - ; - *p = old_table[i]; - } - a_delete old_table; - } - return result; -} - -void clear_labels() -{ - for (int i = 0; i < label_table_size; i++) { - delete label_table[i]; - label_table[i] = 0; - } - label_table_used = 0; - label_pool.clear(); -} - -static void consider_authors(reference **start, reference **end, int i); - -void compute_labels(reference **v, int n) -{ - if (parsed_label - && (parsed_label->analyze() & expression::CONTAINS_AT) - && sort_fields.length() >= 2 - && sort_fields[0] == 'A' - && sort_fields[1] == '+') - consider_authors(v, v + n, 0); - for (int i = 0; i < n; i++) - v[i]->compute_label(); -} - - -/* A reference with a list of authors _needs_ author i -where 0 <= i <= N if there exists a reference with a list of authors - such that != and M >= i -and Aj = Bj for 0 <= j < i. In this case if we can't say ``A0, -A1,...,A(i-1) et al'' because this would match both and -. If a reference needs author i we only have to call -need_author(j) for some j >= i such that the reference also needs -author j. */ - -/* This function handles 2 tasks: -determine which authors are needed (cannot be elided with et al.); -determine which authors can have only last names in the labels. - -References >= start and < end have the same first i author names. -Also they're sorted by A+. */ - -static void consider_authors(reference **start, reference **end, int i) -{ - if (start >= end) - return; - reference **p = start; - if (i >= (*p)->get_nauthors()) { - for (++p; p < end && i >= (*p)->get_nauthors(); p++) - ; - if (p < end && i > 0) { - // If we have an author list and an author list , - // then both lists need C. - for (reference **q = start; q < end; q++) - (*q)->need_author(i - 1); - } - start = p; - } - while (p < end) { - reference **last_name_start = p; - reference **name_start = p; - for (++p; - p < end && i < (*p)->get_nauthors() - && same_author_last_name(**last_name_start, **p, i); - p++) { - if (!same_author_name(**name_start, **p, i)) { - consider_authors(name_start, p, i + 1); - name_start = p; - } - } - consider_authors(name_start, p, i + 1); - if (last_name_start == name_start) { - for (reference **q = last_name_start; q < p; q++) - (*q)->set_last_name_unambiguous(i); - } - // If we have an author list and , then the lists - // need author D and E respectively. - if (name_start > start || p < end) { - for (reference **q = last_name_start; q < p; q++) - (*q)->need_author(i); - } - } -} - -int same_author_last_name(const reference &r1, const reference &r2, int n) -{ - const char *ae1; - const char *as1 = r1.get_sort_field(0, n, 0, &ae1); - assert(as1 != 0); - const char *ae2; - const char *as2 = r2.get_sort_field(0, n, 0, &ae2); - assert(as2 != 0); - return ae1 - as1 == ae2 - as2 && memcmp(as1, as2, ae1 - as1) == 0; -} - -int same_author_name(const reference &r1, const reference &r2, int n) -{ - const char *ae1; - const char *as1 = r1.get_sort_field(0, n, -1, &ae1); - assert(as1 != 0); - const char *ae2; - const char *as2 = r2.get_sort_field(0, n, -1, &ae2); - assert(as2 != 0); - return ae1 - as1 == ae2 - as2 && memcmp(as1, as2, ae1 - as1) == 0; -} - - -void int_set::set(int i) -{ - assert(i >= 0); - int bytei = i >> 3; - if (bytei >= v.length()) { - int old_length = v.length(); - v.set_length(bytei + 1); - for (int j = old_length; j <= bytei; j++) - v[j] = 0; - } - v[bytei] |= 1 << (i & 7); -} - -int int_set::get(int i) const -{ - assert(i >= 0); - int bytei = i >> 3; - return bytei >= v.length() ? 0 : (v[bytei] & (1 << (i & 7))) != 0; -} - -void reference::set_last_name_unambiguous(int i) -{ - last_name_unambiguous.set(i); -} - -void reference::need_author(int n) -{ - if (n > last_needed_author) - last_needed_author = n; -} - -const char *reference::get_authors(const char **end) const -{ - if (!computed_authors) { - ((reference *)this)->computed_authors = 1; - string &result = ((reference *)this)->authors; - int na = get_nauthors(); - result.clear(); - for (int i = 0; i < na; i++) { - if (last_name_unambiguous.get(i)) { - const char *e, *start = get_author_last_name(i, &e); - assert(start != 0); - result.append(start, e - start); - } - else { - const char *e, *start = get_author(i, &e); - assert(start != 0); - result.append(start, e - start); - } - if (i == last_needed_author - && et_al.length() > 0 - && et_al_min_elide > 0 - && last_needed_author + et_al_min_elide < na - && na >= et_al_min_total) { - result += et_al; - break; - } - if (i < na - 1) { - if (na == 2) - result += join_authors_exactly_two; - else if (i < na - 2) - result += join_authors_default; - else - result += join_authors_last_two; - } - } - } - const char *start = authors.contents(); - *end = start + authors.length(); - return start; -} - -int reference::get_nauthors() const -{ - if (nauthors < 0) { - const char *dummy; - for (int na = 0; get_author(na, &dummy) != 0; na++) - ; - ((reference *)this)->nauthors = na; - } - return nauthors; -} -#line 1220 "y.tab.c" -#define YYABORT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", yystate, - yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, shifting to state %d\n", - yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, error recovery shifting\ - to state %d\n", *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("yydebug: error recovery discarding state %d\n", - *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, error recovery discards token %d (%s)\n", - yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, reducing by rule %d (%s)\n", - yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 1: -#line 250 "/u/jjc/groff/refer/label.y" -{ parse_result = (yyvsp[0].expr ? new analyzed_expr(yyvsp[0].expr) : 0); } -break; -case 2: -#line 255 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[0].expr; } -break; -case 3: -#line 257 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new conditional_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr); } -break; -case 4: -#line 262 "/u/jjc/groff/refer/label.y" -{ yyval.expr = 0; } -break; -case 5: -#line 264 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[0].expr; } -break; -case 6: -#line 269 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[0].expr; } -break; -case 7: -#line 271 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new alternative_expr(yyvsp[-2].expr, yyvsp[0].expr); } -break; -case 8: -#line 273 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new conditional_expr(yyvsp[-2].expr, yyvsp[0].expr, 0); } -break; -case 9: -#line 278 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[0].expr; } -break; -case 10: -#line 280 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new list_expr(yyvsp[-1].expr, yyvsp[0].expr); } -break; -case 11: -#line 285 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[0].expr; } -break; -case 12: -#line 287 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new substitute_expr(yyvsp[-2].expr, yyvsp[0].expr); } -break; -case 13: -#line 292 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new at_expr; } -break; -case 14: -#line 294 "/u/jjc/groff/refer/label.y" -{ - yyval.expr = new literal_expr(literals.contents() + yyvsp[0].str.start, - yyvsp[0].str.len); - } -break; -case 15: -#line 299 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new field_expr(yyvsp[0].num, 0); } -break; -case 16: -#line 301 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new field_expr(yyvsp[-1].num, yyvsp[0].num - 1); } -break; -case 17: -#line 303 "/u/jjc/groff/refer/label.y" -{ - switch (yyvsp[0].num) { - case 'I': - case 'i': - case 'A': - case 'a': - yyval.expr = new format_expr(yyvsp[0].num); - break; - default: - command_error("unrecognized format `%1'", char(yyvsp[0].num)); - yyval.expr = new format_expr('a'); - break; - } - } -break; -case 18: -#line 319 "/u/jjc/groff/refer/label.y" -{ - yyval.expr = new format_expr('0', yyvsp[0].dig.ndigits, yyvsp[0].dig.val); - } -break; -case 19: -#line 323 "/u/jjc/groff/refer/label.y" -{ - switch (yyvsp[-1].num) { - case 'l': - yyval.expr = new map_expr(yyvsp[-4].expr, lowercase); - break; - case 'u': - yyval.expr = new map_expr(yyvsp[-4].expr, uppercase); - break; - case 'c': - yyval.expr = new map_expr(yyvsp[-4].expr, capitalize); - break; - case 'r': - yyval.expr = new map_expr(yyvsp[-4].expr, reverse_name); - break; - case 'a': - yyval.expr = new map_expr(yyvsp[-4].expr, abbreviate_name); - break; - case 'y': - yyval.expr = new extractor_expr(yyvsp[-4].expr, find_year, yyvsp[-2].num); - break; - case 'n': - yyval.expr = new extractor_expr(yyvsp[-4].expr, find_last_name, yyvsp[-2].num); - break; - default: - yyval.expr = yyvsp[-4].expr; - command_error("unknown function `%1'", char(yyvsp[-1].num)); - break; - } - } -break; -case 20: -#line 354 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new truncate_expr(yyvsp[-2].expr, yyvsp[0].num); } -break; -case 21: -#line 356 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new truncate_expr(yyvsp[-2].expr, -yyvsp[0].num); } -break; -case 22: -#line 358 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new star_expr(yyvsp[-1].expr); } -break; -case 23: -#line 360 "/u/jjc/groff/refer/label.y" -{ yyval.expr = yyvsp[-1].expr; } -break; -case 24: -#line 362 "/u/jjc/groff/refer/label.y" -{ yyval.expr = new separator_expr(yyvsp[-1].expr); } -break; -case 25: -#line 367 "/u/jjc/groff/refer/label.y" -{ yyval.num = -1; } -break; -case 26: -#line 369 "/u/jjc/groff/refer/label.y" -{ yyval.num = yyvsp[0].num; } -break; -case 27: -#line 374 "/u/jjc/groff/refer/label.y" -{ yyval.num = yyvsp[0].num; } -break; -case 28: -#line 376 "/u/jjc/groff/refer/label.y" -{ yyval.num = yyvsp[-1].num*10 + yyvsp[0].num; } -break; -case 29: -#line 381 "/u/jjc/groff/refer/label.y" -{ yyval.dig.ndigits = 1; yyval.dig.val = yyvsp[0].num; } -break; -case 30: -#line 383 "/u/jjc/groff/refer/label.y" -{ yyval.dig.ndigits = yyvsp[-1].dig.ndigits + 1; yyval.dig.val = yyvsp[-1].dig.val*10 + yyvsp[0].num; } -break; -case 31: -#line 389 "/u/jjc/groff/refer/label.y" -{ yyval.num = 0; } -break; -case 32: -#line 391 "/u/jjc/groff/refer/label.y" -{ yyval.num = 1; } -break; -case 33: -#line 393 "/u/jjc/groff/refer/label.y" -{ yyval.num = -1; } -break; -#line 1538 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state 0 to\ - state %d\n", YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", - YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state %d \ -to state %d\n", *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/gnu/usr.bin/gzip/zcmp b/gnu/usr.bin/gzip/zcmp deleted file mode 100644 index c21e7ef8ae06..000000000000 --- a/gnu/usr.bin/gzip/zcmp +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# Zcmp and zdiff are used to invoke the cmp or the diff pro- -# gram on compressed files. All options specified are passed -# directly to cmp or diff. If only 1 file is specified, then -# the files compared are file1 and an uncompressed file1.gz. -# If two files are specified, then they are uncompressed (if -# necessary) and fed to cmp or diff. The exit status from cmp -# or diff is preserved. - -prog=`echo $0 | sed 's|.*/||'` -case "$prog" in - *cmp) comp=${CMP-cmp} ;; - *) comp=${DIFF-diff} ;; -esac - -OPTIONS= -FILES= -for ARG -do - case "$ARG" in - -*) OPTIONS="$OPTIONS $ARG";; - *) if test -f "$ARG"; then - FILES="$FILES $ARG" - else - echo "${prog}: $ARG not found or not a regular file" - exit 1 - fi ;; - esac -done -if test -z "$FILES"; then - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi -set $FILES -if test $# -eq 1; then - FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'` - gzip -cd "$1" | $comp $OPTIONS - "$FILE" - STAT="$?" - -elif test $# -eq 2; then - case "$1" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'` - gzip -cd "$2" > /tmp/"$F".$$ - gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$ - STAT="$?" - /bin/rm -f /tmp/"$F".$$;; - - *) gzip -cd "$1" | $comp $OPTIONS - "$2" - STAT="$?";; - esac;; - *) case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - gzip -cd "$2" | $comp $OPTIONS "$1" - - STAT="$?";; - *) $comp $OPTIONS "$1" "$2" - STAT="$?";; - esac;; - esac - exit "$STAT" -else - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi diff --git a/gnu/usr.bin/pr/COPYING b/gnu/usr.bin/pr/COPYING deleted file mode 100644 index a43ea2126fb6..000000000000 --- a/gnu/usr.bin/pr/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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 of the License, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/gnu/usr.bin/pr/getopt.h b/gnu/usr.bin/pr/getopt.h deleted file mode 100644 index 45541f5ac0f9..000000000000 --- a/gnu/usr.bin/pr/getopt.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* 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'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if __STDC__ -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (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 (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/pr/version.h b/gnu/usr.bin/pr/version.h deleted file mode 100644 index 63de4fd14719..000000000000 --- a/gnu/usr.bin/pr/version.h +++ /dev/null @@ -1 +0,0 @@ -extern const char *version_string; diff --git a/gnu/usr.bin/ptx/ptx.info b/gnu/usr.bin/ptx/ptx.info deleted file mode 100644 index 3bbd1bb8cf07..000000000000 --- a/gnu/usr.bin/ptx/ptx.info +++ /dev/null @@ -1,496 +0,0 @@ -This is Info file ptx.info, produced by Makeinfo-1.47 from the input -file ./ptx.texinfo. - - This file documents the `ptx' command, which has the purpose of -generated permuted indices for group of files. - - Copyright (C) 1990, 1991, 1993 by the Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: ptx.info, Node: Top, Next: Invoking ptx, Prev: (dir), Up: (dir) - -Introduction -************ - - This is the 0.3 beta release of `ptx', the GNU version of a permuted -index generator. This software has the main goal of providing a -replacement for the traditional `ptx' as found on System V machines, -able to handle small files quickly, while providing a platform for more -development. - - This version reimplements and extends traditional `ptx'. Among -other things, it can produce a readable "KWIC" (keywords in their -context) without the need of `nroff', there is also an option to -produce TeX compatible output. This version does not handle huge input -files, that is, those files which do not fit in memory all at once. - - *Please note* that an overall renaming of all options is -foreseeable. In fact, GNU ptx specifications are not frozen yet. - -* Menu: - -* Invoking ptx:: How to use this program -* Compatibility:: The GNU extensions to `ptx' - - -- The Detailed Node Listing -- - -How to use this program - -* General options:: Options which affect general program behaviour. -* Charset selection:: Underlying character set considerations. -* Input processing:: Input fields, contexts, and keyword selection. -* Output formatting:: Types of output format, and sizing the fields. - - -File: ptx.info, Node: Invoking ptx, Next: Compatibility, Prev: Top, Up: Top - -How to use this program -*********************** - - This tool reads a text file and essentially produces a permuted -index, with each keyword in its context. The calling sketch is one of: - - ptx [OPTION ...] [FILE ...] - - or: - - ptx -G [OPTION ...] [INPUT [OUTPUT]] - - The `-G' (or its equivalent: `--traditional') option disables all -GNU extensions and revert to traditional mode, thus introducing some -limitations, and changes several of the program's default option values. -When `-G' is not specified, GNU extensions are always enabled. GNU -extensions to `ptx' are documented wherever appropriate in this -document. See *Note Compatibility:: for an explicit list of them. - - Individual options are explained later in this document. - - When GNU extensions are enabled, there may be zero, one or several -FILE after the options. If there is no FILE, the program reads the -standard input. If there is one or several FILE, they give the name of -input files which are all read in turn, as if all the input files were -concatenated. However, there is a full contextual break between each -file and, when automatic referencing is requested, file names and line -numbers refer to individual text input files. In all cases, the -program produces the permuted index onto the standard output. - - When GNU extensions are *not* enabled, that is, when the program -operates in traditional mode, there may be zero, one or two parameters -besides the options. If there is no parameters, the program reads the -standard input and produces the permuted index onto the standard output. -If there is only one parameter, it names the text INPUT to be read -instead of the standard input. If two parameters are given, they give -respectively the name of the INPUT file to read and the name of the -OUTPUT file to produce. *Be very careful* to note that, in this case, -the contents of file given by the second parameter is destroyed. This -behaviour is dictated only by System V `ptx' compatibility, because GNU -Standards discourage output parameters not introduced by an option. - - Note that for *any* file named as the value of an option or as an -input text file, a single dash `-' may be used, in which case standard -input is assumed. However, it would not make sense to use this -convention more than once per program invocation. - -* Menu: - -* General options:: Options which affect general program behaviour. -* Charset selection:: Underlying character set considerations. -* Input processing:: Input fields, contexts, and keyword selection. -* Output formatting:: Types of output format, and sizing the fields. - - -File: ptx.info, Node: General options, Next: Charset selection, Prev: Invoking ptx, Up: Invoking ptx - -General options -=============== - -`-C' -`--copyright' - Prints a short note about the Copyright and copying conditions, - then exit without further processing. - -`-G' -`--traditional' - As already explained, this option disables all GNU extensions to - `ptx' and switch to traditional mode. - -`--help' - Prints a short help on standard output, then exit without further - processing. - -`--version' - Prints the program verison on standard output, then exit without - further processing. - - -File: ptx.info, Node: Charset selection, Next: Input processing, Prev: General options, Up: Invoking ptx - -Charset selection -================= - - As it is setup now, the program assumes that the input file is coded -using 8-bit ISO 8859-1 code, also known as Latin-1 character set, -*unless* if it is compiled for MS-DOS, in which case it uses the -character set of the IBM-PC. (GNU `ptx' is not known to work on -smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of -characters which are letters is then different, this fact alters the -behaviour of regular expression matching. Thus, the default regular -expression for a keyword allows foreign or diacriticized letters. -Keyword sorting, however, is still crude; it obeys the underlying -character set ordering quite blindly. - -`-f' -`--ignore-case' - Fold lower case letters to upper case for sorting. - - -File: ptx.info, Node: Input processing, Next: Output formatting, Prev: Charset selection, Up: Invoking ptx - -Word selection -============== - -`-b FILE' -`--break-file=FILE' - This option is an alternative way to option `-W' for describing - which characters make up words. This option introduces the name - of a file which contains a list of characters which can*not* be - part of one word, this file is called the "Break file". Any - character which is not part of the Break file is a word - constituent. If both options `-b' and `-W' are specified, then - `-W' has precedence and `-b' is ignored. - - When GNU extensions are enabled, the only way to avoid newline as a - break character is to write all the break characters in the file - with no newline at all, not even at the end of the file. When GNU - extensions are disabled, spaces, tabs and newlines are always - considered as break characters even if not included in the Break - file. - -`-i FILE' -`--ignore-file=FILE' - The file associated with this option contains a list of words - which will never be taken as keywords in concordance output. It - is called the "Ignore file". The file contains exactly one word - in each line; the end of line separation of words is not subject - to the value of the `-S' option. - - There is a default Ignore file used by `ptx' when this option is - not specified, usually found in `/usr/local/lib/eign' if this has - not been changed at installation time. If you want to deactivate - the default Ignore file, specify `/dev/null' instead. - -`-o FILE' -`--only-file=FILE' - The file associated with this option contains a list of words - which will be retained in concordance output, any word not - mentioned in this file is ignored. The file is called the "Only - file". The file contains exactly one word in each line; the end - of line separation of words is not subject to the value of the - `-S' option. - - There is no default for the Only file. In the case there are both - an Only file and an Ignore file, a word will be subject to be a - keyword only if it is given in the Only file and not given in the - Ignore file. - -`-r' -`--references' - On each input line, the leading sequence of non white characters - will be taken to be a reference that has the purpose of - identifying this input line on the produced permuted index. See - *Note Output formatting:: for more information about reference - production. Using this option change the default value for option - `-S'. - - Using this option, the program does not try very hard to remove - references from contexts in output, but it succeeds in doing so - *when* the context ends exactly at the newline. If option `-r' is - used with `-S' default value, or when GNU extensions are disabled, - this condition is always met and references are completely - excluded from the output contexts. - -`-S REGEXP' -`--sentence-regexp=REGEXP' - This option selects which regular expression will describe the end - of a line or the end of a sentence. In fact, there is other - distinction between end of lines or end of sentences than the - effect of this regular expression, and input line boundaries have - no special significance outside this option. By default, when GNU - extensions are enabled and if `-r' option is not used, end of - sentences are used. In this case, the precise REGEX is imported - from GNU emacs: - - [.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]* - - Whenever GNU extensions are disabled or if `-r' option is used, end - of lines are used; in this case, the default REGEXP is just: - - \n - - Using an empty REGEXP is equivalent to completely disabling end of - line or end of sentence recognition. In this case, the whole file - is considered to be a single big line or sentence. The user might - want to disallow all truncation flag generation as well, through - option `-F ""'. *Note Syntax of Regular Expressions: - (emacs)Regexps. - - When the keywords happen to be near the beginning of the input - line or sentence, this often creates an unused area at the - beginning of the output context line; when the keywords happen to - be near the end of the input line or sentence, this often creates - an unused area at the end of the output context line. The program - tries to fill those unused areas by wrapping around context in - them; the tail of the input line or sentence is used to fill the - unused area on the left of the output line; the head of the input - line or sentence is used to fill the unused area on the right of - the output line. - - As a matter of convenience to the user, many usual backslashed - escape sequences, as found in the C language, are recognized and - converted to the corresponding characters by `ptx' itself. - -`-W REGEXP' -`--word-regexp=REGEXP' - This option selects which regular expression will describe each - keyword. By default, if GNU extensions are enabled, a word is a - sequence of letters; the REGEXP used is `\w+'. When GNU - extensions are disabled, a word is by default anything which ends - with a space, a tab or a newline; the REGEXP used is `[^ \t\n]+'. - - An empty REGEXP is equivalent to not using this option, letting the - default dive in. *Note Syntax of Regular Expressions: - (emacs)Regexps. - - As a matter of convenience to the user, many usual backslashed - escape sequences, as found in the C language, are recognized and - converted to the corresponding characters by `ptx' itself. - - -File: ptx.info, Node: Output formatting, Prev: Input processing, Up: Invoking ptx - -Output formatting -================= - - Output format is mainly controlled by `-O' and `-T' options, -described in the table below. When neither `-O' nor `-T' is selected, -and if GNU extensions are enabled, the program choose an output format -suited for a dumb terminal. Each keyword occurrence is output to the -center of one line, surrounded by its left and right contexts. Each -field is properly justified, so the concordance output could readily be -observed. As a special feature, if automatic references are selected -by option `-A' and are output before the left context, that is, if -option `-R' is *not* selected, then a colon is added after the -reference; this nicely interfaces with GNU Emacs `next-error' -processing. In this default output format, each white space character, -like newline and tab, is merely changed to exactly one space, with no -special attempt to compress consecutive spaces. This might change in -the future. Except for those white space characters, every other -character of the underlying set of 256 characters is transmitted -verbatim. - - Output format is further controlled by the following options. - -`-g NUMBER' -`--gap-size=NUMBER' - Select the size of the minimum white gap between the fields on the - output line. - -`-w NUMBER' -`--width=NUMBER' - Select the output maximum width of each final line. If references - are used, they are included or excluded from the output maximum - width depending on the value of option `-R'. If this option is not - selected, that is, when references are output before the left - context, the output maximum width takes into account the maximum - length of all references. If this options is selected, that is, - when references are output after the right context, the output - maximum width does not take into account the space taken by - references, nor the gap that precedes them. - -`-A' -`--auto-reference' - Select automatic references. Each input line will have an - automatic reference made up of the file name and the line ordinal, - with a single colon between them. However, the file name will be - empty when standard input is being read. If both `-A' and `-r' - are selected, then the input reference is still read and skipped, - but the automatic reference is used at output time, overriding the - input reference. - -`-R' -`--right-side-refs' - In default output format, when option `-R' is not used, any - reference produced by the effect of options `-r' or `-A' are given - to the far right of output lines, after the right context. In - default output format, when option `-R' is specified, references - are rather given to the beginning of each output line, before the - left context. For any other output format, option `-R' is almost - ignored, except for the fact that the width of references is *not* - taken into account in total output width given by `-w' whenever - `-R' is selected. - - This option is automatically selected whenever GNU extensions are - disabled. - -`-F STRING' -`--flac-truncation=STRING' - This option will request that any truncation in the output be - reported using the string STRING. Most output fields - theoretically extend towards the beginning or the end of the - current line, or current sentence, as selected with option `-S'. - But there is a maximum allowed output line width, changeable - through option `-w', which is further divided into space for - various output fields. When a field has to be truncated because - cannot extend until the beginning or the end of the current line - to fit in the, then a truncation occurs. By default, the string - used is a single slash, as in `-F /'. - - STRING may have more than one character, as in `-F ...'. Also, in - the particular case STRING is empty (`-F ""'), truncation flagging - is disabled, and no truncation marks are appended in this case. - - As a matter of convenience to the user, many usual backslashed - escape sequences, as found in the C language, are recognized and - converted to the corresponding characters by `ptx' itself. - -`-M STRING' -`--macro-name=STRING' - Select another STRING to be used instead of `xx', while generating - output suitable for `nroff', `troff' or TeX. - -`-O' -`--format=roff' - Choose an output format suitable for `nroff' or `troff' - processing. Each output line will look like: - - .xx "TAIL" "BEFORE" "KEYWORD_AND_AFTER" "HEAD" "REF" - - so it will be possible to write an `.xx' roff macro to take care of - the output typesetting. This is the default output format when GNU - extensions are disabled. Option `-M' might be used to change `xx' - to another macro name. - - In this output format, each non-graphical character, like newline - and tab, is merely changed to exactly one space, with no special - attempt to compress consecutive spaces. Each quote character: `"' - is doubled so it will be correctly processed by `nroff' or `troff'. - -`-T' -`--format=tex' - Choose an output format suitable for TeX processing. Each output - line will look like: - - \xx {TAIL}{BEFORE}{KEYWORD}{AFTER}{HEAD}{REF} - - so it will be possible to write write a `\xx' definition to take - care of the output typesetting. Note that when references are not - being produced, that is, neither option `-A' nor option `-r' is - selected, the last parameter of each `\xx' call is inhibited. - Option `-M' might be used to change `xx' to another macro name. - - In this output format, some special characters, like `$', `%', - `&', `#' and `_' are automatically protected with a backslash. - Curly brackets `{', `}' are also protected with a backslash, but - also enclosed in a pair of dollar signs to force mathematical - mode. The backslash itself produces the sequence `\backslash{}'. - Circumflex and tilde diacritics produce the sequence `^\{ }' and - `~\{ }' respectively. Other diacriticized characters of the - underlying character set produce an appropriate TeX sequence as - far as possible. The other non-graphical characters, like newline - and tab, and all others characters which are not part of ASCII, - are merely changed to exactly one space, with no special attempt - to compress consecutive spaces. Let me know how to improve this - special character processing for TeX. - - -File: ptx.info, Node: Compatibility, Prev: Invoking ptx, Up: Top - -The GNU extensions to `ptx' -*************************** - - This version of `ptx' contains a few features which do not exist in -System V `ptx'. These extra features are suppressed by using the `-G' -command line option, unless overridden by other command line options. -Some GNU extensions cannot be recovered by overriding, so the simple -rule is to avoid `-G' if you care about GNU extensions. Here are the -differences between this program and System V `ptx'. - - * This program can read many input files at once, it always writes - the resulting concordance on standard output. On the other end, - System V `ptx' reads only one file and produce the result on - standard output or, if a second FILE parameter is given on the - command, to that FILE. - - Having output parameters not introduced by options is a quite - dangerous practice which GNU avoids as far as possible. So, for - using `ptx' portably between GNU and System V, you should pay - attention to always use it with a single input file, and always - expect the result on standard output. You might also want to - automatically configure in a `-G' option to `ptx' calls in - products using `ptx', if the configurator finds that the installed - `ptx' accepts `-G'. - - * The only options available in System V `ptx' are options `-b', - `-f', `-g', `-i', `-o', `-r', `-t' and `-w'. All other options - are GNU extensions and are not repeated in this enumeration. - Moreover, some options have a slightly different meaning when GNU - extensions are enabled, as explained below. - - * By default, concordance output is not formatted for `troff' or - `nroff'. It is rather formatted for a dumb terminal. `troff' or - `nroff' output may still be selected through option `-O'. - - * Unless `-R' option is used, the maximum reference width is - subtracted from the total output line width. With GNU extensions - disabled, width of references is not taken into account in the - output line width computations. - - * All 256 characters, even `NUL's, are always read and processed from - input file with no adverse effect, even if GNU extensions are - disabled. However, System V `ptx' does not accept 8-bit - characters, a few control characters are rejected, and the tilda - `~' is condemned. - - * Input line length is only limited by available memory, even if GNU - extensions are disabled. However, System V `ptx' processes only - the first 200 characters in each line. - - * The break (non-word) characters default to be every character - except all letters of the underlying character set, diacriticized - or not. When GNU extensions are disabled, the break characters - default to space, tab and newline only. - - * The program makes better use of output line width. If GNU - extensions are disabled, the program rather tries to imitate - System V `ptx', but still, there are some slight disposition - glitches this program does not completely reproduce. - - * The user can specify both an Ignore file and an Only file. This - is not allowed with System V `ptx'. - - - -Tag Table: -Node: Top939 -Node: Invoking ptx2298 -Node: General options5025 -Node: Charset selection5639 -Node: Input processing6514 -Node: Output formatting12205 -Node: Compatibility18737 - -End Tag Table diff --git a/gnu/usr.bin/ptx/ptx.texinfo b/gnu/usr.bin/ptx/ptx.texinfo deleted file mode 100644 index e690c55f80c1..000000000000 --- a/gnu/usr.bin/ptx/ptx.texinfo +++ /dev/null @@ -1,554 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename ptx.info -@settitle GNU @code{ptx} reference manual -@finalout -@c %**end of header - -@ifinfo -This file documents the @code{ptx} command, which has the purpose of -generated permuted indices for group of files. - -Copyright (C) 1990, 1991, 1993 by the Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end ifinfo - -@titlepage -@title ptx -@subtitle The GNU permuted indexer -@subtitle Edition 0.3, for ptx version 0.3 -@subtitle November 1993 -@author by Francois Pinard - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1990, 1991, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end titlepage - -@node Top, Invoking ptx, (dir), (dir) -@chapter Introduction - -This is the 0.3 beta release of @code{ptx}, the GNU version of a -permuted index generator. This software has the main goal of providing -a replacement for the traditional @code{ptx} as found on System V -machines, able to handle small files quickly, while providing a platform -for more development. - -This version reimplements and extends traditional @code{ptx}. Among -other things, it can produce a readable @dfn{KWIC} (keywords in their -context) without the need of @code{nroff}, there is also an option to -produce @TeX{} compatible output. This version does not handle huge -input files, that is, those files which do not fit in memory all at -once. - -@emph{Please note} that an overall renaming of all options is -foreseeable. In fact, GNU ptx specifications are not frozen yet. - -@menu -* Invoking ptx:: How to use this program -* Compatibility:: The GNU extensions to @code{ptx} - - --- The Detailed Node Listing --- - -How to use this program - -* General options:: Options which affect general program behaviour. -* Charset selection:: Underlying character set considerations. -* Input processing:: Input fields, contexts, and keyword selection. -* Output formatting:: Types of output format, and sizing the fields. -@end menu - -@node Invoking ptx, Compatibility, Top, Top -@chapter How to use this program - -This tool reads a text file and essentially produces a permuted index, with -each keyword in its context. The calling sketch is one of: - -@example -ptx [@var{option} @dots{}] [@var{file} @dots{}] -@end example - -or: - -@example -ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]] -@end example - -The @samp{-G} (or its equivalent: @samp{--traditional}) option disables -all GNU extensions and revert to traditional mode, thus introducing some -limitations, and changes several of the program's default option values. -When @samp{-G} is not specified, GNU extensions are always enabled. GNU -extensions to @code{ptx} are documented wherever appropriate in this -document. See @xref{Compatibility} for an explicit list of them. - -Individual options are explained later in this document. - -When GNU extensions are enabled, there may be zero, one or several -@var{file} after the options. If there is no @var{file}, the program -reads the standard input. If there is one or several @var{file}, they -give the name of input files which are all read in turn, as if all the -input files were concatenated. However, there is a full contextual -break between each file and, when automatic referencing is requested, -file names and line numbers refer to individual text input files. In -all cases, the program produces the permuted index onto the standard -output. - -When GNU extensions are @emph{not} enabled, that is, when the program -operates in traditional mode, there may be zero, one or two parameters -besides the options. If there is no parameters, the program reads the -standard input and produces the permuted index onto the standard output. -If there is only one parameter, it names the text @var{input} to be read -instead of the standard input. If two parameters are given, they give -respectively the name of the @var{input} file to read and the name of -the @var{output} file to produce. @emph{Be very careful} to note that, -in this case, the contents of file given by the second parameter is -destroyed. This behaviour is dictated only by System V @code{ptx} -compatibility, because GNU Standards discourage output parameters not -introduced by an option. - -Note that for @emph{any} file named as the value of an option or as an -input text file, a single dash @kbd{-} may be used, in which case -standard input is assumed. However, it would not make sense to use this -convention more than once per program invocation. - -@menu -* General options:: Options which affect general program behaviour. -* Charset selection:: Underlying character set considerations. -* Input processing:: Input fields, contexts, and keyword selection. -* Output formatting:: Types of output format, and sizing the fields. -@end menu - -@node General options, Charset selection, Invoking ptx, Invoking ptx -@section General options - -@table @code - -@item -C -@itemx --copyright -Prints a short note about the Copyright and copying conditions, then -exit without further processing. - -@item -G -@itemx --traditional -As already explained, this option disables all GNU extensions to -@code{ptx} and switch to traditional mode. - -@item --help -Prints a short help on standard output, then exit without further -processing. - -@item --version -Prints the program verison on standard output, then exit without further -processing. - -@end table - -@node Charset selection, Input processing, General options, Invoking ptx -@section Charset selection - -As it is setup now, the program assumes that the input file is coded -using 8-bit ISO 8859-1 code, also known as Latin-1 character set, -@emph{unless} if it is compiled for MS-DOS, in which case it uses the -character set of the IBM-PC. (GNU @code{ptx} is not known to work on -smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of -characters which are letters is then different, this fact alters the -behaviour of regular expression matching. Thus, the default regular -expression for a keyword allows foreign or diacriticized letters. -Keyword sorting, however, is still crude; it obeys the underlying -character set ordering quite blindly. - -@table @code - -@item -f -@itemx --ignore-case -Fold lower case letters to upper case for sorting. - -@end table - -@node Input processing, Output formatting, Charset selection, Invoking ptx -@section Word selection - -@table @code - -@item -b @var{file} -@item --break-file=@var{file} - -This option is an alternative way to option @code{-W} for describing -which characters make up words. This option introduces the name of a -file which contains a list of characters which can@emph{not} be part of -one word, this file is called the @dfn{Break file}. Any character which -is not part of the Break file is a word constituent. If both options -@code{-b} and @code{-W} are specified, then @code{-W} has precedence and -@code{-b} is ignored. - -When GNU extensions are enabled, the only way to avoid newline as a -break character is to write all the break characters in the file with no -newline at all, not even at the end of the file. When GNU extensions -are disabled, spaces, tabs and newlines are always considered as break -characters even if not included in the Break file. - -@item -i @var{file} -@itemx --ignore-file=@var{file} - -The file associated with this option contains a list of words which will -never be taken as keywords in concordance output. It is called the -@dfn{Ignore file}. The file contains exactly one word in each line; the -end of line separation of words is not subject to the value of the -@code{-S} option. - -There is a default Ignore file used by @code{ptx} when this option is -not specified, usually found in @file{/usr/local/lib/eign} if this has -not been changed at installation time. If you want to deactivate the -default Ignore file, specify @code{/dev/null} instead. - -@item -o @var{file} -@itemx --only-file=@var{file} - -The file associated with this option contains a list of words which will -be retained in concordance output, any word not mentioned in this file -is ignored. The file is called the @dfn{Only file}. The file contains -exactly one word in each line; the end of line separation of words is -not subject to the value of the @code{-S} option. - -There is no default for the Only file. In the case there are both an -Only file and an Ignore file, a word will be subject to be a keyword -only if it is given in the Only file and not given in the Ignore file. - -@item -r -@itemx --references - -On each input line, the leading sequence of non white characters will be -taken to be a reference that has the purpose of identifying this input -line on the produced permuted index. See @xref{Output formatting} for -more information about reference production. Using this option change -the default value for option @code{-S}. - -Using this option, the program does not try very hard to remove -references from contexts in output, but it succeeds in doing so -@emph{when} the context ends exactly at the newline. If option -@code{-r} is used with @code{-S} default value, or when GNU extensions -are disabled, this condition is always met and references are completely -excluded from the output contexts. - -@item -S @var{regexp} -@itemx --sentence-regexp=@var{regexp} - -This option selects which regular expression will describe the end of a -line or the end of a sentence. In fact, there is other distinction -between end of lines or end of sentences than the effect of this regular -expression, and input line boundaries have no special significance -outside this option. By default, when GNU extensions are enabled and if -@code{-r} option is not used, end of sentences are used. In this -case, the precise @var{regex} is imported from GNU emacs: - -@example -[.?!][]\"')@}]*\\($\\|\t\\| \\)[ \t\n]* -@end example - -Whenever GNU extensions are disabled or if @code{-r} option is used, end -of lines are used; in this case, the default @var{regexp} is just: - -@example -\n -@end example - -Using an empty REGEXP is equivalent to completely disabling end of line or end -of sentence recognition. In this case, the whole file is considered to -be a single big line or sentence. The user might want to disallow all -truncation flag generation as well, through option @code{-F ""}. -@xref{Regexps, , Syntax of Regular Expressions, emacs, The GNU Emacs -Manual}. - -When the keywords happen to be near the beginning of the input line or -sentence, this often creates an unused area at the beginning of the -output context line; when the keywords happen to be near the end of the -input line or sentence, this often creates an unused area at the end of -the output context line. The program tries to fill those unused areas -by wrapping around context in them; the tail of the input line or -sentence is used to fill the unused area on the left of the output line; -the head of the input line or sentence is used to fill the unused area -on the right of the output line. - -As a matter of convenience to the user, many usual backslashed escape -sequences, as found in the C language, are recognized and converted to -the corresponding characters by @code{ptx} itself. - -@item -W @var{regexp} -@itemx --word-regexp=@var{regexp} - -This option selects which regular expression will describe each keyword. -By default, if GNU extensions are enabled, a word is a sequence of -letters; the @var{regexp} used is @code{\w+}. When GNU extensions are -disabled, a word is by default anything which ends with a space, a tab -or a newline; the @var{regexp} used is @code{[^ \t\n]+}. - -An empty REGEXP is equivalent to not using this option, letting the -default dive in. @xref{Regexps, , Syntax of Regular Expressions, emacs, -The GNU Emacs Manual}. - -As a matter of convenience to the user, many usual backslashed escape -sequences, as found in the C language, are recognized and converted to -the corresponding characters by @code{ptx} itself. - -@end table - -@node Output formatting, , Input processing, Invoking ptx -@section Output formatting - -Output format is mainly controlled by @code{-O} and @code{-T} options, -described in the table below. When neither @code{-O} nor @code{-T} is -selected, and if GNU extensions are enabled, the program choose an -output format suited for a dumb terminal. Each keyword occurrence is -output to the center of one line, surrounded by its left and right -contexts. Each field is properly justified, so the concordance output -could readily be observed. As a special feature, if automatic -references are selected by option @code{-A} and are output before the -left context, that is, if option @code{-R} is @emph{not} selected, then -a colon is added after the reference; this nicely interfaces with GNU -Emacs @code{next-error} processing. In this default output format, each -white space character, like newline and tab, is merely changed to -exactly one space, with no special attempt to compress consecutive -spaces. This might change in the future. Except for those white space -characters, every other character of the underlying set of 256 -characters is transmitted verbatim. - -Output format is further controlled by the following options. - -@table @code - -@item -g @var{number} -@itemx --gap-size=@var{number} - -Select the size of the minimum white gap between the fields on the output -line. - -@item -w @var{number} -@itemx --width=@var{number} - -Select the output maximum width of each final line. If references are -used, they are included or excluded from the output maximum width -depending on the value of option @code{-R}. If this option is not -selected, that is, when references are output before the left context, -the output maximum width takes into account the maximum length of all -references. If this options is selected, that is, when references are -output after the right context, the output maximum width does not take -into account the space taken by references, nor the gap that precedes -them. - -@item -A -@itemx --auto-reference - -Select automatic references. Each input line will have an automatic -reference made up of the file name and the line ordinal, with a single -colon between them. However, the file name will be empty when standard -input is being read. If both @code{-A} and @code{-r} are selected, then -the input reference is still read and skipped, but the automatic -reference is used at output time, overriding the input reference. - -@item -R -@itemx --right-side-refs - -In default output format, when option @code{-R} is not used, any -reference produced by the effect of options @code{-r} or @code{-A} are -given to the far right of output lines, after the right context. In -default output format, when option @code{-R} is specified, references -are rather given to the beginning of each output line, before the left -context. For any other output format, option @code{-R} is almost -ignored, except for the fact that the width of references is @emph{not} -taken into account in total output width given by @code{-w} whenever -@code{-R} is selected. - -This option is automatically selected whenever GNU extensions are -disabled. - -@item -F @var{string} -@itemx --flac-truncation=@var{string} - -This option will request that any truncation in the output be reported -using the string @var{string}. Most output fields theoretically extend -towards the beginning or the end of the current line, or current -sentence, as selected with option @code{-S}. But there is a maximum -allowed output line width, changeable through option @code{-w}, which is -further divided into space for various output fields. When a field has -to be truncated because cannot extend until the beginning or the end of -the current line to fit in the, then a truncation occurs. By default, -the string used is a single slash, as in @code{-F /}. - -@var{string} may have more than one character, as in @code{-F ...}. -Also, in the particular case @var{string} is empty (@code{-F ""}), -truncation flagging is disabled, and no truncation marks are appended in -this case. - -As a matter of convenience to the user, many usual backslashed escape -sequences, as found in the C language, are recognized and converted to -the corresponding characters by @code{ptx} itself. - -@item -M @var{string} -@itemx --macro-name=@var{string} - -Select another @var{string} to be used instead of @samp{xx}, while -generating output suitable for @code{nroff}, @code{troff} or @TeX{}. - -@item -O -@itemx --format=roff - -Choose an output format suitable for @code{nroff} or @code{troff} -processing. Each output line will look like: - -@example -.xx "@var{tail}" "@var{before}" "@var{keyword_and_after}" "@var{head}" "@var{ref}" -@end example - -so it will be possible to write an @samp{.xx} roff macro to take care of -the output typesetting. This is the default output format when GNU -extensions are disabled. Option @samp{-M} might be used to change -@samp{xx} to another macro name. - -In this output format, each non-graphical character, like newline and -tab, is merely changed to exactly one space, with no special attempt to -compress consecutive spaces. Each quote character: @kbd{"} is doubled -so it will be correctly processed by @code{nroff} or @code{troff}. - -@item -T -@itemx --format=tex - -Choose an output format suitable for @TeX{} processing. Each output -line will look like: - -@example -\xx @{@var{tail}@}@{@var{before}@}@{@var{keyword}@}@{@var{after}@}@{@var{head}@}@{@var{ref}@} -@end example - -@noindent -so it will be possible to write write a @code{\xx} definition to take -care of the output typesetting. Note that when references are not being -produced, that is, neither option @code{-A} nor option @code{-r} is -selected, the last parameter of each @code{\xx} call is inhibited. -Option @samp{-M} might be used to change @samp{xx} to another macro -name. - -In this output format, some special characters, like @kbd{$}, @kbd{%}, -@kbd{&}, @kbd{#} and @kbd{_} are automatically protected with a -backslash. Curly brackets @kbd{@{}, @kbd{@}} are also protected with a -backslash, but also enclosed in a pair of dollar signs to force -mathematical mode. The backslash itself produces the sequence -@code{\backslash@{@}}. Circumflex and tilde diacritics produce the -sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other -diacriticized characters of the underlying character set produce an -appropriate @TeX{} sequence as far as possible. The other non-graphical -characters, like newline and tab, and all others characters which are -not part of ASCII, are merely changed to exactly one space, with no -special attempt to compress consecutive spaces. Let me know how to -improve this special character processing for @TeX{}. - -@end table - -@node Compatibility, , Invoking ptx, Top -@chapter The GNU extensions to @code{ptx} - -This version of @code{ptx} contains a few features which do not exist in -System V @code{ptx}. These extra features are suppressed by using the -@samp{-G} command line option, unless overridden by other command line -options. Some GNU extensions cannot be recovered by overriding, so the -simple rule is to avoid @samp{-G} if you care about GNU extensions. -Here are the differences between this program and System V @code{ptx}. - -@itemize @bullet - -@item -This program can read many input files at once, it always writes the -resulting concordance on standard output. On the other end, System V -@code{ptx} reads only one file and produce the result on standard output -or, if a second @var{file} parameter is given on the command, to that -@var{file}. - -Having output parameters not introduced by options is a quite dangerous -practice which GNU avoids as far as possible. So, for using @code{ptx} -portably between GNU and System V, you should pay attention to always -use it with a single input file, and always expect the result on -standard output. You might also want to automatically configure in a -@samp{-G} option to @code{ptx} calls in products using @code{ptx}, if -the configurator finds that the installed @code{ptx} accepts @samp{-G}. - -@item -The only options available in System V @code{ptx} are options @samp{-b}, -@samp{-f}, @samp{-g}, @samp{-i}, @samp{-o}, @samp{-r}, @samp{-t} and -@samp{-w}. All other options are GNU extensions and are not repeated in -this enumeration. Moreover, some options have a slightly different -meaning when GNU extensions are enabled, as explained below. - -@item -By default, concordance output is not formatted for @code{troff} or -@code{nroff}. It is rather formatted for a dumb terminal. @code{troff} -or @code{nroff} output may still be selected through option @code{-O}. - -@item -Unless @code{-R} option is used, the maximum reference width is -subtracted from the total output line width. With GNU extensions -disabled, width of references is not taken into account in the output -line width computations. - -@item -All 256 characters, even @kbd{NUL}s, are always read and processed from -input file with no adverse effect, even if GNU extensions are disabled. -However, System V @code{ptx} does not accept 8-bit characters, a few -control characters are rejected, and the tilda @kbd{~} is condemned. - -@item -Input line length is only limited by available memory, even if GNU -extensions are disabled. However, System V @code{ptx} processes only -the first 200 characters in each line. - -@item -The break (non-word) characters default to be every character except all -letters of the underlying character set, diacriticized or not. When GNU -extensions are disabled, the break characters default to space, tab and -newline only. - -@item -The program makes better use of output line width. If GNU extensions -are disabled, the program rather tries to imitate System V @code{ptx}, -but still, there are some slight disposition glitches this program does -not completely reproduce. - -@item -The user can specify both an Ignore file and an Only file. This is not -allowed with System V @code{ptx}. - -@end itemize - -@bye diff --git a/gnu/usr.bin/tar/regex.h b/gnu/usr.bin/tar/regex.h deleted file mode 100644 index 0840861da369..000000000000 --- a/gnu/usr.bin/tar/regex.h +++ /dev/null @@ -1,490 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library, version 0.11. - - Copyright (C) 1985, 89, 90, 91, 92 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __REGEXP_LIBRARY_H__ -#define __REGEXP_LIBRARY_H__ - -/* POSIX says that must be included (by the caller) before - . */ - -#ifdef VMS -/* VMS doesn't have `size_t' in , even though POSIX says it - should be there. */ -#include -#endif - - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* If this bit is set, then character classes are supported. They are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -#undef RE_DUP_MAX -#endif -#define RE_DUP_MAX ((1 << 15) - 1) - - -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - - -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields `buffer', `allocated', `fastmap', - `translate', and `no_sub' can be set. After the pattern has been - compiled, the `re_nsub' field is available. All other fields are - private to the regex routines. */ - -struct re_pattern_buffer -{ -/* [[[begin pattern_buffer]]] */ - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -/* [[[end pattern_buffer]]] */ -}; - -typedef struct re_pattern_buffer regex_t; - - -/* search.c (search_buffer) in Emacs needs this one opcode value. It is - defined both in `regex.c' and here. */ -#define RE_EXACTN_VALUE 1 - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - `re_match_2' returns information about at least this many registers - the first time a `regs' structure is passed. */ -#ifndef RE_NREGS -#define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -#define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -#define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `re_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, int length, - struct re_pattern_buffer *buffer)); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); - - -/* Like `re_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); - - -/* Like `re_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); - - -/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); - -/* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); - -/* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); -extern int regexec - _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags)); -extern size_t regerror - _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size)); -extern void regfree _RE_ARGS ((regex_t *preg)); - -#endif /* not __REGEXP_LIBRARY_H__ */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/usr.bin/tar/y.tab.h b/gnu/usr.bin/tar/y.tab.h deleted file mode 100644 index 4a541d2c97f7..000000000000 --- a/gnu/usr.bin/tar/y.tab.h +++ /dev/null @@ -1,18 +0,0 @@ -#define tAGO 257 -#define tDAY 258 -#define tDAYZONE 259 -#define tID 260 -#define tMERIDIAN 261 -#define tMINUTE_UNIT 262 -#define tMONTH 263 -#define tMONTH_UNIT 264 -#define tSEC_UNIT 265 -#define tSNUMBER 266 -#define tUNUMBER 267 -#define tZONE 268 -#define tDST 269 -typedef union { - time_t Number; - enum _MERIDIAN Meridian; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/texinfo/info-files/info-stnd.info b/gnu/usr.bin/texinfo/info-files/info-stnd.info deleted file mode 100644 index 31f486a45cb4..000000000000 --- a/gnu/usr.bin/texinfo/info-files/info-stnd.info +++ /dev/null @@ -1,1259 +0,0 @@ -This is Info file info-stnd.info, produced by Makeinfo-1.55 from the -input file info-stnd.texi. - -This file documents GNU Info, a program for viewing the on-line -formatted versions of Texinfo files. This documentation is different -from the documentation for the Info reader that is part of GNU Emacs. -If you do not know how to use Info, but have a working Info reader, you -should read that documentation first. - -Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -sections entitled "Copying" and "GNU General Public License" are -included exactly as in the original, and provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. - - -File: info-stnd.info, Node: Top, Next: What is Info, Prev: (dir), Up: (dir) - -The GNU Info Program -******************** - -This file documents GNU Info, a program for viewing the on-line -formatted versions of Texinfo files, version 2.9. This documentation -is different from the documentation for the Info reader that is part of -GNU Emacs. - -* Menu: - -* What is Info:: -* Options:: Options you can pass on the command line. -* Cursor Commands:: Commands which move the cursor within a node. -* Scrolling Commands:: Commands for moving the node around - in a window. -* Node Commands:: Commands for selecting a new node. -* Searching Commands:: Commands for searching an Info file. -* Xref Commands:: Commands for selecting cross references. -* Window Commands:: Commands which manipulate multiple windows. -* Printing Nodes:: How to print out the contents of a node. -* Miscellaneous Commands:: A few commands that defy categories. -* Variables:: How to change the default behavior of Info. -* GNU Info Global Index:: Global index containing keystrokes, - command names, variable names, - and general concepts. - - -File: info-stnd.info, Node: What is Info, Next: Options, Prev: Top, Up: Top - -What is Info? -************* - -"Info" is a program which is used to view Info files on an ASCII -terminal. "Info files" are the result of processing Texinfo files with -the program `makeinfo' or with one of the Emacs commands, such as `M-x -texinfo-format-buffer'. Texinfo itself is a documentation system that -uses a single source file to produce both on-line information and -printed output. You can typeset and print the files that you read in -Info. - - -File: info-stnd.info, Node: Options, Next: Cursor Commands, Prev: What is Info, Up: Top - -Command Line Options -******************** - -GNU Info accepts several options to control the initial node being -viewed, and to specify which directories to search for Info files. Here -is a template showing an invocation of GNU Info from the shell: - - info [--OPTION-NAME OPTION-VALUE] MENU-ITEM... - -The following OPTION-NAMES are available when invoking Info from the -shell: - -`--directory DIRECTORY-PATH' -`-d DIRECTORY-PATH' - Add DIRECTORY-PATH to the list of directory paths searched when - Info needs to find a file. You may issue `--directory' multiple - times; once for each directory which contains Info files. - Alternatively, you may specify a value for the environment variable - `INFOPATH'; if `--directory' is not given, the value of `INFOPATH' - is used. The value of `INFOPATH' is a colon separated list of - directory names. If you do not supply `INFOPATH' or - `--directory-path', Info uses a default path. - -`--file FILENAME' -`-f FILENAME' - Specify a particular Info file to visit. By default, Info visits - the file `dir'; if you use this option, Info will start with - `(FILENAME)Top' as the first file and node. - -`--node NODENAME' -`-n NODENAME' - Specify a particular node to visit in the initial file that Info - loads. This is especially useful in conjunction with `--file'(1) - (*note Options-Footnotes::). You may specify `--node' multiple - times; for an interactive Info, each NODENAME is visited in its - own window, for a non-interactive Info (such as when `--output' is - given) each NODENAME is processed sequentially. - -`--output FILENAME' -`-o FILENAME' - Specify FILENAME as the name of a file to which to direct output. - Each node that Info visits will be output to FILENAME instead of - interactively viewed. A value of `-' for FILENAME specifies the - standard output. - -`--subnodes' - This option only has meaning when given in conjunction with - `--output'. It means to recursively output the nodes appearing in - the menus of each node being output. Menu items which resolve to - external Info files are not output, and neither are menu items - which are members of an index. Each node is only output once. - -`--help' -`-h' - Produces a relatively brief description of the available Info - options. - -`--version' - Prints the version information of Info and exits. - -`MENU-ITEM' - Info treats its remaining arguments as the names of menu items. - The first argument is a menu item in the initial node visited, - while the second argument is a menu item in the first argument's - node. You can easily move to the node of your choice by - specifying the menu names which describe the path to that node. - For example, - - info emacs buffers - - first selects the menu item `Emacs' in the node `(dir)Top', and - then selects the menu item `Buffers' in the node `(emacs)Top'. - - -File: info-stnd.info, Node: Options-Footnotes, Up: Options - -(1) Of course, you can specify both the file and node in a `--node' -command; but don't forget to escape the open and close parentheses from -the shell as in: `info --node '(emacs)Buffers'' - - -File: info-stnd.info, Node: Cursor Commands, Next: Scrolling Commands, Prev: Options, Up: Top - -Moving the Cursor -***************** - -Many people find that reading screens of text page by page is made -easier when one is able to indicate particular pieces of text with some -kind of pointing device. Since this is the case, GNU Info (both the -Emacs and standalone versions) have several commands which allow you to -move the cursor about the screen. The notation used in this manual to -describe keystrokes is identical to the notation used within the Emacs -manual, and the GNU Readline manual. *Note Character Conventions: -(emacs)Characters, if you are unfamiliar with the notation. - -The following table lists the basic cursor movement commands in Info. -Each entry consists of the key sequence you should type to execute the -cursor movement, the `M-x'(1) (*note Cursor Commands-Footnotes::) -command name (displayed in parentheses), and a short description of -what the command does. All of the cursor motion commands can take an -"numeric" argument (*note `universal-argument': Miscellaneous -Commands.), to find out how to supply them. With a numeric argument, -the motion commands are simply executed that many times; for example, a -numeric argument of 4 given to `next-line' causes the cursor to move -down 4 lines. With a negative numeric argument, the motion is -reversed; an argument of -4 given to the `next-line' command would -cause the cursor to move *up* 4 lines. - -`C-n' (`next-line') - Move the cursor down to the next line. - -`C-p' (`prev-line') - Move the cursor up to the previous line. - -`C-a' (`beginning-of-line') - Move the cursor to the start of the current line. - -`C-e' (`end-of-line') - Move the cursor to the end of the current line. - -`C-f' (`forward-char') - Move the cursor forward a character. - -`C-b' (`backward-char') - Move the cursor backward a character. - -`M-f' (`forward-word') - Move the cursor forward a word. - -`M-b' (`backward-word') - Move the cursor backward a word. - -`M-<' (`beginning-of-node') -`b' - Move the cursor to the start of the current node. - -`M->' (`end-of-node') - Move the cursor to the end of the current node. - -`M-r' (`move-to-window-line') - Move the cursor to a specific line of the window. Without a - numeric argument, `M-r' moves the cursor to the start of the line - in the center of the window. With a numeric argument of N, `M-r' - moves the cursor to the start of the Nth line in the window. - - -File: info-stnd.info, Node: Cursor Commands-Footnotes, Up: Cursor Commands - -(1) `M-x' is also a command; it invokes `execute-extended-command'. -*Note Executing an extended command: (emacs)M-x, for more detailed -information. - - -File: info-stnd.info, Node: Scrolling Commands, Next: Node Commands, Prev: Cursor Commands, Up: Top - -Moving Text Within a Window -*************************** - -Sometimes you are looking at a screenful of text, and only part of the -current paragraph you are reading is visible on the screen. The -commands detailed in this section are used to shift which part of the -current node is visible on the screen. - -`SPC' (`scroll-forward') -`C-v' - Shift the text in this window up. That is, show more of the node - which is currently below the bottom of the window. With a numeric - argument, show that many more lines at the bottom of the window; a - numeric argument of 4 would shift all of the text in the window up - 4 lines (discarding the top 4 lines), and show you four new lines - at the bottom of the window. Without a numeric argument, SPC - takes the bottom two lines of the window and places them at the - top of the window, redisplaying almost a completely new screenful - of lines. - -`DEL' (`scroll-backward') -`M-v' - Shift the text in this window down. The inverse of - `scroll-forward'. - -The `scroll-forward' and `scroll-backward' commands can also move -forward and backward through the node structure of the file. If you -press SPC while viewing the end of a node, or DEL while viewing the -beginning of a node, what happens is controlled by the variable -`scroll-behavior'. *Note `scroll-behavior': Variables, for more -information. - -`C-l' (`redraw-display') - Redraw the display from scratch, or shift the line containing the - cursor to a specified location. With no numeric argument, `C-l' - clears the screen, and then redraws its entire contents. Given a - numeric argument of N, the line containing the cursor is shifted - so that it is on the Nth line of the window. - -`C-x w' (`toggle-wrap') - Toggles the state of line wrapping in the current window. - Normally, lines which are longer than the screen width "wrap", - i.e., they are continued on the next line. Lines which wrap have - a `\' appearing in the rightmost column of the screen. You can - cause such lines to be terminated at the rightmost column by - changing the state of line wrapping in the window with `C-x w'. - When a line which needs more space than one screen width to - display is displayed, a `$' appears in the rightmost column of the - screen, and the remainder of the line is invisible. - - -File: info-stnd.info, Node: Node Commands, Next: Searching Commands, Prev: Scrolling Commands, Up: Top - -Selecting a New Node -******************** - -This section details the numerous Info commands which select a new node -to view in the current window. - -The most basic node commands are `n', `p', `u', and `l'. - -When you are viewing a node, the top line of the node contains some Info -"pointers" which describe where the next, previous, and up nodes are. -Info uses this line to move about the node structure of the file when -you use the following commands: - -`n' (`next-node') - Select the `Next' node. - -`p' (`prev-node') - Select the `Prev' node. - -`u' (`up-node') - Select the `Up' node. - -You can easily select a node that you have already viewed in this window -by using the `l' command - this name stands for "last", and actually -moves through the list of already visited nodes for this window. `l' -with a negative numeric argument moves forward through the history of -nodes for this window, so you can quickly step between two adjacent (in -viewing history) nodes. - -`l' (`history-node') - Select the most recently selected node in this window. - -Two additional commands make it easy to select the most commonly -selected nodes; they are `t' and `d'. - -`t' (`top-node') - Select the node `Top' in the current Info file. - -`d' (`dir-node') - Select the directory node (i.e., the node `(dir)'). - -Here are some other commands which immediately result in the selection -of a different node in the current window: - -`<' (`first-node') - Selects the first node which appears in this file. This node is - most often `Top', but it does not have to be. - -`>' (`last-node') - Select the last node which appears in this file. - -`]' (`global-next-node') - Move forward or down through node structure. If the node that you - are currently viewing has a `Next' pointer, that node is selected. - Otherwise, if this node has a menu, the first menu item is - selected. If there is no `Next' and no menu, the same process is - tried with the `Up' node of this node. - -`[' (`global-prev-node') - Move backward or up through node structure. If the node that you - are currently viewing has a `Prev' pointer, that node is selected. - Otherwise, if the node has an `Up' pointer, that node is selected, - and if it has a menu, the last item in the menu is selected. - -You can get the same behavior as `global-next-node' and -`global-prev-node' while simply scrolling through the file with SPC and -DEL; *Note `scroll-behavior': Variables, for more information. - -`g' (`goto-node') - Read the name of a node and select it. No completion is done while - reading the node name, since the desired node may reside in a - separate file. The node must be typed exactly as it appears in - the Info file. A file name may be included as with any node - specification, for example - - `g(emacs)Buffers' - - finds the node `Buffers' in the Info file `emacs'. - -`C-x k' (`kill-node') - Kill a node. The node name is prompted for in the echo area, with - a default of the current node. "Killing" a node means that Info - tries hard to forget about it, removing it from the list of - history nodes kept for the window where that node is found. - Another node is selected in the window which contained the killed - node. - -`C-x C-f' (`view-file') - Read the name of a file and selects the entire file. The command - `C-x C-f FILENAME' - is equivalent to typing - `g(FILENAME)*' - -`C-x C-b' (`list-visited-nodes') - Make a window containing a menu of all of the currently visited - nodes. This window becomes the selected window, and you may use - the standard Info commands within it. - -`C-x b' (`select-visited-node') - Select a node which has been previously visited in a visible - window. This is similar to `C-x C-b' followed by `m', but no - window is created. - - -File: info-stnd.info, Node: Searching Commands, Next: Xref Commands, Prev: Node Commands, Up: Top - -Searching an Info File -********************** - -GNU Info allows you to search for a sequence of characters throughout an -entire Info file, search through the indices of an Info file, or find -areas within an Info file which discuss a particular topic. - -`s' (`search') - Read a string in the echo area and search for it. - -`C-s' (`isearch-forward') - Interactively search forward through the Info file for a string as - you type it. - -`C-r' (`isearch-backward') - Interactively search backward through the Info file for a string as - you type it. - -`i' (`index-search') - Look up a string in the indices for this Info file, and select a - node where the found index entry points to. - -`,' (`next-index-match') - Move to the node containing the next matching index item from the - last `i' command. - -The most basic searching command is `s' (`search'). The `s' command -prompts you for a string in the echo area, and then searches the -remainder of the Info file for an occurrence of that string. If the -string is found, the node containing it is selected, and the cursor is -left positioned at the start of the found string. Subsequent `s' -commands show you the default search string within `[' and `]'; -pressing RET instead of typing a new string will use the default search -string. - -"Incremental searching" is similar to basic searching, but the string -is looked up while you are typing it, instead of waiting until the -entire search string has been specified. - - -File: info-stnd.info, Node: Xref Commands, Next: Window Commands, Prev: Searching Commands, Up: Top - -Selecting Cross References -************************** - -We have already discussed the `Next', `Prev', and `Up' pointers which -appear at the top of a node. In addition to these pointers, a node may -contain other pointers which refer you to a different node, perhaps in -another Info file. Such pointers are called "cross references", or -"xrefs" for short. - -* Menu: - -* Parts of an Xref:: What a cross reference is made of. -* Selecting Xrefs:: Commands for selecting menu or note items. - - -File: info-stnd.info, Node: Parts of an Xref, Next: Selecting Xrefs, Up: Xref Commands - -Parts of an Xref -================ - -Cross references have two major parts: the first part is called the -"label"; it is the name that you can use to refer to the cross -reference, and the second is the "target"; it is the full name of the -node that the cross reference points to. - -The target is separated from the label by a colon `:'; first the label -appears, and then the target. For example, in the sample menu cross -reference below, the single colon separates the label from the target. - - * Foo Label: Foo Target. More information about Foo. - -Note the `.' which ends the name of the target. The `.' is not part of -the target; it serves only to let Info know where the target name ends. - -A shorthand way of specifying references allows two adjacent colons to -stand for a target name which is the same as the label name: - - * Foo Commands:: Commands pertaining to Foo. - -In the above example, the name of the target is the same as the name of -the label, in this case `Foo Commands'. - -You will normally see two types of cross reference while viewing nodes: -"menu" references, and "note" references. Menu references appear -within a node's menu; they begin with a `*' at the beginning of a line, -and continue with a label, a target, and a comment which describes what -the contents of the node pointed to contains. - -Note references appear within the body of the node text; they begin with -`*Note', and continue with a label and a target. - -Like `Next', `Prev', and `Up' pointers, cross references can point to -any valid node. They are used to refer you to a place where more -detailed information can be found on a particular subject. Here is a -cross reference which points to a node within the Texinfo -documentation: *Note Writing an Xref: (texinfo)xref, for more -information on creating your own texinfo cross references. - - -File: info-stnd.info, Node: Selecting Xrefs, Prev: Parts of an Xref, Up: Xref Commands - -Selecting Xrefs -=============== - -The following table lists the Info commands which operate on menu items. - -`1' (`menu-digit') -`2' ... `9' - Within an Info window, pressing a single digit, (such as `1'), - selects that menu item, and places its node in the current window. - For convenience, there is one exception; pressing `0' selects the - *last* item in the node's menu. - -`0' (`last-menu-item') - Select the last item in the current node's menu. - -`m' (`menu-item') - Reads the name of a menu item in the echo area and selects its - node. Completion is available while reading the menu label. - -`M-x find-menu' - Move the cursor to the start of this node's menu. - -This table lists the Info commands which operate on note cross -references. - -`f' (`xref-item') -`r' - Reads the name of a note cross reference in the echo area and - selects its node. Completion is available while reading the cross - reference label. - -Finally, the next few commands operate on menu or note references alike: - -`TAB' (`move-to-next-xref') - Move the cursor to the start of the next nearest menu item or note - reference in this node. You can then use RET - (`select-reference-this-line') to select the menu or note - reference. - -`M-TAB' (`move-to-prev-xref') - Move the cursor the start of the nearest previous menu item or note - reference in this node. - -`RET' (`select-reference-this-line') - Select the menu item or note reference appearing on this line. - - -File: info-stnd.info, Node: Window Commands, Next: Printing Nodes, Prev: Xref Commands, Up: Top - -Manipulating Multiple Windows -***************************** - -A "window" is a place to show the text of a node. Windows have a view -area where the text of the node is displayed, and an associated "mode -line", which briefly describes the node being viewed. - -GNU Info supports multiple windows appearing in a single screen; each -window is separated from the next by its modeline. At any time, there -is only one "active" window, that is, the window in which the cursor -appears. There are commands available for creating windows, changing -the size of windows, selecting which window is active, and for deleting -windows. - -* Menu: - -* The Mode Line:: What appears in the mode line? -* Basic Windows:: Manipulating windows in Info. -* The Echo Area:: Used for displaying errors and reading input. - - -File: info-stnd.info, Node: The Mode Line, Next: Basic Windows, Up: Window Commands - -The Mode Line -============= - -A "mode line" is a line of inverse video which appears at the bottom of -an Info window. It describes the contents of the window just above it; -this information includes the name of the file and node appearing in -that window, the number of screen lines it takes to display the node, -and the percentage of text that is above the top of the window. It can -also tell you if the indirect tags table for this Info file needs to be -updated, and whether or not the Info file was compressed when stored on -disk. - -Here is a sample mode line for a window containing an uncompressed file -named `dir', showing the node `Top'. - - -----Info: (dir)Top, 40 lines --Top--------------------------------------- - ^^ ^ ^^^ ^^ - (file)Node #lines where - -When a node comes from a file which is compressed on disk, this is -indicated in the mode line with two small `z''s. In addition, if the -Info file containing the node has been split into subfiles, the name of -the subfile containing the node appears in the modeline as well: - - --zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- - -When Info makes a node internally, such that there is no corresponding -info file on disk, the name of the node is surrounded by asterisks -(`*'). The name itself tells you what the contents of the window are; -the sample mode line below shows an internally constructed node showing -possible completions: - - -----Info: *Completions*, 7 lines --All----------------------------------- - - -File: info-stnd.info, Node: Basic Windows, Next: The Echo Area, Prev: The Mode Line, Up: Window Commands - -Window Commands -=============== - -It can be convenient to view more than one node at a time. To allow -this, Info can display more than one "window". Each window has its own -mode line (*note The Mode Line::.) and history of nodes viewed in that -window (*note `history-node': Node Commands.). - -`C-x o' (`next-window') - Select the next window on the screen. Note that the echo area can - only be selected if it is already in use, and you have left it - temporarily. Normally, `C-x o' simply moves the cursor into the - next window on the screen, or if you are already within the last - window, into the first window on the screen. Given a numeric - argument, `C-x o' moves over that many windows. A negative - argument causes `C-x o' to select the previous window on the - screen. - -`M-x prev-window' - Select the previous window on the screen. This is identical to - `C-x o' with a negative argument. - -`C-x 2' (`split-window') - Split the current window into two windows, both showing the same - node. Each window is one half the size of the original window, - and the cursor remains in the original window. The variable - `automatic-tiling' can cause all of the windows on the screen to - be resized for you automatically, please *note automatic-tiling: - Variables. for more information. - -`C-x 0' (`delete-window') - Delete the current window from the screen. If you have made too - many windows and your screen appears cluttered, this is the way to - get rid of some of them. - -`C-x 1' (`keep-one-window') - Delete all of the windows excepting the current one. - -`ESC C-v' (`scroll-other-window') - Scroll the other window, in the same fashion that `C-v' might - scroll the current window. Given a negative argument, scroll the - "other" window backward. - -`C-x ^' (`grow-window') - Grow (or shrink) the current window. Given a numeric argument, - grow the current window that many lines; with a negative numeric - argument, shrink the window instead. - -`C-x t' (`tile-windows') - Divide the available screen space among all of the visible windows. - Each window is given an equal portion of the screen in which to - display its contents. The variable `automatic-tiling' can cause - `tile-windows' to be called when a window is created or deleted. - *Note `automatic-tiling': Variables. - - -File: info-stnd.info, Node: The Echo Area, Prev: Basic Windows, Up: Window Commands - -The Echo Area -============= - -The "echo area" is a one line window which appears at the bottom of the -screen. It is used to display informative or error messages, and to -read lines of input from you when that is necessary. Almost all of the -commands available in the echo area are identical to their Emacs -counterparts, so please refer to that documentation for greater depth of -discussion on the concepts of editing a line of text. The following -table briefly lists the commands that are available while input is being -read in the echo area: - -`C-f' (`echo-area-forward') - Move forward a character. - -`C-b' (`echo-area-backward') - Move backward a character. - -`C-a' (`echo-area-beg-of-line') - Move to the start of the input line. - -`C-e' (`echo-area-end-of-line') - Move to the end of the input line. - -`M-f' (`echo-area-forward-word') - Move forward a word. - -`M-b' (`echo-area-backward-word') - Move backward a word. - -`C-d' (`echo-area-delete') - Delete the character under the cursor. - -`DEL' (`echo-area-rubout') - Delete the character behind the cursor. - -`C-g' (`echo-area-abort') - Cancel or quit the current operation. If completion is being read, - `C-g' discards the text of the input line which does not match any - completion. If the input line is empty, `C-g' aborts the calling - function. - -`RET' (`echo-area-newline') - Accept (or forces completion of) the current input line. - -`C-q' (`echo-area-quoted-insert') - Insert the next character verbatim. This is how you can insert - control characters into a search string, for example. - -PRINTING CHARACTER (`echo-area-insert') - Insert the character. - -`M-TAB' (`echo-area-tab-insert') - Insert a TAB character. - -`C-t' (`echo-area-transpose-chars') - Transpose the characters at the cursor. - -The next group of commands deal with "killing", and "yanking" text. -For an in depth discussion of killing and yanking, *note Killing and -Deleting: (emacs)Killing. - -`M-d' (`echo-area-kill-word') - Kill the word following the cursor. - -`M-DEL' (`echo-area-backward-kill-word') - Kill the word preceding the cursor. - -`C-k' (`echo-area-kill-line') - Kill the text from the cursor to the end of the line. - -`C-x DEL' (`echo-area-backward-kill-line') - Kill the text from the cursor to the beginning of the line. - -`C-y' (`echo-area-yank') - Yank back the contents of the last kill. - -`M-y' (`echo-area-yank-pop') - Yank back a previous kill, removing the last yanked text first. - -Sometimes when reading input in the echo area, the command that needed -input will only accept one of a list of several choices. The choices -represent the "possible completions", and you must respond with one of -them. Since there are a limited number of responses you can make, Info -allows you to abbreviate what you type, only typing as much of the -response as is necessary to uniquely identify it. In addition, you can -request Info to fill in as much of the response as is possible; this is -called "completion". - -The following commands are available when completing in the echo area: - -`TAB' (`echo-area-complete') -`SPC' - Insert as much of a completion as is possible. - -`?' (`echo-area-possible-completions') - Display a window containing a list of the possible completions of - what you have typed so far. For example, if the available choices - are: - - bar - foliate - food - forget - - and you have typed an `f', followed by `?', the possible - completions would contain: - - foliate - food - forget - - i.e., all of the choices which begin with `f'. Pressing SPC or - TAB would result in `fo' appearing in the echo area, since all of - the choices which begin with `f' continue with `o'. Now, typing - `l' followed by `TAB' results in `foliate' appearing in the echo - area, since that is the only choice which begins with `fol'. - -`ESC C-v' (`echo-area-scroll-completions-window') - Scroll the completions window, if that is visible, or the "other" - window if not. - - -File: info-stnd.info, Node: Printing Nodes, Next: Miscellaneous Commands, Prev: Window Commands, Up: Top - -Printing Out Nodes -****************** - -You may wish to print out the contents of a node as a quick reference -document for later use. Info provides you with a command for doing -this. In general, we recommend that you use TeX to format the document -and print sections of it, by running `tex' on the Texinfo source file. - -`M-x print-node' - Pipe the contents of the current node through the command in the - environment variable `INFO_PRINT_COMMAND'. If the variable does - not exist, the node is simply piped to `lpr'. - - -File: info-stnd.info, Node: Miscellaneous Commands, Next: Variables, Prev: Printing Nodes, Up: Top - -Miscellaneous Commands -********************** - -GNU Info contains several commands which self-document GNU Info: - -`M-x describe-command' - Read the name of an Info command in the echo area and then display - a brief description of what that command does. - -`M-x describe-key' - Read a key sequence in the echo area, and then display the name and - documentation of the Info command that the key sequence invokes. - -`M-x describe-variable' - Read the name of a variable in the echo area and then display a - brief description of what the variable affects. - -`M-x where-is' - Read the name of an Info command in the echo area, and then display - a key sequence which can be typed in order to invoke that command. - -`C-h' (`get-help-window') -`?' - Create (or Move into) the window displaying `*Help*', and place a - node containing a quick reference card into it. This window - displays the most concise information about GNU Info available. - -`h' (`get-info-help-node') - Try hard to visit the node `(info)Help'. The Info file - `info.texi' distributed with GNU Info contains this node. Of - course, the file must first be processed with `makeinfo', and then - placed into the location of your Info directory. - -Here are the commands for creating a numeric argument: - -`C-u' (`universal-argument') - Start (or multiply by 4) the current numeric argument. `C-u' is a - good way to give a small numeric argument to cursor movement or - scrolling commands; `C-u C-v' scrolls the screen 4 lines, while - `C-u C-u C-n' moves the cursor down 16 lines. - -`M-1' (`add-digit-to-numeric-arg') -`M-2' ... `M-9' - Add the digit value of the invoking key to the current numeric - argument. Once Info is reading a numeric argument, you may just - type the digits of the argument, without the Meta prefix. For - example, you might give `C-l' a numeric argument of 32 by typing: - - `C-u 3 2 C-l' - - or - - `M-3 2 C-l' - -`C-g' is used to abort the reading of a multi-character key sequence, -to cancel lengthy operations (such as multi-file searches) and to -cancel reading input in the echo area. - -`C-g' (`abort-key') - Cancel current operation. - -The `q' command of Info simply quits running Info. - -`q' (`quit') - Exit GNU Info. - -If the operating system tells GNU Info that the screen is 60 lines tall, -and it is actually only 40 lines tall, here is a way to tell Info that -the operating system is correct. - -`M-x set-screen-height' - Read a height value in the echo area and set the height of the - displayed screen to that value. - -Finally, Info provides a convenient way to display footnotes which might -be associated with the current node that you are viewing: - -`ESC C-f' (`show-footnotes') - Show the footnotes (if any) associated with the current node in - another window. You can have Info automatically display the - footnotes associated with a node when the node is selected by - setting the variable `automatic-footnotes'. *Note - `automatic-footnotes': Variables. - - -File: info-stnd.info, Node: Variables, Next: GNU Info Global Index, Prev: Miscellaneous Commands, Up: Top - -Manipulating Variables -********************** - -GNU Info contains several "variables" whose values are looked at by -various Info commands. You can change the values of these variables, -and thus change the behavior of Info to more closely match your -environment and Info file reading manner. - -`M-x set-variable' - Read the name of a variable, and the value for it, in the echo - area and then set the variable to that value. Completion is - available when reading the variable name; often, completion is - available when reading the value to give to the variable, but that - depends on the variable itself. If a variable does *not* supply - multiple choices to complete over, it expects a numeric value. - -`M-x describe-variable' - Read the name of a variable in the echo area and then display a - brief description of what the variable affects. - -Here is a list of the variables that you can set in Info. - -`automatic-footnotes' - When set to `On', footnotes appear and disappear automatically. - This variable is `On' by default. When a node is selected, a - window containing the footnotes which appear in that node is - created, and the footnotes are displayed within the new window. - The window that Info creates to contain the footnotes is called - `*Footnotes*'. If a node is selected which contains no footnotes, - and a `*Footnotes*' window is on the screen, the `*Footnotes*' - window is deleted. Footnote windows created in this fashion are - not automatically tiled so that they can use as little of the - display as is possible. - -`automatic-tiling' - When set to `On', creating or deleting a window resizes other - windows. This variable is `Off' by default. Normally, typing - `C-x 2' divides the current window into two equal parts. When - `automatic-tiling' is set to `On', all of the windows are resized - automatically, keeping an equal number of lines visible in each - window. There are exceptions to the automatic tiling; - specifically, the windows `*Completions*' and `*Footnotes*' are - *not* resized through automatic tiling; they remain their original - size. - -`visible-bell' - When set to `On', GNU Info attempts to flash the screen instead of - ringing the bell. This variable is `Off' by default. Of course, - Info can only flash the screen if the terminal allows it; in the - case that the terminal does not allow it, the setting of this - variable has no effect. However, you can make Info perform - quietly by setting the `errors-ring-bell' variable to `Off'. - -`errors-ring-bell' - When set to `On', errors cause the bell to ring. The default - setting of this variable is `On'. - -`gc-compressed-files' - When set to `On', Info garbage collects files which had to be - uncompressed. The default value of this variable is `Off'. - Whenever a node is visited in Info, the Info file containing that - node is read into core, and Info reads information about the tags - and nodes contained in that file. Once the tags information is - read by Info, it is never forgotten. However, the actual text of - the nodes does not need to remain in core unless a particular Info - window needs it. For non-compressed files, the text of the nodes - does not remain in core when it is no longer in use. But - de-compressing a file can be a time consuming operation, and so - Info tries hard not to do it twice. `gc-compressed-files' tells - Info it is okay to garbage collect the text of the nodes of a file - which was compressed on disk. - -`show-index-match' - When set to `On', the portion of the matched search string is - highlighted in the message which explains where the matched search - string was found. The default value of this variable is `On'. - When Info displays the location where an index match was found, - (*note `next-index-match': Searching Commands.), the portion of the - string that you had typed is highlighted by displaying it in the - inverse case from its surrounding characters. - -`scroll-behavior' - Control what happens when forward scrolling is requested at the - end of a node, or when backward scrolling is requested at the - beginning of a node. The default value for this variable is - `Continuous'. There are three possible values for this variable: - - `Continuous' - Try to get the first item in this node's menu, or failing - that, the `Next' node, or failing that, the `Next' of the - `Up'. This behavior is identical to using the `]' - (`global-next-node') and `[' (`global-prev-node') commands. - - `Next Only' - Only try to get the `Next' node. - - `Page Only' - Simply give up, changing nothing. If `scroll-behavior' is - `Page Only', no scrolling command can change the node that is - being viewed. - -`scroll-step' - The number of lines to scroll when the cursor moves out of the - window. Scrolling happens automatically if the cursor has moved - out of the visible portion of the node text when it is time to - display. Usually the scrolling is done so as to put the cursor on - the center line of the current window. However, if the variable - `scroll-step' has a nonzero value, Info attempts to scroll the - node text by that many lines; if that is enough to bring the - cursor back into the window, that is what is done. The default - value of this variable is 0, thus placing the cursor (and the text - it is attached to) in the center of the window. Setting this - variable to 1 causes a kind of "smooth scrolling" which some - people prefer. - -`ISO-Latin' - When set to `On', Info accepts and displays ISO Latin characters. - By default, Info assumes an ASCII character set. `ISO-Latin' tells - Info that it is running in an environment where the European - standard character set is in use, and allows you to input such - characters to Info, as well as display them. - - -File: info-stnd.info, Node: GNU Info Global Index, Prev: Variables, Up: Top - -Global Index -************ - -* Menu: - -* ,: Searching Commands. -* 0, in Info windows: Selecting Xrefs. -* 1 ... 9, in Info windows: Selecting Xrefs. -* 1 ... 9, in Info windows: Selecting Xrefs. -* <: Node Commands. -* >: Node Commands. -* ?, in Info windows: Miscellaneous Commands. -* ?, in the echo area: The Echo Area. -* -subnodes, command line option: Options. -* abort-key: Miscellaneous Commands. -* add-digit-to-numeric-arg: Miscellaneous Commands. -* arguments, command line: Options. -* automatic-footnotes: Variables. -* automatic-tiling: Variables. -* b, in Info windows: Cursor Commands. -* backward-char: Cursor Commands. -* backward-word: Cursor Commands. -* beginning-of-line: Cursor Commands. -* beginning-of-node: Cursor Commands. -* C-a, in Info windows: Cursor Commands. -* C-a, in the echo area: The Echo Area. -* C-b, in Info windows: Cursor Commands. -* C-b, in the echo area: The Echo Area. -* C-d, in the echo area: The Echo Area. -* C-e, in Info windows: Cursor Commands. -* C-e, in the echo area: The Echo Area. -* C-f, in Info windows: Cursor Commands. -* C-f, in the echo area: The Echo Area. -* C-g, in Info windows: Miscellaneous Commands. -* C-g, in the echo area: The Echo Area. -* C-h: Miscellaneous Commands. -* C-k, in the echo area: The Echo Area. -* C-l: Scrolling Commands. -* C-n: Cursor Commands. -* C-p: Cursor Commands. -* C-q, in the echo area: The Echo Area. -* C-r: Searching Commands. -* C-s: Searching Commands. -* C-t, in the echo area: The Echo Area. -* C-u: Miscellaneous Commands. -* C-v: Scrolling Commands. -* C-w: Scrolling Commands. -* C-x 0: Basic Windows. -* C-x 1: Basic Windows. -* C-x 2: Basic Windows. -* C-x b: Node Commands. -* C-x C-b: Node Commands. -* C-x C-f: Node Commands. -* C-x DEL, in the echo area: The Echo Area. -* C-x k: Node Commands. -* C-x o: Basic Windows. -* C-x t: Basic Windows. -* C-x ^: Basic Windows. -* C-y, in the echo area: The Echo Area. -* cancelling the current operation: Miscellaneous Commands. -* cancelling typeahead: Miscellaneous Commands. -* command line options: Options. -* commands, describing: Miscellaneous Commands. -* cursor, moving: Cursor Commands. -* d: Node Commands. -* DEL, in Info windows: Scrolling Commands. -* DEL, in the echo area: The Echo Area. -* delete-window: Basic Windows. -* describe-command: Miscellaneous Commands. -* describe-key: Miscellaneous Commands. -* describe-variable: Variables. -* dir-node: Node Commands. -* directory path: Options. -* echo area: The Echo Area. -* echo-area-abort: The Echo Area. -* echo-area-backward: The Echo Area. -* echo-area-backward-kill-line: The Echo Area. -* echo-area-backward-kill-word: The Echo Area. -* echo-area-backward-word: The Echo Area. -* echo-area-beg-of-line: The Echo Area. -* echo-area-complete: The Echo Area. -* echo-area-delete: The Echo Area. -* echo-area-end-of-line: The Echo Area. -* echo-area-forward: The Echo Area. -* echo-area-forward-word: The Echo Area. -* echo-area-insert: The Echo Area. -* echo-area-kill-line: The Echo Area. -* echo-area-kill-word: The Echo Area. -* echo-area-newline: The Echo Area. -* echo-area-possible-completions: The Echo Area. -* echo-area-quoted-insert: The Echo Area. -* echo-area-rubout: The Echo Area. -* echo-area-scroll-completions-window: The Echo Area. -* echo-area-tab-insert: The Echo Area. -* echo-area-transpose-chars: The Echo Area. -* echo-area-yank: The Echo Area. -* echo-area-yank-pop: The Echo Area. -* end-of-line: Cursor Commands. -* end-of-node: Cursor Commands. -* errors-ring-bell: Variables. -* ESC C-f: Miscellaneous Commands. -* ESC C-v, in Info windows: Basic Windows. -* ESC C-v, in the echo area: The Echo Area. -* f: Selecting Xrefs. -* file, outputting to: Options. -* find-menu: Selecting Xrefs. -* first-node: Node Commands. -* footnotes, displaying: Miscellaneous Commands. -* forward-char: Cursor Commands. -* forward-word: Cursor Commands. -* functions, describing: Miscellaneous Commands. -* g: Node Commands. -* gc-compressed-files: Variables. -* get-help-window: Miscellaneous Commands. -* get-info-help-node: Miscellaneous Commands. -* global-next-node: Node Commands. -* global-prev-node: Node Commands. -* goto-node: Node Commands. -* grow-window: Basic Windows. -* h: Miscellaneous Commands. -* history-node: Node Commands. -* i: Searching Commands. -* index-search: Searching Commands. -* Info file, selecting: Options. -* INFO_PRINT_COMMAND, environment variable: Printing Nodes. -* isearch-backward: Searching Commands. -* isearch-forward: Searching Commands. -* ISO Latin characters: Variables. -* ISO-Latin: Variables. -* keep-one-window: Basic Windows. -* keys, describing: Miscellaneous Commands. -* kill-node: Node Commands. -* l: Node Commands. -* last-menu-item: Selecting Xrefs. -* last-node: Node Commands. -* list-visited-nodes: Node Commands. -* m: Selecting Xrefs. -* M-1 ... M-9: Miscellaneous Commands. -* M-<: Cursor Commands. -* M->: Cursor Commands. -* M-b, in Info windows: Cursor Commands. -* M-b, in the echo area: The Echo Area. -* M-d, in the echo area: The Echo Area. -* M-DEL, in the echo area: The Echo Area. -* M-f, in Info windows: Cursor Commands. -* M-f, in the echo area: The Echo Area. -* M-r: Cursor Commands. -* M-TAB, in Info windows: Selecting Xrefs. -* M-TAB, in the echo area: The Echo Area. -* M-v: Scrolling Commands. -* M-y, in the echo area: The Echo Area. -* menu, following: Options. -* menu-digit: Selecting Xrefs. -* menu-item: Selecting Xrefs. -* move-to-next-xref: Selecting Xrefs. -* move-to-prev-xref: Selecting Xrefs. -* move-to-window-line: Cursor Commands. -* n: Node Commands. -* next-index-match: Searching Commands. -* next-line: Cursor Commands. -* next-node: Node Commands. -* next-window: Basic Windows. -* node, selecting: Options. -* nodes, selection of: Node Commands. -* numeric arguments: Miscellaneous Commands. -* outputting to a file: Options. -* p: Node Commands. -* prev-line: Cursor Commands. -* prev-node: Node Commands. -* prev-window: Basic Windows. -* print-node: Printing Nodes. -* printing: Printing Nodes. -* printing characters, in the echo area: The Echo Area. -* q: Miscellaneous Commands. -* quit: Miscellaneous Commands. -* quitting: Miscellaneous Commands. -* r: Selecting Xrefs. -* redraw-display: Scrolling Commands. -* RET, in Info windows: Selecting Xrefs. -* RET, in the echo area: The Echo Area. -* s: Searching Commands. -* screen, changing the height of: Miscellaneous Commands. -* scroll-backward: Scrolling Commands. -* scroll-behavior: Variables. -* scroll-forward: Scrolling Commands. -* scroll-other-window: Basic Windows. -* scroll-step: Variables. -* scrolling: Scrolling Commands. -* scrolling through node structure: Scrolling Commands. -* search: Searching Commands. -* searching: Searching Commands. -* select-reference-this-line: Selecting Xrefs. -* select-visited-node: Node Commands. -* set-screen-height: Miscellaneous Commands. -* set-variable: Variables. -* show-footnotes: Miscellaneous Commands. -* show-index-match: Variables. -* SPC, in Info windows: Scrolling Commands. -* SPC, in the echo area: The Echo Area. -* split-window: Basic Windows. -* t: Node Commands. -* TAB, in Info windows: Selecting Xrefs. -* TAB, in the echo area: The Echo Area. -* tile-windows: Basic Windows. -* tiling: Basic Windows. -* toggle-wrap: Scrolling Commands. -* top-node: Node Commands. -* u: Node Commands. -* universal-argument: Miscellaneous Commands. -* up-node: Node Commands. -* variables, describing: Variables. -* variables, setting: Variables. -* version information: Options. -* view-file: Node Commands. -* visible-bell: Variables. -* where-is: Miscellaneous Commands. -* windows, creating: Basic Windows. -* windows, deleting: Basic Windows. -* windows, manipulating: Window Commands. -* windows, selecting: Basic Windows. -* xref-item: Selecting Xrefs. -* [: Node Commands. -* ]: Node Commands. - - - -Tag Table: -Node: Top1263 -Node: What is Info2593 -Node: Options3127 -Node: Options-Footnotes6157 -Node: Cursor Commands6411 -Node: Cursor Commands-Footnotes8906 -Node: Scrolling Commands9136 -Node: Node Commands11600 -Node: Searching Commands15563 -Node: Xref Commands17151 -Node: Parts of an Xref17766 -Node: Selecting Xrefs19711 -Node: Window Commands21298 -Node: The Mode Line22233 -Node: Basic Windows23872 -Node: The Echo Area26374 -Node: Printing Nodes30531 -Node: Miscellaneous Commands31174 -Node: Variables34345 -Node: GNU Info Global Index40515 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/info-files/info.info b/gnu/usr.bin/texinfo/info-files/info.info deleted file mode 100644 index b6fd8508b832..000000000000 --- a/gnu/usr.bin/texinfo/info-files/info.info +++ /dev/null @@ -1,777 +0,0 @@ -This is Info file info.info, produced by Makeinfo-1.55 from the input -file info.texi. - - This file describes how to use Info, the on-line, menu-driven GNU -documentation system. - - Copyright (C) 1989, 1992 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: info.info, Node: Top, Next: Getting Started, Prev: (dir), Up: (dir) - -Info: An Introduction -********************* - - Info is a program for reading documentation, which you are using now. - - To learn how to use Info, type the command `h'. It brings you to a -programmed instruction sequence. - - To learn advanced Info commands, type `n' twice. This brings you to -`Info for Experts', skipping over the . `Getting Started' chapter. - -* Menu: - -* Getting Started:: -* Advanced Info:: -* Create an Info File:: - - -File: info.info, Node: Getting Started, Next: Advanced Info, Prev: Top, Up: Top - -Getting Started -*************** - - This first part of the Info manual describes how to get around inside -of Info. The second part of the manual describes various advanced Info -commands, and how to write an Info as distinct from a Texinfo file. -The third part is about how to generate Info files from Texinfo files. - -* Menu: - -* Help-Small-Screen:: Starting Info on a Small Screen -* Help:: How to use Info -* Help-P:: Returning to the Previous node -* Help-^L:: The Space, Rubout, B and ^L commands. -* Help-M:: Menus -* Help-Adv:: Some advanced Info commands -* Help-Q:: Quitting Info - - -File: info.info, Node: Help-Small-Screen, Next: Help, Up: Getting Started - -Starting Info on a Small Screen -=============================== - - Since your terminal has an unusually small number of lines on its -screen, it is necessary to give you special advice at the beginning. - - If you see the text `--All----' at near the bottom right corner of -the screen, it means the entire text you are looking at fits on the -screen. If you see `--Top----' instead, it means that there is more -text below that does not fit. To move forward through the text and see -another screen full, press the Space bar, SPC. To move back up, press -the key labeled `Rubout' or `Delete' or DEL. - - Here are 40 lines of junk, so you can try SPC and DEL and see what -they do. At the end are instructions of what you should do next. - - This is line 17 -This is line 18 -This is line 19 -This is line 20 -This is line 21 -This is line 22 -This is line 23 -This is line 24 -This is line 25 -This is line 26 -This is line 27 -This is line 28 -This is line 29 -This is line 30 -This is line 31 -This is line 32 -This is line 33 -This is line 34 -This is line 35 -This is line 36 -This is line 37 -This is line 38 -This is line 39 -This is line 40 -This is line 41 -This is line 42 -This is line 43 -This is line 44 -This is line 45 -This is line 46 -This is line 47 -This is line 48 -This is line 49 -This is line 50 -This is line 51 -This is line 52 -This is line 53 -This is line 54 -This is line 55 -This is line 56 -If you have managed to get here, go back to the beginning with DEL, and -come back here again, then you understand SPC and DEL. So now type an -`n'--just one character; do not type the quotes and do not type the -Return key, RET, afterward--to get to the normal start of the course. - - -File: info.info, Node: Help, Next: Help-P, Prev: Help-Small-Screen, Up: Getting Started - -How to use Info -=============== - - You are talking to the program Info, for reading documentation. - - Right now you are looking at one "Node" of Information. A node -contains text describing a specific topic at a specific level of -detail. This node's topic is "how to use Info". - - The top line of a node is its "header". This node's header (look at -it now) says that it is the node named `Help' in the file `info'. It -says that the `Next' node after this one is the node called `Help-P'. -An advanced Info command lets you go to any node whose name you know. - - Besides a `Next', a node can have a `Previous' or an `Up'. This -node has a `Previous' but no `Up', as you can see. - - Now it is time to move on to the `Next' node, named `Help-P'. - - >> Type `n' to move there. Type just one character; do not type -the quotes and do not type a RET afterward. - - `>>' in the margin means it is really time to try a command. - - -File: info.info, Node: Help-P, Next: Help-^L, Prev: Help, Up: Getting Started - -Returning to the Previous node -============================== - - This node is called `Help-P'. The `Previous' node, as you see, is -`Help', which is the one you just came from using the `n' command. -Another `n' command now would take you to the next node, `Help-^L'. - - >> But do not do that yet. First, try the `p' command, which takes - you to the `Previous' node. When you get there, you can do an `n' -again to return here. - - This all probably seems insultingly simple so far, but *do not* be -led into skimming. Things will get more complicated soon. Also, do -not try a new command until you are told it is time to. Otherwise, you -may make Info skip past an important warning that was coming up. - - >> Now do an `n' to get to the node `Help-^L' and learn more. - - -File: info.info, Node: Help-^L, Next: Help-M, Prev: Help-P, Up: Getting Started - -The Space, Rubout, B and ^L commands. -===================================== - - This node's header tells you that you are now at node `Help-^L', and -that `p' would get you back to `Help-P'. The node's title is -underlined; it says what the node is about (most nodes have titles). - - This is a big node and it does not all fit on your display screen. -You can tell that there is more that is not visible because you can see -the string `--Top-----' rather than `--All----' near the bottom right -corner of the screen. - - The SPC, DEL and `b' commands exist to allow you to "move around" in -a node that does not all fit on the screen at once. SPC moves forward, -to show what was below the bottom of the screen. DEL moves backward, -to show what was above the top of the screen (there is not anything -above the top until you have typed some spaces). - - >> Now try typing a SPC (afterward, type a DEL to return here). - - When you type the SPC, the two lines that were at the bottom of the -screen appear at the top, followed by more lines. DEL takes the two -lines from the top and moves them to the bottom, *usually*, but if -there are not a full screen's worth of lines above them they may not -make it all the way to the bottom. - - If you type a SPC when there is no more to see, it rings the bell -and otherwise does nothing. The same goes for a DEL when the header of -the node is visible. - - If your screen is ever garbaged, you can tell Info to print it out -again by typing `C-l' (`Control-L', that is--hold down "Control" and -type an L or `l'). - - >> Type `C-l' now. - - To move back to the beginning of the node you are on, you can type a -lot of DELs. You can also type simply `b' for beginning. - - >> Try that now. (I have put in enough verbiage to make sure you are - not on the first screenful now). Then come back, typing SPC -several times. - - You have just learned a considerable number of commands. If you -want to use one but have trouble remembering which, you should type a ? -which prints out a brief list of commands. When you are finished -looking at the list, make it go away by typing a SPC. - - >> Type a ? now. After it finishes, type a SPC. - - (If you are using the standalone Info reader, type `l' to return -here.) - - From now on, you will encounter large nodes without warning, and -will be expected to know how to use SPC and DEL to move around in them -without being told. Since not all terminals have the same size screen, -it would be impossible to warn you anyway. - - >> Now type `n' to see the description of the `m' command. - - -File: info.info, Node: Help-M, Next: Help-Adv, Prev: Help-^L, Up: Getting Started - -Menus -===== - - Menus and the `m' command - - With only the `n' and `p' commands for moving between nodes, nodes -are restricted to a linear sequence. Menus allow a branching -structure. A menu is a list of other nodes you can move to. It is -actually just part of the text of the node formatted specially so that -Info can interpret it. The beginning of a menu is always identified by -a line which starts with `* Menu:'. A node contains a menu if and only -if it has a line in it which starts that way. The only menu you can -use at any moment is the one in the node you are in. To use a menu in -any other node, you must move to that node first. - - After the start of the menu, each line that starts with a `*' -identifies one subtopic. The line usually contains a brief name for -the subtopic (followed by a `:'), the name of the node that talks about -that subtopic, and optionally some further description of the subtopic. -Lines in the menu that do not start with a `*' have no special -meaning--they are only for the human reader's benefit and do not define -additional subtopics. Here is an example: - - * Foo: FOO's Node This tells about FOO - - The subtopic name is Foo, and the node describing it is `FOO's Node'. -The rest of the line is just for the reader's Information. [[ But this -line is not a real menu item, simply because there is no line above it -which starts with `* Menu:'.]] - - When you use a menu to go to another node (in a way that will be -described soon), what you specify is the subtopic name, the first thing -in the menu line. Info uses it to find the menu line, extracts the -node name from it, and goes to that node. The reason that there is -both a subtopic name and a node name is that the node name must be -meaningful to the computer and may therefore have to be ugly looking. -The subtopic name can be chosen just to be convenient for the user to -specify. Often the node name is convenient for the user to specify and -so both it and the subtopic name are the same. There is an -abbreviation for this: - - * Foo:: This tells about FOO - -This means that the subtopic name and node name are the same; they are -both `Foo'. - - >> Now use SPCs to find the menu in this node, then come back to -the front with a `b'. As you see, a menu is actually visible in its -node. If you cannot find a menu in a node by looking at it, then -the node does not have a menu and the `m' command is not available. - - The command to go to one of the subnodes is `m'--but *do not do it -yet!* Before you use `m', you must understand the difference between -commands and arguments. So far, you have learned several commands that -do not need arguments. When you type one, Info processes it and is -instantly ready for another command. The `m' command is different: it -is incomplete without the "name of the subtopic". Once you have typed -`m', Info tries to read the subtopic name. - - Now look for the line containing many dashes near the bottom of the -screen. There is one more line beneath that one, but usually it is -blank If it is empty, Info is ready for a command, such as `n' or `b' -or SPC or `m'. If that line contains text ending in a colon, it mean -Info is trying to read the "argument" to a command. At such times, -commands do not work, because Info tries to use them as the argument. -You must either type the argument and finish the command you started, -or type `Control-g' to cancel the command. When you have done one of -those things, the line becomes blank again. - - The command to go to a subnode via a menu is `m'. After you type -the `m', the line at the bottom of the screen says `Menu item: '. You -must then type the name of the subtopic you want, and end it with a RET. - - You can abbreviate the subtopic name. If the abbreviation is not -unique, the first matching subtopic is chosen. Some menus put the -shortest possible abbreviation for each subtopic name in capital -letters, so you can see how much you need to type. It does not matter -whether you use upper case or lower case when you type the subtopic. -You should not put any spaces at the end, or inside of the item name, -except for one space where a space appears in the item in the menu. - - Here is a menu to give you a chance to practice. - - * Menu: The menu starts here. - - This menu givs you three ways of going to one place, Help-FOO. - - * Foo: Help-FOO. A node you can visit for fun. -* Bar: Help-FOO. Strange! two ways to get to the same place. -* Help-FOO:: And yet another! ->> Now type just an `m' and see what happens: - - Now you are "inside" an `m' command. Commands cannot be used now; -the next thing you will type must be the name of a subtopic. - - You can change your mind about doing the `m' by typing Control-g. - - >> Try that now; notice the bottom line clear. - - >> Then type another `m'. - - >> Now type `BAR' item name. Do not type RET yet. - - While you are typing the item name, you can use the DEL character to -cancel one character at a time if you make a mistake. - - >> Type one to cancel the `R'. You could type another `R' to -replace it. You do not have to, since `BA' is a valid abbreviation. - - >> Now you are ready to go. Type a RET. - - After visiting Help-FOO, you should return here. - - >> Type `n' to see more commands. - - Here is another way to get to Help-FOO, a menu. You can ignore this -if you want, or else try it (but then please come back to here). - -* Menu: - -* Help-FOO:: - - -File: info.info, Node: Help-FOO, Up: Help-M - -The `u' command ---------------- - - Congratulations! This is the node `Help-FOO'. Unlike the other -nodes you have seen, this one has an `Up': `Help-M', the node you just -came from via the `m' command. This is the usual convention--the nodes -you reach from a menu have `Up' nodes that lead back to the menu. -Menus move Down in the tree, and `Up' moves Up. `Previous', on the -other hand, is usually used to "stay on the same level but go backwards" - - You can go back to the node `Help-M' by typing the command `u' for -"Up". That puts you at the *front* of the node--to get back to where -you were reading you have to type some SPCs. - - >> Now type `u' to move back up to `Help-M'. - - -File: info.info, Node: Help-Adv, Next: Help-Q, Prev: Help-M, Up: Getting Started - -Some advanced Info commands -=========================== - - The course is almost over, so please stick with it to the end. - - If you have been moving around to different nodes and wish to -retrace your steps, the `l' command (`l' for "last") will do that, one -node at a time. If you have been following directions, an `l' command -now will get you back to `Help-M'. Another `l' command would undo the -`u' and get you back to `Help-FOO'. Another `l' would undo the `m' and -get you back to `Help-M'. - - >> Try typing three `l''s, pausing in between to see what each -`l' does. - - Then follow directions again and you will end up back here. - - Note the difference between `l' and `p': `l' moves to where *you* -last were, whereas `p' always moves to the node which the header says -is the `Previous' node (from this node, to `Help-M'). - - The `d' command gets you instantly to the Directory node. This -node, which is the first one you saw when you entered Info, has a menu -which leads (directly, or indirectly through other menus), to all the -nodes that exist. - - >> Try doing a `d', then do an `l' to return here (yes, *do* -return). - - Sometimes, in Info documentation, you will see a cross reference. -Cross references look like this: *Note Cross: Help-Cross. That is a -real, live cross reference which is named `Cross' and points at the -node named `Help-Cross'. - - If you wish to follow a cross reference, you must use the `f' -command. The `f' must be followed by the cross reference name (in this -case, `Cross'). You can use DEL to edit the name, and if you change -your mind about following any reference you can use `Control-g' to -cancel the command. - - Completion is available in the `f' command; you can complete among -all the cross reference names in the current node. - - >> Type `f', followed by `Cross', and a RET. - - To get a list of all the cross references in the current node, you -can type `?' after an `f'. The `f' continues to await a cross -reference name even after printing the list, so if you do not actually -want to follow a reference you should type a `Control-g' to cancel the -`f'. - - >> Type "f?" to get a list of the footnotes in this node. Then type -a `Control-g' and see how the `f' gives up. - - >> Now type `n' to see the last node of the course. - - -File: info.info, Node: Help-Cross, Up: Help-Adv - -The node reached by the cross reference in Info ------------------------------------------------ - - This is the node reached by the cross reference named `Cross'. - - While this node is specifically intended to be reached by a cross -reference, most cross references lead to nodes that "belong" someplace -else far away in the structure of Info. So you cannot expect the -footnote to have a `Next', `Previous' or `Up' pointing back to where -you came from. In general, the `l' (el) command is the only way to get -back there. - - >> Type `l' to return to the node where the cross reference was. - - -File: info.info, Node: Help-Q, Prev: Help-Adv, Up: Getting Started - -Quitting Info -============= - - To get out of Info, back to what you were doing before, type `q' for -"Quit". - - This is the end of the course on using Info. There are some other -commands that are not essential or are meant for experienced users; -they are useful, and you can find them by looking in the directory for -documentation on Info. Finding them will be a good exercise in using -Info in the usual manner. - - >> Type `d' to go to the Info directory node; then type `mInfo' -and RET, to get to the node about Info and see what other help is -available. - - -File: info.info, Node: Advanced Info, Next: Create an Info File, Prev: Getting Started, Up: Top - -Info for Experts -**************** - - This chapter describes various advanced Info commands, and how to -write an Info as distinct from a Texinfo file. (However, in most -cases, writing a Texinfo file is better, since you can use it *both* to -generate an Info file and to make a printed manual. *Note Overview of -Texinfo: (texinfo)Top.) - -* Menu: - -* Expert:: Advanced Info commands: g, s, e, and 1 - 5. -* Add:: Describes how to add new nodes to the hierarchy. - Also tells what nodes look like. -* Menus:: How to add to or create menus in Info nodes. -* Cross-refs:: How to add cross-references to Info nodes. -* Tags:: How to make tag tables for Info files. -* Checking:: Checking an Info File - - -File: info.info, Node: Expert, Next: Add, Up: Advanced Info - -Advanced Info Commands -====================== - - `g', `s', `1', - `5', and `e' - - If you know a node's name, you can go there by typing `g', the name, -and RET. Thus, `gTopRET' would go to the node called `Top' in this -file (its directory node). `gExpertRET' would come back here. - - Unlike `m', `g' does not allow the use of abbreviations. - - To go to a node in another file, you can include the filename in the -node name by putting it at the front, in parentheses. Thus, -`g(dir)TopRET' would go to the Info Directory node, which is node `Top' -in the file `dir'. - - The node name `*' specifies the whole file. So you can look at all -of the current file by typing `g*RET' or all of any other file with -`g(FILENAME)RET'. - - The `s' command allows you to search a whole file for a string. It -switches to the next node if and when that is necessary. You type `s' -followed by the string to search for, terminated by RET. To search for -the same string again, just `s' followed by RET will do. The file's -nodes are scanned in the order they are in in the file, which has no -necessary relationship to the order that they may be in in the tree -structure of menus and `next' pointers. But normally the two orders -are not very different. In any case, you can always do a `b' to find -out what node you have reached, if the header is not visible (this can -happen, because `s' puts your cursor at the occurrence of the string, -not at the beginning of the node). - - If you grudge the system each character of type-in it requires, you -might like to use the commands `1', `2', `3', `4', and `5'. They are -short for the `m' command together with an argument. "1", "2", "3", -"4", and "5". `1' goes through the first item in the current node's -menu; `2' goes through the second item, etc. Note that numbers larger -than 5 are not allowed. If the item you want is that far down, you are -better off using an abbreviation for its name than counting. - - The Info command `e' changes from Info mode to an ordinary Emacs -editing mode, so that you can edit the text of the current node. Type -`C-c C-c' to switch back to Info. The `e' command is allowed only if -the variable `Info-enable-edit' is non-`nil'. - - -File: info.info, Node: Add, Next: Menus, Prev: Expert, Up: Advanced Info - -Adding a new node to Info -========================= - - To add a new topic to the list in the directory, you must: - - 1. Create a node, in some file, to document that topic. - - 2. Put that topic in the menu in the directory. *Note Menu: Menus. - - The new node can live in an existing documentation file, or in a new -one. It must have a ^_ character before it (invisible to the user; -this node has one but you cannot see it), and it ends with either a ^_, -a ^L, or the end of file. Note: If you put in a ^L to end a new node, -be sure that there is a ^_ after it to start the next one, since ^L -cannot *start* a node. Also, a nicer way to make a node boundary be a -page boundary as well is to put a ^L *right after* the ^_. - - The ^_ starting a node must be followed by a newline or a ^L -newline, after which comes the node's header line. The header line -must give the node's name (by which Info finds it), and state the names -of the `Next', `Previous', and `Up' nodes (if there are any). As you -can see, this node's `Up' node is the node `Top', which points at all -the documentation for Info. The `Next' node is `Menus'. - - The keywords "Node", "Previous", "Up" and "Next", may appear in any -order, anywhere in the header line, but the recommended order is the -one in this sentence. Each keyword must be followed by a colon, spaces -and tabs, and then the appropriate name. The name may be terminated -with a tab, a comma, or a newline. A space does not end it; node names -may contain spaces. The case of letters in the names is insignificant. - - A node name has two forms. A node in the current file is named by -what appears after the `Node: ' in that node's first line. For -example, this node's name is `Add'. A node in another file is named by -`(FILENAME)NODE-WITHIN-FILE', as in `(info)Add' for this node. If the -file name is relative, it is taken starting from the standard Info file -directory of your site. The name `(FILENAME)Top' can be abbreviated to -just `(FILENAME)'. By convention, the name `Top' is used for the -"highest" node in any single file--the node whose `Up' points out of -the file. The Directory node is `(dir)'. The `Top' node of a document -file listed in the Directory should have an `Up: (dir)' in it. - - The node name `*' is special: it refers to the entire file. Thus, -`g*' shows you the whole current file. The use of the node `*' is to -make it possible to make old-fashioned, unstructured files into nodes -of the tree. - - The `Node:' name, in which a node states its own name, must not -contain a filename, since Info when searching for a node does not -expect one to be there. The `Next', `Previous' and `Up' names may -contain them. In this node, since the `Up' node is in the same file, -it was not necessary to use one. - - Note that the nodes in this file have a file name in the header -line. The file names are ignored by Info, but they serve as comments -to help identify the node for the user. - - -File: info.info, Node: Menus, Next: Cross-refs, Prev: Add, Up: Advanced Info - -How to Create Menus -=================== - - Any node in the Info hierarchy may have a "menu"--a list of subnodes. -The `m' command searches the current node's menu for the topic which it -reads from the terminal. - - A menu begins with a line starting with `* Menu:'. The rest of the -line is a comment. After the starting line, every line that begins -with a `* ' lists a single topic. The name of the topic-the argument -that the user must give to the `m' command to select this topic--comes -right after the star and space, and is followed by a colon, spaces and -tabs, and the name of the node which discusses that topic. The node -name, like node names following `Next', `Previous' and `Up', may be -terminated with a tab, comma, or newline; it may also be terminated -with a period. - - If the node name and topic name are the same, than rather than -giving the name twice, the abbreviation `* NAME::' may be used (and -should be used, whenever possible, as it reduces the visual clutter in -the menu). - - It is considerate to choose the topic names so that they differ from -each other very near the beginning--this allows the user to type short -abbreviations. In a long menu, it is a good idea to capitalize the -beginning of each item name which is the minimum acceptable -abbreviation for it (a long menu is more than 5 or so entries). - - The nodes listed in a node's menu are called its "subnodes", and it -is their "superior". They should each have an `Up:' pointing at the -superior. It is often useful to arrange all or most of the subnodes in -a sequence of `Next' and `Previous' pointers so that someone who wants -to see them all need not keep revisiting the Menu. - - The Info Directory is simply the menu of the node `(dir)Top'--that -is, node `Top' in file `.../info/dir'. You can put new entries in that -menu just like any other menu. The Info Directory is *not* the same as -the file directory called `info'. It happens that many of Info's files -live on that file directory, but they do not have to; and files on that -directory are not automatically listed in the Info Directory node. - - Also, although the Info node graph is claimed to be a "hierarchy", -in fact it can be *any* directed graph. Shared structures and pointer -cycles are perfectly possible, and can be used if they are appropriate -to the meaning to be expressed. There is no need for all the nodes in -a file to form a connected structure. In fact, this file has two -connected components. You are in one of them, which is under the node -`Top'; the other contains the node `Help' which the `h' command goes -to. In fact, since there is no garbage collector, nothing terrible -happens if a substructure is not pointed to, but such a substructure is -rather useless since nobody can ever find out that it exists. - - -File: info.info, Node: Cross-refs, Next: Tags, Prev: Menus, Up: Advanced Info - -Creating Cross References -========================= - - A cross reference can be placed anywhere in the text, unlike a menu -item which must go at the front of a line. A cross reference looks -like a menu item except that it has `*note' instead of `*'. It -*cannot* be terminated by a `)', because `)''s are so often part of -node names. If you wish to enclose a cross reference in parentheses, -terminate it with a period first. Here are two examples of cross -references pointers: - - *Note details: commands. (See *note 3: Full Proof.) - - They are just examples. The places they "lead to" do not really -exist! - - -File: info.info, Node: Tags, Next: Checking, Prev: Cross-refs, Up: Advanced Info - -Tag Tables for Info Files -========================= - - You can speed up the access to nodes of a large Info file by giving -it a tag table. Unlike the tag table for a program, the tag table for -an Info file lives inside the file itself and is used automatically -whenever Info reads in the file. - - To make a tag table, go to a node in the file using Emacs Info mode -and type `M-x Info-tagify'. Then you must use `C-x C-s' to save the -file. - - Once the Info file has a tag table, you must make certain it is up -to date. If, as a result of deletion of text, any node moves back more -than a thousand characters in the file from the position recorded in -the tag table, Info will no longer be able to find that node. To -update the tag table, use the `Info-tagify' command again. - - An Info file tag table appears at the end of the file and looks like -this: - - ^_ - Tag Table: - File: info, Node: Cross-refs^?21419 - File: info, Node: Tags^?22145 - ^_ - End Tag Table - -Note that it contains one line per node, and this line contains the -beginning of the node's header (ending just after the node name), a DEL -character, and the character position in the file of the beginning of -the node. - - -File: info.info, Node: Checking, Prev: Tags, Up: Advanced Info - -Checking an Info File -===================== - - When creating an Info file, it is easy to forget the name of a node -when you are making a pointer to it from another node. If you put in -the wrong name for a node, this is not detected until someone tries to -go through the pointer using Info. Verification of the Info file is an -automatic process which checks all pointers to nodes and reports any -pointers which are invalid. Every `Next', `Previous', and `Up' is -checked, as is every menu item and every cross reference. In addition, -any `Next' which does not have a `Previous' pointing back is reported. -Only pointers within the file are checked, because checking pointers to -other files would be terribly slow. But those are usually few. - - To check an Info file, do `M-x Info-validate' while looking at any -node of the file with Emacs Info mode. - - -File: info.info, Node: Create an Info File, Prev: Advanced Info, Up: Top - -Creating an Info File from a Makeinfo file -****************************************** - - `makeinfo' is a utility that converts a Texinfo file into an Info -file; `texinfo-format-region' and `texinfo-format-buffer' are GNU Emacs -functions that do the same. - - *Note Creating an Info File: (texinfo)Create an Info File, to learn -how to create an Info file from a Texinfo file. - - *Note Overview of Texinfo: (texinfo)Top, to learn how to write a -Texinfo file. - - - -Tag Table: -Node: Top913 -Node: Getting Started1431 -Node: Help-Small-Screen2179 -Node: Help3921 -Node: Help-P4949 -Node: Help-^L5811 -Node: Help-M8462 -Node: Help-FOO14030 -Node: Help-Adv14766 -Node: Help-Cross17148 -Node: Help-Q17794 -Node: Advanced Info18434 -Node: Expert19330 -Node: Add21601 -Node: Menus24635 -Node: Cross-refs27509 -Node: Tags28211 -Node: Checking29510 -Node: Create an Info File30434 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/info-files/makeinfo.info b/gnu/usr.bin/texinfo/info-files/makeinfo.info deleted file mode 100644 index 81dbe14a40fd..000000000000 --- a/gnu/usr.bin/texinfo/info-files/makeinfo.info +++ /dev/null @@ -1,224 +0,0 @@ -This is Info file makeinfo.info, produced by Makeinfo-1.55 from the -input file makeinfo.texi. - -This file is an extract from the `Texinfo' manual. -It documents `makeinfo', a program that converts Texinfo files into -Info files. - -Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. - - -File: makeinfo.info, Node: Top, Next: What is makeinfo, Prev: (dir), Up: (dir) - -`makeinfo' -********** - -This file documents the use of the `makeinfo' program, versions 1.51 -and later. It is an extract from the `Texinfo' manual. - -* Menu: - -* What is makeinfo:: - - -File: makeinfo.info, Node: What is makeinfo, Prev: Top, Up: Top - -What is `makeinfo'? -******************* - -`makeinfo' is a program for converting "Texinfo" files into "Info" -files. Texinfo is a documentation system that uses a single source -file to produce both on-line information and printed output. - -You can read the on-line information using Info; type `info' to learn -about Info. *Note Texinfo: (texinfo.texi)Top, to learn about the -Texinfo documentation system. - -* Menu: - -* Formatting Control:: -* Options:: -* Pointer Validation:: - - -File: makeinfo.info, Node: Formatting Control, Next: Options, Up: What is makeinfo - -Controlling Paragraph Formats -============================= - -In general, `makeinfo' "fills" the paragraphs that it outputs to an -Info file. Filling is the process of breaking and connecting lines so -that lines are the same length as or shorter than the number specified -as the fill column. Lines are broken between words. With `makeinfo', -you can control: - - * The width of each paragraph (the "fill-column"). - - * The amount of indentation that the first line of each paragraph - receives (the "paragraph-indentation"). - - -File: makeinfo.info, Node: Options, Next: Pointer Validation, Prev: Formatting Control, Up: What is makeinfo - -Command Line Options -==================== - -The following command line options are available for `makeinfo'. - -`-D VAR' - Cause VAR to be defined. This is equivalent to `@set VAR' in the - Texinfo file. - -`--error-limit LIMIT' - Set the maximum number of errors that `makeinfo' will report - before exiting (on the assumption that continuing would be - useless). The default number of errors that can be reported before - `makeinfo' gives up is 100. - -`--fill-column WIDTH' - Specify the maximum number of columns in a line; this is the - right-hand edge of a line. Paragraphs that are filled will be - filled to this width. The default value for `fill-column' is 72. - -`--footnote-style STYLE' - Set the footnote style to STYLE, either `end' for the end node - style or `separate' for the separate node style. The value set by - this option overrides the value set in a Texinfo file by an - `@footnotestyle' command. When the footnote style is `separate', - `makeinfo' makes a new node containing the footnotes found in the - current node. When the footnote style is `end', `makeinfo' places - the footnote references at the end of the current node. - -`-I DIR' - Add `dir' to the directory search list for finding files that are - included using the `@include' command. By default, `makeinfo' - searches only the current directory. - -`--no-headers' - Do not include menus or node lines in the output. This results in - an ASCII file that you cannot read in Info since it does not - contain the requisite nodes or menus; but you can print such a - file in a single, typewriter-like font and produce acceptable - output. - -`--no-split' - Suppress the splitting stage of `makeinfo'. Normally, large - output files (where the size is greater than 70k bytes) are split - into smaller subfiles, each one approximately 50k bytes. If you - specify `--no-split', `makeinfo' will not split up the output file. - -`--no-pointer-validate' -`--no-validate' - Suppress the pointer-validation phase of `makeinfo'. Normally, - after a Texinfo file is processed, some consistency checks are - made to ensure that cross references can be resolved, etc. *Note - Pointer Validation::. - -`--no-warn' - Suppress the output of warning messages. This does *not* suppress - the output of error messages, only warnings. You might want this - if the file you are creating has examples of Texinfo cross - references within it, and the nodes that are referenced do not - actually exist. - -`--no-number-footnotes' - Supress automatic footnote numbering. By default, `makeinfo' - numbers each footnote sequentially in a single node, resetting the - current footnote number to 1 at the start of each node. - -`--output FILE' -`-o FILE' - Specify that the output should be directed to FILE and not to the - file name specified in the `@setfilename' command found in the - Texinfo source. FILE can be the special token `-', which specifies - standard output. - -`--paragraph-indent INDENT' - Set the paragraph indentation style to INDENT. The value set by - this option overrides the value set in a Texinfo file by an - `@paragraphindent' command. The value of INDENT is interpreted as - follows: - - * If the value of INDENT is `asis', do not change the existing - indentation at the starts of paragraphs. - - * If the value of INDENT is zero, delete any existing - indentation. - - * If the value of INDENT is greater than zero, indent each - paragraph by that number of spaces. - -`--reference-limit LIMIT' - Set the value of the number of references to a node that - `makeinfo' will make without reporting a warning. If a node has - more than this number of references in it, `makeinfo' will make the - references but also report a warning. - -`-U VAR' - Cause VAR to be undefined. This is equivalent to `@clear VAR' in - the Texinfo file. - -`--verbose' - Cause `makeinfo' to display messages saying what it is doing. - Normally, `makeinfo' only outputs messages if there are errors or - warnings. - -`--version' - Report the version number of this copy of `makeinfo'. - - -File: makeinfo.info, Node: Pointer Validation, Prev: Options, Up: What is makeinfo - -Pointer Validation -================== - -If you do not suppress pointer-validation (by using the -`--no-pointer-validation' option), `makeinfo' will check the validity -of the final Info file. Mostly, this means ensuring that nodes you -have referenced really exist. Here is a complete list of what is -checked: - - 1. If a `Next', `Previous', or `Up' node reference is a reference to a - node in the current file and is not an external reference such as - to `(dir)', then the referenced node must exist. - - 2. In every node, if the `Previous' node is different from the `Up' - node, then the `Previous' node must also be pointed to by a `Next' - node. - - 3. Every node except the `Top' node must have an `Up' pointer. - - 4. The node referenced by an `Up' pointer must contain a reference to - the current node in some manner other than through a `Next' - reference. This includes menu entries and cross references. - - 5. If the `Next' reference of a node is not the same as the `Next' - reference of the `Up' reference, then the node referenced by the - `Next' pointer must have a `Previous' pointer that points back to - the current node. This rule allows the last node in a section to - point to the first node of the next chapter. - - - -Tag Table: -Node: Top949 -Node: What is makeinfo1215 -Node: Formatting Control1758 -Node: Options2377 -Node: Pointer Validation6743 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/info-files/texi-files/info-stnd.texi b/gnu/usr.bin/texinfo/info-files/texi-files/info-stnd.texi deleted file mode 100644 index 286973b01334..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi-files/info-stnd.texi +++ /dev/null @@ -1,1359 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header -@setfilename info-stnd.info -@settitle GNU Info -@set InfoProgVer 2.9 -@paragraphindent none -@footnotestyle separate -@synindex vr cp -@synindex fn cp -@synindex ky cp -@comment %**end of header - -@ifinfo -This file documents GNU Info, a program for viewing the on-line formatted -versions of Texinfo files. This documentation is different from the -documentation for the Info reader that is part of GNU Emacs. If you do -not know how to use Info, but have a working Info reader, you should -read that documentation first. - -Copyright @copyright{} 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -sections entitled ``Copying'' and ``GNU General Public License'' are -included exactly as in the original, and provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. -@end ifinfo - -@titlepage -@title GNU Info User's Guide -@subtitle For GNU Info version @value{InfoProgVer} -@author Brian J. Fox (bfox@@ai.mit.edu) -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993 Free Software Foundation - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -sections entitled ``Copying'' and ``GNU General Public License'' are -included exactly as in the original, and provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. -@end titlepage - -@ifinfo -@node Top, What is Info, (dir), (dir) -@top The GNU Info Program - -This file documents GNU Info, a program for viewing the on-line -formatted versions of Texinfo files, version @value{InfoProgVer}. This -documentation is different from the documentation for the Info reader -that is part of GNU Emacs. -@end ifinfo - -@menu -* What is Info:: -* Options:: Options you can pass on the command line. -* Cursor Commands:: Commands which move the cursor within a node. -* Scrolling Commands:: Commands for moving the node around - in a window. -* Node Commands:: Commands for selecting a new node. -* Searching Commands:: Commands for searching an Info file. -* Xref Commands:: Commands for selecting cross references. -* Window Commands:: Commands which manipulate multiple windows. -* Printing Nodes:: How to print out the contents of a node. -* Miscellaneous Commands:: A few commands that defy categories. -* Variables:: How to change the default behavior of Info. -* GNU Info Global Index:: Global index containing keystrokes, - command names, variable names, - and general concepts. -@end menu - -@node What is Info, Options, Top, Top -@chapter What is Info? - -@iftex -This file documents GNU Info, a program for viewing the on-line formatted -versions of Texinfo files, version @value{InfoProgVer}. -@end iftex - -@dfn{Info} is a program which is used to view Info files on an ASCII -terminal. @dfn{Info files} are the result of processing Texinfo files -with the program @code{makeinfo} or with one of the Emacs commands, such -as @code{M-x texinfo-format-buffer}. Texinfo itself is a documentation -system that uses a single source file to produce both on-line -information and printed output. You can typeset and print the -files that you read in Info.@refill - -@node Options, Cursor Commands, What is Info, Top -@chapter Command Line Options -@cindex command line options -@cindex arguments, command line - -GNU Info accepts several options to control the initial node being -viewed, and to specify which directories to search for Info files. Here -is a template showing an invocation of GNU Info from the shell: - -@example -info [--@var{option-name} @var{option-value}] @var{menu-item}@dots{} -@end example - -The following @var{option-names} are available when invoking Info from -the shell: - -@table @code -@cindex directory path -@item --directory @var{directory-path} -@itemx -d @var{directory-path} -Add @var{directory-path} to the list of directory paths searched when -Info needs to find a file. You may issue @code{--directory} multiple -times; once for each directory which contains Info files. -Alternatively, you may specify a value for the environment variable -@code{INFOPATH}; if @code{--directory} is not given, the value of -@code{INFOPATH} is used. The value of @code{INFOPATH} is a colon -separated list of directory names. If you do not supply @code{INFOPATH} -or @code{--directory-path}, Info uses a default path. - -@item --file @var{filename} -@itemx -f @var{filename} -@cindex Info file, selecting -Specify a particular Info file to visit. By default, Info visits -the file @code{dir}; if you use this option, Info will start with -@code{(@var{filename})Top} as the first file and node. - -@item --node @var{nodename} -@itemx -n @var{nodename} -@cindex node, selecting -Specify a particular node to visit in the initial file that Info -loads. This is especially useful in conjunction with -@code{--file}@footnote{Of course, you can specify both the file and node -in a @code{--node} command; but don't forget to escape the open and -close parentheses from the shell as in: @code{info --node -'(emacs)Buffers'}}. You may specify @code{--node} multiple times; for -an interactive Info, each @var{nodename} is visited in its own window, -for a non-interactive Info (such as when @code{--output} is given) each -@var{nodename} is processed sequentially. - -@item --output @var{filename} -@itemx -o @var{filename} -@cindex file, outputting to -@cindex outputting to a file -Specify @var{filename} as the name of a file to which to direct output. -Each node that Info visits will be output to @var{filename} instead of -interactively viewed. A value of @code{-} for @var{filename} specifies -the standard output. - -@item --subnodes -@cindex @code{--subnodes}, command line option -This option only has meaning when given in conjunction with -@code{--output}. It means to recursively output the nodes appearing in -the menus of each node being output. Menu items which resolve to -external Info files are not output, and neither are menu items which are -members of an index. Each node is only output once. - -@item --help -@itemx -h -Produces a relatively brief description of the available Info options. - -@item --version -@cindex version information -Prints the version information of Info and exits. - -@item @var{menu-item} -@cindex menu, following -Info treats its remaining arguments as the names of menu items. The -first argument is a menu item in the initial node visited, while -the second argument is a menu item in the first argument's node. -You can easily move to the node of your choice by specifying the menu -names which describe the path to that node. For example, - -@example -info emacs buffers -@end example - -@noindent -first selects the menu item @samp{Emacs} in the node @samp{(dir)Top}, -and then selects the menu item @samp{Buffers} in the node -@samp{(emacs)Top}. -@end table - -@node Cursor Commands, Scrolling Commands, Options, Top -@chapter Moving the Cursor -@cindex cursor, moving - -Many people find that reading screens of text page by page is made -easier when one is able to indicate particular pieces of text with some -kind of pointing device. Since this is the case, GNU Info (both the -Emacs and standalone versions) have several commands which allow you to -move the cursor about the screen. The notation used in this manual to -describe keystrokes is identical to the notation used within the Emacs -manual, and the GNU Readline manual. @xref{Characters, , Character -Conventions, emacs, the GNU Emacs Manual}, if you are unfamiliar with the -notation. - -The following table lists the basic cursor movement commands in Info. -Each entry consists of the key sequence you should type to execute the -cursor movement, the @code{M-x}@footnote{@code{M-x} is also a command; it -invokes @code{execute-extended-command}. @xref{M-x, , Executing an -extended command, emacs, the GNU Emacs Manual}, for more detailed -information.} command name (displayed in parentheses), and a short -description of what the command does. All of the cursor motion commands -can take an @dfn{numeric} argument (@pxref{Miscellaneous Commands, -@code{universal-argument}}), to find out how to supply them. With a -numeric argument, the motion commands are simply executed that -many times; for example, a numeric argument of 4 given to -@code{next-line} causes the cursor to move down 4 lines. With a -negative numeric argument, the motion is reversed; an argument of -4 -given to the @code{next-line} command would cause the cursor to move -@emph{up} 4 lines. - -@table @asis -@item @code{C-n} (@code{next-line}) -@kindex C-n -@findex next-line -Move the cursor down to the next line. - -@item @code{C-p} (@code{prev-line}) -@kindex C-p -@findex prev-line -Move the cursor up to the previous line. - -@item @code{C-a} (@code{beginning-of-line}) -@kindex C-a, in Info windows -@findex beginning-of-line -Move the cursor to the start of the current line. - -@item @code{C-e} (@code{end-of-line}) -@kindex C-e, in Info windows -@findex end-of-line -Move the cursor to the end of the current line. - -@item @code{C-f} (@code{forward-char}) -@kindex C-f, in Info windows -@findex forward-char -Move the cursor forward a character. - -@item @code{C-b} (@code{backward-char}) -@kindex C-b, in Info windows -@findex backward-char -Move the cursor backward a character. - -@item @code{M-f} (@code{forward-word}) -@kindex M-f, in Info windows -@findex forward-word -Move the cursor forward a word. - -@item @code{M-b} (@code{backward-word}) -@kindex M-b, in Info windows -@findex backward-word -Move the cursor backward a word. - -@item @code{M-<} (@code{beginning-of-node}) -@itemx @code{b} -@kindex b, in Info windows -@kindex M-< -@findex beginning-of-node -Move the cursor to the start of the current node. - -@item @code{M->} (@code{end-of-node}) -@kindex M-> -@findex end-of-node -Move the cursor to the end of the current node. - -@item @code{M-r} (@code{move-to-window-line}) -@kindex M-r -@findex move-to-window-line -Move the cursor to a specific line of the window. Without a numeric -argument, @code{M-r} moves the cursor to the start of the line in the -center of the window. With a numeric argument of @var{n}, @code{M-r} -moves the cursor to the start of the @var{n}th line in the window. -@end table - -@node Scrolling Commands, Node Commands, Cursor Commands, Top -@chapter Moving Text Within a Window -@cindex scrolling - -Sometimes you are looking at a screenful of text, and only part of the -current paragraph you are reading is visible on the screen. The -commands detailed in this section are used to shift which part of the -current node is visible on the screen. - -@table @asis -@item @code{SPC} (@code{scroll-forward}) -@itemx @code{C-v} -@kindex SPC, in Info windows -@kindex C-v -@findex scroll-forward -Shift the text in this window up. That is, show more of the node which -is currently below the bottom of the window. With a numeric argument, -show that many more lines at the bottom of the window; a numeric -argument of 4 would shift all of the text in the window up 4 lines -(discarding the top 4 lines), and show you four new lines at the bottom -of the window. Without a numeric argument, @key{SPC} takes the bottom -two lines of the window and places them at the top of the window, -redisplaying almost a completely new screenful of lines. - -@item @code{DEL} (@code{scroll-backward}) -@itemx @code{M-v} -@kindex DEL, in Info windows -@kindex M-v -@findex scroll-backward -Shift the text in this window down. The inverse of -@code{scroll-forward}. -@end table - -@cindex scrolling through node structure -The @code{scroll-forward} and @code{scroll-backward} commands can also -move forward and backward through the node structure of the file. If -you press @key{SPC} while viewing the end of a node, or @key{DEL} while -viewing the beginning of a node, what happens is controlled by the -variable @code{scroll-behavior}. @xref{Variables, -@code{scroll-behavior}}, for more information. - -@table @asis -@item @code{C-l} (@code{redraw-display}) -@kindex C-l -@findex redraw-display -Redraw the display from scratch, or shift the line containing the cursor -to a specified location. With no numeric argument, @samp{C-l} clears -the screen, and then redraws its entire contents. Given a numeric -argument of @var{n}, the line containing the cursor is shifted so that -it is on the @var{n}th line of the window. - -@item @code{C-x w} (@code{toggle-wrap}) -@kindex C-w -@findex toggle-wrap -Toggles the state of line wrapping in the current window. Normally, -lines which are longer than the screen width @dfn{wrap}, i.e., they are -continued on the next line. Lines which wrap have a @samp{\} appearing -in the rightmost column of the screen. You can cause such lines to be -terminated at the rightmost column by changing the state of line -wrapping in the window with @code{C-x w}. When a line which needs more -space than one screen width to display is displayed, a @samp{$} appears -in the rightmost column of the screen, and the remainder of the line is -invisible. -@end table - -@node Node Commands, Searching Commands, Scrolling Commands, Top -@chapter Selecting a New Node -@cindex nodes, selection of - -This section details the numerous Info commands which select a new node -to view in the current window. - -The most basic node commands are @samp{n}, @samp{p}, @samp{u}, and -@samp{l}. - -When you are viewing a node, the top line of the node contains some Info -@dfn{pointers} which describe where the next, previous, and up nodes -are. Info uses this line to move about the node structure of the file -when you use the following commands: - -@table @asis -@item @code{n} (@code{next-node}) -@kindex n -@findex next-node -Select the `Next' node. - -@item @code{p} (@code{prev-node}) -@kindex p -@findex prev-node -Select the `Prev' node. - -@item @code{u} (@code{up-node}) -@kindex u -@findex up-node -Select the `Up' node. -@end table - -You can easily select a node that you have already viewed in this window -by using the @samp{l} command -- this name stands for "last", and -actually moves through the list of already visited nodes for this -window. @samp{l} with a negative numeric argument moves forward through -the history of nodes for this window, so you can quickly step between -two adjacent (in viewing history) nodes. - -@table @asis -@item @code{l} (@code{history-node}) -@kindex l -@findex history-node -Select the most recently selected node in this window. -@end table - -Two additional commands make it easy to select the most commonly -selected nodes; they are @samp{t} and @samp{d}. - -@table @asis -@item @code{t} (@code{top-node}) -@kindex t -@findex top-node -Select the node @samp{Top} in the current Info file. - -@item @code{d} (@code{dir-node}) -@kindex d -@findex dir-node -Select the directory node (i.e., the node @samp{(dir)}). -@end table - -Here are some other commands which immediately result in the selection -of a different node in the current window: - -@table @asis -@item @code{<} (@code{first-node}) -@kindex < -@findex first-node -Selects the first node which appears in this file. This node is most -often @samp{Top}, but it does not have to be. - -@item @code{>} (@code{last-node}) -@kindex > -@findex last-node -Select the last node which appears in this file. - -@item @code{]} (@code{global-next-node}) -@kindex ] -@findex global-next-node -Move forward or down through node structure. If the node that you are -currently viewing has a @samp{Next} pointer, that node is selected. -Otherwise, if this node has a menu, the first menu item is selected. If -there is no @samp{Next} and no menu, the same process is tried with the -@samp{Up} node of this node. - -@item @code{[} (@code{global-prev-node}) -@kindex [ -@findex global-prev-node -Move backward or up through node structure. If the node that you are -currently viewing has a @samp{Prev} pointer, that node is selected. -Otherwise, if the node has an @samp{Up} pointer, that node is selected, -and if it has a menu, the last item in the menu is selected. -@end table - -You can get the same behavior as @code{global-next-node} and -@code{global-prev-node} while simply scrolling through the file with -@key{SPC} and @key{DEL}; @xref{Variables, @code{scroll-behavior}}, for -more information. - -@table @asis -@item @code{g} (@code{goto-node}) -@kindex g -@findex goto-node -Read the name of a node and select it. No completion is done while -reading the node name, since the desired node may reside in a separate -file. The node must be typed exactly as it appears in the Info file. A -file name may be included as with any node specification, for example - -@example -@code{g(emacs)Buffers} -@end example - -finds the node @samp{Buffers} in the Info file @file{emacs}. - -@item @code{C-x k} (@code{kill-node}) -@kindex C-x k -@findex kill-node -Kill a node. The node name is prompted for in the echo area, with a -default of the current node. @dfn{Killing} a node means that Info tries -hard to forget about it, removing it from the list of history nodes kept -for the window where that node is found. Another node is selected in -the window which contained the killed node. - -@item @code{C-x C-f} (@code{view-file}) -@kindex C-x C-f -@findex view-file -Read the name of a file and selects the entire file. The command -@example -@code{C-x C-f @var{filename}} -@end example -is equivalent to typing -@example -@code{g(@var{filename})*} -@end example - -@item @code{C-x C-b} (@code{list-visited-nodes}) -@kindex C-x C-b -@findex list-visited-nodes -Make a window containing a menu of all of the currently visited nodes. -This window becomes the selected window, and you may use the standard -Info commands within it. - -@item @code{C-x b} (@code{select-visited-node}) -@kindex C-x b -@findex select-visited-node -Select a node which has been previously visited in a visible window. -This is similar to @samp{C-x C-b} followed by @samp{m}, but no window is -created. -@end table - -@node Searching Commands, Xref Commands, Node Commands, Top -@chapter Searching an Info File -@cindex searching - -GNU Info allows you to search for a sequence of characters throughout an -entire Info file, search through the indices of an Info file, or find -areas within an Info file which discuss a particular topic. - -@table @asis -@item @code{s} (@code{search}) -@kindex s -@findex search -Read a string in the echo area and search for it. - -@item @code{C-s} (@code{isearch-forward}) -@kindex C-s -@findex isearch-forward -Interactively search forward through the Info file for a string as you -type it. - -@item @code{C-r} (@code{isearch-backward}) -@kindex C-r -@findex isearch-backward -Interactively search backward through the Info file for a string as -you type it. - -@item @code{i} (@code{index-search}) -@kindex i -@findex index-search -Look up a string in the indices for this Info file, and select a node -where the found index entry points to. - -@item @code{,} (@code{next-index-match}) -@kindex , -@findex next-index-match -Move to the node containing the next matching index item from the last -@samp{i} command. -@end table - -The most basic searching command is @samp{s} (@code{search}). The -@samp{s} command prompts you for a string in the echo area, and then -searches the remainder of the Info file for an occurrence of that string. -If the string is found, the node containing it is selected, and the -cursor is left positioned at the start of the found string. Subsequent -@samp{s} commands show you the default search string within @samp{[} and -@samp{]}; pressing @key{RET} instead of typing a new string will use the -default search string. - -@dfn{Incremental searching} is similar to basic searching, but the -string is looked up while you are typing it, instead of waiting until -the entire search string has been specified. - -@node Xref Commands, Window Commands, Searching Commands, Top -@chapter Selecting Cross References - -We have already discussed the @samp{Next}, @samp{Prev}, and @samp{Up} -pointers which appear at the top of a node. In addition to these -pointers, a node may contain other pointers which refer you to a -different node, perhaps in another Info file. Such pointers are called -@dfn{cross references}, or @dfn{xrefs} for short. - -@menu -* Parts of an Xref:: What a cross reference is made of. -* Selecting Xrefs:: Commands for selecting menu or note items. -@end menu - -@node Parts of an Xref, Selecting Xrefs, , Xref Commands -@section Parts of an Xref - -Cross references have two major parts: the first part is called the -@dfn{label}; it is the name that you can use to refer to the cross -reference, and the second is the @dfn{target}; it is the full name of -the node that the cross reference points to. - -The target is separated from the label by a colon @samp{:}; first the -label appears, and then the target. For example, in the sample menu -cross reference below, the single colon separates the label from the -target. - -@example -* Foo Label: Foo Target. More information about Foo. -@end example - -Note the @samp{.} which ends the name of the target. The @samp{.} is -not part of the target; it serves only to let Info know where the target -name ends. - -A shorthand way of specifying references allows two adjacent colons to -stand for a target name which is the same as the label name: - -@example -* Foo Commands:: Commands pertaining to Foo. -@end example - -In the above example, the name of the target is the same as the name of -the label, in this case @code{Foo Commands}. - -You will normally see two types of cross reference while viewing nodes: -@dfn{menu} references, and @dfn{note} references. Menu references -appear within a node's menu; they begin with a @samp{*} at the beginning -of a line, and continue with a label, a target, and a comment which -describes what the contents of the node pointed to contains. - -Note references appear within the body of the node text; they begin with -@code{*Note}, and continue with a label and a target. - -Like @samp{Next}, @samp{Prev}, and @samp{Up} pointers, cross references -can point to any valid node. They are used to refer you to a place -where more detailed information can be found on a particular subject. -Here is a cross reference which points to a node within the Texinfo -documentation: @xref{xref, , Writing an Xref, texinfo, the Texinfo -Manual}, for more information on creating your own texinfo cross -references. - -@node Selecting Xrefs, , Parts of an Xref, Xref Commands -@section Selecting Xrefs - -The following table lists the Info commands which operate on menu items. - -@table @asis -@item @code{1} (@code{menu-digit}) -@itemx @code{2} @dots{} @code{9} -@cindex 1 @dots{} 9, in Info windows -@kindex 1 @dots{} 9, in Info windows -@findex menu-digit -Within an Info window, pressing a single digit, (such as @samp{1}), -selects that menu item, and places its node in the current window. -For convenience, there is one exception; pressing @samp{0} selects the -@emph{last} item in the node's menu. - -@item @code{0} (@code{last-menu-item}) -@kindex 0, in Info windows -@findex last-menu-item -Select the last item in the current node's menu. - -@item @code{m} (@code{menu-item}) -@kindex m -@findex menu-item -Reads the name of a menu item in the echo area and selects its node. -Completion is available while reading the menu label. - -@item @code{M-x find-menu} -@findex find-menu -Move the cursor to the start of this node's menu. -@end table - -This table lists the Info commands which operate on note cross references. - -@table @asis -@item @code{f} (@code{xref-item}) -@itemx @code{r} -@kindex f -@kindex r -@findex xref-item -Reads the name of a note cross reference in the echo area and selects -its node. Completion is available while reading the cross reference -label. -@end table - -Finally, the next few commands operate on menu or note references alike: - -@table @asis -@item @code{TAB} (@code{move-to-next-xref}) -@kindex TAB, in Info windows -@findex move-to-next-xref -Move the cursor to the start of the next nearest menu item or note -reference in this node. You can then use @key{RET} -(@code{select-reference-this-line}) to select the menu or note reference. - -@item @code{M-TAB} (@code{move-to-prev-xref}) -@kindex M-TAB, in Info windows -@findex move-to-prev-xref -Move the cursor the start of the nearest previous menu item or note -reference in this node. - -@item @code{RET} (@code{select-reference-this-line}) -@kindex RET, in Info windows -@findex select-reference-this-line -Select the menu item or note reference appearing on this line. -@end table - -@node Window Commands, Printing Nodes, Xref Commands, Top -@chapter Manipulating Multiple Windows -@cindex windows, manipulating - -A @dfn{window} is a place to show the text of a node. Windows have a -view area where the text of the node is displayed, and an associated -@dfn{mode line}, which briefly describes the node being viewed. - -GNU Info supports multiple windows appearing in a single screen; each -window is separated from the next by its modeline. At any time, there -is only one @dfn{active} window, that is, the window in which the cursor -appears. There are commands available for creating windows, changing -the size of windows, selecting which window is active, and for deleting -windows. - -@menu -* The Mode Line:: What appears in the mode line? -* Basic Windows:: Manipulating windows in Info. -* The Echo Area:: Used for displaying errors and reading input. -@end menu - -@node The Mode Line, Basic Windows, , Window Commands -@section The Mode Line - -A @dfn{mode line} is a line of inverse video which appears at the bottom -of an Info window. It describes the contents of the window just above -it; this information includes the name of the file and node appearing in -that window, the number of screen lines it takes to display the node, -and the percentage of text that is above the top of the window. It can -also tell you if the indirect tags table for this Info file needs to be -updated, and whether or not the Info file was compressed when stored on -disk. - -Here is a sample mode line for a window containing an uncompressed file -named @file{dir}, showing the node @samp{Top}. - -@example -@group ------Info: (dir)Top, 40 lines --Top--------------------------------------- - ^^ ^ ^^^ ^^ - (file)Node #lines where -@end group -@end example - -When a node comes from a file which is compressed on disk, this is -indicated in the mode line with two small @samp{z}'s. In addition, if -the Info file containing the node has been split into subfiles, the name -of the subfile containing the node appears in the modeline as well: - -@example ---zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- -@end example - -When Info makes a node internally, such that there is no corresponding -info file on disk, the name of the node is surrounded by asterisks -(@samp{*}). The name itself tells you what the contents of the window -are; the sample mode line below shows an internally constructed node -showing possible completions: - -@example ------Info: *Completions*, 7 lines --All----------------------------------- -@end example - -@node Basic Windows, The Echo Area, The Mode Line, Window Commands -@section Window Commands - -It can be convenient to view more than one node at a time. To allow -this, Info can display more than one @dfn{window}. Each window has its -own mode line (@pxref{The Mode Line}) and history of nodes viewed in that -window (@pxref{Node Commands, , @code{history-node}}). - -@table @asis -@item @code{C-x o} (@code{next-window}) -@cindex windows, selecting -@kindex C-x o -@findex next-window -Select the next window on the screen. Note that the echo area can only be -selected if it is already in use, and you have left it temporarily. -Normally, @samp{C-x o} simply moves the cursor into the next window on -the screen, or if you are already within the last window, into the first -window on the screen. Given a numeric argument, @samp{C-x o} moves over -that many windows. A negative argument causes @samp{C-x o} to select -the previous window on the screen. - -@item @code{M-x prev-window} -@findex prev-window -Select the previous window on the screen. This is identical to -@samp{C-x o} with a negative argument. - -@item @code{C-x 2} (@code{split-window}) -@cindex windows, creating -@kindex C-x 2 -@findex split-window -Split the current window into two windows, both showing the same node. -Each window is one half the size of the original window, and the cursor -remains in the original window. The variable @code{automatic-tiling} -can cause all of the windows on the screen to be resized for you -automatically, please @pxref{Variables, , automatic-tiling} for more -information. - -@item @code{C-x 0} (@code{delete-window}) -@cindex windows, deleting -@kindex C-x 0 -@findex delete-window -Delete the current window from the screen. If you have made too many -windows and your screen appears cluttered, this is the way to get rid of -some of them. - -@item @code{C-x 1} (@code{keep-one-window}) -@kindex C-x 1 -@findex keep-one-window -Delete all of the windows excepting the current one. - -@item @code{ESC C-v} (@code{scroll-other-window}) -@kindex ESC C-v, in Info windows -@findex scroll-other-window -Scroll the other window, in the same fashion that @samp{C-v} might -scroll the current window. Given a negative argument, scroll the -"other" window backward. - -@item @code{C-x ^} (@code{grow-window}) -@kindex C-x ^ -@findex grow-window -Grow (or shrink) the current window. Given a numeric argument, grow -the current window that many lines; with a negative numeric argument, -shrink the window instead. - -@item @code{C-x t} (@code{tile-windows}) -@cindex tiling -@kindex C-x t -@findex tile-windows -Divide the available screen space among all of the visible windows. -Each window is given an equal portion of the screen in which to display -its contents. The variable @code{automatic-tiling} can cause -@code{tile-windows} to be called when a window is created or deleted. -@xref{Variables, , @code{automatic-tiling}}. -@end table - -@node The Echo Area, , Basic Windows, Window Commands -@section The Echo Area -@cindex echo area - -The @dfn{echo area} is a one line window which appears at the bottom of -the screen. It is used to display informative or error messages, and to -read lines of input from you when that is necessary. Almost all of the -commands available in the echo area are identical to their Emacs -counterparts, so please refer to that documentation for greater depth of -discussion on the concepts of editing a line of text. The following -table briefly lists the commands that are available while input is being -read in the echo area: - -@table @asis -@item @code{C-f} (@code{echo-area-forward}) -@kindex C-f, in the echo area -@findex echo-area-forward -Move forward a character. - -@item @code{C-b} (@code{echo-area-backward}) -@kindex C-b, in the echo area -@findex echo-area-backward -Move backward a character. - -@item @code{C-a} (@code{echo-area-beg-of-line}) -@kindex C-a, in the echo area -@findex echo-area-beg-of-line -Move to the start of the input line. - -@item @code{C-e} (@code{echo-area-end-of-line}) -@kindex C-e, in the echo area -@findex echo-area-end-of-line -Move to the end of the input line. - -@item @code{M-f} (@code{echo-area-forward-word}) -@kindex M-f, in the echo area -@findex echo-area-forward-word -Move forward a word. - -@item @code{M-b} (@code{echo-area-backward-word}) -@kindex M-b, in the echo area -@findex echo-area-backward-word -Move backward a word. - -@item @code{C-d} (@code{echo-area-delete}) -@kindex C-d, in the echo area -@findex echo-area-delete -Delete the character under the cursor. - -@item @code{DEL} (@code{echo-area-rubout}) -@kindex DEL, in the echo area -@findex echo-area-rubout -Delete the character behind the cursor. - -@item @code{C-g} (@code{echo-area-abort}) -@kindex C-g, in the echo area -@findex echo-area-abort -Cancel or quit the current operation. If completion is being read, -@samp{C-g} discards the text of the input line which does not match any -completion. If the input line is empty, @samp{C-g} aborts the calling -function. - -@item @code{RET} (@code{echo-area-newline}) -@kindex RET, in the echo area -@findex echo-area-newline -Accept (or forces completion of) the current input line. - -@item @code{C-q} (@code{echo-area-quoted-insert}) -@kindex C-q, in the echo area -@findex echo-area-quoted-insert -Insert the next character verbatim. This is how you can insert control -characters into a search string, for example. - -@item @var{printing character} (@code{echo-area-insert}) -@kindex printing characters, in the echo area -@findex echo-area-insert -Insert the character. - -@item @code{M-TAB} (@code{echo-area-tab-insert}) -@kindex M-TAB, in the echo area -@findex echo-area-tab-insert -Insert a TAB character. - -@item @code{C-t} (@code{echo-area-transpose-chars}) -@kindex C-t, in the echo area -@findex echo-area-transpose-chars -Transpose the characters at the cursor. -@end table - -The next group of commands deal with @dfn{killing}, and @dfn{yanking} -text. For an in depth discussion of killing and yanking, -@pxref{Killing, , Killing and Deleting, emacs, the GNU Emacs Manual} - -@table @asis -@item @code{M-d} (@code{echo-area-kill-word}) -@kindex M-d, in the echo area -@findex echo-area-kill-word -Kill the word following the cursor. - -@item @code{M-DEL} (@code{echo-area-backward-kill-word}) -@kindex M-DEL, in the echo area -@findex echo-area-backward-kill-word -Kill the word preceding the cursor. - -@item @code{C-k} (@code{echo-area-kill-line}) -@kindex C-k, in the echo area -@findex echo-area-kill-line -Kill the text from the cursor to the end of the line. - -@item @code{C-x DEL} (@code{echo-area-backward-kill-line}) -@kindex C-x DEL, in the echo area -@findex echo-area-backward-kill-line -Kill the text from the cursor to the beginning of the line. - -@item @code{C-y} (@code{echo-area-yank}) -@kindex C-y, in the echo area -@findex echo-area-yank -Yank back the contents of the last kill. - -@item @code{M-y} (@code{echo-area-yank-pop}) -@kindex M-y, in the echo area -@findex echo-area-yank-pop -Yank back a previous kill, removing the last yanked text first. -@end table - -Sometimes when reading input in the echo area, the command that needed -input will only accept one of a list of several choices. The choices -represent the @dfn{possible completions}, and you must respond with one -of them. Since there are a limited number of responses you can make, -Info allows you to abbreviate what you type, only typing as much of the -response as is necessary to uniquely identify it. In addition, you can -request Info to fill in as much of the response as is possible; this -is called @dfn{completion}. - -The following commands are available when completing in the echo area: - -@table @asis -@item @code{TAB} (@code{echo-area-complete}) -@itemx @code{SPC} -@kindex TAB, in the echo area -@kindex SPC, in the echo area -@findex echo-area-complete -Insert as much of a completion as is possible. - -@item @code{?} (@code{echo-area-possible-completions}) -@kindex ?, in the echo area -@findex echo-area-possible-completions -Display a window containing a list of the possible completions of what -you have typed so far. For example, if the available choices are: - -@example -@group -bar -foliate -food -forget -@end group -@end example - -@noindent -and you have typed an @samp{f}, followed by @samp{?}, the possible -completions would contain: - -@example -@group -foliate -food -forget -@end group -@end example - -@noindent -i.e., all of the choices which begin with @samp{f}. Pressing @key{SPC} -or @key{TAB} would result in @samp{fo} appearing in the echo area, since -all of the choices which begin with @samp{f} continue with @samp{o}. -Now, typing @samp{l} followed by @samp{TAB} results in @samp{foliate} -appearing in the echo area, since that is the only choice which begins -with @samp{fol}. - -@item @code{ESC C-v} (@code{echo-area-scroll-completions-window}) -@kindex ESC C-v, in the echo area -@findex echo-area-scroll-completions-window -Scroll the completions window, if that is visible, or the "other" -window if not. -@end table - -@node Printing Nodes, Miscellaneous Commands, Window Commands, Top -@chapter Printing Out Nodes -@cindex printing - -You may wish to print out the contents of a node as a quick reference -document for later use. Info provides you with a command for doing -this. In general, we recommend that you use @TeX{} to format the -document and print sections of it, by running @code{tex} on the Texinfo -source file. - -@table @asis -@item @code{M-x print-node} -@findex print-node -@cindex INFO_PRINT_COMMAND, environment variable -Pipe the contents of the current node through the command in the -environment variable @code{INFO_PRINT_COMMAND}. If the variable does not -exist, the node is simply piped to @code{lpr}. -@end table - -@node Miscellaneous Commands, Variables, Printing Nodes, Top -@chapter Miscellaneous Commands - -GNU Info contains several commands which self-document GNU Info: - -@table @asis -@item @code{M-x describe-command} -@cindex functions, describing -@cindex commands, describing -@findex describe-command -Read the name of an Info command in the echo area and then display a -brief description of what that command does. - -@item @code{M-x describe-key} -@cindex keys, describing -@findex describe-key -Read a key sequence in the echo area, and then display the name and -documentation of the Info command that the key sequence invokes. - -@item @code{M-x describe-variable} -Read the name of a variable in the echo area and then display a brief -description of what the variable affects. - -@item @code{M-x where-is} -@findex where-is -Read the name of an Info command in the echo area, and then display -a key sequence which can be typed in order to invoke that command. - -@item @code{C-h} (@code{get-help-window}) -@itemx @code{?} -@kindex C-h -@kindex ?, in Info windows -@findex get-help-window -Create (or Move into) the window displaying @code{*Help*}, and place -a node containing a quick reference card into it. This window displays -the most concise information about GNU Info available. - -@item @code{h} (@code{get-info-help-node}) -@kindex h -@findex get-info-help-node -Try hard to visit the node @code{(info)Help}. The Info file -@file{info.texi} distributed with GNU Info contains this node. Of -course, the file must first be processed with @code{makeinfo}, and then -placed into the location of your Info directory. -@end table - -Here are the commands for creating a numeric argument: - -@table @asis -@item @code{C-u} (@code{universal-argument}) -@cindex numeric arguments -@kindex C-u -@findex universal-argument -Start (or multiply by 4) the current numeric argument. @samp{C-u} is -a good way to give a small numeric argument to cursor movement or -scrolling commands; @samp{C-u C-v} scrolls the screen 4 lines, while -@samp{C-u C-u C-n} moves the cursor down 16 lines. - -@item @code{M-1} (@code{add-digit-to-numeric-arg}) -@itemx @code{M-2} @dots{} @code{M-9} -@kindex M-1 @dots{} M-9 -@findex add-digit-to-numeric-arg -Add the digit value of the invoking key to the current numeric -argument. Once Info is reading a numeric argument, you may just type -the digits of the argument, without the Meta prefix. For example, you -might give @samp{C-l} a numeric argument of 32 by typing: - -@example -@kbd{C-u 3 2 C-l} -@end example - -@noindent -or - -@example -@kbd{M-3 2 C-l} -@end example -@end table - -@samp{C-g} is used to abort the reading of a multi-character key -sequence, to cancel lengthy operations (such as multi-file searches) and -to cancel reading input in the echo area. - -@table @asis -@item @code{C-g} (@code{abort-key}) -@cindex cancelling typeahead -@cindex cancelling the current operation -@kindex C-g, in Info windows -@findex abort-key -Cancel current operation. -@end table - -The @samp{q} command of Info simply quits running Info. - -@table @asis -@item @code{q} (@code{quit}) -@cindex quitting -@kindex q -@findex quit -Exit GNU Info. -@end table - -If the operating system tells GNU Info that the screen is 60 lines tall, -and it is actually only 40 lines tall, here is a way to tell Info that -the operating system is correct. - -@table @asis -@item @code{M-x set-screen-height} -@findex set-screen-height -@cindex screen, changing the height of -Read a height value in the echo area and set the height of the -displayed screen to that value. -@end table - -Finally, Info provides a convenient way to display footnotes which might -be associated with the current node that you are viewing: - -@table @asis -@item @code{ESC C-f} (@code{show-footnotes}) -@kindex ESC C-f -@findex show-footnotes -@cindex footnotes, displaying -Show the footnotes (if any) associated with the current node in another -window. You can have Info automatically display the footnotes -associated with a node when the node is selected by setting the variable -@code{automatic-footnotes}. @xref{Variables, , @code{automatic-footnotes}}. -@end table - -@node Variables, GNU Info Global Index, Miscellaneous Commands, Top -@chapter Manipulating Variables - -GNU Info contains several @dfn{variables} whose values are looked at by various -Info commands. You can change the values of these variables, and thus -change the behavior of Info to more closely match your environment and -Info file reading manner. - -@table @asis -@item @code{M-x set-variable} -@cindex variables, setting -@findex set-variable -Read the name of a variable, and the value for it, in the echo area and -then set the variable to that value. Completion is available when -reading the variable name; often, completion is available when reading -the value to give to the variable, but that depends on the variable -itself. If a variable does @emph{not} supply multiple choices to -complete over, it expects a numeric value. - -@item @code{M-x describe-variable} -@cindex variables, describing -@findex describe-variable -Read the name of a variable in the echo area and then display a brief -description of what the variable affects. -@end table - -Here is a list of the variables that you can set in Info. - -@table @code -@item automatic-footnotes -@vindex automatic-footnotes -When set to @code{On}, footnotes appear and disappear automatically. -This variable is @code{On} by default. When a node is selected, a -window containing the footnotes which appear in that node is created, -and the footnotes are displayed within the new window. The window that -Info creates to contain the footnotes is called @samp{*Footnotes*}. If -a node is selected which contains no footnotes, and a @samp{*Footnotes*} -window is on the screen, the @samp{*Footnotes*} window is deleted. -Footnote windows created in this fashion are not automatically tiled so -that they can use as little of the display as is possible. - -@item automatic-tiling -@vindex automatic-tiling -When set to @code{On}, creating or deleting a window resizes other -windows. This variable is @code{Off} by default. Normally, typing -@samp{C-x 2} divides the current window into two equal parts. When -@code{automatic-tiling} is set to @code{On}, all of the windows are -resized automatically, keeping an equal number of lines visible in each -window. There are exceptions to the automatic tiling; specifically, the -windows @samp{*Completions*} and @samp{*Footnotes*} are @emph{not} -resized through automatic tiling; they remain their original size. - -@item visible-bell -@vindex visible-bell -When set to @code{On}, GNU Info attempts to flash the screen instead of -ringing the bell. This variable is @code{Off} by default. Of course, -Info can only flash the screen if the terminal allows it; in the case -that the terminal does not allow it, the setting of this variable has no -effect. However, you can make Info perform quietly by setting the -@code{errors-ring-bell} variable to @code{Off}. - -@item errors-ring-bell -@vindex errors-ring-bell -When set to @code{On}, errors cause the bell to ring. The default -setting of this variable is @code{On}. - -@item gc-compressed-files -@vindex gc-compressed-files -When set to @code{On}, Info garbage collects files which had to be -uncompressed. The default value of this variable is @code{Off}. -Whenever a node is visited in Info, the Info file containing that node -is read into core, and Info reads information about the tags and nodes -contained in that file. Once the tags information is read by Info, it -is never forgotten. However, the actual text of the nodes does not need -to remain in core unless a particular Info window needs it. For -non-compressed files, the text of the nodes does not remain in core when -it is no longer in use. But de-compressing a file can be a time -consuming operation, and so Info tries hard not to do it twice. -@code{gc-compressed-files} tells Info it is okay to garbage collect the -text of the nodes of a file which was compressed on disk. - -@item show-index-match -@vindex show-index-match -When set to @code{On}, the portion of the matched search string is -highlighted in the message which explains where the matched search -string was found. The default value of this variable is @code{On}. -When Info displays the location where an index match was found, -(@pxref{Searching Commands, , @code{next-index-match}}), the portion of the -string that you had typed is highlighted by displaying it in the inverse -case from its surrounding characters. - -@item scroll-behavior -@vindex scroll-behavior -Control what happens when forward scrolling is requested at the end of -a node, or when backward scrolling is requested at the beginning of a -node. The default value for this variable is @code{Continuous}. There -are three possible values for this variable: - -@table @code -@item Continuous -Try to get the first item in this node's menu, or failing that, the -@samp{Next} node, or failing that, the @samp{Next} of the @samp{Up}. -This behavior is identical to using the @samp{]} -(@code{global-next-node}) and @samp{[} (@code{global-prev-node}) -commands. - -@item Next Only -Only try to get the @samp{Next} node. - -@item Page Only -Simply give up, changing nothing. If @code{scroll-behavior} is -@code{Page Only}, no scrolling command can change the node that is being -viewed. -@end table - -@item scroll-step -@vindex scroll-step -The number of lines to scroll when the cursor moves out of the window. -Scrolling happens automatically if the cursor has moved out of the -visible portion of the node text when it is time to display. Usually -the scrolling is done so as to put the cursor on the center line of the -current window. However, if the variable @code{scroll-step} has a -nonzero value, Info attempts to scroll the node text by that many lines; -if that is enough to bring the cursor back into the window, that is what -is done. The default value of this variable is 0, thus placing the -cursor (and the text it is attached to) in the center of the window. -Setting this variable to 1 causes a kind of "smooth scrolling" which -some people prefer. - -@item ISO-Latin -@cindex ISO Latin characters -@vindex ISO-Latin -When set to @code{On}, Info accepts and displays ISO Latin characters. -By default, Info assumes an ASCII character set. @code{ISO-Latin} tells -Info that it is running in an environment where the European standard -character set is in use, and allows you to input such characters to -Info, as well as display them. -@end table - - - -@c the following is incomplete -@ignore -@c node Info for Sys Admins -@c chapter Info for System Administrators - -This text describes some common ways of setting up an Info hierarchy -from scratch, and details the various options that are available when -installing Info. This text is designed for the person who is installing -GNU Info on the system; although users may find the information present -in this section interesting, none of it is vital to understanding how to -use GNU Info. - -@menu -* Setting the INFOPATH:: Where are my Info files kept? -* Editing the DIR node:: What goes in `DIR', and why? -* Storing Info files:: Alternate formats allow flexibility in setups. -* Using `localdir':: Building DIR on the fly. -* Example setups:: Some common ways to organize Info files. -@end menu - -@c node Setting the INFOPATH -@c section Setting the INFOPATH - -Where are my Info files kept? - -@c node Editing the DIR node -@c section Editing the DIR node - -What goes in `DIR', and why? - -@c node Storing Info files -@c section Storing Info files - -Alternate formats allow flexibility in setups. - -@c node Using `localdir' -@c section Using `localdir' - -Building DIR on the fly. - -@c node Example setups -@c section Example setups - -Some common ways to organize Info files. -@end ignore - -@node GNU Info Global Index, , Variables, Top -@appendix Global Index - -@printindex cp - -@contents -@bye diff --git a/gnu/usr.bin/texinfo/info-files/texi-files/info.texi b/gnu/usr.bin/texinfo/info-files/texi-files/info.texi deleted file mode 100644 index 5eec9f10f0e3..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi-files/info.texi +++ /dev/null @@ -1,861 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header -@setfilename info.info -@settitle Info 1.0 -@comment %**end of header - -@iftex -@finalout -@end iftex - -@ifinfo -This file describes how to use Info, -the on-line, menu-driven GNU documentation system. - -Copyright (C) 1989, 1992 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end ifinfo - -@setchapternewpage odd -@titlepage -@sp 11 -@center @titlefont{Info} -@sp 2 -@center The -@sp 2 -@center On-line, Menu-driven -@sp 2 -@center GNU Documentation System - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1992, 1993 Free Software Foundation, Inc. -@sp 2 - -Published by the Free Software Foundation @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 USA @* - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end titlepage - -@ifinfo -@node Top, Getting Started, (dir), (dir) -@top Info: An Introduction - -Info is a program for reading documentation, which you are using now. - -To learn how to use Info, type the command @kbd{h}. It brings you -to a programmed instruction sequence. - -@c Need to make sure that `Info-help' goes to the right node, -@c which is the first node of the first chapter. (It should.) -@c (Info-find-node "info" -@c (if (< (window-height) 23) -@c "Help-Small-Screen" -@c "Help"))) - -To learn advanced Info commands, type @kbd{n} twice. This -brings you to @cite{Info for Experts}, skipping over the . -`Getting Started' chapter. -@end ifinfo - -@menu -* Getting Started:: -* Advanced Info:: -* Create an Info File:: -@end menu - -@node Getting Started, Advanced Info, Top, Top -@comment node-name, next, previous, up -@chapter Getting Started - -This first part of the Info manual describes how to get around inside -of Info. The second part of the manual describes various advanced -Info commands, and how to write an Info as distinct from a Texinfo -file. The third part is about how to generate Info files from -Texinfo files. - -@iftex -This manual is primarily designed for use on a computer, so that you can -try Info commands while reading about them. Reading it on paper is less -effective, since you must take it on faith that the commands described -really do what the manual says. By all means go through this manual now -that you have it; but please try going through the on-line version as -well. - -There are two ways of looking at the online version of this manual: - -@enumerate -@item -Type @code{info} at your shell's command line. This approach uses a -small stand-alone program designed just to read Info files. - -@item -Type @code{emacs} at the command line; then type @kbd{C-h i} (Control -@kbd{h}, followed by @kbd{i}). This approach uses -the Info mode of the Emacs program, an editor with many other -capabilities. -@end enumerate - -In either case, then type @kbd{mInfo} (just the letters), followed by -@key{RET}---the ``Return'' or ``Enter'' key. At this point, you should -be ready to follow the instructions in this manual as you read them on -the screen. -@c FIXME! (pesch@cygnus.com, 14 dec 1992) -@c Is it worth worrying about what-if the beginner goes to somebody -@c else's Emacs session, which already has an Info running in the middle -@c of something---in which case these simple instructions won't work? -@end iftex - -@menu -* Help-Small-Screen:: Starting Info on a Small Screen -* Help:: How to use Info -* Help-P:: Returning to the Previous node -* Help-^L:: The Space, Rubout, B and ^L commands. -* Help-M:: Menus -* Help-Adv:: Some advanced Info commands -* Help-Q:: Quitting Info -@end menu - -@node Help-Small-Screen, Help, , Getting Started -@comment node-name, next, previous, up -@section Starting Info on a Small Screen - -@iftex -(In Info, you only see this section if your terminal has a small -number of lines; most readers pass by it without seeing it.) -@end iftex - -Since your terminal has an unusually small number of lines on its -screen, it is necessary to give you special advice at the beginning. - -If you see the text @samp{--All----} at near the bottom right corner -of the screen, it means the entire text you are looking at fits on the -screen. If you see @samp{--Top----} instead, it means that there is -more text below that does not fit. To move forward through the text -and see another screen full, press the Space bar, @key{SPC}. To move -back up, press the key labeled @samp{Rubout} or @samp{Delete} or -@key{DEL}. - -@ifinfo -Here are 40 lines of junk, so you can try @key{SPC} and @key{DEL} and -see what they do. At the end are instructions of what you should do -next. - -This is line 17 @* -This is line 18 @* -This is line 19 @* -This is line 20 @* -This is line 21 @* -This is line 22 @* -This is line 23 @* -This is line 24 @* -This is line 25 @* -This is line 26 @* -This is line 27 @* -This is line 28 @* -This is line 29 @* -This is line 30 @* -This is line 31 @* -This is line 32 @* -This is line 33 @* -This is line 34 @* -This is line 35 @* -This is line 36 @* -This is line 37 @* -This is line 38 @* -This is line 39 @* -This is line 40 @* -This is line 41 @* -This is line 42 @* -This is line 43 @* -This is line 44 @* -This is line 45 @* -This is line 46 @* -This is line 47 @* -This is line 48 @* -This is line 49 @* -This is line 50 @* -This is line 51 @* -This is line 52 @* -This is line 53 @* -This is line 54 @* -This is line 55 @* -This is line 56 @* - -If you have managed to get here, go back to the beginning with -@key{DEL}, and come back here again, then you understand @key{SPC} and -@key{DEL}. So now type an @kbd{n}---just one character; do not type -the quotes and do not type the Return key, @key{RET}, afterward---to -get to the normal start of the course. -@end ifinfo - -@node Help, Help-P, Help-Small-Screen, Getting Started -@comment node-name, next, previous, up -@section How to use Info - -You are talking to the program Info, for reading documentation. - - Right now you are looking at one @dfn{Node} of Information. -A node contains text describing a specific topic at a specific -level of detail. This node's topic is ``how to use Info''. - - The top line of a node is its @dfn{header}. This node's header (look at -it now) says that it is the node named @samp{Help} in the file -@file{info}. It says that the @samp{Next} node after this one is the node -called @samp{Help-P}. An advanced Info command lets you go to any node -whose name you know. - - Besides a @samp{Next}, a node can have a @samp{Previous} or an @samp{Up}. -This node has a @samp{Previous} but no @samp{Up}, as you can see. - - Now it is time to move on to the @samp{Next} node, named @samp{Help-P}. - ->> Type @samp{n} to move there. Type just one character; - do not type the quotes and do not type a @key{RET} afterward. - -@samp{>>} in the margin means it is really time to try a command. - -@node Help-P, Help-^L, Help, Getting Started -@comment node-name, next, previous, up -@section Returning to the Previous node - -This node is called @samp{Help-P}. The @samp{Previous} node, as you see, -is @samp{Help}, which is the one you just came from using the @kbd{n} -command. Another @kbd{n} command now would take you to the next -node, @samp{Help-^L}. - ->> But do not do that yet. First, try the @kbd{p} command, which takes - you to the @samp{Previous} node. When you get there, you can do an - @kbd{n} again to return here. - - This all probably seems insultingly simple so far, but @emph{do not} be -led into skimming. Things will get more complicated soon. Also, -do not try a new command until you are told it is time to. Otherwise, -you may make Info skip past an important warning that was coming up. - ->> Now do an @kbd{n} to get to the node @samp{Help-^L} and learn more. - -@node Help-^L, Help-M, Help-P, Getting Started -@comment node-name, next, previous, up -@section The Space, Rubout, B and ^L commands. - - This node's header tells you that you are now at node @samp{Help-^L}, and -that @kbd{p} would get you back to @samp{Help-P}. The node's title is -underlined; it says what the node is about (most nodes have titles). - - This is a big node and it does not all fit on your display screen. -You can tell that there is more that is not visible because you -can see the string @samp{--Top-----} rather than @samp{--All----} near -the bottom right corner of the screen. - - The @key{SPC}, @key{DEL} and @kbd{b} commands exist to allow you to ``move -around'' in a node that does not all fit on the screen at once. -@key{SPC} moves forward, to show what was below the bottom of the screen. -@key{DEL} moves backward, to show what was above the top of the screen -(there is not anything above the top until you have typed some spaces). - ->> Now try typing a @key{SPC} (afterward, type a @key{DEL} to return here). - - When you type the @key{SPC}, the two lines that were at the bottom -of the screen appear at the top, followed by more lines. @key{DEL} -takes the two lines from the top and moves them to the bottom, -@emph{usually}, but if there are not a full screen's worth of lines above -them they may not make it all the way to the bottom. - - If you type a @key{SPC} when there is no more to see, it rings the -bell and otherwise does nothing. The same goes for a @key{DEL} when -the header of the node is visible. - - If your screen is ever garbaged, you can tell Info to print it out -again by typing @kbd{C-l} (@kbd{Control-L}, that is---hold down ``Control'' and -type an @key{L} or @kbd{l}). - ->> Type @kbd{C-l} now. - - To move back to the beginning of the node you are on, you can type -a lot of @key{DEL}s. You can also type simply @kbd{b} for beginning. - ->> Try that now. (I have put in enough verbiage to make sure you are - not on the first screenful now). Then come back, typing @key{SPC} - several times. - - You have just learned a considerable number of commands. If you -want to use one but have trouble remembering which, you should type -a @key{?} which prints out a brief list of commands. When you are -finished looking at the list, make it go away by typing a @key{SPC}. - ->> Type a @key{?} now. After it finishes, type a @key{SPC}. - - (If you are using the standalone Info reader, type `l' to return here.) - - From now on, you will encounter large nodes without warning, and -will be expected to know how to use @key{SPC} and @key{DEL} to move -around in them without being told. Since not all terminals have -the same size screen, it would be impossible to warn you anyway. - ->> Now type @kbd{n} to see the description of the @kbd{m} command. - -@node Help-M, Help-Adv, Help-^L, Getting Started -@comment node-name, next, previous, up -@section Menus - -Menus and the @kbd{m} command - - With only the @kbd{n} and @kbd{p} commands for moving between nodes, nodes -are restricted to a linear sequence. Menus allow a branching -structure. A menu is a list of other nodes you can move to. It is -actually just part of the text of the node formatted specially so that -Info can interpret it. The beginning of a menu is always identified -by a line which starts with @samp{* Menu:}. A node contains a menu if and -only if it has a line in it which starts that way. The only menu you -can use at any moment is the one in the node you are in. To use a -menu in any other node, you must move to that node first. - - After the start of the menu, each line that starts with a @samp{*} -identifies one subtopic. The line usually contains a brief name -for the subtopic (followed by a @samp{:}), the name of the node that talks -about that subtopic, and optionally some further description of the -subtopic. Lines in the menu that do not start with a @samp{*} have no -special meaning---they are only for the human reader's benefit and do -not define additional subtopics. Here is an example: - -@example -* Foo: FOO's Node This tells about FOO -@end example - -The subtopic name is Foo, and the node describing it is @samp{FOO's Node}. -The rest of the line is just for the reader's Information. -[[ But this line is not a real menu item, simply because there is -no line above it which starts with @samp{* Menu:}.]] - - When you use a menu to go to another node (in a way that will be -described soon), what you specify is the subtopic name, the first -thing in the menu line. Info uses it to find the menu line, extracts -the node name from it, and goes to that node. The reason that there -is both a subtopic name and a node name is that the node name must be -meaningful to the computer and may therefore have to be ugly looking. -The subtopic name can be chosen just to be convenient for the user to -specify. Often the node name is convenient for the user to specify -and so both it and the subtopic name are the same. There is an -abbreviation for this: - -@example -* Foo:: This tells about FOO -@end example - -@noindent -This means that the subtopic name and node name are the same; they are -both @samp{Foo}. - ->> Now use @key{SPC}s to find the menu in this node, then come back to - the front with a @kbd{b}. As you see, a menu is actually visible in - its node. If you cannot find a menu in a node by looking at it, - then the node does not have a menu and the @kbd{m} command is not - available. - - The command to go to one of the subnodes is @kbd{m}---but @emph{do not do it -yet!} Before you use @kbd{m}, you must understand the difference between -commands and arguments. So far, you have learned several commands -that do not need arguments. When you type one, Info processes it and -is instantly ready for another command. The @kbd{m} command is different: -it is incomplete without the @dfn{name of the subtopic}. Once you have -typed @kbd{m}, Info tries to read the subtopic name. - - Now look for the line containing many dashes near the bottom of the -screen. There is one more line beneath that one, but usually it is -blank If it is empty, Info is ready for a command, such as @kbd{n} or @kbd{b} -or @key{SPC} or @kbd{m}. If that line contains text ending in a colon, it -mean Info is trying to read the @dfn{argument} to a command. At such -times, commands do not work, because Info tries to use them as the -argument. You must either type the argument and finish the command -you started, or type @kbd{Control-g} to cancel the command. When you have -done one of those things, the line becomes blank again. - - The command to go to a subnode via a menu is @kbd{m}. After you type -the @kbd{m}, the line at the bottom of the screen says @samp{Menu item: }. -You must then type the name of the subtopic you want, and end it with -a @key{RET}. - - You can abbreviate the subtopic name. If the abbreviation is not -unique, the first matching subtopic is chosen. Some menus put -the shortest possible abbreviation for each subtopic name in capital -letters, so you can see how much you need to type. It does not -matter whether you use upper case or lower case when you type the -subtopic. You should not put any spaces at the end, or inside of the -item name, except for one space where a space appears in the item in -the menu. - - Here is a menu to give you a chance to practice. - -* Menu: The menu starts here. - -This menu givs you three ways of going to one place, Help-FOO. - -* Foo: Help-FOO. A node you can visit for fun.@* -* Bar: Help-FOO. Strange! two ways to get to the same place.@* -* Help-FOO:: And yet another!@* - - ->> Now type just an @kbd{m} and see what happens: - - Now you are ``inside'' an @kbd{m} command. Commands cannot be used -now; the next thing you will type must be the name of a subtopic. - - You can change your mind about doing the @kbd{m} by typing Control-g. - ->> Try that now; notice the bottom line clear. - ->> Then type another @kbd{m}. - ->> Now type @samp{BAR} item name. Do not type @key{RET} yet. - - While you are typing the item name, you can use the @key{DEL} -character to cancel one character at a time if you make a mistake. - ->> Type one to cancel the @samp{R}. You could type another @samp{R} to - replace it. You do not have to, since @samp{BA} is a valid abbreviation. - ->> Now you are ready to go. Type a @key{RET}. - - After visiting Help-FOO, you should return here. - ->> Type @kbd{n} to see more commands. - -@c If a menu appears at the end of this node, remove it. -@c It is an accident of the menu updating command. - -Here is another way to get to Help-FOO, a menu. You can ignore this -if you want, or else try it (but then please come back to here). - -@menu -* Help-FOO:: -@end menu - -@node Help-FOO, , , Help-M -@comment node-name, next, previous, up -@subsection The @kbd{u} command - - Congratulations! This is the node @samp{Help-FOO}. Unlike the other -nodes you have seen, this one has an @samp{Up}: @samp{Help-M}, the node you -just came from via the @kbd{m} command. This is the usual -convention---the nodes you reach from a menu have @samp{Up} nodes that lead -back to the menu. Menus move Down in the tree, and @samp{Up} moves Up. -@samp{Previous}, on the other hand, is usually used to ``stay on the same -level but go backwards'' - - You can go back to the node @samp{Help-M} by typing the command -@kbd{u} for ``Up''. That puts you at the @emph{front} of the -node---to get back to where you were reading you have to type -some @key{SPC}s. - ->> Now type @kbd{u} to move back up to @samp{Help-M}. - -@node Help-Adv, Help-Q, Help-M, Getting Started -@comment node-name, next, previous, up -@section Some advanced Info commands - - The course is almost over, so please stick with it to the end. - - If you have been moving around to different nodes and wish to -retrace your steps, the @kbd{l} command (@kbd{l} for @dfn{last}) will -do that, one node at a time. If you have been following directions, -an @kbd{l} command now will get you back to @samp{Help-M}. Another -@kbd{l} command would undo the @kbd{u} and get you back to -@samp{Help-FOO}. Another @kbd{l} would undo the @kbd{m} and get you -back to @samp{Help-M}. - ->> Try typing three @kbd{l}'s, pausing in between to see what each - @kbd{l} does. - -Then follow directions again and you will end up back here. - - Note the difference between @kbd{l} and @kbd{p}: @kbd{l} moves to -where @emph{you} last were, whereas @kbd{p} always moves to the node -which the header says is the @samp{Previous} node (from this node, to -@samp{Help-M}). - - The @samp{d} command gets you instantly to the Directory node. -This node, which is the first one you saw when you entered Info, -has a menu which leads (directly, or indirectly through other menus), -to all the nodes that exist. - ->> Try doing a @samp{d}, then do an @kbd{l} to return here (yes, - @emph{do} return). - - Sometimes, in Info documentation, you will see a cross reference. -Cross references look like this: @xref{Help-Cross, Cross}. That is a -real, live cross reference which is named @samp{Cross} and points at -the node named @samp{Help-Cross}. - - If you wish to follow a cross reference, you must use the @samp{f} -command. The @samp{f} must be followed by the cross reference name -(in this case, @samp{Cross}). You can use @key{DEL} to edit the name, -and if you change your mind about following any reference you can use -@kbd{Control-g} to cancel the command. - - Completion is available in the @samp{f} command; you can complete among -all the cross reference names in the current node. - ->> Type @samp{f}, followed by @samp{Cross}, and a @key{RET}. - - To get a list of all the cross references in the current node, you can -type @kbd{?} after an @samp{f}. The @samp{f} continues to await a -cross reference name even after printing the list, so if you do not -actually want to follow a reference you should type a @kbd{Control-g} -to cancel the @samp{f}. - ->> Type "f?" to get a list of the footnotes in this node. Then type a - @kbd{Control-g} and see how the @samp{f} gives up. - ->> Now type @kbd{n} to see the last node of the course. - -@c If a menu appears at the end of this node, remove it. -@c It is an accident of the menu updating command. - -@node Help-Cross, , , Help-Adv -@comment node-name, next, previous, up -@unnumberedsubsec The node reached by the cross reference in Info - - This is the node reached by the cross reference named @samp{Cross}. - - While this node is specifically intended to be reached by a cross -reference, most cross references lead to nodes that ``belong'' -someplace else far away in the structure of Info. So you cannot expect -the footnote to have a @samp{Next}, @samp{Previous} or @samp{Up} pointing back to -where you came from. In general, the @kbd{l} (el) command is the only -way to get back there. - ->> Type @kbd{l} to return to the node where the cross reference was. - -@node Help-Q, , Help-Adv, Getting Started -@comment node-name, next, previous, up -@section Quitting Info - - To get out of Info, back to what you were doing before, type @kbd{q} -for @dfn{Quit}. - - This is the end of the course on using Info. There are some other -commands that are not essential or are meant for experienced users; -they are useful, and you can find them by looking in the directory for -documentation on Info. Finding them will be a good exercise in using -Info in the usual manner. - ->> Type @samp{d} to go to the Info directory node; then type - @samp{mInfo} and @key{RET}, to get to the node about Info - and see what other help is available. - -@node Advanced Info, Create an Info File, Getting Started, Top -@comment node-name, next, previous, up -@chapter Info for Experts - -This chapter describes various advanced Info commands, and how to write -an Info as distinct from a Texinfo file. (However, in most cases, writing a -Texinfo file is better, since you can use it @emph{both} to generate an -Info file and to make a printed manual. @xref{Top,, Overview of -Texinfo, texinfo, Texinfo: The GNU Documentation Format}.) - -@menu -* Expert:: Advanced Info commands: g, s, e, and 1 - 5. -* Add:: Describes how to add new nodes to the hierarchy. - Also tells what nodes look like. -* Menus:: How to add to or create menus in Info nodes. -* Cross-refs:: How to add cross-references to Info nodes. -* Tags:: How to make tag tables for Info files. -* Checking:: Checking an Info File -@end menu - -@node Expert, Add, , Advanced Info -@comment node-name, next, previous, up -@section Advanced Info Commands - -@kbd{g}, @kbd{s}, @kbd{1}, -- @kbd{5}, and @kbd{e} - -If you know a node's name, you can go there by typing @kbd{g}, the -name, and @key{RET}. Thus, @kbd{gTop@key{RET}} would go to the node -called @samp{Top} in this file (its directory node). -@kbd{gExpert@key{RET}} would come back here. - -Unlike @kbd{m}, @kbd{g} does not allow the use of abbreviations. - -To go to a node in another file, you can include the filename in the -node name by putting it at the front, in parentheses. Thus, -@kbd{g(dir)Top@key{RET}} would go to the Info Directory node, which is -node @samp{Top} in the file @file{dir}. - -The node name @samp{*} specifies the whole file. So you can look at -all of the current file by typing @kbd{g*@key{RET}} or all of any -other file with @kbd{g(FILENAME)@key{RET}}. - -The @kbd{s} command allows you to search a whole file for a string. -It switches to the next node if and when that is necessary. You -type @kbd{s} followed by the string to search for, terminated by -@key{RET}. To search for the same string again, just @kbd{s} followed -by @key{RET} will do. The file's nodes are scanned in the order -they are in in the file, which has no necessary relationship to the -order that they may be in in the tree structure of menus and @samp{next} pointers. -But normally the two orders are not very different. In any case, -you can always do a @kbd{b} to find out what node you have reached, if -the header is not visible (this can happen, because @kbd{s} puts your -cursor at the occurrence of the string, not at the beginning of the -node). - -If you grudge the system each character of type-in it requires, you -might like to use the commands @kbd{1}, @kbd{2}, @kbd{3}, @kbd{4}, and -@kbd{5}. They are short for the @kbd{m} command together with an -argument. "1", "2", "3", "4", and "5". @kbd{1} goes through the -first item in the current node's menu; @kbd{2} goes through the second -item, etc. Note that numbers larger than 5 are not allowed. If the -item you want is that far down, you are better off using an -abbreviation for its name than counting. - -The Info command @kbd{e} changes from Info mode to an ordinary -Emacs editing mode, so that you can edit the text of the current node. -Type @kbd{C-c C-c} to switch back to Info. The @kbd{e} command is allowed -only if the variable @code{Info-enable-edit} is non-@code{nil}. - -@node Add, Menus, Expert, Advanced Info -@comment node-name, next, previous, up -@section Adding a new node to Info - -To add a new topic to the list in the directory, you must: - -@enumerate -@item -Create a node, in some file, to document that topic. - -@item -Put that topic in the menu in the directory. @xref{Menus, Menu}. -@end enumerate - - The new node can live in an existing documentation file, or in a new -one. It must have a @key{^_} character before it (invisible to the -user; this node has one but you cannot see it), and it ends with either -a @key{^_}, a @key{^L}, or the end of file. Note: If you put in a -@key{^L} to end a new node, be sure that there is a @key{^_} after it -to start the next one, since @key{^L} cannot @emph{start} a node. -Also, a nicer way to make a node boundary be a page boundary as well -is to put a @key{^L} @emph{right after} the @key{^_}. - - The @key{^_} starting a node must be followed by a newline or a -@key{^L} newline, after which comes the node's header line. The -header line must give the node's name (by which Info finds it), -and state the names of the @samp{Next}, @samp{Previous}, and @samp{Up} nodes (if -there are any). As you can see, this node's @samp{Up} node is the node -@samp{Top}, which points at all the documentation for Info. The @samp{Next} -node is @samp{Menus}. - - The keywords @dfn{Node}, @dfn{Previous}, @dfn{Up} and @dfn{Next}, -may appear in any order, anywhere in the header line, but the -recommended order is the one in this sentence. Each keyword must be -followed by a colon, spaces and tabs, and then the appropriate name. -The name may be terminated with a tab, a comma, or a newline. A space -does not end it; node names may contain spaces. The case of letters -in the names is insignificant. - - A node name has two forms. A node in the current file is named by -what appears after the @samp{Node: } in that node's first line. For -example, this node's name is @samp{Add}. A node in another file is -named by @samp{(@var{filename})@var{node-within-file}}, as in -@samp{(info)Add} for this node. If the file name is relative, it is -taken starting from the standard Info file directory of your site. -The name @samp{(@var{filename})Top} can be abbreviated to just -@samp{(@var{filename})}. By convention, the name @samp{Top} is used for -the ``highest'' node in any single file---the node whose @samp{Up} points -out of the file. The Directory node is @file{(dir)}. The @samp{Top} node -of a document file listed in the Directory should have an @samp{Up: -(dir)} in it. - - The node name @kbd{*} is special: it refers to the entire file. -Thus, @kbd{g*} shows you the whole current file. The use of the -node @kbd{*} is to make it possible to make old-fashioned, -unstructured files into nodes of the tree. - - The @samp{Node:} name, in which a node states its own name, must not -contain a filename, since Info when searching for a node does not -expect one to be there. The @samp{Next}, @samp{Previous} and @samp{Up} names may -contain them. In this node, since the @samp{Up} node is in the same file, -it was not necessary to use one. - - Note that the nodes in this file have a file name in the header -line. The file names are ignored by Info, but they serve as comments -to help identify the node for the user. - -@node Menus, Cross-refs, Add, Advanced Info -@comment node-name, next, previous, up -@section How to Create Menus - - Any node in the Info hierarchy may have a @dfn{menu}---a list of subnodes. -The @kbd{m} command searches the current node's menu for the topic which it -reads from the terminal. - - A menu begins with a line starting with @samp{* Menu:}. The rest of the -line is a comment. After the starting line, every line that begins -with a @samp{* } lists a single topic. The name of the topic--the -argument that the user must give to the @kbd{m} command to select this -topic---comes right after the star and space, and is followed by a -colon, spaces and tabs, and the name of the node which discusses that -topic. The node name, like node names following @samp{Next}, @samp{Previous} -and @samp{Up}, may be terminated with a tab, comma, or newline; it may also -be terminated with a period. - - If the node name and topic name are the same, than rather than -giving the name twice, the abbreviation @samp{* NAME::} may be used -(and should be used, whenever possible, as it reduces the visual -clutter in the menu). - - It is considerate to choose the topic names so that they differ -from each other very near the beginning---this allows the user to type -short abbreviations. In a long menu, it is a good idea to capitalize -the beginning of each item name which is the minimum acceptable -abbreviation for it (a long menu is more than 5 or so entries). - - The nodes listed in a node's menu are called its ``subnodes'', and -it is their ``superior''. They should each have an @samp{Up:} pointing at -the superior. It is often useful to arrange all or most of the -subnodes in a sequence of @samp{Next} and @samp{Previous} pointers so that someone who -wants to see them all need not keep revisiting the Menu. - - The Info Directory is simply the menu of the node @samp{(dir)Top}---that -is, node @samp{Top} in file @file{.../info/dir}. You can put new entries -in that menu just like any other menu. The Info Directory is @emph{not} the -same as the file directory called @file{info}. It happens that many of -Info's files live on that file directory, but they do not have to; and -files on that directory are not automatically listed in the Info -Directory node. - - Also, although the Info node graph is claimed to be a ``hierarchy'', -in fact it can be @emph{any} directed graph. Shared structures and -pointer cycles are perfectly possible, and can be used if they are -appropriate to the meaning to be expressed. There is no need for all -the nodes in a file to form a connected structure. In fact, this file -has two connected components. You are in one of them, which is under -the node @samp{Top}; the other contains the node @samp{Help} which the -@kbd{h} command goes to. In fact, since there is no garbage -collector, nothing terrible happens if a substructure is not pointed -to, but such a substructure is rather useless since nobody can -ever find out that it exists. - -@node Cross-refs, Tags, Menus, Advanced Info -@comment node-name, next, previous, up -@section Creating Cross References - - A cross reference can be placed anywhere in the text, unlike a menu -item which must go at the front of a line. A cross reference looks -like a menu item except that it has @samp{*note} instead of @kbd{*}. -It @emph{cannot} be terminated by a @samp{)}, because @samp{)}'s are -so often part of node names. If you wish to enclose a cross reference -in parentheses, terminate it with a period first. Here are two -examples of cross references pointers: - -@example -*Note details: commands. (See *note 3: Full Proof.) -@end example - -They are just examples. The places they ``lead to'' do not really exist! - -@node Tags, Checking, Cross-refs, Advanced Info -@comment node-name, next, previous, up -@section Tag Tables for Info Files - - You can speed up the access to nodes of a large Info file by giving -it a tag table. Unlike the tag table for a program, the tag table for -an Info file lives inside the file itself and is used -automatically whenever Info reads in the file. - - To make a tag table, go to a node in the file using Emacs Info mode and type -@kbd{M-x Info-tagify}. Then you must use @kbd{C-x C-s} to save the -file. - - Once the Info file has a tag table, you must make certain it is up -to date. If, as a result of deletion of text, any node moves back -more than a thousand characters in the file from the position -recorded in the tag table, Info will no longer be able to find that -node. To update the tag table, use the @code{Info-tagify} command again. - - An Info file tag table appears at the end of the file and looks like -this: - -@example -^_ -Tag Table: -File: info, Node: Cross-refs^?21419 -File: info, Node: Tags^?22145 -^_ -End Tag Table -@end example - -@noindent -Note that it contains one line per node, and this line contains -the beginning of the node's header (ending just after the node name), -a @key{DEL} character, and the character position in the file of the -beginning of the node. - -@node Checking, , Tags, Advanced Info -@comment node-name, next, previous, up -@section Checking an Info File - - When creating an Info file, it is easy to forget the name of a node -when you are making a pointer to it from another node. If you put in -the wrong name for a node, this is not detected until someone -tries to go through the pointer using Info. Verification of the Info -file is an automatic process which checks all pointers to nodes and -reports any pointers which are invalid. Every @samp{Next}, @samp{Previous}, and -@samp{Up} is checked, as is every menu item and every cross reference. In -addition, any @samp{Next} which does not have a @samp{Previous} pointing back is -reported. Only pointers within the file are checked, because checking -pointers to other files would be terribly slow. But those are usually -few. - - To check an Info file, do @kbd{M-x Info-validate} while looking at -any node of the file with Emacs Info mode. - -@node Create an Info File, , Advanced Info, Top -@comment node-name, next, previous, up -@chapter Creating an Info File from a Makeinfo file - -@code{makeinfo} is a utility that converts a Texinfo file into an Info -file; @code{texinfo-format-region} and @code{texinfo-format-buffer} are -GNU Emacs functions that do the same. - -@xref{Create an Info File, , Creating an Info File, texinfo, the Texinfo -Manual}, to learn how to create an Info file from a Texinfo file. - -@xref{Top,, Overview of Texinfo, texinfo, Texinfo: The GNU Documentation -Format}, to learn how to write a Texinfo file. - -@bye - diff --git a/gnu/usr.bin/texinfo/info-files/texi-files/makeinfo.texi b/gnu/usr.bin/texinfo/info-files/texi-files/makeinfo.texi deleted file mode 100644 index 21ee2d3c869f..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi-files/makeinfo.texi +++ /dev/null @@ -1,285 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header -@setfilename makeinfo.info -@set VERSION 1.51 -@paragraphindent none -@comment %**start of header - -@ifinfo -This file is an extract from the @cite{Texinfo} manual.@* -It documents @code{makeinfo}, a program that converts Texinfo -files into Info files. - -Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end ifinfo - -@titlepage -@title Makeinfo -@author Brian J. Fox and Robert J. Chassell - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993 Free Software Foundation, Inc. - - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end titlepage - -@ifinfo -@node Top, What is makeinfo, (dir), (dir) -@unnumbered @code{makeinfo} - -This file documents the use of the @code{makeinfo} program, versions -@value{VERSION} and later. It is an extract from the @cite{Texinfo} manual. -@end ifinfo - -@menu -* What is makeinfo:: -@end menu - -@node What is makeinfo, , Top, Top -@chapter What is @code{makeinfo}? - -@iftex -This file documents the use of the @code{makeinfo} program, versions -@value{VERSION} and later. It is an extract from the @cite{Texinfo} manual. -@end iftex - -@code{makeinfo} is a program for converting @dfn{Texinfo} files into @dfn{Info} -files. Texinfo is a documentation system that uses a single source file to -produce both on-line information and printed output. - -You can read the on-line information using Info; type @code{info} to -learn about Info. -@ifinfo -@xref{Top, Texinfo, Overview of Texinfo, texinfo.texi, Texinfo}, -@end ifinfo -@iftex -See the @cite{Texinfo} manual, -@end iftex -to learn about the Texinfo documentation system. - -@menu -* Formatting Control:: -* Options:: -* Pointer Validation:: -@end menu - -@node Formatting Control, Options, , What is makeinfo -@section Controlling Paragraph Formats - -In general, @code{makeinfo} @dfn{fills} the paragraphs that it outputs -to an Info file. Filling is the process of breaking and connecting -lines so that lines are the same length as or shorter than the number -specified as the fill column. Lines are broken between words. With -@code{makeinfo}, you can control: - -@itemize @bullet -@item -The width of each paragraph (the @dfn{fill-column}). -@item -The amount of indentation that the first line of -each paragraph receives (the @dfn{paragraph-indentation}). -@end itemize - -@node Options, Pointer Validation, Formatting Control, What is makeinfo -@section Command Line Options - -The following command line options are available for @code{makeinfo}. - -@need 100 -@table @code -@item -D @var{var} -Cause @var{var} to be defined. This is equivalent to -@code{@@set @var{var}} in the Texinfo file. - -@need 150 -@item --error-limit @var{limit} -Set the maximum number of errors that @code{makeinfo} will report -before exiting (on the assumption that continuing would be useless). -The default number of errors that can be reported before -@code{makeinfo} gives up is 100.@refill - -@need 150 -@item --fill-column @var{width} -Specify the maximum number of columns in a line; this is the right-hand -edge of a line. Paragraphs that are filled will be filled to this -width. The default value for @code{fill-column} is 72. -@refill - -@item --footnote-style @var{style} -Set the footnote style to @var{style}, either @samp{end} for the end -node style or @samp{separate} for the separate node style. The value -set by this option overrides the value set in a Texinfo file by an -@code{@@footnotestyle} command. When the footnote style is -@samp{separate}, @code{makeinfo} makes a new node containing the -footnotes found in the current node. When the footnote style is -@samp{end}, @code{makeinfo} places the footnote references at the end -of the current node.@refill - -@need 150 -@item -I @var{dir} -Add @code{dir} to the directory search list for finding files that are -included using the @code{@@include} command. By default, -@code{makeinfo} searches only the current directory. - -@need 150 -@item --no-headers -Do not include menus or node lines in the output. This results in an -@sc{ascii} file that you cannot read in Info since it does not contain -the requisite nodes or menus; but you can print such a file in a -single, typewriter-like font and produce acceptable output. - -@need 150 -@item --no-split -Suppress the splitting stage of @code{makeinfo}. Normally, large -output files (where the size is greater than 70k bytes) are split into -smaller subfiles, each one approximately 50k bytes. If you specify -@samp{--no-split}, @code{makeinfo} will not split up the output -file.@refill - -@need 100 -@item --no-pointer-validate -@item --no-validate -Suppress the pointer-validation phase of @code{makeinfo}. Normally, -after a Texinfo file is processed, some consistency checks are made to -ensure that cross references can be resolved, etc. -@xref{Pointer Validation}.@refill - -@need 150 -@item --no-warn -Suppress the output of warning messages. This does @emph{not} -suppress the output of error messages, only warnings. You might -want this if the file you are creating has examples of Texinfo cross -references within it, and the nodes that are referenced do not actually -exist.@refill - -@item --no-number-footnotes -Supress automatic footnote numbering. By default, @code{makeinfo} -numbers each footnote sequentially in a single node, resetting the -current footnote number to 1 at the start of each node. - -@need 150 -@item --output @var{file} -@itemx -o @var{file} -Specify that the output should be directed to @var{file} and not to the -file name specified in the @code{@@setfilename} command found in the Texinfo -source. @var{file} can be the special token @samp{-}, which specifies -standard output. - -@need 150 -@item --paragraph-indent @var{indent} -Set the paragraph indentation style to @var{indent}. The value set by -this option overrides the value set in a Texinfo file by an -@code{@@paragraphindent} command. The value of @var{indent} is -interpreted as follows:@refill - -@itemize @bullet -@item -If the value of @var{indent} is @samp{asis}, do not change the -existing indentation at the starts of paragraphs.@refill - -@item -If the value of @var{indent} is zero, delete any existing -indentation.@refill - -@item -If the value of @var{indent} is greater than zero, indent each -paragraph by that number of spaces.@refill -@end itemize - -@need 100 -@item --reference-limit @var{limit} -Set the value of the number of references to a node that -@code{makeinfo} will make without reporting a warning. If a node has more -than this number of references in it, @code{makeinfo} will make the -references but also report a warning.@refill - -@need 150 -@item -U @var{var} -Cause @var{var} to be undefined. This is equivalent to -@code{@@clear @var{var}} in the Texinfo file. - -@need 100 -@item --verbose -Cause @code{makeinfo} to display messages saying what it is doing. -Normally, @code{makeinfo} only outputs messages if there are errors or -warnings.@refill - -@need 100 -@item --version -Report the version number of this copy of @code{makeinfo}.@refill -@end table - -@node Pointer Validation, , Options, What is makeinfo -@section Pointer Validation -@cindex Pointer validation with @code{makeinfo} -@cindex Validation of pointers - -If you do not suppress pointer-validation (by using the -@samp{--no-pointer-validation} option), @code{makeinfo} -will check the validity of the final Info file. Mostly, -this means ensuring that nodes you have referenced -really exist. Here is a complete list of what is -checked:@refill - -@enumerate -@item -If a `Next', `Previous', or `Up' node reference is a reference to a -node in the current file and is not an external reference such as to -@file{(dir)}, then the referenced node must exist.@refill - -@item -In every node, if the `Previous' node is different from the `Up' node, -then the `Previous' node must also be pointed to by a `Next' node.@refill - -@item -Every node except the `Top' node must have an `Up' pointer.@refill - -@item -The node referenced by an `Up' pointer must contain a reference to the -current node in some manner other than through a `Next' reference. -This includes menu entries and cross references.@refill - -@item -If the `Next' reference of a node is not the same as the `Next' reference -of the `Up' reference, then the node referenced by the `Next' pointer -must have a `Previous' pointer that points back to the current node. -This rule allows the last node in a section to point to the first node -of the next chapter.@refill -@end enumerate - -@bye diff --git a/gnu/usr.bin/texinfo/info-files/texi-files/texi.texi b/gnu/usr.bin/texinfo/info-files/texi-files/texi.texi deleted file mode 100644 index f77f66245a3b..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi-files/texi.texi +++ /dev/null @@ -1,15626 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header -@setfilename texi.info -@settitle Texinfo @value{edition} -@syncodeindex vr fn -@c footnotestyle separate -@c paragraphindent 2 -@smallbook -@comment %**end of header - -@ignore -@ifinfo -@format -START-INFO-DIR-ENTRY -* Texinfo: (texi.info). The documentation format for the GNU Project. -END-INFO-DIR-ENTRY -@end format -@end ifinfo -@end ignore - -@c Set smallbook if printing in smallbook format so the example of the -@c smallbook font is actually written using smallbook; in bigbook, a kludge -@c is used for TeX output. -@c set smallbook -@clear smallbook - -@set edition 2.18 -@set update-date 26 March 1993 -@set update-month March 1993 - -@c Experiment with smaller amounts of whitespace between chapters -@c and sections. -@tex -\global\chapheadingskip = 15pt plus 4pt minus 2pt -\global\secheadingskip = 12pt plus 3pt minus 2pt -\global\subsecheadingskip = 9pt plus 2pt minus 2pt -@end tex - -@c Experiment with smaller amounts of whitespace between paragraphs in -@c the 8.5 by 11 inch format. -@ifclear smallbook -@tex -\global\parskip 6pt plus 1pt -@end tex -@end ifclear - -@finalout - -@c Currently undocumented commands, 24 March 1993: -@c See documentation in `texinfmt.el' file. -@c -@c raisesections (Two useful commands.) -@c lowersections -@c nwnode (Same as node, but no warnings; for `makeinfo'.) -@c math (Unsatisfactory TeX definition; no processing for Info.) -@c definfoenclose (For ifinfo text only; not supported by `makeinfo'; -@c each instance requires a corresponding TeX definition.) - -@ifinfo -This file documents Texinfo, a documentation system that uses a single -source file to produce both on-line information and a printed manual. - -Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - -This is the second edition of the Texinfo documentation,@* -and is consistent with version 2 of @file{texinfo.tex}. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end ifinfo - -@setchapternewpage odd -@titlepage -@c use the new format for titles -@title Texinfo -@subtitle The GNU Documentation Format -@subtitle Edition @value{edition}, for Texinfo Version Two -@subtitle @value{update-month} - -@author by Robert J. Chassell and Richard M. Stallman - -@comment Include the Distribution inside the titlepage so -@c that headings are turned off. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - -@sp 2 -This is the second edition of the Texinfo documentation,@* -and is consistent with version 2 of @file{texinfo.tex}. -@sp 2 - -Published by the Free Software Foundation @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 USA @* -Printed copies are available for $15 each.@* -ISBN-1882114-12-4 - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@sp 2 -Cover art by Etienne Suvasa. -@end titlepage - -@ifinfo -@node Top, Copying, (dir), (dir) -@top Texinfo - -Texinfo is a documentation system that uses a single source file to -produce both on-line information and printed output.@refill - -The first part of this master menu lists the major nodes in this Info -document, including the @@-command and concept indices. The rest of -the menu lists all the lower level nodes in the document.@refill - -This is Edition @value{edition} of the Texinfo documentation, -@w{@value{update-date},} for Texinfo Version 2. -@end ifinfo - -@c Here is a spare copy of the chapter menu entry descriptions, -@c in case they are accidently deleted -@ignore -Your rights. -Texinfo in brief. -How to use Texinfo mode. -What is at the beginning of a Texinfo file? -What is at the end of a Texinfo file? -How to create chapters, sections, subsections, - appendices, and other parts. -How to provide structure for a document. -How to write nodes. -How to write menus. -How to write cross references. -How to mark words and phrases as code, - keyboard input, meta-syntactic - variables, and the like. -How to write quotations, examples, etc. -How to write lists and tables. -How to create indices. -How to insert @@-signs, braces, etc. -How to indicate results of evaluation, - expansion of macros, errors, etc. -How to force and prevent line and page breaks. -How to describe functions and the like in a uniform manner. -How to write footnotes. -How to specify text for either @TeX{} or Info. -How to print hardcopy. -How to create an Info file. -How to install an Info file -A list of all the Texinfo @@-commands. -Hints on how to write a Texinfo document. -A sample Texinfo file to look at. -Tell readers they have the right to copy - and distribute. -How to incorporate other Texinfo files. -How to write page headings and footings. -How to find formatting mistakes. -All about paragraph refilling. -A description of @@-Command syntax. -Texinfo second edition features. -A menu containing commands and variables. -A menu covering many topics. -@end ignore - -@menu -* Copying:: Your rights. -* Overview:: Texinfo in brief. -* Texinfo Mode:: How to use Texinfo mode. -* Beginning a File:: What is at the beginning of a Texinfo file? -* Ending a File:: What is at the end of a Texinfo file? -* Structuring:: How to create chapters, sections, subsections, - appendices, and other parts. -* Nodes:: How to write nodes. -* Menus:: How to write menus. -* Cross References:: How to write cross references. -* Marking Text:: How to mark words and phrases as code, - keyboard input, meta-syntactic - variables, and the like. -* Quotations and Examples:: How to write quotations, examples, etc. -* Lists and Tables:: How to write lists and tables. -* Indices:: How to create indices. -* Insertions:: How to insert @@-signs, braces, etc. -* Glyphs:: How to indicate results of evaluation, - expansion of macros, errors, etc. -* Breaks:: How to force and prevent line and page breaks. -* Definition Commands:: How to describe functions and the like - in a uniform manner. -* Footnotes:: How to write footnotes. -* Conditionals:: How to specify text for either @TeX{} or Info. -* Format/Print Hardcopy:: How to convert a Texinfo file to a file - for printing and how to print that file. -* Create an Info File:: Convert a Texinfo file into an Info file. -* Install an Info File:: Make an Info file accessible to users. -* Command List:: All the Texinfo @@-commands. -* Tips:: Hints on how to write a Texinfo document. -* Sample Texinfo File:: A sample Texinfo file to look at. -* Sample Permissions:: Tell readers they have the right to copy - and distribute. -* Include Files:: How to incorporate other Texinfo files. -* Headings:: How to write page headings and footings. -* Catching Mistakes:: How to find formatting mistakes. -* Refilling Paragraphs:: All about paragraph refilling. -* Command Syntax:: A description of @@-Command syntax. -* Obtaining TeX:: How to Obtain @TeX{}. -* New Features:: Texinfo second edition features. -* Command and Variable Index:: A menu containing commands and variables. -* Concept Index:: A menu covering many topics. - - --- The Detailed Node Listing --- - -Overview of Texinfo - -* Using Texinfo:: Create a conventional printed book - or an Info file. -* Info Files:: What is an Info file? -* Printed Books:: Characteristics of a printed book or manual. -* Formatting Commands:: @@-commands are used for formatting. -* Conventions:: General rules for writing a Texinfo file. -* Comments:: How to write comments and mark regions that - the formatting commands will ignore. -* Minimum:: What a Texinfo file must have. -* Six Parts:: Usually, a Texinfo file has six parts. -* Short Sample:: A short sample Texinfo file. -* Acknowledgements:: - -Using Texinfo Mode - -* Texinfo Mode Overview:: How Texinfo mode can help you. -* Emacs Editing:: Texinfo mode adds to GNU Emacs' general - purpose editing features. -* Inserting:: How to insert frequently used @@-commands. -* Showing the Structure:: How to show the structure of a file. -* Updating Nodes and Menus:: How to update or create new nodes and menus. -* Info Formatting:: How to format for Info. -* Printing:: How to format and print part or all of a file. -* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. - -Updating Nodes and Menus - -* Updating Commands:: Five major updating commands. -* Updating Requirements:: How to structure a Texinfo file for - using the updating command. -* Other Updating Commands:: How to indent descriptions, insert - missing nodes lines, and update - nodes in sequence. - -Beginning a Texinfo File - -* Four Parts:: Four parts begin a Texinfo file. -* Sample Beginning:: Here is a sample beginning for a Texinfo file. -* Header:: The very beginning of a Texinfo file. -* Info Summary and Permissions:: Summary and copying permissions for Info. -* Titlepage & Copyright Page:: Creating the title and copyright pages. -* The Top Node:: Creating the `Top' node and master menu. -* Software Copying Permissions:: Ensure that you and others continue to - have the right to use and share software. - -The Texinfo File Header - -* First Line:: The first line of a Texinfo file. -* Start of Header:: Formatting a region requires this. -* setfilename:: Tell Info the name of the Info file. -* settitle:: Create a title for the printed work. -* setchapternewpage:: Start chapters on right-hand pages. -* paragraphindent:: An option to specify paragraph indentation. -* End of Header:: Formatting a region requires this. - -The Title and Copyright Pages - -* titlepage:: Create a title for the printed document. -* titlefont center sp:: The @code{@@titlefont}, @code{@@center}, - and @code{@@sp} commands. -* title subtitle author:: The @code{@@title}, @code{@@subtitle}, - and @code{@@author} commands. -* Copyright & Permissions:: How to write the copyright notice and - include copying permissions. -* end titlepage:: Turn on page headings after the title and - copyright pages. -* headings on off:: An option for turning headings on and off - and double or single sided printing. - -The `Top' Node and Master Menu - -* Title of Top Node:: Sketch what the file is about. -* Master Menu Parts:: A master menu has three or more parts. - -Ending a Texinfo File - -* Printing Indices & Menus:: How to print an index in hardcopy and - generate index menus in Info. -* Contents:: How to create a table of contents. -* File End:: How to mark the end of a file. - -Chapter Structuring - -* Tree Structuring:: A manual is like an upside down tree @dots{} -* Structuring Command Types:: How to divide a manual into parts. -* makeinfo top:: The @code{@@top} command, part of the `Top' node. -* chapter:: -* unnumbered & appendix:: -* majorheading & chapheading:: -* section:: -* unnumberedsec appendixsec heading:: -* subsection:: -* unnumberedsubsec appendixsubsec subheading:: -* subsubsection:: Commands for the lowest level sections. - -Nodes - -* Two Paths:: Different commands to structure - Info output and printed output. -* Node Menu Illustration:: A diagram, and sample nodes and menus. -* node:: How to write a node, in detail. -* makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. - -The @code{@@node} Command - -* Node Names:: How to choose node and pointer names. -* Writing a Node:: How to write an @code{@@node} line. -* Node Line Tips:: Keep names short. -* Node Line Requirements:: Keep names unique, without @@-commands. -* First Node:: How to write a `Top' node. -* makeinfo top command:: How to use the @code{@@top} command. -* Top Node Summary:: Write a brief description for readers. - -Menus - -* Menu Location:: Put a menu in a short node. -* Writing a Menu:: What is a menu? -* Menu Parts:: A menu entry has three parts. -* Less Cluttered Menu Entry:: Two part menu entry. -* Menu Example:: Two and three part menu entries. -* Other Info Files:: How to refer to a different Info file. - -Cross References - -* References:: What cross references are for. -* Cross Reference Commands:: A summary of the different commands. -* Cross Reference Parts:: A cross reference has several parts. -* xref:: Begin a reference with `See' @dots{} -* Top Node Naming:: How to refer to the beginning of another file. -* ref:: A reference for the last part of a sentence. -* pxref:: How to write a parenthetical cross reference. -* inforef:: How to refer to an Info-only file. - -@code{@@xref} - -* Reference Syntax:: What a reference looks like and requires. -* One Argument:: @code{@@xref} with one argument. -* Two Arguments:: @code{@@xref} with two arguments. -* Three Arguments:: @code{@@xref} with three arguments. -* Four and Five Arguments:: @code{@@xref} with four and five arguments. - -Marking Words and Phrases - -* Indicating:: How to indicate definitions, files, etc. -* Emphasis:: How to emphasize text. - -Indicating Definitions, Commands, etc. - -* Useful Highlighting:: Highlighting provides useful information. -* code:: How to indicate code. -* kbd:: How to show keyboard input. -* key:: How to specify keys. -* samp:: How to show a literal sequence of characters. -* var:: How to indicate a metasyntactic variable. -* file:: How to indicate the name of a file. -* dfn:: How to specify a definition. -* cite:: How to refer to a book that is not in Info. - -Emphasizing Text - -* emph & strong:: How to emphasize text in Texinfo. -* Smallcaps:: How to use the small caps font. -* Fonts:: Various font commands for printed output. - -Quotations and Examples - -* Block Enclosing Commands:: Use different constructs for - different purposes. -* quotation:: How to write a quotation. -* example:: How to write an example in a fixed-width font. -* noindent:: How to prevent paragraph indentation. -* Lisp Example:: How to illustrate Lisp code. -* smallexample & smalllisp:: Forms for the @code{@@smallbook} option. -* display:: How to write an example in the current font. -* format:: How to write an example that does not narrow - the margins. -* exdent:: How to undo the indentation of a line. -* flushleft & flushright:: How to push text flushleft or flushright. -* cartouche:: How to draw cartouches around examples. - -Making Lists and Tables - -* Introducing Lists:: Texinfo formats lists for you. -* itemize:: How to construct a simple list. -* enumerate:: How to construct a numbered list. -* Two-column Tables:: How to construct a two-column table. - -Making a Two-column Table - -* table:: How to construct a two-column table. -* ftable vtable:: How to construct a two-column table - with automatic indexing. -* itemx:: How to put more entries in the first column. - -Creating Indices - -* Index Entries:: Choose different words for index entries. -* Predefined Indices:: Use different indices for different kinds - of entry. -* Indexing Commands:: How to make an index entry. -* Combining Indices:: How to combine indices. -* New Indices:: How to define your own indices. - -Combining Indices - -* syncodeindex:: How to merge two indices, using @code{@@code} - font for the merged-from index. -* synindex:: How to merge two indices, using the - default font of the merged-to index. - -Special Insertions - -* Braces Atsigns Periods:: How to insert braces, @samp{@@} and periods. -* dmn:: How to format a dimension. -* Dots Bullets:: How to insert dots and bullets. -* TeX and copyright:: How to insert the @TeX{} logo - and the copyright symbol. -* minus:: How to insert a minus sign. - -Inserting @samp{@@}, Braces, and Periods - -* Inserting An Atsign:: -* Inserting Braces:: How to insert @samp{@{} and @samp{@}} -* Controlling Spacing:: How to insert the right amount of space - after punctuation within a sentence. - -Inserting Ellipsis, Dots, and Bullets - -* dots:: How to insert dots @dots{} -* bullet:: How to insert a bullet. - -Inserting @TeX{} and the Copyright Symbol - -* tex:: How to insert the @TeX{} logo. -* copyright symbol:: How to use @code{@@copyright}@{@}. - -Glyphs for Examples - -* Glyphs Summary:: -* result:: How to show the result of expression. -* expansion:: How to indicate an expansion. -* Print Glyph:: How to indicate printed output. -* Error Glyph:: How to indicate an error message. -* Equivalence:: How to indicate equivalence. -* Point Glyph:: How to indicate the location of point. - -Making and Preventing Breaks - -* Break Commands:: Cause and prevent splits. -* Line Breaks:: How to force a single line to use two lines. -* w:: How to prevent unwanted line breaks. -* sp:: How to insert blank lines. -* page:: How to force the start of a new page. -* group:: How to prevent unwanted page breaks. -* need:: Another way to prevent unwanted page breaks. - -Definition Commands - -* Def Cmd Template:: How to structure a description using a - definition command. -* Optional Arguments:: How to handle optional and repeated arguments. -* deffnx:: How to group two or more `first' lines. -* Def Cmds in Detail:: All the definition commands. -* Def Cmd Conventions:: Conventions for writing definitions. -* Sample Function Definition:: - -The Definition Commands - -* Functions Commands:: Commands for functions and similar entities. -* Variables Commands:: Commands for variables and similar entities. -* Typed Functions:: Commands for functions in typed languages. -* Typed Variables:: Commands for variables in typed languages. -* Abstract Objects:: Commands for object-oriented programming. -* Data Types:: The definition command for data types. - -Conditionally Visible Text - -* Conditional Commands:: How to specify text for Info or @TeX{}. -* Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. -* set clear value:: How to designate which text to format (for - both Info and @TeX{}); and how to set a - flag to a string that you can insert. - -@code{@@set}, @code{@@clear}, and @code{@@value} - -* ifset ifclear:: Format a region if a flag is set. -* value:: Replace a flag with a string. -* value Example:: An easy way to update edition information. - -Format and Print Hardcopy - -* Use TeX:: Use @TeX{} to format for hardcopy. -* Shell Format & Print:: How to format and print a hardcopy manual - with shell commands. -* Within Emacs:: How to format and print from an Emacs shell. -* Texinfo Mode Printing:: How to format and print in Texinfo mode. -* Compile-Command:: How to print using Emacs's compile command. -* Requirements Summary:: @TeX{} formatting requirements summary. -* Preparing for TeX:: What you need to do to use @TeX{}. -* Overfull hboxes:: What are and what to do with overfull hboxes. -* smallbook:: How to print small format books and manuals. -* A4 Paper:: How to print on European A4 paper. -* Cropmarks and Magnification:: How to print marks to indicate the size - of pages and how to print scaled up output. - -Creating an Info File - -* makeinfo advantages:: @code{makeinfo} provides better error checking. -* Invoking makeinfo:: How to run @code{makeinfo} from a shell. -* makeinfo options:: Specify fill-column and other options. -* Pointer Validation:: How to check that pointers point somewhere. -* makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. -* texinfo-format commands:: Two Info formatting commands written - in Emacs Lisp are an alternative - to @code{makeinfo}. -* Batch Formatting:: How to format for Info in Emacs Batch mode. -* Tag and Split Files:: How tagged and split files help Info - to run better. - -Installing an Info File - -* Directory file:: The top level menu for all Info files. -* New Info File:: Listing a new info file. -* Other Info Directories:: How to specify Info files that are - located in other directories. - -Sample Permissions - -* Inserting Permissions:: How to put permissions in your document. -* ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. -* Titlepage Permissions:: Sample Titlepage copying permissions. - -Include Files - -* Using Include Files:: How to use the @code{@@include} command. -* texinfo-multiple-files-update:: How to create and update nodes and - menus when using included files. -* Include File Requirements:: What @code{texinfo-multiple-files-update} expects. -* Sample Include File:: A sample outer file with included files - within it; and a sample included file. -* Include Files Evolution:: How use of the @code{@@include} command - has changed over time. - -Page Headings - -* Headings Introduced:: Conventions for using page headings. -* Heading Format:: Standard page heading formats. -* Heading Choice:: How to specify the type of page heading. -* Custom Headings:: How to create your own headings and footings. - -Formatting Mistakes - -* makeinfo preferred:: @code{makeinfo} finds errors. -* Debugging with Info:: How to catch errors with Info formatting. -* Debugging with TeX:: How to catch errors with @TeX{} formatting. -* Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. -* Using occur:: How to list all lines containing a pattern. -* Running Info-Validate:: How to find badly referenced nodes. - -Finding Badly Referenced Nodes - -* Using Info-validate:: How to run @code{Info-validate}. -* Unsplit:: How to create an unsplit file. -* Tagifying:: How to tagify a file. -* Splitting:: How to split a file manually. - -Second Edition Features - -* New Texinfo Mode Commands:: The updating commands are especially useful. -* New Commands:: Many newly described @@-commands. -@end menu - -@node Copying, Overview, Top, Top -@comment node-name, next, previous, up -@unnumbered Texinfo Copying Conditions -@cindex Copying conditions -@cindex Conditions for copying Texinfo - -The programs currently being distributed that relate to Texinfo include -portions of GNU Emacs, plus other separate programs (including -@code{makeinfo}, @code{info}, @code{texindex}, and @file{texinfo.tex}). -These programs are @dfn{free}; this means that everyone is free to use -them and free to redistribute them on a free basis. The Texinfo-related -programs are not in the public domain; they are copyrighted and there -are restrictions on their distribution, but these restrictions are -designed to permit everything that a good cooperating citizen would want -to do. What is not allowed is to try to prevent others from further -sharing any version of these programs that they might get from -you.@refill - - Specifically, we want to make sure that you have the right to give -away copies of the programs that relate to Texinfo, that you receive -source code or else can get it if you want it, that you can change these -programs or use pieces of them in new free programs, and that you know -you can do these things.@refill - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of the Texinfo related programs, you must give the recipients all -the rights that you have. You must make sure that they, too, receive or -can get the source code. And you must tell them their rights.@refill - - Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for the programs that relate to Texinfo. -If these programs are modified by someone else and passed on, we want -their recipients to know that what they have is not what we distributed, -so that any problems introduced by others will not reflect on our -reputation.@refill - - The precise conditions of the licenses for the programs currently -being distributed that relate to Texinfo are found in the General Public -Licenses that accompany them.@refill - -@node Overview, Texinfo Mode, Copying, Top -@comment node-name, next, previous, up -@chapter Overview of Texinfo -@cindex Overview of Texinfo -@cindex Texinfo overview - -@dfn{Texinfo}@footnote{Note that the first syllable of ``Texinfo'' is -pronounced like ``speck'', not ``hex''. This odd pronunciation is -derived from, but is not the same as, the pronunciation of @TeX{}. In -the word @TeX{}, the @samp{X} is actually the Greek letter ``chi'' -rather than the English letter ``ex''. Pronounce @TeX{} as if the -@samp{X} were the last sound in the name `Bach'; but pronounce Texinfo -as if the @samp{x} were a `k'. Spell ``Texinfo'' with a capital ``T'' -and write the other letters in lower case.} -is a documentation system that uses a single source file to produce both -on-line information and printed output. This means that instead of -writing two different documents, one for the on-line help or other on-line -information and the other for a typeset manual or other printed work, you -need write only one document. When the work is revised, you need revise -only one document. (You can read the on-line information, known as an -@dfn{Info file}, with an Info documentation-reading program.)@refill - -@menu -* Using Texinfo:: Create a conventional printed book - or an Info file. -* Info Files:: What is an Info file? -* Printed Books:: Characteristics of a printed book or manual. -* Formatting Commands:: @@-commands are used for formatting. -* Conventions:: General rules for writing a Texinfo file. -* Comments:: How to write comments and mark regions that - the formatting commands will ignore. -* Minimum:: What a Texinfo file must have. -* Six Parts:: Usually, a Texinfo file has six parts. -* Short Sample:: A short sample Texinfo file. -* Acknowledgements:: -@end menu - -@node Using Texinfo, Info Files, , Overview -@ifinfo -@heading Using Texinfo -@end ifinfo - -Using Texinfo, you can create a printed document with the normal -features of a book, including chapters, sections, cross references, -and indices. From the same Texinfo source file, you can create a -menu-driven, on-line Info file with nodes, menus, cross references, -and indices. You can, if you wish, make the chapters and sections of -the printed document correspond to the nodes of the on-line -information; and you use the same cross references and indices for -both the Info file and the printed work. @cite{The GNU -Emacs Manual} is a good example of a Texinfo file, as is this manual.@refill - -To make a printed document, you process a Texinfo source file with the -@TeX{} typesetting program. This creates a @sc{dvi} file that you can -typeset and print as a book or report. (Note that the Texinfo language is -completely different from @TeX{}'s usual language, Plain@TeX{}, which -Texinfo replaces.) If you do not have @TeX{}, but do have -@code{troff} or @code{nroff}, you can use the @code{texi2roff} program -instead.@refill - -To make an Info file, you process a Texinfo source file with the -@code{makeinfo} utility or Emacs's @code{texinfo-format-buffer} command; -this creates an Info file that you can install on-line.@refill - -@TeX{} and @code{texi2roff} work with many types of printer; similarly, -Info works with almost every type of computer terminal. This power -makes Texinfo a general purpose system, but brings with it a constraint, -which is that a Texinfo file may contain only the customary -``typewriter'' characters (letters, numbers, spaces, and punctuation -marks) but no special graphics.@refill - -A Texinfo file is a plain @sc{ascii} file containing text and -@dfn{@@-commands} (words preceded by an @samp{@@}) that tell the -typesetting and formatting programs what to do. You may edit a -Texinfo file with any text editor; but it is especially convenient to -use GNU Emacs since that editor has a special mode, called Texinfo -mode, that provides various Texinfo-related features. (@xref{Texinfo -Mode}.)@refill - -Before writing a Texinfo source file, you should become familiar with -the Info documentation reading program and learn about nodes, -menus, cross references, and the rest. (@inforef{Top, info, info}, -for more information.)@refill - -You can use Texinfo to create both on-line help and printed manuals; -moreover, Texinfo is freely redistributable. For these reasons, Texinfo -is the format in which documentation for GNU utilities and libraries is -written.@refill - -@node Info Files, Printed Books, Using Texinfo, Overview -@comment node-name, next, previous, up -@section Info files -@cindex Info files - -An Info file is a Texinfo file formatted so that the Info documentation -reading program can operate on it. (@code{makeinfo} -and @code{texinfo-format-buffer} are two commands that convert a Texinfo file -into an Info file.)@refill - -Info files are divided into pieces called @dfn{nodes}, each of which -contains the discussion of one topic. Each node has a name, and -contains both text for the user to read and pointers to other nodes, -which are identified by their names. The Info program displays one node -at a time, and provides commands with which the user can move to other -related nodes.@refill - -@ifinfo -@inforef{Top, info, info}, for more information about using Info.@refill -@end ifinfo - -Each node of an Info file may have any number of child nodes that -describe subtopics of the node's topic. The names of child -nodes are listed in a @dfn{menu} within the parent node; this -allows you to use certain Info commands to move to one of the child -nodes. Generally, an Info file is organized like a book. If a node -is at the logical level of a chapter, its child nodes are at the level -of sections; likewise, the child nodes of sections are at the level -of subsections.@refill - -All the children of any one parent are linked together in a -bidirectional chain of `Next' and `Previous' pointers. The `Next' -pointer provides a link to the next section, and the `Previous' pointer -provides a link to the previous section. This means that all the nodes -that are at the level of sections within a chapter are linked together. -Normally the order in this chain is the same as the order of the -children in the parent's menu. Each child node records the parent node -name as its `Up' pointer. The last child has no `Next' pointer, and the -first child has the parent both as its `Previous' and as its `Up' -pointer.@footnote{In some documents, the first child has no `Previous' -pointer. Occasionally, the last child has the node name of the next -following higher level node as its `Next' pointer.}@refill - -The book-like structuring of an Info file into nodes that correspond -to chapters, sections, and the like is a matter of convention, not a -requirement. The `Up', `Previous', and `Next' pointers of a node can -point to any other nodes, and a menu can contain any other nodes. -Thus, the node structure can be any directed graph. But it is usually -more comprehensible to follow a structure that corresponds to the -structure of chapters and sections in a printed book or report.@refill - -In addition to menus and to `Next', `Previous', and `Up' pointers, Info -provides pointers of another kind, called references, that can be -sprinkled throughout the text. This is usually the best way to -represent links that do not fit a hierarchical structure.@refill - -Usually, you will design a document so that its nodes match the -structure of chapters and sections in the printed output. But there -are times when this is not right for the material being discussed. -Therefore, Texinfo uses separate commands to specify the node -structure for the Info file and the section structure for the printed -output.@refill - -Generally, you enter an Info file through a node that by convention is -called @samp{Top}. This node normally contains just a brief summary -of the file's purpose, and a large menu through which the rest of the -file is reached. From this node, you can either traverse the file -systematically by going from node to node, or you can go to a specific -node listed in the main menu, or you can search the index menus and -then go directly to the node that has the information you want.@refill -@c !!! With the standalone Info system you may go to specific nodes -@c directly.. - -If you want to read through an Info file in sequence, as if it were a -printed manual, you can get the whole file with the advanced Info -command @kbd{g* @key{RET}}. (@inforef{Expert, Advanced Info commands, -info}.)@refill - -@c !!! dir file may be located in one of many places: -@c /usr/local/emacs/info mentioned in info.c DEFAULT_INFOPATH -@c /usr/local/lib/emacs/info mentioned in info.c DEFAULT_INFOPATH -@c /usr/gnu/info mentioned in info.c DEFAULT_INFOPATH -@c /usr/local/info -@c /usr/local/lib/info -The @file{dir} file in the @file{info} directory serves as the -departure point for the whole Info system. From it, you can reach the -`Top' nodes of each of the documents in a complete Info system.@refill - -@node Printed Books, Formatting Commands, Info Files, Overview -@comment node-name, next, previous, up -@section Printed Books -@cindex Printed book and manual characteristics -@cindex Manual characteristics, printed -@cindex Book characteristics, printed -@cindex Texinfo printed book characteristics -@cindex Characteristics, printed books or manuals - -A Texinfo file can be formatted and typeset as a printed book or manual. -To do this, you need @TeX{}, a powerful, sophisticated typesetting -program written by Donald Knuth.@footnote{You can also use the -@code{texi2roff} program if you do not have @TeX{}; since Texinfo is -designed for use with @TeX{}, @code{texi2roff} is not described here. -@code{texi2roff} is part of the standard GNU distribution.}@refill - -A Texinfo-based book is similar to any other typeset, printed work: it -can have a title page, copyright page, table of contents, and preface, -as well as chapters, numbered or unnumbered sections and subsections, -page headers, cross references, footnotes, and indices.@refill - -You can use Texinfo to write a book without ever having the intention -of converting it into on-line information. You can use Texinfo for -writing a printed novel, and even to write a printed memo, although -this latter application is not recommended since electronic mail is so -much easier.@refill - -@TeX{} is a general purpose typesetting program. Texinfo provides a -file called @file{texinfo.tex} that contains information (definitions or -@dfn{macros}) that @TeX{} uses when it typesets a Texinfo file. -(@file{texinfo.tex} tells @TeX{} how to convert the Texinfo @@-commands -to @TeX{} commands, which @TeX{} can then process to create the typeset -document.) @file{texinfo.tex} contains the specifications for printing -a document.@refill - -Most often, documents are printed on 8.5 inch by 11 inch -pages (216@dmn{mm} by 280@dmn{mm}; this is the default size), but you -can also print for 7 inch by 9.25 inch pages (178@dmn{mm} by -235@dmn{mm}; the @code{@@smallbook} size) or on European A4 size paper -(@code{@@afourpaper}). (@xref{smallbook, , Printing ``Small'' Books}. -Also, see @ref{A4 Paper, ,Printing on A4 Paper}.)@refill - -By changing the parameters in @file{texinfo.tex}, you can change the -size of the printed document. In addition, you can change the style in -which the printed document is formatted; for example, you can change the -sizes and fonts used, the amount of indentation for each paragraph, the -degree to which words are hyphenated, and the like. By changing the -specifications, you can make a book look dignified, old and serious, or -light-hearted, young and cheery.@refill - -@TeX{} is freely distributable. It is written in a dialect of Pascal -called WEB and can be compiled either in Pascal or (by using a -conversion program that comes with the @TeX{} distribution) in C. -(@xref{TeX Mode, ,@TeX{} Mode, emacs, The GNU Emacs Manual}, for information -about @TeX{}.)@refill - -@TeX{} is very powerful and has a great many features. Because a -Texinfo file must be able to present information both on a -character-only terminal in Info form and in a typeset book, the -formatting commands that Texinfo supports are necessarily -limited.@refill - -@xref{Obtaining TeX, , How to Obtain @TeX{}}. - - -@node Formatting Commands, Conventions, Printed Books, Overview -@comment node-name, next, previous, up -@section @@-commands -@cindex @@-commands -@cindex Formatting commands - -In a Texinfo file, the commands that tell @TeX{} how to typeset the -printed manual and tell @code{makeinfo} and -@code{texinfo-format-buffer} how to create an Info file are preceded -by @samp{@@}; they are called @dfn{@@-commands}. For example, -@code{@@node} is the command to indicate a node and @code{@@chapter} -is the command to indicate the start of a chapter.@refill - -@quotation -@strong{Please note:} All the @@-commands, with the exception of the -@code{@@TeX@{@}} command, must be written entirely in lower -case.@refill -@end quotation - -The Texinfo @@-commands are a strictly limited set of constructs. The -strict limits make it possible for Texinfo files to be understood both -by @TeX{} and by the code that converts them into Info files. You can -display Info files on any terminal that displays alphabetic and -numeric characters. Similarly, you can print the output generated by -@TeX{} on a wide variety of printers.@refill - -Depending on what they do or what arguments@footnote{The word -@dfn{argument} comes from the way it is used in mathematics and does -not refer to a disputation between two people; it refers to the -information presented to the command. According to the @cite{Oxford -English Dictionary}, the word derives from the Latin for @dfn{to make -clear, prove}; thus it came to mean `the evidence offered as proof', -which is to say, `the information offered', which led to its -mathematical meaning. In its other thread of derivation, the word -came to mean `to assert in a manner against which others may make -counter assertions', which led to the meaning of `argument' as a -disputation.} they take, you need to write @@-commands on lines of -their own or as part of sentences:@refill - -@itemize @bullet -@item -Write a command such as @code{@@noindent} at the beginning of a line as -the only text on the line. (@code{@@noindent} prevents the beginning of -the next line from being indented as the beginning of a -paragraph.)@refill - -@item -Write a command such as @code{@@chapter} at the beginning of a line -followed by the command's arguments, in this case the chapter title, on -the rest of the line. (@code{@@chapter} creates chapter titles.)@refill - -@item -Write a command such as @code{@@dots@{@}} wherever you wish but usually -within a sentence. (@code{@@dots@{@}} creates dots @dots{})@refill - -@item -Write a command such as @code{@@code@{@var{sample-code}@}} wherever you -wish (but usually within a sentence) with its argument, -@var{sample-code} in this example, between the braces. (@code{@@code} -marks text as being code.)@refill - -@item -Write a command such as @code{@@example} at the beginning of a line of -its own; write the body-text on following lines; and write the matching -@code{@@end} command, @code{@@end example} in this case, at the -beginning of a line of its own after the body-text. (@code{@@example} -@dots{} @code{@@end example} indents and typesets body-text as an -example.)@refill -@end itemize - -@noindent -@cindex Braces, when to use -As a general rule, a command requires braces if it mingles among other -text; but it does not need braces if it starts a line of its own. The -non-alphabetic commands, such as @code{@@:}, are exceptions to the rule; -they do not need braces.@refill - -As you gain experience with Texinfo, you will rapidly learn how to -write the different commands: the different ways to write commands -make it easier to write and read Texinfo files than if all commands -followed exactly the same syntax. (For details about @@-command -syntax, see @ref{Command Syntax, , @@-Command Syntax}.)@refill - -@node Conventions, Comments, Formatting Commands, Overview -@comment node-name, next, previous, up -@section General Syntactic Conventions -@cindex General syntactic conventions -@cindex Syntactic conventions -@cindex Conventions, syntactic - -All @sc{ascii} printing characters except @samp{@@}, @samp{@{} and -@samp{@}} can appear in a Texinfo file and stand for themselves. -@samp{@@} is the escape character which introduces commands. -@samp{@{} and @samp{@}} should be used only to surround arguments to -certain commands. To put one of these special characters into the -document, put an @samp{@@} character in front of it, like this: -@samp{@@@@}, @samp{@@@{}, and @samp{@@@}}.@refill - -@ifinfo -It is customary in @TeX{} to use doubled single-quote characters to -begin and end quotations: ` ` and ' ' (but without a space between the -two single-quote characters). This convention should be followed in -Texinfo files. @TeX{} converts doubled single-quote characters to -left- and right-hand doubled quotation marks and Info converts doubled -single-quote characters to @sc{ascii} double-quotes: ` ` and ' ' to " .@refill -@end ifinfo -@iftex -It is customary in @TeX{} to use doubled single-quote characters to -begin and end quotations: @w{@tt{ `` }} and @w{@tt{ '' }}. This -convention should be followed in Texinfo files. @TeX{} converts -doubled single-quote characters to left- and right-hand doubled -quotation marks, ``like this'', and Info converts doubled single-quote -characters to @sc{ascii} double-quotes: @w{@tt{ `` }} and -@w{@tt{ '' }} to @w{@tt{ " }}.@refill -@end iftex - -Use three hyphens in a row, @samp{---}, for a dash---like this. In -@TeX{}, a single or even a double hyphen produces a printed dash that -is shorter than the usual typeset dash. Info reduces three hyphens to two for -display on the screen.@refill - -To prevent a paragraph from being indented in the printed manual, put -the command @code{@@noindent} on a line by itself before the -paragraph.@refill - -If you mark off a region of the Texinfo file with the @code{@@iftex} -and @w{@code{@@end iftex}} commands, that region will appear only in -the printed copy; in that region, you can use certain commands -borrowed from Plain@TeX{} that you cannot use in Info. Likewise, if -you mark off a region with the @code{@@ifinfo} and @code{@@end ifinfo} -commands, that region will appear only in the Info file; in that -region, you can use Info commands that you cannot use in @TeX{}. -(@xref{Conditionals}.) - -@cindex Tabs; don't use! -@quotation -@strong{Caution:} Do not use tabs in a Texinfo file! @TeX{} uses -variable-width fonts, which means that it cannot predefine a tab to work -in all circumstances. Consequently, @TeX{} treats tabs like single -spaces, and that is not what they look like.@refill - -@noindent -To avoid this problem, Texinfo mode causes GNU Emacs to insert multiple -spaces when you press the @key{TAB} key.@refill - -@noindent -Also, you can run @code{untabify} in Emacs to convert tabs in a region -to multiple spaces.@refill -@end quotation - -@node Comments, Minimum, Conventions, Overview -@comment node-name, next, previous, up -@section Comments - -You can write comments in a Texinfo file that will not appear in -either the Info file or the printed manual by using the -@code{@@comment} command (which may be abbreviated to @code{@@c}). -Such comments are for the person who reads the Texinfo file. All the -text on a line that follows either @code{@@comment} or @code{@@c} is a -comment; the rest of the line does not appear in either the Info file -or the printed manual. (Often, you can write the @code{@@comment} or -@code{@@c} in the middle of a line, and only the text that follows after -the @code{@@comment} or @code{@@c} command does not appear; but some -commands, such as @code{@@settitle} and @code{@@setfilename}, work on a -whole line. You cannot use @code{@@comment} or @code{@@c} in a line -beginning with such a command.)@refill -@cindex Comments -@findex comment -@findex c @r{(comment)} - -You can write long stretches of text that will not appear in either -the Info file or the printed manual by using the @code{@@ignore} and -@code{@@end ignore} commands. Write each of these commands on a line -of its own, starting each command at the beginning of the line. Text -between these two commands does not appear in the processed output. -You can use @code{@@ignore} and @code{@@end ignore} for writing -comments. Often, @code{@@ignore} and @code{@@end ignore} is used -to enclose a part of the copying permissions that applies to the -Texinfo source file of a document, but not to the Info or printed -version of the document.@refill -@cindex Ignored text -@cindex Unprocessed text -@findex ignore -@c !!! Perhaps include this comment about ignore and ifset: -@ignore -Text enclosed by @code{@@ignore} or by failing @code{@@ifset} or -@code{@@ifclear} conditions is ignored in the sense that it will not -contribute to the formatted output. However, TeX and makeinfo must -still parse the ignored text, in order to understand when to -@emph{stop} ignoring text from the source file; that means that you -will still get error messages if you have invalid Texinfo markup -within ignored text. -@end ignore - -@node Minimum, Six Parts, Comments, Overview -@comment node-name, next, previous, up -@section What a Texinfo File Must Have -@cindex Minimal Texinfo file (requirements) -@cindex Must have in Texinfo file -@cindex Required in Texinfo file -@cindex Texinfo file minimum - -By convention, the names of Texinfo files end with one of the -extensions @file{.texinfo}, @file{.texi}, or @file{.tex}. The longer -extension is preferred since it describes more clearly to a human -reader the nature of the file. The shorter extensions are for -operating systems that cannot handle long file names.@refill - -In order to be made into a printed manual and an Info file, a -Texinfo file @strong{must} begin with lines like this:@refill - -@example -@group -\input texinfo -@@setfilename @var{info-file-name} -@@settitle @var{name-of-manual} -@end group -@end example - -@noindent -The contents of the file follow this beginning, and then you @strong{must} end -a Texinfo file with a line like this:@refill - -@example -@@bye -@end example - -@findex input @r{(@TeX{} command)} -@noindent -The @samp{\input texinfo} line tells @TeX{} to use the -@file{texinfo.tex} file, which tells @TeX{} how to translate the Texinfo -@@-commands into @TeX{} typesetting commands. (Note the use of the -backslash, @samp{\}; this is correct for @TeX{}.) The -@samp{@@setfilename} line provides a name for the Info file and the -@samp{@@settitle} line specifies a title for the page headers (or -footers) of the printed manual.@refill - -The @code{@@bye} line at the end of the file on a line of its own tells -the formatters that the file is ended and to stop formatting.@refill - -Usually, you will not use quite such a spare format, but will include -mode setting and start-of-header and end-of-header lines at the -beginning of a Texinfo file, like this:@refill - -@example -@group -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename @var{info-file-name} -@@settitle @var{name-of-manual} -@@c %**end of header -@end group -@end example - -@noindent -In the first line, @samp{-*-texinfo-*-} causes Emacs to switch into -Texinfo mode when you edit the file. - -The @code{@@c} lines which surround the @samp{@@setfilename} and -@samp{@@settitle} lines are optional, but you need them in order to -run @TeX{} or Info on just part of the file. (@xref{Start of Header}, -for more information.)@refill - -Furthermore, you will usually provide a Texinfo file with a title -page, indices, and the like. But the minimum, which can be useful -for short documents, is just the three lines at the beginning and the -one line at the end.@refill - -@node Six Parts, Short Sample, Minimum, Overview -@comment node-name, next, previous, up -@section Six Parts of a Texinfo File - -Generally, a Texinfo file contains more than the minimal -beginning and end---it usually contains six parts:@refill - -@table @r -@item 1. Header -The @dfn{Header} names the file, tells @TeX{} which definitions' file to -use, and performs other ``housekeeping'' tasks.@refill - -@item 2. Summary Description and Copyright -The @dfn{Summary Description and Copyright} segment describes the document -and contains the copyright notice and copying permissions for the Info -file. The segment must be enclosed between @code{@@ifinfo} and -@code{@@end ifinfo} commands so that the formatters place it only in the Info -file.@refill - -@item 3. Title and Copyright -The @dfn{Title and Copyright} segment contains the title and copyright pages -and copying permissions for the printed manual. The segment must be -enclosed between @code{@@titlepage} and @code{@@end titlepage} commands. -The title and copyright page appear only in the printed @w{manual}.@refill - -@item 4. `Top' Node and Master Menu -The @dfn{Master Menu} contains a complete menu of all the nodes in the whole -Info file. It appears only in the Info file, in the `Top' node.@refill - -@item 5. Body -The @dfn{Body} of the document may be structured like a traditional book or -encyclopedia or it may be free form.@refill - -@item 6. End -The @dfn{End} contains commands for printing indices and generating -the table of contents, and the @code{@@bye} command on a line of its -own.@refill -@end table - -@node Short Sample, Acknowledgements, Six Parts, Overview -@comment node-name, next, previous, up -@section A Short Sample Texinfo File -@cindex Sample Texinfo file - -Here is a complete but very short Texinfo file, in 6 parts. The first -three parts of the file, from @samp{\input texinfo} through to -@samp{@@end titlepage}, look more intimidating than they are. Most of -the material is standard boilerplate; when you write a manual, simply -insert the names for your own manual in this segment. (@xref{Beginning a -File}.)@refill - -@noindent -In the following, the sample text is @emph{indented}; comments on it are -not. The complete file, without any comments, is shown in -@ref{Sample Texinfo File}. - -@subheading Part 1: Header - -@noindent -The header does not appear in either the Info file or the@* -printed output. It sets various parameters, including the@* -name of the Info file and the title used in the header. - -@example -@group -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename sample.info -@@settitle Sample Document -@@c %**end of header - -@@setchapternewpage odd -@end group -@end example - -@subheading Part 2: Summary Description and Copyright - -@noindent -The summary description and copyright segment does not@* -appear in the printed document. - -@example -@group -@@ifinfo -This is a short example of a complete Texinfo file. - -Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. -@@end ifinfo -@end group -@end example - -@subheading Part 3: Titlepage and Copyright - -@noindent -The titlepage segment does not appear in the Info file. - -@example -@group -@@titlepage -@@sp 10 -@@comment The title is printed in a large font. -@@center @@titlefont@{Sample Title@} -@end group - -@group -@@c The following two commands start the copyright page. -@@page -@@vskip 0pt plus 1filll -Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. -@@end titlepage -@end group -@end example - -@subheading Part 4: `Top' Node and Master Menu - -@noindent -The `Top' node contains the master menu for the Info file.@* -Since a printed manual uses a table of contents rather than@* -a menu, the master menu appears only in the Info file. - -@example -@group -@@node Top, First Chapter, (dir), (dir) -@@comment node-name, next, previous, up -@end group -@end example - -@example -@group -@@menu -* First Chapter:: The first chapter is the - only chapter in this sample. -* Concept Index:: This index has two entries. -@@end menu -@end group -@end example - -@subheading Part 5: The Body of the Document - -@noindent -The body segment contains all the text of the document, but not the -indices or table of contents. This example illustrates a node and a -chapter containing an enumerated list.@refill - -@example -@group -@@node First Chapter, Concept Index, Top, Top -@@comment node-name, next, previous, up -@@chapter First Chapter -@@cindex Sample index entry -@end group - -@group -This is the contents of the first chapter. -@@cindex Another sample index entry -@end group - -@group -Here is a numbered list. - -@@enumerate -@@item -This is the first item. - -@@item -This is the second item. -@@end enumerate -@end group - -@group -The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} -commands transform a Texinfo file such as this into -an Info file; and @@TeX@{@} typesets it for a printed -manual. -@end group -@end example - -@subheading Part 6: The End of the Document - -@noindent -The end segment contains commands both for generating an index in a node -and unnumbered chapter of its own and for generating the table of -contents; and it contains the @code{@@bye} command that marks the end of -the document.@refill - -@example -@group -@@node Concept Index, , First Chapter, Top -@@comment node-name, next, previous, up -@@unnumbered Concept Index -@end group - -@group -@@printindex cp - -@@contents -@@bye -@end group -@end example - -@subheading The Results - -Here is what the contents of the first chapter of the sample look like: - -@sp 1 -@need 700 -@quotation -This is the contents of the first chapter. - -Here is a numbered list. - -@enumerate -@item -This is the first item. - -@item -This is the second item. -@end enumerate - -The @code{makeinfo} and @code{texinfo-format-buffer} -commands transform a Texinfo file such as this into -an Info file; and @TeX{} typesets it for a printed -manual. -@end quotation - -@node Acknowledgements, , Short Sample, Overview -@comment node-name, next, previous, up -@section Acknowledgements - -Richard M.@: Stallman wrote Edition 1.0 of this manual. -@w{Robert J.@: Chassell} revised and extended it, -starting with Edition 1.1. - -Our thanks go out to all who helped improve this work, particularly to -@w{Francois Pinard} and @w{David D.@: Zuhn}, who tirelessly recorded -and reported mistakes and obscurities; our special thanks go to -@w{Melissa Weisshaus} for her frequent and often tedious reviews of -nearly similar editions. Our mistakes are our own. - -@c ignore until mailing lists set up -@ignore -Please send suggestions and corrections to: - -@example -@group -@r{Internet address:} - bug-gnu-texinfo@@prep.ai.mit.edu - -@r{UUCP path:} - mit-eddie!prep.ai.mit.edu!bug-gnu-texinfo -@end group -@end example - -@noindent -Please include the manual's edition number in your messages. -@end ignore - -@node Texinfo Mode, Beginning a File, Overview, Top -@comment node-name, next, previous, up -@chapter Using Texinfo Mode -@cindex Texinfo mode -@cindex Mode, using Texinfo -@cindex GNU Emacs -@cindex Emacs - -You may edit a Texinfo file with any text editor you choose. A Texinfo -file is no different from any other @sc{ascii} file. However, GNU Emacs -comes with a special mode, called Texinfo -mode, that provides Emacs commands and tools to help ease your work.@refill - -This chapter describes features of GNU Emacs' Texinfo mode but not any -features of the Texinfo formatting language. If you are reading this -manual straight through from the beginning, you may want to skim through -this chapter briefly and come back to it after reading succeeding -chapters which describe the Texinfo formatting language in -detail.@refill - -@menu -* Texinfo Mode Overview:: How Texinfo mode can help you. -* Emacs Editing:: Texinfo mode adds to GNU Emacs' general - purpose editing features. -* Inserting:: How to insert frequently used @@-commands. -* Showing the Structure:: How to show the structure of a file. -* Updating Nodes and Menus:: How to update or create new nodes and menus. -* Info Formatting:: How to format for Info. -* Printing:: How to format and print part or all of a file. -* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. -@end menu - -@node Texinfo Mode Overview, Emacs Editing, , Texinfo Mode -@ifinfo -@heading Texinfo Mode Overview -@end ifinfo - -Texinfo mode provides special features for working with Texinfo -files:@refill - -@itemize @bullet -@item -Insert frequently used @@commands. @refill - -@item -Automatically create @code{@@node} lines. - -@item -Show the structure of a Texinfo source file.@refill - -@item -Automatically create or update the `Next',@* -`Previous', and `Up' pointers of a node. - -@item -Automatically create or update menus.@refill - -@item -Automatically create a master menu.@refill - -@item -Format a part or all of a file for Info.@refill - -@item -Typeset and print part or all of a file.@refill -@end itemize - -Perhaps the two most helpful features are those for inserting frequently -used @@-commands and for creating node pointers and menus.@refill - -@node Emacs Editing, Inserting, Texinfo Mode Overview, Texinfo Mode -@section The Usual GNU Emacs Editing Commands - -In most cases, the usual Text mode commands work the same in Texinfo -mode as they do in Text mode. Texinfo mode adds new editing commands -and tools to GNU Emacs' general purpose editing features. The major -difference concerns filling. In Texinfo mode, the paragraph -separation variable and syntax table are redefined so that Texinfo -commands that should be on lines of their own are not inadvertently -included in paragraphs. Thus, the @kbd{M-q} (@code{fill-paragraph}) -command will refill a paragraph but not mix an indexing command on a -line adjacent to it into the paragraph.@refill - -In addition, Texinfo mode sets the @code{page-delimiter} variable to -the value of @code{texinfo-chapter-level-regexp}; by default, this is -a regular expression matching the commands for chapters and their -equivalents, such as appendices. With this value for the page -delimiter, you can jump from chapter title to chapter title with the -@kbd{C-x ]} (@code{forward-page}) and @kbd{C-x [} -(@code{backward-page}) commands and narrow to a chapter with the -@kbd{C-x p} (@code{narrow-to-page}) command. (@xref{Pages, , ,emacs, -The GNU Emacs Manual}, for details about the page commands.)@refill - -You may name a Texinfo file however you wish, but the convention is to -end a Texinfo file name with one of the three extensions -@file{.texinfo}, @file{.texi}, or @file{.tex}. A longer extension is -preferred, since it is explicit, but a shorter extension may be -necessary for operating systems that limit the length of file names. -GNU Emacs automatically enters Texinfo mode when you visit a file with -a @file{.texinfo} or @file{.texi} -extension. Also, Emacs switches to Texinfo mode -when you visit a -file that has @samp{-*-texinfo-*-} in its first line. If ever you are -in another mode and wish to switch to Texinfo mode, type @code{M-x -texinfo-mode}.@refill - -Like all other Emacs features, you can customize or enhance Texinfo -mode as you wish. In particular, the keybindings are very easy to -change. The keybindings described here are the default or standard -ones.@refill - -@node Inserting, Showing the Structure, Emacs Editing, Texinfo Mode -@comment node-name, next, previous, up -@section Inserting Frequently Used Commands -@cindex Inserting frequently used commands -@cindex Frequently used commands, inserting -@cindex Commands, inserting them - -Texinfo mode provides commands to insert various frequently used -@@-commands into the buffer. You can use these commands to save -keystrokes.@refill - -The insert commands are invoked by typing @kbd{C-c} twice and then the -first letter of the @@-command:@refill - -@table @kbd -@item C-c C-c c -@itemx M-x texinfo-insert-@@code -@findex texinfo-insert-@@code -Insert @code{@@code@{@}} and put the -cursor between the braces.@refill - -@item C-c C-c d -@itemx M-x texinfo-insert-@@dfn -@findex texinfo-insert-@@dfn -Insert @code{@@dfn@{@}} and put the -cursor between the braces.@refill - -@item C-c C-c e -@itemx M-x texinfo-insert-@@end -@findex texinfo-insert-@@end -Insert @code{@@end} and attempt to insert the correct following word, -such as @samp{example} or @samp{table}. (This command does not handle -nested lists correctly, but inserts the word appropriate to the -immediately preceding list.)@refill - -@item C-c C-c i -@itemx M-x texinfo-insert-@@item -@findex texinfo-insert-@@item -Insert @code{@@item} and put the -cursor at the beginning of the next line.@refill - -@item C-c C-c k -@itemx M-x texinfo-insert-@@kbd -@findex texinfo-insert-@@kbd -Insert @code{@@kbd@{@}} and put the -cursor between the braces.@refill - -@item C-c C-c n -@itemx M-x texinfo-insert-@@node -@findex texinfo-insert-@@node -Insert @code{@@node} and a comment line -listing the sequence for the `Next', -`Previous', and `Up' nodes. -Leave point after the @code{@@node}.@refill - -@item C-c C-c o -@itemx M-x texinfo-insert-@@noindent -@findex texinfo-insert-@@noindent -Insert @code{@@noindent} and put the -cursor at the beginning of the next line.@refill - -@item C-c C-c s -@itemx M-x texinfo-insert-@@samp -@findex texinfo-insert-@@samp -Insert @code{@@samp@{@}} and put the -cursor between the braces.@refill - -@item C-c C-c t -@itemx M-x texinfo-insert-@@table -@findex texinfo-insert-@@table -Insert @code{@@table} followed by a @key{SPC} -and leave the cursor after the @key{SPC}.@refill - -@item C-c C-c v -@itemx M-x texinfo-insert-@@var -@findex texinfo-insert-@@var -Insert @code{@@var@{@}} and put the -cursor between the braces.@refill - -@item C-c C-c x -@itemx M-x texinfo-insert-@@example -@findex texinfo-insert-@@example -Insert @code{@@example} and put the -cursor at the beginning of the next line.@refill - -@c M-@{ was the binding for texinfo-insert-braces; -@c in Emacs 19, backward-paragraph will take this binding. -@item C-c C-c @{ -@itemx M-x texinfo-insert-braces -@findex texinfo-insert-braces -Insert @code{@{@}} and put the cursor between the braces.@refill - -@item C-c C-c @} -@itemx C-c C-c ] -@itemx M-x up-list -@findex up-list -Move from between a pair of braces forward past the closing brace. -Typing @kbd{C-c C-c ]} is easier than typing @kbd{C-c C-c @}}, which -is, however, more mnemonic; hence the two keybindings. (Also, you can -move out from between braces by typing @kbd{C-f}.)@refill -@end table - -To put a command such as @w{@code{@@code@{@dots{}@}}} around an -@emph{existing} word, position the cursor in front of the word and type -@kbd{C-u 1 C-c C-c c}. This makes it easy to edit existing plain text. -The value of the prefix argument tells Emacs how many words following -point to include between braces---1 for one word, 2 for two words, and -so on. Use a negative argument to enclose the previous word or words. -If you do not specify a prefix argument, Emacs inserts the @@-command -string and positions the cursor between the braces. This feature works -only for those @@-commands that operate on a word or words within one -line, such as @code{@@kbd} and @code{@@var}.@refill - -This set of insert commands was created after analyzing the frequency -with which different @@-commands are used in the @cite{GNU Emacs -Manual} and the @cite{GDB Manual}. If you wish to add your own insert -commands, you can bind a keyboard macro to a key, use abbreviations, -or extend the code in @file{texinfo.el}.@refill - -@findex texinfo-start-menu-description -@cindex Menu description, start -@cindex Description for menu, start -@kbd{C-c C-c C-d} (@code{texinfo-start-menu-description}) is an insert -command that works differently from the other insert commands. It -inserts a node's section or chapter title in the space for the -description in a menu entry line. (A menu entry has three parts, the -entry name, the node name, and the description. Only the node name is -required, but a description helps explain what the node is about. -@xref{Menu Parts, , The Parts of a Menu}.)@refill - -To use @code{texinfo-start-menu-description}, position point in a menu -entry line and type @kbd{C-c C-c C-d}. The command looks for and copies -the title that goes with the node name, and inserts the title as a -description; it positions point at beginning of the inserted text so you -can edit it. The function does not insert the title if the menu entry -line already contains a description.@refill - -This command is only an aid to writing descriptions; it does not do the -whole job. You must edit the inserted text since a title tends to use -the same words as a node name but a useful description uses different -words.@refill - -@node Showing the Structure, Updating Nodes and Menus, Inserting, Texinfo Mode -@comment node-name, next, previous, up -@section Showing the Section Structure of a File -@cindex Showing the section structure of a file -@cindex Section structure of a file, showing it -@cindex Structure of a file, showing it -@cindex Outline of file structure, showing it -@cindex Contents-like outline of file structure -@cindex File section structure, showing it -@cindex Texinfo file section structure, showing it - -You can show the section structure of a Texinfo file by using the -@kbd{C-c C-s} command (@code{texinfo-show-structure}). This command -shows the section structure of a Texinfo file by listing the lines -that begin with the @@-commands for @code{@@chapter}, -@code{@@section}, and the like. It constructs what amounts -to a table of contents. These lines are displayed in another buffer -called the @samp{*Occur*} buffer. In that buffer, you can position -the cursor over one of the lines and use the @kbd{C-c C-c} command -(@code{occur-mode-goto-occurrence}), to jump to the corresponding spot -in the Texinfo file.@refill - -@table @kbd -@item C-c C-s -@itemx M-x texinfo-show-structure -@findex texinfo-show-structure -Show the @code{@@chapter}, @code{@@section}, and such lines of a -Texinfo file.@refill - -@item C-c C-c -@itemx M-x occur-mode-goto-occurrence -@findex occur-mode-goto-occurrence -Go to the line in the Texinfo file corresponding to the line under the -cursor in the @file{*Occur*} buffer.@refill -@end table - -If you call @code{texinfo-show-structure} with a prefix argument by -typing @w{@kbd{C-u C-c C-s}}, it will list not only those lines with the -@@-commands for @code{@@chapter}, @code{@@section}, and the like, -but also the @code{@@node} lines. (This is how the -@code{texinfo-show-structure} command worked without an argument in -the first version of Texinfo. It was changed because @code{@@node} -lines clutter up the @samp{*Occur*} buffer and are usually not -needed.) You can use @code{texinfo-show-structure} with a prefix -argument to check whether the `Next', `Previous', and `Up' pointers of -an @code{@@node} line are correct.@refill - -Often, when you are working on a manual, you will be interested only -in the structure of the current chapter. In this case, you can mark -off the region of the buffer that you are interested in with the -@kbd{C-x n} (@code{narrow-to-region}) command and -@code{texinfo-show-structure} will work on only that region. To see -the whole buffer again, use @w{@kbd{C-x w}} (@code{widen}). -(@xref{Narrowing, , , emacs, The GNU Emacs Manual}, for more -information about the narrowing commands.)@refill - -@vindex page-delimiter -@cindex Page delimiter in Texinfo mode -In addition to providing the @code{texinfo-show-structure} command, -Texinfo mode sets the value of the page delimiter variable to match -the chapter-level @@-commands. This enables you to use the @kbd{C-x -]} (@code{forward-page}) and @kbd{C-x [} (@code{backward-page}) -commands to move forward and backward by chapter, and to use the -@kbd{C-x p} (@code{narrow-to-page}) command to narrow to a chapter. -@xref{Pages, , , emacs, The GNU Emacs Manual}, for more information -about the page commands.@refill - -@node Updating Nodes and Menus, Info Formatting, Showing the Structure, Texinfo Mode -@comment node-name, next, previous, up -@section Updating Nodes and Menus -@cindex Updating nodes and menus -@cindex Create nodes, menus automatically -@cindex Insert nodes, menus automatically -@cindex Automatically insert nodes, menus - -Texinfo mode provides commands for automatically creating or updating -menus and node pointers. The commands are called ``update'' commands -because their most frequent use is for updating a Texinfo file after -you have worked on it; but you can use them to insert the `Next', -`Previous', and `Up' pointers into an @code{@@node} line that has none and to -create menus in a file that has none.@refill - -If you do not use the updating commands, you need to write menus and -node pointers by hand, which is a tedious task.@refill - -@menu -* Updating Commands:: Five major updating commands. -* Updating Requirements:: How to structure a Texinfo file for - using the updating command. -* Other Updating Commands:: How to indent descriptions, insert - missing nodes lines, and update - nodes in sequence. -@end menu - -@node Updating Commands, Updating Requirements, , Updating Nodes and Menus -@ifinfo -@subheading The Updating Commands -@end ifinfo - -You can use the updating commands@refill - -@itemize @bullet -@item -to insert or update the `Next', `Previous', and `Up' pointers of a -node,@refill - -@item -to insert or update the menu for a section, and@refill - -@item -to create a master menu for a Texinfo source file.@refill -@end itemize - -You can also use the commands to update all the nodes and menus in a -region or in a whole Texinfo file.@refill - -The updating commands work only with conventional Texinfo files, which -are structured hierarchically like books. In such files, a structuring -command line must follow closely after each @code{@@node} line, except -for the `Top' @code{@@node} line. (A @dfn{structuring command line} is -a line beginning with @code{@@chapter}, @code{@@section}, or other -similar command.) - -You can write the structuring command line on the line that follows -immediately after an @code{@@node} line or else on the line that -follows after a single @code{@@comment} line or a single -@code{@@ifinfo} line. You cannot interpose more than one line between -the @code{@@node} line and the structuring command line; and you may -interpose only an @code{@@comment} line or an @code{@@ifinfo} line. - -Commands which work on a whole buffer require that the `Top' node be -followed by a node with an @code{@@chapter} or equivalent-level command. -Note that the menu updating commands will not create a main or master -menu for a Texinfo file that has only @code{@@chapter}-level nodes! The -menu updating commands only create menus @emph{within} nodes for lower level -nodes. To create a menu of chapters, you must provide a `Top' -node.@refill - -The menu updating commands remove menu entries that refer to other Info -files since they do not refer to nodes within the current buffer. This -is a deficiency. Rather than use menu entries, you can use cross -references to refer to other Info files. None of the updating commands -affect cross references.@refill - -Texinfo mode has five updating commands that are used most often: two -are for updating the node pointers or menu of a single node (or a -region); two are for updating every node pointer and menu in a file; -and one, the @code{texinfo-master-menu} command, is for creating a -master menu for a complete file, and optionally, for updating every -node and menu in the whole Texinfo file.@refill - -The @code{texinfo-master-menu} command is the primary command:@refill - -@table @kbd -@item C-c C-u m -@itemx M-x texinfo-master-menu -@findex texinfo-master-menu -Create or update a master menu that includes all the other menus -(incorporating the descriptions from pre-existing menus, if -any).@refill - -With an argument (prefix argument, @kbd{C-u,} if interactive), first create or -update all the nodes and all the regular menus in the buffer before -constructing the master menu. (@xref{The Top Node, , The Top Node and -Master Menu}, for more about a master menu.)@refill - -For @code{texinfo-master-menu} to work, the Texinfo file must have a -`Top' node and at least one subsequent node.@refill - -After extensively editing a Texinfo file, you can type the following: - -@example -C-u M-x texinfo-master-menu -@exdent or -C-u C-c C-u m -@end example - -@noindent -This updates all the nodes and menus completely and all at once.@refill -@end table - -The other major updating commands do smaller jobs and are designed for -the person who updates nodes and menus as he or she writes a Texinfo -file.@refill - -@need 1000 -The commands are:@refill - -@table @kbd -@item C-c C-u C-n -@itemx M-x texinfo-update-node -@findex texinfo-update-node -Insert the `Next', `Previous', and `Up' pointers for the node that point is -within (i.e., for the @code{@@node} line preceding point). If the -@code{@@node} line has pre-existing `Next', `Previous', or `Up' -pointers in it, the old pointers are removed and new ones inserted. -With an argument (prefix argument, @kbd{C-u}, if interactive), this command -updates all @code{@@node} lines in the region (which is the text -between point and mark).@refill - -@item C-c C-u C-m -@itemx M-x texinfo-make-menu -@findex texinfo-make-menu -Create or update the menu in the node that point is within. -With an argument (@kbd{C-u} as prefix argument, if -interactive), the command makes or updates menus for the -nodes which are either within or a part of the -region.@refill - -Whenever @code{texinfo-make-menu} updates an existing menu, the -descriptions from that menu are incorporated into the new menu. This -is done by copying descriptions from the existing menu to the entries -in the new menu that have the same node names. If the node names are -different, the descriptions are not copied to the new menu.@refill - -@item C-c C-u C-e -@itemx M-x texinfo-every-node-update -@findex texinfo-every-node-update -Insert or update the `Next', `Previous', and `Up' pointers for every -node in the buffer.@refill - -@item C-c C-u C-a -@itemx M-x texinfo-all-menus-update -@findex texinfo-all-menus-update -Create or update all the menus in the buffer. With an argument -(@kbd{C-u} as prefix argument, if interactive), first insert -or update all the node -pointers before working on the menus.@refill - -If a master menu exists, the @code{texinfo-all-menus-update} command -updates it; but the command does not create a new master menu if none -already exists. (Use the @code{texinfo-master-menu} command for -that.)@refill - -When working on a document that does not merit a master menu, you can -type the following: - -@example -C-u C-c C-u C-a -@exdent or -C-u M-x texinfo-all-menus-update -@end example - -@noindent -This updates all the nodes and menus.@refill -@end table - -The @code{texinfo-column-for-description} variable specifies the -column to which menu descriptions are indented. By default, the value -is 32 although it is often useful to reduce it to as low as 24. You -can set the variable with the @kbd{M-x edit-options} command -(@pxref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs -Manual}) or with the @kbd{M-x set-variable} command (@pxref{Examining, -, Examining and Setting Variables, emacs, The GNU Emacs -Manual}).@refill - -Also, the @code{texinfo-indent-menu-description} command may be used to -indent existing menu descriptions to a specified column. Finally, if -you wish, you can use the @code{texinfo-insert-node-lines} command to -insert missing @code{@@node} lines into a file. (@xref{Other Updating -Commands}, for more information.)@refill - -@node Updating Requirements, Other Updating Commands, Updating Commands, Updating Nodes and Menus -@comment node-name, next, previous, up -@subsection Updating Requirements -@cindex Updating requirements -@cindex Requirements for updating commands - -To use the updating commands, you must organize the Texinfo file -hierarchically with chapters, sections, subsections, and the like. -When you construct the hierarchy of the manual, do not `jump down' -more than one level at a time: you can follow the `Top' node with a -chapter, but not with a section; you can follow a chapter with a -section, but not with a subsection. However, you may `jump up' any -number of levels at one time---for example, from a subsection to a -chapter.@refill - -Each @code{@@node} line, with the exception of the line for the `Top' -node, must be followed by a line with a structuring command such as -@code{@@chapter}, @code{@@section}, or -@code{@@unnumberedsubsec}.@refill - -Each @code{@@node} line/structuring-command line combination -must look either like this:@refill - -@example -@group -@@node Comments, Minimum, Conventions, Overview -@@comment node-name, next, previous, up -@@section Comments -@end group -@end example - -or like this (without the @code{@@comment} line): - -@example -@group -@@node Comments, Minimum, Conventions, Overview -@@section Comments -@end group -@end example - -@noindent -In this example, `Comments' is the name of both the node and the -section. The next node is called `Minimum' and the previous node is -called `Conventions'. The `Comments' section is within the `Overview' -node, which is specified by the `Up' pointer. (Instead of an -@code{@@comment} line, you can write an @code{@@ifinfo} line.)@refill - -If a file has a `Top' node, it must be called @samp{top} or @samp{Top} -and be the first node in the file.@refill - -The menu updating commands create a menu of sections within a chapter, -a menu of subsections within a section, and so on. This means that -you must have a `Top' node if you want a menu of chapters.@refill - -Incidentally, the @code{makeinfo} command will create an Info file for -a hierarchically organized Texinfo file that lacks `Next', `Previous' -and `Up' pointers. Thus, if you can be sure that your Texinfo file -will be formatted with @code{makeinfo}, you have no need for the -`update node' commands. (@xref{Create an Info File, , Creating an -Info File}, for more information about @code{makeinfo}.) However, -both @code{makeinfo} and the @code{texinfo-format-@dots{}} commands -require that you insert menus in the file.@refill - -@node Other Updating Commands, , Updating Requirements, Updating Nodes and Menus -@comment node-name, next, previous, up -@subsection Other Updating Commands - -In addition to the five major updating commands, Texinfo mode -possesses several less frequently used updating commands:@refill - -@table @kbd -@item M-x texinfo-insert-node-lines -@findex texinfo-insert-node-lines -Insert @code{@@node} lines before the @code{@@chapter}, -@code{@@section}, and other sectioning commands wherever they are -missing throughout a region in a Texinfo file.@refill - -With an argument (@kbd{C-u} as prefix argument, if interactive), the -@code{texinfo-insert-node-lines} command not only inserts -@code{@@node} lines but also inserts the chapter or section titles as -the names of the corresponding nodes. In addition, it inserts the -titles as node names in pre-existing @code{@@node} lines that lack -names. Since node names should be more concise than section or -chapter titles, you must manually edit node names so inserted.@refill - -For example, the following marks a whole buffer as a region and inserts -@code{@@node} lines and titles throughout:@refill - -@example -C-x h C-u M-x texinfo-insert-node-lines -@end example - -(Note that this command inserts titles as node names in @code{@@node} -lines; the @code{texinfo-start-menu-description} command -(@pxref{Inserting, Inserting Frequently Used Commands}) inserts titles -as descriptions in menu entries, a different action. However, in both -cases, you need to edit the inserted text.)@refill - -@item M-x texinfo-multiple-files-update -@findex texinfo-multiple-files-update @r{(in brief)} -Update nodes and menus in a document built from several separate files. -With @kbd{C-u} as a prefix argument, create and insert a master menu in -the outer file. With a numeric prefix argument, such as @kbd{C-u 2}, first -update all the menus and all the `Next', `Previous', and `Up' pointers -of all the included files before creating and inserting a master menu in -the outer file. The @code{texinfo-multiple-files-update} command is -described in the appendix on @code{@@include} files. -@ifinfo -@xref{texinfo-multiple-files-update}.@refill -@end ifinfo -@iftex -@xref{texinfo-multiple-files-update, , -@code{texinfo-multiple-files-update}}.@refill -@end iftex - -@item M-x texinfo-indent-menu-description -@findex texinfo-indent-menu-description -Indent every description in the menu following point to the specified -column. You can use this command to give yourself more space for -descriptions. With an argument (@kbd{C-u} as prefix argument, if -interactive), the @code{texinfo-indent-menu-description} command indents -every description in every menu in the region. However, this command -does not indent the second and subsequent lines of a multi-line -description.@refill - -@item M-x texinfo-sequential-node-update -@findex texinfo-sequential-node-update -Insert the names of the nodes immediately following and preceding the -current node as the `Next' or `Previous' pointers regardless of those -nodes' hierarchical level. This means that the `Next' node of a -subsection may well be the next chapter. Sequentially ordered nodes are -useful for novels and other documents that you read through -sequentially. (However, in Info, the @code{g* @key{RET}} command lets -you look through the file sequentially, so sequentially ordered nodes -are not strictly necessary.) With an argument (prefix argument, if -interactive), the @code{texinfo-sequential-node-update} command -sequentially updates all the nodes in the region.@refill -@end table - -@node Info Formatting, Printing, Updating Nodes and Menus, Texinfo Mode -@comment node-name, next, previous, up -@section Formatting for Info -@cindex Formatting for Info -@cindex Running an Info formatter -@cindex Info formatting - -Texinfo mode provides several commands for formatting part or all of a -Texinfo file for Info. Often, when you are writing a document, you -want to format only part of a file---that is, a region.@refill - -You can use either the @code{texinfo-format-region} or the -@code{makeinfo-region} command to format a region:@refill - -@table @kbd -@findex texinfo-format-region -@item C-c C-e C-r -@itemx M-x texinfo-format-region -@itemx C-c C-m C-r -@itemx M-x makeinfo-region -Format the current region for Info.@refill -@end table - -You can use either the @code{texinfo-format-buffer} or the -@code{makeinfo-buffer} command to format a whole buffer:@refill - -@table @kbd -@findex texinfo-format-buffer -@item C-c C-e C-b -@itemx M-x texinfo-format-buffer -@itemx C-c C-m C-b -@itemx M-x makeinfo-buffer -Format the current buffer for Info.@refill -@end table - -@need 1000 -For example, after writing a Texinfo file, you can type the following: - -@example -C-u C-c C-u m -@exdent or -C-u M-x texinfo-master-menu -@end example - -@noindent -This updates all the nodes and menus. Then type the following to create -an Info file: - -@example -C-c C-m C-b -@exdent or -M-x makeinfo-buffer -@end example - -For the Info formatting commands to work, the file @emph{must} include -a line that has @code{@@setfilename} in its header.@refill - -Not all systems support the @code{makeinfo}-based formatting commands.@refill - -@xref{Create an Info File}, for details about Info formatting.@refill - -@node Printing, Texinfo Mode Summary, Info Formatting, Texinfo Mode -@comment node-name, next, previous, up -@section Formatting and Printing -@cindex Formatting for printing -@cindex Printing a region or buffer -@cindex Region formatting and printing -@cindex Buffer formatting and printing -@cindex Part of file formatting and printing - -Typesetting and printing a Texinfo file is a multi-step process in which -you first create a file for printing (called a @sc{dvi} file), and then -print the file. Optionally, you may also create indices. To do this, -you must run the @code{texindex} command after first running the -@code{tex} typesetting command; and then you must run the @code{tex} -command again. @refill - -Often, when you are writing a document, you want to typeset and print -only part of a file to see what it will look like. You can use the -@code{texinfo-tex-region} and related commands for this purpose. Use -the @code{texinfo-tex-buffer} command to format all of a -buffer.@refill - -@table @kbd -@item C-c C-t C-r -@itemx M-x texinfo-tex-region -@findex texinfo-tex-region -Run @TeX{} on the region.@refill - -@item C-c C-t C-b -@itemx M-x texinfo-tex-buffer -@findex texinfo-tex-buffer -Run @TeX{} on the buffer.@refill - -@item C-c C-t C-i -@itemx M-x texinfo-texindex -Run @code{texindex} to sort the indices of a Texinfo file formatted with -@code{texinfo-tex-region} or @code{texinfo-tex-buffer}. You must run -the @code{tex} command a second time after sorting the raw index -files.@refill - -@item C-c C-t C-p -@itemx M-x texinfo-tex-print -@findex texinfo-tex-print -Print the file (or the part of the file) previously formatted with -@code{texinfo-tex-buffer} or @code{texinfo-tex-region}.@refill -@end table - -For @code{texinfo-tex-region} or @code{texinfo-tex-buffer} to work, the -file @emph{must} start with a @samp{\input texinfo} line and must -include an @code{@@settitle} line. The file must end with @code{@@bye} -on a line by itself. (When you use @code{texinfo-tex-region}, you must -surround the @code{@@settitle} line with start-of-header and -end-of-header lines.)@refill - -@xref{Format/Print Hardcopy}, for a description of the other @TeX{} related -commands, such as @code{tex-show-print-queue}.@refill - -@node Texinfo Mode Summary, , Printing, Texinfo Mode -@comment node-name, next, previous, up -@section Texinfo Mode Summary - -In Texinfo mode, each set of commands has default keybindings that -begin with the same keys. All the commands that are custom-created -for Texinfo mode begin with @kbd{C-c}. The keys are somewhat -mnemonic.@refill - -@subheading Insert Commands - -The insert commands are invoked by typing @kbd{C-c} twice and then the -first letter of the @@-command to be inserted. (It might make more -sense mnemonically to use @kbd{C-c C-i}, for `custom insert', but -@kbd{C-c C-c} is quick to type.)@refill - -@example -C-c C-c c @r{Insert} @samp{@@code}. -C-c C-c d @r{Insert} @samp{@@dfn}. -C-c C-c e @r{Insert} @samp{@@end}. -C-c C-c i @r{Insert} @samp{@@item}. -C-c C-c n @r{Insert} @samp{@@node}. -C-c C-c s @r{Insert} @samp{@@samp}. -C-c C-c v @r{Insert} @samp{@@var}. -C-c C-c @{ @r{Insert braces.} -C-c C-c ] -C-c C-c @} @r{Move out of enclosing braces.} - -@group -C-c C-c C-d @r{Insert a node's section title} - @r{in the space for the description} - @r{in a menu entry line.} -@end group -@end example - -@subheading Show Structure - -The @code{texinfo-show-structure} command is often used within a -narrowed region.@refill - -@example -C-c C-s @r{List all the headings.} -@end example - -@subheading The Master Update Command - -The @code{texinfo-master-menu} command creates a master menu; and can -be used to update every node and menu in a file as well.@refill - -@example -@group -C-c C-u m -M-x texinfo-master-menu - @r{Create or update a master menu.} -@end group - -@group -C-u C-c C-u m @r{With @kbd{C-u} as a prefix argument, first} - @r{create or update all nodes and regular} - @r{menus, and then create a master menu.} -@end group -@end example - -@subheading Update Pointers - -@c !!! added verbiage to prevent overfull hbox --bob 26 Mar 93 -The update pointer commands are invoked by typing @kbd{C-c C-u} and -then either typing @kbd{C-n} for @code{texinfo-update-node} or typing -@kbd{C-e} for @code{texinfo-every-node-update}.@refill - -@example -C-c C-u C-n @r{Update a node.} -C-c C-u C-e @r{Update every node in the buffer.} -@end example - -@subheading Update Menus - -Invoke the update menu commands by typing @kbd{C-c C-u} -and then either @kbd{C-m} for @code{texinfo-make-menu} or -@kbd{C-a} for @code{texinfo-all-menus-update}. To update -both nodes and menus at the same time, precede @kbd{C-c C-u -C-a} with @kbd{C-u}.@refill - -@example -C-c C-u C-m @r{Make or update a menu.} - -@group -C-c C-u C-a @r{Make or update all} - @r{menus in a buffer.} -@end group - -@group -C-u C-c C-u C-a @r{With @kbd{C-u} as a prefix argument,} - @r{first create or update all nodes and} - @r{then create or update all menus.} -@end group -@end example - -@subheading Format for Info - -The Info formatting commands that are written in Emacs Lisp are -invoked by typing @kbd{C-c C-e} and then either @kbd{C-r} for a region -or @kbd{C-b} for the whole buffer.@refill - -The Info formatting commands that are written in C and based on the -@code{makeinfo} program are invoked by typing @kbd{C-c C-m} and then -either @kbd{C-r} for a region or @kbd{C-b} for the whole buffer.@refill - -@need 800 -@noindent -Use the @code{texinfo-format@dots{}} commands: - -@example -@group -C-c C-e C-r @r{Format the region.} -C-c C-e C-b @r{Format the buffer.} -@end group -@end example - -@need 750 -@noindent -Use @code{makeinfo}: - -@example -C-c C-m C-r @r{Format the region.} -C-c C-m C-b @r{Format the buffer.} -C-c C-m C-l @r{Recenter the @code{makeinfo} output buffer.} -C-c C-m C-k @r{Kill the @code{makeinfo} formatting job.} -@end example - -@subheading Typeset and Print - -The @TeX{} typesetting and printing commands are invoked by typing -@kbd{C-c C-t} and then another control command: @kbd{C-r} for -@code{texinfo-tex-region}, @kbd{C-b} for @code{texinfo-tex-buffer}, -and so on.@refill - -@example -C-c C-t C-r @r{Run @TeX{} on the region.} -C-c C-t C-b @r{Run @TeX{} on the buffer.} -C-c C-t C-i @r{Run} @code{texindex}. -C-c C-t C-p @r{Print the @sc{dvi} file.} -C-c C-t C-q @r{Show the print queue.} -C-c C-t C-d @r{Delete a job from the print queue.} -C-c C-t C-k @r{Kill the current @TeX{} formatting job.} -C-c C-t C-x @r{Quit a currently stopped @TeX{} formatting job.} -C-c C-t C-l @r{Recenter the output buffer.} -@end example - -@subheading Other Updating Commands - -The `other updating commands' do not have standard keybindings because -they are rarely used. - -@example -@group -M-x texinfo-insert-node-lines - @r{Insert missing @code{@@node} lines in region.} - @r{With @kbd{C-u} as a prefix argument,} - @r{use section titles as node names.} -@end group - -@group -M-x texinfo-multiple-files-update - @r{Update a multi-file document.} - @r{With @kbd{C-u 2} as a prefix argument,} - @r{create or update all nodes and menus} - @r{in all included files first.} -@end group - -@group -M-x texinfo-indent-menu-description - @r{Indent descriptions.} -@end group - -@group -M-x texinfo-sequential-node-update - @r{Insert node pointers in strict sequence.} -@end group -@end example - -@node Beginning a File, Ending a File, Texinfo Mode, Top -@comment node-name, next, previous, up -@chapter Beginning a Texinfo File -@cindex Beginning a Texinfo file -@cindex Texinfo file beginning -@cindex File beginning - -Certain pieces of information must be provided at the beginning of a -Texinfo file, such as the name of the file and the title of the -document.@refill - -@menu -* Four Parts:: Four parts begin a Texinfo file. -* Sample Beginning:: Here is a sample beginning for a Texinfo file. -* Header:: The very beginning of a Texinfo file. -* Info Summary and Permissions:: Summary and copying permissions for Info. -* Titlepage & Copyright Page:: Creating the title and copyright pages. -* The Top Node:: Creating the `Top' node and master menu. -* Software Copying Permissions:: Ensure that you and others continue to - have the right to use and share software. -@end menu - -@node Four Parts, Sample Beginning, , Beginning a File -@ifinfo -@heading Four Parts Begin a File -@end ifinfo - -Generally, the beginning of a Texinfo file has four parts:@refill - -@enumerate -@item -The header, delimited by special comment lines, that includes the -commands for naming the Texinfo file and telling @TeX{} what -definitions' file to use when processing the Texinfo file.@refill - -@item -A short statement of what the file is about, with a copyright notice -and copying permissions. This is enclosed in @code{@@ifinfo} and -@code{@@end ifinfo} commands so that the formatters place it only -in the Info file.@refill - -@item -A title page and copyright page, with a copyright notice and copying -permissions. This is enclosed between @code{@@titlepage} and -@code{@@end titlepage} commands. The title and copyright page appear -only in the printed @w{manual}.@refill - -@item -The `Top' node that contains a menu for the whole Info file. The -contents of this node appear only in the Info file.@refill -@end enumerate - -Also, optionally, you may include the copying conditions for a program -and a warranty disclaimer. The copying section will be followed by an -introduction or else by the first chapter of the manual.@refill - -Since the copyright notice and copying permissions for the Texinfo -document (in contrast to the copying permissions for a program) are in -parts that appear only in the Info file or only in the printed manual, -this information must be given twice.@refill - -@node Sample Beginning, Header, Four Parts, Beginning a File -@comment node-name, next, previous, up -@section Sample Texinfo File Beginning - -The following sample shows what is needed.@refill - -@example -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename @var{name-of-info-file} -@@settitle @var{name-of-manual} -@@setchapternewpage odd -@@c %**end of header - -@@ifinfo -This file documents @dots{} - -Copyright @var{year} @var{copyright-owner} - -@group -Permission is granted to @dots{} -@@end ifinfo -@end group - -@group -@@c This title page illustrates only one of the -@@c two methods of forming a title page. -@end group - -@group -@@titlepage -@@title @var{name-of-manual-when-printed} -@@subtitle @var{subtitle-if-any} -@@subtitle @var{second-subtitle} -@@author @var{author} -@end group - -@group -@@c The following two commands -@@c start the copyright page. -@@page -@@vskip 0pt plus 1filll -Copyright @@copyright@{@} @var{year} @var{copyright-owner} -@end group - -Published by @dots{} - -Permission is granted to @dots{} -@@end titlepage - -@@node Top, Overview, (dir), (dir) - -@@ifinfo -This document describes @dots{} - -This document applies to version @dots{} -of the program named @dots{} -@@end ifinfo - -@group -@@menu -* Copying:: Your rights and freedoms. -* First Chapter:: Getting started @dots{} -* Second Chapter:: @dots{} - @dots{} - @dots{} -@@end menu -@end group - -@group -@@node First Chapter, Second Chapter, top, top -@@comment node-name, next, previous, up -@@chapter First Chapter -@@cindex Index entry for First Chapter -@end group -@end example - -@node Header, Info Summary and Permissions, Sample Beginning, Beginning a File -@comment node-name, next, previous, up -@section The Texinfo File Header -@cindex Header for Texinfo files -@cindex Texinfo file header - -Texinfo files start with at least three lines that provide Info and -@TeX{} with necessary information. These are the @code{\input -texinfo} line, the @code{@@settitle} line, and the -@code{@@setfilename} line. If you want to run @TeX{} on just a part -of the Texinfo File, you must write the @code{@@settitle} -and @code{@@setfilename} lines between start-of-header and end-of-header -lines.@refill - -Thus, the beginning of a Texinfo file looks like this: - -@example -@group -\input texinfo @@c -*-texinfo-*- -@@setfilename sample.info -@@settitle Sample Document -@end group -@end example - -@noindent -or else like this: - -@example -@group -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename sample.info -@@settitle Sample Document -@@c %**end of header -@end group -@end example - -@menu -* First Line:: The first line of a Texinfo file. -* Start of Header:: Formatting a region requires this. -* setfilename:: Tell Info the name of the Info file. -* settitle:: Create a title for the printed work. -* setchapternewpage:: Start chapters on right-hand pages. -* paragraphindent:: An option to specify paragraph indentation. -* End of Header:: Formatting a region requires this. -@end menu - -@node First Line, Start of Header, , Header -@comment node-name, next, previous, up -@subsection The First Line of a Texinfo File -@cindex First line of a Texinfo file -@cindex Beginning line of a Texinfo file -@cindex Header of a Texinfo file - -Every Texinfo file that is to be the top-level input to @TeX{} must begin -with a line that looks like this:@refill - -@example -\input texinfo @@c -*-texinfo-*- -@end example - -@noindent -This line serves two functions: - -@enumerate -@item -When the file is processed by @TeX{}, the @code{\input texinfo} command -tells @TeX{} to load the macros needed for processing a Texinfo file. -These are in a file called @file{texinfo.tex}, which is usually located -in the @file{/usr/lib/tex/macros} directory. @TeX{} uses the backslash, -@samp{\}, to mark the beginning of a command, just as Texinfo uses -@code{@@}. The @file{texinfo.tex} file causes the switch from @samp{\} -to @samp{@@}; before the switch occurs, @TeX{} requires @samp{\}, which -is why it appears at the beginning of the file.@refill - -@item -When the file is edited in GNU Emacs, the @samp{-*-texinfo-*-} mode -specification tells Emacs to use Texinfo mode.@refill -@end enumerate - -@node Start of Header, setfilename, First Line, Header -@comment node-name, next, previous, up -@subsection Start of Header -@cindex Start of header line - -Write a start-of-header line on the second line of a Texinfo file. -Follow the start-of-header line with @code{@@setfilename} and -@code{@@settitle} lines and, optionally, with other command lines, such -as @code{@@smallbook} or @code{@@footnotestyle}; and then by an -end-of-header line (@pxref{End of Header}).@refill - -With these lines, you can format part of a Texinfo file for Info or -typeset part for printing.@refill - -A start-of-header line looks like this:@refill - -@example -@@c %**start of header -@end example - -The odd string of characters, @samp{%**}, is to ensure that no other -comment is accidentally taken for a start-of-header line.@refill - -@node setfilename, settitle, Start of Header, Header -@comment node-name, next, previous, up -@subsection @code{@@setfilename} -@cindex Info file requires @code{@@setfilename} -@findex setfilename - -In order to be made into an Info file, a Texinfo file must contain a line -that looks like this:@refill - -@example -@@setfilename @var{info-file-name} -@end example - -Write the @code{@@setfilename} command at the beginning of a line and -follow it on the same line by the Info file name. Do not write -anything else on the line; anything on the line after the command is -considered part of the file name, including a comment.@refill - -The @code{@@setfilename} line specifies the name of the Info file to be -generated. This name should be different from the name of the Texinfo -file. The convention is to write a name with a @samp{.info} extension, -to produce an Info file name such as @file{texinfo.info}.@refill - -Some operating systems cannot handle long file names. You can run into -a problem even when the file name you specify is itself short enough. -This occurs because the Info formatters split a long Info file into -short indirect subfiles, and name them by appending `-1', `-2', @dots{}, -`-10', `-11', and so on, to the original file name. (@xref{Tag and -Split Files, , Tag Files and Split Files}.) The subfile name -@file{texinfo.info-10}, for example, is too long for some systems; so -the Info file name for this document is actually @file{texinfo} rather than -@file{texinfo.info}.@refill - -The Info formatting commands ignore everything written before the -@code{@@setfilename} line, which is why the very first line of -the file (the @code{\input} line) does not need to be commented out. -The @code{@@setfilename} line is ignored when you typeset a printed -manual.@refill - -@node settitle, setchapternewpage, setfilename, Header -@comment node-name, next, previous, up -@subsection @code{@@settitle} -@findex settitle - -In order to be made into a printed manual, a Texinfo file must contain -a line that looks like this:@refill - -@example -@@settitle @var{title} -@end example - -Write the @code{@@settitle} command at the beginning of a line and -follow it on the same line by the title. This tells @TeX{} the title -to use in a header or footer. Do not write anything else on the line; -anything on the line after the command is considered part of the -title, including a comment.@refill - -Conventionally, @TeX{} formats a Texinfo file for double-sided output -so as to print the title in the left-hand (even-numbered) page -headings and the current chapter titles in the right-hand -(odd-numbered) page headings. (@TeX{} learns the title of each -chapter from each @code{@@chapter} command.) Page footers are not -printed.@refill - -Even if you are printing in a single-sided style, @TeX{} looks for an -@code{@@settitle} command line, in case you include the manual title -in the heading. @refill - -The @code{@@settitle} command should precede everything that generates -actual output in @TeX{}.@refill - -Although the title in the @code{@@settitle} command is usually the -same as the title on the title page, it does not affect the title as -it appears on the title page. Thus, the two do not need not match -exactly; and the title in the @code{@@settitle} command can be a -shortened or expanded version of the title as it appears on the title -page. (@xref{titlepage, , @code{@@titlepage}}.)@refill - -@TeX{} prints page headings only for that text that comes after the -@code{@@end titlepage} command in the Texinfo file, or that comes -after an @code{@@headings} command that turns on headings. -(@xref{headings on off, , The @code{@@headings} Command}, for more -information.)@refill - -You may, if you wish, create your own, customized headings and -footings. @xref{Headings, , Page Headings}, for a detailed discussion -of this process.@refill - -@node setchapternewpage, paragraphindent, settitle, Header -@comment node-name, next, previous, up -@subsection @code{@@setchapternewpage} -@cindex Starting chapters -@cindex Pages, starting odd -@findex setchapternewpage - -In a book or a manual, text is usually printed on both sides of the -paper, chapters start on right-hand pages, and right-hand pages have -odd numbers. But in short reports, text often is printed only on one -side of the paper. Also in short reports, chapters sometimes do not -start on new pages, but are printed on the same page as the end of the -preceding chapter, after a small amount of vertical whitespace.@refill - -You can use the @code{@@setchapternewpage} command with various -arguments to specify how @TeX{} should start chapters and whether it -should typeset pages for printing on one or both sides of the paper -(single-sided or double-sided printing).@refill - -Write the @code{@@setchapternewpage} command at the beginning of a -line followed by its argument.@refill - -For example, you would write the following to cause each chapter to -start on a fresh odd-numbered page:@refill - -@example -@@setchapternewpage odd -@end example - -You can specify one of three alternatives with the -@code{@@setchapternewpage} command:@refill - -@table @asis -@ignore -@item No @code{@@setchapternewpage} command -If the Texinfo file does not contain an @code{@@setchapternewpage} -command before the @code{@@titlepage} command, @TeX{} automatically -begins chapters on new pages and prints headings in the standard -format for single-sided printing. This is the conventional format for -single-sided printing.@refill - -The result is exactly the same as when you write -@code{@@setchapternewpage on}.@refill -@end ignore -@item @code{@@setchapternewpage off} -Cause @TeX{} to typeset a new chapter on the same page as the last -chapter, after skipping some vertical whitespace. Also, cause @TeX{} to -format page headers for single-sided printing. (You can override the -headers format with the @code{@@headings double} command; see -@ref{headings on off, , The @code{@@headings} Command}.)@refill - -@item @code{@@setchapternewpage on} -Cause @TeX{} to start new chapters on new pages and to typeset page -headers for single-sided printing. This is the form most often -used for short reports.@refill - -This alternative is the default.@refill - -@item @code{@@setchapternewpage odd} -Cause @TeX{} to start new chapters on new, odd-numbered pages -(right-handed pages) and to typeset for double-sided printing. This is -the form most often used for books and manuals.@refill -@end table - -@noindent -Texinfo does not have an @code{@@setchapternewpage even} command.@refill - -@noindent -(You can countermand or modify an @code{@@setchapternewpage} command -with an @code{@@headings} command. @xref{headings on off, , The -@code{@@headings} Command}.)@refill - -At the beginning of a manual or book, pages are not numbered---for -example, the title and copyright pages of a book are not numbered. -By convention, table of contents pages are numbered with roman -numerals and not in sequence with the rest of the document.@refill - -Since an Info file does not have pages, the @code{@@setchapternewpage} -command has no effect on it.@refill - -Usually, you do not write an @code{@@setchapternewpage} command for -single-sided printing, but accept the default which is to typeset for -single-sided printing and to start new chapters on new pages. Usually, -you write an @code{@@setchapternewpage odd} command for double-sided -printing.@refill - -@node paragraphindent, End of Header, setchapternewpage, Header -@comment node-name, next, previous, up -@subsection Paragraph Indenting -@cindex Indenting paragraphs -@cindex Paragraph indentation -@findex paragraphindent - -The Info formatting commands may insert spaces at the beginning of the -first line of each paragraph, thereby indenting that paragraph. You -can use the @code{@@paragraphindent} command to specify the -indentation. Write an @code{@@paragraphindent} command at the -beginning of a line followed by either @samp{asis} or a number. The -template is:@refill - -@example -@@paragraphindent @var{indent} -@end example - -The Info formatting commands indent according to the value of -@var{indent}:@refill - -@itemize @bullet -@item -If the value of @var{indent} is @samp{asis}, the Info formatting -commands do not change the existing indentation.@refill - -@item -If the value of @var{indent} is 0, the Info formatting commands delete -existing indentation.@refill - -@item -If the value of @var{indent} is greater than 0, the Info formatting -commands indent the paragraph by that number of spaces.@refill -@end itemize - -The default value of @var{indent} is @samp{asis}.@refill - -Write the @code{@@paragraphindent} command before or shortly after the -end-of-header line at the beginning of a Texinfo file. (If you write -the command between the start-of-header and end-of-header lines, the -region formatting commands indent paragraphs as specified.)@refill - -@c !!! added verbiage to prevent overfull hbox --bob 26 Mar 93 -A peculiarity of @code{texinfo-format-buffer} and -@code{texinfo-format-region} is that they do not indent (nor -fill) paragraphs that contain @code{@@w} or @code{@@*} commands. -@xref{Refilling Paragraphs}, for a detailed description of what goes -on.@refill - -@node End of Header, , paragraphindent, Header -@comment node-name, next, previous, up -@subsection End of Header -@cindex End of header line - -Follow the header lines with an @w{end-of-header} line. -An end-of-header line looks like this:@refill - -@example -@@c %**end of header -@end example - -If you include the @code{@@setchapternewpage} command between the -start-of-header and end-of-header lines, @TeX{} will typeset a region as -that command specifies. Similarly, if you include an @code{@@smallbook} -command between the start-of-header and end-of-header lines, @TeX{} will -typeset a region in the ``small'' book format.@refill - -@ifinfo -The reason for the odd string of characters (@samp{%**}) is so that the -@code{texinfo-tex-region} command does not accidentally find -something that it should not when it is looking for the header.@refill - -The start-of-header line and the end-of-header line are Texinfo mode -variables that you can change.@refill -@end ifinfo - -@iftex -@xref{Start of Header}. -@end iftex - -@node Info Summary and Permissions, Titlepage & Copyright Page, Header, Beginning a File -@comment node-name, next, previous, up -@section Summary and Copying Permissions for Info - -The title page and the copyright page appear only in the printed copy of -the manual; therefore, the same information must be inserted in a -section that appears only in the Info file. This section usually -contains a brief description of the contents of the Info file, a -copyright notice, and copying permissions.@refill - -The copyright notice should read:@refill - -@example -Copyright @var{year} @var{copyright-owner} -@end example - -@noindent -and be put on a line by itself.@refill - -Standard text for the copyright permissions is contained in an appendix -to this manual; see @ref{ifinfo Permissions, , @samp{ifinfo} Copying -Permissions}, for the complete text.@refill - -The permissions text appears in an Info file @emph{before} the first -node. This mean that a reader does @emph{not} see this text when -reading the file using Info, except when using the advanced Info command -@kbd{g *}. - -@node Titlepage & Copyright Page, The Top Node, Info Summary and Permissions, Beginning a File -@comment node-name, next, previous, up -@section The Title and Copyright Pages - -A manual's name and author are usually printed on a title page. -Sometimes copyright information is printed on the title page as well; -more often, copyright information is printed on the back of the title -page. - -The title and copyright pages appear in the printed manual, but not in the -Info file. Because of this, it is possible to use several slightly -obscure @TeX{} typesetting commands that cannot be used in an Info file. -In addition, this part of the beginning of a Texinfo file contains the text -of the copying permissions that will appear in the printed manual.@refill - -@xref{Titlepage Permissions, , Titlepage Copying Permissions}, for the -standard text for the copyright permissions.@refill - -@menu -* titlepage:: Create a title for the printed document. -* titlefont center sp:: The @code{@@titlefont}, @code{@@center}, - and @code{@@sp} commands. -* title subtitle author:: The @code{@@title}, @code{@@subtitle}, - and @code{@@author} commands. -* Copyright & Permissions:: How to write the copyright notice and - include copying permissions. -* end titlepage:: Turn on page headings after the title and - copyright pages. -* headings on off:: An option for turning headings on and off - and double or single sided printing. -@end menu - -@node titlepage, titlefont center sp, , Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection @code{@@titlepage} -@cindex Title page -@findex titlepage - -Start the material for the title page and following copyright page -with @code{@@titlepage} on a line by itself and end it with -@code{@@end titlepage} on a line by itself.@refill - -The @code{@@end titlepage} command starts a new page and turns on page -numbering. (@xref{Headings, , Page Headings}, for details about how to -generate of page headings.) All the material that you want to -appear on unnumbered pages should be put between the -@code{@@titlepage} and @code{@@end titlepage} commands. By using the -@code{@@page} command you can force a page break within the region -delineated by the @code{@@titlepage} and @code{@@end titlepage} -commands and thereby create more than one unnumbered page. This is -how the copyright page is produced. (The @code{@@titlepage} command -might perhaps have been better named the -@code{@@titleandadditionalpages} command, but that would have been -rather long!)@refill - -@c !!! append refill to footnote when makeinfo can handle it. -When you write a manual about a computer program, you should write the -version of the program to which the manual applies on the title -page. If the manual changes more frequently than the program or is -independent of it, you should also include an edition -number@footnote{We have found that it is helpful to refer to versions -of manuals as `editions' and versions of programs as `versions'; -otherwise, we find we are liable to confuse each other in conversation -by referring to both the documentation and the software with the same -words.} for the manual. This helps readers keep track of which manual -is for which version of the program. (The `Top' node -should also contain this information; see @ref{makeinfo top, , -@code{@@top}}.)@refill - -Texinfo provides two methods for creating a title page. One method -uses the @code{@@titlefont}, @code{@@sp}, and @code{@@center} commands -to generate a title page in which the words on the page are -centered.@refill - -The second method uses the @code{@@title}, @code{@@subtitle}, and -@code{@@author} commands to create a title page with black rules under -the title and author lines and the subtitle text set flush to the -right hand side of the page. With this method, you do not specify any -of the actual formatting of the title page. You specify the text -you want, and Texinfo does the formatting. You may use either -method.@refill - -@node titlefont center sp, title subtitle author, titlepage, Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection @code{@@titlefont}, @code{@@center}, and @code{@@sp} -@findex titlefont -@findex center -@findex sp @r{(titlepage line spacing)} - -You can use the @code{@@titlefont}, @code{@@sp}, and @code{@@center} -commands to create a title page for a printed document. (This is the -first of the two methods for creating a title page in Texinfo.)@refill - -Use the @code{@@titlefont} command to select a large font suitable for -the title itself.@refill - -@need 700 -For example: - -@example -@@titlefont@{Texinfo@} -@end example - -Use the @code{@@center} command at the beginning of a line to center -the remaining text on that line. Thus,@refill - -@example -@@center @@titlefont@{Texinfo@} -@end example - -@noindent -centers the title, which in this example is ``Texinfo'' printed -in the title font.@refill - -Use the @code{@@sp} command to insert vertical space. For example:@refill - -@example -@@sp 2 -@end example - -@noindent -This inserts two blank lines on the printed page. (@xref{sp, , -@code{@@sp}}, for more information about the @code{@@sp} -command.)@refill - -A template for this method looks like this:@refill - -@example -@group -@@titlepage -@@sp 10 -@@center @@titlefont@{@var{name-of-manual-when-printed}@} -@@sp 2 -@@center @var{subtitle-if-any} -@@sp 2 -@@center @var{author} -@dots{} -@@end titlepage -@end group -@end example - -The spacing of the example fits an 8 1/2 by 11 inch manual.@refill - -@node title subtitle author, Copyright & Permissions, titlefont center sp, Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection @code{@@title}, @code{@@subtitle}, and @code{@@author} -@findex title -@findex subtitle -@findex author - -You can use the @code{@@title}, @code{@@subtitle}, and @code{@@author} -commands to create a title page in which the vertical and horizontal -spacing is done for you automatically. This contrasts with the method -described in -the previous section, in which the @code{@@sp} command is needed to -adjust vertical spacing.@refill - -Write the @code{@@title}, @code{@@subtitle}, or @code{@@author} -commands at the beginning of a line followed by the title, subtitle, -or author.@refill - -The @code{@@title} command produces a line in which the title is set -flush to the left-hand side of the page in a larger than normal font. -The title is underlined with a black rule.@refill - -The @code{@@subtitle} command sets subtitles in a normal-sized font -flush to the right-hand side of the page.@refill - -The @code{@@author} command sets the names of the author or authors in -a middle-sized font flush to the left-hand side of the page on a line -near the bottom of the title page. The names are underlined with a -black rule that is thinner than the rule that underlines the title. -(The black rule only occurs if the @code{@@author} command line is -followed by an @code{@@page} command line.)@refill - -There are two ways to use the @code{@@author} command: you can write -the name or names on the remaining part of the line that starts with -an @code{@@author} command:@refill - -@example -@@author by Jane Smith and John Doe -@end example - -@noindent -or you can write the names one above each other by using two (or more) -@code{@@author} commands:@refill - -@example -@group -@@author Jane Smith -@@author John Doe -@end group -@end example - -@noindent -(Only the bottom name is underlined with a black rule.)@refill - -@need 950 -A template for this method looks like this:@refill - -@example -@group -@@titlepage -@@title @var{name-of-manual-when-printed} -@@subtitle @var{subtitle-if-any} -@@subtitle @var{second-subtitle} -@@author @var{author} -@@page -@dots{} -@@end titlepage -@end group -@end example - -@ifinfo -@noindent -Contrast this form with the form of a title page written using the -@code{@@sp}, @code{@@center}, and @code{@@titlefont} commands:@refill - -@example -@@titlepage -@@sp 10 -@@center @@titlefont@{Name of Manual When Printed@} -@@sp 2 -@@center Subtitle, If Any -@@sp 1 -@@center Second subtitle -@@sp 2 -@@center Author -@@page -@dots{} -@@end titlepage -@end example -@end ifinfo - -@node Copyright & Permissions, end titlepage, title subtitle author, Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection Copyright Page and Permissions -@cindex Copyright page -@cindex Printed permissions -@cindex Permissions, printed - -By international treaty, the copyright notice for a book should be -either on the title page or on the back of the title page. The -copyright notice should include the year followed by the name of the -organization or person who owns the copyright.@refill - -When the copyright notice is on the back of the title page, that page -is customarily not numbered. Therefore, in Texinfo, the information -on the copyright page should be within @code{@@titlepage} and -@code{@@end titlepage} commands.@refill - -@findex vskip -@findex filll -@cindex Vertical whitespace (@samp{vskip}) -Use the @code{@@page} command to cause a page break. To push the -copyright notice and the other text on the copyright page towards the -bottom of the page, you can write a somewhat mysterious line after the -@code{@@page} command that reads like this:@refill - -@example -@@vskip 0pt plus 1filll -@end example - -@noindent -This is a @TeX{} command that is not supported by the Info formatting -commands. The @code{@@vskip} command inserts whitespace. The -@samp{0pt plus 1filll} means to put in zero points of mandatory whitespace, -and as much optional whitespace as needed to push the -following text to the bottom of the page. Note the use of three -@samp{l}s in the word @samp{filll}; this is the correct usage in -@TeX{}.@refill - -@findex copyright -In a printed manual, the @code{@@copyright@{@}} command generates a -@samp{c} inside a circle. (In Info, it generates @samp{(C)}.) The -copyright notice itself has the following legally defined sequence:@refill - -@example -Copyright @copyright{} @var{year} @var{copyright-owner} -@end example - -It is customary to put information on how to get a manual after the -copyright notice, followed by the copying permissions for the -manual.@refill - -Note that permissions must be given here as well as in the summary -segment within @code{@@ifinfo} and @code{@@end ifinfo} that -immediately follows the header since this text appears only in the -printed manual and the @samp{ifinfo} text appears only in the Info -file.@refill - -@xref{Sample Permissions}, for the standard text.@refill - -@node end titlepage, headings on off, Copyright & Permissions, Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection Heading Generation -@findex end titlepage -@cindex Headings, page, begin to appear -@cindex Titlepage end starts headings -@cindex End titlepage starts headings - -An @code{@@end titlepage} command on a line by itself not only marks -the end of the title and copyright pages, but also causes @TeX{} to start -generating page headings and page numbers. - -To repeat what is said elsewhere, Texinfo has two standard page heading -formats, one for documents which are printed on one side of each sheet of paper -(single-sided printing), and the other for documents which are printed on both -sides of each sheet (double-sided printing). -(@xref{setchapternewpage, ,@code{@@setchapternewpage}}.) -You can specify these formats in different ways:@refill - -@itemize @bullet -@item -The conventional way is to write an @code{@@setchapternewpage} command -before the title page commands, and then have the @code{@@end -titlepage} command start generating page headings in the manner desired. -(@xref{setchapternewpage, , @code{@@setchapternewpage}}.)@refill - -@item -Alternatively, you can use the @code{@@headings} command to prevent page -headings from being generated or to start them for either single or -double-sided printing. (Write an @code{@@headings} command immediately -after the @code{@@end titlepage} command. @xref{headings on off, , The -@code{@@headings} Command}, for more information.)@refill - -@item -Or, you may specify your own page heading and footing format. -@xref{Headings, , Page Headings}, for detailed -information about page headings and footings.@refill -@end itemize - -Most documents are formatted with the standard single-sided or -double-sided format, using @code{@@setchapternewpage odd} for -double-sided printing and no @code{@@setchapternewpage} command for -single-sided printing.@refill - -@node headings on off, , end titlepage, Titlepage & Copyright Page -@comment node-name, next, previous, up -@subsection The @code{@@headings} Command -@findex headings - -The @code{@@headings} command is rarely used. It specifies what kind of -page headings and footings to print on each page. Usually, this is -controlled by the @code{@@setchapternewpage} command. You need the -@code{@@headings} command only if the @code{@@setchapternewpage} command -does not do what you want, or if you want to turn off pre-defined page -headings prior to defining your own. Write an @code{@@headings} command -immediately after the @code{@@end titlepage} command.@refill - -There are four ways to use the @code{@@headings} command:@refill - -@table @code -@item @@headings off -Turn off printing of page headings.@refill - -@item @@headings single -Turn on page headings appropriate for single-sided printing. -@refill - -@item @@headings double -@itemx @@headings on -Turn on page headings appropriate for double-sided printing. The two -commands, @code{@@headings on} and @code{@@headings double}, are -synonymous.@refill -@end table - -For example, suppose you write @code{@@setchapternewpage off} before the -@code{@@titlepage} command to tell @TeX{} to start a new chapter on the -same page as the end of the last chapter. This command also causes -@TeX{} to typeset page headers for single-sided printing. To cause -@TeX{} to typeset for double sided printing, write @code{@@headings -double} after the @code{@@end titlepage} command. - -You can stop @TeX{} from generating any page headings at all by -writing @code{@@headings off} on a line of its own immediately after the -line containing the @code{@@end titlepage} command, like this:@refill - -@example -@@end titlepage -@@headings off -@end example - -@noindent -The @code{@@headings off} command overrides the @code{@@end titlepage} -command, which would otherwise cause @TeX{} to print page -headings.@refill - -You can also specify your own style of page heading and footing. -@xref{Headings, , Page Headings}, for more information.@refill - -@node The Top Node, Software Copying Permissions, Titlepage & Copyright Page, Beginning a File -@comment node-name, next, previous, up -@section The `Top' Node and Master Menu -@cindex @samp{@r{Top}} node -@cindex Master menu -@cindex Node, `Top' - -The `Top' node is the node from which you enter an Info file.@refill - -A `Top' node should contain a brief description of the Info file and an -extensive, master menu for the whole Info file. -This helps the reader understand what the Info file is -about. Also, you should write the version number of the program to -which the Info file applies; or, at least, the edition number.@refill - -The contents of the `Top' node should appear only in the Info file; none -of it should appear in printed output, so enclose it between -@code{@@ifinfo} and @code{@@end ifinfo} commands. (@TeX{} does not -print either an @code{@@node} line or a menu; they appear only in Info; -strictly speaking, you are not required to enclose these parts between -@code{@@ifinfo} and @code{@@end ifinfo}, but it is simplest to do so. -@xref{Conditionals, , Conditionally Visible Text}.)@refill - -@menu -* Title of Top Node:: Sketch what the file is about. -* Master Menu Parts:: A master menu has three or more parts. -@end menu - -@node Title of Top Node, Master Menu Parts, , The Top Node -@ifinfo -@subheading `Top' Node Title -@end ifinfo - -Sometimes, you will want to place an @code{@@top} sectioning command -line containing the title of the document immediately after the -@code{@@node Top} line (@pxref{makeinfo top command, , The @code{@@top} -Sectioning Command}, for more information).@refill - -For example, the beginning of the Top node of this manual contains an -@code{@@top} sectioning command, a short description, and edition and -version information. It looks like this:@refill - -@example -@group -@dots{} -@@end titlepage - -@@ifinfo -@@node Top, Copying, (dir), (dir) -@@top Texinfo - -Texinfo is a documentation system@dots{} -@end group - -@group -This is edition@dots{} -@dots{} -@@end ifinfo -@end group - -@group -@@menu -* Copying:: Texinfo is freely - redistributable. -* Overview:: What is Texinfo? -@dots{} -@end group -@@end menu -@end example - -In a `Top' node, the `Previous', and `Up' nodes usually refer to the top -level directory of the whole Info system, which is called @samp{(dir)}. -The `Next' node refers to the first node that follows the main or master -menu, which is usually the copying permissions, introduction, or first -chapter.@refill - -@node Master Menu Parts, , Title of Top Node, The Top Node -@subsection Parts of a Master Menu -@cindex Master menu parts -@cindex Parts of a master menu - -A @dfn{master menu} is a detailed main menu listing all the nodes in a -file. - -A master menu is enclosed in @code{@@menu} and @code{@@end menu} -commands and does not appear in the printed document.@refill - -Generally, a master menu is divided into parts.@refill - -@itemize @bullet -@item -The first part contains the major nodes in the Texinfo file: the nodes -for the chapters, chapter-like sections, and the appendices.@refill - -@item -The second part contains nodes for the indices.@refill - -@item -The third and subsequent parts contain a listing of the other, lower -level nodes, often ordered by chapter. This way, rather than go -through an intermediary menu, an inquirer can go directly to a -particular node when searching for specific information. These menu -items are not required; add them if you think they are a -convenience.@refill -@end itemize - -Each section in the menu can be introduced by a descriptive line. So -long as the line does not begin with an asterisk, it will not be -treated as a menu entry. (@xref{Writing a Menu}, for more -information.)@refill - -For example, the master menu for this manual looks like the following -(but has many more entries):@refill - -@example -@group -@@menu -* Copying:: Texinfo is freely - redistributable. -* Overview:: What is Texinfo? -* Texinfo Mode:: Special features in GNU Emacs. -@dots{} -@dots{} -@end group -@group -* Command and Variable Index:: - An entry for each @@-command. -* Concept Index:: An entry for each concept. -@end group - -@group - --- The Detailed Node Listing --- - -Overview of Texinfo - -* Info Files:: What is an Info file? -* Printed Manuals:: Characteristics of - a printed manual. -@dots{} -@dots{} -@end group - -@group -Using Texinfo Mode - -* Info on a Region:: Formatting part of a file - for Info. -@dots{} -@dots{} -@@end menu -@end group -@end example - -@node Software Copying Permissions, , The Top Node, Beginning a File -@comment node-name, next, previous, up -@section Software Copying Permissions -@cindex Software copying permissions -@cindex Copying software -@cindex Distribution -@cindex License agreement - -If the Texinfo file has a section containing the ``General Public -License'' and the distribution information and a warranty disclaimer -for the software that is documented, this section usually follows the -`Top' node. The General Public License is very important to Project -GNU software. It ensures that you and others will continue to have a -right to use and share the software.@refill - -The copying and distribution information and the disclaimer are -followed by an introduction or else by the first chapter of the -manual.@refill - -@cindex Introduction, as part of file -Although an introduction is not a required part of a Texinfo file, it -is very helpful. Ideally, it should state clearly and concisely what -the file is about and who would be interested in reading it. In -general, an introduction would follow the licensing and distribution -information, although sometimes people put it earlier in the document. -Usually, an introduction is put in an @code{@@unnumbered} section. -(@xref{unnumbered & appendix, , The @code{@@unnumbered} and -@code{@@appendix} Commands}.)@refill - -@node Ending a File, Structuring, Beginning a File, Top -@comment node-name, next, previous, up -@chapter Ending a Texinfo File -@cindex Ending a Texinfo file -@cindex Texinfo file ending -@cindex File ending -@findex bye - -The end of a Texinfo file should include the commands that create -indices and generate detailed and summary tables of contents. -And it must include the @code{@@bye} command that marks the last line -processed by @TeX{}.@refill - -@need 700 -For example: - -@example -@@node Concept Index, , Variables Index, Top -@@c node-name, next, previous, up -@@unnumbered Concept Index - -@@printindex cp - -@@contents -@@bye -@end example - -@menu -* Printing Indices & Menus:: How to print an index in hardcopy and - generate index menus in Info. -* Contents:: How to create a table of contents. -* File End:: How to mark the end of a file. -@end menu - -@node Printing Indices & Menus, Contents, , Ending a File -@comment node-name, next, previous, up -@section Index Menus and Printing an Index -@findex printindex -@cindex Printing an index -@cindex Indices, printing and menus -@cindex Generating menus with indices -@cindex Menus generated with indices - -To print an index means to include it as part of a manual or Info -file. This does not happen automatically just because you use -@code{@@cindex} or other index-entry generating commands in the -Texinfo file; those just cause the raw data for the index to be -accumulated. To generate an index, you must include the -@code{@@printindex} command at the place in the document where you -want the index to appear. Also, as part of the process of creating a -printed manual, you must run a program called @code{texindex} -(@pxref{Format/Print Hardcopy}) to sort the raw data to produce a sorted -index file. The sorted index file is what is actually used to -print the index.@refill - -Texinfo offers six different types of predefined index: the concept -index, the function index, the variables index, the keystroke index, the -program index, and the data type index (@pxref{Predefined Indices}). Each -index type has a two-letter name: @samp{cp}, @samp{fn}, @samp{vr}, -@samp{ky}, @samp{pg}, and @samp{tp}. You may merge indices, or put them -into separate sections (@pxref{Combining Indices}); or you may define -your own indices (@pxref{New Indices, , Defining New Indices}).@refill - -The @code{@@printindex} command takes a two-letter index name, reads -the corresponding sorted index file and formats it appropriately into -an index.@refill - -@ignore -The two-letter index names are: - -@table @samp -@item cp -concept index -@item fn -function index -@item vr -variable index -@item ky -key index -@item pg -program index -@item tp -data type index -@end table -@end ignore -The @code{@@printindex} command does not generate a chapter heading -for the index. Consequently, you should precede the -@code{@@printindex} command with a suitable section or chapter command -(usually @code{@@unnumbered}) to supply the chapter heading and put -the index into the table of contents. Precede the @code{@@unnumbered} -command with an @code{@@node} line.@refill - -@need 1200 -For example: - -@smallexample -@group -@@node Variable Index, Concept Index, Function Index, Top -@@comment node-name, next, previous, up -@@unnumbered Variable Index - -@@printindex vr -@end group - -@group -@@node Concept Index, , Variable Index, Top -@@comment node-name, next, previous, up -@@unnumbered Concept Index - -@@printindex cp -@end group - -@group -@@summarycontents -@@contents -@@bye -@end group -@end smallexample - -@noindent -(Readers often prefer that the concept index come last in a book, -since that makes it easiest to find.)@refill - -@ignore -In @TeX{}, the @code{@@printindex} command needs a sorted index file -to work from. @TeX{} does not know how to do sorting; this is a -deficiency. @TeX{} writes output files of raw index data; use the -@code{texindex} program to convert these files to sorted index files. -(@xref{Format/Print Hardcopy}, for more information.)@refill -@end ignore -@node Contents, File End, Printing Indices & Menus, Ending a File -@comment node-name, next, previous, up -@section Generating a Table of Contents -@cindex Table of contents -@cindex Contents, Table of -@findex contents -@findex summarycontents -@findex shortcontents - -The @code{@@chapter}, @code{@@section}, and other structuring commands -supply the information to make up a table of contents, but they do not -cause an actual table to appear in the manual. To do this, you must -use the @code{@@contents} and @code{@@summarycontents} -commands:@refill - -@table @code -@item @@contents -Generate a table of contents in a printed manual, including all -chapters, sections, subsections, etc., as well as appendices and -unnumbered chapters. (Headings generated by the @code{@@heading} -series of commands do not appear in the table of contents.) The -@code{@@contents} command should be written on a line by -itself.@refill - -@item @@shortcontents -@itemx @@summarycontents -(@code{@@summarycontents} is a synonym for @code{@@shortcontents}; the -two commands are exactly the same.)@refill - -Generate a short or summary table of contents that lists only the -chapters (and appendices and unnumbered chapters). Omit sections, subsections -and subsubsections. Only a long manual needs a short table -of contents in addition to the full table of contents.@refill - -Write the @code{@@shortcontents} command on a line by itself right -@emph{before} the @code{@@contents} command.@refill -@end table - -The table of contents commands automatically generate a chapter-like -heading at the top of the first table of contents page. Write the table -of contents commands at the very end of a Texinfo file, just before the -@code{@@bye} command, following any index sections---anything in the -Texinfo file after the table of contents commands will be omitted from -the table of contents.@refill - -When you print a manual with a table of contents, the table of -contents are printed last and numbered with roman numerals. You need -to place those pages in their proper place, after the title page, -yourself. (This is the only collating you need to do for a printed -manual. The table of contents is printed last because it is generated -after the rest of the manual is typeset.)@refill - -@need 700 -Here is an example of where to write table of contents commands:@refill - -@example -@group -@var{indices}@dots{} -@@shortcontents -@@contents -@@bye -@end group -@end example - -Since an Info file uses menus instead of tables of contents, the Info -formatting commands ignore the @code{@@contents} and -@code{@@shortcontents} commands.@refill - -@node File End, , Contents, Ending a File -@comment node-name, next, previous, up -@section @code{@@bye} File Ending -@findex bye - -An @code{@@bye} command terminates @TeX{} or Info formatting. None of -the formatting commands see any of the file following @code{@@bye}. -The @code{@@bye} command should be on a line by itself.@refill - -If you wish, you may follow the @code{@@bye} line with notes. These notes -will not be formatted and will not appear in either Info or a printed -manual; it is as if text after @code{@@bye} were within @code{@@ignore} -@dots{} @code{@@end ignore}. Also, you may follow the @code{@@bye} line -with a local variables list. @xref{Compile-Command, , Using Local -Variables and the Compile Command}, for more information.@refill - -@node Structuring, Nodes, Ending a File, Top -@comment node-name, next, previous, up -@chapter Chapter Structuring -@cindex Chapter structuring -@cindex Structuring of chapters - -The @dfn{chapter structuring} commands divide a document into a hierarchy of -chapters, sections, subsections, and subsubsections. These commands -generate large headings; they also provide information for the table -of contents of a printed manual (@pxref{Contents, , Generating a Table -of Contents}).@refill - -The chapter structuring commands do not create an Info node structure, -so normally you should put an @code{@@node} command immediately before -each chapter structuring command (@pxref{Nodes}). The only time you -are likely to use the chapter structuring commands without using the -node structuring commands is if you are writing a document that -contains no cross references and will never be transformed into Info -format.@refill - -It is unlikely that you will ever write a Texinfo file that is -intended only as an Info file and not as a printable document. If you -do, you might still use chapter structuring commands to create a -heading at the top of each node---but you don't need to.@refill - -@menu -* Tree Structuring:: A manual is like an upside down tree @dots{} -* Structuring Command Types:: How to divide a manual into parts. -* makeinfo top:: The @code{@@top} command, part of the `Top' node. -* chapter:: -* unnumbered & appendix:: -* majorheading & chapheading:: -* section:: -* unnumberedsec appendixsec heading:: -* subsection:: -* unnumberedsubsec appendixsubsec subheading:: -* subsubsection:: Commands for the lowest level sections. -@end menu - -@node Tree Structuring, Structuring Command Types, , Structuring -@comment node-name, next, previous, up -@section Tree Structure of Sections -@cindex Tree structuring - -A Texinfo file is usually structured like a book with chapters, -sections, subsections, and the like. This structure can be visualized -as a tree (or rather as an upside-down tree) with the root at the top -and the levels corresponding to chapters, sections, subsection, and -subsubsections.@refill - -Here is a diagram that shows a Texinfo file with three chapters, -each of which has two sections.@refill - -@example -@group - Top - | - ------------------------------------- - | | | - Chapter 1 Chapter 2 Chapter 3 - | | | - -------- -------- -------- - | | | | | | - Section Section Section Section Section Section - 1.1 1.2 2.1 2.2 3.1 3.2 - -@end group -@end example - -In a Texinfo file that has this structure, the beginning of Chapter 2 -looks like this:@refill - -@example -@group -@@node Chapter 2, Chapter 3, Chapter 1, top -@@chapter Chapter 2 -@end group -@end example - -The chapter structuring commands are described in the sections that -follow; the @code{@@node} and @code{@@menu} commands are described in -following chapters. (@xref{Nodes}, and see @ref{Menus}.)@refill - -@node Structuring Command Types, makeinfo top, Tree Structuring, Structuring -@comment node-name, next, previous, up -@section Types of Structuring Command - -The chapter structuring commands fall into four groups or series, each -of which contains structuring commands corresponding to the -hierarchical levels of chapters, sections, subsections, and -subsubsections.@refill - -The four groups are the @code{@@chapter} series, the -@code{@@unnumbered} series, the @code{@@appendix} series, and the -@code{@@heading} series.@refill - -Each command produces titles that have a different appearance on the -printed page or Info file; only some of the commands produce -titles that are listed in the table of contents of a printed book or -manual.@refill - -@itemize @bullet -@item -The @code{@@chapter} and @code{@@appendix} series of commands produce -numbered or lettered entries both in the body of a printed work and in -its table of contents.@refill - -@item -The @code{@@unnumbered} series of commands produce unnumbered entries -both in the body of a printed work and in its table of contents. The -@code{@@top} command, which has a special use, is a member of this -series (@pxref{makeinfo top, , @code{@@top}}).@refill - -@item -The @code{@@heading} series of commands produce unnumbered headings -that do not appear in a table of contents. The heading commands never -start a new page.@refill - -@item -The @code{@@majorheading} command produces results similar to using -the @code{@@chapheading} command but generates a larger vertical -whitespace before the heading.@refill - -@item -When an @code{@@setchapternewpage} command says to do so, the -@code{@@chapter}, @code{@@unnumbered}, and @code{@@appendix} commands -start new pages in the printed manual; the @code{@@heading} commands -do not.@refill -@end itemize - -@need 1000 -Here are the four groups of chapter structuring commands:@refill - -@c Slightly different formatting for regular sized books and smallbooks. -@ifset smallbook -@sp 1 -@tex -{\let\rm=\indrm \let\tt=\indtt -\halign{\hskip\itemindent#\hfil& \hskip.5em#\hfil& \hskip.5em#\hfil& -\hskip.5em#\hfil\cr - -& & & \rm No new pages\cr -\rm Numbered& \rm Unnumbered& \rm Lettered and numbered& \rm Unnumbered\cr -\rm In contents& \rm In contents& \rm In contents& \rm Not in contents\cr - -& & & \cr - & \tt @@top& & \tt @@majorheading\cr -\tt @@chapter& \tt @@unnumbered& \tt @@appendix& \tt @@chapheading\cr -\tt @@section& \tt @@unnumberedsec& \tt @@appendixsec& \tt @@heading\cr -\tt @@subsection&\tt @@unnumberedsubsec&\tt @@appendixsubsec& -\tt @@subheading\cr -\tt @@subsubsection& \tt @@unnumberedsubsubsec& \tt @@appendixsubsubsec& -\tt @@subsubheading\cr}} -@end tex -@end ifset -@ifclear smallbook -@sp 1 -@tex -\vbox{ -\halign{\hskip\itemindent\hskip.5em#\hfil& \hskip.5em#\hfil& -\hskip.5em#\hfil& \hskip.5em #\hfil\cr - -& & & \cr -& & & \rm No new pages\cr -\rm Numbered& \rm Unnumbered& \rm Lettered and numbered& \rm Unnumbered\cr -\rm In contents& \rm In contents& \rm In contents& \rm Not in contents\cr - -& & & \cr - & \tt @@top& & \tt @@majorheading\cr -\tt @@chapter& \tt @@unnumbered& \tt @@appendix& \tt @@chapheading\cr -\tt @@section& \tt @@unnumberedsec& \tt @@appendixsec& \tt @@heading\cr -\tt @@subsection&\tt @@unnumberedsubsec&\tt @@appendixsubsec& -\tt @@subheading\cr -\tt @@subsubsection& \tt @@unnumberedsubsubsec& \tt @@appendixsubsubsec& -\tt @@subsubheading\cr}} -@end tex -@end ifclear -@ifinfo -@example -@group - @r{No new pages} -@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} -@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} - - @@top @@majorheading -@@chapter @@unnumbered @@appendix @@chapheading -@@section @@unnumberedsec @@appendixsec @@heading -@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading -@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading -@end group -@end example -@end ifinfo - -@c Cannot line up columns properly inside of an example because of roman -@c proportional fonts. -@ignore -@ifset smallbook -@iftex -@smallexample -@group - @r{No new pages} -@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} -@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} - - @@top @@majorheading -@@chapter @@unnumbered @@appendix @@chapheading -@@section @@unnumberedsec @@appendixsec @@heading -@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading -@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading -@end group -@end smallexample -@end iftex -@end ifset -@ifclear smallbook -@iftex -@smallexample -@group - @r{No new pages} -@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} -@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} - - @@top @@majorheading -@@chapter @@unnumbered @@appendix @@chapheading -@@section @@unnumberedsec @@appendixsec @@heading -@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading -@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading -@end group -@end smallexample -@end iftex -@end ignore - -@node makeinfo top, chapter, Structuring Command Types, Structuring -@comment node-name, next, previous, up -@section @code{@@top} - -The @code{@@top} command is a special sectioning command that you use -only after an @code{@@node Top} line at the beginning of a Texinfo file. -The @code{@@top} command tells the @code{makeinfo} formatter -which node is the `Top' -node. It has the same typesetting effect as @code{@@unnumbered} -(@pxref{unnumbered & appendix, , @code{@@unnumbered}, @code{@@appendix}}). -For detailed information, see -@ref{makeinfo top command, , The @code{@@top} Command}.@refill - -@node chapter, unnumbered & appendix, makeinfo top, Structuring -@comment node-name, next, previous, up -@section @code{@@chapter} -@findex chapter - -@code{@@chapter} identifies a chapter in the document. Write the -command at the beginning of a line and follow it on the same line by -the title of the chapter.@refill - -For example, this chapter in this manual is entitled ``Chapter -Structuring''; the @code{@@chapter} line looks like this:@refill - -@example -@@chapter Chapter Structuring -@end example - -In @TeX{}, the @code{@@chapter} command creates a chapter in the -document, specifying the chapter title. The chapter is numbered -automatically.@refill - -In Info, the @code{@@chapter} command causes the title to appear on a -line by itself, with a line of asterisks inserted underneath. Thus, -in Info, the above example produces the following output:@refill - -@example -Chapter Structuring -******************* -@end example - -@node unnumbered & appendix, majorheading & chapheading, chapter, Structuring -@comment node-name, next, previous, up -@section @code{@@unnumbered}, @code{@@appendix} -@findex unnumbered -@findex appendix - -Use the @code{@@unnumbered} command to create a chapter that appears -in a printed manual without chapter numbers of any kind. Use the -@code{@@appendix} command to create an appendix in a printed manual -that is labelled by letter instead of by number.@refill - -For Info file output, the @code{@@unnumbered} and @code{@@appendix} -commands are equivalent to @code{@@chapter}: the title is printed on a -line by itself with a line of asterisks underneath. (@xref{chapter, , -@code{@@chapter}}.)@refill - -To create an appendix or an unnumbered chapter, write an -@code{@@appendix} or @code{@@unnumbered} command at the beginning of a -line and follow it on the same line by the title, as you would if you -were creating a chapter.@refill - -@node majorheading & chapheading, section, unnumbered & appendix, Structuring -@section @code{@@majorheading}, @code{@@chapheading} -@findex majorheading -@findex chapheading - -The @code{@@majorheading} and @code{@@chapheading} commands put -chapter-like headings in the body of a document.@refill - -However, neither command causes @TeX{} to produce a numbered heading -or an entry in the table of contents; and neither command causes -@TeX{} to start a new page in a printed manual.@refill - -In @TeX{}, an @code{@@majorheading} command generates a larger vertical -whitespace before the heading than an @code{@@chapheading} command but -is otherwise the same.@refill - -In Info, -the @code{@@majorheading} and -@code{@@chapheading} commands are equivalent to -@code{@@chapter}: the title is printed on a line by itself with a line -of asterisks underneath. (@xref{chapter, , @code{@@chapter}}.)@refill - -@node section, unnumberedsec appendixsec heading, majorheading & chapheading, Structuring -@comment node-name, next, previous, up -@section @code{@@section} -@findex section - -In a printed manual, an @code{@@section} command identifies a -numbered section within a chapter. The section title appears in the -table of contents. In Info, an @code{@@section} command provides a -title for a segment of text, underlined with @samp{=}.@refill - -This section is headed with an @code{@@section} command and looks like -this in the Texinfo file:@refill - -@example -@@section @@code@{@@@@section@} -@end example - -To create a section, write the @code{@@section} command at the -beginning of a line and follow it on the same line by the section -title.@refill - -Thus, - -@example -@@section This is a section -@end example - -@noindent -produces - -@example -@group -This is a section -================= -@end group -@end example - -@noindent -in Info. - -@node unnumberedsec appendixsec heading, subsection, section, Structuring -@comment node-name, next, previous, up -@section @code{@@unnumberedsec}, @code{@@appendixsec}, @code{@@heading} -@findex unnumberedsec -@findex appendixsec -@findex heading - -The @code{@@unnumberedsec}, @code{@@appendixsec}, and @code{@@heading} -commands are, respectively, the unnumbered, appendix-like, and -heading-like equivalents of the @code{@@section} command. -(@xref{section, , @code{@@section}}.)@refill - -@table @code -@item @@unnumberedsec -The @code{@@unnumberedsec} command may be used within an -unnumbered chapter or within a regular chapter or appendix to -provide an unnumbered section.@refill - -@item @@appendixsec -@itemx @@appendixsection -@code{@@appendixsection} is a longer spelling of the -@code{@@appendixsec} command; the two are synonymous.@refill -@findex appendixsection - -Conventionally, the @code{@@appendixsec} or @code{@@appendixsection} -command is used only within appendices.@refill - -@item @@heading -You may use the @code{@@heading} command anywhere you wish for a -section-style heading that will not appear in the table of contents.@refill -@end table - -@node subsection, unnumberedsubsec appendixsubsec subheading, unnumberedsec appendixsec heading, Structuring -@comment node-name, next, previous, up -@section The @code{@@subsection} Command -@findex subsection - -Subsections are to sections as sections are to chapters. -(@xref{section, , @code{@@section}}.) In Info, subsection titles are -underlined with @samp{-}. For example,@refill - -@example -@@subsection This is a subsection -@end example - -@noindent -produces - -@example -@group -This is a subsection --------------------- -@end group -@end example - -In a printed manual, subsections are listed in the table of contents -and are numbered three levels deep.@refill - -@node unnumberedsubsec appendixsubsec subheading, subsubsection, subsection, Structuring -@comment node-name, next, previous, up -@section The @code{@@subsection}-like Commands -@cindex Subsection-like commands -@findex unnumberedsubsec -@findex appendixsubsec -@findex subheading - -The @code{@@unnumberedsubsec}, @code{@@appendixsubsec}, and -@code{@@subheading} commands are, respectively, the unnumbered, -appendix-like, and heading-like equivalents of the @code{@@subsection} -command. (@xref{subsection, , @code{@@subsection}}.)@refill - -In Info, the @code{@@subsection}-like commands generate a title -underlined with hyphens. In a printed manual, an @code{@@subheading} -command produces a heading like that of a subsection except that it is -not numbered and does not appear in the table of contents. Similarly, -an @code{@@unnumberedsubsec} command produces an unnumbered heading like -that of a subsection and an @code{@@appendixsubsec} command produces a -subsection-like heading labelled with a letter and numbers; both of -these commands produce headings that appear in the table of -contents.@refill - -@node subsubsection, , unnumberedsubsec appendixsubsec subheading, Structuring -@comment node-name, next, previous, up -@section The `subsub' Commands -@cindex Subsub commands -@findex subsubsection -@findex unnumberedsubsubsec -@findex appendixsubsubsec -@findex subsubheading - -The fourth and lowest level sectioning commands in Texinfo are the -`subsub' commands. They are:@refill - -@table @code -@item @@subsubsection -Subsubsections are to subsections as subsections are to sections. -(@xref{subsection, , @code{@@subsection}}.) In a printed manual, -subsubsection titles appear in the table of contents and are numbered -four levels deep.@refill - -@item @@unnumberedsubsubsec -Unnumbered subsubsection titles appear in the table of contents of a -printed manual, but lack numbers. Otherwise, unnumbered -subsubsections are the same as subsubsections. In Info, unnumbered -subsubsections look exactly like ordinary subsubsections.@refill - -@item @@appendixsubsubsec -Conventionally, appendix commands are used only for appendices and are -lettered and numbered appropriately in a printed manual. They also -appear in the table of contents. In Info, appendix subsubsections look -exactly like ordinary subsubsections.@refill - -@item @@subsubheading -The @code{@@subsubheading} command may be used anywhere that you need -a small heading that will not appear in the table of contents. In -Info, subsubheadings look exactly like ordinary subsubsection -headings.@refill -@end table - -In Info, `subsub' titles are underlined with periods. -For example,@refill - -@example -@@subsubsection This is a subsubsection -@end example - -@noindent -produces - -@example -@group -This is a subsubsection -....................... -@end group -@end example - -@node Nodes, Menus, Structuring, Top -@comment node-name, next, previous, up -@chapter Nodes - -@dfn{Nodes} are the primary segments of a Texinfo file. They do not -themselves impose a hierarchic or any other kind of structure on a file. -Nodes contain @dfn{node pointers} that name other nodes, and can contain -@dfn{menus} which are lists of nodes. In Info, the movement commands -can carry you to a pointed-to node or to a node listed in a menu. Node -pointers and menus provide structure for Info files just as chapters, -sections, subsections, and the like, provide structure for printed -books.@refill - -@menu -* Two Paths:: Different commands to structure - Info output and printed output. -* Node Menu Illustration:: A diagram, and sample nodes and menus. -* node:: How to write a node, in detail. -* makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. -@end menu - -@node Two Paths, Node Menu Illustration, , Nodes -@ifinfo -@heading Two Paths -@end ifinfo - -The node and menu commands and the chapter structuring commands are -independent of each other: - -@itemize @bullet -@item -In Info, node and menu commands provide structure. The chapter -structuring commands generate headings with different kinds of -underlining---asterisks for chapters, hyphens for sections, and so on; -they do nothing else.@refill - -@item -In @TeX{}, the chapter structuring commands generate chapter and section -numbers and tables of contents. The node and menu commands provide -information for cross references; they do nothing else.@refill -@end itemize - -You can use node pointers and menus to structure an Info file any way -you want; and you can write a Texinfo file so that its Info output has a -different structure than its printed output. However, most Texinfo -files are written such that the structure for the Info output -corresponds to the structure for the printed output. It is not -convenient to do otherwise.@refill - -Generally, printed output is structured in a tree-like hierarchy in -which the chapters are the major limbs from which the sections branch -out. Similarly, node pointers and menus are organized to create a -matching structure in the Info output.@refill - -@node Node Menu Illustration, node, Two Paths, Nodes -@comment node-name, next, previous, up -@section Node and Menu Illustration - -Here is a copy of the diagram shown earlier that illustrates a Texinfo -file with three chapters, each of which contains two sections.@refill - -Note that the ``root'' is at the top of the diagram and the ``leaves'' -are at the bottom. This is how such a diagram is drawn conventionally; -it illustrates an upside-down tree. For this reason, the root node is -called the `Top' node, and `Up' node pointers carry you closer to the -root.@refill - -@example -@group - Top - | - ------------------------------------- - | | | - Chapter 1 Chapter 2 Chapter 3 - | | | - -------- -------- -------- - | | | | | | - Section Section Section Section Section Section - 1.1 1.2 2.1 2.2 3.1 3.2 - -@end group -@end example - -Write the beginning of the node for Chapter 2 like this:@refill - -@example -@group -@@node Chapter 2, Chapter 3, Chapter 1, top -@@comment node-name, next, previous, up -@end group -@end example - -@noindent -This @code{@@node} line says that the name of this node is ``Chapter 2'', the -name of the `Next' node is ``Chapter 3'', the name of the `Previous' -node is ``Chapter 1'', and the name of the `Up' node is ``Top''. - -@quotation -@strong{Please Note:} `Next' refers to the next node at the same -hierarchical level in the manual, not necessarily to the next node -within the Texinfo file. In the Texinfo file, the subsequent node may -be at a lower level---a section-level node may follow a chapter-level -node, and a subsection-level node may follow a section-level node. -`Next' and `Previous' refer to nodes at the @emph{same} hierarchical -level. (The `Top' node contains the exception to this rule. Since the -`Top' node is the only node at that level, `Next' refers to the first -following node, which is almost always a chapter or chapter-level -node.)@refill -@end quotation - -To go to Sections 2.1 and 2.2 using Info, you need a menu inside Chapter -2. (@xref{Menus}.) You would write the menu just -before the beginning of Section 2.1, like this:@refill - -@example -@group - @@menu - * Sect. 2.1:: Description of this section. - * Sect. 2.2:: - @@end menu -@end group -@end example - -Write the node for Sect. 2.1 like this:@refill - -@example -@group - @@node Sect. 2.1, Sect. 2.2, Chapter 2, Chapter 2 - @@comment node-name, next, previous, up -@end group -@end example - -In Info format, the `Next' and `Previous' pointers of a node usually -lead to other nodes at the same level---from chapter to chapter or from -section to section (sometimes, as shown, the `Previous' pointer points -up); an `Up' pointer usually leads to a node at the level above (closer -to the `Top' node); and a `Menu' leads to nodes at a level below (closer -to `leaves'). (A cross reference can point to a node at any level; -see @ref{Cross References}.)@refill - -Usually, an @code{@@node} command and a chapter structuring command are -used in sequence, along with indexing commands. (You may follow the -@code{@@node} line with a comment line that reminds you which pointer is -which.)@refill - -Here is the beginning of the chapter in this manual called ``Ending a -Texinfo File''. This shows an @code{@@node} line followed by a comment -line, an @code{@@chapter} line, and then by indexing lines.@refill - -@example -@group -@@node Ending a File, Structuring, Beginning a File, Top -@@comment node-name, next, previous, up -@@chapter Ending a Texinfo File -@@cindex Ending a Texinfo file -@@cindex Texinfo file ending -@@cindex File ending -@end group -@end example - -@node node, makeinfo Pointer Creation, Node Menu Illustration, Nodes -@comment node-name, next, previous, up -@section The @code{@@node} Command - -@cindex Node, defined -A @dfn{node} is a segment of text that begins at an @code{@@node} -command and continues until the next @code{@@node} command. The -definition of node is different from that for chapter or section. A -chapter may contain sections and a section may contain subsections; -but a node cannot contain subnodes; the text of a node continues only -until the next @code{@@node} command in the file. A node usually -contains only one chapter structuring command, the one that follows -the @code{@@node} line. On the other hand, in printed output nodes -are used only for cross references, so a chapter or section may -contain any number of nodes. Indeed, a chapter usually contains -several nodes, one for each section, subsection, and -subsubsection.@refill - -To create a node, write an @code{@@node} command at the beginning of a -line, and follow it with four arguments, separated by commas, on the -rest of the same line. These arguments are the name of the node, and -the names of the `Next', `Previous', and `Up' pointers, in that order. -You may insert spaces before each pointer if you wish; the spaces are -ignored. You must write the name of the node, and the names of the -`Next', `Previous', and `Up' pointers, all on the same line. Otherwise, -the formatters fail. (@inforef{Top, info, info}, for more information -about nodes in Info.)@refill - -Usually, you write one of the chapter-structuring command lines -immediately after an @code{@@node} line---for example, an -@code{@@section} or @code{@@subsection} line. (@xref{Structuring -Command Types, , Types of Structuring Command}.)@refill - -@quotation -@strong{Please note:} The GNU Emacs Texinfo mode updating commands work -only with Texinfo files in which @code{@@node} lines are followed by chapter -structuring lines. @xref{Updating Requirements}.@refill -@end quotation - -@TeX{} uses @code{@@node} lines to identify the names to use for cross -references. For this reason, you must write @code{@@node} lines in a -Texinfo file that you intend to format for printing, even if you do not -intend to format it for Info. (Cross references, such as the one at the -end of this sentence, are made with @code{@@xref} and its related -commands; see @ref{Cross References}.)@refill - -@menu -* Node Names:: How to choose node and pointer names. -* Writing a Node:: How to write an @code{@@node} line. -* Node Line Tips:: Keep names short. -* Node Line Requirements:: Keep names unique, without @@-commands. -* First Node:: How to write a `Top' node. -* makeinfo top command:: How to use the @code{@@top} command. -* Top Node Summary:: Write a brief description for readers. -@end menu - -@node Node Names, Writing a Node, , node -@ifinfo -@subheading Choosing Node and Pointer Names -@end ifinfo - -The name of a node identifies the node. The pointers enable -you to reach other nodes and consist of the names of those nodes.@refill - -Normally, a node's `Up' pointer contains the name of the node whose menu -mentions that node. The node's `Next' pointer contains the name of the -node that follows that node in that menu and its `Previous' pointer -contains the name of the node that precedes it in that menu. When a -node's `Previous' node is the same as its `Up' node, both node pointers -name the same node.@refill - -Usually, the first node of a Texinfo file is the `Top' node, and its -`Up' and `Previous' pointers point to the @file{dir} file, which -contains the main menu for all of Info.@refill - -The `Top' node itself contains the main or master menu for the manual. -Also, it is helpful to include a brief description of the manual in the -`Top' node. @xref{First Node}, for information on how to write the -first node of a Texinfo file.@refill - -@node Writing a Node, Node Line Tips, Node Names, node -@comment node-name, next, previous, up -@subsection How to Write an @code{@@node} Line -@cindex Writing an @code{@@node} line -@cindex @code{@@node} line writing -@cindex Node line writing - -The easiest way to write an @code{@@node} line is to write @code{@@node} -at the beginning of a line and then the name of the node, like -this:@refill - -@example -@@node @var{node-name} -@end example - -If you are using GNU Emacs, you can use the update node commands -provided by Texinfo mode to insert the names of the pointers; or you -can leave the pointers out of the Texinfo file and let @code{makeinfo} -insert node pointers into the Info file it creates. (@xref{Texinfo -Mode}, and @ref{makeinfo Pointer Creation}.)@refill - -Alternatively, you can insert the `Next', `Previous', and `Up' -pointers yourself. If you do this, you may find it helpful to use the -Texinfo mode keyboard command @kbd{C-c C-c n}. This command inserts -@samp{@@node} and a comment line listing the names of the pointers in -their proper order. The comment line helps you keep track of which -arguments are for which pointers. This comment line is especially useful -if you are not familiar with Texinfo.@refill - -The template for a node line with `Next', `Previous', and `Up' pointers -looks like this:@refill - -@example -@@node @var{node-name}, @var{next}, @var{previous}, @var{up} -@end example - -If you wish, you can ignore @code{@@node} lines altogether in your first -draft and then use the @code{texinfo-insert-node-lines} command to -create @code{@@node} lines for you. However, we do not -recommend this practice. It is better to name the node itself -at the same time that you -write a segment so you can easily make cross references. A large number -of cross references are an especially important feature of a good Info -file.@refill - -After you have inserted an @code{@@node} line, you should immediately -write an @@-command for the chapter or section and insert its name. -Next (and this is important!), put in several index entries. Usually, -you will find at least two and often as many as four or five ways of -referring to the node in the index. Use them all. This will make it -much easier for people to find the node.@refill - -@node Node Line Tips, Node Line Requirements, Writing a Node, node -@comment node-name, next, previous, up -@subsection @code{@@node} Line Tips - -Here are three suggestions: - -@itemize @bullet -@item -Try to pick node names that are informative but short.@refill - -In the Info file, the file name, node name, and pointer names are all -inserted on one line, which may run into the right edge of the window. -(This does not cause a problem with Info, but is ugly.)@refill - -@item -Try to pick node names that differ from each other near the beginnings -of their names. This way, it is easy to use automatic name completion in -Info.@refill - -@item -By convention, node names are capitalized just as they would be for -section or chapter titles---initial and significant words are -capitalized; others are not.@refill -@end itemize - -@node Node Line Requirements, First Node, Node Line Tips, node -@comment node-name, next, previous, up -@subsection @code{@@node} Line Requirements - -@cindex Node line requirements -Here are several requirements for @code{@@node} lines: - -@itemize @bullet -@cindex Unique nodename requirement -@cindex Nodename must be unique -@item -All the node names for a single Info file must be unique.@refill - -Duplicates confuse the Info movement commands. This means, for -example, that if you end every chapter with a summary, you must name -each summary node differently. You cannot just call each one -``Summary''. You may, however, duplicate the titles of chapters, sections, -and the like. Thus you can end each chapter in a book with a section -called ``Summary'', so long as the node names for those sections are all -different.@refill - -@item -A pointer name must be the name of a node.@refill - -The node to which a pointer points may come before or after the -node containing the pointer.@refill - -@cindex @@-command in nodename -@cindex Nodename, cannot contain -@item -You cannot use any of the Texinfo @@-commands in a node name; -@w{@@-commands} confuse Info.@refill - -@need 750 -Thus, the beginning of the section called @code{@@chapter} looks like -this:@refill - -@smallexample -@group -@@node chapter, unnumbered & appendix, makeinfo top, Structuring -@@comment node-name, next, previous, up -@@section @@code@{@@@@chapter@} -@@findex chapter -@end group -@end smallexample - -@cindex Comma in nodename -@cindex Colon in nodename -@cindex Apostrophe in nodename -@item -You cannot use commas, colons, or apostrophes within a node name; these -confuse @TeX{} or the Info formatters.@refill - -@need 700 -For example, the following is a section title: - -@smallexample -@@code@{@@@@unnumberedsec@}, @@code@{@@@@appendixsec@}, @@code@{@@@@heading@} -@end smallexample - -@noindent -The corresponding node name is: - -@smallexample -unnumberedsec appendixsec heading -@end smallexample - -@cindex Case in nodename -@item -Case is significant. -@end itemize - -@node First Node, makeinfo top command, Node Line Requirements, node -@comment node-name, next, previous, up -@subsection The First Node -@cindex @samp{@r{Top}} node is first -@cindex First node - -The first node of a Texinfo file is the `Top' node, except in an -included file (@pxref{Include Files}). - -The `Top' node (which must be named @samp{top} or @samp{Top}) should -have as its `Up' and `Previous' nodes the name of a node in another -file, where there is a menu that leads to this file. Specify the file -name in parentheses. If the file is to be installed directly in the -Info directory file, use @samp{(dir)} as the parent of the `Top' node; -this is short for @samp{(dir)top}, and specifies the `Top' node in the -@file{dir} file, which contains the main menu for Info. For example, -the @code{@@node Top} line of this manual looks like this:@refill - -@example -@@node Top, Overview, (dir), (dir) -@end example - -@noindent -(You may use the Texinfo updating commands or the @code{makeinfo} -utility to insert these `Next' and @samp{(dir)} pointers -automatically.)@refill - -@xref{Install an Info File}, for more information about installing -an Info file in the @file{info} directory.@refill - -The `Top' node contains the main or master menu for the document. - -@node makeinfo top command, Top Node Summary, First Node, node -@comment node-name, next, previous, up -@subsection The @code{@@top} Sectioning Command -@findex top @r{(@@-command)} - -A special sectioning command, @code{@@top}, has been created for use -with the @code{@@node Top} line. The @code{@@top} sectioning command tells -@code{makeinfo} that it marks the `Top' node in the file. It provides -the information that @code{makeinfo} needs to insert node -pointers automatically. Write the @code{@@top} command at the -beginning of the line immediately following the @code{@@node Top} -line. Write the title on the remaining part of the same line as the -@code{@@top} command.@refill - -In Info, the @code{@@top} sectioning command causes the title to appear on a -line by itself, with a line of asterisks inserted underneath.@refill - -In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} -sectioning command is merely a synonym for @code{@@unnumbered}. -Neither of these formatters require an @code{@@top} command, and do -nothing special with it. You can use @code{@@chapter} or -@code{@@unnumbered} after the @code{@@node Top} line when you use -these formatters. Also, you can use @code{@@chapter} or -@code{@@unnumbered} when you use the Texinfo updating commands to -create or update pointers and menus.@refill - -Whatever sectioning command follows an @code{@@node Top} line, whether -it be @code{@@top} or @code{@@chapter}, the @code{@@node Top} line and -the immediately following line and any additional text must be -enclosed between @code{@@ifinfo} and @code{@@end ifinfo} commands. -(@xref{Conditionals}.) This prevents the title and the accompanying -text from appearing in printed output. Write the @code{@@ifinfo} -command before the @code{@@node} line and write the @code{@@end ifinfo} command -after the @code{@@top} or other sectioning command and after any -additional text. (You can write the @code{@@end ifinfo} command after -the @code{@@end menu} command if you like.)@refill - -@node Top Node Summary, , makeinfo top command, node -@subsection The `Top' Node Summary -@cindex @samp{@r{Top}} node summary - -You can help readers by writing a summary in the `Top' node, after the -@code{@@top} line, before the main or master menu. The summary should -briefly describe the Info file. You should also write the version -number of the program to which the manual applies in this section. This -helps the reader keep track of which manual is for which version of the -program. If the manual changes more frequently than the program or is -independent of it, you should also include an edition number for the -manual. (The title page should also contain this information: -see @ref{titlepage, , @code{@@titlepage}}.)@refill - -Put the whole of the `Top' node, including the @code{@@top} sectioning -command line if you -have one, between @code{@@ifinfo} and @code{@@end -ifinfo} so none of the text appears in the printed output -(@pxref{Conditionals, , Conditionally Visible Text}). (You may want to -repeat the brief description from the `Top' node within @code{@@iftex} -@dots{} @code{@@end iftex} at the beginning of the first chapter, for -those who read the printed manual.) - -@node makeinfo Pointer Creation, , node, Nodes -@section Creating Pointers with @code{makeinfo} -@cindex Creating pointers with @code{makeinfo} -@cindex Pointer creation with @code{makeinfo} -@cindex Automatic pointer creation with @code{makeinfo} - -The @code{makeinfo} program has a feature for automatically creating -node pointers for a hierarchically organized file that lacks -them.@refill - -When you take advantage of this feature, you do not need to write the -`Next', `Previous', and `Up' pointers after the name of a node. -However, you must write a sectioning command, such as @code{@@chapter} -or @code{@@section}, on the line immediately following each truncated -@code{@@node} line. You cannot write a comment line after a node -line; the section line must follow it immediately.@refill - -In addition, you must follow the `Top' @code{@@node} line with a line beginning -with @code{@@top} to mark the `Top' node in the file. @xref{makeinfo -top, , @code{@@top}}. - -Finally, you must write the name of each node (except for the `Top' -node) in a menu that is one or more hierarchical levels above the -node's hierarchical level.@refill - -This node pointer insertion feature in @code{makeinfo} is an -alternative to the menu and pointer creation and update commands in -Texinfo mode. (@xref{Updating Nodes and Menus}.) It is especially -helpful to people who do not use GNU Emacs for writing Texinfo -documents.@refill - -@node Menus, Cross References, Nodes, Top -@comment node-name, next, previous, up -@chapter Menus -@cindex Menus -@findex menu - -@dfn{Menus} contain pointers to subordinate -nodes.@footnote{Menus can carry you to any node, regardless -of the hierarchical structure; even to nodes in a different -Info file. However, the GNU Emacs Texinfo mode updating -commands work only to create menus of subordinate nodes. -Conventionally, cross references are used to refer to other -nodes.} In Info, you use menus to go to such nodes. Menus -have no effect in printed manuals and do not appear in -them.@refill - -By convention, a menu is put at the end of a node since a reader who -uses the menu may not see text that follows it.@refill - -@ifinfo -A node that has a menu should @emph{not} contain much text. If you -have a lot of text and a menu, move most of the text into a new -subnode---all but a few lines.@refill -@end ifinfo -@iftex -@emph{A node that has a menu should not contain much text.} If you -have a lot of text and a menu, move most of the text into a new -subnode---all but a few lines. Otherwise, a reader with a terminal -that displays only a few lines may miss the menu and its associated -text. As a practical matter, you should locate a menu within 20 lines -of the beginning of the node.@refill -@end iftex - -@menu -* Menu Location:: Put a menu in a short node. -* Writing a Menu:: What is a menu? -* Menu Parts:: A menu entry has three parts. -* Less Cluttered Menu Entry:: Two part menu entry. -* Menu Example:: Two and three part menu entries. -* Other Info Files:: How to refer to a different Info file. -@end menu - -@node Menu Location, Writing a Menu, , Menus -@ifinfo -@heading Menus Need Short Nodes -@end ifinfo -@cindex Menu location -@cindex Location of menus -@cindex Nodes for menus are short -@cindex Short nodes for menus - -@ifinfo -A reader can easily see a menu that is close to the beginning of the -node. The node should be short. As a practical matter, you should -locate a menu within 20 lines of the beginning of the node. -Otherwise, a reader with a terminal that displays only a few lines may -miss the menu and its associated text.@refill -@end ifinfo - -The short text before a menu may look awkward in a printed manual. To -avoid this, you can write a menu near the beginning of its node and -follow the menu by an @code{@@node} line, and then an @code{@@heading} -line located within @code{@@ifinfo} and @code{@@end ifinfo}. This way, -the menu, @code{@@node} line, and title appear only in the Info file, -not the printed document.@refill - -For example, the preceding two paragraphs follow an Info-only menu, -@code{@@node} line, and heading, and look like this:@refill - -@example -@group -@@menu -* Menu Location:: Put a menu in a short node. -* Writing a Menu:: What is a menu? -* Menu Parts:: A menu entry has three parts. -* Less Cluttered Menu Entry:: Two part menu entry. -* Menu Example:: Two and three part entries. -* Other Info Files:: How to refer to a different - Info file. -@@end menu - -@@node Menu Location, Writing a Menu, , Menus -@@ifinfo -@@heading Menus Need Short Nodes -@@end ifinfo -@end group -@end example - -The Texinfo file for this document contains more than a dozen -examples of this procedure. One is at the beginning of this chapter; -another is at the beginning of the ``Cross References'' chapter.@refill - -@node Writing a Menu, Menu Parts, Menu Location, Menus -@section Writing a Menu -@cindex Writing a menu -@cindex Menu writing - -A menu consists of an @code{@@menu} command on a line by -itself followed by menu entry lines or menu comment lines -and then by an @code{@@end menu} command on a line by -itself.@refill - -A menu looks like this:@refill - -@example -@group -@@menu -Larger Units of Text - -* Files:: All about handling files. -* Multiples: Buffers. Multiple buffers; editing - several files at once. -@@end menu -@end group -@end example - -In a menu, every line that begins with an @w{@samp{* }} is a -@dfn{menu entry}. (Note the space after the asterisk.) A -line that does not start with an @w{@samp{* }} may also -appear in a menu. Such a line is not a menu entry but is a -menu comment line that appears in the Info file. In -the example above, the line @samp{Larger Units of Text} is a -menu comment line; the two lines starting with @w{@samp{* }} -are menu entries. - -@node Menu Parts, Less Cluttered Menu Entry, Writing a Menu, Menus -@section The Parts of a Menu -@cindex Parts of a menu -@cindex Menu parts -@cindex @code{@@menu} parts - -A menu entry has three parts, only the second of which is -required:@refill - -@enumerate -@item -The menu entry name. - -@item -The name of the node (required). - -@item -A description of the item. -@end enumerate - -The template for a menu entry looks like this:@refill - -@example -* @var{menu-entry-name}: @var{node-name}. @var{description} -@end example - -Follow the menu entry name with a single colon and follow the node name -with tab, comma, period, or newline.@refill - -In Info, a user selects a node with the @kbd{m} (@code{Info-menu}) -command. The menu entry name is what the user types after the @kbd{m} -command.@refill - -The third part of a menu entry is a descriptive phrase or -sentence. Menu entry names and node names are often short; the -description explains to the reader what the node is about. The -description, which is optional, can spread over two or more lines. A -useful description complements the node name rather than repeats -it.@refill - -@node Less Cluttered Menu Entry, Menu Example, Menu Parts, Menus -@comment node-name, next, previous, up -@section Less Cluttered Menu Entry -@cindex Two part menu entry -@cindex Double-colon menu entries -@cindex Menu entries with two colons -@cindex Less cluttered menu entry -@cindex Uncluttered menu entry - -When the menu entry name and node name are the same, you can write -the name immediately after the asterisk and space at the beginning of -the line and follow the name with two colons.@refill - -@need 800 -For example, write - -@example -* Name:: @var{description} -@end example - -@need 800 -@noindent -instead of - -@example -* Name: Name. @var{description} -@end example - -You should use the node name for the menu entry name whenever possible, -since it reduces visual clutter in the menu.@refill - -@node Menu Example, Other Info Files, Less Cluttered Menu Entry, Menus -@comment node-name, next, previous, up -@section A Menu Example -@cindex Menu example -@cindex Example menu - -A menu looks like this in Texinfo:@refill - -@example -@group -@@menu -* menu entry name: Node name. A short description. -* Node name:: This form is preferred. -@@end menu -@end group -@end example - -@need 800 -@noindent -This produces: - -@example -@group -* menu: - -* menu entry name: Node name. A short description. -* Node name:: This form is preferred. -@end group -@end example - -@need 700 -Here is an example as you might see it in a Texinfo file:@refill - -@example -@group -@@menu -Larger Units of Text - -* Files:: All about handling files. -* Multiples: Buffers. Multiple buffers; editing - several files at once. -@@end menu -@end group -@end example - -@need 800 -@noindent -This produces: - -@example -@group -* menu: -Larger Units of Text - -* Files:: All about handling files. -* Multiples: Buffers. Multiple buffers; editing - several files at once. -@end group -@end example - -In this example, the menu has two entries. @samp{Files} is both a menu -entry name and the name of the node referred to by that name. -@samp{Multiples} is the menu entry name; it refers to the node named -@samp{Buffers}. The line @samp{Larger Units of Text} is a comment; it -appears in the menu, but is not an entry.@refill - -Since no file name is specified with either @samp{Files} or -@samp{Buffers}, they must be the names of nodes in the same Info file -(@pxref{Other Info Files, , Referring to Other Info Files}).@refill - -@node Other Info Files, , Menu Example, Menus -@comment node-name, next, previous, up -@section Referring to Other Info Files -@cindex Referring to other Info files -@cindex Nodes in other Info files -@cindex Other Info files' nodes -@cindex Going to other Info files' nodes -@cindex Info; other files' nodes - -You can create a menu entry that enables a reader in Info to go to a -node in another Info file by writing the file name in parentheses just -before the node name. In this case, you should use the three-part menu -entry format, which saves the reader from having to type the file -name.@refill - -@need 800 -The format looks like this:@refill - -@example -@group -@@menu -* @var{first-entry-name}:(@var{filename})@var{nodename}. @var{description} -* @var{second-entry-name}:(@var{filename})@var{second-node}. @var{description} -@@end menu -@end group -@end example - -For example, to refer directly to the @samp{Outlining} and -@samp{Rebinding} nodes in the @cite{Emacs Manual}, you would write a -menu like this:@refill - -@example -@group -@@menu -* Outlining: (emacs)Outline Mode. The major mode for - editing outlines. -* Rebinding: (emacs)Rebinding. How to redefine the - meaning of a key. -@@end menu -@end group -@end example - -If you do not list the node name, but only name the file, then Info -presumes that you are referring to the `Top' node.@refill - -The @file{dir} file that contains the main menu for Info has menu -entries that list only file names. These take you directly to the `Top' -nodes of each Info document. (@xref{Install an Info File}.)@refill - -@need 700 -For example: - -@example -@group -* Info: (info). Documentation browsing system. -* Emacs: (emacs). The extensible, self-documenting - text editor. -@end group -@end example - -@noindent -(The @file{dir} top level directory for the Info system is an Info file, -not a Texinfo file, but a menu entry looks the same in both types of -file.)@refill - -Note that the GNU Emacs Texinfo mode menu updating commands only work -with nodes within the current buffer, so you cannot use them to create -menus that refer to other files. You must write such menus by hand.@refill - -@node Cross References, Marking Text, Menus, Top -@comment node-name, next, previous, up -@chapter Cross References -@cindex Making cross references -@cindex Cross references -@cindex References - -@dfn{Cross references} are used to refer the reader to other parts of the -same or different Texinfo files. In Texinfo, nodes are the -places to which cross references can refer.@refill - -@menu -* References:: What cross references are for. -* Cross Reference Commands:: A summary of the different commands. -* Cross Reference Parts:: A cross reference has several parts. -* xref:: Begin a reference with `See' @dots{} -* Top Node Naming:: How to refer to the beginning of another file. -* ref:: A reference for the last part of a sentence. -* pxref:: How to write a parenthetical cross reference. -* inforef:: How to refer to an Info-only file. -@end menu - -@node References, Cross Reference Commands, , Cross References -@ifinfo -@heading What References Are For -@end ifinfo - -Often, but not always, a printed document should be designed so that -it can be read sequentially. People tire of flipping back and forth -to find information that should be presented to them as they need -it.@refill - -However, in any document, some information will be too detailed for -the current context, or incidental to it; use cross references to -provide access to such information. Also, an on-line help system or a -reference manual is not like a novel; few read such documents in -sequence from beginning to end. Instead, people look up what they -need. For this reason, such creations should contain many cross -references to help readers find other information that they may not -have read.@refill - -In a printed manual, a cross reference results in a page reference, -unless it is to another manual altogether, in which case the cross -reference names that manual.@refill - -In Info, a cross reference results in an entry that you can follow using -the Info @samp{f} command. (@inforef{Help-Adv, Some advanced Info -commands, info}.)@refill - -The various cross reference commands use nodes to define cross -reference locations. This is evident in Info, in which a cross -reference takes you to the specified node. @TeX{} also uses nodes to -define cross reference locations, but the action is less obvious. When -@TeX{} generates a @sc{dvi} file, it records nodes' page numbers and -uses the page numbers in making references. Thus, if you are writing -a manual that will only be printed, and will not be used on-line, you -must nonetheless write @code{@@node} lines to name the places to which -you make cross references.@refill - -@need 800 -@node Cross Reference Commands, Cross Reference Parts, References, Cross References -@comment node-name, next, previous, up -@section Different Cross Reference Commands -@cindex Different cross reference commands - -There are four different cross reference commands:@refill - -@table @code -@item @@xref -Used to start a sentence in the printed manual saying -@w{`See @dots{}'} or an entry in the Info file saying -@samp{*Note @dots{}}. - -@item @@ref -Used within or, more often, at the end of a sentence; same as -@code{@@xref} for Info; produces just the reference in the printed -manual without a preceding `See'.@refill - -@item @@pxref -Used within parentheses to make a reference that suits both an Info -file and a printed book. Starts with a lower case `see' within the -printed manual. (@samp{p} is for `parenthesis'.)@refill - -@item @@inforef -Used to make a reference to an Info file for which there is no printed -manual.@refill -@end table - -@noindent -(The @code{@@cite} command is used to make references to books and -manuals for which there is no corresponding Info file and, therefore, -no node to which to point. @xref{cite, , @code{@@cite}}.)@refill - -@node Cross Reference Parts, xref, Cross Reference Commands, Cross References -@comment node-name, next, previous, up -@section Parts of a Cross Reference -@cindex Cross reference parts -@cindex Parts of a cross reference - -A cross reference command requires only one argument, which is the -name of the node to which it refers. But a cross reference command -may contain up to four additional arguments. By using these -arguments, you can provide a cross reference name for Info, a topic -description or section title for the printed output, the name of a -different Info file, and the name of a different printed -manual.@refill - -Here is a simple cross reference example:@refill - -@example -@@xref@{Node name@}. -@end example - -@noindent -which produces - -@example -*Note Node name::. -@end example - -@noindent -and - -@quotation -See Section @var{nnn} [Node name], page @var{ppp}. -@end quotation - -@need 700 -Here is an example of a full five-part cross reference:@refill - -@example -@group -@@xref@{Node name, Cross Reference Name, Particular Topic, -info-file-name, A Printed Manual@}, for details. -@end group -@end example - -@noindent -which produces - -@example -*Note Cross Reference Name: (info-file-name)Node name, -for details. -@end example - -@noindent -in Info and - -@quotation -See section ``Particular Topic'' in @i{A Printed Manual}, for details. -@end quotation - -@noindent -in a printed book. - -The five possible arguments for a cross reference are:@refill - -@enumerate -@item -The node name (required). This is the node to which the -cross reference takes you. In a printed document, the location of the -node provides the page reference only for references within the same -document.@refill - -@item -The cross reference name for the Info reference, if it is to be different -from the node name. If you include this argument, it argument becomes -the first part of the cross reference. It is usually omitted.@refill - -@item -A topic description or section name. Often, this is the title of the -section. This is used as the name of the reference in the printed -manual. If omitted, the node name is used.@refill - -@item -The name of the Info file in which the reference is located, if it is -different from the current file.@refill - -@item -The name of a printed manual from a different Texinfo file.@refill -@end enumerate - -The template for a full five argument cross reference looks like -this:@refill - -@example -@group -@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, -@var{info-file-name}, @var{printed-manual-title}@}. -@end group -@end example - -Cross references with one, two, three, four, and five arguments are -described separately following the description of @code{@@xref}.@refill - -Write a node name in a cross reference in exactly the same way as in -the @code{@@node} line, including the same capitalization; otherwise, the -formatters may not find the reference.@refill - -You can write cross reference commands within a paragraph, but note -how Info and @TeX{} format the output of each of the various commands: -write @code{@@xref} at the beginning of a sentence; write -@code{@@pxref} only within parentheses, and so on.@refill - -@node xref, Top Node Naming, Cross Reference Parts, Cross References -@comment node-name, next, previous, up -@section @code{@@xref} -@findex xref -@cindex Cross references using @code{@@xref} -@cindex References using @code{@@xref} - -The @code{@@xref} command generates a cross reference for the -beginning of a sentence. The Info formatting commands convert it into -an Info cross reference, which the Info @samp{f} command can use to -bring you directly to another node. The @TeX{} typesetting commands -convert it into a page reference, or a reference to another book or -manual.@refill - -@menu -* Reference Syntax:: What a reference looks like and requires. -* One Argument:: @code{@@xref} with one argument. -* Two Arguments:: @code{@@xref} with two arguments. -* Three Arguments:: @code{@@xref} with three arguments. -* Four and Five Arguments:: @code{@@xref} with four and five arguments. -@end menu - -@node Reference Syntax, One Argument, , xref -@ifinfo -@subheading What a Reference Looks Like and Requires -@end ifinfo - -Most often, an Info cross reference looks like this:@refill - -@example -*Note @var{node-name}::. -@end example - -@noindent -or like this - -@example -*Note @var{cross-reference-name}: @var{node-name}. -@end example - -@noindent -In @TeX{}, a cross reference looks like this: - -@example -See Section @var{section-number} [@var{node-name}], page @var{page}. -@end example - -@noindent -or like this - -@example -See Section @var{section-number} [@var{title-or-topic}], page @var{page}. -@end example - -The @code{@@xref} command does not generate a period or comma to end -the cross reference in either the Info file or the printed output. -You must write that period or comma yourself; otherwise, Info will not -recognize the end of the reference. (The @code{@@pxref} command works -differently. @xref{pxref, , @code{@@pxref}}.)@refill - -@quotation -@strong{Please note:} A period or comma @strong{must} follow the closing -brace of an @code{@@xref}. It is required to terminate the cross -reference. This period or comma will appear in the output, both in -the Info file and in the printed manual.@refill -@end quotation - -@code{@@xref} must refer to an Info node by name. Use @code{@@node} -to define the node (@pxref{Writing a Node}).@refill - -@code{@@xref} is followed by several arguments inside braces, separated by -commas. Whitespace before and after these commas is ignored.@refill - -A cross reference requires only the name of a node; but it may contain -up to four additional arguments. Each of these variations produces a -cross reference that looks somewhat different.@refill - -@quotation -@strong{Please note:} Commas separate arguments in a cross reference; -avoid including them in the title or other part lest the formatters -mistake them for separators.@refill -@end quotation - -@node One Argument, Two Arguments, Reference Syntax, xref -@subsection @code{@@xref} with One Argument - -The simplest form of @code{@@xref} takes one argument, the name of -another node in the same Info file. The Info formatters produce -output that the Info readers can use to jump to the reference; @TeX{} -produces output that specifies the page and section number for you.@refill - -@need 700 -@noindent -For example, - -@example -@@xref@{Tropical Storms@}. -@end example - -@noindent -produces - -@example -*Note Tropical Storms::. -@end example - -@noindent -and - -@quotation -See Section 3.1 [Tropical Storms], page 24. -@end quotation - -@noindent -(Note that in the preceding example the closing brace is followed by a -period.)@refill - -You can write a clause after the cross reference, like this:@refill - -@example -@@xref@{Tropical Storms@}, for more info. -@end example - -@noindent -which produces - -@example -*Note Tropical Storms::, for more info. -@end example - -@quotation -See Section 3.1 [Tropical Storms], page 24, for more info. -@end quotation - -@noindent -(Note that in the preceding example the closing brace is followed by a -comma, and then by the clause, which is followed by a period.)@refill - -@node Two Arguments, Three Arguments, One Argument, xref -@subsection @code{@@xref} with Two Arguments - -With two arguments, the second is used as the name of the Info cross -reference, while the first is still the name of the node to which the -cross reference points.@refill - -@need 750 -@noindent -The template is like this: - -@example -@@xref@{@var{node-name}, @var{cross-reference-name}@}. -@end example - -@need 700 -@noindent -For example, - -@example -@@xref@{Electrical Effects, Lightning@}. -@end example - -@noindent -produces: - -@example -*Note Lightning: Electrical Effects. -@end example - -@noindent -and - -@quotation -See Section 5.2 [Electrical Effects], page 57. -@end quotation - -@noindent -(Note that in the preceding example the closing brace is followed by a -period; and that the node name is printed, not the cross reference name.)@refill - -You can write a clause after the cross reference, like this:@refill - -@example -@@xref@{Electrical Effects, Lightning@}, for more info. -@end example - -@noindent -which produces -@example -*Note Lightning: Electrical Effects, for more info. -@end example - -@noindent -and - -@quotation -See Section 5.2 [Electrical Effects], page 57, for more info. -@end quotation - -@noindent -(Note that in the preceding example the closing brace is followed by a -comma, and then by the clause, which is followed by a period.)@refill - -@node Three Arguments, Four and Five Arguments, Two Arguments, xref -@subsection @code{@@xref} with Three Arguments - -A third argument replaces the node name in the @TeX{} output. The third -argument should be the name of the section in the printed output, or -else state the topic discussed by that section. Often, you will want to -use initial upper case letters so it will be easier to read when the -reference is printed. Use a third argument when the node name is -unsuitable because of syntax or meaning.@refill - -Remember to avoid placing a comma within the title or topic section of -a cross reference, or within any other section. The formatters divide -cross references into arguments according to the commas; a comma -within a title or other section will divide it into two arguments. In -a reference, you need to write a title such as ``Clouds, Mist, and -Fog'' without the commas.@refill - -Also, remember to write a comma or period after the closing brace of a -@code{@@xref} to terminate the cross reference. In the following -examples, a clause follows a terminating comma.@refill - - -@need 750 -@noindent -The template is like this: - -@example -@group -@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}@}. -@end group -@end example - -@need 700 -@noindent -For example, - -@example -@group -@@xref@{Electrical Effects, Lightning, Thunder and Lightning@}, -for details. -@end group -@end example - -@noindent -produces - -@example -*Note Lightning: Electrical Effects, for details. -@end example - -@noindent -and - -@quotation -See Section 5.2 [Thunder and Lightning], page 57, for details. -@end quotation - -If a third argument is given and the second one is empty, then the -third argument serves both. (Note how two commas, side by side, mark -the empty second argument.)@refill - -@example -@group -@@xref@{Electrical Effects, , Thunder and Lightning@}, -for details. -@end group -@end example - -@noindent -produces - -@example -*Note Thunder and Lightning: Electrical Effects, for details. -@end example - -@noindent -and - -@quotation -See Section 5.2 [Thunder and Lightning], page 57, for details. -@end quotation - -As a practical matter, it is often best to write cross references with -just the first argument if the node name and the section title are the -same, and with the first and third arguments if the node name and title -are different.@refill - -Here are several examples from @cite{The GAWK Manual}:@refill - -@smallexample -@@xref@{Sample Program@}. -@@xref@{Glossary@}. -@@xref@{Case-sensitivity, ,Case-sensitivity in Matching@}. -@@xref@{Close Output, , Closing Output Files and Pipes@}, - for more information. -@@xref@{Regexp, , Regular Expressions as Patterns@}. -@end smallexample - -@node Four and Five Arguments, , Three Arguments, xref -@subsection @code{@@xref} with Four and Five Arguments - -In a cross reference, a fourth argument specifies the name of another -Info file, different from the file in which the reference appears, and -a fifth argument specifies its title as a printed manual.@refill - -Remember that a comma or period must follow the closing brace of an -@code{@@xref} command to terminate the cross reference. In the -following examples, a clause follows a terminating comma.@refill - -@need 800 -@noindent -The template is: - -@example -@group -@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, -@var{info-file-name}, @var{printed-manual-title}@}. -@end group -@end example - -@need 700 -@noindent -For example, - -@example -@@xref@{Electrical Effects, Lightning, Thunder and Lightning, -weather, An Introduction to Meteorology@}, for details. -@end example - -@noindent -produces - -@example -*Note Lightning: (weather)Electrical Effects, for details. -@end example - -@noindent -The name of the Info file is enclosed in parentheses and precedes -the name of the node. - -@noindent -In a printed manual, the reference looks like this:@refill - -@quotation -See section ``Thunder and Lightning'' in @i{An Introduction to -Meteorology}, for details. -@end quotation - -@noindent -The title of the printed manual is typeset in italics; and the -reference lacks a page number since @TeX{} cannot know to which page a -reference refers when that reference is to another manual.@refill - -Often, you will leave out the second argument when you use the long -version of @code{@@xref}. In this case, the third argument, the topic -description, will be used as the cross reference name in Info.@refill - -@noindent -The template looks like this: - -@example -@@xref@{@var{node-name}, , @var{title-or-topic}, @var{info-file-name}, -@var{printed-manual-title}@}, for details. -@end example - -@noindent -which produces - -@example -*Note @var{title-or-topic}: (@var{info-file-name})@var{node-name}, for details. -@end example - -@noindent -and - -@quotation -See section @var{title-or-topic} in @var{printed-manual-title}, for details. -@end quotation - -@need 700 -@noindent -For example, - -@example -@@xref@{Electrical Effects, , Thunder and Lightning, -weather, An Introduction to Meteorology@}, for details. -@end example - -@noindent -produces - -@example -@group -*Note Thunder and Lightning: (weather)Electrical Effects, -for details. -@end group -@end example - -@noindent -and - -@quotation -See section ``Thunder and Lightning'' in @i{An Introduction to -Meteorology}, for details. -@end quotation - -On rare occasions, you may want to refer to another Info file that -is within a single printed manual---when multiple Texinfo files are -incorporated into the same @TeX{} run but make separate Info files. -In this case, you need to specify only the fourth argument, and not -the fifth.@refill - -@node Top Node Naming, ref, xref, Cross References -@section Naming a `Top' Node -@cindex Naming a `Top' Node in references -@cindex @samp{@r{Top}} node naming for references - -In a cross reference, you must always name a node. This means that in -order to refer to a whole manual, you must identify the `Top' node by -writing it as the first argument to the @code{@@xref} command. (This -is different from the way you write a menu entry; see @ref{Other Info -Files, , Referring to Other Info Files}.) At the same time, to -provide a meaningful section topic or title in the printed cross -reference (instead of the word `Top'), you must write an appropriate -entry for the third argument to the @code{@@xref} command. -@refill - -@noindent -Thus, to make a cross reference to @cite{The GNU Make Manual}, -write:@refill - -@example -@@xref@{Top, , Overview, make, The GNU Make Manual@}. -@end example - -@noindent -which produces - -@example -*Note Overview: (make)Top. -@end example - -@noindent -and - -@quotation -See section ``Overview'' in @i{The GNU Make Manual}. -@end quotation - -@noindent -In this example, @samp{Top} is the name of the first node, and -@samp{Overview} is the name of the first section of the manual.@refill -@node ref, pxref, Top Node Naming, Cross References -@comment node-name, next, previous, up -@section @code{@@ref} -@cindex Cross references using @code{@@ref} -@cindex References using @code{@@ref} -@findex ref - -@code{@@ref} is nearly the same as @code{@@xref} except that it does -not generate a `See' in the printed output, just the reference itself. -This makes it useful as the last part of a sentence.@refill - -@need 700 -@noindent -For example, - -@example -For more information, see @@ref@{Hurricanes@}. -@end example - -@noindent -produces - -@example -For more information, see *Note Hurricanes. -@end example - -@noindent -and - -@quotation -For more information, see Section 8.2 [Hurricanes], page 123. -@end quotation - -The @code{@@ref} command sometimes leads writers to express themselves -in a manner that is suitable for a printed manual but looks awkward -in the Info format. Bear in mind that your audience will be using -both the printed and the Info format.@refill - -@need 800 -@noindent -For example, - -@example -@group -Sea surges are described in @@ref@{Hurricanes@}. -@end group -@end example - -@need 800 -@noindent -produces - -@quotation -Sea surges are described in Section 6.7 [Hurricanes], page 72. -@end quotation - -@need 800 -@noindent -in a printed document, and the following in Info: - -@example -Sea surges are described in *Note Hurricanes::. -@end example - -@quotation -@strong{Caution:} You @emph{must} write a period or comma immediately -after an @code{@@ref} command with two or more arguments. Otherwise, -Info will not find the end of the cross reference entry and its -attempt to follow the cross reference will fail. As a general rule, -you should write a period or comma after every @code{@@ref} command. -This looks best in both the printed and the Info output.@refill -@end quotation - -@node pxref, inforef, ref, Cross References -@comment node-name, next, previous, up -@section @code{@@pxref} -@cindex Cross references using @code{@@pxref} -@cindex References using @code{@@pxref} -@findex pxref - -The parenthetical reference command, @code{@@pxref}, is nearly the -same as @code{@@xref}, but you use it @emph{only} inside parentheses -and you do @emph{not} type a comma or period after the command's -closing brace. The command differs from @code{@@xref} in two -ways:@refill - -@enumerate -@item -@TeX{} typesets the reference for the printed manual with a lower case -`see' rather than an upper case `See'.@refill - -@item -The Info formatting commands automatically end the reference with a -closing colon or period.@refill -@end enumerate - -Because one type of formatting automatically inserts closing -punctuation and the other does not, you should use @code{@@pxref} -@emph{only} inside parentheses as part of another sentence. Also, you -yourself should not insert punctuation after the reference, as you do -with @code{@@xref}.@refill - -@code{@@pxref} is designed so that the output looks right and works -right between parentheses both in printed output and in an Info file. -In a printed manual, a closing comma or period should not follow a -cross reference within parentheses; such punctuation is wrong. But in -an Info file, suitable closing punctuation must follow the cross -reference so Info can recognize its end. @code{@@pxref} spares you -the need to use complicated methods to put a terminator into one form -of the output and not the other.@refill - -@noindent -With one argument, a parenthetical cross reference looks like -this:@refill - -@example -@dots{} storms cause flooding (@@pxref@{Hurricanes@}) @dots{} -@end example - -@need 800 -@noindent -which produces - -@example -@group -@dots{} storms cause flooding (*Note Hurricanes::) @dots{} -@end group -@end example - -@noindent -and - -@quotation -@dots{} storms cause flooding (see Section 6.7 [Hurricanes], page 72) @dots{} -@end quotation - -With two arguments, a parenthetical cross reference has this -template:@refill - -@example -@dots{} (@@pxref@{@var{node-name}, @var{cross-reference-name}@}) @dots{} -@end example - -@noindent -which produces - -@example -@dots{} (*Note @var{cross-reference-name}: @var{node-name}.) @dots{} -@end example - -@noindent -and - -@need 1500 -@quotation -@dots{} (see Section @var{nnn} [@var{node-name}], page @var{ppp}) @dots{} -@end quotation - -@code{@@pxref} can be used with up to five arguments just like -@code{@@xref} (@pxref{xref, , @code{@@xref}}).@refill - -@quotation -@strong{Please note:} Use @code{@@pxref} only as a parenthetical -reference. Do not try to use @code{@@pxref} as a clause in a sentence. -It will look bad in either the Info file, the printed output, or -both.@refill - -Also, parenthetical cross references look best at the ends of sentences. -Although you may write them in the middle of a sentence, that location -breaks up the flow of text.@refill -@end quotation - -@node inforef, , pxref, Cross References -@comment node-name, next, previous, up -@section @code{@@inforef} -@cindex Cross references using @code{@@inforef} -@cindex References using @code{@@inforef} -@findex inforef - -@code{@@inforef} is used for cross references to Info files for which -there are no printed manuals. Even in a printed manual, -@code{@@inforef} generates a reference directing the user to look in -an Info file.@refill - -The command takes either two or three arguments, in the following -order:@refill - -@enumerate -@item -The node name. - -@item -The cross reference name (optional). - -@item -The Info file name. -@end enumerate - -@noindent -Separate the arguments with commas, as with @code{@@xref}. Also, you -must terminate the reference with a comma or period after the -@samp{@}}, as you do with @code{@@xref}.@refill - -@noindent -The template is: - -@example -@@inforef@{@var{node-name}, @var{cross-reference-name}, @var{info-file-name}@}, -@end example - -@need 800 -@noindent -Thus, - -@example -@group -@@inforef@{Expert, Advanced Info commands, info@}, -for more information. -@end group -@end example - -@need 800 -@noindent -produces - -@example -@group -*Note Advanced Info commands: (info)Expert, -for more information. -@end group -@end example - -@need 800 -@noindent -and - -@quotation -See Info file @file{info}, node @samp{Expert}, for more information. -@end quotation - -@need 800 -@noindent -Similarly, - -@example -@group -@@inforef@{Expert, , info@}, for more information. -@end group -@end example - -@need 800 -@noindent -produces - -@example -*Note (info)Expert::, for more information. -@end example - -@need 800 -@noindent -and - -@quotation -See Info file @file{info}, node @samp{Expert}, for more information. -@end quotation - -The converse of @code{@@inforef} is @code{@@cite}, which is used to -refer to printed works for which no Info form exists. @xref{cite, , -@code{@@cite}}.@refill - -@node Marking Text, Quotations and Examples, Cross References, Top -@comment node-name, next, previous, up -@chapter Marking Words and Phrases -@cindex Paragraph, marking text within -@cindex Marking words and phrases -@cindex Words and phrases, marking them -@cindex Marking text within a paragraph - -In Texinfo, you can mark words and phrases in a variety of ways. -The Texinfo formatters use this information to determine how to -highlight the text. -You can specify, for example, whether a word or phrase is a -defining occurrence, a metasyntactic variable, or a symbol used in a -program. Also, you can emphasize text.@refill - -@menu -* Indicating:: How to indicate definitions, files, etc. -* Emphasis:: How to emphasize text. -@end menu - -@node Indicating, Emphasis, , Marking Text -@comment node-name, next, previous, up -@section Indicating Definitions, Commands, etc. -@cindex Highlighting text -@cindex Indicating commands, definitions, etc. - -Texinfo has commands for indicating just what kind of object a piece of -text refers to. For example, metasyntactic variables are marked by -@code{@@var}, and code by @code{@@code}. Since the pieces of text are -labelled by commands that tell what kind of object they are, it is easy -to change the way the Texinfo formatters prepare such text. (Texinfo is -an @emph{intentional} formatting language rather than a @emph{typesetting} -formatting language.)@refill - -For example, in a printed manual, -code is usually illustrated in a typewriter font; -@code{@@code} tells @TeX{} to typeset this text in this font. But it -would be easy to change the way @TeX{} highlights code to use another -font, and this change would not effect how keystroke examples are -highlighted. If straight typesetting commands were used in the body -of the file and you wanted to make a change, you would need to check -every single occurrence to make sure that you were changing code and -not something else that should not be changed.@refill - -@menu -* Useful Highlighting:: Highlighting provides useful information. -* code:: How to indicate code. -* kbd:: How to show keyboard input. -* key:: How to specify keys. -* samp:: How to show a literal sequence of characters. -* var:: How to indicate a metasyntactic variable. -* file:: How to indicate the name of a file. -* dfn:: How to specify a definition. -* cite:: How to refer to a book that is not in Info. -@end menu - -@node Useful Highlighting, code, , Indicating -@ifinfo -@subheading Highlighting Commands are Useful -@end ifinfo - -The highlighting commands can be used to generate useful information -from the file, such as lists of functions or file names. It is -possible, for example, to write a program in Emacs Lisp (or a keyboard -macro) to insert an index entry after every paragraph that contains -words or phrases marked by a specified command. You could do this to -construct an index of functions if you had not already made the -entries.@refill - -The commands serve a variety of purposes:@refill - -@table @code -@item @@code@{@var{sample-code}@} -Indicate text that is a literal example of a piece of a program.@refill - -@item @@kbd@{@var{keyboard-characters}@} -Indicate keyboard input.@refill - -@item @@key@{@var{key-name}@} -Indicate the conventional name for a key on a keyboard.@refill - -@item @@samp@{@var{text}@} -Indicate text that is a literal example of a sequence of characters.@refill - -@item @@var@{@var{metasyntactic-variable}@} -Indicate a metasyntactic variable.@refill - -@item @@file@{@var{file-name}@} -Indicate the name of a file.@refill - -@item @@dfn@{@var{term}@} -Indicate the introductory or defining use of a term.@refill - -@item @@cite@{@var{reference}@} -Indicate the name of a book.@refill - -@ignore -@item @@ctrl@{@var{ctrl-char}@} -Use for an @sc{ascii} control character.@refill -@end ignore -@end table - -@node code, kbd, Useful Highlighting, Indicating -@comment node-name, next, previous, up -@subsection @code{@@code}@{@var{sample-code}@} -@findex code - -Use the @code{@@code} command to indicate text that is a piece of a -program and which consists of entire syntactic tokens. Enclose the -text in braces.@refill - -Thus, you should use @code{@@code} for an expression in a program, for -the name of a variable or function used in a program, or for a -keyword. Also, you should use @code{@@code} for the name of a -program, such as @code{diff}, that is a name used in the machine. (You -should write the name of a program in the ordinary text font if you -regard it as a new English word, such as `Emacs' or `Bison'.)@refill - -Use @code{@@code} for environment variables such as @code{TEXINPUTS}, -and other variables.@refill - -Use @code{@@code} for command names in command languages that -resemble programming languages, such as Texinfo or the shell. -For example, @code{@@code} and @code{@@samp} are produced by writing -@samp{@@code@{@@@@code@}} and @samp{@@code@{@@@@samp@}} in the Texinfo -source, respectively.@refill - -Note, however, that you should not use @code{@@code} for shell options -such as @samp{-c} when such options stand alone. (Use @code{@@samp}.) -Also, an entire shell command often looks better if written using -@code{@@samp} rather than @code{@@code}. In this case, the rule is to -choose the more pleasing format.@refill - -It is incorrect to alter the case of a word inside an @code{@@code} -command when it appears at the beginning of a sentence. Most computer -languages are case sensitive. In C, for example, @code{Printf} is -different from the identifier @code{printf}, and most likely is a -misspelling of it. Even in languages which are not case sensitive, it -is confusing to a human reader to see identifiers spelled in different -ways. Pick one spelling and always use that. If you do not want to -start a sentence with a command written all in lower case, you should -rearrange the sentence.@refill - -Do not use the @code{@@code} command for a string of characters shorter -than a syntactic token. If you are writing about @samp{TEXINPU}, which -is just a part of the name for the @code{TEXINPUTS} environment -variable, you should use @code{@@samp}.@refill - -In particular, you should not use the @code{@@code} command when writing -about the characters used in a token; do not, for example, use -@code{@@code} when you are explaining what letters or printable symbols -can be used in the names of functions. (Use @code{@@samp}.) Also, you -should not use @code{@@code} to mark text that is considered input to -programs unless the input is written in a language that is like a -programming language. For example, you should not use @code{@@code} for -the keystroke commands of GNU Emacs (use @code{@@kbd} instead) although -you may use @code{@@code} for the names of the Emacs Lisp functions that -the keystroke commands invoke.@refill - -In the printed manual, @code{@@code} causes @TeX{} to typeset the -argument in a typewriter face. In the Info file, it causes the Info -formatting commands to use single quotation marks around the text. - -@need 700 -For example, - -@example -Use @@code@{diff@} to compare two files. -@end example - -@noindent -produces this in the printed manual:@refill - -@quotation -Use @code{diff} to compare two files. -@end quotation -@iftex - -@noindent -and this in the Info file:@refill - -@example -Use `diff' to compare two files. -@end example -@end iftex - -@node kbd, key, code, Indicating -@comment node-name, next, previous, up -@subsection @code{@@kbd}@{@var{keyboard-characters}@} -@findex kbd - -Use the @code{@@kbd} command for characters of input to be typed by -users. For example, to refer to the characters @kbd{M-a}, -write@refill - -@example -@@kbd@{M-a@} -@end example - -@noindent -and to refer to the characters @kbd{M-x shell}, write@refill - -@example -@@kbd@{M-x shell@} -@end example - -The @code{@@kbd} command has the same effect as @code{@@code} in Info, -but may produce a different font in a printed manual.@refill - -You can embed another @@-command inside the braces of an @code{@@kbd} -command. Here, for example, is the way to describe a command that -would be described more verbosely as ``press an @samp{r} and then -press the @key{RET} key'':@refill - -@example -@@kbd@{r @@key@{RET@}@} -@end example - -@noindent -This produces: @kbd{r @key{RET}} - -You also use the @code{@@kbd} command if you are spelling out the letters -you type; for example:@refill - -@example -To give the @@code@{logout@} command, -type the characters @@kbd@{l o g o u t @@key@{RET@}@}. -@end example - -@noindent -This produces: - -@quotation -To give the @code{logout} command, -type the characters @kbd{l o g o u t @key{RET}}. -@end quotation - -(Also, this example shows that you can add spaces for clarity. If you -really want to mention a space character as one of the characters of -input, write @kbd{@@key@{SPC@}} for it.)@refill - -@node key, samp, kbd, Indicating -@comment node-name, next, previous, up -@subsection @code{@@key}@{@var{key-name}@} -@findex key - -Use the @code{@@key} command for the conventional name for a key on a -keyboard, as in:@refill - -@example -@@key@{RET@} -@end example - -You can use the @code{@@key} command within the argument of an -@code{@@kbd} command when the sequence of characters to be typed -includes one or more keys that are described by name.@refill - -@need 700 -For example, to produce @kbd{C-x @key{ESC}} you would type:@refill - -@example -@@kbd@{C-x @@key@{ESC@}@} -@end example - -@c bob: this next sentence looks weird, having a semi-colon followed by -@c a colon that ends the "sentence".. --mew -Here is a list of the recommended names for keys; they are all in -upper case:@refill -@cindex Recommended names for keys -@cindex Keys, recommended names -@cindex Names recommended for keys -@cindex Abbreviations for keys - -@quotation -@table @t -@item SPC -Space -@item RET -Return -@item LFD -Linefeed -@item TAB -Tab -@item BS -Backspace -@item ESC -Escape -@item DEL -Delete -@item SFT -Shift -@item CTL -Control -@item META -Meta -@end table -@end quotation - -There are subtleties to handling words like `meta' or `ctl' that are -names of shift keys. When mentioning a character in which the shift -key is used, such as @kbd{Meta-a}, use the @code{@@kbd} command alone; -do not use the @code{@@key} command; but when you are referring to the -shift key in isolation, use the @code{@@key} command. For example, -write @samp{@@kbd@{Meta-a@}} to produce @kbd{Meta-a} and -@samp{@@key@{META@}} to produce @key{META}. This is because -@kbd{Meta-a} refers to keys that you press on a keyboard, but -@key{META} refers to a key without implying that you press it. In -short, use @code{@@kbd} for what you do, and use @code{@@key} for what -you talk about: ``Press @code{@@kbd@{M-a@}} to move point to the -beginning of the sentence. The @code{@@key@{META@}} key is often in the -lower left of the keyboard.''@refill -@cindex META key - -@node samp, var, key, Indicating -@comment node-name, next, previous, up -@subsection @code{@@samp}@{@var{text}@} -@findex samp - -Use the @code{@@samp} command to indicate text that is a literal example -or `sample' of a sequence of characters in a file, string, pattern, etc. -Enclose the text in braces. The argument appears within single -quotation marks in both the Info file and the printed manual; in -addition, it is printed in a fixed-width font.@refill - -@example -To match @@samp@{foo@} at the end of the line, -use the regexp @@samp@{foo$@}. -@end example - -@noindent -produces - -@quotation -To match @samp{foo} at the end of the line, use the regexp -@samp{foo$}.@refill -@end quotation - -Any time you are referring to single characters, you should use -@code{@@samp} unless @code{@@kbd} is more appropriate. Use -@code{@@samp} for the names of command-line options. Also, you may use -@code{@@samp} for entire statements in C and for entire shell -commands---in this case, @code{@@samp} often looks better than -@code{@@code}. Basically, @code{@@samp} is a catchall for whatever is -not covered by @code{@@code}, @code{@@kbd}, or @code{@@key}.@refill - -Only include punctuation marks within braces if they are part of the -string you are specifying. Write punctuation marks outside the braces -if those punctuation marks are part of the English text that surrounds -the string. In the following sentence, for example, the commas and -period are outside of the braces:@refill - -@example -@group -In English, the vowels are @@samp@{a@}, @@samp@{e@}, -@@samp@{i@}, @@samp@{o@}, @@samp@{u@}, and sometimes -@@samp@{y@}. -@end group -@end example - -@noindent -This produces: - -@quotation -In English, the vowels are @samp{a}, @samp{e}, -@samp{i}, @samp{o}, @samp{u}, and sometimes -@samp{y}. -@end quotation - -@node var, file, samp, Indicating -@comment node-name, next, previous, up -@subsection @code{@@var}@{@var{metasyntactic-variable}@} -@findex var - -Use the @code{@@var} command to indicate metasyntactic variables. A -@dfn{metasyntactic variable} is something that stands for another piece of -text. For example, you should use a metasyntactic variable in the -documentation of a function to describe the arguments that are passed -to that function.@refill - -Do not use @code{@@var} for the names of particular variables in -programming languages. These are specific names from a program, so -@code{@@code} is correct for them. For example, the Lisp variable -@code{texinfo-tex-command} is not a metasyntactic variable; it is -properly formatted using @code{@@code}.@refill - -The effect of @code{@@var} in the Info file is to change the case of -the argument to all upper case; in the printed manual, to italicize it. - -@need 700 -For example, - -@example -To delete file @@var@{filename@}, -type @@code@{rm @@var@{filename@}@}. -@end example - -@noindent -produces - -@quotation -To delete file @var{filename}, type @code{rm @var{filename}}. -@end quotation - -@noindent -(Note that @code{@@var} may appear inside @code{@@code}, -@code{@@samp}, @code{@@file}, etc.)@refill - -Write a metasyntactic variable all in lower case without spaces, and -use hyphens to make it more readable. Thus, the Texinfo source for -the illustration of how to begin a Texinfo manual looks like -this:@refill - -@example -@group -\input texinfo -@@@@setfilename @@var@{info-file-name@} -@@@@settitle @@var@{name-of-manual@} -@end group -@end example - -@noindent -This produces: - -@example -@group -\input texinfo -@@setfilename @var{info-file-name} -@@settitle @var{name-of-manual} -@end group -@end example - -In some documentation styles, metasyntactic variables are shown with -angle brackets, for example:@refill - -@example -@dots{}, type rm -@end example - -@noindent -However, that is not the style that Texinfo uses. (You can, of -course, modify the sources to @TeX{} and the Info formatting commands -to output the @code{<@dots{}>} format if you wish.)@refill - -@node file, dfn, var, Indicating -@comment node-name, next, previous, up -@subsection @code{@@file}@{@var{file-name}@} -@findex file - -Use the @code{@@file} command to indicate text that is the name of a -file, buffer, or directory, or is the name of a node in Info. You can -also use the command for file name suffixes. Do not use @code{@@file} -for symbols in a programming language; use @code{@@code}. - -Currently, @code{@@file} is equivalent to @code{@@samp} in its effects. -For example,@refill - -@example -The @@file@{.el@} files are in -the @@file@{/usr/local/emacs/lisp@} directory. -@end example - -@noindent -produces - -@quotation -The @file{.el} files are in -the @file{/usr/local/emacs/lisp} directory. -@end quotation - -@node dfn, cite, file, Indicating -@comment node-name, next, previous, up -@subsection @code{@@dfn}@{@var{term}@} -@findex dfn - -Use the @code{@@dfn} command to identify the introductory or defining -use of a technical term. Use the command only in passages whose -purpose is to introduce a term which will be used again or which the -reader ought to know. Mere passing mention of a term for the first -time does not deserve @code{@@dfn}. The command generates italics in -the printed manual, and double quotation marks in the Info file. For -example:@refill - -@example -Getting rid of a file is called @@dfn@{deleting@} it. -@end example - -@noindent -produces - -@quotation -Getting rid of a file is called @dfn{deleting} it. -@end quotation - -As a general rule, a sentence containing the defining occurrence of a -term should be a definition of the term. The sentence does not need -to say explicitly that it is a definition, but it should contain the -information of a definition---it should make the meaning clear. - -@node cite, , dfn, Indicating -@comment node-name, next, previous, up -@subsection @code{@@cite}@{@var{reference}@} -@findex cite - -Use the @code{@@cite} command for the name of a book that lacks a -companion Info file. The command produces italics in the printed -manual, and quotation marks in the Info file.@refill - -(If a book is written in Texinfo, it is better to use a cross reference -command since a reader can easily follow such a reference in Info. -@xref{xref, , @code{@@xref}}.)@refill -@ignore - -@c node ctrl, , cite, Indicating -@comment node-name, next, previous, up -@c subsection @code{@@ctrl}@{@var{ctrl-char}@} -@findex ctrl - -The @code{@@ctrl} command is seldom used. It describes an @sc{ascii} -control character by inserting the actual character into the Info -file. - -Usually, in Texinfo, you talk what you type as keyboard entry by -describing it with @code{@@kbd}: thus, @samp{@@kbd@{C-a@}} for -@kbd{C-a}. Use @code{@@kbd} in this way when talking about a control -character that is typed on the keyboard by the user. When talking -about a control character appearing in a file or a string, do not use -@code{@@kbd} since the control character is not typed. Also, do not -use @samp{C-} but spell out @code{control-}, as in @samp{control-a}, -to make it easier for a reader to understand.@refill - -@code{@@ctrl} is an idea from the beginnings of Texinfo which may not -really fit in to the scheme of things. But there may be times when -you want to use the command. The pattern is -@code{@@ctrl@{@var{ch}@}}, where @var{ch} is an @sc{ascii} character -whose control-equivalent is wanted. For example, to specify -@samp{control-f}, you would enter@refill - -@example -@@ctrl@{f@} -@end example - -@noindent -produces - -@quotation -@ctrl{f} -@end quotation - -In the Info file, this generates the specified control character, output -literally into the file. This is done so a user can copy the specified -control character (along with whatever else he or she wants) into another -Emacs buffer and use it. Since the `control-h',`control-i', and -`control-j' characters are formatting characters, they should not be -indicated with @code{@@ctrl}.@refill - -In a printed manual, @code{@@ctrl} generates text to describe or -identify that control character: an uparrow followed by the character -@var{ch}.@refill -@end ignore - -@node Emphasis, , Indicating, Marking Text -@comment node-name, next, previous, up -@section Emphasizing Text -@cindex Emphasizing text - -Usually, Texinfo changes the font to mark words in the text according to -what category the words belong to; an example is the @code{@@code} command. -Most often, this is the best way to mark words. -However, sometimes you will want to emphasize text without indicating a -category. Texinfo has two commands to do this. Also, Texinfo has -several commands that specify the font in which @TeX{} will typeset -text. These commands have no affect on Info and only one of them, -the @code{@@r} command, has any regular use.@refill - -@menu -* emph & strong:: How to emphasize text in Texinfo. -* Smallcaps:: How to use the small caps font. -* Fonts:: Various font commands for printed output. -@end menu - -@node emph & strong, Smallcaps, , Emphasis -@comment node-name, next, previous, up -@subsection @code{@@emph}@{@var{text}@} and @code{@@strong}@{@var{text}@} -@cindex Emphasizing text, font for -@findex emph -@findex strong - -The @code{@@emph} and @code{@@strong} commands are for emphasis; -@code{@@strong} is stronger. In printed output, @code{@@emph} -produces @emph{italics} and @code{@@strong} produces -@strong{bold}.@refill - -@need 800 -For example, - -@example -@group -@@quotation -@@strong@{Caution:@} @@code@{rm * .[^.]*@} removes @@emph@{all@} -files in the directory. -@@end quotation -@end group -@end example - -@iftex -@noindent -produces the following in printed output: - -@quotation -@strong{Caution}: @code{rm * .[^.]*} removes @emph{all} -files in the directory. -@end quotation - -@noindent -and the following in Info: -@end iftex -@ifinfo -@noindent -produces: -@end ifinfo - -@example - *Caution*: `rm * .[^.]*' removes *all* - files in the directory. -@end example - -The @code{@@strong} command is seldom used except to mark what is, in -effect, a typographical element, such as the word `Caution' in the -preceding example. - -In the Info file, both @code{@@emph} and @code{@@strong} put asterisks -around the text.@refill - -@quotation -@strong{Caution:} Do not use @code{@@emph} or @code{@@strong} with the -word @samp{Note}; Info will mistake the combination for a cross -reference. Use a phrase such as @strong{Please note} or -@strong{Caution} instead.@refill -@end quotation - -@node Smallcaps, Fonts, emph & strong, Emphasis -@subsection @code{@@sc}@{@var{text}@}: The Small Caps Font -@cindex Small caps font -@findex sc @r{(small caps font)} - -@iftex -Use the @samp{@@sc} command to set text in the printed output in @sc{a -small caps font} and set text in the Info file in upper case letters.@refill -@end iftex -@ifinfo -Use the @samp{@@sc} command to set text in the printed output in a -small caps font and set text in the Info file in upper case letters.@refill -@end ifinfo - -Write the text between braces in lower case, like this:@refill - -@example -The @@sc@{acm@} and @@sc@{ieee@} are technical societies. -@end example - -@noindent -This produces: - -@display -The @sc{acm} and @sc{ieee} are technical societies. -@end display - -@TeX{} typesets the small caps font in a manner that prevents the -letters from `jumping out at you on the page'. This makes small caps -text easier to read than text in all upper case. The Info formatting -commands set all small caps text in upper case.@refill - -@ifinfo -If the text between the braces of an @code{@@sc} command is upper case, -@TeX{} typesets in full-size capitals. Use full-size capitals -sparingly.@refill -@end ifinfo -@iftex -If the text between the braces of an @code{@@sc} command is upper case, -@TeX{} typesets in @sc{FULL-SIZE CAPITALS}. Use full-size capitals -sparingly.@refill -@end iftex - -You may also use the small caps font for a jargon word such as -@sc{ato} (a @sc{nasa} word meaning `abort to orbit').@refill - -There are subtleties to using the small caps font with a jargon word -such as @sc{cdr}, a word used in Lisp programming. In this case, you -should use the small caps font when the word refers to the second and -subsequent elements of a list (the @sc{cdr} of the list), but you -should use @samp{@@code} when the word refers to the Lisp function of -the same spelling.@refill - -@node Fonts, , Smallcaps, Emphasis -@comment node-name, next, previous, up -@subsection Fonts for Printing, Not Info -@cindex Fonts for printing, not for Info -@findex i @r{(italic font)} -@findex b @r{(bold font)} -@findex t @r{(typewriter font)} -@findex r @r{(Roman font)} - -Texinfo provides four font commands that specify font changes in the -printed manual but have no effect in the Info file. @code{@@i} -requests @i{italic} font (in some versions of @TeX{}, a slanted font -is used), @code{@@b} requests @b{bold} face, @code{@@t} requests the -@t{fixed-width}, typewriter-style font used by @code{@@code}, and @code{@@r} requests a -@r{roman} font, which is the usual font in which text is printed. All -four commands apply to an argument that follows, surrounded by -braces.@refill - -Only the @code{@@r} command has much use: in example programs, you -can use the @code{@@r} command to convert code comments from the -fixed-width font to a roman font. This looks better in printed -output.@refill - -@need 700 -For example, - -@example -@group -@@lisp -(+ 2 2) ; @@r@{Add two plus two.@} -@@end lisp -@end group -@end example - -@noindent -produces - -@lisp -(+ 2 2) ; @r{Add two plus two.} -@end lisp - -If possible, you should avoid using the other three font commands. If -you need to use one, it probably indicates a gap in the Texinfo -language.@refill - -@node Quotations and Examples, Lists and Tables, Marking Text, Top -@comment node-name, next, previous, up -@chapter Quotations and Examples - -Quotations and examples are blocks of text consisting of one or more -whole paragraphs that are set off from the bulk of the text and -treated differently. They are usually indented.@refill - -In Texinfo, you always begin a quotation or example by writing an -@@-command at the beginning of a line by itself, and end it by writing -an @code{@@end} command that is also at the beginning of a line by -itself. For instance, you begin an example by writing @code{@@example} -by itself at the beginning of a line and end the example by writing -@code{@@end example} on a line by itself, at the beginning of that -line.@refill -@findex end - -@menu -* Block Enclosing Commands:: Use different constructs for - different purposes. -* quotation:: How to write a quotation. -* example:: How to write an example in a fixed-width font. -* noindent:: How to prevent paragraph indentation. -* Lisp Example:: How to illustrate Lisp code. -* smallexample & smalllisp:: Forms for the @code{@@smallbook} option. -* display:: How to write an example in the current font. -* format:: How to write an example that does not narrow - the margins. -* exdent:: How to undo the indentation of a line. -* flushleft & flushright:: How to push text flushleft or flushright. -* cartouche:: How to draw cartouches around examples. -@end menu - -@node Block Enclosing Commands, quotation, , Quotations and Examples -@section The Block Enclosing Commands - -Here are commands for quotations and examples:@refill - -@table @code -@item @@quotation -Indicate text that is quoted. The text is filled, indented, and -printed in a roman font by default.@refill - -@item @@example -Illustrate code, commands, and the like. The text is printed -in a fixed-width font, and indented but not filled.@refill - -@item @@lisp -Illustrate Lisp code. The text is printed in a fixed-width font, -and indented but not filled.@refill - -@item @@smallexample -Illustrate code, commands, and the like. Similar to -@code{@@example}, except that in @TeX{} this command typesets text in -a smaller font for the smaller @code{@@smallbook} format than for the -8.5 by 11 inch format.@refill - -@item @@smalllisp -Illustrate Lisp code. Similar to @code{@@lisp}, except that -in @TeX{} this command typesets text in a smaller font for the smaller -@code{@@smallbook} format than for the 8.5 by 11 inch format.@refill - -@item @@display -Display illustrative text. The text is indented but not filled, and -no font is specified (so, by default, the font is roman).@refill - -@item @@format -Print illustrative text. The text is not indented and not filled -and no font is specified (so, by default, the font is roman).@refill -@end table - -The @code{@@exdent} command is used within the above constructs to -undo the indentation of a line. - -The @code{@@flushleft} and @code{@@flushright} commands are used to line -up the left or right margins of unfilled text.@refill - -The @code{@@noindent} command may be used after one of the above -constructs to prevent the following text from being indented as a new -paragraph.@refill - -You can use the @code{@@cartouche} command within one of the above -constructs to highlight the example or quotation by drawing a box with -rounded corners around it. (The @code{@@cartouche} command affects -only the printed manual; it has no effect in the Info file; see -@ref{cartouche, , Drawing Cartouches Around Examples}.)@refill - -@node quotation, example, Block Enclosing Commands, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@quotation} -@cindex Quotations -@findex quotation - -The text of a quotation is -processed normally except that:@refill - -@itemize @bullet -@item -the margins are closer to the center of the page, so the whole of the -quotation is indented;@refill - -@item -the first lines of paragraphs are indented no more than other -lines;@refill - -@item -in the printed output, interparagraph spacing is reduced.@refill -@end itemize - -@quotation -This is an example of text written between an @code{@@quotation} -command and an @code{@@end quotation} command. An @code{@@quotation} -command is most often used to indicate text that is excerpted from -another (real or hypothetical) printed work.@refill -@end quotation - -Write an @code{@@quotation} command as text on a line by itself. This -line will disappear from the output. Mark the end of the quotation -with a line beginning with and containing only @code{@@end quotation}. -The @code{@@end quotation} line will likewise disappear from the -output. Thus, the following,@refill - -@example -@@quotation -This is -a foo. -@@end quotation -@end example - -@noindent -produces - -@quotation -This is a foo. -@end quotation - -@node example, noindent, quotation, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@example} -@cindex Examples, formatting them -@cindex Formatting examples -@findex example - -The @code{@@example} command is used to indicate an example that is -not part of the running text, such as computer input or output.@refill - -@example -@group -This is an example of text written between an -@code{@@example} command -and an @code{@@end example} command. -The text is indented but not filled. -@end group - -@group -In the printed manual, the text is typeset in a -fixed-width font, and extra spaces and blank lines are -significant. In the Info file, an analogous result is -obtained by indenting each line with five spaces. -@end group -@end example - -Write an @code{@@example} command at the beginning of a line by itself. -This line will disappear from the output. Mark the end of the example -with an @code{@@end example} command, also written at the beginning of a -line by itself. The @code{@@end example} will disappear from the -output.@refill - -@need 700 -For example, - -@example -@@example -mv foo bar -@@end example -@end example - -@noindent -produces - -@example -mv foo bar -@end example - -Since the lines containing @code{@@example} and @code{@@end example} -will disappear, you should put a blank line before the -@code{@@example} and another blank line after the @code{@@end -example}. (Remember that blank lines between the beginning -@code{@@example} and the ending @code{@@end example} will appear in -the output.)@refill - -@quotation -@strong{Caution:} Do not use tabs in the lines of an example (or anywhere -else in Texinfo, for that matter)! @TeX{} treats tabs as single -spaces, and that is not what they look like. This is a problem with -@TeX{}. (If necessary, in Emacs, you can use @kbd{M-x untabify} to -convert tabs in a region to multiple spaces.)@refill -@end quotation - -Examples are often, logically speaking, ``in the middle'' of a -paragraph, and the text continues after an example should not be -indented. The @code{@@noindent} command prevents a piece of text from -being indented as if it were a new paragraph. -@ifinfo -(@xref{noindent}.) -@end ifinfo - -(The @code{@@code} command is used for examples of code that are -embedded within sentences, not set off from preceding and following -text. @xref{code, , @code{@@code}}.) - -@node noindent, Lisp Example, example, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@noindent} -@findex noindent - -An example or other inclusion can break a paragraph into segments. -Ordinarily, the formatters indent text that follows an example as a new -paragraph. However, you can prevent this by writing @code{@@noindent} -at the beginning of a line by itself preceding the continuation -text.@refill - -@need 750 -For example: - -@example -@group -@@example -This is an example -@@end example - -@@noindent -This line is not indented. As you can see, the -beginning of the line is fully flush left with the line -that follows after it. (This whole example is between -@@code@{@@@@display@} and @@code@{@@@@end display@}.) -@end group -@end example - -@noindent -produces - -@display -@example -This is an example -@end example -@tex -% Remove extra vskip; this is a kludge to counter the effect of display -\vskip-3.5\baselineskip -@end tex - -@noindent -This line is not indented. As you can see, the -beginning of the line is fully flush left with the line -that follows after it. (This whole example is between -@code{@@display} and @code{@@end display}.) -@end display - -To adjust the number of blank lines properly in the Info file output, -remember that the line containing @code{@@noindent} does not generate a -blank line, and neither does the @code{@@end example} line.@refill - -In the Texinfo source file for this manual, each line that says -`produces' is preceded by a line containing @code{@@noindent}.@refill - -Do not put braces after an @code{@@noindent} command; they are not -necessary, since @code{@@noindent} is a command used outside of -paragraphs (@pxref{Command Syntax}).@refill - -@node Lisp Example, smallexample & smalllisp, noindent, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@lisp} -@cindex Lisp example -@findex lisp - -The @code{@@lisp} command is used for Lisp code. It is synonymous -with the @code{@@example} command. - -@lisp -This is an example of text written between an -@code{@@lisp} command and an @code{@@end lisp} command. -@end lisp - -Use @code{@@lisp} instead of @code{@@example} so as to preserve -information regarding the nature of the example. This is useful, for -example, if you write a function that evaluates only and all the Lisp -code in a Texinfo file. Then you can use the Texinfo file as a Lisp -library.@footnote{It would be straightforward to extend Texinfo to -work in a similar fashion for C, @sc{fortran}, or other languages.}@refill - -Mark the end of @code{@@lisp} with @code{@@end lisp} on a line by -itself.@refill - -@node smallexample & smalllisp, display, Lisp Example, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@smallexample} and @code{@@smalllisp} -@cindex Small book example -@cindex Example for a small book -@cindex Lisp example for a small book -@findex smallexample -@findex smalllisp - -In addition to the regular @code{@@example} and @code{@@lisp} commands, -Texinfo has two other ``example-style'' commands. These are the -@code{@@smallexample} and @code{@@smalllisp} commands. Both these -commands are designed for use with the @code{@@smallbook} command that -causes @TeX{} to produce a printed manual in a 7 by 9.25 inch format -rather than the regular 8.5 by 11 inch format.@refill - -In @TeX{}, the @code{@@smallexample} and @code{@@smalllisp} commands -typeset text in a smaller font for the smaller @code{@@smallbook} -format than for the 8.5 by 11 inch format. Consequently, many examples -containing long lines fit in a narrower, @code{@@smallbook} page -without needing to be shortened. Both commands typeset in the normal -font size when you format for the 8.5 by 11 inch size; indeed, -in this situation, the @code{@@smallexample} and @code{@@smalllisp} -commands are defined to be the @code{@@example} and @code{@@lisp} -commands.@refill - -In Info, the @code{@@smallexample} and @code{@@smalllisp} commands are -equivalent to the @code{@@example} and @code{@@lisp} commands, and work -exactly the same.@refill - -Mark the end of @code{@@smallexample} or @code{@@smalllisp} with -@code{@@end smallexample} or @code{@@end smalllisp}, -respectively.@refill - -@iftex -Here is an example written in the small font used by the -@code{@@smallexample} and @code{@@smalllisp} commands: - -@ifclear smallbook -@display -@tex -% Remove extra vskip; this is a kludge to counter the effect of display -\vskip-3\baselineskip -{\ninett -\dots{} to make sure that you have the freedom to -distribute copies of free software (and charge for -this service if you wish), that you receive source -code or can get it if you want it, that you can -change the software or use pieces of it in new free -programs; and that you know you can do these things.} -@end tex -@end display -@end ifclear -@end iftex -@ifset smallbook -@iftex -@smallexample -This is an example of text written between @code{@@smallexample} and -@code{@@end smallexample}. In Info and in an 8.5 by 11 inch manual, -this text appears in its normal size; but in a 7 by 9.25 inch manual, -this text appears in a smaller font. -@end smallexample -@end iftex -@end ifset -@ifinfo -@smallexample -This is an example of text written between @code{@@smallexample} and -@code{@@end smallexample}. In Info and in an 8.5 by 11 inch manual, -this text appears in its normal size; but in a 7 by 9.25 inch manual, -this text appears in a smaller font. -@end smallexample -@end ifinfo - -The @code{@@smallexample} and @code{@@smalllisp} commands make it -easier to prepare smaller format manuals without forcing you to edit -examples by hand to fit them onto narrower pages.@refill - -As a general rule, a printed document looks better if you write all the -examples in a chapter consistently in @code{@@example} or in -@code{@@smallexample}. Only occasionally should you mix the two -formats.@refill - -@xref{smallbook, , Printing ``Small'' Books}, for more information -about the @code{@@smallbook} command.@refill - -@node display, format, smallexample & smalllisp, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@display} -@cindex Display formatting -@findex display - -The @code{@@display} command begins a kind of example. It is like the -@code{@@example} command -except that, in -a printed manual, @code{@@display} does not select the fixed-width -font. In fact, it does not specify the font at all, so that the text -appears in the same font it would have appeared in without the -@code{@@display} command.@refill - -@display -This is an example of text written between an @code{@@display} command -and an @code{@@end display} command. The @code{@@display} command -indents the text, but does not fill it. -@end display - -@node format, exdent, display, Quotations and Examples -@comment node-name, next, previous, up -@section @code{@@format} -@findex format - -The @code{@@format} command is similar to @code{@@example} except -that, in the printed manual, @code{@@format} does not select the -fixed-width font and does not narrow the margins.@refill - -@format -This is an example of text written between an @code{@@format} command -and an @code{@@end format} command. As you can see -from this example, -the @code{@@format} command does not fill the text. -@end format - -@node exdent, flushleft & flushright, format, Quotations and Examples -@section @code{@@exdent}: Undoing a Line's Indentation -@cindex Indentation undoing -@findex exdent - -The @code{@@exdent} command removes any indentation a line might have. -The command is written at the beginning of a line and applies only to -the text that follows the command that is on the same line. Do not use -braces around the text. In a printed manual, the text on an -@code{@@exdent} line is printed in the roman font.@refill - -@code{@@exdent} is usually used within examples. Thus,@refill - -@example -@group -@@example -This line follows an @@@@example command. -@@exdent This line is exdented. -This line follows the exdented line. -The @@@@end example comes on the next line. -@@end group -@end group -@end example - -@noindent -produces - -@example -@group -This line follows an @@example command. -@exdent This line is exdented. -This line follows the exdented line. -The @@end example comes on the next line. -@end group -@end example - -In practice, the @code{@@exdent} command is rarely used. -Usually, you un-indent text by ending the example and -returning the page to its normal width.@refill - -@node flushleft & flushright, cartouche, exdent, Quotations and Examples -@section @code{@@flushleft} and @code{@@flushright} -@findex flushleft -@findex flushright - -The @code{@@flushleft} and @code{@@flushright} commands line up the -ends of lines on the left and right margins of a page, -but do not fill the text. The commands are written on lines of their -own, without braces. The @code{@@flushleft} and @code{@@flushright} -commands are ended by @code{@@end flushleft} and @code{@@end -flushright} commands on lines of their own.@refill - -@need 800 -For example, - -@example -@group -@@flushleft -This text is -written flushleft. -@@end flushleft -@end group -@end example - -@noindent -produces - -@quotation -@flushleft -This text is -written flushleft. -@end flushleft -@end quotation - - -Flushright produces the type of indentation often used in the return -address of letters.@refill - -@need 800 -@noindent -For example, - -@example -@group -@@flushright -Here is an example of text written -flushright. The @@code@{@@flushright@} command -right justifies every line but leaves the -left end ragged. -@@end flushright -@end group -@end example - -@noindent -produces - -@flushright -Here is an example of text written -flushright. The @code{@@flushright} command -right justifies every line but leaves the -left end ragged. -@end flushright - -@node cartouche, , flushleft & flushright, Quotations and Examples -@section Drawing Cartouches Around Examples -@findex cartouche -@cindex Box with rounded corners - -In a printed manual, the @code{@@cartouche} command draws a box with -rounded corners around its contents. You can use this command to -further highlight an example or quotation. For instance, you could -write a manual in which one type of example is surrounded by a cartouche -for emphasis.@refill - -The @code{@@cartouche} command affects only the printed manual; it has -no effect in the Info file.@refill - -@need 1500 -For example, - -@example -@group -@@example -@@cartouche -% pwd -/usr/local/lib/emacs/info -@@end cartouche -@@end example -@end group -@end example - -@noindent -surrounds the two-line example with a box with rounded corners, in the -printed manual. - -@iftex -In a printed manual, the example looks like this:@refill - -@example -@group -@cartouche -% pwd -/usr/local/lib/emacs/info -@end cartouche -@end group -@end example -@end iftex - -@node Lists and Tables, Indices, Quotations and Examples, Top -@comment node-name, next, previous, up -@chapter Making Lists and Tables -@cindex Making lists and tables -@cindex Lists and tables, making them -@cindex Tables and lists, making them - -Texinfo has several ways of making lists and two-column tables. Lists can -be bulleted or numbered, while two-column tables can highlight the items in -the first column.@refill - -@menu -* Introducing Lists:: Texinfo formats lists for you. -* itemize:: How to construct a simple list. -* enumerate:: How to construct a numbered list. -* Two-column Tables:: How to construct a two-column table. -@end menu - -@ifinfo -@node Introducing Lists, itemize, , Lists and Tables -@heading Introducing Lists -@end ifinfo - -Texinfo automatically indents the text in lists or tables, and numbers -an enumerated list. This last feature is useful if you modify the -list, since you do not need to renumber it yourself.@refill - -Numbered lists and tables begin with the appropriate @@-command at the -beginning of a line, and end with the corresponding @code{@@end} -command on a line by itself. The table and itemized-list commands -also require that you write formatting information on the same line as -the beginning @@-command.@refill - -Begin an enumerated list, for example, with an @code{@@enumerate} -command and end the list with an @code{@@end enumerate} command. -Begin an itemized list with an @code{@@itemize} command, followed on -the same line by a formatting command such as @code{@@bullet}, and end -the list with an @code{@@end itemize} command.@refill -@findex end - -Precede each element of a list with an @code{@@item} or @code{@@itemx} -command.@refill - -@sp 1 -@noindent -Here is an itemized list of the different kinds of table and lists:@refill - -@itemize @bullet -@item -Itemized lists with and without bullets. - -@item -Enumerated lists, using numbers or letters. - -@item -Two-column tables with highlighting. -@end itemize - -@sp 1 -@noindent -Here is an enumerated list with the same items:@refill - -@enumerate -@item -Itemized lists with and without bullets. - -@item -Enumerated lists, using numbers or letters. - -@item -Two-column tables with highlighting. -@end enumerate - -@sp 1 -@noindent -And here is a two-column table with the same items and their -@w{@@-commands}:@refill - -@table @code -@item @@itemize -Itemized lists with and without bullets. - -@item @@enumerate -Enumerated lists, using numbers or letters. - -@item @@table -@itemx @@ftable -@itemx @@vtable -Two-column tables with highlighting. -@end table - -@node itemize, enumerate, Introducing Lists, Lists and Tables -@comment node-name, next, previous, up -@section Making an Itemized List -@cindex Itemization -@findex itemize - -The @code{@@itemize} command produces sequences of indented -paragraphs, with a bullet or other mark inside the left margin -at the beginning of each paragraph for which such a mark is desired.@refill - -Begin an itemized list by writing @code{@@itemize} at the beginning of -a line. Follow the command, on the same line, with a character or a -Texinfo command that generates a mark. Usually, you will write -@code{@@bullet} after @code{@@itemize}, but you can use -@code{@@minus}, or any character or any special symbol that results in -a single character in the Info file. (When you write @code{@@bullet} -or @code{@@minus} after an @code{@@itemize} command, you may omit the -@samp{@{@}}.)@refill - -Write the text of the indented paragraphs themselves after the -@code{@@itemize}, up to another line that says @code{@@end -itemize}.@refill - -Before each paragraph for which a mark in the margin is desired, write -a line that says just @code{@@item}. Do not write any other text on this -line.@refill -@findex item - -Usually, you should put a blank line before an @code{@@item}. This -puts a blank line in the Info file. (@TeX{} inserts the proper -interline whitespace in either case.) Except when the entries are -very brief, these blank lines make the list look better.@refill - -Here is an example of the use of @code{@@itemize}, followed by the -output it produces. Note that @code{@@bullet} produces an @samp{*} in -Info and a round dot in @TeX{}.@refill - -@example -@group -@@itemize @@bullet -@@item -Some text for foo. - -@@item -Some text -for bar. -@@end itemize -@end group -@end example - -@noindent -This produces: - -@quotation -@itemize @bullet -@item -Some text for foo. - -@item -Some text -for bar. -@end itemize -@end quotation - -Itemized lists may be embedded within other itemized lists. Here is a -list marked with dashes embedded in a list marked with bullets:@refill - -@example -@group -@@itemize @@bullet -@@item -First item. - -@@itemize @@minus -@@item -Inner item. - -@@item -Second inner item. -@@end itemize - -@@item -Second outer item. -@@end itemize -@end group -@end example - -@noindent -This produces: - -@quotation -@itemize @bullet -@item -First item. - -@itemize @minus -@item -Inner item. - -@item -Second inner item. -@end itemize - -@item -Second outer item. -@end itemize -@end quotation - -@node enumerate, Two-column Tables, itemize, Lists and Tables -@comment node-name, next, previous, up -@section Making a Numbered or Lettered List -@cindex Enumeration -@findex enumerate - -@code{@@enumerate} is like @code{@@itemize} except that the marks in -the left margin contain successive integers or letters. -(@xref{itemize, , @code{@@itemize}}.)@refill - -Write the @code{@@enumerate} command at the beginning of a line. -The command does not require an argument, but accepts either a number or -a letter as an option. -Without an argument, @code{@@enumerate} starts the list -with the number 1. With a numeric argument, such as 3, -the command starts the list with that number. -With an upper or lower case letter, such as @kbd{a} or @kbd{A}, -the command starts the list with that letter.@refill - -Write the text of the enumerated list in the same way you write an -itemized list: put @code{@@item} on a line of its own before the start of -each paragraph that you want enumerated. Do not write any other text on -the line beginning with @code{@@item}.@refill - -You should put a blank line between entries in the list. -This generally makes it easier to read the Info file.@refill - -@need 1500 -Here is an example of @code{@@enumerate} without an argument:@refill - -@example -@group -@@enumerate -@@item -Underlying causes. - -@@item -Proximate causes. -@@end enumerate -@end group -@end example - -@noindent -This produces: - -@enumerate -@item -Underlying causes. - -@item -Proximate causes. -@end enumerate -@sp 1 -Here is an example with an argument of @kbd{3}:@refill -@sp 1 -@example -@group -@@enumerate 3 -@@item -Predisposing causes. - -@@item -Precipitating causes. - -@@item -Perpetuating causes. -@@end enumerate -@end group -@end example - -@noindent -This produces: - -@enumerate 3 -@item -Predisposing causes. - -@item -Precipitating causes. - -@item -Perpetuating causes. -@end enumerate -@sp 1 -Here is a brief summary of the alternatives. The summary is constructed -using @code{@@enumerate} with an argument of @kbd{a}.@refill -@sp 1 -@enumerate a -@item -@code{@@enumerate} - -Without an argument, produce a numbered list, starting with the number -1.@refill - -@item -@code{@@enumerate @var{positive-integer}} - -With a (positive) numeric argument, start a numbered list with that -number. You can use this to continue a list that you interrupted with -other text.@refill - -@item -@code{@@enumerate @var{upper-case-letter}} - -With an upper case letter as argument, start a list -in which each item is marked -by a letter, beginning with that upper case letter.@refill - -@item -@code{@@enumerate @var{lower-case-letter}} - -With a lower case letter as argument, start a list -in which each item is marked by -a letter, beginning with that lower case letter.@refill -@end enumerate - -You can also nest enumerated lists, as in an outline.@refill - -@node Two-column Tables, , enumerate, Lists and Tables -@comment node-name, next, previous, up -@section Making a Two-column Table -@cindex Tables, making two-column -@findex table - -@code{@@table} is similar to @code{@@itemize}, but the command allows -you to specify a name or heading line for each item. (@xref{itemize, -, @code{@@itemize}}.) The @code{@@table} command is used to produce -two-column tables, and is especially useful for glossaries and -explanatory exhibits.@refill - -@menu -* table:: How to construct a two-column table. -* ftable vtable:: How to construct a two-column table - with automatic indexing. -* itemx:: How to put more entries in the first column. -@end menu - -@ifinfo -@node table, ftable vtable, , Two-column Tables -@subheading Using the @code{@@table} Command - -Use the @code{@@table} command to produce two-column tables.@refill -@end ifinfo - -Write the @code{@@table} command at the beginning of a line and follow -it on the same line with an argument that is a Texinfo command such as -@code{@@code}, @code{@@samp}, @code{@@var}, or @code{@@kbd}. -Although these commands are usually followed by arguments in braces, -in this case you use the command name without an argument because -@code{@@item} will supply the argument. This command will be applied -to the text that goes into the first column of each item and -determines how it will be highlighted. For example, @code{@@samp} -will cause the text in the first column to be highlighted with an -@code{@@samp} command.@refill - -You may also choose to use the @code{@@asis} command as an argument to -@code{@@table}. @code{@@asis} is a command that does nothing; if you use this -command after @code{@@table}, @TeX{} and the Info formatting commands -output the first column entries without added highlighting (`as -is').@refill - -(The @code{@@table} command may work with other commands besides those -listed here. However, you can only use commands -that normally take arguments in braces.)@refill - -Begin each table entry with an @code{@@item} command at the beginning -of a line. Write the first column text on the same line as the -@code{@@item} command. Write the second column text on the line -following the @code{@@item} line and on subsequent lines. (You do not -need to type anything for an empty second column entry.) You may -write as many lines of supporting text as you wish, even several -paragraphs. But only text on the same line as the @code{@@item} will -be placed in the first column.@refill -@findex item - -Normally, you should put a blank line before an @code{@@item} line. -This puts a blank like in the Info file. Except when the entries are -very brief, a blank line looks better.@refill - -@need 1500 -The following table, for example, highlights the text in the first -column with an @code{@@samp} command:@refill - -@example -@group -@@table @@samp -@@item foo -This is the text for -@@samp@{foo@}. - -@@item bar -Text for @@samp@{bar@}. -@@end table -@end group -@end example - -@noindent -This produces: - -@table @samp -@item foo -This is the text for -@samp{foo}. -@item bar -Text for @samp{bar}. -@end table - -If you want to list two or more named items with a single block of -text, use the @code{@@itemx} command. (@xref{itemx, , -@code{@@itemx}}.)@refill - -@node ftable vtable, itemx, table, Two-column Tables -@comment node-name, next, previous, up -@subsection @code{@@ftable} and @code{@@vtable} -@cindex Tables with indexes -@cindex Indexing table entries automatically -@findex ftable -@findex vtable - -The @code{@@ftable} and @code{@@vtable} commands are the same as the -@code{@@table} command except that @code{@@ftable} automatically enters -each of the items in the first column of the table into the index of -functions and @code{@@vtable} automatically enters each of the items in -the first column of the table into the index of variables. This -simplifies the task of creating indices. Only the items on the same -line as the @code{@@item} commands are indexed, and they are indexed in -exactly the form that they appear on that line. @xref{Indices, , -Creating Indices}, for more information about indices.@refill - -Begin a two-column table using @code{@@ftable} or @code{@@vtable} by -writing the @@-command at the beginning of a line, followed on the same -line by an argument that is a Texinfo command such as @code{@@code}, -exactly as you would for an @code{@@table} command; and end the table -with an @code{@@end ftable} or @code{@@end vtable} command on a line by -itself. - -@node itemx, , ftable vtable, Two-column Tables -@comment node-name, next, previous, up -@subsection @code{@@itemx} -@cindex Two named items for @code{@@table} -@findex itemx - -Use the @code{@@itemx} command inside a table when you have two or -more first column entries for the same item, each of which should -appear on a line of its own. Use @code{@@itemx} for all but the first -entry. The @code{@@itemx} command works exactly like @code{@@item} -except that it does not generate extra vertical space above the first -column text.@refill - -@need 1000 -For example, - -@example -@group -@@table @@code -@@item upcase -@@itemx downcase -These two functions accept a character or a string as -argument, and return the corresponding upper case (lower -case) character or string. -@@end table -@end group -@end example - -@noindent -This produces: - -@table @code -@item upcase -@itemx downcase -These two functions accept a character or a string as -argument, and return the corresponding upper case (lower -case) character or string.@refill -@end table - -@noindent -(Note also that this example illustrates multi-line supporting text in -a two-column table.)@refill - -@node Indices, Insertions, Lists and Tables, Top -@comment node-name, next, previous, up -@chapter Creating Indices -@cindex Indices -@cindex Creating indices - -Using Texinfo, you can generate indices without having to sort and -collate entries manually. In an index, the entries are listed in -alphabetical order, together with information on how to find the -discussion of each entry. In a printed manual, this information -consists of page numbers. In an Info file, this information is a menu -entry leading to the first node referenced.@refill - -Texinfo provides several predefined kinds of index: an index -for functions, an index for variables, an index for concepts, and so -on. You can combine indices or use them for other than their -canonical purpose. If you wish, you can define your own indices.@refill - -@menu -* Index Entries:: Choose different words for index entries. -* Predefined Indices:: Use different indices for different kinds - of entry. -* Indexing Commands:: How to make an index entry. -* Combining Indices:: How to combine indices. -* New Indices:: How to define your own indices. -@end menu - -@node Index Entries, Predefined Indices, , Indices -@comment node-name, next, previous, up -@section Making Index Entries -@cindex Index entries, making -@cindex Entries, making index - -When you are making index entries, it is good practice to think of the -different ways people may look for something. Different people -@emph{do not} think of the same words when they look something up. A -helpful index will have items indexed under all the different words -that people may use. For example, one reader may think it obvious that -the two-letter names for indices should be listed under ``Indices, -two-letter names'', since the word ``Index'' is the general concept. -But another reader may remember the specific concept of two-letter -names and search for the entry listed as ``Two letter names for -indices''. A good index will have both entries and will help both -readers.@refill - -Like typesetting, the construction of an index is a highly skilled, -professional art, the subtleties of which are not appreciated until you -need to do it yourself.@refill - -@xref{Printing Indices & Menus}, for information about printing an index -at the end of a book or creating an index menu in an Info file.@refill - -@node Predefined Indices, Indexing Commands, Index Entries, Indices -@comment node-name, next, previous, up -@section Predefined Indices - -Texinfo provides six predefined indices:@refill - -@itemize @bullet -@item -A @dfn{concept index} listing concepts that are discussed.@refill - -@item -A @dfn{function index} listing functions (such as entry points of -libraries).@refill - -@item -A @dfn{variables index} listing variables (such as global variables -of libraries).@refill - -@item -A @dfn{keystroke index} listing keyboard commands.@refill - -@item -A @dfn{program index} listing names of programs.@refill - -@item -A @dfn{data type index} listing data types (such as structures defined in -header files).@refill -@end itemize - -@noindent -Not every manual needs all of these, and most manuals use two or three -of them. This manual has two indices: a -concept index and an @@-command index (that is actually the function -index but is called a command index in the chapter heading). Two or -more indices can be combined into one using the @code{@@synindex} or -@code{@@syncodeindex} commands. @xref{Combining Indices}.@refill - -@node Indexing Commands, Combining Indices, Predefined Indices, Indices -@comment node-name, next, previous, up -@section Defining the Entries of an Index -@cindex Defining indexing entries -@cindex Index entries -@cindex Entries for an index -@cindex Specifying index entries -@cindex Creating index entries - -The data to make an index come from many individual indexing commands -scattered throughout the Texinfo source file. Each command says to add -one entry to a particular index; after formatting, the index will give -the current page number or node name as the reference.@refill - -An index entry consists of an indexing command at the beginning of a -line followed, on the rest of the line, by the entry.@refill - -For example, this section begins with the following five entries for -the concept index:@refill - -@example -@@cindex Defining indexing entries -@@cindex Index entries -@@cindex Entries for an index -@@cindex Specifying index entries -@@cindex Creating index entries -@end example - -Each predefined index has its own indexing command---@code{@@cindex} -for the concept index, @code{@@findex} for the function index, and so -on.@refill - -@cindex Capitalizing index entries -@cindex Index entry capitalization -The usual convention is to capitalize the first word of each index -entry, unless that word is the name of a function, variable, or other -such entity that should not be capitalized. Thus, if you are -documenting Emacs Lisp, you should usually capitalize entries in -the concept index, but not those in the function index. -However, if your -concept index entries are consistently short (one or two words each) -it may look better for each regular entry to start with a lower case -letter. Whichever convention you adapt, please be consistent! - -By default, entries for a concept index are printed in a small roman -font and entries for the other indices are printed in a small -@code{@@code} font. You may change the way part of an entry is -printed with the usual Texinfo commands, such as @code{@@file} for -file names and @code{@@emph} for emphasis (@pxref{Marking -Text}).@refill -@cindex Index font types - -@cindex Predefined indexing commands -@cindex Indexing commands, predefined -The six indexing commands for predefined indices are: - -@table @code -@item @@cindex @var{concept} -@findex cindex -Make an entry in the concept index for @var{concept}.@refill - -@item @@findex @var{function} -@findex findex -Make an entry in the function index for @var{function}.@refill - -@item @@vindex @var{variable} -@findex vindex -Make an entry in the variable index for @var{variable}.@refill - -@item @@kindex @var{keystroke} -@findex kindex -Make an entry in the key index for @var{keystroke}.@refill - -@item @@pindex @var{program} -@findex pindex -Make an entry in the program index for @var{program}.@refill - -@item @@tindex @var{data type} -@findex tindex -Make an entry in the data type index for @var{data type}.@refill -@end table - -@quotation -@strong{Caution:} Do not use a colon in an index entry. In Info, a -colon separates the menu entry name from the node name. An extra -colon confuses Info. -@xref{Menu Parts, , The Parts of a Menu}, -for more information about the structure of a menu entry.@refill -@end quotation - -If you write several identical index entries in different places in a -Texinfo file, the index in the printed manual will list all the pages to -which those entries refer. However, the index in the Info file will -list @strong{only} the node that references the @strong{first} of those -index entries. Therefore, it is best to write indices in which each -entry refers to only one place in the Texinfo file. Fortunately, this -constraint is a feature rather than a loss since it means that the index -will be easy to use. Otherwise, you could create an index that lists -several pages for one entry and your reader would not know to which page -to turn. If you have two identical entries for one topic, change the -topics slightly, or qualify them to indicate the difference.@refill - -You are not actually required to use the predefined indices for their -canonical purposes. For example, suppose you wish to index some C -preprocessor macros. You could put them in the function index along -with actual functions, just by writing @code{@@findex} commands for -them; then, when you print the ``Function Index'' as an unnumbered -chapter, you could give it the title `Function and Macro Index' and -all will be consistent for the reader. Or you could put the macros in -with the data types by writing @code{@@tindex} commands for them, and -give that index a suitable title so the reader will understand. -(@xref{Printing Indices & Menus}.)@refill - -@node Combining Indices, New Indices, Indexing Commands, Indices -@comment node-name, next, previous, up -@section Combining Indices -@cindex Combining indices -@cindex Indices, combining them - -Sometimes you will want to combine two disparate indices such as functions -and concepts, perhaps because you have few enough of one of them that -a separate index for them would look silly.@refill - -You could put functions into the concept index by writing -@code{@@cindex} commands for them instead of @code{@@findex} commands, -and produce a consistent manual by printing the concept index with the -title `Function and Concept Index' and not printing the `Function -Index' at all; but this is not a robust procedure. It works only if -your document is never included as part of another -document that is designed to have a separate function index; if your -document were to be included with such a document, the functions from -your document and those from the other would not end up together. -Also, to make your function names appear in the right font in the -concept index, you would need to enclose every one of them between -the braces of @code{@@code}.@refill - -@menu -* syncodeindex:: How to merge two indices, using @code{@@code} - font for the merged-from index. -* synindex:: How to merge two indices, using the - default font of the merged-to index. -@end menu - -@node syncodeindex, synindex, , Combining Indices -@subsubsection @code{@@syncodeindex} -@findex syncodeindex - -When you want to combine functions and concepts into one index, you -should index the functions with @code{@@findex} and index the concepts -with @code{@@cindex}, and use the @code{@@syncodeindex} command to -redirect the function index entries into the concept index.@refill -@findex syncodeindex - -The @code{@@syncodeindex} command takes two arguments; they are the name -of the index to redirect, and the name of the index to redirect it to. -The template looks like this:@refill - -@example -@@syncodeindex @var{from} @var{to} -@end example - -@cindex Predefined names for indices -@cindex Two letter names for indices -@cindex Indices, two letter names -@cindex Names for indices -For this purpose, the indices are given two-letter names:@refill - -@table @samp -@item cp -concept index -@item fn -function index -@item vr -variable index -@item ky -key index -@item pg -program index -@item tp -data type index -@end table - -Write an @code{@@syncodeindex} command before or shortly after the -end-of-header line at the beginning of a Texinfo file. For example, -to merge a function index with a concept index, write the -following:@refill - -@example -@@syncodeindex fn cp -@end example - -@noindent -This will cause all entries designated for the function index to merge -in with the concept index instead.@refill - -To merge both a variables index and a function index into a concept -index, write the following:@refill - -@example -@group -@@syncodeindex vr cp -@@syncodeindex fn cp -@end group -@end example - -@cindex Fonts for indices -The @code{@@syncodeindex} command puts all the entries from the `from' -index (the redirected index) into the @code{@@code} font, overriding -whatever default font is used by the index to which the entries are -now directed. This way, if you direct function names from a function -index into a concept index, all the function names are printed in the -@code{@@code} font as you would expect.@refill - -@node synindex, , syncodeindex, Combining Indices -@subsubsection @code{@@synindex} -@findex synindex - -The @code{@@synindex} command is nearly the same as the -@code{@@syncodeindex} command, except that it does not put the -`from' index entries into the @code{@@code} font; rather it puts -them in the roman font. Thus, you use @code{@@synindex} when you -merge a concept index into a function index.@refill - -@xref{Printing Indices & Menus}, for information about printing an index -at the end of a book or creating an index menu in an Info file.@refill - -@node New Indices, , Combining Indices, Indices -@section Defining New Indices -@cindex Defining new indices -@cindex Indices, defining new -@cindex New index defining -@findex defindex -@findex defcodeindex - -In addition to the predefined indices, you may use the -@code{@@defindex} and @code{@@defcodeindex} commands to define new -indices. These commands create new indexing @@-commands with which -you mark index entries. The @code{@@defindex }command is used like -this:@refill - -@example -@@defindex @var{name} -@end example - -The name of an index should be a two letter word, such as @samp{au}. -For example:@refill - -@example -@@defindex au -@end example - -This defines a new index, called the @samp{au} index. At the same -time, it creates a new indexing command, @code{@@auindex}, that you -can use to make index entries. Use the new indexing command just as -you would use a predefined indexing command.@refill - -For example, here is a section heading followed by a concept index -entry and two @samp{au} index entries.@refill - -@example -@@section Cognitive Semantics -@@cindex kinesthetic image schemas -@@auindex Johnson, Mark -@@auindex Lakoff, George -@end example - -@noindent -(Evidently, @samp{au} serves here as an abbreviation for ``author''.) -Texinfo constructs the new indexing command by concatenating the name -of the index with @samp{index}; thus, defining an @samp{au} index -leads to the automatic creation of an @code{@@auindex} command.@refill - -Use the @code{@@printindex} command to print the index, as you do with -the predefined indices. For example:@refill - -@example -@group -@@node Author Index, Subject Index, , Top -@@unnumbered Author Index - -@@printindex au -@end group -@end example - -The @code{@@defcodeindex} is like the @code{@@defindex} command, except -that, in the printed output, it prints entries in an @code{@@code} font -instead of a roman font. Thus, it parallels the @code{@@findex} command -rather than the @code{@@cindex} command.@refill - -You should define new indices within or right after the end-of-header -line of a Texinfo file, before any @code{@@synindex} or -@code{@@syncodeindex} commands (@pxref{Header}).@refill - -@node Insertions, Glyphs, Indices, Top -@comment node-name, next, previous, up -@chapter Special Insertions -@cindex Inserting special characters and symbols -@cindex Special insertions - -Texinfo provides several commands for formatting dimensions, for -inserting single characters that have special meaning in Texinfo, such -as braces, and for inserting special graphic symbols that do not -correspond to characters, such as dots and bullets.@refill - -@iftex -These are: - -@itemize @bullet -@item -Braces, @samp{@@} and periods. - -@item -Format a dimension, such as @samp{12@dmn{pt}}. - -@item -Dots and bullets. - -@item -The @TeX{} logo and the copyright symbol. - -@item -A minus sign. -@end itemize -@end iftex - -@menu -* Braces Atsigns Periods:: How to insert braces, @samp{@@} and periods. -* dmn:: How to format a dimension. -* Dots Bullets:: How to insert dots and bullets. -* TeX and copyright:: How to insert the @TeX{} logo - and the copyright symbol. -* minus:: How to insert a minus sign. -@end menu - -@node Braces Atsigns Periods, dmn, , Insertions -@comment node-name, next, previous, up -@section Inserting @samp{@@}, Braces, and Periods -@cindex Inserting @@, braces, and periods -@cindex Braces, inserting -@cindex Periods, inserting -@cindex Single characters, commands to insert -@cindex Commands to insert single characters - -@samp{@@} and curly braces are special characters in Texinfo. To -insert these characters so they appear in text, you must put an @samp{@@} in front -of these characters to prevent Texinfo from misinterpreting them.@refill - -Periods are also special. Depending on whether the period is inside -or at the end of a sentence, less or more space is inserted after a -period in a typeset manual. Since it is not always possible for -Texinfo to determine when a period ends a sentence and when it is used -in an abbreviation, special commands are needed in some circumstances. -(Usually, Texinfo can guess how to handle periods, so you do not need -to use the special commands; you just enter a period as you would if -you were using a typewriter, which means you put two spaces after the -period, question mark, or exclamation mark that ends a -sentence.)@refill - -Do not put braces after any of these commands; they are not -necessary.@refill - -@menu -* Inserting An Atsign:: -* Inserting Braces:: How to insert @samp{@{} and @samp{@}} -* Controlling Spacing:: How to insert the right amount of space - after punctuation within a sentence. -@end menu - -@node Inserting An Atsign, Inserting Braces, , Braces Atsigns Periods -@comment node-name, next, previous, up -@subsection Inserting @samp{@@} with @@@@ -@findex @@ @r{(single @samp{@@})} - -@code{@@@@} stands for a single @samp{@@} in either printed or Info -output.@refill - -Do not put braces after an @code{@@@@} command.@refill - -@node Inserting Braces, Controlling Spacing, Inserting An Atsign, Braces Atsigns Periods -@comment node-name, next, previous, up -@subsection Inserting @samp{@{} and @samp{@}}with @@@{ and @@@} -@findex @{ @r{(single @samp{@{})} -@findex @} @r{(single @samp{@}})} - -@code{@@@{} stands for a single @samp{@{} in either printed or Info -output.@refill - -@code{@@@}} stands for a single @samp{@}} in either printed or Info -output.@refill - -Do not put braces after either an @code{@@@{} or an @code{@@@}} -command.@refill - -@node Controlling Spacing, , Inserting Braces, Braces Atsigns Periods -@comment node-name, next, previous, up -@subsection Spacing After Colons and Periods -@findex : @r{(suppress widening)} - -Use the @code{@@:}@: command after a period, question mark, -exclamation mark, or colon that should not be followed by extra space. -For example, use @code{@@:}@: after periods that end abbreviations -which are not at the ends of sentences. @code{@@:}@: has no effect on -the Info file output.@refill - -@need 700 -For example, - -@example -The s.o.p.@@: has three parts @dots{} -The s.o.p. has three parts @dots{} -@end example - -@noindent -@ifinfo -produces -@end ifinfo -@iftex -produces the following. If you look carefully at this printed output, -you will see a little more whitespace after @samp{s.o.p.} in the second -line.@refill -@end iftex - -@quotation -The s.o.p.@: has three parts @dots{}@* -The s.o.p. has three parts @dots{} -@end quotation - -@noindent -@kbd{@@:} has no effect on the Info output. (@samp{s.o.p} is an acronym -for ``Standard Operating Procedure''.) - -@findex . @r{(true end of sentence)} -Use @code{@@.}@: instead of a period at the end of a sentence that -ends with a single capital letter. Otherwise, @TeX{} will think the -letter is an abbreviation and will not insert the correct -end-of-sentence spacing. Here is an example:@refill - -@example -Give it to M.I.B. and to M.E.W@@. Also, give it to R.J.C@@. -Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. -@end example - -@noindent -@ifinfo -produces -@end ifinfo -@iftex -produces the following. If you look carefully at this printed output, -you will see a little more whitespace after the @samp{W} in the first -line.@refill -@end iftex - -@quotation -Give it to M.I.B. and to M.E.W@. Also, give it to R.J.C@.@* -Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. -@end quotation - -In the Info file output, @code{@@.}@: is equivalent to a simple -@samp{.}.@refill - -The meanings of @code{@@:}@: and @code{@@.}@: in Texinfo are designed -to work well with the Emacs sentence motion commands. This made it -necessary for them to be incompatible with some other formatting -systems that use @@-commands.@refill - -Do not put braces after either an @code{@@:} or an @code{@@.} command.@refill - -@node dmn, Dots Bullets, Braces Atsigns Periods, Insertions -@section @code{@@dmn}@{@var{dimension}@}: Format a Dimension -@cindex Thin space between number, dimension -@cindex Dimension formatting -@cindex Format a dimension -@findex dmn - -At times, you may want to write @samp{12@dmn{pt}} or -@samp{8.5@dmn{in}} with little or no space between the number and the -abbreviation for the dimension. You can use the @code{@@dmn} command -to do this. On seeing the command, @TeX{} inserts just enough space -for proper typesetting; the Info formatting commands insert no space -at all, since the Info file does not require it.@refill - -To use the @code{@@dmn} command, write the number and then follow it -immediately, with no intervening space, by @code{@@dmn}, and then by -the dimension within braces.@refill - -@need 700 -@noindent -For example, - -@example -A4 paper is 8.27@@dmn@{in@} wide. -@end example - -@noindent -produces - -@quotation -A4 paper is 8.27@dmn{in} wide. -@end quotation - -Not everyone uses this style. Instead of writing -@w{@samp{8.27@@dmn@{in@}}} in the Texinfo file, you may write -@w{@samp{8.27 in.}} or @w{@samp{8.27 inches}}. (In these cases, the -formatters may insert a line break between the number and the -dimension. Also, if you write a period after an abbreviation within a -sentence, you should write @samp{@@:} after the period to prevent -@TeX{} from inserting extra whitespace. @xref{Controlling Spacing, , -Spacing After Colons and Periods}.)@refill - -@node Dots Bullets, TeX and copyright, dmn, Insertions -@comment node-name, next, previous, up -@section Inserting Ellipsis, Dots, and Bullets -@cindex Dots, inserting -@cindex Bullets, inserting -@cindex Ellipsis, inserting -@cindex Inserting ellipsis -@cindex Inserting dots -@cindex Special typesetting commands -@cindex Typesetting commands for dots, etc. - -An @dfn{ellipsis} (a line of dots) is not typeset as a string of -periods, so a special command is used for ellipsis in Texinfo. The -@code{@@bullet} command is special, too. Each of these commands is -followed by a pair of braces, @samp{@{@}}, without any whitespace -between the name of the command and the braces. (You need to use braces -with these commands because you can use them next to other text; without -the braces, the formatters would be confused. @xref{Command Syntax, , -@@-Command Syntax}, for further information.)@refill - -@menu -* dots:: How to insert dots @dots{} -* bullet:: How to insert a bullet. -@end menu - -@node dots, bullet, , Dots Bullets -@comment node-name, next, previous, up -@subsection @code{@@dots}@{@} -@findex dots -@cindex Inserting dots -@cindex Dots, inserting - -Use the @code{@@dots@{@}} command to generate an ellipsis, which is -three dots in a row, appropriately spaced, like this: `@dots{}'. Do -not simply write three periods in the input file; that would work for -the Info file output, but would produce the wrong amount of space -between the periods in the printed manual.@refill - -@iftex -Here is an ellipsis: @dots{} - -Here are three periods in a row: ... - -In printed output, the three periods in a row are closer together than -the dots in the ellipsis. -@end iftex - -@node bullet, , dots, Dots Bullets -@comment node-name, next, previous, up -@subsection @code{@@bullet}@{@} -@findex bullet - -Use the @code{@@bullet@{@}} command to generate a large round dot, or -the closest possible thing to one. In Info, an asterisk is used.@refill - -Here is a bullet: @bullet{} - -When you use @code{@@bullet} in @code{@@itemize}, you do not need to -type the braces, because @code{@@itemize} supplies them. @xref{itemize}.@refill - -@node TeX and copyright, minus, Dots Bullets, Insertions -@comment node-name, next, previous, up -@section Inserting @TeX{} and the Copyright Symbol - -The logo `@TeX{}' is typeset in a special fashion and it needs an -@@-command. The copyright symbol, `@copyright{}', is also special. -Each of these commands is followed by a pair of braces, @samp{@{@}}, -without any whitespace between the name of the command and the -braces.@refill - -@menu -* tex:: How to insert the @TeX{} logo. -* copyright symbol:: How to use @code{@@copyright}@{@}. -@end menu - -@node tex, copyright symbol, , TeX and copyright -@comment node-name, next, previous, up -@subsection @code{@@TeX}@{@} -@findex tex (command) - -Use the @code{@@TeX@{@}} command to generate `@TeX{}'. In a printed -manual, this is a special logo that is different from three ordinary -letters. In Info, it just looks like @samp{TeX}. The -@code{@@TeX@{@}} command is unique among Texinfo commands in that the -@key{T} and the @key{X} are in upper case.@refill - -@node copyright symbol, , tex, TeX and copyright -@comment node-name, next, previous, up -@subsection @code{@@copyright}@{@} -@findex copyright - -Use the @code{@@copyright@{@}} command to generate `@copyright{}'. In -a printed manual, this is a @samp{c} inside a circle, and in Info, -this is @samp{(C)}.@refill - -@node minus, , TeX and copyright, Insertions -@section @code{@@minus}@{@}: Inserting a Minus Sign -@findex minus - -Use the @code{@@minus@{@}} command to generate a minus sign. In a -fixed-width font, this is a single hyphen, but in a proportional font, -the symbol is the customary length for a minus sign---a little longer -than a hyphen.@refill - -You can compare the two forms: - -@display -@samp{@minus{}} is a minus sign generated with @samp{@@minus@{@}}, - -`-' is a hyphen generated with the character @samp{-}. -@end display - -@noindent -In the fixed-width font used by Info, @code{@@minus@{@}} is the same -as a hyphen.@refill - -You should not use @code{@@minus@{@}} inside @code{@@code} or -@code{@@example} because the width distinction is not made in the -fixed-width font they use.@refill - -When you use @code{@@minus} to specify the mark beginning each entry in -an itemized list, you do not need to type the braces -(@pxref{itemize}).@refill - -@node Glyphs, Breaks, Insertions, Top -@comment node-name, next, previous, up -@chapter Glyphs for Examples -@cindex Glyphs - -In Texinfo, code is often illustrated in examples that are delimited -by @code{@@example} and @code{@@end example}, or by @code{@@lisp} and -@code{@@end lisp}. In such examples, you can indicate the results of -evaluation or an expansion using @samp{@result{}} or -@samp{@expansion{}}. Likewise, there are commands to insert glyphs -to indicate -printed output, error messages, equivalence of expressions, and the -location of point.@refill - -The glyph-insertion commands do not need to be used within an example, but -most often they are. Every glyph-insertion command is followed by a pair of -left- and right-hand braces.@refill - -@menu -* Glyphs Summary:: -* result:: How to show the result of expression. -* expansion:: How to indicate an expansion. -* Print Glyph:: How to indicate printed output. -* Error Glyph:: How to indicate an error message. -* Equivalence:: How to indicate equivalence. -* Point Glyph:: How to indicate the location of point. -@end menu - -@node Glyphs Summary, result, , Glyphs -@ifinfo -@heading Glyphs Summary - -Here are the different glyph commands:@refill -@end ifinfo - -@table @asis -@item @result{} -@code{@@result@{@}} points to the result of an expression.@refill - -@item @expansion{} -@code{@@expansion@{@}} shows the results of a macro expansion.@refill - -@item @print{} -@code{@@print@{@}} indicates printed output.@refill - -@item @error{} -@code{@@error@{@}} indicates that the following text is an error -message.@refill - -@item @equiv{} -@code{@@equiv@{@}} indicates the exact equivalence of two forms.@refill - -@item @point{} -@code{@@point@{@}} shows the location of point.@refill -@end table - -@node result, expansion, Glyphs Summary, Glyphs -@section @result{}: Indicating Evaluation -@cindex Result of an expression -@cindex Indicating evaluation -@cindex Evaluation glyph -@cindex Value of an expression, indicating - -Use the @code{@@result@{@}} command to indicate the result of -evaluating an expression.@refill - -@iftex -The @code{@@result@{@}} command is displayed as @samp{=>} in Info and -as @samp{@result{}} in the printed output. -@end iftex -@ifinfo -The @code{@@result@{@}} command is displayed as @samp{@result{}} in Info -and as a double stemmed arrow in the printed output.@refill -@end ifinfo - -Thus, the following, - -@lisp -(cdr '(1 2 3)) - @result{} (2 3) -@end lisp - -@noindent -may be read as ``@code{(cdr '(1 2 3))} evaluates to @code{(2 3)}''. - -@node expansion, Print Glyph, result, Glyphs -@section @expansion{}: Indicating an Expansion -@cindex Expansion, indicating it - -When an expression is a macro call, it expands into a new expression. -You can indicate the result of the expansion with the -@code{@@expansion@{@}} command.@refill - -@iftex -The @code{@@expansion@{@}} command is displayed as @samp{==>} in Info and -as @samp{@expansion{}} in the printed output. -@end iftex -@ifinfo -The @code{@@expansion@{@}} command is displayed as @samp{@expansion{}} -in Info and as a long arrow with a flat base in the printed output.@refill -@end ifinfo - -@need 700 -For example, the following - -@example -@group -@@lisp -(third '(a b c)) - @@expansion@{@} (car (cdr (cdr '(a b c)))) - @@result@{@} c -@@end lisp -@end group -@end example - -@noindent -produces - -@lisp -@group -(third '(a b c)) - @expansion{} (car (cdr (cdr '(a b c)))) - @result{} c -@end group -@end lisp - -@noindent -which may be read as: - -@quotation -@code{(third '(a b c))} expands to @code{(car (cdr (cdr '(a b c))))}; -the result of evaluating the expression is @code{c}. -@end quotation - -@noindent -Often, as in this case, an example looks better if the -@code{@@expansion@{@}} and @code{@@result@{@}} commands are indented -five spaces.@refill - -@node Print Glyph, Error Glyph, expansion, Glyphs -@section @print{}: Indicating Printed Output -@cindex Printed output, indicating it - -Sometimes an expression will print output during its execution. You -can indicate the printed output with the @code{@@print@{@}} command.@refill - -@iftex -The @code{@@print@{@}} command is displayed as @samp{-|} in Info and -as @samp{@print{}} in the printed output. -@end iftex -@ifinfo -The @code{@@print@{@}} command is displayed as @samp{@print{}} in Info -and similarly, as a horizontal dash butting against a vertical bar, in -the printed output.@refill -@end ifinfo - -In the following example, the printed text is indicated with -@samp{@print{}}, and the value of the expression follows on the -last line.@refill - -@lisp -@group -(progn (print 'foo) (print 'bar)) - @print{} foo - @print{} bar - @result{} bar -@end group -@end lisp - -@noindent -In a Texinfo source file, this example is written as follows: - -@lisp -@group -@@lisp -(progn (print 'foo) (print 'bar)) - @@print@{@} foo - @@print@{@} bar - @@result@{@} bar -@@end lisp -@end group -@end lisp - -@node Error Glyph, Equivalence, Print Glyph, Glyphs -@section @error{}: Indicating an Error Message -@cindex Error message, indicating it - -A piece of code may cause an error when you evaluate it. You can -designate the error message with the @code{@@error@{@}} command.@refill - -@iftex -The @code{@@error@{@}} command is displayed as @samp{error-->} in Info -and as @samp{@error{}} in the printed output. -@end iftex -@ifinfo -The @code{@@error@{@}} command is displayed as @samp{@error{}} in Info -and as the word `error' in a box in the printed output.@refill -@end ifinfo - -@need 700 -Thus, - -@example -@@lisp -(+ 23 'x) -@@error@{@} Wrong type argument: integer-or-marker-p, x -@@end lisp -@end example - -@noindent -produces - -@lisp -(+ 23 'x) -@error{} Wrong type argument: integer-or-marker-p, x -@end lisp - -@noindent -This indicates that the following error message is printed -when you evaluate the expression: - -@lisp -Wrong type argument: integer-or-marker-p, x -@end lisp - -Note that @samp{@error{}} itself is not part of the error -message. - -@node Equivalence, Point Glyph, Error Glyph, Glyphs -@section @equiv{}: Indicating Equivalence -@cindex Equivalence, indicating it - -Sometimes two expressions produce identical results. You can indicate the -exact equivalence of two forms with the @code{@@equiv@{@}} command.@refill - -@iftex -The @code{@@equiv@{@}} command is displayed as @samp{==} in Info and -as @samp{@equiv{}} in the printed output. -@end iftex -@ifinfo -The @code{@@equiv@{@}} command is displayed as @samp{@equiv{}} in Info -and as a three parallel horizontal lines in the printed output.@refill -@end ifinfo - -Thus, - -@example -@@lisp -(make-sparse-keymap) @@equiv@{@} (list 'keymap) -@@end lisp -@end example - -@noindent -produces - -@lisp -(make-sparse-keymap) @equiv{} (list 'keymap) -@end lisp - -@noindent -This indicates that evaluating @code{(make-sparse-keymap)} produces -identical results to evaluating @code{(list 'keymap)}. - -@c Cannot write point command here because it causes trouble with TOC. -@node Point Glyph, , Equivalence, Glyphs -@section Indicating Point in a Buffer -@cindex Point, indicating it in a buffer - -Sometimes you need to show an example of text in an Emacs buffer. In -such examples, the convention is to include the entire contents of the -buffer in question between two lines of dashes containing the buffer -name.@refill - -You can use the @samp{@@point@{@}} command to show the location of point -in the text in the buffer. (The symbol for point, of course, is not -part of the text in the buffer; it indicates the place @emph{between} -two characters where point is located.)@refill - -@iftex -The @code{@@point@{@}} command is displayed as @samp{-!-} in Info and -as @samp{@point{}} in the printed output. -@end iftex -@ifinfo -The @code{@@point@{@}} command is displayed as @samp{@point{}} in Info -and as a small five pointed star in the printed output.@refill -@end ifinfo - -The following example shows the contents of buffer @file{foo} before -and after evaluating a Lisp command to insert the word @code{changed}.@refill - -@example -@group ----------- Buffer: foo ---------- -This is the @point{}contents of foo. ----------- Buffer: foo ---------- - -@end group -@end example - -@example -@group -(insert "changed ") - @result{} nil ----------- Buffer: foo ---------- -This is the changed @point{}contents of foo. ----------- Buffer: foo ---------- - -@end group -@end example - -In a Texinfo source file, the example is written like this:@refill - -@example -@@example ----------- Buffer: foo ---------- -This is the @@point@{@}contents of foo. ----------- Buffer: foo ---------- - -(insert "changed ") - @@result@{@} nil ----------- Buffer: foo ---------- -This is the changed @@point@{@}contents of foo. ----------- Buffer: foo ---------- -@@end example -@end example - -@node Breaks, Definition Commands, Glyphs, Top -@comment node-name, next, previous, up -@chapter Making and Preventing Breaks -@cindex Making line and page breaks -@cindex Preventing line and page breaks - -Usually, a Texinfo file is processed both by @TeX{} and by one of the -Info formatting commands. Line, paragraph, or page breaks sometimes -occur in the `wrong' place in one or other form of output. You must -ensure that text looks right both in the printed manual and in the -Info file.@refill - -For example, in a printed manual, page breaks may occur awkwardly in -the middle of an example; to prevent this, you can hold text together -using a grouping command that keeps the text from being split across -two pages. Conversely, you may want to force a page break where none -would occur normally. Fortunately, problems like these do not often -arise. When they do, use the break, break prevention, or pagination -commands.@refill - -@menu -* Break Commands:: Cause and prevent splits. -* Line Breaks:: How to force a single line to use two lines. -* w:: How to prevent unwanted line breaks. -* sp:: How to insert blank lines. -* page:: How to force the start of a new page. -* group:: How to prevent unwanted page breaks. -* need:: Another way to prevent unwanted page breaks. -@end menu - -@ifinfo -@node Break Commands, Line Breaks, , Breaks -@heading The Break Commands -@end ifinfo -@iftex -@sp 1 -@end iftex - -The break commands create line and paragraph breaks:@refill - -@table @code -@item @@* -Force a line break. - -@item @@sp @var{n} -Skip @var{n} blank lines.@refill -@end table -@iftex -@sp 1 -@end iftex - -The line-break-prevention command holds text together all on one -line:@refill - -@table @code -@item @@w@{@var{text}@} -Prevent @var{text} from being split and hyphenated across two lines.@refill -@end table -@iftex -@sp 1 -@end iftex - -The pagination commands apply only to printed output, since Info -files do not have pages.@refill - -@table @code -@item @@page -Start a new page in the printed manual.@refill - -@item @@group -Hold text together that must appear on one printed page.@refill - -@item @@need @var{mils} -Start a new printed page if not enough space on this one.@refill -@end table - -@node Line Breaks, w, Break Commands, Breaks -@comment node-name, next, previous, up -@section @code{@@*}: Generate Line Breaks -@findex * @r{(force line break)} -@cindex Line breaks -@cindex Breaks in a line - -The @code{@@*} command forces a line break in both the printed manual and -in Info.@refill - -@need 700 -For example, - -@example -This line @@* is broken @@*in two places. -@end example - -@noindent -produces - -@example -@group -This line - is broken -in two places. -@end group -@end example - -@noindent -(Note that the space after the first @code{@@*} command is faithfully -carried down to the next line.)@refill - -@need 800 -The @code{@@*} command is often used in a file's copyright page:@refill - -@example -@group -This is edition 2.0 of the Texinfo documentation,@@* -and is for @dots{} -@end group -@end example - -@noindent -In this case, the @code{@@*} command keeps @TeX{} from stretching the -line across the whole page in an ugly manner.@refill - -@quotation -@strong{Please note:} Do not write braces after an @code{@@*} command; -they are not needed.@refill - -Do not write an @code{@@refill} command at the end of a paragraph -containing an @code{@@*} command; it will cause the paragraph to be -refilled after the line break occurs, negating the effect of the line -break.@refill -@end quotation - -@node w, sp, Line Breaks, Breaks -@comment node-name, next, previous, up -@section @code{@@w}@{@var{text}@}: Prevent Line Breaks -@findex w @r{(prevent line break)} -@cindex Line breaks, preventing - -@code{@@w@{@var{text}@}} outputs @var{text} and prohibits line breaks -within @var{text}.@refill - -You can use the @code{@@w} command to prevent @TeX{} from automatically -hyphenating a long name or phrase that accidentally falls near the end -of a line.@refill - -@example -You can copy GNU software from @@w@{@@file@{prep.ai.mit.edu@}@}. -@end example - -@noindent -produces - -@quotation -You can copy GNU software from @w{@file{prep.ai.mit.edu}}. -@end quotation - -In the Texinfo file, you must write the @code{@@w} command and its -argument (all the affected text) all on one line.@refill - -@quotation -@strong{Caution:} Do not write an @code{@@refill} command at the end -of a paragraph containing an @code{@@w} command; it will cause the -paragraph to be refilled and may thereby negate the effect of the -@code{@@w} command.@refill -@end quotation - -@node sp, page, w, Breaks -@comment node-name, next, previous, up -@section @code{@@sp} @var{n}: Insert Blank Lines -@findex sp @r{(line spacing)} -@cindex Spaces (blank lines) -@cindex Blank lines -@cindex Line spacing - -A line beginning with and containing only @code{@@sp @var{n}} -generates @var{n} blank lines of space in both the printed manual and -the Info file. @code{@@sp} also forces a paragraph break. For -example,@refill - -@example -@@sp 2 -@end example - -@noindent -generates two blank lines. - -The @code{@@sp} command is most often used in the title page.@refill - -@ignore -@c node br, page, sp, Breaks -@comment node-name, next, previous, up -@c section @code{@@br}: Generate Paragraph Breaks -@findex br @r{(paragraph breaks)} -@cindex Paragraph breaks -@cindex Breaks in a paragraph - -The @code{@@br} command forces a paragraph break. It inserts a blank -line. You can use the command within or at the end of a line. If -used within a line, the @code{@@br@{@}} command must be followed by -left and right braces (as shown here) to mark the end of the -command.@refill - -@need 700 -For example, - -@example -@group -This line @@br@{@}contains and is ended by paragraph breaks@@br -and is followed by another line. -@end group -@end example - -@noindent -produces - -@example -@group -This line - -contains and is ended by paragraph breaks - -and is followed by another line. -@end group -@end example - -The @code{@@br} command is seldom used. -@end ignore - -@node page, group, sp, Breaks -@comment node-name, next, previous, up -@section @code{@@page}: Start a New Page -@cindex Page breaks -@findex page - -A line containing only @code{@@page} starts a new page in a printed -manual. The command has no effect on Info files since they are not -paginated. An @code{@@page} command is often used in the @code{@@titlepage} -section of a Texinfo file to start the copyright page.@refill - -@node group, need, page, Breaks -@comment node-name, next, previous, up -@section @code{@@group}: Prevent Page Breaks -@cindex Group (hold text together vertically) -@cindex Holding text together vertically -@cindex Vertically holding text together -@findex group - -The @code{@@group} command (on a line by itself) is used inside an -@code{@@example} or similar construct to begin an unsplittable vertical -group, which will appear entirely on one page in the printed output. -The group is terminated by a line containing only @code{@@end group}. -These two lines produce no output of their own, and in the Info file -output they have no effect at all.@refill - -@c Once said that these environments -@c turn off vertical spacing between ``paragraphs''. -@c Also, quotation used to work, but doesn't in texinfo-2.72 -Although @code{@@group} would make sense conceptually in a wide -variety of contexts, its current implementation works reliably only -within @code{@@example} and variants, and within @code{@@display}, -@code{@@format}, @code{@@flushleft} and @code{@@flushright}. -@xref{Quotations and Examples}. (What all these commands have in -common is that each line of input produces a line of output.) In -other contexts, @code{@@group} can cause anomalous vertical -spacing.@refill - -@need 750 -This formatting requirement means that you should write: - -@example -@group -@@example -@@group -@dots{} -@@end group -@@end example -@end group -@end example - -@noindent -with the @code{@@group} and @code{@@end group} commands inside the -@code{@@example} and @code{@@end example} commands. - -The @code{@@group} command is most often used to hold an example -together on one page. In this Texinfo manual, more than 100 examples -contain text that is enclosed between @code{@@group} and @code{@@end -group}. - -If you forget to end a group, you may get strange and unfathomable -error messages when you run @TeX{}. This is because @TeX{} keeps -trying to put the rest of the Texinfo file onto the one page and does -not start to generate error messages until it has processed -considerable text. It is a good rule of thumb to look for a missing -@code{@@end group} if you get incomprehensible error messages in -@TeX{}.@refill - -@node need, , group, Breaks -@comment node-name, next, previous, up -@section @code{@@need @var{mils}}: Prevent Page Breaks -@cindex Need space at page bottom -@findex need - -A line containing only @code{@@need @var{n}} starts -a new page in a printed manual if fewer than @var{n} mils (thousandths -of an inch) remain on the current page. Do not use -braces around the argument @var{n}. The @code{@@need} command has no -effect on Info files since they are not paginated.@refill - -@need 800 -This paragraph is preceded by an @code{@@need} command that tells -@TeX{} to start a new page if fewer than 800 mils (eight-tenths -inch) remain on the page. It looks like this:@refill - -@example -@group -@@need 800 -This paragraph is preceded by @dots{} -@end group -@end example - -The @code{@@need} command is useful for preventing orphans (single -lines at the bottoms of printed pages).@refill - -@node Definition Commands, Footnotes, Breaks, Top -@chapter Definition Commands -@cindex Definition commands - -The @code{@@deffn} command and the other @dfn{definition commands} -enable you to describe functions, variables, macros, commands, user -options, special forms and other such artifacts in a uniform -format.@refill - -In the Info file, a definition causes the entity -category---`Function', `Variable', or whatever---to appear at the -beginning of the first line of the definition, followed by the -entity's name and arguments. In the printed manual, the command -causes @TeX{} to print the entity's name and its arguments on the left -margin and print the category next to the right margin. In both -output formats, the body of the definition is indented. Also, the -name of the entity is entered into the appropriate index: -@code{@@deffn} enters the name into the index of functions, -@code{@@defvr} enters it into the index of variables, and so -on.@refill - -A manual need not and should not contain more than one definition for -a given name. An appendix containing a summary should use -@code{@@table} rather than the definition commands.@refill - -@menu -* Def Cmd Template:: How to structure a description using a - definition command. -* Optional Arguments:: How to handle optional and repeated arguments. -* deffnx:: How to group two or more `first' lines. -* Def Cmds in Detail:: All the definition commands. -* Def Cmd Conventions:: Conventions for writing definitions. -* Sample Function Definition:: -@end menu - -@node Def Cmd Template, Optional Arguments, , Definition Commands -@section The Template for a Definition -@cindex Definition template -@cindex Template for a definition - -The @code{@@deffn} command is used for definitions of entities that -resemble functions. To write a definition using the @code{@@deffn} -command, write the @code{@@deffn} command at the beginning of a line -and follow it on the same line by the category of the entity, the name -of the entity itself, and its arguments (if any). Then write the body -of the definition on succeeding lines. (You may embed examples in the -body.) Finally, end the definition with an @code{@@end deffn} command -written on a line of its own. (The other definition commands follow -the same format.)@refill - -The template for a definition looks like this: - -@example -@group -@@deffn @var{category} @var{name} @var{arguments}@dots{} -@var{body-of-definition} -@@end deffn -@end group -@end example - -@need 700 -@noindent -For example, - -@example -@group -@@deffn Command forward-word count -This command moves point forward @@var@{count@} words -(or backward if @@var@{count@} is negative). @dots{} -@@end deffn -@end group -@end example - -@noindent -produces - -@quotation -@deffn Command forward-word count -This function moves point forward @var{count} words -(or backward if @var{count} is negative). @dots{} -@end deffn -@end quotation - -Capitalize the category name like a title. If the name of the -category contains spaces, as in the phrase `Interactive Command', -write braces around it. For example:@refill - -@example -@group -@@deffn @{Interactive Command@} isearch-forward -@dots{} -@@end deffn -@end group -@end example - -@noindent -Otherwise, the second word will be mistaken for the name of the -entity.@refill - -Some of the definition commands are more general than others. The -@code{@@deffn} command, for example, is the general definition command -for functions and the like---for entities that may take arguments. When -you use this command, you specify the category to which the entity -belongs. The @code{@@deffn} command possesses three predefined, -specialized variations, @code{@@defun}, @code{@@defmac}, and -@code{@@defspec}, that specify the category for you: ``Function'', -``Macro'', and ``Special Form'' respectively. The @code{@@defvr} -command also is accompanied by several predefined, specialized -variations for describing particular kinds of variables.@refill - -The template for a specialized definition, such as @code{@@defun}, is -similar to the template for a generalized definition, except that you -do not need to specify the category:@refill - -@example -@group -@@defun @var{name} @var{arguments}@dots{} -@var{body-of-definition} -@@end defun -@end group -@end example - -@noindent -Thus, - -@example -@group -@@defun buffer-end flag -This function returns @@code@{(point-min)@} if @@var@{flag@} -is less than 1, @@code@{(point-max)@} otherwise. -@dots{} -@@end defun -@end group -@end example - -@noindent -produces - -@quotation -@defun buffer-end flag -This function returns @code{(point-min)} if @var{flag} is less than 1, -@code{(point-max)} otherwise. @dots{} -@end defun -@end quotation - -@noindent -@xref{Sample Function Definition, Sample Function Definition, A Sample -Function Definition}, for a more detailed example of a function -definition, including the use of @code{@@example} inside the -definition.@refill - -The other specialized commands work like @code{@@defun}.@refill - -@node Optional Arguments, deffnx, Def Cmd Template, Definition Commands -@section Optional and Repeated Arguments -@cindex Optional and repeated arguments -@cindex Repeated and optional arguments -@cindex Arguments, repeated and optional -@cindex Syntax, optional & repeated arguments -@cindex Meta-syntactic chars for arguments - -Some entities take optional or repeated arguments, which may be -specified by a distinctive glyph that uses square brackets and -ellipses. For @w{example}, a special form often breaks its argument list -into separate arguments in more complicated ways than a -straightforward function.@refill - -@iftex -An argument enclosed within square brackets is optional. -Thus, the phrase -@samp{@code{@r{[}@var{optional-arg}@r{]}}} means that -@var{optional-arg} is optional. -An argument followed by an ellipsis is optional -and may be repeated more than once. -@c This is consistent with Emacs Lisp Reference manual -Thus, @samp{@var{repeated-args}@dots{}} stands for zero or more arguments. -Parentheses are used when several arguments are grouped -into additional levels of list structure in Lisp. -@end iftex -@c The following looks better in Info (no `r', `samp' and `code'): -@ifinfo -An argument enclosed within square brackets is optional. -Thus, [@var{optional-arg}] means that @var{optional-arg} is optional. -An argument followed by an ellipsis is optional -and may be repeated more than once. -@c This is consistent with Emacs Lisp Reference manual -Thus, @var{repeated-args}@dots{} stands for zero or more arguments. -Parentheses are used when several arguments are grouped -into additional levels of list structure in Lisp. -@end ifinfo - -Here is the @code{@@defspec} line of an example of an imaginary -special form:@refill - -@quotation -@defspec foobar (@var{var} [@var{from} @var{to} [@var{inc}]]) @var{body}@dots{} -@end defspec -@tex -\vskip \parskip -@end tex -@end quotation - -@noindent -In this example, the arguments @var{from} and @var{to} are optional, -but must both be present or both absent. If they are present, -@var{inc} may optionally be specified as well. These arguments are -grouped with the argument @var{var} into a list, to distinguish them -from @var{body}, which includes all remaining elements of the -form.@refill - -In a Texinfo source file, this @code{@@defspec} line is written like -this (except it would not be split over two lines, as it is in this -example).@refill - -@example -@group -@@defspec foobar (@@var@{var@} [@@var@{from@} @@var@{to@} - [@@var@{inc@}]]) @@var@{body@}@@dots@{@} -@end group -@end example - -@noindent -The function is listed in the Command and Variable Index under -@samp{foobar}.@refill - -@node deffnx, Def Cmds in Detail, Optional Arguments, Definition Commands -@section Two or More `First' Lines -@cindex Two `First' Lines for @code{@@deffn} -@cindex Grouping two definitions together -@cindex Definitions grouped together -@findex deffnx - -To create two or more `first' or header lines for a definition, follow -the first @code{@@deffn} line by a line beginning with @code{@@deffnx}. -The @code{@@deffnx} command works exactly like @code{@@deffn} -except that it does not generate extra vertical white space between it -and the preceding line.@refill - -@need 1000 -For example, - -@example -@group -@@deffn @{Interactive Command@} isearch-forward -@@deffnx @{Interactive Command@} isearch-backward -These two search commands are similar except @dots{} -@@end deffn -@end group -@end example - -@noindent -produces - -@deffn {Interactive Command} isearch-forward -@deffnx {Interactive Command} isearch-backward -These two search commands are similar except @dots{} -@end deffn - -Each of the other definition commands has an `x' form: @code{@@defunx}, -@code{@@defvrx}, @code{@@deftypefunx}, etc. - -The `x' forms work just like @code{@@itemx}; see @ref{itemx, , @code{@@itemx}}. - -@node Def Cmds in Detail, Def Cmd Conventions, deffnx, Definition Commands -@section The Definition Commands - -Texinfo provides more than a dozen definition commands, all of which -are described in this section.@refill - -The definition commands automatically enter the name of the entity in -the appropriate index: for example, @code{@@deffn}, @code{@@defun}, -and @code{@@defmac} enter function names in the index of functions; -@code{@@defvr} and @code{@@defvar} enter variable names in the index -of variables.@refill - -Although the examples that follow mostly illustrate Lisp, the commands -can be used for other programming languages.@refill - -@menu -* Functions Commands:: Commands for functions and similar entities. -* Variables Commands:: Commands for variables and similar entities. -* Typed Functions:: Commands for functions in typed languages. -* Typed Variables:: Commands for variables in typed languages. -* Abstract Objects:: Commands for object-oriented programming. -* Data Types:: The definition command for data types. -@end menu - -@node Functions Commands, Variables Commands, , Def Cmds in Detail -@subsection Functions and Similar Entities - -This section describes the commands for describing functions and similar -entities:@refill - -@table @code -@findex deffn -@item @@deffn @var{category} @var{name} @var{arguments}@dots{} -The @code{@@deffn} command is the general definition command for -functions, interactive commands, and similar entities that may take -arguments. You must choose a term to describe the category of entity -being defined; for example, ``Function'' could be used if the entity is -a function. The @code{@@deffn} command is written at the beginning of a -line and is followed on the same line by the category of entity being -described, the name of this particular entity, and its arguments, if -any. Terminate the definition with @code{@@end deffn} on a line of its -own.@refill - -@need 750 -For example, here is a definition: - -@example -@group -@@deffn Command forward-char nchars -Move point forward @@var@{nchars@} characters. -@@end deffn -@end group -@end example - -@noindent -This shows a rather terse definition for a ``command'' named -@code{forward-char} with one argument, @var{nchars}. - -@code{@@deffn} prints argument names such as @var{nchars} in italics or -upper case, as if @code{@@var} had been used, because we think of these -names as metasyntactic variables---they stand for the actual argument -values. Within the text of the description, write an argument name -explicitly with @code{@@var} to refer to the value of the argument. In -the example above, we used @samp{@@var@{nchars@}} in this way. - -The template for @code{@@deffn} is: - -@example -@group -@@deffn @var{category} @var{name} @var{arguments}@dots{} -@var{body-of-definition} -@@end deffn -@end group -@end example - -@findex defun -@item @@defun @var{name} @var{arguments}@dots{} -The @code{@@defun} command is the definition command for functions. -@code{@@defun} is equivalent to @samp{@@deffn Function -@dots{}}.@refill - -@need 800 -@noindent -For example, - -@example -@group -@@defun set symbol new-value -Change the value of the symbol @@var@{symbol@} -to @@var@{new-value@}. -@@end defun -@end group -@end example - -@noindent -shows a rather terse definition for a function @code{set} whose -arguments are @var{symbol} and @var{new-value}. The argument names on -the @code{@@defun} line automatically appear in italics or upper case as -if they were enclosed in @code{@@var}. Terminate the definition with -@code{@@end defun} on a line of its own.@refill - -The template is: - -@example -@group -@@defun @var{function-name} @var{arguments}@dots{} -@var{body-of-definition} -@@end defun -@end group -@end example - -@code{@@defun} creates an entry in the index of functions. - -@findex defmac -@item @@defmac @var{name} @var{arguments}@dots{} -The @code{@@defmac} command is the definition command for macros. -@code{@@defmac} is equivalent to @samp{@@deffn Macro @dots{}} and -works like @code{@@defun}.@refill - -@findex defspec -@item @@defspec @var{name} @var{arguments}@dots{} -The @code{@@defspec} command is the definition command for special -forms. (In Lisp, a special form is an entity much like a function.) -@code{@@defspec} is equivalent to @samp{@@deffn @{Special Form@} -@dots{}} and works like @code{@@defun}.@refill -@end table - -@node Variables Commands, Typed Functions, Functions Commands, Def Cmds in Detail -@subsection Variables and Similar Entities - -Here are the commands for defining variables and similar -entities:@refill - -@table @code -@findex defvr -@item @@defvr @var{category} @var{name} -The @code{@@defvr} command is a general definition command for -something like a variable---an entity that records a value. You must -choose a term to describe the category of entity being defined; for -example, ``Variable'' could be used if the entity is a variable. -Write the @code{@@defvr} command at the beginning of a line and -followed it on the same line by the category of the entity and the -name of the entity.@refill - -Capitalize the category name like a title. If the name of the -category contains spaces, as in the name `User Option', write braces -around it. Otherwise, the second word will be mistaken for the name -of the entity, for example: - -@example -@group -@@defvr @{User Option@} fill-column -This buffer-local variable specifies -the maximum width of filled lines. -@dots{} -@@end defvr -@end group -@end example - -Terminate the definition with @code{@@end defvr} on a line of its -own.@refill - -The template is: - -@example -@group -@@defvr @var{category} @var{name} -@var{body-of-definition} -@@end defvr -@end group -@end example - -@code{@@defvr} creates an entry in the index of variables for @var{name}. - -@findex defvar -@item @@defvar @var{name} -The @code{@@defvar} command is the definition command for variables. -@code{@@defvar} is equivalent to @samp{@@defvr Variable -@dots{}}.@refill - -@need 750 -For example: - -@example -@group -@@defvar kill-ring -@dots{} -@@end defvar -@end group -@end example - -The template is: - -@example -@group -@@defvar @var{name} -@var{body-of-definition} -@@end defvar -@end group -@end example - -@code{@@defvar} creates an entry in the index of variables for -@var{name}.@refill - -@findex defopt -@item @@defopt @var{name} -The @code{@@defopt} command is the definition command for user -options. @code{@@defopt} is equivalent to @samp{@@defvr @{User -Option@} @dots{}} and works like @code{@@defvar}.@refill -@end table - -@node Typed Functions, Typed Variables, Variables Commands, Def Cmds in Detail -@subsection Functions in Typed Languages - -The @code{@@deftypefn} command and its variations are for describing -functions in C or any other language in which you must declare types -of variables and functions.@refill - -@table @code -@findex deftypefn -@item @@deftypefn @var{category} @var{data-type} @var{name} @var{arguments}@dots{} -The @code{@@deftypefn} command is the general definition command for -functions and similar entities that may take arguments and that are -typed. The @code{@@deftypefn} command is written at the beginning of -a line and is followed on the same line by the category of entity -being described, the type of the returned value, the name of this -particular entity, and its arguments, if any.@refill - -@need 800 -@noindent -For example, - -@example -@group -@@deftypefn @{Library Function@} int foobar - (int @@var@{foo@}, float @@var@{bar@}) -@dots{} -@@end deftypefn -@end group -@end example - -@need 1000 -@noindent -(where the text before the ``@dots{}'', shown above as two lines, would -actually be a single line in a real Texinfo file) produces the following -in Info: - -@smallexample -@group --- Library Function: int foobar (int FOO, float BAR) -@dots{} -@end group -@end smallexample -@iftex - -In a printed manual, it produces: - -@quotation -@deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) -@dots{} -@end deftypefn -@end quotation -@end iftex - -This means that @code{foobar} is a ``library function'' that returns an -@code{int}, and its arguments are @var{foo} (an @code{int}) and -@var{bar} (a @code{float}).@refill - -The argument names that you write in @code{@@deftypefn} are not subject -to an implicit @code{@@var}---since the actual names of the arguments in -@code{@@deftypefn} are typically scattered among data type names and -keywords, Texinfo cannot find them without help. Instead, you must write -@code{@@var} explicitly around the argument names. In the example -above, the argument names are @samp{foo} and @samp{bar}.@refill - -The template for @code{@@deftypefn} is:@refill - -@example -@group -@@deftypefn @var{category} @var{data-type} @var{name} @var{arguments} @dots{} -@var{body-of-description} -@@end deftypefn -@end group -@end example - -@noindent -Note that if the @var{category} or @var{data type} is more than one -word then it must be enclosed in braces to make it a single argument.@refill - -If you are describing a procedure in a language that has packages, -such as Ada, you might consider using @code{@@deftypefn} in a manner -somewhat contrary to the convention described in the preceding -paragraphs.@refill - -@need 800 -@noindent -For example: - -@example -@group -@@deftypefn stacks private push - (@@var@{s@}:in out stack; - @@var@{n@}:in integer) -@dots{} -@@end deftypefn -@end group -@end example - -@noindent -(The @code{@@deftypefn} arguments are shown split into three lines, but -would be a single line in a real Texinfo file.) - -In this instance, the procedure is classified as belonging to the -package @code{stacks} rather than classified as a `procedure' and its -data type is described as @code{private}. (The name of the procedure -is @code{push}, and its arguments are @var{s} and @var{n}.)@refill - -@code{@@deftypefn} creates an entry in the index of functions for -@var{name}.@refill - -@findex deftypefun -@item @@deftypefun @var{data-type} @var{name} @var{arguments}@dots{} -The @code{@@deftypefun} command is the specialized definition command -for functions in typed languages. The command is equivalent to -@samp{@@deftypefn Function @dots{}}.@refill - -@need 800 -@noindent -Thus, - -@smallexample -@group -@@deftypefun int foobar (int @@var@{foo@}, float @@var@{bar@}) -@dots{} -@@end deftypefun -@end group -@end smallexample - -@noindent -produces the following in Info: - -@example -@group --- Function: int foobar (int FOO, float BAR) -@dots{} -@end group -@end example -@iftex - -@need 800 -@noindent -and the following in a printed manual: - -@quotation -@deftypefun int foobar (int @var{foo}, float @var{bar}) -@dots{} -@end deftypefun -@end quotation -@end iftex - -@need 800 -The template is: - -@example -@group -@@deftypefun @var{type} @var{name} @var{arguments}@dots{} -@var{body-of-description} -@@end deftypefun -@end group -@end example - -@code{@@deftypefun} creates an entry in the index of functions for -@var{name}.@refill -@end table - -@node Typed Variables, Abstract Objects, Typed Functions, Def Cmds in Detail -@subsection Variables in Typed Languages - -Variables in typed languages are handled in a manner similar to -functions in typed languages. @xref{Typed Functions}. The general -definition command @code{@@deftypevr} corresponds to -@code{@@deftypefn} and the specialized definition command -@code{@@deftypevar} corresponds to @code{@@deftypefun}.@refill - -@table @code -@findex deftypevr -@item @@deftypevr @var{category} @var{data-type} @var{name} -The @code{@@deftypevr} command is the general definition command for -something like a variable in a typed language---an entity that records -a value. You must choose a term to describe the category of the -entity being defined; for example, ``Variable'' could be used if the -entity is a variable.@refill - -The @code{@@deftypevr} command is written at the beginning of a line -and is followed on the same line by the category of the entity -being described, the data type, and the name of this particular -entity.@refill - -@need 800 -@noindent -For example: - -@example -@group -@@deftypevr @{Global Flag@} int enable -@dots{} -@@end deftypevr -@end group -@end example - -@noindent -produces the following in Info: - -@example -@group --- Global Flag: int enable -@dots{} -@end group -@end example -@iftex - -@noindent -and the following in a printed manual: - -@quotation -@deftypevr {Global Flag} int enable -@dots{} -@end deftypevr -@end quotation -@end iftex - -@need 800 -The template is: - -@example -@@deftypevr @var{category} @var{data-type} @var{name} -@var{body-of-description} -@@end deftypevr -@end example - -@code{@@deftypevr} creates an entry in the index of variables for -@var{name}.@refill - -@findex deftypevar -@item @@deftypevar @var{data-type} @var{name} -The @code{@@deftypevar} command is the specialized definition command -for variables in typed languages. @code{@@deftypevar} is equivalent -to @samp{@@deftypevr Variable @dots{}}.@refill - -@need 800 -@noindent -For example: - -@example -@group -@@deftypevar int fubar -@dots{} -@@end deftypevar -@end group -@end example - -@noindent -produces the following in Info: - -@example -@group --- Variable: int fubar -@dots{} -@end group -@end example -@iftex - -@need 800 -@noindent -and the following in a printed manual: - -@quotation -@deftypevar int fubar -@dots{} -@end deftypevar -@end quotation -@end iftex - -@need 800 -@noindent -The template is: - -@example -@group -@@deftypevar @var{data-type} @var{name} -@var{body-of-description} -@@end deftypevar -@end group -@end example - -@code{@@deftypevar} creates an entry in the index of variables for -@var{name}.@refill -@end table - -@node Abstract Objects, Data Types, Typed Variables, Def Cmds in Detail -@subsection Object-Oriented Programming - -Here are the commands for formatting descriptions about abstract -objects, such as are used in object-oriented programming. A class is -a defined type of abstract object. An instance of a class is a -particular object that has the type of the class. An instance -variable is a variable that belongs to the class but for which each -instance has its own value.@refill - -In a definition, if the name of a class is truly a name defined in the -programming system for a class, then you should write an @code{@@code} -around it. Otherwise, it is printed in the usual text font.@refill - -@table @code -@findex defcv -@item @@defcv @var{category} @var{class} @var{name} -The @code{@@defcv} command is the general definition command for -variables associated with classes in object-oriented programming. The -@code{@@defcv} command is followed by three arguments: the category of -thing being defined, the class to which it belongs, and its -name. Thus,@refill - -@example -@group -@@defcv @{Class Option@} Window border-pattern -@dots{} -@@end defcv -@end group -@end example - -@noindent -illustrates how you would write the first line of a definition of the -@code{border-pattern} class option of the class @code{Window}.@refill - -The template is - -@example -@group -@@defcv @var{category} @var{class} @var{name} -@dots{} -@@end defcv -@end group -@end example - -@code{@@defcv} creates an entry in the index of variables. - -@findex defivar -@item @@defivar @var{class} @var{name} -The @code{@@defivar} command is the definition command for instance -variables in object-oriented programming. @code{@@defivar} is -equivalent to @samp{@@defcv @{Instance Variable@} @dots{}}@refill - -The template is: - -@example -@group -@@defivar @var{class} @var{instance-variable-name} -@var{body-of-definition} -@@end defivar -@end group -@end example - -@code{@@defivar} creates an entry in the index of variables. - -@findex defop -@item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} -The @code{@@defop} command is the general definition command for -entities that may resemble methods in object-oriented programming. -These entities take arguments, as functions do, but are associated -with particular classes of objects.@refill - -For example, some systems have constructs called @dfn{wrappers} that -are associated with classes as methods are, but that act more like -macros than like functions. You could use @code{@@defop Wrapper} to -describe one of these.@refill - -Sometimes it is useful to distinguish methods and @dfn{operations}. -You can think of an operation as the specification for a method. -Thus, a window system might specify that all window classes have a -method named @code{expose}; we would say that this window system -defines an @code{expose} operation on windows in general. Typically, -the operation has a name and also specifies the pattern of arguments; -all methods that implement the operation must accept the same -arguments, since applications that use the operation do so without -knowing which method will implement it.@refill - -Often it makes more sense to document operations than methods. For -example, window application developers need to know about the -@code{expose} operation, but need not be concerned with whether a -given class of windows has its own method to implement this operation. -To describe this operation, you would write:@refill - -@example -@@defop Operation windows expose -@end example - -The @code{@@defop} command is written at the beginning of a line and -is followed on the same line by the overall name of the category of -operation, the name of the class of the operation, the name of the -operation, and its arguments, if any.@refill - -@need 800 -@noindent -The template is: - -@example -@group -@@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} -@var{body-of-definition} -@@end defop -@end group -@end example - -@code{@@defop} creates an entry, such as `@code{expose} on -@code{windows}', in the index of functions.@refill - -@findex defmethod -@item @@defmethod @var{class} @var{name} @var{arguments}@dots{} -The @code{@@defmethod} command is the definition command for methods -in object-oriented programming. A method is a kind of function that -implements an operation for a particular class of objects and its -subclasses. In the Lisp Machine, methods actually were functions, but -they were usually defined with @code{defmethod}. - -@code{@@defmethod} is equivalent to @samp{@@defop Method @dots{}}. -The command is written at the beginning of a line and is followed by -the name of the class of the method, the name of the method, and its -arguments, if any.@refill - -@need 800 -@noindent -For example, - -@example -@group -@@defmethod @code{bar-class} bar-method argument -@dots{} -@@end defmethod -@end group -@end example - -@noindent -illustrates the definition for a method called @code{bar-method} of -the class @code{bar-class}. The method takes an argument.@refill - -The template is: - -@example -@group -@@defmethod @var{class} @var{method-name} @var{arguments}@dots{} -@var{body-of-definition} -@@end defmethod -@end group -@end example - -@c !!! reworded to prevent overfull hbox --bob 26 Mar 93 -@code{@@defmethod} creates an entry in the index of functions, such as -`@code{bar-method} on @code{bar-class}'.@refill -@end table - -@node Data Types, , Abstract Objects, Def Cmds in Detail -@subsection Data Types - -Here is the command for data types:@refill - -@table @code -@findex deftp -@item @@deftp @var{category} @var{name} @var{attributes}@dots{} -The @code{@@deftp} command is the generic definition command for data -types. The command is written at the beginning of a line and is -followed on the same line by the category, by the name of the type -(which is a word like @code{int} or @code{float}), and then by names of -attributes of objects of that type. Thus, you could use this command -for describing @code{int} or @code{float}, in which case you could use -@code{data type} as the category. (A data type is a category of -certain objects for purposes of deciding which operations can be -performed on them.)@refill - -In Lisp, for example, @dfn{pair} names a particular data -type, and an object of that type has two slots called the -@sc{car} and the @sc{cdr}. Here is how you would write the first line -of a definition of @code{pair}.@refill - -@example -@group -@@deftp @{Data type@} pair car cdr -@dots{} -@@end deftp -@end group -@end example - -@need 950 -The template is: - -@example -@group -@@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} -@var{body-of-definition} -@@end deftp -@end group -@end example - -@code{@@deftp} creates an entry in the index of data types. -@end table - -@node Def Cmd Conventions, Sample Function Definition, Def Cmds in Detail, Definition Commands -@section Conventions for Writing Definitions -@cindex Definition conventions -@cindex Conventions for writing definitions - -When you write a definition using @code{@@deffn}, @code{@@defun}, or -one of the other definition commands, please take care to use -arguments that indicate the meaning, as with the @var{count} argument -to the @code{forward-word} function. Also, if the name of an argument -contains the name of a type, such as @var{integer}, take care that the -argument actually is of that type.@refill - -@node Sample Function Definition, , Def Cmd Conventions, Definition Commands -@section A Sample Function Definition -@cindex Function definitions -@cindex Command definitions -@cindex Macro definitions -@cindex Sample function definition - -A function definition uses the @code{@@defun} and @code{@@end defun} -commands. The name of the function follows immediately after the -@code{@@defun} command and it is followed, on the same line, by the -parameter list.@refill - -Here is a definition from @cite{The GNU Emacs Lisp Reference Manual}. -(@xref{Calling Functions, , Calling Functions, elisp, The GNU Emacs -Lisp Reference Manual}.) - -@quotation -@defun apply function &rest arguments -@code{apply} calls @var{function} with @var{arguments}, just -like @code{funcall} but with one difference: the last of -@var{arguments} is a list of arguments to give to -@var{function}, rather than a single argument. We also say -that this list is @dfn{appended} to the other arguments. - -@code{apply} returns the result of calling @var{function}. -As with @code{funcall}, @var{function} must either be a Lisp -function or a primitive function; special forms and macros -do not make sense in @code{apply}. - -@example -(setq f 'list) - @result{} list -(apply f 'x 'y 'z) -@error{} Wrong type argument: listp, z -(apply '+ 1 2 '(3 4)) - @result{} 10 -(apply '+ '(1 2 3 4)) - @result{} 10 - -(apply 'append '((a b c) nil (x y z) nil)) - @result{} (a b c x y z) -@end example - -An interesting example of using @code{apply} is found in the description -of @code{mapcar}.@refill -@end defun -@end quotation - -@need 1200 -In the Texinfo source file, this example looks like this: - -@example -@group -@@defun apply function &rest arguments - -@@code@{apply@} calls @@var@{function@} with -@@var@{arguments@}, just like @@code@{funcall@} but with one -difference: the last of @@var@{arguments@} is a list of -arguments to give to @@var@{function@}, rather than a single -argument. We also say that this list is @@dfn@{appended@} -to the other arguments. -@end group - -@group -@@code@{apply@} returns the result of calling -@@var@{function@}. As with @@code@{funcall@}, -@@var@{function@} must either be a Lisp function or a -primitive function; special forms and macros do not make -sense in @@code@{apply@}. -@end group - -@group -@@example -(setq f 'list) - @@result@{@} list -(apply f 'x 'y 'z) -@@error@{@} Wrong type argument: listp, z -(apply '+ 1 2 '(3 4)) - @@result@{@} 10 -(apply '+ '(1 2 3 4)) - @@result@{@} 10 - -(apply 'append '((a b c) nil (x y z) nil)) - @@result@{@} (a b c x y z) -@@end example -@end group - -@group -An interesting example of using @@code@{apply@} is found -in the description of @@code@{mapcar@}.@@refill -@@end defun -@end group -@end example - -@noindent -In this manual, this function is listed in the Command and Variable -Index under @code{apply}.@refill - -Ordinary variables and user options are described using a format like -that for functions except that variables do not take arguments. - -@node Footnotes, Conditionals, Definition Commands, Top -@comment node-name, next, previous, up -@chapter Footnotes -@cindex Footnotes -@findex footnote - -A @dfn{footnote} is for a reference that documents or elucidates the -primary text.@footnote{A footnote should complement or expand upon -the primary text, but a reader should not need to read a footnote to -understand the primary text. For a thorough discussion of footnotes, -see @cite{The Chicago Manual of Style}, which is published by the -University of Chicago Press.}@refill - -In Texinfo, footnotes are created with the @code{@@footnote} command. -This command is followed immediately by a left brace, then by the text -of the footnote, and then by a terminating right brace. The template -is: - -@example -@@footnote@{@var{text}@} -@end example - -Footnotes may be of any length, but are usually short.@refill - -For example, this clause is followed by a sample -footnote@footnote{Here is the sample footnote.}; in the Texinfo -source, it looks like this:@refill - -@example -@dots{}a sample footnote @@footnote@{Here is the sample -footnote.@}; in the Texinfo source@dots{} -@end example - -In a printed manual or book, the reference mark for a footnote is a -small, superscripted number; the text of the footnote is written at -the bottom of the page, below a horizontal line.@refill - -In Info, the reference mark for a footnote is a pair of parentheses -with the footnote number between them, like this: @samp{(1)}.@refill - -Info has two footnote styles, which determine where the text of the -footnote is located:@refill - -@itemize @bullet -@cindex @samp{@r{End}} node footnote style -@item -In the `End' node style, all the footnotes for a single node -are placed at the end of that node. The footnotes are separated from -the rest of the node by a line of dashes with the word -@samp{Footnotes} within it. Each footnote begins with an -@samp{(@var{n})} reference mark.@refill - -@need 700 -@noindent -Here is an example of a single footnote in the end of node style:@refill - -@example -@group - --------- Footnotes --------- - -(1) Here is a sample footnote. -@end group -@end example - -@cindex @samp{@r{Separate}} footnote style -@item -In the `Separate' node style, all the footnotes for a single -node are placed in an automatically constructed node of -their own. In this style, a ``footnote reference'' follows -each @samp{(@var{n})} reference mark in the body of the -node. The footnote reference is actually a cross reference -which you use to reach the footnote node.@refill - -The name of the node containing the footnotes is constructed -by appending @w{@samp{-Footnotes}} to the name of the node -that contains the footnotes. (Consequently, the footnotes' -node for the @file{Footnotes} node is -@w{@file{Footnotes-Footnotes}}!) The footnotes' node has an -`Up' node pointer that leads back to its parent node.@refill - -@noindent -Here is how the first footnote in this manual looks after being -formatted for Info in the separate node style:@refill - -@smallexample -@group -File: texinfo.info Node: Overview-Footnotes, Up: Overview - -(1) Note that the first syllable of "Texinfo" is -pronounced like "speck", not "hex". @dots{} -@end group -@end smallexample -@end itemize - -A Texinfo file may be formatted into an Info file with either footnote -style.@refill - -@findex footnotestyle -Use the @code{@@footnotestyle} command to specify an Info file's -footnote style. Write this command at the beginning of a line followed -by an argument, either @samp{end} for the end node style or -@samp{separate} for the separate node style. - -@need 700 -For example, - -@example -@@footnotestyle end -@end example -@noindent -or -@example -@@footnotestyle separate -@end example - -Write an @code{@@footnotestyle} command before or shortly after the -end-of-header line at the beginning of a Texinfo file. (If you -include the @code{@@footnotestyle} command between the start-of-header -and end-of-header lines, the region formatting commands will format -footnotes as specified.)@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -If you do not specify a footnote style, the formatting commands use -their default style. Currently, @code{makeinfo} uses the `end' style, -while @code{texinfo-format-buffer} and @code{texinfo-format-region} -use the `separate' style.@refill - -@c !!! note: makeinfo's --footnote-style option overrides footnotestyle -@ignore -If you use @code{makeinfo} to create the Info file, the -@samp{--footnote-style} option determines which style is used, -@samp{end} for the end of node style or @samp{separate} for the -separate node style. Thus, to format the Texinfo manual in the -separate node style, you would use the following shell command:@refill - -@example -makeinfo --footnote-style=separate texinfo.texi -@end example - -@noindent -To format the Texinfo manual in the end of node style, you would -type:@refill - -@example -makeinfo --footnote-style=end texinfo.texi -@end example -@end ignore -@ignore -If you use @code{texinfo-format-buffer} or -@code{texinfo-format-region} to create the Info file, the value of the -@code{texinfo-footnote-style} variable controls the footnote style. -It can be either @samp{"separate"} for the separate node style or -@samp{"end"} for the end of node style. (You can change the value of -this variable with the @kbd{M-x edit-options} command (@pxref{Edit -Options, , Editing Variable Values, emacs, The GNU Emacs Manual}), or -with the @kbd{M-x set-variable} command (@pxref{Examining, , Examining -and Setting Variables, emacs, The GNU Emacs Manual}).@refill - -The @code{texinfo-footnote-style} variable also controls the style if -you use the @kbd{M-x makeinfo-region} or @kbd{M-x makeinfo-buffer} -command in Emacs.@refill -@end ignore -This chapter contains two footnotes.@refill - -@node Conditionals, Format/Print Hardcopy, Footnotes, Top -@comment node-name, next, previous, up -@chapter Conditionally Visible Text -@cindex Conditionally visible text -@cindex Text, conditionally visible -@cindex Visibility of conditional text -@cindex If text conditionally visible -@findex ifinfo -@findex iftex - -Sometimes it is good to use different text for a printed manual and -its corresponding Info file. In this case, you can use the -@dfn{conditional commands} to specify which text is for the printed manual -and which is for the Info file.@refill - -@menu -* Conditional Commands:: How to specify text for Info or @TeX{}. -* Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. -* set clear value:: How to designate which text to format (for - both Info and @TeX{}); and how to set a - flag to a string that you can insert. -@end menu - -@node Conditional Commands, Using Ordinary TeX Commands, , Conditionals -@ifinfo -@heading Using @code{@@ifinfo} and @code{@@iftex} -@end ifinfo - -@code{@@ifinfo} begins segments of text that should be ignored -by @TeX{} when it -typesets the printed manual. The segment of text appears only -in the Info file. -The @code{@@ifinfo} command should appear on a line by itself; end -the Info-only text with a line containing @code{@@end ifinfo} by -itself. At the beginning of a Texinfo file, the Info permissions are -contained within a region marked by @code{@@ifinfo} and @code{@@end -ifinfo}. (@xref{Info Summary and Permissions}.)@refill - -The @code{@@iftex} and @code{@@end iftex} commands are similar to the -@code{@@ifinfo} and @code{@@end ifinfo} commands, except that they -specify text that will appear in the printed manual but not in the Info -file.@refill - -@need 700 -For example, - -@example -@@iftex -This text will appear only in the printed manual. -@@end iftex - -@@ifinfo -However, this text will appear only in Info. -@@end ifinfo -@end example - -@noindent -The preceding example produces the following line: - -@iftex -This text will appear only in the printed manual. -@end iftex - -@ifinfo -However, this text will appear only in Info. -@end ifinfo - -@noindent -Note how you only see one of the two lines, depending on whether you -are reading the Info version or the printed version of this -manual.@refill - -The @code{@@titlepage} command is a special variant of @code{@@iftex} that -is used for making the title and copyright pages of the printed -manual. (@xref{titlepage, , @code{@@titlepage}}.) @refill - -@node Using Ordinary TeX Commands, set clear value, Conditional Commands, Conditionals -@comment node-name, next, previous, up -@section Using Ordinary @TeX{} Commands -@cindex @TeX{} commands, using ordinary -@cindex Ordinary @TeX{} commands, using -@cindex Commands using ordinary @TeX{} -@cindex Plain@TeX{} - -Inside a region delineated by @code{@@iftex} and @code{@@end iftex}, -you can embed some Plain@TeX{} commands. Info will ignore these -commands since they are only in that part of the file which is seen by -@TeX{}. You can write the @TeX{} commands as you would write them in -a normal @TeX{} file, except that you must replace the @samp{\} used -by @TeX{} with an @samp{@@}. For example, in the @code{@@titlepage} -section of a Texinfo file, you can use the @TeX{} command -@code{@@vskip} to format the copyright page. (The @code{@@titlepage} -command causes Info to ignore the region automatically, as it does -with the @code{@@iftex} command.)@refill - -However, many features of Plain@TeX{} will not work, as they are -overridden by features of Texinfo. - -@findex tex -You can enter Plain@TeX{} completely, and use @samp{\} in the @TeX{} -commands, by delineating a region with the @code{@@tex} and @code{@@end -tex} commands. (The @code{@@tex} command also causes Info to ignore the -region, like the @code{@@iftex} -command.)@refill - -@cindex Mathematical expressions -For example, here is a mathematical expression written in -Plain@TeX{}:@refill - -@example -@@tex -$$ \chi^2 = \sum_@{i=1@}^N - \left (y_i - (a + b x_i) - \over \sigma_i\right)^2 $$ -@@end tex -@end example - -@noindent -The output of this example will appear only in a printed manual. If -you are reading this in Info, you will not see anything after this -paragraph. -@iftex -In a printed manual, the above expression looks like -this: -@end iftex - -@tex -$$ \chi^2 = \sum_{i=1}^N - \left(y_i - (a + b x_i) - \over \sigma_i\right)^2 $$ -@end tex - -@node set clear value, , Using Ordinary TeX Commands, Conditionals -@comment node-name, next, previous, up -@section @code{@@set}, @code{@@clear}, and @code{@@value} - -You can direct the Texinfo formatting commands to format or ignore parts -of a Texinfo file with the @code{@@set}, @code{@@clear}, @code{@@ifset}, -and @code{@@ifclear} commands.@refill - -In addition, you can use the @code{@@set @var{flag}} command to set the -value of @var{flag} to a string of characters; and use -@code{@@value@{@var{flag}@}} to insert that string. You can use -@code{@@set}, for example, to set a date and use @code{@@value} to -insert the date in several places in the Texinfo file.@refill - -@menu -* ifset ifclear:: Format a region if a flag is set. -* value:: Replace a flag with a string. -* value Example:: An easy way to update edition information. -@end menu - -@node ifset ifclear, value, , set clear value -@subsection @code{@@ifset} and @code{@@ifclear} - -@findex ifset -When a @var{flag} is set, the Texinfo formatting commands format text -between subsequent pairs of @code{@@ifset @var{flag}} and @code{@@end -ifset} commands. When the @var{flag} is cleared, the Texinfo formatting -commands do @emph{not} format the text. - -Use the @code{@@set @var{flag}} command to turn on, or @dfn{set}, a -@var{flag}; a @dfn{flag} can be any single word. The format for the -command looks like this:@refill -@findex set - -@example -@@set @var{flag} -@end example - -Write the conditionally formatted text between @code{@@ifset @var{flag}} -and @code{@@end ifset} commands, like this:@refill - -@example -@group -@@ifset @var{flag} -@var{conditional-text} -@@end ifset -@end group -@end example - -For example, you can create one document that has two variants, such as -a manual for a `large' and `small' model:@refill - -@example -You can use this machine to dig up shrubs -without hurting them. - -@@set large - -@@ifset large -It can also dig up fully grown trees. -@@end ifset - -Remember to replant promptly @dots{} -@end example - -@noindent -In the example, the formatting commands will format the text between -@code{@@ifset large} and @code{@@end ifset} because the @code{large} -flag is set.@refill - -@findex clear -Use the @code{@@clear @var{flag}} command to turn off, or @dfn{clear}, -a flag. Clearing a flag is the opposite of setting a flag. The -command looks like this:@refill - -@example -@@clear @var{flag} -@end example - -@noindent -Write the command on a line of its own. - -When @var{flag} is cleared, the Texinfo formatting commands do -@emph{not} format the text between @code{@@ifset @var{flag}} and -@code{@@end ifset}; that text is ignored and does not appear in either -printed or Info output.@refill - -For example, if you clear the flag of the preceding example by writing -an @code{@@clear large} command after the @code{@@set large} command -(but before the conditional text), then the Texinfo formatting commands -ignore the text between the @code{@@ifset large} and @code{@@end ifset} -commands. In the formatted output, that text does not appear; in both -printed and Info output, you see only the lines that say, ``You can use -this machine to dig up shrubs without hurting them. Remember to replant -promptly @dots{}''. - -@findex ifclear -If a flag is cleared with an @code{@@clear @var{flag}} command, then -the formatting commands format text between subsequent pairs of -@code{@@ifclear} and @code{@@end ifclear} commands. But if the flag -is set with @code{@@set @var{flag}}, then the formatting commands do -@emph{not} format text between an @code{@@ifclear} and an @code{@@end -ifclear} command; rather, they ignore that text. An @code{@@ifclear} -command looks like this:@refill - -@example -@@ifclear @var{flag} -@end example - -@need 700 -In brief, the commands are:@refill - -@table @code -@item @@set @var{flag} -Tell the Texinfo formatting commands that @var{flag} is set.@refill - -@item @@clear @var{flag} -Tell the Texinfo formatting commands that @var{flag} is cleared.@refill - -@item @@ifset @var{flag} -If @var{flag} is set, tell the Texinfo formatting commands to format -the text up to the following @code{@@end ifset} command.@refill - -If @var{flag} is cleared, tell the Texinfo formatting commands to -ignore text up to the following @code{@@end ifset} command.@refill - -@item @@ifclear @var{flag} -If @var{flag} is set, tell the Texinfo formatting commands to ignore -the text up to the following @code{@@end ifclear} command.@refill - -If @var{flag} is cleared, tell the Texinfo formatting commands to -format the text up to the following @code{@@end ifclear} -command.@refill -@end table - -@node value, value Example, ifset ifclear, set clear value -@subsection @code{@@value} -@findex value - -You can use the @code{@@set} command to specify a value for a flag, -which is expanded by the @code{@@value} command. The value is a string -a characters. - -Write the @code{@@set} command like this: - -@example -@@set foo This is a string. -@end example - -@noindent -This sets the value of @code{foo} to ``This is a string.'' - -The Texinfo formatters replace an @code{@@value@{@var{flag}@}} command with -the string to which @var{flag} is set.@refill - -Thus, when @code{foo} is set as shown above, the Texinfo formatters convert - -@example -@group -@@value@{foo@} -@exdent @r{to} -This is a string. -@end group -@end example - -You can write an @code{@@value} command within a paragraph; but you -must write an @code{@@set} command on a line of its own. - -If you write the @code{@@set} command like this: - -@example -@@set foo -@end example - -@noindent -without specifying a string, the value of @code{foo} is an empty string. - -If you clear a previously set flag with an @code{@@clear @var{flag}} -command, a subsequent @code{@@value@{flag@}} command is invalid and the -string is replaced with an error message that says @samp{@{No value for -"@var{flag}"@}}. - -For example, if you set @code{foo} as follows:@refill - -@example -@@set how-much very, very, very -@end example - -@noindent -then the formatters transform - -@example -@group -It is a @@value@{how-much@} wet day. -@exdent @r{into} -It is a very, very, very wet day. -@end group -@end example - -If you write - -@example -@@clear how-much -@end example - -@noindent -then the formatters transform - -@example -@group -It is a @@value@{how-much@} wet day. -@exdent @r{into} -It is a @{No value for "how-much"@} wet day. -@end group -@end example - -@node value Example, , value, set clear value -@subsection @code{@@value} Example - -You can use the @code{@@value} command to limit the number of places you -need to change when you record an update to a manual. -Here is how it is done in @cite{The GNU Make Manual}: - -@need 1000 -@noindent -Set the flags: - -@example -@group -@@set EDITION 0.35 Beta -@@set VERSION 3.63 Beta -@@set UPDATED 14 August 1992 -@@set UPDATE-MONTH August 1992 -@end group -@end example - -@need 750 -@noindent -Write text for the first @code{@@ifinfo} section, for people reading the -Texinfo file: - -@example -@group -This is Edition @@value@{EDITION@}, -last updated @@value@{UPDATED@}, -of @@cite@{The GNU Make Manual@}, -for @@code@{make@}, Version @@value@{VERSION@}. -@end group -@end example - -@need 1000 -@noindent -Write text for the title page, for people reading the printed manual: -@c List only the month and the year since that looks less fussy on a -@c printed cover than a date that lists the day as well. - -@example -@group -@@title GNU Make -@@subtitle A Program for Directing Recompilation -@@subtitle Edition @@value@{EDITION@}, @dots{} -@@subtitle @@value@{UPDATE-MONTH@} -@end group -@end example - -@noindent -(On a printed cover, a date listing the month and the year looks less -fussy than a date listing the day as well as the month and year.) - -@need 750 -@noindent -Write text for the Top node, for people reading the Info file: - -@example -@group -This is Edition @@value@{EDITION@} -of the @@cite@{GNU Make Manual@}, -last updated @@value@{UPDATED@} -for @@code@{make@} Version @@value@{VERSION@}. -@end group -@end example - -@need 950 -After you format the manual, the text in the first @code{@@ifinfo} -section looks like this: - -@example -@group -This is Edition 0.35 Beta, last updated 14 August 1992, -of `The GNU Make Manual', for `make', Version 3.63 Beta. -@end group -@end example - -When you update the manual, change only the values of the flags; you do -not need to rewrite the three sections. - -@node Format/Print Hardcopy, Create an Info File, Conditionals, Top -@comment node-name, next, previous, up -@chapter Format and Print Hardcopy -@cindex Format and print hardcopy -@cindex Hardcopy, printing it -@cindex Making a printed manual -@cindex Sorting indices -@cindex Indices, sorting -@cindex @TeX{} index sorting -@findex texindex - -There are three major shell commands for making a printed manual from a -Texinfo file: one for converting the Texinfo file into a file that will be -printed, a second for sorting indices, and a third for printing the -formatted document. When you use the shell commands, you can either -work directly in the operating system shell or work within a shell -inside GNU Emacs.@refill - -If you are using GNU Emacs, you can use commands provided by Texinfo -mode instead of shell commands. In addition to the three commands to -format a file, sort the indices, and print the result, Texinfo mode -offers key bindings for commands to recenter the output buffer, show the -print queue, and delete a job from the print queue.@refill - -@menu -* Use TeX:: Use @TeX{} to format for hardcopy. -* Shell Format & Print:: How to format and print a hardcopy manual - with shell commands. -* Within Emacs:: How to format and print from an Emacs shell. -* Texinfo Mode Printing:: How to format and print in Texinfo mode. -* Compile-Command:: How to print using Emacs's compile command. -* Requirements Summary:: @TeX{} formatting requirements summary. -* Preparing for TeX:: What you need to do to use @TeX{}. -* Overfull hboxes:: What are and what to do with overfull hboxes. -* smallbook:: How to print small format books and manuals. -* A4 Paper:: How to print on European A4 paper. -* Cropmarks and Magnification:: How to print marks to indicate the size - of pages and how to print scaled up output. -@end menu - -@node Use TeX, Shell Format & Print, , Format/Print Hardcopy -@ifinfo -@heading Use @TeX{} -@end ifinfo - -The typesetting program called @TeX{} is used for formatting a Texinfo -file. @TeX{} is a very powerful typesetting program and, if used right, -does an exceptionally good job. @xref{Obtaining TeX, , How to Obtain -@TeX{}}, for information on how to obtain @TeX{}.@refill - -The @code{makeinfo}, @code{texinfo-format-region}, and -@code{texinfo-format-buffer} commands read the very same @@-commands -in the Texinfo file as does @TeX{}, but process them differently to -make an Info file; see @ref{Create an Info File}.@refill - -@node Shell Format & Print, Within Emacs, Use TeX, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Format and Print Using Shell Commands - -@cindex DVI file -Format the Texinfo file with the shell command @code{tex} followed by -the name of the Texinfo file. This produces a formatted @sc{dvi} file -as well as several auxiliary files containing indices, cross -references, etc. The @sc{dvi} file (for @dfn{DeVice Independent} -file) can be printed on a wide variety of printers.@refill - -The @code{tex} formatting command itself does not sort the indices; it -writes an output file of unsorted index data. This is a misfeature of -@TeX{}. Hence, to generate a printed index, you first need a sorted -index to work from. The @code{texindex} command sorts indices. (The -source file @file{texindex.c} comes as part of the standard GNU -distribution and is usually installed when Emacs is installed.)@refill -@findex texindex -@ignore -Usage: texindex [-k] [-T tempdir] infile [-o outfile] ... - -Each infile arg can optionally be followed by a `-o outfile' arg; -for each infile that is not followed by a -o arg, the infile name with -`s' (for `sorted') appended is used for the outfile. - --T dir is the directory to put temp files in, instead of /tmp. --k means `keep tempfiles', for debugging. -@end ignore - -The @code{tex} formatting command outputs unsorted index files under -names that obey a standard convention. These names are the name of -your main input file to the @code{tex} formatting command, with -everything after the first period thrown away, and the two letter -names of indices added at the end. For example, the raw index output -files for the input file @file{foo.texinfo} would be @file{foo.cp}, -@file{foo.vr}, @file{foo.fn}, @file{foo.tp}, @file{foo.pg} and -@file{foo.ky}. Those are exactly the arguments to give to -@code{texindex}.@refill - -@need 1000 -Or else, you can use @samp{??} as ``wild-cards'' and give the command in -this form:@refill - -@example -texindex foo.?? -@end example - -@noindent -This command will run @code{texindex} on all the unsorted index files, -including any that you have defined yourself using @code{@@defindex} -or @code{@@defcodeindex}. (You may execute @samp{texindex foo.??} -even if there are similarly named files with two letter extensions -that are not index files, such as @samp{foo.el}. The @code{texindex} -command reports but otherwise ignores such files.)@refill - -For each file specified, @code{texindex} generates a sorted index file -whose name is made by appending @samp{s} to the input file name. The -@code{@@printindex} command knows to look for a file of that name. -@code{texindex} does not alter the raw index output file.@refill - -After you have sorted the indices, you need to rerun the @code{tex} -formatting command on the Texinfo file. This regenerates a formatted -@sc{dvi} file with up-to-date index entries.@footnote{If you use more -than one index and have cross references to an index other than the -first, you must run @code{tex} @emph{three times} to get correct output: -once to generate raw index data; again (after @code{texindex}) to output -the text of the indices and determine their true page numbers; and a -third time to output correct page numbers in cross references to them. -However, cross references to indices are rare.}@refill - -To summarize, this is a three step process: - -@enumerate -@item -Run the @code{tex} formatting command on the Texinfo file. This -generates the formatted @sc{dvi} file as well as the raw index files -with two letter extensions.@refill - -@item -Run the shell command @code{texindex} on the raw index files to sort -them. This creates the corresponding sorted index files.@refill - -@item -Rerun the @code{tex} formatting command on the Texinfo file. This -regenerates a formatted @sc{dvi} file with the index entries in the -correct order. This second run also corrects the page numbers for -the cross references. (The tables of contents are always correct.)@refill -@end enumerate - -You need not run @code{texindex} each time after you run the -@code{tex} formatting. If you do not, on the next run, the @code{tex} -formatting command will use whatever sorted index files happen to -exist from the previous use of @code{texindex}. This is usually -@sc{ok} while you are debugging.@refill - -@findex texi2dvi @r{(shell script)} -Rather than type the @code{tex} and @code{texindex} commands yourself, -you can use @code{texi2dvi}. This shell script is designed to -simplify the @code{tex}---@code{texindex}---@code{tex} sequence by -figuring out whether index files and @sc{dvi} files are up-to-date. -It runs @code{texindex} and @code{tex} only when necessary. - -@need 1000 -The syntax for @code{texi2dvi} is like this (where @samp{%} is the -shell prompt):@refill - -@example -% texi2dvi @var{filename}@dots{} -@end example - -@findex lpr @r{(@sc{dvi} print command)} -Finally, you can print the @sc{dvi} file with the @sc{dvi} print command. -The precise command to use depends on the system; @samp{lpr -d} is -common. The @sc{dvi} print command may require a file name without any -extension or with a @samp{.dvi} extension.@refill - -@need 1200 -The following commands, for example, sort the indices, format, and -print the @cite{Bison Manual} (where @samp{%} is the shell -prompt):@refill - -@example -@group -% tex bison.texinfo -% texindex bison.?? -% tex bison.texinfo -% lpr -d bison.dvi -@end group -@end example - -@noindent -(Remember that the shell commands may be different at your site; but -these are commonly used versions.)@refill - -@node Within Emacs, Texinfo Mode Printing, Shell Format & Print, Format/Print Hardcopy -@comment node-name, next, previous, up -@section From an Emacs Shell @dots{} -@cindex Print, format from Emacs shell -@cindex Format, print from Emacs shell -@cindex Shell, format, print from -@cindex Emacs shell, format, print from -@cindex GNU Emacs shell, format, print from - -You can give formatting and printing commands from a shell within GNU -Emacs. To create a shell within Emacs, type @kbd{M-x shell}. In this -shell, you can format and print the document. @xref{Shell Format & Print, , -How to Format and Print Using Shell Commands}, for details.@refill - -You can switch to and from the shell buffer while @code{tex} is -running and do other editing. If you are formatting a long document -on a slow machine, this can be very convenient.@refill - -You can also use @code{texi2dvi} from an Emacs shell. For example, -here is how to use @code{texi2dvi} to format and print @cite{Using and -Porting GNU CC} from a shell within Emacs (where @samp{%} is the shell -prompt):@refill - -@example -@group -% texi2dvi gcc.texinfo -% lpr -d gcc.dvi -@end group -@end example -@ifinfo - -@xref{Texinfo Mode Printing}, for more information about formatting -and printing in Texinfo mode.@refill -@end ifinfo - -@node Texinfo Mode Printing, Compile-Command, Within Emacs, Format/Print Hardcopy -@section Formatting and Printing in Texinfo Mode -@cindex Region printing in Texinfo mode -@cindex Format and print in Texinfo mode -@cindex Print and format in Texinfo mode - -Texinfo mode provides several predefined key commands for @TeX{} -formatting and printing. These include commands for sorting indices, -looking at the printer queue, killing the formatting job, and -recentering the display of the buffer in which the operations -occur.@refill - -@table @kbd -@item C-c C-t C-r -@itemx M-x texinfo-tex-region -Run @TeX{} on the current region.@refill - -@item C-c C-t C-b -@itemx M-x texinfo-tex-buffer -Run @TeX{} on the current buffer.@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -@item C-c C-t C-i -@itemx M-x texinfo-texindex -Sort the indices of a Texinfo file that have been formatted with -@code{texinfo-tex-region} or @code{texinfo-tex-buffer}.@refill - -@item C-c C-t C-p -@itemx M-x texinfo-tex-print -Print a @sc{dvi} file that was made with @code{texinfo-tex-region} or -@code{texinfo-tex-buffer}.@refill - -@item C-c C-t C-q -@itemx M-x texinfo-show-tex-print-queue -Show the print queue.@refill - -@item C-c C-t C-d -@itemx M-x texinfo-delete-from-tex-print-queue -Delete a job from the print queue; you will be prompted for the job -number shown by a preceding @kbd{C-c C-t C-q} command -(@code{texinfo-show-tex-print-queue}).@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -@item C-c C-t C-k -@itemx M-x texinfo-kill-tex-job -Kill either the currently running @TeX{} job that has been started by -@code{texinfo-tex-region} or @code{texinfo-tex-buffer}, or any other -process running in the Texinfo shell buffer.@refill - -@item C-c C-t C-x -@itemx M-x texinfo-quit-tex-job -Quit a @TeX{} formatting job that has stopped because of an error by -sending an @key{x} to it. When you do this, @TeX{} preserves a record -of what it did in a @file{.log} file.@refill - -@item C-c C-t C-l -@itemx M-x texinfo-recenter-tex-output-buffer -Redisplay the shell buffer in which the @TeX{} printing and formatting -commands are run to show its most recent output.@refill -@end table - -Thus, the usual sequence of commands for formatting a buffer is as -follows (with comments to the right):@refill - -@example -@group -C-c C-t C-b @r{Run @TeX{} on the buffer.} -C-c C-t C-i @r{Sort the indices.} -C-c C-t C-b @r{Rerun @TeX{} to regenerate indices.} -C-c C-t C-p @r{Print the @sc{dvi} file.} -C-c C-t C-q @r{Display the printer queue.} -@end group -@end example - -The Texinfo mode @TeX{} formatting commands start a subshell in Emacs -called the @file{*texinfo-tex-shell*}. The @code{texinfo-tex-command}, -@code{texinfo-texindex-command}, and @code{tex-dvi-print-command} -commands are all run in this shell. - -You can watch the commands operate in the @samp{*texinfo-tex-shell*} buffer, -and you can switch to and from and use the @samp{*texinfo-tex-shell*} buffer -as you would any other shell buffer.@refill - -@need 1500 -The formatting and print commands depend on the values of several variables. -The default values are:@refill - -@sp 1 -@example -@group - @r{Variable} @r{Default value} - -texinfo-tex-command "tex" -texinfo-texindex-command "texindex" -texinfo-tex-shell-cd-command "cd" -texinfo-tex-dvi-print-command "lpr -d" -texinfo-show-tex-queue-command "lpq" -texinfo-delete-from-print-queue-command "lprm" -texinfo-start-of-header "%**start" -texinfo-end-of-header "%**end" -texinfo-tex-trailer "@@bye" -@end group -@end example - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -The default values of both the @code{texinfo-tex-command} and the -@code{texinfo-texindex-command} variables are set in the @file{texnfo-tex.el} -file.@refill - -You can change the values of these variables with the @kbd{M-x -edit-options} command (@pxref{Edit Options, , Editing Variable Values, -emacs, The GNU Emacs Manual}), with the @kbd{M-x set-variable} command -(@pxref{Examining, , Examining and Setting Variables, emacs, The GNU -Emacs Manual}), or with your @file{.emacs} initialization file -(@pxref{Init File, , , emacs, The GNU Emacs Manual}).@refill - -@node Compile-Command, Requirements Summary, Texinfo Mode Printing, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Using the Local Variables List -@cindex Local variables -@cindex Compile command for formatting -@cindex Format with the compile command - -Yet another way to apply the @TeX{} formatting command to a Texinfo -file is to put that command in a @dfn{local variables list} at the end -of the Texinfo file. You can then specify the @TeX{} formatting -command as a @code{compile-command} and have Emacs run the @TeX{} -formatting command by typing @kbd{M-x compile}. This creates a -special shell called the @samp{*compilation buffer*} in which Emacs -runs the compile command. For example, at the end of the -@file{gdb.texinfo} file, after the @code{@@bye}, you would put the -following:@refill - -@example -@@c Local Variables: -@@c compile-command: "tex gdb.texinfo" -@@c End: -@end example - -@noindent -This technique is most often used by programmers who also compile programs -this way; see @ref{Compilation, , , emacs, The GNU Emacs Manual}.@refill - -@node Requirements Summary, Preparing for TeX, Compile-Command, Format/Print Hardcopy -@comment node-name, next, previous, up -@section @TeX{} Formatting Requirements Summary -@cindex Requirements for formatting -@cindex Formatting requirements - -Every Texinfo file that is to be input to @TeX{} must begin with a -@code{\input} command and contain an @code{@@settitle} command:@refill - -@example -\input texinfo -@@settitle @var{name-of-manual} -@end example - -@noindent -The first command instructs @TeX{} to load the macros it needs to -process a Texinfo file and the second command specifies the title of -printed manual.@refill - -@need 1000 -Every Texinfo file must end with a line that terminates @TeX{} -processing and forces out unfinished pages:@refill - -@example -@@bye -@end example - -Strictly speaking, these three lines are all a Texinfo file needs for -@TeX{}, besides the body. (The @code{@@setfilename} line is the only -line that a Texinfo file needs for Info formatting.)@refill - -Usually, the file's first line contains an @samp{@@c -*-texinfo-*-} -comment that causes Emacs to switch to Texinfo mode when you edit the -file. In addition, the beginning usually includes an -@code{@@setfilename} for Info formatting, an @code{@@setchapternewpage} -command, a title page, a copyright page, and permissions. Besides an -@code{@@bye}, the end of a file usually includes indices and a table of -contents.@refill - -@iftex -For more information, see -@ref{setchapternewpage, , @code{@@setchapternewpage}}, -@ref{Headings, ,Page Headings}, -@ref{Titlepage & Copyright Page}, -@ref{Printing Indices & Menus}, and -@ref{Contents}. -@end iftex -@noindent -@ifinfo -For more information, see@* -@ref{setchapternewpage, , @code{@@setchapternewpage}},@* -@ref{Headings, ,Page Headings},@* -@ref{Titlepage & Copyright Page},@* -@ref{Printing Indices & Menus}, and@* -@ref{Contents}. -@end ifinfo - -@node Preparing for TeX, Overfull hboxes, Requirements Summary, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Preparing to Use @TeX{} -@cindex Preparing to use @TeX{} -@cindex @TeX{} input initialization -@cindex @code{TEXINPUTS} environment variable -@vindex TEXINPUTS -@cindex @b{.profile} initialization file -@cindex @b{.cshrc} initialization file -@cindex Initialization file for @TeX{} input - -@TeX{} needs to know where to find the @file{texinfo.tex} file -that you have told it to input with the @samp{\input texinfo} command -at the beginning of the first line. The @file{texinfo.tex} file tells -@TeX{} how to handle @@-commands. (@file{texinfo.tex} is -included in the standard GNU distributions.)@refill - -Usually, the @file{texinfo.tex} file is put in the default directory -that contains @TeX{} macros (the @file{/usr/lib/tex/macros} -directory) when GNU Emacs or other GNU software is installed. -In this case, @TeX{} will -find the file and you do not need to do anything special. -Alternatively, you can put @file{texinfo.tex} in the directory in -which the Texinfo source file is located, and @TeX{} will find it -there.@refill - -However, you may want to specify the location of the @code{\input} file -yourself. One way to do this is to write the complete path for the file -after the @code{\input} command. Another way is to set the -@code{TEXINPUTS} environment variable in your @file{.cshrc} or -@file{.profile} file. The @code{TEXINPUTS} environment variable will tell -@TeX{} where to find the @file{texinfo.tex} file and any other file that -you might want @TeX{} to use.@refill - -Whether you use a @file{.cshrc} or @file{.profile} file depends on -whether you use @code{csh}, @code{sh}, or @code{bash} for your shell -command interpreter. When you use @code{csh}, it looks to the -@file{.cshrc} file for initialization information, and when you use -@code{sh} or @code{bash}, it looks to the @file{.profile} file.@refill - -@need 1000 -In a @file{.cshrc} file, you could use the following @code{csh} command -sequence:@refill - -@example -setenv TEXINPUTS .:/usr/me/mylib:/usr/lib/tex/macros -@end example - -@need 1000 -In a @file{.profile} file, you could use the following @code{sh} command -sequence: - -@example -@group -TEXINPUTS=.:/usr/me/mylib:/usr/lib/tex/macros -export TEXINPUTS -@end group -@end example - -@noindent -This would cause @TeX{} to look for @file{\input} file first in the current -directory, indicated by the @samp{.}, then in a hypothetical user's -@file{me/mylib} directory, and finally in the system library.@refill - -@node Overfull hboxes, smallbook, Preparing for TeX, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Overfull ``hboxes'' -@cindex Overfull @samp{hboxes} -@cindex @samp{hboxes}, overfull -@cindex Final output - -@TeX{} is sometimes unable to typeset a line without extending it into -the right margin. This can occur when @TeX{} comes upon what it -interprets as a long word that it cannot hyphenate, such as an -electronic mail network address or a very long title. When this -happens, @TeX{} prints an error message like this:@refill - -@example -Overfull \hbox (20.76302pt too wide) -@end example - -@noindent -(In @TeX{}, lines are in ``horizontal boxes'', hence the term, ``hbox''. -The backslash, @samp{\}, is the @TeX{} equivalent of @samp{@@}.)@refill - -@TeX{} also provides the line number in the Texinfo source file and -the text of the offending line, which is marked at all the places that -@TeX{} knows how to hyphenate words. -@xref{Debugging with TeX, , Catching Errors with @TeX{} Formatting}, -for more information about typesetting errors.@refill - -If the Texinfo file has an overfull hbox, you can rewrite the sentence -so the overfull hbox does not occur, or you can decide to leave it. A -small excursion into the right margin often does not matter and may not -even be noticeable.@refill - -@cindex Black rectangle in hardcopy -@cindex Rectangle, ugly, black in hardcopy -However, unless told otherwise, @TeX{} will print a large, ugly, black -rectangle beside the line that contains the overful hbox. This is so -you will notice the location of the problem if you are correcting a -draft.@refill - -@need 1000 -@findex finalout -To prevent such a monstrosity from marring your final printout, write -the following in the beginning of the Texinfo file on a line of its own, -before the @code{@@titlepage} command:@refill - -@example -@@finalout -@end example - -@node smallbook, A4 Paper, Overfull hboxes, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Printing ``Small'' Books -@findex smallbook -@cindex Small book size -@cindex Book, printing small -@cindex Page sizes for books -@cindex Size of printed book - -By default, @TeX{} typesets pages for printing in an 8.5 by 11 inch -format. However, you can direct @TeX{} to typeset a document in a 7 by -9.25 inch format that is suitable for bound books by inserting the -following command on a line by itself at the beginning of the Texinfo -file, before the title page:@refill - -@example -@@smallbook -@end example - -@noindent -(Since regular sized books are often about 7 by 9.25 inches, this -command might better have been called the @code{@@regularbooksize} -command, but it came to be called the @code{@@smallbook} command by -comparison to the 8.5 by 11 inch format.)@refill - -If you write the @code{@@smallbook} command between the -start-of-header and end-of-header lines, the Texinfo mode @TeX{} -region formatting command, @code{texinfo-tex-region}, will format the -region in ``small'' book size (@pxref{Start of Header}).@refill - -The Free Software Foundation distributes printed copies of @cite{The GNU -Emacs Manual} and other manuals in the ``small'' book size. -@xref{smallexample & smalllisp, , @code{@@smallexample} and -@code{@@smalllisp}}, for information about commands that make it easier -to produce examples for a smaller manual.@refill - -@node A4 Paper, Cropmarks and Magnification, smallbook, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Printing on A4 Paper -@cindex A4 paper, printing on -@cindex Paper size, European A4 -@cindex European A4 paper -@findex afourpaper - -You can tell @TeX{} to typeset a document for printing on European size -A4 paper with the @code{@@afourpaper} command. Write the command on a -line by itself between @code{@@iftex} and @code{@@end iftex} lines near -the beginning of the Texinfo file, before the title page:@refill - -For example, this is how you would write the header for this manual:@refill - -@example -@group -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename texinfo -@@settitle Texinfo -@@syncodeindex vr fn -@@iftex -@@afourpaper -@@end iftex -@@c %**end of header -@end group -@end example - -@node Cropmarks and Magnification, , A4 Paper, Format/Print Hardcopy -@comment node-name, next, previous, up -@section Cropmarks and Magnification - -@findex cropmarks -@cindex Cropmarks for printing -@cindex Printing cropmarks -You can attempt to direct @TeX{} to print cropmarks at the corners of -pages with the @code{@@cropmarks} command. Write the @code{@@cropmarks} -command on a line by itself between @code{@@iftex} and @code{@@end -iftex} lines near the beginning of the Texinfo file, before the title -page, like this:@refill - -@example -@group -@@iftex -@@cropmarks -@@end iftex -@end group -@end example - -This command is mainly for printers that typeset several pages on one -sheet of film; but you can attempt to use it to mark the corners of a -book set to 7 by 9.25 inches with the @code{@@smallbook} command. -(Printers will not produce cropmarks for regular sized output that is -printed on regular sized paper.) Since different printing machines work -in different ways, you should explore the use of this command with a -spirit of adventure. You may have to redefine the command in the -@file{texinfo.tex} definitions file.@refill - -@findex mag @r{(@TeX{} command)} -@cindex Magnified printing -@cindex Larger or smaller pages -You can attempt to direct @TeX{} to typeset pages larger or smaller than -usual with the @code{\mag} @TeX{} command. Everything that is typeset -is scaled proportionally larger or smaller. (@code{\mag} stands for -``magnification''.) This is @emph{not} a Texinfo @@-command, but is a -Plain@TeX{} command that is prefixed with a backslash. You have to -write this command between @code{@@tex} and @code{@@end tex} -(@pxref{Using Ordinary TeX Commands, , Using Ordinary @TeX{} -Commands}).@refill - -Follow the @code{\mag} command with an @samp{=} and then a number that -is 1000 times the magnification you desire. For example, to print pages -at 1.2 normal size, write the following near the beginning of the -Texinfo file, before the title page:@refill - -@example -@group -@@tex -\mag=1200 -@@end tex -@end group -@end example - -With some printing technologies, you can print normal-sized copies that -look better than usual by using a larger-than-normal master.@refill - -Depending on your system, @code{\mag} may not work or may work only at -certain magnifications. Be prepared to experiment.@refill - -@node Create an Info File, Install an Info File, Format/Print Hardcopy, Top -@comment node-name, next, previous, up -@chapter Creating an Info File -@cindex Creating an Info file -@cindex Info, creating an on-line file -@cindex Formatting a file for Info - -@code{makeinfo} is a utility that converts a Texinfo file into an Info -file; @code{texinfo-format-region} and @code{texinfo-format-buffer} are -GNU Emacs functions that do the same.@refill - -A Texinfo file must possess an @code{@@setfilename} line near its -beginning, otherwise the Info formatting commands will fail.@refill - -For information on installing the Info file in the Info system, see -@ref{Install an Info File}.@refill - -@menu -* makeinfo advantages:: @code{makeinfo} provides better error checking. -* Invoking makeinfo:: How to run @code{makeinfo} from a shell. -* makeinfo options:: Specify fill-column and other options. -* Pointer Validation:: How to check that pointers point somewhere. -* makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. -* texinfo-format commands:: Two Info formatting commands written - in Emacs Lisp are an alternative - to @code{makeinfo}. -* Batch Formatting:: How to format for Info in Emacs Batch mode. -* Tag and Split Files:: How tagged and split files help Info - to run better. -@end menu - -@node makeinfo advantages, Invoking makeinfo, , Create an Info File -@ifinfo -@heading @code{makeinfo} Preferred -@end ifinfo - -The @code{makeinfo} utility creates an Info file from a Texinfo source -file more quickly than either of the Emacs formatting commands and -provides better error messages. We recommend it. @code{makeinfo} is a -C program that is independent of Emacs. You do not need to run Emacs to -use @code{makeinfo}, which means you can use @code{makeinfo} on machines -that are too small to run Emacs. You can run @code{makeinfo} in -any one of three ways: from an operating system shell, from a shell -inside Emacs, or by typing a key command in Texinfo mode in Emacs. -@refill - -The @code{texinfo-format-region} and the @code{texinfo-format-buffer} -commands are useful if you cannot run @code{makeinfo}. Also, in some -circumstances, they format short regions or buffers more quickly than -@code{makeinfo}.@refill - -@node Invoking makeinfo, makeinfo options, makeinfo advantages, Create an Info File -@section Invoking @code{makeinfo} from a Shell - -To create an Info file from a Texinfo file, type @code{makeinfo} -followed by the name of the Texinfo file. Thus, to create the Info -file for Bison, type the following at the shell prompt (where @samp{%} -is the prompt):@refill - -@example -% makeinfo bison.texinfo -@end example - -(You can run a shell inside Emacs by typing @kbd{M-x -shell}.)@refill - -@ifinfo -Sometimes you will want to specify options. For example, if you wish -to discover which version of @code{makeinfo} you are using, -type:@refill - -@example -% makeinfo --version -@end example - -@xref{makeinfo options}, for more information. -@end ifinfo - -@node makeinfo options, Pointer Validation, Invoking makeinfo, Create an Info File -@comment node-name, next, previous, up -@section Options for @code{makeinfo} -@cindex @code{makeinfo} options -@cindex Options for @code{makeinfo} - -The @code{makeinfo} command takes a number of options. Most often, -options are used to set the value of the fill column and specify the -footnote style. Each command line option is a word preceded by -@samp{--}@footnote{@samp{--} has replaced @samp{+}, the old introductory -character, to maintain POSIX.2 compatibility without losing long-named -options.} or a letter preceded by @samp{-}. You can use abbreviations -for the option names as long as they are unique.@refill - -For example, you could use the following command to create an Info -file for @file{bison.texinfo} in which each line is filled to only 68 -columns (where @samp{%} is the prompt):@refill - -@example -% makeinfo --fill-column=68 bison.texinfo -@end example - -You can write two or more options in sequence, like this:@refill - -@example -% makeinfo --no-split --fill-column=70 @dots{} -@end example - -@noindent -This would keep the Info file together as one possibly very long -file and would also set the fill column to 70.@refill - -@iftex -If you wish to discover which version of @code{makeinfo} -you are using, type:@refill - -@example -% makeinfo --version -@end example -@end iftex - -The options are:@refill - -@need 100 -@table @code -@item -D @var{var} -Cause @var{var} to be defined. This is equivalent to -@code{@@set @var{var}} in the Texinfo file. - -@need 150 -@item --error-limit @var{limit} -Set the maximum number of errors that @code{makeinfo} will report -before exiting (on the assumption that continuing would be useless). -The default number of errors that can be reported before -@code{makeinfo} gives up is 100.@refill - -@need 150 -@item --fill-column @var{width} -Specify the maximum number of columns in a line; this is the right-hand -edge of a line. Paragraphs that are filled will be filled to this -width. (Filling is the process of breaking up and connecting lines so -that lines are the same length as or shorter than the number specified -as the fill column. Lines are broken between words.) The default value -for @code{fill-column} is 72. -@refill - -@item --footnote-style @var{style} -Set the footnote style to @var{style}, either @samp{end} for the end -node style or @samp{separate} for the separate node style. The value -set by this option overrides the value set in a Texinfo file by an -@code{@@footnotestyle} command. When the footnote style is -@samp{separate}, @code{makeinfo} makes a new node containing the -footnotes found in the current node. When the footnote style is -@samp{end}, @code{makeinfo} places the footnote references at the end -of the current node.@refill - -@need 150 -@item -I @var{dir} -Add @code{dir} to the directory search list for finding files that are -included using the @code{@@include} command. By default, -@code{makeinfo} searches only the current directory. - -@need 150 -@item --no-headers -Do not include menus or node lines in the output. This results in an -@sc{ascii} file that you cannot read in Info since it does not contain -the requisite nodes or menus; but you can print such a file in a -single, typewriter-like font and produce acceptable output. - -@need 150 -@item --no-split -Suppress the splitting stage of @code{makeinfo}. Normally, large -output files (where the size is greater than 70k bytes) are split into -smaller subfiles, each one approximately 50k bytes. If you specify -@samp{--no-split}, @code{makeinfo} will not split up the output -file.@refill - -@need 100 -@item --no-pointer-validate -@item --no-validate -Suppress the pointer-validation phase of @code{makeinfo}. Normally, -after a Texinfo file is processed, some consistency checks are made to -ensure that cross references can be resolved, etc. -@xref{Pointer Validation}.@refill - -@need 150 -@item --no-warn -Suppress the output of warning messages. This does @emph{not} -suppress the output of error messages, only warnings. You might -want this if the file you are creating has examples of Texinfo cross -references within it, and the nodes that are referenced do not actually -exist.@refill - -@item --no-number-footnotes -Supress automatic footnote numbering. By default, @code{makeinfo} -numbers each footnote sequentially in a single node, resetting the -current footnote number to 1 at the start of each node. - -@need 150 -@item --output @var{file} -@itemx -o @var{file} -Specify that the output should be directed to @var{file} and not to the -file name specified in the @code{@@setfilename} command found in the Texinfo -source. @var{file} can be the special token @samp{-}, which specifies -standard output. - -@need 150 -@item --paragraph-indent @var{indent} -Set the paragraph indentation style to @var{indent}. The value set by -this option overrides the value set in a Texinfo file by an -@code{@@paragraphindent} command. The value of @var{indent} is -interpreted as follows:@refill - -@itemize @bullet -@item -If the value of @var{indent} is @samp{asis}, do not change the -existing indentation at the starts of paragraphs.@refill - -@item -If the value of @var{indent} is zero, delete any existing -indentation.@refill - -@item -If the value of @var{indent} is greater than zero, indent each -paragraph by that number of spaces.@refill -@end itemize - -@need 100 -@item --reference-limit @var{limit} -Set the value of the number of references to a node that -@code{makeinfo} will make without reporting a warning. If a node has more -than this number of references in it, @code{makeinfo} will make the -references but also report a warning.@refill - -@need 150 -@item -U @var{var} -Cause @var{var} to be undefined. This is equivalent to -@code{@@clear @var{var}} in the Texinfo file. - -@need 100 -@item --verbose -Cause @code{makeinfo} to display messages saying what it is doing. -Normally, @code{makeinfo} only outputs messages if there are errors or -warnings.@refill - -@need 100 -@item --version -Report the version number of this copy of @code{makeinfo}.@refill -@end table - -@node Pointer Validation, makeinfo in Emacs, makeinfo options, Create an Info File -@section Pointer Validation -@cindex Pointer validation with @code{makeinfo} -@cindex Validation of pointers - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -@code{makeinfo} will check the validity of the final Info file unless -you suppress pointer-validation by using the -@samp{--no-pointer-validation} option. Mostly, this means ensuring -that nodes you have referenced really exist. Here is a complete list -of what is checked:@refill - -@enumerate -@item -If a `Next', `Previous', or `Up' node reference is a reference to a -node in the current file and is not an external reference such as to -@file{(dir)}, then the referenced node must exist.@refill - -@item -In every node, if the `Previous' node is different from the `Up' node, -then the `Previous' node must also be pointed to by a `Next' node.@refill - -@item -Every node except the `Top' node must have an `Up' pointer.@refill - -@item -The node referenced by an `Up' pointer must contain a reference to the -current node in some manner other than through a `Next' reference. -This includes menu entries and cross references.@refill - -@item -If the `Next' reference of a node is not the same as the `Next' reference -of the `Up' reference, then the node referenced by the `Next' pointer -must have a `Previous' pointer that points back to the current node. -This rule allows the last node in a section to point to the first node -of the next chapter.@refill -@end enumerate - -@node makeinfo in Emacs, texinfo-format commands, Pointer Validation, Create an Info File -@section Running @code{makeinfo} inside Emacs -@cindex Running @code{makeinfo} in Emacs -@cindex @code{makeinfo} inside Emacs -@cindex Shell, running @code{makeinfo} in - -You can run @code{makeinfo} in GNU Emacs Texinfo mode by using either the -@code{makeinfo-region} or the @code{makeinfo-buffer} commands. In -Texinfo mode, the commands are bound to @kbd{C-c C-m C-r} and @kbd{C-c -C-m C-b} by default.@refill - -@table @kbd -@item C-c C-m C-r -@itemx M-x makeinfo-region -Format the current region for Info.@refill -@findex makeinfo-region - -@item C-c C-m C-b -@itemx M-x makeinfo-buffer -Format the current buffer for Info.@refill -@findex makeinfo-buffer -@end table - -When you invoke either @code{makeinfo-region} or -@code{makeinfo-buffer}, Emacs prompts for a file name, offering the -name of the visited file as the default. You can edit the default -file name in the minibuffer if you wish, before typing @key{RET} to -start the @code{makeinfo} process.@refill - -The Emacs @code{makeinfo-region} and @code{makeinfo-buffer} commands -run the @code{makeinfo} program in a temporary shell buffer. If -@code{makeinfo} finds any errors, Emacs displays the error messages in -the temporary buffer.@refill - -@cindex Errors, parsing -@cindex Parsing errors -@findex next-error -You can parse the error messages by typing @kbd{C-x `} -(@code{next-error}). This causes Emacs to go to and position the -cursor on the line in the Texinfo source that @code{makeinfo} thinks -caused the error. @xref{Compilation, , Running @code{make} or -Compilers Generally, emacs, The GNU Emacs Manual}, for more -information about using the @code{next-error} command.@refill - -In addition, you can kill the shell in which the @code{makeinfo} -command is running or make the shell buffer display its most recent -output.@refill - - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -@table @kbd -@item C-c C-m C-k -@itemx M-x makeinfo-kill-job -@findex makeinfo-kill-job -Kill the currently running job created by -@code{makeinfo-region} or @code{makeinfo-buffer}.@refill - -@item C-c C-m C-l -@itemx M-x makeinfo-recenter-output-buffer -@findex makeinfo-recenter-output-buffer -Redisplay the @code{makeinfo} shell buffer to display its most recent -output.@refill -@end table - -@noindent -(Note that the parallel commands for killing and recentering a @TeX{} -job are @kbd{C-c C-t C-k} and @kbd{C-c C-t C-l}. @xref{Texinfo Mode -Printing}.)@refill - -You can specify options for @code{makeinfo} by setting the -@code{makeinfo-options} variable with either the @kbd{M-x -edit-options} or the @kbd{M-x set-variable} command, or by setting the -variable in your @file{.emacs} initialization file.@refill - -For example, you could write the following in your @file{.emacs} file:@refill - -@example -@group -(setq makeinfo-options - "--paragraph-indent=0 --no-split - --fill-column=70 --verbose") -@end group -@end example - -@c If you write these three cross references using xref, you see -@c three references to the same named manual, which looks strange. -@iftex -For more information, see @ref{makeinfo options, , Options for -@code{makeinfo}}, as well as ``Editing Variable Values,''``Examining and -Setting Variables,'' and ``Init File'' in the @cite{The GNU Emacs -Manual}. -@end iftex -@noindent -@ifinfo -For more information, see@* -@ref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual},@* -@ref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual},@* -@ref{Init File, , , emacs, The GNU Emacs Manual}, and@* -@ref{makeinfo options, , Options for @code{makeinfo}}. -@end ifinfo - -@node texinfo-format commands, Batch Formatting, makeinfo in Emacs, Create an Info File -@comment node-name, next, previous, up -@section The @code{texinfo-format@dots{}} Commands -@findex texinfo-format-region -@findex texinfo-format-buffer - -In GNU Emacs in Texinfo mode, you can format part or all of a Texinfo -file with the @code{texinfo-format-region} command. This formats the -current region and displays the formatted text in a temporary buffer -called @samp{*Info Region*}.@refill - -Similarly, you can format a buffer with the -@code{texinfo-format-buffer} command. This command creates a new -buffer and generates the Info file in it. Typing @kbd{C-x C-s} will -save the Info file under the name specified by the -@code{@@setfilename} line which must be near the beginning of the -Texinfo file.@refill - -@table @kbd -@item C-c C-e C-r -@itemx @code{texinfo-format-region} -Format the current region for Info. -@findex texinfo-format-region - -@item C-c C-e C-b -@itemx @code{texinfo-format-buffer} -Format the current buffer for Info. -@findex texinfo-format-buffer -@end table - -The @code{texinfo-format-region} and @code{texinfo-format-buffer} -commands provide you with some error checking, and other functions can -provide you with further help in finding formatting errors. These -procedures are described in an appendix; see @ref{Catching Mistakes}. -However, the @code{makeinfo} program is often faster and -provides better error checking (@pxref{makeinfo in Emacs}).@refill - -@node Batch Formatting, Tag and Split Files, texinfo-format commands, Create an Info File -@comment node-name, next, previous, up -@section Batch Formatting -@cindex Batch formatting for Info -@cindex Info batch formatting - -You can format Texinfo files for Info using @code{batch-texinfo-format} -and Emacs Batch mode. You can run Emacs in Batch mode from any shell, -including a shell inside of Emacs. (@xref{Command Switches, , Command -Line Switches and Arguments, emacs, The GNU Emacs Manual}.)@refill - -Here is the command to format all the files that end in @file{.texinfo} -in the current directory (where @samp{%} is the shell prompt):@refill - -@example -% emacs -batch -funcall batch-texinfo-format *.texinfo -@end example - -@noindent -Emacs processes all the files listed on the command line, even if an -error occurs while attempting to format some of them.@refill - -Run @code{batch-texinfo-format} only with Emacs in Batch mode as shown; -it is not interactive. It kills the Batch mode Emacs on completion.@refill - -@code{batch-texinfo-format} is convenient if you lack @code{makeinfo} -and want to format several Texinfo files at once. When you use Batch -mode, you create a new Emacs process. This frees your current Emacs, so -you can continue working in it. (When you run -@code{texinfo-format-region} or @code{texinfo-format-buffer}, you cannot -use that Emacs for anything else until the command finishes.)@refill - -@node Tag and Split Files, , Batch Formatting, Create an Info File -@comment node-name, next, previous, up -@section Tag Files and Split Files -@cindex Making a tag table automatically -@cindex Tag table, making automatically - -If a Texinfo file has more than 30,000 bytes, -@code{texinfo-format-buffer} automatically creates a tag table -for its Info file; @code{makeinfo} always creates a tag table. With -a @dfn{tag table}, Info can jump to new nodes more quickly than it can -otherwise.@refill - -@cindex Indirect subfiles -In addition, if the Texinfo file contains more than about 70,000 -bytes, @code{texinfo-format-buffer} and @code{makeinfo} split the -large Info file into shorter @dfn{indirect} subfiles of about 50,000 -bytes each. Big files are split into smaller files so that Emacs does -not need to make a large buffer to hold the whole of a large Info -file; instead, Emacs allocates just enough memory for the small, split -off file that is needed at the time. This way, Emacs avoids wasting -memory when you run Info. (Before splitting was implemented, Info -files were always kept short and @dfn{include files} were designed as -a way to create a single, large printed manual out of the smaller Info -files. @xref{Include Files}, for more information. Include files are -still used for very large documents, such as @cite{The Emacs Lisp -Reference Manual}, in which each chapter is a separate file.)@refill - -When a file is split, Info itself makes use of a shortened version of -the original file that contains just the tag table and references to -the files that were split off. The split off files are called -@dfn{indirect} files.@refill - -The split off files have names that are created by appending @w{@samp{-1}}, -@w{@samp{-2}}, @w{@samp{-3}} and so on to the file name specified by the -@code{@@setfilename} command. The shortened version of the original file -continues to have the name specified by @code{@@setfilename}.@refill - -At one stage in writing this document, for example, the Info file was saved -as @file{test-texinfo} and that file looked like this:@refill - -@example -@group -Info file: test-texinfo, -*-Text-*- -produced by texinfo-format-buffer -from file: new-texinfo-manual.texinfo - -^_ -Indirect: -test-texinfo-1: 102 -test-texinfo-2: 50422 -test-texinfo-3: 101300 -^_^L -Tag table: -(Indirect) -Node: overview^?104 -Node: info file^?1271 -Node: printed manual^?4853 -Node: conventions^?6855 -@dots{} -@end group -@end example - -@noindent -(But @file{test-texinfo} had far more nodes than are shown here.) Each of -the split off, indirect files, @file{test-texinfo-1}, -@file{test-texinfo-2}, and @file{test-texinfo-3}, is listed in this file -after the line that says @samp{Indirect:}. The tag table is listed after -the line that says @samp{Tag table:}. @refill - -In the list of indirect files, the number following the file name -records the cumulative number of bytes in the preceding indirect files, -not counting the file list itself, the tag table, or the permissions -text in each file. In the tag table, the number following the node name -records the location of the beginning of the node, in bytes from the -beginning.@refill - -If you are using @code{texinfo-format-buffer} to create Info files, -you may want to run the @code{Info-validate} command. (The -@code{makeinfo} command does such a good job on its own, you do not -need @code{Info-validate}.) However, you cannot run the @kbd{M-x -Info-validate} node-checking command on indirect files. For -information on how to prevent files from being split and how to -validate the structure of the nodes, see @ref{Using -Info-validate}.@refill - -@node Install an Info File, Command List, Create an Info File, Top -@comment node-name, next, previous, up -@chapter Installing an Info File -@cindex Installing an Info file -@cindex Info file installation -@cindex @file{dir} directory for Info installation - -Info files are usually kept in the @file{info} -directory. (You can find the location of this directory within Emacs -by typing @kbd{C-h i} to enter Info and then typing @kbd{C-x C-f} to -see the full pathname to the @file{info} directory.) - -@menu -* Directory file:: The top level menu for all Info files. -* New Info File:: Listing a new info file. -* Other Info Directories:: How to specify Info files that are - located in other directories. -@end menu - -@node Directory file, New Info File, , Install an Info File -@ifinfo -@heading The @file{dir} File -@end ifinfo - -For Info to work, the @file{info} directory must contain a file that -serves as a top level directory for the Info system. By convention, -this file is called @file{dir}. The @file{dir} file is itself an Info -file. It contains the top level menu for all the Info files in the -system. The menu looks like this:@refill - -@example -* Menu: - -* Info: (info). Documentation browsing system. -* Emacs: (emacs). The extensible, self-documenting - text editor. -* Texinfo: (texinfo). With one source file, make - either a printed manual using - TeX or an Info file. -@dots{} -@end example - -Each of these menu entries points to the `Top' node of the Info file -that is named in parentheses. (The menu entry does not need to -specify the `Top' node, since Info goes to the `Top' node if no node -name is mentioned. @xref{Other Info Files, , Nodes in Other Info -Files}.)@refill - -Thus, the @samp{Info} entry points to the `Top' node of the -@file{info} file and the @samp{Emacs} entry points to the `Top' node -of the @file{emacs} file.@refill - -In each of the Info files, the `Up' pointer of the `Top' node refers -back to the @code{dir} file. For example, the line for the `Top' -node of the Emacs manual looks like this in Info:@refill - -@example -File: emacs Node: Top, Up: (DIR), Next: Distrib -@end example - -@noindent -(Note that in this case, the @file{dir} file name is written in upper -case letters---it can be written in either upper or lower case. Info -has a feature that it will change the case of the file name to lower -case if it cannot find the name as written.)@refill - -@c !!! Can any file name be written in upper or lower case, -@c or is dir a special case? -@c Yes, apparently so, at least with Gillespie's Info. --rjc 24mar92 -@c -@node New Info File, Other Info Directories, Directory file, Install an Info File -@section Listing a New Info File -@cindex Adding a new info file -@cindex Listing a new info file -@cindex New info file, listing it in @file{dir} file -@cindex Info file, listing new one -@cindex @file{dir} file listing - -To add a new Info file to your system, write a menu entry for it in the -menu in the @file{dir} file in the @file{info} directory. Also, move -the new Info file itself to the @file{info} directory. For example, if -you were adding documentation for GDB, you would write the following new -entry:@refill - -@example -* GDB: (gdb). The source-level C debugger. -@end example - -@noindent -The first part of the menu entry is the menu entry name, followed by a -colon. The second part is the name of the Info file, in parentheses, -followed by a period. The third part is the description.@refill - -Conventionally, the name of an Info file has a @file{.info} extension. -Thus, you might list the name of the file like this: - -@example -* GDB: (gdb.info). The source-level C debugger. -@end example - -@noindent -However, Info will look for a file with a @file{.info} extension if it -does not find the file under the name given in the menu. This means -that you can refer to the file @file{gdb.info} as @file{gdb}, as shown -in the first example. This looks better. - -@node Other Info Directories, , New Info File, Install an Info File -@comment node-name, next, previous, up -@section Info Files in Other Directories -@cindex Installing Info in another directory -@cindex Info installed in another directory -@cindex Another Info directory - -If an Info file is not in the @file{info} directory, there are two -ways to specify its location:@refill - -@itemize @bullet -@item -Write the pathname as the menu's second part, or;@refill - -@item -Specify the @file{info} directory name in an environment variable in -your @file{.profile} or @file{.cshrc} initialization file. (Only you -and others with the same environment variable will be able to find Info -files whose location is specified this way.)@refill -@end itemize - -For example, to reach a test file in the @file{~bob/manuals} -directory, you could add an entry like this to the menu in the -@file{dir} file:@refill - -@example -* Test: (~bob/manuals/info-test). Bob's own test file. -@end example - -@noindent -In this case, the absolute file name of the @file{info-test} file is -written as the second part of the menu entry.@refill - -@vindex INFOPATH -Alternatively, you can tell Info where to look by setting the -@code{INFOPATH} environment variable in your @file{.cshrc} or -@file{.profile} file.@refill - -If you use @code{sh} or @code{bash} for your shell command interpreter, -you must set the @code{INFOPATH} environment variable in the -@file{.profile} initialization file; but if you use @code{csh}, you must -set the variable in the @file{.cshrc} initialization file. The two -files require slightly different command formats.@refill - -@itemize @bullet -@item -In a @file{.cshrc} file, you could set the @code{INFOPATH} -variable as follows:@refill - -@smallexample -setenv INFOPATH .:~bob/manuals:/usr/local/emacs/info -@end smallexample - -@item -In a @file{.profile} file, you would achieve the same effect by -writing:@refill - -@smallexample -INFOPATH=.:~bob/manuals:/usr/local/emacs/info -export INFOPATH -@end smallexample -@end itemize - -@noindent -Either form would cause Info to look first in the current directory, -indicated by the @samp{.}, then in the @file{~bob/manuals} directory, -and finally in the @file{/usr/local/emacs/info} directory (which is -a common location for the standard Info directory).@refill - -@c ================ Appendix starts here ================ - -@node Command List, Tips, Install an Info File, Top -@appendix @@-Command List -@cindex Alphabetical @@-command list -@cindex List of @@-commands -@cindex @@-command list - -Here is an alphabetical list of the @@-commands in Texinfo. Square -brackets, @t{[}@w{ }@t{]}, indicate optional arguments; an ellipsis, -@samp{@dots{}}, indicates repeated text.@refill - -@sp 1 -@table @code -@item @@* -Force a line break. Do not end a paragraph that uses @code{@@*} with -an @code{@@refill} command. @xref{Line Breaks}.@refill - -@item @@. -Stands for a period that really does end a sentence (usually after an -end-of-sentence capital letter). @xref{Controlling Spacing}.@refill - -@item @@: -Indicate to @TeX{} that an immediately preceding period, question -mark, exclamation mark, or colon does not end a sentence. Prevent -@TeX{} from inserting extra whitespace as it does at the end of a -sentence. The command has no effect on the Info file output. -@xref{Controlling Spacing}.@refill - -@item @@@@ -Stands for @samp{@@}. @xref{Braces Atsigns Periods, , Inserting -@samp{@@}}.@refill - -@item @@@{ -Stands for a left-hand brace, @samp{@{}. -@xref{Braces Atsigns Periods, , Inserting @@ braces and periods}.@refill - -@item @@@} -Stands for a right-hand brace, @samp{@}}. -@xref{Braces Atsigns Periods, , Inserting @@ braces and periods}.@refill - -@item @@appendix @var{title} -Begin an appendix. The title appears in the table -of contents of a printed manual. In Info, the title is -underlined with asterisks. @xref{unnumbered & appendix, , The -@code{@@unnumbered} and @code{@@appendix} Commands}.@refill - -@item @@appendixsec @var{title} -@itemx @@appendixsection @var{title} -Begin an appendix section within an appendix. The section title appears -in the table of contents of a printed manual. In Info, the title is -underlined with equal signs. @code{@@appendixsection} is a longer -spelling of the @code{@@appendixsec} command. @xref{unnumberedsec -appendixsec heading, , Section Commands}.@refill - -@item @@appendixsubsec @var{title} -Begin an appendix subsection within an appendix. The title appears -in the table of contents of a printed manual. In Info, the title is -underlined with hyphens. @xref{unnumberedsubsec appendixsubsec -subheading, , Subsection Commands}.@refill - -@item @@appendixsubsubsec @var{title} -Begin an appendix subsubsection within a subappendix. The title -appears in the table of contents of a printed manual. In Info, the -title is underlined with periods. @xref{subsubsection,, The `subsub' -Commands}.@refill - -@item @@asis -Used following @code{@@table}, @code{@@ftable}, and @code{@@vtable} to -print the table's first column without highlighting (``as is''). -@xref{Two-column Tables, , Making a Two-column Table}.@refill - -@item @@author @var{author} -Typeset @var{author} flushleft and underline it. @xref{title -subtitle author, , The @code{@@title} and @code{@@author} -Commands}.@refill - -@item @@b@{@var{text}@} -Print @var{text} in @b{bold} font. No effect in Info. @xref{Fonts}.@refill - -@ignore -@item @@br -Force a paragraph break. If used within a line, follow @code{@@br} -with braces. @xref{br, , @code{@@br}}.@refill -@end ignore - -@item @@bullet@{@} -Generate a large round dot, or the closest possible -thing to one. @xref{bullet, , @code{@@bullet}}.@refill - -@item @@bye -Stop formatting a file. The formatters do not see the contents of a -file following an @code{@@bye} command. @xref{Ending a File}.@refill - -@item @@c @var{comment} -Begin a comment in Texinfo. The rest of the line does not appear in -either the Info file or the printed manual. A synonym for -@code{@@comment}. @xref{Conventions, , General Syntactic -Conventions}.@refill - -@item @@cartouche -Highlight an example or quotation by drawing a box with rounded -corners around it. Pair with @code{@@end cartouche}. No effect in -Info. @xref{cartouche, , Drawing Cartouches Around Examples}.)@refill - -@item @@center @var{line-of-text} -Center the line of text following the command. -@xref{titlefont center sp, , @code{@@center}}.@refill - -@item @@chapheading @var{title} -Print a chapter-like heading in the text, but not in the table of -contents of a printed manual. In Info, the title is underlined with -asterisks. @xref{majorheading & chapheading, , @code{@@majorheading} -and @code{@@chapheading}}.@refill - -@item @@chapter @var{title} -Begin a chapter. The chapter title appears in the table of -contents of a printed manual. In Info, the title is underlined with -asterisks. @xref{chapter, , @code{@@chapter}}.@refill - -@item @@cindex @var{entry} -Add @var{entry} to the index of concepts. @xref{Index Entries, , -Defining the Entries of an Index}.@refill - -@item @@cite@{@var{reference}@} -Highlight the name of a book or other reference that lacks a -companion Info file. @xref{cite, , @code{@@cite}}.@refill - -@item @@clear @var{flag} -Unset @var{flag}, preventing the Texinfo formatting commands from -formatting text between subsequent pairs of @code{@@ifset @var{flag}} -and @code{@@end ifset} commands, and preventing -@code{@@value@{@var{flag}@}} from expanding to the value to which -@var{flag} is set. -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@item @@code@{@var{sample-code}@} -Highlight text that is an expression, a syntactically complete token -of a program, or a program name. @xref{code, , @code{@@code}}.@refill - -@item @@comment @var{comment} -Begin a comment in Texinfo. The rest of the line does not appear in -either the Info file or the printed manual. A synonym for @code{@@c}. -@xref{Conventions, , General Syntactic Conventions}.@refill - -@item @@contents -Print a complete table of contents. Has no effect in Info, which uses -menus instead. @xref{Contents, , Generating a Table of -Contents}.@refill - -@item @@copyright@{@} -Generate a copyright symbol. @xref{copyright symbol, , -@code{@@copyright}}.@refill - -@ignore -@item @@ctrl@{@var{ctrl-char}@} -Describe an @sc{ascii} control character. Insert actual control character -into Info file. @xref{ctrl, , @code{@@ctrl}}.@refill -@end ignore - -@item @@defcodeindex @var{index-name} -Define a new index and its indexing command. Print entries in an -@code{@@code} font. @xref{New Indices, , Defining New -Indices}.@refill - -@item @@defcv @var{category} @var{class} @var{name} -Format a description for a variable associated with a class in -object-oriented programming. Takes three arguments: the category of -thing being defined, the class to which it belongs, and its name. -@xref{Definition Commands}.@refill - -@item @@deffn @var{category} @var{name} @var{arguments}@dots{} -Format a description for a function, interactive command, or similar -entity that may take arguments. @code{@@deffn} takes as arguments the -category of entity being described, the name of this particular -entity, and its arguments, if any. @xref{Definition Commands}.@refill - -@item @@defindex @var{index-name} -Define a new index and its indexing command. Print entries in a roman -font. @xref{New Indices, , Defining New Indices}.@refill - -@item @@defivar @var{class} @var{instance-variable-name} -Format a description for an instance variable in object-oriented -programming. The command is equivalent to @samp{@@defcv @{Instance -Variable@} @dots{}}. @xref{Definition Commands}.@refill - -@item @@defmac @var{macro-name} @var{arguments}@dots{} -Format a description for a macro. The command is equivalent to -@samp{@@deffn Macro @dots{}}. @xref{Definition Commands}.@refill - -@item @@defmethod @var{class} @var{method-name} @var{arguments}@dots{} -Format a description for a method in object-oriented programming. The -command is equivalent to @samp{@@defop Method @dots{}}. Takes as -arguments the name of the class of the method, the name of the -method, and its arguments, if any. @xref{Definition Commands}.@refill - -@item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} -Format a description for an operation in object-oriented programming. -@code{@@defop} takes as arguments the overall name of the category of -operation, the name of the class of the operation, the name of the -operation, and its arguments, if any. @xref{Definition -Commands}.@refill - -@need 100 -@item @@defopt @var{option-name} -Format a description for a user option. The command is equivalent to -@samp{@@defvr @{User Option@} @dots{}}. @xref{Definition Commands}.@refill - -@need 100 -@item @@defspec @var{special-form-name} @var{arguments}@dots{} -Format a description for a special form. The command is equivalent to -@samp{@@deffn @{Special Form@} @dots{}}. @xref{Definition Commands}.@refill - -@need 200 -@item @@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} -Format a description for a data type. @code{@@deftp} takes as -arguments the category, the name of the type (which is a word like -@samp{int} or @samp{float}), and then the names of attributes of -objects of that -type. @xref{Definition Commands}.@refill - -@item @@deftypefn @var{classification} @var{data-type} @var{name} @var{arguments}@dots{} -Format a description for a function or similar entity that may take -arguments and that is typed. @code{@@deftypefn} takes as arguments -the classification of entity being described, the type, the name of -the entity, and its arguments, if any. @xref{Definition -Commands}.@refill - -@item @@deftypefun @var{data-type} @var{function-name} @var{arguments}@dots{} -Format a description for a function in a typed language. -The command is equivalent to @samp{@@deftypefn Function @dots{}}. -@xref{Definition Commands}.@refill - -@item @@deftypevr @var{classification} @var{data-type} @var{name} -Format a description for something like a variable in a typed -language---an entity that records a value. Takes as arguments the -classification of entity being described, the type, and the name of -the entity. @xref{Definition Commands}.@refill - -@item @@deftypevar @var{data-type} @var{variable-name} -Format a description for a variable in a typed language. The command is -equivalent to @samp{@@deftypevr Variable @dots{}}. @xref{Definition -Commands}.@refill - -@item @@defun @var{function-name} @var{arguments}@dots{} -Format a description for functions. The command is equivalent to -@samp{@@deffn Function @dots{}}. @xref{Definition Commands}.@refill - -@item @@defvar @var{variable-name} -Format a description for variables. The command is equivalent to -@samp{@@defvr Variable @dots{}}. @xref{Definition Commands}.@refill - -@item @@defvr @var{category} @var{name} -Format a description for any kind of variable. @code{@@defvr} takes -as arguments the category of the entity and the name of the entity. -@xref{Definition Commands}.@refill - -@item @@dfn@{@var{term}@} -Highlight the introductory or defining use of a term. -@xref{dfn, , @code{@@dfn}}.@refill - -@need 100 -@item @@display -Begin a kind of example. Indent text, do not fill, do not select a -new font. Pair with @code{@@end display}. @xref{display, , -@code{@@display}}.@refill - -@need 100 -@item @@dmn@{@var{dimension}@} -Format a dimension. Cause @TeX{} to insert a narrow space before -@var{dimension}. No effect in Info. Use for writing a number -followed by an abbreviation of a dimension name, such as -@samp{12@dmn{pt}}, written as @samp{12@@dmn@{pt@}}, with no space -between the number and the @code{@@dmn} command. @xref{dmn, , -@code{@@dmn}}.@refill - -@need 100 -@item @@dots@{@} -Insert an ellipsis: @samp{@dots{}}. -@xref{dots, , @code{@@dots}}.@refill - -@need 100 -@item @@emph@{@var{text}@} -Highlight @var{text}; text is displayed in @emph{italics} in printed -output, and surrounded by asterisks in Info. @xref{Emphasis, , Emphasizing Text}.@refill - -@need 100 -@item @@enumerate [@var{number-or-letter}] -Begin a numbered list, using @code{@@item} for each entry. -Optionally, start list with @var{number-or-letter}. Pair with -@code{@@end enumerate}. @xref{enumerate, , -@code{@@enumerate}}.@refill - -@need 100 -@item @@equiv@{@} -Indicate to the reader the exact equivalence of two forms with a -glyph: @samp{@equiv{}}. @xref{Equivalence}.@refill - -@item @@error@{@} -Indicate to the reader with a glyph that the following text is -an error message: @samp{@error{}}. @xref{Error Glyph}.@refill - -@item @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page footings for even-numbered (left-hand) pages. Not relevant to -Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@item @@evenheading [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page headings for even-numbered (left-hand) pages. Not relevant to -Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@item @@everyfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page footings for every page. Not relevant to Info. @xref{Custom -Headings, , How to Make Your Own Headings}.@refill - -@item @@everyheading [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page headings for every page. Not relevant to Info. @xref{Custom -Headings, , How to Make Your Own Headings}.@refill - -@item @@example -Begin an example. Indent text, do not fill, and select fixed-width font. -Pair with @code{@@end example}. @xref{example, , -@code{@@example}}.@refill - -@item @@exdent @var{line-of-text} -Remove any indentation a line might have. @xref{exdent, , -Undoing the Indentation of a Line}.@refill - -@item @@expansion@{@} -Indicate the result of a macro expansion to the reader with a special -glyph: @samp{@expansion{}}. -@xref{expansion, , @expansion{} Indicating an Expansion}.@refill - -@item @@file@{@var{filename}@} -Highlight the name of a file, buffer, node, or directory. @xref{file, , -@code{@@file}}.@refill - -@item @@finalout -Prevent @TeX{} from printing large black warning rectangles beside -over-wide lines. @xref{Overfull hboxes}.@refill - -@need 100 -@item @@findex @var{entry} -Add @var{entry} to the index of functions. @xref{Index Entries, , -Defining the Entries of an Index}.@refill - -@need 200 -@item @@flushleft -Left justify every line but leave the right end ragged. -Leave font as is. Pair with @code{@@end flushleft}. -@xref{flushleft & flushright, , @code{@@flushleft} and -@code{@@flushright}}.@refill - -@need 200 -@item @@flushright -Right justify every line but leave the left end ragged. -Leave font as is. Pair with @code{@@end flushright}. -@xref{flushleft & flushright, , @code{@@flushleft} and -@code{@@flushright}}.@refill - -@need 200 -@item @@footnote@{@var{text-of-footnote}@} -Enter a footnote. Footnote text is printed at the bottom of the page -by @TeX{}; Info may format in either `End' node or `Separate' node style. -@xref{Footnotes}.@refill - -@item @@footnotestyle @var{style} -Specify an Info file's footnote style, either @samp{end} for the end -node style or @samp{separate} for the separate node style. -@xref{Footnotes}.@refill - -@item @@format -Begin a kind of example. Like @code{@@example} or @code{@@display}, -but do not narrow the margins and do not select the fixed-width font. -Pair with @code{@@end format}. @xref{example, , -@code{@@example}}.@refill - -@item @@ftable @var{formatting-command} -Begin a two-column table, using @code{@@item} for each entry. -Automatically enter each of the items in the first column into the -index of functions. Pair with @code{@@end ftable}. The same as -@code{@@table}, except for indexing. @xref{ftable vtable, , -@code{@@ftable} and @code{@@vtable}}.@refill - -@item @@group -Hold text together that must appear on one printed page. Pair with -@code{@@end group}. Not relevant to Info. @xref{group, , -@code{@@group}}.@refill - -@item @@heading @var{title} -Print an unnumbered section-like heading in the text, but not in the -table of contents of a printed manual. In Info, the title is -underlined with equal signs. @xref{unnumberedsec appendixsec heading, -, Section Commands}.@refill - -@item @@headings @var{on-off-single-double} -Turn page headings on or off, or specify single-sided or double-sided -page headings for printing. @code{@@headings on} is synonymous with -@code{@@headings double}. @xref{headings on off, , The -@code{@@headings} Command}.@refill - -@item @@i@{@var{text}@} -Print @var{text} in @i{italic} font. No effect in Info. -@xref{Fonts}.@refill - -@item @@ifclear @var{flag} -If @var{flag} is cleared, the Texinfo formatting commands format text -between @code{@@ifclear @var{flag}} and the following @code{@@end -ifclear} command. -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@item @@ifinfo -Begin a stretch of text that will be ignored by @TeX{} when it -typesets the printed manual. The text appears only in the Info file. -Pair with @code{@@end ifinfo}. @xref{Conditionals, , Conditionally -Visible Text}.@refill - -@item @@ifset @var{flag} -If @var{flag} is set, the Texinfo formatting commands format text -between @code{@@ifset @var{flag}} and the following @code{@@end ifset} -command. -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@item @@iftex -Begin a stretch of text that will not appear in the Info file, but -will be processed only by @TeX{}. Pair with @code{@@end iftex}. -@xref{Conditionals, , Conditionally Visible Text}.@refill - -@item @@ignore -Begin a stretch of text that will not appear in either the Info file -or the printed output. Pair with @code{@@end ignore}. -@xref{Comments, , Comments and Ignored Text}.@refill - -@item @@include @var{filename} -Incorporate the contents of the file @var{filename} into the Info file -or printed document. @xref{Include Files}.@refill - -@item @@inforef@{@var{node-name}, [@var{entry-name}], @var{info-file-name}@} -Make a cross reference to an Info file for which there is no printed -manual. @xref{inforef, , Cross references using -@code{@@inforef}}.@refill - -@item \input @var{macro-definitions-file} -Use the specified macro definitions file. This command is used only -in the first line of a Texinfo file to cause @TeX{} to make use of the -@file{texinfo} macro definitions file. The backslash in @code{\input} -is used instead of an @code{@@} because @TeX{} does not properly -recognize @code{@@} until after it has read the definitions file. -@xref{Header, , The Texinfo File Header}.@refill - -@item @@item -Indicate the beginning of a marked paragraph for @code{@@itemize} and -@code{@@enumerate}; indicate the beginning of the text of a first column -entry for @code{@@table}, @code{@@ftable}, and @code{@@vtable}. -@xref{Lists and Tables}.@refill - -@item @@itemize @var{mark-generating-character-or-command} -Produce a sequence of indented paragraphs, with a mark inside the left -margin at the beginning of each paragraph. Pair with @code{@@end -itemize}. @xref{itemize, , @code{@@itemize}}.@refill - -@item @@itemx -Like @code{@@item} but do not generate extra vertical space above the -item text. @xref{itemx, , @code{@@itemx}}.@refill - -@item @@kbd@{@var{keyboard-characters}@} -Indicate text that consists of characters of input to be typed by -users. @xref{kbd, , @code{@@kbd}}.@refill - -@item @@key@{@var{key-name}@} -Highlight @var{key-name}, a conventional name for a key on a keyboard. -@xref{key, , @code{@@key}}.@refill - -@item @@kindex @var{entry} -Add @var{entry} to the index of keys. @xref{Index Entries, , Defining the -Entries of an Index}.@refill - -@item @@lisp -Begin an example of Lisp code. Indent text, do not fill, and select -fixed-width font. Pair with @code{@@end lisp}. @xref{Lisp Example, , -@code{@@lisp}}.@refill - -@item @@majorheading @var{title} -Print a chapter-like heading in the text, but not in the table of -contents of a printed manual. Generate more vertical whitespace before -the heading than the @code{@@chapheading} command. In Info, the chapter -heading line is underlined with asterisks. @xref{majorheading & -chapheading, , @code{@@majorheading} and @code{@@chapheading}}.@refill - -@item @@menu -Mark the beginning of a menu of nodes in Info. No effect in a printed -manual. Pair with @code{@@end menu}. @xref{Menus}.@refill - -@item @@minus@{@} -Generate a minus sign. @xref{minus, , @code{@@minus}}.@refill - -@item @@need @var{n} -Start a new page in a printed manual if fewer than @var{n} mils -(thousandths of an inch) remain on the current page. @xref{need, , -@code{@@need}}.@refill - -@item @@node @var{name, next, previous, up} -Define the beginning of a new node in Info, and serve as a locator for -references for @TeX{}. @xref{node, , @code{@@node}}.@refill - -@need 200 -@item @@noindent -Prevent text from being indented as if it were a new paragraph. -@xref{noindent, , @code{@@noindent}}.@refill - -@item @@oddfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page footings for odd-numbered (right-hand) pages. Not relevant to -Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@item @@oddheading [@var{left}] @@| [@var{center}] @@| [@var{right}] -Specify page headings for odd-numbered (right-hand) pages. Not relevant to -Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@item @@page -Start a new page in a printed manual. No effect in Info. -@xref{page, , @code{@@page}}.@refill - -@item @@paragraphindent @var{indent} -Indent paragraphs by @var{indent} number of spaces; delete indentation -if the value of @var{indent} is 0; and do not change indentation if -@var{indent} is @code{asis}. @xref{paragraphindent, , Paragraph -Indenting}.@refill - -@item @@pindex @var{entry} -Add @var{entry} to the index of programs. @xref{Index Entries, , Defining -the Entries of an Index}.@refill - -@item @@point@{@} -Indicate the position of point in a buffer to the reader with a -glyph: @samp{@point{}}. @xref{Point Glyph, , Indicating -Point in a Buffer}.@refill - -@item @@print@{@} -Indicate printed output to the reader with a glyph: -@samp{@print{}}. @xref{Print Glyph}.@refill - -@item @@printindex @var{index-name} -Print an alphabetized two-column index in a printed manual or generate -an alphabetized menu of index entries for Info. @xref{Printing -Indices & Menus}.@refill - -@item @@pxref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} -Make a reference that starts with a lower case `see' in a printed -manual. Use within parentheses only. Do not follow command with a -punctuation mark. The Info formatting commands automatically insert -terminating punctuation as needed, which is why you do not need to -insert punctuation. Only the first argument is mandatory. -@xref{pxref, , @code{@@pxref}}.@refill - -@item @@quotation -Narrow the margins to indicate text that is quoted from another real -or imaginary work. Write command on a line of its own. Pair with -@code{@@end quotation}. @xref{quotation, , -@code{@@quotation}}.@refill - -@need 100 -@item @@r@{@var{text}@} -Print @var{text} in @r{roman} font. No effect in Info. -@xref{Fonts}.@refill - -@need 300 -@item @@ref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} -Make a reference. In a printed manual, the reference does not start -with a `See'. Follow command with a punctuation mark. Only the first -argument is mandatory. @xref{ref, , @code{@@ref}}.@refill - -@need 300 -@item @@refill -In Info, refill and indent the paragraph after all the other processing -has been done. No effect on @TeX{}, which always refills. This command -is no longer needed, since all formatters now automatically refill. -@xref{Refilling Paragraphs}.@refill - -@need 300 -@item @@result@{@} -Indicate the result of an expression to the reader with a special -glyph: @samp{@result{}}. @xref{result, , @code{@@result}}.@refill - -@item @@samp@{@var{text}@} -Highlight @var{text} that is a literal example of a sequence of -characters. Used for single characters, for statements, and often for -entire shell commands. @xref{samp, , @code{@@samp}}.@refill - -@item @@sc@{@var{text}@} -Set @var{text} in a printed output in @sc{the small caps font} and -set text in the Info file in uppercase letters. -@xref{Smallcaps}.@refill - -@item @@section @var{title} -Begin a section within a chapter. In a printed manual, the section -title is numbered and appears in the table of contents. In Info, the -title is underlined with equal signs. @xref{section, , -@code{@@section}}.@refill - -@item @@set @var{flag} [@var{string}] -Make @var{flag} active, causing the Texinfo formatting commands to -format text between subsequent pairs of @code{@@ifset @var{flag}} and -@code{@@end ifset} commands. Optionally, set value of @var{flag} to -@var{string}. -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@item @@setchapternewpage @var{on-off-odd} -Specify whether chapters start on new pages, and if so, whether on -odd-numbered (right-hand) new pages. @xref{setchapternewpage, , -@code{@@setchapternewpage}}.@refill - -@item @@setfilename @var{info-file-name} -Provide a name for the Info file. @xref{Conventions, , General -Syntactic Conventions}.@refill - -@item @@settitle @var{title} -Provide a title for page headers in a printed manual. -@xref{Conventions, , General Syntactic Conventions}.@refill - -@item @@shortcontents -Print a short table of contents. Not relevant to Info, which uses -menus rather than tables of contents. A synonym for -@code{@@summarycontents}. @xref{Contents, , Generating a Table of -Contents}.@refill - -@need 400 -@item @@smallbook -Cause @TeX{} to produce a printed manual in a 7 by 9.25 inch format -rather than the regular 8.5 by 11 inch format. @xref{smallbook, , -Printing Small Books}. Also, see @ref{smallexample & smalllisp, , -@code{@@smallexample} and @code{@@smalllisp}}.@refill - -@need 400 -@item @@smallexample -Indent text to indicate an example. Do not fill, select fixed-width -font. In @code{@@smallbook} format, print text in a smaller font than -with @code{@@example}. Pair with @code{@@end smallexample}. -@xref{smallexample & smalllisp, , @code{@@smallexample} and -@code{@@smalllisp}}.@refill - -@need 400 -@item @@smalllisp -Begin an example of Lisp code. Indent text, do not fill, select -fixed-width font. In @code{@@smallbook} format, print text in a -smaller font. Pair with @code{@@end smalllisp}. @xref{smallexample & -smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}.@refill - -@need 700 -@item @@sp @var{n} -Skip @var{n} blank lines. @xref{sp, , @code{@@sp}}.@refill - -@need 700 -@item @@strong @var{text} -Emphasize @var{text} by typesetting it in a @strong{bold} font for the -printed manual and by surrounding it with asterisks for Info. -@xref{emph & strong, , Emphasizing Text}.@refill - -@item @@subheading @var{title} -Print an unnumbered subsection-like heading in the text, but not in -the table of contents of a printed manual. In Info, the title is -underlined with hyphens. @xref{unnumberedsubsec appendixsubsec -subheading, , @code{@@unnumberedsubsec} @code{@@appendixsubsec} -@code{@@subheading}}.@refill - -@item @@subsection @var{title} -Begin a subsection within a section. In a printed manual, the -subsection title is numbered and appears in the table of contents. In -Info, the title is underlined with hyphens. @xref{subsection, , -@code{@@subsection}}.@refill - -@item @@subsubheading @var{title} -Print an unnumbered subsubsection-like heading in the text, but not in -the table of contents of a printed manual. In Info, the title is -underlined with periods. @xref{subsubsection, , The `subsub' -Commands}.@refill - -@item @@subsubsection @var{title} -Begin a subsubsection within a subsection. In a printed manual, -the subsubsection title is numbered and appears in the table of -contents. In Info, the title is underlined with periods. -@xref{subsubsection, , The `subsub' Commands}.@refill - -@item @@subtitle @var{title} -In a printed manual, set a subtitle in a normal sized font flush to -the right-hand side of the page. Not relevant to Info, which does not -have title pages. @xref{title subtitle author, , @code{@@title} -@code{@@subtitle} and @code{@@author} Commands}.@refill - -@item @@summarycontents -Print a short table of contents. Not relevant to Info, which uses -menus rather than tables of contents. A synonym for -@code{@@shortcontents}. @xref{Contents, , Generating a Table of -Contents}.@refill - -@need 300 -@item @@syncodeindex @var{from-index} @var{into-index} -Merge the index named in the first argument into the index named in -the second argument, printing the entries from the first index in -@code{@@code} font. @xref{Combining Indices}.@refill - -@need 300 -@item @@synindex @var{from-index} @var{into-index} -Merge the index named in the first argument into the index named in -the second argument. Do not change the font of @var{from-index} -entries. @xref{Combining Indices}.@refill - -@need 100 -@item @@t@{@var{text}@} -Print @var{text} in a @t{fixed-width}, typewriter-like font. -No effect in Info. @xref{Fonts}.@refill - -@need 400 -@item @@table @var{formatting-command} -Begin a two-column table, using @code{@@item} for each entry. Write -each first column entry on the same line as @code{@@item}. First -column entries are printed in the font resulting from -@var{formatting-command}. Pair with @code{@@end table}. -@xref{Two-column Tables, , Making a Two-column Table}. -Also see @ref{ftable vtable, , @code{@@ftable} and @code{@@vtable}}, -and @ref{itemx, , @code{@@itemx}}.@refill - -@item @@TeX@{@} -Insert the logo @TeX{}. @xref{TeX and copyright, , Inserting @TeX{} -and @copyright{}}.@refill - -@item @@tex -Enter @TeX{} completely. Pair with @code{@@end tex}. @xref{Using -Ordinary TeX Commands, , Using Ordinary @TeX{} Commands}.@refill - -@item @@thischapter -In a heading or footing, stands for the number and name of the current -chapter, in the format `Chapter 1: Title'. @xref{Custom -Headings, , How to Make Your Own Headings}.@refill - -@item @@thischaptername -In a heading or footing, stands for the name of the current chapter. -@xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@item @@thisfile -In a heading or footing, stands for the name of the current -@code{@@include} file. Does not insert anything if not within an -@code{@@include} file. @xref{Custom Headings, , How to Make Your Own -Headings}.@refill - -@item @@thispage -In a heading or footing, stands for the current page number. -@xref{Custom Headings, , How to Make Your Own Headings}.@refill - -@ignore -@item @@thissection -In a heading or footing, stands for the title of the current section. -@xref{Custom Headings, , How to Make Your Own Headings}.@refill -@end ignore - -@item @@thistitle -In a heading or footing, stands for the name of the document, as specified -by the @code{@@settitle} command. @xref{Custom Headings, , How to -Make Your Own Headings}.@refill - -@item @@tindex @var{entry} -Add @var{entry} to the index of data types. @xref{Index Entries, , -Defining the Entries of an Index}.@refill - -@item @@title @var{title} -In a printed manual, set a title flush to the left-hand side of the -page in a larger than normal font and underline it with a black rule. -Not relevant to Info, which does not have title pages. @xref{title -subtitle author, , The @code{@@title} @code{@@subtitle} and -@code{@@author} Commands}.@refill - -@need 400 -@item @@titlefont@{@var{text}@} -In a printed manual, print @var{text} in a larger than normal font. -Not relevant to Info, which does not have title pages. -@xref{titlefont center sp, , The @code{@@titlefont} @code{@@center} -and @code{@@sp} Commands}.@refill - -@need 300 -@item @@titlepage -Indicate to Texinfo the beginning of the title page. Write command on -a line of its own. Pair with @code{@@end titlepage}. Nothing between -@code{@@titlepage} and @code{@@end titlepage} appears in Info. -@xref{titlepage, , @code{@@titlepage}}.@refill - -@need 150 -@item @@today@{@} -Insert the current date, in `1 Jan 1900' style. @xref{Custom -Headings, , How to Make Your Own Headings}.@refill - -@item @@top @var{title} -In a Texinfo file to be formatted with @code{makeinfo}, identify the -topmost @code{@@node} line in the file, which must be written on the line -immediately preceding the @code{@@top} command. Used for -@code{makeinfo}'s node pointer insertion feature. The title is -underlined with asterisks. Both the @code{@@node} line and the @code{@@top} -line normally should be enclosed by @code{@@ifinfo} and @code{@@end -ifinfo}. In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} -command is merely a synonym for @code{@@unnumbered}. @xref{makeinfo -Pointer Creation, , Creating Pointers with @code{makeinfo}}. - -@item @@unnumbered @var{title} -In a printed manual, begin a chapter that appears without chapter -numbers of any kind. The title appears in the table of contents of a -printed manual. In Info, the title is underlined with asterisks. -@xref{unnumbered & appendix, , @code{@@unnumbered} and -@code{@@appendix}}.@refill - -@item @@unnumberedsec @var{title} -In a printed manual, begin a section that appears without section -numbers of any kind. The title appears in the table of contents of a -printed manual. In Info, the title is underlined with equal signs. -@xref{unnumberedsec appendixsec heading, , Section Commands}.@refill - -@item @@unnumberedsubsec @var{title} -In a printed manual, begin an unnumbered subsection within a -chapter. The title appears in the table of contents of a printed -manual. In Info, the title is underlined with hyphens. -@xref{unnumberedsubsec appendixsubsec subheading, , -@code{@@unnumberedsubsec} @code{@@appendixsubsec} -@code{@@subheading}}.@refill - -@item @@unnumberedsubsubsec @var{title} -In a printed manual, begin an unnumbered subsubsection within a -chapter. The title appears in the table of contents of a printed -manual. In Info, the title is underlined with periods. -@xref{subsubsection, , The `subsub' Commands}.@refill - -@item @@value@{@var{flag}@} -Replace @var{flag} with the value to which it is set by @code{@@set -@var{flag}}. -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@item @@var@{@var{metasyntactic-variable}@} -Highlight a metasyntactic variable, which is something that stands for -another piece of text. @xref{var, , Indicating Metasyntactic -Variables}.@refill - -@need 400 -@item @@vindex @var{entry} -Add @var{entry} to the index of variables. @xref{Index Entries, , -Defining the Entries of an Index}.@refill - -@need 400 -@item @@vskip @var{amount} -In a printed manual, insert whitespace so as to push text on the -remainder of the page towards the bottom of the page. Used in -formatting the copyright page with the argument @samp{0pt plus -1filll}. (Note spelling of @samp{filll}.) @code{@@vskip} may be used -only in contexts ignored for Info. @xref{Copyright & Permissions, , -The Copyright Page and Printed Permissions}.@refill - -@need 400 -@item @@vtable @var{formatting-command} -Begin a two-column table, using @code{@@item} for each entry. -Automatically enter each of the items in the first column into the -index of variables. Pair with @code{@@end vtable}. The same as -@code{@@table}, except for indexing. @xref{ftable vtable, , -@code{@@ftable} and @code{@@vtable}}.@refill - -@need 400 -@item @@w@{@var{text}@} -Prevent @var{text} from being split across two lines. Do not end a -paragraph that uses @code{@@w} with an @code{@@refill} command. -In the Texinfo file, keep @var{text} on one line. -@xref{w, , @code{@@w}}.@refill - -@need 400 -@item @@xref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} -Make a reference that starts with `See' in a printed manual. Follow -command with a punctuation mark. Only the first argument is -mandatory. @xref{xref, , @code{@@xref}}.@refill -@end table - -@node Tips, Sample Texinfo File, Command List, Top -@comment node-name, next, previous, up -@appendix Tips and Hints - -Here are some tips for writing Texinfo documentation:@refill - -@cindex Tips -@cindex Usage tips -@cindex Hints -@itemize @bullet -@item -Write in the present tense, not in the past or the future. - -@item -Write actively! For example, write ``We recommend that @dots{}'' rather -than ``It is recommended that @dots{}''. - -@item -Use 70 or 72 as your fill column. Longer lines are hard to read. - -@item -Include a copyright notice and copying permissions. -@end itemize - -@subsubheading Index, index, index! - -Write many index entries, in different ways. -Readers like indices; they are helpful and convenient. - -Although it is easiest to write index entries as you write the body of -the text, some people prefer to write entries afterwards. In either -case, write an entry before the paragraph to which it applies. This -way, an index entry points to the first page of a paragraph that is -split across pages. - -Here are more hints we have found valuable: - -@itemize @bullet -@item -Write each index entry differently, so each entry refers to a different -place in the document. The index of an Info file lists only one -location for each entry. - -@item -Write index entries only where a topic is discussed significantly. For -example, it is not useful to index ``debugging information'' in a -chapter on reporting bugs. Someone who wants to know about debugging -information will certainly not find it in that chapter. - -@item -Consistently capitalize the first word of every index entry, or else use -lower case. According to convention, you should capitalize the first -word of an index entry. However, this practice may make an index look -crowded. Some writers prefer lower case. Regardless of which you -prefer, choose one style and stick to it. Mixing the two styles looks -bad. - -@item -Always capitalize or use upper case for those words in an index for -which this is proper, such as names of countries or acronyms. - -@item -Write the indexing commands that refer to a whole section immediately -after the section command, and write the indexing commands that refer to -the paragraph before the paragraph. - -@need 1000 -In the example that follows, a blank line comes after the index -entry for ``Leaping'': - -@example -@group -@@section The Dog and the Fox -@@cindex Jumping, in general -@@cindex Leaping - -@@cindex Dog, lazy, jumped over -@@cindex Lazy dog jumped over -@@cindex Fox, jumps over dog -@@cindex Quick fox jumps over dog -The quick brown fox jumps over the lazy dog. -@end group -@end example - -@noindent -(Note that the example shows entries for the same concept that are -written in different ways---@samp{Lazy dog}, and @samp{Dog, lazy}---so -readers can look up the concept in different ways.) -@end itemize - -@subsubheading Blank lines - -@itemize @bullet -@item -Insert a blank line between a sectioning command and the first following -sentence or paragraph, or between the indexing commands associated with -the sectioning command and the first following sentence or paragraph, as -shown in the tip on indexing. Otherwise, a formatter may fold title and -paragraph together. - -@item -Always insert a blank line before an @code{@@table} command and after an -@code{@@end table} command; but never insert a blank line after an -@code{@@table} command or before an @code{@@end table} command. - -@need 1000 -For example, - -@example -@group -Types of fox: - -@@table @@samp -@@item Quick -Jump over lazy dogs. -@end group - -@group -@@item Brown -Also jump over lazy dogs. -@@end table - -@end group -@group -@@noindent -On the other hand, @dots{} -@end group -@end example - -Insert blank lines before and after @code{@@itemize} @dots{} @code{@@end -itemize} and @code{@@enumerate} @dots{} @code{@@end enumerate} in the -same way. -@end itemize - -@subsubheading Complete phrases - -Complete phrases are easier to read than @dots{} - -@itemize @bullet -@item -Write entries in an itemized list as complete sentences; or at least, as -complete phrases. Incomplete expressions @dots{} awkward @dots{} like -this. - -@item -Write the prefatory sentence or phrase for a multi-item list or table as -a complete expression. Do not write ``You can set:''; instead, write -``You can set these variables:''. The former expression sounds cut off. -@end itemize - -@subsubheading Editions, dates and versions - -Write the edition and version numbers and date in three places in every -manual: - -@enumerate -@item -In the first @code{@@ifinfo} section, for people reading the Texinfo file. - -@item -In the @code{@@titlepage} section, for people reading the printed manual. - -@item -In the `Top' node, for people reading the Info file. -@end enumerate - -@noindent -Also, it helps to write a note before the first @code{@@ifinfo} -section to explain what you are doing. - -@need 800 -@noindent -For example: - -@example -@group -@@c ===> NOTE! <== -@@c Specify the edition and version numbers and date -@@c in *three* places: -@@c 1. First ifinfo section 2. title page 3. top node -@@c To find the locations, search for !!set -@end group - -@group -@@ifinfo -@@c !!set edition, date, version -This is Edition 4.03, January 1992, -of the @@cite@{GDB Manual@} for GDB Version 4.3. -@dots{} -@end group -@end example - -@noindent ----or use @code{@@set} and @code{@@value} -(@pxref{value Example, , @code{@@value} Example}). - -@subsubheading Definition Commands - -Definition commands are @code{@@deffn}, @code{@@defun}, -@code{@@defmac}, and the like, and enable you to write descriptions in -a uniform format.@refill - -@itemize @bullet -@item -Write just one definition command for each entity you define with a -definition command. The automatic indexing feature creates an index -entry that leads the reader to the definition. - -@item -Use @code{@@table} @dots{} @code{@@end table} in an appendix that -contains a summary of functions, not @code{@@deffn} or other definition -commands. -@end itemize - -@subsubheading Capitalization - -@itemize @bullet -@item -Capitalize @samp{Texinfo}; it is a name. Do not write the @samp{x} or -@samp{i} in upper case. - -@item -Capitalize @samp{Info}; it is a name. - -@item -Write @TeX{} using the @code{@@TeX@{@}} command. Note the uppercase -@samp{T} and @samp{X}. This command causes the formatters to -typeset the name according to the wishes of Donald Knuth, who wrote -@TeX{}. -@end itemize - -@subsubheading Spaces - -Do not use spaces to format a Texinfo file, except inside of -@code{@@example} @dots{} @code{@@end example} and similar commands. - -@need 700 -For example, @TeX{} fills the following: - -@example -@group - @@kbd@{C-x v@} - @@kbd@{M-x vc-next-action@} - Perform the next logical operation - on the version-controlled file - corresponding to the current buffer. -@end group -@end example - -@need 950 -@noindent -so it looks like this: - -@iftex -@quotation - @kbd{C-x v} - @kbd{M-x vc-next-action} - Perform the next logical operation on the version-controlled file - corresponding to the current buffer. -@end quotation -@end iftex -@ifinfo -@quotation -`C-x v' `M-x vc-next-action' Perform the next logical operation on the -version-controlled file corresponding to the current buffer. -@end quotation -@end ifinfo - -@noindent -In this case, the text should be formatted with -@code{@@table}, @code{@@item}, and @code{@@itemx}, to create a table. - -@subsubheading @@code, @@samp, @@var, and @samp{---} - -@itemize @bullet -@item -Use @code{@@code} around Lisp symbols, including command names. -For example, - -@example -The main function is @@code@{vc-next-action@}, @dots{} -@end example - -@item -Avoid putting letters such as @samp{s} immediately after an -@samp{@@code}. Such letters look bad. - -@item -Use @code{@@var} around meta-variables. Do not write angle brackets -around them. - -@item -Use three hyphens in a row, @samp{---}, to indicate a long dash. @TeX{} -typesets these as a long dash and the Info formatters reduce three -hyphens to two. -@end itemize - -@subsubheading Periods Outside of Quotes - -Place periods and other punctuation marks @emph{outside} of quotations, -unless the punctuation is part of the quotation. This practice goes against -convention, but enables the reader to distinguish between the contents -of the quotation and the whole passage. - -For example, you should write the following sentence with the period -outside the end quotation marks: - -@example -Evidently, @samp{au} is an abbreviation for ``author''. -@end example - -@noindent -since @samp{au} does @emph{not} serve as an abbreviation for -@samp{author.} (with a period following the word). - -@subsubheading Introducing New Terms - -@itemize @bullet -@item -Introduce new terms so that a user who does not know them can understand -them from context; or write a definition for the term. - -For example, in the following, the terms ``check in'', ``register'' and -``delta'' are all appearing for the first time; the example sentence should be -rewritten so they are understandable. - -@quotation -The major function assists you in checking in a file to your -version control system and registering successive sets of changes to -it as deltas. -@end quotation - -@item -Use the @code{@@dfn} command around a word being introduced, to indicate -that the user should not expect to know the meaning already, and should -expect to learn the meaning from this passage. -@end itemize - -@subsubheading @@pxref - -@c !!! maybe include this in the tips on pxref -@ignore -By the way, it is okay to use pxref with something else in front of -it within the parens, as long as the pxref is followed by the close -paren, and the material inside the parents is not part of a larger -sentence. Also, you can use xref inside parens as part of a complete -sentence so long as you terminate the cross reference with punctuation. -@end ignore -Absolutely never use @code{@@pxref} except in the special context for -which it is designed: inside parentheses, with the closing parenthesis -following immediately after the closing brace. One formatter -automatically inserts closing punctuation and the other does not. This -means that the output looks right both in printed output and in an Info -file, but only when the command is used inside parentheses. - -@subsubheading Invoking from a Shell - -You can invoke programs such as Emacs, GCC, and GAWK from a shell. -The documentation for each program should contain a section that -describes this. Unfortunately, if the node names and titles for these -sections are all different, readers find it hard to search for the -section.@refill - -Name such sections with a phrase beginning with the word -@w{`Invoking @dots{}'}, as in `Invoking Emacs'; this way -users can find the section easily. - -@subsubheading @sc{ansi c} Syntax - -When you use @code{@@example} to describe a C function's calling -conventions, use the @sc{ansi c} syntax, like this:@refill - -@example -void dld_init (char *@@var@{path@}); -@end example - -@noindent -And in the subsequent discussion, refer to the argument values by -writing the same argument names, again highlighted with -@code{@@var}.@refill - -@need 800 -Avoid the obsolete style that looks like this:@refill - -@example -#include - -dld_init (path) -char *path; -@end example - -Also, it is best to avoid writing @code{#include} above the -declaration just to indicate that the function is declared in a -header file. The practice may give the misimpression that the -@code{#include} belongs near the declaration of the function. Either -state explicitly which header file holds the declaration or, better -yet, name the header file used for a group of functions at the -beginning of the section that describes the functions.@refill - -@subsubheading Bad Examples - -Here are several examples of bad writing to avoid: - -In this example, say, `` @dots{} you must @code{@@dfn}@{check -in@} the new version.'' That flows better. - -@quotation -When you are done editing the file, you must perform a -@code{@@dfn}@{check in@}. -@end quotation - -In the following example, say, ``@dots{} makes a unified interface such as VC -mode possible.'' - -@quotation -SCCS, RCS and other version-control systems all perform similar -functions in broadly similar ways (it is this resemblance which makes -a unified control mode like this possible). -@end quotation - -And in this example, you should specify what `it' refers to: - -@quotation -If you are working with other people, it assists in coordinating -everyone's changes so they do not step on each other. -@end quotation - -@subsubheading And Finally @dots{} - -@itemize @bullet -@item -Pronounce @TeX{} as if the @samp{X} were a Greek `chi', as the last -sound in the name `Bach'. But pronounce Texinfo as in `speck': -@samp{teckinfo}. - -@item -Write notes for yourself at the very end of a Texinfo file after the -@code{@@bye}. None of the formatters process text after the -@code{@@bye}; it is as if the text were within @code{@@ignore} @dots{} -@code{@@end ignore}. -@end itemize - -@node Sample Texinfo File, Sample Permissions, Tips, Top -@comment node-name, next, previous, up -@appendix A Sample Texinfo File -@cindex Sample Texinfo file, no comments - -Here is a complete, short sample Texinfo file, without any commentary. -You can see this file, with comments, in the first chapter. -@xref{Short Sample, , A Short Sample Texinfo File}. - -@sp 1 -@example -\input texinfo @@c -*-texinfo-*- -@@c %**start of header -@@setfilename sample.info -@@settitle Sample Document -@@c %**end of header - -@@setchapternewpage odd - -@@ifinfo -This is a short example of a complete Texinfo file. - -Copyright 1990 Free Software Foundation, Inc. -@@end ifinfo - -@@titlepage -@@sp 10 -@@comment The title is printed in a large font. -@@center @@titlefont@{Sample Title@} - -@@c The following two commands start the copyright page. -@@page -@@vskip 0pt plus 1filll -Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. -@@end titlepage - -@@node Top, First Chapter, (dir), (dir) -@@comment node-name, next, previous, up - -@@menu -* First Chapter:: The first chapter is the - only chapter in this sample. -* Concept Index:: This index has two entries. -@@end menu - -@@node First Chapter, Concept Index, Top, Top -@@comment node-name, next, previous, up -@@chapter First Chapter -@@cindex Sample index entry - -This is the contents of the first chapter. -@@cindex Another sample index entry - -Here is a numbered list. - -@@enumerate -@@item -This is the first item. - -@@item -This is the second item. -@@end enumerate - -The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} -commands transform a Texinfo file such as this into -an Info file; and @@TeX@{@} typesets it for a printed -manual. - -@@node Concept Index, , First Chapter, Top -@@comment node-name, next, previous, up -@@unnumbered Concept Index - -@@printindex cp - -@@contents -@@bye -@end example - -@node Sample Permissions, Include Files, Sample Texinfo File, Top -@appendix Sample Permissions -@cindex Permissions -@cindex Copying permissions - -Texinfo files should contain sections that tell the readers that they -have the right to copy and distribute the Texinfo file, the Info file, -and the printed manual.@refill - -Also, if you are writing a manual about software, you should explain -that the software is free and either include the GNU General Public -License (GPL) or provide a reference to it. @xref{Distrib, , -Distribution, emacs, The GNU Emacs Manual}, for an example of the text -that could be used in the software ``Distribution'', ``General Public -License'', and ``NO WARRANTY'' sections of a document. @xref{Copying, -, Texinfo Copying Conditions}, for an example of a brief explanation -of how the copying conditions provide you with rights. @refill - -@menu -* Inserting Permissions:: How to put permissions in your document. -* ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. -* Titlepage Permissions:: Sample Titlepage copying permissions. -@end menu - -@node Inserting Permissions, ifinfo Permissions, , Sample Permissions -@ifinfo -@appendixsec Inserting Permissions -@end ifinfo - -In a Texinfo file, the first @code{@@ifinfo} section usually begins -with a line that says what the file documents. This is what a person -reading the unprocessed Texinfo file or using the advanced Info -command @kbd{g *} sees first. @inforef{Expert, Advanced Info -commands, info}, for more information. (A reader using the regular -Info commands usually starts reading at the first node and skips -this first section, which is not in a node.)@refill - -In the @code{@@ifinfo} section, the summary sentence is followed by a -copyright notice and then by the copying permission notice. One of -the copying permission paragraphs is enclosed in @code{@@ignore} and -@code{@@end ignore} commands. This paragraph states that the Texinfo -file can be processed through @TeX{} and printed, provided the printed -manual carries the proper copying permission notice. This paragraph -is not made part of the Info file since it is not relevant to the Info -file; but it is a mandatory part of the Texinfo file since it permits -people to process the Texinfo file in @TeX{} and print the -results.@refill - -In the printed manual, the Free Software Foundation copying permission -notice follows the copyright notice and publishing information and is -located within the region delineated by the @code{@@titlepage} and -@code{@@end titlepage} commands. The copying permission notice is exactly -the same as the notice in the @code{@@ifinfo} section except that the -paragraph enclosed in @code{@@ignore} and @code{@@end ignore} commands is -not part of the notice.@refill - -To make it simple to insert a permission notice into each section of -the Texinfo file, sample permission notices for each section are -reproduced in full below.@refill - -Note that you may need to specify the correct name of a section -mentioned in the permission notice. For example, in @cite{The GDB -Manual}, the name of the section referring to the General Public -License is called the ``GDB General Public License'', but in the -sample shown below, that section is referred to generically as the -``GNU General Public License''. If the Texinfo file does not carry a -copy of the General Public License, leave out the reference to it, but -be sure to include the rest of the sentence.@refill - -@node ifinfo Permissions, Titlepage Permissions, Inserting Permissions, Sample Permissions -@comment node-name, next, previous, up -@appendixsec @samp{ifinfo} Copying Permissions -@cindex @samp{ifinfo} permissions - -In the @code{@@ifinfo} section of a Texinfo file, the standard Free -Software Foundation permission notice reads as follows:@refill - -@example -This file documents @dots{} - -Copyright 1992 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim -copies of this manual provided the copyright notice and -this permission notice are preserved on all copies. - -@@ignore -Permission is granted to process this file through TeX -and print the results, provided the printed document -carries a copying permission notice identical to this -one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). - -@@end ignore -Permission is granted to copy and distribute modified -versions of this manual under the conditions for -verbatim copying, provided also that the sections -entitled ``Copying'' and ``GNU General Public License'' -are included exactly as in the original, and provided -that the entire resulting derived work is distributed -under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute -translations of this manual into another language, -under the above conditions for modified versions, -except that this permission notice may be stated in a -translation approved by the Free Software Foundation. -@end example - -@node Titlepage Permissions, , ifinfo Permissions, Sample Permissions -@comment node-name, next, previous, up -@appendixsec Titlepage Copying Permissions -@cindex Titlepage permissions - -In the @code{@@titlepage} section of a Texinfo file, the standard Free -Software Foundation copying permission notice follows the copyright -notice and publishing information. The standard phrasing is as -follows:@refill - -@example -Permission is granted to make and distribute verbatim -copies of this manual provided the copyright notice and -this permission notice are preserved on all copies. - -Permission is granted to copy and distribute modified -versions of this manual under the conditions for -verbatim copying, provided also that the sections -entitled ``Copying'' and ``GNU General Public License'' -are included exactly as in the original, and provided -that the entire resulting derived work is distributed -under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute -translations of this manual into another language, -under the above conditions for modified versions, -except that this permission notice may be stated in a -translation approved by the Free Software Foundation. -@end example - -@node Include Files, Headings, Sample Permissions, Top -@comment node-name, next, previous, up -@appendix Include Files -@cindex Include files - -When @TeX{} or an Info formatting command sees an @code{@@include} -command in a Texinfo file, it processes the contents of the file named -by the command and incorporates them into the @sc{dvi} or Info file being -created. Index entries from the included file are incorporated into -the indices of the output file.@refill - -Include files let you keep a single large document as a collection of -conveniently small parts.@refill - -@menu -* Using Include Files:: How to use the @code{@@include} command. -* texinfo-multiple-files-update:: How to create and update nodes and - menus when using included files. -* Include File Requirements:: What @code{texinfo-multiple-files-update} expects. -* Sample Include File:: A sample outer file with included files - within it; and a sample included file. -* Include Files Evolution:: How use of the @code{@@include} command - has changed over time. -@end menu - -@node Using Include Files, texinfo-multiple-files-update, , Include Files -@appendixsec How to Use Include Files -@findex include - -To include another file within a Texinfo file, write the -@code{@@include} command at the beginning of a line and follow it on -the same line by the name of a file to be included. For -example:@refill - -@example -@@include buffers.texi -@end example - -An included file should simply be a segment of text that you expect to -be included as is into the overall or @dfn{outer} Texinfo file; it -should not contain the standard beginning and end parts of a Texinfo -file. In particular, you should not start an included file with a -line saying @samp{\input texinfo}; if you do, that phrase is inserted -into the output file as is. Likewise, you should not end an included -file with an @code{@@bye} command; nothing after @code{@@bye} is -formatted.@refill - -In the past, you were required to write an @code{@@setfilename} line at the -beginning of an included file, but no longer. Now, it does not matter -whether you write such a line. If an @code{@@setfilename} line exists -in an included file, it is ignored.@refill - -Conventionally, an included file begins with an @code{@@node} line that -is followed by an @code{@@chapter} line. Each included file is one -chapter. This makes it easy to use the regular node and menu creating -and updating commands to create the node pointers and menus within the -included file. However, the simple Emacs node and menu creating and -updating commands do not work with multiple Texinfo files. Thus you -cannot use these commands to fill in the `Next', `Previous', and `Up' -pointers of the @code{@@node} line that begins the included file. Also, -you cannot use the regular commands to create a master menu for the -whole file. Either you must insert the menus and the `Next', -`Previous', and `Up' pointers by hand, or you must use the GNU Emacs -Texinfo mode command, @code{texinfo-multiple-files-update}, that is -designed for @code{@@include} files.@refill - -@node texinfo-multiple-files-update, Include File Requirements, Using Include Files, Include Files -@appendixsec @code{texinfo-multiple-files-update} -@findex texinfo-multiple-files-update - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -GNU Emacs Texinfo mode provides a command to handle included files -called @code{texinfo-multiple-files-update}. This command creates or -updates `Next', `Previous', and `Up' pointers of included files as -well as those in the outer or overall Texinfo file, and it creates or -updates a main menu in the outer file. Depending whether you call it -with optional arguments, the command updates only the pointers in the -first @code{@@node} line of the included files or all of them:@refill - -@table @kbd -@item M-x texinfo-multiple-files-update -Called without any arguments:@refill - -@itemize @minus -@item -Create or update the `Next', `Previous', and `Up' pointers of the -first @code{@@node} line in each file included in an outer or overall -Texinfo file.@refill - -@item -Create or update the `Top' level node pointers of the outer or -overall file.@refill - -@item -Create or update a main menu in the outer file.@refill -@end itemize - -@item C-u M-x texinfo-multiple-files-update -Called with @kbd{C-u} as a prefix argument: - -@itemize @minus{} -@item -Create or update pointers in the first @code{@@node} line in each -included file. - -@item -Create or update the `Top' level node pointers of the outer file. - -@item -Create and insert a master menu in the outer file. The master menu -is made from all the menus in all the included files.@refill -@end itemize - -@item C-u 8 M-x texinfo-multiple-files-update -Called with a numeric prefix argument, such as @kbd{C-u 8}: - -@itemize @minus -@item -Create or update @strong{all} the `Next', `Previous', and `Up' pointers -of all the included files.@refill - -@item -Create or update @strong{all} the menus of all the included -files.@refill - -@item -Create or update the `Top' level node pointers of the outer or -overall file.@refill - -@item -And then create a master menu in the outer file. This is similar to -invoking @code{texinfo-master-menu} with an argument when you are -working with just one file.@refill -@end itemize -@end table - -Note the use of the prefix argument in interactive use: with a regular -prefix argument, just @w{@kbd{C-u}}, the -@code{texinfo-multiple-files-update} command inserts a master menu; -with a numeric prefix argument, such as @kbd{C-u 8}, the command -updates @strong{every} pointer and menu in @strong{all} the files and then inserts a -master menu.@refill - -@node Include File Requirements, Sample Include File, texinfo-multiple-files-update, Include Files -@appendixsec Include File Requirements -@cindex Include file requirements -@cindex Requirements for include files - -If you plan to use the @code{texinfo-multiple-files-update} command, -the outer Texinfo file that lists included files within it should -contain nothing but the beginning and end parts of a Texinfo file, and -a number of @code{@@include} commands listing the included files. It -should not even include indices, which should be listed in an included -file of their own.@refill - -Moreover, each of the included files must contain exactly one highest -level node (conventionally, @code{@@chapter} or equivalent), -and this node must be the first node in the included file. -Furthermore, each of these highest level nodes in each included file -must be at the same hierarchical level in the file structure. -Usually, each is an @code{@@chapter}, an @code{@@appendix}, or an -@code{@@unnumbered} node. Thus, normally, each included file contains -one, and only one, chapter or equivalent-level node.@refill - -The outer file should contain only @emph{one} node, the `Top' node. It -should @emph{not} contain any nodes besides the single `Top' node. The -@code{texinfo-multiple-files-update} command will not process -them.@refill - -@node Sample Include File, Include Files Evolution, Include File Requirements, Include Files -@appendixsec Sample File with @code{@@include} -@cindex Sample @code{@@include} file -@cindex Include file sample -@cindex @code{@@include} file sample - -Here is an example of a complete outer Texinfo file with @code{@@include} files -within it before running @code{texinfo-multiple-files-update}, which -would insert a main or master menu:@refill - -@example -@group -\input texinfo @@c -*-texinfo-*- -@c %**start of header -@@setfilename include-example.info -@@settitle Include Example -@c %**end of header -@end group - -@group -@@setchapternewpage odd -@@titlepage -@@sp 12 -@@center @@titlefont@{Include Example@} -@@sp 2 -@@center by Whom Ever -@end group - -@group -@@page -@@vskip 0pt plus 1filll -Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. -@@end titlepage -@end group - -@group -@@ifinfo -@@node Top, First, (dir), (dir) -@@top Master Menu -@@end ifinfo -@end group - -@group -@@include foo.texinfo -@@include bar.texinfo -@@include concept-index.texinfo -@end group - -@group -@@summarycontents -@@contents - -@@bye -@end group -@end example - -An included file, such as @file{foo.texinfo}, might look like -this:@refill - -@example -@group -@@node First, Second, , Top -@@chapter First Chapter - -Contents of first chapter @dots{} -@end group -@end example - -The full contents of @file{concept-index.texinfo} might be as simple as this: - -@example -@group -@@node Concept Index, , Second, Top -@@unnumbered Concept Index - -@@printindex cp -@end group -@end example - -The outer Texinfo source file for @cite{The GNU Emacs Lisp Reference -Manual} is named @file{elisp.texi}. This outer file contains a master -menu with 417 entries and a list of 41 @code{@@include} -files.@refill - -@node Include Files Evolution, , Sample Include File, Include Files -@comment node-name, next, previous, up -@appendixsec Evolution of Include Files - -When Info was first created, it was customary to create many small -Info files on one subject. Each Info file was formatted from its own -Texinfo source file. This custom meant that Emacs did not need to -make a large buffer to hold the whole of a large Info file when -someone wanted information; instead, Emacs allocated just enough -memory for the small Info file that contained the particular -information sought. This way, Emacs could avoid wasting memory.@refill - -References from one file to another were made by referring to the file -name as well as the node name. (@xref{Other Info Files, , Referring to -Other Info Files}. Also, see @ref{Four and Five Arguments, , -@code{@@xref} with Four and Five Arguments}.)@refill - -Include files were designed primarily as a way to create a single, -large printed manual out of several smaller Info files. In a printed -manual, all the references were within the same document, so @TeX{} -could automatically determine the references' page numbers. The Info -formatting commands used include files only for creating joint -indices; each of the individual Texinfo files had to be formatted for -Info individually. (Each, therefore, required its own -@code{@@setfilename} line.)@refill - -However, because large Info files are now split automatically, it is -no longer necessary to keep them small.@refill - -Nowadays, multiple Texinfo files are used mostly for large documents, -such as @cite{The GNU Emacs Lisp Reference Manual}, and for projects -in which several different people write different sections of a -document simultaneously.@refill - -In addition, the Info formatting commands have been extended to work -with the @code{@@include} command so as to create a single large Info -file that is split into smaller files if necessary. This means that -you can write menus and cross references without naming the different -Texinfo files.@refill - -@node Headings, Catching Mistakes, Include Files, Top -@comment node-name, next, previous, up -@appendix Page Headings -@cindex Headings -@cindex Footings -@cindex Page numbering -@cindex Page headings -@cindex Formatting headings and footings - -Most printed manuals contain headings along the top of every page -except the title and copyright pages. Some manuals also contain -footings. (Headings and footings have no meaning to Info, which is -not paginated.)@refill - -@menu -* Headings Introduced:: Conventions for using page headings. -* Heading Format:: Standard page heading formats. -* Heading Choice:: How to specify the type of page heading. -* Custom Headings:: How to create your own headings and footings. -@end menu - -@node Headings Introduced, Heading Format, , Headings -@ifinfo -@heading Headings Introduced -@end ifinfo - -Texinfo provides standard page heading formats for manuals that are printed -on one side of each sheet of paper and for manuals that are printed on -both sides of the paper. Usually, you will use one or other of these -formats, but you can specify your own format, if you wish.@refill - -In addition, you can specify whether chapters should begin on a new -page, or merely continue the same page as the previous chapter; and if -chapters begin on new pages, you can specify whether they must be -odd-numbered pages.@refill - -By convention, a book is printed on both sides of each sheet of paper. -When you open a book, the right-hand page is odd-numbered, and -chapters begin on right-hand pages---a preceding left-hand page is -left blank if necessary. Reports, however, are often printed on just -one side of paper, and chapters begin on a fresh page immediately -following the end of the preceding chapter. In short or informal -reports, chapters often do not begin on a new page at all, but are -separated from the preceding text by a small amount of whitespace.@refill - -The @code{@@setchapternewpage} command controls whether chapters begin -on new pages, and whether one of the standard heading formats is used. -In addition, Texinfo has several heading and footing commands that you -can use to generate your own heading and footing formats.@refill - -In Texinfo, headings and footings are single lines at the tops and -bottoms of pages; you cannot create multiline headings or footings. -Each header or footer line is divided into three parts: a left part, a -middle part, and a right part. Any part, or a whole line, may be left -blank. Text for the left part of a header or footer line is set -flushleft; text for the middle part is centered; and, text for the -right part is set flushright.@refill - -@node Heading Format, Heading Choice, Headings Introduced, Headings -@comment node-name, next, previous, up -@appendixsec Standard Heading Formats - -Texinfo provides two standard heading formats, one for manuals printed -on one side of each sheet of paper, and the other for manuals printed -on both sides of the paper. - -By default, nothing is specified for the footing of a Texinfo file, -so the footing remains blank.@refill - -The standard format for single-sided printing consists of a header -line in which the left-hand part contains the name of the chapter, the -central part is blank, and the right-hand part contains the page -number.@refill - -@need 950 -A single-sided page looks like this: - -@example -@group - _______________________ - | | - | chapter page number | - | | - | Start of text ... | - | ... | - | | - -@end group -@end example - -The standard format for two-sided printing depends on whether the page -number is even or odd. By convention, even-numbered pages are on the -left- and odd-numbered pages are on the right. (@TeX{} will adjust the -widths of the left- and right-hand margins. Usually, widths are -correct, but during double-sided printing, it is wise to check that -pages will bind properly---sometimes a printer will produce output in -which the even-numbered pages have a larger right-hand margin than the -odd-numbered pages.)@refill - -In the standard double-sided format, the left part of the left-hand -(even-numbered) page contains the page number, the central part is -blank, and the right part contains the title (specified by the -@code{@@settitle} command). The left part of the right-hand -(odd-numbered) page contains the name of the chapter, the central part -is blank, and the right part contains the page number.@refill - -@need 750 -Two pages, side by side as in an open book, look like this:@refill - -@example -@group - _______________________ _______________________ - | | | | - | page number title | | chapter page number | - | | | | - | Start of text ... | | More text ... | - | ... | | ... | - | | | | - -@end group -@end example - -@noindent -The chapter name is preceded by the word @samp{Chapter}, the chapter -number and a colon. This makes it easier to keep track of where you -are in the manual.@refill - -@node Heading Choice, Custom Headings, Heading Format, Headings -@comment node-name, next, previous, up -@appendixsec Specifying the Type of Heading - -@TeX{} does not begin to generate page headings for a standard Texinfo -file until it reaches the @code{@@end titlepage} command. Thus, the -title and copyright pages are not numbered. The @code{@@end -titlepage} command causes @TeX{} to begin to generate page headings -according to a standard format specified by the -@code{@@setchapternewpage} command that precedes the -@code{@@titlepage} section.@refill - -@need 1000 -There are four possibilities:@refill - -@table @asis -@item No @code{@@setchapternewpage} command -Cause @TeX{} to specify the single-sided heading format, with chapters -on new pages. This is the same as @code{@@setchapternewpage on}.@refill - -@item @code{@@setchapternewpage on} -Specify the single-sided heading format, with chapters on new pages.@refill - -@item @code{@@setchapternewpage off} -Cause @TeX{} to start a new chapter on the same page as the last page of -the preceding chapter, after skipping some vertical whitespace. Also -cause @TeX{} to typeset for single-sided printing. (You can override -the headers format with the @code{@@headings double} command; see -@ref{headings on off, , The @code{@@headings} Command}.)@refill - -@item @code{@@setchapternewpage odd} -Specify the double-sided heading format, with chapters on new pages.@refill -@end table - -@noindent -Texinfo lacks an @code{@@setchapternewpage even} command.@refill - -@node Custom Headings, , Heading Choice, Headings -@comment node-name, next, previous, up -@appendixsec How to Make Your Own Headings - -You can use the standard headings provided with Texinfo or specify -your own.@refill - -@c Following paragraph is verbose to prevent overfull hboxes. -Texinfo provides six commands for specifying headings and -footings. The @code{@@everyheading} command and -@code{@@everyfooting} command generate page headers and footers -that are the same for both even- and odd-numbered pages. -The @code{@@evenheading} command and @code{@@evenfooting} -command generate headers and footers for even-numbered -(left-hand) pages; and the @code{@@oddheading} command and -@code{@@oddfooting} command generate headers and footers for -odd-numbered (right-hand) pages.@refill - -Write custom heading specifications in the Texinfo file immediately -after the @code{@@end titlepage} command. Enclose your specifications -between @code{@@iftex} and @code{@@end iftex} commands since the -@code{texinfo-format-buffer} command may not recognize them. Also, -you must cancel the predefined heading commands with the -@code{@@headings off} command before defining your own -specifications.@refill - -@need 1000 -Here is how to tell @TeX{} to place the chapter name at the left, the -page number in the center, and the date at the right of every header -for both even- and odd-numbered pages:@refill - -@example -@group -@@iftex -@@headings off -@@everyheading @@thischapter @@| @@thispage @@| @@today@{@} -@@end iftex -@end group -@end example - -@noindent -You need to divide the left part from the central part and the central -part from the right had part by inserting @samp{@@|} between parts. -Otherwise, the specification command will not be able to tell where -the text for one part ends and the next part begins.@refill - -Each part can contain text or @@-commands. The text -is printed as if the part were within an ordinary paragraph in the -body of the page. The @@-commands replace -themselves with the page number, date, chapter name, or -whatever.@refill - -@need 950 -Here are the six heading and footing commands:@refill - -@findex everyheading -@findex everyfooting -@table @code -@item @@everyheading @var{left} @@| @var{center} @@| @var{right} -@itemx @@everyfooting @var{left} @@| @var{center} @@| @var{right} - -The `every' commands specify the format for both even- and odd-numbered -pages. These commands are for documents that are printed on one side -of each sheet of paper, or for documents in which you want symmetrical -headers or footers.@refill - -@findex evenheading -@findex evenfooting -@findex oddheading -@findex oddfooting -@item @@evenheading @var{left} @@| @var{center} @@| @var{right} -@itemx @@oddheading @var{left} @@| @var{center} @@| @var{right} - -@itemx @@evenfooting @var{left} @@| @var{center} @@| @var{right} -@itemx @@oddfooting @var{left} @@| @var{center} @@| @var{right} - -The `even' and `odd' commands specify the format for even-numbered -pages and odd-numbered pages. These commands are for books and -manuals that are printed on both sides of each sheet of paper.@refill -@end table - -Use the @samp{@@this@dots{}} series of @@-commands to -provide the names of chapters -and sections and the page number. You can use the -@samp{@@this@dots{}} commands in the left, center, or right portions -of headers and footers, or anywhere else in a Texinfo file so long as -they are between @code{@@iftex} and @code{@@end iftex} commands.@refill - -@need 1000 -Here are the @samp{@@this@dots{}} commands:@refill - -@table @code -@findex thispage -@item @@thispage -Expands to the current page number.@refill -@c !!! Karl Berry says that `thissection' fails on page breaks. -@ignore -@item @@thissection -Expands to the name of the current section.@refill -@end ignore - -@findex thischaptername -@item @@thischaptername -Expands to the name of the current chapter.@refill - -@findex thischapter -@item @@thischapter -Expands to the number and name of the current -chapter, in the format `Chapter 1: Title'.@refill - -@findex thistitle -@item @@thistitle -Expands to the name of the document, as specified by the -@code{@@settitle} command.@refill - -@findex thisfile -@item @@thisfile -For @code{@@include} files only: expands to the name of the current -@code{@@include} file. If the current Texinfo source file is not an -@code{@@include} file, this command has no effect. This command does -@emph{not} provide the name of the current Texinfo source file unless -it is an @code{@@include} file. (@xref{Include Files}, for more -information about @code{@@include} files.)@refill -@end table - -@noindent -You can also use the @code{@@today@{@}} command, which expands to the -current date, in `1 Jan 1900' format.@refill -@findex today - -Other @@-commands and text are printed in a header or footer just as -if they were in the body of a page. It is useful to incorporate text, -particularly when you are writing drafts:@refill - -@example -@group -@@iftex -@@headings off -@@everyheading @@emph@{Draft!@} @@| @@thispage @@| @@thischapter -@@everyfooting @@| @@| Version: 0.27: @@today@{@} -@@end iftex -@end group -@end example - -Beware of overlong titles: they may overlap another part of the -header or footer and blot it out.@refill - -@node Catching Mistakes, Refilling Paragraphs, Headings, Top -@comment node-name, next, previous, up -@appendix Formatting Mistakes -@cindex Structure, catching mistakes in -@cindex Nodes, catching mistakes -@cindex Catching mistakes -@cindex Correcting mistakes -@cindex Mistakes, catching -@cindex Problems, catching -@cindex Debugging the Texinfo structure - -Besides mistakes in the content of your documentation, there -are two kinds of mistake you can make with Texinfo: you can make mistakes -with @@-commands, and you can make mistakes with the structure of the -nodes and chapters.@refill - -Emacs has two tools for catching the @@-command mistakes and two for -catching structuring mistakes.@refill - -For finding problems with @@-commands, you can run @TeX{} or a region -formatting command on the region that has a problem; indeed, you can -run these commands on each region as you write it.@refill - -For finding problems with the structure of nodes and chapters, you can use -@kbd{C-c C-s} (@code{texinfo-show-structure}) and the related @code{occur} -command and you can use the @kbd{M-x Info-validate} command.@refill - -@menu -* makeinfo preferred:: @code{makeinfo} finds errors. -* Debugging with Info:: How to catch errors with Info formatting. -* Debugging with TeX:: How to catch errors with @TeX{} formatting. -* Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. -* Using occur:: How to list all lines containing a pattern. -* Running Info-Validate:: How to find badly referenced nodes. -@end menu - -@node makeinfo preferred, Debugging with Info, , Catching Mistakes -@ifinfo -@heading @code{makeinfo} Find Errors -@end ifinfo - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -The @code{makeinfo} program does an excellent job of catching errors -and reporting them---far better than either the -@code{texinfo-format-region} or the @code{texinfo-format-buffer} -command. In addition, the various functions for automatically -creating and updating node pointers and menus remove many -opportunities for human error.@refill - -If you can, use the updating commands to create and insert pointers -and menus. These prevent many errors. Then use @code{makeinfo} (or -its Texinfo mode manifestations, @code{makeinfo-region} and -@code{makeinfo-buffer}) to format your file and check for other -errors. This is the best way to work with Texinfo. But if you -cannot use @code{makeinfo}, or your problem is very puzzling, then you -may want to use the tools described in this appendix.@refill - -@node Debugging with Info, Debugging with TeX, makeinfo preferred, Catching Mistakes -@comment node-name, next, previous, up -@appendixsec Catching Errors with Info Formatting -@cindex Catching errors with Info formatting -@cindex Debugging with Info formatting - -After you have written part of a Texinfo file, you can use the -@code{texinfo-format-region} or the @code{makeinfo-region} command to -see whether the region formats properly.@refill - -Most likely, however, you are reading this section because for some -reason you cannot use the @code{makeinfo-region} command; therefore, the -rest of this section presumes that you are using -@code{texinfo-format-region}.@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -If you make a mistake with an @@-command, -@code{texinfo-format-region} will stop processing at or after the -error and display an error message. To see where in the buffer the -error occurred, switch to the @samp{*Info Region*} buffer; the cursor -will be in a position that is after the location of the error. Also, -the text will not be formatted after the place where the error -occurred (or more precisely, where it was detected).@refill - -For example, if you accidentally end a menu with the command @code{@@end -menus} with an `s' on the end, instead of with @code{@@end menu}, you -will see an error message that says:@refill - -@example -@@end menus is not handled by texinfo -@end example - -@noindent -The cursor will stop at the point in the buffer where the error -occurs, or not long after it. The buffer will look like this:@refill - -@example -@group ----------- Buffer: *Info Region* ---------- -* Menu: - -* Using texinfo-show-structure:: How to use - `texinfo-show-structure' - to catch mistakes. -* Running Info-Validate:: How to check for - unreferenced nodes. -@@end menus -@point{} ----------- Buffer: *Info Region* ---------- -@end group -@end example - -The @code{texinfo-format-region} command sometimes provides slightly -odd error messages. For example, the following cross reference fails to format:@refill - -@example -(@@xref@{Catching Mistakes, for more info.) -@end example - -@noindent -In this case, @code{texinfo-format-region} detects the missing closing -brace but displays a message that says @samp{Unbalanced parentheses} -rather than @samp{Unbalanced braces}. This is because the formatting -command looks for mismatches between braces as if they were -parentheses.@refill - -Sometimes @code{texinfo-format-region} fails to detect mistakes. For -example, in the following, the closing brace is swapped with the -closing parenthesis:@refill - -@example -(@@xref@{Catching Mistakes), for more info.@} -@end example - -@noindent -Formatting produces: -@example -(*Note for more info.: Catching Mistakes) -@end example - -The only way for you to detect this error is to realize that the -reference should have looked like this:@refill - -@example -(*Note Catching Mistakes::, for more info.) -@end example - -Incidentally, if you are reading this node in Info and type @kbd{f -@key{RET}} (@code{Info-follow-reference}), you will generate an error -message that says: - -@example -No such node: "Catching Mistakes) The only way @dots{} -@end example - -@noindent -This is because Info perceives the example of the error as the first -cross reference in this node and if you type a @key{RET} immediately -after typing the Info @kbd{f} command, Info will attempt to go to the -referenced node. If you type @kbd{f catch @key{TAB} @key{RET}}, Info -will complete the node name of the correctly written example and take -you to the `Catching Mistakes' node. (If you try this, you can return -from the `Catching Mistakes' node by typing @kbd{l} -(@code{Info-last}).) - -@c !!! section on using Elisp debugger ignored. -@ignore -Sometimes @code{texinfo-format-region} will stop long after the -original error; this is because it does not discover the problem until -then. In this case, you will need to backtrack.@refill - -@c menu -@c * Using the Emacs Lisp Debugger:: How to use the Emacs Lisp debugger. -@c end menu - -@c node Using the Emacs Lisp Debugger -@c appendixsubsec Using the Emacs Lisp Debugger -@c index Using the Emacs Lisp debugger -@c index Emacs Lisp debugger -@c index Debugger, using the Emacs Lisp - -If an error is especially elusive, you can turn on the Emacs Lisp -debugger and look at the backtrace; this tells you where in the -@code{texinfo-format-region} function the problem occurred. You can -turn on the debugger with the command:@refill - -@example -M-x set-variable @key{RET} debug-on-error @key{RET} t @key{RET} -@end example - -@noindent -and turn it off with - -@example -M-x set-variable @key{RET} debug-on-error @key{RET} nil @key{RET} -@end example - -Often, when you are using the debugger, it is easier to follow what is -going on if you use the Emacs Lisp files that are not byte-compiled. -The byte-compiled sources send octal numbers to the debugger that may -look mysterious. To use the uncompiled source files, load -@file{texinfmt.el} and @file{texinfo.el} with the @kbd{M-x load-file} -command.@refill - -The debugger will not catch an error if @code{texinfo-format-region} -does not detect one. In the example shown above, -@code{texinfo-format-region} did not find the error when the whole -list was formatted, but only when part of the list was formatted. -When @code{texinfo-format-region} did not find an error, the debugger -did not find one either. @refill - -However, when @code{texinfo-format-region} did report an error, it -invoked the debugger. This is the backtrace it produced:@refill - -@example ----------- Buffer: *Backtrace* ---------- -Signalling: (search-failed "[@},]") - re-search-forward("[@},]") - (while ...) - (let ...) - texinfo-format-parse-args() - (let ...) - texinfo-format-xref() - funcall(texinfo-format-xref) - (if ...) - (let ...) - (if ...) - (while ...) - texinfo-format-scan() - (save-excursion ...) - (let ...) - texinfo-format-region(103370 103631) -* call-interactively(texinfo-format-region) ----------- Buffer: *Backtrace* ---------- -@end example - -The backtrace is read from the bottom up. -@code{texinfo-format-region} was called interactively; and it, in -turn, called various functions, including @code{texinfo-format-scan}, -@code{texinfo-format-xref} and @code{texinfo-format-parse-args}. -Inside the function @code{texinfo-format-parse-args}, the function -@code{re-search-forward} was called; it was this function that could -not find the missing right-hand brace.@refill - -@xref{Lisp Debug, , Debugging Emacs Lisp, emacs, The GNU Emacs -Manual}, for more information.@refill -@end ignore - -@node Debugging with TeX, Using texinfo-show-structure, Debugging with Info, Catching Mistakes -@comment node-name, next, previous, up -@appendixsec Catching Errors with @TeX{} Formatting -@cindex Catching errors with @TeX{} formatting -@cindex Debugging with @TeX{} formatting - -You can also catch mistakes when you format a file with @TeX{}.@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -Usually, you do this after you have run -@code{texinfo-format-buffer} (or, better, @code{makeinfo-buffer}) on -the same file, because @code{texinfo-format-buffer} sometimes displays -error messages that make more sense than @TeX{}. (@xref{Debugging -with Info}, for more information.)@refill - -For example, @TeX{} was run on a Texinfo file, part of which is shown -here:@refill - -@example ----------- Buffer: texinfo.texi ---------- -name of the texinfo file as an extension. The -@@samp@{??@} are `wildcards' that cause the shell to -substitute all the raw index files. (@@xref@{sorting -indices, for more information about sorting -indices.)@@refill ----------- Buffer: texinfo.texi ---------- -@end example - -@noindent -(The cross reference lacks a closing brace.) -@TeX{} produced the following output, after which it stopped:@refill - -@example ----------- Buffer: *texinfo-tex-shell* ---------- -Runaway argument? -@{sorting indices, for more information about sorting -indices.) @@refill @@ETC. -! Paragraph ended before @@xref was complete. - - @@par -l.27 - -? ----------- Buffer: *texinfo-tex-shell* ---------- -@end example - -In this case, @TeX{} produced an accurate and -understandable error message: - -@example -Paragraph ended before @@xref was complete. -@end example - -@noindent -@samp{@@par} is an internal @TeX{} command of no relevance to Texinfo. -@samp{l.27} means that @TeX{} detected the problem on line 27 of the -Texinfo file. The @samp{?} is the prompt @TeX{} uses in this -circumstance.@refill - -Unfortunately, @TeX{} is not always so helpful, and sometimes you must -truly be a Sherlock Holmes to discover what went wrong.@refill - -In any case, if you run into a problem like this, you can do one of three -things.@refill - -@enumerate -@item -You can tell @TeX{} to continue running and ignore just this error by -typing @key{RET} at the @samp{?} prompt.@refill - -@item -You can tell @TeX{} to continue running and to ignore all errors as best -it can by typing @kbd{r @key{RET}} at the @samp{?} prompt.@refill - -This is often the best thing to do. However, beware: the one error -may produce a cascade of additional error messages as its consequences -are felt through the rest of the file. (To stop @TeX{} when it is -producing such an avalanche of error messages, type @kbd{C-d} (or -@kbd{C-c C-d}, if you are running a shell inside Emacs Version 18.))@refill - -@item -You can tell @TeX{} to stop this run by typing @kbd{x @key{RET}} -at the @samp{?} prompt.@refill -@end enumerate - -Please note that if you are running @TeX{} inside Emacs, you need to -switch to the shell buffer and line at which @TeX{} offers the @samp{?} -prompt.@refill - -Sometimes @TeX{} will format a file without producing error messages even -though there is a problem. This usually occurs if a command is not ended -but @TeX{} is able to continue processing anyhow. For example, if you fail -to end an itemized list with the @code{@@end itemize} command, @TeX{} will -write a @sc{dvi} file that you can print out. The only error message that -@TeX{} will give you is the somewhat mysterious comment that@refill - -@example -(@@end occurred inside a group at level 1) -@end example - -@noindent -However, if you print the @sc{dvi} file, you will find that the text -of the file that follows the itemized list is entirely indented as if -it were part of the last item in the itemized list. The error message -is the way @TeX{} says that it expected to find an @code{@@end} -command somewhere in the file; but that it could not determine where -it was needed.@refill - -Another source of notoriously hard-to-find errors is a missing -@code{@@end group} command. If you ever are stumped by -incomprehensible errors, look for a missing @code{@@end group} command -first.@refill - -If the Texinfo file lacks header lines, -@TeX{} may stop in the -beginning of its run and display output that looks like the following. -The @samp{*} indicates that @TeX{} is waiting for input.@refill - -@example -This is TeX, Version 2.0 for Berkeley UNIX -(preloaded format=plain-cm 87.10.25) -(test.texinfo [1]) -* -@end example - -@noindent -In this case, simply type @kbd{\end @key{RET}} after the asterisk. Then -write the header lines in the Texinfo file and run the @TeX{} command -again. (Note the use of the backslash, @samp{\}. @TeX{} uses @samp{\} -instead of @samp{@@}; and in this circumstance, you are working -directly with @TeX{}, not with Texinfo.)@refill - -@node Using texinfo-show-structure, Using occur, Debugging with TeX, Catching Mistakes -@comment node-name, next, previous, up -@appendixsec Using @code{texinfo-show-structure} -@cindex Showing the structure of a file -@findex texinfo-show-structure - -It is not always easy to keep track of the nodes, chapters, sections, and -subsections of a Texinfo file. This is especially true if you are revising -or adding to a Texinfo file that someone else has written.@refill - -In GNU Emacs, in Texinfo mode, the @code{texinfo-show-structure} -command lists all the lines that begin with the @@-commands that -specify the structure: @code{@@chapter}, @code{@@section}, -@code{@@appendix}, and so on. With an argument (@w{@kbd{C-u}} -as prefix argument, if interactive), -the command also shows the @code{@@node} lines. The -@code{texinfo-show-structure} command is bound to @kbd{C-c C-s} in -Texinfo mode, by default.@refill - -The lines are displayed in a buffer called the @samp{*Occur*} buffer. -For example, when @code{texinfo-show-structure} was run on an earlier -version of this appendix, it produced the following:@refill - -@smallexample -Lines matching "^@@\\(chapter \\|sect\\|sub\\|unnum\\|major\\| -heading \\|appendix\\)" in buffer texinfo.texi. - 4:@@appendix Formatting Mistakes - 52:@@appendixsec Catching Errors with Info Formatting -222:@@appendixsec Catching Errors with @@TeX@{@} Formatting -338:@@appendixsec Using @@code@{texinfo-show-structure@} -407:@@appendixsubsec Using @@code@{occur@} -444:@@appendixsec Finding Badly Referenced Nodes -513:@@appendixsubsec Running @@code@{Info-validate@} -573:@@appendixsubsec Splitting a File Manually -@end smallexample - -This says that lines 4, 52, and 222 of @file{texinfo.texi} begin with -the @code{@@appendix}, @code{@@appendixsec}, and @code{@@appendixsec} -commands respectively. If you move your cursor into the @samp{*Occur*} -window, you can position the cursor over one of the lines and use the -@kbd{C-c C-c} command (@code{occur-mode-goto-occurrence}), to jump to -the corresponding spot in the Texinfo file. @xref{Other Repeating -Search, , Using Occur, emacs, The GNU Emacs Manual}, for more -information about @code{occur-mode-goto-occurrence}.@refill - -The first line in the @samp{*Occur*} window describes the @dfn{regular -expression} specified by @var{texinfo-heading-pattern}. This regular -expression is the pattern that @code{texinfo-show-structure} looks for. -@xref{Regexps, , Using Regular Expressions, emacs, The GNU Emacs Manual}, -for more information.@refill - -When you invoke the @code{texinfo-show-structure} command, Emacs will -display the structure of the whole buffer. If you want to see the -structure of just a part of the buffer, of one chapter, for example, -use the @kbd{C-x n} (@code{narrow-to-region}) command to mark the -region. (@xref{Narrowing, , , emacs, The GNU Emacs Manual}.) This is -how the example used above was generated. (To see the whole buffer -again, use @kbd{C-x w} (@code{widen}).)@refill - -If you call @code{texinfo-show-structure} with a prefix argument by -typing @w{@kbd{C-u C-c C-s}}, it will list lines beginning with -@code{@@node} as well as the lines beginning with the @@-sign commands -for @code{@@chapter}, @code{@@section}, and the like.@refill - -You can remind yourself of the structure of a Texinfo file by looking at -the list in the @samp{*Occur*} window; and if you have mis-named a node -or left out a section, you can correct the mistake.@refill - -@node Using occur, Running Info-Validate, Using texinfo-show-structure, Catching Mistakes -@comment node-name, next, previous, up -@appendixsec Using @code{occur} -@cindex Occurrences, listing with @code{@@occur} -@findex occur - -Sometimes the @code{texinfo-show-structure} command produces too much -information. Perhaps you want to remind yourself of the overall structure -of a Texinfo file, and are overwhelmed by the detailed list produced by -@code{texinfo-show-structure}. In this case, you can use the @code{occur} -command directly. To do this, type@refill - -@example -@kbd{M-x occur} -@end example - -@noindent -and then, when prompted, type a @dfn{regexp}, a regular expression for -the pattern you want to match. (@xref{Regexps, , Regular Expressions, -emacs, The GNU Emacs Manual}.) The @code{occur} command works from -the current location of the cursor in the buffer to the end of the -buffer. If you want to run @code{occur} on the whole buffer, place -the cursor at the beginning of the buffer.@refill - -For example, to see all the lines that contain the word -@samp{@@chapter} in them, just type @samp{@@chapter}. This will -produce a list of the chapters. It will also list all the sentences -with @samp{@@chapter} in the middle of the line.@refill - -If you want to see only those lines that start with the word -@samp{@@chapter}, type @samp{^@@chapter} when prompted by -@code{occur}. If you want to see all the lines that end with a word -or phrase, end the last word with a @samp{$}; for example, -@samp{catching mistakes$}. This can be helpful when you want to see -all the nodes that are part of the same chapter or section and -therefore have the same `Up' pointer.@refill - -@xref{Other Repeating Search, , Using Occur, emacs , The GNU Emacs Manual}, -for more information.@refill - -@node Running Info-Validate, , Using occur, Catching Mistakes -@comment node-name, next, previous, up -@appendixsec Finding Badly Referenced Nodes -@findex Info-validate -@cindex Nodes, checking for badly referenced -@cindex Checking for badly referenced nodes -@cindex Looking for badly referenced nodes -@cindex Finding badly referenced nodes -@cindex Badly referenced nodes - -You can use the @code{Info-validate} command to check whether any of -the `Next', `Previous', `Up' or other node pointers fail to point to a -node. This command checks that every node pointer points to an -existing node. The @code{Info-validate} command works only on Info -files, not on Texinfo files.@refill - -The @code{makeinfo} program validates pointers automatically, so you -do not need to use the @code{Info-validate} command if you are using -@code{makeinfo}. You only may need to use @code{Info-validate} if you -are unable to run @code{makeinfo} and instead must create an Info file -using @code{texinfo-format-region} or @code{texinfo-format-buffer}, or -if you write an Info file from scratch.@refill - -@menu -* Using Info-validate:: How to run @code{Info-validate}. -* Unsplit:: How to create an unsplit file. -* Tagifying:: How to tagify a file. -* Splitting:: How to split a file manually. -@end menu - -@node Using Info-validate, Unsplit, , Running Info-Validate -@appendixsubsec Running @code{Info-validate} -@cindex Running @code{Info-validate} -@cindex Info validating a large file -@cindex Validating a large file - -To use @code{Info-validate}, visit the Info file you wish to check and -type:@refill - -@example -M-x Info-validate -@end example - -@noindent -(Note that the @code{Info-validate} command requires an upper case -`I'. You may also need to create a tag table before running -@code{Info-validate}. @xref{Tagifying}.)@refill - -If your file is valid, you will receive a message that says ``File appears -valid''. However, if you have a pointer that does not point to a node, -error messages will be displayed in a buffer called @samp{*problems in -info file*}.@refill - -For example, @code{Info-validate} was run on a test file that contained -only the first node of this manual. One of the messages said:@refill - -@example -In node "Overview", invalid Next: Texinfo Mode -@end example - -@noindent -This meant that the node called @samp{Overview} had a `Next' pointer that -did not point to anything (which was true in this case, since the test file -had only one node in it).@refill - -Now suppose we add a node named @samp{Texinfo Mode} to our test case -but we do not specify a `Previous' for this node. Then we will get -the following error message:@refill - -@example -In node "Texinfo Mode", should have Previous: Overview -@end example - -@noindent -This is because every `Next' pointer should be matched by a -`Previous' (in the node where the `Next' points) which points back.@refill - -@code{Info-validate} also checks that all menu entries and cross references -point to actual nodes.@refill - -Note that @code{Info-validate} requires a tag table and does not work -with files that have been split. (The @code{texinfo-format-buffer} -command automatically splits large files.) In order to use -@code{Info-validate} on a large file, you must run -@code{texinfo-format-buffer} with an argument so that it does not split -the Info file; and you must create a tag table for the unsplit -file.@refill - -@node Unsplit, Tagifying, Using Info-validate, Running Info-Validate -@comment node-name, next, previous, up -@appendixsubsec Creating an Unsplit File -@cindex Creating an unsplit file -@cindex Unsplit file creation - -You can run @code{Info-validate} only on a single Info file that has a -tag table. The command will not work on the indirect subfiles that -are generated when a master file is split. If you have a large file -(longer than 70,000 bytes or so), you need to run the -@code{texinfo-format-buffer} or @code{makeinfo-buffer} command in such -a way that it does not create indirect subfiles. You will also need -to create a tag table for the Info file. After you have done this, -you can run @code{Info-validate} and look for badly referenced -nodes.@refill - -@c !!! broke into two paragraphs to prevent overfull hbox --bob 26 Mar 93 -The first step is to create an unsplit Info file. - -To prevent @code{texinfo-format-buffer} from splitting a Texinfo file -into smaller Info files, give a prefix to the @kbd{M-x -texinfo-format-buffer} command:@refill - -@example -C-u M-x texinfo-format-buffer -@end example - -@noindent -or else - -@example -C-u C-c C-e C-b -@end example - -@noindent -When you do this, Texinfo will not split the file and will not create -a tag table for it. @refill -@cindex Making a tag table manually -@cindex Tag table, making manually - -@node Tagifying, Splitting, Unsplit, Running Info-Validate -@appendixsubsec Tagifying a File - -After creating an unsplit Info file, you must create a tag table for -it. Visit the Info file you wish to tagify and type:@refill - -@example -M-x Info-tagify -@end example - -@noindent -(Note the upper case @key{I} in @code{Info-tagify}.) This creates an -Info file with a tag table that you can validate.@refill - -The third step is to validate the Info file:@refill - -@example -M-x Info-validate -@end example - -@noindent -(Note the upper case @key{I} in @code{Info-validate}.) -In brief, the steps are:@refill - -@example -@group -C-u M-x texinfo-format-buffer -M-x Info-tagify -M-x Info-validate -@end group -@end example - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -After you have validated the node structure, you will be able to rerun -@code{texinfo-format-buffer} in the normal way so it will construct a -tag table and split the file automatically, or you can make the tag -table and split the file manually.@refill - -@node Splitting, , Tagifying, Running Info-Validate -@comment node-name, next, previous, up -@appendixsubsec Splitting a File Manually -@cindex Splitting an Info file manually -@cindex Info file, splitting manually - -You should split a large file or else let the -@code{texinfo-format-buffer} or @code{makeinfo-buffer} command do it -for you automatically. (Generally you will let one of the formatting -commands do this job for you. @xref{Create an Info File}.)@refill - -The split-off files are called the indirect subfiles.@refill - -Info files are split to save memory. With smaller files, Emacs does not -have make such a large buffer to hold the information.@refill - -If an Info file has more than 30 nodes, you should also make a tag -table for it. @xref{Using Info-validate}, for information -about creating a tag table. (Again, tag tables are usually created -automatically by the formatting command; you only need to create a tag -table yourself if you are doing the job manually. Most likely, you -will do this for a large, unsplit file on which you have run -@code{Info-validate}.)@refill - -@c Info-split is autoloaded in `loaddefs.el' in Emacs 18.51 -@ignore -Before running @code{Info-split}, you need to load the @code{info} library -into Emacs by giving the command @kbd{M-x load-library @key{RET} info -@key{RET}}. -@end ignore - -Visit the Info file you wish to tagify and split and type the two -commands:@refill - -@example -M-x Info-tagify -M-x Info-split -@end example - -@noindent -(Note that the @samp{I} in @samp{Info} is upper case.)@refill - -When you use the @code{Info-split} command, the buffer is modified into a -(small) Info file which lists the indirect subfiles. This file should be -saved in place of the original visited file. The indirect subfiles are -written in the same directory the original file is in, with names generated -by appending @samp{-} and a number to the original file name.@refill - -The primary file still functions as an Info file, but it contains just -the tag table and a directory of subfiles.@refill - -@node Refilling Paragraphs, Command Syntax, Catching Mistakes, Top -@comment node-name, next, previous, up -@appendix Refilling Paragraphs -@cindex Refilling paragraphs -@cindex Filling paragraphs -@findex refill - -The @code{@@refill} command refills and, optionally, indents the first -line of a paragraph.@footnote{Perhaps the command should have been -called the @code{@@refillandindent} command, but @code{@@refill} is -shorter and the name was chosen before indenting was possible.} The -@code{@@refill} command is no longer important, but we describe it here -because you once needed it. You will see it in many old Texinfo -files.@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -Without refilling, paragraphs containing long @@-constructs may look -bad after formatting because the formatter removes @@-commands and -shortens some lines more than others. In the past, neither -@code{texinfo-format-region} nor -@code{texinfo-format-buffer} refilled paragraphs -automatically. The @code{@@refill} command had to be written at the -end of every paragraph to cause these formatters to fill them. (Both -@TeX{} and @code{makeinfo} have always refilled paragraphs -automatically.) Now, all the Info formatters automatically fill and -indent those paragraphs that need to be filled and indented.@refill - -@c !!! changed wording to prevent overfull hbox --bob 26 Mar 93 -The @code{@@refill} command causes both the @code{texinfo-format-region} -command and the -@code{texinfo-format-buffer} command to refill a paragraph in the Info file -@emph{after} all the other processing has been done. For this reason, -you can not use @code{@@refill} with a paragraph containing either -@code{@@*} or @code{@@w@{ @dots{} @}} since the refilling action will -override those two commands.@refill - -The @code{texinfo-format-region} and @code{texinfo-format-buffer} -commands now automatically append @code{@@refill} to the end of each -paragraph that should be filled. They do not append @code{@@refill} to -the ends of paragraphs that contain @code{@@*} or @w{@code{@@w@{ @dots{}@}}} -and therefore do not refill or indent them.@refill - -@node Command Syntax, Obtaining TeX, Refilling Paragraphs, Top -@comment node-name, next, previous, up -@appendix @@-Command Syntax -@cindex @@-command syntax - -The character @samp{@@} is used to start special Texinfo commands. -(It has the same meaning that @samp{\} has in Plain@TeX{}.) Texinfo -has four types of @@-command:@refill - -@table @asis -@item 1. Non-alphabetic commands. -These commands consist of an @@ followed by a punctuation mark or other -character that is not part of the alphabet. Non-alphabetic commands -are almost always part of the text within a paragraph, and never take -any argument. The two characters (@@ and the other one) are complete -in themselves; none is followed by braces. The non-alphabetic -commands are: @code{@@.}, @code{@@:}, @code{@@*}, @code{@@@@}, -@code{@@@{}, and @code{@@@}}.@refill - -@item 2. Alphabetic commands that do not require arguments. -These commands start with @@ followed by a word followed by left- and -right-hand braces. These commands insert special symbols in the -document; they do not require arguments. For example, -@code{@@dots@{@}} @result{} @samp{@dots{}}, @code{@@equiv@{@}} -@result{} @samp{@equiv{}}, @code{@@TeX@{@}} @result{} `@TeX{}', -and @code{@@bullet@{@}} @result{} @samp{@bullet{}}.@refill - -@item 3. Alphabetic commands that require arguments within braces. -These commands start with @@ followed by a letter or a word, followed by an -argument within braces. For example, the command @code{@@dfn} indicates -the introductory or defining use of a term; it is used as follows: @samp{In -Texinfo, @@@@-commands are @@dfn@{mark-up@} commands.}@refill - -@item 4. Alphabetic commands that occupy an entire line. -These commands occupy an entire line. The line starts with @@, -followed by the name of the command (a word); for example, @code{@@center} -or @code{@@cindex}. If no argument is needed, the word is followed by -the end of the line. If there is an argument, it is separated from -the command name by a space. Braces are not used.@refill -@end table - -@cindex Braces and argument syntax -Thus, the alphabetic commands fall into classes that have -different argument syntaxes. You cannot tell to which class a command -belongs by the appearance of its name, but you can tell by the -command's meaning: if the command stands for a glyph, it is in -class 2 and does not require an argument; if it makes sense to use the -command together with other text as part of a paragraph, the command -is in class 3 and must be followed by an argument in braces; -otherwise, it is in class 4 and uses the rest of the line as its -argument.@refill - -The purpose of having a different syntax for commands of classes 3 and -4 is to make Texinfo files easier to read, and also to help the GNU -Emacs paragraph and filling commands work properly. There is only one -exception to this rule: the command @code{@@refill}, which is always -used at the end of a paragraph immediately following the final period -or other punctuation character. @code{@@refill} takes no argument and -does @emph{not} require braces. @code{@@refill} never confuses the -Emacs paragraph commands because it cannot appear at the beginning of -a line.@refill - -@node Obtaining TeX, New Features, Command Syntax, Top -@appendix How to Obtain @TeX{} -@cindex Obtaining @TeX{} -@cindex @TeX{}, how to obtain - -@c !!! Here is information about obtaining TeX. Update it whenever. -@c Last updated by RJC on 6 October 1992 -@c based on message from elisabet@@.u.washington.edu -@TeX{} is freely redistributable. You can obtain @TeX{} for Unix -systems from the University of Washington for a distribution -fee.@refill - -To order a full distribution, send $200.00 for a 1/2-inch 9-track 1600 -bpi (@code{tar} or @code{cpio}) tape reel, or $210.00 for a 1/4-inch -4-track QIC-24 (@code{tar} or @code{cpio}) cartridge, to:@refill - -@display -Northwest Computing Support Center -DR-10, Thomson Hall 35 -University of Washington -Seattle, Washington 98195 -@end display - -@noindent -Please make checks payable to the University of Washington.@refill - -Prepaid orders are preferred but purchase orders are acceptable; -however, purchase orders carry an extra charge of $10.00, to pay for -processing.@refill - -Overseas sites: please add to the base cost $20.00 for shipment via -air parcel post, or $30.00 for shipment via courier.@refill - -Please check with the Northwest Computing Support Center at the -University of Washington for current prices and formats:@refill - -@example -@group -@r{telephone:} (206) 543-6259 -@r{email:} elisabet@@u.washington.edu -@end group -@end example - -@node New Features, Command and Variable Index, Obtaining TeX, Top -@appendix Second Edition Features - -@tex -% Widen the space for the first column so three control-character -% strings fit in the first column. Switched back to default .8in -% value at end of chapter. -\global\tableindent=1.0in -@end tex - -The second edition of the Texinfo manual describes more than 20 new -Texinfo mode commands and more than 50 previously undocumented Texinfo -@@-commands. This edition is more than twice the length of the first -edition.@refill - -Here is a brief description of the new commands.@refill - -@menu -* New Texinfo Mode Commands:: The updating commands are especially useful. -* New Commands:: Many newly described @@-commands. -@end menu - -@node New Texinfo Mode Commands, New Commands, , New Features -@appendixsec New Texinfo Mode Commands - -Texinfo mode provides commands and features especially designed for -working with Texinfo files. More than 20 new commands have been -added, including commands for automatically creating and updating -both nodes and menus. This is a tedious task when done by hand.@refill - -The keybindings are intended to be somewhat mnemonic.@refill - -@subheading Update all nodes and menus - -The @code{texinfo-master-menu} command is the primary command: - -@table @kbd -@item C-c C-u m -@itemx M-x texinfo-master-menu -Create or update a master menu. -With @kbd{C-u} as a prefix argument, -first create or update all nodes -and regular menus. -@end table - -@subheading Update Pointers - -@noindent -Create or update `Next', `Previous', and `Up' node pointers.@refill - -@noindent -@xref{Updating Nodes and Menus}. - -@table @kbd -@item C-c C-u C-n -@itemx M-x texinfo-update-node -Update a node. - -@item C-c C-u C-e -@itemx M-x texinfo-every-node-update -Update every node in the buffer. -@end table - -@subheading Update Menus - -@noindent -Create or update menus.@refill - -@noindent -@xref{Updating Nodes and Menus}. - -@table @kbd -@item C-c C-u C-m -@itemx M-x texinfo-make-menu -Make or update a menu. - -@item C-c C-u C-a -@itemx M-x texinfo-all-menus-update -Make or update all the menus in a buffer. -With @kbd{C-u} as a prefix argument, -first update all the nodes. -@end table - -@subheading Insert Title as Description - -@noindent -Insert a node's chapter or section title in the space for the -description in a menu entry line; position point so you can edit the -insert. (This command works somewhat differently than the other -insertion commands, which insert only a predefined string.)@refill - -@noindent -@xref{Inserting, Inserting Frequently Used Commands}. - -@table @kbd -@item C-c C-c C-d -Insert title. -@end table - -@subheading Format for Info - -@noindent -Provide keybindings both for the Info formatting commands that are -written in Emacs Lisp and for @code{makeinfo} that is written in -C.@refill - -@noindent -@xref{Info Formatting}. - -@noindent -Use the Emacs lisp @code{texinfo-format@dots{}} commands: - -@table @kbd -@item C-c C-e C-r -Format the region. - -@item C-c C-e C-b -Format the buffer. -@end table - -@noindent -Use @code{makeinfo}: - -@table @kbd -@item C-c C-m C-r -Format the region. - -@item C-c C-m C-b -Format the buffer. - -@item C-c C-m C-l -Recenter the @code{makeinfo} output buffer. - -@item C-c C-m C-k -Kill the @code{makeinfo} formatting job. -@end table - -@subheading Typeset and Print - -@noindent -Typeset and print Texinfo documents from within Emacs.@refill - -@ifinfo -@noindent -@xref{Printing}. -@end ifinfo -@iftex -@noindent -@xref{Printing, , Formatting and Printing}. -@end iftex - -@table @kbd -@item C-c C-t C-r -Run @TeX{} on the region. - -@item C-c C-t C-b -Run @TeX{} on the buffer. - -@item C-c C-t C-i -Run @code{texindex}. - -@item C-c C-t C-p -Print the @sc{dvi} file. - -@item C-c C-t C-q -Show the print queue. - -@item C-c C-t C-d -Delete a job from the print queue. - -@item C-c C-t C-k -Kill the current @TeX{} formatting job. - -@item C-c C-t C-x -Quit a currently stopped @TeX{} formatting job. - -@item C-c C-t C-l -Recenter the output buffer. -@end table - -@subheading Other Updating Commands - -@noindent -The ``other updating commands'' do not have standard keybindings because -they are used less frequently.@refill - -@noindent -@xref{Other Updating Commands}. - -@table @kbd -@item M-x texinfo-insert-node-lines -Insert missing @code{@@node} lines using -section titles as node names. - -@item M-x texinfo-multiple-files-update -Update a multi-file document. -With a numeric prefix, such as @kbd{C-u 8}, -update @strong{every} pointer and -menu in @strong{all} the files and -then insert a master menu. - -@item M-x texinfo-indent-menu-description -Indent descriptions in menus. - -@item M-x texinfo-sequential-node-update -Insert node pointers in strict sequence. -@end table - -@node New Commands, , New Texinfo Mode Commands, New Features -@appendixsec New Texinfo @@-Commands - -The second edition of the Texinfo manual describes more than 50 -commands that were not described in the first edition. A third or so -of these commands existed in Texinfo but were not documented in the -manual; the others are new. Here is a listing, with brief -descriptions of them:@refill - -@subheading Indexing - -@noindent -Create your own index, and merge indices.@refill - -@noindent -@xref{Indices}. - -@table @kbd -@item @@defindex @var{index-name} -Define a new index and its indexing command. -See also the @code{@@defcodeindex} command. - -@c written verbosely to avoid overful hbox -@item @@synindex @var{from-index} @var{into-index} -Merge the @var{from-index} index into the @var{into-index} index. -See also the @code{@@syncodeindex} command. -@end table - -@subheading Definitions - -@noindent -Describe functions, variables, macros, -commands, user options, special forms, and other such artifacts in a -uniform format.@refill - -@noindent -@xref{Definition Commands}. - -@table @kbd -@item @@deffn @var{category} @var{name} @var{arguments}@dots{} -Format a description for functions, interactive -commands, and similar entities. - -@item @@defvr, @@defop, @dots{} -15 other related commands. -@end table - -@subheading Glyphs - -@noindent -Indicate the results of evaluation, expansion, -printed output, an error message, equivalence of expressions, and the -location of point.@refill - -@noindent -@xref{Glyphs}. - -@table @kbd -@item @@equiv@{@} -@itemx @equiv{} -Equivalence: - -@item @@error@{@} -@itemx @error{} -Error message - -@item @@expansion@{@} -@itemx @expansion{} -Macro expansion - -@item @@point@{@} -@itemx @point{} -Position of point - -@item @@print@{@} -@itemx @print{} -Printed output - -@item @@result@{@} -@itemx @result{} -Result of an expression -@end table - -@subheading Page Headings - -@noindent -Customize page headings. - -@noindent -@xref{Headings}. - -@table @kbd -@item @@headings @var{on-off-single-double} -Headings on or off, single, or double-sided. - -@item @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] -Footings for even-numbered (left-hand) pages. - -@item @@evenheading, @@everyheading, @@oddheading, @dots{} -Five other related commands. - -@item @@thischapter -Insert name of chapter and chapter number. - -@item @@thischaptername, @@thisfile, @@thistitle, @@thispage -Related commands. -@end table - -@subheading Formatting - -@noindent -Format blocks of text. - -@noindent -@xref{Quotations and Examples}, and@* -@ref{Lists and Tables, , Making Lists and Tables}. - -@table @kbd -@item @@cartouche -Draw rounded box surrounding text (not in Info). - -@item @@enumerate @var{optional-arg} -Enumerate a list with letters or numbers. - -@item @@exdent @var{line-of-text} -Remove indentation. - -@item @@flushleft -Left justify. - -@item @@flushright -Right justify. - -@item @@format -Do not narrow nor change font. - -@item @@ftable @var{formatting-command} -@itemx @@vtable @var{formatting-command} -Two-column table with indexing. - -@item @@lisp -For an example of Lisp code. - -@item @@smallexample -@itemx @@smalllisp -Like @@table and @@lisp @r{but for} @@smallbook. -@end table - -@subheading Conditionals - -@noindent -Conditionally format text. - -@noindent -@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill - -@table @kbd -@item @@set @var{flag} [@var{string}] -Set a flag. Optionally, set value -of @var{flag} to @var{string}. - -@item @@clear @var{flag} -Clear a flag. - -@item @@value@{@var{flag}@} -Replace with value to which @var{flag} is set. - -@item @@ifset @var{flag} -Format, if @var{flag} is set. - -@item @@ifclear @var{flag} -Ignore, if @var{flag} is set. -@end table - -@subheading @@heading series for Titles - -@noindent -Produce unnumbered headings that do not appear in a table of contents. - -@noindent -@xref{Structuring}. - -@table @kbd -@item @@heading @var{title} -Unnumbered section-like heading not listed -in the table of contents of a printed manual. - -@item @@chapheading, @@majorheading, @@subheading, @@subsubheading -Related commands. -@end table - -@need 1000 -@subheading Font commands - -@need 1000 -@noindent -@xref{Smallcaps}, and @* -@ref{Fonts}. - -@table @kbd -@item @@r@{@var{text}@} -Print in roman font. - -@item @@sc@{@var{text}@} -Print in @sc{small caps} font. -@end table - -@subheading Miscellaneous - -@noindent -See @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author} Commands},@* -see @ref{Overfull hboxes},@* -see @ref{Footnotes},@* -see @ref{dmn, , Format a Dimension},@* -see @ref{minus, , Inserting a Minus Sign},@* -see @ref{paragraphindent, , Paragraph Indenting},@* -see @ref{Cross Reference Commands},@* -see @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author}}, and@* -see @ref{Custom Headings, , How to Make Your Own Headings}. - -@need 700 -@table @kbd -@item @@author @var{author} -Typeset author's name. - -@item @@finalout -Produce cleaner printed output. - -@item @@footnotestyle -Specify footnote style. - -@item @@dmn@{@var{dimension}@} -Format a dimension. - -@item @@minus@{@} -Generate a minus sign. - -@item @@paragraphindent -Specify paragraph indentation. - -@item @@ref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} -Make a reference. In the printed manual, the -reference does not start with the word `see'. - -@item @@title @var{title} -Typeset @var{title} in the alternative -title page format. - -@item @@subtitle @var{subtitle} -Typeset @var{subtitle} in the alternative -title page format. - -@item @@today@{@} -Insert the current date. -@end table -@tex -% Switch width of first column of tables back to default value -\global\tableindent=.8in -@end tex - -@node Command and Variable Index, Concept Index, New Features, Top -@comment node-name, next, previous, up -@unnumbered Command and Variable Index - -This is an alphabetical list of all the @@-commands and several -variables. To make the list easier to use, the commands are listed -without their preceding @samp{@@}.@refill - -@printindex fn - -@node Concept Index, , Command and Variable Index, Top -@comment node-name, next, previous, up -@unnumbered Concept Index - -@printindex cp - -@summarycontents -@contents -@bye diff --git a/gnu/usr.bin/texinfo/info-files/texi-files/userdoc.texi b/gnu/usr.bin/texinfo/info-files/texi-files/userdoc.texi deleted file mode 100644 index 4ebeae84a581..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi-files/userdoc.texi +++ /dev/null @@ -1,1263 +0,0 @@ -@c This file is meant to be included in any arbitrary piece of -@c documentation that wishes to describe the info program. Some day -@c info-stnd.texi should probably use this file instead of duplicating -@c its contents. -@c -@c This file documents the use of the standalone GNU Info program, -@c versions 2.7 and later. - -@ifclear InfoProgVer -@set InfoProgVer 2.9 -@end ifclear -@synindex vr cp -@synindex fn cp -@synindex ky cp - -@heading What is Info? - -This text documents the use of the GNU Info program, version -@value{InfoProgVer}. - -@dfn{Info} is a program which is used to view info files on an ASCII -terminal. @dfn{info files} are the result of processing texinfo files -with the program @code{makeinfo} or with the Emacs command @code{M-x -texinfo-format-buffer}. Finally, @dfn{texinfo} is a documentation -language which allows a printed manual and online documentation (an info -file) to be produced from a single source file. - -@menu -* Options:: Options you can pass on the command line. -* Cursor Commands:: Commands which move the cursor within a node. -* Scrolling Commands:: Commands for moving the node around in a window. -* Node Commands:: Commands for selecting a new node. -* Searching Commands:: Commands for searching an info file. -* Xref Commands:: Commands for selecting cross references. -* Window Commands:: Commands which manipulate multiple windows. -* Printing Nodes:: How to print out the contents of a node. -* Miscellaneous Commands:: A few commands that defy categories. -* Variables:: How to change the default behaviour of Info. -* Info for Sys Admins:: How to setup Info. Using special options. -@ifset STANDALONE -* GNU Info Global Index:: Global index containing keystrokes, command names, - variable names, and general concepts. -@end ifset -@end menu - -@node Options -@chapter Command Line Options -@cindex command line options -@cindex arguments, command line - -GNU Info accepts several options to control the initial node being -viewed, and to specify which directories to search for info files. Here -is a template showing an invocation of GNU Info from the shell: - -@example -info [--@var{option-name} @var{option-value}] @var{menu-item}@dots{} -@end example - -The following @var{option-names} are available when invoking Info from -the shell: - -@table @code -@cindex directory path -@item --directory @var{directory-path} -@itemx -d @var{directory-path} -Adds @var{directory-path} to the list of directory paths searched when -Info needs to find a file. You may issue @code{--directory} multiple -times; once for each directory which contains info files. -Alternatively, you may specify a value for the environment variable -@code{INFOPATH}; if @code{--directory} is not given, the value of -@code{INFOPATH} is used. The value of @code{INFOPATH} is a colon -separated list of directory names. If you do not supply -@code{INFOPATH} or @code{--directory-path} a default path is used. - -@item --file @var{filename} -@itemx -f @var{filename} -@cindex info file, selecting -Specifies a particular info file to visit. Instead of visiting the file -@code{dir}, Info will start with @code{(@var{filename})Top} as the first -file and node. - -@item --node @var{nodename} -@itemx -n @var{nodename} -@cindex node, selecting -Specifies a particular node to visit in the initial file loaded. This -is especially useful in conjunction with @code{--file}@footnote{Of -course, you can specify both the file and node in a @code{--node} -command; but don't forget to escape the open and close parentheses from -the shell as in: @code{info --node '(emacs)Buffers'}}. You may specify -@code{--node} multiple times; for an interactive Info, each -@var{nodename} is visited in its own window, for a non-interactive Info -(such as when @code{--output} is given) each @var{nodename} is processed -sequentially. - -@item --output @var{filename} -@itemx -o @var{filename} -@cindex file, outputting to -@cindex outputting to a file -Specify @var{filename} as the name of a file to output to. Each node -that Info visits will be output to @var{filename} instead of -interactively viewed. A value of @code{-} for @var{filename} specifies -the standard output. - -@item --subnodes -@cindex @code{--subnodes}, command line option -This option only has meaning when given in conjunction with -@code{--output}. It means to recursively output the nodes appearing in -the menus of each node being output. Menu items which resolve to -external info files are not output, and neither are menu items which are -members of an index. Each node is only output once. - -@item --help -@itemx -h -Produces a relatively brief description of the available Info options. - -@item --version -@cindex version information -Prints the version information of Info and exits. - -@item @var{menu-item} -@cindex menu, following -Remaining arguments to Info are treated as the names of menu items. The -first argument would be a menu item in the initial node visited, while -the second argument would be a menu item in the first argument's node. -You can easily move to the node of your choice by specifying the menu -names which describe the path to that node. For example, - -@example -info emacs buffers -@end example - -first selects the menu item @samp{Emacs} in the node @samp{(dir)Top}, -and then selects the menu item @samp{Buffers} in the node -@samp{(emacs)Top}. - -@end table - -@node Cursor Commands -@chapter Moving the Cursor -@cindex cursor, moving -Many people find that reading screens of text page by page is made -easier when one is able to indicate particular pieces of text with some -kind of pointing device. Since this is the case, GNU Info (both the -Emacs and standalone versions) have several commands which allow you to -move the cursor about the screen. The notation used in this manual to -describe keystrokes is identical to the notation used within the Emacs -manual, and the GNU Readline manual. @xref{Characters, , Character -Conventions, emacs, the GNU Emacs Manual}, if you are unfamilar with the -notation. - -The following table lists the basic cursor movement commands in Info. -Each entry consists of the key sequence you should type to execute the -cursor movement, the @code{M-x}@footnote{@code{M-x} is also a command; it -invokes @code{execute-extended-command}. @xref{M-x, , Executing an -extended command, emacs, the GNU Emacs Manual}, for more detailed -information.} command name (displayed in parentheses), and a short -description of what the command does. All of the cursor motion commands -can take an @dfn{numeric} argument (@pxref{Miscellaneous Commands, -@code{universal-argument}}), to find out how to supply them. With a -numeric argument, the motion commands are simply executed that -many times; for example, a numeric argument of 4 given to -@code{next-line} causes the cursor to move down 4 lines. With a -negative numeric argument, the motion is reversed; an argument of -4 -given to the @code{next-line} command would cause the cursor to move -@emph{up} 4 lines. - -@table @asis -@item @code{C-n} (@code{next-line}) -@kindex C-n -@findex next-line -Moves the cursor down to the next line. - -@item @code{C-p} (@code{prev-line}) -@kindex C-p -@findex prev-line -Move the cursor up to the previous line. - -@item @code{C-a} (@code{beginning-of-line}) -@kindex C-a, in Info windows -@findex beginning-of-line -Move the cursor to the start of the current line. - -@item @code{C-e} (@code{end-of-line}) -@kindex C-e, in Info windows -@findex end-of-line -Moves the cursor to the end of the current line. - -@item @code{C-f} (@code{forward-char}) -@kindex C-f, in Info windows -@findex forward-char -Move the cursor forward a character. - -@item @code{C-b} (@code{backward-char}) -@kindex C-b, in Info windows -@findex backward-char -Move the cursor backward a character. - -@item @code{M-f} (@code{forward-word}) -@kindex M-f, in Info windows -@findex forward-word -Moves the cursor forward a word. - -@item @code{M-b} (@code{backward-word}) -@kindex M-b, in Info winows -@findex backward-word -Moves the cursor backward a word. - -@item @code{M-<} (@code{beginning-of-node}) -@itemx @code{b} -@kindex b, in Info winows -@kindex M-< -@findex beginning-of-node -Moves the cursor to the start of the current node. - -@item @code{M->} (@code{end-of-node}) -@kindex M-> -@findex end-of-node -Moves the cursor to the end of the current node. - -@item @code{M-r} (@code{move-to-window-line}) -@kindex M-r -@findex move-to-window-line -Moves the cursor to a specific line of the window. Without a numeric -argument, @code{M-r} moves the cursor to the start of the line in the -center of the window. With a numeric argument of @var{n}, @code{M-r} -moves the cursor to the start of the @var{n}th line in the window. -@end table - -@node Scrolling Commands -@chapter Moving Text Within a Window -@cindex scrolling - -Sometimes you are looking at a screenful of text, and only part of the -current paragraph you are reading is visible on the screen. The -commands detailed in this section are used to shift which part of the -current node is visible on the screen. - -@table @asis -@item @code{SPC} (@code{scroll-forward}) -@itemx @code{C-v} -@kindex SPC, in Info windows -@kindex C-v -@findex scroll-forward -Shift the text in this window up. That is, show more of the node which -is currently below the bottom of the window. With a numeric argument, -show that many more lines at the bottom of the window; a numeric -argument of 4 would shift all of the text in the window up 4 lines -(discarding the top 4 lines), and show you four new lines at the bottom -of the window. Without a numeric argument, @key{SPC} takes the bottom -two lines of the window and places them at the top of the window, -redisplaying almost a completely new screenful of lines. - -@item @code{DEL} (@code{scroll-backward}) -@itemx @code{M-v} -@kindex DEL, in Info windows -@kindex M-v -@findex scroll-backward -Shift the text in this window down. The inverse of -@code{scroll-forward}. - -@end table - -@cindex scrolling through node structure -The @code{scroll-forward} and @code{scroll-backward} commands can also -move forward and backward through the node structure of the file. If -you press @key{SPC} while viewing the end of a node, or @key{DEL} while -viewing the beginning of a node, what happens is controlled by the -variable @code{scroll-behaviour}. @xref{Variables, -@code{scroll-behaviour}}, for more information. - -@table @asis -@item @code{C-l} (@code{redraw-display}) -@kindex C-l -@findex redraw-display -Redraw the display from scratch, or shift the line containing the cursor -to a specified location. With no numeric argument, @samp{C-l} clears -the screen, and then redraws its entire contents. Given a numeric -argument of @var{n}, the line containing the cursor is shifted so that -it is on the @var{n}th line of the window. - -@item @code{C-x w} (@code{toggle-wrap}) -@kindex C-w -@findex toggle-wrap -Toggles the state of line wrapping in the current window. Normally, -lines which are longer than the screen width @dfn{wrap}, i.e., they are -continued on the next line. Lines which wrap have a @samp{\} appearing -in the rightmost column of the screen. You can cause such lines to be -terminated at the rightmost column by changing the state of line -wrapping in the window with @code{C-x w}. When a line which needs more -space than one screen width to display is displayed, a @samp{$} appears -in the rightmost column of the screen, and the remainder of the line is -invisible. -@end table - -@node Node Commands -@chapter Selecting a New Node -@cindex nodes, selection of - -This section details the numerous Info commands which select a new node -to view in the current window. - -The most basic node commands are @samp{n}, @samp{p}, @samp{u}, and -@samp{l}. - -When you are viewing a node, the top line of the node contains some Info -@dfn{pointers} which describe where the next, previous, and up nodes -are. Info uses this line to move about the node structure of the file -when you use the following commands: - -@table @asis -@item @code{n} (@code{next-node}) -@kindex n -@findex next-node -Selects the `Next' node. - -@item @code{p} (@code{prev-node}) -@kindex p -@findex prev-node -Selects the `Prev' node. - -@item @code{u} (@code{up-node}) -@kindex u -@findex up-node -Selects the `Up' node. -@end table - -You can easily select a node that you have already viewed in this window -by using the @samp{l} command -- this name stands for "last", and -actually moves through the list of already visited nodes for this -window. @samp{l} with a negative numeric argument moves forward through -the history of nodes for this window, so you can quickly step between -two adjacent (in viewing history) nodes. - -@table @asis -@item @code{l} (@code{history-node}) -@kindex l -@findex history-node -Selects the most recently selected node in this window. -@end table - -Two additional commands make it easy to select the most commonly -selected nodes; they are @samp{t} and @samp{d}. - -@table @asis -@item @code{t} (@code{top-node}) -@kindex t -@findex top-node -Selects the node @samp{Top} in the current info file. - -@item @code{d} (@code{dir-node}) -@kindex d -@findex dir-node -Selects the directory node (i.e., the node @samp{(dir)}). -@end table - -Here are some other commands which immediately result in the selection -of a different node in the current window: - -@table @asis -@item @code{<} (@code{first-node}) -@kindex < -@findex first-node -Selects the first node which appears in this file. This node is most -often @samp{Top}, but it doesn't have to be. - -@item @code{>} (@code{last-node}) -@kindex > -@findex last-node -Selects the last node which appears in this file. - -@item @code{]} (@code{global-next-node}) -@kindex ] -@findex global-next-node -Moves forward or down through node structure. If the node that you are -currently viewing has a @samp{Next} pointer, that node is selected. -Otherwise, if this node has a menu, the first menu item is selected. If -there is no @samp{Next} and no menu, the same process is tried with the -@samp{Up} node of this node. - -@item @code{[} (@code{global-prev-node}) -@kindex [ -@findex global-prev-node -Moves backward or up through node structure. If the node that you are -currently viewing has a @samp{Prev} pointer, that node is selected. -Otherwise, if the node has an @samp{Up} pointer, that node is selected, -and if it has a menu, the last item in the menu is selected. -@end table - -You can get the same behaviour as @code{global-next-node} and -@code{global-prev-node} while simply scrolling through the file with -@key{SPC} and @key{DEL}; @xref{Variables, @code{scroll-behaviour}}, for -more information. - -@table @asis -@item @code{g} (@code{goto-node}) -@kindex g -@findex goto-node -Reads the name of a node and selects it. No completion is done while -reading the node name, since the desired node may reside in a separate -file. The node must be typed exactly as it appears in the info file. A -file name may be included as with any node specification, for example - -@example -@code{g(emacs)Buffers} -@end example - -finds the node @samp{Buffers} in the info file @file{emacs}. - -@item @code{C-x k} (@code{kill-node}) -@kindex C-x k -@findex kill-node -Kills a node. The node name is prompted for in the echo area, with a -default of the current node. @dfn{Killing} a node means that Info tries -hard to forget about it, removing it from the list of history nodes kept -for the window where that node is found. Another node is selected in -the window which contained the killed node. - -@item @code{C-x C-f} (@code{view-file}) -@kindex C-x C-f -@findex view-file -Reads the name of a file and selects the entire file. The command -@example -@code{C-x C-f @var{filename}} -@end example -is equivalent to typing -@example -@code{g(@var{filename})*} -@end example - -@item @code{C-x C-b} (@code{list-visited-nodes}) -@kindex C-x C-b -@findex list-visited-nodes -Makes a window containing a menu of all of the currently visited nodes. -This window becomes the selected window, and you may use the standard -Info commands within it. - -@item @code{C-x b} (@code{select-visited-node}) -@kindex C-x b -@findex select-visited-node -Selects a node which has been previously visited in a visible window. -This is similar to @samp{C-x C-b} followed by @samp{m}, but no window is -created. -@end table - -@node Searching Commands -@chapter Searching an Info File -@cindex searching - -GNU Info allows you to search for a sequence of characters throughout an -entire info file, search through the indices of an info file, or find -areas within an info file which discuss a particular topic. - -@table @asis -@item @code{s} (@code{search}) -@kindex s -@findex search -Reads a string in the echo area and searches for it. - -@item @code{C-s} (@code{isearch-forward}) -@kindex C-s -@findex isearch-forward -Interactively searches forward through the info file for a string as you -type it. - -@item @code{C-r} (@code{isearch-backward}) -@kindex C-r -@findex isearch-backward -Interactively searches backward through the info file for a string as -you type it. - -@item @code{i} (@code{index-search}) -@kindex i -@findex index-search -Looks up a string in the indices for this info file, and selects a node -where the found index entry points to. - -@item @code{,} (@code{next-index-match}) -@kindex , -@findex next-index-match -Moves to the node containing the next matching index item from the last -@samp{i} command. -@end table - -The most basic searching command is @samp{s} (@code{search}). The -@samp{s} command prompts you for a string in the echo area, and then -searches the remainder of the info file for an ocurrence of that string. -If the string is found, the node containing it is selected, and the -cursor is left positioned at the start of the found string. Subsequent -@samp{s} commands show you the default search string within @samp{[} and -@samp{]}; pressing @key{RET} instead of typing a new string will use the -default search string. - -@dfn{Incremental searching} is similar to basic searching, but the -string is looked up while you are typing it, instead of waiting until -the entire search string has been specified. - -@node Xref Commands -@chapter Selecting Cross References - -We have already discussed the @samp{Next}, @samp{Prev}, and @samp{Up} -pointers which appear at the top of a node. In addition to these -pointers, a node may contain other pointers which refer you to a -different node, perhaps in another info file. Such pointers are called -@dfn{cross references}, or @dfn{xrefs} for short. - -@menu -* Parts of an Xref:: What a cross reference is made of. -* Selecting Xrefs:: Commands for selecting menu or note items. -@end menu - -@node Parts of an Xref -@section Parts of an Xref - -Cross references have two major parts: the first part is called the -@dfn{label}; it is the name that you can use to refer to the cross -reference, and the second is the @dfn{target}; it is the full name of -the node that the cross reference points to. - -The target is separated from the label by a colon @samp{:}; first the -label appears, and then the target. For example, in the sample menu -cross reference below, the single colon separates the label from the -target. - -@example -* Foo Label: Foo Target. More information about Foo. -@end example - -Note the @samp{.} which ends the name of the target. The @samp{.} is -not part of the target; it serves only to let Info know where the target -name ends. - -A shorthand way of specifying references allows two adjacent colons to -stand for a target name which is the same as the label name: - -@example -* Foo Commands:: Commands pertaining to Foo. -@end example - -In the above example, the name of the target is the same as the name of -the label, in this case @code{Foo Commands}. - -You will normally see two types of cross references while viewing nodes: -@dfn{menu} references, and @dfn{note} references. Menu references -appear within a node's menu; they begin with a @samp{*} at the beginning -of a line, and continue with a label, a target, and a comment which -describes what the contents of the node pointed to contains. - -Note references appear within the body of the node text; they begin with -@code{*Note}, and continue with a label and a target. - -Like @samp{Next}, @samp{Prev} and @samp{Up} pointers, cross references -can point to any valid node. They are used to refer you to a place -where more detailed information can be found on a particular subject. -Here is a cross reference which points to a node within the Texinfo -documentation: @xref{xref, , Writing an Xref, texinfo, the Texinfo -Manual}, for more information on creating your own texinfo cross -references. - -@node Selecting Xrefs -@section Selecting Xrefs - -The following table lists the Info commands which operate on menu items. - -@table @asis -@item @code{1} (@code{menu-digit}) -@itemx @code{2} @dots{} @code{9} -@cindex 1 @dots{} 9, in Info windows -@kindex 1 @dots{} 9, in Info windows -@findex menu-digit -Within an Info window, pressing a single digit, (such as @samp{1}), -selects that menu item, and places its node in the current window. -For convenience, there is one exception; pressing @samp{0} selects the -@emph{last} item in the node's menu. - -@item @code{0} (@code{last-menu-item}) -@kindex 0, in Info windows -@findex last-menu-item -Select the last item in the current node's menu. - -@item @code{m} (@code{menu-item}) -@kindex m -@findex menu-item -Reads the name of a menu item in the echo area and selects its node. -Completion is available while reading the menu label. - -@item @code{M-x find-menu} -@findex find-menu -Moves the cursor to the start of this node's menu. -@end table - -This table lists the Info commands which operate on note cross references. - -@table @asis -@item @code{f} (@code{xref-item}) -@itemx @code{r} -@kindex f -@kindex r -@findex xref-item -Reads the name of a note cross reference in the echo area and selects -its node. Completion is available while reading the cross reference -label. -@end table - -Finally, the next few commands operate on menu or note references alike: - -@table @asis -@item @code{TAB} (@code{move-to-next-xref}) -@kindex TAB, in Info windows -@findex move-to-next-xref -Moves the cursor to the start of the next nearest menu item or note -reference in this node. You can then use @key{RET} -(@code{select-reference-this-line} to select the menu or note reference. - -@item @code{M-TAB} (@code{move-to-prev-xref}) -@kindex M-TAB, in Info windows -@findex move-to-prev-xref -Moves the cursor the start of the nearest previous menu item or note -reference in this node. - -@item @code{RET} (@code{select-reference-this-line}) -@kindex RET, in Info windows -@findex select-reference-this-line -Selects the menu item or note reference appearing on this line. -@end table - -@node Window Commands -@chapter Manipulating Multiple Windows -@cindex windows, manipulating - -A @dfn{window} is a place to show the text of a node. Windows have a -view area where the text of the node is displayed, and an associated -@dfn{mode line}, which briefly describes the node being viewed. - -GNU Info supports multiple windows appearing in a single screen; each -window is separated from the next by its modeline. At any time, there -is only one @dfn{active} window, that is, the window in which the cursor -appears. There are commands available for creating windows, changing -the size of windows, selecting which window is active, and for deleting -windows. - -@menu -* The Mode Line:: What appears in the mode line? -* Basic Windows:: Manipulating windows in Info. -* The Echo Area:: Used for displaying errors and reading input. -@end menu - -@node The Mode Line -@section The Mode Line - -A @dfn{mode line} is a line of inverse video which appears at the bottom -of an info window. It describes the contents of the window just above -it; this information includes the name of the file and node appearing in -that window, the number of screen lines it takes to display the node, -and the percentage of text that is above the top of the window. It can -also tell you if the indirect tags table for this info file needs to be -updated, and whether or not the info file was compressed when stored on -disk. - -Here is a sample mode line for a window containing an uncompressed file -named @file{dir}, showing the node @samp{Top}. - -@example ------Info: (dir)Top, 40 lines --Top--------------------------------------- - ^^ ^ ^^^ ^^ - (file)Node #lines where -@end example - -When a node comes from a file which is compressed on disk, this is -indicated in the mode line with two small @samp{z}'s. In addition, if -the info file containing the node has been split into subfiles, the name -of the subfile containing the node appears in the modeline as well: - -@example ---zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- -@end example - -When Info makes a node internally, such that there is no corresponding -info file on disk, the name of the node is surrounded by asterisks -(@samp{*}). The name itself tells you what the contents of the window -are; the sample mode line below shows an internally constructed node -showing possible completions: - -@example ------Info: *Completions*, 7 lines --All----------------------------------- -@end example - -@node Basic Windows -@section Window Commands - -It can be convenient to view more than one node at a time. To allow -this, Info can display more than one @dfn{window}. Each window has its -own mode line (@pxref{The Mode Line}) and history of nodes viewed in that -window (@pxref{Node Commands, , @code{history-node}}). - -@table @asis -@item @code{C-x o} (@code{next-window}) -@cindex windows, selecting -@kindex C-x o -@findex next-window -Selects the next window on the screen. Note that the echo area can only be -selected if it is already in use, and you have left it temporarily. -Normally, @samp{C-x o} simply moves the cursor into the next window on -the screen, or if you are already within the last window, into the first -window on the screen. Given a numeric argument, @samp{C-x o} moves over -that many windows. A negative argument causes @samp{C-x o} to select -the previous window on the screen. - -@item @code{M-x prev-window} -@findex prev-window -Selects the previous window on the screen. This is identical to -@samp{C-x o} with a negative argument. - -@item @code{C-x 2} (@code{split-window}) -@cindex windows, creating -@kindex C-x 2 -@findex split-window -Splits the current window into two windows, both showing the same node. -Each window is one half the size of the original window, and the cursor -remains in the original window. The variable @code{automatic-tiling} -can cause all of the windows on the screen to be resized for you -automatically, please @pxref{Variables, , automatic-tiling} for more -information. - -@item @code{C-x 0} (@code{delete-window}) -@cindex windows, deleting -@kindex C-x 0 -@findex delete-window -Deletes the current window from the screen. If you have made too many -windows and your screen appears cluttered, this is the way to get rid of -some of them. - -@item @code{C-x 1} (@code{keep-one-window}) -@kindex C-x 1 -@findex keep-one-window -Deletes all of the windows excepting the current one. - -@item @code{ESC C-v} (@code{scroll-other-window}) -@kindex ESC C-v, in Info windows -@findex scroll-other-window -Scrolls the other window, in the same fashion that @samp{C-v} might -scroll the current window. Given a negative argument, the "other" -window is scrolled backward. - -@item @code{C-x ^} (@code{grow-window}) -@kindex C-x ^ -@findex grow-window -Grows (or shrinks) the current window. Given a numeric argument, grows -the current window that many lines; with a negative numeric argument, -the window is shrunk instead. - -@item @code{C-x t} (@code{tile-windows}) -@cindex tiling -@kindex C-x t -@findex tile-windows -Divides the available screen space among all of the visible windows. -Each window is given an equal portion of the screen in which to display -its contents. The variable @code{automatic-tiling} can cause -@code{tile-windows} to be called when a window is created or deleted. -@xref{Variables, , @code{automatic-tiling}}. -@end table - -@node The Echo Area -@section The Echo Area -@cindex echo area - -The @dfn{echo area} is a one line window which appears at the bottom of -the screen. It is used to display informative or error messages, and to -read lines of input from you when that is necessary. Almost all of the -commands available in the echo area are identical to their Emacs -counterparts, so please refer to that documentation for greater depth of -discussion on the concepts of editing a line of text. The following -table briefly lists the commands that are available while input is being -read in the echo area: - -@table @asis -@item @code{C-f} (@code{echo-area-forward}) -@kindex C-f, in the echo area -@findex echo-area-forward -Moves forward a character. - -@item @code{C-b} (@code{echo-area-backward}) -@kindex C-b, in the echo area -@findex echo-area-backward -Moves backward a character. - -@item @code{C-a} (@code{echo-area-beg-of-line}) -@kindex C-a, in the echo area -@findex echo-area-beg-of-line -Moves to the start of the input line. - -@item @code{C-e} (@code{echo-area-end-of-line}) -@kindex C-e, in the echo area -@findex echo-area-end-of-line -Moves to the end of the input line. - -@item @code{M-f} (@code{echo-area-forward-word}) -@kindex M-f, in the echo area -@findex echo-area-forward-word -Moves forward a word. - -@item @code{M-b} (@code{echo-area-backward-word}) -@kindex M-b, in the echo area -@findex echo-area-backward-word -Moves backward a word. - -@item @code{C-d} (@code{echo-area-delete}) -@kindex C-d, in the echo area -@findex echo-area-delete -Deletes the character under the cursor. - -@item @code{DEL} (@code{echo-area-rubout}) -@kindex DEL, in the echo area -@findex echo-area-rubout -Deletes the character behind the cursor. - -@item @code{C-g} (@code{echo-area-abort}) -@kindex C-g, in the echo area -@findex echo-area-abort -Cancels or quits the current operation. If completion is being read, -@samp{C-g} discards the text of the input line which does not match any -completion. If the input line is empty, @samp{C-g} aborts the calling -function. - -@item @code{RET} (@code{echo-area-newline}) -@kindex RET, in the echo area -@findex echo-area-newline -Accepts (or forces completion of) the current input line. - -@item @code{C-q} (@code{echo-area-quoted-insert}) -@kindex C-q, in the echo area -@findex echo-area-quoted-insert -Inserts the next character verbatim. This is how you can insert control -characters into a search string, for example. - -@item @var{printing character} (@code{echo-area-insert}) -@kindex printing characters, in the echo area -@findex echo-area-insert -Inserts the character. - -@item @code{M-TAB} (@code{echo-area-tab-insert}) -@kindex M-TAB, in the echo area -@findex echo-area-tab-insert -Inserts a TAB character. - -@item @code{C-t} (@code{echo-area-transpose-chars}) -@kindex C-t, in the echo area -@findex echo-area-transpose-chars -Transposes the characters at the cursor. -@end table - -The next group of commands deal with @dfn{killing}, and @dfn{yanking} -text. For an in depth discussion of killing and yanking, -@pxref{Killing, , Killing and Deleting, emacs, the GNU Emacs Manual} - -@table @asis -@item @code{M-d} (@code{echo-area-kill-word}) -@kindex M-d, in the echo area -@findex echo-area-kill-word -Kills the word following the cursor. - -@item @code{M-DEL} (@code{echo-area-backward-kill-word}) -@kindex M-DEL, in the echo area -@findex echo-area-backward-kill-word -Kills the word preceding the cursor. - -@item @code{C-k} (@code{echo-area-kill-line}) -@kindex C-k, in the echo area -@findex echo-area-kill-line -Kills the text from the cursor to the end of the line. - -@item @code{C-x DEL} (@code{echo-area-backward-kill-line}) -@kindex C-x DEL, in the echo area -@findex echo-area-backward-kill-line -Kills the text from the cursor to the beginning of the line. - -@item @code{C-y} (@code{echo-area-yank}) -@kindex C-y, in the echo area -@findex echo-area-yank -Yanks back the contents of the last kill. - -@item @code{M-y} (@code{echo-area-yank-pop}) -@kindex M-y, in the echo area -@findex echo-area-yank-pop -Yanks back a previous kill, removing the last yanked text first. -@end table - -Sometimes when reading input in the echo area, the command that needed -input will only accept one of a list of several choices. The choices -represent the @dfn{possible completions}, and you must respond with one -of them. Since there are a limited number of responses you can make, -Info allows you to abbreviate what you type, only typing as much of the -response as is necessary to uniquely identify it. In addition, you can -request Info to fill in as much of the response as is possible; this -is called @dfn{completion}. - -The following commands are available when completing in the echo area: - -@table @asis -@item @code{TAB} (@code{echo-area-complete}) -@itemx @code{SPC} -@kindex TAB, in the echo area -@kindex SPC, in the echo area -@findex echo-area-complete -Inserts as much of a completion as is possible. - -@item @code{?} (@code{echo-area-possible-completions}) -@kindex ?, in the echo area -@findex echo-area-possible-completions -Displays a window containing a list of the possible completions of what -you have typed so far. For example, if the available choices are: -@example -bar -foliate -food -forget -@end example -and you have typed an @samp{f}, followed by @samp{?}, the possible -completions would contain: -@example -foliate -food -forget -@end example -i.e., all of the choices which begin with @samp{f}. Pressing @key{SPC} -or @key{TAB} would result in @samp{fo} appearing in the echo area, since -all of the choices which begin with @samp{f} continue with @samp{o}. -Now, typing @samp{l} followed by @samp{TAB} results in @samp{foliate} -appearing in the echo area, since that is the only choice which begins -with @samp{fol}. - -@item @code{ESC C-v} (@code{echo-area-scroll-completions-window}) -@kindex ESC C-v, in the echo area -@findex echo-area-scroll-completions-window -Scrolls the completions window, if that is visible, or the "other" -window if not. -@end table - -@node Printing Nodes -@chapter Printing Out Nodes -@cindex printing - -You may wish to print out the contents of a node as a quick reference -document for later use. Info provides you with a command for doing -this. In general, we recommend that you use @TeX{} to format the -document and print sections of it, by running @code{tex} on the texinfo -source file. - -@table @asis -@item @code{M-x print-node} -@findex print-node -@cindex INFO_PRINT_COMMAND, environment variable -Pipes the contents of the current node through the command in the -environment variable @code{INFO_PRINT_COMMAND}. If the variable doesn't -exist, the node is simply piped to @code{lpr}. -@end table - -@node Miscellaneous Commands -@chapter Miscellaneous Commands - -GNU Info contains several commands which self-document GNU Info: - -@table @asis -@item @code{M-x describe-command} -@cindex functions, describing -@cindex commands, describing -@findex describe-command -Reads the name of an Info command in the echo area and then displays a -brief description of what that command does. - -@item @code{M-x describe-key} -@cindex keys, describing -@findex describe-key -Reads a key sequence in the echo area, and then displays the name and -documentation of the Info command that the key sequence invokes. - -@item @code{M-x describe-variable} -Reads the name of a variable in the echo area and then displays a brief -description of what the variable affects. - -@item @code{M-x where-is} -@findex where-is -Reads the name of an Info command in the echo area, and then displays -a key sequence which can be typed in order to invoke that command. - -@item @code{C-h} (@code{get-help-window}) -@itemx @code{?} -@kindex C-h -@kindex ?, in Info windows -@findex get-help-window -Creates (or moves into) the window displaying @code{*Help*}, and places -a node containing a quick reference card into it. This window displays -the most concise information about GNU Info available. - -@item @code{h} (@code{get-info-help-node}) -@kindex h -@findex get-info-help-node -Tries hard to visit the node @code{(info)Help}. The info file -@file{info.texi} distributed with GNU Info contains this node. Of -course, the file must first be processed with @code{makeinfo}, and then -placed into the location of your info directory. -@end table - -Here are the commands for creating a numeric argument: - -@table @asis -@item @code{C-u} (@code{universal-argument}) -@cindex numeric arguments -@kindex C-u -@findex universal-argument -Starts (or multiplies by 4) the current numeric argument. @samp{C-u} is -a good way to give a small numeric argument to cursor movement or -scrolling commands; @samp{C-u C-v} scrolls the screen 4 lines, while -@samp{C-u C-u C-n} moves the cursor down 16 lines. - -@item @code{M-1} (@code{add-digit-to-numeric-arg}) -@itemx @code{M-2} @dots{} @code{M-9} -@kindex M-1 @dots{} M-9 -@findex add-digit-to-numeric-arg -Adds the digit value of the invoking key to the current numeric -argument. Once Info is reading a numeric argument, you may just type -the digits of the argument, without the Meta prefix. For example, you -might give @samp{C-l} a numeric argument of 32 by typing: - -@example -@kbd{C-u 3 2 C-l} -@end example -or -@example -@kbd{M-3 2 C-l} -@end example -@end table - -@samp{C-g} is used to abort the reading of a multi-character key -sequence, to cancel lengthy operations (such as multi-file searches) and -to cancel reading input in the echo area. - -@table @asis -@item @code{C-g} (@code{abort-key}) -@cindex cancelling typeahead -@cindex cancelling the current operation -@kindex C-g, in Info windows -@findex abort-key -Cancels current operation. -@end table - -The @samp{q} command of Info simply quits running Info. - -@table @asis -@item @code{q} (@code{quit}) -@cindex quitting -@kindex q -@findex quit -Exits GNU Info. -@end table - -If the operating system tells GNU Info that the screen is 60 lines tall, -and it is actually only 40 lines tall, here is a way to tell Info that -the operating system is correct. - -@table @asis -@item @code{M-x set-screen-height} -@findex set-screen-height -@cindex screen, changing the height of -Reads a height value in the echo area and sets the height of the -displayed screen to that value. -@end table - -Finally, Info provides a convenient way to display footnotes which might -be associated with the current node that you are viewing: - -@table @asis -@item @code{ESC C-f} (@code{show-footnotes}) -@kindex ESC C-f -@findex show-footnotes -@cindex footnotes, displaying -Shows the footnotes (if any) associated with the current node in another -window. You can have Info automatically display the footnotes -associated with a node when the node is selected by setting the variable -@code{automatic-footnotes}. @xref{Variables, , @code{automatic-footnotes}}. -@end table - -@node Variables -@chapter Manipulating Variables - -GNU Info contains several @dfn{variables} whose values are looked at by various -Info commands. You can change the values of these variables, and thus -change the behaviour of Info to more closely match your environment and -info file reading manner. - -@table @asis -@item @code{M-x set-variable} -@cindex variables, setting -@findex set-variable -Reads the name of a variable, and the value for it, in the echo area and -then sets the variable to that value. Completion is available when -reading the variable name; often, completion is available when reading -the value to give to the variable, but that depends on the variable -itself. If a variable does @emph{not} supply multiple choices to -complete over, it expects a numeric value. - -@item @code{M-x describe-variable} -@cindex variables, describing -@findex describe-variable -Reads the name of a variable in the echo area and then displays a brief -description of what the variable affects. -@end table - -Here is a list of the variables that you can set in Info. - -@table @code -@item automatic-footnotes -@vindex automatic-footnotes -When set to @code{On}, footnotes appear and disappear automatically. -This variable is @code{On} by default. When a node is selected, a -window containing the footnotes which appear in that node is created, -and the footnotes are displayed within the new window. The window that -Info creates to contain the footnotes is called @samp{*Footnotes*}. If -a node is selected which contains no footnotes, and a @samp{*Footnotes*} -window is on the screen, the @samp{*Footnotes*} window is deleted. -Footnote windows created in this fashion are not automatically tiled so -that they can use as little of the display as is possible. - -@item automatic-tiling -@vindex automatic-tiling -When set to @code{On}, creating or deleting a window resizes other -windows. This variable is @code{Off} by default. Normally, typing -@samp{C-x 2} divides the current window into two equal parts. When -@code{automatic-tiling} is set to @code{On}, all of the windows are -resized automatically, keeping an equal number of lines visible in each -window. There are exceptions to the automatic tiling; specifically, the -windows @samp{*Completions*} and @samp{*Footnotes*} are @emph{not} -resized through automatic tiling; they remain their original size. - -@item visible-bell -@vindex visible-bell -When set to @code{On}, GNU Info attempts to flash the screen instead of -ringing the bell. This variable is @code{Off} by default. Of course, -Info can only flash the screen if the terminal allows it; in the case -that the terminal does not allow it, the setting of this variable has no -effect. However, you can make Info perform quietly by setting the -@code{errors-ring-bell} variable to @code{Off}. - -@item errors-ring-bell -@vindex errors-ring-bell -When set to @code{On}, errors cause the bell to ring. The default -setting of this variable is @code{On}. - -@item gc-compressed-files -@vindex gc-compressed-files -When set to @code{On}, Info garbage collects files which had to be -uncompressed. The default value of this variable is @code{Off}. -Whenever a node is visited in Info, the info file containing that node -is read into core, and Info reads information about the tags and nodes -contained in that file. Once the tags information is read by Info, it -is never forgotten. However, the actual text of the nodes does not need -to remain in core unless a particular info window needs it. For -non-compressed files, the text of the nodes does not remain in core when -it is no longer in use. But de-compressing a file can be a time -consuming operation, and so Info tries hard not to do it twice. -@code{gc-compressed-files} tells Info it is okay to garbage collect the -text of the nodes of a file which was compressed on disk. - -@item show-index-match -@vindex show-index-match -When set to @code{On}, the portion of the matched search string is -highlighted in the message which explains where the matched search -string was found. The default value of this variable is @code{On}. -When Info displays the location where an index match was found, -(@pxref{Searching Commands, , @code{next-index-match}}), the portion of the -string that you had typed is highlighted by displaying it in the inverse -case from its surrounding characters. - -@item scroll-behaviour -@vindex scroll-behaviour -Controls what happens when forward scrolling is requested at the end of -a node, or when backward scrolling is requested at the beginning of a -node. The default value for this variable is @code{Continuous}. There -are three possible values for this variable: - -@table @code -@item Continuous -Tries to get the first item in this node's menu, or failing that, the -@samp{Next} node, or failing that, the @samp{Next} of the @samp{Up}. -This behaviour is identical to using the @samp{]} -(@code{global-next-node}) and @samp{[} (@code{global-prev-node}) -commands. - -@item Next Only -Only tries to get the @samp{Next} node. - -@item Page Only -Simply gives up, changing nothing. If @code{scroll-behaviour} is -@code{Page Only}, no scrolling command can change the node that is being -viewed. -@end table - -@item scroll-step -@vindex scroll-step -The number of lines to scroll when the cursor moves out of the window. -Scrolling happens automatically if the cursor has moved out of the -visible portion of the node text when it is time to display. Usually -the scrolling is done so as to put the cursor on the center line of the -current window. However, if the variable @code{scroll-step} has a -nonzero value, Info attempts to scroll the node text by that many lines; -if that is enough to bring the cursor back into the window, that is what -is done. The default value of this variable is 0, thus placing the -cursor (and the text it is attached to) in the center of the window. -Setting this variable to 1 causes a kind of "smooth scrolling" which -some people prefer. - -@item ISO-Latin -@cindex ISO Latin characters -@vindex ISO-Latin -When set to @code{On}, Info accepts and displays ISO Latin characters. -By default, Info assumes an ASCII character set. @code{ISO-Latin} tells -Info that it is running in an environment where the European standard -character set is in use, and allows you to input such characters to -Info, as well as display them. -@end table - -@node Info for Sys Admins -@chapter Info for System Administrators - -This text describes some common ways of setting up an Info heierarchy -from scratch, and details the various options that are available when -installing Info. This text is designed for the person who is installing -GNU Info on the system; although users may find the information present -in this section interesting, none of it is vital to understanding how to -use GNU Info. - -@menu -* Setting the INFOPATH:: Where are my Info files kept? -* Editing the DIR node:: What goes in `DIR', and why? -* Storing Info files:: Alternate formats allow flexibilty in setups. -* Using `localdir':: Building DIR on the fly. -* Example setups:: Some common ways to origanize Info files. -@end menu - -@node Setting the INFOPATH -@section Setting the INFOPATH -Where are my Info files kept? - -@node Editing the DIR node -@section Editing the DIR node -What goes in `DIR', and why? - -@node Storing Info files -@section Storing Info files -Alternate formats allow flexibilty in setups. - -@node Using `localdir' -@section Using `localdir' -Building DIR on the fly. - -@node Example setups -@section Example setups -Some common ways to origanize Info files. - -@ifset STANDALONE -@node GNU Info Global Index -@appendix Global Index -@printindex cp -@end ifset diff --git a/gnu/usr.bin/texinfo/info-files/texi.info b/gnu/usr.bin/texinfo/info-files/texi.info deleted file mode 100644 index cd677e85cd5e..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info +++ /dev/null @@ -1,297 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -Indirect: -texi.info-1: 1096 -texi.info-2: 50585 -texi.info-3: 100344 -texi.info-4: 149083 -texi.info-5: 197497 -texi.info-6: 247275 -texi.info-7: 296490 -texi.info-8: 346023 -texi.info-9: 387598 -texi.info-10: 433598 -texi.info-11: 476101 - -Tag Table: -(Indirect) -Node: Top1096 -Node: Copying21758 -Node: Overview23766 -Node: Using Texinfo25673 -Node: Info Files28165 -Node: Printed Books32225 -Node: Formatting Commands35110 -Node: Conventions38551 -Node: Comments40811 -Node: Minimum42233 -Node: Six Parts44386 -Node: Short Sample45896 -Node: Acknowledgements50027 -Node: Texinfo Mode50585 -Node: Texinfo Mode Overview51956 -Node: Emacs Editing52709 -Node: Inserting54839 -Node: Showing the Structure59115 -Node: Updating Nodes and Menus61634 -Node: Updating Commands62706 -Node: Updating Requirements68741 -Node: Other Updating Commands71042 -Node: Info Formatting74311 -Node: Printing75635 -Node: Texinfo Mode Summary77399 -Node: Beginning a File82167 -Node: Four Parts83056 -Node: Sample Beginning84502 -Node: Header86125 -Node: First Line87476 -Node: Start of Header88448 -Node: setfilename89163 -Node: settitle90763 -Node: setchapternewpage92646 -Node: paragraphindent95412 -Node: End of Header96877 -Node: Info Summary and Permissions97717 -Node: Titlepage & Copyright Page98738 -Node: titlepage100344 -Node: titlefont center sp102665 -Node: title subtitle author103895 -Node: Copyright & Permissions106171 -Node: end titlepage108176 -Node: headings on off109881 -Node: The Top Node111707 -Node: Title of Top Node112862 -Node: Master Menu Parts114099 -Node: Software Copying Permissions116150 -Node: Ending a File117318 -Node: Printing Indices & Menus118165 -Node: Contents120448 -Node: File End122790 -Node: Structuring123462 -Node: Tree Structuring125043 -Node: Structuring Command Types126467 -Node: makeinfo top128792 -Node: chapter129323 -Node: unnumbered & appendix130147 -Node: majorheading & chapheading130986 -Node: section131808 -Node: unnumberedsec appendixsec heading132573 -Node: subsection133560 -Node: unnumberedsubsec appendixsubsec subheading134131 -Node: subsubsection135083 -Node: Nodes136603 -Node: Two Paths137538 -Node: Node Menu Illustration138810 -Node: node142510 -Node: Node Names145206 -Node: Writing a Node146271 -Node: Node Line Tips148291 -Node: Node Line Requirements149083 -Node: First Node150691 -Node: makeinfo top command151811 -Node: Top Node Summary153591 -Node: makeinfo Pointer Creation154728 -Node: Menus155977 -Node: Menu Location157220 -Node: Writing a Menu158884 -Node: Menu Parts159850 -Node: Less Cluttered Menu Entry160848 -Node: Menu Example161473 -Node: Other Info Files162995 -Node: Cross References164855 -Node: References165734 -Node: Cross Reference Commands167458 -Node: Cross Reference Parts168509 -Node: xref171238 -Node: Reference Syntax172035 -Node: One Argument173679 -Node: Two Arguments174690 -Node: Three Arguments175804 -Node: Four and Five Arguments178189 -Node: Top Node Naming180602 -Node: ref181610 -Node: pxref182998 -Node: inforef185382 -Node: Marking Text186662 -Node: Indicating187283 -Node: Useful Highlighting189014 -Node: code190199 -Node: kbd193243 -Node: key194431 -Node: samp195985 -Node: var197497 -Node: file199287 -Node: dfn199893 -Node: cite200802 -Node: Emphasis201243 -Node: emph & strong202071 -Node: Smallcaps203041 -Node: Fonts204371 -Node: Quotations and Examples205427 -Node: Block Enclosing Commands207048 -Node: quotation209043 -Node: example210132 -Node: noindent212190 -Node: Lisp Example213657 -Node: smallexample & smalllisp214488 -Node: display216516 -Node: format217146 -Node: exdent217605 -Node: flushleft & flushright218684 -Node: cartouche219946 -Node: Lists and Tables220716 -Node: Introducing Lists221311 -Node: itemize222953 -Node: enumerate225104 -Node: Two-column Tables227594 -Node: table228287 -Node: ftable vtable230601 -Node: itemx231644 -Node: Indices232604 -Node: Index Entries233753 -Node: Predefined Indices234870 -Node: Indexing Commands235865 -Node: Combining Indices239873 -Node: syncodeindex241235 -Node: synindex242874 -Node: New Indices243398 -Node: Insertions245227 -Node: Braces Atsigns Periods245985 -Node: Inserting An Atsign247275 -Node: Inserting Braces247533 -Node: Controlling Spacing247932 -Node: dmn249490 -Node: Dots Bullets250719 -Node: dots251525 -Node: bullet251920 -Node: TeX and copyright252297 -Node: tex252861 -Node: copyright symbol253233 -Node: minus253479 -Node: Glyphs254350 -Node: Glyphs Summary255461 -Node: result255973 -Node: expansion256430 -Node: Print Glyph257352 -Node: Error Glyph258203 -Node: Equivalence259021 -Node: Point Glyph259683 -Node: Breaks261206 -Node: Break Commands262558 -Node: Line Breaks263246 -Node: w264248 -Node: sp265066 -Node: page265474 -Node: group265851 -Node: need267596 -Node: Definition Commands268326 -Node: Def Cmd Template269897 -Node: Optional Arguments272807 -Node: deffnx274396 -Node: Def Cmds in Detail275352 -Node: Functions Commands276462 -Node: Variables Commands279391 -Node: Typed Functions281340 -Node: Typed Variables284875 -Node: Abstract Objects286856 -Node: Data Types291752 -Node: Def Cmd Conventions293005 -Node: Sample Function Definition293566 -Node: Footnotes296490 -Node: Conditionals300343 -Node: Conditional Commands301099 -Node: Using Ordinary TeX Commands302508 -Node: set clear value303956 -Node: ifset ifclear304761 -Node: value307921 -Node: value Example309339 -Node: Format/Print Hardcopy310917 -Node: Use TeX312719 -Node: Shell Format & Print313310 -Node: Within Emacs317908 -Node: Texinfo Mode Printing318896 -Node: Compile-Command322646 -Node: Requirements Summary323554 -Node: Preparing for TeX324974 -Node: Overfull hboxes326989 -Node: smallbook328549 -Node: A4 Paper329782 -Node: Cropmarks and Magnification330484 -Node: Create an Info File332460 -Node: makeinfo advantages333764 -Node: Invoking makeinfo334651 -Node: makeinfo options335363 -Node: Pointer Validation340823 -Node: makeinfo in Emacs342207 -Node: texinfo-format commands344752 -Node: Batch Formatting346023 -Node: Tag and Split Files347269 -Node: Install an Info File350626 -Node: Directory file351276 -Node: New Info File352956 -Node: Other Info Directories354095 -Node: Command List355961 -Node: Tips387598 -Node: Sample Texinfo File399031 -Node: Sample Permissions401147 -Node: Inserting Permissions402188 -Node: ifinfo Permissions404469 -Node: Titlepage Permissions406088 -Node: Include Files407348 -Node: Using Include Files408434 -Node: texinfo-multiple-files-update410368 -Node: Include File Requirements412759 -Node: Sample Include File414004 -Node: Include Files Evolution415532 -Node: Headings417509 -Node: Headings Introduced418144 -Node: Heading Format420033 -Node: Heading Choice422489 -Node: Custom Headings423860 -Node: Catching Mistakes428069 -Node: makeinfo preferred429359 -Node: Debugging with Info430260 -Node: Debugging with TeX433598 -Node: Using texinfo-show-structure437940 -Node: Using occur441040 -Node: Running Info-Validate442579 -Node: Using Info-validate443639 -Node: Unsplit445454 -Node: Tagifying446502 -Node: Splitting447361 -Node: Refilling Paragraphs448981 -Node: Command Syntax450800 -Node: Obtaining TeX453731 -Node: New Features454842 -Node: New Texinfo Mode Commands455424 -Node: New Commands458894 -Node: Command and Variable Index463543 -Node: Concept Index476101 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-1 b/gnu/usr.bin/texinfo/info-files/texi.info-1 deleted file mode 100644 index 28b4895fc7e5..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-1 +++ /dev/null @@ -1,1131 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) - -Texinfo -******* - - Texinfo is a documentation system that uses a single source file to -produce both on-line information and printed output. - - The first part of this master menu lists the major nodes in this Info -document, including the @-command and concept indices. The rest of the -menu lists all the lower level nodes in the document. - - This is Edition 2.18 of the Texinfo documentation, 26 March 1993, -for Texinfo Version 2. - -* Menu: - -* Copying:: Your rights. -* Overview:: Texinfo in brief. -* Texinfo Mode:: How to use Texinfo mode. -* Beginning a File:: What is at the beginning of a Texinfo file? -* Ending a File:: What is at the end of a Texinfo file? -* Structuring:: How to create chapters, sections, subsections, - appendices, and other parts. -* Nodes:: How to write nodes. -* Menus:: How to write menus. -* Cross References:: How to write cross references. -* Marking Text:: How to mark words and phrases as code, - keyboard input, meta-syntactic - variables, and the like. -* Quotations and Examples:: How to write quotations, examples, etc. -* Lists and Tables:: How to write lists and tables. -* Indices:: How to create indices. -* Insertions:: How to insert @-signs, braces, etc. -* Glyphs:: How to indicate results of evaluation, - expansion of macros, errors, etc. -* Breaks:: How to force and prevent line and page breaks. -* Definition Commands:: How to describe functions and the like - in a uniform manner. -* Footnotes:: How to write footnotes. -* Conditionals:: How to specify text for either TeX or Info. -* Format/Print Hardcopy:: How to convert a Texinfo file to a file - for printing and how to print that file. -* Create an Info File:: Convert a Texinfo file into an Info file. -* Install an Info File:: Make an Info file accessible to users. -* Command List:: All the Texinfo @-commands. -* Tips:: Hints on how to write a Texinfo document. -* Sample Texinfo File:: A sample Texinfo file to look at. -* Sample Permissions:: Tell readers they have the right to copy - and distribute. -* Include Files:: How to incorporate other Texinfo files. -* Headings:: How to write page headings and footings. -* Catching Mistakes:: How to find formatting mistakes. -* Refilling Paragraphs:: All about paragraph refilling. -* Command Syntax:: A description of @-Command syntax. -* Obtaining TeX:: How to Obtain TeX. -* New Features:: Texinfo second edition features. -* Command and Variable Index:: A menu containing commands and variables. -* Concept Index:: A menu covering many topics. - - -- The Detailed Node Listing -- - -Overview of Texinfo - -* Using Texinfo:: Create a conventional printed book - or an Info file. -* Info Files:: What is an Info file? -* Printed Books:: Characteristics of a printed book or manual. -* Formatting Commands:: @-commands are used for formatting. -* Conventions:: General rules for writing a Texinfo file. -* Comments:: How to write comments and mark regions that - the formatting commands will ignore. -* Minimum:: What a Texinfo file must have. -* Six Parts:: Usually, a Texinfo file has six parts. -* Short Sample:: A short sample Texinfo file. -* Acknowledgements:: - -Using Texinfo Mode - -* Texinfo Mode Overview:: How Texinfo mode can help you. -* Emacs Editing:: Texinfo mode adds to GNU Emacs' general - purpose editing features. -* Inserting:: How to insert frequently used @-commands. -* Showing the Structure:: How to show the structure of a file. -* Updating Nodes and Menus:: How to update or create new nodes and menus. -* Info Formatting:: How to format for Info. -* Printing:: How to format and print part or all of a file. -* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. - -Updating Nodes and Menus - -* Updating Commands:: Five major updating commands. -* Updating Requirements:: How to structure a Texinfo file for - using the updating command. -* Other Updating Commands:: How to indent descriptions, insert - missing nodes lines, and update - nodes in sequence. - -Beginning a Texinfo File - -* Four Parts:: Four parts begin a Texinfo file. -* Sample Beginning:: Here is a sample beginning for a Texinfo file. -* Header:: The very beginning of a Texinfo file. -* Info Summary and Permissions:: Summary and copying permissions for Info. -* Titlepage & Copyright Page:: Creating the title and copyright pages. -* The Top Node:: Creating the `Top' node and master menu. -* Software Copying Permissions:: Ensure that you and others continue to - have the right to use and share software. - -The Texinfo File Header - -* First Line:: The first line of a Texinfo file. -* Start of Header:: Formatting a region requires this. -* setfilename:: Tell Info the name of the Info file. -* settitle:: Create a title for the printed work. -* setchapternewpage:: Start chapters on right-hand pages. -* paragraphindent:: An option to specify paragraph indentation. -* End of Header:: Formatting a region requires this. - -The Title and Copyright Pages - -* titlepage:: Create a title for the printed document. -* titlefont center sp:: The `@titlefont', `@center', - and `@sp' commands. -* title subtitle author:: The `@title', `@subtitle', - and `@author' commands. -* Copyright & Permissions:: How to write the copyright notice and - include copying permissions. -* end titlepage:: Turn on page headings after the title and - copyright pages. -* headings on off:: An option for turning headings on and off - and double or single sided printing. - -The `Top' Node and Master Menu - -* Title of Top Node:: Sketch what the file is about. -* Master Menu Parts:: A master menu has three or more parts. - -Ending a Texinfo File - -* Printing Indices & Menus:: How to print an index in hardcopy and - generate index menus in Info. -* Contents:: How to create a table of contents. -* File End:: How to mark the end of a file. - -Chapter Structuring - -* Tree Structuring:: A manual is like an upside down tree ... -* Structuring Command Types:: How to divide a manual into parts. -* makeinfo top:: The `@top' command, part of the `Top' node. -* chapter:: -* unnumbered & appendix:: -* majorheading & chapheading:: -* section:: -* unnumberedsec appendixsec heading:: -* subsection:: -* unnumberedsubsec appendixsubsec subheading:: -* subsubsection:: Commands for the lowest level sections. - -Nodes - -* Two Paths:: Different commands to structure - Info output and printed output. -* Node Menu Illustration:: A diagram, and sample nodes and menus. -* node:: How to write a node, in detail. -* makeinfo Pointer Creation:: How to create node pointers with `makeinfo'. - -The `@node' Command - -* Node Names:: How to choose node and pointer names. -* Writing a Node:: How to write an `@node' line. -* Node Line Tips:: Keep names short. -* Node Line Requirements:: Keep names unique, without @-commands. -* First Node:: How to write a `Top' node. -* makeinfo top command:: How to use the `@top' command. -* Top Node Summary:: Write a brief description for readers. - -Menus - -* Menu Location:: Put a menu in a short node. -* Writing a Menu:: What is a menu? -* Menu Parts:: A menu entry has three parts. -* Less Cluttered Menu Entry:: Two part menu entry. -* Menu Example:: Two and three part menu entries. -* Other Info Files:: How to refer to a different Info file. - -Cross References - -* References:: What cross references are for. -* Cross Reference Commands:: A summary of the different commands. -* Cross Reference Parts:: A cross reference has several parts. -* xref:: Begin a reference with `See' ... -* Top Node Naming:: How to refer to the beginning of another file. -* ref:: A reference for the last part of a sentence. -* pxref:: How to write a parenthetical cross reference. -* inforef:: How to refer to an Info-only file. - -`@xref' - -* Reference Syntax:: What a reference looks like and requires. -* One Argument:: `@xref' with one argument. -* Two Arguments:: `@xref' with two arguments. -* Three Arguments:: `@xref' with three arguments. -* Four and Five Arguments:: `@xref' with four and five arguments. - -Marking Words and Phrases - -* Indicating:: How to indicate definitions, files, etc. -* Emphasis:: How to emphasize text. - -Indicating Definitions, Commands, etc. - -* Useful Highlighting:: Highlighting provides useful information. -* code:: How to indicate code. -* kbd:: How to show keyboard input. -* key:: How to specify keys. -* samp:: How to show a literal sequence of characters. -* var:: How to indicate a metasyntactic variable. -* file:: How to indicate the name of a file. -* dfn:: How to specify a definition. -* cite:: How to refer to a book that is not in Info. - -Emphasizing Text - -* emph & strong:: How to emphasize text in Texinfo. -* Smallcaps:: How to use the small caps font. -* Fonts:: Various font commands for printed output. - -Quotations and Examples - -* Block Enclosing Commands:: Use different constructs for - different purposes. -* quotation:: How to write a quotation. -* example:: How to write an example in a fixed-width font. -* noindent:: How to prevent paragraph indentation. -* Lisp Example:: How to illustrate Lisp code. -* smallexample & smalllisp:: Forms for the `@smallbook' option. -* display:: How to write an example in the current font. -* format:: How to write an example that does not narrow - the margins. -* exdent:: How to undo the indentation of a line. -* flushleft & flushright:: How to push text flushleft or flushright. -* cartouche:: How to draw cartouches around examples. - -Making Lists and Tables - -* Introducing Lists:: Texinfo formats lists for you. -* itemize:: How to construct a simple list. -* enumerate:: How to construct a numbered list. -* Two-column Tables:: How to construct a two-column table. - -Making a Two-column Table - -* table:: How to construct a two-column table. -* ftable vtable:: How to construct a two-column table - with automatic indexing. -* itemx:: How to put more entries in the first column. - -Creating Indices - -* Index Entries:: Choose different words for index entries. -* Predefined Indices:: Use different indices for different kinds - of entry. -* Indexing Commands:: How to make an index entry. -* Combining Indices:: How to combine indices. -* New Indices:: How to define your own indices. - -Combining Indices - -* syncodeindex:: How to merge two indices, using `@code' - font for the merged-from index. -* synindex:: How to merge two indices, using the - default font of the merged-to index. - -Special Insertions - -* Braces Atsigns Periods:: How to insert braces, `@' and periods. -* dmn:: How to format a dimension. -* Dots Bullets:: How to insert dots and bullets. -* TeX and copyright:: How to insert the TeX logo - and the copyright symbol. -* minus:: How to insert a minus sign. - -Inserting `@', Braces, and Periods - -* Inserting An Atsign:: -* Inserting Braces:: How to insert `{' and `}' -* Controlling Spacing:: How to insert the right amount of space - after punctuation within a sentence. - -Inserting Ellipsis, Dots, and Bullets - -* dots:: How to insert dots ... -* bullet:: How to insert a bullet. - -Inserting TeX and the Copyright Symbol - -* tex:: How to insert the TeX logo. -* copyright symbol:: How to use `@copyright'{}. - -Glyphs for Examples - -* Glyphs Summary:: -* result:: How to show the result of expression. -* expansion:: How to indicate an expansion. -* Print Glyph:: How to indicate printed output. -* Error Glyph:: How to indicate an error message. -* Equivalence:: How to indicate equivalence. -* Point Glyph:: How to indicate the location of point. - -Making and Preventing Breaks - -* Break Commands:: Cause and prevent splits. -* Line Breaks:: How to force a single line to use two lines. -* w:: How to prevent unwanted line breaks. -* sp:: How to insert blank lines. -* page:: How to force the start of a new page. -* group:: How to prevent unwanted page breaks. -* need:: Another way to prevent unwanted page breaks. - -Definition Commands - -* Def Cmd Template:: How to structure a description using a - definition command. -* Optional Arguments:: How to handle optional and repeated arguments. -* deffnx:: How to group two or more `first' lines. -* Def Cmds in Detail:: All the definition commands. -* Def Cmd Conventions:: Conventions for writing definitions. -* Sample Function Definition:: - -The Definition Commands - -* Functions Commands:: Commands for functions and similar entities. -* Variables Commands:: Commands for variables and similar entities. -* Typed Functions:: Commands for functions in typed languages. -* Typed Variables:: Commands for variables in typed languages. -* Abstract Objects:: Commands for object-oriented programming. -* Data Types:: The definition command for data types. - -Conditionally Visible Text - -* Conditional Commands:: How to specify text for Info or TeX. -* Using Ordinary TeX Commands:: You can use any and all TeX commands. -* set clear value:: How to designate which text to format (for - both Info and TeX); and how to set a - flag to a string that you can insert. - -`@set', `@clear', and `@value' - -* ifset ifclear:: Format a region if a flag is set. -* value:: Replace a flag with a string. -* value Example:: An easy way to update edition information. - -Format and Print Hardcopy - -* Use TeX:: Use TeX to format for hardcopy. -* Shell Format & Print:: How to format and print a hardcopy manual - with shell commands. -* Within Emacs:: How to format and print from an Emacs shell. -* Texinfo Mode Printing:: How to format and print in Texinfo mode. -* Compile-Command:: How to print using Emacs's compile command. -* Requirements Summary:: TeX formatting requirements summary. -* Preparing for TeX:: What you need to do to use TeX. -* Overfull hboxes:: What are and what to do with overfull hboxes. -* smallbook:: How to print small format books and manuals. -* A4 Paper:: How to print on European A4 paper. -* Cropmarks and Magnification:: How to print marks to indicate the size - of pages and how to print scaled up output. - -Creating an Info File - -* makeinfo advantages:: `makeinfo' provides better error checking. -* Invoking makeinfo:: How to run `makeinfo' from a shell. -* makeinfo options:: Specify fill-column and other options. -* Pointer Validation:: How to check that pointers point somewhere. -* makeinfo in Emacs:: How to run `makeinfo' from Emacs. -* texinfo-format commands:: Two Info formatting commands written - in Emacs Lisp are an alternative - to `makeinfo'. -* Batch Formatting:: How to format for Info in Emacs Batch mode. -* Tag and Split Files:: How tagged and split files help Info - to run better. - -Installing an Info File - -* Directory file:: The top level menu for all Info files. -* New Info File:: Listing a new info file. -* Other Info Directories:: How to specify Info files that are - located in other directories. - -Sample Permissions - -* Inserting Permissions:: How to put permissions in your document. -* ifinfo Permissions:: Sample `ifinfo' copying permissions. -* Titlepage Permissions:: Sample Titlepage copying permissions. - -Include Files - -* Using Include Files:: How to use the `@include' command. -* texinfo-multiple-files-update:: How to create and update nodes and - menus when using included files. -* Include File Requirements:: What `texinfo-multiple-files-update' expects. -* Sample Include File:: A sample outer file with included files - within it; and a sample included file. -* Include Files Evolution:: How use of the `@include' command - has changed over time. - -Page Headings - -* Headings Introduced:: Conventions for using page headings. -* Heading Format:: Standard page heading formats. -* Heading Choice:: How to specify the type of page heading. -* Custom Headings:: How to create your own headings and footings. - -Formatting Mistakes - -* makeinfo preferred:: `makeinfo' finds errors. -* Debugging with Info:: How to catch errors with Info formatting. -* Debugging with TeX:: How to catch errors with TeX formatting. -* Using texinfo-show-structure:: How to use `texinfo-show-structure'. -* Using occur:: How to list all lines containing a pattern. -* Running Info-Validate:: How to find badly referenced nodes. - -Finding Badly Referenced Nodes - -* Using Info-validate:: How to run `Info-validate'. -* Unsplit:: How to create an unsplit file. -* Tagifying:: How to tagify a file. -* Splitting:: How to split a file manually. - -Second Edition Features - -* New Texinfo Mode Commands:: The updating commands are especially useful. -* New Commands:: Many newly described @-commands. - - -File: texi.info, Node: Copying, Next: Overview, Prev: Top, Up: Top - -Texinfo Copying Conditions -************************** - - The programs currently being distributed that relate to Texinfo -include portions of GNU Emacs, plus other separate programs (including -`makeinfo', `info', `texindex', and `texinfo.tex'). These programs are -"free"; this means that everyone is free to use them and free to -redistribute them on a free basis. The Texinfo-related programs are -not in the public domain; they are copyrighted and there are -restrictions on their distribution, but these restrictions are designed -to permit everything that a good cooperating citizen would want to do. -What is not allowed is to try to prevent others from further sharing -any version of these programs that they might get from you. - - Specifically, we want to make sure that you have the right to give -away copies of the programs that relate to Texinfo, that you receive -source code or else can get it if you want it, that you can change these -programs or use pieces of them in new free programs, and that you know -you can do these things. - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of the Texinfo related programs, you must give the recipients all -the rights that you have. You must make sure that they, too, receive or -can get the source code. And you must tell them their rights. - - Also, for our own protection, we must make certain that everyone -finds out that there is no warranty for the programs that relate to -Texinfo. If these programs are modified by someone else and passed on, -we want their recipients to know that what they have is not what we -distributed, so that any problems introduced by others will not reflect -on our reputation. - - The precise conditions of the licenses for the programs currently -being distributed that relate to Texinfo are found in the General Public -Licenses that accompany them. - - -File: texi.info, Node: Overview, Next: Texinfo Mode, Prev: Copying, Up: Top - -Overview of Texinfo -******************* - - "Texinfo"(1) is a documentation system that uses a single source -file to produce both on-line information and printed output. This -means that instead of writing two different documents, one for the -on-line help or other on-line information and the other for a typeset -manual or other printed work, you need write only one document. When -the work is revised, you need revise only one document. (You can read -the on-line information, known as an "Info file", with an Info -documentation-reading program.) - -* Menu: - -* Using Texinfo:: Create a conventional printed book - or an Info file. -* Info Files:: What is an Info file? -* Printed Books:: Characteristics of a printed book or manual. -* Formatting Commands:: @-commands are used for formatting. -* Conventions:: General rules for writing a Texinfo file. -* Comments:: How to write comments and mark regions that - the formatting commands will ignore. -* Minimum:: What a Texinfo file must have. -* Six Parts:: Usually, a Texinfo file has six parts. -* Short Sample:: A short sample Texinfo file. -* Acknowledgements:: - - ---------- Footnotes ---------- - - (1) Note that the first syllable of "Texinfo" is pronounced like -"speck", not "hex". This odd pronunciation is derived from, but is not -the same as, the pronunciation of TeX. In the word TeX, the `X' is -actually the Greek letter "chi" rather than the English letter "ex". -Pronounce TeX as if the `X' were the last sound in the name `Bach'; but -pronounce Texinfo as if the `x' were a `k'. Spell "Texinfo" with a -capital "T" and write the other letters in lower case. - - -File: texi.info, Node: Using Texinfo, Next: Info Files, Up: Overview - -Using Texinfo -============= - - Using Texinfo, you can create a printed document with the normal -features of a book, including chapters, sections, cross references, and -indices. From the same Texinfo source file, you can create a -menu-driven, on-line Info file with nodes, menus, cross references, and -indices. You can, if you wish, make the chapters and sections of the -printed document correspond to the nodes of the on-line information; -and you use the same cross references and indices for both the Info -file and the printed work. `The GNU Emacs Manual' is a good example of -a Texinfo file, as is this manual. - - To make a printed document, you process a Texinfo source file with -the TeX typesetting program. This creates a DVI file that you can -typeset and print as a book or report. (Note that the Texinfo language -is completely different from TeX's usual language, PlainTeX, which -Texinfo replaces.) If you do not have TeX, but do have `troff' or -`nroff', you can use the `texi2roff' program instead. - - To make an Info file, you process a Texinfo source file with the -`makeinfo' utility or Emacs's `texinfo-format-buffer' command; this -creates an Info file that you can install on-line. - - TeX and `texi2roff' work with many types of printer; similarly, Info -works with almost every type of computer terminal. This power makes -Texinfo a general purpose system, but brings with it a constraint, -which is that a Texinfo file may contain only the customary -"typewriter" characters (letters, numbers, spaces, and punctuation -marks) but no special graphics. - - A Texinfo file is a plain ASCII file containing text and -"@-commands" (words preceded by an `@') that tell the typesetting and -formatting programs what to do. You may edit a Texinfo file with any -text editor; but it is especially convenient to use GNU Emacs since -that editor has a special mode, called Texinfo mode, that provides -various Texinfo-related features. (*Note Texinfo Mode::.) - - Before writing a Texinfo source file, you should become familiar with -the Info documentation reading program and learn about nodes, menus, -cross references, and the rest. (*note info: (info)Top, for more -information.) - - You can use Texinfo to create both on-line help and printed manuals; -moreover, Texinfo is freely redistributable. For these reasons, Texinfo -is the format in which documentation for GNU utilities and libraries is -written. - - -File: texi.info, Node: Info Files, Next: Printed Books, Prev: Using Texinfo, Up: Overview - -Info files -========== - - An Info file is a Texinfo file formatted so that the Info -documentation reading program can operate on it. (`makeinfo' and -`texinfo-format-buffer' are two commands that convert a Texinfo file -into an Info file.) - - Info files are divided into pieces called "nodes", each of which -contains the discussion of one topic. Each node has a name, and -contains both text for the user to read and pointers to other nodes, -which are identified by their names. The Info program displays one node -at a time, and provides commands with which the user can move to other -related nodes. - - *note info: (info)Top, for more information about using Info. - - Each node of an Info file may have any number of child nodes that -describe subtopics of the node's topic. The names of child nodes are -listed in a "menu" within the parent node; this allows you to use -certain Info commands to move to one of the child nodes. Generally, an -Info file is organized like a book. If a node is at the logical level -of a chapter, its child nodes are at the level of sections; likewise, -the child nodes of sections are at the level of subsections. - - All the children of any one parent are linked together in a -bidirectional chain of `Next' and `Previous' pointers. The `Next' -pointer provides a link to the next section, and the `Previous' pointer -provides a link to the previous section. This means that all the nodes -that are at the level of sections within a chapter are linked together. -Normally the order in this chain is the same as the order of the -children in the parent's menu. Each child node records the parent node -name as its `Up' pointer. The last child has no `Next' pointer, and the -first child has the parent both as its `Previous' and as its `Up' -pointer.(1) - - The book-like structuring of an Info file into nodes that correspond -to chapters, sections, and the like is a matter of convention, not a -requirement. The `Up', `Previous', and `Next' pointers of a node can -point to any other nodes, and a menu can contain any other nodes. -Thus, the node structure can be any directed graph. But it is usually -more comprehensible to follow a structure that corresponds to the -structure of chapters and sections in a printed book or report. - - In addition to menus and to `Next', `Previous', and `Up' pointers, -Info provides pointers of another kind, called references, that can be -sprinkled throughout the text. This is usually the best way to -represent links that do not fit a hierarchical structure. - - Usually, you will design a document so that its nodes match the -structure of chapters and sections in the printed output. But there -are times when this is not right for the material being discussed. -Therefore, Texinfo uses separate commands to specify the node structure -for the Info file and the section structure for the printed output. - - Generally, you enter an Info file through a node that by convention -is called `Top'. This node normally contains just a brief summary of -the file's purpose, and a large menu through which the rest of the file -is reached. From this node, you can either traverse the file -systematically by going from node to node, or you can go to a specific -node listed in the main menu, or you can search the index menus and -then go directly to the node that has the information you want. - - If you want to read through an Info file in sequence, as if it were a -printed manual, you can get the whole file with the advanced Info -command `g* RET'. (*note Advanced Info commands: (info)Expert.) - - The `dir' file in the `info' directory serves as the departure point -for the whole Info system. From it, you can reach the `Top' nodes of -each of the documents in a complete Info system. - - ---------- Footnotes ---------- - - (1) In some documents, the first child has no `Previous' pointer. -Occasionally, the last child has the node name of the next following -higher level node as its `Next' pointer. - - -File: texi.info, Node: Printed Books, Next: Formatting Commands, Prev: Info Files, Up: Overview - -Printed Books -============= - - A Texinfo file can be formatted and typeset as a printed book or -manual. To do this, you need TeX, a powerful, sophisticated typesetting -program written by Donald Knuth.(1) - - A Texinfo-based book is similar to any other typeset, printed work: -it can have a title page, copyright page, table of contents, and -preface, as well as chapters, numbered or unnumbered sections and -subsections, page headers, cross references, footnotes, and indices. - - You can use Texinfo to write a book without ever having the intention -of converting it into on-line information. You can use Texinfo for -writing a printed novel, and even to write a printed memo, although -this latter application is not recommended since electronic mail is so -much easier. - - TeX is a general purpose typesetting program. Texinfo provides a -file called `texinfo.tex' that contains information (definitions or -"macros") that TeX uses when it typesets a Texinfo file. -(`texinfo.tex' tells TeX how to convert the Texinfo @-commands to TeX -commands, which TeX can then process to create the typeset document.) -`texinfo.tex' contains the specifications for printing a document. - - Most often, documents are printed on 8.5 inch by 11 inch pages -(216mm by 280mm; this is the default size), but you can also print for -7 inch by 9.25 inch pages (178mm by 235mm; the `@smallbook' size) or on -European A4 size paper (`@afourpaper'). (*Note Printing "Small" Books: -smallbook. Also, see *Note Printing on A4 Paper: A4 Paper.) - - By changing the parameters in `texinfo.tex', you can change the size -of the printed document. In addition, you can change the style in -which the printed document is formatted; for example, you can change the -sizes and fonts used, the amount of indentation for each paragraph, the -degree to which words are hyphenated, and the like. By changing the -specifications, you can make a book look dignified, old and serious, or -light-hearted, young and cheery. - - TeX is freely distributable. It is written in a dialect of Pascal -called WEB and can be compiled either in Pascal or (by using a -conversion program that comes with the TeX distribution) in C. (*Note -TeX Mode: (emacs)TeX Mode, for information about TeX.) - - TeX is very powerful and has a great many features. Because a -Texinfo file must be able to present information both on a -character-only terminal in Info form and in a typeset book, the -formatting commands that Texinfo supports are necessarily limited. - - *Note How to Obtain TeX: Obtaining TeX. - - ---------- Footnotes ---------- - - (1) You can also use the `texi2roff' program if you do not have -TeX; since Texinfo is designed for use with TeX, `texi2roff' is not -described here. `texi2roff' is part of the standard GNU distribution. - - -File: texi.info, Node: Formatting Commands, Next: Conventions, Prev: Printed Books, Up: Overview - -@-commands -========== - - In a Texinfo file, the commands that tell TeX how to typeset the -printed manual and tell `makeinfo' and `texinfo-format-buffer' how to -create an Info file are preceded by `@'; they are called "@-commands". -For example, `@node' is the command to indicate a node and `@chapter' -is the command to indicate the start of a chapter. - - *Please note:* All the @-commands, with the exception of the - `@TeX{}' command, must be written entirely in lower case. - - The Texinfo @-commands are a strictly limited set of constructs. The -strict limits make it possible for Texinfo files to be understood both -by TeX and by the code that converts them into Info files. You can -display Info files on any terminal that displays alphabetic and numeric -characters. Similarly, you can print the output generated by TeX on a -wide variety of printers. - - Depending on what they do or what arguments(1) they take, you need -to write @-commands on lines of their own or as part of sentences: - - * Write a command such as `@noindent' at the beginning of a line as - the only text on the line. (`@noindent' prevents the beginning of - the next line from being indented as the beginning of a paragraph.) - - * Write a command such as `@chapter' at the beginning of a line - followed by the command's arguments, in this case the chapter - title, on the rest of the line. (`@chapter' creates chapter - titles.) - - * Write a command such as `@dots{}' wherever you wish but usually - within a sentence. (`@dots{}' creates dots ...) - - * Write a command such as `@code{SAMPLE-CODE}' wherever you wish - (but usually within a sentence) with its argument, SAMPLE-CODE in - this example, between the braces. (`@code' marks text as being - code.) - - * Write a command such as `@example' at the beginning of a line of - its own; write the body-text on following lines; and write the - matching `@end' command, `@end example' in this case, at the - beginning of a line of its own after the body-text. (`@example' - ... `@end example' indents and typesets body-text as an example.) - -As a general rule, a command requires braces if it mingles among other -text; but it does not need braces if it starts a line of its own. The -non-alphabetic commands, such as `@:', are exceptions to the rule; they -do not need braces. - - As you gain experience with Texinfo, you will rapidly learn how to -write the different commands: the different ways to write commands make -it easier to write and read Texinfo files than if all commands followed -exactly the same syntax. (For details about @-command syntax, see -*Note @-Command Syntax: Command Syntax.) - - ---------- Footnotes ---------- - - (1) The word "argument" comes from the way it is used in -mathematics and does not refer to a disputation between two people; it -refers to the information presented to the command. According to the -`Oxford English Dictionary', the word derives from the Latin for "to -make clear, prove"; thus it came to mean `the evidence offered as -proof', which is to say, `the information offered', which led to its -mathematical meaning. In its other thread of derivation, the word came -to mean `to assert in a manner against which others may make counter -assertions', which led to the meaning of `argument' as a disputation. - - -File: texi.info, Node: Conventions, Next: Comments, Prev: Formatting Commands, Up: Overview - -General Syntactic Conventions -============================= - - All ASCII printing characters except `@', `{' and `}' can appear in -a Texinfo file and stand for themselves. `@' is the escape character -which introduces commands. `{' and `}' should be used only to surround -arguments to certain commands. To put one of these special characters -into the document, put an `@' character in front of it, like this: -`@@', `@{', and `@}'. - - It is customary in TeX to use doubled single-quote characters to -begin and end quotations: ` ` and ' ' (but without a space between the -two single-quote characters). This convention should be followed in -Texinfo files. TeX converts doubled single-quote characters to left- -and right-hand doubled quotation marks and Info converts doubled -single-quote characters to ASCII double-quotes: ` ` and ' ' to " . - - Use three hyphens in a row, `---', for a dash--like this. In TeX, a -single or even a double hyphen produces a printed dash that is shorter -than the usual typeset dash. Info reduces three hyphens to two for -display on the screen. - - To prevent a paragraph from being indented in the printed manual, put -the command `@noindent' on a line by itself before the paragraph. - - If you mark off a region of the Texinfo file with the `@iftex' and -`@end iftex' commands, that region will appear only in the printed -copy; in that region, you can use certain commands borrowed from -PlainTeX that you cannot use in Info. Likewise, if you mark off a -region with the `@ifinfo' and `@end ifinfo' commands, that region will -appear only in the Info file; in that region, you can use Info commands -that you cannot use in TeX. (*Note Conditionals::.) - - *Caution:* Do not use tabs in a Texinfo file! TeX uses - variable-width fonts, which means that it cannot predefine a tab - to work in all circumstances. Consequently, TeX treats tabs like - single spaces, and that is not what they look like. - - To avoid this problem, Texinfo mode causes GNU Emacs to insert - multiple spaces when you press the TAB key. - - Also, you can run `untabify' in Emacs to convert tabs in a region - to multiple spaces. - - -File: texi.info, Node: Comments, Next: Minimum, Prev: Conventions, Up: Overview - -Comments -======== - - You can write comments in a Texinfo file that will not appear in -either the Info file or the printed manual by using the `@comment' -command (which may be abbreviated to `@c'). Such comments are for the -person who reads the Texinfo file. All the text on a line that follows -either `@comment' or `@c' is a comment; the rest of the line does not -appear in either the Info file or the printed manual. (Often, you can -write the `@comment' or `@c' in the middle of a line, and only the text -that follows after the `@comment' or `@c' command does not appear; but -some commands, such as `@settitle' and `@setfilename', work on a whole -line. You cannot use `@comment' or `@c' in a line beginning with such -a command.) - - You can write long stretches of text that will not appear in either -the Info file or the printed manual by using the `@ignore' and `@end -ignore' commands. Write each of these commands on a line of its own, -starting each command at the beginning of the line. Text between these -two commands does not appear in the processed output. You can use -`@ignore' and `@end ignore' for writing comments. Often, `@ignore' and -`@end ignore' is used to enclose a part of the copying permissions that -applies to the Texinfo source file of a document, but not to the Info -or printed version of the document. - - -File: texi.info, Node: Minimum, Next: Six Parts, Prev: Comments, Up: Overview - -What a Texinfo File Must Have -============================= - - By convention, the names of Texinfo files end with one of the -extensions `.texinfo', `.texi', or `.tex'. The longer extension is -preferred since it describes more clearly to a human reader the nature -of the file. The shorter extensions are for operating systems that -cannot handle long file names. - - In order to be made into a printed manual and an Info file, a -Texinfo file *must* begin with lines like this: - - \input texinfo - @setfilename INFO-FILE-NAME - @settitle NAME-OF-MANUAL - -The contents of the file follow this beginning, and then you *must* end -a Texinfo file with a line like this: - - @bye - -The `\input texinfo' line tells TeX to use the `texinfo.tex' file, -which tells TeX how to translate the Texinfo @-commands into TeX -typesetting commands. (Note the use of the backslash, `\'; this is -correct for TeX.) The `@setfilename' line provides a name for the Info -file and the `@settitle' line specifies a title for the page headers (or -footers) of the printed manual. - - The `@bye' line at the end of the file on a line of its own tells -the formatters that the file is ended and to stop formatting. - - Usually, you will not use quite such a spare format, but will include -mode setting and start-of-header and end-of-header lines at the -beginning of a Texinfo file, like this: - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename INFO-FILE-NAME - @settitle NAME-OF-MANUAL - @c %**end of header - -In the first line, `-*-texinfo-*-' causes Emacs to switch into Texinfo -mode when you edit the file. - - The `@c' lines which surround the `@setfilename' and `@settitle' -lines are optional, but you need them in order to run TeX or Info on -just part of the file. (*Note Start of Header::, for more information.) - - Furthermore, you will usually provide a Texinfo file with a title -page, indices, and the like. But the minimum, which can be useful for -short documents, is just the three lines at the beginning and the one -line at the end. - - -File: texi.info, Node: Six Parts, Next: Short Sample, Prev: Minimum, Up: Overview - -Six Parts of a Texinfo File -=========================== - - Generally, a Texinfo file contains more than the minimal beginning -and end--it usually contains six parts: - -1. Header - The "Header" names the file, tells TeX which definitions' file to - use, and performs other "housekeeping" tasks. - -2. Summary Description and Copyright - The "Summary Description and Copyright" segment describes the - document and contains the copyright notice and copying permissions - for the Info file. The segment must be enclosed between `@ifinfo' - and `@end ifinfo' commands so that the formatters place it only in - the Info file. - -3. Title and Copyright - The "Title and Copyright" segment contains the title and copyright - pages and copying permissions for the printed manual. The segment - must be enclosed between `@titlepage' and `@end titlepage' - commands. The title and copyright page appear only in the printed - manual. - -4. `Top' Node and Master Menu - The "Master Menu" contains a complete menu of all the nodes in the - whole Info file. It appears only in the Info file, in the `Top' - node. - -5. Body - The "Body" of the document may be structured like a traditional - book or encyclopedia or it may be free form. - -6. End - The "End" contains commands for printing indices and generating - the table of contents, and the `@bye' command on a line of its own. - - -File: texi.info, Node: Short Sample, Next: Acknowledgements, Prev: Six Parts, Up: Overview - -A Short Sample Texinfo File -=========================== - - Here is a complete but very short Texinfo file, in 6 parts. The -first three parts of the file, from `\input texinfo' through to `@end -titlepage', look more intimidating than they are. Most of the material -is standard boilerplate; when you write a manual, simply insert the -names for your own manual in this segment. (*Note Beginning a File::.) - -In the following, the sample text is *indented*; comments on it are -not. The complete file, without any comments, is shown in *Note Sample -Texinfo File::. - -Part 1: Header --------------- - -The header does not appear in either the Info file or the -printed output. It sets various parameters, including the -name of the Info file and the title used in the header. - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename sample.info - @settitle Sample Document - @c %**end of header - - @setchapternewpage odd - -Part 2: Summary Description and Copyright ------------------------------------------ - -The summary description and copyright segment does not -appear in the printed document. - - @ifinfo - This is a short example of a complete Texinfo file. - - Copyright @copyright{} 1990 Free Software Foundation, Inc. - @end ifinfo - -Part 3: Titlepage and Copyright -------------------------------- - -The titlepage segment does not appear in the Info file. - - @titlepage - @sp 10 - @comment The title is printed in a large font. - @center @titlefont{Sample Title} - - @c The following two commands start the copyright page. - @page - @vskip 0pt plus 1filll - Copyright @copyright{} 1990 Free Software Foundation, Inc. - @end titlepage - -Part 4: `Top' Node and Master Menu ----------------------------------- - -The `Top' node contains the master menu for the Info file. -Since a printed manual uses a table of contents rather than -a menu, the master menu appears only in the Info file. - - @node Top, First Chapter, (dir), (dir) - @comment node-name, next, previous, up - - @menu - * First Chapter:: The first chapter is the - only chapter in this sample. - * Concept Index:: This index has two entries. - @end menu - -Part 5: The Body of the Document ---------------------------------- - -The body segment contains all the text of the document, but not the -indices or table of contents. This example illustrates a node and a -chapter containing an enumerated list. - - @node First Chapter, Concept Index, Top, Top - @comment node-name, next, previous, up - @chapter First Chapter - @cindex Sample index entry - - This is the contents of the first chapter. - @cindex Another sample index entry - - Here is a numbered list. - - @enumerate - @item - This is the first item. - - @item - This is the second item. - @end enumerate - - The @code{makeinfo} and @code{texinfo-format-buffer} - commands transform a Texinfo file such as this into - an Info file; and @TeX{} typesets it for a printed - manual. - -Part 6: The End of the Document -------------------------------- - -The end segment contains commands both for generating an index in a node -and unnumbered chapter of its own and for generating the table of -contents; and it contains the `@bye' command that marks the end of the -document. - - @node Concept Index, , First Chapter, Top - @comment node-name, next, previous, up - @unnumbered Concept Index - - @printindex cp - - @contents - @bye - -The Results ------------ - - Here is what the contents of the first chapter of the sample look -like: - - This is the contents of the first chapter. - - Here is a numbered list. - - 1. This is the first item. - - 2. This is the second item. - - The `makeinfo' and `texinfo-format-buffer' commands transform a - Texinfo file such as this into an Info file; and TeX typesets it - for a printed manual. - - -File: texi.info, Node: Acknowledgements, Prev: Short Sample, Up: Overview - -Acknowledgements -================ - - Richard M. Stallman wrote Edition 1.0 of this manual. -Robert J. Chassell revised and extended it, starting with Edition 1.1. - - Our thanks go out to all who helped improve this work, particularly -to Francois Pinard and David D. Zuhn, who tirelessly recorded and -reported mistakes and obscurities; our special thanks go to -Melissa Weisshaus for her frequent and often tedious reviews of nearly -similar editions. Our mistakes are our own. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-10 b/gnu/usr.bin/texinfo/info-files/texi.info-10 deleted file mode 100644 index f28ff2e0e2a8..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-10 +++ /dev/null @@ -1,1165 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Debugging with TeX, Next: Using texinfo-show-structure, Prev: Debugging with Info, Up: Catching Mistakes - -Catching Errors with TeX Formatting -=================================== - - You can also catch mistakes when you format a file with TeX. - - Usually, you do this after you have run `texinfo-format-buffer' (or, -better, `makeinfo-buffer') on the same file, because -`texinfo-format-buffer' sometimes displays error messages that make -more sense than TeX. (*Note Debugging with Info::, for more -information.) - - For example, TeX was run on a Texinfo file, part of which is shown -here: - - ---------- Buffer: texinfo.texi ---------- - name of the texinfo file as an extension. The - @samp{??} are `wildcards' that cause the shell to - substitute all the raw index files. (@xref{sorting - indices, for more information about sorting - indices.)@refill - ---------- Buffer: texinfo.texi ---------- - -(The cross reference lacks a closing brace.) TeX produced the following -output, after which it stopped: - - ---------- Buffer: *texinfo-tex-shell* ---------- - Runaway argument? - {sorting indices, for more information about sorting - indices.) @refill @ETC. - ! Paragraph ended before @xref was complete. - - @par - l.27 - - ? - ---------- Buffer: *texinfo-tex-shell* ---------- - - In this case, TeX produced an accurate and understandable error -message: - - Paragraph ended before @xref was complete. - -`@par' is an internal TeX command of no relevance to Texinfo. `l.27' -means that TeX detected the problem on line 27 of the Texinfo file. -The `?' is the prompt TeX uses in this circumstance. - - Unfortunately, TeX is not always so helpful, and sometimes you must -truly be a Sherlock Holmes to discover what went wrong. - - In any case, if you run into a problem like this, you can do one of -three things. - - 1. You can tell TeX to continue running and ignore just this error by - typing RET at the `?' prompt. - - 2. You can tell TeX to continue running and to ignore all errors as - best it can by typing `r RET' at the `?' prompt. - - This is often the best thing to do. However, beware: the one error - may produce a cascade of additional error messages as its - consequences are felt through the rest of the file. (To stop TeX - when it is producing such an avalanche of error messages, type - `C-d' (or `C-c C-d', if you are running a shell inside Emacs - Version 18.)) - - 3. You can tell TeX to stop this run by typing `x RET' at the `?' - prompt. - - Please note that if you are running TeX inside Emacs, you need to -switch to the shell buffer and line at which TeX offers the `?' prompt. - - Sometimes TeX will format a file without producing error messages -even though there is a problem. This usually occurs if a command is -not ended but TeX is able to continue processing anyhow. For example, -if you fail to end an itemized list with the `@end itemize' command, -TeX will write a DVI file that you can print out. The only error -message that TeX will give you is the somewhat mysterious comment that - - (@end occurred inside a group at level 1) - -However, if you print the DVI file, you will find that the text of the -file that follows the itemized list is entirely indented as if it were -part of the last item in the itemized list. The error message is the -way TeX says that it expected to find an `@end' command somewhere in -the file; but that it could not determine where it was needed. - - Another source of notoriously hard-to-find errors is a missing `@end -group' command. If you ever are stumped by incomprehensible errors, -look for a missing `@end group' command first. - - If the Texinfo file lacks header lines, TeX may stop in the -beginning of its run and display output that looks like the following. -The `*' indicates that TeX is waiting for input. - - This is TeX, Version 2.0 for Berkeley UNIX - (preloaded format=plain-cm 87.10.25) - (test.texinfo [1]) - * - -In this case, simply type `\end RET' after the asterisk. Then write -the header lines in the Texinfo file and run the TeX command again. -(Note the use of the backslash, `\'. TeX uses `\' instead of `@'; and -in this circumstance, you are working directly with TeX, not with -Texinfo.) - - -File: texi.info, Node: Using texinfo-show-structure, Next: Using occur, Prev: Debugging with TeX, Up: Catching Mistakes - -Using `texinfo-show-structure' -============================== - - It is not always easy to keep track of the nodes, chapters, -sections, and subsections of a Texinfo file. This is especially true -if you are revising or adding to a Texinfo file that someone else has -written. - - In GNU Emacs, in Texinfo mode, the `texinfo-show-structure' command -lists all the lines that begin with the @-commands that specify the -structure: `@chapter', `@section', `@appendix', and so on. With an -argument (`C-u' as prefix argument, if interactive), the command also -shows the `@node' lines. The `texinfo-show-structure' command is bound -to `C-c C-s' in Texinfo mode, by default. - - The lines are displayed in a buffer called the `*Occur*' buffer. -For example, when `texinfo-show-structure' was run on an earlier -version of this appendix, it produced the following: - - Lines matching "^@\\(chapter \\|sect\\|sub\\|unnum\\|major\\| - heading \\|appendix\\)" in buffer texinfo.texi. - 4:@appendix Formatting Mistakes - 52:@appendixsec Catching Errors with Info Formatting - 222:@appendixsec Catching Errors with @TeX{} Formatting - 338:@appendixsec Using @code{texinfo-show-structure} - 407:@appendixsubsec Using @code{occur} - 444:@appendixsec Finding Badly Referenced Nodes - 513:@appendixsubsec Running @code{Info-validate} - 573:@appendixsubsec Splitting a File Manually - - This says that lines 4, 52, and 222 of `texinfo.texi' begin with the -`@appendix', `@appendixsec', and `@appendixsec' commands respectively. -If you move your cursor into the `*Occur*' window, you can position the -cursor over one of the lines and use the `C-c C-c' command -(`occur-mode-goto-occurrence'), to jump to the corresponding spot in -the Texinfo file. *Note Using Occur: (emacs)Other Repeating Search, -for more information about `occur-mode-goto-occurrence'. - - The first line in the `*Occur*' window describes the "regular -expression" specified by TEXINFO-HEADING-PATTERN. This regular -expression is the pattern that `texinfo-show-structure' looks for. -*Note Using Regular Expressions: (emacs)Regexps, for more information. - - When you invoke the `texinfo-show-structure' command, Emacs will -display the structure of the whole buffer. If you want to see the -structure of just a part of the buffer, of one chapter, for example, -use the `C-x n' (`narrow-to-region') command to mark the region. -(*Note Narrowing: (emacs)Narrowing.) This is how the example used -above was generated. (To see the whole buffer again, use `C-x w' -(`widen').) - - If you call `texinfo-show-structure' with a prefix argument by -typing `C-u C-c C-s', it will list lines beginning with `@node' as well -as the lines beginning with the @-sign commands for `@chapter', -`@section', and the like. - - You can remind yourself of the structure of a Texinfo file by -looking at the list in the `*Occur*' window; and if you have mis-named -a node or left out a section, you can correct the mistake. - - -File: texi.info, Node: Using occur, Next: Running Info-Validate, Prev: Using texinfo-show-structure, Up: Catching Mistakes - -Using `occur' -============= - - Sometimes the `texinfo-show-structure' command produces too much -information. Perhaps you want to remind yourself of the overall -structure of a Texinfo file, and are overwhelmed by the detailed list -produced by `texinfo-show-structure'. In this case, you can use the -`occur' command directly. To do this, type - - `M-x occur' - -and then, when prompted, type a "regexp", a regular expression for the -pattern you want to match. (*Note Regular Expressions: -(emacs)Regexps.) The `occur' command works from the current location -of the cursor in the buffer to the end of the buffer. If you want to -run `occur' on the whole buffer, place the cursor at the beginning of -the buffer. - - For example, to see all the lines that contain the word `@chapter' -in them, just type `@chapter'. This will produce a list of the -chapters. It will also list all the sentences with `@chapter' in the -middle of the line. - - If you want to see only those lines that start with the word -`@chapter', type `^@chapter' when prompted by `occur'. If you want to -see all the lines that end with a word or phrase, end the last word -with a `$'; for example, `catching mistakes$'. This can be helpful -when you want to see all the nodes that are part of the same chapter or -section and therefore have the same `Up' pointer. - - *Note Using Occur: (emacs)Other Repeating Search, for more -information. - - -File: texi.info, Node: Running Info-Validate, Prev: Using occur, Up: Catching Mistakes - -Finding Badly Referenced Nodes -============================== - - You can use the `Info-validate' command to check whether any of the -`Next', `Previous', `Up' or other node pointers fail to point to a -node. This command checks that every node pointer points to an -existing node. The `Info-validate' command works only on Info files, -not on Texinfo files. - - The `makeinfo' program validates pointers automatically, so you do -not need to use the `Info-validate' command if you are using -`makeinfo'. You only may need to use `Info-validate' if you are unable -to run `makeinfo' and instead must create an Info file using -`texinfo-format-region' or `texinfo-format-buffer', or if you write an -Info file from scratch. - -* Menu: - -* Using Info-validate:: How to run `Info-validate'. -* Unsplit:: How to create an unsplit file. -* Tagifying:: How to tagify a file. -* Splitting:: How to split a file manually. - - -File: texi.info, Node: Using Info-validate, Next: Unsplit, Up: Running Info-Validate - -Running `Info-validate' ------------------------ - - To use `Info-validate', visit the Info file you wish to check and -type: - - M-x Info-validate - -(Note that the `Info-validate' command requires an upper case `I'. You -may also need to create a tag table before running `Info-validate'. -*Note Tagifying::.) - - If your file is valid, you will receive a message that says "File -appears valid". However, if you have a pointer that does not point to -a node, error messages will be displayed in a buffer called `*problems -in info file*'. - - For example, `Info-validate' was run on a test file that contained -only the first node of this manual. One of the messages said: - - In node "Overview", invalid Next: Texinfo Mode - -This meant that the node called `Overview' had a `Next' pointer that -did not point to anything (which was true in this case, since the test -file had only one node in it). - - Now suppose we add a node named `Texinfo Mode' to our test case but -we do not specify a `Previous' for this node. Then we will get the -following error message: - - In node "Texinfo Mode", should have Previous: Overview - -This is because every `Next' pointer should be matched by a `Previous' -(in the node where the `Next' points) which points back. - - `Info-validate' also checks that all menu entries and cross -references point to actual nodes. - - Note that `Info-validate' requires a tag table and does not work -with files that have been split. (The `texinfo-format-buffer' command -automatically splits large files.) In order to use `Info-validate' on -a large file, you must run `texinfo-format-buffer' with an argument so -that it does not split the Info file; and you must create a tag table -for the unsplit file. - - -File: texi.info, Node: Unsplit, Next: Tagifying, Prev: Using Info-validate, Up: Running Info-Validate - -Creating an Unsplit File ------------------------- - - You can run `Info-validate' only on a single Info file that has a -tag table. The command will not work on the indirect subfiles that are -generated when a master file is split. If you have a large file -(longer than 70,000 bytes or so), you need to run the -`texinfo-format-buffer' or `makeinfo-buffer' command in such a way that -it does not create indirect subfiles. You will also need to create a -tag table for the Info file. After you have done this, you can run -`Info-validate' and look for badly referenced nodes. - - The first step is to create an unsplit Info file. - - To prevent `texinfo-format-buffer' from splitting a Texinfo file -into smaller Info files, give a prefix to the `M-x -texinfo-format-buffer' command: - - C-u M-x texinfo-format-buffer - -or else - - C-u C-c C-e C-b - -When you do this, Texinfo will not split the file and will not create a -tag table for it. - - -File: texi.info, Node: Tagifying, Next: Splitting, Prev: Unsplit, Up: Running Info-Validate - -Tagifying a File ----------------- - - After creating an unsplit Info file, you must create a tag table for -it. Visit the Info file you wish to tagify and type: - - M-x Info-tagify - -(Note the upper case I in `Info-tagify'.) This creates an Info file -with a tag table that you can validate. - - The third step is to validate the Info file: - - M-x Info-validate - -(Note the upper case I in `Info-validate'.) In brief, the steps are: - - C-u M-x texinfo-format-buffer - M-x Info-tagify - M-x Info-validate - - After you have validated the node structure, you will be able to -rerun `texinfo-format-buffer' in the normal way so it will construct a -tag table and split the file automatically, or you can make the tag -table and split the file manually. - - -File: texi.info, Node: Splitting, Prev: Tagifying, Up: Running Info-Validate - -Splitting a File Manually -------------------------- - - You should split a large file or else let the -`texinfo-format-buffer' or `makeinfo-buffer' command do it for you -automatically. (Generally you will let one of the formatting commands -do this job for you. *Note Create an Info File::.) - - The split-off files are called the indirect subfiles. - - Info files are split to save memory. With smaller files, Emacs does -not have make such a large buffer to hold the information. - - If an Info file has more than 30 nodes, you should also make a tag -table for it. *Note Using Info-validate::, for information about -creating a tag table. (Again, tag tables are usually created -automatically by the formatting command; you only need to create a tag -table yourself if you are doing the job manually. Most likely, you -will do this for a large, unsplit file on which you have run -`Info-validate'.) - - Visit the Info file you wish to tagify and split and type the two -commands: - - M-x Info-tagify - M-x Info-split - -(Note that the `I' in `Info' is upper case.) - - When you use the `Info-split' command, the buffer is modified into a -(small) Info file which lists the indirect subfiles. This file should -be saved in place of the original visited file. The indirect subfiles -are written in the same directory the original file is in, with names -generated by appending `-' and a number to the original file name. - - The primary file still functions as an Info file, but it contains -just the tag table and a directory of subfiles. - - -File: texi.info, Node: Refilling Paragraphs, Next: Command Syntax, Prev: Catching Mistakes, Up: Top - -Refilling Paragraphs -******************** - - The `@refill' command refills and, optionally, indents the first -line of a paragraph.(1) The `@refill' command is no longer important, -but we describe it here because you once needed it. You will see it in -many old Texinfo files. - - Without refilling, paragraphs containing long @-constructs may look -bad after formatting because the formatter removes @-commands and -shortens some lines more than others. In the past, neither -`texinfo-format-region' nor `texinfo-format-buffer' refilled paragraphs -automatically. The `@refill' command had to be written at the end of -every paragraph to cause these formatters to fill them. (Both TeX and -`makeinfo' have always refilled paragraphs automatically.) Now, all -the Info formatters automatically fill and indent those paragraphs that -need to be filled and indented. - - The `@refill' command causes both the `texinfo-format-region' -command and the `texinfo-format-buffer' command to refill a paragraph -in the Info file *after* all the other processing has been done. For -this reason, you can not use `@refill' with a paragraph containing -either `@*' or `@w{ ... }' since the refilling action will override -those two commands. - - The `texinfo-format-region' and `texinfo-format-buffer' commands now -automatically append `@refill' to the end of each paragraph that should -be filled. They do not append `@refill' to the ends of paragraphs that -contain `@*' or `@w{ ...}' and therefore do not refill or indent them. - - ---------- Footnotes ---------- - - (1) Perhaps the command should have been called the -`@refillandindent' command, but `@refill' is shorter and the name was -chosen before indenting was possible. - - -File: texi.info, Node: Command Syntax, Next: Obtaining TeX, Prev: Refilling Paragraphs, Up: Top - -@-Command Syntax -**************** - - The character `@' is used to start special Texinfo commands. (It -has the same meaning that `\' has in PlainTeX.) Texinfo has four types -of @-command: - -1. Non-alphabetic commands. - These commands consist of an @ followed by a punctuation mark or - other character that is not part of the alphabet. Non-alphabetic - commands are almost always part of the text within a paragraph, - and never take any argument. The two characters (@ and the other - one) are complete in themselves; none is followed by braces. The - non-alphabetic commands are: `@.', `@:', `@*', `@@', `@{', and - `@}'. - -2. Alphabetic commands that do not require arguments. - These commands start with @ followed by a word followed by left- - and right-hand braces. These commands insert special symbols in - the document; they do not require arguments. For example, - `@dots{}' => `...', `@equiv{}' => `==', `@TeX{}' => `TeX', and - `@bullet{}' => `*'. - -3. Alphabetic commands that require arguments within braces. - These commands start with @ followed by a letter or a word, - followed by an argument within braces. For example, the command - `@dfn' indicates the introductory or defining use of a term; it is - used as follows: `In Texinfo, @@-commands are @dfn{mark-up} - commands.' - -4. Alphabetic commands that occupy an entire line. - These commands occupy an entire line. The line starts with @, - followed by the name of the command (a word); for example, - `@center' or `@cindex'. If no argument is needed, the word is - followed by the end of the line. If there is an argument, it is - separated from the command name by a space. Braces are not used. - - Thus, the alphabetic commands fall into classes that have different -argument syntaxes. You cannot tell to which class a command belongs by -the appearance of its name, but you can tell by the command's meaning: -if the command stands for a glyph, it is in class 2 and does not -require an argument; if it makes sense to use the command together with -other text as part of a paragraph, the command is in class 3 and must -be followed by an argument in braces; otherwise, it is in class 4 and -uses the rest of the line as its argument. - - The purpose of having a different syntax for commands of classes 3 -and 4 is to make Texinfo files easier to read, and also to help the GNU -Emacs paragraph and filling commands work properly. There is only one -exception to this rule: the command `@refill', which is always used at -the end of a paragraph immediately following the final period or other -punctuation character. `@refill' takes no argument and does *not* -require braces. `@refill' never confuses the Emacs paragraph commands -because it cannot appear at the beginning of a line. - - -File: texi.info, Node: Obtaining TeX, Next: New Features, Prev: Command Syntax, Up: Top - -How to Obtain TeX -***************** - - TeX is freely redistributable. You can obtain TeX for Unix systems -from the University of Washington for a distribution fee. - - To order a full distribution, send $200.00 for a 1/2-inch 9-track -1600 bpi (`tar' or `cpio') tape reel, or $210.00 for a 1/4-inch 4-track -QIC-24 (`tar' or `cpio') cartridge, to: - - Northwest Computing Support Center - DR-10, Thomson Hall 35 - University of Washington - Seattle, Washington 98195 - -Please make checks payable to the University of Washington. - - Prepaid orders are preferred but purchase orders are acceptable; -however, purchase orders carry an extra charge of $10.00, to pay for -processing. - - Overseas sites: please add to the base cost $20.00 for shipment via -air parcel post, or $30.00 for shipment via courier. - - Please check with the Northwest Computing Support Center at the -University of Washington for current prices and formats: - - telephone: (206) 543-6259 - email: elisabet@u.washington.edu - - -File: texi.info, Node: New Features, Next: Command and Variable Index, Prev: Obtaining TeX, Up: Top - -Second Edition Features -*********************** - - The second edition of the Texinfo manual describes more than 20 new -Texinfo mode commands and more than 50 previously undocumented Texinfo -@-commands. This edition is more than twice the length of the first -edition. - - Here is a brief description of the new commands. - -* Menu: - -* New Texinfo Mode Commands:: The updating commands are especially useful. -* New Commands:: Many newly described @-commands. - - -File: texi.info, Node: New Texinfo Mode Commands, Next: New Commands, Up: New Features - -New Texinfo Mode Commands -========================= - - Texinfo mode provides commands and features especially designed for -working with Texinfo files. More than 20 new commands have been added, -including commands for automatically creating and updating both nodes -and menus. This is a tedious task when done by hand. - - The keybindings are intended to be somewhat mnemonic. - -Update all nodes and menus --------------------------- - - The `texinfo-master-menu' command is the primary command: - -`C-c C-u m' -`M-x texinfo-master-menu' - Create or update a master menu. With `C-u' as a prefix argument, - first create or update all nodes and regular menus. - -Update Pointers ---------------- - -Create or update `Next', `Previous', and `Up' node pointers. - -*Note Updating Nodes and Menus::. - -`C-c C-u C-n' -`M-x texinfo-update-node' - Update a node. - -`C-c C-u C-e' -`M-x texinfo-every-node-update' - Update every node in the buffer. - -Update Menus ------------- - -Create or update menus. - -*Note Updating Nodes and Menus::. - -`C-c C-u C-m' -`M-x texinfo-make-menu' - Make or update a menu. - -`C-c C-u C-a' -`M-x texinfo-all-menus-update' - Make or update all the menus in a buffer. With `C-u' as a prefix - argument, first update all the nodes. - -Insert Title as Description ---------------------------- - -Insert a node's chapter or section title in the space for the -description in a menu entry line; position point so you can edit the -insert. (This command works somewhat differently than the other -insertion commands, which insert only a predefined string.) - -*Note Inserting Frequently Used Commands: Inserting. - -`C-c C-c C-d' - Insert title. - -Format for Info ---------------- - -Provide keybindings both for the Info formatting commands that are -written in Emacs Lisp and for `makeinfo' that is written in C. - -*Note Info Formatting::. - -Use the Emacs lisp `texinfo-format...' commands: - -`C-c C-e C-r' - Format the region. - -`C-c C-e C-b' - Format the buffer. - -Use `makeinfo': - -`C-c C-m C-r' - Format the region. - -`C-c C-m C-b' - Format the buffer. - -`C-c C-m C-l' - Recenter the `makeinfo' output buffer. - -`C-c C-m C-k' - Kill the `makeinfo' formatting job. - -Typeset and Print ------------------ - -Typeset and print Texinfo documents from within Emacs. - -*Note Printing::. - -`C-c C-t C-r' - Run TeX on the region. - -`C-c C-t C-b' - Run TeX on the buffer. - -`C-c C-t C-i' - Run `texindex'. - -`C-c C-t C-p' - Print the DVI file. - -`C-c C-t C-q' - Show the print queue. - -`C-c C-t C-d' - Delete a job from the print queue. - -`C-c C-t C-k' - Kill the current TeX formatting job. - -`C-c C-t C-x' - Quit a currently stopped TeX formatting job. - -`C-c C-t C-l' - Recenter the output buffer. - -Other Updating Commands ------------------------ - -The "other updating commands" do not have standard keybindings because -they are used less frequently. - -*Note Other Updating Commands::. - -`M-x texinfo-insert-node-lines' - Insert missing `@node' lines using section titles as node names. - -`M-x texinfo-multiple-files-update' - Update a multi-file document. With a numeric prefix, such as `C-u - 8', update *every* pointer and menu in *all* the files and then - insert a master menu. - -`M-x texinfo-indent-menu-description' - Indent descriptions in menus. - -`M-x texinfo-sequential-node-update' - Insert node pointers in strict sequence. - - -File: texi.info, Node: New Commands, Prev: New Texinfo Mode Commands, Up: New Features - -New Texinfo @-Commands -====================== - - The second edition of the Texinfo manual describes more than 50 -commands that were not described in the first edition. A third or so -of these commands existed in Texinfo but were not documented in the -manual; the others are new. Here is a listing, with brief descriptions -of them: - -Indexing --------- - -Create your own index, and merge indices. - -*Note Indices::. - -`@defindex INDEX-NAME' - Define a new index and its indexing command. See also the - `@defcodeindex' command. - -`@synindex FROM-INDEX INTO-INDEX' - Merge the FROM-INDEX index into the INTO-INDEX index. See also - the `@syncodeindex' command. - -Definitions ------------ - -Describe functions, variables, macros, commands, user options, special -forms, and other such artifacts in a uniform format. - -*Note Definition Commands::. - -`@deffn CATEGORY NAME ARGUMENTS...' - Format a description for functions, interactive commands, and - similar entities. - -`@defvr, @defop, ...' - 15 other related commands. - -Glyphs ------- - -Indicate the results of evaluation, expansion, printed output, an error -message, equivalence of expressions, and the location of point. - -*Note Glyphs::. - -`@equiv{}' -`==' - Equivalence: - -`@error{}' -`error-->' - Error message - -`@expansion{}' -`==>' - Macro expansion - -`@point{}' -`-!-' - Position of point - -`@print{}' -`-|' - Printed output - -`@result{}' -`=>' - Result of an expression - -Page Headings -------------- - -Customize page headings. - -*Note Headings::. - -`@headings ON-OFF-SINGLE-DOUBLE' - Headings on or off, single, or double-sided. - -`@evenfooting [LEFT] @| [CENTER] @| [RIGHT]' - Footings for even-numbered (left-hand) pages. - -`@evenheading, @everyheading, @oddheading, ...' - Five other related commands. - -`@thischapter' - Insert name of chapter and chapter number. - -`@thischaptername, @thisfile, @thistitle, @thispage' - Related commands. - -Formatting ----------- - -Format blocks of text. - -*Note Quotations and Examples::, and -*Note Making Lists and Tables: Lists and Tables. - -`@cartouche' - Draw rounded box surrounding text (not in Info). - -`@enumerate OPTIONAL-ARG' - Enumerate a list with letters or numbers. - -`@exdent LINE-OF-TEXT' - Remove indentation. - -`@flushleft' - Left justify. - -`@flushright' - Right justify. - -`@format' - Do not narrow nor change font. - -`@ftable FORMATTING-COMMAND' -`@vtable FORMATTING-COMMAND' - Two-column table with indexing. - -`@lisp' - For an example of Lisp code. - -`@smallexample' -`@smalllisp' - Like @table and @lisp but for @smallbook. - -Conditionals ------------- - -Conditionally format text. - -*Note `@set' `@clear' `@value': set clear value. - -`@set FLAG [STRING]' - Set a flag. Optionally, set value of FLAG to STRING. - -`@clear FLAG' - Clear a flag. - -`@value{FLAG}' - Replace with value to which FLAG is set. - -`@ifset FLAG' - Format, if FLAG is set. - -`@ifclear FLAG' - Ignore, if FLAG is set. - -@heading series for Titles --------------------------- - -Produce unnumbered headings that do not appear in a table of contents. - -*Note Structuring::. - -`@heading TITLE' - Unnumbered section-like heading not listed in the table of - contents of a printed manual. - -`@chapheading, @majorheading, @subheading, @subsubheading' - Related commands. - -Font commands -------------- - -*Note Smallcaps::, and -*Note Fonts::. - -`@r{TEXT}' - Print in roman font. - -`@sc{TEXT}' - Print in SMALL CAPS font. - -Miscellaneous -------------- - -See *Note `@title' `@subtitle' and `@author' Commands: title subtitle -author, -see *Note Overfull hboxes::, -see *Note Footnotes::, -see *Note Format a Dimension: dmn, -see *Note Inserting a Minus Sign: minus, -see *Note Paragraph Indenting: paragraphindent, -see *Note Cross Reference Commands::, -see *Note `@title' `@subtitle' and `@author': title subtitle author, and -see *Note How to Make Your Own Headings: Custom Headings. - -`@author AUTHOR' - Typeset author's name. - -`@finalout' - Produce cleaner printed output. - -`@footnotestyle' - Specify footnote style. - -`@dmn{DIMENSION}' - Format a dimension. - -`@minus{}' - Generate a minus sign. - -`@paragraphindent' - Specify paragraph indentation. - -`@ref{NODE-NAME, [ENTRY], [TOPIC-OR-TITLE], [INFO-FILE], [MANUAL]}' - Make a reference. In the printed manual, the reference does not - start with the word `see'. - -`@title TITLE' - Typeset TITLE in the alternative title page format. - -`@subtitle SUBTITLE' - Typeset SUBTITLE in the alternative title page format. - -`@today{}' - Insert the current date. - - -File: texi.info, Node: Command and Variable Index, Next: Concept Index, Prev: New Features, Up: Top - -Command and Variable Index -************************** - - This is an alphabetical list of all the @-commands and several -variables. To make the list easier to use, the commands are listed -without their preceding `@'. - -* Menu: - -* * (force line break): Line Breaks. -* . (true end of sentence): Controlling Spacing. -* : (suppress widening): Controlling Spacing. -* @ (single @): Inserting An Atsign. -* { (single {): Inserting Braces. -* } (single }): Inserting Braces. -* afourpaper: A4 Paper. -* appendix: unnumbered & appendix. -* appendixsec: unnumberedsec appendixsec heading. -* appendixsection: unnumberedsec appendixsec heading. -* appendixsubsec: unnumberedsubsec appendixsubsec subheading. -* appendixsubsubsec: subsubsection. -* apply: Sample Function Definition. -* author: title subtitle author. -* b (bold font): Fonts. -* buffer-end: Def Cmd Template. -* bullet: bullet. -* bye: Ending a File. -* bye: File End. -* c (comment): Comments. -* cartouche: cartouche. -* center: titlefont center sp. -* chapheading: majorheading & chapheading. -* chapter: chapter. -* cindex: Indexing Commands. -* cite: cite. -* clear: ifset ifclear. -* code: code. -* comment: Comments. -* contents: Contents. -* copyright: copyright symbol. -* copyright: Copyright & Permissions. -* cropmarks: Cropmarks and Magnification. -* defcodeindex: New Indices. -* defcv: Abstract Objects. -* deffn: Functions Commands. -* deffnx: deffnx. -* defindex: New Indices. -* defivar: Abstract Objects. -* defmac: Functions Commands. -* defmethod: Abstract Objects. -* defop: Abstract Objects. -* defopt: Variables Commands. -* defspec: Functions Commands. -* deftp: Data Types. -* deftypefn: Typed Functions. -* deftypefun: Typed Functions. -* deftypevar: Typed Variables. -* deftypevr: Typed Variables. -* defun: Functions Commands. -* defvar: Variables Commands. -* defvr: Variables Commands. -* dfn: dfn. -* display: display. -* dmn: dmn. -* dots: dots. -* emph: emph & strong. -* end: Quotations and Examples. -* end: Introducing Lists. -* end titlepage: end titlepage. -* enumerate: enumerate. -* evenfooting: Custom Headings. -* evenheading: Custom Headings. -* everyfooting: Custom Headings. -* everyheading: Custom Headings. -* example: example. -* exdent: exdent. -* file: file. -* filll: Copyright & Permissions. -* finalout: Overfull hboxes. -* findex: Indexing Commands. -* flushleft: flushleft & flushright. -* flushright: flushleft & flushright. -* foobar: Optional Arguments. -* footnote: Footnotes. -* footnotestyle: Footnotes. -* format: format. -* forward-word: Def Cmd Template. -* ftable: ftable vtable. -* group: group. -* heading: unnumberedsec appendixsec heading. -* headings: headings on off. -* i (italic font): Fonts. -* ifclear: ifset ifclear. -* ifinfo: Conditionals. -* ifset: ifset ifclear. -* iftex: Conditionals. -* ignore: Comments. -* include: Using Include Files. -* Info-validate: Running Info-Validate. -* INFOPATH: Other Info Directories. -* inforef: inforef. -* input (TeX command): Minimum. -* isearch-backward: deffnx. -* isearch-forward: deffnx. -* item: itemize. -* item: table. -* itemize: itemize. -* itemx: itemx. -* kbd: kbd. -* key: key. -* kindex: Indexing Commands. -* lisp: Lisp Example. -* lpr (DVI print command): Shell Format & Print. -* mag (TeX command): Cropmarks and Magnification. -* majorheading: majorheading & chapheading. -* makeinfo-buffer: makeinfo in Emacs. -* makeinfo-kill-job: makeinfo in Emacs. -* makeinfo-recenter-output-buffer: makeinfo in Emacs. -* makeinfo-region: makeinfo in Emacs. -* menu: Menus. -* minus: minus. -* need: need. -* next-error: makeinfo in Emacs. -* noindent: noindent. -* occur: Using occur. -* occur-mode-goto-occurrence: Showing the Structure. -* oddfooting: Custom Headings. -* oddheading: Custom Headings. -* page: page. -* page-delimiter: Showing the Structure. -* paragraphindent: paragraphindent. -* pindex: Indexing Commands. -* printindex: Printing Indices & Menus. -* pxref: pxref. -* quotation: quotation. -* r (Roman font): Fonts. -* ref: ref. -* refill: Refilling Paragraphs. -* samp: samp. -* sc (small caps font): Smallcaps. -* section: section. -* set: ifset ifclear. -* setchapternewpage: setchapternewpage. -* setfilename: setfilename. -* settitle: settitle. -* shortcontents: Contents. -* smallbook: smallbook. -* smallexample: smallexample & smalllisp. -* smalllisp: smallexample & smalllisp. -* sp (line spacing): sp. -* sp (titlepage line spacing): titlefont center sp. -* strong: emph & strong. -* subheading: unnumberedsubsec appendixsubsec subheading. -* subsection: subsection. -* subsubheading: subsubsection. -* subsubsection: subsubsection. -* subtitle: title subtitle author. -* summarycontents: Contents. -* syncodeindex: syncodeindex. -* syncodeindex: syncodeindex. -* synindex: synindex. -* t (typewriter font): Fonts. -* table: Two-column Tables. -* tex: Using Ordinary TeX Commands. -* tex (command): tex. -* texi2dvi (shell script): Shell Format & Print. -* texindex: Format/Print Hardcopy. -* texindex: Shell Format & Print. -* texinfo-all-menus-update: Updating Commands. -* texinfo-every-node-update: Updating Commands. -* texinfo-format-buffer: Info Formatting. -* texinfo-format-buffer: texinfo-format commands. -* texinfo-format-buffer: texinfo-format commands. -* texinfo-format-region: texinfo-format commands. -* texinfo-format-region: texinfo-format commands. -* texinfo-format-region: Info Formatting. -* texinfo-indent-menu-description: Other Updating Commands. -* texinfo-insert-@code: Inserting. -* texinfo-insert-@dfn: Inserting. -* texinfo-insert-@end: Inserting. -* texinfo-insert-@example: Inserting. -* texinfo-insert-@item: Inserting. -* texinfo-insert-@kbd: Inserting. -* texinfo-insert-@node: Inserting. -* texinfo-insert-@noindent: Inserting. -* texinfo-insert-@samp: Inserting. -* texinfo-insert-@table: Inserting. -* texinfo-insert-@var: Inserting. -* texinfo-insert-braces: Inserting. -* texinfo-insert-node-lines: Other Updating Commands. -* texinfo-make-menu: Updating Commands. -* texinfo-master-menu: Updating Commands. -* texinfo-multiple-files-update: texinfo-multiple-files-update. -* texinfo-multiple-files-update (in brief): Other Updating Commands. -* texinfo-sequential-node-update: Other Updating Commands. -* texinfo-show-structure: Using texinfo-show-structure. -* texinfo-show-structure: Showing the Structure. -* texinfo-start-menu-description: Inserting. -* texinfo-tex-buffer: Printing. -* texinfo-tex-print: Printing. -* texinfo-tex-region: Printing. -* texinfo-update-node: Updating Commands. -* TEXINPUTS: Preparing for TeX. -* thischapter: Custom Headings. -* thischaptername: Custom Headings. -* thisfile: Custom Headings. -* thispage: Custom Headings. -* thistitle: Custom Headings. -* tindex: Indexing Commands. -* title: title subtitle author. -* titlefont: titlefont center sp. -* titlepage: titlepage. -* today: Custom Headings. -* top (@-command): makeinfo top command. -* unnumbered: unnumbered & appendix. -* unnumberedsec: unnumberedsec appendixsec heading. -* unnumberedsubsec: unnumberedsubsec appendixsubsec subheading. -* unnumberedsubsubsec: subsubsection. -* up-list: Inserting. -* value: value. -* var: var. -* vindex: Indexing Commands. -* vskip: Copyright & Permissions. -* vtable: ftable vtable. -* w (prevent line break): w. -* xref: xref. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-11 b/gnu/usr.bin/texinfo/info-files/texi.info-11 deleted file mode 100644 index f960227aaba1..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-11 +++ /dev/null @@ -1,451 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Concept Index, Prev: Command and Variable Index, Up: Top - -Concept Index -************* - -* Menu: - -* @-command in nodename: Node Line Requirements. -* @-command list: Command List. -* @-command syntax: Command Syntax. -* @-commands: Formatting Commands. -* .cshrc initialization file: Preparing for TeX. -* .profile initialization file: Preparing for TeX. -* @include file sample: Sample Include File. -* @menu parts: Menu Parts. -* @node line writing: Writing a Node. -* makeinfo inside Emacs: makeinfo in Emacs. -* makeinfo options: makeinfo options. -* TEXINPUTS environment variable: Preparing for TeX. -* dir directory for Info installation: Install an Info File. -* dir file listing: New Info File. -* End node footnote style: Footnotes. -* Separate footnote style: Footnotes. -* Top node: The Top Node. -* Top node is first: First Node. -* Top node naming for references: Top Node Naming. -* Top node summary: Top Node Summary. -* hboxes, overfull: Overfull hboxes. -* ifinfo permissions: ifinfo Permissions. -* TeX commands, using ordinary: Using Ordinary TeX Commands. -* TeX index sorting: Format/Print Hardcopy. -* TeX input initialization: Preparing for TeX. -* TeX, how to obtain: Obtaining TeX. -* A4 paper, printing on: A4 Paper. -* Abbreviations for keys: key. -* Adding a new info file: New Info File. -* Alphabetical @-command list: Command List. -* Another Info directory: Other Info Directories. -* Apostrophe in nodename: Node Line Requirements. -* Arguments, repeated and optional: Optional Arguments. -* Automatic pointer creation with makeinfo: makeinfo Pointer Creation. -* Automatically insert nodes, menus: Updating Nodes and Menus. -* Badly referenced nodes: Running Info-Validate. -* Batch formatting for Info: Batch Formatting. -* Beginning a Texinfo file: Beginning a File. -* Beginning line of a Texinfo file: First Line. -* Black rectangle in hardcopy: Overfull hboxes. -* Blank lines: sp. -* Book characteristics, printed: Printed Books. -* Book, printing small: smallbook. -* Box with rounded corners: cartouche. -* Braces and argument syntax: Command Syntax. -* Braces, inserting: Braces Atsigns Periods. -* Braces, when to use: Formatting Commands. -* Breaks in a line: Line Breaks. -* Buffer formatting and printing: Printing. -* Bullets, inserting: Dots Bullets. -* Capitalizing index entries: Indexing Commands. -* Case in nodename: Node Line Requirements. -* Catching errors with TeX formatting: Debugging with TeX. -* Catching errors with Info formatting: Debugging with Info. -* Catching mistakes: Catching Mistakes. -* Chapter structuring: Structuring. -* Characteristics, printed books or manuals: Printed Books. -* Checking for badly referenced nodes: Running Info-Validate. -* Colon in nodename: Node Line Requirements. -* Combining indices: Combining Indices. -* Comma in nodename: Node Line Requirements. -* Command definitions: Sample Function Definition. -* Commands to insert single characters: Braces Atsigns Periods. -* Commands using ordinary TeX: Using Ordinary TeX Commands. -* Commands, inserting them: Inserting. -* Comments: Comments. -* Compile command for formatting: Compile-Command. -* Conditionally visible text: Conditionals. -* Conditions for copying Texinfo: Copying. -* Contents, Table of: Contents. -* Contents-like outline of file structure: Showing the Structure. -* Conventions for writing definitions: Def Cmd Conventions. -* Conventions, syntactic: Conventions. -* Copying conditions: Copying. -* Copying permissions: Sample Permissions. -* Copying software: Software Copying Permissions. -* Copyright page: Copyright & Permissions. -* Correcting mistakes: Catching Mistakes. -* Create nodes, menus automatically: Updating Nodes and Menus. -* Creating an Info file: Create an Info File. -* Creating an unsplit file: Unsplit. -* Creating index entries: Indexing Commands. -* Creating indices: Indices. -* Creating pointers with makeinfo: makeinfo Pointer Creation. -* Cropmarks for printing: Cropmarks and Magnification. -* Cross reference parts: Cross Reference Parts. -* Cross references: Cross References. -* Cross references using @inforef: inforef. -* Cross references using @pxref: pxref. -* Cross references using @ref: ref. -* Cross references using @xref: xref. -* Debugging the Texinfo structure: Catching Mistakes. -* Debugging with TeX formatting: Debugging with TeX. -* Debugging with Info formatting: Debugging with Info. -* Defining indexing entries: Indexing Commands. -* Defining new indices: New Indices. -* Definition commands: Definition Commands. -* Definition conventions: Def Cmd Conventions. -* Definition template: Def Cmd Template. -* Definitions grouped together: deffnx. -* Description for menu, start: Inserting. -* Different cross reference commands: Cross Reference Commands. -* Dimension formatting: dmn. -* Display formatting: display. -* Distribution: Software Copying Permissions. -* Dots, inserting: dots. -* Dots, inserting: Dots Bullets. -* Double-colon menu entries: Less Cluttered Menu Entry. -* DVI file: Shell Format & Print. -* Ellipsis, inserting: Dots Bullets. -* Emacs: Texinfo Mode. -* Emacs shell, format, print from: Within Emacs. -* Emphasizing text: Emphasis. -* Emphasizing text, font for: emph & strong. -* End of header line: End of Header. -* End titlepage starts headings: end titlepage. -* Ending a Texinfo file: Ending a File. -* Entries for an index: Indexing Commands. -* Entries, making index: Index Entries. -* Enumeration: enumerate. -* Equivalence, indicating it: Equivalence. -* Error message, indicating it: Error Glyph. -* Errors, parsing: makeinfo in Emacs. -* European A4 paper: A4 Paper. -* Evaluation glyph: result. -* Example for a small book: smallexample & smalllisp. -* Example menu: Menu Example. -* Examples, formatting them: example. -* Expansion, indicating it: expansion. -* File beginning: Beginning a File. -* File ending: Ending a File. -* File section structure, showing it: Showing the Structure. -* Filling paragraphs: Refilling Paragraphs. -* Final output: Overfull hboxes. -* Finding badly referenced nodes: Running Info-Validate. -* First line of a Texinfo file: First Line. -* First node: First Node. -* Fonts for indices: syncodeindex. -* Fonts for printing, not for Info: Fonts. -* Footings: Headings. -* Footnotes: Footnotes. -* Format a dimension: dmn. -* Format and print hardcopy: Format/Print Hardcopy. -* Format and print in Texinfo mode: Texinfo Mode Printing. -* Format with the compile command: Compile-Command. -* Format, print from Emacs shell: Within Emacs. -* Formatting a file for Info: Create an Info File. -* Formatting commands: Formatting Commands. -* Formatting examples: example. -* Formatting for Info: Info Formatting. -* Formatting for printing: Printing. -* Formatting headings and footings: Headings. -* Formatting requirements: Requirements Summary. -* Frequently used commands, inserting: Inserting. -* Function definitions: Sample Function Definition. -* General syntactic conventions: Conventions. -* Generating menus with indices: Printing Indices & Menus. -* Glyphs: Glyphs. -* GNU Emacs: Texinfo Mode. -* GNU Emacs shell, format, print from: Within Emacs. -* Going to other Info files' nodes: Other Info Files. -* Group (hold text together vertically): group. -* Grouping two definitions together: deffnx. -* Hardcopy, printing it: Format/Print Hardcopy. -* Header for Texinfo files: Header. -* Header of a Texinfo file: First Line. -* Headings: Headings. -* Headings, page, begin to appear: end titlepage. -* Highlighting text: Indicating. -* Hints: Tips. -* Holding text together vertically: group. -* If text conditionally visible: Conditionals. -* Ignored text: Comments. -* Include file requirements: Include File Requirements. -* Include file sample: Sample Include File. -* Include files: Include Files. -* Indentation undoing: exdent. -* Indenting paragraphs: paragraphindent. -* Index entries: Indexing Commands. -* Index entries, making: Index Entries. -* Index entry capitalization: Indexing Commands. -* Index font types: Indexing Commands. -* Indexing commands, predefined: Indexing Commands. -* Indexing table entries automatically: ftable vtable. -* Indicating commands, definitions, etc.: Indicating. -* Indicating evaluation: result. -* Indices: Indices. -* Indices, combining them: Combining Indices. -* Indices, defining new: New Indices. -* Indices, printing and menus: Printing Indices & Menus. -* Indices, sorting: Format/Print Hardcopy. -* Indices, two letter names: syncodeindex. -* Indirect subfiles: Tag and Split Files. -* Info batch formatting: Batch Formatting. -* Info file installation: Install an Info File. -* Info file requires @setfilename: setfilename. -* Info file, listing new one: New Info File. -* Info file, splitting manually: Splitting. -* Info files: Info Files. -* Info formatting: Info Formatting. -* Info installed in another directory: Other Info Directories. -* Info validating a large file: Using Info-validate. -* Info, creating an on-line file: Create an Info File. -* Info; other files' nodes: Other Info Files. -* Initialization file for TeX input: Preparing for TeX. -* Insert nodes, menus automatically: Updating Nodes and Menus. -* Inserting @, braces, and periods: Braces Atsigns Periods. -* Inserting dots: Dots Bullets. -* Inserting dots: dots. -* Inserting ellipsis: Dots Bullets. -* Inserting frequently used commands: Inserting. -* Inserting special characters and symbols: Insertions. -* Installing an Info file: Install an Info File. -* Installing Info in another directory: Other Info Directories. -* Introduction, as part of file: Software Copying Permissions. -* Itemization: itemize. -* Keys, recommended names: key. -* Larger or smaller pages: Cropmarks and Magnification. -* Less cluttered menu entry: Less Cluttered Menu Entry. -* License agreement: Software Copying Permissions. -* Line breaks: Line Breaks. -* Line breaks, preventing: w. -* Line spacing: sp. -* Lisp example: Lisp Example. -* Lisp example for a small book: smallexample & smalllisp. -* List of @-commands: Command List. -* Listing a new info file: New Info File. -* Lists and tables, making them: Lists and Tables. -* Local variables: Compile-Command. -* Location of menus: Menu Location. -* Looking for badly referenced nodes: Running Info-Validate. -* Macro definitions: Sample Function Definition. -* Magnified printing: Cropmarks and Magnification. -* Making a printed manual: Format/Print Hardcopy. -* Making a tag table automatically: Tag and Split Files. -* Making a tag table manually: Unsplit. -* Making cross references: Cross References. -* Making line and page breaks: Breaks. -* Making lists and tables: Lists and Tables. -* Manual characteristics, printed: Printed Books. -* Marking text within a paragraph: Marking Text. -* Marking words and phrases: Marking Text. -* Master menu: The Top Node. -* Master menu parts: Master Menu Parts. -* Mathematical expressions: Using Ordinary TeX Commands. -* Menu description, start: Inserting. -* Menu entries with two colons: Less Cluttered Menu Entry. -* Menu example: Menu Example. -* Menu location: Menu Location. -* Menu parts: Menu Parts. -* Menu writing: Writing a Menu. -* Menus: Menus. -* Menus generated with indices: Printing Indices & Menus. -* META key: key. -* Meta-syntactic chars for arguments: Optional Arguments. -* Minimal Texinfo file (requirements): Minimum. -* Mistakes, catching: Catching Mistakes. -* Mode, using Texinfo: Texinfo Mode. -* Must have in Texinfo file: Minimum. -* Names for indices: syncodeindex. -* Names recommended for keys: key. -* Naming a `Top' Node in references: Top Node Naming. -* Need space at page bottom: need. -* New index defining: New Indices. -* New info file, listing it in dir file: New Info File. -* Node line requirements: Node Line Requirements. -* Node line writing: Writing a Node. -* Node, defined: node. -* Node, `Top': The Top Node. -* Nodename must be unique: Node Line Requirements. -* Nodename, cannot contain: Node Line Requirements. -* Nodes for menus are short: Menu Location. -* Nodes in other Info files: Other Info Files. -* Nodes, catching mistakes: Catching Mistakes. -* Nodes, checking for badly referenced: Running Info-Validate. -* Obtaining TeX: Obtaining TeX. -* Occurrences, listing with @occur: Using occur. -* Optional and repeated arguments: Optional Arguments. -* Options for makeinfo: makeinfo options. -* Ordinary TeX commands, using: Using Ordinary TeX Commands. -* Other Info files' nodes: Other Info Files. -* Outline of file structure, showing it: Showing the Structure. -* Overfull hboxes: Overfull hboxes. -* Overview of Texinfo: Overview. -* Page breaks: page. -* Page delimiter in Texinfo mode: Showing the Structure. -* Page headings: Headings. -* Page numbering: Headings. -* Page sizes for books: smallbook. -* Pages, starting odd: setchapternewpage. -* Paper size, European A4: A4 Paper. -* Paragraph indentation: paragraphindent. -* Paragraph, marking text within: Marking Text. -* Parsing errors: makeinfo in Emacs. -* Part of file formatting and printing: Printing. -* Parts of a cross reference: Cross Reference Parts. -* Parts of a master menu: Master Menu Parts. -* Parts of a menu: Menu Parts. -* Periods, inserting: Braces Atsigns Periods. -* Permissions: Sample Permissions. -* Permissions, printed: Copyright & Permissions. -* PlainTeX: Using Ordinary TeX Commands. -* Point, indicating it in a buffer: Point Glyph. -* Pointer creation with makeinfo: makeinfo Pointer Creation. -* Pointer validation with makeinfo: Pointer Validation. -* Predefined indexing commands: Indexing Commands. -* Predefined names for indices: syncodeindex. -* Preparing to use TeX: Preparing for TeX. -* Preventing line and page breaks: Breaks. -* Print and format in Texinfo mode: Texinfo Mode Printing. -* Print, format from Emacs shell: Within Emacs. -* Printed book and manual characteristics: Printed Books. -* Printed output, indicating it: Print Glyph. -* Printed permissions: Copyright & Permissions. -* Printing a region or buffer: Printing. -* Printing an index: Printing Indices & Menus. -* Printing cropmarks: Cropmarks and Magnification. -* Problems, catching: Catching Mistakes. -* Quotations: quotation. -* Recommended names for keys: key. -* Rectangle, ugly, black in hardcopy: Overfull hboxes. -* References: Cross References. -* References using @inforef: inforef. -* References using @pxref: pxref. -* References using @ref: ref. -* References using @xref: xref. -* Referring to other Info files: Other Info Files. -* Refilling paragraphs: Refilling Paragraphs. -* Region formatting and printing: Printing. -* Region printing in Texinfo mode: Texinfo Mode Printing. -* Repeated and optional arguments: Optional Arguments. -* Required in Texinfo file: Minimum. -* Requirements for formatting: Requirements Summary. -* Requirements for include files: Include File Requirements. -* Requirements for updating commands: Updating Requirements. -* Result of an expression: result. -* Running Info-validate: Using Info-validate. -* Running makeinfo in Emacs: makeinfo in Emacs. -* Running an Info formatter: Info Formatting. -* Sample @include file: Sample Include File. -* Sample function definition: Sample Function Definition. -* Sample Texinfo file: Short Sample. -* Sample Texinfo file, no comments: Sample Texinfo File. -* Section structure of a file, showing it: Showing the Structure. -* Shell, format, print from: Within Emacs. -* Shell, running makeinfo in: makeinfo in Emacs. -* Short nodes for menus: Menu Location. -* Showing the section structure of a file: Showing the Structure. -* Showing the structure of a file: Using texinfo-show-structure. -* Single characters, commands to insert: Braces Atsigns Periods. -* Size of printed book: smallbook. -* Small book example: smallexample & smalllisp. -* Small book size: smallbook. -* Small caps font: Smallcaps. -* Software copying permissions: Software Copying Permissions. -* Sorting indices: Format/Print Hardcopy. -* Spaces (blank lines): sp. -* Special insertions: Insertions. -* Special typesetting commands: Dots Bullets. -* Specifying index entries: Indexing Commands. -* Splitting an Info file manually: Splitting. -* Start of header line: Start of Header. -* Starting chapters: setchapternewpage. -* Structure of a file, showing it: Showing the Structure. -* Structure, catching mistakes in: Catching Mistakes. -* Structuring of chapters: Structuring. -* Subsection-like commands: unnumberedsubsec appendixsubsec subheading. -* Subsub commands: subsubsection. -* Syntactic conventions: Conventions. -* Syntax, optional & repeated arguments: Optional Arguments. -* Table of contents: Contents. -* Tables and lists, making them: Lists and Tables. -* Tables with indexes: ftable vtable. -* Tables, making two-column: Two-column Tables. -* Tabs; don't use!: Conventions. -* Tag table, making automatically: Tag and Split Files. -* Tag table, making manually: Unsplit. -* Template for a definition: Def Cmd Template. -* Texinfo file beginning: Beginning a File. -* Texinfo file ending: Ending a File. -* Texinfo file header: Header. -* Texinfo file minimum: Minimum. -* Texinfo file section structure, showing it: Showing the Structure. -* Texinfo mode: Texinfo Mode. -* Texinfo overview: Overview. -* Texinfo printed book characteristics: Printed Books. -* Text, conditionally visible: Conditionals. -* Thin space between number, dimension: dmn. -* Tips: Tips. -* Title page: titlepage. -* Titlepage end starts headings: end titlepage. -* Titlepage permissions: Titlepage Permissions. -* Tree structuring: Tree Structuring. -* Two letter names for indices: syncodeindex. -* Two named items for @table: itemx. -* Two part menu entry: Less Cluttered Menu Entry. -* Two `First' Lines for @deffn: deffnx. -* Typesetting commands for dots, etc.: Dots Bullets. -* Uncluttered menu entry: Less Cluttered Menu Entry. -* Unique nodename requirement: Node Line Requirements. -* Unprocessed text: Comments. -* Unsplit file creation: Unsplit. -* Updating nodes and menus: Updating Nodes and Menus. -* Updating requirements: Updating Requirements. -* Usage tips: Tips. -* Validating a large file: Using Info-validate. -* Validation of pointers: Pointer Validation. -* Value of an expression, indicating: result. -* Vertical whitespace (vskip): Copyright & Permissions. -* Vertically holding text together: group. -* Visibility of conditional text: Conditionals. -* Words and phrases, marking them: Marking Text. -* Writing a menu: Writing a Menu. -* Writing an @node line: Writing a Node. - - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-2 b/gnu/usr.bin/texinfo/info-files/texi.info-2 deleted file mode 100644 index 6ad094d10c4d..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-2 +++ /dev/null @@ -1,1289 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Texinfo Mode, Next: Beginning a File, Prev: Overview, Up: Top - -Using Texinfo Mode -****************** - - You may edit a Texinfo file with any text editor you choose. A -Texinfo file is no different from any other ASCII file. However, GNU -Emacs comes with a special mode, called Texinfo mode, that provides -Emacs commands and tools to help ease your work. - - This chapter describes features of GNU Emacs' Texinfo mode but not -any features of the Texinfo formatting language. If you are reading -this manual straight through from the beginning, you may want to skim -through this chapter briefly and come back to it after reading -succeeding chapters which describe the Texinfo formatting language in -detail. - -* Menu: - -* Texinfo Mode Overview:: How Texinfo mode can help you. -* Emacs Editing:: Texinfo mode adds to GNU Emacs' general - purpose editing features. -* Inserting:: How to insert frequently used @-commands. -* Showing the Structure:: How to show the structure of a file. -* Updating Nodes and Menus:: How to update or create new nodes and menus. -* Info Formatting:: How to format for Info. -* Printing:: How to format and print part or all of a file. -* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. - - -File: texi.info, Node: Texinfo Mode Overview, Next: Emacs Editing, Up: Texinfo Mode - -Texinfo Mode Overview -===================== - - Texinfo mode provides special features for working with Texinfo -files: - - * Insert frequently used @commands. - - * Automatically create `@node' lines. - - * Show the structure of a Texinfo source file. - - * Automatically create or update the `Next', - `Previous', and `Up' pointers of a node. - - * Automatically create or update menus. - - * Automatically create a master menu. - - * Format a part or all of a file for Info. - - * Typeset and print part or all of a file. - - Perhaps the two most helpful features are those for inserting -frequently used @-commands and for creating node pointers and menus. - - -File: texi.info, Node: Emacs Editing, Next: Inserting, Prev: Texinfo Mode Overview, Up: Texinfo Mode - -The Usual GNU Emacs Editing Commands -==================================== - - In most cases, the usual Text mode commands work the same in Texinfo -mode as they do in Text mode. Texinfo mode adds new editing commands -and tools to GNU Emacs' general purpose editing features. The major -difference concerns filling. In Texinfo mode, the paragraph separation -variable and syntax table are redefined so that Texinfo commands that -should be on lines of their own are not inadvertently included in -paragraphs. Thus, the `M-q' (`fill-paragraph') command will refill a -paragraph but not mix an indexing command on a line adjacent to it into -the paragraph. - - In addition, Texinfo mode sets the `page-delimiter' variable to the -value of `texinfo-chapter-level-regexp'; by default, this is a regular -expression matching the commands for chapters and their equivalents, -such as appendices. With this value for the page delimiter, you can -jump from chapter title to chapter title with the `C-x ]' -(`forward-page') and `C-x [' (`backward-page') commands and narrow to a -chapter with the `C-x p' (`narrow-to-page') command. (*Note Pages: -(emacs)Pages, for details about the page commands.) - - You may name a Texinfo file however you wish, but the convention is -to end a Texinfo file name with one of the three extensions `.texinfo', -`.texi', or `.tex'. A longer extension is preferred, since it is -explicit, but a shorter extension may be necessary for operating -systems that limit the length of file names. GNU Emacs automatically -enters Texinfo mode when you visit a file with a `.texinfo' or `.texi' -extension. Also, Emacs switches to Texinfo mode when you visit a file -that has `-*-texinfo-*-' in its first line. If ever you are in another -mode and wish to switch to Texinfo mode, type `M-x texinfo-mode'. - - Like all other Emacs features, you can customize or enhance Texinfo -mode as you wish. In particular, the keybindings are very easy to -change. The keybindings described here are the default or standard -ones. - - -File: texi.info, Node: Inserting, Next: Showing the Structure, Prev: Emacs Editing, Up: Texinfo Mode - -Inserting Frequently Used Commands -================================== - - Texinfo mode provides commands to insert various frequently used -@-commands into the buffer. You can use these commands to save -keystrokes. - - The insert commands are invoked by typing `C-c' twice and then the -first letter of the @-command: - -`C-c C-c c' -`M-x texinfo-insert-@code' - Insert `@code{}' and put the cursor between the braces. - -`C-c C-c d' -`M-x texinfo-insert-@dfn' - Insert `@dfn{}' and put the cursor between the braces. - -`C-c C-c e' -`M-x texinfo-insert-@end' - Insert `@end' and attempt to insert the correct following word, - such as `example' or `table'. (This command does not handle - nested lists correctly, but inserts the word appropriate to the - immediately preceding list.) - -`C-c C-c i' -`M-x texinfo-insert-@item' - Insert `@item' and put the cursor at the beginning of the next - line. - -`C-c C-c k' -`M-x texinfo-insert-@kbd' - Insert `@kbd{}' and put the cursor between the braces. - -`C-c C-c n' -`M-x texinfo-insert-@node' - Insert `@node' and a comment line listing the sequence for the - `Next', `Previous', and `Up' nodes. Leave point after the `@node'. - -`C-c C-c o' -`M-x texinfo-insert-@noindent' - Insert `@noindent' and put the cursor at the beginning of the next - line. - -`C-c C-c s' -`M-x texinfo-insert-@samp' - Insert `@samp{}' and put the cursor between the braces. - -`C-c C-c t' -`M-x texinfo-insert-@table' - Insert `@table' followed by a SPC and leave the cursor after the - SPC. - -`C-c C-c v' -`M-x texinfo-insert-@var' - Insert `@var{}' and put the cursor between the braces. - -`C-c C-c x' -`M-x texinfo-insert-@example' - Insert `@example' and put the cursor at the beginning of the next - line. - -`C-c C-c {' -`M-x texinfo-insert-braces' - Insert `{}' and put the cursor between the braces. - -`C-c C-c }' -`C-c C-c ]' -`M-x up-list' - Move from between a pair of braces forward past the closing brace. - Typing `C-c C-c ]' is easier than typing `C-c C-c }', which is, - however, more mnemonic; hence the two keybindings. (Also, you can - move out from between braces by typing `C-f'.) - - To put a command such as `@code{...}' around an *existing* word, -position the cursor in front of the word and type `C-u 1 C-c C-c c'. -This makes it easy to edit existing plain text. The value of the -prefix argument tells Emacs how many words following point to include -between braces--1 for one word, 2 for two words, and so on. Use a -negative argument to enclose the previous word or words. If you do not -specify a prefix argument, Emacs inserts the @-command string and -positions the cursor between the braces. This feature works only for -those @-commands that operate on a word or words within one line, such -as `@kbd' and `@var'. - - This set of insert commands was created after analyzing the frequency -with which different @-commands are used in the `GNU Emacs Manual' and -the `GDB Manual'. If you wish to add your own insert commands, you can -bind a keyboard macro to a key, use abbreviations, or extend the code -in `texinfo.el'. - - `C-c C-c C-d' (`texinfo-start-menu-description') is an insert -command that works differently from the other insert commands. It -inserts a node's section or chapter title in the space for the -description in a menu entry line. (A menu entry has three parts, the -entry name, the node name, and the description. Only the node name is -required, but a description helps explain what the node is about. -*Note The Parts of a Menu: Menu Parts.) - - To use `texinfo-start-menu-description', position point in a menu -entry line and type `C-c C-c C-d'. The command looks for and copies -the title that goes with the node name, and inserts the title as a -description; it positions point at beginning of the inserted text so you -can edit it. The function does not insert the title if the menu entry -line already contains a description. - - This command is only an aid to writing descriptions; it does not do -the whole job. You must edit the inserted text since a title tends to -use the same words as a node name but a useful description uses -different words. - - -File: texi.info, Node: Showing the Structure, Next: Updating Nodes and Menus, Prev: Inserting, Up: Texinfo Mode - -Showing the Section Structure of a File -======================================= - - You can show the section structure of a Texinfo file by using the -`C-c C-s' command (`texinfo-show-structure'). This command shows the -section structure of a Texinfo file by listing the lines that begin -with the @-commands for `@chapter', `@section', and the like. It -constructs what amounts to a table of contents. These lines are -displayed in another buffer called the `*Occur*' buffer. In that -buffer, you can position the cursor over one of the lines and use the -`C-c C-c' command (`occur-mode-goto-occurrence'), to jump to the -corresponding spot in the Texinfo file. - -`C-c C-s' -`M-x texinfo-show-structure' - Show the `@chapter', `@section', and such lines of a Texinfo file. - -`C-c C-c' -`M-x occur-mode-goto-occurrence' - Go to the line in the Texinfo file corresponding to the line under - the cursor in the `*Occur*' buffer. - - If you call `texinfo-show-structure' with a prefix argument by -typing `C-u C-c C-s', it will list not only those lines with the -@-commands for `@chapter', `@section', and the like, but also the -`@node' lines. (This is how the `texinfo-show-structure' command -worked without an argument in the first version of Texinfo. It was -changed because `@node' lines clutter up the `*Occur*' buffer and are -usually not needed.) You can use `texinfo-show-structure' with a prefix -argument to check whether the `Next', `Previous', and `Up' pointers of -an `@node' line are correct. - - Often, when you are working on a manual, you will be interested only -in the structure of the current chapter. In this case, you can mark -off the region of the buffer that you are interested in with the `C-x -n' (`narrow-to-region') command and `texinfo-show-structure' will work -on only that region. To see the whole buffer again, use `C-x w' -(`widen'). (*Note Narrowing: (emacs)Narrowing, for more information -about the narrowing commands.) - - In addition to providing the `texinfo-show-structure' command, -Texinfo mode sets the value of the page delimiter variable to match the -chapter-level @-commands. This enables you to use the `C-x ]' -(`forward-page') and `C-x [' (`backward-page') commands to move forward -and backward by chapter, and to use the `C-x p' (`narrow-to-page') -command to narrow to a chapter. *Note Pages: (emacs)Pages, for more -information about the page commands. - - -File: texi.info, Node: Updating Nodes and Menus, Next: Info Formatting, Prev: Showing the Structure, Up: Texinfo Mode - -Updating Nodes and Menus -======================== - - Texinfo mode provides commands for automatically creating or updating -menus and node pointers. The commands are called "update" commands -because their most frequent use is for updating a Texinfo file after -you have worked on it; but you can use them to insert the `Next', -`Previous', and `Up' pointers into an `@node' line that has none and to -create menus in a file that has none. - - If you do not use the updating commands, you need to write menus and -node pointers by hand, which is a tedious task. - -* Menu: - -* Updating Commands:: Five major updating commands. -* Updating Requirements:: How to structure a Texinfo file for - using the updating command. -* Other Updating Commands:: How to indent descriptions, insert - missing nodes lines, and update - nodes in sequence. - - -File: texi.info, Node: Updating Commands, Next: Updating Requirements, Up: Updating Nodes and Menus - -The Updating Commands ---------------------- - - You can use the updating commands - - * to insert or update the `Next', `Previous', and `Up' pointers of a - node, - - * to insert or update the menu for a section, and - - * to create a master menu for a Texinfo source file. - - You can also use the commands to update all the nodes and menus in a -region or in a whole Texinfo file. - - The updating commands work only with conventional Texinfo files, -which are structured hierarchically like books. In such files, a -structuring command line must follow closely after each `@node' line, -except for the `Top' `@node' line. (A "structuring command line" is a -line beginning with `@chapter', `@section', or other similar command.) - - You can write the structuring command line on the line that follows -immediately after an `@node' line or else on the line that follows -after a single `@comment' line or a single `@ifinfo' line. You cannot -interpose more than one line between the `@node' line and the -structuring command line; and you may interpose only an `@comment' line -or an `@ifinfo' line. - - Commands which work on a whole buffer require that the `Top' node be -followed by a node with an `@chapter' or equivalent-level command. -Note that the menu updating commands will not create a main or master -menu for a Texinfo file that has only `@chapter'-level nodes! The menu -updating commands only create menus *within* nodes for lower level -nodes. To create a menu of chapters, you must provide a `Top' node. - - The menu updating commands remove menu entries that refer to other -Info files since they do not refer to nodes within the current buffer. -This is a deficiency. Rather than use menu entries, you can use cross -references to refer to other Info files. None of the updating commands -affect cross references. - - Texinfo mode has five updating commands that are used most often: two -are for updating the node pointers or menu of a single node (or a -region); two are for updating every node pointer and menu in a file; -and one, the `texinfo-master-menu' command, is for creating a master -menu for a complete file, and optionally, for updating every node and -menu in the whole Texinfo file. - - The `texinfo-master-menu' command is the primary command: - -`C-c C-u m' -`M-x texinfo-master-menu' - Create or update a master menu that includes all the other menus - (incorporating the descriptions from pre-existing menus, if any). - - With an argument (prefix argument, `C-u,' if interactive), first - create or update all the nodes and all the regular menus in the - buffer before constructing the master menu. (*Note The Top Node - and Master Menu: The Top Node, for more about a master menu.) - - For `texinfo-master-menu' to work, the Texinfo file must have a - `Top' node and at least one subsequent node. - - After extensively editing a Texinfo file, you can type the - following: - - C-u M-x texinfo-master-menu - or - C-u C-c C-u m - - This updates all the nodes and menus completely and all at once. - - The other major updating commands do smaller jobs and are designed -for the person who updates nodes and menus as he or she writes a -Texinfo file. - - The commands are: - -`C-c C-u C-n' -`M-x texinfo-update-node' - Insert the `Next', `Previous', and `Up' pointers for the node that - point is within (i.e., for the `@node' line preceding point). If - the `@node' line has pre-existing `Next', `Previous', or `Up' - pointers in it, the old pointers are removed and new ones inserted. - With an argument (prefix argument, `C-u', if interactive), this - command updates all `@node' lines in the region (which is the text - between point and mark). - -`C-c C-u C-m' -`M-x texinfo-make-menu' - Create or update the menu in the node that point is within. With - an argument (`C-u' as prefix argument, if interactive), the - command makes or updates menus for the nodes which are either - within or a part of the region. - - Whenever `texinfo-make-menu' updates an existing menu, the - descriptions from that menu are incorporated into the new menu. - This is done by copying descriptions from the existing menu to the - entries in the new menu that have the same node names. If the - node names are different, the descriptions are not copied to the - new menu. - -`C-c C-u C-e' -`M-x texinfo-every-node-update' - Insert or update the `Next', `Previous', and `Up' pointers for - every node in the buffer. - -`C-c C-u C-a' -`M-x texinfo-all-menus-update' - Create or update all the menus in the buffer. With an argument - (`C-u' as prefix argument, if interactive), first insert or update - all the node pointers before working on the menus. - - If a master menu exists, the `texinfo-all-menus-update' command - updates it; but the command does not create a new master menu if - none already exists. (Use the `texinfo-master-menu' command for - that.) - - When working on a document that does not merit a master menu, you - can type the following: - - C-u C-c C-u C-a - or - C-u M-x texinfo-all-menus-update - - This updates all the nodes and menus. - - The `texinfo-column-for-description' variable specifies the column -to which menu descriptions are indented. By default, the value is 32 -although it is often useful to reduce it to as low as 24. You can set -the variable with the `M-x edit-options' command (*note Editing -Variable Values: (emacs)Edit Options.) or with the `M-x set-variable' -command (*note Examining and Setting Variables: (emacs)Examining.). - - Also, the `texinfo-indent-menu-description' command may be used to -indent existing menu descriptions to a specified column. Finally, if -you wish, you can use the `texinfo-insert-node-lines' command to insert -missing `@node' lines into a file. (*Note Other Updating Commands::, -for more information.) - - -File: texi.info, Node: Updating Requirements, Next: Other Updating Commands, Prev: Updating Commands, Up: Updating Nodes and Menus - -Updating Requirements ---------------------- - - To use the updating commands, you must organize the Texinfo file -hierarchically with chapters, sections, subsections, and the like. -When you construct the hierarchy of the manual, do not `jump down' more -than one level at a time: you can follow the `Top' node with a chapter, -but not with a section; you can follow a chapter with a section, but -not with a subsection. However, you may `jump up' any number of levels -at one time--for example, from a subsection to a chapter. - - Each `@node' line, with the exception of the line for the `Top' -node, must be followed by a line with a structuring command such as -`@chapter', `@section', or `@unnumberedsubsec'. - - Each `@node' line/structuring-command line combination must look -either like this: - - @node Comments, Minimum, Conventions, Overview - @comment node-name, next, previous, up - @section Comments - - or like this (without the `@comment' line): - - @node Comments, Minimum, Conventions, Overview - @section Comments - -In this example, `Comments' is the name of both the node and the -section. The next node is called `Minimum' and the previous node is -called `Conventions'. The `Comments' section is within the `Overview' -node, which is specified by the `Up' pointer. (Instead of an -`@comment' line, you can write an `@ifinfo' line.) - - If a file has a `Top' node, it must be called `top' or `Top' and be -the first node in the file. - - The menu updating commands create a menu of sections within a -chapter, a menu of subsections within a section, and so on. This means -that you must have a `Top' node if you want a menu of chapters. - - Incidentally, the `makeinfo' command will create an Info file for a -hierarchically organized Texinfo file that lacks `Next', `Previous' and -`Up' pointers. Thus, if you can be sure that your Texinfo file will be -formatted with `makeinfo', you have no need for the `update node' -commands. (*Note Creating an Info File: Create an Info File, for more -information about `makeinfo'.) However, both `makeinfo' and the -`texinfo-format-...' commands require that you insert menus in the file. - - -File: texi.info, Node: Other Updating Commands, Prev: Updating Requirements, Up: Updating Nodes and Menus - -Other Updating Commands ------------------------ - - In addition to the five major updating commands, Texinfo mode -possesses several less frequently used updating commands: - -`M-x texinfo-insert-node-lines' - Insert `@node' lines before the `@chapter', `@section', and other - sectioning commands wherever they are missing throughout a region - in a Texinfo file. - - With an argument (`C-u' as prefix argument, if interactive), the - `texinfo-insert-node-lines' command not only inserts `@node' lines - but also inserts the chapter or section titles as the names of the - corresponding nodes. In addition, it inserts the titles as node - names in pre-existing `@node' lines that lack names. Since node - names should be more concise than section or chapter titles, you - must manually edit node names so inserted. - - For example, the following marks a whole buffer as a region and - inserts `@node' lines and titles throughout: - - C-x h C-u M-x texinfo-insert-node-lines - - (Note that this command inserts titles as node names in `@node' - lines; the `texinfo-start-menu-description' command (*note - Inserting Frequently Used Commands: Inserting.) inserts titles as - descriptions in menu entries, a different action. However, in both - cases, you need to edit the inserted text.) - -`M-x texinfo-multiple-files-update' - Update nodes and menus in a document built from several separate - files. With `C-u' as a prefix argument, create and insert a - master menu in the outer file. With a numeric prefix argument, - such as `C-u 2', first update all the menus and all the `Next', - `Previous', and `Up' pointers of all the included files before - creating and inserting a master menu in the outer file. The - `texinfo-multiple-files-update' command is described in the - appendix on `@include' files. *Note - texinfo-multiple-files-update::. - -`M-x texinfo-indent-menu-description' - Indent every description in the menu following point to the - specified column. You can use this command to give yourself more - space for descriptions. With an argument (`C-u' as prefix - argument, if interactive), the `texinfo-indent-menu-description' - command indents every description in every menu in the region. - However, this command does not indent the second and subsequent - lines of a multi-line description. - -`M-x texinfo-sequential-node-update' - Insert the names of the nodes immediately following and preceding - the current node as the `Next' or `Previous' pointers regardless - of those nodes' hierarchical level. This means that the `Next' - node of a subsection may well be the next chapter. Sequentially - ordered nodes are useful for novels and other documents that you - read through sequentially. (However, in Info, the `g* RET' - command lets you look through the file sequentially, so - sequentially ordered nodes are not strictly necessary.) With an - argument (prefix argument, if interactive), the - `texinfo-sequential-node-update' command sequentially updates all - the nodes in the region. - - -File: texi.info, Node: Info Formatting, Next: Printing, Prev: Updating Nodes and Menus, Up: Texinfo Mode - -Formatting for Info -=================== - - Texinfo mode provides several commands for formatting part or all of -a Texinfo file for Info. Often, when you are writing a document, you -want to format only part of a file--that is, a region. - - You can use either the `texinfo-format-region' or the -`makeinfo-region' command to format a region: - -`C-c C-e C-r' -`M-x texinfo-format-region' -`C-c C-m C-r' -`M-x makeinfo-region' - Format the current region for Info. - - You can use either the `texinfo-format-buffer' or the -`makeinfo-buffer' command to format a whole buffer: - -`C-c C-e C-b' -`M-x texinfo-format-buffer' -`C-c C-m C-b' -`M-x makeinfo-buffer' - Format the current buffer for Info. - - For example, after writing a Texinfo file, you can type the -following: - - C-u C-c C-u m -or - C-u M-x texinfo-master-menu - -This updates all the nodes and menus. Then type the following to create -an Info file: - - C-c C-m C-b -or - M-x makeinfo-buffer - - For the Info formatting commands to work, the file *must* include a -line that has `@setfilename' in its header. - - Not all systems support the `makeinfo'-based formatting commands. - - *Note Create an Info File::, for details about Info formatting. - - -File: texi.info, Node: Printing, Next: Texinfo Mode Summary, Prev: Info Formatting, Up: Texinfo Mode - -Formatting and Printing -======================= - - Typesetting and printing a Texinfo file is a multi-step process in -which you first create a file for printing (called a DVI file), and then -print the file. Optionally, you may also create indices. To do this, -you must run the `texindex' command after first running the `tex' -typesetting command; and then you must run the `tex' command again. - - Often, when you are writing a document, you want to typeset and print -only part of a file to see what it will look like. You can use the -`texinfo-tex-region' and related commands for this purpose. Use the -`texinfo-tex-buffer' command to format all of a buffer. - -`C-c C-t C-r' -`M-x texinfo-tex-region' - Run TeX on the region. - -`C-c C-t C-b' -`M-x texinfo-tex-buffer' - Run TeX on the buffer. - -`C-c C-t C-i' -`M-x texinfo-texindex' - Run `texindex' to sort the indices of a Texinfo file formatted with - `texinfo-tex-region' or `texinfo-tex-buffer'. You must run the - `tex' command a second time after sorting the raw index files. - -`C-c C-t C-p' -`M-x texinfo-tex-print' - Print the file (or the part of the file) previously formatted with - `texinfo-tex-buffer' or `texinfo-tex-region'. - - For `texinfo-tex-region' or `texinfo-tex-buffer' to work, the file -*must* start with a `\input texinfo' line and must include an -`@settitle' line. The file must end with `@bye' on a line by itself. -(When you use `texinfo-tex-region', you must surround the `@settitle' -line with start-of-header and end-of-header lines.) - - *Note Format/Print Hardcopy::, for a description of the other TeX -related commands, such as `tex-show-print-queue'. - - -File: texi.info, Node: Texinfo Mode Summary, Prev: Printing, Up: Texinfo Mode - -Texinfo Mode Summary -==================== - - In Texinfo mode, each set of commands has default keybindings that -begin with the same keys. All the commands that are custom-created for -Texinfo mode begin with `C-c'. The keys are somewhat mnemonic. - -Insert Commands ---------------- - - The insert commands are invoked by typing `C-c' twice and then the -first letter of the @-command to be inserted. (It might make more -sense mnemonically to use `C-c C-i', for `custom insert', but `C-c C-c' -is quick to type.) - - C-c C-c c Insert `@code'. - C-c C-c d Insert `@dfn'. - C-c C-c e Insert `@end'. - C-c C-c i Insert `@item'. - C-c C-c n Insert `@node'. - C-c C-c s Insert `@samp'. - C-c C-c v Insert `@var'. - C-c C-c { Insert braces. - C-c C-c ] - C-c C-c } Move out of enclosing braces. - - C-c C-c C-d Insert a node's section title - in the space for the description - in a menu entry line. - -Show Structure --------------- - - The `texinfo-show-structure' command is often used within a narrowed -region. - - C-c C-s List all the headings. - -The Master Update Command -------------------------- - - The `texinfo-master-menu' command creates a master menu; and can be -used to update every node and menu in a file as well. - - C-c C-u m - M-x texinfo-master-menu - Create or update a master menu. - - C-u C-c C-u m With `C-u' as a prefix argument, first - create or update all nodes and regular - menus, and then create a master menu. - -Update Pointers ---------------- - - The update pointer commands are invoked by typing `C-c C-u' and then -either typing `C-n' for `texinfo-update-node' or typing `C-e' for -`texinfo-every-node-update'. - - C-c C-u C-n Update a node. - C-c C-u C-e Update every node in the buffer. - -Update Menus ------------- - - Invoke the update menu commands by typing `C-c C-u' and then either -`C-m' for `texinfo-make-menu' or `C-a' for `texinfo-all-menus-update'. -To update both nodes and menus at the same time, precede `C-c C-u C-a' -with `C-u'. - - C-c C-u C-m Make or update a menu. - - C-c C-u C-a Make or update all - menus in a buffer. - - C-u C-c C-u C-a With `C-u' as a prefix argument, - first create or update all nodes and - then create or update all menus. - -Format for Info ---------------- - - The Info formatting commands that are written in Emacs Lisp are -invoked by typing `C-c C-e' and then either `C-r' for a region or `C-b' -for the whole buffer. - - The Info formatting commands that are written in C and based on the -`makeinfo' program are invoked by typing `C-c C-m' and then either -`C-r' for a region or `C-b' for the whole buffer. - -Use the `texinfo-format...' commands: - - C-c C-e C-r Format the region. - C-c C-e C-b Format the buffer. - -Use `makeinfo': - - C-c C-m C-r Format the region. - C-c C-m C-b Format the buffer. - C-c C-m C-l Recenter the `makeinfo' output buffer. - C-c C-m C-k Kill the `makeinfo' formatting job. - -Typeset and Print ------------------ - - The TeX typesetting and printing commands are invoked by typing `C-c -C-t' and then another control command: `C-r' for `texinfo-tex-region', -`C-b' for `texinfo-tex-buffer', and so on. - - C-c C-t C-r Run TeX on the region. - C-c C-t C-b Run TeX on the buffer. - C-c C-t C-i Run `texindex'. - C-c C-t C-p Print the DVI file. - C-c C-t C-q Show the print queue. - C-c C-t C-d Delete a job from the print queue. - C-c C-t C-k Kill the current TeX formatting job. - C-c C-t C-x Quit a currently stopped TeX formatting job. - C-c C-t C-l Recenter the output buffer. - -Other Updating Commands ------------------------ - - The `other updating commands' do not have standard keybindings -because they are rarely used. - - M-x texinfo-insert-node-lines - Insert missing `@node' lines in region. - With `C-u' as a prefix argument, - use section titles as node names. - - M-x texinfo-multiple-files-update - Update a multi-file document. - With `C-u 2' as a prefix argument, - create or update all nodes and menus - in all included files first. - - M-x texinfo-indent-menu-description - Indent descriptions. - - M-x texinfo-sequential-node-update - Insert node pointers in strict sequence. - - -File: texi.info, Node: Beginning a File, Next: Ending a File, Prev: Texinfo Mode, Up: Top - -Beginning a Texinfo File -************************ - - Certain pieces of information must be provided at the beginning of a -Texinfo file, such as the name of the file and the title of the -document. - -* Menu: - -* Four Parts:: Four parts begin a Texinfo file. -* Sample Beginning:: Here is a sample beginning for a Texinfo file. -* Header:: The very beginning of a Texinfo file. -* Info Summary and Permissions:: Summary and copying permissions for Info. -* Titlepage & Copyright Page:: Creating the title and copyright pages. -* The Top Node:: Creating the `Top' node and master menu. -* Software Copying Permissions:: Ensure that you and others continue to - have the right to use and share software. - - -File: texi.info, Node: Four Parts, Next: Sample Beginning, Up: Beginning a File - -Four Parts Begin a File -======================= - - Generally, the beginning of a Texinfo file has four parts: - - 1. The header, delimited by special comment lines, that includes the - commands for naming the Texinfo file and telling TeX what - definitions' file to use when processing the Texinfo file. - - 2. A short statement of what the file is about, with a copyright - notice and copying permissions. This is enclosed in `@ifinfo' and - `@end ifinfo' commands so that the formatters place it only in the - Info file. - - 3. A title page and copyright page, with a copyright notice and - copying permissions. This is enclosed between `@titlepage' and - `@end titlepage' commands. The title and copyright page appear - only in the printed manual. - - 4. The `Top' node that contains a menu for the whole Info file. The - contents of this node appear only in the Info file. - - Also, optionally, you may include the copying conditions for a -program and a warranty disclaimer. The copying section will be -followed by an introduction or else by the first chapter of the manual. - - Since the copyright notice and copying permissions for the Texinfo -document (in contrast to the copying permissions for a program) are in -parts that appear only in the Info file or only in the printed manual, -this information must be given twice. - - -File: texi.info, Node: Sample Beginning, Next: Header, Prev: Four Parts, Up: Beginning a File - -Sample Texinfo File Beginning -============================= - - The following sample shows what is needed. - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename NAME-OF-INFO-FILE - @settitle NAME-OF-MANUAL - @setchapternewpage odd - @c %**end of header - - @ifinfo - This file documents ... - - Copyright YEAR COPYRIGHT-OWNER - - Permission is granted to ... - @end ifinfo - - @c This title page illustrates only one of the - @c two methods of forming a title page. - - @titlepage - @title NAME-OF-MANUAL-WHEN-PRINTED - @subtitle SUBTITLE-IF-ANY - @subtitle SECOND-SUBTITLE - @author AUTHOR - - @c The following two commands - @c start the copyright page. - @page - @vskip 0pt plus 1filll - Copyright @copyright{} YEAR COPYRIGHT-OWNER - - Published by ... - - Permission is granted to ... - @end titlepage - - @node Top, Overview, (dir), (dir) - - @ifinfo - This document describes ... - - This document applies to version ... - of the program named ... - @end ifinfo - - @menu - * Copying:: Your rights and freedoms. - * First Chapter:: Getting started ... - * Second Chapter:: ... - ... - ... - @end menu - - @node First Chapter, Second Chapter, top, top - @comment node-name, next, previous, up - @chapter First Chapter - @cindex Index entry for First Chapter - - -File: texi.info, Node: Header, Next: Info Summary and Permissions, Prev: Sample Beginning, Up: Beginning a File - -The Texinfo File Header -======================= - - Texinfo files start with at least three lines that provide Info and -TeX with necessary information. These are the `\input texinfo' line, -the `@settitle' line, and the `@setfilename' line. If you want to run -TeX on just a part of the Texinfo File, you must write the `@settitle' -and `@setfilename' lines between start-of-header and end-of-header -lines. - - Thus, the beginning of a Texinfo file looks like this: - - \input texinfo @c -*-texinfo-*- - @setfilename sample.info - @settitle Sample Document - -or else like this: - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename sample.info - @settitle Sample Document - @c %**end of header - -* Menu: - -* First Line:: The first line of a Texinfo file. -* Start of Header:: Formatting a region requires this. -* setfilename:: Tell Info the name of the Info file. -* settitle:: Create a title for the printed work. -* setchapternewpage:: Start chapters on right-hand pages. -* paragraphindent:: An option to specify paragraph indentation. -* End of Header:: Formatting a region requires this. - - -File: texi.info, Node: First Line, Next: Start of Header, Up: Header - -The First Line of a Texinfo File --------------------------------- - - Every Texinfo file that is to be the top-level input to TeX must -begin with a line that looks like this: - - \input texinfo @c -*-texinfo-*- - -This line serves two functions: - - 1. When the file is processed by TeX, the `\input texinfo' command - tells TeX to load the macros needed for processing a Texinfo file. - These are in a file called `texinfo.tex', which is usually located - in the `/usr/lib/tex/macros' directory. TeX uses the backslash, - `\', to mark the beginning of a command, just as Texinfo uses `@'. - The `texinfo.tex' file causes the switch from `\' to `@'; before - the switch occurs, TeX requires `\', which is why it appears at - the beginning of the file. - - 2. When the file is edited in GNU Emacs, the `-*-texinfo-*-' mode - specification tells Emacs to use Texinfo mode. - - -File: texi.info, Node: Start of Header, Next: setfilename, Prev: First Line, Up: Header - -Start of Header ---------------- - - Write a start-of-header line on the second line of a Texinfo file. -Follow the start-of-header line with `@setfilename' and `@settitle' -lines and, optionally, with other command lines, such as `@smallbook' -or `@footnotestyle'; and then by an end-of-header line (*note End of -Header::.). - - With these lines, you can format part of a Texinfo file for Info or -typeset part for printing. - - A start-of-header line looks like this: - - @c %**start of header - - The odd string of characters, `%**', is to ensure that no other -comment is accidentally taken for a start-of-header line. - - -File: texi.info, Node: setfilename, Next: settitle, Prev: Start of Header, Up: Header - -`@setfilename' --------------- - - In order to be made into an Info file, a Texinfo file must contain a -line that looks like this: - - @setfilename INFO-FILE-NAME - - Write the `@setfilename' command at the beginning of a line and -follow it on the same line by the Info file name. Do not write -anything else on the line; anything on the line after the command is -considered part of the file name, including a comment. - - The `@setfilename' line specifies the name of the Info file to be -generated. This name should be different from the name of the Texinfo -file. The convention is to write a name with a `.info' extension, to -produce an Info file name such as `texinfo.info'. - - Some operating systems cannot handle long file names. You can run -into a problem even when the file name you specify is itself short -enough. This occurs because the Info formatters split a long Info file -into short indirect subfiles, and name them by appending `-1', `-2', -..., `-10', `-11', and so on, to the original file name. (*Note Tag -Files and Split Files: Tag and Split Files.) The subfile name -`texinfo.info-10', for example, is too long for some systems; so the -Info file name for this document is actually `texinfo' rather than -`texinfo.info'. - - The Info formatting commands ignore everything written before the -`@setfilename' line, which is why the very first line of the file (the -`\input' line) does not need to be commented out. The `@setfilename' -line is ignored when you typeset a printed manual. - - -File: texi.info, Node: settitle, Next: setchapternewpage, Prev: setfilename, Up: Header - -`@settitle' ------------ - - In order to be made into a printed manual, a Texinfo file must -contain a line that looks like this: - - @settitle TITLE - - Write the `@settitle' command at the beginning of a line and follow -it on the same line by the title. This tells TeX the title to use in a -header or footer. Do not write anything else on the line; anything on -the line after the command is considered part of the title, including a -comment. - - Conventionally, TeX formats a Texinfo file for double-sided output -so as to print the title in the left-hand (even-numbered) page headings -and the current chapter titles in the right-hand (odd-numbered) page -headings. (TeX learns the title of each chapter from each `@chapter' -command.) Page footers are not printed. - - Even if you are printing in a single-sided style, TeX looks for an -`@settitle' command line, in case you include the manual title in the -heading. - - The `@settitle' command should precede everything that generates -actual output in TeX. - - Although the title in the `@settitle' command is usually the same as -the title on the title page, it does not affect the title as it appears -on the title page. Thus, the two do not need not match exactly; and -the title in the `@settitle' command can be a shortened or expanded -version of the title as it appears on the title page. (*Note -`@titlepage': titlepage.) - - TeX prints page headings only for that text that comes after the -`@end titlepage' command in the Texinfo file, or that comes after an -`@headings' command that turns on headings. (*Note The `@headings' -Command: headings on off, for more information.) - - You may, if you wish, create your own, customized headings and -footings. *Note Page Headings: Headings, for a detailed discussion of -this process. - - -File: texi.info, Node: setchapternewpage, Next: paragraphindent, Prev: settitle, Up: Header - -`@setchapternewpage' --------------------- - - In a book or a manual, text is usually printed on both sides of the -paper, chapters start on right-hand pages, and right-hand pages have -odd numbers. But in short reports, text often is printed only on one -side of the paper. Also in short reports, chapters sometimes do not -start on new pages, but are printed on the same page as the end of the -preceding chapter, after a small amount of vertical whitespace. - - You can use the `@setchapternewpage' command with various arguments -to specify how TeX should start chapters and whether it should typeset -pages for printing on one or both sides of the paper (single-sided or -double-sided printing). - - Write the `@setchapternewpage' command at the beginning of a line -followed by its argument. - - For example, you would write the following to cause each chapter to -start on a fresh odd-numbered page: - - @setchapternewpage odd - - You can specify one of three alternatives with the -`@setchapternewpage' command: - -`@setchapternewpage off' - Cause TeX to typeset a new chapter on the same page as the last - chapter, after skipping some vertical whitespace. Also, cause TeX - to format page headers for single-sided printing. (You can - override the headers format with the `@headings double' command; - see *Note The `@headings' Command: headings on off.) - -`@setchapternewpage on' - Cause TeX to start new chapters on new pages and to typeset page - headers for single-sided printing. This is the form most often - used for short reports. - - This alternative is the default. - -`@setchapternewpage odd' - Cause TeX to start new chapters on new, odd-numbered pages - (right-handed pages) and to typeset for double-sided printing. - This is the form most often used for books and manuals. - -Texinfo does not have an `@setchapternewpage even' command. - -(You can countermand or modify an `@setchapternewpage' command with an -`@headings' command. *Note The `@headings' Command: headings on off.) - - At the beginning of a manual or book, pages are not numbered--for -example, the title and copyright pages of a book are not numbered. By -convention, table of contents pages are numbered with roman numerals -and not in sequence with the rest of the document. - - Since an Info file does not have pages, the `@setchapternewpage' -command has no effect on it. - - Usually, you do not write an `@setchapternewpage' command for -single-sided printing, but accept the default which is to typeset for -single-sided printing and to start new chapters on new pages. Usually, -you write an `@setchapternewpage odd' command for double-sided printing. - - -File: texi.info, Node: paragraphindent, Next: End of Header, Prev: setchapternewpage, Up: Header - -Paragraph Indenting -------------------- - - The Info formatting commands may insert spaces at the beginning of -the first line of each paragraph, thereby indenting that paragraph. You -can use the `@paragraphindent' command to specify the indentation. -Write an `@paragraphindent' command at the beginning of a line followed -by either `asis' or a number. The template is: - - @paragraphindent INDENT - - The Info formatting commands indent according to the value of INDENT: - - * If the value of INDENT is `asis', the Info formatting commands do - not change the existing indentation. - - * If the value of INDENT is 0, the Info formatting commands delete - existing indentation. - - * If the value of INDENT is greater than 0, the Info formatting - commands indent the paragraph by that number of spaces. - - The default value of INDENT is `asis'. - - Write the `@paragraphindent' command before or shortly after the -end-of-header line at the beginning of a Texinfo file. (If you write -the command between the start-of-header and end-of-header lines, the -region formatting commands indent paragraphs as specified.) - - A peculiarity of `texinfo-format-buffer' and `texinfo-format-region' -is that they do not indent (nor fill) paragraphs that contain `@w' or -`@*' commands. *Note Refilling Paragraphs::, for a detailed -description of what goes on. - - -File: texi.info, Node: End of Header, Prev: paragraphindent, Up: Header - -End of Header -------------- - - Follow the header lines with an end-of-header line. An -end-of-header line looks like this: - - @c %**end of header - - If you include the `@setchapternewpage' command between the -start-of-header and end-of-header lines, TeX will typeset a region as -that command specifies. Similarly, if you include an `@smallbook' -command between the start-of-header and end-of-header lines, TeX will -typeset a region in the "small" book format. - - The reason for the odd string of characters (`%**') is so that the -`texinfo-tex-region' command does not accidentally find something that -it should not when it is looking for the header. - - The start-of-header line and the end-of-header line are Texinfo mode -variables that you can change. - - -File: texi.info, Node: Info Summary and Permissions, Next: Titlepage & Copyright Page, Prev: Header, Up: Beginning a File - -Summary and Copying Permissions for Info -======================================== - - The title page and the copyright page appear only in the printed -copy of the manual; therefore, the same information must be inserted in -a section that appears only in the Info file. This section usually -contains a brief description of the contents of the Info file, a -copyright notice, and copying permissions. - - The copyright notice should read: - - Copyright YEAR COPYRIGHT-OWNER - -and be put on a line by itself. - - Standard text for the copyright permissions is contained in an -appendix to this manual; see *Note `ifinfo' Copying Permissions: ifinfo -Permissions, for the complete text. - - The permissions text appears in an Info file *before* the first -node. This mean that a reader does *not* see this text when reading -the file using Info, except when using the advanced Info command `g *'. - - -File: texi.info, Node: Titlepage & Copyright Page, Next: The Top Node, Prev: Info Summary and Permissions, Up: Beginning a File - -The Title and Copyright Pages -============================= - - A manual's name and author are usually printed on a title page. -Sometimes copyright information is printed on the title page as well; -more often, copyright information is printed on the back of the title -page. - - The title and copyright pages appear in the printed manual, but not -in the Info file. Because of this, it is possible to use several -slightly obscure TeX typesetting commands that cannot be used in an -Info file. In addition, this part of the beginning of a Texinfo file -contains the text of the copying permissions that will appear in the -printed manual. - - *Note Titlepage Copying Permissions: Titlepage Permissions, for the -standard text for the copyright permissions. - -* Menu: - -* titlepage:: Create a title for the printed document. -* titlefont center sp:: The `@titlefont', `@center', - and `@sp' commands. -* title subtitle author:: The `@title', `@subtitle', - and `@author' commands. -* Copyright & Permissions:: How to write the copyright notice and - include copying permissions. -* end titlepage:: Turn on page headings after the title and - copyright pages. -* headings on off:: An option for turning headings on and off - and double or single sided printing. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-3 b/gnu/usr.bin/texinfo/info-files/texi.info-3 deleted file mode 100644 index 1058a1aca173..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-3 +++ /dev/null @@ -1,1262 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: titlepage, Next: titlefont center sp, Up: Titlepage & Copyright Page - -`@titlepage' ------------- - - Start the material for the title page and following copyright page -with `@titlepage' on a line by itself and end it with `@end titlepage' -on a line by itself. - - The `@end titlepage' command starts a new page and turns on page -numbering. (*Note Page Headings: Headings, for details about how to -generate of page headings.) All the material that you want to appear -on unnumbered pages should be put between the `@titlepage' and `@end -titlepage' commands. By using the `@page' command you can force a page -break within the region delineated by the `@titlepage' and `@end -titlepage' commands and thereby create more than one unnumbered page. -This is how the copyright page is produced. (The `@titlepage' command -might perhaps have been better named the `@titleandadditionalpages' -command, but that would have been rather long!) - - When you write a manual about a computer program, you should write -the version of the program to which the manual applies on the title -page. If the manual changes more frequently than the program or is -independent of it, you should also include an edition number(1) for the -manual. This helps readers keep track of which manual is for which -version of the program. (The `Top' node should also contain this -information; see *Note `@top': makeinfo top.) - - Texinfo provides two methods for creating a title page. One method -uses the `@titlefont', `@sp', and `@center' commands to generate a -title page in which the words on the page are centered. - - The second method uses the `@title', `@subtitle', and `@author' -commands to create a title page with black rules under the title and -author lines and the subtitle text set flush to the right hand side of -the page. With this method, you do not specify any of the actual -formatting of the title page. You specify the text you want, and -Texinfo does the formatting. You may use either method. - - ---------- Footnotes ---------- - - (1) We have found that it is helpful to refer to versions of -manuals as `editions' and versions of programs as `versions'; -otherwise, we find we are liable to confuse each other in conversation -by referring to both the documentation and the software with the same -words. - - -File: texi.info, Node: titlefont center sp, Next: title subtitle author, Prev: titlepage, Up: Titlepage & Copyright Page - -`@titlefont', `@center', and `@sp' ----------------------------------- - - You can use the `@titlefont', `@sp', and `@center' commands to -create a title page for a printed document. (This is the first of the -two methods for creating a title page in Texinfo.) - - Use the `@titlefont' command to select a large font suitable for the -title itself. - - For example: - - @titlefont{Texinfo} - - Use the `@center' command at the beginning of a line to center the -remaining text on that line. Thus, - - @center @titlefont{Texinfo} - -centers the title, which in this example is "Texinfo" printed in the -title font. - - Use the `@sp' command to insert vertical space. For example: - - @sp 2 - -This inserts two blank lines on the printed page. (*Note `@sp': sp, -for more information about the `@sp' command.) - - A template for this method looks like this: - - @titlepage - @sp 10 - @center @titlefont{NAME-OF-MANUAL-WHEN-PRINTED} - @sp 2 - @center SUBTITLE-IF-ANY - @sp 2 - @center AUTHOR - ... - @end titlepage - - The spacing of the example fits an 8 1/2 by 11 inch manual. - - -File: texi.info, Node: title subtitle author, Next: Copyright & Permissions, Prev: titlefont center sp, Up: Titlepage & Copyright Page - -`@title', `@subtitle', and `@author' ------------------------------------- - - You can use the `@title', `@subtitle', and `@author' commands to -create a title page in which the vertical and horizontal spacing is -done for you automatically. This contrasts with the method described in -the previous section, in which the `@sp' command is needed to adjust -vertical spacing. - - Write the `@title', `@subtitle', or `@author' commands at the -beginning of a line followed by the title, subtitle, or author. - - The `@title' command produces a line in which the title is set flush -to the left-hand side of the page in a larger than normal font. The -title is underlined with a black rule. - - The `@subtitle' command sets subtitles in a normal-sized font flush -to the right-hand side of the page. - - The `@author' command sets the names of the author or authors in a -middle-sized font flush to the left-hand side of the page on a line -near the bottom of the title page. The names are underlined with a -black rule that is thinner than the rule that underlines the title. -(The black rule only occurs if the `@author' command line is followed -by an `@page' command line.) - - There are two ways to use the `@author' command: you can write the -name or names on the remaining part of the line that starts with an -`@author' command: - - @author by Jane Smith and John Doe - -or you can write the names one above each other by using two (or more) -`@author' commands: - - @author Jane Smith - @author John Doe - -(Only the bottom name is underlined with a black rule.) - - A template for this method looks like this: - - @titlepage - @title NAME-OF-MANUAL-WHEN-PRINTED - @subtitle SUBTITLE-IF-ANY - @subtitle SECOND-SUBTITLE - @author AUTHOR - @page - ... - @end titlepage - -Contrast this form with the form of a title page written using the -`@sp', `@center', and `@titlefont' commands: - - @titlepage - @sp 10 - @center @titlefont{Name of Manual When Printed} - @sp 2 - @center Subtitle, If Any - @sp 1 - @center Second subtitle - @sp 2 - @center Author - @page - ... - @end titlepage - - -File: texi.info, Node: Copyright & Permissions, Next: end titlepage, Prev: title subtitle author, Up: Titlepage & Copyright Page - -Copyright Page and Permissions ------------------------------- - - By international treaty, the copyright notice for a book should be -either on the title page or on the back of the title page. The -copyright notice should include the year followed by the name of the -organization or person who owns the copyright. - - When the copyright notice is on the back of the title page, that page -is customarily not numbered. Therefore, in Texinfo, the information on -the copyright page should be within `@titlepage' and `@end titlepage' -commands. - - Use the `@page' command to cause a page break. To push the -copyright notice and the other text on the copyright page towards the -bottom of the page, you can write a somewhat mysterious line after the -`@page' command that reads like this: - - @vskip 0pt plus 1filll - -This is a TeX command that is not supported by the Info formatting -commands. The `@vskip' command inserts whitespace. The `0pt plus -1filll' means to put in zero points of mandatory whitespace, and as -much optional whitespace as needed to push the following text to the -bottom of the page. Note the use of three `l's in the word `filll'; -this is the correct usage in TeX. - - In a printed manual, the `@copyright{}' command generates a `c' -inside a circle. (In Info, it generates `(C)'.) The copyright notice -itself has the following legally defined sequence: - - Copyright (C) YEAR COPYRIGHT-OWNER - - It is customary to put information on how to get a manual after the -copyright notice, followed by the copying permissions for the manual. - - Note that permissions must be given here as well as in the summary -segment within `@ifinfo' and `@end ifinfo' that immediately follows the -header since this text appears only in the printed manual and the -`ifinfo' text appears only in the Info file. - - *Note Sample Permissions::, for the standard text. - - -File: texi.info, Node: end titlepage, Next: headings on off, Prev: Copyright & Permissions, Up: Titlepage & Copyright Page - -Heading Generation ------------------- - - An `@end titlepage' command on a line by itself not only marks the -end of the title and copyright pages, but also causes TeX to start -generating page headings and page numbers. - - To repeat what is said elsewhere, Texinfo has two standard page -heading formats, one for documents which are printed on one side of -each sheet of paper (single-sided printing), and the other for -documents which are printed on both sides of each sheet (double-sided -printing). (*Note `@setchapternewpage': setchapternewpage.) You can -specify these formats in different ways: - - * The conventional way is to write an `@setchapternewpage' command - before the title page commands, and then have the `@end titlepage' - command start generating page headings in the manner desired. - (*Note `@setchapternewpage': setchapternewpage.) - - * Alternatively, you can use the `@headings' command to prevent page - headings from being generated or to start them for either single or - double-sided printing. (Write an `@headings' command immediately - after the `@end titlepage' command. *Note The `@headings' - Command: headings on off, for more information.) - - * Or, you may specify your own page heading and footing format. - *Note Page Headings: Headings, for detailed information about page - headings and footings. - - Most documents are formatted with the standard single-sided or -double-sided format, using `@setchapternewpage odd' for double-sided -printing and no `@setchapternewpage' command for single-sided printing. - - -File: texi.info, Node: headings on off, Prev: end titlepage, Up: Titlepage & Copyright Page - -The `@headings' Command ------------------------ - - The `@headings' command is rarely used. It specifies what kind of -page headings and footings to print on each page. Usually, this is -controlled by the `@setchapternewpage' command. You need the -`@headings' command only if the `@setchapternewpage' command does not -do what you want, or if you want to turn off pre-defined page headings -prior to defining your own. Write an `@headings' command immediately -after the `@end titlepage' command. - - There are four ways to use the `@headings' command: - -`@headings off' - Turn off printing of page headings. - -`@headings single' - Turn on page headings appropriate for single-sided printing. - -`@headings double' -`@headings on' - Turn on page headings appropriate for double-sided printing. The - two commands, `@headings on' and `@headings double', are - synonymous. - - For example, suppose you write `@setchapternewpage off' before the -`@titlepage' command to tell TeX to start a new chapter on the same -page as the end of the last chapter. This command also causes TeX to -typeset page headers for single-sided printing. To cause TeX to -typeset for double sided printing, write `@headings double' after the -`@end titlepage' command. - - You can stop TeX from generating any page headings at all by writing -`@headings off' on a line of its own immediately after the line -containing the `@end titlepage' command, like this: - - @end titlepage - @headings off - -The `@headings off' command overrides the `@end titlepage' command, -which would otherwise cause TeX to print page headings. - - You can also specify your own style of page heading and footing. -*Note Page Headings: Headings, for more information. - - -File: texi.info, Node: The Top Node, Next: Software Copying Permissions, Prev: Titlepage & Copyright Page, Up: Beginning a File - -The `Top' Node and Master Menu -============================== - - The `Top' node is the node from which you enter an Info file. - - A `Top' node should contain a brief description of the Info file and -an extensive, master menu for the whole Info file. This helps the -reader understand what the Info file is about. Also, you should write -the version number of the program to which the Info file applies; or, -at least, the edition number. - - The contents of the `Top' node should appear only in the Info file; -none of it should appear in printed output, so enclose it between -`@ifinfo' and `@end ifinfo' commands. (TeX does not print either an -`@node' line or a menu; they appear only in Info; strictly speaking, -you are not required to enclose these parts between `@ifinfo' and `@end -ifinfo', but it is simplest to do so. *Note Conditionally Visible -Text: Conditionals.) - -* Menu: - -* Title of Top Node:: Sketch what the file is about. -* Master Menu Parts:: A master menu has three or more parts. - - -File: texi.info, Node: Title of Top Node, Next: Master Menu Parts, Up: The Top Node - -`Top' Node Title ----------------- - - Sometimes, you will want to place an `@top' sectioning command line -containing the title of the document immediately after the `@node Top' -line (*note The `@top' Sectioning Command: makeinfo top command., for -more information). - - For example, the beginning of the Top node of this manual contains an -`@top' sectioning command, a short description, and edition and version -information. It looks like this: - - ... - @end titlepage - - @ifinfo - @node Top, Copying, (dir), (dir) - @top Texinfo - - Texinfo is a documentation system... - - This is edition... - ... - @end ifinfo - - @menu - * Copying:: Texinfo is freely - redistributable. - * Overview:: What is Texinfo? - ... - @end menu - - In a `Top' node, the `Previous', and `Up' nodes usually refer to the -top level directory of the whole Info system, which is called `(dir)'. -The `Next' node refers to the first node that follows the main or master -menu, which is usually the copying permissions, introduction, or first -chapter. - - -File: texi.info, Node: Master Menu Parts, Prev: Title of Top Node, Up: The Top Node - -Parts of a Master Menu ----------------------- - - A "master menu" is a detailed main menu listing all the nodes in a -file. - - A master menu is enclosed in `@menu' and `@end menu' commands and -does not appear in the printed document. - - Generally, a master menu is divided into parts. - - * The first part contains the major nodes in the Texinfo file: the - nodes for the chapters, chapter-like sections, and the appendices. - - * The second part contains nodes for the indices. - - * The third and subsequent parts contain a listing of the other, - lower level nodes, often ordered by chapter. This way, rather - than go through an intermediary menu, an inquirer can go directly - to a particular node when searching for specific information. - These menu items are not required; add them if you think they are a - convenience. - - Each section in the menu can be introduced by a descriptive line. So -long as the line does not begin with an asterisk, it will not be -treated as a menu entry. (*Note Writing a Menu::, for more -information.) - - For example, the master menu for this manual looks like the following -(but has many more entries): - - @menu - * Copying:: Texinfo is freely - redistributable. - * Overview:: What is Texinfo? - * Texinfo Mode:: Special features in GNU Emacs. - ... - ... - * Command and Variable Index:: - An entry for each @-command. - * Concept Index:: An entry for each concept. - - --- The Detailed Node Listing --- - - Overview of Texinfo - - * Info Files:: What is an Info file? - * Printed Manuals:: Characteristics of - a printed manual. - ... - ... - - Using Texinfo Mode - - * Info on a Region:: Formatting part of a file - for Info. - ... - ... - @end menu - - -File: texi.info, Node: Software Copying Permissions, Prev: The Top Node, Up: Beginning a File - -Software Copying Permissions -============================ - - If the Texinfo file has a section containing the "General Public -License" and the distribution information and a warranty disclaimer for -the software that is documented, this section usually follows the `Top' -node. The General Public License is very important to Project GNU -software. It ensures that you and others will continue to have a right -to use and share the software. - - The copying and distribution information and the disclaimer are -followed by an introduction or else by the first chapter of the manual. - - Although an introduction is not a required part of a Texinfo file, it -is very helpful. Ideally, it should state clearly and concisely what -the file is about and who would be interested in reading it. In -general, an introduction would follow the licensing and distribution -information, although sometimes people put it earlier in the document. -Usually, an introduction is put in an `@unnumbered' section. (*Note -The `@unnumbered' and `@appendix' Commands: unnumbered & appendix.) - - -File: texi.info, Node: Ending a File, Next: Structuring, Prev: Beginning a File, Up: Top - -Ending a Texinfo File -********************* - - The end of a Texinfo file should include the commands that create -indices and generate detailed and summary tables of contents. And it -must include the `@bye' command that marks the last line processed by -TeX. - - For example: - - @node Concept Index, , Variables Index, Top - @c node-name, next, previous, up - @unnumbered Concept Index - - @printindex cp - - @contents - @bye - -* Menu: - -* Printing Indices & Menus:: How to print an index in hardcopy and - generate index menus in Info. -* Contents:: How to create a table of contents. -* File End:: How to mark the end of a file. - - -File: texi.info, Node: Printing Indices & Menus, Next: Contents, Up: Ending a File - -Index Menus and Printing an Index -================================= - - To print an index means to include it as part of a manual or Info -file. This does not happen automatically just because you use -`@cindex' or other index-entry generating commands in the Texinfo file; -those just cause the raw data for the index to be accumulated. To -generate an index, you must include the `@printindex' command at the -place in the document where you want the index to appear. Also, as -part of the process of creating a printed manual, you must run a -program called `texindex' (*note Format/Print Hardcopy::.) to sort the -raw data to produce a sorted index file. The sorted index file is what -is actually used to print the index. - - Texinfo offers six different types of predefined index: the concept -index, the function index, the variables index, the keystroke index, the -program index, and the data type index (*note Predefined Indices::.). -Each index type has a two-letter name: `cp', `fn', `vr', `ky', `pg', -and `tp'. You may merge indices, or put them into separate sections -(*note Combining Indices::.); or you may define your own indices (*note -Defining New Indices: New Indices.). - - The `@printindex' command takes a two-letter index name, reads the -corresponding sorted index file and formats it appropriately into an -index. - - The `@printindex' command does not generate a chapter heading for -the index. Consequently, you should precede the `@printindex' command -with a suitable section or chapter command (usually `@unnumbered') to -supply the chapter heading and put the index into the table of -contents. Precede the `@unnumbered' command with an `@node' line. - - For example: - - @node Variable Index, Concept Index, Function Index, Top - @comment node-name, next, previous, up - @unnumbered Variable Index - - @printindex vr - - @node Concept Index, , Variable Index, Top - @comment node-name, next, previous, up - @unnumbered Concept Index - - @printindex cp - - @summarycontents - @contents - @bye - -(Readers often prefer that the concept index come last in a book, since -that makes it easiest to find.) - - -File: texi.info, Node: Contents, Next: File End, Prev: Printing Indices & Menus, Up: Ending a File - -Generating a Table of Contents -============================== - - The `@chapter', `@section', and other structuring commands supply -the information to make up a table of contents, but they do not cause -an actual table to appear in the manual. To do this, you must use the -`@contents' and `@summarycontents' commands: - -`@contents' - Generate a table of contents in a printed manual, including all - chapters, sections, subsections, etc., as well as appendices and - unnumbered chapters. (Headings generated by the `@heading' series - of commands do not appear in the table of contents.) The - `@contents' command should be written on a line by itself. - -`@shortcontents' -`@summarycontents' - (`@summarycontents' is a synonym for `@shortcontents'; the two - commands are exactly the same.) - - Generate a short or summary table of contents that lists only the - chapters (and appendices and unnumbered chapters). Omit sections, - subsections and subsubsections. Only a long manual needs a short - table of contents in addition to the full table of contents. - - Write the `@shortcontents' command on a line by itself right - *before* the `@contents' command. - - The table of contents commands automatically generate a chapter-like -heading at the top of the first table of contents page. Write the table -of contents commands at the very end of a Texinfo file, just before the -`@bye' command, following any index sections--anything in the Texinfo -file after the table of contents commands will be omitted from the -table of contents. - - When you print a manual with a table of contents, the table of -contents are printed last and numbered with roman numerals. You need -to place those pages in their proper place, after the title page, -yourself. (This is the only collating you need to do for a printed -manual. The table of contents is printed last because it is generated -after the rest of the manual is typeset.) - - Here is an example of where to write table of contents commands: - - INDICES... - @shortcontents - @contents - @bye - - Since an Info file uses menus instead of tables of contents, the Info -formatting commands ignore the `@contents' and `@shortcontents' -commands. - - -File: texi.info, Node: File End, Prev: Contents, Up: Ending a File - -`@bye' File Ending -================== - - An `@bye' command terminates TeX or Info formatting. None of the -formatting commands see any of the file following `@bye'. The `@bye' -command should be on a line by itself. - - If you wish, you may follow the `@bye' line with notes. These notes -will not be formatted and will not appear in either Info or a printed -manual; it is as if text after `@bye' were within `@ignore' ... `@end -ignore'. Also, you may follow the `@bye' line with a local variables -list. *Note Using Local Variables and the Compile Command: -Compile-Command, for more information. - - -File: texi.info, Node: Structuring, Next: Nodes, Prev: Ending a File, Up: Top - -Chapter Structuring -******************* - - The "chapter structuring" commands divide a document into a -hierarchy of chapters, sections, subsections, and subsubsections. -These commands generate large headings; they also provide information -for the table of contents of a printed manual (*note Generating a Table -of Contents: Contents.). - - The chapter structuring commands do not create an Info node -structure, so normally you should put an `@node' command immediately -before each chapter structuring command (*note Nodes::.). The only -time you are likely to use the chapter structuring commands without -using the node structuring commands is if you are writing a document -that contains no cross references and will never be transformed into -Info format. - - It is unlikely that you will ever write a Texinfo file that is -intended only as an Info file and not as a printable document. If you -do, you might still use chapter structuring commands to create a -heading at the top of each node--but you don't need to. - -* Menu: - -* Tree Structuring:: A manual is like an upside down tree ... -* Structuring Command Types:: How to divide a manual into parts. -* makeinfo top:: The `@top' command, part of the `Top' node. -* chapter:: -* unnumbered & appendix:: -* majorheading & chapheading:: -* section:: -* unnumberedsec appendixsec heading:: -* subsection:: -* unnumberedsubsec appendixsubsec subheading:: -* subsubsection:: Commands for the lowest level sections. - - -File: texi.info, Node: Tree Structuring, Next: Structuring Command Types, Up: Structuring - -Tree Structure of Sections -========================== - - A Texinfo file is usually structured like a book with chapters, -sections, subsections, and the like. This structure can be visualized -as a tree (or rather as an upside-down tree) with the root at the top -and the levels corresponding to chapters, sections, subsection, and -subsubsections. - - Here is a diagram that shows a Texinfo file with three chapters, -each of which has two sections. - - Top - | - ------------------------------------- - | | | - Chapter 1 Chapter 2 Chapter 3 - | | | - -------- -------- -------- - | | | | | | - Section Section Section Section Section Section - 1.1 1.2 2.1 2.2 3.1 3.2 - - In a Texinfo file that has this structure, the beginning of Chapter 2 -looks like this: - - @node Chapter 2, Chapter 3, Chapter 1, top - @chapter Chapter 2 - - The chapter structuring commands are described in the sections that -follow; the `@node' and `@menu' commands are described in following -chapters. (*Note Nodes::, and see *Note Menus::.) - - -File: texi.info, Node: Structuring Command Types, Next: makeinfo top, Prev: Tree Structuring, Up: Structuring - -Types of Structuring Command -============================ - - The chapter structuring commands fall into four groups or series, -each of which contains structuring commands corresponding to the -hierarchical levels of chapters, sections, subsections, and -subsubsections. - - The four groups are the `@chapter' series, the `@unnumbered' series, -the `@appendix' series, and the `@heading' series. - - Each command produces titles that have a different appearance on the -printed page or Info file; only some of the commands produce titles -that are listed in the table of contents of a printed book or manual. - - * The `@chapter' and `@appendix' series of commands produce numbered - or lettered entries both in the body of a printed work and in its - table of contents. - - * The `@unnumbered' series of commands produce unnumbered entries - both in the body of a printed work and in its table of contents. - The `@top' command, which has a special use, is a member of this - series (*note `@top': makeinfo top.). - - * The `@heading' series of commands produce unnumbered headings that - do not appear in a table of contents. The heading commands never - start a new page. - - * The `@majorheading' command produces results similar to using the - `@chapheading' command but generates a larger vertical whitespace - before the heading. - - * When an `@setchapternewpage' command says to do so, the - `@chapter', `@unnumbered', and `@appendix' commands start new - pages in the printed manual; the `@heading' commands do not. - - Here are the four groups of chapter structuring commands: - - No new pages - Numbered Unnumbered Lettered and numbered Unnumbered - In contents In contents In contents Not in contents - - @top @majorheading - @chapter @unnumbered @appendix @chapheading - @section @unnumberedsec @appendixsec @heading - @subsection @unnumberedsubsec @appendixsubsec @subheading - @subsubsection @unnumberedsubsubsec @appendixsubsubsec @subsubheading - - -File: texi.info, Node: makeinfo top, Next: chapter, Prev: Structuring Command Types, Up: Structuring - -`@top' -====== - - The `@top' command is a special sectioning command that you use only -after an `@node Top' line at the beginning of a Texinfo file. The -`@top' command tells the `makeinfo' formatter which node is the `Top' -node. It has the same typesetting effect as `@unnumbered' (*note -`@unnumbered': (`@appendix')unnumbered & appendix.). For detailed -information, see *Note The `@top' Command: makeinfo top command. - - -File: texi.info, Node: chapter, Next: unnumbered & appendix, Prev: makeinfo top, Up: Structuring - -`@chapter' -========== - - `@chapter' identifies a chapter in the document. Write the command -at the beginning of a line and follow it on the same line by the title -of the chapter. - - For example, this chapter in this manual is entitled "Chapter -Structuring"; the `@chapter' line looks like this: - - @chapter Chapter Structuring - - In TeX, the `@chapter' command creates a chapter in the document, -specifying the chapter title. The chapter is numbered automatically. - - In Info, the `@chapter' command causes the title to appear on a line -by itself, with a line of asterisks inserted underneath. Thus, in -Info, the above example produces the following output: - - Chapter Structuring - ******************* - - -File: texi.info, Node: unnumbered & appendix, Next: majorheading & chapheading, Prev: chapter, Up: Structuring - -`@unnumbered', `@appendix' -========================== - - Use the `@unnumbered' command to create a chapter that appears in a -printed manual without chapter numbers of any kind. Use the -`@appendix' command to create an appendix in a printed manual that is -labelled by letter instead of by number. - - For Info file output, the `@unnumbered' and `@appendix' commands are -equivalent to `@chapter': the title is printed on a line by itself with -a line of asterisks underneath. (*Note `@chapter': chapter.) - - To create an appendix or an unnumbered chapter, write an `@appendix' -or `@unnumbered' command at the beginning of a line and follow it on -the same line by the title, as you would if you were creating a chapter. - - -File: texi.info, Node: majorheading & chapheading, Next: section, Prev: unnumbered & appendix, Up: Structuring - -`@majorheading', `@chapheading' -=============================== - - The `@majorheading' and `@chapheading' commands put chapter-like -headings in the body of a document. - - However, neither command causes TeX to produce a numbered heading or -an entry in the table of contents; and neither command causes TeX to -start a new page in a printed manual. - - In TeX, an `@majorheading' command generates a larger vertical -whitespace before the heading than an `@chapheading' command but is -otherwise the same. - - In Info, the `@majorheading' and `@chapheading' commands are -equivalent to `@chapter': the title is printed on a line by itself with -a line of asterisks underneath. (*Note `@chapter': chapter.) - - -File: texi.info, Node: section, Next: unnumberedsec appendixsec heading, Prev: majorheading & chapheading, Up: Structuring - -`@section' -========== - - In a printed manual, an `@section' command identifies a numbered -section within a chapter. The section title appears in the table of -contents. In Info, an `@section' command provides a title for a -segment of text, underlined with `='. - - This section is headed with an `@section' command and looks like -this in the Texinfo file: - - @section @code{@@section} - - To create a section, write the `@section' command at the beginning -of a line and follow it on the same line by the section title. - - Thus, - - @section This is a section - -produces - - This is a section - ================= - -in Info. - - -File: texi.info, Node: unnumberedsec appendixsec heading, Next: subsection, Prev: section, Up: Structuring - -`@unnumberedsec', `@appendixsec', `@heading' -============================================ - - The `@unnumberedsec', `@appendixsec', and `@heading' commands are, -respectively, the unnumbered, appendix-like, and heading-like -equivalents of the `@section' command. (*Note `@section': section.) - -`@unnumberedsec' - The `@unnumberedsec' command may be used within an unnumbered - chapter or within a regular chapter or appendix to provide an - unnumbered section. - -`@appendixsec' -`@appendixsection' - `@appendixsection' is a longer spelling of the `@appendixsec' - command; the two are synonymous. - - Conventionally, the `@appendixsec' or `@appendixsection' command - is used only within appendices. - -`@heading' - You may use the `@heading' command anywhere you wish for a - section-style heading that will not appear in the table of - contents. - - -File: texi.info, Node: subsection, Next: unnumberedsubsec appendixsubsec subheading, Prev: unnumberedsec appendixsec heading, Up: Structuring - -The `@subsection' Command -========================= - - Subsections are to sections as sections are to chapters. (*Note -`@section': section.) In Info, subsection titles are underlined with -`-'. For example, - - @subsection This is a subsection - -produces - - This is a subsection - -------------------- - - In a printed manual, subsections are listed in the table of contents -and are numbered three levels deep. - - -File: texi.info, Node: unnumberedsubsec appendixsubsec subheading, Next: subsubsection, Prev: subsection, Up: Structuring - -The `@subsection'-like Commands -=============================== - - The `@unnumberedsubsec', `@appendixsubsec', and `@subheading' -commands are, respectively, the unnumbered, appendix-like, and -heading-like equivalents of the `@subsection' command. (*Note -`@subsection': subsection.) - - In Info, the `@subsection'-like commands generate a title underlined -with hyphens. In a printed manual, an `@subheading' command produces a -heading like that of a subsection except that it is not numbered and -does not appear in the table of contents. Similarly, an -`@unnumberedsubsec' command produces an unnumbered heading like that of -a subsection and an `@appendixsubsec' command produces a -subsection-like heading labelled with a letter and numbers; both of -these commands produce headings that appear in the table of contents. - - -File: texi.info, Node: subsubsection, Prev: unnumberedsubsec appendixsubsec subheading, Up: Structuring - -The `subsub' Commands -===================== - - The fourth and lowest level sectioning commands in Texinfo are the -`subsub' commands. They are: - -`@subsubsection' - Subsubsections are to subsections as subsections are to sections. - (*Note `@subsection': subsection.) In a printed manual, - subsubsection titles appear in the table of contents and are - numbered four levels deep. - -`@unnumberedsubsubsec' - Unnumbered subsubsection titles appear in the table of contents of - a printed manual, but lack numbers. Otherwise, unnumbered - subsubsections are the same as subsubsections. In Info, unnumbered - subsubsections look exactly like ordinary subsubsections. - -`@appendixsubsubsec' - Conventionally, appendix commands are used only for appendices and - are lettered and numbered appropriately in a printed manual. They - also appear in the table of contents. In Info, appendix - subsubsections look exactly like ordinary subsubsections. - -`@subsubheading' - The `@subsubheading' command may be used anywhere that you need a - small heading that will not appear in the table of contents. In - Info, subsubheadings look exactly like ordinary subsubsection - headings. - - In Info, `subsub' titles are underlined with periods. For example, - - @subsubsection This is a subsubsection - -produces - - This is a subsubsection - ....................... - - -File: texi.info, Node: Nodes, Next: Menus, Prev: Structuring, Up: Top - -Nodes -***** - - "Nodes" are the primary segments of a Texinfo file. They do not -themselves impose a hierarchic or any other kind of structure on a file. -Nodes contain "node pointers" that name other nodes, and can contain -"menus" which are lists of nodes. In Info, the movement commands can -carry you to a pointed-to node or to a node listed in a menu. Node -pointers and menus provide structure for Info files just as chapters, -sections, subsections, and the like, provide structure for printed -books. - -* Menu: - -* Two Paths:: Different commands to structure - Info output and printed output. -* Node Menu Illustration:: A diagram, and sample nodes and menus. -* node:: How to write a node, in detail. -* makeinfo Pointer Creation:: How to create node pointers with `makeinfo'. - - -File: texi.info, Node: Two Paths, Next: Node Menu Illustration, Up: Nodes - -Two Paths -========= - - The node and menu commands and the chapter structuring commands are -independent of each other: - - * In Info, node and menu commands provide structure. The chapter - structuring commands generate headings with different kinds of - underlining--asterisks for chapters, hyphens for sections, and so - on; they do nothing else. - - * In TeX, the chapter structuring commands generate chapter and - section numbers and tables of contents. The node and menu - commands provide information for cross references; they do nothing - else. - - You can use node pointers and menus to structure an Info file any way -you want; and you can write a Texinfo file so that its Info output has a -different structure than its printed output. However, most Texinfo -files are written such that the structure for the Info output -corresponds to the structure for the printed output. It is not -convenient to do otherwise. - - Generally, printed output is structured in a tree-like hierarchy in -which the chapters are the major limbs from which the sections branch -out. Similarly, node pointers and menus are organized to create a -matching structure in the Info output. - - -File: texi.info, Node: Node Menu Illustration, Next: node, Prev: Two Paths, Up: Nodes - -Node and Menu Illustration -========================== - - Here is a copy of the diagram shown earlier that illustrates a -Texinfo file with three chapters, each of which contains two sections. - - Note that the "root" is at the top of the diagram and the "leaves" -are at the bottom. This is how such a diagram is drawn conventionally; -it illustrates an upside-down tree. For this reason, the root node is -called the `Top' node, and `Up' node pointers carry you closer to the -root. - - Top - | - ------------------------------------- - | | | - Chapter 1 Chapter 2 Chapter 3 - | | | - -------- -------- -------- - | | | | | | - Section Section Section Section Section Section - 1.1 1.2 2.1 2.2 3.1 3.2 - - Write the beginning of the node for Chapter 2 like this: - - @node Chapter 2, Chapter 3, Chapter 1, top - @comment node-name, next, previous, up - -This `@node' line says that the name of this node is "Chapter 2", the -name of the `Next' node is "Chapter 3", the name of the `Previous' node -is "Chapter 1", and the name of the `Up' node is "Top". - - *Please Note:* `Next' refers to the next node at the same - hierarchical level in the manual, not necessarily to the next node - within the Texinfo file. In the Texinfo file, the subsequent node - may be at a lower level--a section-level node may follow a - chapter-level node, and a subsection-level node may follow a - section-level node. `Next' and `Previous' refer to nodes at the - *same* hierarchical level. (The `Top' node contains the exception - to this rule. Since the `Top' node is the only node at that - level, `Next' refers to the first following node, which is almost - always a chapter or chapter-level node.) - - To go to Sections 2.1 and 2.2 using Info, you need a menu inside -Chapter 2. (*Note Menus::.) You would write the menu just before the -beginning of Section 2.1, like this: - - @menu - * Sect. 2.1:: Description of this section. - * Sect. 2.2:: - @end menu - - Write the node for Sect. 2.1 like this: - - @node Sect. 2.1, Sect. 2.2, Chapter 2, Chapter 2 - @comment node-name, next, previous, up - - In Info format, the `Next' and `Previous' pointers of a node usually -lead to other nodes at the same level--from chapter to chapter or from -section to section (sometimes, as shown, the `Previous' pointer points -up); an `Up' pointer usually leads to a node at the level above (closer -to the `Top' node); and a `Menu' leads to nodes at a level below (closer -to `leaves'). (A cross reference can point to a node at any level; see -*Note Cross References::.) - - Usually, an `@node' command and a chapter structuring command are -used in sequence, along with indexing commands. (You may follow the -`@node' line with a comment line that reminds you which pointer is -which.) - - Here is the beginning of the chapter in this manual called "Ending a -Texinfo File". This shows an `@node' line followed by a comment line, -an `@chapter' line, and then by indexing lines. - - @node Ending a File, Structuring, Beginning a File, Top - @comment node-name, next, previous, up - @chapter Ending a Texinfo File - @cindex Ending a Texinfo file - @cindex Texinfo file ending - @cindex File ending - - -File: texi.info, Node: node, Next: makeinfo Pointer Creation, Prev: Node Menu Illustration, Up: Nodes - -The `@node' Command -=================== - - A "node" is a segment of text that begins at an `@node' command and -continues until the next `@node' command. The definition of node is -different from that for chapter or section. A chapter may contain -sections and a section may contain subsections; but a node cannot -contain subnodes; the text of a node continues only until the next -`@node' command in the file. A node usually contains only one chapter -structuring command, the one that follows the `@node' line. On the -other hand, in printed output nodes are used only for cross references, -so a chapter or section may contain any number of nodes. Indeed, a -chapter usually contains several nodes, one for each section, -subsection, and subsubsection. - - To create a node, write an `@node' command at the beginning of a -line, and follow it with four arguments, separated by commas, on the -rest of the same line. These arguments are the name of the node, and -the names of the `Next', `Previous', and `Up' pointers, in that order. -You may insert spaces before each pointer if you wish; the spaces are -ignored. You must write the name of the node, and the names of the -`Next', `Previous', and `Up' pointers, all on the same line. Otherwise, -the formatters fail. (*note info: (info)Top, for more information -about nodes in Info.) - - Usually, you write one of the chapter-structuring command lines -immediately after an `@node' line--for example, an `@section' or -`@subsection' line. (*Note Types of Structuring Command: Structuring -Command Types.) - - *Please note:* The GNU Emacs Texinfo mode updating commands work - only with Texinfo files in which `@node' lines are followed by - chapter structuring lines. *Note Updating Requirements::. - - TeX uses `@node' lines to identify the names to use for cross -references. For this reason, you must write `@node' lines in a Texinfo -file that you intend to format for printing, even if you do not intend -to format it for Info. (Cross references, such as the one at the end -of this sentence, are made with `@xref' and its related commands; see -*Note Cross References::.) - -* Menu: - -* Node Names:: How to choose node and pointer names. -* Writing a Node:: How to write an `@node' line. -* Node Line Tips:: Keep names short. -* Node Line Requirements:: Keep names unique, without @-commands. -* First Node:: How to write a `Top' node. -* makeinfo top command:: How to use the `@top' command. -* Top Node Summary:: Write a brief description for readers. - - -File: texi.info, Node: Node Names, Next: Writing a Node, Up: node - -Choosing Node and Pointer Names -------------------------------- - - The name of a node identifies the node. The pointers enable you to -reach other nodes and consist of the names of those nodes. - - Normally, a node's `Up' pointer contains the name of the node whose -menu mentions that node. The node's `Next' pointer contains the name -of the node that follows that node in that menu and its `Previous' -pointer contains the name of the node that precedes it in that menu. -When a node's `Previous' node is the same as its `Up' node, both node -pointers name the same node. - - Usually, the first node of a Texinfo file is the `Top' node, and its -`Up' and `Previous' pointers point to the `dir' file, which contains -the main menu for all of Info. - - The `Top' node itself contains the main or master menu for the -manual. Also, it is helpful to include a brief description of the -manual in the `Top' node. *Note First Node::, for information on how -to write the first node of a Texinfo file. - - -File: texi.info, Node: Writing a Node, Next: Node Line Tips, Prev: Node Names, Up: node - -How to Write an `@node' Line ----------------------------- - - The easiest way to write an `@node' line is to write `@node' at the -beginning of a line and then the name of the node, like this: - - @node NODE-NAME - - If you are using GNU Emacs, you can use the update node commands -provided by Texinfo mode to insert the names of the pointers; or you -can leave the pointers out of the Texinfo file and let `makeinfo' -insert node pointers into the Info file it creates. (*Note Texinfo -Mode::, and *Note makeinfo Pointer Creation::.) - - Alternatively, you can insert the `Next', `Previous', and `Up' -pointers yourself. If you do this, you may find it helpful to use the -Texinfo mode keyboard command `C-c C-c n'. This command inserts -`@node' and a comment line listing the names of the pointers in their -proper order. The comment line helps you keep track of which arguments -are for which pointers. This comment line is especially useful if you -are not familiar with Texinfo. - - The template for a node line with `Next', `Previous', and `Up' -pointers looks like this: - - @node NODE-NAME, NEXT, PREVIOUS, UP - - If you wish, you can ignore `@node' lines altogether in your first -draft and then use the `texinfo-insert-node-lines' command to create -`@node' lines for you. However, we do not recommend this practice. It -is better to name the node itself at the same time that you write a -segment so you can easily make cross references. A large number of -cross references are an especially important feature of a good Info -file. - - After you have inserted an `@node' line, you should immediately -write an @-command for the chapter or section and insert its name. -Next (and this is important!), put in several index entries. Usually, -you will find at least two and often as many as four or five ways of -referring to the node in the index. Use them all. This will make it -much easier for people to find the node. - - -File: texi.info, Node: Node Line Tips, Next: Node Line Requirements, Prev: Writing a Node, Up: node - -`@node' Line Tips ------------------ - - Here are three suggestions: - - * Try to pick node names that are informative but short. - - In the Info file, the file name, node name, and pointer names are - all inserted on one line, which may run into the right edge of the - window. (This does not cause a problem with Info, but is ugly.) - - * Try to pick node names that differ from each other near the - beginnings of their names. This way, it is easy to use automatic - name completion in Info. - - * By convention, node names are capitalized just as they would be for - section or chapter titles--initial and significant words are - capitalized; others are not. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-4 b/gnu/usr.bin/texinfo/info-files/texi.info-4 deleted file mode 100644 index 8698ab6cb47a..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-4 +++ /dev/null @@ -1,1412 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Node Line Requirements, Next: First Node, Prev: Node Line Tips, Up: node - -`@node' Line Requirements -------------------------- - - Here are several requirements for `@node' lines: - - * All the node names for a single Info file must be unique. - - Duplicates confuse the Info movement commands. This means, for - example, that if you end every chapter with a summary, you must - name each summary node differently. You cannot just call each one - "Summary". You may, however, duplicate the titles of chapters, - sections, and the like. Thus you can end each chapter in a book - with a section called "Summary", so long as the node names for - those sections are all different. - - * A pointer name must be the name of a node. - - The node to which a pointer points may come before or after the - node containing the pointer. - - * You cannot use any of the Texinfo @-commands in a node name; - @-commands confuse Info. - - Thus, the beginning of the section called `@chapter' looks like - this: - - @node chapter, unnumbered & appendix, makeinfo top, Structuring - @comment node-name, next, previous, up - @section @code{@@chapter} - @findex chapter - - * You cannot use commas, colons, or apostrophes within a node name; - these confuse TeX or the Info formatters. - - For example, the following is a section title: - - @code{@@unnumberedsec}, @code{@@appendixsec}, @code{@@heading} - - The corresponding node name is: - - unnumberedsec appendixsec heading - - * Case is significant. - - -File: texi.info, Node: First Node, Next: makeinfo top command, Prev: Node Line Requirements, Up: node - -The First Node --------------- - - The first node of a Texinfo file is the `Top' node, except in an -included file (*note Include Files::.). - - The `Top' node (which must be named `top' or `Top') should have as -its `Up' and `Previous' nodes the name of a node in another file, where -there is a menu that leads to this file. Specify the file name in -parentheses. If the file is to be installed directly in the Info -directory file, use `(dir)' as the parent of the `Top' node; this is -short for `(dir)top', and specifies the `Top' node in the `dir' file, -which contains the main menu for Info. For example, the `@node Top' -line of this manual looks like this: - - @node Top, Overview, (dir), (dir) - -(You may use the Texinfo updating commands or the `makeinfo' utility to -insert these `Next' and `(dir)' pointers automatically.) - - *Note Install an Info File::, for more information about installing -an Info file in the `info' directory. - - The `Top' node contains the main or master menu for the document. - - -File: texi.info, Node: makeinfo top command, Next: Top Node Summary, Prev: First Node, Up: node - -The `@top' Sectioning Command ------------------------------ - - A special sectioning command, `@top', has been created for use with -the `@node Top' line. The `@top' sectioning command tells `makeinfo' -that it marks the `Top' node in the file. It provides the information -that `makeinfo' needs to insert node pointers automatically. Write the -`@top' command at the beginning of the line immediately following the -`@node Top' line. Write the title on the remaining part of the same -line as the `@top' command. - - In Info, the `@top' sectioning command causes the title to appear on -a line by itself, with a line of asterisks inserted underneath. - - In TeX and `texinfo-format-buffer', the `@top' sectioning command is -merely a synonym for `@unnumbered'. Neither of these formatters -require an `@top' command, and do nothing special with it. You can use -`@chapter' or `@unnumbered' after the `@node Top' line when you use -these formatters. Also, you can use `@chapter' or `@unnumbered' when -you use the Texinfo updating commands to create or update pointers and -menus. - - Whatever sectioning command follows an `@node Top' line, whether it -be `@top' or `@chapter', the `@node Top' line and the immediately -following line and any additional text must be enclosed between -`@ifinfo' and `@end ifinfo' commands. (*Note Conditionals::.) This -prevents the title and the accompanying text from appearing in printed -output. Write the `@ifinfo' command before the `@node' line and write -the `@end ifinfo' command after the `@top' or other sectioning command -and after any additional text. (You can write the `@end ifinfo' -command after the `@end menu' command if you like.) - - -File: texi.info, Node: Top Node Summary, Prev: makeinfo top command, Up: node - -The `Top' Node Summary ----------------------- - - You can help readers by writing a summary in the `Top' node, after -the `@top' line, before the main or master menu. The summary should -briefly describe the Info file. You should also write the version -number of the program to which the manual applies in this section. This -helps the reader keep track of which manual is for which version of the -program. If the manual changes more frequently than the program or is -independent of it, you should also include an edition number for the -manual. (The title page should also contain this information: see -*Note `@titlepage': titlepage.) - - Put the whole of the `Top' node, including the `@top' sectioning -command line if you have one, between `@ifinfo' and `@end ifinfo' so -none of the text appears in the printed output (*note Conditionally -Visible Text: Conditionals.). (You may want to repeat the brief -description from the `Top' node within `@iftex' ... `@end iftex' at the -beginning of the first chapter, for those who read the printed manual.) - - -File: texi.info, Node: makeinfo Pointer Creation, Prev: node, Up: Nodes - -Creating Pointers with `makeinfo' -================================= - - The `makeinfo' program has a feature for automatically creating node -pointers for a hierarchically organized file that lacks them. - - When you take advantage of this feature, you do not need to write the -`Next', `Previous', and `Up' pointers after the name of a node. -However, you must write a sectioning command, such as `@chapter' or -`@section', on the line immediately following each truncated `@node' -line. You cannot write a comment line after a node line; the section -line must follow it immediately. - - In addition, you must follow the `Top' `@node' line with a line -beginning with `@top' to mark the `Top' node in the file. *Note `@top': -makeinfo top. - - Finally, you must write the name of each node (except for the `Top' -node) in a menu that is one or more hierarchical levels above the -node's hierarchical level. - - This node pointer insertion feature in `makeinfo' is an alternative -to the menu and pointer creation and update commands in Texinfo mode. -(*Note Updating Nodes and Menus::.) It is especially helpful to people -who do not use GNU Emacs for writing Texinfo documents. - - -File: texi.info, Node: Menus, Next: Cross References, Prev: Nodes, Up: Top - -Menus -***** - - "Menus" contain pointers to subordinate nodes.(1) In Info, you use -menus to go to such nodes. Menus have no effect in printed manuals and -do not appear in them. - - By convention, a menu is put at the end of a node since a reader who -uses the menu may not see text that follows it. - - A node that has a menu should *not* contain much text. If you have -a lot of text and a menu, move most of the text into a new subnode--all -but a few lines. - -* Menu: - -* Menu Location:: Put a menu in a short node. -* Writing a Menu:: What is a menu? -* Menu Parts:: A menu entry has three parts. -* Less Cluttered Menu Entry:: Two part menu entry. -* Menu Example:: Two and three part menu entries. -* Other Info Files:: How to refer to a different Info file. - - ---------- Footnotes ---------- - - (1) Menus can carry you to any node, regardless of the hierarchical -structure; even to nodes in a different Info file. However, the GNU -Emacs Texinfo mode updating commands work only to create menus of -subordinate nodes. Conventionally, cross references are used to refer -to other nodes. - - -File: texi.info, Node: Menu Location, Next: Writing a Menu, Up: Menus - -Menus Need Short Nodes -====================== - - A reader can easily see a menu that is close to the beginning of the -node. The node should be short. As a practical matter, you should -locate a menu within 20 lines of the beginning of the node. Otherwise, -a reader with a terminal that displays only a few lines may miss the -menu and its associated text. - - The short text before a menu may look awkward in a printed manual. -To avoid this, you can write a menu near the beginning of its node and -follow the menu by an `@node' line, and then an `@heading' line located -within `@ifinfo' and `@end ifinfo'. This way, the menu, `@node' line, -and title appear only in the Info file, not the printed document. - - For example, the preceding two paragraphs follow an Info-only menu, -`@node' line, and heading, and look like this: - - @menu - * Menu Location:: Put a menu in a short node. - * Writing a Menu:: What is a menu? - * Menu Parts:: A menu entry has three parts. - * Less Cluttered Menu Entry:: Two part menu entry. - * Menu Example:: Two and three part entries. - * Other Info Files:: How to refer to a different - Info file. - @end menu - - @node Menu Location, Writing a Menu, , Menus - @ifinfo - @heading Menus Need Short Nodes - @end ifinfo - - The Texinfo file for this document contains more than a dozen -examples of this procedure. One is at the beginning of this chapter; -another is at the beginning of the "Cross References" chapter. - - -File: texi.info, Node: Writing a Menu, Next: Menu Parts, Prev: Menu Location, Up: Menus - -Writing a Menu -============== - - A menu consists of an `@menu' command on a line by itself followed -by menu entry lines or menu comment lines and then by an `@end menu' -command on a line by itself. - - A menu looks like this: - - @menu - Larger Units of Text - - * Files:: All about handling files. - * Multiples: Buffers. Multiple buffers; editing - several files at once. - @end menu - - In a menu, every line that begins with an `* ' is a "menu entry". -(Note the space after the asterisk.) A line that does not start with -an `* ' may also appear in a menu. Such a line is not a menu entry but -is a menu comment line that appears in the Info file. In the example -above, the line `Larger Units of Text' is a menu comment line; the two -lines starting with `* ' are menu entries. - - -File: texi.info, Node: Menu Parts, Next: Less Cluttered Menu Entry, Prev: Writing a Menu, Up: Menus - -The Parts of a Menu -=================== - - A menu entry has three parts, only the second of which is required: - - 1. The menu entry name. - - 2. The name of the node (required). - - 3. A description of the item. - - The template for a menu entry looks like this: - - * MENU-ENTRY-NAME: NODE-NAME. DESCRIPTION - - Follow the menu entry name with a single colon and follow the node -name with tab, comma, period, or newline. - - In Info, a user selects a node with the `m' (`Info-menu') command. -The menu entry name is what the user types after the `m' command. - - The third part of a menu entry is a descriptive phrase or sentence. -Menu entry names and node names are often short; the description -explains to the reader what the node is about. The description, which -is optional, can spread over two or more lines. A useful description -complements the node name rather than repeats it. - - -File: texi.info, Node: Less Cluttered Menu Entry, Next: Menu Example, Prev: Menu Parts, Up: Menus - -Less Cluttered Menu Entry -========================= - - When the menu entry name and node name are the same, you can write -the name immediately after the asterisk and space at the beginning of -the line and follow the name with two colons. - - For example, write - - * Name:: DESCRIPTION - -instead of - - * Name: Name. DESCRIPTION - - You should use the node name for the menu entry name whenever -possible, since it reduces visual clutter in the menu. - - -File: texi.info, Node: Menu Example, Next: Other Info Files, Prev: Less Cluttered Menu Entry, Up: Menus - -A Menu Example -============== - - A menu looks like this in Texinfo: - - @menu - * menu entry name: Node name. A short description. - * Node name:: This form is preferred. - @end menu - -This produces: - - * menu: - - * menu entry name: Node name. A short description. - * Node name:: This form is preferred. - - Here is an example as you might see it in a Texinfo file: - - @menu - Larger Units of Text - - * Files:: All about handling files. - * Multiples: Buffers. Multiple buffers; editing - several files at once. - @end menu - -This produces: - - * menu: - Larger Units of Text - - * Files:: All about handling files. - * Multiples: Buffers. Multiple buffers; editing - several files at once. - - In this example, the menu has two entries. `Files' is both a menu -entry name and the name of the node referred to by that name. -`Multiples' is the menu entry name; it refers to the node named -`Buffers'. The line `Larger Units of Text' is a comment; it appears in -the menu, but is not an entry. - - Since no file name is specified with either `Files' or `Buffers', -they must be the names of nodes in the same Info file (*note Referring -to Other Info Files: Other Info Files.). - - -File: texi.info, Node: Other Info Files, Prev: Menu Example, Up: Menus - -Referring to Other Info Files -============================= - - You can create a menu entry that enables a reader in Info to go to a -node in another Info file by writing the file name in parentheses just -before the node name. In this case, you should use the three-part menu -entry format, which saves the reader from having to type the file name. - - The format looks like this: - - @menu - * FIRST-ENTRY-NAME:(FILENAME)NODENAME. DESCRIPTION - * SECOND-ENTRY-NAME:(FILENAME)SECOND-NODE. DESCRIPTION - @end menu - - For example, to refer directly to the `Outlining' and `Rebinding' -nodes in the `Emacs Manual', you would write a menu like this: - - @menu - * Outlining: (emacs)Outline Mode. The major mode for - editing outlines. - * Rebinding: (emacs)Rebinding. How to redefine the - meaning of a key. - @end menu - - If you do not list the node name, but only name the file, then Info -presumes that you are referring to the `Top' node. - - The `dir' file that contains the main menu for Info has menu entries -that list only file names. These take you directly to the `Top' nodes -of each Info document. (*Note Install an Info File::.) - - For example: - - * Info: (info). Documentation browsing system. - * Emacs: (emacs). The extensible, self-documenting - text editor. - -(The `dir' top level directory for the Info system is an Info file, not -a Texinfo file, but a menu entry looks the same in both types of file.) - - Note that the GNU Emacs Texinfo mode menu updating commands only work -with nodes within the current buffer, so you cannot use them to create -menus that refer to other files. You must write such menus by hand. - - -File: texi.info, Node: Cross References, Next: Marking Text, Prev: Menus, Up: Top - -Cross References -**************** - - "Cross references" are used to refer the reader to other parts of the -same or different Texinfo files. In Texinfo, nodes are the places to -which cross references can refer. - -* Menu: - -* References:: What cross references are for. -* Cross Reference Commands:: A summary of the different commands. -* Cross Reference Parts:: A cross reference has several parts. -* xref:: Begin a reference with `See' ... -* Top Node Naming:: How to refer to the beginning of another file. -* ref:: A reference for the last part of a sentence. -* pxref:: How to write a parenthetical cross reference. -* inforef:: How to refer to an Info-only file. - - -File: texi.info, Node: References, Next: Cross Reference Commands, Up: Cross References - -What References Are For -======================= - - Often, but not always, a printed document should be designed so that -it can be read sequentially. People tire of flipping back and forth to -find information that should be presented to them as they need it. - - However, in any document, some information will be too detailed for -the current context, or incidental to it; use cross references to -provide access to such information. Also, an on-line help system or a -reference manual is not like a novel; few read such documents in -sequence from beginning to end. Instead, people look up what they -need. For this reason, such creations should contain many cross -references to help readers find other information that they may not -have read. - - In a printed manual, a cross reference results in a page reference, -unless it is to another manual altogether, in which case the cross -reference names that manual. - - In Info, a cross reference results in an entry that you can follow -using the Info `f' command. (*note Some advanced Info commands: -(info)Help-Adv.) - - The various cross reference commands use nodes to define cross -reference locations. This is evident in Info, in which a cross -reference takes you to the specified node. TeX also uses nodes to -define cross reference locations, but the action is less obvious. When -TeX generates a DVI file, it records nodes' page numbers and uses the -page numbers in making references. Thus, if you are writing a manual -that will only be printed, and will not be used on-line, you must -nonetheless write `@node' lines to name the places to which you make -cross references. - - -File: texi.info, Node: Cross Reference Commands, Next: Cross Reference Parts, Prev: References, Up: Cross References - -Different Cross Reference Commands -================================== - - There are four different cross reference commands: - -`@xref' - Used to start a sentence in the printed manual saying `See ...' or - an entry in the Info file saying `*Note ...'. - -`@ref' - Used within or, more often, at the end of a sentence; same as - `@xref' for Info; produces just the reference in the printed - manual without a preceding `See'. - -`@pxref' - Used within parentheses to make a reference that suits both an Info - file and a printed book. Starts with a lower case `see' within the - printed manual. (`p' is for `parenthesis'.) - -`@inforef' - Used to make a reference to an Info file for which there is no - printed manual. - -(The `@cite' command is used to make references to books and manuals -for which there is no corresponding Info file and, therefore, no node -to which to point. *Note `@cite': cite.) - - -File: texi.info, Node: Cross Reference Parts, Next: xref, Prev: Cross Reference Commands, Up: Cross References - -Parts of a Cross Reference -========================== - - A cross reference command requires only one argument, which is the -name of the node to which it refers. But a cross reference command may -contain up to four additional arguments. By using these arguments, you -can provide a cross reference name for Info, a topic description or -section title for the printed output, the name of a different Info -file, and the name of a different printed manual. - - Here is a simple cross reference example: - - @xref{Node name}. - -which produces - - *Note Node name::. - -and - - See Section NNN [Node name], page PPP. - - Here is an example of a full five-part cross reference: - - @xref{Node name, Cross Reference Name, Particular Topic, - info-file-name, A Printed Manual}, for details. - -which produces - - *Note Cross Reference Name: (info-file-name)Node name, - for details. - -in Info and - - See section "Particular Topic" in A Printed Manual, for details. - -in a printed book. - - The five possible arguments for a cross reference are: - - 1. The node name (required). This is the node to which the cross - reference takes you. In a printed document, the location of the - node provides the page reference only for references within the - same document. - - 2. The cross reference name for the Info reference, if it is to be - different from the node name. If you include this argument, it - argument becomes the first part of the cross reference. It is - usually omitted. - - 3. A topic description or section name. Often, this is the title of - the section. This is used as the name of the reference in the - printed manual. If omitted, the node name is used. - - 4. The name of the Info file in which the reference is located, if it - is different from the current file. - - 5. The name of a printed manual from a different Texinfo file. - - The template for a full five argument cross reference looks like -this: - - @xref{NODE-NAME, CROSS-REFERENCE-NAME, TITLE-OR-TOPIC, - INFO-FILE-NAME, PRINTED-MANUAL-TITLE}. - - Cross references with one, two, three, four, and five arguments are -described separately following the description of `@xref'. - - Write a node name in a cross reference in exactly the same way as in -the `@node' line, including the same capitalization; otherwise, the -formatters may not find the reference. - - You can write cross reference commands within a paragraph, but note -how Info and TeX format the output of each of the various commands: -write `@xref' at the beginning of a sentence; write `@pxref' only -within parentheses, and so on. - - -File: texi.info, Node: xref, Next: Top Node Naming, Prev: Cross Reference Parts, Up: Cross References - -`@xref' -======= - - The `@xref' command generates a cross reference for the beginning of -a sentence. The Info formatting commands convert it into an Info cross -reference, which the Info `f' command can use to bring you directly to -another node. The TeX typesetting commands convert it into a page -reference, or a reference to another book or manual. - -* Menu: - -* Reference Syntax:: What a reference looks like and requires. -* One Argument:: `@xref' with one argument. -* Two Arguments:: `@xref' with two arguments. -* Three Arguments:: `@xref' with three arguments. -* Four and Five Arguments:: `@xref' with four and five arguments. - - -File: texi.info, Node: Reference Syntax, Next: One Argument, Up: xref - -What a Reference Looks Like and Requires ----------------------------------------- - - Most often, an Info cross reference looks like this: - - *Note NODE-NAME::. - -or like this - - *Note CROSS-REFERENCE-NAME: NODE-NAME. - -In TeX, a cross reference looks like this: - - See Section SECTION-NUMBER [NODE-NAME], page PAGE. - -or like this - - See Section SECTION-NUMBER [TITLE-OR-TOPIC], page PAGE. - - The `@xref' command does not generate a period or comma to end the -cross reference in either the Info file or the printed output. You -must write that period or comma yourself; otherwise, Info will not -recognize the end of the reference. (The `@pxref' command works -differently. *Note `@pxref': pxref.) - - *Please note:* A period or comma *must* follow the closing brace - of an `@xref'. It is required to terminate the cross reference. - This period or comma will appear in the output, both in the Info - file and in the printed manual. - - `@xref' must refer to an Info node by name. Use `@node' to define -the node (*note Writing a Node::.). - - `@xref' is followed by several arguments inside braces, separated by -commas. Whitespace before and after these commas is ignored. - - A cross reference requires only the name of a node; but it may -contain up to four additional arguments. Each of these variations -produces a cross reference that looks somewhat different. - - *Please note:* Commas separate arguments in a cross reference; - avoid including them in the title or other part lest the formatters - mistake them for separators. - - -File: texi.info, Node: One Argument, Next: Two Arguments, Prev: Reference Syntax, Up: xref - -`@xref' with One Argument -------------------------- - - The simplest form of `@xref' takes one argument, the name of another -node in the same Info file. The Info formatters produce output that -the Info readers can use to jump to the reference; TeX produces output -that specifies the page and section number for you. - -For example, - - @xref{Tropical Storms}. - -produces - - *Note Tropical Storms::. - -and - - See Section 3.1 [Tropical Storms], page 24. - -(Note that in the preceding example the closing brace is followed by a -period.) - - You can write a clause after the cross reference, like this: - - @xref{Tropical Storms}, for more info. - -which produces - - *Note Tropical Storms::, for more info. - - See Section 3.1 [Tropical Storms], page 24, for more info. - -(Note that in the preceding example the closing brace is followed by a -comma, and then by the clause, which is followed by a period.) - - -File: texi.info, Node: Two Arguments, Next: Three Arguments, Prev: One Argument, Up: xref - -`@xref' with Two Arguments --------------------------- - - With two arguments, the second is used as the name of the Info cross -reference, while the first is still the name of the node to which the -cross reference points. - -The template is like this: - - @xref{NODE-NAME, CROSS-REFERENCE-NAME}. - -For example, - - @xref{Electrical Effects, Lightning}. - -produces: - - *Note Lightning: Electrical Effects. - -and - - See Section 5.2 [Electrical Effects], page 57. - -(Note that in the preceding example the closing brace is followed by a -period; and that the node name is printed, not the cross reference -name.) - - You can write a clause after the cross reference, like this: - - @xref{Electrical Effects, Lightning}, for more info. - -which produces - *Note Lightning: Electrical Effects, for more info. - -and - - See Section 5.2 [Electrical Effects], page 57, for more info. - -(Note that in the preceding example the closing brace is followed by a -comma, and then by the clause, which is followed by a period.) - - -File: texi.info, Node: Three Arguments, Next: Four and Five Arguments, Prev: Two Arguments, Up: xref - -`@xref' with Three Arguments ----------------------------- - - A third argument replaces the node name in the TeX output. The third -argument should be the name of the section in the printed output, or -else state the topic discussed by that section. Often, you will want to -use initial upper case letters so it will be easier to read when the -reference is printed. Use a third argument when the node name is -unsuitable because of syntax or meaning. - - Remember to avoid placing a comma within the title or topic section -of a cross reference, or within any other section. The formatters -divide cross references into arguments according to the commas; a comma -within a title or other section will divide it into two arguments. In -a reference, you need to write a title such as "Clouds, Mist, and Fog" -without the commas. - - Also, remember to write a comma or period after the closing brace of -a `@xref' to terminate the cross reference. In the following examples, -a clause follows a terminating comma. - -The template is like this: - - @xref{NODE-NAME, CROSS-REFERENCE-NAME, TITLE-OR-TOPIC}. - -For example, - - @xref{Electrical Effects, Lightning, Thunder and Lightning}, - for details. - -produces - - *Note Lightning: Electrical Effects, for details. - -and - - See Section 5.2 [Thunder and Lightning], page 57, for details. - - If a third argument is given and the second one is empty, then the -third argument serves both. (Note how two commas, side by side, mark -the empty second argument.) - - @xref{Electrical Effects, , Thunder and Lightning}, - for details. - -produces - - *Note Thunder and Lightning: Electrical Effects, for details. - -and - - See Section 5.2 [Thunder and Lightning], page 57, for details. - - As a practical matter, it is often best to write cross references -with just the first argument if the node name and the section title are -the same, and with the first and third arguments if the node name and -title are different. - - Here are several examples from `The GAWK Manual': - - @xref{Sample Program}. - @xref{Glossary}. - @xref{Case-sensitivity, ,Case-sensitivity in Matching}. - @xref{Close Output, , Closing Output Files and Pipes}, - for more information. - @xref{Regexp, , Regular Expressions as Patterns}. - - -File: texi.info, Node: Four and Five Arguments, Prev: Three Arguments, Up: xref - -`@xref' with Four and Five Arguments ------------------------------------- - - In a cross reference, a fourth argument specifies the name of another -Info file, different from the file in which the reference appears, and -a fifth argument specifies its title as a printed manual. - - Remember that a comma or period must follow the closing brace of an -`@xref' command to terminate the cross reference. In the following -examples, a clause follows a terminating comma. - -The template is: - - @xref{NODE-NAME, CROSS-REFERENCE-NAME, TITLE-OR-TOPIC, - INFO-FILE-NAME, PRINTED-MANUAL-TITLE}. - -For example, - - @xref{Electrical Effects, Lightning, Thunder and Lightning, - weather, An Introduction to Meteorology}, for details. - -produces - - *Note Lightning: (weather)Electrical Effects, for details. - -The name of the Info file is enclosed in parentheses and precedes the -name of the node. - -In a printed manual, the reference looks like this: - - See section "Thunder and Lightning" in An Introduction to - Meteorology, for details. - -The title of the printed manual is typeset in italics; and the -reference lacks a page number since TeX cannot know to which page a -reference refers when that reference is to another manual. - - Often, you will leave out the second argument when you use the long -version of `@xref'. In this case, the third argument, the topic -description, will be used as the cross reference name in Info. - -The template looks like this: - - @xref{NODE-NAME, , TITLE-OR-TOPIC, INFO-FILE-NAME, - PRINTED-MANUAL-TITLE}, for details. - -which produces - - *Note TITLE-OR-TOPIC: (INFO-FILE-NAME)NODE-NAME, for details. - -and - - See section TITLE-OR-TOPIC in PRINTED-MANUAL-TITLE, for details. - -For example, - - @xref{Electrical Effects, , Thunder and Lightning, - weather, An Introduction to Meteorology}, for details. - -produces - - *Note Thunder and Lightning: (weather)Electrical Effects, - for details. - -and - - See section "Thunder and Lightning" in An Introduction to - Meteorology, for details. - - On rare occasions, you may want to refer to another Info file that -is within a single printed manual--when multiple Texinfo files are -incorporated into the same TeX run but make separate Info files. In -this case, you need to specify only the fourth argument, and not the -fifth. - - -File: texi.info, Node: Top Node Naming, Next: ref, Prev: xref, Up: Cross References - -Naming a `Top' Node -=================== - - In a cross reference, you must always name a node. This means that -in order to refer to a whole manual, you must identify the `Top' node by -writing it as the first argument to the `@xref' command. (This is -different from the way you write a menu entry; see *Note Referring to -Other Info Files: Other Info Files.) At the same time, to provide a -meaningful section topic or title in the printed cross reference -(instead of the word `Top'), you must write an appropriate entry for -the third argument to the `@xref' command. - -Thus, to make a cross reference to `The GNU Make Manual', write: - - @xref{Top, , Overview, make, The GNU Make Manual}. - -which produces - - *Note Overview: (make)Top. - -and - - See section "Overview" in The GNU Make Manual. - -In this example, `Top' is the name of the first node, and `Overview' is -the name of the first section of the manual. - - -File: texi.info, Node: ref, Next: pxref, Prev: Top Node Naming, Up: Cross References - -`@ref' -====== - - `@ref' is nearly the same as `@xref' except that it does not -generate a `See' in the printed output, just the reference itself. -This makes it useful as the last part of a sentence. - -For example, - - For more information, see @ref{Hurricanes}. - -produces - - For more information, see *Note Hurricanes. - -and - - For more information, see Section 8.2 [Hurricanes], page 123. - - The `@ref' command sometimes leads writers to express themselves in -a manner that is suitable for a printed manual but looks awkward in the -Info format. Bear in mind that your audience will be using both the -printed and the Info format. - -For example, - - Sea surges are described in @ref{Hurricanes}. - -produces - - Sea surges are described in Section 6.7 [Hurricanes], page 72. - -in a printed document, and the following in Info: - - Sea surges are described in *Note Hurricanes::. - - *Caution:* You *must* write a period or comma immediately after an - `@ref' command with two or more arguments. Otherwise, Info will - not find the end of the cross reference entry and its attempt to - follow the cross reference will fail. As a general rule, you - should write a period or comma after every `@ref' command. This - looks best in both the printed and the Info output. - - -File: texi.info, Node: pxref, Next: inforef, Prev: ref, Up: Cross References - -`@pxref' -======== - - The parenthetical reference command, `@pxref', is nearly the same as -`@xref', but you use it *only* inside parentheses and you do *not* type -a comma or period after the command's closing brace. The command -differs from `@xref' in two ways: - - 1. TeX typesets the reference for the printed manual with a lower case - `see' rather than an upper case `See'. - - 2. The Info formatting commands automatically end the reference with a - closing colon or period. - - Because one type of formatting automatically inserts closing -punctuation and the other does not, you should use `@pxref' *only* -inside parentheses as part of another sentence. Also, you yourself -should not insert punctuation after the reference, as you do with -`@xref'. - - `@pxref' is designed so that the output looks right and works right -between parentheses both in printed output and in an Info file. In a -printed manual, a closing comma or period should not follow a cross -reference within parentheses; such punctuation is wrong. But in an -Info file, suitable closing punctuation must follow the cross reference -so Info can recognize its end. `@pxref' spares you the need to use -complicated methods to put a terminator into one form of the output and -not the other. - -With one argument, a parenthetical cross reference looks like this: - - ... storms cause flooding (@pxref{Hurricanes}) ... - -which produces - - ... storms cause flooding (*Note Hurricanes::) ... - -and - - ... storms cause flooding (see Section 6.7 [Hurricanes], page 72) - ... - - With two arguments, a parenthetical cross reference has this -template: - - ... (@pxref{NODE-NAME, CROSS-REFERENCE-NAME}) ... - -which produces - - ... (*Note CROSS-REFERENCE-NAME: NODE-NAME.) ... - -and - - ... (see Section NNN [NODE-NAME], page PPP) ... - - `@pxref' can be used with up to five arguments just like `@xref' -(*note `@xref': xref.). - - *Please note:* Use `@pxref' only as a parenthetical reference. Do - not try to use `@pxref' as a clause in a sentence. It will look - bad in either the Info file, the printed output, or both. - - Also, parenthetical cross references look best at the ends of - sentences. Although you may write them in the middle of a - sentence, that location breaks up the flow of text. - - -File: texi.info, Node: inforef, Prev: pxref, Up: Cross References - -`@inforef' -========== - - `@inforef' is used for cross references to Info files for which -there are no printed manuals. Even in a printed manual, `@inforef' -generates a reference directing the user to look in an Info file. - - The command takes either two or three arguments, in the following -order: - - 1. The node name. - - 2. The cross reference name (optional). - - 3. The Info file name. - -Separate the arguments with commas, as with `@xref'. Also, you must -terminate the reference with a comma or period after the `}', as you do -with `@xref'. - -The template is: - - @inforef{NODE-NAME, CROSS-REFERENCE-NAME, INFO-FILE-NAME}, - -Thus, - - @inforef{Expert, Advanced Info commands, info}, - for more information. - -produces - - *Note Advanced Info commands: (info)Expert, - for more information. - -and - - See Info file `info', node `Expert', for more information. - -Similarly, - - @inforef{Expert, , info}, for more information. - -produces - - *Note (info)Expert::, for more information. - -and - - See Info file `info', node `Expert', for more information. - - The converse of `@inforef' is `@cite', which is used to refer to -printed works for which no Info form exists. *Note `@cite': cite. - - -File: texi.info, Node: Marking Text, Next: Quotations and Examples, Prev: Cross References, Up: Top - -Marking Words and Phrases -************************* - - In Texinfo, you can mark words and phrases in a variety of ways. -The Texinfo formatters use this information to determine how to -highlight the text. You can specify, for example, whether a word or -phrase is a defining occurrence, a metasyntactic variable, or a symbol -used in a program. Also, you can emphasize text. - -* Menu: - -* Indicating:: How to indicate definitions, files, etc. -* Emphasis:: How to emphasize text. - - -File: texi.info, Node: Indicating, Next: Emphasis, Up: Marking Text - -Indicating Definitions, Commands, etc. -====================================== - - Texinfo has commands for indicating just what kind of object a piece -of text refers to. For example, metasyntactic variables are marked by -`@var', and code by `@code'. Since the pieces of text are labelled by -commands that tell what kind of object they are, it is easy to change -the way the Texinfo formatters prepare such text. (Texinfo is an -*intentional* formatting language rather than a *typesetting* -formatting language.) - - For example, in a printed manual, code is usually illustrated in a -typewriter font; `@code' tells TeX to typeset this text in this font. -But it would be easy to change the way TeX highlights code to use -another font, and this change would not effect how keystroke examples -are highlighted. If straight typesetting commands were used in the body -of the file and you wanted to make a change, you would need to check -every single occurrence to make sure that you were changing code and -not something else that should not be changed. - -* Menu: - -* Useful Highlighting:: Highlighting provides useful information. -* code:: How to indicate code. -* kbd:: How to show keyboard input. -* key:: How to specify keys. -* samp:: How to show a literal sequence of characters. -* var:: How to indicate a metasyntactic variable. -* file:: How to indicate the name of a file. -* dfn:: How to specify a definition. -* cite:: How to refer to a book that is not in Info. - - -File: texi.info, Node: Useful Highlighting, Next: code, Up: Indicating - -Highlighting Commands are Useful --------------------------------- - - The highlighting commands can be used to generate useful information -from the file, such as lists of functions or file names. It is -possible, for example, to write a program in Emacs Lisp (or a keyboard -macro) to insert an index entry after every paragraph that contains -words or phrases marked by a specified command. You could do this to -construct an index of functions if you had not already made the entries. - - The commands serve a variety of purposes: - -`@code{SAMPLE-CODE}' - Indicate text that is a literal example of a piece of a program. - -`@kbd{KEYBOARD-CHARACTERS}' - Indicate keyboard input. - -`@key{KEY-NAME}' - Indicate the conventional name for a key on a keyboard. - -`@samp{TEXT}' - Indicate text that is a literal example of a sequence of - characters. - -`@var{METASYNTACTIC-VARIABLE}' - Indicate a metasyntactic variable. - -`@file{FILE-NAME}' - Indicate the name of a file. - -`@dfn{TERM}' - Indicate the introductory or defining use of a term. - -`@cite{REFERENCE}' - Indicate the name of a book. - - -File: texi.info, Node: code, Next: kbd, Prev: Useful Highlighting, Up: Indicating - -`@code'{SAMPLE-CODE} --------------------- - - Use the `@code' command to indicate text that is a piece of a -program and which consists of entire syntactic tokens. Enclose the -text in braces. - - Thus, you should use `@code' for an expression in a program, for the -name of a variable or function used in a program, or for a keyword. -Also, you should use `@code' for the name of a program, such as `diff', -that is a name used in the machine. (You should write the name of a -program in the ordinary text font if you regard it as a new English -word, such as `Emacs' or `Bison'.) - - Use `@code' for environment variables such as `TEXINPUTS', and other -variables. - - Use `@code' for command names in command languages that resemble -programming languages, such as Texinfo or the shell. For example, -`@code' and `@samp' are produced by writing `@code{@@code}' and -`@code{@@samp}' in the Texinfo source, respectively. - - Note, however, that you should not use `@code' for shell options -such as `-c' when such options stand alone. (Use `@samp'.) Also, an -entire shell command often looks better if written using `@samp' rather -than `@code'. In this case, the rule is to choose the more pleasing -format. - - It is incorrect to alter the case of a word inside an `@code' -command when it appears at the beginning of a sentence. Most computer -languages are case sensitive. In C, for example, `Printf' is different -from the identifier `printf', and most likely is a misspelling of it. -Even in languages which are not case sensitive, it is confusing to a -human reader to see identifiers spelled in different ways. Pick one -spelling and always use that. If you do not want to start a sentence -with a command written all in lower case, you should rearrange the -sentence. - - Do not use the `@code' command for a string of characters shorter -than a syntactic token. If you are writing about `TEXINPU', which is -just a part of the name for the `TEXINPUTS' environment variable, you -should use `@samp'. - - In particular, you should not use the `@code' command when writing -about the characters used in a token; do not, for example, use `@code' -when you are explaining what letters or printable symbols can be used -in the names of functions. (Use `@samp'.) Also, you should not use -`@code' to mark text that is considered input to programs unless the -input is written in a language that is like a programming language. -For example, you should not use `@code' for the keystroke commands of -GNU Emacs (use `@kbd' instead) although you may use `@code' for the -names of the Emacs Lisp functions that the keystroke commands invoke. - - In the printed manual, `@code' causes TeX to typeset the argument in -a typewriter face. In the Info file, it causes the Info formatting -commands to use single quotation marks around the text. - - For example, - - Use @code{diff} to compare two files. - -produces this in the printed manual: - - Use `diff' to compare two files. - - -File: texi.info, Node: kbd, Next: key, Prev: code, Up: Indicating - -`@kbd'{KEYBOARD-CHARACTERS} ---------------------------- - - Use the `@kbd' command for characters of input to be typed by users. -For example, to refer to the characters `M-a', write - - @kbd{M-a} - -and to refer to the characters `M-x shell', write - - @kbd{M-x shell} - - The `@kbd' command has the same effect as `@code' in Info, but may -produce a different font in a printed manual. - - You can embed another @-command inside the braces of an `@kbd' -command. Here, for example, is the way to describe a command that -would be described more verbosely as "press an `r' and then press the -RET key": - - @kbd{r @key{RET}} - -This produces: `r RET' - - You also use the `@kbd' command if you are spelling out the letters -you type; for example: - - To give the @code{logout} command, - type the characters @kbd{l o g o u t @key{RET}}. - -This produces: - - To give the `logout' command, type the characters `l o g o u t - RET'. - - (Also, this example shows that you can add spaces for clarity. If -you really want to mention a space character as one of the characters of -input, write `@key{SPC}' for it.) - - -File: texi.info, Node: key, Next: samp, Prev: kbd, Up: Indicating - -`@key'{KEY-NAME} ----------------- - - Use the `@key' command for the conventional name for a key on a -keyboard, as in: - - @key{RET} - - You can use the `@key' command within the argument of an `@kbd' -command when the sequence of characters to be typed includes one or -more keys that are described by name. - - For example, to produce `C-x ESC' you would type: - - @kbd{C-x @key{ESC}} - - Here is a list of the recommended names for keys; they are all in -upper case: - - SPC - Space - - RET - Return - - LFD - Linefeed - - TAB - Tab - - BS - Backspace - - ESC - Escape - - DEL - Delete - - SFT - Shift - - CTL - Control - - META - Meta - - There are subtleties to handling words like `meta' or `ctl' that are -names of shift keys. When mentioning a character in which the shift -key is used, such as `Meta-a', use the `@kbd' command alone; do not use -the `@key' command; but when you are referring to the shift key in -isolation, use the `@key' command. For example, write `@kbd{Meta-a}' -to produce `Meta-a' and `@key{META}' to produce META. This is because -`Meta-a' refers to keys that you press on a keyboard, but META refers -to a key without implying that you press it. In short, use `@kbd' for -what you do, and use `@key' for what you talk about: "Press `@kbd{M-a}' -to move point to the beginning of the sentence. The `@key{META}' key -is often in the lower left of the keyboard." - - -File: texi.info, Node: samp, Next: var, Prev: key, Up: Indicating - -`@samp'{TEXT} -------------- - - Use the `@samp' command to indicate text that is a literal example -or `sample' of a sequence of characters in a file, string, pattern, etc. -Enclose the text in braces. The argument appears within single -quotation marks in both the Info file and the printed manual; in -addition, it is printed in a fixed-width font. - - To match @samp{foo} at the end of the line, - use the regexp @samp{foo$}. - -produces - - To match `foo' at the end of the line, use the regexp `foo$'. - - Any time you are referring to single characters, you should use -`@samp' unless `@kbd' is more appropriate. Use `@samp' for the names -of command-line options. Also, you may use `@samp' for entire -statements in C and for entire shell commands--in this case, `@samp' -often looks better than `@code'. Basically, `@samp' is a catchall for -whatever is not covered by `@code', `@kbd', or `@key'. - - Only include punctuation marks within braces if they are part of the -string you are specifying. Write punctuation marks outside the braces -if those punctuation marks are part of the English text that surrounds -the string. In the following sentence, for example, the commas and -period are outside of the braces: - - In English, the vowels are @samp{a}, @samp{e}, - @samp{i}, @samp{o}, @samp{u}, and sometimes - @samp{y}. - -This produces: - - In English, the vowels are `a', `e', `i', `o', `u', and sometimes - `y'. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-5 b/gnu/usr.bin/texinfo/info-files/texi.info-5 deleted file mode 100644 index 84b7295f0194..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-5 +++ /dev/null @@ -1,1433 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: var, Next: file, Prev: samp, Up: Indicating - -`@var'{METASYNTACTIC-VARIABLE} ------------------------------- - - Use the `@var' command to indicate metasyntactic variables. A -"metasyntactic variable" is something that stands for another piece of -text. For example, you should use a metasyntactic variable in the -documentation of a function to describe the arguments that are passed -to that function. - - Do not use `@var' for the names of particular variables in -programming languages. These are specific names from a program, so -`@code' is correct for them. For example, the Lisp variable -`texinfo-tex-command' is not a metasyntactic variable; it is properly -formatted using `@code'. - - The effect of `@var' in the Info file is to change the case of the -argument to all upper case; in the printed manual, to italicize it. - - For example, - - To delete file @var{filename}, - type @code{rm @var{filename}}. - -produces - - To delete file FILENAME, type `rm FILENAME'. - -(Note that `@var' may appear inside `@code', `@samp', `@file', etc.) - - Write a metasyntactic variable all in lower case without spaces, and -use hyphens to make it more readable. Thus, the Texinfo source for the -illustration of how to begin a Texinfo manual looks like this: - - \input texinfo - @@setfilename @var{info-file-name} - @@settitle @var{name-of-manual} - -This produces: - - \input texinfo - @setfilename INFO-FILE-NAME - @settitle NAME-OF-MANUAL - - In some documentation styles, metasyntactic variables are shown with -angle brackets, for example: - - ..., type rm - -However, that is not the style that Texinfo uses. (You can, of course, -modify the sources to TeX and the Info formatting commands to output -the `<...>' format if you wish.) - - -File: texi.info, Node: file, Next: dfn, Prev: var, Up: Indicating - -`@file'{FILE-NAME} ------------------- - - Use the `@file' command to indicate text that is the name of a file, -buffer, or directory, or is the name of a node in Info. You can also -use the command for file name suffixes. Do not use `@file' for symbols -in a programming language; use `@code'. - - Currently, `@file' is equivalent to `@samp' in its effects. For -example, - - The @file{.el} files are in - the @file{/usr/local/emacs/lisp} directory. - -produces - - The `.el' files are in the `/usr/local/emacs/lisp' directory. - - -File: texi.info, Node: dfn, Next: cite, Prev: file, Up: Indicating - -`@dfn'{TERM} ------------- - - Use the `@dfn' command to identify the introductory or defining use -of a technical term. Use the command only in passages whose purpose is -to introduce a term which will be used again or which the reader ought -to know. Mere passing mention of a term for the first time does not -deserve `@dfn'. The command generates italics in the printed manual, -and double quotation marks in the Info file. For example: - - Getting rid of a file is called @dfn{deleting} it. - -produces - - Getting rid of a file is called "deleting" it. - - As a general rule, a sentence containing the defining occurrence of a -term should be a definition of the term. The sentence does not need to -say explicitly that it is a definition, but it should contain the -information of a definition--it should make the meaning clear. - - -File: texi.info, Node: cite, Prev: dfn, Up: Indicating - -`@cite'{REFERENCE} ------------------- - - Use the `@cite' command for the name of a book that lacks a -companion Info file. The command produces italics in the printed -manual, and quotation marks in the Info file. - - (If a book is written in Texinfo, it is better to use a cross -reference command since a reader can easily follow such a reference in -Info. *Note `@xref': xref.) - - -File: texi.info, Node: Emphasis, Prev: Indicating, Up: Marking Text - -Emphasizing Text -================ - - Usually, Texinfo changes the font to mark words in the text -according to what category the words belong to; an example is the -`@code' command. Most often, this is the best way to mark words. -However, sometimes you will want to emphasize text without indicating a -category. Texinfo has two commands to do this. Also, Texinfo has -several commands that specify the font in which TeX will typeset text. -These commands have no affect on Info and only one of them, the `@r' -command, has any regular use. - -* Menu: - -* emph & strong:: How to emphasize text in Texinfo. -* Smallcaps:: How to use the small caps font. -* Fonts:: Various font commands for printed output. - - -File: texi.info, Node: emph & strong, Next: Smallcaps, Up: Emphasis - -`@emph'{TEXT} and `@strong'{TEXT} ---------------------------------- - - The `@emph' and `@strong' commands are for emphasis; `@strong' is -stronger. In printed output, `@emph' produces *italics* and `@strong' -produces *bold*. - - For example, - - @quotation - @strong{Caution:} @code{rm * .[^.]*} removes @emph{all} - files in the directory. - @end quotation - -produces: - - *Caution*: `rm * .[^.]*' removes *all* - files in the directory. - - The `@strong' command is seldom used except to mark what is, in -effect, a typographical element, such as the word `Caution' in the -preceding example. - - In the Info file, both `@emph' and `@strong' put asterisks around -the text. - - *Caution:* Do not use `@emph' or `@strong' with the word `Note'; - Info will mistake the combination for a cross reference. Use a - phrase such as *Please note* or *Caution* instead. - - -File: texi.info, Node: Smallcaps, Next: Fonts, Prev: emph & strong, Up: Emphasis - -`@sc'{TEXT}: The Small Caps Font --------------------------------- - - Use the `@sc' command to set text in the printed output in a small -caps font and set text in the Info file in upper case letters. - - Write the text between braces in lower case, like this: - - The @sc{acm} and @sc{ieee} are technical societies. - -This produces: - - The ACM and IEEE are technical societies. - - TeX typesets the small caps font in a manner that prevents the -letters from `jumping out at you on the page'. This makes small caps -text easier to read than text in all upper case. The Info formatting -commands set all small caps text in upper case. - - If the text between the braces of an `@sc' command is upper case, -TeX typesets in full-size capitals. Use full-size capitals sparingly. - - You may also use the small caps font for a jargon word such as ATO -(a NASA word meaning `abort to orbit'). - - There are subtleties to using the small caps font with a jargon word -such as CDR, a word used in Lisp programming. In this case, you should -use the small caps font when the word refers to the second and -subsequent elements of a list (the CDR of the list), but you should use -`@code' when the word refers to the Lisp function of the same spelling. - - -File: texi.info, Node: Fonts, Prev: Smallcaps, Up: Emphasis - -Fonts for Printing, Not Info ----------------------------- - - Texinfo provides four font commands that specify font changes in the -printed manual but have no effect in the Info file. `@i' requests -italic font (in some versions of TeX, a slanted font is used), `@b' -requests bold face, `@t' requests the fixed-width, typewriter-style -font used by `@code', and `@r' requests a roman font, which is the -usual font in which text is printed. All four commands apply to an -argument that follows, surrounded by braces. - - Only the `@r' command has much use: in example programs, you can use -the `@r' command to convert code comments from the fixed-width font to -a roman font. This looks better in printed output. - - For example, - - @lisp - (+ 2 2) ; @r{Add two plus two.} - @end lisp - -produces - - (+ 2 2) ; Add two plus two. - - If possible, you should avoid using the other three font commands. -If you need to use one, it probably indicates a gap in the Texinfo -language. - - -File: texi.info, Node: Quotations and Examples, Next: Lists and Tables, Prev: Marking Text, Up: Top - -Quotations and Examples -*********************** - - Quotations and examples are blocks of text consisting of one or more -whole paragraphs that are set off from the bulk of the text and treated -differently. They are usually indented. - - In Texinfo, you always begin a quotation or example by writing an -@-command at the beginning of a line by itself, and end it by writing -an `@end' command that is also at the beginning of a line by itself. -For instance, you begin an example by writing `@example' by itself at -the beginning of a line and end the example by writing `@end example' -on a line by itself, at the beginning of that line. - -* Menu: - -* Block Enclosing Commands:: Use different constructs for - different purposes. -* quotation:: How to write a quotation. -* example:: How to write an example in a fixed-width font. -* noindent:: How to prevent paragraph indentation. -* Lisp Example:: How to illustrate Lisp code. -* smallexample & smalllisp:: Forms for the `@smallbook' option. -* display:: How to write an example in the current font. -* format:: How to write an example that does not narrow - the margins. -* exdent:: How to undo the indentation of a line. -* flushleft & flushright:: How to push text flushleft or flushright. -* cartouche:: How to draw cartouches around examples. - - -File: texi.info, Node: Block Enclosing Commands, Next: quotation, Up: Quotations and Examples - -The Block Enclosing Commands -============================ - - Here are commands for quotations and examples: - -`@quotation' - Indicate text that is quoted. The text is filled, indented, and - printed in a roman font by default. - -`@example' - Illustrate code, commands, and the like. The text is printed in a - fixed-width font, and indented but not filled. - -`@lisp' - Illustrate Lisp code. The text is printed in a fixed-width font, - and indented but not filled. - -`@smallexample' - Illustrate code, commands, and the like. Similar to `@example', - except that in TeX this command typesets text in a smaller font - for the smaller `@smallbook' format than for the 8.5 by 11 inch - format. - -`@smalllisp' - Illustrate Lisp code. Similar to `@lisp', except that in TeX this - command typesets text in a smaller font for the smaller - `@smallbook' format than for the 8.5 by 11 inch format. - -`@display' - Display illustrative text. The text is indented but not filled, - and no font is specified (so, by default, the font is roman). - -`@format' - Print illustrative text. The text is not indented and not filled - and no font is specified (so, by default, the font is roman). - - The `@exdent' command is used within the above constructs to undo -the indentation of a line. - - The `@flushleft' and `@flushright' commands are used to line up the -left or right margins of unfilled text. - - The `@noindent' command may be used after one of the above -constructs to prevent the following text from being indented as a new -paragraph. - - You can use the `@cartouche' command within one of the above -constructs to highlight the example or quotation by drawing a box with -rounded corners around it. (The `@cartouche' command affects only the -printed manual; it has no effect in the Info file; see *Note Drawing -Cartouches Around Examples: cartouche.) - - -File: texi.info, Node: quotation, Next: example, Prev: Block Enclosing Commands, Up: Quotations and Examples - -`@quotation' -============ - - The text of a quotation is processed normally except that: - - * the margins are closer to the center of the page, so the whole of - the quotation is indented; - - * the first lines of paragraphs are indented no more than other - lines; - - * in the printed output, interparagraph spacing is reduced. - - This is an example of text written between an `@quotation' command - and an `@end quotation' command. An `@quotation' command is most - often used to indicate text that is excerpted from another (real - or hypothetical) printed work. - - Write an `@quotation' command as text on a line by itself. This -line will disappear from the output. Mark the end of the quotation -with a line beginning with and containing only `@end quotation'. The -`@end quotation' line will likewise disappear from the output. Thus, -the following, - - @quotation - This is - a foo. - @end quotation - -produces - - This is a foo. - - -File: texi.info, Node: example, Next: noindent, Prev: quotation, Up: Quotations and Examples - -`@example' -========== - - The `@example' command is used to indicate an example that is not -part of the running text, such as computer input or output. - - This is an example of text written between an - `@example' command - and an `@end example' command. - The text is indented but not filled. - - In the printed manual, the text is typeset in a - fixed-width font, and extra spaces and blank lines are - significant. In the Info file, an analogous result is - obtained by indenting each line with five spaces. - - Write an `@example' command at the beginning of a line by itself. -This line will disappear from the output. Mark the end of the example -with an `@end example' command, also written at the beginning of a line -by itself. The `@end example' will disappear from the output. - - For example, - - @example - mv foo bar - @end example - -produces - - mv foo bar - - Since the lines containing `@example' and `@end example' will -disappear, you should put a blank line before the `@example' and -another blank line after the `@end example'. (Remember that blank -lines between the beginning `@example' and the ending `@end example' -will appear in the output.) - - *Caution:* Do not use tabs in the lines of an example (or anywhere - else in Texinfo, for that matter)! TeX treats tabs as single - spaces, and that is not what they look like. This is a problem - with TeX. (If necessary, in Emacs, you can use `M-x untabify' to - convert tabs in a region to multiple spaces.) - - Examples are often, logically speaking, "in the middle" of a -paragraph, and the text continues after an example should not be -indented. The `@noindent' command prevents a piece of text from being -indented as if it were a new paragraph. (*Note noindent::.) - - (The `@code' command is used for examples of code that are embedded -within sentences, not set off from preceding and following text. *Note -`@code': code.) - - -File: texi.info, Node: noindent, Next: Lisp Example, Prev: example, Up: Quotations and Examples - -`@noindent' -=========== - - An example or other inclusion can break a paragraph into segments. -Ordinarily, the formatters indent text that follows an example as a new -paragraph. However, you can prevent this by writing `@noindent' at the -beginning of a line by itself preceding the continuation text. - - For example: - - @example - This is an example - @end example - - @noindent - This line is not indented. As you can see, the - beginning of the line is fully flush left with the line - that follows after it. (This whole example is between - @code{@@display} and @code{@@end display}.) - -produces - - This is an example - - - This line is not indented. As you can see, the - beginning of the line is fully flush left with the line - that follows after it. (This whole example is between - `@display' and `@end display'.) - - To adjust the number of blank lines properly in the Info file output, -remember that the line containing `@noindent' does not generate a blank -line, and neither does the `@end example' line. - - In the Texinfo source file for this manual, each line that says -`produces' is preceded by a line containing `@noindent'. - - Do not put braces after an `@noindent' command; they are not -necessary, since `@noindent' is a command used outside of paragraphs -(*note Command Syntax::.). - - -File: texi.info, Node: Lisp Example, Next: smallexample & smalllisp, Prev: noindent, Up: Quotations and Examples - -`@lisp' -======= - - The `@lisp' command is used for Lisp code. It is synonymous with -the `@example' command. - - This is an example of text written between an - `@lisp' command and an `@end lisp' command. - - Use `@lisp' instead of `@example' so as to preserve information -regarding the nature of the example. This is useful, for example, if -you write a function that evaluates only and all the Lisp code in a -Texinfo file. Then you can use the Texinfo file as a Lisp library.(1) - - Mark the end of `@lisp' with `@end lisp' on a line by itself. - - ---------- Footnotes ---------- - - (1) It would be straightforward to extend Texinfo to work in a -similar fashion for C, FORTRAN, or other languages. - - -File: texi.info, Node: smallexample & smalllisp, Next: display, Prev: Lisp Example, Up: Quotations and Examples - -`@smallexample' and `@smalllisp' -================================ - - In addition to the regular `@example' and `@lisp' commands, Texinfo -has two other "example-style" commands. These are the `@smallexample' -and `@smalllisp' commands. Both these commands are designed for use -with the `@smallbook' command that causes TeX to produce a printed -manual in a 7 by 9.25 inch format rather than the regular 8.5 by 11 -inch format. - - In TeX, the `@smallexample' and `@smalllisp' commands typeset text -in a smaller font for the smaller `@smallbook' format than for the 8.5 -by 11 inch format. Consequently, many examples containing long lines -fit in a narrower, `@smallbook' page without needing to be shortened. -Both commands typeset in the normal font size when you format for the -8.5 by 11 inch size; indeed, in this situation, the `@smallexample' and -`@smalllisp' commands are defined to be the `@example' and `@lisp' -commands. - - In Info, the `@smallexample' and `@smalllisp' commands are -equivalent to the `@example' and `@lisp' commands, and work exactly the -same. - - Mark the end of `@smallexample' or `@smalllisp' with `@end -smallexample' or `@end smalllisp', respectively. - - This is an example of text written between `@smallexample' and - `@end smallexample'. In Info and in an 8.5 by 11 inch manual, - this text appears in its normal size; but in a 7 by 9.25 inch manual, - this text appears in a smaller font. - - The `@smallexample' and `@smalllisp' commands make it easier to -prepare smaller format manuals without forcing you to edit examples by -hand to fit them onto narrower pages. - - As a general rule, a printed document looks better if you write all -the examples in a chapter consistently in `@example' or in -`@smallexample'. Only occasionally should you mix the two formats. - - *Note Printing "Small" Books: smallbook, for more information about -the `@smallbook' command. - - -File: texi.info, Node: display, Next: format, Prev: smallexample & smalllisp, Up: Quotations and Examples - -`@display' -========== - - The `@display' command begins a kind of example. It is like the -`@example' command except that, in a printed manual, `@display' does -not select the fixed-width font. In fact, it does not specify the font -at all, so that the text appears in the same font it would have -appeared in without the `@display' command. - - This is an example of text written between an `@display' command - and an `@end display' command. The `@display' command - indents the text, but does not fill it. - - -File: texi.info, Node: format, Next: exdent, Prev: display, Up: Quotations and Examples - -`@format' -========= - - The `@format' command is similar to `@example' except that, in the -printed manual, `@format' does not select the fixed-width font and does -not narrow the margins. - -This is an example of text written between an `@format' command -and an `@end format' command. As you can see -from this example, -the `@format' command does not fill the text. - - -File: texi.info, Node: exdent, Next: flushleft & flushright, Prev: format, Up: Quotations and Examples - -`@exdent': Undoing a Line's Indentation -======================================= - - The `@exdent' command removes any indentation a line might have. -The command is written at the beginning of a line and applies only to -the text that follows the command that is on the same line. Do not use -braces around the text. In a printed manual, the text on an `@exdent' -line is printed in the roman font. - - `@exdent' is usually used within examples. Thus, - - @example - This line follows an @@example command. - @exdent This line is exdented. - This line follows the exdented line. - The @@end example comes on the next line. - @end group - -produces - - This line follows an @example command. -This line is exdented. - This line follows the exdented line. - The @end example comes on the next line. - - In practice, the `@exdent' command is rarely used. Usually, you -un-indent text by ending the example and returning the page to its -normal width. - - -File: texi.info, Node: flushleft & flushright, Next: cartouche, Prev: exdent, Up: Quotations and Examples - -`@flushleft' and `@flushright' -============================== - - The `@flushleft' and `@flushright' commands line up the ends of -lines on the left and right margins of a page, but do not fill the -text. The commands are written on lines of their own, without braces. -The `@flushleft' and `@flushright' commands are ended by `@end -flushleft' and `@end flushright' commands on lines of their own. - - For example, - - @flushleft - This text is - written flushleft. - @end flushleft - -produces - - This text is - written flushleft. - - Flushright produces the type of indentation often used in the return -address of letters. - -For example, - - @flushright - Here is an example of text written - flushright. The @code{@flushright} command - right justifies every line but leaves the - left end ragged. - @end flushright - -produces - - Here is an example of text written - flushright. The `@flushright' command - right justifies every line but leaves the - left end ragged. - - -File: texi.info, Node: cartouche, Prev: flushleft & flushright, Up: Quotations and Examples - -Drawing Cartouches Around Examples -================================== - - In a printed manual, the `@cartouche' command draws a box with -rounded corners around its contents. You can use this command to -further highlight an example or quotation. For instance, you could -write a manual in which one type of example is surrounded by a cartouche -for emphasis. - - The `@cartouche' command affects only the printed manual; it has no -effect in the Info file. - - For example, - - @example - @cartouche - % pwd - /usr/local/lib/emacs/info - @end cartouche - @end example - -surrounds the two-line example with a box with rounded corners, in the -printed manual. - - -File: texi.info, Node: Lists and Tables, Next: Indices, Prev: Quotations and Examples, Up: Top - -Making Lists and Tables -*********************** - - Texinfo has several ways of making lists and two-column tables. -Lists can be bulleted or numbered, while two-column tables can -highlight the items in the first column. - -* Menu: - -* Introducing Lists:: Texinfo formats lists for you. -* itemize:: How to construct a simple list. -* enumerate:: How to construct a numbered list. -* Two-column Tables:: How to construct a two-column table. - - -File: texi.info, Node: Introducing Lists, Next: itemize, Up: Lists and Tables - -Introducing Lists -================= - - Texinfo automatically indents the text in lists or tables, and -numbers an enumerated list. This last feature is useful if you modify -the list, since you do not need to renumber it yourself. - - Numbered lists and tables begin with the appropriate @-command at the -beginning of a line, and end with the corresponding `@end' command on a -line by itself. The table and itemized-list commands also require that -you write formatting information on the same line as the beginning -@-command. - - Begin an enumerated list, for example, with an `@enumerate' command -and end the list with an `@end enumerate' command. Begin an itemized -list with an `@itemize' command, followed on the same line by a -formatting command such as `@bullet', and end the list with an `@end -itemize' command. - - Precede each element of a list with an `@item' or `@itemx' command. - -Here is an itemized list of the different kinds of table and lists: - - * Itemized lists with and without bullets. - - * Enumerated lists, using numbers or letters. - - * Two-column tables with highlighting. - -Here is an enumerated list with the same items: - - 1. Itemized lists with and without bullets. - - 2. Enumerated lists, using numbers or letters. - - 3. Two-column tables with highlighting. - -And here is a two-column table with the same items and their @-commands: - -`@itemize' - Itemized lists with and without bullets. - -`@enumerate' - Enumerated lists, using numbers or letters. - -`@table' -`@ftable' -`@vtable' - Two-column tables with highlighting. - - -File: texi.info, Node: itemize, Next: enumerate, Prev: Introducing Lists, Up: Lists and Tables - -Making an Itemized List -======================= - - The `@itemize' command produces sequences of indented paragraphs, -with a bullet or other mark inside the left margin at the beginning of -each paragraph for which such a mark is desired. - - Begin an itemized list by writing `@itemize' at the beginning of a -line. Follow the command, on the same line, with a character or a -Texinfo command that generates a mark. Usually, you will write -`@bullet' after `@itemize', but you can use `@minus', or any character -or any special symbol that results in a single character in the Info -file. (When you write `@bullet' or `@minus' after an `@itemize' -command, you may omit the `{}'.) - - Write the text of the indented paragraphs themselves after the -`@itemize', up to another line that says `@end itemize'. - - Before each paragraph for which a mark in the margin is desired, -write a line that says just `@item'. Do not write any other text on -this line. - - Usually, you should put a blank line before an `@item'. This puts a -blank line in the Info file. (TeX inserts the proper interline -whitespace in either case.) Except when the entries are very brief, -these blank lines make the list look better. - - Here is an example of the use of `@itemize', followed by the output -it produces. Note that `@bullet' produces an `*' in Info and a round -dot in TeX. - - @itemize @bullet - @item - Some text for foo. - - @item - Some text - for bar. - @end itemize - -This produces: - - * Some text for foo. - - * Some text for bar. - - Itemized lists may be embedded within other itemized lists. Here is -a list marked with dashes embedded in a list marked with bullets: - - @itemize @bullet - @item - First item. - - @itemize @minus - @item - Inner item. - - @item - Second inner item. - @end itemize - - @item - Second outer item. - @end itemize - -This produces: - - * First item. - - - Inner item. - - - Second inner item. - - * Second outer item. - - -File: texi.info, Node: enumerate, Next: Two-column Tables, Prev: itemize, Up: Lists and Tables - -Making a Numbered or Lettered List -================================== - - `@enumerate' is like `@itemize' except that the marks in the left -margin contain successive integers or letters. (*Note `@itemize': -itemize.) - - Write the `@enumerate' command at the beginning of a line. The -command does not require an argument, but accepts either a number or a -letter as an option. Without an argument, `@enumerate' starts the list -with the number 1. With a numeric argument, such as 3, the command -starts the list with that number. With an upper or lower case letter, -such as `a' or `A', the command starts the list with that letter. - - Write the text of the enumerated list in the same way you write an -itemized list: put `@item' on a line of its own before the start of -each paragraph that you want enumerated. Do not write any other text on -the line beginning with `@item'. - - You should put a blank line between entries in the list. This -generally makes it easier to read the Info file. - - Here is an example of `@enumerate' without an argument: - - @enumerate - @item - Underlying causes. - - @item - Proximate causes. - @end enumerate - -This produces: - - 1. Underlying causes. - - 2. Proximate causes. - - Here is an example with an argument of `3': - - @enumerate 3 - @item - Predisposing causes. - - @item - Precipitating causes. - - @item - Perpetuating causes. - @end enumerate - -This produces: - - 3. Predisposing causes. - - 4. Precipitating causes. - - 5. Perpetuating causes. - - Here is a brief summary of the alternatives. The summary is -constructed using `@enumerate' with an argument of `a'. - - a. `@enumerate' - - Without an argument, produce a numbered list, starting with the - number 1. - - b. `@enumerate POSITIVE-INTEGER' - - With a (positive) numeric argument, start a numbered list with that - number. You can use this to continue a list that you interrupted - with other text. - - c. `@enumerate UPPER-CASE-LETTER' - - With an upper case letter as argument, start a list in which each - item is marked by a letter, beginning with that upper case letter. - - d. `@enumerate LOWER-CASE-LETTER' - - With a lower case letter as argument, start a list in which each - item is marked by a letter, beginning with that lower case letter. - - You can also nest enumerated lists, as in an outline. - - -File: texi.info, Node: Two-column Tables, Prev: enumerate, Up: Lists and Tables - -Making a Two-column Table -========================= - - `@table' is similar to `@itemize', but the command allows you to -specify a name or heading line for each item. (*Note `@itemize': -itemize.) The `@table' command is used to produce two-column tables, -and is especially useful for glossaries and explanatory exhibits. - -* Menu: - -* table:: How to construct a two-column table. -* ftable vtable:: How to construct a two-column table - with automatic indexing. -* itemx:: How to put more entries in the first column. - - -File: texi.info, Node: table, Next: ftable vtable, Up: Two-column Tables - -Using the `@table' Command --------------------------- - - Use the `@table' command to produce two-column tables. - - Write the `@table' command at the beginning of a line and follow it -on the same line with an argument that is a Texinfo command such as -`@code', `@samp', `@var', or `@kbd'. Although these commands are -usually followed by arguments in braces, in this case you use the -command name without an argument because `@item' will supply the -argument. This command will be applied to the text that goes into the -first column of each item and determines how it will be highlighted. -For example, `@samp' will cause the text in the first column to be -highlighted with an `@samp' command. - - You may also choose to use the `@asis' command as an argument to -`@table'. `@asis' is a command that does nothing; if you use this -command after `@table', TeX and the Info formatting commands output the -first column entries without added highlighting (`as is'). - - (The `@table' command may work with other commands besides those -listed here. However, you can only use commands that normally take -arguments in braces.) - - Begin each table entry with an `@item' command at the beginning of a -line. Write the first column text on the same line as the `@item' -command. Write the second column text on the line following the -`@item' line and on subsequent lines. (You do not need to type -anything for an empty second column entry.) You may write as many -lines of supporting text as you wish, even several paragraphs. But -only text on the same line as the `@item' will be placed in the first -column. - - Normally, you should put a blank line before an `@item' line. This -puts a blank like in the Info file. Except when the entries are very -brief, a blank line looks better. - - The following table, for example, highlights the text in the first -column with an `@samp' command: - - @table @samp - @item foo - This is the text for - @samp{foo}. - - @item bar - Text for @samp{bar}. - @end table - -This produces: - -`foo' - This is the text for `foo'. - -`bar' - Text for `bar'. - - If you want to list two or more named items with a single block of -text, use the `@itemx' command. (*Note `@itemx': itemx.) - - -File: texi.info, Node: ftable vtable, Next: itemx, Prev: table, Up: Two-column Tables - -`@ftable' and `@vtable' ------------------------ - - The `@ftable' and `@vtable' commands are the same as the `@table' -command except that `@ftable' automatically enters each of the items in -the first column of the table into the index of functions and `@vtable' -automatically enters each of the items in the first column of the table -into the index of variables. This simplifies the task of creating -indices. Only the items on the same line as the `@item' commands are -indexed, and they are indexed in exactly the form that they appear on -that line. *Note Creating Indices: Indices, for more information about -indices. - - Begin a two-column table using `@ftable' or `@vtable' by writing the -@-command at the beginning of a line, followed on the same line by an -argument that is a Texinfo command such as `@code', exactly as you -would for an `@table' command; and end the table with an `@end ftable' -or `@end vtable' command on a line by itself. - - -File: texi.info, Node: itemx, Prev: ftable vtable, Up: Two-column Tables - -`@itemx' --------- - - Use the `@itemx' command inside a table when you have two or more -first column entries for the same item, each of which should appear on -a line of its own. Use `@itemx' for all but the first entry. The -`@itemx' command works exactly like `@item' except that it does not -generate extra vertical space above the first column text. - - For example, - - @table @code - @item upcase - @itemx downcase - These two functions accept a character or a string as - argument, and return the corresponding upper case (lower - case) character or string. - @end table - -This produces: - -`upcase' -`downcase' - These two functions accept a character or a string as argument, - and return the corresponding upper case (lower case) character or - string. - -(Note also that this example illustrates multi-line supporting text in -a two-column table.) - - -File: texi.info, Node: Indices, Next: Insertions, Prev: Lists and Tables, Up: Top - -Creating Indices -**************** - - Using Texinfo, you can generate indices without having to sort and -collate entries manually. In an index, the entries are listed in -alphabetical order, together with information on how to find the -discussion of each entry. In a printed manual, this information -consists of page numbers. In an Info file, this information is a menu -entry leading to the first node referenced. - - Texinfo provides several predefined kinds of index: an index for -functions, an index for variables, an index for concepts, and so on. -You can combine indices or use them for other than their canonical -purpose. If you wish, you can define your own indices. - -* Menu: - -* Index Entries:: Choose different words for index entries. -* Predefined Indices:: Use different indices for different kinds - of entry. -* Indexing Commands:: How to make an index entry. -* Combining Indices:: How to combine indices. -* New Indices:: How to define your own indices. - - -File: texi.info, Node: Index Entries, Next: Predefined Indices, Up: Indices - -Making Index Entries -==================== - - When you are making index entries, it is good practice to think of -the different ways people may look for something. Different people *do -not* think of the same words when they look something up. A helpful -index will have items indexed under all the different words that people -may use. For example, one reader may think it obvious that the -two-letter names for indices should be listed under "Indices, -two-letter names", since the word "Index" is the general concept. But -another reader may remember the specific concept of two-letter names -and search for the entry listed as "Two letter names for indices". A -good index will have both entries and will help both readers. - - Like typesetting, the construction of an index is a highly skilled, -professional art, the subtleties of which are not appreciated until you -need to do it yourself. - - *Note Printing Indices & Menus::, for information about printing an -index at the end of a book or creating an index menu in an Info file. - - -File: texi.info, Node: Predefined Indices, Next: Indexing Commands, Prev: Index Entries, Up: Indices - -Predefined Indices -================== - - Texinfo provides six predefined indices: - - * A "concept index" listing concepts that are discussed. - - * A "function index" listing functions (such as entry points of - libraries). - - * A "variables index" listing variables (such as global variables of - libraries). - - * A "keystroke index" listing keyboard commands. - - * A "program index" listing names of programs. - - * A "data type index" listing data types (such as structures defined - in header files). - -Not every manual needs all of these, and most manuals use two or three -of them. This manual has two indices: a concept index and an @-command -index (that is actually the function index but is called a command -index in the chapter heading). Two or more indices can be combined -into one using the `@synindex' or `@syncodeindex' commands. *Note -Combining Indices::. - - -File: texi.info, Node: Indexing Commands, Next: Combining Indices, Prev: Predefined Indices, Up: Indices - -Defining the Entries of an Index -================================ - - The data to make an index come from many individual indexing commands -scattered throughout the Texinfo source file. Each command says to add -one entry to a particular index; after formatting, the index will give -the current page number or node name as the reference. - - An index entry consists of an indexing command at the beginning of a -line followed, on the rest of the line, by the entry. - - For example, this section begins with the following five entries for -the concept index: - - @cindex Defining indexing entries - @cindex Index entries - @cindex Entries for an index - @cindex Specifying index entries - @cindex Creating index entries - - Each predefined index has its own indexing command--`@cindex' for -the concept index, `@findex' for the function index, and so on. - - The usual convention is to capitalize the first word of each index -entry, unless that word is the name of a function, variable, or other -such entity that should not be capitalized. Thus, if you are -documenting Emacs Lisp, you should usually capitalize entries in the -concept index, but not those in the function index. However, if your -concept index entries are consistently short (one or two words each) it -may look better for each regular entry to start with a lower case -letter. Whichever convention you adapt, please be consistent! - - By default, entries for a concept index are printed in a small roman -font and entries for the other indices are printed in a small `@code' -font. You may change the way part of an entry is printed with the -usual Texinfo commands, such as `@file' for file names and `@emph' for -emphasis (*note Marking Text::.). - - The six indexing commands for predefined indices are: - -`@cindex CONCEPT' - Make an entry in the concept index for CONCEPT. - -`@findex FUNCTION' - Make an entry in the function index for FUNCTION. - -`@vindex VARIABLE' - Make an entry in the variable index for VARIABLE. - -`@kindex KEYSTROKE' - Make an entry in the key index for KEYSTROKE. - -`@pindex PROGRAM' - Make an entry in the program index for PROGRAM. - -`@tindex DATA TYPE' - Make an entry in the data type index for DATA TYPE. - - *Caution:* Do not use a colon in an index entry. In Info, a colon - separates the menu entry name from the node name. An extra colon - confuses Info. *Note The Parts of a Menu: Menu Parts, for more - information about the structure of a menu entry. - - If you write several identical index entries in different places in a -Texinfo file, the index in the printed manual will list all the pages to -which those entries refer. However, the index in the Info file will -list *only* the node that references the *first* of those index -entries. Therefore, it is best to write indices in which each entry -refers to only one place in the Texinfo file. Fortunately, this -constraint is a feature rather than a loss since it means that the index -will be easy to use. Otherwise, you could create an index that lists -several pages for one entry and your reader would not know to which page -to turn. If you have two identical entries for one topic, change the -topics slightly, or qualify them to indicate the difference. - - You are not actually required to use the predefined indices for their -canonical purposes. For example, suppose you wish to index some C -preprocessor macros. You could put them in the function index along -with actual functions, just by writing `@findex' commands for them; -then, when you print the "Function Index" as an unnumbered chapter, you -could give it the title `Function and Macro Index' and all will be -consistent for the reader. Or you could put the macros in with the -data types by writing `@tindex' commands for them, and give that index -a suitable title so the reader will understand. (*Note Printing -Indices & Menus::.) - - -File: texi.info, Node: Combining Indices, Next: New Indices, Prev: Indexing Commands, Up: Indices - -Combining Indices -================= - - Sometimes you will want to combine two disparate indices such as -functions and concepts, perhaps because you have few enough of one of -them that a separate index for them would look silly. - - You could put functions into the concept index by writing `@cindex' -commands for them instead of `@findex' commands, and produce a -consistent manual by printing the concept index with the title -`Function and Concept Index' and not printing the `Function Index' at -all; but this is not a robust procedure. It works only if your -document is never included as part of another document that is designed -to have a separate function index; if your document were to be included -with such a document, the functions from your document and those from -the other would not end up together. Also, to make your function names -appear in the right font in the concept index, you would need to -enclose every one of them between the braces of `@code'. - -* Menu: - -* syncodeindex:: How to merge two indices, using `@code' - font for the merged-from index. -* synindex:: How to merge two indices, using the - default font of the merged-to index. - - -File: texi.info, Node: syncodeindex, Next: synindex, Up: Combining Indices - -`@syncodeindex' -............... - - When you want to combine functions and concepts into one index, you -should index the functions with `@findex' and index the concepts with -`@cindex', and use the `@syncodeindex' command to redirect the function -index entries into the concept index. - - The `@syncodeindex' command takes two arguments; they are the name -of the index to redirect, and the name of the index to redirect it to. -The template looks like this: - - @syncodeindex FROM TO - - For this purpose, the indices are given two-letter names: - -`cp' - concept index - -`fn' - function index - -`vr' - variable index - -`ky' - key index - -`pg' - program index - -`tp' - data type index - - Write an `@syncodeindex' command before or shortly after the -end-of-header line at the beginning of a Texinfo file. For example, to -merge a function index with a concept index, write the following: - - @syncodeindex fn cp - -This will cause all entries designated for the function index to merge -in with the concept index instead. - - To merge both a variables index and a function index into a concept -index, write the following: - - @syncodeindex vr cp - @syncodeindex fn cp - - The `@syncodeindex' command puts all the entries from the `from' -index (the redirected index) into the `@code' font, overriding whatever -default font is used by the index to which the entries are now -directed. This way, if you direct function names from a function index -into a concept index, all the function names are printed in the `@code' -font as you would expect. - - -File: texi.info, Node: synindex, Prev: syncodeindex, Up: Combining Indices - -`@synindex' -........... - - The `@synindex' command is nearly the same as the `@syncodeindex' -command, except that it does not put the `from' index entries into the -`@code' font; rather it puts them in the roman font. Thus, you use -`@synindex' when you merge a concept index into a function index. - - *Note Printing Indices & Menus::, for information about printing an -index at the end of a book or creating an index menu in an Info file. - - -File: texi.info, Node: New Indices, Prev: Combining Indices, Up: Indices - -Defining New Indices -==================== - - In addition to the predefined indices, you may use the `@defindex' -and `@defcodeindex' commands to define new indices. These commands -create new indexing @-commands with which you mark index entries. The -`@defindex 'command is used like this: - - @defindex NAME - - The name of an index should be a two letter word, such as `au'. For -example: - - @defindex au - - This defines a new index, called the `au' index. At the same time, -it creates a new indexing command, `@auindex', that you can use to make -index entries. Use the new indexing command just as you would use a -predefined indexing command. - - For example, here is a section heading followed by a concept index -entry and two `au' index entries. - - @section Cognitive Semantics - @cindex kinesthetic image schemas - @auindex Johnson, Mark - @auindex Lakoff, George - -(Evidently, `au' serves here as an abbreviation for "author".) Texinfo -constructs the new indexing command by concatenating the name of the -index with `index'; thus, defining an `au' index leads to the automatic -creation of an `@auindex' command. - - Use the `@printindex' command to print the index, as you do with the -predefined indices. For example: - - @node Author Index, Subject Index, , Top - @unnumbered Author Index - - @printindex au - - The `@defcodeindex' is like the `@defindex' command, except that, in -the printed output, it prints entries in an `@code' font instead of a -roman font. Thus, it parallels the `@findex' command rather than the -`@cindex' command. - - You should define new indices within or right after the end-of-header -line of a Texinfo file, before any `@synindex' or `@syncodeindex' -commands (*note Header::.). - - -File: texi.info, Node: Insertions, Next: Glyphs, Prev: Indices, Up: Top - -Special Insertions -****************** - - Texinfo provides several commands for formatting dimensions, for -inserting single characters that have special meaning in Texinfo, such -as braces, and for inserting special graphic symbols that do not -correspond to characters, such as dots and bullets. - -* Menu: - -* Braces Atsigns Periods:: How to insert braces, `@' and periods. -* dmn:: How to format a dimension. -* Dots Bullets:: How to insert dots and bullets. -* TeX and copyright:: How to insert the TeX logo - and the copyright symbol. -* minus:: How to insert a minus sign. - - -File: texi.info, Node: Braces Atsigns Periods, Next: dmn, Up: Insertions - -Inserting `@', Braces, and Periods -================================== - - `@' and curly braces are special characters in Texinfo. To insert -these characters so they appear in text, you must put an `@' in front -of these characters to prevent Texinfo from misinterpreting them. - - Periods are also special. Depending on whether the period is inside -or at the end of a sentence, less or more space is inserted after a -period in a typeset manual. Since it is not always possible for -Texinfo to determine when a period ends a sentence and when it is used -in an abbreviation, special commands are needed in some circumstances. -(Usually, Texinfo can guess how to handle periods, so you do not need -to use the special commands; you just enter a period as you would if -you were using a typewriter, which means you put two spaces after the -period, question mark, or exclamation mark that ends a sentence.) - - Do not put braces after any of these commands; they are not -necessary. - -* Menu: - -* Inserting An Atsign:: -* Inserting Braces:: How to insert `{' and `}' -* Controlling Spacing:: How to insert the right amount of space - after punctuation within a sentence. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-6 b/gnu/usr.bin/texinfo/info-files/texi.info-6 deleted file mode 100644 index cac7b3ab88dd..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-6 +++ /dev/null @@ -1,1461 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Inserting An Atsign, Next: Inserting Braces, Up: Braces Atsigns Periods - -Inserting `@' with @@ ---------------------- - - `@@' stands for a single `@' in either printed or Info output. - - Do not put braces after an `@@' command. - - -File: texi.info, Node: Inserting Braces, Next: Controlling Spacing, Prev: Inserting An Atsign, Up: Braces Atsigns Periods - -Inserting `{' and `}'with @{ and @} ------------------------------------ - - `@{' stands for a single `{' in either printed or Info output. - - `@}' stands for a single `}' in either printed or Info output. - - Do not put braces after either an `@{' or an `@}' command. - - -File: texi.info, Node: Controlling Spacing, Prev: Inserting Braces, Up: Braces Atsigns Periods - -Spacing After Colons and Periods --------------------------------- - - Use the `@:' command after a period, question mark, exclamation -mark, or colon that should not be followed by extra space. For -example, use `@:' after periods that end abbreviations which are not at -the ends of sentences. `@:' has no effect on the Info file output. - - For example, - - The s.o.p.@: has three parts ... - The s.o.p. has three parts ... - -produces - - The s.o.p. has three parts ... - The s.o.p. has three parts ... - -`@:' has no effect on the Info output. (`s.o.p' is an acronym for -"Standard Operating Procedure".) - - Use `@.' instead of a period at the end of a sentence that ends with -a single capital letter. Otherwise, TeX will think the letter is an -abbreviation and will not insert the correct end-of-sentence spacing. -Here is an example: - - Give it to M.I.B. and to M.E.W@. Also, give it to R.J.C@. - Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. - -produces - - Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. - Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. - - In the Info file output, `@.' is equivalent to a simple `.'. - - The meanings of `@:' and `@.' in Texinfo are designed to work well -with the Emacs sentence motion commands. This made it necessary for -them to be incompatible with some other formatting systems that use -@-commands. - - Do not put braces after either an `@:' or an `@.' command. - - -File: texi.info, Node: dmn, Next: Dots Bullets, Prev: Braces Atsigns Periods, Up: Insertions - -`@dmn'{DIMENSION}: Format a Dimension -===================================== - - At times, you may want to write `12pt' or `8.5in' with little or no -space between the number and the abbreviation for the dimension. You -can use the `@dmn' command to do this. On seeing the command, TeX -inserts just enough space for proper typesetting; the Info formatting -commands insert no space at all, since the Info file does not require -it. - - To use the `@dmn' command, write the number and then follow it -immediately, with no intervening space, by `@dmn', and then by the -dimension within braces. - -For example, - - A4 paper is 8.27@dmn{in} wide. - -produces - - A4 paper is 8.27in wide. - - Not everyone uses this style. Instead of writing `8.27@dmn{in}' in -the Texinfo file, you may write `8.27 in.' or `8.27 inches'. (In these -cases, the formatters may insert a line break between the number and the -dimension. Also, if you write a period after an abbreviation within a -sentence, you should write `@:' after the period to prevent TeX from -inserting extra whitespace. *Note Spacing After Colons and Periods: -Controlling Spacing.) - - -File: texi.info, Node: Dots Bullets, Next: TeX and copyright, Prev: dmn, Up: Insertions - -Inserting Ellipsis, Dots, and Bullets -===================================== - - An "ellipsis" (a line of dots) is not typeset as a string of -periods, so a special command is used for ellipsis in Texinfo. The -`@bullet' command is special, too. Each of these commands is followed -by a pair of braces, `{}', without any whitespace between the name of -the command and the braces. (You need to use braces with these -commands because you can use them next to other text; without the -braces, the formatters would be confused. *Note @-Command Syntax: -Command Syntax, for further information.) - -* Menu: - -* dots:: How to insert dots ... -* bullet:: How to insert a bullet. - - -File: texi.info, Node: dots, Next: bullet, Up: Dots Bullets - -`@dots'{} ---------- - - Use the `@dots{}' command to generate an ellipsis, which is three -dots in a row, appropriately spaced, like this: `...'. Do not simply -write three periods in the input file; that would work for the Info -file output, but would produce the wrong amount of space between the -periods in the printed manual. - - -File: texi.info, Node: bullet, Prev: dots, Up: Dots Bullets - -`@bullet'{} ------------ - - Use the `@bullet{}' command to generate a large round dot, or the -closest possible thing to one. In Info, an asterisk is used. - - Here is a bullet: * - - When you use `@bullet' in `@itemize', you do not need to type the -braces, because `@itemize' supplies them. *Note itemize::. - - -File: texi.info, Node: TeX and copyright, Next: minus, Prev: Dots Bullets, Up: Insertions - -Inserting TeX and the Copyright Symbol -====================================== - - The logo `TeX' is typeset in a special fashion and it needs an -@-command. The copyright symbol, `(C)', is also special. Each of -these commands is followed by a pair of braces, `{}', without any -whitespace between the name of the command and the braces. - -* Menu: - -* tex:: How to insert the TeX logo. -* copyright symbol:: How to use `@copyright'{}. - - -File: texi.info, Node: tex, Next: copyright symbol, Up: TeX and copyright - -`@TeX'{} --------- - - Use the `@TeX{}' command to generate `TeX'. In a printed manual, -this is a special logo that is different from three ordinary letters. -In Info, it just looks like `TeX'. The `@TeX{}' command is unique -among Texinfo commands in that the T and the X are in upper case. - - -File: texi.info, Node: copyright symbol, Prev: tex, Up: TeX and copyright - -`@copyright'{} --------------- - - Use the `@copyright{}' command to generate `(C)'. In a printed -manual, this is a `c' inside a circle, and in Info, this is `(C)'. - - -File: texi.info, Node: minus, Prev: TeX and copyright, Up: Insertions - -`@minus'{}: Inserting a Minus Sign -================================== - - Use the `@minus{}' command to generate a minus sign. In a -fixed-width font, this is a single hyphen, but in a proportional font, -the symbol is the customary length for a minus sign--a little longer -than a hyphen. - - You can compare the two forms: - - `-' is a minus sign generated with `@minus{}', - - `-' is a hyphen generated with the character `-'. - -In the fixed-width font used by Info, `@minus{}' is the same as a -hyphen. - - You should not use `@minus{}' inside `@code' or `@example' because -the width distinction is not made in the fixed-width font they use. - - When you use `@minus' to specify the mark beginning each entry in an -itemized list, you do not need to type the braces (*note itemize::.). - - -File: texi.info, Node: Glyphs, Next: Breaks, Prev: Insertions, Up: Top - -Glyphs for Examples -******************* - - In Texinfo, code is often illustrated in examples that are delimited -by `@example' and `@end example', or by `@lisp' and `@end lisp'. In -such examples, you can indicate the results of evaluation or an -expansion using `=>' or `==>'. Likewise, there are commands to insert -glyphs to indicate printed output, error messages, equivalence of -expressions, and the location of point. - - The glyph-insertion commands do not need to be used within an -example, but most often they are. Every glyph-insertion command is -followed by a pair of left- and right-hand braces. - -* Menu: - -* Glyphs Summary:: -* result:: How to show the result of expression. -* expansion:: How to indicate an expansion. -* Print Glyph:: How to indicate printed output. -* Error Glyph:: How to indicate an error message. -* Equivalence:: How to indicate equivalence. -* Point Glyph:: How to indicate the location of point. - - -File: texi.info, Node: Glyphs Summary, Next: result, Up: Glyphs - -Glyphs Summary -============== - - Here are the different glyph commands: - -=> - `@result{}' points to the result of an expression. - -==> - `@expansion{}' shows the results of a macro expansion. - --| - `@print{}' indicates printed output. - -error--> - `@error{}' indicates that the following text is an error message. - -== - `@equiv{}' indicates the exact equivalence of two forms. - --!- - `@point{}' shows the location of point. - - -File: texi.info, Node: result, Next: expansion, Prev: Glyphs Summary, Up: Glyphs - -=>: Indicating Evaluation -========================= - - Use the `@result{}' command to indicate the result of evaluating an -expression. - - The `@result{}' command is displayed as `=>' in Info and as a double -stemmed arrow in the printed output. - - Thus, the following, - - (cdr '(1 2 3)) - => (2 3) - -may be read as "`(cdr '(1 2 3))' evaluates to `(2 3)'". - - -File: texi.info, Node: expansion, Next: Print Glyph, Prev: result, Up: Glyphs - -==>: Indicating an Expansion -============================ - - When an expression is a macro call, it expands into a new expression. -You can indicate the result of the expansion with the `@expansion{}' -command. - - The `@expansion{}' command is displayed as `==>' in Info and as a -long arrow with a flat base in the printed output. - - For example, the following - - @lisp - (third '(a b c)) - @expansion{} (car (cdr (cdr '(a b c)))) - @result{} c - @end lisp - -produces - - (third '(a b c)) - ==> (car (cdr (cdr '(a b c)))) - => c - -which may be read as: - - `(third '(a b c))' expands to `(car (cdr (cdr '(a b c))))'; the - result of evaluating the expression is `c'. - -Often, as in this case, an example looks better if the `@expansion{}' -and `@result{}' commands are indented five spaces. - - -File: texi.info, Node: Print Glyph, Next: Error Glyph, Prev: expansion, Up: Glyphs - --|: Indicating Printed Output -============================= - - Sometimes an expression will print output during its execution. You -can indicate the printed output with the `@print{}' command. - - The `@print{}' command is displayed as `-|' in Info and similarly, -as a horizontal dash butting against a vertical bar, in the printed -output. - - In the following example, the printed text is indicated with `-|', -and the value of the expression follows on the last line. - - (progn (print 'foo) (print 'bar)) - -| foo - -| bar - => bar - -In a Texinfo source file, this example is written as follows: - - @lisp - (progn (print 'foo) (print 'bar)) - @print{} foo - @print{} bar - @result{} bar - @end lisp - - -File: texi.info, Node: Error Glyph, Next: Equivalence, Prev: Print Glyph, Up: Glyphs - -error-->: Indicating an Error Message -===================================== - - A piece of code may cause an error when you evaluate it. You can -designate the error message with the `@error{}' command. - - The `@error{}' command is displayed as `error-->' in Info and as the -word `error' in a box in the printed output. - - Thus, - - @lisp - (+ 23 'x) - @error{} Wrong type argument: integer-or-marker-p, x - @end lisp - -produces - - (+ 23 'x) - error--> Wrong type argument: integer-or-marker-p, x - -This indicates that the following error message is printed when you -evaluate the expression: - - Wrong type argument: integer-or-marker-p, x - - Note that `error-->' itself is not part of the error message. - - -File: texi.info, Node: Equivalence, Next: Point Glyph, Prev: Error Glyph, Up: Glyphs - -==: Indicating Equivalence -========================== - - Sometimes two expressions produce identical results. You can -indicate the exact equivalence of two forms with the `@equiv{}' command. - - The `@equiv{}' command is displayed as `==' in Info and as a three -parallel horizontal lines in the printed output. - - Thus, - - @lisp - (make-sparse-keymap) @equiv{} (list 'keymap) - @end lisp - -produces - - (make-sparse-keymap) == (list 'keymap) - -This indicates that evaluating `(make-sparse-keymap)' produces -identical results to evaluating `(list 'keymap)'. - - -File: texi.info, Node: Point Glyph, Prev: Equivalence, Up: Glyphs - -Indicating Point in a Buffer -============================ - - Sometimes you need to show an example of text in an Emacs buffer. In -such examples, the convention is to include the entire contents of the -buffer in question between two lines of dashes containing the buffer -name. - - You can use the `@point{}' command to show the location of point in -the text in the buffer. (The symbol for point, of course, is not part -of the text in the buffer; it indicates the place *between* two -characters where point is located.) - - The `@point{}' command is displayed as `-!-' in Info and as a small -five pointed star in the printed output. - - The following example shows the contents of buffer `foo' before and -after evaluating a Lisp command to insert the word `changed'. - - ---------- Buffer: foo ---------- - This is the -!-contents of foo. - ---------- Buffer: foo ---------- - - (insert "changed ") - => nil - ---------- Buffer: foo ---------- - This is the changed -!-contents of foo. - ---------- Buffer: foo ---------- - - In a Texinfo source file, the example is written like this: - - @example - ---------- Buffer: foo ---------- - This is the @point{}contents of foo. - ---------- Buffer: foo ---------- - - (insert "changed ") - @result{} nil - ---------- Buffer: foo ---------- - This is the changed @point{}contents of foo. - ---------- Buffer: foo ---------- - @end example - - -File: texi.info, Node: Breaks, Next: Definition Commands, Prev: Glyphs, Up: Top - -Making and Preventing Breaks -**************************** - - Usually, a Texinfo file is processed both by TeX and by one of the -Info formatting commands. Line, paragraph, or page breaks sometimes -occur in the `wrong' place in one or other form of output. You must -ensure that text looks right both in the printed manual and in the Info -file. - - For example, in a printed manual, page breaks may occur awkwardly in -the middle of an example; to prevent this, you can hold text together -using a grouping command that keeps the text from being split across -two pages. Conversely, you may want to force a page break where none -would occur normally. Fortunately, problems like these do not often -arise. When they do, use the break, break prevention, or pagination -commands. - -* Menu: - -* Break Commands:: Cause and prevent splits. -* Line Breaks:: How to force a single line to use two lines. -* w:: How to prevent unwanted line breaks. -* sp:: How to insert blank lines. -* page:: How to force the start of a new page. -* group:: How to prevent unwanted page breaks. -* need:: Another way to prevent unwanted page breaks. - - -File: texi.info, Node: Break Commands, Next: Line Breaks, Up: Breaks - -The Break Commands -================== - - The break commands create line and paragraph breaks: - -`@*' - Force a line break. - -`@sp N' - Skip N blank lines. - - The line-break-prevention command holds text together all on one -line: - -`@w{TEXT}' - Prevent TEXT from being split and hyphenated across two lines. - - The pagination commands apply only to printed output, since Info -files do not have pages. - -`@page' - Start a new page in the printed manual. - -`@group' - Hold text together that must appear on one printed page. - -`@need MILS' - Start a new printed page if not enough space on this one. - - -File: texi.info, Node: Line Breaks, Next: w, Prev: Break Commands, Up: Breaks - -`@*': Generate Line Breaks -========================== - - The `@*' command forces a line break in both the printed manual and -in Info. - - For example, - - This line @* is broken @*in two places. - -produces - - This line - is broken - in two places. - -(Note that the space after the first `@*' command is faithfully carried -down to the next line.) - - The `@*' command is often used in a file's copyright page: - - This is edition 2.0 of the Texinfo documentation,@* - and is for ... - -In this case, the `@*' command keeps TeX from stretching the line -across the whole page in an ugly manner. - - *Please note:* Do not write braces after an `@*' command; they are - not needed. - - Do not write an `@refill' command at the end of a paragraph - containing an `@*' command; it will cause the paragraph to be - refilled after the line break occurs, negating the effect of the - line break. - - -File: texi.info, Node: w, Next: sp, Prev: Line Breaks, Up: Breaks - -`@w'{TEXT}: Prevent Line Breaks -=============================== - - `@w{TEXT}' outputs TEXT and prohibits line breaks within TEXT. - - You can use the `@w' command to prevent TeX from automatically -hyphenating a long name or phrase that accidentally falls near the end -of a line. - - You can copy GNU software from @w{@file{prep.ai.mit.edu}}. - -produces - - You can copy GNU software from `prep.ai.mit.edu'. - - In the Texinfo file, you must write the `@w' command and its -argument (all the affected text) all on one line. - - *Caution:* Do not write an `@refill' command at the end of a - paragraph containing an `@w' command; it will cause the paragraph - to be refilled and may thereby negate the effect of the `@w' - command. - - -File: texi.info, Node: sp, Next: page, Prev: w, Up: Breaks - -`@sp' N: Insert Blank Lines -=========================== - - A line beginning with and containing only `@sp N' generates N blank -lines of space in both the printed manual and the Info file. `@sp' -also forces a paragraph break. For example, - - @sp 2 - -generates two blank lines. - - The `@sp' command is most often used in the title page. - - -File: texi.info, Node: page, Next: group, Prev: sp, Up: Breaks - -`@page': Start a New Page -========================= - - A line containing only `@page' starts a new page in a printed -manual. The command has no effect on Info files since they are not -paginated. An `@page' command is often used in the `@titlepage' -section of a Texinfo file to start the copyright page. - - -File: texi.info, Node: group, Next: need, Prev: page, Up: Breaks - -`@group': Prevent Page Breaks -============================= - - The `@group' command (on a line by itself) is used inside an -`@example' or similar construct to begin an unsplittable vertical -group, which will appear entirely on one page in the printed output. -The group is terminated by a line containing only `@end group'. These -two lines produce no output of their own, and in the Info file output -they have no effect at all. - - Although `@group' would make sense conceptually in a wide variety of -contexts, its current implementation works reliably only within -`@example' and variants, and within `@display', `@format', `@flushleft' -and `@flushright'. *Note Quotations and Examples::. (What all these -commands have in common is that each line of input produces a line of -output.) In other contexts, `@group' can cause anomalous vertical -spacing. - - This formatting requirement means that you should write: - - @example - @group - ... - @end group - @end example - -with the `@group' and `@end group' commands inside the `@example' and -`@end example' commands. - - The `@group' command is most often used to hold an example together -on one page. In this Texinfo manual, more than 100 examples contain -text that is enclosed between `@group' and `@end group'. - - If you forget to end a group, you may get strange and unfathomable -error messages when you run TeX. This is because TeX keeps trying to -put the rest of the Texinfo file onto the one page and does not start -to generate error messages until it has processed considerable text. -It is a good rule of thumb to look for a missing `@end group' if you -get incomprehensible error messages in TeX. - - -File: texi.info, Node: need, Prev: group, Up: Breaks - -`@need MILS': Prevent Page Breaks -================================= - - A line containing only `@need N' starts a new page in a printed -manual if fewer than N mils (thousandths of an inch) remain on the -current page. Do not use braces around the argument N. The `@need' -command has no effect on Info files since they are not paginated. - - This paragraph is preceded by an `@need' command that tells TeX to -start a new page if fewer than 800 mils (eight-tenths inch) remain on -the page. It looks like this: - - @need 800 - This paragraph is preceded by ... - - The `@need' command is useful for preventing orphans (single lines -at the bottoms of printed pages). - - -File: texi.info, Node: Definition Commands, Next: Footnotes, Prev: Breaks, Up: Top - -Definition Commands -******************* - - The `@deffn' command and the other "definition commands" enable you -to describe functions, variables, macros, commands, user options, -special forms and other such artifacts in a uniform format. - - In the Info file, a definition causes the entity -category--`Function', `Variable', or whatever--to appear at the -beginning of the first line of the definition, followed by the entity's -name and arguments. In the printed manual, the command causes TeX to -print the entity's name and its arguments on the left margin and print -the category next to the right margin. In both output formats, the -body of the definition is indented. Also, the name of the entity is -entered into the appropriate index: `@deffn' enters the name into the -index of functions, `@defvr' enters it into the index of variables, and -so on. - - A manual need not and should not contain more than one definition for -a given name. An appendix containing a summary should use `@table' -rather than the definition commands. - -* Menu: - -* Def Cmd Template:: How to structure a description using a - definition command. -* Optional Arguments:: How to handle optional and repeated arguments. -* deffnx:: How to group two or more `first' lines. -* Def Cmds in Detail:: All the definition commands. -* Def Cmd Conventions:: Conventions for writing definitions. -* Sample Function Definition:: - - -File: texi.info, Node: Def Cmd Template, Next: Optional Arguments, Up: Definition Commands - -The Template for a Definition -============================= - - The `@deffn' command is used for definitions of entities that -resemble functions. To write a definition using the `@deffn' command, -write the `@deffn' command at the beginning of a line and follow it on -the same line by the category of the entity, the name of the entity -itself, and its arguments (if any). Then write the body of the -definition on succeeding lines. (You may embed examples in the body.) -Finally, end the definition with an `@end deffn' command written on a -line of its own. (The other definition commands follow the same -format.) - - The template for a definition looks like this: - - @deffn CATEGORY NAME ARGUMENTS... - BODY-OF-DEFINITION - @end deffn - -For example, - - @deffn Command forward-word count - This command moves point forward @var{count} words - (or backward if @var{count} is negative). ... - @end deffn - -produces - - - Command: forward-word COUNT - This function moves point forward COUNT words (or backward if - COUNT is negative). ... - - Capitalize the category name like a title. If the name of the -category contains spaces, as in the phrase `Interactive Command', write -braces around it. For example: - - @deffn {Interactive Command} isearch-forward - ... - @end deffn - -Otherwise, the second word will be mistaken for the name of the entity. - - Some of the definition commands are more general than others. The -`@deffn' command, for example, is the general definition command for -functions and the like--for entities that may take arguments. When you -use this command, you specify the category to which the entity belongs. -The `@deffn' command possesses three predefined, specialized -variations, `@defun', `@defmac', and `@defspec', that specify the -category for you: "Function", "Macro", and "Special Form" respectively. -The `@defvr' command also is accompanied by several predefined, -specialized variations for describing particular kinds of variables. - - The template for a specialized definition, such as `@defun', is -similar to the template for a generalized definition, except that you -do not need to specify the category: - - @defun NAME ARGUMENTS... - BODY-OF-DEFINITION - @end defun - -Thus, - - @defun buffer-end flag - This function returns @code{(point-min)} if @var{flag} - is less than 1, @code{(point-max)} otherwise. - ... - @end defun - -produces - - - Function: buffer-end FLAG - This function returns `(point-min)' if FLAG is less than 1, - `(point-max)' otherwise. ... - -*Note Sample Function Definition: Sample Function Definition, for a -more detailed example of a function definition, including the use of -`@example' inside the definition. - - The other specialized commands work like `@defun'. - - -File: texi.info, Node: Optional Arguments, Next: deffnx, Prev: Def Cmd Template, Up: Definition Commands - -Optional and Repeated Arguments -=============================== - - Some entities take optional or repeated arguments, which may be -specified by a distinctive glyph that uses square brackets and -ellipses. For example, a special form often breaks its argument list -into separate arguments in more complicated ways than a straightforward -function. - - An argument enclosed within square brackets is optional. Thus, -[OPTIONAL-ARG] means that OPTIONAL-ARG is optional. An argument -followed by an ellipsis is optional and may be repeated more than once. -Thus, REPEATED-ARGS... stands for zero or more arguments. Parentheses -are used when several arguments are grouped into additional levels of -list structure in Lisp. - - Here is the `@defspec' line of an example of an imaginary special -form: - - - Special Form: foobar (VAR [FROM TO [INC]]) BODY... - -In this example, the arguments FROM and TO are optional, but must both -be present or both absent. If they are present, INC may optionally be -specified as well. These arguments are grouped with the argument VAR -into a list, to distinguish them from BODY, which includes all -remaining elements of the form. - - In a Texinfo source file, this `@defspec' line is written like this -(except it would not be split over two lines, as it is in this example). - - @defspec foobar (@var{var} [@var{from} @var{to} - [@var{inc}]]) @var{body}@dots{} - -The function is listed in the Command and Variable Index under `foobar'. - - -File: texi.info, Node: deffnx, Next: Def Cmds in Detail, Prev: Optional Arguments, Up: Definition Commands - -Two or More `First' Lines -========================= - - To create two or more `first' or header lines for a definition, -follow the first `@deffn' line by a line beginning with `@deffnx'. The -`@deffnx' command works exactly like `@deffn' except that it does not -generate extra vertical white space between it and the preceding line. - - For example, - - @deffn {Interactive Command} isearch-forward - @deffnx {Interactive Command} isearch-backward - These two search commands are similar except ... - @end deffn - -produces - - - Interactive Command: isearch-forward - - Interactive Command: isearch-backward - These two search commands are similar except ... - - Each of the other definition commands has an `x' form: `@defunx', -`@defvrx', `@deftypefunx', etc. - - The `x' forms work just like `@itemx'; see *Note `@itemx': itemx. - - -File: texi.info, Node: Def Cmds in Detail, Next: Def Cmd Conventions, Prev: deffnx, Up: Definition Commands - -The Definition Commands -======================= - - Texinfo provides more than a dozen definition commands, all of which -are described in this section. - - The definition commands automatically enter the name of the entity in -the appropriate index: for example, `@deffn', `@defun', and `@defmac' -enter function names in the index of functions; `@defvr' and `@defvar' -enter variable names in the index of variables. - - Although the examples that follow mostly illustrate Lisp, the -commands can be used for other programming languages. - -* Menu: - -* Functions Commands:: Commands for functions and similar entities. -* Variables Commands:: Commands for variables and similar entities. -* Typed Functions:: Commands for functions in typed languages. -* Typed Variables:: Commands for variables in typed languages. -* Abstract Objects:: Commands for object-oriented programming. -* Data Types:: The definition command for data types. - - -File: texi.info, Node: Functions Commands, Next: Variables Commands, Up: Def Cmds in Detail - -Functions and Similar Entities ------------------------------- - - This section describes the commands for describing functions and -similar entities: - -`@deffn CATEGORY NAME ARGUMENTS...' - The `@deffn' command is the general definition command for - functions, interactive commands, and similar entities that may take - arguments. You must choose a term to describe the category of - entity being defined; for example, "Function" could be used if the - entity is a function. The `@deffn' command is written at the - beginning of a line and is followed on the same line by the - category of entity being described, the name of this particular - entity, and its arguments, if any. Terminate the definition with - `@end deffn' on a line of its own. - - For example, here is a definition: - - @deffn Command forward-char nchars - Move point forward @var{nchars} characters. - @end deffn - - This shows a rather terse definition for a "command" named - `forward-char' with one argument, NCHARS. - - `@deffn' prints argument names such as NCHARS in italics or upper - case, as if `@var' had been used, because we think of these names - as metasyntactic variables--they stand for the actual argument - values. Within the text of the description, write an argument name - explicitly with `@var' to refer to the value of the argument. In - the example above, we used `@var{nchars}' in this way. - - The template for `@deffn' is: - - @deffn CATEGORY NAME ARGUMENTS... - BODY-OF-DEFINITION - @end deffn - -`@defun NAME ARGUMENTS...' - The `@defun' command is the definition command for functions. - `@defun' is equivalent to `@deffn Function ...'. - - For example, - - @defun set symbol new-value - Change the value of the symbol @var{symbol} - to @var{new-value}. - @end defun - - shows a rather terse definition for a function `set' whose - arguments are SYMBOL and NEW-VALUE. The argument names on the - `@defun' line automatically appear in italics or upper case as if - they were enclosed in `@var'. Terminate the definition with `@end - defun' on a line of its own. - - The template is: - - @defun FUNCTION-NAME ARGUMENTS... - BODY-OF-DEFINITION - @end defun - - `@defun' creates an entry in the index of functions. - -`@defmac NAME ARGUMENTS...' - The `@defmac' command is the definition command for macros. - `@defmac' is equivalent to `@deffn Macro ...' and works like - `@defun'. - -`@defspec NAME ARGUMENTS...' - The `@defspec' command is the definition command for special - forms. (In Lisp, a special form is an entity much like a - function.) `@defspec' is equivalent to `@deffn {Special Form} ...' - and works like `@defun'. - - -File: texi.info, Node: Variables Commands, Next: Typed Functions, Prev: Functions Commands, Up: Def Cmds in Detail - -Variables and Similar Entities ------------------------------- - - Here are the commands for defining variables and similar entities: - -`@defvr CATEGORY NAME' - The `@defvr' command is a general definition command for something - like a variable--an entity that records a value. You must choose - a term to describe the category of entity being defined; for - example, "Variable" could be used if the entity is a variable. - Write the `@defvr' command at the beginning of a line and followed - it on the same line by the category of the entity and the name of - the entity. - - Capitalize the category name like a title. If the name of the - category contains spaces, as in the name `User Option', write - braces around it. Otherwise, the second word will be mistaken for - the name of the entity, for example: - - @defvr {User Option} fill-column - This buffer-local variable specifies - the maximum width of filled lines. - ... - @end defvr - - Terminate the definition with `@end defvr' on a line of its own. - - The template is: - - @defvr CATEGORY NAME - BODY-OF-DEFINITION - @end defvr - - `@defvr' creates an entry in the index of variables for NAME. - -`@defvar NAME' - The `@defvar' command is the definition command for variables. - `@defvar' is equivalent to `@defvr Variable ...'. - - For example: - - @defvar kill-ring - ... - @end defvar - - The template is: - - @defvar NAME - BODY-OF-DEFINITION - @end defvar - - `@defvar' creates an entry in the index of variables for NAME. - -`@defopt NAME' - The `@defopt' command is the definition command for user options. - `@defopt' is equivalent to `@defvr {User Option} ...' and works - like `@defvar'. - - -File: texi.info, Node: Typed Functions, Next: Typed Variables, Prev: Variables Commands, Up: Def Cmds in Detail - -Functions in Typed Languages ----------------------------- - - The `@deftypefn' command and its variations are for describing -functions in C or any other language in which you must declare types of -variables and functions. - -`@deftypefn CATEGORY DATA-TYPE NAME ARGUMENTS...' - The `@deftypefn' command is the general definition command for - functions and similar entities that may take arguments and that are - typed. The `@deftypefn' command is written at the beginning of a - line and is followed on the same line by the category of entity - being described, the type of the returned value, the name of this - particular entity, and its arguments, if any. - - For example, - - @deftypefn {Library Function} int foobar - (int @var{foo}, float @var{bar}) - ... - @end deftypefn - - (where the text before the "...", shown above as two lines, would - actually be a single line in a real Texinfo file) produces the - following in Info: - - -- Library Function: int foobar (int FOO, float BAR) - ... - - This means that `foobar' is a "library function" that returns an - `int', and its arguments are FOO (an `int') and BAR (a `float'). - - The argument names that you write in `@deftypefn' are not subject - to an implicit `@var'--since the actual names of the arguments in - `@deftypefn' are typically scattered among data type names and - keywords, Texinfo cannot find them without help. Instead, you - must write `@var' explicitly around the argument names. In the - example above, the argument names are `foo' and `bar'. - - The template for `@deftypefn' is: - - @deftypefn CATEGORY DATA-TYPE NAME ARGUMENTS ... - BODY-OF-DESCRIPTION - @end deftypefn - - Note that if the CATEGORY or DATA TYPE is more than one word then - it must be enclosed in braces to make it a single argument. - - If you are describing a procedure in a language that has packages, - such as Ada, you might consider using `@deftypefn' in a manner - somewhat contrary to the convention described in the preceding - paragraphs. - - For example: - - @deftypefn stacks private push - (@var{s}:in out stack; - @var{n}:in integer) - ... - @end deftypefn - - (The `@deftypefn' arguments are shown split into three lines, but - would be a single line in a real Texinfo file.) - - In this instance, the procedure is classified as belonging to the - package `stacks' rather than classified as a `procedure' and its - data type is described as `private'. (The name of the procedure - is `push', and its arguments are S and N.) - - `@deftypefn' creates an entry in the index of functions for NAME. - -`@deftypefun DATA-TYPE NAME ARGUMENTS...' - The `@deftypefun' command is the specialized definition command - for functions in typed languages. The command is equivalent to - `@deftypefn Function ...'. - - Thus, - - @deftypefun int foobar (int @var{foo}, float @var{bar}) - ... - @end deftypefun - - produces the following in Info: - - -- Function: int foobar (int FOO, float BAR) - ... - - The template is: - - @deftypefun TYPE NAME ARGUMENTS... - BODY-OF-DESCRIPTION - @end deftypefun - - `@deftypefun' creates an entry in the index of functions for NAME. - - -File: texi.info, Node: Typed Variables, Next: Abstract Objects, Prev: Typed Functions, Up: Def Cmds in Detail - -Variables in Typed Languages ----------------------------- - - Variables in typed languages are handled in a manner similar to -functions in typed languages. *Note Typed Functions::. The general -definition command `@deftypevr' corresponds to `@deftypefn' and the -specialized definition command `@deftypevar' corresponds to -`@deftypefun'. - -`@deftypevr CATEGORY DATA-TYPE NAME' - The `@deftypevr' command is the general definition command for - something like a variable in a typed language--an entity that - records a value. You must choose a term to describe the category - of the entity being defined; for example, "Variable" could be used - if the entity is a variable. - - The `@deftypevr' command is written at the beginning of a line and - is followed on the same line by the category of the entity being - described, the data type, and the name of this particular entity. - - For example: - - @deftypevr {Global Flag} int enable - ... - @end deftypevr - - produces the following in Info: - - -- Global Flag: int enable - ... - - The template is: - - @deftypevr CATEGORY DATA-TYPE NAME - BODY-OF-DESCRIPTION - @end deftypevr - - `@deftypevr' creates an entry in the index of variables for NAME. - -`@deftypevar DATA-TYPE NAME' - The `@deftypevar' command is the specialized definition command - for variables in typed languages. `@deftypevar' is equivalent to - `@deftypevr Variable ...'. - - For example: - - @deftypevar int fubar - ... - @end deftypevar - - produces the following in Info: - - -- Variable: int fubar - ... - - The template is: - - @deftypevar DATA-TYPE NAME - BODY-OF-DESCRIPTION - @end deftypevar - - `@deftypevar' creates an entry in the index of variables for NAME. - - -File: texi.info, Node: Abstract Objects, Next: Data Types, Prev: Typed Variables, Up: Def Cmds in Detail - -Object-Oriented Programming ---------------------------- - - Here are the commands for formatting descriptions about abstract -objects, such as are used in object-oriented programming. A class is a -defined type of abstract object. An instance of a class is a -particular object that has the type of the class. An instance variable -is a variable that belongs to the class but for which each instance has -its own value. - - In a definition, if the name of a class is truly a name defined in -the programming system for a class, then you should write an `@code' -around it. Otherwise, it is printed in the usual text font. - -`@defcv CATEGORY CLASS NAME' - The `@defcv' command is the general definition command for - variables associated with classes in object-oriented programming. - The `@defcv' command is followed by three arguments: the category - of thing being defined, the class to which it belongs, and its - name. Thus, - - @defcv {Class Option} Window border-pattern - ... - @end defcv - - illustrates how you would write the first line of a definition of - the `border-pattern' class option of the class `Window'. - - The template is - - @defcv CATEGORY CLASS NAME - ... - @end defcv - - `@defcv' creates an entry in the index of variables. - -`@defivar CLASS NAME' - The `@defivar' command is the definition command for instance - variables in object-oriented programming. `@defivar' is - equivalent to `@defcv {Instance Variable} ...' - - The template is: - - @defivar CLASS INSTANCE-VARIABLE-NAME - BODY-OF-DEFINITION - @end defivar - - `@defivar' creates an entry in the index of variables. - -`@defop CATEGORY CLASS NAME ARGUMENTS...' - The `@defop' command is the general definition command for - entities that may resemble methods in object-oriented programming. - These entities take arguments, as functions do, but are associated - with particular classes of objects. - - For example, some systems have constructs called "wrappers" that - are associated with classes as methods are, but that act more like - macros than like functions. You could use `@defop Wrapper' to - describe one of these. - - Sometimes it is useful to distinguish methods and "operations". - You can think of an operation as the specification for a method. - Thus, a window system might specify that all window classes have a - method named `expose'; we would say that this window system - defines an `expose' operation on windows in general. Typically, - the operation has a name and also specifies the pattern of - arguments; all methods that implement the operation must accept - the same arguments, since applications that use the operation do - so without knowing which method will implement it. - - Often it makes more sense to document operations than methods. For - example, window application developers need to know about the - `expose' operation, but need not be concerned with whether a given - class of windows has its own method to implement this operation. - To describe this operation, you would write: - - @defop Operation windows expose - - The `@defop' command is written at the beginning of a line and is - followed on the same line by the overall name of the category of - operation, the name of the class of the operation, the name of the - operation, and its arguments, if any. - - The template is: - - @defop CATEGORY CLASS NAME ARGUMENTS... - BODY-OF-DEFINITION - @end defop - - `@defop' creates an entry, such as ``expose' on `windows'', in the - index of functions. - -`@defmethod CLASS NAME ARGUMENTS...' - The `@defmethod' command is the definition command for methods in - object-oriented programming. A method is a kind of function that - implements an operation for a particular class of objects and its - subclasses. In the Lisp Machine, methods actually were functions, - but they were usually defined with `defmethod'. - - `@defmethod' is equivalent to `@defop Method ...'. The command is - written at the beginning of a line and is followed by the name of - the class of the method, the name of the method, and its - arguments, if any. - - For example, - - @defmethod `bar-class' bar-method argument - ... - @end defmethod - - illustrates the definition for a method called `bar-method' of the - class `bar-class'. The method takes an argument. - - The template is: - - @defmethod CLASS METHOD-NAME ARGUMENTS... - BODY-OF-DEFINITION - @end defmethod - - `@defmethod' creates an entry in the index of functions, such as - ``bar-method' on `bar-class''. - - -File: texi.info, Node: Data Types, Prev: Abstract Objects, Up: Def Cmds in Detail - -Data Types ----------- - - Here is the command for data types: - -`@deftp CATEGORY NAME ATTRIBUTES...' - The `@deftp' command is the generic definition command for data - types. The command is written at the beginning of a line and is - followed on the same line by the category, by the name of the type - (which is a word like `int' or `float'), and then by names of - attributes of objects of that type. Thus, you could use this - command for describing `int' or `float', in which case you could - use `data type' as the category. (A data type is a category of - certain objects for purposes of deciding which operations can be - performed on them.) - - In Lisp, for example, "pair" names a particular data type, and an - object of that type has two slots called the CAR and the CDR. - Here is how you would write the first line of a definition of - `pair'. - - @deftp {Data type} pair car cdr - ... - @end deftp - - The template is: - - @deftp CATEGORY NAME-OF-TYPE ATTRIBUTES... - BODY-OF-DEFINITION - @end deftp - - `@deftp' creates an entry in the index of data types. - - -File: texi.info, Node: Def Cmd Conventions, Next: Sample Function Definition, Prev: Def Cmds in Detail, Up: Definition Commands - -Conventions for Writing Definitions -=================================== - - When you write a definition using `@deffn', `@defun', or one of the -other definition commands, please take care to use arguments that -indicate the meaning, as with the COUNT argument to the `forward-word' -function. Also, if the name of an argument contains the name of a -type, such as INTEGER, take care that the argument actually is of that -type. - - -File: texi.info, Node: Sample Function Definition, Prev: Def Cmd Conventions, Up: Definition Commands - -A Sample Function Definition -============================ - - A function definition uses the `@defun' and `@end defun' commands. -The name of the function follows immediately after the `@defun' command -and it is followed, on the same line, by the parameter list. - - Here is a definition from `The GNU Emacs Lisp Reference Manual'. -(*Note Calling Functions: (elisp)Calling Functions.) - - - Function: apply FUNCTION &rest ARGUMENTS - `apply' calls FUNCTION with ARGUMENTS, just like `funcall' - but with one difference: the last of ARGUMENTS is a list of - arguments to give to FUNCTION, rather than a single argument. - We also say that this list is "appended" to the other - arguments. - - `apply' returns the result of calling FUNCTION. As with - `funcall', FUNCTION must either be a Lisp function or a - primitive function; special forms and macros do not make - sense in `apply'. - - (setq f 'list) - => list - (apply f 'x 'y 'z) - error--> Wrong type argument: listp, z - (apply '+ 1 2 '(3 4)) - => 10 - (apply '+ '(1 2 3 4)) - => 10 - - (apply 'append '((a b c) nil (x y z) nil)) - => (a b c x y z) - - An interesting example of using `apply' is found in the - description of `mapcar'. - - In the Texinfo source file, this example looks like this: - - @defun apply function &rest arguments - - @code{apply} calls @var{function} with - @var{arguments}, just like @code{funcall} but with one - difference: the last of @var{arguments} is a list of - arguments to give to @var{function}, rather than a single - argument. We also say that this list is @dfn{appended} - to the other arguments. - - @code{apply} returns the result of calling - @var{function}. As with @code{funcall}, - @var{function} must either be a Lisp function or a - primitive function; special forms and macros do not make - sense in @code{apply}. - - @example - (setq f 'list) - @result{} list - (apply f 'x 'y 'z) - @error{} Wrong type argument: listp, z - (apply '+ 1 2 '(3 4)) - @result{} 10 - (apply '+ '(1 2 3 4)) - @result{} 10 - - (apply 'append '((a b c) nil (x y z) nil)) - @result{} (a b c x y z) - @end example - - An interesting example of using @code{apply} is found - in the description of @code{mapcar}.@refill - @end defun - -In this manual, this function is listed in the Command and Variable -Index under `apply'. - - Ordinary variables and user options are described using a format like -that for functions except that variables do not take arguments. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-7 b/gnu/usr.bin/texinfo/info-files/texi.info-7 deleted file mode 100644 index 3ea85eee31f9..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-7 +++ /dev/null @@ -1,1307 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Footnotes, Next: Conditionals, Prev: Definition Commands, Up: Top - -Footnotes -********* - - A "footnote" is for a reference that documents or elucidates the -primary text.(1) - - In Texinfo, footnotes are created with the `@footnote' command. -This command is followed immediately by a left brace, then by the text -of the footnote, and then by a terminating right brace. The template -is: - - @footnote{TEXT} - - Footnotes may be of any length, but are usually short. - - For example, this clause is followed by a sample footnote(2); in the -Texinfo source, it looks like this: - - ...a sample footnote @footnote{Here is the sample - footnote.}; in the Texinfo source... - - In a printed manual or book, the reference mark for a footnote is a -small, superscripted number; the text of the footnote is written at the -bottom of the page, below a horizontal line. - - In Info, the reference mark for a footnote is a pair of parentheses -with the footnote number between them, like this: `(1)'. - - Info has two footnote styles, which determine where the text of the -footnote is located: - - * In the `End' node style, all the footnotes for a single node are - placed at the end of that node. The footnotes are separated from - the rest of the node by a line of dashes with the word `Footnotes' - within it. Each footnote begins with an `(N)' reference mark. - - Here is an example of a single footnote in the end of node style: - - --------- Footnotes --------- - - (1) Here is a sample footnote. - - * In the `Separate' node style, all the footnotes for a single node - are placed in an automatically constructed node of their own. In - this style, a "footnote reference" follows each `(N)' reference - mark in the body of the node. The footnote reference is actually - a cross reference which you use to reach the footnote node. - - The name of the node containing the footnotes is constructed by - appending `-Footnotes' to the name of the node that contains the - footnotes. (Consequently, the footnotes' node for the `Footnotes' - node is `Footnotes-Footnotes'!) The footnotes' node has an `Up' - node pointer that leads back to its parent node. - - Here is how the first footnote in this manual looks after being - formatted for Info in the separate node style: - - File: texinfo.info Node: Overview-Footnotes, Up: Overview - - (1) Note that the first syllable of "Texinfo" is - pronounced like "speck", not "hex". ... - - A Texinfo file may be formatted into an Info file with either -footnote style. - - Use the `@footnotestyle' command to specify an Info file's footnote -style. Write this command at the beginning of a line followed by an -argument, either `end' for the end node style or `separate' for the -separate node style. - - For example, - - @footnotestyle end - -or - @footnotestyle separate - - Write an `@footnotestyle' command before or shortly after the -end-of-header line at the beginning of a Texinfo file. (If you include -the `@footnotestyle' command between the start-of-header and -end-of-header lines, the region formatting commands will format -footnotes as specified.) - - If you do not specify a footnote style, the formatting commands use -their default style. Currently, `makeinfo' uses the `end' style, while -`texinfo-format-buffer' and `texinfo-format-region' use the `separate' -style. - - This chapter contains two footnotes. - - ---------- Footnotes ---------- - - (1) A footnote should complement or expand upon the primary text, -but a reader should not need to read a footnote to understand the -primary text. For a thorough discussion of footnotes, see `The Chicago -Manual of Style', which is published by the University of Chicago Press. - - (2) Here is the sample footnote. - - -File: texi.info, Node: Conditionals, Next: Format/Print Hardcopy, Prev: Footnotes, Up: Top - -Conditionally Visible Text -************************** - - Sometimes it is good to use different text for a printed manual and -its corresponding Info file. In this case, you can use the -"conditional commands" to specify which text is for the printed manual -and which is for the Info file. - -* Menu: - -* Conditional Commands:: How to specify text for Info or TeX. -* Using Ordinary TeX Commands:: You can use any and all TeX commands. -* set clear value:: How to designate which text to format (for - both Info and TeX); and how to set a - flag to a string that you can insert. - - -File: texi.info, Node: Conditional Commands, Next: Using Ordinary TeX Commands, Up: Conditionals - -Using `@ifinfo' and `@iftex' -============================ - - `@ifinfo' begins segments of text that should be ignored by TeX when -it typesets the printed manual. The segment of text appears only in -the Info file. The `@ifinfo' command should appear on a line by -itself; end the Info-only text with a line containing `@end ifinfo' by -itself. At the beginning of a Texinfo file, the Info permissions are -contained within a region marked by `@ifinfo' and `@end ifinfo'. (*Note -Info Summary and Permissions::.) - - The `@iftex' and `@end iftex' commands are similar to the `@ifinfo' -and `@end ifinfo' commands, except that they specify text that will -appear in the printed manual but not in the Info file. - - For example, - - @iftex - This text will appear only in the printed manual. - @end iftex - - @ifinfo - However, this text will appear only in Info. - @end ifinfo - -The preceding example produces the following line: - - However, this text will appear only in Info. - -Note how you only see one of the two lines, depending on whether you -are reading the Info version or the printed version of this manual. - - The `@titlepage' command is a special variant of `@iftex' that is -used for making the title and copyright pages of the printed manual. -(*Note `@titlepage': titlepage.) - - -File: texi.info, Node: Using Ordinary TeX Commands, Next: set clear value, Prev: Conditional Commands, Up: Conditionals - -Using Ordinary TeX Commands -=========================== - - Inside a region delineated by `@iftex' and `@end iftex', you can -embed some PlainTeX commands. Info will ignore these commands since -they are only in that part of the file which is seen by TeX. You can -write the TeX commands as you would write them in a normal TeX file, -except that you must replace the `\' used by TeX with an `@'. For -example, in the `@titlepage' section of a Texinfo file, you can use the -TeX command `@vskip' to format the copyright page. (The `@titlepage' -command causes Info to ignore the region automatically, as it does with -the `@iftex' command.) - - However, many features of PlainTeX will not work, as they are -overridden by features of Texinfo. - - You can enter PlainTeX completely, and use `\' in the TeX commands, -by delineating a region with the `@tex' and `@end tex' commands. (The -`@tex' command also causes Info to ignore the region, like the `@iftex' -command.) - - For example, here is a mathematical expression written in PlainTeX: - - @tex - $$ \chi^2 = \sum_{i=1}^N - \left (y_i - (a + b x_i) - \over \sigma_i\right)^2 $$ - @end tex - -The output of this example will appear only in a printed manual. If -you are reading this in Info, you will not see anything after this -paragraph. - - -File: texi.info, Node: set clear value, Prev: Using Ordinary TeX Commands, Up: Conditionals - -`@set', `@clear', and `@value' -============================== - - You can direct the Texinfo formatting commands to format or ignore -parts of a Texinfo file with the `@set', `@clear', `@ifset', and -`@ifclear' commands. - - In addition, you can use the `@set FLAG' command to set the value of -FLAG to a string of characters; and use `@value{FLAG}' to insert that -string. You can use `@set', for example, to set a date and use -`@value' to insert the date in several places in the Texinfo file. - -* Menu: - -* ifset ifclear:: Format a region if a flag is set. -* value:: Replace a flag with a string. -* value Example:: An easy way to update edition information. - - -File: texi.info, Node: ifset ifclear, Next: value, Up: set clear value - -`@ifset' and `@ifclear' ------------------------ - - When a FLAG is set, the Texinfo formatting commands format text -between subsequent pairs of `@ifset FLAG' and `@end ifset' commands. -When the FLAG is cleared, the Texinfo formatting commands do *not* -format the text. - - Use the `@set FLAG' command to turn on, or "set", a FLAG; a "flag" -can be any single word. The format for the command looks like this: - - @set FLAG - - Write the conditionally formatted text between `@ifset FLAG' and -`@end ifset' commands, like this: - - @ifset FLAG - CONDITIONAL-TEXT - @end ifset - - For example, you can create one document that has two variants, such -as a manual for a `large' and `small' model: - - You can use this machine to dig up shrubs - without hurting them. - - @set large - - @ifset large - It can also dig up fully grown trees. - @end ifset - - Remember to replant promptly ... - -In the example, the formatting commands will format the text between -`@ifset large' and `@end ifset' because the `large' flag is set. - - Use the `@clear FLAG' command to turn off, or "clear", a flag. -Clearing a flag is the opposite of setting a flag. The command looks -like this: - - @clear FLAG - -Write the command on a line of its own. - - When FLAG is cleared, the Texinfo formatting commands do *not* -format the text between `@ifset FLAG' and `@end ifset'; that text is -ignored and does not appear in either printed or Info output. - - For example, if you clear the flag of the preceding example by -writing an `@clear large' command after the `@set large' command (but -before the conditional text), then the Texinfo formatting commands -ignore the text between the `@ifset large' and `@end ifset' commands. -In the formatted output, that text does not appear; in both printed and -Info output, you see only the lines that say, "You can use this machine -to dig up shrubs without hurting them. Remember to replant promptly -...". - - If a flag is cleared with an `@clear FLAG' command, then the -formatting commands format text between subsequent pairs of `@ifclear' -and `@end ifclear' commands. But if the flag is set with `@set FLAG', -then the formatting commands do *not* format text between an `@ifclear' -and an `@end ifclear' command; rather, they ignore that text. An -`@ifclear' command looks like this: - - @ifclear FLAG - - In brief, the commands are: - -`@set FLAG' - Tell the Texinfo formatting commands that FLAG is set. - -`@clear FLAG' - Tell the Texinfo formatting commands that FLAG is cleared. - -`@ifset FLAG' - If FLAG is set, tell the Texinfo formatting commands to format the - text up to the following `@end ifset' command. - - If FLAG is cleared, tell the Texinfo formatting commands to ignore - text up to the following `@end ifset' command. - -`@ifclear FLAG' - If FLAG is set, tell the Texinfo formatting commands to ignore the - text up to the following `@end ifclear' command. - - If FLAG is cleared, tell the Texinfo formatting commands to format - the text up to the following `@end ifclear' command. - - -File: texi.info, Node: value, Next: value Example, Prev: ifset ifclear, Up: set clear value - -`@value' --------- - - You can use the `@set' command to specify a value for a flag, which -is expanded by the `@value' command. The value is a string a -characters. - - Write the `@set' command like this: - - @set foo This is a string. - -This sets the value of `foo' to "This is a string." - - The Texinfo formatters replace an `@value{FLAG}' command with the -string to which FLAG is set. - - Thus, when `foo' is set as shown above, the Texinfo formatters -convert - - @value{foo} -to - This is a string. - - You can write an `@value' command within a paragraph; but you must -write an `@set' command on a line of its own. - - If you write the `@set' command like this: - - @set foo - -without specifying a string, the value of `foo' is an empty string. - - If you clear a previously set flag with an `@clear FLAG' command, a -subsequent `@value{flag}' command is invalid and the string is replaced -with an error message that says `{No value for "FLAG"}'. - - For example, if you set `foo' as follows: - - @set how-much very, very, very - -then the formatters transform - - It is a @value{how-much} wet day. -into - It is a very, very, very wet day. - - If you write - - @clear how-much - -then the formatters transform - - It is a @value{how-much} wet day. -into - It is a {No value for "how-much"} wet day. - - -File: texi.info, Node: value Example, Prev: value, Up: set clear value - -`@value' Example ----------------- - - You can use the `@value' command to limit the number of places you -need to change when you record an update to a manual. Here is how it -is done in `The GNU Make Manual': - -Set the flags: - - @set EDITION 0.35 Beta - @set VERSION 3.63 Beta - @set UPDATED 14 August 1992 - @set UPDATE-MONTH August 1992 - -Write text for the first `@ifinfo' section, for people reading the -Texinfo file: - - This is Edition @value{EDITION}, - last updated @value{UPDATED}, - of @cite{The GNU Make Manual}, - for @code{make}, Version @value{VERSION}. - -Write text for the title page, for people reading the printed manual: - - @title GNU Make - @subtitle A Program for Directing Recompilation - @subtitle Edition @value{EDITION}, ... - @subtitle @value{UPDATE-MONTH} - -(On a printed cover, a date listing the month and the year looks less -fussy than a date listing the day as well as the month and year.) - -Write text for the Top node, for people reading the Info file: - - This is Edition @value{EDITION} - of the @cite{GNU Make Manual}, - last updated @value{UPDATED} - for @code{make} Version @value{VERSION}. - - After you format the manual, the text in the first `@ifinfo' section -looks like this: - - This is Edition 0.35 Beta, last updated 14 August 1992, - of `The GNU Make Manual', for `make', Version 3.63 Beta. - - When you update the manual, change only the values of the flags; you -do not need to rewrite the three sections. - - -File: texi.info, Node: Format/Print Hardcopy, Next: Create an Info File, Prev: Conditionals, Up: Top - -Format and Print Hardcopy -************************* - - There are three major shell commands for making a printed manual -from a Texinfo file: one for converting the Texinfo file into a file -that will be printed, a second for sorting indices, and a third for -printing the formatted document. When you use the shell commands, you -can either work directly in the operating system shell or work within a -shell inside GNU Emacs. - - If you are using GNU Emacs, you can use commands provided by Texinfo -mode instead of shell commands. In addition to the three commands to -format a file, sort the indices, and print the result, Texinfo mode -offers key bindings for commands to recenter the output buffer, show the -print queue, and delete a job from the print queue. - -* Menu: - -* Use TeX:: Use TeX to format for hardcopy. -* Shell Format & Print:: How to format and print a hardcopy manual - with shell commands. -* Within Emacs:: How to format and print from an Emacs shell. -* Texinfo Mode Printing:: How to format and print in Texinfo mode. -* Compile-Command:: How to print using Emacs's compile command. -* Requirements Summary:: TeX formatting requirements summary. -* Preparing for TeX:: What you need to do to use TeX. -* Overfull hboxes:: What are and what to do with overfull hboxes. -* smallbook:: How to print small format books and manuals. -* A4 Paper:: How to print on European A4 paper. -* Cropmarks and Magnification:: How to print marks to indicate the size - of pages and how to print scaled up output. - - -File: texi.info, Node: Use TeX, Next: Shell Format & Print, Up: Format/Print Hardcopy - -Use TeX -======= - - The typesetting program called TeX is used for formatting a Texinfo -file. TeX is a very powerful typesetting program and, if used right, -does an exceptionally good job. *Note How to Obtain TeX: Obtaining -TeX, for information on how to obtain TeX. - - The `makeinfo', `texinfo-format-region', and `texinfo-format-buffer' -commands read the very same @-commands in the Texinfo file as does TeX, -but process them differently to make an Info file; see *Note Create an -Info File::. - - -File: texi.info, Node: Shell Format & Print, Next: Within Emacs, Prev: Use TeX, Up: Format/Print Hardcopy - -Format and Print Using Shell Commands -===================================== - - Format the Texinfo file with the shell command `tex' followed by the -name of the Texinfo file. This produces a formatted DVI file as well -as several auxiliary files containing indices, cross references, etc. -The DVI file (for "DeVice Independent" file) can be printed on a wide -variety of printers. - - The `tex' formatting command itself does not sort the indices; it -writes an output file of unsorted index data. This is a misfeature of -TeX. Hence, to generate a printed index, you first need a sorted index -to work from. The `texindex' command sorts indices. (The source file -`texindex.c' comes as part of the standard GNU distribution and is -usually installed when Emacs is installed.) - - The `tex' formatting command outputs unsorted index files under -names that obey a standard convention. These names are the name of -your main input file to the `tex' formatting command, with everything -after the first period thrown away, and the two letter names of indices -added at the end. For example, the raw index output files for the -input file `foo.texinfo' would be `foo.cp', `foo.vr', `foo.fn', -`foo.tp', `foo.pg' and `foo.ky'. Those are exactly the arguments to -give to `texindex'. - - Or else, you can use `??' as "wild-cards" and give the command in -this form: - - texindex foo.?? - -This command will run `texindex' on all the unsorted index files, -including any that you have defined yourself using `@defindex' or -`@defcodeindex'. (You may execute `texindex foo.??' even if there are -similarly named files with two letter extensions that are not index -files, such as `foo.el'. The `texindex' command reports but otherwise -ignores such files.) - - For each file specified, `texindex' generates a sorted index file -whose name is made by appending `s' to the input file name. The -`@printindex' command knows to look for a file of that name. -`texindex' does not alter the raw index output file. - - After you have sorted the indices, you need to rerun the `tex' -formatting command on the Texinfo file. This regenerates a formatted -DVI file with up-to-date index entries.(1) - - To summarize, this is a three step process: - - 1. Run the `tex' formatting command on the Texinfo file. This - generates the formatted DVI file as well as the raw index files - with two letter extensions. - - 2. Run the shell command `texindex' on the raw index files to sort - them. This creates the corresponding sorted index files. - - 3. Rerun the `tex' formatting command on the Texinfo file. This - regenerates a formatted DVI file with the index entries in the - correct order. This second run also corrects the page numbers for - the cross references. (The tables of contents are always correct.) - - You need not run `texindex' each time after you run the `tex' -formatting. If you do not, on the next run, the `tex' formatting -command will use whatever sorted index files happen to exist from the -previous use of `texindex'. This is usually OK while you are debugging. - - Rather than type the `tex' and `texindex' commands yourself, you can -use `texi2dvi'. This shell script is designed to simplify the -`tex'--`texindex'--`tex' sequence by figuring out whether index files -and DVI files are up-to-date. It runs `texindex' and `tex' only when -necessary. - - The syntax for `texi2dvi' is like this (where `%' is the shell -prompt): - - % texi2dvi FILENAME... - - Finally, you can print the DVI file with the DVI print command. The -precise command to use depends on the system; `lpr -d' is common. The -DVI print command may require a file name without any extension or with -a `.dvi' extension. - - The following commands, for example, sort the indices, format, and -print the `Bison Manual' (where `%' is the shell prompt): - - % tex bison.texinfo - % texindex bison.?? - % tex bison.texinfo - % lpr -d bison.dvi - -(Remember that the shell commands may be different at your site; but -these are commonly used versions.) - - ---------- Footnotes ---------- - - (1) If you use more than one index and have cross references to an -index other than the first, you must run `tex' *three times* to get -correct output: once to generate raw index data; again (after -`texindex') to output the text of the indices and determine their true -page numbers; and a third time to output correct page numbers in cross -references to them. However, cross references to indices are rare. - - -File: texi.info, Node: Within Emacs, Next: Texinfo Mode Printing, Prev: Shell Format & Print, Up: Format/Print Hardcopy - -From an Emacs Shell ... -======================= - - You can give formatting and printing commands from a shell within GNU -Emacs. To create a shell within Emacs, type `M-x shell'. In this -shell, you can format and print the document. *Note How to Format and -Print Using Shell Commands: Shell Format & Print, for details. - - You can switch to and from the shell buffer while `tex' is running -and do other editing. If you are formatting a long document on a slow -machine, this can be very convenient. - - You can also use `texi2dvi' from an Emacs shell. For example, here -is how to use `texi2dvi' to format and print `Using and Porting GNU CC' -from a shell within Emacs (where `%' is the shell prompt): - - % texi2dvi gcc.texinfo - % lpr -d gcc.dvi - - *Note Texinfo Mode Printing::, for more information about formatting -and printing in Texinfo mode. - - -File: texi.info, Node: Texinfo Mode Printing, Next: Compile-Command, Prev: Within Emacs, Up: Format/Print Hardcopy - -Formatting and Printing in Texinfo Mode -======================================= - - Texinfo mode provides several predefined key commands for TeX -formatting and printing. These include commands for sorting indices, -looking at the printer queue, killing the formatting job, and -recentering the display of the buffer in which the operations occur. - -`C-c C-t C-r' -`M-x texinfo-tex-region' - Run TeX on the current region. - -`C-c C-t C-b' -`M-x texinfo-tex-buffer' - Run TeX on the current buffer. - -`C-c C-t C-i' -`M-x texinfo-texindex' - Sort the indices of a Texinfo file that have been formatted with - `texinfo-tex-region' or `texinfo-tex-buffer'. - -`C-c C-t C-p' -`M-x texinfo-tex-print' - Print a DVI file that was made with `texinfo-tex-region' or - `texinfo-tex-buffer'. - -`C-c C-t C-q' -`M-x texinfo-show-tex-print-queue' - Show the print queue. - -`C-c C-t C-d' -`M-x texinfo-delete-from-tex-print-queue' - Delete a job from the print queue; you will be prompted for the job - number shown by a preceding `C-c C-t C-q' command - (`texinfo-show-tex-print-queue'). - -`C-c C-t C-k' -`M-x texinfo-kill-tex-job' - Kill either the currently running TeX job that has been started by - `texinfo-tex-region' or `texinfo-tex-buffer', or any other process - running in the Texinfo shell buffer. - -`C-c C-t C-x' -`M-x texinfo-quit-tex-job' - Quit a TeX formatting job that has stopped because of an error by - sending an x to it. When you do this, TeX preserves a record of - what it did in a `.log' file. - -`C-c C-t C-l' -`M-x texinfo-recenter-tex-output-buffer' - Redisplay the shell buffer in which the TeX printing and formatting - commands are run to show its most recent output. - - Thus, the usual sequence of commands for formatting a buffer is as -follows (with comments to the right): - - C-c C-t C-b Run TeX on the buffer. - C-c C-t C-i Sort the indices. - C-c C-t C-b Rerun TeX to regenerate indices. - C-c C-t C-p Print the DVI file. - C-c C-t C-q Display the printer queue. - - The Texinfo mode TeX formatting commands start a subshell in Emacs -called the `*texinfo-tex-shell*'. The `texinfo-tex-command', -`texinfo-texindex-command', and `tex-dvi-print-command' commands are -all run in this shell. - - You can watch the commands operate in the `*texinfo-tex-shell*' -buffer, and you can switch to and from and use the -`*texinfo-tex-shell*' buffer as you would any other shell buffer. - - The formatting and print commands depend on the values of several -variables. The default values are: - - Variable Default value - - texinfo-tex-command "tex" - texinfo-texindex-command "texindex" - texinfo-tex-shell-cd-command "cd" - texinfo-tex-dvi-print-command "lpr -d" - texinfo-show-tex-queue-command "lpq" - texinfo-delete-from-print-queue-command "lprm" - texinfo-start-of-header "%**start" - texinfo-end-of-header "%**end" - texinfo-tex-trailer "@bye" - - The default values of both the `texinfo-tex-command' and the -`texinfo-texindex-command' variables are set in the `texnfo-tex.el' -file. - - You can change the values of these variables with the `M-x -edit-options' command (*note Editing Variable Values: (emacs)Edit -Options.), with the `M-x set-variable' command (*note Examining and -Setting Variables: (emacs)Examining.), or with your `.emacs' -initialization file (*note Init File: (emacs)Init File.). - - -File: texi.info, Node: Compile-Command, Next: Requirements Summary, Prev: Texinfo Mode Printing, Up: Format/Print Hardcopy - -Using the Local Variables List -============================== - - Yet another way to apply the TeX formatting command to a Texinfo -file is to put that command in a "local variables list" at the end of -the Texinfo file. You can then specify the TeX formatting command as a -`compile-command' and have Emacs run the TeX formatting command by -typing `M-x compile'. This creates a special shell called the -`*compilation buffer*' in which Emacs runs the compile command. For -example, at the end of the `gdb.texinfo' file, after the `@bye', you -would put the following: - - @c Local Variables: - @c compile-command: "tex gdb.texinfo" - @c End: - -This technique is most often used by programmers who also compile -programs this way; see *Note Compilation: (emacs)Compilation. - - -File: texi.info, Node: Requirements Summary, Next: Preparing for TeX, Prev: Compile-Command, Up: Format/Print Hardcopy - -TeX Formatting Requirements Summary -=================================== - - Every Texinfo file that is to be input to TeX must begin with a -`\input' command and contain an `@settitle' command: - - \input texinfo - @settitle NAME-OF-MANUAL - -The first command instructs TeX to load the macros it needs to process -a Texinfo file and the second command specifies the title of printed -manual. - - Every Texinfo file must end with a line that terminates TeX -processing and forces out unfinished pages: - - @bye - - Strictly speaking, these three lines are all a Texinfo file needs for -TeX, besides the body. (The `@setfilename' line is the only line that -a Texinfo file needs for Info formatting.) - - Usually, the file's first line contains an `@c -*-texinfo-*-' -comment that causes Emacs to switch to Texinfo mode when you edit the -file. In addition, the beginning usually includes an `@setfilename' -for Info formatting, an `@setchapternewpage' command, a title page, a -copyright page, and permissions. Besides an `@bye', the end of a file -usually includes indices and a table of contents. - -For more information, see -*Note `@setchapternewpage': setchapternewpage, -*Note Page Headings: Headings, -*Note Titlepage & Copyright Page::, -*Note Printing Indices & Menus::, and -*Note Contents::. - - -File: texi.info, Node: Preparing for TeX, Next: Overfull hboxes, Prev: Requirements Summary, Up: Format/Print Hardcopy - -Preparing to Use TeX -==================== - -TeX needs to know where to find the `texinfo.tex' file that you have -told it to input with the `\input texinfo' command at the beginning of -the first line. The `texinfo.tex' file tells TeX how to handle -@-commands. (`texinfo.tex' is included in the standard GNU -distributions.) - - Usually, the `texinfo.tex' file is put in the default directory that -contains TeX macros (the `/usr/lib/tex/macros' directory) when GNU -Emacs or other GNU software is installed. In this case, TeX will find -the file and you do not need to do anything special. Alternatively, -you can put `texinfo.tex' in the directory in which the Texinfo source -file is located, and TeX will find it there. - - However, you may want to specify the location of the `\input' file -yourself. One way to do this is to write the complete path for the file -after the `\input' command. Another way is to set the `TEXINPUTS' -environment variable in your `.cshrc' or `.profile' file. The -`TEXINPUTS' environment variable will tell TeX where to find the -`texinfo.tex' file and any other file that you might want TeX to use. - - Whether you use a `.cshrc' or `.profile' file depends on whether you -use `csh', `sh', or `bash' for your shell command interpreter. When -you use `csh', it looks to the `.cshrc' file for initialization -information, and when you use `sh' or `bash', it looks to the -`.profile' file. - - In a `.cshrc' file, you could use the following `csh' command -sequence: - - setenv TEXINPUTS .:/usr/me/mylib:/usr/lib/tex/macros - - In a `.profile' file, you could use the following `sh' command -sequence: - - TEXINPUTS=.:/usr/me/mylib:/usr/lib/tex/macros - export TEXINPUTS - -This would cause TeX to look for `\input' file first in the current -directory, indicated by the `.', then in a hypothetical user's -`me/mylib' directory, and finally in the system library. - - -File: texi.info, Node: Overfull hboxes, Next: smallbook, Prev: Preparing for TeX, Up: Format/Print Hardcopy - -Overfull "hboxes" -================= - - TeX is sometimes unable to typeset a line without extending it into -the right margin. This can occur when TeX comes upon what it -interprets as a long word that it cannot hyphenate, such as an -electronic mail network address or a very long title. When this -happens, TeX prints an error message like this: - - Overfull \hbox (20.76302pt too wide) - -(In TeX, lines are in "horizontal boxes", hence the term, "hbox". The -backslash, `\', is the TeX equivalent of `@'.) - - TeX also provides the line number in the Texinfo source file and the -text of the offending line, which is marked at all the places that TeX -knows how to hyphenate words. *Note Catching Errors with TeX -Formatting: Debugging with TeX, for more information about typesetting -errors. - - If the Texinfo file has an overfull hbox, you can rewrite the -sentence so the overfull hbox does not occur, or you can decide to -leave it. A small excursion into the right margin often does not -matter and may not even be noticeable. - - However, unless told otherwise, TeX will print a large, ugly, black -rectangle beside the line that contains the overful hbox. This is so -you will notice the location of the problem if you are correcting a -draft. - - To prevent such a monstrosity from marring your final printout, write -the following in the beginning of the Texinfo file on a line of its own, -before the `@titlepage' command: - - @finalout - - -File: texi.info, Node: smallbook, Next: A4 Paper, Prev: Overfull hboxes, Up: Format/Print Hardcopy - -Printing "Small" Books -====================== - - By default, TeX typesets pages for printing in an 8.5 by 11 inch -format. However, you can direct TeX to typeset a document in a 7 by -9.25 inch format that is suitable for bound books by inserting the -following command on a line by itself at the beginning of the Texinfo -file, before the title page: - - @smallbook - -(Since regular sized books are often about 7 by 9.25 inches, this -command might better have been called the `@regularbooksize' command, -but it came to be called the `@smallbook' command by comparison to the -8.5 by 11 inch format.) - - If you write the `@smallbook' command between the start-of-header -and end-of-header lines, the Texinfo mode TeX region formatting -command, `texinfo-tex-region', will format the region in "small" book -size (*note Start of Header::.). - - The Free Software Foundation distributes printed copies of `The GNU -Emacs Manual' and other manuals in the "small" book size. *Note -`@smallexample' and `@smalllisp': smallexample & smalllisp, for -information about commands that make it easier to produce examples for -a smaller manual. - - -File: texi.info, Node: A4 Paper, Next: Cropmarks and Magnification, Prev: smallbook, Up: Format/Print Hardcopy - -Printing on A4 Paper -==================== - - You can tell TeX to typeset a document for printing on European size -A4 paper with the `@afourpaper' command. Write the command on a line -by itself between `@iftex' and `@end iftex' lines near the beginning of -the Texinfo file, before the title page: - - For example, this is how you would write the header for this manual: - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename texinfo - @settitle Texinfo - @syncodeindex vr fn - @iftex - @afourpaper - @end iftex - @c %**end of header - - -File: texi.info, Node: Cropmarks and Magnification, Prev: A4 Paper, Up: Format/Print Hardcopy - -Cropmarks and Magnification -=========================== - - You can attempt to direct TeX to print cropmarks at the corners of -pages with the `@cropmarks' command. Write the `@cropmarks' command on -a line by itself between `@iftex' and `@end iftex' lines near the -beginning of the Texinfo file, before the title page, like this: - - @iftex - @cropmarks - @end iftex - - This command is mainly for printers that typeset several pages on one -sheet of film; but you can attempt to use it to mark the corners of a -book set to 7 by 9.25 inches with the `@smallbook' command. (Printers -will not produce cropmarks for regular sized output that is printed on -regular sized paper.) Since different printing machines work in -different ways, you should explore the use of this command with a -spirit of adventure. You may have to redefine the command in the -`texinfo.tex' definitions file. - - You can attempt to direct TeX to typeset pages larger or smaller than -usual with the `\mag' TeX command. Everything that is typeset is -scaled proportionally larger or smaller. (`\mag' stands for -"magnification".) This is *not* a Texinfo @-command, but is a PlainTeX -command that is prefixed with a backslash. You have to write this -command between `@tex' and `@end tex' (*note Using Ordinary TeX -Commands: Using Ordinary TeX Commands.). - - Follow the `\mag' command with an `=' and then a number that is 1000 -times the magnification you desire. For example, to print pages at 1.2 -normal size, write the following near the beginning of the Texinfo -file, before the title page: - - @tex - \mag=1200 - @end tex - - With some printing technologies, you can print normal-sized copies -that look better than usual by using a larger-than-normal master. - - Depending on your system, `\mag' may not work or may work only at -certain magnifications. Be prepared to experiment. - - -File: texi.info, Node: Create an Info File, Next: Install an Info File, Prev: Format/Print Hardcopy, Up: Top - -Creating an Info File -********************* - - `makeinfo' is a utility that converts a Texinfo file into an Info -file; `texinfo-format-region' and `texinfo-format-buffer' are GNU Emacs -functions that do the same. - - A Texinfo file must possess an `@setfilename' line near its -beginning, otherwise the Info formatting commands will fail. - - For information on installing the Info file in the Info system, see -*Note Install an Info File::. - -* Menu: - -* makeinfo advantages:: `makeinfo' provides better error checking. -* Invoking makeinfo:: How to run `makeinfo' from a shell. -* makeinfo options:: Specify fill-column and other options. -* Pointer Validation:: How to check that pointers point somewhere. -* makeinfo in Emacs:: How to run `makeinfo' from Emacs. -* texinfo-format commands:: Two Info formatting commands written - in Emacs Lisp are an alternative - to `makeinfo'. -* Batch Formatting:: How to format for Info in Emacs Batch mode. -* Tag and Split Files:: How tagged and split files help Info - to run better. - - -File: texi.info, Node: makeinfo advantages, Next: Invoking makeinfo, Up: Create an Info File - -`makeinfo' Preferred -==================== - - The `makeinfo' utility creates an Info file from a Texinfo source -file more quickly than either of the Emacs formatting commands and -provides better error messages. We recommend it. `makeinfo' is a C -program that is independent of Emacs. You do not need to run Emacs to -use `makeinfo', which means you can use `makeinfo' on machines that are -too small to run Emacs. You can run `makeinfo' in any one of three -ways: from an operating system shell, from a shell inside Emacs, or by -typing a key command in Texinfo mode in Emacs. - - The `texinfo-format-region' and the `texinfo-format-buffer' commands -are useful if you cannot run `makeinfo'. Also, in some circumstances, -they format short regions or buffers more quickly than `makeinfo'. - - -File: texi.info, Node: Invoking makeinfo, Next: makeinfo options, Prev: makeinfo advantages, Up: Create an Info File - -Invoking `makeinfo' from a Shell -================================ - - To create an Info file from a Texinfo file, type `makeinfo' followed -by the name of the Texinfo file. Thus, to create the Info file for -Bison, type the following at the shell prompt (where `%' is the prompt): - - % makeinfo bison.texinfo - - (You can run a shell inside Emacs by typing `M-x shell'.) - - Sometimes you will want to specify options. For example, if you wish -to discover which version of `makeinfo' you are using, type: - - % makeinfo --version - - *Note makeinfo options::, for more information. - - -File: texi.info, Node: makeinfo options, Next: Pointer Validation, Prev: Invoking makeinfo, Up: Create an Info File - -Options for `makeinfo' -====================== - - The `makeinfo' command takes a number of options. Most often, -options are used to set the value of the fill column and specify the -footnote style. Each command line option is a word preceded by `--'(1) -or a letter preceded by `-'. You can use abbreviations for the option -names as long as they are unique. - - For example, you could use the following command to create an Info -file for `bison.texinfo' in which each line is filled to only 68 -columns (where `%' is the prompt): - - % makeinfo --fill-column=68 bison.texinfo - - You can write two or more options in sequence, like this: - - % makeinfo --no-split --fill-column=70 ... - -This would keep the Info file together as one possibly very long file -and would also set the fill column to 70. - - The options are: - -`-D VAR' - Cause VAR to be defined. This is equivalent to `@set VAR' in the - Texinfo file. - -`--error-limit LIMIT' - Set the maximum number of errors that `makeinfo' will report - before exiting (on the assumption that continuing would be - useless). The default number of errors that can be reported before - `makeinfo' gives up is 100. - -`--fill-column WIDTH' - Specify the maximum number of columns in a line; this is the - right-hand edge of a line. Paragraphs that are filled will be - filled to this width. (Filling is the process of breaking up and - connecting lines so that lines are the same length as or shorter - than the number specified as the fill column. Lines are broken - between words.) The default value for `fill-column' is 72. - -`--footnote-style STYLE' - Set the footnote style to STYLE, either `end' for the end node - style or `separate' for the separate node style. The value set by - this option overrides the value set in a Texinfo file by an - `@footnotestyle' command. When the footnote style is `separate', - `makeinfo' makes a new node containing the footnotes found in the - current node. When the footnote style is `end', `makeinfo' places - the footnote references at the end of the current node. - -`-I DIR' - Add `dir' to the directory search list for finding files that are - included using the `@include' command. By default, `makeinfo' - searches only the current directory. - -`--no-headers' - Do not include menus or node lines in the output. This results in - an ASCII file that you cannot read in Info since it does not - contain the requisite nodes or menus; but you can print such a - file in a single, typewriter-like font and produce acceptable - output. - -`--no-split' - Suppress the splitting stage of `makeinfo'. Normally, large - output files (where the size is greater than 70k bytes) are split - into smaller subfiles, each one approximately 50k bytes. If you - specify `--no-split', `makeinfo' will not split up the output file. - -`--no-pointer-validate' -`--no-validate' - Suppress the pointer-validation phase of `makeinfo'. Normally, - after a Texinfo file is processed, some consistency checks are - made to ensure that cross references can be resolved, etc. *Note - Pointer Validation::. - -`--no-warn' - Suppress the output of warning messages. This does *not* suppress - the output of error messages, only warnings. You might want this - if the file you are creating has examples of Texinfo cross - references within it, and the nodes that are referenced do not - actually exist. - -`--no-number-footnotes' - Supress automatic footnote numbering. By default, `makeinfo' - numbers each footnote sequentially in a single node, resetting the - current footnote number to 1 at the start of each node. - -`--output FILE' -`-o FILE' - Specify that the output should be directed to FILE and not to the - file name specified in the `@setfilename' command found in the - Texinfo source. FILE can be the special token `-', which specifies - standard output. - -`--paragraph-indent INDENT' - Set the paragraph indentation style to INDENT. The value set by - this option overrides the value set in a Texinfo file by an - `@paragraphindent' command. The value of INDENT is interpreted as - follows: - - * If the value of INDENT is `asis', do not change the existing - indentation at the starts of paragraphs. - - * If the value of INDENT is zero, delete any existing - indentation. - - * If the value of INDENT is greater than zero, indent each - paragraph by that number of spaces. - -`--reference-limit LIMIT' - Set the value of the number of references to a node that - `makeinfo' will make without reporting a warning. If a node has - more than this number of references in it, `makeinfo' will make the - references but also report a warning. - -`-U VAR' - Cause VAR to be undefined. This is equivalent to `@clear VAR' in - the Texinfo file. - -`--verbose' - Cause `makeinfo' to display messages saying what it is doing. - Normally, `makeinfo' only outputs messages if there are errors or - warnings. - -`--version' - Report the version number of this copy of `makeinfo'. - - ---------- Footnotes ---------- - - (1) `--' has replaced `+', the old introductory character, to -maintain POSIX.2 compatibility without losing long-named options. - - -File: texi.info, Node: Pointer Validation, Next: makeinfo in Emacs, Prev: makeinfo options, Up: Create an Info File - -Pointer Validation -================== - - `makeinfo' will check the validity of the final Info file unless you -suppress pointer-validation by using the `--no-pointer-validation' -option. Mostly, this means ensuring that nodes you have referenced -really exist. Here is a complete list of what is checked: - - 1. If a `Next', `Previous', or `Up' node reference is a reference to a - node in the current file and is not an external reference such as - to `(dir)', then the referenced node must exist. - - 2. In every node, if the `Previous' node is different from the `Up' - node, then the `Previous' node must also be pointed to by a `Next' - node. - - 3. Every node except the `Top' node must have an `Up' pointer. - - 4. The node referenced by an `Up' pointer must contain a reference to - the current node in some manner other than through a `Next' - reference. This includes menu entries and cross references. - - 5. If the `Next' reference of a node is not the same as the `Next' - reference of the `Up' reference, then the node referenced by the - `Next' pointer must have a `Previous' pointer that points back to - the current node. This rule allows the last node in a section to - point to the first node of the next chapter. - - -File: texi.info, Node: makeinfo in Emacs, Next: texinfo-format commands, Prev: Pointer Validation, Up: Create an Info File - -Running `makeinfo' inside Emacs -=============================== - - You can run `makeinfo' in GNU Emacs Texinfo mode by using either the -`makeinfo-region' or the `makeinfo-buffer' commands. In Texinfo mode, -the commands are bound to `C-c C-m C-r' and `C-c C-m C-b' by default. - -`C-c C-m C-r' -`M-x makeinfo-region' - Format the current region for Info. - -`C-c C-m C-b' -`M-x makeinfo-buffer' - Format the current buffer for Info. - - When you invoke either `makeinfo-region' or `makeinfo-buffer', Emacs -prompts for a file name, offering the name of the visited file as the -default. You can edit the default file name in the minibuffer if you -wish, before typing RET to start the `makeinfo' process. - - The Emacs `makeinfo-region' and `makeinfo-buffer' commands run the -`makeinfo' program in a temporary shell buffer. If `makeinfo' finds -any errors, Emacs displays the error messages in the temporary buffer. - - You can parse the error messages by typing `C-x `' (`next-error'). -This causes Emacs to go to and position the cursor on the line in the -Texinfo source that `makeinfo' thinks caused the error. *Note Running -`make' or Compilers Generally: (emacs)Compilation, for more information -about using the `next-error' command. - - In addition, you can kill the shell in which the `makeinfo' command -is running or make the shell buffer display its most recent output. - -`C-c C-m C-k' -`M-x makeinfo-kill-job' - Kill the currently running job created by `makeinfo-region' or - `makeinfo-buffer'. - -`C-c C-m C-l' -`M-x makeinfo-recenter-output-buffer' - Redisplay the `makeinfo' shell buffer to display its most recent - output. - -(Note that the parallel commands for killing and recentering a TeX job -are `C-c C-t C-k' and `C-c C-t C-l'. *Note Texinfo Mode Printing::.) - - You can specify options for `makeinfo' by setting the -`makeinfo-options' variable with either the `M-x edit-options' or the -`M-x set-variable' command, or by setting the variable in your `.emacs' -initialization file. - - For example, you could write the following in your `.emacs' file: - - (setq makeinfo-options - "--paragraph-indent=0 --no-split - --fill-column=70 --verbose") - -For more information, see -*Note Editing Variable Values: (emacs)Edit Options, -*Note Examining and Setting Variables: (emacs)Examining, -*Note Init File: (emacs)Init File, and -*Note Options for `makeinfo': makeinfo options. - - -File: texi.info, Node: texinfo-format commands, Next: Batch Formatting, Prev: makeinfo in Emacs, Up: Create an Info File - -The `texinfo-format...' Commands -================================ - -In GNU Emacs in Texinfo mode, you can format part or all of a Texinfo -file with the `texinfo-format-region' command. This formats the -current region and displays the formatted text in a temporary buffer -called `*Info Region*'. - - Similarly, you can format a buffer with the `texinfo-format-buffer' -command. This command creates a new buffer and generates the Info file -in it. Typing `C-x C-s' will save the Info file under the name -specified by the `@setfilename' line which must be near the beginning -of the Texinfo file. - -`C-c C-e C-r' -``texinfo-format-region'' - Format the current region for Info. - -`C-c C-e C-b' -``texinfo-format-buffer'' - Format the current buffer for Info. - - The `texinfo-format-region' and `texinfo-format-buffer' commands -provide you with some error checking, and other functions can provide -you with further help in finding formatting errors. These procedures -are described in an appendix; see *Note Catching Mistakes::. However, -the `makeinfo' program is often faster and provides better error -checking (*note makeinfo in Emacs::.). - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-8 b/gnu/usr.bin/texinfo/info-files/texi.info-8 deleted file mode 100644 index ba35e6eddf38..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-8 +++ /dev/null @@ -1,1056 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Batch Formatting, Next: Tag and Split Files, Prev: texinfo-format commands, Up: Create an Info File - -Batch Formatting -================ - - You can format Texinfo files for Info using `batch-texinfo-format' -and Emacs Batch mode. You can run Emacs in Batch mode from any shell, -including a shell inside of Emacs. (*Note Command Line Switches and -Arguments: (emacs)Command Switches.) - - Here is the command to format all the files that end in `.texinfo' -in the current directory (where `%' is the shell prompt): - - % emacs -batch -funcall batch-texinfo-format *.texinfo - -Emacs processes all the files listed on the command line, even if an -error occurs while attempting to format some of them. - - Run `batch-texinfo-format' only with Emacs in Batch mode as shown; -it is not interactive. It kills the Batch mode Emacs on completion. - - `batch-texinfo-format' is convenient if you lack `makeinfo' and want -to format several Texinfo files at once. When you use Batch mode, you -create a new Emacs process. This frees your current Emacs, so you can -continue working in it. (When you run `texinfo-format-region' or -`texinfo-format-buffer', you cannot use that Emacs for anything else -until the command finishes.) - - -File: texi.info, Node: Tag and Split Files, Prev: Batch Formatting, Up: Create an Info File - -Tag Files and Split Files -========================= - - If a Texinfo file has more than 30,000 bytes, -`texinfo-format-buffer' automatically creates a tag table for its Info -file; `makeinfo' always creates a tag table. With a "tag table", Info -can jump to new nodes more quickly than it can otherwise. - - In addition, if the Texinfo file contains more than about 70,000 -bytes, `texinfo-format-buffer' and `makeinfo' split the large Info file -into shorter "indirect" subfiles of about 50,000 bytes each. Big files -are split into smaller files so that Emacs does not need to make a -large buffer to hold the whole of a large Info file; instead, Emacs -allocates just enough memory for the small, split off file that is -needed at the time. This way, Emacs avoids wasting memory when you run -Info. (Before splitting was implemented, Info files were always kept -short and "include files" were designed as a way to create a single, -large printed manual out of the smaller Info files. *Note Include -Files::, for more information. Include files are still used for very -large documents, such as `The Emacs Lisp Reference Manual', in which -each chapter is a separate file.) - - When a file is split, Info itself makes use of a shortened version of -the original file that contains just the tag table and references to -the files that were split off. The split off files are called -"indirect" files. - - The split off files have names that are created by appending `-1', -`-2', `-3' and so on to the file name specified by the `@setfilename' -command. The shortened version of the original file continues to have -the name specified by `@setfilename'. - - At one stage in writing this document, for example, the Info file -was saved as `test-texinfo' and that file looked like this: - - Info file: test-texinfo, -*-Text-*- - produced by texinfo-format-buffer - from file: new-texinfo-manual.texinfo - - ^_ - Indirect: - test-texinfo-1: 102 - test-texinfo-2: 50422 - test-texinfo-3: 101300 - ^_^L - Tag table: - (Indirect) - Node: overview^?104 - Node: info file^?1271 - Node: printed manual^?4853 - Node: conventions^?6855 - ... - -(But `test-texinfo' had far more nodes than are shown here.) Each of -the split off, indirect files, `test-texinfo-1', `test-texinfo-2', and -`test-texinfo-3', is listed in this file after the line that says -`Indirect:'. The tag table is listed after the line that says `Tag -table:'. - - In the list of indirect files, the number following the file name -records the cumulative number of bytes in the preceding indirect files, -not counting the file list itself, the tag table, or the permissions -text in each file. In the tag table, the number following the node name -records the location of the beginning of the node, in bytes from the -beginning. - - If you are using `texinfo-format-buffer' to create Info files, you -may want to run the `Info-validate' command. (The `makeinfo' command -does such a good job on its own, you do not need `Info-validate'.) -However, you cannot run the `M-x Info-validate' node-checking command -on indirect files. For information on how to prevent files from being -split and how to validate the structure of the nodes, see *Note Using -Info-validate::. - - -File: texi.info, Node: Install an Info File, Next: Command List, Prev: Create an Info File, Up: Top - -Installing an Info File -*********************** - - Info files are usually kept in the `info' directory. (You can find -the location of this directory within Emacs by typing `C-h i' to enter -Info and then typing `C-x C-f' to see the full pathname to the `info' -directory.) - -* Menu: - -* Directory file:: The top level menu for all Info files. -* New Info File:: Listing a new info file. -* Other Info Directories:: How to specify Info files that are - located in other directories. - - -File: texi.info, Node: Directory file, Next: New Info File, Up: Install an Info File - -The `dir' File -============== - - For Info to work, the `info' directory must contain a file that -serves as a top level directory for the Info system. By convention, -this file is called `dir'. The `dir' file is itself an Info file. It -contains the top level menu for all the Info files in the system. The -menu looks like this: - - * Menu: - - * Info: (info). Documentation browsing system. - * Emacs: (emacs). The extensible, self-documenting - text editor. - * Texinfo: (texinfo). With one source file, make - either a printed manual using - TeX or an Info file. - ... - - Each of these menu entries points to the `Top' node of the Info file -that is named in parentheses. (The menu entry does not need to specify -the `Top' node, since Info goes to the `Top' node if no node name is -mentioned. *Note Nodes in Other Info Files: Other Info Files.) - - Thus, the `Info' entry points to the `Top' node of the `info' file -and the `Emacs' entry points to the `Top' node of the `emacs' file. - - In each of the Info files, the `Up' pointer of the `Top' node refers -back to the `dir' file. For example, the line for the `Top' node of -the Emacs manual looks like this in Info: - - File: emacs Node: Top, Up: (DIR), Next: Distrib - -(Note that in this case, the `dir' file name is written in upper case -letters--it can be written in either upper or lower case. Info has a -feature that it will change the case of the file name to lower case if -it cannot find the name as written.) - - -File: texi.info, Node: New Info File, Next: Other Info Directories, Prev: Directory file, Up: Install an Info File - -Listing a New Info File -======================= - - To add a new Info file to your system, write a menu entry for it in -the menu in the `dir' file in the `info' directory. Also, move the new -Info file itself to the `info' directory. For example, if you were -adding documentation for GDB, you would write the following new entry: - - * GDB: (gdb). The source-level C debugger. - -The first part of the menu entry is the menu entry name, followed by a -colon. The second part is the name of the Info file, in parentheses, -followed by a period. The third part is the description. - - Conventionally, the name of an Info file has a `.info' extension. -Thus, you might list the name of the file like this: - - * GDB: (gdb.info). The source-level C debugger. - -However, Info will look for a file with a `.info' extension if it does -not find the file under the name given in the menu. This means that -you can refer to the file `gdb.info' as `gdb', as shown in the first -example. This looks better. - - -File: texi.info, Node: Other Info Directories, Prev: New Info File, Up: Install an Info File - -Info Files in Other Directories -=============================== - - If an Info file is not in the `info' directory, there are two ways -to specify its location: - - * Write the pathname as the menu's second part, or; - - * Specify the `info' directory name in an environment variable in - your `.profile' or `.cshrc' initialization file. (Only you and - others with the same environment variable will be able to find Info - files whose location is specified this way.) - - For example, to reach a test file in the `~bob/manuals' directory, -you could add an entry like this to the menu in the `dir' file: - - * Test: (~bob/manuals/info-test). Bob's own test file. - -In this case, the absolute file name of the `info-test' file is written -as the second part of the menu entry. - - Alternatively, you can tell Info where to look by setting the -`INFOPATH' environment variable in your `.cshrc' or `.profile' file. - - If you use `sh' or `bash' for your shell command interpreter, you -must set the `INFOPATH' environment variable in the `.profile' -initialization file; but if you use `csh', you must set the variable in -the `.cshrc' initialization file. The two files require slightly -different command formats. - - * In a `.cshrc' file, you could set the `INFOPATH' variable as - follows: - - setenv INFOPATH .:~bob/manuals:/usr/local/emacs/info - - * In a `.profile' file, you would achieve the same effect by writing: - - INFOPATH=.:~bob/manuals:/usr/local/emacs/info - export INFOPATH - -Either form would cause Info to look first in the current directory, -indicated by the `.', then in the `~bob/manuals' directory, and finally -in the `/usr/local/emacs/info' directory (which is a common location -for the standard Info directory). - - -File: texi.info, Node: Command List, Next: Tips, Prev: Install an Info File, Up: Top - -@-Command List -************** - - Here is an alphabetical list of the @-commands in Texinfo. Square -brackets, [ ], indicate optional arguments; an ellipsis, `...', -indicates repeated text. - -`@*' - Force a line break. Do not end a paragraph that uses `@*' with an - `@refill' command. *Note Line Breaks::. - -`@.' - Stands for a period that really does end a sentence (usually after - an end-of-sentence capital letter). *Note Controlling Spacing::. - -`@:' - Indicate to TeX that an immediately preceding period, question - mark, exclamation mark, or colon does not end a sentence. Prevent - TeX from inserting extra whitespace as it does at the end of a - sentence. The command has no effect on the Info file output. - *Note Controlling Spacing::. - -`@@' - Stands for `@'. *Note Inserting `@': Braces Atsigns Periods. - -`@{' - Stands for a left-hand brace, `{'. *Note Inserting @ braces and - periods: Braces Atsigns Periods. - -`@}' - Stands for a right-hand brace, `}'. *Note Inserting @ braces and - periods: Braces Atsigns Periods. - -`@appendix TITLE' - Begin an appendix. The title appears in the table of contents of - a printed manual. In Info, the title is underlined with - asterisks. *Note The `@unnumbered' and `@appendix' Commands: - unnumbered & appendix. - -`@appendixsec TITLE' -`@appendixsection TITLE' - Begin an appendix section within an appendix. The section title - appears in the table of contents of a printed manual. In Info, - the title is underlined with equal signs. `@appendixsection' is a - longer spelling of the `@appendixsec' command. *Note Section - Commands: unnumberedsec appendixsec heading. - -`@appendixsubsec TITLE' - Begin an appendix subsection within an appendix. The title appears - in the table of contents of a printed manual. In Info, the title - is underlined with hyphens. *Note Subsection Commands: - unnumberedsubsec appendixsubsec subheading. - -`@appendixsubsubsec TITLE' - Begin an appendix subsubsection within a subappendix. The title - appears in the table of contents of a printed manual. In Info, the - title is underlined with periods. *Note The `subsub' Commands: - subsubsection. - -`@asis' - Used following `@table', `@ftable', and `@vtable' to print the - table's first column without highlighting ("as is"). *Note Making - a Two-column Table: Two-column Tables. - -`@author AUTHOR' - Typeset AUTHOR flushleft and underline it. *Note The `@title' and - `@author' Commands: title subtitle author. - -`@b{TEXT}' - Print TEXT in bold font. No effect in Info. *Note Fonts::. - -`@bullet{}' - Generate a large round dot, or the closest possible thing to one. - *Note `@bullet': bullet. - -`@bye' - Stop formatting a file. The formatters do not see the contents of - a file following an `@bye' command. *Note Ending a File::. - -`@c COMMENT' - Begin a comment in Texinfo. The rest of the line does not appear - in either the Info file or the printed manual. A synonym for - `@comment'. *Note General Syntactic Conventions: Conventions. - -`@cartouche' - Highlight an example or quotation by drawing a box with rounded - corners around it. Pair with `@end cartouche'. No effect in - Info. *Note Drawing Cartouches Around Examples: cartouche.) - -`@center LINE-OF-TEXT' - Center the line of text following the command. *Note `@center': - titlefont center sp. - -`@chapheading TITLE' - Print a chapter-like heading in the text, but not in the table of - contents of a printed manual. In Info, the title is underlined - with asterisks. *Note `@majorheading' and `@chapheading': - majorheading & chapheading. - -`@chapter TITLE' - Begin a chapter. The chapter title appears in the table of - contents of a printed manual. In Info, the title is underlined - with asterisks. *Note `@chapter': chapter. - -`@cindex ENTRY' - Add ENTRY to the index of concepts. *Note Defining the Entries of - an Index: Index Entries. - -`@cite{REFERENCE}' - Highlight the name of a book or other reference that lacks a - companion Info file. *Note `@cite': cite. - -`@clear FLAG' - Unset FLAG, preventing the Texinfo formatting commands from - formatting text between subsequent pairs of `@ifset FLAG' and - `@end ifset' commands, and preventing `@value{FLAG}' from - expanding to the value to which FLAG is set. *Note `@set' - `@clear' `@value': set clear value. - -`@code{SAMPLE-CODE}' - Highlight text that is an expression, a syntactically complete - token of a program, or a program name. *Note `@code': code. - -`@comment COMMENT' - Begin a comment in Texinfo. The rest of the line does not appear - in either the Info file or the printed manual. A synonym for `@c'. - *Note General Syntactic Conventions: Conventions. - -`@contents' - Print a complete table of contents. Has no effect in Info, which - uses menus instead. *Note Generating a Table of Contents: - Contents. - -`@copyright{}' - Generate a copyright symbol. *Note `@copyright': copyright symbol. - -`@defcodeindex INDEX-NAME' - Define a new index and its indexing command. Print entries in an - `@code' font. *Note Defining New Indices: New Indices. - -`@defcv CATEGORY CLASS NAME' - Format a description for a variable associated with a class in - object-oriented programming. Takes three arguments: the category - of thing being defined, the class to which it belongs, and its - name. *Note Definition Commands::. - -`@deffn CATEGORY NAME ARGUMENTS...' - Format a description for a function, interactive command, or - similar entity that may take arguments. `@deffn' takes as - arguments the category of entity being described, the name of this - particular entity, and its arguments, if any. *Note Definition - Commands::. - -`@defindex INDEX-NAME' - Define a new index and its indexing command. Print entries in a - roman font. *Note Defining New Indices: New Indices. - -`@defivar CLASS INSTANCE-VARIABLE-NAME' - Format a description for an instance variable in object-oriented - programming. The command is equivalent to `@defcv {Instance - Variable} ...'. *Note Definition Commands::. - -`@defmac MACRO-NAME ARGUMENTS...' - Format a description for a macro. The command is equivalent to - `@deffn Macro ...'. *Note Definition Commands::. - -`@defmethod CLASS METHOD-NAME ARGUMENTS...' - Format a description for a method in object-oriented programming. - The command is equivalent to `@defop Method ...'. Takes as - arguments the name of the class of the method, the name of the - method, and its arguments, if any. *Note Definition Commands::. - -`@defop CATEGORY CLASS NAME ARGUMENTS...' - Format a description for an operation in object-oriented - programming. `@defop' takes as arguments the overall name of the - category of operation, the name of the class of the operation, the - name of the operation, and its arguments, if any. *Note - Definition Commands::. - -`@defopt OPTION-NAME' - Format a description for a user option. The command is equivalent - to `@defvr {User Option} ...'. *Note Definition Commands::. - -`@defspec SPECIAL-FORM-NAME ARGUMENTS...' - Format a description for a special form. The command is - equivalent to `@deffn {Special Form} ...'. *Note Definition - Commands::. - -`@deftp CATEGORY NAME-OF-TYPE ATTRIBUTES...' - Format a description for a data type. `@deftp' takes as arguments - the category, the name of the type (which is a word like `int' or - `float'), and then the names of attributes of objects of that - type. *Note Definition Commands::. - -`@deftypefn CLASSIFICATION DATA-TYPE NAME ARGUMENTS...' - Format a description for a function or similar entity that may take - arguments and that is typed. `@deftypefn' takes as arguments the - classification of entity being described, the type, the name of - the entity, and its arguments, if any. *Note Definition - Commands::. - -`@deftypefun DATA-TYPE FUNCTION-NAME ARGUMENTS...' - Format a description for a function in a typed language. The - command is equivalent to `@deftypefn Function ...'. *Note - Definition Commands::. - -`@deftypevr CLASSIFICATION DATA-TYPE NAME' - Format a description for something like a variable in a typed - language--an entity that records a value. Takes as arguments the - classification of entity being described, the type, and the name of - the entity. *Note Definition Commands::. - -`@deftypevar DATA-TYPE VARIABLE-NAME' - Format a description for a variable in a typed language. The - command is equivalent to `@deftypevr Variable ...'. *Note - Definition Commands::. - -`@defun FUNCTION-NAME ARGUMENTS...' - Format a description for functions. The command is equivalent to - `@deffn Function ...'. *Note Definition Commands::. - -`@defvar VARIABLE-NAME' - Format a description for variables. The command is equivalent to - `@defvr Variable ...'. *Note Definition Commands::. - -`@defvr CATEGORY NAME' - Format a description for any kind of variable. `@defvr' takes as - arguments the category of the entity and the name of the entity. - *Note Definition Commands::. - -`@dfn{TERM}' - Highlight the introductory or defining use of a term. *Note - `@dfn': dfn. - -`@display' - Begin a kind of example. Indent text, do not fill, do not select a - new font. Pair with `@end display'. *Note `@display': display. - -`@dmn{DIMENSION}' - Format a dimension. Cause TeX to insert a narrow space before - DIMENSION. No effect in Info. Use for writing a number followed - by an abbreviation of a dimension name, such as `12pt', written as - `12@dmn{pt}', with no space between the number and the `@dmn' - command. *Note `@dmn': dmn. - -`@dots{}' - Insert an ellipsis: `...'. *Note `@dots': dots. - -`@emph{TEXT}' - Highlight TEXT; text is displayed in *italics* in printed output, - and surrounded by asterisks in Info. *Note Emphasizing Text: - Emphasis. - -`@enumerate [NUMBER-OR-LETTER]' - Begin a numbered list, using `@item' for each entry. Optionally, - start list with NUMBER-OR-LETTER. Pair with `@end enumerate'. - *Note `@enumerate': enumerate. - -`@equiv{}' - Indicate to the reader the exact equivalence of two forms with a - glyph: `=='. *Note Equivalence::. - -`@error{}' - Indicate to the reader with a glyph that the following text is an - error message: `error-->'. *Note Error Glyph::. - -`@evenfooting [LEFT] @| [CENTER] @| [RIGHT]' - Specify page footings for even-numbered (left-hand) pages. Not - relevant to Info. *Note How to Make Your Own Headings: Custom - Headings. - -`@evenheading [LEFT] @| [CENTER] @| [RIGHT]' - Specify page headings for even-numbered (left-hand) pages. Not - relevant to Info. *Note How to Make Your Own Headings: Custom - Headings. - -`@everyfooting [LEFT] @| [CENTER] @| [RIGHT]' - Specify page footings for every page. Not relevant to Info. - *Note How to Make Your Own Headings: Custom Headings. - -`@everyheading [LEFT] @| [CENTER] @| [RIGHT]' - Specify page headings for every page. Not relevant to Info. - *Note How to Make Your Own Headings: Custom Headings. - -`@example' - Begin an example. Indent text, do not fill, and select - fixed-width font. Pair with `@end example'. *Note `@example': - example. - -`@exdent LINE-OF-TEXT' - Remove any indentation a line might have. *Note Undoing the - Indentation of a Line: exdent. - -`@expansion{}' - Indicate the result of a macro expansion to the reader with a - special glyph: `==>'. *Note ==> Indicating an Expansion: - expansion. - -`@file{FILENAME}' - Highlight the name of a file, buffer, node, or directory. *Note - `@file': file. - -`@finalout' - Prevent TeX from printing large black warning rectangles beside - over-wide lines. *Note Overfull hboxes::. - -`@findex ENTRY' - Add ENTRY to the index of functions. *Note Defining the Entries - of an Index: Index Entries. - -`@flushleft' - Left justify every line but leave the right end ragged. Leave - font as is. Pair with `@end flushleft'. *Note `@flushleft' and - `@flushright': flushleft & flushright. - -`@flushright' - Right justify every line but leave the left end ragged. Leave - font as is. Pair with `@end flushright'. *Note `@flushleft' and - `@flushright': flushleft & flushright. - -`@footnote{TEXT-OF-FOOTNOTE}' - Enter a footnote. Footnote text is printed at the bottom of the - page by TeX; Info may format in either `End' node or `Separate' - node style. *Note Footnotes::. - -`@footnotestyle STYLE' - Specify an Info file's footnote style, either `end' for the end - node style or `separate' for the separate node style. *Note - Footnotes::. - -`@format' - Begin a kind of example. Like `@example' or `@display', but do - not narrow the margins and do not select the fixed-width font. - Pair with `@end format'. *Note `@example': example. - -`@ftable FORMATTING-COMMAND' - Begin a two-column table, using `@item' for each entry. - Automatically enter each of the items in the first column into the - index of functions. Pair with `@end ftable'. The same as - `@table', except for indexing. *Note `@ftable' and `@vtable': - ftable vtable. - -`@group' - Hold text together that must appear on one printed page. Pair with - `@end group'. Not relevant to Info. *Note `@group': group. - -`@heading TITLE' - Print an unnumbered section-like heading in the text, but not in - the table of contents of a printed manual. In Info, the title is - underlined with equal signs. *Note Section Commands: - unnumberedsec appendixsec heading. - -`@headings ON-OFF-SINGLE-DOUBLE' - Turn page headings on or off, or specify single-sided or - double-sided page headings for printing. `@headings on' is - synonymous with `@headings double'. *Note The `@headings' - Command: headings on off. - -`@i{TEXT}' - Print TEXT in italic font. No effect in Info. *Note Fonts::. - -`@ifclear FLAG' - If FLAG is cleared, the Texinfo formatting commands format text - between `@ifclear FLAG' and the following `@end ifclear' command. - *Note `@set' `@clear' `@value': set clear value. - -`@ifinfo' - Begin a stretch of text that will be ignored by TeX when it - typesets the printed manual. The text appears only in the Info - file. Pair with `@end ifinfo'. *Note Conditionally Visible Text: - Conditionals. - -`@ifset FLAG' - If FLAG is set, the Texinfo formatting commands format text - between `@ifset FLAG' and the following `@end ifset' command. - *Note `@set' `@clear' `@value': set clear value. - -`@iftex' - Begin a stretch of text that will not appear in the Info file, but - will be processed only by TeX. Pair with `@end iftex'. *Note - Conditionally Visible Text: Conditionals. - -`@ignore' - Begin a stretch of text that will not appear in either the Info - file or the printed output. Pair with `@end ignore'. *Note - Comments and Ignored Text: Comments. - -`@include FILENAME' - Incorporate the contents of the file FILENAME into the Info file - or printed document. *Note Include Files::. - -`@inforef{NODE-NAME, [ENTRY-NAME], INFO-FILE-NAME}' - Make a cross reference to an Info file for which there is no - printed manual. *Note Cross references using `@inforef': inforef. - -`\input MACRO-DEFINITIONS-FILE' - Use the specified macro definitions file. This command is used - only in the first line of a Texinfo file to cause TeX to make use - of the `texinfo' macro definitions file. The backslash in `\input' - is used instead of an `@' because TeX does not properly recognize - `@' until after it has read the definitions file. *Note The - Texinfo File Header: Header. - -`@item' - Indicate the beginning of a marked paragraph for `@itemize' and - `@enumerate'; indicate the beginning of the text of a first column - entry for `@table', `@ftable', and `@vtable'. *Note Lists and - Tables::. - -`@itemize MARK-GENERATING-CHARACTER-OR-COMMAND' - Produce a sequence of indented paragraphs, with a mark inside the - left margin at the beginning of each paragraph. Pair with `@end - itemize'. *Note `@itemize': itemize. - -`@itemx' - Like `@item' but do not generate extra vertical space above the - item text. *Note `@itemx': itemx. - -`@kbd{KEYBOARD-CHARACTERS}' - Indicate text that consists of characters of input to be typed by - users. *Note `@kbd': kbd. - -`@key{KEY-NAME}' - Highlight KEY-NAME, a conventional name for a key on a keyboard. - *Note `@key': key. - -`@kindex ENTRY' - Add ENTRY to the index of keys. *Note Defining the Entries of an - Index: Index Entries. - -`@lisp' - Begin an example of Lisp code. Indent text, do not fill, and - select fixed-width font. Pair with `@end lisp'. *Note `@lisp': - Lisp Example. - -`@majorheading TITLE' - Print a chapter-like heading in the text, but not in the table of - contents of a printed manual. Generate more vertical whitespace - before the heading than the `@chapheading' command. In Info, the - chapter heading line is underlined with asterisks. *Note - `@majorheading' and `@chapheading': majorheading & chapheading. - -`@menu' - Mark the beginning of a menu of nodes in Info. No effect in a - printed manual. Pair with `@end menu'. *Note Menus::. - -`@minus{}' - Generate a minus sign. *Note `@minus': minus. - -`@need N' - Start a new page in a printed manual if fewer than N mils - (thousandths of an inch) remain on the current page. *Note - `@need': need. - -`@node NAME, NEXT, PREVIOUS, UP' - Define the beginning of a new node in Info, and serve as a locator - for references for TeX. *Note `@node': node. - -`@noindent' - Prevent text from being indented as if it were a new paragraph. - *Note `@noindent': noindent. - -`@oddfooting [LEFT] @| [CENTER] @| [RIGHT]' - Specify page footings for odd-numbered (right-hand) pages. Not - relevant to Info. *Note How to Make Your Own Headings: Custom - Headings. - -`@oddheading [LEFT] @| [CENTER] @| [RIGHT]' - Specify page headings for odd-numbered (right-hand) pages. Not - relevant to Info. *Note How to Make Your Own Headings: Custom - Headings. - -`@page' - Start a new page in a printed manual. No effect in Info. *Note - `@page': page. - -`@paragraphindent INDENT' - Indent paragraphs by INDENT number of spaces; delete indentation - if the value of INDENT is 0; and do not change indentation if - INDENT is `asis'. *Note Paragraph Indenting: paragraphindent. - -`@pindex ENTRY' - Add ENTRY to the index of programs. *Note Defining the Entries of - an Index: Index Entries. - -`@point{}' - Indicate the position of point in a buffer to the reader with a - glyph: `-!-'. *Note Indicating Point in a Buffer: Point Glyph. - -`@print{}' - Indicate printed output to the reader with a glyph: `-|'. *Note - Print Glyph::. - -`@printindex INDEX-NAME' - Print an alphabetized two-column index in a printed manual or - generate an alphabetized menu of index entries for Info. *Note - Printing Indices & Menus::. - -`@pxref{NODE-NAME, [ENTRY], [TOPIC-OR-TITLE], [INFO-FILE], [MANUAL]}' - Make a reference that starts with a lower case `see' in a printed - manual. Use within parentheses only. Do not follow command with a - punctuation mark. The Info formatting commands automatically - insert terminating punctuation as needed, which is why you do not - need to insert punctuation. Only the first argument is mandatory. - *Note `@pxref': pxref. - -`@quotation' - Narrow the margins to indicate text that is quoted from another - real or imaginary work. Write command on a line of its own. Pair - with `@end quotation'. *Note `@quotation': quotation. - -`@r{TEXT}' - Print TEXT in roman font. No effect in Info. *Note Fonts::. - -`@ref{NODE-NAME, [ENTRY], [TOPIC-OR-TITLE], [INFO-FILE], [MANUAL]}' - Make a reference. In a printed manual, the reference does not - start with a `See'. Follow command with a punctuation mark. Only - the first argument is mandatory. *Note `@ref': ref. - -`@refill' - In Info, refill and indent the paragraph after all the other - processing has been done. No effect on TeX, which always refills. - This command is no longer needed, since all formatters now - automatically refill. *Note Refilling Paragraphs::. - -`@result{}' - Indicate the result of an expression to the reader with a special - glyph: `=>'. *Note `@result': result. - -`@samp{TEXT}' - Highlight TEXT that is a literal example of a sequence of - characters. Used for single characters, for statements, and often - for entire shell commands. *Note `@samp': samp. - -`@sc{TEXT}' - Set TEXT in a printed output in THE SMALL CAPS FONT and set text - in the Info file in uppercase letters. *Note Smallcaps::. - -`@section TITLE' - Begin a section within a chapter. In a printed manual, the section - title is numbered and appears in the table of contents. In Info, - the title is underlined with equal signs. *Note `@section': - section. - -`@set FLAG [STRING]' - Make FLAG active, causing the Texinfo formatting commands to - format text between subsequent pairs of `@ifset FLAG' and `@end - ifset' commands. Optionally, set value of FLAG to STRING. *Note - `@set' `@clear' `@value': set clear value. - -`@setchapternewpage ON-OFF-ODD' - Specify whether chapters start on new pages, and if so, whether on - odd-numbered (right-hand) new pages. *Note `@setchapternewpage': - setchapternewpage. - -`@setfilename INFO-FILE-NAME' - Provide a name for the Info file. *Note General Syntactic - Conventions: Conventions. - -`@settitle TITLE' - Provide a title for page headers in a printed manual. *Note - General Syntactic Conventions: Conventions. - -`@shortcontents' - Print a short table of contents. Not relevant to Info, which uses - menus rather than tables of contents. A synonym for - `@summarycontents'. *Note Generating a Table of Contents: - Contents. - -`@smallbook' - Cause TeX to produce a printed manual in a 7 by 9.25 inch format - rather than the regular 8.5 by 11 inch format. *Note Printing - Small Books: smallbook. Also, see *Note `@smallexample' and - `@smalllisp': smallexample & smalllisp. - -`@smallexample' - Indent text to indicate an example. Do not fill, select - fixed-width font. In `@smallbook' format, print text in a smaller - font than with `@example'. Pair with `@end smallexample'. *Note - `@smallexample' and `@smalllisp': smallexample & smalllisp. - -`@smalllisp' - Begin an example of Lisp code. Indent text, do not fill, select - fixed-width font. In `@smallbook' format, print text in a smaller - font. Pair with `@end smalllisp'. *Note `@smallexample' and - `@smalllisp': smallexample & smalllisp. - -`@sp N' - Skip N blank lines. *Note `@sp': sp. - -`@strong TEXT' - Emphasize TEXT by typesetting it in a *bold* font for the printed - manual and by surrounding it with asterisks for Info. *Note - Emphasizing Text: emph & strong. - -`@subheading TITLE' - Print an unnumbered subsection-like heading in the text, but not in - the table of contents of a printed manual. In Info, the title is - underlined with hyphens. *Note `@unnumberedsubsec' - `@appendixsubsec' `@subheading': unnumberedsubsec appendixsubsec - subheading. - -`@subsection TITLE' - Begin a subsection within a section. In a printed manual, the - subsection title is numbered and appears in the table of contents. - In Info, the title is underlined with hyphens. *Note - `@subsection': subsection. - -`@subsubheading TITLE' - Print an unnumbered subsubsection-like heading in the text, but - not in the table of contents of a printed manual. In Info, the - title is underlined with periods. *Note The `subsub' Commands: - subsubsection. - -`@subsubsection TITLE' - Begin a subsubsection within a subsection. In a printed manual, - the subsubsection title is numbered and appears in the table of - contents. In Info, the title is underlined with periods. *Note - The `subsub' Commands: subsubsection. - -`@subtitle TITLE' - In a printed manual, set a subtitle in a normal sized font flush to - the right-hand side of the page. Not relevant to Info, which does - not have title pages. *Note `@title' `@subtitle' and `@author' - Commands: title subtitle author. - -`@summarycontents' - Print a short table of contents. Not relevant to Info, which uses - menus rather than tables of contents. A synonym for - `@shortcontents'. *Note Generating a Table of Contents: Contents. - -`@syncodeindex FROM-INDEX INTO-INDEX' - Merge the index named in the first argument into the index named in - the second argument, printing the entries from the first index in - `@code' font. *Note Combining Indices::. - -`@synindex FROM-INDEX INTO-INDEX' - Merge the index named in the first argument into the index named in - the second argument. Do not change the font of FROM-INDEX - entries. *Note Combining Indices::. - -`@t{TEXT}' - Print TEXT in a fixed-width, typewriter-like font. No effect in - Info. *Note Fonts::. - -`@table FORMATTING-COMMAND' - Begin a two-column table, using `@item' for each entry. Write - each first column entry on the same line as `@item'. First column - entries are printed in the font resulting from FORMATTING-COMMAND. - Pair with `@end table'. *Note Making a Two-column Table: - Two-column Tables. Also see *Note `@ftable' and `@vtable': ftable - vtable, and *Note `@itemx': itemx. - -`@TeX{}' - Insert the logo TeX. *Note Inserting TeX and (C): TeX and - copyright. - -`@tex' - Enter TeX completely. Pair with `@end tex'. *Note Using Ordinary - TeX Commands: Using Ordinary TeX Commands. - -`@thischapter' - In a heading or footing, stands for the number and name of the - current chapter, in the format `Chapter 1: Title'. *Note How to - Make Your Own Headings: Custom Headings. - -`@thischaptername' - In a heading or footing, stands for the name of the current - chapter. *Note How to Make Your Own Headings: Custom Headings. - -`@thisfile' - In a heading or footing, stands for the name of the current - `@include' file. Does not insert anything if not within an - `@include' file. *Note How to Make Your Own Headings: Custom - Headings. - -`@thispage' - In a heading or footing, stands for the current page number. - *Note How to Make Your Own Headings: Custom Headings. - -`@thistitle' - In a heading or footing, stands for the name of the document, as - specified by the `@settitle' command. *Note How to Make Your Own - Headings: Custom Headings. - -`@tindex ENTRY' - Add ENTRY to the index of data types. *Note Defining the Entries - of an Index: Index Entries. - -`@title TITLE' - In a printed manual, set a title flush to the left-hand side of the - page in a larger than normal font and underline it with a black - rule. Not relevant to Info, which does not have title pages. - *Note The `@title' `@subtitle' and `@author' Commands: title - subtitle author. - -`@titlefont{TEXT}' - In a printed manual, print TEXT in a larger than normal font. Not - relevant to Info, which does not have title pages. *Note The - `@titlefont' `@center' and `@sp' Commands: titlefont center sp. - -`@titlepage' - Indicate to Texinfo the beginning of the title page. Write - command on a line of its own. Pair with `@end titlepage'. - Nothing between `@titlepage' and `@end titlepage' appears in Info. - *Note `@titlepage': titlepage. - -`@today{}' - Insert the current date, in `1 Jan 1900' style. *Note How to Make - Your Own Headings: Custom Headings. - -`@top TITLE' - In a Texinfo file to be formatted with `makeinfo', identify the - topmost `@node' line in the file, which must be written on the line - immediately preceding the `@top' command. Used for `makeinfo''s - node pointer insertion feature. The title is underlined with - asterisks. Both the `@node' line and the `@top' line normally - should be enclosed by `@ifinfo' and `@end ifinfo'. In TeX and - `texinfo-format-buffer', the `@top' command is merely a synonym - for `@unnumbered'. *Note Creating Pointers with `makeinfo': - makeinfo Pointer Creation. - -`@unnumbered TITLE' - In a printed manual, begin a chapter that appears without chapter - numbers of any kind. The title appears in the table of contents - of a printed manual. In Info, the title is underlined with - asterisks. *Note `@unnumbered' and `@appendix': unnumbered & - appendix. - -`@unnumberedsec TITLE' - In a printed manual, begin a section that appears without section - numbers of any kind. The title appears in the table of contents - of a printed manual. In Info, the title is underlined with equal - signs. *Note Section Commands: unnumberedsec appendixsec heading. - -`@unnumberedsubsec TITLE' - In a printed manual, begin an unnumbered subsection within a - chapter. The title appears in the table of contents of a printed - manual. In Info, the title is underlined with hyphens. *Note - `@unnumberedsubsec' `@appendixsubsec' `@subheading': - unnumberedsubsec appendixsubsec subheading. - -`@unnumberedsubsubsec TITLE' - In a printed manual, begin an unnumbered subsubsection within a - chapter. The title appears in the table of contents of a printed - manual. In Info, the title is underlined with periods. *Note The - `subsub' Commands: subsubsection. - -`@value{FLAG}' - Replace FLAG with the value to which it is set by `@set FLAG'. - *Note `@set' `@clear' `@value': set clear value. - -`@var{METASYNTACTIC-VARIABLE}' - Highlight a metasyntactic variable, which is something that stands - for another piece of text. *Note Indicating Metasyntactic - Variables: var. - -`@vindex ENTRY' - Add ENTRY to the index of variables. *Note Defining the Entries - of an Index: Index Entries. - -`@vskip AMOUNT' - In a printed manual, insert whitespace so as to push text on the - remainder of the page towards the bottom of the page. Used in - formatting the copyright page with the argument `0pt plus 1filll'. - (Note spelling of `filll'.) `@vskip' may be used only in - contexts ignored for Info. *Note The Copyright Page and Printed - Permissions: Copyright & Permissions. - -`@vtable FORMATTING-COMMAND' - Begin a two-column table, using `@item' for each entry. - Automatically enter each of the items in the first column into the - index of variables. Pair with `@end vtable'. The same as - `@table', except for indexing. *Note `@ftable' and `@vtable': - ftable vtable. - -`@w{TEXT}' - Prevent TEXT from being split across two lines. Do not end a - paragraph that uses `@w' with an `@refill' command. In the - Texinfo file, keep TEXT on one line. *Note `@w': w. - -`@xref{NODE-NAME, [ENTRY], [TOPIC-OR-TITLE], [INFO-FILE], [MANUAL]}' - Make a reference that starts with `See' in a printed manual. - Follow command with a punctuation mark. Only the first argument is - mandatory. *Note `@xref': xref. - diff --git a/gnu/usr.bin/texinfo/info-files/texi.info-9 b/gnu/usr.bin/texinfo/info-files/texi.info-9 deleted file mode 100644 index b128db5725df..000000000000 --- a/gnu/usr.bin/texinfo/info-files/texi.info-9 +++ /dev/null @@ -1,1210 +0,0 @@ -This is Info file texi.info, produced by Makeinfo-1.55 from the input -file texi.texi. - - This file documents Texinfo, a documentation system that uses a -single source file to produce both on-line information and a printed -manual. - - Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation, -Inc. - - This is the second edition of the Texinfo documentation, -and is consistent with version 2 of `texinfo.tex'. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: texi.info, Node: Tips, Next: Sample Texinfo File, Prev: Command List, Up: Top - -Tips and Hints -************** - - Here are some tips for writing Texinfo documentation: - - * Write in the present tense, not in the past or the future. - - * Write actively! For example, write "We recommend that ..." rather - than "It is recommended that ...". - - * Use 70 or 72 as your fill column. Longer lines are hard to read. - - * Include a copyright notice and copying permissions. - -Index, index, index! -.................... - - Write many index entries, in different ways. Readers like indices; -they are helpful and convenient. - - Although it is easiest to write index entries as you write the body -of the text, some people prefer to write entries afterwards. In either -case, write an entry before the paragraph to which it applies. This -way, an index entry points to the first page of a paragraph that is -split across pages. - - Here are more hints we have found valuable: - - * Write each index entry differently, so each entry refers to a - different place in the document. The index of an Info file lists - only one location for each entry. - - * Write index entries only where a topic is discussed significantly. - For example, it is not useful to index "debugging information" in - a chapter on reporting bugs. Someone who wants to know about - debugging information will certainly not find it in that chapter. - - * Consistently capitalize the first word of every index entry, or - else use lower case. According to convention, you should - capitalize the first word of an index entry. However, this - practice may make an index look crowded. Some writers prefer - lower case. Regardless of which you prefer, choose one style and - stick to it. Mixing the two styles looks bad. - - * Always capitalize or use upper case for those words in an index for - which this is proper, such as names of countries or acronyms. - - * Write the indexing commands that refer to a whole section - immediately after the section command, and write the indexing - commands that refer to the paragraph before the paragraph. - - In the example that follows, a blank line comes after the index - entry for "Leaping": - - @section The Dog and the Fox - @cindex Jumping, in general - @cindex Leaping - - @cindex Dog, lazy, jumped over - @cindex Lazy dog jumped over - @cindex Fox, jumps over dog - @cindex Quick fox jumps over dog - The quick brown fox jumps over the lazy dog. - - (Note that the example shows entries for the same concept that are - written in different ways--`Lazy dog', and `Dog, lazy'--so readers - can look up the concept in different ways.) - -Blank lines -........... - - * Insert a blank line between a sectioning command and the first - following sentence or paragraph, or between the indexing commands - associated with the sectioning command and the first following - sentence or paragraph, as shown in the tip on indexing. - Otherwise, a formatter may fold title and paragraph together. - - * Always insert a blank line before an `@table' command and after an - `@end table' command; but never insert a blank line after an - `@table' command or before an `@end table' command. - - For example, - - Types of fox: - - @table @samp - @item Quick - Jump over lazy dogs. - - @item Brown - Also jump over lazy dogs. - @end table - @noindent - On the other hand, ... - - Insert blank lines before and after `@itemize' ... `@end itemize' - and `@enumerate' ... `@end enumerate' in the same way. - -Complete phrases -................ - - Complete phrases are easier to read than ... - - * Write entries in an itemized list as complete sentences; or at - least, as complete phrases. Incomplete expressions ... awkward - ... like this. - - * Write the prefatory sentence or phrase for a multi-item list or - table as a complete expression. Do not write "You can set:"; - instead, write "You can set these variables:". The former - expression sounds cut off. - -Editions, dates and versions -............................ - - Write the edition and version numbers and date in three places in -every manual: - - 1. In the first `@ifinfo' section, for people reading the Texinfo - file. - - 2. In the `@titlepage' section, for people reading the printed manual. - - 3. In the `Top' node, for people reading the Info file. - -Also, it helps to write a note before the first `@ifinfo' section to -explain what you are doing. - -For example: - - @c ===> NOTE! <== - @c Specify the edition and version numbers and date - @c in *three* places: - @c 1. First ifinfo section 2. title page 3. top node - @c To find the locations, search for !!set - - @ifinfo - @c !!set edition, date, version - This is Edition 4.03, January 1992, - of the @cite{GDB Manual} for GDB Version 4.3. - ... - ---or use `@set' and `@value' (*note `@value' Example: value Example.). - -Definition Commands -................... - - Definition commands are `@deffn', `@defun', `@defmac', and the like, -and enable you to write descriptions in a uniform format. - - * Write just one definition command for each entity you define with a - definition command. The automatic indexing feature creates an - index entry that leads the reader to the definition. - - * Use `@table' ... `@end table' in an appendix that contains a - summary of functions, not `@deffn' or other definition commands. - -Capitalization -.............. - - * Capitalize `Texinfo'; it is a name. Do not write the `x' or `i' - in upper case. - - * Capitalize `Info'; it is a name. - - * Write TeX using the `@TeX{}' command. Note the uppercase `T' and - `X'. This command causes the formatters to typeset the name - according to the wishes of Donald Knuth, who wrote TeX. - -Spaces -...... - - Do not use spaces to format a Texinfo file, except inside of -`@example' ... `@end example' and similar commands. - - For example, TeX fills the following: - - @kbd{C-x v} - @kbd{M-x vc-next-action} - Perform the next logical operation - on the version-controlled file - corresponding to the current buffer. - -so it looks like this: - - `C-x v' `M-x vc-next-action' Perform the next logical operation on - the version-controlled file corresponding to the current buffer. - -In this case, the text should be formatted with `@table', `@item', and -`@itemx', to create a table. - -@code, @samp, @var, and `---' -............................. - - * Use `@code' around Lisp symbols, including command names. For - example, - - The main function is @code{vc-next-action}, ... - - * Avoid putting letters such as `s' immediately after an `@code'. - Such letters look bad. - - * Use `@var' around meta-variables. Do not write angle brackets - around them. - - * Use three hyphens in a row, `---', to indicate a long dash. TeX - typesets these as a long dash and the Info formatters reduce three - hyphens to two. - -Periods Outside of Quotes -......................... - - Place periods and other punctuation marks *outside* of quotations, -unless the punctuation is part of the quotation. This practice goes -against convention, but enables the reader to distinguish between the -contents of the quotation and the whole passage. - - For example, you should write the following sentence with the period -outside the end quotation marks: - - Evidently, `au' is an abbreviation for ``author''. - -since `au' does *not* serve as an abbreviation for `author.' (with a -period following the word). - -Introducing New Terms -..................... - - * Introduce new terms so that a user who does not know them can - understand them from context; or write a definition for the term. - - For example, in the following, the terms "check in", "register" and - "delta" are all appearing for the first time; the example sentence - should be rewritten so they are understandable. - - The major function assists you in checking in a file to your - version control system and registering successive sets of - changes to it as deltas. - - * Use the `@dfn' command around a word being introduced, to indicate - that the user should not expect to know the meaning already, and - should expect to learn the meaning from this passage. - -@pxref -...... - - Absolutely never use `@pxref' except in the special context for -which it is designed: inside parentheses, with the closing parenthesis -following immediately after the closing brace. One formatter -automatically inserts closing punctuation and the other does not. This -means that the output looks right both in printed output and in an Info -file, but only when the command is used inside parentheses. - -Invoking from a Shell -..................... - - You can invoke programs such as Emacs, GCC, and GAWK from a shell. -The documentation for each program should contain a section that -describes this. Unfortunately, if the node names and titles for these -sections are all different, readers find it hard to search for the -section. - - Name such sections with a phrase beginning with the word -`Invoking ...', as in `Invoking Emacs'; this way users can find the -section easily. - -ANSI C Syntax -............. - - When you use `@example' to describe a C function's calling -conventions, use the ANSI C syntax, like this: - - void dld_init (char *@var{path}); - -And in the subsequent discussion, refer to the argument values by -writing the same argument names, again highlighted with `@var'. - - Avoid the obsolete style that looks like this: - - #include - - dld_init (path) - char *path; - - Also, it is best to avoid writing `#include' above the declaration -just to indicate that the function is declared in a header file. The -practice may give the misimpression that the `#include' belongs near -the declaration of the function. Either state explicitly which header -file holds the declaration or, better yet, name the header file used -for a group of functions at the beginning of the section that describes -the functions. - -Bad Examples -............ - - Here are several examples of bad writing to avoid: - - In this example, say, " ... you must `@dfn'{check in} the new -version." That flows better. - - When you are done editing the file, you must perform a - `@dfn'{check in}. - - In the following example, say, "... makes a unified interface such -as VC mode possible." - - SCCS, RCS and other version-control systems all perform similar - functions in broadly similar ways (it is this resemblance which - makes a unified control mode like this possible). - - And in this example, you should specify what `it' refers to: - - If you are working with other people, it assists in coordinating - everyone's changes so they do not step on each other. - -And Finally ... -............... - - * Pronounce TeX as if the `X' were a Greek `chi', as the last sound - in the name `Bach'. But pronounce Texinfo as in `speck': - `teckinfo'. - - * Write notes for yourself at the very end of a Texinfo file after - the `@bye'. None of the formatters process text after the `@bye'; - it is as if the text were within `@ignore' ... `@end ignore'. - - -File: texi.info, Node: Sample Texinfo File, Next: Sample Permissions, Prev: Tips, Up: Top - -A Sample Texinfo File -********************* - - Here is a complete, short sample Texinfo file, without any -commentary. You can see this file, with comments, in the first chapter. -*Note A Short Sample Texinfo File: Short Sample. - - \input texinfo @c -*-texinfo-*- - @c %**start of header - @setfilename sample.info - @settitle Sample Document - @c %**end of header - - @setchapternewpage odd - - @ifinfo - This is a short example of a complete Texinfo file. - - Copyright 1990 Free Software Foundation, Inc. - @end ifinfo - - @titlepage - @sp 10 - @comment The title is printed in a large font. - @center @titlefont{Sample Title} - - @c The following two commands start the copyright page. - @page - @vskip 0pt plus 1filll - Copyright @copyright{} 1990 Free Software Foundation, Inc. - @end titlepage - - @node Top, First Chapter, (dir), (dir) - @comment node-name, next, previous, up - - @menu - * First Chapter:: The first chapter is the - only chapter in this sample. - * Concept Index:: This index has two entries. - @end menu - - @node First Chapter, Concept Index, Top, Top - @comment node-name, next, previous, up - @chapter First Chapter - @cindex Sample index entry - - This is the contents of the first chapter. - @cindex Another sample index entry - - Here is a numbered list. - - @enumerate - @item - This is the first item. - - @item - This is the second item. - @end enumerate - - The @code{makeinfo} and @code{texinfo-format-buffer} - commands transform a Texinfo file such as this into - an Info file; and @TeX{} typesets it for a printed - manual. - - @node Concept Index, , First Chapter, Top - @comment node-name, next, previous, up - @unnumbered Concept Index - - @printindex cp - - @contents - @bye - - -File: texi.info, Node: Sample Permissions, Next: Include Files, Prev: Sample Texinfo File, Up: Top - -Sample Permissions -****************** - - Texinfo files should contain sections that tell the readers that they -have the right to copy and distribute the Texinfo file, the Info file, -and the printed manual. - - Also, if you are writing a manual about software, you should explain -that the software is free and either include the GNU General Public -License (GPL) or provide a reference to it. *Note Distribution: -(emacs)Distrib, for an example of the text that could be used in the -software "Distribution", "General Public License", and "NO WARRANTY" -sections of a document. *Note Texinfo Copying Conditions: Copying, for -an example of a brief explanation of how the copying conditions provide -you with rights. - -* Menu: - -* Inserting Permissions:: How to put permissions in your document. -* ifinfo Permissions:: Sample `ifinfo' copying permissions. -* Titlepage Permissions:: Sample Titlepage copying permissions. - - -File: texi.info, Node: Inserting Permissions, Next: ifinfo Permissions, Up: Sample Permissions - -Inserting Permissions -===================== - - In a Texinfo file, the first `@ifinfo' section usually begins with a -line that says what the file documents. This is what a person reading -the unprocessed Texinfo file or using the advanced Info command `g *' -sees first. *note Advanced Info commands: (info)Expert, for more -information. (A reader using the regular Info commands usually starts -reading at the first node and skips this first section, which is not in -a node.) - - In the `@ifinfo' section, the summary sentence is followed by a -copyright notice and then by the copying permission notice. One of the -copying permission paragraphs is enclosed in `@ignore' and `@end -ignore' commands. This paragraph states that the Texinfo file can be -processed through TeX and printed, provided the printed manual carries -the proper copying permission notice. This paragraph is not made part -of the Info file since it is not relevant to the Info file; but it is a -mandatory part of the Texinfo file since it permits people to process -the Texinfo file in TeX and print the results. - - In the printed manual, the Free Software Foundation copying -permission notice follows the copyright notice and publishing -information and is located within the region delineated by the -`@titlepage' and `@end titlepage' commands. The copying permission -notice is exactly the same as the notice in the `@ifinfo' section -except that the paragraph enclosed in `@ignore' and `@end ignore' -commands is not part of the notice. - - To make it simple to insert a permission notice into each section of -the Texinfo file, sample permission notices for each section are -reproduced in full below. - - Note that you may need to specify the correct name of a section -mentioned in the permission notice. For example, in `The GDB Manual', -the name of the section referring to the General Public License is -called the "GDB General Public License", but in the sample shown below, -that section is referred to generically as the "GNU General Public -License". If the Texinfo file does not carry a copy of the General -Public License, leave out the reference to it, but be sure to include -the rest of the sentence. - - -File: texi.info, Node: ifinfo Permissions, Next: Titlepage Permissions, Prev: Inserting Permissions, Up: Sample Permissions - -`ifinfo' Copying Permissions -============================ - - In the `@ifinfo' section of a Texinfo file, the standard Free -Software Foundation permission notice reads as follows: - - This file documents ... - - Copyright 1992 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim - copies of this manual provided the copyright notice and - this permission notice are preserved on all copies. - - @ignore - Permission is granted to process this file through TeX - and print the results, provided the printed document - carries a copying permission notice identical to this - one except for the removal of this paragraph (this - paragraph not being relevant to the printed manual). - - @end ignore - Permission is granted to copy and distribute modified - versions of this manual under the conditions for - verbatim copying, provided also that the sections - entitled ``Copying'' and ``GNU General Public License'' - are included exactly as in the original, and provided - that the entire resulting derived work is distributed - under the terms of a permission notice identical to this - one. - - Permission is granted to copy and distribute - translations of this manual into another language, - under the above conditions for modified versions, - except that this permission notice may be stated in a - translation approved by the Free Software Foundation. - - -File: texi.info, Node: Titlepage Permissions, Prev: ifinfo Permissions, Up: Sample Permissions - -Titlepage Copying Permissions -============================= - - In the `@titlepage' section of a Texinfo file, the standard Free -Software Foundation copying permission notice follows the copyright -notice and publishing information. The standard phrasing is as follows: - - Permission is granted to make and distribute verbatim - copies of this manual provided the copyright notice and - this permission notice are preserved on all copies. - - Permission is granted to copy and distribute modified - versions of this manual under the conditions for - verbatim copying, provided also that the sections - entitled ``Copying'' and ``GNU General Public License'' - are included exactly as in the original, and provided - that the entire resulting derived work is distributed - under the terms of a permission notice identical to this - one. - - Permission is granted to copy and distribute - translations of this manual into another language, - under the above conditions for modified versions, - except that this permission notice may be stated in a - translation approved by the Free Software Foundation. - - -File: texi.info, Node: Include Files, Next: Headings, Prev: Sample Permissions, Up: Top - -Include Files -************* - - When TeX or an Info formatting command sees an `@include' command in -a Texinfo file, it processes the contents of the file named by the -command and incorporates them into the DVI or Info file being created. -Index entries from the included file are incorporated into the indices -of the output file. - - Include files let you keep a single large document as a collection of -conveniently small parts. - -* Menu: - -* Using Include Files:: How to use the `@include' command. -* texinfo-multiple-files-update:: How to create and update nodes and - menus when using included files. -* Include File Requirements:: What `texinfo-multiple-files-update' expects. -* Sample Include File:: A sample outer file with included files - within it; and a sample included file. -* Include Files Evolution:: How use of the `@include' command - has changed over time. - - -File: texi.info, Node: Using Include Files, Next: texinfo-multiple-files-update, Up: Include Files - -How to Use Include Files -======================== - - To include another file within a Texinfo file, write the `@include' -command at the beginning of a line and follow it on the same line by -the name of a file to be included. For example: - - @include buffers.texi - - An included file should simply be a segment of text that you expect -to be included as is into the overall or "outer" Texinfo file; it -should not contain the standard beginning and end parts of a Texinfo -file. In particular, you should not start an included file with a line -saying `\input texinfo'; if you do, that phrase is inserted into the -output file as is. Likewise, you should not end an included file with -an `@bye' command; nothing after `@bye' is formatted. - - In the past, you were required to write an `@setfilename' line at the -beginning of an included file, but no longer. Now, it does not matter -whether you write such a line. If an `@setfilename' line exists in an -included file, it is ignored. - - Conventionally, an included file begins with an `@node' line that is -followed by an `@chapter' line. Each included file is one chapter. -This makes it easy to use the regular node and menu creating and -updating commands to create the node pointers and menus within the -included file. However, the simple Emacs node and menu creating and -updating commands do not work with multiple Texinfo files. Thus you -cannot use these commands to fill in the `Next', `Previous', and `Up' -pointers of the `@node' line that begins the included file. Also, you -cannot use the regular commands to create a master menu for the whole -file. Either you must insert the menus and the `Next', `Previous', and -`Up' pointers by hand, or you must use the GNU Emacs Texinfo mode -command, `texinfo-multiple-files-update', that is designed for -`@include' files. - - -File: texi.info, Node: texinfo-multiple-files-update, Next: Include File Requirements, Prev: Using Include Files, Up: Include Files - -`texinfo-multiple-files-update' -=============================== - - GNU Emacs Texinfo mode provides a command to handle included files -called `texinfo-multiple-files-update'. This command creates or -updates `Next', `Previous', and `Up' pointers of included files as well -as those in the outer or overall Texinfo file, and it creates or -updates a main menu in the outer file. Depending whether you call it -with optional arguments, the command updates only the pointers in the -first `@node' line of the included files or all of them: - -`M-x texinfo-multiple-files-update' - Called without any arguments: - - - Create or update the `Next', `Previous', and `Up' pointers of - the first `@node' line in each file included in an outer or - overall Texinfo file. - - - Create or update the `Top' level node pointers of the outer or - overall file. - - - Create or update a main menu in the outer file. - -`C-u M-x texinfo-multiple-files-update' - Called with `C-u' as a prefix argument: - - - Create or update pointers in the first `@node' line in each - included file. - - - Create or update the `Top' level node pointers of the outer - file. - - - Create and insert a master menu in the outer file. The - master menu is made from all the menus in all the included - files. - -`C-u 8 M-x texinfo-multiple-files-update' - Called with a numeric prefix argument, such as `C-u 8': - - - Create or update *all* the `Next', `Previous', and `Up' - pointers of all the included files. - - - Create or update *all* the menus of all the included files. - - - Create or update the `Top' level node pointers of the outer or - overall file. - - - And then create a master menu in the outer file. This is - similar to invoking `texinfo-master-menu' with an argument - when you are working with just one file. - - Note the use of the prefix argument in interactive use: with a -regular prefix argument, just `C-u', the -`texinfo-multiple-files-update' command inserts a master menu; with a -numeric prefix argument, such as `C-u 8', the command updates *every* -pointer and menu in *all* the files and then inserts a master menu. - - -File: texi.info, Node: Include File Requirements, Next: Sample Include File, Prev: texinfo-multiple-files-update, Up: Include Files - -Include File Requirements -========================= - - If you plan to use the `texinfo-multiple-files-update' command, the -outer Texinfo file that lists included files within it should contain -nothing but the beginning and end parts of a Texinfo file, and a number -of `@include' commands listing the included files. It should not even -include indices, which should be listed in an included file of their -own. - - Moreover, each of the included files must contain exactly one highest -level node (conventionally, `@chapter' or equivalent), and this node -must be the first node in the included file. Furthermore, each of -these highest level nodes in each included file must be at the same -hierarchical level in the file structure. Usually, each is an -`@chapter', an `@appendix', or an `@unnumbered' node. Thus, normally, -each included file contains one, and only one, chapter or -equivalent-level node. - - The outer file should contain only *one* node, the `Top' node. It -should *not* contain any nodes besides the single `Top' node. The -`texinfo-multiple-files-update' command will not process them. - - -File: texi.info, Node: Sample Include File, Next: Include Files Evolution, Prev: Include File Requirements, Up: Include Files - -Sample File with `@include' -=========================== - - Here is an example of a complete outer Texinfo file with `@include' -files within it before running `texinfo-multiple-files-update', which -would insert a main or master menu: - - \input texinfo @c -*-texinfo-*- - @setfilename include-example.info - @settitle Include Example - - @setchapternewpage odd - @titlepage - @sp 12 - @center @titlefont{Include Example} - @sp 2 - @center by Whom Ever - - @page - @vskip 0pt plus 1filll - Copyright @copyright{} 1990 Free Software Foundation, Inc. - @end titlepage - - @ifinfo - @node Top, First, (dir), (dir) - @top Master Menu - @end ifinfo - - @include foo.texinfo - @include bar.texinfo - @include concept-index.texinfo - - @summarycontents - @contents - - @bye - - An included file, such as `foo.texinfo', might look like this: - - @node First, Second, , Top - @chapter First Chapter - - Contents of first chapter ... - - The full contents of `concept-index.texinfo' might be as simple as -this: - - @node Concept Index, , Second, Top - @unnumbered Concept Index - - @printindex cp - - The outer Texinfo source file for `The GNU Emacs Lisp Reference -Manual' is named `elisp.texi'. This outer file contains a master menu -with 417 entries and a list of 41 `@include' files. - - -File: texi.info, Node: Include Files Evolution, Prev: Sample Include File, Up: Include Files - -Evolution of Include Files -========================== - - When Info was first created, it was customary to create many small -Info files on one subject. Each Info file was formatted from its own -Texinfo source file. This custom meant that Emacs did not need to make -a large buffer to hold the whole of a large Info file when someone -wanted information; instead, Emacs allocated just enough memory for the -small Info file that contained the particular information sought. This -way, Emacs could avoid wasting memory. - - References from one file to another were made by referring to the -file name as well as the node name. (*Note Referring to Other Info -Files: Other Info Files. Also, see *Note `@xref' with Four and Five -Arguments: Four and Five Arguments.) - - Include files were designed primarily as a way to create a single, -large printed manual out of several smaller Info files. In a printed -manual, all the references were within the same document, so TeX could -automatically determine the references' page numbers. The Info -formatting commands used include files only for creating joint indices; -each of the individual Texinfo files had to be formatted for Info -individually. (Each, therefore, required its own `@setfilename' line.) - - However, because large Info files are now split automatically, it is -no longer necessary to keep them small. - - Nowadays, multiple Texinfo files are used mostly for large documents, -such as `The GNU Emacs Lisp Reference Manual', and for projects in -which several different people write different sections of a document -simultaneously. - - In addition, the Info formatting commands have been extended to work -with the `@include' command so as to create a single large Info file -that is split into smaller files if necessary. This means that you can -write menus and cross references without naming the different Texinfo -files. - - -File: texi.info, Node: Headings, Next: Catching Mistakes, Prev: Include Files, Up: Top - -Page Headings -************* - - Most printed manuals contain headings along the top of every page -except the title and copyright pages. Some manuals also contain -footings. (Headings and footings have no meaning to Info, which is not -paginated.) - -* Menu: - -* Headings Introduced:: Conventions for using page headings. -* Heading Format:: Standard page heading formats. -* Heading Choice:: How to specify the type of page heading. -* Custom Headings:: How to create your own headings and footings. - - -File: texi.info, Node: Headings Introduced, Next: Heading Format, Up: Headings - -Headings Introduced -=================== - - Texinfo provides standard page heading formats for manuals that are -printed on one side of each sheet of paper and for manuals that are -printed on both sides of the paper. Usually, you will use one or other -of these formats, but you can specify your own format, if you wish. - - In addition, you can specify whether chapters should begin on a new -page, or merely continue the same page as the previous chapter; and if -chapters begin on new pages, you can specify whether they must be -odd-numbered pages. - - By convention, a book is printed on both sides of each sheet of -paper. When you open a book, the right-hand page is odd-numbered, and -chapters begin on right-hand pages--a preceding left-hand page is left -blank if necessary. Reports, however, are often printed on just one -side of paper, and chapters begin on a fresh page immediately following -the end of the preceding chapter. In short or informal reports, -chapters often do not begin on a new page at all, but are separated -from the preceding text by a small amount of whitespace. - - The `@setchapternewpage' command controls whether chapters begin on -new pages, and whether one of the standard heading formats is used. In -addition, Texinfo has several heading and footing commands that you can -use to generate your own heading and footing formats. - - In Texinfo, headings and footings are single lines at the tops and -bottoms of pages; you cannot create multiline headings or footings. -Each header or footer line is divided into three parts: a left part, a -middle part, and a right part. Any part, or a whole line, may be left -blank. Text for the left part of a header or footer line is set -flushleft; text for the middle part is centered; and, text for the -right part is set flushright. - - -File: texi.info, Node: Heading Format, Next: Heading Choice, Prev: Headings Introduced, Up: Headings - -Standard Heading Formats -======================== - - Texinfo provides two standard heading formats, one for manuals -printed on one side of each sheet of paper, and the other for manuals -printed on both sides of the paper. - - By default, nothing is specified for the footing of a Texinfo file, -so the footing remains blank. - - The standard format for single-sided printing consists of a header -line in which the left-hand part contains the name of the chapter, the -central part is blank, and the right-hand part contains the page number. - - A single-sided page looks like this: - - _______________________ - | | - | chapter page number | - | | - | Start of text ... | - | ... | - | | - - The standard format for two-sided printing depends on whether the -page number is even or odd. By convention, even-numbered pages are on -the left- and odd-numbered pages are on the right. (TeX will adjust the -widths of the left- and right-hand margins. Usually, widths are -correct, but during double-sided printing, it is wise to check that -pages will bind properly--sometimes a printer will produce output in -which the even-numbered pages have a larger right-hand margin than the -odd-numbered pages.) - - In the standard double-sided format, the left part of the left-hand -(even-numbered) page contains the page number, the central part is -blank, and the right part contains the title (specified by the -`@settitle' command). The left part of the right-hand (odd-numbered) -page contains the name of the chapter, the central part is blank, and -the right part contains the page number. - - Two pages, side by side as in an open book, look like this: - - _______________________ _______________________ - | | | | - | page number title | | chapter page number | - | | | | - | Start of text ... | | More text ... | - | ... | | ... | - | | | | - -The chapter name is preceded by the word `Chapter', the chapter number -and a colon. This makes it easier to keep track of where you are in -the manual. - - -File: texi.info, Node: Heading Choice, Next: Custom Headings, Prev: Heading Format, Up: Headings - -Specifying the Type of Heading -============================== - - TeX does not begin to generate page headings for a standard Texinfo -file until it reaches the `@end titlepage' command. Thus, the title -and copyright pages are not numbered. The `@end titlepage' command -causes TeX to begin to generate page headings according to a standard -format specified by the `@setchapternewpage' command that precedes the -`@titlepage' section. - - There are four possibilities: - -No `@setchapternewpage' command - Cause TeX to specify the single-sided heading format, with chapters - on new pages. This is the same as `@setchapternewpage on'. - -`@setchapternewpage on' - Specify the single-sided heading format, with chapters on new - pages. - -`@setchapternewpage off' - Cause TeX to start a new chapter on the same page as the last page - of the preceding chapter, after skipping some vertical whitespace. - Also cause TeX to typeset for single-sided printing. (You can - override the headers format with the `@headings double' command; - see *Note The `@headings' Command: headings on off.) - -`@setchapternewpage odd' - Specify the double-sided heading format, with chapters on new - pages. - -Texinfo lacks an `@setchapternewpage even' command. - - -File: texi.info, Node: Custom Headings, Prev: Heading Choice, Up: Headings - -How to Make Your Own Headings -============================= - - You can use the standard headings provided with Texinfo or specify -your own. - - Texinfo provides six commands for specifying headings and footings. -The `@everyheading' command and `@everyfooting' command generate page -headers and footers that are the same for both even- and odd-numbered -pages. The `@evenheading' command and `@evenfooting' command generate -headers and footers for even-numbered (left-hand) pages; and the -`@oddheading' command and `@oddfooting' command generate headers and -footers for odd-numbered (right-hand) pages. - - Write custom heading specifications in the Texinfo file immediately -after the `@end titlepage' command. Enclose your specifications -between `@iftex' and `@end iftex' commands since the -`texinfo-format-buffer' command may not recognize them. Also, you must -cancel the predefined heading commands with the `@headings off' command -before defining your own specifications. - - Here is how to tell TeX to place the chapter name at the left, the -page number in the center, and the date at the right of every header -for both even- and odd-numbered pages: - - @iftex - @headings off - @everyheading @thischapter @| @thispage @| @today{} - @end iftex - -You need to divide the left part from the central part and the central -part from the right had part by inserting `@|' between parts. -Otherwise, the specification command will not be able to tell where the -text for one part ends and the next part begins. - - Each part can contain text or @-commands. The text is printed as if -the part were within an ordinary paragraph in the body of the page. -The @-commands replace themselves with the page number, date, chapter -name, or whatever. - - Here are the six heading and footing commands: - -`@everyheading LEFT @| CENTER @| RIGHT' -`@everyfooting LEFT @| CENTER @| RIGHT' - The `every' commands specify the format for both even- and - odd-numbered pages. These commands are for documents that are - printed on one side of each sheet of paper, or for documents in - which you want symmetrical headers or footers. - -`@evenheading LEFT @| CENTER @| RIGHT' -`@oddheading LEFT @| CENTER @| RIGHT' -`@evenfooting LEFT @| CENTER @| RIGHT' -`@oddfooting LEFT @| CENTER @| RIGHT' - The `even' and `odd' commands specify the format for even-numbered - pages and odd-numbered pages. These commands are for books and - manuals that are printed on both sides of each sheet of paper. - - Use the `@this...' series of @-commands to provide the names of -chapters and sections and the page number. You can use the `@this...' -commands in the left, center, or right portions of headers and footers, -or anywhere else in a Texinfo file so long as they are between `@iftex' -and `@end iftex' commands. - - Here are the `@this...' commands: - -`@thispage' - Expands to the current page number. - -`@thischaptername' - Expands to the name of the current chapter. - -`@thischapter' - Expands to the number and name of the current chapter, in the - format `Chapter 1: Title'. - -`@thistitle' - Expands to the name of the document, as specified by the - `@settitle' command. - -`@thisfile' - For `@include' files only: expands to the name of the current - `@include' file. If the current Texinfo source file is not an - `@include' file, this command has no effect. This command does - *not* provide the name of the current Texinfo source file unless - it is an `@include' file. (*Note Include Files::, for more - information about `@include' files.) - -You can also use the `@today{}' command, which expands to the current -date, in `1 Jan 1900' format. - - Other @-commands and text are printed in a header or footer just as -if they were in the body of a page. It is useful to incorporate text, -particularly when you are writing drafts: - - @iftex - @headings off - @everyheading @emph{Draft!} @| @thispage @| @thischapter - @everyfooting @| @| Version: 0.27: @today{} - @end iftex - - Beware of overlong titles: they may overlap another part of the -header or footer and blot it out. - - -File: texi.info, Node: Catching Mistakes, Next: Refilling Paragraphs, Prev: Headings, Up: Top - -Formatting Mistakes -******************* - - Besides mistakes in the content of your documentation, there are two -kinds of mistake you can make with Texinfo: you can make mistakes with -@-commands, and you can make mistakes with the structure of the nodes -and chapters. - - Emacs has two tools for catching the @-command mistakes and two for -catching structuring mistakes. - - For finding problems with @-commands, you can run TeX or a region -formatting command on the region that has a problem; indeed, you can -run these commands on each region as you write it. - - For finding problems with the structure of nodes and chapters, you -can use `C-c C-s' (`texinfo-show-structure') and the related `occur' -command and you can use the `M-x Info-validate' command. - -* Menu: - -* makeinfo preferred:: `makeinfo' finds errors. -* Debugging with Info:: How to catch errors with Info formatting. -* Debugging with TeX:: How to catch errors with TeX formatting. -* Using texinfo-show-structure:: How to use `texinfo-show-structure'. -* Using occur:: How to list all lines containing a pattern. -* Running Info-Validate:: How to find badly referenced nodes. - - -File: texi.info, Node: makeinfo preferred, Next: Debugging with Info, Up: Catching Mistakes - -`makeinfo' Find Errors -====================== - - The `makeinfo' program does an excellent job of catching errors and -reporting them--far better than either the `texinfo-format-region' or -the `texinfo-format-buffer' command. In addition, the various -functions for automatically creating and updating node pointers and -menus remove many opportunities for human error. - - If you can, use the updating commands to create and insert pointers -and menus. These prevent many errors. Then use `makeinfo' (or its -Texinfo mode manifestations, `makeinfo-region' and `makeinfo-buffer') -to format your file and check for other errors. This is the best way -to work with Texinfo. But if you cannot use `makeinfo', or your -problem is very puzzling, then you may want to use the tools described -in this appendix. - - -File: texi.info, Node: Debugging with Info, Next: Debugging with TeX, Prev: makeinfo preferred, Up: Catching Mistakes - -Catching Errors with Info Formatting -==================================== - - After you have written part of a Texinfo file, you can use the -`texinfo-format-region' or the `makeinfo-region' command to see whether -the region formats properly. - - Most likely, however, you are reading this section because for some -reason you cannot use the `makeinfo-region' command; therefore, the -rest of this section presumes that you are using -`texinfo-format-region'. - - If you make a mistake with an @-command, `texinfo-format-region' -will stop processing at or after the error and display an error -message. To see where in the buffer the error occurred, switch to the -`*Info Region*' buffer; the cursor will be in a position that is after -the location of the error. Also, the text will not be formatted after -the place where the error occurred (or more precisely, where it was -detected). - - For example, if you accidentally end a menu with the command `@end -menus' with an `s' on the end, instead of with `@end menu', you will -see an error message that says: - - @end menus is not handled by texinfo - -The cursor will stop at the point in the buffer where the error occurs, -or not long after it. The buffer will look like this: - - ---------- Buffer: *Info Region* ---------- - * Menu: - - * Using texinfo-show-structure:: How to use - `texinfo-show-structure' - to catch mistakes. - * Running Info-Validate:: How to check for - unreferenced nodes. - @end menus - -!- - ---------- Buffer: *Info Region* ---------- - - The `texinfo-format-region' command sometimes provides slightly odd -error messages. For example, the following cross reference fails to -format: - - (@xref{Catching Mistakes, for more info.) - -In this case, `texinfo-format-region' detects the missing closing brace -but displays a message that says `Unbalanced parentheses' rather than -`Unbalanced braces'. This is because the formatting command looks for -mismatches between braces as if they were parentheses. - - Sometimes `texinfo-format-region' fails to detect mistakes. For -example, in the following, the closing brace is swapped with the -closing parenthesis: - - (@xref{Catching Mistakes), for more info.} - -Formatting produces: - (*Note for more info.: Catching Mistakes) - - The only way for you to detect this error is to realize that the -reference should have looked like this: - - (*Note Catching Mistakes::, for more info.) - - Incidentally, if you are reading this node in Info and type `f RET' -(`Info-follow-reference'), you will generate an error message that says: - - No such node: "Catching Mistakes) The only way ... - -This is because Info perceives the example of the error as the first -cross reference in this node and if you type a RET immediately after -typing the Info `f' command, Info will attempt to go to the referenced -node. If you type `f catch TAB RET', Info will complete the node name -of the correctly written example and take you to the `Catching -Mistakes' node. (If you try this, you can return from the `Catching -Mistakes' node by typing `l' (`Info-last').) - diff --git a/gnu/usr.bin/texinfo/info/info-stnd.info b/gnu/usr.bin/texinfo/info/info-stnd.info deleted file mode 100644 index 31f486a45cb4..000000000000 --- a/gnu/usr.bin/texinfo/info/info-stnd.info +++ /dev/null @@ -1,1259 +0,0 @@ -This is Info file info-stnd.info, produced by Makeinfo-1.55 from the -input file info-stnd.texi. - -This file documents GNU Info, a program for viewing the on-line -formatted versions of Texinfo files. This documentation is different -from the documentation for the Info reader that is part of GNU Emacs. -If you do not know how to use Info, but have a working Info reader, you -should read that documentation first. - -Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -sections entitled "Copying" and "GNU General Public License" are -included exactly as in the original, and provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. - - -File: info-stnd.info, Node: Top, Next: What is Info, Prev: (dir), Up: (dir) - -The GNU Info Program -******************** - -This file documents GNU Info, a program for viewing the on-line -formatted versions of Texinfo files, version 2.9. This documentation -is different from the documentation for the Info reader that is part of -GNU Emacs. - -* Menu: - -* What is Info:: -* Options:: Options you can pass on the command line. -* Cursor Commands:: Commands which move the cursor within a node. -* Scrolling Commands:: Commands for moving the node around - in a window. -* Node Commands:: Commands for selecting a new node. -* Searching Commands:: Commands for searching an Info file. -* Xref Commands:: Commands for selecting cross references. -* Window Commands:: Commands which manipulate multiple windows. -* Printing Nodes:: How to print out the contents of a node. -* Miscellaneous Commands:: A few commands that defy categories. -* Variables:: How to change the default behavior of Info. -* GNU Info Global Index:: Global index containing keystrokes, - command names, variable names, - and general concepts. - - -File: info-stnd.info, Node: What is Info, Next: Options, Prev: Top, Up: Top - -What is Info? -************* - -"Info" is a program which is used to view Info files on an ASCII -terminal. "Info files" are the result of processing Texinfo files with -the program `makeinfo' or with one of the Emacs commands, such as `M-x -texinfo-format-buffer'. Texinfo itself is a documentation system that -uses a single source file to produce both on-line information and -printed output. You can typeset and print the files that you read in -Info. - - -File: info-stnd.info, Node: Options, Next: Cursor Commands, Prev: What is Info, Up: Top - -Command Line Options -******************** - -GNU Info accepts several options to control the initial node being -viewed, and to specify which directories to search for Info files. Here -is a template showing an invocation of GNU Info from the shell: - - info [--OPTION-NAME OPTION-VALUE] MENU-ITEM... - -The following OPTION-NAMES are available when invoking Info from the -shell: - -`--directory DIRECTORY-PATH' -`-d DIRECTORY-PATH' - Add DIRECTORY-PATH to the list of directory paths searched when - Info needs to find a file. You may issue `--directory' multiple - times; once for each directory which contains Info files. - Alternatively, you may specify a value for the environment variable - `INFOPATH'; if `--directory' is not given, the value of `INFOPATH' - is used. The value of `INFOPATH' is a colon separated list of - directory names. If you do not supply `INFOPATH' or - `--directory-path', Info uses a default path. - -`--file FILENAME' -`-f FILENAME' - Specify a particular Info file to visit. By default, Info visits - the file `dir'; if you use this option, Info will start with - `(FILENAME)Top' as the first file and node. - -`--node NODENAME' -`-n NODENAME' - Specify a particular node to visit in the initial file that Info - loads. This is especially useful in conjunction with `--file'(1) - (*note Options-Footnotes::). You may specify `--node' multiple - times; for an interactive Info, each NODENAME is visited in its - own window, for a non-interactive Info (such as when `--output' is - given) each NODENAME is processed sequentially. - -`--output FILENAME' -`-o FILENAME' - Specify FILENAME as the name of a file to which to direct output. - Each node that Info visits will be output to FILENAME instead of - interactively viewed. A value of `-' for FILENAME specifies the - standard output. - -`--subnodes' - This option only has meaning when given in conjunction with - `--output'. It means to recursively output the nodes appearing in - the menus of each node being output. Menu items which resolve to - external Info files are not output, and neither are menu items - which are members of an index. Each node is only output once. - -`--help' -`-h' - Produces a relatively brief description of the available Info - options. - -`--version' - Prints the version information of Info and exits. - -`MENU-ITEM' - Info treats its remaining arguments as the names of menu items. - The first argument is a menu item in the initial node visited, - while the second argument is a menu item in the first argument's - node. You can easily move to the node of your choice by - specifying the menu names which describe the path to that node. - For example, - - info emacs buffers - - first selects the menu item `Emacs' in the node `(dir)Top', and - then selects the menu item `Buffers' in the node `(emacs)Top'. - - -File: info-stnd.info, Node: Options-Footnotes, Up: Options - -(1) Of course, you can specify both the file and node in a `--node' -command; but don't forget to escape the open and close parentheses from -the shell as in: `info --node '(emacs)Buffers'' - - -File: info-stnd.info, Node: Cursor Commands, Next: Scrolling Commands, Prev: Options, Up: Top - -Moving the Cursor -***************** - -Many people find that reading screens of text page by page is made -easier when one is able to indicate particular pieces of text with some -kind of pointing device. Since this is the case, GNU Info (both the -Emacs and standalone versions) have several commands which allow you to -move the cursor about the screen. The notation used in this manual to -describe keystrokes is identical to the notation used within the Emacs -manual, and the GNU Readline manual. *Note Character Conventions: -(emacs)Characters, if you are unfamiliar with the notation. - -The following table lists the basic cursor movement commands in Info. -Each entry consists of the key sequence you should type to execute the -cursor movement, the `M-x'(1) (*note Cursor Commands-Footnotes::) -command name (displayed in parentheses), and a short description of -what the command does. All of the cursor motion commands can take an -"numeric" argument (*note `universal-argument': Miscellaneous -Commands.), to find out how to supply them. With a numeric argument, -the motion commands are simply executed that many times; for example, a -numeric argument of 4 given to `next-line' causes the cursor to move -down 4 lines. With a negative numeric argument, the motion is -reversed; an argument of -4 given to the `next-line' command would -cause the cursor to move *up* 4 lines. - -`C-n' (`next-line') - Move the cursor down to the next line. - -`C-p' (`prev-line') - Move the cursor up to the previous line. - -`C-a' (`beginning-of-line') - Move the cursor to the start of the current line. - -`C-e' (`end-of-line') - Move the cursor to the end of the current line. - -`C-f' (`forward-char') - Move the cursor forward a character. - -`C-b' (`backward-char') - Move the cursor backward a character. - -`M-f' (`forward-word') - Move the cursor forward a word. - -`M-b' (`backward-word') - Move the cursor backward a word. - -`M-<' (`beginning-of-node') -`b' - Move the cursor to the start of the current node. - -`M->' (`end-of-node') - Move the cursor to the end of the current node. - -`M-r' (`move-to-window-line') - Move the cursor to a specific line of the window. Without a - numeric argument, `M-r' moves the cursor to the start of the line - in the center of the window. With a numeric argument of N, `M-r' - moves the cursor to the start of the Nth line in the window. - - -File: info-stnd.info, Node: Cursor Commands-Footnotes, Up: Cursor Commands - -(1) `M-x' is also a command; it invokes `execute-extended-command'. -*Note Executing an extended command: (emacs)M-x, for more detailed -information. - - -File: info-stnd.info, Node: Scrolling Commands, Next: Node Commands, Prev: Cursor Commands, Up: Top - -Moving Text Within a Window -*************************** - -Sometimes you are looking at a screenful of text, and only part of the -current paragraph you are reading is visible on the screen. The -commands detailed in this section are used to shift which part of the -current node is visible on the screen. - -`SPC' (`scroll-forward') -`C-v' - Shift the text in this window up. That is, show more of the node - which is currently below the bottom of the window. With a numeric - argument, show that many more lines at the bottom of the window; a - numeric argument of 4 would shift all of the text in the window up - 4 lines (discarding the top 4 lines), and show you four new lines - at the bottom of the window. Without a numeric argument, SPC - takes the bottom two lines of the window and places them at the - top of the window, redisplaying almost a completely new screenful - of lines. - -`DEL' (`scroll-backward') -`M-v' - Shift the text in this window down. The inverse of - `scroll-forward'. - -The `scroll-forward' and `scroll-backward' commands can also move -forward and backward through the node structure of the file. If you -press SPC while viewing the end of a node, or DEL while viewing the -beginning of a node, what happens is controlled by the variable -`scroll-behavior'. *Note `scroll-behavior': Variables, for more -information. - -`C-l' (`redraw-display') - Redraw the display from scratch, or shift the line containing the - cursor to a specified location. With no numeric argument, `C-l' - clears the screen, and then redraws its entire contents. Given a - numeric argument of N, the line containing the cursor is shifted - so that it is on the Nth line of the window. - -`C-x w' (`toggle-wrap') - Toggles the state of line wrapping in the current window. - Normally, lines which are longer than the screen width "wrap", - i.e., they are continued on the next line. Lines which wrap have - a `\' appearing in the rightmost column of the screen. You can - cause such lines to be terminated at the rightmost column by - changing the state of line wrapping in the window with `C-x w'. - When a line which needs more space than one screen width to - display is displayed, a `$' appears in the rightmost column of the - screen, and the remainder of the line is invisible. - - -File: info-stnd.info, Node: Node Commands, Next: Searching Commands, Prev: Scrolling Commands, Up: Top - -Selecting a New Node -******************** - -This section details the numerous Info commands which select a new node -to view in the current window. - -The most basic node commands are `n', `p', `u', and `l'. - -When you are viewing a node, the top line of the node contains some Info -"pointers" which describe where the next, previous, and up nodes are. -Info uses this line to move about the node structure of the file when -you use the following commands: - -`n' (`next-node') - Select the `Next' node. - -`p' (`prev-node') - Select the `Prev' node. - -`u' (`up-node') - Select the `Up' node. - -You can easily select a node that you have already viewed in this window -by using the `l' command - this name stands for "last", and actually -moves through the list of already visited nodes for this window. `l' -with a negative numeric argument moves forward through the history of -nodes for this window, so you can quickly step between two adjacent (in -viewing history) nodes. - -`l' (`history-node') - Select the most recently selected node in this window. - -Two additional commands make it easy to select the most commonly -selected nodes; they are `t' and `d'. - -`t' (`top-node') - Select the node `Top' in the current Info file. - -`d' (`dir-node') - Select the directory node (i.e., the node `(dir)'). - -Here are some other commands which immediately result in the selection -of a different node in the current window: - -`<' (`first-node') - Selects the first node which appears in this file. This node is - most often `Top', but it does not have to be. - -`>' (`last-node') - Select the last node which appears in this file. - -`]' (`global-next-node') - Move forward or down through node structure. If the node that you - are currently viewing has a `Next' pointer, that node is selected. - Otherwise, if this node has a menu, the first menu item is - selected. If there is no `Next' and no menu, the same process is - tried with the `Up' node of this node. - -`[' (`global-prev-node') - Move backward or up through node structure. If the node that you - are currently viewing has a `Prev' pointer, that node is selected. - Otherwise, if the node has an `Up' pointer, that node is selected, - and if it has a menu, the last item in the menu is selected. - -You can get the same behavior as `global-next-node' and -`global-prev-node' while simply scrolling through the file with SPC and -DEL; *Note `scroll-behavior': Variables, for more information. - -`g' (`goto-node') - Read the name of a node and select it. No completion is done while - reading the node name, since the desired node may reside in a - separate file. The node must be typed exactly as it appears in - the Info file. A file name may be included as with any node - specification, for example - - `g(emacs)Buffers' - - finds the node `Buffers' in the Info file `emacs'. - -`C-x k' (`kill-node') - Kill a node. The node name is prompted for in the echo area, with - a default of the current node. "Killing" a node means that Info - tries hard to forget about it, removing it from the list of - history nodes kept for the window where that node is found. - Another node is selected in the window which contained the killed - node. - -`C-x C-f' (`view-file') - Read the name of a file and selects the entire file. The command - `C-x C-f FILENAME' - is equivalent to typing - `g(FILENAME)*' - -`C-x C-b' (`list-visited-nodes') - Make a window containing a menu of all of the currently visited - nodes. This window becomes the selected window, and you may use - the standard Info commands within it. - -`C-x b' (`select-visited-node') - Select a node which has been previously visited in a visible - window. This is similar to `C-x C-b' followed by `m', but no - window is created. - - -File: info-stnd.info, Node: Searching Commands, Next: Xref Commands, Prev: Node Commands, Up: Top - -Searching an Info File -********************** - -GNU Info allows you to search for a sequence of characters throughout an -entire Info file, search through the indices of an Info file, or find -areas within an Info file which discuss a particular topic. - -`s' (`search') - Read a string in the echo area and search for it. - -`C-s' (`isearch-forward') - Interactively search forward through the Info file for a string as - you type it. - -`C-r' (`isearch-backward') - Interactively search backward through the Info file for a string as - you type it. - -`i' (`index-search') - Look up a string in the indices for this Info file, and select a - node where the found index entry points to. - -`,' (`next-index-match') - Move to the node containing the next matching index item from the - last `i' command. - -The most basic searching command is `s' (`search'). The `s' command -prompts you for a string in the echo area, and then searches the -remainder of the Info file for an occurrence of that string. If the -string is found, the node containing it is selected, and the cursor is -left positioned at the start of the found string. Subsequent `s' -commands show you the default search string within `[' and `]'; -pressing RET instead of typing a new string will use the default search -string. - -"Incremental searching" is similar to basic searching, but the string -is looked up while you are typing it, instead of waiting until the -entire search string has been specified. - - -File: info-stnd.info, Node: Xref Commands, Next: Window Commands, Prev: Searching Commands, Up: Top - -Selecting Cross References -************************** - -We have already discussed the `Next', `Prev', and `Up' pointers which -appear at the top of a node. In addition to these pointers, a node may -contain other pointers which refer you to a different node, perhaps in -another Info file. Such pointers are called "cross references", or -"xrefs" for short. - -* Menu: - -* Parts of an Xref:: What a cross reference is made of. -* Selecting Xrefs:: Commands for selecting menu or note items. - - -File: info-stnd.info, Node: Parts of an Xref, Next: Selecting Xrefs, Up: Xref Commands - -Parts of an Xref -================ - -Cross references have two major parts: the first part is called the -"label"; it is the name that you can use to refer to the cross -reference, and the second is the "target"; it is the full name of the -node that the cross reference points to. - -The target is separated from the label by a colon `:'; first the label -appears, and then the target. For example, in the sample menu cross -reference below, the single colon separates the label from the target. - - * Foo Label: Foo Target. More information about Foo. - -Note the `.' which ends the name of the target. The `.' is not part of -the target; it serves only to let Info know where the target name ends. - -A shorthand way of specifying references allows two adjacent colons to -stand for a target name which is the same as the label name: - - * Foo Commands:: Commands pertaining to Foo. - -In the above example, the name of the target is the same as the name of -the label, in this case `Foo Commands'. - -You will normally see two types of cross reference while viewing nodes: -"menu" references, and "note" references. Menu references appear -within a node's menu; they begin with a `*' at the beginning of a line, -and continue with a label, a target, and a comment which describes what -the contents of the node pointed to contains. - -Note references appear within the body of the node text; they begin with -`*Note', and continue with a label and a target. - -Like `Next', `Prev', and `Up' pointers, cross references can point to -any valid node. They are used to refer you to a place where more -detailed information can be found on a particular subject. Here is a -cross reference which points to a node within the Texinfo -documentation: *Note Writing an Xref: (texinfo)xref, for more -information on creating your own texinfo cross references. - - -File: info-stnd.info, Node: Selecting Xrefs, Prev: Parts of an Xref, Up: Xref Commands - -Selecting Xrefs -=============== - -The following table lists the Info commands which operate on menu items. - -`1' (`menu-digit') -`2' ... `9' - Within an Info window, pressing a single digit, (such as `1'), - selects that menu item, and places its node in the current window. - For convenience, there is one exception; pressing `0' selects the - *last* item in the node's menu. - -`0' (`last-menu-item') - Select the last item in the current node's menu. - -`m' (`menu-item') - Reads the name of a menu item in the echo area and selects its - node. Completion is available while reading the menu label. - -`M-x find-menu' - Move the cursor to the start of this node's menu. - -This table lists the Info commands which operate on note cross -references. - -`f' (`xref-item') -`r' - Reads the name of a note cross reference in the echo area and - selects its node. Completion is available while reading the cross - reference label. - -Finally, the next few commands operate on menu or note references alike: - -`TAB' (`move-to-next-xref') - Move the cursor to the start of the next nearest menu item or note - reference in this node. You can then use RET - (`select-reference-this-line') to select the menu or note - reference. - -`M-TAB' (`move-to-prev-xref') - Move the cursor the start of the nearest previous menu item or note - reference in this node. - -`RET' (`select-reference-this-line') - Select the menu item or note reference appearing on this line. - - -File: info-stnd.info, Node: Window Commands, Next: Printing Nodes, Prev: Xref Commands, Up: Top - -Manipulating Multiple Windows -***************************** - -A "window" is a place to show the text of a node. Windows have a view -area where the text of the node is displayed, and an associated "mode -line", which briefly describes the node being viewed. - -GNU Info supports multiple windows appearing in a single screen; each -window is separated from the next by its modeline. At any time, there -is only one "active" window, that is, the window in which the cursor -appears. There are commands available for creating windows, changing -the size of windows, selecting which window is active, and for deleting -windows. - -* Menu: - -* The Mode Line:: What appears in the mode line? -* Basic Windows:: Manipulating windows in Info. -* The Echo Area:: Used for displaying errors and reading input. - - -File: info-stnd.info, Node: The Mode Line, Next: Basic Windows, Up: Window Commands - -The Mode Line -============= - -A "mode line" is a line of inverse video which appears at the bottom of -an Info window. It describes the contents of the window just above it; -this information includes the name of the file and node appearing in -that window, the number of screen lines it takes to display the node, -and the percentage of text that is above the top of the window. It can -also tell you if the indirect tags table for this Info file needs to be -updated, and whether or not the Info file was compressed when stored on -disk. - -Here is a sample mode line for a window containing an uncompressed file -named `dir', showing the node `Top'. - - -----Info: (dir)Top, 40 lines --Top--------------------------------------- - ^^ ^ ^^^ ^^ - (file)Node #lines where - -When a node comes from a file which is compressed on disk, this is -indicated in the mode line with two small `z''s. In addition, if the -Info file containing the node has been split into subfiles, the name of -the subfile containing the node appears in the modeline as well: - - --zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- - -When Info makes a node internally, such that there is no corresponding -info file on disk, the name of the node is surrounded by asterisks -(`*'). The name itself tells you what the contents of the window are; -the sample mode line below shows an internally constructed node showing -possible completions: - - -----Info: *Completions*, 7 lines --All----------------------------------- - - -File: info-stnd.info, Node: Basic Windows, Next: The Echo Area, Prev: The Mode Line, Up: Window Commands - -Window Commands -=============== - -It can be convenient to view more than one node at a time. To allow -this, Info can display more than one "window". Each window has its own -mode line (*note The Mode Line::.) and history of nodes viewed in that -window (*note `history-node': Node Commands.). - -`C-x o' (`next-window') - Select the next window on the screen. Note that the echo area can - only be selected if it is already in use, and you have left it - temporarily. Normally, `C-x o' simply moves the cursor into the - next window on the screen, or if you are already within the last - window, into the first window on the screen. Given a numeric - argument, `C-x o' moves over that many windows. A negative - argument causes `C-x o' to select the previous window on the - screen. - -`M-x prev-window' - Select the previous window on the screen. This is identical to - `C-x o' with a negative argument. - -`C-x 2' (`split-window') - Split the current window into two windows, both showing the same - node. Each window is one half the size of the original window, - and the cursor remains in the original window. The variable - `automatic-tiling' can cause all of the windows on the screen to - be resized for you automatically, please *note automatic-tiling: - Variables. for more information. - -`C-x 0' (`delete-window') - Delete the current window from the screen. If you have made too - many windows and your screen appears cluttered, this is the way to - get rid of some of them. - -`C-x 1' (`keep-one-window') - Delete all of the windows excepting the current one. - -`ESC C-v' (`scroll-other-window') - Scroll the other window, in the same fashion that `C-v' might - scroll the current window. Given a negative argument, scroll the - "other" window backward. - -`C-x ^' (`grow-window') - Grow (or shrink) the current window. Given a numeric argument, - grow the current window that many lines; with a negative numeric - argument, shrink the window instead. - -`C-x t' (`tile-windows') - Divide the available screen space among all of the visible windows. - Each window is given an equal portion of the screen in which to - display its contents. The variable `automatic-tiling' can cause - `tile-windows' to be called when a window is created or deleted. - *Note `automatic-tiling': Variables. - - -File: info-stnd.info, Node: The Echo Area, Prev: Basic Windows, Up: Window Commands - -The Echo Area -============= - -The "echo area" is a one line window which appears at the bottom of the -screen. It is used to display informative or error messages, and to -read lines of input from you when that is necessary. Almost all of the -commands available in the echo area are identical to their Emacs -counterparts, so please refer to that documentation for greater depth of -discussion on the concepts of editing a line of text. The following -table briefly lists the commands that are available while input is being -read in the echo area: - -`C-f' (`echo-area-forward') - Move forward a character. - -`C-b' (`echo-area-backward') - Move backward a character. - -`C-a' (`echo-area-beg-of-line') - Move to the start of the input line. - -`C-e' (`echo-area-end-of-line') - Move to the end of the input line. - -`M-f' (`echo-area-forward-word') - Move forward a word. - -`M-b' (`echo-area-backward-word') - Move backward a word. - -`C-d' (`echo-area-delete') - Delete the character under the cursor. - -`DEL' (`echo-area-rubout') - Delete the character behind the cursor. - -`C-g' (`echo-area-abort') - Cancel or quit the current operation. If completion is being read, - `C-g' discards the text of the input line which does not match any - completion. If the input line is empty, `C-g' aborts the calling - function. - -`RET' (`echo-area-newline') - Accept (or forces completion of) the current input line. - -`C-q' (`echo-area-quoted-insert') - Insert the next character verbatim. This is how you can insert - control characters into a search string, for example. - -PRINTING CHARACTER (`echo-area-insert') - Insert the character. - -`M-TAB' (`echo-area-tab-insert') - Insert a TAB character. - -`C-t' (`echo-area-transpose-chars') - Transpose the characters at the cursor. - -The next group of commands deal with "killing", and "yanking" text. -For an in depth discussion of killing and yanking, *note Killing and -Deleting: (emacs)Killing. - -`M-d' (`echo-area-kill-word') - Kill the word following the cursor. - -`M-DEL' (`echo-area-backward-kill-word') - Kill the word preceding the cursor. - -`C-k' (`echo-area-kill-line') - Kill the text from the cursor to the end of the line. - -`C-x DEL' (`echo-area-backward-kill-line') - Kill the text from the cursor to the beginning of the line. - -`C-y' (`echo-area-yank') - Yank back the contents of the last kill. - -`M-y' (`echo-area-yank-pop') - Yank back a previous kill, removing the last yanked text first. - -Sometimes when reading input in the echo area, the command that needed -input will only accept one of a list of several choices. The choices -represent the "possible completions", and you must respond with one of -them. Since there are a limited number of responses you can make, Info -allows you to abbreviate what you type, only typing as much of the -response as is necessary to uniquely identify it. In addition, you can -request Info to fill in as much of the response as is possible; this is -called "completion". - -The following commands are available when completing in the echo area: - -`TAB' (`echo-area-complete') -`SPC' - Insert as much of a completion as is possible. - -`?' (`echo-area-possible-completions') - Display a window containing a list of the possible completions of - what you have typed so far. For example, if the available choices - are: - - bar - foliate - food - forget - - and you have typed an `f', followed by `?', the possible - completions would contain: - - foliate - food - forget - - i.e., all of the choices which begin with `f'. Pressing SPC or - TAB would result in `fo' appearing in the echo area, since all of - the choices which begin with `f' continue with `o'. Now, typing - `l' followed by `TAB' results in `foliate' appearing in the echo - area, since that is the only choice which begins with `fol'. - -`ESC C-v' (`echo-area-scroll-completions-window') - Scroll the completions window, if that is visible, or the "other" - window if not. - - -File: info-stnd.info, Node: Printing Nodes, Next: Miscellaneous Commands, Prev: Window Commands, Up: Top - -Printing Out Nodes -****************** - -You may wish to print out the contents of a node as a quick reference -document for later use. Info provides you with a command for doing -this. In general, we recommend that you use TeX to format the document -and print sections of it, by running `tex' on the Texinfo source file. - -`M-x print-node' - Pipe the contents of the current node through the command in the - environment variable `INFO_PRINT_COMMAND'. If the variable does - not exist, the node is simply piped to `lpr'. - - -File: info-stnd.info, Node: Miscellaneous Commands, Next: Variables, Prev: Printing Nodes, Up: Top - -Miscellaneous Commands -********************** - -GNU Info contains several commands which self-document GNU Info: - -`M-x describe-command' - Read the name of an Info command in the echo area and then display - a brief description of what that command does. - -`M-x describe-key' - Read a key sequence in the echo area, and then display the name and - documentation of the Info command that the key sequence invokes. - -`M-x describe-variable' - Read the name of a variable in the echo area and then display a - brief description of what the variable affects. - -`M-x where-is' - Read the name of an Info command in the echo area, and then display - a key sequence which can be typed in order to invoke that command. - -`C-h' (`get-help-window') -`?' - Create (or Move into) the window displaying `*Help*', and place a - node containing a quick reference card into it. This window - displays the most concise information about GNU Info available. - -`h' (`get-info-help-node') - Try hard to visit the node `(info)Help'. The Info file - `info.texi' distributed with GNU Info contains this node. Of - course, the file must first be processed with `makeinfo', and then - placed into the location of your Info directory. - -Here are the commands for creating a numeric argument: - -`C-u' (`universal-argument') - Start (or multiply by 4) the current numeric argument. `C-u' is a - good way to give a small numeric argument to cursor movement or - scrolling commands; `C-u C-v' scrolls the screen 4 lines, while - `C-u C-u C-n' moves the cursor down 16 lines. - -`M-1' (`add-digit-to-numeric-arg') -`M-2' ... `M-9' - Add the digit value of the invoking key to the current numeric - argument. Once Info is reading a numeric argument, you may just - type the digits of the argument, without the Meta prefix. For - example, you might give `C-l' a numeric argument of 32 by typing: - - `C-u 3 2 C-l' - - or - - `M-3 2 C-l' - -`C-g' is used to abort the reading of a multi-character key sequence, -to cancel lengthy operations (such as multi-file searches) and to -cancel reading input in the echo area. - -`C-g' (`abort-key') - Cancel current operation. - -The `q' command of Info simply quits running Info. - -`q' (`quit') - Exit GNU Info. - -If the operating system tells GNU Info that the screen is 60 lines tall, -and it is actually only 40 lines tall, here is a way to tell Info that -the operating system is correct. - -`M-x set-screen-height' - Read a height value in the echo area and set the height of the - displayed screen to that value. - -Finally, Info provides a convenient way to display footnotes which might -be associated with the current node that you are viewing: - -`ESC C-f' (`show-footnotes') - Show the footnotes (if any) associated with the current node in - another window. You can have Info automatically display the - footnotes associated with a node when the node is selected by - setting the variable `automatic-footnotes'. *Note - `automatic-footnotes': Variables. - - -File: info-stnd.info, Node: Variables, Next: GNU Info Global Index, Prev: Miscellaneous Commands, Up: Top - -Manipulating Variables -********************** - -GNU Info contains several "variables" whose values are looked at by -various Info commands. You can change the values of these variables, -and thus change the behavior of Info to more closely match your -environment and Info file reading manner. - -`M-x set-variable' - Read the name of a variable, and the value for it, in the echo - area and then set the variable to that value. Completion is - available when reading the variable name; often, completion is - available when reading the value to give to the variable, but that - depends on the variable itself. If a variable does *not* supply - multiple choices to complete over, it expects a numeric value. - -`M-x describe-variable' - Read the name of a variable in the echo area and then display a - brief description of what the variable affects. - -Here is a list of the variables that you can set in Info. - -`automatic-footnotes' - When set to `On', footnotes appear and disappear automatically. - This variable is `On' by default. When a node is selected, a - window containing the footnotes which appear in that node is - created, and the footnotes are displayed within the new window. - The window that Info creates to contain the footnotes is called - `*Footnotes*'. If a node is selected which contains no footnotes, - and a `*Footnotes*' window is on the screen, the `*Footnotes*' - window is deleted. Footnote windows created in this fashion are - not automatically tiled so that they can use as little of the - display as is possible. - -`automatic-tiling' - When set to `On', creating or deleting a window resizes other - windows. This variable is `Off' by default. Normally, typing - `C-x 2' divides the current window into two equal parts. When - `automatic-tiling' is set to `On', all of the windows are resized - automatically, keeping an equal number of lines visible in each - window. There are exceptions to the automatic tiling; - specifically, the windows `*Completions*' and `*Footnotes*' are - *not* resized through automatic tiling; they remain their original - size. - -`visible-bell' - When set to `On', GNU Info attempts to flash the screen instead of - ringing the bell. This variable is `Off' by default. Of course, - Info can only flash the screen if the terminal allows it; in the - case that the terminal does not allow it, the setting of this - variable has no effect. However, you can make Info perform - quietly by setting the `errors-ring-bell' variable to `Off'. - -`errors-ring-bell' - When set to `On', errors cause the bell to ring. The default - setting of this variable is `On'. - -`gc-compressed-files' - When set to `On', Info garbage collects files which had to be - uncompressed. The default value of this variable is `Off'. - Whenever a node is visited in Info, the Info file containing that - node is read into core, and Info reads information about the tags - and nodes contained in that file. Once the tags information is - read by Info, it is never forgotten. However, the actual text of - the nodes does not need to remain in core unless a particular Info - window needs it. For non-compressed files, the text of the nodes - does not remain in core when it is no longer in use. But - de-compressing a file can be a time consuming operation, and so - Info tries hard not to do it twice. `gc-compressed-files' tells - Info it is okay to garbage collect the text of the nodes of a file - which was compressed on disk. - -`show-index-match' - When set to `On', the portion of the matched search string is - highlighted in the message which explains where the matched search - string was found. The default value of this variable is `On'. - When Info displays the location where an index match was found, - (*note `next-index-match': Searching Commands.), the portion of the - string that you had typed is highlighted by displaying it in the - inverse case from its surrounding characters. - -`scroll-behavior' - Control what happens when forward scrolling is requested at the - end of a node, or when backward scrolling is requested at the - beginning of a node. The default value for this variable is - `Continuous'. There are three possible values for this variable: - - `Continuous' - Try to get the first item in this node's menu, or failing - that, the `Next' node, or failing that, the `Next' of the - `Up'. This behavior is identical to using the `]' - (`global-next-node') and `[' (`global-prev-node') commands. - - `Next Only' - Only try to get the `Next' node. - - `Page Only' - Simply give up, changing nothing. If `scroll-behavior' is - `Page Only', no scrolling command can change the node that is - being viewed. - -`scroll-step' - The number of lines to scroll when the cursor moves out of the - window. Scrolling happens automatically if the cursor has moved - out of the visible portion of the node text when it is time to - display. Usually the scrolling is done so as to put the cursor on - the center line of the current window. However, if the variable - `scroll-step' has a nonzero value, Info attempts to scroll the - node text by that many lines; if that is enough to bring the - cursor back into the window, that is what is done. The default - value of this variable is 0, thus placing the cursor (and the text - it is attached to) in the center of the window. Setting this - variable to 1 causes a kind of "smooth scrolling" which some - people prefer. - -`ISO-Latin' - When set to `On', Info accepts and displays ISO Latin characters. - By default, Info assumes an ASCII character set. `ISO-Latin' tells - Info that it is running in an environment where the European - standard character set is in use, and allows you to input such - characters to Info, as well as display them. - - -File: info-stnd.info, Node: GNU Info Global Index, Prev: Variables, Up: Top - -Global Index -************ - -* Menu: - -* ,: Searching Commands. -* 0, in Info windows: Selecting Xrefs. -* 1 ... 9, in Info windows: Selecting Xrefs. -* 1 ... 9, in Info windows: Selecting Xrefs. -* <: Node Commands. -* >: Node Commands. -* ?, in Info windows: Miscellaneous Commands. -* ?, in the echo area: The Echo Area. -* -subnodes, command line option: Options. -* abort-key: Miscellaneous Commands. -* add-digit-to-numeric-arg: Miscellaneous Commands. -* arguments, command line: Options. -* automatic-footnotes: Variables. -* automatic-tiling: Variables. -* b, in Info windows: Cursor Commands. -* backward-char: Cursor Commands. -* backward-word: Cursor Commands. -* beginning-of-line: Cursor Commands. -* beginning-of-node: Cursor Commands. -* C-a, in Info windows: Cursor Commands. -* C-a, in the echo area: The Echo Area. -* C-b, in Info windows: Cursor Commands. -* C-b, in the echo area: The Echo Area. -* C-d, in the echo area: The Echo Area. -* C-e, in Info windows: Cursor Commands. -* C-e, in the echo area: The Echo Area. -* C-f, in Info windows: Cursor Commands. -* C-f, in the echo area: The Echo Area. -* C-g, in Info windows: Miscellaneous Commands. -* C-g, in the echo area: The Echo Area. -* C-h: Miscellaneous Commands. -* C-k, in the echo area: The Echo Area. -* C-l: Scrolling Commands. -* C-n: Cursor Commands. -* C-p: Cursor Commands. -* C-q, in the echo area: The Echo Area. -* C-r: Searching Commands. -* C-s: Searching Commands. -* C-t, in the echo area: The Echo Area. -* C-u: Miscellaneous Commands. -* C-v: Scrolling Commands. -* C-w: Scrolling Commands. -* C-x 0: Basic Windows. -* C-x 1: Basic Windows. -* C-x 2: Basic Windows. -* C-x b: Node Commands. -* C-x C-b: Node Commands. -* C-x C-f: Node Commands. -* C-x DEL, in the echo area: The Echo Area. -* C-x k: Node Commands. -* C-x o: Basic Windows. -* C-x t: Basic Windows. -* C-x ^: Basic Windows. -* C-y, in the echo area: The Echo Area. -* cancelling the current operation: Miscellaneous Commands. -* cancelling typeahead: Miscellaneous Commands. -* command line options: Options. -* commands, describing: Miscellaneous Commands. -* cursor, moving: Cursor Commands. -* d: Node Commands. -* DEL, in Info windows: Scrolling Commands. -* DEL, in the echo area: The Echo Area. -* delete-window: Basic Windows. -* describe-command: Miscellaneous Commands. -* describe-key: Miscellaneous Commands. -* describe-variable: Variables. -* dir-node: Node Commands. -* directory path: Options. -* echo area: The Echo Area. -* echo-area-abort: The Echo Area. -* echo-area-backward: The Echo Area. -* echo-area-backward-kill-line: The Echo Area. -* echo-area-backward-kill-word: The Echo Area. -* echo-area-backward-word: The Echo Area. -* echo-area-beg-of-line: The Echo Area. -* echo-area-complete: The Echo Area. -* echo-area-delete: The Echo Area. -* echo-area-end-of-line: The Echo Area. -* echo-area-forward: The Echo Area. -* echo-area-forward-word: The Echo Area. -* echo-area-insert: The Echo Area. -* echo-area-kill-line: The Echo Area. -* echo-area-kill-word: The Echo Area. -* echo-area-newline: The Echo Area. -* echo-area-possible-completions: The Echo Area. -* echo-area-quoted-insert: The Echo Area. -* echo-area-rubout: The Echo Area. -* echo-area-scroll-completions-window: The Echo Area. -* echo-area-tab-insert: The Echo Area. -* echo-area-transpose-chars: The Echo Area. -* echo-area-yank: The Echo Area. -* echo-area-yank-pop: The Echo Area. -* end-of-line: Cursor Commands. -* end-of-node: Cursor Commands. -* errors-ring-bell: Variables. -* ESC C-f: Miscellaneous Commands. -* ESC C-v, in Info windows: Basic Windows. -* ESC C-v, in the echo area: The Echo Area. -* f: Selecting Xrefs. -* file, outputting to: Options. -* find-menu: Selecting Xrefs. -* first-node: Node Commands. -* footnotes, displaying: Miscellaneous Commands. -* forward-char: Cursor Commands. -* forward-word: Cursor Commands. -* functions, describing: Miscellaneous Commands. -* g: Node Commands. -* gc-compressed-files: Variables. -* get-help-window: Miscellaneous Commands. -* get-info-help-node: Miscellaneous Commands. -* global-next-node: Node Commands. -* global-prev-node: Node Commands. -* goto-node: Node Commands. -* grow-window: Basic Windows. -* h: Miscellaneous Commands. -* history-node: Node Commands. -* i: Searching Commands. -* index-search: Searching Commands. -* Info file, selecting: Options. -* INFO_PRINT_COMMAND, environment variable: Printing Nodes. -* isearch-backward: Searching Commands. -* isearch-forward: Searching Commands. -* ISO Latin characters: Variables. -* ISO-Latin: Variables. -* keep-one-window: Basic Windows. -* keys, describing: Miscellaneous Commands. -* kill-node: Node Commands. -* l: Node Commands. -* last-menu-item: Selecting Xrefs. -* last-node: Node Commands. -* list-visited-nodes: Node Commands. -* m: Selecting Xrefs. -* M-1 ... M-9: Miscellaneous Commands. -* M-<: Cursor Commands. -* M->: Cursor Commands. -* M-b, in Info windows: Cursor Commands. -* M-b, in the echo area: The Echo Area. -* M-d, in the echo area: The Echo Area. -* M-DEL, in the echo area: The Echo Area. -* M-f, in Info windows: Cursor Commands. -* M-f, in the echo area: The Echo Area. -* M-r: Cursor Commands. -* M-TAB, in Info windows: Selecting Xrefs. -* M-TAB, in the echo area: The Echo Area. -* M-v: Scrolling Commands. -* M-y, in the echo area: The Echo Area. -* menu, following: Options. -* menu-digit: Selecting Xrefs. -* menu-item: Selecting Xrefs. -* move-to-next-xref: Selecting Xrefs. -* move-to-prev-xref: Selecting Xrefs. -* move-to-window-line: Cursor Commands. -* n: Node Commands. -* next-index-match: Searching Commands. -* next-line: Cursor Commands. -* next-node: Node Commands. -* next-window: Basic Windows. -* node, selecting: Options. -* nodes, selection of: Node Commands. -* numeric arguments: Miscellaneous Commands. -* outputting to a file: Options. -* p: Node Commands. -* prev-line: Cursor Commands. -* prev-node: Node Commands. -* prev-window: Basic Windows. -* print-node: Printing Nodes. -* printing: Printing Nodes. -* printing characters, in the echo area: The Echo Area. -* q: Miscellaneous Commands. -* quit: Miscellaneous Commands. -* quitting: Miscellaneous Commands. -* r: Selecting Xrefs. -* redraw-display: Scrolling Commands. -* RET, in Info windows: Selecting Xrefs. -* RET, in the echo area: The Echo Area. -* s: Searching Commands. -* screen, changing the height of: Miscellaneous Commands. -* scroll-backward: Scrolling Commands. -* scroll-behavior: Variables. -* scroll-forward: Scrolling Commands. -* scroll-other-window: Basic Windows. -* scroll-step: Variables. -* scrolling: Scrolling Commands. -* scrolling through node structure: Scrolling Commands. -* search: Searching Commands. -* searching: Searching Commands. -* select-reference-this-line: Selecting Xrefs. -* select-visited-node: Node Commands. -* set-screen-height: Miscellaneous Commands. -* set-variable: Variables. -* show-footnotes: Miscellaneous Commands. -* show-index-match: Variables. -* SPC, in Info windows: Scrolling Commands. -* SPC, in the echo area: The Echo Area. -* split-window: Basic Windows. -* t: Node Commands. -* TAB, in Info windows: Selecting Xrefs. -* TAB, in the echo area: The Echo Area. -* tile-windows: Basic Windows. -* tiling: Basic Windows. -* toggle-wrap: Scrolling Commands. -* top-node: Node Commands. -* u: Node Commands. -* universal-argument: Miscellaneous Commands. -* up-node: Node Commands. -* variables, describing: Variables. -* variables, setting: Variables. -* version information: Options. -* view-file: Node Commands. -* visible-bell: Variables. -* where-is: Miscellaneous Commands. -* windows, creating: Basic Windows. -* windows, deleting: Basic Windows. -* windows, manipulating: Window Commands. -* windows, selecting: Basic Windows. -* xref-item: Selecting Xrefs. -* [: Node Commands. -* ]: Node Commands. - - - -Tag Table: -Node: Top1263 -Node: What is Info2593 -Node: Options3127 -Node: Options-Footnotes6157 -Node: Cursor Commands6411 -Node: Cursor Commands-Footnotes8906 -Node: Scrolling Commands9136 -Node: Node Commands11600 -Node: Searching Commands15563 -Node: Xref Commands17151 -Node: Parts of an Xref17766 -Node: Selecting Xrefs19711 -Node: Window Commands21298 -Node: The Mode Line22233 -Node: Basic Windows23872 -Node: The Echo Area26374 -Node: Printing Nodes30531 -Node: Miscellaneous Commands31174 -Node: Variables34345 -Node: GNU Info Global Index40515 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/info/info.info b/gnu/usr.bin/texinfo/info/info.info deleted file mode 100644 index b6fd8508b832..000000000000 --- a/gnu/usr.bin/texinfo/info/info.info +++ /dev/null @@ -1,777 +0,0 @@ -This is Info file info.info, produced by Makeinfo-1.55 from the input -file info.texi. - - This file describes how to use Info, the on-line, menu-driven GNU -documentation system. - - Copyright (C) 1989, 1992 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: info.info, Node: Top, Next: Getting Started, Prev: (dir), Up: (dir) - -Info: An Introduction -********************* - - Info is a program for reading documentation, which you are using now. - - To learn how to use Info, type the command `h'. It brings you to a -programmed instruction sequence. - - To learn advanced Info commands, type `n' twice. This brings you to -`Info for Experts', skipping over the . `Getting Started' chapter. - -* Menu: - -* Getting Started:: -* Advanced Info:: -* Create an Info File:: - - -File: info.info, Node: Getting Started, Next: Advanced Info, Prev: Top, Up: Top - -Getting Started -*************** - - This first part of the Info manual describes how to get around inside -of Info. The second part of the manual describes various advanced Info -commands, and how to write an Info as distinct from a Texinfo file. -The third part is about how to generate Info files from Texinfo files. - -* Menu: - -* Help-Small-Screen:: Starting Info on a Small Screen -* Help:: How to use Info -* Help-P:: Returning to the Previous node -* Help-^L:: The Space, Rubout, B and ^L commands. -* Help-M:: Menus -* Help-Adv:: Some advanced Info commands -* Help-Q:: Quitting Info - - -File: info.info, Node: Help-Small-Screen, Next: Help, Up: Getting Started - -Starting Info on a Small Screen -=============================== - - Since your terminal has an unusually small number of lines on its -screen, it is necessary to give you special advice at the beginning. - - If you see the text `--All----' at near the bottom right corner of -the screen, it means the entire text you are looking at fits on the -screen. If you see `--Top----' instead, it means that there is more -text below that does not fit. To move forward through the text and see -another screen full, press the Space bar, SPC. To move back up, press -the key labeled `Rubout' or `Delete' or DEL. - - Here are 40 lines of junk, so you can try SPC and DEL and see what -they do. At the end are instructions of what you should do next. - - This is line 17 -This is line 18 -This is line 19 -This is line 20 -This is line 21 -This is line 22 -This is line 23 -This is line 24 -This is line 25 -This is line 26 -This is line 27 -This is line 28 -This is line 29 -This is line 30 -This is line 31 -This is line 32 -This is line 33 -This is line 34 -This is line 35 -This is line 36 -This is line 37 -This is line 38 -This is line 39 -This is line 40 -This is line 41 -This is line 42 -This is line 43 -This is line 44 -This is line 45 -This is line 46 -This is line 47 -This is line 48 -This is line 49 -This is line 50 -This is line 51 -This is line 52 -This is line 53 -This is line 54 -This is line 55 -This is line 56 -If you have managed to get here, go back to the beginning with DEL, and -come back here again, then you understand SPC and DEL. So now type an -`n'--just one character; do not type the quotes and do not type the -Return key, RET, afterward--to get to the normal start of the course. - - -File: info.info, Node: Help, Next: Help-P, Prev: Help-Small-Screen, Up: Getting Started - -How to use Info -=============== - - You are talking to the program Info, for reading documentation. - - Right now you are looking at one "Node" of Information. A node -contains text describing a specific topic at a specific level of -detail. This node's topic is "how to use Info". - - The top line of a node is its "header". This node's header (look at -it now) says that it is the node named `Help' in the file `info'. It -says that the `Next' node after this one is the node called `Help-P'. -An advanced Info command lets you go to any node whose name you know. - - Besides a `Next', a node can have a `Previous' or an `Up'. This -node has a `Previous' but no `Up', as you can see. - - Now it is time to move on to the `Next' node, named `Help-P'. - - >> Type `n' to move there. Type just one character; do not type -the quotes and do not type a RET afterward. - - `>>' in the margin means it is really time to try a command. - - -File: info.info, Node: Help-P, Next: Help-^L, Prev: Help, Up: Getting Started - -Returning to the Previous node -============================== - - This node is called `Help-P'. The `Previous' node, as you see, is -`Help', which is the one you just came from using the `n' command. -Another `n' command now would take you to the next node, `Help-^L'. - - >> But do not do that yet. First, try the `p' command, which takes - you to the `Previous' node. When you get there, you can do an `n' -again to return here. - - This all probably seems insultingly simple so far, but *do not* be -led into skimming. Things will get more complicated soon. Also, do -not try a new command until you are told it is time to. Otherwise, you -may make Info skip past an important warning that was coming up. - - >> Now do an `n' to get to the node `Help-^L' and learn more. - - -File: info.info, Node: Help-^L, Next: Help-M, Prev: Help-P, Up: Getting Started - -The Space, Rubout, B and ^L commands. -===================================== - - This node's header tells you that you are now at node `Help-^L', and -that `p' would get you back to `Help-P'. The node's title is -underlined; it says what the node is about (most nodes have titles). - - This is a big node and it does not all fit on your display screen. -You can tell that there is more that is not visible because you can see -the string `--Top-----' rather than `--All----' near the bottom right -corner of the screen. - - The SPC, DEL and `b' commands exist to allow you to "move around" in -a node that does not all fit on the screen at once. SPC moves forward, -to show what was below the bottom of the screen. DEL moves backward, -to show what was above the top of the screen (there is not anything -above the top until you have typed some spaces). - - >> Now try typing a SPC (afterward, type a DEL to return here). - - When you type the SPC, the two lines that were at the bottom of the -screen appear at the top, followed by more lines. DEL takes the two -lines from the top and moves them to the bottom, *usually*, but if -there are not a full screen's worth of lines above them they may not -make it all the way to the bottom. - - If you type a SPC when there is no more to see, it rings the bell -and otherwise does nothing. The same goes for a DEL when the header of -the node is visible. - - If your screen is ever garbaged, you can tell Info to print it out -again by typing `C-l' (`Control-L', that is--hold down "Control" and -type an L or `l'). - - >> Type `C-l' now. - - To move back to the beginning of the node you are on, you can type a -lot of DELs. You can also type simply `b' for beginning. - - >> Try that now. (I have put in enough verbiage to make sure you are - not on the first screenful now). Then come back, typing SPC -several times. - - You have just learned a considerable number of commands. If you -want to use one but have trouble remembering which, you should type a ? -which prints out a brief list of commands. When you are finished -looking at the list, make it go away by typing a SPC. - - >> Type a ? now. After it finishes, type a SPC. - - (If you are using the standalone Info reader, type `l' to return -here.) - - From now on, you will encounter large nodes without warning, and -will be expected to know how to use SPC and DEL to move around in them -without being told. Since not all terminals have the same size screen, -it would be impossible to warn you anyway. - - >> Now type `n' to see the description of the `m' command. - - -File: info.info, Node: Help-M, Next: Help-Adv, Prev: Help-^L, Up: Getting Started - -Menus -===== - - Menus and the `m' command - - With only the `n' and `p' commands for moving between nodes, nodes -are restricted to a linear sequence. Menus allow a branching -structure. A menu is a list of other nodes you can move to. It is -actually just part of the text of the node formatted specially so that -Info can interpret it. The beginning of a menu is always identified by -a line which starts with `* Menu:'. A node contains a menu if and only -if it has a line in it which starts that way. The only menu you can -use at any moment is the one in the node you are in. To use a menu in -any other node, you must move to that node first. - - After the start of the menu, each line that starts with a `*' -identifies one subtopic. The line usually contains a brief name for -the subtopic (followed by a `:'), the name of the node that talks about -that subtopic, and optionally some further description of the subtopic. -Lines in the menu that do not start with a `*' have no special -meaning--they are only for the human reader's benefit and do not define -additional subtopics. Here is an example: - - * Foo: FOO's Node This tells about FOO - - The subtopic name is Foo, and the node describing it is `FOO's Node'. -The rest of the line is just for the reader's Information. [[ But this -line is not a real menu item, simply because there is no line above it -which starts with `* Menu:'.]] - - When you use a menu to go to another node (in a way that will be -described soon), what you specify is the subtopic name, the first thing -in the menu line. Info uses it to find the menu line, extracts the -node name from it, and goes to that node. The reason that there is -both a subtopic name and a node name is that the node name must be -meaningful to the computer and may therefore have to be ugly looking. -The subtopic name can be chosen just to be convenient for the user to -specify. Often the node name is convenient for the user to specify and -so both it and the subtopic name are the same. There is an -abbreviation for this: - - * Foo:: This tells about FOO - -This means that the subtopic name and node name are the same; they are -both `Foo'. - - >> Now use SPCs to find the menu in this node, then come back to -the front with a `b'. As you see, a menu is actually visible in its -node. If you cannot find a menu in a node by looking at it, then -the node does not have a menu and the `m' command is not available. - - The command to go to one of the subnodes is `m'--but *do not do it -yet!* Before you use `m', you must understand the difference between -commands and arguments. So far, you have learned several commands that -do not need arguments. When you type one, Info processes it and is -instantly ready for another command. The `m' command is different: it -is incomplete without the "name of the subtopic". Once you have typed -`m', Info tries to read the subtopic name. - - Now look for the line containing many dashes near the bottom of the -screen. There is one more line beneath that one, but usually it is -blank If it is empty, Info is ready for a command, such as `n' or `b' -or SPC or `m'. If that line contains text ending in a colon, it mean -Info is trying to read the "argument" to a command. At such times, -commands do not work, because Info tries to use them as the argument. -You must either type the argument and finish the command you started, -or type `Control-g' to cancel the command. When you have done one of -those things, the line becomes blank again. - - The command to go to a subnode via a menu is `m'. After you type -the `m', the line at the bottom of the screen says `Menu item: '. You -must then type the name of the subtopic you want, and end it with a RET. - - You can abbreviate the subtopic name. If the abbreviation is not -unique, the first matching subtopic is chosen. Some menus put the -shortest possible abbreviation for each subtopic name in capital -letters, so you can see how much you need to type. It does not matter -whether you use upper case or lower case when you type the subtopic. -You should not put any spaces at the end, or inside of the item name, -except for one space where a space appears in the item in the menu. - - Here is a menu to give you a chance to practice. - - * Menu: The menu starts here. - - This menu givs you three ways of going to one place, Help-FOO. - - * Foo: Help-FOO. A node you can visit for fun. -* Bar: Help-FOO. Strange! two ways to get to the same place. -* Help-FOO:: And yet another! ->> Now type just an `m' and see what happens: - - Now you are "inside" an `m' command. Commands cannot be used now; -the next thing you will type must be the name of a subtopic. - - You can change your mind about doing the `m' by typing Control-g. - - >> Try that now; notice the bottom line clear. - - >> Then type another `m'. - - >> Now type `BAR' item name. Do not type RET yet. - - While you are typing the item name, you can use the DEL character to -cancel one character at a time if you make a mistake. - - >> Type one to cancel the `R'. You could type another `R' to -replace it. You do not have to, since `BA' is a valid abbreviation. - - >> Now you are ready to go. Type a RET. - - After visiting Help-FOO, you should return here. - - >> Type `n' to see more commands. - - Here is another way to get to Help-FOO, a menu. You can ignore this -if you want, or else try it (but then please come back to here). - -* Menu: - -* Help-FOO:: - - -File: info.info, Node: Help-FOO, Up: Help-M - -The `u' command ---------------- - - Congratulations! This is the node `Help-FOO'. Unlike the other -nodes you have seen, this one has an `Up': `Help-M', the node you just -came from via the `m' command. This is the usual convention--the nodes -you reach from a menu have `Up' nodes that lead back to the menu. -Menus move Down in the tree, and `Up' moves Up. `Previous', on the -other hand, is usually used to "stay on the same level but go backwards" - - You can go back to the node `Help-M' by typing the command `u' for -"Up". That puts you at the *front* of the node--to get back to where -you were reading you have to type some SPCs. - - >> Now type `u' to move back up to `Help-M'. - - -File: info.info, Node: Help-Adv, Next: Help-Q, Prev: Help-M, Up: Getting Started - -Some advanced Info commands -=========================== - - The course is almost over, so please stick with it to the end. - - If you have been moving around to different nodes and wish to -retrace your steps, the `l' command (`l' for "last") will do that, one -node at a time. If you have been following directions, an `l' command -now will get you back to `Help-M'. Another `l' command would undo the -`u' and get you back to `Help-FOO'. Another `l' would undo the `m' and -get you back to `Help-M'. - - >> Try typing three `l''s, pausing in between to see what each -`l' does. - - Then follow directions again and you will end up back here. - - Note the difference between `l' and `p': `l' moves to where *you* -last were, whereas `p' always moves to the node which the header says -is the `Previous' node (from this node, to `Help-M'). - - The `d' command gets you instantly to the Directory node. This -node, which is the first one you saw when you entered Info, has a menu -which leads (directly, or indirectly through other menus), to all the -nodes that exist. - - >> Try doing a `d', then do an `l' to return here (yes, *do* -return). - - Sometimes, in Info documentation, you will see a cross reference. -Cross references look like this: *Note Cross: Help-Cross. That is a -real, live cross reference which is named `Cross' and points at the -node named `Help-Cross'. - - If you wish to follow a cross reference, you must use the `f' -command. The `f' must be followed by the cross reference name (in this -case, `Cross'). You can use DEL to edit the name, and if you change -your mind about following any reference you can use `Control-g' to -cancel the command. - - Completion is available in the `f' command; you can complete among -all the cross reference names in the current node. - - >> Type `f', followed by `Cross', and a RET. - - To get a list of all the cross references in the current node, you -can type `?' after an `f'. The `f' continues to await a cross -reference name even after printing the list, so if you do not actually -want to follow a reference you should type a `Control-g' to cancel the -`f'. - - >> Type "f?" to get a list of the footnotes in this node. Then type -a `Control-g' and see how the `f' gives up. - - >> Now type `n' to see the last node of the course. - - -File: info.info, Node: Help-Cross, Up: Help-Adv - -The node reached by the cross reference in Info ------------------------------------------------ - - This is the node reached by the cross reference named `Cross'. - - While this node is specifically intended to be reached by a cross -reference, most cross references lead to nodes that "belong" someplace -else far away in the structure of Info. So you cannot expect the -footnote to have a `Next', `Previous' or `Up' pointing back to where -you came from. In general, the `l' (el) command is the only way to get -back there. - - >> Type `l' to return to the node where the cross reference was. - - -File: info.info, Node: Help-Q, Prev: Help-Adv, Up: Getting Started - -Quitting Info -============= - - To get out of Info, back to what you were doing before, type `q' for -"Quit". - - This is the end of the course on using Info. There are some other -commands that are not essential or are meant for experienced users; -they are useful, and you can find them by looking in the directory for -documentation on Info. Finding them will be a good exercise in using -Info in the usual manner. - - >> Type `d' to go to the Info directory node; then type `mInfo' -and RET, to get to the node about Info and see what other help is -available. - - -File: info.info, Node: Advanced Info, Next: Create an Info File, Prev: Getting Started, Up: Top - -Info for Experts -**************** - - This chapter describes various advanced Info commands, and how to -write an Info as distinct from a Texinfo file. (However, in most -cases, writing a Texinfo file is better, since you can use it *both* to -generate an Info file and to make a printed manual. *Note Overview of -Texinfo: (texinfo)Top.) - -* Menu: - -* Expert:: Advanced Info commands: g, s, e, and 1 - 5. -* Add:: Describes how to add new nodes to the hierarchy. - Also tells what nodes look like. -* Menus:: How to add to or create menus in Info nodes. -* Cross-refs:: How to add cross-references to Info nodes. -* Tags:: How to make tag tables for Info files. -* Checking:: Checking an Info File - - -File: info.info, Node: Expert, Next: Add, Up: Advanced Info - -Advanced Info Commands -====================== - - `g', `s', `1', - `5', and `e' - - If you know a node's name, you can go there by typing `g', the name, -and RET. Thus, `gTopRET' would go to the node called `Top' in this -file (its directory node). `gExpertRET' would come back here. - - Unlike `m', `g' does not allow the use of abbreviations. - - To go to a node in another file, you can include the filename in the -node name by putting it at the front, in parentheses. Thus, -`g(dir)TopRET' would go to the Info Directory node, which is node `Top' -in the file `dir'. - - The node name `*' specifies the whole file. So you can look at all -of the current file by typing `g*RET' or all of any other file with -`g(FILENAME)RET'. - - The `s' command allows you to search a whole file for a string. It -switches to the next node if and when that is necessary. You type `s' -followed by the string to search for, terminated by RET. To search for -the same string again, just `s' followed by RET will do. The file's -nodes are scanned in the order they are in in the file, which has no -necessary relationship to the order that they may be in in the tree -structure of menus and `next' pointers. But normally the two orders -are not very different. In any case, you can always do a `b' to find -out what node you have reached, if the header is not visible (this can -happen, because `s' puts your cursor at the occurrence of the string, -not at the beginning of the node). - - If you grudge the system each character of type-in it requires, you -might like to use the commands `1', `2', `3', `4', and `5'. They are -short for the `m' command together with an argument. "1", "2", "3", -"4", and "5". `1' goes through the first item in the current node's -menu; `2' goes through the second item, etc. Note that numbers larger -than 5 are not allowed. If the item you want is that far down, you are -better off using an abbreviation for its name than counting. - - The Info command `e' changes from Info mode to an ordinary Emacs -editing mode, so that you can edit the text of the current node. Type -`C-c C-c' to switch back to Info. The `e' command is allowed only if -the variable `Info-enable-edit' is non-`nil'. - - -File: info.info, Node: Add, Next: Menus, Prev: Expert, Up: Advanced Info - -Adding a new node to Info -========================= - - To add a new topic to the list in the directory, you must: - - 1. Create a node, in some file, to document that topic. - - 2. Put that topic in the menu in the directory. *Note Menu: Menus. - - The new node can live in an existing documentation file, or in a new -one. It must have a ^_ character before it (invisible to the user; -this node has one but you cannot see it), and it ends with either a ^_, -a ^L, or the end of file. Note: If you put in a ^L to end a new node, -be sure that there is a ^_ after it to start the next one, since ^L -cannot *start* a node. Also, a nicer way to make a node boundary be a -page boundary as well is to put a ^L *right after* the ^_. - - The ^_ starting a node must be followed by a newline or a ^L -newline, after which comes the node's header line. The header line -must give the node's name (by which Info finds it), and state the names -of the `Next', `Previous', and `Up' nodes (if there are any). As you -can see, this node's `Up' node is the node `Top', which points at all -the documentation for Info. The `Next' node is `Menus'. - - The keywords "Node", "Previous", "Up" and "Next", may appear in any -order, anywhere in the header line, but the recommended order is the -one in this sentence. Each keyword must be followed by a colon, spaces -and tabs, and then the appropriate name. The name may be terminated -with a tab, a comma, or a newline. A space does not end it; node names -may contain spaces. The case of letters in the names is insignificant. - - A node name has two forms. A node in the current file is named by -what appears after the `Node: ' in that node's first line. For -example, this node's name is `Add'. A node in another file is named by -`(FILENAME)NODE-WITHIN-FILE', as in `(info)Add' for this node. If the -file name is relative, it is taken starting from the standard Info file -directory of your site. The name `(FILENAME)Top' can be abbreviated to -just `(FILENAME)'. By convention, the name `Top' is used for the -"highest" node in any single file--the node whose `Up' points out of -the file. The Directory node is `(dir)'. The `Top' node of a document -file listed in the Directory should have an `Up: (dir)' in it. - - The node name `*' is special: it refers to the entire file. Thus, -`g*' shows you the whole current file. The use of the node `*' is to -make it possible to make old-fashioned, unstructured files into nodes -of the tree. - - The `Node:' name, in which a node states its own name, must not -contain a filename, since Info when searching for a node does not -expect one to be there. The `Next', `Previous' and `Up' names may -contain them. In this node, since the `Up' node is in the same file, -it was not necessary to use one. - - Note that the nodes in this file have a file name in the header -line. The file names are ignored by Info, but they serve as comments -to help identify the node for the user. - - -File: info.info, Node: Menus, Next: Cross-refs, Prev: Add, Up: Advanced Info - -How to Create Menus -=================== - - Any node in the Info hierarchy may have a "menu"--a list of subnodes. -The `m' command searches the current node's menu for the topic which it -reads from the terminal. - - A menu begins with a line starting with `* Menu:'. The rest of the -line is a comment. After the starting line, every line that begins -with a `* ' lists a single topic. The name of the topic-the argument -that the user must give to the `m' command to select this topic--comes -right after the star and space, and is followed by a colon, spaces and -tabs, and the name of the node which discusses that topic. The node -name, like node names following `Next', `Previous' and `Up', may be -terminated with a tab, comma, or newline; it may also be terminated -with a period. - - If the node name and topic name are the same, than rather than -giving the name twice, the abbreviation `* NAME::' may be used (and -should be used, whenever possible, as it reduces the visual clutter in -the menu). - - It is considerate to choose the topic names so that they differ from -each other very near the beginning--this allows the user to type short -abbreviations. In a long menu, it is a good idea to capitalize the -beginning of each item name which is the minimum acceptable -abbreviation for it (a long menu is more than 5 or so entries). - - The nodes listed in a node's menu are called its "subnodes", and it -is their "superior". They should each have an `Up:' pointing at the -superior. It is often useful to arrange all or most of the subnodes in -a sequence of `Next' and `Previous' pointers so that someone who wants -to see them all need not keep revisiting the Menu. - - The Info Directory is simply the menu of the node `(dir)Top'--that -is, node `Top' in file `.../info/dir'. You can put new entries in that -menu just like any other menu. The Info Directory is *not* the same as -the file directory called `info'. It happens that many of Info's files -live on that file directory, but they do not have to; and files on that -directory are not automatically listed in the Info Directory node. - - Also, although the Info node graph is claimed to be a "hierarchy", -in fact it can be *any* directed graph. Shared structures and pointer -cycles are perfectly possible, and can be used if they are appropriate -to the meaning to be expressed. There is no need for all the nodes in -a file to form a connected structure. In fact, this file has two -connected components. You are in one of them, which is under the node -`Top'; the other contains the node `Help' which the `h' command goes -to. In fact, since there is no garbage collector, nothing terrible -happens if a substructure is not pointed to, but such a substructure is -rather useless since nobody can ever find out that it exists. - - -File: info.info, Node: Cross-refs, Next: Tags, Prev: Menus, Up: Advanced Info - -Creating Cross References -========================= - - A cross reference can be placed anywhere in the text, unlike a menu -item which must go at the front of a line. A cross reference looks -like a menu item except that it has `*note' instead of `*'. It -*cannot* be terminated by a `)', because `)''s are so often part of -node names. If you wish to enclose a cross reference in parentheses, -terminate it with a period first. Here are two examples of cross -references pointers: - - *Note details: commands. (See *note 3: Full Proof.) - - They are just examples. The places they "lead to" do not really -exist! - - -File: info.info, Node: Tags, Next: Checking, Prev: Cross-refs, Up: Advanced Info - -Tag Tables for Info Files -========================= - - You can speed up the access to nodes of a large Info file by giving -it a tag table. Unlike the tag table for a program, the tag table for -an Info file lives inside the file itself and is used automatically -whenever Info reads in the file. - - To make a tag table, go to a node in the file using Emacs Info mode -and type `M-x Info-tagify'. Then you must use `C-x C-s' to save the -file. - - Once the Info file has a tag table, you must make certain it is up -to date. If, as a result of deletion of text, any node moves back more -than a thousand characters in the file from the position recorded in -the tag table, Info will no longer be able to find that node. To -update the tag table, use the `Info-tagify' command again. - - An Info file tag table appears at the end of the file and looks like -this: - - ^_ - Tag Table: - File: info, Node: Cross-refs^?21419 - File: info, Node: Tags^?22145 - ^_ - End Tag Table - -Note that it contains one line per node, and this line contains the -beginning of the node's header (ending just after the node name), a DEL -character, and the character position in the file of the beginning of -the node. - - -File: info.info, Node: Checking, Prev: Tags, Up: Advanced Info - -Checking an Info File -===================== - - When creating an Info file, it is easy to forget the name of a node -when you are making a pointer to it from another node. If you put in -the wrong name for a node, this is not detected until someone tries to -go through the pointer using Info. Verification of the Info file is an -automatic process which checks all pointers to nodes and reports any -pointers which are invalid. Every `Next', `Previous', and `Up' is -checked, as is every menu item and every cross reference. In addition, -any `Next' which does not have a `Previous' pointing back is reported. -Only pointers within the file are checked, because checking pointers to -other files would be terribly slow. But those are usually few. - - To check an Info file, do `M-x Info-validate' while looking at any -node of the file with Emacs Info mode. - - -File: info.info, Node: Create an Info File, Prev: Advanced Info, Up: Top - -Creating an Info File from a Makeinfo file -****************************************** - - `makeinfo' is a utility that converts a Texinfo file into an Info -file; `texinfo-format-region' and `texinfo-format-buffer' are GNU Emacs -functions that do the same. - - *Note Creating an Info File: (texinfo)Create an Info File, to learn -how to create an Info file from a Texinfo file. - - *Note Overview of Texinfo: (texinfo)Top, to learn how to write a -Texinfo file. - - - -Tag Table: -Node: Top913 -Node: Getting Started1431 -Node: Help-Small-Screen2179 -Node: Help3921 -Node: Help-P4949 -Node: Help-^L5811 -Node: Help-M8462 -Node: Help-FOO14030 -Node: Help-Adv14766 -Node: Help-Cross17148 -Node: Help-Q17794 -Node: Advanced Info18434 -Node: Expert19330 -Node: Add21601 -Node: Menus24635 -Node: Cross-refs27509 -Node: Tags28211 -Node: Checking29510 -Node: Create an Info File30434 - -End Tag Table diff --git a/gnu/usr.bin/texinfo/misc/texindex.c b/gnu/usr.bin/texinfo/misc/texindex.c deleted file mode 100644 index a88d51696919..000000000000 --- a/gnu/usr.bin/texinfo/misc/texindex.c +++ /dev/null @@ -1,1700 +0,0 @@ -/* Prepare TeX index dribble output into an actual index. - - Version 1.45 - - Copyright (C) 1987, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include -#include -#include -#include "getopt.h" - -#if defined (STDC_HEADERS) -# include -# include -# if !defined (bzero) -# define bzero(p, n) memset((p), '\0', (n)) -# endif /* !bzero */ -#else /* !STDC_HEADERS */ -extern int errno; -char *getenv (), *malloc (), *realloc (); -void bzero (); -#endif /* !STDC_HEADERS */ - -#if defined (HAVE_UNISTD_H) -# include -#else /* !HAVE_UNISTD_H */ -long lseek (); -#endif /* !HAVE_UNISTD_H */ - -char *mktemp (); - -#if defined (VMS) -# if !defined (VAX11C) -# define noshare -# endif /* !VAX11C */ -# include -extern noshare int sys_nerr; -extern noshare char *sys_errlist[]; - -# include - -# define TI_NO_ERROR ((1 << 28) | 1) -# define TI_FATAL_ERROR ((1 << 28) | 4) -# define unlink delete - -#else /* !VMS */ - -extern int sys_nerr; -extern char *sys_errlist[]; - -# if defined (HAVE_SYS_FCNTL_H) -# include -# include -# endif /* HAVE_SYS_FCNTL_H */ - -# if defined (_AIX) || !defined (_POSIX_VERSION) -# include -# else /* !AIX && _POSIX_VERSION */ -# if !defined (HAVE_SYS_FCNTL_H) -# include -# endif /* !HAVE_FCNTL_H */ -# endif /* !_AIX && _POSIX_VERSION */ -# define TI_NO_ERROR 0 -# define TI_FATAL_ERROR 1 -#endif /* !VMS */ - -#if !defined (SEEK_SET) -# define SEEK_SET 0 -# define SEEK_CUR 1 -# define SEEK_END 2 -#endif /* !SEEK_SET */ - -/* When sorting in core, this structure describes one line - and the position and length of its first keyfield. */ -struct lineinfo -{ - char *text; /* The actual text of the line. */ - union { - char *text; /* The start of the key (for textual comparison). */ - long number; /* The numeric value (for numeric comparison). */ - } key; - long keylen; /* Length of KEY field. */ -}; - -/* This structure describes a field to use as a sort key. */ -struct keyfield -{ - int startwords; /* Number of words to skip. */ - int startchars; /* Number of additional chars to skip. */ - int endwords; /* Number of words to ignore at end. */ - int endchars; /* Ditto for characters of last word. */ - char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ - char fold_case; /* Non-zero means case doesn't matter. */ - char reverse; /* Non-zero means compare in reverse order. */ - char numeric; /* Non-zeros means field is ASCII numeric. */ - char positional; /* Sort according to file position. */ - char braced; /* Count balanced-braced groupings as fields. */ -}; - -/* Vector of keyfields to use. */ -struct keyfield keyfields[3]; - -/* Number of keyfields stored in that vector. */ -int num_keyfields = 3; - -/* Vector of input file names, terminated with a null pointer. */ -char **infiles; - -/* Vector of corresponding output file names, or NULL, meaning default it - (add an `s' to the end). */ -char **outfiles; - -/* Length of `infiles'. */ -int num_infiles; - -/* Pointer to the array of pointers to lines being sorted. */ -char **linearray; - -/* The allocated length of `linearray'. */ -long nlines; - -/* Directory to use for temporary files. On Unix, it ends with a slash. */ -char *tempdir; - -/* Start of filename to use for temporary files. */ -char *tempbase; - -/* Number of last temporary file. */ -int tempcount; - -/* Number of last temporary file already deleted. - Temporary files are deleted by `flush_tempfiles' in order of creation. */ -int last_deleted_tempcount; - -/* During in-core sort, this points to the base of the data block - which contains all the lines of data. */ -char *text_base; - -/* Additional command switches .*/ - -/* Nonzero means do not delete tempfiles -- for debugging. */ -int keep_tempfiles; - -/* The name this program was run with. */ -char *program_name; - -/* Forward declarations of functions in this file. */ - -void decode_command (); -void sort_in_core (); -void sort_offline (); -char **parsefile (); -char *find_field (); -char *find_pos (); -long find_value (); -char *find_braced_pos (); -char *find_braced_end (); -void writelines (); -int compare_field (); -int compare_full (); -long readline (); -int merge_files (); -int merge_direct (); -void pfatal_with_name (); -void fatal (); -void error (); -void *xmalloc (), *xrealloc (); -char *concat (); -char *maketempname (); -void flush_tempfiles (); -char *tempcopy (); - -#define MAX_IN_CORE_SORT 500000 - -void -main (argc, argv) - int argc; - char **argv; -{ - int i; - - tempcount = 0; - last_deleted_tempcount = 0; - program_name = argv[0]; - - /* Describe the kind of sorting to do. */ - /* The first keyfield uses the first braced field and folds case. */ - keyfields[0].braced = 1; - keyfields[0].fold_case = 1; - keyfields[0].endwords = -1; - keyfields[0].endchars = -1; - - /* The second keyfield uses the second braced field, numerically. */ - keyfields[1].braced = 1; - keyfields[1].numeric = 1; - keyfields[1].startwords = 1; - keyfields[1].endwords = -1; - keyfields[1].endchars = -1; - - /* The third keyfield (which is ignored while discarding duplicates) - compares the whole line. */ - keyfields[2].endwords = -1; - keyfields[2].endchars = -1; - - decode_command (argc, argv); - - tempbase = mktemp (concat ("txiXXXXXX", "", "")); - - /* Process input files completely, one by one. */ - - for (i = 0; i < num_infiles; i++) - { - int desc; - long ptr; - char *outfile; - - desc = open (infiles[i], O_RDONLY, 0); - if (desc < 0) - pfatal_with_name (infiles[i]); - lseek (desc, 0L, SEEK_END); - ptr = lseek (desc, 0L, SEEK_CUR); - - close (desc); - - outfile = outfiles[i]; - if (!outfile) - { - outfile = concat (infiles[i], "s", ""); - } - - if (ptr < MAX_IN_CORE_SORT) - /* Sort a small amount of data. */ - sort_in_core (infiles[i], ptr, outfile); - else - sort_offline (infiles[i], ptr, outfile); - } - - flush_tempfiles (tempcount); - exit (TI_NO_ERROR); -} - -void -usage () -{ - fprintf (stderr, "\ -Usage: %s [-k] infile [-o outfile] ...\n", program_name); - exit (1); -} - -/* Decode the command line arguments to set the parameter variables - and set up the vector of keyfields and the vector of input files. */ - -void -decode_command (argc, argv) - int argc; - char **argv; -{ - int optc; - char **ip; - char **op; - - /* Store default values into parameter variables. */ - - tempdir = getenv ("TMPDIR"); -#ifdef VMS - if (tempdir == NULL) - tempdir = "sys$scratch:"; -#else - if (tempdir == NULL) - tempdir = "/tmp/"; - else - tempdir = concat (tempdir, "/", ""); -#endif - - keep_tempfiles = 0; - - /* Allocate ARGC input files, which must be enough. */ - - infiles = (char **) xmalloc (argc * sizeof (char *)); - outfiles = (char **) xmalloc (argc * sizeof (char *)); - ip = infiles; - op = outfiles; - - while ((optc = getopt (argc, argv, "-ko:")) != EOF) - { - switch (optc) - { - case 1: /* Non-option filename. */ - *ip++ = optarg; - *op++ = NULL; - break; - - case 'k': - keep_tempfiles = 1; - break; - - case 'o': - if (op > outfiles) - *(op - 1) = optarg; - break; - - default: - usage (); - } - } - - /* Record number of keyfields and terminate list of filenames. */ - num_infiles = ip - infiles; - *ip = 0; - if (num_infiles == 0) - usage (); -} - -/* Return a name for a temporary file. */ - -char * -maketempname (count) - int count; -{ - char tempsuffix[10]; - sprintf (tempsuffix, "%d", count); - return concat (tempdir, tempbase, tempsuffix); -} - -/* Delete all temporary files up to TO_COUNT. */ - -void -flush_tempfiles (to_count) - int to_count; -{ - if (keep_tempfiles) - return; - while (last_deleted_tempcount < to_count) - unlink (maketempname (++last_deleted_tempcount)); -} - -/* Copy the input file open on IDESC into a temporary file - and return the temporary file name. */ - -#define BUFSIZE 1024 - -char * -tempcopy (idesc) - int idesc; -{ - char *outfile = maketempname (++tempcount); - int odesc; - char buffer[BUFSIZE]; - - odesc = open (outfile, O_WRONLY | O_CREAT, 0666); - - if (odesc < 0) - pfatal_with_name (outfile); - - while (1) - { - int nread = read (idesc, buffer, BUFSIZE); - write (odesc, buffer, nread); - if (!nread) - break; - } - - close (odesc); - - return outfile; -} - -/* Compare LINE1 and LINE2 according to the specified set of keyfields. */ - -int -compare_full (line1, line2) - char **line1, **line2; -{ - int i; - - /* Compare using the first keyfield; - if that does not distinguish the lines, try the second keyfield; - and so on. */ - - for (i = 0; i < num_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], *line1, &length1); - char *start2 = find_field (&keyfields[i], *line2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, - start2, length2, *line2 - text_base); - if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } - } - - return 0; /* Lines match exactly. */ -} - -/* Compare LINE1 and LINE2, described by structures - in which the first keyfield is identified in advance. - For positional sorting, assumes that the order of the lines in core - reflects their nominal order. */ - -int -compare_prepared (line1, line2) - struct lineinfo *line1, *line2; -{ - int i; - int tem; - char *text1, *text2; - - /* Compare using the first keyfield, which has been found for us already. */ - if (keyfields->positional) - { - if (line1->text - text_base > line2->text - text_base) - tem = 1; - else - tem = -1; - } - else if (keyfields->numeric) - tem = line1->key.number - line2->key.number; - else - tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, - line2->key.text, line2->keylen, 0); - if (tem) - { - if (keyfields->reverse) - return -tem; - return tem; - } - - text1 = line1->text; - text2 = line2->text; - - /* Compare using the second keyfield; - if that does not distinguish the lines, try the third keyfield; - and so on. */ - - for (i = 1; i < num_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], text1, &length1); - char *start2 = find_field (&keyfields[i], text2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, - start2, length2, text2 - text_base); - if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } - } - - return 0; /* Lines match exactly. */ -} - -/* Like compare_full but more general. - You can pass any strings, and you can say how many keyfields to use. - POS1 and POS2 should indicate the nominal positional ordering of - the two lines in the input. */ - -int -compare_general (str1, str2, pos1, pos2, use_keyfields) - char *str1, *str2; - long pos1, pos2; - int use_keyfields; -{ - int i; - - /* Compare using the first keyfield; - if that does not distinguish the lines, try the second keyfield; - and so on. */ - - for (i = 0; i < use_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], str1, &length1); - char *start2 = find_field (&keyfields[i], str2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, pos1, - start2, length2, pos2); - if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } - } - - return 0; /* Lines match exactly. */ -} - -/* Find the start and length of a field in STR according to KEYFIELD. - A pointer to the starting character is returned, and the length - is stored into the int that LENGTHPTR points to. */ - -char * -find_field (keyfield, str, lengthptr) - struct keyfield *keyfield; - char *str; - long *lengthptr; -{ - char *start; - char *end; - char *(*fun) (); - - if (keyfield->braced) - fun = find_braced_pos; - else - fun = find_pos; - - start = (*fun) (str, keyfield->startwords, keyfield->startchars, - keyfield->ignore_blanks); - if (keyfield->endwords < 0) - { - if (keyfield->braced) - end = find_braced_end (start); - else - { - end = start; - while (*end && *end != '\n') - end++; - } - } - else - { - end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0); - if (end - str < start - str) - end = start; - } - *lengthptr = end - start; - return start; -} - -/* Return a pointer to a specified place within STR, - skipping (from the beginning) WORDS words and then CHARS chars. - If IGNORE_BLANKS is nonzero, we skip all blanks - after finding the specified word. */ - -char * -find_pos (str, words, chars, ignore_blanks) - char *str; - int words, chars; - int ignore_blanks; -{ - int i; - char *p = str; - - for (i = 0; i < words; i++) - { - char c; - /* Find next bunch of nonblanks and skip them. */ - while ((c = *p) == ' ' || c == '\t') - p++; - while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) - p++; - if (!*p || *p == '\n') - return p; - } - - while (*p == ' ' || *p == '\t') - p++; - - for (i = 0; i < chars; i++) - { - if (!*p || *p == '\n') - break; - p++; - } - return p; -} - -/* Like find_pos but assumes that each field is surrounded by braces - and that braces within fields are balanced. */ - -char * -find_braced_pos (str, words, chars, ignore_blanks) - char *str; - int words, chars; - int ignore_blanks; -{ - int i; - int bracelevel; - char *p = str; - char c; - - for (i = 0; i < words; i++) - { - bracelevel = 1; - while ((c = *p++) != '{' && c != '\n' && c) - /* Do nothing. */ ; - if (c != '{') - return p - 1; - while (bracelevel) - { - c = *p++; - if (c == '{') - bracelevel++; - if (c == '}') - bracelevel--; - if (c == 0 || c == '\n') - return p - 1; - } - } - - while ((c = *p++) != '{' && c != '\n' && c) - /* Do nothing. */ ; - - if (c != '{') - return p - 1; - - if (ignore_blanks) - while ((c = *p) == ' ' || c == '\t') - p++; - - for (i = 0; i < chars; i++) - { - if (!*p || *p == '\n') - break; - p++; - } - return p; -} - -/* Find the end of the balanced-brace field which starts at STR. - The position returned is just before the closing brace. */ - -char * -find_braced_end (str) - char *str; -{ - int bracelevel; - char *p = str; - char c; - - bracelevel = 1; - while (bracelevel) - { - c = *p++; - if (c == '{') - bracelevel++; - if (c == '}') - bracelevel--; - if (c == 0 || c == '\n') - return p - 1; - } - return p - 1; -} - -long -find_value (start, length) - char *start; - long length; -{ - while (length != 0L) - { - if (isdigit (*start)) - return atol (start); - length--; - start++; - } - return 0l; -} - -/* Vector used to translate characters for comparison. - This is how we make all alphanumerics follow all else, - and ignore case in the first sorting. */ -int char_order[256]; - -void -init_char_order () -{ - int i; - for (i = 1; i < 256; i++) - char_order[i] = i; - - for (i = '0'; i <= '9'; i++) - char_order[i] += 512; - - for (i = 'a'; i <= 'z'; i++) - { - char_order[i] = 512 + i; - char_order[i + 'A' - 'a'] = 512 + i; - } -} - -/* Compare two fields (each specified as a start pointer and a character count) - according to KEYFIELD. - The sign of the value reports the relation between the fields. */ - -int -compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) - struct keyfield *keyfield; - char *start1; - long length1; - long pos1; - char *start2; - long length2; - long pos2; -{ - if (keyfields->positional) - { - if (pos1 > pos2) - return 1; - else - return -1; - } - if (keyfield->numeric) - { - long value = find_value (start1, length1) - find_value (start2, length2); - if (value > 0) - return 1; - if (value < 0) - return -1; - return 0; - } - else - { - char *p1 = start1; - char *p2 = start2; - char *e1 = start1 + length1; - char *e2 = start2 + length2; - - while (1) - { - int c1, c2; - - if (p1 == e1) - c1 = 0; - else - c1 = *p1++; - if (p2 == e2) - c2 = 0; - else - c2 = *p2++; - - if (char_order[c1] != char_order[c2]) - return char_order[c1] - char_order[c2]; - if (!c1) - break; - } - - /* Strings are equal except possibly for case. */ - p1 = start1; - p2 = start2; - while (1) - { - int c1, c2; - - if (p1 == e1) - c1 = 0; - else - c1 = *p1++; - if (p2 == e2) - c2 = 0; - else - c2 = *p2++; - - if (c1 != c2) - /* Reverse sign here so upper case comes out last. */ - return c2 - c1; - if (!c1) - break; - } - - return 0; - } -} - -/* A `struct linebuffer' is a structure which holds a line of text. - `readline' reads a line from a stream into a linebuffer - and works regardless of the length of the line. */ - -struct linebuffer -{ - long size; - char *buffer; -}; - -/* Initialize LINEBUFFER for use. */ - -void -initbuffer (linebuffer) - struct linebuffer *linebuffer; -{ - linebuffer->size = 200; - linebuffer->buffer = (char *) xmalloc (200); -} - -/* Read a line of text from STREAM into LINEBUFFER. - Return the length of the line. */ - -long -readline (linebuffer, stream) - struct linebuffer *linebuffer; - FILE *stream; -{ - char *buffer = linebuffer->buffer; - char *p = linebuffer->buffer; - char *end = p + linebuffer->size; - - while (1) - { - int c = getc (stream); - if (p == end) - { - buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); - p += buffer - linebuffer->buffer; - end += buffer - linebuffer->buffer; - linebuffer->buffer = buffer; - } - if (c < 0 || c == '\n') - { - *p = 0; - break; - } - *p++ = c; - } - - return p - buffer; -} - -/* Sort an input file too big to sort in core. */ - -void -sort_offline (infile, nfiles, total, outfile) - char *infile; - int nfiles; - long total; - char *outfile; -{ - /* More than enough. */ - int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; - char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); - FILE *istream = fopen (infile, "r"); - int i; - struct linebuffer lb; - long linelength; - int failure = 0; - - initbuffer (&lb); - - /* Read in one line of input data. */ - - linelength = readline (&lb, istream); - - if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') - { - error ("%s: not a texinfo index file", infile); - return; - } - - /* Split up the input into `ntemps' temporary files, or maybe fewer, - and put the new files' names into `tempfiles' */ - - for (i = 0; i < ntemps; i++) - { - char *outname = maketempname (++tempcount); - FILE *ostream = fopen (outname, "w"); - long tempsize = 0; - - if (!ostream) - pfatal_with_name (outname); - tempfiles[i] = outname; - - /* Copy lines into this temp file as long as it does not make file - "too big" or until there are no more lines. */ - - while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) - { - tempsize += linelength + 1; - fputs (lb.buffer, ostream); - putc ('\n', ostream); - - /* Read another line of input data. */ - - linelength = readline (&lb, istream); - if (!linelength && feof (istream)) - break; - - if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') - { - error ("%s: not a texinfo index file", infile); - failure = 1; - goto fail; - } - } - fclose (ostream); - if (feof (istream)) - break; - } - - free (lb.buffer); - -fail: - /* Record number of temp files we actually needed. */ - - ntemps = i; - - /* Sort each tempfile into another tempfile. - Delete the first set of tempfiles and put the names of the second - into `tempfiles'. */ - - for (i = 0; i < ntemps; i++) - { - char *newtemp = maketempname (++tempcount); - sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); - if (!keep_tempfiles) - unlink (tempfiles[i]); - tempfiles[i] = newtemp; - } - - if (failure) - return; - - /* Merge the tempfiles together and indexify. */ - - merge_files (tempfiles, ntemps, outfile); -} - -/* Sort INFILE, whose size is TOTAL, - assuming that is small enough to be done in-core, - then indexify it and send the output to OUTFILE (or to stdout). */ - -void -sort_in_core (infile, total, outfile) - char *infile; - long total; - char *outfile; -{ - char **nextline; - char *data = (char *) xmalloc (total + 1); - char *file_data; - long file_size; - int i; - FILE *ostream = stdout; - struct lineinfo *lineinfo; - - /* Read the contents of the file into the moby array `data'. */ - - int desc = open (infile, O_RDONLY, 0); - - if (desc < 0) - fatal ("failure reopening %s", infile); - for (file_size = 0;;) - { - i = read (desc, data + file_size, total - file_size); - if (i <= 0) - break; - file_size += i; - } - file_data = data; - data[file_size] = 0; - - close (desc); - - if (file_size > 0 && data[0] != '\\' && data[0] != '@') - { - error ("%s: not a texinfo index file", infile); - return; - } - - init_char_order (); - - /* Sort routines want to know this address. */ - - text_base = data; - - /* Create the array of pointers to lines, with a default size - frequently enough. */ - - nlines = total / 50; - if (!nlines) - nlines = 2; - linearray = (char **) xmalloc (nlines * sizeof (char *)); - - /* `nextline' points to the next free slot in this array. - `nlines' is the allocated size. */ - - nextline = linearray; - - /* Parse the input file's data, and make entries for the lines. */ - - nextline = parsefile (infile, nextline, file_data, file_size); - if (nextline == 0) - { - error ("%s: not a texinfo index file", infile); - return; - } - - /* Sort the lines. */ - - /* If we have enough space, find the first keyfield of each line in advance. - Make a `struct lineinfo' for each line, which records the keyfield - as well as the line, and sort them. */ - - lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); - - if (lineinfo) - { - struct lineinfo *lp; - char **p; - - for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - { - lp->text = *p; - lp->key.text = find_field (keyfields, *p, &lp->keylen); - if (keyfields->numeric) - lp->key.number = find_value (lp->key.text, lp->keylen); - } - - qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared); - - for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - *p = lp->text; - - free (lineinfo); - } - else - qsort (linearray, nextline - linearray, sizeof (char *), compare_full); - - /* Open the output file. */ - - if (outfile) - { - ostream = fopen (outfile, "w"); - if (!ostream) - pfatal_with_name (outfile); - } - - writelines (linearray, nextline - linearray, ostream); - if (outfile) - fclose (ostream); - - free (linearray); - free (data); -} - -/* Parse an input string in core into lines. - DATA is the input string, and SIZE is its length. - Data goes in LINEARRAY starting at NEXTLINE. - The value returned is the first entry in LINEARRAY still unused. - Value 0 means input file contents are invalid. */ - -char ** -parsefile (filename, nextline, data, size) - char *filename; - char **nextline; - char *data; - long size; -{ - char *p, *end; - char **line = nextline; - - p = data; - end = p + size; - *end = 0; - - while (p != end) - { - if (p[0] != '\\' && p[0] != '@') - return 0; - - *line = p; - while (*p && *p != '\n') - p++; - if (p != end) - p++; - - line++; - if (line == linearray + nlines) - { - char **old = linearray; - linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); - line += linearray - old; - } - } - - return line; -} - -/* Indexification is a filter applied to the sorted lines - as they are being written to the output file. - Multiple entries for the same name, with different page numbers, - get combined into a single entry with multiple page numbers. - The first braced field, which is used for sorting, is discarded. - However, its first character is examined, folded to lower case, - and if it is different from that in the previous line fed to us - a \initial line is written with one argument, the new initial. - - If an entry has four braced fields, then the second and third - constitute primary and secondary names. - In this case, each change of primary name - generates a \primary line which contains only the primary name, - and in between these are \secondary lines which contain - just a secondary name and page numbers. */ - -/* The last primary name we wrote a \primary entry for. - If only one level of indexing is being done, this is the last name seen. */ -char *lastprimary; -/* Length of storage allocated for lastprimary. */ -int lastprimarylength; - -/* Similar, for the secondary name. */ -char *lastsecondary; -int lastsecondarylength; - -/* Zero if we are not in the middle of writing an entry. - One if we have written the beginning of an entry but have not - yet written any page numbers into it. - Greater than one if we have written the beginning of an entry - plus at least one page number. */ -int pending; - -/* The initial (for sorting purposes) of the last primary entry written. - When this changes, a \initial {c} line is written */ - -char *lastinitial; - -int lastinitiallength; - -/* When we need a string of length 1 for the value of lastinitial, - store it here. */ - -char lastinitial1[2]; - -/* Initialize static storage for writing an index. */ - -void -init_index () -{ - pending = 0; - lastinitial = lastinitial1; - lastinitial1[0] = 0; - lastinitial1[1] = 0; - lastinitiallength = 0; - lastprimarylength = 100; - lastprimary = (char *) xmalloc (lastprimarylength + 1); - bzero (lastprimary, lastprimarylength + 1); - lastsecondarylength = 100; - lastsecondary = (char *) xmalloc (lastsecondarylength + 1); - bzero (lastsecondary, lastsecondarylength + 1); -} - -/* Indexify. Merge entries for the same name, - insert headers for each initial character, etc. */ - -void -indexify (line, ostream) - char *line; - FILE *ostream; -{ - char *primary, *secondary, *pagenumber; - int primarylength, secondarylength = 0, pagelength; - int nosecondary; - int initiallength; - char *initial; - char initial1[2]; - register char *p; - - /* First, analyze the parts of the entry fed to us this time. */ - - p = find_braced_pos (line, 0, 0, 0); - if (*p == '{') - { - initial = p; - /* Get length of inner pair of braces starting at `p', - including that inner pair of braces. */ - initiallength = find_braced_end (p + 1) + 1 - p; - } - else - { - initial = initial1; - initial1[0] = *p; - initial1[1] = 0; - initiallength = 1; - - if (initial1[0] >= 'a' && initial1[0] <= 'z') - initial1[0] -= 040; - } - - pagenumber = find_braced_pos (line, 1, 0, 0); - pagelength = find_braced_end (pagenumber) - pagenumber; - if (pagelength == 0) - abort (); - - primary = find_braced_pos (line, 2, 0, 0); - primarylength = find_braced_end (primary) - primary; - - secondary = find_braced_pos (line, 3, 0, 0); - nosecondary = !*secondary; - if (!nosecondary) - secondarylength = find_braced_end (secondary) - secondary; - - /* If the primary is different from before, make a new primary entry. */ - if (strncmp (primary, lastprimary, primarylength)) - { - /* Close off current secondary entry first, if one is open. */ - if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } - - /* If this primary has a different initial, include an entry for - the initial. */ - if (initiallength != lastinitiallength || - strncmp (initial, lastinitial, initiallength)) - { - fprintf (ostream, "\\initial {"); - fwrite (initial, 1, initiallength, ostream); - fprintf (ostream, "}\n", initial); - if (initial == initial1) - { - lastinitial = lastinitial1; - *lastinitial1 = *initial1; - } - else - { - lastinitial = initial; - } - lastinitiallength = initiallength; - } - - /* Make the entry for the primary. */ - if (nosecondary) - fputs ("\\entry {", ostream); - else - fputs ("\\primary {", ostream); - fwrite (primary, primarylength, 1, ostream); - if (nosecondary) - { - fputs ("}{", ostream); - pending = 1; - } - else - fputs ("}\n", ostream); - - /* Record name of most recent primary. */ - if (lastprimarylength < primarylength) - { - lastprimarylength = primarylength + 100; - lastprimary = (char *) xrealloc (lastprimary, - 1 + lastprimarylength); - } - strncpy (lastprimary, primary, primarylength); - lastprimary[primarylength] = 0; - - /* There is no current secondary within this primary, now. */ - lastsecondary[0] = 0; - } - - /* Should not have an entry with no subtopic following one with a subtopic. */ - - if (nosecondary && *lastsecondary) - error ("entry %s follows an entry with a secondary name", line); - - /* Start a new secondary entry if necessary. */ - if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) - { - if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } - - /* Write the entry for the secondary. */ - fputs ("\\secondary {", ostream); - fwrite (secondary, secondarylength, 1, ostream); - fputs ("}{", ostream); - pending = 1; - - /* Record name of most recent secondary. */ - if (lastsecondarylength < secondarylength) - { - lastsecondarylength = secondarylength + 100; - lastsecondary = (char *) xrealloc (lastsecondary, - 1 + lastsecondarylength); - } - strncpy (lastsecondary, secondary, secondarylength); - lastsecondary[secondarylength] = 0; - } - - /* Here to add one more page number to the current entry. */ - if (pending++ != 1) - fputs (", ", ostream); /* Punctuate first, if this is not the first. */ - fwrite (pagenumber, pagelength, 1, ostream); -} - -/* Close out any unfinished output entry. */ - -void -finish_index (ostream) - FILE *ostream; -{ - if (pending) - fputs ("}\n", ostream); - free (lastprimary); - free (lastsecondary); -} - -/* Copy the lines in the sorted order. - Each line is copied out of the input file it was found in. */ - -void -writelines (linearray, nlines, ostream) - char **linearray; - int nlines; - FILE *ostream; -{ - char **stop_line = linearray + nlines; - char **next_line; - - init_index (); - - /* Output the text of the lines, and free the buffer space. */ - - for (next_line = linearray; next_line != stop_line; next_line++) - { - /* If -u was specified, output the line only if distinct from previous one. */ - if (next_line == linearray - /* Compare previous line with this one, using only the - explicitly specd keyfields. */ - || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) - { - char *p = *next_line; - char c; - - while ((c = *p++) && c != '\n') - /* Do nothing. */ ; - *(p - 1) = 0; - indexify (*next_line, ostream); - } - } - - finish_index (ostream); -} - -/* Assume (and optionally verify) that each input file is sorted; - merge them and output the result. - Returns nonzero if any input file fails to be sorted. - - This is the high-level interface that can handle an unlimited - number of files. */ - -#define MAX_DIRECT_MERGE 10 - -int -merge_files (infiles, nfiles, outfile) - char **infiles; - int nfiles; - char *outfile; -{ - char **tempfiles; - int ntemps; - int i; - int value = 0; - int start_tempcount = tempcount; - - if (nfiles <= MAX_DIRECT_MERGE) - return merge_direct (infiles, nfiles, outfile); - - /* Merge groups of MAX_DIRECT_MERGE input files at a time, - making a temporary file to hold each group's result. */ - - ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; - tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); - for (i = 0; i < ntemps; i++) - { - int nf = MAX_DIRECT_MERGE; - if (i + 1 == ntemps) - nf = nfiles - i * MAX_DIRECT_MERGE; - tempfiles[i] = maketempname (++tempcount); - value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); - } - - /* All temporary files that existed before are no longer needed - since their contents have been merged into our new tempfiles. - So delete them. */ - flush_tempfiles (start_tempcount); - - /* Now merge the temporary files we created. */ - - merge_files (tempfiles, ntemps, outfile); - - free (tempfiles); - - return value; -} - -/* Assume (and optionally verify) that each input file is sorted; - merge them and output the result. - Returns nonzero if any input file fails to be sorted. - - This version of merging will not work if the number of - input files gets too high. Higher level functions - use it only with a bounded number of input files. */ - -int -merge_direct (infiles, nfiles, outfile) - char **infiles; - int nfiles; - char *outfile; -{ - struct linebuffer *lb1, *lb2; - struct linebuffer **thisline, **prevline; - FILE **streams; - int i; - int nleft; - int lossage = 0; - int *file_lossage; - struct linebuffer *prev_out = 0; - FILE *ostream = stdout; - - if (outfile) - { - ostream = fopen (outfile, "w"); - } - if (!ostream) - pfatal_with_name (outfile); - - init_index (); - - if (nfiles == 0) - { - if (outfile) - fclose (ostream); - return 0; - } - - /* For each file, make two line buffers. - Also, for each file, there is an element of `thisline' - which points at any time to one of the file's two buffers, - and an element of `prevline' which points to the other buffer. - `thisline' is supposed to point to the next available line from the file, - while `prevline' holds the last file line used, - which is remembered so that we can verify that the file is properly sorted. */ - - /* lb1 and lb2 contain one buffer each per file. */ - lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); - lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); - - /* thisline[i] points to the linebuffer holding the next available line in file i, - or is zero if there are no lines left in that file. */ - thisline = (struct linebuffer **) - xmalloc (nfiles * sizeof (struct linebuffer *)); - /* prevline[i] points to the linebuffer holding the last used line - from file i. This is just for verifying that file i is properly - sorted. */ - prevline = (struct linebuffer **) - xmalloc (nfiles * sizeof (struct linebuffer *)); - /* streams[i] holds the input stream for file i. */ - streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); - /* file_lossage[i] is nonzero if we already know file i is not - properly sorted. */ - file_lossage = (int *) xmalloc (nfiles * sizeof (int)); - - /* Allocate and initialize all that storage. */ - - for (i = 0; i < nfiles; i++) - { - initbuffer (&lb1[i]); - initbuffer (&lb2[i]); - thisline[i] = &lb1[i]; - prevline[i] = &lb2[i]; - file_lossage[i] = 0; - streams[i] = fopen (infiles[i], "r"); - if (!streams[i]) - pfatal_with_name (infiles[i]); - - readline (thisline[i], streams[i]); - } - - /* Keep count of number of files not at eof. */ - nleft = nfiles; - - while (nleft) - { - struct linebuffer *best = 0; - struct linebuffer *exch; - int bestfile = -1; - int i; - - /* Look at the next avail line of each file; choose the least one. */ - - for (i = 0; i < nfiles; i++) - { - if (thisline[i] && - (!best || - 0 < compare_general (best->buffer, thisline[i]->buffer, - (long) bestfile, (long) i, num_keyfields))) - { - best = thisline[i]; - bestfile = i; - } - } - - /* Output that line, unless it matches the previous one and we - don't want duplicates. */ - - if (!(prev_out && - !compare_general (prev_out->buffer, - best->buffer, 0L, 1L, num_keyfields - 1))) - indexify (best->buffer, ostream); - prev_out = best; - - /* Now make the line the previous of its file, and fetch a new - line from that file. */ - - exch = prevline[bestfile]; - prevline[bestfile] = thisline[bestfile]; - thisline[bestfile] = exch; - - while (1) - { - /* If the file has no more, mark it empty. */ - - if (feof (streams[bestfile])) - { - thisline[bestfile] = 0; - /* Update the number of files still not empty. */ - nleft--; - break; - } - readline (thisline[bestfile], streams[bestfile]); - if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) - break; - } - } - - finish_index (ostream); - - /* Free all storage and close all input streams. */ - - for (i = 0; i < nfiles; i++) - { - fclose (streams[i]); - free (lb1[i].buffer); - free (lb2[i].buffer); - } - free (file_lossage); - free (lb1); - free (lb2); - free (thisline); - free (prevline); - free (streams); - - if (outfile) - fclose (ostream); - - return lossage; -} - -/* Print error message and exit. */ - -void -fatal (s1, s2) - char *s1, *s2; -{ - error (s1, s2); - exit (TI_FATAL_ERROR); -} - -/* Print error message. S1 is printf control string, S2 is arg for it. */ - -void -error (s1, s2) - char *s1, *s2; -{ - printf ("%s: ", program_name); - printf (s1, s2); - printf ("\n"); -} - -void -perror_with_name (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - error (s, name); -} - -void -pfatal_with_name (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - fatal (s, name); -} - -/* Return a newly-allocated string whose contents concatenate those of - S1, S2, S3. */ - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - char *result = (char *) xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - *(result + len1 + len2 + len3) = 0; - - return result; -} - -/* Just like malloc, but kills the program in case of fatal error. */ -void * -xmalloc (nbytes) - int nbytes; -{ - void *temp = (void *) malloc (nbytes); - - if (nbytes && temp == (void *)NULL) - memory_error ("xmalloc", nbytes); - - return (temp); -} - -/* Like realloc (), but barfs if there isn't enough memory. */ -void * -xrealloc (pointer, nbytes) - void *pointer; - int nbytes; -{ - void *temp; - - if (!pointer) - temp = (void *)xmalloc (nbytes); - else - temp = (void *)realloc (pointer, nbytes); - - if (nbytes && !temp) - memory_error ("xrealloc", nbytes); - - return (temp); -} - -memory_error (callers_name, bytes_wanted) - char *callers_name; - int bytes_wanted; -{ - char printable_string[80]; - - sprintf (printable_string, - "Virtual memory exhausted in %s ()! Needed %d bytes.", - callers_name, bytes_wanted); - - error (printable_string); - abort (); -} - -#ifndef STDC_HEADERS -void -bzero (b, length) - register char *b; - register int length; -{ -#ifdef VMS - short zero = 0; - long max_str = 65535; - - while (length > max_str) - { - (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); - length -= max_str; - b += max_str; - } - (void) LIB$MOVC5 (&zero, &zero, &zero, &length, b); -#else - while (length-- > 0) - *b++ = 0; -#endif /* not VMS */ -} -#endif /* not STDC_HEADERS */ diff --git a/include/tzfile.h b/include/tzfile.h deleted file mode 100644 index 246e6a71ec41..000000000000 --- a/include/tzfile.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)tzfile.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _TZFILE_H_ -#define _TZFILE_H_ - -/* - * Information about time zone files. - */ - /* Time zone object file directory */ -#define TZDIR "/usr/share/zoneinfo" -#define TZDEFAULT "/etc/localtime" -#define TZDEFRULES "posixrules" - -/* -** Each file begins with. . . -*/ - -struct tzhead { - char tzh_reserved[24]; /* reserved for future use */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ -}; - -/* -** . . .followed by. . . -** -** tzh_timecnt (char [4])s coded transition times a la time(2) -** tzh_timecnt (unsigned char)s types of local time starting at above -** tzh_typecnt repetitions of -** one (char [4]) coded GMT offset in seconds -** one (unsigned char) used to set tm_isdst -** one (unsigned char) that's an abbreviation list index -** tzh_charcnt (char)s '\0'-terminated zone abbreviations -** tzh_leapcnt repetitions of -** one (char [4]) coded leap second transition times -** one (char [4]) total correction after above -** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition -** time is standard time, if FALSE, -** transition time is wall clock time -** if absent, transition times are -** assumed to be wall clock time -*/ - -/* -** In the current implementation, "tzset()" refuses to deal with files that -** exceed any of the limits below. -*/ - -/* -** The TZ_MAX_TIMES value below is enough to handle a bit more than a -** year's worth of solar time (corrected daily to the nearest second) or -** 138 years of Pacific Presidential Election time -** (where there are three time zone transitions every fourth year). -*/ -#define TZ_MAX_TIMES 370 - -#define NOSOLAR /* 4BSD doesn't currently handle solar time */ - -#ifndef NOSOLAR -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#else -#define TZ_MAX_TYPES 10 /* Maximum number of local time types */ -#endif - -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -/* -** Accurate only for the past couple of centuries; -** that will probably do. -*/ - -#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) - -#endif /* !_TZFILE_H_ */ diff --git a/lib/csu/i386/gprof.ex b/lib/csu/i386/gprof.ex deleted file mode 100644 index d86d517b2045..000000000000 --- a/lib/csu/i386/gprof.ex +++ /dev/null @@ -1,3 +0,0 @@ -g/_mcount/s/_mcount/mcount/g -w -q diff --git a/lib/libc/compat-43/setregid.2 b/lib/libc/compat-43/setregid.2 deleted file mode 100644 index bf2624da1f27..000000000000 --- a/lib/libc/compat-43/setregid.2 +++ /dev/null @@ -1,93 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setregid.2 8.2 (Berkeley) 4/16/94 -.\" -.Dd April 16, 1994 -.Dt SETREGID 2 -.Os BSD 4.2 -.Sh NAME -.Nm setregid -.Nd set real and effective group ID -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn setregid "gid_t rgid" "gid_t egid" -.Sh DESCRIPTION -The real and effective group ID's of the current process -are set to the arguments. -Unprivileged users may change the real group -ID to the effective group ID and vice-versa; only the super-user may -make other changes. -.Pp -Supplying a value of -1 for either the real or effective -group ID forces the system to substitute the current -ID in place of the -1 parameter. -.Pp -The -.Fn setregid -function was intended to allow swapping -the real and effective group IDs -in set-group-ID programs to temporarily relinquish the set-group-ID value. -This function did not work correctly, -and its purpose is now better served by the use of the -.Fn setegid -function (see -.Xr setuid 2 ) . -.Pp -When setting the real and effective group IDs to the same value, -the standard -.Fn setgid -function is preferred. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width [EPERM] -.It Bq Er EPERM -The current process is not the super-user and a change -other than changing the effective group-id to the real group-id -was specified. -.El -.Sh SEE ALSO -.Xr getgid 2 , -.Xr setegid 2 , -.Xr setgid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Nm -function call appeared in -.Bx 4.2 -and was dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/setregid.c b/lib/libc/compat-43/setregid.c deleted file mode 100644 index f91418ba650e..000000000000 --- a/lib/libc/compat-43/setregid.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setregid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -setregid(rgid, egid) - gid_t rgid, egid; -{ - static gid_t savedgid = -1; - - if (savedgid == -1) - savedgid = getegid(); - /* - * we assume that the intent here is to be able to - * get back rgid priviledge. So we make sure that - * we will be able to do so, but do not actually - * set the rgid. - */ - if (rgid != -1 && rgid != getgid() && rgid != savedgid) { - errno = EPERM; - return (-1); - } - if (egid != -1 && setegid(egid) < 0) - return (-1); - return (0); -} diff --git a/lib/libc/compat-43/setreuid.2 b/lib/libc/compat-43/setreuid.2 deleted file mode 100644 index 980da123db31..000000000000 --- a/lib/libc/compat-43/setreuid.2 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setreuid.2 8.2 (Berkeley) 4/16/94 -.\" -.Dd April 16, 1994 -.Dt SETREUID 2 -.Os BSD 4 -.Sh NAME -.Nm setreuid -.Nd set real and effective user ID's -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn setreuid "uid_t ruid" "uid_t euid" -.Sh DESCRIPTION -The real and effective user IDs of the -current process are set according to the arguments. -If -.Fa ruid -or -.Fa euid -is -1, the current uid is filled in by the system. -Unprivileged users may change the real user -ID to the effective user ID and vice-versa; only the super-user may -make other changes. -.Pp -The -.Fn setreuid -function has been used to swap the real and effective user IDs -in set-user-ID programs to temporarily relinquish the set-user-ID value. -This purpose is now better served by the use of the -.Fn seteuid -function (see -.Xr setuid 2 ) . -.Pp -When setting the real and effective user IDs to the same value, -the standard -.Fn setuid -function is preferred. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width [EPERM] -.It Bq Er EPERM -The current process is not the super-user and a change -other than changing the effective user-id to the real user-id -was specified. -.El -.Sh SEE ALSO -.Xr getuid 2 , -.Xr seteuid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Nm -function call appeared in -.Bx 4.2 -and was dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/setreuid.c b/lib/libc/compat-43/setreuid.c deleted file mode 100644 index 40316815814e..000000000000 --- a/lib/libc/compat-43/setreuid.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)setreuid.c 8.1 (Berkeley) 6/2/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -setreuid(ruid, euid) - uid_t ruid, euid; -{ - static uid_t saveduid = -1; - - if (saveduid == -1) - saveduid = geteuid(); - /* - * we assume that the intent here is to be able to - * get back ruid priviledge. So we make sure that - * we will be able to do so, but do not actually - * set the ruid. - */ - if (ruid != -1 && ruid != getuid() && ruid != saveduid) { - errno = EPERM; - return (-1); - } - if (euid != -1 && seteuid(euid) < 0) - return (-1); - return (0); -} diff --git a/lib/libc/gen/ctime.3 b/lib/libc/gen/ctime.3 deleted file mode 100644 index ff6a8efd5967..000000000000 --- a/lib/libc/gen/ctime.3 +++ /dev/null @@ -1,258 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Arthur Olson. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ctime.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt CTIME 3 -.Os BSD 4.3 -.Sh NAME -.Nm asctime , -.Nm ctime , -.Nm difftime , -.Nm gmtime , -.Nm localtime , -.Nm mktime -.Nd transform binary date and time value to -.Tn ASCII -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Vt extern char *tzname[2]; -.Ft char * -.Fn ctime "const time_t *clock" -.Ft double -.Fn difftime "time_t time1" "time_t time0" -.Ft char * -.Fn asctime "const struct tm *tm" -.Ft struct tm * -.Fn localtime "const time_t *clock" -.Ft struct tm * -.Fn gmtime "const time_t *clock" -.Ft time_t -.Fn mktime "struct tm *tm" -.Sh DESCRIPTION -The functions -.Fn ctime , -.Fn gmtime -and -.Fn localtime -all take as an argument a time value representing the time in seconds since -the Epoch (00:00:00 -.Tn UTC , -January 1, 1970; see -.Xr time 3 ) . -.Pp -The function -.Fn localtime -converts the time value pointed at by -.Fa clock , -and returns a pointer to a -.Dq Fa struct tm -(described below) which contains -the broken-out time information for the value after adjusting for the current -time zone (and any other factors such as Daylight Saving Time). -Time zone adjustments are performed as specified by the -.Ev TZ -environmental variable (see -.Xr tzset 3 ) . -The function -.Fn localtime -uses -.Xr tzset -to initialize time conversion information if -.Xr tzset -has not already been called by the process. -.Pp -After filling in the tm structure, -.Fn localtime -sets the -.Fa tm_isdst Ns 'th -element of -.Fa tzname -to a pointer to an -.Tn ASCII -string that's the time zone abbreviation to be -used with -.Fn localtime Ns 's -return value. -.Pp -The function -.Fn gmtime -similarly converts the time value, but without any time zone adjustment, -and returns a pointer to a tm structure (described below). -.Pp -The -.Fn ctime -function -adjusts the time value for the current time zone in the same manner as -.Fn localtime , -and returns a pointer to a 26-character string of the form: -.Bd -literal -offset indent -Thu Nov 24 18:22:48 1986\en\e0 -.Ed -.Pp -All the fields have constant width. -.Pp -The -.Fn asctime -function -converts the broken down time in the structure -.Fa tm -pointed at by -.Fa *tm -to the form -shown in the example above. -.Pp -The function -.Fn mktime -converts the broken-down time, expressed as local time, in the structure -pointed to by tm into a time value with the same encoding as that of the -values returned by the -.Xr time 3 -function, that is, seconds from the Epoch, -.Tn UTC . -.Pp -The original values of the -.Fa tm_wday -and -.Fa tm_yday -components of the structure are ignored, and the original values of the -other components are not restricted to their normal ranges. -(A positive or zero value for -.Fa tm_isdst -causes -.Fn mktime -to presume initially that summer time (for example, Daylight Saving Time) -is or is not in effect for the specified time, respectively. -A negative value for -.Fa tm_isdst -causes the -.Fn mktime -function to attempt to divine whether summer time is in effect for the -specified time.) -.Pp -On successful completion, the values of the -.Fa tm_wday -and -.Fa tm_yday -components of the structure are set appropriately, and the other components -are set to represent the specified calendar time, but with their values -forced to their normal ranges; the final value of -.Fa tm_mday -is not set until -.Fa tm_mon -and -.Fa tm_year -are determined. -.Fn Mktime -returns the specified calendar time; if the calendar time cannot be -represented, it returns \-1; -.Pp -The -.Fn difftime -function -returns the difference between two calendar times, -.Pf ( Fa time1 -- -.Fa time0 ) , -expressed in seconds. -.Pp -External declarations as well as the tm structure definition are in the -.Aq Pa time.h -include file. -The tm structure includes at least the following fields: -.Bd -literal -offset indent -int tm_sec; /\(** seconds (0 - 60) \(**/ -int tm_min; /\(** minutes (0 - 59) \(**/ -int tm_hour; /\(** hours (0 - 23) \(**/ -int tm_mday; /\(** day of month (1 - 31) \(**/ -int tm_mon; /\(** month of year (0 - 11) \(**/ -int tm_year; /\(** year \- 1900 \(**/ -int tm_wday; /\(** day of week (Sunday = 0) \(**/ -int tm_yday; /\(** day of year (0 - 365) \(**/ -int tm_isdst; /\(** is summer time in effect? \(**/ -char \(**tm_zone; /\(** abbreviation of timezone name \(**/ -long tm_gmtoff; /\(** offset from UTC in seconds \(**/ -.Ed -.Pp -The -field -.Fa tm_isdst -is non-zero if summer time is in effect. -.Pp -The field -.Fa tm_gmtoff -is the offset (in seconds) of the time represented from -.Tn UTC , -with positive -values indicating east of the Prime Meridian. -.Sh SEE ALSO -.Xr date 1 , -.Xr gettimeofday 2 , -.Xr getenv 3 , -.Xr time 3 , -.Xr tzset 3 , -.Xr tzfile 5 -.Sh HISTORY -This manual page is derived from -the time package contributed to Berkeley by -Arthur Olsen and which appeared in -.Bx 4.3 . -.Sh BUGS -Except for -.Fn difftime -and -.Fn mktime , -these functions leaves their result in an internal static object and return -a pointer to that object. Subsequent calls to these -function will modify the same object. -.Pp -The -.Fa tm_zone -field of a returned tm structure points to a static array of characters, -which will also be overwritten by any subsequent calls (as well as by -subsequent calls to -.Xr tzset 3 -and -.Xr tzsetwall 3 ) . -.Pp -Use of the external variable -.Fa tzname -is discouraged; the -.Fa tm_zone -entry in the tm structure is preferred. -.Pp -Avoid using out-of-range values with -.Fn mktime -when setting up lunch with promptness sticklers in Riyadh. diff --git a/lib/libc/gen/ctime.c b/lib/libc/gen/ctime.c deleted file mode 100644 index b11e39b77c68..000000000000 --- a/lib/libc/gen/ctime.c +++ /dev/null @@ -1,1381 +0,0 @@ -/* - * Copyright (c) 1987, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ctime.c 8.2 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ - -/* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). -*/ - -/*LINTLIBRARY*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __STDC__ -#include - -#define P(s) s -#define alloc_size_t size_t -#define qsort_size_t size_t -#define fread_size_t size_t -#define fwrite_size_t size_t - -#else /* !defined __STDC__ */ - -#define P(s) () - -typedef char * genericptr_t; -typedef unsigned alloc_size_t; -typedef int qsort_size_t; -typedef int fread_size_t; -typedef int fwrite_size_t; - -extern char * calloc(); -extern char * malloc(); -extern char * realloc(); -extern char * getenv(); - -#endif /* !defined __STDC__ */ - -extern time_t time(); - -#define ACCESS_MODE O_RDONLY -#define OPEN_MODE O_RDONLY - -#ifndef WILDABBR -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ -#define WILDABBR " " -#endif /* !defined WILDABBR */ - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif /* !defined TRUE */ - -static const char GMT[] = "GMT"; - -struct ttinfo { /* time type information */ - long tt_gmtoff; /* GMT offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* TRUE if transition is std time */ -}; - -struct lsinfo { /* leap second information */ - time_t ls_trans; /* transition time */ - long ls_corr; /* correction to apply */ -}; - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - time_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? - TZ_MAX_CHARS + 1 : sizeof GMT]; - struct lsinfo lsis[TZ_MAX_LEAPS]; -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - long r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ - -static long detzcode P((const char * codep)); -static const char * getzname P((const char * strp)); -static const char * getnum P((const char * strp, int * nump, int min, - int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static void gmtsub P((const time_t * timep, long offset, - struct tm * tmp)); -static void localsub P((const time_t * timep, long offset, - struct tm * tmp)); -static void normalize P((int * tensptr, int * unitsptr, int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, void (* funcp)(), - long offset)); -static time_t time2 P((struct tm *tmp, void (* funcp)(), - long offset, int * okayp)); -static void timesub P((const time_t * timep, long offset, - const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, - const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, - const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp)); -static int tzparse P((const char * name, struct state * sp, - int lastditch)); - -#ifdef ALL_STATE -static struct state * lclptr; -static struct state * gmtptr; -#endif /* defined ALL_STATE */ - -#ifndef ALL_STATE -static struct state lclmem; -static struct state gmtmem; -#define lclptr (&lclmem) -#define gmtptr (&gmtmem) -#endif /* State Farm */ - -static int lcl_is_set; -static int gmt_is_set; - -char * tzname[2] = { - WILDABBR, - WILDABBR -}; - -#ifdef USG_COMPAT -time_t timezone = 0; -int daylight = 0; -#endif /* defined USG_COMPAT */ - -#ifdef ALTZONE -time_t altzone = 0; -#endif /* defined ALTZONE */ - -static long -detzcode(codep) -const char * const codep; -{ - register long result; - register int i; - - result = 0; - for (i = 0; i < 4; ++i) - result = (result << 8) | (codep[i] & 0xff); - return result; -} - -static void -settzname() -{ - register const struct state * const sp = lclptr; - register int i; - - tzname[0] = WILDABBR; - tzname[1] = WILDABBR; -#ifdef USG_COMPAT - daylight = 0; - timezone = 0; -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - altzone = 0; -#endif /* defined ALTZONE */ -#ifdef ALL_STATE - if (sp == NULL) { - tzname[0] = tzname[1] = GMT; - return; - } -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) { - register const struct ttinfo * const ttisp = &sp->ttis[i]; - - tzname[ttisp->tt_isdst] = - (char *) &sp->chars[ttisp->tt_abbrind]; -#ifdef USG_COMPAT - if (ttisp->tt_isdst) - daylight = 1; - if (i == 0 || !ttisp->tt_isdst) - timezone = -(ttisp->tt_gmtoff); -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - if (i == 0 || ttisp->tt_isdst) - altzone = -(ttisp->tt_gmtoff); -#endif /* defined ALTZONE */ - } - /* - ** And to get the latest zone names into tzname. . . - */ - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * const ttisp = - &sp->ttis[sp->types[i]]; - - tzname[ttisp->tt_isdst] = - (char *) &sp->chars[ttisp->tt_abbrind]; - } -} - -static int -tzload(name, sp) -register const char * name; -register struct state * const sp; -{ - register const char * p; - register int i; - register int fid; - - if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; - { - char fullname[FILENAME_MAX + 1]; - - if (name[0] == ':') - ++name; - if (name[0] != '/') { - if ((p = TZDIR) == NULL) - return -1; - if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; - (void) strcpy(fullname, p); - (void) strcat(fullname, "/"); - (void) strcat(fullname, name); - name = fullname; - } - if ((fid = open(name, OPEN_MODE)) == -1) - return -1; - } - { - register const struct tzhead * tzhp; - char buf[sizeof *sp + sizeof *tzhp]; - int ttisstdcnt; - - i = read(fid, buf, sizeof buf); - if (close(fid) != 0 || i < sizeof *tzhp) - return -1; - tzhp = (struct tzhead *) buf; - ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt); - sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt); - sp->timecnt = (int) detzcode(tzhp->tzh_timecnt); - sp->typecnt = (int) detzcode(tzhp->tzh_typecnt); - sp->charcnt = (int) detzcode(tzhp->tzh_charcnt); - if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || - sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || - sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || - sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || - (ttisstdcnt != sp->typecnt && ttisstdcnt != 0)) - return -1; - if (i < sizeof *tzhp + - sp->timecnt * (4 + sizeof (char)) + - sp->typecnt * (4 + 2 * sizeof (char)) + - sp->charcnt * sizeof (char) + - sp->leapcnt * 2 * 4 + - ttisstdcnt * sizeof (char)) - return -1; - p = buf + sizeof *tzhp; - for (i = 0; i < sp->timecnt; ++i) { - sp->ats[i] = detzcode(p); - p += 4; - } - for (i = 0; i < sp->timecnt; ++i) { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) - return -1; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - ttisp->tt_gmtoff = detzcode(p); - p += 4; - ttisp->tt_isdst = (unsigned char) *p++; - if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; - ttisp->tt_abbrind = (unsigned char) *p++; - if (ttisp->tt_abbrind < 0 || - ttisp->tt_abbrind > sp->charcnt) - return -1; - } - for (i = 0; i < sp->charcnt; ++i) - sp->chars[i] = *p++; - sp->chars[i] = '\0'; /* ensure '\0' at end */ - for (i = 0; i < sp->leapcnt; ++i) { - register struct lsinfo * lsisp; - - lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; - lsisp->ls_corr = detzcode(p); - p += 4; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisstdcnt == 0) - ttisp->tt_ttisstd = FALSE; - else { - ttisp->tt_ttisstd = *p++; - if (ttisp->tt_ttisstd != TRUE && - ttisp->tt_ttisstd != FALSE) - return -1; - } - } - } - return 0; -} - -static const int mon_lengths[2][MONSPERYEAR] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, - 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -static const int year_lengths[2] = { - DAYSPERNYEAR, DAYSPERLYEAR -}; - -/* -** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that -** character. -*/ - -static const char * -getzname(strp) -register const char * strp; -{ - register char c; - - while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && - c != '+') - ++strp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number from that string. -** Check that the number is within a specified range; if it is not, return -** NULL. -** Otherwise, return a pointer to the first character not part of the number. -*/ - -static const char * -getnum(strp, nump, min, max) -register const char * strp; -int * const nump; -const int min; -const int max; -{ - register char c; - register int num; - - if (strp == NULL || !isdigit(*strp)) - return NULL; - num = 0; - while ((c = *strp) != '\0' && isdigit(c)) { - num = num * 10 + (c - '0'); - if (num > max) - return NULL; /* illegal value */ - ++strp; - } - if (num < min) - return NULL; /* illegal value */ - *nump = num; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number of seconds, -** in hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the number -** of seconds. -*/ - -static const char * -getsecs(strp, secsp) -register const char * strp; -long * const secsp; -{ - int num; - - strp = getnum(strp, &num, 0, HOURSPERDAY); - if (strp == NULL) - return NULL; - *secsp = num * SECSPERHOUR; - if (*strp == ':') { - ++strp; - strp = getnum(strp, &num, 0, MINSPERHOUR - 1); - if (strp == NULL) - return NULL; - *secsp += num * SECSPERMIN; - if (*strp == ':') { - ++strp; - strp = getnum(strp, &num, 0, SECSPERMIN - 1); - if (strp == NULL) - return NULL; - *secsp += num; - } - } - return strp; -} - -/* -** Given a pointer into a time zone string, extract an offset, in -** [+-]hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the time. -*/ - -static const char * -getoffset(strp, offsetp) -register const char * strp; -long * const offsetp; -{ - register int neg; - - if (*strp == '-') { - neg = 1; - ++strp; - } else if (isdigit(*strp) || *strp++ == '+') - neg = 0; - else return NULL; /* illegal offset */ - strp = getsecs(strp, offsetp); - if (strp == NULL) - return NULL; /* illegal time */ - if (neg) - *offsetp = -*offsetp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". -** If a valid rule is not found, return NULL. -** Otherwise, return a pointer to the first character not part of the rule. -*/ - -static const char * -getrule(strp, rulep) -const char * strp; -register struct rule * const rulep; -{ - if (*strp == 'J') { - /* - ** Julian day. - */ - rulep->r_type = JULIAN_DAY; - ++strp; - strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); - } else if (*strp == 'M') { - /* - ** Month, week, day. - */ - rulep->r_type = MONTH_NTH_DAY_OF_WEEK; - ++strp; - strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_week, 1, 5); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); - } else if (isdigit(*strp)) { - /* - ** Day of year. - */ - rulep->r_type = DAY_OF_YEAR; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); - } else return NULL; /* invalid format */ - if (strp == NULL) - return NULL; - if (*strp == '/') { - /* - ** Time specified. - */ - ++strp; - strp = getsecs(strp, &rulep->r_time); - } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ - return strp; -} - -/* -** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the -** year, a rule, and the offset from GMT at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. -*/ - -static time_t -transtime(janfirst, year, rulep, offset) -const time_t janfirst; -const int year; -register const struct rule * const rulep; -const long offset; -{ - register int leapyear; - register time_t value; - register int i; - int d, m1, yy0, yy1, yy2, dow; - - leapyear = isleap(year); - switch (rulep->r_type) { - - case JULIAN_DAY: - /* - ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - ** years. - ** In non-leap years, or if the day number is 59 or less, just - ** add SECSPERDAY times the day number-1 to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; - if (leapyear && rulep->r_day >= 60) - value += SECSPERDAY; - break; - - case DAY_OF_YEAR: - /* - ** n - day of year. - ** Just add SECSPERDAY times the day number to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + rulep->r_day * SECSPERDAY; - break; - - case MONTH_NTH_DAY_OF_WEEK: - /* - ** Mm.n.d - nth "dth day" of month m. - */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; - - /* - ** Use Zeller's Congruence to get day-of-week of first day of - ** month. - */ - m1 = (rulep->r_mon + 9) % 12 + 1; - yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; - yy1 = yy0 / 100; - yy2 = yy0 % 100; - dow = ((26 * m1 - 2) / 10 + - 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; - if (dow < 0) - dow += DAYSPERWEEK; - - /* - ** "dow" is the day-of-week of the first day of the month. Get - ** the day-of-month (zero-origin) of the first "dow" day of the - ** month. - */ - d = rulep->r_day - dow; - if (d < 0) - d += DAYSPERWEEK; - for (i = 1; i < rulep->r_week; ++i) { - if (d + DAYSPERWEEK >= - mon_lengths[leapyear][rulep->r_mon - 1]) - break; - d += DAYSPERWEEK; - } - - /* - ** "d" is the day-of-month (zero-origin) of the day we want. - */ - value += d * SECSPERDAY; - break; - } - - /* - ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in - ** question. To get the Epoch-relative time of the specified local - ** time on that day, add the transition time and the current offset - ** from GMT. - */ - return value + rulep->r_time + offset; -} - -/* -** Given a POSIX section 8-style TZ string, fill in the rule tables as -** appropriate. -*/ - -static int -tzparse(name, sp, lastditch) -const char * name; -register struct state * const sp; -const int lastditch; -{ - const char * stdname; - const char * dstname; - int stdlen; - int dstlen; - long stdoffset; - long dstoffset; - register time_t * atp; - register unsigned char * typep; - register char * cp; - register int load_result; - - stdname = name; - if (lastditch) { - stdlen = strlen(name); /* length of standard zone name */ - name += stdlen; - if (stdlen >= sizeof sp->chars) - stdlen = (sizeof sp->chars) - 1; - } else { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; - } - if (*name == '\0') - return -1; - else { - name = getoffset(name, &stdoffset); - if (name == NULL) - return -1; - } - load_result = tzload(TZDEFRULES, sp); - if (load_result != 0) - sp->leapcnt = 0; /* so, we're off a little */ - if (*name != '\0') { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; - if (*name != '\0' && *name != ',' && *name != ';') { - name = getoffset(name, &dstoffset); - if (name == NULL) - return -1; - } else dstoffset = stdoffset - SECSPERHOUR; - if (*name == ',' || *name == ';') { - struct rule start; - struct rule end; - register int year; - register time_t janfirst; - time_t starttime; - time_t endtime; - - ++name; - if ((name = getrule(name, &start)) == NULL) - return -1; - if (*name++ != ',') - return -1; - if ((name = getrule(name, &end)) == NULL) - return -1; - if (*name != '\0') - return -1; - sp->typecnt = 2; /* standard time and DST */ - /* - ** Two transitions per year, from EPOCH_YEAR to 2037. - */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; - sp->ttis[0].tt_gmtoff = -dstoffset; - sp->ttis[0].tt_isdst = 1; - sp->ttis[0].tt_abbrind = stdlen + 1; - sp->ttis[1].tt_gmtoff = -stdoffset; - sp->ttis[1].tt_isdst = 0; - sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; - janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) { - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - if (starttime > endtime) { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } else { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } - janfirst += - year_lengths[isleap(year)] * SECSPERDAY; - } - } else { - int sawstd; - int sawdst; - long stdfix; - long dstfix; - long oldfix; - int isdst; - register int i; - - if (*name != '\0') - return -1; - if (load_result != 0) - return -1; - /* - ** Compute the difference between the real and - ** prototype standard and summer time offsets - ** from GMT, and put the real standard and summer - ** time offsets into the rules in place of the - ** prototype offsets. - */ - sawstd = FALSE; - sawdst = FALSE; - stdfix = 0; - dstfix = 0; - for (i = 0; i < sp->typecnt; ++i) { - if (sp->ttis[i].tt_isdst) { - oldfix = dstfix; - dstfix = - sp->ttis[i].tt_gmtoff + dstoffset; - if (sawdst && (oldfix != dstfix)) - return -1; - sp->ttis[i].tt_gmtoff = -dstoffset; - sp->ttis[i].tt_abbrind = stdlen + 1; - sawdst = TRUE; - } else { - oldfix = stdfix; - stdfix = - sp->ttis[i].tt_gmtoff + stdoffset; - if (sawstd && (oldfix != stdfix)) - return -1; - sp->ttis[i].tt_gmtoff = -stdoffset; - sp->ttis[i].tt_abbrind = 0; - sawstd = TRUE; - } - } - /* - ** Make sure we have both standard and summer time. - */ - if (!sawdst || !sawstd) - return -1; - /* - ** Now correct the transition times by shifting - ** them by the difference between the real and - ** prototype offsets. Note that this difference - ** can be different in standard and summer time; - ** the prototype probably has a 1-hour difference - ** between standard and summer time, but a different - ** difference can be specified in TZ. - */ - isdst = FALSE; /* we start in standard time */ - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * ttisp; - - /* - ** If summer time is in effect, and the - ** transition time was not specified as - ** standard time, add the summer time - ** offset to the transition time; - ** otherwise, add the standard time offset - ** to the transition time. - */ - ttisp = &sp->ttis[sp->types[i]]; - sp->ats[i] += - (isdst && !ttisp->tt_ttisstd) ? - dstfix : stdfix; - isdst = ttisp->tt_isdst; - } - } - } else { - dstlen = 0; - sp->typecnt = 1; /* only standard time */ - sp->timecnt = 0; - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = 0; - sp->ttis[0].tt_abbrind = 0; - } - sp->charcnt = stdlen + 1; - if (dstlen != 0) - sp->charcnt += dstlen + 1; - if (sp->charcnt > sizeof sp->chars) - return -1; - cp = sp->chars; - (void) strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; - if (dstlen != 0) { - (void) strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; - } - return 0; -} - -static void -gmtload(sp) -struct state * const sp; -{ - if (tzload(GMT, sp) != 0) - (void) tzparse(GMT, sp, TRUE); -} - -void -tzset() -{ - register const char * name; - void tzsetwall(); - - name = getenv("TZ"); - if (name == NULL) { - tzsetwall(); - return; - } - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (*name == '\0') { - /* - ** User wants it fast rather than right. - */ - lclptr->leapcnt = 0; /* so, we're off a little */ - lclptr->timecnt = 0; - lclptr->ttis[0].tt_gmtoff = 0; - lclptr->ttis[0].tt_abbrind = 0; - (void) strcpy(lclptr->chars, GMT); - } else if (tzload(name, lclptr) != 0) - if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) - (void) gmtload(lclptr); - settzname(); -} - -void -tzsetwall() -{ - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (tzload((char *) NULL, lclptr) != 0) - gmtload(lclptr); - settzname(); -} - -/* -** The easy way to behave "as if no library function calls" localtime -** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- -** but it *is* desirable.) -** -** The unused offset argument is for the benefit of mktime variants. -*/ - -/*ARGSUSED*/ -static void -localsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; -{ - register struct state * sp; - register const struct ttinfo * ttisp; - register int i; - const time_t t = *timep; - - if (!lcl_is_set) - tzset(); - sp = lclptr; -#ifdef ALL_STATE - if (sp == NULL) { - gmtsub(timep, offset, tmp); - return; - } -#endif /* defined ALL_STATE */ - if (sp->timecnt == 0 || t < sp->ats[0]) { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) { - i = 0; - break; - } - } else { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; - } - ttisp = &sp->ttis[i]; - /* - ** To get (wrong) behavior that's compatible with System V Release 2.0 - ** you'd replace the statement below with - ** t += ttisp->tt_gmtoff; - ** timesub(&t, 0L, sp, tmp); - */ - timesub(&t, ttisp->tt_gmtoff, sp, tmp); - tmp->tm_isdst = ttisp->tt_isdst; - tzname[tmp->tm_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; - tmp->tm_zone = &sp->chars[ttisp->tt_abbrind]; -} - -struct tm * -localtime(timep) -const time_t * const timep; -{ - static struct tm tm; - - localsub(timep, 0L, &tm); - return &tm; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static void -gmtsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; -{ - if (!gmt_is_set) { - gmt_is_set = TRUE; -#ifdef ALL_STATE - gmtptr = (struct state *) malloc(sizeof *gmtptr); - if (gmtptr != NULL) -#endif /* defined ALL_STATE */ - gmtload(gmtptr); - } - timesub(timep, offset, gmtptr, tmp); - /* - ** Could get fancy here and deliver something such as - ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, - ** but this is no time for a treasure hunt. - */ - if (offset != 0) - tmp->tm_zone = WILDABBR; - else { -#ifdef ALL_STATE - if (gmtptr == NULL) - tmp->TM_ZONE = GMT; - else tmp->TM_ZONE = gmtptr->chars; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - tmp->tm_zone = gmtptr->chars; -#endif /* State Farm */ - } -} - -struct tm * -gmtime(timep) -const time_t * const timep; -{ - static struct tm tm; - - gmtsub(timep, 0L, &tm); - return &tm; -} - -static void -timesub(timep, offset, sp, tmp) -const time_t * const timep; -const long offset; -register const struct state * const sp; -register struct tm * const tmp; -{ - register const struct lsinfo * lp; - register long days; - register long rem; - register int y; - register int yleap; - register const int * ip; - register long corr; - register int hit; - register int i; - - corr = 0; - hit = FALSE; -#ifdef ALL_STATE - i = (sp == NULL) ? 0 : sp->leapcnt; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - i = sp->leapcnt; -#endif /* State Farm */ - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) { - if (*timep == lp->ls_trans) - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - corr = lp->ls_corr; - break; - } - } - days = *timep / SECSPERDAY; - rem = *timep % SECSPERDAY; -#ifdef mc68k - if (*timep == 0x80000000) { - /* - ** A 3B1 muffs the division on the most negative number. - */ - days = -24855; - rem = -11648; - } -#endif /* mc68k */ - rem += (offset - corr); - while (rem < 0) { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) { - rem -= SECSPERDAY; - ++days; - } - tmp->tm_hour = (int) (rem / SECSPERHOUR); - rem = rem % SECSPERHOUR; - tmp->tm_min = (int) (rem / SECSPERMIN); - tmp->tm_sec = (int) (rem % SECSPERMIN); - if (hit) - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60". - */ - ++(tmp->tm_sec); - tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - y = EPOCH_YEAR; - if (days >= 0) - for ( ; ; ) { - yleap = isleap(y); - if (days < (long) year_lengths[yleap]) - break; - ++y; - days = days - (long) year_lengths[yleap]; - } - else do { - --y; - yleap = isleap(y); - days = days + (long) year_lengths[yleap]; - } while (days < 0); - tmp->tm_year = y - TM_YEAR_BASE; - tmp->tm_yday = (int) days; - ip = mon_lengths[yleap]; - for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) - days = days - (long) ip[tmp->tm_mon]; - tmp->tm_mday = (int) (days + 1); - tmp->tm_isdst = 0; - tmp->tm_gmtoff = offset; -} - -/* -** A la X3J11 -*/ - -char * -asctime(timeptr) -register const struct tm * timeptr; -{ - static const char wday_name[DAYSPERWEEK][3] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static const char mon_name[MONSPERYEAR][3] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - static char result[26]; - - (void) sprintf(result, "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n", - wday_name[timeptr->tm_wday], - mon_name[timeptr->tm_mon], - timeptr->tm_mday, timeptr->tm_hour, - timeptr->tm_min, timeptr->tm_sec, - TM_YEAR_BASE + timeptr->tm_year); - return result; -} - -char * -ctime(timep) -const time_t * const timep; -{ - return asctime(localtime(timep)); -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). -** It does a binary search of the time_t space. Since time_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -static void -normalize(tensptr, unitsptr, base) -int * const tensptr; -int * const unitsptr; -const int base; -{ - if (*unitsptr >= base) { - *tensptr += *unitsptr / base; - *unitsptr %= base; - } else if (*unitsptr < 0) { - *tensptr -= 1 + (-(*unitsptr + 1)) / base; - *unitsptr = base - 1 - (-(*unitsptr + 1)) % base; - } -} - -static int -tmcomp(atmp, btmp) -register const struct tm * const atmp; -register const struct tm * const btmp; -{ - register int result; - - if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && - (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static time_t -time2(tmp, funcp, offset, okayp) -struct tm * const tmp; -void (* const funcp)(); -const long offset; -int * const okayp; -{ - register const struct state * sp; - register int dir; - register int bits; - register int i, j ; - register int saved_seconds; - time_t newt; - time_t t; - struct tm yourtm, mytm; - - *okayp = FALSE; - yourtm = *tmp; - if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) - normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); - normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); - normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); - normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); - while (yourtm.tm_mday <= 0) { - --yourtm.tm_year; - yourtm.tm_mday += - year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; - } - while (yourtm.tm_mday > DAYSPERLYEAR) { - yourtm.tm_mday -= - year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; - ++yourtm.tm_year; - } - for ( ; ; ) { - i = mon_lengths[isleap(yourtm.tm_year + - TM_YEAR_BASE)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) { - yourtm.tm_mon = 0; - ++yourtm.tm_year; - } - } - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - /* - ** Calculate the number of magnitude bits in a time_t - ** (this works regardless of whether time_t is - ** signed or unsigned, though lint complains if unsigned). - */ - for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) - ; - /* - ** If time_t is signed, then 0 is the median value, - ** if time_t is unsigned, then 1 << bits is median. - */ - t = (t < 0) ? 0 : ((time_t) 1 << bits); - for ( ; ; ) { - (*funcp)(&t, offset, &mytm); - dir = tmcomp(&mytm, &yourtm); - if (dir != 0) { - if (bits-- < 0) - return WRONG; - if (bits < 0) - --t; - else if (dir > 0) - t -= (time_t) 1 << bits; - else t += (time_t) 1 << bits; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - sp = (const struct state *) - ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = 0; j < sp->typecnt; ++j) { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - - sp->ttis[i].tt_gmtoff; - (*funcp)(&newt, offset, &mytm); - if (tmcomp(&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } -label: - t += saved_seconds; - (*funcp)(&t, offset, tmp); - *okayp = TRUE; - return t; -} - -static time_t -time1(tmp, funcp, offset) -struct tm * const tmp; -void (* const funcp)(); -const long offset; -{ - register time_t t; - register const struct state * sp; - register int samei, otheri; - int okay; - - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2(tmp, funcp, offset, &okay); - if (okay || tmp->tm_isdst < 0) - return t; - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (samei = 0; samei < sp->typecnt; ++samei) { - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otheri = 0; otheri < sp->typecnt; ++otheri) { - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2(tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -time_t -mktime(tmp) -struct tm * const tmp; -{ - return time1(tmp, localsub, 0L); -} diff --git a/lib/libc/gen/difftime.c b/lib/libc/gen/difftime.c deleted file mode 100644 index 394133087203..000000000000 --- a/lib/libc/gen/difftime.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)difftime.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -double -difftime(time1, time0) - time_t time1, time0; -{ - return(time1 - time0); -} diff --git a/lib/libc/gen/sigsetjmp.c b/lib/libc/gen/sigsetjmp.c deleted file mode 100644 index ca960a69a30e..000000000000 --- a/lib/libc/gen/sigsetjmp.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sigsetjmp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -int -sigsetjmp(jmpbuf, savemask) - sigjmp_buf jmpbuf; - int savemask; -{ - - jmpbuf[_JBLEN] = savemask; - if (savemask) - return (setjmp(jmpbuf)); - return (_setjmp(jmpbuf)); -} - -void -siglongjmp(jmpbuf, retval) - sigjmp_buf jmpbuf; - int retval; -{ - - if (jmpbuf[_JBLEN]) - return (longjmp(jmpbuf, retval)); - return (_longjmp(jmpbuf, retval)); -} diff --git a/lib/libc/i386/gen/_setjmp.s b/lib/libc/i386/gen/_setjmp.s deleted file mode 100644 index 47e319a4abda..000000000000 --- a/lib/libc/i386/gen/_setjmp.s +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -#include "DEFS.h" - -ENTRY(_setjmp) - movl 4(%esp),%eax - movl 0(%esp),%edx - movl %edx, 0(%eax) /* rta */ - movl %ebx, 4(%eax) - movl %esp, 8(%eax) - movl %ebp,12(%eax) - movl %esi,16(%eax) - movl %edi,20(%eax) - movl $0,%eax - ret - -ENTRY(_longjmp) - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - cmpl $0,%eax - jne 1f - movl $1,%eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/gen/alloca.s b/lib/libc/i386/gen/alloca.s deleted file mode 100644 index a2d6a41f3af9..000000000000 --- a/lib/libc/i386/gen/alloca.s +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)alloca.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* like alloc, but automatic automatic free in return */ - -#include "DEFS.h" - -ENTRY(alloca) - popl %edx /* pop return addr */ - popl %eax /* pop amount to allocate */ - movl %esp,%ecx - addl $3,%eax /* round up to next word */ - andl $0xfffffffc,%eax - subl %eax,%esp - movl %esp,%eax /* base of newly allocated space */ - pushl 8(%ecx) /* copy possible saved registers */ - pushl 4(%ecx) - pushl 0(%ecx) - pushl %eax /* dummy to pop at callsite */ - jmp %edx /* "return" */ diff --git a/lib/libc/i386/gen/divsi3.s b/lib/libc/i386/gen/divsi3.s deleted file mode 100644 index 946a4a16c472..000000000000 --- a/lib/libc/i386/gen/divsi3.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)divsi3.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - - .globl ___divsi3 -___divsi3: - movl 4(%esp),%eax - cltd - idivl 8(%esp) - ret diff --git a/lib/libc/i386/gen/fabs.s b/lib/libc/i386/gen/fabs.s deleted file mode 100644 index 40e72c80ef74..000000000000 --- a/lib/libc/i386/gen/fabs.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(fabs) - fldl 4(%esp) - fabs - ret diff --git a/lib/libc/i386/gen/fixdfsi.s b/lib/libc/i386/gen/fixdfsi.s deleted file mode 100644 index 138d0788018e..000000000000 --- a/lib/libc/i386/gen/fixdfsi.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)fixdfsi.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - - .globl ___fixdfsi -___fixdfsi: - fldl 4(%esp) - fistpl 4(%esp) - movl 4(%esp),%eax - ret diff --git a/lib/libc/i386/gen/fixunsdfsi.s b/lib/libc/i386/gen/fixunsdfsi.s deleted file mode 100644 index 7025bb6bd9cf..000000000000 --- a/lib/libc/i386/gen/fixunsdfsi.s +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)fixunsdfsi.s 8.1 6/4/93" -#endif /* LIBC_SCCS and not lint */ - - .globl ___fixunsdfsi -___fixunsdfsi: - fldl 4(%esp) /* argument double to accum stack */ - frndint /* create integer */ - fcoml fbiggestsigned /* bigger than biggest signed? */ - fstsw %ax - sahf - jnb 1f - - fistpl 4(%esp) - movl 4(%esp),%eax - ret - -1: fsubl fbiggestsigned /* reduce for proper conversion */ - fistpl 4(%esp) /* convert */ - movl 4(%esp),%eax - orl $0x80000000,%eax /* restore bias */ - ret - -fbiggestsigned: .double 0r2147483648.0 diff --git a/lib/libc/i386/gen/modf.s b/lib/libc/i386/gen/modf.s deleted file mode 100644 index 2551237df3e6..000000000000 --- a/lib/libc/i386/gen/modf.s +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * modf(value, iptr): return fractional part of value, and stores the - * integral part into iptr (a pointer to double). - * - * Written by Sean Eric Fagan (sef@kithrup.COM) - * Sun Mar 11 20:27:30 PST 1990 - */ - -/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */ -.text -.globl _modf -_modf: - pushl %ebp - movl %esp,%ebp - subl $16,%esp - fnstcw -12(%ebp) - movw -12(%ebp),%dx - orw $3072,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) - fldl 8(%ebp) - frndint - fstpl -8(%ebp) - fldcw -12(%ebp) - movl 16(%ebp),%eax - movl -8(%ebp),%edx - movl -4(%ebp),%ecx - movl %edx,(%eax) - movl %ecx,4(%eax) - fldl 8(%ebp) - fsubl -8(%ebp) - jmp L1 -L1: - leave - ret diff --git a/lib/libc/i386/gen/setjmp.s b/lib/libc/i386/gen/setjmp.s deleted file mode 100644 index b24da115efe2..000000000000 --- a/lib/libc/i386/gen/setjmp.s +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -#include "DEFS.h" - -ENTRY(setjmp) - pushl $0 - call _sigblock - popl %edx - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - movl $0,%eax - ret - -ENTRY(longjmp) - movl 4(%esp),%edx - pushl 24(%edx) - call _sigsetmask - popl %eax - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - cmpl $0,%eax - jne 1f - movl $1,%eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/gen/udivsi3.s b/lib/libc/i386/gen/udivsi3.s deleted file mode 100644 index 791e5264e336..000000000000 --- a/lib/libc/i386/gen/udivsi3.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)udivsi3.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - - .globl ___udivsi3 -___udivsi3: - movl 4(%esp),%eax - xorl %edx,%edx - divl 8(%esp) - ret diff --git a/lib/libc/i386/net/htonl.s b/lib/libc/i386/net/htonl.s deleted file mode 100644 index 01d93c840fbe..000000000000 --- a/lib/libc/i386/net/htonl.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* netorder = htonl(hostorder) */ - -#include "DEFS.h" - -ENTRY(htonl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/htons.s b/lib/libc/i386/net/htons.s deleted file mode 100644 index 74a76abd3b5e..000000000000 --- a/lib/libc/i386/net/htons.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* netorder = htons(hostorder) */ - -#include "DEFS.h" - -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/ntohl.s b/lib/libc/i386/net/ntohl.s deleted file mode 100644 index 29802facea31..000000000000 --- a/lib/libc/i386/net/ntohl.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)ntohl.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/net/ntohs.s b/lib/libc/i386/net/ntohs.s deleted file mode 100644 index 4b521dad3023..000000000000 --- a/lib/libc/i386/net/ntohs.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)ntohs.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/i386/stdlib/abs.s b/lib/libc/i386/stdlib/abs.s deleted file mode 100644 index 755ea5693ae0..000000000000 --- a/lib/libc/i386/stdlib/abs.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)abs.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(abs) - movl 4(%esp),%eax - cmpl $0,%eax - jge 1f - negl %eax -1: ret diff --git a/lib/libc/i386/string/bzero.s b/lib/libc/i386/string/bzero.s deleted file mode 100644 index 79a5a694f93c..000000000000 --- a/lib/libc/i386/string/bzero.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)bzero.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* bzero (base,cnt) */ - - .globl _bzero -_bzero: - pushl %edi - movl 8(%esp),%edi - movl 12(%esp),%ecx - movb $0x00,%al - cld - rep - stosb - popl %edi - ret diff --git a/lib/libc/i386/sys/Ovfork.s b/lib/libc/i386/sys/Ovfork.s deleted file mode 100644 index c7e6b8a9e7b0..000000000000 --- a/lib/libc/i386/sys/Ovfork.s +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ - .set vfork,66 -.globl _vfork - -_vfork: - popl %ecx /* my rta into ecx */ - movl $vfork, %eax - LCALL(7,0) - jb verror -vforkok: - cmpl $0,%edx /* child process? */ - jne child /* yes */ - jmp parent -.globl _errno -verror: - movl %eax,_errno - movl $-1,%eax - jmp %ecx -child: - movl $0,%eax -parent: - jmp %ecx diff --git a/lib/libc/i386/sys/brk.s b/lib/libc/i386/sys/brk.s deleted file mode 100644 index f85186cf265d..000000000000 --- a/lib/libc/i386/sys/brk.s +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl curbrk - .globl minbrk -ENTRY(_brk) - jmp ok - -ENTRY(brk) - movl 4(%esp),%eax - cmpl %eax,minbrk - jl ok - movl minbrk,%eax - movl %eax,4(%esp) -ok: - lea SYS_brk,%eax - LCALL(7,0) - jb err - movl 4(%esp),%eax - movl %eax,curbrk - movl $0,%eax - ret -err: - jmp cerror diff --git a/lib/libc/i386/sys/cerror.s b/lib/libc/i386/sys/cerror.s deleted file mode 100644 index cc2d82fc7717..000000000000 --- a/lib/libc/i386/sys/cerror.s +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _errno -cerror: - movl %eax,_errno - movl $-1,%eax - ret diff --git a/lib/libc/i386/sys/exect.s b/lib/libc/i386/sys/exect.s deleted file mode 100644 index 6b42cf84e500..000000000000 --- a/lib/libc/i386/sys/exect.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)exect.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" -#include - -ENTRY(exect) - lea SYS_execve,%eax - pushf - popl %edx - orl $ PSL_T,%edx - pushl %edx - popf - LCALL(7,0) - jmp cerror /* exect(file, argv, env); */ diff --git a/lib/libc/i386/sys/fork.s b/lib/libc/i386/sys/fork.s deleted file mode 100644 index ff4d94879417..000000000000 --- a/lib/libc/i386/sys/fork.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)fork.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(fork) - cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */ - je 1f - movl $0,%eax -1: - ret /* pid = fork(); */ diff --git a/lib/libc/i386/sys/mount.s b/lib/libc/i386/sys/mount.s deleted file mode 100644 index ac418f756f58..000000000000 --- a/lib/libc/i386/sys/mount.s +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)mount.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(mount) - movl $0,%eax - ret diff --git a/lib/libc/i386/sys/pipe.s b/lib/libc/i386/sys/pipe.s deleted file mode 100644 index 6469397053d6..000000000000 --- a/lib/libc/i386/sys/pipe.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)pipe.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(pipe) - movl 4(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - movl $0,%eax - ret diff --git a/lib/libc/i386/sys/ptrace.s b/lib/libc/i386/sys/ptrace.s deleted file mode 100644 index 98994eabdef9..000000000000 --- a/lib/libc/i386/sys/ptrace.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax - movl %eax,_errno - lea SYS_ptrace,%eax - LCALL(7,0) - jb err - ret -err: - jmp cerror diff --git a/lib/libc/i386/sys/reboot.s b/lib/libc/i386/sys/reboot.s deleted file mode 100644 index 020bea067b52..000000000000 --- a/lib/libc/i386/sys/reboot.s +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)reboot.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/i386/sys/sbrk.s b/lib/libc/i386/sys/sbrk.s deleted file mode 100644 index 7fecd93535a8..000000000000 --- a/lib/libc/i386/sys/sbrk.s +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) - movl 4(%esp),%ecx - movl curbrk,%eax - addl %eax,4(%esp) - lea SYS_brk,%eax - LCALL(7,0) - jb err - movl curbrk,%eax - addl %ecx,curbrk - ret -err: - jmp cerror diff --git a/lib/libc/i386/sys/setlogin.s b/lib/libc/i386/sys/setlogin.s deleted file mode 100644 index 43d31d7b919c..000000000000 --- a/lib/libc/i386/sys/setlogin.s +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) - movl $0,__logname_valid - ret /* setlogin(name) */ diff --git a/lib/libc/i386/sys/sigpending.s b/lib/libc/i386/sys/sigpending.s deleted file mode 100644 index 63b06a2d935a..000000000000 --- a/lib/libc/i386/sys/sigpending.s +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl 4(%esp),%ecx # fetch pointer to... - movl %eax,(%ecx) # store old mask - xorl %eax,%eax - ret diff --git a/lib/libc/i386/sys/sigprocmask.s b/lib/libc/i386/sys/sigprocmask.s deleted file mode 100644 index ef91e80611ad..000000000000 --- a/lib/libc/i386/sys/sigprocmask.s +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigprocmask) - movl 8(%esp),%ecx # fetch new sigset pointer - cmpl $0,%ecx # check new sigset pointer - jne 1f # if not null, indirect -/* movl $0,8(%esp) # null mask pointer: block empty set */ - movl $1,4(%esp) # SIG_BLOCK - jmp 2f -1: movl (%ecx),%ecx # fetch indirect ... - movl %ecx,8(%esp) # to new mask arg -2: movl $ SYS_sigprocmask , %eax - LCALL(0x7,0) - jb err - movl 12(%esp),%ecx # fetch old mask requested - cmpl $0,%ecx # test if old mask requested - je out - movl %eax,(%ecx) # store old mask -out: - xorl %eax,%eax - ret diff --git a/lib/libc/i386/sys/sigreturn.s b/lib/libc/i386/sys/sigreturn.s deleted file mode 100644 index 1bd6a3b876c6..000000000000 --- a/lib/libc/i386/sys/sigreturn.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .align 2; _/**/x: pusha ; \ - .data; 1:; .long 0; .text; movl $1b,%eax; call mcount; popa ; nop -#endif /* PROF */ - -SYSCALL(sigreturn) - ret diff --git a/lib/libc/i386/sys/sigsuspend.s b/lib/libc/i386/sys/sigsuspend.s deleted file mode 100644 index afbc1ba96a9d..000000000000 --- a/lib/libc/i386/sys/sigsuspend.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigsuspend) - movl 4(%esp),%eax # fetch mask arg - movl (%eax),%eax # indirect to mask arg - movl %eax,4(%esp) - movl $ SYS_sigsuspend ,%eax - LCALL(0x7,0) - jb err - xorl %eax,%eax # shouldn t happen - ret diff --git a/lib/libc/i386/sys/syscall.s b/lib/libc/i386/sys/syscall.s deleted file mode 100644 index 189f4dd7b641..000000000000 --- a/lib/libc/i386/sys/syscall.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - LCALL(7,0) - jb 1f - ret -1: - jmp cerror diff --git a/lib/libc/net/getnetbyname.c b/lib/libc/net/getnetbyname.c deleted file mode 100644 index 5082a7abbfb5..000000000000 --- a/lib/libc/net/getnetbyname.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetbyname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern int _net_stayopen; - -struct netent * -getnetbyname(name) - register const char *name; -{ - register struct netent *p; - register char **cp; - - setnetent(_net_stayopen); - while (p = getnetent()) { - if (strcmp(p->n_name, name) == 0) - break; - for (cp = p->n_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) - goto found; - } -found: - if (!_net_stayopen) - endnetent(); - return (p); -} diff --git a/lib/libc/net/getnetent.c b/lib/libc/net/getnetent.c deleted file mode 100644 index 49ec9b745abc..000000000000 --- a/lib/libc/net/getnetent.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#define MAXALIASES 35 - -static FILE *netf; -static char line[BUFSIZ+1]; -static struct netent net; -static char *net_aliases[MAXALIASES]; -int _net_stayopen; - -void -setnetent(f) - int f; -{ - if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); - else - rewind(netf); - _net_stayopen |= f; -} - -void -endnetent() -{ - if (netf) { - fclose(netf); - netf = NULL; - } - _net_stayopen = 0; -} - -struct netent * -getnetent() -{ - char *p; - register char *cp, **q; - - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) - return (NULL); -again: - p = fgets(line, BUFSIZ, netf); - if (p == NULL) - return (NULL); - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - net.n_name = p; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - net.n_net = inet_network(cp); - net.n_addrtype = AF_INET; - q = net.n_aliases = net_aliases; - if (p != NULL) - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &net_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&net); -} diff --git a/lib/libc/net/sethostent.c b/lib/libc/net/sethostent.c deleted file mode 100644 index dbc6e204060e..000000000000 --- a/lib/libc/net/sethostent.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -void -sethostent(stayopen) -{ - if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; -} - -void -endhostent() -{ - _res.options &= ~(RES_STAYOPEN | RES_USEVC); - _res_close(); -} diff --git a/lib/libc/stdlib/free.3 b/lib/libc/stdlib/free.3 deleted file mode 100644 index 17d99eb97c3b..000000000000 --- a/lib/libc/stdlib/free.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)free.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt FREE 3 -.Os -.Sh NAME -.Nm free -.Nd free up memory allocated with malloc, calloc or realloc -.Sh SYNOPSIS -.Fd #include -.Ft void -.Fn free "void *ptr" -.Sh DESCRIPTION -The -.Fn free -function causes the space pointed to by -.Fa ptr -to be deallocated, that is, made available -for further allocation. -If -.Fa ptr -is a null pointer, no action occurs. -Otherwise, if the argument does not match a pointer earlier -returned by the -.Xr calloc , -.Xr malloc , -or -.Xr realloc -function, or if the space has been deallocated by a call to -.Fn free -or -.Xr realloc , -general havoc may occur. -.Sh RETURN VALUES -The -.Fn free -function returns no value. -.Sh SEE ALSO -.Xr calloc 3 , -.Xr malloc 3 , -.Xr realloc 3 -.Sh STANDARDS -The -.Fn free -function conforms to -.St -ansiC . diff --git a/lib/libc/stdlib/realloc.3 b/lib/libc/stdlib/realloc.3 deleted file mode 100644 index 903825cbb96f..000000000000 --- a/lib/libc/stdlib/realloc.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)realloc.3 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt REALLOC 3 -.Os -.Sh NAME -.Nm realloc -.Nd reallocation of memory function -.Sh SYNOPSIS -.Fd #include -.Ft void * -.Fn realloc "void *ptr" "size_t size" -.Sh DESCRIPTION -The -.Fn realloc -function changes the size of the object pointed to by -.Fa ptr -to the size specified by -.Fa size . -The contents of the object are unchanged up to the lesser -of the new and old sizes. -If the new size is larger, the value of the newly allocated portion -of the object is indeterminate. -If -.Fa ptr -is a null pointer, the -.Fn realloc -function behaves like the -.Xr malloc 3 -function for the specified size. -Otherwise, if -.Fa ptr -does not match a pointer earlier returned by the -.Xr calloc 3 , -.Xr malloc 3 , -or -.Fn realloc -function, or if the space has been deallocated -by a call to the -.Xr free -or -.Fn realloc -function, unpredictable and usually detrimental -behavior will occur. -If the space cannot be allocated, the object -pointed to by -.Fa ptr -is unchanged. -If -.Fa size -is zero and -.Fa ptr -is not a null pointer, the object it points to is freed. -.Pp -The -.Fn realloc -function returns either a null pointer or a pointer -to the possibly moved allocated space. -.Sh SEE ALSO -.Xr alloca 3 , -.Xr calloc 3 , -.Xr free 3 , -.Xr malloc 3 , -.Sh STANDARDS -The -.Fn realloc -function conforms to -.St -ansiC . diff --git a/lib/libc/stdtime/localtime.c.ORIG b/lib/libc/stdtime/localtime.c.ORIG deleted file mode 100644 index 54031479f1dc..000000000000 --- a/lib/libc/stdtime/localtime.c.ORIG +++ /dev/null @@ -1,1530 +0,0 @@ -#ifndef lint -#ifndef NOID -static char elsieid[] = "@(#)localtime.c 7.19"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - -/* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). -*/ - -/*LINTLIBRARY*/ - -#include "private.h" -#include "tzfile.h" -#include "fcntl.h" - -#define ACCESS_MODE O_RDONLY - -#ifdef O_BINARY -#define OPEN_MODE (O_RDONLY | O_BINARY) -#endif /* defined O_BINARY */ -#ifndef O_BINARY -#define OPEN_MODE O_RDONLY -#endif /* !defined O_BINARY */ - -#ifndef WILDABBR -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ -#define WILDABBR " " -#endif /* !defined WILDABBR */ - -static const char GMT[] = "GMT"; - -struct ttinfo { /* time type information */ - long tt_gmtoff; /* GMT offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* TRUE if transition is std time */ -}; - -struct lsinfo { /* leap second information */ - time_t ls_trans; /* transition time */ - long ls_corr; /* correction to apply */ -}; - -#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) - -#ifdef TZNAME_MAX -#define MY_TZNAME_MAX TZNAME_MAX -#endif /* defined TZNAME_MAX */ -#ifndef TZNAME_MAX -#define MY_TZNAME_MAX 255 -#endif /* !defined TZNAME_MAX */ - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - time_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof GMT), - (2 * (MY_TZNAME_MAX + 1)))]; - struct lsinfo lsis[TZ_MAX_LEAPS]; -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - long r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ - -static long detzcode P((const char * codep)); -static const char * getzname P((const char * strp)); -static const char * getnum P((const char * strp, int * nump, int min, - int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static void gmtsub P((const time_t * timep, long offset, - struct tm * tmp)); -static void localsub P((const time_t * timep, long offset, - struct tm * tmp)); -static int increment_overflow P((int * number, int delta)); -static int normalize_overflow P((int * tensptr, int * unitsptr, - int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, void (* funcp)(), - long offset)); -static time_t time2 P((struct tm *tmp, void (* funcp)(), - long offset, int * okayp)); -static void timesub P((const time_t * timep, long offset, - const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, - const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, - const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp)); -static int tzparse P((const char * name, struct state * sp, - int lastditch)); - -#ifdef ALL_STATE -static struct state * lclptr; -static struct state * gmtptr; -#endif /* defined ALL_STATE */ - -#ifndef ALL_STATE -static struct state lclmem; -static struct state gmtmem; -#define lclptr (&lclmem) -#define gmtptr (&gmtmem) -#endif /* State Farm */ - -static int lcl_is_set; -static int gmt_is_set; - -char * tzname[2] = { - WILDABBR, - WILDABBR -}; - -#ifdef USG_COMPAT -time_t timezone = 0; -int daylight = 0; -#endif /* defined USG_COMPAT */ - -#ifdef ALTZONE -time_t altzone = 0; -#endif /* defined ALTZONE */ - -static long -detzcode(codep) -const char * const codep; -{ - register long result; - register int i; - - result = 0; - for (i = 0; i < 4; ++i) - result = (result << 8) | (codep[i] & 0xff); - return result; -} - -static void -settzname() -{ - register const struct state * const sp = lclptr; - register int i; - - tzname[0] = WILDABBR; - tzname[1] = WILDABBR; -#ifdef USG_COMPAT - daylight = 0; - timezone = 0; -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - altzone = 0; -#endif /* defined ALTZONE */ -#ifdef ALL_STATE - if (sp == NULL) { - tzname[0] = tzname[1] = GMT; - return; - } -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) { - register const struct ttinfo * const ttisp = &sp->ttis[i]; - - tzname[ttisp->tt_isdst] = - (char *) &sp->chars[ttisp->tt_abbrind]; -#ifdef USG_COMPAT - if (ttisp->tt_isdst) - daylight = 1; - if (i == 0 || !ttisp->tt_isdst) - timezone = -(ttisp->tt_gmtoff); -#endif /* defined USG_COMPAT */ -#ifdef ALTZONE - if (i == 0 || ttisp->tt_isdst) - altzone = -(ttisp->tt_gmtoff); -#endif /* defined ALTZONE */ - } - /* - ** And to get the latest zone names into tzname. . . - */ - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * const ttisp = - &sp->ttis[ - sp->types[i]]; - - tzname[ttisp->tt_isdst] = - (char *) &sp->chars[ttisp->tt_abbrind]; - } -} - -static int -tzload(name, sp) -register const char * name; -register struct state * const sp; -{ - register const char * p; - register int i; - register int fid; - - if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; - { - register int doaccess; - char fullname[FILENAME_MAX + 1]; - - if (name[0] == ':') - ++name; - doaccess = name[0] == '/'; - if (!doaccess) { - if ((p = TZDIR) == NULL) - return -1; - if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; - (void) strcpy(fullname, p); - (void) strcat(fullname, "/"); - (void) strcat(fullname, name); - /* - ** Set doaccess if '.' (as in "../") shows up in name. - */ - if (strchr(name, '.') != NULL) - doaccess = TRUE; - name = fullname; - } - if (doaccess && access(name, ACCESS_MODE) != 0) - return -1; - if ((fid = open(name, OPEN_MODE)) == -1) - return -1; - } - { - register const struct tzhead * tzhp; - char buf[sizeof *sp + sizeof *tzhp]; - int ttisstdcnt; - - i = read(fid, buf, sizeof buf); - if (close(fid) != 0 || i < sizeof *tzhp) - return -1; - tzhp = (struct tzhead *) buf; - ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt); - sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt); - sp->timecnt = (int) detzcode(tzhp->tzh_timecnt); - sp->typecnt = (int) detzcode(tzhp->tzh_typecnt); - sp->charcnt = (int) detzcode(tzhp->tzh_charcnt); - if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || - sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || - sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || - sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || - (ttisstdcnt != sp->typecnt && ttisstdcnt != 0)) - return -1; - if (i < sizeof *tzhp + - sp->timecnt * (4 + sizeof (char)) + - sp->typecnt * (4 + 2 * sizeof (char)) + - sp->charcnt * sizeof (char) + - sp->leapcnt * 2 * 4 + - ttisstdcnt * sizeof (char)) - return -1; - p = buf + sizeof *tzhp; - for (i = 0; i < sp->timecnt; ++i) { - sp->ats[i] = detzcode(p); - p += 4; - } - for (i = 0; i < sp->timecnt; ++i) { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) - return -1; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - ttisp->tt_gmtoff = detzcode(p); - p += 4; - ttisp->tt_isdst = (unsigned char) *p++; - if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; - ttisp->tt_abbrind = (unsigned char) *p++; - if (ttisp->tt_abbrind < 0 || - ttisp->tt_abbrind > sp->charcnt) - return -1; - } - for (i = 0; i < sp->charcnt; ++i) - sp->chars[i] = *p++; - sp->chars[i] = '\0'; /* ensure '\0' at end */ - for (i = 0; i < sp->leapcnt; ++i) { - register struct lsinfo * lsisp; - - lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; - lsisp->ls_corr = detzcode(p); - p += 4; - } - for (i = 0; i < sp->typecnt; ++i) { - register struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisstdcnt == 0) - ttisp->tt_ttisstd = FALSE; - else { - ttisp->tt_ttisstd = *p++; - if (ttisp->tt_ttisstd != TRUE && - ttisp->tt_ttisstd != FALSE) - return -1; - } - } - } - return 0; -} - -static const int mon_lengths[2][MONSPERYEAR] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -static const int year_lengths[2] = { - DAYSPERNYEAR, DAYSPERLYEAR -}; - -/* -** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that -** character. -*/ - -static const char * -getzname(strp) -register const char * strp; -{ - register char c; - - while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && - c != '+') - ++strp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number from that string. -** Check that the number is within a specified range; if it is not, return -** NULL. -** Otherwise, return a pointer to the first character not part of the number. -*/ - -static const char * -getnum(strp, nump, min, max) -register const char * strp; -int * const nump; -const int min; -const int max; -{ - register char c; - register int num; - - if (strp == NULL || !isdigit(*strp)) - return NULL; - num = 0; - while ((c = *strp) != '\0' && isdigit(c)) { - num = num * 10 + (c - '0'); - if (num > max) - return NULL; /* illegal value */ - ++strp; - } - if (num < min) - return NULL; /* illegal value */ - *nump = num; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number of seconds, -** in hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the number -** of seconds. -*/ - -static const char * -getsecs(strp, secsp) -register const char * strp; -long * const secsp; -{ - int num; - - strp = getnum(strp, &num, 0, HOURSPERDAY); - if (strp == NULL) - return NULL; - *secsp = num * SECSPERHOUR; - if (*strp == ':') { - ++strp; - strp = getnum(strp, &num, 0, MINSPERHOUR - 1); - if (strp == NULL) - return NULL; - *secsp += num * SECSPERMIN; - if (*strp == ':') { - ++strp; - strp = getnum(strp, &num, 0, SECSPERMIN - 1); - if (strp == NULL) - return NULL; - *secsp += num; - } - } - return strp; -} - -/* -** Given a pointer into a time zone string, extract an offset, in -** [+-]hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the time. -*/ - -static const char * -getoffset(strp, offsetp) -register const char * strp; -long * const offsetp; -{ - register int neg; - - if (*strp == '-') { - neg = 1; - ++strp; - } else if (isdigit(*strp) || *strp++ == '+') - neg = 0; - else return NULL; /* illegal offset */ - strp = getsecs(strp, offsetp); - if (strp == NULL) - return NULL; /* illegal time */ - if (neg) - *offsetp = -*offsetp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". -** If a valid rule is not found, return NULL. -** Otherwise, return a pointer to the first character not part of the rule. -*/ - -static const char * -getrule(strp, rulep) -const char * strp; -register struct rule * const rulep; -{ - if (*strp == 'J') { - /* - ** Julian day. - */ - rulep->r_type = JULIAN_DAY; - ++strp; - strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); - } else if (*strp == 'M') { - /* - ** Month, week, day. - */ - rulep->r_type = MONTH_NTH_DAY_OF_WEEK; - ++strp; - strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_week, 1, 5); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); - } else if (isdigit(*strp)) { - /* - ** Day of year. - */ - rulep->r_type = DAY_OF_YEAR; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); - } else return NULL; /* invalid format */ - if (strp == NULL) - return NULL; - if (*strp == '/') { - /* - ** Time specified. - */ - ++strp; - strp = getsecs(strp, &rulep->r_time); - } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ - return strp; -} - -/* -** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the -** year, a rule, and the offset from GMT at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. -*/ - -static time_t -transtime(janfirst, year, rulep, offset) -const time_t janfirst; -const int year; -register const struct rule * const rulep; -const long offset; -{ - register int leapyear; - register time_t value; - register int i; - int d, m1, yy0, yy1, yy2, dow; - - leapyear = isleap(year); - switch (rulep->r_type) { - - case JULIAN_DAY: - /* - ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - ** years. - ** In non-leap years, or if the day number is 59 or less, just - ** add SECSPERDAY times the day number-1 to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; - if (leapyear && rulep->r_day >= 60) - value += SECSPERDAY; - break; - - case DAY_OF_YEAR: - /* - ** n - day of year. - ** Just add SECSPERDAY times the day number to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + rulep->r_day * SECSPERDAY; - break; - - case MONTH_NTH_DAY_OF_WEEK: - /* - ** Mm.n.d - nth "dth day" of month m. - */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; - - /* - ** Use Zeller's Congruence to get day-of-week of first day of - ** month. - */ - m1 = (rulep->r_mon + 9) % 12 + 1; - yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; - yy1 = yy0 / 100; - yy2 = yy0 % 100; - dow = ((26 * m1 - 2) / 10 + - 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; - if (dow < 0) - dow += DAYSPERWEEK; - - /* - ** "dow" is the day-of-week of the first day of the month. Get - ** the day-of-month (zero-origin) of the first "dow" day of the - ** month. - */ - d = rulep->r_day - dow; - if (d < 0) - d += DAYSPERWEEK; - for (i = 1; i < rulep->r_week; ++i) { - if (d + DAYSPERWEEK >= - mon_lengths[leapyear][rulep->r_mon - 1]) - break; - d += DAYSPERWEEK; - } - - /* - ** "d" is the day-of-month (zero-origin) of the day we want. - */ - value += d * SECSPERDAY; - break; - } - - /* - ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in - ** question. To get the Epoch-relative time of the specified local - ** time on that day, add the transition time and the current offset - ** from GMT. - */ - return value + rulep->r_time + offset; -} - -/* -** Given a POSIX section 8-style TZ string, fill in the rule tables as -** appropriate. -*/ - -static int -tzparse(name, sp, lastditch) -const char * name; -register struct state * const sp; -const int lastditch; -{ - const char * stdname; - const char * dstname; - int stdlen; - int dstlen; - long stdoffset; - long dstoffset; - register time_t * atp; - register unsigned char * typep; - register char * cp; - register int load_result; - - stdname = name; - if (lastditch) { - stdlen = strlen(name); /* length of standard zone name */ - name += stdlen; - if (stdlen >= sizeof sp->chars) - stdlen = (sizeof sp->chars) - 1; - } else { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; - } - if (*name == '\0') - return -1; /* was "stdoffset = 0;" */ - else { - name = getoffset(name, &stdoffset); - if (name == NULL) - return -1; - } - load_result = tzload(TZDEFRULES, sp); - if (load_result != 0) - sp->leapcnt = 0; /* so, we're off a little */ - if (*name != '\0') { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; - if (*name != '\0' && *name != ',' && *name != ';') { - name = getoffset(name, &dstoffset); - if (name == NULL) - return -1; - } else dstoffset = stdoffset - SECSPERHOUR; - if (*name == ',' || *name == ';') { - struct rule start; - struct rule end; - register int year; - register time_t janfirst; - time_t starttime; - time_t endtime; - - ++name; - if ((name = getrule(name, &start)) == NULL) - return -1; - if (*name++ != ',') - return -1; - if ((name = getrule(name, &end)) == NULL) - return -1; - if (*name != '\0') - return -1; - sp->typecnt = 2; /* standard time and DST */ - /* - ** Two transitions per year, from EPOCH_YEAR to 2037. - */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; - sp->ttis[0].tt_gmtoff = -dstoffset; - sp->ttis[0].tt_isdst = 1; - sp->ttis[0].tt_abbrind = stdlen + 1; - sp->ttis[1].tt_gmtoff = -stdoffset; - sp->ttis[1].tt_isdst = 0; - sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; - janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) { - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - if (starttime > endtime) { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } else { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } - janfirst += year_lengths[isleap(year)] * - SECSPERDAY; - } - } else { - int sawstd; - int sawdst; - long stdfix; - long dstfix; - long oldfix; - int isdst; - register int i; - - if (*name != '\0') - return -1; - if (load_result != 0) - return -1; - /* - ** Compute the difference between the real and - ** prototype standard and summer time offsets - ** from GMT, and put the real standard and summer - ** time offsets into the rules in place of the - ** prototype offsets. - */ - sawstd = FALSE; - sawdst = FALSE; - stdfix = 0; - dstfix = 0; - for (i = 0; i < sp->typecnt; ++i) { - if (sp->ttis[i].tt_isdst) { - oldfix = dstfix; - dstfix = sp->ttis[i].tt_gmtoff + - dstoffset; - if (sawdst && (oldfix != dstfix)) - return -1; - sp->ttis[i].tt_gmtoff = -dstoffset; - sp->ttis[i].tt_abbrind = stdlen + 1; - sawdst = TRUE; - } else { - oldfix = stdfix; - stdfix = sp->ttis[i].tt_gmtoff + - stdoffset; - if (sawstd && (oldfix != stdfix)) - return -1; - sp->ttis[i].tt_gmtoff = -stdoffset; - sp->ttis[i].tt_abbrind = 0; - sawstd = TRUE; - } - } - /* - ** Make sure we have both standard and summer time. - */ - if (!sawdst || !sawstd) - return -1; - /* - ** Now correct the transition times by shifting - ** them by the difference between the real and - ** prototype offsets. Note that this difference - ** can be different in standard and summer time; - ** the prototype probably has a 1-hour difference - ** between standard and summer time, but a different - ** difference can be specified in TZ. - */ - isdst = FALSE; /* we start in standard time */ - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * ttisp; - - /* - ** If summer time is in effect, and the - ** transition time was not specified as - ** standard time, add the summer time - ** offset to the transition time; - ** otherwise, add the standard time offset - ** to the transition time. - */ - ttisp = &sp->ttis[sp->types[i]]; - sp->ats[i] += - (isdst && !ttisp->tt_ttisstd) ? - dstfix : stdfix; - isdst = ttisp->tt_isdst; - } - } - } else { - dstlen = 0; - sp->typecnt = 1; /* only standard time */ - sp->timecnt = 0; - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = 0; - sp->ttis[0].tt_abbrind = 0; - } - sp->charcnt = stdlen + 1; - if (dstlen != 0) - sp->charcnt += dstlen + 1; - if (sp->charcnt > sizeof sp->chars) - return -1; - cp = sp->chars; - (void) strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; - if (dstlen != 0) { - (void) strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; - } - return 0; -} - -static void -gmtload(sp) -struct state * const sp; -{ - if (tzload(GMT, sp) != 0) - (void) tzparse(GMT, sp, TRUE); -} - -#ifndef STD_INSPIRED -static -#endif /* !defined STD_INSPIRED */ -void -tzsetwall() -{ - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (tzload((char *) NULL, lclptr) != 0) - gmtload(lclptr); - settzname(); -} - -void -tzset() -{ - register const char * name; - - name = getenv("TZ"); - if (name == NULL) { - tzsetwall(); - return; - } - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (*name == '\0') { - /* - ** User wants it fast rather than right. - */ - lclptr->leapcnt = 0; /* so, we're off a little */ - lclptr->timecnt = 0; - lclptr->ttis[0].tt_gmtoff = 0; - lclptr->ttis[0].tt_abbrind = 0; - (void) strcpy(lclptr->chars, GMT); - } else if (tzload(name, lclptr) != 0) - if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) - (void) gmtload(lclptr); - settzname(); -} - -/* -** The easy way to behave "as if no library function calls" localtime -** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- -** but it *is* desirable.) -** -** The unused offset argument is for the benefit of mktime variants. -*/ - -/*ARGSUSED*/ -static void -localsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; -{ - register const struct state * sp; - register const struct ttinfo * ttisp; - register int i; - const time_t t = *timep; - - if (!lcl_is_set) - tzset(); - sp = lclptr; -#ifdef ALL_STATE - if (sp == NULL) { - gmtsub(timep, offset, tmp); - return; - } -#endif /* defined ALL_STATE */ - if (sp->timecnt == 0 || t < sp->ats[0]) { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) { - i = 0; - break; - } - } else { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; - } - ttisp = &sp->ttis[i]; - /* - ** To get (wrong) behavior that's compatible with System V Release 2.0 - ** you'd replace the statement below with - ** t += ttisp->tt_gmtoff; - ** timesub(&t, 0L, sp, tmp); - */ - timesub(&t, ttisp->tt_gmtoff, sp, tmp); - tmp->tm_isdst = ttisp->tt_isdst; - tzname[tmp->tm_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; -#ifdef TM_ZONE - tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; -#endif /* defined TM_ZONE */ -} - -struct tm * -localtime(timep) -const time_t * const timep; -{ - static struct tm tm; - - localsub(timep, 0L, &tm); - return &tm; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static void -gmtsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; -{ - if (!gmt_is_set) { - gmt_is_set = TRUE; -#ifdef ALL_STATE - gmtptr = (struct state *) malloc(sizeof *gmtptr); - if (gmtptr != NULL) -#endif /* defined ALL_STATE */ - gmtload(gmtptr); - } - timesub(timep, offset, gmtptr, tmp); -#ifdef TM_ZONE - /* - ** Could get fancy here and deliver something such as - ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, - ** but this is no time for a treasure hunt. - */ - if (offset != 0) - tmp->TM_ZONE = WILDABBR; - else { -#ifdef ALL_STATE - if (gmtptr == NULL) - tmp->TM_ZONE = GMT; - else tmp->TM_ZONE = gmtptr->chars; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - tmp->TM_ZONE = gmtptr->chars; -#endif /* State Farm */ - } -#endif /* defined TM_ZONE */ -} - -struct tm * -gmtime(timep) -const time_t * const timep; -{ - static struct tm tm; - - gmtsub(timep, 0L, &tm); - return &tm; -} - -#ifdef STD_INSPIRED - -struct tm * -offtime(timep, offset) -const time_t * const timep; -const long offset; -{ - static struct tm tm; - - gmtsub(timep, offset, &tm); - return &tm; -} - -#endif /* defined STD_INSPIRED */ - -static void -timesub(timep, offset, sp, tmp) -const time_t * const timep; -const long offset; -register const struct state * const sp; -register struct tm * const tmp; -{ - register const struct lsinfo * lp; - register long days; - register long rem; - register int y; - register int yleap; - register const int * ip; - register long corr; - register int hit; - register int i; - - corr = 0; - hit = 0; -#ifdef ALL_STATE - i = (sp == NULL) ? 0 : sp->leapcnt; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - i = sp->leapcnt; -#endif /* State Farm */ - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) { - if (*timep == lp->ls_trans) { - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - if (hit) - while (i > 0 && - sp->lsis[i].ls_trans == - sp->lsis[i - 1].ls_trans + 1 && - sp->lsis[i].ls_corr == - sp->lsis[i - 1].ls_corr + 1) { - ++hit; - --i; - } - } - corr = lp->ls_corr; - break; - } - } - days = *timep / SECSPERDAY; - rem = *timep % SECSPERDAY; -#ifdef mc68k - if (*timep == 0x80000000) { - /* - ** A 3B1 muffs the division on the most negative number. - */ - days = -24855; - rem = -11648; - } -#endif /* mc68k */ - rem += (offset - corr); - while (rem < 0) { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) { - rem -= SECSPERDAY; - ++days; - } - tmp->tm_hour = (int) (rem / SECSPERHOUR); - rem = rem % SECSPERHOUR; - tmp->tm_min = (int) (rem / SECSPERMIN); - tmp->tm_sec = (int) (rem % SECSPERMIN); - if (hit) - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60" et seq. - */ - tmp->tm_sec += hit; - tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - y = EPOCH_YEAR; - if (days >= 0) - for ( ; ; ) { - yleap = isleap(y); - if (days < (long) year_lengths[yleap]) - break; - ++y; - days = days - (long) year_lengths[yleap]; - } - else do { - --y; - yleap = isleap(y); - days = days + (long) year_lengths[yleap]; - } while (days < 0); - tmp->tm_year = y - TM_YEAR_BASE; - tmp->tm_yday = (int) days; - ip = mon_lengths[yleap]; - for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) - days = days - (long) ip[tmp->tm_mon]; - tmp->tm_mday = (int) (days + 1); - tmp->tm_isdst = 0; -#ifdef TM_GMTOFF - tmp->TM_GMTOFF = offset; -#endif /* defined TM_GMTOFF */ -} - -char * -ctime(timep) -const time_t * const timep; -{ - return asctime(localtime(timep)); -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). -** It does a binary search of the time_t space. Since time_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -/* -** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com). -*/ - -static int -increment_overflow(number, delta) -int * number; -int delta; -{ - int number0; - - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); -} - -static int -normalize_overflow(tensptr, unitsptr, base) -int * const tensptr; -int * const unitsptr; -const int base; -{ - register int tensdelta; - - tensdelta = (*unitsptr >= 0) ? - (*unitsptr / base) : - (-1 - (-1 - *unitsptr) / base); - *unitsptr -= tensdelta * base; - return increment_overflow(tensptr, tensdelta); -} - -static int -tmcomp(atmp, btmp) -register const struct tm * const atmp; -register const struct tm * const btmp; -{ - register int result; - - if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && - (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static time_t -time2(tmp, funcp, offset, okayp) -struct tm * const tmp; -void (* const funcp)(); -const long offset; -int * const okayp; -{ - register const struct state * sp; - register int dir; - register int bits; - register int i, j ; - register int saved_seconds; - time_t newt; - time_t t; - struct tm yourtm, mytm; - - *okayp = FALSE; - yourtm = *tmp; - if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) - return WRONG; - if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) - return WRONG; - if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR)) - return WRONG; - /* - ** Turn yourtm.tm_year into an actual year number for now. - ** It is converted back to an offset from TM_YEAR_BASE later. - */ - if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE)) - return WRONG; - while (yourtm.tm_mday <= 0) { - if (increment_overflow(&yourtm.tm_year, -1)) - return WRONG; - yourtm.tm_mday += year_lengths[isleap(yourtm.tm_year)]; - } - while (yourtm.tm_mday > DAYSPERLYEAR) { - yourtm.tm_mday -= year_lengths[isleap(yourtm.tm_year)]; - if (increment_overflow(&yourtm.tm_year, 1)) - return WRONG; - } - for ( ; ; ) { - i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) { - yourtm.tm_mon = 0; - if (increment_overflow(&yourtm.tm_year, 1)) - return WRONG; - } - } - if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE)) - return WRONG; - if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) { - /* - ** We can't set tm_sec to 0, because that might push the - ** time below the minimum representable time. - ** Set tm_sec to 59 instead. - ** This assumes that the minimum representable time is - ** not in the same minute that a leap second was deleted from, - ** which is a safer assumption than using 58 would be. - */ - if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN)) - return WRONG; - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = SECSPERMIN - 1; - } else { - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - } - /* - ** Calculate the number of magnitude bits in a time_t - ** (this works regardless of whether time_t is - ** signed or unsigned, though lint complains if unsigned). - */ - for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) - continue; - /* - ** If time_t is signed, then 0 is the median value, - ** if time_t is unsigned, then 1 << bits is median. - */ - t = (t < 0) ? 0 : ((time_t) 1 << bits); - for ( ; ; ) { - (*funcp)(&t, offset, &mytm); - dir = tmcomp(&mytm, &yourtm); - if (dir != 0) { - if (bits-- < 0) - return WRONG; - if (bits < 0) - --t; - else if (dir > 0) - t -= (time_t) 1 << bits; - else t += (time_t) 1 << bits; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) - (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = 0; j < sp->typecnt; ++j) { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - - sp->ttis[i].tt_gmtoff; - (*funcp)(&newt, offset, &mytm); - if (tmcomp(&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } -label: - newt = t + saved_seconds; - if ((newt < t) != (saved_seconds < 0)) - return WRONG; - t = newt; - (*funcp)(&t, offset, tmp); - *okayp = TRUE; - return t; -} - -static time_t -time1(tmp, funcp, offset) -struct tm * const tmp; -void (* const funcp)(); -const long offset; -{ - register time_t t; - register const struct state * sp; - register int samei, otheri; - int okay; - - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2(tmp, funcp, offset, &okay); -#ifdef PCTS - /* - ** PCTS code courtesy Grant Sullivan (grant@osf.org). - */ - if (okay) - return t; - if (tmp->tm_isdst < 0) - tmp->tm_isdst = 0; /* reset to std and try again */ -#endif /* defined PCTS */ -#ifndef PCTS - if (okay || tmp->tm_isdst < 0) - return t; -#endif /* !defined PCTS */ - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (samei = 0; samei < sp->typecnt; ++samei) { - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otheri = 0; otheri < sp->typecnt; ++otheri) { - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2(tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -time_t -mktime(tmp) -struct tm * const tmp; -{ - return time1(tmp, localsub, 0L); -} - -#ifdef STD_INSPIRED - -time_t -timelocal(tmp) -struct tm * const tmp; -{ - tmp->tm_isdst = -1; /* in case it wasn't initialized */ - return mktime(tmp); -} - -time_t -timegm(tmp) -struct tm * const tmp; -{ - tmp->tm_isdst = 0; - return time1(tmp, gmtsub, 0L); -} - -time_t -timeoff(tmp, offset) -struct tm * const tmp; -const long offset; -{ - tmp->tm_isdst = 0; - return time1(tmp, gmtsub, offset); -} - -#endif /* defined STD_INSPIRED */ - -#ifdef CMUCS - -/* -** The following is supplied for compatibility with -** previous versions of the CMUCS runtime library. -*/ - -long -gtime(tmp) -struct tm * const tmp; -{ - const time_t t = mktime(tmp); - - if (t == WRONG) - return -1; - return t; -} - -#endif /* defined CMUCS */ - -/* -** XXX--is the below the right way to conditionalize?? -*/ - -#ifdef STD_INSPIRED - -/* -** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599 -** shall correspond to "Wed Dec 31 23:59:59 GMT 1986", which -** is not the case if we are accounting for leap seconds. -** So, we provide the following conversion routines for use -** when exchanging timestamps with POSIX conforming systems. -*/ - -static long -leapcorr(timep) -time_t * timep; -{ - register struct state * sp; - register struct lsinfo * lp; - register int i; - - if (!lcl_is_set) - (void) tzset(); - sp = lclptr; - i = sp->leapcnt; - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) - return lp->ls_corr; - } - return 0; -} - -time_t -time2posix(t) -time_t t; -{ - return t - leapcorr(&t); -} - -time_t -posix2time(t) -time_t t; -{ - time_t x; - time_t y; - - /* - ** For a positive leap second hit, the result - ** is not unique. For a negative leap second - ** hit, the corresponding time doesn't exist, - ** so we return an adjacent second. - */ - x = t + leapcorr(&t); - y = x - leapcorr(&x); - if (y < t) { - do { - x++; - y = x - leapcorr(&x); - } while (y < t); - if (t != y) - return x - 1; - } else if (y > t) { - do { - --x; - y = x - leapcorr(&x); - } while (y > t); - if (t != y) - return x + 1; - } - return x; -} - -#endif /* defined STD_INSPIRED */ diff --git a/lib/libc/string/strftime.3 b/lib/libc/string/strftime.3 deleted file mode 100644 index 3da35a1c4460..000000000000 --- a/lib/libc/string/strftime.3 +++ /dev/null @@ -1,186 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt STRFTIME 3 -.Os -.Sh NAME -.Nm strftime -.Nd format date and time -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft size_t -.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" -.Sh DESCRIPTION -The -.Fn strftime -function formats the information from -.Fa timeptr -into the buffer -.Fa buf -according to the string pointed to by -.Fa format . -.Pp -The -.Fa format -string consists of zero or more conversion specifications and -ordinary characters. -All ordinary characters are copied directly into the buffer. -A conversion specification consists of a percent sign -.Dq Ql % -and one other character. -.Pp -No more than -.Fa maxsize -characters will be placed into the array. -If the total number of resulting characters, including the terminating -null character, is not more than -.Fa maxsize , -.Fn strftime -returns the number of characters in the array, not counting the -terminating null. -Otherwise, zero is returned. -.Pp -Each conversion specification is replaced by the characters as -follows which are then copied into the buffer. -.Bl -tag -width "xxxx" -.It Cm \&%A -is replaced by the full weekday name. -.It Cm %a -is replaced by the abbreviated weekday name, where the abbreviation -is the first three characters. -.It Cm \&%B -is replaced by the full month name. -.It Cm %b or %h -is replaced by the abbreviated month name, where the abbreviation is -the first three characters. -.It Cm \&%C -is equivalent to -.Dq Li %a %b %e %H:%M:%S %Y -(the format produced by -.Xr asctime 3 . -.It Cm %c -is equivalent to -.Dq Li %m/%d/%y . -.It Cm \&%D -is replaced by the date in the format -.Dq Ql mm/dd/yy . -.It Cm %d -is replaced by the day of the month as a decimal number (01-31). -.It Cm %e -is replaced by the day of month as a decimal number (1-31); single -digits are preceded by a blank. -.It Cm \&%H -is replaced by the hour (24-hour clock) as a decimal number (00-23). -.It Cm \&%I -is replaced by the hour (12-hour clock) as a decimal number (01-12). -.It Cm %j -is replaced by the day of the year as a decimal number (001-366). -.It Cm %k -is replaced by the hour (24-hour clock) as a decimal number (0-23); -single digits are preceded by a blank. -.It Cm %l -is replaced by the hour (12-hour clock) as a decimal number (1-12); -single digits are preceded by a blank. -.It Cm \&%M -is replaced by the minute as a decimal number (00-59). -.It Cm %m -is replaced by the month as a decimal number (01-12). -.It Cm %n -is replaced by a newline. -.It Cm %p -is replaced by either -.Dq Tn AM -or -.Dq Tn PM -as appropriate. -.It Cm \&%R -is equivalent to -.Dq Li %H:%M -.It Cm %r -is equivalent to -.Dq Li %I:%M:%S %p . -.It Cm %t -is replaced by a tab. -.It Cm \&%S -is replaced by the second as a decimal number (00-60). -.It Cm %s -is replaced by the number of seconds since the Epoch, UCT (see -.Xr mktime 3 ) . -.It Cm \&%T No or Cm \&%X -is equivalent to -.Dq Li %H:%M:%S . -.It Cm \&%U -is replaced by the week number of the year (Sunday as the first day of -the week) as a decimal number (00-53). -.It Cm \&%W -is replaced by the week number of the year (Monday as the first day of -the week) as a decimal number (00-53). -.It Cm %w -is replaced by the weekday (Sunday as the first day of the week) -as a decimal number (0-6). -.It Cm %x -is equivalent to -.Dq Li %m/%d/%y %H:%M:%S . -.It Cm \&%Y -is replaced by the year with century as a decimal number. -.It Cm %y -is replaced by the year without century as a decimal number (00-99). -.It Cm \&%Z -is replaced by the time zone name. -.It Cm %% -is replaced by -.Ql % . -.El -.Sh SEE ALSO -.Xr date 1 , -.Xr ctime 3 , -.Xr printf 1 , -.Xr printf 3 -.Sh STANDARDS -The -.Fn strftime -function -conforms to -.St -ansiC . -The -.Ql %s -conversion specification is an extension. -.Sh BUGS -There is no conversion specification for the phase of the moon. diff --git a/lib/libc/string/strftime.c b/lib/libc/string/strftime.c deleted file mode 100644 index b39aeeb9917a..000000000000 --- a/lib/libc/string/strftime.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strftime.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -static char *afmt[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", -}; -static char *Afmt[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", - "Saturday", -}; -static char *bfmt[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", - "Oct", "Nov", "Dec", -}; -static char *Bfmt[] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December", -}; - -static size_t gsize; -static char *pt; -static int _add __P((char *)); -static int _conv __P((int, int, int)); -static int _secs __P((const struct tm *)); -static size_t _fmt __P((const char *, const struct tm *)); - -size_t -strftime(s, maxsize, format, t) - char *s; - size_t maxsize; - const char *format; - const struct tm *t; -{ - - pt = s; - if ((gsize = maxsize) < 1) - return(0); - if (_fmt(format, t)) { - *pt = '\0'; - return(maxsize - gsize); - } - return(0); -} - -static size_t -_fmt(format, t) - register const char *format; - const struct tm *t; -{ - for (; *format; ++format) { - if (*format == '%') - switch(*++format) { - case '\0': - --format; - break; - case 'A': - if (t->tm_wday < 0 || t->tm_wday > 6) - return(0); - if (!_add(Afmt[t->tm_wday])) - return(0); - continue; - case 'a': - if (t->tm_wday < 0 || t->tm_wday > 6) - return(0); - if (!_add(afmt[t->tm_wday])) - return(0); - continue; - case 'B': - if (t->tm_mon < 0 || t->tm_mon > 11) - return(0); - if (!_add(Bfmt[t->tm_mon])) - return(0); - continue; - case 'b': - case 'h': - if (t->tm_mon < 0 || t->tm_mon > 11) - return(0); - if (!_add(bfmt[t->tm_mon])) - return(0); - continue; - case 'C': - if (!_fmt("%a %b %e %H:%M:%S %Y", t)) - return(0); - continue; - case 'c': - if (!_fmt("%m/%d/%y %H:%M:%S", t)) - return(0); - continue; - case 'D': - if (!_fmt("%m/%d/%y", t)) - return(0); - continue; - case 'd': - if (!_conv(t->tm_mday, 2, '0')) - return(0); - continue; - case 'e': - if (!_conv(t->tm_mday, 2, ' ')) - return(0); - continue; - case 'H': - if (!_conv(t->tm_hour, 2, '0')) - return(0); - continue; - case 'I': - if (!_conv(t->tm_hour % 12 ? - t->tm_hour % 12 : 12, 2, '0')) - return(0); - continue; - case 'j': - if (!_conv(t->tm_yday + 1, 3, '0')) - return(0); - continue; - case 'k': - if (!_conv(t->tm_hour, 2, ' ')) - return(0); - continue; - case 'l': - if (!_conv(t->tm_hour % 12 ? - t->tm_hour % 12 : 12, 2, ' ')) - return(0); - continue; - case 'M': - if (!_conv(t->tm_min, 2, '0')) - return(0); - continue; - case 'm': - if (!_conv(t->tm_mon + 1, 2, '0')) - return(0); - continue; - case 'n': - if (!_add("\n")) - return(0); - continue; - case 'p': - if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) - return(0); - continue; - case 'R': - if (!_fmt("%H:%M", t)) - return(0); - continue; - case 'r': - if (!_fmt("%I:%M:%S %p", t)) - return(0); - continue; - case 'S': - if (!_conv(t->tm_sec, 2, '0')) - return(0); - continue; - case 's': - if (!_secs(t)) - return(0); - continue; - case 'T': - case 'X': - if (!_fmt("%H:%M:%S", t)) - return(0); - continue; - case 't': - if (!_add("\t")) - return(0); - continue; - case 'U': - if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, - 2, '0')) - return(0); - continue; - case 'W': - if (!_conv((t->tm_yday + 7 - - (t->tm_wday ? (t->tm_wday - 1) : 6)) - / 7, 2, '0')) - return(0); - continue; - case 'w': - if (!_conv(t->tm_wday, 1, '0')) - return(0); - continue; - case 'x': - if (!_fmt("%m/%d/%y", t)) - return(0); - continue; - case 'y': - if (!_conv((t->tm_year + TM_YEAR_BASE) - % 100, 2, '0')) - return(0); - continue; - case 'Y': - if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) - return(0); - continue; - case 'Z': - if (!t->tm_zone || !_add(t->tm_zone)) - return(0); - continue; - case '%': - /* - * X311J/88-090 (4.12.3.5): if conversion char is - * undefined, behavior is undefined. Print out the - * character itself as printf(3) does. - */ - default: - break; - } - if (!gsize--) - return(0); - *pt++ = *format; - } - return(gsize); -} - -static int -_secs(t) - const struct tm *t; -{ - static char buf[15]; - register time_t s; - register char *p; - struct tm tmp; - - /* Make a copy, mktime(3) modifies the tm struct. */ - tmp = *t; - s = mktime(&tmp); - for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10) - *p-- = s % 10 + '0'; - return(_add(++p)); -} - -static int -_conv(n, digits, pad) - int n, digits, pad; -{ - static char buf[10]; - register char *p; - - for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) - *p-- = n % 10 + '0'; - while (p > buf && digits-- > 0) - *p-- = pad; - return(_add(++p)); -} - -static int -_add(str) - register char *str; -{ - for (;; ++pt, --gsize) { - if (!gsize) - return(0); - if (!(*pt = *str++)) - return(1); - } -} diff --git a/lib/libcompat/regexp/regexp.h b/lib/libcompat/regexp/regexp.h deleted file mode 100644 index 73d6bf412424..000000000000 --- a/lib/libcompat/regexp/regexp.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Definitions etc. for regexp(3) routines. - * - * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], - * not the System V one. - */ -#define NSUBEXP 10 -typedef struct regexp { - char *startp[NSUBEXP]; - char *endp[NSUBEXP]; - char regstart; /* Internal use only. */ - char reganch; /* Internal use only. */ - char *regmust; /* Internal use only. */ - int regmlen; /* Internal use only. */ - char program[1]; /* Unwarranted chumminess with compiler. */ -} regexp; - -extern regexp *regcomp(); -extern int regexec(); -extern void regsub(); -extern void regerror(); diff --git a/lib/libedit/histedit.h b/lib/libedit/histedit.h deleted file mode 100644 index 95423c6482f5..000000000000 --- a/lib/libedit/histedit.h +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Christos Zoulas of Cornell University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)histedit.h 8.2 (Berkeley) 1/3/94 - */ - -/* - * histedit.h: Line editor and history interface. - */ -#ifndef _h_editline -#define _h_editline - -#include -#include - -/* - * ==== Editing ==== - */ -typedef struct editline EditLine; - -/* - * For user-defined function interface - */ -typedef struct lineinfo { - __const char *buffer; - __const char *cursor; - __const char *lastchar; -} LineInfo; - - -/* - * EditLine editor function return codes. - * For user-defined function interface - */ -#define CC_NORM 0 -#define CC_NEWLINE 1 -#define CC_EOF 2 -#define CC_ARGHACK 3 -#define CC_REFRESH 4 -#define CC_CURSOR 5 -#define CC_ERROR 6 -#define CC_FATAL 7 - -/* - * Initialization, cleanup, and resetting - */ -EditLine *el_init __P((const char *, FILE *, FILE *)); -void el_reset __P((EditLine *)); -void el_end __P((EditLine *)); - - -/* - * Get a line, a character or push a string back in the input queue - */ -__const char *el_gets __P((EditLine *, int *)); -int el_getc __P((EditLine *, char *)); -void el_push __P((EditLine *, const char *)); - -/* - * High level function internals control - * Parses argc, argv array and executes builtin editline commands - */ -int el_parse __P((EditLine *, int, char **)); - -/* - * Low level editline access function - */ -int el_set __P((EditLine *, int, ...)); - -/* - * el_set/el_get parameters - */ -#define EL_PROMPT 0 /* , el_pfunc_t); */ -#define EL_TERMINAL 1 /* , const char *); */ -#define EL_EDITOR 2 /* , const char *); */ -#define EL_SIGNAL 3 /* , int); */ -#define EL_BIND 4 /* , const char *, ..., NULL); */ -#define EL_TELLTC 5 /* , const char *, ..., NULL); */ -#define EL_SETTC 6 /* , const char *, ..., NULL); */ -#define EL_ECHOTC 7 /* , const char *, ..., NULL); */ -#define EL_SETTY 8 /* , const char *, ..., NULL); */ -#define EL_ADDFN 9 /* , const char *, const char * */ - /* , el_func_t); */ -#define EL_HIST 10 /* , hist_fun_t, const char *); */ - -/* - * Source named file or $PWD/.editrc or $HOME/.editrc - */ -int el_source __P((EditLine *, const char *)); - -/* - * Must be called when the terminal changes size; If EL_SIGNAL - * is set this is done automatically otherwise it is the responsibility - * of the application - */ -void el_resize __P((EditLine *)); - - -/* - * User-defined function interface. - */ -__const LineInfo *el_line __P((EditLine *)); -int el_insertstr __P((EditLine *, char *)); -void el_deletestr __P((EditLine *, int)); - -/* - * ==== History ==== - */ - -typedef struct history History; - -typedef struct HistEvent { - int num; - __const char *str; -} HistEvent; - -/* - * History access functions. - */ -History * history_init __P((void)); -void history_end __P((History *)); - -__const HistEvent * history __P((History *, int, ...)); - -#define H_FUNC 0 /* , UTSL */ -#define H_EVENT 1 /* , const int); */ -#define H_FIRST 2 /* , void); */ -#define H_LAST 3 /* , void); */ -#define H_PREV 4 /* , void); */ -#define H_NEXT 5 /* , void); */ -#define H_CURR 6 /* , void); */ -#define H_ADD 7 /* , const char*); */ -#define H_ENTER 8 /* , const char*); */ -#define H_END 9 /* , void); */ -#define H_NEXT_STR 10 /* , const char*); */ -#define H_PREV_STR 11 /* , const char*); */ -#define H_NEXT_EVENT 12 /* , const int); */ -#define H_PREV_EVENT 13 /* , const int); */ - -#endif /* _h_editline */ diff --git a/lib/libedit/termcap.h b/lib/libedit/termcap.h deleted file mode 100644 index 4fd2cab0ec02..000000000000 --- a/lib/libedit/termcap.h +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Christos Zoulas of Cornell University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)termcap.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * termcap.h: I cannot find those in any include files... - */ -#ifndef _h_termcap -#define _h_termcap - -int tgetent __P((char *, char *)); -char *tgetstr __P((char *, char **)); -int tgetflag __P((char *)); -int tgetnum __P((char *)); -char *tgoto __P((char *, int, int)); -char *tputs __P((char *, int, void (*)(int))); - -#endif /* _h_termcap */ diff --git a/lib/librpc/DISCLAIMER b/lib/librpc/DISCLAIMER deleted file mode 100644 index 1a66d5f4c9cd..000000000000 --- a/lib/librpc/DISCLAIMER +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ diff --git a/lib/librpc/Makefile b/lib/librpc/Makefile deleted file mode 100644 index bafff291ebd0..000000000000 --- a/lib/librpc/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC -# -# Build and install everything. -# -# These directories are presumed to exist in DESTDIR: -# /usr/lib /usr/bin /usr/include -# -DESTDIR= -CFLAGS=-O -MAKE=make - -# These are not used by BSD except portmap which lives in -# /usr/src/usr.sbin/portmap. -# SUBDIR= rpcgen etc rpcsvc - -all install: rpclib ${SUBDIR} - -rpclib: FRC - @echo "Building and installing RPC library" - cd rpc; $(MAKE) ${MFLAGS} all DESTDIR=${DESTDIR}; \ - $(MAKE) ${MFLAGS} install DESTDIR=${DESTDIR} - -${SUBDIR}: FRC - @echo "Building and installing files from: $@" - cd $@; $(MAKE) ${MFLAGS} DESTDIR=${DESTDIR} CFLAGS=${CFLAGS};\ - $(MAKE) ${MFLAGS} install DESTDIR=${DESTDIR} - -FRC: - diff --git a/lib/librpc/README b/lib/librpc/README deleted file mode 100644 index ad9d70f99056..000000000000 --- a/lib/librpc/README +++ /dev/null @@ -1,233 +0,0 @@ -RPCSRC 4.0 7/11/89 - -This distribution contains Sun Microsystem's implementation of the -RPC and XDR protocols and is compatible with 4.2BSD and 4.3BSD. Also -included is complete documentation, utilities, RPC service -specification files, and demonstration services in the format used by -the RPC protocol compiler (rpcgen). See WHAT'S NEW below for -details. - -NOTE ABOUT SECURE RPC: - -This release of RPCSRC contains most of the code needed to implement -Secure RPC (see "DES Authentication" in the RPC Protocol Specification, -doc/rpc.rfc.ms). Due to legal considerations, we are unable to -distribute an implementation of DES, the Data Encryption Standard, which -Secure RPC requires. For this reason, all of the files, documentation, and -programs associated with Secure RPC have been placed into a separate -directory, secure_rpc. The RPC library contained in the main body of this -release *DOES NOT* support Secure RPC. See secure_rpc/README for more -details. (A DES library was posted in Volume 18 of comp.sources.unix.) - -If you wish to report bugs found in this release, send mail to: - -Portable ONC/NFS -Sun Microsystems, Inc -MS 12-33 -2550 Garcia Avenue -Mountain View, CA 94043 - -or send Email to nfsnet@sun.com (the Internet) or sun!nfsnet (Usenet). - -ROADMAP - -The directory hierarchy is as follows: - - demo/ Various demonstration services - demo/dir Remote directory lister - demo/msg Remote console message delivery service - demo/sort Remote sort service - - doc/ Documentation for RPC, XDR and NFS in "-ms" format. - - etc/ Utilities (rpcinfo and portmap). portmap must be - started by root before any other RPC network services are - used. SEE BELOW FOR BUGFIX TO 4.3BSD COMPILER. - - man/ Manual pages for RPC library, rpcgen, and utilities. - - rpc/ The RPC and XDR library. SEE BELOW - FOR BUGFIX TO 4.2BSD COMPILER. - - rpcgen/ The RPC Language compiler (for .x files) - - rpcsvc/ Service definition files for various services and the - server and client code for the Remote Status service. - - secure_rpc/ The files in this directory are used to build a version of - the RPC library with DES Authentication. See the README - file in that directory for more details. - -BUILD INSTRUCTIONS - -Makefiles can be found in all directories except for man. The -Makefile in the top directory will cause these others to be invoked -(except for in the doc, man and demo directories), in turn building the -entire release. - -WARNING! THE DEFAULT INSTALLATION PROCEDURES WILL INSTALL FILES -IN /usr/include, /usr/lib, /usr/bin and /etc. - -The master RPC include file, rpc/rpc.h, is used by all programs and -routines that use RPC. It includes other RPC and system include files -needed by the RPC system. PLEASE NOTE: If your system has NFS, it -may have been based on Sun's NFS Source. The include files installed -by this package may duplicate include files you will find on your NFS -system. The RPCSRC 4.0 include files are upwardly compatible to all -NFS Source include files as of the date of this distribution (not -including any new definitions or declarations added by your system -vendor). HOWEVER: Please read the comments towards the end of -rpc/rpc.h regarding rpc/netdb.h. You may need to uncomment the -inclusion of that file if the structures it defines are already -defined by your system's include files. - -After making any compiler fixes that are needed (see below), at -the top directory, type: - - make install - -For all installations, the Makefile macro DESTDIR is prepended to the -installation path. It is defined to be null in the Makefiles, so -installations are relative to root. (You will probably need root -privileges for installing the files under the default path.) To -install the files under some other tree (e.g., /usr/local), use the -command: - - make install DESTDIR=/usr/local - -This will place the include files in /usr/local/usr/include, the RPC -library in /usr/local/usr/lib, rpcgen in /usr/local/usr/bin, and the -utilities in /usr/local/etc. You'll have to edit the Makefiles or -install the files by hand if you want to do anything other than this -kind of relocation of the installation tree. - -The RPC library will be built and installed first. By default it is -installed in /usr/lib as "librpclib.a". The directory -/usr/include/rpc will also be created, and several header files will -be installed there. ALL RPC SERVICES INCLUDE THESE HEADER FILES. - -The programs in etc/ link in routines from librpclib.a. If you change -where it is installed, be sure to edit etc/'s Makefile to reflect this. -These programs are installed in /etc. PORTMAP MUST BE RUNNING ON -YOUR SYSTEM BEFORE YOU START ANY OTHER RPC SERVICE. - -rpcgen is installed in /usr/bin. This program is required to build -the demonstration services in demo and the rstat client and server in -rpcsvc/. - -The rpcsvc/ directory will install its files in the directory -/usr/include/rpcsvc. The Remote Status service (rstat_svc) will be -compiled and installed in /etc. If you wish to make this service -available, you should either start this service when needed or have -it started at boot time by invoking it in your /etc/rc.local script. -(Be sure that portmap is started first!) Sun has modified its -version of inetd to automatically start RPC services. (Use "make -LIB=" when building rstat on a Sun Workstation.) The Remote Status -client (rstat) will be installed in /usr/bin. This program queries -the rstat_svc on a remote host and prints a system status summary -similar to the one printed by "uptime". - -The documentation is not built during the "make install" command. -Typing "make" in the doc directory will cause all of the manuals to -be formatted using nroff into a single file. We have had a report -that certain "troff" equivalents have trouble processing the full -manual. If you have trouble, try building the manuals individually -(see the Makefile). - -The demonstration services in the demo directory are not built by the -top-level "make install" command. To build these, cd to the demo -directory and enter "make". The three services will be built. -RPCGEN MUST BE INSTALLED in a path that make can find. To run the -services, start the portmap program as root and invoke the service -(you probably will want to put it in the background). rpcinfo can be -used to check that the service succeeded in getting registered with -portmap, and to ping the service (see rpcinfo's man page). You can -then use the corresponding client program to exercise the service. -To build these services on a Sun workstation, you must prevent the -Makefile from trying to link the RPC library (as these routines are -already a part of Sun's libc). Use: "make LIB=". - -BUGFIX FOR 4.3BSD COMPILER - -The use of a 'void *' declaration for one of the arguments in -the reply_proc() procedure in etc/rpcinfo.c will trigger a bug -in the 4.3BSD compiler. The bug is fixed by the following change to -the compiler file mip/manifest.h: - -*** manifest.h.r1.1 Thu Apr 30 13:52:25 1987 ---- manifest.h.r1.2 Mon Nov 23 18:58:17 1987 -*************** -*** 21,27 **** - /* - * Bogus type values - */ -! #define TNULL PTR /* pointer to UNDEF */ - #define TVOID FTN /* function returning UNDEF (for void) */ - - /* ---- 21,27 ---- - /* - * Bogus type values - */ -! #define TNULL INCREF(MOETY) /* pointer to MOETY -- impossible type */ - #define TVOID FTN /* function returning UNDEF (for void) */ - - /* - -If you cannot fix your compiler, change the declaration in reply_proc() -from 'void *' to 'char *'. - -BUGFIX FOR 4.2BSD COMPILER - -Unpatched 4.2BSD compilers complain about valid C. You can make old -compilers happy by changing some voids to ints. However, the fix to -the 4.2 VAX compiler is as follows (to mip/trees.c): - -*** trees.c.r1.1 Mon May 11 13:47:58 1987 ---- trees.c.r1.2 Wed Jul 2 18:28:52 1986 -*************** -*** 1247,1253 **** - if(o==CAST && mt1==0)return(TYPL+TYMATCH); - if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH ); - else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN ); -! else if( mt12 == 0 ) break; - else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN ); - else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN ); - break; ---- 1261,1269 ---- - if(o==CAST && mt1==0)return(TYPL+TYMATCH); - if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH ); - else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN ); -! /* if right is TVOID and looks like a CALL, is not ok */ -! else if (mt2 == 0 && (p->in.right->in.op == CALL || p->in.right->in.op == UNARY CALL)) -! break; - else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN ); - else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN ); - break; - -WHAT'S NEW IN THIS RELEASE: RPCSRC 4.0 - -The previous release was RPCSRC 3.9. As with all previous releases, -this release is based directly on files from Sun Microsystem's -implementation. - -Upgrade from RPCSRC 3.9 - -1) RPCSRC 4.0 upgrades RPCSRC 3.9. Improvements from SunOS 4.0 have - been integrated into this release. - -Secure RPC (in the secure_rpc/ directory) - -2) DES Authentication routines and programs are provided. -3) A new manual, "Secure NFS" is provided, which describes Secure RPC - and Secure NFS. -4) Skeleton routines and manual pages are provided which describe the - DES encryption procedures required by Secure RPC. HOWEVER, NO DES - ROUTINE IS PROVIDED. - -New Functionality - -5) rpcinfo can now be used to de-register services from the portmapper - which may have terminated abnormally. -6) A new client, rstat, is provided which queries the rstat_svc and - prints a status line similar to the one displayed by "uptime". diff --git a/lib/librpc/demo/Makefile b/lib/librpc/demo/Makefile deleted file mode 100644 index 05510d64eb9f..000000000000 --- a/lib/librpc/demo/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/02 4.0 RPCSRC -# -# -# Build all demo services -# -MAKE = make -LIB=-lrpclib - -SUBDIR= dir msg sort - -all: ${SUBDIR} - -clean cleanup: - cd dir; $(MAKE) ${MFLAGS} cleanup - cd msg; $(MAKE) ${MFLAGS} cleanup - cd sort; $(MAKE) ${MFLAGS} cleanup - -install: - @echo "No installations done." - -${SUBDIR}: FRC - cd $@; $(MAKE) ${MFLAGS} LIB=$(LIB) - -FRC: diff --git a/lib/librpc/demo/dir/Makefile b/lib/librpc/demo/dir/Makefile deleted file mode 100644 index 592c9d6861e9..000000000000 --- a/lib/librpc/demo/dir/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/02 4.0 RPCSRC -# -BIN = dir_svc rls -GEN = dir_clnt.c dir_svc.c dir_xdr.c dir.h -LIB = -lrpclib -RPCCOM = rpcgen - -all: $(BIN) - -$(GEN): dir.x - $(RPCCOM) dir.x - -dir_svc: dir_proc.o dir_svc.o dir_xdr.o - $(CC) -o $@ dir_proc.o dir_svc.o dir_xdr.o $(LIB) - -rls: rls.o dir_clnt.o dir_xdr.o - $(CC) -o $@ rls.o dir_clnt.o dir_xdr.o $(LIB) - -rls.o: rls.c dir.h - -dir_proc.o: dir_proc.c dir.h - -clean cleanup: - rm -f $(GEN) *.o $(BIN) - diff --git a/lib/librpc/demo/dir/dir.x b/lib/librpc/demo/dir/dir.x deleted file mode 100644 index db4283cbfe00..000000000000 --- a/lib/librpc/demo/dir/dir.x +++ /dev/null @@ -1,37 +0,0 @@ -/* @(#)dir.x 2.1 88/08/02 4.0 RPCSRC */ -/* - * dir.x: Remote directory listing protocol - */ -const MAXNAMELEN = 255; /* maximum length of a directory entry */ - -typedef string nametype; /* a directory entry */ - -typedef struct namenode *namelist; /* a link in the listing */ - -/* - * A node in the directory listing - */ -struct namenode { - nametype name; /* name of directory entry */ - namelist next; /* next entry */ -}; - -/* - * The result of a READDIR operation. - */ -union readdir_res switch (int errno) { -case 0: - namelist list; /* no error: return directory listing */ -default: - void; /* error occurred: nothing else to return */ -}; - -/* - * The directory program definition - */ -program DIRPROG { - version DIRVERS { - readdir_res - READDIR(nametype) = 1; - } = 1; -} = 76; diff --git a/lib/librpc/demo/dir/dir_proc.c b/lib/librpc/demo/dir/dir_proc.c deleted file mode 100644 index 9f7522a92715..000000000000 --- a/lib/librpc/demo/dir/dir_proc.c +++ /dev/null @@ -1,55 +0,0 @@ -/* @(#)dir_proc.c 2.1 88/08/02 4.0 RPCSRC */ -/* - * dir_proc.c: remote readdir implementation - */ -#include -#include -#include "dir.h" - -extern int errno; -extern char *malloc(); -extern char *strcpy(); - -readdir_res * -readdir_1(dirname) - nametype *dirname; -{ - DIR *dirp; - struct direct *d; - namelist nl; - namelist *nlp; - static readdir_res res; /* must be static! */ - - /* - * Open directory - */ - dirp = opendir(*dirname); - if (dirp == NULL) { - res.errno = errno; - return (&res); - } - - /* - * Free previous result - */ - xdr_free(xdr_readdir_res, &res); - - /* - * Collect directory entries - */ - nlp = &res.readdir_res_u.list; - while (d = readdir(dirp)) { - nl = *nlp = (namenode *) malloc(sizeof(namenode)); - nl->name = malloc(strlen(d->d_name)+1); - strcpy(nl->name, d->d_name); - nlp = &nl->next; - } - *nlp = NULL; - - /* - * Return the result - */ - res.errno = 0; - closedir(dirp); - return (&res); -} diff --git a/lib/librpc/demo/dir/rls.c b/lib/librpc/demo/dir/rls.c deleted file mode 100644 index 4f2d473674e4..000000000000 --- a/lib/librpc/demo/dir/rls.c +++ /dev/null @@ -1,81 +0,0 @@ -/* @(#)rls.c 2.2 88/08/12 4.0 RPCSRC */ -/* - * rls.c: Remote directory listing client - */ -#include -#include /* always need this */ -#include "dir.h" /* need this too: will be generated by rpcgen*/ - -extern int errno; - -main(argc, argv) - int argc; - char *argv[]; -{ - CLIENT *cl; - char *server; - char *dir; - readdir_res *result; - namelist nl; - - - if (argc != 3) { - fprintf(stderr, "usage: %s host directory\n", argv[0]); - exit(1); - } - - /* - * Remember what our command line arguments refer to - */ - server = argv[1]; - dir = argv[2]; - - /* - * Create client "handle" used for calling DIRPROG on the - * server designated on the command line. We tell the rpc package - * to use the "tcp" protocol when contacting the server. - */ - cl = clnt_create(server, DIRPROG, DIRVERS, "tcp"); - if (cl == NULL) { - /* - * Couldn't establish connection with server. - * Print error message and die. - */ - clnt_pcreateerror(server); - exit(1); - } - - /* - * Call the remote procedure "readdir" on the server - */ - result = readdir_1(&dir, cl); - if (result == NULL) { - /* - * An error occurred while calling the server. - * Print error message and die. - */ - clnt_perror(cl, server); - exit(1); - } - - /* - * Okay, we successfully called the remote procedure. - */ - if (result->errno != 0) { - /* - * A remote system error occurred. - * Print error message and die. - */ - errno = result->errno; - perror(dir); - exit(1); - } - - /* - * Successfuly got a directory listing. - * Print it out. - */ - for (nl = result->readdir_res_u.list; nl != NULL; nl = nl->next) { - printf("%s\n", nl->name); - } -} diff --git a/lib/librpc/demo/msg/Makefile b/lib/librpc/demo/msg/Makefile deleted file mode 100644 index 2f3f5ddf1655..000000000000 --- a/lib/librpc/demo/msg/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC -# -BIN = printmsg msg_svc rprintmsg -GEN = msg_clnt.c msg_svc.c msg.h -LIB = -lrpclib -RPCCOM = rpcgen - -all: $(BIN) - -# -# This is the non-networked version of the program -# -printmsg: printmsg.o - $(CC) -o $@ printmsg.o - -# -# note: no xdr routines are generated here, due this service's -# use of basic data types. -# -$(GEN): msg.x - $(RPCCOM) msg.x - -msg_svc: msg_proc.o msg_svc.o - $(CC) -o $@ msg_proc.o msg_svc.o $(LIB) - -rprintmsg: rprintmsg.o msg_clnt.o - $(CC) -o $@ rprintmsg.o msg_clnt.o $(LIB) - -rprintmsg.o: rprintmsg.c msg.h - -msg_proc.o: msg_proc.c msg.h - -clean cleanup: - rm -f $(GEN) *.o $(BIN) - diff --git a/lib/librpc/demo/msg/msg.x b/lib/librpc/demo/msg/msg.x deleted file mode 100644 index d3113520d822..000000000000 --- a/lib/librpc/demo/msg/msg.x +++ /dev/null @@ -1,9 +0,0 @@ -/* @(#)msg.x 2.1 88/08/11 4.0 RPCSRC */ -/* - * msg.x: Remote message printing protocol - */ -program MESSAGEPROG { - version MESSAGEVERS { - int PRINTMESSAGE(string) = 1; - } = 1; -} = 99; diff --git a/lib/librpc/demo/msg/msg_proc.c b/lib/librpc/demo/msg/msg_proc.c deleted file mode 100644 index 80e5d959aa7f..000000000000 --- a/lib/librpc/demo/msg/msg_proc.c +++ /dev/null @@ -1,28 +0,0 @@ -/* @(#)msg_proc.c 2.1 88/08/11 4.0 RPCSRC */ -/* - * msg_proc.c: implementation of the remote procedure "printmessage" - */ -#include -#include /* always need this here */ -#include "msg.h" /* need this too: msg.h will be generated by rpcgen */ - -/* - * Remote verson of "printmessage" - */ -int * -printmessage_1(msg) - char **msg; -{ - static int result; /* must be static! */ - FILE *f; - - f = fopen("/dev/console", "w"); - if (f == NULL) { - result = 0; - return (&result); - } - fprintf(f, "%s\n", *msg); - fclose(f); - result = 1; - return (&result); -} diff --git a/lib/librpc/demo/msg/printmsg.c b/lib/librpc/demo/msg/printmsg.c deleted file mode 100644 index dde55dd86709..000000000000 --- a/lib/librpc/demo/msg/printmsg.c +++ /dev/null @@ -1,43 +0,0 @@ -/* @(#)printmsg.c 2.1 88/08/11 4.0 RPCSRC */ -/* - * printmsg.c: print a message on the console - */ -#include - -main(argc, argv) - int argc; - char *argv[]; -{ - char *message; - - if (argc < 2) { - fprintf(stderr, "usage: %s \n", argv[0]); - exit(1); - } - message = argv[1]; - - if (!printmessage(message)) { - fprintf(stderr, "%s: sorry, couldn't print your message\n", - argv[0]); - exit(1); - } - printf("Message delivered!\n"); -} - -/* - * Print a message to the console. - * Return a boolean indicating whether the message was actually printed. - */ -printmessage(msg) - char *msg; -{ - FILE *f; - - f = fopen("/dev/console", "w"); - if (f == NULL) { - return (0); - } - fprintf(f, "%s\n", msg); - fclose(f); - return(1); -} diff --git a/lib/librpc/demo/msg/rprintmsg.c b/lib/librpc/demo/msg/rprintmsg.c deleted file mode 100644 index b9cb1e361706..000000000000 --- a/lib/librpc/demo/msg/rprintmsg.c +++ /dev/null @@ -1,74 +0,0 @@ -/* @(#)rprintmsg.c 2.1 88/08/11 4.0 RPCSRC */ -/* - * rprintmsg.c: remote version of "printmsg.c" - */ -#include -#include /* always need this */ -#include "msg.h" /* need this too: will be generated by rpcgen*/ - -main(argc, argv) - int argc; - char *argv[]; -{ - CLIENT *cl; - int *result; - char *server; - char *message; - - if (argc < 3) { - fprintf(stderr, "usage: %s host message\n", argv[0]); - exit(1); - } - - /* - * Remember what our command line arguments refer to - */ - server = argv[1]; - message = argv[2]; - - /* - * Create client "handle" used for calling MESSAGEPROG on the - * server designated on the command line. We tell the rpc package - * to use the "tcp" protocol when contacting the server. - */ - cl = clnt_create(server, MESSAGEPROG, MESSAGEVERS, "tcp"); - if (cl == NULL) { - /* - * Couldn't establish connection with server. - * Print error message and die. - */ - clnt_pcreateerror(server); - exit(1); - } - - /* - * Call the remote procedure "printmessage" on the server - */ - result = printmessage_1(&message, cl); - if (result == NULL) { - /* - * An error occurred while calling the server. - * Print error message and die. - */ - clnt_perror(cl, server); - exit(1); - } - - /* - * Okay, we successfully called the remote procedure. - */ - if (*result == 0) { - /* - * Server was unable to print our message. - * Print error message and die. - */ - fprintf(stderr, "%s: sorry, %s couldn't print your message\n", - argv[0], server); - exit(1); - } - - /* - * The message got printed on the server's console - */ - printf("Message delivered to %s!\n", server); -} diff --git a/lib/librpc/demo/sort/Makefile b/lib/librpc/demo/sort/Makefile deleted file mode 100644 index 07627fafbe39..000000000000 --- a/lib/librpc/demo/sort/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC -# - -BIN = rsort sort_svc -GEN = sort_clnt.c sort_svc.c sort_xdr.c sort.h -LIB = -lrpclib -RPCCOM = rpcgen - -all: $(BIN) - -rsort: rsort.o sort_clnt.o sort_xdr.o - $(CC) $(LDFLAGS) -o $@ rsort.o sort_clnt.o sort_xdr.o $(LIB) - -rsort.o: rsort.c sort.h - -sort_clnt.c: - $(RPCCOM) -l sort.x >$@ - -sort_svc: sort_proc.o sort_svc.o sort_xdr.o - $(CC) $(LDFLAGS) -o $@ sort_proc.o sort_svc.o sort_xdr.o $(LIB) - -sort_proc.o: sort_proc.c sort.h - -sort_svc.c: - $(RPCCOM) -s udp sort.x >$@ - -sort_xdr.c: - $(RPCCOM) -c sort.x >$@ - -sort.h: - $(RPCCOM) -h sort.x >$@ - -clean cleanup: - rm -f $(GEN) *.o $(BIN) - diff --git a/lib/librpc/demo/sort/rsort.c b/lib/librpc/demo/sort/rsort.c deleted file mode 100644 index 5c05ad7f42cc..000000000000 --- a/lib/librpc/demo/sort/rsort.c +++ /dev/null @@ -1,43 +0,0 @@ -/* @(#)rsort.c 2.1 88/08/11 4.0 RPCSRC */ -/* - * rsort.c - * Client side application which sorts argc, argv. - */ -#include -#include -#include "sort.h" - -main(argc, argv) - int argc; - char **argv; -{ - char *machinename; - struct sortstrings args, res; - int i; - - if (argc < 3) { - fprintf(stderr, "usage: %s machinename [s1 ...]\n", argv[0]); - exit(1); - } - machinename = argv[1]; - args.ss.ss_len = argc - 2; /* substract off progname, machinename */ - args.ss.ss_val = &argv[2]; - res.ss.ss_val = (char **)NULL; - - if ((i = callrpc(machinename, SORTPROG, SORTVERS, SORT, - xdr_sortstrings, &args, xdr_sortstrings, &res))) - { - fprintf(stderr, "%s: call to sort service failed. ", argv[0]); - clnt_perrno(i); - fprintf(stderr, "\n"); - exit(1); - } - - for (i = 0; i < res.ss.ss_len; i++) { - printf("%s\n", res.ss.ss_val[i]); - } - - /* should free res here */ - exit(0); -} - diff --git a/lib/librpc/demo/sort/sort.x b/lib/librpc/demo/sort/sort.x deleted file mode 100644 index 629110cdf33a..000000000000 --- a/lib/librpc/demo/sort/sort.x +++ /dev/null @@ -1,19 +0,0 @@ -/* @(#)sort.x 2.1 88/08/11 4.0 RPCSRC */ -/* - * The sort procedure receives an array of strings and returns an array - * of strings. This toy service handles a maximum of 64 strings. - */ -const MAXSORTSIZE = 64; -const MAXSTRINGLEN = 64; - -typedef string str; /* the string itself */ - -struct sortstrings { - str ss; -}; - -program SORTPROG { - version SORTVERS { - sortstrings SORT(sortstrings) = 1; - } = 1; -} = 22855; diff --git a/lib/librpc/demo/sort/sort_proc.c b/lib/librpc/demo/sort/sort_proc.c deleted file mode 100644 index 5538faf7ea03..000000000000 --- a/lib/librpc/demo/sort/sort_proc.c +++ /dev/null @@ -1,27 +0,0 @@ -/* @(#)sort_proc.c 2.1 88/08/11 4.0 RPCSRC */ -#include -#include "sort.h" - -static int -comparestrings(sp1, sp2) - char **sp1, **sp2; -{ - return (strcmp(*sp1, *sp2)); -} - -struct sortstrings * -sort_1(ssp) - struct sortstrings *ssp; -{ - static struct sortstrings ss_res; - - if (ss_res.ss.ss_val != (str *)NULL) - free(ss_res.ss.ss_val); - - qsort(ssp->ss.ss_val, ssp->ss.ss_len, sizeof (char *), comparestrings); - ss_res.ss.ss_len = ssp->ss.ss_len; - ss_res.ss.ss_val = (str *)malloc(ssp->ss.ss_len * sizeof(str *)); - bcopy(ssp->ss.ss_val, ss_res.ss.ss_val, - ssp->ss.ss_len * sizeof(str *)); - return(&ss_res); -} diff --git a/lib/librpc/doc/Makefile b/lib/librpc/doc/Makefile deleted file mode 100644 index db819a097bb2..000000000000 --- a/lib/librpc/doc/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/04 4.0 RPCSRC -# -# -# The targets all.nroff and all.troff will make monolithic documents -# with nroff and troff, respectively. The other *.nroff and *.troff -# targets will make individual documents -# -TROFF= ditroff -TOPTS= -t -NROFF= nroff -NOPTS= -PIC= pic -TBL= tbl -EQN= eqn - -SRC= rpc.prog.ms rpcgen.ms xdr.nts.ms xdr.rfc.ms rpc.rfc.ms nfs.rfc.ms - -all default: all.nroff - -install: all.nroff - @echo "Nothing installed." - -all.nroff: ${SRC} - ${TBL} ${SRC} | ${EQN} | ${NROFF} ${NOPTS} -ms >all.nroff - -all.troff: ${SRC} - ${TBL} ${SRC} | ${PIC} | ${EQN} | ${TROFF} ${TOPTS} -ms >all.troff - -# - -rpc.prog.nroff: rpc.prog.ms - ${TBL} rpc.prog.ms | ${NROFF} ${NOPTS} -ms >rpc.prog.nroff - -rpc.prog.troff: rpc.prog.ms - ${TBL} rpc.prog.ms | ${PIC} | ${TROFF} ${TOPTS} -ms >rpc.prog.troff - -# - -rpcgen.troff: rpcgen.ms - ${TBL} rpcgen.ms | ${TROFF} ${TOPTS} -ms >rpcgen.troff - -rpcgen.nroff: rpcgen.ms - ${TBL} rpcgen.ms | ${NROFF} ${NOPTS} -ms >rpcgen.nroff - -# - -xdr.nts.troff: xdr.nts.ms - ${TBL} xdr.nts.ms | ${EQN} | ${TROFF} ${TOPTS} -ms >xdr.nts.troff - -xdr.nts.nroff: xdr.nts.ms - ${TBL} xdr.nts.ms | ${EQN} | ${NROFF} ${NOPTS} -ms >xdr.nts.nroff - -# - -xdr.rfc.troff: xdr.rfc.ms - ${TBL} xdr.rfc.ms | ${TROFF} ${TOPTS} -ms >xdr.rfc.troff - -xdr.rfc.nroff: xdr.rfc.ms - ${TBL} xdr.rfc.ms | ${NROFF} ${NOPTS} -ms >xdr.rfc.nroff - -# - -rpc.rfc.troff: rpc.rfc.ms - ${TBL} rpc.rfc.ms | ${TROFF} ${TOPTS} -ms >rpc.rfc.troff - -rpc.rfc.nroff: rpc.rfc.ms - ${TBL} rpc.rfc.ms | ${NROFF} ${NOPTS} -ms >rpc.rfc.nroff - -# - -nfs.rfc.troff: nfs.rfc.ms - ${TBL} nfs.rfc.ms | ${TROFF} ${TOPTS} -ms >nfs.rfc.troff - -nfs.rfc.nroff: nfs.rfc.ms - ${TBL} nfs.rfc.ms | ${NROFF} ${NOPTS} -ms >nfs.rfc.nroff - -clean: - rm -f *.nroff *.troff - -spell: ${SRC} - @for i in ${SRC}; do \ - echo $$i; spell $$i | sort | comm -23 - spell.ok > $$i.spell; \ - done diff --git a/lib/librpc/doc/nfs.rfc.ms b/lib/librpc/doc/nfs.rfc.ms deleted file mode 100644 index 0c9a8995b5c7..000000000000 --- a/lib/librpc/doc/nfs.rfc.ms +++ /dev/null @@ -1,1372 +0,0 @@ -.\" -.\" Must use -- tbl -- with this one -.\" -.\" @(#)nfs.rfc.ms 2.2 88/08/05 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'Network File System: Version 2 Protocol Specification''Page %' -.EH 'Page %''Network File System: Version 2 Protocol Specification' -.if \\n%=1 .bp -.SH -\&Network File System: Version 2 Protocol Specification -.IX NFS "" "" "" PAGE MAJOR -.IX "Network File System" "" "" "" PAGE MAJOR -.IX NFS "version-2 protocol specification" -.IX "Network File System" "version-2 protocol specification" -.LP -.NH 0 -\&Status of this Standard -.LP -Note: This document specifies a protocol that Sun Microsystems, Inc., -and others are using. It specifies it in standard ARPA RFC form. -.NH 1 -\&Introduction -.IX NFS introduction -.LP -The Sun Network Filesystem (NFS) protocol provides transparent remote -access to shared filesystems over local area networks. The NFS -protocol is designed to be machine, operating system, network architecture, -and transport protocol independent. This independence is -achieved through the use of Remote Procedure Call (RPC) primitives -built on top of an External Data Representation (XDR). Implementations -exist for a variety of machines, from personal computers to -supercomputers. -.LP -The supporting mount protocol allows the server to hand out remote -access privileges to a restricted set of clients. It performs the -operating system-specific functions that allow, for example, to -attach remote directory trees to some local file system. -.NH 2 -\&Remote Procedure Call -.IX "Remote Procedure Call" -.LP -Sun's remote procedure call specification provides a procedure- -oriented interface to remote services. Each server supplies a -program that is a set of procedures. NFS is one such "program". -The combination of host address, program number, and procedure -number specifies one remote service procedure. RPC does not depend -on services provided by specific protocols, so it can be used with -any underlying transport protocol. See the -.I "Remote Procedure Calls: Protocol Specification" -chapter of this manual. -.NH 2 -\&External Data Representation -.IX "External Data Representation" -.LP -The External Data Representation (XDR) standard provides a common -way of representing a set of data types over a network. -The NFS -Protocol Specification is written using the RPC data description -language. -For more information, see the -.I " External Data Representation Standard: Protocol Specification." -Sun provides implementations of XDR and -RPC, but NFS does not require their use. Any software that -provides equivalent functionality can be used, and if the encoding -is exactly the same it can interoperate with other implementations -of NFS. -.NH 2 -\&Stateless Servers -.IX "stateless servers" -.IX servers stateless -.LP -The NFS protocol is stateless. That is, a server does not need to -maintain any extra state information about any of its clients in -order to function correctly. Stateless servers have a distinct -advantage over stateful servers in the event of a failure. With -stateless servers, a client need only retry a request until the -server responds; it does not even need to know that the server has -crashed, or the network temporarily went down. The client of a -stateful server, on the other hand, needs to either detect a server -crash and rebuild the server's state when it comes back up, or -cause client operations to fail. -.LP -This may not sound like an important issue, but it affects the -protocol in some unexpected ways. We feel that it is worth a bit -of extra complexity in the protocol to be able to write very simple -servers that do not require fancy crash recovery. -.LP -On the other hand, NFS deals with objects such as files and -directories that inherently have state -- what good would a file be -if it did not keep its contents intact? The goal is to not -introduce any extra state in the protocol itself. Another way to -simplify recovery is by making operations "idempotent" whenever -possible (so that they can potentially be repeated). -.NH 1 -\&NFS Protocol Definition -.IX NFS "protocol definition" -.IX NFS protocol -.LP -Servers have been known to change over time, and so can the -protocol that they use. So RPC provides a version number with each -RPC request. This RFC describes version two of the NFS protocol. -Even in the second version, there are various obsolete procedures -and parameters, which will be removed in later versions. An RFC -for version three of the NFS protocol is currently under -preparation. -.NH 2 -\&File System Model -.IX filesystem model -.LP -NFS assumes a file system that is hierarchical, with directories as -all but the bottom-level files. Each entry in a directory (file, -directory, device, etc.) has a string name. Different operating -systems may have restrictions on the depth of the tree or the names -used, as well as using different syntax to represent the "pathname", -which is the concatenation of all the "components" (directory and -file names) in the name. A "file system" is a tree on a single -server (usually a single disk or physical partition) with a specified -"root". Some operating systems provide a "mount" operation to make -all file systems appear as a single tree, while others maintain a -"forest" of file systems. Files are unstructured streams of -uninterpreted bytes. Version 3 of NFS uses a slightly more general -file system model. -.LP -NFS looks up one component of a pathname at a time. It may not be -obvious why it does not just take the whole pathname, traipse down -the directories, and return a file handle when it is done. There are -several good reasons not to do this. First, pathnames need -separators between the directory components, and different operating -systems use different separators. We could define a Network Standard -Pathname Representation, but then every pathname would have to be -parsed and converted at each end. Other issues are discussed in -\fINFS Implementation Issues\fP below. -.LP -Although files and directories are similar objects in many ways, -different procedures are used to read directories and files. This -provides a network standard format for representing directories. The -same argument as above could have been used to justify a procedure -that returns only one directory entry per call. The problem is -efficiency. Directories can contain many entries, and a remote call -to return each would be just too slow. -.NH 2 -\&RPC Information -.IX NFS "RPC information" -.IP \fIAuthentication\fP -The NFS service uses -.I AUTH_UNIX , -.I AUTH_DES , -or -.I AUTH_SHORT -style -authentication, except in the NULL procedure where -.I AUTH_NONE -is also allowed. -.IP "\fITransport Protocols\fP" -NFS currently is supported on UDP/IP only. -.IP "\fIPort Number\fP" -The NFS protocol currently uses the UDP port number 2049. This is -not an officially assigned port, so later versions of the protocol -use the \*QPortmapping\*U facility of RPC. -.NH 2 -\&Sizes of XDR Structures -.IX "XDR structure sizes" -.LP -These are the sizes, given in decimal bytes, of various XDR -structures used in the protocol: -.DS -/* \fIThe maximum number of bytes of data in a READ or WRITE request\fP */ -const MAXDATA = 8192; - -/* \fIThe maximum number of bytes in a pathname argument\fP */ -const MAXPATHLEN = 1024; - -/* \fIThe maximum number of bytes in a file name argument\fP */ -const MAXNAMLEN = 255; - -/* \fIThe size in bytes of the opaque "cookie" passed by READDIR\fP */ -const COOKIESIZE = 4; - -/* \fIThe size in bytes of the opaque file handle\fP */ -const FHSIZE = 32; -.DE -.NH 2 -\&Basic Data Types -.IX "NFS data types" -.IX NFS "basic data types" -.LP -The following XDR definitions are basic structures and types used -in other structures described further on. -.KS -.NH 3 -\&stat -.IX "NFS data types" stat "" \fIstat\fP -.DS -enum stat { - NFS_OK = 0, - NFSERR_PERM=1, - NFSERR_NOENT=2, - NFSERR_IO=5, - NFSERR_NXIO=6, - NFSERR_ACCES=13, - NFSERR_EXIST=17, - NFSERR_NODEV=19, - NFSERR_NOTDIR=20, - NFSERR_ISDIR=21, - NFSERR_FBIG=27, - NFSERR_NOSPC=28, - NFSERR_ROFS=30, - NFSERR_NAMETOOLONG=63, - NFSERR_NOTEMPTY=66, - NFSERR_DQUOT=69, - NFSERR_STALE=70, - NFSERR_WFLUSH=99 -}; -.DE -.KE -.LP -The -.I stat -type is returned with every procedure's results. A -value of -.I NFS_OK -indicates that the call completed successfully and -the results are valid. The other values indicate some kind of -error occurred on the server side during the servicing of the -procedure. The error values are derived from UNIX error numbers. -.IP \fBNFSERR_PERM\fP: -Not owner. The caller does not have correct ownership -to perform the requested operation. -.IP \fBNFSERR_NOENT\fP: -No such file or directory. The file or directory -specified does not exist. -.IP \fBNFSERR_IO\fP: -Some sort of hard error occurred when the operation was -in progress. This could be a disk error, for example. -.IP \fBNFSERR_NXIO\fP: -No such device or address. -.IP \fBNFSERR_ACCES\fP: -Permission denied. The caller does not have the -correct permission to perform the requested operation. -.IP \fBNFSERR_EXIST\fP: -File exists. The file specified already exists. -.IP \fBNFSERR_NODEV\fP: -No such device. -.IP \fBNFSERR_NOTDIR\fP: -Not a directory. The caller specified a -non-directory in a directory operation. -.IP \fBNFSERR_ISDIR\fP: -Is a directory. The caller specified a directory in -a non- directory operation. -.IP \fBNFSERR_FBIG\fP: -File too large. The operation caused a file to grow -beyond the server's limit. -.IP \fBNFSERR_NOSPC\fP: -No space left on device. The operation caused the -server's filesystem to reach its limit. -.IP \fBNFSERR_ROFS\fP: -Read-only filesystem. Write attempted on a read-only filesystem. -.IP \fBNFSERR_NAMETOOLONG\fP: -File name too long. The file name in an operation was too long. -.IP \fBNFSERR_NOTEMPTY\fP: -Directory not empty. Attempted to remove a -directory that was not empty. -.IP \fBNFSERR_DQUOT\fP: -Disk quota exceeded. The client's disk quota on the -server has been exceeded. -.IP \fBNFSERR_STALE\fP: -The "fhandle" given in the arguments was invalid. -That is, the file referred to by that file handle no longer exists, -or access to it has been revoked. -.IP \fBNFSERR_WFLUSH\fP: -The server's write cache used in the -.I WRITECACHE -call got flushed to disk. -.LP -.KS -.NH 3 -\&ftype -.IX "NFS data types" ftype "" \fIftype\fP -.DS -enum ftype { - NFNON = 0, - NFREG = 1, - NFDIR = 2, - NFBLK = 3, - NFCHR = 4, - NFLNK = 5 -}; -.DE -.KE -The enumeration -.I ftype -gives the type of a file. The type -.I NFNON -indicates a non-file, -.I NFREG -is a regular file, -.I NFDIR -is a directory, -.I NFBLK -is a block-special device, -.I NFCHR -is a character-special device, and -.I NFLNK -is a symbolic link. -.KS -.NH 3 -\&fhandle -.IX "NFS data types" fhandle "" \fIfhandle\fP -.DS -typedef opaque fhandle[FHSIZE]; -.DE -.KE -The -.I fhandle -is the file handle passed between the server and the client. -All file operations are done using file handles to refer to a file or -directory. The file handle can contain whatever information the server -needs to distinguish an individual file. -.KS -.NH 3 -\&timeval -.IX "NFS data types" timeval "" \fItimeval\fP -.DS -struct timeval { - unsigned int seconds; - unsigned int useconds; -}; -.DE -.KE -The -.I timeval -structure is the number of seconds and microseconds -since midnight January 1, 1970, Greenwich Mean Time. It is used to -pass time and date information. -.KS -.NH 3 -\&fattr -.IX "NFS data types" fattr "" \fIfattr\fP -.DS -struct fattr { - ftype type; - unsigned int mode; - unsigned int nlink; - unsigned int uid; - unsigned int gid; - unsigned int size; - unsigned int blocksize; - unsigned int rdev; - unsigned int blocks; - unsigned int fsid; - unsigned int fileid; - timeval atime; - timeval mtime; - timeval ctime; -}; -.DE -.KE -The -.I fattr -structure contains the attributes of a file; "type" is the type of -the file; "nlink" is the number of hard links to the file (the number -of different names for the same file); "uid" is the user -identification number of the owner of the file; "gid" is the group -identification number of the group of the file; "size" is the size in -bytes of the file; "blocksize" is the size in bytes of a block of the -file; "rdev" is the device number of the file if it is type -.I NFCHR -or -.I NFBLK ; -"blocks" is the number of blocks the file takes up on disk; "fsid" is -the file system identifier for the filesystem containing the file; -"fileid" is a number that uniquely identifies the file within its -filesystem; "atime" is the time when the file was last accessed for -either read or write; "mtime" is the time when the file data was last -modified (written); and "ctime" is the time when the status of the -file was last changed. Writing to the file also changes "ctime" if -the size of the file changes. -.LP -"mode" is the access mode encoded as a set of bits. Notice that the -file type is specified both in the mode bits and in the file type. -This is really a bug in the protocol and will be fixed in future -versions. The descriptions given below specify the bit positions -using octal numbers. -.TS -box tab (&) ; -cfI cfI -lfL l . -Bit&Description -_ -0040000&This is a directory; "type" field should be NFDIR. -0020000&This is a character special file; "type" field should be NFCHR. -0060000&This is a block special file; "type" field should be NFBLK. -0100000&This is a regular file; "type" field should be NFREG. -0120000&This is a symbolic link file; "type" field should be NFLNK. -0140000&This is a named socket; "type" field should be NFNON. -0004000&Set user id on execution. -0002000&Set group id on execution. -0001000&Save swapped text even after use. -0000400&Read permission for owner. -0000200&Write permission for owner. -0000100&Execute and search permission for owner. -0000040&Read permission for group. -0000020&Write permission for group. -0000010&Execute and search permission for group. -0000004&Read permission for others. -0000002&Write permission for others. -0000001&Execute and search permission for others. -.TE -.KS -Notes: -.IP -The bits are the same as the mode bits returned by the -.I stat(2) -system call in the UNIX system. The file type is specified both in -the mode bits and in the file type. This is fixed in future -versions. -.IP -The "rdev" field in the attributes structure is an operating system -specific device specifier. It will be removed and generalized in -the next revision of the protocol. -.KE -.LP -.KS -.NH 3 -\&sattr -.IX "NFS data types" sattr "" \fIsattr\fP -.DS -struct sattr { - unsigned int mode; - unsigned int uid; - unsigned int gid; - unsigned int size; - timeval atime; - timeval mtime; -}; -.DE -.KE -The -.I sattr -structure contains the file attributes which can be set -from the client. The fields are the same as for -.I fattr -above. A "size" of zero means the file should be truncated. -A value of -1 indicates a field that should be ignored. -.LP -.KS -.NH 3 -\&filename -.IX "NFS data types" filename "" \fIfilename\fP -.DS -typedef string filename; -.DE -.KE -The type -.I filename -is used for passing file names or pathname components. -.LP -.KS -.NH 3 -\&path -.IX "NFS data types" path "" \fIpath\fP -.DS -typedef string path; -.DE -.KE -The type -.I path -is a pathname. The server considers it as a string -with no internal structure, but to the client it is the name of a -node in a filesystem tree. -.LP -.KS -.NH 3 -\&attrstat -.IX "NFS data types" attrstat "" \fIattrstat\fP -.DS -union attrstat switch (stat status) { - case NFS_OK: - fattr attributes; - default: - void; -}; -.DE -.KE -The -.I attrstat -structure is a common procedure result. It contains -a "status" and, if the call succeeded, it also contains the -attributes of the file on which the operation was done. -.LP -.KS -.NH 3 -\&diropargs -.IX "NFS data types" diropargs "" \fIdiropargs\fP -.DS -struct diropargs { - fhandle dir; - filename name; -}; -.DE -.KE -The -.I diropargs -structure is used in directory operations. The -"fhandle" "dir" is the directory in which to find the file "name". -A directory operation is one in which the directory is affected. -.LP -.KS -.NH 3 -\&diropres -.IX "NFS data types" diropres "" \fIdiropres\fP -.DS -union diropres switch (stat status) { - case NFS_OK: - struct { - fhandle file; - fattr attributes; - } diropok; - default: - void; -}; -.DE -.KE -The results of a directory operation are returned in a -.I diropres -structure. If the call succeeded, a new file handle "file" and the -"attributes" associated with that file are returned along with the -"status". -.NH 2 -\&Server Procedures -.IX "NFS server procedures" "" "" "" PAGE MAJOR -.LP -The protocol definition is given as a set of procedures with -arguments and results defined using the RPC language. A brief -description of the function of each procedure should provide enough -information to allow implementation. -.LP -All of the procedures in the NFS protocol are assumed to be -synchronous. When a procedure returns to the client, the client -can assume that the operation has completed and any data associated -with the request is now on stable storage. For example, a client -.I WRITE -request may cause the server to update data blocks, -filesystem information blocks (such as indirect blocks), and file -attribute information (size and modify times). When the -.I WRITE -returns to the client, it can assume that the write is safe, even -in case of a server crash, and it can discard the data written. -This is a very important part of the statelessness of the server. -If the server waited to flush data from remote requests, the client -would have to save those requests so that it could resend them in -case of a server crash. -.ie t .DS -.el .DS L - -.ft I -/* -* Remote file service routines -*/ -.ft CW -program NFS_PROGRAM { - version NFS_VERSION { - void NFSPROC_NULL(void) = 0; - attrstat NFSPROC_GETATTR(fhandle) = 1; - attrstat NFSPROC_SETATTR(sattrargs) = 2; - void NFSPROC_ROOT(void) = 3; - diropres NFSPROC_LOOKUP(diropargs) = 4; - readlinkres NFSPROC_READLINK(fhandle) = 5; - readres NFSPROC_READ(readargs) = 6; - void NFSPROC_WRITECACHE(void) = 7; - attrstat NFSPROC_WRITE(writeargs) = 8; - diropres NFSPROC_CREATE(createargs) = 9; - stat NFSPROC_REMOVE(diropargs) = 10; - stat NFSPROC_RENAME(renameargs) = 11; - stat NFSPROC_LINK(linkargs) = 12; - stat NFSPROC_SYMLINK(symlinkargs) = 13; - diropres NFSPROC_MKDIR(createargs) = 14; - stat NFSPROC_RMDIR(diropargs) = 15; - readdirres NFSPROC_READDIR(readdirargs) = 16; - statfsres NFSPROC_STATFS(fhandle) = 17; - } = 2; -} = 100003; -.DE -.KS -.NH 3 -\&Do Nothing -.IX "NFS server procedures" NFSPROC_NULL() "" \fINFSPROC_NULL()\fP -.DS -void -NFSPROC_NULL(void) = 0; -.DE -.KE -This procedure does no work. It is made available in all RPC -services to allow server response testing and timing. -.KS -.NH 3 -\&Get File Attributes -.IX "NFS server procedures" NFSPROC_GETATTR() "" \fINFSPROC_GETATTR()\fP -.DS -attrstat -NFSPROC_GETATTR (fhandle) = 1; -.DE -.KE -If the reply status is -.I NFS_OK , -then the reply attributes contains -the attributes for the file given by the input fhandle. -.KS -.NH 3 -\&Set File Attributes -.IX "NFS server procedures" NFSPROC_SETATTR() "" \fINFSPROC_SETATTR()\fP -.DS -struct sattrargs { - fhandle file; - sattr attributes; - }; - -attrstat -NFSPROC_SETATTR (sattrargs) = 2; -.DE -.KE -The "attributes" argument contains fields which are either -1 or -are the new value for the attributes of "file". If the reply -status is -.I NFS_OK , -then the reply attributes have the attributes of -the file after the "SETATTR" operation has completed. -.LP -Note: The use of -1 to indicate an unused field in "attributes" is -changed in the next version of the protocol. -.KS -.NH 3 -\&Get Filesystem Root -.IX "NFS server procedures" NFSPROC_ROOT "" \fINFSPROC_ROOT\fP -.DS -void -NFSPROC_ROOT(void) = 3; -.DE -.KE -Obsolete. This procedure is no longer used because finding the -root file handle of a filesystem requires moving pathnames between -client and server. To do this right we would have to define a -network standard representation of pathnames. Instead, the -function of looking up the root file handle is done by the -.I MNTPROC_MNT() -procedure. (See the -.I "Mount Protocol Definition" -later in this chapter for details). -.KS -.NH 3 -\&Look Up File Name -.IX "NFS server procedures" NFSPROC_LOOKUP() "" \fINFSPROC_LOOKUP()\fP -.DS -diropres -NFSPROC_LOOKUP(diropargs) = 4; -.DE -.KE -If the reply "status" is -.I NFS_OK , -then the reply "file" and reply -"attributes" are the file handle and attributes for the file "name" -in the directory given by "dir" in the argument. -.KS -.NH 3 -\&Read From Symbolic Link -.IX "NFS server procedures" NFSPROC_READLINK() "" \fINFSPROC_READLINK()\fP -.DS -union readlinkres switch (stat status) { - case NFS_OK: - path data; - default: - void; -}; - -readlinkres -NFSPROC_READLINK(fhandle) = 5; -.DE -.KE -If "status" has the value -.I NFS_OK , -then the reply "data" is the data in -the symbolic link given by the file referred to by the fhandle argument. -.LP -Note: since NFS always parses pathnames on the client, the -pathname in a symbolic link may mean something different (or be -meaningless) on a different client or on the server if a different -pathname syntax is used. -.KS -.NH 3 -\&Read From File -.IX "NFS server procedures" NFSPROC_READ "" \fINFSPROC_READ\fP -.DS -struct readargs { - fhandle file; - unsigned offset; - unsigned count; - unsigned totalcount; -}; - -union readres switch (stat status) { - case NFS_OK: - fattr attributes; - opaque data; - default: - void; -}; - -readres -NFSPROC_READ(readargs) = 6; -.DE -.KE -Returns up to "count" bytes of "data" from the file given by -"file", starting at "offset" bytes from the beginning of the file. -The first byte of the file is at offset zero. The file attributes -after the read takes place are returned in "attributes". -.LP -Note: The argument "totalcount" is unused, and is removed in the -next protocol revision. -.KS -.NH 3 -\&Write to Cache -.IX "NFS server procedures" NFSPROC_WRITECACHE() "" \fINFSPROC_WRITECACHE()\fP -.DS -void -NFSPROC_WRITECACHE(void) = 7; -.DE -.KE -To be used in the next protocol revision. -.KS -.NH 3 -\&Write to File -.IX "NFS server procedures" NFSPROC_WRITE() "" \fINFSPROC_WRITE()\fP -.DS -struct writeargs { - fhandle file; - unsigned beginoffset; - unsigned offset; - unsigned totalcount; - opaque data; -}; - -attrstat -NFSPROC_WRITE(writeargs) = 8; -.DE -.KE -Writes "data" beginning "offset" bytes from the beginning of -"file". The first byte of the file is at offset zero. If the -reply "status" is NFS_OK, then the reply "attributes" contains the -attributes of the file after the write has completed. The write -operation is atomic. Data from this call to -.I WRITE -will not be mixed with data from another client's calls. -.LP -Note: The arguments "beginoffset" and "totalcount" are ignored and -are removed in the next protocol revision. -.KS -.NH 3 -\&Create File -.IX "NFS server procedures" NFSPROC_CREATE() "" \fINFSPROC_CREATE()\fP -.DS -struct createargs { - diropargs where; - sattr attributes; -}; - -diropres -NFSPROC_CREATE(createargs) = 9; -.DE -.KE -The file "name" is created in the directory given by "dir". The -initial attributes of the new file are given by "attributes". A -reply "status" of NFS_OK indicates that the file was created, and -reply "file" and reply "attributes" are its file handle and -attributes. Any other reply "status" means that the operation -failed and no file was created. -.LP -Note: This routine should pass an exclusive create flag, meaning -"create the file only if it is not already there". -.KS -.NH 3 -\&Remove File -.IX "NFS server procedures" NFSPROC_REMOVE() "" \fINFSPROC_REMOVE()\fP -.DS -stat -NFSPROC_REMOVE(diropargs) = 10; -.DE -.KE -The file "name" is removed from the directory given by "dir". A -reply of NFS_OK means the directory entry was removed. -.LP -Note: possibly non-idempotent operation. -.KS -.NH 3 -\&Rename File -.IX "NFS server procedures" NFSPROC_RENAME() "" \fINFSPROC_RENAME()\fP -.DS -struct renameargs { - diropargs from; - diropargs to; -}; - -stat -NFSPROC_RENAME(renameargs) = 11; -.DE -.KE -The existing file "from.name" in the directory given by "from.dir" -is renamed to "to.name" in the directory given by "to.dir". If the -reply is -.I NFS_OK , -the file was renamed. The -RENAME -operation is -atomic on the server; it cannot be interrupted in the middle. -.LP -Note: possibly non-idempotent operation. -.KS -.NH 3 -\&Create Link to File -.IX "NFS server procedures" NFSPROC_LINK() "" \fINFSPROC_LINK()\fP -.DS -struct linkargs { - fhandle from; - diropargs to; -}; - -stat -NFSPROC_LINK(linkargs) = 12; -.DE -.KE -Creates the file "to.name" in the directory given by "to.dir", -which is a hard link to the existing file given by "from". If the -return value is -.I NFS_OK , -a link was created. Any other return value -indicates an error, and the link was not created. -.LP -A hard link should have the property that changes to either of the -linked files are reflected in both files. When a hard link is made -to a file, the attributes for the file should have a value for -"nlink" that is one greater than the value before the link. -.LP -Note: possibly non-idempotent operation. -.KS -.NH 3 -\&Create Symbolic Link -.IX "NFS server procedures" NFSPROC_SYMLINK() "" \fINFSPROC_SYMLINK()\fP -.DS -struct symlinkargs { - diropargs from; - path to; - sattr attributes; -}; - -stat -NFSPROC_SYMLINK(symlinkargs) = 13; -.DE -.KE -Creates the file "from.name" with ftype -.I NFLNK -in the directory -given by "from.dir". The new file contains the pathname "to" and -has initial attributes given by "attributes". If the return value -is -.I NFS_OK , -a link was created. Any other return value indicates an -error, and the link was not created. -.LP -A symbolic link is a pointer to another file. The name given in -"to" is not interpreted by the server, only stored in the newly -created file. When the client references a file that is a symbolic -link, the contents of the symbolic link are normally transparently -reinterpreted as a pathname to substitute. A -.I READLINK -operation returns the data to the client for interpretation. -.LP -Note: On UNIX servers the attributes are never used, since -symbolic links always have mode 0777. -.KS -.NH 3 -\&Create Directory -.IX "NFS server procedures" NFSPROC_MKDIR() "" \fINFSPROC_MKDIR()\fP -.DS -diropres -NFSPROC_MKDIR (createargs) = 14; -.DE -.KE -The new directory "where.name" is created in the directory given by -"where.dir". The initial attributes of the new directory are given -by "attributes". A reply "status" of NFS_OK indicates that the new -directory was created, and reply "file" and reply "attributes" are -its file handle and attributes. Any other reply "status" means -that the operation failed and no directory was created. -.LP -Note: possibly non-idempotent operation. -.KS -.NH 3 -\&Remove Directory -.IX "NFS server procedures" NFSPROC_RMDIR() "" \fINFSPROC_RMDIR()\fP -.DS -stat -NFSPROC_RMDIR(diropargs) = 15; -.DE -.KE -The existing empty directory "name" in the directory given by "dir" -is removed. If the reply is -.I NFS_OK , -the directory was removed. -.LP -Note: possibly non-idempotent operation. -.KS -.NH 3 -\&Read From Directory -.IX "NFS server procedures" NFSPROC_READDIR() "" \fINFSPROC_READDIR()\fP -.DS -struct readdirargs { - fhandle dir; - nfscookie cookie; - unsigned count; -}; - -struct entry { - unsigned fileid; - filename name; - nfscookie cookie; - entry *nextentry; -}; - -union readdirres switch (stat status) { - case NFS_OK: - struct { - entry *entries; - bool eof; - } readdirok; - default: - void; -}; - -readdirres -NFSPROC_READDIR (readdirargs) = 16; -.DE -.KE -Returns a variable number of directory entries, with a total size -of up to "count" bytes, from the directory given by "dir". If the -returned value of "status" is -.I NFS_OK , -then it is followed by a -variable number of "entry"s. Each "entry" contains a "fileid" -which consists of a unique number to identify the file within a -filesystem, the "name" of the file, and a "cookie" which is an -opaque pointer to the next entry in the directory. The cookie is -used in the next -.I READDIR -call to get more entries starting at a -given point in the directory. The special cookie zero (all bits -zero) can be used to get the entries starting at the beginning of -the directory. The "fileid" field should be the same number as the -"fileid" in the the attributes of the file. (See the -.I "Basic Data Types" -section.) -The "eof" flag has a value of -.I TRUE -if there are no more entries in the directory. -.KS -.NH 3 -\&Get Filesystem Attributes -.IX "NFS server procedures" NFSPROC_STATFS() "" \fINFSPROC_STATFS()\fP -.DS -union statfsres (stat status) { - case NFS_OK: - struct { - unsigned tsize; - unsigned bsize; - unsigned blocks; - unsigned bfree; - unsigned bavail; - } info; - default: - void; -}; - -statfsres -NFSPROC_STATFS(fhandle) = 17; -.DE -.KE -If the reply "status" is -.I NFS_OK , -then the reply "info" gives the -attributes for the filesystem that contains file referred to by the -input fhandle. The attribute fields contain the following values: -.IP tsize: -The optimum transfer size of the server in bytes. This is -the number of bytes the server would like to have in the -data part of READ and WRITE requests. -.IP bsize: -The block size in bytes of the filesystem. -.IP blocks: -The total number of "bsize" blocks on the filesystem. -.IP bfree: -The number of free "bsize" blocks on the filesystem. -.IP bavail: -The number of "bsize" blocks available to non-privileged users. -.LP -Note: This call does not work well if a filesystem has variable -size blocks. -.NH 1 -\&NFS Implementation Issues -.IX NFS implementation -.LP -The NFS protocol is designed to be operating system independent, but -since this version was designed in a UNIX environment, many -operations have semantics similar to the operations of the UNIX file -system. This section discusses some of the implementation-specific -semantic issues. -.NH 2 -\&Server/Client Relationship -.IX NFS "server/client relationship" -.LP -The NFS protocol is designed to allow servers to be as simple and -general as possible. Sometimes the simplicity of the server can be a -problem, if the client wants to implement complicated filesystem -semantics. -.LP -For example, some operating systems allow removal of open files. A -process can open a file and, while it is open, remove it from the -directory. The file can be read and written as long as the process -keeps it open, even though the file has no name in the filesystem. -It is impossible for a stateless server to implement these semantics. -The client can do some tricks such as renaming the file on remove, -and only removing it on close. We believe that the server provides -enough functionality to implement most file system semantics on the -client. -.LP -Every NFS client can also potentially be a server, and remote and -local mounted filesystems can be freely intermixed. This leads to -some interesting problems when a client travels down the directory -tree of a remote filesystem and reaches the mount point on the server -for another remote filesystem. Allowing the server to follow the -second remote mount would require loop detection, server lookup, and -user revalidation. Instead, we decided not to let clients cross a -server's mount point. When a client does a LOOKUP on a directory on -which the server has mounted a filesystem, the client sees the -underlying directory instead of the mounted directory. A client can -do remote mounts that match the server's mount points to maintain the -server's view. -.LP -.NH 2 -\&Pathname Interpretation -.IX NFS "pathname interpretation" -.LP -There are a few complications to the rule that pathnames are always -parsed on the client. For example, symbolic links could have -different interpretations on different clients. Another common -problem for non-UNIX implementations is the special interpretation of -the pathname ".." to mean the parent of a given directory. The next -revision of the protocol uses an explicit flag to indicate the parent -instead. -.NH 2 -\&Permission Issues -.IX NFS "permission issues" -.LP -The NFS protocol, strictly speaking, does not define the permission -checking used by servers. However, it is expected that a server -will do normal operating system permission checking using -.I AUTH_UNIX -style authentication as the basis of its protection mechanism. The -server gets the client's effective "uid", effective "gid", and groups -on each call and uses them to check permission. There are various -problems with this method that can been resolved in interesting ways. -.LP -Using "uid" and "gid" implies that the client and server share the -same "uid" list. Every server and client pair must have the same -mapping from user to "uid" and from group to "gid". Since every -client can also be a server, this tends to imply that the whole -network shares the same "uid/gid" space. -.I AUTH_DES -(and the next -revision of the NFS protocol) uses string names instead of numbers, -but there are still complex problems to be solved. -.LP -Another problem arises due to the usually stateful open operation. -Most operating systems check permission at open time, and then check -that the file is open on each read and write request. With stateless -servers, the server has no idea that the file is open and must do -permission checking on each read and write call. On a local -filesystem, a user can open a file and then change the permissions so -that no one is allowed to touch it, but will still be able to write -to the file because it is open. On a remote filesystem, by contrast, -the write would fail. To get around this problem, the server's -permission checking algorithm should allow the owner of a file to -access it regardless of the permission setting. -.LP -A similar problem has to do with paging in from a file over the -network. The operating system usually checks for execute permission -before opening a file for demand paging, and then reads blocks from -the open file. The file may not have read permission, but after it -is opened it doesn't matter. An NFS server can not tell the -difference between a normal file read and a demand page-in read. To -make this work, the server allows reading of files if the "uid" given -in the call has execute or read permission on the file. -.LP -In most operating systems, a particular user (on the user ID zero) -has access to all files no matter what permission and ownership they -have. This "super-user" permission may not be allowed on the server, -since anyone who can become super-user on their workstation could -gain access to all remote files. The UNIX server by default maps -user id 0 to -2 before doing its access checking. This works except -for NFS root filesystems, where super-user access cannot be avoided. -.NH 2 -\&Setting RPC Parameters -.IX NFS "setting RPC parameters" -.LP -Various file system parameters and options should be set at mount -time. The mount protocol is described in the appendix below. For -example, "Soft" mounts as well as "Hard" mounts are usually both -provided. Soft mounted file systems return errors when RPC -operations fail (after a given number of optional retransmissions), -while hard mounted file systems continue to retransmit forever. -Clients and servers may need to keep caches of recent operations to -help avoid problems with non-idempotent operations. -.NH 1 -\&Mount Protocol Definition -.IX "mount protocol" "" "" "" PAGE MAJOR -.sp 1 -.NH 2 -\&Introduction -.IX "mount protocol" introduction -.LP -The mount protocol is separate from, but related to, the NFS -protocol. It provides operating system specific services to get the -NFS off the ground -- looking up server path names, validating user -identity, and checking access permissions. Clients use the mount -protocol to get the first file handle, which allows them entry into a -remote filesystem. -.LP -The mount protocol is kept separate from the NFS protocol to make it -easy to plug in new access checking and validation methods without -changing the NFS server protocol. -.LP -Notice that the protocol definition implies stateful servers because -the server maintains a list of client's mount requests. The mount -list information is not critical for the correct functioning of -either the client or the server. It is intended for advisory use -only, for example, to warn possible clients when a server is going -down. -.LP -Version one of the mount protocol is used with version two of the NFS -protocol. The only connecting point is the -.I fhandle -structure, which is the same for both protocols. -.NH 2 -\&RPC Information -.IX "mount protocol" "RPC information" -.IP \fIAuthentication\fP -The mount service uses -.I AUTH_UNIX -and -.I AUTH_DES -style authentication only. -.IP "\fITransport Protocols\fP" -The mount service is currently supported on UDP/IP only. -.IP "\fIPort Number\fP" -Consult the server's portmapper, described in the chapter -.I "Remote Procedure Calls: Protocol Specification", -to find the port number on which the mount service is registered. -.NH 2 -\&Sizes of XDR Structures -.IX "mount protocol" "XDR structure sizes" -.LP -These are the sizes, given in decimal bytes, of various XDR -structures used in the protocol: -.DS -/* \fIThe maximum number of bytes in a pathname argument\fP */ -const MNTPATHLEN = 1024; - -/* \fIThe maximum number of bytes in a name argument\fP */ -const MNTNAMLEN = 255; - -/* \fIThe size in bytes of the opaque file handle\fP */ -const FHSIZE = 32; -.DE -.NH 2 -\&Basic Data Types -.IX "mount protocol" "basic data types" -.IX "mount data types" -.LP -This section presents the data types used by the mount protocol. -In many cases they are similar to the types used in NFS. -.KS -.NH 3 -\&fhandle -.IX "mount data types" fhandle "" \fIfhandle\fP -.DS -typedef opaque fhandle[FHSIZE]; -.DE -.KE -The type -.I fhandle -is the file handle that the server passes to the -client. All file operations are done using file handles to refer -to a file or directory. The file handle can contain whatever -information the server needs to distinguish an individual file. -.LP -This is the same as the "fhandle" XDR definition in version 2 of -the NFS protocol; see -.I "Basic Data Types" -in the definition of the NFS protocol, above. -.KS -.NH 3 -\&fhstatus -.IX "mount data types" fhstatus "" \fIfhstatus\fP -.DS -union fhstatus switch (unsigned status) { - case 0: - fhandle directory; - default: - void; -}; -.DE -.KE -The type -.I fhstatus -is a union. If a "status" of zero is returned, -the call completed successfully, and a file handle for the -"directory" follows. A non-zero status indicates some sort of -error. In this case the status is a UNIX error number. -.KS -.NH 3 -\&dirpath -.IX "mount data types" dirpath "" \fIdirpath\fP -.DS -typedef string dirpath; -.DE -.KE -The type -.I dirpath -is a server pathname of a directory. -.KS -.NH 3 -\&name -.IX "mount data types" name "" \fIname\fP -.DS -typedef string name; -.DE -.KE -The type -.I name -is an arbitrary string used for various names. -.NH 2 -\&Server Procedures -.IX "mount server procedures" -.LP -The following sections define the RPC procedures supplied by a -mount server. -.ie t .DS -.el .DS L -.ft I -/* -* Protocol description for the mount program -*/ -.ft CW - -program MOUNTPROG { -.ft I -/* -* Version 1 of the mount protocol used with -* version 2 of the NFS protocol. -*/ -.ft CW - version MOUNTVERS { - void MOUNTPROC_NULL(void) = 0; - fhstatus MOUNTPROC_MNT(dirpath) = 1; - mountlist MOUNTPROC_DUMP(void) = 2; - void MOUNTPROC_UMNT(dirpath) = 3; - void MOUNTPROC_UMNTALL(void) = 4; - exportlist MOUNTPROC_EXPORT(void) = 5; - } = 1; -} = 100005; -.DE -.KS -.NH 3 -\&Do Nothing -.IX "mount server procedures" MNTPROC_NULL() "" \fIMNTPROC_NULL()\fP -.DS -void -MNTPROC_NULL(void) = 0; -.DE -.KE -This procedure does no work. It is made available in all RPC -services to allow server response testing and timing. -.KS -.NH 3 -\&Add Mount Entry -.IX "mount server procedures" MNTPROC_MNT() "" \fIMNTPROC_MNT()\fP -.DS -fhstatus -MNTPROC_MNT(dirpath) = 1; -.DE -.KE -If the reply "status" is 0, then the reply "directory" contains the -file handle for the directory "dirname". This file handle may be -used in the NFS protocol. This procedure also adds a new entry to -the mount list for this client mounting "dirname". -.KS -.NH 3 -\&Return Mount Entries -.IX "mount server procedures" MNTPROC_DUMP() "" \fIMNTPROC_DUMP()\fP -.DS -struct *mountlist { - name hostname; - dirpath directory; - mountlist nextentry; -}; - -mountlist -MNTPROC_DUMP(void) = 2; -.DE -.KE -Returns the list of remote mounted filesystems. The "mountlist" -contains one entry for each "hostname" and "directory" pair. -.KS -.NH 3 -\&Remove Mount Entry -.IX "mount server procedures" MNTPROC_UMNT() "" \fIMNTPROC_UMNT()\fP -.DS -void -MNTPROC_UMNT(dirpath) = 3; -.DE -.KE -Removes the mount list entry for the input "dirpath". -.KS -.NH 3 -\&Remove All Mount Entries -.IX "mount server procedures" MNTPROC_UMNTALL() "" \fIMNTPROC_UMNTALL()\fP -.DS -void -MNTPROC_UMNTALL(void) = 4; -.DE -.KE -Removes all of the mount list entries for this client. -.KS -.NH 3 -\&Return Export List -.IX "mount server procedures" MNTPROC_EXPORT() "" \fIMNTPROC_EXPORT()\fP -.DS -struct *groups { - name grname; - groups grnext; -}; - -struct *exportlist { - dirpath filesys; - groups groups; - exportlist next; -}; - -exportlist -MNTPROC_EXPORT(void) = 5; -.DE -.KE -Returns a variable number of export list entries. Each entry -contains a filesystem name and a list of groups that are allowed to -import it. The filesystem name is in "filesys", and the group name -is in the list "groups". -.LP -Note: The exportlist should contain -more information about the status of the filesystem, such as a -read-only flag. diff --git a/lib/librpc/doc/rpc.prog.ms b/lib/librpc/doc/rpc.prog.ms deleted file mode 100644 index 3b02447fe84a..000000000000 --- a/lib/librpc/doc/rpc.prog.ms +++ /dev/null @@ -1,2684 +0,0 @@ -.\" -.\" Must use -- tbl and pic -- with this one -.\" -.\" @(#)rpc.prog.ms 2.3 88/08/11 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.IX "Network Programming" "" "" "" PAGE MAJOR -.nr OF 0 -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'Remote Procedure Call Programming Guide''Page %' -.EH 'Page %''Remote Procedure Call Programming Guide' -.SH -\&Remote Procedure Call Programming Guide -.nr OF 1 -.IX "RPC Programming Guide" -.LP -This document assumes a working knowledge of network theory. It is -intended for programmers who wish to write network applications using -remote procedure calls (explained below), and who want to understand -the RPC mechanisms usually hidden by the -.I rpcgen(1) -protocol compiler. -.I rpcgen -is described in detail in the previous chapter, the -.I "\fBrpcgen\fP \fIProgramming Guide\fP". -.SH -Note: -.I -.IX rpcgen "" \fIrpcgen\fP -Before attempting to write a network application, or to convert an -existing non-network application to run over the network, you may want to -understand the material in this chapter. However, for most applications, -you can circumvent the need to cope with the details presented here by using -.I rpcgen . -The -.I "Generating XDR Routines" -section of that chapter contains the complete source for a working RPC -service\(ema remote directory listing service which uses -.I rpcgen -to generate XDR routines as well as client and server stubs. -.LP -.LP -What are remote procedure calls? Simply put, they are the high-level -communications paradigm used in the operating system. -RPC presumes the existence of -low-level networking mechanisms (such as TCP/IP and UDP/IP), and upon them -it implements a logical client to server communications system designed -specifically for the support of network applications. With RPC, the client -makes a procedure call to send a data packet to the server. When the -packet arrives, the server calls a dispatch routine, performs whatever -service is requested, sends back the reply, and the procedure call returns -to the client. -.NH 0 -\&Layers of RPC -.IX "layers of RPC" -.IX "RPC" "layers" -.LP -The RPC interface can be seen as being divided into three layers.\** -.FS -For a complete specification of the routines in the remote procedure -call Library, see the -.I rpc(3N) -manual page. -.FE -.LP -.I "The Highest Layer:" -.IX RPC "The Highest Layer" -The highest layer is totally transparent to the operating system, -machine and network upon which is is run. It's probably best to -think of this level as a way of -.I using -RPC, rather than as -a \fIpart of\fP RPC proper. Programmers who write RPC routines -should (almost) always make this layer available to others by way -of a simple C front end that entirely hides the networking. -.LP -To illustrate, at this level a program can simply make a call to -.I rnusers (), -a C routine which returns the number of users on a remote machine. -The user is not explicitly aware of using RPC \(em they simply -call a procedure, just as they would call -.I malloc() . -.LP -.I "The Middle Layer:" -.IX RPC "The Middle Layer" -The middle layer is really \*QRPC proper.\*U Here, the user doesn't -need to consider details about sockets, the UNIX system, or other low-level -implementation mechanisms. They simply make remote procedure calls -to routines on other machines. The selling point here is simplicity. -It's this layer that allows RPC to pass the \*Qhello world\*U test \(em -simple things should be simple. The middle-layer routines are used -for most applications. -.LP -RPC calls are made with the system routines -.I registerrpc() -.I callrpc() -and -.I svc_run (). -The first two of these are the most fundamental: -.I registerrpc() -obtains a unique system-wide procedure-identification number, and -.I callrpc() -actually executes a remote procedure call. At the middle level, a -call to -.I rnusers() -is implemented by way of these two routines. -.LP -The middle layer is unfortunately rarely used in serious programming -due to its inflexibility (simplicity). It does not allow timeout -specifications or the choice of transport. It allows no UNIX -process control or flexibility in case of errors. It doesn't support -multiple kinds of call authentication. The programmer rarely needs -all these kinds of control, but one or two of them is often necessary. -.LP -.I "The Lowest Layer:" -.IX RPC "The Lowest Layer" -The lowest layer does allow these details to be controlled by the -programmer, and for that reason it is often necessary. Programs -written at this level are also most efficient, but this is rarely a -real issue \(em since RPC clients and servers rarely generate -heavy network loads. -.LP -Although this document only discusses the interface to C, -remote procedure calls can be made from any language. -Even though this document discusses RPC -when it is used to communicate -between processes on different machines, -it works just as well for communication -between different processes on the same machine. -.br -.KS -.NH 2 -\&The RPC Paradigm -.IX RPC paradigm -.LP -Here is a diagram of the RPC paradigm: -.LP -\fBFigure 1-1\fI Network Communication with the Remote Reocedure Call\fR -.LP -.PS -L1: arrow down 1i "client " rjust "program " rjust -L2: line right 1.5i "\fIcallrpc\fP" "function" -move up 1.5i; line dotted down 6i; move up 4.5i -arrow right 1i -L3: arrow down 1i "invoke " rjust "service " rjust -L4: arrow right 1.5i "call" "service" -L5: arrow down 1i " service" ljust " executes" ljust -L6: arrow left 1.5i "\fIreturn\fP" "answer" -L7: arrow down 1i "request " rjust "completed " rjust -L8: line left 1i -arrow left 1.5i "\fIreturn\fP" "reply" -L9: arrow down 1i "program " rjust "continues " rjust -line dashed down from L2 to L9 -line dashed down from L4 to L7 -line dashed up 1i from L3 "service " rjust "daemon " rjust -arrow dashed down 1i from L8 -move right 1i from L3 -box invis "Machine B" -move left 1.2i from L2; move down -box invis "Machine A" -.PE -.KE -.KS -.NH 1 -\&Higher Layers of RPC -.NH 2 -\&Highest Layer -.IX "highest layer of RPC" -.IX RPC "highest layer" -.LP -Imagine you're writing a program that needs to know -how many users are logged into a remote machine. -You can do this by calling the RPC library routine -.I rnusers() -as illustrated below: -.ie t .DS -.el .DS L -.ft CW -#include - -main(argc, argv) - int argc; - char **argv; -{ - int num; - - if (argc != 2) { - fprintf(stderr, "usage: rnusers hostname\en"); - exit(1); - } - if ((num = rnusers(argv[1])) < 0) { - fprintf(stderr, "error: rnusers\en"); - exit(-1); - } - printf("%d users on %s\en", num, argv[1]); - exit(0); -} -.DE -.KE -RPC library routines such as -.I rnusers() -are in the RPC services library -.I librpcsvc.a -Thus, the program above should be compiled with -.DS -.ft CW -% cc \fIprogram.c -lrpcsvc\fP -.DE -.I rnusers (), -like the other RPC library routines, is documented in section 3R -of the -.I "System Interface Manual for the Sun Workstation" , -the same section which documents the standard Sun RPC services. -.IX "RPC Services" -See the -.I intro(3R) -manual page for an explanation of the documentation strategy -for these services and their RPC protocols. -.LP -Here are some of the RPC service library routines available to the -C programmer: -.LP -\fBTable 3-3\fI RPC Service Library Routines\RP -.TS -box tab (&) ; -cfI cfI -lfL l . -Routine&Description -_ -.sp.5 -rnusers&Return number of users on remote machine -rusers&Return information about users on remote machine -havedisk&Determine if remote machine has disk -rstats&Get performance data from remote kernel -rwall&Write to specified remote machines -yppasswd&Update user password in Yellow Pages -.TE -.LP -Other RPC services \(em for example -.I ether() -.I mount -.I rquota() -and -.I spray -\(em are not available to the C programmer as library routines. -They do, however, -have RPC program numbers so they can be invoked with -.I callrpc() -which will be discussed in the next section. Most of them also -have compilable -.I rpcgen(1) -protocol description files. (The -.I rpcgen -protocol compiler radically simplifies the process of developing -network applications. -See the \fBrpcgen\fI Programming Guide\fR -for detailed information about -.I rpcgen -and -.I rpcgen -protocol description files). -.KS -.NH 2 -\&Intermediate Layer -.IX "intermediate layer of RPC" -.IX "RPC" "intermediate layer" -.LP -The simplest interface, which explicitly makes RPC calls, uses the -functions -.I callrpc() -and -.I registerrpc() -Using this method, the number of remote users can be gotten as follows: -.ie t .DS -.el .DS L -#include -#include -#include -#include - -main(argc, argv) - int argc; - char **argv; -{ - unsigned long nusers; - int stat; - - if (argc != 2) { - fprintf(stderr, "usage: nusers hostname\en"); - exit(-1); - } - if (stat = callrpc(argv[1], - RUSERSPROG, RUSERSVERS, RUSERSPROC_NUM, - xdr_void, 0, xdr_u_long, &nusers) != 0) { - clnt_perrno(stat); - exit(1); - } - printf("%d users on %s\en", nusers, argv[1]); - exit(0); -} -.DE -.KE -Each RPC procedure is uniquely defined by a program number, -version number, and procedure number. The program number -specifies a group of related remote procedures, each of -which has a different procedure number. Each program also -has a version number, so when a minor change is made to a -remote service (adding a new procedure, for example), a new -program number doesn't have to be assigned. When you want -to call a procedure to find the number of remote users, you -look up the appropriate program, version and procedure numbers -in a manual, just as you look up the name of a memory allocator -when you want to allocate memory. -.LP -The simplest way of making remote procedure calls is with the the RPC -library routine -.I callrpc() -It has eight parameters. The first is the name of the remote server -machine. The next three parameters are the program, version, and procedure -numbers\(emtogether they identify the procedure to be called. -The fifth and sixth parameters are an XDR filter and an argument to -be encoded and passed to the remote procedure. -The final two parameters are a filter for decoding the results -returned by the remote procedure and a pointer to the place where -the procedure's results are to be stored. Multiple arguments and -results are handled by embedding them in structures. If -.I callrpc() -completes successfully, it returns zero; else it returns a nonzero -value. The return codes (of type -.IX "enum clnt_stat (in RPC programming)" "" "\fIenum clnt_stat\fP (in RPC programming)" -cast into an integer) are found in -.I . -.LP -Since data types may be represented differently on different machines, -.I callrpc() -needs both the type of the RPC argument, as well as -a pointer to the argument itself (and similarly for the result). For -.I RUSERSPROC_NUM , -the return value is an -.I "unsigned long" -so -.I callrpc() -has -.I xdr_u_long() -as its first return parameter, which says -that the result is of type -.I "unsigned long" -and -.I &nusers -as its second return parameter, -which is a pointer to where the long result will be placed. Since -.I RUSERSPROC_NUM -takes no argument, the argument parameter of -.I callrpc() -is -.I xdr_void (). -.LP -After trying several times to deliver a message, if -.I callrpc() -gets no answer, it returns with an error code. -The delivery mechanism is UDP, -which stands for User Datagram Protocol. -Methods for adjusting the number of retries -or for using a different protocol require you to use the lower -layer of the RPC library, discussed later in this document. -The remote server procedure -corresponding to the above might look like this: -.ie t .DS -.el .DS L -.ft CW -.ft CW -char * -nuser(indata) - char *indata; -{ - unsigned long nusers; - -.ft I - /* - * Code here to compute the number of users - * and place result in variable \fInusers\fP. - */ -.ft CW - return((char *)&nusers); -} -.DE -.LP -It takes one argument, which is a pointer to the input -of the remote procedure call (ignored in our example), -and it returns a pointer to the result. -In the current version of C, -character pointers are the generic pointers, -so both the input argument and the return value are cast to -.I "char *" . -.LP -Normally, a server registers all of the RPC calls it plans -to handle, and then goes into an infinite loop waiting to service requests. -In this example, there is only a single procedure -to register, so the main body of the server would look like this: -.ie t .DS -.el .DS L -.ft CW -#include -#include -#include -#include - -char *nuser(); - -main() -{ - registerrpc(RUSERSPROG, RUSERSVERS, RUSERSPROC_NUM, - nuser, xdr_void, xdr_u_long); - svc_run(); /* \fINever returns\fP */ - fprintf(stderr, "Error: svc_run returned!\en"); - exit(1); -} -.DE -.LP -The -.I registerrpc() -routine registers a C procedure as corresponding to a -given RPC procedure number. The first three parameters, -.I RUSERPROG , -.I RUSERSVERS , -and -.I RUSERSPROC_NUM -are the program, version, and procedure numbers -of the remote procedure to be registered; -.I nuser() -is the name of the local procedure that implements the remote -procedure; and -.I xdr_void() -and -.I xdr_u_long() -are the XDR filters for the remote procedure's arguments and -results, respectively. (Multiple arguments or multiple results -are passed as structures). -.LP -Only the UDP transport mechanism can use -.I registerrpc() -thus, it is always safe in conjunction with calls generated by -.I callrpc() . -.SH -.IX "UDP 8K warning" -Warning: the UDP transport mechanism can only deal with -arguments and results less than 8K bytes in length. -.LP -.LP -After registering the local procedure, the server program's -main procedure calls -.I svc_run (), -the RPC library's remote procedure dispatcher. It is this -function that calls the remote procedures in response to RPC -call messages. Note that the dispatcher takes care of decoding -remote procedure arguments and encoding results, using the XDR -filters specified when the remote procedure was registered. -.NH 2 -\&Assigning Program Numbers -.IX "program number assignment" -.IX "assigning program numbers" -.LP -Program numbers are assigned in groups of -.I 0x20000000 -according to the following chart: -.DS -.ft CW - 0x0 - 0x1fffffff \fRDefined by Sun\fP -0x20000000 - 0x3fffffff \fRDefined by user\fP -0x40000000 - 0x5fffffff \fRTransient\fP -0x60000000 - 0x7fffffff \fRReserved\fP -0x80000000 - 0x9fffffff \fRReserved\fP -0xa0000000 - 0xbfffffff \fRReserved\fP -0xc0000000 - 0xdfffffff \fRReserved\fP -0xe0000000 - 0xffffffff \fRReserved\fP -.ft R -.DE -Sun Microsystems administers the first group of numbers, which -should be identical for all Sun customers. If a customer -develops an application that might be of general interest, that -application should be given an assigned number in the first -range. The second group of numbers is reserved for specific -customer applications. This range is intended primarily for -debugging new programs. The third group is reserved for -applications that generate program numbers dynamically. The -final groups are reserved for future use, and should not be -used. -.LP -To register a protocol specification, send a request by network -mail to -.I rpc@sun -or write to: -.DS -RPC Administrator -Sun Microsystems -2550 Garcia Ave. -Mountain View, CA 94043 -.DE -Please include a compilable -.I rpcgen -\*Q.x\*U file describing your protocol. -You will be given a unique program number in return. -.IX RPC administration -.IX administration "of RPC" -.LP -The RPC program numbers and protocol specifications -of standard Sun RPC services can be -found in the include files in -.I "/usr/include/rpcsvc" . -These services, however, constitute only a small subset -of those which have been registered. The complete list of -registered programs, as of the time when this manual was -printed, is: -.LP -\fBTable 3-2\fI RPC Registered Programs\fR -.TS H -box tab (&) ; -lfBI lfBI lfBI -lfL lfL lfI . -RPC Number&Program&Description -_ -.TH -.sp.5 -100000&PMAPPROG&portmapper -100001&RSTATPROG&remote stats -100002&RUSERSPROG&remote users -100003&NFSPROG&nfs -100004&YPPROG&Yellow Pages -100005&MOUNTPROG&mount demon -100006&DBXPROG&remote dbx -100007&YPBINDPROG&yp binder -100008&WALLPROG&shutdown msg -100009&YPPASSWDPROG&yppasswd server -100010ÐERSTATPROGðer stats -100011&RQUOTAPROG&disk quotas -100012&SPRAYPROG&spray packets -100013&IBM3270PROG&3270 mapper -100014&IBMRJEPROG&RJE mapper -100015&SELNSVCPROG&selection service -100016&RDATABASEPROG&remote database access -100017&REXECPROG&remote execution -100018&ALICEPROG&Alice Office Automation -100019&SCHEDPROG&scheduling service -100020&LOCKPROG&local lock manager -100021&NETLOCKPROG&network lock manager -100022&X25PROG&x.25 inr protocol -100023&STATMON1PROG&status monitor 1 -100024&STATMON2PROG&status monitor 2 -100025&SELNLIBPROG&selection library -100026&BOOTPARAMPROG&boot parameters service -100027&MAZEPROG&mazewars game -100028&YPUPDATEPROG&yp update -100029&KEYSERVEPROG&key server -100030&SECURECMDPROG&secure login -100031&NETFWDIPROG&nfs net forwarder init -100032&NETFWDTPROG&nfs net forwarder trans -100033&SUNLINKMAP_PROG&sunlink MAP -100034&NETMONPROG&network monitor -100035&DBASEPROG&lightweight database -100036&PWDAUTHPROG&password authorization -100037&TFSPROG&translucent file svc -100038&NSEPROG&nse server -100039&NSE_ACTIVATE_PROG&nse activate daemon -.sp .2i -150001&PCNFSDPROG&pc passwd authorization -.sp .2i -200000&PYRAMIDLOCKINGPROG&Pyramid-locking -200001&PYRAMIDSYS5&Pyramid-sys5 -200002&CADDS_IMAGE&CV cadds_image -.sp .2i -300001&ADT_RFLOCKPROG&ADT file locking -.TE -.NH 2 -\&Passing Arbitrary Data Types -.IX "arbitrary data types" -.LP -In the previous example, the RPC call passes a single -.I "unsigned long" -RPC can handle arbitrary data structures, regardless of -different machines' byte orders or structure layout conventions, -by always converting them to a network standard called -.I "External Data Representation" -(XDR) before -sending them over the wire. -The process of converting from a particular machine representation -to XDR format is called -.I serializing , -and the reverse process is called -.I deserializing . -The type field parameters of -.I callrpc() -and -.I registerrpc() -can be a built-in procedure like -.I xdr_u_long() -in the previous example, or a user supplied one. -XDR has these built-in type routines: -.IX RPC "built-in routines" -.DS -.ft CW -xdr_int() xdr_u_int() xdr_enum() -xdr_long() xdr_u_long() xdr_bool() -xdr_short() xdr_u_short() xdr_wrapstring() -xdr_char() xdr_u_char() -.DE -Note that the routine -.I xdr_string() -exists, but cannot be used with -.I callrpc() -and -.I registerrpc (), -which only pass two parameters to their XDR routines. -.I xdr_wrapstring() -has only two parameters, and is thus OK. It calls -.I xdr_string (). -.LP -As an example of a user-defined type routine, -if you wanted to send the structure -.DS -.ft CW -struct simple { - int a; - short b; -} simple; -.DE -then you would call -.I callrpc() -as -.DS -.ft CW -callrpc(hostname, PROGNUM, VERSNUM, PROCNUM, - xdr_simple, &simple ...); -.DE -where -.I xdr_simple() -is written as: -.ie t .DS -.el .DS L -.ft CW -#include - -xdr_simple(xdrsp, simplep) - XDR *xdrsp; - struct simple *simplep; -{ - if (!xdr_int(xdrsp, &simplep->a)) - return (0); - if (!xdr_short(xdrsp, &simplep->b)) - return (0); - return (1); -} -.DE -.LP -An XDR routine returns nonzero (true in the sense of C) if it -completes successfully, and zero otherwise. -A complete description of XDR is in the -.I "XDR Protocol Specification" -section of this manual, only few implementation examples are -given here. -.LP -In addition to the built-in primitives, -there are also the prefabricated building blocks: -.DS -.ft CW -xdr_array() xdr_bytes() xdr_reference() -xdr_vector() xdr_union() xdr_pointer() -xdr_string() xdr_opaque() -.DE -To send a variable array of integers, -you might package them up as a structure like this -.DS -.ft CW -struct varintarr { - int *data; - int arrlnth; -} arr; -.DE -and make an RPC call such as -.DS -.ft CW -callrpc(hostname, PROGNUM, VERSNUM, PROCNUM, - xdr_varintarr, &arr...); -.DE -with -.I xdr_varintarr() -defined as: -.ie t .DS -.el .DS L -.ft CW -xdr_varintarr(xdrsp, arrp) - XDR *xdrsp; - struct varintarr *arrp; -{ - return (xdr_array(xdrsp, &arrp->data, &arrp->arrlnth, - MAXLEN, sizeof(int), xdr_int)); -} -.DE -This routine takes as parameters the XDR handle, -a pointer to the array, a pointer to the size of the array, -the maximum allowable array size, -the size of each array element, -and an XDR routine for handling each array element. -.KS -.LP -If the size of the array is known in advance, one can use -.I xdr_vector (), -which serializes fixed-length arrays. -.ie t .DS -.el .DS L -.ft CW -int intarr[SIZE]; - -xdr_intarr(xdrsp, intarr) - XDR *xdrsp; - int intarr[]; -{ - int i; - - return (xdr_vector(xdrsp, intarr, SIZE, sizeof(int), - xdr_int)); -} -.DE -.KE -.LP -XDR always converts quantities to 4-byte multiples when serializing. -Thus, if either of the examples above involved characters -instead of integers, each character would occupy 32 bits. -That is the reason for the XDR routine -.I xdr_bytes() -which is like -.I xdr_array() -except that it packs characters; -.I xdr_bytes() -has four parameters, similar to the first four parameters of -.I xdr_array (). -For null-terminated strings, there is also the -.I xdr_string() -routine, which is the same as -.I xdr_bytes() -without the length parameter. -On serializing it gets the string length from -.I strlen (), -and on deserializing it creates a null-terminated string. -.LP -Here is a final example that calls the previously written -.I xdr_simple() -as well as the built-in functions -.I xdr_string() -and -.I xdr_reference (), -which chases pointers: -.ie t .DS -.el .DS L -.ft CW -struct finalexample { - char *string; - struct simple *simplep; -} finalexample; - -xdr_finalexample(xdrsp, finalp) - XDR *xdrsp; - struct finalexample *finalp; -{ - - if (!xdr_string(xdrsp, &finalp->string, MAXSTRLEN)) - return (0); - if (!xdr_reference(xdrsp, &finalp->simplep, - sizeof(struct simple), xdr_simple); - return (0); - return (1); -} -.DE -Note that we could as easily call -.I xdr_simple() -here instead of -.I xdr_reference (). -.NH 1 -\&Lowest Layer of RPC -.IX "lowest layer of RPC" -.IX "RPC" "lowest layer" -.LP -In the examples given so far, -RPC takes care of many details automatically for you. -In this section, we'll show you how you can change the defaults -by using lower layers of the RPC library. -It is assumed that you are familiar with sockets -and the system calls for dealing with them. -.LP -There are several occasions when you may need to use lower layers of -RPC. First, you may need to use TCP, since the higher layer uses UDP, -which restricts RPC calls to 8K bytes of data. Using TCP permits calls -to send long streams of data. -For an example, see the -.I TCP -section below. Second, you may want to allocate and free memory -while serializing or deserializing with XDR routines. -There is no call at the higher level to let -you free memory explicitly. -For more explanation, see the -.I "Memory Allocation with XDR" -section below. -Third, you may need to perform authentication -on either the client or server side, by supplying -credentials or verifying them. -See the explanation in the -.I Authentication -section below. -.NH 2 -\&More on the Server Side -.IX RPC "server side" -.LP -The server for the -.I nusers() -program shown below does the same thing as the one using -.I registerrpc() -above, but is written using a lower layer of the RPC package: -.ie t .DS -.el .DS L -.ft CW -#include -#include -#include -#include - -main() -{ - SVCXPRT *transp; - int nuser(); - - transp = svcudp_create(RPC_ANYSOCK); - if (transp == NULL){ - fprintf(stderr, "can't create an RPC server\en"); - exit(1); - } - pmap_unset(RUSERSPROG, RUSERSVERS); - if (!svc_register(transp, RUSERSPROG, RUSERSVERS, - nuser, IPPROTO_UDP)) { - fprintf(stderr, "can't register RUSER service\en"); - exit(1); - } - svc_run(); /* \fINever returns\fP */ - fprintf(stderr, "should never reach this point\en"); -} - -nuser(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - unsigned long nusers; - - switch (rqstp->rq_proc) { - case NULLPROC: - if (!svc_sendreply(transp, xdr_void, 0)) - fprintf(stderr, "can't reply to RPC call\en"); - return; - case RUSERSPROC_NUM: -.ft I - /* - * Code here to compute the number of users - * and assign it to the variable \fInusers\fP - */ -.ft CW - if (!svc_sendreply(transp, xdr_u_long, &nusers)) - fprintf(stderr, "can't reply to RPC call\en"); - return; - default: - svcerr_noproc(transp); - return; - } -} -.DE -.LP -First, the server gets a transport handle, which is used -for receiving and replying to RPC messages. -.I registerrpc() -uses -.I svcudp_create() -to get a UDP handle. -If you require a more reliable protocol, call -.I svctcp_create() -instead. -If the argument to -.I svcudp_create() -is -.I RPC_ANYSOCK -the RPC library creates a socket -on which to receive and reply to RPC calls. Otherwise, -.I svcudp_create() -expects its argument to be a valid socket number. -If you specify your own socket, it can be bound or unbound. -If it is bound to a port by the user, the port numbers of -.I svcudp_create() -and -.I clnttcp_create() -(the low-level client routine) must match. -.LP -If the user specifies the -.I RPC_ANYSOCK -argument, the RPC library routines will open sockets. -Otherwise they will expect the user to do so. The routines -.I svcudp_create() -and -.I clntudp_create() -will cause the RPC library routines to -.I bind() -their socket if it is not bound already. -.LP -A service may choose to register its port number with the -local portmapper service. This is done is done by specifying -a non-zero protocol number in -.I svc_register (). -Incidently, a client can discover the server's port number by -consulting the portmapper on their server's machine. This can -be done automatically by specifying a zero port number in -.I clntudp_create() -or -.I clnttcp_create (). -.LP -After creating an -.I SVCXPRT , -the next step is to call -.I pmap_unset() -so that if the -.I nusers() -server crashed earlier, -any previous trace of it is erased before restarting. -More precisely, -.I pmap_unset() -erases the entry for -.I RUSERSPROG -from the port mapper's tables. -.LP -Finally, we associate the program number for -.I nusers() -with the procedure -.I nuser (). -The final argument to -.I svc_register() -is normally the protocol being used, -which, in this case, is -.I IPPROTO_UDP -Notice that unlike -.I registerrpc (), -there are no XDR routines involved -in the registration process. -Also, registration is done on the program, -rather than procedure, level. -.LP -The user routine -.I nuser() -must call and dispatch the appropriate XDR routines -based on the procedure number. -Note that -two things are handled by -.I nuser() -that -.I registerrpc() -handles automatically. -The first is that procedure -.I NULLPROC -(currently zero) returns with no results. -This can be used as a simple test -for detecting if a remote program is running. -Second, there is a check for invalid procedure numbers. -If one is detected, -.I svcerr_noproc() -is called to handle the error. -.KS -.LP -The user service routine serializes the results and returns -them to the RPC caller via -.I svc_sendreply() -Its first parameter is the -.I SVCXPRT -handle, the second is the XDR routine, -and the third is a pointer to the data to be returned. -Not illustrated above is how a server -handles an RPC program that receives data. -As an example, we can add a procedure -.I RUSERSPROC_BOOL -which has an argument -.I nusers (), -and returns -.I TRUE -or -.I FALSE -depending on whether there are nusers logged on. -It would look like this: -.ie t .DS -.el .DS L -.ft CW -case RUSERSPROC_BOOL: { - int bool; - unsigned nuserquery; - - if (!svc_getargs(transp, xdr_u_int, &nuserquery) { - svcerr_decode(transp); - return; - } -.ft I - /* - * Code to set \fInusers\fP = number of users - */ -.ft CW - if (nuserquery == nusers) - bool = TRUE; - else - bool = FALSE; - if (!svc_sendreply(transp, xdr_bool, &bool)) { - fprintf(stderr, "can't reply to RPC call\en"); - return (1); - } - return; -} -.DE -.KE -.LP -The relevant routine is -.I svc_getargs() -which takes an -.I SVCXPRT -handle, the XDR routine, -and a pointer to where the input is to be placed as arguments. -.NH 2 -\&Memory Allocation with XDR -.IX "memory allocation with XDR" -.IX XDR "memory allocation" -.LP -XDR routines not only do input and output, -they also do memory allocation. -This is why the second parameter of -.I xdr_array() -is a pointer to an array, rather than the array itself. -If it is -.I NULL , -then -.I xdr_array() -allocates space for the array and returns a pointer to it, -putting the size of the array in the third argument. -As an example, consider the following XDR routine -.I xdr_chararr1() -which deals with a fixed array of bytes with length -.I SIZE . -.ie t .DS -.el .DS L -.ft CW -xdr_chararr1(xdrsp, chararr) - XDR *xdrsp; - char chararr[]; -{ - char *p; - int len; - - p = chararr; - len = SIZE; - return (xdr_bytes(xdrsp, &p, &len, SIZE)); -} -.DE -If space has already been allocated in -.I chararr , -it can be called from a server like this: -.ie t .DS -.el .DS L -.ft CW -char chararr[SIZE]; - -svc_getargs(transp, xdr_chararr1, chararr); -.DE -If you want XDR to do the allocation, -you would have to rewrite this routine in the following way: -.ie t .DS -.el .DS L -.ft CW -xdr_chararr2(xdrsp, chararrp) - XDR *xdrsp; - char **chararrp; -{ - int len; - - len = SIZE; - return (xdr_bytes(xdrsp, charrarrp, &len, SIZE)); -} -.DE -Then the RPC call might look like this: -.ie t .DS -.el .DS L -.ft CW -char *arrptr; - -arrptr = NULL; -svc_getargs(transp, xdr_chararr2, &arrptr); -.ft I -/* - * Use the result here - */ -.ft CW -svc_freeargs(transp, xdr_chararr2, &arrptr); -.DE -Note that, after being used, the character array can be freed with -.I svc_freeargs() -.I svc_freeargs() -will not attempt to free any memory if the variable indicating it -is NULL. For example, in the the routine -.I xdr_finalexample (), -given earlier, if -.I finalp->string -was NULL, then it would not be freed. The same is true for -.I finalp->simplep . -.LP -To summarize, each XDR routine is responsible -for serializing, deserializing, and freeing memory. -When an XDR routine is called from -.I callrpc() -the serializing part is used. -When called from -.I svc_getargs() -the deserializer is used. -And when called from -.I svc_freeargs() -the memory deallocator is used. When building simple examples like those -in this section, a user doesn't have to worry -about the three modes. -See the -.I "External Data Representation: Sun Technical Notes" -for examples of more sophisticated XDR routines that determine -which of the three modes they are in and adjust their behavior accordingly. -.KS -.NH 2 -\&The Calling Side -.IX RPC "calling side" -.LP -When you use -.I callrpc() -you have no control over the RPC delivery -mechanism or the socket used to transport the data. -To illustrate the layer of RPC that lets you adjust these -parameters, consider the following code to call the -.I nusers -service: -.ie t .DS -.el .DS L -.ft CW -.vs 11 -#include -#include -#include -#include -#include -#include -#include - -main(argc, argv) - int argc; - char **argv; -{ - struct hostent *hp; - struct timeval pertry_timeout, total_timeout; - struct sockaddr_in server_addr; - int sock = RPC_ANYSOCK; - register CLIENT *client; - enum clnt_stat clnt_stat; - unsigned long nusers; - - if (argc != 2) { - fprintf(stderr, "usage: nusers hostname\en"); - exit(-1); - } - if ((hp = gethostbyname(argv[1])) == NULL) { - fprintf(stderr, "can't get addr for %s\en",argv[1]); - exit(-1); - } - pertry_timeout.tv_sec = 3; - pertry_timeout.tv_usec = 0; - bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, - hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((client = clntudp_create(&server_addr, RUSERSPROG, - RUSERSVERS, pertry_timeout, &sock)) == NULL) { - clnt_pcreateerror("clntudp_create"); - exit(-1); - } - total_timeout.tv_sec = 20; - total_timeout.tv_usec = 0; - clnt_stat = clnt_call(client, RUSERSPROC_NUM, xdr_void, - 0, xdr_u_long, &nusers, total_timeout); - if (clnt_stat != RPC_SUCCESS) { - clnt_perror(client, "rpc"); - exit(-1); - } - clnt_destroy(client); - close(sock); - exit(0); -} -.vs -.DE -.KE -The low-level version of -.I callrpc() -is -.I clnt_call() -which takes a -.I CLIENT -pointer rather than a host name. The parameters to -.I clnt_call() -are a -.I CLIENT -pointer, the procedure number, -the XDR routine for serializing the argument, -a pointer to the argument, -the XDR routine for deserializing the return value, -a pointer to where the return value will be placed, -and the time in seconds to wait for a reply. -.LP -The -.I CLIENT -pointer is encoded with the transport mechanism. -.I callrpc() -uses UDP, thus it calls -.I clntudp_create() -to get a -.I CLIENT -pointer. To get TCP (Transmission Control Protocol), you would use -.I clnttcp_create() . -.LP -The parameters to -.I clntudp_create() -are the server address, the program number, the version number, -a timeout value (between tries), and a pointer to a socket. -The final argument to -.I clnt_call() -is the total time to wait for a response. -Thus, the number of tries is the -.I clnt_call() -timeout divided by the -.I clntudp_create() -timeout. -.LP -Note that the -.I clnt_destroy() -call -always deallocates the space associated with the -.I CLIENT -handle. It closes the socket associated with the -.I CLIENT -handle, however, only if the RPC library opened it. It the -socket was opened by the user, it stays open. This makes it -possible, in cases where there are multiple client handles -using the same socket, to destroy one handle without closing -the socket that other handles are using. -.LP -To make a stream connection, the call to -.I clntudp_create() -is replaced with a call to -.I clnttcp_create() . -.DS -.ft CW -clnttcp_create(&server_addr, prognum, versnum, &sock, - inputsize, outputsize); -.DE -There is no timeout argument; instead, the receive and send buffer -sizes must be specified. When the -.I clnttcp_create() -call is made, a TCP connection is established. -All RPC calls using that -.I CLIENT -handle would use this connection. -The server side of an RPC call using TCP has -.I svcudp_create() -replaced by -.I svctcp_create() . -.DS -.ft CW -transp = svctcp_create(RPC_ANYSOCK, 0, 0); -.DE -The last two arguments to -.I svctcp_create() -are send and receive sizes respectively. If `0' is specified for -either of these, the system chooses a reasonable default. -.KS -.NH 1 -\&Other RPC Features -.IX "RPC" "miscellaneous features" -.IX "miscellaneous RPC features" -.LP -This section discusses some other aspects of RPC -that are occasionally useful. -.NH 2 -\&Select on the Server Side -.IX RPC select() RPC \fIselect()\fP -.IX select() "" \fIselect()\fP "on the server side" -.LP -Suppose a process is processing RPC requests -while performing some other activity. -If the other activity involves periodically updating a data structure, -the process can set an alarm signal before calling -.I svc_run() -But if the other activity -involves waiting on a a file descriptor, the -.I svc_run() -call won't work. -The code for -.I svc_run() -is as follows: -.ie t .DS -.el .DS L -.ft CW -.vs 11 -void -svc_run() -{ - fd_set readfds; - int dtbsz = getdtablesize(); - - for (;;) { - readfds = svc_fds; - switch (select(dtbsz, &readfds, NULL,NULL,NULL)) { - - case -1: - if (errno == EINTR) - continue; - perror("select"); - return; - case 0: - break; - default: - svc_getreqset(&readfds); - } - } -} -.vs -.DE -.KE -.LP -You can bypass -.I svc_run() -and call -.I svc_getreqset() -yourself. -All you need to know are the file descriptors -of the socket(s) associated with the programs you are waiting on. -Thus you can have your own -.I select() -.IX select() "" \fIselect()\fP -that waits on both the RPC socket, -and your own descriptors. Note that -.I svc_fds() -is a bit mask of all the file descriptors that RPC is using for -services. It can change everytime that -.I any -RPC library routine is called, because descriptors are constantly -being opened and closed, for example for TCP connections. -.NH 2 -\&Broadcast RPC -.IX "broadcast RPC" -.IX RPC "broadcast" -.LP -The -.I portmapper -is a daemon that converts RPC program numbers -into DARPA protocol port numbers; see the -.I portmap -man page. You can't do broadcast RPC without the portmapper. -Here are the main differences between -broadcast RPC and normal RPC calls: -.IP 1. -Normal RPC expects one answer, whereas -broadcast RPC expects many answers -(one or more answer from each responding machine). -.IP 2. -Broadcast RPC can only be supported by packet-oriented (connectionless) -transport protocols like UPD/IP. -.IP 3. -The implementation of broadcast RPC -treats all unsuccessful responses as garbage by filtering them out. -Thus, if there is a version mismatch between the -broadcaster and a remote service, -the user of broadcast RPC never knows. -.IP 4. -All broadcast messages are sent to the portmap port. -Thus, only services that register themselves with their portmapper -are accessible via the broadcast RPC mechanism. -.IP 5. -Broadcast requests are limited in size to the MTU (Maximum Transfer -Unit) of the local network. For Ethernet, the MTU is 1500 bytes. -.KS -.NH 3 -\&Broadcast RPC Synopsis -.IX "broadcast RPC" synopsis -.IX "RPC" "broadcast synopsis" -.ie t .DS -.el .DS L -.ft CW -#include - . . . -enum clnt_stat clnt_stat; - . . . -clnt_stat = clnt_broadcast(prognum, versnum, procnum, - inproc, in, outproc, out, eachresult) - u_long prognum; /* \fIprogram number\fP */ - u_long versnum; /* \fIversion number\fP */ - u_long procnum; /* \fIprocedure number\fP */ - xdrproc_t inproc; /* \fIxdr routine for args\fP */ - caddr_t in; /* \fIpointer to args\fP */ - xdrproc_t outproc; /* \fIxdr routine for results\fP */ - caddr_t out; /* \fIpointer to results\fP */ - bool_t (*eachresult)();/* \fIcall with each result gotten\fP */ -.DE -.KE -The procedure -.I eachresult() -is called each time a valid result is obtained. -It returns a boolean that indicates -whether or not the user wants more responses. -.ie t .DS -.el .DS L -.ft CW -bool_t done; - . . . -done = eachresult(resultsp, raddr) - caddr_t resultsp; - struct sockaddr_in *raddr; /* \fIAddr of responding machine\fP */ -.DE -If -.I done -is -.I TRUE , -then broadcasting stops and -.I clnt_broadcast() -returns successfully. -Otherwise, the routine waits for another response. -The request is rebroadcast -after a few seconds of waiting. -If no responses come back, -the routine returns with -.I RPC_TIMEDOUT . -.NH 2 -\&Batching -.IX "batching" -.IX RPC "batching" -.LP -The RPC architecture is designed so that clients send a call message, -and wait for servers to reply that the call succeeded. -This implies that clients do not compute -while servers are processing a call. -This is inefficient if the client does not want or need -an acknowledgement for every message sent. -It is possible for clients to continue computing -while waiting for a response, -using RPC batch facilities. -.LP -RPC messages can be placed in a \*Qpipeline\*U of calls -to a desired server; this is called batching. -Batching assumes that: -1) each RPC call in the pipeline requires no response from the server, -and the server does not send a response message; and -2) the pipeline of calls is transported on a reliable -byte stream transport such as TCP/IP. -Since the server does not respond to every call, -the client can generate new calls in parallel -with the server executing previous calls. -Furthermore, the TCP/IP implementation can buffer up -many call messages, and send them to the server in one -.I write() -system call. This overlapped execution -greatly decreases the interprocess communication overhead of -the client and server processes, -and the total elapsed time of a series of calls. -.LP -Since the batched calls are buffered, -the client should eventually do a nonbatched call -in order to flush the pipeline. -.LP -A contrived example of batching follows. -Assume a string rendering service (like a window system) -has two similar calls: one renders a string and returns void results, -while the other renders a string and remains silent. -The service (using the TCP/IP transport) may look like: -.ie t .DS -.el .DS L -.ft CW -#include -#include -#include - -void windowdispatch(); - -main() -{ - SVCXPRT *transp; - - transp = svctcp_create(RPC_ANYSOCK, 0, 0); - if (transp == NULL){ - fprintf(stderr, "can't create an RPC server\en"); - exit(1); - } - pmap_unset(WINDOWPROG, WINDOWVERS); - if (!svc_register(transp, WINDOWPROG, WINDOWVERS, - windowdispatch, IPPROTO_TCP)) { - fprintf(stderr, "can't register WINDOW service\en"); - exit(1); - } - svc_run(); /* \fINever returns\fP */ - fprintf(stderr, "should never reach this point\en"); -} - -void -windowdispatch(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - char *s = NULL; - - switch (rqstp->rq_proc) { - case NULLPROC: - if (!svc_sendreply(transp, xdr_void, 0)) - fprintf(stderr, "can't reply to RPC call\en"); - return; - case RENDERSTRING: - if (!svc_getargs(transp, xdr_wrapstring, &s)) { - fprintf(stderr, "can't decode arguments\en"); -.ft I - /* - * Tell caller he screwed up - */ -.ft CW - svcerr_decode(transp); - break; - } -.ft I - /* - * Code here to render the string \fIs\fP - */ -.ft CW - if (!svc_sendreply(transp, xdr_void, NULL)) - fprintf(stderr, "can't reply to RPC call\en"); - break; - case RENDERSTRING_BATCHED: - if (!svc_getargs(transp, xdr_wrapstring, &s)) { - fprintf(stderr, "can't decode arguments\en"); -.ft I - /* - * We are silent in the face of protocol errors - */ -.ft CW - break; - } -.ft I - /* - * Code here to render string s, but send no reply! - */ -.ft CW - break; - default: - svcerr_noproc(transp); - return; - } -.ft I - /* - * Now free string allocated while decoding arguments - */ -.ft CW - svc_freeargs(transp, xdr_wrapstring, &s); -} -.DE -Of course the service could have one procedure -that takes the string and a boolean -to indicate whether or not the procedure should respond. -.LP -In order for a client to take advantage of batching, -the client must perform RPC calls on a TCP-based transport -and the actual calls must have the following attributes: -1) the result's XDR routine must be zero -.I NULL ), -and 2) the RPC call's timeout must be zero. -.KS -.LP -Here is an example of a client that uses batching to render a -bunch of strings; the batching is flushed when the client gets -a null string (EOF): -.ie t .DS -.el .DS L -.ft CW -.vs 11 -#include -#include -#include -#include -#include -#include - -main(argc, argv) - int argc; - char **argv; -{ - struct hostent *hp; - struct timeval pertry_timeout, total_timeout; - struct sockaddr_in server_addr; - int sock = RPC_ANYSOCK; - register CLIENT *client; - enum clnt_stat clnt_stat; - char buf[1000], *s = buf; - - if ((client = clnttcp_create(&server_addr, - WINDOWPROG, WINDOWVERS, &sock, 0, 0)) == NULL) { - perror("clnttcp_create"); - exit(-1); - } - total_timeout.tv_sec = 0; - total_timeout.tv_usec = 0; - while (scanf("%s", s) != EOF) { - clnt_stat = clnt_call(client, RENDERSTRING_BATCHED, - xdr_wrapstring, &s, NULL, NULL, total_timeout); - if (clnt_stat != RPC_SUCCESS) { - clnt_perror(client, "batched rpc"); - exit(-1); - } - } - - /* \fINow flush the pipeline\fP */ - - total_timeout.tv_sec = 20; - clnt_stat = clnt_call(client, NULLPROC, xdr_void, NULL, - xdr_void, NULL, total_timeout); - if (clnt_stat != RPC_SUCCESS) { - clnt_perror(client, "rpc"); - exit(-1); - } - clnt_destroy(client); - exit(0); -} -.vs -.DE -.KE -Since the server sends no message, -the clients cannot be notified of any of the failures that may occur. -Therefore, clients are on their own when it comes to handling errors. -.LP -The above example was completed to render -all of the (2000) lines in the file -.I /etc/termcap . -The rendering service did nothing but throw the lines away. -The example was run in the following four configurations: -1) machine to itself, regular RPC; -2) machine to itself, batched RPC; -3) machine to another, regular RPC; and -4) machine to another, batched RPC. -The results are as follows: -1) 50 seconds; -2) 16 seconds; -3) 52 seconds; -4) 10 seconds. -Running -.I fscanf() -on -.I /etc/termcap -only requires six seconds. -These timings show the advantage of protocols -that allow for overlapped execution, -though these protocols are often hard to design. -.NH 2 -\&Authentication -.IX "authentication" -.IX "RPC" "authentication" -.LP -In the examples presented so far, -the caller never identified itself to the server, -and the server never required an ID from the caller. -Clearly, some network services, such as a network filesystem, -require stronger security than what has been presented so far. -.LP -In reality, every RPC call is authenticated by -the RPC package on the server, and similarly, -the RPC client package generates and sends authentication parameters. -Just as different transports (TCP/IP or UDP/IP) -can be used when creating RPC clients and servers, -different forms of authentication can be associated with RPC clients; -the default authentication type used as a default is type -.I none . -.LP -The authentication subsystem of the RPC package is open ended. -That is, numerous types of authentication are easy to support. -.NH 3 -\&UNIX Authentication -.IX "UNIX Authentication" -.IP "\fIThe Client Side\fP" -.LP -When a caller creates a new RPC client handle as in: -.DS -.ft CW -clnt = clntudp_create(address, prognum, versnum, - wait, sockp) -.DE -the appropriate transport instance defaults -the associate authentication handle to be -.DS -.ft CW -clnt->cl_auth = authnone_create(); -.DE -The RPC client can choose to use -.I UNIX -style authentication by setting -.I clnt\->cl_auth -after creating the RPC client handle: -.DS -.ft CW -clnt->cl_auth = authunix_create_default(); -.DE -This causes each RPC call associated with -.I clnt -to carry with it the following authentication credentials structure: -.ie t .DS -.el .DS L -.ft I -/* - * UNIX style credentials. - */ -.ft CW -struct authunix_parms { - u_long aup_time; /* \fIcredentials creation time\fP */ - char *aup_machname; /* \fIhost name where client is\fP */ - int aup_uid; /* \fIclient's UNIX effective uid\fP */ - int aup_gid; /* \fIclient's current group id\fP */ - u_int aup_len; /* \fIelement length of aup_gids\fP */ - int *aup_gids; /* \fIarray of groups user is in\fP */ -}; -.DE -These fields are set by -.I authunix_create_default() -by invoking the appropriate system calls. -Since the RPC user created this new style of authentication, -the user is responsible for destroying it with: -.DS -.ft CW -auth_destroy(clnt->cl_auth); -.DE -This should be done in all cases, to conserve memory. -.sp -.IP "\fIThe Server Side\fP" -.LP -Service implementors have a harder time dealing with authentication issues -since the RPC package passes the service dispatch routine a request -that has an arbitrary authentication style associated with it. -Consider the fields of a request handle passed to a service dispatch routine: -.ie t .DS -.el .DS L -.ft I -/* - * An RPC Service request - */ -.ft CW -struct svc_req { - u_long rq_prog; /* \fIservice program number\fP */ - u_long rq_vers; /* \fIservice protocol vers num\fP */ - u_long rq_proc; /* \fIdesired procedure number\fP */ - struct opaque_auth rq_cred; /* \fIraw credentials from wire\fP */ - caddr_t rq_clntcred; /* \fIcredentials (read only)\fP */ -}; -.DE -The -.I rq_cred -is mostly opaque, except for one field of interest: -the style or flavor of authentication credentials: -.ie t .DS -.el .DS L -.ft I -/* - * Authentication info. Mostly opaque to the programmer. - */ -.ft CW -struct opaque_auth { - enum_t oa_flavor; /* \fIstyle of credentials\fP */ - caddr_t oa_base; /* \fIaddress of more auth stuff\fP */ - u_int oa_length; /* \fInot to exceed \fIMAX_AUTH_BYTES */ -}; -.DE -.IX RPC guarantees -The RPC package guarantees the following -to the service dispatch routine: -.IP 1. -That the request's -.I rq_cred -is well formed. Thus the service implementor may inspect the request's -.I rq_cred.oa_flavor -to determine which style of authentication the caller used. -The service implementor may also wish to inspect the other fields of -.I rq_cred -if the style is not one of the styles supported by the RPC package. -.IP 2. -That the request's -.I rq_clntcred -field is either -.I NULL -or points to a well formed structure -that corresponds to a supported style of authentication credentials. -Remember that only -.I unix -style is currently supported, so (currently) -.I rq_clntcred -could be cast to a pointer to an -.I authunix_parms -structure. If -.I rq_clntcred -is -.I NULL , -the service implementor may wish to inspect the other (opaque) fields of -.I rq_cred -in case the service knows about a new type of authentication -that the RPC package does not know about. -.LP -Our remote users service example can be extended so that -it computes results for all users except UID 16: -.ie t .DS -.el .DS L -.ft CW -.vs 11 -nuser(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - struct authunix_parms *unix_cred; - int uid; - unsigned long nusers; - -.ft I - /* - * we don't care about authentication for null proc - */ -.ft CW - if (rqstp->rq_proc == NULLPROC) { - if (!svc_sendreply(transp, xdr_void, 0)) { - fprintf(stderr, "can't reply to RPC call\en"); - return (1); - } - return; - } -.ft I - /* - * now get the uid - */ -.ft CW - switch (rqstp->rq_cred.oa_flavor) { - case AUTH_UNIX: - unix_cred = - (struct authunix_parms *)rqstp->rq_clntcred; - uid = unix_cred->aup_uid; - break; - case AUTH_NULL: - default: - svcerr_weakauth(transp); - return; - } - switch (rqstp->rq_proc) { - case RUSERSPROC_NUM: -.ft I - /* - * make sure caller is allowed to call this proc - */ -.ft CW - if (uid == 16) { - svcerr_systemerr(transp); - return; - } -.ft I - /* - * Code here to compute the number of users - * and assign it to the variable \fInusers\fP - */ -.ft CW - if (!svc_sendreply(transp, xdr_u_long, &nusers)) { - fprintf(stderr, "can't reply to RPC call\en"); - return (1); - } - return; - default: - svcerr_noproc(transp); - return; - } -} -.vs -.DE -A few things should be noted here. -First, it is customary not to check -the authentication parameters associated with the -.I NULLPROC -(procedure number zero). -Second, if the authentication parameter's type is not suitable -for your service, you should call -.I svcerr_weakauth() . -And finally, the service protocol itself should return status -for access denied; in the case of our example, the protocol -does not have such a status, so we call the service primitive -.I svcerr_systemerr() -instead. -.LP -The last point underscores the relation between -the RPC authentication package and the services; -RPC deals only with -.I authentication -and not with individual services' -.I "access control" . -The services themselves must implement their own access control policies -and reflect these policies as return statuses in their protocols. -.NH 2 -\&DES Authentication -.IX RPC DES -.IX RPC authentication -.LP -UNIX authentication is quite easy to defeat. Instead of using -.I authunix_create_default (), -one can call -.I authunix_create() -and then modify the RPC authentication handle it returns by filling in -whatever user ID and hostname they wish the server to think they have. -DES authentication is thus recommended for people who want more security -than UNIX authentication offers. -.LP -The details of the DES authentication protocol are complicated and -are not explained here. -See -.I "Remote Procedure Calls: Protocol Specification" -for the details. -.LP -In order for DES authentication to work, the -.I keyserv(8c) -daemon must be running on both the server and client machines. The -users on these machines need public keys assigned by the network -administrator in the -.I publickey(5) -database. And, they need to have decrypted their secret keys -using their login password. This automatically happens when one -logs in using -.I login(1) , -or can be done manually using -.I keylogin(1) . -The -.I "Network Services" -chapter -./" XXX -explains more how to setup secure networking. -.sp -.IP "\fIClient Side\fP" -.LP -If a client wishes to use DES authentication, it must set its -authentication handle appropriately. Here is an example: -.DS -cl->cl_auth = - authdes_create(servername, 60, &server_addr, NULL); -.DE -The first argument is the network name or \*Qnetname\*U of the owner of -the server process. Typically, server processes are root processes -and their netname can be derived using the following call: -.DS -char servername[MAXNETNAMELEN]; - -host2netname(servername, rhostname, NULL); -.DE -Here, -.I rhostname -is the hostname of the machine the server process is running on. -.I host2netname() -fills in -.I servername -to contain this root process's netname. If the -server process was run by a regular user, one could use the call -.I user2netname() -instead. Here is an example for a server process with the same user -ID as the client: -.DS -char servername[MAXNETNAMELEN]; - -user2netname(servername, getuid(), NULL); -.DE -The last argument to both of these calls, -.I user2netname() -and -.I host2netname (), -is the name of the naming domain where the server is located. The -.I NULL -used here means \*Quse the local domain name.\*U -.LP -The second argument to -.I authdes_create() -is a lifetime for the credential. Here it is set to sixty -seconds. What that means is that the credential will expire 60 -seconds from now. If some mischievous user tries to reuse the -credential, the server RPC subsystem will recognize that it has -expired and not grant any requests. If the same mischievous user -tries to reuse the credential within the sixty second lifetime, -he will still be rejected because the server RPC subsystem -remembers which credentials it has already seen in the near past, -and will not grant requests to duplicates. -.LP -The third argument to -.I authdes_create() -is the address of the host to synchronize with. In order for DES -authentication to work, the server and client must agree upon the -time. Here we pass the address of the server itself, so the -client and server will both be using the same time: the server's -time. The argument can be -.I NULL , -which means \*Qdon't bother synchronizing.\*U You should only do this -if you are sure the client and server are already synchronized. -.LP -The final argument to -.I authdes_create() -is the address of a DES encryption key to use for encrypting -timestamps and data. If this argument is -.I NULL , -as it is in this example, a random key will be chosen. The client -may find out the encryption key being used by consulting the -.I ah_key -field of the authentication handle. -.sp -.IP "\fIServer Side\fP" -.LP -The server side is a lot simpler than the client side. Here is the -previous example rewritten to use -.I AUTH_DES -instead of -.I AUTH_UNIX : -.ie t .DS -.el .DS L -.ft CW -.vs 11 -#include -#include - . . . - . . . -nuser(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - struct authdes_cred *des_cred; - int uid; - int gid; - int gidlen; - int gidlist[10]; -.ft I - /* - * we don't care about authentication for null proc - */ -.ft CW - - if (rqstp->rq_proc == NULLPROC) { - /* \fIsame as before\fP */ - } - -.ft I - /* - * now get the uid - */ -.ft CW - switch (rqstp->rq_cred.oa_flavor) { - case AUTH_DES: - des_cred = - (struct authdes_cred *) rqstp->rq_clntcred; - if (! netname2user(des_cred->adc_fullname.name, - &uid, &gid, &gidlen, gidlist)) - { - fprintf(stderr, "unknown user: %s\n", - des_cred->adc_fullname.name); - svcerr_systemerr(transp); - return; - } - break; - case AUTH_NULL: - default: - svcerr_weakauth(transp); - return; - } - -.ft I - /* - * The rest is the same as before - */ -.ft CW -.vs -.DE -Note the use of the routine -.I netname2user (), -the inverse of -.I user2netname (): -it takes a network ID and converts to a unix ID. -.I netname2user () -also supplies the group IDs which we don't use in this example, -but which may be useful to other UNIX programs. -.NH 2 -\&Using Inetd -.IX inetd "" "using \fIinetd\fP" -.LP -An RPC server can be started from -.I inetd -The only difference from the usual code is that the service -creation routine should be called in the following form: -.ie t .DS -.el .DS L -.ft CW -transp = svcudp_create(0); /* \fIFor UDP\fP */ -transp = svctcp_create(0,0,0); /* \fIFor listener TCP sockets\fP */ -transp = svcfd_create(0,0,0); /* \fIFor connected TCP sockets\fP */ -.DE -since -.I inet -passes a socket as file descriptor 0. -Also, -.I svc_register() -should be called as -.ie t .DS -.el .DS L -.ft CW -svc_register(transp, PROGNUM, VERSNUM, service, 0); -.DE -with the final flag as 0, -since the program would already be registered by -.I inetd -Remember that if you want to exit -from the server process and return control to -.I inet -you need to explicitly exit, since -.I svc_run() -never returns. -.LP -The format of entries in -.I /etc/inetd.conf -for RPC services is in one of the following two forms: -.ie t .DS -.el .DS L -.ft CW -p_name/version dgram rpc/udp wait/nowait user server args -p_name/version stream rpc/tcp wait/nowait user server args -.DE -where -.I p_name -is the symbolic name of the program as it appears in -.I rpc(5) , -.I server -is the program implementing the server, -and -.I program -and -.I version -are the program and version numbers of the service. -For more information, see -.I inetd.conf(5) . -.LP -If the same program handles multiple versions, -then the version number can be a range, -as in this example: -.ie t .DS -.el .DS L -.ft CW -rstatd/1-2 dgram rpc/udp wait root /usr/etc/rpc.rstatd -.DE -.NH 1 -\&More Examples -.sp 1 -.NH 2 -\&Versions -.IX "versions" -.IX "RPC" "versions" -.LP -By convention, the first version number of program -.I PROG -is -.I PROGVERS_ORIG -and the most recent version is -.I PROGVERS -Suppose there is a new version of the -.I user -program that returns an -.I "unsigned short" -rather than a -.I long . -If we name this version -.I RUSERSVERS_SHORT -then a server that wants to support both versions -would do a double register. -.ie t .DS -.el .DS L -.ft CW -if (!svc_register(transp, RUSERSPROG, RUSERSVERS_ORIG, - nuser, IPPROTO_TCP)) { - fprintf(stderr, "can't register RUSER service\en"); - exit(1); -} -if (!svc_register(transp, RUSERSPROG, RUSERSVERS_SHORT, - nuser, IPPROTO_TCP)) { - fprintf(stderr, "can't register RUSER service\en"); - exit(1); -} -.DE -Both versions can be handled by the same C procedure: -.ie t .DS -.el .DS L -.ft CW -.vs 11 -nuser(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - unsigned long nusers; - unsigned short nusers2; - - switch (rqstp->rq_proc) { - case NULLPROC: - if (!svc_sendreply(transp, xdr_void, 0)) { - fprintf(stderr, "can't reply to RPC call\en"); - return (1); - } - return; - case RUSERSPROC_NUM: -.ft I - /* - * Code here to compute the number of users - * and assign it to the variable \fInusers\fP - */ -.ft CW - nusers2 = nusers; - switch (rqstp->rq_vers) { - case RUSERSVERS_ORIG: - if (!svc_sendreply(transp, xdr_u_long, - &nusers)) { - fprintf(stderr,"can't reply to RPC call\en"); - } - break; - case RUSERSVERS_SHORT: - if (!svc_sendreply(transp, xdr_u_short, - &nusers2)) { - fprintf(stderr,"can't reply to RPC call\en"); - } - break; - } - default: - svcerr_noproc(transp); - return; - } -} -.vs -.DE -.KS -.NH 2 -\&TCP -.IX "TCP" -.LP -Here is an example that is essentially -.I rcp. -The initiator of the RPC -.I snd -call takes its standard input and sends it to the server -.I rcv -which prints it on standard output. -The RPC call uses TCP. -This also illustrates an XDR procedure that behaves differently -on serialization than on deserialization. -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * The xdr routine: - * on decode, read from wire, write onto fp - * on encode, read from fp, write onto wire - */ -.ft CW -#include -#include - -xdr_rcp(xdrs, fp) - XDR *xdrs; - FILE *fp; -{ - unsigned long size; - char buf[BUFSIZ], *p; - - if (xdrs->x_op == XDR_FREE)/* nothing to free */ - return 1; - while (1) { - if (xdrs->x_op == XDR_ENCODE) { - if ((size = fread(buf, sizeof(char), BUFSIZ, - fp)) == 0 && ferror(fp)) { - fprintf(stderr, "can't fread\en"); - return (1); - } - } - p = buf; - if (!xdr_bytes(xdrs, &p, &size, BUFSIZ)) - return 0; - if (size == 0) - return 1; - if (xdrs->x_op == XDR_DECODE) { - if (fwrite(buf, sizeof(char), size, - fp) != size) { - fprintf(stderr, "can't fwrite\en"); - return (1); - } - } - } -} -.vs -.DE -.KE -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * The sender routines - */ -.ft CW -#include -#include -#include -#include -#include - -main(argc, argv) - int argc; - char **argv; -{ - int xdr_rcp(); - int err; - - if (argc < 2) { - fprintf(stderr, "usage: %s servername\en", argv[0]); - exit(-1); - } - if ((err = callrpctcp(argv[1], RCPPROG, RCPPROC, - RCPVERS, xdr_rcp, stdin, xdr_void, 0) != 0)) { - clnt_perrno(err); - fprintf(stderr, "can't make RPC call\en"); - exit(1); - } - exit(0); -} - -callrpctcp(host, prognum, procnum, versnum, - inproc, in, outproc, out) - char *host, *in, *out; - xdrproc_t inproc, outproc; -{ - struct sockaddr_in server_addr; - int socket = RPC_ANYSOCK; - enum clnt_stat clnt_stat; - struct hostent *hp; - register CLIENT *client; - struct timeval total_timeout; - - if ((hp = gethostbyname(host)) == NULL) { - fprintf(stderr, "can't get addr for '%s'\en", host); - return (-1); - } - bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, - hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((client = clnttcp_create(&server_addr, prognum, - versnum, &socket, BUFSIZ, BUFSIZ)) == NULL) { - perror("rpctcp_create"); - return (-1); - } - total_timeout.tv_sec = 20; - total_timeout.tv_usec = 0; - clnt_stat = clnt_call(client, procnum, - inproc, in, outproc, out, total_timeout); - clnt_destroy(client); - return (int)clnt_stat; -} -.vs -.DE -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * The receiving routines - */ -.ft CW -#include -#include - -main() -{ - register SVCXPRT *transp; - int rcp_service(), xdr_rcp(); - - if ((transp = svctcp_create(RPC_ANYSOCK, - BUFSIZ, BUFSIZ)) == NULL) { - fprintf("svctcp_create: error\en"); - exit(1); - } - pmap_unset(RCPPROG, RCPVERS); - if (!svc_register(transp, - RCPPROG, RCPVERS, rcp_service, IPPROTO_TCP)) { - fprintf(stderr, "svc_register: error\en"); - exit(1); - } - svc_run(); /* \fInever returns\fP */ - fprintf(stderr, "svc_run should never return\en"); -} - -rcp_service(rqstp, transp) - register struct svc_req *rqstp; - register SVCXPRT *transp; -{ - switch (rqstp->rq_proc) { - case NULLPROC: - if (svc_sendreply(transp, xdr_void, 0) == 0) { - fprintf(stderr, "err: rcp_service"); - return (1); - } - return; - case RCPPROC_FP: - if (!svc_getargs(transp, xdr_rcp, stdout)) { - svcerr_decode(transp); - return; - } - if (!svc_sendreply(transp, xdr_void, 0)) { - fprintf(stderr, "can't reply\en"); - return; - } - return (0); - default: - svcerr_noproc(transp); - return; - } -} -.vs -.DE -.NH 2 -\&Callback Procedures -.IX RPC "callback procedures" -.LP -Occasionally, it is useful to have a server become a client, -and make an RPC call back to the process which is its client. -An example is remote debugging, -where the client is a window system program, -and the server is a debugger running on the remote machine. -Most of the time, -the user clicks a mouse button at the debugging window, -which converts this to a debugger command, -and then makes an RPC call to the server -(where the debugger is actually running), -telling it to execute that command. -However, when the debugger hits a breakpoint, the roles are reversed, -and the debugger wants to make an rpc call to the window program, -so that it can inform the user that a breakpoint has been reached. -.LP -In order to do an RPC callback, -you need a program number to make the RPC call on. -Since this will be a dynamically generated program number, -it should be in the transient range, -.I "0x40000000 - 0x5fffffff" . -The routine -.I gettransient() -returns a valid program number in the transient range, -and registers it with the portmapper. -It only talks to the portmapper running on the same machine as the -.I gettransient() -routine itself. The call to -.I pmap_set() -is a test and set operation, -in that it indivisibly tests whether a program number -has already been registered, -and if it has not, then reserves it. On return, the -.I sockp -argument will contain a socket that can be used -as the argument to an -.I svcudp_create() -or -.I svctcp_create() -call. -.ie t .DS -.el .DS L -.ft CW -.vs 11 -#include -#include -#include - -gettransient(proto, vers, sockp) - int proto, vers, *sockp; -{ - static int prognum = 0x40000000; - int s, len, socktype; - struct sockaddr_in addr; - - switch(proto) { - case IPPROTO_UDP: - socktype = SOCK_DGRAM; - break; - case IPPROTO_TCP: - socktype = SOCK_STREAM; - break; - default: - fprintf(stderr, "unknown protocol type\en"); - return 0; - } - if (*sockp == RPC_ANYSOCK) { - if ((s = socket(AF_INET, socktype, 0)) < 0) { - perror("socket"); - return (0); - } - *sockp = s; - } - else - s = *sockp; - addr.sin_addr.s_addr = 0; - addr.sin_family = AF_INET; - addr.sin_port = 0; - len = sizeof(addr); -.ft I - /* - * may be already bound, so don't check for error - */ -.ft CW - bind(s, &addr, len); - if (getsockname(s, &addr, &len)< 0) { - perror("getsockname"); - return (0); - } - while (!pmap_set(prognum++, vers, proto, - ntohs(addr.sin_port))) continue; - return (prognum-1); -} -.vs -.DE -.SH -Note: -.I -The call to -.I ntohs() -is necessary to ensure that the port number in -.I "addr.sin_port" , -which is in -.I network -byte order, is passed in -.I host -byte order (as -.I pmap_set() -expects). See the -.I byteorder(3N) -man page for more details on the conversion of network -addresses from network to host byte order. -.KS -.LP -The following pair of programs illustrate how to use the -.I gettransient() -routine. -The client makes an RPC call to the server, -passing it a transient program number. -Then the client waits around to receive a callback -from the server at that program number. -The server registers the program -.I EXAMPLEPROG -so that it can receive the RPC call -informing it of the callback program number. -Then at some random time (on receiving an -.I ALRM -signal in this example), it sends a callback RPC call, -using the program number it received earlier. -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * client - */ -.ft CW -#include -#include - -int callback(); -char hostname[256]; - -main() -{ - int x, ans, s; - SVCXPRT *xprt; - - gethostname(hostname, sizeof(hostname)); - s = RPC_ANYSOCK; - x = gettransient(IPPROTO_UDP, 1, &s); - fprintf(stderr, "client gets prognum %d\en", x); - if ((xprt = svcudp_create(s)) == NULL) { - fprintf(stderr, "rpc_server: svcudp_create\en"); - exit(1); - } -.ft I - /* protocol is 0 - gettransient does registering - */ -.ft CW - (void)svc_register(xprt, x, 1, callback, 0); - ans = callrpc(hostname, EXAMPLEPROG, EXAMPLEVERS, - EXAMPLEPROC_CALLBACK, xdr_int, &x, xdr_void, 0); - if ((enum clnt_stat) ans != RPC_SUCCESS) { - fprintf(stderr, "call: "); - clnt_perrno(ans); - fprintf(stderr, "\en"); - } - svc_run(); - fprintf(stderr, "Error: svc_run shouldn't return\en"); -} - -callback(rqstp, transp) - register struct svc_req *rqstp; - register SVCXPRT *transp; -{ - switch (rqstp->rq_proc) { - case 0: - if (!svc_sendreply(transp, xdr_void, 0)) { - fprintf(stderr, "err: exampleprog\en"); - return (1); - } - return (0); - case 1: - if (!svc_getargs(transp, xdr_void, 0)) { - svcerr_decode(transp); - return (1); - } - fprintf(stderr, "client got callback\en"); - if (!svc_sendreply(transp, xdr_void, 0)) { - fprintf(stderr, "err: exampleprog"); - return (1); - } - } -} -.vs -.DE -.KE -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * server - */ -.ft CW -#include -#include -#include - -char *getnewprog(); -char hostname[256]; -int docallback(); -int pnum; /* \fIprogram number for callback routine\fP */ - -main() -{ - gethostname(hostname, sizeof(hostname)); - registerrpc(EXAMPLEPROG, EXAMPLEVERS, - EXAMPLEPROC_CALLBACK, getnewprog, xdr_int, xdr_void); - fprintf(stderr, "server going into svc_run\en"); - signal(SIGALRM, docallback); - alarm(10); - svc_run(); - fprintf(stderr, "Error: svc_run shouldn't return\en"); -} - -char * -getnewprog(pnump) - char *pnump; -{ - pnum = *(int *)pnump; - return NULL; -} - -docallback() -{ - int ans; - - ans = callrpc(hostname, pnum, 1, 1, xdr_void, 0, - xdr_void, 0); - if (ans != 0) { - fprintf(stderr, "server: "); - clnt_perrno(ans); - fprintf(stderr, "\en"); - } -} -.vs -.DE diff --git a/lib/librpc/doc/rpc.rfc.ms b/lib/librpc/doc/rpc.rfc.ms deleted file mode 100644 index af9c2df2ed83..000000000000 --- a/lib/librpc/doc/rpc.rfc.ms +++ /dev/null @@ -1,1302 +0,0 @@ -.\" -.\" Must use -- tbl -- with this one -.\" -.\" @(#)rpc.rfc.ms 2.2 88/08/05 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'Remote Procedure Calls: Protocol Specification''Page %' -.EH 'Page %''Remote Procedure Calls: Protocol Specification' -.if \\n%=1 .bp -.SH -\&Remote Procedure Calls: Protocol Specification -.LP -.NH 0 -\&Status of this Memo -.LP -Note: This chapter specifies a protocol that Sun Microsystems, Inc., -and others are using. -It has been designated RFC1050 by the ARPA Network -Information Center. -.LP -.NH 1 -\&Introduction -.LP -This chapter specifies a message protocol used in implementing -Sun's Remote Procedure Call (RPC) package. (The message protocol is -specified with the External Data Representation (XDR) language. -See the -.I "External Data Representation Standard: Protocol Specification" -for the details. Here, we assume that the reader is familiar -with XDR and do not attempt to justify it or its uses). The paper -by Birrell and Nelson [1] is recommended as an excellent background -to and justification of RPC. -.NH 2 -\&Terminology -.LP -This chapter discusses servers, services, programs, procedures, -clients, and versions. A server is a piece of software where network -services are implemented. A network service is a collection of one -or more remote programs. A remote program implements one or more -remote procedures; the procedures, their parameters, and results are -documented in the specific program's protocol specification (see the -\fIPort Mapper Program Protocol\fP\, below, for an example). Network -clients are pieces of software that initiate remote procedure calls -to services. A server may support more than one version of a remote -program in order to be forward compatible with changing protocols. -.LP -For example, a network file service may be composed of two programs. -One program may deal with high-level applications such as file system -access control and locking. The other may deal with low-level file -IO and have procedures like "read" and "write". A client machine of -the network file service would call the procedures associated with -the two programs of the service on behalf of some user on the client -machine. -.NH 2 -\&The RPC Model -.LP -The remote procedure call model is similar to the local procedure -call model. In the local case, the caller places arguments to a -procedure in some well-specified location (such as a result -register). It then transfers control to the procedure, and -eventually gains back control. At that point, the results of the -procedure are extracted from the well-specified location, and the -caller continues execution. -.LP -The remote procedure call is similar, in that one thread of control -logically winds through two processes\(emone is the caller's process, -the other is a server's process. That is, the caller process sends a -call message to the server process and waits (blocks) for a reply -message. The call message contains the procedure's parameters, among -other things. The reply message contains the procedure's results, -among other things. Once the reply message is received, the results -of the procedure are extracted, and caller's execution is resumed. -.LP -On the server side, a process is dormant awaiting the arrival of a -call message. When one arrives, the server process extracts the -procedure's parameters, computes the results, sends a reply message, -and then awaits the next call message. -.LP -Note that in this model, only one of the two processes is active at -any given time. However, this model is only given as an example. -The RPC protocol makes no restrictions on the concurrency model -implemented, and others are possible. For example, an implementation -may choose to have RPC calls be asynchronous, so that the client may -do useful work while waiting for the reply from the server. Another -possibility is to have the server create a task to process an -incoming request, so that the server can be free to receive other -requests. -.NH 2 -\&Transports and Semantics -.LP -The RPC protocol is independent of transport protocols. That is, RPC -does not care how a message is passed from one process to another. -The protocol deals only with specification and interpretation of -messages. -.LP -It is important to point out that RPC does not try to implement any -kind of reliability and that the application must be aware of the -type of transport protocol underneath RPC. If it knows it is running -on top of a reliable transport such as TCP/IP[6], then most of the -work is already done for it. On the other hand, if it is running on -top of an unreliable transport such as UDP/IP[7], it must implement -is own retransmission and time-out policy as the RPC layer does not -provide this service. -.LP -Because of transport independence, the RPC protocol does not attach -specific semantics to the remote procedures or their execution. -Semantics can be inferred from (but should be explicitly specified -by) the underlying transport protocol. For example, consider RPC -running on top of an unreliable transport such as UDP/IP. If an -application retransmits RPC messages after short time-outs, the only -thing it can infer if it receives no reply is that the procedure was -executed zero or more times. If it does receive a reply, then it can -infer that the procedure was executed at least once. -.LP -A server may wish to remember previously granted requests from a -client and not regrant them in order to insure some degree of -execute-at-most-once semantics. A server can do this by taking -advantage of the transaction ID that is packaged with every RPC -request. The main use of this transaction is by the client RPC layer -in matching replies to requests. However, a client application may -choose to reuse its previous transaction ID when retransmitting a -request. The server application, knowing this fact, may choose to -remember this ID after granting a request and not regrant requests -with the same ID in order to achieve some degree of -execute-at-most-once semantics. The server is not allowed to examine -this ID in any other way except as a test for equality. -.LP -On the other hand, if using a reliable transport such as TCP/IP, the -application can infer from a reply message that the procedure was -executed exactly once, but if it receives no reply message, it cannot -assume the remote procedure was not executed. Note that even if a -connection-oriented protocol like TCP is used, an application still -needs time-outs and reconnection to handle server crashes. -.LP -There are other possibilities for transports besides datagram- or -connection-oriented protocols. For example, a request-reply protocol -such as VMTP[2] is perhaps the most natural transport for RPC. -.SH -.I -NOTE: At Sun, RPC is currently implemented on top of both TCP/IP -and UDP/IP transports. -.LP -.NH 2 -\&Binding and Rendezvous Independence -.LP -The act of binding a client to a service is NOT part of the remote -procedure call specification. This important and necessary function -is left up to some higher-level software. (The software may use RPC -itself\(emsee the \fIPort Mapper Program Protocol\fP\, below). -.LP -Implementors should think of the RPC protocol as the jump-subroutine -instruction ("JSR") of a network; the loader (binder) makes JSR -useful, and the loader itself uses JSR to accomplish its task. -Likewise, the network makes RPC useful, using RPC to accomplish this -task. -.NH 2 -\&Authentication -.LP -The RPC protocol provides the fields necessary for a client to -identify itself to a service and vice-versa. Security and access -control mechanisms can be built on top of the message authentication. -Several different authentication protocols can be supported. A field -in the RPC header indicates which protocol is being used. More -information on specific authentication protocols can be found in the -\fIAuthentication Protocols\fP\, -below. -.KS -.NH 1 -\&RPC Protocol Requirements -.LP -The RPC protocol must provide for the following: -.IP 1. -Unique specification of a procedure to be called. -.IP 2. -Provisions for matching response messages to request messages. -.KE -.IP 3. -Provisions for authenticating the caller to service and vice-versa. -.LP -Besides these requirements, features that detect the following are -worth supporting because of protocol roll-over errors, implementation -bugs, user error, and network administration: -.IP 1. -RPC protocol mismatches. -.IP 2. -Remote program protocol version mismatches. -.IP 3. -Protocol errors (such as misspecification of a procedure's parameters). -.IP 4. -Reasons why remote authentication failed. -.IP 5. -Any other reasons why the desired procedure was not called. -.NH 2 -\&Programs and Procedures -.LP -The RPC call message has three unsigned fields: remote program -number, remote program version number, and remote procedure number. -The three fields uniquely identify the procedure to be called. -Program numbers are administered by some central authority (like -Sun). Once an implementor has a program number, he can implement his -remote program; the first implementation would most likely have the -version number of 1. Because most new protocols evolve into better, -stable, and mature protocols, a version field of the call message -identifies which version of the protocol the caller is using. -Version numbers make speaking old and new protocols through the same -server process possible. -.LP -The procedure number identifies the procedure to be called. These -numbers are documented in the specific program's protocol -specification. For example, a file service's protocol specification -may state that its procedure number 5 is "read" and procedure number -12 is "write". -.LP -Just as remote program protocols may change over several versions, -the actual RPC message protocol could also change. Therefore, the -call message also has in it the RPC version number, which is always -equal to two for the version of RPC described here. -.LP -The reply message to a request message has enough information to -distinguish the following error conditions: -.IP 1. -The remote implementation of RPC does speak protocol version 2. -The lowest and highest supported RPC version numbers are returned. -.IP 2. -The remote program is not available on the remote system. -.IP 3. -The remote program does not support the requested version number. -The lowest and highest supported remote program version numbers are -returned. -.IP 4. -The requested procedure number does not exist. (This is usually a -caller side protocol or programming error.) -.IP 5. -The parameters to the remote procedure appear to be garbage from the -server's point of view. (Again, this is usually caused by a -disagreement about the protocol between client and service.) -.NH 2 -\&Authentication -.LP -Provisions for authentication of caller to service and vice-versa are -provided as a part of the RPC protocol. The call message has two -authentication fields, the credentials and verifier. The reply -message has one authentication field, the response verifier. The RPC -protocol specification defines all three fields to be the following -opaque type: -.DS -.ft CW -.vs 11 -enum auth_flavor { - AUTH_NULL = 0, - AUTH_UNIX = 1, - AUTH_SHORT = 2, - AUTH_DES = 3 - /* \fIand more to be defined\fP */ -}; - -struct opaque_auth { - auth_flavor flavor; - opaque body<400>; -}; -.DE -.LP -In simple English, any -.I opaque_auth -structure is an -.I auth_flavor -enumeration followed by bytes which are opaque to the RPC protocol -implementation. -.LP -The interpretation and semantics of the data contained within the -authentication fields is specified by individual, independent -authentication protocol specifications. (See -\fIAuthentication Protocols\fP\, -below, for definitions of the various authentication protocols.) -.LP -If authentication parameters were rejected, the response message -contains information stating why they were rejected. -.NH 2 -\&Program Number Assignment -.LP -Program numbers are given out in groups of -.I 0x20000000 -(decimal 536870912) according to the following chart: -.TS -box tab (&) ; -lfI lfI -rfL cfI . -Program Numbers&Description -_ -.sp .5 -0 - 1fffffff&Defined by Sun -20000000 - 3fffffff&Defined by user -40000000 - 5fffffff&Transient -60000000 - 7fffffff&Reserved -80000000 - 9fffffff&Reserved -a0000000 - bfffffff&Reserved -c0000000 - dfffffff&Reserved -e0000000 - ffffffff&Reserved -.TE -.LP -The first group is a range of numbers administered by Sun -Microsystems and should be identical for all sites. The second range -is for applications peculiar to a particular site. This range is -intended primarily for debugging new programs. When a site develops -an application that might be of general interest, that application -should be given an assigned number in the first range. The third -group is for applications that generate program numbers dynamically. -The final groups are reserved for future use, and should not be used. -.NH 2 -\&Other Uses of the RPC Protocol -.LP -The intended use of this protocol is for calling remote procedures. -That is, each call message is matched with a response message. -However, the protocol itself is a message-passing protocol with which -other (non-RPC) protocols can be implemented. Sun currently uses, or -perhaps abuses, the RPC message protocol for the following two -(non-RPC) protocols: batching (or pipelining) and broadcast RPC. -These two protocols are discussed but not defined below. -.NH 3 -\&Batching -.LP -Batching allows a client to send an arbitrarily large sequence of -call messages to a server; batching typically uses reliable byte -stream protocols (like TCP/IP) for its transport. In the case of -batching, the client never waits for a reply from the server, and the -server does not send replies to batch requests. A sequence of batch -calls is usually terminated by a legitimate RPC in order to flush the -pipeline (with positive acknowledgement). -.NH 3 -\&Broadcast RPC -.LP -In broadcast RPC-based protocols, the client sends a broadcast packet -to the network and waits for numerous replies. Broadcast RPC uses -unreliable, packet-based protocols (like UDP/IP) as its transports. -Servers that support broadcast protocols only respond when the -request is successfully processed, and are silent in the face of -errors. Broadcast RPC uses the Port Mapper RPC service to achieve -its semantics. See the \fIPort Mapper Program Protocol\fP\, below, -for more information. -.KS -.NH 1 -\&The RPC Message Protocol -.LP -This section defines the RPC message protocol in the XDR data -description language. The message is defined in a top-down style. -.ie t .DS -.el .DS L -.ft CW -enum msg_type { - CALL = 0, - REPLY = 1 -}; - -.ft I -/* -* A reply to a call message can take on two forms: -* The message was either accepted or rejected. -*/ -.ft CW -enum reply_stat { - MSG_ACCEPTED = 0, - MSG_DENIED = 1 -}; - -.ft I -/* -* Given that a call message was accepted, the following is the -* status of an attempt to call a remote procedure. -*/ -.ft CW -enum accept_stat { - SUCCESS = 0, /* \fIRPC executed successfully \fP*/ - PROG_UNAVAIL = 1, /* \fIremote hasn't exported program \fP*/ - PROG_MISMATCH = 2, /* \fIremote can't support version # \fP*/ - PROC_UNAVAIL = 3, /* \fIprogram can't support procedure \fP*/ - GARBAGE_ARGS = 4 /* \fIprocedure can't decode params \fP*/ -}; -.DE -.ie t .DS -.el .DS L -.ft I -/* -* Reasons why a call message was rejected: -*/ -.ft CW -enum reject_stat { - RPC_MISMATCH = 0, /* \fIRPC version number != 2 \fP*/ - AUTH_ERROR = 1 /* \fIremote can't authenticate caller \fP*/ -}; - -.ft I -/* -* Why authentication failed: -*/ -.ft CW -enum auth_stat { - AUTH_BADCRED = 1, /* \fIbad credentials \fP*/ - AUTH_REJECTEDCRED = 2, /* \fIclient must begin new session \fP*/ - AUTH_BADVERF = 3, /* \fIbad verifier \fP*/ - AUTH_REJECTEDVERF = 4, /* \fIverifier expired or replayed \fP*/ - AUTH_TOOWEAK = 5 /* \fIrejected for security reasons \fP*/ -}; -.DE -.KE -.ie t .DS -.el .DS L -.ft I -/* -* The RPC message: -* All messages start with a transaction identifier, xid, -* followed by a two-armed discriminated union. The union's -* discriminant is a msg_type which switches to one of the two -* types of the message. The xid of a \fIREPLY\fP message always -* matches that of the initiating \fICALL\fP message. NB: The xid -* field is only used for clients matching reply messages with -* call messages or for servers detecting retransmissions; the -* service side cannot treat this id as any type of sequence -* number. -*/ -.ft CW -struct rpc_msg { - unsigned int xid; - union switch (msg_type mtype) { - case CALL: - call_body cbody; - case REPLY: - reply_body rbody; - } body; -}; -.DE -.ie t .DS -.el .DS L -.ft I -/* -* Body of an RPC request call: -* In version 2 of the RPC protocol specification, rpcvers must -* be equal to 2. The fields prog, vers, and proc specify the -* remote program, its version number, and the procedure within -* the remote program to be called. After these fields are two -* authentication parameters: cred (authentication credentials) -* and verf (authentication verifier). The two authentication -* parameters are followed by the parameters to the remote -* procedure, which are specified by the specific program -* protocol. -*/ -.ft CW -struct call_body { - unsigned int rpcvers; /* \fImust be equal to two (2) \fP*/ - unsigned int prog; - unsigned int vers; - unsigned int proc; - opaque_auth cred; - opaque_auth verf; - /* \fIprocedure specific parameters start here \fP*/ -}; -.DE -.ie t .DS -.el .DS L -.ft I -/* -* Body of a reply to an RPC request: -* The call message was either accepted or rejected. -*/ -.ft CW -union reply_body switch (reply_stat stat) { - case MSG_ACCEPTED: - accepted_reply areply; - case MSG_DENIED: - rejected_reply rreply; -} reply; -.DE -.ie t .DS -.el .DS L -.ft I -/* -* Reply to an RPC request that was accepted by the server: -* there could be an error even though the request was accepted. -* The first field is an authentication verifier that the server -* generates in order to validate itself to the caller. It is -* followed by a union whose discriminant is an enum -* accept_stat. The \fISUCCESS\fP arm of the union is protocol -* specific. The \fIPROG_UNAVAIL\fP, \fIPROC_UNAVAIL\fP, and \fIGARBAGE_ARGP\fP -* arms of the union are void. The \fIPROG_MISMATCH\fP arm specifies -* the lowest and highest version numbers of the remote program -* supported by the server. -*/ -.ft CW -struct accepted_reply { - opaque_auth verf; - union switch (accept_stat stat) { - case SUCCESS: - opaque results[0]; - /* \fIprocedure-specific results start here\fP */ - case PROG_MISMATCH: - struct { - unsigned int low; - unsigned int high; - } mismatch_info; - default: -.ft I - /* - * Void. Cases include \fIPROG_UNAVAIL, PROC_UNAVAIL\fP, - * and \fIGARBAGE_ARGS\fP. - */ -.ft CW - void; - } reply_data; -}; -.DE -.ie t .DS -.el .DS L -.ft I -/* -* Reply to an RPC request that was rejected by the server: -* The request can be rejected for two reasons: either the -* server is not running a compatible version of the RPC -* protocol (\fIRPC_MISMATCH\fP), or the server refuses to -* authenticate the caller (\fIAUTH_ERROR\fP). In case of an RPC -* version mismatch, the server returns the lowest and highest -* supported RPC version numbers. In case of refused -* authentication, failure status is returned. -*/ -.ft CW -union rejected_reply switch (reject_stat stat) { - case RPC_MISMATCH: - struct { - unsigned int low; - unsigned int high; - } mismatch_info; - case AUTH_ERROR: - auth_stat stat; -}; -.DE -.NH 1 -\&Authentication Protocols -.LP -As previously stated, authentication parameters are opaque, but -open-ended to the rest of the RPC protocol. This section defines -some "flavors" of authentication implemented at (and supported by) -Sun. Other sites are free to invent new authentication types, with -the same rules of flavor number assignment as there is for program -number assignment. -.NH 2 -\&Null Authentication -.LP -Often calls must be made where the caller does not know who he is or -the server does not care who the caller is. In this case, the flavor -value (the discriminant of the \fIopaque_auth\fP's union) of the RPC -message's credentials, verifier, and response verifier is -.I AUTH_NULL . -The bytes of the opaque_auth's body are undefined. -It is recommended that the opaque length be zero. -.NH 2 -\&UNIX Authentication -.LP -The caller of a remote procedure may wish to identify himself as he -is identified on a UNIX system. The value of the credential's -discriminant of an RPC call message is -.I AUTH_UNIX . -The bytes of -the credential's opaque body encode the following structure: -.DS -.ft CW -struct auth_unix { - unsigned int stamp; - string machinename<255>; - unsigned int uid; - unsigned int gid; - unsigned int gids<10>; -}; -.DE -The -.I stamp -is an arbitrary ID which the caller machine may -generate. The -.I machinename -is the name of the caller's machine (like "krypton"). The -.I uid -is the caller's effective user ID. The -.I gid -is the caller's effective group ID. The -.I gids -is a -counted array of groups which contain the caller as a member. The -verifier accompanying the credentials should be of -.I AUTH_NULL -(defined above). -.LP -The value of the discriminant of the response verifier received in -the reply message from the server may be -.I AUTH_NULL -or -.I AUTH_SHORT . -In the case of -.I AUTH_SHORT , -the bytes of the response verifier's string encode an opaque -structure. This new opaque structure may now be passed to the server -instead of the original -.I AUTH_UNIX -flavor credentials. The server keeps a cache which maps shorthand -opaque structures (passed back by way of an -.I AUTH_SHORT -style response verifier) to the original credentials of the caller. -The caller can save network bandwidth and server cpu cycles by using -the new credentials. -.LP -The server may flush the shorthand opaque structure at any time. If -this happens, the remote procedure call message will be rejected due -to an authentication error. The reason for the failure will be -.I AUTH_REJECTEDCRED . -At this point, the caller may wish to try the original -.I AUTH_UNIX -style of credentials. -.KS -.NH 2 -\&DES Authentication -.LP -UNIX authentication suffers from two major problems: -.IP 1. -The naming is too UNIX-system oriented. -.IP 2. -There is no verifier, so credentials can easily be faked. -.LP -DES authentication attempts to fix these two problems. -.KE -.NH 3 -\&Naming -.LP -The first problem is handled by addressing the caller by a simple -string of characters instead of by an operating system specific -integer. This string of characters is known as the "netname" or -network name of the caller. The server is not allowed to interpret -the contents of the caller's name in any other way except to -identify the caller. Thus, netnames should be unique for every -caller in the internet. -.LP -It is up to each operating system's implementation of DES -authentication to generate netnames for its users that insure this -uniqueness when they call upon remote servers. Operating systems -already know how to distinguish users local to their systems. It is -usually a simple matter to extend this mechanism to the network. -For example, a UNIX user at Sun with a user ID of 515 might be -assigned the following netname: "unix.515@sun.com". This netname -contains three items that serve to insure it is unique. Going -backwards, there is only one naming domain called "sun.com" in the -internet. Within this domain, there is only one UNIX user with -user ID 515. However, there may be another user on another -operating system, for example VMS, within the same naming domain -that, by coincidence, happens to have the same user ID. To insure -that these two users can be distinguished we add the operating -system name. So one user is "unix.515@sun.com" and the other is -"vms.515@sun.com". -.LP -The first field is actually a naming method rather than an -operating system name. It just happens that today there is almost -a one-to-one correspondence between naming methods and operating -systems. If the world could agree on a naming standard, the first -field could be the name of that standard, instead of an operating -system name. -.LP -.NH 3 -\&DES Authentication Verifiers -.LP -Unlike UNIX authentication, DES authentication does have a verifier -so the server can validate the client's credential (and -vice-versa). The contents of this verifier is primarily an -encrypted timestamp. The server can decrypt this timestamp, and if -it is close to what the real time is, then the client must have -encrypted it correctly. The only way the client could encrypt it -correctly is to know the "conversation key" of the RPC session. And -if the client knows the conversation key, then it must be the real -client. -.LP -The conversation key is a DES [5] key which the client generates -and notifies the server of in its first RPC call. The conversation -key is encrypted using a public key scheme in this first -transaction. The particular public key scheme used in DES -authentication is Diffie-Hellman [3] with 192-bit keys. The -details of this encryption method are described later. -.LP -The client and the server need the same notion of the current time -in order for all of this to work. If network time synchronization -cannot be guaranteed, then client can synchronize with the server -before beginning the conversation, perhaps by consulting the -Internet Time Server (TIME[4]). -.LP -The way a server determines if a client timestamp is valid is -somewhat complicated. For any other transaction but the first, the -server just checks for two things: -.IP 1. -the timestamp is greater than the one previously seen from the -same client. -.IP 2. -the timestamp has not expired. -.LP -A timestamp is expired if the server's time is later than the sum -of the client's timestamp plus what is known as the client's -"window". The "window" is a number the client passes (encrypted) -to the server in its first transaction. You can think of it as a -lifetime for the credential. -.LP -This explains everything but the first transaction. In the first -transaction, the server checks only that the timestamp has not -expired. If this was all that was done though, then it would be -quite easy for the client to send random data in place of the -timestamp with a fairly good chance of succeeding. As an added -check, the client sends an encrypted item in the first transaction -known as the "window verifier" which must be equal to the window -minus 1, or the server will reject the credential. -.LP -The client too must check the verifier returned from the server to -be sure it is legitimate. The server sends back to the client the -encrypted timestamp it received from the client, minus one second. -If the client gets anything different than this, it will reject it. -.LP -.NH 3 -\&Nicknames and Clock Synchronization -.LP -After the first transaction, the server's DES authentication -subsystem returns in its verifier to the client an integer -"nickname" which the client may use in its further transactions -instead of passing its netname, encrypted DES key and window every -time. The nickname is most likely an index into a table on the -server which stores for each client its netname, decrypted DES key -and window. -.LP -Though they originally were synchronized, the client's and server's -clocks can get out of sync again. When this happens the client RPC -subsystem most likely will get back -.I RPC_AUTHERROR -at which point it should resynchronize. -.LP -A client may still get the -.I RPC_AUTHERROR -error even though it is -synchronized with the server. The reason is that the server's -nickname table is a limited size, and it may flush entries whenever -it wants. A client should resend its original credential in this -case and the server will give it a new nickname. If a server -crashes, the entire nickname table gets flushed, and all clients -will have to resend their original credentials. -.KS -.NH 3 -\&DES Authentication Protocol (in XDR language) -.ie t .DS -.el .DS L -.ft I -/* -* There are two kinds of credentials: one in which the client uses -* its full network name, and one in which it uses its "nickname" -* (just an unsigned integer) given to it by the server. The -* client must use its fullname in its first transaction with the -* server, in which the server will return to the client its -* nickname. The client may use its nickname in all further -* transactions with the server. There is no requirement to use the -* nickname, but it is wise to use it for performance reasons. -*/ -.ft CW -enum authdes_namekind { - ADN_FULLNAME = 0, - ADN_NICKNAME = 1 -}; - -.ft I -/* -* A 64-bit block of encrypted DES data -*/ -.ft CW -typedef opaque des_block[8]; - -.ft I -/* -* Maximum length of a network user's name -*/ -.ft CW -const MAXNETNAMELEN = 255; - -.ft I -/* -* A fullname contains the network name of the client, an encrypted -* conversation key and the window. The window is actually a -* lifetime for the credential. If the time indicated in the -* verifier timestamp plus the window has past, then the server -* should expire the request and not grant it. To insure that -* requests are not replayed, the server should insist that -* timestamps are greater than the previous one seen, unless it is -* the first transaction. In the first transaction, the server -* checks instead that the window verifier is one less than the -* window. -*/ -.ft CW -struct authdes_fullname { -string name; /* \fIname of client \f(CW*/ -des_block key; /* \fIPK encrypted conversation key \f(CW*/ -unsigned int window; /* \fIencrypted window \f(CW*/ -}; - -.ft I -/* -* A credential is either a fullname or a nickname -*/ -.ft CW -union authdes_cred switch (authdes_namekind adc_namekind) { - case ADN_FULLNAME: - authdes_fullname adc_fullname; - case ADN_NICKNAME: - unsigned int adc_nickname; -}; - -.ft I -/* -* A timestamp encodes the time since midnight, January 1, 1970. -*/ -.ft CW -struct timestamp { - unsigned int seconds; /* \fIseconds \fP*/ - unsigned int useconds; /* \fIand microseconds \fP*/ -}; - -.ft I -/* -* Verifier: client variety -* The window verifier is only used in the first transaction. In -* conjunction with a fullname credential, these items are packed -* into the following structure before being encrypted: -* -* \f(CWstruct {\fP -* \f(CWadv_timestamp; \fP-- one DES block -* \f(CWadc_fullname.window; \fP-- one half DES block -* \f(CWadv_winverf; \fP-- one half DES block -* \f(CW}\fP -* This structure is encrypted using CBC mode encryption with an -* input vector of zero. All other encryptions of timestamps use -* ECB mode encryption. -*/ -.ft CW -struct authdes_verf_clnt { - timestamp adv_timestamp; /* \fIencrypted timestamp \fP*/ - unsigned int adv_winverf; /* \fIencrypted window verifier \fP*/ -}; - -.ft I -/* -* Verifier: server variety -* The server returns (encrypted) the same timestamp the client -* gave it minus one second. It also tells the client its nickname -* to be used in future transactions (unencrypted). -*/ -.ft CW -struct authdes_verf_svr { -timestamp adv_timeverf; /* \fIencrypted verifier \fP*/ -unsigned int adv_nickname; /* \fInew nickname for client \fP*/ -}; -.DE -.KE -.NH 3 -\&Diffie-Hellman Encryption -.LP -In this scheme, there are two constants, -.I BASE -and -.I MODULUS . -The -particular values Sun has chosen for these for the DES -authentication protocol are: -.ie t .DS -.el .DS L -.ft CW -const BASE = 3; -const MODULUS = - "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; /* \fIhex \fP*/ -.DE -.ft R -The way this scheme works is best explained by an example. Suppose -there are two people "A" and "B" who want to send encrypted -messages to each other. So, A and B both generate "secret" keys at -random which they do not reveal to anyone. Let these keys be -represented as SK(A) and SK(B). They also publish in a public -directory their "public" keys. These keys are computed as follows: -.ie t .DS -.el .DS L -.ft CW -PK(A) = ( BASE ** SK(A) ) mod MODULUS -PK(B) = ( BASE ** SK(B) ) mod MODULUS -.DE -.ft R -The "**" notation is used here to represent exponentiation. Now, -both A and B can arrive at the "common" key between them, -represented here as CK(A, B), without revealing their secret keys. -.LP -A computes: -.ie t .DS -.el .DS L -.ft CW -CK(A, B) = ( PK(B) ** SK(A)) mod MODULUS -.DE -.ft R -while B computes: -.ie t .DS -.el .DS L -.ft CW -CK(A, B) = ( PK(A) ** SK(B)) mod MODULUS -.DE -.ft R -These two can be shown to be equivalent: -.ie t .DS -.el .DS L -.ft CW -(PK(B) ** SK(A)) mod MODULUS = (PK(A) ** SK(B)) mod MODULUS -.DE -.ft R -We drop the "mod MODULUS" parts and assume modulo arithmetic to -simplify things: -.ie t .DS -.el .DS L -.ft CW -PK(B) ** SK(A) = PK(A) ** SK(B) -.DE -.ft R -Then, replace PK(B) by what B computed earlier and likewise for -PK(A). -.ie t .DS -.el .DS L -.ft CW -((BASE ** SK(B)) ** SK(A) = (BASE ** SK(A)) ** SK(B) -.DE -.ft R -which leads to: -.ie t .DS -.el .DS L -.ft CW -BASE ** (SK(A) * SK(B)) = BASE ** (SK(A) * SK(B)) -.DE -.ft R -This common key CK(A, B) is not used to encrypt the timestamps used -in the protocol. Rather, it is used only to encrypt a conversation -key which is then used to encrypt the timestamps. The reason for -doing this is to use the common key as little as possible, for fear -that it could be broken. Breaking the conversation key is a far -less serious offense, since conversations are relatively -short-lived. -.LP -The conversation key is encrypted using 56-bit DES keys, yet the -common key is 192 bits. To reduce the number of bits, 56 bits are -selected from the common key as follows. The middle-most 8-bytes -are selected from the common key, and then parity is added to the -lower order bit of each byte, producing a 56-bit key with 8 bits of -parity. -.KS -.NH 1 -\&Record Marking Standard -.LP -When RPC messages are passed on top of a byte stream protocol (like -TCP/IP), it is necessary, or at least desirable, to delimit one -message from another in order to detect and possibly recover from -user protocol errors. This is called record marking (RM). Sun uses -this RM/TCP/IP transport for passing RPC messages on TCP streams. -One RPC message fits into one RM record. -.LP -A record is composed of one or more record fragments. A record -fragment is a four-byte header followed by 0 to (2**31) - 1 bytes of -fragment data. The bytes encode an unsigned binary number; as with -XDR integers, the byte order is from highest to lowest. The number -encodes two values\(ema boolean which indicates whether the fragment -is the last fragment of the record (bit value 1 implies the fragment -is the last fragment) and a 31-bit unsigned binary value which is the -length in bytes of the fragment's data. The boolean value is the -highest-order bit of the header; the length is the 31 low-order bits. -(Note that this record specification is NOT in XDR standard form!) -.KE -.KS -.NH 1 -\&The RPC Language -.LP -Just as there was a need to describe the XDR data-types in a formal -language, there is also need to describe the procedures that operate -on these XDR data-types in a formal language as well. We use the RPC -Language for this purpose. It is an extension to the XDR language. -The following example is used to describe the essence of the -language. -.NH 2 -\&An Example Service Described in the RPC Language -.LP -Here is an example of the specification of a simple ping program. -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* -* Simple ping program -*/ -.ft CW -program PING_PROG { - /* \fILatest and greatest version\fP */ - version PING_VERS_PINGBACK { - void - PINGPROC_NULL(void) = 0; - -.ft I - /* - * Ping the caller, return the round-trip time - * (in microseconds). Returns -1 if the operation - * timed out. - */ -.ft CW - int - PINGPROC_PINGBACK(void) = 1; -} = 2; - -.ft I -/* -* Original version -*/ -.ft CW -version PING_VERS_ORIG { - void - PINGPROC_NULL(void) = 0; - } = 1; -} = 1; - -const PING_VERS = 2; /* \fIlatest version \fP*/ -.vs -.DE -.KE -.LP -The first version described is -.I PING_VERS_PINGBACK -with two procedures, -.I PINGPROC_NULL -and -.I PINGPROC_PINGBACK . -.I PINGPROC_NULL -takes no arguments and returns no results, but it is useful for -computing round-trip times from the client to the server and back -again. By convention, procedure 0 of any RPC protocol should have -the same semantics, and never require any kind of authentication. -The second procedure is used for the client to have the server do a -reverse ping operation back to the client, and it returns the amount -of time (in microseconds) that the operation used. The next version, -.I PING_VERS_ORIG , -is the original version of the protocol -and it does not contain -.I PINGPROC_PINGBACK -procedure. It is useful -for compatibility with old client programs, and as this program -matures it may be dropped from the protocol entirely. -.KS -.NH 2 -\&The RPC Language Specification -.LP -The RPC language is identical to the XDR language, except for the -added definition of a -.I program-def -described below. -.DS -.ft CW -program-def: - "program" identifier "{" - version-def - version-def * - "}" "=" constant ";" - -version-def: - "version" identifier "{" - procedure-def - procedure-def * - "}" "=" constant ";" - -procedure-def: - type-specifier identifier "(" type-specifier ")" - "=" constant ";" -.DE -.KE -.NH 2 -\&Syntax Notes -.IP 1. -The following keywords are added and cannot be used as -identifiers: "program" and "version"; -.IP 2. -A version name cannot occur more than once within the scope of -a program definition. Nor can a version number occur more than once -within the scope of a program definition. -.IP 3. -A procedure name cannot occur more than once within the scope -of a version definition. Nor can a procedure number occur more than -once within the scope of version definition. -.IP 4. -Program identifiers are in the same name space as constant and -type identifiers. -.IP 5. -Only unsigned constants can be assigned to programs, versions -and procedures. -.NH 1 -\&Port Mapper Program Protocol -.LP -The port mapper program maps RPC program and version numbers to -transport-specific port numbers. This program makes dynamic binding -of remote programs possible. -.LP -This is desirable because the range of reserved port numbers is very -small and the number of potential remote programs is very large. By -running only the port mapper on a reserved port, the port numbers of -other remote programs can be ascertained by querying the port mapper. -.LP -The port mapper also aids in broadcast RPC. A given RPC program will -usually have different port number bindings on different machines, so -there is no way to directly broadcast to all of these programs. The -port mapper, however, does have a fixed port number. So, to -broadcast to a given program, the client actually sends its message -to the port mapper located at the broadcast address. Each port -mapper that picks up the broadcast then calls the local service -specified by the client. When the port mapper gets the reply from -the local service, it sends the reply on back to the client. -.KS -.NH 2 -\&Port Mapper Protocol Specification (in RPC Language) -.ie t .DS -.el .DS L -.ft CW -.vs 11 -const PMAP_PORT = 111; /* \fIportmapper port number \fP*/ - -.ft I -/* -* A mapping of (program, version, protocol) to port number -*/ -.ft CW -struct mapping { - unsigned int prog; - unsigned int vers; - unsigned int prot; - unsigned int port; -}; - -.ft I -/* -* Supported values for the "prot" field -*/ -.ft CW -const IPPROTO_TCP = 6; /* \fIprotocol number for TCP/IP \fP*/ -const IPPROTO_UDP = 17; /* \fIprotocol number for UDP/IP \fP*/ - -.ft I -/* -* A list of mappings -*/ -.ft CW -struct *pmaplist { - mapping map; - pmaplist next; -}; -.vs -.DE -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* -* Arguments to callit -*/ -.ft CW -struct call_args { - unsigned int prog; - unsigned int vers; - unsigned int proc; - opaque args<>; -}; - -.ft I -/* -* Results of callit -*/ -.ft CW -struct call_result { - unsigned int port; - opaque res<>; -}; -.vs -.DE -.KE -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* -* Port mapper procedures -*/ -.ft CW -program PMAP_PROG { - version PMAP_VERS { - void - PMAPPROC_NULL(void) = 0; - - bool - PMAPPROC_SET(mapping) = 1; - - bool - PMAPPROC_UNSET(mapping) = 2; - - unsigned int - PMAPPROC_GETPORT(mapping) = 3; - - pmaplist - PMAPPROC_DUMP(void) = 4; - - call_result - PMAPPROC_CALLIT(call_args) = 5; - } = 2; -} = 100000; -.vs -.DE -.NH 2 -\&Port Mapper Operation -.LP -The portmapper program currently supports two protocols (UDP/IP and -TCP/IP). The portmapper is contacted by talking to it on assigned -port number 111 (SUNRPC [8]) on either of these protocols. The -following is a description of each of the portmapper procedures: -.IP \fBPMAPPROC_NULL:\fP -This procedure does no work. By convention, procedure zero of any -protocol takes no parameters and returns no results. -.IP \fBPMAPPROC_SET:\fP -When a program first becomes available on a machine, it registers -itself with the port mapper program on the same machine. The program -passes its program number "prog", version number "vers", transport -protocol number "prot", and the port "port" on which it awaits -service request. The procedure returns a boolean response whose -value is -.I TRUE -if the procedure successfully established the mapping and -.I FALSE -otherwise. The procedure refuses to establish -a mapping if one already exists for the tuple "(prog, vers, prot)". -.IP \fBPMAPPROC_UNSET:\fP -When a program becomes unavailable, it should unregister itself with -the port mapper program on the same machine. The parameters and -results have meanings identical to those of -.I PMAPPROC_SET . -The protocol and port number fields of the argument are ignored. -.IP \fBPMAPPROC_GETPORT:\fP -Given a program number "prog", version number "vers", and transport -protocol number "prot", this procedure returns the port number on -which the program is awaiting call requests. A port value of zeros -means the program has not been registered. The "port" field of the -argument is ignored. -.IP \fBPMAPPROC_DUMP:\fP -This procedure enumerates all entries in the port mapper's database. -The procedure takes no parameters and returns a list of program, -version, protocol, and port values. -.IP \fBPMAPPROC_CALLIT:\fP -This procedure allows a caller to call another remote procedure on -the same machine without knowing the remote procedure's port number. -It is intended for supporting broadcasts to arbitrary remote programs -via the well-known port mapper's port. The parameters "prog", -"vers", "proc", and the bytes of "args" are the program number, -version number, procedure number, and parameters of the remote -procedure. -.LP -.B Note: -.RS -.IP 1. -This procedure only sends a response if the procedure was -successfully executed and is silent (no response) otherwise. -.IP 2. -The port mapper communicates with the remote program using UDP/IP -only. -.RE -.LP -The procedure returns the remote program's port number, and the bytes -of results are the results of the remote procedure. -.bp -.NH 1 -\&References -.LP -[1] Birrell, Andrew D. & Nelson, Bruce Jay; "Implementing Remote -Procedure Calls"; XEROX CSL-83-7, October 1983. -.LP -[2] Cheriton, D.; "VMTP: Versatile Message Transaction Protocol", -Preliminary Version 0.3; Stanford University, January 1987. -.LP -[3] Diffie & Hellman; "New Directions in Cryptography"; IEEE -Transactions on Information Theory IT-22, November 1976. -.LP -[4] Harrenstien, K.; "Time Server", RFC 738; Information Sciences -Institute, October 1977. -.LP -[5] National Bureau of Standards; "Data Encryption Standard"; Federal -Information Processing Standards Publication 46, January 1977. -.LP -[6] Postel, J.; "Transmission Control Protocol - DARPA Internet -Program Protocol Specification", RFC 793; Information Sciences -Institute, September 1981. -.LP -[7] Postel, J.; "User Datagram Protocol", RFC 768; Information Sciences -Institute, August 1980. -.LP -[8] Reynolds, J. & Postel, J.; "Assigned Numbers", RFC 923; Information -Sciences Institute, October 1984. diff --git a/lib/librpc/doc/rpcgen.ms b/lib/librpc/doc/rpcgen.ms deleted file mode 100644 index b4e50e5d6f04..000000000000 --- a/lib/librpc/doc/rpcgen.ms +++ /dev/null @@ -1,1299 +0,0 @@ -.\" -.\" Must use -- tbl -- for this one -.\" -.\" @(#)rpcgen.ms 2.2 88/08/04 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH '\fBrpcgen\fP Programming Guide''Page %' -.EH 'Page %''\fBrpcgen\fP Programming Guide' -.if \\n%=1 .bp -.SH -\&\fBrpcgen\fP Programming Guide -.NH 0 -\&The \fBrpcgen\fP Protocol Compiler -.IX rpcgen "" \fIrpcgen\fP "" PAGE MAJOR -.LP -.IX RPC "" "" \fIrpcgen\fP -The details of programming applications to use Remote Procedure Calls -can be overwhelming. Perhaps most daunting is the writing of the XDR -routines necessary to convert procedure arguments and results into -their network format and vice-versa. -.LP -Fortunately, -.I rpcgen(1) -exists to help programmers write RPC applications simply and directly. -.I rpcgen -does most of the dirty work, allowing programmers to debug -the main features of their application, instead of requiring them to -spend most of their time debugging their network interface code. -.LP -.I rpcgen -is a compiler. It accepts a remote program interface definition written -in a language, called RPC Language, which is similar to C. It produces a C -language output which includes stub versions of the client routines, a -server skeleton, XDR filter routines for both parameters and results, and a -header file that contains common definitions. The client stubs interface -with the RPC library and effectively hide the network from their callers. -The server stub similarly hides the network from the server procedures that -are to be invoked by remote clients. -.I rpcgen 's -output files can be compiled and linked in the usual way. The developer -writes server procedures\(emin any language that observes Sun calling -conventions\(emand links them with the server skeleton produced by -.I rpcgen -to get an executable server program. To use a remote program, a programmer -writes an ordinary main program that makes local procedure calls to the -client stubs produced by -.I rpcgen . -Linking this program with -.I rpcgen 's -stubs creates an executable program. (At present the main program must be -written in C). -.I rpcgen -options can be used to suppress stub generation and to specify the transport -to be used by the server stub. -.LP -Like all compilers, -.I rpcgen -reduces development time -that would otherwise be spent coding and debugging low-level routines. -All compilers, including -.I rpcgen , -do this at a small cost in efficiency -and flexibility. However, many compilers allow escape hatches for -programmers to mix low-level code with high-level code. -.I rpcgen -is no exception. In speed-critical applications, hand-written routines -can be linked with the -.I rpcgen -output without any difficulty. Also, one may proceed by using -.I rpcgen -output as a starting point, and then rewriting it as necessary. -(If you need a discussion of RPC programming without -.I rpcgen , -see the -.I "Remote Procedure Call Programming Guide)\. -.NH 1 -\&Converting Local Procedures into Remote Procedures -.IX rpcgen "local procedures" \fIrpcgen\fP -.IX rpcgen "remote procedures" \fIrpcgen\fP -.LP -Assume an application that runs on a single machine, one which we want -to convert to run over the network. Here we will demonstrate such a -conversion by way of a simple example\(ema program that prints a -message to the console: -.ie t .DS -.el .DS L -.ft I -/* - * printmsg.c: print a message on the console - */ -.ft CW -#include - -main(argc, argv) - int argc; - char *argv[]; -{ - char *message; - - if (argc < 2) { - fprintf(stderr, "usage: %s \en", argv[0]); - exit(1); - } - message = argv[1]; - - if (!printmessage(message)) { - fprintf(stderr, "%s: couldn't print your message\en", - argv[0]); - exit(1); - } - printf("Message Delivered!\en"); - exit(0); -} -.ft I -/* - * Print a message to the console. - * Return a boolean indicating whether the message was actually printed. - */ -.ft CW -printmessage(msg) - char *msg; -{ - FILE *f; - - f = fopen("/dev/console", "w"); - if (f == NULL) { - return (0); - } - fprintf(f, "%s\en", msg); - fclose(f); - return(1); -} -.DE -.LP -And then, of course: -.ie t .DS -.el .DS L -.ft CW -example% \fBcc printmsg.c -o printmsg\fP -example% \fBprintmsg "Hello, there."\fP -Message delivered! -example% -.DE -.LP -If -.I printmessage() -was turned into a remote procedure, -then it could be called from anywhere in the network. -Ideally, one would just like to stick a keyword like -.I remote -in front of a -procedure to turn it into a remote procedure. Unfortunately, -we have to live within the constraints of the C language, since -it existed long before RPC did. But even without language -support, it's not very difficult to make a procedure remote. -.LP -In general, it's necessary to figure out what the types are for -all procedure inputs and outputs. In this case, we have a -procedure -.I printmessage() -which takes a string as input, and returns an integer -as output. Knowing this, we can write a protocol specification in RPC -language that describes the remote version of -.I printmessage (). -Here it is: -.ie t .DS -.el .DS L -.ft I -/* - * msg.x: Remote message printing protocol - */ -.ft CW - -program MESSAGEPROG { - version MESSAGEVERS { - int PRINTMESSAGE(string) = 1; - } = 1; -} = 99; -.DE -.LP -Remote procedures are part of remote programs, so we actually declared -an entire remote program here which contains the single procedure -.I PRINTMESSAGE . -This procedure was declared to be in version 1 of the -remote program. No null procedure (procedure 0) is necessary because -.I rpcgen -generates it automatically. -.LP -Notice that everything is declared with all capital letters. This is -not required, but is a good convention to follow. -.LP -Notice also that the argument type is \*Qstring\*U and not \*Qchar *\*U. This -is because a \*Qchar *\*U in C is ambiguous. Programmers usually intend it -to mean a null-terminated string of characters, but it could also -represent a pointer to a single character or a pointer to an array of -characters. In RPC language, a null-terminated string is -unambiguously called a \*Qstring\*U. -.LP -There are just two more things to write. First, there is the remote -procedure itself. Here's the definition of a remote procedure -to implement the -.I PRINTMESSAGE -procedure we declared above: -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * msg_proc.c: implementation of the remote procedure "printmessage" - */ -.ft CW - -#include -#include /* \fIalways needed\fP */ -#include "msg.h" /* \fIneed this too: msg.h will be generated by rpcgen\fP */ - -.ft I -/* - * Remote verson of "printmessage" - */ -.ft CW -int * -printmessage_1(msg) - char **msg; -{ - static int result; /* \fImust be static!\fP */ - FILE *f; - - f = fopen("/dev/console", "w"); - if (f == NULL) { - result = 0; - return (&result); - } - fprintf(f, "%s\en", *msg); - fclose(f); - result = 1; - return (&result); -} -.vs -.DE -.LP -Notice here that the declaration of the remote procedure -.I printmessage_1() -differs from that of the local procedure -.I printmessage() -in three ways: -.IP 1. -It takes a pointer to a string instead of a string itself. This -is true of all remote procedures: they always take pointers to their -arguments rather than the arguments themselves. -.IP 2. -It returns a pointer to an integer instead of an integer itself. This is -also generally true of remote procedures: they always return a pointer -to their results. -.IP 3. -It has an \*Q_1\*U appended to its name. In general, all remote -procedures called by -.I rpcgen -are named by the following rule: the name in the program definition -(here -.I PRINTMESSAGE ) -is converted to all -lower-case letters, an underbar (\*Q_\*U) is appended to it, and -finally the version number (here 1) is appended. -.LP -The last thing to do is declare the main client program that will call -the remote procedure. Here it is: -.ie t .DS -.el .DS L -.ft I -/* - * rprintmsg.c: remote version of "printmsg.c" - */ -.ft CW -#include -#include /* \fIalways needed\fP */ -#include "msg.h" /* \fIneed this too: msg.h will be generated by rpcgen\fP */ - -main(argc, argv) - int argc; - char *argv[]; -{ - CLIENT *cl; - int *result; - char *server; - char *message; - - if (argc < 3) { - fprintf(stderr, "usage: %s host message\en", argv[0]); - exit(1); - } - -.ft I - /* - * Save values of command line arguments - */ -.ft CW - server = argv[1]; - message = argv[2]; - -.ft I - /* - * Create client "handle" used for calling \fIMESSAGEPROG\fP on the - * server designated on the command line. We tell the RPC package - * to use the "tcp" protocol when contacting the server. - */ -.ft CW - cl = clnt_create(server, MESSAGEPROG, MESSAGEVERS, "tcp"); - if (cl == NULL) { -.ft I - /* - * Couldn't establish connection with server. - * Print error message and die. - */ -.ft CW - clnt_pcreateerror(server); - exit(1); - } - -.ft I - /* - * Call the remote procedure "printmessage" on the server - */ -.ft CW - result = printmessage_1(&message, cl); - if (result == NULL) { -.ft I - /* - * An error occurred while calling the server. - * Print error message and die. - */ -.ft CW - clnt_perror(cl, server); - exit(1); - } - -.ft I - /* - * Okay, we successfully called the remote procedure. - */ -.ft CW - if (*result == 0) { -.ft I - /* - * Server was unable to print our message. - * Print error message and die. - */ -.ft CW - fprintf(stderr, "%s: %s couldn't print your message\en", - argv[0], server); - exit(1); - } - -.ft I - /* - * The message got printed on the server's console - */ -.ft CW - printf("Message delivered to %s!\en", server); -} -.DE -There are two things to note here: -.IP 1. -.IX "client handle, used by rpcgen" "" "client handle, used by \fIrpcgen\fP" -First a client \*Qhandle\*U is created using the RPC library routine -.I clnt_create (). -This client handle will be passed to the stub routines -which call the remote procedure. -.IP 2. -The remote procedure -.I printmessage_1() -is called exactly the same way as it is declared in -.I msg_proc.c -except for the inserted client handle as the first argument. -.LP -Here's how to put all of the pieces together: -.ie t .DS -.el .DS L -.ft CW -example% \fBrpcgen msg.x\fP -example% \fBcc rprintmsg.c msg_clnt.c -o rprintmsg\fP -example% \fBcc msg_proc.c msg_svc.c -o msg_server\fP -.DE -Two programs were compiled here: the client program -.I rprintmsg -and the server program -.I msg_server . -Before doing this though, -.I rpcgen -was used to fill in the missing pieces. -.LP -Here is what -.I rpcgen -did with the input file -.I msg.x : -.IP 1. -It created a header file called -.I msg.h -that contained -.I #define 's -for -.I MESSAGEPROG , -.I MESSAGEVERS -and -.I PRINTMESSAGE -for use in the other modules. -.IP 2. -It created client \*Qstub\*U routines in the -.I msg_clnt.c -file. In this case there is only one, the -.I printmessage_1() -that was referred to from the -.I printmsg -client program. The name of the output file for -client stub routines is always formed in this way: if the name of the -input file is -.I FOO.x , -the client stubs output file is called -.I FOO_clnt.c . -.IP 3. -It created the server program which calls -.I printmessage_1() -in -.I msg_proc.c . -This server program is named -.I msg_svc.c . -The rule for naming the server output file is similar to the -previous one: for an input file called -.I FOO.x , -the output server file is named -.I FOO_svc.c . -.LP -Now we're ready to have some fun. First, copy the server to a -remote machine and run it. For this example, the -machine is called \*Qmoon\*U. Server processes are run in the -background, because they never exit. -.ie t .DS -.el .DS L -.ft CW -moon% \fBmsg_server &\fP -.DE -Then on our local machine (\*Qsun\*U) we can print a message on \*Qmoon\*Us -console. -.ie t .DS -.el .DS L -.ft CW -sun% \fBprintmsg moon "Hello, moon."\fP -.DE -The message will get printed to \*Qmoon\*Us console. You can print a -message on anybody's console (including your own) with this program if -you are able to copy the server to their machine and run it. -.NH 1 -\&Generating XDR Routines -.IX RPC "generating XDR routines" -.LP -The previous example only demonstrated the automatic generation of -client and server RPC code. -.I rpcgen -may also be used to generate XDR routines, that is, the routines -necessary to convert local data -structures into network format and vice-versa. This example presents -a complete RPC service\(ema remote directory listing service, which uses -.I rpcgen -not only to generate stub routines, but also to generate the XDR -routines. Here is the protocol description file: -.ie t .DS -.el .DS L -.ft I -/* - * dir.x: Remote directory listing protocol - */ -.ft CW -const MAXNAMELEN = 255; /* \fImaximum length of a directory entry\fP */ - -typedef string nametype; /* \fIa directory entry\fP */ - -typedef struct namenode *namelist; /* \fIa link in the listing\fP */ - -.ft I -/* - * A node in the directory listing - */ -.ft CW -struct namenode { - nametype name; /* \fIname of directory entry\fP */ - namelist next; /* \fInext entry\fP */ -}; - -.ft I -/* - * The result of a READDIR operation. - */ -.ft CW -union readdir_res switch (int errno) { -case 0: - namelist list; /* \fIno error: return directory listing\fP */ -default: - void; /* \fIerror occurred: nothing else to return\fP */ -}; - -.ft I -/* - * The directory program definition - */ -.ft CW -program DIRPROG { - version DIRVERS { - readdir_res - READDIR(nametype) = 1; - } = 1; -} = 76; -.DE -.SH -Note: -.I -Types (like -.I readdir_res -in the example above) can be defined using -the \*Qstruct\*U, \*Qunion\*U and \*Qenum\*U keywords, but those keywords -should not be used in subsequent declarations of variables of those types. -For example, if you define a union \*Qfoo\*U, you should declare using -only \*Qfoo\*U and not \*Qunion foo\*U. In fact, -.I rpcgen -compiles -RPC unions into C structures and it is an error to declare them using the -\*Qunion\*U keyword. -.LP -Running -.I rpcgen -on -.I dir.x -creates four output files. Three are the same as before: header file, -client stub routines and server skeleton. The fourth are the XDR routines -necessary for converting the data types we declared into XDR format and -vice-versa. These are output in the file -.I dir_xdr.c . -.LP -Here is the implementation of the -.I READDIR -procedure. -.ie t .DS -.el .DS L -.vs 11 -.ft I -/* - * dir_proc.c: remote readdir implementation - */ -.ft CW -#include -#include -#include "dir.h" - -extern int errno; -extern char *malloc(); -extern char *strdup(); - -readdir_res * -readdir_1(dirname) - nametype *dirname; -{ - DIR *dirp; - struct direct *d; - namelist nl; - namelist *nlp; - static readdir_res res; /* \fImust be static\fP! */ - -.ft I - /* - * Open directory - */ -.ft CW - dirp = opendir(*dirname); - if (dirp == NULL) { - res.errno = errno; - return (&res); - } - -.ft I - /* - * Free previous result - */ -.ft CW - xdr_free(xdr_readdir_res, &res); - -.ft I - /* - * Collect directory entries. - * Memory allocated here will be freed by \fIxdr_free\fP - * next time \fIreaddir_1\fP is called - */ -.ft CW - nlp = &res.readdir_res_u.list; - while (d = readdir(dirp)) { - nl = *nlp = (namenode *) malloc(sizeof(namenode)); - nl->name = strdup(d->d_name); - nlp = &nl->next; - } - *nlp = NULL; - -.ft I - /* - * Return the result - */ -.ft CW - res.errno = 0; - closedir(dirp); - return (&res); -} -.vs -.DE -Finally, there is the client side program to call the server: -.ie t .DS -.el .DS L -.ft I -/* - * rls.c: Remote directory listing client - */ -.ft CW -#include -#include /* \fIalways need this\fP */ -#include "dir.h" /* \fIwill be generated by rpcgen\fI */ - -extern int errno; - -main(argc, argv) - int argc; - char *argv[]; -{ - CLIENT *cl; - char *server; - char *dir; - readdir_res *result; - namelist nl; - - - if (argc != 3) { - fprintf(stderr, "usage: %s host directory\en", - argv[0]); - exit(1); - } - -.ft I - /* - * Remember what our command line arguments refer to - */ -.ft CW - server = argv[1]; - dir = argv[2]; - -.ft I - /* - * Create client "handle" used for calling \fIMESSAGEPROG\fP on the - * server designated on the command line. We tell the RPC package - * to use the "tcp" protocol when contacting the server. - */ -.ft CW - cl = clnt_create(server, DIRPROG, DIRVERS, "tcp"); - if (cl == NULL) { -.ft I - /* - * Couldn't establish connection with server. - * Print error message and die. - */ -.ft CW - clnt_pcreateerror(server); - exit(1); - } - -.ft I - /* - * Call the remote procedure \fIreaddir\fP on the server - */ -.ft CW - result = readdir_1(&dir, cl); - if (result == NULL) { -.ft I - /* - * An error occurred while calling the server. - * Print error message and die. - */ -.ft CW - clnt_perror(cl, server); - exit(1); - } - -.ft I - /* - * Okay, we successfully called the remote procedure. - */ -.ft CW - if (result->errno != 0) { -.ft I - /* - * A remote system error occurred. - * Print error message and die. - */ -.ft CW - errno = result->errno; - perror(dir); - exit(1); - } - -.ft I - /* - * Successfully got a directory listing. - * Print it out. - */ -.ft CW - for (nl = result->readdir_res_u.list; nl != NULL; - nl = nl->next) { - printf("%s\en", nl->name); - } - exit(0); -} -.DE -Compile everything, and run. -.DS -.ft CW -sun% \fBrpcgen dir.x\fP -sun% \fBcc rls.c dir_clnt.c dir_xdr.c -o rls\fP -sun% \fBcc dir_svc.c dir_proc.c dir_xdr.c -o dir_svc\fP - -sun% \fBdir_svc &\fP - -moon% \fBrls sun /usr/pub\fP -\&. -\&.. -ascii -eqnchar -greek -kbd -marg8 -tabclr -tabs -tabs4 -moon% -.DE -.LP -.IX "debugging with rpcgen" "" "debugging with \fIrpcgen\fP" -A final note about -.I rpcgen : -The client program and the server procedure can be tested together -as a single program by simply linking them with each other rather -than with the client and server stubs. The procedure calls will be -executed as ordinary local procedure calls and the program can be -debugged with a local debugger such as -.I dbx . -When the program is working, the client program can be linked to -the client stub produced by -.I rpcgen -and the server procedures can be linked to the server stub produced -by -.I rpcgen . -.SH -.I NOTE : -\fIIf you do this, you may want to comment out calls to RPC library -routines, and have client-side routines call server routines -directly.\fP -.LP -.NH 1 -\&The C-Preprocessor -.IX rpcgen "C-preprocessor" \fIrpcgen\fP -.LP -The C-preprocessor is run on all input files before they are -compiled, so all the preprocessor directives are legal within a \*Q.x\*U -file. Four symbols may be defined, depending upon which output file is -getting generated. The symbols are: -.TS -box tab (&); -lfI lfI -lfL l . -Symbol&Usage -_ -RPC_HDR&for header-file output -RPC_XDR&for XDR routine output -RPC_SVC&for server-skeleton output -RPC_CLNT&for client stub output -.TE -.LP -Also, -.I rpcgen -does a little preprocessing of its own. Any line that -begins with a percent sign is passed directly into the output file, -without any interpretation of the line. Here is a simple example that -demonstrates the preprocessing features. -.ie t .DS -.el .DS L -.ft I -/* - * time.x: Remote time protocol - */ -.ft CW -program TIMEPROG { - version TIMEVERS { - unsigned int TIMEGET(void) = 1; - } = 1; -} = 44; - -#ifdef RPC_SVC -%int * -%timeget_1() -%{ -% static int thetime; -% -% thetime = time(0); -% return (&thetime); -%} -#endif -.DE -The '%' feature is not generally recommended, as there is no guarantee -that the compiler will stick the output where you intended. -.NH 1 -\&\fBrpcgen\fP Programming Notes -.IX rpcgen "other operations" \fIrpcgen\fP -.sp -.NH 2 -\&Timeout Changes -.IX rpcgen "timeout changes" \fIrpcgen\fP -.LP -RPC sets a default timeout of 25 seconds for RPC calls when -.I clnt_create() -is used. This timeout may be changed using -.I clnt_control() -Here is a small code fragment to demonstrate use of -.I clnt_control (): -.ID -struct timeval tv; -CLIENT *cl; -.sp .5 -cl = clnt_create("somehost", SOMEPROG, SOMEVERS, "tcp"); -if (cl == NULL) { - exit(1); -} -tv.tv_sec = 60; /* \fIchange timeout to 1 minute\fP */ -tv.tv_usec = 0; -clnt_control(cl, CLSET_TIMEOUT, &tv); -.DE -.NH 2 -\&Handling Broadcast on the Server Side -.IX "broadcast RPC" -.IX rpcgen "broadcast RPC" \fIrpcgen\fP -.LP -When a procedure is known to be called via broadcast RPC, -it is usually wise for the server to not reply unless it can provide -some useful information to the client. This prevents the network -from getting flooded by useless replies. -.LP -To prevent the server from replying, a remote procedure can -return NULL as its result, and the server code generated by -.I rpcgen -will detect this and not send out a reply. -.LP -Here is an example of a procedure that replies only if it -thinks it is an NFS server: -.ID -void * -reply_if_nfsserver() -{ - char notnull; /* \fIjust here so we can use its address\fP */ -.sp .5 - if (access("/etc/exports", F_OK) < 0) { - return (NULL); /* \fIprevent RPC from replying\fP */ - } -.ft I - /* - * return non-null pointer so RPC will send out a reply - */ -.ft L - return ((void *)¬null); -} -.DE -Note that if procedure returns type \*Qvoid *\*U, they must return a non-NULL -pointer if they want RPC to reply for them. -.NH 2 -\&Other Information Passed to Server Procedures -.LP -Server procedures will often want to know more about an RPC call -than just its arguments. For example, getting authentication information -is important to procedures that want to implement some level of security. -This extra information is actually supplied to the server procedure as a -second argument. Here is an example to demonstrate its use. What we've -done here is rewrite the previous -.I printmessage_1() -procedure to only allow root users to print a message to the console. -.ID -int * -printmessage_1(msg, rq) - char **msg; - struct svc_req *rq; -{ - static in result; /* \fIMust be static\fP */ - FILE *f; - struct suthunix_parms *aup; -.sp .5 - aup = (struct authunix_parms *)rq->rq_clntcred; - if (aup->aup_uid != 0) { - result = 0; - return (&result); - } -.sp -.ft I - /* - * Same code as before. - */ -.ft L -} -.DE -.NH 1 -\&RPC Language -.IX RPCL -.IX rpcgen "RPC Language" \fIrpcgen\fP -.LP -RPC language is an extension of XDR language. The sole extension is -the addition of the -.I program -type. For a complete description of the XDR language syntax, see the -.I "External Data Representation Standard: Protocol Specification" -chapter. For a description of the RPC extensions to the XDR language, -see the -.I "Remote Procedure Calls: Protocol Specification" -chapter. -.LP -However, XDR language is so close to C that if you know C, you know most -of it already. We describe here the syntax of the RPC language, -showing a few examples along the way. We also show how the various -RPC and XDR type definitions get compiled into C type definitions in -the output header file. -.KS -.NH 2 -Definitions -\& -.IX rpcgen definitions \fIrpcgen\fP -.LP -An RPC language file consists of a series of definitions. -.DS L -.ft CW - definition-list: - definition ";" - definition ";" definition-list -.DE -.KE -It recognizes five types of definitions. -.DS L -.ft CW - definition: - enum-definition - struct-definition - union-definition - typedef-definition - const-definition - program-definition -.DE -.NH 2 -Structures -\& -.IX rpcgen structures \fIrpcgen\fP -.LP -An XDR struct is declared almost exactly like its C counterpart. It -looks like the following: -.DS L -.ft CW - struct-definition: - "struct" struct-ident "{" - declaration-list - "}" - - declaration-list: - declaration ";" - declaration ";" declaration-list -.DE -As an example, here is an XDR structure to a two-dimensional -coordinate, and the C structure that it gets compiled into in the -output header file. -.DS -.ft CW - struct coord { struct coord { - int x; --> int x; - int y; int y; - }; }; - typedef struct coord coord; -.DE -The output is identical to the input, except for the added -.I typedef -at the end of the output. This allows one to use \*Qcoord\*U instead of -\*Qstruct coord\*U when declaring items. -.NH 2 -Unions -\& -.IX rpcgen unions \fIrpcgen\fP -.LP -XDR unions are discriminated unions, and look quite different from C -unions. They are more analogous to Pascal variant records than they -are to C unions. -.DS L -.ft CW - union-definition: - "union" union-ident "switch" "(" declaration ")" "{" - case-list - "}" - - case-list: - "case" value ":" declaration ";" - "default" ":" declaration ";" - "case" value ":" declaration ";" case-list -.DE -Here is an example of a type that might be returned as the result of a -\*Qread data\*U operation. If there is no error, return a block of data. -Otherwise, don't return anything. -.DS L -.ft CW - union read_result switch (int errno) { - case 0: - opaque data[1024]; - default: - void; - }; -.DE -It gets compiled into the following: -.DS L -.ft CW - struct read_result { - int errno; - union { - char data[1024]; - } read_result_u; - }; - typedef struct read_result read_result; -.DE -Notice that the union component of the output struct has the name as -the type name, except for the trailing \*Q_u\*U. -.NH 2 -Enumerations -\& -.IX rpcgen enumerations \fIrpcgen\fP -.LP -XDR enumerations have the same syntax as C enumerations. -.DS L -.ft CW - enum-definition: - "enum" enum-ident "{" - enum-value-list - "}" - - enum-value-list: - enum-value - enum-value "," enum-value-list - - enum-value: - enum-value-ident - enum-value-ident "=" value -.DE -Here is a short example of an XDR enum, and the C enum that it gets -compiled into. -.DS L -.ft CW - enum colortype { enum colortype { - RED = 0, RED = 0, - GREEN = 1, --> GREEN = 1, - BLUE = 2 BLUE = 2, - }; }; - typedef enum colortype colortype; -.DE -.NH 2 -Typedef -\& -.IX rpcgen typedef \fIrpcgen\fP -.LP -XDR typedefs have the same syntax as C typedefs. -.DS L -.ft CW - typedef-definition: - "typedef" declaration -.DE -Here is an example that defines a -.I fname_type -used for declaring -file name strings that have a maximum length of 255 characters. -.DS L -.ft CW -typedef string fname_type<255>; --> typedef char *fname_type; -.DE -.NH 2 -Constants -\& -.IX rpcgen constants \fIrpcgen\fP -.LP -XDR constants symbolic constants that may be used wherever a -integer constant is used, for example, in array size specifications. -.DS L -.ft CW - const-definition: - "const" const-ident "=" integer -.DE -For example, the following defines a constant -.I DOZEN -equal to 12. -.DS L -.ft CW - const DOZEN = 12; --> #define DOZEN 12 -.DE -.NH 2 -Programs -\& -.IX rpcgen programs \fIrpcgen\fP -.LP -RPC programs are declared using the following syntax: -.DS L -.ft CW - program-definition: - "program" program-ident "{" - version-list - "}" "=" value - - version-list: - version ";" - version ";" version-list - - version: - "version" version-ident "{" - procedure-list - "}" "=" value - - procedure-list: - procedure ";" - procedure ";" procedure-list - - procedure: - type-ident procedure-ident "(" type-ident ")" "=" value -.DE -For example, here is the time protocol, revisited: -.ie t .DS -.el .DS L -.ft I -/* - * time.x: Get or set the time. Time is represented as number of seconds - * since 0:00, January 1, 1970. - */ -.ft CW -program TIMEPROG { - version TIMEVERS { - unsigned int TIMEGET(void) = 1; - void TIMESET(unsigned) = 2; - } = 1; -} = 44; -.DE -This file compiles into #defines in the output header file: -.ie t .DS -.el .DS L -.ft CW -#define TIMEPROG 44 -#define TIMEVERS 1 -#define TIMEGET 1 -#define TIMESET 2 -.DE -.NH 2 -Declarations -\& -.IX rpcgen declarations \fIrpcgen\fP -.LP -In XDR, there are only four kinds of declarations. -.DS L -.ft CW - declaration: - simple-declaration - fixed-array-declaration - variable-array-declaration - pointer-declaration -.DE -\fB1) Simple declarations\fP are just like simple C declarations. -.DS L -.ft CW - simple-declaration: - type-ident variable-ident -.DE -Example: -.DS L -.ft CW - colortype color; --> colortype color; -.DE -\fB2) Fixed-length Array Declarations\fP are just like C array declarations: -.DS L -.ft CW - fixed-array-declaration: - type-ident variable-ident "[" value "]" -.DE -Example: -.DS L -.ft CW - colortype palette[8]; --> colortype palette[8]; -.DE -\fB3) Variable-Length Array Declarations\fP have no explicit syntax -in C, so XDR invents its own using angle-brackets. -.DS L -.ft CW -variable-array-declaration: - type-ident variable-ident "<" value ">" - type-ident variable-ident "<" ">" -.DE -The maximum size is specified between the angle brackets. The size may -be omitted, indicating that the array may be of any size. -.DS L -.ft CW - int heights<12>; /* \fIat most 12 items\fP */ - int widths<>; /* \fIany number of items\fP */ -.DE -Since variable-length arrays have no explicit syntax in C, these -declarations are actually compiled into \*Qstruct\*Us. For example, the -\*Qheights\*U declaration gets compiled into the following struct: -.DS L -.ft CW - struct { - u_int heights_len; /* \fI# of items in array\fP */ - int *heights_val; /* \fIpointer to array\fP */ - } heights; -.DE -Note that the number of items in the array is stored in the \*Q_len\*U -component and the pointer to the array is stored in the \*Q_val\*U -component. The first part of each of these component's names is the -same as the name of the declared XDR variable. -.LP -\fB4) Pointer Declarations\fP are made in -XDR exactly as they are in C. You can't -really send pointers over the network, but you can use XDR pointers -for sending recursive data types such as lists and trees. The type is -actually called \*Qoptional-data\*U, not \*Qpointer\*U, in XDR language. -.DS L -.ft CW - pointer-declaration: - type-ident "*" variable-ident -.DE -Example: -.DS L -.ft CW - listitem *next; --> listitem *next; -.DE -.NH 2 -\&Special Cases -.IX rpcgen "special cases" \fIrpcgen\fP -.LP -There are a few exceptions to the rules described above. -.LP -.B Booleans: -C has no built-in boolean type. However, the RPC library does a -boolean type called -.I bool_t -that is either -.I TRUE -or -.I FALSE . -Things declared as type -.I bool -in XDR language are compiled into -.I bool_t -in the output header file. -.LP -Example: -.DS L -.ft CW - bool married; --> bool_t married; -.DE -.B Strings: -C has no built-in string type, but instead uses the null-terminated -\*Qchar *\*U convention. In XDR language, strings are declared using the -\*Qstring\*U keyword, and compiled into \*Qchar *\*Us in the output header -file. The maximum size contained in the angle brackets specifies the -maximum number of characters allowed in the strings (not counting the -.I NULL -character). The maximum size may be left off, indicating a string -of arbitrary length. -.LP -Examples: -.DS L -.ft CW - string name<32>; --> char *name; - string longname<>; --> char *longname; -.DE -.B "Opaque Data:" -Opaque data is used in RPC and XDR to describe untyped data, that is, -just sequences of arbitrary bytes. It may be declared either as a -fixed or variable length array. -.DS L -Examples: -.ft CW - opaque diskblock[512]; --> char diskblock[512]; - - opaque filedata<1024>; --> struct { - u_int filedata_len; - char *filedata_val; - } filedata; -.DE -.B Voids: -In a void declaration, the variable is not named. The declaration is -just \*Qvoid\*U and nothing else. Void declarations can only occur in two -places: union definitions and program definitions (as the argument or -result of a remote procedure). diff --git a/lib/librpc/doc/xdr.nts.ms b/lib/librpc/doc/xdr.nts.ms deleted file mode 100644 index 6c2d482dea7f..000000000000 --- a/lib/librpc/doc/xdr.nts.ms +++ /dev/null @@ -1,1966 +0,0 @@ -.\" -.\" Must use -- eqn -- with this one -.\" -.\" @(#)xdr.nts.ms 2.2 88/08/05 4.0 RPCSRC -.EQ -delim $$ -.EN -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'External Data Representation: Sun Technical Notes''Page %' -.EH 'Page %''External Data Representation: Sun Technical Notes' -.if \\n%=1 .bp -.SH -\&External Data Representation: Sun Technical Notes -.IX XDR "Sun technical notes" -.LP -This chapter contains technical notes on Sun's implementation of the -External Data Representation (XDR) standard, a set of library routines -that allow a C programmer to describe arbitrary data structures in a -machinex-independent fashion. -For a formal specification of the XDR -standard, see the -.I "External Data Representation Standard: Protocol Specification". -XDR is the backbone of Sun's Remote Procedure Call package, in the -sense that data for remote procedure calls is transmitted using the -standard. XDR library routines should be used to transmit data -that is accessed (read or written) by more than one type of machine.\** -.FS -.IX XDR "system routines" -For a compete specification of the system External Data Representation -routines, see the -.I xdr(3N) -manual page. -.FE -.LP -This chapter contains a short tutorial overview of the XDR library -routines, a guide to accessing currently available XDR streams, and -information on defining new streams and data types. XDR was designed -to work across different languages, operating systems, and machine -architectures. Most users (particularly RPC users) will only need -the information in the -.I "Number Filters", -.I "Floating Point Filters", -and -.I "Enumeration Filters" -sections. -Programmers wishing to implement RPC and XDR on new machines -will be interested in the rest of the chapter, as well as the -.I "External Data Representaiton Standard: Protocol Specification", -which will be their primary reference. -.SH -Note: -.I -.I rpcgen -can be used to write XDR routines even in cases where no RPC calls are -being made. -.LP -On Sun systems, -C programs that want to use XDR routines -must include the file -.I , -which contains all the necessary interfaces to the XDR system. -Since the C library -.I libc.a -contains all the XDR routines, -compile as normal. -.DS -example% \fBcc\0\fIprogram\fP.c\fI -.DE -.ne 3i -.NH 0 -\&Justification -.IX XDR justification -.LP -Consider the following two programs, -.I writer : -.ie t .DS -.el .DS L -.ft CW -#include -.sp.5 -main() /* \fIwriter.c\fP */ -{ - long i; -.sp.5 - for (i = 0; i < 8; i++) { - if (fwrite((char *)&i, sizeof(i), 1, stdout) != 1) { - fprintf(stderr, "failed!\en"); - exit(1); - } - } - exit(0); -} -.DE -and -.I reader : -.ie t .DS -.el .DS L -.ft CW -#include -.sp.5 -main() /* \fIreader.c\fP */ -{ - long i, j; -.sp.5 - for (j = 0; j < 8; j++) { - if (fread((char *)&i, sizeof (i), 1, stdin) != 1) { - fprintf(stderr, "failed!\en"); - exit(1); - } - printf("%ld ", i); - } - printf("\en"); - exit(0); -} -.DE -The two programs appear to be portable, because (a) they pass -.I lint -checking, and (b) they exhibit the same behavior when executed -on two different hardware architectures, a Sun and a VAX. -.LP -Piping the output of the -.I writer -program to the -.I reader -program gives identical results on a Sun or a VAX. -.DS -.ft CW -sun% \fBwriter | reader\fP -0 1 2 3 4 5 6 7 -sun% - - -vax% \fBwriter | reader\fP -0 1 2 3 4 5 6 7 -vax% -.DE -With the advent of local area networks and 4.2BSD came the concept -of \*Qnetwork pipes\*U \(em a process produces data on one machine, -and a second process consumes data on another machine. -A network pipe can be constructed with -.I writer -and -.I reader . -Here are the results if the first produces data on a Sun, -and the second consumes data on a VAX. -.DS -.ft CW -sun% \fBwriter | rsh vax reader\fP -0 16777216 33554432 50331648 67108864 83886080 100663296 -117440512 -sun% -.DE -Identical results can be obtained by executing -.I writer -on the VAX and -.I reader -on the Sun. These results occur because the byte ordering -of long integers differs between the VAX and the Sun, -even though word size is the same. -Note that $16777216$ is $2 sup 24$ \(em -when four bytes are reversed, the 1 winds up in the 24th bit. -.LP -Whenever data is shared by two or more machine types, there is -a need for portable data. Programs can be made data-portable by -replacing the -.I read() -and -.I write() -calls with calls to an XDR library routine -.I xdr_long() , -a filter that knows the standard representation -of a long integer in its external form. -Here are the revised versions of -.I writer : -.ie t .DS -.el .DS L -.ft CW -#include -#include /* \fIxdr is a sub-library of rpc\fP */ -.sp.5 -main() /* \fIwriter.c\fP */ -{ - XDR xdrs; - long i; -.sp.5 - xdrstdio_create(&xdrs, stdout, XDR_ENCODE); - for (i = 0; i < 8; i++) { - if (!xdr_long(&xdrs, &i)) { - fprintf(stderr, "failed!\en"); - exit(1); - } - } - exit(0); -} -.DE -and -.I reader : -.ie t .DS -.el .DS L -.ft CW -#include -#include /* \fIxdr is a sub-library of rpc\fP */ -.sp.5 -main() /* \fIreader.c\fP */ -{ - XDR xdrs; - long i, j; -.sp.5 - xdrstdio_create(&xdrs, stdin, XDR_DECODE); - for (j = 0; j < 8; j++) { - if (!xdr_long(&xdrs, &i)) { - fprintf(stderr, "failed!\en"); - exit(1); - } - printf("%ld ", i); - } - printf("\en"); - exit(0); -} -.DE -The new programs were executed on a Sun, -on a VAX, and from a Sun to a VAX; -the results are shown below. -.DS -.ft CW -sun% \fBwriter | reader\fP -0 1 2 3 4 5 6 7 -sun% - -vax% \fBwriter | reader\fP -0 1 2 3 4 5 6 7 -vax% - -sun% \fBwriter | rsh vax reader\fP -0 1 2 3 4 5 6 7 -sun% -.DE -.SH -Note: -.I -.IX XDR "portable data" -Integers are just the tip of the portable-data iceberg. Arbitrary -data structures present portability problems, particularly with -respect to alignment and pointers. Alignment on word boundaries -may cause the size of a structure to vary from machine to machine. -And pointers, which are very convenient to use, have no meaning -outside the machine where they are defined. -.LP -.NH 1 -\&A Canonical Standard -.IX XDR "canonical standard" -.LP -XDR's approach to standardizing data representations is -.I canonical . -That is, XDR defines a single byte order (Big Endian), a single -floating-point representation (IEEE), and so on. Any program running on -any machine can use XDR to create portable data by translating its -local representation to the XDR standard representations; similarly, any -program running on any machine can read portable data by translating the -XDR standard representaions to its local equivalents. The single standard -completely decouples programs that create or send portable data from those -that use or receive portable data. The advent of a new machine or a new -language has no effect upon the community of existing portable data creators -and users. A new machine joins this community by being \*Qtaught\*U how to -convert the standard representations and its local representations; the -local representations of other machines are irrelevant. Conversely, to -existing programs running on other machines, the local representations of -the new machine are also irrelevant; such programs can immediately read -portable data produced by the new machine because such data conforms to the -canonical standards that they already understand. -.LP -There are strong precedents for XDR's canonical approach. For example, -TCP/IP, UDP/IP, XNS, Ethernet, and, indeed, all protocols below layer five -of the ISO model, are canonical protocols. The advantage of any canonical -approach is simplicity; in the case of XDR, a single set of conversion -routines is written once and is never touched again. The canonical approach -has a disadvantage, but it is unimportant in real-world data transfer -applications. Suppose two Little-Endian machines are transferring integers -according to the XDR standard. The sending machine converts the integers -from Little-Endian byte order to XDR (Big-Endian) byte order; the receiving -machine performs the reverse conversion. Because both machines observe the -same byte order, their conversions are unnecessary. The point, however, is -not necessity, but cost as compared to the alternative. -.LP -The time spent converting to and from a canonical representation is -insignificant, especially in networking applications. Most of the time -required to prepare a data structure for transfer is not spent in conversion -but in traversing the elements of the data structure. To transmit a tree, -for example, each leaf must be visited and each element in a leaf record must -be copied to a buffer and aligned there; storage for the leaf may have to be -deallocated as well. Similarly, to receive a tree, storage must be -allocated for each leaf, data must be moved from the buffer to the leaf and -properly aligned, and pointers must be constructed to link the leaves -together. Every machine pays the cost of traversing and copying data -structures whether or not conversion is required. In networking -applications, communications overhead\(emthe time required to move the data -down through the sender's protocol layers, across the network and up through -the receiver's protocol layers\(emdwarfs conversion overhead. -.NH 1 -\&The XDR Library -.IX "XDR" "library" -.LP -The XDR library not only solves data portability problems, it also -allows you to write and read arbitrary C constructs in a consistent, -specified, well-documented manner. Thus, it can make sense to use the -library even when the data is not shared among machines on a network. -.LP -The XDR library has filter routines for -strings (null-terminated arrays of bytes), -structures, unions, and arrays, to name a few. -Using more primitive routines, -you can write your own specific XDR routines -to describe arbitrary data structures, -including elements of arrays, arms of unions, -or objects pointed at from other structures. -The structures themselves may contain arrays of arbitrary elements, -or pointers to other structures. -.LP -Let's examine the two programs more closely. -There is a family of XDR stream creation routines -in which each member treats the stream of bits differently. -In our example, data is manipulated using standard I/O routines, -so we use -.I xdrstdio_create (). -.IX xdrstdio_create() "" "\fIxdrstdio_create()\fP" -The parameters to XDR stream creation routines -vary according to their function. -In our example, -.I xdrstdio_create() -takes a pointer to an XDR structure that it initializes, -a pointer to a -.I FILE -that the input or output is performed on, and the operation. -The operation may be -.I XDR_ENCODE -for serializing in the -.I writer -program, or -.I XDR_DECODE -for deserializing in the -.I reader -program. -.LP -Note: RPC users never need to create XDR streams; -the RPC system itself creates these streams, -which are then passed to the users. -.LP -The -.I xdr_long() -.IX xdr_long() "" "\fIxdr_long()\fP" -primitive is characteristic of most XDR library -primitives and all client XDR routines. -First, the routine returns -.I FALSE -(0) if it fails, and -.I TRUE -(1) if it succeeds. -Second, for each data type, -.I xxx , -there is an associated XDR routine of the form: -.DS -.ft CW -xdr_xxx(xdrs, xp) - XDR *xdrs; - xxx *xp; -{ -} -.DE -In our case, -.I xxx -is long, and the corresponding XDR routine is -a primitive, -.I xdr_long() . -The client could also define an arbitrary structure -.I xxx -in which case the client would also supply the routine -.I xdr_xxx (), -describing each field by calling XDR routines -of the appropriate type. -In all cases the first parameter, -.I xdrs -can be treated as an opaque handle, -and passed to the primitive routines. -.LP -XDR routines are direction independent; -that is, the same routines are called to serialize or deserialize data. -This feature is critical to software engineering of portable data. -The idea is to call the same routine for either operation \(em -this almost guarantees that serialized data can also be deserialized. -One routine is used by both producer and consumer of networked data. -This is implemented by always passing the address -of an object rather than the object itself \(em -only in the case of deserialization is the object modified. -This feature is not shown in our trivial example, -but its value becomes obvious when nontrivial data structures -are passed among machines. -If needed, the user can obtain the -direction of the XDR operation. -See the -.I "XDR Operation Directions" -section below for details. -.LP -Let's look at a slightly more complicated example. -Assume that a person's gross assets and liabilities -are to be exchanged among processes. -Also assume that these values are important enough -to warrant their own data type: -.ie t .DS -.el .DS L -.ft CW -struct gnumbers { - long g_assets; - long g_liabilities; -}; -.DE -The corresponding XDR routine describing this structure would be: -.ie t .DS -.el .DS L -.ft CW -bool_t /* \fITRUE is success, FALSE is failure\fP */ -xdr_gnumbers(xdrs, gp) - XDR *xdrs; - struct gnumbers *gp; -{ - if (xdr_long(xdrs, &gp->g_assets) && - xdr_long(xdrs, &gp->g_liabilities)) - return(TRUE); - return(FALSE); -} -.DE -Note that the parameter -.I xdrs -is never inspected or modified; -it is only passed on to the subcomponent routines. -It is imperative to inspect the return value of each XDR routine call, -and to give up immediately and return -.I FALSE -if the subroutine fails. -.LP -This example also shows that the type -.I bool_t -is declared as an integer whose only values are -.I TRUE -(1) and -.I FALSE -(0). This document uses the following definitions: -.ie t .DS -.el .DS L -.ft CW -#define bool_t int -#define TRUE 1 -#define FALSE 0 -.DE -.LP -Keeping these conventions in mind, -.I xdr_gnumbers() -can be rewritten as follows: -.ie t .DS -.el .DS L -.ft CW -xdr_gnumbers(xdrs, gp) - XDR *xdrs; - struct gnumbers *gp; -{ - return(xdr_long(xdrs, &gp->g_assets) && - xdr_long(xdrs, &gp->g_liabilities)); -} -.DE -This document uses both coding styles. -.NH 1 -\&XDR Library Primitives -.IX "library primitives for XDR" -.IX XDR "library primitives" -.LP -This section gives a synopsis of each XDR primitive. -It starts with basic data types and moves on to constructed data types. -Finally, XDR utilities are discussed. -The interface to these primitives -and utilities is defined in the include file -.I , -automatically included by -.I . -.NH 2 -\&Number Filters -.IX "XDR library" "number filters" -.LP -The XDR library provides primitives to translate between numbers -and their corresponding external representations. -Primitives cover the set of numbers in: -.DS -.ft CW -[signed, unsigned] * [short, int, long] -.DE -.ne 2i -Specifically, the eight primitives are: -.DS -.ft CW -bool_t xdr_char(xdrs, cp) - XDR *xdrs; - char *cp; -.sp.5 -bool_t xdr_u_char(xdrs, ucp) - XDR *xdrs; - unsigned char *ucp; -.sp.5 -bool_t xdr_int(xdrs, ip) - XDR *xdrs; - int *ip; -.sp.5 -bool_t xdr_u_int(xdrs, up) - XDR *xdrs; - unsigned *up; -.sp.5 -bool_t xdr_long(xdrs, lip) - XDR *xdrs; - long *lip; -.sp.5 -bool_t xdr_u_long(xdrs, lup) - XDR *xdrs; - u_long *lup; -.sp.5 -bool_t xdr_short(xdrs, sip) - XDR *xdrs; - short *sip; -.sp.5 -bool_t xdr_u_short(xdrs, sup) - XDR *xdrs; - u_short *sup; -.DE -The first parameter, -.I xdrs , -is an XDR stream handle. -The second parameter is the address of the number -that provides data to the stream or receives data from it. -All routines return -.I TRUE -if they complete successfully, and -.I FALSE -otherwise. -.NH 2 -\&Floating Point Filters -.IX "XDR library" "floating point filters" -.LP -The XDR library also provides primitive routines -for C's floating point types: -.DS -.ft CW -bool_t xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; -.sp.5 -bool_t xdr_double(xdrs, dp) - XDR *xdrs; - double *dp; -.DE -The first parameter, -.I xdrs -is an XDR stream handle. -The second parameter is the address -of the floating point number that provides data to the stream -or receives data from it. -Both routines return -.I TRUE -if they complete successfully, and -.I FALSE -otherwise. -.LP -Note: Since the numbers are represented in IEEE floating point, -routines may fail when decoding a valid IEEE representation -into a machine-specific representation, or vice-versa. -.NH 2 -\&Enumeration Filters -.IX "XDR library" "enumeration filters" -.LP -The XDR library provides a primitive for generic enumerations. -The primitive assumes that a C -.I enum -has the same representation inside the machine as a C integer. -The boolean type is an important instance of the -.I enum . -The external representation of a boolean is always -.I TRUE -(1) or -.I FALSE -(0). -.DS -.ft CW -#define bool_t int -#define FALSE 0 -#define TRUE 1 -.sp.5 -#define enum_t int -.sp.5 -bool_t xdr_enum(xdrs, ep) - XDR *xdrs; - enum_t *ep; -.sp.5 -bool_t xdr_bool(xdrs, bp) - XDR *xdrs; - bool_t *bp; -.DE -The second parameters -.I ep -and -.I bp -are addresses of the associated type that provides data to, or -receives data from, the stream -.I xdrs . -.NH 2 -\&No Data -.IX "XDR library" "no data" -.LP -Occasionally, an XDR routine must be supplied to the RPC system, -even when no data is passed or required. -The library provides such a routine: -.DS -.ft CW -bool_t xdr_void(); /* \fIalways returns TRUE\fP */ -.DE -.NH 2 -\&Constructed Data Type Filters -.IX "XDR library" "constructed data type filters" -.LP -Constructed or compound data type primitives -require more parameters and perform more complicated functions -then the primitives discussed above. -This section includes primitives for -strings, arrays, unions, and pointers to structures. -.LP -Constructed data type primitives may use memory management. -In many cases, memory is allocated when deserializing data with -.I XDR_DECODE -Therefore, the XDR package must provide means to deallocate memory. -This is done by an XDR operation, -.I XDR_FREE -To review, the three XDR directional operations are -.I XDR_ENCODE , -.I XDR_DECODE -and -.I XDR_FREE . -.NH 3 -\&Strings -.IX "XDR library" "strings" -.LP -In C, a string is defined as a sequence of bytes -terminated by a null byte, -which is not considered when calculating string length. -However, when a string is passed or manipulated, -a pointer to it is employed. -Therefore, the XDR library defines a string to be a -.I "char *" -and not a sequence of characters. -The external representation of a string is drastically different -from its internal representation. -Externally, strings are represented as -sequences of ASCII characters, -while internally, they are represented with character pointers. -Conversion between the two representations -is accomplished with the routine -.I xdr_string (): -.IX xdr_string() "" \fIxdr_string()\fP -.DS -.ft CW -bool_t xdr_string(xdrs, sp, maxlength) - XDR *xdrs; - char **sp; - u_int maxlength; -.DE -The first parameter -.I xdrs -is the XDR stream handle. -The second parameter -.I sp -is a pointer to a string (type -.I "char **" . -The third parameter -.I maxlength -specifies the maximum number of bytes allowed during encoding or decoding. -its value is usually specified by a protocol. For example, a protocol -specification may say that a file name may be no longer than 255 characters. -.LP -The routine returns -.I FALSE -if the number of characters exceeds -.I maxlength , -and -.I TRUE -if it doesn't. -.SH -Keep -.I maxlength -small. If it is too big you can blow the heap, since -.I xdr_string() -will call -.I malloc() -for space. -.LP -The behavior of -.I xdr_string() -.IX xdr_string() "" \fIxdr_string()\fP -is similar to the behavior of other routines -discussed in this section. The direction -.I XDR_ENCODE -is easiest to understand. The parameter -.I sp -points to a string of a certain length; -if the string does not exceed -.I maxlength , -the bytes are serialized. -.LP -The effect of deserializing a string is subtle. -First the length of the incoming string is determined; -it must not exceed -.I maxlength . -Next -.I sp -is dereferenced; if the the value is -.I NULL , -then a string of the appropriate length is allocated and -.I *sp -is set to this string. -If the original value of -.I *sp -is non-null, then the XDR package assumes -that a target area has been allocated, -which can hold strings no longer than -.I maxlength . -In either case, the string is decoded into the target area. -The routine then appends a null character to the string. -.LP -In the -.I XDR_FREE -operation, the string is obtained by dereferencing -.I sp . -If the string is not -.I NULL , -it is freed and -.I *sp -is set to -.I NULL . -In this operation, -.I xdr_string() -ignores the -.I maxlength -parameter. -.NH 3 -\&Byte Arrays -.IX "XDR library" "byte arrays" -.LP -Often variable-length arrays of bytes are preferable to strings. -Byte arrays differ from strings in the following three ways: -1) the length of the array (the byte count) is explicitly -located in an unsigned integer, -2) the byte sequence is not terminated by a null character, and -3) the external representation of the bytes is the same as their -internal representation. -The primitive -.I xdr_bytes() -.IX xdr_bytes() "" \fIxdr_bytes()\fP -converts between the internal and external -representations of byte arrays: -.DS -.ft CW -bool_t xdr_bytes(xdrs, bpp, lp, maxlength) - XDR *xdrs; - char **bpp; - u_int *lp; - u_int maxlength; -.DE -The usage of the first, second and fourth parameters -are identical to the first, second and third parameters of -.I xdr_string (), -respectively. -The length of the byte area is obtained by dereferencing -.I lp -when serializing; -.I *lp -is set to the byte length when deserializing. -.NH 3 -\&Arrays -.IX "XDR library" "arrays" -.LP -The XDR library package provides a primitive -for handling arrays of arbitrary elements. -The -.I xdr_bytes() -routine treats a subset of generic arrays, -in which the size of array elements is known to be 1, -and the external description of each element is built-in. -The generic array primitive, -.I xdr_array() , -.IX xdr_array() "" \fIxdr_array()\fP -requires parameters identical to those of -.I xdr_bytes() -plus two more: -the size of array elements, -and an XDR routine to handle each of the elements. -This routine is called to encode or decode -each element of the array. -.DS -.ft CW -bool_t -xdr_array(xdrs, ap, lp, maxlength, elementsiz, xdr_element) - XDR *xdrs; - char **ap; - u_int *lp; - u_int maxlength; - u_int elementsiz; - bool_t (*xdr_element)(); -.DE -The parameter -.I ap -is the address of the pointer to the array. -If -.I *ap -is -.I NULL -when the array is being deserialized, -XDR allocates an array of the appropriate size and sets -.I *ap -to that array. -The element count of the array is obtained from -.I *lp -when the array is serialized; -.I *lp -is set to the array length when the array is deserialized. -The parameter -.I maxlength -is the maximum number of elements that the array is allowed to have; -.I elementsiz -is the byte size of each element of the array -(the C function -.I sizeof() -can be used to obtain this value). -The -.I xdr_element() -.IX xdr_element() "" \fIxdr_element()\fP -routine is called to serialize, deserialize, or free -each element of the array. -.br -.LP -Before defining more constructed data types, it is appropriate to -present three examples. -.LP -.I "Example A:" -.br -A user on a networked machine can be identified by -(a) the machine name, such as -.I krypton : -see the -.I gethostname -man page; (b) the user's UID: see the -.I geteuid -man page; and (c) the group numbers to which the user belongs: -see the -.I getgroups -man page. A structure with this information and its associated -XDR routine could be coded like this: -.ie t .DS -.el .DS L -.ft CW -struct netuser { - char *nu_machinename; - int nu_uid; - u_int nu_glen; - int *nu_gids; -}; -#define NLEN 255 /* \fImachine names < 256 chars\fP */ -#define NGRPS 20 /* \fIuser can't be in > 20 groups\fP */ -.sp.5 -bool_t -xdr_netuser(xdrs, nup) - XDR *xdrs; - struct netuser *nup; -{ - return(xdr_string(xdrs, &nup->nu_machinename, NLEN) && - xdr_int(xdrs, &nup->nu_uid) && - xdr_array(xdrs, &nup->nu_gids, &nup->nu_glen, - NGRPS, sizeof (int), xdr_int)); -} -.DE -.LP -.I "Example B:" -.br -A party of network users could be implemented -as an array of -.I netuser -structure. -The declaration and its associated XDR routines -are as follows: -.ie t .DS -.el .DS L -.ft CW -struct party { - u_int p_len; - struct netuser *p_nusers; -}; -#define PLEN 500 /* \fImax number of users in a party\fP */ -.sp.5 -bool_t -xdr_party(xdrs, pp) - XDR *xdrs; - struct party *pp; -{ - return(xdr_array(xdrs, &pp->p_nusers, &pp->p_len, PLEN, - sizeof (struct netuser), xdr_netuser)); -} -.DE -.LP -.I "Example C:" -.br -The well-known parameters to -.I main , -.I argc -and -.I argv -can be combined into a structure. -An array of these structures can make up a history of commands. -The declarations and XDR routines might look like: -.ie t .DS -.el .DS L -.ft CW -struct cmd { - u_int c_argc; - char **c_argv; -}; -#define ALEN 1000 /* \fIargs cannot be > 1000 chars\fP */ -#define NARGC 100 /* \fIcommands cannot have > 100 args\fP */ - -struct history { - u_int h_len; - struct cmd *h_cmds; -}; -#define NCMDS 75 /* \fIhistory is no more than 75 commands\fP */ - -bool_t -xdr_wrap_string(xdrs, sp) - XDR *xdrs; - char **sp; -{ - return(xdr_string(xdrs, sp, ALEN)); -} -.DE -.ie t .DS -.el .DS L -.ft CW -bool_t -xdr_cmd(xdrs, cp) - XDR *xdrs; - struct cmd *cp; -{ - return(xdr_array(xdrs, &cp->c_argv, &cp->c_argc, NARGC, - sizeof (char *), xdr_wrap_string)); -} -.DE -.ie t .DS -.el .DS L -.ft CW -bool_t -xdr_history(xdrs, hp) - XDR *xdrs; - struct history *hp; -{ - return(xdr_array(xdrs, &hp->h_cmds, &hp->h_len, NCMDS, - sizeof (struct cmd), xdr_cmd)); -} -.DE -The most confusing part of this example is that the routine -.I xdr_wrap_string() -is needed to package the -.I xdr_string() -routine, because the implementation of -.I xdr_array() -only passes two parameters to the array element description routine; -.I xdr_wrap_string() -supplies the third parameter to -.I xdr_string (). -.LP -By now the recursive nature of the XDR library should be obvious. -Let's continue with more constructed data types. -.NH 3 -\&Opaque Data -.IX "XDR library" "opaque data" -.LP -In some protocols, handles are passed from a server to client. -The client passes the handle back to the server at some later time. -Handles are never inspected by clients; -they are obtained and submitted. -That is to say, handles are opaque. -The -.I xdr_opaque() -.IX xdr_opaque() "" \fIxdr_opaque()\fP -primitive is used for describing fixed sized, opaque bytes. -.DS -.ft CW -bool_t xdr_opaque(xdrs, p, len) - XDR *xdrs; - char *p; - u_int len; -.DE -The parameter -.I p -is the location of the bytes; -.I len -is the number of bytes in the opaque object. -By definition, the actual data -contained in the opaque object are not machine portable. -.NH 3 -\&Fixed Sized Arrays -.IX "XDR library" "fixed sized arrays" -.LP -The XDR library provides a primitive, -.I xdr_vector (), -for fixed-length arrays. -.ie t .DS -.el .DS L -.ft CW -#define NLEN 255 /* \fImachine names must be < 256 chars\fP */ -#define NGRPS 20 /* \fIuser belongs to exactly 20 groups\fP */ -.sp.5 -struct netuser { - char *nu_machinename; - int nu_uid; - int nu_gids[NGRPS]; -}; -.sp.5 -bool_t -xdr_netuser(xdrs, nup) - XDR *xdrs; - struct netuser *nup; -{ - int i; -.sp.5 - if (!xdr_string(xdrs, &nup->nu_machinename, NLEN)) - return(FALSE); - if (!xdr_int(xdrs, &nup->nu_uid)) - return(FALSE); - if (!xdr_vector(xdrs, nup->nu_gids, NGRPS, sizeof(int), - xdr_int)) { - return(FALSE); - } - return(TRUE); -} -.DE -.NH 3 -\&Discriminated Unions -.IX "XDR library" "discriminated unions" -.LP -The XDR library supports discriminated unions. -A discriminated union is a C union and an -.I enum_t -value that selects an \*Qarm\*U of the union. -.DS -.ft CW -struct xdr_discrim { - enum_t value; - bool_t (*proc)(); -}; -.sp.5 -bool_t xdr_union(xdrs, dscmp, unp, arms, defaultarm) - XDR *xdrs; - enum_t *dscmp; - char *unp; - struct xdr_discrim *arms; - bool_t (*defaultarm)(); /* \fImay equal NULL\fP */ -.DE -First the routine translates the discriminant of the union located at -.I *dscmp . -The discriminant is always an -.I enum_t . -Next the union located at -.I *unp -is translated. -The parameter -.I arms -is a pointer to an array of -.I xdr_discrim -structures. -Each structure contains an ordered pair of -.I [value,proc] . -If the union's discriminant is equal to the associated -.I value , -then the -.I proc -is called to translate the union. -The end of the -.I xdr_discrim -structure array is denoted by a routine of value -.I NULL -(0). If the discriminant is not found in the -.I arms -array, then the -.I defaultarm -procedure is called if it is non-null; -otherwise the routine returns -.I FALSE . -.LP -.I "Example D:" -Suppose the type of a union may be integer, -character pointer (a string), or a -.I gnumbers -structure. -Also, assume the union and its current type -are declared in a structure. -The declaration is: -.ie t .DS -.el .DS L -.ft CW -enum utype { INTEGER=1, STRING=2, GNUMBERS=3 }; -.sp.5 -struct u_tag { - enum utype utype; /* \fIthe union's discriminant\fP */ - union { - int ival; - char *pval; - struct gnumbers gn; - } uval; -}; -.DE -The following constructs and XDR procedure (de)serialize -the discriminated union: -.ie t .DS -.el .DS L -.ft CW -struct xdr_discrim u_tag_arms[4] = { - { INTEGER, xdr_int }, - { GNUMBERS, xdr_gnumbers } - { STRING, xdr_wrap_string }, - { __dontcare__, NULL } - /* \fIalways terminate arms with a NULL xdr_proc\fP */ -} -.sp.5 -bool_t -xdr_u_tag(xdrs, utp) - XDR *xdrs; - struct u_tag *utp; -{ - return(xdr_union(xdrs, &utp->utype, &utp->uval, - u_tag_arms, NULL)); -} -.DE -The routine -.I xdr_gnumbers() -was presented above in -.I "The XDR Library" -section. -.I xdr_wrap_string() -was presented in example C. -The default -.I arm -parameter to -.I xdr_union() -(the last parameter) is -.I NULL -in this example. Therefore the value of the union's discriminant -may legally take on only values listed in the -.I u_tag_arms -array. This example also demonstrates that -the elements of the arm's array do not need to be sorted. -.LP -It is worth pointing out that the values of the discriminant -may be sparse, though in this example they are not. -It is always good -practice to assign explicitly integer values to each element of the -discriminant's type. -This practice both documents the external -representation of the discriminant and guarantees that different -C compilers emit identical discriminant values. -.LP -Exercise: Implement -.I xdr_union() -using the other primitives in this section. -.NH 3 -\&Pointers -.IX "XDR library" "pointers" -.LP -In C it is often convenient to put pointers -to another structure within a structure. -The -.I xdr_reference() -.IX xdr_reference() "" \fIxdr_reference()\fP -primitive makes it easy to serialize, deserialize, and free -these referenced structures. -.DS -.ft CW -bool_t xdr_reference(xdrs, pp, size, proc) - XDR *xdrs; - char **pp; - u_int ssize; - bool_t (*proc)(); -.DE -.LP -Parameter -.I pp -is the address of -the pointer to the structure; -parameter -.I ssize -is the size in bytes of the structure (use the C function -.I sizeof() -to obtain this value); and -.I proc -is the XDR routine that describes the structure. -When decoding data, storage is allocated if -.I *pp -is -.I NULL . -.LP -There is no need for a primitive -.I xdr_struct() -to describe structures within structures, -because pointers are always sufficient. -.LP -Exercise: Implement -.I xdr_reference() -using -.I xdr_array (). -Warning: -.I xdr_reference() -and -.I xdr_array() -are NOT interchangeable external representations of data. -.LP -.I "Example E:" -Suppose there is a structure containing a person's name -and a pointer to a -.I gnumbers -structure containing the person's gross assets and liabilities. -The construct is: -.DS -.ft CW -struct pgn { - char *name; - struct gnumbers *gnp; -}; -.DE -The corresponding XDR routine for this structure is: -.DS -.ft CW -bool_t -xdr_pgn(xdrs, pp) - XDR *xdrs; - struct pgn *pp; -{ - if (xdr_string(xdrs, &pp->name, NLEN) && - xdr_reference(xdrs, &pp->gnp, - sizeof(struct gnumbers), xdr_gnumbers)) - return(TRUE); - return(FALSE); -} -.DE -.IX "pointer semantics and XDR" -.I "Pointer Semantics and XDR" -.LP -In many applications, C programmers attach double meaning to -the values of a pointer. Typically the value -.I NULL -(or zero) means data is not needed, -yet some application-specific interpretation applies. -In essence, the C programmer is encoding -a discriminated union efficiently -by overloading the interpretation of the value of a pointer. -For instance, in example E a -.I NULL -pointer value for -.I gnp -could indicate that -the person's assets and liabilities are unknown. -That is, the pointer value encodes two things: -whether or not the data is known; -and if it is known, where it is located in memory. -Linked lists are an extreme example of the use -of application-specific pointer interpretation. -.LP -The primitive -.I xdr_reference() -.IX xdr_reference() "" \fIxdr_reference()\fP -cannot and does not attach any special -meaning to a null-value pointer during serialization. -That is, passing an address of a pointer whose value is -.I NULL -to -.I xdr_reference() -when serialing data will most likely cause a memory fault and, on the UNIX -system, a core dump. -.LP -.I xdr_pointer() -correctly handles -.I NULL -pointers. For more information about its use, see -the -.I "Linked Lists" -topics below. -.LP -.I Exercise: -After reading the section on -.I "Linked Lists" , -return here and extend example E so that -it can correctly deal with -.I NULL -pointer values. -.LP -.I Exercise: -Using the -.I xdr_union (), -.I xdr_reference() -and -.I xdr_void() -primitives, implement a generic pointer handling primitive -that implicitly deals with -.I NULL -pointers. That is, implement -.I xdr_pointer (). -.NH 2 -\&Non-filter Primitives -.IX "XDR" "non-filter primitives" -.LP -XDR streams can be manipulated with -the primitives discussed in this section. -.DS -.ft CW -u_int xdr_getpos(xdrs) - XDR *xdrs; -.sp.5 -bool_t xdr_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -.sp.5 -xdr_destroy(xdrs) - XDR *xdrs; -.DE -The routine -.I xdr_getpos() -.IX xdr_getpos() "" \fIxdr_getpos()\fP -returns an unsigned integer -that describes the current position in the data stream. -Warning: In some XDR streams, the returned value of -.I xdr_getpos() -is meaningless; -the routine returns a \-1 in this case -(though \-1 should be a legitimate value). -.LP -The routine -.I xdr_setpos() -.IX xdr_setpos() "" \fIxdr_setpos()\fP -sets a stream position to -.I pos . -Warning: In some XDR streams, setting a position is impossible; -in such cases, -.I xdr_setpos() -will return -.I FALSE . -This routine will also fail if the requested position is out-of-bounds. -The definition of bounds varies from stream to stream. -.LP -The -.I xdr_destroy() -.IX xdr_destroy() "" \fIxdr_destroy()\fP -primitive destroys the XDR stream. -Usage of the stream -after calling this routine is undefined. -.NH 2 -\&XDR Operation Directions -.IX XDR "operation directions" -.IX "direction of XDR operations" -.LP -At times you may wish to optimize XDR routines by taking -advantage of the direction of the operation \(em -.I XDR_ENCODE -.I XDR_DECODE -or -.I XDR_FREE -The value -.I xdrs->x_op -always contains the direction of the XDR operation. -Programmers are not encouraged to take advantage of this information. -Therefore, no example is presented here. However, an example in the -.I "Linked Lists" -topic below, demonstrates the usefulness of the -.I xdrs->x_op -field. -.NH 2 -\&XDR Stream Access -.IX "XDR" "stream access" -.LP -An XDR stream is obtained by calling the appropriate creation routine. -These creation routines take arguments that are tailored to the -specific properties of the stream. -.LP -Streams currently exist for (de)serialization of data to or from -standard I/O -.I FILE -streams, TCP/IP connections and UNIX files, and memory. -.NH 3 -\&Standard I/O Streams -.IX "XDR" "standard I/O streams" -.LP -XDR streams can be interfaced to standard I/O using the -.I xdrstdio_create() -.IX xdrstdio_create() "" \fIxdrstdio_create()\fP -routine as follows: -.DS -.ft CW -#include -#include /* \fIxdr streams part of rpc\fP */ -.sp.5 -void -xdrstdio_create(xdrs, fp, x_op) - XDR *xdrs; - FILE *fp; - enum xdr_op x_op; -.DE -The routine -.I xdrstdio_create() -initializes an XDR stream pointed to by -.I xdrs . -The XDR stream interfaces to the standard I/O library. -Parameter -.I fp -is an open file, and -.I x_op -is an XDR direction. -.NH 3 -\&Memory Streams -.IX "XDR" "memory streams" -.LP -Memory streams allow the streaming of data into or out of -a specified area of memory: -.DS -.ft CW -#include -.sp.5 -void -xdrmem_create(xdrs, addr, len, x_op) - XDR *xdrs; - char *addr; - u_int len; - enum xdr_op x_op; -.DE -The routine -.I xdrmem_create() -.IX xdrmem_create() "" \fIxdrmem_create()\fP -initializes an XDR stream in local memory. -The memory is pointed to by parameter -.I addr ; -parameter -.I len -is the length in bytes of the memory. -The parameters -.I xdrs -and -.I x_op -are identical to the corresponding parameters of -.I xdrstdio_create (). -Currently, the UDP/IP implementation of RPC uses -.I xdrmem_create (). -Complete call or result messages are built in memory before calling the -.I sendto() -system routine. -.NH 3 -\&Record (TCP/IP) Streams -.IX "XDR" "record (TCP/IP) streams" -.LP -A record stream is an XDR stream built on top of -a record marking standard that is built on top of the -UNIX file or 4.2 BSD connection interface. -.DS -.ft CW -#include /* \fIxdr streams part of rpc\fP */ -.sp.5 -xdrrec_create(xdrs, - sendsize, recvsize, iohandle, readproc, writeproc) - XDR *xdrs; - u_int sendsize, recvsize; - char *iohandle; - int (*readproc)(), (*writeproc)(); -.DE -The routine -.I xdrrec_create() -provides an XDR stream interface that allows for a bidirectional, -arbitrarily long sequence of records. -The contents of the records are meant to be data in XDR form. -The stream's primary use is for interfacing RPC to TCP connections. -However, it can be used to stream data into or out of normal -UNIX files. -.LP -The parameter -.I xdrs -is similar to the corresponding parameter described above. -The stream does its own data buffering similar to that of standard I/O. -The parameters -.I sendsize -and -.I recvsize -determine the size in bytes of the output and input buffers, respectively; -if their values are zero (0), then predetermined defaults are used. -When a buffer needs to be filled or flushed, the routine -.I readproc() -or -.I writeproc() -is called, respectively. -The usage and behavior of these -routines are similar to the UNIX system calls -.I read() -and -.I write (). -However, -the first parameter to each of these routines is the opaque parameter -.I iohandle . -The other two parameters -.I buf "" -and -.I nbytes ) -and the results -(byte count) are identical to the system routines. -If -.I xxx -is -.I readproc() -or -.I writeproc (), -then it has the following form: -.DS -.ft CW -.ft I -/* - * returns the actual number of bytes transferred. - * -1 is an error - */ -.ft CW -int -xxx(iohandle, buf, len) - char *iohandle; - char *buf; - int nbytes; -.DE -The XDR stream provides means for delimiting records in the byte stream. -The implementation details of delimiting records in a stream are -discussed in the -.I "Advanced Topics" -topic below. -The primitives that are specific to record streams are as follows: -.DS -.ft CW -bool_t -xdrrec_endofrecord(xdrs, flushnow) - XDR *xdrs; - bool_t flushnow; -.sp.5 -bool_t -xdrrec_skiprecord(xdrs) - XDR *xdrs; -.sp.5 -bool_t -xdrrec_eof(xdrs) - XDR *xdrs; -.DE -The routine -.I xdrrec_endofrecord() -.IX xdrrec_endofrecord() "" \fIxdrrec_endofrecord()\fP -causes the current outgoing data to be marked as a record. -If the parameter -.I flushnow -is -.I TRUE , -then the stream's -.I writeproc -will be called; otherwise, -.I writeproc -will be called when the output buffer has been filled. -.LP -The routine -.I xdrrec_skiprecord() -.IX xdrrec_skiprecord() "" \fIxdrrec_skiprecord()\fP -causes an input stream's position to be moved past -the current record boundary and onto the -beginning of the next record in the stream. -.LP -If there is no more data in the stream's input buffer, -then the routine -.I xdrrec_eof() -.IX xdrrec_eof() "" \fIxdrrec_eof()\fP -returns -.I TRUE . -That is not to say that there is no more data -in the underlying file descriptor. -.NH 2 -\&XDR Stream Implementation -.IX "XDR" "stream implementation" -.IX "stream implementation in XDR" -.LP -This section provides the abstract data types needed -to implement new instances of XDR streams. -.NH 3 -\&The XDR Object -.IX "XDR" "object" -.LP -The following structure defines the interface to an XDR stream: -.ie t .DS -.el .DS L -.ft CW -enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 }; -.sp.5 -typedef struct { - enum xdr_op x_op; /* \fIoperation; fast added param\fP */ - struct xdr_ops { - bool_t (*x_getlong)(); /* \fIget long from stream\fP */ - bool_t (*x_putlong)(); /* \fIput long to stream\fP */ - bool_t (*x_getbytes)(); /* \fIget bytes from stream\fP */ - bool_t (*x_putbytes)(); /* \fIput bytes to stream\fP */ - u_int (*x_getpostn)(); /* \fIreturn stream offset\fP */ - bool_t (*x_setpostn)(); /* \fIreposition offset\fP */ - caddr_t (*x_inline)(); /* \fIptr to buffered data\fP */ - VOID (*x_destroy)(); /* \fIfree private area\fP */ - } *x_ops; - caddr_t x_public; /* \fIusers' data\fP */ - caddr_t x_private; /* \fIpointer to private data\fP */ - caddr_t x_base; /* \fIprivate for position info\fP */ - int x_handy; /* \fIextra private word\fP */ -} XDR; -.DE -The -.I x_op -field is the current operation being performed on the stream. -This field is important to the XDR primitives, -but should not affect a stream's implementation. -That is, a stream's implementation should not depend -on this value. -The fields -.I x_private , -.I x_base , -and -.I x_handy -are private to the particular -stream's implementation. -The field -.I x_public -is for the XDR client and should never be used by -the XDR stream implementations or the XDR primitives. -.I x_getpostn() , -.I x_setpostn() -and -.I x_destroy() -are macros for accessing operations. The operation -.I x_inline() -takes two parameters: -an XDR *, and an unsigned integer, which is a byte count. -The routine returns a pointer to a piece of -the stream's internal buffer. -The caller can then use the buffer segment for any purpose. -From the stream's point of view, the bytes in the -buffer segment have been consumed or put. -The routine may return -.I NULL -if it cannot return a buffer segment of the requested size. -(The -.I x_inline() -routine is for cycle squeezers. -Use of the resulting buffer is not data-portable. -Users are encouraged not to use this feature.) -.LP -The operations -.I x_getbytes() -and -.I x_putbytes() -blindly get and put sequences of bytes -from or to the underlying stream; -they return -.I TRUE -if they are successful, and -.I FALSE -otherwise. The routines have identical parameters (replace -.I xxx ): -.DS -.ft CW -bool_t -xxxbytes(xdrs, buf, bytecount) - XDR *xdrs; - char *buf; - u_int bytecount; -.DE -The operations -.I x_getlong() -and -.I x_putlong() -receive and put -long numbers from and to the data stream. -It is the responsibility of these routines -to translate the numbers between the machine representation -and the (standard) external representation. -The UNIX primitives -.I htonl() -and -.I ntohl() -can be helpful in accomplishing this. -The higher-level XDR implementation assumes that -signed and unsigned long integers contain the same number of bits, -and that nonnegative integers -have the same bit representations as unsigned integers. -The routines return -.I TRUE -if they succeed, and -.I FALSE -otherwise. They have identical parameters: -.DS -.ft CW -bool_t -xxxlong(xdrs, lp) - XDR *xdrs; - long *lp; -.DE -Implementors of new XDR streams must make an XDR structure -(with new operation routines) available to clients, -using some kind of create routine. -.NH 1 -\&Advanced Topics -.IX XDR "advanced topics" -.LP -This section describes techniques for passing data structures that -are not covered in the preceding sections. Such structures include -linked lists (of arbitrary lengths). Unlike the simpler examples -covered in the earlier sections, the following examples are written -using both the XDR C library routines and the XDR data description -language. -The -.I "External Data Representation Standard: Protocol Specification" -describes this -language in complete detail. -.NH 2 -\&Linked Lists -.IX XDR "linked lists" -.LP -The last example in the -.I Pointers -topic earlier in this chapter -presented a C data structure and its associated XDR -routines for a individual's gross assets and liabilities. -The example is duplicated below: -.ie t .DS -.el .DS L -.ft CW -struct gnumbers { - long g_assets; - long g_liabilities; -}; -.sp.5 -bool_t -xdr_gnumbers(xdrs, gp) - XDR *xdrs; - struct gnumbers *gp; -{ - if (xdr_long(xdrs, &(gp->g_assets))) - return(xdr_long(xdrs, &(gp->g_liabilities))); - return(FALSE); -} -.DE -.LP -Now assume that we wish to implement a linked list of such information. -A data structure could be constructed as follows: -.ie t .DS -.el .DS L -.ft CW -struct gnumbers_node { - struct gnumbers gn_numbers; - struct gnumbers_node *gn_next; -}; -.sp .5 -typedef struct gnumbers_node *gnumbers_list; -.DE -.LP -The head of the linked list can be thought of as the data object; -that is, the head is not merely a convenient shorthand for a -structure. Similarly the -.I gn_next -field is used to indicate whether or not the object has terminated. -Unfortunately, if the object continues, the -.I gn_next -field is also the address of where it continues. The link addresses -carry no useful information when the object is serialized. -.LP -The XDR data description of this linked list is described by the -recursive declaration of -.I gnumbers_list : -.ie t .DS -.el .DS L -.ft CW -struct gnumbers { - int g_assets; - int g_liabilities; -}; -.sp .5 -struct gnumbers_node { - gnumbers gn_numbers; - gnumbers_node *gn_next; -}; -.DE -.LP -In this description, the boolean indicates whether there is more data -following it. If the boolean is -.I FALSE , -then it is the last data field of the structure. If it is -.I TRUE , -then it is followed by a gnumbers structure and (recursively) by a -.I gnumbers_list . -Note that the C declaration has no boolean explicitly declared in it -(though the -.I gn_next -field implicitly carries the information), while the XDR data -description has no pointer explicitly declared in it. -.LP -Hints for writing the XDR routines for a -.I gnumbers_list -follow easily from the XDR description above. Note how the primitive -.I xdr_pointer() -is used to implement the XDR union above. -.ie t .DS -.el .DS L -.ft CW -bool_t -xdr_gnumbers_node(xdrs, gn) - XDR *xdrs; - gnumbers_node *gn; -{ - return(xdr_gnumbers(xdrs, &gn->gn_numbers) && - xdr_gnumbers_list(xdrs, &gp->gn_next)); -} -.sp .5 -bool_t -xdr_gnumbers_list(xdrs, gnp) - XDR *xdrs; - gnumbers_list *gnp; -{ - return(xdr_pointer(xdrs, gnp, - sizeof(struct gnumbers_node), - xdr_gnumbers_node)); -} -.DE -.LP -The unfortunate side effect of XDR'ing a list with these routines -is that the C stack grows linearly with respect to the number of -node in the list. This is due to the recursion. The following -routine collapses the above two mutually recursive into a single, -non-recursive one. -.ie t .DS -.el .DS L -.ft CW -bool_t -xdr_gnumbers_list(xdrs, gnp) - XDR *xdrs; - gnumbers_list *gnp; -{ - bool_t more_data; - gnumbers_list *nextp; -.sp .5 - for (;;) { - more_data = (*gnp != NULL); - if (!xdr_bool(xdrs, &more_data)) { - return(FALSE); - } - if (! more_data) { - break; - } - if (xdrs->x_op == XDR_FREE) { - nextp = &(*gnp)->gn_next; - } - if (!xdr_reference(xdrs, gnp, - sizeof(struct gnumbers_node), xdr_gnumbers)) { - - return(FALSE); - } - gnp = (xdrs->x_op == XDR_FREE) ? - nextp : &(*gnp)->gn_next; - } - *gnp = NULL; - return(TRUE); -} -.DE -.LP -The first task is to find out whether there is more data or not, -so that this boolean information can be serialized. Notice that -this statement is unnecessary in the -.I XDR_DECODE -case, since the value of more_data is not known until we -deserialize it in the next statement. -.LP -The next statement XDR's the more_data field of the XDR union. -Then if there is truly no more data, we set this last pointer to -.I NULL -to indicate the end of the list, and return -.I TRUE -because we are done. Note that setting the pointer to -.I NULL -is only important in the -.I XDR_DECODE -case, since it is already -.I NULL -in the -.I XDR_ENCODE -and -XDR_FREE -cases. -.LP -Next, if the direction is -.I XDR_FREE , -the value of -.I nextp -is set to indicate the location of the next pointer in the list. -We do this now because we need to dereference gnp to find the -location of the next item in the list, and after the next -statement the storage pointed to by -.I gnp -will be freed up and no be longer valid. We can't do this for all -directions though, because in the -.I XDR_DECODE -direction the value of -.I gnp -won't be set until the next statement. -.LP -Next, we XDR the data in the node using the primitive -.I xdr_reference (). -.I xdr_reference() -is like -.I xdr_pointer() -which we used before, but it does not -send over the boolean indicating whether there is more data. -We use it instead of -.I xdr_pointer() -because we have already XDR'd this information ourselves. Notice -that the xdr routine passed is not the same type as an element -in the list. The routine passed is -.I xdr_gnumbers (), -for XDR'ing gnumbers, but each element in the list is actually of -type -.I gnumbers_node . -We don't pass -.I xdr_gnumbers_node() -because it is recursive, and instead use -.I xdr_gnumbers() -which XDR's all of the non-recursive part. Note that this trick -will work only if the -.I gn_numbers -field is the first item in each element, so that their addresses -are identical when passed to -.I xdr_reference (). -.LP -Finally, we update -.I gnp -to point to the next item in the list. If the direction is -.I XDR_FREE , -we set it to the previously saved value, otherwise we can -dereference -.I gnp -to get the proper value. Though harder to understand than the -recursive version, this non-recursive routine is far less likely -to blow the C stack. It will also run more efficiently since -a lot of procedure call overhead has been removed. Most lists -are small though (in the hundreds of items or less) and the -recursive version should be sufficient for them. -.EQ -delim off -.EN diff --git a/lib/librpc/doc/xdr.rfc.ms b/lib/librpc/doc/xdr.rfc.ms deleted file mode 100644 index d4baff53915b..000000000000 --- a/lib/librpc/doc/xdr.rfc.ms +++ /dev/null @@ -1,1058 +0,0 @@ -.\" -.\" Must use -- tbl -- with this one -.\" -.\" @(#)xdr.rfc.ms 2.2 88/08/05 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'External Data Representation Standard''Page %' -.EH 'Page %''External Data Representation Standard' -.IX "External Data Representation" -.if \\n%=1 .bp -.SH -\&External Data Representation Standard: Protocol Specification -.IX XDR RFC -.IX XDR "protocol specification" -.LP -.NH 0 -\&Status of this Standard -.nr OF 1 -.IX XDR "RFC status" -.LP -Note: This chapter specifies a protocol that Sun Microsystems, Inc., and -others are using. It has been designated RFC1014 by the ARPA Network -Information Center. -.NH 1 -Introduction -\& -.LP -XDR is a standard for the description and encoding of data. It is -useful for transferring data between different computer -architectures, and has been used to communicate data between such -diverse machines as the Sun Workstation, VAX, IBM-PC, and Cray. -XDR fits into the ISO presentation layer, and is roughly analogous in -purpose to X.409, ISO Abstract Syntax Notation. The major difference -between these two is that XDR uses implicit typing, while X.409 uses -explicit typing. -.LP -XDR uses a language to describe data formats. The language can only -be used only to describe data; it is not a programming language. -This language allows one to describe intricate data formats in a -concise manner. The alternative of using graphical representations -(itself an informal language) quickly becomes incomprehensible when -faced with complexity. The XDR language itself is similar to the C -language [1], just as Courier [4] is similar to Mesa. Protocols such -as Sun RPC (Remote Procedure Call) and the NFS (Network File System) -use XDR to describe the format of their data. -.LP -The XDR standard makes the following assumption: that bytes (or -octets) are portable, where a byte is defined to be 8 bits of data. -A given hardware device should encode the bytes onto the various -media in such a way that other hardware devices may decode the bytes -without loss of meaning. For example, the Ethernet standard -suggests that bytes be encoded in "little-endian" style [2], or least -significant bit first. -.NH 2 -\&Basic Block Size -.IX XDR "basic block size" -.IX XDR "block size" -.LP -The representation of all items requires a multiple of four bytes (or -32 bits) of data. The bytes are numbered 0 through n-1. The bytes -are read or written to some byte stream such that byte m always -precedes byte m+1. If the n bytes needed to contain the data are not -a multiple of four, then the n bytes are followed by enough (0 to 3) -residual zero bytes, r, to make the total byte count a multiple of 4. -.LP -We include the familiar graphic box notation for illustration and -comparison. In most illustrations, each box (delimited by a plus -sign at the 4 corners and vertical bars and dashes) depicts a byte. -Ellipses (...) between boxes show zero or more additional bytes where -required. -.ie t .DS -.el .DS L -\fIA Block\fP - -\f(CW+--------+--------+...+--------+--------+...+--------+ -| byte 0 | byte 1 |...|byte n-1| 0 |...| 0 | -+--------+--------+...+--------+--------+...+--------+ -|<-----------n bytes---------->|<------r bytes------>| -|<-----------n+r (where (n+r) mod 4 = 0)>----------->|\fP - -.DE -.NH 1 -\&XDR Data Types -.IX XDR "data types" -.IX "XDR data types" -.LP -Each of the sections that follow describes a data type defined in the -XDR standard, shows how it is declared in the language, and includes -a graphic illustration of its encoding. -.LP -For each data type in the language we show a general paradigm -declaration. Note that angle brackets (< and >) denote -variable length sequences of data and square brackets ([ and ]) denote -fixed-length sequences of data. "n", "m" and "r" denote integers. -For the full language specification and more formal definitions of -terms such as "identifier" and "declaration", refer to -.I "The XDR Language Specification" , -below. -.LP -For some data types, more specific examples are included. -A more extensive example of a data description is in -.I "An Example of an XDR Data Description" -below. -.NH 2 -\&Integer -.IX XDR integer -.LP -An XDR signed integer is a 32-bit datum that encodes an integer in -the range [-2147483648,2147483647]. The integer is represented in -two's complement notation. The most and least significant bytes are -0 and 3, respectively. Integers are declared as follows: -.ie t .DS -.el .DS L -\fIInteger\fP - -\f(CW(MSB) (LSB) -+-------+-------+-------+-------+ -|byte 0 |byte 1 |byte 2 |byte 3 | -+-------+-------+-------+-------+ -<------------32 bits------------>\fP -.DE -.NH 2 -\&Unsigned Integer -.IX XDR "unsigned integer" -.IX XDR "integer, unsigned" -.LP -An XDR unsigned integer is a 32-bit datum that encodes a nonnegative -integer in the range [0,4294967295]. It is represented by an -unsigned binary number whose most and least significant bytes are 0 -and 3, respectively. An unsigned integer is declared as follows: -.ie t .DS -.el .DS L -\fIUnsigned Integer\fP - -\f(CW(MSB) (LSB) -+-------+-------+-------+-------+ -|byte 0 |byte 1 |byte 2 |byte 3 | -+-------+-------+-------+-------+ -<------------32 bits------------>\fP -.DE -.NH 2 -\&Enumeration -.IX XDR enumeration -.LP -Enumerations have the same representation as signed integers. -Enumerations are handy for describing subsets of the integers. -Enumerated data is declared as follows: -.ft CW -.DS -enum { name-identifier = constant, ... } identifier; -.DE -For example, the three colors red, yellow, and blue could be -described by an enumerated type: -.DS -.ft CW -enum { RED = 2, YELLOW = 3, BLUE = 5 } colors; -.DE -It is an error to encode as an enum any other integer than those that -have been given assignments in the enum declaration. -.NH 2 -\&Boolean -.IX XDR boolean -.LP -Booleans are important enough and occur frequently enough to warrant -their own explicit type in the standard. Booleans are declared as -follows: -.DS -.ft CW -bool identifier; -.DE -This is equivalent to: -.DS -.ft CW -enum { FALSE = 0, TRUE = 1 } identifier; -.DE -.NH 2 -\&Hyper Integer and Unsigned Hyper Integer -.IX XDR "hyper integer" -.IX XDR "integer, hyper" -.LP -The standard also defines 64-bit (8-byte) numbers called hyper -integer and unsigned hyper integer. Their representations are the -obvious extensions of integer and unsigned integer defined above. -They are represented in two's complement notation. The most and -least significant bytes are 0 and 7, respectively. Their -declarations: -.ie t .DS -.el .DS L -\fIHyper Integer\fP -\fIUnsigned Hyper Integer\fP - -\f(CW(MSB) (LSB) -+-------+-------+-------+-------+-------+-------+-------+-------+ -|byte 0 |byte 1 |byte 2 |byte 3 |byte 4 |byte 5 |byte 6 |byte 7 | -+-------+-------+-------+-------+-------+-------+-------+-------+ -<----------------------------64 bits---------------------------->\fP -.DE -.NH 2 -\&Floating-point -.IX XDR "integer, floating point" -.IX XDR "floating-point integer" -.LP -The standard defines the floating-point data type "float" (32 bits or -4 bytes). The encoding used is the IEEE standard for normalized -single-precision floating-point numbers [3]. The following three -fields describe the single-precision floating-point number: -.RS -.IP \fBS\fP: -The sign of the number. Values 0 and 1 represent positive and -negative, respectively. One bit. -.IP \fBE\fP: -The exponent of the number, base 2. 8 bits are devoted to this -field. The exponent is biased by 127. -.IP \fBF\fP: -The fractional part of the number's mantissa, base 2. 23 bits -are devoted to this field. -.RE -.LP -Therefore, the floating-point number is described by: -.DS -(-1)**S * 2**(E-Bias) * 1.F -.DE -It is declared as follows: -.ie t .DS -.el .DS L -\fISingle-Precision Floating-Point\fP - -\f(CW+-------+-------+-------+-------+ -|byte 0 |byte 1 |byte 2 |byte 3 | -S| E | F | -+-------+-------+-------+-------+ -1|<- 8 ->|<-------23 bits------>| -<------------32 bits------------>\fP -.DE -Just as the most and least significant bytes of a number are 0 and 3, -the most and least significant bits of a single-precision floating- -point number are 0 and 31. The beginning bit (and most significant -bit) offsets of S, E, and F are 0, 1, and 9, respectively. Note that -these numbers refer to the mathematical positions of the bits, and -NOT to their actual physical locations (which vary from medium to -medium). -.LP -The IEEE specifications should be consulted concerning the encoding -for signed zero, signed infinity (overflow), and denormalized numbers -(underflow) [3]. According to IEEE specifications, the "NaN" (not a -number) is system dependent and should not be used externally. -.NH 2 -\&Double-precision Floating-point -.IX XDR "integer, double-precision floating point" -.IX XDR "double-precision floating-point integer" -.LP -The standard defines the encoding for the double-precision floating- -point data type "double" (64 bits or 8 bytes). The encoding used is -the IEEE standard for normalized double-precision floating-point -numbers [3]. The standard encodes the following three fields, which -describe the double-precision floating-point number: -.RS -.IP \fBS\fP: -The sign of the number. Values 0 and 1 represent positive and -negative, respectively. One bit. -.IP \fBE\fP: -The exponent of the number, base 2. 11 bits are devoted to this -field. The exponent is biased by 1023. -.IP \fBF\fP: -The fractional part of the number's mantissa, base 2. 52 bits -are devoted to this field. -.RE -.LP -Therefore, the floating-point number is described by: -.DS -(-1)**S * 2**(E-Bias) * 1.F -.DE -It is declared as follows: -.ie t .DS -.el .DS L -\fIDouble-Precision Floating-Point\fP - -\f(CW+------+------+------+------+------+------+------+------+ -|byte 0|byte 1|byte 2|byte 3|byte 4|byte 5|byte 6|byte 7| -S| E | F | -+------+------+------+------+------+------+------+------+ -1|<--11-->|<-----------------52 bits------------------->| -<-----------------------64 bits------------------------->\fP -.DE -Just as the most and least significant bytes of a number are 0 and 3, -the most and least significant bits of a double-precision floating- -point number are 0 and 63. The beginning bit (and most significant -bit) offsets of S, E , and F are 0, 1, and 12, respectively. Note -that these numbers refer to the mathematical positions of the bits, -and NOT to their actual physical locations (which vary from medium to -medium). -.LP -The IEEE specifications should be consulted concerning the encoding -for signed zero, signed infinity (overflow), and denormalized numbers -(underflow) [3]. According to IEEE specifications, the "NaN" (not a -number) is system dependent and should not be used externally. -.NH 2 -\&Fixed-length Opaque Data -.IX XDR "fixed-length opaque data" -.IX XDR "opaque data, fixed length" -.LP -At times, fixed-length uninterpreted data needs to be passed among -machines. This data is called "opaque" and is declared as follows: -.DS -.ft CW -opaque identifier[n]; -.DE -where the constant n is the (static) number of bytes necessary to -contain the opaque data. If n is not a multiple of four, then the n -bytes are followed by enough (0 to 3) residual zero bytes, r, to make -the total byte count of the opaque object a multiple of four. -.ie t .DS -.el .DS L -\fIFixed-Length Opaque\fP - -\f(CW0 1 ... -+--------+--------+...+--------+--------+...+--------+ -| byte 0 | byte 1 |...|byte n-1| 0 |...| 0 | -+--------+--------+...+--------+--------+...+--------+ -|<-----------n bytes---------->|<------r bytes------>| -|<-----------n+r (where (n+r) mod 4 = 0)------------>|\fP -.DE -.NH 2 -\&Variable-length Opaque Data -.IX XDR "variable-length opaque data" -.IX XDR "opaque data, variable length" -.LP -The standard also provides for variable-length (counted) opaque data, -defined as a sequence of n (numbered 0 through n-1) arbitrary bytes -to be the number n encoded as an unsigned integer (as described -below), and followed by the n bytes of the sequence. -.LP -Byte m of the sequence always precedes byte m+1 of the sequence, and -byte 0 of the sequence always follows the sequence's length (count). -enough (0 to 3) residual zero bytes, r, to make the total byte count -a multiple of four. Variable-length opaque data is declared in the -following way: -.DS -.ft CW -opaque identifier; -.DE -or -.DS -.ft CW -opaque identifier<>; -.DE -The constant m denotes an upper bound of the number of bytes that the -sequence may contain. If m is not specified, as in the second -declaration, it is assumed to be (2**32) - 1, the maximum length. -The constant m would normally be found in a protocol specification. -For example, a filing protocol may state that the maximum data -transfer size is 8192 bytes, as follows: -.DS -.ft CW -opaque filedata<8192>; -.DE -This can be illustrated as follows: -.ie t .DS -.el .DS L -\fIVariable-Length Opaque\fP - -\f(CW0 1 2 3 4 5 ... -+-----+-----+-----+-----+-----+-----+...+-----+-----+...+-----+ -| length n |byte0|byte1|...| n-1 | 0 |...| 0 | -+-----+-----+-----+-----+-----+-----+...+-----+-----+...+-----+ -|<-------4 bytes------->|<------n bytes------>|<---r bytes--->| -|<----n+r (where (n+r) mod 4 = 0)---->|\fP -.DE -.LP -It is an error to encode a length greater than the maximum -described in the specification. -.NH 2 -\&String -.IX XDR string -.LP -The standard defines a string of n (numbered 0 through n-1) ASCII -bytes to be the number n encoded as an unsigned integer (as described -above), and followed by the n bytes of the string. Byte m of the -string always precedes byte m+1 of the string, and byte 0 of the -string always follows the string's length. If n is not a multiple of -four, then the n bytes are followed by enough (0 to 3) residual zero -bytes, r, to make the total byte count a multiple of four. Counted -byte strings are declared as follows: -.DS -.ft CW -string object; -.DE -or -.DS -.ft CW -string object<>; -.DE -The constant m denotes an upper bound of the number of bytes that a -string may contain. If m is not specified, as in the second -declaration, it is assumed to be (2**32) - 1, the maximum length. -The constant m would normally be found in a protocol specification. -For example, a filing protocol may state that a file name can be no -longer than 255 bytes, as follows: -.DS -.ft CW -string filename<255>; -.DE -Which can be illustrated as: -.ie t .DS -.el .DS L -\fIA String\fP - -\f(CW0 1 2 3 4 5 ... -+-----+-----+-----+-----+-----+-----+...+-----+-----+...+-----+ -| length n |byte0|byte1|...| n-1 | 0 |...| 0 | -+-----+-----+-----+-----+-----+-----+...+-----+-----+...+-----+ -|<-------4 bytes------->|<------n bytes------>|<---r bytes--->| -|<----n+r (where (n+r) mod 4 = 0)---->|\fP -.DE -.LP -It is an error to encode a length greater than the maximum -described in the specification. -.NH 2 -\&Fixed-length Array -.IX XDR "fixed-length array" -.IX XDR "array, fixed length" -.LP -Declarations for fixed-length arrays of homogeneous elements are in -the following form: -.DS -.ft CW -type-name identifier[n]; -.DE -Fixed-length arrays of elements numbered 0 through n-1 are encoded by -individually encoding the elements of the array in their natural -order, 0 through n-1. Each element's size is a multiple of four -bytes. Though all elements are of the same type, the elements may -have different sizes. For example, in a fixed-length array of -strings, all elements are of type "string", yet each element will -vary in its length. -.ie t .DS -.el .DS L -\fIFixed-Length Array\fP - -\f(CW+---+---+---+---+---+---+---+---+...+---+---+---+---+ -| element 0 | element 1 |...| element n-1 | -+---+---+---+---+---+---+---+---+...+---+---+---+---+ -|<--------------------n elements------------------->|\fP -.DE -.NH 2 -\&Variable-length Array -.IX XDR "variable-length array" -.IX XDR "array, variable length" -.LP -Counted arrays provide the ability to encode variable-length arrays -of homogeneous elements. The array is encoded as the element count n -(an unsigned integer) followed by the encoding of each of the array's -elements, starting with element 0 and progressing through element n- -1. The declaration for variable-length arrays follows this form: -.DS -.ft CW -type-name identifier; -.DE -or -.DS -.ft CW -type-name identifier<>; -.DE -The constant m specifies the maximum acceptable element count of an -array; if m is not specified, as in the second declaration, it is -assumed to be (2**32) - 1. -.ie t .DS -.el .DS L -\fICounted Array\fP - -\f(CW0 1 2 3 -+--+--+--+--+--+--+--+--+--+--+--+--+...+--+--+--+--+ -| n | element 0 | element 1 |...|element n-1| -+--+--+--+--+--+--+--+--+--+--+--+--+...+--+--+--+--+ -|<-4 bytes->|<--------------n elements------------->|\fP -.DE -It is an error to encode a value of n that is greater than the -maximum described in the specification. -.NH 2 -\&Structure -.IX XDR structure -.LP -Structures are declared as follows: -.DS -.ft CW -struct { - component-declaration-A; - component-declaration-B; - \&... -} identifier; -.DE -The components of the structure are encoded in the order of their -declaration in the structure. Each component's size is a multiple of -four bytes, though the components may be different sizes. -.ie t .DS -.el .DS L -\fIStructure\fP - -\f(CW+-------------+-------------+... -| component A | component B |... -+-------------+-------------+...\fP -.DE -.NH 2 -\&Discriminated Union -.IX XDR "discriminated union" -.IX XDR union discriminated -.LP -A discriminated union is a type composed of a discriminant followed -by a type selected from a set of prearranged types according to the -value of the discriminant. The type of discriminant is either "int", -"unsigned int", or an enumerated type, such as "bool". The component -types are called "arms" of the union, and are preceded by the value -of the discriminant which implies their encoding. Discriminated -unions are declared as follows: -.DS -.ft CW -union switch (discriminant-declaration) { - case discriminant-value-A: - arm-declaration-A; - case discriminant-value-B: - arm-declaration-B; - \&... - default: default-declaration; -} identifier; -.DE -Each "case" keyword is followed by a legal value of the discriminant. -The default arm is optional. If it is not specified, then a valid -encoding of the union cannot take on unspecified discriminant values. -The size of the implied arm is always a multiple of four bytes. -.LP -The discriminated union is encoded as its discriminant followed by -the encoding of the implied arm. -.ie t .DS -.el .DS L -\fIDiscriminated Union\fP - -\f(CW0 1 2 3 -+---+---+---+---+---+---+---+---+ -| discriminant | implied arm | -+---+---+---+---+---+---+---+---+ -|<---4 bytes--->|\fP -.DE -.NH 2 -\&Void -.IX XDR void -.LP -An XDR void is a 0-byte quantity. Voids are useful for describing -operations that take no data as input or no data as output. They are -also useful in unions, where some arms may contain data and others do -not. The declaration is simply as follows: -.DS -.ft CW -void; -.DE -Voids are illustrated as follows: -.ie t .DS -.el .DS L -\fIVoid\fP - -\f(CW ++ - || - ++ ---><-- 0 bytes\fP -.DE -.NH 2 -\&Constant -.IX XDR constant -.LP -The data declaration for a constant follows this form: -.DS -.ft CW -const name-identifier = n; -.DE -"const" is used to define a symbolic name for a constant; it does not -declare any data. The symbolic constant may be used anywhere a -regular constant may be used. For example, the following defines a -symbolic constant DOZEN, equal to 12. -.DS -.ft CW -const DOZEN = 12; -.DE -.NH 2 -\&Typedef -.IX XDR typedef -.LP -"typedef" does not declare any data either, but serves to define new -identifiers for declaring data. The syntax is: -.DS -.ft CW -typedef declaration; -.DE -The new type name is actually the variable name in the declaration -part of the typedef. For example, the following defines a new type -called "eggbox" using an existing type called "egg": -.DS -.ft CW -typedef egg eggbox[DOZEN]; -.DE -Variables declared using the new type name have the same type as the -new type name would have in the typedef, if it was considered a -variable. For example, the following two declarations are equivalent -in declaring the variable "fresheggs": -.DS -.ft CW -eggbox fresheggs; -egg fresheggs[DOZEN]; -.DE -When a typedef involves a struct, enum, or union definition, there is -another (preferred) syntax that may be used to define the same type. -In general, a typedef of the following form: -.DS -.ft CW -typedef <> identifier; -.DE -may be converted to the alternative form by removing the "typedef" -part and placing the identifier after the "struct", "union", or -"enum" keyword, instead of at the end. For example, here are the two -ways to define the type "bool": -.DS -.ft CW -typedef enum { /* \fIusing typedef\fP */ - FALSE = 0, - TRUE = 1 - } bool; - -enum bool { /* \fIpreferred alternative\fP */ - FALSE = 0, - TRUE = 1 - }; -.DE -The reason this syntax is preferred is one does not have to wait -until the end of a declaration to figure out the name of the new -type. -.NH 2 -\&Optional-data -.IX XDR "optional data" -.IX XDR "data, optional" -.LP -Optional-data is one kind of union that occurs so frequently that we -give it a special syntax of its own for declaring it. It is declared -as follows: -.DS -.ft CW -type-name *identifier; -.DE -This is equivalent to the following union: -.DS -.ft CW -union switch (bool opted) { - case TRUE: - type-name element; - case FALSE: - void; -} identifier; -.DE -It is also equivalent to the following variable-length array -declaration, since the boolean "opted" can be interpreted as the -length of the array: -.DS -.ft CW -type-name identifier<1>; -.DE -Optional-data is not so interesting in itself, but it is very useful -for describing recursive data-structures such as linked-lists and -trees. For example, the following defines a type "stringlist" that -encodes lists of arbitrary length strings: -.DS -.ft CW -struct *stringlist { - string item<>; - stringlist next; -}; -.DE -It could have been equivalently declared as the following union: -.DS -.ft CW -union stringlist switch (bool opted) { - case TRUE: - struct { - string item<>; - stringlist next; - } element; - case FALSE: - void; -}; -.DE -or as a variable-length array: -.DS -.ft CW -struct stringlist<1> { - string item<>; - stringlist next; -}; -.DE -Both of these declarations obscure the intention of the stringlist -type, so the optional-data declaration is preferred over both of -them. The optional-data type also has a close correlation to how -recursive data structures are represented in high-level languages -such as Pascal or C by use of pointers. In fact, the syntax is the -same as that of the C language for pointers. -.NH 2 -\&Areas for Future Enhancement -.IX XDR futures -.LP -The XDR standard lacks representations for bit fields and bitmaps, -since the standard is based on bytes. Also missing are packed (or -binary-coded) decimals. -.LP -The intent of the XDR standard was not to describe every kind of data -that people have ever sent or will ever want to send from machine to -machine. Rather, it only describes the most commonly used data-types -of high-level languages such as Pascal or C so that applications -written in these languages will be able to communicate easily over -some medium. -.LP -One could imagine extensions to XDR that would let it describe almost -any existing protocol, such as TCP. The minimum necessary for this -are support for different block sizes and byte-orders. The XDR -discussed here could then be considered the 4-byte big-endian member -of a larger XDR family. -.NH 1 -\&Discussion -.sp 2 -.NH 2 -\&Why a Language for Describing Data? -.IX XDR language -.LP -There are many advantages in using a data-description language such -as XDR versus using diagrams. Languages are more formal than -diagrams and lead to less ambiguous descriptions of data. -Languages are also easier to understand and allow one to think of -other issues instead of the low-level details of bit-encoding. -Also, there is a close analogy between the types of XDR and a -high-level language such as C or Pascal. This makes the -implementation of XDR encoding and decoding modules an easier task. -Finally, the language specification itself is an ASCII string that -can be passed from machine to machine to perform on-the-fly data -interpretation. -.NH 2 -\&Why Only one Byte-Order for an XDR Unit? -.IX XDR "byte order" -.LP -Supporting two byte-orderings requires a higher level protocol for -determining in which byte-order the data is encoded. Since XDR is -not a protocol, this can't be done. The advantage of this, though, -is that data in XDR format can be written to a magnetic tape, for -example, and any machine will be able to interpret it, since no -higher level protocol is necessary for determining the byte-order. -.NH 2 -\&Why does XDR use Big-Endian Byte-Order? -.LP -Yes, it is unfair, but having only one byte-order means you have to -be unfair to somebody. Many architectures, such as the Motorola -68000 and IBM 370, support the big-endian byte-order. -.NH 2 -\&Why is the XDR Unit Four Bytes Wide? -.LP -There is a tradeoff in choosing the XDR unit size. Choosing a small -size such as two makes the encoded data small, but causes alignment -problems for machines that aren't aligned on these boundaries. A -large size such as eight means the data will be aligned on virtually -every machine, but causes the encoded data to grow too big. We chose -four as a compromise. Four is big enough to support most -architectures efficiently, except for rare machines such as the -eight-byte aligned Cray. Four is also small enough to keep the -encoded data restricted to a reasonable size. -.NH 2 -\&Why must Variable-Length Data be Padded with Zeros? -.IX XDR "variable-length data" -.LP -It is desirable that the same data encode into the same thing on all -machines, so that encoded data can be meaningfully compared or -checksummed. Forcing the padded bytes to be zero ensures this. -.NH 2 -\&Why is there No Explicit Data-Typing? -.LP -Data-typing has a relatively high cost for what small advantages it -may have. One cost is the expansion of data due to the inserted type -fields. Another is the added cost of interpreting these type fields -and acting accordingly. And most protocols already know what type -they expect, so data-typing supplies only redundant information. -However, one can still get the benefits of data-typing using XDR. One -way is to encode two things: first a string which is the XDR data -description of the encoded data, and then the encoded data itself. -Another way is to assign a value to all the types in XDR, and then -define a universal type which takes this value as its discriminant -and for each value, describes the corresponding data type. -.NH 1 -\&The XDR Language Specification -.IX XDR language -.sp 1 -.NH 2 -\&Notational Conventions -.IX "XDR language" notation -.LP -This specification uses an extended Backus-Naur Form notation for -describing the XDR language. Here is a brief description of the -notation: -.IP 1. -The characters -.I | , -.I ( , -.I ) , -.I [ , -.I ] , -.I " , -and -.I * -are special. -.IP 2. -Terminal symbols are strings of any characters surrounded by -double quotes. -.IP 3. -Non-terminal symbols are strings of non-special characters. -.IP 4. -Alternative items are separated by a vertical bar ("\fI|\fP"). -.IP 5. -Optional items are enclosed in brackets. -.IP 6. -Items are grouped together by enclosing them in parentheses. -.IP 7. -A -.I * -following an item means 0 or more occurrences of that item. -.LP -For example, consider the following pattern: -.DS L -"a " "very" (", " " very")* [" cold " "and"] " rainy " ("day" | "night") -.DE -.LP -An infinite number of strings match this pattern. A few of them -are: -.DS -"a very rainy day" -"a very, very rainy day" -"a very cold and rainy day" -"a very, very, very cold and rainy night" -.DE -.NH 2 -\&Lexical Notes -.IP 1. -Comments begin with '/*' and terminate with '*/'. -.IP 2. -White space serves to separate items and is otherwise ignored. -.IP 3. -An identifier is a letter followed by an optional sequence of -letters, digits or underbar ('_'). The case of identifiers is -not ignored. -.IP 4. -A constant is a sequence of one or more decimal digits, -optionally preceded by a minus-sign ('-'). -.NH 2 -\&Syntax Information -.IX "XDR language" syntax -.DS -.ft CW -declaration: - type-specifier identifier - | type-specifier identifier "[" value "]" - | type-specifier identifier "<" [ value ] ">" - | "opaque" identifier "[" value "]" - | "opaque" identifier "<" [ value ] ">" - | "string" identifier "<" [ value ] ">" - | type-specifier "*" identifier - | "void" -.DE -.DS -.ft CW -value: - constant - | identifier - -type-specifier: - [ "unsigned" ] "int" - | [ "unsigned" ] "hyper" - | "float" - | "double" - | "bool" - | enum-type-spec - | struct-type-spec - | union-type-spec - | identifier -.DE -.DS -.ft CW -enum-type-spec: - "enum" enum-body - -enum-body: - "{" - ( identifier "=" value ) - ( "," identifier "=" value )* - "}" -.DE -.DS -.ft CW -struct-type-spec: - "struct" struct-body - -struct-body: - "{" - ( declaration ";" ) - ( declaration ";" )* - "}" -.DE -.DS -.ft CW -union-type-spec: - "union" union-body - -union-body: - "switch" "(" declaration ")" "{" - ( "case" value ":" declaration ";" ) - ( "case" value ":" declaration ";" )* - [ "default" ":" declaration ";" ] - "}" - -constant-def: - "const" identifier "=" constant ";" -.DE -.DS -.ft CW -type-def: - "typedef" declaration ";" - | "enum" identifier enum-body ";" - | "struct" identifier struct-body ";" - | "union" identifier union-body ";" - -definition: - type-def - | constant-def - -specification: - definition * -.DE -.NH 3 -\&Syntax Notes -.IX "XDR language" syntax -.LP -.IP 1. -The following are keywords and cannot be used as identifiers: -"bool", "case", "const", "default", "double", "enum", "float", -"hyper", "opaque", "string", "struct", "switch", "typedef", "union", -"unsigned" and "void". -.IP 2. -Only unsigned constants may be used as size specifications for -arrays. If an identifier is used, it must have been declared -previously as an unsigned constant in a "const" definition. -.IP 3. -Constant and type identifiers within the scope of a specification -are in the same name space and must be declared uniquely within this -scope. -.IP 4. -Similarly, variable names must be unique within the scope of -struct and union declarations. Nested struct and union declarations -create new scopes. -.IP 5. -The discriminant of a union must be of a type that evaluates to -an integer. That is, "int", "unsigned int", "bool", an enumerated -type or any typedefed type that evaluates to one of these is legal. -Also, the case values must be one of the legal values of the -discriminant. Finally, a case value may not be specified more than -once within the scope of a union declaration. -.NH 1 -\&An Example of an XDR Data Description -.LP -Here is a short XDR data description of a thing called a "file", -which might be used to transfer files from one machine to another. -.ie t .DS -.el .DS L -.ft CW - -const MAXUSERNAME = 32; /*\fI max length of a user name \fP*/ -const MAXFILELEN = 65535; /*\fI max length of a file \fP*/ -const MAXNAMELEN = 255; /*\fI max length of a file name \fP*/ - -.ft I -/* - * Types of files: - */ -.ft CW - -enum filekind { - TEXT = 0, /*\fI ascii data \fP*/ - DATA = 1, /*\fI raw data \fP*/ - EXEC = 2 /*\fI executable \fP*/ -}; - -.ft I -/* - * File information, per kind of file: - */ -.ft CW - -union filetype switch (filekind kind) { - case TEXT: - void; /*\fI no extra information \fP*/ - case DATA: - string creator; /*\fI data creator \fP*/ - case EXEC: - string interpretor; /*\fI program interpretor \fP*/ -}; - -.ft I -/* - * A complete file: - */ -.ft CW - -struct file { - string filename; /*\fI name of file \fP*/ - filetype type; /*\fI info about file \fP*/ - string owner; /*\fI owner of file \fP*/ - opaque data; /*\fI file data \fP*/ -}; -.DE -.LP -Suppose now that there is a user named "john" who wants to store -his lisp program "sillyprog" that contains just the data "(quit)". -His file would be encoded as follows: -.TS -box tab (&) ; -lfI lfI lfI lfI -rfL rfL rfL l . -Offset&Hex Bytes&ASCII&Description -_ -0&00 00 00 09&....&Length of filename = 9 -4&73 69 6c 6c&sill&Filename characters -8&79 70 72 6f&ypro& ... and more characters ... -12&67 00 00 00&g...& ... and 3 zero-bytes of fill -16&00 00 00 02&....&Filekind is EXEC = 2 -20&00 00 00 04&....&Length of interpretor = 4 -24&6c 69 73 70&lisp&Interpretor characters -28&00 00 00 04&....&Length of owner = 4 -32&6a 6f 68 6e&john&Owner characters -36&00 00 00 06&....&Length of file data = 6 -40&28 71 75 69&(qui&File data bytes ... -44&74 29 00 00&t)..& ... and 2 zero-bytes of fill -.TE -.NH 1 -\&References -.LP -[1] Brian W. Kernighan & Dennis M. Ritchie, "The C Programming -Language", Bell Laboratories, Murray Hill, New Jersey, 1978. -.LP -[2] Danny Cohen, "On Holy Wars and a Plea for Peace", IEEE Computer, -October 1981. -.LP -[3] "IEEE Standard for Binary Floating-Point Arithmetic", ANSI/IEEE -Standard 754-1985, Institute of Electrical and Electronics -Engineers, August 1985. -.LP -[4] "Courier: The Remote Procedure Call Protocol", XEROX -Corporation, XSIS 038112, December 1981. diff --git a/lib/librpc/etc/Makefile b/lib/librpc/etc/Makefile deleted file mode 100644 index beb2ce9bf903..000000000000 --- a/lib/librpc/etc/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/01 4.0 RPCSRC -# -# Files and programs for /etc. rpclib must have already been installed. -# -DESTDIR= -CFLAGS= -O -LIB = -lrpclib -LDFLAGS= $(LIB) - -BIN = portmap rpcinfo -MISC= rpc - -all: ${BIN} - -portmap: - ${CC} ${CFLAGS} -o $@ $@.c ${LDFLAGS} - -rpcinfo: getopt.o - ${CC} ${CFLAGS} -o $@ $@.c getopt.o ${LDFLAGS} - -install: ${BIN} - -mkdir ${DESTDIR}/etc && chown bin ${DESTDIR}/etc && \ - chmod 755 ${DESTDIR}/etc - @echo "Installing RPC utility files in ${DESTDIR}/etc" - @set -x;for i in ${BIN}; do \ - (install -s $$i ${DESTDIR}/etc/$$i); done - @echo "Installing ${DESTDIR}/etc/rpc" - @set -x;for i in ${MISC}; do \ - (install -c -m 644 $$i ${DESTDIR}/etc/$$i); done - -clean: - rm -f core *.o - rm -f ${BIN} - -depend: ${BIN} - rm -f makedep - for i in ${BIN}; do \ - ${CC} -M ${INCPATH} $$i.c | sed 's/\.o//' | \ - awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \ - else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ - else rec = rec " " $$2 } } \ - END { print rec } ' >> makedep; done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - - -depend.42BSD depend.42bsd: - cp /dev/null x.c - for i in $(BIN) ; do \ - (/bin/grep '^#[ ]*include' x.c $$i.c | sed \ - -e 's,<\(.*\)>,"/usr/include/\1",' \ - -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ - -e 's/\.c/\.o/' >>makedep); done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep x.c - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - -# DO NOT DELETE THIS LINE -- make depend uses it - - diff --git a/lib/librpc/etc/getopt.c b/lib/librpc/etc/getopt.c deleted file mode 100644 index 7296b05af2e7..000000000000 --- a/lib/librpc/etc/getopt.c +++ /dev/null @@ -1,75 +0,0 @@ -/* @(#)getopt.c 2.1 88/08/01 4.0 RPCSRC */ - -/* this is a public domain version of getopt */ - -/*LINTLIBRARY*/ -#ifndef NULL -#define NULL 0 -#endif NULL -#ifndef EOF -#define EOF (-1) -#endif EOF - -#define ERR(s, c) if(opterr){\ - extern int strlen(), write();\ - char errbuf[2];\ - errbuf[0] = c; errbuf[1] = '\n';\ - (void) write(2, argv[0], strlen(argv[0]));\ - (void) write(2, s, strlen(s));\ - (void) write(2, errbuf, 2);} - -#define strchr index - -extern int strcmp(); -extern char *strchr(); - -int opterr = 1; -int optind = 1; -int optopt; -char *optarg; - -int -getopt(argc, argv, opts) -int argc; -char **argv, *opts; -{ - static int sp = 1; - register int c; - register char *cp; - - if(sp == 1) - if(optind >= argc || - argv[optind][0] != '-' || argv[optind][1] == '\0') - return(EOF); - else if(strcmp(argv[optind], "--") == NULL) { - optind++; - return(EOF); - } - optopt = c = argv[optind][sp]; - if(c == ':' || (cp=strchr(opts, c)) == NULL) { - ERR(": unknown option, -", c); - if(argv[optind][++sp] == '\0') { - optind++; - sp = 1; - } - return('?'); - } - if(*++cp == ':') { - if(argv[optind][sp+1] != '\0') - optarg = &argv[optind++][sp+1]; - else if(++optind >= argc) { - ERR(": argument missing for -", c); - sp = 1; - return('?'); - } else - optarg = argv[optind++]; - sp = 1; - } else { - if(argv[optind][++sp] == '\0') { - sp = 1; - optind++; - } - optarg = NULL; - } - return(c); -} diff --git a/lib/librpc/etc/portmap.c b/lib/librpc/etc/portmap.c deleted file mode 100644 index adfdef955ecd..000000000000 --- a/lib/librpc/etc/portmap.c +++ /dev/null @@ -1,481 +0,0 @@ -/* @(#)portmap.c 2.3 88/08/11 4.0 RPCSRC */ -#ifndef lint -static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro"; -#endif - -/* - * Copyright (c) 1984 by Sun Microsystems, Inc. - */ - -/* - * portmap.c, Implements the program,version to port number mapping for - * rpc. - */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -char *malloc(); -int reg_service(); -void reap(); -struct pmaplist *pmaplist; -static int debugging = 0; - -main() -{ - SVCXPRT *xprt; - int sock, pid, t; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - register struct pmaplist *pml; - -#ifndef DEBUG - pid = fork(); - if (pid < 0) { - perror("portmap: fork"); - exit(1); - } - if (pid != 0) - exit(0); - for (t = 0; t < 20; t++) - close(t); - open("/", 0); - dup2(0, 1); - dup2(0, 2); - t = open("/dev/tty", 2); - if (t >= 0) { - ioctl(t, TIOCNOTTY, (char *)0); - close(t); - } -#endif - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("portmap cannot create socket"); - exit(1); - } - - addr.sin_addr.s_addr = 0; - addr.sin_family = AF_INET; - addr.sin_port = htons(PMAPPORT); - if (bind(sock, (struct sockaddr *)&addr, len) != 0) { - perror("portmap cannot bind"); - exit(1); - } - - if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) { - fprintf(stderr, "couldn't do udp_create\n"); - exit(1); - } - /* make an entry for ourself */ - pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); - pml->pml_next = 0; - pml->pml_map.pm_prog = PMAPPROG; - pml->pml_map.pm_vers = PMAPVERS; - pml->pml_map.pm_prot = IPPROTO_UDP; - pml->pml_map.pm_port = PMAPPORT; - pmaplist = pml; - - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - perror("portmap cannot create socket"); - exit(1); - } - if (bind(sock, (struct sockaddr *)&addr, len) != 0) { - perror("portmap cannot bind"); - exit(1); - } - if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE)) - == (SVCXPRT *)NULL) { - fprintf(stderr, "couldn't do tcp_create\n"); - exit(1); - } - /* make an entry for ourself */ - pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); - pml->pml_map.pm_prog = PMAPPROG; - pml->pml_map.pm_vers = PMAPVERS; - pml->pml_map.pm_prot = IPPROTO_TCP; - pml->pml_map.pm_port = PMAPPORT; - pml->pml_next = pmaplist; - pmaplist = pml; - - (void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE); - - (void)signal(SIGCHLD, reap); - svc_run(); - fprintf(stderr, "run_svc returned unexpectedly\n"); - abort(); -} - -static struct pmaplist * -find_service(prog, vers, prot) - u_long prog; - u_long vers; -{ - register struct pmaplist *hit = NULL; - register struct pmaplist *pml; - - for (pml = pmaplist; pml != NULL; pml = pml->pml_next) { - if ((pml->pml_map.pm_prog != prog) || - (pml->pml_map.pm_prot != prot)) - continue; - hit = pml; - if (pml->pml_map.pm_vers == vers) - break; - } - return (hit); -} - -/* - * 1 OK, 0 not - */ -reg_service(rqstp, xprt) - struct svc_req *rqstp; - SVCXPRT *xprt; -{ - struct pmap reg; - struct pmaplist *pml, *prevpml, *fnd; - int ans, port; - caddr_t t; - -#ifdef DEBUG - fprintf(stderr, "server: about do a switch\n"); -#endif - switch (rqstp->rq_proc) { - - case PMAPPROC_NULL: - /* - * Null proc call - */ - if ((!svc_sendreply(xprt, xdr_void, NULL)) && debugging) { - abort(); - } - break; - - case PMAPPROC_SET: - /* - * Set a program,version to port mapping - */ - if (!svc_getargs(xprt, xdr_pmap, ®)) - svcerr_decode(xprt); - else { - /* - * check to see if already used - * find_service returns a hit even if - * the versions don't match, so check for it - */ - fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); - if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) { - if (fnd->pml_map.pm_port == reg.pm_port) { - ans = 1; - goto done; - } - else { - ans = 0; - goto done; - } - } else { - /* - * add to END of list - */ - pml = (struct pmaplist *) - malloc((u_int)sizeof(struct pmaplist)); - pml->pml_map = reg; - pml->pml_next = 0; - if (pmaplist == 0) { - pmaplist = pml; - } else { - for (fnd= pmaplist; fnd->pml_next != 0; - fnd = fnd->pml_next); - fnd->pml_next = pml; - } - ans = 1; - } - done: - if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && - debugging) { - fprintf(stderr, "svc_sendreply\n"); - abort(); - } - } - break; - - case PMAPPROC_UNSET: - /* - * Remove a program,version to port mapping. - */ - if (!svc_getargs(xprt, xdr_pmap, ®)) - svcerr_decode(xprt); - else { - ans = 0; - for (prevpml = NULL, pml = pmaplist; pml != NULL; ) { - if ((pml->pml_map.pm_prog != reg.pm_prog) || - (pml->pml_map.pm_vers != reg.pm_vers)) { - /* both pml & prevpml move forwards */ - prevpml = pml; - pml = pml->pml_next; - continue; - } - /* found it; pml moves forward, prevpml stays */ - ans = 1; - t = (caddr_t)pml; - pml = pml->pml_next; - if (prevpml == NULL) - pmaplist = pml; - else - prevpml->pml_next = pml; - free(t); - } - if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && - debugging) { - fprintf(stderr, "svc_sendreply\n"); - abort(); - } - } - break; - - case PMAPPROC_GETPORT: - /* - * Lookup the mapping for a program,version and return its port - */ - if (!svc_getargs(xprt, xdr_pmap, ®)) - svcerr_decode(xprt); - else { - fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); - if (fnd) - port = fnd->pml_map.pm_port; - else - port = 0; - if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) && - debugging) { - fprintf(stderr, "svc_sendreply\n"); - abort(); - } - } - break; - - case PMAPPROC_DUMP: - /* - * Return the current set of mapped program,version - */ - if (!svc_getargs(xprt, xdr_void, NULL)) - svcerr_decode(xprt); - else { - if ((!svc_sendreply(xprt, xdr_pmaplist, - (caddr_t)&pmaplist)) && debugging) { - fprintf(stderr, "svc_sendreply\n"); - abort(); - } - } - break; - - case PMAPPROC_CALLIT: - /* - * Calls a procedure on the local machine. If the requested - * procedure is not registered this procedure does not return - * error information!! - * This procedure is only supported on rpc/udp and calls via - * rpc/udp. It passes null authentication parameters. - */ - callit(rqstp, xprt); - break; - - default: - svcerr_noproc(xprt); - break; - } -} - - -/* - * Stuff for the rmtcall service - */ -#define ARGSIZE 9000 - -typedef struct encap_parms { - u_long arglen; - char *args; -}; - -static bool_t -xdr_encap_parms(xdrs, epp) - XDR *xdrs; - struct encap_parms *epp; -{ - - return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE)); -} - -typedef struct rmtcallargs { - u_long rmt_prog; - u_long rmt_vers; - u_long rmt_port; - u_long rmt_proc; - struct encap_parms rmt_args; -}; - -static bool_t -xdr_rmtcall_args(xdrs, cap) - register XDR *xdrs; - register struct rmtcallargs *cap; -{ - - /* does not get a port number */ - if (xdr_u_long(xdrs, &(cap->rmt_prog)) && - xdr_u_long(xdrs, &(cap->rmt_vers)) && - xdr_u_long(xdrs, &(cap->rmt_proc))) { - return (xdr_encap_parms(xdrs, &(cap->rmt_args))); - } - return (FALSE); -} - -static bool_t -xdr_rmtcall_result(xdrs, cap) - register XDR *xdrs; - register struct rmtcallargs *cap; -{ - if (xdr_u_long(xdrs, &(cap->rmt_port))) - return (xdr_encap_parms(xdrs, &(cap->rmt_args))); - return (FALSE); -} - -/* - * only worries about the struct encap_parms part of struct rmtcallargs. - * The arglen must already be set!! - */ -static bool_t -xdr_opaque_parms(xdrs, cap) - XDR *xdrs; - struct rmtcallargs *cap; -{ - - return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen)); -} - -/* - * This routine finds and sets the length of incoming opaque paraters - * and then calls xdr_opaque_parms. - */ -static bool_t -xdr_len_opaque_parms(xdrs, cap) - register XDR *xdrs; - struct rmtcallargs *cap; -{ - register u_int beginpos, lowpos, highpos, currpos, pos; - - beginpos = lowpos = pos = xdr_getpos(xdrs); - highpos = lowpos + ARGSIZE; - while ((int)(highpos - lowpos) >= 0) { - currpos = (lowpos + highpos) / 2; - if (xdr_setpos(xdrs, currpos)) { - pos = currpos; - lowpos = currpos + 1; - } else { - highpos = currpos - 1; - } - } - xdr_setpos(xdrs, beginpos); - cap->rmt_args.arglen = pos - beginpos; - return (xdr_opaque_parms(xdrs, cap)); -} - -/* - * Call a remote procedure service - * This procedure is very quiet when things go wrong. - * The proc is written to support broadcast rpc. In the broadcast case, - * a machine should shut-up instead of complain, less the requestor be - * overrun with complaints at the expense of not hearing a valid reply ... - * - * This now forks so that the program & process that it calls can call - * back to the portmapper. - */ -static -callit(rqstp, xprt) - struct svc_req *rqstp; - SVCXPRT *xprt; -{ - struct rmtcallargs a; - struct pmaplist *pml; - u_short port; - struct sockaddr_in me; - int pid, socket = -1; - CLIENT *client; - struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred; - struct timeval timeout; - char buf[ARGSIZE]; - - timeout.tv_sec = 5; - timeout.tv_usec = 0; - a.rmt_args.args = buf; - if (!svc_getargs(xprt, xdr_rmtcall_args, &a)) - return; - if ((pml = find_service(a.rmt_prog, a.rmt_vers, IPPROTO_UDP)) == NULL) - return; - /* - * fork a child to do the work. Parent immediately returns. - * Child exits upon completion. - */ - if ((pid = fork()) != 0) { - if (debugging && (pid < 0)) { - fprintf(stderr, "portmap CALLIT: cannot fork.\n"); - } - return; - } - port = pml->pml_map.pm_port; - get_myaddress(&me); - me.sin_port = htons(port); - client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &socket); - if (client != (CLIENT *)NULL) { - if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) { - client->cl_auth = authunix_create(au->aup_machname, - au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids); - } - a.rmt_port = (u_long)port; - if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a, - xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) { - svc_sendreply(xprt, xdr_rmtcall_result, &a); - } - AUTH_DESTROY(client->cl_auth); - clnt_destroy(client); - } - (void)close(socket); - exit(0); -} - -void -reap() -{ - while (wait3(NULL, WNOHANG, NULL) > 0); -} diff --git a/lib/librpc/etc/rpc b/lib/librpc/etc/rpc deleted file mode 100644 index bebfb51b731a..000000000000 --- a/lib/librpc/etc/rpc +++ /dev/null @@ -1,33 +0,0 @@ -# -# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI -# -portmapper 100000 portmap sunrpc -rstatd 100001 rstat rstat_svc rup perfmeter -rusersd 100002 rusers -nfs 100003 nfsprog -ypserv 100004 ypprog -mountd 100005 mount showmount -ypbind 100007 -walld 100008 rwall shutdown -yppasswdd 100009 yppasswd -etherstatd 100010 etherstat -rquotad 100011 rquotaprog quota rquota -sprayd 100012 spray -3270_mapper 100013 -rje_mapper 100014 -selection_svc 100015 selnsvc -database_svc 100016 -rexd 100017 rex -alis 100018 -sched 100019 -llockmgr 100020 -nlockmgr 100021 -x25.inr 100022 -statmon 100023 -status 100024 -bootparam 100026 -ypupdated 100028 ypupdate -keyserv 100029 keyserver -tfsd 100037 -nsed 100038 -nsemntd 100039 diff --git a/lib/librpc/etc/rpcinfo.c b/lib/librpc/etc/rpcinfo.c deleted file mode 100644 index 961f9b0b2d75..000000000000 --- a/lib/librpc/etc/rpcinfo.c +++ /dev/null @@ -1,665 +0,0 @@ -/* @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC */ -#ifndef lint -static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI"; -#endif - -/* - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -/* - * rpcinfo: ping a particular rpc program - * or dump the portmapper - */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXHOSTLEN 256 - -#define MIN_VERS ((u_long) 0) -#define MAX_VERS ((u_long) 4294967295L) - -static void udpping(/*u_short portflag, int argc, char **argv*/); -static void tcpping(/*u_short portflag, int argc, char **argv*/); -static int pstatus(/*CLIENT *client, u_long prognum, u_long vers*/); -static void pmapdump(/*int argc, char **argv*/); -static bool_t reply_proc(/*void *res, struct sockaddr_in *who*/); -static void brdcst(/*int argc, char **argv*/); -static void deletereg(/* int argc, char **argv */) ; -static void usage(/*void*/); -static u_long getprognum(/*char *arg*/); -static u_long getvers(/*char *arg*/); -static void get_inet_address(/*struct sockaddr_in *addr, char *host*/); -extern u_long inet_addr(); /* in 4.2BSD, arpa/inet.h called that a in_addr */ -extern char *inet_ntoa(); - -/* - * Functions to be performed. - */ -#define NONE 0 /* no function */ -#define PMAPDUMP 1 /* dump portmapper registrations */ -#define TCPPING 2 /* ping TCP service */ -#define UDPPING 3 /* ping UDP service */ -#define BRDCST 4 /* ping broadcast UDP service */ -#define DELETES 5 /* delete registration for the service */ - -int -main(argc, argv) - int argc; - char **argv; -{ - register int c; - extern char *optarg; - extern int optind; - int errflg; - int function; - u_short portnum; - - function = NONE; - portnum = 0; - errflg = 0; - while ((c = getopt(argc, argv, "ptubdn:")) != EOF) { - switch (c) { - - case 'p': - if (function != NONE) - errflg = 1; - else - function = PMAPDUMP; - break; - - case 't': - if (function != NONE) - errflg = 1; - else - function = TCPPING; - break; - - case 'u': - if (function != NONE) - errflg = 1; - else - function = UDPPING; - break; - - case 'b': - if (function != NONE) - errflg = 1; - else - function = BRDCST; - break; - - case 'n': - portnum = (u_short) atoi(optarg); /* hope we don't get bogus # */ - break; - - case 'd': - if (function != NONE) - errflg = 1; - else - function = DELETES; - break; - - case '?': - errflg = 1; - } - } - - if (errflg || function == NONE) { - usage(); - return (1); - } - - switch (function) { - - case PMAPDUMP: - if (portnum != 0) { - usage(); - return (1); - } - pmapdump(argc - optind, argv + optind); - break; - - case UDPPING: - udpping(portnum, argc - optind, argv + optind); - break; - - case TCPPING: - tcpping(portnum, argc - optind, argv + optind); - break; - - case BRDCST: - if (portnum != 0) { - usage(); - return (1); - } - brdcst(argc - optind, argv + optind); - break; - - case DELETES: - deletereg(argc - optind, argv + optind); - break; - } - - return (0); -} - -static void -udpping(portnum, argc, argv) - u_short portnum; - int argc; - char **argv; -{ - struct timeval to; - struct sockaddr_in addr; - enum clnt_stat rpc_stat; - CLIENT *client; - u_long prognum, vers, minvers, maxvers; - int sock = RPC_ANYSOCK; - struct rpc_err rpcerr; - int failure; - - if (argc < 2 || argc > 3) { - usage(); - exit(1); - } - prognum = getprognum(argv[1]); - get_inet_address(&addr, argv[0]); - /* Open the socket here so it will survive calls to clnt_destroy */ - sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (sock < 0) { - perror("rpcinfo: socket"); - exit(1); - } - failure = 0; - if (argc == 2) { - /* - * A call to version 0 should fail with a program/version - * mismatch, and give us the range of versions supported. - */ - addr.sin_port = htons(portnum); - to.tv_sec = 5; - to.tv_usec = 0; - if ((client = clntudp_create(&addr, prognum, (u_long)0, - to, &sock)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu is not available\n", - prognum); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL, - xdr_void, (char *)NULL, to); - if (rpc_stat == RPC_PROGVERSMISMATCH) { - clnt_geterr(client, &rpcerr); - minvers = rpcerr.re_vers.low; - maxvers = rpcerr.re_vers.high; - } else if (rpc_stat == RPC_SUCCESS) { - /* - * Oh dear, it DOES support version 0. - * Let's try version MAX_VERS. - */ - addr.sin_port = htons(portnum); - to.tv_sec = 5; - to.tv_usec = 0; - if ((client = clntudp_create(&addr, prognum, MAX_VERS, - to, &sock)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, MAX_VERS); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, NULLPROC, xdr_void, - (char *)NULL, xdr_void, (char *)NULL, to); - if (rpc_stat == RPC_PROGVERSMISMATCH) { - clnt_geterr(client, &rpcerr); - minvers = rpcerr.re_vers.low; - maxvers = rpcerr.re_vers.high; - } else if (rpc_stat == RPC_SUCCESS) { - /* - * It also supports version MAX_VERS. - * Looks like we have a wise guy. - * OK, we give them information on all - * 4 billion versions they support... - */ - minvers = 0; - maxvers = MAX_VERS; - } else { - (void) pstatus(client, prognum, MAX_VERS); - exit(1); - } - } else { - (void) pstatus(client, prognum, (u_long)0); - exit(1); - } - clnt_destroy(client); - for (vers = minvers; vers <= maxvers; vers++) { - addr.sin_port = htons(portnum); - to.tv_sec = 5; - to.tv_usec = 0; - if ((client = clntudp_create(&addr, prognum, vers, - to, &sock)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, vers); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, NULLPROC, xdr_void, - (char *)NULL, xdr_void, (char *)NULL, to); - if (pstatus(client, prognum, vers) < 0) - failure = 1; - clnt_destroy(client); - } - } - else { - vers = getvers(argv[2]); - addr.sin_port = htons(portnum); - to.tv_sec = 5; - to.tv_usec = 0; - if ((client = clntudp_create(&addr, prognum, vers, - to, &sock)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, vers); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, - xdr_void, (char *)NULL, to); - if (pstatus(client, prognum, vers) < 0) - failure = 1; - } - (void) close(sock); /* Close it up again */ - if (failure) - exit(1); -} - -static void -tcpping(portnum, argc, argv) - u_short portnum; - int argc; - char **argv; -{ - struct timeval to; - struct sockaddr_in addr; - enum clnt_stat rpc_stat; - CLIENT *client; - u_long prognum, vers, minvers, maxvers; - int sock = RPC_ANYSOCK; - struct rpc_err rpcerr; - int failure; - - if (argc < 2 || argc > 3) { - usage(); - exit(1); - } - prognum = getprognum(argv[1]); - get_inet_address(&addr, argv[0]); - failure = 0; - if (argc == 2) { - /* - * A call to version 0 should fail with a program/version - * mismatch, and give us the range of versions supported. - */ - addr.sin_port = htons(portnum); - if ((client = clnttcp_create(&addr, prognum, MIN_VERS, - &sock, 0, 0)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu is not available\n", - prognum); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL, - xdr_void, (char *)NULL, to); - if (rpc_stat == RPC_PROGVERSMISMATCH) { - clnt_geterr(client, &rpcerr); - minvers = rpcerr.re_vers.low; - maxvers = rpcerr.re_vers.high; - } else if (rpc_stat == RPC_SUCCESS) { - /* - * Oh dear, it DOES support version 0. - * Let's try version MAX_VERS. - */ - addr.sin_port = htons(portnum); - if ((client = clnttcp_create(&addr, prognum, MAX_VERS, - &sock, 0, 0)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, MAX_VERS); - exit(1); - } - to.tv_sec = 10; - to.tv_usec = 0; - rpc_stat = clnt_call(client, NULLPROC, xdr_void, - (char *)NULL, xdr_void, (char *)NULL, to); - if (rpc_stat == RPC_PROGVERSMISMATCH) { - clnt_geterr(client, &rpcerr); - minvers = rpcerr.re_vers.low; - maxvers = rpcerr.re_vers.high; - } else if (rpc_stat == RPC_SUCCESS) { - /* - * It also supports version MAX_VERS. - * Looks like we have a wise guy. - * OK, we give them information on all - * 4 billion versions they support... - */ - minvers = 0; - maxvers = MAX_VERS; - } else { - (void) pstatus(client, prognum, MAX_VERS); - exit(1); - } - } else { - (void) pstatus(client, prognum, MIN_VERS); - exit(1); - } - clnt_destroy(client); - (void) close(sock); - sock = RPC_ANYSOCK; /* Re-initialize it for later */ - for (vers = minvers; vers <= maxvers; vers++) { - addr.sin_port = htons(portnum); - if ((client = clnttcp_create(&addr, prognum, vers, - &sock, 0, 0)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, vers); - exit(1); - } - to.tv_usec = 0; - to.tv_sec = 10; - rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, - xdr_void, (char *)NULL, to); - if (pstatus(client, prognum, vers) < 0) - failure = 1; - clnt_destroy(client); - (void) close(sock); - sock = RPC_ANYSOCK; - } - } - else { - vers = getvers(argv[2]); - addr.sin_port = htons(portnum); - if ((client = clnttcp_create(&addr, prognum, vers, &sock, - 0, 0)) == NULL) { - clnt_pcreateerror("rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, vers); - exit(1); - } - to.tv_usec = 0; - to.tv_sec = 10; - rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, - xdr_void, (char *)NULL, to); - if (pstatus(client, prognum, vers) < 0) - failure = 1; - } - if (failure) - exit(1); -} - -/* - * This routine should take a pointer to an "rpc_err" structure, rather than - * a pointer to a CLIENT structure, but "clnt_perror" takes a pointer to - * a CLIENT structure rather than a pointer to an "rpc_err" structure. - * As such, we have to keep the CLIENT structure around in order to print - * a good error message. - */ -static int -pstatus(client, prognum, vers) - register CLIENT *client; - u_long prognum; - u_long vers; -{ - struct rpc_err rpcerr; - - clnt_geterr(client, &rpcerr); - if (rpcerr.re_status != RPC_SUCCESS) { - clnt_perror(client, "rpcinfo"); - printf("program %lu version %lu is not available\n", - prognum, vers); - return (-1); - } else { - printf("program %lu version %lu ready and waiting\n", - prognum, vers); - return (0); - } -} - -static void -pmapdump(argc, argv) - int argc; - char **argv; -{ - struct sockaddr_in server_addr; - register struct hostent *hp; - struct pmaplist *head = NULL; - int socket = RPC_ANYSOCK; - struct timeval minutetimeout; - register CLIENT *client; - struct rpcent *rpc; - - if (argc > 1) { - usage(); - exit(1); - } - if (argc == 1) - get_inet_address(&server_addr, argv[0]); - else { - bzero((char *)&server_addr, sizeof server_addr); - server_addr.sin_family = AF_INET; - if ((hp = gethostbyname("localhost")) != NULL) - bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, - hp->h_length); - else - server_addr.sin_addr.s_addr = inet_addr("0.0.0.0"); - } - minutetimeout.tv_sec = 60; - minutetimeout.tv_usec = 0; - server_addr.sin_port = htons(PMAPPORT); - if ((client = clnttcp_create(&server_addr, PMAPPROG, - PMAPVERS, &socket, 50, 500)) == NULL) { - clnt_pcreateerror("rpcinfo: can't contact portmapper"); - exit(1); - } - if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL, - xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) { - fprintf(stderr, "rpcinfo: can't contact portmapper: "); - clnt_perror(client, "rpcinfo"); - exit(1); - } - if (head == NULL) { - printf("No remote programs registered.\n"); - } else { - printf(" program vers proto port\n"); - for (; head != NULL; head = head->pml_next) { - printf("%10ld%5ld", - head->pml_map.pm_prog, - head->pml_map.pm_vers); - if (head->pml_map.pm_prot == IPPROTO_UDP) - printf("%6s", "udp"); - else if (head->pml_map.pm_prot == IPPROTO_TCP) - printf("%6s", "tcp"); - else - printf("%6ld", head->pml_map.pm_prot); - printf("%7ld", head->pml_map.pm_port); - rpc = getrpcbynumber(head->pml_map.pm_prog); - if (rpc) - printf(" %s\n", rpc->r_name); - else - printf("\n"); - } - } -} - -/* - * reply_proc collects replies from the broadcast. - * to get a unique list of responses the output of rpcinfo should - * be piped through sort(1) and then uniq(1). - */ - -/*ARGSUSED*/ -static bool_t -reply_proc(res, who) - void *res; /* Nothing comes back */ - struct sockaddr_in *who; /* Who sent us the reply */ -{ - register struct hostent *hp; - - hp = gethostbyaddr((char *) &who->sin_addr, sizeof who->sin_addr, - AF_INET); - printf("%s %s\n", inet_ntoa(who->sin_addr), - (hp == NULL) ? "(unknown)" : hp->h_name); - return(FALSE); -} - -static void -brdcst(argc, argv) - int argc; - char **argv; -{ - enum clnt_stat rpc_stat; - u_long prognum, vers; - - if (argc != 2) { - usage(); - exit(1); - } - prognum = getprognum(argv[0]); - vers = getvers(argv[1]); - rpc_stat = clnt_broadcast(prognum, vers, NULLPROC, xdr_void, - (char *)NULL, xdr_void, (char *)NULL, reply_proc); - if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT)) { - fprintf(stderr, "rpcinfo: broadcast failed: %s\n", - clnt_sperrno(rpc_stat)); - exit(1); - } - exit(0); -} - -static void -deletereg(argc, argv) - int argc; - char **argv; -{ u_long prog_num, version_num ; - - if (argc != 2) { - usage() ; - exit(1) ; - } - if (getuid()) { /* This command allowed only to root */ - fprintf(stderr, "Sorry. You are not root\n") ; - exit(1) ; - } - prog_num = getprognum(argv[0]); - version_num = getvers(argv[1]); - if ((pmap_unset(prog_num, version_num)) == 0) { - fprintf(stderr, "rpcinfo: Could not delete registration for prog %s version %s\n", - argv[0], argv[1]) ; - exit(1) ; - } -} - -static void -usage() -{ - fprintf(stderr, "Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n"); - fprintf(stderr, " rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n"); - fprintf(stderr, " rpcinfo -p [ host ]\n"); - fprintf(stderr, " rpcinfo -b prognum versnum\n"); - fprintf(stderr, " rpcinfo -d prognum versnum\n") ; -} - -static u_long -getprognum(arg) - char *arg; -{ - register struct rpcent *rpc; - register u_long prognum; - - if (isalpha(*arg)) { - rpc = getrpcbyname(arg); - if (rpc == NULL) { - fprintf(stderr, "rpcinfo: %s is unknown service\n", - arg); - exit(1); - } - prognum = rpc->r_number; - } else { - prognum = (u_long) atoi(arg); - } - - return (prognum); -} - -static u_long -getvers(arg) - char *arg; -{ - register u_long vers; - - vers = (int) atoi(arg); - return (vers); -} - -static void -get_inet_address(addr, host) - struct sockaddr_in *addr; - char *host; -{ - register struct hostent *hp; - - bzero((char *)addr, sizeof *addr); - addr->sin_addr.s_addr = (u_long) inet_addr(host); - if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) { - if ((hp = gethostbyname(host)) == NULL) { - fprintf(stderr, "rpcinfo: %s is unknown host\n", host); - exit(1); - } - bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length); - } - addr->sin_family = AF_INET; -} diff --git a/lib/librpc/man/man1/rpcgen.1 b/lib/librpc/man/man1/rpcgen.1 deleted file mode 100644 index 6c50cecfb6b2..000000000000 --- a/lib/librpc/man/man1/rpcgen.1 +++ /dev/null @@ -1,197 +0,0 @@ -.\" Copyright 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Derived from Sun Microsystems rpcgen.1 2.2 88/08/02 4.0 RPCSRC -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rpcgen.1 5.4 (Berkeley) 12/30/93 -.\" -.Dd December 30, 1993 -.Dt RPCGEN 1 -.Sh NAME -.Nm rpcgen -.Nd an -.Tn RPC -protocol compiler -.Sh SYNOPSIS -.Nm rpcgen Ar infile -.Nm rpcgen -.Fl c | Fl h | Fl l | -.Fl m -.Op Fl o Ar outfile -.Op Ar infile -.Nm rpcgen Fl s Ar transport -.Op Fl o Ar outfile -.Op Ar infile -.Sh DESCRIPTION -.Nm rpcgen -is a tool that generates -.Tn \&C -code to implement an -.Tn RPC -protocol. The input to -.Nm rpcgen -is a language similar to C -known as -.Tn RPC -Language (Remote Procedure Call Language). Information -about the syntax of -.Tn RPC -Language is available in the -.Rs -.%T "Rpcgen Programming Guide" -.Re -.Pp -Available options: -.Bl -tag -width indent -.It Fl c -Compile into -.Dv XDR -routines. -.It Fl h -Compile into -.Tn \&C -data-definitions (a header file) -.It Fl l -Compile into client-side stubs. -.It Fl m -Compile into server-side stubs, but do not generate a -.Em main -routine. -This option is useful for doing callback-routines and for people who -need to write their own -.Em main -routine to do initialization. -.It Fl o Ar outfile -Specify the name of the output file. -If none is specified, standard output is used -.Pf ( Fl c , -.Fl h , -.Fl l -and -.Fl s -modes only). -.It Fl s Ar transport -Compile into server-side stubs, using the given transport. The -supported transports -are -.Tn UDP -and -.Tn TCP . -This option may be invoked more than once -so as to compile a server that serves multiple transports. -.El -.Pp -.Nm rpcgen -is normally used as in the first synopsis where it takes an input file -and generates four output files. If the -.Ar infile -is named -.Pa proto.x , -then -.Nm rpcgen -will generate a header file in -.Pa proto.h , -.Dv XDR -routines in -.Pa proto_xdr.c , -server-side stubs in -.Pa proto_svc.c , -and client-side stubs in -.Pa proto_clnt.c . -.Pp -The other synopses shown above are used when one does not want to -generate all the output files, but only a particular one. Their -usage is described in the -.Sx USAGE -section below. -.Pp -The C-preprocessor, -.Xr cpp 1 , -is run on all input files before they are actually -interpreted by -.Nm rpcgen , -so all the -.Xr cpp -directives are legal within an -.Nm rpcgen -input file. For each type of output file, -.Nm rpcgen -defines a special -.Xr cpp -symbol for use by the -.Nm rpcgen -programmer: -.Pp -.Bl -tag -width "RPC_CLNT" -.It Dv RPC_HDR -defined when compiling into header files -.It Dv RPC_XDR -defined when compiling into -.Dv XDR -routines -.It Dv RPC_SVC -defined when compiling into server-side stubs -.It Dv RPC_CLNT -defined when compiling into client-side stubs -.El -.Pp -In addition, -.Nm rpcgen -does a little preprocessing of its own. -Any line beginning with -.Ql \&% -is passed directly into the output file, uninterpreted by -.Nm rpcgen . -.Pp -You can customize some of your -.Dv XDR -routines by leaving those data -types undefined. For every data type that is undefined, -.Nm rpcgen -will assume that there exists a routine with the name -.Em xdr_ -prepended to the name of the undefined type. -.Sh SEE ALSO -.Xr cpp 1 -.Rs -.%T "Rpcgen Programming Guide" -.%I "Sun Microsystems" -.Re -.Sh BUGS -.Pp -Nesting is not supported. -As a work-around, structures can be declared at -top-level, and their name used inside other structures in order to achieve -the same effect. -.Pp -Name clashes can occur when using program definitions, since the apparent -scoping does not really apply. Most of these can be avoided by giving -unique names for programs, versions, procedures and types. diff --git a/lib/librpc/man/man1/rstat.1 b/lib/librpc/man/man1/rstat.1 deleted file mode 100644 index 52eaa31c924e..000000000000 --- a/lib/librpc/man/man1/rstat.1 +++ /dev/null @@ -1,57 +0,0 @@ -.\" @(#)rstat.1 2.1 88/08/03 4.0 RPCSRC -.TH RSTAT 1 "3 August 1988" -.SH NAME -rstat \- remote status display -.SH SYNOPSIS -.B rstat -.B host -.SH DESCRIPTION -.LP -.B rstat -displays a summary of the current system status of a particular -.BR host . -The output shows the current time of day, how long the system has -been up, -and the load averages. -The load average numbers give the number of jobs in the run queue -averaged over 1, 5 and 15 minutes. -.PP -The -.B rstat_svc(8c) -daemon must be running on the remote host for this command to -work. -.B rstat -uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x. -.SH EXAMPLE -.RS -.ft B -.nf -example% rstat otherhost -7:36am up 6 days, 16:45, load average: 0.20, 0.23, 0.18 -example% -.ft R -.fi -.RE -.SH DIAGNOSTICS -.LP -rstat: RPC: Program not registered -.IP -The -.B rstat_svc -daemon has not been started on the remote host. -.LP -rstat: RPC: Timed out -.IP -A communication error occurred. Either the network is -excessively congested, or the -.B rstat_svc -daemon has terminated on the remote host. -.LP -rstat: RPC: Port mapper failure - RPC: Timed out -.IP -The remote host is not running the portmapper (see -.BR portmap(8c) ), -and cannot accommodate any RPC-based services. The host may be down. -.SH "SEE ALSO" -.BR portmap (8c), -.BR rstat_svc (8c) diff --git a/lib/librpc/man/man3/bindresvport.3n b/lib/librpc/man/man3/bindresvport.3n deleted file mode 100644 index 1fb1f9a30600..000000000000 --- a/lib/librpc/man/man3/bindresvport.3n +++ /dev/null @@ -1,27 +0,0 @@ -.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI -.TH BINDRESVPORT 3N "22 november 1987" -.SH NAME -bindresvport \- bind a socket to a privileged IP port -.SH SYNOPSIS -.nf -.B #include -.B #include -.LP -.B int bindresvport(sd, sin) -.B int sd; -.B struct sockaddr_in \(**sin; -.fi -.SH DESCRIPTION -.LP -.B bindresvport(\|) -is used to bind a socket descriptor to a privileged -.SM IP -port, that is, a -port number in the range 0-1023. -The routine returns 0 if it is successful, -otherwise \-1 is returned and -.B errno -set to reflect the cause of the error. -.LP -Only root can bind to a privileged port; this call will fail for any -other users. diff --git a/lib/librpc/man/man3/getrpcent.3n b/lib/librpc/man/man3/getrpcent.3n deleted file mode 100644 index f500c01b075f..000000000000 --- a/lib/librpc/man/man3/getrpcent.3n +++ /dev/null @@ -1,109 +0,0 @@ -.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI -.TH GETRPCENT 3N "14 December 1987" -.SH NAME -getrpcent, getrpcbyname, getrpcbynumber \- get RPC entry -.SH SYNOPSIS -.nf -.ft B -#include -.LP -.ft B -struct rpcent *getrpcent(\|) -.LP -.ft B -struct rpcent *getrpcbyname(name) -char *name; -.LP -.ft B -struct rpcent *getrpcbynumber(number) -int number; -.LP -.ft B -setrpcent (stayopen) -int stayopen -.LP -.ft B -endrpcent (\|) -.fi -.SH DESCRIPTION -.LP -.BR getrpcent(\|) , -.BR getrpcbyname(\|) , -and -.B getrpcbynumber(\|) -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the rpc program number data base, -.BR /etc/rpc . -.RS -.LP -.nf -.ft B -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - long r_number; /* rpc program number */ -}; -.ft R -.fi -.RE -.LP -The members of this structure are: -.RS -.PD 0 -.TP 20 -.B r_name -The name of the server for this rpc program. -.TP 20 -.B r_aliases -A zero terminated list of alternate names for the rpc program. -.TP 20 -.B r_number -The rpc program number for this service. -.PD -.RE -.LP -.B getrpcent(\|) -reads the next line of the file, opening the file if necessary. -.LP -.B getrpcent(\|) -opens and rewinds the file. If the -.I stayopen -flag is non-zero, -the net data base will not be closed after each call to -.B getrpcent(\|) -(either directly, or indirectly through one of -the other \*(lqgetrpc\*(rq calls). -.LP -.B endrpcent -closes the file. -.LP -.B getrpcbyname(\|) -and -.B getrpcbynumber(\|) -sequentially search from the beginning -of the file until a matching rpc program name or -program number is found, or until end-of-file is encountered. -.SH FILES -.PD 0 -.TP 20 -.B /etc/rpc -.PD -.SH "SEE ALSO" -.BR rpc (5), -.BR rpcinfo (8C), -.BR ypserv (8) -.SH DIAGNOSTICS -.LP -A -.SM NULL -pointer is returned on -.SM EOF -or error. -.SH BUGS -.LP -All information -is contained in a static area -so it must be copied if it is -to be saved. diff --git a/lib/librpc/man/man3/getrpcport.3r b/lib/librpc/man/man3/getrpcport.3r deleted file mode 100644 index 0323d34a07c8..000000000000 --- a/lib/librpc/man/man3/getrpcport.3r +++ /dev/null @@ -1,31 +0,0 @@ -.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI -.TH GETRPCPORT 3R "6 October 1987" -.SH NAME -getrpcport \- get RPC port number -.SH SYNOPSIS -.ft B -.nf -int getrpcport(host, prognum, versnum, proto) - char *host; - int prognum, versnum, proto; -.fi -.SH DESCRIPTION -.IX getrpcport "" "\fLgetrpcport\fR \(em get RPC port number" -.B getrpcport(\|) -returns the port number for version -.I versnum -of the RPC program -.I prognum -running on -.I host -and using protocol -.IR proto . -It returns 0 if it cannot contact the portmapper, or if -.I prognum -is not registered. If -.I prognum -is registered but not with version -.IR versnum , -it will still return a port number (for some version of the program) -indicating that the program is indeed registered. -The version mismatch will be detected upon the first call to the service. diff --git a/lib/librpc/man/man3/rpc.3n b/lib/librpc/man/man3/rpc.3n deleted file mode 100644 index b5a2b92fce76..000000000000 --- a/lib/librpc/man/man3/rpc.3n +++ /dev/null @@ -1,1729 +0,0 @@ -.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI -.TH RPC 3N "16 February 1988" -.SH NAME -rpc \- library routines for remote procedure calls -.SH SYNOPSIS AND DESCRIPTION -These routines allow C programs to make procedure -calls on other machines across the network. -First, the client calls a procedure to send a -data packet to the server. -Upon receipt of the packet, the server calls a dispatch routine -to perform the requested service, and then sends back a -reply. -Finally, the procedure call returns to the client. -.LP -Routines that are used for Secure RPC (DES authentication) are described in -.BR rpc_secure (3N). -Secure RPC can be used only if DES encryption is available. -.LP -.ft B -.nf -.sp .5 -#include -.fi -.ft R -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -auth_destroy(auth) -\s-1AUTH\s0 *auth; -.fi -.ft R -.IP -A macro that destroys the authentication information associated with -.IR auth . -Destruction usually involves deallocation of private data -structures. The use of -.I auth -is undefined after calling -.BR auth_destroy(\|) . -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -\s-1AUTH\s0 * -authnone_create(\|) -.fi -.ft R -.IP -Create and returns an -.SM RPC -authentication handle that passes nonusable authentication -information with each remote procedure call. This is the -default authentication used by -.SM RPC. -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -\s-1AUTH\s0 * -authunix_create(host, uid, gid, len, aup_gids) -char *host; -int uid, gid, len, *aup.gids; -.fi -.ft R -.IP -Create and return an -.SM RPC -authentication handle that contains -.UX -authentication information. -The parameter -.I host -is the name of the machine on which the information was -created; -.I uid -is the user's user -.SM ID ; -.I gid -is the user's current group -.SM ID ; -.I len -and -.I aup_gids -refer to a counted array of groups to which the user belongs. -It is easy to impersonate a user. -.br -.if t .ne 5 -.LP -.ft B -.nf -.sp .5 -\s-1AUTH\s0 * -authunix_create_default(\|) -.fi -.ft R -.IP -Calls -.B authunix_create(\|) -with the appropriate parameters. -.br -.if t .ne 13 -.LP -.ft B -.nf -.sp .5 -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) -char *host; -u_long prognum, versnum, procnum; -char *in, *out; -xdrproc_t inproc, outproc; -.fi -.ft R -.IP -Call the remote procedure associated with -.IR prognum , -.IR versnum , -and -.I procnum -on the machine, -.IR host . -The parameter -.I in -is the address of the procedure's argument(s), and -.I out -is the address of where to place the result(s); -.I inproc -is used to encode the procedure's parameters, and -.I outproc -is used to decode the procedure's results. -This routine returns zero if it succeeds, or the value of -.B "enum clnt_stat" -cast to an integer if it fails. -The routine -.B clnt_perrno(\|) -is handy for translating failure statuses into messages. -.IP -Warning: calling remote procedures with this routine -uses -.SM UDP/IP -as a transport; see -.B clntudp_create(\|) -for restrictions. -You do not have control of timeouts or authentication using -this routine. -.br -.if t .ne 16 -.LP -.ft B -.nf -.sp .5 -enum clnt_stat -clnt_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult) -u_long prognum, versnum, procnum; -char *in, *out; -xdrproc_t inproc, outproc; -resultproc_t eachresult; -.fi -.ft R -.IP -Like -.BR callrpc(\|) , -except the call message is broadcast to all locally -connected broadcast nets. Each time it receives a -response, this routine calls -.BR eachresult(\|) , -whose form is: -.IP -.RS 1i -.ft B -.nf -eachresult(out, addr) -char *out; -struct sockaddr_in *addr; -.ft R -.fi -.RE -.IP -where -.I out -is the same as -.I out -passed to -.BR clnt_broadcast(\|) , -except that the remote procedure's output is decoded there; -.I addr -points to the address of the machine that sent the results. -If -.B eachresult(\|) -returns zero, -.B clnt_broadcast(\|) -waits for more replies; otherwise it returns with appropriate -status. -.IP -Warning: broadcast sockets are limited in size to the -maximum transfer unit of the data link. For ethernet, -this value is 1500 bytes. -.br -.if t .ne 13 -.LP -.ft B -.nf -.sp .5 -enum clnt_stat -clnt_call(clnt, procnum, inproc, in, outproc, out, tout) -\s-1CLIENT\s0 *clnt; -u_long -procnum; -xdrproc_t inproc, outproc; -char *in, *out; -struct timeval tout; -.fi -.ft R -.IP -A macro that calls the remote procedure -.I procnum -associated with the client handle, -.IR clnt , -which is obtained with an -.SM RPC -client creation routine such as -.BR clnt_create(\|) . -The parameter -.I in -is the address of the procedure's argument(s), and -.I out -is the address of where to place the result(s); -.I inproc -is used to encode the procedure's parameters, and -.I outproc -is used to decode the procedure's results; -.I tout -is the time allowed for results to come back. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -clnt_destroy(clnt) -\s-1CLIENT\s0 *clnt; -.fi -.ft R -.IP -A macro that destroys the client's -.SM RPC -handle. Destruction usually involves deallocation -of private data structures, including -.I clnt -itself. Use of -.I clnt -is undefined after calling -.BR clnt_destroy(\|) . -If the -.SM RPC -library opened the associated socket, it will close it also. -Otherwise, the socket remains open. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -\s-1CLIENT\s0 * -clnt_create(host, prog, vers, proto) -char *host; -u_long prog, vers; -char *proto; -.fi -.ft R -.IP -Generic client creation routine. -.I host -identifies the name of the remote host where the server -is located. -.I proto -indicates which kind of transport protocol to use. The -currently supported values for this field are \(lqudp\(rq -and \(lqtcp\(rq. -Default timeouts are set, but can be modified using -.BR clnt_control(\|) . -.IP -Warning: Using -.SM UDP -has its shortcomings. Since -.SM UDP\s0-based -.SM RPC -messages can only hold up to 8 Kbytes of encoded data, -this transport cannot be used for procedures that take -large arguments or return huge results. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -bool_t -clnt_control(cl, req, info) -\s-1CLIENT\s0 *cl; -char *info; -.fi -.ft R -.IP -A macro used to change or retrieve various information -about a client object. -.I req -indicates the type of operation, and -.I info -is a pointer to the information. For both -.SM UDP -and -.SM TCP\s0, -the supported values of -.I req -and their argument types and what they do are: -.IP -.nf -.ta +2.0i +2.0i +2.0i -.SM CLSET_TIMEOUT\s0 struct timeval set total timeout -.SM CLGET_TIMEOUT\s0 struct timeval get total timeout -.fi -.IP -Note: if you set the timeout using -.BR clnt_control(\|) , -the timeout parameter passed to -.B clnt_call(\|) -will be ignored in all future calls. -.IP -.nf -.SM CLGET_SERVER_ADDR\s0 struct sockaddr_in get server's address -.fi -.br -.IP -The following operations are valid for -.SM UDP -only: -.IP -.nf -.ta +2.0i ; +2.0i ; +2.0i -.SM CLSET_RETRY_TIMEOUT\s0 struct timeval set the retry timeout -.SM CLGET_RETRY_TIMEOUT\s0 struct timeval get the retry timeout -.fi -.br -.IP -The retry timeout is the time that -.SM "UDP RPC" -waits for the server to reply before -retransmitting the request. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -clnt_freeres(clnt, outproc, out) -\s-1CLIENT\s0 *clnt; -xdrproc_t outproc; -char *out; -.fi -.ft R -.IP -A macro that frees any data allocated by the -.SM RPC/XDR -system when it decoded the results of an -.SM RPC -call. The -parameter -.I out -is the address of the results, and -.I outproc -is the -.SM XDR -routine describing the results. -This routine returns one if the results were successfully -freed, -and zero otherwise. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -void -clnt_geterr(clnt, errp) -\s-1CLIENT\s0 *clnt; -struct rpc_err *errp; -.fi -.ft R -.IP -A macro that copies the error structure out of the client -handle -to the structure at address -.IR errp . -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -clnt_pcreateerror(s) -char *s; -.fi -.ft R -.IP -Print a message to standard error indicating -why a client -.SM RPC -handle could not be created. -The message is prepended with string -.I s -and a colon. -Used when a -.BR clnt_create(\|) , -.BR clntraw_create(\|) , -.BR clnttcp_create(\|) , -or -.B clntudp_create(\|) -call fails. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -clnt_perrno(stat) -enum clnt_stat stat; -.fi -.ft R -.IP -Print a message to standard error corresponding -to the condition indicated by -.IR stat . -Used after -.BR callrpc(\|) . -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -clnt_perror(clnt, s) -\s-1CLIENT\s0 *clnt; -char *s; -.fi -.ft R -.IP -Print a message to standard error indicating why an -.SM RPC -call failed; -.I clnt -is the handle used to do the call. -The message is prepended with string -.I s -and a colon. -Used after -.BR clnt_call(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -char * -clnt_spcreateerror -char *s; -.fi -.ft R -.IP -Like -.BR clnt_pcreateerror(\|) , -except that it returns a string -instead of printing to the standard error. -.IP -Bugs: returns pointer to static data that is overwritten -on each call. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -char * -clnt_sperrno(stat) -enum clnt_stat stat; -.fi -.ft R -.IP -Take the same arguments as -.BR clnt_perrno(\|) , -but instead of sending a message to the standard error -indicating why an -.SM RPC -call failed, return a pointer to a string which contains -the message. The string ends with a -.SM NEWLINE\s0. -.IP -.B clnt_sperrno(\|) -is used instead of -.B clnt_perrno(\|) -if the program does not have a standard error (as a program -running as a server quite likely does not), or if the -programmer -does not want the message to be output with -.BR printf , -or if a message format different than that supported by -.B clnt_perrno(\|) -is to be used. -Note: unlike -.B clnt_sperror(\|) -and -.BR clnt_spcreaterror(\|) , -.B clnt_sperrno(\|) -returns pointer to static data, but the -result will not get overwritten on each call. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -char * -clnt_sperror(rpch, s) -\s-1CLIENT\s0 *rpch; -char *s; -.fi -.ft R -.IP -Like -.BR clnt_perror(\|) , -except that (like -.BR clnt_sperrno(\|) ) -it returns a string instead of printing to standard error. -.IP -Bugs: returns pointer to static data that is overwritten -on each call. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -\s-1CLIENT\s0 * -clntraw_create(prognum, versnum) -u_long prognum, versnum; -.fi -.ft R -.IP -This routine creates a toy -.SM RPC -client for the remote program -.IR prognum , -version -.IR versnum . -The transport used to pass messages to the service is -actually a buffer within the process's address space, so the -corresponding -.SM RPC -server should live in the same address space; see -.BR svcraw_create(\|) . -This allows simulation of -.SM RPC -and acquisition of -.SM RPC -overheads, such as round trip times, without any -kernel interference. This routine returns -.SM NULL -if it fails. -.br -.if t .ne 15 -.LP -.ft B -.nf -.sp .5 -\s-1CLIENT\s0 * -clnttcp_create(addr, prognum, versnum, sockp, sendsz, recvsz) -struct sockaddr_in *addr; -u_long prognum, versnum; -int *sockp; -u_int sendsz, recvsz; -.fi -.ft R -.IP -This routine creates an -.SM RPC -client for the remote program -.IR prognum , -version -.IR versnum ; -the client uses -.SM TCP/IP -as a transport. The remote program is located at Internet -address -.IR *addr . -If -.\"The following in-line font conversion is necessary for the hyphen indicator -\fB\%addr\->sin_port\fR -is zero, then it is set to the actual port that the remote -program is listening on (the remote -.B portmap -service is consulted for this information). The parameter -.I sockp -is a socket; if it is -.BR \s-1RPC_ANYSOCK\s0 , -then this routine opens a new one and sets -.IR sockp . -Since -.SM TCP\s0-based -.SM RPC -uses buffered -.SM I/O , -the user may specify the size of the send and receive buffers -with the parameters -.I sendsz -and -.IR recvsz ; -values of zero choose suitable defaults. -This routine returns -.SM NULL -if it fails. -.br -.if t .ne 15 -.LP -.ft B -.nf -.sp .5 -\s-1CLIENT\s0 * -clntudp_create(addr, prognum, versnum, wait, sockp) -struct sockaddr_in *addr; -u_long prognum, versnum; -struct timeval wait; -int *sockp; -.fi -.ft R -.IP -This routine creates an -.SM RPC -client for the remote program -.IR prognum , -version -.IR versnum ; -the client uses use -.SM UDP/IP -as a transport. The remote program is located at Internet -address -.IR addr . -If -\fB\%addr\->sin_port\fR -is zero, then it is set to actual port that the remote -program is listening on (the remote -.B portmap -service is consulted for this information). The parameter -.I sockp -is a socket; if it is -.BR \s-1RPC_ANYSOCK\s0 , -then this routine opens a new one and sets -.IR sockp . -The -.SM UDP -transport resends the call message in intervals of -.B wait -time until a response is received or until the call times -out. -The total time for the call to time out is specified by -.BR clnt_call(\|) . -.IP -Warning: since -.SM UDP\s0-based -.SM RPC -messages can only hold up to 8 Kbytes -of encoded data, this transport cannot be used for procedures -that take large arguments or return huge results. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -\s-1CLIENT\s0 * -clntudp_bufcreate(addr, prognum, versnum, wait, sockp, sendsize, recosize) -struct sockaddr_in *addr; -u_long prognum, versnum; -struct timeval wait; -int *sockp; -unsigned int sendsize; -unsigned int recosize; -.fi -.ft R -.IP -This routine creates an -.SM RPC -client for the remote program -.IR prognum , -on -.IR versnum ; -the client uses use -.SM UDP/IP -as a transport. The remote program is located at Internet -address -.IR addr . -If -\fB\%addr\->sin_port\fR -is zero, then it is set to actual port that the remote -program is listening on (the remote -.B portmap -service is consulted for this information). The parameter -.I sockp -is a socket; if it is -.BR \s-1RPC_ANYSOCK\s0 , -then this routine opens a new one and sets -.BR sockp . -The -.SM UDP -transport resends the call message in intervals of -.B wait -time until a response is received or until the call times -out. -The total time for the call to time out is specified by -.BR clnt_call(\|) . -.IP -This allows the user to specify the maximun packet size for sending and receiving -.SM UDP\s0-based -.SM RPC -messages. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -get_myaddress(addr) -struct sockaddr_in *addr; -.fi -.ft R -.IP -Stuff the machine's -.SM IP -address into -.IR *addr , -without consulting the library routines that deal with -.BR /etc/hosts . -The port number is always set to -.BR htons(\s-1PMAPPORT\s0) . -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -struct pmaplist * -pmap_getmaps(addr) -struct sockaddr_in *addr; -.fi -.ft R -.IP -A user interface to the -.B portmap -service, which returns a list of the current -.SM RPC -program-to-port mappings -on the host located at -.SM IP -address -.IR *addr . -This routine can return -.SM NULL . -The command -.RB ` "rpcinfo \-p" ' -uses this routine. -.br -.if t .ne 12 -.LP -.ft B -.nf -.sp .5 -u_short -pmap_getport(addr, prognum, versnum, protocol) -struct sockaddr_in *addr; -u_long prognum, versnum, protocol; -.fi -.ft R -.IP -A user interface to the -.B portmap -service, which returns the port number -on which waits a service that supports program number -.IR prognum , -version -.IR versnum , -and speaks the transport protocol associated with -.IR protocol . -The value of -.I protocol -is most likely -.B -.SM IPPROTO_UDP -or -.BR \s-1IPPROTO_TCP\s0 . -A return value of zero means that the mapping does not exist -or that -the -.SM RPC -system failured to contact the remote -.B portmap -service. In the latter case, the global variable -.B rpc_createerr(\|) -contains the -.SM RPC -status. -.br -.if t .ne 15 -.LP -.ft B -.nf -.sp .5 -enum clnt_stat -pmap_rmtcall(addr, prognum, versnum, procnum, inproc, in, outproc, out, tout, portp) -struct sockaddr_in *addr; -u_long prognum, versnum, procnum; -char *in, *out; -xdrproc_t inproc, outproc; -struct timeval tout; -u_long *portp; -.fi -.ft R -.IP -A user interface to the -.B portmap -service, which instructs -.B portmap -on the host at -.SM IP -address -.I *addr -to make an -.SM RPC -call on your behalf to a procedure on that host. -The parameter -.I *portp -will be modified to the program's port number if the -procedure -succeeds. The definitions of other parameters are discussed -in -.B callrpc(\|) -and -.BR clnt_call(\|) . -This procedure should be used for a \(lqping\(rq and nothing -else. -See also -.BR clnt_broadcast(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -pmap_set(prognum, versnum, protocol, port) -u_long prognum, versnum, protocol; -u_short port; -.fi -.ft R -.IP -A user interface to the -.B portmap -service, which establishes a mapping between the triple -.RI [ prognum , versnum , protocol\fR] -and -.I port -on the machine's -.B portmap -service. The value of -.I protocol -is most likely -.B -.SM IPPROTO_UDP -or -.BR \s-1IPPROTO_TCP\s0 . -This routine returns one if it succeeds, zero otherwise. -Automatically done by -.BR svc_register(\|) . -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -pmap_unset(prognum, versnum) -u_long prognum, versnum; -.fi -.ft R -.IP -A user interface to the -.B portmap -service, which destroys all mapping between the triple -.RI [ prognum , versnum , *\fR] -and -.B ports -on the machine's -.B portmap -service. This routine returns one if it succeeds, zero -otherwise. -.br -.if t .ne 15 -.LP -.ft B -.nf -.sp .5 -registerrpc(prognum, versnum, procnum, procname, inproc, outproc) -u_long prognum, versnum, procnum; -char *(*procname) (\|) ; -xdrproc_t inproc, outproc; -.fi -.ft R -.IP -Register procedure -.I procname -with the -.SM RPC -service package. If a request arrives for program -.IR prognum , -version -.IR versnum , -and procedure -.IR procnum , -.I procname -is called with a pointer to its parameter(s); -.I progname -should return a pointer to its static result(s); -.I inproc -is used to decode the parameters while -.I outproc -is used to encode the results. -This routine returns zero if the registration succeeded, \-1 -otherwise. -.IP -Warning: remote procedures registered in this form -are accessed using the -.SM UDP/IP -transport; see -.B svcudp_create(\|) -for restrictions. -.br -.if t .ne 5 -.LP -.ft B -.nf -.sp .5 -struct rpc_createerr rpc_createerr; -.fi -.ft R -.IP -A global variable whose value is set by any -.SM RPC -client creation routine -that does not succeed. Use the routine -.B clnt_pcreateerror(\|) -to print the reason why. -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -svc_destroy(xprt) -\s-1SVCXPRT\s0 * -xprt; -.fi -.ft R -.IP -A macro that destroys the -.SM RPC -service transport handle, -.IR xprt . -Destruction usually involves deallocation -of private data structures, including -.I xprt -itself. Use of -.I xprt -is undefined after calling this routine. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -fd_set svc_fdset; -.fi -.ft R -.IP -A global variable reflecting the -.SM RPC -service side's -read file descriptor bit mask; it is suitable as a parameter -to the -.B select -system call. This is only of interest -if a service implementor does not call -.BR svc_run(\|) , -but rather does his own asynchronous event processing. -This variable is read-only (do not pass its address to -.BR select !), -yet it may change after calls to -.B svc_getreqset(\|) -or any creation routines. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -int svc_fds; -.fi -.ft R -.IP -Similar to -.BR svc_fedset(\|) , -but limited to 32 descriptors. This -interface is obsoleted by -.BR svc_fdset(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -svc_freeargs(xprt, inproc, in) -\s-1SVCXPRT\s0 *xprt; -xdrproc_t inproc; -char *in; -.fi -.ft R -.IP -A macro that frees any data allocated by the -.SM RPC/XDR -system when it decoded the arguments to a service procedure -using -.BR svc_getargs(\|) . -This routine returns 1 if the results were successfully -freed, -and zero otherwise. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -svc_getargs(xprt, inproc, in) -\s-1SVCXPRT\s0 *xprt; -xdrproc_t inproc; -char *in; -.fi -.ft R -.IP -A macro that decodes the arguments of an -.SM RPC -request -associated with the -.SM RPC -service transport handle, -.IR xprt . -The parameter -.I in -is the address where the arguments will be placed; -.I inproc -is the -.SM XDR -routine used to decode the arguments. -This routine returns one if decoding succeeds, and zero -otherwise. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -struct sockaddr_in * -svc_getcaller(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -The approved way of getting the network address of the caller -of a procedure associated with the -.SM RPC -service transport handle, -.IR xprt . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -svc_getreqset(rdfds) -fd_set *rdfds; -.fi -.ft R -.IP -This routine is only of interest if a service implementor -does not call -.BR svc_run(\|) , -but instead implements custom asynchronous event processing. -It is called when the -.B select -system call has determined that an -.SM RPC -request has arrived on some -.SM RPC -.B socket(s) ; -.I rdfds -is the resultant read file descriptor bit mask. -The routine returns when all sockets associated with the -value of -.I rdfds -have been serviced. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -svc_getreq(rdfds) -int rdfds; -.fi -.ft R -.IP -Similar to -.BR svc_getreqset(\|) , -but limited to 32 descriptors. This interface is obsoleted by -.BR svc_getreqset(\|) . -.br -.if t .ne 17 -.LP -.ft B -.nf -.sp .5 -svc_register(xprt, prognum, versnum, dispatch, protocol) -\s-1SVCXPRT\s0 *xprt; -u_long prognum, versnum; -void (*dispatch) (\|); -u_long protocol; -.fi -.ft R -.IP -Associates -.I prognum -and -.I versnum -with the service dispatch procedure, -.IR dispatch . -If -.I protocol -is zero, the service is not registered with the -.B portmap -service. If -.I protocol -is non-zero, then a mapping of the triple -.RI [ prognum , versnum , protocol\fR] -to -\fB\%xprt\->xp_port\fR -is established with the local -.B portmap -service (generally -.I protocol -is zero, -.B -.SM IPPROTO_UDP -or -.B -.SM IPPROTO_TCP -). -The procedure -.I dispatch -has the following form: -.RS 1i -.ft B -.nf -dispatch(request, xprt) -struct svc_req *request; -\s-1SVCXPRT\s0 *xprt; -.ft R -.fi -.RE -.IP -The -.B svc_register(\|) -routine returns one if it succeeds, and zero otherwise. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -svc_run(\|) -.fi -.ft R -.IP -This routine never returns. It waits for -.SM RPC -requests to arrive, and calls the appropriate service -procedure using -.B svc_getreq(\|) -when one arrives. This procedure is usually waiting for a -.B select(\|) -system call to return. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -svc_sendreply(xprt, outproc, out) -\s-1SVCXPRT\s0 *xprt; -xdrproc_t outproc; -char *out; -.fi -.ft R -.IP -Called by an -.SM RPC -service's dispatch routine to send the results of a -remote procedure call. The parameter -.I xprt -is the request's associated transport handle; -.I outproc -is the -.SM XDR -routine which is used to encode the results; and -.I out -is the address of the results. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svc_unregister(prognum, versnum) -u_long prognum, versnum; -.fi -.ft R -.IP -Remove all mapping of the double -.RI [ prognum , versnum ] -to dispatch routines, and of the triple -.RI [ prognum , versnum , *\fR] -to port number. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -void -svcerr_auth(xprt, why) -\s-1SVCXPRT\s0 *xprt; -enum auth_stat why; -.fi -.ft R -.IP -Called by a service dispatch routine that refuses to perform -a remote procedure call due to an authentication error. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svcerr_decode(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called by a service dispatch routine that cannot successfully -decode its parameters. See also -.BR svc_getargs(\|) . -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svcerr_noproc(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called by a service dispatch routine that does not implement -the procedure number that the caller requests. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svcerr_noprog(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called when the desired program is not registered with the -.SM RPC -package. Service implementors usually do not need this routine. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svcerr_progvers(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called when the desired version of a program is not registered -with the -.SM RPC -package. Service implementors usually do not need this routine. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -svcerr_systemerr(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called by a service dispatch routine when it detects a system -error -not covered by any particular protocol. -For example, if a service can no longer allocate storage, -it may call this routine. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -svcerr_weakauth(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Called by a service dispatch routine that refuses to perform -a remote procedure call due to insufficient -authentication parameters. The routine calls -.BR "svcerr_auth(xprt, \s-1AUTH_TOOWEAK\s0)" . -.br -.if t .ne 11 -.LP -.ft B -.nf -.sp .5 -\s-1SVCXPRT\s0 * -svcraw_create(\|) -.fi -.ft R -.IP -This routine creates a toy -.SM RPC -service transport, to which it returns a pointer. The -transport -is really a buffer within the process's address space, -so the corresponding -.SM RPC -client should live in the same -address space; -see -.BR clntraw_create(\|) . -This routine allows simulation of -.SM RPC -and acquisition of -.SM RPC -overheads (such as round trip times), without any kernel -interference. -This routine returns -.SM NULL -if it fails. -.br -.if t .ne 11 -.LP -.ft B -.nf -.sp .5 -\s-1SVCXPRT\s0 * -svctcp_create(sock, send_buf_size, recv_buf_size) -int sock; -u_int send_buf_size, recv_buf_size; -.fi -.ft R -.IP -This routine creates a -.SM TCP/IP\s0-based -.SM RPC -service transport, to which it returns a pointer. -The transport is associated with the socket -.IR sock , -which may be -.BR \s-1RPC_ANYSOCK\s0 , -in which case a new socket is created. -If the socket is not bound to a local -.SM TCP -port, then this routine binds it to an arbitrary port. Upon -completion, -\fB\%xprt\->xp_sock\fR -is the transport's socket descriptor, and -\fB\%xprt\->xp_port\fR -is the transport's port number. -This routine returns -.SM NULL -if it fails. Since -.SM TCP\s0-based -.SM RPC -uses buffered -.SM I/O , -users may specify the size of buffers; values of zero -choose suitable defaults. -.br -.if t .ne 11 -.LP -.ft B -.nf -.sp .5 -\s-1SVCXPRT\s0 * -svcfd_create(fd, sendsize, recvsize) -int fd; -u_int sendsize; -u_int recvsize; -.fi -.ft R -.IP -Create a service on top of any open descriptor. Typically, -this -descriptor is a connected socket for a stream protocol such -as -.SM TCP\s0. -.I sendsize -and -.I recvsize -indicate sizes for the send and receive buffers. If they are -zero, a reasonable default is chosen. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -\s-1SVCXPRT\s0 * -svcudp_bufcreate(sock, sendsize, recosize) -int sock; -.fi -.ft R -.IP -This routine creates a -.SM UDP/IP\s0-based -.SM RPC -service transport, to which it returns a pointer. -The transport is associated with the socket -.IR sock , -which may be -.B \s-1RPC_ANYSOCK\s0 , -in which case a new socket is created. -If the socket is not bound to a local -.SM UDP -port, then this routine binds it to an arbitrary port. Upon -completion, -\fB\%xprt\->xp_sock\fR -is the transport's socket descriptor, and -\fB\%xprt\->xp_port\fR -is the transport's port number. -This routine returns -.SM NULL -if it fails. -.IP -This allows the user to specify the maximun packet size for sending and -receiving -.SM UDP\s0-based -.SM RPC messages. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_accepted_reply(xdrs, ar) -\s-1XDR\s0 *xdrs; -struct accepted_reply *ar; -.fi -.ft R -.IP -Used for encoding -.SM RPC -reply messages. This routine is useful for users who -wish to generate -\s-1RPC\s0-style -messages without using the -.SM RPC -package. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_authunix_parms(xdrs, aupp) -\s-1XDR\s0 *xdrs; -struct authunix_parms *aupp; -.fi -.ft R -.IP -Used for describing -.SM UNIX -credentials. This routine is useful for users -who wish to generate these credentials without using the -.SM RPC -authentication package. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -void -xdr_callhdr(xdrs, chdr) -\s-1XDR\s0 *xdrs; -struct rpc_msg *chdr; -.fi -.ft R -.IP -Used for describing -.SM RPC -call header messages. -This routine is useful for users who wish to generate -.SM RPC\s0-style -messages without using the -.SM RPC -package. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_callmsg(xdrs, cmsg) -\s-1XDR\s0 *xdrs; -struct rpc_msg *cmsg; -.fi -.ft R -.IP -Used for describing -.SM RPC -call messages. -This routine is useful for users who wish to generate -.SM RPC\s0-style -messages without using the -.SM RPC -package. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_opaque_auth(xdrs, ap) -\s-1XDR\s0 *xdrs; -struct opaque_auth *ap; -.fi -.ft R -.IP -Used for describing -.SM RPC -authentication information messages. -This routine is useful for users who wish to generate -.SM RPC\s0-style -messages without using the -.SM RPC -package. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_pmap(xdrs, regs) -\s-1XDR\s0 *xdrs; -struct pmap *regs; -.fi -.ft R -.IP -Used for describing parameters to various -.B portmap -procedures, externally. -This routine is useful for users who wish to generate -these parameters without using the -.B pmap -interface. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_pmaplist(xdrs, rp) -\s-1XDR\s0 *xdrs; -struct pmaplist **rp; -.fi -.ft R -.IP -Used for describing a list of port mappings, externally. -This routine is useful for users who wish to generate -these parameters without using the -.B pmap -interface. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_rejected_reply(xdrs, rr) -\s-1XDR\s0 *xdrs; -struct rejected_reply *rr; -.fi -.ft R -.IP -Used for describing -.SM RPC -reply messages. -This routine is useful for users who wish to generate -.SM RPC\s0-style -messages without using the -.SM RPC -package. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdr_replymsg(xdrs, rmsg) -\s-1XDR\s0 *xdrs; -struct rpc_msg *rmsg; -.fi -.ft R -.IP -Used for describing -.SM RPC -reply messages. -This routine is useful for users who wish to generate -.SM RPC -style messages without using the -.SM RPC -package. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -xprt_register(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -After -.SM RPC -service transport handles are created, -they should register themselves with the -.SM RPC -service package. -This routine modifies the global variable -.BR svc_fds(\|) . -Service implementors usually do not need this routine. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -xprt_unregister(xprt) -\s-1SVCXPRT\s0 *xprt; -.fi -.ft R -.IP -Before an -.SM RPC -service transport handle is destroyed, -it should unregister itself with the -.SM RPC -service package. -This routine modifies the global variable -.BR svc_fds(\|) . -Service implementors usually do not need this routine. -.SH SEE ALSO -.BR rpc_secure (3N), -.BR xdr (3N) -.br -The following manuals: -.RS -.ft I -Remote Procedure Calls: Protocol Specification -.br -Remote Procedure Call Programming Guide -.br -rpcgen Programming Guide -.br -.ft R -.RE -.IR "\s-1RPC\s0: Remote Procedure Call Protocol Specification" , -.SM RFC1050, Sun Microsystems, Inc., -.SM USC-ISI\s0. - diff --git a/lib/librpc/man/man3/xdr.3n b/lib/librpc/man/man3/xdr.3n deleted file mode 100644 index b656ea804da8..000000000000 --- a/lib/librpc/man/man3/xdr.3n +++ /dev/null @@ -1,823 +0,0 @@ -.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI -.TH XDR 3N "16 February 1988" -.SH NAME -xdr \- library routines for external data representation -.SH SYNOPSIS AND DESCRIPTION -.LP -These routines allow C programmers to describe -arbitrary data structures in a machine-independent fashion. -Data for remote procedure calls are transmitted using these -routines. -.LP -.ft B -.nf -.sp .5 -xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc) -\s-1XDR\s0 *xdrs; -char **arrp; -u_int *sizep, maxsize, elsize; -xdrproc_t elproc; -.fi -.ft R -.IP -A filter primitive that translates between variable-length -arrays -and their corresponding external representations. The -parameter -.I arrp -is the address of the pointer to the array, while -.I sizep -is the address of the element count of the array; -this element count cannot exceed -.IR maxsize . -The parameter -.I elsize -is the -.I sizeof -each of the array's elements, and -.I elproc -is an -.SM XDR -filter that translates between -the array elements' C form, and their external -representation. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdr_bool(xdrs, bp) -\s-1XDR\s0 *xdrs; -bool_t *bp; -.fi -.ft R -.IP -A filter primitive that translates between booleans (C -integers) -and their external representations. When encoding data, this -filter produces values of either one or zero. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -xdr_bytes(xdrs, sp, sizep, maxsize) -\s-1XDR\s0 *xdrs; -char **sp; -u_int *sizep, maxsize; -.fi -.ft R -.IP -A filter primitive that translates between counted byte -strings and their external representations. -The parameter -.I sp -is the address of the string pointer. The length of the -string is located at address -.IR sizep ; -strings cannot be longer than -.IR maxsize . -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_char(xdrs, cp) -\s-1XDR\s0 *xdrs; -char *cp; -.fi -.ft R -.IP -A filter primitive that translates between C characters -and their external representations. -This routine returns one if it succeeds, zero otherwise. -Note: encoded characters are not packed, and occupy 4 bytes -each. For arrays of characters, it is worthwhile to -consider -.BR xdr_bytes(\|) , -.B xdr_opaque(\|) -or -.BR xdr_string(\|) . -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -void -xdr_destroy(xdrs) -\s-1XDR\s0 *xdrs; -.fi -.ft R -.IP -A macro that invokes the destroy routine associated with the -.SM XDR -stream, -.IR xdrs . -Destruction usually involves freeing private data structures -associated with the stream. Using -.I xdrs -after invoking -.B xdr_destroy(\|) -is undefined. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_double(xdrs, dp) -\s-1XDR\s0 *xdrs; -double *dp; -.fi -.ft R -.IP -A filter primitive that translates between C -.B double -precision numbers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_enum(xdrs, ep) -\s-1XDR\s0 *xdrs; -enum_t *ep; -.fi -.ft R -.IP -A filter primitive that translates between C -.BR enum s -(actually integers) and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdr_float(xdrs, fp) -\s-1XDR\s0 *xdrs; -float *fp; -.fi -.ft R -.IP -A filter primitive that translates between C -.BR float s -and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -void -xdr_free(proc, objp) -xdrproc_t proc; -char *objp; -.fi -.ft R -.IP -Generic freeing routine. The first argument is the -.SM XDR -routine for the object being freed. The second argument -is a pointer to the object itself. Note: the pointer passed -to this routine is -.I not -freed, but what it points to -.I is -freed (recursively). -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -u_int -xdr_getpos(xdrs) -\s-1XDR\s0 *xdrs; -.fi -.ft R -.IP -A macro that invokes the get-position routine -associated with the -.SM XDR -stream, -.IR xdrs . -The routine returns an unsigned integer, -which indicates the position of the -.SM XDR -byte stream. -A desirable feature of -.SM XDR -streams is that simple arithmetic works with this number, -although the -.SM XDR -stream instances need not guarantee this. -.br -.if t .ne 4 -.LP -.ft B -.nf -.sp .5 -.br -long * -xdr_inline(xdrs, len) -\s-1XDR\s0 *xdrs; -int len; -.fi -.ft R -.IP -A macro that invokes the in-line routine associated with the -.SM XDR -stream, -.IR xdrs . -The routine returns a pointer -to a contiguous piece of the stream's buffer; -.I len -is the byte length of the desired buffer. -Note: pointer is cast to -.BR "long *" . -.IP -Warning: -.B xdr_inline(\|) -may return -.SM NULL -(0) -if it cannot allocate a contiguous piece of a buffer. -Therefore the behavior may vary among stream instances; -it exists for the sake of efficiency. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_int(xdrs, ip) -\s-1XDR\s0 *xdrs; -int *ip; -.fi -.ft R -.IP -A filter primitive that translates between C integers -and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_long(xdrs, lp) -\s-1XDR\s0 *xdrs; -long *lp; -.fi -.ft R -.IP -A filter primitive that translates between C -.B long -integers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 12 -.LP -.ft B -.nf -.sp .5 -void -xdrmem_create(xdrs, addr, size, op) -\s-1XDR\s0 *xdrs; -char *addr; -u_int size; -enum xdr_op op; -.fi -.ft R -.IP -This routine initializes the -.SM XDR -stream object pointed to by -.IR xdrs . -The stream's data is written to, or read from, -a chunk of memory at location -.I addr -whose length is no more than -.I size -bytes long. The -.I op -determines the direction of the -.SM XDR -stream -(either -.BR \s-1XDR_ENCODE\s0 , -.BR \s-1XDR_DECODE\s0 , -or -.BR \s-1XDR_FREE\s0 ). -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -xdr_opaque(xdrs, cp, cnt) -\s-1XDR\s0 *xdrs; -char *cp; -u_int cnt; -.fi -.ft R -.IP -A filter primitive that translates between fixed size opaque -data -and its external representation. -The parameter -.I cp -is the address of the opaque object, and -.I cnt -is its size in bytes. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -xdr_pointer(xdrs, objpp, objsize, xdrobj) -\s-1XDR\s0 *xdrs; -char **objpp; -u_int objsize; -xdrproc_t xdrobj; -.fi -.ft R -.IP -Like -.B xdr_reference(\|) -execpt that it serializes -.SM NULL -pointers, whereas -.B xdr_reference(\|) -does not. Thus, -.B xdr_pointer(\|) -can represent -recursive data structures, such as binary trees or -linked lists. -.br -.if t .ne 15 -.LP -.ft B -.nf -.sp .5 -void -xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit) -\s-1XDR\s0 *xdrs; -u_int sendsize, recvsize; -char *handle; -int (*readit) (\|), (*writeit) (\|); -.fi -.ft R -.IP -This routine initializes the -.SM XDR -stream object pointed to by -.IR xdrs . -The stream's data is written to a buffer of size -.IR sendsize ; -a value of zero indicates the system should use a suitable -default. The stream's data is read from a buffer of size -.IR recvsize ; -it too can be set to a suitable default by passing a zero -value. -When a stream's output buffer is full, -.I writeit -is called. Similarly, when a stream's input buffer is empty, -.I readit -is called. The behavior of these two routines is similar to -the -system calls -.B read -and -.BR write , -except that -.I handle -is passed to the former routines as the first parameter. -Note: the -.SM XDR -stream's -.I op -field must be set by the caller. -.IP -Warning: this -.SM XDR -stream implements an intermediate record stream. -Therefore there are additional bytes in the stream -to provide record boundary information. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -xdrrec_endofrecord(xdrs, sendnow) -\s-1XDR\s0 *xdrs; -int sendnow; -.fi -.ft R -.IP -This routine can be invoked only on -streams created by -.BR xdrrec_create(\|) . -The data in the output buffer is marked as a completed -record, -and the output buffer is optionally written out if -.I sendnow -is non-zero. This routine returns one if it succeeds, zero -otherwise. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdrrec_eof(xdrs) -\s-1XDR\s0 *xdrs; -int empty; -.fi -.ft R -.IP -This routine can be invoked only on -streams created by -.BR xdrrec_create(\|) . -After consuming the rest of the current record in the stream, -this routine returns one if the stream has no more input, -zero otherwise. -.br -.if t .ne 3 -.LP -.ft B -.nf -.sp .5 -xdrrec_skiprecord(xdrs) -\s-1XDR\s0 *xdrs; -.fi -.ft R -.IP -This routine can be invoked only on -streams created by -.BR xdrrec_create(\|) . -It tells the -.SM XDR -implementation that the rest of the current record -in the stream's input buffer should be discarded. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 11 -.LP -.ft B -.nf -.sp .5 -xdr_reference(xdrs, pp, size, proc) -\s-1XDR\s0 *xdrs; -char **pp; -u_int size; -xdrproc_t proc; -.fi -.ft R -.IP -A primitive that provides pointer chasing within structures. -The parameter -.I pp -is the address of the pointer; -.I size -is the -.I sizeof -the structure that -.I *pp -points to; and -.I proc -is an -.SM XDR -procedure that filters the structure -between its C form and its external representation. -This routine returns one if it succeeds, zero otherwise. -.IP -Warning: this routine does not understand -.SM NULL -pointers. Use -.B xdr_pointer(\|) -instead. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -xdr_setpos(xdrs, pos) -\s-1XDR\s0 *xdrs; -u_int pos; -.fi -.ft R -.IP -A macro that invokes the set position routine associated with -the -.SM XDR -stream -.IR xdrs . -The parameter -.I pos -is a position value obtained from -.BR xdr_getpos(\|) . -This routine returns one if the -.SM XDR -stream could be repositioned, -and zero otherwise. -.IP -Warning: it is difficult to reposition some types of -.SM XDR -streams, so this routine may fail with one -type of stream and succeed with another. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdr_short(xdrs, sp) -\s-1XDR\s0 *xdrs; -short *sp; -.fi -.ft R -.IP -A filter primitive that translates between C -.B short -integers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -void -xdrstdio_create(xdrs, file, op) -\s-1XDR\s0 *xdrs; -\s-1FILE\s0 *file; -enum xdr_op op; -.fi -.ft R -.IP -This routine initializes the -.SM XDR -stream object pointed to by -.IR xdrs . -The -.SM XDR -stream data is written to, or read from, the Standard -.B I/O -stream -.IR file . -The parameter -.I op -determines the direction of the -.SM XDR -stream (either -.BR \s-1XDR_ENCODE\s0 , -.BR \s-1XDR_DECODE\s0 , -or -.BR \s-1XDR_FREE\s0 ). -.IP -Warning: the destroy routine associated with such -.SM XDR -streams calls -.B fflush(\|) -on the -.I file -stream, but never -.BR fclose(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -xdr_string(xdrs, sp, maxsize) -\s-1XDR\s0 -*xdrs; -char **sp; -u_int maxsize; -.fi -.ft R -.IP -A filter primitive that translates between C strings and -their -corresponding external representations. -Strings cannot be longer than -.IR maxsize . -Note: -.I sp -is the address of the string's pointer. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -xdr_u_char(xdrs, ucp) -\s-1XDR\s0 *xdrs; -unsigned char *ucp; -.fi -.ft R -.IP -A filter primitive that translates between -.B unsigned -C characters and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -xdr_u_int(xdrs, up) -\s-1XDR\s0 *xdrs; -unsigned *up; -.fi -.ft R -.IP -A filter primitive that translates between C -.B unsigned -integers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_u_long(xdrs, ulp) -\s-1XDR\s0 *xdrs; -unsigned long *ulp; -.fi -.ft R -.IP -A filter primitive that translates between C -.B "unsigned long" -integers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -xdr_u_short(xdrs, usp) -\s-1XDR\s0 *xdrs; -unsigned short *usp; -.fi -.ft R -.IP -A filter primitive that translates between C -.B "unsigned short" -integers and their external representations. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 16 -.LP -.ft B -.nf -.sp .5 -xdr_union(xdrs, dscmp, unp, choices, dfault) -\s-1XDR\s0 *xdrs; -int *dscmp; -char *unp; -struct xdr_discrim *choices; -bool_t (*defaultarm) (\|); /* may equal \s-1NULL\s0 */ -.fi -.ft R -.IP -A filter primitive that translates between a discriminated C -.B union -and its corresponding external representation. It first -translates the discriminant of the union located at -.IR dscmp . -This discriminant is always an -.BR enum_t . -Next the union located at -.I unp -is translated. The parameter -.I choices -is a pointer to an array of -.B xdr_discrim(\|) -structures. Each structure contains an ordered pair of -.RI [ value , proc ]. -If the union's discriminant is equal to the associated -.IR value , -then the -.I proc -is called to translate the union. The end of the -.B xdr_discrim(\|) -structure array is denoted by a routine of value -.SM NULL\s0. -If the discriminant is not found in the -.I choices -array, then the -.I defaultarm -procedure is called (if it is not -.SM NULL\s0). -Returns one if it succeeds, zero otherwise. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -xdr_vector(xdrs, arrp, size, elsize, elproc) -\s-1XDR\s0 *xdrs; -char *arrp; -u_int size, elsize; -xdrproc_t elproc; -.fi -.ft R -.IP -A filter primitive that translates between fixed-length -arrays -and their corresponding external representations. The -parameter -.I arrp -is the address of the pointer to the array, while -.I size -is is the element count of the array. The parameter -.I elsize -is the -.I sizeof -each of the array's elements, and -.I elproc -is an -.SM XDR -filter that translates between -the array elements' C form, and their external -representation. -This routine returns one if it succeeds, zero otherwise. -.br -.if t .ne 5 -.LP -.ft B -.nf -.sp .5 -xdr_void(\|) -.fi -.ft R -.IP -This routine always returns one. -It may be passed to -.SM RPC -routines that require a function parameter, -where nothing is to be done. -.br -.if t .ne 10 -.LP -.ft B -.nf -.sp .5 -xdr_wrapstring(xdrs, sp) -\s-1XDR\s0 *xdrs; -char **sp; -.fi -.ft R -.IP -A primitive that calls -.B "xdr_string(xdrs, sp,\s-1MAXUN.UNSIGNED\s0 );" -where -.B -.SM MAXUN.UNSIGNED -is the maximum value of an unsigned integer. -.B xdr_wrapstring(\|) -is handy because the -.SM RPC -package passes a maximum of two -.SM XDR -routines as parameters, and -.BR xdr_string(\|) , -one of the most frequently used primitives, requires three. -Returns one if it succeeds, zero otherwise. -.SH SEE ALSO -.BR rpc (3N) -.LP -The following manuals: -.RS -.ft I -eXternal Data Representation Standard: Protocol Specification -.br -eXternal Data Representation: Sun Technical Notes -.ft R -.br -.IR "\s-1XDR\s0: External Data Representation Standard" , -.SM RFC1014, Sun Microsystems, Inc., -.SM USC-ISI\s0. diff --git a/lib/librpc/man/man5/rpc.5 b/lib/librpc/man/man5/rpc.5 deleted file mode 100644 index 324ecb153a83..000000000000 --- a/lib/librpc/man/man5/rpc.5 +++ /dev/null @@ -1,71 +0,0 @@ -.\" @(#)rpc.5 2.2 88/08/03 4.0 RPCSRC; from 1.4 87/11/27 SMI; -.TH RPC 5 "26 September 1985" -.SH NAME -rpc \- rpc program number data base -.SH SYNOPSIS -.B /etc/rpc -.SH DESCRIPTION -The -.I rpc -file contains user readable names that -can be used in place of rpc program numbers. -Each line has the following information: -.HP 10 -name of server for the rpc program -.br -.ns -.HP 10 -rpc program number -.br -.ns -.HP 10 -aliases -.LP -Items are separated by any number of blanks and/or -tab characters. -A ``#'' indicates the beginning of a comment; characters up to the end of -the line are not interpreted by routines which search the file. -.LP -Here is an example of the \fI/etc/rpc\fP file from the Sun RPC Source -distribution. -.nf -.ta 1.5i +0.5i +1.0i +1.0i -# -# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI -# -portmapper 100000 portmap sunrpc -rstatd 100001 rstat rstat_svc rup perfmeter -rusersd 100002 rusers -nfs 100003 nfsprog -ypserv 100004 ypprog -mountd 100005 mount showmount -ypbind 100007 -walld 100008 rwall shutdown -yppasswdd 100009 yppasswd -etherstatd 100010 etherstat -rquotad 100011 rquotaprog quota rquota -sprayd 100012 spray -3270_mapper 100013 -rje_mapper 100014 -selection_svc 100015 selnsvc -database_svc 100016 -rexd 100017 rex -alis 100018 -sched 100019 -llockmgr 100020 -nlockmgr 100021 -x25.inr 100022 -statmon 100023 -status 100024 -bootparam 100026 -ypupdated 100028 ypupdate -keyserv 100029 keyserver -tfsd 100037 -nsed 100038 -nsemntd 100039 -.fi -.DT -.SH FILES -/etc/rpc -.SH "SEE ALSO" -getrpcent(3N) diff --git a/lib/librpc/man/man8/portmap.8c b/lib/librpc/man/man8/portmap.8c deleted file mode 100644 index 862bd0518460..000000000000 --- a/lib/librpc/man/man8/portmap.8c +++ /dev/null @@ -1,53 +0,0 @@ -.\" @(#)portmap.8c 2.2 88/08/03 4.0 RPCSRC; from 1.10 88/03/14 SMI -.TH PORTMAP 8C "9 September 1987" -.SH NAME -portmap \- DARPA port to RPC program number mapper -.SH SYNOPSIS -.B /usr/etc/rpc.portmap -.SH DESCRIPTION -.IX "portmap command" "" "\fLportmap\fP \(em DARPA to RPC mapper" -.IX DARPA "to RPC mapper \(em \fLportmap\fP" -.B portmap -is a server that converts -.SM RPC -program numbers into -.SM DARPA -protocol port numbers. -It must be running in order to make -.SM RPC -calls. -.LP -When an -.SM RPC -server is started, it will tell -.B portmap -what port number it is listening to, and what -.SM RPC -program numbers it is prepared to serve. -When a client wishes to make an -.SM RPC -call to a given program number, -it will first contact -.B portmap -on the server machine to determine -the port number where -.SM RPC -packets should be sent. -.LP -Normally, standard -.SM RPC -servers are started by -.BR inetd (8C), -so -.B portmap -must be started before -.B inetd -is invoked. -.SH "SEE ALSO" -.BR inetd.conf (5), -.BR rpcinfo (8), -.BR inetd (8) -.SH BUGS -If -.B portmap -crashes, all servers must be restarted. diff --git a/lib/librpc/man/man8/rpcinfo.8c b/lib/librpc/man/man8/rpcinfo.8c deleted file mode 100644 index 2d0de97fd39e..000000000000 --- a/lib/librpc/man/man8/rpcinfo.8c +++ /dev/null @@ -1,183 +0,0 @@ -.\" @(#)rpcinfo.8c 2.2 88/08/03 4.0 RPCSRC; from 1.24 88/02/25 SMI -.TH RPCINFO 8C "17 December 1987" -.SH NAME -rpcinfo \- report RPC information -.SH SYNOPSIS -.B "rpcinfo \-p" -[ -.I host -] -.LP -.B "rpcinfo" -[ -.B \-n -.I portnum -] -.B \-u -.I host -.I program -[ -.I version -] -.LP -.B "rpcinfo" -[ -.B \-n -.I portnum -] -.B \-t -.I host -.I program -[ -.I version -] -.LP -.B "rpcinfo \-b" -.I program -.I version -.LP -.B "rpcinfo \-d" -.I program -.I version -.SH DESCRIPTION -.B rpcinfo -makes an -.SM RPC -call to an -.SM RPC -server and reports what it finds. -.SH OPTIONS -.TP -.B \-p -Probe the portmapper on -.IR host , -and print a list of all registered -.SM RPC -programs. If -.I host -is not specified, it defaults to the value returned by -.BR hostname (1). -.TP -.B \-u -Make an -.SM RPC -call to procedure 0 of -.I program -on the specified -.I host -using -.SM UDP\s0, -and report whether a response was received. -.TP -.B \-t -Make an -.SM RPC -call to procedure 0 of -.I program -on the specified -.I host -using -.SM TCP\s0, -and report whether a response was received. -.TP -.B \-n -Use -.I portnum -as the port number for the -.I \-t -and -.I \-u -options instead of the port number given by the portmapper. -.TP -.B \-b -Make an -.SM RPC -broadcast to procedure 0 of the specified -.I program -and -.I version -using -.SM UDP -and report all hosts that respond. -.TP -.B \-d -Delete registration for the -.SM RPC -service of the specified -.I program -and -.IR version . -This option can be exercised only by the super-user. -.LP -The -.I program -argument can be either a name or a number. -.LP -If a -.I version -is specified, -.B rpcinfo -attempts to call that version of the specified -.IR program . -Otherwise, -.B rpcinfo -attempts to find all the registered version -numbers for the specified -.I program -by calling version 0 (which is presumed not -to exist; if it does exist, -.B rpcinfo -attempts to obtain this information by calling -an extremely high version -number instead) and attempts to call each registered version. -Note: the version number is required for -.B \-b -and -.B \-d -options. -.SH EXAMPLES -To show all of the -.SM RPC -services registered on the local machine use: -.IP -.B example% rpcinfo -p -.LP -To show all of the -.SM RPC -services registered on the machine named -.B klaxon -use: -.IP -.B example% rpcinfo -p klaxon -.LP -To show all machines on the local net that are running the Yellow Pages -service use: -.IP -.B "example% rpcinfo -b ypserv 'version' | uniq" -.LP -where 'version' is the current Yellow Pages version obtained from the -results of the -.B \-p -switch above. -.LP -To delete the registration for version 1 of the -.B walld -service use: -.IP -.B example% rpcinfo -d walld 1 -.SH "SEE ALSO" -.BR rpc (5), -.BR portmap (8C) -.LP -.I "\s-1RPC\s0 Programming Guide" -.SH BUGS -In releases prior to Sun\s-1OS\s0 -3.0, the Network File System (\s-1NFS\s0) did not -register itself with the -portmapper; -.B rpcinfo -cannot be used to make -.SM RPC -calls to the -.SM NFS -server on hosts running such releases. diff --git a/lib/librpc/man/man8/rstat_svc.8c b/lib/librpc/man/man8/rstat_svc.8c deleted file mode 100644 index a10b71dbacad..000000000000 --- a/lib/librpc/man/man8/rstat_svc.8c +++ /dev/null @@ -1,21 +0,0 @@ -.\" @(#)rstat_svc.8c 2.2 88/08/03 4.0 RPCSRC; from 1.10 87/09/09 SMI -.TH RSTAT_SVC 8C "24 November 1987" -.SH NAME -rstat_svc \- kernel statistics server -.SH SYNOPSIS -.B /etc/rstat_svc -.SH DESCRIPTION -.LP -.B rstat_svc -is a server which returns performance statistics -obtained from the kernel. -These statistics are graphically displayed by the Sun Microsystems program, -.BR perfmeter (1). -The -.B rstat_svc -daemon is normally invoked at boot time through /etc/rc.local. -.PP -.B rstat_svc -uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x. -.SH "SEE ALSO" -.BR rstat (1), diff --git a/lib/librpc/rpc/auth.h b/lib/librpc/rpc/auth.h deleted file mode 100644 index a823ddd2ba85..000000000000 --- a/lib/librpc/rpc/auth.h +++ /dev/null @@ -1,166 +0,0 @@ -/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * auth.h, Authentication interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The data structures are completely opaque to the client. The client - * is required to pass a AUTH * to routines that create rpc - * "sessions". - */ - - -#define MAX_AUTH_BYTES 400 -#define MAXNETNAMELEN 255 /* maximum length of network user's name */ - -/* - * Status returned from authentication check - */ -enum auth_stat { - AUTH_OK=0, - /* - * failed at remote end - */ - AUTH_BADCRED=1, /* bogus credentials (seal broken) */ - AUTH_REJECTEDCRED=2, /* client should begin new session */ - AUTH_BADVERF=3, /* bogus verifier (seal broken) */ - AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ - AUTH_TOOWEAK=5, /* rejected due to security reasons */ - /* - * failed locally - */ - AUTH_INVALIDRESP=6, /* bogus response verifier */ - AUTH_FAILED=7 /* some unknown reason */ -}; - -#if (mc68000 || sparc || vax || i386 || tahoe || luna68k || hp300 || mips) -typedef u_long u_int32; /* 32-bit unsigned integers */ -#endif - -union des_block { - struct { - u_int32 high; - u_int32 low; - } key; - char c[8]; -}; -typedef union des_block des_block; -extern bool_t xdr_des_block(); - -/* - * Authentication info. Opaque to client. - */ -struct opaque_auth { - enum_t oa_flavor; /* flavor of auth */ - caddr_t oa_base; /* address of more auth stuff */ - u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ -}; - - -/* - * Auth handle, interface to client side authenticators. - */ -typedef struct { - struct opaque_auth ah_cred; - struct opaque_auth ah_verf; - union des_block ah_key; - struct auth_ops { - void (*ah_nextverf)(); - int (*ah_marshal)(); /* nextverf & serialize */ - int (*ah_validate)(); /* validate varifier */ - int (*ah_refresh)(); /* refresh credentials */ - void (*ah_destroy)(); /* destroy this structure */ - } *ah_ops; - caddr_t ah_private; -} AUTH; - - -/* - * Authentication ops. - * The ops and the auth handle provide the interface to the authenticators. - * - * AUTH *auth; - * XDR *xdrs; - * struct opaque_auth verf; - */ -#define AUTH_NEXTVERF(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) -#define auth_nextverf(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) - -#define AUTH_MARSHALL(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) -#define auth_marshall(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) - -#define AUTH_VALIDATE(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define auth_validate(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) - -#define AUTH_REFRESH(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) -#define auth_refresh(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) - -#define AUTH_DESTROY(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) -#define auth_destroy(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) - - -extern struct opaque_auth _null_auth; - - -/* - * These are the various implementations of client side authenticators. - */ - -/* - * Unix style authentication - * AUTH *authunix_create(machname, uid, gid, len, aup_gids) - * char *machname; - * int uid; - * int gid; - * int len; - * int *aup_gids; - */ -extern AUTH *authunix_create(); -extern AUTH *authunix_create_default(); /* takes no parameters */ -extern AUTH *authnone_create(); /* takes no parameters */ -extern AUTH *authdes_create(); - -#define AUTH_NONE 0 /* no authentication */ -#define AUTH_NULL 0 /* backward compatibility */ -#define AUTH_UNIX 1 /* unix style (uid, gids) */ -#define AUTH_SHORT 2 /* short hand unix style */ -#define AUTH_DES 3 /* des style (encrypted timestamps) */ diff --git a/lib/librpc/rpc/auth_none.c b/lib/librpc/rpc/auth_none.c deleted file mode 100644 index 630037fb47d3..000000000000 --- a/lib/librpc/rpc/auth_none.c +++ /dev/null @@ -1,133 +0,0 @@ -/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * auth_none.c - * Creates a client authentication handle for passing "null" - * credentials and verifiers to remote systems. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#define MAX_MARSHEL_SIZE 20 - -/* - * Authenticator operations routines - */ -static void authnone_verf(); -static void authnone_destroy(); -static bool_t authnone_marshal(); -static bool_t authnone_validate(); -static bool_t authnone_refresh(); - -static struct auth_ops ops = { - authnone_verf, - authnone_marshal, - authnone_validate, - authnone_refresh, - authnone_destroy -}; - -static struct authnone_private { - AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; - u_int mcnt; -} *authnone_private; - -AUTH * -authnone_create() -{ - register struct authnone_private *ap = authnone_private; - XDR xdr_stream; - register XDR *xdrs; - - if (ap == 0) { - ap = (struct authnone_private *)calloc(1, sizeof (*ap)); - if (ap == 0) - return (0); - authnone_private = ap; - } - if (!ap->mcnt) { - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = &ops; - xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, - XDR_ENCODE); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); - ap->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - } - return (&ap->no_client); -} - -/*ARGSUSED*/ -static bool_t -authnone_marshal(client, xdrs) - AUTH *client; - XDR *xdrs; -{ - register struct authnone_private *ap = authnone_private; - - if (ap == 0) - return (0); - return ((*xdrs->x_ops->x_putbytes)(xdrs, - ap->marshalled_client, ap->mcnt)); -} - -static void -authnone_verf() -{ -} - -static bool_t -authnone_validate() -{ - - return (TRUE); -} - -static bool_t -authnone_refresh() -{ - - return (FALSE); -} - -static void -authnone_destroy() -{ -} diff --git a/lib/librpc/rpc/auth_unix.c b/lib/librpc/rpc/auth_unix.c deleted file mode 100644 index d085d02648a6..000000000000 --- a/lib/librpc/rpc/auth_unix.c +++ /dev/null @@ -1,337 +0,0 @@ -/* @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * auth_unix.c, Implements UNIX style authentication parameters. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The system is very weak. The client uses no encryption for it's - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - * - */ - -#include - -#include -#include -#include -#include - -/* - * Unix authenticator operations vector - */ -static void authunix_nextverf(); -static bool_t authunix_marshal(); -static bool_t authunix_validate(); -static bool_t authunix_refresh(); -static void authunix_destroy(); - -static struct auth_ops auth_unix_ops = { - authunix_nextverf, - authunix_marshal, - authunix_validate, - authunix_refresh, - authunix_destroy -}; - -/* - * This struct is pointed to by the ah_private field of an auth_handle. - */ -struct audata { - struct opaque_auth au_origcred; /* original credentials */ - struct opaque_auth au_shcred; /* short hand cred */ - u_long au_shfaults; /* short hand cache faults */ - char au_marshed[MAX_AUTH_BYTES]; - u_int au_mpos; /* xdr pos at end of marshed */ -}; -#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) - -static bool_t marshal_new_auth(); - - -/* - * Create a unix style authenticator. - * Returns an auth handle with the given stuff in it. - */ -AUTH * -authunix_create(machname, uid, gid, len, aup_gids) - char *machname; - int uid; - int gid; - register int len; - int *aup_gids; -{ - struct authunix_parms aup; - char mymem[MAX_AUTH_BYTES]; - struct timeval now; - XDR xdrs; - register AUTH *auth; - register struct audata *au; - - /* - * Allocate and set up auth handle - */ - auth = (AUTH *)mem_alloc(sizeof(*auth)); -#ifndef KERNEL - if (auth == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - au = (struct audata *)mem_alloc(sizeof(*au)); -#ifndef KERNEL - if (au == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - auth->ah_ops = &auth_unix_ops; - auth->ah_private = (caddr_t)au; - auth->ah_verf = au->au_shcred = _null_auth; - au->au_shfaults = 0; - - /* - * fill in param struct from the given params - */ - (void)gettimeofday(&now, (struct timezone *)0); - aup.aup_time = now.tv_sec; - aup.aup_machname = machname; - aup.aup_uid = uid; - aup.aup_gid = gid; - aup.aup_len = (u_int)len; - aup.aup_gids = aup_gids; - - /* - * Serialize the parameters into origcred - */ - xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); - if (! xdr_authunix_parms(&xdrs, &aup)) - abort(); - au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); - au->au_origcred.oa_flavor = AUTH_UNIX; -#ifdef KERNEL - au->au_origcred.oa_base = mem_alloc((u_int) len); -#else - if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - bcopy(mymem, au->au_origcred.oa_base, (u_int)len); - - /* - * set auth handle to reflect new cred. - */ - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); - return (auth); -} - -/* - * Some servers will refuse mounts if the group list is larger - * than it expects (like 8). This allows the application to set - * the maximum size of the group list that will be sent. - */ - -static maxgrplist = NGRPS; - -set_rpc_maxgrouplist(num) - int num; -{ - - if (num < NGRPS) - maxgrplist = num; -} - -/* - * Returns an auth handle with parameters determined by doing lots of - * syscalls. - */ -AUTH * -authunix_create_default() -{ - register int len; - char machname[MAX_MACHINE_NAME + 1]; - register int uid; - register int gid; - int gids[NGRPS]; - - if (gethostname(machname, MAX_MACHINE_NAME) == -1) - abort(); - machname[MAX_MACHINE_NAME] = 0; - uid = geteuid(); - gid = getegid(); - if ((len = getgroups(NGRPS, gids)) < 0) - abort(); - if (len > maxgrplist) - len = maxgrplist; - return (authunix_create(machname, uid, gid, len, gids)); -} - -/* - * authunix operations - */ - -static void -authunix_nextverf(auth) - AUTH *auth; -{ - /* no action necessary */ -} - -static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; -{ - register struct audata *au = AUTH_PRIVATE(auth); - - return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); -} - -static bool_t -authunix_validate(auth, verf) - register AUTH *auth; - struct opaque_auth verf; -{ - register struct audata *au; - XDR xdrs; - - if (verf.oa_flavor == AUTH_SHORT) { - au = AUTH_PRIVATE(auth); - xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE); - - if (au->au_shcred.oa_base != NULL) { - mem_free(au->au_shcred.oa_base, - au->au_shcred.oa_length); - au->au_shcred.oa_base = NULL; - } - if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { - auth->ah_cred = au->au_shcred; - } else { - xdrs.x_op = XDR_FREE; - (void)xdr_opaque_auth(&xdrs, &au->au_shcred); - au->au_shcred.oa_base = NULL; - auth->ah_cred = au->au_origcred; - } - marshal_new_auth(auth); - } - return (TRUE); -} - -static bool_t -authunix_refresh(auth) - register AUTH *auth; -{ - register struct audata *au = AUTH_PRIVATE(auth); - struct authunix_parms aup; - struct timeval now; - XDR xdrs; - register int stat; - - if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { - /* there is no hope. Punt */ - return (FALSE); - } - au->au_shfaults ++; - - /* first deserialize the creds back into a struct authunix_parms */ - aup.aup_machname = NULL; - aup.aup_gids = (int *)NULL; - xdrmem_create(&xdrs, au->au_origcred.oa_base, - au->au_origcred.oa_length, XDR_DECODE); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - - /* update the time and serialize in place */ - (void)gettimeofday(&now, (struct timezone *)0); - aup.aup_time = now.tv_sec; - xdrs.x_op = XDR_ENCODE; - XDR_SETPOS(&xdrs, 0); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); -done: - /* free the struct authunix_parms created by deserializing */ - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, &aup); - XDR_DESTROY(&xdrs); - return (stat); -} - -static void -authunix_destroy(auth) - register AUTH *auth; -{ - register struct audata *au = AUTH_PRIVATE(auth); - - mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); - - if (au->au_shcred.oa_base != NULL) - mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); - - mem_free(auth->ah_private, sizeof(struct audata)); - - if (auth->ah_verf.oa_base != NULL) - mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); - - mem_free((caddr_t)auth, sizeof(*auth)); -} - -/* - * Marshals (pre-serializes) an auth struct. - * sets private data, au_marshed and au_mpos - */ -static bool_t -marshal_new_auth(auth) - register AUTH *auth; -{ - XDR xdr_stream; - register XDR *xdrs = &xdr_stream; - register struct audata *au = AUTH_PRIVATE(auth); - - xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); - if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || - (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { - perror("auth_none.c - Fatal marshalling problem"); - } else { - au->au_mpos = XDR_GETPOS(xdrs); - } - XDR_DESTROY(xdrs); -} diff --git a/lib/librpc/rpc/auth_unix.h b/lib/librpc/rpc/auth_unix.h deleted file mode 100644 index 705741e1393c..000000000000 --- a/lib/librpc/rpc/auth_unix.h +++ /dev/null @@ -1,72 +0,0 @@ -/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)auth_unix.h 1.5 86/07/16 SMI */ - -/* - * auth_unix.h, Protocol for UNIX style authentication parameters for RPC - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * The system is very weak. The client uses no encryption for it - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - */ - -/* The machine name is part of a credential; it may not exceed 255 bytes */ -#define MAX_MACHINE_NAME 255 - -/* gids compose part of a credential; there may not be more than 16 of them */ -#define NGRPS 16 - -/* - * Unix style credentials. - */ -struct authunix_parms { - u_long aup_time; - char *aup_machname; - int aup_uid; - int aup_gid; - u_int aup_len; - int *aup_gids; -}; - -extern bool_t xdr_authunix_parms(); - -/* - * If a response verifier has flavor AUTH_SHORT, - * then the body of the response verifier encapsulates the following structure; - * again it is serialized in the obvious fashion. - */ -struct short_hand_verf { - struct opaque_auth new_cred; -}; diff --git a/lib/librpc/rpc/authunix_prot.c b/lib/librpc/rpc/authunix_prot.c deleted file mode 100644 index a60d99a57b73..000000000000 --- a/lib/librpc/rpc/authunix_prot.c +++ /dev/null @@ -1,66 +0,0 @@ -/* @(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * authunix_prot.c - * XDR for UNIX style authentication parameters for RPC - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - - -#include -#include -#include -#include - -/* - * XDR for unix authentication parameters. - */ -bool_t -xdr_authunix_parms(xdrs, p) - register XDR *xdrs; - register struct authunix_parms *p; -{ - - if (xdr_u_long(xdrs, &(p->aup_time)) - && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_int(xdrs, &(p->aup_uid)) - && xdr_int(xdrs, &(p->aup_gid)) - && xdr_array(xdrs, (caddr_t *)&(p->aup_gids), - &(p->aup_len), NGRPS, sizeof(int), xdr_int) ) { - return (TRUE); - } - return (FALSE); -} - diff --git a/lib/librpc/rpc/bindresvport.c b/lib/librpc/rpc/bindresvport.c deleted file mode 100644 index 63a68d36e15f..000000000000 --- a/lib/librpc/rpc/bindresvport.c +++ /dev/null @@ -1,79 +0,0 @@ -static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1987 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -/* - * Bind a socket to a privileged IP port - */ -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; -{ - int res; - static short port; - struct sockaddr_in myaddr; - extern int errno; - int i; - -#define STARTPORT 600 -#define ENDPORT (IPPORT_RESERVED - 1) -#define NPORTS (ENDPORT - STARTPORT + 1) - - if (sin == (struct sockaddr_in *)0) { - sin = &myaddr; - bzero(sin, sizeof (*sin)); - sin->sin_family = AF_INET; - } else if (sin->sin_family != AF_INET) { - errno = EPFNOSUPPORT; - return (-1); - } - if (port == 0) { - port = (getpid() % NPORTS) + STARTPORT; - } - res = -1; - errno = EADDRINUSE; - for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) { - sin->sin_port = htons(port++); - if (port > ENDPORT) { - port = STARTPORT; - } - res = bind(sd, - (struct sockaddr *)sin, sizeof(struct sockaddr_in)); - } - return (res); -} diff --git a/lib/librpc/rpc/clnt.h b/lib/librpc/rpc/clnt.h deleted file mode 100644 index 8c002a19faee..000000000000 --- a/lib/librpc/rpc/clnt.h +++ /dev/null @@ -1,331 +0,0 @@ -/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * clnt.h - Client side remote procedure call interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _CLNT_ -#define _CLNT_ - -/* - * Rpc calls return an enum clnt_stat. This should be looked at more, - * since each implementation is required to live with this (implementation - * independent) list of errors. - */ -enum clnt_stat { - RPC_SUCCESS=0, /* call succeeded */ - /* - * local errors - */ - RPC_CANTENCODEARGS=1, /* can't encode arguments */ - RPC_CANTDECODERES=2, /* can't decode results */ - RPC_CANTSEND=3, /* failure in sending call */ - RPC_CANTRECV=4, /* failure in receiving result */ - RPC_TIMEDOUT=5, /* call timed out */ - /* - * remote errors - */ - RPC_VERSMISMATCH=6, /* rpc versions not compatible */ - RPC_AUTHERROR=7, /* authentication error */ - RPC_PROGUNAVAIL=8, /* program not available */ - RPC_PROGVERSMISMATCH=9, /* program version mismatched */ - RPC_PROCUNAVAIL=10, /* procedure unavailable */ - RPC_CANTDECODEARGS=11, /* decode arguments error */ - RPC_SYSTEMERROR=12, /* generic "other problem" */ - - /* - * callrpc & clnt_create errors - */ - RPC_UNKNOWNHOST=13, /* unknown host name */ - RPC_UNKNOWNPROTO=17, /* unkown protocol */ - - /* - * _ create errors - */ - RPC_PMAPFAILURE=14, /* the pmapper failed in its call */ - RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ - /* - * unspecified error - */ - RPC_FAILED=16 -}; - - -/* - * Error info. - */ -struct rpc_err { - enum clnt_stat re_status; - union { - int RE_errno; /* realated system error */ - enum auth_stat RE_why; /* why the auth error occurred */ - struct { - u_long low; /* lowest verion supported */ - u_long high; /* highest verion supported */ - } RE_vers; - struct { /* maybe meaningful if RPC_FAILED */ - long s1; - long s2; - } RE_lb; /* life boot & debugging only */ - } ru; -#define re_errno ru.RE_errno -#define re_why ru.RE_why -#define re_vers ru.RE_vers -#define re_lb ru.RE_lb -}; - - -/* - * Client rpc handle. - * Created by individual implementations, see e.g. rpc_udp.c. - * Client is responsible for initializing auth, see e.g. auth_none.c. - */ -typedef struct { - AUTH *cl_auth; /* authenticator */ - struct clnt_ops { - enum clnt_stat (*cl_call)(); /* call remote procedure */ - void (*cl_abort)(); /* abort a call */ - void (*cl_geterr)(); /* get specific error code */ - bool_t (*cl_freeres)(); /* frees results */ - void (*cl_destroy)();/* destroy this structure */ - bool_t (*cl_control)();/* the ioctl() of rpc */ - } *cl_ops; - caddr_t cl_private; /* private stuff */ -} CLIENT; - - -/* - * client side rpc interface ops - * - * Parameter types are: - * - */ - -/* - * enum clnt_stat - * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) - * CLIENT *rh; - * u_long proc; - * xdrproc_t xargs; - * caddr_t argsp; - * xdrproc_t xres; - * caddr_t resp; - * struct timeval timeout; - */ -#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) -#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) - -/* - * void - * CLNT_ABORT(rh); - * CLIENT *rh; - */ -#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) -#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) - -/* - * struct rpc_err - * CLNT_GETERR(rh); - * CLIENT *rh; - */ -#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) -#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) - - -/* - * bool_t - * CLNT_FREERES(rh, xres, resp); - * CLIENT *rh; - * xdrproc_t xres; - * caddr_t resp; - */ -#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) -#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) - -/* - * bool_t - * CLNT_CONTROL(cl, request, info) - * CLIENT *cl; - * u_int request; - * char *info; - */ -#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) -#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) - -/* - * control operations that apply to both udp and tcp transports - */ -#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ -#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ -#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ -/* - * udp only control operations - */ -#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ -#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ - -/* - * void - * CLNT_DESTROY(rh); - * CLIENT *rh; - */ -#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) -#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) - - -/* - * RPCTEST is a test program which is accessable on every rpc - * transport/port. It is used for testing, performance evaluation, - * and network administration. - */ - -#define RPCTEST_PROGRAM ((u_long)1) -#define RPCTEST_VERSION ((u_long)1) -#define RPCTEST_NULL_PROC ((u_long)2) -#define RPCTEST_NULL_BATCH_PROC ((u_long)3) - -/* - * By convention, procedure 0 takes null arguments and returns them - */ - -#define NULLPROC ((u_long)0) - -/* - * Below are the client handle creation routines for the various - * implementations of client side rpc. They can return NULL if a - * creation failure occurs. - */ - -/* - * Memory based rpc (for speed check and testing) - * CLIENT * - * clntraw_create(prog, vers) - * u_long prog; - * u_long vers; - */ -extern CLIENT *clntraw_create(); - - -/* - * Generic client creation routine. Supported protocols are "udp" and "tcp" - */ -extern CLIENT * -clnt_create(/*host, prog, vers, prot*/); /* - char *host; -- hostname - u_long prog; -- program number - u_long vers; -- version number - char *prot; -- protocol -*/ - - - - -/* - * TCP based rpc - * CLIENT * - * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long prog; - * u_long version; - * register int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -extern CLIENT *clnttcp_create(); - -/* - * UDP based rpc. - * CLIENT * - * clntudp_create(raddr, program, version, wait, sockp) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * - * Same as above, but you specify max packet sizes. - * CLIENT * - * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -extern CLIENT *clntudp_create(); -extern CLIENT *clntudp_bufcreate(); - -/* - * Print why creation failed - */ -void clnt_pcreateerror(/* char *msg */); /* stderr */ -char *clnt_spcreateerror(/* char *msg */); /* string */ - -/* - * Like clnt_perror(), but is more verbose in its output - */ -void clnt_perrno(/* enum clnt_stat num */); /* stderr */ - -/* - * Print an English error message, given the client error code - */ -void clnt_perror(/* CLIENT *clnt, char *msg */); /* stderr */ -char *clnt_sperror(/* CLIENT *clnt, char *msg */); /* string */ - -/* - * If a creation fails, the following allows the user to figure out why. - */ -struct rpc_createerr { - enum clnt_stat cf_stat; - struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ -}; - -extern struct rpc_createerr rpc_createerr; - - - -/* - * Copy error message to buffer. - */ -char *clnt_sperrno(/* enum clnt_stat num */); /* string */ - - - -#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ -#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ - -#endif /*!_CLNT_*/ diff --git a/lib/librpc/rpc/clnt_generic.c b/lib/librpc/rpc/clnt_generic.c deleted file mode 100644 index e54e77828b2a..000000000000 --- a/lib/librpc/rpc/clnt_generic.c +++ /dev/null @@ -1,110 +0,0 @@ -/* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; -#endif -/* - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include -#include - -/* - * Generic client creation: takes (hostname, program-number, protocol) and - * returns client handle. Default options are set, which the user can - * change using the rpc equivalent of ioctl()'s. - */ -CLIENT * -clnt_create(hostname, prog, vers, proto) - char *hostname; - unsigned prog; - unsigned vers; - char *proto; -{ - struct hostent *h; - struct protoent *p; - struct sockaddr_in sin; - int sock; - struct timeval tv; - CLIENT *client; - - h = gethostbyname(hostname); - if (h == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; - return (NULL); - } - if (h->h_addrtype != AF_INET) { - /* - * Only support INET for now - */ - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; - return (NULL); - } - sin.sin_family = h->h_addrtype; - sin.sin_port = 0; - bzero(sin.sin_zero, sizeof(sin.sin_zero)); - bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); - p = getprotobyname(proto); - if (p == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return (NULL); - } - sock = RPC_ANYSOCK; - switch (p->p_proto) { - case IPPROTO_UDP: - tv.tv_sec = 5; - tv.tv_usec = 0; - client = clntudp_create(&sin, prog, vers, tv, &sock); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - case IPPROTO_TCP: - client = clnttcp_create(&sin, prog, vers, &sock, 0, 0); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - tv.tv_usec = 0; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - default: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return (NULL); - } - return (client); -} diff --git a/lib/librpc/rpc/clnt_perror.c b/lib/librpc/rpc/clnt_perror.c deleted file mode 100644 index c618c5f3e97f..000000000000 --- a/lib/librpc/rpc/clnt_perror.c +++ /dev/null @@ -1,302 +0,0 @@ -/* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_perror.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ -#include - -#include -#include -#include - -static char *auth_errmsg(); - -extern char *strcpy(); - -static char *buf; - -static char * -_buf() -{ - - if (buf == 0) - buf = (char *)malloc(256); - return (buf); -} - -/* - * Print reply error info - */ -char * -clnt_sperror(rpch, s) - CLIENT *rpch; - char *s; -{ - struct rpc_err e; - void clnt_perrno(); - char *err; - char *str = _buf(); - char *strstart = str; - - if (str == 0) - return (0); - CLNT_GETERR(rpch, &e); - - (void) sprintf(str, "%s: ", s); - str += strlen(str); - - (void) strcpy(str, clnt_sperrno(e.re_status)); - str += strlen(str); - - switch (e.re_status) { - case RPC_SUCCESS: - case RPC_CANTENCODEARGS: - case RPC_CANTDECODERES: - case RPC_TIMEDOUT: - case RPC_PROGUNAVAIL: - case RPC_PROCUNAVAIL: - case RPC_CANTDECODEARGS: - case RPC_SYSTEMERROR: - case RPC_UNKNOWNHOST: - case RPC_UNKNOWNPROTO: - case RPC_PMAPFAILURE: - case RPC_PROGNOTREGISTERED: - case RPC_FAILED: - break; - - case RPC_CANTSEND: - case RPC_CANTRECV: - (void) sprintf(str, "; errno = %s", - strerror(e.re_errno)); - str += strlen(str); - break; - - case RPC_VERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - case RPC_AUTHERROR: - err = auth_errmsg(e.re_why); - (void) sprintf(str,"; why = "); - str += strlen(str); - if (err != NULL) { - (void) sprintf(str, "%s",err); - } else { - (void) sprintf(str, - "(unknown authentication error - %d)", - (int) e.re_why); - } - str += strlen(str); - break; - - case RPC_PROGVERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - default: /* unknown */ - (void) sprintf(str, - "; s1 = %lu, s2 = %lu", - e.re_lb.s1, e.re_lb.s2); - str += strlen(str); - break; - } - (void) sprintf(str, "\n"); - return(strstart) ; -} - -void -clnt_perror(rpch, s) - CLIENT *rpch; - char *s; -{ - (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); -} - - -struct rpc_errtab { - enum clnt_stat status; - char *message; -}; - -static struct rpc_errtab rpc_errlist[] = { - { RPC_SUCCESS, - "RPC: Success" }, - { RPC_CANTENCODEARGS, - "RPC: Can't encode arguments" }, - { RPC_CANTDECODERES, - "RPC: Can't decode result" }, - { RPC_CANTSEND, - "RPC: Unable to send" }, - { RPC_CANTRECV, - "RPC: Unable to receive" }, - { RPC_TIMEDOUT, - "RPC: Timed out" }, - { RPC_VERSMISMATCH, - "RPC: Incompatible versions of RPC" }, - { RPC_AUTHERROR, - "RPC: Authentication error" }, - { RPC_PROGUNAVAIL, - "RPC: Program unavailable" }, - { RPC_PROGVERSMISMATCH, - "RPC: Program/version mismatch" }, - { RPC_PROCUNAVAIL, - "RPC: Procedure unavailable" }, - { RPC_CANTDECODEARGS, - "RPC: Server can't decode arguments" }, - { RPC_SYSTEMERROR, - "RPC: Remote system error" }, - { RPC_UNKNOWNHOST, - "RPC: Unknown host" }, - { RPC_UNKNOWNPROTO, - "RPC: Unknown protocol" }, - { RPC_PMAPFAILURE, - "RPC: Port mapper failure" }, - { RPC_PROGNOTREGISTERED, - "RPC: Program not registered"}, - { RPC_FAILED, - "RPC: Failed (unspecified error)"} -}; - - -/* - * This interface for use by clntrpc - */ -char * -clnt_sperrno(stat) - enum clnt_stat stat; -{ - int i; - - for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { - if (rpc_errlist[i].status == stat) { - return (rpc_errlist[i].message); - } - } - return ("RPC: (unknown error code)"); -} - -void -clnt_perrno(num) - enum clnt_stat num; -{ - (void) fprintf(stderr,"%s",clnt_sperrno(num)); -} - - -char * -clnt_spcreateerror(s) - char *s; -{ - extern int sys_nerr; - char *str = _buf(); - - if (str == 0) - return(0); - (void) sprintf(str, "%s: ", s); - (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); - switch (rpc_createerr.cf_stat) { - case RPC_PMAPFAILURE: - (void) strcat(str, " - "); - (void) strcat(str, - clnt_sperrno(rpc_createerr.cf_error.re_status)); - break; - - case RPC_SYSTEMERROR: - (void) strcat(str, " - "); - if (rpc_createerr.cf_error.re_errno > 0 - && rpc_createerr.cf_error.re_errno < sys_nerr) - (void) strcat(str, - strerror(rpc_createerr.cf_error.re_errno)); - else - (void) sprintf(&str[strlen(str)], "Error %d", - rpc_createerr.cf_error.re_errno); - break; - } - (void) strcat(str, "\n"); - return (str); -} - -void -clnt_pcreateerror(s) - char *s; -{ - (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); -} - -struct auth_errtab { - enum auth_stat status; - char *message; -}; - -static struct auth_errtab auth_errlist[] = { - { AUTH_OK, - "Authentication OK" }, - { AUTH_BADCRED, - "Invalid client credential" }, - { AUTH_REJECTEDCRED, - "Server rejected credential" }, - { AUTH_BADVERF, - "Invalid client verifier" }, - { AUTH_REJECTEDVERF, - "Server rejected verifier" }, - { AUTH_TOOWEAK, - "Client credential too weak" }, - { AUTH_INVALIDRESP, - "Invalid server verifier" }, - { AUTH_FAILED, - "Failed (unspecified error)" }, -}; - -static char * -auth_errmsg(stat) - enum auth_stat stat; -{ - int i; - - for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { - if (auth_errlist[i].status == stat) { - return(auth_errlist[i].message); - } - } - return(NULL); -} diff --git a/lib/librpc/rpc/clnt_raw.c b/lib/librpc/rpc/clnt_raw.c deleted file mode 100644 index 89059ae2da77..000000000000 --- a/lib/librpc/rpc/clnt_raw.c +++ /dev/null @@ -1,238 +0,0 @@ -/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_raw.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Memory based rpc for simple testing and timing. - * Interface to create an rpc client and server in the same process. - * This lets us similate rpc and get round trip overhead, without - * any interference from the kernal. - */ - -#include - -#define MCALL_MSG_SIZE 24 - -/* - * This is the "network" we will be moving stuff over. - */ -static struct clntraw_private { - CLIENT client_object; - XDR xdr_stream; - char _raw_buf[UDPMSGSIZE]; - char mashl_callmsg[MCALL_MSG_SIZE]; - u_int mcnt; -} *clntraw_private; - -static enum clnt_stat clntraw_call(); -static void clntraw_abort(); -static void clntraw_geterr(); -static bool_t clntraw_freeres(); -static bool_t clntraw_control(); -static void clntraw_destroy(); - -static struct clnt_ops client_ops = { - clntraw_call, - clntraw_abort, - clntraw_geterr, - clntraw_freeres, - clntraw_destroy, - clntraw_control -}; - -void svc_getreq(); - -/* - * Create a client handle for memory based rpc. - */ -CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; -{ - register struct clntraw_private *clp = clntraw_private; - struct rpc_msg call_msg; - XDR *xdrs = &clp->xdr_stream; - CLIENT *client = &clp->client_object; - - if (clp == 0) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); - if (clp == 0) - return (0); - clntraw_private = clp; - } - /* - * pre-serialize the staic part of the call msg and stash it away - */ - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = prog; - call_msg.rm_call.cb_vers = vers; - xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); - if (! xdr_callhdr(xdrs, &call_msg)) { - perror("clnt_raw.c - Fatal header serialization error."); - } - clp->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - - /* - * Set xdrmem for client/server shared buffer - */ - xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); - - /* - * create client handle - */ - client->cl_ops = &client_ops; - client->cl_auth = authnone_create(); - return (client); -} - -static enum clnt_stat -clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - u_long proc; - xdrproc_t xargs; - caddr_t argsp; - xdrproc_t xresults; - caddr_t resultsp; - struct timeval timeout; -{ - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - struct rpc_msg msg; - enum clnt_stat status; - struct rpc_err error; - - if (clp == 0) - return (RPC_FAILED); -call_again: - /* - * send request - */ - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; - if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) { - return (RPC_CANTENCODEARGS); - } - (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ - - /* - * We have to call server input routine here because this is - * all going on in one process. Yuk. - */ - svc_getreq(1); - - /* - * get results - */ - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = resultsp; - msg.acpted_rply.ar_results.proc = xresults; - if (! xdr_replymsg(xdrs, &msg)) - return (RPC_CANTDECODERES); - _seterr_reply(&msg, &error); - status = error.re_status; - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - } /* end successful completion */ - else { - if (AUTH_REFRESH(h->cl_auth)) - goto call_again; - } /* end of unsuccessful completion */ - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - if (msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); - } - } - - return (status); -} - -static void -clntraw_geterr() -{ -} - - -static bool_t -clntraw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - bool_t rval; - - if (clp == 0) - { - rval = (bool_t) RPC_FAILED; - return (rval); - } - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clntraw_abort() -{ -} - -static bool_t -clntraw_control() -{ - return (FALSE); -} - -static void -clntraw_destroy() -{ -} diff --git a/lib/librpc/rpc/clnt_simple.c b/lib/librpc/rpc/clnt_simple.c deleted file mode 100644 index 043ce0a3ebda..000000000000 --- a/lib/librpc/rpc/clnt_simple.c +++ /dev/null @@ -1,112 +0,0 @@ -/* @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_simple.c - * Simplified front end to rpc. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -static struct callrpc_private { - CLIENT *client; - int socket; - int oldprognum, oldversnum, valid; - char *oldhost; -} *callrpc_private; - -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - char *host; - xdrproc_t inproc, outproc; - char *in, *out; -{ - register struct callrpc_private *crp = callrpc_private; - struct sockaddr_in server_addr; - enum clnt_stat clnt_stat; - struct hostent *hp; - struct timeval timeout, tottimeout; - - if (crp == 0) { - crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); - if (crp == 0) - return (0); - callrpc_private = crp; - } - if (crp->oldhost == NULL) { - crp->oldhost = malloc(256); - crp->oldhost[0] = 0; - crp->socket = RPC_ANYSOCK; - } - if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum - && strcmp(crp->oldhost, host) == 0) { - /* reuse old client */ - } else { - crp->valid = 0; - (void)close(crp->socket); - crp->socket = RPC_ANYSOCK; - if (crp->client) { - clnt_destroy(crp->client); - crp->client = NULL; - } - if ((hp = gethostbyname(host)) == NULL) - return ((int) RPC_UNKNOWNHOST); - timeout.tv_usec = 0; - timeout.tv_sec = 5; - bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, - (u_long)versnum, timeout, &crp->socket)) == NULL) - return ((int) rpc_createerr.cf_stat); - crp->valid = 1; - crp->oldprognum = prognum; - crp->oldversnum = versnum; - (void) strcpy(crp->oldhost, host); - } - tottimeout.tv_sec = 25; - tottimeout.tv_usec = 0; - clnt_stat = clnt_call(crp->client, procnum, inproc, in, - outproc, out, tottimeout); - /* - * if call failed, empty cache - */ - if (clnt_stat != RPC_SUCCESS) - crp->valid = 0; - return ((int) clnt_stat); -} diff --git a/lib/librpc/rpc/clnt_tcp.c b/lib/librpc/rpc/clnt_tcp.c deleted file mode 100644 index 2222bc6577be..000000000000 --- a/lib/librpc/rpc/clnt_tcp.c +++ /dev/null @@ -1,466 +0,0 @@ -/* @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_tcp.c, Implements a TCP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * TCP based RPC supports 'batched calls'. - * A sequence of calls may be batched-up in a send buffer. The rpc call - * return immediately to the client even though the call was not necessarily - * sent. The batching occurs if the results' xdr routine is NULL (0) AND - * the rpc timeout value is zero (see clnt.h, rpc). - * - * Clients should NOT casually batch calls that in fact return results; that is, - * the server side should be aware that a call is batched and not produce any - * return message. Batched calls that produce many result messages can - * deadlock (netlock) the client and the server.... - * - * Now go hang yourself. - */ - -#include -#include -#include -#include -#include -#include - -#define MCALL_MSG_SIZE 24 - -extern int errno; - -static int readtcp(); -static int writetcp(); - -static enum clnt_stat clnttcp_call(); -static void clnttcp_abort(); -static void clnttcp_geterr(); -static bool_t clnttcp_freeres(); -static bool_t clnttcp_control(); -static void clnttcp_destroy(); - -static struct clnt_ops tcp_ops = { - clnttcp_call, - clnttcp_abort, - clnttcp_geterr, - clnttcp_freeres, - clnttcp_destroy, - clnttcp_control -}; - -struct ct_data { - int ct_sock; - bool_t ct_closeit; - struct timeval ct_wait; - bool_t ct_waitset; /* wait set by clnt_control? */ - struct sockaddr_in ct_addr; - struct rpc_err ct_error; - char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ - u_int ct_mpos; /* pos after marshal */ - XDR ct_xdrs; -}; - -/* - * Create a client handle for a tcp/ip connection. - * If *sockp<0, *sockp is set to a newly created TCP socket and it is - * connected to raddr. If *sockp non-negative then - * raddr is ignored. The rpc/tcp package does buffering - * similar to stdio, so the client must pick send and receive buffer sizes,]; - * 0 => use the default. - * If raddr->sin_port is 0, then a binder on the remote machine is - * consulted for the right port number. - * NB: *sockp is copied into a private area. - * NB: It is the clients responsibility to close *sockp. - * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this - * something more useful. - */ -CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - register int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *h; - register struct ct_data *ct; - struct timeval now; - struct rpc_msg call_msg; - - h = (CLIENT *)mem_alloc(sizeof(*h)); - if (h == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - ct = (struct ct_data *)mem_alloc(sizeof(*ct)); - if (ct == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - - /* - * If no port number given ask the pmap for one - */ - if (raddr->sin_port == 0) { - u_short port; - if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) { - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); - return ((CLIENT *)NULL); - } - raddr->sin_port = htons(port); - } - - /* - * If no socket given, open one - */ - if (*sockp < 0) { - *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - (void)bindresvport(*sockp, (struct sockaddr_in *)0); - if ((*sockp < 0) - || (connect(*sockp, (struct sockaddr *)raddr, - sizeof(*raddr)) < 0)) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(*sockp); - goto fooy; - } - ct->ct_closeit = TRUE; - } else { - ct->ct_closeit = FALSE; - } - - /* - * Set up private data struct - */ - ct->ct_sock = *sockp; - ct->ct_wait.tv_usec = 0; - ct->ct_waitset = FALSE; - ct->ct_addr = *raddr; - - /* - * Initialize call message - */ - (void)gettimeofday(&now, (struct timezone *)0); - call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = prog; - call_msg.rm_call.cb_vers = vers; - - /* - * pre-serialize the staic part of the call msg and stash it away - */ - xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, - XDR_ENCODE); - if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { - if (ct->ct_closeit) { - (void)close(*sockp); - } - goto fooy; - } - ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); - XDR_DESTROY(&(ct->ct_xdrs)); - - /* - * Create a client handle which uses xdrrec for serialization - * and authnone for authentication. - */ - xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, - (caddr_t)ct, readtcp, writetcp); - h->cl_ops = &tcp_ops; - h->cl_private = (caddr_t) ct; - h->cl_auth = authnone_create(); - return (h); - -fooy: - /* - * Something goofed, free stuff and barf - */ - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); - return ((CLIENT *)NULL); -} - -static enum clnt_stat -clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) - register CLIENT *h; - u_long proc; - xdrproc_t xdr_args; - caddr_t args_ptr; - xdrproc_t xdr_results; - caddr_t results_ptr; - struct timeval timeout; -{ - register struct ct_data *ct = (struct ct_data *) h->cl_private; - register XDR *xdrs = &(ct->ct_xdrs); - struct rpc_msg reply_msg; - u_long x_id; - u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */ - register bool_t shipnow; - int refreshes = 2; - - if (!ct->ct_waitset) { - ct->ct_wait = timeout; - } - - shipnow = - (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0 - && timeout.tv_usec == 0) ? FALSE : TRUE; - -call_again: - xdrs->x_op = XDR_ENCODE; - ct->ct_error.re_status = RPC_SUCCESS; - x_id = ntohl(--(*msg_x_id)); - if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xdr_args)(xdrs, args_ptr))) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTENCODEARGS; - (void)xdrrec_endofrecord(xdrs, TRUE); - return (ct->ct_error.re_status); - } - if (! xdrrec_endofrecord(xdrs, shipnow)) - return (ct->ct_error.re_status = RPC_CANTSEND); - if (! shipnow) - return (RPC_SUCCESS); - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - return(ct->ct_error.re_status = RPC_TIMEDOUT); - } - - - /* - * Keep receiving until we get a valid transaction id - */ - xdrs->x_op = XDR_DECODE; - while (TRUE) { - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = xdr_void; - if (! xdrrec_skiprecord(xdrs)) - return (ct->ct_error.re_status); - /* now decode and validate the response header */ - if (! xdr_replymsg(xdrs, &reply_msg)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - continue; - return (ct->ct_error.re_status); - } - if (reply_msg.rm_xid == x_id) - break; - } - - /* - * process header - */ - _seterr_reply(&reply_msg, &(ct->ct_error)); - if (ct->ct_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) { - ct->ct_error.re_status = RPC_AUTHERROR; - ct->ct_error.re_why = AUTH_INVALIDRESP; - } else if (! (*xdr_results)(xdrs, results_ptr)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTDECODERES; - } - /* free verifier ... */ - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else { - /* maybe our credentials need to be refreshed ... */ - if (refreshes-- && AUTH_REFRESH(h->cl_auth)) - goto call_again; - } /* end of unsuccessful completion */ - return (ct->ct_error.re_status); -} - -static void -clnttcp_geterr(h, errp) - CLIENT *h; - struct rpc_err *errp; -{ - register struct ct_data *ct = - (struct ct_data *) h->cl_private; - - *errp = ct->ct_error; -} - -static bool_t -clnttcp_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct ct_data *ct = (struct ct_data *)cl->cl_private; - register XDR *xdrs = &(ct->ct_xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clnttcp_abort() -{ -} - -static bool_t -clnttcp_control(cl, request, info) - CLIENT *cl; - int request; - char *info; -{ - register struct ct_data *ct = (struct ct_data *)cl->cl_private; - - switch (request) { - case CLSET_TIMEOUT: - ct->ct_wait = *(struct timeval *)info; - ct->ct_waitset = TRUE; - break; - case CLGET_TIMEOUT: - *(struct timeval *)info = ct->ct_wait; - break; - case CLGET_SERVER_ADDR: - *(struct sockaddr_in *)info = ct->ct_addr; - break; - default: - return (FALSE); - } - return (TRUE); -} - - -static void -clnttcp_destroy(h) - CLIENT *h; -{ - register struct ct_data *ct = - (struct ct_data *) h->cl_private; - - if (ct->ct_closeit) { - (void)close(ct->ct_sock); - } - XDR_DESTROY(&(ct->ct_xdrs)); - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); -} - -/* - * Interface between xdr serializer and tcp connection. - * Behaves like the system calls, read & write, but keeps some error state - * around for the rpc level. - */ -static int -readtcp(ct, buf, len) - register struct ct_data *ct; - caddr_t buf; - register int len; -{ -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; - - if (len == 0) - return (0); - FD_ZERO(&mask); - FD_SET(ct->ct_sock, &mask); -#else - register int mask = 1 << (ct->ct_sock); - int readfds; - - if (len == 0) - return (0); - -#endif /* def FD_SETSIZE */ - while (TRUE) { - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, - &(ct->ct_wait))) { - case 0: - ct->ct_error.re_status = RPC_TIMEDOUT; - return (-1); - - case -1: - if (errno == EINTR) - continue; - ct->ct_error.re_status = RPC_CANTRECV; - ct->ct_error.re_errno = errno; - return (-1); - } - break; - } - switch (len = read(ct->ct_sock, buf, len)) { - - case 0: - /* premature eof */ - ct->ct_error.re_errno = ECONNRESET; - ct->ct_error.re_status = RPC_CANTRECV; - len = -1; /* it's really an error */ - break; - - case -1: - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTRECV; - break; - } - return (len); -} - -static int -writetcp(ct, buf, len) - struct ct_data *ct; - caddr_t buf; - int len; -{ - register int i, cnt; - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(ct->ct_sock, buf, cnt)) == -1) { - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTSEND; - return (-1); - } - } - return (len); -} diff --git a/lib/librpc/rpc/clnt_udp.c b/lib/librpc/rpc/clnt_udp.c deleted file mode 100644 index 815cbb4ed269..000000000000 --- a/lib/librpc/rpc/clnt_udp.c +++ /dev/null @@ -1,442 +0,0 @@ -/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_udp.c, Implements a UDP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include - -extern int errno; - -/* - * UDP bases client side rpc operations - */ -static enum clnt_stat clntudp_call(); -static void clntudp_abort(); -static void clntudp_geterr(); -static bool_t clntudp_freeres(); -static bool_t clntudp_control(); -static void clntudp_destroy(); - -static struct clnt_ops udp_ops = { - clntudp_call, - clntudp_abort, - clntudp_geterr, - clntudp_freeres, - clntudp_destroy, - clntudp_control -}; - -/* - * Private data kept per client handle - */ -struct cu_data { - int cu_sock; - bool_t cu_closeit; - struct sockaddr_in cu_raddr; - int cu_rlen; - struct timeval cu_wait; - struct timeval cu_total; - struct rpc_err cu_error; - XDR cu_outxdrs; - u_int cu_xdrpos; - u_int cu_sendsz; - char *cu_outbuf; - u_int cu_recvsz; - char cu_inbuf[1]; -}; - -/* - * Create a UDP based client handle. - * If *sockp<0, *sockp is set to a newly created UPD socket. - * If raddr->sin_port is 0 a binder on the remote machine - * is consulted for the correct port number. - * NB: It is the clients responsibility to close *sockp. - * NB: The rpch->cl_auth is initialized to null authentication. - * Caller may wish to set this something more useful. - * - * wait is the amount of time used between retransmitting a call if - * no response has been heard; retransmition occurs until the actual - * rpc call times out. - * - * sendsz and recvsz are the maximum allowable packet sizes that can be - * sent and received. - */ -CLIENT * -clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - register int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *cl; - register struct cu_data *cu; - struct timeval now; - struct rpc_msg call_msg; - - cl = (CLIENT *)mem_alloc(sizeof(CLIENT)); - if (cl == NULL) { - (void) fprintf(stderr, "clntudp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - sendsz = ((sendsz + 3) / 4) * 4; - recvsz = ((recvsz + 3) / 4) * 4; - cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz); - if (cu == NULL) { - (void) fprintf(stderr, "clntudp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - cu->cu_outbuf = &cu->cu_inbuf[recvsz]; - - (void)gettimeofday(&now, (struct timezone *)0); - if (raddr->sin_port == 0) { - u_short port; - if ((port = - pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { - goto fooy; - } - raddr->sin_port = htons(port); - } - cl->cl_ops = &udp_ops; - cl->cl_private = (caddr_t)cu; - cu->cu_raddr = *raddr; - cu->cu_rlen = sizeof (cu->cu_raddr); - cu->cu_wait = wait; - cu->cu_total.tv_sec = -1; - cu->cu_total.tv_usec = -1; - cu->cu_sendsz = sendsz; - cu->cu_recvsz = recvsz; - call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = program; - call_msg.rm_call.cb_vers = version; - xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, - sendsz, XDR_ENCODE); - if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { - goto fooy; - } - cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); - if (*sockp < 0) { - int dontblock = 1; - - *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (*sockp < 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - /* attempt to bind to prov port */ - (void)bindresvport(*sockp, (struct sockaddr_in *)0); - /* the sockets rpc controls are non-blocking */ - (void)ioctl(*sockp, FIONBIO, (char *) &dontblock); - cu->cu_closeit = TRUE; - } else { - cu->cu_closeit = FALSE; - } - cu->cu_sock = *sockp; - cl->cl_auth = authnone_create(); - return (cl); -fooy: - if (cu) - mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz); - if (cl) - mem_free((caddr_t)cl, sizeof(CLIENT)); - return ((CLIENT *)NULL); -} - -CLIENT * -clntudp_create(raddr, program, version, wait, sockp) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - register int *sockp; -{ - - return(clntudp_bufcreate(raddr, program, version, wait, sockp, - UDPMSGSIZE, UDPMSGSIZE)); -} - -static enum clnt_stat -clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) - register CLIENT *cl; /* client handle */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - struct timeval utimeout; /* seconds to wait before giving up */ -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - register XDR *xdrs; - register int outlen; - register int inlen; - int fromlen; -#ifdef FD_SETSIZE - fd_set readfds; - fd_set mask; -#else - int readfds; - register int mask; -#endif /* def FD_SETSIZE */ - struct sockaddr_in from; - struct rpc_msg reply_msg; - XDR reply_xdrs; - struct timeval time_waited; - bool_t ok; - int nrefreshes = 2; /* number of times to refresh cred */ - struct timeval timeout; - - if (cu->cu_total.tv_usec == -1) { - timeout = utimeout; /* use supplied timeout */ - } else { - timeout = cu->cu_total; /* use default timeout */ - } - - time_waited.tv_sec = 0; - time_waited.tv_usec = 0; -call_again: - xdrs = &(cu->cu_outxdrs); - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, cu->cu_xdrpos); - /* - * the transaction is the first thing in the out buffer - */ - (*(u_short *)(cu->cu_outbuf))++; - if ((! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) - return (cu->cu_error.re_status = RPC_CANTENCODEARGS); - outlen = (int)XDR_GETPOS(xdrs); - -send_again: - if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, - (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) - != outlen) { - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTSEND); - } - - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - return (cu->cu_error.re_status = RPC_TIMEDOUT); - } - /* - * sub-optimal code appears here because we have - * some clock time to spare while the packets are in flight. - * (We assume that this is actually only executed once.) - */ - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = resultsp; - reply_msg.acpted_rply.ar_results.proc = xresults; -#ifdef FD_SETSIZE - FD_ZERO(&mask); - FD_SET(cu->cu_sock, &mask); -#else - mask = 1 << cu->cu_sock; -#endif /* def FD_SETSIZE */ - for (;;) { - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, - (int *)NULL, &(cu->cu_wait))) { - - case 0: - time_waited.tv_sec += cu->cu_wait.tv_sec; - time_waited.tv_usec += cu->cu_wait.tv_usec; - while (time_waited.tv_usec >= 1000000) { - time_waited.tv_sec++; - time_waited.tv_usec -= 1000000; - } - if ((time_waited.tv_sec < timeout.tv_sec) || - ((time_waited.tv_sec == timeout.tv_sec) && - (time_waited.tv_usec < timeout.tv_usec))) - goto send_again; - return (cu->cu_error.re_status = RPC_TIMEDOUT); - - /* - * buggy in other cases because time_waited is not being - * updated. - */ - case -1: - if (errno == EINTR) - continue; - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTRECV); - } - do { - fromlen = sizeof(struct sockaddr); - inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, - (int) cu->cu_recvsz, 0, - (struct sockaddr *)&from, &fromlen); - } while (inlen < 0 && errno == EINTR); - if (inlen < 0) { - if (errno == EWOULDBLOCK) - continue; - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTRECV); - } - if (inlen < sizeof(u_long)) - continue; - /* see if reply transaction id matches sent id */ - if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf))) - continue; - /* we now assume we have the proper reply */ - break; - } - - /* - * now decode and validate the response - */ - xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE); - ok = xdr_replymsg(&reply_xdrs, &reply_msg); - /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ - if (ok) { - _seterr_reply(&reply_msg, &(cu->cu_error)); - if (cu->cu_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(cl->cl_auth, - &reply_msg.acpted_rply.ar_verf)) { - cu->cu_error.re_status = RPC_AUTHERROR; - cu->cu_error.re_why = AUTH_INVALIDRESP; - } - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, - &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else { - /* maybe our credentials need to be refreshed ... */ - if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) { - nrefreshes--; - goto call_again; - } - } /* end of unsuccessful completion */ - } /* end of valid reply message */ - else { - cu->cu_error.re_status = RPC_CANTDECODERES; - } - return (cu->cu_error.re_status); -} - -static void -clntudp_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - *errp = cu->cu_error; -} - - -static bool_t -clntudp_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - register XDR *xdrs = &(cu->cu_outxdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clntudp_abort(/*h*/) - /*CLIENT *h;*/ -{ -} - -static bool_t -clntudp_control(cl, request, info) - CLIENT *cl; - int request; - char *info; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - switch (request) { - case CLSET_TIMEOUT: - cu->cu_total = *(struct timeval *)info; - break; - case CLGET_TIMEOUT: - *(struct timeval *)info = cu->cu_total; - break; - case CLSET_RETRY_TIMEOUT: - cu->cu_wait = *(struct timeval *)info; - break; - case CLGET_RETRY_TIMEOUT: - *(struct timeval *)info = cu->cu_wait; - break; - case CLGET_SERVER_ADDR: - *(struct sockaddr_in *)info = cu->cu_raddr; - break; - default: - return (FALSE); - } - return (TRUE); -} - -static void -clntudp_destroy(cl) - CLIENT *cl; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - if (cu->cu_closeit) { - (void)close(cu->cu_sock); - } - XDR_DESTROY(&(cu->cu_outxdrs)); - mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); - mem_free((caddr_t)cl, sizeof(CLIENT)); -} diff --git a/lib/librpc/rpc/get_myaddress.c b/lib/librpc/rpc/get_myaddress.c deleted file mode 100644 index 60b12272c4f5..000000000000 --- a/lib/librpc/rpc/get_myaddress.c +++ /dev/null @@ -1,96 +0,0 @@ -/* @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * get_myaddress.c - * - * Get client's IP address via ioctl. This avoids using the yellowpages. - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * don't use gethostbyname, which would invoke yellow pages - */ -get_myaddress(addr) - struct sockaddr_in *addr; -{ - int s; - char buf[BUFSIZ]; - struct ifconf ifc; - struct ifreq ifreq, *ifr; - int len, slop; - - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("get_myaddress: socket"); - exit(1); - } - ifc.ifc_len = sizeof (buf); - ifc.ifc_buf = buf; - if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { - perror("get_myaddress: ioctl (get interface configuration)"); - exit(1); - } - ifr = ifc.ifc_req; - for (len = ifc.ifc_len; len; len -= sizeof ifreq) { - ifreq = *ifr; - if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - perror("get_myaddress: ioctl"); - exit(1); - } - if ((ifreq.ifr_flags & IFF_UP) && - ifr->ifr_addr.sa_family == AF_INET) { - *addr = *((struct sockaddr_in *)&ifr->ifr_addr); - addr->sin_port = htons(PMAPPORT); - break; - } - /* - * Deal with variable length addresses - */ - slop = ifr->ifr_addr.sa_len - sizeof (struct sockaddr); - if (slop) { - ifr = (struct ifreq *) ((caddr_t)ifr + slop); - len -= slop; - } - ifr++; - } - (void) close(s); -} diff --git a/lib/librpc/rpc/getrpcent.c b/lib/librpc/rpc/getrpcent.c deleted file mode 100644 index e103546054f1..000000000000 --- a/lib/librpc/rpc/getrpcent.c +++ /dev/null @@ -1,235 +0,0 @@ -/* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -/* - * Internet version. - */ -struct rpcdata { - FILE *rpcf; - char *current; - int currentlen; - int stayopen; -#define MAXALIASES 35 - char *rpc_aliases[MAXALIASES]; - struct rpcent rpc; - char line[BUFSIZ+1]; - char *domain; -} *rpcdata; - -static struct rpcent *interpret(); -struct hostent *gethostent(); -char *inet_ntoa(); -char *index(); - -static char RPCDB[] = "/etc/rpc"; - -static struct rpcdata * -_rpcdata() -{ - register struct rpcdata *d = rpcdata; - - if (d == 0) { - d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); - rpcdata = d; - } - return (d); -} - -struct rpcent * -getrpcbynumber(number) - register int number; -{ - register struct rpcdata *d = _rpcdata(); - register struct rpcent *p; - int reason; - char adrstr[16], *val = NULL; - int vallen; - - if (d == 0) - return (0); - setrpcent(0); - while (p = getrpcent()) { - if (p->r_number == number) - break; - } - endrpcent(); - return (p); -} - -struct rpcent * -getrpcbyname(name) - char *name; -{ - struct rpcent *rpc; - char **rp; - - setrpcent(0); - while(rpc = getrpcent()) { - if (strcmp(rpc->r_name, name) == 0) - return (rpc); - for (rp = rpc->r_aliases; *rp != NULL; rp++) { - if (strcmp(*rp, name) == 0) - return (rpc); - } - } - endrpcent(); - return (NULL); -} - -setrpcent(f) - int f; -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; - if (d->rpcf == NULL) - d->rpcf = fopen(RPCDB, "r"); - else - rewind(d->rpcf); - if (d->current) - free(d->current); - d->current = NULL; - d->stayopen |= f; -} - -endrpcent() -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; - if (d->current && !d->stayopen) { - free(d->current); - d->current = NULL; - } - if (d->rpcf && !d->stayopen) { - fclose(d->rpcf); - d->rpcf = NULL; - } -} - -struct rpcent * -getrpcent() -{ - struct rpcent *hp; - int reason; - char *key = NULL, *val = NULL; - int keylen, vallen; - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return(NULL); - if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) - return (NULL); - if (fgets(d->line, BUFSIZ, d->rpcf) == NULL) - return (NULL); - return interpret(d->line, strlen(d->line)); -} - -static struct rpcent * -interpret(val, len) -{ - register struct rpcdata *d = _rpcdata(); - char *p; - register char *cp, **q; - - if (d == 0) - return; - strncpy(d->line, val, len); - p = d->line; - d->line[len] = '\n'; - if (*p == '#') - return (getrpcent()); - cp = index(p, '#'); - if (cp == NULL) - { - cp = index(p, '\n'); - if (cp == NULL) - return (getrpcent()); - } - *cp = '\0'; - cp = index(p, ' '); - if (cp == NULL) - { - cp = index(p, '\t'); - if (cp == NULL) - return (getrpcent()); - } - *cp++ = '\0'; - /* THIS STUFF IS INTERNET SPECIFIC */ - d->rpc.r_name = d->line; - while (*cp == ' ' || *cp == '\t') - cp++; - d->rpc.r_number = atoi(cp); - q = d->rpc.r_aliases = d->rpc_aliases; - cp = index(p, ' '); - if (cp != NULL) - *cp++ = '\0'; - else - { - cp = index(p, '\t'); - if (cp != NULL) - *cp++ = '\0'; - } - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &(d->rpc_aliases[MAXALIASES - 1])) - *q++ = cp; - cp = index(p, ' '); - if (cp != NULL) - *cp++ = '\0'; - else - { - cp = index(p, '\t'); - if (cp != NULL) - *cp++ = '\0'; - } - } - *q = NULL; - return (&d->rpc); -} diff --git a/lib/librpc/rpc/getrpcport.c b/lib/librpc/rpc/getrpcport.c deleted file mode 100644 index 9b13bac6b010..000000000000 --- a/lib/librpc/rpc/getrpcport.c +++ /dev/null @@ -1,55 +0,0 @@ -/* @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -getrpcport(host, prognum, versnum, proto) - char *host; -{ - struct sockaddr_in addr; - struct hostent *hp; - - if ((hp = gethostbyname(host)) == NULL) - return (0); - bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length); - addr.sin_family = AF_INET; - addr.sin_port = 0; - return (pmap_getport(&addr, prognum, versnum, proto)); -} diff --git a/lib/librpc/rpc/pmap_clnt.c b/lib/librpc/rpc/pmap_clnt.c deleted file mode 100644 index 09220e77b1fe..000000000000 --- a/lib/librpc/rpc/pmap_clnt.c +++ /dev/null @@ -1,115 +0,0 @@ -/* @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_clnt.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; - -void clnt_perror(); - - -/* - * Set a mapping between program,version and port. - * Calls the pmap service remotely to do the mapping. - */ -bool_t -pmap_set(program, version, protocol, port) - u_long program; - u_long version; - int protocol; - u_short port; -{ - struct sockaddr_in myaddress; - int socket = -1; - register CLIENT *client; - struct pmap parms; - bool_t rslt; - - get_myaddress(&myaddress); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = port; - if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout) != RPC_SUCCESS) { - clnt_perror(client, "Cannot register service"); - return (FALSE); - } - CLNT_DESTROY(client); - (void)close(socket); - return (rslt); -} - -/* - * Remove the mapping between program,version and port. - * Calls the pmap service remotely to do the un-mapping. - */ -bool_t -pmap_unset(program, version) - u_long program; - u_long version; -{ - struct sockaddr_in myaddress; - int socket = -1; - register CLIENT *client; - struct pmap parms; - bool_t rslt; - - get_myaddress(&myaddress); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_port = parms.pm_prot = 0; - CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout); - CLNT_DESTROY(client); - (void)close(socket); - return (rslt); -} diff --git a/lib/librpc/rpc/pmap_clnt.h b/lib/librpc/rpc/pmap_clnt.h deleted file mode 100644 index d2ea2a88e9e5..000000000000 --- a/lib/librpc/rpc/pmap_clnt.h +++ /dev/null @@ -1,65 +0,0 @@ -/* @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * pmap_clnt.h - * Supplies C routines to get to portmap services. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * Usage: - * success = pmap_set(program, version, protocol, port); - * success = pmap_unset(program, version); - * port = pmap_getport(address, program, version, protocol); - * head = pmap_getmaps(address); - * clnt_stat = pmap_rmtcall(address, program, version, procedure, - * xdrargs, argsp, xdrres, resp, tout, port_ptr) - * (works for udp only.) - * clnt_stat = clnt_broadcast(program, version, procedure, - * xdrargs, argsp, xdrres, resp, eachresult) - * (like pmap_rmtcall, except the call is broadcasted to all - * locally connected nets. For each valid response received, - * the procedure eachresult is called. Its form is: - * done = eachresult(resp, raddr) - * bool_t done; - * caddr_t resp; - * struct sockaddr_in raddr; - * where resp points to the results of the call and raddr is the - * address if the responder to the broadcast. - */ - -extern bool_t pmap_set(); -extern bool_t pmap_unset(); -extern struct pmaplist *pmap_getmaps(); -enum clnt_stat pmap_rmtcall(); -enum clnt_stat clnt_broadcast(); -extern u_short pmap_getport(); diff --git a/lib/librpc/rpc/pmap_getmaps.c b/lib/librpc/rpc/pmap_getmaps.c deleted file mode 100644 index e4a9c49361cf..000000000000 --- a/lib/librpc/rpc/pmap_getmaps.c +++ /dev/null @@ -1,84 +0,0 @@ -/* @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_getmap.c - * Client interface to pmap rpc service. - * contains pmap_getmaps, which is only tcp service involved - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define NAMELEN 255 -#define MAX_BROADCAST_SIZE 1400 - -extern int errno; - -/* - * Get a copy of the current port maps. - * Calls the pmap service remotely to do get the maps. - */ -struct pmaplist * -pmap_getmaps(address) - struct sockaddr_in *address; -{ - struct pmaplist *head = (struct pmaplist *)NULL; - int socket = -1; - struct timeval minutetimeout; - register CLIENT *client; - - minutetimeout.tv_sec = 60; - minutetimeout.tv_usec = 0; - address->sin_port = htons(PMAPPORT); - client = clnttcp_create(address, PMAPPROG, - PMAPVERS, &socket, 50, 500); - if (client != (CLIENT *)NULL) { - if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist, - &head, minutetimeout) != RPC_SUCCESS) { - clnt_perror(client, "pmap_getmaps rpc problem"); - } - CLNT_DESTROY(client); - } - (void)close(socket); - address->sin_port = 0; - return (head); -} diff --git a/lib/librpc/rpc/pmap_getport.c b/lib/librpc/rpc/pmap_getport.c deleted file mode 100644 index 77b9cf743ab1..000000000000 --- a/lib/librpc/rpc/pmap_getport.c +++ /dev/null @@ -1,87 +0,0 @@ -/* @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_getport.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; - -/* - * Find the mapped port for program,version. - * Calls the pmap service remotely to do the lookup. - * Returns 0 if no map exists. - */ -u_short -pmap_getport(address, program, version, protocol) - struct sockaddr_in *address; - u_long program; - u_long version; - u_int protocol; -{ - u_short port = 0; - int socket = -1; - register CLIENT *client; - struct pmap parms; - - address->sin_port = htons(PMAPPORT); - client = clntudp_bufcreate(address, PMAPPROG, - PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client != (CLIENT *)NULL) { - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = 0; /* not needed or used */ - if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms, - xdr_u_short, &port, tottimeout) != RPC_SUCCESS){ - rpc_createerr.cf_stat = RPC_PMAPFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - } else if (port == 0) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - } - CLNT_DESTROY(client); - } - (void)close(socket); - address->sin_port = 0; - return (port); -} diff --git a/lib/librpc/rpc/pmap_prot.c b/lib/librpc/rpc/pmap_prot.c deleted file mode 100644 index 643c2ff6a29c..000000000000 --- a/lib/librpc/rpc/pmap_prot.c +++ /dev/null @@ -1,57 +0,0 @@ -/* @(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_prot.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - - -bool_t -xdr_pmap(xdrs, regs) - XDR *xdrs; - struct pmap *regs; -{ - - if (xdr_u_long(xdrs, ®s->pm_prog) && - xdr_u_long(xdrs, ®s->pm_vers) && - xdr_u_long(xdrs, ®s->pm_prot)) - return (xdr_u_long(xdrs, ®s->pm_port)); - return (FALSE); -} diff --git a/lib/librpc/rpc/pmap_prot.h b/lib/librpc/rpc/pmap_prot.h deleted file mode 100644 index ccf7a77b4153..000000000000 --- a/lib/librpc/rpc/pmap_prot.h +++ /dev/null @@ -1,94 +0,0 @@ -/* @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * pmap_prot.h - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The following procedures are supported by the protocol: - * - * PMAPPROC_NULL() returns () - * takes nothing, returns nothing - * - * PMAPPROC_SET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Registers the tuple - * [prog, vers, prot, port]. - * - * PMAPPROC_UNSET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Un-registers pair - * [prog, vers]. prot and port are ignored. - * - * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). - * 0 is failure. Otherwise returns the port number where the pair - * [prog, vers] is registered. It may lie! - * - * PMAPPROC_DUMP() RETURNS (struct pmaplist *) - * - * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) - * RETURNS (port, string<>); - * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); - * Calls the procedure on the local machine. If it is not registered, - * this procedure is quite; ie it does not return error information!!! - * This procedure only is supported on rpc/udp and calls via - * rpc/udp. This routine only passes null authentication parameters. - * This file has no interface to xdr routines for PMAPPROC_CALLIT. - * - * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. - */ - -#define PMAPPORT ((u_short)111) -#define PMAPPROG ((u_long)100000) -#define PMAPVERS ((u_long)2) -#define PMAPVERS_PROTO ((u_long)2) -#define PMAPVERS_ORIG ((u_long)1) -#define PMAPPROC_NULL ((u_long)0) -#define PMAPPROC_SET ((u_long)1) -#define PMAPPROC_UNSET ((u_long)2) -#define PMAPPROC_GETPORT ((u_long)3) -#define PMAPPROC_DUMP ((u_long)4) -#define PMAPPROC_CALLIT ((u_long)5) - -struct pmap { - long unsigned pm_prog; - long unsigned pm_vers; - long unsigned pm_prot; - long unsigned pm_port; -}; - -extern bool_t xdr_pmap(); - -struct pmaplist { - struct pmap pml_map; - struct pmaplist *pml_next; -}; - -extern bool_t xdr_pmaplist(); diff --git a/lib/librpc/rpc/pmap_prot2.c b/lib/librpc/rpc/pmap_prot2.c deleted file mode 100644 index e2a8214d48ad..000000000000 --- a/lib/librpc/rpc/pmap_prot2.c +++ /dev/null @@ -1,116 +0,0 @@ -/* @(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_prot2.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - - -/* - * What is going on with linked lists? (!) - * First recall the link list declaration from pmap_prot.h: - * - * struct pmaplist { - * struct pmap pml_map; - * struct pmaplist *pml_map; - * }; - * - * Compare that declaration with a corresponding xdr declaration that - * is (a) pointer-less, and (b) recursive: - * - * typedef union switch (bool_t) { - * - * case TRUE: struct { - * struct pmap; - * pmaplist_t foo; - * }; - * - * case FALSE: struct {}; - * } pmaplist_t; - * - * Notice that the xdr declaration has no nxt pointer while - * the C declaration has no bool_t variable. The bool_t can be - * interpreted as ``more data follows me''; if FALSE then nothing - * follows this bool_t; if TRUE then the bool_t is followed by - * an actual struct pmap, and then (recursively) by the - * xdr union, pamplist_t. - * - * This could be implemented via the xdr_union primitive, though this - * would cause a one recursive call per element in the list. Rather than do - * that we can ``unwind'' the recursion - * into a while loop and do the union arms in-place. - * - * The head of the list is what the C programmer wishes to past around - * the net, yet is the data that the pointer points to which is interesting; - * this sounds like a job for xdr_reference! - */ -bool_t -xdr_pmaplist(xdrs, rp) - register XDR *xdrs; - register struct pmaplist **rp; -{ - /* - * more_elements is pre-computed in case the direction is - * XDR_ENCODE or XDR_FREE. more_elements is overwritten by - * xdr_bool when the direction is XDR_DECODE. - */ - bool_t more_elements; - register int freeing = (xdrs->x_op == XDR_FREE); - register struct pmaplist **next; - - while (TRUE) { - more_elements = (bool_t)(*rp != NULL); - if (! xdr_bool(xdrs, &more_elements)) - return (FALSE); - if (! more_elements) - return (TRUE); /* we are done */ - /* - * the unfortunate side effect of non-recursion is that in - * the case of freeing we must remember the next object - * before we free the current object ... - */ - if (freeing) - next = &((*rp)->pml_next); - if (! xdr_reference(xdrs, (caddr_t *)rp, - (u_int)sizeof(struct pmaplist), xdr_pmap)) - return (FALSE); - rp = (freeing) ? next : &((*rp)->pml_next); - } -} diff --git a/lib/librpc/rpc/pmap_rmt.c b/lib/librpc/rpc/pmap_rmt.c deleted file mode 100644 index 8945b2fb01b8..000000000000 --- a/lib/librpc/rpc/pmap_rmt.c +++ /dev/null @@ -1,395 +0,0 @@ -/* @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; -#endif - -/* - * pmap_rmt.c - * Client interface to pmap rpc service. - * remote call and broadcast service - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define MAX_BROADCAST_SIZE 1400 - -extern int errno; -static struct timeval timeout = { 3, 0 }; - - -/* - * pmapper remote-call-service interface. - * This routine is used to call the pmapper remote call service - * which will look up a service program in the port maps, and then - * remotely call that routine with the given parameters. This allows - * programs to do a lookup and call in one step. -*/ -enum clnt_stat -pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) - struct sockaddr_in *addr; - u_long prog, vers, proc; - xdrproc_t xdrargs, xdrres; - caddr_t argsp, resp; - struct timeval tout; - u_long *port_ptr; -{ - int socket = -1; - register CLIENT *client; - struct rmtcallargs a; - struct rmtcallres r; - enum clnt_stat stat; - - addr->sin_port = htons(PMAPPORT); - client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); - if (client != (CLIENT *)NULL) { - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.args_ptr = argsp; - a.xdr_args = xdrargs; - r.port_ptr = port_ptr; - r.results_ptr = resp; - r.xdr_results = xdrres; - stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a, - xdr_rmtcallres, &r, tout); - CLNT_DESTROY(client); - } else { - stat = RPC_FAILED; - } - (void)close(socket); - addr->sin_port = 0; - return (stat); -} - - -/* - * XDR remote call arguments - * written for XDR_ENCODE direction only - */ -bool_t -xdr_rmtcall_args(xdrs, cap) - register XDR *xdrs; - register struct rmtcallargs *cap; -{ - u_int lenposition, argposition, position; - - if (xdr_u_long(xdrs, &(cap->prog)) && - xdr_u_long(xdrs, &(cap->vers)) && - xdr_u_long(xdrs, &(cap->proc))) { - lenposition = XDR_GETPOS(xdrs); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - argposition = XDR_GETPOS(xdrs); - if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) - return (FALSE); - position = XDR_GETPOS(xdrs); - cap->arglen = (u_long)position - (u_long)argposition; - XDR_SETPOS(xdrs, lenposition); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - XDR_SETPOS(xdrs, position); - return (TRUE); - } - return (FALSE); -} - -/* - * XDR remote call results - * written for XDR_DECODE direction only - */ -bool_t -xdr_rmtcallres(xdrs, crp) - register XDR *xdrs; - register struct rmtcallres *crp; -{ - caddr_t port_ptr; - - port_ptr = (caddr_t)crp->port_ptr; - if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), - xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { - crp->port_ptr = (u_long *)port_ptr; - return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); - } - return (FALSE); -} - - -/* - * The following is kludged-up support for simple rpc broadcasts. - * Someday a large, complicated system will replace these trivial - * routines which only support udp/ip . - */ - -static int -getbroadcastnets(addrs, sock, buf) - struct in_addr *addrs; - int sock; /* any valid socket will do */ - char *buf; /* why allocxate more when we can use existing... */ -{ - struct ifconf ifc; - struct ifreq ifreq, *ifr; - struct sockaddr_in *sin; - char *cp, *cplim; - int n, i = 0; - - ifc.ifc_len = UDPMSGSIZE; - ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { - perror("broadcast: ioctl (get interface configuration)"); - return (0); - } -#define max(a, b) (a > b ? a : b) -#define size(p) max((p).sa_len, sizeof(p)) - cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ - for (cp = buf; cp < cplim; - cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) { - ifr = (struct ifreq *)cp; - if (ifr->ifr_addr.sa_family != AF_INET) - continue; - ifreq = *ifr; - if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - perror("broadcast: ioctl (get interface flags)"); - continue; - } - if ((ifreq.ifr_flags & IFF_BROADCAST) && - (ifreq.ifr_flags & IFF_UP)) { - sin = (struct sockaddr_in *)&ifr->ifr_addr; -#ifdef SIOCGIFBRDADDR /* 4.3BSD */ - if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { - addrs[i++] = - inet_makeaddr(inet_netof(sin->sin_addr), - INADDR_ANY); - } else { - addrs[i++] = ((struct sockaddr_in*) - &ifreq.ifr_addr)->sin_addr; - } -#else /* 4.2 BSD */ - addrs[i++] = inet_makeaddr(inet_netof(sin->sin_addr), - INADDR_ANY); -#endif - } - } - return (i); -} - -typedef bool_t (*resultproc_t)(); - -enum clnt_stat -clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) - u_long prog; /* program number */ - u_long vers; /* version number */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ -{ - enum clnt_stat stat; - AUTH *unix_auth = authunix_create_default(); - XDR xdr_stream; - register XDR *xdrs = &xdr_stream; - int outlen, inlen, fromlen, nets; - register int sock; - int on = 1; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; -#else - int readfds; - register int mask; -#endif /* def FD_SETSIZE */ - register int i; - bool_t done = FALSE; - register u_long xid; - u_long port; - struct in_addr addrs[20]; - struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ - struct rmtcallargs a; - struct rmtcallres r; - struct rpc_msg msg; - struct timeval t; - char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; - - /* - * initialization: create a socket, a broadcast address, and - * preserialize the arguments into a send buffer. - */ - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("Cannot create socket for broadcast rpc"); - stat = RPC_CANTSEND; - goto done_broad; - } -#ifdef SO_BROADCAST - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { - perror("Cannot set socket option SO_BROADCAST"); - stat = RPC_CANTSEND; - goto done_broad; - } -#endif /* def SO_BROADCAST */ -#ifdef FD_SETSIZE - FD_ZERO(&mask); - FD_SET(sock, &mask); -#else - mask = (1 << sock); -#endif /* def FD_SETSIZE */ - nets = getbroadcastnets(addrs, sock, inbuf); - bzero((char *)&baddr, sizeof (baddr)); - baddr.sin_family = AF_INET; - baddr.sin_port = htons(PMAPPORT); - baddr.sin_addr.s_addr = htonl(INADDR_ANY); -/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ - (void)gettimeofday(&t, (struct timezone *)0); - msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec; - t.tv_usec = 0; - msg.rm_direction = CALL; - msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - msg.rm_call.cb_prog = PMAPPROG; - msg.rm_call.cb_vers = PMAPVERS; - msg.rm_call.cb_proc = PMAPPROC_CALLIT; - msg.rm_call.cb_cred = unix_auth->ah_cred; - msg.rm_call.cb_verf = unix_auth->ah_verf; - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.xdr_args = xargs; - a.args_ptr = argsp; - r.port_ptr = &port; - r.xdr_results = xresults; - r.results_ptr = resultsp; - xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE); - if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) { - stat = RPC_CANTENCODEARGS; - goto done_broad; - } - outlen = (int)xdr_getpos(xdrs); - xdr_destroy(xdrs); - /* - * Basic loop: broadcast a packet and wait a while for response(s). - * The response timeout grows larger per iteration. - */ - for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { - for (i = 0; i < nets; i++) { - baddr.sin_addr = addrs[i]; - if (sendto(sock, outbuf, outlen, 0, - (struct sockaddr *)&baddr, - sizeof (struct sockaddr)) != outlen) { - perror("Cannot send broadcast packet"); - stat = RPC_CANTSEND; - goto done_broad; - } - } - if (eachresult == NULL) { - stat = RPC_SUCCESS; - goto done_broad; - } - recv_again: - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = (caddr_t)&r; - msg.acpted_rply.ar_results.proc = xdr_rmtcallres; - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, - (int *)NULL, &t)) { - - case 0: /* timed out */ - stat = RPC_TIMEDOUT; - continue; - - case -1: /* some kind of error */ - if (errno == EINTR) - goto recv_again; - perror("Broadcast select problem"); - stat = RPC_CANTRECV; - goto done_broad; - - } /* end of select results switch */ - try_again: - fromlen = sizeof(struct sockaddr); - inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, - (struct sockaddr *)&raddr, &fromlen); - if (inlen < 0) { - if (errno == EINTR) - goto try_again; - perror("Cannot receive reply to broadcast"); - stat = RPC_CANTRECV; - goto done_broad; - } - if (inlen < sizeof(u_long)) - goto recv_again; - /* - * see if reply transaction id matches sent id. - * If so, decode the results. - */ - xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); - if (xdr_replymsg(xdrs, &msg)) { - if ((msg.rm_xid == xid) && - (msg.rm_reply.rp_stat == MSG_ACCEPTED) && - (msg.acpted_rply.ar_stat == SUCCESS)) { - raddr.sin_port = htons((u_short)port); - done = (*eachresult)(resultsp, &raddr); - } - /* otherwise, we just ignore the errors ... */ - } else { -#ifdef notdef - /* some kind of deserialization problem ... */ - if (msg.rm_xid == xid) - fprintf(stderr, "Broadcast deserialization problem"); - /* otherwise, just random garbage */ -#endif - } - xdrs->x_op = XDR_FREE; - msg.acpted_rply.ar_results.proc = xdr_void; - (void)xdr_replymsg(xdrs, &msg); - (void)(*xresults)(xdrs, resultsp); - xdr_destroy(xdrs); - if (done) { - stat = RPC_SUCCESS; - goto done_broad; - } else { - goto recv_again; - } - } -done_broad: - (void)close(sock); - AUTH_DESTROY(unix_auth); - return (stat); -} - diff --git a/lib/librpc/rpc/pmap_rmt.h b/lib/librpc/rpc/pmap_rmt.h deleted file mode 100644 index ee68cebec221..000000000000 --- a/lib/librpc/rpc/pmap_rmt.h +++ /dev/null @@ -1,53 +0,0 @@ -/* @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Structures and XDR routines for parameters to and replies from - * the portmapper remote-call-service. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -struct rmtcallargs { - u_long prog, vers, proc, arglen; - caddr_t args_ptr; - xdrproc_t xdr_args; -}; - -bool_t xdr_rmtcall_args(); - -struct rmtcallres { - u_long *port_ptr; - u_long resultslen; - caddr_t results_ptr; - xdrproc_t xdr_results; -}; - -bool_t xdr_rmtcallres(); diff --git a/lib/librpc/rpc/rpc.h b/lib/librpc/rpc/rpc.h deleted file mode 100644 index e46e1ff0f5ff..000000000000 --- a/lib/librpc/rpc/rpc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC; from 1.9 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * rpc.h, Just includes the billions of rpc header files necessary to - * do remote procedure calling. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#ifndef __RPC_HEADER__ -#define __RPC_HEADER__ - -#include /* some typedefs */ -#include - -/* external data representation interfaces */ -#include /* generic (de)serializer */ - -/* Client side only authentication */ -#include /* generic authenticator (client side) */ - -/* Client side (mostly) remote procedure call */ -#include /* generic rpc stuff */ - -/* semi-private protocol headers */ -#include /* protocol for rpc messages */ -#include /* protocol for unix style cred */ -/* - * Uncomment-out the next line if you are building the rpc library with - * DES Authentication (see the README file in the secure_rpc/ directory). - */ -/*#include * protocol for des style cred */ - -/* Server side only remote procedure callee */ -#include /* service manager and multiplexer */ -#include /* service side authenticator */ - -/* - * COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON - * A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will - * already have the structures defined by included in . - */ -/* routines for parsing /etc/rpc */ - -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; - -struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent(); - -#endif /* ndef __RPC_HEADER__ */ diff --git a/lib/librpc/rpc/rpc_callmsg.c b/lib/librpc/rpc/rpc_callmsg.c deleted file mode 100644 index d9d815a6fba0..000000000000 --- a/lib/librpc/rpc/rpc_callmsg.c +++ /dev/null @@ -1,190 +0,0 @@ -/* @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * rpc_callmsg.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ - -#include - -#include - -/* - * XDR a call message - */ -bool_t -xdr_callmsg(xdrs, cmsg) - register XDR *xdrs; - register struct rpc_msg *cmsg; -{ - register long *buf; - register struct opaque_auth *oa; - - if (xdrs->x_op == XDR_ENCODE) { - if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_cred.oa_length) - + 2 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_verf.oa_length)); - if (buf != NULL) { - IXDR_PUT_LONG(buf, cmsg->rm_xid); - IXDR_PUT_ENUM(buf, cmsg->rm_direction); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog); - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers); - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc); - oa = &cmsg->rm_call.cb_cred; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_LONG(buf, oa->oa_length); - if (oa->oa_length) { - bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); - buf += RNDUP(oa->oa_length) / sizeof (long); - } - oa = &cmsg->rm_call.cb_verf; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_LONG(buf, oa->oa_length); - if (oa->oa_length) { - bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / sizeof (long); - */ - } - return (TRUE); - } - } - if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); - if (buf != NULL) { - cmsg->rm_xid = IXDR_GET_LONG(buf); - cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf); - cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf); - cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf); - oa = &cmsg->rm_call.cb_cred; - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = IXDR_GET_LONG(buf); - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - bcopy((caddr_t)buf, oa->oa_base, - oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / - sizeof (long); - */ - } - } - oa = &cmsg->rm_call.cb_verf; - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || - xdr_u_int(xdrs, &oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = IXDR_GET_LONG(buf); - } - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - bcopy((caddr_t)buf, oa->oa_base, - oa->oa_length); - /* no real need... - buf += RNDUP(oa->oa_length) / - sizeof (long); - */ - } - } - return (TRUE); - } - } - if ( - xdr_u_long(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - (cmsg->rm_direction == CALL) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) && - xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) ) - return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf))); - return (FALSE); -} - diff --git a/lib/librpc/rpc/rpc_commondata.c b/lib/librpc/rpc/rpc_commondata.c deleted file mode 100644 index 75cead0875b4..000000000000 --- a/lib/librpc/rpc/rpc_commondata.c +++ /dev/null @@ -1,41 +0,0 @@ -/* @(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#include -/* - * This file should only contain common data (global data) that is exported - * by public interfaces - */ -struct opaque_auth _null_auth; -#ifdef FD_SETSIZE -fd_set svc_fdset; -#else -int svc_fds; -#endif /* def FD_SETSIZE */ -struct rpc_createerr rpc_createerr; diff --git a/lib/librpc/rpc/rpc_dtablesize.c b/lib/librpc/rpc/rpc_dtablesize.c deleted file mode 100644 index a8488172e4e4..000000000000 --- a/lib/librpc/rpc/rpc_dtablesize.c +++ /dev/null @@ -1,46 +0,0 @@ -/* @(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro"; -#endif - -/* - * Cache the result of getdtablesize(), so we don't have to do an - * expensive system call every time. - */ -_rpc_dtablesize() -{ - static int size; - - if (size == 0) { - size = getdtablesize(); - } - return (size); -} diff --git a/lib/librpc/rpc/rpc_msg.h b/lib/librpc/rpc/rpc_msg.h deleted file mode 100644 index b78872b6a8d6..000000000000 --- a/lib/librpc/rpc/rpc_msg.h +++ /dev/null @@ -1,187 +0,0 @@ -/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ - -/* - * rpc_msg.h - * rpc message definition - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#define RPC_MSG_VERSION ((u_long) 2) -#define RPC_SERVICE_PORT ((u_short) 2048) - -/* - * Bottom up definition of an rpc message. - * NOTE: call and reply use the same overall stuct but - * different parts of unions within it. - */ - -enum msg_type { - CALL=0, - REPLY=1 -}; - -enum reply_stat { - MSG_ACCEPTED=0, - MSG_DENIED=1 -}; - -enum accept_stat { - SUCCESS=0, - PROG_UNAVAIL=1, - PROG_MISMATCH=2, - PROC_UNAVAIL=3, - GARBAGE_ARGS=4, - SYSTEM_ERR=5 -}; - -enum reject_stat { - RPC_MISMATCH=0, - AUTH_ERROR=1 -}; - -/* - * Reply part of an rpc exchange - */ - -/* - * Reply to an rpc request that was accepted by the server. - * Note: there could be an error even though the request was - * accepted. - */ -struct accepted_reply { - struct opaque_auth ar_verf; - enum accept_stat ar_stat; - union { - struct { - u_long low; - u_long high; - } AR_versions; - struct { - caddr_t where; - xdrproc_t proc; - } AR_results; - /* and many other null cases */ - } ru; -#define ar_results ru.AR_results -#define ar_vers ru.AR_versions -}; - -/* - * Reply to an rpc request that was rejected by the server. - */ -struct rejected_reply { - enum reject_stat rj_stat; - union { - struct { - u_long low; - u_long high; - } RJ_versions; - enum auth_stat RJ_why; /* why authentication did not work */ - } ru; -#define rj_vers ru.RJ_versions -#define rj_why ru.RJ_why -}; - -/* - * Body of a reply to an rpc request. - */ -struct reply_body { - enum reply_stat rp_stat; - union { - struct accepted_reply RP_ar; - struct rejected_reply RP_dr; - } ru; -#define rp_acpt ru.RP_ar -#define rp_rjct ru.RP_dr -}; - -/* - * Body of an rpc request call. - */ -struct call_body { - u_long cb_rpcvers; /* must be equal to two */ - u_long cb_prog; - u_long cb_vers; - u_long cb_proc; - struct opaque_auth cb_cred; - struct opaque_auth cb_verf; /* protocol specific - provided by client */ -}; - -/* - * The rpc message - */ -struct rpc_msg { - u_long rm_xid; - enum msg_type rm_direction; - union { - struct call_body RM_cmb; - struct reply_body RM_rmb; - } ru; -#define rm_call ru.RM_cmb -#define rm_reply ru.RM_rmb -}; -#define acpted_rply ru.RM_rmb.ru.RP_ar -#define rjcted_rply ru.RM_rmb.ru.RP_dr - - -/* - * XDR routine to handle a rpc message. - * xdr_callmsg(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callmsg(); - -/* - * XDR routine to pre-serialize the static part of a rpc message. - * xdr_callhdr(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callhdr(); - -/* - * XDR routine to handle a rpc reply. - * xdr_replymsg(xdrs, rmsg) - * XDR *xdrs; - * struct rpc_msg *rmsg; - */ -extern bool_t xdr_replymsg(); - -/* - * Fills in the error part of a reply message. - * _seterr_reply(msg, error) - * struct rpc_msg *msg; - * struct rpc_err *error; - */ -extern void _seterr_reply(); diff --git a/lib/librpc/rpc/rpc_prot.c b/lib/librpc/rpc/rpc_prot.c deleted file mode 100644 index 4b1319ad560f..000000000000 --- a/lib/librpc/rpc/rpc_prot.c +++ /dev/null @@ -1,289 +0,0 @@ -/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * rpc_prot.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements the rpc message definition, - * its serializer and some common rpc utility routines. - * The routines are meant for various implementations of rpc - - * they are NOT for the rpc client or rpc service implementations! - * Because authentication stuff is easy and is part of rpc, the opaque - * routines are also in this program. - */ - -#include - -#include - -/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ - -struct opaque_auth _null_auth; - -/* - * XDR an opaque authentication struct - * (see auth.h) - */ -bool_t -xdr_opaque_auth(xdrs, ap) - register XDR *xdrs; - register struct opaque_auth *ap; -{ - - if (xdr_enum(xdrs, &(ap->oa_flavor))) - return (xdr_bytes(xdrs, &ap->oa_base, - &ap->oa_length, MAX_AUTH_BYTES)); - return (FALSE); -} - -/* - * XDR a DES block - */ -bool_t -xdr_des_block(xdrs, blkp) - register XDR *xdrs; - register des_block *blkp; -{ - return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block))); -} - -/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ - -/* - * XDR the MSG_ACCEPTED part of a reply message union - */ -bool_t -xdr_accepted_reply(xdrs, ar) - register XDR *xdrs; - register struct accepted_reply *ar; -{ - - /* personalized union, rather than calling xdr_union */ - if (! xdr_opaque_auth(xdrs, &(ar->ar_verf))) - return (FALSE); - if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat))) - return (FALSE); - switch (ar->ar_stat) { - - case SUCCESS: - return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where)); - - case PROG_MISMATCH: - if (! xdr_u_long(xdrs, &(ar->ar_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(ar->ar_vers.high))); - } - return (TRUE); /* TRUE => open ended set of problems */ -} - -/* - * XDR the MSG_DENIED part of a reply message union - */ -bool_t -xdr_rejected_reply(xdrs, rr) - register XDR *xdrs; - register struct rejected_reply *rr; -{ - - /* personalized union, rather than calling xdr_union */ - if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat))) - return (FALSE); - switch (rr->rj_stat) { - - case RPC_MISMATCH: - if (! xdr_u_long(xdrs, &(rr->rj_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(rr->rj_vers.high))); - - case AUTH_ERROR: - return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why))); - } - return (FALSE); -} - -static struct xdr_discrim reply_dscrm[3] = { - { (int)MSG_ACCEPTED, xdr_accepted_reply }, - { (int)MSG_DENIED, xdr_rejected_reply }, - { __dontcare__, NULL_xdrproc_t } }; - -/* - * XDR a reply message - */ -bool_t -xdr_replymsg(xdrs, rmsg) - register XDR *xdrs; - register struct rpc_msg *rmsg; -{ - if ( - xdr_u_long(xdrs, &(rmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) && - (rmsg->rm_direction == REPLY) ) - return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat), - (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t)); - return (FALSE); -} - - -/* - * Serializes the "static part" of a call message header. - * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers. - * The rm_xid is not really static, but the user can easily munge on the fly. - */ -bool_t -xdr_callhdr(xdrs, cmsg) - register XDR *xdrs; - register struct rpc_msg *cmsg; -{ - - cmsg->rm_direction = CALL; - cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; - if ( - (xdrs->x_op == XDR_ENCODE) && - xdr_u_long(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) ) - return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); - return (FALSE); -} - -/* ************************** Client utility routine ************* */ - -static void -accepted(acpt_stat, error) - register enum accept_stat acpt_stat; - register struct rpc_err *error; -{ - - switch (acpt_stat) { - - case PROG_UNAVAIL: - error->re_status = RPC_PROGUNAVAIL; - return; - - case PROG_MISMATCH: - error->re_status = RPC_PROGVERSMISMATCH; - return; - - case PROC_UNAVAIL: - error->re_status = RPC_PROCUNAVAIL; - return; - - case GARBAGE_ARGS: - error->re_status = RPC_CANTDECODEARGS; - return; - - case SYSTEM_ERR: - error->re_status = RPC_SYSTEMERROR; - return; - - case SUCCESS: - error->re_status = RPC_SUCCESS; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)MSG_ACCEPTED; - error->re_lb.s2 = (long)acpt_stat; -} - -static void -rejected(rjct_stat, error) - register enum reject_stat rjct_stat; - register struct rpc_err *error; -{ - - switch (rjct_stat) { - - case RPC_VERSMISMATCH: - error->re_status = RPC_VERSMISMATCH; - return; - - case AUTH_ERROR: - error->re_status = RPC_AUTHERROR; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)MSG_DENIED; - error->re_lb.s2 = (long)rjct_stat; -} - -/* - * given a reply message, fills in the error - */ -void -_seterr_reply(msg, error) - register struct rpc_msg *msg; - register struct rpc_err *error; -{ - - /* optimized for normal, SUCCESSful case */ - switch (msg->rm_reply.rp_stat) { - - case MSG_ACCEPTED: - if (msg->acpted_rply.ar_stat == SUCCESS) { - error->re_status = RPC_SUCCESS; - return; - }; - accepted(msg->acpted_rply.ar_stat, error); - break; - - case MSG_DENIED: - rejected(msg->rjcted_rply.rj_stat, error); - break; - - default: - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)(msg->rm_reply.rp_stat); - break; - } - switch (error->re_status) { - - case RPC_VERSMISMATCH: - error->re_vers.low = msg->rjcted_rply.rj_vers.low; - error->re_vers.high = msg->rjcted_rply.rj_vers.high; - break; - - case RPC_AUTHERROR: - error->re_why = msg->rjcted_rply.rj_why; - break; - - case RPC_PROGVERSMISMATCH: - error->re_vers.low = msg->acpted_rply.ar_vers.low; - error->re_vers.high = msg->acpted_rply.ar_vers.high; - break; - } -} diff --git a/lib/librpc/rpc/svc.c b/lib/librpc/rpc/svc.c deleted file mode 100644 index 3327ee5bdd6c..000000000000 --- a/lib/librpc/rpc/svc.c +++ /dev/null @@ -1,479 +0,0 @@ -/* @(#)svc.c 2.4 88/08/11 4.0 RPCSRC; from 1.44 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro"; -#endif - -/* - * svc.c, Server-side remote procedure call interface. - * - * There are two sets of procedures here. The xprt routines are - * for handling transport handles. The svc routines handle the - * list of service routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -extern int errno; - -#ifdef FD_SETSIZE -static SVCXPRT **xports; -#else -#define NOFILE 32 - -static SVCXPRT *xports[NOFILE]; -#endif /* def FD_SETSIZE */ - -#define NULL_SVC ((struct svc_callout *)0) -#define RQCRED_SIZE 400 /* this size is excessive */ - -/* - * The services list - * Each entry represents a set of procedures (an rpc program). - * The dispatch routine takes request structs and runs the - * apropriate procedure. - */ -static struct svc_callout { - struct svc_callout *sc_next; - u_long sc_prog; - u_long sc_vers; - void (*sc_dispatch)(); -} *svc_head; - -static struct svc_callout *svc_find(); - -/* *************** SVCXPRT related stuff **************** */ - -/* - * Activate a transport handle. - */ -void -xprt_register(xprt) - SVCXPRT *xprt; -{ - register int sock = xprt->xp_sock; - -#ifdef FD_SETSIZE - if (xports == NULL) { - xports = (SVCXPRT **) - mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); - } - if (sock < _rpc_dtablesize()) { - xports[sock] = xprt; - FD_SET(sock, &svc_fdset); - } -#else - if (sock < NOFILE) { - xports[sock] = xprt; - svc_fds |= (1 << sock); - } -#endif /* def FD_SETSIZE */ - -} - -/* - * De-activate a transport handle. - */ -void -xprt_unregister(xprt) - SVCXPRT *xprt; -{ - register int sock = xprt->xp_sock; - -#ifdef FD_SETSIZE - if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) { - xports[sock] = (SVCXPRT *)0; - FD_CLR(sock, &svc_fdset); - } -#else - if ((sock < NOFILE) && (xports[sock] == xprt)) { - xports[sock] = (SVCXPRT *)0; - svc_fds &= ~(1 << sock); - } -#endif /* def FD_SETSIZE */ -} - - -/* ********************** CALLOUT list related stuff ************* */ - -/* - * Add a service program to the callout list. - * The dispatch routine will be called when a rpc request for this - * program number comes in. - */ -bool_t -svc_register(xprt, prog, vers, dispatch, protocol) - SVCXPRT *xprt; - u_long prog; - u_long vers; - void (*dispatch)(); - int protocol; -{ - struct svc_callout *prev; - register struct svc_callout *s; - - if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) { - if (s->sc_dispatch == dispatch) - goto pmap_it; /* he is registering another xptr */ - return (FALSE); - } - s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout)); - if (s == (struct svc_callout *)0) { - return (FALSE); - } - s->sc_prog = prog; - s->sc_vers = vers; - s->sc_dispatch = dispatch; - s->sc_next = svc_head; - svc_head = s; -pmap_it: - /* now register the information with the local binder service */ - if (protocol) { - return (pmap_set(prog, vers, protocol, xprt->xp_port)); - } - return (TRUE); -} - -/* - * Remove a service program from the callout list. - */ -void -svc_unregister(prog, vers) - u_long prog; - u_long vers; -{ - struct svc_callout *prev; - register struct svc_callout *s; - - if ((s = svc_find(prog, vers, &prev)) == NULL_SVC) - return; - if (prev == NULL_SVC) { - svc_head = s->sc_next; - } else { - prev->sc_next = s->sc_next; - } - s->sc_next = NULL_SVC; - mem_free((char *) s, (u_int) sizeof(struct svc_callout)); - /* now unregister the information with the local binder service */ - (void)pmap_unset(prog, vers); -} - -/* - * Search the callout list for a program number, return the callout - * struct. - */ -static struct svc_callout * -svc_find(prog, vers, prev) - u_long prog; - u_long vers; - struct svc_callout **prev; -{ - register struct svc_callout *s, *p; - - p = NULL_SVC; - for (s = svc_head; s != NULL_SVC; s = s->sc_next) { - if ((s->sc_prog == prog) && (s->sc_vers == vers)) - goto done; - p = s; - } -done: - *prev = p; - return (s); -} - -/* ******************* REPLY GENERATION ROUTINES ************ */ - -/* - * Send a reply to an rpc request - */ -bool_t -svc_sendreply(xprt, xdr_results, xdr_location) - register SVCXPRT *xprt; - xdrproc_t xdr_results; - caddr_t xdr_location; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SUCCESS; - rply.acpted_rply.ar_results.where = xdr_location; - rply.acpted_rply.ar_results.proc = xdr_results; - return (SVC_REPLY(xprt, &rply)); -} - -/* - * No procedure error reply - */ -void -svcerr_noproc(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROC_UNAVAIL; - SVC_REPLY(xprt, &rply); -} - -/* - * Can't decode args error reply - */ -void -svcerr_decode(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = GARBAGE_ARGS; - SVC_REPLY(xprt, &rply); -} - -/* - * Some system error - */ -void -svcerr_systemerr(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SYSTEM_ERR; - SVC_REPLY(xprt, &rply); -} - -/* - * Authentication error reply - */ -void -svcerr_auth(xprt, why) - SVCXPRT *xprt; - enum auth_stat why; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_DENIED; - rply.rjcted_rply.rj_stat = AUTH_ERROR; - rply.rjcted_rply.rj_why = why; - SVC_REPLY(xprt, &rply); -} - -/* - * Auth too weak error reply - */ -void -svcerr_weakauth(xprt) - SVCXPRT *xprt; -{ - - svcerr_auth(xprt, AUTH_TOOWEAK); -} - -/* - * Program unavailable error reply - */ -void -svcerr_noprog(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_UNAVAIL; - SVC_REPLY(xprt, &rply); -} - -/* - * Program version mismatch error reply - */ -void -svcerr_progvers(xprt, low_vers, high_vers) - register SVCXPRT *xprt; - u_long low_vers; - u_long high_vers; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_MISMATCH; - rply.acpted_rply.ar_vers.low = low_vers; - rply.acpted_rply.ar_vers.high = high_vers; - SVC_REPLY(xprt, &rply); -} - -/* ******************* SERVER INPUT STUFF ******************* */ - -/* - * Get server side input from some transport. - * - * Statement of authentication parameters management: - * This function owns and manages all authentication parameters, specifically - * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and - * the "cooked" credentials (rqst->rq_clntcred). - * However, this function does not know the structure of the cooked - * credentials, so it make the following assumptions: - * a) the structure is contiguous (no pointers), and - * b) the cred structure size does not exceed RQCRED_SIZE bytes. - * In all events, all three parameters are freed upon exit from this routine. - * The storage is trivially management on the call stack in user land, but - * is mallocated in kernel land. - */ - -void -svc_getreq(rdfds) - int rdfds; -{ -#ifdef FD_SETSIZE - fd_set readfds; - - FD_ZERO(&readfds); - readfds.fds_bits[0] = rdfds; - svc_getreqset(&readfds); -#else - int readfds = rdfds & svc_fds; - - svc_getreqset(&readfds); -#endif /* def FD_SETSIZE */ -} - -void -svc_getreqset(readfds) -#ifdef FD_SETSIZE - fd_set *readfds; -{ -#else - int *readfds; -{ - int readfds_local = *readfds; -#endif /* def FD_SETSIZE */ - enum xprt_stat stat; - struct rpc_msg msg; - int prog_found; - u_long low_vers; - u_long high_vers; - struct svc_req r; - register SVCXPRT *xprt; - register u_long mask; - register int bit; - register u_long *maskp; - register int setsize; - register int sock; - char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; - msg.rm_call.cb_cred.oa_base = cred_area; - msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); - r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); - - -#ifdef FD_SETSIZE - setsize = _rpc_dtablesize(); - maskp = (u_long *)readfds->fds_bits; - for (sock = 0; sock < setsize; sock += NFDBITS) { - for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) { - /* sock has input waiting */ - xprt = xports[sock + bit - 1]; -#else - for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) { - if ((readfds_local & 1) != 0) { - /* sock has input waiting */ - xprt = xports[sock]; -#endif /* def FD_SETSIZE */ - /* now receive msgs from xprtprt (support batch calls) */ - do { - if (SVC_RECV(xprt, &msg)) { - - /* now find the exported program and call it */ - register struct svc_callout *s; - enum auth_stat why; - - r.rq_xprt = xprt; - r.rq_prog = msg.rm_call.cb_prog; - r.rq_vers = msg.rm_call.cb_vers; - r.rq_proc = msg.rm_call.cb_proc; - r.rq_cred = msg.rm_call.cb_cred; - /* first authenticate the message */ - if ((why= _authenticate(&r, &msg)) != AUTH_OK) { - svcerr_auth(xprt, why); - goto call_done; - } - /* now match message with a registered service*/ - prog_found = FALSE; - low_vers = 0 - 1; - high_vers = 0; - for (s = svc_head; s != NULL_SVC; s = s->sc_next) { - if (s->sc_prog == r.rq_prog) { - if (s->sc_vers == r.rq_vers) { - (*s->sc_dispatch)(&r, xprt); - goto call_done; - } /* found correct version */ - prog_found = TRUE; - if (s->sc_vers < low_vers) - low_vers = s->sc_vers; - if (s->sc_vers > high_vers) - high_vers = s->sc_vers; - } /* found correct program */ - } - /* - * if we got here, the program or version - * is not served ... - */ - if (prog_found) - svcerr_progvers(xprt, - low_vers, high_vers); - else - svcerr_noprog(xprt); - /* Fall through to ... */ - } - call_done: - if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ - SVC_DESTROY(xprt); - break; - } - } while (stat == XPRT_MOREREQS); - } - } -} diff --git a/lib/librpc/rpc/svc.h b/lib/librpc/rpc/svc.h deleted file mode 100644 index dbae45df68b3..000000000000 --- a/lib/librpc/rpc/svc.h +++ /dev/null @@ -1,280 +0,0 @@ -/* @(#)svc.h 2.2 88/07/29 4.0 RPCSRC; from 1.20 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * svc.h, Server-side remote procedure call interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef __SVC_HEADER__ -#define __SVC_HEADER__ - -/* - * This interface must manage two items concerning remote procedure calling: - * - * 1) An arbitrary number of transport connections upon which rpc requests - * are received. The two most notable transports are TCP and UDP; they are - * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; - * they in turn call xprt_register and xprt_unregister. - * - * 2) An arbitrary number of locally registered services. Services are - * described by the following four data: program number, version number, - * "service dispatch" function, a transport handle, and a boolean that - * indicates whether or not the exported program should be registered with a - * local binder service; if true the program's number and version and the - * port number from the transport handle are registered with the binder. - * These data are registered with the rpc svc system via svc_register. - * - * A service's dispatch function is called whenever an rpc request comes in - * on a transport. The request's program and version numbers must match - * those of the registered service. The dispatch function is passed two - * parameters, struct svc_req * and SVCXPRT *, defined below. - */ - -enum xprt_stat { - XPRT_DIED, - XPRT_MOREREQS, - XPRT_IDLE -}; - -/* - * Server side transport handle - */ -typedef struct { - int xp_sock; - u_short xp_port; /* associated port number */ - struct xp_ops { - bool_t (*xp_recv)(); /* receive incomming requests */ - enum xprt_stat (*xp_stat)(); /* get transport status */ - bool_t (*xp_getargs)(); /* get arguments */ - bool_t (*xp_reply)(); /* send reply */ - bool_t (*xp_freeargs)();/* free mem allocated for args */ - void (*xp_destroy)(); /* destroy this struct */ - } *xp_ops; - int xp_addrlen; /* length of remote address */ - struct sockaddr_in xp_raddr; /* remote address */ - struct opaque_auth xp_verf; /* raw response verifier */ - caddr_t xp_p1; /* private */ - caddr_t xp_p2; /* private */ -} SVCXPRT; - -/* - * Approved way of getting address of caller - */ -#define svc_getcaller(x) (&(x)->xp_raddr) - -/* - * Operations defined on an SVCXPRT handle - * - * SVCXPRT *xprt; - * struct rpc_msg *msg; - * xdrproc_t xargs; - * caddr_t argsp; - */ -#define SVC_RECV(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) -#define svc_recv(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) - -#define SVC_STAT(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) -#define svc_stat(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) - -#define SVC_GETARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) -#define svc_getargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) - -#define SVC_REPLY(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) -#define svc_reply(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) - -#define SVC_FREEARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) -#define svc_freeargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) - -#define SVC_DESTROY(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) -#define svc_destroy(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) - - -/* - * Service request - */ -struct svc_req { - u_long rq_prog; /* service program number */ - u_long rq_vers; /* service protocol version */ - u_long rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - caddr_t rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ -}; - - -/* - * Service registration - * - * svc_register(xprt, prog, vers, dispatch, protocol) - * SVCXPRT *xprt; - * u_long prog; - * u_long vers; - * void (*dispatch)(); - * int protocol; (like TCP or UDP, zero means do not register) - */ -extern bool_t svc_register(); - -/* - * Service un-registration - * - * svc_unregister(prog, vers) - * u_long prog; - * u_long vers; - */ -extern void svc_unregister(); - -/* - * Transport registration. - * - * xprt_register(xprt) - * SVCXPRT *xprt; - */ -extern void xprt_register(); - -/* - * Transport un-register - * - * xprt_unregister(xprt) - * SVCXPRT *xprt; - */ -extern void xprt_unregister(); - - - - -/* - * When the service routine is called, it must first check to see if it - * knows about the procedure; if not, it should call svcerr_noproc - * and return. If so, it should deserialize its arguments via - * SVC_GETARGS (defined above). If the deserialization does not work, - * svcerr_decode should be called followed by a return. Successful - * decoding of the arguments should be followed the execution of the - * procedure's code and a call to svc_sendreply. - * - * Also, if the service refuses to execute the procedure due to too- - * weak authentication parameters, svcerr_weakauth should be called. - * Note: do not confuse access-control failure with weak authentication! - * - * NB: In pure implementations of rpc, the caller always waits for a reply - * msg. This message is sent when svc_sendreply is called. - * Therefore pure service implementations should always call - * svc_sendreply even if the function logically returns void; use - * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows - * for the abuse of pure rpc via batched calling or pipelining. In the - * case of a batched call, svc_sendreply should NOT be called since - * this would send a return message, which is what batching tries to avoid. - * It is the service/protocol writer's responsibility to know which calls are - * batched and which are not. Warning: responding to batch calls may - * deadlock the caller and server processes! - */ - -extern bool_t svc_sendreply(); -extern void svcerr_decode(); -extern void svcerr_weakauth(); -extern void svcerr_noproc(); -extern void svcerr_progvers(); -extern void svcerr_auth(); -extern void svcerr_noprog(); -extern void svcerr_systemerr(); - -/* - * Lowest level dispatching -OR- who owns this process anyway. - * Somebody has to wait for incoming requests and then call the correct - * service routine. The routine svc_run does infinite waiting; i.e., - * svc_run never returns. - * Since another (co-existant) package may wish to selectively wait for - * incoming calls or other events outside of the rpc architecture, the - * routine svc_getreq is provided. It must be passed readfds, the - * "in-place" results of a select system call (see select, section 2). - */ - -/* - * Global keeper of rpc service descriptors in use - * dynamic; must be inspected before each call to select - */ -#ifdef FD_SETSIZE -extern fd_set svc_fdset; -#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ -#else -extern int svc_fds; -#endif /* def FD_SETSIZE */ - -/* - * a small program implemented by the svc_rpc implementation itself; - * also see clnt.h for protocol numbers. - */ -extern void rpctest_service(); - -extern void svc_getreq(); -extern void svc_getreqset(); /* takes fdset instead of int */ -extern void svc_run(); /* never returns */ - -/* - * Socket to use on svcxxx_create call to get default socket - */ -#define RPC_ANYSOCK -1 - -/* - * These are the existing service side transport implementations - */ - -/* - * Memory based rpc for testing and timing. - */ -extern SVCXPRT *svcraw_create(); - -/* - * Udp based rpc. - */ -extern SVCXPRT *svcudp_create(); -extern SVCXPRT *svcudp_bufcreate(); - -/* - * Tcp based rpc. - */ -extern SVCXPRT *svctcp_create(); - - - -#endif !__SVC_HEADER__ diff --git a/lib/librpc/rpc/svc_auth.c b/lib/librpc/rpc/svc_auth.c deleted file mode 100644 index ab7ab694219f..000000000000 --- a/lib/librpc/rpc/svc_auth.c +++ /dev/null @@ -1,114 +0,0 @@ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * svc_auth_nodes.c, Server-side rpc authenticator interface, - * *WITHOUT* DES authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -/* - * svcauthsw is the bdevsw of server side authentication. - * - * Server side authenticators are called from authenticate by - * using the client auth struct flavor field to index into svcauthsw. - * The server auth flavors must implement a routine that looks - * like: - * - * enum auth_stat - * flavorx_auth(rqst, msg) - * register struct svc_req *rqst; - * register struct rpc_msg *msg; - * - */ - -enum auth_stat _svcauth_null(); /* no authentication */ -enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ -enum auth_stat _svcauth_short(); /* short hand unix style */ - -static struct { - enum auth_stat (*authenticator)(); -} svcauthsw[] = { - _svcauth_null, /* AUTH_NULL */ - _svcauth_unix, /* AUTH_UNIX */ - _svcauth_short, /* AUTH_SHORT */ -}; -#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ - - -/* - * The call rpc message, msg has been obtained from the wire. The msg contains - * the raw form of credentials and verifiers. authenticate returns AUTH_OK - * if the msg is successfully authenticated. If AUTH_OK then the routine also - * does the following things: - * set rqst->rq_xprt->verf to the appropriate response verifier; - * sets rqst->rq_client_cred to the "cooked" form of the credentials. - * - * NB: rqst->rq_cxprt->verf must be pre-alloctaed; - * its length is set appropriately. - * - * The caller still owns and is responsible for msg->u.cmb.cred and - * msg->u.cmb.verf. The authentication system retains ownership of - * rqst->rq_client_cred, the cooked credentials. - * - * There is an assumption that any flavour less than AUTH_NULL is - * invalid. - */ -enum auth_stat -_authenticate(rqst, msg) - register struct svc_req *rqst; - struct rpc_msg *msg; -{ - register int cred_flavor; - - rqst->rq_cred = msg->rm_call.cb_cred; - rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; - rqst->rq_xprt->xp_verf.oa_length = 0; - cred_flavor = rqst->rq_cred.oa_flavor; - if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { - return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); - } - - return (AUTH_REJECTEDCRED); -} - -enum auth_stat -_svcauth_null(/*rqst, msg*/) - /*struct svc_req *rqst; - struct rpc_msg *msg;*/ -{ - - return (AUTH_OK); -} diff --git a/lib/librpc/rpc/svc_auth.h b/lib/librpc/rpc/svc_auth.h deleted file mode 100644 index a36a01aba8eb..000000000000 --- a/lib/librpc/rpc/svc_auth.h +++ /dev/null @@ -1,42 +0,0 @@ -/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)svc_auth.h 1.6 86/07/16 SMI */ - -/* - * svc_auth.h, Service side of rpc authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - - -/* - * Server side authenticator - */ -extern enum auth_stat _authenticate(); diff --git a/lib/librpc/rpc/svc_auth_unix.c b/lib/librpc/rpc/svc_auth_unix.c deleted file mode 100644 index ea00b7895fce..000000000000 --- a/lib/librpc/rpc/svc_auth_unix.c +++ /dev/null @@ -1,134 +0,0 @@ -/* @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC; from 1.28 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_auth_unix.c - * Handles UNIX flavor authentication parameters on the service side of rpc. - * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. - * _svcauth_unix does full blown unix style uid,gid+gids auth, - * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. - * Note: the shorthand has been gutted for efficiency. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include - -/* - * Unix longhand authenticator - */ -enum auth_stat -_svcauth_unix(rqst, msg) - register struct svc_req *rqst; - register struct rpc_msg *msg; -{ - register enum auth_stat stat; - XDR xdrs; - register struct authunix_parms *aup; - register long *buf; - struct area { - struct authunix_parms area_aup; - char area_machname[MAX_MACHINE_NAME+1]; - int area_gids[NGRPS]; - } *area; - u_int auth_len; - int str_len, gid_len; - register int i; - - area = (struct area *) rqst->rq_clntcred; - aup = &area->area_aup; - aup->aup_machname = area->area_machname; - aup->aup_gids = area->area_gids; - auth_len = (u_int)msg->rm_call.cb_cred.oa_length; - xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); - buf = XDR_INLINE(&xdrs, auth_len); - if (buf != NULL) { - aup->aup_time = IXDR_GET_LONG(buf); - str_len = IXDR_GET_U_LONG(buf); - if (str_len > MAX_MACHINE_NAME) { - stat = AUTH_BADCRED; - goto done; - } - bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len); - aup->aup_machname[str_len] = 0; - str_len = RNDUP(str_len); - buf += str_len / sizeof (long); - aup->aup_uid = IXDR_GET_LONG(buf); - aup->aup_gid = IXDR_GET_LONG(buf); - gid_len = IXDR_GET_U_LONG(buf); - if (gid_len > NGRPS) { - stat = AUTH_BADCRED; - goto done; - } - aup->aup_len = gid_len; - for (i = 0; i < gid_len; i++) { - aup->aup_gids[i] = IXDR_GET_LONG(buf); - } - /* - * five is the smallest unix credentials structure - - * timestamp, hostname len (0), uid, gid, and gids len (0). - */ - if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { - (void) printf("bad auth_len gid %d str %d auth %d\n", - gid_len, str_len, auth_len); - stat = AUTH_BADCRED; - goto done; - } - } else if (! xdr_authunix_parms(&xdrs, aup)) { - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, aup); - stat = AUTH_BADCRED; - goto done; - } - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; - rqst->rq_xprt->xp_verf.oa_length = 0; - stat = AUTH_OK; -done: - XDR_DESTROY(&xdrs); - return (stat); -} - - -/* - * Shorthand unix authenticator - * Looks up longhand in a cache. - */ -/*ARGSUSED*/ -enum auth_stat -_svcauth_short(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; -{ - return (AUTH_REJECTEDCRED); -} diff --git a/lib/librpc/rpc/svc_raw.c b/lib/librpc/rpc/svc_raw.c deleted file mode 100644 index 1170ecec83f2..000000000000 --- a/lib/librpc/rpc/svc_raw.c +++ /dev/null @@ -1,166 +0,0 @@ -/* @(#)svc_raw.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_raw.c, This a toy for simple testing and timing. - * Interface to create an rpc client and server in the same UNIX process. - * This lets us similate rpc and get rpc (round trip) overhead, without - * any interference from the kernal. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - - -/* - * This is the "network" that we will be moving data over - */ -static struct svcraw_private { - char _raw_buf[UDPMSGSIZE]; - SVCXPRT server; - XDR xdr_stream; - char verf_body[MAX_AUTH_BYTES]; -} *svcraw_private; - -static bool_t svcraw_recv(); -static enum xprt_stat svcraw_stat(); -static bool_t svcraw_getargs(); -static bool_t svcraw_reply(); -static bool_t svcraw_freeargs(); -static void svcraw_destroy(); - -static struct xp_ops server_ops = { - svcraw_recv, - svcraw_stat, - svcraw_getargs, - svcraw_reply, - svcraw_freeargs, - svcraw_destroy -}; - -SVCXPRT * -svcraw_create() -{ - register struct svcraw_private *srp = svcraw_private; - - if (srp == 0) { - srp = (struct svcraw_private *)calloc(1, sizeof (*srp)); - if (srp == 0) - return (0); - } - srp->server.xp_sock = 0; - srp->server.xp_port = 0; - srp->server.xp_ops = &server_ops; - srp->server.xp_verf.oa_base = srp->verf_body; - xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE); - return (&srp->server); -} - -static enum xprt_stat -svcraw_stat() -{ - - return (XPRT_IDLE); -} - -static bool_t -svcraw_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (0); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) - return (FALSE); - return (TRUE); -} - -static bool_t -svcraw_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (FALSE); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_replymsg(xdrs, msg)) - return (FALSE); - (void)XDR_GETPOS(xdrs); /* called just for overhead */ - return (TRUE); -} - -static bool_t -svcraw_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register struct svcraw_private *srp = svcraw_private; - - if (srp == 0) - return (FALSE); - return ((*xdr_args)(&srp->xdr_stream, args_ptr)); -} - -static bool_t -svcraw_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (FALSE); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static void -svcraw_destroy() -{ -} diff --git a/lib/librpc/rpc/svc_run.c b/lib/librpc/rpc/svc_run.c deleted file mode 100644 index c1c3e0478114..000000000000 --- a/lib/librpc/rpc/svc_run.c +++ /dev/null @@ -1,72 +0,0 @@ -/* @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; -#endif - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * This is the rpc server side idle loop - * Wait for input, call server program. - */ -#include -#include - -void -svc_run() -{ -#ifdef FD_SETSIZE - fd_set readfds; -#else - int readfds; -#endif /* def FD_SETSIZE */ - extern int errno; - - for (;;) { -#ifdef FD_SETSIZE - readfds = svc_fdset; -#else - readfds = svc_fds; -#endif /* def FD_SETSIZE */ - switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0, - (struct timeval *)0)) { - case -1: - if (errno == EINTR) { - continue; - } - perror("svc_run: - select failed"); - return; - case 0: - continue; - default: - svc_getreqset(&readfds); - } - } -} diff --git a/lib/librpc/rpc/svc_simple.c b/lib/librpc/rpc/svc_simple.c deleted file mode 100644 index d6bcbd3c040d..000000000000 --- a/lib/librpc/rpc/svc_simple.c +++ /dev/null @@ -1,143 +0,0 @@ -/* @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_simple.c - * Simplified front end to rpc. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -static struct proglst { - char *(*p_progname)(); - int p_prognum; - int p_procnum; - xdrproc_t p_inproc, p_outproc; - struct proglst *p_nxt; -} *proglst; -static void universal(); -static SVCXPRT *transp; -struct proglst *pl; - -registerrpc(prognum, versnum, procnum, progname, inproc, outproc) - char *(*progname)(); - xdrproc_t inproc, outproc; -{ - - if (procnum == NULLPROC) { - (void) fprintf(stderr, - "can't reassign procedure number %d\n", NULLPROC); - return (-1); - } - if (transp == 0) { - transp = svcudp_create(RPC_ANYSOCK); - if (transp == NULL) { - (void) fprintf(stderr, "couldn't create an rpc server\n"); - return (-1); - } - } - (void) pmap_unset((u_long)prognum, (u_long)versnum); - if (!svc_register(transp, (u_long)prognum, (u_long)versnum, - universal, IPPROTO_UDP)) { - (void) fprintf(stderr, "couldn't register prog %d vers %d\n", - prognum, versnum); - return (-1); - } - pl = (struct proglst *)malloc(sizeof(struct proglst)); - if (pl == NULL) { - (void) fprintf(stderr, "registerrpc: out of memory\n"); - return (-1); - } - pl->p_progname = progname; - pl->p_prognum = prognum; - pl->p_procnum = procnum; - pl->p_inproc = inproc; - pl->p_outproc = outproc; - pl->p_nxt = proglst; - proglst = pl; - return (0); -} - -static void -universal(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - int prog, proc; - char *outdata; - char xdrbuf[UDPMSGSIZE]; - struct proglst *pl; - - /* - * enforce "procnum 0 is echo" convention - */ - if (rqstp->rq_proc == NULLPROC) { - if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) { - (void) fprintf(stderr, "xxx\n"); - exit(1); - } - return; - } - prog = rqstp->rq_prog; - proc = rqstp->rq_proc; - for (pl = proglst; pl != NULL; pl = pl->p_nxt) - if (pl->p_prognum == prog && pl->p_procnum == proc) { - /* decode arguments into a CLEAN buffer */ - bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */ - if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) { - svcerr_decode(transp); - return; - } - outdata = (*(pl->p_progname))(xdrbuf); - if (outdata == NULL && pl->p_outproc != xdr_void) - /* there was an error */ - return; - if (!svc_sendreply(transp, pl->p_outproc, outdata)) { - (void) fprintf(stderr, - "trouble replying to prog %d\n", - pl->p_prognum); - exit(1); - } - /* free the decoded arguments */ - (void)svc_freeargs(transp, pl->p_inproc, xdrbuf); - return; - } - (void) fprintf(stderr, "never registered prog %d\n", prog); - exit(1); -} - diff --git a/lib/librpc/rpc/svc_tcp.c b/lib/librpc/rpc/svc_tcp.c deleted file mode 100644 index efa21dcdcd7a..000000000000 --- a/lib/librpc/rpc/svc_tcp.c +++ /dev/null @@ -1,419 +0,0 @@ -/* @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_tcp.c, Server side for TCP/IP based RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Actually implements two flavors of transporter - - * a tcp rendezvouser (a listner and connection establisher) - * and a record/tcp stream. - */ - -#include -#include -#include -#include -#include -extern errno; - -/* - * Ops vector for TCP/IP based rpc service handle - */ -static bool_t svctcp_recv(); -static enum xprt_stat svctcp_stat(); -static bool_t svctcp_getargs(); -static bool_t svctcp_reply(); -static bool_t svctcp_freeargs(); -static void svctcp_destroy(); - -static struct xp_ops svctcp_op = { - svctcp_recv, - svctcp_stat, - svctcp_getargs, - svctcp_reply, - svctcp_freeargs, - svctcp_destroy -}; - -/* - * Ops vector for TCP/IP rendezvous handler - */ -static bool_t rendezvous_request(); -static enum xprt_stat rendezvous_stat(); - -static struct xp_ops svctcp_rendezvous_op = { - rendezvous_request, - rendezvous_stat, - (bool_t (*)())abort, - (bool_t (*)())abort, - (bool_t (*)())abort, - svctcp_destroy -}; - -static int readtcp(), writetcp(); -static SVCXPRT *makefd_xprt(); - -struct tcp_rendezvous { /* kept in xprt->xp_p1 */ - u_int sendsize; - u_int recvsize; -}; - -struct tcp_conn { /* kept in xprt->xp_p1 */ - enum xprt_stat strm_stat; - u_long x_id; - XDR xdrs; - char verf_body[MAX_AUTH_BYTES]; -}; - -/* - * Usage: - * xprt = svctcp_create(sock, send_buf_size, recv_buf_size); - * - * Creates, registers, and returns a (rpc) tcp based transporter. - * Once *xprt is initialized, it is registered as a transporter - * see (svc.h, xprt_register). This routine returns - * a NULL if a problem occurred. - * - * If sock<0 then a socket is created, else sock is used. - * If the socket, sock is not bound to a port then svctcp_create - * binds it to an arbitrary port. The routine then starts a tcp - * listener on the socket's associated port. In any (successful) case, - * xprt->xp_sock is the registered socket number and xprt->xp_port is the - * associated port number. - * - * Since tcp streams do buffered io similar to stdio, the caller can specify - * how big the send and receive buffers are via the second and third parms; - * 0 => use the system default. - */ -SVCXPRT * -svctcp_create(sock, sendsize, recvsize) - register int sock; - u_int sendsize; - u_int recvsize; -{ - bool_t madesock = FALSE; - register SVCXPRT *xprt; - register struct tcp_rendezvous *r; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - - if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - perror("svctcp_.c - udp socket creation problem"); - return ((SVCXPRT *)NULL); - } - madesock = TRUE; - } - bzero((char *)&addr, sizeof (addr)); - addr.sin_family = AF_INET; - if (bindresvport(sock, &addr)) { - addr.sin_port = 0; - (void)bind(sock, (struct sockaddr *)&addr, len); - } - if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || - (listen(sock, 2) != 0)) { - perror("svctcp_.c - cannot getsockname or listen"); - if (madesock) - (void)close(sock); - return ((SVCXPRT *)NULL); - } - r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); - if (r == NULL) { - (void) fprintf(stderr, "svctcp_create: out of memory\n"); - return (NULL); - } - r->sendsize = sendsize; - r->recvsize = recvsize; - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - (void) fprintf(stderr, "svctcp_create: out of memory\n"); - return (NULL); - } - xprt->xp_p2 = NULL; - xprt->xp_p1 = (caddr_t)r; - xprt->xp_verf = _null_auth; - xprt->xp_ops = &svctcp_rendezvous_op; - xprt->xp_port = ntohs(addr.sin_port); - xprt->xp_sock = sock; - xprt_register(xprt); - return (xprt); -} - -/* - * Like svtcp_create(), except the routine takes any *open* UNIX file - * descriptor as its first input. - */ -SVCXPRT * -svcfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - - return (makefd_xprt(fd, sendsize, recvsize)); -} - -static SVCXPRT * -makefd_xprt(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - register SVCXPRT *xprt; - register struct tcp_conn *cd; - - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == (SVCXPRT *)NULL) { - (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); - goto done; - } - cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn)); - if (cd == (struct tcp_conn *)NULL) { - (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); - mem_free((char *) xprt, sizeof(SVCXPRT)); - xprt = (SVCXPRT *)NULL; - goto done; - } - cd->strm_stat = XPRT_IDLE; - xdrrec_create(&(cd->xdrs), sendsize, recvsize, - (caddr_t)xprt, readtcp, writetcp); - xprt->xp_p2 = NULL; - xprt->xp_p1 = (caddr_t)cd; - xprt->xp_verf.oa_base = cd->verf_body; - xprt->xp_addrlen = 0; - xprt->xp_ops = &svctcp_op; /* truely deals with calls */ - xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ - xprt->xp_sock = fd; - xprt_register(xprt); - done: - return (xprt); -} - -static bool_t -rendezvous_request(xprt) - register SVCXPRT *xprt; -{ - int sock; - struct tcp_rendezvous *r; - struct sockaddr_in addr; - int len; - - r = (struct tcp_rendezvous *)xprt->xp_p1; - again: - len = sizeof(struct sockaddr_in); - if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr, - &len)) < 0) { - if (errno == EINTR) - goto again; - return (FALSE); - } - /* - * make a new transporter (re-uses xprt) - */ - xprt = makefd_xprt(sock, r->sendsize, r->recvsize); - xprt->xp_raddr = addr; - xprt->xp_addrlen = len; - return (FALSE); /* there is never an rpc msg to be processed */ -} - -static enum xprt_stat -rendezvous_stat() -{ - - return (XPRT_IDLE); -} - -static void -svctcp_destroy(xprt) - register SVCXPRT *xprt; -{ - register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; - - xprt_unregister(xprt); - (void)close(xprt->xp_sock); - if (xprt->xp_port != 0) { - /* a rendezvouser socket */ - xprt->xp_port = 0; - } else { - /* an actual connection socket */ - XDR_DESTROY(&(cd->xdrs)); - } - mem_free((caddr_t)cd, sizeof(struct tcp_conn)); - mem_free((caddr_t)xprt, sizeof(SVCXPRT)); -} - -/* - * All read operations timeout after 35 seconds. - * A timeout is fatal for the connection. - */ -static struct timeval wait_per_try = { 35, 0 }; - -/* - * reads data from the tcp conection. - * any error is fatal and the connection is closed. - * (And a read of zero bytes is a half closed stream => error.) - */ -static int -readtcp(xprt, buf, len) - register SVCXPRT *xprt; - caddr_t buf; - register int len; -{ - register int sock = xprt->xp_sock; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; - - FD_ZERO(&mask); - FD_SET(sock, &mask); -#else - register int mask = 1 << sock; - int readfds; -#endif /* def FD_SETSIZE */ - do { - readfds = mask; - if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, - &wait_per_try) <= 0) { - if (errno == EINTR) { - continue; - } - goto fatal_err; - } -#ifdef FD_SETSIZE - } while (!FD_ISSET(sock, &readfds)); -#else - } while (readfds != mask); -#endif /* def FD_SETSIZE */ - if ((len = read(sock, buf, len)) > 0) { - return (len); - } -fatal_err: - ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; - return (-1); -} - -/* - * writes data to the tcp connection. - * Any error is fatal and the connection is closed. - */ -static int -writetcp(xprt, buf, len) - register SVCXPRT *xprt; - caddr_t buf; - int len; -{ - register int i, cnt; - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { - ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = - XPRT_DIED; - return (-1); - } - } - return (len); -} - -static enum xprt_stat -svctcp_stat(xprt) - SVCXPRT *xprt; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - - if (cd->strm_stat == XPRT_DIED) - return (XPRT_DIED); - if (! xdrrec_eof(&(cd->xdrs))) - return (XPRT_MOREREQS); - return (XPRT_IDLE); -} - -static bool_t -svctcp_recv(xprt, msg) - SVCXPRT *xprt; - register struct rpc_msg *msg; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - register XDR *xdrs = &(cd->xdrs); - - xdrs->x_op = XDR_DECODE; - (void)xdrrec_skiprecord(xdrs); - if (xdr_callmsg(xdrs, msg)) { - cd->x_id = msg->rm_xid; - return (TRUE); - } - return (FALSE); -} - -static bool_t -svctcp_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - - return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr)); -} - -static bool_t -svctcp_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register XDR *xdrs = - &(((struct tcp_conn *)(xprt->xp_p1))->xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static bool_t -svctcp_reply(xprt, msg) - SVCXPRT *xprt; - register struct rpc_msg *msg; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - register XDR *xdrs = &(cd->xdrs); - register bool_t stat; - - xdrs->x_op = XDR_ENCODE; - msg->rm_xid = cd->x_id; - stat = xdr_replymsg(xdrs, msg); - (void)xdrrec_endofrecord(xdrs, TRUE); - return (stat); -} diff --git a/lib/librpc/rpc/svc_udp.c b/lib/librpc/rpc/svc_udp.c deleted file mode 100644 index 429b01b6de55..000000000000 --- a/lib/librpc/rpc/svc_udp.c +++ /dev/null @@ -1,477 +0,0 @@ -/* @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_udp.c, - * Server side for UDP/IP based RPC. (Does some caching in the hopes of - * achieving execute-at-most-once semantics.) - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - - -#define rpc_buffer(xprt) ((xprt)->xp_p1) -#define MAX(a, b) ((a > b) ? a : b) - -static bool_t svcudp_recv(); -static bool_t svcudp_reply(); -static enum xprt_stat svcudp_stat(); -static bool_t svcudp_getargs(); -static bool_t svcudp_freeargs(); -static void svcudp_destroy(); - -static struct xp_ops svcudp_op = { - svcudp_recv, - svcudp_stat, - svcudp_getargs, - svcudp_reply, - svcudp_freeargs, - svcudp_destroy -}; - -extern int errno; - -/* - * kept in xprt->xp_p2 - */ -struct svcudp_data { - u_int su_iosz; /* byte size of send.recv buffer */ - u_long su_xid; /* transaction id */ - XDR su_xdrs; /* XDR handle */ - char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ - char * su_cache; /* cached data, NULL if no cache */ -}; -#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2)) - -/* - * Usage: - * xprt = svcudp_create(sock); - * - * If sock<0 then a socket is created, else sock is used. - * If the socket, sock is not bound to a port then svcudp_create - * binds it to an arbitrary port. In any (successful) case, - * xprt->xp_sock is the registered socket number and xprt->xp_port is the - * associated port number. - * Once *xprt is initialized, it is registered as a transporter; - * see (svc.h, xprt_register). - * The routines returns NULL if a problem occurred. - */ -SVCXPRT * -svcudp_bufcreate(sock, sendsz, recvsz) - register int sock; - u_int sendsz, recvsz; -{ - bool_t madesock = FALSE; - register SVCXPRT *xprt; - register struct svcudp_data *su; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - - if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("svcudp_create: socket creation problem"); - return ((SVCXPRT *)NULL); - } - madesock = TRUE; - } - bzero((char *)&addr, sizeof (addr)); - addr.sin_family = AF_INET; - if (bindresvport(sock, &addr)) { - addr.sin_port = 0; - (void)bind(sock, (struct sockaddr *)&addr, len); - } - if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { - perror("svcudp_create - cannot getsockname"); - if (madesock) - (void)close(sock); - return ((SVCXPRT *)NULL); - } - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - su = (struct svcudp_data *)mem_alloc(sizeof(*su)); - if (su == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4; - if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - xdrmem_create( - &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE); - su->su_cache = NULL; - xprt->xp_p2 = (caddr_t)su; - xprt->xp_verf.oa_base = su->su_verfbody; - xprt->xp_ops = &svcudp_op; - xprt->xp_port = ntohs(addr.sin_port); - xprt->xp_sock = sock; - xprt_register(xprt); - return (xprt); -} - -SVCXPRT * -svcudp_create(sock) - int sock; -{ - - return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE)); -} - -static enum xprt_stat -svcudp_stat(xprt) - SVCXPRT *xprt; -{ - - return (XPRT_IDLE); -} - -static bool_t -svcudp_recv(xprt, msg) - register SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcudp_data *su = su_data(xprt); - register XDR *xdrs = &(su->su_xdrs); - register int rlen; - char *reply; - u_long replylen; - static int cache_get(); - - again: - xprt->xp_addrlen = sizeof(struct sockaddr_in); - rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, - 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen)); - if (rlen == -1 && errno == EINTR) - goto again; - if (rlen < 4*sizeof(u_long)) - return (FALSE); - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) - return (FALSE); - su->su_xid = msg->rm_xid; - if (su->su_cache != NULL) { - if (cache_get(xprt, msg, &reply, &replylen)) { - (void) sendto(xprt->xp_sock, reply, (int) replylen, 0, - (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen); - return (TRUE); - } - } - return (TRUE); -} - -static bool_t -svcudp_reply(xprt, msg) - register SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcudp_data *su = su_data(xprt); - register XDR *xdrs = &(su->su_xdrs); - register int slen; - register bool_t stat = FALSE; - static void cache_set(); - - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - msg->rm_xid = su->su_xid; - if (xdr_replymsg(xdrs, msg)) { - slen = (int)XDR_GETPOS(xdrs); - if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0, - (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen) - == slen) { - stat = TRUE; - if (su->su_cache && slen >= 0) { - cache_set(xprt, (u_long) slen); - } - } - } - return (stat); -} - -static bool_t -svcudp_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - - return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr)); -} - -static bool_t -svcudp_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register XDR *xdrs = &(su_data(xprt)->su_xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static void -svcudp_destroy(xprt) - register SVCXPRT *xprt; -{ - register struct svcudp_data *su = su_data(xprt); - - xprt_unregister(xprt); - (void)close(xprt->xp_sock); - XDR_DESTROY(&(su->su_xdrs)); - mem_free(rpc_buffer(xprt), su->su_iosz); - mem_free((caddr_t)su, sizeof(struct svcudp_data)); - mem_free((caddr_t)xprt, sizeof(SVCXPRT)); -} - - -/***********this could be a separate file*********************/ - -/* - * Fifo cache for udp server - * Copies pointers to reply buffers into fifo cache - * Buffers are sent again if retransmissions are detected. - */ - -#define SPARSENESS 4 /* 75% sparse */ - -#define CACHE_PERROR(msg) \ - (void) fprintf(stderr,"%s\n", msg) - -#define ALLOC(type, size) \ - (type *) mem_alloc((unsigned) (sizeof(type) * (size))) - -#define BZERO(addr, type, size) \ - bzero((char *) addr, sizeof(type) * (int) (size)) - -/* - * An entry in the cache - */ -typedef struct cache_node *cache_ptr; -struct cache_node { - /* - * Index into cache is xid, proc, vers, prog and address - */ - u_long cache_xid; - u_long cache_proc; - u_long cache_vers; - u_long cache_prog; - struct sockaddr_in cache_addr; - /* - * The cached reply and length - */ - char * cache_reply; - u_long cache_replylen; - /* - * Next node on the list, if there is a collision - */ - cache_ptr cache_next; -}; - - - -/* - * The entire cache - */ -struct udp_cache { - u_long uc_size; /* size of cache */ - cache_ptr *uc_entries; /* hash table of entries in cache */ - cache_ptr *uc_fifo; /* fifo list of entries in cache */ - u_long uc_nextvictim; /* points to next victim in fifo list */ - u_long uc_prog; /* saved program number */ - u_long uc_vers; /* saved version number */ - u_long uc_proc; /* saved procedure number */ - struct sockaddr_in uc_addr; /* saved caller's address */ -}; - - -/* - * the hashing function - */ -#define CACHE_LOC(transp, xid) \ - (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) - - -/* - * Enable use of the cache. - * Note: there is no disable. - */ -svcudp_enablecache(transp, size) - SVCXPRT *transp; - u_long size; -{ - struct svcudp_data *su = su_data(transp); - struct udp_cache *uc; - - if (su->su_cache != NULL) { - CACHE_PERROR("enablecache: cache already enabled"); - return(0); - } - uc = ALLOC(struct udp_cache, 1); - if (uc == NULL) { - CACHE_PERROR("enablecache: could not allocate cache"); - return(0); - } - uc->uc_size = size; - uc->uc_nextvictim = 0; - uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); - if (uc->uc_entries == NULL) { - CACHE_PERROR("enablecache: could not allocate cache data"); - return(0); - } - BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); - uc->uc_fifo = ALLOC(cache_ptr, size); - if (uc->uc_fifo == NULL) { - CACHE_PERROR("enablecache: could not allocate cache fifo"); - return(0); - } - BZERO(uc->uc_fifo, cache_ptr, size); - su->su_cache = (char *) uc; - return(1); -} - - -/* - * Set an entry in the cache - */ -static void -cache_set(xprt, replylen) - SVCXPRT *xprt; - u_long replylen; -{ - register cache_ptr victim; - register cache_ptr *vicp; - register struct svcudp_data *su = su_data(xprt); - struct udp_cache *uc = (struct udp_cache *) su->su_cache; - u_int loc; - char *newbuf; - - /* - * Find space for the new entry, either by - * reusing an old entry, or by mallocing a new one - */ - victim = uc->uc_fifo[uc->uc_nextvictim]; - if (victim != NULL) { - loc = CACHE_LOC(xprt, victim->cache_xid); - for (vicp = &uc->uc_entries[loc]; - *vicp != NULL && *vicp != victim; - vicp = &(*vicp)->cache_next) - ; - if (*vicp == NULL) { - CACHE_PERROR("cache_set: victim not found"); - return; - } - *vicp = victim->cache_next; /* remote from cache */ - newbuf = victim->cache_reply; - } else { - victim = ALLOC(struct cache_node, 1); - if (victim == NULL) { - CACHE_PERROR("cache_set: victim alloc failed"); - return; - } - newbuf = mem_alloc(su->su_iosz); - if (newbuf == NULL) { - CACHE_PERROR("cache_set: could not allocate new rpc_buffer"); - return; - } - } - - /* - * Store it away - */ - victim->cache_replylen = replylen; - victim->cache_reply = rpc_buffer(xprt); - rpc_buffer(xprt) = newbuf; - xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE); - victim->cache_xid = su->su_xid; - victim->cache_proc = uc->uc_proc; - victim->cache_vers = uc->uc_vers; - victim->cache_prog = uc->uc_prog; - victim->cache_addr = uc->uc_addr; - loc = CACHE_LOC(xprt, victim->cache_xid); - victim->cache_next = uc->uc_entries[loc]; - uc->uc_entries[loc] = victim; - uc->uc_fifo[uc->uc_nextvictim++] = victim; - uc->uc_nextvictim %= uc->uc_size; -} - -/* - * Try to get an entry from the cache - * return 1 if found, 0 if not found - */ -static -cache_get(xprt, msg, replyp, replylenp) - SVCXPRT *xprt; - struct rpc_msg *msg; - char **replyp; - u_long *replylenp; -{ - u_int loc; - register cache_ptr ent; - register struct svcudp_data *su = su_data(xprt); - register struct udp_cache *uc = (struct udp_cache *) su->su_cache; - -# define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) - - loc = CACHE_LOC(xprt, su->su_xid); - for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { - if (ent->cache_xid == su->su_xid && - ent->cache_proc == uc->uc_proc && - ent->cache_vers == uc->uc_vers && - ent->cache_prog == uc->uc_prog && - EQADDR(ent->cache_addr, uc->uc_addr)) { - *replyp = ent->cache_reply; - *replylenp = ent->cache_replylen; - return(1); - } - } - /* - * Failed to find entry - * Remember a few things so we can do a set later - */ - uc->uc_proc = msg->rm_call.cb_proc; - uc->uc_vers = msg->rm_call.cb_vers; - uc->uc_prog = msg->rm_call.cb_prog; - uc->uc_addr = xprt->xp_raddr; - return(0); -} - diff --git a/lib/librpc/rpc/types.h b/lib/librpc/rpc/types.h deleted file mode 100644 index 06d22bf8006a..000000000000 --- a/lib/librpc/rpc/types.h +++ /dev/null @@ -1,63 +0,0 @@ -/* @(#)types.h 2.3 88/08/15 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)types.h 1.18 87/07/24 SMI */ - -/* - * Rpc additions to - */ -#ifndef __TYPES_RPC_HEADER__ -#define __TYPES_RPC_HEADER__ - -#define bool_t int -#define enum_t int -#define FALSE (0) -#define TRUE (1) -#define __dontcare__ -1 -#ifndef NULL -# define NULL 0 -#endif - -void *malloc(); -#define mem_alloc(bsize) malloc(bsize) -#define mem_free(ptr, bsize) free(ptr) - -#ifndef makedev /* ie, we haven't already included it */ -#include -#endif -#include - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK (u_long)0x7F000001 -#endif -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#endif /* ndef __TYPES_RPC_HEADER__ */ diff --git a/lib/librpc/rpc/xdr.c b/lib/librpc/rpc/xdr.c deleted file mode 100644 index 6c379c9e1b86..000000000000 --- a/lib/librpc/rpc/xdr.c +++ /dev/null @@ -1,576 +0,0 @@ -/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; -#endif - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include - -#include -#include - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) -#define LASTUNSIGNED ((u_int) 0-1) - -/* - * for unit alignment - */ -static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free(proc, objp) - xdrproc_t proc; - char *objp; -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc)(&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void(/* xdrs, addr */) - /* XDR *xdrs; */ - /* caddr_t addr; */ -{ - - return (TRUE); -} - -/* - * XDR integers - */ -bool_t -xdr_int(xdrs, ip) - XDR *xdrs; - int *ip; -{ - -#ifdef lint - (void) (xdr_short(xdrs, (short *)ip)); - return (xdr_long(xdrs, (long *)ip)); -#else - if (sizeof (int) == sizeof (long)) { - return (xdr_long(xdrs, (long *)ip)); - } else { - return (xdr_short(xdrs, (short *)ip)); - } -#endif -} - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int(xdrs, up) - XDR *xdrs; - u_int *up; -{ - -#ifdef lint - (void) (xdr_short(xdrs, (short *)up)); - return (xdr_u_long(xdrs, (u_long *)up)); -#else - if (sizeof (u_int) == sizeof (u_long)) { - return (xdr_u_long(xdrs, (u_long *)up)); - } else { - return (xdr_short(xdrs, (short *)up)); - } -#endif -} - -/* - * XDR long integers - * same as xdr_u_long - open coded to save a proc call! - */ -bool_t -xdr_long(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if (xdrs->x_op == XDR_ENCODE) - return (XDR_PUTLONG(xdrs, lp)); - - if (xdrs->x_op == XDR_DECODE) - return (XDR_GETLONG(xdrs, lp)); - - if (xdrs->x_op == XDR_FREE) - return (TRUE); - - return (FALSE); -} - -/* - * XDR unsigned long integers - * same as xdr_long - open coded to save a proc call! - */ -bool_t -xdr_u_long(xdrs, ulp) - register XDR *xdrs; - u_long *ulp; -{ - - if (xdrs->x_op == XDR_DECODE) - return (XDR_GETLONG(xdrs, (long *)ulp)); - if (xdrs->x_op == XDR_ENCODE) - return (XDR_PUTLONG(xdrs, (long *)ulp)); - if (xdrs->x_op == XDR_FREE) - return (TRUE); - return (FALSE); -} - -/* - * XDR short integers - */ -bool_t -xdr_short(xdrs, sp) - register XDR *xdrs; - short *sp; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *sp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *sp = (short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short(xdrs, usp) - register XDR *xdrs; - u_short *usp; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *usp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *usp = (u_short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - - -/* - * XDR a char - */ -bool_t -xdr_char(xdrs, cp) - XDR *xdrs; - char *cp; -{ - int i; - - i = (*cp); - if (!xdr_int(xdrs, &i)) { - return (FALSE); - } - *cp = i; - return (TRUE); -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char(xdrs, cp) - XDR *xdrs; - char *cp; -{ - u_int u; - - u = (*cp); - if (!xdr_u_int(xdrs, &u)) { - return (FALSE); - } - *cp = u; - return (TRUE); -} - -/* - * XDR booleans - */ -bool_t -xdr_bool(xdrs, bp) - register XDR *xdrs; - bool_t *bp; -{ - long lb; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return (XDR_PUTLONG(xdrs, &lb)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &lb)) { - return (FALSE); - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR enumerations - */ -bool_t -xdr_enum(xdrs, ep) - XDR *xdrs; - enum_t *ep; -{ -#ifndef lint - enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - if (sizeof (enum sizecheck) == sizeof (long)) { - return (xdr_long(xdrs, (long *)ep)); - } else if (sizeof (enum sizecheck) == sizeof (short)) { - return (xdr_short(xdrs, (short *)ep)); - } else { - return (FALSE); - } -#else - (void) (xdr_short(xdrs, (short *)ep)); - return (xdr_long(xdrs, (long *)ep)); -#endif -} - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque(xdrs, cp, cnt) - register XDR *xdrs; - caddr_t cp; - register u_int cnt; -{ - register u_int rndup; - static crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return (TRUE); - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - if (xdrs->x_op == XDR_DECODE) { - if (!XDR_GETBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_GETBYTES(xdrs, crud, rndup)); - } - - if (xdrs->x_op == XDR_ENCODE) { - if (!XDR_PUTBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); - } - - if (xdrs->x_op == XDR_FREE) { - return (TRUE); - } - - return (FALSE); -} - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes(xdrs, cpp, sizep, maxsize) - register XDR *xdrs; - char **cpp; - register u_int *sizep; - u_int maxsize; -{ - register char *sp = *cpp; /* sp is the actual string pointer */ - register u_int nodesize; - - /* - * first deal with the length since xdr bytes are counted - */ - if (! xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) { - *cpp = sp = (char *)mem_alloc(nodesize); - } - if (sp == NULL) { - (void) fprintf(stderr, "xdr_bytes: out of memory\n"); - return (FALSE); - } - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, nodesize)); - - case XDR_FREE: - if (sp != NULL) { - mem_free(sp, nodesize); - *cpp = NULL; - } - return (TRUE); - } - return (FALSE); -} - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj(xdrs, np) - XDR *xdrs; - struct netobj *np; -{ - - return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); -} - -/* - * XDR a descriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -bool_t -xdr_union(xdrs, dscmp, unp, choices, dfault) - register XDR *xdrs; - enum_t *dscmp; /* enum to decide which arm to work on */ - char *unp; /* the union itself */ - struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ - xdrproc_t dfault; /* default xdr routine */ -{ - register enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (! xdr_enum(xdrs, dscmp)) { - return (FALSE); - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) { - if (choices->value == dscm) - return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault)(xdrs, unp, LASTUNSIGNED)); -} - - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string(xdrs, cpp, maxsize) - register XDR *xdrs; - char **cpp; - u_int maxsize; -{ - register char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) { - return(TRUE); /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - size = strlen(sp); - break; - } - if (! xdr_u_int(xdrs, &size)) { - return (FALSE); - } - if (size > maxsize) { - return (FALSE); - } - nodesize = size + 1; - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) - *cpp = sp = (char *)mem_alloc(nodesize); - if (sp == NULL) { - (void) fprintf(stderr, "xdr_string: out of memory\n"); - return (FALSE); - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, size)); - - case XDR_FREE: - mem_free(sp, nodesize); - *cpp = NULL; - return (TRUE); - } - return (FALSE); -} - -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring(xdrs, cpp) - XDR *xdrs; - char **cpp; -{ - if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { - return (TRUE); - } - return (FALSE); -} diff --git a/lib/librpc/rpc/xdr.h b/lib/librpc/rpc/xdr.h deleted file mode 100644 index 6cd3e6fe0397..000000000000 --- a/lib/librpc/rpc/xdr.h +++ /dev/null @@ -1,270 +0,0 @@ -/* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)xdr.h 1.19 87/04/22 SMI */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef __XDR_HEADER__ -#define __XDR_HEADER__ - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE=0, - XDR_DECODE=1, - XDR_FREE=2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - * bool_t (*xdrproc_t)(XDR *, caddr_t *); - */ -typedef bool_t (*xdrproc_t)(); - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the paticular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular impelementation. - */ -typedef struct { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { - bool_t (*x_getlong)(); /* get a long from underlying stream */ - bool_t (*x_putlong)(); /* put a long to " */ - bool_t (*x_getbytes)();/* get some bytes from " */ - bool_t (*x_putbytes)();/* put some bytes to " */ - u_int (*x_getpostn)();/* returns bytes off from beginning */ - bool_t (*x_setpostn)();/* lets you reposition the stream */ - long * (*x_inline)(); /* buf quick ptr to buffered data */ - void (*x_destroy)(); /* free privates of this xdr_stream */ - } *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - int x_handy; /* extra private word */ -} XDR; - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * long *longp; - * caddr_t addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) -#define xdr_destroy(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * a entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim { - int value; - xdrproc_t proc; -}; - -/* - * In-line routines for fast encode/decode of primitve data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ -#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) - -/* - * These are the "generic" xdr routines. - */ -extern bool_t xdr_void(); -extern bool_t xdr_int(); -extern bool_t xdr_u_int(); -extern bool_t xdr_long(); -extern bool_t xdr_u_long(); -extern bool_t xdr_short(); -extern bool_t xdr_u_short(); -extern bool_t xdr_bool(); -extern bool_t xdr_enum(); -extern bool_t xdr_array(); -extern bool_t xdr_bytes(); -extern bool_t xdr_opaque(); -extern bool_t xdr_string(); -extern bool_t xdr_union(); -extern bool_t xdr_char(); -extern bool_t xdr_u_char(); -extern bool_t xdr_vector(); -extern bool_t xdr_float(); -extern bool_t xdr_double(); -extern bool_t xdr_reference(); -extern bool_t xdr_pointer(); -extern bool_t xdr_wrapstring(); - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj { - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj(); - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ -extern void xdrmem_create(); /* XDR using memory buffers */ -extern void xdrstdio_create(); /* XDR using stdio library */ -extern void xdrrec_create(); /* XDR pseudo records for tcp */ -extern bool_t xdrrec_endofrecord(); /* make end of xdr record */ -extern bool_t xdrrec_skiprecord(); /* move to beginning of next record */ -extern bool_t xdrrec_eof(); /* true if no more input */ - -#endif !__XDR_HEADER__ diff --git a/lib/librpc/rpc/xdr_array.c b/lib/librpc/rpc/xdr_array.c deleted file mode 100644 index 7c2831ccd229..000000000000 --- a/lib/librpc/rpc/xdr_array.c +++ /dev/null @@ -1,153 +0,0 @@ -/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_array.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ - -#include - -#include -#include - -#define LASTUNSIGNED ((u_int)0-1) - - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -bool_t -xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) - register XDR *xdrs; - caddr_t *addrp; /* array pointer */ - u_int *sizep; /* number of elements */ - u_int maxsize; /* max numberof elements */ - u_int elsize; /* size in bytes of each element */ - xdrproc_t elproc; /* xdr routine to handle each element */ -{ - register u_int i; - register caddr_t target = *addrp; - register u_int c; /* the actual element count */ - register bool_t stat = TRUE; - register u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (! xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - c = *sizep; - if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) { - case XDR_DECODE: - if (c == 0) - return (TRUE); - *addrp = target = mem_alloc(nodesize); - if (target == NULL) { - (void) fprintf(stderr, - "xdr_array: out of memory\n"); - return (FALSE); - } - bzero(target, nodesize); - break; - - case XDR_FREE: - return (TRUE); - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) { - stat = (*elproc)(xdrs, target, LASTUNSIGNED); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) { - mem_free(*addrp, nodesize); - *addrp = NULL; - } - return (stat); -} - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) - register XDR *xdrs; - register char *basep; - register u_int nelem; - register u_int elemsize; - register xdrproc_t xdr_elem; -{ - register u_int i; - register char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) { - if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { - return(FALSE); - } - elptr += elemsize; - } - return(TRUE); -} - diff --git a/lib/librpc/rpc/xdr_float.c b/lib/librpc/rpc/xdr_float.c deleted file mode 100644 index 4b5b697bcf30..000000000000 --- a/lib/librpc/rpc/xdr_float.c +++ /dev/null @@ -1,267 +0,0 @@ -/* @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_float.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include - -#include -#include - -/* - * NB: Not portable. - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#ifdef vax - -/* What IEEE single precision floating point looks like on a Vax */ -struct ieee_single { - unsigned int mantissa: 23; - unsigned int exp : 8; - unsigned int sign : 1; -}; - -/* Vax single precision floating point */ -struct vax_single { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; -}; - -#define VAX_SNG_BIAS 0x81 -#define IEEE_SNG_BIAS 0x7f - -static struct sgl_limits { - struct vax_single s; - struct ieee_single ieee; -} sgl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ - { 0x0, 0xff, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ - { 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; -#endif /* vax */ - -bool_t -xdr_float(xdrs, fp) - register XDR *xdrs; - register float *fp; -{ -#if !defined(mc68000) && !defined(sparc) - struct ieee_single is; - struct vax_single vs, *vsp; - struct sgl_limits *lim; - int i; -#endif - switch (xdrs->x_op) { - - case XDR_ENCODE: -#if defined(mc68000) || defined(sparc) - return (XDR_PUTLONG(xdrs, (long *)fp)); -#else - vs = *((struct vax_single *)fp); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((vs.mantissa2 == lim->s.mantissa2) && - (vs.exp == lim->s.exp) && - (vs.mantissa1 == lim->s.mantissa1)) { - is = lim->ieee; - goto shipit; - } - } - is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; - is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; - shipit: - is.sign = vs.sign; - return (XDR_PUTLONG(xdrs, (long *)&is)); -#endif - - case XDR_DECODE: -#if defined(mc68000) || defined(sparc) - return (XDR_GETLONG(xdrs, (long *)fp)); -#else - vsp = (struct vax_single *)fp; - if (!XDR_GETLONG(xdrs, (long *)&is)) - return (FALSE); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((is.exp == lim->ieee.exp) && - (is.mantissa == lim->ieee.mantissa)) { - *vsp = lim->s; - goto doneit; - } - } - vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; - vsp->mantissa2 = is.mantissa; - vsp->mantissa1 = (is.mantissa >> 16); - doneit: - vsp->sign = is.sign; - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#ifdef vax -/* What IEEE double precision floating point looks like on a Vax */ -struct ieee_double { - unsigned int mantissa1 : 20; - unsigned int exp : 11; - unsigned int sign : 1; - unsigned int mantissa2 : 32; -}; - -/* Vax double precision floating point */ -struct vax_double { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; - unsigned int mantissa3 : 16; - unsigned int mantissa4 : 16; -}; - -#define VAX_DBL_BIAS 0x81 -#define IEEE_DBL_BIAS 0x3ff -#define MASK(nbits) ((1 << nbits) - 1) - -static struct dbl_limits { - struct vax_double d; - struct ieee_double ieee; -} dbl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ - { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ - { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; - -#endif /* vax */ - - -bool_t -xdr_double(xdrs, dp) - register XDR *xdrs; - double *dp; -{ - register long *lp; -#if !defined(mc68000) && !defined(sparc) - struct ieee_double id; - struct vax_double vd; - register struct dbl_limits *lim; - int i; -#endif - - switch (xdrs->x_op) { - - case XDR_ENCODE: -#if defined(mc68000) || defined(sparc) - lp = (long *)dp; -#else - vd = *((struct vax_double *)dp); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((vd.mantissa4 == lim->d.mantissa4) && - (vd.mantissa3 == lim->d.mantissa3) && - (vd.mantissa2 == lim->d.mantissa2) && - (vd.mantissa1 == lim->d.mantissa1) && - (vd.exp == lim->d.exp)) { - id = lim->ieee; - goto shipit; - } - } - id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; - id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); - id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | - (vd.mantissa3 << 13) | - ((vd.mantissa4 >> 3) & MASK(13)); - shipit: - id.sign = vd.sign; - lp = (long *)&id; -#endif - return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); - - case XDR_DECODE: -#if defined(mc68000) || defined(sparc) - lp = (long *)dp; - return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); -#else - lp = (long *)&id; - if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) - return (FALSE); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((id.mantissa2 == lim->ieee.mantissa2) && - (id.mantissa1 == lim->ieee.mantissa1) && - (id.exp == lim->ieee.exp)) { - vd = lim->d; - goto doneit; - } - } - vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; - vd.mantissa1 = (id.mantissa1 >> 13); - vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | - (id.mantissa2 >> 29); - vd.mantissa3 = (id.mantissa2 >> 13); - vd.mantissa4 = (id.mantissa2 << 3); - doneit: - vd.sign = id.sign; - *dp = *((double *)&vd); - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} diff --git a/lib/librpc/rpc/xdr_mem.c b/lib/librpc/rpc/xdr_mem.c deleted file mode 100644 index 558d36922703..000000000000 --- a/lib/librpc/rpc/xdr_mem.c +++ /dev/null @@ -1,184 +0,0 @@ -/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_mem.h, XDR implementation using memory buffers. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * If you have some data to be interpreted as external data representation - * or to be converted to external data representation in a memory buffer, - * then this is the package for you. - * - */ - - -#include -#include -#include - -static bool_t xdrmem_getlong(); -static bool_t xdrmem_putlong(); -static bool_t xdrmem_getbytes(); -static bool_t xdrmem_putbytes(); -static u_int xdrmem_getpos(); -static bool_t xdrmem_setpos(); -static long * xdrmem_inline(); -static void xdrmem_destroy(); - -static struct xdr_ops xdrmem_ops = { - xdrmem_getlong, - xdrmem_putlong, - xdrmem_getbytes, - xdrmem_putbytes, - xdrmem_getpos, - xdrmem_setpos, - xdrmem_inline, - xdrmem_destroy -}; - -/* - * The procedure xdrmem_create initializes a stream descriptor for a - * memory buffer. - */ -void -xdrmem_create(xdrs, addr, size, op) - register XDR *xdrs; - caddr_t addr; - u_int size; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = &xdrmem_ops; - xdrs->x_private = xdrs->x_base = addr; - xdrs->x_handy = size; -} - -static void -xdrmem_destroy(/*xdrs*/) - /*XDR *xdrs;*/ -{ -} - -static bool_t -xdrmem_getlong(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if ((xdrs->x_handy -= sizeof(long)) < 0) - return (FALSE); - *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private)))); - xdrs->x_private += sizeof(long); - return (TRUE); -} - -static bool_t -xdrmem_putlong(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if ((xdrs->x_handy -= sizeof(long)) < 0) - return (FALSE); - *(long *)xdrs->x_private = (long)htonl((u_long)(*lp)); - xdrs->x_private += sizeof(long); - return (TRUE); -} - -static bool_t -xdrmem_getbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; -{ - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - bcopy(xdrs->x_private, addr, len); - xdrs->x_private += len; - return (TRUE); -} - -static bool_t -xdrmem_putbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; -{ - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - bcopy(addr, xdrs->x_private, len); - xdrs->x_private += len; - return (TRUE); -} - -static u_int -xdrmem_getpos(xdrs) - register XDR *xdrs; -{ - - return ((u_int)xdrs->x_private - (u_int)xdrs->x_base); -} - -static bool_t -xdrmem_setpos(xdrs, pos) - register XDR *xdrs; - u_int pos; -{ - register caddr_t newaddr = xdrs->x_base + pos; - register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; - - if ((long)newaddr > (long)lastaddr) - return (FALSE); - xdrs->x_private = newaddr; - xdrs->x_handy = (int)lastaddr - (int)newaddr; - return (TRUE); -} - -static long * -xdrmem_inline(xdrs, len) - register XDR *xdrs; - int len; -{ - long *buf = 0; - - if (xdrs->x_handy >= len) { - xdrs->x_handy -= len; - buf = (long *) xdrs->x_private; - xdrs->x_private += len; - } - return (buf); -} diff --git a/lib/librpc/rpc/xdr_rec.c b/lib/librpc/rpc/xdr_rec.c deleted file mode 100644 index 6ebea844a684..000000000000 --- a/lib/librpc/rpc/xdr_rec.c +++ /dev/null @@ -1,583 +0,0 @@ -/* @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" - * layer above tcp (for rpc's use). - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These routines interface XDRSTREAMS to a tcp/ip connection. - * There is a record marking layer between the xdr stream - * and the tcp transport level. A record is composed on one or more - * record fragments. A record fragment is a thirty-two bit header followed - * by n bytes of data, where n is contained in the header. The header - * is represented as a htonl(u_long). Thegh order bit encodes - * whether or not the fragment is the last fragment of the record - * (1 => fragment is last, 0 => more fragments to follow. - * The other 31 bits encode the byte length of the fragment. - */ - -#include -#include -#include -#include -#include - -static u_int fix_buf_size(); -static bool_t flush_out(); -static bool_t get_input_bytes(); -static bool_t set_input_fragment(); -static bool_t skip_input_bytes(); - -static bool_t xdrrec_getlong(); -static bool_t xdrrec_putlong(); -static bool_t xdrrec_getbytes(); -static bool_t xdrrec_putbytes(); -static u_int xdrrec_getpos(); -static bool_t xdrrec_setpos(); -static long * xdrrec_inline(); -static void xdrrec_destroy(); - -static struct xdr_ops xdrrec_ops = { - xdrrec_getlong, - xdrrec_putlong, - xdrrec_getbytes, - xdrrec_putbytes, - xdrrec_getpos, - xdrrec_setpos, - xdrrec_inline, - xdrrec_destroy -}; - -/* - * A record is composed of one or more record fragments. - * A record fragment is a two-byte header followed by zero to - * 2**32-1 bytes. The header is treated as a long unsigned and is - * encode/decoded to the network via htonl/ntohl. The low order 31 bits - * are a byte count of the fragment. The highest order bit is a boolean: - * 1 => this fragment is the last fragment of the record, - * 0 => this fragment is followed by more fragment(s). - * - * The fragment/record machinery is not general; it is constructed to - * meet the needs of xdr and rpc based on tcp. - */ - -#define LAST_FRAG ((u_long)(1 << 31)) - -typedef struct rec_strm { - caddr_t tcp_handle; - caddr_t the_buffer; - /* - * out-goung bits - */ - int (*writeit)(); - caddr_t out_base; /* output buffer (points to frag header) */ - caddr_t out_finger; /* next output position */ - caddr_t out_boundry; /* data cannot up to this address */ - u_long *frag_header; /* beginning of curren fragment */ - bool_t frag_sent; /* true if buffer sent in middle of record */ - /* - * in-coming bits - */ - int (*readit)(); - u_long in_size; /* fixed size of the input buffer */ - caddr_t in_base; - caddr_t in_finger; /* location of next byte to be had */ - caddr_t in_boundry; /* can read up to this location */ - long fbtbc; /* fragment bytes to be consumed */ - bool_t last_frag; - u_int sendsize; - u_int recvsize; -} RECSTREAM; - - -/* - * Create an xdr handle for xdrrec - * xdrrec_create fills in xdrs. Sendsize and recvsize are - * send and recv buffer sizes (0 => use default). - * tcp_handle is an opaque handle that is passed as the first parameter to - * the procedures readit and writeit. Readit and writeit are read and - * write respectively. They are like the system - * calls expect that they take an opaque handle rather than an fd. - */ -void -xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) - register XDR *xdrs; - register u_int sendsize; - register u_int recvsize; - caddr_t tcp_handle; - int (*readit)(); /* like read, but pass it a tcp_handle, not sock */ - int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */ -{ - register RECSTREAM *rstrm = - (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); - - if (rstrm == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); - /* - * This is bad. Should rework xdrrec_create to - * return a handle, and in this case return NULL - */ - return; - } - /* - * adjust sizes and allocate buffer quad byte aligned - */ - rstrm->sendsize = sendsize = fix_buf_size(sendsize); - rstrm->recvsize = recvsize = fix_buf_size(recvsize); - rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); - if (rstrm->the_buffer == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); - return; - } - for (rstrm->out_base = rstrm->the_buffer; - (u_int)rstrm->out_base % BYTES_PER_XDR_UNIT != 0; - rstrm->out_base++); - rstrm->in_base = rstrm->out_base + sendsize; - /* - * now the rest ... - */ - xdrs->x_ops = &xdrrec_ops; - xdrs->x_private = (caddr_t)rstrm; - rstrm->tcp_handle = tcp_handle; - rstrm->readit = readit; - rstrm->writeit = writeit; - rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; - rstrm->frag_header = (u_long *)rstrm->out_base; - rstrm->out_finger += sizeof(u_long); - rstrm->out_boundry += sendsize; - rstrm->frag_sent = FALSE; - rstrm->in_size = recvsize; - rstrm->in_boundry = rstrm->in_base; - rstrm->in_finger = (rstrm->in_boundry += recvsize); - rstrm->fbtbc = 0; - rstrm->last_frag = TRUE; -} - - -/* - * The reoutines defined below are the xdr ops which will go into the - * xdr handle filled in by xdrrec_create. - */ - -static bool_t -xdrrec_getlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register long *buflp = (long *)(rstrm->in_finger); - long mylong; - - /* first try the inline, fast case */ - if ((rstrm->fbtbc >= sizeof(long)) && - (((int)rstrm->in_boundry - (int)buflp) >= sizeof(long))) { - *lp = (long)ntohl((u_long)(*buflp)); - rstrm->fbtbc -= sizeof(long); - rstrm->in_finger += sizeof(long); - } else { - if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(long))) - return (FALSE); - *lp = (long)ntohl((u_long)mylong); - } - return (TRUE); -} - -static bool_t -xdrrec_putlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register long *dest_lp = ((long *)(rstrm->out_finger)); - - if ((rstrm->out_finger += sizeof(long)) > rstrm->out_boundry) { - /* - * this case should almost never happen so the code is - * inefficient - */ - rstrm->out_finger -= sizeof(long); - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - dest_lp = ((long *)(rstrm->out_finger)); - rstrm->out_finger += sizeof(long); - } - *dest_lp = (long)htonl((u_long)(*lp)); - return (TRUE); -} - -static bool_t /* must manage buffers, fragments, and records */ -xdrrec_getbytes(xdrs, addr, len) - XDR *xdrs; - register caddr_t addr; - register u_int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int current; - - while (len > 0) { - current = rstrm->fbtbc; - if (current == 0) { - if (rstrm->last_frag) - return (FALSE); - if (! set_input_fragment(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - if (! get_input_bytes(rstrm, addr, current)) - return (FALSE); - addr += current; - rstrm->fbtbc -= current; - len -= current; - } - return (TRUE); -} - -static bool_t -xdrrec_putbytes(xdrs, addr, len) - XDR *xdrs; - register caddr_t addr; - register u_int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int current; - - while (len > 0) { - current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger; - current = (len < current) ? len : current; - bcopy(addr, rstrm->out_finger, current); - rstrm->out_finger += current; - addr += current; - len -= current; - if (rstrm->out_finger == rstrm->out_boundry) { - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - } - } - return (TRUE); -} - -static u_int -xdrrec_getpos(xdrs) - register XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - register long pos; - - pos = lseek((int)rstrm->tcp_handle, (long) 0, 1); - if (pos != -1) - switch (xdrs->x_op) { - - case XDR_ENCODE: - pos += rstrm->out_finger - rstrm->out_base; - break; - - case XDR_DECODE: - pos -= rstrm->in_boundry - rstrm->in_finger; - break; - - default: - pos = (u_int) -1; - break; - } - return ((u_int) pos); -} - -static bool_t -xdrrec_setpos(xdrs, pos) - register XDR *xdrs; - u_int pos; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - u_int currpos = xdrrec_getpos(xdrs); - int delta = currpos - pos; - caddr_t newpos; - - if ((int)currpos != -1) - switch (xdrs->x_op) { - - case XDR_ENCODE: - newpos = rstrm->out_finger - delta; - if ((newpos > (caddr_t)(rstrm->frag_header)) && - (newpos < rstrm->out_boundry)) { - rstrm->out_finger = newpos; - return (TRUE); - } - break; - - case XDR_DECODE: - newpos = rstrm->in_finger - delta; - if ((delta < (int)(rstrm->fbtbc)) && - (newpos <= rstrm->in_boundry) && - (newpos >= rstrm->in_base)) { - rstrm->in_finger = newpos; - rstrm->fbtbc -= delta; - return (TRUE); - } - break; - } - return (FALSE); -} - -static long * -xdrrec_inline(xdrs, len) - register XDR *xdrs; - int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - long * buf = NULL; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - if ((rstrm->out_finger + len) <= rstrm->out_boundry) { - buf = (long *) rstrm->out_finger; - rstrm->out_finger += len; - } - break; - - case XDR_DECODE: - if ((len <= rstrm->fbtbc) && - ((rstrm->in_finger + len) <= rstrm->in_boundry)) { - buf = (long *) rstrm->in_finger; - rstrm->fbtbc -= len; - rstrm->in_finger += len; - } - break; - } - return (buf); -} - -static void -xdrrec_destroy(xdrs) - register XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - - mem_free(rstrm->the_buffer, - rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); - mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); -} - - -/* - * Exported routines to manage xdr records - */ - -/* - * Before reading (deserializing from the stream, one should always call - * this procedure to guarantee proper record alignment. - */ -bool_t -xdrrec_skiprecord(xdrs) - XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (FALSE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (FALSE); - } - rstrm->last_frag = FALSE; - return (TRUE); -} - -/* - * Look ahead fuction. - * Returns TRUE iff there is no more input in the buffer - * after consuming the rest of the current record. - */ -bool_t -xdrrec_eof(xdrs) - XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (TRUE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (TRUE); - } - if (rstrm->in_finger == rstrm->in_boundry) - return (TRUE); - return (FALSE); -} - -/* - * The client must tell the package when an end-of-record has occurred. - * The second paraemters tells whether the record should be flushed to the - * (output) tcp stream. (This let's the package support batched or - * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. - */ -bool_t -xdrrec_endofrecord(xdrs, sendnow) - XDR *xdrs; - bool_t sendnow; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register u_long len; /* fragment length */ - - if (sendnow || rstrm->frag_sent || - ((u_long)rstrm->out_finger + sizeof(u_long) >= - (u_long)rstrm->out_boundry)) { - rstrm->frag_sent = FALSE; - return (flush_out(rstrm, TRUE)); - } - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - - sizeof(u_long); - *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG); - rstrm->frag_header = (u_long *)rstrm->out_finger; - rstrm->out_finger += sizeof(u_long); - return (TRUE); -} - - -/* - * Internal useful routines - */ -static bool_t -flush_out(rstrm, eor) - register RECSTREAM *rstrm; - bool_t eor; -{ - register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0; - register u_long len = (u_long)(rstrm->out_finger) - - (u_long)(rstrm->frag_header) - sizeof(u_long); - - *(rstrm->frag_header) = htonl(len | eormask); - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); - if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) - != (int)len) - return (FALSE); - rstrm->frag_header = (u_long *)rstrm->out_base; - rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_long); - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -fill_input_buf(rstrm) - register RECSTREAM *rstrm; -{ - register caddr_t where; - u_int i; - register int len; - - where = rstrm->in_base; - i = (u_int)rstrm->in_boundry % BYTES_PER_XDR_UNIT; - where += i; - len = rstrm->in_size - i; - if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) - return (FALSE); - rstrm->in_finger = where; - where += len; - rstrm->in_boundry = where; - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -get_input_bytes(rstrm, addr, len) - register RECSTREAM *rstrm; - register caddr_t addr; - register int len; -{ - register int current; - - while (len > 0) { - current = (int)rstrm->in_boundry - (int)rstrm->in_finger; - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - bcopy(rstrm->in_finger, addr, current); - rstrm->in_finger += current; - addr += current; - len -= current; - } - return (TRUE); -} - -static bool_t /* next two bytes of the input stream are treated as a header */ -set_input_fragment(rstrm) - register RECSTREAM *rstrm; -{ - u_long header; - - if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) - return (FALSE); - header = (long)ntohl(header); - rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; - rstrm->fbtbc = header & (~LAST_FRAG); - return (TRUE); -} - -static bool_t /* consumes input bytes; knows nothing about records! */ -skip_input_bytes(rstrm, cnt) - register RECSTREAM *rstrm; - long cnt; -{ - register int current; - - while (cnt > 0) { - current = (int)rstrm->in_boundry - (int)rstrm->in_finger; - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (cnt < current) ? cnt : current; - rstrm->in_finger += current; - cnt -= current; - } - return (TRUE); -} - -static u_int -fix_buf_size(s) - register u_int s; -{ - - if (s < 100) - s = 4000; - return (RNDUP(s)); -} diff --git a/lib/librpc/rpc/xdr_reference.c b/lib/librpc/rpc/xdr_reference.c deleted file mode 100644 index 32d91d9999e4..000000000000 --- a/lib/librpc/rpc/xdr_reference.c +++ /dev/null @@ -1,132 +0,0 @@ -/* @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; -#endif - -/* - * xdr_reference.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1987, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * "pointers". See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include - -#define LASTUNSIGNED ((u_int)0-1) - -/* - * XDR an indirect pointer - * xdr_reference is for recursively translating a structure that is - * referenced by a pointer inside the structure that is currently being - * translated. pp references a pointer to storage. If *pp is null - * the necessary storage is allocated. - * size is the sizeof the referneced structure. - * proc is the routine to handle the referenced structure. - */ -bool_t -xdr_reference(xdrs, pp, size, proc) - register XDR *xdrs; - caddr_t *pp; /* the pointer to work on */ - u_int size; /* size of the object pointed to */ - xdrproc_t proc; /* xdr routine to handle the object */ -{ - register caddr_t loc = *pp; - register bool_t stat; - - if (loc == NULL) - switch (xdrs->x_op) { - case XDR_FREE: - return (TRUE); - - case XDR_DECODE: - *pp = loc = (caddr_t) mem_alloc(size); - if (loc == NULL) { - (void) fprintf(stderr, - "xdr_reference: out of memory\n"); - return (FALSE); - } - bzero(loc, (int)size); - break; - } - - stat = (*proc)(xdrs, loc, LASTUNSIGNED); - - if (xdrs->x_op == XDR_FREE) { - mem_free(loc, size); - *pp = NULL; - } - return (stat); -} - - -/* - * xdr_pointer(): - * - * XDR a pointer to a possibly recursive data structure. This - * differs with xdr_reference in that it can serialize/deserialiaze - * trees correctly. - * - * What's sent is actually a union: - * - * union object_pointer switch (boolean b) { - * case TRUE: object_data data; - * case FALSE: void nothing; - * } - * - * > objpp: Pointer to the pointer to the object. - * > obj_size: size of the object. - * > xdr_obj: routine to XDR an object. - * - */ -bool_t -xdr_pointer(xdrs,objpp,obj_size,xdr_obj) - register XDR *xdrs; - char **objpp; - u_int obj_size; - xdrproc_t xdr_obj; -{ - - bool_t more_data; - - more_data = (*objpp != NULL); - if (! xdr_bool(xdrs,&more_data)) { - return (FALSE); - } - if (! more_data) { - *objpp = NULL; - return (TRUE); - } - return (xdr_reference(xdrs,objpp,obj_size,xdr_obj)); -} diff --git a/lib/librpc/rpc/xdr_stdio.c b/lib/librpc/rpc/xdr_stdio.c deleted file mode 100644 index 694774f6f6d6..000000000000 --- a/lib/librpc/rpc/xdr_stdio.c +++ /dev/null @@ -1,189 +0,0 @@ -/* @(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include -#include -#include - -static bool_t xdrstdio_getlong(); -static bool_t xdrstdio_putlong(); -static bool_t xdrstdio_getbytes(); -static bool_t xdrstdio_putbytes(); -static u_int xdrstdio_getpos(); -static bool_t xdrstdio_setpos(); -static long * xdrstdio_inline(); -static void xdrstdio_destroy(); - -/* - * Ops vector for stdio type XDR - */ -static struct xdr_ops xdrstdio_ops = { - xdrstdio_getlong, /* deseraialize a long int */ - xdrstdio_putlong, /* seraialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy /* destroy stream */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create(xdrs, file, op) - register XDR *xdrs; - FILE *file; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = &xdrstdio_ops; - xdrs->x_private = (caddr_t)file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy(xdrs) - register XDR *xdrs; -{ - (void)fflush((FILE *)xdrs->x_private); - /* xx should we close the file ?? */ -}; - -static bool_t -xdrstdio_getlong(xdrs, lp) - XDR *xdrs; - register long *lp; -{ - - if (fread((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); -#ifndef mc68000 - *lp = ntohl(*lp); -#endif - return (TRUE); -} - -static bool_t -xdrstdio_putlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - -#ifndef mc68000 - long mycopy = htonl(*lp); - lp = &mycopy; -#endif - if (fwrite((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_getbytes(xdrs, addr, len) - XDR *xdrs; - caddr_t addr; - u_int len; -{ - - if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_putbytes(xdrs, addr, len) - XDR *xdrs; - caddr_t addr; - u_int len; -{ - - if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static u_int -xdrstdio_getpos(xdrs) - XDR *xdrs; -{ - - return ((u_int) ftell((FILE *)xdrs->x_private)); -} - -static bool_t -xdrstdio_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - - return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? - FALSE : TRUE); -} - -static long * -xdrstdio_inline(xdrs, len) - XDR *xdrs; - u_int len; -{ - - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return (NULL); -} diff --git a/lib/librpc/rpcgen/Makefile b/lib/librpc/rpcgen/Makefile deleted file mode 100644 index f6d15c3d5a27..000000000000 --- a/lib/librpc/rpcgen/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/01 4.0 RPCSRC -# -# Makefile for rpc protocol compiler -# Copyright (C) 1987, Sun Microsystems, Inc. -# -SRCS= rpc_main.c rpc_hout.c rpc_cout.c rpc_parse.c rpc_scan.c rpc_util.c \ - rpc_svcout.c rpc_clntout.c -HDRS= rpc_util.h rpc_parse.h rpc_scan.h -OBJS= rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o rpc_scan.o rpc_util.o \ - rpc_svcout.o rpc_clntout.o - -GOAL=rpcgen -CFLAGS = -O -DESTDIR= - -$(GOAL): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $@ - -install: $(GOAL) - @echo "Installing the RPC Protocol Compiler" - install -s $(GOAL) $(DESTDIR)/usr/bin - -lint: $(SRCS) $(HDRS) - lint $(SRCS) - -clean: - rm -f $(GOAL) $(OBJS) - -depend: $(SRCS) $(HDRS) - @${CC} ${CFLAGS} -M ${SRCS} > makedep - @echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep - @echo '$$r makedep' >>eddep - @echo 'w' >>eddep - @cp Makefile makefile.bak - @ed - Makefile < eddep - @rm eddep makedep makefile.bak - -depend.42BSD depend.42bsd: - cp /dev/null x.c - for i in $(SRCS) ; do \ - (/bin/grep '^#[ ]*include' x.c $$i | sed \ - -e '/\.\.\/h/d' \ - -e '/\.\.\/ufs/d' \ - -e 's,<\(.*\)>,"/usr/include/\1",' \ - -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ - -e 's/\.c/\.o/' >>makedep); done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep x.c - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - -# DO NOT DELETE THIS LINE - - diff --git a/lib/librpc/rpcgen/rpc_clntout.c b/lib/librpc/rpcgen/rpc_clntout.c deleted file mode 100644 index 555681bd2a3c..000000000000 --- a/lib/librpc/rpcgen/rpc_clntout.c +++ /dev/null @@ -1,126 +0,0 @@ -/* @(#)rpc_clntout.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_clntout.c 1.2 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsytsems, Inc. - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" - -#define DEFAULT_TIMEOUT 25 /* in seconds */ - -void -write_stubs() -{ - list *l; - definition *def; - - f_print(fout, - "\n/* Default timeout can be changed using clnt_control() */\n"); - f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", - DEFAULT_TIMEOUT); - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) { - write_program(def); - } - } -} - - -static -write_program(def) - definition *def; -{ - version_list *vp; - proc_list *proc; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\n"); - ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*\n"); - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "(argp, clnt)\n"); - f_print(fout, "\t"); - ptype(proc->arg_prefix, proc->arg_type, 1); - f_print(fout, "*argp;\n"); - f_print(fout, "\tCLIENT *clnt;\n"); - f_print(fout, "{\n"); - printbody(proc); - f_print(fout, "}\n\n"); - } - } -} - -static char * -ampr(type) - char *type; -{ - if (isvectordef(type, REL_ALIAS)) { - return (""); - } else { - return ("&"); - } -} - -static -printbody(proc) - proc_list *proc; -{ - f_print(fout, "\tstatic "); - if (streq(proc->res_type, "void")) { - f_print(fout, "char "); - } else { - ptype(proc->res_prefix, proc->res_type, 0); - } - f_print(fout, "res;\n"); - f_print(fout, "\n"); - f_print(fout, "\tbzero((char *)%sres, sizeof(res));\n", - ampr(proc->res_type)); - f_print(fout, - "\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n", - proc->proc_name, stringfix(proc->arg_type), - stringfix(proc->res_type), ampr(proc->res_type)); - f_print(fout, "\t\treturn (NULL);\n"); - f_print(fout, "\t}\n"); - if (streq(proc->res_type, "void")) { - f_print(fout, "\treturn ((void *)%sres);\n", - ampr(proc->res_type)); - } else { - f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type)); - } -} diff --git a/lib/librpc/rpcgen/rpc_cout.c b/lib/librpc/rpcgen/rpc_cout.c deleted file mode 100644 index 86d38652f5b1..000000000000 --- a/lib/librpc/rpcgen/rpc_cout.c +++ /dev/null @@ -1,350 +0,0 @@ -/* @(#)rpc_cout.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_cout.c 1.8 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_cout.c, XDR routine outputter for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include "rpc_util.h" -#include "rpc_parse.h" - -/* - * Emit the C-routine for the given definition - */ -void -emit(def) - definition *def; -{ - if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { - return; - } - print_header(def); - switch (def->def_kind) { - case DEF_UNION: - emit_union(def); - break; - case DEF_ENUM: - emit_enum(def); - break; - case DEF_STRUCT: - emit_struct(def); - break; - case DEF_TYPEDEF: - emit_typedef(def); - break; - } - print_trailer(); -} - -static -findtype(def, type) - definition *def; - char *type; -{ - if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { - return (0); - } else { - return (streq(def->def_name, type)); - } -} - -static -undefined(type) - char *type; -{ - definition *def; - - def = (definition *) FINDVAL(defined, type, findtype); - return (def == NULL); -} - - -static -print_header(def) - definition *def; -{ - space(); - f_print(fout, "bool_t\n"); - f_print(fout, "xdr_%s(xdrs, objp)\n", def->def_name); - f_print(fout, "\tXDR *xdrs;\n"); - f_print(fout, "\t%s ", def->def_name); - if (def->def_kind != DEF_TYPEDEF || - !isvectordef(def->def.ty.old_type, def->def.ty.rel)) { - f_print(fout, "*"); - } - f_print(fout, "objp;\n"); - f_print(fout, "{\n"); -} - -static -print_trailer() -{ - f_print(fout, "\treturn (TRUE);\n"); - f_print(fout, "}\n"); - space(); -} - - -static -print_ifopen(indent, name) - int indent; - char *name; -{ - tabify(fout, indent); - f_print(fout, "if (!xdr_%s(xdrs", name); -} - - -static -print_ifarg(arg) - char *arg; -{ - f_print(fout, ", %s", arg); -} - - -static -print_ifsizeof(prefix, type) - char *prefix; - char *type; -{ - if (streq(type, "bool")) { - f_print(fout, ", sizeof(bool_t), xdr_bool"); - } else { - f_print(fout, ", sizeof("); - if (undefined(type) && prefix) { - f_print(fout, "%s ", prefix); - } - f_print(fout, "%s), xdr_%s", type, type); - } -} - -static -print_ifclose(indent) - int indent; -{ - f_print(fout, ")) {\n"); - tabify(fout, indent); - f_print(fout, "\treturn (FALSE);\n"); - tabify(fout, indent); - f_print(fout, "}\n"); -} - -static -space() -{ - f_print(fout, "\n\n"); -} - -static -print_ifstat(indent, prefix, type, rel, amax, objname, name) - int indent; - char *prefix; - char *type; - relation rel; - char *amax; - char *objname; - char *name; -{ - char *alt = NULL; - - switch (rel) { - case REL_POINTER: - print_ifopen(indent, "pointer"); - print_ifarg("(char **)"); - f_print(fout, "%s", objname); - print_ifsizeof(prefix, type); - break; - case REL_VECTOR: - if (streq(type, "string")) { - alt = "string"; - } else if (streq(type, "opaque")) { - alt = "opaque"; - } - if (alt) { - print_ifopen(indent, alt); - print_ifarg(objname); - } else { - print_ifopen(indent, "vector"); - print_ifarg("(char *)"); - f_print(fout, "%s", objname); - } - print_ifarg(amax); - if (!alt) { - print_ifsizeof(prefix, type); - } - break; - case REL_ARRAY: - if (streq(type, "string")) { - alt = "string"; - } else if (streq(type, "opaque")) { - alt = "bytes"; - } - if (streq(type, "string")) { - print_ifopen(indent, alt); - print_ifarg(objname); - } else { - if (alt) { - print_ifopen(indent, alt); - } else { - print_ifopen(indent, "array"); - } - print_ifarg("(char **)"); - if (*objname == '&') { - f_print(fout, "%s.%s_val, (u_int *)%s.%s_len", - objname, name, objname, name); - } else { - f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len", - objname, name, objname, name); - } - } - print_ifarg(amax); - if (!alt) { - print_ifsizeof(prefix, type); - } - break; - case REL_ALIAS: - print_ifopen(indent, type); - print_ifarg(objname); - break; - } - print_ifclose(indent); -} - - -/* ARGSUSED */ -static -emit_enum(def) - definition *def; -{ - print_ifopen(1, "enum"); - print_ifarg("(enum_t *)objp"); - print_ifclose(1); -} - - -static -emit_union(def) - definition *def; -{ - declaration *dflt; - case_list *cl; - declaration *cs; - char *object; - char *format = "&objp->%s_u.%s"; - - print_stat(&def->def.un.enum_decl); - f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); - for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { - cs = &cl->case_decl; - f_print(fout, "\tcase %s:\n", cl->case_name); - if (!streq(cs->type, "void")) { - object = alloc(strlen(def->def_name) + strlen(format) + - strlen(cs->name) + 1); - s_print(object, format, def->def_name, cs->name); - print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max, - object, cs->name); - free(object); - } - f_print(fout, "\t\tbreak;\n"); - } - dflt = def->def.un.default_decl; - if (dflt != NULL) { - if (!streq(dflt->type, "void")) { - f_print(fout, "\tdefault:\n"); - object = alloc(strlen(def->def_name) + strlen(format) + - strlen(dflt->name) + 1); - s_print(object, format, def->def_name, dflt->name); - print_ifstat(2, dflt->prefix, dflt->type, dflt->rel, - dflt->array_max, object, dflt->name); - free(object); - f_print(fout, "\t\tbreak;\n"); - } - } else { - f_print(fout, "\tdefault:\n"); - f_print(fout, "\t\treturn (FALSE);\n"); - } - f_print(fout, "\t}\n"); -} - - - -static -emit_struct(def) - definition *def; -{ - decl_list *dl; - - for (dl = def->def.st.decls; dl != NULL; dl = dl->next) { - print_stat(&dl->decl); - } -} - - - - -static -emit_typedef(def) - definition *def; -{ - char *prefix = def->def.ty.old_prefix; - char *type = def->def.ty.old_type; - char *amax = def->def.ty.array_max; - relation rel = def->def.ty.rel; - - print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); -} - - - - - -static -print_stat(dec) - declaration *dec; -{ - char *prefix = dec->prefix; - char *type = dec->type; - char *amax = dec->array_max; - relation rel = dec->rel; - char name[256]; - - if (isvectordef(type, rel)) { - s_print(name, "objp->%s", dec->name); - } else { - s_print(name, "&objp->%s", dec->name); - } - print_ifstat(1, prefix, type, rel, amax, name, dec->name); -} diff --git a/lib/librpc/rpcgen/rpc_hout.c b/lib/librpc/rpcgen/rpc_hout.c deleted file mode 100644 index 1bf009738d5a..000000000000 --- a/lib/librpc/rpcgen/rpc_hout.c +++ /dev/null @@ -1,370 +0,0 @@ -/* @(#)rpc_hout.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI"; -#endif - -/* - * rpc_hout.c, Header file outputter for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include "rpc_util.h" -#include "rpc_parse.h" - - -/* - * Print the C-version of an xdr definition - */ -void -print_datadef(def) - definition *def; -{ - if (def->def_kind != DEF_CONST) { - f_print(fout, "\n"); - } - switch (def->def_kind) { - case DEF_STRUCT: - pstructdef(def); - break; - case DEF_UNION: - puniondef(def); - break; - case DEF_ENUM: - penumdef(def); - break; - case DEF_TYPEDEF: - ptypedef(def); - break; - case DEF_PROGRAM: - pprogramdef(def); - break; - case DEF_CONST: - pconstdef(def); - break; - } - if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) { - f_print(fout, "bool_t xdr_%s();\n", def->def_name); - } - if (def->def_kind != DEF_CONST) { - f_print(fout, "\n"); - } -} - -static -pconstdef(def) - definition *def; -{ - pdefine(def->def_name, def->def.co); -} - -static -pstructdef(def) - definition *def; -{ - decl_list *l; - char *name = def->def_name; - - f_print(fout, "struct %s {\n", name); - for (l = def->def.st.decls; l != NULL; l = l->next) { - pdeclaration(name, &l->decl, 1); - } - f_print(fout, "};\n"); - f_print(fout, "typedef struct %s %s;\n", name, name); -} - -static -puniondef(def) - definition *def; -{ - case_list *l; - char *name = def->def_name; - declaration *decl; - - f_print(fout, "struct %s {\n", name); - decl = &def->def.un.enum_decl; - if (streq(decl->type, "bool")) { - f_print(fout, "\tbool_t %s;\n", decl->name); - } else { - f_print(fout, "\t%s %s;\n", decl->type, decl->name); - } - f_print(fout, "\tunion {\n"); - for (l = def->def.un.cases; l != NULL; l = l->next) { - pdeclaration(name, &l->case_decl, 2); - } - decl = def->def.un.default_decl; - if (decl && !streq(decl->type, "void")) { - pdeclaration(name, decl, 2); - } - f_print(fout, "\t} %s_u;\n", name); - f_print(fout, "};\n"); - f_print(fout, "typedef struct %s %s;\n", name, name); -} - - - -static -pdefine(name, num) - char *name; - char *num; -{ - f_print(fout, "#define %s %s\n", name, num); -} - -static -puldefine(name, num) - char *name; - char *num; -{ - f_print(fout, "#define %s ((u_long)%s)\n", name, num); -} - -static -define_printed(stop, start) - proc_list *stop; - version_list *start; -{ - version_list *vers; - proc_list *proc; - - for (vers = start; vers != NULL; vers = vers->next) { - for (proc = vers->procs; proc != NULL; proc = proc->next) { - if (proc == stop) { - return (0); - } else if (streq(proc->proc_name, stop->proc_name)) { - return (1); - } - } - } - abort(); - /* NOTREACHED */ -} - - -static -pprogramdef(def) - definition *def; -{ - version_list *vers; - proc_list *proc; - - puldefine(def->def_name, def->def.pr.prog_num); - for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { - puldefine(vers->vers_name, vers->vers_num); - for (proc = vers->procs; proc != NULL; proc = proc->next) { - if (!define_printed(proc, def->def.pr.versions)) { - puldefine(proc->proc_name, proc->proc_num); - } - pprocdef(proc, vers); - } - } -} - - -pprocdef(proc, vp) - proc_list *proc; - version_list *vp; -{ - f_print(fout, "extern "); - if (proc->res_prefix) { - if (streq(proc->res_prefix, "enum")) { - f_print(fout, "enum "); - } else { - f_print(fout, "struct "); - } - } - if (streq(proc->res_type, "bool")) { - f_print(fout, "bool_t *"); - } else if (streq(proc->res_type, "string")) { - f_print(fout, "char **"); - } else { - f_print(fout, "%s *", fixtype(proc->res_type)); - } - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "();\n"); -} - -static -penumdef(def) - definition *def; -{ - char *name = def->def_name; - enumval_list *l; - char *last = NULL; - int count = 0; - - f_print(fout, "enum %s {\n", name); - for (l = def->def.en.vals; l != NULL; l = l->next) { - f_print(fout, "\t%s", l->name); - if (l->assignment) { - f_print(fout, " = %s", l->assignment); - last = l->assignment; - count = 1; - } else { - if (last == NULL) { - f_print(fout, " = %d", count++); - } else { - f_print(fout, " = %s + %d", last, count++); - } - } - f_print(fout, ",\n"); - } - f_print(fout, "};\n"); - f_print(fout, "typedef enum %s %s;\n", name, name); -} - -static -ptypedef(def) - definition *def; -{ - char *name = def->def_name; - char *old = def->def.ty.old_type; - char prefix[8]; /* enough to contain "struct ", including NUL */ - relation rel = def->def.ty.rel; - - - if (!streq(name, old)) { - if (streq(old, "string")) { - old = "char"; - rel = REL_POINTER; - } else if (streq(old, "opaque")) { - old = "char"; - } else if (streq(old, "bool")) { - old = "bool_t"; - } - if (undefined2(old, name) && def->def.ty.old_prefix) { - s_print(prefix, "%s ", def->def.ty.old_prefix); - } else { - prefix[0] = 0; - } - f_print(fout, "typedef "); - switch (rel) { - case REL_ARRAY: - f_print(fout, "struct {\n"); - f_print(fout, "\tu_int %s_len;\n", name); - f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name); - f_print(fout, "} %s", name); - break; - case REL_POINTER: - f_print(fout, "%s%s *%s", prefix, old, name); - break; - case REL_VECTOR: - f_print(fout, "%s%s %s[%s]", prefix, old, name, - def->def.ty.array_max); - break; - case REL_ALIAS: - f_print(fout, "%s%s %s", prefix, old, name); - break; - } - f_print(fout, ";\n"); - } -} - - -static -pdeclaration(name, dec, tab) - char *name; - declaration *dec; - int tab; -{ - char buf[8]; /* enough to hold "struct ", include NUL */ - char *prefix; - char *type; - - if (streq(dec->type, "void")) { - return; - } - tabify(fout, tab); - if (streq(dec->type, name) && !dec->prefix) { - f_print(fout, "struct "); - } - if (streq(dec->type, "string")) { - f_print(fout, "char *%s", dec->name); - } else { - prefix = ""; - if (streq(dec->type, "bool")) { - type = "bool_t"; - } else if (streq(dec->type, "opaque")) { - type = "char"; - } else { - if (dec->prefix) { - s_print(buf, "%s ", dec->prefix); - prefix = buf; - } - type = dec->type; - } - switch (dec->rel) { - case REL_ALIAS: - f_print(fout, "%s%s %s", prefix, type, dec->name); - break; - case REL_VECTOR: - f_print(fout, "%s%s %s[%s]", prefix, type, dec->name, - dec->array_max); - break; - case REL_POINTER: - f_print(fout, "%s%s *%s", prefix, type, dec->name); - break; - case REL_ARRAY: - f_print(fout, "struct {\n"); - tabify(fout, tab); - f_print(fout, "\tu_int %s_len;\n", dec->name); - tabify(fout, tab); - f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); - tabify(fout, tab); - f_print(fout, "} %s", dec->name); - break; - } - } - f_print(fout, ";\n"); -} - - - -static -undefined2(type, stop) - char *type; - char *stop; -{ - list *l; - definition *def; - - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) { - if (streq(def->def_name, stop)) { - return (1); - } else if (streq(def->def_name, type)) { - return (0); - } - } - } - return (1); -} diff --git a/lib/librpc/rpcgen/rpc_main.c b/lib/librpc/rpcgen/rpc_main.c deleted file mode 100644 index 795bf2aa5703..000000000000 --- a/lib/librpc/rpcgen/rpc_main.c +++ /dev/null @@ -1,433 +0,0 @@ -/* @(#)rpc_main.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_main.c 1.7 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_main.c, Top level of the RPC protocol compiler. - * Copyright (C) 1987, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include "rpc_util.h" -#include "rpc_parse.h" -#include "rpc_scan.h" - -#define EXTEND 1 /* alias for TRUE */ - -struct commandline { - int cflag; - int hflag; - int lflag; - int sflag; - int mflag; - char *infile; - char *outfile; -}; - -static char *cmdname; -static char CPP[] = "/lib/cpp"; -static char CPPFLAGS[] = "-C"; -static char *allv[] = { - "rpcgen", "-s", "udp", "-s", "tcp", -}; -static int allc = sizeof(allv)/sizeof(allv[0]); - -main(argc, argv) - int argc; - char *argv[]; - -{ - struct commandline cmd; - - if (!parseargs(argc, argv, &cmd)) { - f_print(stderr, - "usage: %s infile\n", cmdname); - f_print(stderr, - " %s [-c | -h | -l | -m] [-o outfile] [infile]\n", - cmdname); - f_print(stderr, - " %s [-s udp|tcp]* [-o outfile] [infile]\n", - cmdname); - exit(1); - } - if (cmd.cflag) { - c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile); - } else if (cmd.hflag) { - h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile); - } else if (cmd.lflag) { - l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile); - } else if (cmd.sflag || cmd.mflag) { - s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND, - cmd.outfile, cmd.mflag); - } else { - c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); - reinitialize(); - h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h"); - reinitialize(); - l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); - reinitialize(); - s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, - "_svc.c", cmd.mflag); - } - exit(0); -} - -/* - * add extension to filename - */ -static char * -extendfile(file, ext) - char *file; - char *ext; -{ - char *res; - char *p; - - res = alloc(strlen(file) + strlen(ext) + 1); - if (res == NULL) { - abort(); - } - p = rindex(file, '.'); - if (p == NULL) { - p = file + strlen(file); - } - (void) strcpy(res, file); - (void) strcpy(res + (p - file), ext); - return (res); -} - -/* - * Open output file with given extension - */ -static -open_output(infile, outfile) - char *infile; - char *outfile; -{ - if (outfile == NULL) { - fout = stdout; - return; - } - if (infile != NULL && streq(outfile, infile)) { - f_print(stderr, "%s: output would overwrite %s\n", cmdname, - infile); - crash(); - } - fout = fopen(outfile, "w"); - if (fout == NULL) { - f_print(stderr, "%s: unable to open ", cmdname); - perror(outfile); - crash(); - } - record_open(outfile); -} - -/* - * Open input file with given define for C-preprocessor - */ -static -open_input(infile, define) - char *infile; - char *define; -{ - int pd[2]; - - infilename = (infile == NULL) ? "" : infile; - (void) pipe(pd); - switch (fork()) { - case 0: - (void) close(1); - (void) dup2(pd[1], 1); - (void) close(pd[0]); - execl(CPP, CPP, CPPFLAGS, define, infile, NULL); - perror("execl"); - exit(1); - case -1: - perror("fork"); - exit(1); - } - (void) close(pd[1]); - fin = fdopen(pd[0], "r"); - if (fin == NULL) { - f_print(stderr, "%s: ", cmdname); - perror(infilename); - crash(); - } -} - -/* - * Compile into an XDR routine output file - */ -static -c_output(infile, define, extend, outfile) - char *infile; - char *define; - int extend; - char *outfile; -{ - definition *def; - char *include; - char *outfilename; - long tell; - - open_input(infile, define); - outfilename = extend ? extendfile(infile, outfile) : outfile; - open_output(infile, outfilename); - f_print(fout, "#include \n"); - if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); - free(include); - } - tell = ftell(fout); - while (def = get_definition()) { - emit(def); - } - if (extend && tell == ftell(fout)) { - (void) unlink(outfilename); - } -} - -/* - * Compile into an XDR header file - */ -static -h_output(infile, define, extend, outfile) - char *infile; - char *define; - int extend; - char *outfile; -{ - definition *def; - char *outfilename; - long tell; - - open_input(infile, define); - outfilename = extend ? extendfile(infile, outfile) : outfile; - open_output(infile, outfilename); - tell = ftell(fout); - while (def = get_definition()) { - print_datadef(def); - } - if (extend && tell == ftell(fout)) { - (void) unlink(outfilename); - } -} - -/* - * Compile into an RPC service - */ -static -s_output(argc, argv, infile, define, extend, outfile, nomain) - int argc; - char *argv[]; - char *infile; - char *define; - int extend; - char *outfile; - int nomain; -{ - char *include; - definition *def; - int foundprogram; - char *outfilename; - - open_input(infile, define); - outfilename = extend ? extendfile(infile, outfile) : outfile; - open_output(infile, outfilename); - f_print(fout, "#include \n"); - f_print(fout, "#include \n"); - if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); - free(include); - } - foundprogram = 0; - while (def = get_definition()) { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) { - (void) unlink(outfilename); - return; - } - if (nomain) { - write_programs((char *)NULL); - } else { - write_most(); - do_registers(argc, argv); - write_rest(); - write_programs("static"); - } -} - -static -l_output(infile, define, extend, outfile) - char *infile; - char *define; - int extend; - char *outfile; -{ - char *include; - definition *def; - int foundprogram; - char *outfilename; - - open_input(infile, define); - outfilename = extend ? extendfile(infile, outfile) : outfile; - open_output(infile, outfilename); - f_print(fout, "#include \n"); - if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); - free(include); - } - foundprogram = 0; - while (def = get_definition()) { - foundprogram |= (def->def_kind == DEF_PROGRAM); - } - if (extend && !foundprogram) { - (void) unlink(outfilename); - return; - } - write_stubs(); -} - -/* - * Perform registrations for service output - */ -static -do_registers(argc, argv) - int argc; - char *argv[]; - -{ - int i; - - for (i = 1; i < argc; i++) { - if (streq(argv[i], "-s")) { - write_register(argv[i + 1]); - i++; - } - } -} - -/* - * Parse command line arguments - */ -static -parseargs(argc, argv, cmd) - int argc; - char *argv[]; - struct commandline *cmd; - -{ - int i; - int j; - char c; - char flag[(1 << 8 * sizeof(char))]; - int nflags; - - cmdname = argv[0]; - cmd->infile = cmd->outfile = NULL; - if (argc < 2) { - return (0); - } - flag['c'] = 0; - flag['h'] = 0; - flag['s'] = 0; - flag['o'] = 0; - flag['l'] = 0; - flag['m'] = 0; - for (i = 1; i < argc; i++) { - if (argv[i][0] != '-') { - if (cmd->infile) { - return (0); - } - cmd->infile = argv[i]; - } else { - for (j = 1; argv[i][j] != 0; j++) { - c = argv[i][j]; - switch (c) { - case 'c': - case 'h': - case 'l': - case 'm': - if (flag[c]) { - return (0); - } - flag[c] = 1; - break; - case 'o': - case 's': - if (argv[i][j - 1] != '-' || - argv[i][j + 1] != 0) { - return (0); - } - flag[c] = 1; - if (++i == argc) { - return (0); - } - if (c == 's') { - if (!streq(argv[i], "udp") && - !streq(argv[i], "tcp")) { - return (0); - } - } else if (c == 'o') { - if (cmd->outfile) { - return (0); - } - cmd->outfile = argv[i]; - } - goto nextarg; - - default: - return (0); - } - } - nextarg: - ; - } - } - cmd->cflag = flag['c']; - cmd->hflag = flag['h']; - cmd->sflag = flag['s']; - cmd->lflag = flag['l']; - cmd->mflag = flag['m']; - nflags = cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag; - if (nflags == 0) { - if (cmd->outfile != NULL || cmd->infile == NULL) { - return (0); - } - } else if (nflags > 1) { - return (0); - } - return (1); -} diff --git a/lib/librpc/rpcgen/rpc_parse.c b/lib/librpc/rpcgen/rpc_parse.c deleted file mode 100644 index 9e4663fb3634..000000000000 --- a/lib/librpc/rpcgen/rpc_parse.c +++ /dev/null @@ -1,419 +0,0 @@ -/* @(#)rpc_parse.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_parse.c 1.4 87/04/28 (C) 1987 SMI"; -#endif - -/* - * rpc_parse.c, Parser for the RPC protocol compiler - * Copyright (C) 1987 Sun Microsystems, Inc. - */ -#include -#include "rpc_util.h" -#include "rpc_scan.h" -#include "rpc_parse.h" - -/* - * return the next definition you see - */ -definition * -get_definition() -{ - definition *defp; - token tok; - - defp = ALLOC(definition); - get_token(&tok); - switch (tok.kind) { - case TOK_STRUCT: - def_struct(defp); - break; - case TOK_UNION: - def_union(defp); - break; - case TOK_TYPEDEF: - def_typedef(defp); - break; - case TOK_ENUM: - def_enum(defp); - break; - case TOK_PROGRAM: - def_program(defp); - break; - case TOK_CONST: - def_const(defp); - break; - case TOK_EOF: - return (NULL); - break; - default: - error("definition keyword expected"); - } - scan(TOK_SEMICOLON, &tok); - isdefined(defp); - return (defp); -} - -static -isdefined(defp) - definition *defp; -{ - STOREVAL(&defined, defp); -} - - -static -def_struct(defp) - definition *defp; -{ - token tok; - declaration dec; - decl_list *decls; - decl_list **tailp; - - defp->def_kind = DEF_STRUCT; - - scan(TOK_IDENT, &tok); - defp->def_name = tok.str; - scan(TOK_LBRACE, &tok); - tailp = &defp->def.st.decls; - do { - get_declaration(&dec, DEF_STRUCT); - decls = ALLOC(decl_list); - decls->decl = dec; - *tailp = decls; - tailp = &decls->next; - scan(TOK_SEMICOLON, &tok); - peek(&tok); - } while (tok.kind != TOK_RBRACE); - get_token(&tok); - *tailp = NULL; -} - -static -def_program(defp) - definition *defp; -{ - token tok; - version_list *vlist; - version_list **vtailp; - proc_list *plist; - proc_list **ptailp; - - defp->def_kind = DEF_PROGRAM; - scan(TOK_IDENT, &tok); - defp->def_name = tok.str; - scan(TOK_LBRACE, &tok); - vtailp = &defp->def.pr.versions; - scan(TOK_VERSION, &tok); - do { - scan(TOK_IDENT, &tok); - vlist = ALLOC(version_list); - vlist->vers_name = tok.str; - scan(TOK_LBRACE, &tok); - ptailp = &vlist->procs; - do { - plist = ALLOC(proc_list); - get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM); - if (streq(plist->res_type, "opaque")) { - error("illegal result type"); - } - scan(TOK_IDENT, &tok); - plist->proc_name = tok.str; - scan(TOK_LPAREN, &tok); - get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM); - if (streq(plist->arg_type, "opaque")) { - error("illegal argument type"); - } - scan(TOK_RPAREN, &tok); - scan(TOK_EQUAL, &tok); - scan_num(&tok); - scan(TOK_SEMICOLON, &tok); - plist->proc_num = tok.str; - *ptailp = plist; - ptailp = &plist->next; - peek(&tok); - } while (tok.kind != TOK_RBRACE); - *vtailp = vlist; - vtailp = &vlist->next; - scan(TOK_RBRACE, &tok); - scan(TOK_EQUAL, &tok); - scan_num(&tok); - vlist->vers_num = tok.str; - scan(TOK_SEMICOLON, &tok); - scan2(TOK_VERSION, TOK_RBRACE, &tok); - } while (tok.kind == TOK_VERSION); - scan(TOK_EQUAL, &tok); - scan_num(&tok); - defp->def.pr.prog_num = tok.str; - *vtailp = NULL; -} - -static -def_enum(defp) - definition *defp; -{ - token tok; - enumval_list *elist; - enumval_list **tailp; - - defp->def_kind = DEF_ENUM; - scan(TOK_IDENT, &tok); - defp->def_name = tok.str; - scan(TOK_LBRACE, &tok); - tailp = &defp->def.en.vals; - do { - scan(TOK_IDENT, &tok); - elist = ALLOC(enumval_list); - elist->name = tok.str; - elist->assignment = NULL; - scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok); - if (tok.kind == TOK_EQUAL) { - scan_num(&tok); - elist->assignment = tok.str; - scan2(TOK_COMMA, TOK_RBRACE, &tok); - } - *tailp = elist; - tailp = &elist->next; - } while (tok.kind != TOK_RBRACE); - *tailp = NULL; -} - -static -def_const(defp) - definition *defp; -{ - token tok; - - defp->def_kind = DEF_CONST; - scan(TOK_IDENT, &tok); - defp->def_name = tok.str; - scan(TOK_EQUAL, &tok); - scan2(TOK_IDENT, TOK_STRCONST, &tok); - defp->def.co = tok.str; -} - -static -def_union(defp) - definition *defp; -{ - token tok; - declaration dec; - case_list *cases; - case_list **tailp; - - defp->def_kind = DEF_UNION; - scan(TOK_IDENT, &tok); - defp->def_name = tok.str; - scan(TOK_SWITCH, &tok); - scan(TOK_LPAREN, &tok); - get_declaration(&dec, DEF_UNION); - defp->def.un.enum_decl = dec; - tailp = &defp->def.un.cases; - scan(TOK_RPAREN, &tok); - scan(TOK_LBRACE, &tok); - scan(TOK_CASE, &tok); - while (tok.kind == TOK_CASE) { - scan(TOK_IDENT, &tok); - cases = ALLOC(case_list); - cases->case_name = tok.str; - scan(TOK_COLON, &tok); - get_declaration(&dec, DEF_UNION); - cases->case_decl = dec; - *tailp = cases; - tailp = &cases->next; - scan(TOK_SEMICOLON, &tok); - scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok); - } - *tailp = NULL; - if (tok.kind == TOK_DEFAULT) { - scan(TOK_COLON, &tok); - get_declaration(&dec, DEF_UNION); - defp->def.un.default_decl = ALLOC(declaration); - *defp->def.un.default_decl = dec; - scan(TOK_SEMICOLON, &tok); - scan(TOK_RBRACE, &tok); - } else { - defp->def.un.default_decl = NULL; - } -} - - -static -def_typedef(defp) - definition *defp; -{ - declaration dec; - - defp->def_kind = DEF_TYPEDEF; - get_declaration(&dec, DEF_TYPEDEF); - defp->def_name = dec.name; - defp->def.ty.old_prefix = dec.prefix; - defp->def.ty.old_type = dec.type; - defp->def.ty.rel = dec.rel; - defp->def.ty.array_max = dec.array_max; -} - - -static -get_declaration(dec, dkind) - declaration *dec; - defkind dkind; -{ - token tok; - - get_type(&dec->prefix, &dec->type, dkind); - dec->rel = REL_ALIAS; - if (streq(dec->type, "void")) { - return; - } - scan2(TOK_STAR, TOK_IDENT, &tok); - if (tok.kind == TOK_STAR) { - dec->rel = REL_POINTER; - scan(TOK_IDENT, &tok); - } - dec->name = tok.str; - if (peekscan(TOK_LBRACKET, &tok)) { - if (dec->rel == REL_POINTER) { - error("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_VECTOR; - scan_num(&tok); - dec->array_max = tok.str; - scan(TOK_RBRACKET, &tok); - } else if (peekscan(TOK_LANGLE, &tok)) { - if (dec->rel == REL_POINTER) { - error("no array-of-pointer declarations -- use typedef"); - } - dec->rel = REL_ARRAY; - if (peekscan(TOK_RANGLE, &tok)) { - dec->array_max = "~0"; /* unspecified size, use max */ - } else { - scan_num(&tok); - dec->array_max = tok.str; - scan(TOK_RANGLE, &tok); - } - } - if (streq(dec->type, "opaque")) { - if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) { - error("array declaration expected"); - } - } else if (streq(dec->type, "string")) { - if (dec->rel != REL_ARRAY) { - error("variable-length array declaration expected"); - } - } -} - - -static -get_type(prefixp, typep, dkind) - char **prefixp; - char **typep; - defkind dkind; -{ - token tok; - - *prefixp = NULL; - get_token(&tok); - switch (tok.kind) { - case TOK_IDENT: - *typep = tok.str; - break; - case TOK_STRUCT: - case TOK_ENUM: - case TOK_UNION: - *prefixp = tok.str; - scan(TOK_IDENT, &tok); - *typep = tok.str; - break; - case TOK_UNSIGNED: - unsigned_dec(typep); - break; - case TOK_SHORT: - *typep = "short"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_LONG: - *typep = "long"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_VOID: - if (dkind != DEF_UNION && dkind != DEF_PROGRAM) { - error("voids allowed only inside union and program definitions"); - } - *typep = tok.str; - break; - case TOK_STRING: - case TOK_OPAQUE: - case TOK_CHAR: - case TOK_INT: - case TOK_FLOAT: - case TOK_DOUBLE: - case TOK_BOOL: - *typep = tok.str; - break; - default: - error("expected type specifier"); - } -} - - -static -unsigned_dec(typep) - char **typep; -{ - token tok; - - peek(&tok); - switch (tok.kind) { - case TOK_CHAR: - get_token(&tok); - *typep = "u_char"; - break; - case TOK_SHORT: - get_token(&tok); - *typep = "u_short"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_LONG: - get_token(&tok); - *typep = "u_long"; - (void) peekscan(TOK_INT, &tok); - break; - case TOK_INT: - get_token(&tok); - *typep = "u_int"; - break; - default: - *typep = "u_int"; - break; - } -} diff --git a/lib/librpc/rpcgen/rpc_parse.h b/lib/librpc/rpcgen/rpc_parse.h deleted file mode 100644 index b53cc56ff833..000000000000 --- a/lib/librpc/rpcgen/rpc_parse.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)rpc_parse.h 1.3 87/03/09 (C) 1987 SMI */ - -/* - * rpc_parse.h, Definitions for the RPCL parser - * Copyright (C) 1987, Sun Microsystems, Inc. - */ - -enum defkind { - DEF_CONST, - DEF_STRUCT, - DEF_UNION, - DEF_ENUM, - DEF_TYPEDEF, - DEF_PROGRAM -}; -typedef enum defkind defkind; - -typedef char *const_def; - -enum relation { - REL_VECTOR, /* fixed length array */ - REL_ARRAY, /* variable length array */ - REL_POINTER, /* pointer */ - REL_ALIAS, /* simple */ -}; -typedef enum relation relation; - -struct typedef_def { - char *old_prefix; - char *old_type; - relation rel; - char *array_max; -}; -typedef struct typedef_def typedef_def; - - -struct enumval_list { - char *name; - char *assignment; - struct enumval_list *next; -}; -typedef struct enumval_list enumval_list; - -struct enum_def { - enumval_list *vals; -}; -typedef struct enum_def enum_def; - - -struct declaration { - char *prefix; - char *type; - char *name; - relation rel; - char *array_max; -}; -typedef struct declaration declaration; - - -struct decl_list { - declaration decl; - struct decl_list *next; -}; -typedef struct decl_list decl_list; - -struct struct_def { - decl_list *decls; -}; -typedef struct struct_def struct_def; - - -struct case_list { - char *case_name; - declaration case_decl; - struct case_list *next; -}; -typedef struct case_list case_list; - -struct union_def { - declaration enum_decl; - case_list *cases; - declaration *default_decl; -}; -typedef struct union_def union_def; - - - -struct proc_list { - char *proc_name; - char *proc_num; - char *arg_type; - char *arg_prefix; - char *res_type; - char *res_prefix; - struct proc_list *next; -}; -typedef struct proc_list proc_list; - - -struct version_list { - char *vers_name; - char *vers_num; - proc_list *procs; - struct version_list *next; -}; -typedef struct version_list version_list; - -struct program_def { - char *prog_num; - version_list *versions; -}; -typedef struct program_def program_def; - -struct definition { - char *def_name; - defkind def_kind; - union { - const_def co; - struct_def st; - union_def un; - enum_def en; - typedef_def ty; - program_def pr; - } def; -}; -typedef struct definition definition; - -/* @(#)rpc_parse.h 2.1 88/08/01 4.0 RPCSRC */ -definition *get_definition(); diff --git a/lib/librpc/rpcgen/rpc_scan.c b/lib/librpc/rpcgen/rpc_scan.c deleted file mode 100644 index e46a1b5f2b0e..000000000000 --- a/lib/librpc/rpcgen/rpc_scan.c +++ /dev/null @@ -1,473 +0,0 @@ -/* @(#)rpc_scan.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_scan.c 1.6 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_scan.c, Scanner for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include -#include "rpc_scan.h" -#include "rpc_util.h" - -#define startcomment(where) (where[0] == '/' && where[1] == '*') -#define endcomment(where) (where[-1] == '*' && where[0] == '/') - -static int pushed = 0; /* is a token pushed */ -static token lasttok; /* last token, if pushed */ - -/* - * scan expecting 1 given token - */ -void -scan(expect, tokp) - tok_kind expect; - token *tokp; -{ - get_token(tokp); - if (tokp->kind != expect) { - expected1(expect); - } -} - -/* - * scan expecting 2 given tokens - */ -void -scan2(expect1, expect2, tokp) - tok_kind expect1; - tok_kind expect2; - token *tokp; -{ - get_token(tokp); - if (tokp->kind != expect1 && tokp->kind != expect2) { - expected2(expect1, expect2); - } -} - -/* - * scan expecting 3 given token - */ -void -scan3(expect1, expect2, expect3, tokp) - tok_kind expect1; - tok_kind expect2; - tok_kind expect3; - token *tokp; -{ - get_token(tokp); - if (tokp->kind != expect1 && tokp->kind != expect2 - && tokp->kind != expect3) { - expected3(expect1, expect2, expect3); - } -} - - -/* - * scan expecting a constant, possibly symbolic - */ -void -scan_num(tokp) - token *tokp; -{ - get_token(tokp); - switch (tokp->kind) { - case TOK_IDENT: - break; - default: - error("constant or identifier expected"); - } -} - - -/* - * Peek at the next token - */ -void -peek(tokp) - token *tokp; -{ - get_token(tokp); - unget_token(tokp); -} - - -/* - * Peek at the next token and scan it if it matches what you expect - */ -int -peekscan(expect, tokp) - tok_kind expect; - token *tokp; -{ - peek(tokp); - if (tokp->kind == expect) { - get_token(tokp); - return (1); - } - return (0); -} - - - -/* - * Get the next token, printing out any directive that are encountered. - */ -void -get_token(tokp) - token *tokp; -{ - int commenting; - - if (pushed) { - pushed = 0; - *tokp = lasttok; - return; - } - commenting = 0; - for (;;) { - if (*where == 0) { - for (;;) { - if (!fgets(curline, MAXLINESIZE, fin)) { - tokp->kind = TOK_EOF; - *where = 0; - return; - } - linenum++; - if (commenting) { - break; - } else if (cppline(curline)) { - docppline(curline, &linenum, - &infilename); - } else if (directive(curline)) { - printdirective(curline); - } else { - break; - } - } - where = curline; - } else if (isspace(*where)) { - while (isspace(*where)) { - where++; /* eat */ - } - } else if (commenting) { - where++; - if (endcomment(where)) { - where++; - commenting--; - } - } else if (startcomment(where)) { - where += 2; - commenting++; - } else { - break; - } - } - - /* - * 'where' is not whitespace, comment or directive Must be a token! - */ - switch (*where) { - case ':': - tokp->kind = TOK_COLON; - where++; - break; - case ';': - tokp->kind = TOK_SEMICOLON; - where++; - break; - case ',': - tokp->kind = TOK_COMMA; - where++; - break; - case '=': - tokp->kind = TOK_EQUAL; - where++; - break; - case '*': - tokp->kind = TOK_STAR; - where++; - break; - case '[': - tokp->kind = TOK_LBRACKET; - where++; - break; - case ']': - tokp->kind = TOK_RBRACKET; - where++; - break; - case '{': - tokp->kind = TOK_LBRACE; - where++; - break; - case '}': - tokp->kind = TOK_RBRACE; - where++; - break; - case '(': - tokp->kind = TOK_LPAREN; - where++; - break; - case ')': - tokp->kind = TOK_RPAREN; - where++; - break; - case '<': - tokp->kind = TOK_LANGLE; - where++; - break; - case '>': - tokp->kind = TOK_RANGLE; - where++; - break; - - case '"': - tokp->kind = TOK_STRCONST; - findstrconst(&where, &tokp->str); - break; - - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - tokp->kind = TOK_IDENT; - findconst(&where, &tokp->str); - break; - - - default: - if (!(isalpha(*where) || *where == '_')) { - char buf[100]; - char *p; - - s_print(buf, "illegal character in file: "); - p = buf + strlen(buf); - if (isprint(*where)) { - s_print(p, "%c", *where); - } else { - s_print(p, "%d", *where); - } - error(buf); - } - findkind(&where, tokp); - break; - } -} - - - -static -unget_token(tokp) - token *tokp; -{ - lasttok = *tokp; - pushed = 1; -} - - -static -findstrconst(str, val) - char **str; - char **val; -{ - char *p; - int size; - - p = *str; - do { - *p++; - } while (*p && *p != '"'); - if (*p == 0) { - error("unterminated string constant"); - } - p++; - size = p - *str; - *val = alloc(size + 1); - (void) strncpy(*val, *str, size); - (*val)[size] = 0; - *str = p; -} - -static -findconst(str, val) - char **str; - char **val; -{ - char *p; - int size; - - p = *str; - if (*p == '0' && *(p + 1) == 'x') { - p++; - do { - p++; - } while (isxdigit(*p)); - } else { - do { - p++; - } while (isdigit(*p)); - } - size = p - *str; - *val = alloc(size + 1); - (void) strncpy(*val, *str, size); - (*val)[size] = 0; - *str = p; -} - - - -static token symbols[] = { - {TOK_CONST, "const"}, - {TOK_UNION, "union"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_STRUCT, "struct"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_ENUM, "enum"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_CHAR, "char"}, - {TOK_INT, "int"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_FLOAT, "float"}, - {TOK_DOUBLE, "double"}, - {TOK_STRING, "string"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"}, -}; - - -static -findkind(mark, tokp) - char **mark; - token *tokp; -{ - - int len; - token *s; - char *str; - - str = *mark; - for (s = symbols; s->kind != TOK_EOF; s++) { - len = strlen(s->str); - if (strncmp(str, s->str, len) == 0) { - if (!isalnum(str[len]) && str[len] != '_') { - tokp->kind = s->kind; - tokp->str = s->str; - *mark = str + len; - return; - } - } - } - tokp->kind = TOK_IDENT; - for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); - tokp->str = alloc(len + 1); - (void) strncpy(tokp->str, str, len); - tokp->str[len] = 0; - *mark = str + len; -} - -static -cppline(line) - char *line; -{ - return (line == curline && *line == '#'); -} - -static -directive(line) - char *line; -{ - return (line == curline && *line == '%'); -} - -static -printdirective(line) - char *line; -{ - f_print(fout, "%s", line + 1); -} - -static -docppline(line, lineno, fname) - char *line; - int *lineno; - char **fname; -{ - char *file; - int num; - char *p; - - line++; - while (isspace(*line)) { - line++; - } - num = atoi(line); - while (isdigit(*line)) { - line++; - } - while (isspace(*line)) { - line++; - } - if (*line != '"') { - error("preprocessor error"); - } - line++; - p = file = alloc(strlen(line) + 1); - while (*line && *line != '"') { - *p++ = *line++; - } - if (*line == 0) { - error("preprocessor error"); - } - *p = 0; - if (*file == 0) { - *fname = NULL; - } else { - *fname = file; - } - *lineno = num - 1; -} diff --git a/lib/librpc/rpcgen/rpc_scan.h b/lib/librpc/rpcgen/rpc_scan.h deleted file mode 100644 index ad243d59c152..000000000000 --- a/lib/librpc/rpcgen/rpc_scan.h +++ /dev/null @@ -1,101 +0,0 @@ -/* @(#)rpc_scan.h 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)rpc_scan.h 1.3 87/03/09 (C) 1987 SMI */ - -/* - * rpc_scan.h, Definitions for the RPCL scanner - * Copyright (C) 1987, Sun Microsystems, Inc. - */ - -/* - * kinds of tokens - */ -enum tok_kind { - TOK_IDENT, - TOK_STRCONST, - TOK_LPAREN, - TOK_RPAREN, - TOK_LBRACE, - TOK_RBRACE, - TOK_LBRACKET, - TOK_RBRACKET, - TOK_LANGLE, - TOK_RANGLE, - TOK_STAR, - TOK_COMMA, - TOK_EQUAL, - TOK_COLON, - TOK_SEMICOLON, - TOK_CONST, - TOK_STRUCT, - TOK_UNION, - TOK_SWITCH, - TOK_CASE, - TOK_DEFAULT, - TOK_ENUM, - TOK_TYPEDEF, - TOK_INT, - TOK_SHORT, - TOK_LONG, - TOK_UNSIGNED, - TOK_FLOAT, - TOK_DOUBLE, - TOK_OPAQUE, - TOK_CHAR, - TOK_STRING, - TOK_BOOL, - TOK_VOID, - TOK_PROGRAM, - TOK_VERSION, - TOK_EOF -}; -typedef enum tok_kind tok_kind; - -/* - * a token - */ -struct token { - tok_kind kind; - char *str; -}; -typedef struct token token; - - -/* - * routine interface - */ -void scanprint(); -void scan(); -void scan2(); -void scan3(); -void scan_num(); -void peek(); -int peekscan(); -void get_token(); diff --git a/lib/librpc/rpcgen/rpc_svcout.c b/lib/librpc/rpcgen/rpc_svcout.c deleted file mode 100644 index 7289b0da6e1f..000000000000 --- a/lib/librpc/rpcgen/rpc_svcout.c +++ /dev/null @@ -1,275 +0,0 @@ -/* @(#)rpc_svcout.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_svcout.c 1.6 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsytsems, Inc. - */ -#include -#include -#include "rpc_parse.h" -#include "rpc_util.h" - -static char RQSTP[] = "rqstp"; -static char TRANSP[] = "transp"; -static char ARG[] = "argument"; -static char RESULT[] = "result"; -static char ROUTINE[] = "local"; - - -/* - * write most of the service, that is, everything but the registrations. - */ -void -write_most() -{ - list *l; - definition *def; - version_list *vp; - - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) { - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\nstatic void "); - pvname(def->def_name, vp->vers_num); - f_print(fout, "();"); - } - } - } - f_print(fout, "\n\n"); - f_print(fout, "main()\n"); - f_print(fout, "{\n"); - f_print(fout, "\tSVCXPRT *%s;\n", TRANSP); - f_print(fout, "\n"); - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\t(void)pmap_unset(%s, %s);\n", def->def_name, vp->vers_name); - } - } -} - - -/* - * write a registration for the given transport - */ -void -write_register(transp) - char *transp; -{ - list *l; - definition *def; - version_list *vp; - - f_print(fout, "\n"); - f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp); - if (streq(transp, "tcp")) { - f_print(fout, ", 0, 0"); - } - f_print(fout, ");\n"); - f_print(fout, "\tif (%s == NULL) {\n", TRANSP); - f_print(fout, "\t\t(void)fprintf(stderr, \"cannot create %s service.\\n\");\n", transp); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t}\n"); - - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind != DEF_PROGRAM) { - continue; - } - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, - "\tif (!svc_register(%s, %s, %s, ", - TRANSP, def->def_name, vp->vers_name); - pvname(def->def_name, vp->vers_num); - f_print(fout, ", IPPROTO_%s)) {\n", - streq(transp, "udp") ? "UDP" : "TCP"); - f_print(fout, - "\t\t(void)fprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n", - def->def_name, vp->vers_name, transp); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t}\n"); - } - } -} - - -/* - * write the rest of the service - */ -void -write_rest() -{ - f_print(fout, "\tsvc_run();\n"); - f_print(fout, "\t(void)fprintf(stderr, \"svc_run returned\\n\");\n"); - f_print(fout, "\texit(1);\n"); - f_print(fout, "}\n"); -} - -void -write_programs(storage) - char *storage; -{ - list *l; - definition *def; - - for (l = defined; l != NULL; l = l->next) { - def = (definition *) l->val; - if (def->def_kind == DEF_PROGRAM) { - write_program(def, storage); - } - } -} - - -static -write_program(def, storage) - definition *def; - char *storage; -{ - version_list *vp; - proc_list *proc; - int filled; - - for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\n"); - if (storage != NULL) { - f_print(fout, "%s ", storage); - } - f_print(fout, "void\n"); - pvname(def->def_name, vp->vers_num); - f_print(fout, "(%s, %s)\n", RQSTP, TRANSP); - f_print(fout, " struct svc_req *%s;\n", RQSTP); - f_print(fout, " SVCXPRT *%s;\n", TRANSP); - f_print(fout, "{\n"); - - filled = 0; - f_print(fout, "\tunion {\n"); - for (proc = vp->procs; proc != NULL; proc = proc->next) { - if (streq(proc->arg_type, "void")) { - continue; - } - filled = 1; - f_print(fout, "\t\t"); - ptype(proc->arg_prefix, proc->arg_type, 0); - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_arg;\n"); - } - if (!filled) { - f_print(fout, "\t\tint fill;\n"); - } - f_print(fout, "\t} %s;\n", ARG); - f_print(fout, "\tchar *%s;\n", RESULT); - f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT); - f_print(fout, "\tchar *(*%s)();\n", ROUTINE); - f_print(fout, "\n"); - f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP); - - if (!nullproc(vp->procs)) { - f_print(fout, "\tcase NULLPROC:\n"); - f_print(fout, "\t\t(void)svc_sendreply(%s, xdr_void, (char *)NULL);\n", TRANSP); - f_print(fout, "\t\treturn;\n\n"); - } - for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\tcase %s:\n", proc->proc_name); - f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG, - stringfix(proc->arg_type)); - f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT, - stringfix(proc->res_type)); - f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE); - pvname(proc->proc_name, vp->vers_num); - f_print(fout, ";\n"); - f_print(fout, "\t\tbreak;\n\n"); - } - f_print(fout, "\tdefault:\n"); - printerr("noproc", TRANSP); - f_print(fout, "\t\treturn;\n"); - f_print(fout, "\t}\n"); - - f_print(fout, "\tbzero((char *)&%s, sizeof(%s));\n", ARG, ARG); - printif("getargs", TRANSP, "&", ARG); - printerr("decode", TRANSP); - f_print(fout, "\t\treturn;\n"); - f_print(fout, "\t}\n"); - - f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG, - RQSTP); - f_print(fout, - "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", - RESULT, TRANSP, RESULT, RESULT); - printerr("systemerr", TRANSP); - f_print(fout, "\t}\n"); - - printif("freeargs", TRANSP, "&", ARG); - f_print(fout, "\t\t(void)fprintf(stderr, \"unable to free arguments\\n\");\n"); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t}\n"); - - f_print(fout, "}\n\n"); - } -} - -static -printerr(err, transp) - char *err; - char *transp; -{ - f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp); -} - -static -printif(proc, transp, prefix, arg) - char *proc; - char *transp; - char *prefix; - char *arg; -{ - f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", - proc, transp, arg, prefix, arg); -} - - -nullproc(proc) - proc_list *proc; -{ - for (; proc != NULL; proc = proc->next) { - if (streq(proc->proc_num, "0")) { - return (1); - } - } - return (0); -} diff --git a/lib/librpc/rpcgen/rpc_util.c b/lib/librpc/rpcgen/rpc_util.c deleted file mode 100644 index 8136535b2f9d..000000000000 --- a/lib/librpc/rpcgen/rpc_util.c +++ /dev/null @@ -1,436 +0,0 @@ -/* @(#)rpc_util.c 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#ifndef lint -static char sccsid[] = "@(#)rpc_util.c 1.5 87/06/24 (C) 1987 SMI"; -#endif - -/* - * rpc_util.c, Utility routines for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include "rpc_scan.h" -#include "rpc_parse.h" -#include "rpc_util.h" - -char curline[MAXLINESIZE]; /* current read line */ -char *where = curline; /* current point in line */ -int linenum = 0; /* current line number */ - -char *infilename; /* input filename */ - -#define NFILES 4 -char *outfiles[NFILES]; /* output file names */ -int nfiles; - -FILE *fout; /* file pointer of current output */ -FILE *fin; /* file pointer of current input */ - -list *defined; /* list of defined things */ - -/* - * Reinitialize the world - */ -reinitialize() -{ - bzero(curline, MAXLINESIZE); - where = curline; - linenum = 0; - defined = NULL; -} - -/* - * string equality - */ -streq(a, b) - char *a; - char *b; -{ - return (strcmp(a, b) == 0); -} - -/* - * find a value in a list - */ -char * -findval(lst, val, cmp) - list *lst; - char *val; - int (*cmp) (); - -{ - for (; lst != NULL; lst = lst->next) { - if ((*cmp) (lst->val, val)) { - return (lst->val); - } - } - return (NULL); -} - -/* - * store a value in a list - */ -void -storeval(lstp, val) - list **lstp; - char *val; -{ - list **l; - list *lst; - - for (l = lstp; *l != NULL; l = (list **) & (*l)->next); - lst = ALLOC(list); - lst->val = val; - lst->next = NULL; - *l = lst; -} - - -static -findit(def, type) - definition *def; - char *type; -{ - return (streq(def->def_name, type)); -} - - -static char * -fixit(type, orig) - char *type; - char *orig; -{ - definition *def; - - def = (definition *) FINDVAL(defined, type, findit); - if (def == NULL || def->def_kind != DEF_TYPEDEF) { - return (orig); - } - switch (def->def.ty.rel) { - case REL_VECTOR: - return (def->def.ty.old_type); - case REL_ALIAS: - return (fixit(def->def.ty.old_type, orig)); - default: - return (orig); - } -} - -char * -fixtype(type) - char *type; -{ - return (fixit(type, type)); -} - -char * -stringfix(type) - char *type; -{ - if (streq(type, "string")) { - return ("wrapstring"); - } else { - return (type); - } -} - -void -ptype(prefix, type, follow) - char *prefix; - char *type; - int follow; -{ - if (prefix != NULL) { - if (streq(prefix, "enum")) { - f_print(fout, "enum "); - } else { - f_print(fout, "struct "); - } - } - if (streq(type, "bool")) { - f_print(fout, "bool_t "); - } else if (streq(type, "string")) { - f_print(fout, "char *"); - } else { - f_print(fout, "%s ", follow ? fixtype(type) : type); - } -} - - -static -typedefed(def, type) - definition *def; - char *type; -{ - if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) { - return (0); - } else { - return (streq(def->def_name, type)); - } -} - -isvectordef(type, rel) - char *type; - relation rel; -{ - definition *def; - - for (;;) { - switch (rel) { - case REL_VECTOR: - return (!streq(type, "string")); - case REL_ARRAY: - return (0); - case REL_POINTER: - return (0); - case REL_ALIAS: - def = (definition *) FINDVAL(defined, type, typedefed); - if (def == NULL) { - return (0); - } - type = def->def.ty.old_type; - rel = def->def.ty.rel; - } - } -} - - -static char * -locase(str) - char *str; -{ - char c; - static char buf[100]; - char *p = buf; - - while (c = *str++) { - *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; - } - *p = 0; - return (buf); -} - - -void -pvname(pname, vnum) - char *pname; - char *vnum; -{ - f_print(fout, "%s_%s", locase(pname), vnum); -} - - -/* - * print a useful (?) error message, and then die - */ -void -error(msg) - char *msg; -{ - printwhere(); - f_print(stderr, "%s, line %d: ", infilename, linenum); - f_print(stderr, "%s\n", msg); - crash(); -} - -/* - * Something went wrong, unlink any files that we may have created and then - * die. - */ -crash() -{ - int i; - - for (i = 0; i < nfiles; i++) { - (void) unlink(outfiles[i]); - } - exit(1); -} - - -void -record_open(file) - char *file; -{ - if (nfiles < NFILES) { - outfiles[nfiles++] = file; - } else { - f_print(stderr, "too many files!\n"); - crash(); - } -} - -static char expectbuf[100]; -static char *toktostr(); - -/* - * error, token encountered was not the expected one - */ -void -expected1(exp1) - tok_kind exp1; -{ - s_print(expectbuf, "expected '%s'", - toktostr(exp1)); - error(expectbuf); -} - -/* - * error, token encountered was not one of two expected ones - */ -void -expected2(exp1, exp2) - tok_kind exp1, exp2; -{ - s_print(expectbuf, "expected '%s' or '%s'", - toktostr(exp1), - toktostr(exp2)); - error(expectbuf); -} - -/* - * error, token encountered was not one of 3 expected ones - */ -void -expected3(exp1, exp2, exp3) - tok_kind exp1, exp2, exp3; -{ - s_print(expectbuf, "expected '%s', '%s' or '%s'", - toktostr(exp1), - toktostr(exp2), - toktostr(exp3)); - error(expectbuf); -} - -void -tabify(f, tab) - FILE *f; - int tab; -{ - while (tab--) { - (void) fputc('\t', f); - } -} - - - -static token tokstrings[] = { - {TOK_IDENT, "identifier"}, - {TOK_CONST, "const"}, - {TOK_RPAREN, ")"}, - {TOK_LPAREN, "("}, - {TOK_RBRACE, "}"}, - {TOK_LBRACE, "{"}, - {TOK_LBRACKET, "["}, - {TOK_RBRACKET, "]"}, - {TOK_STAR, "*"}, - {TOK_COMMA, ","}, - {TOK_EQUAL, "="}, - {TOK_COLON, ":"}, - {TOK_SEMICOLON, ";"}, - {TOK_UNION, "union"}, - {TOK_STRUCT, "struct"}, - {TOK_SWITCH, "switch"}, - {TOK_CASE, "case"}, - {TOK_DEFAULT, "default"}, - {TOK_ENUM, "enum"}, - {TOK_TYPEDEF, "typedef"}, - {TOK_INT, "int"}, - {TOK_SHORT, "short"}, - {TOK_LONG, "long"}, - {TOK_UNSIGNED, "unsigned"}, - {TOK_DOUBLE, "double"}, - {TOK_FLOAT, "float"}, - {TOK_CHAR, "char"}, - {TOK_STRING, "string"}, - {TOK_OPAQUE, "opaque"}, - {TOK_BOOL, "bool"}, - {TOK_VOID, "void"}, - {TOK_PROGRAM, "program"}, - {TOK_VERSION, "version"}, - {TOK_EOF, "??????"} -}; - -static char * -toktostr(kind) - tok_kind kind; -{ - token *sp; - - for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++); - return (sp->str); -} - - - -static -printbuf() -{ - char c; - int i; - int cnt; - -# define TABSIZE 4 - - for (i = 0; c = curline[i]; i++) { - if (c == '\t') { - cnt = 8 - (i % TABSIZE); - c = ' '; - } else { - cnt = 1; - } - while (cnt--) { - (void) fputc(c, stderr); - } - } -} - - -static -printwhere() -{ - int i; - char c; - int cnt; - - printbuf(); - for (i = 0; i < where - curline; i++) { - c = curline[i]; - if (c == '\t') { - cnt = 8 - (i % TABSIZE); - } else { - cnt = 1; - } - while (cnt--) { - (void) fputc('^', stderr); - } - } - (void) fputc('\n', stderr); -} diff --git a/lib/librpc/rpcgen/rpc_util.h b/lib/librpc/rpcgen/rpc_util.h deleted file mode 100644 index f4525a04410f..000000000000 --- a/lib/librpc/rpcgen/rpc_util.h +++ /dev/null @@ -1,114 +0,0 @@ -/* @(#)rpc_util.h 2.1 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)rpc_util.h 1.6 87/06/24 (C) 1987 SMI */ - -/* - * rpc_util.h, Useful definitions for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -extern char *malloc(); - -#define alloc(size) malloc((unsigned)(size)) -#define ALLOC(object) (object *) malloc(sizeof(object)) - -extern char *sprintf(); - -#define s_print (void) sprintf -#define f_print (void) fprintf - -struct list { - char *val; - struct list *next; -}; -typedef struct list list; - -/* - * Global variables - */ -#define MAXLINESIZE 1024 -extern char curline[MAXLINESIZE]; -extern char *where; -extern int linenum; - -extern char *infilename; -extern FILE *fout; -extern FILE *fin; - -extern list *defined; - -/* - * rpc_util routines - */ -void storeval(); - -#define STOREVAL(list,item) \ - storeval(list,(char *)item) - -char *findval(); - -#define FINDVAL(list,item,finder) \ - findval(list, (char *) item, finder) - -char *fixtype(); -char *stringfix(); -void pvname(); -void ptype(); -int isvectordef(); -int streq(); -void error(); -void expected1(); -void expected2(); -void expected3(); -void tabify(); -void record_open(); - -/* - * rpc_cout routines - */ -void cprint(); -void emit(); - -/* - * rpc_hout routines - */ -void print_datadef(); - -/* - * rpc_svcout routines - */ -void write_most(); -void write_register(); -void write_rest(); -void write_programs(); - -/* - * rpc_clntout routines - */ -void write_stubs(); diff --git a/lib/librpc/rpcsvc/Makefile b/lib/librpc/rpcsvc/Makefile deleted file mode 100644 index 690d945d5e54..000000000000 --- a/lib/librpc/rpcsvc/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -# -# @(#)Makefile 2.3 88/08/11 4.0 RPCSRC -# -# -RPCCOM = rpcgen -LIB = -lrpclib - -DESTDIR= -CFLAGS= -O -LDFLAGS= - -HDRS= klm_prot.h mount.h nfs_prot.h nlm_prot.h rex.h rquota.h rnusers.h\ - rquota.h rstat.h sm_inter.h spray.h yppasswd.h yp.h -XFILES= bootparam_prot.x klm_prot.x mount.x nfs_prot.x nlm_prot.x \ - rex.x rnusers.x rquota.x rstat.x sm_inter.x spray.x yppasswd.x yp.x -BIN= rstat -SVCBIN= rstat_svc -GEN= rstat_clnt.c rstat_svc.c rstat_xdr.c - -all: $(HDRS) $(BIN) $(SVCBIN) - -install: $(HDRS) $(XFILES) - @echo "Creating RPC service headers directory" - -mkdir ${DESTDIR}/usr/include/rpcsvc && \ - chown bin ${DESTDIR}/usr/include/rpcsvc && \ - chmod 755 ${DESTDIR}/usr/include/rpcsvc - @echo "Installing RPC service header and definition files" - for i in $(HDRS) $(XFILES); do \ - (install -c -m 644 $$i ${DESTDIR}/usr/include/rpcsvc) done - -mkdir ${DESTDIR}/etc && chown bin ${DESTDIR}/etc && \ - chmod 755 ${DESTDIR}/etc - @echo "Installing ${SVCBIN} in ${DESTDIR}/etc" - @set -x;for i in ${SVCBIN}; do \ - (install -c -s $$i ${DESTDIR}/etc/$$i); done - @echo "Installing ${BIN} in ${DESTDIR}/usr/bin" - @set -x;for i in ${BIN}; do \ - (install -c -s $$i ${DESTDIR}/usr/bin/$$i); done - -rstat_svc: rstat_proc.o rstat_svc.o rstat_xdr.o - $(CC) $(LDFLAGS) -o $@ rstat_proc.o rstat_svc.o rstat_xdr.o $(LIB) - -rstat: rstat.o rstat_clnt.o rstat_xdr.o - $(CC) $(LDFLAGS) -o $@ rstat.o rstat_clnt.o rstat_xdr.o $(LIB) - -rstat.c rstat_proc.c: rstat.h - -klm_prot.h: klm_prot.x - $(RPCCOM) -h klm_prot.x -o $@ -mount.h: mount.x - $(RPCCOM) -h mount.x -o $@ -nfs_prot.h: nfs_prot.x - $(RPCCOM) -h nfs_prot.x -o $@ -nlm_prot.h: nlm_prot.x - $(RPCCOM) -h nlm_prot.x -o $@ -rex.h: rex.x - $(RPCCOM) -h rex.x -o $@ -rnusers.h: rnusers.x - $(RPCCOM) -h rnusers.x -o $@ -rquota.h: rquota.x - $(RPCCOM) -h rquota.x -o $@ -rstat.h: rstat.x - $(RPCCOM) -h rstat.x -o $@ -sm_inter.h: sm_inter.x - $(RPCCOM) -h sm_inter.x -o $@ -spray.h: spray.x - $(RPCCOM) -h spray.x -o $@ -yp.h: yp.x - $(RPCCOM) -h yp.x -o $@ -yppasswd.h: yppasswd.x - $(RPCCOM) -h yppasswd.x -o $@ - -rstat_clnt.c: rstat.x - $(RPCCOM) -l rstat.x -o $@ -rstat_svc.c: rstat.x - $(RPCCOM) -s udp rstat.x -o $@ -rstat_xdr.c: rstat.x - $(RPCCOM) -c rstat.x -o $@ - -clean cleanup: - rm -f *.o $(GEN) $(BIN) $(SVCBIN) diff --git a/lib/librpc/rpcsvc/bootparam_prot.x b/lib/librpc/rpcsvc/bootparam_prot.x deleted file mode 100644 index 65bc0dcbfb2a..000000000000 --- a/lib/librpc/rpcsvc/bootparam_prot.x +++ /dev/null @@ -1,97 +0,0 @@ -/* @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * RPC for bootparms service. - * There are two procedures: - * WHOAMI takes a net address and returns a client name and also a - * likely net address for routing - * GETFILE takes a client name and file identifier and returns the - * server name, server net address and pathname for the file. - * file identifiers typically include root, swap, pub and dump - */ - -#ifdef RPC_HDR -%#include -%#include -%#include -%#include -#endif - -const MAX_MACHINE_NAME = 255; -const MAX_PATH_LEN = 1024; -const MAX_FILEID = 32; -const IP_ADDR_TYPE = 1; - -typedef string bp_machine_name_t; -typedef string bp_path_t; -typedef string bp_fileid_t; - -struct ip_addr_t { - char net; - char host; - char lh; - char impno; -}; - -union bp_address switch (int address_type) { - case IP_ADDR_TYPE: - ip_addr_t ip_addr; -}; - -struct bp_whoami_arg { - bp_address client_address; -}; - -struct bp_whoami_res { - bp_machine_name_t client_name; - bp_machine_name_t domain_name; - bp_address router_address; -}; - -struct bp_getfile_arg { - bp_machine_name_t client_name; - bp_fileid_t file_id; -}; - -struct bp_getfile_res { - bp_machine_name_t server_name; - bp_address server_address; - bp_path_t server_path; -}; - -program BOOTPARAMPROG { - version BOOTPARAMVERS { - bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; - bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; - } = 1; -} = 100026; diff --git a/lib/librpc/rpcsvc/klm_prot.x b/lib/librpc/rpcsvc/klm_prot.x deleted file mode 100644 index e23caf40f743..000000000000 --- a/lib/librpc/rpcsvc/klm_prot.x +++ /dev/null @@ -1,132 +0,0 @@ -/* @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Kernel/lock manager protocol definition - * Copyright (C) 1986 Sun Microsystems, Inc. - * - * protocol used between the UNIX kernel (the "client") and the - * local lock manager. The local lock manager is a deamon running - * above the kernel. - */ -program KLM_PROG { - version KLM_VERS { - - klm_testrply KLM_TEST (struct klm_testargs) = 1; - - klm_stat KLM_LOCK (struct klm_lockargs) = 2; - - klm_stat KLM_CANCEL (struct klm_lockargs) = 3; - /* klm_granted=> the cancel request fails due to lock is already granted */ - /* klm_denied=> the cancel request successfully aborts -lock request */ - - klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4; - } = 1; -} = 100020; - -const LM_MAXSTRLEN = 1024; - -/* - * lock manager status returns - */ -enum klm_stats { - klm_granted = 0, /* lock is granted */ - klm_denied = 1, /* lock is denied */ - klm_denied_nolocks = 2, /* no lock entry available */ - klm_working = 3 /* lock is being processed */ -}; - -/* - * lock manager lock identifier - */ -struct klm_lock { - string server_name; - netobj fh; /* a counted file handle */ - int pid; /* holder of the lock */ - unsigned l_offset; /* beginning offset of the lock */ - unsigned l_len; /* byte length of the lock; - * zero means through end of file */ -}; - -/* - * lock holder identifier - */ -struct klm_holder { - bool exclusive; /* FALSE if shared lock */ - int svid; /* holder of the lock (pid) */ - unsigned l_offset; /* beginning offset of the lock */ - unsigned l_len; /* byte length of the lock; - * zero means through end of file */ -}; - -/* - * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL - */ -struct klm_stat { - klm_stats stat; -}; - -/* - * reply to a KLM_TEST call - */ -union klm_testrply switch (klm_stats stat) { - case klm_denied: - struct klm_holder holder; - default: /* All other cases return no arguments */ - void; -}; - - -/* - * arguments to KLM_LOCK - */ -struct klm_lockargs { - bool block; - bool exclusive; - struct klm_lock alock; -}; - -/* - * arguments to KLM_TEST - */ -struct klm_testargs { - bool exclusive; - struct klm_lock alock; -}; - -/* - * arguments to KLM_UNLOCK - */ -struct klm_unlockargs { - struct klm_lock alock; -}; diff --git a/lib/librpc/rpcsvc/mount.x b/lib/librpc/rpcsvc/mount.x deleted file mode 100644 index 7e0d7f3ad6d9..000000000000 --- a/lib/librpc/rpcsvc/mount.x +++ /dev/null @@ -1,161 +0,0 @@ -/* @(#)mount.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Protocol description for the mount program - */ - - -const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ -const MNTNAMLEN = 255; /* maximum bytes in a name argument */ -const FHSIZE = 32; /* size in bytes of a file handle */ - -/* - * The fhandle is the file handle that the server passes to the client. - * All file operations are done using the file handles to refer to a file - * or a directory. The file handle can contain whatever information the - * server needs to distinguish an individual file. - */ -typedef opaque fhandle[FHSIZE]; - -/* - * If a status of zero is returned, the call completed successfully, and - * a file handle for the directory follows. A non-zero status indicates - * some sort of error. The status corresponds with UNIX error numbers. - */ -union fhstatus switch (unsigned fhs_status) { -case 0: - fhandle fhs_fhandle; -default: - void; -}; - -/* - * The type dirpath is the pathname of a directory - */ -typedef string dirpath; - -/* - * The type name is used for arbitrary names (hostnames, groupnames) - */ -typedef string name; - -/* - * A list of who has what mounted - */ -typedef struct mountbody *mountlist; -struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; -}; - -/* - * A list of netgroups - */ -typedef struct groupnode *groups; -struct groupnode { - name gr_name; - groups gr_next; -}; - -/* - * A list of what is exported and to whom - */ -typedef struct exportnode *exports; -struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; -}; - -program MOUNTPROG { - /* - * Version one of the mount protocol communicates with version two - * of the NFS protocol. The only connecting point is the fhandle - * structure, which is the same for both protocols. - */ - version MOUNTVERS { - /* - * Does no work. It is made available in all RPC services - * to allow server reponse testing and timing - */ - void - MOUNTPROC_NULL(void) = 0; - - /* - * If fhs_status is 0, then fhs_fhandle contains the - * file handle for the directory. This file handle may - * be used in the NFS protocol. This procedure also adds - * a new entry to the mount list for this client mounting - * the directory. - * Unix authentication required. - */ - fhstatus - MOUNTPROC_MNT(dirpath) = 1; - - /* - * Returns the list of remotely mounted filesystems. The - * mountlist contains one entry for each hostname and - * directory pair. - */ - mountlist - MOUNTPROC_DUMP(void) = 2; - - /* - * Removes the mount list entry for the directory - * Unix authentication required. - */ - void - MOUNTPROC_UMNT(dirpath) = 3; - - /* - * Removes all of the mount list entries for this client - * Unix authentication required. - */ - void - MOUNTPROC_UMNTALL(void) = 4; - - /* - * Returns a list of all the exported filesystems, and which - * machines are allowed to import it. - */ - exports - MOUNTPROC_EXPORT(void) = 5; - - /* - * Identical to MOUNTPROC_EXPORT above - */ - exports - MOUNTPROC_EXPORTALL(void) = 6; - } = 1; -} = 100005; diff --git a/lib/librpc/rpcsvc/nfs_prot.x b/lib/librpc/rpcsvc/nfs_prot.x deleted file mode 100644 index 7633e5add47d..000000000000 --- a/lib/librpc/rpcsvc/nfs_prot.x +++ /dev/null @@ -1,355 +0,0 @@ -/* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * nfs_prot.x 1.2 87/10/12 - * Copyright 1987 Sun Microsystems, Inc. - */ -const NFS_PORT = 2049; -const NFS_MAXDATA = 8192; -const NFS_MAXPATHLEN = 1024; -const NFS_MAXNAMLEN = 255; -const NFS_FHSIZE = 32; -const NFS_COOKIESIZE = 4; -const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ - -/* - * File types - */ -const NFSMODE_FMT = 0170000; /* type of file */ -const NFSMODE_DIR = 0040000; /* directory */ -const NFSMODE_CHR = 0020000; /* character special */ -const NFSMODE_BLK = 0060000; /* block special */ -const NFSMODE_REG = 0100000; /* regular */ -const NFSMODE_LNK = 0120000; /* symbolic link */ -const NFSMODE_SOCK = 0140000; /* socket */ -const NFSMODE_FIFO = 0010000; /* fifo */ - -/* - * Error status - */ -enum nfsstat { - NFS_OK= 0, /* no error */ - NFSERR_PERM=1, /* Not owner */ - NFSERR_NOENT=2, /* No such file or directory */ - NFSERR_IO=5, /* I/O error */ - NFSERR_NXIO=6, /* No such device or address */ - NFSERR_ACCES=13, /* Permission denied */ - NFSERR_EXIST=17, /* File exists */ - NFSERR_NODEV=19, /* No such device */ - NFSERR_NOTDIR=20, /* Not a directory*/ - NFSERR_ISDIR=21, /* Is a directory */ - NFSERR_FBIG=27, /* File too large */ - NFSERR_NOSPC=28, /* No space left on device */ - NFSERR_ROFS=30, /* Read-only file system */ - NFSERR_NAMETOOLONG=63, /* File name too long */ - NFSERR_NOTEMPTY=66, /* Directory not empty */ - NFSERR_DQUOT=69, /* Disc quota exceeded */ - NFSERR_STALE=70, /* Stale NFS file handle */ - NFSERR_WFLUSH=99 /* write cache flushed */ -}; - -/* - * File types - */ -enum ftype { - NFNON = 0, /* non-file */ - NFREG = 1, /* regular file */ - NFDIR = 2, /* directory */ - NFBLK = 3, /* block special */ - NFCHR = 4, /* character special */ - NFLNK = 5, /* symbolic link */ - NFSOCK = 6, /* unix domain sockets */ - NFBAD = 7, /* unused */ - NFFIFO = 8 /* named pipe */ -}; - -/* - * File access handle - */ -struct nfs_fh { - opaque data[NFS_FHSIZE]; -}; - -/* - * Timeval - */ -struct nfstime { - unsigned seconds; - unsigned useconds; -}; - - -/* - * File attributes - */ -struct fattr { - ftype type; /* file type */ - unsigned mode; /* protection mode bits */ - unsigned nlink; /* # hard links */ - unsigned uid; /* owner user id */ - unsigned gid; /* owner group id */ - unsigned size; /* file size in bytes */ - unsigned blocksize; /* prefered block size */ - unsigned rdev; /* special device # */ - unsigned blocks; /* Kb of disk used by file */ - unsigned fsid; /* device # */ - unsigned fileid; /* inode # */ - nfstime atime; /* time of last access */ - nfstime mtime; /* time of last modification */ - nfstime ctime; /* time of last change */ -}; - -/* - * File attributes which can be set - */ -struct sattr { - unsigned mode; /* protection mode bits */ - unsigned uid; /* owner user id */ - unsigned gid; /* owner group id */ - unsigned size; /* file size in bytes */ - nfstime atime; /* time of last access */ - nfstime mtime; /* time of last modification */ -}; - - -typedef string filename; -typedef string nfspath; - -/* - * Reply status with file attributes - */ -union attrstat switch (nfsstat status) { -case NFS_OK: - fattr attributes; -default: - void; -}; - -struct sattrargs { - nfs_fh file; - sattr attributes; -}; - -/* - * Arguments for directory operations - */ -struct diropargs { - nfs_fh dir; /* directory file handle */ - filename name; /* name (up to NFS_MAXNAMLEN bytes) */ -}; - -struct diropokres { - nfs_fh file; - fattr attributes; -}; - -/* - * Results from directory operation - */ -union diropres switch (nfsstat status) { -case NFS_OK: - diropokres diropres; -default: - void; -}; - -union readlinkres switch (nfsstat status) { -case NFS_OK: - nfspath data; -default: - void; -}; - -/* - * Arguments to remote read - */ -struct readargs { - nfs_fh file; /* handle for file */ - unsigned offset; /* byte offset in file */ - unsigned count; /* immediate read count */ - unsigned totalcount; /* total read count (from this offset)*/ -}; - -/* - * Status OK portion of remote read reply - */ -struct readokres { - fattr attributes; /* attributes, need for pagin*/ - opaque data; -}; - -union readres switch (nfsstat status) { -case NFS_OK: - readokres reply; -default: - void; -}; - -/* - * Arguments to remote write - */ -struct writeargs { - nfs_fh file; /* handle for file */ - unsigned beginoffset; /* beginning byte offset in file */ - unsigned offset; /* current byte offset in file */ - unsigned totalcount; /* total write count (to this offset)*/ - opaque data; -}; - -struct createargs { - diropargs where; - sattr attributes; -}; - -struct renameargs { - diropargs from; - diropargs to; -}; - -struct linkargs { - nfs_fh from; - diropargs to; -}; - -struct symlinkargs { - diropargs from; - nfspath to; - sattr attributes; -}; - - -typedef opaque nfscookie[NFS_COOKIESIZE]; - -/* - * Arguments to readdir - */ -struct readdirargs { - nfs_fh dir; /* directory handle */ - nfscookie cookie; - unsigned count; /* number of directory bytes to read */ -}; - -struct entry { - unsigned fileid; - filename name; - nfscookie cookie; - entry *nextentry; -}; - -struct dirlist { - entry *entries; - bool eof; -}; - -union readdirres switch (nfsstat status) { -case NFS_OK: - dirlist reply; -default: - void; -}; - -struct statfsokres { - unsigned tsize; /* preferred transfer size in bytes */ - unsigned bsize; /* fundamental file system block size */ - unsigned blocks; /* total blocks in file system */ - unsigned bfree; /* free blocks in fs */ - unsigned bavail; /* free blocks avail to non-superuser */ -}; - -union statfsres switch (nfsstat status) { -case NFS_OK: - statfsokres reply; -default: - void; -}; - -/* - * Remote file service routines - */ -program NFS_PROGRAM { - version NFS_VERSION { - void - NFSPROC_NULL(void) = 0; - - attrstat - NFSPROC_GETATTR(nfs_fh) = 1; - - attrstat - NFSPROC_SETATTR(sattrargs) = 2; - - void - NFSPROC_ROOT(void) = 3; - - diropres - NFSPROC_LOOKUP(diropargs) = 4; - - readlinkres - NFSPROC_READLINK(nfs_fh) = 5; - - readres - NFSPROC_READ(readargs) = 6; - - void - NFSPROC_WRITECACHE(void) = 7; - - attrstat - NFSPROC_WRITE(writeargs) = 8; - - diropres - NFSPROC_CREATE(createargs) = 9; - - nfsstat - NFSPROC_REMOVE(diropargs) = 10; - - nfsstat - NFSPROC_RENAME(renameargs) = 11; - - nfsstat - NFSPROC_LINK(linkargs) = 12; - - nfsstat - NFSPROC_SYMLINK(symlinkargs) = 13; - - diropres - NFSPROC_MKDIR(createargs) = 14; - - nfsstat - NFSPROC_RMDIR(diropargs) = 15; - - readdirres - NFSPROC_READDIR(readdirargs) = 16; - - statfsres - NFSPROC_STATFS(nfs_fh) = 17; - } = 2; -} = 100003; - diff --git a/lib/librpc/rpcsvc/nlm_prot.x b/lib/librpc/rpcsvc/nlm_prot.x deleted file mode 100644 index e60c9315c24a..000000000000 --- a/lib/librpc/rpcsvc/nlm_prot.x +++ /dev/null @@ -1,179 +0,0 @@ -/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */ - -/* - * Network lock manager protocol definition - * Copyright (C) 1986 Sun Microsystems, Inc. - * - * protocol used between local lock manager and remote lock manager - */ - -#ifdef RPC_HDR -%#define LM_MAXSTRLEN 1024 -%#define MAXNAMELEN LM_MAXSTRLEN+1 -#endif - -/* - * status of a call to the lock manager - */ -enum nlm_stats { - nlm_granted = 0, - nlm_denied = 1, - nlm_denied_nolocks = 2, - nlm_blocked = 3, - nlm_denied_grace_period = 4 -}; - -struct nlm_holder { - bool exclusive; - int svid; - netobj oh; - unsigned l_offset; - unsigned l_len; -}; - -union nlm_testrply switch (nlm_stats stat) { - case nlm_denied: - struct nlm_holder holder; - default: - void; -}; - -struct nlm_stat { - nlm_stats stat; -}; - -struct nlm_res { - netobj cookie; - nlm_stat stat; -}; - -struct nlm_testres { - netobj cookie; - nlm_testrply stat; -}; - -struct nlm_lock { - string caller_name; - netobj fh; /* identify a file */ - netobj oh; /* identify owner of a lock */ - int svid; /* generated from pid for svid */ - unsigned l_offset; - unsigned l_len; -}; - -struct nlm_lockargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; - bool reclaim; /* used for recovering locks */ - int state; /* specify local status monitor state */ -}; - -struct nlm_cancargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_testargs { - netobj cookie; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_unlockargs { - netobj cookie; - struct nlm_lock alock; -}; - - -#ifdef RPC_HDR -%/* -% * The following enums are actually bit encoded for efficient -% * boolean algebra.... DON'T change them..... -% */ -#endif -enum fsh_mode { - fsm_DN = 0, /* deny none */ - fsm_DR = 1, /* deny read */ - fsm_DW = 2, /* deny write */ - fsm_DRW = 3 /* deny read/write */ -}; - -enum fsh_access { - fsa_NONE = 0, /* for completeness */ - fsa_R = 1, /* read only */ - fsa_W = 2, /* write only */ - fsa_RW = 3 /* read/write */ -}; - -struct nlm_share { - string caller_name; - netobj fh; - netobj oh; - fsh_mode mode; - fsh_access access; -}; - -struct nlm_shareargs { - netobj cookie; - nlm_share share; - bool reclaim; -}; - -struct nlm_shareres { - netobj cookie; - nlm_stats stat; - int sequence; -}; - -struct nlm_notify { - string name; - long state; -}; - -/* - * Over-the-wire protocol used between the network lock managers - */ - -program NLM_PROG { - version NLM_VERS { - - nlm_testres NLM_TEST(struct nlm_testargs) = 1; - - nlm_res NLM_LOCK(struct nlm_lockargs) = 2; - - nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; - nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; - - /* - * remote lock manager call-back to grant lock - */ - nlm_res NLM_GRANTED(struct nlm_testargs)= 5; - /* - * message passing style of requesting lock - */ - void NLM_TEST_MSG(struct nlm_testargs) = 6; - void NLM_LOCK_MSG(struct nlm_lockargs) = 7; - void NLM_CANCEL_MSG(struct nlm_cancargs) =8; - void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; - void NLM_GRANTED_MSG(struct nlm_testargs) = 10; - void NLM_TEST_RES(nlm_testres) = 11; - void NLM_LOCK_RES(nlm_res) = 12; - void NLM_CANCEL_RES(nlm_res) = 13; - void NLM_UNLOCK_RES(nlm_res) = 14; - void NLM_GRANTED_RES(nlm_res) = 15; - } = 1; - - version NLM_VERSX { - nlm_shareres NLM_SHARE(nlm_shareargs) = 20; - nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; - nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; - void NLM_FREE_ALL(nlm_notify) = 23; - } = 3; - -} = 100021; - diff --git a/lib/librpc/rpcsvc/rex.x b/lib/librpc/rpcsvc/rex.x deleted file mode 100644 index 6063fdd28a57..000000000000 --- a/lib/librpc/rpcsvc/rex.x +++ /dev/null @@ -1,229 +0,0 @@ -/* @(#)rex.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Remote execution (rex) protocol specification - */ - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimeter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/lib/librpc/rpcsvc/rnusers.x b/lib/librpc/rpcsvc/rnusers.x deleted file mode 100644 index 257df1e6e91d..000000000000 --- a/lib/librpc/rpcsvc/rnusers.x +++ /dev/null @@ -1,86 +0,0 @@ -/* @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Find out about remote users - */ - -const MAXUSERS = 100; -const MAXUTLEN = 256; - -struct utmp { - string ut_line; - string ut_name; - string ut_host; - int ut_time; -}; - - -struct utmpidle { - utmp ui_utmp; - unsigned int ui_idle; -}; - -typedef utmp utmparr; - -typedef utmpidle utmpidlearr; - -program RUSERSPROG { - /* - * Includes idle information - */ - version RUSERSVERS_IDLE { - int - RUSERSPROC_NUM(void) = 1; - - utmpidlearr - RUSERSPROC_NAMES(void) = 2; - - utmpidlearr - RUSERSPROC_ALLNAMES(void) = 3; - } = 1; - - /* - * Old version does not include idle information - */ - version RUSERSVERS_ORIG { - int - RUSERSPROC_NUM(void) = 1; - - utmparr - RUSERSPROC_NAMES(void) = 2; - - utmparr - RUSERSPROC_ALLNAMES(void) = 3; - } = 2; -} = 100002; - diff --git a/lib/librpc/rpcsvc/rquota.x b/lib/librpc/rpcsvc/rquota.x deleted file mode 100644 index 62888f612a78..000000000000 --- a/lib/librpc/rpcsvc/rquota.x +++ /dev/null @@ -1,61 +0,0 @@ -/* @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */ - -/* - * Remote quota protocol - * Requires unix authentication - */ - -const RQ_PATHLEN = 1024; - -struct getquota_args { - string gqa_pathp; /* path to filesystem of interest */ - int gqa_uid; /* inquire about quota for uid */ -}; - -/* - * remote quota structure - */ -struct rquota { - int rq_bsize; /* block size for block counts */ - bool rq_active; /* indicates whether quota is active */ - unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ - unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ - unsigned int rq_curblocks; /* current block count */ - unsigned int rq_fhardlimit; /* absolute limit on allocated files */ - unsigned int rq_fsoftlimit; /* preferred file limit */ - unsigned int rq_curfiles; /* current # allocated files */ - unsigned int rq_btimeleft; /* time left for excessive disk use */ - unsigned int rq_ftimeleft; /* time left for excessive files */ -}; - -enum gqr_status { - Q_OK = 1, /* quota returned */ - Q_NOQUOTA = 2, /* noquota for uid */ - Q_EPERM = 3 /* no permission to access quota */ -}; - -union getquota_rslt switch (gqr_status status) { -case Q_OK: - rquota gqr_rquota; /* valid if status == Q_OK */ -case Q_NOQUOTA: - void; -case Q_EPERM: - void; -}; - -program RQUOTAPROG { - version RQUOTAVERS { - /* - * Get all quotas - */ - getquota_rslt - RQUOTAPROC_GETQUOTA(getquota_args) = 1; - - /* - * Get active quotas only - */ - getquota_rslt - RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; - } = 1; -} = 100011; diff --git a/lib/librpc/rpcsvc/rstat.c b/lib/librpc/rpcsvc/rstat.c deleted file mode 100644 index fe83ae51a0ac..000000000000 --- a/lib/librpc/rpcsvc/rstat.c +++ /dev/null @@ -1,85 +0,0 @@ -/* @(#)rstat.c 2.3 88/11/30 4.0 RPCSRC */ -/* - * Simple program that prints the status of a remote host, in a format - * similar to that used by the 'w' command, using the rstat.x service. - */ - -#include -#include -#include /* include */ -#include "rstat.h" - -main(argc, argv) -int argc; -char **argv; -{ - - char *host; - CLIENT *rstat_clnt; - statstime *host_stat; - struct tm *tmp_time; - struct tm host_time; - struct tm host_uptime; - char days_buf[16]; - char hours_buf[16]; - - if (argc != 2) - { - fprintf(stderr, "usage: %s \"host\"\n", argv[0]); - exit(1); - } - - host = argv[1]; - - /* client handle to rstat */ - rstat_clnt = clnt_create(host, RSTATPROG, RSTATVERS_TIME, "udp"); - if (rstat_clnt == NULL) - { - clnt_pcreateerror(argv[0]); - exit(1); - } - - host_stat = rstatproc_stats_3(NULL, rstat_clnt); - if (host_stat == NULL) - { - clnt_perror(rstat_clnt, argv[0]); - exit(1); - } - - tmp_time = localtime(&host_stat->curtime.tv_sec); - host_time = *tmp_time; - - host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; - - tmp_time = gmtime(&host_stat->curtime.tv_sec); - host_uptime = *tmp_time; - - if (host_uptime.tm_yday != 0) - sprintf(days_buf, "%d day%s, ", host_uptime.tm_yday, - (host_uptime.tm_yday > 1) ? "s" : ""); - else - days_buf[0] = '\0'; - - if (host_uptime.tm_hour != 0) - sprintf(hours_buf, "%2d:%02d,", - host_uptime.tm_hour, host_uptime.tm_min); - else - if (host_uptime.tm_min != 0) - sprintf(hours_buf, "%2d mins,", host_uptime.tm_min); - else - hours_buf[0] = '\0'; - - printf(" %2d:%02d%cm up %s%s load average: %.2f %.2f %.2f\n", - (host_time.tm_hour > 12) ? host_time.tm_hour - 12 - : host_time.tm_hour, - host_time.tm_min, - (host_time.tm_hour >= 12) ? 'p' - : 'a', - days_buf, - hours_buf, - (double)host_stat->avenrun[0]/FSCALE, - (double)host_stat->avenrun[1]/FSCALE, - (double)host_stat->avenrun[2]/FSCALE); - - exit(0); -} diff --git a/lib/librpc/rpcsvc/rstat.x b/lib/librpc/rpcsvc/rstat.x deleted file mode 100644 index 6367c4394321..000000000000 --- a/lib/librpc/rpcsvc/rstat.x +++ /dev/null @@ -1,145 +0,0 @@ -/* @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC */ -/* @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Gather statistics on remote machines - */ - -#ifdef RPC_HDR - -%#ifndef FSCALE -%/* -% * Scale factor for scaled integers used to count load averages. -% */ -%#define FSHIFT 8 /* bits to right of fixed binary point */ -%#define FSCALE (1< -#include -#include -#include -#include -#include -#include -#include -#include -#include "rstat.h" - -struct nlist nl[] = { -#define X_CPTIME 0 - { "_cp_time" }, -#define X_SUM 1 - { "_sum" }, -#define X_IFNET 2 - { "_ifnet" }, -#define X_DKXFER 3 - { "_dk_xfer" }, -#define X_BOOTTIME 4 - { "_boottime" }, -#define X_AVENRUN 5 - { "_avenrun" }, -#define X_HZ 6 - { "_hz" }, - "", -}; -int kmem; -int firstifnet, numintfs; /* chain of ethernet interfaces */ -int stats_service(); - -/* - * Define EXIT_WHEN_IDLE if you are able to have this program invoked - * automatically on demand (as from inetd). When defined, the service - * will terminated after being idle for 20 seconds. - */ -int sincelastreq = 0; /* number of alarms since last request */ -#ifdef EXIT_WHEN_IDLE -#define CLOSEDOWN 20 /* how long to wait before exiting */ -#endif /* def EXIT_WHEN_IDLE */ - -union { - struct stats s1; - struct statsswtch s2; - struct statstime s3; -} stats_all; - -int updatestat(); -static stat_is_init = 0; -extern int errno; - -#ifndef FSCALE -#define FSCALE (1 << 8) -#endif - -stat_init() -{ - stat_is_init = 1; - setup(); - updatestat(); - alarm(1); - signal(SIGALRM, updatestat); - sleep(1); /* allow for one wake-up */ -} - -statstime * -rstatproc_stats_3() -{ - if (! stat_is_init) - stat_init(); - sincelastreq = 0; - return(&stats_all.s3); -} - -statsswtch * -rstatproc_stats_2() -{ - if (! stat_is_init) - stat_init(); - sincelastreq = 0; - return(&stats_all.s2); -} - -stats * -rstatproc_stats_1() -{ - if (! stat_is_init) - stat_init(); - sincelastreq = 0; - return(&stats_all.s1); -} - -u_int * -rstatproc_havedisk_3() -{ - static u_int have; - - if (! stat_is_init) - stat_init(); - sincelastreq = 0; - have = havedisk(); - return(&have); -} - -u_int * -rstatproc_havedisk_2() -{ - return(rstatproc_havedisk_3()); -} - -u_int * -rstatproc_havedisk_1() -{ - return(rstatproc_havedisk_3()); -} - -updatestat() -{ - int off, i, hz; - struct vmmeter sum; - struct ifnet ifnet; - double avrun[3]; - struct timeval tm, btm; - -#ifdef DEBUG - fprintf(stderr, "entering updatestat\n"); -#endif -#ifdef EXIT_WHEN_IDLE - if (sincelastreq >= CLOSEDOWN) { -#ifdef DEBUG - fprintf(stderr, "about to closedown\n"); -#endif - exit(0); - } - sincelastreq++; -#endif /* def EXIT_WHEN_IDLE */ - if (lseek(kmem, (long)nl[X_HZ].n_value, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&hz, sizeof hz) != sizeof hz) { - fprintf(stderr, "rstat: can't read hz from kmem\n"); - exit(1); - } - if (lseek(kmem, (long)nl[X_CPTIME].n_value, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)stats_all.s1.cp_time, sizeof (stats_all.s1.cp_time)) - != sizeof (stats_all.s1.cp_time)) { - fprintf(stderr, "rstat: can't read cp_time from kmem\n"); - exit(1); - } - if (lseek(kmem, (long)nl[X_AVENRUN].n_value, 0) ==-1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } -#ifdef vax - if (read(kmem, (char *)avrun, sizeof (avrun)) != sizeof (avrun)) { - fprintf(stderr, "rstat: can't read avenrun from kmem\n"); - exit(1); - } - stats_all.s2.avenrun[0] = avrun[0] * FSCALE; - stats_all.s2.avenrun[1] = avrun[1] * FSCALE; - stats_all.s2.avenrun[2] = avrun[2] * FSCALE; -#endif - if (lseek(kmem, (long)nl[X_BOOTTIME].n_value, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&btm, sizeof (stats_all.s2.boottime)) - != sizeof (stats_all.s2.boottime)) { - fprintf(stderr, "rstat: can't read boottime from kmem\n"); - exit(1); - } - stats_all.s2.boottime.tv_sec = btm.tv_sec; - stats_all.s2.boottime.tv_usec = btm.tv_usec; - - -#ifdef DEBUG - fprintf(stderr, "%d %d %d %d\n", stats_all.s1.cp_time[0], - stats_all.s1.cp_time[1], stats_all.s1.cp_time[2], stats_all.s1.cp_time[3]); -#endif - - if (lseek(kmem, (long)nl[X_SUM].n_value, 0) ==-1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&sum, sizeof sum) != sizeof sum) { - fprintf(stderr, "rstat: can't read sum from kmem\n"); - exit(1); - } - stats_all.s1.v_pgpgin = sum.v_pgpgin; - stats_all.s1.v_pgpgout = sum.v_pgpgout; - stats_all.s1.v_pswpin = sum.v_pswpin; - stats_all.s1.v_pswpout = sum.v_pswpout; - stats_all.s1.v_intr = sum.v_intr; - gettimeofday(&tm, (struct timezone *) 0); - stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + - hz*(tm.tv_usec - btm.tv_usec)/1000000; - stats_all.s2.v_swtch = sum.v_swtch; - - if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)stats_all.s1.dk_xfer, sizeof (stats_all.s1.dk_xfer)) - != sizeof (stats_all.s1.dk_xfer)) { - fprintf(stderr, "rstat: can't read dk_xfer from kmem\n"); - exit(1); - } - - stats_all.s1.if_ipackets = 0; - stats_all.s1.if_opackets = 0; - stats_all.s1.if_ierrors = 0; - stats_all.s1.if_oerrors = 0; - stats_all.s1.if_collisions = 0; - for (off = firstifnet, i = 0; off && i < numintfs; i++) { - if (lseek(kmem, (long)off, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&ifnet, sizeof ifnet) != sizeof ifnet) { - fprintf(stderr, "rstat: can't read ifnet from kmem\n"); - exit(1); - } - stats_all.s1.if_ipackets += ifnet.if_ipackets; - stats_all.s1.if_opackets += ifnet.if_opackets; - stats_all.s1.if_ierrors += ifnet.if_ierrors; - stats_all.s1.if_oerrors += ifnet.if_oerrors; - stats_all.s1.if_collisions += ifnet.if_collisions; - off = (int) ifnet.if_next; - } - gettimeofday((struct timeval *)&stats_all.s3.curtime, - (struct timezone *) 0); - alarm(1); -} - -static -setup() -{ - struct ifnet ifnet; - int off; - - nlist("/vmunix", nl); - if (nl[0].n_value == 0) { - fprintf(stderr, "rstat: Variables missing from namelist\n"); - exit (1); - } - if ((kmem = open("/dev/kmem", 0)) < 0) { - fprintf(stderr, "rstat: can't open kmem\n"); - exit(1); - } - - off = nl[X_IFNET].n_value; - if (lseek(kmem, (long)off, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&firstifnet, sizeof(int)) != sizeof (int)) { - fprintf(stderr, "rstat: can't read firstifnet from kmem\n"); - exit(1); - } - numintfs = 0; - for (off = firstifnet; off;) { - if (lseek(kmem, (long)off, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)&ifnet, sizeof ifnet) != sizeof ifnet) { - fprintf(stderr, "rstat: can't read ifnet from kmem\n"); - exit(1); - } - numintfs++; - off = (int) ifnet.if_next; - } -} - -/* - * returns true if have a disk - */ -static -havedisk() -{ - int i, cnt; - long xfer[DK_NDRIVE]; - - nlist("/vmunix", nl); - if (nl[X_DKXFER].n_value == 0) { - fprintf(stderr, "rstat: Variables missing from namelist\n"); - exit (1); - } - if ((kmem = open("/dev/kmem", 0)) < 0) { - fprintf(stderr, "rstat: can't open kmem\n"); - exit(1); - } - if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) { - fprintf(stderr, "rstat: can't seek in kmem\n"); - exit(1); - } - if (read(kmem, (char *)xfer, sizeof xfer)!= sizeof xfer) { - fprintf(stderr, "rstat: can't read kmem\n"); - exit(1); - } - cnt = 0; - for (i=0; i < DK_NDRIVE; i++) - cnt += xfer[i]; - return (cnt != 0); -} diff --git a/lib/librpc/rpcsvc/sm_inter.x b/lib/librpc/rpcsvc/sm_inter.x deleted file mode 100644 index 2817ebfda3b4..000000000000 --- a/lib/librpc/rpcsvc/sm_inter.x +++ /dev/null @@ -1,116 +0,0 @@ -/* @(#)sm_inter.x 2.2 88/08/01 4.0 RPCSRC */ -/* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Status monitor protocol specification - * Copyright (C) 1986 Sun Microsystems, Inc. - * - */ - - -program SM_PROG { - version SM_VERS { - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* if res_stat == stat_succ, state = state number of site sm_name */ - struct sm_stat_res SM_STAT(struct sm_name) = 1; - - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* stat consists of state number of local site */ - struct sm_stat_res SM_MON(struct mon) = 2; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON(struct mon_id) = 3; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON_ALL(struct my_id) = 4; - - void SM_SIMU_CRASH(void) = 5; - - } = 1; -} = 100024; - -const SM_MAXSTRLEN = 1024; - -struct sm_name { - string mon_name; -}; - -struct my_id { - string my_name; /* name of the site iniates the monitoring request*/ - int my_prog; /* rpc program # of the requesting process */ - int my_vers; /* rpc version # of the requesting process */ - int my_proc; /* rpc procedure # of the requesting process */ -}; - -struct mon_id { - string mon_name; /* name of the site to be monitored */ - struct my_id my_id; -}; - - -struct mon{ - struct mon_id mon_id; - opaque priv[16]; /* private information to store at monitor for requesting process */ -}; - - -/* - * state # of status monitor monitonically increases each time - * status of the site changes: - * an even number (>= 0) indicates the site is down and - * an odd number (> 0) indicates the site is up; - */ -struct sm_stat { - int state; /* state # of status monitor */ -}; - -enum res { - stat_succ = 0, /* status monitor agrees to monitor */ - stat_fail = 1 /* status monitor cannot monitor */ -}; - -struct sm_stat_res { - res res_stat; - int state; -}; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct status { - string mon_name; - int state; - opaque priv[16]; /* stored private information */ -}; diff --git a/lib/librpc/rpcsvc/spray.x b/lib/librpc/rpcsvc/spray.x deleted file mode 100644 index b242f0ac75d3..000000000000 --- a/lib/librpc/rpcsvc/spray.x +++ /dev/null @@ -1,84 +0,0 @@ -/* @(#)spray.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Spray a server with packets - * Useful for testing flakiness of network interfaces - */ - -const SPRAYMAX = 8845; /* max amount can spray */ - -/* - * GMT since 0:00, 1 January 1970 - */ -struct spraytimeval { - unsigned int sec; - unsigned int usec; -}; - -/* - * spray statistics - */ -struct spraycumul { - unsigned int counter; - spraytimeval clock; -}; - -/* - * spray data - */ -typedef opaque sprayarr; - -program SPRAYPROG { - version SPRAYVERS { - /* - * Just throw away the data and increment the counter - * This call never returns, so the client should always - * time it out. - */ - void - SPRAYPROC_SPRAY(sprayarr) = 1; - - /* - * Get the value of the counter and elapsed time since - * last CLEAR. - */ - spraycumul - SPRAYPROC_GET(void) = 2; - - /* - * Clear the counter and reset the elapsed time - */ - void - SPRAYPROC_CLEAR(void) = 3; - } = 1; -} = 100012; diff --git a/lib/librpc/rpcsvc/yp.x b/lib/librpc/rpcsvc/yp.x deleted file mode 100644 index 8fe70a270674..000000000000 --- a/lib/librpc/rpcsvc/yp.x +++ /dev/null @@ -1,291 +0,0 @@ -/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Protocol description file for the Yellow Pages Service - */ - -const YPMAXRECORD = 1024; -const YPMAXDOMAIN = 64; -const YPMAXMAP = 64; -const YPMAXPEER = 64; - - -enum ypstat { - YP_TRUE = 1, - YP_NOMORE = 2, - YP_FALSE = 0, - YP_NOMAP = -1, - YP_NODOM = -2, - YP_NOKEY = -3, - YP_BADOP = -4, - YP_BADDB = -5, - YP_YPERR = -6, - YP_BADARGS = -7, - YP_VERS = -8 -}; - - -enum ypxfrstat { - YPXFR_SUCC = 1, - YPXFR_AGE = 2, - YPXFR_NOMAP = -1, - YPXFR_NODOM = -2, - YPXFR_RSRC = -3, - YPXFR_RPC = -4, - YPXFR_MADDR = -5, - YPXFR_YPERR = -6, - YPXFR_BADARGS = -7, - YPXFR_DBM = -8, - YPXFR_FILE = -9, - YPXFR_SKEW = -10, - YPXFR_CLEAR = -11, - YPXFR_FORCE = -12, - YPXFR_XFRERR = -13, - YPXFR_REFUSED = -14 -}; - - -typedef string domainname; -typedef string mapname; -typedef string peername; -typedef opaque keydat; -typedef opaque valdat; - - -struct ypmap_parms { - domainname domain; - mapname map; - unsigned int ordernum; - peername peer; -}; - -struct ypreq_key { - domainname domain; - mapname map; - keydat key; -}; - -struct ypreq_nokey { - domainname domain; - mapname map; -}; - -struct ypreq_xfr { - ypmap_parms map_parms; - unsigned int transid; - unsigned int prog; - unsigned int port; -}; - - -struct ypresp_val { - ypstat stat; - valdat val; -}; - -struct ypresp_key_val { - ypstat stat; - keydat key; - valdat val; -}; - - -struct ypresp_master { - ypstat stat; - peername peer; -}; - -struct ypresp_order { - ypstat stat; - unsigned int ordernum; -}; - -union ypresp_all switch (bool more) { -case TRUE: - ypresp_key_val val; -case FALSE: - void; -}; - -struct ypresp_xfr { - unsigned int transid; - ypxfrstat xfrstat; -}; - -struct ypmaplist { - mapname map; - ypmaplist *next; -}; - -struct ypresp_maplist { - ypstat stat; - ypmaplist *maps; -}; - -enum yppush_status { - YPPUSH_SUCC = 1, /* Success */ - YPPUSH_AGE = 2, /* Master's version not newer */ - YPPUSH_NOMAP = -1, /* Can't find server for map */ - YPPUSH_NODOM = -2, /* Domain not supported */ - YPPUSH_RSRC = -3, /* Local resource alloc failure */ - YPPUSH_RPC = -4, /* RPC failure talking to server */ - YPPUSH_MADDR = -5, /* Can't get master address */ - YPPUSH_YPERR = -6, /* YP server/map db error */ - YPPUSH_BADARGS = -7, /* Request arguments bad */ - YPPUSH_DBM = -8, /* Local dbm operation failed */ - YPPUSH_FILE = -9, /* Local file I/O operation failed */ - YPPUSH_SKEW = -10, /* Map version skew during transfer */ - YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ - YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ - YPPUSH_XFRERR = -13, /* ypxfr error */ - YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ -}; - -struct yppushresp_xfr { - unsigned transid; - yppush_status status; -}; - -/* - * Response structure and overall result status codes. Success and failure - * represent two separate response message types. - */ - -enum ypbind_resptype { - YPBIND_SUCC_VAL = 1, - YPBIND_FAIL_VAL = 2 -}; - -struct ypbind_binding { - opaque ypbind_binding_addr[4]; /* In network order */ - opaque ypbind_binding_port[2]; /* In network order */ -}; - -union ypbind_resp switch (ypbind_resptype ypbind_status) { -case YPBIND_FAIL_VAL: - unsigned ypbind_error; -case YPBIND_SUCC_VAL: - ypbind_binding ypbind_bindinfo; -}; - -/* Detailed failure reason codes for response field ypbind_error*/ - -const YPBIND_ERR_ERR = 1; /* Internal error */ -const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ -const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ - - -/* - * Request data structure for ypbind "Set domain" procedure. - */ -struct ypbind_setdom { - domainname ypsetdom_domain; - ypbind_binding ypsetdom_binding; - unsigned ypsetdom_vers; -}; - - -/* - * YP access protocol - */ -program YPPROG { - version YPVERS { - void - YPPROC_NULL(void) = 0; - - bool - YPPROC_DOMAIN(domainname) = 1; - - bool - YPPROC_DOMAIN_NONACK(domainname) = 2; - - ypresp_val - YPPROC_MATCH(ypreq_key) = 3; - - ypresp_key_val - YPPROC_FIRST(ypreq_key) = 4; - - ypresp_key_val - YPPROC_NEXT(ypreq_key) = 5; - - ypresp_xfr - YPPROC_XFR(ypreq_xfr) = 6; - - void - YPPROC_CLEAR(void) = 7; - - ypresp_all - YPPROC_ALL(ypreq_nokey) = 8; - - ypresp_master - YPPROC_MASTER(ypreq_nokey) = 9; - - ypresp_order - YPPROC_ORDER(ypreq_nokey) = 10; - - ypresp_maplist - YPPROC_MAPLIST(domainname) = 11; - } = 2; -} = 100004; - - -/* - * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR - */ -program YPPUSH_XFRRESPPROG { - version YPPUSH_XFRRESPVERS { - void - YPPUSHPROC_NULL(void) = 0; - - yppushresp_xfr - YPPUSHPROC_XFRRESP(void) = 1; - } = 1; -} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ - - -/* - * YP binding protocol - */ -program YPBINDPROG { - version YPBINDVERS { - void - YPBINDPROC_NULL(void) = 0; - - ypbind_resp - YPBINDPROC_DOMAIN(domainname) = 1; - - void - YPBINDPROC_SETDOM(ypbind_setdom) = 2; - } = 2; -} = 100007; - - diff --git a/lib/librpc/rpcsvc/yppasswd.x b/lib/librpc/rpcsvc/yppasswd.x deleted file mode 100644 index ad349adbfa30..000000000000 --- a/lib/librpc/rpcsvc/yppasswd.x +++ /dev/null @@ -1,63 +0,0 @@ -/* @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * YP password update protocol - * Requires unix authentication - */ -program YPPASSWDPROG { - version YPPASSWDVERS { - /* - * Update my passwd entry - */ - int - YPPASSWDPROC_UPDATE(yppasswd) = 1; - } = 1; -} = 100009; - - -struct passwd { - string pw_name<>; /* username */ - string pw_passwd<>; /* encrypted password */ - int pw_uid; /* user id */ - int pw_gid; /* group id */ - string pw_gecos<>; /* in real life name */ - string pw_dir<>; /* home directory */ - string pw_shell<>; /* default shell */ -}; - -struct yppasswd { - string oldpass<>; /* unencrypted old password */ - passwd newpw; /* new passwd entry */ -}; - - diff --git a/lib/librpc/secure_rpc/README b/lib/librpc/secure_rpc/README deleted file mode 100644 index b8a860ef2698..000000000000 --- a/lib/librpc/secure_rpc/README +++ /dev/null @@ -1,92 +0,0 @@ -Export restriction prohibit us from including DES encryption routines in RPCSRC -4.0. The main RPCSRC 4.0 hierarchy does not include DES Authentication, -however this directory contains the documentation and code used to build secure -rpc. THIS DISTRIBUTION OF SECURE RPC NEEDS EXTENSIVE WORK BEFORE IT CAN BE -USED. PLEASE READ THE PORTING GUIDLINES BELOW. - -HIERARCHY - -bin/ - - This directory contains chkey and keylogin. These are user programs - used to establish the credentials of an RPC user. - -demo/ - The 'whoami' service is found here. It can be used to test secure RPC. - rpcgen is used to build the client and server. - -des/ - - des_crypt.h defines the interfaces to cbc_crypt() and ecb_crypt(), - the DES routines used by DES Authentication. - des.h defines the desparams structure that is used internally by - these routines. Secure RPC expects it to be installed in - /usr/include/sys. - des_crypt.c defines the cbc_crypt() and ecb_crypt() routines. These - eventually call the routine _des_crypt(), which is *not* provided. - des_soft.c contains the des_setparity() routine. - -doc/ - - The document "nfs.secure.ms" is found here. It describes Secure - RPC and Secure NFS. - -keyserv/ - - This is an RPC based program that stores the private keys for - users that are using secure RPC. - -man/ - - Manual pages for the programs and library routines are found here. - -rpc/ - - The routines in this directory should be integrated with the - default rpc directory to make a single RPC library. The Makefile - found in this directory replaces the one in ../rpc. Note: the file - svc_auth.c in this directory replaces the one in ../rpc. Also, the - file ../rpc/rpc.h should be edited to include the file - (it presently is commented out). - -PORTING GUIDELINES - -You will need to provide a DES encryption routine. man/des_crypt.3 describes -the interface to ecb_crypt() and cbc_crypt() (secure RPC uses both modes). The -des/ directory has the "front-end" for these routines in the des_crypt.c file. - -Since public key authentication systems require a network global data lookup -facility, this implementation uses Sun's Yellow Pages. If your site does not -have Yellow Pages, you will have to modify the routines in rpc/publickey.c and -bin/chkey.c. One possible approach is to replace the YP calls with code to -read the file /etc/publickey; this file would presumably be shared by all -secure RPC sites via NFS or some equivalent file sharing facility. If you wish -to implement YP yourself, the RPCL (.x) protocol description file can be found -in ../rpcsvc/yp.x. - -The routines in rpc/ and keyserv/ assume that the file des/des_crypt.h -is installed in /usr/include (they include ). The file -des/des_crypt.c assumes that des.h is installed in /usr/include/sys (it -include ). The des/ directory does not have a Makefile that -would install these header files, so you will either have to do this -by hand, or modify the routines to include the header files in a way suitable -for your site. - -While the programs in bin/ and keyserv/ can be built in place (assuming -the header files they include and the RPC library are available), the files -in rpc/ must be moved into ../rpc/, the main RPC library. The Makefile and -svc_auth.c found in rpc/ will replace those found in ../rpc/. You must also -edit ../rpc/rpc.h to include . - -OPERATION - -Please read the documentation and manual pages for information on how to -administer secure RPC. - -In the demo/ directory you'll find the 'whoami' service. This service uses DES -Authentication, and can be used to check out secure RPC. The client program, -'rme' takes a host as an argument. This host must be running the keyserv -daemon and the 'whoami_svc' server. The service returns the identity of the -client-user as known to the system on which the server is running. This -information is only returned, however, if the client request has proper DES -credentials. diff --git a/lib/librpc/secure_rpc/bin/Makefile b/lib/librpc/secure_rpc/bin/Makefile deleted file mode 100644 index 9d080187616d..000000000000 --- a/lib/librpc/secure_rpc/bin/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/10 4.0 RPCSRC -# -DESTDIR= -CFLAGS= -O -RPCLIB= -lrpclib - -# C programs that live in the current directory and need explicit make lines. -# (make depend has special rules for these files) -# -NSTD= chkey keylogin - -all: ${NSTD} - -chkey: chkey.c - ${CC} ${CFLAGS} -o chkey chkey.c -lrpcsvc -lmp ${RPCLIB} - -keylogin: keylogin.c - ${CC} ${CFLAGS} -o keylogin keylogin.c -lrpcsvc ${RPCLIB} - -install: - -for i in ${NSTD}; do \ - (install -s $$i ${DESTDIR}/usr/bin/$$i); done - -clean: - rm -f a.out core *.s *.o - rm -f ${NSTD} - -depend: - for i in ${NSTD}; do \ - cc -M ${INCPATH} $$i.c | sed 's/\.o//' | \ - awk ' { if ($$1 != prev) \ - { if (rec != "") print rec; rec = $$0; prev = $$1; } \ - else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ - else rec = rec " " $$2 } } \ - END { print rec } ' >> makedep; done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - -# Files listed in ${NSTD} have explicit make lines given below. - -# DO NOT DELETE THIS LINE -- make depend uses it - diff --git a/lib/librpc/secure_rpc/bin/chkey.c b/lib/librpc/secure_rpc/bin/chkey.c deleted file mode 100644 index eefb34e606d5..000000000000 --- a/lib/librpc/secure_rpc/bin/chkey.c +++ /dev/null @@ -1,302 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)chkey.c 2.3 88/08/15 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * Command to change one's public key in the public key database - */ -#include -#include -#include -#include -#include -#include -#include - -extern char *getpass(); -extern char *index(); -extern char *crypt(); -extern char *sprintf(); -extern long random(); - -static char PKMAP[] = "publickey.byname"; -static char *domain; -struct passwd *ypgetpwuid(); - -main(argc, argv) - int argc; - char **argv; -{ - char name[MAXNETNAMELEN+1]; - char public[HEXKEYBYTES + 1]; - char secret[HEXKEYBYTES + 1]; - char crypt1[HEXKEYBYTES + KEYCHECKSUMSIZE + 1]; - char crypt2[HEXKEYBYTES + KEYCHECKSUMSIZE + 1]; - int status; - char *pass; - struct passwd *pw; - char *master; - int euid; - int fd; - int force; - char *self; - - self = argv[0]; - force = 0; - for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) { - if (argv[0][2] != 0) { - usage(self); - } - switch (argv[0][1]) { - case 'f': - force = 1; - break; - default: - usage(self); - } - } - if (argc != 0) { - usage(self); - } - - (void)yp_get_default_domain(&domain); - if (yp_master(domain, PKMAP, &master) != 0) { - (void)fprintf(stderr, - "can't find master of publickey database\n"); - exit(1); - } - - getnetname(name); - (void)printf("Generating new key for %s.\n", name); - - euid = geteuid(); - if (euid != 0) { - pw = ypgetpwuid(euid); - if (pw == NULL) { - (void)fprintf(stderr, - "No yp password found: can't change key.\n"); - exit(1); - } - } else { - pw = getpwuid(0); - if (pw == NULL) { - (void)fprintf(stderr, - "No password found: can't change key.\n"); - exit(1); - } - } - pass = getpass("Password:"); - if (!force) { - if (strcmp(crypt(pass, pw->pw_passwd), pw->pw_passwd) != 0) { - (void)fprintf(stderr, "Invalid password.\n"); - exit(1); - } - } - - genkeys(public, secret, pass); - - bcopy(secret, crypt1, HEXKEYBYTES); - bcopy(secret, crypt1 + HEXKEYBYTES, KEYCHECKSUMSIZE); - crypt1[HEXKEYBYTES + KEYCHECKSUMSIZE] = 0; - xencrypt(crypt1, pass); - - if (force) { - bcopy(crypt1, crypt2, HEXKEYBYTES + KEYCHECKSUMSIZE + 1); - xdecrypt(crypt2, getpass("Retype password:")); - if (bcmp(crypt2, crypt2 + HEXKEYBYTES, KEYCHECKSUMSIZE) != 0 || - bcmp(crypt2, secret, HEXKEYBYTES) != 0) { - (void)fprintf(stderr, "Password incorrect.\n"); - exit(1); - } - } - - (void)printf("Sending key change request to %s...\n", master); - status = setpublicmap(name, public, crypt1); - if (status != 0) { - (void)printf("%s: unable to update yp database (%u): %s\n", - self, status, yperr_string(status)); - (void)printf("Perhaps %s is down?\n", master); - exit(1); - } - (void)printf("Done.\n"); - - if (key_setsecret(secret) < 0) { - (void)printf("Unable to login with new secret key.\n"); - exit(1); - } -} - -usage(name) - char *name; -{ - (void)fprintf(stderr, "usage: %s [-f]\n", name); - exit(1); -} - - -/* - * Generate a seed - */ -getseed(seed, seedsize, pass) - char *seed; - int seedsize; - unsigned char *pass; -{ - int i; - int rseed; - struct timeval tv; - - (void)gettimeofday(&tv, (struct timezone *)NULL); - rseed = tv.tv_sec + tv.tv_usec; - for (i = 0; i < 8; i++) { - rseed ^= (rseed << 8) | pass[i]; - } - srandom(rseed); - - for (i = 0; i < seedsize; i++) { - seed[i] = (random() & 0xff) ^ pass[i % 8]; - } -} - - -/* - * Generate a random public/secret key pair - */ -genkeys(public, secret, pass) - char *public; - char *secret; - char *pass; -{ - int i; - -#define BASEBITS (8*sizeof(short) - 1) -#define BASE (1 << BASEBITS) - - MINT *pk = itom(0); - MINT *sk = itom(0); - MINT *tmp; - MINT *base = itom(BASE); - MINT *root = itom(PROOT); - MINT *modulus = xtom(HEXMODULUS); - short r; - unsigned short seed[KEYSIZE/BASEBITS + 1]; - char *xkey; - - getseed((char *)seed, sizeof(seed), (unsigned char *)pass); - for (i = 0; i < KEYSIZE/BASEBITS + 1; i++) { - r = seed[i] % BASE; - tmp = itom(r); - mult(sk, base, sk); - madd(sk, tmp, sk); - mfree(tmp); - } - tmp = itom(0); - mdiv(sk, modulus, tmp, sk); - mfree(tmp); - pow(root, sk, modulus, pk); - xkey = mtox(sk); - adjust(secret, xkey); - xkey = mtox(pk); - adjust(public, xkey); - mfree(sk); - mfree(base); - mfree(pk); - mfree(root); - mfree(modulus); -} - -/* - * Adjust the input key so that it is 0-filled on the left - */ -adjust(keyout, keyin) - char keyout[HEXKEYBYTES+1]; - char *keyin; -{ - char *p; - char *s; - - for (p = keyin; *p; p++) - ; - for (s = keyout + HEXKEYBYTES; p >= keyin; p--, s--) { - *s = *p; - } - while (s >= keyout) { - *s-- = '0'; - } -} - -/* - * Set the entry in the public key map - */ -setpublicmap(name, public, secret) - char *name; - char *public; - char *secret; -{ - char pkent[1024]; - u_int rslt; - - (void)sprintf(pkent,"%s:%s", public, secret); - rslt = yp_update(domain, PKMAP, YPOP_STORE, - name, strlen(name), pkent, strlen(pkent)); - return (rslt); -} - -struct passwd * -ypgetpwuid(uid) - int uid; -{ - char uidstr[10]; - char *val; - int vallen; - static struct passwd pw; - char *p; - - (void)sprintf(uidstr, "%d", uid); - if (yp_match(domain, "passwd.byuid", uidstr, strlen(uidstr), - &val, &vallen) != 0) { - return (NULL); - } - p = index(val, ':'); - if (p == NULL) { - return (NULL); - } - pw.pw_passwd = p + 1; - p = index(pw.pw_passwd, ':'); - if (p == NULL) { - return (NULL); - } - *p = 0; - return (&pw); -} diff --git a/lib/librpc/secure_rpc/bin/keylogin.c b/lib/librpc/secure_rpc/bin/keylogin.c deleted file mode 100644 index 0643f07eee9e..000000000000 --- a/lib/librpc/secure_rpc/bin/keylogin.c +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)keylogin.c 2.2 88/08/10 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * Set secret key on local machine - */ -#include -#include -#include - -main(argc,argv) - int argc; - char *argv[]; -{ - char fullname[MAXNETNAMELEN + 1]; - char secret[HEXKEYBYTES + 1]; - char *getpass(); - - getnetname(fullname); - if (! getsecretkey(fullname, secret, getpass("Password:"))) { - fprintf(stderr, "Can't find %s's secret key\n", fullname); - exit(1); - } - if (secret[0] == 0) { - fprintf(stderr, "Password incorrect for %s\n", fullname); - exit(1); - } - if (key_setsecret(secret) < 0) { - fprintf(stderr, "Could not set %s's secret key\n", fullname); - fprintf(stderr, "Maybe the keyserver is down?\n"); - exit(1); - } - exit(0); -} diff --git a/lib/librpc/secure_rpc/demo/Makefile b/lib/librpc/secure_rpc/demo/Makefile deleted file mode 100644 index f1e62a7f6831..000000000000 --- a/lib/librpc/secure_rpc/demo/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# -# @(#)Makefile 2.2 88/08/15 4.0 RPCSRC -# -BIN = whoami_svc rme -GEN = whoami_clnt.c whoami_svc.c whoami_xdr.c whoami.h -LIB = -lrpclib -#use this line on SunOS or NFSSRC-based systems. -#LIB = -lrpcsvc -RPCCOM = rpcgen - -all: $(BIN) - -$(GEN): whoami.x - $(RPCCOM) whoami.x - -whoami_svc: whoami_proc.o whoami_svc.o whoami_xdr.o - $(CC) -o $@ whoami_proc.o whoami_svc.o whoami_xdr.o $(LIB) - -rme: rme.o whoami_clnt.o whoami_xdr.o - $(CC) -o $@ rme.o whoami_clnt.o whoami_xdr.o $(LIB) - -rme.o: rme.c whoami.h - -whoami_proc.o: whoami_proc.c whoami.h - -clean cleanup: - rm -f $(GEN) *.o $(BIN) - diff --git a/lib/librpc/secure_rpc/demo/rme.c b/lib/librpc/secure_rpc/demo/rme.c deleted file mode 100644 index 773eafaf5793..000000000000 --- a/lib/librpc/secure_rpc/demo/rme.c +++ /dev/null @@ -1,96 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rme.c 2.3 88/09/09 4.0 RPCSRC"; -#endif -/* - * rme.c: secure identity verifier and reporter: client side - */ -#include -#include -#include "whoami.h" - -/* - * Before running this program, the user must have a key in the publickey - * database, and must have logged in with a password (or used keylogin). - * The user's machine and the server's machine must both be running keyserv. - */ - -main(argc, argv) - int argc; - char *argv[]; -{ - CLIENT *cl; - char *server; - remote_identity *remote_me; - name *servername; - void *nullp; - - if (argc != 2) { - fprintf(stderr, "usage: %s host\n", argv[0]); - exit(1); - } - - /* - * Remember what our command line argument refers to - */ - server = argv[1]; - - /* - * Create client "handle" used for calling WHOAMI on the - * server designated on the command line. We tell the rpc package - * to use the "udp" protocol when contacting the server. - */ - cl = clnt_create(server, WHOAMI, WHOAMI_V1, "udp"); - if (cl == NULL) { - /* - * Couldn't establish connection with server. - * Print error message and die. - */ - clnt_pcreateerror(server); - exit(1); - } - /* - * Get network identifier for server machine. - */ - servername = whoami_whoru_1(nullp, cl); - if (servername == NULL) - { - fprintf(stderr, "Trouble communicating with %s\n", - clnt_sperror(cl, server)); - exit(1); - } - else if (*servername[0] == '\0') - { - fprintf(stderr, "Could not determine netname of WHOAMI server.\n"); - exit(1); - } - printf("Server's netname is: %s\n", *servername); - - /* - * A wide window and no synchronization is used. Client and server - * clock must be with five minutes of each other. - */ - if ((cl->cl_auth = authdes_create(*servername, 300, NULL, NULL)) == NULL) - { - fprintf(stderr, "Could not establish DES credentials of netname %s\n", - servername); - exit(1); - } - - /* - * Find out who I am, in the server's point of view. - */ - remote_me = whoami_iask_1(nullp, cl); - if (remote_me == NULL) - { - fprintf(stderr, "Trouble getting my identity from %s\n", - clnt_sperror(cl, server)); - exit(1); - } - /* - * Print out my identity. - */ - printf("My remote user name: %s\n", remote_me->remote_username); - printf("My remote real name: %s\n", remote_me->remote_realname); - - exit(0); -} diff --git a/lib/librpc/secure_rpc/demo/whoami.x b/lib/librpc/secure_rpc/demo/whoami.x deleted file mode 100644 index 041cd0a678ef..000000000000 --- a/lib/librpc/secure_rpc/demo/whoami.x +++ /dev/null @@ -1,33 +0,0 @@ -/* @(#)whoami.x 2.2 88/08/22 4.0 RPCSRC */ - -const WHOAMI_NGROUPS = 16; - -typedef string name; - -struct remote_identity { - bool authenticated; /* TRUE if the server authenticates us */ - name remote_username; /* login name */ - name remote_realname; /* gcos-field name (long name) */ - int uid; - int gid; - int gids; -}; - -program WHOAMI { - version WHOAMI_V1 { - /* - * Report on the server's notion of the client's identity. - * Will respond to AUTH_DES only. - */ - remote_identity - WHOAMI_IASK(void) = 1; - /* - * Return server's netname. AUTH_NONE is okay. - * This routine allows this server to be started under any uid, - * and the client can ask it its netname for use in authdes_create(). - */ - name - WHOAMI_WHORU(void) = 2; - - } = 1; -} = 80955; diff --git a/lib/librpc/secure_rpc/demo/whoami_proc.c b/lib/librpc/secure_rpc/demo/whoami_proc.c deleted file mode 100644 index 231d32228002..000000000000 --- a/lib/librpc/secure_rpc/demo/whoami_proc.c +++ /dev/null @@ -1,95 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)whoami_proc.c 2.3 89/07/11 4.0 RPCSRC"; -#endif -/* - * whoami_proc.c: secure identity verifier and reporter: server proc - */ -#include -#include -#include -#include -#include "whoami.h" - -extern char *strcpy(); - -/* - * Report on the server's notion of the client's identity. - */ -remote_identity * -whoami_iask_1(nullarg, rqstp) - void *nullarg; - struct svc_req *rqstp; -{ -static remote_identity whoisthem; -static char username[MAXNETNAMELEN+1]; -static char realname[MAXNETNAMELEN+1]; /* really gecos field */ -static int grouplist[NGROUPS]; - char publickey[HEXKEYBYTES+1]; - - struct authdes_cred *des_cred; - struct passwd *pwdent; - - switch (rqstp->rq_cred.oa_flavor) - { - case AUTH_DES: - whoisthem.remote_username = username; - whoisthem.remote_realname = realname; - whoisthem.gids.gids_val = grouplist; - des_cred = (struct authdes_cred *) rqstp->rq_clntcred; - /* - * Check to see if the netname being used is in the public key - * database (if not, reject this (potential) imposter). - */ - if (! getpublickey(des_cred->adc_fullname.name, publickey)) - { - svcerr_weakauth(rqstp->rq_xprt); - return(NULL); - } - /* - * Get the info that the client wants. - */ - if (! netname2user(des_cred->adc_fullname.name, &whoisthem.uid, - &whoisthem.gid, &whoisthem.gids.gids_len, - whoisthem.gids.gids_val)) - { /* netname not found */ - whoisthem.authenticated = FALSE; - strcpy(whoisthem.remote_username, "nobody"); - strcpy(whoisthem.remote_realname, "INTERLOPER!"); - whoisthem.uid = -2; - whoisthem.gid = -2; - whoisthem.gids.gids_len = 0; - return(&whoisthem); - } - /* else we found the netname */ - whoisthem.authenticated = TRUE; - pwdent = getpwuid(whoisthem.uid); - strcpy(whoisthem.remote_username, pwdent->pw_name); - strcpy(whoisthem.remote_realname, pwdent->pw_gecos); - return(&whoisthem); - break; - case AUTH_UNIX: - case AUTH_NULL: - default: - svcerr_weakauth(rqstp->rq_xprt); - return(NULL); - } -} - -/* - * Return server's netname. AUTH_NONE is valid. - * This routine allows this server to be started under any uid, - * and the client can ask us our netname for use in authdes_create(). - */ -name * -whoami_whoru_1(nullarg, rqstp) - void *nullarg; - struct svc_req *rqstp; -{ -static name whoru; -static char servername[MAXNETNAMELEN+1]; - - whoru = servername; - getnetname(servername); - - return(&whoru); -} diff --git a/lib/librpc/secure_rpc/des/des.h b/lib/librpc/secure_rpc/des/des.h deleted file mode 100644 index c237f23d2b82..000000000000 --- a/lib/librpc/secure_rpc/des/des.h +++ /dev/null @@ -1,68 +0,0 @@ -/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Generic DES driver interface - * Keep this file hardware independent! - * Copyright (c) 1986 by Sun Microsystems, Inc. - */ - -#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ -#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ - -enum desdir { ENCRYPT, DECRYPT }; -enum desmode { CBC, ECB }; - -/* - * parameters to ioctl call - */ -struct desparams { - u_char des_key[8]; /* key (with low bit parity) */ - enum desdir des_dir; /* direction */ - enum desmode des_mode; /* mode */ - u_char des_ivec[8]; /* input vector */ - unsigned des_len; /* number of bytes to crypt */ - union { - u_char UDES_data[DES_QUICKLEN]; - u_char *UDES_buf; - } UDES; -# define des_data UDES.UDES_data /* direct data here if quick */ -# define des_buf UDES.UDES_buf /* otherwise, pointer to data */ -}; - -/* - * Encrypt an arbitrary sized buffer - */ -#define DESIOCBLOCK _IOWR(d, 6, struct desparams) - -/* - * Encrypt of small amount of data, quickly - */ -#define DESIOCQUICK _IOWR(d, 7, struct desparams) - diff --git a/lib/librpc/secure_rpc/des/des_crypt.c b/lib/librpc/secure_rpc/des/des_crypt.c deleted file mode 100644 index 57a9e712f86b..000000000000 --- a/lib/librpc/secure_rpc/des/des_crypt.c +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * des_crypt.c, DES encryption library routines - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#include -#include -#include - -/* - * To see if chip is installed - */ -#define UNOPENED (-2) -static int g_desfd = UNOPENED; - - -/* - * Copy 8 bytes - */ -#define COPY8(src, dst) { \ - register char *a = (char *) dst; \ - register char *b = (char *) src; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ -} - -/* - * Copy multiple of 8 bytes - */ -#define DESCOPY(src, dst, len) { \ - register char *a = (char *) dst; \ - register char *b = (char *) src; \ - register int i; \ - for (i = (int) len; i > 0; i -= 8) { \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \ - } \ -} - -/* - * CBC mode encryption - */ -cbc_crypt(key, buf, len, mode, ivec) - char *key; - char *buf; - unsigned len; - unsigned mode; - char *ivec; -{ - int err; - struct desparams dp; - - dp.des_mode = CBC; - COPY8(ivec, dp.des_ivec); - err = common_crypt(key, buf, len, mode, &dp); - COPY8(dp.des_ivec, ivec); - return(err); -} - - -/* - * ECB mode encryption - */ -ecb_crypt(key, buf, len, mode) - char *key; - char *buf; - unsigned len; - unsigned mode; -{ - struct desparams dp; - - dp.des_mode = ECB; - return(common_crypt(key, buf, len, mode, &dp)); -} - - - -/* - * Common code to cbc_crypt() & ecb_crypt() - */ -static -common_crypt(key, buf, len, mode, desp) - char *key; - char *buf; - register unsigned len; - unsigned mode; - register struct desparams *desp; -{ - register int desdev; - register int res; - - if ((len % 8) != 0 || len > DES_MAXDATA) { - return(DESERR_BADPARAM); - } - desp->des_dir = - ((mode & DES_DIRMASK) == DES_ENCRYPT) ? ENCRYPT : DECRYPT; - - desdev = mode & DES_DEVMASK; - COPY8(key, desp->des_key); - /* - * software - */ - if (!_des_crypt(buf, len, desp)) { - return (DESERR_HWERROR); - } - return(desdev == DES_SW ? DESERR_NONE : DESERR_NOHWDEVICE); -} diff --git a/lib/librpc/secure_rpc/des/des_crypt.h b/lib/librpc/secure_rpc/des/des_crypt.h deleted file mode 100644 index d21d095b7155..000000000000 --- a/lib/librpc/secure_rpc/des/des_crypt.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI - * - * des_crypt.h, des library routine interface - * Copyright (C) 1986, Sun Microsystems, Inc. - */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ -#define DES_DIRMASK (1 << 0) -#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ -#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ - - -#define DES_DEVMASK (1 << 1) -#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ -#define DES_SW (1*DES_DEVMASK) /* Use software device */ - - -#define DESERR_NONE 0 /* succeeded */ -#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ -#define DESERR_HWERROR 2 /* failed, hardware/driver error */ -#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ - -#define DES_FAILED(err) \ - ((err) > DESERR_NOHWDEVICE) - -/* - * cbc_crypt() - * ecb_crypt() - * - * Encrypt (or decrypt) len bytes of a buffer buf. - * The length must be a multiple of eight. - * The key should have odd parity in the low bit of each byte. - * ivec is the input vector, and is updated to the new one (cbc only). - * The mode is created by oring together the appropriate parameters. - * DESERR_NOHWDEVICE is returned if DES_HW was specified but - * there was no hardware to do it on (the data will still be - * encrypted though, in software). - */ - - -/* - * Cipher Block Chaining mode - */ -cbc_crypt(/* key, buf, len, mode, ivec */); /* - char *key; - char *buf; - unsigned len; - unsigned mode; - char *ivec; -*/ - - -/* - * Electronic Code Book mode - */ -ecb_crypt(/* key, buf, len, mode */); /* - char *key; - char *buf; - unsigned len; - unsigned mode; -*/ - - -#ifndef KERNEL -/* - * Set des parity for a key. - * DES parity is odd and in the low bit of each byte - */ -void -des_setparity(/* key */); /* - char *key; -*/ -#endif diff --git a/lib/librpc/secure_rpc/des/des_soft.c b/lib/librpc/secure_rpc/des/des_soft.c deleted file mode 100644 index 01dd7f280b2f..000000000000 --- a/lib/librpc/secure_rpc/des/des_soft.c +++ /dev/null @@ -1,67 +0,0 @@ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Table giving odd parity in the low bit for ASCII characters - */ -static char partab[128] = { - 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, - 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, - 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, - 0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f, - 0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26, - 0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f, - 0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37, - 0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e, - 0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46, - 0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f, - 0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57, - 0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e, - 0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67, - 0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e, - 0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76, - 0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f, -}; - -/* - * Add odd parity to low bit of 8 byte key - */ -void -des_setparity(p) - char *p; -{ - int i; - - for (i = 0; i < 8; i++) { - *p = partab[*p & 0x7f]; - p++; - } -} diff --git a/lib/librpc/secure_rpc/doc/Makefile b/lib/librpc/secure_rpc/doc/Makefile deleted file mode 100644 index 3cfbe9efef81..000000000000 --- a/lib/librpc/secure_rpc/doc/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# @(#)Makefile 2.1 88/08/10 4.0 RPCSRC -# -# -TROFF= ditroff -TOPTS= -t -NROFF= nroff -NOPTS= -PIC= pic -TBL= tbl -EQN= eqn - -SRC= nfs.secure.ms - -all default: all.nroff - -install: all.nroff - @echo "Nothing installed." - -all.nroff: ${SRC} - ${TBL} ${SRC} | ${EQN} | ${NROFF} ${NOPTS} -ms >all.nroff - -all.troff: ${SRC} - ${TBL} ${SRC} | ${PIC} | ${EQN} | ${TROFF} ${TOPTS} -ms >all.troff - -# - -nfs.secure.nroff: nfs.secure.ms - ${TBL} nfs.secure.ms | ${EQN} | ${NROFF} ${NOPTS} -ms >nfs.secure.nroff - -nfs.secure.troff: nfs.secure.ms - ${TBL} nfs.secure.ms|${PIC}|${EQN}| ${TROFF} ${TOPTS} -ms >nfs.secure.troff - -clean: - rm -f *.nroff *.troff - -spell: ${SRC} - @for i in ${SRC}; do \ - echo $$i; spell $$i | sort | comm -23 - spell.ok > $$i.spell; \ - done diff --git a/lib/librpc/secure_rpc/doc/nfs.secure.ms b/lib/librpc/secure_rpc/doc/nfs.secure.ms deleted file mode 100644 index 247679018ae3..000000000000 --- a/lib/librpc/secure_rpc/doc/nfs.secure.ms +++ /dev/null @@ -1,934 +0,0 @@ -.\" Must use -- pic tbl eqn -- with this one. -.\" -.\" @(#)nfs.secure.ms 2.2 88/08/09 4.0 RPCSRC -.de BT -.if \\n%=1 .tl ''- % -'' -.. -.ND -.\" prevent excess underlining in nroff -.if n .fp 2 R -.OH 'Secure Networking''Page %' -.EH 'Page %''Secure Networking' -.if \\n%=1 .bp -.EQ -delim $$ -gsize 11 -.EN -.SH -\&Secure Networking -.nr OF 1 -.IX "security" "of networks" "" "" PAGE START -.IX "network security" "" "" "" PAGE START -.IX "NFS security" "" "" "" PAGE START -.LP -RPCSRC 4.0 includes an authentication system -that greatly improves the security of network environments. -The system is general enough to be used by other -.UX -and non-UNIX systems. -The system uses DES encryption and public key cryptography -to authenticate both users and machines in the network. -(DES stands for Data Encryption Standard.) -.LP -Public key cryptography is a cipher system that involves two keys: -one public and the other private. -The public key is published, while the private key is not; -the private (or secret) key is used to encrypt and decrypt data. -Sun's system differs from some other public key cryptography systems -in that the public and secret keys are used to generate a common key, -which is used in turn to create a DES key. -DES is relatively fast, -and on Sun Workstations, -optional hardware is available to make it even faster. -.# -.NH 0 -\&Administering Secure RPC -.IX "administering secure RPC" -.IX "security" "RPC administration" -.LP -This section describes what the system administrator must do -in order to use secure networking. -.IP 1 -RPCSRC now includes the -.I /etc/publickey -.IX "etc/publickey" "" "\&\fI/etc/publickey\fP" -database, which should contain three fields for each user: -the user's netname, a public key, and an encrypted secret key. -The corresponding Yellow Pages map is available to YP clients as -.I publickey.byname -but the database should reside only on the YP master. Make sure -.I /etc/netid -exists on the YP master server. -As normally installed, the only user is -.I nobody . -This is convenient administratively, -because users can establish their own public keys using -.I chkey (1) -.IX "chkey command" "" "\&\fIchkey\fP command" -without administrator intervention. -For even greater security, -the administrator can establish public keys for everyone using -.I newkey (8). -.IX "newkey command" "" "\&\fInewkey\fP command" -Note that the Yellow Pages take time to propagate a new map, -so it's a good idea for users to run -.I chkey , -or for the administrator to run -.I newkey , -just before going home for the night. -.IP 2 -Verify that the -.I keyserv (8c) -.IX "keyserv daemon" "" "\&\fIkeyserv\fP daemon" -daemon was started by -.I /etc/rc.local -and is still running. -This daemon performs public key encryption -and stores the private key (encrypted, of course) in -.I /etc/keystore : -.DS -% \fBps aux | grep keyserv\fP -root 1354 0.0 4.1 128 296 p0 I Oct 15 0:13 keyserv -.DE -When users log in with -.I login -.IX "login command" "" "\&\fIlogin\fP command" -or remote log in with -.I rlogin , -these programs use the typed password to decrypt the secret key stored in -.I /etc/publickey . -This becomes the private key, and gets passed to the -.I keyserv -daemon. -If users don't type a password for -.I login -or -.I rlogin , -either because their password field is empty -or because their machine is in the -.I hosts\fR.\fPequiv -.IX "etc/hosts.equiv" "" "\&\fI/etc/hosts.equiv\fP" -file of the remote host, -they can still place a private key in -.I /etc/keystore -by invoking the -.I keylogin (1) -.IX "keylogin command" "" "\&\fIkeylogin\fP command" -program. -Administrators should take care not to delete -.I /etc/keystore -and -.I /etc/.rootkey -(the latter file contains the private key for -.I root ). -.IP 3 -When you reinstall, move, or upgrade a machine, save -.I /etc/keystore -and -.I /etc/.rootkey -along with everything else you normally save. -.LP -.LP -Note that if you -.I login , -.I rlogin , -or -.I telnet -to another machine, are asked for your password, and type it correctly, -you've given away access to your own account. -This is because your secret key is now stored in -.I /etc/keystore -on that remote machine. -This is only a concern if you don't trust the remote machine. -If this is the case, -don't ever log in to a remote machine if it asks for your password. -Instead, use NFS to remote mount the files you're looking for. -At this point there is no -.I keylogout -command, even though there should be. -.LP -The remainder of this chapter discusses the theory of secure networking, -and is useful as a background for both users and administrators. -.# -.NH 1 -\&Security Shortcomings of NFS -.IX "security" "shortcomings of NFS" -.LP -Sun's Remote Procedure Call (RPC) mechanism has proved to be a very -powerful primitive for building network services. -The most well-known of these services is the Network File System (NFS), -a service that provides transparent file-sharing -between heterogeneous machine architectures and operating systems. -The NFS is not without its shortcomings, however. -Currently, an NFS server authenticates a file request by authenticating the -machine making the request, but not the user. -On NFS-based filesystems, it is a simple matter of running -.I su -.IX "su command" "" "\&\fIsu\fP command" -to impersonate the rightful owner of a file. -But the security weaknesses of the NFS are nothing new. -The familiar command -.I rlogin -is subject to exactly the same attacks as the NFS -because it uses the same kind of authentication. -.LP -A common solution to network security problems -is to leave the solution to each application. -A far better solution is to put authentication at the RPC level. -The result is a standard authentication system -that covers all RPC-based applications, -such as the NFS and the Yellow Pages (a name-lookup service). -Our system allows the authentication of users as well as machines. -The advantage of this is that it makes a network environment -more like the older time-sharing environment. -Users can log in on any machine, -just as they could log in on any terminal. -Their login password is their passport to network security. -No knowledge of the underlying authentication system is required. -Our goal was a system that is as secure and easy to use -as a time-sharing system. -.LP -Several remarks are in order. Given -.I root -access and a good knowledge of network programming, -anyone is capable of injecting arbitrary data into the network, -and picking up any data from the network. -However, on a local area network, no machine is capable of packet smashing \(en -capturing packets before they reach their destination, changing the contents, -then sending packets back on their original course \(en -because packets reach all machines, including the server, at the same time. -Packet smashing is possible on a gateway, though, -so make sure you trust all gateways on the network. -The most dangerous attacks are those involving the injection of data, -such as impersonating a user by generating the right packets, -or recording conversations and replaying them later. -These attacks affect data integrity. -Attacks involving passive eavesdropping \(en -merely listening to network traffic without impersonating anybody \(en -are not as dangerous, since data integrity had not been compromised. -Users can protect the privacy of sensitive information -by encrypting data that goes over the network. -It's not easy to make sense of network traffic, anyway. -.# -.NH 1 -\&RPC Authentication -.IX "RPC authentication" -.IX "authentication" "RPC" -.LP -RPC is at the core of the new network security system. -To understand the big picture, -it's necessary to understand how authentication works in RPC. -RPC's authentication is open-ended: -a variety of authentication systems may be plugged into it -and may coexist on the network. -Currently, we have two: UNIX and DES. -UNIX authentication is the older, weaker system; -DES authentication is the new system discussed in this chapter. -Two terms are important for any RPC authentication system: -.I credentials -and -.I verifiers . -Using ID badges as an example, the credential is what identifies a person: -a name, address, birth date, etc. -The verifier is the photo attached to the badge: -you can be sure the badge has not been stolen by checking the photo -on the badge against the person carrying it. -In RPC, things are similar. -The client process sends both a credential and a verifier -to the server with each RPC request. -The server sends back only a verifier, -since the client already knows the server's credentials. -.# -.NH 2 -\&UNIX Authentication -.IX "UNIX authentication" -.IX "authentication" "UNIX" -.LP -UNIX authentication was used by most of Sun's original network services. -The credentials contain the client's machine-name, -.I uid , -.I gid , -and group-access-list. -The verifier contains \fBnothing\fP! -There are two problems with this system. -The glaring problem is the empty verifier, -which makes it easy to cook up the right credential using -.I hostname -.IX "hostname command" "" "\&\fIhostname\fP command" -and -.I su . -.IX "su command" "" "\&\fIsu\fP command" -If you trust all root users in the network, this is not really a problem. -But many networks \(en especially at universities \(en are not this secure. -The NFS tries to combat deficiencies in UNIX authentication -by checking the source Internet address of -.I mount -requests as a verifier of the -.I hostname -field, and accepting requests only from privileged Internet ports. -Still, it is not difficult to circumvent these measures, -and NFS really has no way to verify the user-ID. -.LP -The other problem with UNIX authentication appears in the name UNIX. -It is unrealistic to assume that all machines on a network -will be UNIX machines. -The NFS works with MS-DOS and VMS machines, -but UNIX authentication breaks down when applied to them. -For instance, MS-DOS doesn't even have a notion of different user IDs. -.LP -Given these shortcomings, -it is clear what is needed in a new authentication system: -operating system independent credentials, and secure verifiers. -This is the essence of DES authentication discussed below. -.# -.NH 2 -\&DES Authentication -.IX "DES authentication" -.IX "authentication" "DES" -.LP -The security of DES authentication is based on -a sender's ability to encrypt the current time, -which the receiver can then decrypt and check against its own clock. -The timestamp is encrypted with DES. -Two things are necessary for this scheme to work: -1) the two agents must agree on what the current time is, and -2) the sender and receiver must be using the same encryption key. -.LP -If a network has time synchronization (Berkeley's TEMPO for example), -then client/server time synchronization is performed automatically. -However, if this is not available, -timestamps can be computed using the server's time instead of network time. -In order to do this, the client asks the server what time it is, -before starting the RPC session, -then computes the time difference between its own clock and the server's. -This difference is used to offset the client's clock when computing timestamps. -If the client and server clocks get out of sync -to the point where the server begins rejecting the client's requests, -the DES authentication system just resynchronizes with the server. -.LP -Here's how the client and server arrive at the same encryption key. -When a client wishes to talk to a server, it generates at random -a key to be used for encrypting the timestamps (among other things). -This key is known as the -.I "conversation key, CK." -The client encrypts the conversation key using a public key scheme, -and sends it to the server in its first transaction. -This key is the only thing that is ever encrypted with public key cryptography. -The particular scheme used is described further on in this chapter. -For now, suffice to say that for any two agents A and B, -there is a DES key $K sub AB$ that only A and B can deduce. -This key is known as the -.I "common key," -$K sub AB$. -.EQ -gsize 10 -.EN -.ne 1i -.PS -.in +.7i -circlerad=.4 -boxht=.2 -boxwid=1.3 -circle "\s+9A\s-9" "(client)" at 0,1.2 -circle "\s+9B\s-9" "(server)" at 5.1,1.2 -line invis at .5,2 ; box invis "\fBCredential\fP"; line invis; - box invis "\fBVerifier\fP" -arrow at .5,1.7; box "$A, K sub AB (CK), CK(win)$"; arrow; - box "$CK(t sub 1 ), CK(win + 1)$"; arrow -arrow <- at .5,1.4; line right 1.3; line; - box "$CK(t sub 1 - 1), ID$"; arrow <- -arrow at .5,1; box "ID"; arrow; - box "$CK(t sub 2 )$"; arrow -arrow <- at .5,.7; line right 1.3; line; - box "$CK(t sub 2 - 1), ID$"; arrow <- -arrow at .5,.3; box "ID"; arrow; - box "$CK(t sub n )$"; arrow -arrow <- at .5,0; line right 1.3; line; - box "$CK(t sub n - 1), ID$"; arrow <- -.PE -.EQ -gsize 11 -.EN -.in -.7i -.LP -The figure above illustrates the authentication protocol in more detail, -describing client A talking to server B. -A term of the form $K(x)$ means $x$ encrypted with the DES key $K$. -Examining the figure, you can see that for its first request, -the client's credential contains three things: -its name $A$, the conversation key $CK$ encrypted with the common key -$K sub AB$, and a thing called $win$ (window) encrypted with $CK$. -What the window says to the server, in effect, is this: -.LP -.I -I will be sending you many credentials in the future, -but there may be crackers sending them too, -trying to impersonate me with bogus timestamps. -When you receive a timestamp, check to see if your current time -is somewhere between the timestamp and the timestamp plus the window. -If it's not, please reject the credential. -.LP -For secure NFS filesystems, the window currently defaults to 30 minutes. -The client's verifier in the first request contains the encrypted timestamp -and an encrypted verifier of the specified window, $win + 1$. -The reason this exists is the following. -Suppose somebody wanted to impersonate A by writing a program -that instead of filling in the encrypted fields of the credential and verifier, -just stuffs in random bits. -The server will decrypt CK into some random DES key, -and use it to decrypt the window and the timestamp. -These will just end up as random numbers. -After a few thousand trials, there is a good chance -that the random window/timestamp pair will pass the authentication system. -The window verifier makes guessing the right credential much more difficult. -.LP -After authenticating the client, -the server stores four things into a credential table: -the client's name A, the conversation key $CK$, the window, and the timestamp. -The reason the server stores the first three things should be clear: -it needs them for future use. -The reason for storing the timestamp is to protect against replays. -The server will only accept timestamps -that are chronologically greater than the last one seen, -so any replayed transactions are guaranteed to be rejected. -The server returns to the client in its verifier an index ID -into its credential table, plus the client's timestamp minus one, -encrypted by $CK$. -The client knows that only the server could have sent such a verifier, -since only the server knows what timestamp the client sent. -The reason for subtracting one from it is to insure that it is invalid -and cannot be reused as a client verifier. -.LP -The first transaction is rather complicated, -but after this things go very smoothly. -The client just sends its ID and an encrypted timestamp to the server, -and the server sends back the client's timestamp minus one, -encrypted by $CK$. -.# -.NH 1 -\&Public Key Encryption -.IX "public key encryption" -.LP -The particular public key encryption scheme Sun uses -is the Diffie-Hellman method. -The way this algorithm works is to generate a -.I "secret key" -$SK sub A$ at random -and compute a -.I "public key" -$PK sub A$ using the following formula -($PK$ and $SK$ are 192 bit numbers and \(*a is a well-known constant): -.EQ -PK sub A ~ = ~ alpha sup {SK sub A} -.EN -Public key $PK sub A$ is stored in a public directory, -but secret key $SK sub A$ is kept private. -Next, $PK sub B$ is generated from $SK sub B$ in the same manner as above. -Now common key $K sub AB$ can be derived as follows: -.EQ -K sub AB ~ = ~ PK sub B sup {SK sub A} ~ = ~ -( alpha sup {SK sub B} ) sup {SK sub A} ~ = ~ -alpha sup {( SK sub A SK sub B )} -.EN -Without knowing the client's secret key, -the server can calculate the same common key $K sub AB$ -in a different way, as follows: -.EQ -K sub AB ~ = ~ PK sub A sup {SK sub B} ~ = ~ -( alpha sup {SK sub A} ) sup {SK sub B} ~ = ~ -alpha sup {( SK sub A SK sub B )} -.EN -Notice that nobody else but the server and client can calculate $K sub AB$, -since doing so requires knowing either one secret key or the other. -All of this arithmetic is actually computed modulo $M$, -which is another well-known constant. -It would seem at first that somebody could guess your secret key -by taking the logarithm of your public one, -but $M$ is so large that this is a computationally infeasible task. -To be secure, $K sub AB$ has too many bits to be used as a DES key, -so 56 bits are extracted from it to form the DES key. -.LP -Both the public and the secret keys -are stored indexed by netname in the Yellow Pages map -.I publickey.byname -the secret key is DES-encrypted with your login password. -When you log in to a machine, the -.I login -program grabs your encrypted secret key, -decrypts it with your login password, -and gives it to a secure local keyserver to save -for use in future RPC transactions. -Note that ordinary users do not have to be aware of -their public and secret keys. -In addition to changing your login password, the -.I yppasswd -.IX "yppasswd command" "" "\&\fIyppasswd\fP command" -program randomly generates a new public/secret key pair as well. -.LP -The keyserver -.I keyserv (8c) -.IX "keyserv daemon" "" "\&\fIkeyserv\fP daemon" -is an RPC service local to each machine -that performs all of the public key operations, -of which there are only three. They are: -.DS -setsecretkey(secretkey) -encryptsessionkey(servername, des_key) -decryptsessionkey(clientname, des_key) -.DE -.I setsecretkey() -tells the keyserver to store away your secret key $SK sub A$ for future use; -it is normally called by -.I login . -The client program calls -.I encryptsessionkey() -to generate the encrypted conversation key -that is passed in the first RPC transaction to a server. -The keyserver looks up -.I servername 's -public key and combines it with the client's secret key (set up by a previous -.I setsecretkey() -call) to generate the key that encrypts -.I des_key . -The server asks the keyserver to decrypt the conversation key by calling -.I decryptsessionkey(). -Note that implicit in these procedures is the name of caller, -who must be authenticated in some manner. -The keyserver cannot use DES authentication to do this, -since it would create deadlock. -The keyserver solves this problem by storing the secret keys by -.I uid , -and only granting requests to local root processes. -The client process then executes a -.I setuid -process, owned by root, which makes the request on the part of the client, -telling the keyserver the real -.I uid -of the client. Ideally, the three operations described above -would be system calls, and the kernel would talk to the keyserver directly, -instead of executing the -.I setuid -program. -.# -.NH 1 -\&Naming of Network Entities -.IX "naming of network entities" -.IX "network naming" -.LP -The old UNIX authentication system has a few problems when it comes to naming. -Recall that with UNIX authentication, -the name of a network entity is basically the -.I uid . -These -.I uid s -are assigned per Yellow Pages naming domain, -which typically spans several machines. -We have already stated one problem with this system, -that it is too UNIX system oriented, -but there are two other problems as well. -One is the problem of -.I uid -clashes when domains are linked together. -The other problem is that the super-user (with -.I uid -of 0) should not be assigned on a per-domain basis, -but rather on a per-machine basis. -By default, the NFS deals with this latter problem in a severe manner: -it does not allow root access across the network by -.I uid -0 at all. -.LP -DES authentication corrects these problems -by basing naming upon new names that we call -.I netnames. -Simply put, a netname is just a string of printable characters, -and fundamentally, it is really these netnames that we authenticate. -The public and secret keys are stored on a per-netname, -rather than per-username, basis. -The Yellow Pages map -.I netid.byname -maps the netname into a local -.I uid -and group-access-list, -though non-Sun environments may map the netname into something else. -.LP -We solve the Internet naming problem by choosing globally unique netnames. -This is far easier then choosing globally unique user IDs. -In the Sun environment, user names are unique within each Yellow Page domain. -Netnames are assigned by concatenating the operating system and user ID -with the Yellow Pages and ARPA domain names. -For example, a UNIX system user with a user ID of 508 in the domain -.I eng.sun.COM -would be assigned the following netname: -.I unix.508@eng.sun.COM . -A good convention for naming domains is to append -the ARPA domain name (COM, EDU, GOV, MIL) to the local domain name. -Thus, the Yellow Pages domain -.I eng -within the ARPA domain -.I sun.COM -becomes -.I eng.sun.COM . -.LP -We solve the problem of multiple super-users per domain -by assigning netnames to machines as well as to users. -A machine's netname is formed much like a user's. -For example, a UNIX machine named -.I hal -in the same domain as before has the netname -.I unix.hal@eng.sun.COM . -Proper authentication of machines is very important for diskless machines -that need full access to their home directories over the net. -.LP -Non-Sun environments will have other ways of generating netnames, -but this does not preclude them from accessing -the secure network services of the Sun environment. -To authenticate users from any remote domain, -all that has to be done is make entries for them in two Yellow Pages databases. -One is an entry for their public and secret keys, -the other is for their local -.I uid -and group-access-list mapping. -Upon doing this, users in the remote domain -will be able access all of the local network services, -such as the NFS and remote logins. -.# -.NH 1 -\&Applications of DES Authentication -.IX "applications of DES authentication" -.IX "authentication" "DES" -.LP -The first application of DES authentication -is a generalized Yellow Pages update service. -This service allows users to update private fields in Yellow Page databases. -So far the Yellow Pages maps -.I hosts, -.I ethers, -.I bootparams -and -.I publickey -employ the DES-based update service. -Before the advent of an update service for mail aliases, -Sun had to hire a full-time person just to update mail aliases. -.LP -The second application of DES authentication is the most important: -a more secure Network File System. -There are three security problems with the -old NFS using UNIX authentication. -The first is that verification of credentials occurs only at mount time -when the client gets from the server a piece of information -that is its key to all further requests: the -.I "file handle" . -Security can be broken if one can figure out a file handle -without contacting the server, perhaps by tapping into the net or by guessing. -After an NFS file system has been mounted, -there is no checking of credentials during file requests, -which brings up the second problem. -If a file system has been mounted from a server that serves multiple clients -(as is typically the case), there is no protection -against someone who has root permission on their machine using -.I su -(or some other means of changing -.I uid ) -gaining unauthorized access to other people's files. -The third problem with the NFS is the severe method it uses to circumvent -the problem of not being able to authenticate remote client super-users: -denying them super-user access altogether. -.LP -The new authentication system corrects all of these problems. -Guessing file handles is no longer a problem since in order to gain -unauthorized access, the miscreant will also have to guess the right -encrypted timestamp to place in the credential, -which is a virtually impossible task. -The problem of authenticating root users is solved, -since the new system can authenticate machines. -At this point, however, -secure NFS is not used for root filesystems. -Root users of nonsecure filesystems are identified by IP address. -.LP -Actually, the level of security associated with each filesystem -may be altered by the administrator. The file -.I /etc/exports -.IX "etc/exports" "" "\&\fI/etc/exports\fP" -contains a list of filesystems and which machines may mount them. -By default, filesystems are exported with UNIX authentication, -but the administrator can have them exported with DES authentication -by specifying -.I -secure -on any line in the -.I /etc/exports -file. Associated with DES authentication is a parameter: -the maximum window size that the server is willing to accept. -.# -.NH 1 -\&Security Issues Remaining -.IX "security" "issues remaining" -.IX "remaining security issues" -.LP -There are several ways to break DES authentication, but using -.I su -is not one of them. In order to be authenticated, -your secret key must be stored by your workstation. -This usually occurs when you login, with the -.I login -program decrypting your secret key with your login password, -and storing it away for you. -If somebody tries to use -.I su -to impersonate you, it won't work, -because they won't be able to decrypt your secret key. Editing -.I /etc/passwd -isn't going to help them either, because the thing they need to edit, -your encrypted secret key, is stored in the Yellow Pages. -If you log into somebody else's workstation and type in your password, -then your secret key would be stored in their workstation and they could use -.I su -to impersonate you. But this is not a problem since you should not -be giving away your password to a machine you don't trust anyway. -Someone on that machine could just as easily change -.I login -to save all the passwords it sees into a file. -.LP -Not having -.I su -to employ any more, how can nefarious users impersonate others now? -Probably the easiest way is to guess somebody's password, -since most people don't choose very secure passwords. -We offer no protection against this; -it's up to each user to choose a secure password. -.LP -The next best attack would be to attempt replays. -For example, let's say I have been squirreling away -all of your NFS transactions with a particular server. -As long as the server remains up, -I won't succeed by replaying them since the server always demands timestamps -that are greater than the previous ones seen. -But suppose I go and pull the plug on your server, causing it to crash. -As it reboots, its credential table will be clean, -so it has lost all track of previously seen timestamps, -and now I am free to replay your transactions. -There are few things to be said about this. -First of all, servers should be kept in a secure place -so that no one can go and pull the plug on them. -But even if they are physically secure, -servers occasionally crash without any help. -Replaying transactions is not a very big security problem, -but even so, there is protection against it. -If a client specifies a window size that is smaller than the time it takes -a server to reboot (5 to 10 minutes), the server will reject -any replayed transactions because they will have expired. -.LP -There are other ways to break DES authentication, -but they are much more difficult. -These methods involve breaking the DES key itself, -or computing the logarithm of the public key, -both of which would would take months of compute time on a supercomputer. -But it is important to keep our goals in mind. -Sun did not aim for super-secure network computing. -What we wanted was something as secure as a good time-sharing system, -and in that we have been successful. -.LP -There is another security issue that DES authentication does not address, -and that is tapping of the net. -Even with DES authentication in place, -there is no protection against somebody watching what goes across the net. -This is not a big problem for most things, -such as the NFS, since very few files are not publically readable, and besides, -trying to make sense of all the bits flying over the net is not a trivial task. -For logins, this is a bit of a problem because you wouldn't -want somebody to pick up your password over the net. -As we mentioned before, -a side effect of the authentication system is a key exchange, -so that the network tapping problem can be tackled on a per-application basis. -.# -.NH 1 -\&Performance -.IX "performance of DES authentication" -.IX "authentication" "performance" -.LP -Public key systems are known to be slow, -but there is not much actual public key encryption going on in Sun's system. -Public key encryption only occurs in the first transaction with a service, -and even then, there is caching that speeds things up considerably. -The first time a client program contacts a server, -both it and the server will have to calculate the common key. -The time it takes to compute the common key is basically the time it takes -to compute an exponential modulo $M$. -On a Sun-3 using a 192-bit modulus, this takes roughly 1 second, -which means it takes 2 seconds just to get things started, -since both client and server have to perform this operation. -This is a long time, -but you have to wait only the first time you contact a machine. -Since the keyserver caches the results of previous computations, -it does not have to recompute the exponential every time. -.LP -The most important service in terms of performance is the secure NFS, -which is acceptably fast. -The extra overhead that DES authentication requires versus UNIX authentication -is the encryption. -A timestamp is a 64-bit quantity, -which also happens to be the DES block size. -Four encryption operations take place in an average RPC transaction: -the client encrypts the request timestamp, the server decrypts it, -the server encrypts the reply timestamp, and the client decrypts it. -On a Sun-3, the time it takes to encrypt one block is about -half a millisecond if performed by hardware, -and 1.2 milliseconds if performed by software. -So, the extra time added to the round trip time is about -2 milliseconds for hardware encryption and 5 for software. -The round trip time for the average NFS request is about 20 milliseconds, -resulting in a performance hit of 10 percent if one has encryption hardware, -and 25 percent if not. -Remember that this is the impact on network performance. -The fact is that not all file operations go over the wire, -so the impact on total system performance will actually be lower than this. -It is also important to remember that security is optional, -so environments that require higher performance can turn it off. -.# -.NH 1 -\&Problems with Booting and \&\fBsetuid\fP Programs -.IX "problems with booting and \&\fIsetuid\fP programs" -.IX "booting and \&\fIsetuid\fP problems" -.LP -Consider the problem of a machine rebooting, -say after a power failure at some strange hour when nobody is around. -All of the secret keys that were stored get wiped out, -and now no process will be able to access secure network services, -such as mounting an NFS filesystem. -The important processes at this time are usually root processes, -so things would work OK if root's secret key were stored away, -but nobody is around to type the password that decrypts it. -The solution to this problem is to store root's decrypted secret key in a file, -which the keyserver can read. -This works well for diskful machines that can store the secret key -on a physically secure local disk, -but not so well for diskless machines, -whose secret key must be stored across the network. -If you tap the net when a diskless machine is booting, -you will find the decrypted key. -This is not very easy to accomplish, though. -.LP -Another booting problem is the single-user boot. -There is a mode of booting known as single-user mode, where a -.I root -login shell appears on the console. -The problem here is that a password is not required for this. -With C2 security installed, -a password is required in order to boot single-user. -Without C2 security installed, -machines can still be booted single-user without a password, -as long as the entry for -.I console -in the -.I /etc/ttytab -.IX "etc/ttytab" "" "\&\fI/etc/ttytab\fP" -file is labeled as physically -.I secure -(this is the default). -.LP -Yet another problem is that diskless machine booting is not totally secure. -It is possible for somebody to impersonate the boot-server, -and boot a devious kernel that, for example, -makes a record of your secret key on a remote machine. -The problem is that our system is set up to provide protection -only after the kernel and the keyserver are running. -Before that, there is no way to authenticate -the replies given by the boot server. -We don't consider this a serious problem, -because it is highly unlikely that somebody would be able to write -this funny kernel without source code. -Also, the crime is not without evidence. -If you polled the net for boot-servers, -you would discover the devious boot-server's location. -.LP -Not all -.I setuid -programs will behave as they should. -For example, if a -.I setuid -program is owned by -.I dave , -who has not logged into the machine since it booted, -then the program will not be able to access any secure network services as -.I dave . -The good news is that most -.I setuid -programs are owned by root, -and since root's secret key is always stored at boot time, -these programs will behave as they always have. -.# -.NH 1 -\&Conclusion -.IX "network security" "summary" -.LP -Our goal was to build a system as secure as a time-shared system. -This goal has been met. -The way you are authenticated in a time-sharing system -is by knowing your password. -With DES authentication, the same is true. -In time-sharing the person you trust is your system administrator, -who has an ethical obligation -not to change your password in order to impersonate you. -In Sun's system, you trust your network administrator, -who does not alter your entry in the public key database. -In one sense, our system is even more secure than time-sharing, -because it is useless to place a tap on the network -in hopes of catching a password or encryption key, -since these are encrypted. -Most time-sharing environments do not encrypt data emanating from the terminal; -users must trust that nobody is tapping their terminal lines. -.LP -DES authentication is perhaps not the ultimate authentication system. -In the future it is likely there will be sufficient advances -in algorithms and hardware to render the public key system -as we have defined it useless. -But at least DES authentication offers a smooth migration path for the future. -Syntactically speaking, -nothing in the protocol requires the encryption of the conversation -key to be Diffie-Hellman, or even public key encryption in general. -To make the authentication stronger in the future, -all that needs to be done is to strengthen the way -the conversation key is encrypted. -Semantically, this will be a different protocol, -but the beauty of RPC is that it can be plugged in -and live peacefully with any authentication system. -.LP -For the present at least, DES authentication satisfies our requirements -for a secure networking environment. -From it we built a system secure enough for use in unfriendly networks, -such as a student-run university workstation environment. -The price for this security is not high. -Nobody has to carry around a magnetic card or remember -any hundred digit numbers. -You use your login password to authenticate yourself, just as before. -There is a small impact on performance, -but if this worries you and you have a friendly net, -you can turn authentication off. -.# -.NH 1 -\&References -.IX "references on network security" -.LP -Diffie and Hellman, ``New Directions in Cryptography,'' -\fIIEEE Transactions on Information Theory IT-22,\fP -November 1976. -.LP -Gusella & Zatti, ``TEMPO: A Network Time Controller -for a Distributed Berkeley UNIX System,'' -\fIUSENIX 1984 Summer Conference Proceedings,\fP -June 1984. -.LP -National Bureau of Standards, ``Data Encryption Standard,'' -\fIFederal Information Processing Standards Publication 46,\fP -January 15, 1977. -.LP -Needham & Schroeder, ``Using Encryption for Authentication -in Large Networks of Computers,'' -\fIXerox Corporation CSL-78-4,\fP -September 1978. -.EQ -delim off -.EN -.IX "security" "of networks" "" "" PAGE END -.IX "network security" "" "" "" PAGE END -.IX "NFS security" "" "" "" PAGE END diff --git a/lib/librpc/secure_rpc/keyserv/Makefile b/lib/librpc/secure_rpc/keyserv/Makefile deleted file mode 100644 index de6771ee0d58..000000000000 --- a/lib/librpc/secure_rpc/keyserv/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# @(#)Makefile 2.4 88/08/15 4.0 RPCSRC; from 1.9 87/11/29 SMI -# -CFLAGS= -O -RPCLIB= -lrpclib -#RPCLIB= -lrpcsvc - -KEYSERV_OBJS = keyserv.o setkey.o detach.o mp.o -KEYENVOY_OBJS = keyenvoy.o -SRCS = keyserv.c setkey.c detach.c keyenvoy.c mp.c - -ALL= keyserv keyenvoy - -all: $(ALL) - -keyserv: $(KEYSERV_OBJS) - $(CC) $(CFLAGS) $(KEYSERV_OBJS) -lmp $(LIBC) $(RPCLIB) -o $@ - -keyenvoy: $(KEYENVOY_OBJS) - $(CC) $(CFLAGS) $(KEYENVOY_OBJS) $(LIBC) $(RPCLIB) -o $@ - -clean: - rm -f $(ALL) $(KEYSERV_OBJS) $(KEYENVOY_OBJS) - -install: $(ALL) - install -s -m 755 keyserv $(DESTDIR)/usr/etc - install -s -m 4755 keyenvoy $(DESTDIR)/usr/etc - -depend: - rm -f makedep - for i in ${SRCS}; do \ - ${CC} -M ${INCPATH} $$i | \ - awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \ - else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ - else rec = rec " " $$2 } } \ - END { print rec } ' >> makedep; done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - -# DO NOT DELETE THIS LINE -- make depend uses it - - diff --git a/lib/librpc/secure_rpc/keyserv/detach.c b/lib/librpc/secure_rpc/keyserv/detach.c deleted file mode 100644 index ff1fac3dac37..000000000000 --- a/lib/librpc/secure_rpc/keyserv/detach.c +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)detach.c 2.2 88/08/10 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#include -#include - -/* - * detach from tty - */ -detachfromtty() -{ - int tt; - - close(0); - close(1); - close(2); - switch (fork()) { - case -1: - perror("fork"); - break; - case 0: - break; - default: - exit(0); - } - tt = open("/dev/tty", O_RDWR); - if (tt > 0) { - ioctl(tt, TIOCNOTTY, 0); - close(tt); - } - (void)open("/dev/null", O_RDWR, 0); - dup(0); - dup(0); -} - - diff --git a/lib/librpc/secure_rpc/keyserv/keyenvoy.c b/lib/librpc/secure_rpc/keyserv/keyenvoy.c deleted file mode 100644 index 5379651acb56..000000000000 --- a/lib/librpc/secure_rpc/keyserv/keyenvoy.c +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)keyenvoy.c 2.2 88/08/10 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (C) 1986, Sun Microsystems, Inc. - */ -#include -#include -#include -#include -#include -#include -#include - -/* - * Talk to the keyserver on a privileged port on the part of a calling program. - * - * Protocol is for caller to send through stdin the procedure number - * to call followed by the argument data. We call the keyserver, and - * send the results back to the caller through stdout. - * Non-zero exit status means something went wrong. - */ - -#ifndef DEBUG -#define debug(msg) -#endif - -#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */ -#define TOTAL_TRIES 10 /* Number of tries */ - -/* - * Opaque data that we send and receive - */ -#define MAXOPAQUE 256 -struct opaqn { - u_int len; - u_int data[MAXOPAQUE]; -}; -bool_t xdr_opaqn(); - - -main(argc,argv) - int argc; - char *argv[]; -{ - XDR xdrs_args; - XDR xdrs_rslt; - int proc; - struct opaqn args, rslt; - - - if (isatty(0)) { - fprintf(stderr, - "This program cannot be used interactively.\n"); - exit(1); - } - -#ifdef DEBUG - close(2); - open("/dev/console", O_WRONLY, 0); -#endif - - xdrstdio_create(&xdrs_args, stdin, XDR_DECODE); - xdrstdio_create(&xdrs_rslt, stdout, XDR_ENCODE); - - if ( ! xdr_u_long(&xdrs_args, &proc)) { - debug("no proc"); - exit(1); - } - if (! xdr_opaqn(&xdrs_args, &args)) { - debug("recving args failed"); - exit(1); - } - if (! callkeyserver(proc, xdr_opaqn, &args, xdr_opaqn, &rslt)) { - debug("rpc_call failed"); - exit(1); - } - if (! xdr_opaqn(&xdrs_rslt, &rslt)) { - debug("sending args failed"); - exit(1); - } - exit(0); -} - - - -callkeyserver(proc, xdr_args, args, xdr_rslt, rslt) - u_long proc; - bool_t (*xdr_args)(); - void *args; - bool_t (*xdr_rslt)(); - void *rslt; - -{ - struct sockaddr_in remote; - int port; - struct timeval wait; - enum clnt_stat stat; - CLIENT *client; - int sd; - - /* - * set up the remote address - * and create client - */ - remote.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - remote.sin_family = AF_INET; - remote.sin_port = 0; - wait.tv_sec = TOTAL_TIMEOUT/TOTAL_TRIES; wait.tv_usec = 0; - sd = RPC_ANYSOCK; - client = clntudp_create(&remote, KEY_PROG, KEY_VERS, wait, &sd); - if (client == NULL) { - debug("no client"); - return (0); - } - - /* - * Check that server is bound to a reserved port, so - * that noone can masquerade as the keyserver. - */ - if (ntohs(remote.sin_port) >= IPPORT_RESERVED) { - debug("insecure port"); - return (0); - } - - /* - * Create authentication - * All we care about really is sending the real uid - */ - client->cl_auth = authunix_create("", getuid(), 0, 0, NULL); - if (client->cl_auth == NULL) { - debug("no auth"); - return (0); - } - wait.tv_sec = TOTAL_TIMEOUT; wait.tv_usec = 0; - stat = clnt_call(client, proc, xdr_args, args, xdr_rslt, rslt, wait); - if (stat != RPC_SUCCESS) { - debug("clnt_call failed"); - } - return (stat == RPC_SUCCESS); -} - - -/* - * XDR opaque data - * Don't know the length on decode, so just keep receiving until failure. - */ -bool_t -xdr_opaqn(xdrs, objp) - XDR *xdrs; - struct opaqn *objp; -{ - int i; - - switch (xdrs->x_op) { - case XDR_FREE: - break; - case XDR_DECODE: - for (i = 0; i < MAXOPAQUE && xdr_int(xdrs, &objp->data[i]); i++) { - } - if (i == MAXOPAQUE) { - return (FALSE); - } - objp->len = i; - break; - case XDR_ENCODE: - for (i = 0; i < objp->len; i++) { - if (! xdr_int(xdrs, &objp->data[i])) { - return (FALSE); - } - } - break; - } - return (TRUE); -} - - -#ifdef DEBUG -debug(msg) - char *msg; -{ - fprintf(stderr, "%s\n", msg); -} -#endif diff --git a/lib/librpc/secure_rpc/keyserv/keyserv.c b/lib/librpc/secure_rpc/keyserv/keyserv.c deleted file mode 100644 index d82dc12a0f1e..000000000000 --- a/lib/librpc/secure_rpc/keyserv/keyserv.c +++ /dev/null @@ -1,458 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)keyserv.c 2.4 88/08/15 4.0 RPCSRC Copyr 1988 Sun Micro"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -/* - * Keyserver - * Store secret keys per uid. Do public key encryption and decryption - * operations. Generate "random" keys. Do not talk to anything but a local root - * process (by checking that the source port < IPPORT_RESERVED and by binding - * to the loopback address). - */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -char ROOTKEY[] = "/etc/.rootkey"; - -extern long random(); - -extern keystatus pk_setkey(); -extern keystatus pk_encrypt(); -extern keystatus pk_decrypt(); - - -#ifdef DEBUG -int debugging = 1; -#else -int debugging = 0; -#endif - -static void keyprogram(); -des_block masterkey; - -main(argc, argv) - int argc; - char *argv[]; - -{ - SVCXPRT *transp; - int nflag; - - nflag = (argc == 2) && (strcmp(argv[1], "-n") == 0); - if (!(argc == 1 || nflag)) { - (void) fprintf(stderr, "usage: %s [-n]\n", argv[0]); - exit(1); - } - /* - * Initialize - */ - (void) umask(066); /* paranoia */ - if (geteuid() != 0) { - (void) fprintf(stderr, "%s must be run as root\n", argv[0]); - exit(1); - } - setmodulus(HEXMODULUS); - openstore(); - getrootkey(&masterkey, nflag); - readkeys(); - - /* - * create the service, register it, and run - */ - transp = svcudp_create(RPC_ANYSOCK); - if (transp == NULL) { - (void) fprintf(stderr, - "%s: unable to create udp service\n", argv[0]); - exit(1); - } - pmap_unset(KEY_PROG, KEY_VERS); - if (!svc_register(transp, KEY_PROG, KEY_VERS, keyprogram, - IPPROTO_UDP)) { - (void) fprintf(stderr, "%s: unable to register service\n", - argv[0]); - exit(1); - } - /* - * run - */ - if (!debugging) { - detachfromtty(); - } - svc_run(); - abort(); -} - -/* - * In the event that we don't get a root password, we try to randomize the - * master key the best we can - */ -randomize(master) - des_block *master; -{ - int i; - int seed; - struct timeval tv; - int shift; - - seed = 0; - for (i = 0; i < 1024; i++) { - (void) gettimeofday(&tv, (struct timezone *) NULL); - shift = i % 8 * sizeof(int); - seed ^= (tv.tv_usec << shift) | (tv.tv_usec >> (32 - shift)); - } - srandom(seed); - master->key.low = random(); - master->key.high = random(); - srandom(seed); -} - - - -/* - * Try to get root's secret key, by prompting if terminal is a tty, else trying - * from standard input. - */ -getrootkey(master, prompt) - des_block *master; - int prompt; -{ - char *getpass(); - char *passwd; - char name[MAXNETNAMELEN + 1]; - char secret[HEXKEYBYTES + 1]; - char *crypt(); - int fd; - - if (!prompt) { - /* - * Read secret key out of $ROOTKEY - */ - fd = open(ROOTKEY, O_RDONLY, 0); - if (fd < 0) { - randomize(master); - return (0); - } - if (read(fd, secret, HEXKEYBYTES) < 0) { - (void) fprintf(stderr, "Invalid %s\n", ROOTKEY); - (void) close(fd); - return (0); - } - (void) close(fd); - secret[HEXKEYBYTES] = 0; - } else { - /* - * Decrypt yellow pages entry to get secret key - */ - passwd = getpass("root password:"); - passwd2des(passwd, master); - getnetname(name); - if (!getsecretkey(name, secret, passwd)) { - (void) fprintf(stderr, - "Can't find %s's secret key\n", name); - return (0); - } - if (secret[0] == 0) { - (void) fprintf(stderr, - "Invalid password for %s\n", name); - return (0); - } - } - (void) pk_setkey(0, secret); - return (1); -} - - -/* - * Procedures to implement RPC service - */ - -char * -strstatus(status) - keystatus status; -{ - switch (status) { - case KEY_SUCCESS: - return ("KEY_SUCCESS"); - case KEY_NOSECRET: - return ("KEY_NOSECRET"); - case KEY_UNKNOWN: - return ("KEY_UNKNOWN"); - case KEY_SYSTEMERR: - return ("KEY_SYSTEMERR"); - default: - return ("(bad result code)"); - } -} - -keystatus * -key_set_1(uid, key) - short uid; - keybuf key; -{ - static keystatus status; - - if (debugging) { - (void) fprintf(stderr, "set(%d, %.*s) = ", uid, - sizeof(keybuf), key); - } - status = pk_setkey(uid, key); - if (debugging) { - (void) fprintf(stderr, "%s\n", strstatus(status)); - (void) fflush(stderr); - } - return (&status); -} - - - -cryptkeyres * -key_encrypt_1(uid, arg) - short uid; - cryptkeyarg *arg; -{ - static cryptkeyres res; - - if (debugging) { - (void) fprintf(stderr, "encrypt(%d, %s, %08x%08x) = ", uid, - arg->remotename, arg->deskey.key.high, - arg->deskey.key.low); - } - res.cryptkeyres_u.deskey = arg->deskey; - res.status = pk_encrypt(uid, arg->remotename, &res.cryptkeyres_u.deskey); - if (debugging) { - if (res.status == KEY_SUCCESS) { - (void) fprintf(stderr, "%08x%08x\n", - res.cryptkeyres_u.deskey.key.high, - res.cryptkeyres_u.deskey.key.low); - } else { - (void) fprintf(stderr, - "%s\n", strstatus(res.status)); - } - (void) fflush(stderr); - } - return (&res); -} - -cryptkeyres * -key_decrypt_1(uid, arg) - short uid; - cryptkeyarg *arg; -{ - static cryptkeyres res; - - if (debugging) { - (void) fprintf(stderr, "decrypt(%d, %s, %08x%08x) = ", uid, - arg->remotename, arg->deskey.key.high, - arg->deskey.key.low); - } - res.cryptkeyres_u.deskey = arg->deskey; - res.status = pk_decrypt(uid, arg->remotename, - &res.cryptkeyres_u.deskey); - if (debugging) { - if (res.status == KEY_SUCCESS) { - (void) fprintf(stderr, "%08x%08x\n", - res.cryptkeyres_u.deskey.key.high, - res.cryptkeyres_u.deskey.key.low); - } else { - (void) fprintf(stderr, "%s\n", strstatus(res.status)); - } - (void) fflush(stderr); - } - return (&res); -} - -des_block * -key_gen_1() -{ - struct timeval time; - static des_block keygen; - static des_block key; - - (void) gettimeofday(&time, (struct timezone *) NULL); - keygen.key.high += (time.tv_sec ^ time.tv_usec); - keygen.key.low += (time.tv_sec ^ time.tv_usec); - ecb_crypt(&masterkey, &keygen, sizeof(keygen), DES_ENCRYPT | DES_HW); - key = keygen; - des_setparity(&key); - if (debugging) { - (void) fprintf(stderr, "gen() = %08x%08x\n", key.key.high, - key.key.low); - (void) fflush(stderr); - } - return (&key); -} - -/* ARGSUSED */ -getcredres * -key_getcred_1(uid, name) - short uid; - netnamestr *name; -{ - static getcredres res; - static int gids[NGROUPS]; - struct unixcred *cred; - - cred = &res.getcredres_u.cred; - cred->gids.gids_val = gids; - if (!netname2user(*name, &cred->uid, &cred->gid, - &cred->gids.gids_len, gids)) { - res.status = KEY_UNKNOWN; - } else { - res.status = KEY_SUCCESS; - } - if (debugging) { - (void) fprintf(stderr, "getcred(%s) = ", *name); - if (res.status == KEY_SUCCESS) { - (void) fprintf(stderr, "uid=%d,gid=%d,grouplen=%d\n", - cred->uid, cred->gid, cred->gids.gids_len); - } else { - (void) fprintf(stderr, "%s\n", strstatus(res.status)); - } - (void) fflush(stderr); - } - return (&res); -} - - -/* - * RPC boilerplate - */ -static void -keyprogram(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - union { - keybuf key_set_1_arg; - cryptkeyarg key_encrypt_1_arg; - cryptkeyarg key_decrypt_1_arg; - des_block key_gen_1_arg; - } argument; - char *result; - - bool_t(*xdr_argument) (), (*xdr_result) (); - char *(*local) (); - struct sockaddr_in remote; - int uid; - int check_auth; - - switch (rqstp->rq_proc) { - case NULLPROC: - svc_sendreply(transp, xdr_void, (char *) NULL); - return; - - case KEY_SET: - xdr_argument = xdr_keybuf; - xdr_result = xdr_int; - local = (char *(*)()) key_set_1; - check_auth = 1; - break; - - case KEY_ENCRYPT: - xdr_argument = xdr_cryptkeyarg; - xdr_result = xdr_cryptkeyres; - local = (char *(*)()) key_encrypt_1; - check_auth = 1; - break; - - case KEY_DECRYPT: - xdr_argument = xdr_cryptkeyarg; - xdr_result = xdr_cryptkeyres; - local = (char *(*)()) key_decrypt_1; - check_auth = 1; - break; - - case KEY_GEN: - xdr_argument = xdr_void; - xdr_result = xdr_des_block; - local = (char *(*)()) key_gen_1; - check_auth = 0; - break; - - case KEY_GETCRED: - xdr_argument = xdr_netnamestr; - xdr_result = xdr_getcredres; - local = (char *(*)()) key_getcred_1; - check_auth = 0; - break; - - default: - svcerr_noproc(transp); - return; - } - if (check_auth) { - remote = *svc_getcaller(transp); - if (ntohs(remote.sin_port) >= IPPORT_RESERVED || - ntohl(remote.sin_addr.s_addr) != INADDR_LOOPBACK) { - if (debugging) { - (void) fprintf(stderr, - "not local privileged process\n"); - } - svcerr_weakauth(transp); - return; - } - if (rqstp->rq_cred.oa_flavor != AUTH_UNIX) { - if (debugging) { - (void) fprintf(stderr, - "not unix authentication\n"); - } - svcerr_weakauth(transp); - return; - } - uid = ((struct authunix_parms *) rqstp->rq_clntcred)->aup_uid; - } - bzero((char *) &argument, sizeof(argument)); - if (!svc_getargs(transp, xdr_argument, &argument)) { - svcerr_decode(transp); - return; - } - result = (*local) (uid, &argument); - if (!svc_sendreply(transp, xdr_result, (char *) result)) { - (void) fprintf(stderr, "unable to reply\n"); - svcerr_systemerr(transp); - } - if (!svc_freeargs(transp, xdr_argument, &argument)) { - (void) fprintf(stderr, "unable to free arguments\n"); - exit(1); - } -} diff --git a/lib/librpc/secure_rpc/keyserv/mp.c b/lib/librpc/secure_rpc/keyserv/mp.c deleted file mode 100644 index 97c85b06fecc..000000000000 --- a/lib/librpc/secure_rpc/keyserv/mp.c +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)mp.c 2.1 88/08/15 4.0 RPCSRC Copyr 1988 Sun Micro"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * These routines add hexadecimal functionality to the multiple-precision - * library. - */ -#include -#include - -void mfree(); - -/* - * Convert hex digit to binary value - */ -static int -xtoi(c) - char c; -{ - if (c >= '0' && c <= '9') { - return(c - '0'); - } else if (c >= 'a' && c <= 'f') { - return(c - 'a' + 10); - } else { - return(-1); - } -} - -/* - * Convert hex key to MINT key - */ -MINT * -xtom(key) - char *key; -{ - int digit; - MINT *m = itom(0); - MINT *d; - MINT *sixteen; - sixteen = itom(16); - for (; *key; key++) { - digit = xtoi(*key); - if (digit < 0) { - return(NULL); - } - d = itom(digit); - mult(m,sixteen,m); - madd(m,d,m); - mfree(d); - } - mfree(sixteen); - return(m); -} -static char -itox(d) - short d; -{ - d &= 15; - if (d < 10) { - return('0' + d); - } else { - return('a' - 10 + d); - } -} -/* - * Convert MINT key to hex key - */ -char * -mtox(key) - MINT *key; -{ - MINT *m = itom(0); - MINT *zero = itom(0); - short r; - char *p; - char c; - char *s; - char *hex; - int size; -#define BASEBITS (8*sizeof(short) - 1) - if (key->len >= 0) { - size = key->len; - } else { - size = -key->len; - } - hex = malloc((unsigned) ((size * BASEBITS + 3)) / 4 + 1); - if (hex == NULL) { - return(NULL); - } - move(key,m); - p = hex; - do { - sdiv(m,16,m,&r); - *p++ = itox(r); - } while (mcmp(m,zero) != 0); - mfree(m); - mfree(zero); - *p = 0; - for (p--, s = hex; s < p; s++, p--) { - c = *p; - *p = *s; - *s = c; - } - return(hex); -} -/* - * Deallocate a multiple precision integer - */ -void -mfree(a) - MINT *a; -{ - xfree(a); - free((char *)a); -} - diff --git a/lib/librpc/secure_rpc/keyserv/setkey.c b/lib/librpc/secure_rpc/keyserv/setkey.c deleted file mode 100644 index d62dc9c7cf5c..000000000000 --- a/lib/librpc/secure_rpc/keyserv/setkey.c +++ /dev/null @@ -1,514 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)setkey.c 2.2 88/08/10 4.0 RPCSRC; from Copyr 1988 Sun Micro"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -/* - * Do the real work of the keyserver . - * Store secret keys. Compute common keys, - * and use them to decrypt and encrypt DES keys . - * Cache the common keys, so the - * expensive computation is avoided. - */ -#include -#include -#include -#include -#include -#include -#include - -extern char *malloc(); -extern char ROOTKEY[]; - -static MINT *MODULUS; -static char *fetchsecretkey(); -static keystatus pk_crypt(); - - -/* - * Set the modulus for all our Diffie-Hellman operations - */ -setmodulus(modx) - char *modx; -{ - MODULUS = xtom(modx); -} - - -/* - * Set the secretkey key for this uid - */ -keystatus -pk_setkey(uid, skey) - short uid; - keybuf skey; -{ - if (!storesecretkey(uid, skey)) { - return (KEY_SYSTEMERR); - } - return (KEY_SUCCESS); -} - - -/* - * Encrypt the key using the public key associated with remote_name and the - * secret key associated with uid. - */ -keystatus -pk_encrypt(uid, remote_name, key) - short uid; - char *remote_name; - des_block *key; -{ - return (pk_crypt(uid, remote_name, key, DES_ENCRYPT)); -} - - -/* - * Decrypt the key using the public key associated with remote_name and the - * secret key associated with uid. - */ -keystatus -pk_decrypt(uid, remote_name, key) - short uid; - char *remote_name; - des_block *key; -{ - return (pk_crypt(uid, remote_name, key, DES_DECRYPT)); -} - - -/* - * Do the work of pk_encrypt && pk_decrypt - */ -static keystatus -pk_crypt(uid, remote_name, key, mode) - short uid; - char *remote_name; - des_block *key; - int mode; -{ - char *xsecret; - char xpublic[HEXKEYBYTES + 1]; - char xsecret_hold[HEXKEYBYTES + 1]; - des_block deskey; - int err; - MINT *public; - MINT *secret; - MINT *common; - char zero[8]; - - xsecret = fetchsecretkey(uid); - if (xsecret == NULL) { - bzero(zero, sizeof(zero)); - xsecret = xsecret_hold; - if (!getsecretkey("nobody", xsecret, zero) || - xsecret[0] == 0) { - return (KEY_NOSECRET); - } - } - if (!getpublickey(remote_name, xpublic) && - !getpublickey("nobody", xpublic)) { - return (KEY_UNKNOWN); - } - if (!readcache(xpublic, xsecret, &deskey)) { - public = xtom(xpublic); - secret = xtom(xsecret); - common = itom(0); - pow(public, secret, MODULUS, common); - extractdeskey(common, &deskey); - writecache(xpublic, xsecret, &deskey); - mfree(secret); - mfree(public); - mfree(common); - } - err = ecb_crypt(&deskey, key, sizeof(des_block), DES_HW | mode); - if (DES_FAILED(err)) { - return (KEY_SYSTEMERR); - } - return (KEY_SUCCESS); -} - - -/* - * Choose middle 64 bits of the common key to use as our des key, possibly - * overwriting the lower order bits by setting parity. - */ -static -extractdeskey(ck, deskey) - MINT *ck; - des_block *deskey; -{ - MINT *a; - short r; - int i; - short base = (1 << 8); - char *k; - - - a = itom(0); - move(ck, a); - for (i = 0; i < ((KEYSIZE - 64) / 2) / 8; i++) { - sdiv(a, base, a, &r); - } - k = deskey->c; - for (i = 0; i < 8; i++) { - sdiv(a, base, a, &r); - *k++ = r; - } - mfree(a); - des_setparity(deskey); -} - - -/* - * Key storage management - */ - -struct secretkey_list { - short uid; - char secretkey[HEXKEYBYTES+1]; - struct secretkey_list *next; -}; - -static struct secretkey_list *g_secretkeys; - -/* - * Fetch the secret key for this uid - */ -static char * -fetchsecretkey(uid) - short uid; -{ - struct secretkey_list *l; - - for (l = g_secretkeys; l != NULL; l = l->next) { - if (l->uid == uid) { - return (l->secretkey); - } - } - return (NULL); -} - -/* - * Store the secretkey for this uid - */ -storesecretkey(uid, key) - short uid; - keybuf key; -{ - struct secretkey_list *new; - struct secretkey_list **l; - int nitems; - - - nitems = 0; - for (l = &g_secretkeys; *l != NULL && (*l)->uid != uid; - l = &(*l)->next) { - nitems++; - } - if (*l == NULL) { - new = (struct secretkey_list *)malloc(sizeof(*new)); - if (new == NULL) { - return (0); - } - new->uid = uid; - new->next = NULL; - *l = new; - } else { - new = *l; - } - bcopy(key, new->secretkey, HEXKEYBYTES); - new->secretkey[HEXKEYBYTES] = 0; - seekitem(nitems); - writeitem(uid, new->secretkey); - return (1); -} - - -hexdigit(val) - int val; -{ - return ("0123456789abcdef"[val]); - -} -bin2hex(bin, hex, size) - unsigned char *bin; - unsigned char *hex; - int size; -{ - int i; - - for (i = 0; i < size; i++) { - *hex++ = hexdigit(*bin >> 4); - *hex++ = hexdigit(*bin++ & 0xf); - } -} - -hexval(dig) - char dig; -{ - if ('0' <= dig && dig <= '9') { - return (dig - '0'); - } else if ('a' <= dig && dig <= 'f') { - return (dig - 'a' + 10); - } else if ('A' <= dig && dig <= 'F') { - return (dig - 'A' + 10); - } else { - return (-1); - } -} - -hex2bin(hex, bin, size) - unsigned char *hex; - unsigned char *bin; - int size; -{ - int i; - - for (i = 0; i < size; i++) { - *bin = hexval(*hex++) << 4; - *bin++ |= hexval(*hex++); - } -} - -static char KEYSTORE[] = "/etc/keystore"; -FILE *kf; - -openstore() -{ - kf = fopen(KEYSTORE, "r+"); - if (kf == NULL) { - kf = fopen(KEYSTORE, "w+"); - if (kf == NULL) { - return (0); - } - } - setbuf(kf, NULL); - return (1); -} - -static char rootkey[KEYBYTES]; -static int haverootkey; -struct storedkey { - short uid; - char crypt[KEYBYTES]; -}; - -readkeys() -{ - struct secretkey_list *node; - struct secretkey_list **l; - int uid; - char secretkey[HEXKEYBYTES+1]; - - if (kf == NULL) { - return; - } - l = &g_secretkeys; - seekitem(0); - while (readitem(&uid, secretkey)) { - node = (struct secretkey_list *)malloc(sizeof(*node)); - if (node == NULL) { - return; - } - node->uid = uid; - bcopy(secretkey, node->secretkey, HEXKEYBYTES + 1); - node->next = NULL; - *l = node; - l = &node->next; - } -} - -writekeys() -{ - struct secretkey_list *k; - - seekitem(0); - for (k = g_secretkeys; k != NULL; k = k->next) { - writeitem(k->uid, k->secretkey); - } -} - -seekitem(item) - int item; -{ - if (kf != NULL) { - fseek(kf, item * sizeof(struct storedkey), 0); - } -} - -writeitem(uid, key) - int uid; - char *key; -{ - struct storedkey item; - char rootkey_tmp[KEYBYTES]; - int reencrypt; - - if (kf == NULL) { - return (1); - } - if (uid == 0) { - writerootkey(key); - hex2bin(key, rootkey_tmp, KEYBYTES); - reencrypt = (haverootkey && - bcmp(rootkey, rootkey_tmp, KEYBYTES) != 0); - bcopy(rootkey_tmp, rootkey, KEYBYTES); - haverootkey = 1; - if (reencrypt) { - writekeys(); - return (1); - } - } - if (!haverootkey) { - return (1); - } - item.uid = uid; - hex2bin(key, item.crypt, KEYBYTES); - ecb_crypt(rootkey, item.crypt, KEYBYTES, DES_ENCRYPT|DES_HW); - return (fwrite(&item, sizeof(item), 1, kf) >= 0); -} - - -readitem(uidp, key) - int *uidp; - char *key; -{ - struct storedkey item; - - if (!haverootkey || kf == NULL) { - return (0); - } - if (fread(&item, sizeof(item), 1, kf) != 1) { - return (0); - } - *uidp = item.uid; - ecb_crypt(rootkey, item.crypt, KEYBYTES, DES_DECRYPT|DES_HW); - bin2hex(item.crypt, key, KEYBYTES); - key[HEXKEYBYTES] = 0; - return (1); -} - -/* - * Root users store their key in /etc/$ROOTKEY so - * that they can auto reboot without having to be - * around to type a password. Storing this in a file - * is rather dubious: it should really be in the EEPROM - * so it does not go over the net for diskless machines. - */ -writerootkey(secret) - char *secret; -{ - char newline = '\n'; - int fd; - - fd = open(ROOTKEY, O_WRONLY|O_TRUNC|O_CREAT, 0); - if (fd < 0) { - perror(ROOTKEY); - } else { - if (write(fd, secret, strlen(secret)) < 0 || - write(fd, &newline, sizeof(newline)) < 0) { - (void)fprintf(stderr, "%s: ", ROOTKEY); - perror("write"); - } - close(fd); - } -} - - -/* - * Exponential caching management - */ -struct cachekey_list { - keybuf secret; - keybuf public; - des_block deskey; - struct cachekey_list *next; -}; -static struct cachekey_list *g_cachedkeys; - - -/* - * cache result of expensive multiple precision exponential operation - */ -static -writecache(pub, sec, deskey) - char *pub; - char *sec; - des_block *deskey; -{ - struct cachekey_list *new; - - new = (struct cachekey_list *) malloc(sizeof(struct cachekey_list)); - if (new == NULL) { - return; - } - bcopy(pub, new->public, sizeof(keybuf)); - bcopy(sec, new->secret, sizeof(keybuf)); - new->deskey = *deskey; - new->next = g_cachedkeys; - g_cachedkeys = new; -} - -/* - * Try to find the common key in the cache - */ -static -readcache(pub, sec, deskey) - char *pub; - char *sec; - des_block *deskey; -{ - struct cachekey_list *found; - register struct cachekey_list **l; - -#define cachehit(pub, sec, list) \ - (bcmp(pub, (list)->public, sizeof(keybuf)) == 0 && \ - bcmp(sec, (list)->secret, sizeof(keybuf)) == 0) - - for (l = &g_cachedkeys; - (*l) != NULL && !cachehit(pub, sec, *l); - l = &(*l)->next); - if ((*l) == NULL) { - return (0); - } - found = *l; - (*l) = (*l)->next; - found->next = g_cachedkeys; - g_cachedkeys = found; - *deskey = found->deskey; - return (1); -} diff --git a/lib/librpc/secure_rpc/man/chkey.1 b/lib/librpc/secure_rpc/man/chkey.1 deleted file mode 100644 index fbf1fcd74c34..000000000000 --- a/lib/librpc/secure_rpc/man/chkey.1 +++ /dev/null @@ -1,19 +0,0 @@ -.\" @(#)chkey.1 2.1 88/08/10 4.0 RPCSRC; from 1.6 88/02/29 SMI; -.TH CHKEY 1 "9 September 1987" -.SH NAME -chkey \- change your encryption key -.SH SYNOPSIS -.B chkey -.SH DESCRIPTION -.IX "chkey command" "" "\fLchkey\fP command" -.IX "encryption key, change, \fLchkey\fR command" -.B chkey -prompts the user for their login password, and uses it to encrypt -a new encryption key for the user to be stored in the -.BR publickey (5) -database. -.SH "SEE ALSO" -.BR keylogin (1), -.BR publickey (5), -.BR keyserv (8C), -.BR newkey (8) diff --git a/lib/librpc/secure_rpc/man/des_crypt.3 b/lib/librpc/secure_rpc/man/des_crypt.3 deleted file mode 100644 index ca0a33e1c27d..000000000000 --- a/lib/librpc/secure_rpc/man/des_crypt.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI; -.TH DES_CRYPT 3 "6 October 1987" -.SH NAME -des_crypt, ecb_crypt, cbc_crypt, des_setparity \- fast DES encryption -.SH SYNOPSIS -.nf -.B #include -.LP -.B int ecb_crypt(key, data, datalen, mode) -.B char *key; -.B char *data; -.B unsigned datalen; -.B unsigned mode; -.LP -.B int cbc_crypt(key, data, datalen, mode, ivec) -.B char *key; -.B char *data; -.B unsigned datalen; -.B unsigned mode; -.B char *ivec; -.LP -.B void des_setparity(key) -.B char *key; -.fi -.SH DESCRIPTION -.IX encryption cbc_crypt "" \fLcbc_crypt\fP -.IX "des encryption" cbc_crypt "DES encryption" \fLcbc_crypt\fP -.IX encryption des_setparity "" \fLdes_setparity\fP -.IX "des encryption" des_setparity "DES encryption" \fLdes_setparity\fP -.B ecb_crypt(\|) -and -.B cbc_crypt(\|) -implement the -.SM NBS -.SM DES -(Data Encryption Standard). -These routines are faster and more general purpose than -.BR crypt (3). -They also are able to utilize -.SM DES -hardware if it is available. -.B ecb_crypt(\|) -encrypts in -.SM ECB -(Electronic Code Book) -mode, which encrypts blocks of data independently. -.B cbc_crypt(\|) -encrypts in -.SM CBC -(Cipher Block Chaining) -mode, which chains together -successive blocks. -.SM CBC -mode protects against insertions, deletions and -substitutions of blocks. Also, regularities in the clear text will -not appear in the cipher text. -.LP -Here is how to use these routines. The first parameter, -.IR key , -is the 8-byte encryption key with parity. -To set the key's parity, which for -.SM DES -is in the low bit of each byte, use -.IR des_setparity . -The second parameter, -.IR data , -contains the data to be encrypted or decrypted. The -third parameter, -.IR datalen , -is the length in bytes of -.IR data , -which must be a multiple of 8. The fourth parameter, -.IR mode , -is formed by -.SM OR\s0'ing -together some things. For the encryption direction 'or' in either -.SM DES_ENCRYPT -or -.SM DES_DECRYPT\s0. -For software versus hardware -encryption, 'or' in either -.SM DES_HW -or -.SM DES_SW\s0. -If -.SM DES_HW -is specified, and there is no hardware, then the encryption is performed -in software and the routine returns -.SM DESERR_NOHWDEVICE\s0. -For -.IR cbc_crypt , -the parameter -.I ivec -is the the 8-byte initialization -vector for the chaining. It is updated to the next initialization -vector upon return. -.LP -.SH "SEE ALSO" -.BR des (1), -.BR crypt (3) -.SH DIAGNOSTICS -.PD 0 -.TP 20 -.SM DESERR_NONE -No error. -.TP -.SM DESERR_NOHWDEVICE -Encryption succeeded, but done in software instead of the requested hardware. -.TP -.SM DESERR_HWERR -An error occurred in the hardware or driver. -.TP -.SM DESERR_BADPARAM -Bad parameter to routine. -.PD -.LP -Given a result status -.IR stat , -the macro -.SM DES_FAILED\c -.BR ( stat ) -is false only for the first two statuses. -.SH RESTRICTIONS -These routines are not available in RPCSRC 4.0. -This information is provided to describe the DES interface expected by -Secure RPC. diff --git a/lib/librpc/secure_rpc/man/keyenvoy.8c b/lib/librpc/secure_rpc/man/keyenvoy.8c deleted file mode 100644 index 8cf7bc3a2ef8..000000000000 --- a/lib/librpc/secure_rpc/man/keyenvoy.8c +++ /dev/null @@ -1,22 +0,0 @@ -.\" @(#)keyenvoy.8c 2.1 88/08/10 4.0 RPCSRC; from 1.5 88/03/01 SMI; -.TH KEYENVOY 8C "9 September 1987" -.SH NAME -keyenvoy \- talk to keyserver -.SH SYNOPSIS -.B keyenvoy -.SH DESCRIPTION -.IX "keyenvoy command" "" "\fLkeyenvoy\fP command" -.B keyenvoy -is used by some -.SM RPC -programs to talk to the key server, -.BR keyserv (8C). -The key server will not talk to anything but a root process, and -.B keyenvoy -is a set-uid root process that acts as an intermediary between a user -process that wishes to talk to the -key server and the key server itself. -.LP -This program cannot be run interactively. -.SH "SEE ALSO" -.BR keyserv (8C) diff --git a/lib/librpc/secure_rpc/man/keylogin.1 b/lib/librpc/secure_rpc/man/keylogin.1 deleted file mode 100644 index 516d9deab6c7..000000000000 --- a/lib/librpc/secure_rpc/man/keylogin.1 +++ /dev/null @@ -1,32 +0,0 @@ -.\" @(#)keylogin.1 2.1 88/08/10 4.0 RPCSRC; from 1.6 88/02/29 SMI; -.TH KEYLOGIN 1 "9 September 1987" -.SH NAME -keylogin \- decrypt and store secret key -.SH SYNOPSIS -.B keylogin -.SH DESCRIPTION -.IX "keylogin command" "" "\fLkeylogin\fR command" -.LP -.B keylogin -prompts the user for their login password, and uses it do decrypt -the user's secret key stored in the -.BR publickey (5) -database. Once decrypted, the user's key is stored by the local -key server process -.BR keyserv (8C) -to be used by any secure network services, such as -.SM NFS\s0. -.LP -Normally, -.BR login (1) -does this work when the user logs onto the system, but running -.B keylogin -may be necessary if -the user did not type a password to -.BR login (1). -.SH "SEE ALSO" -.BR chkey (1), -.BR login (1), -.BR publickey (5), -.BR keyserv (8C), -.BR newkey (8) diff --git a/lib/librpc/secure_rpc/man/keyserv.8c b/lib/librpc/secure_rpc/man/keyserv.8c deleted file mode 100644 index aa153ed3fe41..000000000000 --- a/lib/librpc/secure_rpc/man/keyserv.8c +++ /dev/null @@ -1,52 +0,0 @@ -.\" @(#)keyserv.8c 2.1 88/08/10 4.0 RPCSRC; from 1.6 88/03/01 SMI; -.TH KEYSERV 8C "9 September 1987" -.SH NAME -keyserv \- server for storing public and private keys -.SH SYNOPSIS -.B keyserv -[ -.B \-n -] -.SH DESCRIPTION -.IX "keyenvoy server" "" "\fLkeyenvoy\fP server" -.B keyserv -is a daemon that is used for storing the -private encryption keys of each -user logged into the system. These encryption -keys are using for accessing -secure network services such as secure -.SM NFS\s0. -When a user logs in to the system, the -.BR login(1) -program uses the login password to decrypt -the user's encryption key stored -in the Yellow Pages, and then gives the decrypted key to the -.B keyserv -daemon to store away. -.LP -Normally, root's key is read from the file -.B /etc/.rootkey -when the daemon starts up. This is useful during power-fail reboots -when no one is around to type a password, yet you still want the -secure network services to operate normally. -.SH OPTIONS -.TP -.B \-n -Do not read root's key from -.BR /etc/.rootkey . -Instead, prompt the user for the password to decrypt -.B root 's -key stored in the Yellow Pages and then store the decrypted key in -.B /etc/.rootkey -for future use. -This option is useful if the -.B /etc/.rootkey -file ever gets out of date or corrupted. -.SH FILES -.PD 0 -.TP 20 -.B /etc/.rootkey -.PD -.SH "SEE ALSO" -.BR login (1), -.BR publickey (5) diff --git a/lib/librpc/secure_rpc/man/publickey.3r b/lib/librpc/secure_rpc/man/publickey.3r deleted file mode 100644 index 7063e8a43ccc..000000000000 --- a/lib/librpc/secure_rpc/man/publickey.3r +++ /dev/null @@ -1,44 +0,0 @@ -.\" @(#)publickey.3r 2.1 88/08/07 4.0 RPCSRC -.TH PUBLICKEY 3R "6 October 1987" -.SH NAME -publickey, getpublickey, getsecretkey \- get public or secret key -.SH SYNOPSIS -.nf -.B #include -.B #include -.LP -.B getpublickey(netname, publickey) -.B char netname[\s-1MAXNETNAMELEN\s0+1]; -.B char publickey[\s-1HEXKEYBYTES\s0+1]; -.LP -.B getsecretkey(netname, secretkey, passwd) -.B char netname[\s-1MAXNETNAMELEN\s0+1]; -.B char secretkey[\s-1HEXKEYBYTES\s0+1]; -.B char *passwd; -.fi -.SH DESCRIPTION -.IX "getpublickey function" "" "\fLgetpublickey()\fP function" -.IX "getsecretkey function" "" "\fLgetsecretkey()\fP function" -These routines are used to get public and secret keys from the -.SM YP -database. -.B getsecretkey(\|) -has an extra argument, -.IR passwd , -which is used to decrypt the encrypted secret key stored in the database. -Both routines return 1 if they are successful in finding the key, 0 otherwise. -The keys are returned as -.SM NULL\s0-terminated, -hexadecimal strings. If the password supplied to -.B getsecretkey(\|) -fails to decrypt the secret key, the routine will return 1 but the -.I secretkey -argument will be a -.SM NULL -string (``''). -.SH "SEE ALSO" -.BR publickey (5) -.LP -.I \s-1RPC\s0 Programmer's Manual -in -.TX NETP diff --git a/lib/librpc/secure_rpc/man/publickey.5 b/lib/librpc/secure_rpc/man/publickey.5 deleted file mode 100644 index de3c1e99e779..000000000000 --- a/lib/librpc/secure_rpc/man/publickey.5 +++ /dev/null @@ -1,37 +0,0 @@ -.\" @(#)publickey.5 2.1 88/08/07 4.0 RPCSRC; from 1.6 88/02/29 SMI; -.TH PUBLICKEY 5 "19 October 1987" -.SH NAME -publickey \- public key database -.SH SYNOPSIS -.B /etc/publickey -.SH DESCRIPTION -.LP -.B /etc/publickey -is the public key database used for secure -networking. Each entry in -the database consists of a network user -name (which may either refer to -a user or a hostname), followed by the user's -public key (in hex -notation), a colon, and then the user's -secret key encrypted with -its login password (also in hex notation). -.LP -This file is altered either by the user through the -.BR chkey (1) -command or by the system administrator through the -.BR newkey (8) -command. -The file -.B /etc/publickey -should only contain data on the Yellow -Pages master machine, where it -is converted into the -.SM YP -database -.BR publickey.byname . -.SH SEE ALSO -.BR chkey (1), -.BR publickey (3R), -.BR newkey (8), -.BR ypupdated (8C) diff --git a/lib/librpc/secure_rpc/man/rpc_secure.3n b/lib/librpc/secure_rpc/man/rpc_secure.3n deleted file mode 100644 index 6e9a2ee362f8..000000000000 --- a/lib/librpc/secure_rpc/man/rpc_secure.3n +++ /dev/null @@ -1,330 +0,0 @@ -.\" @(#)rpc_secure.3n 2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI -.TH RPC 3N "16 February 1988" -.SH NAME -rpc_secure \- library routines for secure remote procedure calls -.SH SYNOPSIS AND DESCRIPTION -These routines are part of the RPC library. They implement DES -Authentication. See -.BR rpc (3N) -for further details about RPC. -.LP -.ft B -.nf -.sp .5 -#include -.fi -.ft R -.br -.if t .ne 22 -.LP -.ft B -.nf -.sp .5 -\s-1AUTH\s0 * -authdes_create(name, window, syncaddr, ckey) -char *name; -unsigned window; -struct sockaddr_in *addr; -des_block *ckey; -.fi -.ft R -.IP -.B authdes_create(\|) -is the first of two routines which interface to the -.SM RPC -secure authentication system, known as -.SM DES -authentication. -The second is -.BR authdes_getucred(\|) , -below. Note: the keyserver daemon -.BR keyserv (8C) -must be running for the -.SM DES -authentication system to work. -.IP -.BR authdes_create(\|) , -used on the client side, returns an authentication handle that -will enable the use of the secure authentication system. -The first parameter -.I name -is the network name, or -.IR netname , -of the owner of the server process. This field usually -represents a -.I hostname -derived from the utility routine -.BR host2netname , -but could also represent a user name using -.BR user2netname . -The second field is window on the validity of -the client credential, given in seconds. A small -window is more secure than a large one, but choosing -too small of a window will increase the frequency of -resynchronizations because of clock drift. The third -parameter -.I syncaddr -is optional. If it is -.SM NULL\s0, -then the authentication system will assume -that the local clock is always in sync with the server's -clock, and will not attempt resynchronizations. If an address -is supplied, however, then the system will use the address -for consulting the remote time service whenever -resynchronization -is required. This parameter is usually the -address of the -.SM RPC -server itself. The final parameter -.I ckey -is also optional. If it is -.SM NULL\s0, -then the authentication system will -generate a random -.SM DES -key to be used for the encryption of credentials. -If it is supplied, however, then it will be used instead. -.br -.if t .ne 13 -.LP -.ft B -.nf -.sp .5 -authdes_getucred(adc, uid, gid, grouplen, groups) -struct authdes_cred *adc; -short *uid; -short *gid; -short *grouplen; -int *groups; -.fi -.ft R -.IP -.BR authdes_getucred(\|) , -the second of the two -.SM DES -authentication routines, -is used on the server side for converting a -.SM DES -credential, which is -operating system independent, into a -.UX -credential. This routine differs from utility routine -.B netname2user -in that -.B authdes_getucred(\|) -pulls its information from a cache, and does not have to do a -Yellow Pages lookup every time it is called to get its information. -.br -.ft .ne 8 -.LP -.ft B -.nf -.sp .5 -host2netname(name, host, domain) -char *name; -char *host; -char *domain; -.fi -.ft R -.IP -Convert from a domain-specific hostname to an -operating-system independent netname. Return -.SM TRUE -if it succeeds and -.SM FALSE -if it fails. Inverse of -.BR netname2host(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -key_decryptsession(remotename, deskey) -char *remotename; -des_block *deskey; -.fi -.ft R -.IP -.B key_decryptsession(\|) -is an interface to the keyserver daemon, which is associated -with -.SM RPC\s0's -secure authentication system (\s-1DES\s0 -authentication). -User programs rarely need to call it, or its associated routines -.BR key_encryptsession(\|) , -.B key_gendes(\|) -and -.BR key_setsecret(\|) . -System commands such as -.B login -and the -.SM RPC -library are the main clients of these four routines. -.IP -.B key_decryptsession(\|) -takes a server netname and a des key, and decrypts the key by -using the the public key of the the server and the secret key -associated with the effective uid of the calling process. It -is the inverse of -.BR key_encryptsession(\|) . -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -key_encryptsession(remotename, deskey) -char *remotename; -des_block *deskey; -.fi -.ft R -.IP -.B key_encryptsession(\|) -is a keyserver interface routine. It -takes a server netname and a des key, and encrypts -it using the public key of the the server and the secret key -associated with the effective uid of the calling process. It -is the inverse of -.BR key_decryptsession(\|) . -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -key_gendes(deskey) -des_block *deskey; -.fi -.ft R -.IP -.B key_gendes(\|) -is a keyserver interface routine. It -is used to ask the keyserver for a secure conversation key. -Choosing one at \(lqrandom\(rq is usually not good enough, -because -the common ways of choosing random numbers, such as using the -current time, are very easy to guess. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -key_setsecret(key) -char *key; -.fi -.ft R -.IP -.B key_setsecret(\|) -is a keyserver interface routine. It is used to set the key for -the effective -.I uid -of the calling process. -.br -.if t .ne 7 -.LP -.ft B -.nf -.sp .5 -getnetname(name) -char name[\s-1MAXNETNAMELEN\s0]; -.fi -.ft R -.IP -.B getnetname(\|) -installs the unique, operating-system independent netname of -the -caller in the fixed-length array -.IR name . -Returns -.SM TRUE -if it succeeds and -.SM FALSE -if it fails. -.br -.if t .ne 6 -.LP -.ft B -.nf -.sp .5 -netname2host(name, host, hostlen) -char *name; -char *host; -int hostlen; -.fi -.ft R -.IP -Convert from an operating-system independent netname to a -domain-specific hostname. Returns -.SM TRUE -if it succeeds and -.SM FALSE -if it fails. Inverse of -.BR host2netname(\|) . -.br -.if t .ne 9 -.LP -.ft B -.nf -.sp .5 -netname2user(name, uidp, gidp, gidlenp, gidlist) -char *name; -int *uidp; -int *gidp; -int *gidlenp; -int *gidlist; -.fi -.ft R -.IP -Convert from an operating-system independent netname to a -domain-specific user -.SM ID. -Returns -.SM TRUE -if it succeeds and -.SM FALSE -if it fails. Inverse of -.BR user2netname(\|) . -.br -.if t .ne 8 -.LP -.ft B -.nf -.sp .5 -user2netname(name, uid, domain) -char *name; -int uid; -char *domain; -.fi -.ft R -.IP -Convert from a domain-specific username to an operating-system -independent netname. Returns -.SM TRUE -if it succeeds and -.SM FALSE -if it fails. Inverse of -.BR netname2user(\|) . -.br -.SH SEE ALSO -.BR xdr (3N), -.BR keyserv (8C), -.BR rpc (3N) -.br -The following manuals: -.RS -.ft I -Remote Procedure Calls: Protocol Specification -.br -Remote Procedure Call Programming Guide -.br -rpcgen Programming Guide -.br -.ft R -.RE -.IR "\s-1RPC\s0: Remote Procedure Call Protocol Specification" , -.SM RFC1050, Sun Microsystems, Inc., -.SM USC-ISI\s0. - diff --git a/lib/librpc/secure_rpc/man/rtime.3n b/lib/librpc/secure_rpc/man/rtime.3n deleted file mode 100644 index af0c1ca15960..000000000000 --- a/lib/librpc/secure_rpc/man/rtime.3n +++ /dev/null @@ -1,43 +0,0 @@ -.\" @(#)rtime.3n 2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI -.TH RTIME 3 "22 November 1987" -.SH NAME -rtime \- get remote time -.SH SYNOPSIS -.nf -.B #include -.B #include -.B #include -.LP -.B int rtime(addrp, timep, timeout) -.B struct sockaddr_in \(**addrp; -.B struct timeval \(**timep; -.B struct timeval \(**timeout; -.fi -.SH DESCRIPTION -.B rtime(\|) -consults the Internet Time Server at the address pointed to by -.I addrp -and returns the remote time in the -.B timeval -struct pointed to by -.IR timep . -Normally, the -.SM UDP -protocol is used when consulting the Time Server. The -.I timeout -parameter specifies how long the -routine should wait before giving -up when waiting for a reply. If -.I timeout -is specified as -.SM NULL\s0, -however, the routine will instead use -.SM TCP -and block until a reply is received from the time server. -.LP -The routine returns 0 if it is successful. Otherwise, -it returns \-1 and -.B errno -is set to reflect the cause of the error. -.SH "SEE ALSO" -.BR timed (8c) diff --git a/lib/librpc/secure_rpc/rpc/Makefile b/lib/librpc/secure_rpc/rpc/Makefile deleted file mode 100644 index 88b242fcf28f..000000000000 --- a/lib/librpc/secure_rpc/rpc/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# @(#)Makefile 2.3 88/08/15 4.0 RPCSRC -# -# -# Copyright (c) 1987 by Sun Microsystems, Inc. -# - -DESTDIR= - -CFLAGS = -I.. - -SRCS = auth_des.c authdes_prot.c key_call.c key_prot.c netname.c svcauth_des.c \ - openchild.c rtime.c publickey.c xcrypt.c \ - auth_none.c auth_unix.c authunix_prot.c bindresvport.c \ - clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c clnt_tcp.c \ - clnt_udp.c rpc_dtablesize.c get_myaddress.c getrpcent.c getrpcport.c \ - pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \ - pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \ - svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \ - svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c - -OBJS = auth_des.o authdes_prot.o key_call.o key_prot.o netname.o svcauth_des.o \ - openchild.o rtime.o publickey.o xcrypt.o \ - auth_none.o auth_unix.o authunix_prot.o bindresvport.o \ - clnt_generic.o clnt_perror.o clnt_raw.o clnt_simple.o clnt_tcp.o \ - clnt_udp.o rpc_dtablesize.o get_myaddress.o getrpcent.o getrpcport.o \ - pmap_clnt.o pmap_getmaps.o pmap_getport.o pmap_prot.o \ - pmap_prot2.o pmap_rmt.o rpc_prot.o rpc_commondata.o rpc_callmsg.o \ - svc.o svc_auth.o svc_auth_unix.o svc_raw.o svc_run.o svc_simple.o \ - svc_tcp.o svc_udp.o xdr.o xdr_array.o xdr_float.o xdr_mem.o \ - xdr_rec.o xdr_reference.o xdr_stdio.o - -HDRS = key_prot.h \ - auth.h auth_unix.h auth_des.h clnt.h netdb.h pmap_clnt.h \ - pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h svc.h svc_auth.h types.h xdr.h - -XFILES= key_prot.x - -all rpclib: librpclib.a - -librpclib.a: ${OBJS} - @echo "building librpclib.a" - @ar cru librpclib.a ${OBJS} - -install: $(HDRS) librpclib.a - @echo "Creating RPC header directory" - -mkdir ${DESTDIR}/usr/include/rpc && \ - chown bin ${DESTDIR}/usr/include/rpc && \ - chmod 755 ${DESTDIR}/usr/include/rpc - @echo "Installing RPC header files" - -set -x;for i in $(HDRS) $(XFILES) ; do \ - (install -c -m 644 $$i ${DESTDIR}/usr/include/rpc) done - @echo "Installing RPC library" - install -c -m 644 librpclib.a ${DESTDIR}/usr/lib - ranlib ${DESTDIR}/usr/lib/librpclib.a - -tags: $(SRCS) $(HDRS) - ctags -tw $(SRCS) $(HDRS) - -ref: tags - sed 's, /.*,,' tags | \ - awk ' { printf("%-26s%-16s%s\n", $$1, $$2, $$3) }' > ref - -lint: $(SRCS) $(HDRS) - $(LINT.c) $(SRCS) - -clean: rm -f *.o rpclib.a - -.SUFFIXES: .x .x~ - -.x.c: - rpcgen -c $< | \ - sed 's/^#include \"$*\.h\"/#include /' > $@ - -.x.h: - rpcgen -h $< > $@ - -depend: $(SRCS) $(HDRS) - @${CC} ${CFLAGS} -M ${SRCS} > makedep - @echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep - @echo '$$r makedep' >>eddep - @echo 'w' >>eddep - @cp Makefile makefile.bak - @ed - Makefile < eddep - @rm eddep makedep makefile.bak - -depend.42BSD depend.42bsd: - cp /dev/null x.c - for i in $(SRCS) ; do \ - (/bin/grep '^#[ ]*include' x.c $$i | sed \ - -e '/\.\.\/h/d' \ - -e '/\.\.\/ufs/d' \ - -e 's,<\(.*\)>,"/usr/include/\1",' \ - -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ - -e 's/\.c/\.o/' >>makedep); done - echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep - echo '$$r makedep' >>eddep - echo 'w' >>eddep - cp Makefile Makefile.bak - ed - Makefile < eddep - rm eddep makedep x.c - echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile - echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile - echo '# see make depend above' >> Makefile - -# DO NOT DELETE THIS LINE - - diff --git a/lib/librpc/secure_rpc/rpc/auth_des.c b/lib/librpc/secure_rpc/rpc/auth_des.c deleted file mode 100644 index a757c498a99e..000000000000 --- a/lib/librpc/secure_rpc/rpc/auth_des.c +++ /dev/null @@ -1,411 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)auth_des.c 2.2 88/07/29 4.0 RPCSRC; from 1.9 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* - * auth_des.c, client-side implementation of DES authentication - */ - -#include -#include -#include -#include -#include -#include /* XXX: just to get htonl() and ntohl() */ -#include - -#define MILLION 1000000L -#define RTIME_TIMEOUT 5 /* seconds to wait for sync */ - -#define AUTH_PRIVATE(auth) (struct ad_private *) auth->ah_private -#define ALLOC(object_type) (object_type *) mem_alloc(sizeof(object_type)) -#define FREE(ptr, size) mem_free((char *)(ptr), (int) size) -#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) - -#define debug(msg) /*printf("%s\n", msg) */ - -/* - * DES authenticator operations vector - */ -static void authdes_nextverf(); -static bool_t authdes_marshal(); -static bool_t authdes_validate(); -static bool_t authdes_refresh(); -static void authdes_destroy(); -static struct auth_ops authdes_ops = { - authdes_nextverf, - authdes_marshal, - authdes_validate, - authdes_refresh, - authdes_destroy -}; - - -/* - * This struct is pointed to by the ah_private field of an "AUTH *" - */ -struct ad_private { - char *ad_fullname; /* client's full name */ - u_int ad_fullnamelen; /* length of name, rounded up */ - char *ad_servername; /* server's full name */ - u_int ad_servernamelen; /* length of name, rounded up */ - u_int ad_window; /* client specified window */ - bool_t ad_dosync; /* synchronize? */ - struct sockaddr ad_syncaddr; /* remote host to synch with */ - struct timeval ad_timediff; /* server's time - client's time */ - u_long ad_nickname; /* server's nickname for client */ - struct authdes_cred ad_cred; /* storage for credential */ - struct authdes_verf ad_verf; /* storage for verifier */ - struct timeval ad_timestamp; /* timestamp sent */ - des_block ad_xkey; /* encrypted conversation key */ -}; - - -/* - * Create the client des authentication object - */ -AUTH * -authdes_create(servername, window, syncaddr, ckey) - char *servername; /* network name of server */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional addr of host to sync with */ - des_block *ckey; /* optional conversation key to use*/ -{ - - AUTH *auth; - struct ad_private *ad; - char namebuf[MAXNETNAMELEN+1]; - - /* - * Allocate everything now - */ - auth = ALLOC(AUTH); - ad = ALLOC(struct ad_private); - (void) getnetname(namebuf); - - ad->ad_fullnamelen = RNDUP(strlen(namebuf)); - ad->ad_fullname = mem_alloc(ad->ad_fullnamelen + 1); - - ad->ad_servernamelen = strlen(servername); - ad->ad_servername = mem_alloc(ad->ad_servernamelen + 1); - - if (auth == NULL || ad == NULL || ad->ad_fullname == NULL || - ad->ad_servername == NULL) { - debug("authdes_create: out of memory"); - goto failed; - } - - /* - * Set up private data - */ - bcopy(namebuf, ad->ad_fullname, ad->ad_fullnamelen + 1); - bcopy(servername, ad->ad_servername, ad->ad_servernamelen + 1); - if (syncaddr != NULL) { - ad->ad_syncaddr = *syncaddr; - ad->ad_dosync = TRUE; - } else { - ad->ad_dosync = FALSE; - } - ad->ad_window = window; - if (ckey == NULL) { - if (key_gendes(&auth->ah_key) < 0) { - debug("authdes_create: unable to gen conversation key"); - return (NULL); - } - } else { - auth->ah_key = *ckey; - } - - /* - * Set up auth handle - */ - auth->ah_cred.oa_flavor = AUTH_DES; - auth->ah_verf.oa_flavor = AUTH_DES; - auth->ah_ops = &authdes_ops; - auth->ah_private = (caddr_t)ad; - - if (!authdes_refresh(auth)) { - goto failed; - } - return (auth); - -failed: - if (auth != NULL) - FREE(auth, sizeof(AUTH)); - if (ad != NULL) - FREE(ad, sizeof(struct ad_private)); - if (ad->ad_fullname != NULL) - FREE(ad->ad_fullname, ad->ad_fullnamelen + 1); - if (ad->ad_servername != NULL) - FREE(ad->ad_servername, ad->ad_servernamelen + 1); - return (NULL); -} - -/* - * Implement the five authentication operations - */ - - -/* - * 1. Next Verifier - */ -/*ARGSUSED*/ -static void -authdes_nextverf(auth) - AUTH *auth; -{ - /* what the heck am I supposed to do??? */ -} - - - -/* - * 2. Marshal - */ -static bool_t -authdes_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; -{ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_cred *cred = &ad->ad_cred; - struct authdes_verf *verf = &ad->ad_verf; - des_block cryptbuf[2]; - des_block ivec; - int status; - int len; - register long *ixdr; - - /* - * Figure out the "time", accounting for any time difference - * with the server if necessary. - */ - (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL); - ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; - ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; - if (ad->ad_timestamp.tv_usec >= MILLION) { - ad->ad_timestamp.tv_usec -= MILLION; - ad->ad_timestamp.tv_sec += 1; - } - - /* - * XDR the timestamp and possibly some other things, then - * encrypt them. - */ - ixdr = (long *)cryptbuf; - IXDR_PUT_LONG(ixdr, ad->ad_timestamp.tv_sec); - IXDR_PUT_LONG(ixdr, ad->ad_timestamp.tv_usec); - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - IXDR_PUT_U_LONG(ixdr, ad->ad_window); - IXDR_PUT_U_LONG(ixdr, ad->ad_window - 1); - ivec.key.high = ivec.key.low = 0; - status = cbc_crypt((char *)&auth->ah_key, (char *)cryptbuf, - 2*sizeof(des_block), DES_ENCRYPT | DES_HW, (char *)&ivec); - } else { - status = ecb_crypt((char *)&auth->ah_key, (char *)cryptbuf, - sizeof(des_block), DES_ENCRYPT | DES_HW); - } - if (DES_FAILED(status)) { - debug("authdes_marshal: DES encryption failure"); - return (FALSE); - } - ad->ad_verf.adv_xtimestamp = cryptbuf[0]; - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high; - ad->ad_verf.adv_winverf = cryptbuf[1].key.low; - } else { - ad->ad_cred.adc_nickname = ad->ad_nickname; - ad->ad_verf.adv_winverf = 0; - } - - /* - * Serialize the credential and verifier into opaque - * authentication data. - */ - if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { - len = ((1 + 1 + 2 + 1)*BYTES_PER_XDR_UNIT + ad->ad_fullnamelen); - } else { - len = (1 + 1)*BYTES_PER_XDR_UNIT; - } - - if (ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT)) { - IXDR_PUT_LONG(ixdr, AUTH_DES); - IXDR_PUT_LONG(ixdr, len); - } else { - ATTEMPT(xdr_putlong(xdrs, &auth->ah_cred.oa_flavor)); - ATTEMPT(xdr_putlong(xdrs, &len)); - } - ATTEMPT(xdr_authdes_cred(xdrs, cred)); - - len = (2 + 1)*BYTES_PER_XDR_UNIT; - if (ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT)) { - IXDR_PUT_LONG(ixdr, AUTH_DES); - IXDR_PUT_LONG(ixdr, len); - } else { - ATTEMPT(xdr_putlong(xdrs, &auth->ah_verf.oa_flavor)); - ATTEMPT(xdr_putlong(xdrs, &len)); - } - ATTEMPT(xdr_authdes_verf(xdrs, verf)); - return (TRUE); -} - - -/* - * 3. Validate - */ -static bool_t -authdes_validate(auth, rverf) - AUTH *auth; - struct opaque_auth *rverf; -{ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_verf verf; - int status; - register u_long *ixdr; - - if (rverf->oa_length != (2 + 1) * BYTES_PER_XDR_UNIT) { - return (FALSE); - } - ixdr = (u_long *)rverf->oa_base; - verf.adv_xtimestamp.key.high = (u_long)*ixdr++; - verf.adv_xtimestamp.key.low = (u_long)*ixdr++; - verf.adv_int_u = (u_long)*ixdr++; /* nickname not XDR'd ! */ - - /* - * Decrypt the timestamp - */ - status = ecb_crypt((char *)&auth->ah_key, (char *)&verf.adv_xtimestamp, - sizeof(des_block), DES_DECRYPT | DES_HW); - - if (DES_FAILED(status)) { - debug("authdes_validate: DES decryption failure"); - return (FALSE); - } - - /* - * xdr the decrypted timestamp - */ - ixdr = (u_long *)verf.adv_xtimestamp.c; - verf.adv_timestamp.tv_sec = IXDR_GET_LONG(ixdr) + 1; - verf.adv_timestamp.tv_usec = IXDR_GET_LONG(ixdr); - - /* - * validate - */ - if (bcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp, - sizeof(struct timeval)) != 0) { - debug("authdes_validate: verifier mismatch\n"); - return (FALSE); - } - - /* - * We have a nickname now, let's use it - */ - ad->ad_nickname = verf.adv_nickname; - ad->ad_cred.adc_namekind = ADN_NICKNAME; - return (TRUE); -} - -/* - * 4. Refresh - */ -static bool_t -authdes_refresh(auth) - AUTH *auth; -{ - struct ad_private *ad = AUTH_PRIVATE(auth); - struct authdes_cred *cred = &ad->ad_cred; - - if (ad->ad_dosync && - !synchronize(&ad->ad_syncaddr, &ad->ad_timediff)) { - /* - * Hope the clocks are synced! - */ - ad->ad_timediff.tv_sec = ad->ad_timediff.tv_usec = 0; - debug("authdes_refresh: unable to synchronize with server"); - } - ad->ad_xkey = auth->ah_key; - if (key_encryptsession(ad->ad_servername, &ad->ad_xkey) < 0) { - debug("authdes_create: unable to encrypt conversation key"); - return (FALSE); - } - cred->adc_fullname.key = ad->ad_xkey; - cred->adc_namekind = ADN_FULLNAME; - cred->adc_fullname.name = ad->ad_fullname; - return (TRUE); -} - - -/* - * 5. Destroy - */ -static void -authdes_destroy(auth) - AUTH *auth; -{ - struct ad_private *ad = AUTH_PRIVATE(auth); - - FREE(ad->ad_fullname, ad->ad_fullnamelen + 1); - FREE(ad->ad_servername, ad->ad_servernamelen + 1); - FREE(ad, sizeof(struct ad_private)); - FREE(auth, sizeof(AUTH)); -} - - - -/* - * Synchronize with the server at the given address, that is, - * adjust timep to reflect the delta between our clocks - */ -static bool_t -synchronize(syncaddr, timep) - struct sockaddr *syncaddr; - struct timeval *timep; -{ - struct timeval mytime; - struct timeval timeout; - - timeout.tv_sec = RTIME_TIMEOUT; - timeout.tv_usec = 0; - if (rtime((struct sockaddr_in *)syncaddr, timep, &timeout) < 0) { - return (FALSE); - } - (void) gettimeofday(&mytime, (struct timezone *)NULL); - timep->tv_sec -= mytime.tv_sec; - if (mytime.tv_usec > timep->tv_usec) { - timep->tv_sec -= 1; - timep->tv_usec += MILLION; - } - timep->tv_usec -= mytime.tv_usec; - return (TRUE); -} diff --git a/lib/librpc/secure_rpc/rpc/auth_des.h b/lib/librpc/secure_rpc/rpc/auth_des.h deleted file mode 100644 index 4ae476123432..000000000000 --- a/lib/librpc/secure_rpc/rpc/auth_des.h +++ /dev/null @@ -1,105 +0,0 @@ -/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * auth_des.h, Protocol for DES style authentication for RPC - */ - -#ifndef _AUTH_DES_ -#define _AUTH_DES_ - -/* - * There are two kinds of "names": fullnames and nicknames - */ -enum authdes_namekind { - ADN_FULLNAME, - ADN_NICKNAME -}; - -/* - * A fullname contains the network name of the client, - * a conversation key and the window - */ -struct authdes_fullname { - char *name; /* network name of client, up to MAXNETNAMELEN */ - des_block key; /* conversation key */ - u_long window; /* associated window */ -}; - - -/* - * A credential - */ -struct authdes_cred { - enum authdes_namekind adc_namekind; - struct authdes_fullname adc_fullname; - u_long adc_nickname; -}; - - - -/* - * A des authentication verifier - */ -struct authdes_verf { - union { - struct timeval adv_ctime; /* clear time */ - des_block adv_xtime; /* crypt time */ - } adv_time_u; - u_long adv_int_u; -}; - -/* - * des authentication verifier: client variety - * - * adv_timestamp is the current time. - * adv_winverf is the credential window + 1. - * Both are encrypted using the conversation key. - */ -#define adv_timestamp adv_time_u.adv_ctime -#define adv_xtimestamp adv_time_u.adv_xtime -#define adv_winverf adv_int_u - -/* - * des authentication verifier: server variety - * - * adv_timeverf is the client's timestamp + client's window - * adv_nickname is the server's nickname for the client. - * adv_timeverf is encrypted using the conversation key. - */ -#define adv_timeverf adv_time_u.adv_ctime -#define adv_xtimeverf adv_time_u.adv_xtime -#define adv_nickname adv_int_u - -#endif /* ndef _AUTH_DES_ */ diff --git a/lib/librpc/secure_rpc/rpc/authdes_prot.c b/lib/librpc/secure_rpc/rpc/authdes_prot.c deleted file mode 100644 index 14679c00a9cc..000000000000 --- a/lib/librpc/secure_rpc/rpc/authdes_prot.c +++ /dev/null @@ -1,82 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)authdes_prot.c 2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * authdes_prot.c, XDR routines for DES authentication - */ - -#include -#include -#include -#include - -#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) - -bool_t -xdr_authdes_cred(xdrs, cred) - XDR *xdrs; - struct authdes_cred *cred; -{ - /* - * Unrolled xdr - */ - ATTEMPT(xdr_enum(xdrs, (enum_t *)&cred->adc_namekind)); - switch (cred->adc_namekind) { - case ADN_FULLNAME: - ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name, MAXNETNAMELEN)); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key, sizeof(des_block))); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window, sizeof(cred->adc_fullname.window))); - return (TRUE); - case ADN_NICKNAME: - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname, sizeof(cred->adc_nickname))); - return (TRUE); - default: - return (FALSE); - } -} - - -bool_t -xdr_authdes_verf(xdrs, verf) - register XDR *xdrs; - register struct authdes_verf *verf; -{ - /* - * Unrolled xdr - */ - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp, sizeof(des_block))); - ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u, sizeof(verf->adv_int_u))); - return (TRUE); -} diff --git a/lib/librpc/secure_rpc/rpc/key_call.c b/lib/librpc/secure_rpc/rpc/key_call.c deleted file mode 100644 index c2fd3354d042..000000000000 --- a/lib/librpc/secure_rpc/rpc/key_call.c +++ /dev/null @@ -1,228 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)key_call.c 2.2 88/08/15 4.0 RPCSRC; from 1.11 88/02/08 SMI"; -#endif -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * key_call.c, Interface to keyserver - * - * setsecretkey(key) - set your secret key - * encryptsessionkey(agent, deskey) - encrypt a session key to talk to agent - * decryptsessionkey(agent, deskey) - decrypt ditto - * gendeskey(deskey) - generate a secure des key - * netname2user(...) - get unix credential for given name (kernel only) - */ -#include -#include -#include -#include - -#define KEY_TIMEOUT 5 /* per-try timeout in seconds */ -#define KEY_NRETRY 12 /* number of retries */ - -#define debug(msg) /* turn off debugging */ - -static struct timeval trytimeout = { KEY_TIMEOUT, 0 }; -static struct timeval tottimeout = { KEY_TIMEOUT * KEY_NRETRY, 0 }; - -key_setsecret(secretkey) - char *secretkey; -{ - keystatus status; - - if (!key_call((u_long)KEY_SET, xdr_keybuf, secretkey, xdr_keystatus, - (char*)&status)) - { - return (-1); - } - if (status != KEY_SUCCESS) { - debug("set status is nonzero"); - return (-1); - } - return (0); -} - - -key_encryptsession(remotename, deskey) - char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_ENCRYPT, - xdr_cryptkeyarg, (char *)&arg, xdr_cryptkeyres, (char *)&res)) - { - return (-1); - } - if (res.status != KEY_SUCCESS) { - debug("encrypt status is nonzero"); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - - -key_decryptsession(remotename, deskey) - char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_DECRYPT, - xdr_cryptkeyarg, (char *)&arg, xdr_cryptkeyres, (char *)&res)) - { - return (-1); - } - if (res.status != KEY_SUCCESS) { - debug("decrypt status is nonzero"); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -key_gendes(key) - des_block *key; -{ - struct sockaddr_in sin; - CLIENT *client; - int socket; - enum clnt_stat stat; - - - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - bzero(sin.sin_zero, sizeof(sin.sin_zero)); - socket = RPC_ANYSOCK; - client = clntudp_bufcreate(&sin, (u_long)KEY_PROG, (u_long)KEY_VERS, - trytimeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == NULL) { - return (-1); - } - stat = clnt_call(client, KEY_GEN, xdr_void, NULL, - xdr_des_block, key, tottimeout); - clnt_destroy(client); - (void) close(socket); - if (stat != RPC_SUCCESS) { - return (-1); - } - return (0); -} - - -#include -#include - - -static -key_call(proc, xdr_arg, arg, xdr_rslt, rslt) - u_long proc; - bool_t (*xdr_arg)(); - char *arg; - bool_t (*xdr_rslt)(); - char *rslt; -{ - XDR xdrargs; - XDR xdrrslt; - FILE *fargs; - FILE *frslt; - int (*osigchild)(); - union wait status; - int pid; - int success; - int ruid; - int euid; - static char MESSENGER[] = "/usr/etc/keyenvoy"; - - success = 1; - osigchild = signal(SIGCHLD, SIG_IGN); - - /* - * We are going to exec a set-uid program which makes our effective uid - * zero, and authenticates us with our real uid. We need to make the - * effective uid be the real uid for the setuid program, and - * the real uid be the effective uid so that we can change things back. - */ - euid = geteuid(); - ruid = getuid(); - (void) setreuid(euid, ruid); - pid = _openchild(MESSENGER, &fargs, &frslt); - (void) setreuid(ruid, euid); - if (pid < 0) { - debug("open_streams"); - return (0); - } - xdrstdio_create(&xdrargs, fargs, XDR_ENCODE); - xdrstdio_create(&xdrrslt, frslt, XDR_DECODE); - - if (!xdr_u_long(&xdrargs, &proc) || !(*xdr_arg)(&xdrargs, arg)) { - debug("xdr args"); - success = 0; - } - (void) fclose(fargs); - - if (success && !(*xdr_rslt)(&xdrrslt, rslt)) { - debug("xdr rslt"); - success = 0; - } - -#ifdef NOTDEF - /* - * WARNING! XXX - * The original code appears first. wait4 returns only after the process - * with the requested pid terminates. The effect of using wait() instead - * has not been determined. - */ - (void) fclose(frslt); - if (wait4(pid, &status, 0, NULL) < 0 || status.w_retcode != 0) { - debug("wait4"); - success = 0; - } -#endif /* def NOTDEF */ - if (wait(&status) < 0 || status.w_retcode != 0) { - debug("wait"); - success = 0; - } - (void)signal(SIGCHLD, osigchild); - - return (success); -} - diff --git a/lib/librpc/secure_rpc/rpc/key_prot.c b/lib/librpc/secure_rpc/rpc/key_prot.c deleted file mode 100644 index a93f54312a0e..000000000000 --- a/lib/librpc/secure_rpc/rpc/key_prot.c +++ /dev/null @@ -1,165 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)key_prot.c 2.1 88/08/07 4.0 RPCSRC; from 1.4 88/02/08 SMI"; -#endif - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#include -#include - - -/* - * Compiled from key_prot.x using rpcgen. - * DO NOT EDIT THIS FILE! - * This is NOT source code! - */ - - -bool_t -xdr_keystatus(xdrs, objp) - XDR *xdrs; - keystatus *objp; -{ - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_keybuf(xdrs, objp) - XDR *xdrs; - keybuf objp; -{ - if (!xdr_opaque(xdrs, objp, HEXKEYBYTES)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_netnamestr(xdrs, objp) - XDR *xdrs; - netnamestr *objp; -{ - if (!xdr_string(xdrs, objp, MAXNETNAMELEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_cryptkeyarg(xdrs, objp) - XDR *xdrs; - cryptkeyarg *objp; -{ - if (!xdr_netnamestr(xdrs, &objp->remotename)) { - return (FALSE); - } - if (!xdr_des_block(xdrs, &objp->deskey)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_cryptkeyres(xdrs, objp) - XDR *xdrs; - cryptkeyres *objp; -{ - if (!xdr_keystatus(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - - - -bool_t -xdr_unixcred(xdrs, objp) - XDR *xdrs; - unixcred *objp; -{ - if (!xdr_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_array(xdrs, (char **)&objp->gids.gids_val, (u_int *)&objp->gids.gids_len, MAXGIDS, sizeof(int), xdr_int)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_getcredres(xdrs, objp) - XDR *xdrs; - getcredres *objp; -{ - if (!xdr_keystatus(xdrs, &objp->status)) { - return (FALSE); - } - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_unixcred(xdrs, &objp->getcredres_u.cred)) { - return (FALSE); - } - break; - } - return (TRUE); -} - - diff --git a/lib/librpc/secure_rpc/rpc/key_prot.h b/lib/librpc/secure_rpc/rpc/key_prot.h deleted file mode 100644 index 277e4b832634..000000000000 --- a/lib/librpc/secure_rpc/rpc/key_prot.h +++ /dev/null @@ -1,114 +0,0 @@ -/* @(#)key_prot.h 2.1 88/08/07 4.0 RPCSRC; from 1.4 87/03/10 Copyr 1986 Sun Micro */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - - -/* - * Compiled from key_prot.x using rpcgen. - * DO NOT EDIT THIS FILE! - * This is NOT source code! - */ - -#define KEY_PROG 100029 -#define KEY_VERS 1 -#define KEY_SET 1 -#define KEY_ENCRYPT 2 -#define KEY_DECRYPT 3 -#define KEY_GEN 4 -#define KEY_GETCRED 5 - -#define PROOT 3 -#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" -#define HEXKEYBYTES 48 -#define KEYSIZE 192 -#define KEYBYTES 24 -#define KEYCHECKSUMSIZE 16 - -enum keystatus { - KEY_SUCCESS = 0, - KEY_NOSECRET = 1, - KEY_UNKNOWN = 2, - KEY_SYSTEMERR = 3, -}; -typedef enum keystatus keystatus; -bool_t xdr_keystatus(); - - -typedef char keybuf[HEXKEYBYTES]; -bool_t xdr_keybuf(); - - -typedef char *netnamestr; -bool_t xdr_netnamestr(); - - -struct cryptkeyarg { - netnamestr remotename; - des_block deskey; -}; -typedef struct cryptkeyarg cryptkeyarg; -bool_t xdr_cryptkeyarg(); - - -struct cryptkeyres { - keystatus status; - union { - des_block deskey; - } cryptkeyres_u; -}; -typedef struct cryptkeyres cryptkeyres; -bool_t xdr_cryptkeyres(); - -#define MAXGIDS 16 - -struct unixcred { - int uid; - int gid; - struct { - u_int gids_len; - int *gids_val; - } gids; -}; -typedef struct unixcred unixcred; -bool_t xdr_unixcred(); - - -struct getcredres { - keystatus status; - union { - unixcred cred; - } getcredres_u; -}; -typedef struct getcredres getcredres; -bool_t xdr_getcredres(); - diff --git a/lib/librpc/secure_rpc/rpc/key_prot.x b/lib/librpc/secure_rpc/rpc/key_prot.x deleted file mode 100644 index 2f6ebdbcf0ef..000000000000 --- a/lib/librpc/secure_rpc/rpc/key_prot.x +++ /dev/null @@ -1,151 +0,0 @@ -%/* @(#)key_prot.x 2.1 88/08/07 4.0 RPCSRC; from 1.7 88/02/08 SMI */ -% -%/* -% * Copyright (c) 1988 by Sun Microsystems, Inc. -% */ -% -%/* -% * Compiled from key_prot.x using rpcgen. -% * DO NOT EDIT THIS FILE! -% * This is NOT source code! -% */ - -/* - * Key server protocol definition - * Copyright (C) 1987 Sun Microsystems, Inc. - * - * The keyserver is a public key storage/encryption/decryption service - * The encryption method used is Diffie-Hellman with 128 bit keys. - * - * The key server is local to each machine, akin to the portmapper. - * Only privileged processes may talk to the key server, so - * user processes must communicate through a privileged dispatcher (such - * as the kernel or a set-uid-root process). - */ -program KEY_PROG { - version KEY_VERS { - /* - * This is my secret key. - * Store it for me. - */ - int - KEY_SET(keybuf) = 1; - - /* - * I want to talk to X. - * Encrypt a conversation key for me. - */ - cryptkeyres - KEY_ENCRYPT(cryptkeyarg) = 2; - - /* - * X just sent me a message. - * Decrypt the conversation key for me. - */ - cryptkeyres - KEY_DECRYPT(cryptkeyarg) = 3; - - /* - * Generate a secure conversation key for me - */ - des_block - KEY_GEN(void) = 4; - - /* - * Get me the uid, gid and group-access-list associated - * with this netname (for kernel which cannot use yp) - */ - getcredres - KEY_GETCRED(netnamestr) = 5; - } = 1; -} = 100029; - - -/* - * PROOT and MODULUS define the way the Diffie-Hellman key is generated. - * - * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1, - * where p is also prime. - * - * PROOT satisfies the following two conditions: - * (1) (PROOT ** 2) % MODULUS != 1 - * (2) (PROOT ** p) % MODULUS != 1 - * - */ - -const PROOT = 3; -const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; - -const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */ -const KEYSIZE = 192; /* KEYSIZE == bit length of key */ -const KEYBYTES = 24; /* byte length of key */ - -/* - * The first 16 hex digits of the encrypted secret key are used as - * a checksum in the database. - */ -const KEYCHECKSUMSIZE = 16; - -/* - * status of operation - */ -enum keystatus { - KEY_SUCCESS, /* no problems */ - KEY_NOSECRET, /* no secret key stored */ - KEY_UNKNOWN, /* unknown netname */ - KEY_SYSTEMERR /* system error (out of memory, encryption failure) */ -}; - -/* - * The kernel doesn't use keybuf, so we insure that it - * is ifdef'd out in the output files. The proper way to do - * this is to #ifndef KERNEL it here, and have the kernel build - * use rpcgen, but config doesn't understand rpcgen files so - * it is done this way. - */ -#ifndef RPC_SVC -%#ifndef KERNEL -typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */ -%#endif -#endif - -typedef string netnamestr; - -/* - * Argument to ENCRYPT or DECRYPT - */ -struct cryptkeyarg { - netnamestr remotename; - des_block deskey; -}; - -/* - * Result of ENCRYPT or DECRYPT - */ -union cryptkeyres switch (keystatus status) { -case KEY_SUCCESS: - des_block deskey; -default: - void; -}; - -const MAXGIDS = 16; /* max number of gids in gid list */ - -/* - * Unix credential - */ -struct unixcred { - int uid; - int gid; - int gids; -}; - -/* - * Result returned from GETCRED - */ -union getcredres switch (keystatus status) { -case KEY_SUCCESS: - unixcred cred; -default: - void; -}; diff --git a/lib/librpc/secure_rpc/rpc/netname.c b/lib/librpc/secure_rpc/rpc/netname.c deleted file mode 100644 index 21e2491d9a8d..000000000000 --- a/lib/librpc/secure_rpc/rpc/netname.c +++ /dev/null @@ -1,239 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)netname.c 2.2 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * netname utility routines - * convert from unix names to network names and vice-versa - * This module is operating system dependent! - * What we define here will work with any unix system that has adopted - * the sun yp domain architecture. - */ -#include -#include -#include - -extern char *sprintf(); -extern char *strncpy(); - -static char OPSYS[] = "unix"; -static char NETID[] = "netid.byname"; - -/* - * Convert network-name into unix credential - */ -netname2user(netname, uidp, gidp, gidlenp, gidlist) - char netname[MAXNETNAMELEN+1]; - int *uidp; - int *gidp; - int *gidlenp; - int *gidlist; -{ - int stat; - char *val; - char *p; - int vallen; - char *domain; - int gidlen; - - stat = yp_get_default_domain(&domain); - if (stat != 0) { - return (0); - } - stat = yp_match(domain, NETID, netname, strlen(netname), &val, &vallen); - if (stat != 0) { - return (0); - } - val[vallen] = 0; - p = val; - *uidp = atois(&p); - if (p == NULL || *p++ != ':') { - free(val); - return (0); - } - *gidp = atois(&p); - if (p == NULL) { - free(val); - return (0); - } - gidlen = 0; - for (gidlen = 0; gidlen < NGROUPS; gidlen++) { - if (*p++ != ',') { - break; - } - gidlist[gidlen] = atois(&p); - if (p == NULL) { - free(val); - return (0); - } - } - *gidlenp = gidlen; - free(val); - return (1); -} - -/* - * Convert network-name to hostname - */ -netname2host(netname, hostname, hostlen) - char netname[MAXNETNAMELEN+1]; - char *hostname; - int hostlen; -{ - int stat; - char *val; - int vallen; - char *domain; - - stat = yp_get_default_domain(&domain); - if (stat != 0) { - return (0); - } - stat = yp_match(domain, NETID, netname, strlen(netname), &val, &vallen); - if (stat != 0) { - return (0); - } - val[vallen] = 0; - if (*val != '0') { - free(val); - return (0); - } - if (val[1] != ':') { - free(val); - return (0); - } - (void) strncpy(hostname, val + 2, hostlen); - free(val); - return (1); -} - - -/* - * Figure out my fully qualified network name - */ -getnetname(name) - char name[MAXNETNAMELEN+1]; -{ - int uid; - - uid = geteuid(); - if (uid == 0) { - return (host2netname(name, (char *) NULL, (char *) NULL)); - } else { - return (user2netname(name, uid, (char *) NULL)); - } -} - - -/* - * Convert unix cred to network-name - */ -user2netname(netname, uid, domain) - char netname[MAXNETNAMELEN + 1]; - int uid; - char *domain; -{ - char *dfltdom; - -#define MAXIPRINT (11) /* max length of printed integer */ - - if (domain == NULL) { - if (yp_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (strlen(domain) + 1 + MAXIPRINT > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%d@%s", OPSYS, uid, domain); - return (1); -} - - -/* - * Convert host to network-name - */ -host2netname(netname, host, domain) - char netname[MAXNETNAMELEN + 1]; - char *host; - char *domain; -{ - char *dfltdom; - char hostname[MAXHOSTNAMELEN+1]; - - if (domain == NULL) { - if (yp_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (host == NULL) { - (void) gethostname(hostname, sizeof(hostname)); - host = hostname; - } - if (strlen(domain) + 1 + strlen(host) > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain); - return (1); -} - - -static -atois(str) - char **str; -{ - char *p; - int n; - int sign; - - if (**str == '-') { - sign = -1; - (*str)++; - } else { - sign = 1; - } - n = 0; - for (p = *str; isdigit(*p); p++) { - n = (10 * n) + (*p - '0'); - } - if (p == *str) { - *str = NULL; - return (0); - } - *str = p; - return (n * sign); -} diff --git a/lib/librpc/secure_rpc/rpc/openchild.c b/lib/librpc/secure_rpc/rpc/openchild.c deleted file mode 100644 index b30e61515902..000000000000 --- a/lib/librpc/secure_rpc/rpc/openchild.c +++ /dev/null @@ -1,133 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)openchild.c 2.3 88/08/15 4.0 RPCSRC; from 1.7 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * Open two pipes to a child process, one for reading, one for writing. - * The pipes are accessed by FILE pointers. This is NOT a public - * interface, but for internal use only! - */ -#include - -extern char *malloc(); -extern char *rindex(); -extern char *sprintf(); - -static char *basename(); -static char SHELL[] = "/bin/sh"; - - -/* - * returns pid, or -1 for failure - */ -_openchild(command, fto, ffrom) - char *command; - FILE **fto; - FILE **ffrom; -{ - int i; - int pid; - int pdto[2]; - int pdfrom[2]; - char *com; - - - if (pipe(pdto) < 0) { - goto error1; - } - if (pipe(pdfrom) < 0) { - goto error2; - } - switch (pid = vfork()) { - case -1: - goto error3; - - case 0: - /* - * child: read from pdto[0], write into pdfrom[1] - */ - (void) close(0); - (void) dup(pdto[0]); - (void) close(1); - (void) dup(pdfrom[1]); - for (i = _rpc_dtablesize() - 1; i >= 3; i--) { - (void) close(i); - } - com = malloc((unsigned) strlen(command) + 6); - if (com == NULL) { - _exit(~0); - } - (void) sprintf(com, "exec %s", command); - execl(SHELL, basename(SHELL), "-c", com, NULL); - _exit(~0); - - default: - /* - * parent: write into pdto[1], read from pdfrom[0] - */ - *fto = fdopen(pdto[1], "w"); - (void) close(pdto[0]); - *ffrom = fdopen(pdfrom[0], "r"); - (void) close(pdfrom[1]); - break; - } - return (pid); - - /* - * error cleanup and return - */ -error3: - (void) close(pdfrom[0]); - (void) close(pdfrom[1]); -error2: - (void) close(pdto[0]); - (void) close(pdto[1]); -error1: - return (-1); -} - -static char * -basename(path) - char *path; -{ - char *p; - - p = rindex(path, '/'); - if (p == NULL) { - return (path); - } else { - return (p + 1); - } -} diff --git a/lib/librpc/secure_rpc/rpc/publickey.c b/lib/librpc/secure_rpc/rpc/publickey.c deleted file mode 100644 index d403b63eaf1d..000000000000 --- a/lib/librpc/secure_rpc/rpc/publickey.c +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)publickey.c 2.3 88/08/15 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - * @(#) from SUN 1.3 - */ - -/* - * Public key lookup routines - */ -#include -#include -#include -#include - - -extern char *index(); -extern char *strcpy(); - -static char PKMAP[] = "publickey.byname"; - -/* - * Get somebody's encrypted secret key from the database, using - * the given passwd to decrypt it. - */ -getsecretkey(netname, secretkey, passwd) - char *netname; - char *secretkey; - char *passwd; -{ - char *domain; - int len; - char *lookup; - int err; - char *p; - - - err = yp_get_default_domain(&domain); - if (err) { - return(0); - } - err = yp_match(domain, PKMAP, netname, strlen(netname), &lookup, &len); - if (err) { - return(0); - } - lookup[len] = 0; - p = index(lookup,':'); - if (p == NULL) { - free(lookup); - return(0); - } - p++; - if (!xdecrypt(p, passwd)) { - free(lookup); - return(0); - } - if (bcmp(p, p + HEXKEYBYTES, KEYCHECKSUMSIZE) != 0) { - secretkey[0] = 0; - free(lookup); - return(1); - } - p[HEXKEYBYTES] = 0; - (void) strcpy(secretkey, p); - free(lookup); - return(1); -} - - - -/* - * Get somebody's public key - */ -getpublickey(netname, publickey) - char *netname; - char *publickey; -{ - char *domain; - int len; - char *lookup; - int err; - char *p; - - err = yp_get_default_domain(&domain); - if (err) { - return(0); - } - err = yp_match(domain, PKMAP, netname, strlen(netname), &lookup, &len); - if (err) { - return(0); - } - p = index(lookup, ':'); - if (p == NULL) { - free(lookup); - return(0); - } - *p = 0; - (void) strcpy(publickey, lookup); - return(1); -} diff --git a/lib/librpc/secure_rpc/rpc/rtime.c b/lib/librpc/secure_rpc/rpc/rtime.c deleted file mode 100644 index 725995cb6855..000000000000 --- a/lib/librpc/secure_rpc/rpc/rtime.c +++ /dev/null @@ -1,141 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 SMI"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - - */ - -/* - * rtime - get time from remote machine - * - * gets time, obtaining value from host - * on the udp/time socket. Since timeserver returns - * with time of day in seconds since Jan 1, 1900, must - * subtract seconds before Jan 1, 1970 to get - * what unix uses. - */ -#include -#include -#include -#include -#include -#include - -#define NYEARS (1970 - 1900) -#define TOFFSET (60*60*24*(365*NYEARS + (NYEARS/4))) -extern errno; - -static void do_close(); - -rtime(addrp, timep, timeout) - struct sockaddr_in *addrp; - struct timeval *timep; - struct timeval *timeout; -{ - int s; - fd_set readfds; - int res; - unsigned long thetime; - struct sockaddr_in from; - int fromlen; - int type; - - if (timeout == NULL) { - type = SOCK_STREAM; - } else { - type = SOCK_DGRAM; - } - s = socket(AF_INET, type, 0); - if (s < 0) { - return(-1); - } - addrp->sin_family = AF_INET; - addrp->sin_port = htons(IPPORT_TIMESERVER); - if (type == SOCK_DGRAM) { - res = sendto(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)addrp, sizeof(*addrp)); - if (res < 0) { - do_close(s); - return(-1); - } - do { - FD_ZERO(&readfds); - FD_SET(s, &readfds); - res = select(_rpc_dtablesize(), &readfds, (int *)NULL, - (int *)NULL, timeout); - } while (res < 0 && errno == EINTR); - if (res <= 0) { - if (res == 0) { - errno = ETIMEDOUT; - } - do_close(s); - return(-1); - } - fromlen = sizeof(from); - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)&from, &fromlen); - do_close(s); - if (res < 0) { - return(-1); - } - } else { - if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) { - do_close(s); - return(-1); - } - res = read(s, (char *)&thetime, sizeof(thetime)); - do_close(s); - if (res < 0) { - return(-1); - } - } - if (res != sizeof(thetime)) { - errno = EIO; - return(-1); - } - thetime = ntohl(thetime); - timep->tv_sec = thetime - TOFFSET; - timep->tv_usec = 0; - return(0); -} - -static void -do_close(s) - int s; -{ - int save; - - save = errno; - (void) close(s); - errno = save; -} diff --git a/lib/librpc/secure_rpc/rpc/svc_auth.c b/lib/librpc/secure_rpc/rpc/svc_auth.c deleted file mode 100644 index 7ad47cad60a6..000000000000 --- a/lib/librpc/secure_rpc/rpc/svc_auth.c +++ /dev/null @@ -1,116 +0,0 @@ -/* @(#)svc_auth.c 2.4 88/08/15 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * svc_auth.c, Server-side rpc authenticator interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -/* - * svcauthsw is the bdevsw of server side authentication. - * - * Server side authenticators are called from authenticate by - * using the client auth struct flavor field to index into svcauthsw. - * The server auth flavors must implement a routine that looks - * like: - * - * enum auth_stat - * flavorx_auth(rqst, msg) - * register struct svc_req *rqst; - * register struct rpc_msg *msg; - * - */ - -enum auth_stat _svcauth_null(); /* no authentication */ -enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ -enum auth_stat _svcauth_short(); /* short hand unix style */ -enum auth_stat _svcauth_des(); /* des style */ - -static struct { - enum auth_stat (*authenticator)(); -} svcauthsw[] = { - _svcauth_null, /* AUTH_NULL */ - _svcauth_unix, /* AUTH_UNIX */ - _svcauth_short, /* AUTH_SHORT */ - _svcauth_des /* AUTH_DES */ -}; -#define AUTH_MAX 3 /* HIGHEST AUTH NUMBER */ - - -/* - * The call rpc message, msg has been obtained from the wire. The msg contains - * the raw form of credentials and verifiers. authenticate returns AUTH_OK - * if the msg is successfully authenticated. If AUTH_OK then the routine also - * does the following things: - * set rqst->rq_xprt->verf to the appropriate response verifier; - * sets rqst->rq_client_cred to the "cooked" form of the credentials. - * - * NB: rqst->rq_cxprt->verf must be pre-alloctaed; - * its length is set appropriately. - * - * The caller still owns and is responsible for msg->u.cmb.cred and - * msg->u.cmb.verf. The authentication system retains ownership of - * rqst->rq_client_cred, the cooked credentials. - * - * There is an assumption that any flavour less than AUTH_NULL is - * invalid. - */ -enum auth_stat -_authenticate(rqst, msg) - register struct svc_req *rqst; - struct rpc_msg *msg; -{ - register int cred_flavor; - - rqst->rq_cred = msg->rm_call.cb_cred; - rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; - rqst->rq_xprt->xp_verf.oa_length = 0; - cred_flavor = rqst->rq_cred.oa_flavor; - if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { - return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); - } - - return (AUTH_REJECTEDCRED); -} - -enum auth_stat -_svcauth_null(/*rqst, msg*/) - /*struct svc_req *rqst; - struct rpc_msg *msg;*/ -{ - - return (AUTH_OK); -} diff --git a/lib/librpc/secure_rpc/rpc/svcauth_des.c b/lib/librpc/secure_rpc/rpc/svcauth_des.c deleted file mode 100644 index 0129bef5aac3..000000000000 --- a/lib/librpc/secure_rpc/rpc/svcauth_des.c +++ /dev/null @@ -1,519 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)svcauth_des.c 2.3 89/07/11 4.0 RPCSRC; from 1.15 88/02/08 SMI"; -#endif - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * svcauth_des.c, server-side des authentication - * - * We insure for the service the following: - * (1) The timestamp microseconds do not exceed 1 million. - * (2) The timestamp plus the window is less than the current time. - * (3) The timestamp is not less than the one previously - * seen in the current session. - * - * It is up to the server to determine if the window size is - * too small . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define debug(msg) /*printf("svcauth_des: %s\n", msg)*/ - -extern char *strcpy(); - -#define USEC_PER_SEC ((u_long) 1000000L) -#define BEFORE(t1, t2) timercmp(t1, t2, <) - -/* - * LRU cache of conversation keys and some other useful items. - */ -#define AUTHDES_CACHESZ 64 -struct cache_entry { - des_block key; /* conversation key */ - char *rname; /* client's name */ - u_int window; /* credential lifetime window */ - struct timeval laststamp; /* detect replays of creds */ - char *localcred; /* generic local credential */ -}; -static struct cache_entry *authdes_cache/* [AUTHDES_CACHESZ] */; -static short *authdes_lru/* [AUTHDES_CACHESZ] */; - -static void cache_init(); /* initialize the cache */ -static short cache_spot(); /* find an entry in the cache */ -static void cache_ref(/*short sid*/); /* note that sid was ref'd */ - -static void invalidate(); /* invalidate entry in cache */ - -/* - * cache statistics - */ -struct { - u_long ncachehits; /* times cache hit, and is not replay */ - u_long ncachereplays; /* times cache hit, and is replay */ - u_long ncachemisses; /* times cache missed */ -} svcauthdes_stats; - -/* - * Service side authenticator for AUTH_DES - */ -enum auth_stat -_svcauth_des(rqst, msg) - register struct svc_req *rqst; - register struct rpc_msg *msg; -{ - - register long *ixdr; - des_block cryptbuf[2]; - register struct authdes_cred *cred; - struct authdes_verf verf; - int status; - register struct cache_entry *entry; - short sid; - des_block *sessionkey; - des_block ivec; - u_int window; - struct timeval timestamp; - u_long namelen; - struct area { - struct authdes_cred area_cred; - char area_netname[MAXNETNAMELEN+1]; - } *area; - - if (authdes_cache == NULL) { - cache_init(); - } - - area = (struct area *)rqst->rq_clntcred; - cred = (struct authdes_cred *)&area->area_cred; - - /* - * Get the credential - */ - ixdr = (long *)msg->rm_call.cb_cred.oa_base; - cred->adc_namekind = IXDR_GET_ENUM(ixdr, enum authdes_namekind); - switch (cred->adc_namekind) { - case ADN_FULLNAME: - namelen = IXDR_GET_U_LONG(ixdr); - if (namelen > MAXNETNAMELEN) { - return (AUTH_BADCRED); - } - cred->adc_fullname.name = area->area_netname; - bcopy((char *)ixdr, cred->adc_fullname.name, - (u_int)namelen); - cred->adc_fullname.name[namelen] = 0; - ixdr += (RNDUP(namelen) / BYTES_PER_XDR_UNIT); - cred->adc_fullname.key.key.high = (u_long)*ixdr++; - cred->adc_fullname.key.key.low = (u_long)*ixdr++; - cred->adc_fullname.window = (u_long)*ixdr++; - break; - case ADN_NICKNAME: - cred->adc_nickname = (u_long)*ixdr++; - break; - default: - return (AUTH_BADCRED); - } - - /* - * Get the verifier - */ - ixdr = (long *)msg->rm_call.cb_verf.oa_base; - verf.adv_xtimestamp.key.high = (u_long)*ixdr++; - verf.adv_xtimestamp.key.low = (u_long)*ixdr++; - verf.adv_int_u = (u_long)*ixdr++; - - - /* - * Get the conversation key - */ - if (cred->adc_namekind == ADN_FULLNAME) { - sessionkey = &cred->adc_fullname.key; - if (key_decryptsession(cred->adc_fullname.name, - sessionkey) < 0) { - debug("decryptsessionkey"); - return (AUTH_BADCRED); /* key not found */ - } - } else { /* ADN_NICKNAME */ - sid = (short)cred->adc_nickname; - if (sid >= AUTHDES_CACHESZ) { - debug("bad nickname"); - return (AUTH_BADCRED); /* garbled credential */ - } - sessionkey = &authdes_cache[sid].key; - } - - - /* - * Decrypt the timestamp - */ - cryptbuf[0] = verf.adv_xtimestamp; - if (cred->adc_namekind == ADN_FULLNAME) { - cryptbuf[1].key.high = cred->adc_fullname.window; - cryptbuf[1].key.low = verf.adv_winverf; - ivec.key.high = ivec.key.low = 0; - status = cbc_crypt((char *)sessionkey, (char *)cryptbuf, - 2*sizeof(des_block), DES_DECRYPT | DES_HW, - (char *)&ivec); - } else { - status = ecb_crypt((char *)sessionkey, (char *)cryptbuf, - sizeof(des_block), DES_DECRYPT | DES_HW); - } - if (DES_FAILED(status)) { - debug("decryption failure"); - return (AUTH_FAILED); /* system error */ - } - - /* - * XDR the decrypted timestamp - */ - ixdr = (long *)cryptbuf; - timestamp.tv_sec = IXDR_GET_LONG(ixdr); - timestamp.tv_usec = IXDR_GET_LONG(ixdr); - - /* - * Check for valid credentials and verifiers. - * They could be invalid because the key was flushed - * out of the cache, and so a new session should begin. - * Be sure and send AUTH_REJECTED{CRED, VERF} if this is the case. - */ - { - struct timeval current; - int nick; - int winverf; - - if (cred->adc_namekind == ADN_FULLNAME) { - window = IXDR_GET_U_LONG(ixdr); - winverf = IXDR_GET_U_LONG(ixdr); - if (winverf != window - 1) { - debug("window verifier mismatch"); - return (AUTH_BADCRED); /* garbled credential */ - } - sid = cache_spot(sessionkey, cred->adc_fullname.name, - ×tamp); - if (sid < 0) { - debug("replayed credential"); - return (AUTH_REJECTEDCRED); /* replay */ - } - nick = 0; - } else { /* ADN_NICKNAME */ - window = authdes_cache[sid].window; - nick = 1; - } - - if ((u_long)timestamp.tv_usec >= USEC_PER_SEC) { - debug("invalid usecs"); - /* cached out (bad key), or garbled verifier */ - return (nick ? AUTH_REJECTEDVERF : AUTH_BADVERF); - } - if (nick && BEFORE(×tamp, - &authdes_cache[sid].laststamp)) { - debug("timestamp before last seen"); - return (AUTH_REJECTEDVERF); /* replay */ - } - (void) gettimeofday(¤t, (struct timezone *)NULL); - current.tv_sec -= window; /* allow for expiration */ - if (!BEFORE(¤t, ×tamp)) { - debug("timestamp expired"); - /* replay, or garbled credential */ - return (nick ? AUTH_REJECTEDVERF : AUTH_BADCRED); - } - } - - /* - * Set up the reply verifier - */ - verf.adv_nickname = (u_long)sid; - - /* - * xdr the timestamp before encrypting - */ - ixdr = (long *)cryptbuf; - IXDR_PUT_LONG(ixdr, timestamp.tv_sec - 1); - IXDR_PUT_LONG(ixdr, timestamp.tv_usec); - - /* - * encrypt the timestamp - */ - status = ecb_crypt((char *)sessionkey, (char *)cryptbuf, - sizeof(des_block), DES_ENCRYPT | DES_HW); - if (DES_FAILED(status)) { - debug("encryption failure"); - return (AUTH_FAILED); /* system error */ - } - verf.adv_xtimestamp = cryptbuf[0]; - - /* - * Serialize the reply verifier, and update rqst - */ - ixdr = (long *)msg->rm_call.cb_verf.oa_base; - *ixdr++ = (long)verf.adv_xtimestamp.key.high; - *ixdr++ = (long)verf.adv_xtimestamp.key.low; - *ixdr++ = (long)verf.adv_int_u; - - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_DES; - rqst->rq_xprt->xp_verf.oa_base = msg->rm_call.cb_verf.oa_base; - rqst->rq_xprt->xp_verf.oa_length = - (char *)ixdr - msg->rm_call.cb_verf.oa_base; - - /* - * We succeeded, commit the data to the cache now and - * finish cooking the credential. - */ - entry = &authdes_cache[sid]; - entry->laststamp = timestamp; - cache_ref(sid); - if (cred->adc_namekind == ADN_FULLNAME) { - cred->adc_fullname.window = window; - cred->adc_nickname = (u_long)sid; /* save nickname */ - if (entry->rname != NULL) { - mem_free(entry->rname, strlen(entry->rname) + 1); - } - entry->rname = mem_alloc((u_int)strlen(cred->adc_fullname.name) - + 1); - if (entry->rname != NULL) { - (void) strcpy(entry->rname, cred->adc_fullname.name); - } else { - debug("out of memory"); - } - entry->key = *sessionkey; - entry->window = window; - invalidate(entry->localcred); /* mark any cached cred invalid */ - } else { /* ADN_NICKNAME */ - /* - * nicknames are cooked into fullnames - */ - cred->adc_namekind = ADN_FULLNAME; - cred->adc_fullname.name = entry->rname; - cred->adc_fullname.key = entry->key; - cred->adc_fullname.window = entry->window; - } - return (AUTH_OK); /* we made it!*/ -} - - -/* - * Initialize the cache - */ -static void -cache_init() -{ - register int i; - - authdes_cache = (struct cache_entry *) - mem_alloc(sizeof(struct cache_entry) * AUTHDES_CACHESZ); - bzero((char *)authdes_cache, - sizeof(struct cache_entry) * AUTHDES_CACHESZ); - - authdes_lru = (short *)mem_alloc(sizeof(short) * AUTHDES_CACHESZ); - /* - * Initialize the lru list - */ - for (i = 0; i < AUTHDES_CACHESZ; i++) { - authdes_lru[i] = i; - } -} - - -/* - * Find the lru victim - */ -static short -cache_victim() -{ - return (authdes_lru[AUTHDES_CACHESZ-1]); -} - -/* - * Note that sid was referenced - */ -static void -cache_ref(sid) - register short sid; -{ - register int i; - register short curr; - register short prev; - - prev = authdes_lru[0]; - authdes_lru[0] = sid; - for (i = 1; prev != sid; i++) { - curr = authdes_lru[i]; - authdes_lru[i] = prev; - prev = curr; - } -} - - -/* - * Find a spot in the cache for a credential containing - * the items given. Return -1 if a replay is detected, otherwise - * return the spot in the cache. - */ -static short -cache_spot(key, name, timestamp) - register des_block *key; - char *name; - struct timeval *timestamp; -{ - register struct cache_entry *cp; - register int i; - register u_long hi; - - hi = key->key.high; - for (cp = authdes_cache, i = 0; i < AUTHDES_CACHESZ; i++, cp++) { - if (cp->key.key.high == hi && - cp->key.key.low == key->key.low && - cp->rname != NULL && - bcmp(cp->rname, name, strlen(name) + 1) == 0) { - if (BEFORE(timestamp, &cp->laststamp)) { - svcauthdes_stats.ncachereplays++; - return (-1); /* replay */ - } - svcauthdes_stats.ncachehits++; - return (i); /* refresh */ - } - } - svcauthdes_stats.ncachemisses++; - return (cache_victim()); /* new credential */ -} - - -#if (defined(sun) || defined(vax)) -/* - * Local credential handling stuff. - * NOTE: bsd unix dependent. - * Other operating systems should put something else here. - */ -#define UNKNOWN -2 /* grouplen, if cached cred is unknown user */ -#define INVALID -1 /* grouplen, if cache entry is invalid */ - -struct bsdcred { - short uid; /* cached uid */ - short gid; /* cached gid */ - short grouplen; /* length of cached groups */ - short groups[NGROUPS]; /* cached groups */ -}; - -/* - * Map a des credential into a unix cred. - * We cache the credential here so the application does - * not have to make an rpc call every time to interpret - * the credential. - */ -authdes_getucred(adc, uid, gid, grouplen, groups) - struct authdes_cred *adc; - short *uid; - short *gid; - short *grouplen; - register int *groups; -{ - unsigned sid; - register int i; - int i_uid; - int i_gid; - int i_grouplen; - struct bsdcred *cred; - - sid = adc->adc_nickname; - if (sid >= AUTHDES_CACHESZ) { - debug("invalid nickname"); - return (0); - } - cred = (struct bsdcred *)authdes_cache[sid].localcred; - if (cred == NULL) { - cred = (struct bsdcred *)mem_alloc(sizeof(struct bsdcred)); - authdes_cache[sid].localcred = (char *)cred; - cred->grouplen = INVALID; - } - if (cred->grouplen == INVALID) { - /* - * not in cache: lookup - */ - if (!netname2user(adc->adc_fullname.name, &i_uid, &i_gid, - &i_grouplen, groups)) - { - debug("unknown netname"); - cred->grouplen = UNKNOWN; /* mark as lookup up, but not found */ - return (0); - } - debug("missed ucred cache"); - *uid = cred->uid = i_uid; - *gid = cred->gid = i_gid; - *grouplen = cred->grouplen = i_grouplen; - for (i = i_grouplen - 1; i >= 0; i--) { - cred->groups[i] = groups[i]; /* int to short */ - } - return (1); - } else if (cred->grouplen == UNKNOWN) { - /* - * Already lookup up, but no match found - */ - return (0); - } - - /* - * cached credentials - */ - *uid = cred->uid; - *gid = cred->gid; - *grouplen = cred->grouplen; - for (i = cred->grouplen - 1; i >= 0; i--) { - groups[i] = cred->groups[i]; /* short to int */ - } - return (1); -} - -static void -invalidate(cred) - char *cred; -{ - if (cred == NULL) { - return; - } - ((struct bsdcred *)cred)->grouplen = INVALID; -} -#endif - diff --git a/lib/librpc/secure_rpc/rpc/xcrypt.c b/lib/librpc/secure_rpc/rpc/xcrypt.c deleted file mode 100644 index 215fda651479..000000000000 --- a/lib/librpc/secure_rpc/rpc/xcrypt.c +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)xcrypt.c 2.2 88/08/10 4.0 RPCSRC"; -#endif -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Hex encryption/decryption and utility routines - * - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#include -#include - -extern char *malloc(); - -extern char hex[]; /* forward */ -static char hexval(); - -/* - * Encrypt a secret key given passwd - * The secret key is passed and returned in hex notation. - * Its length must be a multiple of 16 hex digits (64 bits). - */ -xencrypt(secret, passwd) - char *secret; - char *passwd; -{ - char key[8]; - char ivec[8]; - char *buf; - int err; - int len; - - len = strlen(secret) / 2; - buf = malloc((unsigned)len); - - hex2bin(len, secret, buf); - passwd2des(passwd, key); - bzero(ivec, 8); - - err = cbc_crypt(key, buf, len, DES_ENCRYPT | DES_HW, ivec); - if (DES_FAILED(err)) { - free(buf); - return (0); - } - bin2hex(len, (unsigned char *) buf, secret); - free(buf); - return (1); -} - -/* - * Decrypt secret key using passwd - * The secret key is passed and returned in hex notation. - * Once again, the length is a multiple of 16 hex digits - */ -xdecrypt(secret, passwd) - char *secret; - char *passwd; -{ - char key[8]; - char ivec[8]; - char *buf; - int err; - int len; - - len = strlen(secret) / 2; - buf = malloc((unsigned)len); - - hex2bin(len, secret, buf); - passwd2des(passwd, key); - bzero(ivec, 8); - - err = cbc_crypt(key, buf, len, DES_DECRYPT | DES_HW, ivec); - if (DES_FAILED(err)) { - free(buf); - return (0); - } - bin2hex(len, (unsigned char *) buf, secret); - free(buf); - return (1); -} - - -/* - * Turn password into DES key - */ -passwd2des(pw, key) - char *pw; - char *key; -{ - int i; - - bzero(key, 8); - for (i = 0; *pw; i = (i+1)%8) { - key[i] ^= *pw++ << 1; - } - des_setparity(key); -} - - - -/* - * Hex to binary conversion - */ -static -hex2bin(len, hexnum, binnum) - int len; - char *hexnum; - char *binnum; -{ - int i; - - for (i = 0; i < len; i++) { - *binnum++ = 16 * hexval(hexnum[2*i]) + hexval(hexnum[2*i+1]); - } -} - -/* - * Binary to hex conversion - */ -static -bin2hex(len, binnum, hexnum) - int len; - unsigned char *binnum; - char *hexnum; -{ - int i; - unsigned val; - - for (i = 0; i < len; i++) { - val = binnum[i]; - hexnum[i*2] = hex[val >> 4]; - hexnum[i*2+1] = hex[val & 0xf]; - } - hexnum[len*2] = 0; -} - -static char hex[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', -}; - -static char -hexval(c) - char c; -{ - if (c >= '0' && c <= '9') { - return (c - '0'); - } else if (c >= 'a' && c <= 'z') { - return (c - 'a' + 10); - } else if (c >= 'A' && c <= 'Z') { - return (c - 'A' + 10); - } else { - return (-1); - } -} diff --git a/lib/libtelnet/auth-proto.h b/lib/libtelnet/auth-proto.h deleted file mode 100644 index 06bba2b55c1d..000000000000 --- a/lib/libtelnet/auth-proto.h +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)auth-proto.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#if !defined(P) -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif -#endif - -#if defined(AUTHENTICATION) -Authenticator *findauthenticator P((int, int)); - -void auth_init P((char *, int)); -int auth_cmd P((int, char **)); -void auth_request P((void)); -void auth_send P((unsigned char *, int)); -void auth_send_retry P((void)); -void auth_is P((unsigned char *, int)); -void auth_reply P((unsigned char *, int)); -void auth_finished P((Authenticator *, int)); -int auth_wait P((char *)); -void auth_disable_name P((char *)); -void auth_gen_printsub P((unsigned char *, int, unsigned char *, int)); - -#ifdef KRB4 -int kerberos4_init P((Authenticator *, int)); -int kerberos4_send P((Authenticator *)); -void kerberos4_is P((Authenticator *, unsigned char *, int)); -void kerberos4_reply P((Authenticator *, unsigned char *, int)); -int kerberos4_status P((Authenticator *, char *, int)); -void kerberos4_printsub P((unsigned char *, int, unsigned char *, int)); -#endif - -#ifdef KRB5 -int kerberos5_init P((Authenticator *, int)); -int kerberos5_send P((Authenticator *)); -void kerberos5_is P((Authenticator *, unsigned char *, int)); -void kerberos5_reply P((Authenticator *, unsigned char *, int)); -int kerberos5_status P((Authenticator *, char *, int)); -void kerberos5_printsub P((unsigned char *, int, unsigned char *, int)); -#endif -#endif diff --git a/lib/libtelnet/auth.c b/lib/libtelnet/auth.c deleted file mode 100644 index 1eb198a895e9..000000000000 --- a/lib/libtelnet/auth.c +++ /dev/null @@ -1,658 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)auth.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - - -#if defined(AUTHENTICATION) -#include -#include -#include -#define AUTH_NAMES -#include -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -#include "encrypt.h" -#include "auth.h" -#include "misc-proto.h" -#include "auth-proto.h" - -#define typemask(x) (1<<((x)-1)) - -#ifdef KRB4_ENCPWD -extern krb4encpwd_init(); -extern krb4encpwd_send(); -extern krb4encpwd_is(); -extern krb4encpwd_reply(); -extern krb4encpwd_status(); -extern krb4encpwd_printsub(); -#endif - -#ifdef RSA_ENCPWD -extern rsaencpwd_init(); -extern rsaencpwd_send(); -extern rsaencpwd_is(); -extern rsaencpwd_reply(); -extern rsaencpwd_status(); -extern rsaencpwd_printsub(); -#endif - -int auth_debug_mode = 0; -static char *Name = "Noname"; -static int Server = 0; -static Authenticator *authenticated = 0; -static int authenticating = 0; -static int validuser = 0; -static unsigned char _auth_send_data[256]; -static unsigned char *auth_send_data; -static int auth_send_cnt = 0; - -/* - * Authentication types supported. Plese note that these are stored - * in priority order, i.e. try the first one first. - */ -Authenticator authenticators[] = { -#ifdef SPX - { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, - spx_init, - spx_send, - spx_is, - spx_reply, - spx_status, - spx_printsub }, - { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, - spx_init, - spx_send, - spx_is, - spx_reply, - spx_status, - spx_printsub }, -#endif -#ifdef KRB5 -# ifdef ENCRYPTION - { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, - kerberos5_init, - kerberos5_send, - kerberos5_is, - kerberos5_reply, - kerberos5_status, - kerberos5_printsub }, -# endif /* ENCRYPTION */ - { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, - kerberos5_init, - kerberos5_send, - kerberos5_is, - kerberos5_reply, - kerberos5_status, - kerberos5_printsub }, -#endif -#ifdef KRB4 -# ifdef ENCRYPTION - { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, - kerberos4_init, - kerberos4_send, - kerberos4_is, - kerberos4_reply, - kerberos4_status, - kerberos4_printsub }, -# endif /* ENCRYPTION */ - { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, - kerberos4_init, - kerberos4_send, - kerberos4_is, - kerberos4_reply, - kerberos4_status, - kerberos4_printsub }, -#endif -#ifdef KRB4_ENCPWD - { AUTHTYPE_KRB4_ENCPWD, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, - krb4encpwd_init, - krb4encpwd_send, - krb4encpwd_is, - krb4encpwd_reply, - krb4encpwd_status, - krb4encpwd_printsub }, -#endif -#ifdef RSA_ENCPWD - { AUTHTYPE_RSA_ENCPWD, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, - rsaencpwd_init, - rsaencpwd_send, - rsaencpwd_is, - rsaencpwd_reply, - rsaencpwd_status, - rsaencpwd_printsub }, -#endif - { 0, }, -}; - -static Authenticator NoAuth = { 0 }; - -static int i_support = 0; -static int i_wont_support = 0; - - Authenticator * -findauthenticator(type, way) - int type; - int way; -{ - Authenticator *ap = authenticators; - - while (ap->type && (ap->type != type || ap->way != way)) - ++ap; - return(ap->type ? ap : 0); -} - - void -auth_init(name, server) - char *name; - int server; -{ - Authenticator *ap = authenticators; - - Server = server; - Name = name; - - i_support = 0; - authenticated = 0; - authenticating = 0; - while (ap->type) { - if (!ap->init || (*ap->init)(ap, server)) { - i_support |= typemask(ap->type); - if (auth_debug_mode) - printf(">>>%s: I support auth type %d %d\r\n", - Name, - ap->type, ap->way); - } - ++ap; - } -} - - void -auth_disable_name(name) - char *name; -{ - int x; - for (x = 0; x < AUTHTYPE_CNT; ++x) { - if (!strcasecmp(name, AUTHTYPE_NAME(x))) { - i_wont_support |= typemask(x); - break; - } - } -} - - int -getauthmask(type, maskp) - char *type; - int *maskp; -{ - register int x; - - if (strcasecmp(type, AUTHTYPE_NAME(0))) { - *maskp = -1; - return(1); - } - - for (x = 1; x < AUTHTYPE_CNT; ++x) { - if (!strcasecmp(type, AUTHTYPE_NAME(x))) { - *maskp = typemask(x); - return(1); - } - } - return(0); -} - - int -auth_enable(type) - int type; -{ - return(auth_onoff(type, 1)); -} - - int -auth_disable(type) - int type; -{ - return(auth_onoff(type, 0)); -} - - int -auth_onoff(type, on) - char *type; - int on; -{ - int mask = -1; - Authenticator *ap; - - if (!strcasecmp(type, "?") || !strcasecmp(type, "help")) { - printf("auth %s 'type'\n", on ? "enable" : "disable"); - printf("Where 'type' is one of:\n"); - printf("\t%s\n", AUTHTYPE_NAME(0)); - for (ap = authenticators; ap->type; ap++) - printf("\t%s\n", AUTHTYPE_NAME(ap->type)); - return(0); - } - - if (!getauthmask(type, &mask)) { - printf("%s: invalid authentication type\n", type); - return(0); - } - mask = getauthmask(type, &mask); - if (on) - i_wont_support &= ~mask; - else - i_wont_support |= mask; - return(1); -} - - int -auth_togdebug(on) - int on; -{ - if (on < 0) - auth_debug_mode ^= 1; - else - auth_debug_mode = on; - printf("auth debugging %s\n", auth_debug_mode ? "enabled" : "disabled"); - return(1); -} - - int -auth_status() -{ - Authenticator *ap; - - if (i_wont_support == -1) - printf("Authentication disabled\n"); - else - printf("Authentication enabled\n"); - - for (ap = authenticators; ap->type; ap++) - printf("%s: %s\n", AUTHTYPE_NAME(ap->type), - (i_wont_support & typemask(ap->type)) ? - "disabled" : "enabled"); - return(1); -} - -/* - * This routine is called by the server to start authentication - * negotiation. - */ - void -auth_request() -{ - static unsigned char str_request[64] = { IAC, SB, - TELOPT_AUTHENTICATION, - TELQUAL_SEND, }; - Authenticator *ap = authenticators; - unsigned char *e = str_request + 4; - - if (!authenticating) { - authenticating = 1; - while (ap->type) { - if (i_support & ~i_wont_support & typemask(ap->type)) { - if (auth_debug_mode) { - printf(">>>%s: Sending type %d %d\r\n", - Name, ap->type, ap->way); - } - *e++ = ap->type; - *e++ = ap->way; - } - ++ap; - } - *e++ = IAC; - *e++ = SE; - net_write(str_request, e - str_request); - printsub('>', &str_request[2], e - str_request - 2); - } -} - -/* - * This is called when an AUTH SEND is received. - * It should never arrive on the server side (as only the server can - * send an AUTH SEND). - * You should probably respond to it if you can... - * - * If you want to respond to the types out of order (i.e. even - * if he sends LOGIN KERBEROS and you support both, you respond - * with KERBEROS instead of LOGIN (which is against what the - * protocol says)) you will have to hack this code... - */ - void -auth_send(data, cnt) - unsigned char *data; - int cnt; -{ - Authenticator *ap; - static unsigned char str_none[] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_IS, AUTHTYPE_NULL, 0, - IAC, SE }; - if (Server) { - if (auth_debug_mode) { - printf(">>>%s: auth_send called!\r\n", Name); - } - return; - } - - if (auth_debug_mode) { - printf(">>>%s: auth_send got:", Name); - printd(data, cnt); printf("\r\n"); - } - - /* - * Save the data, if it is new, so that we can continue looking - * at it if the authorization we try doesn't work - */ - if (data < _auth_send_data || - data > _auth_send_data + sizeof(_auth_send_data)) { - auth_send_cnt = cnt > sizeof(_auth_send_data) - ? sizeof(_auth_send_data) - : cnt; - bcopy((void *)data, (void *)_auth_send_data, auth_send_cnt); - auth_send_data = _auth_send_data; - } else { - /* - * This is probably a no-op, but we just make sure - */ - auth_send_data = data; - auth_send_cnt = cnt; - } - while ((auth_send_cnt -= 2) >= 0) { - if (auth_debug_mode) - printf(">>>%s: He supports %d\r\n", - Name, *auth_send_data); - if ((i_support & ~i_wont_support) & typemask(*auth_send_data)) { - ap = findauthenticator(auth_send_data[0], - auth_send_data[1]); - if (ap && ap->send) { - if (auth_debug_mode) - printf(">>>%s: Trying %d %d\r\n", - Name, auth_send_data[0], - auth_send_data[1]); - if ((*ap->send)(ap)) { - /* - * Okay, we found one we like - * and did it. - * we can go home now. - */ - if (auth_debug_mode) - printf(">>>%s: Using type %d\r\n", - Name, *auth_send_data); - auth_send_data += 2; - return; - } - } - /* else - * just continue on and look for the - * next one if we didn't do anything. - */ - } - auth_send_data += 2; - } - net_write(str_none, sizeof(str_none)); - printsub('>', &str_none[2], sizeof(str_none) - 2); - if (auth_debug_mode) - printf(">>>%s: Sent failure message\r\n", Name); - auth_finished(0, AUTH_REJECT); -#ifdef KANNAN - /* - * We requested strong authentication, however no mechanisms worked. - * Therefore, exit on client end. - */ - printf("Unable to securely authenticate user ... exit\n"); - exit(0); -#endif /* KANNAN */ -} - - void -auth_send_retry() -{ - /* - * if auth_send_cnt <= 0 then auth_send will end up rejecting - * the authentication and informing the other side of this. - */ - auth_send(auth_send_data, auth_send_cnt); -} - - void -auth_is(data, cnt) - unsigned char *data; - int cnt; -{ - Authenticator *ap; - - if (cnt < 2) - return; - - if (data[0] == AUTHTYPE_NULL) { - auth_finished(0, AUTH_REJECT); - return; - } - - if (ap = findauthenticator(data[0], data[1])) { - if (ap->is) - (*ap->is)(ap, data+2, cnt-2); - } else if (auth_debug_mode) - printf(">>>%s: Invalid authentication in IS: %d\r\n", - Name, *data); -} - - void -auth_reply(data, cnt) - unsigned char *data; - int cnt; -{ - Authenticator *ap; - - if (cnt < 2) - return; - - if (ap = findauthenticator(data[0], data[1])) { - if (ap->reply) - (*ap->reply)(ap, data+2, cnt-2); - } else if (auth_debug_mode) - printf(">>>%s: Invalid authentication in SEND: %d\r\n", - Name, *data); -} - - void -auth_name(data, cnt) - unsigned char *data; - int cnt; -{ - Authenticator *ap; - unsigned char savename[256]; - - if (cnt < 1) { - if (auth_debug_mode) - printf(">>>%s: Empty name in NAME\r\n", Name); - return; - } - if (cnt > sizeof(savename) - 1) { - if (auth_debug_mode) - printf(">>>%s: Name in NAME (%d) exceeds %d length\r\n", - Name, cnt, sizeof(savename)-1); - return; - } - bcopy((void *)data, (void *)savename, cnt); - savename[cnt] = '\0'; /* Null terminate */ - if (auth_debug_mode) - printf(">>>%s: Got NAME [%s]\r\n", Name, savename); - auth_encrypt_user(savename); -} - - int -auth_sendname(cp, len) - unsigned char *cp; - int len; -{ - static unsigned char str_request[256+6] - = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; - register unsigned char *e = str_request + 4; - register unsigned char *ee = &str_request[sizeof(str_request)-2]; - - while (--len >= 0) { - if ((*e++ = *cp++) == IAC) - *e++ = IAC; - if (e >= ee) - return(0); - } - *e++ = IAC; - *e++ = SE; - net_write(str_request, e - str_request); - printsub('>', &str_request[2], e - &str_request[2]); - return(1); -} - - void -auth_finished(ap, result) - Authenticator *ap; - int result; -{ - if (!(authenticated = ap)) - authenticated = &NoAuth; - validuser = result; -} - - /* ARGSUSED */ - static void -auth_intr(sig) - int sig; -{ - auth_finished(0, AUTH_REJECT); -} - - int -auth_wait(name) - char *name; -{ - if (auth_debug_mode) - printf(">>>%s: in auth_wait.\r\n", Name); - - if (Server && !authenticating) - return(0); - - (void) signal(SIGALRM, auth_intr); - alarm(30); - while (!authenticated) - if (telnet_spin()) - break; - alarm(0); - (void) signal(SIGALRM, SIG_DFL); - - /* - * Now check to see if the user is valid or not - */ - if (!authenticated || authenticated == &NoAuth) - return(AUTH_REJECT); - - if (validuser == AUTH_VALID) - validuser = AUTH_USER; - - if (authenticated->status) - validuser = (*authenticated->status)(authenticated, - name, validuser); - return(validuser); -} - - void -auth_debug(mode) - int mode; -{ - auth_debug_mode = mode; -} - - void -auth_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - Authenticator *ap; - - if ((ap = findauthenticator(data[1], data[2])) && ap->printsub) - (*ap->printsub)(data, cnt, buf, buflen); - else - auth_gen_printsub(data, cnt, buf, buflen); -} - - void -auth_gen_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - register unsigned char *cp; - unsigned char tbuf[16]; - - cnt -= 3; - data += 3; - buf[buflen-1] = '\0'; - buf[buflen-2] = '*'; - buflen -= 2; - for (; cnt > 0; cnt--, data++) { - sprintf((char *)tbuf, " %d", *data); - for (cp = tbuf; *cp && buflen > 0; --buflen) - *buf++ = *cp++; - if (buflen <= 0) - return; - } - *buf = '\0'; -} -#endif diff --git a/lib/libtelnet/auth.h b/lib/libtelnet/auth.h deleted file mode 100644 index 615e8a07b894..000000000000 --- a/lib/libtelnet/auth.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)auth.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#ifndef __AUTH__ -#define __AUTH__ - -#define AUTH_REJECT 0 /* Rejected */ -#define AUTH_UNKNOWN 1 /* We don't know who he is, but he's okay */ -#define AUTH_OTHER 2 /* We know him, but not his name */ -#define AUTH_USER 3 /* We know he name */ -#define AUTH_VALID 4 /* We know him, and he needs no password */ - -#if !defined(P) -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif -#endif - -typedef struct XauthP { - int type; - int way; - int (*init) P((struct XauthP *, int)); - int (*send) P((struct XauthP *)); - void (*is) P((struct XauthP *, unsigned char *, int)); - void (*reply) P((struct XauthP *, unsigned char *, int)); - int (*status) P((struct XauthP *, char *, int)); - void (*printsub) P((unsigned char *, int, unsigned char *, int)); -} Authenticator; - -#include "auth-proto.h" - -extern auth_debug_mode; -#endif diff --git a/lib/libtelnet/enc-proto.h b/lib/libtelnet/enc-proto.h deleted file mode 100644 index 2e30908f292d..000000000000 --- a/lib/libtelnet/enc-proto.h +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)enc-proto.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ -#if !defined(P) -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif -#endif - -#ifdef ENCRYPTION -void encrypt_init P((char *, int)); -Encryptions *findencryption P((int)); -void encrypt_send_supprt P((void)); -void encrypt_auto P((int)); -void decrypt_auto P((int)); -void encrypt_is P((unsigned char *, int)); -void encrypt_reply P((unsigned char *, int)); -void encrypt_start_input P((int)); -void encrypt_session_key P((Session_Key *, int)); -void encrypt_end_input P((void)); -void encrypt_start_output P((int)); -void encrypt_end_output P((void)); -void encrypt_send_request_start P((void)); -void encrypt_send_request_end P((void)); -void encrypt_send_end P((void)); -void encrypt_wait P((void)); -void encrypt_send_support P((void)); -void encrypt_send_keyid P((int, unsigned char *, int, int)); -int net_write P((unsigned char *, int)); - -#ifdef TELENTD -void encrypt_wait P((void)); -#else -int encrypt_cmd P((int, char **)); -void encrypt_display P((void)); -#endif - -void krbdes_encrypt P((unsigned char *, int)); -int krbdes_decrypt P((int)); -int krbdes_is P((unsigned char *, int)); -int krbdes_reply P((unsigned char *, int)); -void krbdes_init P((int)); -int krbdes_start P((int, int)); -void krbdes_session P((Session_Key *, int)); -void krbdes_printsub P((unsigned char *, int, unsigned char *, int)); - -void cfb64_encrypt P((unsigned char *, int)); -int cfb64_decrypt P((int)); -void cfb64_init P((int)); -int cfb64_start P((int, int)); -int cfb64_is P((unsigned char *, int)); -int cfb64_reply P((unsigned char *, int)); -void cfb64_session P((Session_Key *, int)); -int cfb64_keyid P((int, unsigned char *, int *)); -void cfb64_printsub P((unsigned char *, int, unsigned char *, int)); - -void ofb64_encrypt P((unsigned char *, int)); -int ofb64_decrypt P((int)); -void ofb64_init P((int)); -int ofb64_start P((int, int)); -int ofb64_is P((unsigned char *, int)); -int ofb64_reply P((unsigned char *, int)); -void ofb64_session P((Session_Key *, int)); -int ofb64_keyid P((int, unsigned char *, int *)); -void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); - -int des_new_random_key P((Block)); -void des_set_random_generator_seed P((Block)); -void des_key_sched P((Block, Schedule)); -void des_ecb_encrypt P((Block, Block, Schedule, int)); -int des_string_to_key P((char *, Block)); -#endif /* ENCRYPTION */ diff --git a/lib/libtelnet/enc_des.c b/lib/libtelnet/enc_des.c deleted file mode 100644 index 15e8521c1714..000000000000 --- a/lib/libtelnet/enc_des.c +++ /dev/null @@ -1,724 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)enc_des.c 8.2 (Berkeley) 12/15/93"; -#endif /* not lint */ - -#ifdef ENCRYPTION -# ifdef AUTHENTICATION -# ifdef DES_ENCRYPTION -#include -#include -#ifdef __STDC__ -#include -#endif - -#include "encrypt.h" -#include "key-proto.h" -#include "misc-proto.h" - -extern encrypt_debug_mode; - -#define CFB 0 -#define OFB 1 - -#define NO_SEND_IV 1 -#define NO_RECV_IV 2 -#define NO_KEYID 4 -#define IN_PROGRESS (NO_SEND_IV|NO_RECV_IV|NO_KEYID) -#define SUCCESS 0 -#define FAILED -1 - - -struct fb { - Block krbdes_key; - Schedule krbdes_sched; - Block temp_feed; - unsigned char fb_feed[64]; - int need_start; - int state[2]; - int keyid[2]; - int once; - struct stinfo { - Block str_output; - Block str_feed; - Block str_iv; - Block str_ikey; - Schedule str_sched; - int str_index; - int str_flagshift; - } streams[2]; -}; - -static struct fb fb[2]; - -struct keyidlist { - char *keyid; - int keyidlen; - char *key; - int keylen; - int flags; -} keyidlist [] = { - { "\0", 1, 0, 0, 0 }, /* default key of zero */ - { 0, 0, 0, 0, 0 } -}; - -#define KEYFLAG_MASK 03 - -#define KEYFLAG_NOINIT 00 -#define KEYFLAG_INIT 01 -#define KEYFLAG_OK 02 -#define KEYFLAG_BAD 03 - -#define KEYFLAG_SHIFT 2 - -#define SHIFT_VAL(a,b) (KEYFLAG_SHIFT*((a)+((b)*2))) - -#define FB64_IV 1 -#define FB64_IV_OK 2 -#define FB64_IV_BAD 3 - - -void fb64_stream_iv P((Block, struct stinfo *)); -void fb64_init P((struct fb *)); -static int fb64_start P((struct fb *, int, int)); -int fb64_is P((unsigned char *, int, struct fb *)); -int fb64_reply P((unsigned char *, int, struct fb *)); -static void fb64_session P((Session_Key *, int, struct fb *)); -void fb64_stream_key P((Block, struct stinfo *)); -int fb64_keyid P((int, unsigned char *, int *, struct fb *)); - - void -cfb64_init(server) - int server; -{ - fb64_init(&fb[CFB]); - fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64; - fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, CFB); - fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, CFB); -} - - void -ofb64_init(server) - int server; -{ - fb64_init(&fb[OFB]); - fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64; - fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, OFB); - fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, OFB); -} - - void -fb64_init(fbp) - register struct fb *fbp; -{ - bzero((void *)fbp, sizeof(*fbp)); - fbp->state[0] = fbp->state[1] = FAILED; - fbp->fb_feed[0] = IAC; - fbp->fb_feed[1] = SB; - fbp->fb_feed[2] = TELOPT_ENCRYPT; - fbp->fb_feed[3] = ENCRYPT_IS; -} - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - * 2: Not yet. Other things (like getting the key from - * Kerberos) have to happen before we can continue. - */ - int -cfb64_start(dir, server) - int dir; - int server; -{ - return(fb64_start(&fb[CFB], dir, server)); -} - int -ofb64_start(dir, server) - int dir; - int server; -{ - return(fb64_start(&fb[OFB], dir, server)); -} - - static int -fb64_start(fbp, dir, server) - struct fb *fbp; - int dir; - int server; -{ - Block b; - int x; - unsigned char *p; - register int state; - - switch (dir) { - case DIR_DECRYPT: - /* - * This is simply a request to have the other side - * start output (our input). He will negotiate an - * IV so we need not look for it. - */ - state = fbp->state[dir-1]; - if (state == FAILED) - state = IN_PROGRESS; - break; - - case DIR_ENCRYPT: - state = fbp->state[dir-1]; - if (state == FAILED) - state = IN_PROGRESS; - else if ((state & NO_SEND_IV) == 0) - break; - - if (!VALIDKEY(fbp->krbdes_key)) { - fbp->need_start = 1; - break; - } - state &= ~NO_SEND_IV; - state |= NO_RECV_IV; - if (encrypt_debug_mode) - printf("Creating new feed\r\n"); - /* - * Create a random feed and send it over. - */ - des_new_random_key(fbp->temp_feed); - des_ecb_encrypt(fbp->temp_feed, fbp->temp_feed, - fbp->krbdes_sched, 1); - p = fbp->fb_feed + 3; - *p++ = ENCRYPT_IS; - p++; - *p++ = FB64_IV; - for (x = 0; x < sizeof(Block); ++x) { - if ((*p++ = fbp->temp_feed[x]) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); - net_write(fbp->fb_feed, p - fbp->fb_feed); - break; - default: - return(FAILED); - } - return(fbp->state[dir-1] = state); -} - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - */ - int -cfb64_is(data, cnt) - unsigned char *data; - int cnt; -{ - return(fb64_is(data, cnt, &fb[CFB])); -} - int -ofb64_is(data, cnt) - unsigned char *data; - int cnt; -{ - return(fb64_is(data, cnt, &fb[OFB])); -} - - int -fb64_is(data, cnt, fbp) - unsigned char *data; - int cnt; - struct fb *fbp; -{ - int x; - unsigned char *p; - Block b; - register int state = fbp->state[DIR_DECRYPT-1]; - - if (cnt-- < 1) - goto failure; - - switch (*data++) { - case FB64_IV: - if (cnt != sizeof(Block)) { - if (encrypt_debug_mode) - printf("CFB64: initial vector failed on size\r\n"); - state = FAILED; - goto failure; - } - - if (encrypt_debug_mode) - printf("CFB64: initial vector received\r\n"); - - if (encrypt_debug_mode) - printf("Initializing Decrypt stream\r\n"); - - fb64_stream_iv((void *)data, &fbp->streams[DIR_DECRYPT-1]); - - p = fbp->fb_feed + 3; - *p++ = ENCRYPT_REPLY; - p++; - *p++ = FB64_IV_OK; - *p++ = IAC; - *p++ = SE; - printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); - net_write(fbp->fb_feed, p - fbp->fb_feed); - - state = fbp->state[DIR_DECRYPT-1] = IN_PROGRESS; - break; - - default: - if (encrypt_debug_mode) { - printf("Unknown option type: %d\r\n", *(data-1)); - printd(data, cnt); - printf("\r\n"); - } - /* FALL THROUGH */ - failure: - /* - * We failed. Send an FB64_IV_BAD option - * to the other side so it will know that - * things failed. - */ - p = fbp->fb_feed + 3; - *p++ = ENCRYPT_REPLY; - p++; - *p++ = FB64_IV_BAD; - *p++ = IAC; - *p++ = SE; - printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); - net_write(fbp->fb_feed, p - fbp->fb_feed); - - break; - } - return(fbp->state[DIR_DECRYPT-1] = state); -} - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - */ - int -cfb64_reply(data, cnt) - unsigned char *data; - int cnt; -{ - return(fb64_reply(data, cnt, &fb[CFB])); -} - int -ofb64_reply(data, cnt) - unsigned char *data; - int cnt; -{ - return(fb64_reply(data, cnt, &fb[OFB])); -} - - - int -fb64_reply(data, cnt, fbp) - unsigned char *data; - int cnt; - struct fb *fbp; -{ - int x; - unsigned char *p; - Block b; - register int state = fbp->state[DIR_ENCRYPT-1]; - - if (cnt-- < 1) - goto failure; - - switch (*data++) { - case FB64_IV_OK: - fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]); - if (state == FAILED) - state = IN_PROGRESS; - state &= ~NO_RECV_IV; - encrypt_send_keyid(DIR_ENCRYPT, (unsigned char *)"\0", 1, 1); - break; - - case FB64_IV_BAD: - bzero(fbp->temp_feed, sizeof(Block)); - fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]); - state = FAILED; - break; - - default: - if (encrypt_debug_mode) { - printf("Unknown option type: %d\r\n", data[-1]); - printd(data, cnt); - printf("\r\n"); - } - /* FALL THROUGH */ - failure: - state = FAILED; - break; - } - return(fbp->state[DIR_ENCRYPT-1] = state); -} - - void -cfb64_session(key, server) - Session_Key *key; - int server; -{ - fb64_session(key, server, &fb[CFB]); -} - - void -ofb64_session(key, server) - Session_Key *key; - int server; -{ - fb64_session(key, server, &fb[OFB]); -} - - static void -fb64_session(key, server, fbp) - Session_Key *key; - int server; - struct fb *fbp; -{ - - if (!key || key->type != SK_DES) { - if (encrypt_debug_mode) - printf("Can't set krbdes's session key (%d != %d)\r\n", - key ? key->type : -1, SK_DES); - return; - } - bcopy((void *)key->data, (void *)fbp->krbdes_key, sizeof(Block)); - - fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]); - fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); - - if (fbp->once == 0) { - des_set_random_generator_seed(fbp->krbdes_key); - fbp->once = 1; - } - des_key_sched(fbp->krbdes_key, fbp->krbdes_sched); - /* - * Now look to see if krbdes_start() was was waiting for - * the key to show up. If so, go ahead an call it now - * that we have the key. - */ - if (fbp->need_start) { - fbp->need_start = 0; - fb64_start(fbp, DIR_ENCRYPT, server); - } -} - -/* - * We only accept a keyid of 0. If we get a keyid of - * 0, then mark the state as SUCCESS. - */ - int -cfb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; -{ - return(fb64_keyid(dir, kp, lenp, &fb[CFB])); -} - - int -ofb64_keyid(dir, kp, lenp) - int dir, *lenp; - unsigned char *kp; -{ - return(fb64_keyid(dir, kp, lenp, &fb[OFB])); -} - - int -fb64_keyid(dir, kp, lenp, fbp) - int dir, *lenp; - unsigned char *kp; - struct fb *fbp; -{ - register int state = fbp->state[dir-1]; - - if (*lenp != 1 || (*kp != '\0')) { - *lenp = 0; - return(state); - } - - if (state == FAILED) - state = IN_PROGRESS; - - state &= ~NO_KEYID; - - return(fbp->state[dir-1] = state); -} - - void -fb64_printsub(data, cnt, buf, buflen, type) - unsigned char *data, *buf, *type; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - char *cp; - - buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ - buflen -= 1; - - switch(data[2]) { - case FB64_IV: - sprintf(lbuf, "%s_IV", type); - cp = lbuf; - goto common; - - case FB64_IV_OK: - sprintf(lbuf, "%s_IV_OK", type); - cp = lbuf; - goto common; - - case FB64_IV_BAD: - sprintf(lbuf, "%s_IV_BAD", type); - cp = lbuf; - goto common; - - default: - sprintf(lbuf, " %d (unknown)", data[2]); - cp = lbuf; - common: - for (; (buflen > 0) && (*buf = *cp++); buf++) - buflen--; - for (i = 3; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - for (cp = lbuf; (buflen > 0) && (*buf = *cp++); buf++) - buflen--; - } - break; - } -} - - void -cfb64_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - fb64_printsub(data, cnt, buf, buflen, "CFB64"); -} - - void -ofb64_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - fb64_printsub(data, cnt, buf, buflen, "OFB64"); -} - - void -fb64_stream_iv(seed, stp) - Block seed; - register struct stinfo *stp; -{ - - bcopy((void *)seed, (void *)stp->str_iv, sizeof(Block)); - bcopy((void *)seed, (void *)stp->str_output, sizeof(Block)); - - des_key_sched(stp->str_ikey, stp->str_sched); - - stp->str_index = sizeof(Block); -} - - void -fb64_stream_key(key, stp) - Block key; - register struct stinfo *stp; -{ - bcopy((void *)key, (void *)stp->str_ikey, sizeof(Block)); - des_key_sched(key, stp->str_sched); - - bcopy((void *)stp->str_iv, (void *)stp->str_output, sizeof(Block)); - - stp->str_index = sizeof(Block); -} - -/* - * DES 64 bit Cipher Feedback - * - * key --->+-----+ - * +->| DES |--+ - * | +-----+ | - * | v - * INPUT --(--------->(+)+---> DATA - * | | - * +-------------+ - * - * - * Given: - * iV: Initial vector, 64 bits (8 bytes) long. - * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt). - * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output. - * - * V0 = DES(iV, key) - * On = Dn ^ Vn - * V(n+1) = DES(On, key) - */ - - void -cfb64_encrypt(s, c) - register unsigned char *s; - int c; -{ - register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1]; - register int index; - - index = stp->str_index; - while (c-- > 0) { - if (index == sizeof(Block)) { - Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); - index = 0; - } - - /* On encryption, we store (feed ^ data) which is cypher */ - *s = stp->str_output[index] = (stp->str_feed[index] ^ *s); - s++; - index++; - } - stp->str_index = index; -} - - int -cfb64_decrypt(data) - int data; -{ - register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1]; - int index; - - if (data == -1) { - /* - * Back up one byte. It is assumed that we will - * never back up more than one byte. If we do, this - * may or may not work. - */ - if (stp->str_index) - --stp->str_index; - return(0); - } - - index = stp->str_index++; - if (index == sizeof(Block)) { - Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); - stp->str_index = 1; /* Next time will be 1 */ - index = 0; /* But now use 0 */ - } - - /* On decryption we store (data) which is cypher. */ - stp->str_output[index] = data; - return(data ^ stp->str_feed[index]); -} - -/* - * DES 64 bit Output Feedback - * - * key --->+-----+ - * +->| DES |--+ - * | +-----+ | - * +-----------+ - * v - * INPUT -------->(+) ----> DATA - * - * Given: - * iV: Initial vector, 64 bits (8 bytes) long. - * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt). - * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output. - * - * V0 = DES(iV, key) - * V(n+1) = DES(Vn, key) - * On = Dn ^ Vn - */ - void -ofb64_encrypt(s, c) - register unsigned char *s; - int c; -{ - register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1]; - register int index; - - index = stp->str_index; - while (c-- > 0) { - if (index == sizeof(Block)) { - Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); - index = 0; - } - *s++ ^= stp->str_feed[index]; - index++; - } - stp->str_index = index; -} - - int -ofb64_decrypt(data) - int data; -{ - register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1]; - int index; - - if (data == -1) { - /* - * Back up one byte. It is assumed that we will - * never back up more than one byte. If we do, this - * may or may not work. - */ - if (stp->str_index) - --stp->str_index; - return(0); - } - - index = stp->str_index++; - if (index == sizeof(Block)) { - Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); - stp->str_index = 1; /* Next time will be 1 */ - index = 0; /* But now use 0 */ - } - - return(data ^ stp->str_feed[index]); -} -# endif /* DES_ENCRYPTION */ -# endif /* AUTHENTICATION */ -#endif /* ENCRYPTION */ diff --git a/lib/libtelnet/encrypt.c b/lib/libtelnet/encrypt.c deleted file mode 100644 index 8662473f3256..000000000000 --- a/lib/libtelnet/encrypt.c +++ /dev/null @@ -1,999 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)encrypt.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#ifdef ENCRYPTION - -#define ENCRYPT_NAMES -#include - -#include "encrypt.h" -#include "misc.h" - -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -/* - * These functions pointers point to the current routines - * for encrypting and decrypting data. - */ -void (*encrypt_output) P((unsigned char *, int)); -int (*decrypt_input) P((int)); - -int encrypt_debug_mode = 0; -static int decrypt_mode = 0; -static int encrypt_mode = 0; -static int encrypt_verbose = 0; -static int autoencrypt = 0; -static int autodecrypt = 0; -static int havesessionkey = 0; -static int Server = 0; -static char *Name = "Noname"; - -#define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0) - -static long i_support_encrypt = typemask(ENCTYPE_DES_CFB64) - | typemask(ENCTYPE_DES_OFB64); -static long i_support_decrypt = typemask(ENCTYPE_DES_CFB64) - | typemask(ENCTYPE_DES_OFB64); -static long i_wont_support_encrypt = 0; -static long i_wont_support_decrypt = 0; -#define I_SUPPORT_ENCRYPT (i_support_encrypt & ~i_wont_support_encrypt) -#define I_SUPPORT_DECRYPT (i_support_decrypt & ~i_wont_support_decrypt) - -static long remote_supports_encrypt = 0; -static long remote_supports_decrypt = 0; - -static Encryptions encryptions[] = { -#ifdef DES_ENCRYPTION - { "DES_CFB64", ENCTYPE_DES_CFB64, - cfb64_encrypt, - cfb64_decrypt, - cfb64_init, - cfb64_start, - cfb64_is, - cfb64_reply, - cfb64_session, - cfb64_keyid, - cfb64_printsub }, - { "DES_OFB64", ENCTYPE_DES_OFB64, - ofb64_encrypt, - ofb64_decrypt, - ofb64_init, - ofb64_start, - ofb64_is, - ofb64_reply, - ofb64_session, - ofb64_keyid, - ofb64_printsub }, -#endif /* DES_ENCRYPTION */ - { 0, }, -}; - -static unsigned char str_send[64] = { IAC, SB, TELOPT_ENCRYPT, - ENCRYPT_SUPPORT }; -static unsigned char str_suplen = 0; -static unsigned char str_start[72] = { IAC, SB, TELOPT_ENCRYPT }; -static unsigned char str_end[] = { IAC, SB, TELOPT_ENCRYPT, 0, IAC, SE }; - - Encryptions * -findencryption(type) - int type; -{ - Encryptions *ep = encryptions; - - if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & typemask(type))) - return(0); - while (ep->type && ep->type != type) - ++ep; - return(ep->type ? ep : 0); -} - - Encryptions * -finddecryption(type) - int type; -{ - Encryptions *ep = encryptions; - - if (!(I_SUPPORT_DECRYPT & remote_supports_encrypt & typemask(type))) - return(0); - while (ep->type && ep->type != type) - ++ep; - return(ep->type ? ep : 0); -} - -#define MAXKEYLEN 64 - -static struct key_info { - unsigned char keyid[MAXKEYLEN]; - int keylen; - int dir; - int *modep; - Encryptions *(*getcrypt)(); -} ki[2] = { - { { 0 }, 0, DIR_ENCRYPT, &encrypt_mode, findencryption }, - { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption }, -}; - - void -encrypt_init(name, server) - char *name; - int server; -{ - Encryptions *ep = encryptions; - - Name = name; - Server = server; - i_support_encrypt = i_support_decrypt = 0; - remote_supports_encrypt = remote_supports_decrypt = 0; - encrypt_mode = 0; - decrypt_mode = 0; - encrypt_output = 0; - decrypt_input = 0; -#ifdef notdef - encrypt_verbose = !server; -#endif - - str_suplen = 4; - - while (ep->type) { - if (encrypt_debug_mode) - printf(">>>%s: I will support %s\r\n", - Name, ENCTYPE_NAME(ep->type)); - i_support_encrypt |= typemask(ep->type); - i_support_decrypt |= typemask(ep->type); - if ((i_wont_support_decrypt & typemask(ep->type)) == 0) - if ((str_send[str_suplen++] = ep->type) == IAC) - str_send[str_suplen++] = IAC; - if (ep->init) - (*ep->init)(Server); - ++ep; - } - str_send[str_suplen++] = IAC; - str_send[str_suplen++] = SE; -} - - void -encrypt_list_types() -{ - Encryptions *ep = encryptions; - - printf("Valid encryption types:\n"); - while (ep->type) { - printf("\t%s (%d)\r\n", ENCTYPE_NAME(ep->type), ep->type); - ++ep; - } -} - - int -EncryptEnable(type, mode) - char *type, *mode; -{ - if (isprefix(type, "help") || isprefix(type, "?")) { - printf("Usage: encrypt enable [input|output]\n"); - encrypt_list_types(); - return(0); - } - if (EncryptType(type, mode)) - return(EncryptStart(mode)); - return(0); -} - - int -EncryptDisable(type, mode) - char *type, *mode; -{ - register Encryptions *ep; - int ret = 0; - - if (isprefix(type, "help") || isprefix(type, "?")) { - printf("Usage: encrypt disable [input|output]\n"); - encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, - sizeof(Encryptions))) == 0) { - printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { - printf("Ambiguous type '%s'\n", type); - } else { - if ((mode == 0) || (isprefix(mode, "input") ? 1 : 0)) { - if (decrypt_mode == ep->type) - EncryptStopInput(); - i_wont_support_decrypt |= typemask(ep->type); - ret = 1; - } - if ((mode == 0) || (isprefix(mode, "output"))) { - if (encrypt_mode == ep->type) - EncryptStopOutput(); - i_wont_support_encrypt |= typemask(ep->type); - ret = 1; - } - if (ret == 0) - printf("%s: invalid encryption mode\n", mode); - } - return(ret); -} - - int -EncryptType(type, mode) - char *type; - char *mode; -{ - register Encryptions *ep; - int ret = 0; - - if (isprefix(type, "help") || isprefix(type, "?")) { - printf("Usage: encrypt type [input|output]\n"); - encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, - sizeof(Encryptions))) == 0) { - printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { - printf("Ambiguous type '%s'\n", type); - } else { - if ((mode == 0) || isprefix(mode, "input")) { - decrypt_mode = ep->type; - i_wont_support_decrypt &= ~typemask(ep->type); - ret = 1; - } - if ((mode == 0) || isprefix(mode, "output")) { - encrypt_mode = ep->type; - i_wont_support_encrypt &= ~typemask(ep->type); - ret = 1; - } - if (ret == 0) - printf("%s: invalid encryption mode\n", mode); - } - return(ret); -} - - int -EncryptStart(mode) - char *mode; -{ - register int ret = 0; - if (mode) { - if (isprefix(mode, "input")) - return(EncryptStartInput()); - if (isprefix(mode, "output")) - return(EncryptStartOutput()); - if (isprefix(mode, "help") || isprefix(mode, "?")) { - printf("Usage: encrypt start [input|output]\n"); - return(0); - } - printf("%s: invalid encryption mode 'encrypt start ?' for help\n", mode); - return(0); - } - ret += EncryptStartInput(); - ret += EncryptStartOutput(); - return(ret); -} - - int -EncryptStartInput() -{ - if (decrypt_mode) { - encrypt_send_request_start(); - return(1); - } - printf("No previous decryption mode, decryption not enabled\r\n"); - return(0); -} - - int -EncryptStartOutput() -{ - if (encrypt_mode) { - encrypt_start_output(encrypt_mode); - return(1); - } - printf("No previous encryption mode, encryption not enabled\r\n"); - return(0); -} - - int -EncryptStop(mode) - char *mode; -{ - int ret = 0; - if (mode) { - if (isprefix(mode, "input")) - return(EncryptStopInput()); - if (isprefix(mode, "output")) - return(EncryptStopOutput()); - if (isprefix(mode, "help") || isprefix(mode, "?")) { - printf("Usage: encrypt stop [input|output]\n"); - return(0); - } - printf("%s: invalid encryption mode 'encrypt stop ?' for help\n", mode); - return(0); - } - ret += EncryptStopInput(); - ret += EncryptStopOutput(); - return(ret); -} - - int -EncryptStopInput() -{ - encrypt_send_request_end(); - return(1); -} - - int -EncryptStopOutput() -{ - encrypt_send_end(); - return(1); -} - - void -encrypt_display() -{ - if (encrypt_output) - printf("Currently encrypting output with %s\r\n", - ENCTYPE_NAME(encrypt_mode)); - if (decrypt_input) - printf("Currently decrypting input with %s\r\n", - ENCTYPE_NAME(decrypt_mode)); -} - - int -EncryptStatus() -{ - if (encrypt_output) - printf("Currently encrypting output with %s\r\n", - ENCTYPE_NAME(encrypt_mode)); - else if (encrypt_mode) { - printf("Currently output is clear text.\r\n"); - printf("Last encryption mode was %s\r\n", - ENCTYPE_NAME(encrypt_mode)); - } - if (decrypt_input) { - printf("Currently decrypting input with %s\r\n", - ENCTYPE_NAME(decrypt_mode)); - } else if (decrypt_mode) { - printf("Currently input is clear text.\r\n"); - printf("Last decryption mode was %s\r\n", - ENCTYPE_NAME(decrypt_mode)); - } - return 1; -} - - void -encrypt_send_support() -{ - if (str_suplen) { - /* - * If the user has requested that decryption start - * immediatly, then send a "REQUEST START" before - * we negotiate the type. - */ - if (!Server && autodecrypt) - encrypt_send_request_start(); - net_write(str_send, str_suplen); - printsub('>', &str_send[2], str_suplen - 2); - str_suplen = 0; - } -} - - int -EncryptDebug(on) - int on; -{ - if (on < 0) - encrypt_debug_mode ^= 1; - else - encrypt_debug_mode = on; - printf("Encryption debugging %s\r\n", - encrypt_debug_mode ? "enabled" : "disabled"); - return(1); -} - - int -EncryptVerbose(on) - int on; -{ - if (on < 0) - encrypt_verbose ^= 1; - else - encrypt_verbose = on; - printf("Encryption %s verbose\r\n", - encrypt_verbose ? "is" : "is not"); - return(1); -} - - int -EncryptAutoEnc(on) - int on; -{ - encrypt_auto(on); - printf("Automatic encryption of output is %s\r\n", - autoencrypt ? "enabled" : "disabled"); - return(1); -} - - int -EncryptAutoDec(on) - int on; -{ - decrypt_auto(on); - printf("Automatic decryption of input is %s\r\n", - autodecrypt ? "enabled" : "disabled"); - return(1); -} - -/* - * Called when ENCRYPT SUPPORT is received. - */ - void -encrypt_support(typelist, cnt) - unsigned char *typelist; - int cnt; -{ - register int type, use_type = 0; - Encryptions *ep; - - /* - * Forget anything the other side has previously told us. - */ - remote_supports_decrypt = 0; - - while (cnt-- > 0) { - type = *typelist++; - if (encrypt_debug_mode) - printf(">>>%s: He is supporting %s (%d)\r\n", - Name, - ENCTYPE_NAME(type), type); - if ((type < ENCTYPE_CNT) && - (I_SUPPORT_ENCRYPT & typemask(type))) { - remote_supports_decrypt |= typemask(type); - if (use_type == 0) - use_type = type; - } - } - if (use_type) { - ep = findencryption(use_type); - if (!ep) - return; - type = ep->start ? (*ep->start)(DIR_ENCRYPT, Server) : 0; - if (encrypt_debug_mode) - printf(">>>%s: (*ep->start)() returned %d\r\n", - Name, type); - if (type < 0) - return; - encrypt_mode = use_type; - if (type == 0) - encrypt_start_output(use_type); - } -} - - void -encrypt_is(data, cnt) - unsigned char *data; - int cnt; -{ - Encryptions *ep; - register int type, ret; - - if (--cnt < 0) - return; - type = *data++; - if (type < ENCTYPE_CNT) - remote_supports_encrypt |= typemask(type); - if (!(ep = finddecryption(type))) { - if (encrypt_debug_mode) - printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n", - Name, - ENCTYPE_NAME_OK(type) - ? ENCTYPE_NAME(type) : "(unknown)", - type); - return; - } - if (!ep->is) { - if (encrypt_debug_mode) - printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n", - Name, - ENCTYPE_NAME_OK(type) - ? ENCTYPE_NAME(type) : "(unknown)", - type); - ret = 0; - } else { - ret = (*ep->is)(data, cnt); - if (encrypt_debug_mode) - printf("(*ep->is)(%x, %d) returned %s(%d)\n", data, cnt, - (ret < 0) ? "FAIL " : - (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); - } - if (ret < 0) { - autodecrypt = 0; - } else { - decrypt_mode = type; - if (ret == 0 && autodecrypt) - encrypt_send_request_start(); - } -} - - void -encrypt_reply(data, cnt) - unsigned char *data; - int cnt; -{ - Encryptions *ep; - register int ret, type; - - if (--cnt < 0) - return; - type = *data++; - if (!(ep = findencryption(type))) { - if (encrypt_debug_mode) - printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n", - Name, - ENCTYPE_NAME_OK(type) - ? ENCTYPE_NAME(type) : "(unknown)", - type); - return; - } - if (!ep->reply) { - if (encrypt_debug_mode) - printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n", - Name, - ENCTYPE_NAME_OK(type) - ? ENCTYPE_NAME(type) : "(unknown)", - type); - ret = 0; - } else { - ret = (*ep->reply)(data, cnt); - if (encrypt_debug_mode) - printf("(*ep->reply)(%x, %d) returned %s(%d)\n", - data, cnt, - (ret < 0) ? "FAIL " : - (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); - } - if (encrypt_debug_mode) - printf(">>>%s: encrypt_reply returned %d\n", Name, ret); - if (ret < 0) { - autoencrypt = 0; - } else { - encrypt_mode = type; - if (ret == 0 && autoencrypt) - encrypt_start_output(type); - } -} - -/* - * Called when a ENCRYPT START command is received. - */ - void -encrypt_start(data, cnt) - unsigned char *data; - int cnt; -{ - Encryptions *ep; - - if (!decrypt_mode) { - /* - * Something is wrong. We should not get a START - * command without having already picked our - * decryption scheme. Send a REQUEST-END to - * attempt to clear the channel... - */ - printf("%s: Warning, Cannot decrypt input stream!!!\r\n", Name); - encrypt_send_request_end(); - return; - } - - if (ep = finddecryption(decrypt_mode)) { - decrypt_input = ep->input; - if (encrypt_verbose) - printf("[ Input is now decrypted with type %s ]\r\n", - ENCTYPE_NAME(decrypt_mode)); - if (encrypt_debug_mode) - printf(">>>%s: Start to decrypt input with type %s\r\n", - Name, ENCTYPE_NAME(decrypt_mode)); - } else { - printf("%s: Warning, Cannot decrypt type %s (%d)!!!\r\n", - Name, - ENCTYPE_NAME_OK(decrypt_mode) - ? ENCTYPE_NAME(decrypt_mode) - : "(unknown)", - decrypt_mode); - encrypt_send_request_end(); - } -} - - void -encrypt_session_key(key, server) - Session_Key *key; - int server; -{ - Encryptions *ep = encryptions; - - havesessionkey = 1; - - while (ep->type) { - if (ep->session) - (*ep->session)(key, server); -#ifdef notdef - if (!encrypt_output && autoencrypt && !server) - encrypt_start_output(ep->type); - if (!decrypt_input && autodecrypt && !server) - encrypt_send_request_start(); -#endif - ++ep; - } -} - -/* - * Called when ENCRYPT END is received. - */ - void -encrypt_end() -{ - decrypt_input = 0; - if (encrypt_debug_mode) - printf(">>>%s: Input is back to clear text\r\n", Name); - if (encrypt_verbose) - printf("[ Input is now clear text ]\r\n"); -} - -/* - * Called when ENCRYPT REQUEST-END is received. - */ - void -encrypt_request_end() -{ - encrypt_send_end(); -} - -/* - * Called when ENCRYPT REQUEST-START is received. If we receive - * this before a type is picked, then that indicates that the - * other side wants us to start encrypting data as soon as we - * can. - */ - void -encrypt_request_start(data, cnt) - unsigned char *data; - int cnt; -{ - if (encrypt_mode == 0) { - if (Server) - autoencrypt = 1; - return; - } - encrypt_start_output(encrypt_mode); -} - -static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT }; - -encrypt_enc_keyid(keyid, len) - unsigned char *keyid; - int len; -{ - encrypt_keyid(&ki[1], keyid, len); -} - -encrypt_dec_keyid(keyid, len) - unsigned char *keyid; - int len; -{ - encrypt_keyid(&ki[0], keyid, len); -} - -encrypt_keyid(kp, keyid, len) - struct key_info *kp; - unsigned char *keyid; - int len; -{ - Encryptions *ep; - unsigned char *strp, *cp; - int dir = kp->dir; - register int ret = 0; - - if (!(ep = (*kp->getcrypt)(*kp->modep))) { - if (len == 0) - return; - kp->keylen = 0; - } else if (len == 0) { - /* - * Empty option, indicates a failure. - */ - if (kp->keylen == 0) - return; - kp->keylen = 0; - if (ep->keyid) - (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen); - - } else if ((len != kp->keylen) || (bcmp(keyid, kp->keyid, len) != 0)) { - /* - * Length or contents are different - */ - kp->keylen = len; - bcopy(keyid, kp->keyid, len); - if (ep->keyid) - (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen); - } else { - if (ep->keyid) - ret = (*ep->keyid)(dir, kp->keyid, &kp->keylen); - if ((ret == 0) && (dir == DIR_ENCRYPT) && autoencrypt) - encrypt_start_output(*kp->modep); - return; - } - - encrypt_send_keyid(dir, kp->keyid, kp->keylen, 0); -} - - void -encrypt_send_keyid(dir, keyid, keylen, saveit) - int dir; - unsigned char *keyid; - int keylen; - int saveit; -{ - unsigned char *strp; - - str_keyid[3] = (dir == DIR_ENCRYPT) - ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID; - if (saveit) { - struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1]; - bcopy(keyid, kp->keyid, keylen); - kp->keylen = keylen; - } - - for (strp = &str_keyid[4]; keylen > 0; --keylen) { - if ((*strp++ = *keyid++) == IAC) - *strp++ = IAC; - } - *strp++ = IAC; - *strp++ = SE; - net_write(str_keyid, strp - str_keyid); - printsub('>', &str_keyid[2], strp - str_keyid - 2); -} - - void -encrypt_auto(on) - int on; -{ - if (on < 0) - autoencrypt ^= 1; - else - autoencrypt = on ? 1 : 0; -} - - void -decrypt_auto(on) - int on; -{ - if (on < 0) - autodecrypt ^= 1; - else - autodecrypt = on ? 1 : 0; -} - - void -encrypt_start_output(type) - int type; -{ - Encryptions *ep; - register unsigned char *p; - register int i; - - if (!(ep = findencryption(type))) { - if (encrypt_debug_mode) { - printf(">>>%s: Can't encrypt with type %s (%d)\r\n", - Name, - ENCTYPE_NAME_OK(type) - ? ENCTYPE_NAME(type) : "(unknown)", - type); - } - return; - } - if (ep->start) { - i = (*ep->start)(DIR_ENCRYPT, Server); - if (encrypt_debug_mode) { - printf(">>>%s: Encrypt start: %s (%d) %s\r\n", - Name, - (i < 0) ? "failed" : - "initial negotiation in progress", - i, ENCTYPE_NAME(type)); - } - if (i) - return; - } - p = str_start + 3; - *p++ = ENCRYPT_START; - for (i = 0; i < ki[0].keylen; ++i) { - if ((*p++ = ki[0].keyid[i]) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - net_write(str_start, p - str_start); - net_encrypt(); - printsub('>', &str_start[2], p - &str_start[2]); - /* - * If we are already encrypting in some mode, then - * encrypt the ring (which includes our request) in - * the old mode, mark it all as "clear text" and then - * switch to the new mode. - */ - encrypt_output = ep->output; - encrypt_mode = type; - if (encrypt_debug_mode) - printf(">>>%s: Started to encrypt output with type %s\r\n", - Name, ENCTYPE_NAME(type)); - if (encrypt_verbose) - printf("[ Output is now encrypted with type %s ]\r\n", - ENCTYPE_NAME(type)); -} - - void -encrypt_send_end() -{ - if (!encrypt_output) - return; - - str_end[3] = ENCRYPT_END; - net_write(str_end, sizeof(str_end)); - net_encrypt(); - printsub('>', &str_end[2], sizeof(str_end) - 2); - /* - * Encrypt the output buffer now because it will not be done by - * netflush... - */ - encrypt_output = 0; - if (encrypt_debug_mode) - printf(">>>%s: Output is back to clear text\r\n", Name); - if (encrypt_verbose) - printf("[ Output is now clear text ]\r\n"); -} - - void -encrypt_send_request_start() -{ - register unsigned char *p; - register int i; - - p = &str_start[3]; - *p++ = ENCRYPT_REQSTART; - for (i = 0; i < ki[1].keylen; ++i) { - if ((*p++ = ki[1].keyid[i]) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - net_write(str_start, p - str_start); - printsub('>', &str_start[2], p - &str_start[2]); - if (encrypt_debug_mode) - printf(">>>%s: Request input to be encrypted\r\n", Name); -} - - void -encrypt_send_request_end() -{ - str_end[3] = ENCRYPT_REQEND; - net_write(str_end, sizeof(str_end)); - printsub('>', &str_end[2], sizeof(str_end) - 2); - - if (encrypt_debug_mode) - printf(">>>%s: Request input to be clear text\r\n", Name); -} - - void -encrypt_wait() -{ - register int encrypt, decrypt; - if (encrypt_debug_mode) - printf(">>>%s: in encrypt_wait\r\n", Name); - if (!havesessionkey || !(I_SUPPORT_ENCRYPT & remote_supports_decrypt)) - return; - while (autoencrypt && !encrypt_output) - if (telnet_spin()) - return; -} - - void -encrypt_debug(mode) - int mode; -{ - encrypt_debug_mode = mode; -} - - void -encrypt_gen_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char tbuf[16], *cp; - - cnt -= 2; - data += 2; - buf[buflen-1] = '\0'; - buf[buflen-2] = '*'; - buflen -= 2;; - for (; cnt > 0; cnt--, data++) { - sprintf(tbuf, " %d", *data); - for (cp = tbuf; *cp && buflen > 0; --buflen) - *buf++ = *cp++; - if (buflen <= 0) - return; - } - *buf = '\0'; -} - - void -encrypt_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - Encryptions *ep; - register int type = data[1]; - - for (ep = encryptions; ep->type && ep->type != type; ep++) - ; - - if (ep->printsub) - (*ep->printsub)(data, cnt, buf, buflen); - else - encrypt_gen_printsub(data, cnt, buf, buflen); -} -#endif /* ENCRYPTION */ diff --git a/lib/libtelnet/encrypt.h b/lib/libtelnet/encrypt.h deleted file mode 100644 index e0ae385f13f3..000000000000 --- a/lib/libtelnet/encrypt.h +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)encrypt.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#ifdef ENCRYPTION -# ifndef __ENCRYPTION__ -# define __ENCRYPTION__ - -#define DIR_DECRYPT 1 -#define DIR_ENCRYPT 2 - -typedef unsigned char Block[8]; -typedef unsigned char *BlockT; -typedef struct { Block _; } Schedule[16]; - -#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \ - key[4] | key[5] | key[6] | key[7]) - -#define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(Block))) - -typedef struct { - short type; - int length; - unsigned char *data; -} Session_Key; - -# if !defined(P) -# ifdef __STDC__ -# define P(x) x -# else -# define P(x) () -# endif -# endif - -typedef struct { - char *name; - int type; - void (*output) P((unsigned char *, int)); - int (*input) P((int)); - void (*init) P((int)); - int (*start) P((int, int)); - int (*is) P((unsigned char *, int)); - int (*reply) P((unsigned char *, int)); - void (*session) P((Session_Key *, int)); - int (*keyid) P((int, unsigned char *, int *)); - void (*printsub) P((unsigned char *, int, unsigned char *, int)); -} Encryptions; - -#define SK_DES 1 /* Matched Kerberos v5 KEYTYPE_DES */ - -#include "enc-proto.h" - -extern int encrypt_debug_mode; -extern int (*decrypt_input) P((int)); -extern void (*encrypt_output) P((unsigned char *, int)); -# endif /* __ENCRYPTION__ */ -#endif /* ENCRYPTION */ diff --git a/lib/libtelnet/kerberos.c b/lib/libtelnet/kerberos.c deleted file mode 100644 index aa9b4189c86c..000000000000 --- a/lib/libtelnet/kerberos.c +++ /dev/null @@ -1,554 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)kerberos.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#ifdef KRB4 -#include -#include -#include -#include /* BSD wont include this in krb.h, so we do it here */ -#include -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -#include "encrypt.h" -#include "auth.h" -#include "misc.h" - -int kerberos4_cksum P((unsigned char *, int)); -int krb_mk_req P((KTEXT, char *, char *, char *, u_long)); -int krb_rd_req P((KTEXT, char *, char *, u_long, AUTH_DAT *, char *)); -int krb_kntoln P((AUTH_DAT *, char *)); -int krb_get_cred P((char *, char *, char *, CREDENTIALS *)); -int krb_get_lrealm P((char *, int)); -int kuserok P((AUTH_DAT *, char *)); - -extern auth_debug_mode; - -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, - AUTHTYPE_KERBEROS_V4, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; - -#define KRB_AUTH 0 /* Authentication data follows */ -#define KRB_REJECT 1 /* Rejected (reason might follow) */ -#define KRB_ACCEPT 2 /* Accepted */ -#define KRB_CHALLENGE 3 /* Challenge for mutual auth. */ -#define KRB_RESPONSE 4 /* Response for mutual auth. */ - -#define KRB_SERVICE_NAME "rcmd" - -static KTEXT_ST auth; -static char name[ANAME_SZ]; -static AUTH_DAT adat = { 0 }; -#ifdef ENCRYPTION -static Block session_key = { 0 }; -static Schedule sched; -static Block challenge = { 0 }; -#endif /* ENCRYPTION */ - - static int -Data(ap, type, d, c) - Authenticator *ap; - int type; - void *d; - int c; -{ - unsigned char *p = str_data + 4; - unsigned char *cd = (unsigned char *)d; - - if (c == -1) - c = strlen((char *)cd); - - if (auth_debug_mode) { - printf("%s:%d: [%d] (%d)", - str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", - str_data[3], - type, c); - printd(d, c); - printf("\r\n"); - } - *p++ = ap->type; - *p++ = ap->way; - *p++ = type; - while (c-- > 0) { - if ((*p++ = *cd++) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - if (str_data[3] == TELQUAL_IS) - printsub('>', &str_data[2], p - (&str_data[2])); - return(net_write(str_data, p - str_data)); -} - - int -kerberos4_init(ap, server) - Authenticator *ap; - int server; -{ - FILE *fp; - - if (server) { - str_data[3] = TELQUAL_REPLY; - if ((fp = fopen(KEYFILE, "r")) == NULL) - return(0); - fclose(fp); - } else { - str_data[3] = TELQUAL_IS; - } - return(1); -} - -char dst_realm_buf[REALM_SZ], *dest_realm = NULL; -int dst_realm_sz = REALM_SZ; - - int -kerberos4_send(ap) - Authenticator *ap; -{ - KTEXT_ST auth; -#ifdef ENCRYPTION - Block enckey; -#endif /* ENCRYPTION */ - char instance[INST_SZ]; - char *realm; - char *krb_realmofhost(); - char *krb_get_phost(); - CREDENTIALS cred; - int r; - - printf("[ Trying KERBEROS4 ... ]\n"); - if (!UserNameRequested) { - if (auth_debug_mode) { - printf("Kerberos V4: no user name supplied\r\n"); - } - return(0); - } - - bzero(instance, sizeof(instance)); - - if (realm = krb_get_phost(RemoteHostName)) - strncpy(instance, realm, sizeof(instance)); - - instance[sizeof(instance)-1] = '\0'; - - realm = dest_realm ? dest_realm : krb_realmofhost(RemoteHostName); - - if (!realm) { - printf("Kerberos V4: no realm for %s\r\n", RemoteHostName); - return(0); - } - if (r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L)) { - printf("mk_req failed: %s\r\n", krb_err_txt[r]); - return(0); - } - if (r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred)) { - printf("get_cred failed: %s\r\n", krb_err_txt[r]); - return(0); - } - if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { - if (auth_debug_mode) - printf("Not enough room for user name\r\n"); - return(0); - } - if (auth_debug_mode) - printf("Sent %d bytes of authentication data\r\n", auth.length); - if (!Data(ap, KRB_AUTH, (void *)auth.dat, auth.length)) { - if (auth_debug_mode) - printf("Not enough room for authentication data\r\n"); - return(0); - } -#ifdef ENCRYPTION - /* - * If we are doing mutual authentication, get set up to send - * the challenge, and verify it when the response comes back. - */ - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - register int i; - - des_key_sched(cred.session, sched); - des_set_random_generator_seed(cred.session); - des_new_random_key(challenge); - des_ecb_encrypt(challenge, session_key, sched, 1); - /* - * Increment the challenge by 1, and encrypt it for - * later comparison. - */ - for (i = 7; i >= 0; --i) { - register int x; - x = (unsigned int)challenge[i] + 1; - challenge[i] = x; /* ignore overflow */ - if (x < 256) /* if no overflow, all done */ - break; - } - des_ecb_encrypt(challenge, challenge, sched, 1); - } -#endif /* ENCRYPTION */ - - if (auth_debug_mode) { - printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length)); - printd(auth.dat, auth.length); - printf("\r\n"); - printf("Sent Kerberos V4 credentials to server\r\n"); - } - return(1); -} - - void -kerberos4_is(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ -#ifdef ENCRYPTION - Session_Key skey; - Block datablock; -#endif /* ENCRYPTION */ - char realm[REALM_SZ]; - char instance[INST_SZ]; - int r; - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB_AUTH: - if (krb_get_lrealm(realm, 1) != KSUCCESS) { - Data(ap, KRB_REJECT, (void *)"No local V4 Realm.", -1); - auth_finished(ap, AUTH_REJECT); - if (auth_debug_mode) - printf("No local realm\r\n"); - return; - } - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); - if (auth_debug_mode) { - printf("Got %d bytes of authentication data\r\n", cnt); - printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length)); - printd(auth.dat, auth.length); - printf("\r\n"); - } - instance[0] = '*'; instance[1] = 0; - if (r = krb_rd_req(&auth, KRB_SERVICE_NAME, - instance, 0, &adat, "")) { - if (auth_debug_mode) - printf("Kerberos failed him as %s\r\n", name); - Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1); - auth_finished(ap, AUTH_REJECT); - return; - } -#ifdef ENCRYPTION - bcopy((void *)adat.session, (void *)session_key, sizeof(Block)); -#endif /* ENCRYPTION */ - krb_kntoln(&adat, name); - - if (UserNameRequested && !kuserok(&adat, UserNameRequested)) - Data(ap, KRB_ACCEPT, (void *)0, 0); - else - Data(ap, KRB_REJECT, - (void *)"user is not authorized", -1); - auth_finished(ap, AUTH_USER); - break; - - case KRB_CHALLENGE: -#ifndef ENCRYPTION - Data(ap, KRB_RESPONSE, (void *)0, 0); -#else /* ENCRYPTION */ - if (!VALIDKEY(session_key)) { - /* - * We don't have a valid session key, so just - * send back a response with an empty session - * key. - */ - Data(ap, KRB_RESPONSE, (void *)0, 0); - break; - } - - des_key_sched(session_key, sched); - bcopy((void *)data, (void *)datablock, sizeof(Block)); - /* - * Take the received encrypted challenge, and encrypt - * it again to get a unique session_key for the - * ENCRYPT option. - */ - des_ecb_encrypt(datablock, session_key, sched, 1); - skey.type = SK_DES; - skey.length = 8; - skey.data = session_key; - encrypt_session_key(&skey, 1); - /* - * Now decrypt the received encrypted challenge, - * increment by one, re-encrypt it and send it back. - */ - des_ecb_encrypt(datablock, challenge, sched, 0); - for (r = 7; r >= 0; r++) { - register int t; - t = (unsigned int)challenge[r] + 1; - challenge[r] = t; /* ignore overflow */ - if (t < 256) /* if no overflow, all done */ - break; - } - des_ecb_encrypt(challenge, challenge, sched, 1); - Data(ap, KRB_RESPONSE, (void *)challenge, sizeof(challenge)); -#endif /* ENCRYPTION */ - break; - - default: - if (auth_debug_mode) - printf("Unknown Kerberos option %d\r\n", data[-1]); - Data(ap, KRB_REJECT, 0, 0); - break; - } -} - - void -kerberos4_reply(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ -#ifdef ENCRYPTION - Session_Key skey; -#endif /* ENCRYPTION */ - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB_REJECT: - if (cnt > 0) { - printf("[ Kerberos V4 refuses authentication because %.*s ]\r\n", - cnt, data); - } else - printf("[ Kerberos V4 refuses authentication ]\r\n"); - auth_send_retry(); - return; - case KRB_ACCEPT: - printf("[ Kerberos V4 accepts you ]\n"); - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - /* - * Send over the encrypted challenge. - */ -#ifndef ENCRYPTION - Data(ap, KRB_CHALLENGE, (void *)0, 0); -#else /* ENCRYPTION */ - Data(ap, KRB_CHALLENGE, (void *)session_key, - sizeof(session_key)); - des_ecb_encrypt(session_key, session_key, sched, 1); - skey.type = SK_DES; - skey.length = 8; - skey.data = session_key; - encrypt_session_key(&skey, 0); -#endif /* ENCRYPTION */ - return; - } - auth_finished(ap, AUTH_USER); - return; - case KRB_RESPONSE: -#ifdef ENCRYPTION - /* - * Verify that the response to the challenge is correct. - */ - if ((cnt != sizeof(Block)) || - (0 != memcmp((void *)data, (void *)challenge, - sizeof(challenge)))) - { -#endif /* ENCRYPTION */ - printf("[ Kerberos V4 challenge failed!!! ]\r\n"); - auth_send_retry(); - return; -#ifdef ENCRYPTION - } - printf("[ Kerberos V4 challenge successful ]\r\n"); - auth_finished(ap, AUTH_USER); -#endif /* ENCRYPTION */ - break; - default: - if (auth_debug_mode) - printf("Unknown Kerberos option %d\r\n", data[-1]); - return; - } -} - - int -kerberos4_status(ap, name, level) - Authenticator *ap; - char *name; - int level; -{ - if (level < AUTH_USER) - return(level); - - if (UserNameRequested && !kuserok(&adat, UserNameRequested)) { - strcpy(name, UserNameRequested); - return(AUTH_VALID); - } else - return(AUTH_USER); -} - -#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} -#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} - - void -kerberos4_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - - buf[buflen-1] = '\0'; /* make sure its NULL terminated */ - buflen -= 1; - - switch(data[3]) { - case KRB_REJECT: /* Rejected (reason might follow) */ - strncpy((char *)buf, " REJECT ", buflen); - goto common; - - case KRB_ACCEPT: /* Accepted (name might follow) */ - strncpy((char *)buf, " ACCEPT ", buflen); - common: - BUMP(buf, buflen); - if (cnt <= 4) - break; - ADDC(buf, buflen, '"'); - for (i = 4; i < cnt; i++) - ADDC(buf, buflen, data[i]); - ADDC(buf, buflen, '"'); - ADDC(buf, buflen, '\0'); - break; - - case KRB_AUTH: /* Authentication data follows */ - strncpy((char *)buf, " AUTH", buflen); - goto common2; - - case KRB_CHALLENGE: - strncpy((char *)buf, " CHALLENGE", buflen); - goto common2; - - case KRB_RESPONSE: - strncpy((char *)buf, " RESPONSE", buflen); - goto common2; - - default: - sprintf(lbuf, " %d (unknown)", data[3]); - strncpy((char *)buf, lbuf, buflen); - common2: - BUMP(buf, buflen); - for (i = 4; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - strncpy((char *)buf, lbuf, buflen); - BUMP(buf, buflen); - } - break; - } -} - - int -kerberos4_cksum(d, n) - unsigned char *d; - int n; -{ - int ck = 0; - - /* - * A comment is probably needed here for those not - * well versed in the "C" language. Yes, this is - * supposed to be a "switch" with the body of the - * "switch" being a "while" statement. The whole - * purpose of the switch is to allow us to jump into - * the middle of the while() loop, and then not have - * to do any more switch()s. - * - * Some compilers will spit out a warning message - * about the loop not being entered at the top. - */ - switch (n&03) - while (n > 0) { - case 0: - ck ^= (int)*d++ << 24; - --n; - case 3: - ck ^= (int)*d++ << 16; - --n; - case 2: - ck ^= (int)*d++ << 8; - --n; - case 1: - ck ^= (int)*d++; - --n; - } - return(ck); -} -#endif - -#ifdef notdef - -prkey(msg, key) - char *msg; - unsigned char *key; -{ - register int i; - printf("%s:", msg); - for (i = 0; i < 8; i++) - printf(" %3d", key[i]); - printf("\r\n"); -} -#endif diff --git a/lib/libtelnet/kerberos5.c b/lib/libtelnet/kerberos5.c deleted file mode 100644 index d57fba3aa0f3..000000000000 --- a/lib/libtelnet/kerberos5.c +++ /dev/null @@ -1,762 +0,0 @@ -/* - * $Source: /mit/krb5/.cvsroot/src/appl/telnet/libtelnet/kerberos5.c,v $ - * $Author: tytso $ - * $Id: kerberos5.c,v 5.3 1993/09/01 03:00:12 tytso Exp $ - */ - -#if !defined(lint) && !defined(SABER) -static -#ifdef __STDC__ -const -#endif -char rcsid_kerberos5_c[] = "$Id: kerberos5.c,v 5.3 1993/09/01 03:00:12 tytso Exp $"; -#endif /* lint */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)kerberos5.c 8.2 (Berkeley) 12/15/93"; -#endif /* not lint */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - - -#ifdef KRB5 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* kerberos 5 include files (ext-proto.h) will get an appropriate stdlib.h - and string.h/strings.h */ - -#include "encrypt.h" -#include "auth.h" -#include "misc.h" - -extern auth_debug_mode; - -#ifdef FORWARD -int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */ - -/* These values need to be the same as those defined in telnet/main.c. */ -/* Either define them in both places, or put in some common header file. */ -#define OPTS_FORWARD_CREDS 0x00000002 -#define OPTS_FORWARDABLE_CREDS 0x00000001 - -void kerberos5_forward(); - -#endif /* FORWARD */ - -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, - AUTHTYPE_KERBEROS_V5, }; -/*static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, };*/ - -#define KRB_AUTH 0 /* Authentication data follows */ -#define KRB_REJECT 1 /* Rejected (reason might follow) */ -#define KRB_ACCEPT 2 /* Accepted */ -#define KRB_RESPONSE 3 /* Response for mutual auth. */ - -#ifdef FORWARD -#define KRB_FORWARD 4 /* Forwarded credentials follow */ -#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */ -#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */ -#endif /* FORWARD */ - -static krb5_data auth; - /* telnetd gets session key from here */ -static krb5_tkt_authent *authdat = NULL; -/* telnet matches the AP_REQ and AP_REP with this */ -static krb5_authenticator authenticator; - -/* some compilers can't hack void *, so we use the Kerberos krb5_pointer, - which is either void * or char *, depending on the compiler. */ - -#define Voidptr krb5_pointer - -Block session_key; - - static int -Data(ap, type, d, c) - Authenticator *ap; - int type; - Voidptr d; - int c; -{ - unsigned char *p = str_data + 4; - unsigned char *cd = (unsigned char *)d; - - if (c == -1) - c = strlen((char *)cd); - - if (auth_debug_mode) { - printf("%s:%d: [%d] (%d)", - str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", - str_data[3], - type, c); - printd(d, c); - printf("\r\n"); - } - *p++ = ap->type; - *p++ = ap->way; - *p++ = type; - while (c-- > 0) { - if ((*p++ = *cd++) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - if (str_data[3] == TELQUAL_IS) - printsub('>', &str_data[2], p - &str_data[2]); - return(net_write(str_data, p - str_data)); -} - - int -kerberos5_init(ap, server) - Authenticator *ap; - int server; -{ - if (server) - str_data[3] = TELQUAL_REPLY; - else - str_data[3] = TELQUAL_IS; - krb5_init_ets(); - return(1); -} - - int -kerberos5_send(ap) - Authenticator *ap; -{ - char **realms; - char *name; - char *p1, *p2; - krb5_checksum ksum; - krb5_octet sum[CRC32_CKSUM_LENGTH]; - krb5_principal server; - krb5_error_code r; - krb5_ccache ccache; - krb5_creds creds; /* telnet gets session key from here */ - extern krb5_flags krb5_kdc_default_options; - int ap_opts; - -#ifdef ENCRYPTION - krb5_keyblock *newkey = 0; -#endif /* ENCRYPTION */ - - ksum.checksum_type = CKSUMTYPE_CRC32; - ksum.contents = sum; - ksum.length = sizeof(sum); - bzero((Voidptr )sum, sizeof(sum)); - - if (!UserNameRequested) { - if (auth_debug_mode) { - printf("Kerberos V5: no user name supplied\r\n"); - } - return(0); - } - - if (r = krb5_cc_default(&ccache)) { - if (auth_debug_mode) { - printf("Kerberos V5: could not get default ccache\r\n"); - } - return(0); - } - - if ((name = malloc(strlen(RemoteHostName)+1)) == NULL) { - if (auth_debug_mode) - printf("Out of memory for hostname in Kerberos V5\r\n"); - return(0); - } - - if (r = krb5_get_host_realm(RemoteHostName, &realms)) { - if (auth_debug_mode) - printf("Kerberos V5: no realm for %s\r\n", RemoteHostName); - free(name); - return(0); - } - - p1 = RemoteHostName; - p2 = name; - - while (*p2 = *p1++) { - if (isupper(*p2)) - *p2 |= 040; - ++p2; - } - - if (r = krb5_build_principal_ext(&server, - strlen(realms[0]), realms[0], - 4, "host", - p2 - name, name, - 0)) { - if (auth_debug_mode) { - printf("Kerberos V5: failure setting up principal (%s)\r\n", - error_message(r)); - } - free(name); - krb5_free_host_realm(realms); - return(0); - } - - - bzero((char *)&creds, sizeof(creds)); - creds.server = server; - - if (r = krb5_cc_get_principal(ccache, &creds.client)) { - if (auth_debug_mode) { - printf("Kerberos V5: failure on principal (%s)\r\n", - error_message(r)); - } - free(name); - krb5_free_principal(server); - krb5_free_host_realm(realms); - return(0); - } - - if (r = krb5_get_credentials(krb5_kdc_default_options, ccache, &creds)) { - if (auth_debug_mode) { - printf("Kerberos V5: failure on credentials(%d)\r\n",r); - } - free(name); - krb5_free_host_realm(realms); - krb5_free_principal(server); - return(0); - } - - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) - ap_opts = AP_OPTS_MUTUAL_REQUIRED; - else - ap_opts = 0; - - r = krb5_mk_req_extended(ap_opts, &ksum, krb5_kdc_default_options, 0, -#ifdef ENCRYPTION - &newkey, -#else /* ENCRYPTION */ - 0, -#endif /* ENCRYPTION */ - ccache, &creds, &authenticator, &auth); - /* don't let the key get freed if we clean up the authenticator */ - authenticator.subkey = 0; - - free(name); - krb5_free_host_realm(realms); - krb5_free_principal(server); -#ifdef ENCRYPTION - if (newkey) { - /* keep the key in our private storage, but don't use it - yet---see kerberos5_reply() below */ - if (newkey->keytype != KEYTYPE_DES) { - if (creds.keyblock.keytype == KEYTYPE_DES) - /* use the session key in credentials instead */ - memcpy((char *)session_key, - (char *)creds.keyblock.contents, sizeof(Block)); - else - /* XXX ? */; - } else { - memcpy((char *)session_key, (char *)newkey->contents, - sizeof(Block)); - } - krb5_free_keyblock(newkey); - } -#endif /* ENCRYPTION */ - if (r) { - if (auth_debug_mode) { - printf("Kerberos V5: mk_req failed (%s)\r\n", - error_message(r)); - } - return(0); - } - - if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { - if (auth_debug_mode) - printf("Not enough room for user name\r\n"); - return(0); - } - if (!Data(ap, KRB_AUTH, auth.data, auth.length)) { - if (auth_debug_mode) - printf("Not enough room for authentication data\r\n"); - return(0); - } - if (auth_debug_mode) { - printf("Sent Kerberos V5 credentials to server\r\n"); - } - return(1); -} - - void -kerberos5_is(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - int r; - struct hostent *hp; - char *p1, *p2; - static char *realm = NULL; - krb5_principal server; - krb5_ap_rep_enc_part reply; - krb5_data outbuf; -#ifdef ENCRYPTION - Session_Key skey; -#endif /* ENCRYPTION */ - char *name; - char *getenv(); - krb5_data inbuf; - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB_AUTH: - auth.data = (char *)data; - auth.length = cnt; - - if (!(hp = gethostbyname(LocalHostName))) { - if (auth_debug_mode) - printf("Cannot resolve local host name\r\n"); - Data(ap, KRB_REJECT, "Unknown local hostname.", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - - if (!realm && (krb5_get_default_realm(&realm))) { - if (auth_debug_mode) - printf("Could not get default realm\r\n"); - Data(ap, KRB_REJECT, "Could not get default realm.", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - - if ((name = malloc(strlen(hp->h_name)+1)) == NULL) { - if (auth_debug_mode) - printf("Out of memory for hostname in Kerberos V5\r\n"); - Data(ap, KRB_REJECT, "Out of memory.", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - - p1 = hp->h_name; - p2 = name; - - while (*p2 = *p1++) { - if (isupper(*p2)) - *p2 |= 040; - ++p2; - } - - if (authdat) - krb5_free_tkt_authent(authdat); - - r = krb5_build_principal_ext(&server, - strlen(realm), realm, - 4, "host", - p2 - name, name, - 0); - if (!r) { - r = krb5_rd_req_simple(&auth, server, 0, &authdat); - krb5_free_principal(server); - } - if (r) { - char errbuf[128]; - - errout: - authdat = 0; - (void) strcpy(errbuf, "Read req failed: "); - (void) strcat(errbuf, error_message(r)); - Data(ap, KRB_REJECT, errbuf, -1); - if (auth_debug_mode) - printf("%s\r\n", errbuf); - return; - } - free(name); - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - /* do ap_rep stuff here */ - reply.ctime = authdat->authenticator->ctime; - reply.cusec = authdat->authenticator->cusec; - reply.subkey = 0; /* use the one he gave us, so don't - need to return one here */ - reply.seq_number = 0; /* we don't do seq #'s. */ - - if (r = krb5_mk_rep(&reply, - authdat->authenticator->subkey ? - authdat->authenticator->subkey : - authdat->ticket->enc_part2->session, - &outbuf)) { - goto errout; - } - Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length); - } - if (krb5_unparse_name(authdat->ticket->enc_part2 ->client, - &name)) - name = 0; - Data(ap, KRB_ACCEPT, name, name ? -1 : 0); - if (auth_debug_mode) { - printf("Kerberos5 identifies him as ``%s''\r\n", - name ? name : ""); - } - auth_finished(ap, AUTH_USER); - - free(name); - if (authdat->authenticator->subkey && - authdat->authenticator->subkey->keytype == KEYTYPE_DES) { - bcopy((Voidptr )authdat->authenticator->subkey->contents, - (Voidptr )session_key, sizeof(Block)); - } else if (authdat->ticket->enc_part2->session->keytype == - KEYTYPE_DES) { - bcopy((Voidptr )authdat->ticket->enc_part2->session->contents, - (Voidptr )session_key, sizeof(Block)); - } else - break; - -#ifdef ENCRYPTION - skey.type = SK_DES; - skey.length = 8; - skey.data = session_key; - encrypt_session_key(&skey, 1); -#endif /* ENCRYPTION */ - break; -#ifdef FORWARD - case KRB_FORWARD: - inbuf.data = (char *)data; - inbuf.length = cnt; - if (r = rd_and_store_for_creds(&inbuf, authdat->ticket, - UserNameRequested)) { - char errbuf[128]; - - (void) strcpy(errbuf, "Read forwarded creds failed: "); - (void) strcat(errbuf, error_message(r)); - Data(ap, KRB_FORWARD_REJECT, errbuf, -1); - if (auth_debug_mode) - printf("Could not read forwarded credentials\r\n"); - } - else - Data(ap, KRB_FORWARD_ACCEPT, 0, 0); - if (auth_debug_mode) - printf("Forwarded credentials obtained\r\n"); - break; -#endif /* FORWARD */ - default: - if (auth_debug_mode) - printf("Unknown Kerberos option %d\r\n", data[-1]); - Data(ap, KRB_REJECT, 0, 0); - break; - } -} - - void -kerberos5_reply(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - static int mutual_complete = 0; - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB_REJECT: - if (cnt > 0) { - printf("[ Kerberos V5 refuses authentication because %.*s ]\r\n", - cnt, data); - } else - printf("[ Kerberos V5 refuses authentication ]\r\n"); - auth_send_retry(); - return; - case KRB_ACCEPT: - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL && - !mutual_complete) { - printf("[ Kerberos V5 accepted you, but didn't provide mutual authentication! ]\n"); - auth_send_retry(); - return; - } - if (cnt) - printf("[ Kerberos V5 accepts you as ``%.*s'' ]\n", cnt, data); - else - printf("[ Kerberos V5 accepts you ]\n"); - auth_finished(ap, AUTH_USER); -#ifdef FORWARD - if (forward_flags & OPTS_FORWARD_CREDS) - kerberos5_forward(ap); -#endif /* FORWARD */ - break; - case KRB_RESPONSE: - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - /* the rest of the reply should contain a krb_ap_rep */ - krb5_ap_rep_enc_part *reply; - krb5_data inbuf; - krb5_error_code r; - krb5_keyblock tmpkey; - - inbuf.length = cnt; - inbuf.data = (char *)data; - - tmpkey.keytype = KEYTYPE_DES; - tmpkey.contents = session_key; - tmpkey.length = sizeof(Block); - - if (r = krb5_rd_rep(&inbuf, &tmpkey, &reply)) { - printf("[ Mutual authentication failed: %s ]\n", - error_message(r)); - auth_send_retry(); - return; - } - if (reply->ctime != authenticator.ctime || - reply->cusec != authenticator.cusec) { - printf("[ Mutual authentication failed (mismatched KRB_AP_REP) ]\n"); - auth_send_retry(); - return; - } - krb5_free_ap_rep_enc_part(reply); -#ifdef ENCRYPTION - skey.type = SK_DES; - skey.length = 8; - skey.data = session_key; - encrypt_session_key(&skey, 0); -#endif /* ENCRYPTION */ - mutual_complete = 1; - } - return; -#ifdef FORWARD - case KRB_FORWARD_ACCEPT: - printf("[ Kerberos V5 accepted forwarded credentials ]\n"); - return; - case KRB_FORWARD_REJECT: - printf("[ Kerberos V5 refuses forwarded credentials because %.*s ]\r\n", - cnt, data); - return; -#endif /* FORWARD */ - default: - if (auth_debug_mode) - printf("Unknown Kerberos option %d\r\n", data[-1]); - return; - } -} - - int -kerberos5_status(ap, name, level) - Authenticator *ap; - char *name; - int level; -{ - if (level < AUTH_USER) - return(level); - - if (UserNameRequested && - krb5_kuserok(authdat->ticket->enc_part2->client, UserNameRequested)) - { - strcpy(name, UserNameRequested); - return(AUTH_VALID); - } else - return(AUTH_USER); -} - -#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} -#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} - - void -kerberos5_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - - buf[buflen-1] = '\0'; /* make sure its NULL terminated */ - buflen -= 1; - - switch(data[3]) { - case KRB_REJECT: /* Rejected (reason might follow) */ - strncpy((char *)buf, " REJECT ", buflen); - goto common; - - case KRB_ACCEPT: /* Accepted (name might follow) */ - strncpy((char *)buf, " ACCEPT ", buflen); - common: - BUMP(buf, buflen); - if (cnt <= 4) - break; - ADDC(buf, buflen, '"'); - for (i = 4; i < cnt; i++) - ADDC(buf, buflen, data[i]); - ADDC(buf, buflen, '"'); - ADDC(buf, buflen, '\0'); - break; - - - case KRB_AUTH: /* Authentication data follows */ - strncpy((char *)buf, " AUTH", buflen); - goto common2; - - case KRB_RESPONSE: - strncpy((char *)buf, " RESPONSE", buflen); - goto common2; - -#ifdef FORWARD - case KRB_FORWARD: /* Forwarded credentials follow */ - strncpy((char *)buf, " FORWARD", buflen); - goto common2; - - case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */ - strncpy((char *)buf, " FORWARD_ACCEPT", buflen); - goto common2; - - case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */ - /* (reason might follow) */ - strncpy((char *)buf, " FORWARD_REJECT", buflen); - goto common2; -#endif /* FORWARD */ - - default: - sprintf(lbuf, " %d (unknown)", data[3]); - strncpy((char *)buf, lbuf, buflen); - common2: - BUMP(buf, buflen); - for (i = 4; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - strncpy((char *)buf, lbuf, buflen); - BUMP(buf, buflen); - } - break; - } -} - -#ifdef FORWARD - void -kerberos5_forward(ap) - Authenticator *ap; -{ - struct hostent *hp; - krb5_creds *local_creds; - krb5_error_code r; - krb5_data forw_creds; - extern krb5_cksumtype krb5_kdc_req_sumtype; - krb5_ccache ccache; - int i; - - if (!(local_creds = (krb5_creds *) - calloc(1, sizeof(*local_creds)))) { - if (auth_debug_mode) - printf("Kerberos V5: could not allocate memory for credentials\r\n"); - return; - } - - if (r = krb5_sname_to_principal(RemoteHostName, "host", 1, - &local_creds->server)) { - if (auth_debug_mode) - printf("Kerberos V5: could not build server name - %s\r\n", - error_message(r)); - krb5_free_creds(local_creds); - return; - } - - if (r = krb5_cc_default(&ccache)) { - if (auth_debug_mode) - printf("Kerberos V5: could not get default ccache - %s\r\n", - error_message(r)); - krb5_free_creds(local_creds); - return; - } - - if (r = krb5_cc_get_principal(ccache, &local_creds->client)) { - if (auth_debug_mode) - printf("Kerberos V5: could not get default principal - %s\r\n", - error_message(r)); - krb5_free_creds(local_creds); - return; - } - - /* Get ticket from credentials cache */ - if (r = krb5_get_credentials(KRB5_GC_CACHED, ccache, local_creds)) { - if (auth_debug_mode) - printf("Kerberos V5: could not obtain credentials - %s\r\n", - error_message(r)); - krb5_free_creds(local_creds); - return; - } - - if (r = get_for_creds(ETYPE_DES_CBC_CRC, - krb5_kdc_req_sumtype, - RemoteHostName, - local_creds->client, - &local_creds->keyblock, - forward_flags & OPTS_FORWARDABLE_CREDS, - &forw_creds)) { - if (auth_debug_mode) - printf("Kerberos V5: error getting forwarded creds - %s\r\n", - error_message(r)); - krb5_free_creds(local_creds); - return; - } - - /* Send forwarded credentials */ - if (!Data(ap, KRB_FORWARD, forw_creds.data, forw_creds.length)) { - if (auth_debug_mode) - printf("Not enough room for authentication data\r\n"); - } - else { - if (auth_debug_mode) - printf("Forwarded local Kerberos V5 credentials to server\r\n"); - } - - krb5_free_creds(local_creds); -} -#endif /* FORWARD */ - -#endif /* KRB5 */ diff --git a/lib/libtelnet/key-proto.h b/lib/libtelnet/key-proto.h deleted file mode 100644 index 9668a775be50..000000000000 --- a/lib/libtelnet/key-proto.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)key-proto.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#ifndef __KEY_PROTO__ -#define __KEY_PROTO__ - -#if !defined(P) -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif -#endif - -int key_file_exists P((void)); -void key_lookup P((unsigned char *, Block)); -void key_stream_init P((Block, Block, int)); -unsigned char key_stream P((int, int)); -#endif diff --git a/lib/libtelnet/krb4encpwd.c b/lib/libtelnet/krb4encpwd.c deleted file mode 100644 index 0f75d4d06076..000000000000 --- a/lib/libtelnet/krb4encpwd.c +++ /dev/null @@ -1,446 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)krb4encpwd.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - - -#ifdef KRB4_ENCPWD -/* - * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION - * ALL RIGHTS RESERVED - * - * "Digital Equipment Corporation authorizes the reproduction, - * distribution and modification of this software subject to the following - * restrictions: - * - * 1. Any partial or whole copy of this software, or any modification - * thereof, must include this copyright notice in its entirety. - * - * 2. This software is supplied "as is" with no warranty of any kind, - * expressed or implied, for any purpose, including any warranty of fitness - * or merchantibility. DIGITAL assumes no responsibility for the use or - * reliability of this software, nor promises to provide any form of - * support for it on any basis. - * - * 3. Distribution of this software is authorized only if no profit or - * remuneration of any kind is received in exchange for such distribution. - * - * 4. This software produces public key authentication certificates - * bearing an expiration date established by DIGITAL and RSA Data - * Security, Inc. It may cease to generate certificates after the expiration - * date. Any modification of this software that changes or defeats - * the expiration date or its effect is unauthorized. - * - * 5. Software that will renew or extend the expiration date of - * authentication certificates produced by this software may be obtained - * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA - * 94065, (415)595-8782, or from DIGITAL" - * - */ - -#include -#include -#include -#include - -#include -#include -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -#include "encrypt.h" -#include "auth.h" -#include "misc.h" - -int krb_mk_encpwd_req P((KTEXT, char *, char *, char *, char *, char *, char *)); -int krb_rd_encpwd_req P((KTEXT, char *, char *, u_long, AUTH_DAT *, char *, char *, char *, char *)); - -extern auth_debug_mode; - -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, - AUTHTYPE_KRB4_ENCPWD, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; - -#define KRB4_ENCPWD_AUTH 0 /* Authentication data follows */ -#define KRB4_ENCPWD_REJECT 1 /* Rejected (reason might follow) */ -#define KRB4_ENCPWD_ACCEPT 2 /* Accepted */ -#define KRB4_ENCPWD_CHALLENGE 3 /* Challenge for mutual auth. */ -#define KRB4_ENCPWD_ACK 4 /* Acknowledge */ - -#define KRB_SERVICE_NAME "rcmd" - -static KTEXT_ST auth; -static char name[ANAME_SZ]; -static char user_passwd[ANAME_SZ]; -static AUTH_DAT adat = { 0 }; -#ifdef ENCRYPTION -static Block session_key = { 0 }; -#endif /* ENCRYPTION */ -static Schedule sched; -static char challenge[REALM_SZ]; - - static int -Data(ap, type, d, c) - Authenticator *ap; - int type; - void *d; - int c; -{ - unsigned char *p = str_data + 4; - unsigned char *cd = (unsigned char *)d; - - if (c == -1) - c = strlen((char *)cd); - - if (0) { - printf("%s:%d: [%d] (%d)", - str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", - str_data[3], - type, c); - printd(d, c); - printf("\r\n"); - } - *p++ = ap->type; - *p++ = ap->way; - *p++ = type; - while (c-- > 0) { - if ((*p++ = *cd++) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - if (str_data[3] == TELQUAL_IS) - printsub('>', &str_data[2], p - (&str_data[2])); - return(net_write(str_data, p - str_data)); -} - - int -krb4encpwd_init(ap, server) - Authenticator *ap; - int server; -{ - char hostname[80], *cp, *realm; - C_Block skey; - - if (server) { - str_data[3] = TELQUAL_REPLY; - } else { - str_data[3] = TELQUAL_IS; - gethostname(hostname, sizeof(hostname)); - realm = krb_realmofhost(hostname); - cp = index(hostname, '.'); - if (*cp != NULL) *cp = NULL; - if (read_service_key(KRB_SERVICE_NAME, hostname, realm, 0, - KEYFILE, (char *)skey)) { - return(0); - } - } - return(1); -} - - int -krb4encpwd_send(ap) - Authenticator *ap; -{ - - printf("[ Trying KRB4ENCPWD ... ]\n"); - if (!UserNameRequested) { - return(0); - } - if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { - return(0); - } - - if (!Data(ap, KRB4_ENCPWD_ACK, (void *)NULL, 0)) { - return(0); - } - - return(1); -} - - void -krb4encpwd_is(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - Block datablock; - char r_passwd[ANAME_SZ], r_user[ANAME_SZ]; - char lhostname[ANAME_SZ], *cp; - int r; - time_t now; - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB4_ENCPWD_AUTH: - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); - - gethostname(lhostname, sizeof(lhostname)); - if ((cp = index(lhostname, '.')) != 0) *cp = '\0'; - - if (r = krb_rd_encpwd_req(&auth, KRB_SERVICE_NAME, lhostname, 0, &adat, NULL, challenge, r_user, r_passwd)) { - Data(ap, KRB4_ENCPWD_REJECT, (void *)"Auth failed", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - auth_encrypt_userpwd(r_passwd); - if (passwdok(UserNameRequested, UserPassword) == 0) { - /* - * illegal username and password - */ - Data(ap, KRB4_ENCPWD_REJECT, (void *)"Illegal password", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - - bcopy((void *)adat.session, (void *)session_key, sizeof(Block)); - Data(ap, KRB4_ENCPWD_ACCEPT, (void *)0, 0); - auth_finished(ap, AUTH_USER); - break; - - case KRB4_ENCPWD_CHALLENGE: - /* - * Take the received random challenge text and save - * for future authentication. - */ - bcopy((void *)data, (void *)challenge, sizeof(Block)); - break; - - - case KRB4_ENCPWD_ACK: - /* - * Receive ack, if mutual then send random challenge - */ - - /* - * If we are doing mutual authentication, get set up to send - * the challange, and verify it when the response comes back. - */ - - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - register int i; - - time(&now); - sprintf(challenge, "%x", now); - Data(ap, KRB4_ENCPWD_CHALLENGE, (void *)challenge, strlen(challenge)); - } - break; - - default: - Data(ap, KRB4_ENCPWD_REJECT, 0, 0); - break; - } -} - - - void -krb4encpwd_reply(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - KTEXT_ST krb_token; - Block enckey; - CREDENTIALS cred; - int r; - char randchal[REALM_SZ], instance[ANAME_SZ], *cp; - char hostname[80], *realm; - - if (cnt-- < 1) - return; - switch (*data++) { - case KRB4_ENCPWD_REJECT: - if (cnt > 0) { - printf("[ KRB4_ENCPWD refuses authentication because %.*s ]\r\n", - cnt, data); - } else - printf("[ KRB4_ENCPWD refuses authentication ]\r\n"); - auth_send_retry(); - return; - case KRB4_ENCPWD_ACCEPT: - printf("[ KRB4_ENCPWD accepts you ]\n"); - auth_finished(ap, AUTH_USER); - return; - case KRB4_ENCPWD_CHALLENGE: - /* - * Verify that the response to the challenge is correct. - */ - - gethostname(hostname, sizeof(hostname)); - realm = krb_realmofhost(hostname); - bcopy((void *)data, (void *)challenge, cnt); - bzero(user_passwd, sizeof(user_passwd)); - local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0); - UserPassword = user_passwd; - Challenge = challenge; - strcpy(instance, RemoteHostName); - if ((cp = index(instance, '.')) != 0) *cp = '\0'; - - if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) { - krb_token.length = 0; - } - - if (!Data(ap, KRB4_ENCPWD_AUTH, (void *)krb_token.dat, krb_token.length)) { - return; - } - - break; - - default: - return; - } -} - - int -krb4encpwd_status(ap, name, level) - Authenticator *ap; - char *name; - int level; -{ - - if (level < AUTH_USER) - return(level); - - if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) { - strcpy(name, UserNameRequested); - return(AUTH_VALID); - } else { - return(AUTH_USER); - } -} - -#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} -#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} - - void -krb4encpwd_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - - buf[buflen-1] = '\0'; /* make sure its NULL terminated */ - buflen -= 1; - - switch(data[3]) { - case KRB4_ENCPWD_REJECT: /* Rejected (reason might follow) */ - strncpy((char *)buf, " REJECT ", buflen); - goto common; - - case KRB4_ENCPWD_ACCEPT: /* Accepted (name might follow) */ - strncpy((char *)buf, " ACCEPT ", buflen); - common: - BUMP(buf, buflen); - if (cnt <= 4) - break; - ADDC(buf, buflen, '"'); - for (i = 4; i < cnt; i++) - ADDC(buf, buflen, data[i]); - ADDC(buf, buflen, '"'); - ADDC(buf, buflen, '\0'); - break; - - case KRB4_ENCPWD_AUTH: /* Authentication data follows */ - strncpy((char *)buf, " AUTH", buflen); - goto common2; - - case KRB4_ENCPWD_CHALLENGE: - strncpy((char *)buf, " CHALLENGE", buflen); - goto common2; - - case KRB4_ENCPWD_ACK: - strncpy((char *)buf, " ACK", buflen); - goto common2; - - default: - sprintf(lbuf, " %d (unknown)", data[3]); - strncpy((char *)buf, lbuf, buflen); - common2: - BUMP(buf, buflen); - for (i = 4; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - strncpy((char *)buf, lbuf, buflen); - BUMP(buf, buflen); - } - break; - } -} - -int passwdok(name, passwd) -char *name, *passwd; -{ - char *crypt(); - char *salt, *p; - struct passwd *pwd; - int passwdok_status = 0; - - if (pwd = getpwnam(name)) - salt = pwd->pw_passwd; - else salt = "xx"; - - p = crypt(passwd, salt); - - if (pwd && !strcmp(p, pwd->pw_passwd)) { - passwdok_status = 1; - } else passwdok_status = 0; - return(passwdok_status); -} - -#endif - -#ifdef notdef - -prkey(msg, key) - char *msg; - unsigned char *key; -{ - register int i; - printf("%s:", msg); - for (i = 0; i < 8; i++) - printf(" %3d", key[i]); - printf("\r\n"); -} -#endif diff --git a/lib/libtelnet/read_password.c b/lib/libtelnet/read_password.c deleted file mode 100644 index 7644d9a60e57..000000000000 --- a/lib/libtelnet/read_password.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)read_password.c 8.2 (Berkeley) 12/15/93"; -#endif /* not lint */ - -/* - * $Source: /mit/kerberos/src/lib/des/RCS/read_password.c,v $ - * $Author: jon $ - * - * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute - * of Technology. - * - * For copying and distribution information, please see the file - * . - * - * This routine prints the supplied string to standard - * output as a prompt, and reads a password string without - * echoing. - */ - -#if defined(RSA_ENCPWD) || defined(KRB4_ENCPWD) - -#include -#include -#include -#include -#include - -static jmp_buf env; - -/*** Routines ****************************************************** */ -/* - * This version just returns the string, doesn't map to key. - * - * Returns 0 on success, non-zero on failure. - */ - -int -local_des_read_pw_string(s,max,prompt,verify) - char *s; - int max; - char *prompt; - int verify; -{ - int ok = 0; - char *ptr; - - jmp_buf old_env; - struct sgttyb tty_state; - char key_string[BUFSIZ]; - - if (max > BUFSIZ) { - return -1; - } - - /* XXX assume jmp_buf is typedef'ed to an array */ - bcopy((char *)old_env, (char *)env, sizeof(env)); - if (setjmp(env)) - goto lose; - - /* save terminal state*/ - if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1) - return -1; -/* - push_signals(); -*/ - /* Turn off echo */ - tty_state.sg_flags &= ~ECHO; - if (ioctl(0,TIOCSETP,(char *)&tty_state) == -1) - return -1; - while (!ok) { - (void) printf(prompt); - (void) fflush(stdout); - while (!fgets(s, max, stdin)); - - if ((ptr = index(s, '\n'))) - *ptr = '\0'; - if (verify) { - printf("\nVerifying, please re-enter %s",prompt); - (void) fflush(stdout); - if (!fgets(key_string, sizeof(key_string), stdin)) { - clearerr(stdin); - continue; - } - if ((ptr = index(key_string, '\n'))) - *ptr = '\0'; - if (strcmp(s,key_string)) { - printf("\n\07\07Mismatch - try again\n"); - (void) fflush(stdout); - continue; - } - } - ok = 1; - } - -lose: - if (!ok) - bzero(s, max); - printf("\n"); - /* turn echo back on */ - tty_state.sg_flags |= ECHO; - if (ioctl(0,TIOCSETP,(char *)&tty_state)) - ok = 0; -/* - pop_signals(); -*/ - bcopy((char *)env, (char *)old_env, sizeof(env)); - if (verify) - bzero(key_string, sizeof (key_string)); - s[max-1] = 0; /* force termination */ - return !ok; /* return nonzero if not okay */ -} -#endif /* defined(RSA_ENCPWD) || defined(KRB4_ENCPWD) */ diff --git a/lib/libtelnet/rsaencpwd.c b/lib/libtelnet/rsaencpwd.c deleted file mode 100644 index eda70fe0f737..000000000000 --- a/lib/libtelnet/rsaencpwd.c +++ /dev/null @@ -1,492 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)rsaencpwd.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - - -#ifdef RSA_ENCPWD -/* - * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION - * ALL RIGHTS RESERVED - * - * "Digital Equipment Corporation authorizes the reproduction, - * distribution and modification of this software subject to the following - * restrictions: - * - * 1. Any partial or whole copy of this software, or any modification - * thereof, must include this copyright notice in its entirety. - * - * 2. This software is supplied "as is" with no warranty of any kind, - * expressed or implied, for any purpose, including any warranty of fitness - * or merchantibility. DIGITAL assumes no responsibility for the use or - * reliability of this software, nor promises to provide any form of - * support for it on any basis. - * - * 3. Distribution of this software is authorized only if no profit or - * remuneration of any kind is received in exchange for such distribution. - * - * 4. This software produces public key authentication certificates - * bearing an expiration date established by DIGITAL and RSA Data - * Security, Inc. It may cease to generate certificates after the expiration - * date. Any modification of this software that changes or defeats - * the expiration date or its effect is unauthorized. - * - * 5. Software that will renew or extend the expiration date of - * authentication certificates produced by this software may be obtained - * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA - * 94065, (415)595-8782, or from DIGITAL" - * - */ - -#include -#include -#include -#include - -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -#include "encrypt.h" -#include "auth.h" -#include "misc.h" -#include "cdc.h" - -extern auth_debug_mode; - -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, - AUTHTYPE_RSA_ENCPWD, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; - -#define RSA_ENCPWD_AUTH 0 /* Authentication data follows */ -#define RSA_ENCPWD_REJECT 1 /* Rejected (reason might follow) */ -#define RSA_ENCPWD_ACCEPT 2 /* Accepted */ -#define RSA_ENCPWD_CHALLENGEKEY 3 /* Challenge and public key */ - -#define NAME_SZ 40 -#define CHAL_SZ 20 -#define PWD_SZ 40 - -static KTEXT_ST auth; -static char name[NAME_SZ]; -static char user_passwd[PWD_SZ]; -static char key_file[2*NAME_SZ]; -static char lhostname[NAME_SZ]; -static char challenge[CHAL_SZ]; -static int challenge_len; - - static int -Data(ap, type, d, c) - Authenticator *ap; - int type; - void *d; - int c; -{ - unsigned char *p = str_data + 4; - unsigned char *cd = (unsigned char *)d; - - if (c == -1) - c = strlen((char *)cd); - - if (0) { - printf("%s:%d: [%d] (%d)", - str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", - str_data[3], - type, c); - printd(d, c); - printf("\r\n"); - } - *p++ = ap->type; - *p++ = ap->way; - if (type != NULL) *p++ = type; - while (c-- > 0) { - if ((*p++ = *cd++) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - if (str_data[3] == TELQUAL_IS) - printsub('>', &str_data[2], p - (&str_data[2])); - return(net_write(str_data, p - str_data)); -} - - int -rsaencpwd_init(ap, server) - Authenticator *ap; - int server; -{ - char *cp; - FILE *fp; - - if (server) { - str_data[3] = TELQUAL_REPLY; - bzero(key_file, sizeof(key_file)); - gethostname(lhostname, sizeof(lhostname)); - if ((cp = index(lhostname, '.')) != 0) *cp = '\0'; - strcpy(key_file, "/etc/."); - strcat(key_file, lhostname); - strcat(key_file, "_privkey"); - if ((fp=fopen(key_file, "r"))==NULL) return(0); - fclose(fp); - } else { - str_data[3] = TELQUAL_IS; - } - return(1); -} - - int -rsaencpwd_send(ap) - Authenticator *ap; -{ - - printf("[ Trying RSAENCPWD ... ]\n"); - if (!UserNameRequested) { - return(0); - } - if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { - return(0); - } - if (!Data(ap, NULL, (void *)NULL, 0)) { - return(0); - } - - - return(1); -} - - void -rsaencpwd_is(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - Block datablock; - char r_passwd[PWD_SZ], r_user[NAME_SZ]; - char *cp, key[160]; - char chalkey[160], *ptr; - FILE *fp; - int r, i, j, chalkey_len, len; - time_t now; - - cnt--; - switch (*data++) { - case RSA_ENCPWD_AUTH: - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); - - if ((fp=fopen(key_file, "r"))==NULL) { - Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - /* - * get privkey - */ - fscanf(fp, "%x;", &len); - for (i=0;iway & AUTH_HOW_MASK) == AUTH_HOW_ONE_WAY) { - register int i; - - - time(&now); - if ((now % 2) == 0) { - sprintf(challenge, "%x", now); - challenge_len = strlen(challenge); - } else { - strcpy(challenge, "randchal"); - challenge_len = 8; - } - - if ((fp=fopen(key_file, "r"))==NULL) { - Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - /* - * skip privkey - */ - fscanf(fp, "%x;", &len); - for (i=0;i 0) { - printf("[ RSA_ENCPWD refuses authentication because %.*s ]\r\n", - cnt, data); - } else - printf("[ RSA_ENCPWD refuses authentication ]\r\n"); - auth_send_retry(); - return; - case RSA_ENCPWD_ACCEPT: - printf("[ RSA_ENCPWD accepts you ]\n"); - auth_finished(ap, AUTH_USER); - return; - case RSA_ENCPWD_CHALLENGEKEY: - /* - * Verify that the response to the challenge is correct. - */ - - bcopy((void *)data, (void *)chalkey, cnt); - ptr = (char *) &chalkey[0]; - ptr += DecodeHeaderLength(chalkey); - if (*ptr != 0x04) { - return; - } - *ptr++; - challenge_len = DecodeValueLength(ptr); - ptr += NumEncodeLengthOctets(challenge_len); - bcopy(ptr, challenge, challenge_len); - ptr += challenge_len; - if (*ptr != 0x04) { - return; - } - *ptr++; - pubkey_len = DecodeValueLength(ptr); - ptr += NumEncodeLengthOctets(pubkey_len); - bcopy(ptr, pubkey, pubkey_len); - bzero(user_passwd, sizeof(user_passwd)); - local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0); - UserPassword = user_passwd; - Challenge = challenge; - r = init_rsa_encpwd(&token, user_passwd, challenge, challenge_len, pubkey); - if (r < 0) { - token.length = 1; - } - - if (!Data(ap, RSA_ENCPWD_AUTH, (void *)token.dat, token.length)) { - return; - } - - break; - - default: - return; - } -} - - int -rsaencpwd_status(ap, name, level) - Authenticator *ap; - char *name; - int level; -{ - - if (level < AUTH_USER) - return(level); - - if (UserNameRequested && rsaencpwd_passwdok(UserNameRequested, UserPassword)) { - strcpy(name, UserNameRequested); - return(AUTH_VALID); - } else { - return(AUTH_USER); - } -} - -#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} -#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} - - void -rsaencpwd_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - - buf[buflen-1] = '\0'; /* make sure its NULL terminated */ - buflen -= 1; - - switch(data[3]) { - case RSA_ENCPWD_REJECT: /* Rejected (reason might follow) */ - strncpy((char *)buf, " REJECT ", buflen); - goto common; - - case RSA_ENCPWD_ACCEPT: /* Accepted (name might follow) */ - strncpy((char *)buf, " ACCEPT ", buflen); - common: - BUMP(buf, buflen); - if (cnt <= 4) - break; - ADDC(buf, buflen, '"'); - for (i = 4; i < cnt; i++) - ADDC(buf, buflen, data[i]); - ADDC(buf, buflen, '"'); - ADDC(buf, buflen, '\0'); - break; - - case RSA_ENCPWD_AUTH: /* Authentication data follows */ - strncpy((char *)buf, " AUTH", buflen); - goto common2; - - case RSA_ENCPWD_CHALLENGEKEY: - strncpy((char *)buf, " CHALLENGEKEY", buflen); - goto common2; - - default: - sprintf(lbuf, " %d (unknown)", data[3]); - strncpy((char *)buf, lbuf, buflen); - common2: - BUMP(buf, buflen); - for (i = 4; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - strncpy((char *)buf, lbuf, buflen); - BUMP(buf, buflen); - } - break; - } -} - -int rsaencpwd_passwdok(name, passwd) -char *name, *passwd; -{ - char *crypt(); - char *salt, *p; - struct passwd *pwd; - int passwdok_status = 0; - - if (pwd = getpwnam(name)) - salt = pwd->pw_passwd; - else salt = "xx"; - - p = crypt(passwd, salt); - - if (pwd && !strcmp(p, pwd->pw_passwd)) { - passwdok_status = 1; - } else passwdok_status = 0; - return(passwdok_status); -} - -#endif - -#ifdef notdef - -prkey(msg, key) - char *msg; - unsigned char *key; -{ - register int i; - printf("%s:", msg); - for (i = 0; i < 8; i++) - printf(" %3d", key[i]); - printf("\r\n"); -} -#endif diff --git a/lib/libtelnet/spx.c b/lib/libtelnet/spx.c deleted file mode 100644 index b4634d0a7036..000000000000 --- a/lib/libtelnet/spx.c +++ /dev/null @@ -1,588 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)spx.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#ifdef SPX -/* - * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION - * ALL RIGHTS RESERVED - * - * "Digital Equipment Corporation authorizes the reproduction, - * distribution and modification of this software subject to the following - * restrictions: - * - * 1. Any partial or whole copy of this software, or any modification - * thereof, must include this copyright notice in its entirety. - * - * 2. This software is supplied "as is" with no warranty of any kind, - * expressed or implied, for any purpose, including any warranty of fitness - * or merchantibility. DIGITAL assumes no responsibility for the use or - * reliability of this software, nor promises to provide any form of - * support for it on any basis. - * - * 3. Distribution of this software is authorized only if no profit or - * remuneration of any kind is received in exchange for such distribution. - * - * 4. This software produces public key authentication certificates - * bearing an expiration date established by DIGITAL and RSA Data - * Security, Inc. It may cease to generate certificates after the expiration - * date. Any modification of this software that changes or defeats - * the expiration date or its effect is unauthorized. - * - * 5. Software that will renew or extend the expiration date of - * authentication certificates produced by this software may be obtained - * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA - * 94065, (415)595-8782, or from DIGITAL" - * - */ - -#include -#include -#include -#include "gssapi_defs.h" -#ifdef __STDC__ -#include -#endif -#ifdef NO_STRING_H -#include -#else -#include -#endif - -#include -#include "encrypt.h" -#include "auth.h" -#include "misc.h" - -extern auth_debug_mode; - -static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, - AUTHTYPE_SPX, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; - -#define SPX_AUTH 0 /* Authentication data follows */ -#define SPX_REJECT 1 /* Rejected (reason might follow) */ -#define SPX_ACCEPT 2 /* Accepted */ - -#ifdef ENCRYPTION -static Block session_key = { 0 }; -#endif /* ENCRYPTION */ -static Schedule sched; -static Block challenge = { 0 }; - - -/*******************************************************************/ - -gss_OID_set actual_mechs; -gss_OID actual_mech_type, output_name_type; -int major_status, status, msg_ctx = 0, new_status; -int req_flags = 0, ret_flags, lifetime_rec; -gss_cred_id_t gss_cred_handle; -gss_ctx_id_t actual_ctxhandle, context_handle; -gss_buffer_desc output_token, input_token, input_name_buffer; -gss_buffer_desc status_string; -gss_name_t desired_targname, src_name; -gss_channel_bindings input_chan_bindings; -char lhostname[GSS_C_MAX_PRINTABLE_NAME]; -char targ_printable[GSS_C_MAX_PRINTABLE_NAME]; -int to_addr=0, from_addr=0; -char *address; -gss_buffer_desc fullname_buffer; -gss_OID fullname_type; -gss_cred_id_t gss_delegated_cred_handle; - -/*******************************************************************/ - - - - static int -Data(ap, type, d, c) - Authenticator *ap; - int type; - void *d; - int c; -{ - unsigned char *p = str_data + 4; - unsigned char *cd = (unsigned char *)d; - - if (c == -1) - c = strlen((char *)cd); - - if (0) { - printf("%s:%d: [%d] (%d)", - str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", - str_data[3], - type, c); - printd(d, c); - printf("\r\n"); - } - *p++ = ap->type; - *p++ = ap->way; - *p++ = type; - while (c-- > 0) { - if ((*p++ = *cd++) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - if (str_data[3] == TELQUAL_IS) - printsub('>', &str_data[2], p - (&str_data[2])); - return(net_write(str_data, p - str_data)); -} - - int -spx_init(ap, server) - Authenticator *ap; - int server; -{ - gss_cred_id_t tmp_cred_handle; - - if (server) { - str_data[3] = TELQUAL_REPLY; - gethostname(lhostname, sizeof(lhostname)); - strcpy(targ_printable, "SERVICE:rcmd@"); - strcat(targ_printable, lhostname); - input_name_buffer.length = strlen(targ_printable); - input_name_buffer.value = targ_printable; - major_status = gss_import_name(&status, - &input_name_buffer, - GSS_C_NULL_OID, - &desired_targname); - major_status = gss_acquire_cred(&status, - desired_targname, - 0, - GSS_C_NULL_OID_SET, - GSS_C_ACCEPT, - &tmp_cred_handle, - &actual_mechs, - &lifetime_rec); - if (major_status != GSS_S_COMPLETE) return(0); - } else { - str_data[3] = TELQUAL_IS; - } - return(1); -} - - int -spx_send(ap) - Authenticator *ap; -{ - Block enckey; - int r; - - gss_OID actual_mech_type, output_name_type; - int msg_ctx = 0, new_status, status; - int req_flags = 0, ret_flags, lifetime_rec, major_status; - gss_buffer_desc output_token, input_token, input_name_buffer; - gss_buffer_desc output_name_buffer, status_string; - gss_name_t desired_targname; - gss_channel_bindings input_chan_bindings; - char targ_printable[GSS_C_MAX_PRINTABLE_NAME]; - int from_addr=0, to_addr=0, myhostlen, j; - int deleg_flag=1, mutual_flag=0, replay_flag=0, seq_flag=0; - char *address; - - printf("[ Trying SPX ... ]\n"); - strcpy(targ_printable, "SERVICE:rcmd@"); - strcat(targ_printable, RemoteHostName); - - input_name_buffer.length = strlen(targ_printable); - input_name_buffer.value = targ_printable; - - if (!UserNameRequested) { - return(0); - } - - major_status = gss_import_name(&status, - &input_name_buffer, - GSS_C_NULL_OID, - &desired_targname); - - - major_status = gss_display_name(&status, - desired_targname, - &output_name_buffer, - &output_name_type); - - printf("target is '%s'\n", output_name_buffer.value); fflush(stdout); - - major_status = gss_release_buffer(&status, &output_name_buffer); - - input_chan_bindings = (gss_channel_bindings) - malloc(sizeof(gss_channel_bindings_desc)); - - input_chan_bindings->initiator_addrtype = GSS_C_AF_INET; - input_chan_bindings->initiator_address.length = 4; - address = (char *) malloc(4); - input_chan_bindings->initiator_address.value = (char *) address; - address[0] = ((from_addr & 0xff000000) >> 24); - address[1] = ((from_addr & 0xff0000) >> 16); - address[2] = ((from_addr & 0xff00) >> 8); - address[3] = (from_addr & 0xff); - input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET; - input_chan_bindings->acceptor_address.length = 4; - address = (char *) malloc(4); - input_chan_bindings->acceptor_address.value = (char *) address; - address[0] = ((to_addr & 0xff000000) >> 24); - address[1] = ((to_addr & 0xff0000) >> 16); - address[2] = ((to_addr & 0xff00) >> 8); - address[3] = (to_addr & 0xff); - input_chan_bindings->application_data.length = 0; - - req_flags = 0; - if (deleg_flag) req_flags = req_flags | 1; - if (mutual_flag) req_flags = req_flags | 2; - if (replay_flag) req_flags = req_flags | 4; - if (seq_flag) req_flags = req_flags | 8; - - major_status = gss_init_sec_context(&status, /* minor status */ - GSS_C_NO_CREDENTIAL, /* cred handle */ - &actual_ctxhandle, /* ctx handle */ - desired_targname, /* target name */ - GSS_C_NULL_OID, /* mech type */ - req_flags, /* req flags */ - 0, /* time req */ - input_chan_bindings, /* chan binding */ - GSS_C_NO_BUFFER, /* input token */ - &actual_mech_type, /* actual mech */ - &output_token, /* output token */ - &ret_flags, /* ret flags */ - &lifetime_rec); /* time rec */ - - if ((major_status != GSS_S_COMPLETE) && - (major_status != GSS_S_CONTINUE_NEEDED)) { - gss_display_status(&new_status, - status, - GSS_C_MECH_CODE, - GSS_C_NULL_OID, - &msg_ctx, - &status_string); - printf("%s\n", status_string.value); - return(0); - } - - if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { - return(0); - } - - if (!Data(ap, SPX_AUTH, (void *)output_token.value, output_token.length)) { - return(0); - } - - return(1); -} - - void -spx_is(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - Block datablock; - int r; - - if (cnt-- < 1) - return; - switch (*data++) { - case SPX_AUTH: - input_token.length = cnt; - input_token.value = (char *) data; - - gethostname(lhostname, sizeof(lhostname)); - - strcpy(targ_printable, "SERVICE:rcmd@"); - strcat(targ_printable, lhostname); - - input_name_buffer.length = strlen(targ_printable); - input_name_buffer.value = targ_printable; - - major_status = gss_import_name(&status, - &input_name_buffer, - GSS_C_NULL_OID, - &desired_targname); - - major_status = gss_acquire_cred(&status, - desired_targname, - 0, - GSS_C_NULL_OID_SET, - GSS_C_ACCEPT, - &gss_cred_handle, - &actual_mechs, - &lifetime_rec); - - major_status = gss_release_name(&status, desired_targname); - - input_chan_bindings = (gss_channel_bindings) - malloc(sizeof(gss_channel_bindings_desc)); - - input_chan_bindings->initiator_addrtype = GSS_C_AF_INET; - input_chan_bindings->initiator_address.length = 4; - address = (char *) malloc(4); - input_chan_bindings->initiator_address.value = (char *) address; - address[0] = ((from_addr & 0xff000000) >> 24); - address[1] = ((from_addr & 0xff0000) >> 16); - address[2] = ((from_addr & 0xff00) >> 8); - address[3] = (from_addr & 0xff); - input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET; - input_chan_bindings->acceptor_address.length = 4; - address = (char *) malloc(4); - input_chan_bindings->acceptor_address.value = (char *) address; - address[0] = ((to_addr & 0xff000000) >> 24); - address[1] = ((to_addr & 0xff0000) >> 16); - address[2] = ((to_addr & 0xff00) >> 8); - address[3] = (to_addr & 0xff); - input_chan_bindings->application_data.length = 0; - - major_status = gss_accept_sec_context(&status, - &context_handle, - gss_cred_handle, - &input_token, - input_chan_bindings, - &src_name, - &actual_mech_type, - &output_token, - &ret_flags, - &lifetime_rec, - &gss_delegated_cred_handle); - - - if (major_status != GSS_S_COMPLETE) { - - major_status = gss_display_name(&status, - src_name, - &fullname_buffer, - &fullname_type); - Data(ap, SPX_REJECT, (void *)"auth failed", -1); - auth_finished(ap, AUTH_REJECT); - return; - } - - major_status = gss_display_name(&status, - src_name, - &fullname_buffer, - &fullname_type); - - - Data(ap, SPX_ACCEPT, (void *)output_token.value, output_token.length); - auth_finished(ap, AUTH_USER); - break; - - default: - Data(ap, SPX_REJECT, 0, 0); - break; - } -} - - - void -spx_reply(ap, data, cnt) - Authenticator *ap; - unsigned char *data; - int cnt; -{ - Session_Key skey; - - if (cnt-- < 1) - return; - switch (*data++) { - case SPX_REJECT: - if (cnt > 0) { - printf("[ SPX refuses authentication because %.*s ]\r\n", - cnt, data); - } else - printf("[ SPX refuses authentication ]\r\n"); - auth_send_retry(); - return; - case SPX_ACCEPT: - printf("[ SPX accepts you ]\n"); - if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - /* - * Send over the encrypted challenge. - */ - input_token.value = (char *) data; - input_token.length = cnt; - - major_status = gss_init_sec_context(&status, /* minor stat */ - GSS_C_NO_CREDENTIAL, /* cred handle */ - &actual_ctxhandle, /* ctx handle */ - desired_targname, /* target name */ - GSS_C_NULL_OID, /* mech type */ - req_flags, /* req flags */ - 0, /* time req */ - input_chan_bindings, /* chan binding */ - &input_token, /* input token */ - &actual_mech_type, /* actual mech */ - &output_token, /* output token */ - &ret_flags, /* ret flags */ - &lifetime_rec); /* time rec */ - - if (major_status != GSS_S_COMPLETE) { - gss_display_status(&new_status, - status, - GSS_C_MECH_CODE, - GSS_C_NULL_OID, - &msg_ctx, - &status_string); - printf("[ SPX mutual response fails ... '%s' ]\r\n", - status_string.value); - auth_send_retry(); - return; - } - } - auth_finished(ap, AUTH_USER); - return; - - default: - return; - } -} - - int -spx_status(ap, name, level) - Authenticator *ap; - char *name; - int level; -{ - - gss_buffer_desc fullname_buffer, acl_file_buffer; - gss_OID fullname_type; - char acl_file[160], fullname[160]; - int major_status, status = 0; - struct passwd *pwd; - - /* - * hard code fullname to - * "SPX:/C=US/O=Digital/OU=LKG/OU=Sphinx/OU=Users/CN=Kannan Alagappan" - * and acl_file to "~kannan/.sphinx" - */ - - pwd = getpwnam(UserNameRequested); - if (pwd == NULL) { - return(AUTH_USER); /* not authenticated */ - } - - strcpy(acl_file, pwd->pw_dir); - strcat(acl_file, "/.sphinx"); - acl_file_buffer.value = acl_file; - acl_file_buffer.length = strlen(acl_file); - - major_status = gss_display_name(&status, - src_name, - &fullname_buffer, - &fullname_type); - - if (level < AUTH_USER) - return(level); - - major_status = gss__check_acl(&status, &fullname_buffer, - &acl_file_buffer); - - if (major_status == GSS_S_COMPLETE) { - strcpy(name, UserNameRequested); - return(AUTH_VALID); - } else { - return(AUTH_USER); - } - -} - -#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} -#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} - - void -spx_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - - buf[buflen-1] = '\0'; /* make sure its NULL terminated */ - buflen -= 1; - - switch(data[3]) { - case SPX_REJECT: /* Rejected (reason might follow) */ - strncpy((char *)buf, " REJECT ", buflen); - goto common; - - case SPX_ACCEPT: /* Accepted (name might follow) */ - strncpy((char *)buf, " ACCEPT ", buflen); - common: - BUMP(buf, buflen); - if (cnt <= 4) - break; - ADDC(buf, buflen, '"'); - for (i = 4; i < cnt; i++) - ADDC(buf, buflen, data[i]); - ADDC(buf, buflen, '"'); - ADDC(buf, buflen, '\0'); - break; - - case SPX_AUTH: /* Authentication data follows */ - strncpy((char *)buf, " AUTH", buflen); - goto common2; - - default: - sprintf(lbuf, " %d (unknown)", data[3]); - strncpy((char *)buf, lbuf, buflen); - common2: - BUMP(buf, buflen); - for (i = 4; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - strncpy((char *)buf, lbuf, buflen); - BUMP(buf, buflen); - } - break; - } -} - -#endif - -#ifdef notdef - -prkey(msg, key) - char *msg; - unsigned char *key; -{ - register int i; - printf("%s:", msg); - for (i = 0; i < 8; i++) - printf(" %3d", key[i]); - printf("\r\n"); -} -#endif diff --git a/lib/libterm/TEST/tc1.c b/lib/libterm/TEST/tc1.c deleted file mode 100644 index fd0870adc679..000000000000 --- a/lib/libterm/TEST/tc1.c +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tc1.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * tc1 [term] - * dummy program to test termlib. - * gets entry, counts it, and prints it. - */ -#include -char buf[1024]; -char *getenv(); - -main(argc, argv) char **argv; { - char *p; - int rc; - - if (argc < 2) - p = getenv("TERM"); - else - p = argv[1]; - rc = tgetent(buf,p); - printf("tgetent returns %d, len=%d, text=\n'%s'\n",rc,strlen(buf),buf); -} diff --git a/lib/libterm/TEST/tc2.c b/lib/libterm/TEST/tc2.c deleted file mode 100644 index 1db9d0027e5d..000000000000 --- a/lib/libterm/TEST/tc2.c +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tc2.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * tc2 [term] - * Dummy program to test out termlib. - * Commands are "tcc\n" where t is type (s for string, f for flag, - * or n for number) and cc is the name of the capability. - */ -#include -char buf[1024]; -char *getenv(), *tgetstr(); - -main(argc, argv) char **argv; { - char *p, *q; - int rc; - char b[3], c; - char area[200]; - - if (argc < 2) - p = getenv("TERM"); - else - p = argv[1]; - rc = tgetent(buf,p); - for (;;) { - c = getchar(); - if (c < 0) - exit(0); - b[0] = getchar(); - if (b[0] < ' ') - exit(0); - b[1] = getchar(); - b[2] = 0; - getchar(); - switch(c) { - case 'f': - printf("%s: %d\n",b,tgetflag(b)); - break; - case 'n': - printf("%s: %d\n",b,tgetnum(b)); - break; - case 's': - q = area; - printf("%s: %s\n",b,tgetstr(b,&q)); - break; - default: - exit(0); - } - } -} diff --git a/lib/libterm/TEST/tc3.c b/lib/libterm/TEST/tc3.c deleted file mode 100644 index 3935e10d18eb..000000000000 --- a/lib/libterm/TEST/tc3.c +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tc3.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * tc3 [term] - * Dummy program to test out termlib. Input two numbers (row and col) - * and it prints out the tgoto string generated. - */ -#include -char buf[1024]; -char *getenv(), *tgetstr(); -char *rdchar(); -char *tgoto(); -char *CM; -char cmbuff[30]; -char *x; -char *UP; -char *tgout; - -main(argc, argv) char **argv; { - char *p; - int rc; - int row, col; - - if (argc < 2) - p = getenv("TERM"); - else - p = argv[1]; - rc = tgetent(buf,p); - x = cmbuff; - UP = tgetstr("up", &x); - printf("UP = %x = ", UP); pr(UP); printf("\n"); - if (UP && *UP==0) - UP = 0; - CM = tgetstr("cm", &x); - printf("CM = "); pr(CM); printf("\n"); - for (;;) { - if (scanf("%d %d", &row, &col) < 2) - exit(0); - tgout = tgoto(CM, col, row); - pr(tgout); - printf("\n"); - } -} - -pr(p) -register char *p; -{ - for (; *p; p++) - printf("%s", rdchar(*p)); -} - -/* - * rdchar() returns a readable representation of an ASCII character - * using ^ for control, ' for meta. - */ -#include -char *rdchar(c) -char c; -{ - static char ret[4]; - register char *p = ret; - - if ((c&0377) > 0177) - *p++ = '\''; - c &= 0177; - if (!isprint(c)) - *p++ = '^'; - *p++ = (isprint(c) ? c : c^0100); - *p = 0; - return (ret); -} diff --git a/lib/libterm/pathnames.h b/lib/libterm/pathnames.h deleted file mode 100644 index db3ccf74f21c..000000000000 --- a/lib/libterm/pathnames.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - */ - -#define _PATH_DEF ".termcap /usr/share/misc/termcap" diff --git a/lib/libterm/termcap.3 b/lib/libterm/termcap.3 deleted file mode 100644 index 08173cda342b..000000000000 --- a/lib/libterm/termcap.3 +++ /dev/null @@ -1,254 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)termcap.3 8.2 (Berkeley) 12/11/93 -.\" -.Dd December 11, 1993 -.Dt TERMCAP 3 -.Os BSD 4 -.Sh NAME -.Nm tgetent , -.Nm tgetnum , -.Nm tgetflag , -.Nm tgetstr , -.Nm tgoto , -.Nm tputs -.Nd terminal independent operation routines -.Sh SYNOPSIS -.Vt char PC; -.Vt char *BC; -.Vt char *UP; -.Vt short ospeed; -.Fn tgetent "char *bp" "char *name" -.Fn tgetnum "char *id" -.Fn tgetflag "char *id" -.Ft char * -.Fn tgetstr "char *id" "char **area" -.Ft char * -.Fn tgoto "char *cm" destcol destline -.Fn tputs "register char *cp" "int affcnt" "int (*outc)()" -.Sh DESCRIPTION -These functions extract and use capabilities from a terminal capability data -base, usually -.Pa /usr/share/misc/termcap , -the format of which is described in -.Xr termcap 5 . -These are low level routines; -see -.Xr curses 3 -for a higher level package. -.Pp -The -.Fn tgetent -function -extracts the entry for terminal -.Fa name -into the buffer at -.Fa bp . -The -.Fa bp -argument -should be a character buffer of size -1024 and must be retained through all subsequent calls to -.Fn tgetnum , -.Fn tgetflag , -and -.Fn tgetstr . -The -.Fn tgetent -function -returns \-1 if none of the -.Nm termcap -data base files could be opened, -0 if the terminal name given does not have an entry, -and 1 if all goes well. -It will look in the environment for a -.Ev TERMCAP -variable. -If found, and the value does not begin with a slash, -and the terminal type -.Fa name -is the same as the environment string -.Ev TERM , -the -.Ev TERMCAP -string is used instead of reading a -.Nm termcap -file. -If it does begin with a slash, the string is used as a path name -of the -.Nm termcap -file to search. -If -.Ev TERMCAP -does not begin with a slash and -.Fa name -is different from -.Ev TERM , -.Fn tgetent -searches the files -.Pa $HOME/.termcap -and -.Pa /usr/share/misc/termcap , -in that order, unless the environment variable -.Ev TERMPATH -exists, -in which case it specifies a list of file pathnames -(separated by spaces or colons) to be searched instead. -Whenever multiple files are searched and a -.Sy tc -field occurs in the requested entry, the entry it names must be found -in the same file or one of the succeeding files. -This can speed up entry into programs that call -.Fn tgetent , -as well as help debug new terminal descriptions -or make one for your terminal if you can't write the file -.Pa /usr/share/misc/termcap . -.Pp -The -.Fn tgetnum -function -gets the numeric value of capability -.Fa id , -returning \-1 if it is not given for the terminal. -The -.Fn tgetflag -function -returns 1 if the specified capability is present in -the terminal's entry, 0 if it is not. -The -.Fn tgetstr -function -returns the string value of the capability -.Fa id , -places it in the buffer at -.Fa area , -and advances the -.Fa area -pointer. -It decodes the abbreviations for this field described in -.Xr termcap 5 , -except for cursor addressing and padding information. -The -.Fn tgetstr -function -returns -.Dv NULL -if the capability was not found. -.Pp -The -.Fn tgoto -function -returns a cursor addressing string decoded from -.Fa cm -to go to column -.Fa destcol -in line -.Fa destline . -It uses the external variables -.Va UP -(from the -.Sy up -capability) -and -.Va BC -(if -.Sy bc -is given rather than -.Sy bs ) -if necessary to avoid placing -.Sy \en , -.Sy ^D -or -.Sy ^@ -in -the returned string. -(Programs which call -.Fn tgoto -should be sure to turn off the -.Dv XTABS -bit(s), -since -.Fn tgoto -may now output a tab. -Note that programs using termcap should in general turn off -.Dv XTABS -anyway since some terminals use control-I for other functions, -such as nondestructive space.) -If a -.Sy % -sequence is given which is not understood, then -.Fn tgoto -returns -.Pq Dv OOPS . -.Pp -The -.Fn tputs -function -decodes the leading padding information of the string -.Fa cp ; -.Fa affcnt -gives the number of lines affected by the operation, or 1 if this is -not applicable, -.Fa outc -is a routine which is called with each character in turn. -The external variable -.Va ospeed -should contain the output speed of the terminal as encoded by -.Xr stty 3 . -The external variable -.Va PC -should contain a pad character to be used (from the -.SY pc -capability) -if a null -.Pq Sy ^@ -is inappropriate. -.Sh FILES -.Bl -tag -width /usr/share/misc/termcap -compact -.It Pa /usr/lib/libtermcap.a -.Fl l Ar ltermcap -library (also known as -.Fl l Ar ltermlib ) -.It Pa /usr/share/misc/termcap -standard terminal capability data base -.It Pa $HOME/.termcap -user's terminal capability data base -.El -.Sh SEE ALSO -.Xr ex 1 , -.Xr curses 3 , -.Xr termcap 5 -.Sh HISTORY -The -.Nm -functions appeared in -.Bx 4.0 . diff --git a/lib/libterm/termcap.c b/lib/libterm/termcap.c deleted file mode 100644 index 708ccfaa5d80..000000000000 --- a/lib/libterm/termcap.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#define PBUFSIZ 512 /* max length of filename path */ -#define PVECSIZ 32 /* max number of names in path */ - -#include -#include -#include -#include -#include "pathnames.h" - -/* - * termcap - routines for dealing with the terminal capability data base - * - * BUG: Should use a "last" pointer in tbuf, so that searching - * for capabilities alphabetically would not be a n**2/2 - * process when large numbers of capabilities are given. - * Note: If we add a last pointer now we will screw up the - * tc capability. We really should compile termcap. - * - * Essentially all the work here is scanning and decoding escapes - * in string capabilities. We don't use stdio because the editor - * doesn't, and because living w/o it is not hard. - */ - -static char *tbuf; /* termcap buffer */ - -/* - * Get an entry for terminal name in buffer bp from the termcap file. - */ -int -tgetent(bp, name) - char *bp, *name; -{ - register char *p; - register char *cp; - char *dummy; - char **fname; - char *home; - int i; - char pathbuf[PBUFSIZ]; /* holds raw path of filenames */ - char *pathvec[PVECSIZ]; /* to point to names in pathbuf */ - char **pvec; /* holds usable tail of path vector */ - char *termpath; - - fname = pathvec; - pvec = pathvec; - tbuf = bp; - p = pathbuf; - cp = getenv("TERMCAP"); - /* - * TERMCAP can have one of two things in it. It can be the - * name of a file to use instead of /etc/termcap. In this - * case it better start with a "/". Or it can be an entry to - * use so we don't have to read the file. In this case it - * has to already have the newlines crunched out. If TERMCAP - * does not hold a file name then a path of names is searched - * instead. The path is found in the TERMPATH variable, or - * becomes "$HOME/.termcap /etc/termcap" if no TERMPATH exists. - */ - if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */ - if (termpath = getenv("TERMPATH")) - strncpy(pathbuf, termpath, PBUFSIZ); - else { - if (home = getenv("HOME")) { /* set up default */ - p += strlen(home); /* path, looking in */ - strcpy(pathbuf, home); /* $HOME first */ - *p++ = '/'; - } /* if no $HOME look in current directory */ - strncpy(p, _PATH_DEF, PBUFSIZ - (p - pathbuf)); - } - } - else /* user-defined name in TERMCAP */ - strncpy(pathbuf, cp, PBUFSIZ); /* still can be tokenized */ - - *fname++ = pathbuf; /* tokenize path into vector of names */ - while (*++p) - if (*p == ' ' || *p == ':') { - *p = '\0'; - while (*++p) - if (*p != ' ' && *p != ':') - break; - if (*p == '\0') - break; - *fname++ = p; - if (fname >= pathvec + PVECSIZ) { - fname--; - break; - } - } - *fname = (char *) 0; /* mark end of vector */ - if (cp && *cp && *cp != '/') - if (cgetset(cp) < 0) - return(-2); - - i = cgetent(&dummy, pathvec, name); - - if (i == 0) - strcpy(bp, dummy); - - if (dummy) - free(dummy); - /* no tc reference loop return code in libterm XXX */ - if (i == -3) - return(-1); - return(i + 1); -} - -/* - * Return the (numeric) option id. - * Numeric options look like - * li#80 - * i.e. the option string is separated from the numeric value by - * a # character. If the option is not found we return -1. - * Note that we handle octal numbers beginning with 0. - */ -int -tgetnum(id) - char *id; -{ - long num; - - if (cgetnum(tbuf, id, &num) == 0) - return(num); - else - return(-1); -} - -/* - * Handle a flag option. - * Flag options are given "naked", i.e. followed by a : or the end - * of the buffer. Return 1 if we find the option, or 0 if it is - * not given. - */ -int -tgetflag(id) - char *id; -{ - return(cgetcap(tbuf, id, ':') != NULL); -} - -/* - * Get a string valued option. - * These are given as - * cl=^Z - * Much decoding is done on the strings, and the strings are - * placed in area, which is a ref parameter which is updated. - * No checking on area overflow. - */ -char * -tgetstr(id, area) - char *id, **area; -{ - char ids[3]; - char *s; - int i; - - /* - * XXX - * This is for all the boneheaded programs that relied on tgetstr - * to look only at the first 2 characters of the string passed... - */ - *ids = *id; - ids[1] = id[1]; - ids[2] = '\0'; - - if ((i = cgetstr(tbuf, ids, &s)) < 0) - return NULL; - - strcpy(*area, s); - *area += i + 1; - return(s); -} diff --git a/lib/libterm/tgoto.c b/lib/libterm/tgoto.c deleted file mode 100644 index f0e4cc4fe311..000000000000 --- a/lib/libterm/tgoto.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tgoto.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#define CTRL(c) ((c) & 037) - -#define MAXRETURNSIZE 64 - -char *UP; -char *BC; - -/* - * Routine to perform cursor addressing. - * CM is a string containing printf type escapes to allow - * cursor addressing. We start out ready to print the destination - * line, and switch each time we print row or column. - * The following escapes are defined for substituting row/column: - * - * %d as in printf - * %2 like %2d - * %3 like %3d - * %. gives %c hacking special case characters - * %+x like %c but adding x first - * - * The codes below affect the state but don't use up a value. - * - * %>xy if value > x add y - * %r reverses row/column - * %i increments row/column (for one origin indexing) - * %% gives % - * %B BCD (2 decimal digits encoded in one byte) - * %D Delta Data (backwards bcd) - * - * all other characters are ``self-inserting''. - */ -char * -tgoto(CM, destcol, destline) - char *CM; - int destcol, destline; -{ - static char result[MAXRETURNSIZE]; - static char added[10]; - char *cp = CM; - register char *dp = result; - register int c; - int oncol = 0; - register int which = destline; - - if (cp == 0) { -toohard: - /* - * ``We don't do that under BOZO's big top'' - */ - return ("OOPS"); - } - added[0] = 0; - while (c = *cp++) { - if (c != '%') { - *dp++ = c; - continue; - } - switch (c = *cp++) { - -#ifdef CM_N - case 'n': - destcol ^= 0140; - destline ^= 0140; - goto setwhich; -#endif - - case 'd': - if (which < 10) - goto one; - if (which < 100) - goto two; - /* fall into... */ - - case '3': - *dp++ = (which / 100) | '0'; - which %= 100; - /* fall into... */ - - case '2': -two: - *dp++ = which / 10 | '0'; -one: - *dp++ = which % 10 | '0'; -swap: - oncol = 1 - oncol; -setwhich: - which = oncol ? destcol : destline; - continue; - -#ifdef CM_GT - case '>': - if (which > *cp++) - which += *cp++; - else - cp++; - continue; -#endif - - case '+': - which += *cp++; - /* fall into... */ - - case '.': -casedot: - /* - * This code is worth scratching your head at for a - * while. The idea is that various weird things can - * happen to nulls, EOT's, tabs, and newlines by the - * tty driver, arpanet, and so on, so we don't send - * them if we can help it. - * - * Tab is taken out to get Ann Arbors to work, otherwise - * when they go to column 9 we increment which is wrong - * because bcd isn't continuous. We should take out - * the rest too, or run the thing through more than - * once until it doesn't make any of these, but that - * would make termlib (and hence pdp-11 ex) bigger, - * and also somewhat slower. This requires all - * programs which use termlib to stty tabs so they - * don't get expanded. They should do this anyway - * because some terminals use ^I for other things, - * like nondestructive space. - */ - if (which == 0 || which == CTRL('d') || /* which == '\t' || */ which == '\n') { - if (oncol || UP) /* Assumption: backspace works */ - /* - * Loop needed because newline happens - * to be the successor of tab. - */ - do { - strcat(added, oncol ? (BC ? BC : "\b") : UP); - which++; - } while (which == '\n'); - } - *dp++ = which; - goto swap; - - case 'r': - oncol = 1; - goto setwhich; - - case 'i': - destcol++; - destline++; - which++; - continue; - - case '%': - *dp++ = c; - continue; - -#ifdef CM_B - case 'B': - which = (which/10 << 4) + which%10; - continue; -#endif - -#ifdef CM_D - case 'D': - which = which - 2 * (which%16); - continue; -#endif - - default: - goto toohard; - } - } - strcpy(dp, added); - return (result); -} diff --git a/lib/libterm/tputs.c b/lib/libterm/tputs.c deleted file mode 100644 index 857147d9283e..000000000000 --- a/lib/libterm/tputs.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tputs.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include - -/* - * The following array gives the number of tens of milliseconds per - * character for each speed as returned by gtty. Thus since 300 - * baud returns a 7, there are 33.3 milliseconds per char at 300 baud. - */ -static -short tmspc10[] = { - 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5 -}; - -short ospeed; -char PC; - -/* - * Put the character string cp out, with padding. - * The number of affected lines is affcnt, and the routine - * used to output one character is outc. - */ -tputs(cp, affcnt, outc) - register char *cp; - int affcnt; - int (*outc)(); -{ - register int i = 0; - register int mspc10; - - if (cp == 0) - return; - - /* - * Convert the number representing the delay. - */ - if (isdigit(*cp)) { - do - i = i * 10 + *cp++ - '0'; - while (isdigit(*cp)); - } - i *= 10; - if (*cp == '.') { - cp++; - if (isdigit(*cp)) - i += *cp - '0'; - /* - * Only one digit to the right of the decimal point. - */ - while (isdigit(*cp)) - cp++; - } - - /* - * If the delay is followed by a `*', then - * multiply by the affected lines count. - */ - if (*cp == '*') - cp++, i *= affcnt; - - /* - * The guts of the string. - */ - while (*cp) - (*outc)(*cp++); - - /* - * If no delay needed, or output speed is - * not comprehensible, then don't try to delay. - */ - if (i == 0) - return; - if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0])) - return; - - /* - * Round up by a half a character frame, - * and then do the delay. - * Too bad there are no user program accessible programmed delays. - * Transmitting pad characters slows many - * terminals down and also loads the system. - */ - mspc10 = tmspc10[ospeed]; - i += mspc10 / 2; - for (i /= mspc10; i > 0; i--) - (*outc)(PC); -} diff --git a/libexec/bugfiler/bug.h b/libexec/bugfiler/bug.h deleted file mode 100644 index 69ea9864294a..000000000000 --- a/libexec/bugfiler/bug.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)bug.h 8.1 (Berkeley) 6/4/93 - */ - -#define BUGS_HOME "owner-bugs@ucbvax.Berkeley.EDU" -#define BUGS_ID "bugs" - -/* - * the METOO definition has the bugfiler exit with an error (-1) status - * if there's a problem. This causes sendmail to send off a copy of the - * report (as failed mail) to the "owner" of the mail alias that executed - * the bugfiler. This is great if you would have otherwise lost the bug - * report. It's not so great if you get a whole bunch of mail that you - * really don't want. - */ -#define METOO - -/* files */ -#define ACK_FILE "bug:ack" /* acknowledge file */ -#define DIST_FILE "bug:redist" /* redistribution file */ -#define ERROR_FILE "log" /* error file */ -#define LOCK_FILE "bug:lock" /* lock file name */ -#define SUMMARY_FILE "summary" /* summary file */ -#define TMP_BUG "errors/BUG_XXXXXX" /* tmp bug report */ -#define TMP_DIR "errors" /* tmp directory */ - -#define CHN (char *)NULL /* null arg string */ -#define COMMENT '#' /* comment in redist file */ -#define EOS (char)NULL /* end of string */ -#define ERR -1 /* error return */ -#define MAXLINELEN 200 /* max line length in message */ -#define NO 0 /* no/false */ -#define OK 0 /* okay return */ -#define YES 1 /* yes/true */ - -typedef struct { - short found, /* line number if found */ - redist; /* if part of redist headers */ - int (*valid)(); /* validation routine */ - short len; /* length of tag */ - char *tag, /* leading tag */ - *line; /* actual line */ -} HEADER; -extern HEADER mailhead[]; - -#define DATE_TAG 0 /* "Date:" offset */ -#define FROM_TAG 1 /* "From " offset */ -#define CFROM_TAG 2 /* "From:" offset */ -#define INDX_TAG 3 /* "Index:" offset */ -#define MSG_TAG 4 /* "Message-Id:" offset */ -#define RPLY_TAG 5 /* "Reply-To:" offset */ -#define RET_TAG 6 /* "Return-Path:" offset */ -#define SUBJ_TAG 7 /* "Subject:" offset */ -#define TO_TAG 8 /* "To:" offset */ -#define APPAR_TO_TAG 9 /* "Apparently-To:" offset */ - -/* so sizeof doesn't return 0 */ -extern char bfr[MAXBSIZE], /* general I/O buffer */ - dir[MAXNAMLEN], /* subject and folder */ - folder[MAXNAMLEN], - tmpname[sizeof(TMP_BUG) + 5]; /* temp bug file */ diff --git a/libexec/bugfiler/bugfiler.8 b/libexec/bugfiler/bugfiler.8 deleted file mode 100644 index 1fc86d25f450..000000000000 --- a/libexec/bugfiler/bugfiler.8 +++ /dev/null @@ -1,290 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)bugfiler.8 8.2 (Berkeley) 12/11/93 -.\" -.Dd December 11, 1993 -.Dt BUGFILER 8 -.Os BSD 4.2 -.Sh NAME -.Nm bugfiler -.Nd file bug reports in folders automatically -.Sh SYNOPSIS -.Nm bugfiler -.Op Fl ar -.Op Fl v Ar version -.Sh DESCRIPTION -.Nm Bugfiler -is a program to automatically intercept, acknowledge, -redistribute and store bug reports. -.Nm Bugfiler -is normally invoked -by the mail delivery program with a line similar to the following in -.Pa /etc/aliases . -.Bd -literal -offset indent -bugs: "|bugfiler" -.Ed -.Pp -It should be noted that the login -.Dq bugs -must exist for the bugfiler -to run. Unless otherwise noted all paths used by -.Nm bugfiler -are -relative to the home directory of this login. -.Nm Bugfiler -also -expects all of its files and directories to be owned by -.Dq bugs . -.Pp -Available options. -.Bl -tag -width Ds -.It Fl a -Do not send automatic mail acknowledgement to the bug report filer. -(The default is to send the acknowledgement with the file -.Pa ~bugs/version/bug:ack -appended). -.It Fl r -Do not redistribute. -.It Fl v Ar version -Override the -.Ar version -provided within the bug report itself. -.El -.Pp -For the bug report to be correctly filed, it must contain a line -in the following format: -.Pp -.Bd -filled -offset indent -compact -.Bl -column Index folder -.It Index: Ta Em folder Ta Ar version -.El -.Ed -.Pp -The directories -.Pa ~bugs/ Ns Ar version -and -.Pa ~bugs/ Ns Ar version/ Ns Em folder -must exist before -.Nm bugfiler -attempts to store the bug report. Bug -reports will be stored in files named by the concatenation of -.Ar version , -.Em folder , -and sequential numbers, i.e. if -.Ar version -is -.Dq 4.3 Tn BSD -and -.Em folder -is -.Dq ucb -the first bug report will be placed in -.Pa ~bugs/4.3BSD/ucb/1 . -If -.Em folder -contains more than one component only -the first one will be used, e.g. if -.Em folder -is -.Dq bin/from.c -or -.Dq bin/adb/con.c -it will be treated as if it were simply -.Dq bin . -.Pp -.Pp -If the -.Fl r -flag is not supplied, redistribution of the bug reports -is done as specified in the file -.Pa ~bugs/version/bug:redist . -This file -is in the format of the -.Xr aliases 5 -file, including comments and -entries requiring multiple lines, with the single exception that the -.Em folder -component of the -.Dq Index: -line replaces the name to alias. -The special folder -.Dq all: -receives a redistribution of all bug reports -sent to this -.Ar version . -For example, the -.Pa bug:redist -file -.Pp -.Bd -literal -offset indent -compact -# bigbug gets a copy of everything -all: bigbug -# ucb folder redistribution list -ucb: karels, kjd@coke.berkeley.edu - ra@beno.css.gov -.Ed -.Pp -will send copies of all bug reports with -.Dq ucb -as the -.Em folder -to bigbug, karels, kjd, and ra. -.Pp -Reports that cannot be filed, due to an invalid -.Dq Index: -line or -some other error, are placed in the directory -.Pa ~bugs/errors . -The -.Nm bugfiler -maintainer should correct these bug reports and then -run -.Nm bugfiler , -with the corrected report as its standard input, -as bug reports with errors are neither acknowledged or redistributed. -All reports that -.Nm bugfiler -handles are logged in -.Pa ~bugs/log. -.Pp -Valid bugs are also logged in the file -.Pa ~bugs/version/summary. -This file has an entry for each bug report for -.Ar version -in the -format: -.Pp -.Bd -literal -offset indent -compact -Filename Date - Subject: - Index: - Owner: Bugs Bunny - Status: Received -.Ed -.Pp -.Li Filename -is the concatenation of -.Ar version , -.Em folder , -and a number -as described above. -.Xr Date -is the date as reported by the system -clock, using -.Xr ctime 3 . -The -.Li Subject: -and -.Li Index: -lines are -copies of the -.Dq Subject: -and -.Dq index: -lines contained in the bug -report. The -.Li Owner -and -.Li Status -fields are intended to provide a -rudimentary method of tracking the status of bug reports. -.Pp -The file -.Pa ~bugs/bug:lock -is the focus of all locking for -.Nm bugfiler . -If you wish to manipulate any of the log or error files, rename or remove -it and -.Nm bugfiler -will treat all bug reports that it receives as if -they were incorrectly formatted, i.e. it will place them in the directory -.Pa ~bugs/errors , -for later recovery by the -.Nm bugfiler -maintainer. -Obviously, this file must be created when you first install -.Nm bugfiler . -.Pp -All errors that occur before -.Pa ~bugs/log -is found are logged into the system -log file, using -.Xr syslog 8 . -.Sh FILES -.Bl -tag -width /usr/share/misc/bugformatxx -compact -.It Pa ~bugs/bug:ack -the acknowledgement message -.It Pa ~bugs/bug:redist -the redistribution list -.It Pa ~bugs/bug:lock -the locking file -.It Pa ~bugs/errors/BUG_?????? -bug reports with format errors -.It Pa ~bugs/log -the log file -.It Pa ~bugs/folder/summary -the summary files -.It Pa /usr/sbin/sendmail -the mail delivery program -.It Pa /usr/share/misc/bugformat -a sample bug report format -.El -.Sh SEE ALSO -.Xr sendbug 1 , -.Xr aliases 5 , -.Xr syslog 8 -.Sh BUGS -Since mail can be forwarded in a number of different ways, -.Nm bugfiler -does not recognize forwarded mail and will acknowledge to the forwarder -instead of the original sender unless there is a -.Dq Reply-To -field in the -header. -.Pp -This version of -.Nm bugfiler -is not compatible with the version -released with -.Bx 4.3 -in that it doesn't complain to the sender about -incorrectly formatted bug reports. -Frankly, we got tired of the profanity, not to mention the extended -conversations -.Nm bugfiler -was holding with -.Xr vacation 1 . -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/libexec/bugfiler/bugfiler.c b/libexec/bugfiler/bugfiler.c deleted file mode 100644 index 75dbef38b0b1..000000000000 --- a/libexec/bugfiler/bugfiler.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 1983, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1986, 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)bugfiler.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Bug report processing program, designed to be invoked - * through aliases(5). - */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "bug.h" -#include "extern.h" - -char bfr[MAXBSIZE], /* general I/O buffer */ - tmpname[sizeof(TMP_BUG) + 5]; /* temp bug file */ - -static void logit __P((void)); -static void make_copy __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; /* getopt arguments */ - register struct passwd *pwd; /* bugs password entry */ - register int ch; /* getopts char */ - int do_ack, /* acknowledge bug report */ - do_redist; /* redistribut BR */ - char *argversion; /* folder name provided */ - - do_ack = do_redist = YES; - argversion = NULL; - while ((ch = getopt(argc, argv, "av:r")) != EOF) - switch(ch) { - case 'a': - do_ack = NO; - break; - case 'v': - argversion = optarg; - break; - case 'r': - do_redist = NO; - break; - case '?': - default: - fputs("usage: bugfiler [-ar] [-v version]\n", stderr); - error("usage: bugfiler [-ar] [-v version]", CHN); - } - - if (!(pwd = getpwnam(BUGS_ID))) - error("can't find bugs login.", BUGS_ID); - - if (chdir(pwd->pw_dir)) /* change to bugs home directory */ - error("can't chdir to %s.", pwd->pw_dir); - - if (seteuid(pwd->pw_uid)) - error("can't set id to %s.", BUGS_ID); - - (void)umask(02); /* everything is 664 */ - seterr(); /* redirect to log file */ - logit(); /* log report arrival */ - make_copy(); /* save copy in case */ - gethead(do_redist); - - if (argversion) /* specific folder requested */ - (void)strcpy(dir, argversion); - - process(); - - if (seteuid(0)) - error("can't set id to root.", CHN); - if (do_ack) - reply(); - if (do_redist) - redist(); - (void)unlink(tmpname); - exit(OK); -} - -/* - * make_copy -- - * make a copy of bug report in error folder - */ -static void -make_copy() -{ - register int cnt, /* read return value */ - tfd; /* temp file descriptor */ - - if (access(TMP_DIR, F_OK)) - (void)mkdir(TMP_DIR, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); - (void)strcpy(tmpname, TMP_BUG); - if (tfd = mkstemp(tmpname)) { - while ((cnt = read(fileno(stdin), - bfr, sizeof(bfr))) != ERR && cnt) - write(tfd, bfr, cnt); - (void)close(tfd); - return; - } - error("can't make copy using %s.", tmpname); -} - -/* - * logit -- - * log this run of the bugfiler - */ -static void -logit() -{ - struct timeval tp; - char *C1, *C2; - - if (gettimeofday(&tp, (struct timezone *)NULL)) - error("can't get time of day.", CHN); - for (C1 = C2 = ctime(&tp.tv_sec); *C1 && *C1 != '\n'; ++C1); - *C1 = EOS; - fputs(C2, stderr); -} diff --git a/libexec/bugfiler/bugformat b/libexec/bugfiler/bugformat deleted file mode 100644 index 97a767d7288c..000000000000 --- a/libexec/bugfiler/bugformat +++ /dev/null @@ -1,32 +0,0 @@ -Subject: Short summary of the problem (please make this meaningful!) -Index: folder 4.4BSD-alpha - -Description: - Detailed description of the problem, suggestion, or complaint. -Repeat-By: - Describe the sequence of events that causes the problem - to occur. -Fix: - Description of how to fix the problem. If you don't know a - fix for the problem, don't include this section. - --------- Remove this line and what's below it, for reference only. -------- - -To ensure that your bug report is handled correctly by bugfiler(8), -you must replace "folder" (on the line above starting with "Index:") -with one of the following values: - - folder ::= bin | doc | etc | games | ideas | include | lib - | local | man | misc | new | sys | ucb - | usr.bin | usr.lib - -If you're not running 4.3BSD, you should also replace "4.3BSD" on -the same line with one of the following values. - - version ::= 4.3BSD | 4.3BSD-tahoe | 4.3BSD-reno | net2 - | 4.4BSD-alpha - -For example, if your bug concerns the program "/usr/bin/file" and -you're currently running 4.3BSD-Reno, you should replace "folder" -with "usr.bin/file", and "4.4BSD-alpha" with "4.3BSD-Reno". The folder -"ideas" is for suggestions. diff --git a/libexec/bugfiler/error.c b/libexec/bugfiler/error.c deleted file mode 100644 index bd00b2bf7511..000000000000 --- a/libexec/bugfiler/error.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)error.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include -#include - -#include "bug.h" -#include "extern.h" - -static short err_redir; /* stderr redirected */ - -/* - * seterr -- - * redirect stderr for error processing - */ -void -seterr() -{ - if (!freopen(ERROR_FILE, "a", stderr)) - error("can't open error file %s.", ERROR_FILE); - err_redir = YES; -} - -/* - * error -- - * write errors to log file and die - */ -void -error(fmt, arg) - register char *fmt, - *arg; -{ - static char logmsg[MAXLINELEN]; /* syslog message */ - - if (err_redir) { - /* don't combine these, "fmt" may not require "arg" */ - fprintf(stderr, "\t%s\n\t", tmpname); - fprintf(stderr, fmt, arg); - fputc('\n', stderr); - } - else { - sprintf(logmsg, "bugfiler: %s", fmt); - syslog(LOG_ERR, logmsg, arg); - } -#ifdef METOO - exit(ERR); -#else - exit(OK); -#endif -} diff --git a/libexec/bugfiler/extern.h b/libexec/bugfiler/extern.h deleted file mode 100644 index b096f3d35ddf..000000000000 --- a/libexec/bugfiler/extern.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.1 (Berkeley) 6/4/93 - */ - -void error __P((char *, char *)); -void gethead __P((int)); -int process __P((void)); -void redist __P((void)); -void reply __P((void)); -void seterr __P((void)); diff --git a/libexec/bugfiler/gethead.c b/libexec/bugfiler/gethead.c deleted file mode 100644 index ba7e361717ba..000000000000 --- a/libexec/bugfiler/gethead.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)gethead.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -#include "pathnames.h" -#include "bug.h" -#include "extern.h" - -static int chk1 __P((char *)); -static int pbuf __P((char *)); - -#define ENT(X) sizeof(X) - 1, X -HEADER mailhead[] = { /* mail headers */ - { NO, YES, NULL, ENT("Date:"), }, - { NO, NO, NULL, ENT("From "), }, - { NO, YES, NULL, ENT("From:"), }, - { NO, NO, chk1, ENT("Index:"), }, - { NO, YES, NULL, ENT("Message-Id:"), }, - { NO, YES, NULL, ENT("Reply-To:"), }, - { NO, YES, NULL, ENT("Return-Path:"), }, - { NO, NO, pbuf, ENT("Subject:"), }, - { NO, YES, NULL, ENT("To:"), }, - { NO, NO, NULL, ENT("Apparently-To:"), }, - { ERR, } -}; - -FILE *dfp; /* distf file pointer */ -char dir[MAXNAMLEN], /* subject and folder */ - folder[MAXNAMLEN]; - -/* - * gethead -- - * read mail and bug headers from bug report, construct redist headers - */ -void -gethead(redist) - int redist; -{ - register HEADER *hp; /* mail header pointer */ - - if (redist) { - int fd; - char *distf; - - distf = strdup(_PATH_TMP); - if (!(fd = mkstemp(distf)) || !(dfp = fdopen(fd, "w+"))) - error("can't create redistribution file %s.", distf); - /* disappear after last reference is closed */ - (void)unlink(distf); - free(distf); - } - if (!freopen(tmpname, "r", stdin)) - error("can't read temporary bug file %s.", tmpname); - - while (fgets(bfr, sizeof(bfr), stdin)) { - for (hp = mailhead; hp->found != ERR; ++hp) - if (!hp->found) - if (!strncmp(hp->tag, bfr, hp->len)) { - if (hp->valid && !((*(hp->valid))(bfr))) - break; - if (!(hp->line = - malloc((u_int)(strlen(bfr) + 1)))) - error("malloc failed.", CHN); - (void)strcpy(hp->line, bfr); - hp->found = YES; - break; - } - if ((hp->found == ERR || hp->redist) && redist) - fputs(bfr, dfp); - } - - if (!mailhead[INDX_TAG].found) - error("no readable \"Index:\" header in bug report.", CHN); -} - -/* - * chk1 -- - * parse the "Index:" line into folder and directory - */ -static int -chk1(line) - char *line; -{ - register char *C; /* tmp pointer */ - struct stat sbuf; /* existence check */ - - if (sscanf(line, " Index: %s %s ", folder, dir) != 2) - return(NO); - if (C = strchr(folder, '/')) { /* deal with "bin/from.c" */ - if (C == folder) - return(NO); - *C = EOS; - } - if (stat(dir, &sbuf) || (sbuf.st_mode & S_IFMT) != S_IFDIR) - return(NO); - (void)pbuf(line); - return(YES); -} - -/* - * pbuf -- - * kludge so that summary file looks pretty - */ -static int -pbuf(line) - char *line; -{ - register char *rp, /* tmp pointers */ - *wp; - - for (rp = line; *rp == ' ' || *rp == '\t'; ++rp); - for (wp = line; *rp; ++wp) { - if ((*wp = *rp++) != ' ' && *wp != '\t') - continue; - *wp = ' '; - while (*rp == ' ' || *rp == '\t') - ++rp; - } - if (wp[-1] == ' ') /* wp can't == line */ - --wp; - *wp = EOS; - return(YES); -} diff --git a/libexec/bugfiler/pathnames.h b/libexec/bugfiler/pathnames.h deleted file mode 100644 index 7ff5ab6f211f..000000000000 --- a/libexec/bugfiler/pathnames.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - */ - -#define MAIL_CMD "/usr/sbin/sendmail -i -t -F \"Bugs Bunny\" -f owner-bugs" -#undef _PATH_TMP -#define _PATH_TMP "/tmp/BUG_XXXXXX" diff --git a/libexec/bugfiler/process.c b/libexec/bugfiler/process.c deleted file mode 100644 index 6d376fdf9d07..000000000000 --- a/libexec/bugfiler/process.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)process.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "bug.h" -#include "extern.h" - -char pfile[MAXPATHLEN]; /* permanent file name */ - -static int getnext __P((void)); - -/* - * process -- - * copy report to permanent file, - * update summary file. - */ -int -process() -{ - register int rval; /* read return value */ - struct timeval tp; /* time of day */ - int lfd; /* lock file descriptor */ - - if (access(LOCK_FILE, R_OK) || (lfd = open(LOCK_FILE, O_RDONLY, 0)) < 0) - error("can't find lock file %s.", LOCK_FILE); - if (flock(lfd, LOCK_EX)) - error("can't get lock.", CHN); - sprintf(pfile, "%s/%s/%d", dir, folder, getnext()); - fprintf(stderr, "\t%s\n", pfile); - if (!(freopen(pfile, "w", stdout))) - error("can't create %s.", pfile); - rewind(stdin); - while ((rval = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && rval) - if (write(fileno(stdout), bfr, rval) != rval) - error("write to %s failed.", pfile); - - /* append information to the summary file */ - sprintf(bfr, "%s/%s", dir, SUMMARY_FILE); - if (!(freopen(bfr, "a", stdout))) - error("can't append to summary file %s.", bfr); - if (gettimeofday(&tp, (struct timezone *)NULL)) - error("can't get time of day.", CHN); - printf("\n%s\t\t%s\t%s\t%s\tOwner: Bugs Bunny\n\tStatus: Received\n", - pfile, ctime(&tp.tv_sec), mailhead[INDX_TAG].line, - mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n"); - (void)flock(lfd, LOCK_UN); - (void)fclose(stdout); -} - -/* - * getnext -- - * get next file name (number) - */ -static int -getnext() -{ - register struct dirent *d; /* directory structure */ - register DIR *dirp; /* directory pointer */ - register int highval, newval; - register char *p; - - (void)sprintf(bfr, "%s/%s", dir, folder); - if (!(dirp = opendir(bfr))) - error("can't read folder directory %s.", bfr); - for (highval = -1; d = readdir(dirp);) { - for (p = d->d_name; *p && isdigit(*p); ++p); - if (!*p && (newval = atoi(d->d_name)) > highval) - highval = newval; - } - closedir(dirp); - return(++highval); -} diff --git a/libexec/bugfiler/redist.c b/libexec/bugfiler/redist.c deleted file mode 100644 index 87a18b6dd6e2..000000000000 --- a/libexec/bugfiler/redist.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)redist.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include - -#include "bug.h" -#include "pathnames.h" -#include "extern.h" - -/* - * redist -- - * Redistribute a bug report to those people indicated in the - * redistribution list file. - */ -void -redist() -{ - extern FILE *dfp; /* dist file fp */ - extern char pfile[]; /* permanent bug file */ - register char *C1, *C2; - FILE *pf; - int group; - - (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); - if (!freopen(bfr, "r", stdin)) - return; - for (pf = NULL, group = 0; fgets(bfr, sizeof(bfr), stdin);) { - if (C1 = strchr(bfr, '\n')) - *C1 = '\0'; -nextline: if (*bfr == COMMENT || - isspace(*bfr) || !(C1 = index(bfr, ':'))) - continue; - *C1 = EOS; - if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { - for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); - if (!*C1) /* if empty list */ - continue; - if (!pf) { - if (!(pf = popen(MAIL_CMD, "w"))) - error("sendmail pipe failed.", CHN); - if (mailhead[SUBJ_TAG].found) - fprintf(pf, - "%s", mailhead[SUBJ_TAG].line); - else - fprintf(pf, - "Subject: Untitled Bug Report\n"); - if (!mailhead[TO_TAG].line) { - if (mailhead[APPAR_TO_TAG].line) - fprintf(pf, "To%s", - strchr(mailhead[APPAR_TO_TAG].line, - ':')); - else - fprintf(pf, "To: %s\n", BUGS_ID); - } - fputs("Resent-To: ", pf); - } - /* - * write out first entry, then succeeding entries - * backward compatible, handles back slashes at end - * of line - */ - if (group++) - fputs(", ", pf); - for (;;) { - if (C2 = strchr(C1, '\\')) - *C2 = EOS; - fputs(C1, pf); - if (!fgets(bfr, sizeof(bfr), stdin)) - break; - if (C1 = strchr(bfr, '\n')) - *C1 = '\0'; - if (*bfr != ' ' && *bfr != '\t') - goto nextline; - for (C1 = bfr; - *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); - } - } - } - if (!pf) - return; - - putc('\n', pf); - - rewind(dfp); - /* add Reference header and copy bug report out */ - while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') - fputs(bfr, pf); - fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); - while (fgets(bfr, sizeof(bfr), dfp)) - fputs(bfr, pf); - (void)pclose(pf); -} diff --git a/libexec/bugfiler/reply.c b/libexec/bugfiler/reply.c deleted file mode 100644 index 0f9940181a25..000000000000 --- a/libexec/bugfiler/reply.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)reply.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include -#include - -#include "bug.h" -#include "extern.h" -#include "pathnames.h" - -/* - * reply -- - * tell the user we got their silly little bug report - */ -void -reply() -{ - register char *C, /* traveling pointer */ - *to; /* who we're replying to */ - register int afd, /* ack file descriptor */ - rval; /* return value */ - FILE *pf; /* pipe pointer */ - - if (mailhead[RPLY_TAG].found) { - for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len; - *C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - if (mailhead[FROM_TAG].found) { - for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len; - *C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - if (mailhead[CFROM_TAG].found) { - for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len; - *C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - return; - - /* if it's a foo , get the XXX, else get foo (first string) */ -gotone: if (to = strchr(C, '<')) - for (C = ++to; - *C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); - else { - to = C; - for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); - } - *C = EOS; - - if (!(pf = popen(MAIL_CMD, "w"))) - error("sendmail pipe failed.", CHN); - - fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", - BUGS_HOME, BUGS_HOME, to); - if (mailhead[SUBJ_TAG].found) - fprintf(pf, "Subject: Re:%s", - mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); - else - fputs("Subject: Bug report acknowledgement.\n", pf); - if (mailhead[DATE_TAG].found) - fprintf(pf, "In-Acknowledgement-Of: Your message of %s", - mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); - if (mailhead[MSG_TAG].found) - fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); - fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ - fflush(pf); - - (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); - if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { - while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) - (void)write(fileno(pf), bfr, rval); - (void)close(afd); - } - pclose(pf); -} diff --git a/libexec/bugfiler/sendbug.1 b/libexec/bugfiler/sendbug.1 deleted file mode 100644 index 31ca8028a2eb..000000000000 --- a/libexec/bugfiler/sendbug.1 +++ /dev/null @@ -1,85 +0,0 @@ -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sendbug.1 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt SENDBUG 1 -.Os BSD 4.2 -.Sh NAME -.Nm sendbug -.Nd mail a system bug report to 4bsd-bugs -.Sh SYNOPSIS -.Nm sendbug -.Op Ar address -.Sh DESCRIPTION -Bug reports sent to `4bsd-bugs@Berkeley.EDU' are intercepted -by a program which expects bug reports to conform to a standard format. -.Nm Sendbug -is a shell script to help the user compose and mail bug reports -in the correct format. -.Nm Sendbug -works by invoking the editor specified by the environment variable -.Ev EDITOR -on a temporary copy of the bug report format outline. The user must fill in the -appropriate fields and exit the editor. -.Nm Sendbug -then mails the completed report to `4bsd-bugs@Berkeley.EDU' or the -.Ar address -specified on the command line. -.Sh ENVIRONMENT -.Nm Sendbug -will utilize the following environment variable if it exists: -.Bl -tag -width EDITOR -.It Ev EDITOR -Specifies the preferred editor. If -.Ev EDITOR -is not set, -.Nm -defaults to -.Xr vi 1 . -.El -.Sh FILES -.Bl -tag -width /usr/share/misc/bugformat -compact -.It Pa /usr/share/misc/bugformat -Contains the bug report outline. -.El -.Sh SEE ALSO -.Xr vi 1 , -.Xr environ 7 , -.Xr bugfiler 8 , -.Xr sendmail 8 -.Sh HISTORY -The -.Nm sendbug -command -appeared in -.Bx 4.2 . diff --git a/libexec/bugfiler/sendbug.sh b/libexec/bugfiler/sendbug.sh deleted file mode 100644 index 911ef9d99b53..000000000000 --- a/libexec/bugfiler/sendbug.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1983, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)sendbug.sh 8.1 (Berkeley) 6/4/93 -# - -# create a bug report and mail it to '4bsd-bugs'. - -PATH=/bin:/sbin:/usr/sbin:/usr/bin -export PATH - -TEMP=/tmp/bug$$ -FORMAT=/usr/share/misc/bugformat - -# uucp sites should use ": ${BUGADDR=ucbvax!4bsd-bugs}" with a suitable path. -: ${BUGADDR=4bsd-bugs@CS.Berkeley.EDU} -: ${EDITOR=vi} - -trap 'rm -f $TEMP ; exit 1' 1 2 3 13 15 - -cp $FORMAT $TEMP -chmod u+w $TEMP -if $EDITOR $TEMP -then - if cmp -s $FORMAT $TEMP - then - echo "File not changed, no bug report submitted." - exit - fi - case "$#" in - 0) sendmail -t -oi $BUGADDR < $TEMP ;; - *) sendmail -t -oi "$@" < $TEMP ;; - esac -fi - -rm -f $TEMP diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h deleted file mode 100644 index 644f93f10747..000000000000 --- a/libexec/getty/extern.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.1 (Berkeley) 6/4/93 - */ - -struct delayval; - -int adelay __P((int, struct delayval *)); -char *autobaud __P((void)); -int delaybits __P((void)); -void edithost __P((char *)); -void gendefaults __P((void)); -int getent __P((char *, char *)); -int getflag __P((char *)); -long getnum __P((char *)); -char *getstr __P((char *, char **)); -void gettable __P((char *, char *)); -void makeenv __P((char *[])); -char *portselector __P((void)); -void set_ttydefaults __P((int)); -void setchars __P((void)); -void setdefaults __P((void)); -long setflags __P((int)); -int speed __P((int)); - -int login_tty __P((int)); /* From libutil. */ diff --git a/libexec/getty/ttydefaults.c b/libexec/getty/ttydefaults.c deleted file mode 100644 index 518f41ba0f60..000000000000 --- a/libexec/getty/ttydefaults.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)ttydefaults.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include - -#include "extern.h" - -void -set_ttydefaults(fd) - int fd; -{ - struct termios term; - - tcgetattr(fd, &term); - term.c_iflag = TTYDEF_IFLAG; - term.c_oflag = TTYDEF_OFLAG; - term.c_lflag = TTYDEF_LFLAG; - term.c_cflag = TTYDEF_CFLAG; - tcsetattr(fd, TCSAFLUSH, &term); -} diff --git a/libexec/kpasswdd/kpasswdd.8 b/libexec/kpasswdd/kpasswdd.8 deleted file mode 100644 index f6a401f8c0fe..000000000000 --- a/libexec/kpasswdd/kpasswdd.8 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)kpasswdd.8 8.1 (Berkeley) 6/9/93 -.\" -.Dd June 9, 1993 -.Dt KPASSWDD 8 -.Os -.Sh NAME -.Nm kpasswdd -.Nd Kerberos password changing daemon -.Sh SYNOPSIS -.Nm kpasswdd -.Sh DESCRIPTION -.Nm Kpasswdd -is the server for the -.Xr passwd 1 -program. -The server provides a remote password changing facility -with Kerberos authentication. -A user must provide the old Kerberos password, encrypted -in a random session key, to the server. -.Nm Kpasswdd -runs only on the Kerberos server, as it directly updates the -Kerberos database. -.Sh SEE ALSO -.Xr kerberos 1 , -.Xr passwd 1 -.Sh HISTORY -The -.Nm kpasswdd -utility first appeared in 4.4BSD. diff --git a/libexec/kpasswdd/kpasswdd.c b/libexec/kpasswdd/kpasswdd.c deleted file mode 100644 index 23ff1f864494..000000000000 --- a/libexec/kpasswdd/kpasswdd.c +++ /dev/null @@ -1,271 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1990, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)kpasswdd.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * kpasswdd - update a principal's passwd field in the Kerberos - * database. Called from inetd. - * K. Fall - * 12-Dec-88 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kpasswd_proto.h" - -static struct kpasswd_data kpwd_data; -static des_cblock master_key, key; -static Key_schedule master_key_schedule, - key_schedule, random_sched; -long mkeyversion; -AUTH_DAT kdata; -static Principal principal_data; -static struct update_data ud_data; - -char inst[INST_SZ]; -char version[9]; -KTEXT_ST ticket; - -char *progname; /* for the library */ - -main() -{ - struct sockaddr_in foreign; - int foreign_len = sizeof(foreign); - int rval, more; - static char name[] = "kpasswdd"; - - static struct rlimit rl = { 0, 0 }; - - progname = name; - openlog("kpasswdd", LOG_CONS | LOG_PID, LOG_AUTH); - - signal(SIGHUP, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGTSTP, SIG_IGN); - if (setrlimit(RLIMIT_CORE, &rl) < 0) { - syslog(LOG_ERR, "setrlimit: %m"); - exit(1); - } - - if (getpeername(0, &foreign, &foreign_len) < 0) { - syslog(LOG_ERR,"getpeername: %m"); - exit(1); - } - - strcpy(inst, "*"); - rval = krb_recvauth( - 0L, /* options--!MUTUAL */ - 0, /* file desc */ - &ticket, /* client's ticket */ - SERVICE, /* expected service */ - inst, /* expected instance */ - &foreign, /* foreign addr */ - (struct sockaddr_in *) 0, /* local addr */ - &kdata, /* returned krb data */ - "", /* service keys file */ - (bit_64 *) NULL, /* returned key schedule */ - version - ); - - - if (rval != KSUCCESS) { - syslog(LOG_NOTICE, "krb_recvauth: %s", krb_err_txt[rval]); - cleanup(); - exit(1); - } - - if (*version == '\0') { - /* indicates error on client's side (no tickets, etc.) */ - cleanup(); - exit(0); - } else if (strcmp(version, "KPWDV0.1") != 0) { - syslog(LOG_NOTICE, - "kpasswdd version conflict (recv'd %s)", - version); - cleanup(); - exit(1); - } - - - /* get master key */ - if (kdb_get_master_key(0, master_key, master_key_schedule) != 0) { - syslog(LOG_ERR, "couldn't get master key"); - cleanup(); - exit(1); - } - - mkeyversion = kdb_get_master_key(NULL, master_key, master_key_schedule); - - if (mkeyversion < 0) { - syslog(LOG_NOTICE, "couldn't verify master key"); - cleanup(); - exit(1); - } - - /* get principal info */ - rval = kerb_get_principal( - kdata.pname, - kdata.pinst, - &principal_data, - 1, - &more - ); - - if (rval < 0) { - syslog(LOG_NOTICE, - "error retrieving principal record for %s.%s", - kdata.pname, kdata.pinst); - cleanup(); - exit(1); - } - - if (rval != 1 || (more != 0)) { - syslog(LOG_NOTICE, "more than 1 dbase entry for %s.%s", - kdata.pname, kdata.pinst); - cleanup(); - exit(1); - } - - /* get the user's key */ - - bcopy(&principal_data.key_low, key, 4); - bcopy(&principal_data.key_high, ((long *) key) + 1, 4); - kdb_encrypt_key(key, key, master_key, master_key_schedule, - DECRYPT); - key_sched(key, key_schedule); - des_set_key(key, key_schedule); - - - /* get random key and send it over {random} Kperson */ - - random_key(kpwd_data.random_key); - strcpy(kpwd_data.secure_msg, SECURE_STRING); - if (des_write(0, &kpwd_data, sizeof(kpwd_data)) != sizeof(kpwd_data)) { - syslog(LOG_NOTICE, "error writing initial data"); - cleanup(); - exit(1); - } - - bzero(key, sizeof(key)); - bzero(key_schedule, sizeof(key_schedule)); - - /* now read update info: { info }Krandom */ - - key_sched(kpwd_data.random_key, random_sched); - des_set_key(kpwd_data.random_key, random_sched); - if (des_read(0, &ud_data, sizeof(ud_data)) != sizeof(ud_data)) { - syslog(LOG_NOTICE, "update aborted"); - cleanup(); - exit(1); - } - - /* validate info string by looking at the embedded string */ - - if (strcmp(ud_data.secure_msg, SECURE_STRING) != 0) { - syslog(LOG_NOTICE, "invalid update from %s", - inet_ntoa(foreign.sin_addr)); - cleanup(); - exit(1); - } - - /* produce the new key entry in the database { key }Kmaster */ - string_to_key(ud_data.pw, key); - kdb_encrypt_key(key, key, - master_key, master_key_schedule, - ENCRYPT); - bcopy(key, &principal_data.key_low, 4); - bcopy(((long *) key) + 1, - &principal_data.key_high, 4); - bzero(key, sizeof(key)); - principal_data.key_version++; - if (kerb_put_principal(&principal_data, 1)) { - syslog(LOG_ERR, "couldn't write new record for %s.%s", - principal_data.name, principal_data.instance); - cleanup(); - exit(1); - } - - syslog(LOG_NOTICE,"wrote new password field for %s.%s from %s", - principal_data.name, - principal_data.instance, - inet_ntoa(foreign.sin_addr) - ); - - send_ack(0, "Update complete.\n"); - cleanup(); - exit(0); -} - -cleanup() -{ - bzero(&kpwd_data, sizeof(kpwd_data)); - bzero(master_key, sizeof(master_key)); - bzero(master_key_schedule, sizeof(master_key_schedule)); - bzero(key, sizeof(key)); - bzero(key_schedule, sizeof(key_schedule)); - bzero(random_sched, sizeof(random_sched)); - bzero(&principal_data, sizeof(principal_data)); - bzero(&ud_data, sizeof(ud_data)); -} - -send_ack(remote, msg) - int remote; - char *msg; -{ - int cc; - cc = des_write(remote, msg, strlen(msg) + 1); - if (cc <= 0) { - syslog(LOG_NOTICE, "error writing ack"); - cleanup(); - exit(1); - } -} diff --git a/libexec/telnetd/authenc.c b/libexec/telnetd/authenc.c deleted file mode 100644 index fcd17fcf73b6..000000000000 --- a/libexec/telnetd/authenc.c +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#if defined(AUTHENTICATION) || defined(ENCRYPTION) -#include "telnetd.h" -#include - - int -net_write(str, len) - unsigned char *str; - int len; -{ - if (nfrontp + len < netobuf + BUFSIZ) { - bcopy((void *)str, (void *)nfrontp, len); - nfrontp += len; - return(len); - } - return(0); -} - - void -net_encrypt() -{ -#ifdef ENCRYPTION - char *s = (nclearto > nbackp) ? nclearto : nbackp; - if (s < nfrontp && encrypt_output) { - (*encrypt_output)((unsigned char *)s, nfrontp - s); - } - nclearto = nfrontp; -#endif /* ENCRYPTION */ -} - - int -telnet_spin() -{ - ttloop(); - return(0); -} - - char * -telnet_getenv(val) - char *val; -{ - extern char *getenv(); - return(getenv(val)); -} - - char * -telnet_gets(prompt, result, length, echo) - char *prompt; - char *result; - int length; - int echo; -{ - return((char *)0); -} -#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */ diff --git a/sbin/disklabel/disklabel.5.5 b/sbin/disklabel/disklabel.5.5 deleted file mode 100644 index fb6f6cd14d58..000000000000 --- a/sbin/disklabel/disklabel.5.5 +++ /dev/null @@ -1,384 +0,0 @@ -.\" Copyright (c) 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Symmetric Computer Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93 -.\" -.Dd June 5, 1993 -.Dt DISKLABEL 5 -.Os -.Sh NAME -.Nm disklabel -.Nd disk pack label -.Sh SYNOPSIS -.Fd #include -.Sh DESCRIPTION -Each disk or disk pack on a system may contain a disk label -which provides detailed information -about the geometry of the disk and the partitions into which the disk -is divided. -It should be initialized when the disk is formatted, -and may be changed later with the -.Xr disklabel 8 -program. -This information is used by the system disk driver and by the bootstrap -program to determine how to program the drive -and where to find the filesystems on the disk partitions. -Additional information is used by the filesystem in order -to use the disk most efficiently and to locate important filesystem information. -The description of each partition contains an identifier for the partition -type (standard filesystem, swap area, etc.). -The filesystem updates the in-core copy of the label if it contains -incomplete information about the filesystem. -.Pp -The label is located in sector number -.Dv LABELSECTOR -of the drive, usually sector 0 where it may be found -without any information about the disk geometry. -It is at an offset -.Dv LABELOFFSET -from the beginning of the sector, to allow room for the initial bootstrap. -The disk sector containing the label is normally made read-only -so that it is not accidentally overwritten by pack-to-pack copies -or swap operations; -the -.Dv DIOCWLABEL -.Xr ioctl 2 , -which is done as needed by the -.Xr disklabel -program. -.Pp -A copy of the in-core label for a disk can be obtained with the -.Dv DIOCGDINFO -.Xr ioctl ; -this works with a file descriptor for a block or character (``raw'') device -for any partition of the disk. -The in-core copy of the label is set by the -.Dv DIOCSDINFO -.Xr ioctl . -The offset of a partition cannot generally be changed while it is open, -nor can it be made smaller while it is open. -One exception is that any change is allowed if no label was found -on the disk, and the driver was able to construct only a skeletal label -without partition information. -Finally, the -.Dv DIOCWDINFO -.Xr ioctl -operation sets the in-core label and then updates the on-disk label; -there must be an existing label on the disk for this operation to succeed. -Thus, the initial label for a disk or disk pack must be installed -by writing to the raw disk. -All of these operations are normally done using -.Xr disklabel . -.Pp -The format of the disk label, as specified in -.Aw Pa sys/disklabel.h , -is -.Bd -literal -/* -* Disk description table, see disktab(5) -*/ -#define DISKTAB "/etc/disktab" - -/* -* Each disk has a label which includes information about the hardware -* disk geometry, filesystem partitions, and drive specific information. -* The label is in block 0 or 1, possibly offset from the beginning -* to leave room for a bootstrap, etc. -*/ - -#ifndef LABELSECTOR -#define LABELSECTOR 0 /* sector containing label */ -#endif - -#ifndef LABELOFFSET -#define LABELOFFSET 64 /* offset of label in sector */ -#endif - -#define DISKMAGIC ((u_long) 0x82564557) /* The disk magic number */ -#ifndef MAXPARTITIONS -#define MAXPARTITIONS 8 -#endif - -#ifndef LOCORE -struct disklabel { - u_long d_magic; /* the magic number */ - short d_type; /* drive type */ - short d_subtype; /* controller/d_type specific */ - char d_typename[16]; /* type name, e.g. "eagle" */ - /* - * d_packname contains the pack identifier and is returned when - * the disklabel is read off the disk or in-core copy. - * d_boot0 and d_boot1 are the (optional) names of the - * primary (block 0) and secondary (block 1-15) bootstraps - * as found in /usr/mdec. These are returned when using - * getdiskbyname(3) - to retrieve the values from /etc/disktab. - */ -#if defined(KERNEL) || defined(STANDALONE) - char d_packname[16]; /* pack identifier */ -#else - union { - char un_d_packname[16]; /* pack identifier */ - struct { - char *un_d_boot0; /* primary bootstrap name */ - char *un_d_boot1; /* secondary bootstrap name */ - } un_b; - } d_un; - -#define d_packname d_un.un_d_packname -#define d_boot0 d_un.un_b.un_d_boot0 -#define d_boot1 d_un.un_b.un_d_boot1 -#endif /* ! KERNEL or STANDALONE */ - - /* disk geometry: */ - u_long d_secsize; /* # of bytes per sector */ - u_long d_nsectors; /* # of data sectors per track */ - u_long d_ntracks; /* # of tracks per cylinder */ - u_long d_ncylinders; /* # of data cylinders per unit */ - u_long d_secpercyl; /* # of data sectors per cylinder */ - u_long d_secperunit; /* # of data sectors per unit */ - /* - * Spares (bad sector replacements) below - * are not counted in d_nsectors or d_secpercyl. - * Spare sectors are assumed to be physical sectors - * which occupy space at the end of each track and/or cylinder. - */ - u_short d_sparespertrack; /* # of spare sectors per track */ - u_short d_sparespercyl; /* # of spare sectors per cylinder */ - /* - * Alternate cylinders include maintenance, replacement, - * configuration description areas, etc. - */ - u_long d_acylinders; /* # of alt. cylinders per unit */ - - /* hardware characteristics: */ - /* - * d_interleave, d_trackskew and d_cylskew describe perturbations - * in the media format used to compensate for a slow controller. - * Interleave is physical sector interleave, set up by the formatter - * or controller when formatting. When interleaving is in use, - * logically adjacent sectors are not physically contiguous, - * but instead are separated by some number of sectors. - * It is specified as the ratio of physical sectors traversed - * per logical sector. Thus an interleave of 1:1 implies contiguous - * layout, while 2:1 implies that logical sector 0 is separated - * by one sector from logical sector 1. - * d_trackskew is the offset of sector 0 on track N - * relative to sector 0 on track N-1 on the same cylinder. - * Finally, d_cylskew is the offset of sector 0 on cylinder N - * relative to sector 0 on cylinder N-1. - */ - u_short d_rpm; /* rotational speed */ - u_short d_interleave; /* hardware sector interleave */ - u_short d_trackskew; /* sector 0 skew, per track */ - u_short d_cylskew; /* sector 0 skew, per cylinder */ - u_long d_headswitch; /* head switch time, usec */ - u_long d_trkseek; /* track-to-track seek, usec */ - u_long d_flags; /* generic flags */ -#define NDDATA 5 - u_long d_drivedata[NDDATA]; /* drive-type specific information */ -#define NSPARE 5 - u_long d_spare[NSPARE]; /* reserved for future use */ - u_long d_magic2; /* the magic number (again) */ - u_short d_checksum; /* xor of data incl. partitions */ - - /* filesystem and partition information: */ - u_short d_npartitions; /* number of partitions in following */ - u_long d_bbsize; /* size of boot area at sn0, bytes */ - u_long d_sbsize; /* max size of fs superblock, bytes */ - struct partition { /* the partition table */ - u_long p_size; /* number of sectors in partition */ - u_long p_offset; /* starting sector */ - u_long p_fsize; /* filesystem basic fragment size */ - u_char p_fstype; /* filesystem type, see below */ - u_char p_frag; /* filesystem fragments per block */ - union { - u_short cpg; /* UFS: FS cylinders per group */ - u_short sgs; /* LFS: FS segment shift */ - } __partition_u1; -#define p_cpg __partition_u1.cpg -#define p_sgs __partition_u1.sgs - u_short p_cpg; /* filesystem cylinders per group */ - } d_partitions[MAXPARTITIONS]; /* actually may be more */ -}; - -/* d_type values: */ -#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ -#define DTYPE_MSCP 2 /* MSCP */ -#define DTYPE_DEC 3 /* other DEC (rk, rl) */ -#define DTYPE_SCSI 4 /* SCSI */ -#define DTYPE_ESDI 5 /* ESDI interface */ -#define DTYPE_ST506 6 /* ST506 etc. */ -#define DTYPE_HPIB 7 /* CS/80 on HP-IB */ -#define DTYPE_HPFL 8 /* HP Fiber-link */ -#define DTYPE_FLOPPY 10 /* floppy */ - -#ifdef DKTYPENAMES -static char *dktypenames[] = { - "unknown", - "SMD", - "MSCP", - "old DEC", - "SCSI", - "ESDI", - "ST506", - "HP-IB", - "HP-FL", - "type 9", - "floppy", - 0 -}; -#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1) -#endif - -/* -* Filesystem type and version. -* Used to interpret other filesystem-specific -* per-partition information. -*/ -#define FS_UNUSED 0 /* unused */ -#define FS_SWAP 1 /* swap */ -#define FS_V6 2 /* Sixth Edition */ -#define FS_V7 3 /* Seventh Edition */ -#define FS_SYSV 4 /* System V */ -#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */ -#define FS_V8 6 /* Eighth Edition, 4K blocks */ -#define FS_BSDFFS 7 /* 4.2BSD fast file system */ -#define FS_MSDOS 8 /* MSDOS file system */ -#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */ -#define FS_OTHER 10 /* in use, but unknown/unsupported */ -#define FS_HPFS 11 /* OS/2 high-performance file system */ -#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */ -#define FS_BOOT 13 /* partition contains bootstrap */ - -#ifdef DKTYPENAMES -static char *fstypenames[] = { - "unused", - "swap", - "Version 6", - "Version 7", - "System V", - "4.1BSD", - "Eighth Edition", - "4.2BSD", - "MSDOS", - "4.4LFS", - "unknown", - "HPFS", - "ISO9660", - "boot", - 0 -}; -#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) -#endif - -/* -* flags shared by various drives: -*/ -#define D_REMOVABLE 0x01 /* removable media */ -#define D_ECC 0x02 /* supports ECC */ -#define D_BADSECT 0x04 /* supports bad sector forw. */ -#define D_RAMDISK 0x08 /* disk emulator */ -#define D_CHAIN 0x10 /* can do back-back transfers */ - -/* -* Drive data for SMD. -*/ - -#define d_smdflags d_drivedata[0] -#define D_SSE 0x1 /* supports skip sectoring */ -#define d_mindist d_drivedata[1] -#define d_maxdist d_drivedata[2] -#define d_sdist d_drivedata[3] - -/* -* Drive data for ST506. -*/ -#define d_precompcyl d_drivedata[0] -#define d_gap3 d_drivedata[1] /* used only when formatting */ - -/* - * Drive data for SCSI. - */ -#define d_blind d_drivedata[0] - -#ifndef LOCORE -/* -* Structure used to perform a format -* or other raw operation, returning data -* and/or register values. -* Register identification and format -* are device- and driver-dependent. -*/ -struct format_op { - char *df_buf; - int df_count; /* value-result */ - daddr_t df_startblk; - int df_reg[8]; /* result */ -}; - -/* -* Structure used internally to retrieve -* information about a partition on a disk. -*/ -struct partinfo { - struct disklabel *disklab; - struct partition *part; -}; - -/* -* Disk-specific ioctls. -*/ - /* get and set disklabel; DIOCGPART used internally */ -#define DIOCGDINFO _IOR('d', 101, struct disklabel) /* get */ -#define DIOCSDINFO _IOW('d', 102, struct disklabel) /* set */ -#define DIOCWDINFO _IOW('d', 103, struct disklabel) /* set, update disk */ -#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ - -/* do format operation, read or write */ -#define DIOCRFORMAT _IOWR('d', 105, struct format_op) -#define DIOCWFORMAT _IOWR('d', 106, struct format_op) - -#define DIOCSSTEP _IOW('d', 107, int) /* set step rate */ -#define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */ -#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ - -#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */ - -#endif LOCORE -.Ed -.Sh SEE ALSO -.Xr disktab 5 , -.Xr disklabel 8 -.Sh HISTORY diff --git a/sbin/fastboot/fastboot.8 b/sbin/fastboot/fastboot.8 deleted file mode 100644 index 2f6ac829da99..000000000000 --- a/sbin/fastboot/fastboot.8 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)fastboot.8 8.1 (Berkeley) 6/5/93 -.\" -.Dd June 5, 1993 -.Dt FASTBOOT 8 -.Os BSD 4.2 -.Sh NAME -.Nm fastboot , -.Nm fasthalt -.Nd "reboot/halt the system without checking the disks" -.Sh SYNOPSIS -.Nm fastboot -.Op Ar boot-options -.Nm fasthalt -.Op Ar halt-options -.Sh DESCRIPTION -.Nm Fastboot -and -.Nm fasthalt -are shell scripts which reboot and halt the system without -checking the file systems. This is done by creating a -file -.Pa /fastboot , -then invoking the -.Xr reboot -program. The system startup script, -.Pa /etc/rc , -looks for this file and, if present, skips the normal -invocation of -.Xr fsck 8 . -.Sh SEE ALSO -.Xr halt 8 , -.Xr reboot 8 , -.Xr rc 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/sbin/scsiformat/scsiformat.c b/sbin/scsiformat/scsiformat.c deleted file mode 100644 index a185a8ee154c..000000000000 --- a/sbin/scsiformat/scsiformat.c +++ /dev/null @@ -1,664 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)scsiformat.c 5.5 (Berkeley) 4/2/94 - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)scsiformat.c 5.5 (Berkeley) 4/2/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include - -#define COMPAT_HPSCSI - -#include -#include -#include -#include -#include -#include - -int fd; -char *device; - -void scsi_str __P((char *, char *, int)); -void do_command __P((int, struct scsi_cdb *, void *, int)); -void do_format __P((void)); -void print_capacity __P((void)); -void print_inquiry __P((void)); -void prflags __P((int, const char *)); -u_char *print_mode_page __P((u_char *)); -void print_mode_sense __P((void)); -void usage __P((void)); - -#define N2(c, d) (((c) << 8) | (d)) -#define N3(b, c, d) (((b) << 16) | N2(c, d)) -#define N4(a, b, c, d) (((a) << 24) | N3(b, c, d)) - -int sense_pctl; - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - int ch, readonly; - - readonly = 0; - sense_pctl = SCSI_MSENSE_PCTL_CUR; - while ((ch = getopt(argc, argv, "rp:")) != EOF) { - switch(ch) { - case 'r': - readonly = 1; - break; - case 'p': /* mode sense page control */ - switch (*optarg) { - case 'c': - sense_pctl = SCSI_MSENSE_PCTL_CUR; - break; - case 'd': - sense_pctl = SCSI_MSENSE_PCTL_DFLT; - break; - case 's': - sense_pctl = SCSI_MSENSE_PCTL_SAVED; - break; - case 'v': - (void)printf( - "*** note: for variable parameters, 1-bit means ``can write here''\n"); - sense_pctl = SCSI_MSENSE_PCTL_VAR; - break; - } - /* FALLTHROUGH */ - case '?': - default: - usage(); - } - } - argc -= optind; - argv += optind; - - if (argc != 1) - usage(); - - device = *argv; - fd = open(device, readonly ? O_RDONLY : O_RDWR, 0); - if (fd < 0) { - (void)fprintf(stderr, - "scsiformat: %s: %s\n", device, strerror(errno)); - exit(1); - } - print_inquiry(); - print_capacity(); - print_mode_sense(); - - if (!readonly) - do_format(); - exit(0); -} - -/* - * Copy a counted string, trimming trailing blanks, and turning the - * result into a C-style string. - */ -void -scsi_str(src, dst, len) - register char *src, *dst; - register int len; -{ - - while (src[len - 1] == ' ') { - if (--len == 0) { - *dst = 0; - return; - } - } - bcopy(src, dst, len); - dst[len] = 0; -} - -void -print_inquiry() -{ - register struct scsi_inq_ansi *si; - int ver; - struct scsi_inquiry inqbuf; - char vendor[10], product[17], rev[5]; - static struct scsi_cdb inq = { - CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 - }; - - do_command(fd, &inq, &inqbuf, sizeof(inqbuf)); - (void)printf("%s: ", device); - - ver = (inqbuf.si_version >> VER_ANSI_SHIFT) & VER_ANSI_MASK; - if (ver != 1 && ver != 2) { - (void)printf("type 0x%x, qual 0x%x, ver 0x%x (ansi %d)\n", - inqbuf.si_type, inqbuf.si_qual, inqbuf.si_version, ver); - return; - } - si = (struct scsi_inq_ansi *)&inqbuf; - switch (si->si_type & TYPE_TYPE_MASK) { - - case TYPE_DAD: - (void)printf("(disk)"); - break; - - case TYPE_WORM: - (void)printf("(WORM)"); - break; - - case TYPE_ROM: - (void)printf("(CD-ROM)"); - break; - - case TYPE_MO: - (void)printf("(MO-DISK)"); - break; - - case TYPE_JUKEBOX: - (void)printf("(jukebox)"); - break; - - default: - (void)printf("(??)"); - break; - } - scsi_str(si->si_vendor, vendor, sizeof(si->si_vendor)); - scsi_str(si->si_product, product, sizeof(si->si_product)); - scsi_str(si->si_rev, rev, sizeof(si->si_rev)); - (void)printf(" %s %s rev %s:", vendor, product, rev); -} - -void -print_capacity() -{ - struct scsi_rc rc; /* for READ CAPACITY */ - static struct scsi_cdb cap = { CMD_READ_CAPACITY }; - - do_command(fd, &cap, &rc, sizeof(rc)); - (void)printf(" %d blocks of %d bytes each\n", - N4(rc.rc_lbah, rc.rc_lbahm, rc.rc_lbalm, rc.rc_lbal) + 1, - N4(rc.rc_blh, rc.rc_blhm, rc.rc_bllm, rc.rc_bll)); -} - -void -print_mode_sense() -{ - register u_char *cp, *ep; - register struct scsi_ms_bd *bd; - register int n, i, l, len, bdlen; -#ifdef TEN_BYTE_SENSE - struct { - struct scsi_ms10 ms; - u_char p[1023 - sizeof(struct scsi_ms10)]; - } msbuf; - static struct scsi_cdb modesense = { - CMD_MODE_SENSE10, SCSI_MSENSE_DBD, 0, 0, 0, 0, 0, - sizeof(msbuf) >> 8, sizeof (msbuf), 0 - }; - - CDB10(&modesense)->cdb_lbam = sense_pctl | SCSI_MS_PC_ALL; - do_command(fd, &modesense, &msbuf, sizeof(msbuf)); - len = N2(msbuf.ms.ms_lenh, msbuf.ms.ms_lenl); - bdlen = N2(msbuf.ms.ms_bdlh, msbuf.ms.ms_bdll); -#else - struct { - struct scsi_ms6 ms; - u_char p[255 - sizeof(struct scsi_ms6)]; - } msbuf; - static struct scsi_cdb modesense = { - CMD_MODE_SENSE6, 0, 0, 0, sizeof(msbuf), 0 - }; - - CDB6(&modesense)->cdb_lbam = sense_pctl | SCSI_MS_PC_ALL; - do_command(fd, &modesense, &msbuf, sizeof(msbuf)); - len = msbuf.ms.ms_len; - bdlen = msbuf.ms.ms_bdl; -#endif - (void)printf("\n%d bytes of mode sense data. ", len); - (void)printf("medium type 0x%x, %swrite protected\n", - msbuf.ms.ms_mt, msbuf.ms.ms_dsp & SCSI_MS_DSP_WP ? "" : "not "); - if ((n = bdlen) != 0) { - bd = (struct scsi_ms_bd *)msbuf.p; - for (n /= sizeof(*bd); --n >= 0; bd++) { - (void)printf("\tdensity code 0x%x, ", bd->bd_dc); - i = N3(bd->bd_nbh, bd->bd_nbm, bd->bd_nbl); - l = N3(bd->bd_blh, bd->bd_blm, bd->bd_bll); - if (i) - (void)printf("%d blocks of length %d\n", i, l); - else - (void)printf("all blocks of length %d\n", l); - } - } - /* - * Sense header lengths includes the sense header, while mode page - * lengths do not ... let's hear it for consistency! - */ - cp = msbuf.p + bdlen; - ep = msbuf.p + len - sizeof(msbuf.ms); - while (cp < ep) - cp = print_mode_page(cp); -} - -void -prflags(v, cp) - int v; - register const char *cp; -{ - register const char *np; - char f, sep; - - for (sep = '<'; (f = *cp++) != 0; cp = np) { - for (np = cp; *np >= ' ';) - np++; - if ((v & (1 << (f - 1))) == 0) - continue; - printf("%c%.*s", sep, np - cp, cp); - sep = ','; - } - if (sep != '<') - putchar('>'); -} - -static char * -cache_policy(x) - int x; -{ - static char rsvd[30]; - - switch (x) { - - case SCSI_CACHE_DEFAULT: - return ("default"); - - case SCSI_CACHE_KEEPPF: - return ("toss cmd data, save prefetch"); - - case SCSI_CACHE_KEEPCMD: - return ("toss prefetch data, save cmd"); - - default: - (void)sprintf(rsvd, "reserved %d", x); - return (rsvd); - } - /* NOTREACHED */ -} - -u_char * -print_mode_page(cp) - u_char *cp; -{ - register struct scsi_ms_page_hdr *mp; - int len, code, i; - u_char *tp; - const char *s; - - mp = (struct scsi_ms_page_hdr *)cp; - code = mp->mp_psc & SCSI_MS_PC_MASK; - len = mp->mp_len; - (void)printf("\npage type %d%s (%d bytes): ", - code, mp->mp_psc & SCSI_MS_MP_SAVEABLE ? " (saveable)" : "", len); - switch (code) { - - case SCSI_MS_PC_RWERRREC: -#define rw ((struct scsi_page_rwerrrec *)(mp + 1)) - (void)printf("Read/Write Error Recovery parameters.\n"); - (void)printf("\tflags = 0x%x", rw->rw_flags); - prflags(rw->rw_flags, - "\10AWRE\7ARRE\6TB\5RC\4EER\3PER\2DTE\1DCR"); - (void)printf(",\n\t%d read retries, %d correction span bits,\n", - rw->rw_read_retry, rw->rw_corr_span); - (void)printf("\t%d head offsets, %d data strobe offsets%s\n", - rw->rw_hd_off, rw->rw_ds_off, len > 6 ? "," : "."); - if (len <= 6) - break; - (void)printf("\t%d write retries, ", rw->rw_write_retry); - i = N2(rw->rw_rtlh, rw->rw_rtll); - if (i != 0xffff) - (void)printf("%d", i); - else - (void)printf("no"); - (void)printf(" recovery time limit.\n"); - break; -#undef rw - - case SCSI_MS_PC_DR: -#define dr ((struct scsi_page_dr *)(mp + 1)) - (void)printf("Disconnect/Reconnect control.\n"); - (void)printf("\tbuffer full ratio %d, buffer empty ratio %d,\n", - dr->dr_full, dr->dr_empty); - (void)printf("\ttime limits: %d bus inactivity, ", - N2(dr->dr_inacth, dr->dr_inactl)); - (void)printf("%d disconnect, %d connect.\n", - N2(dr->dr_disconh, dr->dr_disconl), - N2(dr->dr_conh, dr->dr_conl)); - (void)printf("\tmaximum burst size %d,\n", - N2(dr->dr_bursth, dr->dr_burstl)); - switch (dr->dr_dtdc & SCSI_DR_DTDC_MASK) { - case SCSI_DR_DTDC_NONE: - s = "never"; - break; - case SCSI_DR_DTDC_NOTDATA: - s = "during data transfer"; - break; - case SCSI_DR_DTDC_RSVD: - s = "???"; - break; - case SCSI_DR_DTDC_NOTD2: - s = "during and after data transfer"; - break; - } - (void)printf("\tsuppress disconnect %s.\n", s); - break; -#undef dr - - case SCSI_MS_PC_FMT: -#define fmt ((struct scsi_page_fmt *)(mp + 1)) - (void)printf("Format parameters.\n"); - (void)printf("\t%d tracks/zone, %d alt.sect./zone, ", - N2(fmt->fmt_tpzh, fmt->fmt_tpzl), - N2(fmt->fmt_aspzh, fmt->fmt_aspzl)); - (void)printf("%d alt.tracks/zone,\n\t%d alt.tracks/vol., ", - N2(fmt->fmt_atpzh, fmt->fmt_atpzl), - N2(fmt->fmt_atpvh, fmt->fmt_atpvl)); - (void)printf("%d sectors/track, %d bytes/phys.sector,\n", - N2(fmt->fmt_spth, fmt->fmt_sptl), - N2(fmt->fmt_dbppsh, fmt->fmt_dbppsl)); - (void)printf("\tinterleave %d, track skew %d, cyl.skew %d,\n", - N2(fmt->fmt_ilh, fmt->fmt_ill), - N2(fmt->fmt_tsfh, fmt->fmt_tsfl), - N2(fmt->fmt_csfh, fmt->fmt_csfl)); - (void)printf("\tdrive flags 0x%x", fmt->fmt_flags); - prflags(fmt->fmt_flags, "\10SSEC\7HSEC\6RMB\5SURF"); - (void)printf(".\n"); - break; -#undef fmt - - case SCSI_MS_PC_RDGEOM: -#define rd ((struct scsi_page_rdgeom *)(mp + 1)) - (void)printf("Disk Geometry parameters.\n"); - (void)printf("\t%d cylinders, %d heads,\n", - N3(rd->rd_ncylh, rd->rd_ncylm, rd->rd_ncyll), - rd->rd_nheads); - (void)printf("\tstart write precompensation at cyl %d,\n", - N3(rd->rd_wpcylh, rd->rd_wpcylm, rd->rd_wpcyll)); - (void)printf("\tstart reduced write current at cyl %d,\n", - N3(rd->rd_rwcylh, rd->rd_rwcylm, rd->rd_rwcyll)); - (void)printf("\tseek step rate %f us, landing zone cyl %d,\n", - N2(rd->rd_steph, rd->rd_stepl) * 0.1, - N3(rd->rd_lcylh, rd->rd_lcylm, rd->rd_lcyll)); - switch (rd->rd_rpl & SCSI_RD_RPL_MASK) { - case SCSI_RD_RPL_NONE: - s = "disabled or unsupported"; - break; - case SCSI_RD_RPL_SLAVE: - s = "slave"; - break; - case SCSI_RD_RPL_MASTER: - s = "master"; - break; - case SCSI_RD_RPL_MCONTROL: - s = "master control"; - break; - } - (void)printf("\trotational synch %s, offset %d/256%s\n", - s, rd->rd_roff, len > 18 ? "," : "."); - if (len > 18) - (void)printf("\trotation %d rpm.\n", - N2(rd->rd_rpmh, rd->rd_rpml)); - break; -#undef rd - - case SCSI_MS_PC_VERRREC: -#define v ((struct scsi_page_verrrec *)(mp + 1)) - (void)printf("Verify Error Recovery parameters.\n"); - (void)printf("\tflags = 0x%x", v->v_flags); - prflags(v->v_flags, "\4EER\3PER\2DTE\1DCR"); - (void)printf(",\n\t%d verify retries, %d %s span bits,\n\t", - v->v_verify_retry, v->v_corr_span, "correction"); - (void)printf("%d recovery time limit.\n", - N2(v->v_rtlh, v->v_rtll)); - break; -#undef v - - case SCSI_MS_PC_CACHE: -#define cache ((struct scsi_page_cache *)(mp + 1)) - (void)printf("Caching Page.\n"); - (void)printf("\tflags = 0x%x", cache->cache_flags); - prflags(cache->cache_flags, "\3WCE\2MF\1RCD"); - (void)printf( - ",\n\tread retention = %s, write retention = %s,\n", - cache_policy(SCSI_CACHE_RDPOLICY(cache->cache_reten)), - cache_policy(SCSI_CACHE_WRPOLICY(cache->cache_reten))); - (void)printf("\tdisable prefetch transfer length = %d,\n", - N2(cache->cache_dptlh, cache->cache_dptll)); - (void)printf("\tmin prefetch = %d, max prefetch = %d, ", - N2(cache->cache_minpfh, cache->cache_minpfl), - N2(cache->cache_maxpfh, cache->cache_maxpfl)); - (void)printf("max prefetch ceiling = %d.\n", - N2(cache->cache_mpch, cache->cache_mpcl)); - break; -#undef cache - - case SCSI_MS_PC_CTLMODE: -#define cm ((struct scsi_page_ctlmode *)(mp + 1)) - (void)printf("Control Mode Page.\n"); - (void)printf("\t%s report log-activity error conditions,\n", - cm->cm_rlec & SCSI_CM_RLEC ? "do" : "do not"); - (void)printf("\tqueue algorithm modifier = %d, flags = 0x%x", - SCSI_CM_QMOD(cm->cm_qctl), - cm->cm_qctl & (SCSI_CM_QERR|SCSI_CM_DQUE)); - prflags(cm->cm_qctl, "\2QERR\1DQUE"); - (void)printf(",\n\tECA/AEN flags = 0x%x", cm->cm_ecaaen); - prflags(cm->cm_ecaaen, "\10ECA\3RAENP\2UUAENP\1EAENP"); - (void)printf(", AEN holdoff period = %d ms.\n", - N2(cm->cm_aenholdh, cm->cm_aenholdl)); - break; -#undef cm - - /* - * Vendor Unique, but what the heck. - */ - case SCSI_MS_PC_CDCCACHECTL: -#define ccm ((struct scsi_page_CDCcachectlmode *)(mp + 1)) - (void)printf("CDC-specific Cache Control Mode Page.\n"); - (void)printf("\tflags = 0x%x", ccm->ccm_flags); - prflags(ccm->ccm_flags, "\7WIE\5ENABLE"); - (void)printf(", table size = %d, prefetch threshold = %d\n", - SCSI_CDC_CCM_TBLSZ(ccm->ccm_flags), - ccm->ccm_pfthresh); - (void)printf("\tmaximum %s = %d, maximum %s = %d,\n", - "threshold", ccm->ccm_maxthresh, - "prefetch multiplier", ccm->ccm_maxpfmult); - (void)printf("\tminimum %s = %d, minimum %s = %d.\n", - "threshold", ccm->ccm_minthresh, - "prefetch multiplier", ccm->ccm_minpfmult); - break; -#undef ccm - - default: - (void)printf("Unknown page type."); - for (tp = cp + sizeof(*mp), i = 0; i < len; ++i) { - if ((i & 7) == 0) - (void)printf("\n\t%2d: ", i); - (void)printf(" %02x", *tp++); - } - (void)printf(".\n"); - break; - } - return (cp + sizeof(*mp) + len); -} - -void -pr_sense(fd) - int fd; -{ - static struct scsi_fmt_sense s; - register struct scsi_sense *sn; - - if (ioctl(fd, SDIOCSENSE, &s) < 0) - (void)fprintf(stderr, - "scsiformat: SDIOCSENSE: %s\n", strerror(errno)); - - (void)printf("scsi status 0x%x", s.status); - if (s.status & STS_CHECKCOND) { - sn = (struct scsi_sense *)s.sense; - - (void)printf(" sense class %d, code %d", - SENSE_ECLASS(sn), SENSE_ECODE(sn)); - if (SENSE_ISXSENSE(sn)) { - (void)printf(", key %d", XSENSE_KEY(sn)); - if (XSENSE_IVALID(sn)) - (void)printf(", blk %d", XSENSE_INFO(sn)); - } - } - (void)printf("\n"); -} - -void -do_format() -{ - struct { - struct scsi_ms6 ms; /* mode select header */ - struct scsi_ms_bd bd; /* block descriptor */ - struct scsi_ms_page_hdr mp; /* ctl mode page hdr */ - struct scsi_page_ctlmode cm; /* ctl mode page */ - u_char pad[4]; /* ??? */ - } msel; - u_char fmtbuf[128]; - static struct scsi_cdb modeselect = { - CMD_MODE_SELECT6, - SCSI_MSEL_SCSI2_DATA | SCSI_MSEL_SAVEPAGES, 0, 0, - sizeof(msel), 0 - }; - static struct scsi_cdb format = { CMD_FORMAT_UNIT }; - - /* want mostly 0s; set them all zero here */ - bzero(&msel, sizeof(msel)); - - /* one block descriptor */ - msel.ms.ms_bdl = sizeof(struct scsi_ms_bd); - - /* block length = 512 bytes */ - msel.bd.bd_blm = 512 / 256; - msel.bd.bd_bll = 512 % 256; - - /* - * In the following, the mystery pad region is copied from - * the original driver. I have no idea what it is for. - * (Anyone got SCSI-2 documents?) - */ - - /* mode page parameters: report log-activity exception conditions */ - msel.mp.mp_psc = SCSI_MS_PC_CTLMODE; - msel.mp.mp_len = sizeof(msel.cm) + sizeof(msel.pad); - msel.cm.cm_rlec = SCSI_CM_RLEC; - - do_command(fd, &modeselect, &msel, sizeof(msel)); - - bzero(fmtbuf, sizeof(fmtbuf)); - do_command(fd, &format, fmtbuf, sizeof(fmtbuf)); -} - -void -do_command(fd, cdb, buf, len) - int fd; - struct scsi_cdb *cdb; - void *buf; - int len; -{ - static int on = 1, off = 0; - int user, ret; - - bzero(buf, len); - if (ioctl(fd, SDIOCSFORMAT, &on) < 0) { - (void)fprintf(stderr, - "scsiformat: SDIOCSFORMAT (on): %s\n", strerror(errno)); - if (ioctl(fd, SDIOCGFORMAT, &user) == 0 && user != 0) - (void)fprintf(stderr, "scsiformat: pid %d has it\n", - user); - return; - } - ret = ioctl(fd, SDIOCSCSICOMMAND, cdb); -#ifdef COMPAT_HPSCSI - if (ret < 0) { - static const char scsicmdlen[8] = { 6, 10, 0, 0, 0, 12, 0, 0 }; -#define SCSICMDLEN(cmd) scsicmdlen[(cmd) >> 5] - struct scsi_fmt_cdb { - int len; - u_char cdb[28]; - } sc; -#define OSDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb) - - sc.len = SCSICMDLEN(cdb->cdb_bytes[0]); - bcopy(cdb->cdb_bytes, sc.cdb, sc.len); - ret = ioctl(fd, OSDIOCSCSICOMMAND, &sc); - } -#endif - if (ret < 0) - (void)fprintf(stderr, - "scsiformat: SDIOCSCSICOMMAND: %s\n", strerror(errno)); - else if (read(fd, buf, len) < 0) { - (void)fprintf(stderr, - "scsiformat: read: %s\n", strerror(errno)); - pr_sense(fd); - } - - if (ioctl(fd, SDIOCSFORMAT, &off) < 0) - (void)fprintf(stderr, - "scsiformat: SDIOCSFORMAT (off): %s\n", strerror(errno)); -} - -void -usage() -{ - (void)fprintf(stderr, "usage: scsiformat [-r] [-p c|d|s|v] device\n"); - exit(1); -} diff --git a/secure/usr.bin/telnet/krb4-proto.h b/secure/usr.bin/telnet/krb4-proto.h deleted file mode 100644 index 75f6d4122e94..000000000000 --- a/secure/usr.bin/telnet/krb4-proto.h +++ /dev/null @@ -1,207 +0,0 @@ -#ifdef __STDC__ -# define P(s) s -#else -# define P(s) () -#endif - -/* add_ticket.c */ -int add_ticket P((KTEXT , int , char *, int , char *, char *, char *, int , KTEXT )); - -/* cr_err_reply.c */ -void cr_err_reply P((KTEXT , char *, char *, char *, u_long , u_long , char *)); - -/* create_auth_reply.c */ -KTEXT create_auth_reply P((char *, char *, char *, long , int , unsigned long , int , KTEXT )); - -/* create_ciph.c */ -int create_ciph P((KTEXT , C_Block , char *, char *, char *, unsigned long , int , KTEXT , unsigned long , C_Block )); - -/* create_death_packet.c */ -KTEXT krb_create_death_packet P((char *)); - -/* create_ticket.c */ -int krb_create_ticket P((KTEXT , unsigned int , char *, char *, char *, long , char *, int , long , char *, char *, C_Block )); - -/* debug_decl.c */ - -/* decomp_ticket.c */ -int decomp_ticket P((KTEXT , unsigned char *, char *, char *, char *, unsigned long *, C_Block , int *, unsigned long *, char *, char *, C_Block , Key_schedule )); - -/* dest_tkt.c */ -int dest_tkt P((void )); - -/* extract_ticket.c */ -int extract_ticket P((KTEXT , int , char *, int *, int *, char *, KTEXT )); - -/* fgetst.c */ -int fgetst P((FILE *, char *, int )); - -/* get_ad_tkt.c */ -int get_ad_tkt P((char *, char *, char *, int )); - -/* get_admhst.c */ -int krb_get_admhst P((char *, char *, int )); - -/* get_cred.c */ -int krb_get_cred P((char *, char *, char *, CREDENTIALS *)); - -/* get_in_tkt.c */ -int krb_get_pw_in_tkt P((char *, char *, char *, char *, char *, int , char *)); -int placebo_read_password P((des_cblock *, char *, int )); -int placebo_read_pw_string P((char *, int , char *, int )); - -/* get_krbhst.c */ -int krb_get_krbhst P((char *, char *, int )); - -/* get_krbrlm.c */ -int krb_get_lrealm P((char *, int )); - -/* get_phost.c */ -char *krb_get_phost P((char *)); - -/* get_pw_tkt.c */ -int get_pw_tkt P((char *, char *, char *, char *)); - -/* get_request.c */ -int get_request P((KTEXT , int , char **, char **)); - -/* get_svc_in_tkt.c */ -int krb_get_svc_in_tkt P((char *, char *, char *, char *, char *, int , char *)); - -/* get_tf_fullname.c */ -int krb_get_tf_fullname P((char *, char *, char *, char *)); - -/* get_tf_realm.c */ -int krb_get_tf_realm P((char *, char *)); - -/* getopt.c */ -int getopt P((int , char **, char *)); - -/* getrealm.c */ -char *krb_realmofhost P((char *)); - -/* getst.c */ -int getst P((int , char *, int )); - -/* in_tkt.c */ -int in_tkt P((char *, char *)); - -/* k_gethostname.c */ -int k_gethostname P((char *, int )); - -/* klog.c */ -char *klog P((int , char *, int , int , int , int , int , int , int , int , int , int )); -int kset_logfile P((char *)); - -/* kname_parse.c */ -int kname_parse P((char *, char *, char *, char *)); -int k_isname P((char *)); -int k_isinst P((char *)); -int k_isrealm P((char *)); - -/* kntoln.c */ -int krb_kntoln P((AUTH_DAT *, char *)); - -/* krb_err_txt.c */ - -/* krb_get_in_tkt.c */ -int krb_get_in_tkt P((char *, char *, char *, char *, char *, int , int (*key_proc )(), int (*decrypt_proc )(), char *)); - -/* kuserok.c */ -int kuserok P((AUTH_DAT *, char *)); - -/* log.c */ -void log P((char *, int , int , int , int , int , int , int , int , int , int )); -int set_logfile P((char *)); -int new_log P((long , char *)); - -/* mk_err.c */ -long krb_mk_err P((u_char *, long , char *)); - -/* mk_priv.c */ -long krb_mk_priv P((u_char *, u_char *, u_long , Key_schedule , C_Block , struct sockaddr_in *, struct sockaddr_in *)); - -/* mk_req.c */ -int krb_mk_req P((KTEXT , char *, char *, char *, long )); -int krb_set_lifetime P((int )); - -/* mk_safe.c */ -long krb_mk_safe P((u_char *, u_char *, u_long , C_Block *, struct sockaddr_in *, struct sockaddr_in *)); - -/* month_sname.c */ -char *month_sname P((int )); - -/* netread.c */ -int krb_net_read P((int , char *, int )); - -/* netwrite.c */ -int krb_net_write P((int , char *, int )); - -/* one.c */ - -/* pkt_cipher.c */ -KTEXT pkt_cipher P((KTEXT )); - -/* pkt_clen.c */ -int pkt_clen P((KTEXT )); - -/* rd_err.c */ -int krb_rd_err P((u_char *, u_long , long *, MSG_DAT *)); - -/* rd_priv.c */ -long krb_rd_priv P((u_char *, u_long , Key_schedule , C_Block , struct sockaddr_in *, struct sockaddr_in *, MSG_DAT *)); - -/* rd_req.c */ -int krb_set_key P((char *, int )); -int krb_rd_req P((KTEXT , char *, char *, long , AUTH_DAT *, char *)); - -/* rd_safe.c */ -long krb_rd_safe P((u_char *, u_long , C_Block *, struct sockaddr_in *, struct sockaddr_in *, MSG_DAT *)); - -/* read_service_key.c */ -int read_service_key P((char *, char *, char *, int , char *, char *)); - -/* recvauth.c */ -int krb_recvauth P((long , int , KTEXT , char *, char *, struct sockaddr_in *, struct sockaddr_in *, AUTH_DAT *, char *, Key_schedule , char *)); - -/* save_credentials.c */ -int save_credentials P((char *, char *, char *, C_Block , int , int , KTEXT , long )); - -/* send_to_kdc.c */ -int send_to_kdc P((KTEXT , KTEXT , char *)); - -/* sendauth.c */ -int krb_sendauth P((long , int , KTEXT , char *, char *, char *, u_long , MSG_DAT *, CREDENTIALS *, Key_schedule , struct sockaddr_in *, struct sockaddr_in *, char *)); -int krb_sendsvc P((int , char *)); - -/* setenv.c */ -int setenv P((char *, char *, int )); -void unsetenv P((char *)); -char *getenv P((char *)); -char *_findenv P((char *, int *)); - -/* stime.c */ -char *stime P((long *)); - -/* tf_shm.c */ -int krb_shm_create P((char *)); -int krb_is_diskless P((void )); -int krb_shm_dest P((char *)); - -/* tf_util.c */ -int tf_init P((char *, int )); -int tf_get_pname P((char *)); -int tf_get_pinst P((char *)); -int tf_get_cred P((CREDENTIALS *)); -int tf_close P((void )); -int tf_save_cred P((char *, char *, char *, C_Block , int , int , KTEXT , long )); - -/* tkt_string.c */ -char *tkt_string P((void )); -void krb_set_tkt_string P((char *)); - -/* util.c */ -int ad_print P((AUTH_DAT *)); -int placebo_cblock_print P((des_cblock )); - -#undef P diff --git a/share/doc/psd/00.contents b/share/doc/psd/00.contents deleted file mode 100644 index 3866526be5af..000000000000 --- a/share/doc/psd/00.contents +++ /dev/null @@ -1,191 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)00.contents 8.1 (Berkeley) 6/8/93 -.\" -.OH '''PSD Contents' -.EH 'PSD Contents''' -.TL -UNIX Programmer's Supplementary Documents (PSD) -.sp -\s-24.4 Berkeley Software Distribution\s+2 -.sp -\fRJune, 1993\fR -.PP -This volume contains documents which supplement the manual pages in -.I -The -.UX -Programmer's Reference Manual -.R -for the 4.4BSD system as distributed by U.C. Berkeley. -.SH -Documents of Historical Interest -.IP -.tl 'The Unix Time\-Sharing System''PSD:1' -.QP -Dennis Ritchie and Ken Thompson's original paper about UNIX, reprinted -from Communications of the ACM. - -.IP -.tl 'Unix Implementation''PSD:2' -.QP -Ken Thompson's description of the implementation of the Version 7 -kernel and file system. - -.IP -.tl 'The Unix I/O System''PSD:3' -.QP -Dennis Ritchie's overview of the I/O System of Version 7; still helpful for -those writing device drivers. - -.IP -.tl 'Unix Programming \- Second Edition ''PSD:4' -.QP -Describes the programming interface to the UNIX version 7 operating -system and the standard I/O library. Should be supplemented by -Kernighan and Pike, ``The UNIX Programming Environment'', -Prentice-Hall, 1984 and especially by the Programmer Reference Manual -section 2 (system calls) and 3 (library routines). - -.IP -.tl 'Berkeley Software Architecture Manual (4.4 Edition)''PSD:5' -.QP -A concise and terse description of the system call interface -provided in Berkeley Unix, as revised for 4.4BSD. -This will never be a best seller. - -.SH -Languages in common use -.IP -.tl 'The C Programming Language \- Reference Manual''PSD:6' -.QP -Official statement of the syntax of C. -Should be supplemented by ``The C Programming Language,'' -B.W. Kernighan and D.M. Ritchie, Prentice-Hall, 1978, that -contains a tutorial introduction and many examples. - -.IP -.tl 'Berkeley Pascal User\'s Manual''PSD:7' -.QP -An implementation of this language popular for learning to program. - -.IP -.tl 'A Portable Fortran 77 Compiler''PSD:8' -.QP -A revised version of the document which originally appeared in -Volume 2b of the Bell Labs documentation; -this version reflects the work done at Berkeley. - -.IP -.tl 'Introduction to the f77 I/O Library''PSD:9' -.QP -A description of the revised input/output library for Fortran 77, -reflecting work carried out at Berkeley. - -.SH -Programming Tools -.IP -.tl 'Debugging with GDB: The GNU Source-Level Debugger''PSD:10' -.QP -How to debug programs using the source level \fIgdb\fP debugger -(or how to debug programs without having to know much about machine language). - -.IP -.tl 'A Tutorial Introduction to ADB''PSD:11' -.QP -How to debug programs using the assembly-language level \fIadb\fP debugger. - -.IP -.tl 'Make \- A Program for Maintaining Computer Programs''PSD:12' -.QP -Indispensable tool for making sure large programs are properly -compiled with minimal effort. - -.IP -.tl 'An Introduction to the Revision Control System''PSD:13' -.QP -RCS is a user-contributed tool for working together with other people -without stepping on each other's toes. -An alternative to \fIsccs\fR for controlling software changes. - -.IP -.tl 'An Introduction to the Source Code Control System''PSD:14' -.QP -A useful introductory article for those users with -installations licensed for SCCS. - -.IP -.tl 'YACC: Yet Another Compiler-Compiler''PSD:15' -.QP -Converts a BNF specification of a language and semantic actions -written in C into a compiler for that language. - -.IP -.tl 'LEX \- A Lexical Analyzer Generator''PSD:16' -.QP -Creates a recognizer for a set of regular expressions: -each regular expression can be followed by arbitrary C code -to be executed upon finding the regular expression. - -.IP -.tl 'The M4 Macro Processor''PSD:17' -.QP -M4 is a macro processor useful in its own right and as a -front-end for C, Ratfor, and Cobol. - -.IP -.tl 'gprof: a Call Graph Execution Profiler''PSD:18' -.QP -A program to show the call graph and execution time of a program. -Indispensable aid for improving the running time of almost everything. - -.SH -Programming Libraries -.IP -.tl 'Screen Updating and Cursor Movement Optimization''PSD:19' -.QP -Describes the \fIcurses\fP package, an aid for writing screen-oriented, -terminal-independent programs. - -.SH -General Reference -.IP -.tl 'An Introductory 4.4BSD Interprocess Communication Tutorial''PSD:20' -.QP -How to write programs that use the Interprocess Communication Facilities -of 4.4BSD. - -.IP -.tl 'An Advanced 4.4BSD Interprocess Communication Tutorial''PSD:21' -.QP -The reference document (with some examples) for the Interprocess Communication -Facilities of 4.4BSD. diff --git a/share/doc/psd/Title b/share/doc/psd/Title deleted file mode 100644 index 2ec146c51c6f..000000000000 --- a/share/doc/psd/Title +++ /dev/null @@ -1,131 +0,0 @@ -.\" Copyright (c) 1986, 1993 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)Title 8.2 (Berkeley) 4/19/94 -.\" -.ps 18 -.vs 22 -.sp 2.75i -.ft B -.ce 3 -UNIX Programmer's Supplementary Documents -(PSD) -.ps 14 -.vs 16 -.sp |4i -.ce 2 -4.4 Berkeley Software Distribution -.sp |5.75i -.ft R -.pt 12 -.vs 16 -.ce -June, 1993 -.sp |8.2i -.ce 5 -Computer Systems Research Group -Computer Science Division -Department of Electrical Engineering and Computer Science -University of California -Berkeley, California 94720 -.bp -\& -.sp |1i -.hy 0 -.ps 10 -.vs 12p -Copyright 1979, 1980, 1983, 1986, 1993 -The Regents of the University of California. All rights reserved. -.sp 2 -Other than the specific documents listed below as copyrighted by AT&T, -redistribution and use of this manual in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: -.sp 0.5 -.in +0.2i -.ta 0.2i -.ti -0.2i -1) Redistributions of this manual must retain the copyright -notices on this page, this list of conditions and the following disclaimer. -.ti -0.2i -2) Software or documentation that incorporates part of this manual must -reproduce the copyright notices on this page, this list of conditions and -the following disclaimer in the documentation and/or other materials -provided with the distribution. -.ti -0.2i -3) All advertising materials mentioning features or use of this software -must display the following acknowledgement: -``This product includes software developed by the University of -California, Berkeley and its contributors.'' -.ti -0.2i -4) Neither the name of the University nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. -.in -0.2i -.sp -\fB\s-1THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE.\s+1\fP -.sp 2 -Documents PSD:1, 2, 3, 4, 6, 11, 15, 16, and 17 -are copyright 1979, AT&T Bell Laboratories, Incorporated. -Document PSD:8 is a modification of an earlier document that -is copyrighted 1979 by AT&T Bell Laboratories, Incorporated. -Holders of \x'-1p'UNIX\v'-4p'\s-3TM\s0\v'4p'/32V, -System III, or System V software licenses are -permitted to copy these documents, or any portion of them, -as necessary for licensed use of the software, -provided this copyright notice and statement of permission -are included. -.sp 2 -Document PSD:10 is part of the user contributed software and is -copyright 1992 by the Free Software Foundation, Inc. -Permission is granted to make and distribute verbatim copies of -this document provided the copyright notice and this permission notice -are preserved on all copies. -.sp 2 -Document PSD:13 is part of the user contributed software and is -copyright 1983 by Walter F. Tichy. -Permission to copy the RCS documentation or any portion thereof as -necessary for licensed use of the software is granted to licensees -of this software, provided this copyright notice is included. -.sp 2 -The views and conclusions contained in this manual are those of the -authors and should not be interpreted as representing official policies, -either expressed or implied, of the Regents of the University of California. diff --git a/share/doc/smm/00.contents b/share/doc/smm/00.contents deleted file mode 100644 index ed03c7a69908..000000000000 --- a/share/doc/smm/00.contents +++ /dev/null @@ -1,161 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)00.contents 8.1 (Berkeley) 7/5/93 -.\" -.OH '''SMM Contents' -.EH 'SMM Contents''' -.TL -UNIX System Manager's Manual (SMM) -.sp -\s-24.4 Berkeley Software Distribution\s+2 -.sp -\fRJune, 1993\fR -.PP -This volume contains manual pages and supplementary documents useful to system -administrators. -The information in these documents applies to -the 4.4BSD system as distributed by U.C. Berkeley. -.SH -Reference Manual \- Section 8 -.tl '''(8)' -.IP -Section 8 of the UNIX Programmer's Manual contains information related to -system operation, administration, and maintenance. -.SH -System Installation and Administration -.IP -.tl 'Installing and Operating 4.4BSD''SMM:1' -.QP -The definitive reference document for those occasions when -you find you need to start over again. - -.IP -.tl 'Building 4.4BSD Kernels with \fIConfig\fP''SMM:2' -.QP -In-depth discussions of the use and operation of the \fIconfig\fP -program, and how to build your very own Unix kernel. - -.IP -.tl 'Fsck \- The UNIX File System Check Program''SMM:3' -.QP -A reference document for using the \fIfsck\fP program during -times of file system distress. - -.IP -.tl 'Disc Quotas in a UNIX Environment''SMM:4' -.QP -A light introduction to the techniques -for limiting the use of disc resources. - -.IP -.tl 'A Fast File System for UNIX''SMM:5' -.QP -A description of the 4.4BSD file system organization, -design and implementation. - -.IP -.tl 'The 4.4BSD NFS Implementation''SMM:6' -.QP -An overview of the design, implementation, and use of NFS on 4.4BSD. - -.IP -.tl 'Line Printer Spooler Manual''SMM:7' -.QP -This document describes the structure and installation procedure -for the line printer spooling system. - -.IP -.tl 'Sendmail Installation and Operation Guide''SMM:8' -.QP -The last word in installing and operating the \fIsendmail\fP program. - -.ne 3 -.IP -.tl 'Sendmail \- An Internetwork Mail Router''SMM:9' -.QP -An overview document on the design and implementation of \fIsendmail\fP. - -.IP -.tl 'Name Server Operations Guide for BIND''SMM:10' -.QP -Setting up and operating the name to Internet addressing software. -If you have a network this will be of interest. - -.IP -.tl 'Timed Installation and Operation Guide''SMM:11' -.QP -Describes how to maintain time synchronization between machines -in a local network. - -.IP -.tl 'The Berkeley UNIX Time Synchronization Protocol''SMM:12' -.QP -The protocols and algorithms used by timed, -the network time synchronization daemon. - -.IP -.tl 'AMD \- The 4.4BSD Automounter''SMM:13' -.QP -Automatically mounting file systems on demand. - -.IP -.tl 'Installation and Operation of UUCP''SMM:14' -.QP -Describes the implementation of uucp; for the installer and administrator. - -.IP -.tl 'A Dial\-Up Network of UNIX Systems''SMM:15' -.QP -Describes UUCP, a program for communicating files between UNIX systems. - -.IP -.tl 'On the Security of UNIX''SMM:16' -.QP -Hints on how to break UNIX, and how to avoid your system being broken. - -.IP -.tl 'Password Security \- A Case History''SMM:17' -.QP -How the bad guys used to be able to break the password algorithm, and why -they cannot now (at least not so easily). - -.IP -.tl 'Networking Implementation Notes, 4.4BSD Edition''SMM:18' -.QP -A concise description of the system interfaces used within the -networking subsystem. - -.IP -.tl 'The PERL Programming Language''SMM:19' -.QP -The Practical Extraction and Report Language is ideal for -writing those pesky adminitration scripts. diff --git a/share/doc/smm/Title b/share/doc/smm/Title deleted file mode 100644 index 4dd1b89439ff..000000000000 --- a/share/doc/smm/Title +++ /dev/null @@ -1,203 +0,0 @@ -.\" Copyright (c) 1986, 1993 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)Title 8.2 (Berkeley) 4/19/94 -.\" -.ps 18 -.vs 22 -.sp 2.75i -.ft B -.ce 2 -UNIX System Manager's Manual -(SMM) -.ps 14 -.vs 16 -.sp |4i -.ce 2 -4.4 Berkeley Software Distribution -.sp |5.75i -.ft R -.pt 12 -.vs 16 -.ce -June, 1993 -.sp |8.2i -.ce 5 -Computer Systems Research Group -Computer Science Division -Department of Electrical Engineering and Computer Science -University of California -Berkeley, California 94720 -.bp -\& -.sp |1i -.hy 0 -.ps 10 -.vs 12p -Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993 -The Regents of the University of California. All rights reserved. -.sp 2 -Other than the specific manual pages and documents listed below -as copyrighted by AT&T, -redistribution and use of this manual in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: -.sp 0.5 -.in +0.2i -.ta 0.2i -.ti -0.2i -1) Redistributions of this manual must retain the copyright -notices on this page, this list of conditions and the following disclaimer. -.ti -0.2i -2) Software or documentation that incorporates part of this manual must -reproduce the copyright notices on this page, this list of conditions and -the following disclaimer in the documentation and/or other materials -provided with the distribution. -.ti -0.2i -3) All advertising materials mentioning features or use of this software -must display the following acknowledgement: -``This product includes software developed by the University of -California, Berkeley and its contributors.'' -.ti -0.2i -4) Neither the name of the University nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. -.in -0.2i -.sp -\fB\s-1THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE.\s+1\fP -.sp 2 -The Institute of Electrical and Electronics Engineers and the American -National Standards Committee X3, on Information Processing Systems have -given us permission to reprint portions of their documentation. -.sp -In the following statement, the phrase ``this text'' refers to portions -of the system documentation. -.sp 0.5 -``Portions of this text are reprinted and reproduced in -electronic form in 4.4BSD from IEEE Std 1003.1-1988, IEEE -Standard Portable Operating System Interface for Computer Environments -(POSIX), copyright 1988 by the Institute of Electrical and Electronics -Engineers, Inc. In the event of any discrepancy between these versions -and the original IEEE Standard, the original IEEE Standard is the referee -document.'' -.sp -In the following statement, the phrase ``This material'' refers to portions -of the system documentation. -.sp 0.5 -``This material is reproduced with permission from American National -Standards Committee X3, on Information Processing Systems. Computer and -Business Equipment Manufacturers Association (CBEMA), 311 First St., NW, -Suite 500, Washington, DC 20001-2178. The developmental work of -Programming Language C was completed by the X3J11 Technical Committee.'' -.sp 2 -Manual pages cron.8, icheck.8, ncheck.8, and sa.8 -and documents SMM:15, 16, and 17 -are copyright 1979, AT&T Bell Laboratories, Incorporated. -Document SMM:14 is a modification of an earlier document that -is copyrighted 1979 by AT&T Bell Laboratories, Incorporated. -Holders of \x'-1p'UNIX\v'-4p'\s-3TM\s0\v'4p'/32V, -System III, or System V software licenses are -permitted to copy these documents, or any portion of them, -as necessary for licensed use of the software, -provided this copyright notice and statement of permission -are included. -.sp 2 -The views and conclusions contained in this manual are those of the -authors and should not be interpreted as representing official policies, -either expressed or implied, of the Regents of the University of California. -.br -.ll 6.5i -.lt 6.5i -.po .75i -.in 0i -.af % i -.ds ET\" -.de HD -.po 0 -.lt 7.4i -.tl '''' -.lt -.po -'sp 18p -.if o .tl '\\*(ET''\\*(OT' -.if e .tl '\\*(OT''\\*(ET' -'sp 18p -.ns -.. -.de FO -'sp 18p -.if e .tl '\s9\\*(Dt''\\*(Ed\s0' -.if o .tl '\s9\\*(Ed''\\*(Dt\s0' -'bp -.. -.wh 0 HD -.wh -60p FO -.bp 5 -.ds ET \s9\f2Table \|of \|Contents\fP\s0 -.ds OT - % - -.ce -\f3TABLE \|OF \|CONTENTS\fP -.nr x .5i -.in +\nxu -.nf -.ta \n(.lu-\nxuR -.de xx -\\$1\f3 \a \fP\\$2 -.. -.de t -.sp 1v -.ne .5i -.cs 3 -.ti -.5i -.ss 18 -\f3\s9\\$2. \\$3\s0\fP -.ss 12 -.if t .sp .5v -.cs 3 36 -.ds Ed Section \\$2 -.ds Dt \\$3 -.so \\$1 -.. -.t /usr/src/share/man/man0/toc8 8 "System Maintenance" -.in -.5i -.cs 3 -.if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n -.if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i diff --git a/share/doc/usd/00.contents b/share/doc/usd/00.contents deleted file mode 100644 index eae0ba83d22d..000000000000 --- a/share/doc/usd/00.contents +++ /dev/null @@ -1,262 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)00.contents 8.2 (Berkeley) 4/20/94 -.\" -.de ND -.KE -.sp -.KS -.. -.OH '''USD Contents' -.EH 'USD Contents''' -.TL -UNIX User's Supplementary Documents (USD) -.sp -\s-24.4 Berkeley Software Distribution\s+2 -.sp -\fRJune, 1993\fR -.PP -This volume contains documents which supplement the manual pages in -.I -The Unix User's Reference Manual -.R -for the 4.4BSD system as distributed by U.C. Berkeley. -.sp -.KS -.SH -Getting Started -.ND -.IP -.tl 'Unix for Beginners \- Second Edition''USD:1' -.QP -An introduction to the most basic uses of the system. -.ND -.IP -.tl 'Learn \- Computer\-Aided Instruction on UNIX (Second Edition)''USD:2' -.QP -Describes a computer-aided instruction program that walks new users through -the basics of files, the editor, and document prepararation software. -.ND -.SH -Basic Utilities -.ND -.IP -.tl 'An Introduction to the UNIX Shell''USD:3' -.QP -Steve Bourne's introduction to the capabilities of -.I sh, -a command interpreter especially popular for writing shell scripts. -.ND -.IP -.tl 'An Introduction to the C shell''USD:4' -.QP -This introduction to -.I csh, -(a command interpreter popular for interactive work) describes many -commonly used UNIX commands, assumes little prior knowledge of UNIX, -and has a glossary useful for beginners. -.ND -.IP -.tl 'DC \- An Interactive Desk Calculator''USD:5' -.QP -A super HP calculator, if you do not need floating point. -.ND -.IP -.tl 'BC \- An Arbitrary Precision Desk-Calculator Language''USD:6' -.QP -A front end for DC that provides infix notation, control flow, and -built\-in functions. -.ND -.SH -Communicating with the World -.ND -.IP -.tl 'Mail Reference Manual''USD:7' -.QP -Complete details on one of the programs for sending and reading your mail. -.ND -.IP -.tl 'The Rand MH Message Handling System''USD:8' -.QP -This system for managing your computer mail uses lots of small programs, -instead of one large one. -.ND -.SH -Text Editing -.ND -.IP -.tl 'A Tutorial Introduction to the Unix Text Editor''USD:9' -.QP -An easy way to get started with the line editor, -.I ed. -.ND -.IP -.tl 'Advanced Editing on Unix''USD:10' -.QP -The next step. -.ND -.IP -.tl 'An Introduction to Display Editing with Vi''USD:11' -.QP -The document to learn to use the \fIvi\fR screen editor. -.ND -.IP -.tl 'Ex Reference Manual (Version 3.7)''USD:12' -.QP -The final reference for the \fIex\fR editor. -.ND -.IP -.tl 'Vi Reference Manual''USD:13' -.QP -The definitive reference for the \fInvi\fR editor. -.ND -.IP -.tl 'Jove Manual for UNIX Users''USD:14' -.QP -Jove is a small, self-documenting, customizable display editor, based on -EMACS. A plausible alternative to -.I vi. -.ND -.IP -.tl 'SED \- A Non-interactive Text Editor''USD:15' -.QP -Describes a one-pass variant of -.I ed -useful as a filter for processing large files. -.ND -.IP -.tl 'AWK \- A Pattern Scanning and Processing Language (Second Edition)''USD:16' -.QP -A program for data selection and transformation. -.ND -.SH -Document Preparation -.ND -.IP -.tl 'Typing Documents on UNIX: Using the \-ms Macros with Troff and Nroff''USD:17' -.QP -Describes and gives examples of the basic use of the typesetting tools and -``-ms'', a frequently used package of formatting requests that make it easier -to lay out most documents. -.ND -.IP -.tl 'A Revised Version of \-ms''USD:18' -.QP -A brief description of the Berkeley revisions made to the \-ms formatting -macros for nroff and troff. -.ND -.IP -.tl 'Writing Papers with \fInroff\fR using \-me''USD:19' -.QP -Another popular macro package for -.I nroff. -.ND -.IP -.tl '\-me Reference Manual''USD:20' -.QP -The final word on \-me. -.ND -.IP -.tl 'NROFF/TROFF User\'s Manual''USD:21' -.QP -Extremely detailed information about these document formatting programs. -.ND -.IP -.tl 'A TROFF Tutorial''USD:22' -.QP -An introduction to the most basic uses of -.I troff -for those who really want to know such things, or want to write their -own macros. -.ND -.IP -.tl 'A System for Typesetting Mathematics''USD:23' -.QP -Describes -.I eqn, -an easy-to-learn language for high-quality mathematical typesetting. -.ND -.IP -.tl 'Typesetting Mathematics \- User\'s Guide (Second Edition)''USD:24' -.QP -More details about how to use -.I eqn. -.ND -.IP -.tl 'Tbl \- A Program to Format Tables''USD:25' -.QP -A program for easily typesetting tabular material. -.ND -.IP -.tl 'Refer \- A Bibliography System''USD:26' -.QP -An introduction to one set of tools used to maintain bibliographic databases. -The major program, -.I refer, -is used to automatically retrieve and format the references -based on document citations. -.ND -.IP -.tl 'Some Applications of Inverted Indexes on the UNIX System''USD:27' -.QP -Mike Lesk's paper describes the -.I refer -programs in a somewhat larger context. -.ND -.IP -.tl 'BIB \- A Program for Formatting Bibliographies''USD:28' -.QP -This is an alternative to -.I refer -for expanding citations in documents. -.ND -.IP -.tl 'Writing Tools \- The STYLE and DICTION Programs''USD:29' -.QP -These are programs which can help you understand and improve your -writing style. -.ND -.SH -Amusements -.ND -.IP -.tl 'A Guide to the Dungeons of Doom''USD:30' -.QP -An introduction to the popular game of \fIrogue\fP, a fantasy game -which is one of the biggest known users of VAX cycles. -.ND -.IP -.tl 'Star Trek''USD:31' -.QP -You are the Captain of the Starship Enterprise. Wipe out the -Klingons and save the Federation. -.KE diff --git a/share/doc/usd/Title b/share/doc/usd/Title deleted file mode 100644 index d36a55fccfd1..000000000000 --- a/share/doc/usd/Title +++ /dev/null @@ -1,120 +0,0 @@ -.\" Copyright (c) 1986, 1993 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)Title 8.2 (Berkeley) 4/19/94 -.\" -.ps 18 -.vs 22 -.sp 2.75i -.ft B -.ce 2 -UNIX User's Supplementary Documents -(USD) -.ps 14 -.vs 16 -.sp |4i -.ce 2 -4.4 Berkeley Software Distribution -.sp |5.75i -.ft R -.pt 12 -.vs 16 -.ce -June, 1993 -.sp |8.2i -.ce 5 -Computer Systems Research Group -Computer Science Division -Department of Electrical Engineering and Computer Science -University of California -Berkeley, California 94720 -.bp -\& -.sp |1i -.hy 0 -.ps 10 -.vs 12p -Copyright 1979, 1980, 1983, 1986, 1993 -The Regents of the University of California. All rights reserved. -.sp 2 -Other than the specific documents listed below as copyrighted by AT&T, -redistribution and use of this manual in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: -.sp 0.5 -.in +0.2i -.ta 0.2i -.ti -0.2i -1) Redistributions of this manual must retain the copyright -notices on this page, this list of conditions and the following disclaimer. -.ti -0.2i -2) Software or documentation that incorporates part of this manual must -reproduce the copyright notices on this page, this list of conditions and -the following disclaimer in the documentation and/or other materials -provided with the distribution. -.ti -0.2i -3) All advertising materials mentioning features or use of this software -must display the following acknowledgement: -``This product includes software developed by the University of -California, Berkeley and its contributors.'' -.ti -0.2i -4) Neither the name of the University nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. -.in -0.2i -.sp -\fB\s-1THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE.\s+1\fP -.sp 2 -Documents USD:1, 2, 3, 5, 6, 9, 10, 15, 16, 17, 21, 22, 23, 24, 25, 26, 27, -and 29 are copyright 1979, AT&T Bell Laboratories, Incorporated. -Holders of \x'-1p'UNIX\v'-4p'\s-3TM\s0\v'4p'/32V, -System III, or System V software licenses are -permitted to copy these documents, or any portion of them, -as necessary for licensed use of the software, -provided this copyright notice and statement of permission -are included. -.sp 2 -Documents USD:8, 14, and 28 are part of the -user contributed software. -.sp 2 -The views and conclusions contained in this manual are those of the -authors and should not be interpreted as representing official policies, -either expressed or implied, of the Regents of the University of California. diff --git a/share/man/man8/adduser.8 b/share/man/man8/adduser.8 deleted file mode 100644 index 73e3dcd16505..000000000000 --- a/share/man/man8/adduser.8 +++ /dev/null @@ -1,115 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)adduser.8 8.1 (Berkeley) 6/5/93 -.\" -.Dd June 5, 1993 -.Dt ADDUSER 8 -.Os BSD 4 -.Sh NAME -.Nm adduser -.Nd procedure for adding new users -.Sh DESCRIPTION -A new user must choose a login name, which must not already appear in -.Pa /etc/passwd -or -.Pa /etc/aliases . -It must also not begin with the hyphen -.Ql Fl -character. -It is strongly recommended that it be all lower-case, and not contain -the dot -.Ql \&. -character, as that tends to confuse mailers. -An account can be added by editing a line into the passwd file; this -must be done with the password file locked e.g. by using -.Xr chpass 1 -or -.Xr vipw 8 . -.Pp -A new user is given a group and user id. -Login and user id's should be unique across the system, and often across -a group of systems, since they are used to control file access. -Typically, users working on similar projects will be put in the same groups. -At the University of California, Berkeley, we have groups for system staff, -faculty, graduate students, and special groups for large projects. -.Pp -A skeletal account for a new user -\*(lqernie\*(rq -might look like: -.Bd -literal -ernie::25:30::0:0:Ernie Kovacs,508 Evans Hall,x7925, - 642-8202:/a/users/ernie:/bin/csh -.Ed -.Pp -For a description of each of these fields, see -.Xr passwd 5 . -.Pp -It is useful to give new users some help in getting started, supplying -them with a few skeletal files such as -.Pa \&.profile -if they use -.Pa /bin/sh , -or -.Pa \&.cshrc -and -.Pa \&.login -if they use -.Pa /bin/csh . -The directory -.Pa /usr/share/skel -contains skeletal definitions of such files. -New users should be given copies of these files which, for instance, -use -.Xr tset 1 -automatically at each login. -.Sh FILES -.Bl -tag -width /etc/master.passwdxx -compact -.It Pa /etc/master.passwd -user database -.It Pa /usr/share/skel -skeletal login directory -.El -.Sh SEE ALSO -.Xr chpass 1 , -.Xr finger 1 , -.Xr passwd 1 , -.Xr aliases 5 , -.Xr passwd 5 , -.Xr pwd_mkdb 8 , -.Xr vipw 8 -.Sh BUGS -User information should (and eventually will) be stored elsewhere. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 3.0 . diff --git a/share/tabset/3101 b/share/tabset/3101 deleted file mode 100644 index dab586bf6586..000000000000 --- a/share/tabset/3101 +++ /dev/null @@ -1 +0,0 @@ -H 0 0 0 0 0 0 0 0 0 diff --git a/share/tabset/9837 b/share/tabset/9837 deleted file mode 100644 index 57d211f64ef5..000000000000 --- a/share/tabset/9837 +++ /dev/null @@ -1 +0,0 @@ -3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file diff --git a/share/tabset/aa b/share/tabset/aa deleted file mode 100644 index 578474569bbc..000000000000 --- a/share/tabset/aa +++ /dev/null @@ -1 +0,0 @@ - 1 1 1 1 1 1 1 1 1  diff --git a/share/tabset/aed512 b/share/tabset/aed512 deleted file mode 100644 index 2c9d5fc20b56..000000000000 --- a/share/tabset/aed512 +++ /dev/null @@ -1 +0,0 @@ -\EG1MMM.`40K0001202080K8001????00^L\EC80L80{80^L\EK010100????K0601??0000c818100\EG1HHH.\07210000019A27FD006A280D002A200A52429FE8524861086118612861360N031B4C3F3F1800N041B0C1B4C38301800N001B3B313030301800N011B3B313030341800N021B3B313030381800N050800N061B3B313335301800\07211000015A58E8D5011A58F8D5111A5908D5211A5918D531160\07212000015AD5011858EAD5111858FAD52118590AD5311859160\0721300004B2071C5858E0A18658E0A0A858EA900858F268FA5278590A50A29018591A9F51865908590A90165918591A59038E58E8590A591E58F290185912071C5180A0A0A0901858EA900858F268F60\0721350000BA9472031DEA9502031DE60\E\E\E\EG1MMM.^A diff --git a/share/tabset/beehive b/share/tabset/beehive deleted file mode 100644 index 6d30c692701f..000000000000 --- a/share/tabset/beehive +++ /dev/null @@ -1,2 +0,0 @@ - -                                                                                diff --git a/share/tabset/diablo b/share/tabset/diablo deleted file mode 100644 index 8acc53fe33cb..000000000000 --- a/share/tabset/diablo +++ /dev/null @@ -1,3 +0,0 @@ - 9 -2 1 1 1 !1 )1 11 91 A1 I1 Q1 Y1 a1 i1 q1 y1 - 9 diff --git a/share/tabset/dtc382 b/share/tabset/dtc382 deleted file mode 100644 index 79257c39fd05..000000000000 --- a/share/tabset/dtc382 +++ /dev/null @@ -1 +0,0 @@ -  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file diff --git a/share/tabset/hp700-wy b/share/tabset/hp700-wy deleted file mode 100644 index a48c65be5aa2..000000000000 Binary files a/share/tabset/hp700-wy and /dev/null differ diff --git a/share/tabset/ibm3101 b/share/tabset/ibm3101 deleted file mode 100644 index 7e510ef869fe..000000000000 --- a/share/tabset/ibm3101 +++ /dev/null @@ -1 +0,0 @@ -H 0 0 0 0 0 0 0 0 0 \ No newline at end of file diff --git a/share/tabset/std b/share/tabset/std deleted file mode 100644 index e93f737f0e35..000000000000 --- a/share/tabset/std +++ /dev/null @@ -1 +0,0 @@ - 3 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/share/tabset/stdcrt b/share/tabset/stdcrt deleted file mode 100644 index 66ba12f64da5..000000000000 --- a/share/tabset/stdcrt +++ /dev/null @@ -1 +0,0 @@ - 3 1 1 1 1 1 1 1 1 1 \ No newline at end of file diff --git a/share/tabset/tandem653 b/share/tabset/tandem653 deleted file mode 100644 index 4588c34e51c8..000000000000 --- a/share/tabset/tandem653 +++ /dev/null @@ -1 +0,0 @@ -3 1 1 1 1 1 1 1 1 1 1 diff --git a/share/tabset/teleray b/share/tabset/teleray deleted file mode 100644 index 46158f398e64..000000000000 --- a/share/tabset/teleray +++ /dev/null @@ -1 +0,0 @@ -GY9(FY90FY98FY9@FY9HFY9PFY9XFY9`FY9hF \ No newline at end of file diff --git a/share/tabset/vt100 b/share/tabset/vt100 deleted file mode 100644 index 2ea71e1e7f20..000000000000 --- a/share/tabset/vt100 +++ /dev/null @@ -1 +0,0 @@ -  H H H H H H H H H H \ No newline at end of file diff --git a/share/tabset/vt100-w b/share/tabset/vt100-w deleted file mode 100644 index 20c061497c20..000000000000 --- a/share/tabset/vt100-w +++ /dev/null @@ -1 +0,0 @@ -  H H H H H H H H H H H H H H H H H \ No newline at end of file diff --git a/share/tabset/wyse-adds b/share/tabset/wyse-adds deleted file mode 100644 index 996ed6609585..000000000000 --- a/share/tabset/wyse-adds +++ /dev/null @@ -1,3 +0,0 @@ -Setting tabs... 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 - - diff --git a/share/tabset/xerox1720 b/share/tabset/xerox1720 deleted file mode 100644 index 7437292bffcb..000000000000 --- a/share/tabset/xerox1720 +++ /dev/null @@ -1 +0,0 @@ -2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file diff --git a/share/tabset/zenith29 b/share/tabset/zenith29 deleted file mode 100644 index ada833062341..000000000000 --- a/share/tabset/zenith29 +++ /dev/null @@ -1 +0,0 @@ - H H H H H H H H H H diff --git a/share/tmac/README b/share/tmac/README deleted file mode 100644 index a15dcaf5a8f7..000000000000 --- a/share/tmac/README +++ /dev/null @@ -1,145 +0,0 @@ -# @(#)README 8.1 (Berkeley) 6/8/93 - --mdoc stuff - doc-* files are unstripped tmac.doc-* files - -Site specific string and register names (for doc-{common,nroff,ditroff}) - -.\" tmac.doc-nroff -.\" -.\" Default fonts -.\" FONT DITROFF style TROFF Style NROFF Style -.\" Default Times Roman Times Roman Printer Dependent -.\" Default bold Times Bold Times Bold Printer Dependent -.\" Default italic Times Italic Times Italic Underline -.\" Const width lit Courier Times ? Printer Dependent -.\" Const width bold Courier Bold ? Printer Dependent -.\" Const width ital Courier Oblique ? Printer Dependent -.\" -.\" Default point size 10 (vs 12), Section Header point size 12 (vs 14) -.\" -.\" STRING CONSTANTS -.\" NS aD string (site) Address Style -.\" NS aR string (site) Argument Reference Style -.\" NS cM string (site) Interactive Comand Modifier (flag) -.\" NS eM string (site) Emphasis (in the English sense - usually italics) -.\" NS eR string (site) Errno Style -.\" NS eV string (site) Environment Variable Style -.\" NS fA string (site) Function Argument Style -.\" NS fL string (site) Command Line Flag Style -.\" NS fN string (site) Function Name Style -.\" NS Hs string (site) Header String Style -.\" NS iC string (site) Interactive Command Style -.\" NS lI string (site) Literal Style -.\" NS lp string (site) Left Function Parenthesis Style -.\" NS rp string (site) Right Function Parenthesis Style -.\" NS lP string (site) Left Parenthesis Style -.\" NS rP string (site) Right Parenthesis Style -.\" NS lB string (site) Bracket Open Style -.\" NS rB string (site) Bracket Close Style -.\" NS mL string (site) Diagnostic Message List Style -.\" NS nM string (site) Name (subject of manpage) Style -.\" NS nO string (site) normal font (default) -.\" NS lO string (site) Options Open Bracket Style -.\" NS rO string (site) Options Close Bracket Style -.\" NS pA string (site) Pathname Style -.\" NS Pu string (site) Accepted punctuation string for -mdoc syntax -.\" NS rA string (site) Reference Author Style -.\" NS rT string (site) Reference Title Style -.\" NS sH string (site) Section Header Style -.\" NS sY string (site) Symbolic Emphasis (boldface) -.\" NS sX string (site) Section Header Cross References -.\" NS tN string (site) Trade Name Style -.\" NS vA string (site) Generic Variable Style -.\" NS Vs string (site) Volume Title Style -.\" NS xR string (site) Cross Reference STyle (man page only) -.\" MISCELLANEOUS -.\" NS lS string (site) list-label-sep (list-types hang, number, bullet, diag) -.\" NS iV string soft space (can be split on a newline or padded in adjust mode) -.\" NS sV string manipulable space -.\" NS hV string hard space (cannot be split on newline or padded) -.\" NS tV string tab space (for column function) -.\" NS sI register (site) subheader indent -.\" NS tI register (site) text indent -.\" NS cR register nroff crt flag (1 for crt/online, 0 for printer) -.\" NS Pp register (site) paragraph vertical spacing -.\" NS dI register flag (Bd) -.\" INDENT WIDTHS (used for tag widths, and argument tests) -.\" NS Ad register (site) Width Needed for Address Tag (indented amount) -.\" NS Ac register (site) Angle Quote Close Value -.\" NS Ao register (site) Angle Quote Open Width -.\" NS Aq register (site) Angle Quote Width -.\" NS Bc register (site) Bracket Quote Close Value -.\" NS Bl register (site) Bullet List Macro Value -.\" NS Bo register (site) Bracket Quote Open Width -.\" NS Bq register (site) Bracket Quote Width -.\" NS Ar register (site) Width Needed for Argument -.\" NS Cm register (site) Width neeeded for Interactive Command Modifier -.\" NS Co register (site) Width Needed for Column offset -.\" NS Cx register (site) Width Needed for Complex Expressions -.\" NS Ds register (site) Width Needed for Display (right and left margins) -.\" NS Dc register (site) Double Quote Close Value -.\" NS Do register (site) Double Quote Open Width -.\" NS Dq register (site) Double Quote Width -.\" NS Dv register (site) Defined (#define) variable (markup) -.\" NS tI register (site) tI is dependent on Ds and used by .Dp -.\" NS Ec register (site) Enclose Quote Close Value -.\" NS El register (site) Enumerated List Macro Value -.\" NS Eo register (site) Enclose Quote Open Width -.\" NS Em register (site) Width Needed for Display -.\" NS Eq register (site) Enclose Quote Width -.\" NS Er register (site) Width Needed for Errno Types -.\" NS Ev register (site) Width Needed for Environment Variables -.\" NS Ex register (site) Width Needed for Example Indent -.\" NS Fa register (site) Width Needed for Function Argument -.\" NS Fl register (site) Width Needed for Flag -.\" NS Fc register (site) Funtion Quote Close Value -.\" NS Fn register (site) Width Needed for Function -.\" NS Fo register (site) Funtion Quote Open Width -.\" NS Hl register (site) Hypehnated List Macro Value (sub bullet list) -.\" NS I1, I2, I3 register (site) Indent values -.\" NS Ic register (site) Width neeeded for Interactive Command Name -.\" NS Li register (site) Width Needed for Literal Constant -.\" NS Ms register (site) Width Needed for Math Symbol ? not sure if needed -.\" NS Nm register (site) Width Needed for Name -.\" NS No register (site) Width Needed for Name -.\" NS Ns register (site) No Space Macro Value -.\" NS Oo register (site) Width Needed for Option Open -.\" NS Oc register (site) Width Needed for Option Close -.\" NS Op register (site) Width Needed for Option (one line) -.\" NS Pa register (site) Width Needed for Pathname -.\" NS Pf register (site) Prefix Macro Value -.\" NS Pq register (site) Parenthesis Quote Width -.\" NS Ql register (site) Width Needed for Quoted Literal -.\" NS Sc register (site) Single Quote Close Value -.\" NS So register (site) Single Quote Open Width -.\" NS Sq register (site) Single Quote Width -.\" NS Sy register (site) Width Needed for Symbols, Modes or Masks -.\" NS Sx register (site) Width Needed for Section Header Cross References -.\" NS Ra register (site) Reference Author -.\" NS Rj register (site) Reference Journal Name -.\" NS Rn register (site) Reference Issue Number -.\" NS Ro register (site) Reference Optional Information -.\" NS Rr register (site) Reference Technical Report Name -.\" NS Rt register (site) Reference Book or Article title Title -.\" NS Rv register (site) Reference Volume -.\" NS Ta register (site) Tab macro register -.\" NS Tn register (site) Trade Name Macro Value -.\" NS Tv register (site) Tab Macro Value -.\" NS Tx register (site) Width needed for default or unknown text width -.\" NS Va register (site) Width Needed for Generic Variable -.\" NS Xc register (site) Extended Argument List Close Value -.\" NS Xo register (site) Extended Argument List Open Width -.\" NS Xr register (site) Width Needed for Cross Reference. -.\" .nr %A 1 -.\" .nr %J 1 -.\" .nr %N 1 -.\" .nr %O 1 -.\" .nr %R 1 -.\" .nr %T 1 -.\" .nr %V 1 -.\" PAGE LAYOUT -.\" NS pL macro - page layout -.\" NS Hm register header margin -.\" NS Fm register footer margin -.\" NS vV register vertical distance (from Section headers/Lists/Subsections) diff --git a/share/tmac/doc b/share/tmac/doc deleted file mode 100644 index 609b9c1bcead..000000000000 --- a/share/tmac/doc +++ /dev/null @@ -1,3456 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc 8.1 (Berkeley) 6/8/93 -.\" -.\" .mdoc-parse - attempt to parse troff request arguments -.\" %beginstrip% -.if \n(.g \{\ -.cp 0 -.ftr C CR -.\} -.if t \{\ -. so /usr/share/tmac/tmac.doc-ditroff -.\} -.if n \{\ -. so /usr/share/tmac/tmac.doc-nroff -.\} -.so /usr/share/tmac/tmac.doc-common -.so /usr/share/tmac/tmac.doc-syms -.\" NS Db macro - start/stop DEBUG MODE -.\" NS Db register DEBUG MODE -.\" NS iN register DEBUG MODE (inline if 1, to stderr if 0 (default)) -.nr Db 0 -.de Db -.ie \\n(.$==0 \{\ -. ie \\n(Db==0 \{\ -.tm DEBUGGING ON -. nr Db 1 -. \} -. el \{\ -.tm DEBUGGING OFF -. nr Db 0 -. \} -.\} -.el \{\ -. if "\\$1"on" \{\ -.tm DEBUGGING ON -. nr Db 1 -. \} -. if "\\$1"off" \{\ -.tm DEBUGGING OFF -. nr Db 0 -. \} -.\} -.. -.\" NS aV macro - parse argument vector (recursive) (.aV arg ... ) -.\" NS fV macro - parse argument vector (recursive) (.fV) -.\" NS aC register argument counter (aV/fV) -.\" NS fV register argument counter (must set to \\n(.$ prior to reuqest) (fV) -.\" NS A[0-9] argument vector (aV/fV) -.\" NS C[0-9] reg. arg type(1=macro, 2=arg, 3=punct-suf, 4=punct-pre) (aV/fV) -.\" NS S[0-9] space vector (sV) -.\" NS aP register argument pointer (aV) -.\" NS yU local string used for debugging -.\" NS iI local register (indent for inline debug mode) -.\" NS mN name of calling request (set in each user requestable macro) -.de aV -.nr aC \\n(aC+1 -.ie "\\$1"|" \{\ -. if "\\*(mN"Op" .ds A\\n(aC \fR\\$1\fP -. if "\\*(mN"Ar" .ds A\\n(aC \fR\\$1\fP -. if "\\*(mN"Fl" .ds A\\n(aC \fR\\$1\fP -. if "\\*(mN"Cm" .ds A\\n(aC \fR\\$1\fP -. if "\\*(mN"It" .ds A\\n(aC \fR\\$1\fP -.\} -.el .ds A\\n(aC \\$1 -.aU \\n(aC -.nr C\\n(aC \\n(aT -.s\\n(aT -.if \\n(Db \{\ -. if \\n(aT==1 .ds yU Executable -. if \\n(aT==2 .ds yU String -. if \\n(aT==3 .ds yU Closing Punctuation or suffix -. if \\n(aT==4 .ds yU Opening Punctuation or prefix -. if \\n(iN==1 \{\ -. br -. nr iI \\n(.iu -. in -\\n(iIu -. if \\n(aC==1 \{\ -\&\fBDEBUG(argv) MACRO:\fP `.\\*(mN' \fBLine #:\fP \\n(.c -. \} -\&\t\fBArgc:\fP \\n(aC \fBArgv:\fP `\\*(A\\n(aC' \fBLength:\fP \\n(sW -\&\t\fBSpace:\fP `\\*(S\\n(aC' \fBClass:\fP \\*(yU -. \} -. if \\n(iN==0 \{\ -. if \\n(aC==1 \{\ -. tm DEBUG(argv) MACRO: `.\\*(mN' Line #: \\n(.c -. \} -. tm \tArgc: \\n(aC Argv: `\\*(A\\n(aC' Length: \\n(sW -. tm \tSpace: `\\*(S\\n(aC' Class: \\*(yU -. \} -.\} -.ie \\n(.$==1 \{\ -. nr aP 0 -. ie \\n(dZ==1 \{\ -. if \\n(oM>1 .as b1 \\*(S0 -. \} -. el \{\ -. if \\n(oM>0 \{\ -. if \\n(fC==0 .as b1 \\*(S0 -. \} -. \} -. ds S0 \\*(S\\n(aC -. if \\n(Db \{\ -. if \\n(iN==1 \{\ -\&MACRO REQUEST: \t.\\*(mN \\*(A1 \\*(A2 \\*(A3 \\*(A4 \\*(A5 \\*(A6 \\*(A7 \\*(A8 \\*(A9 -. br -. in \\n(iIu -. \} -. if \\n(iN==0 \{\ -.tm \tMACRO REQUEST: .\\*(mN \\*(A1 \\*(A2 \\*(A3 \\*(A4 \\*(A5 \\*(A6 \\*(A7 \\*(A8 \\*(A9 -. \} -. \} -.\} -.el .aV \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.de fV -.nr aC \\n(aC+1 -.if "\\*(A\\n(aC"|" \{\ -. if "\\*(mN"Op" .ds A\\n(aC \fR\\*(A\\n(aC\fP -. if "\\*(mN"Ar" .ds A\\n(aC \fR\\*(A\\n(aC\fP -. if "\\*(mN"Fl" .ds A\\n(aC \fR\&\\*(A\\n(aC\fP -. if "\\*(mN"Cm" .ds A\\n(aC \fR\\*(A\\n(aC\fP -. if "\\*(mN"It" .ds A\\n(aC \fR\\*(A\\n(aC\fP -.\} -.aU \\n(aC -.nr C\\n(aC \\n(aT -.s\\n(aT -.if \\n(Db \{\ -. if \\n(aT==1 .ds yU Executable -. if \\n(aT==2 .ds yU String -. if \\n(aT==3 .ds yU Closing Punctuation or suffix -. if \\n(aT==4 .ds yU Opening Punctuation or prefix -. if \\n(iN==1 \{\ -. br -. nr iI \\n(.iu -. in -\\n(iIu -. if \\n(aC==1 \{\ -\&\fBDEBUG(fargv) MACRO:\fP `.\\*(mN' \fBLine #:\fP \\n(.c -. \} -\&\t\fBArgc:\fP \\n(aC \fBArgv:\fP `\\*(A\\n(aC' \fBLength:\fP \\n(sW -\&\t\fBSpace:\fP `\\*(S\\n(aC' \fBClass:\fP \\*(yU -. \} -. if \\n(iN==0 \{\ -. if \\n(aC==1 \{\ -. tm DEBUG(fargv) MACRO: `.\\*(mN' Line #: \\n(.c -. \} -. tm \tArgc: \\n(aC Argv: `\\*(A\\n(aC' Length: \\n(sW -. tm \tSpace: `\\*(S\\n(aC' Class: \\*(yU -. \} -.\} -.ie \\n(fV==1 \{\ -. nr aP 0 -. ie \\n(dZ==1 \{\ -. if \\n(oM>1 .as b1 \\*(S0 -. \} -. el \{\ -. if \\n(oM>0 \{\ -. if \\n(fC==0 .as b1 \\*(S0 -. \} -. \} -. ds S0 \\*(S\\n(aC -. nr fV 0 -. if \\n(Db \{\ -. ie \\n(iN \{\ -\&\tMACRO REQUEST: .\\*(mN \\*(A1 \\*(A2 \\*(A3 \\*(A4 \\*(A5 \\*(A6 \\*(A7 \\*(A8 \\*(A9 -. br -. in \\n(iIu -. \} -. el \{\ -.tm \tMACRO REQUEST: .\\*(mN \\*(A1 \\*(A2 \\*(A3 \\*(A4 \\*(A5 \\*(A6 \\*(A7 \\*(A8 \\*(A9 -. \} -. \} -.\} -.el \{\ -. nr fV \\n(fV-1 -. fV -.\} -.. -.\" NS aX macro - stuff saved strings into `b1' (used by -diag list) -.de aX -.nr aP \\n(aP+1 -.as b1 \&\\*(A\\n(aP -.ie \\n(fV==1 \{\ -. nr aP 0 -. nr fV 0 -.\} -.el \{\ -. as b1 \&\\*(sV -. nr fV \\n(fV-1 -. aX -.\} -.. -.\" NS aI macro - append arg to arg vector: .aI [arg] [type] (used by .En only) -.de aI -.ie \\n(aC<9 \{\ -. nr aC \\n(aC+1 -. ds A\\n(aC \\$1 -. nr C\\n(aC \\$2 -. s\\$2 -. ds xV S\\n(aC -.\} -.el \{\ -. tm Usage: Too many arguments (maximum of 8 accepted) (#\\n(.c) -. tm \\*(A1 \\*(A2 \\*(A3 \\*(A4 \\*(A5 \\*(A6 \\*(A7 \\*(A8 \\*(A9 -.\} -.. -.\" -.\" NS aZ macro - print buffer (pB) and clean up arg vectors (aY) -.de aZ -.pB -.aY -.. -.\" NS aY macro - clean up arg vector -.de aY -.rm C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 -.rm A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 -.rm S1 S2 S3 S4 S5 S6 S7 S8 S9 -.nr aC 0 -.nr aP 0 -.. -.\" NS pB macro - test for end of vector (eol) (print b1 buffer or divert) -.de pB -.ie \\n(dZ==1 \{\ -. if \\n(oM==1 \{\&\\*(b1 -. rm S0 -. ds b1 -. \} -. if \\n(oM==0 \{\ -. x2 -. \} -.\} -.el \{\ -. ie \\n(oM==0 \{\&\\*(b1 -. rm S0 -. ds b1 -. \} -. el \{\ -. if ((\\n(sM==1)&(\\n(tP==0)) \{\ -. x1 -. \} -. \} -.\} -.hy -.. -.\" NS x1 macro - save buffer and divert if tP flag set -.\" NS eB diversion string -.\" NS b2 string save of buffer -.\" NS lK register count of lines read from input file -.de x1 -.nr dZ \\n(dZ+1 -.ds b2 \\*(b1 -.ds b1 -.nr lK \\n(.c -.ev 2 -.fi -.di eB -.. -.\" -.\" NS x2 macro - end diversion and print -.\" NS b0 string local temporary -.de x2 -.br -.di -.ev -.ie (\\n(.c-\\n(lK>1) \{\ -. ds b0 \&\\*(eB\\ -. ds b1 \\*(b2\\*(b0\\*(b1 -.\} -.el .ds b1 \\*(b2\\*(b1 -\&\\*(b1 -.rm eB b2 b0 b1 -.nr dZ \\n(dZ-1 -.. -.\" NS Fl macro - flags (appends - and prints flags) -.\" NS cF register save current font -.\" NS cZ register save current font size -.de Fl -.as b1 \&\\*(fL -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. as b1 \&\|\-\|\fP\s0 -. pB -. \} -. el \{\ -. ds mN Fl -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>0 \{\ -. ie (\\n(aC-\\n(aP)==0 \{\ -. as b1 \&\|\-\fP\s0 -. aZ -. \} -. el \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 \{\ -. as b1 \&\|\-\fP\s0 -. \\*(A\\n(aP -. \} -. el \{\ -. nr cF \\n(.f -. nr cZ \\n(.s -. if \\n(C\\n(aP==3 \{\ -. as b1 \&\|\-\| -. \} -. fR -. \} -. \} -.\} -.. -.\" -.\" NS fR macro - Fl flag recursion routine (special handling) -.\" NS jM local register -.\" NS jN local register -.\" -.de fR -.hy 0 -.nr jM \\n(C\\n(aP -.ie \\n(jM==1 \{\ -. as b1 \&\fP\s0 -. \\*(A\\n(aP -.\} -.el \{\ -. nr jN \\n(aP -. ie \\n(jM==2 \{\ -. ie !"\\*(A\\n(aP"\\*(Ba" \{\ -. ie !"\\*(A\\n(aP"\fR|\fP" \{\ -. ie "\\*(A\\n(aP"-" .as b1 \&\|\-\^\-\| -. el .as b1 \&\|\-\\*(A\\n(aP -. \} -. el .as b1 \&\\*(A\\n(aP -. \} -. el .as b1 \&\\*(A\\n(aP -. \} -. el .as b1 \&\f\\n(cF\s\\n(cZ\\*(A\\n(aP\fP\s0 -. ie \\n(aC==\\n(aP \{\ -. if \\n(jM==4 .as b1 \&\|\- -. as b1 \&\fP\s0 -. aZ -. \} -. el \{\ -. nr aP \\n(aP+1 -. ie ((\\n(C\\n(aP==3)&(\\n(C\\n(jN==4)) .as b1 \&\|\- -. el .as b1 \&\\*(S\\n(jN -. fR \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.rr jM jN -.. -.\" -.\" NS nR macro - general name recursion routine -.\" NS jM local register -.\" NS jN local register -.de nR -.hy 0 -.nr jM \\n(C\\n(aP -.ie \\n(jM==1 \{\ -. as b1 \&\f\\n(cF\s\\n(cZ -. \\*(A\\n(aP -.\} -.el \{\ -. nr jN \\n(aP -. ie \\n(jM==2 .as b1 \&\\*(A\\n(aP -. el .as b1 \&\f\\n(cF\s\\n(cZ\\*(A\\n(aP\fP\s0 -. ie \\n(aC==\\n(aP \{\ -. as b1 \&\f\\n(cF\s\\n(cZ -. aZ -. \} -. el \{\ -. nr aP \\n(aP+1 -. as b1 \&\\*(S\\n(jN -. nR -. \} -.\} -.rr jM jN -.. -.\" NS Ar macro - command line `argument' macro -.\" -.de Ar -.as b1 \\*(aR -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. as b1 file\ ...\fP\s0 -. pB -. \} -. el \{\ -. ds mN Ar -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>0 \{\ -. ie (\\n(aC-\\n(aP)==0 \{\ -. as b1 \&file\ ...\fP\s0 -. aZ -. \} -. el \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 \{\ -. as b1 \&file\ ...\fP\s0 -. \\*(A\\n(aP -. \} -. el \{\ -. nr cF \\n(.f -. nr cZ \\n(.s -. if \\n(C\\n(aP==3 \{\ -. as b1 \&file\ ... -. \} -. nR -. \} -. \} -.\} -.. -.\" NS Ad macro - Addresses -.de Ad -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Ad address ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Ad -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(aD -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Cd macro - Config declaration (for section 4 SYNOPSIS) (not callable) -.\" needs work - not very translatable -.de Cd -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Cd Configuration file declaration (#\\n(.c) -. el \{\ -. ds mN Cd -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.br -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(nM -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. ie \\n(nS \{\ -. if "\\*(mN"Cd" \{\ -. rs -. ie \\n(nS>1 .br -. el \{\ -. if \\n(iS==0 .nr iS \\n(Dsu -. \} -. in +\\n(iSu -. ti -\\n(iSu -. nr nS \\n(nS+1 -. \} -. nR -. in -\\n(iSu -. \} -. el .nR -.\} -.. -.\" NS Cm macro - Interactive command modifier (flag) -.de Cm -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Cm Interactive command modifier ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Cm -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(cM -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Dv macro - define variable -.de Dv -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Dv define_variable ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Dv -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(eR -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Em macro - Emphasis -.de Em -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. tm Usage: .Em text ... \\*(Pu (#\\n(.c) -. \} -. el \{\ -. ds mN Em -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(eM -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Er macro - Errnotype -.de Er -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Er ERRNOTYPE ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Er -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(eR -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Ev macro - Environment variable -.de Ev -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Ev ENVIRONMENT_VARIABLE ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Ev -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(eV -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Fd macro - function declaration - not callable (& no err check) -.\" NS fD register subroutine test (in synopsis only) -.\" NS fY register subroutine count (in synopsis only) (fortran only) -.\" NS fZ register also subroutine count (in synopsis only) -.de Fd -.ds mN Fd -.if \\n(nS>0 \{\ -.\" if a variable type was the last thing given, want vertical space -. if \\n(fX>0 \{\ -. Pp -. nr fX 0 -. \} -.\" if a subroutine was the last thing given, want vertical space -. if \\n(fZ>0 \{\ -. ie \\n(fD==0 \{\ -. Pp -. rs -. \} -. el .br -. \} -. nr fD \\n(fD+1 -.\} -.nr cF \\n(.f -.nr cZ \\n(.s -\&\\*(fD\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.br -.ft \\n(cF -.fs \\n(cZ -.. -.\" NS Fr macro - function return value - not callable (at the moment) -.de Fr -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Fr Function_return_value... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Fr -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(aR -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Ic macro - Interactive command -.de Ic -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Ic Interactive command ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Ic -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(iC -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Li macro - literals -.de Li -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage .Li argument ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Li -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(lI -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Or macro - Pipe symbol (OR) -.de Or -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Or ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Or -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(iC -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Ms macro - Math symbol -.de Ms -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Ms Math symbol ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Ms -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(sY -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Nm macro - Name of command or page topic -.\" NS n1 string - save first invocation of .Nm -.\" NS iS register - indent second command line in a synopsis -.de Nm -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. ie "\\*(n1"" .tm Usage: .Nm Name(s) ... \\*(Pu (#\\n(.c) -. el \&\\*(nM\\*(n1\fP\s0 -. \} -. el \{\ -. ds mN Nm -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>0 \{\ -. ie \\n(aC==\\n(aP \{\ -. as b1 \&\\*(nM\\*(n1\fP\s0 -. aZ -. \} -. el \{\ -. as b1 \\*(nM -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 \{\ -. as b1 \&\\*(n1\fP\s0 -. \\*(A\\n(aP -. \} -. el \{\ -. nr cF \\n(.f -. nr cZ \\n(.s -. if \\n(nS \{\ -. if "\\*(mN"Nm" \{\ -. rs -. in -\\n(iSu -. ie \\n(nS>1 .br -. el \{\ -. if \\n(iS==0 \{\ -. sw \\$1 -. nr iS ((\\n(sWu+1)*\\n(fW)u -. \} -. \} -. in +\\n(iSu -. ti -\\n(iSu -. nr nS \\n(nS+1 -. \} -. \} -. if "\\*(n1"" .ds n1 \\*(A\\n(aP -. nR -. \} -. \} -.\} -.. -.\" NS Pa macro - Pathname -.de Pa -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \&\\*(pA~\fP\s0 -. el \{\ -. ds mN Pa -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(pA -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Sy macro - Symbolics -.de Sy -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Sy symbolic_text ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Sy -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(sY -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Tn macro - Trade Name Macro -.de Tn -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Tn Trade_name(s) ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Tn -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(tN\\*(tF -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS nN macro - Trade Name Macro for inside of reference -.de nN -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Tn Trade_name(s) ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Tn -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(tN -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS Va macro - variable name macro -.de Va -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Va variable_name(s) ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Va -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. as b1 \\*(vA -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" -.\" NS No macro - Normal text macro (default text style if mess up) -.de No -.as b1 \\*(nO -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .No must be called with arguments (#\\n(.c) -. el \{\ -. ds mN No -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 \{\ -. \\*(A\\n(aP -. \} -. el \{\ -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -. \} -.\} -.. -.\"------------------------------------------------------------------------ -.\" NS Op macro - Option Expression -.de Op -.if \\n(aC==0 \{\ -. ds mN Op -.\} -.\" .ds qL \&\\*(lO -.\" .ds qR \&\\*(rO -.ds qL \&\\*(lB -.ds qR \&\\*(rB -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -.. -.\" NS Aq macro - Enclose string in angle brackets -.de Aq -.if \\n(aC==0 .ds mN Aq -.ds qL \&< -.ds qR \&> -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Bq macro - Enclose string in square brackets -.de Bq -.if \\n(aC==0 .ds mN Bq -.ds qL \&\\*(lB -.ds qR \&\\*(rB -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Dq macro - Enclose string in double quotes -.de Dq -.if \\n(aC==0 .ds mN Dq -.ds qL \&\\*(Lq -.ds qR \&\\*(Rq -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Eq macro - Enclose string in double quotes -.de Eq -.if \\n(aC==0 .ds mN Eq -.ds qL \\$1 -.ds qR \\$2 -.En \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Pq macro - Enclose string in parenthesis -.de Pq -.if \\n(aC==0 .ds mN Pq -.ds qL \&\\*(lP -.ds qR \&\\*(rP -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Ql macro - Quoted literal is in file mdoc-[dit|n|g]roff (too large -.\" an if-else to carry along recursively for `if n ...') -.\" -.\" NS Sq macro - Enclose string in single quotes -.de Qq -.if \\n(aC==0 .ds mN Qq -.ds qL \&\\*q -.ds qR \&\\*q -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Sq macro - Enclose string in single quotes -.de Sq -.if \\n(aC==0 .ds mN Sq -.ds qL \&\\*(sL -.ds qR \&\\*(sR -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" -.\" NS Es macro - Set up strings for .En call -.de Es -.if \\n(aC==0 \{\ -. ie \\n(.$>2 .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. el \{\ -. ds qL \\$1 -. ds qR \\$2 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ds qL \\*(A\\n(aP -. nr aP \\n(aP+1 -. ds qR \\*(A\\n(aP -. ie \\n(aC>\\n(aP .c\\n(C\\n(aP -. el .aZ -.\} -.. -.\" .tm En beg arg(A[\\n(aP])==\\*(A\\n(aP; -.\" .tm En oM==\\n(oM; dZ==\\n(dZ; Xt==\\n(Xt; aC==\\n(aC -.\" NS En macro - Enclose string with given args (eg [ and ] etc) -.\" NS qL string variable set by calling macro -.\" NS qR string variable set by calling macro -.\" NS aJ register (for vR) -.de En -.ie \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. as b1 \&\\*(qL\\*(qR -. pB -. \} -. el \{\ -.\". as mN (En) -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. as b1 \&\\*(qL -. \} -.\} -.el \{\ -. as b1 \&\\*(qL -.\} -.if \\n(aC>0 \{\ -. ie (\\n(aC-\\n(aP)==0 \{\ -. as b1 \&\\*(qR -. aZ -. \} -. el \{\ -. ie \\n(C\\n(aC==3 \{\ -. nr aJ \\n(aC-1 -. vR -. nr aJ \\n(aJ+1 -. ds A\\n(aJ \&\\*(qR\\*(A\\n(aJ -. nr aJ 0 -. \} -. el .aI \&\\*(qR 3 -. nr aP \\n(aP+1 -. if \\n(C\\n(aP==1 .\\*(A\\n(aP -. if \\n(C\\n(aP>1 \{\ -. nr aP \\n(aP-1 -. No -. \} -. \} -.\} -.. -.\" NS vR macro - vector routine (for En, trace backwards past trail punct) -.de vR -.if \\n(C\\n(aJ==3 \{\ -. nr aJ \\n(aJ-1 -. vR -.\} -.. -.\"------------------------------------------------------------------------ -.\" NS Ao macro - Angle open -.de Ao -.if \\n(aC==0 .ds mN Ao -.ds qL \&< -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Ac macro - Angle close -.de Ac -.if \\n(aC==0 .ds mN Ac -.ds qR \&> -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Bo macro - Bracket open -.de Bo -.if \\n(aC==0 .ds mN Bo -.ds qL \&[ -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Bc macro - Bracket close -.de Bc -.if \\n(aC==0 .ds mN Bc -.ds qR \&] -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Do macro - Double Quote open -.de Do -.if \\n(aC==0 .ds mN Do -.ds qL \&\\*(Lq -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Dc macro - Double Quote close -.de Dc -.if \\n(aC==0 .ds mN Dc -.ds qR \&\\*(Rq -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Eo macro - Enclose open -.de Eo -.if \\n(aC==0 .ds mN Eo -.ds qL \\$1 -.eO \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Ec macro - Enclose close -.de Ec -.if \\n(aC==0 .ds mN Ec -.ds qR \\$1 -.eC \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Oo macro - Option open -.de Oo -.if \\n(aC==0 .ds mN Oo -.ds qL \&[ -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Oc macro - Option close -.de Oc -.if \\n(aC==0 .ds mN Oc -.ds qR \&] -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Po macro - Parenthesis open -.de Po -.if \\n(aC==0 .ds mN Po -.ds qL \&( -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Pc macro - Parenthesis close -.de Pc -.if \\n(aC==0 .ds mN Pc -.ds qR \&) -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Qo macro - Straight Double Quote open -.de Qo -.if \\n(aC==0 .ds mN Qo -.ds qL \&\\*q -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Qc macro - Straight Double Quote close -.de Qc -.if \\n(aC==0 .ds mN Qc -.ds qR \&\\*q -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS So macro - Single Quote open -.de So -.if \\n(aC==0 .ds mN So -.ds qL \&\\*(sL -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Sc macro - Single Quote close -.de Sc -.if \\n(aC==0 .ds mN Sc -.ds qR \&\\*(sR -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Xo macro - Extend open (continue) -.de Xo -.if \\n(aC==0 .ds mN Xo -.\" .nr mN 1 -.ds qL -.eO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Xe macro - Extend close (end) -.de Xc -.\" .nr mN 0 -.if \\n(aC==0 .ds mN Xc -.ds qR -.eC \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS eO macro - enclose string open -.\" NS oM register (extension possible) -.de eO -.nr oM \\n(oM+1 -.\" .tm eO last arg==A[\\n(aC]==\\*(A\\n(aC; aP==\\n(aP; oM==\\n(oM; dZ==\\n(dZ; -.ie \\n(aC==0 \{\ -. ie \\n(.$>0 \{\ -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. as b1 \\*(qL -. \} -. el \{\ -. as b1 \\*(qL -. if (\\n(dZ==0)&(\\n(sM==1) \{\ -. nr dZ \\n(dZ+1 -. ds b2 \\*(b1 -. ds b1 -. nr lK \\n(.c -. ev 2 -. fi -. di eB -. \} -. \} -.\} -.el \{\ -. as b1 \\*(qL -.\} -.ie \\n(aC>0 \{\ -. if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 .\\*(A\\n(aP -. el \{\ -. nr aP \\n(aP-1 -. No -. \} -. \} -. if \\n(aC==\\n(aP \{\ -. if \\n(tP==1 \{\ -.\" .tm SETTING Xt!!! -. nr Xt 1 -. \} -.\".\" . ds S0 -.\"CHANGED ds S0 \\*(iV -. aY -. \} -.\} -.el \{\ -. if \\n(oM>1 .as b1 \\*(sV -.\} -.. -.\" -.\" NS eC macro - enclose string close -.\" NS aa local register -.de eC -.nr oM \\n(oM-1 -.\" tm eC last arg==A[\\n(aC]==\\*(A\\n(aC; aP==\\n(aP; oM==\\n(oM; dZ==\\n(dZ; -.as b1 \\*(qR -.if \\n(aC==0 \{\ -. ie \\n(.$>0 \{\ -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -. el \{\ -. ie "\\*(xB"" \{\ -. pB -. \} -. el \{\ -. pB -.\\*(L\\n(lC -. nr Xt 0 -. ds xB -. \} -. \} -.\} -.if \\n(aC>0 \{\ -. ie \\n(aC==\\n(aP \{\ -. ie \\n(oM==0 \{\ -. aZ -. \} -. el .aY -. \} -. el \{\ -. nr aa \\n(aP+1 -. if \\n(C\\n(aa==2 .as b1 \\*(S\\n(aC -.\" tm CURRENT arg (aP==\\*(A\\n(aP and ap+1==\\*(A\\n(aa) tP==\\n(tP Xt==\\n(Xt -. rr aa -. if \\n(tP>0 \{\ -.\" tm UNSETTING Xt==\\n(Xt!!!! -. if \\n(Xt>0 .nr Xt \\n(Xt-1 -.\" tm NOW Xt==\\n(Xt!!!! -. \} -. No -. \} -.\} -.. -.\"------------------------------------------------------------------------ -.\" NS Pf macro - Prefix (calls .pF) -.de Pf -.if \\n(aC==0 .ds mN Pf -.ds qL \&\\$1 -.pF \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS pF macro - Prefix (for prefixing open quotes, brackets etc) -.de pF -.ie \\n(aC==0 \{\ -. as b1 \&\\*(qL -. ie \\n(.$<2 \{\ -. tm Warning: Missing arguments - prefix .Pf) -. pB -. \} -. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.el \{\ -. ie (\\n(aC-\\n(aP)>1 \{\ -. nr aP \\n(aP+1 -. as b1 \&\\*(A\\n(aP -. \} -. el .tm Warning: .Pf: trailing prefix (#\\n(.c) -.\} -.if \\n(aC>0 \{\ -. ie (\\n(aC-\\n(aP)==0 .aZ -. el \{\ -. nr aP \\n(aP+1 -. c\\n(C\\n(aP -. \} -.\} -.. -.\" NS Ns macro - remove space (space remove done by .aV or .fV) -.de Ns -.if \\n(aC==0 \{\ -. ds mN Ns -. ie \\n(.$>0 .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. el .tm Usage: .Ns must be called with arguments (#\\n(.c) -.\} -.No -.. -.de Ap -.if \\n(aC==0 \{\ -. ds mN Ap -. tm Usage: Ap "cannot be first request on a line (no .Ap)" (#\\n(.c) -.\} -.as b1 \&' -.No -.. -.\" NS Hv macro - Hard (unpaddable) Space vector -.\" NS iV string inter-vector space -.\" NS sV string inter-argument space -.de Hv -.ds iV \\*(sV -.ds sV \\*(hV -.. -.\" NS Sv macro - Soft Space vector (troff limitation) -.de Sv -.ds sV \\*(iV -.. -.\" NS Tv macro - Tab Space vector -.de Tv -.ds sV \\*(tV -.. -.\" NS Sm macro - Space mode -.\" NS sM register - default is one (space mode on) -.nr sM 1 -.de Sm -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm "Usage: .Sm [off | on]" (#\\n(.c) -. el \{\ -. ds mN Sm -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>0 \{\ -. nr aP \\n(aP+1 -. if "\\*(A\\n(aP"on" \{\ -. ds sV \\*(iV -. nr sM 1 -. \} -. if "\\*(A\\n(aP"off" \{\ -. ds sV -. rm S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 -. nr sM 0 -. \} -. ie \\n(aC>\\n(aP \{\ -. No -. \} -. el .aY -.\} -.. -.\"------------------------------------------------------------------------ -.\" Size and Argument type macros -.\" NS aT macro - argument type -.\" NS aU macro - argument type (same as .aT but uses A[1-9] strings -.\" NS aT register argument type -.if \n(.g \{\ -.de aT -.nr aT 0 -.ie \\n(sW>2:(\A'\\$1'==0) \{\ -. nr aT 2 -.\} -.el \{\ -. if \\n(sW==1 \{\ -. ie \\n(z\\$1>2 \{\ -. nr aT \\n(z\\$1 -. \} -. el .nr aT 2 -. \} -. if \\n(sW==2 \{\ -. ie \\n(\\$1 \{\ -. nr aT 1 -. \} -. el .nr aT 2 -. \} -.\} -.. -.de aU -.nr aT 0 -.aW \\$1 -.ie \\n(sW>2:(\A'\\*(A\\$1'==0) .nr aT 2 -.el \{\ -. if \\n(sW==1 \{\ -. ie \\n(z\\*(A\\$1>2 \{\ -. nr aT \\n(z\\*(A\\$1 -. \} -. el .nr aT 2 -. \} -. if \\n(sW==2 \{\ -. ie (\\n(\\*(A\\$1) \{\ -. nr aT 1 -. \} -. el .nr aT 2 -. \} -.\} -.. -.\} -.if !\n(.g \{\ -.de aT -.nr aT 0 -.ie \\n(sW>2 \{\ -. nr aT 2 -.\} -.el \{\ -. if \\n(sW==1 \{\ -. ie \\n(z\\$1>2 \{\ -. nr aT \\n(z\\$1 -. \} -. el .nr aT 2 -. \} -. if \\n(sW==2 \{\ -. ie \\n(\\$1 \{\ -. nr aT 1 -. \} -. el .nr aT 2 -. \} -.\} -.. -.de aU -.nr aT 0 -.aW \\$1 -.ie \\n(sW>2 .nr aT 2 -.el \{\ -. if \\n(sW==1 \{\ -. ie \\n(z\\*(A\\$1>2 \{\ -. nr aT \\n(z\\*(A\\$1 -. \} -. el .nr aT 2 -. \} -. if \\n(sW==2 \{\ -. ie (\\n(\\*(A\\$1) \{\ -. nr aT 1 -. \} -. el .nr aT 2 -. \} -.\} -.. -.\} -.\" NS s1 macro - set spacing for class type 1 -.\" NS s2 macro - set spacing for class type 2 -.\" NS s3 macro - set spacing for class type 3 -.\" NS s1 macro - set spacing for class type 1 -.\" NS s2 macro - set spacing for class type 2 -.\" NS s3 macro - set spacing for class type 3 -.\" NS s4 macro - set spacing for class type 4 -.\" NS S[0-9] string spacing -.\" NS xX local register -.\" NS aa local register -.de s0 -.tm MDOC-ERROR: bogus type 0 (can't set space '\\*(A\\n(aC') (#\\n(.c) -.. -.de s1 -.if \\n(\\*(A\\n(aC==3 \{\ -. nr xX \\n(aC-1 -. rm S\\n(xX -. ds S\\n(aC \\*(sV -.\} -.if \\n(\\*(A\\n(aC==2 \{\ -. nr xX \\n(aC-1 -.\" this kludge can probably go away, but need to double check first -. ie "\\*(A\\n(aC"Nb" .ds S\\n(xX \\*(hV -. el .rm S\\n(xX -.\} -.. -.de s2 -.ds S\\n(aC \\*(sV -.. -.de s3 -.if \\n(aC>1 \{\ -. nr xX \\n(aC-1 -. rm S\\n(xX -.\} -.ds S\\n(aC \\*(sV -.. -.de s4 -.nr aa 0 -.. -.\" Class switches (on current argument aP) -.\" NS c0 macro - catch errors (non-existent class type 0) -.\" NS c1 macro - call request if type 1 -.\" NS c2 macro - call .No if type 2 -.\" NS c3 macro - call .No if type 3 -.\" NS c4 macro - call .No if type 4 -.de c0 -.tm MDOC-ERROR: bogus class 0 (can't determine '\\*(A\\n(aC') (#\\n(.c) -.. -.de c1 -.\\*(A\\n(aP -.. -.de c2 -.nr aP \\n(aP-1 -.No -.. -.de c3 -.nr aP \\n(aP-1 -.No -.. -.de c4 -.nr aP \\n(aP-1 -.No -.. -.\" NS y1 macro - ignore if class 1 -.\" NS y2 macro - ignore if class 2 -.\" NS y3 macro - append if type 3 -.\" NS y4 macro - append if type 4 -.de y1 -.nr aa 1 -.. -.de y2 -.nr aa 1 -.. -.de y3 -.as b1 \\*(A\\n(aP -.nr aP \\n(aP+1 -.n\\C\\n(aP -.. -.de y4 -.as b1 \\*(A\\n(aP -.nr aP \\n(aP+1 -.n\\C\\n(aP -.. -.\"-------------------------------------------------------------------------- -.\" Ns Bf macro - Begin Font Mode (will be begin-mode/end-mode in groff & TeX) -.\" Ns Ef macro - End Font Mode -.de Bf -.ds mN Bf -.ie \\n(.$>0 \{\ -. nr bF \\n(.f -. nr bZ \\n(.s -. if "\\$1"Em" \&\\*(eM\c -. if "\\$1"Li" \&\\*(lI\c -. if "\\$1"Sy" \&\\*(sY\c -. if "\\$1"-emphasis" \&\\*(eM\c -. if "\\$1"-literal" \&\\*(lI\c -. if "\\$1"-symbolic" \&\\*(sY\c -.\} -.el .tm Usage .Bf [Em | emphasis | Li | literal | Sy | symbolic] (#\\n(.c) -.. -.de Ef -.ds mN Ef -.ie \\n(.$>0 .tm Usage .Ef (does not take arguments) (#\\n(.c) -.el \&\f\\n(bF\s\\n(bZ -.. -.\" Ns Bk macro - Begin Keep -.\" Ns Ek macro - End Keep -.\" Ns kS string - keep type -.de Bk -.ds mN Bk -.ie \\n(.$==0 \{\ -.tm Usage: .Bk [-lines | -words] (#\\n(.c) -.\} -.el \{\ -. if !"\\*(kS"" .tm .Bk: nesting keeps not implemented yet. (#\\n(.c) -. if "\\$1"-lines" .tm .Bd -lines: Not implemented yet. (#\\n(.c) -. if "\\$1"-words" .Hv -. ds kS \\$1 -.\} -.. -.de Ek -.ds mN Ek -.ie \\n(.$>0 .tm Usage .Ek (does not take arguments) (#\\n(.c) -.el \{\ -. if "\\*(kS"-lines" .tm .Bd -lines: Not implemented yet. (#\\n(.c) -. if "\\*(kS"-words" .Sv -. rm kS -.\} -.. -.\" NS Bd macro - Begin Display display-type [offset string] -.\" NS Ed macro - end Display -.\" NS O[0-9] registers - stack of indent -.\" NS d[0-9] registers - display-type stack -.de Bd -.ds mN Bd -.ie \\n(.$==0 \{\ -.tm Usage: .Bd [-literal | -filled | -ragged | -unfilled] [-offset [string]] [-compact] (#\\n(.c) -.\} -.el \{\ -. ds aa -. nr bV 0 -. nr iD 0 -. nr dP \\n(dP+1 -. if "\\$1"-literal" \{\ -. nr iD \\n(iD+1 -. ds d\\n(dP dL -. nr cF \\n(.f -. nr cZ \\n(.s -. ie t \{\&\\*(lI -' ta 9n 18n 27n 36n 45n 54n 63n 72n -. \} -. el \{\ -' ta 8n 16n 24n 32n 40n 48n 56n 64n 72n -. \} -. nf -. \} -. if "\\$1"-filled" \{\ -. nr iD \\n(iD+1 -. ds d\\n(dP dF -. br -. \} -. if "\\$1"-ragged" \{\ -. nr iD \\n(iD+1 -. ds d\\n(dP dR -. na -. \} -. if "\\$1"-unfilled" \{\ -. nr iD \\n(iD+1 -. ds d\\n(dP dU -. nf -. \} -.\" .tm Here is argc: \\n(.$ and here is iD \\n(iD -. if ((\\n(iD>=1)&(\\n(.$>\\n(iD)) \{\ -. bV \\$2 \\$3 \\$4 -. \} -. if \\n(O\\n(dP>0 'in \\n(.iu+\\n(O\\n(dPu -. if (\\n(bV==0) \{\ -. if (\\n(nS==0) \{\ -. ie "\\*(d\\n(dP"dR" .sp \\n(dVu -. el 'sp \\n(dVu -. \} -. \} -. if \\n(cR==0 .ne 2v -. nr bV 0 -. nr iD 0 -.\} -.. -.\" NS bV macro - resolve remaining .Bd arguments -.de bV -.\" .tm in bV with args: \\$1 \\$2 \\$3 -.nr iD 1 -.ds bY -.if "\\$1"-offset" \{\ -. ds bY \\$2 -. if "\\*(bY"left" \{\ -. nr iD \\n(iD+1 -. nr O\\n(dP 0 -. \} -. if "\\*(bY"right" \{\ -. nr iD \\n(iD+1 -. nr O\\n(dP (\\n(.l/3)u -. \} -. if "\\*(bY"center" \{\ -. nr iD \\n(iD+1 -. nr O\\n(dP (\\n(.l-\\n(.i)/4u -. \} -. if "\\*(bY"indent" \{\ -. nr iD \\n(iD+1 -. nr O\\n(dP \\n(dIu -. \} -. if "\\*(bY"indent-two" \{\ -. nr iD \\n(iD+1 -. nr O\\n(dP \\n(dIu+\\n(dIu -. \} -. if \\n(iD==1 \{\ -. nr iD \\n(iD+1 -. sW "\\*(bY" -. ie \\n(sW>2 \{\ -. ie ((\\*(bY>9n)&(\\*(bY<100n)) \{\ -. nr O\\n(dP \\*(bY -. \} -. el .nr O\\n(dP (\\n(sW)*\\n(fWu -. \} -. el \{\ -. if \\n(sW==2 .aT \\*(bY -. ie \\n(aT==1 \{\ -. nr O\\n(dP \\n(\\*(bY -. \} -. el .nr O\\n(dP \\*(bY -. \} -. \} -.\} -.if "\\$1"-compact" \{\ -. nr bV 1 -.\} -.if \\n(iD<\\n(.$ \{\ -. ie "\\*(bY"" \{\ -. bV \\$2 \\$3 -. \} -. el \{\ -. bV \\$3 -. \} -.\} -.. -.\" NS Ed macro - end display -.de Ed -.ds mN Ed -.br -.if \\n(dP==0 .tm mdoc: Extraneous .Ed -.if "\\*(d\\n(dP"dL" \{\ -. ft \\n(cF -. fz \\n(cZ -.\} -.in \\n(.iu-\\n(O\\n(dPu -.rr O\\n(dP -.rm d\\n(dP -.nr dP \\n(dP-1 -.fi -.if t .ad -.. -.\"-------------------------------------------------------------------------- -.\" NS Bl macro - begin list (.Bl list-type) -.\" NS L[0-9] registers - stack of list types -.de Bl -.ie \\n(.$==0 \{\ -.tm Usage: .Bl [[-hang | -tag] [-width]] [ -item | -enum | -bullet | -diag] (#\\n(.c) -.\} -.el \{\ -. ds mN Bl -. nr aP 0 -. nr lC \\n(lC+1 -. ds A1 \\$2 -. ds A2 \\$3 -. ds A3 \\$4 -. ds A4 \\$5 -. ds A5 \\$6 -. ds A6 \\$7 -. ds A7 \\$8 -. ds A8 \\$9 -. nr fV \\n(.$-1 -. if "\\$1"-hang" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC hL -. nr w\\n(lC 6n -. nr tC 1 -. \} -. if "\\$1"-tag" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC tL -. nr tC 1 -. \} -. if "\\$1"-item" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC iT -. nr tC 1 -. \} -. if "\\$1"-enum" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC nU -. nr w\\n(lC 3n -. nr tC 1 -. \} -. if "\\$1"-bullet" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC bU -. nr w\\n(lC 2n -. nr tC 1 -. \} -. if "\\$1"-dash" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC hU -. nr w\\n(lC 2n -. nr tC 1 -. \} -. if "\\$1"-hyphen" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC hU -. nr w\\n(lC 2n -. nr tC 1 -. \} -. if "\\$1"-inset" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC lL -. nr tC 1 -. \} -. if "\\$1"-diag" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC mL -. nr mL 1 -. \} -. if "\\$1"-ohang" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC oL -. nr tC 1 -. \} -. if "\\$1"-column" \{\ -. nr aP \\n(aP+1 -. ds L\\n(lC cL -. \} -. ie \\n(aP==0 \{\ -. tm \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. tm Usage: .Bl [[-inset|-tag] -width] [-item|-enum|-bullet|-diag] (#\\n(.c) -. \} -. el \{\ -. tY -. if (\\n(aP==1)&(\\n(aP<\\n(.$) \{\ -. nr aP 0 -. lV -. if "\\*(L\\n(lC"cL" \{\ -. W\\n(wV -. nr w\\n(lC 0 -' in -\\n(eWu -. ie \\n(v\\n(lC==1 \{\ -. nr aa 0 -. \} -. el \{\ -. sp \\n(dVu -. \} -. nf -. nr wV 0 -. \} -. \} -. \} -. nr aP 0 -.\" . ds b1 -. aY -.\" .tm Here is L[\\n(lC]==\\*(L\\n(lC -.\} -.. -.if \n(.g \{\ -. nr i 10 -. while \ni<100 \{\ -. nr num!\nin 1 -. nr i +1 -. \} -.\} -.\" NS lV macro - resolve remaining .Bl arguments -.de lV -.nr aP \\n(aP+1 -.if \\n(fV>=\\n(aP \{\ -. nr iD 0 -. if "\\*(A\\n(aP"-compact" \{\ -. nr iD 1 -. nr v\\n(lC 1 -. \} -. if "\\*(A\\n(aP"-width" \{\ -. nr iD 1 -. nr aP \\n(aP+1 -. nr tW 1 -. ds t\\n(lC TagwidtH -. ds tS \\*(A\\n(aP -. aW \\n(aP -. ie \\n(sW>2 \{\ -. nr w\\n(lC (\\n(sW)*\\n(fWu -. if \\n(sW==3 \{\ -. ie \\n(.g \{\ -. if \A'\\*(tS' .if r num!\\*(tS \{\ -. nr w\\n(lC \\*(tS -. \} -. \} -. el \{\ -. if (\\*(tS>9n)&(\\*(tS<99n) \{\ -. nr w\\n(lC \\*(tSu -. \} -. \} -. \} -. \} -. el \{\ -. aT \\*(tS -. ie \\n(aT==1 \{\ -. nr w\\n(lC \\n(\\*(tS -. \} -. el \{\ -. nr w\\n(lC \\*(tSu -. \} -. \} -. \} -. if "\\*(A\\n(aP"-offset" \{\ -. nr iD 1 -. nr aP \\n(aP+1 -. ie "\\*(A\\n(aP"indent" \{\ -. nr o\\n(lC \\n(Dsu -. \} -. el \{\ -. ds tS \\*(A\\n(aP -. aW \\n(aP -. ie \\n(sW>2 \{\ -. nr o\\n(lC (\\n(sW)*\\n(fWu -. ie \\n(.g \{\ -. if \A'\\*(tS' .if r num!\\*(tS \{\ -. nr o\\n(lC \\*(tS -. \} -. \} -. el \{\ -. if (\\*(tS>9n)&(\\*(tS<100n) \{\ -. nr o\\n(lC \\*(tS -. \} -. \} -. \} -. el \{\ -. ie \\n(C\\n(aP==1 .nr o\\n(lC \\n(\\*(tS -. el .nr o\\n(lC \\*(tS -. \} -. \} -. \} -. if \\n(iD==0 \{\ -. if "\\*(L\\n(lC"cL" \{\ -. nr wV \\n(wV+1 -. ds A\\n(wV \\*(A\\n(aP -. \} -. \} -. if \\n(fV>\\n(aP .lV -.\} -.. -.\" NS El macro - end list -.\" NS iD local register -.de El -.ie \\n(.$>0 \{\ -. tm Usage: .El (#\\n(.c) -.\} -.el \{\ -. ds mN El -. nr iD 0 -. if "\\*(L\\n(lC"cL" \{\ -. nr iD 1 -. cC -. \} -. if "\\*(L\\n(lC"nU" \{\ -. nr nU 0 -. \} -. if \\n(mL>0 \{\ -. nr iD 1 -. nr mL 0 -. tZ -. nr lC \\n(lC-1 -. tY -. \} -. if "\\*(L\\n(lC"iT" \{\ -' in \\n(.iu-\\n(o\\n(lCu -. tZ -. nr lC \\n(lC-1 -. tY -. nr iD 1 -. \} -. if "\\*(L\\n(lC"oL" \{\ -' in \\n(.iu-\\n(o\\n(lCu -. tZ -. nr lC \\n(lC-1 -. tY -. nr iD 1 -. \} -. if "\\*(L\\n(lC"lL" \{\ -' in \\n(.iu-\\n(o\\n(lCu -. tZ -. nr lC \\n(lC-1 -. tY -. nr iD 1 -. \} -. if \\n(iD==0 \{\ -. lE -. \} -. br -. nr iD 0 -.\} -.. -.\" NS It macro - list item -.\" NS iD local register -.\" NS aA save pA font string for section FILES (no underline if nroff) -.de It -.if "\\*(L\\n(lC"" \{\ -. tm Usage .Bl -list-type [-width [string] | -compact | -offset [string]] (#\\n(.c) -. tm .It \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -.\} -.\" .tm Here is L[\\n(lC]==\\*(L\\n(lC -.ne 3v -.ie \\n(.$>0 \{\ -. ds mN It -. ds b1 -. nr iD 0 -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. if "\\*(L\\n(lC"mL" \{\ -. nr iD 1 -. nr aP 0 -. aX -. \\*(L\\n(lC -. \} -. if "\\*(L\\n(lC"cL" \{\ -. ds b1 -. nr aP 0 -. nr iD 1 -. \\*(L\\n(lC -. \} -. if "\\*(L\\n(lC"iT" \{\ -. nr aP 0 -. nr iD 1 -. \\*(L\\n(lC -. \} -. if \\n(iD==0 \{\ -. fV -.\" tm ------------------------------------------------------------------------ -.\" tm It list-type==\\*(L\\n(lC, aP==\\n(aP -.\" tm It beg arg(A[1])==\\*(A1; oM==\\n(oM; dZ==\\n(dZ; Xt==\\n(Xt; aC==\\n(aC -. nr oM \\n(oM+1 -. nr tP 1 -. nr aP \\n(aP+1 -. nr tX \\n(C\\n(aP -. ds tX \\*(A\\n(aP -. if \\n(nF==1 \{\ -. ds aA \\*(pA -. if n .ds pA \\*(nO -. \} -. ie \\n(C\\n(aP==1 \{\ -. \\*(A\\n(aP -. \} -. el \{\ -. nr aP \\n(aP-1 -. No -. \} -.\" tm in It here is b1==\\*(b1 -.\" tm It mid arg(A[1])==\\*(A1; oM==\\n(oM; dZ==\\n(dZ; Xt==\\n(Xt; aC==\\n(aC -. ie \\n(Xt==1 .ds xB \&\\*(L\\n(lC -. el .\\*(L\\n(lC -. \} -. nr iD 0 -.\} -.el .\\*(L\\n(lC -.. -.\" NS lL macro - .It item of list-type inset -.de lL -.lY -.br -\&\\*(b1 -.nr oM \\n(oM-1 -.nr tP 0 -.ds b1 -.aY -'fi -.. -.\" NS hL macro - .It item of list-type hanging label (as opposed to tagged) -.de hL -.lX -.nr bb \\n(w\\n(lCu+\\n(lSu -.ti -\\n(bbu -.ie \w\\*(b1u>=(\\n(w\\n(lCu) \&\\*(b1 -.el \&\\*(b1\h'|\\n(bbu'\c -.nr oM \\n(oM-1 -.ds b1 -.nr tP 0 -.aY -'fi -.. -.\" NS oL macro - .It item of list-type overhanging label -.de oL -.lY -\&\\*(b1 -.br -.nr oM \\n(oM-1 -.ds b1 -.nr tP 0 -.aY -'fi -.. -.\" NS iT macro - .It item of list-type [empty label] -.de iT -.lY -.br -.\" .ds b1 -.aY -'fi -.. -.\" NS nU macro - Enumerated list -.\" NS nU register count -.\" NS hU macro - Hyphen paragraph list (sub bullet list) -.\" NS bU macro - Bullet paragraph list -.de nU -.nr oM \\n(oM+1 -.nr nU \\n(nU+1 -.ds b1 \&\\n(nU. -.uL -.. -.de bU -.nr oM \\n(oM+1 -.nr bU \\n(bU+1 -.ds b1 \&\\*(sY\&\(bu\fP -.uL -.. -.de hU -.nr oM \\n(oM+1 -.nr bU \\n(bU+1 -.ds b1 \&\\*(sY\&\-\fP -.uL -.. -.\" NS uL macro - .It item of list-type enum/bullet/hyphen -.de uL -.lX -.nr bb \\n(w\\n(lCu+\\n(lSu -.ti -\\n(bbu -.ie \w\\*(b1u>=(\\n(w\\n(lCu) \&\\*(b1 -.el \&\\*(b1\h'|\\n(bbu'\c -.nr oM \\n(oM-1 -.\" .nr dZ \\n(dZ+1 -.ds b1 -.nr tP 0 -.aY -'fi -.. -.\" NS mL macro - .It item of list-type diagnostic-message -.de mL -.nr cF \\n(.f -.nr cZ \\n(.s -.ie \\n(mL==1 \{\ -. nr zB \\n(.c -. ie (\\n(zB-\\n(zA)>1 .Pp -. el .br -. nr zA \\n(zB -. nr zB 0 -.\} -.el \{\ -. nr zA \\n(.c -. br -.\} -\&\\*(sY\\*(b1\f\\n(cF\s\\n(cZ\\*(lS\c -.aY -.ds b1 -'fi -.. -.\" NS tL macro - .It item of list-type "tag" -.de tL -.\" tm in tL here is b1==\\*(b1 -.if \\n(tW==0 .lW -.lX -.nr bb \\n(w\\n(lCu+\\n(lSu -.ti -\\n(bbu -.ie (\w\\*(b1u)>(\\n(w\\n(lCu) \{\&\\*(b1 -. br -.\} -.el \&\\*(b1\h'|\\n(bbu'\c -.if \\n(nF==1 \{\ -. if n .ds pA \\*(aA -.\} -.nr oM \\n(oM-1 -.nr tP 0 -.\" .nr dZ \\n(dZ+1 -.ds b1 -.aY -'fi -.. -.\" NS lW macro - resolve unknown label/tag width (if .Bl [inset | tag] only) -.de lW -.if !"TagwidtH"\\*(t\\n(lC" \{\ -. ie \\n(tX==1 \{\ -. ds t\\n(lN \\*(tX -. nr w\\n(lN \\n(\\*(tX -. \} -. el \{\ -. ds t\\n(lN No -. nr w\\n(lN \\n(No -. \} -. if !"\\*(t\\n(lC"\\*(t\\n(lN" .nr tC 1 -.\} -.. -.\" NS lX macro - set up vertical spacing (if compact) and offset+indent (all) -.de lX -.ie \\n(tC \{\ -. nr tC 0 -. nr tW 0 -. if \\n(v\\n(lC==0 .sp \\n(dVu -. in \\n(.iu+\\n(w\\n(lCu+\\n(o\\n(lCu+\\n(lSu -.\} -.el \{\ -. ie \\n(v\\n(lC==1 \{\ -. nr aa 0 -. \} -. el \{\ -. sp \\n(dVu -. \} -.\} -.if !\\n(cR .ne 2v -.. -.\" NS lY macro - set up vertical spacing (if compact) and offset+indent (all) -.de lY -.ie \\n(tC \{\ -. nr tC 0 -. nr tW 0 -. if \\n(v\\n(lC==0 .sp \\n(dVu -. in \\n(.iu+\\n(o\\n(lCu -.\} -.el \{\ -. ie \\n(v\\n(lC==1 \{\ -. nr aa 0 -. \} -. el \{\ -. sp \\n(dVu -. \} -.\} -.if !\\n(cR .ne 2v -.. -.\" NS tS temporary string -.\" NS hL macro - hanging list function -.\" NS tS temporary string -.\" NS hL macro - hanging list function -.\" NS lT macro - tagged list function -.\" NS lE macro - list end function -.\" NS tX string (initial string) -.\" NS tX register (initial class) -.\" NS tC parameter change flag -.\" NS Xt save current list-type flag -.\" NS lC register - list type stack counter -.\" NS tP register tag flag (for diversions) -.\" NS w[0-9] register tag stack (nested tags) -.\" NS t[0-9] register tag string stack (nested tags) -.\" NS o[0-9] register offset stack (nested tags) -.\" NS v[0-9] register vertical tag break stack -.\" NS h[0-9] register horizontal tag stack (continuous if 1, break if 0) -.nr lC 0 -.nr wV 0 -.nr w1 0 -.nr o1 0 -.nr v1 0 -.nr h1 0 -.ds t\n(lC -.de lE -.\" IN lC o[\\n(lC]==\\n(o\\n(lC, w[\\n(lC]==\\n(w\\n(lC, -.ie \\n(o\\n(lC>0 \{\ -' in \\n(.iu-(\\n(w\\n(lCu)-(\\n(o\\n(lCu)-\\n(lSu -. rr o\\n(lC -.\} -.el 'in \\n(.iu-\\n(w\\n(lCu-\\n(lSu -.if \\n(lC<=0 .tm Extraneous .El call (#\\n(.c) -.tZ -.nr lC \\n(lC-1 -.tY -.. -.\" NS tY macro - set up next block for list -.\" NS tZ macro - decrement stack -.\" NS tY register (next possible lC value) -.de tY -.nr tY (\\n(lC+1) -.nr w\\n(tY 0 -.nr h\\n(tY 0 -.nr o\\n(tY 0 -.ds t\\n(tY \\*(t\\n(lC -.ds L\\n(tY -.nr v\\n(tY 0 -.. -.de tZ -.rm L\\n(tY -.rr w\\n(tY -.rr h\\n(tY -.rr o\\n(tY -.rm t\\n(tY -.rr v\\n(tY -.nr tY \\n(tY-1 -.. -.\" initial values -.nr w1 0 -.nr o1 0 -.nr h1 0 -.ds t1 -.nr v1 0 -.nr tY 1 -.\" NS Xr macro - cross reference (man page only) -.de Xr -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Xr manpage_name [section#] \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Xr -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 .tm Usage: .Xr manpage_name [section#] \\*(Pu (#\\n(.c) -. el \{\ -. ie \\n(C\\n(aP>2 .y\\n(C\\n(aP -. el \{\ -. as b1 \&\\*(xR\\*(A\\n(aP\fP\s0 -. if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. if \\n(C\\n(aP==2 \{\ -. as b1 \&(\\*(A\\n(aP) -. nr aP \\n(aP+1 -. \} -. if \\n(aC>=\\n(aP \{\ -. c\\n(C\\n(aP -. \} -. \} -. \} -. aZ -. \} -.\} -.. -.\" NS Sx macro - cross section reference -.de Sx -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Sx Usage: .Sx Section Header \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Sx -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. as b1 \\*(sX -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS cC macro - column-list end-list -.\" NS eW macro - column indent width -.\" NS cI register - column indent width -.\" NS W[1-5] macro - establish tabs for list-type column -.de cC -'in \\n(.iu-\\n(o\\n(lCu-\\n(w\\n(lCu -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.fi -.tZ -.nr lC \\n(lC-1 -.tY -.. -.de W1 -.ta \w\\*(A1 u -.nr eW \w\\*(A1 u -'in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.de W2 -.ta \w\\*(A1 u +\w\\*(A2 u -.nr eW \w\\*(A1 u+\w\\*(A2 u -'in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.de W3 -.ta \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u -.nr eW \w\\*(A1 u+\w\\*(A2 u+\w\\*(A3 u -'in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.de W4 -.ta \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u -.nr eW \w\\*(A1 u+\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u -'in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.de W5 -.ta \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u +\w\\*(A5 u -.nr eW \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u +\w\\*(A5 u -' in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.\" This is packed abnormally close, intercol width should be an option -.de W6 -.ta \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u +\w\\*(A5 u +\w\\*(A6 -.nr eW \w\\*(A1 u +\w\\*(A2 u +\w\\*(A3 u +\w\\*(A4 u +\w\\*(A5 u +\w\\*(A6 -' in \\n(.iu+\\n(eWu+\\n(o\\n(lCu -.. -.\" NS cL macro - column items -.de cL -.if \\n(w\\n(lC==0 .nr w\\n(lC \\n(eWu -.if \\n(.u==0 \{\ -. fi -' in \\n(.iu+\\n(eWu -.\} -.ti -\\n(eWu -.fV -.nr aP \\n(aP+1 -.ie \\n(aC>=\\n(aP \{\ -. if "\\*(A\\n(aP"Ta" \{\ -. nr jJ \\n(aP-1 -. rm S\\n(jJ -. rr jJ -. \} -. c\\n(C\\n(aP -.\} -.el .tm Usage: .It column_string [Ta [column_string ...] ] (#\\n(.c) -.. -.\" NS Ta macro - append tab (\t) -.de Ta -.ie \\n(aC>0 \{\ -. nr aP \\n(aP+1 -. ie \\n(aC>=\\n(aP \{\ -. if "\\*(A\\n(aP"Ta" \{\ -. nr jJ \\n(aP-1 -. rm S\\n(jJ -. rr jJ -. \} -. as b1 \\t -. c\\n(C\\n(aP -. \} -. el \{\ -. as b1 \\t\\c -. rm S\\n(aP -. pB -. aY -.\" . ds b1 -. \} -.\} -.el \{\ -. tm Usage: Ta must follow column entry: e.g. (#\\n(.c) -. tm .It column_string [Ta [column_string ...] ] -.\} -.. -.\" -.\" NS Dl macro - display (one line) literal -.de Dl -'ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.in \\n(.iu+\\n(Dsu -.ie \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. tm Usage: .Dl argument ... (#\\n(.c) -. \} -. el \{\ -. ds mN Dl -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. Li -. \} -.\} -.el \{\ -. tm Usage: .Dl not callable by other macros (#\\n(.c) -.\} -.in \\n(.iu-\\n(Dsu -.. -.\" -.\" NS D1 macro - display (one line) -.de D1 -'ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.in \\n(.iu+\\n(Dsu -.ie \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -. tm Usage: .D1 argument ... (#\\n(.c) -. \} -. el \{\ -. ds mN D1 -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 .\\*(A\\n(aP -. el .No -. \} -.\} -.el \{\ -. tm Usage: .D1 not callable by other macros (#\\n(.c) -.\} -.in \\n(.iu-\\n(Dsu -.. -.\" NS Ex macro - DEFUNCT -.de Ex -.tm Ex defunct, Use .D1: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" -.\" NS Ex macro - DEFUNCT -.de Ex -.tm Ex defunct, Use .D1: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" -.\" NS Vt macro - Variable type (for forcing old style variable declarations) -.\" this is not done in the same manner as .Ot for fortrash - clean up later -.de Vt -.\" if a function declaration was the last thing given, want vertical space -.if \\n(fD>0 \{\ -. Pp -. nr fD 0 -.\} -.\" if a subroutine was the last thing given, want vertical space -.if \\n(fZ>0 \{\ -. ie \\n(fX==0 \{\ -. Pp -. rs -. \} -. el .br -.\} -.nr fX \\n(fX+1 -.nr cF \\n(.f -.nr cZ \\n(.s -\\*(fT\&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.ie \\n(oT==0 .br -.el \&\ \& -.ft \\n(cF -.fs \\n(cZ -.. -.\" -.\" NS Ft macro - Function type -.nr fZ 0 -.de Ft -.if \\n(nS>0 \{\ -. if \\n(fZ>0 \{\ -. Pp -. nr fD 0 -. nr fX 0 -. \} -. if \\n(fD>0 \{\ -. Pp -. nr fD 0 -. nr fX 0 -. \} -. if \\n(fX>0 \{\ -. Pp -. nr fX 0 -. \} -. nr fY 1 -.\} -.nr cF \\n(.f -.nr cZ \\n(.s -\&\\*(fT\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.ft \\n(cF -.fs \\n(cZ -.\" .br -.. -.\" -.\" NS Ot macro - Old Function type (fortran - no newline) -.\" Ns oT register -.nr oT 0 -.de Ot -.nr oT 1 -.if \\n(nS>0 \{\ -. if \\n(fZ>0 \{\ -. Pp -. nr fD 0 -. nr fX 0 -. \} -. if \\n(fD>0 \{\ -. Pp -. nr fD 0 -. nr fX 0 -. \} -. if \\n(fX>0 \{\ -. Pp -. nr fX 0 -. \} -. nr fY 1 -.\} -.if \\n(.$==4 .as b1 \&\\*(fT\&\\$1 \\$2 \\$3 \\$4 -.if \\n(.$==3 .as b1 \&\\*(fT\&\\$1 \\$2 \\$3 -.if \\n(.$==2 .as b1 \&\\*(fT\&\\$1 \\$2 -.if \\n(.$==1 .as b1 \&\\*(fT\&\\$1 -.as b1 \&\ \fP -.. -.\" -.\" NS Fa macro - Function arguments -.de Fa -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Fa Function Arguments ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Fa -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.ie \\n(fC>0 \{\ -. fC -.\} -.el \{\ -. if \\n(aC>\\n(aP \{\ -. as b1 \\*(fA -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -. if \\n(nS>0 \{\ -. if \\n(fZ>0 .br -. \} -. \} -.\} -.. -.\" NS fC macro - interal .Fa for .FO and .Fc -.de fC -.ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -.\" . nr aa \\n(aP -.\" . if \\n(nS>0 \{\ -. ds Fb -. nr fB 0 -. nr Fb 0 -. fB \\*(A\\n(aP -. if \\n(fB>1 \{\ -. rm A\\n(aP -. rn Fb A\\n(aP -. \} -.\" . \} -. if \\n(fC>1 \{\ -. as b1 \&\f\\n(cF\s\\n(cZ\|,\\*(fA\\*(S\\n(aP\\*(A\\n(aP\fP\s0 -. \} -. if \\n(fC==1 \{\ -. as b1 \&\|\\*(fA\\*(A\\n(aP\fP\s0 -. \} -. nr fC \\n(fC+1 -. fC -.\} -.el \{\ -. aY -.\} -.. -.\" NS Fn macro - functions -.\" NS fY register - dick with old style function declarations (fortran) -.\" NS fZ register - break a line when more than one function in a synopsis -.\" -.de Fn -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Fn function_name function_arg(s) ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN Fn -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(nS>0 \{\ -.\" if there is/has been more than one subroutine declaration -. if \\n(fY==0 \{\ -. if \\n(fZ>0 \{\ -. Pp -. nr fX 0 -. nr fD 0 -. \} -. \} -. if \\n(fY==1 \{\ -. br -. nr fX 0 -. nr fD 0 -. nr fY 0 -. \} -. if \\n(fD>0 \{\ -. Pp -. nr fX 0 -. \} -. if \\n(fX>0 \{\ -. Pp -. nr fD 0 -. \} -. nr fZ \\n(fZ+1 -. nr fY 0 -. rs -. ie \\n(nS>1 .br -. el \{\ -. if \\n(iS==0 \{\ -. nr iS ((8)*\\n(fW)u -. \} -. \} -. in +\\n(iSu -. ti -\\n(iSu -. nr nS \\n(nS+1 -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. as b1 \\*(fN\\*(A\\n(aP\fP\s0\\*(lp -. ie \\n(aC>\\n(aP \{\ -. as b1 \\*(fA -. nr aP \\n(aP+1 -. f\\n(C\\n(aP -. \} -. el \{\ -. ie \\n(nS>0 .as b1 \|\\*(rp\fR;\fP -. el .as b1 \|\\*(rp -. aZ -. \} -. if \\n(nS>0 \{\ -. in -\\n(iSu -. \} -.\} -.. -.\" -.\" NS f1 macro - class switch -.\" NS f2 macro - handle function arguments -.\" NS f3 macro - punctuation -.\" NS f4 macro - write out function -.de f1 -.ie \\n(nS>0 .as b1 \\*(rp\fR;\fP\f\\n(cF\s\\n(cZ -.el .as b1 \\*(rp\f\\n(cF\s\\n(cZ -.\\*(A\\n(aP -.. -.de f2 -.if \\n(nS>0 \{\ -. ds Fb -. nr fB 0 -. nr Fb 0 -. fB \\*(A\\n(aP -. if \\n(fB>1 \{\ -. rm A\\n(aP -. rn Fb A\\n(aP -. \} -.\} -.as b1 \\*(A\\n(aP -.ie \\n(aC>\\n(aP \{\ -. nr aa \\n(aP -. nr aP \\n(aP+1 -. if \\n(C\\n(aP==2 \{\ -. as b1 \&\|\f\\n(cF\s\\n(cZ,\\*(S\\n(aa\fP\s0\| -. \} -. f\\n(C\\n(aP -.\} -.el \{\ -. ie \\n(nS>0 .as b1 \\*(rp\fR;\fP\f\\n(cF\s\\n(cZ -. el .as b1 \\*(rp\f\\n(cF\s\\n(cZ -. aZ -.\} -.. -.de f3 -.ie \\n(nS>0 .as b1 \\*(rp\f\\n(cF\s\\n(cZ\\*(A\\n(aP -.el .as b1 \\*(rp\f\\n(cF\s\\n(cZ\\*(A\\n(aP -.ie \\n(aC>\\n(aP \{\ -. No -.\} -.el .aZ -.. -.de f4 -.ie \\n(nS>0 .as b1 \\*(rp\fR;\fP\f\\n(cF\s\\n(cZ\\*(S\\n(aP\\*(A\\n(aP -.el .as b1 \\*(rp\f\\n(cF\s\\n(cZ\\*(S\\n(aP\\*(A\\n(aP -.ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. No -.\} -.el .aZ -.. -.de Fo -.hy 0 -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .Fo function_name -. el \{\ -. ds mN Fo -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(nS>0 \{\ -.\" if there is/has been more than one subroutine declaration -. if \\n(fY==0 \{\ -. if \\n(fZ>0 \{\ -. Pp -. nr fX 0 -. nr fD 0 -. \} -. \} -. if \\n(fY==1 \{\ -. br -. nr fX 0 -. nr fD 0 -. nr fY 0 -. \} -. if \\n(fD>0 \{\ -. Pp -. nr fX 0 -. \} -. if \\n(fX>0 \{\ -. Pp -. nr fD 0 -. \} -. nr fZ \\n(fZ+1 -. nr fY 0 -. rs -. ie \\n(nS>1 .br -. el \{\ -. if \\n(iS==0 \{\ -. nr iS ((8)*\\n(fW)u -. \} -. \} -. in +\\n(iSu -. ti -\\n(iSu -. nr nS \\n(nS+1 -.\} -.if \\n(aC>\\n(aP \{\ -. nr oM \\n(oM+1 -. nr fC 1 -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. as b1 \\*(fN\\*(A\\n(aP\fP\s0\\*(lp -. aY -.\} -.. -.de Fc -.if \\n(aC==0 \{\ -. if \\n(.$>0 \{\ -. ds mN Fo -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.nr fC 0 -.nr oM \\n(oM-1 -.ie \\n(nS>0 .as b1 \|\\*(rp\fR;\fP -.el .as b1 \|\\*(rp -.ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. \\*(A\\n(aP -.\} -.el \{\ -. aZ -.\} -.if \\n(nS>0 \{\ -. in -\\n(iSu -.\} -.hy -.. -.\" NS fb macro - if SYNOPSIS, set hard space inbetween function args -.\" NS fb register - count of words in a function argument -.\" NS Fb register - counter -.\" NS Fb string - temporary string -.de fB -.\" .tm fB==\\n(fB, Fb==\\n(Fb, 1==\\$1 2==\\$2 3==\\$3 4==\\$4 5==\\$5 6==\\$6 -.if \\n(fB==0 \{\ -. nr fB \\n(.$ -. nr Fb 0 -. ds Fb -.\} -.nr Fb \\n(Fb+1 -.as Fb \&\\$1 -.if \\n(Fb<\\n(fB \{\ -. as Fb \&\\*(hV -. fB \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.. -.\" NS Fc - Function close - not implemented yet -.\" NS Fo - Function open - not implemented yet -.\" -.\" Very crude references, stash all reference info into strings (usual -.\" use of b1 buffer, then b1 contents copied to string of retrievable -.\" naming convention), print out reference on .Re request and clean up. -.\" Ordering very limited, no fancy citations, but can do articles, journals -.\" and books - need to add several missing options (like city etc). -.\" should be able to grab a refer entry, massage it a wee bit (prefix -.\" a `.' to the %[A-Z]) and not worry (ha!) -.\" -.\" NS Rs macro - Reference Start -.\" NS rS register - Reference Start flag -.\" NS rS string - Reference Start buffer name for next save (of b1 buffer) -.de Rs -.nr rS 1 -.rC -.if \\n(nA==1 .Pp -.nr Kl 0 -.. -.\" NS Re macro - Reference End -.de Re -.rZ -.rC -.nr rS 0 -.. -.\" NS rC macro - reference cleanup -.de rC -.nr uK 0 -.nr jK 0 -.nr iK 0 -.nr nK 0 -.nr oK 0 -.nr qK 0 -.nr rK 0 -.nr tK 0 -.nr vK 0 -.nr dK 0 -.nr pK 0 -.nr bK 0 -.ds rS -.rm U1 U2 U3 U4 U5 U6 U7 U8 -.rm uK jK iK nK oK rK qK tK vK dK pK bK -.. -.\" NS rZ macro - reference print -.de rZ -.if \\n(uK \{\&\\*(U1, -. nr aK 1 -. if (\\n(uK>1 \{\ -. aK -. \} -. nr Kl -\\n(uK -.\} -.if \\n(tK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \{\ -. ie (\\n(jK==1):(\\n(bK==1) \{\&\\*q\\*(tK\\*q. -. \} -. el \{\&\\*(eM\\*(tK\\*(nO. -. \} -. \} -. if \\n(Kl>0 \{\ -. ie (\\n(jK==1):(\\n(bK==1) \{\&\\*q\\*(tK\\*q, -. \} -. el \{\&\\*(eM\\*(tK\\*(nO, -. \} -. \} -.\} -.if \\n(bK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(eM\\*(bK\\*(nO. -. if \\n(Kl>0 \&\\*(eM\\*(bK\\*(nO, -.\} -.if \\n(iK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(eM\\*(iK\\*(nO. -. if \\n(Kl>0 \&\\*(eM\\*(iK\\*(nO, -.\} -.if \\n(jK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(eM\\*(jK\\*(nO. -. if \\n(Kl>0 \&\\*(eM\\*(jK\\*(nO, -.\} -.if \\n(rK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(rK. -. if \\n(Kl>0 \&\\*(rK, -.\} -.if \\n(nK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(nK. -. if \\n(Kl>0 \&\\*(nK, -.\} -.if \\n(vK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(vK. -. if \\n(Kl>0 \&\\*(vK, -.\} -.if \\n(pK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(pK. -. if \\n(Kl>0 \&\\*(pK, -.\} -.if \\n(qK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(qK. -. if \\n(Kl>0 \&\\*(qK, -.\} -.if \\n(dK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(dK. -. if \\n(Kl>0 \&\\*(dK, -.\} -.if \\n(oK \{\ -. nr Kl \\n(Kl-1 -. if \\n(Kl==0 \&\\*(oK. -. if \\n(Kl>0 \&\\*(oK, -.\} -.if \\n(Kl>0 .tm unresolved reference problem -.. -.\" NS aK macro - print out reference authors -.de aK -.nr aK \\n(aK+1 -.ie (\\n(uK-\\n(aK)==0 \{\&and \\*(U\\n(aK, -.\} -.el \{\&\\*(U\\n(aK, -. aK -.\} -.. -.\" NS %A macro - reference author(s) -.\" NS uK register - reference author(s) counter -.\" NS U[1-9] strings - reference author(s) names -.de %A -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%A Author_name (#\\n(.c) -. el \{\ -. nr uK \\n(uK+1 -. nr Kl \\n(Kl+1 -. ds rS U\\n(uK -. ds mN %A -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %B macro - [reference] Book Name -.\" NS bK string - Book Name -.\" NS bK register - Book Name flag -.de %B -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%B Book Name (#\\n(.c) -. el \{\ -. ds mN %B -. if \\n(rS>0 \{\ -. nr bK \\n(bK+1 -. nr Kl \\n(Kl+1 -. ds rS bK -. \} -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. ie \\n(rS==0 \{\ -. as b1 \&\\*(eM -. nR -. \} -. el .rR -.\} -.. -.\" NS %D macro - [reference] Date -.\" NS dK string - Date String -.\" NS dK register - Date flag -.de %D -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%D Date (#\\n(.c) -. el \{\ -. ds mN %D -. nr dK \\n(dK+1 -. nr Kl \\n(Kl+1 -. ds rS dK -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %I macro - [reference] Issuer/Publisher Name -.\" NS jK register - [reference] Issuer/Publisher Name flag -.\" NS jK string - [reference] Issuer/Publisher Name -.de %I -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%I Issuer/Publisher Name (#\\n(.c) -. el \{\ -. ds mN %I -. nr iK \\n(iK+1 -. ds rS iK -. nr Kl \\n(Kl+1 -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %J macro - [reference] Journal Name -.\" NS jK register - [reference] Journal Name flag -.\" NS jK string - [reference] Journal Name -.de %J -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%J Journal Name (#\\n(.c) -. el \{\ -. ds mN %J -. nr jK \\n(jK+1 -. ds rS jK -. nr Kl \\n(Kl+1 -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %N macro - [reference] issue number -.\" NS nK register - [reference] issue number flag -.\" NS nK string - [reference] issue number -.de %N -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%N issue number (#\\n(.c) -. el \{\ -. nr nK \\n(nK+1 -. nr Kl \\n(Kl+1 -. ds rS nK -. ds mN %N -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %O macro - [reference] optional information -.\" NS oK register - [reference] optional information flag -.\" NS oK string - [reference] optional information -.de %O -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%O optional information ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN %O -. nr oK \\n(oK+1 -. nr Kl \\n(Kl+1 -. ds rS oK -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %P macro - [reference] page numbers -.\" NS pK register - [reference] page number flag -.\" NS pK string - [reference] page number -.de %P -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%P page numbers ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN %P -. nr pK \\n(pK+1 -. nr Kl \\n(Kl+1 -. ds rS pK -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %Q macro - Corporate or Foreign Author -.\" NS qK string - Corporate or Foreign Author -.\" NS qK register - Corporate or Foreign Author flag -.de %Q -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%Q Corporate or Foreign Author (#\\n(.c) -. el \{\ -. ds mN %Q -. nr qK \\n(qK+1 -. nr Kl \\n(Kl+1 -. ds rS qK -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %R macro - [reference] report name -.\" NS rK string - [reference] report name -.\" NS rK register - [reference] report flag -.de %R -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%R reference report (#\\n(.c) -. el \{\ -. ds mN %R -. nr rK \\n(rK+1 -. nr Kl \\n(Kl+1 -. ds rS rK -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS %T macro - reference title -.\" NS tK string - reference title -.\" NS tK register - reference title flag -.de %T -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%T (#\\n(.c) -. el \{\ -. ds mN %T -. if \\n(rS>0 \{\ -. nr tK \\n(tK+1 -. nr Kl \\n(Kl+1 -. ds rS tK -. \} -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -.\" . ie \\n(jS==1 \{\ -.\" . nr cF \\n(.f -.\" . nr cZ \\n(.s -.\" . ds qL \&\\*(Lq\\*(rA -.\" . ds qR \&\\*(Rq\f\\n(cF\s\\n(cZ -.\" . En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\" . \} -.\" . el \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. ie \\n(rS==0 \{\ -. as b1 \&\\*(eM -. nR -. \} -. el .rR -.\" . \} -.\} -.. -.\" NS %V macro - reference volume -.\" NS vK string - reference volume -.\" NS vK register - reference volume flag -.de %V -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .%V Volume , ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN %V -. nr vK \\n(vK+1 -. nr Kl \\n(Kl+1 -. ds rS vK -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. rR -.\} -.. -.\" NS rR macro - reference recursion routine -.\" NS jM local register -.\" NS jN local register -.de rR -.hy 0 -.nr jM \\n(C\\n(aP -.ie \\n(jM==1 \{\ -.\" . as b1 \&\f\\n(cF\s\\n(cZ -. ie "\\*(A\\n(aP"Tn" \{\ -. nN -. \} -. el \{\ -. if \\n(aC>8 .tm Usage: \\*(mN - maximum 8 arguments (#\\n(.c) -. aI rR 1 -. \\*(A\\n(aP -. \} -.\} -.el \{\ -. nr jN \\n(aP -. ie \\n(jM==2 .as b1 \&\\*(A\\n(aP -. el .as b1 \&\\*(A\\n(aP -.\" . el .as b1 \&\f\\n(cF\s\\n(cZ\\*(A\\n(aP\fP\s0 -. ie \\n(aC==\\n(aP \{\ -.\" . as b1 \&\f\\n(cF\s\\n(cZ -. rD -. \} -. el \{\ -. nr aP \\n(aP+1 -. as b1 \&\\*(S\\n(jN -. rR -. \} -.\} -.rr jM jN -.. -.\" NS rD macro - save b1 buffer in to appropriate name -.de rD -.as \\*(rS \\*(b1 -.ds b1 -.ds rS -.aY -.. -.\" NS Hf macro - source include header files. -.de Hf -.Pp -File: -.Pa \\$1 -.Pp -.nr cF \\n(.f -.nr cZ \\n(.s -.ie t \{\ -\&\\*(lI -.br -.ta +9n 18n 27n 36n 45n 54n 63n 72n -.\} -.el \{\ -.ta +8n 16n 24n 32n 40n 48n 56n 64n 72n -.\} -.nf -.so \\$1 -.fi -.ft \\n(cF -.fz \\n(cZ -.Pp -.. -.\" NS An macro - author name -.\" NS aN register -.nr aN 0 -.de An -.if \\n(nY==1 \{\ -. ie \\n(aN==1 \{\ -. br -. \} -. el \{\ -. nr aN 1 -. \} -.\} -.if \\n(aC==0 \{\ -. ie \\n(.$==0 .tm Usage: .An author_name ... \\*(Pu (#\\n(.c) -. el \{\ -. ds mN An -. aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nr cF \\n(.f -. nr cZ \\n(.s -. nR -.\} -.. -.\" NS Sf macro -defunct -.de Sf -.tm .Sf defunct, use prefix or Ns -.. -.ds rV "function returns the value 0 if successful; otherwise the value -1 is returned and the global variable \\*(vAerrno\fP is set to indicate the error. -.\" Ns Rv macro - return values -.\" Ns rV string - standard return message -.de Rv -.ie \\n(.$==0 \{\ -.tm Usage: .Rv [-std] (#\\n(.c) -.\} -.el \{\ -. ds mN Rv -.\" . nr aP 0 -.\" . nr lR \\n(lR+1 -.\" . ds A1 \\$2 -.\" . ds A2 \\$3 -.\" . ds A3 \\$4 -.\" . ds A4 \\$5 -.\" . ds A5 \\$6 -.\" . ds A6 \\$7 -.\" . ds A7 \\$8 -.\" . ds A8 \\$9 -.\" . nr fV \\n(.$-1 -. if "\\$1"-std" \{\ -. nr cH \\*(cH -. if (\\n(cH<2):(\\n(cH>3) .tm Usage: .Rv -std sections 2 and 3 only -. br -\&The -.Fn \\$2 -\&\\*(rV -. \} -.\} -.. diff --git a/share/tmac/doc-common b/share/tmac/doc-common deleted file mode 100644 index a8aef9ed6448..000000000000 --- a/share/tmac/doc-common +++ /dev/null @@ -1,432 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc-common 8.1 (Berkeley) 6/8/93 -.\" -.\" %beginstrip% -.nr %A 1 -.nr %J 1 -.nr %N 1 -.nr %O 1 -.nr %R 1 -.nr %T 1 -.nr %V 1 -.nr Ad 12n -.nr Ac 3 -.nr Ao 12n -.nr An 12n -.nr Aq 12n -.nr Ar 12n -.nr Bc 3 -.nr Bl 1 -.nr Bo 12n -.nr Bq 12n -.nr Cd 12n -.nr Cm 10n -.nr Dc 3 -.nr Do 10n -.nr Dq 12n -.nr Ds 6n -.nr Dq 12n -.nr Dv 12n -.nr Ec 3 -.nr El 1 -.nr Eo 12n -.nr Eq 12n -.nr Em 10n -.nr Er 12n -.nr Ev 15n -.nr Fa 12n -.nr Fl 10n -.nr Fc 3 -.nr Fo 16n -.nr Fn 16n -.nr I1 6n -.nr I2 12n -.nr I3 18n -.nr Ic 10n -.nr Li 16n -.nr Ms 6n -.nr Nm 10n -.nr No 12n -.nr Ns 2 -.nr Oo 10n -.nr Oc 3 -.nr Op 14n -.nr Pa 32n -.nr Pf 12n -.nr Pc 3 -.nr Po 12n -.nr Pq 12n -.nr Ql 16n -.nr Sc 3 -.nr So 12n -.nr Sq 12n -.nr Sy 6n -.nr Sx 16n -.nr Rv 1 -.nr Tn 10n -.nr Ta 1 -.nr Tv 1 -.nr Tx 22n -.nr Va 12n -.nr Xc 3 -.nr Xo 1 -.nr Xr 10n -.ds sV \& \& -.ds hV \&\ \& -.ds iV \& \& -.ds tV \&\\t\& -.\" Punctuation values (3 = closing punctuation, 4 = opening) -.nr z. 3 -.nr z, 3 -.nr z: 3 -.nr z; 3 -.nr z( 4 -.nr z) 3 -.nr z[ 4 -.nr z] 3 -.\" Matching pairs -.ds z( z) -.ds z[ z] -.ds z< z> -.\" This is disgusting, troff not parse ``if'' stmt properly -.nr z0 0 -.nr z1 0 -.nr z2 0 -.nr z3 0 -.nr z4 0 -.nr z5 0 -.nr z6 0 -.nr z7 0 -.nr z8 0 -.nr z9 0 -.nr z# 0 -.\" Header assembly macros -.de Dt -.ds dT UNTITLED -.ds vT LOCAL -.ds cH Null -.if !"\\$1"" .ds dT \\$1 -.if !"\\$2"" \{\ -. ds cH \\$2 -.\" . if "\\$3"" \{\ -. if \\$2>=1 .if \\$2<=8 \{\ -. ds vT BSD Reference Manual -. if \\$2>1 .if \\$2<6 .ds vT BSD Programmer's Manual -. if "\\$2"8" .ds vT BSD System Manager's Manual -. nr sN \\$2 -. \} -. if "\\$2"unass" .ds vT DRAFT -. if "\\$2"draft" .ds vT DRAFT -. if "\\$2"paper" .ds vT UNTITLED -.\" . \} -.\} -.if !"\\$3"" \{\ -. if "\\$3"USD" .ds vT BSD User's Supplementary Documents -. if "\\$3"PS1" .ds vT BSD Programmers's Supplementary Documents -. if "\\$3"AMD" .ds vT BSD Ancestral Manual Documents -. if "\\$3"SMM" .ds vT BSD System Manager's Manual -. if "\\$3"URM" .ds vT BSD Reference Manual -. if "\\$3"PRM" .ds vT BSD Programmers's Manual -. if "\\$3"IND" .ds vT BSD Manual Master Index -.\" . if "\\$3"CON" .ds vT BSD Contributed Software Manual -.\" . if "\\$3"IMP" .ds vT BSD Implementation Notes -.\" . if "\\$3"HOW" .ds vT BSD How Pocket Manual -. if "\\$3"LOCAL" .ds vT BSD Local Manual -. if "\\$3"tahoe" .as vT \ (Tahoe Architecture) -. if "\\$3"vax" .as vT \ (VAX Architecture) -. if "\\$3"hp300" .as vT \ (HP300 Architecture) -. if "\\$3"sparc" .as vT \ (SPARC Architecture) -. if "\\*(vT"LOCAL" .ds vT \\$3 -.\} -.. -.\" NS Os macro - Operating System (behaviour changes after first call) -.\" . ds vT \f(CODRAFT\fP\ \ \-\-\ \ \\*(vT\ \ \-\-\ \ \f(CODRAFT -.\" . ds dD \f(CODRAFT\fP\ \ \-\-\ \ \\*(dD\ \ \-\-\ \ \f(CODRAFT -.\" .ds vT \s+4\f(CODRAFT\fP\s-4\ \ \-\-\ \ \\*(vT\ \ \-\-\ \ \s+4\f(CODRAFT\s-4 -.\" .ds dD \s+4\f(CODRAFT\fP\s-4\ \ \-\-\ \ \\*(dD\ \ \-\-\ \ \s+4\f(CODRAFT\s-4 -.de Os -.ds oS Null -.if "\\$1"" \{\ -. ds oS 4.4BSD -.\} -.if "\\$2"" \{\ -. ds aa Non-Null -.\} -.if "\\$1"ATT" \{\ -. ds oS AT&T -. if "\\$2"" .as oS \0UNIX -. if "\\$2"7th" .as oS \07th Edition -. if "\\$2"7" .as oS \07th Edition -. if "\\$2"III" .as oS \0System III -. if "\\$2"3" .as oS \0System III -. if "\\$2"V" .as oS \0System V -. if "\\$2"V.2" .as oS \0System V Release 2 -. if "\\$2"V.3" .as oS \0System V Release 3 -. if "\\$2"V.4" .as oS \0System V Release 4 -.\} -.if "\\$1"BSD" \{\ -. if "\\$2"3" .ds oS 3rd Berkeley Distribution -. if "\\$2"4" .ds oS 4th Berkeley Distribution -. if "\\$2"4.1" .ds oS 4.1 Berkeley Distribution -. if "\\$2"4.2" .ds oS 4.2 Berkeley Distribution -. if "\\$2"4.3" .ds oS 4.3 Berkeley Distribution -. if "\\$2"4.3T" .ds oS 4.3-Tahoe Berkeley Distribution -. if "\\$2"4.3R" .ds oS 4.3-Reno Berkeley Distribution -. if "\\$2"4.3t" .ds oS 4.3-Tahoe Berkeley Distribution -. if "\\$2"4.3r" .ds oS 4.3-Reno Berkeley Distribution -. if "\\$2"4.4" .ds oS 4.4BSD -.\} -.if "\\*(oS"Null" .ds oS \0\\$1 -.if "\\*(aa"Non-Null" .as oS \0\\$2 -.rm aa -.. -.de Dd -.if !"\\*(dD"" .nr gX 1 -.ie \\n(.$>0 \{\ -. ie \\n(.$==3 \{\ -. ds dD \\$1 \\$2 \\$3 -. \} -. el \{\ -. if "\\n(mo"1" .ds dD January -. if "\\n(mo"2" .ds dD February -. if "\\n(mo"3" .ds dD March -. if "\\n(mo"4" .ds dD April -. if "\\n(mo"5" .ds dD May -. if "\\n(mo"6" .ds dD June -. if "\\n(mo"7" .ds dD July -. if "\\n(mo"8" .ds dD August -. if "\\n(mo"9" .ds dD September -. if "\\n(mo"10" .ds dD October -. if "\\n(mo"11" .ds dD November -. if "\\n(mo"12" .ds dD December -. as dD \&\ \\n(dy, 19\\n(yr -. \} -.\} -.el \{\ -. ds dD Epoch -.\} -.. -.de hM -.ev 1 -.pL -.if !\\n(cR 'sp \\n(Hmu -.tl @\\*(Hs\\*(hT\fP@\\*(Vs\\*(vT\fP@\\*(Hs\\*(hT\fP@ -'sp \\n(Hmu -.ev -.. -.de fM -.ie \\n(cR 'br -.el \{\ -. ev 1 -. pL -. if !\\n(cR \{\ -' sp \\n(Fmu -. tl @\\*(Hs\\*(oS\fP@\\*(Vs\\*(dD\fP@%@ -' bp -. \} -. ev -.\} -.. -.de lM -.fl -.if \\n(cR \{\ -' sp -. tl @\\*(Hs\\*(oS\fP@\\*(Vs\\*(dD\fP@%@ -. pl \\n(nlu -.\} -.. -.de Pp -.sp \\n(Ppu -.ne 2 -.ns -.. -.de Lp -.Pp -.. -.de LP -.tm Not a \-mdoc command: .LP -.. -.de PP -.tm Not a \-mdoc command: .PP -.. -.de pp -.tm Not a \-mdoc command: .pp -.. -.de Nd -\&\-\& \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.de Ss -.sp -.ne 2 -.ti -.25i -\&\\*(sH\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6 \|\\$7 \|\\$8 \|\\$9 -\&\fP\s0 -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.if !\\n(cR .ne 2 -.br -.. -.de Rd -.tm MDOC REGISTER DUMP -.tm Db==\\n(Db register DEBUG MODE -.tm L[0-9] registers - stack of list types -.tm L0==\\n(L0 -.tm L1==\\n(L1 -.tm L2==\\n(L2 -.tm L3==\\n(L3 -.tm L4==\\n(L4 -.tm L5==\\n(L5 -.tm L6==\\n(L6 -.tm L7==\\n(L7 -.tm L8==\\n(L8 -.tm L9==\\n(L9 -.tm O[0-9] registers - stack of indent -.tm O0==\\n(O0 -.tm O1==\\n(O1 -.tm O2==\\n(O2 -.tm O3==\\n(O3 -.tm O4==\\n(O4 -.tm O5==\\n(O5 -.tm O6==\\n(O6 -.tm O7==\\n(O7 -.tm O8==\\n(O8 -.tm O9==\\n(O9 -.tm aC==\\n(aC register argument counter (aV/fV) -.tm aJ==\\n(aJ register (for vR) -.tm aN==\\n(aN register -.tm aP==\\n(aP register argument pointer (aV) -.tm aT==\\n(aT register argument type -.tm aa==\\n(aa local register -.tm bK==\\n(bK register - Book Name flag -.tm cF==\\n(cF register save current font -.tm cI==\\n(cI register - column indent width -.tm cZ==\\n(cZ register save current font size -.tm dK==\\n(dK register - Date flag -.tm d[0-9] registers - display-type stack -.tm d0==\\n(d0 -.tm d1==\\n(d1 -.tm d2==\\n(d2 -.tm d3==\\n(d3 -.tm d4==\\n(d4 -.tm d5==\\n(d5 -.tm d6==\\n(d6 -.tm d7==\\n(d7 -.tm d8==\\n(d8 -.tm d9==\\n(d9 -.tm dZ==\\n(dZ register diversion count -.tm fD==\\n(fD register subroutine test (in synopsis only) -.tm fV==\\n(fV register argument counter (must set to \\n(.$ prior to -.tm fY==\\n(fY register - dick with old style function declarations (fortran) -.tm fZ==\\n(fZ register also subroutine count (in synopsis only) -.tm h[0-9] register horizontal tag stack (continuous if 1, break if -.tm h0==\\n(h0 -.tm h1==\\n(h1 -.tm h2==\\n(h2 -.tm h3==\\n(h3 -.tm h4==\\n(h4 -.tm h5==\\n(h5 -.tm h6==\\n(h6 -.tm h7==\\n(h7 -.tm h8==\\n(h8 -.tm h9==\\n(h9 -.tm iD==\\n(iD local register -.tm iI==\\n(iI local register (indent for inline debug mode) -.tm iN==\\n(iN register DEBUG MODE (inline if 1, to stderr if -.tm iS==\\n(iS register - indent second command line in a synopsis -.tm jK==\\n(jK register - [reference] Journal Name flag -.tm jM==\\n(jM local register -.tm jN==\\n(jN local register -.tm lC==\\n(lC register - list type stack counter -.tm lK==\\n(lK register count of lines read from input file -.tm nK==\\n(nK register - [reference] issue number flag -.tm nU==\\n(nU register count -.tm oK==\\n(oK register - [reference] optional information flag -.tm oM==\\n(oM register (extension possible) -.tm o[0-9] register offset stack (nested tags) -.tm o0==\\n(o0 -.tm o1==\\n(o1 -.tm o2==\\n(o2 -.tm o3==\\n(o3 -.tm o4==\\n(o4 -.tm o5==\\n(o5 -.tm o6==\\n(o6 -.tm o7==\\n(o7 -.tm o8==\\n(o8 -.tm o9==\\n(o9 -.tm oM==\\n(oM register open ended line flag -.tm pK==\\n(pK register - [reference] page number flag -.tm qK==\\n(qK register - Corporate or Foreign Author flag -.tm rK==\\n(rK register - [reference] report flag -.tm rS==\\n(rS register - Reference Start flag -.tm sM==\\n(sM register - default is one (space mode on) -.tm tK==\\n(tK register - reference title flag -.tm tP==\\n(tP register tag flag (for diversions) -.tm tX==\\n(tX register (initial class) -.tm tY==\\n(tY register (next possible lC value) -.tm t[0-9] register tag string stack (nested tags) -.tm t0==\\n(t0 -.tm t1==\\n(t1 -.tm t2==\\n(t2 -.tm t3==\\n(t3 -.tm t4==\\n(t4 -.tm t5==\\n(t5 -.tm t6==\\n(t6 -.tm t7==\\n(t7 -.tm t8==\\n(t8 -.tm t9==\\n(t9 -.tm uK==\\n(uK register - reference author(s) counter -.tm vK==\\n(vK register - reference volume flag -.tm v[0-9] register vertical tag break stack -.tm v0==\\n(v0 -.tm v1==\\n(v1 -.tm v2==\\n(v2 -.tm v3==\\n(v3 -.tm v4==\\n(v4 -.tm v5==\\n(v5 -.tm v6==\\n(v6 -.tm v7==\\n(v7 -.tm v8==\\n(v8 -.tm v9==\\n(v9 -.tm w[0-9] register tag stack (nested tags) -.tm w0==\\n(w0 -.tm w1==\\n(w1 -.tm w2==\\n(w2 -.tm w3==\\n(w3 -.tm w4==\\n(w4 -.tm w5==\\n(w5 -.tm w6==\\n(w6 -.tm w7==\\n(w7 -.tm w8==\\n(w8 -.tm w9==\\n(w9 -.tm xX==\\n(xX local register -.tm END OF REGISTER DUMP -.. diff --git a/share/tmac/doc-ditroff b/share/tmac/doc-ditroff deleted file mode 100644 index 08b413eed38b..000000000000 --- a/share/tmac/doc-ditroff +++ /dev/null @@ -1,269 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc-ditroff 8.1 (Berkeley) 6/8/93 -.\" -.\" tmac.mdoc-ditroff -.\" %beginstrip% -.\" -.ds aD \fI\s10 -.ds aR \f(CO\s10 -.ds cM \f(CB\s10 -.ds dF \fR\s10 -.ds eM \fI\s10 -.ds eR \fC\s10 -.ds eV \fC\s10 -.ds fA \f(CO\s10 -.ds fD \f(CB\s10 -.ds fL \f(CB\s10 -.ds fN \f(CB\s10 -.ds fP \fP\s0 -.ds fS \s0 -.ds fT \f(CO\s10 -.ds Hs \fR\s10 -.ds iC \f(CB\s10 -.ds lI \fC -.ds lP \fR\|(\|\fP\s10 -.ds lp \fR(\fP\s10 -.ds rP \fR\|)\|\fP\s10 -.ds rp \fR)\fP\s10 -.ds lB \fR\^[\^\fP\s10 -.ds rB \fR\^]\fP\s10 -.ds mL \fB\s10 -.ds nM \f(CB\s10 -.ds nO \fR\s10 -.ds nT \s0 -.ds pA \fC\s10 -.ds Pu \fR{\ .\ ,\ :\ ;\ (\ )\ [\ ]\ \fR} -.ds rA \fR\s10 -.ds rT \f(CO\s10 -.ds sH \fB\s10 -.ds sP \s0 -.ds sY \fB\s10 -.ds sX \fR\s10 -.ds tF \fR -.ds tN \s9 -.ds vA \fI\s10 -.ds Vs \fR\s10 -.ds vT \f(CB\s10 -.ds xR \fC\s10 -.tr *\(** -.nr sI \w\fC,u*5 -.nr Ti \n(sIu -.nr Pp .5v -.ds lS \0 -.nr lS \w'\0'u -.nr dI 6n -.de pL -.nr Hm .5i -.nr Fm .5i -.nr ll 6.5i -.ll 6.5i -.nr lt 6.5i -.lt 6.5i -.nr po 1i -.po 1.i -.nr dV .5v -.. -.ds <= \(<= -.ds >= \(>= -.ds Lq \&`` -.ds Rq \&'' -.ds ua \(ua -.ds aa \(aa -.ds ga \(ga -.ds sR \&' -.ds sL \&` -.ds q \&" -.\" Math stuff -.ds Pi \(*p -.ds Ne \(!= -.ds Le \(<= -.ds Ge \(>= -.ds Lt < -.ds Gt > -.ds Pm \(+- -.ds If \(if -.ds Na \fINaN\fP -.ds Ba \fR\&|\fP -.\" -.nr gX 0 -.de hK -.ds hT \\*(dT -.if !"\\*(cH"Null" \{\ -. ie !"\\*(gP"Null" .as hT \|(\|\\*(cH\\*(gP\|) -. el .as hT \\|(\\|\\*(cH\\|) -.\} -.if "\\*(cH"Null" \{\ -. if !"\\*(gP"Null" .as hT \&\|(\|\\*(gP\|) -.\} -.wh 0 hM -.wh -1.25i fM -.\" .tm Here is gX == \\n(gX -.ie \\n(gX==1 \{\ -. rm n1 -. if \\n(.g .br -. if !\\n(.g .bp -.\} -.el \{\ -. if \\n(.g .br -. if !\\n(.g 'bp -.\} -.nr % 1 -.nr gX 0 -.em lM -.. -.\" -.nr fW \w\fC0 -.de sW -.nr sW \w\fC\\$1 -.ie \\n(sW>=\\n(fW \{\ -. ie \\n(sW%\\n(fW .nr sW (\\n(sW/\\n(fW)+1 -. el .nr sW \\n(sW/\\n(fW -.\} -.el \{\ -. ie \\n(sW>0 .nr sW 1 -. el .nr sW 0 -.\} -.. -.\" -.de aW -.nr sW \w\fC\\*(A\\$1 -.ie \\n(sW>=\\n(fW \{\ -. ie \\n(sW%\\n(fW .nr sW (\\n(sW/\\n(fW)+1 -. el .nr sW \\n(sW/\\n(fW -.\} -.el \{\ -. ie \\n(sW>0 .nr sW 1 -. el .nr sW 0 -.\} -.. -.\" NS Ql macro - Quoted literal define -.de Ql -.if \\n(aC==0 \{\ -. ds mN Ql -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. nr fV \\n(.$ -. fV -.\} -.nr aP \\n(aP+1 -.aW \\n(aP -.nr aP \\n(aP-1 -.if \\n(sW>2 .Li -.if \\n(sW<=2 \{\ -.\" Db on -. if (\\n(aP>0) \{\ -. ds A\\n(aP Li -. nr aP \\n(aP -1 -. \} -. if (\\n(aP==0) \{\ -. rm C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 -. rm S1 S2 S3 S4 S5 S6 S7 S8 S9 -. rn A8 A9 -. rn A7 A8 -. rn A6 A7 -. rn A5 A6 -. rn A4 A5 -. rn A3 A4 -. rn A2 A3 -. rn A1 A2 -. ds A1 Li -. nr fV \\n(aC+1 -. nr aC 0 -. fV -. \} -. ds qL \&\\*(sL -. ds qR \&\\*(sR -. En -.\" Db off -.\} -.. -.\" NS Sh macro - Section Headers -.\" NS nS register - Section Header SYNOPSIS flag -.\" NS nF register - Section Header FILES flag -.\" NS nA register - Section Header SEE ALSO flag -.\" NS nT register - Section Header STANDARDS flag -.de Sh -.nr nS 0 -.nr sE 0 -.nr iS 0 -'ad -.ie "\\$1"NAME" \{\ -. hK -' in 0 -.\} -.el \{\ -. nr nS 0 -. nr nA 0 -. nr nF 0 -. nr nT 0 -. nr nY 0 -. nr oT 0 -. if "\\$1"SYNOPSIS" \{\ -. na -. nr nS 1 -. \} -. if "\\$1"DESCRIPTION" \{\ -. nr fY 0 -. nr fZ 0 -. nr fB 0 -. nr Fb 0 -. ds Fb -. \} -. if "\\$1"SEE" \{\ -. nr nA 1 -. na -. \} -. if "\\$1"FILES" .nr nF 1 -. if "\\$1"STANDARDS" .nr nT 1 -. if "\\$1"AUTHORS" .nr nY 1 -. if "\\$1"SEE" .nr sE 1 -. in 0 -. nr aN 0 -.\} -.pL -'sp -.ns -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.if !\\n(cR .ne 3 -'fi -\&\\*(sH\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6 \|\\$7 \|\\$8 \|\\$9 -\&\fP\s0\& -.in \\n(.iu+\\n(Tiu -.ns -.. diff --git a/share/tmac/doc-nroff b/share/tmac/doc-nroff deleted file mode 100644 index 2bb953137eac..000000000000 --- a/share/tmac/doc-nroff +++ /dev/null @@ -1,225 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc-nroff 8.1 (Berkeley) 6/8/93 -.\" -.\" tmac.mdoc-nroff -.\" %beginstrip% -.\" -.ds aD \fI -.ds aR \fI -.ds cM \fB -.ds dF \fR -.ds eM \fI -.ds eR \fR -.ds eV \fR -.ds fA \fI -.ds fD \fB -.ds fL \fB -.ds fN \fB -.ds fP \fP -.ds fS -.ds fT \fI -.ds Hs \fR -.ds iC \fB -.ds lI \fR -.ds lP \fR\|(\fP -.ds rP \fR\|)\fP -.ds lp \fR\|(\fP -.ds rp \fR\|)\fP -.ds lB \fR\|[\|\fP -.ds rB \fR\|]\fP -.ds mL \fB -.ds nM \fB -.ds nO \fR -.ds pA \fI -.ds Pu {\ .\ ,\ ;\ :\ (\ )\ [\ ]} -.ds rA \fR -.ds rT \fI -.ds sH \fB -.ds sP -.ds sY \fB -.ds sX \fI -.ds tF \fR -.ds tN -.ds vA \fI -.ds Vs \fR -.ds vT \fB -.ds xR \fR -.\" MISCELLANEOUS -.nr sI .5i -.nr Ti .5i -.nr cR 1 -.nr Pp 1v -.ds lS \0\0 -.nr lS \w'\0\0'u -.nr dI 6n -.\" -.de pL -.ie \\n(cR .nr Hm 0 -.el .nr Hm .5i -.nr Fm .5i -.nr ll 78n -.ll 78n -.nr lt 78n -.lt 78n -.nr po 0i -.po 0i -.nr dV 1v -.ad l -.na -.. -.ds <= \&<\&= -.ds >= \&>\&= -.ds Rq '' -.ds Lq `` -.ds ua ^ -.ds aa \' -.ds ga \` -.ds sL ` -.ds sR ' -.ds q \&" -.\" Math stuff -.ds Pi pi -.ds Ne != -.ds Le <= -.ds Ge >= -.ds Lt < -.ds Gt > -.ds Pm +- -.ds If infinity -.ds Na \fINaN\fP -.ds Ba \fR\&|\fP - -.\" -.de hK -.nr % 1 -.ds hT \\*(dT -.if !"\\*(cH"Null" \{\ -. ie !"\\*(gP"Null" .as hT \|(\|\\*(cH\\*(gP\|) -. el .as hT \\|(\\|\\*(cH\\|) -.\} -.if "\\*(cH"Null" .if !"\\*(gP"Null" .as hT \&\|(\|\\*(gP\|) -.ie \\n(cR \{\ -. hM -. wh -1v fM -.\} -.el \{\ -. wh 0 hM -. wh -1.167i fM -.\} -.if \\n(nl==0:\\n(nl==-1 'bp -.em lM -.. -.nr fW \w'0' -.de sW -.nr sW \w\\$1 -.ie \\n(sW>=\\n(fW \{\ -. ie \\n(sW%\\n(fW .nr sW (\\n(sW/\\n(fW)+1 -. el .nr sW \\n(sW/\\n(fW -.\} -.el .nr sW 0 -.. -.de aW -.nr sW \w\\*(A\\$1 -.ie \\n(sW>=\\n(fW \{\ -. ie \\n(sW%\\n(fW .nr sW (\\n(sW/\\n(fW)+1 -. el .nr sW \\n(sW/\\n(fW -.\} -.el .nr sW 0 -.. -.\" NS Ql macro - Quoted literal define -.de Ql -.if \\n(aC==0 \{\ -. ds mN Ql -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -.\} -.ds qL \&\\*(sL -.ds qR \&\\*(sR -.En \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" NS Sh macro - Section Headers -.\" NS nS register - Section Header SYNOPSIS flag -.\" NS nF register - Section Header FILES flag -.\" NS nA register - Section Header SEE ALSO flag -.\" NS nT register - Section Header STANDARDS flag -.de Sh -.nr nS 0 -.nr sE 0 -.nr iS 0 -.ie "\\$1"NAME" \{\ -. hK -' in 0 -.\} -.el \{\ -. nr nS 0 -. nr nA 0 -. nr nF 0 -. nr nT 0 -. nr nY 0 -. nr aN 0 -. nr oT 0 -. if "\\$1"SEE" .nr nA 1 -. if "\\$1"FILES" .nr nF 1 -. if "\\$1"STANDARDS" .nr nT 1 -. if "\\$1"SYNOPSIS" .nr nS 1 -. if "\\$1"DESCRIPTION" \{\ -. rr fB -. rr Fb -. ds Fb -. nr fY 0 -. nr fZ 0 -. \} -. if "\\$1"AUTHORS" .nr nY 1 -. in 0 -.\} -.pL -'sp -.ns -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.if !\\n(cR .ne 3 -'fi -\&\\*(sH\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6 \|\\$7 \|\\$8 \|\\$9 -\&\fP\s0\& -.in \\n(.iu+\\n(Tiu -.if "\\$1"SEE" .nr sE 1 -.ns -.. diff --git a/share/tmac/doc-syms b/share/tmac/doc-syms deleted file mode 100644 index edc886f828aa..000000000000 --- a/share/tmac/doc-syms +++ /dev/null @@ -1,238 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc-syms 8.1 (Berkeley) 6/8/93 -.\" -.\" %beginstrip% -.\" NS Ux macro - UNIX -.de Ux -.nr cF \\n(.f -.nr cZ \\n(.s -.ds aa \&\f\\n(cF\s\\n(cZ -.as b1 \&\\*(tNUNIX\\*(aa -.rm aa -.if \\n(aC==0 \{\ -. if \\n(.$>0 .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==1 \{\ -. \\*(A\\n(aP -. \} -. el .nR -.\} -.el .aZ -.. -.\" NS Bx macro -BSD (fix smaller nroff version) -.de Bx -.nr cF \\n(.f -.nr cZ \\n(.s -.ds aa \&\f\\n(cF\s\\n(cZ -.if \\n(aC==0 \{\ -.\" . ie \\n(.$==0 \&\\*(tNBSD\\*(aa \\*(tNUNIX\\*(aa -. ie \\n(.$==0 \&\\*(tNBSD\\*(aa -. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.if "\\$1"-alpha" \{\ -\¤tly in alpha test. -. aY -.\} -.if "\\$1"-beta" \{\ -\¤tly in beta test. -. aY -.\} -.if "\\$1"-devel" \{\ -\¤tly under development. -. aY -.\} -.if \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. ie \\n(C\\n(aP==2 \{\ -. as b1 \&\\*(A\\n(aP\&\\*(tNBSD\\*(aa -. ie \\n(aC>\\n(aP \{\ -. nr jj \\n(aP+1 -. ie \\n(C\\n(jj==2 \{\ -. if "\\*(A\\n(jj"Reno" \{\ -. nr aP \\n(aP+1 -. as b1 \&\-\\*(A\\n(jj -. \} -. if "\\*(A\\n(jj"reno" \{\ -. nr aP \\n(aP+1 -. as b1 \&\-Reno -. \} -. if "\\*(A\\n(jj"Tahoe" \{\ -. nr aP \\n(aP+1 -. as b1 \&\-\\*(A\\n(jj -. \} -. if "\\*(A\\n(jj"tahoe" \{\ -. nr aP \\n(aP+1 -. as b1 \&\-Tahoe -. \} -. ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nR -. \} -. el .aZ -. \} -. el \{\ -. nr aP \\n(aP+1 -. nR -. \} -. rr jj -. \} -. el .aZ -. \} -. el \{\ -. as b1 \&\\*(tNBSD\\*(aa -. nR -. \} -.\} -.. -.\" Ns Ud macro - prints "currently under development" (HISTORY section) -.de Ud -\¤tly under development. -.. -.\" Ns At macro - AT&T UNIX (this macro does not handle punctuation) -.de At -.nr cF \\n(.f -.nr cZ \\n(.s -.ds aa \&\f\\n(cF\s\\n(cZ -.if \\n(.$==2 \{\ -. if "\\$1"32v" \&Version 32V \\*(tNAT&T UNIX\\*(aa\\$2 -. if "\\$1"v6" \&Version 6 \\*(tNAT&T UNIX\\*(aa\\$2 -. if "\\$1"v7" \&Version 7 \\*(tNAT&T UNIX\\*(aa\\$2 -. if "\\$1"V" \&\\*(tNAT&T\\*(aa System V \\*(tNUNIX\\*(aa\\$2 -. if "\\$1"V.1" \&\\*(tNAT&T\\*(aa System V.1 \\*(tNUNIX\\*(aa\\$2 -. if "\\$1"V.4" \&\\*(tNAT&T\\*(aa System V.4 \\*(tNUNIX\\*(aa\\$2 -.\} -.if \\n(.$==1 \{\ -. if "\\$1"32v" \&Version 32V \\*(tNAT&T UNIX\\*(aa -. if "\\$1"v6" \&Version 6 \\*(tNAT&T UNIX\\*(aa -. if "\\$1"v7" \&Version 7 \\*(tNAT&T UNIX\\*(aa -. if "\\$1"V" \&\\*(tNAT&T\\*(aa System V \\*(tNUNIX\\*(aa -. if "\\$1"V.1" \&\\*(tNAT&T\\*(aa System V.1 \\*(tNUNIX\\*(aa -. if "\\$1"V.4" \&\\*(tNAT&T\\*(aa System V.4 \\*(tNUNIX\\*(aa -.\} -.if \\n(.$==0 \{\ -\&\\*(tNAT&T UNIX\\*(aa -.\} -.. -.\" The Bt macro should go away now -.\" Ns Bt macro - prints "is currently in beta test." (HISTORY section) -.de Bt -\&is currently in beta test. -.. -.\" NS St macro - standards (posix, ansi - formal standard names) -.ds Px \\*(tNPOSIX -.ds Ai \\*(tNANSI -.de St -.if \\n(aC==0 \{\ -. ie \\n(.$==0 \{\ -.tm Usage: .St [-p1003.1-88 | -p1003.2 | -ansiC-89 | -iso ] \\*(Pu ... (#\\n(.c) -. \} -. el \{\ -. ds mN St -. nr aP 0 -. ds A1 \\$1 -. ds A2 \\$2 -. ds A3 \\$3 -. ds A4 \\$4 -. ds A5 \\$5 -. ds A6 \\$6 -. ds A7 \\$7 -. ds A8 \\$8 -. ds A9 \\$9 -. nr fV \\n(.$ -. fV -. \} -.\} -.if \\n(aC>\\n(aP \{\ -. nr cF \\n(.f -. nr cZ \\n(.s -. ds aa \&\f\\n(cF\s\\n(cZ -. nr aP \\n(aP+1 -. if "\\*(A\\n(aP"-p1003.1-88" \{\ -. ie \\n(sT==1 \{\ -. ds b1 \&\\*(tNIEEE Std\\*(aa1003.1-1988\\*(sV -. as b1 (``\\*(tN\\*(Px\\*(aa'') -. \} -. el \{\ -. ds b1 \&\\*(tNIEEE Std\\*(aa1003.1-1988\\*(sV -. as b1 (``\\*(tN\\*(Px\\*(aa'') -. \} -. \} -. if "\\*(A\\n(aP"-p1003.2" \{\ -. ie \\n(sT==1 \{\ -. ds b1 \&\\*(tNIEEE Std\\*(aa1003.2 -. as b1 (``\\*(tN\\*(Px\\*(aa'') -. \} -. el \{\ -. ds b1 \&\\*(tNIEEE Std\\*(aa1003.2\\*(sV -. as b1 (``\\*(tN\\*(Px\\*(aa'') -. \} -. \} -. if "\\*(A\\n(aP"-ansiC" \{\ -. ie \\n(sT==1 \{\ -. ds b1 \&\\*(tNANSI C \\*(aaX3.159-1989\\*(sV -. as b1 (``\\*(tNANSI C\\*(aa'') -. \} -. el \{\ -. ds b1 \&\\*(tNANSI C \\*(aaX3.159-1989\\*(sV -. as b1 (``\\*(tNANSI C \\*(aa'') -. \} -. \} -. if "\\*(A\\n(aP"-ansiC-89" \{\ -. ie \\n(sT==1 \{\ -. ds b1 \&\\*(tNANSI C \\*(aaX3.159-1989\\*(sV -. as b1 (``\\*(tNANSI C \\*(aa'') -. \} -. el \{\ -. ds b1 \&\\*(tNANSI C \\*(aaX3.159-1989\\*(sV -. as b1 (``\\*(tNANSI C \\*(aa'') -. \} -. \} -. if "\\*(A\\n(aP"-iso8802-3" \{\ -. ie \\n(sT==1 \{\ -. ds b1 \&\\*(tNISO \\*(aa8802-3: 1989\\*(sV -.\" . as b1 (``\\*(tNANSI C\\*(aa'') -. \} -. el \{\ -. ds b1 \&\\*(tNISO \\*(aa8802-3: 1989\\*(sV -.\" . as b1 (``\\*(tNANSI C\\*(aa'') -. \} -. \} -. ie \\n(aC>\\n(aP \{\ -. nr aP \\n(aP+1 -. nR -. \} -. el .aZ -.\} -.. diff --git a/share/tmac/strip.sed b/share/tmac/strip.sed deleted file mode 100644 index 4a03826442ec..000000000000 --- a/share/tmac/strip.sed +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sed -f -# -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)strip.sed 8.1 (Berkeley) 6/8/93 -# - -/%beginstrip%/{ - h - s/.*/.\\" This version has had comments stripped; an unstripped version is available./p - g -} -/%beginstrip%/,$s/[. ][ ]*\\".*// -/^$/d -/\\n@/d diff --git a/share/tmac/tmac.andoc b/share/tmac/tmac.andoc deleted file mode 100644 index 8ceec48fc7ac..000000000000 --- a/share/tmac/tmac.andoc +++ /dev/null @@ -1,54 +0,0 @@ -.\" -.\" Copyright (c) 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tmac.andoc 8.1 (Berkeley) 6/30/93 -.\" -.\" If -mdoc macros, source tmac.mdoc -.\" If -man macros, check to see if groff or troff/nroff is being used -.\" -.de Dd -.rn Dd xX -.so /usr/share/tmac/tmac.doc -.Dd \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -.rm xX -.. -.de TH -.rn TH xX -.ie \n(.g \{\ -. so /usr/share/tmac/tmac.groff_an -.\} -.el \{\ -. so /usr/old/lib/tmac/tmac.an -.\} -.TH "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" -.rm xX -.. diff --git a/share/tmac/tmac.doc.old b/share/tmac/tmac.doc.old deleted file mode 100644 index e998fcf9f949..000000000000 --- a/share/tmac/tmac.doc.old +++ /dev/null @@ -1,1833 +0,0 @@ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tmac.doc.old 8.1 (Berkeley) 6/8/93 -.\" -.\" Assume nroff on crt's only if cR==1 -.if n .nr cR 1 -.\" STRING CONSTANTS -.\" DITROFF -.if t \{\ -.\" Address Style -.ds aD \fI -.\" Argument Reference Style -.ds aR \f(CO -.\" Interactive Comand Modifier (flag) -.ds cM \f(CB -.\" Emphasis (in the English sense - usually italics) -.ds eM \fI -.\" Errno Style -.ds eR \fC -.\" Environment Variable Style -.ds eV \fC -.\" Command Line Flag Style -.ds fL \f(CB -.\" Header String Style -.ds Hs \fR -.\" Interactive Command Style -.ds iC \f(CB -.\" Literal Style -.ds lI \fC -.\" Left Parenthesis Style -.ds lP \fR\|(\|\fP -.\" Right Parenthesis Style -.ds rP \fR\|)\|\fP -.\" Options Open Bracket Style -.ds lB \fR\^[\^\fP -.\" Options Open Bracket Style -.ds rB \fR\^]\fP -.\" Name (subject of manpage) Style -.ds nM \f(CB -.\" Pathname Style -.ds pA \fC -.\" Accepted punctuation string for -mdoc syntax -.ds Pu \fR[.,:;(\^)[\^]\fR] -.\" Section Header Style -.ds Sp \s12\fB -.\" .ds sT \s-2\fR -.\" Symbolic Emphasis (boldface) -.ds sY \f(CB -.\" Generic Variable Style -.ds vA \fI -.\" Volume Title Style -.ds Vs \fR -.\" Cross Reference STyle (man page only) -.ds xR \fC -.\" Math * -.tr *\(** -.\} -.\" NROFF -.if n \{\ -.\" Address Style -.ds aD \fI -.\" Argument Reference Style -.ds aR \fI -.\" Interactive Command Modifier (flag) -.ds cM \fB -.\" Emphasis (in the English sense - usually italics) -.ds eM \fI -.\" Errno Style -.ds eR \fR -.\" Environment Variable Style -.ds eV \fR -.\" Command Line Flag Style -.ds fL \fB -.\" Header String Style -.ds Hs \fR -.\" Interactive Command Style -.ds iC \fB -.\" Literal Style -.ds lI \fR -.\" Left Parenthesis Style -.ds lP \fR\|(\fP -.\" Right Parenthesis Style -.ds rP \fR\|)\fP -.\" Options Open Bracket Style -.ds lB \fR\|[\|\fP -.\" Options Open Bracket Style -.ds rB \fR\|]\fP -.\" Name (subject of manpage) Style -.ds nM \fB -.\" Pathname Style -.ds pA \fI -.\" Accepted punctuation string for -mdoc syntax -.ds Pu [.,;:()[]] -.\" Section Header Style -.ds Sp \s12\fB -.\" .ds sT \s-2\fR -.\" .ds sT \s-2\fR -.\" Symbol, Mode or Mask Style -.ds sY \fB -.\" Generic Variable Style -.ds vA \fI -.\" Volume Title Style -.ds Vs \fR -.\" Cross Reference Style (man page only) -.ds xR \fR -.\} -.\" INDENTS - Subheaders(sI), Text(Ti) between Section Headers and Subsects -.if t \{\ -. nr sI \w'\fC,'u*5 -. nr Ti \n(sIu -.\} -.if n \{\ -. nr sI .5i -. nr Ti .5i -.\} -.\" Flags for macros names which are used only for .Ds -.nr dI 6n -.nr dC 1 -.nr dL 1 -.nr dR 1 -.\" INDENT WIDTHS (for Lists) -.\" Width Needed for Address Tag (indented amount) -.nr Ad 12n -.\" Angle Quote Width -.nr Aq 12n -.\" Width Needed for Argument -.nr Ar 12n -.\" Width Needed for Column offset -.nr Cl 15n -.\" Width neeeded for Interactive Command Modifier -.nr Cm 10n -.\" Width Needed for Complex Expressions -.nr Cx 20n -.\" Indent Width Needed for Display (right and left margins) -.nr Ds 6n -.\" Double Quote Width -.nr Dq 12n -.\" tI is dependent on Ds and used by .Dp -.nr tI \n(Dsu -.\" Width Needed for Display -.nr Em 10n -.\" Width Needed for Errno Types -.nr Er 15n -.\" Width Needed for Environment Variables -.nr Ev 15n -.\" Width Needed for Example Indent -.nr Ex 10n -.\" Width Needed for Flag -.nr Fl 10n -.\" Width Needed for Function -.nr Fn 16n -.\" Width neeeded for Interactive Command Name -.nr Ic 10n -.\" Width Needed for Constant -.nr Li 16n -.\" Width Needed for Math Symbol ? not sure if needed -.nr Ms 6n -.\" Width Needed for Name -.nr Nm 10n -.\" Width Needed for Option Begin -.nr Ob 14n -.\" Width Needed for Option End -.nr Oe 14n -.\" Width Needed for Option (one line) -.nr Op 14n -.\" Width Needed for Pathname -.nr Pa 32n -.\" Parenthesis Quote Width -.nr Pq 12n -.\" Single Quote Width -.nr Sq 12n -.\" Width Needed for Symbols, Modes or Masks -.nr Sy 6n -.\" Width needed for default or unknown text width -.nr Tx 22n -.\" Width Needed for Generic Variable -.nr Va 12n -.\" Width Needed for Cross Reference, should the cross ref be annotated. -.nr Xr 10n -.\" PARAGRAPH SPACE -.if t \{\ -. nr Pp .5v -.\} -.if n \{\ -. nr Pp 1v -.\} -.\" PAGE LAYOUT -.\" .Li Tagged Paragraph Style - zero if break on oversized tag -.\" one if add em space and continue filling line. -.nr tP 0 -.\" Page Layout Macro -.de pL -.\" DITROFF -.ie t \{\ -.\" Header Margin -. nr Hm .5i -.\" Footer Margin -. nr Fm .5i -.\" Line length -. nr ll 5.5i -.\" Line length -. ll 5.5i -.\" Title length -. nr lt 5.5i -.\" Title length -. lt 5.5i -.\" Page offset -. nr po 1.56i -.\" Page offset -. po 1.56i -.\" Vertical space distance (from Section headers/Lists/Subsections) -. nr vV .5v -.\" em space -. ds tP \|\|\|\|\|\| -.\} -.el \{\ -.\" Line length -. nr ll 78n -. ll 78n -.\" Title length -. nr lt 78n -.\" Title length -. lt 78n -.\" Page offset -. nr po 0i -.\" Page offset -. po 0i -.\" Vertical space distance (from Section headers/Lists/Subsections) -. nr vV 1v -.\" em space -. ds tP \0\0 -.\" Test for crt -. ie \\n(cR .nr Hm 0 -. el .nr Hm .5i -.\" Footer Margin -. nr Fm .5i -.\} -.. -.\" Adjustment mode -.if n \{\ -.ad l -.na -.. -.\} -.\" PREDEFINED STRINGS -.if t \{\ -. ds <= \(<= -. ds >= \(>= -. ds Lq \&`` -. ds Rq \&'' -. ds ua \(ua -. ds aa \(aa -. ds ga \(ga -. ds sR \(aa -. ds sL \(ga -.\} -.if n \{\ -. ds <= \&<\&= -. ds >= \&>\&= -. ds Rq '' -. ds Lq `` -. ds ua ^ -. ds aa ' -. ds ga ` -. ds sL ` -. ds sR ' -.\} -.\" Note: The distances from the bottom or top of the page are set -.\" in headers (macro .hK): to -1.25 for troff, and -1.167 for nroff -.\" bottoms, and top is 0. -.\" -.\" .Dt Document/manpage_title section/chapter volume -.\" The \{ and \} is necessary as roff doesn't nest if-elses -.\" properly, especially with .ds. -.\" TODO: separate Dt into Dt, Ch and Vt for supp docs. -.de Dt -.ds dT UNTITLED -.ds vT Local -.ds cH Null -.\" Volume and Section Number or Chapter Number -.if !"\\$1"" .ds dT \\$1 -.if !"\\$2"" \{\ -. ds cH \\$2 -. if "\\$3"" \{\ -. \" Volume Title if none given -. if \\$2>=1 .if \\$2<=8 \{\ -. ds vT UNIX Reference Manual -. if \\$2>1 .if \\$2<6 .ds vT UNIX Programmer's Manual -. if "\\$2"8" .ds vT UNIX System Manager's Manual -. \} -. if "\\$2"unass" .ds vT DRAFT -. if "\\$2"draft" .ds vT DRAFT -. if "\\$2"paper" .ds vT Null -. \} -.\} -.if !"\\$3"" \{\ -. \" Volume Title if given -. if "\\$3"USD" .ds vT UNIX User's Supplementary Documents -. if "\\$3"PS1" .ds vT UNIX Programmers's Supplementary Documents -. if "\\$3"AMD" .ds vT UNIX Ancestral Manual Documents -. if "\\$3"SMM" .ds vT UNIX System Manager's Manual -. if "\\$3"URM" .ds vT UNIX Reference Manual -. if "\\$3"PRM" .ds vT UNIX Programmers's Manual -. if "\\$3"IND" .ds vT UNIX Manual Master Index -. if "\\$3"CON" .ds vT UNIX Contributed Software Manual -. if "\\$3"IMP" .ds vT UNIX Implementation Notes -. if "\\$3"HOW" .ds vT UNIX How Pocket Manual -. if "\\$3"LOCAL" .ds vT UNIX Local Manual -. if "\\*(vT"Local" .ds vT \\$3 -.\} -.. -.\" -.\" .Os Operating System/Standard and Release or Version Number -.\" -.de Os -.ds oS Null -.if "\\$1"" \{\ -. ds oS \fIBSD Experimental\fP -.\" . ds oS (\fIBag o' Bits\fP) -.\} -.if "\\$2"" \{\ -. ds o1 Non-Null -.\} -.if "\\$1"ATT" \{\ -. ds oS AT&T -. if "\\$2"" .as oS \0UNIX -. if "\\$2"7th" .as oS \07th Edition -. if "\\$2"7" .as oS \07th Edition -. if "\\$2"III" .as oS \0System III -. if "\\$2"3" .as oS \0System III -. if "\\$2"V" .as oS \0System V -. if "\\$2"V.2" .as oS \0System V Release 2 -. if "\\$2"V.3" .as oS \0System V Release 3 -. if "\\$2"V.4" .as oS \0System V Release 4 -.\} -.if "\\$1"BSD" \{\ -. if "\\$2"3" .ds oS 3rd Berkeley Distribution -. if "\\$2"4" .ds oS 4th Berkeley Distribution -. if "\\$2"4.1" .ds oS 4.1 Berkeley Distribution -. if "\\$2"4.2" .ds oS 4.2 Berkeley Distribution -. if "\\$2"4.3" .ds oS 4.3 Berkeley Distribution -. if "\\$2"4.3+" .ds oS 4.3+tahoe Berkeley Distribution -.\} -.if "\\*(oS"Null" .ds oS \\$1 -.if "\\*(o1"Non-Null" .as oS \0\\$2 -.rm o1 -.. -.\" -.\" Standards -.\" -.\" .de St -.\" .ds sT Null -.\" .if "\\$1"POSIX" \{\ -.\" . ds sT IEEE Standard POSIX -.\" . if \\$2 .as sT \0\\$2 -.\" .\} -.\" .if "\\$1"ANSI" \{\ -.\" . ds sT ANSI Standard -.\" . if \\$2 .as sT \0\\$2 -.\" .\} -.\" .if "\\$1"ISO" \{\ -.\" . ds sT ISO Standard -.\" . if \\$2 .as sT \0\\$2 -.\" .\} -.\" .if "\\*(sT"Null" .ds sR \\$3 -.\" .. -.\" -.\" .de Gp -.\" .ie !"\\$1"" .ds gP \&\\$1 \\$2 \\$3 \\$4 \\$5 -.\" .el .ds gP Null -.\" .. -.\" -.\" -.de Dd -.nr aa 0 -.ie \\n(.$>0 \{\ -. ie \\n(.$<4 \{\ -. ds dD \\$1 \\$2 \\$3 -. \} -. el .tm Usage: .Dd Month Day, Year (e.g July 4, 1977). -.\} -.el \{\ -. ds dD Epoch -.\} -.. -.\" -.\" House Keeping Macro - Make sense of dT, cH, vT, sT, gP and dS -.\" TODO: Try to get else's for efficiency -.\" TODO: GET RID OF .wh -1.167i (its in v7) -.\" -.\" -.de hK -.nr % 1 -.ds hT \\*(dT -.if !"\\*(cH"Null" \{\ -. ie !"\\*(gP"Null" .as hT \|(\|\\*(cH\\*(gP\|) -. el .as hT \\|(\\|\\*(cH\\|) -.\} -.if "\\*(cH"Null" .if !"\\*(gP"Null" .as hT \&\|(\|\\*(gP\|) -.if t \{\ -. wh 0 hM -. wh -1.25i fM -.\} -.if n \{\ -. ie \\n(cR \{\ -. hM -. wh -0v fM -. \} -. el \{\ -. wh 0 hM -. wh -1.167i fM -. \} -.\} -.if n \{\ -. if \\n(nl==0:\\n(nl==-1 'bp -.\} -.if t 'bp -.em lM -.. -.\" Header Macro -.\" -.de hM -.ev 1 -.pL -.if !\\n(cR 'sp \\n(Hmu -.tl @\\*(Hs\\*(hT\fP@\\*(Vs\\*(vT\fP@\\*(Hs\\*(hT\fP@ -'sp \\n(Hmu -.ev -.. -.\" -.de fM -.ev 1 -.pL -.if !\\n(cR \{\ -' sp \\n(Fmu -. tl @\\*(Hs\\*(oS\fP@\\*(Vs\\*(dD\fP@%@ -' bp -.\} -.if \\n(cR \{\ -.\" . tl @\\*(Hs\\*(oS\fP@\\*(Vs\\*(dD\fP@%@ -.\" ' bp -.\} -.ev -.. -.de lM -.fl -.if \\n(cR \{\ -. fM -. pl \\n(nlu -.\} -.. -.de Pp -.sp \\n(Ppu -.ne 2 -.ns -.. -.de Lp -.Pp -.. -.de LP -.tm Not a \-mdoc command: .LP -.. -.de PP -.tm Not a \-mdoc command: .PP -.. -.de pp -.tm Not a \-mdoc command: .pp -.. -.de Co -.tm Not a \-mdoc command: .Co -.. -.nr z. 1 -.nr z, 1 -.nr z: 1 -.nr z; 1 -.nr z) 1 -.nr z( 1 -.nr z[ 1 -.nr z] 1 -.\" This is disgusting, troff not parse if stmt properly -.nr z1 0 -.nr z2 0 -.nr z3 0 -.nr z4 0 -.nr z5 0 -.nr z6 0 -.nr z7 0 -.nr z8 0 -.nr z9 0 -.nr z0 0 -.nr z# 0 -.\" -.de Ad -.ie \\n(.$==0 \{\ -. tm Usage: .Ad address [...] \\*(Pu -.\} -.el \{\ -. ds sV \\*(aD -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.\" Command Line Argument Macro -.\" -.de Ar -.ie \\n(.$==0 \{\ -. ie !"\\*(iM"" .as f1 \&[\|\\*(aRfile\ ...\fP\|] -. el \&[\|\\*(aRfile\ ...\fP\|] -.\} -.el \{\ -. ds sV \\*(aR -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Em -.ie \\n(.$==0 \{\ -. tm Usage: .Em text ... \\*(Pu -.\} -.el \{\ -. ds sV \\*(eM -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Er -.ie \\n(.$==0 \{\ -. tm Usage: .Er ERRNOTYPE ... \\*(Pu -. \} -.el \{\ -. ds sV \\*(eR -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Ev -.ie \\n(.$==0 \{\ -. tm Usage: .Ev ENVIRONMENT_VARIABLE(s) ... \\*(Pu -. \} -.el \{\ -. ds sV \\*(eV -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.\" Flag Name Macro -.\" -.de Fl -.ie \\n(.$==0 \{\ -. ie !"\\*(iM"" .as f1 \&\\*(fL\-\fP -. el \&\\*(fL\-\fP -.\} -.el \{\ -. nr rZ 0 -. sW \\$1 -. if (\\n(sW==1&\\n(.$==1) .rZ \\$1 -. ds sV \\*(fL -. nr cF \\n(.f -. ie \\n(rZ \{\ -. ie "\\*(iM"" .ds f1 \&\\*(sV\-\f\\n(cF\\$1 -. el \&\\*(sV\-\f\\n(cF\\$1 -. \} -. el \{\ -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. fB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -. \} -.\} -.. -.\" Interactive Commands Macro -.\" -.de Ic -.ie \\n(.$==0 \{\ -. tm Usage: .Ic Interactive Commands(s) ... \\*(Pu -.\} -.el \{\ -. ds sV \\*(iC -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.\" Interactive Command Modifiers (flags) -.\" -.de Cm -.ie \\n(.$==0 \{\ -. tm Usage: .Cm Interactive Command Modifier(s) ... \\*(Pu -.\} -.el \{\ -. ds sV \\*(cM -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Li -.ie \\n(.$==0 \{\ -. tm Usage: .Li literal ... \\*(Pu -. \} -.el \{\ -. ds sV \\*(lI -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" If in nroff or any other case where the default font -.\" is constant width, and literal means zilch, single quote instead. -.ie n \{\ -.de Ql -. ie \\n(.$==0 \{\ -. tm Usage: .Ql literal ... \\*(Pu -. \} -. el \{\ -. Sq \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.. -.\} -.el \{\ -.de Ql -. ie \\n(.$==0 \{\ -. tm Usage: .Ql literal ... \\*(Pu -. \} -. el \{\ -. Li \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.. -.\} -.\" -.de Nm -.ie \\n(.$==0 \{\ -. if "\\*(n1"" .tm Usage: .Nm Name(s) ... \\*(Pu -. ie !"\\*(iM"" .as f1 \&\\*(nM\\*(n1\\$1\fP -. el \&\\*(nM\\*(n1\\$1\fP -.\} -.el \{\ -. ds sV \\*(nM -. nr cF \\n(.f -. if \\n(nS \{\ -. rs -. in -\\n(iSu -. ie \\n(nS>1 .br -. el \{\ -. sW \\$1 -. nr iS ((\\n(sW+1)*\\n(fW)u -. \} -. in +\\n(iSu -. ti -\\n(iSu -. nr nS \\n(nS+1 -. \} -. if "\\*(n1"" .ds n1 \\$1 -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Pa -.ie \\n(.$==0 \{\ -\&\\*(pA~\fP -.\} -.el \{\ -. ds sV \\*(pA -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Sy -.ie \\n(.$==0 \{\ -. tm Usage: .Sy Symbolic Text ... \\*(Pu -. \} -.el \{\ -. ds sV \\*(sY -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Ms -.ie \\n(.$==0 \{\ -. tm Usage: .Ms Math Symbol ... \\*(Pu -. \} -.el \{\ -. ds sV \\*(sY -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de Va -.ie \\n(.$==0 \{\ -. tm Usage: .Va variable_name(s) ... \\*(Pu -.\} -.el \{\ -. ds sV \\*(vA -. nr cF \\n(.f -. ie "\\*(iM"" .ds f1 \&\\*(sV -. el .as f1 \&\\*(sV -. nB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -.\} -.. -.\" -.de nB -.hy 0 -.if \\n(.$==0 .tm Usage error: called with empty arguments (empty quotes)? -.ie \\n(.$>1 \{\ -. rZ \\$1 -. ie \\n(rZ .as f1 \&\f\\n(cF\\$1\fP -. el .as f1 \&\\$1 -. rZ \\$2 -. if !\\n(rZ \{\ -. ie !"\\*(iM""\{\ -.\" I surrender -. if "\\*(iM"Tp" .as f1 \&\ \& -. if "\\*(iM"Dp" .as f1 \&\ \& -. if "\\*(iM"Op" .as f1 \&\ \& -. if "\\*(iM"Cx" .as f1 \&\ \& -. if "\\*(iM"Dq" .as f1 \& \& -. if "\\*(iM"Sq" .as f1 \& \& -. if "\\*(iM"Pq" .as f1 \& \& -. if "\\*(iM"Aq" .as f1 \& \& -. \} -. el .as f1 \& \& -. \} -. nB \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.el \{\ -. rZ \\$1 -. ie \\n(rZ .as f1 \&\f\\n(cF\\$1 -. el .as f1 \&\\$1\f\\n(cF -. if "\\*(iM"" \{\&\\*(f1 -. ds f1 -. \} -. hy -.\} -.. -.de fB -.hy 0 -.if \\n(.$==0 .tm Usage error: called with empty arguments (empty quotes)? -.ie \\n(.$>1 \{\ -. rZ \\$1 -. ie \\n(rZ .as f1 \&\f\\n(cF\\$1\fP -. el \{\ -. ie "\\$1"-" .as f1 \&\-\- -. el .as f1 \&\-\\$1 -. \} -. rZ \\$2 -. if !\\n(rZ \{\ -. ie !"\\*(iM""\{\ -.\" I surrender -. if "\\*(iM"Tp" .as f1 \&\ \& -. if "\\*(iM"Dp" .as f1 \&\ \& -. if "\\*(iM"Op" .as f1 \&\ \& -. if "\\*(iM"Cx" .as f1 \&\ \& -. if "\\*(iM"Dq" .as f1 \& \& -. if "\\*(iM"Sq" .as f1 \& \& -. if "\\*(iM"Pq" .as f1 \& \& -. if "\\*(iM"Aq" .as f1 \& \& -. \} -. el .as f1 \& \& -. \} -. fB \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.el \{\ -. rZ \\$1 -. ie \\n(rZ .as f1 \&\f\\n(cF\\$1 -. el \{\ -. ie "\\$1"-" .as f1 \&\-\-\f\\n(cF -. el .as f1 \&\-\\$1\f\\n(cF -. \} -. if "\\*(iM"" \{\&\\*(f1 -. ds f1 -. \} -. hy -.\} -.. -.\" -.\" Single quoted Items -.\" eF, sB g[0-9] and f2 -.de Sq -.nr eF 0 -.ie \\n(.$==0 \{\ -. ie "\\*(iM"" \&\\*(sL\&\\*sR -. el .as f1 \&\\*(sL\&\\*(sR -.\} -.el \{\ -. ie "\\*(iM"" \{\ -. ds f1 \&\\*(sL -. ds iM Sq -. \} -. el .as f1 \&\\*(sL -. sB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ie \\n(eF>0 .\\*(g1 \\*(g2 \\*(g3 \\*(g4 \\*(g5 \\*(g6 \\*(g7 \\*(g8 -. el .as f1 \\*(g0 -. as f1 \\*(sR -. if !"\\*(f2"" .as f1 \\*(f2 -. if "\\*(iM"Sq" \{\ -\&\\*(f1 -. ds f1 -. ds iM -. \} -. ds f2 -. rm g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 -. nr eF 0 -.\} -.. -.\" -.\" Double quoted Items -.de Dq -.nr Ef 0 -.ie \\n(.$==0 \{\ -. ie "\\*(iM"" \&\\*(Lq\&\\*(Rq -. el .as f1 \&\\*(Lq\&\\*(Rq -.\} -.el \{\ -. ie "\\*(iM"" \{\ -. ds f1 \&\\*(Lq -. ds iM Dq -. \} -. el .as f1 \&\\*(Lq -. Sb \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ie \\n(Ef>0 .\\*(k1 \\*(k2 \\*(k3 \\*(k4 \\*(k5 \\*(k6 \\*(k7 \\*(k8 -. el .as f1 \\*(k0 -. as f1 \\*(Rq -. if !"\\*(f4"" .as f1 \\*(f4 -. if "\\*(iM"Dq" \{\ -\&\\*(f1 -. ds f1 -. ds iM -. \} -. ds f4 -. rm k0 k1 k2 k3 k4 k5 k6 k7 k8 k9 -. nr Ef 0 -.\} -.. -.\" -.\" Parenthesis quoted Items -.de Pq -.nr pQ 0 -.ie \\n(.$==0 \{\ -. ie "\\*(iM"" \&(\&) -. el .as f1 \&(\&) -.\} -.el \{\ -. ie "\\*(iM"" \{\ -. ds f1 \&( -. ds iM Pq -. \} -. el .as f1 \&( -. pB \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ie \\n(pQ>0 .\\*(y1 \\*(y2 \\*(y3 \\*(y4 \\*(y5 \\*(y6 \\*(y7 \\*(y8 -. el .as f1 \\*(y0 -. as f1 \&) -. if !"\\*(f3"" .as f1 \\*(f3 -. if "\\*(iM"Pq" \{\ -\&\\*(f1 -. ds f1 -. ds iM -. \} -. ds f3 -. rm y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 -. nr pQ 0 -.\} -.. -.\" eF, sB g[0-9] and f2 -.de sB -.hy 0 -.ie \\n(.$==0 .tm Sick Logic: macro sB -.el \{\ -. ie \\n(eF>=1 .nr eF \\n(eF+1 -. el \{\ -. mN \\$1 -. if \\n(mN .nr eF \\n(eF+1 -. \} -. rZ \\$1 -. ie \\n(rZ .as f2 \\$1 -. el \{\ -. ie \\n(eF<1 .as g\\n(eF \\$1 -. el .as g\\n(eF \\$1 -. \} -. if \\n(.$>1 \{\ -. rZ \\$2 -. if \\n(rZ==0 \{\ -. if \\n(eF<1 \{\ -. as g\\n(eF \& \& -. \} -. \} -. sB \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.de Sb -.hy 0 -.ie \\n(.$==0 .tm Sick Logic: macro Sb -.el \{\ -. ie \\n(Ef>=1 .nr Ef \\n(Ef+1 -. el \{\ -. mN \\$1 -. if \\n(mN .nr Ef \\n(Ef+1 -. \} -. rZ \\$1 -. ie \\n(rZ .as f4 \\$1 -. el \{\ -. ie \\n(Ef<1 .as k\\n(Ef \\$1 -. el .as k\\n(Ef \\$1 -. \} -. if \\n(.$>1 \{\ -. rZ \\$2 -. if \\n(rZ==0 \{\ -. if \\n(Ef<1 \{\ -. as k\\n(Ef \& \& -. \} -. \} -. Sb \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.de pB -.hy 0 -.ie \\n(.$==0 .tm Sick Logic: macro pB -.el \{\ -. ie \\n(pQ>=1 .nr pQ \\n(pQ+1 -. el \{\ -. mN \\$1 -. if \\n(mN .nr pQ \\n(pQ+1 -. \} -. rZ \\$1 -. ie \\n(rZ .as f3 \\$1 -. el \{\ -. ie \\n(pQ<1 .as y\\n(pQ \\$1 -. el .as y\\n(pQ \\$1 -. \} -. if \\n(.$>1 \{\ -. rZ \\$2 -. if \\n(rZ==0 \{\ -. if \\n(pQ<1 \{\ -. as y\\n(pQ \& \& -. \} -. \} -. pB \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.de aQ -.hy 0 -.ie \\n(.$==0 .tm Bad Syntax: .Aq -.el \{\ -. ie \\n(aQ>=1 .nr aQ \\n(aQ+1 -. el \{\ -. mN \\$1 -. if \\n(mN .nr aQ \\n(aQ+1 -. \} -. rZ \\$1 -. ie \\n(rZ .as aZ \\$1 -. el \{\ -. ie \\n(aQ<1 .as a\\n(aQ \\$1 -. el .as a\\n(aQ \\$1 -. \} -. if \\n(.$>1 \{\ -. rZ \\$2 -. if \\n(rZ==0 \{\ -. if \\n(aQ<1 \{\ -. as a\\n(aQ \& \& -. \} -. \} -. aQ \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.\" Angle Bracket Quoted Items -.de Aq -.nr aQ 0 -.ie \\n(.$==0 \{\ -. ie "\\*(iM"" \&<\&> -. el .as f1 \&<\&> -.\} -.el \{\ -. ie "\\*(iM"" \{\ -. ds f1 \&< -. ds iM Aq -. \} -. el .as f1 \&< -. aQ \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -. ie \\n(aQ>0 .\\*(a1 \\*(a2 \\*(a3 \\*(a4 \\*(a5 \\*(a6 \\*(a7 \\*(a8 -. el .as f1 \\*(a0 -. as f1 \&> -. if !"\\*(aZ"" .as f1 \\*(aZ -. if "\\*(iM"Aq" \{\ -\&\\*(f1 -. ds f1 -. ds iM -. \} -. ds aZ -. rm a0 a1 a2 a3 a4 a5 a6 a7 a8 -. nr aQ 0 -.\} -.. -.\" macro Name test, return macro register value if true -.de mN -.nr mN 0 -.sW \\$1 -.if \\n(sW==2 \{\ -. if \\n(\\$1 .nr mN \\n(\\$1 -.\} -.. -.\" Punctuation test (using z registers), return 1 if true -.de rZ -.nr rZ 0 -.sW \\$1 -.if \\n(sW==1 \{\ -. if \\n(z\\$1==1 \{\ -. nr rZ 1 -. \} -.\} -.. -.\" -.\" sW returns number of characters in a string -.if t \{\ -.nr fW \w'\fC,' -.de sW -.nr sW \w'\fC\\$1' -.\} -.if n \{\ -.nr fW \w'0' -.de sW -.nr sW \w'\\$1' -.\} -.ie \\n(sW>=\\n(fW \{\ -. ie \\n(sW%\\n(fW .nr sW (\\n(sW/\\n(fW)+1 -. el .nr sW \\n(sW/\\n(fW -.\} -.el .nr sW 0 -.. -.\" Option Expression - -.\" TODO - add line overflow check (right!) -.nr eP 0 -.ds e1 -.nr oE 0 -.nr hP 0 -.ds hP -.nr Ep 0 -.de Op -.hy 0 -.if "\\*(iM"" \{\ -. ds iM Op -. ds f1 \& -.\} -.as f1 \&\\*(lB -.\" .tm Op: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.dO \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.ie !"\\$1"Cx" .oE -.el .nr oE \\n(oE+1 -.. -.\" -.\" just for mike, with every bite of garlic in mind (oops, i mean burp). -.\" dO: go dOwn an argument vector and test each argument to see if -.\" a macro name or punctuation. stash in respective place along -.\" with its arguments. -.nr oO 0 -.nr oP 0 -.nr aO 0 -.de dO -.mN \\$1 -.ie \\n(mN \{\ -. if \\n(oP \{\ -. if \\n(hP \{\ -. nr oZ 1 -. oZ -. Oz -. \} -. if \\n(e1==1 \{\ -.\\*(e1 \\*(e2 \\*(e3 \\*(e4 \\*(e5 \\*(e6 \\*(e7 \\*(e8 \\*(e9 -. \} -. uO -. if !(\\n(oO:\\n(aO) .as f1 \& \& -. \} -. ie "\\$1"Op" \{\ -. as f1 \&\\*(lB -. nr aO \\n(aO+1 -. \} -. el \{\ -. nr eP \\n(eP+1 -. ds e\\n(eP \\$1 -. nr e\\n(eP 1 -. \} -.\} -.el \{\ -.\" .tm dO: $1: \\$1: eP \\n(eP e[\\n(eP]: \\*(e\\n(ePEE -. rZ \\$1 -. ie \\n(rZ \{\ -.\" .tm dO:rZ: $1: \\$1: eP \\n(eP e[\\n(eP]: \\*(e\\n(eP -. nr hP \\n(hP+1 -. ds h\\n(hP \\$1 -. \} -. el \{\ -.\" .tm dO:word $1: \\$1: eP \\n(eP e[\\n(eP]: \\*(e\\n(ePEE -. if \\n(eP==0:\\n(e\\n(eP==1 .nr eP \\n(eP+1 -. if \\n(eZ .as e\\n(eP \& \& -. as e\\n(eP \&\\$1 -.\" . ds e\\n(eP \&\\$1 -. nr eZ \\n(eZ+1 -. \} -.\} -.nr oP 1 -.ie \\n(.$>1 \{\ -. dO \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.\} -.el \{\ -. ie \\n(e1 \{\ -.\\*(e1 \\*(e2 \\*(e3 \\*(e4 \\*(e5 \\*(e6 \\*(e7 \\*(e8 \\*(e9 -. \} -. el \{\ -. as f1 \\*(e1 -. \} -.\} -.. -.\" handle old style arguments such as the arg -Idir -.\" in adb, .Oo is a toggle. -.de Oo -.ie \\n(oO .nr oO 0 -.el .nr oO 1 -.. -.\" stash punctuation -.de oZ -.if \\n(hP>=\\n(oZ \{\ -. nr eP \\n(eP+1 -. ds e\\n(eP \\*(h\\n(oZ -. nr oZ \\n(oZ+1 -. oZ -.\} -.. -.\" clean up punctuation vector -.de Oz -.if \\n(hP>0 \{\ -. rm h\\n(hP -. nr hP \\n(hP-1 -. Oz -.\} -.. -.\" uO: go back up created vector cleaning it up along the way -.de uO -.if \\n(eP>0 \{\ -. rm e\\n(eP -. rr e\\n(eP -. nr eP \\n(eP-1 -. nr oP 0 -. nr eZ 0 -. uO -.\} -.. -.\" option end -.de oE -.uO -.ie \\n(hP \{\ -. as f1 \\*(rB\\*(h1\\*(h2\\*(h3 -. Oz -. nr oZ 0 -.\} -.el \{\ -. as f1 \\*(rB -.\} -.ie "\\*(iM"Op" \{\ -. if \\n(aO .aO -.if t \{\ -. if (\\n(.lu-\\n(.ku-\\n(.ou-(2*\\n(fWu))<\w'\fC\\*(f1'u .br -.\} -.if n \{\ -. nr aa \w'\\*(f1'u -.\" . nr qq \\n(.lu-\\n(.ku-\\n(.ou -.\" \&aa == \\n(aa, f1==\\*(f1, qq==\\n(qq -. if (\\n(.lu-\\n(.ku-\\n(.ou-\\n(aau)<=(8*\\n(fWu) .br -.\} -\&\\*(f1 -. ds iM -. ds f1 -. hy -.\} -.el .nr oE \\n(oE-1 -.. -.de aO -.as f1 \\*(rB -.nr aO \\n(aO-1 -.if \\n(aO >0 .aO -.. -.\" -.de Xr -.if \\n(.$<=1 \{\ -. ie \\n(.$==1 \{\ -. if !"\\*(iM"" .as f1 \&\\*(xR\\$1\fP -. if "\\*(iM"" \&\\*(xR\\$1\fP -. \} -. el .tm Xr Usage: .Xr manpage_name [section#] \\*(Pu -.\} -.if \\n(.$==2 \{\ -. rZ \\$2 -. ie "\\*(iM"" \{\ -. ie \\n(rZ \&\\*(xR\\$1\fP\\$2 -. el \&\\*(xR\\$1\fP(\\$2) -. \} -. el \{\ -. ie \\n(rZ .as f1 \&\\*(xR\\$1\fP\\$2 -. el .as f1 \&\\*(xR\\$1\fP(\\$2) -. \} -.\} -.if \\n(.$>=3 \{\ -. rZ \\$2 -. ie \\n(rZ \{\ -. ie !"\\*(iM"" .as f1 \&\\*(xR\\$1\fP\\$2\\$3\\$4\\$5\\$6\\$7\\$8 -. el \&\\*(xR\\$1\fP\\$2\\$3\\$4\\$5\\$6\\$7\\$8 -. \} -. el \{\ -. rZ \\$3 -. ie \\n(rZ \{\ -. if !"\\*(iM"" \{\ -. as f1 \&\\*(xR\\$1\fP(\\$2)\\$3\\$4\\$5\\$6\\$7\\$8 -. \} -. if "\\*(iM"" \{\ -\&\\*(xR\\$1\fP(\\$2)\\$3\\$4\\$5\\$6\\$7\\$8 -. \} -. \} -. el \{\ -. tm rZ = \\n(rZ the arg is \\$3 -. tm Xr-XX Usage: .Xr manpage_name [section#] \\*(Pu -. \} -. \} -.\} -.. -.\" -.\" -.de Ex -.tm Ex defunct, Use .Dl: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.\" Display (one) Line of text. -.de Dl -.ie "\\*(iM"" \{\ -' ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -. in \\n(.iu+\\n(Dsu -. mN \\$1 -. ie \\n(mN .\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. el \{\ -. nr cF \\n(.f -.\" Literal font is none specified -\&\\*(lI\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. ft \\n(cF -. \} -. in \\n(.iu-\\n(Dsu -.\} -.el \{\ -. mN \\$1 -. ie \\n(mN .\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -. el \{\ -. nr cF \\n(.f -. ds f1 \&\\*(lI\\&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -. as f1 \&\f\\n(cF -. \} -.\} -.. -.\" -.\" -.\" user set Tagged Paragraph Width (used in both Dp and Tp) -.de Tw -.ie \\n(.$==0 \{\ -. nr aa 0 -.\} -.el \{\ -. mN \\$1 -. ie \\n(sW>2 \{\ -. nr tW (\\n(sW+3)*\\n(fWu) -. \} -. el \{\ -. ie \\n(mN .nr tW \\n(mN -. el .nr tW \\$1 -. \} -. nr tF 1 -.\} -.. -.\" -.de Dw -.Tw \\$1 -.. -.\" -.de Di -.ie \\n(.$==0 \{\ -. nr tI \\n(Dsu -.\} -.el \{\ -. sW \\$1 -. if \\n(sW>=2 \{\ -. nr tI \\$1u -. \} -. if \\n(sW<2 \{\ -. if "\\$1"L" \{\ -. nr tI 0 -. \} -. \} -.\} -.. -.\" tagged paragraph -.\" initialize baby stack variables -.nr np 0 -.nr p1 0 -.ds s\n(np -.\" -.de Tp -.ie "\\$1"" .pE p s np -.el \{\ -. ds iM Tp -. mN \\$1 -. ie \\n(tF \{\ -. ds tC Tw -. nr tC 1 -. nr tF 0 -. \} -. el \{\ -. if !"Tw"\\*(s\\n(np" \{\ -. ie \\n(mN \{\ -. ds tC \\$1 -. nr tW \\n(mN -. \} -. el \{\ -. ds tC Tx -. nr tW \\n(Tx -. \} -. if !"\\*(tC"\\*(s\\n(np" .nr tC 1 -. \} -. \} -. sp \\n(vVu -. if !\\n(cR .ne 2 -. if \\n(tC \{\ -. nr np \\n(np+1 -. nr p\\n(np \\n(tW -. ds s\\n(np \\*(tC -. nr tC 0 -. ds tC -. in \\n(.iu+\\n(p\\n(npu -. \} -. ie \\n(mN \{\ -. ds f1 -. \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. if !"\\$1"Cx" .pT st p np -. \} -. el \{\ -. br -. ev 1 -. fi -. di Td -\&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. br -. di -. ev -. na -. ds tD \\*(Td\\ -. pT di p np -. \} -.\} -.. -.\" -.\" -.\" Complex Expression Macro -.\" -.\" TODO: add length across line boundary check (like Li) -.de Cx -.hy 0 -.ie \\n(.$==0 \{\ -. if "\\*(iM"Cx" \{\ -. ds iM -. if \\n(oE .oE -\&\\*(f1 -. ds f1 -. \} -. if "\\*(iM"Tp" .pT st p np -. if "\\*(iM"Dp" .pT st q mp -.\} -.el \{\ -. if "\\*(iM"" \{\ -. ds iM Cx -. ds f1 \& -. \} -. mN \\$1 -.\" Here are the args: `\\$1' `\\$2' `\\$3' `\\$4' -. ie \\n(mN .\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. el \{\ -. as f1 \&\\$1 -. if \\n(.$>1 .Cx \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.\" Prefix string in default font to content specified string -.de Pf -.Cx \\$1 -.\\$2 \\$3 \\$4 \\$5 -.Cx -.. -.\" Suffix string in default font to content specified string -.de Sf -.Cx \\$1 \\$2 -.Cx \\$3 -.Cx -.. -.\" Simple Option Begin -.de Ob -.hy 0 -.ie "\\*(iM"" \{\ -. ev 2 -. fi -. di oB -.\} -.el \{\ -.tm shouldn't be here -. as f1 \&[ -. mN \\$1 -. ie \\n(mN .\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. el \{\ -. as f1 \&\\$1 -. if \\n(.$>1 .Oc \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -.\} -.. -.de Oc -.as f1 \&\\$1 -.if \\n(.$>1 .Oc \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.de Oe -.hy 0 -.ie "\\*(iM"" \{\ -. br -. di -. ev -. ds bO \\*(oB\\ -\&[\\*(bO\&] -.\} -.el \{\ -. as f1 \&] -.\} -.. -.\" White space for Cx -.de Ws -.Cx \&\ \& -.. -.\" tagged paragraph -.\" initialize baby stack variables -.nr mp 0 -.nr q1 0 -.ds r\n(np -.\" -.\" Complex Dp tag -.de Dc -.Dp Cx \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -.. -.\" Complex Tp tag -.de Tc -.Tp Cx \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 -.. -.\" Tag with a flag and an argument with a space -.de Ta -.if "\\$2"" \{\ -. Tp Fl \\$1 -.\} -.el \{\ -. Tp Fl \\$1 -. Cx \&\ \& -. Ar \\$2 \\$3 -. Cx -.\} -.. -.de Da -.Dp Cx Fl \\$1 -.Ws -.Ar \\$2 \\$3 -.Cx -.. -.de To -.Tp Cx Fl \\$1 -.Ar \\$2 \\$3 -.Cx -.. -.de Do -.Dp Cx Fl \\$1 -.Ar \\$2 \\$3 -.Cx -.. -.\" Blended tag toggle -.de Bt -.ie \\n(tP==0 .nr tP 1 -.el .nr tP 0 -.. -.\" Bullet paragraph -.de Bu -.Tp Sy \&\(bu -.. -.\" Display tagged paragraph -.de Dp -.ie "\\$1"" \{\ -. pE q r mp -. sp \\n(vVu -.\} -.el \{\ -. ds iM Dp -. mN \\$1 -. ie \\n(tF \{\ -. ds tC Tw -. nr tC 1 -. nr tF 0 -. \} -. el \{\ -. if !"Tw"\\*(r\\n(mp" \{\ -. ie \\n(mN \{\ -. ds tC \\$1 -. nr tW \\n(mN -. \} -. el \{\ -. ds tC Tx -. nr tW \\n(Tx -. \} -. if !"\\*(tC"\\*(r\\n(mp" .nr tC 1 -. \} -. \} -. if !\\n(cR .ne 2 -. if \\n(tC \{\ -. nr mp \\n(mp+1 -. nr q\\n(mp \\n(tW -. ds r\\n(mp \\*(tC -. nr tC 0 -. ds tC -. ie \\n(tIu==\\n(Dsu .nr i\\n(mp \\n(Dsu -. el \{\ -. nr i\\n(mp \\n(tIu -. nr tI \\n(Dsu -. \} -. in \\n(.iu+\\n(i\\n(mpu -. sp \\n(vVu -. in \\n(.iu+\\n(\\q\\n(mpu -. \} -. ie \\n(mN \{\ -. \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. if !"\\$1"Cx" .pT st q mp -. \} -. el \{\ -. br -. ev 1 -. fi -. di Td -\&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. br -. di -. ev -. na -. ds tD \\*(Td\\ -. pT di q mp -. \} -.\} -.. -.\" -.\" .pE number_stack string_stack counter -.de pE -.ie "\\$3"mp" \{\ -. in \\n(.iu-(\\n(\\$1\\n(\\$3u)-(\\n(i\\n(mpu) -. rr i\\n(mp -.\} -.el .in \\n(.iu-\\n(\\$1\\n(\\$3u -.\" .in \\n(.iu-\\n(\\$1\\n(\\$3u -.if \\n(\\$3<=0 .tm Extraneous call .Tp or .Dp -.rr \\$1\\n(\\$3 -.rm \\$2\\n(\\$3 -.nr \\$3 \\n(\\$3-1 -.ds iM -.. -.\" -.\" .pT [st or di] number_stack counter -.de pT -.ie "\\$1"st" \{\ -. nr bb \\n(\\$2\\n(\\$3u -. ti -\\n(bbu -. ie (\\n(\\$2\\n(\\$3u-2n)<=\w'\\*(f1'u \{\&\\*(f1\\*(tP -. if \\n(tP==0 .br -. \} -. el \\*(f1\h'|\\n(\\$2\\n(\\$3u'\c -.\} -.el \{\ -. ti -\\n(\\$2\\n(\\$3u -. ie (\\n(\\$2\\n(\\$3u-2n)<=\\n(dlu \{\&\\*(tD\\*(tP -. if !\\n(tP .br -. \} -. el \\*(tD\h'|\\n(\\$2\\n(\\$3u-'\c -. if t 'ad -.\} -. ds iM -. ds f1 -'fi -.. -.\" -.\" The new SH -.\" -.de Sh -.\" set Sh state off, check for list state before calling indent (.In) -.nr nS 0 -.nr sE 0 -.ie "\\$1"NAME" \{\ -.\" name state on, housekeep (headers & footers) -. hK -' in 0 -.\} -.el \{\ -. if "\\$1"SYNOPSIS" .nr nS 1 -. in 0 -.\} -.pL -'sp -.ns -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.if !\\n(cR .ne 3 -'fi -\&\fB\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6 \|\\$7 \|\\$8 \|\\$9 -\&\fP\& -.in \\n(.iu+\\n(Tiu -.if "\\$1"SEE" .nr sE 1 -.ns -.. -.\" -.\" Nd minus sign for an en dash used in .Sh Name -.de Nd -\&\-\& \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.de Ss -.sp -.ti -.25i -\&\fB\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6 \|\\$7 \|\\$8 \|\\$9 -\&\fP\& -.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.if !\\n(cR .ne 2 -.br -.. -.\" .if "\\$1"Ss" .in \\n(.iu+\\n(sIu -.\".. -.\" -.\" -.\" Column Macro -.\" -.hy 0 -.de Cw -.ie \\n(.$==0 \{\ -. br -. in \\n(.iu-\\n(eWu -. ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i -.\} -.el \{\ -. Pp -. if \\n(.$==1 \{\ -. ta \w'\\$1 'u -. nr eW \w'\\$1 'u -' in \\n(.iu+\\n(eWu -. \} -. if \\n(.$==2 \{\ -. ta \w'\\$1 'u +\w'\\$2 'u -. nr eW \w'\\$1 'u+\w'\\$2 'u -' in \\n(.iu+\\n(eWu -. \} -. if \\n(.$==3 \{\ -. ta \w'\\$1 'u +\w'\\$2 'u +\w'\\$3 'u -. nr eW \w'\\$1 'u+\w'\\$2 'u+\w'\\$3 'u -' in \\n(.iu+\\n(eWu -. \} -. if \\n(.$==4 \{\ -. ta \w'\\$1 'u +\w'\\$2 'u +\w'\\$3 'u +\w'\\$4 'u -. nr eW \w'\\$1 'u+\w'\\$2 'u+\w'\\$3 'u +\w'\\$4 'u -' in \\n(.iu+\\n(eWu -. \} -. if \\n(.$==5 \{\ -.ta \w'\\$1 'u +\w'\\$2 'u +\w'\\$3 'u +\w'\\$4 'u +\w'\\$5 'u -.nr eW \w'\\$1 'u +\w'\\$2 'u +\w'\\$3 'u +\w'\\$4 'u +\w'\\$5 'u -' in \\n(.iu+\\n(eWu -. \} -.\} -.. -.de Cl -.ti -\\n(eWu -.mN \\$1 -.ie \\n(mN .\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.el \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.nr dQ 0 -.de Ds -.ie !"\\$1"" \{\ -. mN d\\$1 -. if \\n(mN \{\ -. nr dQ \\n(dQ+1 -. d\\$1 -. \} -.\} -.el .br -.nf -.. -.de Df -.ie !"\\$1"" \{\ -. mN d\\$1 -. if \\n(mN \{\ -. nr dQ \\n(dQ+1 -. d\\$1 -. \} -.\} -.el .br -.. -.de Dn -\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.nf -.. -.de dI -.nr d\\n(dQ \\n(dIu -.in \\n(.iu+\\n(dIu -.. -.de dC -.nr d\\n(dQ (\\n(.l-\\n(.i)/4u -.in \\n(.iu+\\n(d\\n(dQu -.. -.de dR -.nr d\\n(dQ (\\n(.l/3)u -.in \\n(.iu+\\n(d\\n(dQu -.. -.de dL -.nr aa 0 -.. -.de De -.br -.if \\n(d\\n(dQ \{\ -. in \\n(.iu-\\n(d\\n(dQu -. rr d\\n(dQ -. nr dQ \\n(dQ-1 -.\} -.fi -.. -.\" -.de Fn -.ie \\n(.$==0 \{\ -. tm Usage: .Fn function_name function_arg(s) ... \\*(Pu -.\} -.el \{\ -. nr cF \\n(.f -. ie \\n(.$==1 .ds f1 \&\\*(nM\\$1\fP\\*(lP\fP\\*(rP\fP -. el \{\ -. ds f1 \\*(nM\\$1\fP\\*(lP -. nr aa 0 -. rC \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -. \} -. if "\\*(iM"" \{\\&\\*(f1 -. ds f1 -. \} -.\} -.. -.\" -.de rC -.rZ \\$1 -.ie \\n(rZ \{\ -. as f1 \f\\n(cF\\*(rP\f\\n(cF\\$1\\$2\\$3\\$4\\$5\\$6\\$7 -.\} -.el \{\ -. ie \\n(aa .as f1 \fP, \\*(aR\\$1 -. el .as f1 \\*(aR\\$1 -. nr aa 1 -. ie \\n(.$>1 .rC \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 -. el .as f1 \fP\\*(rP\fP -.\} -.. diff --git a/share/tmac/tmac.e b/share/tmac/tmac.e deleted file mode 100644 index dabaf7b3543c..000000000000 --- a/share/tmac/tmac.e +++ /dev/null @@ -1,41 +0,0 @@ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tmac.e 8.2 (Berkeley) 3/27/94 -.\" -.\" If groff, use groff -me, else use local -me (w/ditroff, troff, nroff) -.ie \n(.g \{\ -. so /usr/share/tmac/tmac.groff_me -.\} -.el \{\ -. so /usr/share/tmac/tmac.orig_me -.\} diff --git a/share/tmac/tmac.s b/share/tmac/tmac.s deleted file mode 100644 index 8a80ceb82a60..000000000000 --- a/share/tmac/tmac.s +++ /dev/null @@ -1,41 +0,0 @@ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tmac.s 8.1 (Berkeley) 6/8/93 -.\" -.\" If groff, use groff -ms, else use local -ms (w/ditroff, troff, nroff) -.ie \n(.g \{\ -. so /usr/share/tmac/tmac.groff_ms -.\} -.el \{\ -. so /usr/old/lib/tmac/tmac.s -.\} diff --git a/share/tmac/tmac.sU b/share/tmac/tmac.sU deleted file mode 100644 index 3c7a83d05146..000000000000 --- a/share/tmac/tmac.sU +++ /dev/null @@ -1,46 +0,0 @@ -.\" Copyright (c) 1992, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tmac.sU 8.1 (Berkeley) 6/8/93 -.\" -.\" Modify -ms macros for typesetting manuals for Usenix distribution. -.\" Differences: page numbers even on page 1, MH = Bell Labs, -.\" default line length (and title length) 6.5i instead of 6i. -.\" -.so /usr/share/tmac/tmac.s -.nr P1 1 \" page number on page 1 -.nr LL 6.5i -.ll \\n(LLu -.lt 6.5i -.de MH -AT&T Bell Laboratories -Murray Hill, New Jersey 07974 -.. diff --git a/sys/i386/ibcs2/ibcs2_timeb.h b/sys/i386/ibcs2/ibcs2_timeb.h deleted file mode 100644 index d85202d91725..000000000000 --- a/sys/i386/ibcs2/ibcs2_timeb.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1995 Scott Bartram - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Scott Bartram. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _IBCS2_TIMEB_H -#define _IBCS2_TIMEB_H - -#pragma pack(2) -struct xenix_timeb { - ibcs2_time_t time; - unsigned short millitm; - short timezone; - short dstflag; -}; -#pragma pack() - -#define xenix_timeb_len 10 /* packed struct */ - -#endif /* _IBCS2_TIMEB_H */ diff --git a/usr.bin/apropos/Makefile b/usr.bin/apropos/Makefile deleted file mode 100644 index 028a42c467ea..000000000000 --- a/usr.bin/apropos/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= apropos -SRCS= apropos.c config.c -.PATH: ${.CURDIR}/../man - -.include diff --git a/usr.bin/apropos/apropos.1 b/usr.bin/apropos/apropos.1 deleted file mode 100644 index eb68f375561a..000000000000 --- a/usr.bin/apropos/apropos.1 +++ /dev/null @@ -1,120 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)apropos.1 8.1 (Berkeley) 6/29/93 -.\" -.Dd June 29, 1993 -.Dt APROPOS 1 -.Os -.Sh NAME -.Nm apropos -.Nd locate commands by keyword lookup -.Sh SYNOPSIS -.Nm apropos -.Op Fl M Ar path -.Op Fl m Ar path -.Ar keyword ... -.Sh DESCRIPTION -.Nm Apropos -shows which manual pages contain instances of any of the given -.Ar keyword(s) -in their title line. -Each word is considered separately and case of letters is ignored. -Words which are part of other words are considered; when looking for -.Dq compile , -.Nm apropos -will also list all instances of -.Dq compiler . -.Pp -If the line output by -.Nm apropos -starts -.Dq Li name(section) ... -you can enter -.Dq Li man section name -to get -its documentation. -.Pp -The options are as follows: -.Bl -tag -width flag -.It Fl M -Override the list of standard directories -.Nm apropos -searches for a database named -.Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -.It Fl m -Augment the list of standard directories -.Nm apropos -searches for its database. -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -These directories will be searched before the standard directories, -or the directories supplied with the -.Fl M -option or the -.Ev MANPATH -environment variable. -.Sh ENVIRONMENT -.Bl -tag -width MANPATH -.It Ev MANPATH -The standard search path used by -.Xr man 1 -may be overridden by specifying a path in the -.Ev MANPATH -environment variable. -The format of the path is a colon -.Dq \&: -separated list of directories. -.El -.Sh FILES -.Bl -tag -width whatis.db -compact -.It Pa whatis.db -name of the apropos database -.El -.Sh SEE ALSO -.Xr man 1 , -.Xr whatis 1 , -.Xr whereis 1 -.Sh HISTORY -The -.Nm apropos -command appeared in -.Bx 3.0 . diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c deleted file mode 100644 index a0e05256f033..000000000000 --- a/usr.bin/apropos/apropos.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)apropos.c 8.7 (Berkeley) 4/2/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "../man/config.h" -#include "../man/pathnames.h" - -static int *found, foundman; - -void apropos __P((char **, char *, int)); -void lowstr __P((char *, char *)); -int match __P((char *, char *)); -void usage __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - ENTRY *ep; - TAG *tp; - int ch, rv; - char *conffile, **p, *p_augment, *p_path; - - conffile = NULL; - p_augment = p_path = NULL; - while ((ch = getopt(argc, argv, "C:M:m:P:")) != EOF) - switch (ch) { - case 'C': - conffile = optarg; - break; - case 'M': - case 'P': /* backward compatible */ - p_path = optarg; - break; - case 'm': - p_augment = optarg; - break; - case '?': - default: - usage(); - } - argv += optind; - argc -= optind; - - if (argc < 1) - usage(); - - if ((found = malloc((u_int)argc * sizeof(int))) == NULL) - err(1, NULL); - memset(found, 0, argc * sizeof(int)); - - for (p = argv; *p; ++p) /* convert to lower-case */ - lowstr(*p, *p); - - if (p_augment) - apropos(argv, p_augment, 1); - if (p_path || (p_path = getenv("MANPATH"))) - apropos(argv, p_path, 1); - else { - config(conffile); - ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - apropos(argv, ep->s, 0); - } - - if (!foundman) - errx(1, "no %s file found", _PATH_WHATIS); - - rv = 1; - for (p = argv; *p; ++p) - if (found[p - argv]) - rv = 0; - else - (void)printf("%s: nothing appropriate\n", *p); - exit(rv); -} - -void -apropos(argv, path, buildpath) - char **argv, *path; - int buildpath; -{ - char *end, *name, **p; - char buf[LINE_MAX + 1], wbuf[LINE_MAX + 1]; - - for (name = path; name; name = end) { /* through name list */ - if (end = strchr(name, ':')) - *end++ = '\0'; - - if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); - name = hold; - } - - if (!freopen(name, "r", stdin)) - continue; - - foundman = 1; - - /* for each file found */ - while (fgets(buf, sizeof(buf), stdin)) { - if (!strchr(buf, '\n')) { - warnx("%s: line too long", name); - continue; - } - lowstr(buf, wbuf); - for (p = argv; *p; ++p) - if (match(wbuf, *p)) { - (void)printf("%s", buf); - found[p - argv] = 1; - - /* only print line once */ - while (*++p) - if (match(wbuf, *p)) - found[p - argv] = 1; - break; - } - } - } -} - -/* - * match -- - * match anywhere the string appears - */ -int -match(bp, str) - char *bp, *str; -{ - int len; - char test; - - if (!*bp) - return (0); - /* backward compatible: everything matches empty string */ - if (!*str) - return (1); - for (test = *str++, len = strlen(str); *bp;) - if (test == *bp++ && !strncmp(bp, str, len)) - return (1); - return (0); -} - -/* - * lowstr -- - * convert a string to lower case - */ -void -lowstr(from, to) - char *from, *to; -{ - char ch; - - while ((ch = *from++) && ch != '\n') - *to++ = isupper(ch) ? tolower(ch) : ch; - *to = '\0'; -} - -/* - * usage -- - * print usage message and die - */ -void -usage() -{ - - (void)fprintf(stderr, - "usage: apropos [-C file] [-M path] [-m path] keyword ...\n"); - exit(1); -} diff --git a/usr.bin/ar/ar.5.5 b/usr.bin/ar/ar.5.5 deleted file mode 100644 index 29c8f8c8102d..000000000000 --- a/usr.bin/ar/ar.5.5 +++ /dev/null @@ -1,145 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ar.5.5 8.1 (Berkeley) 6/9/93 -.\" -.Dd June 9, 1993 -.Dt AR 5 -.Os -.Sh NAME -.Nm ar -.Nd archive (library) file format -.Sh SYNOPSIS -.Fd #include -.Sh DESCRIPTION -The archive command -.Nm ar -combines several files into one. -Archives are mainly used as libraries of object files intended to be -loaded using the link-editor -.Xr ld 1 . -.Pp -A file created with -.Nm ar -begins with the ``magic'' string "!\en". -The rest of the archive is made up of objects, each of which is composed -of a header for a file, a possible file name, and the file contents. -The header is portable between machine architectures, and, if the file -contents are printable, the archive is itself printable. -.Pp -The header is made up of six variable length -.Tn ASCII -fields, followed by a -two character trailer. -The fields are the object name (16 characters), the file last modification -time (12 characters), the user and group id's (each 6 characters), the file -mode (8 characters) and the file size (10 characters). -All numeric fields are in decimal, except for the file mode which is in -octal. -.Pp -The modification time is the file -.Fa st_mtime -field, i.e., -.Dv CUT -seconds since -the epoch. -The user and group id's are the file -.Fa st_uid -and -.Fa st_gid -fields. -The file mode is the file -.Fa st_mode -field. -The file size is the file -.Fa st_size -field. -The two-byte trailer is the string "\`\en". -.Pp -Only the name field has any provision for overflow. -If any file name is more than 16 characters in length or contains an -embedded space, the string "#1/" followed by the -.Tn ASCII -length of the -name is written in the name field. -The file size (stored in the archive header) is incremented by the length -of the name. -The name is then written immediately following the archive header. -.Pp -Any unused characters in any of these fields are written as space -characters. -If any fields are their particular maximum number of characters in -length, there will be no separation between the fields. -.Pp -Objects in the archive are always an even number of bytes long; files -which are an odd number of bytes long are padded with a newline (``\en'') -character, although the size in the header does not reflect this. -.Sh SEE ALSO -.Xr ar 1 , -.Xr stat 2 -.Sh HISTORY -There have been at least four -.Nm ar -formats. -The first was denoted by the leading ``magic'' number 0177555 (stored as -type int). -These archives were almost certainly created on a 16-bit machine, and -contain headers made up of five fields. -The fields are the object name (8 characters), the file last modification -time (type long), the user id (type char), the file mode (type char) and -the file size (type unsigned int). -Files were padded to an even number of bytes. -.Pp -The second was denoted by the leading ``magic'' number 0177545 (stored as -type int). -These archives may have been created on either 16 or 32-bit machines, and -contain headers made up of six fields. -The fields are the object name (14 characters), the file last modification -time (type long), the user and group id's (each type char), the file mode -(type int) and the file size (type long). -Files were padded to an even number of bytes. -For more information on converting from this format see -.Xr arcv 8 . -.Pp -The current archive format (without support for long character names and -names with embedded spaces) was introduced in -.Bx 4.0 . -The headers were the same as the current format, with the exception that -names longer than 16 characters were truncated, and names with embedded -spaces (and often trailing spaces) were not supported. -It has been extended for these reasons, -as described above. -This format first appeared in 4.4BSD. -.Sh COMPATIBILITY -No archive format is currently specified by any standard. -.At V -has historically distributed archives in a different format from -all of the above. diff --git a/usr.bin/bdes/Makefile b/usr.bin/bdes/Makefile deleted file mode 100644 index 9166f721c4b3..000000000000 --- a/usr.bin/bdes/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= bdes - -.include diff --git a/usr.bin/bdes/bdes.1 b/usr.bin/bdes/bdes.1 deleted file mode 100644 index eecd81b5d86d..000000000000 --- a/usr.bin/bdes/bdes.1 +++ /dev/null @@ -1,304 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Matt Bishop of Dartmouth College. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)bdes.1 8.1 (Berkeley) 6/29/93 -.\" -.TH BDES 1 "June 29, 1993" -.UC 6 -.SH NAME -bdes \- encrypt/decrypt using the Data Encryption Standard -.SH SYNOPSIS -.nf -.ft B -bdes [ \-abdp ] [ \-F N ] [ \-f N ] [ \-k key ] -.ti +5 -[ \-m N ] [ \-o N ] [ \-v vector ] -.ft R -.fi -.SH DESCRIPTION -.I Bdes -implements all DES modes of operation described in FIPS PUB 81, -including alternative cipher feedback mode and both authentication -modes. -.I Bdes -reads from the standard input and writes to the standard output. -By default, the input is encrypted using cipher block chaining mode. -Using the same key for encryption and decryption preserves plain text. -.PP -All modes but the electronic code book mode require an initialization -vector; if none is supplied, the zero vector is used. -If no -.I key -is specified on the command line, the user is prompted for one (see -.IR getpass (3) -for more details). -.PP -The options are as follows: -.TP -\-a -The key and initialization vector strings are to be taken as ASCII, -suppressing the special interpretation given to leading ``0X'', ``0x'', -``0B'', and ``0b'' characters. -This flag applies to -.I both -the key and initialization vector. -.TP -\-b -Use electronic code book mode. -.TP -\-d -Decrypt the input. -.TP -\-F -Use -.IR N -bit -alternative cipher feedback mode. -Currently -.I N -must be a multiple of 7 between 7 and 56 inclusive (this does not conform -to the alternative CFB mode specification). -.TP -\-f -Use -.IR N -bit -cipher feedback mode. -Currently -.I N -must be a multiple of 8 between 8 and 64 inclusive (this does not conform -to the standard CFB mode specification). -.TP -\-k -Use -.I key -as the cryptographic key. -.TP -\-m -Compute a message authentication code (MAC) of -.I N -bits on the input. -The value of -.I N -must be between 1 and 64 inclusive; if -.I N -is not a multiple of 8, enough 0 bits will be added to pad the MAC length -to the nearest multiple of 8. -Only the MAC is output. -MACs are only available in cipher block chaining mode or in cipher feedback -mode. -.TP -\-o -Use -.IR N -bit -output feedback mode. -Currently -.I N -must be a multiple of 8 between 8 and 64 inclusive (this does not conform -to the OFB mode specification). -.TP -\-p -Disable the resetting of the parity bit. -This flag forces the parity bit of the key to be used as typed, rather than -making each character be of odd parity. -It is used only if the key is given in ASCII. -.TP -\-v -Set the initialization vector to -.IR vector ; -the vector is interpreted in the same way as the key. -The vector is ignored in electronic codebook mode. -.PP -The key and initialization vector are taken as sequences of ASCII -characters which are then mapped into their bit representations. -If either begins with ``0X'' or ``0x'', -that one is taken as a sequence of hexadecimal digits indicating the -bit pattern; -if either begins with ``0B'' or ``0b'', -that one is taken as a sequence of binary digits indicating the bit pattern. -In either case, -only the leading 64 bits of the key or initialization vector -are used, -and if fewer than 64 bits are provided, enough 0 bits are appended -to pad the key to 64 bits. -.PP -According to the DES standard, the low-order bit of each character in the -key string is deleted. -Since most ASCII representations set the high-order bit to 0, simply -deleting the low-order bit effectively reduces the size of the key space -from 2\u\s-356\s0\d to 2\u\s-348\s0\d keys. -To prevent this, the high-order bit must be a function depending in part -upon the low-order bit; so, the high-order bit is set to whatever value -gives odd parity. -This preserves the key space size. -Note this resetting of the parity bit is -.I not -done if the key is given in binary or hex, and can be disabled for ASCII -keys as well. -.PP -The DES is considered a very strong cryptosystem, and other than table lookup -attacks, key search attacks, and Hellman's time-memory tradeoff (all of which -are very expensive and time-consuming), no cryptanalytic methods for breaking -the DES are known in the open literature. -No doubt the choice of keys and key security are the most vulnerable aspect -of -.IR bdes . -.SH IMPLEMENTATION NOTES -For implementors wishing to write software compatible with this program, -the following notes are provided. -This software is believed to be compatible with the implementation of the -data encryption standard distributed by Sun Microsystems, Inc. -.PP -In the ECB and CBC modes, plaintext is encrypted in units of 64 bits (8 bytes, -also called a block). -To ensure that the plaintext file is encrypted correctly, -.I bdes -will (internally) append from 1 to 8 bytes, the last byte containing an -integer stating how many bytes of that final block are from the plaintext -file, and encrypt the resulting block. -Hence, when decrypting, the last block may contain from 0 to 7 characters -present in the plaintext file, and the last byte tells how many. -Note that if during decryption the last byte of the file does not contain an -integer between 0 and 7, either the file has been corrupted or an incorrect -key has been given. -A similar mechanism is used for the OFB and CFB modes, except that those -simply require the length of the input to be a multiple of the mode size, -and the final byte contains an integer between 0 and one less than the number -of bytes being used as the mode. -(This was another reason that the mode size must be a multiple of 8 for those -modes.) -.PP -Unlike Sun's implementation, unused bytes of that last block are not filled -with random data, but instead contain what was in those byte positions in -the preceding block. -This is quicker and more portable, and does not weaken the encryption -significantly. -.PP -If the key is entered in ASCII, the parity bits of the key characters are set -so that each key character is of odd parity. -Unlike Sun's implementation, it is possible to enter binary or hexadecimal -keys on the command line, and if this is done, the parity bits are -.I not -reset. -This allows testing using arbitrary bit patterns as keys. -.PP -The Sun implementation always uses an initialization vector of 0 -(that is, all zeroes). -By default, -.I bdes -does too, but this may be changed from the command line. -.SH SEE ALSO -crypt(1), crypt(3), getpass(3) -.sp -.IR "Data Encryption Standard" , -Federal Information Processing Standard #46, -National Bureau of Standards, -U.S. Department of Commerce, -Washington DC -(Jan. 1977) -.sp -.IR "DES Modes of Operation" , -Federal Information Processing Standard #81, -National Bureau of Standards, -U.S. Department of Commerce -Washington DC -(Dec. 1980) -.sp -Dorothy Denning, -.IR "Cryptography and Data Security" , -Addison-Wesley Publishing Co., -Reading, MA -\(co1982. -.sp -Matt Bishop, -.IR "Implementation Notes on bdes(1)" , -Technical Report PCS-TR-91-158, -Department of Mathematics and Computer Science, -Dartmouth College, -Hanover, NH 03755 -(Apr. 1991). -.SH DISCLAIMER -.nf -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. -.fi -.SH BUGS -There is a controversy raging over whether the DES will still be secure -in a few years. -The advent of special-purpose hardware could reduce the cost of any of the -methods of attack named above so that they are no longer computationally -infeasible. -.PP -As the key or key schedule is stored in memory, the encryption can be -compromised if memory is readable. -Additionally, programs which display programs' arguments may compromise the -key and initialization vector, if they are specified on the command line. -To avoid this -.I bdes -overwrites its arguments, however, the obvious race cannot currently be -avoided. -.PP -Certain specific keys should be avoided because they introduce potential -weaknesses; these keys, called the -.I weak -and -.I semiweak -keys, are (in hex notation, where p is either 0 or 1, and P is either -e or f): -.sp -.nf -.in +10n -.ta \w'0x0p0p0p0p0p0p0p0p\0\0\0'u+5n -0x0p0p0p0p0p0p0p0p 0x0p1P0p1P0p0P0p0P -0x0pep0pep0pfp0pfp 0x0pfP0pfP0pfP0pfP -0x1P0p1P0p0P0p0P0p 0x1P1P1P1P0P0P0P0P -0x1Pep1Pep0Pfp0Pfp 0x1PfP1PfP0PfP0PfP -0xep0pep0pfp0pfp0p 0xep1Pep1pfp0Pfp0P -0xepepepepepepepep 0xepfPepfPfpfPfpfP -0xfP0pfP0pfP0pfP0p 0xfP1PfP1PfP0PfP0P -0xfPepfPepfPepfPep 0xfPfPfPfPfPfPfPfP -.fi -.in -10n -.sp -This is inherent in the DES algorithm (see Moore and Simmons, -\*(LqCycle structure of the DES with weak and semi-weak keys,\*(Rq -.I "Advances in Cryptology \- Crypto '86 Proceedings" , -Springer-Verlag New York, \(co1987, pp. 9-32.) diff --git a/usr.bin/bdes/bdes.c b/usr.bin/bdes/bdes.c deleted file mode 100644 index f702e019bec4..000000000000 --- a/usr.bin/bdes/bdes.c +++ /dev/null @@ -1,1046 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Matt Bishop of Dartmouth College. - * - * The United States Government has rights in this work pursuant - * to contract no. NAG 2-680 between the National Aeronautics and - * Space Administration and Dartmouth College. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)bdes.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * BDES -- DES encryption package for Berkeley Software Distribution 4.4 - * options: - * -a key is in ASCII - * -b use ECB (electronic code book) mode - * -d invert (decrypt) input - * -f b use b-bit CFB (cipher feedback) mode - * -F b use b-bit CFB (cipher feedback) alternative mode - * -k key use key as the cryptographic key - * -m b generate a MAC of length b - * -o b use b-bit OFB (output feedback) mode - * -p don't reset the parity bit - * -v v use v as the initialization vector (ignored for ECB) - * note: the last character of the last block is the integer indicating - * how many characters of that block are to be output - * - * Author: Matt Bishop - * Department of Mathematics and Computer Science - * Dartmouth College - * Hanover, NH 03755 - * Email: Matt.Bishop@dartmouth.edu - * ...!decvax!dartvax!Matt.Bishop - * - * See Technical Report PCS-TR91-158, Department of Mathematics and Computer - * Science, Dartmouth College, for a detailed description of the implemen- - * tation and differences between it and Sun's. The DES is described in - * FIPS PUB 46, and the modes in FIPS PUB 81 (see either the manual page - * or the technical report for a complete reference). - */ - -#include -#include -#include -#include -#include -#include - -/* - * BSD and System V systems offer special library calls that do - * block moves and fills, so if possible we take advantage of them - */ -#define MEMCPY(dest,src,len) bcopy((src),(dest),(len)) -#define MEMZERO(dest,len) bzero((dest),(len)) - -/* Hide the calls to the primitive encryption routines. */ -#define FASTWAY -#ifdef FASTWAY -#define DES_KEY(buf) \ - if (des_setkey(buf)) \ - err("des_setkey", 0); -#define DES_XFORM(buf) \ - if (des_cipher(buf, buf, 0L, (inverse ? -1 : 1))) \ - err("des_cipher", 0); -#else -#define DES_KEY(buf) { \ - char bits1[64]; /* bits of key */ \ - expand(buf, bits1); \ - if (setkey(bits1)) \ - err("setkey", 0); \ - } -#define DES_XFORM(buf) { \ - char bits1[64]; /* bits of message */ \ - expand(buf, bits1); \ - if (encrypt(bits1, inverse)) \ - err("encrypt", 0); \ - compress(bits1, buf); \ - } -#endif - -/* - * this does an error-checking write - */ -#define READ(buf, n) fread(buf, sizeof(char), n, stdin) -#define WRITE(buf,n) \ - if (fwrite(buf, sizeof(char), n, stdout) != n) \ - err(bn, NULL); - -/* - * some things to make references easier - */ -typedef char Desbuf[8]; -#define CHAR(x,i) (x[i]) -#define UCHAR(x,i) (x[i]) -#define BUFFER(x) (x) -#define UBUFFER(x) (x) - -/* - * global variables and related macros - */ -#define KEY_DEFAULT 0 /* interpret radix of key from key */ -#define KEY_ASCII 1 /* key is in ASCII characters */ -int keybase = KEY_DEFAULT; /* how to interpret the key */ - -enum { /* encrypt, decrypt, authenticate */ - MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE -} mode = MODE_ENCRYPT; -enum { /* ecb, cbc, cfb, cfba, ofb? */ - ALG_ECB, ALG_CBC, ALG_CFB, ALG_OFB, ALG_CFBA -} alg = ALG_CBC; - -Desbuf ivec; /* initialization vector */ -char bits[] = { /* used to extract bits from a char */ - '\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001' -}; -int inverse; /* 0 to encrypt, 1 to decrypt */ -int macbits = -1; /* number of bits in authentication */ -int fbbits = -1; /* number of feedback bits */ -int pflag; /* 1 to preserve parity bits */ - -main(ac, av) - int ac; /* arg count */ - char **av; /* arg vector */ -{ - extern int optind; /* option (argument) number */ - extern char *optarg; /* argument to option if any */ - register int i; /* counter in a for loop */ - register char *p; /* used to obtain the key */ - Desbuf msgbuf; /* I/O buffer */ - int kflag; /* command-line encryptiooon key */ - int argc; /* the real arg count */ - char **argv; /* the real argument vector */ - - /* - * Hide the arguments from ps(1) by making private copies of them - * and clobbering the global (visible to ps(1)) ones. - */ - argc = ac; - ac = 1; - argv = malloc((argc + 1) * sizeof(char *)); - for (i = 0; i < argc; ++i) { - argv[i] = strdup(av[i]); - MEMZERO(av[i], strlen(av[i])); - } - argv[argc] = NULL; - - /* initialize the initialization vctor */ - MEMZERO(ivec, 8); - - /* process the argument list */ - kflag = 0; - while ((i = getopt(argc, argv, "abdF:f:k:m:o:pv:")) != EOF) - switch(i) { - case 'a': /* key is ASCII */ - keybase = KEY_ASCII; - break; - case 'b': /* use ECB mode */ - alg = ALG_ECB; - break; - case 'd': /* decrypt */ - mode = MODE_DECRYPT; - break; - case 'F': /* use alternative CFB mode */ - alg = ALG_CFBA; - if ((fbbits = setbits(optarg, 7)) > 56 || fbbits == 0) - err(-1, "-F: number must be 1-56 inclusive"); - else if (fbbits == -1) - err(-1, "-F: number must be a multiple of 7"); - break; - case 'f': /* use CFB mode */ - alg = ALG_CFB; - if ((fbbits = setbits(optarg, 8)) > 64 || fbbits == 0) - err(-1, "-f: number must be 1-64 inclusive"); - else if (fbbits == -1) - err(-1, "-f: number must be a multiple of 8"); - break; - case 'k': /* encryption key */ - kflag = 1; - cvtkey(BUFFER(msgbuf), optarg); - break; - case 'm': /* number of bits for MACing */ - mode = MODE_AUTHENTICATE; - if ((macbits = setbits(optarg, 1)) > 64) - err(-1, "-m: number must be 0-64 inclusive"); - break; - case 'o': /* use OFB mode */ - alg = ALG_OFB; - if ((fbbits = setbits(optarg, 8)) > 64 || fbbits == 0) - err(-1, "-o: number must be 1-64 inclusive"); - else if (fbbits == -1) - err(-1, "-o: number must be a multiple of 8"); - break; - case 'p': /* preserve parity bits */ - pflag = 1; - break; - case 'v': /* set initialization vector */ - cvtkey(BUFFER(ivec), optarg); - break; - default: /* error */ - usage(); - } - - if (!kflag) { - /* - * if the key's not ASCII, assume it is - */ - keybase = KEY_ASCII; - /* - * get the key - */ - p = getpass("Enter key: "); - /* - * copy it, nul-padded, into the key area - */ - cvtkey(BUFFER(msgbuf), p); - } - - makekey(msgbuf); - inverse = (alg == ALG_CBC || alg == ALG_ECB) && mode == MODE_DECRYPT; - - switch(alg) { - case ALG_CBC: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CBC mode */ - cbcauth(); - break; - case MODE_DECRYPT: /* decrypt using CBC mode */ - cbcdec(); - break; - case MODE_ENCRYPT: /* encrypt using CBC mode */ - cbcenc(); - break; - } - break; - case ALG_CFB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CFB mode */ - cfbauth(); - break; - case MODE_DECRYPT: /* decrypt using CFB mode */ - cfbdec(); - break; - case MODE_ENCRYPT: /* encrypt using CFB mode */ - cfbenc(); - break; - } - break; - case ALG_CFBA: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CFBA mode */ - err(-1, "can't authenticate with CFBA mode"); - break; - case MODE_DECRYPT: /* decrypt using CFBA mode */ - cfbadec(); - break; - case MODE_ENCRYPT: /* encrypt using CFBA mode */ - cfbaenc(); - break; - } - break; - case ALG_ECB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using ECB mode */ - err(-1, "can't authenticate with ECB mode"); - break; - case MODE_DECRYPT: /* decrypt using ECB mode */ - ecbdec(); - break; - case MODE_ENCRYPT: /* encrypt using ECB mode */ - ecbenc(); - break; - } - break; - case ALG_OFB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using OFB mode */ - err(-1, "can't authenticate with OFB mode"); - break; - case MODE_DECRYPT: /* decrypt using OFB mode */ - ofbdec(); - break; - case MODE_ENCRYPT: /* encrypt using OFB mode */ - ofbenc(); - break; - } - break; - } - exit(0); -} - -/* - * print a warning message and, possibly, terminate - */ -err(n, s) - int n; /* offending block number */ - char *s; /* the message */ -{ - if (n > 0) - (void)fprintf(stderr, "bdes (block %d): ", n); - else - (void)fprintf(stderr, "bdes: "); - (void)fprintf(stderr, "%s\n", s ? s : strerror(errno)); - exit(1); -} - -/* - * map a hex character to an integer - */ -tobinhex(c, radix) - char c; /* char to be converted */ - int radix; /* base (2 to 16) */ -{ - switch(c) { - case '0': return(0x0); - case '1': return(0x1); - case '2': return(radix > 2 ? 0x2 : -1); - case '3': return(radix > 3 ? 0x3 : -1); - case '4': return(radix > 4 ? 0x4 : -1); - case '5': return(radix > 5 ? 0x5 : -1); - case '6': return(radix > 6 ? 0x6 : -1); - case '7': return(radix > 7 ? 0x7 : -1); - case '8': return(radix > 8 ? 0x8 : -1); - case '9': return(radix > 9 ? 0x9 : -1); - case 'A': case 'a': return(radix > 10 ? 0xa : -1); - case 'B': case 'b': return(radix > 11 ? 0xb : -1); - case 'C': case 'c': return(radix > 12 ? 0xc : -1); - case 'D': case 'd': return(radix > 13 ? 0xd : -1); - case 'E': case 'e': return(radix > 14 ? 0xe : -1); - case 'F': case 'f': return(radix > 15 ? 0xf : -1); - } - /* - * invalid character - */ - return(-1); -} - -/* - * convert the key to a bit pattern - */ -cvtkey(obuf, ibuf) - char *obuf; /* bit pattern */ - char *ibuf; /* the key itself */ -{ - register int i, j; /* counter in a for loop */ - int nbuf[64]; /* used for hex/key translation */ - - /* - * just switch on the key base - */ - switch(keybase) { - case KEY_ASCII: /* ascii to integer */ - (void)strncpy(obuf, ibuf, 8); - return; - case KEY_DEFAULT: /* tell from context */ - /* - * leading '0x' or '0X' == hex key - */ - if (ibuf[0] == '0' && (ibuf[1] == 'x' || ibuf[1] == 'X')) { - ibuf = &ibuf[2]; - /* - * now translate it, bombing on any illegal hex digit - */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = tobinhex(ibuf[i], 16)) == -1) - err(-1, "bad hex digit in key"); - while (i < 16) - nbuf[i++] = 0; - for (i = 0; i < 8; i++) - obuf[i] = - ((nbuf[2*i]&0xf)<<4) | (nbuf[2*i+1]&0xf); - /* preserve parity bits */ - pflag = 1; - return; - } - /* - * leading '0b' or '0B' == binary key - */ - if (ibuf[0] == '0' && (ibuf[1] == 'b' || ibuf[1] == 'B')) { - ibuf = &ibuf[2]; - /* - * now translate it, bombing on any illegal binary digit - */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = tobinhex(ibuf[i], 2)) == -1) - err(-1, "bad binary digit in key"); - while (i < 64) - nbuf[i++] = 0; - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - obuf[i] = (obuf[i]<<1)|nbuf[8*i+j]; - /* preserve parity bits */ - pflag = 1; - return; - } - /* - * no special leader -- ASCII - */ - (void)strncpy(obuf, ibuf, 8); - } -} - -/* - * convert an ASCII string into a decimal number: - * 1. must be between 0 and 64 inclusive - * 2. must be a valid decimal number - * 3. must be a multiple of mult - */ -setbits(s, mult) - char *s; /* the ASCII string */ - int mult; /* what it must be a multiple of */ -{ - register char *p; /* pointer in a for loop */ - register int n = 0; /* the integer collected */ - - /* - * skip white space - */ - while (isspace(*s)) - s++; - /* - * get the integer - */ - for (p = s; *p; p++) { - if (isdigit(*p)) - n = n * 10 + *p - '0'; - else { - err(-1, "bad decimal digit in MAC length"); - } - } - /* - * be sure it's a multiple of mult - */ - return((n % mult != 0) ? -1 : n); -} - -/***************** - * DES FUNCTIONS * - *****************/ -/* - * This sets the DES key and (if you're using the deszip version) - * the direction of the transformation. This uses the Sun - * to map the 64-bit key onto the 56 bits that the key schedule - * generation routines use: the old way, which just uses the user- - * supplied 64 bits as is, and the new way, which resets the parity - * bit to be the same as the low-order bit in each character. The - * new way generates a greater variety of key schedules, since many - * systems set the parity (high) bit of each character to 0, and the - * DES ignores the low order bit of each character. - */ -makekey(buf) - Desbuf buf; /* key block */ -{ - register int i, j; /* counter in a for loop */ - register int par; /* parity counter */ - - /* - * if the parity is not preserved, flip it - */ - if (!pflag) { - for (i = 0; i < 8; i++) { - par = 0; - for (j = 1; j < 8; j++) - if ((bits[j]&UCHAR(buf, i)) != 0) - par++; - if ((par&01) == 01) - UCHAR(buf, i) = UCHAR(buf, i)&0177; - else - UCHAR(buf, i) = (UCHAR(buf, i)&0177)|0200; - } - } - - DES_KEY(UBUFFER(buf)); -} - -/* - * This encrypts using the Electronic Code Book mode of DES - */ -ecbenc() -{ - register int n; /* number of bytes actually read */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - for (bn = 0; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - } - /* - * at EOF or last block -- in either ase, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&CHAR(msgbuf, n), 8 - n); - CHAR(msgbuf, 7) = n; - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - -} - -/* - * This decrypts using the Electronic Code Book mode of DES - */ -ecbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - for (bn = 1; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - DES_XFORM(UBUFFER(msgbuf)); - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = CHAR(msgbuf, 7); - if (n < 0 || n > 7) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(BUFFER(msgbuf), n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This encrypts using the Cipher Block Chaining mode of DES - */ -cbcenc() -{ - register int n; /* number of bytes actually read */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - /* - * do the transformation - */ - for (bn = 1; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - for (n = 0; n < 8; n++) - CHAR(msgbuf, n) ^= CHAR(ivec, n); - DES_XFORM(UBUFFER(msgbuf)); - MEMCPY(BUFFER(ivec), BUFFER(msgbuf), 8); - WRITE(BUFFER(msgbuf), 8); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&CHAR(msgbuf, n), 8 - n); - CHAR(msgbuf, 7) = n; - for (n = 0; n < 8; n++) - CHAR(msgbuf, n) ^= CHAR(ivec, n); - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - -} - -/* - * This decrypts using the Cipher Block Chaining mode of DES - */ -cbcdec() -{ - register int n; /* number of bytes actually read */ - Desbuf msgbuf; /* I/O buffer */ - Desbuf ibuf; /* temp buffer for initialization vector */ - register int c; /* used to test for EOF */ - register int bn; /* block number */ - - for (bn = 0; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - MEMCPY(BUFFER(ibuf), BUFFER(msgbuf), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8; c++) - UCHAR(msgbuf, c) ^= UCHAR(ivec, c); - MEMCPY(BUFFER(ivec), BUFFER(ibuf), 8); - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = CHAR(msgbuf, 7); - if (n < 0 || n > 7) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(BUFFER(msgbuf), n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This authenticates using the Cipher Block Chaining mode of DES - */ -cbcauth() -{ - register int n, j; /* number of bytes actually read */ - Desbuf msgbuf; /* I/O buffer */ - Desbuf encbuf; /* encryption buffer */ - - /* - * do the transformation - * note we DISCARD the encrypted block; - * we only care about the last one - */ - while ((n = READ(BUFFER(msgbuf), 8)) == 8) { - for (n = 0; n < 8; n++) - CHAR(encbuf, n) = CHAR(msgbuf, n) ^ CHAR(ivec, n); - DES_XFORM(UBUFFER(encbuf)); - MEMCPY(BUFFER(ivec), BUFFER(encbuf), 8); - } - /* - * now compute the last one, right padding with '\0' if need be - */ - if (n > 0) { - MEMZERO(&CHAR(msgbuf, n), 8 - n); - for (n = 0; n < 8; n++) - CHAR(encbuf, n) = CHAR(msgbuf, n) ^ CHAR(ivec, n); - DES_XFORM(UBUFFER(encbuf)); - } - /* - * drop the bits - * we write chars until fewer than 7 bits, - * and then pad the last one with 0 bits - */ - for (n = 0; macbits > 7; n++, macbits -= 8) - (void)putchar(CHAR(encbuf, n)); - if (macbits > 0) { - CHAR(msgbuf, 0) = 0x00; - for (j = 0; j < macbits; j++) - CHAR(msgbuf, 0) |= (CHAR(encbuf, n)&bits[j]); - (void)putchar(CHAR(msgbuf, 0)); - } -} - -/* - * This encrypts using the Cipher FeedBack mode of DES - */ -cfbenc() -{ - register int n; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = ibuf[n] ^ UCHAR(msgbuf, n); - WRITE(&CHAR(ivec, 8-nbytes), nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the Cipher Block Chaining mode of DES - */ -cfbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = ibuf[c]; - obuf[c] = ibuf[c] ^ UCHAR(msgbuf, c); - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = obuf[nbytes-1]; - if (n < 0 || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This encrypts using the alternative Cipher FeedBack mode of DES - */ -cfbaenc() -{ - register int n; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 7; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = (ibuf[n] ^ UCHAR(msgbuf, n)) - |0200; - for (n = 0; n < nbytes; n++) - obuf[n] = CHAR(ivec, 8-nbytes+n)&0177; - WRITE(obuf, nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = ('0' + n)|0200; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the alternative Cipher Block Chaining mode of DES - */ -cfbadec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 7; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = ibuf[c]|0200; - obuf[c] = (ibuf[c] ^ UCHAR(msgbuf, c))&0177; - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - if ((n = (obuf[nbytes-1] - '0')) < 0 - || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - - -/* - * This encrypts using the Output FeedBack mode of DES - */ -ofbenc() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) { - UCHAR(ivec, 8-nbytes+n) = UCHAR(msgbuf, n); - obuf[n] = ibuf[n] ^ UCHAR(msgbuf, n); - } - WRITE(obuf, nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < nbytes; c++) - ibuf[c] ^= UCHAR(msgbuf, c); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the Output Block Chaining mode of DES - */ -ofbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = UCHAR(msgbuf, c); - obuf[c] = ibuf[c] ^ UCHAR(msgbuf, c); - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = obuf[nbytes-1]; - if (n < 0 || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - /* - * dump it - */ - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This authenticates using the Cipher FeedBack mode of DES - */ -cfbauth() -{ - register int n, j; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - char ibuf[8]; /* input buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - while ((n = READ(ibuf, nbytes)) == nbytes) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = ibuf[n] ^ UCHAR(msgbuf, n); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = '0' + n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - /* - * drop the bits - * we write chars until fewer than 7 bits, - * and then pad the last one with 0 bits - */ - for (n = 0; macbits > 7; n++, macbits -= 8) - (void)putchar(CHAR(msgbuf, n)); - if (macbits > 0) { - CHAR(msgbuf, 0) = 0x00; - for (j = 0; j < macbits; j++) - CHAR(msgbuf, 0) |= (CHAR(msgbuf, n)&bits[j]); - (void)putchar(CHAR(msgbuf, 0)); - } -} - -#ifndef FASTWAY -/* - * change from 8 bits/Uchar to 1 bit/Uchar - */ -expand(from, to) - Desbuf from; /* 8bit/unsigned char string */ - char *to; /* 1bit/char string */ -{ - register int i, j; /* counters in for loop */ - - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - *to++ = (CHAR(from, i)>>(7-j))&01; -} - -/* - * change from 1 bit/char to 8 bits/Uchar - */ -compress(from, to) - char *from; /* 1bit/char string */ - Desbuf to; /* 8bit/unsigned char string */ -{ - register int i, j; /* counters in for loop */ - - for (i = 0; i < 8; i++) { - CHAR(to, i) = 0; - for (j = 0; j < 8; j++) - CHAR(to, i) = ((*from++)<<(7-j))|CHAR(to, i); - } -} -#endif - -/* - * message about usage - */ -usage() -{ - (void)fprintf(stderr, "%s\n", -"usage: bdes [-abdp] [-F bit] [-f bit] [-k key] [-m bit] [-o bit] [-v vector]"); - exit(1); -} diff --git a/usr.bin/bdes/bdes.ps b/usr.bin/bdes/bdes.ps deleted file mode 100644 index 471c267af751..000000000000 --- a/usr.bin/bdes/bdes.ps +++ /dev/null @@ -1,2945 +0,0 @@ -%! -%%BoundingBox: (atend) -%%Pages: (atend) -%%DocumentFonts: (atend) -%%EndComments -% -% FrameMaker PostScript Prolog 2.0, for use with FrameMaker 2.0 -% Copyright (c) 1986,87,89 by Frame Technology, Inc. All rights reserved. -% -% Known Problems: -% Due to bugs in Transcript, the 'PS-Adobe-' is omitted from line 1 -/FMversion (2.0) def -% Set up Color vs. Black-and-White - /FMPrintInColor systemdict /colorimage known def -% Uncomment this line to force b&w on color printer -% /FMPrintInColor false def -/FrameDict 190 dict def -systemdict /errordict known not {/errordict 10 dict def - errordict /rangecheck {stop} put} if -% The readline in 23.0 doesn't recognize cr's as nl's on AppleTalk -FrameDict /tmprangecheck errordict /rangecheck get put -errordict /rangecheck {FrameDict /bug true put} put -FrameDict /bug false put -mark -% Some PS machines read past the CR, so keep the following 3 lines together! -currentfile 5 string readline -00 -0000000000 -cleartomark -errordict /rangecheck FrameDict /tmprangecheck get put -FrameDict /bug get { - /readline { - /gstring exch def - /gfile exch def - /gindex 0 def - { - gfile read pop - dup 10 eq {exit} if - dup 13 eq {exit} if - gstring exch gindex exch put - /gindex gindex 1 add def - } loop - pop - gstring 0 gindex getinterval true - } def - } if -/FMVERSION { - FMversion ne { - /Times-Roman findfont 18 scalefont setfont - 100 100 moveto - (FrameMaker version does not match postscript_prolog!) - dup = - show showpage - } if - } def -/FMLOCAL { - FrameDict begin - 0 def - end - } def - /gstring FMLOCAL - /gfile FMLOCAL - /gindex FMLOCAL - /orgxfer FMLOCAL - /orgproc FMLOCAL - /organgle FMLOCAL - /orgfreq FMLOCAL - /yscale FMLOCAL - /xscale FMLOCAL - /manualfeed FMLOCAL - /paperheight FMLOCAL - /paperwidth FMLOCAL -/FMDOCUMENT { - array /FMfonts exch def - /#copies exch def - FrameDict begin - 0 ne dup {setmanualfeed} if - /manualfeed exch def - /paperheight exch def - /paperwidth exch def - setpapername - manualfeed {true} {papersize} ifelse - {manualpapersize} {false} ifelse - {desperatepapersize} if - /yscale exch def - /xscale exch def - currenttransfer cvlit /orgxfer exch def - currentscreen cvlit /orgproc exch def - /organgle exch def /orgfreq exch def - end - } def - /pagesave FMLOCAL - /orgmatrix FMLOCAL - /landscape FMLOCAL -/FMBEGINPAGE { - FrameDict begin - /pagesave save def - 3.86 setmiterlimit - /landscape exch 0 ne def - landscape { - 90 rotate 0 exch neg translate pop - } - {pop pop} - ifelse - xscale yscale scale - /orgmatrix matrix def - gsave - } def -/FMENDPAGE { - grestore - pagesave restore - end - showpage - } def -/FMDEFINEFONT { - FrameDict begin - findfont - ReEncode - 2 index exch - definefont exch - scalefont - FMfonts 3 1 roll - put - end - } bind def -/FMNORMALIZEGRAPHICS { - newpath - 0.0 0.0 moveto - 1 setlinewidth - 0 setlinecap - 0 0 0 sethsbcolor - 0 setgray - } bind def - /fx FMLOCAL - /fy FMLOCAL - /fh FMLOCAL - /fw FMLOCAL - /llx FMLOCAL - /lly FMLOCAL - /urx FMLOCAL - /ury FMLOCAL -/FMBEGINEPSF { - end - /FMEPSF save def - /showpage {} def - FMNORMALIZEGRAPHICS - [/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall - fx fy translate - rotate - fw urx llx sub div fh ury lly sub div scale - llx neg lly neg translate - } bind def -/FMENDEPSF { - FMEPSF restore - FrameDict begin - } bind def -FrameDict begin -/setmanualfeed { -%%BeginFeature *ManualFeed True - statusdict /manualfeed true put -%%EndFeature - } def -/max {2 copy lt {exch} if pop} bind def -/min {2 copy gt {exch} if pop} bind def -/inch {72 mul} def -/pagedimen { - paperheight sub abs 16 lt exch - paperwidth sub abs 16 lt and - {/papername exch def} {pop} ifelse - } def - /papersizedict FMLOCAL -/setpapername { - /papersizedict 14 dict def - papersizedict begin - /papername /unknown def - /Letter 8.5 inch 11.0 inch pagedimen - /LetterSmall 7.68 inch 10.16 inch pagedimen - /Tabloid 11.0 inch 17.0 inch pagedimen - /Ledger 17.0 inch 11.0 inch pagedimen - /Legal 8.5 inch 14.0 inch pagedimen - /Statement 5.5 inch 8.5 inch pagedimen - /Executive 7.5 inch 10.0 inch pagedimen - /A3 11.69 inch 16.5 inch pagedimen - /A4 8.26 inch 11.69 inch pagedimen - /A4Small 7.47 inch 10.85 inch pagedimen - /B4 10.125 inch 14.33 inch pagedimen - /B5 7.16 inch 10.125 inch pagedimen - end - } def -/papersize { - papersizedict begin - /Letter {lettertray} def - /LetterSmall {lettertray lettersmall} def - /Tabloid {11x17tray} def - /Ledger {ledgertray} def - /Legal {legaltray} def - /Statement {statementtray} def - /Executive {executivetray} def - /A3 {a3tray} def - /A4 {a4tray} def - /A4Small {a4tray a4small} def - /B4 {b4tray} def - /B5 {b5tray} def - /unknown {unknown} def - papersizedict dup papername known {papername} {/unknown} ifelse get - end - /FMdicttop countdictstack 1 add def - statusdict begin stopped end - countdictstack -1 FMdicttop {pop end} for - } def -/manualpapersize { - papersizedict begin - /Letter {letter} def - /LetterSmall {lettersmall} def - /Tabloid {11x17} def - /Ledger {ledger} def - /Legal {legal} def - /Statement {statement} def - /Executive {executive} def - /A3 {a3} def - /A4 {a4} def - /A4Small {a4small} def - /B4 {b4} def - /B5 {b5} def - /unknown {unknown} def - papersizedict dup papername known {papername} {/unknown} ifelse get - end - stopped - } def -/desperatepapersize { - statusdict /setpageparams known - { - paperwidth paperheight 0 1 - statusdict begin - {setpageparams} stopped pop - end - } if - } def -/savematrix { - orgmatrix currentmatrix pop - } bind def -/restorematrix { - orgmatrix setmatrix - } bind def -/dmatrix matrix def -/dpi 72 0 dmatrix defaultmatrix dtransform - dup mul exch dup mul add sqrt def -/freq dpi 18.75 div 8 div round dup 0 eq {pop 1} if 8 mul dpi exch div def -/sangle 1 0 dmatrix defaultmatrix dtransform exch atan def -/DiacriticEncoding [ -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl -/numbersign /dollar /percent /ampersand /quotesingle /parenleft -/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one -/two /three /four /five /six /seven /eight /nine /colon /semicolon -/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K -/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash -/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h -/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar -/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute -/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis -/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis -/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve -/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex -/udieresis /dagger /.notdef /cent /sterling /section /bullet -/paragraph /germandbls /registered /copyright /trademark /acute -/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef -/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown -/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef -/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde -/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright -/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis -/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl -/periodcentered /quotesinglbase /quotedblbase /perthousand -/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute -/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve -/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron -/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron -] def -/ReEncode { - dup - length - dict begin - { - 1 index /FID ne - {def} - {pop pop} ifelse - } forall - Encoding StandardEncoding eq - { - /Encoding DiacriticEncoding def - }if - currentdict - end - } bind def -/graymode true def - /bwidth FMLOCAL - /bpside FMLOCAL - /bstring FMLOCAL - /onbits FMLOCAL - /offbits FMLOCAL - /xindex FMLOCAL - /yindex FMLOCAL - /x FMLOCAL - /y FMLOCAL -/setpattern { - /bwidth exch def - /bpside exch def - /bstring exch def - /onbits 0 def /offbits 0 def - freq sangle landscape {90 add} if - {/y exch def - /x exch def - /xindex x 1 add 2 div bpside mul cvi def - /yindex y 1 add 2 div bpside mul cvi def - bstring yindex bwidth mul xindex 8 idiv add get - 1 7 xindex 8 mod sub bitshift and 0 ne - {/onbits onbits 1 add def 1} - {/offbits offbits 1 add def 0} - ifelse - } - setscreen - {} settransfer - offbits offbits onbits add div FMsetgray - /graymode false def - } bind def -/grayness { - FMsetgray - graymode not { - /graymode true def - orgxfer cvx settransfer - orgfreq organgle orgproc cvx setscreen - } if - } bind def - /HUE FMLOCAL - /SAT FMLOCAL - /BRIGHT FMLOCAL - /Colors FMLOCAL -FMPrintInColor - - { - /HUE 0 def - /SAT 0 def - /BRIGHT 0 def - % array of arrays Hue and Sat values for the separations [HUE BRIGHT] - /Colors - [[0 0 ] % black - [0 0 ] % white - [0.00 1.0] % red - [0.37 1.0] % green - [0.60 1.0] % blue - [0.50 1.0] % cyan - [0.83 1.0] % magenta - [0.16 1.0] % comment / yellow - ] def - - /BEGINBITMAPCOLOR { - BITMAPCOLOR} def - /BEGINBITMAPCOLORc { - BITMAPCOLORc} def - /K { - Colors exch get dup - 0 get /HUE exch store - 1 get /BRIGHT exch store - HUE 0 eq BRIGHT 0 eq and - {1.0 SAT sub setgray} - {HUE SAT BRIGHT sethsbcolor} - ifelse - } def - /FMsetgray { - /SAT exch 1.0 exch sub store - HUE 0 eq BRIGHT 0 eq and - {1.0 SAT sub setgray} - {HUE SAT BRIGHT sethsbcolor} - ifelse - } bind def - } - - { - /BEGINBITMAPCOLOR { - BITMAPGRAY} def - /BEGINBITMAPCOLORc { - BITMAPGRAYc} def - /FMsetgray {setgray} bind def - /K { - pop - } def - } -ifelse -/normalize { - transform round exch round exch itransform - } bind def -/dnormalize { - dtransform round exch round exch idtransform - } bind def -/lnormalize { - 0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop - } bind def -/H { - lnormalize setlinewidth - } bind def -/Z { - setlinecap - } bind def -/X { - fillprocs exch get exec - } bind def -/V { - gsave eofill grestore - } bind def -/N { - stroke - } bind def -/M {newpath moveto} bind def -/E {lineto} bind def -/D {curveto} bind def -/O {closepath} bind def - /n FMLOCAL -/L { - /n exch def - newpath - normalize - moveto - 2 1 n {pop normalize lineto} for - } bind def -/Y { - L - closepath - } bind def - /x1 FMLOCAL - /x2 FMLOCAL - /y1 FMLOCAL - /y2 FMLOCAL - /rad FMLOCAL -/R { - /y2 exch def - /x2 exch def - /y1 exch def - /x1 exch def - x1 y1 - x2 y1 - x2 y2 - x1 y2 - 4 Y - } bind def -/RR { - /rad exch def - normalize - /y2 exch def - /x2 exch def - normalize - /y1 exch def - /x1 exch def - newpath - x1 y1 rad add moveto - x1 y2 x2 y2 rad arcto - x2 y2 x2 y1 rad arcto - x2 y1 x1 y1 rad arcto - x1 y1 x1 y2 rad arcto - closepath - 16 {pop} repeat - } bind def -/C { - grestore - gsave - R - clip - } bind def -/U { - grestore - gsave - } bind def -/F { - FMfonts exch get - setfont - } bind def -/T { - moveto show - } bind def -/RF { - rotate - 0 ne {-1 1 scale} if - } bind def -/TF { - gsave - moveto - RF - show - grestore - } bind def -/P { - moveto - 0 32 3 2 roll widthshow - } bind def -/PF { - gsave - moveto - RF - 0 32 3 2 roll widthshow - grestore - } bind def -/S { - moveto - 0 exch ashow - } bind def -/SF { - gsave - moveto - RF - 0 exch ashow - grestore - } bind def -/B { - moveto - 0 32 4 2 roll 0 exch awidthshow - } bind def -/BF { - gsave - moveto - RF - 0 32 4 2 roll 0 exch awidthshow - grestore - } bind def - /x FMLOCAL - /y FMLOCAL - /dx FMLOCAL - /dy FMLOCAL - /dl FMLOCAL - /t FMLOCAL - /t2 FMLOCAL - /Cos FMLOCAL - /Sin FMLOCAL - /r FMLOCAL -/W { - dnormalize - /dy exch def - /dx exch def - normalize - /y exch def - /x exch def - /dl dx dx mul dy dy mul add sqrt def - dl 0.0 gt { - /t currentlinewidth def - savematrix - /Cos dx dl div def - /Sin dy dl div def - /r [Cos Sin Sin neg Cos 0.0 0.0] def - /t2 t 2.5 mul 3.5 max def - newpath - x y translate - r concat - 0.0 0.0 moveto - dl t 2.7 mul sub 0.0 rlineto - stroke - restorematrix - x dx add y dy add translate - r concat - t 0.67 mul setlinewidth - t 1.61 mul neg 0.0 translate - 0.0 0.0 moveto - t2 1.7 mul neg t2 2.0 div moveto - 0.0 0.0 lineto - t2 1.7 mul neg t2 2.0 div neg lineto - stroke - t setlinewidth - restorematrix - } if - } bind def -/G { - gsave - newpath - normalize translate 0.0 0.0 moveto - dnormalize scale - 0.0 0.0 1.0 5 3 roll arc - closepath fill - grestore - } bind def -/A { - gsave - savematrix - newpath - 2 index 2 div add exch 3 index 2 div sub exch - normalize 2 index 2 div sub exch 3 index 2 div add exch - translate - scale - 0.0 0.0 1.0 5 3 roll arc - restorematrix - stroke - grestore - } bind def - /x FMLOCAL - /y FMLOCAL - /w FMLOCAL - /h FMLOCAL - /xx FMLOCAL - /yy FMLOCAL - /ww FMLOCAL - /hh FMLOCAL - /FMsaveobject FMLOCAL - /FMoptop FMLOCAL - /FMdicttop FMLOCAL -/BEGINPRINTCODE { - /FMdicttop countdictstack 1 add def - /FMoptop count 4 sub def - /FMsaveobject save def - userdict begin - /showpage {} def - FMNORMALIZEGRAPHICS - 3 index neg 3 index neg translate - } bind def -/ENDPRINTCODE { - count -1 FMoptop {pop pop} for - countdictstack -1 FMdicttop {pop end} for - FMsaveobject restore - } bind def -/gn { - 0 - { 46 mul - cf read pop - 32 sub - dup 46 lt {exit} if - 46 sub add - } loop - add - } bind def - /str FMLOCAL -/cfs { - /str sl string def - 0 1 sl 1 sub {str exch val put} for - str def - } bind def -/ic [ - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223 - 0 - {0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx} - {10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx} - {19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} - {13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh} - {4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh} - {13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl} - {7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl} - {0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl} - {10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl} - ] def - /sl FMLOCAL - /val FMLOCAL - /ws FMLOCAL - /im FMLOCAL - /bs FMLOCAL - /cs FMLOCAL - /len FMLOCAL - /pos FMLOCAL -/ms { - /sl exch def - /val 255 def - /ws cfs - /im cfs - /val 0 def - /bs cfs - /cs cfs - } bind def -400 ms -/ip { - is - 0 - cf cs readline pop - { ic exch get exec - add - } forall - pop - - } bind def -/wh { - /len exch def - /pos exch def - ws 0 len getinterval im pos len getinterval copy pop - pos len - } bind def -/bl { - /len exch def - /pos exch def - bs 0 len getinterval im pos len getinterval copy pop - pos len - } bind def -/s1 1 string def -/fl { - /len exch def - /pos exch def - /val cf s1 readhexstring pop 0 get def - pos 1 pos len add 1 sub {im exch val put} for - pos len - } bind def -/hx { - 3 copy getinterval - cf exch readhexstring pop pop - } bind def - /h FMLOCAL - /w FMLOCAL - /d FMLOCAL - /lb FMLOCAL - /bitmapsave FMLOCAL - /is FMLOCAL - /cf FMLOCAL -/wbytes { - dup - 8 eq {pop} {1 eq {7 add 8 idiv} {3 add 4 idiv} ifelse} ifelse - } bind def -/BEGINBITMAPBWc { - 1 {} COMMONBITMAPc - } bind def -/BEGINBITMAPGRAYc { - 8 {} COMMONBITMAPc - } bind def -/BEGINBITMAP2BITc { - 2 {} COMMONBITMAPc - } bind def -/COMMONBITMAPc { - /r exch def - /d exch def - gsave - translate rotate scale /h exch def /w exch def - /lb w d wbytes def - sl lb lt {lb ms} if - /bitmapsave save def - r - /is im 0 lb getinterval def - ws 0 lb getinterval is copy pop - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {ip} image - bitmapsave restore - grestore - } bind def -/BEGINBITMAPBW { - 1 {} COMMONBITMAP - } bind def -/BEGINBITMAPGRAY { - 8 {} COMMONBITMAP - } bind def -/BEGINBITMAP2BIT { - 2 {} COMMONBITMAP - } bind def -/COMMONBITMAP { - /r exch def - /d exch def - gsave - translate rotate scale /h exch def /w exch def - /bitmapsave save def - r - /is w d wbytes string def - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {cf is readhexstring pop} image - bitmapsave restore - grestore - } bind def - /proc1 FMLOCAL - /proc2 FMLOCAL - /newproc FMLOCAL -/Fmcc { - /proc2 exch cvlit def - /proc1 exch cvlit def - /newproc proc1 length proc2 length add array def - newproc 0 proc1 putinterval - newproc proc1 length proc2 putinterval - newproc cvx -} bind def -/ngrayt 256 array def -/nredt 256 array def -/nbluet 256 array def -/ngreent 256 array def - /gryt FMLOCAL - /blut FMLOCAL - /grnt FMLOCAL - /redt FMLOCAL - /indx FMLOCAL - /cynu FMLOCAL - /magu FMLOCAL - /yelu FMLOCAL - /k FMLOCAL - /u FMLOCAL -/colorsetup { - currentcolortransfer - /gryt exch def - /blut exch def - /grnt exch def - /redt exch def - 0 1 255 { - /indx exch def - /cynu 1 red indx get 255 div sub def - /magu 1 green indx get 255 div sub def - /yelu 1 blue indx get 255 div sub def - /k cynu magu min yelu min def - /u k currentundercolorremoval exec def - nredt indx 1 0 cynu u sub max sub redt exec put - ngreent indx 1 0 magu u sub max sub grnt exec put - nbluet indx 1 0 yelu u sub max sub blut exec put - ngrayt indx 1 k currentblackgeneration exec sub gryt exec put - } for - {255 mul cvi nredt exch get} - {255 mul cvi ngreent exch get} - {255 mul cvi nbluet exch get} - {255 mul cvi ngrayt exch get} - setcolortransfer - {pop 0} setundercolorremoval - {} setblackgeneration - } bind def - /tran FMLOCAL -/fakecolorsetup { - /tran 256 string def - 0 1 255 {/indx exch def - tran indx - red indx get 77 mul - green indx get 151 mul - blue indx get 28 mul - add add 256 idiv put} for - currenttransfer - {255 mul cvi tran exch get 255.0 div} - exch Fmcc settransfer -} bind def -/BITMAPCOLOR { - /d 8 def - gsave - translate rotate scale /h exch def /w exch def - /bitmapsave save def - colorsetup - /is w d wbytes string def - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {cf is readhexstring pop} {is} {is} true 3 colorimage - bitmapsave restore - grestore - } bind def -/BITMAPCOLORc { - /d 8 def - gsave - translate rotate scale /h exch def /w exch def - /lb w d wbytes def - sl lb lt {lb ms} if - /bitmapsave save def - colorsetup - /is im 0 lb getinterval def - ws 0 lb getinterval is copy pop - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {ip} {is} {is} true 3 colorimage - bitmapsave restore - grestore - } bind def -/BITMAPGRAY { - 8 {fakecolorsetup} COMMONBITMAP - } bind def -/BITMAPGRAYc { - 8 {fakecolorsetup} COMMONBITMAPc - } bind def -/ENDBITMAP { - } bind def -end -%%EndProlog -%%BeginSetup -(2.0) FMVERSION -1 1 612 792 0 1 16 FMDOCUMENT -/fillprocs 32 array def -fillprocs 0 { 0.000000 grayness } put -fillprocs 1 { 0.100000 grayness } put -fillprocs 2 { 0.300000 grayness } put -fillprocs 3 { 0.500000 grayness } put -fillprocs 4 { 0.700000 grayness } put -fillprocs 5 { 0.900000 grayness } put -fillprocs 6 { 0.970000 grayness } put -fillprocs 7 { 1.000000 grayness } put -fillprocs 8 {<0f87c3e1f0783c1e> 8 1 setpattern } put -fillprocs 9 {<0f1e3c78f0e1c387> 8 1 setpattern } put -fillprocs 10 { 8 1 setpattern } put -fillprocs 11 { 8 1 setpattern } put -fillprocs 12 {<8142241818244281> 8 1 setpattern } put -fillprocs 13 {<8040201008040201> 8 1 setpattern } put -fillprocs 14 {<03060c183060c081> 8 1 setpattern } put -fillprocs 15 {} put -fillprocs 16 { 1.000000 grayness } put -fillprocs 17 { 0.900000 grayness } put -fillprocs 18 { 0.700000 grayness } put -fillprocs 19 { 0.500000 grayness } put -fillprocs 20 { 0.300000 grayness } put -fillprocs 21 { 0.100000 grayness } put -fillprocs 22 { 0.030000 grayness } put -fillprocs 23 { 0.000000 grayness } put -fillprocs 24 { 8 1 setpattern } put -fillprocs 25 { 8 1 setpattern } put -fillprocs 26 {<3333333333333333> 8 1 setpattern } put -fillprocs 27 {<0000ffff0000ffff> 8 1 setpattern } put -fillprocs 28 {<7ebddbe7e7dbbd7e> 8 1 setpattern } put -fillprocs 29 {<7fbfdfeff7fbfdfe> 8 1 setpattern } put -fillprocs 30 { 8 1 setpattern } put -fillprocs 31 {} put -%%EndSetup -0 12 /Helvetica-Bold FMDEFINEFONT -1 12 /Helvetica-BoldOblique FMDEFINEFONT -%%Page: "-1" 1 -%%BeginPaperSize: Letter -%%EndPaperSize -612 792 0 FMBEGINPAGE -144 144 468 396 R -7 X -0 K -V -0 F -0 X -1.2 (IMPLEMENT) 178.34 388 S -1.2 (A) 258.88 388 S -1.2 (TION NOTES ON ) 267.85 388 S -1 F -1.2 (bdes) 382.61 388 S -0 F -1.2 (\0501\051) 415.4 388 S -1.2 (Matt Bishop) 265.09 338 S -1.2 (T) 197.74 288 S -1.2 (echnical Report PCS-TR91-158) 205.38 288 S -FMENDPAGE -%%EndPage: "-1" 2 -%%Page: "0" 2 -612 792 0 FMBEGINPAGE -72 72 540 720 R -7 X -0 K -V -FMENDPAGE -%%EndPage: "0" 3 -0 12 /Times-Roman FMDEFINEFONT -1 18 /Times-Bold FMDEFINEFONT -2 18 /Times-BoldItalic FMDEFINEFONT -3 12 /Times-Italic FMDEFINEFONT -4 12 /Times-Bold FMDEFINEFONT -5 10 /Times-Roman FMDEFINEFONT -6 12 /Courier FMDEFINEFONT -7 12 /Courier-Oblique FMDEFINEFONT -8 12 /ZapfDingbats FMDEFINEFONT -9 12 /Symbol FMDEFINEFONT -10 12 /Courier-Bold FMDEFINEFONT -%%Page: "1" 3 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 1 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -1 F -0 X -(Implementation Notes on ) 179.84 708 T -2 F -(bdes) 378.21 708 T -1 F -(\0501\051) 411.19 708 T -0 F -( ) 432.17 708 T -3 F -(Matt Bishop) 276.51 676 T -0 F -(Department of Mathematics and Computer Science) 182.92 656 T -(Dartmouth College) 259.86 642 T -(Hanover) 257.45 628 T -(, NH 03755) 298.26 628 T -3 F -(ABSTRACT) 277.68 602 T -0 F -0.27 (This note describes the implementation of ) 108 582 P -3 F -0.27 (bdes) 314.13 582 P -0 F -0.27 (, the \336le encryption program being) 336.12 582 P -0.36 (distributed in the 4.4 release of the Berkeley Software Distribution. It implements) 108 568 P -(all modes of the Data Encryption Standard program.) 108 554 T -4 F -(1. Intr) 72 528 T -(oduction) 104.43 528 T -0 F --0.09 (The Data Encryption Standard is a standard endorsed by the federal government. It is con-) 108 504 P --0.56 (siderably stronger than the algorithm used by the ) 72 484 P -5 F --0.47 (UNIX) 305.36 484 P -0 F --0.56 (\252 ) 330.34 484 P -3 F --0.56 (crypt) 344.53 484 P -0 F --0.56 (\0501\051 program, and therefore is a more) 369.18 484 P -0.11 (suitable candidate for protecting information, especially information contained in ) 72 464 P -5 F -0.09 (ASCII) 466.05 464 P -0 F -0.11 ( \336les. The) 492.14 464 P --0.65 (program ) 72 444 P -3 F --0.65 (bdes) 114.99 444 P -0 F --0.65 (\0501\051 implements the DES and all of its modes, including the two authentication modes.) 136.97 444 P --0.59 (Because others may wish to write software compatible with this program, this note presents) 108 420 P --0.04 (the layout of the encrypted \336les produced by ) 72 400 P -3 F --0.04 (bdes) 288.86 400 P -0 F --0.04 ( as well as internal details relevant to the imple-) 310.85 400 P --0.15 (mentation. Whereever possible and appropriate, the description of the ) 72 380 P -3 F --0.15 (des) 408.04 380 P -0 F --0.15 (\0501\051 program given in [4]) 424.03 380 P --0.2 (has been followed; thus, ) 72 360 P -3 F --0.2 (bdes) 190.77 360 P -0 F --0.2 ( is completely compatible with that program. However) 212.75 360 P --0.2 (, ) 473.33 360 P -3 F --0.2 (bdes) 479.12 360 P -0 F --0.2 ( also of-) 501.11 360 P -(fers several extensions to ) 72 340 T -3 F -(des) 195.9 340 T -0 F -( that are not compatible, and these will be explicitly pointed out.) 211.89 340 T --0.14 (In this note, strings typed as shown will be in ) 108 316 P -6 F --0.34 (Courier Roman font) 326.78 316 P -0 F --0.14 (, and strings to be) 455.62 316 P --0.42 (chosen by the user will be in ) 72 296 P -7 F --1 (Courier Oblique font) 209.32 296 P -0 F --0.42 (. The space character \050) 351.24 296 P -5 F --0.35 (ASCII) 457.79 296 P -0 F --0.42 ( <) 483.88 296 P -5 F --0.35 (SP) 493.23 296 P -0 F --0.42 (>, octal) 504.34 296 P --0.43 (40, decimal 32, hex 20\051 will be represented as \322) 72 276 P -8 F --0.47 (z) 296.98 276 P -0 F --0.43 (\323 and the newline character \050) 301.96 276 P -5 F --0.35 (ASCII) 438.03 276 P -0 F --0.43 ( <) 464.13 276 P -5 F --0.35 (NL) 473.46 276 P -0 F --0.43 (>, octal 12,) 486.79 276 P --0.05 (decimal 10, hex a\051 as \322) 72 256 P -9 F --0.05 (\277) 181.65 256 P -0 F --0.05 (\323. Because it is often more convenient to represent arbitrary characters as) 189.54 256 P -1.13 (a sequence of hexadecimal digits, that representation will often be used; these digits will be in) 72 236 P -10 F -(Courier Bold font) 72 216 T -0 F -( with spaces often inserted for readability) 194.33 216 T -(.) 392.07 216 T -4 F -(2. Overview and Use) 72 184 T -3 F --0.39 (Bdes) 108 160 P -0 F --0.39 ( implements the Data Encryption Standard algorithm in software, and enables the user) 131.32 160 P --0.61 (to encrypt data using any of the four modes of operation of the DES \050Electronic Code Book, Cipher) 72 140 P -72 72 540 720 C -72 72 540 117 C -72 72 549 108 R -7 X -0 K -V -5 F -0 X -(This work is based on work funded by grant NAG2-680 from the National -Aeronautics and Space Administration to ) 72 101.33 T -(Dartmouth College.) 72 89.33 T -(UNIX is a Registered T) 72 77.33 T -(rademark of A) 166.58 77.33 T -(T&T Bell Laboratories.) 223.75 77.33 T -72 72 540 720 C -0 0 612 792 C -72 126 225 126 2 L -7 X -0 K -V -0.5 H -2 Z -0 X -N -FMENDPAGE -%%EndPage: "1" 4 -%%Page: "2" 4 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 2 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.31 (Block Chaining, ) 72 712 P -3 F -0.31 (k) 154.25 712 P -0 F -0.31 (-bit Cipher Feed Back, and ) 159.58 712 P -3 F -0.31 (k) 293.71 712 P -0 F -0.31 (-bit Output Feed Back\051 as well as the Alternate ) 299.04 712 P -3 F -0.31 (k) 530.68 712 P -0 F -0.31 (-) 536.01 712 P --0.04 (bit Cipher Feed Back mode. Further) 72 692 P --0.04 (, ) 244.52 692 P -3 F --0.04 (bdes) 250.48 692 P -0 F --0.04 ( supports message authentication code generation based) 272.46 692 P -(on both the Cipher Block Chaining mode and the ) 72 672 T -3 F -(k) 310.86 672 T -0 F -(-bit Cipher Feed Back mode.) 316.19 672 T -0.07 (By default, ) 108 648 P -3 F -0.07 (bdes) 164.43 648 P -0 F -0.07 ( encrypts an input \336le using Cipher Block Chaining mode, and is invoked) 186.41 648 P --0.4 (as a \336lter) 72 628 P --0.4 (. The key may be speci\336ed either on the command line or may be typed to the prompt. So,) 114.51 628 P -(if the input \336le ) 72 608 T -7 F -(inputf) 145.96 608 T -(ile) 189.14 608 T -0 F -( contains the message) 210.73 608 T -6 F -(a) 253.9 584 T -8 F -(z) 261.1 584 T -6 F -(test) 266.07 584 T -8 F -(z) 294.86 584 T -6 F -(message) 299.83 584 T -9 F -(\277) 350.21 584 T -0 F -(then the following command encrypts it using the key ) 72 560 T -6 F -(abcdefgh) 333.5 560 T -0 F -(:) 391.07 560 T -6 F -(bdes -k abcdefgh < ) 158.48 536 T -7 F -(inputf) 295.21 536 T -(ile) 338.38 536 T -6 F -( > ) 359.97 536 T -7 F -(outputf) 381.56 536 T -(ile) 431.93 536 T -0 F -(The option ) 72 512 T -4 F -(-k) 127.3 512 T -0 F -( indicates the next ar) 137.96 512 T -(gument is the key) 237.01 512 T -(. Now ) 321.17 512 T -7 F -(outputf) 353.48 512 T -(ile) 403.86 512 T -0 F -( contains) 425.45 512 T -10 F -(16 0e eb af 68 a0 d0 19 f1 a2 9b 31 0d 8a 01 c3) 136.89 488 T -0 F -0.06 (Other modes are speci\336ed using command-line options, as is control of the way the key is) 108 464 P -(interpreted. The next sections contain several examples, and the Appendix has the manual page.) 72 444 T -4 F -(3. Keys and Parity) 72 412 T -0 F -0.58 (The key consists of 64 bits, and may be presented in any of hex, binary) 108 388 P -0.58 (, or as a string of) 456.48 388 P -5 F -0.12 (ASCII) 72 368 P -0 F -0.14 ( characters. If the key is given in hex or binary) 98.1 368 P -0.14 (, it is used as is with no changes. However) 322.21 368 P -0.14 (, if) 526.53 368 P --0.27 (the key is given in ) 72 348 P -5 F --0.23 (ASCII) 161.59 348 P -0 F --0.27 (, a delicate problem arises: by convention, the parity bit is usually set to 0.) 187.69 348 P --0.47 (This high-order bit is generally ignored by applications; but the DES -does not do so. Instead, it dis-) 72 328 P --0.14 (cards the low-order bit, ef) 72 308 P --0.14 (fectively reducing the size of the space of possible keys from 2) 195.44 308 P -5 F --0.12 (56) 495.97 312.8 P -0 F --0.14 ( to 2) 505.97 308 P -5 F --0.12 (48) 527.01 312.8 P -0 F --0.14 (.) 537 308 P --0.46 ( T) 108 284 P --0.46 (o preserve the size of the key space, the value of the parity bit must be related to the value) 117.03 284 P --0.09 (in the low-order bit, so the program sets the high-order bit to make each character in the key be of) 72 264 P --0.7 (odd parity) 72 244 P --0.7 (. \050Note that the initial value of the parity bit is ) 119.49 244 P -3 F --0.7 (not) 334.99 244 P -0 F --0.7 ( used in this computation.\051 For example,) 350.31 244 P -(if the key is ) 72 224 T -6 F -(abcdefgh) 131.29 224 T -0 F -(, the actual key bits used are determined as follows:) 188.86 224 T -5 F -(ASCII) 99 200 T -0 F -( key) 125.1 200 T -6 F -(a) 243 200 T -(b) 279 200 T -(c) 315 200 T -(d) 351 200 T -(e) 387 200 T -(f) 423 200 T -(g) 459 200 T -(h) 495 200 T -5 F -(ASCII) 99 180 T -0 F -( key bits \050hex\051) 125.1 180 T -10 F -(61) 243 180 T -(62) 279 180 T -(63) 315 180 T -(64) 351 180 T -(65) 387 180 T -(66) 423 180 T -(67) 459 180 T -(68) 495 180 T -0 F -(parity) 99 160 T -(odd) 243 160 T -(odd) 279 160 T -(even) 315 160 T -(odd) 351 160 T -(even) 387 160 T -(even) 423 160 T -(odd) 459 160 T -(odd) 495 160 T -(key bits used \050hex\051) 99 140 T -10 F -(61) 243 140 T -(62) 279 140 T -(e3) 315 140 T -(64) 351 140 T -(e5) 387 140 T -(e6) 423 140 T -(67) 459 140 T -(68) 495 140 T -0 F -0.18 (This convention \050as opposed to requiring even parity) 108 120 P -0.18 (, or simply copying the low-order bit) 362 120 P --0.41 (to the high-order bit\051 was chosen to provide compatibility with the encryption program ) 72 100 P -3 F --0.41 (des) 486.77 100 P -0 F --0.41 ( distrib-) 502.76 100 P --0.52 (uted by Sun Microsystems, Inc. [4]. Whether the key is entered on the command line or on the key-) 72 80 P -FMENDPAGE -%%EndPage: "2" 5 -%%Page: "3" 5 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 3 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -1.89 (board, by default it is processed into the same key schedule generated by Sun\325) 72 712 P -1.89 (s ) 471.02 712 P -3 F -1.89 (des) 480.58 712 P -0 F -1.89 (, so \336les) 496.56 712 P -(encrypted on a Sun can be decrypted using ) 72 692 T -3 F -(bdes) 280.51 692 T -0 F -( \050and vice versa\051.) 302.49 692 T --0.3 (If the user does not wish to use the Sun convention, the option \320) 108 668 P -4 F --0.3 (p) 411.9 668 P -0 F --0.3 ( will disable the parity bit) 418.57 668 P --0.62 (changing; with it, the parity bit is that of the character typed. This -is useful when the key is a known) 72 648 P -5 F -(ASCII) 72 628 T -0 F -( string and the \336le was encrypted on a system which does not alter parity bits.) 98.1 628 T --0.24 (A key may be represented as a bit vector) 108 604 P --0.24 (, rather than an ) 300.74 604 P -5 F --0.2 (ASCII) 374.7 604 P -0 F --0.24 ( string, in one of two ways. It) 400.8 604 P -0.19 (may be represented as a string of up to 16 hexadecimal digits; if fewer than 16 are given, the key) 72 584 P -0.16 (is right \336lled with 0 bits. Or) 72 564 P -0.16 (, it may be represented as a string of up to 64 binary digits, and again) 206.11 564 P -0.15 (if fewer than 64 are given, the key is right-\336lled with 0 bits. Bit -vector keys must be given on the) 72 544 P -0.51 (command line, and must begin with the characters ) 72 524 P -6 F -1.24 (0x) 320.28 524 P -0 F -0.51 ( or ) 334.67 524 P -6 F -1.24 (0X) 351.69 524 P -0 F -0.51 ( \050for hexadecimal\051 or ) 366.08 524 P -6 F -1.24 (0b) 472.71 524 P -0 F -0.51 ( or ) 487.1 524 P -6 F -1.24 (0B) 504.12 524 P -0 F -0.51 ( \050for) 518.51 524 P -(binary\051. For example, all of the following strings generate the same key schedule:) 72 504 T -5 F -(ASCII) 72 480 T -0 F -( key) 98.1 480 T -6 F -(abcdefgh) 180 480 T -0 F -(hexadecimal key) 72 460 T -6 F -(0x6162e364e5e66768) 180 460 T -0 F -(binary key) 72 440 T -6 F -(0b0110000101100010111000110110100011100101111000-) 180 440 T -(1100110011101101000) 180 420 T -0 F --0.14 ( Note that giving the key on the command line as ) 108 396 P -6 F --0.34 (0x6162636465666768) 345.27 396 P -0 F --0.14 ( will ) 474.8 396 P -3 F --0.14 (not) 499.17 396 P -0 F --0.14 ( reset) 514.5 396 P -0.25 (the parity bits, because it is interpreted as a sequence of hex digits, not ) 72 376 P -5 F -0.21 (ASCII) 416.58 376 P -0 F -0.25 ( characters. The dif-) 442.68 376 P -0.69 (ference in interpretation is that here the user can specify all bits of the key exactly) 72 356 P -0.69 (, whereas \050on) 474.34 356 P -0.25 (most terminals\051 it is not possible to control how the parity bit of ) 72 336 P -5 F -0.21 (ASCII) 384.76 336 P -0 F -0.25 ( characters is set. On some) 410.85 336 P -0.36 (systems, it is possible to use a \322Meta\323 key to set the parity bit for an ) 72 316 P -5 F -0.3 (ASCII) 407.23 316 P -0 F -0.36 ( character; should this) 433.33 316 P --0.3 (be the case and the user desire ) 72 296 P -3 F --0.3 (bdes) 218.09 296 P -0 F --0.3 ( not to reset the parity bit, the option ) 240.07 296 P -4 F --0.3 (\320p) 415.25 296 P -0 F --0.3 ( will force the parity bit) 427.92 296 P -(to be used as typed.) 72 276 T -4 F -(4. Encryption Output Repr) 72 244 T -(esentation) 211.05 244 T -0 F -0.01 (All modes of the DES output ciphertext in blocks; the size of the block is 64 bits \0508 bytes\051) 108 220 P --0.25 (for ECB and CBC modes, and ) 72 200 P -3 F --0.25 (k) 218.74 200 P -0 F --0.25 ( bits for the ) 224.07 200 P -3 F --0.25 (k) 281.02 200 P -0 F --0.25 (-bit CFB and OFB modes, and there are as many out-) 286.35 200 P --0.5 (put blocks as input blocks. However) 72 180 P --0.5 (, as the length of the input is usually not a multiple of the block) 243.55 180 P --0.35 (size, some padding is necessary; but as padding must be done by appending characters, these char-) 72 160 P -0.29 (acters must be distinguished from the input characters somehow) 72 140 P -0.29 (. The mechanism used is that the) 381.35 140 P -0.31 (last character of the \050decrypted\051 last block is the -\050integer\051 number of characters from the input in) 72 120 P -(the last block.) 72 100 T -FMENDPAGE -%%EndPage: "3" 6 -%%Page: "4" 6 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 4 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X --0.59 (For example, suppose ) 108 712 P -7 F --1.41 (inputf) 214.16 712 P --1.41 (ile) 257.34 712 P -0 F --0.59 ( contains \322) 278.93 712 P -6 F --1.41 (This) 329.04 712 P -8 F --0.65 (z) 357.83 712 P -6 F --1.41 (is) 362.8 712 P -8 F --0.65 (z) 377.2 712 P -6 F --1.41 (a) 382.17 712 P -8 F --0.65 (z) 389.37 712 P -6 F --1.41 (test) 394.35 712 P -9 F --0.59 (\277) 423.13 712 P -0 F --0.59 (\323, and it is encrypted in) 431.02 712 P -(CBC mode using the key \322) 72 692 T -6 F -(abcdef#@) 200.93 692 T -0 F -(\323 and the initialization vector ) 258.5 692 T -6 F -(0x0) 401.4 692 T -0 F -(; the command is) 422.99 692 T -6 F -(bdes -k abcdef#@ < ) 158.48 668 T -7 F -(inputf) 295.21 668 T -(ile) 338.38 668 T -6 F -( > ) 359.97 668 T -7 F -(outputf) 381.56 668 T -(ile) 431.93 668 T -0 F -(as CBC is the default encryption mode and ) 72 644 T -6 F -(0x0) 281.2 644 T -0 F -( the default initialization vector:) 302.79 644 T -(text) 72 620 T -6 F -(T) 117 620 T -(h) 144 620 T -(i) 171 620 T -(s) 198 620 T -8 F -(z) 225 620 T -6 F -(i) 252 620 T -(s) 279 620 T -8 F -(z) 306 620 T -6 F -(a) 333 620 T -8 F -(z) 360 620 T -6 F -(t) 387 620 T -(e) 414 620 T -(s) 441 620 T -(t) 468 620 T -9 F -(\277) 495 620 T -0 F -(hex) 72 600 T -10 F -(54) 117 600 T -(68) 144 600 T -(69) 171 600 T -(73) 198 600 T -(20) 225 600 T -(69) 252 600 T -(73) 279 600 T -(20) 306 600 T -(61) 333 600 T -(20) 360 600 T -(74) 387 600 T -(65) 414 600 T -(73) 441 600 T -(74) 468 600 T -(0a) 495 600 T -0 F -(input) 72 580 T -10 F -(54) 117 580 T -(68) 144 580 T -(69) 171 580 T -(73) 198 580 T -(20) 225 580 T -(69) 252 580 T -(73) 279 580 T -(20) 306 580 T -(61) 333 580 T -(20) 360 580 T -(74) 387 580 T -(65) 414 580 T -(73) 441 580 T -(74) 468 580 T -(0a) 495 580 T -(07) 522 580 T -0 F -(output) 72 560 T -10 F -(a5) 117 560 T -(5f) 144 560 T -(81) 171 560 T -(53) 198 560 T -(51) 225 560 T -(98) 252 560 T -(47) 279 560 T -(02) 306 560 T -(db) 333 560 T -(5a) 360 560 T -(c5) 387 560 T -(fe) 414 560 T -(50) 441 560 T -(3d) 468 560 T -(40) 495 560 T -(ce) 522 560 T -0 F -0.04 (Notice that the text is 15 characters long, so there are 7 bytes following the last full block.) 108 540 P -3 F -0.22 (Bdes) 72 520 P -0 F -0.22 ( pads this to a full block by appending one byte containing the ) 95.32 520 P -5 F -0.19 (ASCII) 399.67 520 P -0 F -0.22 ( character with numeric) 425.77 520 P -(value 7 \050the ) 72 500 T -5 F -(ASCII) 131.62 500 T -0 F -( character <) 157.71 500 T -5 F -(BEL) 214.42 500 T -0 F -(>\051. The result is then encrypted.) 233.3 500 T -0.44 (As another example, suppose ) 108 476 P -7 F -1.07 (inputf) 253.34 476 P -1.07 (ile) 296.52 476 P -0 F -0.44 ( contains \322) 318.11 476 P -6 F -1.07 (test) 370.29 476 P -0 F -0.44 (\323, and it is encrypted in ECB) 399.08 476 P -(mode using the key \322) 72 456 T -6 F -(abcdef#@) 173.93 456 T -0 F -(\323; the command is) 231.5 456 T -6 F -(bdes -b \320k abcdef#@ < ) 147.69 432 T -7 F -(inputf) 306 432 T -(ile) 349.18 432 T -6 F -( > ) 370.76 432 T -7 F -(outputf) 392.35 432 T -(ile) 442.73 432 T -0 F -(because the option ) 72 408 T -4 F -(\320b) 164.26 408 T -0 F -( signi\336es ECB mode:) 176.93 408 T -(text) 72 384 T -6 F -(t) 144 384 T -(e) 171 384 T -(s) 198 384 T -(t) 225 384 T -0 F -(hex) 72 364 T -10 F -(74) 144 364 T -(65) 171 364 T -(73) 198 364 T -(74) 225 364 T -0 F -(input) 72 344 T -10 F -(74) 144 344 T -(65) 171 344 T -(73) 198 344 T -(74) 225 344 T -(00) 252 344 T -(00) 279 344 T -(00) 306 344 T -(04) 333 344 T -0 F -(output) 72 324 T -10 F -(0d) 144 324 T -(8a) 171 324 T -(6e) 198 324 T -(57) 225 324 T -(9c) 252 324 T -(8f) 279 324 T -(27) 306 324 T -(5d) 333 324 T -0 F --0.31 (Finally) 108 304 P --0.31 (, if the length of the message is indeed a multiple of the block size, an extra block of) 141.21 304 P -0.83 (all 0 bits is added. Suppose ) 72 284 P -7 F -1.99 (inputf) 210.57 284 P -1.99 (ile) 253.74 284 P -0 F -0.83 ( contains \322) 275.33 284 P -6 F -1.99 (test) 328.28 284 P -9 F -0.83 (\277) 357.07 284 P -0 F -0.83 (\323, and it is encrypted in 40-bit CFB) 364.96 284 P -1.51 (mode using the key \322) 72 264 P -6 F -3.62 (abcdef#@) 179.96 264 P -0 F -1.51 (\323 and the initialization vector ) 237.53 264 P -6 F -3.62 (0x0123456789abcdef) 387.97 264 P -0 F -1.51 (; the) 517.5 264 P -(command is) 72 244 T -6 F --0.99 (bdes -f40 -v0x0123456789abcdef -kabcdef#@ < ) 72 220 P -7 F --0.99 (inputf) 383.67 220 P --0.99 (ile) 426.85 220 P -6 F --0.99 ( > ) 448.43 220 P -7 F --0.99 (outputf) 468.04 220 P --0.99 (ile) 518.41 220 P -0 F -0.16 (because the option ) 72 196 P -4 F -0.16 (\320f40 ) 164.75 196 P -0 F -0.16 (signi\336es 40-bit CFB mode, and ) 189.89 196 P -4 F -0.16 (-v0x01234566789abcdef) 343.96 196 P -0 F -0.16 ( sets the initial-) 465.89 196 P -(ization vector \050note that spaces between the option and its ar) 72 176 T -(gument are optional\051:) 361.57 176 T -(text) 72 152 T -6 F -(t) 144 152 T -(e) 171 152 T -(s) 198 152 T -(t) 225 152 T -9 F -(\277) 252 152 T -0 F -(hex) 72 132 T -10 F -(74) 144 132 T -(65) 171 132 T -(73) 198 132 T -(74) 225 132 T -(0a) 252 132 T -0 F -(input) 72 112 T -10 F -(74) 144 112 T -(65) 171 112 T -(73) 198 112 T -(74) 225 112 T -(0a) 252 112 T -(00) 279 112 T -(00) 306 112 T -(00) 333 112 T -(00) 360 112 T -(00) 387 112 T -0 F -(output) 72 92 T -10 F -(e2) 144 92 T -(c2) 171 92 T -(69) 198 92 T -(a4) 225 92 T -(5b) 252 92 T -(3c) 279 92 T -(3d) 306 92 T -(b3) 333 92 T -(f5) 360 92 T -(3c) 387 92 T -FMENDPAGE -%%EndPage: "4" 7 -1 12 /Times-BoldItalic FMDEFINEFONT -2 14 /Symbol FMDEFINEFONT -%%Page: "5" 7 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 5 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -(Note here the block size is 40 bits \0505 bytes\051, not 64 bits \0508 bytes\051.) 108 712 T --0.4 (This technique allows complete compatibility with Sun\325) 108 688 P --0.4 (s ) 374.11 688 P -3 F --0.4 (des) 381.37 688 P -0 F --0.4 ( program. In Sun\325) 397.36 688 P --0.4 (s implemen-) 480.77 688 P -0.02 (tation, padding is done with random bytes rather than bytes containing all zero bits. Cryptograph-) 72 668 P -0.85 (ically) 72 648 P -0.85 (, this makes no dif) 97.87 648 P -0.85 (ference, as the DES is a suf) 189.32 648 P -0.85 (\336ciently good random cipher to obscure the) 325.74 648 P -(input \050see for example [2], Chapter 6\051, and known plaintext attacks are very dif) 72 628 T -(\336cult [1].) 451.82 628 T -4 F -(5. Differ) 72 596 T -(ences Between the Standard CFB and OFB Modes and ) 114.41 596 T -1 F -(bdes) 397.26 596 T -0 F --0.11 (The UNIX operating system treats all \336les as streams of 8-bit bytes. In order to implement) 108 572 P --0.08 (the CFB and OFB modes properly) 72 552 P --0.08 (, it would be necessary to read ) 235.74 552 P -3 F --0.08 (k) 383.74 552 P -0 F --0.08 ( bits from the \336le, where ) 389.07 552 P -3 F --0.08 (k) 509.51 552 P -0 F --0.08 ( is an) 514.84 552 P -0.98 (integer between 1 and 64 inclusive. However) 72 532 P -0.98 (, this would require considerable buf) 294.22 532 P -0.98 (fering and be) 474.77 532 P -0.23 (quite inef) 72 512 P -0.23 (\336cient and prohibitively slow) 117.65 512 P -0.23 (. For these reasons, the current implementation of ) 258.48 512 P -3 F -0.23 (bdes) 501.48 512 P -0 F -0.23 ( re-) 523.46 512 P -0.47 (quires that ) 72 492 P -3 F -0.47 (k) 126.23 492 P -0 F -0.47 ( be a multiple of 8, so that an integral number of bytes will always be read from the) 131.56 492 P -(\336le. Other than this change, this mode is implemented as described in [3].) 72 472 T --0.58 (A similar observation holds for the alternate CFB mode described in [3]. Here, only the low) 108 448 P -0.23 (7 bits of each byte are signi\336cant, and hence the parameter ) 72 428 P -3 F -0.23 (k) 358.95 428 P -0 F -0.23 ( is an integer from 1 to 56 inclusive;) 364.28 428 P -(bdes requires k to be a multiple of 7. The high-order bit is retained for encryption and decryption,) 72 408 T -(but output \050whether from encryption or decryption\051 always has the high-order bit set to zero.) 72 388 T -4 F -(6. Message Authentication Code Modes) 72 356 T -0 F -0.57 (The Data Encryption Standard provides two modes of authentication, each providing be-) 108 332 P -1.27 (tween 1 and 64 bits of authentication data. In both cases an ) 72 312 P -3 F -1.27 (n) 373.32 312 P -0 F -1.27 (-bit message authentication code) 379.32 312 P -0.62 (\050MAC\051 is generated, where 1) 72 292 P -2 F -0.73 ( ) 214.71 292 P -9 F -0.62 (\243) 218.94 292 P -0 F -0.62 ( ) 225.52 292 P -3 F -0.62 (n) 229.15 292 P -0 F -0.62 ( ) 235.14 292 P -9 F -0.62 (\243) 238.76 292 P -0 F -0.62 ( 64. The \336rst is based on the CBC encryption mode, and the) 245.35 292 P -(second on CFB mode. Both work the same.) 72 272 T -0.13 (First, the \336le is padded to a multiple of the block size by appending enough zero bits. It is) 108 248 P --0.16 (then encrypted using the standard CBC \050or CFB\051 algorithm, but -all encrypted text is discarded ex-) 72 228 P --0.44 (cept for the last block. The ) 72 208 P -3 F --0.44 (n) 200.9 208 P -0 F --0.44 ( leading bits of the last block are used as the MAC. Note that the block) 206.9 208 P -(size constrains the number of bits available as the MAC.) 72 188 T -0.71 (The implementation allows the user to specify that the MAC is to be computed in either) 108 164 P --0.01 (CBC or CFB mode, and the user can specify any number of bits from 1 to 64 inclusive. However) 72 144 P --0.01 (,) 537 144 P --0.11 (because the UNIX operating system can only output bits in multiples of 8, if the number of bits of) 72 124 P --0.08 (MAC is not a multiple of 8, the MAC will be right-padded with the minimum number of zero bits) 72 104 P --0.31 (necessary to make the MAC length be a multiple of 8. However) 72 84 P --0.31 (, note that as the standard \050[3], Ap-) 374.6 84 P -FMENDPAGE -%%EndPage: "5" 8 -%%Page: "6" 8 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 6 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X --0.14 (pendix F\051 requires an incomplete \336nal block be right-padded with -zeroes, the technique of forcing) 72 712 P -(the last octet to contain the number of bytes in the message is ) 72 692 T -3 F -(not) 369.47 692 T -0 F -( used here.) 384.8 692 T --0.39 (For example, suppose ) 108 668 P -7 F --0.94 (inputf) 214.76 668 P --0.94 (ile) 257.93 668 P -0 F --0.39 ( contains \322) 279.52 668 P -6 F --0.94 (This) 330.04 668 P -8 F --0.43 (z) 358.82 668 P -6 F --0.94 (is) 363.8 668 P -8 F --0.43 (z) 378.19 668 P -6 F --0.94 (a) 383.17 668 P -8 F --0.43 (z) 390.36 668 P -6 F --0.94 (test) 395.34 668 P -9 F --0.39 (\277) 424.13 668 P -0 F --0.39 (\323, and a 64-bit MAC is) 432.02 668 P --0.73 (to be generated using CBC mode, the key \322) 72 648 P -6 F --1.74 (abcdef#@) 274.39 648 P -0 F --0.73 (\323 and the initialization vector ) 331.96 648 P -6 F --1.74 (0x0) 471.23 648 P -0 F --0.73 (; the com-) 492.82 648 P -(mand is) 72 628 T -6 F -(bdes -m 64 -k abcdef#@ < ) 136.89 604 T -7 F -(inputf) 316.79 604 T -(ile) 359.97 604 T -6 F -( > ) 381.56 604 T -7 F -(outputf) 403.15 604 T -(ile) 453.52 604 T -0 F -(as CBC is the default encryption mode and ) 72 580 T -6 F -(0x0) 281.2 580 T -0 F -( the default initialization vector:) 302.79 580 T -(text) 72 556 T -6 F -(T) 117 556 T -(h) 144 556 T -(i) 171 556 T -(s) 198 556 T -8 F -(z) 225 556 T -6 F -(i) 252 556 T -(s) 279 556 T -8 F -(z) 306 556 T -6 F -(a) 333 556 T -8 F -(z) 360 556 T -6 F -(t) 387 556 T -(e) 414 556 T -(s) 441 556 T -(t) 468 556 T -9 F -(\277) 495 556 T -0 F -(hex) 72 536 T -10 F -(54) 117 536 T -(68) 144 536 T -(69) 171 536 T -(73) 198 536 T -(20) 225 536 T -(69) 252 536 T -(73) 279 536 T -(20) 306 536 T -(61) 333 536 T -(20) 360 536 T -(74) 387 536 T -(65) 414 536 T -(73) 441 536 T -(74) 468 536 T -(0a) 495 536 T -0 F -(input) 72 516 T -10 F -(54) 117 516 T -(68) 144 516 T -(69) 171 516 T -(73) 198 516 T -(20) 225 516 T -(69) 252 516 T -(73) 279 516 T -(20) 306 516 T -(61) 333 516 T -(20) 360 516 T -(74) 387 516 T -(65) 414 516 T -(73) 441 516 T -(74) 468 516 T -(0a) 495 516 T -(00) 522 516 T -0 F -(output) 72 496 T -10 F -(43) 117 496 T -(18) 144 496 T -(de) 171 496 T -(74) 198 496 T -(24) 225 496 T -(a9) 252 496 T -(65) 279 496 T -(d1) 306 496 T -0 F -0.04 (Notice that the text is 15 characters long, so there are 7 bytes following the last full block.) 108 476 P -3 F -(Bdes) 72 456 T -0 F -( pads this to a full block by appending a zero-\336lled byte. The result is then encrypted and the) 95.32 456 T -(last block of output is used as the MAC.) 72 436 T -0.06 (As another example, suppose we used the same text, and wanted a 36-bit MAC to be gen-) 108 412 P -6.91 (erated using 40-bit CFB mode, the key \322) 72 392 P -6 F -16.58 (abcdef#@) 314.9 392 P -0 F -6.91 (\323 and the initialization vector) 372.47 392 P -6 F -(0x0123456789abcdef) 72 372 T -0 F -(; the command is) 201.53 372 T -6 F -(bdes -m 36 -f 40 -v 0x0123456789abcdef < ) 79.32 348 T -7 F -(inputf) 374.36 348 T -(ile) 417.54 348 T -6 F -( > ) 439.13 348 T -7 F -(outputf) 460.71 348 T -(ile) 511.09 348 T -0 F --0.19 (where ) 72 324 P -4 F --0.19 (\320m 36) 104.11 324 P -0 F --0.19 ( is the option to generate a 36-bit MAC, ) 134.91 324 P -4 F --0.19 (\320f 40) 327.79 324 P -0 F --0.19 ( indicates 40-bit CFB is to be used, and) 352.58 324 P -4 F --0.31 (\320v 0x123456789abcdef) 72 304 P -0 F --0.31 ( sets the initialization vector) 186.62 304 P --0.31 (. Note that, as the key is not given on the com-) 319.95 304 P -(mand line, the user will be prompted for it. It gives:) 72 284 T -(text) 72 260 T -6 F -(T) 117 260 T -(h) 144 260 T -(i) 171 260 T -(s) 198 260 T -8 F -(z) 225 260 T -6 F -(i) 252 260 T -(s) 279 260 T -8 F -(z) 306 260 T -6 F -(a) 333 260 T -8 F -(z) 360 260 T -6 F -(t) 387 260 T -(e) 414 260 T -(s) 441 260 T -(t) 468 260 T -9 F -(\277) 495 260 T -0 F -(hex) 72 240 T -10 F -(54) 117 240 T -(68) 144 240 T -(69) 171 240 T -(73) 198 240 T -(20) 225 240 T -(69) 252 240 T -(73) 279 240 T -(20) 306 240 T -(61) 333 240 T -(20) 360 240 T -(74) 387 240 T -(65) 414 240 T -(73) 441 240 T -(74) 468 240 T -(0a) 495 240 T -0 F -(input) 72 220 T -10 F -(54) 117 220 T -(68) 144 220 T -(69) 171 220 T -(73) 198 220 T -(20) 225 220 T -(69) 252 220 T -(73) 279 220 T -(20) 306 220 T -(61) 333 220 T -(20) 360 220 T -(74) 387 220 T -(65) 414 220 T -(73) 441 220 T -(74) 468 220 T -(0a) 495 220 T -0 F -(output) 72 200 T -10 F -(2b) 117 200 T -(18) 144 200 T -(68) 171 200 T -(2d) 198 200 T -(60) 225 200 T -0 F -0.19 (Note that the MAC is padded on the right by four zero bits to produce \336ve characters that) 108 180 P -(can be output.) 72 160 T -4 F -(7. Differ) 72 128 T -(ences Between ) 114.41 128 T -1 F -(bdes) 191.01 128 T -4 F -( and Sun\325) 212.99 128 T -(s DES Implementation) 261.88 128 T -0 F -0.02 (The program ) 108 104 P -3 F -0.02 (bdes) 173.33 104 P -0 F -0.02 ( is designed to be completely compatible with Sun Microsystems, Inc.\325) 195.31 104 P -0.02 (s) 535.33 104 P -0.57 (implementation of the Data Encryption Standard, called ) 72 84 P -3 F -0.57 (des) 347.14 84 P -0 F -0.57 ( and described in [4]. Thus, \336les en-) 363.13 84 P -FMENDPAGE -%%EndPage: "6" 9 -%%Page: "7" 9 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 7 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.44 (crypted using ) 72 712 P -3 F -0.44 (des) 140.84 712 P -0 F -0.44 ( can be decrypted using ) 156.83 712 P -3 F -0.44 (bdes) 275.29 712 P -0 F -0.44 (, and vice versa, provided modes common to both) 297.27 712 P --0.34 (are used. However) 72 692 P --0.34 (, ) 160.41 692 P -3 F --0.34 (bdes) 166.06 692 P -0 F --0.34 ( does not allow \336les to be named on the command line, nor does it support) 188.05 692 P --0.68 (hardware devices \050and so the ) 72 672 P -4 F --0.68 (-s) 210.83 672 P -0 F --0.68 ( and ) 219.49 672 P -4 F --0.68 (-f) 241.45 672 P -0 F --0.68 ( options of Sun\325) 249.44 672 P --0.68 (s ) 323.71 672 P -3 F --0.68 (des) 330.7 672 P -0 F --0.68 ( are not available\051. Further) 346.69 672 P --0.68 (, as encryption) 471.07 672 P --0.05 (is the default, the Sun ) 72 652 P -3 F --0.05 (des) 179.01 652 P -0 F --0.05 ( ) 195 652 P -4 F --0.05 (-e) 197.95 652 P -0 F --0.05 ( option is not recognized. As the manual page to ) 207.27 652 P -3 F --0.05 (bdes) 441.6 652 P -0 F --0.05 ( is in the appen-) 463.59 652 P -(dix, these dif) 72 632 T -(ferences will not be elaborated upon further) 134.08 632 T -(.) 343.24 632 T -0.44 (Sun\325) 108 608 P -0.44 (s ) 130 608 P -3 F -0.44 (des) 138.1 608 P -0 F -0.44 ( supports the use of special-purpose hardware to encrypt and decrypt. Although) 154.09 608 P -3 F -1.33 (bdes) 72 588 P -0 F -1.33 ( does not directly support the use of such hardware, it uses the library routine ) 93.98 588 P -3 F -1.33 (encrypt) 487.05 588 P -0 F -1.33 (\0503\051,) 523.02 588 P --0.09 (which may) 72 568 P --0.09 (. Hardware support was not included directly to support as lar) 124.1 568 P --0.09 (ge a number of platforms) 419.11 568 P -(as possible with installers needing to know as little about the hardware as possible.) 72 548 T --0.08 (Sun\325) 108 524 P --0.08 (s ) 130 524 P -3 F --0.08 (des) 137.58 524 P -0 F --0.08 ( supports only the CBC and ECB encryption modes; ) 153.57 524 P -3 F --0.08 (bdes) 407.07 524 P -0 F --0.08 ( supports all modes de-) 429.05 524 P -0.26 (scribed in [3] \050although CFB and OFB are not completely supported\051 as well as both CBC-based) 72 504 P -(and CFB-based MACs.) 72 484 T -0.15 (Although input with length not a multiple of the block size is handled in the same way by) 108 460 P --0.47 (both ) 72 440 P -3 F --0.47 (des) 95.85 440 P -0 F --0.47 ( and ) 111.84 440 P -3 F --0.47 (bdes) 134.21 440 P -0 F --0.47 (, dif) 156.19 440 P --0.47 (ferent values of the padding bytes are used in all but the last byte of the input.) 174.82 440 P -(Where ) 72 420 T -3 F -(bdes) 106.96 420 T -0 F -( puts zero bytes, ) 128.94 420 T -3 F -(des) 209.89 420 T -0 F -( puts bytes containing random values. The reason for Sun\325) 225.87 420 T -(s doing) 505.02 420 T -0.47 (so is to prevent a known plaintext attack on the \336le should an -attacker determine that the input\325) 72 400 P -0.47 (s) 535.33 400 P --0.29 (length were a multiple of the block size. W) 72 380 P --0.29 (ith ) 276.05 380 P -3 F --0.29 (bdes) 291.43 380 P -0 F --0.29 (, the plaintext contents of the last block of input) 313.41 380 P -0.31 (for such a \336le is known \050a block with all bits zero\051. W) 72 360 P -0.31 (ith ) 333.99 360 P -3 F -0.31 (des) 349.96 360 P -0 F -0.31 (, the plaintext contents of that block) 365.95 360 P -0.73 (are not known. Cryptanalytically) 72 340 P -0.73 (, given the information about the strength of the DES currently) 231.29 340 P -0.2 (known, it is widely believed that known plaintext attacks are infeasible -\050see for example [1]\051 and) 72 320 P -1.86 (so initializing and invoking the pseudorandom number generator seems unnecessary) 72 300 P -1.86 (. But this) 492.63 300 P -(means that ciphertexts produced from a plaintext by ) 72 280 T -3 F -(bdes) 324.48 280 T -0 F -( and ) 346.47 280 T -3 F -(des) 369.78 280 T -0 F -( will dif) 385.77 280 T -(fer in the last block.) 423.54 280 T -4 F -(Refer) 72 248 T -(ences) 100.41 248 T -0 F -([1]) 72 224 T -0.37 (D. Denning, \322The Data Encryption Standard: Fifteen Y) 108 224 P -0.37 (ears of Public Scrutiny) 374.87 224 P -0.37 (,\323 ) 484.8 224 P -3 F -0.37 (Pr) 496.49 224 P -0.37 (oceed-) 508.04 224 P --0.47 (ings of the Sixth Annual Computer Security Applications Confer) 108 204 P --0.47 (ence) 411.65 204 P -0 F --0.47 ( pp. x\320xv \050Dec. 1990\051.) 433.62 204 P -([2]) 72 180 T -(A. Konheim, ) 108 180 T -3 F -(Cryptography: A Primer) 173.29 180 T -0 F -(, John W) 291.4 180 T -(iley and Sons, Inc., New Y) 333.9 180 T -(ork, NY \0501981\051.) 461.94 180 T -([3]) 72 156 T -3 F -0.63 (DES Modes of Operation) 108 156 P -0 F -0.63 (, Federal Information Processing Standards Publication 81, Na-) 231.47 156 P --0.07 (tional Bureau of Standards, U.S. Department of Commerce, W) 108 136 P --0.07 (ashington, DC \050Dec. 1980\051.) 407.62 136 P -([4]) 72 112 T -3 F -(UNIX User) 108 112 T -(\325) 162.74 112 T -(s Manual) 165.18 112 T -0 F -(, Sun Microsystems Inc., Mountain V) 210.16 112 T -(iew) 390 112 T -(, CA \050Mar) 406.54 112 T -(. 1988\051.) 455.51 112 T -4 F -(Appendix. The UNIX System Manual Page for ) 72 80 T -1 F -(bdes) 313.2 80 T -FMENDPAGE -%%EndPage: "7" 10 -1 11 /Times-Bold FMDEFINEFONT -%%Page: "8" 10 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 8 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -1 F -0 X -(NAME) 72 712.67 T -0 F -(bdes - encrypt/decrypt using the Data Encryption Standard) 108 689 T -1 F -(SYNOPSIS) 72 663.67 T -4 F -(bdes) 108 640 T -0 F -( [) 131.33 640 T -3 F -( ) 138.32 640 T -4 F -(-abdp) 141.32 640 T -0 F -( ] [ ) 171.31 640 T -4 F -(-F) 188.3 640 T -0 F -( ) 199.62 640 T -3 F -(b) 202.62 640 T -0 F -( ] [ ) 208.61 640 T -4 F -(-f) 225.6 640 T -0 F -( ) 233.58 640 T -3 F -(b) 236.58 640 T -0 F -( ] [ ) 242.58 640 T -4 F -(-k) 259.56 640 T -0 F -( ) 270.22 640 T -3 F -(key) 273.22 640 T -0 F -( ] [ ) 289.2 640 T -4 F -(-m) 306.18 640 T -0 F -( ) 320.16 640 T -3 F -(b) 323.16 640 T -0 F -( ] [ ) 329.16 640 T -4 F -(-o) 346.14 640 T -0 F -( ) 356.13 640 T -3 F -(b) 359.13 640 T -0 F -( ] [ ) 365.13 640 T -4 F -(-v) 382.11 640 T -0 F -( ) 392.1 640 T -3 F -(vector) 395.1 640 T -0 F -( ]) 425.07 640 T -1 F -(DESCRIPTION) 72 614.67 T -3 F --0.69 (Bdes) 108 591 P -0 F --0.69 ( reads from the standard input and writes on the standard output. It implements all DES) 131.32 591 P --0.09 (modes of operation described in FIPS PUB 81 including alternative cipher feedback mode) 108 577 P -0.74 (and both authentication modes. All modes but the electronic code book mode require an) 108 563 P --0.14 (initialization vector; if none is supplied, the zero vector is used. T) 108 549 P --0.14 (o protect the key and ini-) 420.44 549 P -0.29 (tialization vector from being read by) 108 535 P -3 F -0.29 ( ps) 284.98 535 P -0 F -0.29 (\0501\051, ) 298.94 535 P -3 F -0.29 (bdes ) 319.21 535 P -0 F -0.29 (hides its ar) 344.48 535 P -0.29 (guments on entry) 396.81 535 P -0.29 (. If no ) 479.89 535 P -3 F -0.29 (key ) 512.74 535 P -0 F -0.29 (is) 532 535 P --0.61 (given, one is requested from the controlling terminal if that can be opened, or from the stan-) 108 521 P -(dard input if not.) 108 507 T --0.17 (The key and initialization vector are taken as sequences of ) 108 489 P -5 F --0.14 (ASCII) 389.38 489 P -0 F --0.17 ( characters which are then) 415.48 489 P --0.35 (mapped into their bit representations. If either begins with -\3240x\325 or \3240X\325, that one is taken as) 108 475 P -1.02 (a sequence of hexadecimal digits indicating the bit pattern; if either begins with \3240b\325 or) 108 461 P --0.73 (\3240B\325, that one is taken as a sequence of binary digits -indicating the bit pattern. In either case,) 108 447 P --0.37 (only the leading 64 bits of the key or initialization vector are used, and if fewer than 64 bits) 108 433 P -0.35 (are provided, enough 0 bits are appended to pad the key to 64 bits. Note that if the key is) 108 419 P -0.03 (not entered on the command line, it is interpreted in the same way) 108 405 P -0.03 (, because with 4.4 BSD,) 424.31 405 P --0.36 (the password reading function ) 108 391 P -3 F --0.36 (getpass) 254.45 391 P -0 F --0.36 (\0503\051 allows enough characters for either hex or binary) 290.43 391 P -(keys to be entered.) 108 377 T -0.04 (According to the DES standard, the low-order bit of each character in the key string is de-) 108 359 P --0.18 (leted. Since most ) 108 345 P -5 F --0.15 (ASCII) 192.75 345 P -0 F --0.18 ( representations set the high-order bit to 0, simply deleting the low-) 218.84 345 P --0.29 (order bit ef) 108 331 P --0.29 (fectively reduces the size of the key space from 2) 160.49 331 P -5 F --0.24 (56) 394.67 335.8 P -0 F --0.29 ( to 2) 404.67 331 P -5 F --0.24 (48) 425.41 335.8 P -0 F --0.29 ( keys. T) 435.4 331 P --0.29 (o prevent this,) 472.29 331 P --0.46 (the high-order bit must be a function depending in part upon the low-order bit; so, the high-) 108 317 P -0.11 (order bit is set to whatever value gives odd parity) 108 303 P -0.11 (. This preserves the key space size. Note) 345.05 303 P -(this resetting of the parity bit is ) 108 289 T -3 F -(not) 260.92 289 T -0 F -( done if the key is given in binary or hex.) 276.24 289 T --0.38 (By default, the standard input is encrypted using cipher block chaining mode and is written) 108 271 P -0.18 (to the standard output. Using the same key for encryption and decryption preserves plain-) 108 257 P -(text, so) 108 243 T -( bdes ) 225.81 225 T -3 F -(key) 253.79 225 T -0 F -( < plaintext | bdes \320i ) 269.77 225 T -3 F -(key) 370.21 225 T -0 F -( ) 386.19 225 T -(is a very expensive equivalent of ) 108 201 T -3 F -(cat) 268.54 201 T -0 F -(\0501\051.) 283.2 201 T -(Options are:) 108 183 T -( ) 108 165 T -4 F -(\320a) 111 165 T -0 F --0.75 (The key and initialization vector strings are to be taken as ) 144 165 P -5 F --0.62 (ASCII) 415.89 165 P -0 F --0.75 ( suppressing the spe-) 441.98 165 P -0.3 (cial interpretation given to leading \3240x\325, \3240X\325, \3240b\325, -and \3240B\325 characters. Note this) 144 151 P -(\337ag applies to ) 144 137 T -3 F -(both) 214.29 137 T -0 F -( the key and initialization vector) 235.62 137 T -(.) 389.85 137 T -4 F -(\320b) 108 119 T -0 F -(Use electronic code book mode.) 144 119 T -4 F -(\320d) 108 101 T -0 F -(Decrypt the input.) 144 101 T -FMENDPAGE -%%EndPage: "8" 11 -%%Page: "9" 11 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 9 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -4 F -0 X -(\320f) 108 712 T -0 F -( ) 117.99 712 T -3 F -(b) 120.99 712 T -0 F --0.29 (Use ) 144 712 P -3 F --0.29 (b) 165.36 712 P -0 F --0.29 (-bit cipher feedback mode. Currently ) 171.35 712 P -3 F --0.29 (b) 350.42 712 P -0 F --0.29 ( must be a multiple of 8 between 8 and) 356.42 712 P -(64 inclusive \050this does not conform to the standard CFB mode speci\336cation\051.) 144 698 T -4 F -(\320F) 108 680 T -0 F -( ) 121.32 680 T -3 F -(b) 124.32 680 T -0 F --0.29 (Use ) 144 680 P -3 F --0.29 (b) 165.36 680 P -0 F --0.29 (-bit alternative cipher feedback mode. Currently ) 171.36 680 P -3 F --0.29 (b) 403.77 680 P -0 F --0.29 ( must be a multiple of 7 be-) 409.77 680 P --0.12 (tween 7 and 56 inclusive \050this does not conform to the alternative CFB mode spec-) 144 666 P -(i\336cation\051.) 144 652 T -4 F -(\320k) 108 634 T -0 F -( ) 120.67 634 T -3 F -(key) 123.66 634 T -0 F -0.37 (Use the string ) 144 616 P -3 F -0.37 (key) 214.74 616 P -0 F -0.37 ( as the cryptographic key) 230.72 616 P -0.37 (. If this ar) 352.01 616 P -0.37 (gument is not given, the user) 399.54 616 P -(will be prompted for the key) 144 602 T -(.) 280.12 602 T -4 F -(\320m) 108 584 T -0 F -( ) 123.99 584 T -3 F -(b) 126.99 584 T -0 F -0.71 (Compute a message authentication code \050MAC\051 of ) 144 584 P -3 F -0.71 (b) 395.78 584 P -0 F -0.71 ( bits on the input. ) 401.77 584 P -3 F -0.71 (b) 491.94 584 P -0 F -0.71 ( must be) 497.94 584 P -0.11 (between 1 and 64 inclusive; if ) 144 570 P -3 F -0.11 (b) 291.87 570 P -0 F -0.11 ( is not a multiple of 8, enough 0 bits will be added) 297.86 570 P --0.44 (to pad the MAC length to the nearest multiple of 8. Only the MAC is output. MACs) 144 556 P -(are only available in cipher block chaining mode or in cipher feedback mode.) 144 542 T -4 F -(\320o) 108 524 T -0 F -( ) 119.99 524 T -3 F -(b) 122.99 524 T -0 F --0.34 (Use ) 144 524 P -3 F --0.34 (b) 165.31 524 P -0 F --0.34 (-bit output feedback mode. Currently ) 171.31 524 P -3 F --0.34 (b) 350.83 524 P -0 F --0.34 ( must be a multiple of 8 between 8 and) 356.83 524 P -(64 inclusive \050this does not conform to the OFB mode speci\336cation\051.) 144 510 T -4 F -(\320p) 108 492 T -0 F --0.14 (Disable the resetting of the parity bit. This \337ag forces the parity bit of the key to be) 144 492 P -0.03 (used as typed, rather than making each character be of odd parity) 144 478 P -0.03 (. It is used only if) 455.91 478 P -(the key is given in ) 144 464 T -5 F -(ASCII) 234.95 464 T -0 F -(.) 261.04 464 T -4 F -(\320v) 108 446 T -0 F -( ) 119.99 446 T -3 F -(vector) 122.99 446 T -0 F --0.5 (Set the initialization vector to ) 144 428 P -3 F --0.5 (v) 286.44 428 P -0 F --0.5 (; the vector is interpreted in the same way as the key) 291.76 428 P --0.5 (.) 537 428 P -(The vector is ignored in electronic codebook mode.) 144 414 T --0.55 (The DES is considered a very strong cryptosystem, and other than table lookup attacks, key) 108 396 P -0.24 (search attacks, and Hellman\325) 108 382 P -0.24 (s time-memory tradeof) 246.61 382 P -0.24 (f \050all of which are very expensive and) 356.8 382 P -0.66 (time-consuming\051, no cryptanalytic methods for breaking the DES are known in the open) 108 368 P -0.33 (literature. No doubt the choice of keys and key security are the most vulnerable aspect of) 108 354 P -3 F -(bdes) 108 340 T -0 F -(.) 129.98 340 T -4 F -(IMPLEMENT) 72 314 T -(A) 146.41 314 T -(TION NOTES) 154.18 314 T -0 F -0.57 (For implementors wishing to write software compatible with this program, the following) 108 290 P --0.23 (notes are provided. This software is completely compatible with the implementation of the) 108 276 P -(data encryption standard distributed by Sun Microsystems, Inc.) 108 262 T -0.11 (In the ECB and CBC modes, plaintext is encrypted in units of 64 bits \0508 bytes, also called) 108 244 P -0.52 (a block\051. T) 108 230 P -0.52 (o ensure that the plaintext \336le is encrypted correctly) 160.49 230 P -0.52 (, ) 413.01 230 P -3 F -0.52 (bdes ) 419.53 230 P -0 F -0.52 (will \050internally\051 ap-) 445.03 230 P -0.29 (pend from 1 to 8 bytes, the last byte containing an integer stating how many bytes of that) 108 216 P --0.71 (\336nal block are from the plaintext \336le, and encrypt the resulting block. Hence, when decrypt-) 108 202 P -0.27 (ing, the last block may contain from 0 to 7 characters present in the plaintext \336le, and the) 108 188 P --0.59 (last byte tells how many) 108 174 P --0.59 (. Note that if during decryption the last byte of the \336le does not con-) 221.46 174 P -0.41 (tain an integer between 0 and 7, either the \336le has been corrupted or an incorrect key has) 108 160 P -0.48 (been given. A similar mechanism is used for the OFB and CFB modes, except that those) 108 146 P -0.26 (simply require the length of the input to be a multiple of the mode size, and the \336nal byte) 108 132 P --0.73 (contains an integer between 0 and one less than the number of bytes being used as the mode.) 108 118 P -(\050This was another reason that the mode size must be a multiple of 8 for those modes.\051) 108 104 T -FMENDPAGE -%%EndPage: "9" 12 -%%Page: "10" 12 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 10 of 11) 473.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.94 (Unlike Sun\325) 108 712 P -0.94 (s implementation, unused bytes of that last block are not \336lled with random) 166.58 712 P -0.57 (data, but instead contain what was in those byte positions in the preceding block. This is) 108 698 P -(quicker and more portable, and does not weaken the encryption signi\336cantly) 108 684 T -(.) 473.95 684 T -0.36 (If the key is entered in ) 108 666 P -5 F -0.3 (ASCII) 220.76 666 P -0 F -0.36 (, the parity bits of the key characters are set so that each key) 246.85 666 P -1.03 (character is of odd parity) 108 652 P -1.03 (. Unlike Sun\325) 231.23 652 P -1.03 (s implementation, it is possible to enter binary or) 296.92 652 P --0.57 (hexadecimal keys on the command line, and if this is done, the parity bits are ) 108 638 P -3 F --0.57 (not ) 472.85 638 P -0 F --0.57 (reset. This) 490.61 638 P -(allows testing using arbitrary bit patterns as keys.) 108 624 T -0.64 (The Sun implementation always uses an initialization vector of 0 \050that is, all zeroes\051. By) 108 606 P -(default, ) 108 592 T -3 F -(bdes ) 147.3 592 T -0 F -(does too, but this may be changed from the command line.) 172.29 592 T -4 F -(FILES) 72 566 T -0 F -(/dev/tty) 108 542 T -(controlling terminal for typed key) 180 542 T -4 F -(SEE ALSO) 72 516 T -3 F -(crypt) 108 492 T -0 F -(\0501\051, ) 132.65 492 T -3 F -(crypt) 152.63 492 T -0 F -(\0503\051) 177.27 492 T -3 F --0.4 (Data Encryption Standar) 108 474 P --0.4 (d) 228.02 474 P -0 F --0.4 (, Federal Information Processing Standard #46, National Bureau) 234.02 474 P -(of Standards, U.S. Department of Commerce, W) 108 460 T -(ashington DC \050Jan. 1977\051.) 340.2 460 T -3 F -0.16 (DES) 108 442 P -0 F -0.16 ( ) 129.98 442 P -3 F -0.16 (Modes of Operation, ) 133.15 442 P -0 F -0.16 (Federal Information Processing Standard #81, National Bureau) 236.24 442 P -(of Standards, U.S. Department of Commerce, W) 108 428 T -(ashington DC \050Dec. 1980\051.) 340.2 428 T -2.75 (Dorothy Denning, ) 108 410 P -3 F -2.75 (Cryptography and Data Security) 203.77 410 P -0 F -2.75 (, Addison-W) 368.8 410 P -2.75 (esley Publishing Co.,) 432.55 410 P -(Reading, MA \2511982.) 108 396 T --0.19 ( Matt Bishop, \322Implementation Notes on ) 108 378 P -3 F --0.19 (bdes) 305.76 378 P -0 F --0.19 (\0501\051\323, T) 327.75 378 P --0.19 (echnical Report PCS-TR-91-158, De-) 359.35 378 P -0.34 (partment of Mathematics and Computer Science, Dartmouth College, Hanover) 108 364 P -0.34 (, NH \050Apr) 488.01 364 P -0.34 (.) 537 364 P -(1991\051.) 108 350 T -4 F -(CAUTION) 72 324 T -0 F --0.55 (Certain speci\336c keys should be avoided because they introduce potential weaknesses; these) 108 300 P --0.44 (keys, called the ) 108 286 P -3 F --0.44 (weak) 183.95 286 P -0 F --0.44 ( and ) 208.6 286 P -3 F --0.44 (semiweak) 231.03 286 P -0 F --0.44 ( keys, are \050in hex notation, where ) 277.66 286 P -6 F --1.06 (p) 437.45 286 P -0 F --0.44 ( is either ) 444.64 286 P -6 F --1.06 (0) 487.63 286 P -0 F --0.44 ( or ) 494.82 286 P -6 F --1.06 (1) 509.93 286 P -0 F --0.44 (, and) 517.12 286 P -6 F -(P) 108 272 T -0 F -( is either ) 115.2 272 T -6 F -(e) 159.5 272 T -0 F -( or ) 166.7 272 T -6 F -(f) 182.68 272 T -0 F -(\051:) 189.88 272 T -6 F -(0x0p0p0p0p0p0p0p0p) 144 254 T -(0x0p1P0p1P0p0P0p0P) 360 254 T -(0x0pep0pep0pfp0pfp) 144 236 T -(0x0pfP0pfP0pfP0pfP) 360 236 T -(0x1P0p1P0p0P0p0P0p) 144 218 T -(0x1P1P1P1P0P0P0P0P) 360 218 T -(0x1Pep1Pep0Pfp0Pfp) 144 200 T -(0x1PfP1PfP0PfP0PfP) 360 200 T -(0xep0pep0pfp0pfp0p) 144 182 T -(0xep1Pep1pfp0Pfp0P) 360 182 T -(0xepepepepepepepep) 144 164 T -(0xepfPepfPfpfPfpfP) 360 164 T -(0xfP0pfP0pfP0pfP0p) 144 146 T -(0xfP1PfP1PfP0PfP0P) 360 146 T -(0xfPepfPepfPepfPep) 144 128 T -(0xfPfPfPfPfPfPfPfP) 360 128 T -0 F -0.13 (The weakness of these keys is inherent in the DES algorithm \050see for example Moore and) 108 110 P --0.57 (Simmons, \322Cycle structure of the DES with weak and semi-weak keys,\323) 108 96 P -3 F --0.57 ( Advances in Cryp-) 449.43 96 P -(tology \320 Crypto \32486 Pr) 108 82 T -(oceedings) 216.83 82 T -0 F -(, Springer) 264.79 82 T -(-V) 311.85 82 T -(erlag New Y) 323.17 82 T -(ork, \2511987, pp. 9-32\051.) 383.25 82 T -FMENDPAGE -%%EndPage: "10" 13 -%%Page: "11" 13 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 11 of 11) 473.71 34.7 T -72 72 540 720 R -7 X -V -4 F -0 X -(BUGS) 72 712 T -0 F --0.18 (There is a controversy raging over whether the DES will still be secure in a few years. The) 108 688 P -0.31 (advent of special-purpose hardware could reduce the cost of any of the methods of attack) 108 674 P -(named above so that they are no longer computationally infeasible.) 108 660 T -0.32 (Programs which display programs\325 ar) 108 642 P -0.32 (guments may compromise the key and initialization) 289.59 642 P -0.76 (vector if they are speci\336ed on the command line. T) 108 628 P -0.76 (o avoid this ) 358.46 628 P -3 F -0.76 (bdes) 419.7 628 P -0 F -0.76 ( overwrites its ar) 441.68 628 P -0.76 (gu-) 524.01 628 P -(ments. However) 108 614 T -(, the obvious race cannot currently be avoided.) 186.12 614 T -0.25 (As the key or key schedule is kept in memory throughout the run of this program, the en-) 108 596 P -(cryption can be compromised if memory is readable.) 108 582 T --0.4 (There is no warranty of merchantability nor any warranty of \336tness for a particular purpose) 108 564 P -0.05 (nor any other warranty) 108 550 P -0.05 (, either express or implied, as to the accuracy of the enclosed mate-) 216.95 550 P -(rials or as to their suitability for any particular purpose.) 108 536 T --0.06 (Accordingly) 108 518 P --0.06 (, the user assumes full responsibility for their use. Further) 167.18 518 P --0.06 (, the author assumes) 442.93 518 P --0.25 (no obligation to furnish any assistance of any kind whatsoever) 108 504 P --0.25 (, or to furnish any additional) 404.69 504 P -(information or documentation.) 108 490 T -4 F -(AUTHOR) 72 464 T -0 F --0.54 (Matt Bishop, Department of Mathematics and Computer Science, Bradley Hall, Dartmouth) 108 440 P -(College, Hanover) 108 426 T -(, NH 03755) 192.12 426 T -(Electronic mail addresses:) 108 408 T -(Internet: Matt.Bishop@dartmouth.edu) 108 390 T -(UUCP: decvax!dartvax!Matt.Bishop) 108 372 T -FMENDPAGE -%%EndPage: "11" 14 -%%Trailer -%%BoundingBox: 0 0 612 792 -%%Pages: 13 1 -%%DocumentFonts: Helvetica-Bold -%%+ Helvetica-BoldOblique -%%+ Times-Roman -%%+ Times-Bold -%%+ Times-BoldItalic -%%+ Times-Italic -%%+ Courier -%%+ Courier-Oblique -%%+ ZapfDingbats -%%+ Symbol -%%+ Courier-Bold diff --git a/usr.bin/chat/fix-cua b/usr.bin/chat/fix-cua deleted file mode 100644 index 74f000a30f62..000000000000 --- a/usr.bin/chat/fix-cua +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -LOCKDIR=/var/spool/lock - -case "$1" in - "") echo "Usage: fix-cua device"; exit 1 ;; -esac - -if [ -f $LOCKDIR/LCK..$1 ] -then - echo "/dev/$1 is locked" 2>&1 - exit 1 -fi - -chown root /dev/$1 -chmod 666 /dev/$1 diff --git a/usr.bin/compress/zcat.sh b/usr.bin/compress/zcat.sh deleted file mode 100644 index c4931e486bb0..000000000000 --- a/usr.bin/compress/zcat.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1992, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)zcat.sh 8.1 (Berkeley) 6/6/93 -# - -uncompress -c $* diff --git a/usr.bin/diff/diff/diff.1 b/usr.bin/diff/diff/diff.1 deleted file mode 100644 index 1b5c0787430f..000000000000 --- a/usr.bin/diff/diff/diff.1 +++ /dev/null @@ -1,387 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 -.\" -.Dd June 30, 1993 -.Dt DIFF 1 -.Os BSD 4 -.Sh NAME -.Nm diff -.Nd differential file and directory comparator -.Sh SYNOPSIS -.Nm diff -.Op Fl cefhn -.Op Fl biwt -.Ar file1 file2 -.Nm diff -.Op Fl D Ns Ar string -.Op Fl biw -.Ar file1 file2 -.Nm diff -.Op Fl l -.Op Fl r -.Op Fl s -.Op Fl cefhn -.Op Fl biwt -.Op Fl S Ns Ar name -.Ar dir1 dir2 -.Sh DESCRIPTION -The -.Nm diff -utility compares the contents of -.Ar file1 -and -.Ar file2 -and writes to the standard output the list of changes necessary to -convert one file into the other. -No output is produced if the files are identical. -.Pp -Output options (mutually exclusive): -.Bl -tag -width Ds -.It Fl c -produces a diff with lines of context. -The default is to present 3 lines of context and may be changed, e.g., to 10, by -.Fl c10 . -With -.Fl c -the output format is modified slightly: -the output beginning with identification of the files involved and -their creation dates and then each change is separated -by a line with a dozen *'s. -The lines removed from -.Ar file1 -are marked with `\(mi '; those added to -.Ar file2 -are marked `+ '. Lines which are changed from one -file to the other are marked in both files with `! '. -Changes which lie within lines of each other are grouped -together on output. (This is a change from the previous ``diff -c'' -but the resulting output is usually much easier to interpret.) -.It Fl e -produces output in a form suitable as input for the editor utility, -.Xr ed 1 , -which can then be used to convert file1 into file2. -.Pp -Extra commands are added to the output when comparing directories with -.Fl e , -so that the result is a -.Xr sh 1 -script for converting text files which are common to the two directories -from their state in -.Ar dir1 -to their state in -.Ar dir2 . -.It Fl f -identical output to that of the -.Fl e -flag, but in reverse order. It cannot -be digested by -.Xr ed 1 . -.It Fl h -Invokes an alternate algorithm which can handle files of very long lengths. -There is a trade off. The algorithm can only deal with changes which are -clearly delimited and brief. Long sections of changes and overlaps will -confuse it. -.It Fl n -produces a script similar to that of -.Fl e , -but in the opposite order and with a count of changed lines on each -insert or delete command. This is the form used by -.Xr rcsdiff 1 . -.It Fl D Ns Ar string -creates a merged version of -.Ar file1 -and -.Ar file2 -on the standard output, with C preprocessor controls included so that -a compilation of the result without defining -.Ar string -is equivalent -to compiling -.Ar file1 , -while defining -.Ar string -will yield -.Ar file2 . -.El -.Pp -Comparison options: -.Bl -tag -width Ds -.It Fl b -causes trailing blanks (spaces and tabs) to be ignored, and other -strings of blanks to compare equal. -.It Fl i -ignores the case of letters. E.g., ``A'' will compare equal to ``a''. -.It Fl t -will expand tabs in output lines. Normal or -.Fl c -output adds character(s) to the front of each line which may screw up -the indentation of the original source lines and make the output listing -difficult to interpret. This option will preserve the original source's -indentation. -.It Fl w -is similar to -.Fl b -but causes whitespace (blanks and tabs) to be totally ignored. E.g., -``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''. -.El -.Pp -Directory comparison options: -.Bl -tag -width Ds -.It Fl l -long output format; each text file -.Nm diff Ns \'d -is piped through -.Xr pr 1 -to paginate it, -other differences are remembered and summarized -after all text file differences are reported. -.It Fl r -causes application of -.Nm diff -recursively to common subdirectories encountered. -.It Fl s -causes -.Nm diff -to report files which are the same, which are otherwise not mentioned. -.It Fl S Ns Ar name -re-starts a directory -.Nm diff -in the middle beginning with file -.Ar name . -.El -.Pp -If both arguments are directories, -.Nm diff -sorts the contents of the directories by name, and then runs the -regular file -.Nm diff -algorithm, producing a change list, -on text files which are different. -Binary files which differ, -common subdirectories, and files which appear in only one directory -are described as such. -.Pp -If only one of -.Ar file1 -and -.Ar file2 -is a directory, -.Nm diff -is applied to the non-directory file and the file contained in -the directory file with a filename that is the same as the -last component of the non-directory file. -.Pp -If either -.Ar file1 -or -.Ar file2 -is -.Sq Fl , -the standard input is -used in its place. -.Ss Output Style -The default (without -.Fl e , -.Fl c , -or -.Fl n -.\" -C -options) -output contains lines of these forms, where -.Va XX , YY , ZZ , QQ -are line numbers respective of file order. -.Pp -.Bl -tag -width "XX,YYcZZ,QQ" -compact -.It Li XX Ns Ic a Ns Li YY -At (the end of) line -.Va XX -of -.Ar file1 , -append the contents -of line -.Va YY -of -.Ar file2 -to make them equal. -.It Li XX Ns Ic a Ns Li YY,ZZ -Same as above, but append the range of lines, -.Va YY -through -.Va ZZ -of -.Ar file2 -to line -.Va XX -of file1. -.It Li XX Ns Ic d Ns Li YY -At line -.Va XX -delete -the line. The value -.Va YY -tells to which line the change -would bring -.Ar file1 -in line with -.Ar file1 . -.It Li XX,YY Ns Ic d Ns Li ZZ -Delete the range of lines -.Va XX -through -.Va YY -in -.Ar file1 . -.It Li XX Ns Ic c Ns Li YY -Change the line -.Va XX -in -.Ar file1 -to the line -.Va YY -in -.Ar file2. -.It Li XX,YY Ns Ic c Ns Li ZZ -Replace the range of specified lines with the line -.Va ZZ . -.It Li XX,YY Ns Ic c Ns Li ZZ,QQ -Replace the range -.Va XX , Ns YY -from -.Ar file1 -with the range -.Va ZZ , Ns QQ -from -.Ar file2 . -.El -.Pp -These lines resemble -.Xr ed 1 -subcommands to convert -.Ar file1 -into -.Ar file2 . -The line numbers before the action letters pertain to -.Ar file1 ; -those after pertain to -.Ar file2 . -Thus, by exchanging -.Ic a -for -.Ic d -and reading the line in reverse order, one can also -determine how to convert -.Ar file2 -into -.Ar file1 . -As in -.Xr ed 1 , -identical -pairs (where num1 = num2) are abbreviated as a single -number. -.Sh ENVIRONMENT -.Bl -tag -width TMPDIR -.It Ev TMPDIR -If the environment variable -.Ev TMPDIR -exists, -.Nm diff -will use the directory specified by -.Ev TMPDIR -as the temporary directory. -.El -.Sh FILES -.Bl -tag -width /usr/bin/diffh -compact -.It Pa /tmp/d????? -.It Pa /usr/bin/diffh -Alternate algorithm version (used by option -.Fl h ) . -.It Pa /usr/bin/diff -for directory diffs -.It Pa /usr/bin/pr -used by the -.Fl l -option. -.El -.Sh SEE ALSO -.Xr cmp 1 , -.Xr cc 1 , -.Xr comm 1 , -.Xr ed 1 , -.Xr diff3 1 -.br -.ne 1i -.Sh DIAGNOSTICS -The -.Nm diff -utility exits with one of the following values: -.Pp -.Bl -tag -width Ds -compact -offset indent -.It \&0 -No differences were found. -.It \&1 -Differences were found. -.It "\&>\&1" -An error occurred. -.El -.Sh BUGS -The -.Fl f -and -.Fl e -options -do not provide special handling for lines on which the -first and only character is -.Dq Li \&. . -This can cause problems for -.Xr ed 1 . -.Pp -When comparing directories with the -.Fl b , -.Fl w -or -.Fl i -options specified, -.Nm diff -first compares the files ala -.Ar cmp , -and then decides to run the -.Nm diff -algorithm if they are not equal. -This may cause a small amount of spurious output if the files -then turn out to be identical because the only differences are -insignificant white space or case differences. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/diff/diff3/diff3.1 b/usr.bin/diff/diff3/diff3.1 deleted file mode 100644 index 09b1d72899bd..000000000000 --- a/usr.bin/diff/diff3/diff3.1 +++ /dev/null @@ -1,172 +0,0 @@ -.\" Copyright (c) 1990, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)diff3.1 8.2 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt DIFF3 1 -.Os BSD 4.3R -.Sh NAME -.Nm diff3 -.Nd 3-way differential file comparison -.Sh SYNOPSIS -.Nm diff3 -.Op Fl exEX3 -.Ar file1 file2 file3 -.Sh DESCRIPTION -The -.Nm diff3 -utility compares the contents of three different versions of a file, -.Ar file1 , -.Ar file2 -and -.Ar file3 , -writing the result to the standard output. -The options describe different methods of merging and -purging -the separate versions into a new file. -.Nm Diff3 -is used by -.Xr RCS 1 -to merge specific versions or create -new versions. -.Pp -Options are: -.Bl -tag -width "--E, --X" -.It Fl e -Produces output in a form suitable as an input script for the -.Xr ed 1 -utility. The script may then be used to merge differences common -between all three files and differences specific to file1 and file3. -In other words, the -.Fl e -option ignores differences specific to file1 and file2, and those -specific to file2 and file3. It is useful for backing out changes -specific to file2 only. -.It Fl x -Produces an output script suitable for -.Xr ed 1 -with changes -specific only to all three versions. -.It Fl 3 -Produces an output script suitable for -.Xr ed 1 -with changes -specific only to file3. -.It Fl E , X -Similar to -.Fl e -and -.Fl x , -respectively, but treat overlapping changes (i.e., changes that would -be noted with ==== in the normal listing) differently. The overlapping -lines from both files will be inserted by the edit script, bracketed -by "<<<<<<" and ">>>>>>" lines. -.El -.Pp -The -.Fl E -option is used by -.Tn RCS -.Xr merge 1 -to insure that overlapping changes in the merged files are preserved -and brought to someone's attention. -.Pp -For example, suppose lines 7-8 are changed in both file1 and file2. -Applying the edit script generated by the command -.Pp -.Dl diff3 -E file1 file2 file3 -.Pp -to file1 results in the file: -.Pp -.Bd -literal -offset indent -compact -lines 1-6 -of file1 -<<<<<<< file1 -lines 7-8 -of file1 -======= -lines 7-8 -of file3 ->>>>>>> file3 -rest of file1 -.Ed -.Pp -The default output of -.Nm diff3 -makes notation of the differences between all files, and those differences -specific to each pair of files. The -changes are described by -the commands necessary for -.Xr ed 1 -to create the desired target from the different versions. -See -.Xr diff 1 -for a description of the commands. -.Bl -tag -width "=====" -.It Li \&==== -The lines beneath this notation are ranges of lines which are different -between all files. -.It \&==== Ns Va n -The lines beneath this notation are ranges of lines which are exclusively -different in file -.Va n . -.El -.Sh FILES -.Bl -tag -width /usr/bin/diff3 -compact -.It Pa /tmp/d3????? -temporary files. -.It Pa /usr/bin/diff3 -the executable. -.El -.Sh SEE ALSO -.Xr diff 1 -.Xr ed 1 -.Xr rcs 1 -.Sh BUGS -The -.Fl e -option -cannot catch and change -lines which have -.Ql \&. -as the first and only character on the line. -The resulting script will fail on that line -as -.Ql \&. -is an -.Xr ed 1 -editing command. -.Sh HISTORY -A -.Nm -command appeared in -.At v7 . diff --git a/usr.bin/ee/ee.msg b/usr.bin/ee/ee.msg deleted file mode 100644 index 2117d067ae1a..000000000000 --- a/usr.bin/ee/ee.msg +++ /dev/null @@ -1,170 +0,0 @@ -$ This file contains the messages for ee ("easy editor"). See the file -$ ee.i18n.guide for more information -$ -$ For ee patchlevel 3 -$ -$ $Header: /users/hugh/tmp/old_ae/ee.msg,v 1.3 1993/06/22 04:13:35 hugh Exp $ -$ -$set 1 -$quote " -1 "modes menu" -2 "tabs to spaces " -3 "case sensitive search" -4 "margins observed " -5 "auto-paragraph format" -6 "eightbit characters " -7 "info window " -8 "right margin " -9 "leave menu" -10 "save changes" -11 "no save" -12 "file menu" -13 "read a file" -14 "write a file" -15 "save file" -16 "print editor contents" -17 "search menu" -18 "search for ..." -19 "search" -20 "spell menu" -21 "use 'spell'" -22 "use 'ispell'" -23 "miscellaneous menu" -24 "format paragraph" -25 "shell command" -26 "check spelling" -27 "main menu" -28 "leave editor" -29 "help" -30 "file operations" -31 "redraw screen" -32 "settings" -33 "search" -34 "miscellaneous" -35 "Control keys: " -36 "^a ascii code ^i tab ^r right " -37 "^b bottom of text ^j newline ^t top of text " -38 "^c command ^k delete char ^u up " -39 "^d down ^l left ^v undelete word " -40 "^e search prompt ^m newline ^w delete word " -41 "^f undelete char ^n next page ^x search " -42 "^g begin of line ^o end of line ^y delete line " -43 "^h backspace ^p prev page ^z undelete line " -44 "^[ (escape) menu " -45 " " -46 "Commands: " -47 "help : get this info file : print file name " -48 "read : read a file char : ascii code of char " -49 "write : write a file case : case sensitive search " -50 "exit : leave and save nocase : case insensitive search " -51 "quit : leave, no save !cmd : execute \"cmd\" in shell " -52 "line : display line # 0-9 : go to line \"#\" " -53 "expand : expand tabs noexpand: do not expand tabs " -54 " " -55 " ee [-i] [-e] [-h] [file(s)] " -56 " -i : no information window -e : do not expand tabs -h : no highlight " -57 "^[ (escape) menu ^e search prompt ^y delete line ^u up ^p prev page " -58 "^a ascii code ^x search ^z undelete line ^d down ^n next page " -59 "^b bottom of text ^g begin of line ^w delete word ^l left " -60 "^t top of text ^o end of line ^v undelete word ^r right " -61 "^c command ^k delete char ^f undelete char " -62 "help : get help info |file : print file name |line : print line # " -63 "read : read a file |char : ascii code of char |0-9 : go to line \"#\"" -64 "write: write a file |case : case sensitive search |exit : leave and save " -65 "!cmd : shell \"cmd\" |nocase: ignore case in search |quit : leave, no save" -66 "expand: expand tabs |noexpand: do not expand tabs " -67 " press Escape (^[) for menu" -68 "no file" -69 "ascii code: " -70 "sending contents of buffer to \"%s\" " -71 "command: " -72 "name of file to write: " -73 "name of file to read: " -74 "character = %d" -75 "unknown command \"%s\"" -76 "entered command is not unique" -77 "line %d " -78 "length = %d" -79 "current file is \"%s\" " -80 "usage: %s [-i] [-e] [-h] [+line_number] [file(s)]\n" -81 " -i turn off info window\n" -82 " -e do not convert tabs to spaces\n" -83 " -h do not use highlighting\n" -84 "file \"%s\" is a directory" -85 "new file \"%s\"" -86 "can't open \"%s\"" -87 "file \"%s\", %d lines" -88 "finished reading file \"%s\"" -89 "reading file \"%s\"" -90 ", read only" -91 "file \"%s\", %d lines" -92 "enter name of file: " -93 "no filename entered: file not saved" -94 "changes have been made, are you sure? (y/n [n]) " -95 "y" -96 "file already exists, overwrite? (y/n) [n] " -97 "unable to create file \"%s\"" -98 "writing file \"%s\"" -99 "\"%s\" %d lines, %d characters" -100 " ...searching" -101 "string \"%s\" not found" -102 "search for: " -103 "could not exec %s\n" -104 "press return to continue " -105 "press Esc to cancel" -106 "menu too large for window" -107 "press any key to continue " -108 "shell command: " -109 "...formatting paragraph..." -110 " [in regexec()], more - comments. inspire better dfa exec() strategy. - serious testing and help with special cases. - - Algorithm amalgam summary: - - dfa e?grep (aho/thompson) - ndfa regexp() (spencer/aho) - bmg (boyer/moore/gosper) - "superimposed" bmg (jaw) - fgrep (aho/corrasick) - - sorry, but the knuth/morris/pratt machine, horspool's - "frequentist" code, and the rabin/karp matcher, however cute, - just don't cut it for this production. - - James A. Woods Copyright (c) 1986 - NASA Ames Research Center -*/ -#include -#include -#include -#include /* must be henry spencer's version */ -#include -#include -#include "pathnames.h" - -#define MIN(A, B) ((A) > (B) ? (B) : (A)) - -#ifdef SLOWSYS -#define read xread -#endif - -#define BUFSIZE 8192 /* make higher for cray */ -#define PATSIZE 6000 -#define LARGE BUFSIZE + PATSIZE - -#define NALT 7 /* tied to scanf() size in alternate() */ -#define NMUSH 6 /* loosely relates to expected alt length */ - -#define FIRSTFEW 33 /* Always do FIRSTFEW matches with regexec() */ -#define PUNTPERCENT 10 /* After FIRSTFEW, if PUNTPERCENT of the input - * was processed by regexp(), exec std egrep. */ -#define NL '\n' -#define EOS '\0' -#define NONASCII 0200 /* Bit mask for Kanji non-ascii chars */ -#define META "\n^$.[]()?+*|\\" /* egrep meta-characters */ -#define SS2 '\216' /* EUC Katakana (or Chinese2) prefix */ -#define SS3 '\217' /* EUC Kanji2 (or Chinese3) prefix */ - -extern char *optarg; -extern int optind; -char *progname; - -int cflag, iflag, eflag, fflag, lflag, nflag; /* SVID flags */ -int sflag, hflag; /* v7, v8, bsd */ - -int firstflag; /* Stop at first match */ -int grepflag; /* Called as "grep" */ -int fgrepflag; /* Called as "fgrep" */ -int altflag; /* Simple alternation in pattern */ -int boyonly; /* No regexp needed -- all simple */ -int flushflag; -int grepold, egrepold, fgrepold; - -int nalt; /* Number of alternatives */ -int nsuccess; /* 1 for match, 2 for error */ -int altmin; /* Minimum length of all the alternate - * strings */ -int firstfile; /* argv index of first file argument */ -int patind; /* argv index of pattern */ -long nmatch; /* Number of matches in this file */ -long incount, counted; /* Amount of input consumed */ -long rxcount; /* Bytes of input processed by regexec() */ -int boyfound; /* accumulated partial matches (tripped by - * FIRSTFEW) */ -int prevmatch; /* next three lines aid fast -n */ -long nline, prevnline; -char *prevloc; - -regexp *rspencer; -char *pattern; -char *patboy; /* Pattern for simple Boyer-Moore */ -char *patfile; /* Filename containing pattern(s) */ - -int delta0[256]; /* Boyer-Moore algorithm core */ -char cmap[256]; /* Usually 0-255, but if -i, maps upper to - * lower case */ -char str[BUFSIZE + 2]; -int nleftover; -char linetemp[BUFSIZE]; -char *altpat[NALT]; /* alternation component storage */ -int altlen[NALT]; -short altset[NMUSH + 1][256]; -char preamble[200]; /* match prefix (filename, line no.) */ - -int fd; -char * -strchr(), *strrchr(), *strcpy(), *strncpy(), *strpbrk(), *malloc(); -char * -grepxlat(), *fold(), *pfile(), *alternate(), *isolate(); -char *gotamatch(), *kanji(), *linesave(), *submatch(); -char **args; - -main(argc, argv) - int argc; - char *argv[]; -{ - int c, oflag; - int errflag = 0; - - args = argv; - - if ((progname = strrchr(argv[0], '/')) != 0) - progname++; - else - progname = argv[0]; - if (strcmp(progname, "grep") == 0) - grepflag++; - else if (strcmp(progname, "fgrep") == 0) - fgrepflag++; - - oflag = 0; - while ((c = getopt(argc, argv, "bchie:f:lnosvwxy1")) != EOF) { - switch (c) { - - case 'f': - fflag++; - patfile = optarg; - continue; - case 'b': - case 'v': - egrepold++; /* boyer-moore of little help here */ - continue; - case 'c': - cflag++; - continue; - case 'e': - eflag++; - pattern = optarg; - continue; - case 'h': - hflag++; - continue; - case 'o': - oflag++; - continue; - case '1': /* Stop at very first match */ - firstflag++; /* spead freaks only */ - continue; - case 'i': - iflag++; - continue; - case 'l': - lflag++; - continue; - case 'n': - nflag++; - continue; - case 's': - sflag++; - continue; - case 'w': - case 'y': - if (!grepflag) - errflag++; - grepold++; - continue; - case 'x': /* needs more work, like -b above */ - if (!fgrepflag) - errflag++; - fgrepold++; - continue; - case '?': - errflag++; - } - } - if (errflag || ((argc <= optind) && !fflag && !eflag)) { - if (grepflag) -oops("usage: grep [-bchilnosvwy] [-e] pattern [file ...]"); - else if (fgrepflag) -oops("usage: fgrep [-bchilnosvx] {-f patfile | [-e] strings} [file ...]"); - else /* encourage SVID options, though we provide - * others */ -oops("usage: egrep [-bchilnosv] {-f patfile | [-e] pattern} [file ...]"); - } - if (fflag) - pattern = pfile(patfile); - else if (!eflag) { - patind = optind; - pattern = argv[optind++]; - } - - if (!oflag && (argc - optind) <= 1) /* Filename invisible given < 2 files */ - hflag++; - if (pattern[0] == EOS) - kernighan(argv); /* same as it ever was */ - /* - * 'grep/egrep' merger -- "old" grep is called to handle: tagged - * exprs \( \), word matches \< and \>, -w and -y options, char - * classes with '-' at end (egrep bug?), and patterns beginning with - * an asterisk (don't ask why). otherwise, characters meaningful to - * 'egrep' but not to 'grep' are escaped; the entire expr is then - * passed to 'egrep'. - */ - if (grepflag && !grepold) { - if (strindex(pattern, "\\(") >= 0 || - strindex(pattern, "\\<") >= 0 || - strindex(pattern, "\\>") >= 0 || - strindex(pattern, "-]") >= 0 || - pattern[0] == '*') /* grep bug */ - grepold++; - else - pattern = grepxlat(pattern); - } - if (grepold || egrepold || fgrepold) - kernighan(argv); - - if (iflag) - strcpy(pattern, fold(pattern)); - /* - * If the pattern is a plain string, just run boyer-moore. If it - * consists of meta-free alternatives, run "superimposed" bmg. - * Otherwise, find best string, and compile pattern for regexec(). - */ - if (strpbrk(pattern, META) == NULL) { /* do boyer-moore only */ - boyonly++; - patboy = pattern; - } else { - if ((patboy = alternate(pattern)) != NULL) - boyonly++; - else { - if ((patboy = isolate(pattern)) == NULL) - kernighan(argv); /* expr too involved */ -#ifndef NOKANJI - for (c = 0; pattern[c] != EOS; c++) - if (pattern[c] & NONASCII) /* kanji + meta */ - kernighan(argv); -#endif - if ((rspencer = regcomp(pattern)) == NULL) - oops("regcomp failure"); - } - } - gosper(patboy); /* "pre-conditioning is wonderful" - * -- v. strassen */ - - if ((firstfile = optind) >= argc) { - /* Grep standard input */ - if (lflag) /* We don't know its name! */ - exit(1); - egsecute((char *) NULL); - } else { - while (optind < argc) { - egsecute(argv[optind]); - optind++; - if (firstflag && (nsuccess == 1)) - break; - } - } - exit((nsuccess == 2) ? 2 : (nsuccess == 0)); -} - -char * -pfile(pfname) /* absorb expression from file */ - char *pfname; -{ - int fd; - struct stat patstat; - static char *pat; - - if ((fd = open(pfname, O_RDONLY, 0)) < 0) - oops("can't read pattern file"); - if (fstat(fd, &patstat) != 0) - oops("can't stat pattern file"); - if (patstat.st_size > PATSIZE) { - if (fgrepflag) { /* defer to unix version */ - fgrepold++; - return "dummy"; - } else - oops("pattern file too big"); - } - if ((pat = malloc((unsigned) patstat.st_size + 1)) == NULL) - oops("out of memory to read pattern file"); - if (patstat.st_size != read(fd, pat, (int)patstat.st_size)) - oops("error reading pattern file"); - (void) close(fd); - - pat[patstat.st_size] = EOS; - if (pat[patstat.st_size - 1] == NL) /* NOP for egrep; helps grep */ - pat[patstat.st_size - 1] = EOS; - - if (nlcount(pat, &pat[patstat.st_size]) > NALT) { - if (fgrepflag) - fgrepold++; /* "what's it all about, alfie?" */ - else - egrepold++; - } - return (pat); -} - -egsecute(file) - char *file; -{ - extern int errno; - - if (file == NULL) - fd = 0; - else if ((fd = open(file, O_RDONLY, 0)) <= 0) { - fprintf(stderr, - "%s: %s: %s\n", progname, file, strerror(errno)); - nsuccess = 2; - return; - } - chimaera(file, patboy); - - if (!boyonly && !flushflag && file != NULL) - flushmatches(); - if (file != NULL) - close(fd); -} - -chimaera(file, pat) /* "reach out and boyer-moore search someone" */ - char *file, *pat; /* -- soon-to-be-popular bumper sticker */ -{ - register char *k, *strend, *s; - register int j, count; - register int *deltazero = delta0; - int patlen = altmin; - char *t; - - nleftover = boyfound = flushflag = 0; - nline = 1L; - prevmatch = 0; - nmatch = counted = rxcount = 0L; - - while ((count = read(fd, str + nleftover, BUFSIZE - nleftover)) > 0) { - - counted += count; - strend = linesave(str, count); - - for (k = str + patlen - 1; k < strend;) { - /* - * for a large class of patterns, upwards of 80% of - * match time is spent on the next line. we beat - * existing microcode (vax 'matchc') this way. - */ - while ((k += deltazero[*(unsigned char *) k]) < strend); - if (k < (str + LARGE)) - break; - k -= LARGE; - - if (altflag) { - /* - * Parallel Boyer-Moore. Check whether each - * of the previous chars COULD be - * from one of the alternative strings. - */ - s = k - 1; - j = altmin; - while (altset[--j][(unsigned char) - cmap[*(unsigned char *) s--]]); - /* - * quick test fails. in this life, compare - * 'em all. but, a "reverse trie" would - * attenuate worst case (linear w/delta2?). - */ - if (--j < 0) { - count = nalt - 1; - do { - s = k; - j = altlen[count]; - t = altpat[count]; - - while - (cmap[*(unsigned char *) s--] - == t[--j]); - if (j < 0) - break; - } - while (count--); - } - } else { - /* One string -- check it */ - j = patlen - 1; - s = k - 1; - while (cmap[*(unsigned char *) s--] == pat[--j]); - } - /* - * delta-less shortcut for literati. short shrift for - * genetic engineers? - */ - if (j >= 0) { - k++; /* no match; restart next char */ - continue; - } - k = submatch(file, pat, str, strend, k, count); - if (k == NULL) - return; - } - if (nflag) { - if (prevmatch) - nline = prevnline + nlcount(prevloc, k); - else - nline = nline + nlcount(str, k); - prevmatch = 0; - } - strncpy(str, linetemp, nleftover); - } - if (cflag) { - /* Bug from old grep: -c overrides -h. We fix the bug. */ - if (!hflag) - printf("%s:", file); - printf("%ld\n", nmatch); - } -} - -char * -linesave(str, count) /* accumulate partial line at end of buffer */ - char str[]; - register int count; -{ - register int j; - - count += nleftover; - if (count != BUFSIZE && fd != 0) - str[count++] = NL; /* insurance for broken last line */ - str[count] = EOS; - for (j = count - 1; str[j] != NL && j >= 0;) - j--; - /* - * break up these lines: long line (> BUFSIZE), last line of file, or - * short return from read(), as from tee(1) input - */ - if (j < 0 && (count == (BUFSIZE - nleftover))) { - str[count++] = NL; - str[count] = EOS; - linetemp[0] = EOS; - nleftover = 0; - return (str + count); - } else { - nleftover = count - j - 1; - strncpy(linetemp, str + j + 1, nleftover); - return (str + j); - } -} - -/* - * Process partial match. First check for mis-aligned Kanji, then match line - * against full compiled r.e. if statistics do not warrant handing off to - * standard egrep. - */ -char * -submatch(file, pat, str, strend, k, altindex) - char file[], pat[], str[]; - register char *strend, *k; - int altindex; -{ - register char *s; - char *t, c; - - t = k; - s = ((altflag) ? k - altlen[altindex] + 1 : k - altmin + 1); -#ifndef NOKANJI - c = ((altflag) ? altpat[altindex][0] : pat[0]); - if (c & NONASCII) - if ((s = kanji(str, s, k)) == NULL) - return (++k); /* reject false kanji */ -#endif - do; - while (*s != NL && --s >= str); - k = s + 1; /* now at line start */ - - if (boyonly) - return (gotamatch(file, k)); - - incount = counted - (strend - k); - if (boyfound++ == FIRSTFEW) - execstrategy(file); - - s = t; - do - rxcount++; - while (*s++ != NL); - *--s = EOS; - /* - * "quick henry -- the flit" (after theodor geisel) - */ - if (regexec(rspencer, ((iflag) ? fold(k) : k)) == 1) { - *s = NL; - if (gotamatch(file, k) == NULL) - return (NULL); - } - *s = NL; - return (s + 1); -} - -#ifndef NOKANJI -/* - * EUC code disambiguation -- scan backwards to first 7-bit code, while - * counting intervening 8-bit codes. If odd, reject unaligned Kanji pattern. - * SS2/3 checks are for intermixed Japanase Katakana or Kanji2. - */ -char * -kanji(str, s, k) - register char *str, *s, *k; -{ - register int j = 0; - - for (s--; s >= str; s--) { - if (*s == SS2 || *s == SS3 || (*s & NONASCII) == 0) - break; - j++; - } -#ifndef CHINESE - if (*s == SS2) - j -= 1; -#endif CHINESE - return ((j & 01) ? NULL : k); -} -#endif - -/* - * Compute "Boyer-Moore" delta table -- put skip distance in delta0[c] - */ -gosper(pattern) - char *pattern; /* ... HAKMEM lives ... */ -{ - register int i, j; - unsigned char c; - - /* Make one-string case look like simple alternatives case */ - if (!altflag) { - nalt = 1; - altmin = altlen[0] = strlen(pattern); - altpat[0] = pattern; - } - /* For chars that aren't in any string, skip by string length. */ - for (j = 0; j < 256; j++) { - delta0[j] = altmin; - cmap[j] = j; /* Sneak in initialization of cmap */ - } - - /* For chars in a string, skip distance from char to end of string. */ - /* (If char appears more than once, skip minimum distance.) */ - for (i = 0; i < nalt; i++) - for (j = 0; j < altlen[i] - 1; j++) { - c = altpat[i][j]; - delta0[c] = MIN(delta0[c], altlen[i] - j - 1); - if (iflag && islower((int) c)) - delta0[toupper((int) c)] = delta0[c]; - } - - /* For last char of each string, fall out of search loop. */ - for (i = 0; i < nalt; i++) { - c = altpat[i][altlen[i] - 1]; - delta0[c] = LARGE; - if (iflag && islower((int) c)) - delta0[toupper((int) c)] = LARGE; - } - if (iflag) - for (j = 'A'; j <= 'Z'; j++) - cmap[j] = tolower((int) j); -} - -/* - * Print, count, or stop on full match. Result is either the location for - * continued search, or NULL to stop. - */ -char * -gotamatch(file, s) - register char *file, *s; -{ - char *savematch(); - int squirrel = 0; /* nonzero to squirrel away FIRSTFEW matches */ - - nmatch++; - nsuccess = 1; - if (!boyonly && boyfound <= FIRSTFEW && file != NULL) - squirrel = 1; - - if (sflag) - return (NULL); /* -s usurps all flags (unlike some versions) */ - if (cflag) { /* -c overrides -l, we guess */ - do; - while (*s++ != NL); - } else if (lflag) { - puts(file); - return (NULL); - } else { - if (!hflag) - if (!squirrel) - printf("%s:", file); - else - (void)sprintf(preamble, "%s:", file); - if (nflag) { - if (prevmatch) - prevnline = prevnline + nlcount(prevloc, s); - else - prevnline = nline + nlcount(str, s); - prevmatch = 1; - - if (!squirrel) - printf("%ld:", prevnline); - else - (void)sprintf(preamble + strlen(preamble), - "%ld:", prevnline); - } - if (!squirrel) { - do - putchar(*s); - while (*s++ != NL); - } else - s = savematch(s); - - if (nflag) - prevloc = s - 1; - } - return ((firstflag && !cflag) ? NULL : s); -} - -char * -fold(line) - char *line; -{ - static char fline[BUFSIZE]; - register char *s, *t = fline; - - for (s = line; *s != EOS; s++) - *t++ = (isupper((int) *s) ? (char) tolower((int) *s) : *s); - *t = EOS; - return (fline); -} - -strindex(s, t) /* the easy way, as in K&P, p. 192 */ - char *s, *t; -{ - int i, n; - - n = strlen(t); - for (i = 0; s[i] != '\0'; i++) - if (strncmp(s + i, t, n) == 0) - return (i); - return (-1); -} - -char * -grepxlat(pattern) /* grep pattern meta conversion */ - char *pattern; -{ - register char *p, *s; - static char newpat[BUFSIZE]; - - for (s = newpat, p = pattern; *p != EOS;) { - if (*p == '\\') { /* skip escapes ... */ - *s++ = *p++; - if (*p) - *s++ = *p++; - } else if (*p == '[') { /* ... and char classes */ - while (*p != EOS && *p != ']') - *s++ = *p++; - } else if (strchr("+?|()", *p) != NULL) { - *s++ = '\\'; /* insert protection */ - *s++ = *p++; - } else - *s++ = *p++; - } - *s = EOS; - grepflag = ((patind) ? 0 : 1); - return (newpat); -} - -/* - * Test for simple alternation. Result is NULL if it's not so simple, or is - * a pointer to the first string if it is. Warning: sscanf size is a - * fixpoint, beyond which the speedup linearity starts to break down. In the - * wake of the elegant aho/corrasick "trie"-based fgrep, generalizing - * altpat[] to arbitrary size is not useful. - */ -char * -alternate(regexpr) - char *regexpr; -{ - register int i, j; - register char *start, *stop; - unsigned char c; - - if (fgrepflag && strchr(regexpr, '|')) - return (NULL); - - /* - * break pattern up into altpat array; delimit on newline, bar, - * or EOS. We know we won't overflow, we've already checked the - * number of patterns we're going to find against NALT. - * Also, set length of pattern and find minimum pattern length. - */ - nalt = 0; - altmin = NMUSH; - for (start = stop = regexpr;; ++stop) - if (!*stop || *stop == '|' || *stop == NL) { - altlen[nalt] = j = stop - start; - if (j < altmin) - altmin = j; - if (!(altpat[nalt] = malloc((u_int)(j + 1)))) - oops("out of memory"); - bcopy(start, altpat[nalt], j); - altpat[nalt][j] = EOS; - ++nalt; - if (!*stop) - break; - if (nalt == NALT) - return(NULL); - if (*stop == NL) - *stop = '|'; - start = stop + 1; - } - if (!fgrepflag) { - if (strchr(regexpr, '|') == NULL || regexpr[0] == '|') - return (NULL); - if (strpbrk(regexpr, "^$.[]()?+*\\") != NULL - || strindex(regexpr, "||") >= 0) - return (NULL); - } - - if (nalt > 1) { /* build superimposed "pre-match" sets per - * char */ - altflag++; - for (j = 0; j < nalt; j++) - for (i = 0; i < altmin; i++) { - c = altpat[j][altlen[j] - altmin + i]; - altset[i + 1][c] = 1; /* offset for sentinel */ - } - } - return (altpat[0]); -} - -/* - * Grapple with the dfa (std egrep) vs. ndfa (regexp) tradeoff. Criteria to - * determine whether to use dfa-based egrep: We do FIRSTFEW matches with - * regexec(). If Boyer-Moore up to now matched more than PUNTPERCENT - * of the input, the r.e. is likely to be underspecified, so do old *grep, - * which is faster on complex patterns than regexp(). At FIRSTFEW, - * dump the saved matches collected by savematch(). They are saved - * so that a "PUNT" can "rewind" to ignore them. Stdin is problematic, - * since it's hard to rewind. - */ - -execstrategy(file) - char *file; -{ - int pctmatch; - - pctmatch = (100 * rxcount) / incount; - if (pctmatch > PUNTPERCENT && file != NULL) - kernighan(args); - if (file != NULL) - flushmatches(); -} - -nlcount(bstart, bstop) /* flail interval to totalize newlines. */ - char *bstart, *bstop; -{ - register char *s = bstart; - register char *t = bstop; - register int count = 0; - - do { /* loop unroll for older architectures */ - if (*t == NL) /* ... ask ames!jaw for sample code */ - count++; - } while (t-- > s); - - return (count); -} - -char * -isolate(regexpr) /* isolate longest metacharacter-free string */ - char *regexpr; -{ - char *dummyexpr; - - /* - * We add (.)* because Henry's regcomp only figures regmust if it - * sees a leading * pattern. Foo! - */ - dummyexpr = malloc((unsigned) strlen(regexpr) + 5); - (void)sprintf(dummyexpr, "(.)*%s", regexpr); - if ((rspencer = regcomp(dummyexpr)) == NULL) - kernighan(args); - return (rspencer->regmust); -} - -char *matches[FIRSTFEW]; -static int mcount = 0; - -char * -savematch(s) /* horde matches during statistics gathering */ - register char *s; -{ - char *p; - char *start = s; - int msize = 0; - int psize = strlen(preamble); - - while (*s++ != NL) - msize++; - *--s = EOS; - - p = malloc((unsigned) msize + 1 + psize); - strcpy(p, preamble); - strcpy(p + psize, start); - matches[mcount++] = p; - - preamble[0] = 0; - *s = NL; - return (s); -} - -flushmatches() -{ - int n; - - flushflag = 1; - for (n = 0; n < mcount; n++) - printf("%s\n", matches[n]); - mcount = 0; -} - -oops(message) - char *message; -{ - fprintf(stderr, "%s: %s\n", progname, message); - exit(2); -} - -kernighan(args) /* "let others do the hard part ..." */ - char *args[]; -{ - /* - * We may have already run grep on some of the files; remove them - * from the arg list we pass on. Note that we can't delete them - * totally because the number of file names affects the output - * (automatic -h). - */ - /* better would be fork/exec per punted file -- jaw */ - - while (firstfile && optind > firstfile) - args[firstfile++] = _PATH_DEVNULL; - if (patind) - args[patind] = pattern; - (void) fflush(stdout); - - if (grepflag) - execvp(_PATH_GREPSTD, args), oops("can't exec old 'grep'"); - else if (fgrepflag) - execvp(_PATH_FGREPSTD, args), oops("can't exec old 'fgrep'"); - else - execvp(_PATH_EGREPSTD, args), oops("can't exec old 'egrep'"); -} diff --git a/usr.bin/grep/egrep/grep.1 b/usr.bin/grep/egrep/grep.1 deleted file mode 100644 index 771cc8c65ae7..000000000000 --- a/usr.bin/grep/egrep/grep.1 +++ /dev/null @@ -1,250 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)grep.1 8.3 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt GREP 1 -.Os -.Sh NAME -.Nm grep -.Nd file pattern searcher -.Sh SYNOPSIS -.Nm grep -.Op Fl bchilnosvw -.Op Fl e Ar pattern -.Op Ar -.Nm egrep -.Op Fl bchilnosv -.Op Fl e Ar pattern -.Op Fl f Ar pattern_file -.Op Ar -.Nm fgrep -.Op Fl bchilnosvx -.Op Fl e Ar pattern -.Op Fl f Ar pattern_file -.Op Ar -.Sh DESCRIPTION -The -.Nm grep -utilities search the given input files selecting lines -which match one or more patterns; the type of patterns is controlled -by the options specified. -By default, a pattern -matches an input line if any regular expression (RE) in the -pattern matches the input line without its trailing . -A null RE matches every line. -Each input line that matches at -least one of the patterns is written to the standard output. -.Pp -For simple patterns or -.Xr ex 1 -or -.Xr ed 1 -style regular expressions, the -.Nm grep -utility is used. -The -.Nm egrep -utility -can handle extended regular expressions and -embedded s in patterns. -The -.Nm fgrep -utility is quick but can handle only fixed strings. -A fixed string -is a string of characters, -each character -is matched only by itself. -The pattern -value can consist of multiple lines with -embedded s. -In this case, the s -act as alternation characters, allowing any of the -pattern lines to match a portion of the input. -.Pp -The following options are available: -.Pp -.Bl -tag -width indent -.It Fl b -The block number on the disk in which a matched pattern is located -is displayed in front of the respective matched line. -.It Fl c -Only a count of selected lines is written to standard -output. -.It Fl e Ar expression -Specify a pattern used during the search of the -input. -Multiple -.Fl e -options can be used to specify -multiple patterns; an input line is selected if it -matches any of the specified patterns. -.It Fl f Ar pattern_file -The pattern is read from the file named by the -pathname pattern_file. -Trailing newlines -in the pattern_file are ignored. -.Pf ( Nm Egrep -and -.Nm fgrep -only). -.It Fl h -Never print filename headers with output lines. -.It Fl i -The case of letters is ignored in making comparisons \- that is, upper and -lower case are considered identical. -.It Fl l -Only the names of files containing selected lines -are written to standard output. -Pathnames are -listed once per file searched. -If the standard -input is searched, the pathname -.Sq Fl -is written. -.It Fl n -Each output line is preceded by its relative line -number in the file; each file starting at line 1. -The line number counter is reset for each file processed. -This option is ignored if -.Fl c , -.Fl l , -or -.Fl s -is -specified. -.It Fl o -Always print filename headers with output lines. -.It Fl s -Silent mode. Nothing is printed (except error messages). -This is useful for checking the error status. -.It Fl v -Selected lines are those -.Em not -matching the specified -patterns. -.It Fl x -Only input lines selected against an entire fixed -string or regular expression are considered to be -matching lines. -.Pf ( Nm Fgrep -only). -.It Fl w -The expression is searched for as a word -(as if surrounded by `\e<' and `\e>', see -.Xr ex 1 . ) -.Pf ( Nm Grep -only) -.Pp -.El -If no file arguments are specified, the -standard input is used. -.Pp -The -.Nm grep -utility exits with one of the following values: -.Pp -.Bl -tag -width flag -compact -.It Li 0 -One or more lines were selected. -.It Li 1 -No lines were selected. -.It Li >1 -An error occurred. -.El -.Sh EXTENDED REGULAR EXPRESSIONS -The following characters are interpreted by -.Nm egrep : -.Pp -.Bl -tag -width flag -compact -.It Cm \&$ -Align the match from the end of the line. -.It Cm \&^ -Align the match from the beginning of the line. -.It Cm \&| -Add another pattern (see example below). -.It Cm \&? -Match 1 or less sequential repetitions of the pattern. -.It Cm \&+ -Match 1 or more sequential repetitions of the pattern. -.It Cm \&* -Match 0 or more sequential repetitions of the pattern. -.It Cm \&[] -Match any single character or range of characters -enclosed in the brackets. -.It Cm \&\e -Escape special characters which have meaning to -.Nm egrep , -the set of {$,.,^,[,],|,?,+,*,(,)}. -.El -.Sh EXAMPLES -To find all occurrences of the word patricia in a file: -.Pp -.Dl grep patricia myfile -.Pp -To find all occurrences of the pattern -.Ql \&.Pp -at the beginning of a line: -.Pp -.Dl grep '^\e.Pp' -.Pp -The apostrophes assure the entire expression is evaluated by -.Nm grep -instead of by the -users shell. -The carat or hat -.Ql Li \&^ -means -.Em from the beginning of a line , -and the -.Ql Li \&\e -escapes the -.Ql Li \&. -which would otherwise match any character. -.Pp -A simple example of an extended regular expression: -.Pp -.Dl egrep '19|20|25' calendar -.Pp -Peruses the file calendar looking for either 19, 20 -or 25. -.Sh SEE ALSO -.Xr ed 1 , -.Xr ex 1 , -.Xr sed 1 -.Sh HISTORY -The -.Nm grep -command appeared in -.At v6 . -.Sh BUGS -Lines are limited to 256 characters; longer lines are truncated. diff --git a/usr.bin/grep/egrep/pathnames.h b/usr.bin/grep/egrep/pathnames.h deleted file mode 100644 index a25b3dc79ed0..000000000000 --- a/usr.bin/grep/egrep/pathnames.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#include - -#define _PATH_EGREPSTD "/usr/libexec/old.egrep" -#define _PATH_GREPSTD "/usr/libexec/old.bin.grep" -#define _PATH_FGREPSTD "/usr/libexec/old.fgrep" diff --git a/usr.bin/ld/Makefile b/usr.bin/ld/Makefile deleted file mode 100644 index 834a5c99eeb7..000000000000 --- a/usr.bin/ld/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= ld -SRCS= ld.c cplus-dem.c -NOMAN= noman - -.include diff --git a/usr.bin/ld/cplus-dem.c b/usr.bin/ld/cplus-dem.c deleted file mode 100644 index b2e30509638a..000000000000 --- a/usr.bin/ld/cplus-dem.c +++ /dev/null @@ -1,970 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - */ - -#ifndef lint -static char sccsid[] = "@(#)cplus-dem.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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 1, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). */ - -/* This file exports one function - - char *cplus_demangle (const char *name) - - If `name' is a mangled function name produced by g++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - For example, - - cplus_demangle ("_foo__1Ai") - - returns - - "A::foo(int)" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* #define nounderscore 1 /* define this is names don't start with _ */ - -#include -#include - -#ifdef USG -#include -#include -#else -#include -#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n)) -#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n)) -#define strchr index -#define strrchr rindex -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type); -#else -extern char *cplus_demangle (); -#endif - -#ifdef __STDC__ -extern char *xmalloc (int); -extern char *xrealloc (char *, int); -#else -extern char *xmalloc (); -extern char *xrealloc (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "convert", "+", /* unary + */ - "negate", "-", /* unary - */ - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "truth_not", "!", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "indirect", "*", - "method_call", "->()", - "addr", "&", /* unary & */ - "array", "[]", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl); -static int do_type (const char **type, string *result); -static int do_arg (const char **type, string *result); -static int do_args (const char **type, string *decl); -static void munge_function_name (string *name); -static void remember_type (const char *type, int len); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -static void remember_type (); -#endif - -char * -cplus_demangle (type) - const char *type; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p; -#ifndef LONGERNAMES - const char *premangle; -#endif - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - int n = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = strchr (type, '$')) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$') - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl); - } - p += 2; - -#ifndef LONGERNAMES - premangle = p; -#endif - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } - p += n; -#ifndef LONGERNAMES - remember_type (premangle, p - premangle); -#endif - success = do_args (&p, &decl); - if (const_flag) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result) - const char **type; - string *result; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatilep"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'x': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long long"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result) - const char **type; - string *result; -{ - const char *start = *type; - - if (!do_type (type, result)) - return 0; - remember_type (start, *type - start); - return 1; -} - -static void -remember_type (start, len) - const char *start; - int len; -{ - char *tem; - - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl) - const char **type; - string *decl; -{ - string arg; - int need_comma = 0; - - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma) - string_append (decl, ", "); - if (!do_arg (&tem, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma) - string_append (decl, ", "); - if (!do_arg (type, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name) - string *name; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -#if 0 -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b == s->p) - return; - string_prependn (p, s->b, s->p - s->b); -} -#endif - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/usr.bin/ld/ld.c b/usr.bin/ld/ld.c deleted file mode 100644 index f0b35f2edb10..000000000000 --- a/usr.bin/ld/ld.c +++ /dev/null @@ -1,4718 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)ld.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* Linker `ld' for GNU - Copyright (C) 1988 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 1, 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written by Richard Stallman with some help from Eric Albert. - Set, indirect, and warning symbol features added by Randy Smith. */ - -/* Define how to initialize system-dependent header fields. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* symseg.h defines the obsolete GNU debugging format; we should nuke it. */ -#define CORE_ADDR unsigned long /* For symseg.h */ -#include "symseg.h" - -#define N_SET_MAGIC(exec, val) ((exec).a_magic = val) - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#endif - -#define min(a,b) ((a) < (b) ? (a) : (b)) - -/* Macro to control the number of undefined references printed */ -#define MAX_UREFS_PRINTED 10 - -/* Size of a page; obtained from the operating system. */ - -int page_size; - -/* Name this program was invoked by. */ - -char *progname; - -/* System dependencies */ - -/* Define this to specify the default executable format. */ - -#ifndef DEFAULT_MAGIC -#define DEFAULT_MAGIC ZMAGIC -#endif - -#if defined(hp300) || defined(luna68k) -#define INITIALIZE_HEADER outheader.a_mid = MID_HP300 -#endif - -#ifdef sparc -#ifndef sun -#define sun 1 -#endif -#define INITIALIZE_HEADER \ - (outheader.a_mid = MID_SUN_SPARC, outheader.a_toolversion = 1) -#endif - -/* - * Ok. Following are the relocation information macros. If your - * system should not be able to use the default set (below), you must - * define the following: - - * relocation_info: This must be typedef'd (or #define'd) to the type - * of structure that is stored in the relocation info section of your - * a.out files. Often this is defined in the a.out.h for your system. - * - * RELOC_ADDRESS (rval): Offset into the current section of the - * to be relocated. *Must be an lvalue*. - * - * RELOC_EXTERN_P (rval): Is this relocation entry based on an - * external symbol (1), or was it fully resolved upon entering the - * loader (0) in which case some combination of the value in memory - * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains - * what the value of the relocation actually was. *Must be an lvalue*. - * - * RELOC_TYPE (rval): If this entry was fully resolved upon - * entering the loader, what type should it be relocated as? - * - * RELOC_SYMBOL (rval): If this entry was not fully resolved upon - * entering the loader, what is the index of it's symbol in the symbol - * table? *Must be a lvalue*. - * - * RELOC_MEMORY_ADD_P (rval): This should return true if the final - * relocation value output here should be added to memory, or if the - * section of memory described should simply be set to the relocation - * value. - * - * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives - * an extra value to be added to the relocation value based on the - * individual relocation entry. *Must be an lvalue if defined*. - * - * RELOC_PCREL_P (rval): True if the relocation value described is - * pc relative. - * - * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the - * final relocation value before putting it where it belongs. - * - * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of - * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes - * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could - * do everything in terms of the bit operators below), but having this - * macro could end up producing better code on machines without fancy - * bit twiddling. Also, it's easier to understand/code big/little - * endian distinctions with this macro. - * - * RELOC_TARGET_BITPOS (rval): The starting bit position within the - * object described in RELOC_TARGET_SIZE in which the relocation value - * will go. - * - * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced - * with the bits of the relocation value. It may be assumed by the - * code that the relocation value will fit into this many bits. This - * may be larger than RELOC_TARGET_SIZE if such be useful. - * - * - * Things I haven't implemented - * ---------------------------- - * - * Values for RELOC_TARGET_SIZE other than 0, 1, or 2. - * - * Pc relative relocation for External references. - * - * - */ - -/* The following #if has been modifed for cross compilation */ -/* It originally read: #if defined(sun) && defined(sparc) */ -/* Marc Ullman, Stanford University Nov. 1 1989 */ -#if defined(sun) && (TARGET == SUN4) -/* Sparc (Sun 4) macros */ -#undef relocation_info -#define relocation_info reloc_info_sparc -#define RELOC_ADDRESS(r) ((r)->r_address) -#define RELOC_EXTERN_P(r) ((r)->r_extern) -#define RELOC_TYPE(r) ((r)->r_index) -#define RELOC_SYMBOL(r) ((r)->r_index) -#define RELOC_MEMORY_SUB_P(r) 0 -#define RELOC_MEMORY_ADD_P(r) 0 -#define RELOC_ADD_EXTRA(r) ((r)->r_addend) -#define RELOC_PCREL_P(r) \ - ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) -#define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type]) -#define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type]) -#define RELOC_TARGET_BITPOS(r) 0 -#define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type]) - -/* Note that these are very dependent on the order of the enums in - enum reloc_type (in a.out.h); if they change the following must be - changed */ -/* Also note that the last few may be incorrect; I have no information */ -static int reloc_target_rightshift[] = { - 0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0, -}; -static int reloc_target_size[] = { - 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; -static int reloc_target_bitsize[] = { - 8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16, -}; - -#define MAX_ALIGNMENT (sizeof (double)) -#endif - -/* Default macros */ -#ifndef RELOC_ADDRESS -#define RELOC_ADDRESS(r) ((r)->r_address) -#define RELOC_EXTERN_P(r) ((r)->r_extern) -#define RELOC_TYPE(r) ((r)->r_symbolnum) -#define RELOC_SYMBOL(r) ((r)->r_symbolnum) -#define RELOC_MEMORY_SUB_P(r) 0 -#define RELOC_MEMORY_ADD_P(r) 1 -#undef RELOC_ADD_EXTRA -#define RELOC_PCREL_P(r) ((r)->r_pcrel) -#define RELOC_VALUE_RIGHTSHIFT(r) 0 -#define RELOC_TARGET_SIZE(r) ((r)->r_length) -#define RELOC_TARGET_BITPOS(r) 0 -#define RELOC_TARGET_BITSIZE(r) 32 -#endif - -#ifndef MAX_ALIGNMENT -#define MAX_ALIGNMENT (sizeof (int)) -#endif - -#ifdef nounderscore -#define LPREFIX '.' -#else -#define LPREFIX 'L' -#endif - -#ifndef TEXT_START -#define TEXT_START(x) N_TXTADDR(x) -#endif - -/* Special global symbol types understood by GNU LD. */ - -/* The following type indicates the definition of a symbol as being - an indirect reference to another symbol. The other symbol - appears as an undefined reference, immediately following this symbol. - - Indirection is asymmetrical. The other symbol's value will be used - to satisfy requests for the indirect symbol, but not vice versa. - If the other symbol does not have a definition, libraries will - be searched to find a definition. - - So, for example, the following two lines placed in an assembler - input file would result in an object file which would direct gnu ld - to resolve all references to symbol "foo" as references to symbol - "bar". - - .stabs "_foo",11,0,0,0 - .stabs "_bar",1,0,0,0 - - Note that (11 == (N_INDR | N_EXT)) and (1 == (N_UNDF | N_EXT)). */ - -#ifndef N_INDR -#define N_INDR 0xa -#endif - -/* The following symbols refer to set elements. These are expected - only in input to the loader; they should not appear in loader - output (unless relocatable output is requested). To be recognized - by the loader, the input symbols must have their N_EXT bit set. - All the N_SET[ATDB] symbols with the same name form one set. The - loader collects all of these elements at load time and outputs a - vector for each name. - Space (an array of 32 bit words) is allocated for the set in the - data section, and the n_value field of each set element value is - stored into one word of the array. - The first word of the array is the length of the set (number of - elements). The last word of the vector is set to zero for possible - use by incremental loaders. The array is ordered by the linkage - order; the first symbols which the linker encounters will be first - in the array. - - In C syntax this looks like: - - struct set_vector { - unsigned int length; - unsigned int vector[length]; - unsigned int always_zero; - }; - - Before being placed into the array, each element is relocated - according to its type. This allows the loader to create an array - of pointers to objects automatically. N_SETA type symbols will not - be relocated. - - The address of the set is made into an N_SETV symbol - whose name is the same as the name of the set. - This symbol acts like a N_DATA global symbol - in that it can satisfy undefined external references. - - For the purposes of determining whether or not to load in a library - file, set element definitions are not considered "real - definitions"; they will not cause the loading of a library - member. - - If relocatable output is requested, none of this processing is - done. The symbols are simply relocated and passed through to the - output file. - - So, for example, the following three lines of assembler code - (whether in one file or scattered between several different ones) - will produce a three element vector (total length is five words; - see above), referenced by the symbol "_xyzzy", which will have the - addresses of the routines _init1, _init2, and _init3. - - *NOTE*: If symbolic addresses are used in the n_value field of the - defining .stabs, those symbols must be defined in the same file as - that containing the .stabs. - - .stabs "_xyzzy",23,0,0,_init1 - .stabs "_xyzzy",23,0,0,_init2 - .stabs "_xyzzy",23,0,0,_init3 - - Note that (23 == (N_SETT | N_EXT)). */ - -#ifndef N_SETA -#define N_SETA 0x14 /* Absolute set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETT -#define N_SETT 0x16 /* Text set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETD -#define N_SETD 0x18 /* Data set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETB -#define N_SETB 0x1A /* Bss set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -/* Macros dealing with the set element symbols defined in a.out.h */ -#define SET_ELEMENT_P(x) ((x)>=N_SETA&&(x)<=(N_SETB|N_EXT)) -#define TYPE_OF_SET_ELEMENT(x) ((x)-N_SETA+N_ABS) - -#ifndef N_SETV -#define N_SETV 0x1C /* Pointer to set vector in data area. */ -#endif /* This is output from LD. */ - -/* If a this type of symbol is encountered, its name is a warning - message to print each time the symbol referenced by the next symbol - table entry is referenced. - - This feature may be used to allow backwards compatibility with - certain functions (eg. gets) but to discourage programmers from - their use. - - So if, for example, you wanted to have ld print a warning whenever - the function "gets" was used in their C program, you would add the - following to the assembler file in which gets is defined: - - .stabs "Obsolete function \"gets\" referenced",30,0,0,0 - .stabs "_gets",1,0,0,0 - - These .stabs do not necessarily have to be in the same file as the - gets function, they simply must exist somewhere in the compilation. */ - -#ifndef N_WARNING -#define N_WARNING 0x1E /* Warning message to print if symbol - included */ -#endif /* This is input to ld */ - -#ifndef __GNU_STAB__ - -/* Line number for the data section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_DSLINE -#define N_DSLINE (N_SLINE+N_DATA-N_TEXT) -#endif - -/* Line number for the bss section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_BSLINE -#define N_BSLINE (N_SLINE+N_BSS-N_TEXT) -#endif - -#endif /* not __GNU_STAB__ */ - -/* Symbol table */ - -/* Global symbol data is recorded in these structures, - one for each global symbol. - They are found via hashing in 'symtab', which points to a vector of buckets. - Each bucket is a chain of these structures through the link field. */ - -typedef - struct glosym - { - /* Pointer to next symbol in this symbol's hash bucket. */ - struct glosym *link; - /* Name of this symbol. */ - char *name; - /* Value of this symbol as a global symbol. */ - long value; - /* Chain of external 'nlist's in files for this symbol, both defs - and refs. */ - struct nlist *refs; - /* Any warning message that might be associated with this symbol - from an N_WARNING symbol encountered. */ - char *warning; - /* Nonzero means definitions of this symbol as common have been seen, - and the value here is the largest size specified by any of them. */ - int max_common_size; - /* For relocatable_output, records the index of this global sym in the - symbol table to be written, with the first global sym given index 0.*/ - int def_count; - /* Nonzero means a definition of this global symbol is known to exist. - Library members should not be loaded on its account. */ - char defined; - /* Nonzero means a reference to this global symbol has been seen - in a file that is surely being loaded. - A value higher than 1 is the n_type code for the symbol's - definition. */ - char referenced; - /* A count of the number of undefined references printed for a - specific symbol. If a symbol is unresolved at the end of - digest_symbols (and the loading run is supposed to produce - relocatable output) do_file_warnings keeps track of how many - unresolved reference error messages have been printed for - each symbol here. When the number hits MAX_UREFS_PRINTED, - messages stop. */ - unsigned char undef_refs; - /* 1 means that this symbol has multiple definitions. 2 means - that it has multiple definitions, and some of them are set - elements, one of which has been printed out already. */ - unsigned char multiply_defined; - /* Nonzero means print a message at all refs or defs of this symbol */ - char trace; - } - symbol; - -/* Demangler for C++. */ -extern char *cplus_demangle (); - -/* Demangler function to use. */ -char *(*demangler)() = NULL; - -/* Number of buckets in symbol hash table */ -#define TABSIZE 1009 - -/* The symbol hash table: a vector of TABSIZE pointers to struct glosym. */ -symbol *symtab[TABSIZE]; - -/* Number of symbols in symbol hash table. */ -int num_hash_tab_syms = 0; - -/* Count the number of nlist entries that are for local symbols. - This count and the three following counts - are incremented as as symbols are entered in the symbol table. */ -int local_sym_count; - -/* Count number of nlist entries that are for local symbols - whose names don't start with L. */ -int non_L_local_sym_count; - -/* Count the number of nlist entries for debugger info. */ -int debugger_sym_count; - -/* Count the number of global symbols referenced and not defined. */ -int undefined_global_sym_count; - -/* Count the number of global symbols multiply defined. */ -int multiple_def_count; - -/* Count the number of defined global symbols. - Each symbol is counted only once - regardless of how many different nlist entries refer to it, - since the output file will need only one nlist entry for it. - This count is computed by `digest_symbols'; - it is undefined while symbols are being loaded. */ -int defined_global_sym_count; - -/* Count the number of symbols defined through common declarations. - This count is kept in symdef_library, linear_library, and - enter_global_ref. It is incremented when the defined flag is set - in a symbol because of a common definition, and decremented when - the symbol is defined "for real" (ie. by something besides a common - definition). */ -int common_defined_global_count; - -/* Count the number of set element type symbols and the number of - separate vectors which these symbols will fit into. See the - GNU a.out.h for more info. - This count is computed by 'enter_file_symbols' */ -int set_symbol_count; -int set_vector_count; - -/* Define a linked list of strings which define symbols which should - be treated as set elements even though they aren't. Any symbol - with a prefix matching one of these should be treated as a set - element. - - This is to make up for deficiencies in many assemblers which aren't - willing to pass any stabs through to the loader which they don't - understand. */ -struct string_list_element { - char *str; - struct string_list_element *next; -}; - -struct string_list_element *set_element_prefixes; - -/* Count the number of definitions done indirectly (ie. done relative - to the value of some other symbol. */ -int global_indirect_count; - -/* Count the number of warning symbols encountered. */ -int warning_count; - -/* Total number of symbols to be written in the output file. - Computed by digest_symbols from the variables above. */ -int nsyms; - - -/* Nonzero means ptr to symbol entry for symbol to use as start addr. - -e sets this. */ -symbol *entry_symbol; - -symbol *edata_symbol; /* the symbol _edata */ -symbol *etext_symbol; /* the symbol _etext */ -symbol *end_symbol; /* the symbol _end */ - -/* Each input file, and each library member ("subfile") being loaded, - has a `file_entry' structure for it. - - For files specified by command args, these are contained in the vector - which `file_table' points to. - - For library members, they are dynamically allocated, - and chained through the `chain' field. - The chain is found in the `subfiles' field of the `file_entry'. - The `file_entry' objects for the members have `superfile' fields pointing - to the one for the library. */ - -struct file_entry { - /* Name of this file. */ - char *filename; - /* Name to use for the symbol giving address of text start */ - /* Usually the same as filename, but for a file spec'd with -l - this is the -l switch itself rather than the filename. */ - char *local_sym_name; - - /* Describe the layout of the contents of the file */ - - /* The file's a.out header. */ - struct exec header; - /* Offset in file of GDB symbol segment, or 0 if there is none. */ - int symseg_offset; - - /* Describe data from the file loaded into core */ - - /* Symbol table of the file. */ - struct nlist *symbols; - /* Size in bytes of string table. */ - int string_size; - /* Pointer to the string table. - The string table is not kept in core all the time, - but when it is in core, its address is here. */ - char *strings; - - /* Next two used only if `relocatable_output' or if needed for */ - /* output of undefined reference line numbers. */ - - /* Text reloc info saved by `write_text' for `coptxtrel'. */ - struct relocation_info *textrel; - /* Data reloc info saved by `write_data' for `copdatrel'. */ - struct relocation_info *datarel; - - /* Relation of this file's segments to the output file */ - - /* Start of this file's text seg in the output file core image. */ - int text_start_address; - /* Start of this file's data seg in the output file core image. */ - int data_start_address; - /* Start of this file's bss seg in the output file core image. */ - int bss_start_address; - /* Offset in bytes in the output file symbol table - of the first local symbol for this file. Set by `write_file_symbols'. */ - int local_syms_offset; - - /* For library members only */ - - /* For a library, points to chain of entries for the library members. */ - struct file_entry *subfiles; - /* For a library member, offset of the member within the archive. - Zero for files that are not library members. */ - int starting_offset; - /* Size of contents of this file, if library member. */ - int total_size; - /* For library member, points to the library's own entry. */ - struct file_entry *superfile; - /* For library member, points to next entry for next member. */ - struct file_entry *chain; - - /* 1 if file is a library. */ - char library_flag; - - /* 1 if file's header has been read into this structure. */ - char header_read_flag; - - /* 1 means search a set of directories for this file. */ - char search_dirs_flag; - - /* 1 means this is base file of incremental load. - Do not load this file's text or data. - Also default text_start to after this file's bss. */ - char just_syms_flag; -}; - -/* Vector of entries for input files specified by arguments. - These are all the input files except for members of specified libraries. */ -struct file_entry *file_table; - -/* Length of that vector. */ -int number_of_files; - -/* When loading the text and data, we can avoid doing a close - and another open between members of the same library. - - These two variables remember the file that is currently open. - Both are zero if no file is open. - - See `each_file' and `file_close'. */ - -struct file_entry *input_file; -int input_desc; - -/* The name of the file to write; "a.out" by default. */ - -char *output_filename; - -/* Descriptor for writing that file with `mywrite'. */ - -int outdesc; - -/* Header for that file (filled in by `write_header'). */ - -struct exec outheader; - -#ifdef COFF_ENCAPSULATE -struct coffheader coffheader; -int need_coff_header; -#endif - -/* The following are computed by `digest_symbols'. */ - -int text_size; /* total size of text of all input files. */ -int data_size; /* total size of data of all input files. */ -int bss_size; /* total size of bss of all input files. */ -int text_reloc_size; /* total size of text relocation of all input files. */ -int data_reloc_size; /* total size of data relocation of all input */ - /* files. */ - -/* Specifications of start and length of the area reserved at the end - of the text segment for the set vectors. Computed in 'digest_symbols' */ -int set_sect_start; -int set_sect_size; - -/* Pointer for in core storage for the above vectors, before they are - written. */ -unsigned long *set_vectors; - -/* Amount of cleared space to leave between the text and data segments. */ - -int text_pad; - -/* Amount of bss segment to include as part of the data segment. */ - -int data_pad; - -/* Format of __.SYMDEF: - First, a longword containing the size of the 'symdef' data that follows. - Second, zero or more 'symdef' structures. - Third, a longword containing the length of symbol name strings. - Fourth, zero or more symbol name strings (each followed by a null). */ - -struct symdef { - int symbol_name_string_index; - int library_member_offset; -}; - -/* Record most of the command options. */ - -/* Address we assume the text section will be loaded at. - We relocate symbols and text and data for this, but we do not - write any padding in the output file for it. */ -int text_start; - -/* Offset of default entry-pc within the text section. */ -int entry_offset; - -/* Address we decide the data section will be loaded at. */ -int data_start; - -/* `text-start' address is normally this much plus a page boundary. - This is not a user option; it is fixed for each system. */ -int text_start_alignment; - -/* Nonzero if -T was specified in the command line. - This prevents text_start from being set later to default values. */ -int T_flag_specified; - -/* Nonzero if -Tdata was specified in the command line. - This prevents data_start from being set later to default values. */ -int Tdata_flag_specified; - -/* Size to pad data section up to. - We simply increase the size of the data section, padding with zeros, - and reduce the size of the bss section to match. */ -int specified_data_size; - -/* Magic number to use for the output file, set by switch. */ -int magic; - -/* Nonzero means print names of input files as processed. */ -int trace_files; - -/* Which symbols should be stripped (omitted from the output): - none, all, or debugger symbols. */ -enum { STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER } strip_symbols; - -/* Which local symbols should be omitted: - none, all, or those starting with L. - This is irrelevant if STRIP_NONE. */ -enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals; - -/* Do we want to pad the text to a page boundary? */ -int padtext; - -/* 1 => write load map. */ -int write_map; - -/* 1 => write relocation into output file so can re-input it later. */ -int relocatable_output; - -/* 1 => assign space to common symbols even if `relocatable_output'. */ -int force_common_definition; - -/* Standard directories to search for files specified by -l. */ -char *standard_search_dirs[] = -#ifdef STANDARD_SEARCH_DIRS - {STANDARD_SEARCH_DIRS}; -#else -#ifdef NON_NATIVE - {"/usr/local/lib/gnu"}; -#else - {"/lib", "/usr/lib", "/usr/local/lib"}; -#endif -#endif - -/* Actual vector of directories to search; - this contains those specified with -L plus the standard ones. */ -char **search_dirs; - -/* Length of the vector `search_dirs'. */ -int n_search_dirs; - -/* Non zero means to create the output executable. */ -/* Cleared by nonfatal errors. */ -int make_executable; - -/* Force the executable to be output, even if there are non-fatal - errors */ -int force_executable; - -/* Keep a list of any symbols referenced from the command line (so - that error messages for these guys can be generated). This list is - zero terminated. */ -struct glosym **cmdline_references; -int cl_refs_allocated; - -void bcopy (), bzero (); -int malloc (), realloc (); -#ifndef alloca -int alloca (); -#endif -int free (); - -int xmalloc (); -int xrealloc (); -void fatal (); -void fatal_with_file (); -void perror_name (); -void perror_file (); -void error (); - -void digest_symbols (); -void print_symbols (); -void load_symbols (); -void decode_command (); -void list_undefined_symbols (); -void list_unresolved_references (); -void write_output (); -void write_header (); -void write_text (); -void read_file_relocation (); -void write_data (); -void write_rel (); -void write_syms (); -void write_symsegs (); -void mywrite (); -void symtab_init (); -void padfile (); -char *concat (); -char *get_file_name (); -symbol *getsym (), *getsym_soft (); - -int -main (argc, argv) - char **argv; - int argc; -{ -/* Added this to stop ld core-dumping on very large .o files. */ -#ifdef RLIMIT_STACK - /* Get rid of any avoidable limit on stack size. */ - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* RLIMIT_STACK */ - - page_size = getpagesize (); - progname = argv[0]; - - /* Clear the cumulative info on the output file. */ - - text_size = 0; - data_size = 0; - bss_size = 0; - text_reloc_size = 0; - data_reloc_size = 0; - - data_pad = 0; - text_pad = 0; - - /* Initialize the data about options. */ - - specified_data_size = 0; - strip_symbols = STRIP_NONE; - trace_files = 0; - discard_locals = DISCARD_NONE; - padtext = 0; - entry_symbol = 0; - write_map = 0; - relocatable_output = 0; - force_common_definition = 0; - T_flag_specified = 0; - Tdata_flag_specified = 0; - magic = DEFAULT_MAGIC; - make_executable = 1; - force_executable = 0; - set_element_prefixes = 0; - - /* Initialize the cumulative counts of symbols. */ - - local_sym_count = 0; - non_L_local_sym_count = 0; - debugger_sym_count = 0; - undefined_global_sym_count = 0; - set_symbol_count = 0; - set_vector_count = 0; - global_indirect_count = 0; - warning_count = 0; - multiple_def_count = 0; - common_defined_global_count = 0; - - /* Keep a list of symbols referenced from the command line */ - cl_refs_allocated = 10; - cmdline_references - = (struct glosym **) xmalloc (cl_refs_allocated - * sizeof(struct glosym *)); - *cmdline_references = 0; - - /* Completely decode ARGV. */ - - decode_command (argc, argv); - - /* Create the symbols `etext', `edata' and `end'. */ - - if (!relocatable_output) - symtab_init (); - - /* Determine whether to count the header as part of - the text size, and initialize the text size accordingly. - This depends on the kind of system and on the output format selected. */ - - N_SET_MAGIC (outheader, magic); -#ifdef INITIALIZE_HEADER - INITIALIZE_HEADER; -#endif - - text_size = sizeof (struct exec); -#ifdef COFF_ENCAPSULATE - if (relocatable_output == 0 && file_table[0].just_syms_flag == 0) - { - need_coff_header = 1; - /* set this flag now, since it will change the values of N_TXTOFF, etc */ - N_SET_FLAGS (outheader, N_FLAGS_COFF_ENCAPSULATE); - text_size += sizeof (struct coffheader); - } -#endif - - text_size -= N_TXTOFF (outheader); - - if (text_size < 0) - text_size = 0; - entry_offset = text_size; - - if (!T_flag_specified && !relocatable_output) - text_start = TEXT_START (outheader); - - /* The text-start address is normally this far past a page boundary. */ - text_start_alignment = text_start % page_size; - - /* Load symbols of all input files. - Also search all libraries and decide which library members to load. */ - - load_symbols (); - - /* Compute where each file's sections go, and relocate symbols. */ - - digest_symbols (); - - /* Print error messages for any missing symbols, for any warning - symbols, and possibly multiple definitions */ - - do_warnings (stderr); - - /* Print a map, if requested. */ - - if (write_map) print_symbols (stdout); - - /* Write the output file. */ - - if (make_executable || force_executable) - write_output (); - - exit (!make_executable); -} - -void decode_option (); - -/* Analyze a command line argument. - Return 0 if the argument is a filename. - Return 1 if the argument is a option complete in itself. - Return 2 if the argument is a option which uses an argument. - - Thus, the value is the number of consecutive arguments - that are part of options. */ - -int -classify_arg (arg) - register char *arg; -{ - if (*arg != '-') return 0; - switch (arg[1]) - { - case 'A': - case 'D': - case 'e': - case 'L': - case 'l': - case 'o': - case 'u': - case 'V': - case 'y': - if (arg[2]) - return 1; - return 2; - - case 'B': - if (! strcmp (&arg[2], "static")) - return 1; - - case 'T': - if (arg[2] == 0) - return 2; - if (! strcmp (&arg[2], "text")) - return 2; - if (! strcmp (&arg[2], "data")) - return 2; - return 1; - } - - return 1; -} - -/* Process the command arguments, - setting up file_table with an entry for each input file, - and setting variables according to the options. */ - -void -decode_command (argc, argv) - char **argv; - int argc; -{ - register int i; - register struct file_entry *p; - char *cp; - - number_of_files = 0; - output_filename = "a.out"; - - n_search_dirs = 0; - search_dirs = (char **) xmalloc (sizeof (char *)); - - /* First compute number_of_files so we know how long to make file_table. */ - /* Also process most options completely. */ - - for (i = 1; i < argc; i++) - { - register int code = classify_arg (argv[i]); - if (code) - { - if (i + code > argc) - fatal ("no argument following %s\n", argv[i]); - - decode_option (argv[i], argv[i+1]); - - if (argv[i][1] == 'l' || argv[i][1] == 'A') - number_of_files++; - - i += code - 1; - } - else - number_of_files++; - } - - if (!number_of_files) - fatal ("no input files", 0); - - p = file_table - = (struct file_entry *) xmalloc (number_of_files * sizeof (struct file_entry)); - bzero (p, number_of_files * sizeof (struct file_entry)); - - /* Now scan again and fill in file_table. */ - /* All options except -A and -l are ignored here. */ - - for (i = 1; i < argc; i++) - { - register int code = classify_arg (argv[i]); - - if (code) - { - char *string; - if (code == 2) - string = argv[i+1]; - else - string = &argv[i][2]; - - if (argv[i][1] == 'A') - { - if (p != file_table) - fatal ("-A specified before an input file other than the first"); - - p->filename = string; - p->local_sym_name = string; - p->just_syms_flag = 1; - p++; - } - if (argv[i][1] == 'l') - { - if (cp = rindex(string, '/')) - { - *cp++ = '\0'; - cp = concat (string, "/lib", cp); - p->filename = concat (cp, ".a", ""); - } - else - p->filename = concat ("lib", string, ".a"); - - p->local_sym_name = concat ("-l", string, ""); - p->search_dirs_flag = 1; - p++; - } - i += code - 1; - } - else - { - p->filename = argv[i]; - p->local_sym_name = argv[i]; - p++; - } - } - - /* Now check some option settings for consistency. */ - -#ifdef NMAGIC - if ((magic == ZMAGIC || magic == NMAGIC) -#else - if ((magic == ZMAGIC) -#endif - && (text_start - text_start_alignment) & (page_size - 1)) - fatal ("-T argument not multiple of page size, with sharable output", 0); - - /* Append the standard search directories to the user-specified ones. */ - { - int n = sizeof standard_search_dirs / sizeof standard_search_dirs[0]; - n_search_dirs += n; - search_dirs - = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *)); - bcopy (standard_search_dirs, &search_dirs[n_search_dirs - n], - n * sizeof (char *)); - } -} - - -void -add_cmdline_ref (sp) - struct glosym *sp; -{ - struct glosym **ptr; - - for (ptr = cmdline_references; - ptr < cmdline_references + cl_refs_allocated && *ptr; - ptr++) - ; - - if (ptr >= cmdline_references + cl_refs_allocated - 1) - { - int diff = ptr - cmdline_references; - - cl_refs_allocated *= 2; - cmdline_references = (struct glosym **) - xrealloc (cmdline_references, - cl_refs_allocated * sizeof (struct glosym *)); - ptr = cmdline_references + diff; - } - - *ptr++ = sp; - *ptr = (struct glosym *) 0; -} - -int -set_element_prefixed_p (name) - char *name; -{ - struct string_list_element *p; - int i; - - for (p = set_element_prefixes; p; p = p->next) - { - for (i = 0; p->str[i] != '\0' && (p->str[i] == name[i]); i++) - ; - - if (p->str[i] == '\0') - return 1; - } - return 0; -} - -int parse (); - -/* Record an option and arrange to act on it later. - ARG should be the following command argument, - which may or may not be used by this option. - - The `l' and `A' options are ignored here since they actually - specify input files. */ - -void -decode_option (swt, arg) - register char *swt, *arg; -{ - /* We get Bstatic from gcc on suns. */ - if (! strcmp (swt + 1, "Bstatic")) - return; - if (! strcmp (swt + 1, "Ttext")) - { - text_start = parse (arg, "%x", "invalid argument to -Ttext"); - T_flag_specified = 1; - return; - } - if (! strcmp (swt + 1, "Tdata")) - { - data_start = parse (arg, "%x", "invalid argument to -Tdata"); - Tdata_flag_specified = 1; - return; - } - if (! strcmp (swt + 1, "noinhibit-exec")) - { - force_executable = 1; - return; - } - - if (swt[2] != 0) - arg = &swt[2]; - - switch (swt[1]) - { - case 'A': - return; - - case 'D': - specified_data_size = parse (arg, "%x", "invalid argument to -D"); - return; - - case 'd': - force_common_definition = 1; - return; - - case 'e': - entry_symbol = getsym (arg); - if (!entry_symbol->defined && !entry_symbol->referenced) - undefined_global_sym_count++; - entry_symbol->referenced = 1; - add_cmdline_ref (entry_symbol); - return; - - case 'l': - /* If linking with libg++, use the C++ demangler. */ - if (arg != NULL && strcmp (arg, "g++") == 0) - demangler = cplus_demangle; - return; - - case 'L': - n_search_dirs++; - search_dirs - = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *)); - search_dirs[n_search_dirs - 1] = arg; - return; - - case 'M': - write_map = 1; - return; - - case 'N': - magic = OMAGIC; - return; - -#ifdef NMAGIC - case 'n': - magic = NMAGIC; - return; -#endif - - case 'o': - output_filename = arg; - return; - - case 'p': - padtext = 1; - return; - - case 'r': - relocatable_output = 1; - magic = OMAGIC; - text_start = 0; - return; - - case 'S': - strip_symbols = STRIP_DEBUGGER; - return; - - case 's': - strip_symbols = STRIP_ALL; - return; - - case 'T': - text_start = parse (arg, "%x", "invalid argument to -T"); - T_flag_specified = 1; - return; - - case 't': - trace_files = 1; - return; - - case 'u': - { - register symbol *sp = getsym (arg); - if (!sp->defined && !sp->referenced) - undefined_global_sym_count++; - sp->referenced = 1; - add_cmdline_ref (sp); - } - return; - - case 'V': - { - struct string_list_element *new - = (struct string_list_element *) - xmalloc (sizeof (struct string_list_element)); - - new->str = arg; - new->next = set_element_prefixes; - set_element_prefixes = new; - return; - } - - case 'X': - discard_locals = DISCARD_L; - return; - - case 'x': - discard_locals = DISCARD_ALL; - return; - - case 'y': - { - register symbol *sp = getsym (&swt[2]); - sp->trace = 1; - } - return; - - case 'z': - magic = ZMAGIC; - return; - - default: - fatal ("invalid command option `%s'", swt); - } -} - -/** Convenient functions for operating on one or all files being */ - /** loaded. */ -void print_file_name (); - -/* Call FUNCTION on each input file entry. - Do not call for entries for libraries; - instead, call once for each library member that is being loaded. - - FUNCTION receives two arguments: the entry, and ARG. */ - -void -each_file (function, arg) - register void (*function)(); - register int arg; -{ - register int i; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - (*function) (subentry, arg); - } - else - (*function) (entry, arg); - } -} - -/* Call FUNCTION on each input file entry until it returns a non-zero - value. Return this value. - Do not call for entries for libraries; - instead, call once for each library member that is being loaded. - - FUNCTION receives two arguments: the entry, and ARG. It must be a - function returning unsigned long (though this can probably be fudged). */ - -unsigned long -check_each_file (function, arg) - register unsigned long (*function)(); - register int arg; -{ - register int i; - register unsigned long return_val; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - if (return_val = (*function) (subentry, arg)) - return return_val; - } - else - if (return_val = (*function) (entry, arg)) - return return_val; - } - return 0; -} - -/* Like `each_file' but ignore files that were just for symbol definitions. */ - -void -each_full_file (function, arg) - register void (*function)(); - register int arg; -{ - register int i; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->just_syms_flag) - continue; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - (*function) (subentry, arg); - } - else - (*function) (entry, arg); - } -} - -/* Close the input file that is now open. */ - -void -file_close () -{ - close (input_desc); - input_desc = 0; - input_file = 0; -} - -/* Open the input file specified by 'entry', and return a descriptor. - The open file is remembered; if the same file is opened twice in a row, - a new open is not actually done. */ - -int -file_open (entry) - register struct file_entry *entry; -{ - register int desc; - - if (entry->superfile) - return file_open (entry->superfile); - - if (entry == input_file) - return input_desc; - - if (input_file) file_close (); - - if (entry->search_dirs_flag) - { - int i; - - for (i = 0; i < n_search_dirs; i++) - { - register char *string - = concat (search_dirs[i], "/", entry->filename); - desc = open (string, O_RDONLY, 0); - if (desc > 0) - { - entry->filename = string; - entry->search_dirs_flag = 0; - break; - } - free (string); - } - } - else - desc = open (entry->filename, O_RDONLY, 0); - - if (desc > 0) - { - input_file = entry; - input_desc = desc; - return desc; - } - - perror_file (entry); - /* NOTREACHED */ -} - -/* Print the filename of ENTRY on OUTFILE (a stdio stream), - and then a newline. */ - -void -prline_file_name (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - print_file_name (entry, outfile); - fprintf (outfile, "\n"); -} - -/* Print the filename of ENTRY on OUTFILE (a stdio stream). */ - -void -print_file_name (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - if (entry->superfile) - { - print_file_name (entry->superfile, outfile); - fprintf (outfile, "(%s)", entry->filename); - } - else - fprintf (outfile, "%s", entry->filename); -} - -/* Return the filename of entry as a string (malloc'd for the purpose) */ - -char * -get_file_name (entry) - struct file_entry *entry; -{ - char *result, *supfile; - if (entry->superfile) - { - supfile = get_file_name (entry->superfile); - result = (char *) xmalloc (strlen (supfile) - + strlen (entry->filename) + 3); - sprintf (result, "%s(%s)", supfile, entry->filename); - free (supfile); - } - else - { - result = (char *) xmalloc (strlen (entry->filename) + 1); - strcpy (result, entry->filename); - } - return result; -} - -/* Medium-level input routines for rel files. */ - -/* Read a file's header into the proper place in the file_entry. - DESC is the descriptor on which the file is open. - ENTRY is the file's entry. */ - -void -read_header (desc, entry) - int desc; - register struct file_entry *entry; -{ - register int len; - struct exec *loc = (struct exec *) &entry->header; - - lseek (desc, entry->starting_offset, 0); -#ifdef COFF_ENCAPSULATE - if (entry->just_syms_flag) - lseek (desc, sizeof(coffheader), 1); -#endif - len = read (desc, loc, sizeof (struct exec)); - if (len != sizeof (struct exec)) - fatal_with_file ("failure reading header of ", entry); - if (N_BADMAG (*loc)) - fatal_with_file ("bad magic number in ", entry); - - entry->header_read_flag = 1; -} - -/* Read the symbols of file ENTRY into core. - Assume it is already open, on descriptor DESC. - Also read the length of the string table, which follows the symbol table, - but don't read the contents of the string table. */ - -void -read_entry_symbols (desc, entry) - struct file_entry *entry; - int desc; -{ - int str_size; - - if (!entry->header_read_flag) - read_header (desc, entry); - - entry->symbols = (struct nlist *) xmalloc (entry->header.a_syms); - - lseek (desc, N_SYMOFF (entry->header) + entry->starting_offset, 0); - if (entry->header.a_syms != read (desc, entry->symbols, entry->header.a_syms)) - fatal_with_file ("premature end of file in symbols of ", entry); - - lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0); - if (sizeof str_size != read (desc, &str_size, sizeof str_size)) - fatal_with_file ("bad string table size in ", entry); - - entry->string_size = str_size; -} - -/* Read the string table of file ENTRY into core. - Assume it is already open, on descriptor DESC. - Also record whether a GDB symbol segment follows the string table. */ - -void -read_entry_strings (desc, entry) - struct file_entry *entry; - int desc; -{ - int buffer; - - if (!entry->header_read_flag) - read_header (desc, entry); - - lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0); - if (entry->string_size != read (desc, entry->strings, entry->string_size)) - fatal_with_file ("premature end of file in strings of ", entry); - - /* While we are here, see if the file has a symbol segment at the end. - For a separate file, just try reading some more. - For a library member, compare current pos against total size. */ - if (entry->superfile) - { - if (entry->total_size == N_STROFF (entry->header) + entry->string_size) - return; - } - else - { - buffer = read (desc, &buffer, sizeof buffer); - if (buffer == 0) - return; - if (buffer != sizeof buffer) - fatal_with_file ("premature end of file in GDB symbol segment of ", entry); - } - /* Don't try to do anything with symsegs. */ - return; -#if 0 - /* eliminate warning of `statement not reached'. */ - entry->symseg_offset = N_STROFF (entry->header) + entry->string_size; -#endif -} - -/* Read in the symbols of all input files. */ - -void read_file_symbols (), read_entry_symbols (), read_entry_strings (); -void enter_file_symbols (), enter_global_ref (), search_library (); - -void -load_symbols () -{ - register int i; - - if (trace_files) fprintf (stderr, "Loading symbols:\n\n"); - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - read_file_symbols (entry); - } - - if (trace_files) fprintf (stderr, "\n"); -} - -/* If ENTRY is a rel file, read its symbol and string sections into core. - If it is a library, search it and load the appropriate members - (which means calling this function recursively on those members). */ - -void -read_file_symbols (entry) - register struct file_entry *entry; -{ - register int desc; - register int len; - struct exec hdr; - - desc = file_open (entry); - -#ifdef COFF_ENCAPSULATE - if (entry->just_syms_flag) - lseek (desc, sizeof(coffheader),0); -#endif - - len = read (desc, &hdr, sizeof hdr); - if (len != sizeof hdr) - fatal_with_file ("failure reading header of ", entry); - - if (!N_BADMAG (hdr)) - { - read_entry_symbols (desc, entry); - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (desc, entry); - enter_file_symbols (entry); - entry->strings = 0; - } - else - { - char armag[SARMAG]; - - lseek (desc, 0, 0); - if (SARMAG != read (desc, armag, SARMAG) || strncmp (armag, ARMAG, SARMAG)) - fatal_with_file ("malformed input file (not rel or archive) ", entry); - entry->library_flag = 1; - search_library (desc, entry); - } - - file_close (); -} - -/* Enter the external symbol defs and refs of ENTRY in the hash table. */ - -void -enter_file_symbols (entry) - struct file_entry *entry; -{ - register struct nlist - *p, - *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - if (trace_files) prline_file_name (entry, stderr); - - for (p = entry->symbols; p < end; p++) - { - if (p->n_type == (N_SETV | N_EXT)) continue; - if (set_element_prefixes - && set_element_prefixed_p (p->n_un.n_strx + entry->strings)) - p->n_type += (N_SETA - N_ABS); - - if (SET_ELEMENT_P (p->n_type)) - { - set_symbol_count++; - if (!relocatable_output) - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - } - else if (p->n_type == N_WARNING) - { - char *name = p->n_un.n_strx + entry->strings; - - /* Grab the next entry. */ - p++; - if (p->n_type != (N_UNDF | N_EXT)) - { - fprintf (stderr, "%s: Warning symbol found in %s without external reference following.\n", - progname, entry->filename); - make_executable = 0; - p--; /* Process normally. */ - } - else - { - symbol *sp; - char *sname = p->n_un.n_strx + entry->strings; - /* Deal with the warning symbol. */ - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - sp = getsym (sname); - sp->warning = (char *) xmalloc (strlen(name) + 1); - strcpy (sp->warning, name); - warning_count++; - } - } - else if (p->n_type & N_EXT) - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - else if (p->n_un.n_strx && !(p->n_type & (N_STAB | N_EXT))) - { - if ((p->n_un.n_strx + entry->strings)[0] != LPREFIX) - non_L_local_sym_count++; - local_sym_count++; - } - else debugger_sym_count++; - } - - /* Count one for the local symbol that we generate, - whose name is the file's name (usually) and whose address - is the start of the file's text. */ - - local_sym_count++; - non_L_local_sym_count++; -} - -/* Enter one global symbol in the hash table. - NLIST_P points to the `struct nlist' read from the file - that describes the global symbol. NAME is the symbol's name. - ENTRY is the file entry for the file the symbol comes from. - - The `struct nlist' is modified by placing it on a chain of - all such structs that refer to the same global symbol. - This chain starts in the `refs' field of the symbol table entry - and is chained through the `n_name'. */ - -void -enter_global_ref (nlist_p, name, entry) - register struct nlist *nlist_p; - char *name; - struct file_entry *entry; -{ - register symbol *sp = getsym (name); - register int type = nlist_p->n_type; - int oldref = sp->referenced; - int olddef = sp->defined; - int com = sp->defined && sp->max_common_size; - - nlist_p->n_un.n_name = (char *) sp->refs; - sp->refs = nlist_p; - - sp->referenced = 1; - if (type != (N_UNDF | N_EXT) || nlist_p->n_value) - { - if (!sp->defined || sp->defined == (N_UNDF | N_EXT)) - sp->defined = type; - - if (oldref && !olddef) - /* It used to be undefined and we're defining it. */ - undefined_global_sym_count--; - - if (!olddef && type == (N_UNDF | N_EXT) && nlist_p->n_value) - { - /* First definition and it's common. */ - common_defined_global_count++; - sp->max_common_size = nlist_p->n_value; - } - else if (com && type != (N_UNDF | N_EXT)) - { - /* It used to be common and we're defining it as - something else. */ - common_defined_global_count--; - sp->max_common_size = 0; - } - else if (com && type == (N_UNDF | N_EXT) - && sp->max_common_size < nlist_p->n_value) - /* It used to be common and this is a new common entry to - which we need to pay attention. */ - sp->max_common_size = nlist_p->n_value; - - /* Are we defining it as a set element? */ - if (SET_ELEMENT_P (type) && (!olddef || com)) - set_vector_count++; - /* As an indirection? */ - else if (type == (N_INDR | N_EXT)) - { - /* Indirect symbols value should be modified to point - a symbol being equivalenced to. */ - nlist_p->n_value - = (unsigned int) getsym ((nlist_p + 1)->n_un.n_strx - + entry->strings); - if ((symbol *) nlist_p->n_value == sp) - { - /* Somebody redefined a symbol to be itself. */ - fprintf (stderr, "%s: Symbol %s indirected to itself.\n", - entry->filename, name); - /* Rewrite this symbol as being a global text symbol - with value 0. */ - nlist_p->n_type = sp->defined = N_TEXT | N_EXT; - nlist_p->n_value = 0; - /* Don't make the output executable. */ - make_executable = 0; - } - else - global_indirect_count++; - } - } - else - if (!oldref) -#ifndef DOLLAR_KLUDGE - undefined_global_sym_count++; -#else - { - if (entry->superfile && type == (N_UNDF | N_EXT) && name[1] == '$') - { - /* This is an (ISI?) $-conditional; skip it */ - sp->referenced = 0; - if (sp->trace) - { - fprintf (stderr, "symbol %s is a $-conditional ignored in ", sp->name); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - } - return; - } - else - undefined_global_sym_count++; - } -#endif - - if (sp == end_symbol && entry->just_syms_flag && !T_flag_specified) - text_start = nlist_p->n_value; - - if (sp->trace) - { - register char *reftype; - switch (type & N_TYPE) - { - case N_UNDF: - if (nlist_p->n_value) - reftype = "defined as common"; - else reftype = "referenced"; - break; - - case N_ABS: - reftype = "defined as absolute"; - break; - - case N_TEXT: - reftype = "defined in text section"; - break; - - case N_DATA: - reftype = "defined in data section"; - break; - - case N_BSS: - reftype = "defined in BSS section"; - break; - - case N_SETT: - reftype = "is a text set element"; - break; - - case N_SETD: - reftype = "is a data set element"; - break; - - case N_SETB: - reftype = "is a BSS set element"; - break; - - case N_SETA: - reftype = "is an absolute set element"; - break; - - case N_SETV: - reftype = "defined in data section as vector"; - break; - - case N_INDR: - reftype = (char *) alloca (23 - + strlen ((nlist_p + 1)->n_un.n_strx - + entry->strings)); - sprintf (reftype, "defined equivalent to %s", - (nlist_p + 1)->n_un.n_strx + entry->strings); - break; - -#ifdef sequent - case N_SHUNDF: - reftype = "shared undf"; - break; - -/* These conflict with cases above. - case N_SHDATA: - reftype = "shared data"; - break; - - case N_SHBSS: - reftype = "shared BSS"; - break; -*/ - default: - reftype = "I don't know this type"; - break; -#endif - } - - fprintf (stderr, "symbol %s %s in ", sp->name, reftype); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - } -} - -/* This return 0 if the given file entry's symbol table does *not* - contain the nlist point entry, and it returns the files entry - pointer (cast to unsigned long) if it does. */ - -unsigned long -contains_symbol (entry, n_ptr) - struct file_entry *entry; - register struct nlist *n_ptr; -{ - if (n_ptr >= entry->symbols && - n_ptr < (entry->symbols - + (entry->header.a_syms / sizeof (struct nlist)))) - return (unsigned long) entry; - return 0; -} - - -/* Searching libraries */ - -struct file_entry *decode_library_subfile (); -void linear_library (), symdef_library (); - -/* Search the library ENTRY, already open on descriptor DESC. - This means deciding which library members to load, - making a chain of `struct file_entry' for those members, - and entering their global symbols in the hash table. */ - -void -search_library (desc, entry) - int desc; - struct file_entry *entry; -{ - int member_length; - register char *name; - register struct file_entry *subentry; - - if (!undefined_global_sym_count) return; - - /* Examine its first member, which starts SARMAG bytes in. */ - subentry = decode_library_subfile (desc, entry, SARMAG, &member_length); - if (!subentry) return; - - name = subentry->filename; - free (subentry); - - /* Search via __.SYMDEF if that exists, else linearly. */ - - if (!strcmp (name, "__.SYMDEF")) - symdef_library (desc, entry, member_length); - else - linear_library (desc, entry); -} - -/* Construct and return a file_entry for a library member. - The library's file_entry is library_entry, and the library is open on DESC. - SUBFILE_OFFSET is the byte index in the library of this member's header. - We store the length of the member into *LENGTH_LOC. */ - -struct file_entry * -decode_library_subfile (desc, library_entry, subfile_offset, length_loc) - int desc; - struct file_entry *library_entry; - int subfile_offset; - int *length_loc; -{ - int bytes_read; - register int namelen; - int member_length; - register char *name; - struct ar_hdr hdr1; - register struct file_entry *subentry; - - lseek (desc, subfile_offset, 0); - - bytes_read = read (desc, &hdr1, sizeof hdr1); - if (!bytes_read) - return 0; /* end of archive */ - - if (sizeof hdr1 != bytes_read) - fatal_with_file ("malformed library archive ", library_entry); - - if (sscanf (hdr1.ar_size, "%d", &member_length) != 1) - fatal_with_file ("malformatted header of archive member in ", library_entry); - - subentry = (struct file_entry *) xmalloc (sizeof (struct file_entry)); - bzero (subentry, sizeof (struct file_entry)); - - for (namelen = 0; - namelen < sizeof hdr1.ar_name - && hdr1.ar_name[namelen] != 0 && hdr1.ar_name[namelen] != ' ' - && hdr1.ar_name[namelen] != '/'; - namelen++); - - name = (char *) xmalloc (namelen+1); - strncpy (name, hdr1.ar_name, namelen); - name[namelen] = 0; - - subentry->filename = name; - subentry->local_sym_name = name; - subentry->symbols = 0; - subentry->strings = 0; - subentry->subfiles = 0; - subentry->starting_offset = subfile_offset + sizeof hdr1; - subentry->superfile = library_entry; - subentry->library_flag = 0; - subentry->header_read_flag = 0; - subentry->just_syms_flag = 0; - subentry->chain = 0; - subentry->total_size = member_length; - - (*length_loc) = member_length; - - return subentry; -} - -int subfile_wanted_p (); - -/* Search a library that has a __.SYMDEF member. - DESC is a descriptor on which the library is open. - The file pointer is assumed to point at the __.SYMDEF data. - ENTRY is the library's file_entry. - MEMBER_LENGTH is the length of the __.SYMDEF data. */ - -void -symdef_library (desc, entry, member_length) - int desc; - struct file_entry *entry; - int member_length; -{ - int *symdef_data = (int *) xmalloc (member_length); - register struct symdef *symdef_base; - char *sym_name_base; - int number_of_symdefs; - int length_of_strings; - int not_finished; - int bytes_read; - register int i; - struct file_entry *prev = 0; - int prev_offset = 0; - - bytes_read = read (desc, symdef_data, member_length); - if (bytes_read != member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - number_of_symdefs = *symdef_data / sizeof (struct symdef); - if (number_of_symdefs < 0 || - number_of_symdefs * sizeof (struct symdef) + 2 * sizeof (int) > member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - symdef_base = (struct symdef *) (symdef_data + 1); - length_of_strings = *(int *) (symdef_base + number_of_symdefs); - - if (length_of_strings < 0 - || number_of_symdefs * sizeof (struct symdef) + length_of_strings - + 2 * sizeof (int) > member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - sym_name_base = sizeof (int) + (char *) (symdef_base + number_of_symdefs); - - /* Check all the string indexes for validity. */ - - for (i = 0; i < number_of_symdefs; i++) - { - register int index = symdef_base[i].symbol_name_string_index; - if (index < 0 || index >= length_of_strings - || (index && *(sym_name_base + index - 1))) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - } - - /* Search the symdef data for members to load. - Do this until one whole pass finds nothing to load. */ - - not_finished = 1; - while (not_finished) - { - not_finished = 0; - - /* Scan all the symbols mentioned in the symdef for ones that we need. - Load the library members that contain such symbols. */ - - for (i = 0; - (i < number_of_symdefs - && (undefined_global_sym_count || common_defined_global_count)); - i++) - if (symdef_base[i].symbol_name_string_index >= 0) - { - register symbol *sp; - - sp = getsym_soft (sym_name_base - + symdef_base[i].symbol_name_string_index); - - /* If we find a symbol that appears to be needed, think carefully - about the archive member that the symbol is in. */ - - /* - * Per Mike Karels' recommendation, we no longer load library - * files if the only reference(s) that would be satisfied are - * 'common' references. This prevents some problems with name - * pollution (e.g. a global common 'utime' linked to a function). - */ - if (sp && sp->referenced && !sp->defined) - { - int junk; - register int j; - register int offset = symdef_base[i].library_member_offset; - struct file_entry *subentry; - - /* Don't think carefully about any archive member - more than once in a given pass. */ - - if (prev_offset == offset) - continue; - prev_offset = offset; - - /* Read the symbol table of the archive member. */ - - subentry = decode_library_subfile (desc, entry, offset, &junk); - if (subentry == 0) - fatal ("invalid offset for %s in symbol table of %s", - sym_name_base - + symdef_base[i].symbol_name_string_index, - entry->filename); - read_entry_symbols (desc, subentry); - subentry->strings = (char *) malloc (subentry->string_size); - read_entry_strings (desc, subentry); - - /* Now scan the symbol table and decide whether to load. */ - - if (!subfile_wanted_p (subentry)) - { - free (subentry->symbols); - free (subentry); - } - else - { - /* This member is needed; load it. - Since we are loading something on this pass, - we must make another pass through the symdef data. */ - - not_finished = 1; - - enter_file_symbols (subentry); - - if (prev) - prev->chain = subentry; - else entry->subfiles = subentry; - prev = subentry; - - /* Clear out this member's symbols from the symdef data - so that following passes won't waste time on them. */ - - for (j = 0; j < number_of_symdefs; j++) - { - if (symdef_base[j].library_member_offset == offset) - symdef_base[j].symbol_name_string_index = -1; - } - } - - /* We'll read the strings again if we need them again. */ - free (subentry->strings); - subentry->strings = 0; - } - } - } - - free (symdef_data); -} - -/* Search a library that has no __.SYMDEF. - ENTRY is the library's file_entry. - DESC is the descriptor it is open on. */ - -void -linear_library (desc, entry) - int desc; - struct file_entry *entry; -{ - register struct file_entry *prev = 0; - register int this_subfile_offset = SARMAG; - - while (undefined_global_sym_count || common_defined_global_count) - { - int member_length; - register struct file_entry *subentry; - - subentry = decode_library_subfile (desc, entry, this_subfile_offset, - &member_length); - - if (!subentry) return; - - read_entry_symbols (desc, subentry); - subentry->strings = (char *) alloca (subentry->string_size); - read_entry_strings (desc, subentry); - - if (!subfile_wanted_p (subentry)) - { - free (subentry->symbols); - free (subentry); - } - else - { - enter_file_symbols (subentry); - - if (prev) - prev->chain = subentry; - else entry->subfiles = subentry; - prev = subentry; - subentry->strings = 0; /* Since space will dissapear on return */ - } - - this_subfile_offset += member_length + sizeof (struct ar_hdr); - if (this_subfile_offset & 1) this_subfile_offset++; - } -} - -/* ENTRY is an entry for a library member. - Its symbols have been read into core, but not entered. - Return nonzero if we ought to load this member. */ - -int -subfile_wanted_p (entry) - struct file_entry *entry; -{ - register struct nlist *p; - register struct nlist *end - = entry->symbols + entry->header.a_syms / sizeof (struct nlist); -#ifdef DOLLAR_KLUDGE - register int dollar_cond = 0; -#endif - - for (p = entry->symbols; p < end; p++) - { - register int type = p->n_type; - register char *name = p->n_un.n_strx + entry->strings; - - /* If the symbol has an interesting definition, we could - potentially want it. */ - if (type & N_EXT - && (type != (N_UNDF | N_EXT) || p->n_value - -#ifdef DOLLAR_KLUDGE - || name[1] == '$' -#endif - ) - && !SET_ELEMENT_P (type) - && !set_element_prefixed_p (name)) - { - register symbol *sp = getsym_soft (name); - -#ifdef DOLLAR_KLUDGE - if (name[1] == '$') - { - sp = getsym_soft (&name[2]); - dollar_cond = 1; - if (!sp) continue; - if (sp->referenced) - { - if (write_map) - { - print_file_name (entry, stdout); - fprintf (stdout, " needed due to $-conditional %s\n", name); - } - return 1; - } - continue; - } -#endif - - /* If this symbol has not been hashed, we can't be looking for it. */ - - if (!sp) continue; - - /* - * We don't load a file if it merely satisfies a common reference - * (see explanation above in symdef_library()). - */ - if (sp->referenced && !sp->defined) - { - /* This is a symbol we are looking for. It is either - not yet defined or defined as a common. */ -#ifdef DOLLAR_KLUDGE - if (dollar_cond) continue; -#endif - if (type == (N_UNDF | N_EXT)) - { - /* Symbol being defined as common. - Remember this, but don't load subfile just for this. */ - - /* If it didn't used to be common, up the count of - common symbols. */ - if (!sp->max_common_size) - common_defined_global_count++; - - if (sp->max_common_size < p->n_value) - sp->max_common_size = p->n_value; - if (!sp->defined) - undefined_global_sym_count--; - sp->defined = 1; - continue; - } - - if (write_map) - { - print_file_name (entry, stdout); - fprintf (stdout, " needed due to %s\n", sp->name); - } - return 1; - } - } - } - - return 0; -} - -void consider_file_section_lengths (), relocate_file_addresses (); - -/* Having entered all the global symbols and found the sizes of sections - of all files to be linked, make all appropriate deductions from this data. - - We propagate global symbol values from definitions to references. - We compute the layout of the output file and where each input file's - contents fit into it. */ - -void -digest_symbols () -{ - register int i; - int setv_fill_count; - - if (trace_files) - fprintf (stderr, "Digesting symbol information:\n\n"); - - /* Compute total size of sections */ - - each_file (consider_file_section_lengths, 0); - - /* If necessary, pad text section to full page in the file. - Include the padding in the text segment size. */ - - if (magic == ZMAGIC) - { - int text_end = text_size + N_TXTOFF (outheader); - text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; - text_size += text_pad; - } - if (padtext) - { - int text_end = text_size; - text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; - text_size += text_pad; - } - -#ifdef _N_BASEADDR - /* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */ - outheader.a_entry = N_PAGSIZ (outheader); -#endif - - outheader.a_text = text_size; -#ifdef sequent - outheader.a_text += N_ADDRADJ (outheader); -#endif - - /* Make the data segment address start in memory on a suitable boundary. */ - - if (! Tdata_flag_specified) - data_start = N_DATADDR (outheader) + text_start - TEXT_START (outheader); - - /* Set up the set element vector */ - - if (!relocatable_output) - { - /* The set sector size is the number of set elements + a word - for each symbol for the length word at the beginning of the - vector, plus a word for each symbol for a zero at the end of - the vector (for incremental linking). */ - set_sect_size - = (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long); - set_sect_start = data_start + data_size; - data_size += set_sect_size; - set_vectors = (unsigned long *) xmalloc (set_sect_size); - setv_fill_count = 0; - } - - /* Compute start addresses of each file's sections and symbols. */ - - each_full_file (relocate_file_addresses, 0); - - /* Now, for each symbol, verify that it is defined globally at most once. - Put the global value into the symbol entry. - Common symbols are allocated here, in the BSS section. - Each defined symbol is given a '->defined' field - which is the correct N_ code for its definition, - except in the case of common symbols with -r. - Then make all the references point at the symbol entry - instead of being chained together. */ - - defined_global_sym_count = 0; - - for (i = 0; i < TABSIZE; i++) - { - register symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - { - /* For each symbol */ - register struct nlist *p, *next; - int defs = 0, com = sp->max_common_size; - struct nlist *first_definition; - for (p = sp->refs; p; p = next) - { - register int type = p->n_type; - - if (SET_ELEMENT_P (type)) - { - if (relocatable_output) - fatal ("internal: global ref to set element with -r"); - if (!defs++) - { - sp->value = set_sect_start - + setv_fill_count++ * sizeof (unsigned long); - sp->defined = N_SETV | N_EXT; - first_definition = p; - } - else if ((sp->defined & ~N_EXT) != N_SETV) - { - sp->multiply_defined = 1; - multiple_def_count++; - } - set_vectors[setv_fill_count++] = p->n_value; - } - else if ((type & N_EXT) && type != (N_UNDF | N_EXT)) - { - /* non-common definition */ - if (defs++ && sp->value != p->n_value) - { - sp->multiply_defined = 1; - multiple_def_count++; - } - sp->value = p->n_value; - sp->defined = type; - first_definition = p; - } - next = (struct nlist *) p->n_un.n_name; - p->n_un.n_name = (char *) sp; - } - /* Allocate as common if defined as common and not defined for real */ - if (com && !defs) - { - if (!relocatable_output || force_common_definition) - { - int align = sizeof (int); - - /* Round up to nearest sizeof (int). I don't know - whether this is necessary or not (given that - alignment is taken care of later), but it's - traditional, so I'll leave it in. Note that if - this size alignment is ever removed, ALIGN above - will have to be initialized to 1 instead of - sizeof (int). */ - - com = (com + sizeof (int) - 1) & (- sizeof (int)); - - while (!(com & align)) - align <<= 1; - - align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align; - - bss_size = ((((bss_size + data_size + data_start) - + (align - 1)) & (- align)) - - data_size - data_start); - - sp->value = data_start + data_size + bss_size; - sp->defined = N_BSS | N_EXT; - bss_size += com; - if (write_map) - printf ("Allocating common %s: %x at %x\n", - sp->name, com, sp->value); - } - else - { - sp->defined = 0; - undefined_global_sym_count++; - } - } - /* Set length word at front of vector and zero byte at end. - Reverse the vector itself to put it in file order. */ - if ((sp->defined & ~N_EXT) == N_SETV) - { - unsigned long length_word_index - = (sp->value - set_sect_start) / sizeof (unsigned long); - unsigned long i, tmp; - - set_vectors[length_word_index] - = setv_fill_count - 1 - length_word_index; - - /* Reverse the vector. */ - for (i = 1; - i < (setv_fill_count - length_word_index - 1) / 2 + 1; - i++) - { - tmp = set_vectors[length_word_index + i]; - set_vectors[length_word_index + i] - = set_vectors[setv_fill_count - i]; - set_vectors[setv_fill_count - i] = tmp; - } - - set_vectors[setv_fill_count++] = 0; - } - if (sp->defined) - defined_global_sym_count++; - } - } - - if (end_symbol) /* These are null if -r. */ - { - etext_symbol->value = text_size + text_start; - edata_symbol->value = data_start + data_size; - end_symbol->value = data_start + data_size + bss_size; - } - - /* Figure the data_pad now, so that it overlaps with the bss addresses. */ - - if (specified_data_size && specified_data_size > data_size) - data_pad = specified_data_size - data_size; - - if (magic == ZMAGIC) - data_pad = ((data_pad + data_size + page_size - 1) & (- page_size)) - - data_size; - - bss_size -= data_pad; - if (bss_size < 0) bss_size = 0; - - data_size += data_pad; -} - -/* Accumulate the section sizes of input file ENTRY - into the section sizes of the output file. */ - -void -consider_file_section_lengths (entry) - register struct file_entry *entry; -{ - if (entry->just_syms_flag) - return; - - entry->text_start_address = text_size; - /* If there were any vectors, we need to chop them off */ - text_size += entry->header.a_text; - entry->data_start_address = data_size; - data_size += entry->header.a_data; - entry->bss_start_address = bss_size; - bss_size += entry->header.a_bss; - - text_reloc_size += entry->header.a_trsize; - data_reloc_size += entry->header.a_drsize; -} - -/* Determine where the sections of ENTRY go into the output file, - whose total section sizes are already known. - Also relocate the addresses of the file's local and debugger symbols. */ - -void -relocate_file_addresses (entry) - register struct file_entry *entry; -{ - entry->text_start_address += text_start; - /* Note that `data_start' and `data_size' have not yet been - adjusted for `data_pad'. If they had been, we would get the wrong - results here. */ - entry->data_start_address += data_start; - entry->bss_start_address += data_start + data_size; - - { - register struct nlist *p; - register struct nlist *end - = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - for (p = entry->symbols; p < end; p++) - { - /* If this belongs to a section, update it by the section's start address */ - register int type = p->n_type & N_TYPE; - - switch (type) - { - case N_TEXT: - case N_SETT: - p->n_value += entry->text_start_address; - break; - case N_DATA: - case N_SETV: - case N_SETD: - /* A symbol whose value is in the data section - is present in the input file as if the data section - started at an address equal to the length of the file's text. */ - p->n_value += entry->data_start_address - entry->header.a_text; - break; - case N_BSS: - case N_SETB: - /* likewise for symbols with value in BSS. */ - p->n_value += entry->bss_start_address - - entry->header.a_text - entry->header.a_data; - break; - } - } - } -} - -void describe_file_sections (), list_file_locals (); - -/* Print a complete or partial map of the output file. */ - -void -print_symbols (outfile) - FILE *outfile; -{ - register int i; - - fprintf (outfile, "\nFiles:\n\n"); - - each_file (describe_file_sections, outfile); - - fprintf (outfile, "\nGlobal symbols:\n\n"); - - for (i = 0; i < TABSIZE; i++) - { - register symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - { - if (sp->defined == 1) - fprintf (outfile, " %s: common, length 0x%x\n", sp->name, sp->max_common_size); - if (sp->defined) - fprintf (outfile, " %s: 0x%x\n", sp->name, sp->value); - else if (sp->referenced) - fprintf (outfile, " %s: undefined\n", sp->name); - } - } - - each_file (list_file_locals, outfile); -} - -void -describe_file_sections (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - fprintf (outfile, " "); - print_file_name (entry, outfile); - if (entry->just_syms_flag) - fprintf (outfile, " symbols only\n", 0); - else - fprintf (outfile, " text %x(%x), data %x(%x), bss %x(%x) hex\n", - entry->text_start_address, entry->header.a_text, - entry->data_start_address, entry->header.a_data, - entry->bss_start_address, entry->header.a_bss); -} - -void -list_file_locals (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - register struct nlist - *p, - *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (file_open (entry), entry); - - fprintf (outfile, "\nLocal symbols of "); - print_file_name (entry, outfile); - fprintf (outfile, ":\n\n"); - - for (p = entry->symbols; p < end; p++) - /* If this is a definition, - update it if necessary by this file's start address. */ - if (!(p->n_type & (N_STAB | N_EXT))) - fprintf (outfile, " %s: 0x%x\n", - entry->strings + p->n_un.n_strx, p->n_value); - - entry->strings = 0; /* All done with them. */ -} - - -/* Static vars for do_warnings and subroutines of it */ -int list_unresolved_refs; /* List unresolved refs */ -int list_warning_symbols; /* List warning syms */ -int list_multiple_defs; /* List multiple definitions */ - -/* - * Structure for communication between do_file_warnings and it's - * helper routines. Will in practice be an array of three of these: - * 0) Current line, 1) Next line, 2) Source file info. - */ -struct line_debug_entry -{ - int line; - char *filename; - struct nlist *sym; -}; - -void qsort (); -/* - * Helper routines for do_file_warnings. - */ - -/* Return an integer less than, equal to, or greater than 0 as per the - relation between the two relocation entries. Used by qsort. */ - -int -relocation_entries_relation (rel1, rel2) - struct relocation_info *rel1, *rel2; -{ - return RELOC_ADDRESS(rel1) - RELOC_ADDRESS(rel2); -} - -/* Moves to the next debugging symbol in the file. USE_DATA_SYMBOLS - determines the type of the debugging symbol to look for (DSLINE or - SLINE). STATE_POINTER keeps track of the old and new locatiosn in - the file. It assumes that state_pointer[1] is valid; ie - that it.sym points into some entry in the symbol table. If - state_pointer[1].sym == 0, this routine should not be called. */ - -int -next_debug_entry (use_data_symbols, state_pointer) - register int use_data_symbols; - /* Next must be passed by reference! */ - struct line_debug_entry state_pointer[3]; -{ - register struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1, - /* Used to store source file */ - *source = state_pointer + 2; - struct file_entry *entry = (struct file_entry *) source->sym; - - current->sym = next->sym; - current->line = next->line; - current->filename = next->filename; - - while (++(next->sym) < (entry->symbols - + entry->header.a_syms/sizeof (struct nlist))) - { - /* n_type is a char, and N_SOL, N_EINCL and N_BINCL are > 0x80, so - * may look negative...therefore, must mask to low bits - */ - switch (next->sym->n_type & 0xff) - { - case N_SLINE: - if (use_data_symbols) continue; - next->line = next->sym->n_desc; - return 1; - case N_DSLINE: - if (!use_data_symbols) continue; - next->line = next->sym->n_desc; - return 1; -#ifdef HAVE_SUN_STABS - case N_EINCL: - next->filename = source->filename; - continue; -#endif - case N_SO: - source->filename = next->sym->n_un.n_strx + entry->strings; - source->line++; -#ifdef HAVE_SUN_STABS - case N_BINCL: -#endif - case N_SOL: - next->filename - = next->sym->n_un.n_strx + entry->strings; - default: - continue; - } - } - next->sym = (struct nlist *) 0; - return 0; -} - -/* Create a structure to save the state of a scan through the debug - symbols. USE_DATA_SYMBOLS is set if we should be scanning for - DSLINE's instead of SLINE's. entry is the file entry which points - at the symbols to use. */ - -struct line_debug_entry * -init_debug_scan (use_data_symbols, entry) - int use_data_symbols; - struct file_entry *entry; -{ - struct line_debug_entry - *state_pointer - = (struct line_debug_entry *) - xmalloc (3 * sizeof (struct line_debug_entry)); - register struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1, - *source = state_pointer + 2; /* Used to store source file */ - - struct nlist *tmp; - - for (tmp = entry->symbols; - tmp < (entry->symbols - + entry->header.a_syms/sizeof (struct nlist)); - tmp++) - if (tmp->n_type == (int) N_SO) - break; - - if (tmp >= (entry->symbols - + entry->header.a_syms/sizeof (struct nlist))) - { - /* I believe this translates to "We lose" */ - current->filename = next->filename = entry->filename; - current->line = next->line = -1; - current->sym = next->sym = (struct nlist *) 0; - return state_pointer; - } - - next->line = source->line = 0; - next->filename = source->filename - = (tmp->n_un.n_strx + entry->strings); - source->sym = (struct nlist *) entry; - next->sym = tmp; - - next_debug_entry (use_data_symbols, state_pointer); /* To setup next */ - - if (!next->sym) /* No line numbers for this section; */ - /* setup output results as appropriate */ - { - if (source->line) - { - current->filename = source->filename = entry->filename; - current->line = -1; /* Don't print lineno */ - } - else - { - current->filename = source->filename; - current->line = 0; - } - return state_pointer; - } - - - next_debug_entry (use_data_symbols, state_pointer); /* To setup current */ - - return state_pointer; -} - -/* Takes an ADDRESS (in either text or data space) and a STATE_POINTER - which describes the current location in the implied scan through - the debug symbols within the file which ADDRESS is within, and - returns the source line number which corresponds to ADDRESS. */ - -int -address_to_line (address, state_pointer) - unsigned long address; - /* Next must be passed by reference! */ - struct line_debug_entry state_pointer[3]; -{ - struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1; - struct line_debug_entry *tmp_pointer; - - int use_data_symbols; - - if (next->sym) - use_data_symbols = (next->sym->n_type & N_TYPE) == N_DATA; - else - return current->line; - - /* Go back to the beginning if we've already passed it. */ - if (current->sym->n_value > address) - { - tmp_pointer = init_debug_scan (use_data_symbols, - (struct file_entry *) - ((state_pointer + 2)->sym)); - state_pointer[0] = tmp_pointer[0]; - state_pointer[1] = tmp_pointer[1]; - state_pointer[2] = tmp_pointer[2]; - free (tmp_pointer); - } - - /* If we're still in a bad way, return -1, meaning invalid line. */ - if (current->sym->n_value > address) - return -1; - - while (next->sym - && next->sym->n_value <= address - && next_debug_entry (use_data_symbols, state_pointer)) - ; - return current->line; -} - - -/* Macros for manipulating bitvectors. */ -#define BIT_SET_P(bv, index) ((bv)[(index) >> 3] & 1 << ((index) & 0x7)) -#define SET_BIT(bv, index) ((bv)[(index) >> 3] |= 1 << ((index) & 0x7)) - -/* This routine will scan through the relocation data of file ENTRY, - printing out references to undefined symbols and references to - symbols defined in files with N_WARNING symbols. If DATA_SEGMENT - is non-zero, it will scan the data relocation segment (and use - N_DSLINE symbols to track line number); otherwise it will scan the - text relocation segment. Warnings will be printed on the output - stream OUTFILE. Eventually, every nlist symbol mapped through will - be marked in the NLIST_BITVECTOR, so we don't repeat ourselves when - we scan the nlists themselves. */ - -do_relocation_warnings (entry, data_segment, outfile, nlist_bitvector) - struct file_entry *entry; - int data_segment; - FILE *outfile; - unsigned char *nlist_bitvector; -{ - struct relocation_info - *reloc_start = data_segment ? entry->datarel : entry->textrel, - *reloc; - int reloc_size - = ((data_segment ? entry->header.a_drsize : entry->header.a_trsize) - / sizeof (struct relocation_info)); - int start_of_segment - = (data_segment ? entry->data_start_address : entry->text_start_address); - struct nlist *start_of_syms = entry->symbols; - struct line_debug_entry *state_pointer - = init_debug_scan (data_segment != 0, entry); - register struct line_debug_entry - *current = state_pointer; - /* Assigned to generally static values; should not be written into. */ - char *errfmt; - /* Assigned to alloca'd values cand copied into; should be freed - when done. */ - char *errmsg; - int invalidate_line_number; - - /* We need to sort the relocation info here. Sheesh, so much effort - for one lousy error optimization. */ - - qsort (reloc_start, reloc_size, sizeof (struct relocation_info), - relocation_entries_relation); - - for (reloc = reloc_start; - reloc < (reloc_start + reloc_size); - reloc++) - { - register struct nlist *s; - register symbol *g; - - /* If the relocation isn't resolved through a symbol, continue */ - if (!RELOC_EXTERN_P(reloc)) - continue; - - s = &(entry->symbols[RELOC_SYMBOL(reloc)]); - - /* Local symbols shouldn't ever be used by relocation info, so - the next should be safe. - This is, of course, wrong. References to local BSS symbols can be - the targets of relocation info, and they can (must) be - resolved through symbols. However, these must be defined properly, - (the assembler would have caught it otherwise), so we can - ignore these cases. */ - if (!(s->n_type & N_EXT)) - continue; - - g = (symbol *) s->n_un.n_name; - errmsg = 0; - - if (!g->defined && list_unresolved_refs) /* Reference */ - { - /* Mark as being noted by relocation warning pass. */ - SET_BIT (nlist_bitvector, s - start_of_syms); - - if (g->undef_refs >= MAX_UREFS_PRINTED) /* Listed too many */ - continue; - - /* Undefined symbol which we should mention */ - - if (++(g->undef_refs) == MAX_UREFS_PRINTED) - { - errfmt = "More undefined symbol %s refs follow"; - invalidate_line_number = 1; - } - else - { - errfmt = "Undefined symbol %s referenced from %s segment"; - invalidate_line_number = 0; - } - } - else /* Defined */ - { - /* Potential symbol warning here */ - if (!g->warning) continue; - - /* Mark as being noted by relocation warning pass. */ - SET_BIT (nlist_bitvector, s - start_of_syms); - - errfmt = 0; - errmsg = g->warning; - invalidate_line_number = 0; - } - - - /* If errfmt == 0, errmsg has already been defined. */ - if (errfmt != 0) - { - char *nm; - - if (demangler == NULL || (nm = (*demangler)(g->name)) == NULL) - nm = g->name; - errmsg = (char *) xmalloc (strlen (errfmt) + strlen (nm) + 1); - sprintf (errmsg, errfmt, nm, data_segment ? "data" : "text"); - if (nm != g->name) - free (nm); - } - - address_to_line (RELOC_ADDRESS (reloc) + start_of_segment, - state_pointer); - - if (current->line >=0) - fprintf (outfile, "%s:%d: %s\n", current->filename, - invalidate_line_number ? 0 : current->line, errmsg); - else - fprintf (outfile, "%s: %s\n", current->filename, errmsg); - - if (errfmt != 0) - free (errmsg); - } - - free (state_pointer); -} - -/* Print on OUTFILE a list of all warnings generated by references - and/or definitions in the file ENTRY. List source file and line - number if possible, just the .o file if not. */ - -void -do_file_warnings (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - int number_of_syms = entry->header.a_syms / sizeof (struct nlist); - unsigned char *nlist_bitvector - = (unsigned char *) alloca ((number_of_syms >> 3) + 1); - struct line_debug_entry *text_scan, *data_scan; - int i; - char *errfmt, *file_name; - int line_number; - int dont_allow_symbol_name; - - bzero (nlist_bitvector, (number_of_syms >> 3) + 1); - - /* Read in the files strings if they aren't available */ - if (!entry->strings) - { - int desc; - - entry->strings = (char *) alloca (entry->string_size); - desc = file_open (entry); - read_entry_strings (desc, entry); - } - - read_file_relocation (entry); - - /* Do text warnings based on a scan through the relocation info. */ - do_relocation_warnings (entry, 0, outfile, nlist_bitvector); - - /* Do data warnings based on a scan through the relocation info. */ - do_relocation_warnings (entry, 1, outfile, nlist_bitvector); - - /* Scan through all of the nlist entries in this file and pick up - anything that the scan through the relocation stuff didn't. */ - - text_scan = init_debug_scan (0, entry); - data_scan = init_debug_scan (1, entry); - - for (i = 0; i < number_of_syms; i++) - { - struct nlist *s; - struct glosym *g; - - s = entry->symbols + i; - - if (!(s->n_type & N_EXT)) - continue; - - g = (symbol *) s->n_un.n_name; - dont_allow_symbol_name = 0; - - if (list_multiple_defs && g->multiply_defined) - { - errfmt = "Definition of symbol %s (multiply defined)"; - switch (s->n_type) - { - case N_TEXT | N_EXT: - line_number = address_to_line (s->n_value, text_scan); - file_name = text_scan[0].filename; - break; - case N_DATA | N_EXT: - line_number = address_to_line (s->n_value, data_scan); - file_name = data_scan[0].filename; - break; - case N_SETA | N_EXT: - case N_SETT | N_EXT: - case N_SETD | N_EXT: - case N_SETB | N_EXT: - if (g->multiply_defined == 2) - continue; - errfmt = "First set element definition of symbol %s (multiply defined)"; - break; - default: - continue; /* Don't print out multiple defs - at references. */ - } - } - else if (BIT_SET_P (nlist_bitvector, i)) - continue; - else if (list_unresolved_refs && !g->defined) - { - if (g->undef_refs >= MAX_UREFS_PRINTED) - continue; - - if (++(g->undef_refs) == MAX_UREFS_PRINTED) - errfmt = "More undefined \"%s\" refs follow"; - else - errfmt = "Undefined symbol \"%s\" referenced"; - line_number = -1; - } - else if (g->warning) - { - /* There are two cases in which we don't want to - do this. The first is if this is a definition instead of - a reference. The second is if it's the reference used by - the warning stabs itself. */ - if (s->n_type != (N_EXT | N_UNDF) - || (i && (s-1)->n_type == N_WARNING)) - continue; - - errfmt = g->warning; - line_number = -1; - dont_allow_symbol_name = 1; - } - else - continue; - - if (line_number == -1) - fprintf (outfile, "%s: ", entry->filename); - else - fprintf (outfile, "%s:%d: ", file_name, line_number); - - if (dont_allow_symbol_name) - fprintf (outfile, "%s", errfmt); - else - { - char *nm; - if (demangler != NULL && (nm = (*demangler)(g->name)) != NULL) - { - fprintf (outfile, errfmt, nm); - free (nm); - } - else - fprintf (outfile, errfmt, g->name); - } - - fputc ('\n', outfile); - } - free (text_scan); - free (data_scan); - entry->strings = 0; /* Since it will dissapear anyway. */ -} - -do_warnings (outfile) - FILE *outfile; -{ - list_unresolved_refs = !relocatable_output && undefined_global_sym_count; - list_warning_symbols = warning_count; - list_multiple_defs = multiple_def_count != 0; - - if (!(list_unresolved_refs || - list_warning_symbols || - list_multiple_defs )) - /* No need to run this routine */ - return; - - each_file (do_file_warnings, outfile); - - if (list_unresolved_refs || list_multiple_defs) - make_executable = 0; -} - -/* Write the output file */ - -void -write_output () -{ - struct stat statbuf; - int filemode; - - (void) unlink (output_filename); - outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (outdesc < 0) perror_name (output_filename); - - if (fstat (outdesc, &statbuf) < 0) - perror_name (output_filename); - - (void) fchflags(outdesc, statbuf.st_flags | UF_NODUMP); - - filemode = statbuf.st_mode; - (void) fchmod (outdesc, filemode & ~0111); - - /* Output the a.out header. */ - write_header (); - - /* Output the text and data segments, relocating as we go. */ - write_text (); - write_data (); - - /* Output the merged relocation info, if requested with `-r'. */ - if (relocatable_output) - write_rel (); - - /* Output the symbol table (both globals and locals). */ - write_syms (); - - /* Copy any GDB symbol segments from input files. */ - write_symsegs (); - - if (fchmod (outdesc, filemode | 0111) == -1) - perror_name (output_filename); - - close (outdesc); -} - -void modify_location (), perform_relocation (), copy_text (), copy_data (); - -void -write_header () -{ - N_SET_MAGIC (outheader, magic); - outheader.a_text = text_size; -#ifdef sequent - outheader.a_text += N_ADDRADJ (outheader); - if (entry_symbol == 0) - entry_symbol = getsym("start"); -#endif - outheader.a_data = data_size; - outheader.a_bss = bss_size; - outheader.a_entry = (entry_symbol ? entry_symbol->value - : text_start + entry_offset); -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - { - /* We are encapsulating BSD format within COFF format. */ - struct coffscn *tp, *dp, *bp; - - tp = &coffheader.scns[0]; - dp = &coffheader.scns[1]; - bp = &coffheader.scns[2]; - - strcpy (tp->s_name, ".text"); - tp->s_paddr = text_start; - tp->s_vaddr = text_start; - tp->s_size = text_size; - tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec); - tp->s_relptr = 0; - tp->s_lnnoptr = 0; - tp->s_nreloc = 0; - tp->s_nlnno = 0; - tp->s_flags = 0x20; - strcpy (dp->s_name, ".data"); - dp->s_paddr = data_start; - dp->s_vaddr = data_start; - dp->s_size = data_size; - dp->s_scnptr = tp->s_scnptr + tp->s_size; - dp->s_relptr = 0; - dp->s_lnnoptr = 0; - dp->s_nreloc = 0; - dp->s_nlnno = 0; - dp->s_flags = 0x40; - strcpy (bp->s_name, ".bss"); - bp->s_paddr = dp->s_vaddr + dp->s_size; - bp->s_vaddr = bp->s_paddr; - bp->s_size = bss_size; - bp->s_scnptr = 0; - bp->s_relptr = 0; - bp->s_lnnoptr = 0; - bp->s_nreloc = 0; - bp->s_nlnno = 0; - bp->s_flags = 0x80; - - coffheader.f_magic = COFF_MAGIC; - coffheader.f_nscns = 3; - /* store an unlikely time so programs can - * tell that there is a bsd header - */ - coffheader.f_timdat = 1; - coffheader.f_symptr = 0; - coffheader.f_nsyms = 0; - coffheader.f_opthdr = 28; - coffheader.f_flags = 0x103; - /* aouthdr */ - coffheader.magic = ZMAGIC; - coffheader.vstamp = 0; - coffheader.tsize = tp->s_size; - coffheader.dsize = dp->s_size; - coffheader.bsize = bp->s_size; - coffheader.entry = outheader.a_entry; - coffheader.text_start = tp->s_vaddr; - coffheader.data_start = dp->s_vaddr; - } -#endif - -#ifdef INITIALIZE_HEADER - INITIALIZE_HEADER; -#endif - - if (strip_symbols == STRIP_ALL) - nsyms = 0; - else - { - nsyms = (defined_global_sym_count - + undefined_global_sym_count); - if (discard_locals == DISCARD_L) - nsyms += non_L_local_sym_count; - else if (discard_locals == DISCARD_NONE) - nsyms += local_sym_count; - /* One extra for following reference on indirects */ - if (relocatable_output) - nsyms += set_symbol_count + global_indirect_count; - } - - if (strip_symbols == STRIP_NONE) - nsyms += debugger_sym_count; - - outheader.a_syms = nsyms * sizeof (struct nlist); - - if (relocatable_output) - { - outheader.a_trsize = text_reloc_size; - outheader.a_drsize = data_reloc_size; - } - else - { - outheader.a_trsize = 0; - outheader.a_drsize = 0; - } - -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - mywrite (&coffheader, sizeof coffheader, 1, outdesc); -#endif - mywrite (&outheader, sizeof (struct exec), 1, outdesc); - - /* Output whatever padding is required in the executable file - between the header and the start of the text. */ - -#ifndef COFF_ENCAPSULATE - padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc); -#endif -} - -/* Relocate the text segment of each input file - and write to the output file. */ - -void -write_text () -{ - if (trace_files) - fprintf (stderr, "Copying and relocating text:\n\n"); - - each_full_file (copy_text, 0); - file_close (); - - if (trace_files) - fprintf (stderr, "\n"); - - padfile (text_pad, outdesc); -} - -int -text_offset (entry) - struct file_entry *entry; -{ - return entry->starting_offset + N_TXTOFF (entry->header); -} - -/* Read in all of the relocation information */ - -void -read_relocation () -{ - each_full_file (read_file_relocation, 0); -} - -/* Read in the relocation sections of ENTRY if necessary */ - -void -read_file_relocation (entry) - struct file_entry *entry; -{ - register struct relocation_info *reloc; - int desc; - int read_return; - - desc = -1; - if (!entry->textrel) - { - reloc = (struct relocation_info *) xmalloc (entry->header.a_trsize); - desc = file_open (entry); - lseek (desc, - text_offset (entry) + entry->header.a_text + entry->header.a_data, - L_SET); - if (entry->header.a_trsize != (read_return = read (desc, reloc, entry->header.a_trsize))) - { - fprintf (stderr, "Return from read: %d\n", read_return); - fatal_with_file ("premature eof in text relocation of ", entry); - } - entry->textrel = reloc; - } - - if (!entry->datarel) - { - reloc = (struct relocation_info *) xmalloc (entry->header.a_drsize); - if (desc == -1) desc = file_open (entry); - lseek (desc, - text_offset (entry) + entry->header.a_text - + entry->header.a_data + entry->header.a_trsize, - L_SET); - if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize)) - fatal_with_file ("premature eof in data relocation of ", entry); - entry->datarel = reloc; - } -} - -/* Read the text segment contents of ENTRY, relocate them, - and write the result to the output file. - If `-r', save the text relocation for later reuse. */ - -void -copy_text (entry) - struct file_entry *entry; -{ - register char *bytes; - register int desc; - register struct relocation_info *reloc; - - if (trace_files) - prline_file_name (entry, stderr); - - desc = file_open (entry); - - /* Allocate space for the file's text section */ - - bytes = (char *) alloca (entry->header.a_text); - - /* Deal with relocation information however is appropriate */ - - if (entry->textrel) reloc = entry->textrel; - else if (relocatable_output) - { - read_file_relocation (entry); - reloc = entry->textrel; - } - else - { - reloc = (struct relocation_info *) alloca (entry->header.a_trsize); - lseek (desc, text_offset (entry) + entry->header.a_text + entry->header.a_data, 0); - if (entry->header.a_trsize != read (desc, reloc, entry->header.a_trsize)) - fatal_with_file ("premature eof in text relocation of ", entry); - } - - /* Read the text section into core. */ - - lseek (desc, text_offset (entry), 0); - if (entry->header.a_text != read (desc, bytes, entry->header.a_text)) - fatal_with_file ("premature eof in text section of ", entry); - - - /* Relocate the text according to the text relocation. */ - - perform_relocation (bytes, entry->text_start_address, entry->header.a_text, - reloc, entry->header.a_trsize, entry); - - /* Write the relocated text to the output file. */ - - mywrite (bytes, 1, entry->header.a_text, outdesc); -} - -/* Relocate the data segment of each input file - and write to the output file. */ - -void -write_data () -{ - if (trace_files) - fprintf (stderr, "Copying and relocating data:\n\n"); - - each_full_file (copy_data, 0); - file_close (); - - /* Write out the set element vectors. See digest symbols for - description of length of the set vector section. */ - - if (set_vector_count) - mywrite (set_vectors, 2 * set_symbol_count + set_vector_count, - sizeof (unsigned long), outdesc); - - if (trace_files) - fprintf (stderr, "\n"); - - padfile (data_pad, outdesc); -} - -/* Read the data segment contents of ENTRY, relocate them, - and write the result to the output file. - If `-r', save the data relocation for later reuse. - See comments in `copy_text'. */ - -void -copy_data (entry) - struct file_entry *entry; -{ - register struct relocation_info *reloc; - register char *bytes; - register int desc; - - if (trace_files) - prline_file_name (entry, stderr); - - desc = file_open (entry); - - bytes = (char *) alloca (entry->header.a_data); - - if (entry->datarel) reloc = entry->datarel; - else if (relocatable_output) /* Will need this again */ - { - read_file_relocation (entry); - reloc = entry->datarel; - } - else - { - reloc = (struct relocation_info *) alloca (entry->header.a_drsize); - lseek (desc, text_offset (entry) + entry->header.a_text - + entry->header.a_data + entry->header.a_trsize, - 0); - if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize)) - fatal_with_file ("premature eof in data relocation of ", entry); - } - - lseek (desc, text_offset (entry) + entry->header.a_text, 0); - if (entry->header.a_data != read (desc, bytes, entry->header.a_data)) - fatal_with_file ("premature eof in data section of ", entry); - - perform_relocation (bytes, entry->data_start_address - entry->header.a_text, - entry->header.a_data, reloc, entry->header.a_drsize, entry); - - mywrite (bytes, 1, entry->header.a_data, outdesc); -} - -/* Relocate ENTRY's text or data section contents. - DATA is the address of the contents, in core. - DATA_SIZE is the length of the contents. - PC_RELOCATION is the difference between the address of the contents - in the output file and its address in the input file. - RELOC_INFO is the address of the relocation info, in core. - RELOC_SIZE is its length in bytes. */ -/* This version is about to be severly hacked by Randy. Hope it - works afterwards. */ -void -perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size, entry) - char *data; - struct relocation_info *reloc_info; - struct file_entry *entry; - int pc_relocation; - int data_size; - int reloc_size; -{ - register struct relocation_info *p = reloc_info; - struct relocation_info *end - = reloc_info + reloc_size / sizeof (struct relocation_info); - int text_relocation = entry->text_start_address; - int data_relocation = entry->data_start_address - entry->header.a_text; - int bss_relocation - = entry->bss_start_address - entry->header.a_text - entry->header.a_data; - - for (; p < end; p++) - { - register int relocation = 0; - register int addr = RELOC_ADDRESS(p); - register unsigned int mask = 0; - - if (addr >= data_size) - fatal_with_file ("relocation address out of range in ", entry); - - if (RELOC_EXTERN_P(p)) - { - int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist); - symbol *sp = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - -#ifdef N_INDR - /* Resolve indirection */ - if ((sp->defined & ~N_EXT) == N_INDR) - sp = (symbol *) sp->value; -#endif - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - - /* If the symbol is undefined, leave it at zero. */ - if (! sp->defined) - relocation = 0; - else - relocation = sp->value; - } - else switch (RELOC_TYPE(p)) - { - case N_TEXT: - case N_TEXT | N_EXT: - relocation = text_relocation; - break; - - case N_DATA: - case N_DATA | N_EXT: - /* A word that points to beginning of the the data section - initially contains not 0 but rather the "address" of that section - in the input file, which is the length of the file's text. */ - relocation = data_relocation; - break; - - case N_BSS: - case N_BSS | N_EXT: - /* Similarly, an input word pointing to the beginning of the bss - initially contains the length of text plus data of the file. */ - relocation = bss_relocation; - break; - - case N_ABS: - case N_ABS | N_EXT: - /* Don't know why this code would occur, but apparently it does. */ - break; - - default: - fatal_with_file ("nonexternal relocation code invalid in ", entry); - } - -#ifdef RELOC_ADD_EXTRA - relocation += RELOC_ADD_EXTRA(p); - if (relocatable_output) - { - /* Non-PC relative relocations which are absolute - or which have become non-external now have fixed - relocations. Set the ADD_EXTRA of this relocation - to be the relocation we have now determined. */ - if (! RELOC_PCREL_P (p)) - { - if ((int)p->r_type <= RELOC_32 - || RELOC_EXTERN_P (p) == 0) - RELOC_ADD_EXTRA (p) = relocation; - } - /* External PC-relative relocations continue to move around; - update their relocations by the amount they have moved - so far. */ - else if (RELOC_EXTERN_P (p)) - RELOC_ADD_EXTRA (p) -= pc_relocation; - continue; - } -#endif - - if (RELOC_PCREL_P(p)) - relocation -= pc_relocation; - - relocation >>= RELOC_VALUE_RIGHTSHIFT(p); - - /* Unshifted mask for relocation */ - mask = 1 << RELOC_TARGET_BITSIZE(p) - 1; - mask |= mask - 1; - relocation &= mask; - - /* Shift everything up to where it's going to be used */ - relocation <<= RELOC_TARGET_BITPOS(p); - mask <<= RELOC_TARGET_BITPOS(p); - - switch (RELOC_TARGET_SIZE(p)) - { - case 0: - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(char *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(char *) (data + addr); - *(char *) (data + addr) &= ~mask; - *(char *) (data + addr) |= relocation; - break; - - case 1: -#ifdef tahoe - if (((int) data + addr & 1) == 0) - { -#endif - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(short *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(short *) (data + addr); - *(short *) (data + addr) &= ~mask; - *(short *) (data + addr) |= relocation; -#ifdef tahoe - } - /* - * The CCI Power 6 (aka Tahoe) architecture has byte-aligned - * instruction operands but requires data accesses to be aligned. - * Brain-damage... - */ - else - { - unsigned char *da = (unsigned char *) (data + addr); - unsigned short s = da[0] << 8 | da[1]; - - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & s; - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & s; - s &= ~mask; - s |= relocation; - da[0] = s >> 8; - da[1] = s; - } -#endif - break; - - case 2: -#ifndef _CROSS_TARGET_ARCH -#ifdef tahoe - if (((int) data + addr & 3) == 0) - { -#endif - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(long *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(long *) (data + addr); - *(long *) (data + addr) &= ~mask; - *(long *) (data + addr) |= relocation; -#ifdef tahoe - } - else - { - unsigned char *da = (unsigned char *) (data + addr); - unsigned long l = da[0] << 24 | da[1] << 16 | da[2] << 8 | da[3]; - - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & l; - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & l; - l &= ~mask; - l |= relocation; - da[0] = l >> 24; - da[1] = l >> 16; - da[2] = l >> 8; - da[3] = l; - } -#endif -#else - /* Handle long word alignment requirements of SPARC architecture */ - /* WARNING: This fix makes an assumption on byte ordering */ - /* Marc Ullman, Stanford University Nov. 1 1989 */ - if (RELOC_MEMORY_SUB_P(p)) { - relocation -= mask & - ((*(unsigned short *) (data + addr) << 16) | - *(unsigned short *) (data + addr + 2)); - } else if (RELOC_MEMORY_ADD_P(p)) { - relocation += mask & - ((*(unsigned short *) (data + addr) << 16) | - *(unsigned short *) (data + addr + 2)); - } - *(unsigned short *) (data + addr) &= (~mask >> 16); - *(unsigned short *) (data + addr + 2) &= (~mask & 0xffff); - *(unsigned short *) (data + addr) |= (relocation >> 16); - *(unsigned short *) (data + addr + 2) |= (relocation & 0xffff); -#endif - break; - - default: - fatal_with_file ("Unimplemented relocation field length in ", entry); - } - } -} - -/* For relocatable_output only: write out the relocation, - relocating the addresses-to-be-relocated. */ - -void coptxtrel (), copdatrel (); - -void -write_rel () -{ - register int i; - register int count = 0; - - if (trace_files) - fprintf (stderr, "Writing text relocation:\n\n"); - - /* Assign each global symbol a sequence number, giving the order - in which `write_syms' will write it. - This is so we can store the proper symbolnum fields - in relocation entries we write. */ - - for (i = 0; i < TABSIZE; i++) - { - symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - if (sp->referenced || sp->defined) - { - sp->def_count = count++; - /* Leave room for the reference required by N_INDR, if - necessary. */ - if ((sp->defined & ~N_EXT) == N_INDR) - count++; - } - } - /* Correct, because if (relocatable_output), we will also be writing - whatever indirect blocks we have. */ - if (count != defined_global_sym_count - + undefined_global_sym_count + global_indirect_count) - fatal ("internal error"); - - /* Write out the relocations of all files, remembered from copy_text. */ - - each_full_file (coptxtrel, 0); - - if (trace_files) - fprintf (stderr, "\nWriting data relocation:\n\n"); - - each_full_file (copdatrel, 0); - - if (trace_files) - fprintf (stderr, "\n"); -} - -void -coptxtrel (entry) - struct file_entry *entry; -{ - register struct relocation_info *p, *end; - register int reloc = entry->text_start_address; - - p = entry->textrel; - end = (struct relocation_info *) (entry->header.a_trsize + (char *) p); - while (p < end) - { - RELOC_ADDRESS(p) += reloc; - if (RELOC_EXTERN_P(p)) - { - register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist); - symbol *symptr = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - -#ifdef N_INDR - /* Resolve indirection. */ - if ((symptr->defined & ~N_EXT) == N_INDR) - symptr = (symbol *) symptr->value; -#endif - - /* If the symbol is now defined, change the external relocation - to an internal one. */ - - if (symptr->defined) - { - RELOC_EXTERN_P(p) = 0; - RELOC_SYMBOL(p) = (symptr->defined & N_TYPE); -#ifdef RELOC_ADD_EXTRA - /* If we aren't going to be adding in the value in - memory on the next pass of the loader, then we need - to add it in from the relocation entry. Otherwise - the work we did in this pass is lost. */ - if (!RELOC_MEMORY_ADD_P(p)) - RELOC_ADD_EXTRA (p) += symptr->value; -#endif - } - else - /* Debugger symbols come first, so have to start this - after them. */ - RELOC_SYMBOL(p) = (symptr->def_count + nsyms - - defined_global_sym_count - - undefined_global_sym_count - - global_indirect_count); - } - p++; - } - mywrite (entry->textrel, 1, entry->header.a_trsize, outdesc); -} - -void -copdatrel (entry) - struct file_entry *entry; -{ - register struct relocation_info *p, *end; - /* Relocate the address of the relocation. - Old address is relative to start of the input file's data section. - New address is relative to start of the output file's data section. */ - register int reloc = entry->data_start_address - text_size; - - p = entry->datarel; - end = (struct relocation_info *) (entry->header.a_drsize + (char *) p); - while (p < end) - { - RELOC_ADDRESS(p) += reloc; - if (RELOC_EXTERN_P(p)) - { - register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist); - symbol *symptr = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - int symtype; - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - -#ifdef N_INDR - /* Resolve indirection. */ - if ((symptr->defined & ~N_EXT) == N_INDR) - symptr = (symbol *) symptr->value; -#endif - - symtype = symptr->defined & N_TYPE; - - if (force_common_definition - || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS) - { - RELOC_EXTERN_P(p) = 0; - RELOC_SYMBOL(p) = symtype; - } - else - /* Debugger symbols come first, so have to start this - after them. */ - RELOC_SYMBOL(p) - = (((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)) - ->def_count - + nsyms - defined_global_sym_count - - undefined_global_sym_count - - global_indirect_count); - } - p++; - } - mywrite (entry->datarel, 1, entry->header.a_drsize, outdesc); -} - -void write_file_syms (); -void write_string_table (); - -/* Offsets and current lengths of symbol and string tables in output file. */ - -int symbol_table_offset; -int symbol_table_len; - -/* Address in output file where string table starts. */ -int string_table_offset; - -/* Offset within string table - where the strings in `strtab_vector' should be written. */ -int string_table_len; - -/* Total size of string table strings allocated so far, - including strings in `strtab_vector'. */ -int strtab_size; - -/* Vector whose elements are strings to be added to the string table. */ -char **strtab_vector; - -/* Vector whose elements are the lengths of those strings. */ -int *strtab_lens; - -/* Index in `strtab_vector' at which the next string will be stored. */ -int strtab_index; - -/* Add the string NAME to the output file string table. - Record it in `strtab_vector' to be output later. - Return the index within the string table that this string will have. */ - -int -assign_string_table_index (name) - char *name; -{ - register int index = strtab_size; - register int len = strlen (name) + 1; - - strtab_size += len; - strtab_vector[strtab_index] = name; - strtab_lens[strtab_index++] = len; - - return index; -} - -FILE *outstream = (FILE *) 0; - -/* Write the contents of `strtab_vector' into the string table. - This is done once for each file's local&debugger symbols - and once for the global symbols. */ - -void -write_string_table () -{ - register int i; - - lseek (outdesc, string_table_offset + string_table_len, 0); - - if (!outstream) - outstream = fdopen (outdesc, "w"); - - for (i = 0; i < strtab_index; i++) - { - fwrite (strtab_vector[i], 1, strtab_lens[i], outstream); - string_table_len += strtab_lens[i]; - } - - fflush (outstream); - - /* Report I/O error such as disk full. */ - if (ferror (outstream)) - perror_name (output_filename); -} - -/* Write the symbol table and string table of the output file. */ - -void -write_syms () -{ - /* Number of symbols written so far. */ - int syms_written = 0; - register int i; - register symbol *sp; - - /* Buffer big enough for all the global symbols. One - extra struct for each indirect symbol to hold the extra reference - following. */ - struct nlist *buf - = (struct nlist *) alloca ((defined_global_sym_count - + undefined_global_sym_count - + global_indirect_count) - * sizeof (struct nlist)); - /* Pointer for storing into BUF. */ - register struct nlist *bufp = buf; - - /* Size of string table includes the bytes that store the size. */ - strtab_size = sizeof strtab_size; - - symbol_table_offset = N_SYMOFF (outheader); - symbol_table_len = 0; - string_table_offset = N_STROFF (outheader); - string_table_len = strtab_size; - - if (strip_symbols == STRIP_ALL) - return; - - /* Write the local symbols defined by the various files. */ - - each_file (write_file_syms, &syms_written); - file_close (); - - /* Now write out the global symbols. */ - - /* Allocate two vectors that record the data to generate the string - table from the global symbols written so far. This must include - extra space for the references following indirect outputs. */ - - strtab_vector = (char **) alloca ((num_hash_tab_syms - + global_indirect_count) * sizeof (char *)); - strtab_lens = (int *) alloca ((num_hash_tab_syms - + global_indirect_count) * sizeof (int)); - strtab_index = 0; - - /* Scan the symbol hash table, bucket by bucket. */ - - for (i = 0; i < TABSIZE; i++) - for (sp = symtab[i]; sp; sp = sp->link) - { - struct nlist nl; - - nl.n_other = 0; - nl.n_desc = 0; - - /* Compute a `struct nlist' for the symbol. */ - - if (sp->defined || sp->referenced) - { - /* common condition needs to be before undefined condition */ - /* because unallocated commons are set undefined in */ - /* digest_symbols */ - if (sp->defined > 1) /* defined with known type */ - { - /* If the target of an indirect symbol has been - defined and we are outputting an executable, - resolve the indirection; it's no longer needed */ - if (!relocatable_output - && ((sp->defined & N_TYPE) == N_INDR) - && (((symbol *) sp->value)->defined > 1)) - { - symbol *newsp = (symbol *) sp->value; - nl.n_type = newsp->defined; - nl.n_value = newsp->value; - } - else - { - nl.n_type = sp->defined; - if (sp->defined != (N_INDR | N_EXT)) - nl.n_value = sp->value; - else - nl.n_value = 0; - } - } - else if (sp->max_common_size) /* defined as common but not allocated. */ - { - /* happens only with -r and not -d */ - /* write out a common definition */ - nl.n_type = N_UNDF | N_EXT; - nl.n_value = sp->max_common_size; - } - else if (!sp->defined) /* undefined -- legit only if -r */ - { - nl.n_type = N_UNDF | N_EXT; - nl.n_value = 0; - } - else - fatal ("internal error: %s defined in mysterious way", sp->name); - - /* Allocate string table space for the symbol name. */ - - nl.n_un.n_strx = assign_string_table_index (sp->name); - - /* Output to the buffer and count it. */ - - *bufp++ = nl; - syms_written++; - if (nl.n_type == (N_INDR | N_EXT)) - { - struct nlist xtra_ref; - xtra_ref.n_type = N_EXT | N_UNDF; - xtra_ref.n_un.n_strx - = assign_string_table_index (((symbol *) sp->value)->name); - xtra_ref.n_other = 0; - xtra_ref.n_desc = 0; - xtra_ref.n_value = 0; - *bufp++ = xtra_ref; - syms_written++; - } - } - } - - /* Output the buffer full of `struct nlist's. */ - - lseek (outdesc, symbol_table_offset + symbol_table_len, 0); - mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc); - symbol_table_len += sizeof (struct nlist) * (bufp - buf); - - if (syms_written != nsyms) - fatal ("internal error: wrong number of symbols written into output file", 0); - - if (symbol_table_offset + symbol_table_len != string_table_offset) - fatal ("internal error: inconsistent symbol table length", 0); - - /* Now the total string table size is known, so write it. - We are already positioned at the right place in the file. */ - - mywrite (&strtab_size, sizeof (int), 1, outdesc); /* we're at right place */ - - /* Write the strings for the global symbols. */ - - write_string_table (); -} - -/* Write the local and debugger symbols of file ENTRY. - Increment *SYMS_WRITTEN_ADDR for each symbol that is written. */ - -/* Note that we do not combine identical names of local symbols. - dbx or gdb would be confused if we did that. */ - -void -write_file_syms (entry, syms_written_addr) - struct file_entry *entry; - int *syms_written_addr; -{ - register struct nlist *p = entry->symbols; - register struct nlist *end = p + entry->header.a_syms / sizeof (struct nlist); - - /* Buffer to accumulate all the syms before writing them. - It has one extra slot for the local symbol we generate here. */ - struct nlist *buf - = (struct nlist *) alloca (entry->header.a_syms + sizeof (struct nlist)); - register struct nlist *bufp = buf; - - /* Upper bound on number of syms to be written here. */ - int max_syms = (entry->header.a_syms / sizeof (struct nlist)) + 1; - - /* Make tables that record, for each symbol, its name and its name's length. - The elements are filled in by `assign_string_table_index'. */ - - strtab_vector = (char **) alloca (max_syms * sizeof (char *)); - strtab_lens = (int *) alloca (max_syms * sizeof (int)); - strtab_index = 0; - - /* Generate a local symbol for the start of this file's text. */ - - if (discard_locals != DISCARD_ALL) - { - struct nlist nl; - - nl.n_type = N_FN | N_EXT; - nl.n_un.n_strx = assign_string_table_index (entry->local_sym_name); - nl.n_value = entry->text_start_address; - nl.n_desc = 0; - nl.n_other = 0; - *bufp++ = nl; - (*syms_written_addr)++; - entry->local_syms_offset = *syms_written_addr * sizeof (struct nlist); - } - - /* Read the file's string table. */ - - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (file_open (entry), entry); - - for (; p < end; p++) - { - register int type = p->n_type; - register int write = 0; - - /* WRITE gets 1 for a non-global symbol that should be written. */ - - - if (SET_ELEMENT_P (type)) /* This occurs even if global. These */ - /* types of symbols are never written */ - /* globally, though they are stored */ - /* globally. */ - write = relocatable_output; - else if (!(type & (N_STAB | N_EXT))) - /* ordinary local symbol */ - write = ((discard_locals != DISCARD_ALL) - && !(discard_locals == DISCARD_L && - (p->n_un.n_strx + entry->strings)[0] == LPREFIX) - && type != N_WARNING); - else if (!(type & N_EXT)) - /* debugger symbol */ - write = (strip_symbols == STRIP_NONE); - - if (write) - { - /* If this symbol has a name, - allocate space for it in the output string table. */ - - if (p->n_un.n_strx) - p->n_un.n_strx = assign_string_table_index (p->n_un.n_strx - + entry->strings); - - /* Output this symbol to the buffer and count it. */ - - *bufp++ = *p; - (*syms_written_addr)++; - } - } - - /* All the symbols are now in BUF; write them. */ - - lseek (outdesc, symbol_table_offset + symbol_table_len, 0); - mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc); - symbol_table_len += sizeof (struct nlist) * (bufp - buf); - - /* Write the string-table data for the symbols just written, - using the data in vectors `strtab_vector' and `strtab_lens'. */ - - write_string_table (); - entry->strings = 0; /* Since it will dissapear anyway. */ -} - -/* Copy any GDB symbol segments from the input files to the output file. - The contents of the symbol segment is copied without change - except that we store some information into the beginning of it. */ - -void write_file_symseg (); - -void -write_symsegs () -{ - each_file (write_file_symseg, 0); -} - -void -write_file_symseg (entry) - struct file_entry *entry; -{ - char buffer[4096]; - struct symbol_root root; - int indesc; - int len; - - if (entry->symseg_offset == 0) - return; - - /* This entry has a symbol segment. Read the root of the segment. */ - - indesc = file_open (entry); - lseek (indesc, entry->symseg_offset + entry->starting_offset, 0); - if (sizeof root != read (indesc, &root, sizeof root)) - fatal_with_file ("premature end of file in symbol segment of ", entry); - - /* Store some relocation info into the root. */ - - root.ldsymoff = entry->local_syms_offset; - root.textrel = entry->text_start_address; - root.datarel = entry->data_start_address - entry->header.a_text; - root.bssrel = entry->bss_start_address - - entry->header.a_text - entry->header.a_data; - root.databeg = entry->data_start_address - root.datarel; - root.bssbeg = entry->bss_start_address - root.bssrel; - - /* Write the modified root into the output file. */ - - mywrite (&root, sizeof root, 1, outdesc); - - /* Copy the rest of the symbol segment unchanged. */ - - if (entry->superfile) - { - /* Library member: number of bytes to copy is determined - from the member's total size. */ - - int total = entry->total_size - entry->symseg_offset - sizeof root; - - while (total > 0) - { - len = read (indesc, buffer, min (sizeof buffer, total)); - - if (len != min (sizeof buffer, total)) - fatal_with_file ("premature end of file in symbol segment of ", entry); - total -= len; - mywrite (buffer, len, 1, outdesc); - } - } - else - { - /* A separate file: copy until end of file. */ - - while (len = read (indesc, buffer, sizeof buffer)) - { - mywrite (buffer, len, 1, outdesc); - if (len < sizeof buffer) - break; - } - } - - file_close (); -} - -/* Create the symbol table entries for `etext', `edata' and `end'. */ - -void -symtab_init () -{ -#ifndef nounderscore - edata_symbol = getsym ("_edata"); - etext_symbol = getsym ("_etext"); - end_symbol = getsym ("_end"); -#else - edata_symbol = getsym ("edata"); - etext_symbol = getsym ("etext"); - end_symbol = getsym ("end"); -#endif - -#ifdef sun - { - symbol *dynamic_symbol = getsym ("__DYNAMIC"); - dynamic_symbol->defined = N_ABS | N_EXT; - dynamic_symbol->referenced = 1; - dynamic_symbol->value = 0; - } -#endif - -#ifdef sequent - { - symbol *_387_flt_symbol = getsym ("_387_flt"); - _387_flt_symbol->defined = N_ABS | N_EXT; - _387_flt_symbol->referenced = 1; - _387_flt_symbol->value = 0; - } -#endif - - edata_symbol->defined = N_DATA | N_EXT; - etext_symbol->defined = N_TEXT | N_EXT; - end_symbol->defined = N_BSS | N_EXT; - - edata_symbol->referenced = 1; - etext_symbol->referenced = 1; - end_symbol->referenced = 1; -} - -/* Compute the hash code for symbol name KEY. */ - -int -hash_string (key) - char *key; -{ - register char *cp; - register int k; - - cp = key; - k = 0; - while (*cp) - k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff; - - return k; -} - -/* Get the symbol table entry for the global symbol named KEY. - Create one if there is none. */ - -symbol * -getsym (key) - char *key; -{ - register int hashval; - register symbol *bp; - - /* Determine the proper bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - - for (bp = symtab[hashval]; bp; bp = bp->link) - if (! strcmp (key, bp->name)) - return bp; - - /* Nothing was found; create a new symbol table entry. */ - - bp = (symbol *) xmalloc (sizeof (symbol)); - bp->refs = 0; - bp->name = (char *) xmalloc (strlen (key) + 1); - strcpy (bp->name, key); - bp->defined = 0; - bp->referenced = 0; - bp->trace = 0; - bp->value = 0; - bp->max_common_size = 0; - bp->warning = 0; - bp->undef_refs = 0; - bp->multiply_defined = 0; - - /* Add the entry to the bucket. */ - - bp->link = symtab[hashval]; - symtab[hashval] = bp; - - ++num_hash_tab_syms; - - return bp; -} - -/* Like `getsym' but return 0 if the symbol is not already known. */ - -symbol * -getsym_soft (key) - char *key; -{ - register int hashval; - register symbol *bp; - - /* Determine which bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - - for (bp = symtab[hashval]; bp; bp = bp->link) - if (! strcmp (key, bp->name)) - return bp; - - return 0; -} - -/* Report a fatal error. - STRING is a printf format string and ARG is one arg for it. */ - -void -fatal (string, arg) - char *string, *arg; -{ - fprintf (stderr, "ld: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - exit (1); -} - -/* Report a fatal error. The error message is STRING - followed by the filename of ENTRY. */ - -void -fatal_with_file (string, entry) - char *string; - struct file_entry *entry; -{ - fprintf (stderr, "ld: "); - fprintf (stderr, string); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - exit (1); -} - -/* Report a fatal error using the message for the last failed system call, - followed by the string NAME. */ - -void -perror_name (name) - char *name; -{ - extern int errno; - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - fatal (s, name); -} - -/* Report a fatal error using the message for the last failed system call, - followed by the name of file ENTRY. */ - -void -perror_file (entry) - struct file_entry *entry; -{ - extern int errno; - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for "); - else - s = "cannot open "; - fatal_with_file (s, entry); -} - -/* Report a nonfatal error. - STRING is a format for printf, and ARG1 ... ARG3 are args for it. */ - -void -error (string, arg1, arg2, arg3) - char *string, *arg1, *arg2, *arg3; -{ - fprintf (stderr, "%s: ", progname); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); -} - - -/* Output COUNT*ELTSIZE bytes of data at BUF - to the descriptor DESC. */ - -void -mywrite (buf, count, eltsize, desc) - char *buf; - int count; - int eltsize; - int desc; -{ - register int val; - register int bytes = count * eltsize; - - while (bytes > 0) - { - val = write (desc, buf, bytes); - if (val <= 0) - perror_name (output_filename); - buf += val; - bytes -= val; - } -} - -/* Output PADDING zero-bytes to descriptor OUTDESC. - PADDING may be negative; in that case, do nothing. */ - -void -padfile (padding, outdesc) - int padding; - int outdesc; -{ - register char *buf; - if (padding <= 0) - return; - - buf = (char *) alloca (padding); - bzero (buf, padding); - mywrite (buf, padding, 1, outdesc); -} - -/* Return a newly-allocated string - whose contents concatenate the strings S1, S2, S3. */ - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - register char *result = (char *) xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - result[len1 + len2 + len3] = 0; - - return result; -} - -/* Parse the string ARG using scanf format FORMAT, and return the result. - If it does not parse, report fatal error - generating the error message using format string ERROR and ARG as arg. */ - -int -parse (arg, format, error) - char *arg, *format; -{ - int x; - if (1 != sscanf (arg, format, &x)) - fatal (error, arg); - return x; -} - -/* Like malloc but get fatal error if memory is exhausted. */ - -int -xmalloc (size) - int size; -{ - register int result = malloc (size); - if (!result) - fatal ("virtual memory exhausted", 0); - return result; -} - -/* Like realloc but get fatal error if memory is exhausted. */ - -int -xrealloc (ptr, size) - char *ptr; - int size; -{ - register int result = realloc (ptr, size); - if (!result) - fatal ("virtual memory exhausted", 0); - return result; -} - -#ifdef USG - -void -bzero (p, n) - char *p; -{ - memset (p, 0, n); -} - -void -bcopy (from, to, n) - char *from, *to; -{ - memcpy (to, from, n); -} - -getpagesize () -{ - return (4096); -} - -#endif - -#if defined(sun) && (TARGET == SUN4) - -/* Don't use local pagesize to build for Sparc. */ - -getpagesize () -{ - return (8192); -} -#endif diff --git a/usr.bin/ld/symseg.h b/usr.bin/ld/symseg.h deleted file mode 100644 index 978d8bed9475..000000000000 --- a/usr.bin/ld/symseg.h +++ /dev/null @@ -1,358 +0,0 @@ -/*- - * - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * @(#)symseg.h 8.1 (Berkeley) 6/6/93 - */ - -/* GDB symbol table format definitions. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 1, or (at your option) -any later version. - -GNU CC 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 GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Format of GDB symbol table data. - There is one symbol segment for each source file or - independant compilation. These segments are simply concatenated - to form the GDB symbol table. A zero word where the beginning - of a segment is expected indicates there are no more segments. - -Format of a symbol segment: - - The symbol segment begins with a word containing 1 - if it is in the format described here. Other formats may - be designed, with other code numbers. - - The segment contains many objects which point at each other. - The pointers are offsets in bytes from the beginning of the segment. - Thus, each segment can be loaded into core and its pointers relocated - to make valid in-core pointers. - - All the data objects in the segment can be found indirectly from - one of them, the root object, of type `struct symbol_root'. - It appears at the beginning of the segment. - - The total size of the segment, in bytes, appears as the `length' - field of this object. This size includes the size of the - root object. - - All the object data types are defined here to contain pointer types - appropriate for in-core use on a relocated symbol segment. - Casts to and from type int are required for working with - unrelocated symbol segments such as are found in the file. - - The ldsymaddr word is filled in by the loader to contain - the offset (in bytes) within the ld symbol table - of the first nonglobal symbol from this compilation. - This makes it possible to match those symbols - (which contain line number information) reliably with - the segment they go with. - - Core addresses within the program that appear in the symbol segment - are not relocated by the loader. They are inserted by the assembler - and apply to addresses as output by the assembler, so GDB must - relocate them when it loads the symbol segment. It gets the information - on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg - words of the root object. - - The words textrel, datarel and bssrel - are filled in by ld with the amounts to relocate within-the-file - text, data and bss addresses by; databeg and bssbeg can be - used to tell which kind of relocation an address needs. */ - -enum language {language_c}; - -struct symbol_root -{ - int format; /* Data format version */ - int length; /* # bytes in this symbol segment */ - int ldsymoff; /* Offset in ld symtab of this file's syms */ - int textrel; /* Relocation for text addresses */ - int datarel; /* Relocation for data addresses */ - int bssrel; /* Relocation for bss addresses */ - char *filename; /* Name of main source file compiled */ - char *filedir; /* Name of directory it was reached from */ - struct blockvector *blockvector; /* Vector of all symbol-naming blocks */ - struct typevector *typevector; /* Vector of all data types */ - enum language language; /* Code identifying the language used */ - char *version; /* Version info. Not fully specified */ - char *compilation; /* Compilation info. Not fully specified */ - int databeg; /* Address within the file of data start */ - int bssbeg; /* Address within the file of bss start */ - struct sourcevector *sourcevector; /* Vector of line-number info */ -}; - -/* All data types of symbols in the compiled program - are represented by `struct type' objects. - All of these objects are pointed to by the typevector. - The type vector may have empty slots that contain zero. */ - -struct typevector -{ - int length; /* Number of types described */ - struct type *type[1]; -}; - -/* Different kinds of data types are distinguished by the `code' field. */ - -enum type_code -{ - TYPE_CODE_UNDEF, /* Not used; catches errors */ - TYPE_CODE_PTR, /* Pointer type */ - TYPE_CODE_ARRAY, /* Array type, lower bound zero */ - TYPE_CODE_STRUCT, /* C struct or Pascal record */ - TYPE_CODE_UNION, /* C union or Pascal variant part */ - TYPE_CODE_ENUM, /* Enumeration type */ - TYPE_CODE_FUNC, /* Function type */ - TYPE_CODE_INT, /* Integer type */ - TYPE_CODE_FLT, /* Floating type */ - TYPE_CODE_VOID, /* Void type (values zero length) */ - TYPE_CODE_SET, /* Pascal sets */ - TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ - TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ -}; - -/* This appears in a type's flags word for an unsigned integer type. */ -#define TYPE_FLAG_UNSIGNED 1 - -/* Other flag bits are used with GDB. */ - -struct type -{ - /* Code for kind of type */ - enum type_code code; - /* Name of this type, or zero if none. - This is used for printing only. - Type names specified as input are defined by symbols. */ - char *name; - /* Length in bytes of storage for a value of this type */ - int length; - /* For a pointer type, describes the type of object pointed to. - For an array type, describes the type of the elements. - For a function type, describes the type of the value. - Unused otherwise. */ - struct type *target_type; - /* Type that is a pointer to this type. - Zero if no such pointer-to type is known yet. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *pointer_type; - /* Type that is a function returning this type. - Zero if no such function type is known here. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *function_type; - /* Flags about this type. */ - short flags; - /* Number of fields described for this type */ - short nfields; - /* For structure and union types, a description of each field. - For set and pascal array types, there is one "field", - whose type is the domain type of the set or array. - For range types, there are two "fields", - the minimum and maximum values (both inclusive). - For enum types, each possible value is described by one "field". - For range types, there are two "fields", that record constant values - (inclusive) for the minimum and maximum. - - Using a pointer to a separate array of fields - allows all types to have the same size, which is useful - because we can allocate the space for a type before - we know what to put in it. */ - struct field - { - /* Position of this field, counting in bits from start of - containing structure. For a function type, this is the - position in the argument list of this argument. - For a range bound or enum value, this is the value itself. */ - int bitpos; - /* Size of this field, in bits, or zero if not packed. - For an unpacked field, the field's type's length - says how many bytes the field occupies. */ - int bitsize; - /* In a struct or enum type, type of this field. - In a function type, type of this argument. - In an array type, the domain-type of the array. */ - struct type *type; - /* Name of field, value or argument. - Zero for range bounds and array domains. */ - char *name; - } *fields; -}; - -/* All of the name-scope contours of the program - are represented by `struct block' objects. - All of these objects are pointed to by the blockvector. - - Each block represents one name scope. - Each lexical context has its own block. - - The first two blocks in the blockvector are special. - The first one contains all the symbols defined in this compilation - whose scope is the entire program linked together. - The second one contains all the symbols whose scope is the - entire compilation excluding other separate compilations. - In C, these correspond to global symbols and static symbols. - - Each block records a range of core addresses for the code that - is in the scope of the block. The first two special blocks - give, for the range of code, the entire range of code produced - by the compilation that the symbol segment belongs to. - - The blocks appear in the blockvector - in order of increasing starting-address, - and, within that, in order of decreasing ending-address. - - This implies that within the body of one function - the blocks appear in the order of a depth-first tree walk. */ - -struct blockvector -{ - /* Number of blocks in the list. */ - int nblocks; - /* The blocks themselves. */ - struct block *block[1]; -}; - -struct block -{ - /* Addresses in the executable code that are in this block. - Note: in an unrelocated symbol segment in a file, - these are always zero. They can be filled in from the - N_LBRAC and N_RBRAC symbols in the loader symbol table. */ - int startaddr, endaddr; - /* The symbol that names this block, - if the block is the body of a function; - otherwise, zero. - Note: In an unrelocated symbol segment in an object file, - this field may be zero even when the block has a name. - That is because the block is output before the name - (since the name resides in a higher block). - Since the symbol does point to the block (as its value), - it is possible to find the block and set its name properly. */ - struct symbol *function; - /* The `struct block' for the containing block, or 0 if none. */ - /* Note that in an unrelocated symbol segment in an object file - this pointer may be zero when the correct value should be - the second special block (for symbols whose scope is one compilation). - This is because the compiler ouptuts the special blocks at the - very end, after the other blocks. */ - struct block *superblock; - /* Number of local symbols. */ - int nsyms; - /* The symbols. */ - struct symbol *sym[1]; -}; - -/* Represent one symbol name; a variable, constant, function or typedef. */ - -/* Different name spaces for symbols. Looking up a symbol specifies - a namespace and ignores symbol definitions in other name spaces. - - VAR_NAMESPACE is the usual namespace. - In C, this contains variables, function names, typedef names - and enum type values. - - STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, - it produces a symbol named `foo' in the STRUCT_NAMESPACE. - - LABEL_NAMESPACE may be used for names of labels (for gotos); - currently it is not used and labels are not recorded at all. */ - -/* For a non-global symbol allocated statically, - the correct core address cannot be determined by the compiler. - The compiler puts an index number into the symbol's value field. - This index number can be matched with the "desc" field of - an entry in the loader symbol table. */ - -enum namespace -{ - UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, -}; - -/* An address-class says where to find the value of the symbol in core. */ - -enum address_class -{ - LOC_UNDEF, /* Not used; catches errors */ - LOC_CONST, /* Value is constant int */ - LOC_STATIC, /* Value is at fixed address */ - LOC_REGISTER, /* Value is in register */ - LOC_ARG, /* Value is at spec'd position in arglist */ - LOC_LOCAL, /* Value is at spec'd pos in stack frame */ - LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE - Symbols in the namespace STRUCT_NAMESPACE - all have this class. */ - LOC_LABEL, /* Value is address in the code */ - LOC_BLOCK, /* Value is address of a `struct block'. - Function names have this class. */ - LOC_EXTERNAL, /* Value is at address not in this compilation. - This is used for .comm symbols - and for extern symbols within functions. - Inside GDB, this is changed to LOC_STATIC once the - real address is obtained from a loader symbol. */ - LOC_CONST_BYTES /* Value is a constant byte-sequence. */ -}; - -struct symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class */ - enum address_class class; - /* Data type of value */ - struct type *type; - /* constant value, or address if static, or register number, - or offset in arguments, or offset in stack frame. */ - union - { - long value; - struct block *block; /* for LOC_BLOCK */ - char *bytes; /* for LOC_CONST_BYTES */ - } - value; -}; - -/* Source-file information. - This describes the relation between source files and line numbers - and addresses in the program text. */ - -struct sourcevector -{ - int length; /* Number of source files described */ - struct source *source[1]; /* Descriptions of the files */ -}; - -/* Line number and address of one line. */ - -struct line -{ - int linenum; - int address; -}; - -/* All the information on one source file. */ - -struct source -{ - char *name; /* Name of file */ - int nlines; /* Number of lines that follow */ - struct line lines[1]; /* Information on each line */ -}; diff --git a/usr.bin/lex/flex.1 b/usr.bin/lex/flex.1 deleted file mode 100644 index 6aba4d6977ac..000000000000 --- a/usr.bin/lex/flex.1 +++ /dev/null @@ -1,1001 +0,0 @@ -.TH FLEX 1 "November 1993" "Version 2.4" -.SH NAME -flex \- fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B \-lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.PP -For full documentation, see -.B flexdoc(1). -This manual entry is intended for use as a quick reference. -.SH OPTIONS -.I flex -has the following options: -.TP -.B \-b -generate backing-up information to -.I lex.backup. -This is a list of scanner states which require backing up and the input -characters on which they do so. By adding rules one can remove -backing-up states. If all backing-up states are eliminated and -.B \-Cf -or -.B \-CF -is used, the generated scanner will run faster. -.TP -.B \-c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B \-c -specified table-compression options. This functionality is -now given by the -.B \-C -flag. To ease the the impact of this change, when -.I flex -encounters -.B \-c, -it currently issues a warning message and assumes that -.B \-C -was desired instead. In the future this "promotion" of -.B \-c -to -.B \-C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B \-d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), the scanner will -write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backs up, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B \-f -specifies -.I fast scanner. -No table compression is done and stdio is bypassed. -The result is large but fast. This option is equivalent to -.B \-Cfr -(see below). -.TP -.B \-h -generates a "help" summary of -.I flex's -options to -.I stderr -and then exits. -.TP -.B \-i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B \-l -turns on maximum compatibility with the original AT&T lex implementation, -at a considerable performance cost. This option is incompatible with -.B \-+, \-f, \-F, \-Cf, -or -.B \-CF. -See -.I flexdoc(1) -for details. -.TP -.B \-n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B \-p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a loss of performance in the resulting scanner. -If you give the flag twice, you will also get comments regarding -features that lead to minor performance losses. -.TP -.B \-s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. -.TP -.B \-t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B \-v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -.TP -.B \-w -suppresses warning messages. -.TP -.B \-B -instructs -.I flex -to generate a -.I batch -scanner instead of an -.I interactive -scanner (see -.B \-I -below). See -.I flexdoc(1) -for details. Scanners using -.B \-Cf -or -.B \-CF -compression options automatically specify this option, too. -.TP -.B \-F -specifies that the -.ul -fast -scanner table representation should be used (and stdio bypassed). -This representation is about as fast as the full table representation -.B (-f), -and for some sets of patterns will be considerably smaller (and for -others, larger). It cannot be used with the -.B \-+ -option. See -.B flexdoc(1) -for more details. -.IP -This option is equivalent to -.B \-CFr -(see below). -.TP -.B \-I -instructs -.I flex -to generate an -.I interactive -scanner, that is, a scanner which stops immediately rather than -looking ahead if it knows -that the currently scanned text cannot be part of a longer rule's match. -This is the opposite of -.I batch -scanners (see -.B \-B -above). See -.B flexdoc(1) -for details. -.IP -Note, -.B \-I -cannot be used in conjunction with -.I full -or -.I fast tables, -i.e., the -.B \-f, \-F, \-Cf, -or -.B \-CF -flags. For other table compression options, -.B \-I -is the default. -.TP -.B \-L -instructs -.I flex -not to generate -.B #line -directives in -.B lex.yy.c. -The default is to generate such directives so error -messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -.TP -.B \-T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stderr -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B \-V -prints the version number to -.I stderr -and exits. -.TP -.B \-7 -instructs -.I flex -to generate a 7-bit scanner, which can save considerable table space, -especially when using -.B \-Cf -or -.B \-CF -(and, at most sites, -.B \-7 -is on by default for these options. To see if this is the case, use the -.B -v -verbose flag and check the flag summary it reports). -.TP -.B \-8 -instructs -.I flex -to generate an 8-bit scanner. This is the default except for the -.B \-Cf -and -.B \-CF -compression options, for which the default is site-dependent, and -can be checked by inspecting the flag summary generated by the -.B \-v -option. -.TP -.B \-+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ Scanners in -.I flexdoc(1) -for details. -.TP -.B \-C[aefFmr] -controls the degree of table compression and scanner optimization. -.IP -.B \-Ca -trade off larger tables in the generated scanner for faster performance -because the elements of the tables are better aligned for memory access -and computation. This option can double the size of the tables used by -your scanner. -.IP -.B \-Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties. -Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B \-Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B \-CF -specifies that the alternate fast scanner representation (described in -.B flexdoc(1)) -should be used. This option cannot be used with -.B \-+. -.IP -.B \-Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -.B \-Cr -causes the generated scanner to -.I bypass -using stdio for input. In general this option results in a minor -performance gain only worthwhile if used in conjunction with -.B \-Cf -or -.B \-CF. -It can cause surprising behavior if you use stdio yourself to -read from -.I yyin -prior to calling the scanner. -.IP -A lone -.B \-C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B \-Cf -or -.B \-CF -and -.B \-Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed. -.IP -The default setting is -.B \-Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - -.fi -.IP -.B \-C -options are cumulative. -.TP -.B \-Pprefix -changes the default -.I "yy" -prefix used by -.I flex -to be -.I prefix -instead. See -.I flexdoc(1) -for a description of all the global variables and file names that -this affects. -.TP -.B \-Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH SUMMARY OF FLEX REGULAR EXPRESSIONS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. -.PP -Some notes on patterns: -.IP - -Negated character classes -.I match newlines -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. The following are all illegal: -.nf - - foo/bar$ - foo|(bar$) - foo|^bar - foobar - -.fi -.SH SUMMARY OF SPECIAL ACTIONS -In addition to arbitrary C code, the following can appear in actions: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition. -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). -.B yytext -and -.B yyleng -are set up appropriately. Note that -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.B \-f -or -.B \-F -options. -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -.IP - -.B input() -reads the next character from the input stream (this routine is called -.B yyinput() -if the scanner is compiled using -.B C++). -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -.IP -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.IP - -.B YY_NEW_FILE -is an action available only in <> rules. It means "Okay, I've -set up a new input file, continue scanning". It is no longer required; -you can just assign -.I yyin -to point to a new file in the <> action. -.IP - -.B yy_create_buffer( file, size ) -takes a -.I FILE -pointer and an integer -.I size. -It returns a YY_BUFFER_STATE -handle to a new input buffer large enough to accomodate -.I size -characters and associated with the given file. When in doubt, use -.B YY_BUF_SIZE -for the size. -.IP - -.B yy_switch_to_buffer( new_buffer ) -switches the scanner's processing to scan for tokens from -the given buffer, which must be a YY_BUFFER_STATE. -.IP - -.B yy_delete_buffer( buffer ) -deletes the given buffer. -.SH VALUES AVAILABLE TO THE USER -.IP - -.B char *yytext -holds the text of the current token. It may be modified but not lengthened -(you cannot append characters to the end). Modifying the last character -may affect the activity of rules anchored using '^' during the next scan; -see -.B flexdoc(1) -for details. -.IP -If the special directive -.B %array -appears in the first section of the scanner description, then -.B yytext -is instead declared -.B char yytext[YYLMAX], -where -.B YYLMAX -is a macro definition that you can redefine in the first section -if you don't like the default value (generally 8KB). Using -.B %array -results in somewhat slower scanners, but the value of -.B yytext -becomes immune to calls to -.I input() -and -.I unput(), -which potentially destroy its value when -.B yytext -is a character pointer. The opposite of -.B %array -is -.B %pointer, -which is the default. -.IP -You cannot use -.B %array -when generating C++ scanner classes -(the -.B \-+ -flag). -.IP - -.B int yyleng -holds the length of the current token. -.IP - -.B FILE *yyin -is the file which by default -.I flex -reads from. It may be redefined but doing so only makes sense before -scanning begins or after an EOF has been encountered. Changing it in -the midst of scanning will have unexpected results since -.I flex -buffers its input; use -.B yyrestart() -instead. -Once scanning terminates because an end-of-file -has been seen, -.B -you can assign -.I yyin -at the new input file and then call the scanner again to continue scanning. -.IP - -.B void yyrestart( FILE *new_file ) -may be called to point -.I yyin -at the new input file. The switch-over to the new file is immediate -(any previously buffered-up input is lost). Note that calling -.B yyrestart() -with -.I yyin -as an argument thus throws away the current input buffer and continues -scanning the same input file. -.IP - -.B FILE *yyout -is the file to which -.B ECHO -actions are done. It can be reassigned by the user. -.IP - -.B YY_CURRENT_BUFFER -returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.IP - -.B YY_START -returns an integer value corresponding to the current start -condition. You can subsequently use this value with -.B BEGIN -to return to that start condition. -.SH MACROS AND FUNCTIONS YOU CAN REDEFINE -.IP - -.B YY_DECL -controls how the scanning routine is declared. -By default, it is "int yylex()", or, if prototypes are being -used, "int yylex(void)". This definition may be changed by redefining -the "YY_DECL" macro. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.IP - -The nature of how the scanner -gets its input can be controlled by redefining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -A sample redefinition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #undef YY_INPUT - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -.IP - -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the function -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.IP -The default -.B yywrap() -always returns 1. -.IP - -YY_USER_ACTION -can be redefined to provide an action -which is always executed prior to the matched rule's action. -.IP - -The macro -.B YY_USER_INIT -may be redefined to provide an action which is always executed before -the first scan. -.IP - -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -.SH FILES -.TP -.B \-lfl -library with which to link scanners to obtain the default versions -of -.I yywrap() -and/or -.I main(). -.TP -.I lex.yy.c -generated scanner (called -.I lexyy.c -on some systems). -.TP -.I lex.yy.cc -generated C++ scanner class, when using -.B -+. -.TP -.I -header file defining the C++ scanner base class, -.B FlexLexer, -and its derived class, -.B yyFlexLexer. -.TP -.I flex.skl -skeleton scanner. This file is only used when building flex, not when -flex executes. -.TP -.I lex.backup -backing-up information for -.B \-b -flag (called -.I lex.bck -on some systems). -.SH "SEE ALSO" -.PP -flexdoc(1), lex(1), yacc(1), sed(1), awk(1). -.PP -M. E. Lesk and E. Schmidt, -.I LEX \- Lexical Analyzer Generator -.SH DIAGNOSTICS -.PP -.I reject_used_but_not_detected undefined -or -.PP -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.PP -.I flex scanner jammed - -a scanner compiled with -.B \-s -has encountered an input string which wasn't matched by -any of its rules. -.PP -.I warning, rule cannot be matched -indicates that the given rule -cannot be matched because it follows other rules that will -always match the same text as it. See -.I flexdoc(1) -for an example. -.PP -.I warning, -.B \-s -.I -option given but default rule can be matched -means that it is possible (perhaps only in a particular start condition) -that the default rule (match any single character) is the only one -that will match a particular input. Since -.PP -.I scanner input buffer overflowed - -a scanner rule matched more text than the available dynamic memory. -.PP -.I token too large, exceeds YYLMAX - -your scanner uses -.B %array -and one of its rules matched a string longer than the -.B YYLMAX -constant (8K bytes by default). You can increase the value by -#define'ing -.B YYLMAX -in the definitions section of your -.I flex -input. -.PP -.I scanner requires \-8 flag to -.I use the character 'x' - -Your scanner specification includes recognizing the 8-bit character -.I 'x' -and you did not specify the \-8 flag, and your scanner defaulted to 7-bit -because you used the -.B \-Cf -or -.B \-CF -table compression options. -.PP -.I flex scanner push-back overflow - -you used -.B unput() -to push back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in -.B yytext. -Ideally the scanner should dynamically resize the buffer in this case, but at -present it does not. -.PP -.I -input buffer overflow, can't enlarge buffer because scanner uses REJECT - -the scanner was working on matching an extremely large token and needed -to expand the input buffer. This doesn't work with scanners that use -.B -REJECT. -.PP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -or use C++ scanner classes (the -.B \-+ -option), which are fully reentrant. -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. -.PP -See flexdoc(1) for additional credits and the address to send comments to. -.SH DEFICIENCIES / BUGS -.PP -Some trailing context -patterns cannot be properly matched and generate -warning messages ("dangerous trailing context"). These are -patterns where the ending of the -first part of the rule matches the beginning of the second -part, such as "zx*/xy*", where the 'x*' matches the 'x' at -the beginning of the trailing context. (Note that the POSIX draft -states that the text matched by such patterns is undefined.) -.PP -For some trailing context rules, parts which are actually fixed-length are -not recognized as such, leading to the abovementioned performance loss. -In particular, parts using '|' or {n} (such as "foo{3}") are always -considered variable-length. -.PP -Combining trailing context with the special '|' action can result in -.I fixed -trailing context being turned into the more expensive -.I variable -trailing context. For example, in the following: -.nf - - %% - abc | - xyz/def - -.fi -.PP -Use of -.B unput() -or -.B input() -invalidates yytext and yyleng, unless the -.B %array -directive -or the -.B \-l -option has been used. -.PP -Use of unput() to push back more text than was matched can -result in the pushed-back text matching a beginning-of-line ('^') -rule even though it didn't come at the beginning of the line -(though this is rare!). -.PP -Pattern-matching of NUL's is substantially slower than matching other -characters. -.PP -Dynamic resizing of the input buffer is slow, as it entails rescanning -all the text matched so far by the current (generally huge) token. -.PP -.I flex -does not generate correct #line directives for code internal -to the scanner; thus, bugs in -.I flex.skl -yield bogus line numbers. -.PP -Due to both buffering of input and read-ahead, you cannot intermix -calls to routines, such as, for example, -.B getchar(), -with -.I flex -rules and expect it to work. Call -.B input() -instead. -.PP -The total table entries listed by the -.B \-v -flag excludes the number of table entries needed to determine -what rule has been matched. The number of entries is equal -to the number of DFA states if the scanner does not use -.B REJECT, -and somewhat greater than the number of states if it does. -.PP -.B REJECT -cannot be used with the -.B \-f -or -.B \-F -options. -.PP -The -.I flex -internal algorithms need documentation. diff --git a/usr.bin/lex/flexdoc.1 b/usr.bin/lex/flexdoc.1 deleted file mode 100644 index b80d5699abca..000000000000 --- a/usr.bin/lex/flexdoc.1 +++ /dev/null @@ -1,3045 +0,0 @@ -.TH FLEXDOC 1 "November 1993" "Version 2.4" -.SH NAME -flexdoc \- documentation for flex, fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B \-lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.SH SOME SIMPLE EXAMPLES -.PP -First some simple examples to get the flavor of how one uses -.I flex. -The following -.I flex -input specifies a scanner which whenever it encounters the string -"username" will replace it with the user's login name: -.nf - - %% - username printf( "%s", getlogin() ); - -.fi -By default, any text not matched by a -.I flex -scanner -is copied to the output, so the net effect of this scanner is -to copy its input file to its output with each occurrence -of "username" expanded. -In this input, there is just one rule. "username" is the -.I pattern -and the "printf" is the -.I action. -The "%%" marks the beginning of the rules. -.PP -Here's another simple example: -.nf - - int num_lines = 0, num_chars = 0; - - %% - \\n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf( "# of lines = %d, # of chars = %d\\n", - num_lines, num_chars ); - } - -.fi -This scanner counts the number of characters and the number -of lines in its input (it produces no output other than the -final report on the counts). The first line -declares two globals, "num_lines" and "num_chars", which are accessible -both inside -.B yylex() -and in the -.B main() -routine declared after the second "%%". There are two rules, one -which matches a newline ("\\n") and increments both the line count and -the character count, and one which matches any character other than -a newline (indicated by the "." regular expression). -.PP -A somewhat more complicated example: -.nf - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf( "An integer: %s (%d)\\n", yytext, - atoi( yytext ) ); - } - - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\\n", yytext, - atof( yytext ) ); - } - - if|then|begin|end|procedure|function { - printf( "A keyword: %s\\n", yytext ); - } - - {ID} printf( "An identifier: %s\\n", yytext ); - - "+"|"-"|"*"|"/" printf( "An operator: %s\\n", yytext ); - - "{"[^}\\n]*"}" /* eat up one-line comments */ - - [ \\t\\n]+ /* eat up whitespace */ - - . printf( "Unrecognized character: %s\\n", yytext ); - - %% - - main( argc, argv ) - int argc; - char **argv; - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - } - -.fi -This is the beginnings of a simple scanner for a language like -Pascal. It identifies different types of -.I tokens -and reports on what it has seen. -.PP -The details of this example will be explained in the following -sections. -.SH FORMAT OF THE INPUT FILE -The -.I flex -input file consists of three sections, separated by a line with just -.B %% -in it: -.nf - - definitions - %% - rules - %% - user code - -.fi -The -.I definitions -section contains declarations of simple -.I name -definitions to simplify the scanner specification, and declarations of -.I start conditions, -which are explained in a later section. -.PP -Name definitions have the form: -.nf - - name definition - -.fi -The "name" is a word beginning with a letter or an underscore ('_') -followed by zero or more letters, digits, '_', or '-' (dash). -The definition is taken to begin at the first non-white-space character -following the name and continuing to the end of the line. -The definition can subsequently be referred to using "{name}", which -will expand to "(definition)". For example, -.nf - - DIGIT [0-9] - ID [a-z][a-z0-9]* - -.fi -defines "DIGIT" to be a regular expression which matches a -single digit, and -"ID" to be a regular expression which matches a letter -followed by zero-or-more letters-or-digits. -A subsequent reference to -.nf - - {DIGIT}+"."{DIGIT}* - -.fi -is identical to -.nf - - ([0-9])+"."([0-9])* - -.fi -and matches one-or-more digits followed by a '.' followed -by zero-or-more digits. -.PP -The -.I rules -section of the -.I flex -input contains a series of rules of the form: -.nf - - pattern action - -.fi -where the pattern must be unindented and the action must begin -on the same line. -.PP -See below for a further description of patterns and actions. -.PP -Finally, the user code section is simply copied to -.B lex.yy.c -verbatim. -It is used for companion routines which call or are called -by the scanner. The presence of this section is optional; -if it is missing, the second -.B %% -in the input file may be skipped, too. -.PP -In the definitions and rules sections, any -.I indented -text or text enclosed in -.B %{ -and -.B %} -is copied verbatim to the output (with the %{}'s removed). -The %{}'s must appear unindented on lines by themselves. -.PP -In the rules section, -any indented or %{} text appearing before the -first rule may be used to declare variables -which are local to the scanning routine and (after the declarations) -code which is to be executed whenever the scanning routine is entered. -Other indented or %{} text in the rule section is still copied to the output, -but its meaning is not well-defined and it may well cause compile-time -errors (this feature is present for -.I POSIX -compliance; see below for other such features). -.PP -In the definitions section (but not in the rules section), -an unindented comment (i.e., a line -beginning with "/*") is also copied verbatim to the output up -to the next "*/". -.SH PATTERNS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -Note that inside of a character class, all regular expression operators -lose their special meaning except escape ('\\') and the character class -operators, '-', ']', and, at the beginning of the class, '^'. -.PP -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. For example, -.nf - - foo|bar* - -.fi -is the same as -.nf - - (foo)|(ba(r*)) - -.fi -since the '*' operator has higher precedence than concatenation, -and concatenation higher than alternation ('|'). This pattern -therefore matches -.I either -the string "foo" -.I or -the string "ba" followed by zero-or-more r's. -To match "foo" or zero-or-more "bar"'s, use: -.nf - - foo|(bar)* - -.fi -and to match zero-or-more "foo"'s-or-"bar"'s: -.nf - - (foo|bar)* - -.fi -.PP -Some notes on patterns: -.IP - -A negated character class such as the example "[^A-Z]" -above -.I will match a newline -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). This is unlike how many other regular -expression tools treat negated character classes, but unfortunately -the inconsistency is historically entrenched. -Matching newlines means that a pattern like [^"]* can match the entire -input unless there's another quote in the input. -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. A '^' which does not occur at -the beginning of a rule or a '$' which does not occur at the end of -a rule loses its special properties and is treated as a normal character. -.IP -The following are illegal: -.nf - - foo/bar$ - foobar - -.fi -Note that the first of these, can be written "foo/bar\\n". -.IP -The following will result in '$' or '^' being treated as a normal character: -.nf - - foo|(bar$) - foo|^bar - -.fi -If what's wanted is a "foo" or a bar-followed-by-a-newline, the following -could be used (the special '|' action is explained below): -.nf - - foo | - bar$ /* action goes here */ - -.fi -A similar trick will work for matching a foo or a -bar-at-the-beginning-of-a-line. -.SH HOW THE INPUT IS MATCHED -When the generated scanner is run, it analyzes its input looking -for strings which match any of its patterns. If it finds more than -one match, it takes the one matching the most text (for trailing -context rules, this includes the length of the trailing part, even -though it will then be returned to the input). If it finds two -or more matches of the same length, the -rule listed first in the -.I flex -input file is chosen. -.PP -Once the match is determined, the text corresponding to the match -(called the -.I token) -is made available in the global character pointer -.B yytext, -and its length in the global integer -.B yyleng. -The -.I action -corresponding to the matched pattern is then executed (a more -detailed description of actions follows), and then the remaining -input is scanned for another match. -.PP -If no match is found, then the -.I default rule -is executed: the next character in the input is considered matched and -copied to the standard output. Thus, the simplest legal -.I flex -input is: -.nf - - %% - -.fi -which generates a scanner that simply copies its input (one character -at a time) to its output. -.PP -Note that -.B yytext -can be defined in two different ways: either as a character -.I pointer -or as a character -.I array. -You can control which definition -.I flex -uses by including one of the special directives -.B %pointer -or -.B %array -in the first (definitions) section of your flex input. The default is -.B %pointer, -unless you use the -.B -l -lex compatibility option, in which case -.B yytext -will be an array. -The advantage of using -.B %pointer -is substantially faster scanning and no buffer overflow when matching -very large tokens (unless you run out of dynamic memory). The disadvantage -is that you are restricted in how your actions can modify -.B yytext -(see the next section), and calls to the -.B input() -and -.B unput() -functions destroy the present contents of -.B yytext, -which can be a considerable porting headache when moving between different -.I lex -versions. -.PP -The advantage of -.B %array -is that you can then modify -.B yytext -to your heart's content, and calls to -.B input() -and -.B unput() -do not destroy -.B yytext -(see below). Furthermore, existing -.I lex -programs sometimes access -.B yytext -externally using declarations of the form: -.nf - extern char yytext[]; -.fi -This definition is erroneous when used with -.B %pointer, -but correct for -.B %array. -.PP -.B %array -defines -.B yytext -to be an array of -.B YYLMAX -characters, which defaults to a fairly large value. You can change -the size by simply #define'ing -.B YYLMAX -to a different value in the first section of your -.I flex -input. As mentioned above, with -.B %pointer -yytext grows dynamically to accomodate large tokens. While this means your -.B %pointer -scanner can accomodate very large tokens (such as matching entire blocks -of comments), bear in mind that each time the scanner must resize -.B yytext -it also must rescan the entire token from the beginning, so matching such -tokens can prove slow. -.B yytext -presently does -.I not -dynamically grow if a call to -.B unput() -results in too much text being pushed back; instead, a run-time error results. -.PP -Also note that you cannot use -.B %array -with C++ scanner classes -(the -.B \-+ -option; see below). -.SH ACTIONS -Each pattern in a rule has a corresponding action, which can be any -arbitrary C statement. The pattern ends at the first non-escaped -whitespace character; the remainder of the line is its action. If the -action is empty, then when the pattern is matched the input token -is simply discarded. For example, here is the specification for a program -which deletes all occurrences of "zap me" from its input: -.nf - - %% - "zap me" - -.fi -(It will copy all other characters in the input to the output since -they will be matched by the default rule.) -.PP -Here is a program which compresses multiple blanks and tabs down to -a single blank, and throws away whitespace found at the end of a line: -.nf - - %% - [ \\t]+ putchar( ' ' ); - [ \\t]+$ /* ignore this token */ - -.fi -.PP -If the action contains a '{', then the action spans till the balancing '}' -is found, and the action may cross multiple lines. -.I flex -knows about C strings and comments and won't be fooled by braces found -within them, but also allows actions to begin with -.B %{ -and will consider the action to be all the text up to the next -.B %} -(regardless of ordinary braces inside the action). -.PP -An action consisting solely of a vertical bar ('|') means "same as -the action for the next rule." See below for an illustration. -.PP -Actions can include arbitrary C code, including -.B return -statements to return a value to whatever routine called -.B yylex(). -Each time -.B yylex() -is called it continues processing tokens from where it last left -off until it either reaches -the end of the file or executes a return. -.PP -Actions are free to modify -.B yytext -except for lengthening it (adding -characters to its end--these will overwrite later characters in the -input stream). Modifying the final character of yytext may alter -whether when scanning resumes rules anchored with '^' are active. -Specifically, changing the final character of yytext to a newline will -activate such rules on the next scan, and changing it to anything else -will deactivate the rules. Users should not rely on this behavior being -present in future releases. Finally, note that none of this paragraph -applies when using -.B %array -(see above). -.PP -Actions are free to modify -.B yyleng -except they should not do so if the action also includes use of -.B yymore() -(see below). -.PP -There are a number of special directives which can be included within -an action: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition (see below). -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). The rule is chosen as described -above in "How the Input is Matched", and -.B yytext -and -.B yyleng -set up appropriately. -It may either be one which matched as much text -as the originally chosen rule but came later in the -.I flex -input file, or one which matched less text. -For example, the following will both count the -words in the input and call the routine special() whenever "frob" is seen: -.nf - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \\t\\n]+ ++word_count; - -.fi -Without the -.B REJECT, -any "frob"'s in the input would not be counted as words, since the -scanner normally executes only one action per token. -Multiple -.B REJECT's -are allowed, each one finding the next best choice to the currently -active rule. For example, when the following scanner scans the token -"abcd", it will write "abcdabcaba" to the output: -.nf - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\\n /* eat up any unmatched character */ - -.fi -(The first three rules share the fourth's action since they use -the special '|' action.) -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.I -Cf -or -.I -CF -options (see below). -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. For example, given the input "mega-kludge" -the following will write "mega-mega-kludge" to the output: -.nf - - %% - mega- ECHO; yymore(); - kludge ECHO; - -.fi -First "mega-" is matched and echoed to the output. Then "kludge" -is matched, but the previous "mega-" is still hanging around at the -beginning of -.B yytext -so the -.B ECHO -for the "kludge" rule will actually write "mega-kludge". -The presence of -.B yymore() -in the scanner's action entails a minor performance penalty in the -scanner's matching speed. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). For example, on the input "foobar" the following will write out -"foobarbar": -.nf - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - -.fi -An argument of 0 to -.B yyless -will cause the entire current input string to be scanned again. Unless you've -changed how the scanner will subsequently process its input (using -.B BEGIN, -for example), this will result in an endless loop. -.PP -Note that -.B yyless -is a macro and can only be used in the flex input file, not from -other source files. -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -The following action will take the current token and cause it -to be rescanned enclosed in parentheses. -.nf - - { - int i; - unput( ')' ); - for ( i = yyleng - 1; i >= 0; --i ) - unput( yytext[i] ); - unput( '(' ); - } - -.fi -Note that since each -.B unput() -puts the given character back at the -.I beginning -of the input stream, pushing back strings must be done back-to-front. -Also note that you cannot put back -.B EOF -to attempt to mark the input stream with an end-of-file. -.IP - -.B input() -reads the next character from the input stream. For example, -the following is one way to eat up C comments: -.nf - - %% - "/*" { - register int c; - - for ( ; ; ) - { - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = input()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } - } - -.fi -(Note that if the scanner is compiled using -.B C++, -then -.B input() -is instead referred to as -.B yyinput(), -in order to avoid a name clash with the -.B C++ -stream by the name of -.I input.) -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.SH THE GENERATED SCANNER -The output of -.I flex -is the file -.B lex.yy.c, -which contains the scanning routine -.B yylex(), -a number of tables used by it for matching tokens, and a number -of auxiliary routines and macros. By default, -.B yylex() -is declared as follows: -.nf - - int yylex() - { - ... various definitions and the actions in here ... - } - -.fi -(If your environment supports function prototypes, then it will -be "int yylex( void )".) This definition may be changed by defining -the "YY_DECL" macro. For example, you could use: -.nf - - #define YY_DECL float lexscan( a, b ) float a, b; - -.fi -to give the scanning routine the name -.I lexscan, -returning a float, and taking two floats as arguments. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.PP -Whenever -.B yylex() -is called, it scans tokens from the global input file -.I yyin -(which defaults to stdin). It continues until it either reaches -an end-of-file (at which point it returns the value 0) or -one of its actions executes a -.I return -statement. -.PP -If the scanner reaches an end-of-file, subsequent calls are undefined -unless either -.I yyin -is pointed at a new input file (in which case scanning continues from -that file), or -.B yyrestart() -is called. -.B yyrestart() -takes one argument, a -.B FILE * -pointer, and initializes -.I yyin -for scanning from that file. Essentially there is no difference between -just assigning -.I yyin -to a new input file or using -.B yyrestart() -to do so; the latter is available for compatibility with previous versions -of -.I flex, -and because it can be used to switch input files in the middle of scanning. -It can also be used to throw away the current input buffer, by calling -it with an argument of -.I yyin. -.PP -If -.B yylex() -stops scanning due to executing a -.I return -statement in one of the actions, the scanner may then be called again and it -will resume scanning where it left off. -.PP -By default (and for purposes of efficiency), the scanner uses -block-reads rather than simple -.I getc() -calls to read characters from -.I yyin. -The nature of how it gets its input can be controlled by defining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -.PP -A sample definition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -This definition will change the input processing to occur -one character at a time. -.PP -You also can add in things like keeping track of the -input line number this way; but don't expect your scanner to -go very fast. -.PP -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.PP -The default -.B yywrap() -always returns 1. -.PP -The scanner writes its -.B ECHO -output to the -.I yyout -global (default, stdout), which may be redefined by the user simply -by assigning it to some other -.B FILE -pointer. -.SH START CONDITIONS -.I flex -provides a mechanism for conditionally activating rules. Any rule -whose pattern is prefixed with "" will only be active when -the scanner is in the start condition named "sc". For example, -.nf - - [^"]* { /* eat up the string body ... */ - ... - } - -.fi -will be active only when the scanner is in the "STRING" start -condition, and -.nf - - \\. { /* handle an escape ... */ - ... - } - -.fi -will be active only when the current start condition is -either "INITIAL", "STRING", or "QUOTE". -.PP -Start conditions -are declared in the definitions (first) section of the input -using unindented lines beginning with either -.B %s -or -.B %x -followed by a list of names. -The former declares -.I inclusive -start conditions, the latter -.I exclusive -start conditions. A start condition is activated using the -.B BEGIN -action. Until the next -.B BEGIN -action is executed, rules with the given start -condition will be active and -rules with other start conditions will be inactive. -If the start condition is -.I inclusive, -then rules with no start conditions at all will also be active. -If it is -.I exclusive, -then -.I only -rules qualified with the start condition will be active. -A set of rules contingent on the same exclusive start condition -describe a scanner which is independent of any of the other rules in the -.I flex -input. Because of this, -exclusive start conditions make it easy to specify "mini-scanners" -which scan portions of the input that are syntactically different -from the rest (e.g., comments). -.PP -If the distinction between inclusive and exclusive start conditions -is still a little vague, here's a simple example illustrating the -connection between the two. The set of rules: -.nf - - %s example - %% - foo /* do something */ - -.fi -is equivalent to -.nf - - %x example - %% - foo /* do something */ - -.fi -.PP -Also note that the special start-condition specifier -.B <*> -matches every start condition. Thus, the above example could also -have been written; -.nf - - %x example - %% - <*>foo /* do something */ - -.fi -.PP -The default rule (to -.B ECHO -any unmatched character) remains active in start conditions. -.PP -.B BEGIN(0) -returns to the original state where only the rules with -no start conditions are active. This state can also be -referred to as the start-condition "INITIAL", so -.B BEGIN(INITIAL) -is equivalent to -.B BEGIN(0). -(The parentheses around the start condition name are not required but -are considered good style.) -.PP -.B BEGIN -actions can also be given as indented code at the beginning -of the rules section. For example, the following will cause -the scanner to enter the "SPECIAL" start condition whenever -.I yylex() -is called and the global variable -.I enter_special -is true: -.nf - - int enter_special; - - %x SPECIAL - %% - if ( enter_special ) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - -.fi -.PP -To illustrate the uses of start conditions, -here is a scanner which provides two different interpretations -of a string like "123.456". By default it will treat it as -as three tokens, the integer "123", a dot ('.'), and the integer "456". -But if the string is preceded earlier in the line by the string -"expect-floats" -it will treat it as a single token, the floating-point number -123.456: -.nf - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - printf( "found a float, = %f\\n", - atof( yytext ) ); - } - \\n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - } - - [0-9]+ { - printf( "found an integer, = %d\\n", - atoi( yytext ) ); - } - - "." printf( "found a dot\\n" ); - -.fi -Here is a scanner which recognizes (and discards) C comments while -maintaining a count of the current input line. -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This scanner goes to a bit of trouble to match as much -text as possible with each rule. In general, when attempting to write -a high-speed scanner try to match as much possible in each rule, as -it's a big win. -.PP -Note that start-conditions names are really integer values and -can be stored as such. Thus, the above could be extended in the -following fashion: -.nf - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(comment_caller); - -.fi -Furthermore, you can access the current start condition using -the integer-valued -.B YY_START -macro. For example, the above assignments to -.I comment_caller -could instead be written -.nf - - comment_caller = YY_START; -.fi -.PP -Note that start conditions do not have their own name-space; %s's and %x's -declare names in the same fashion as #define's. -.PP -Finally, here's an example of how to match C-style quoted strings using -exclusive start conditions, including expanded escape sequences (but -not including checking for a string that's too long): -.nf - - %x str - - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - - \\" string_buf_ptr = string_buf; BEGIN(str); - - \\" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\\0'; - /* return string constant token type and - * value to parser - */ - } - - \\n { - /* error - unterminated string constant */ - /* generate error message */ - } - - \\\\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - } - - \\\\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\\48' or '\\0777777' - */ - } - - \\\\n *string_buf_ptr++ = '\\n'; - \\\\t *string_buf_ptr++ = '\\t'; - \\\\r *string_buf_ptr++ = '\\r'; - \\\\b *string_buf_ptr++ = '\\b'; - \\\\f *string_buf_ptr++ = '\\f'; - - \\\\(.|\\n) *string_buf_ptr++ = yytext[1]; - - [^\\\\\\n\\"]+ { - char *yytext_ptr = yytext; - - while ( *yytext_ptr ) - *string_buf_ptr++ = *yytext_ptr++; - } - -.fi -.SH MULTIPLE INPUT BUFFERS -Some scanners (such as those which support "include" files) -require reading from several input streams. As -.I flex -scanners do a large amount of buffering, one cannot control -where the next input will be read from by simply writing a -.B YY_INPUT -which is sensitive to the scanning context. -.B YY_INPUT -is only called when the scanner reaches the end of its buffer, which -may be a long time after scanning a statement such as an "include" -which requires switching the input source. -.PP -To negotiate these sorts of problems, -.I flex -provides a mechanism for creating and switching between multiple -input buffers. An input buffer is created by using: -.nf - - YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) - -.fi -which takes a -.I FILE -pointer and a size and creates a buffer associated with the given -file and large enough to hold -.I size -characters (when in doubt, use -.B YY_BUF_SIZE -for the size). It returns a -.B YY_BUFFER_STATE -handle, which may then be passed to other routines: -.nf - - void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - -.fi -switches the scanner's input buffer so subsequent tokens will -come from -.I new_buffer. -Note that -.B yy_switch_to_buffer() -may be used by yywrap() to set things up for continued scanning, instead -of opening a new file and pointing -.I yyin -at it. -.nf - - void yy_delete_buffer( YY_BUFFER_STATE buffer ) - -.fi -is used to reclaim the storage associated with a buffer. -.PP -.B yy_new_buffer() -is an alias for -.B yy_create_buffer(), -provided for compatibility with the C++ use of -.I new -and -.I delete -for creating and destroying dynamic objects. -.PP -Finally, the -.B YY_CURRENT_BUFFER -macro returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.PP -Here is an example of using these features for writing a scanner -which expands include files (the -.B <> -feature is discussed below): -.nf - - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\\n]*\\n? ECHO; - - [ \\t]* /* eat the whitespace */ - [^ \\t\\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( ... ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - } - - <> { - if ( --include_stack_ptr < 0 ) - { - yyterminate(); - } - - else - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } - -.fi -.SH END-OF-FILE RULES -The special rule "<>" indicates -actions which are to be taken when an end-of-file is -encountered and yywrap() returns non-zero (i.e., indicates -no further files to process). The action must finish -by doing one of four things: -.IP - -assigning -.I yyin -to a new input file (in previous versions of flex, after doing the -assignment you had to call the special action -.B YY_NEW_FILE; -this is no longer necessary); -.IP - -executing a -.I return -statement; -.IP - -executing the special -.B yyterminate() -action; -.IP - -or, switching to a new buffer using -.B yy_switch_to_buffer() -as shown in the example above. -.PP -<> rules may not be used with other -patterns; they may only be qualified with a list of start -conditions. If an unqualified <> rule is given, it -applies to -.I all -start conditions which do not already have <> actions. To -specify an <> rule for only the initial start condition, use -.nf - - <> - -.fi -.PP -These rules are useful for catching things like unclosed comments. -An example: -.nf - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error( "unterminated quote" ); - yyterminate(); - } - <> { - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - } - -.fi -.SH MISCELLANEOUS MACROS -The macro -.bd -YY_USER_ACTION -can be defined to provide an action -which is always executed prior to the matched rule's action. For example, -it could be #define'd to call a routine to convert yytext to lower-case. -.PP -The macro -.B YY_USER_INIT -may be defined to provide an action which is always executed before -the first scan (and before the scanner's internal initializations are done). -For example, it could be used to call a routine to read -in a data table or open a logging file. -.PP -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -Redefining -.B YY_BREAK -allows, for example, C++ users to -#define YY_BREAK to do nothing (while being very careful that every -rule ends with a "break" or a "return"!) to avoid suffering from -unreachable statement warnings where because a rule's action ends with -"return", the -.B YY_BREAK -is inaccessible. -.SH INTERFACING WITH YACC -One of the main uses of -.I flex -is as a companion to the -.I yacc -parser-generator. -.I yacc -parsers expect to call a routine named -.B yylex() -to find the next input token. The routine is supposed to -return the type of the next token as well as putting any associated -value in the global -.B yylval. -To use -.I flex -with -.I yacc, -one specifies the -.B \-d -option to -.I yacc -to instruct it to generate the file -.B y.tab.h -containing definitions of all the -.B %tokens -appearing in the -.I yacc -input. This file is then included in the -.I flex -scanner. For example, if one of the tokens is "TOK_NUMBER", -part of the scanner might look like: -.nf - - %{ - #include "y.tab.h" - %} - - %% - - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; - -.fi -.SH OPTIONS -.I flex -has the following options: -.TP -.B \-b -Generate backing-up information to -.I lex.backup. -This is a list of scanner states which require backing up -and the input characters on which they do so. By adding rules one -can remove backing-up states. If all backing-up states -are eliminated and -.B \-Cf -or -.B \-CF -is used, the generated scanner will run faster (see the -.B \-p -flag). Only users who wish to squeeze every last cycle out of their -scanners need worry about this option. (See the section on Performance -Considerations below.) -.TP -.B \-c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B \-c -specified table-compression options. This functionality is -now given by the -.B \-C -flag. To ease the the impact of this change, when -.I flex -encounters -.B \-c, -it currently issues a warning message and assumes that -.B \-C -was desired instead. In the future this "promotion" of -.B \-c -to -.B \-C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B \-d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), -the scanner will write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backs up, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; at this point, the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B \-f -specifies -.I fast scanner. -No table compression is done and stdio is bypassed. -The result is large but fast. This option is equivalent to -.B \-Cfr -(see below). -.TP -.B \-h -generates a "help" summary of -.I flex's -options to -.I stderr -and then exits. -.TP -.B \-i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B \-l -turns on maximum compatibility with the original AT&T -.I lex -implementation. Note that this does not mean -.I full -compatibility. Use of this option costs a considerable amount of -performance, and it cannot be used with the -.B \-+, -f, -F, -Cf, -or -.B -CF -options. For details on the compatibilities it provides, see the section -"Incompatibilities With Lex And POSIX" below. -.TP -.B \-n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B \-p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a serious loss of performance in the resulting -scanner. If you give the flag twice, you will also get comments regarding -features that lead to minor performance losses. -.IP -Note that the use of -.B REJECT -and variable trailing context (see the Bugs section in flex(1)) -entails a substantial performance penalty; use of -.I yymore(), -the -.B ^ -operator, -and the -.B \-I -flag entail minor performance penalties. -.TP -.B \-s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. This option is -useful for finding holes in a scanner's rule set. -.TP -.B \-t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B \-v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -Most of the statistics are meaningless to the casual -.I flex -user, but the first line identifies the version of -.I flex -(same as reported by -.B \-V), -and the next line the flags used when generating the scanner, including -those that are on by default. -.TP -.B \-w -suppresses warning messages. -.TP -.B \-B -instructs -.I flex -to generate a -.I batch -scanner, the opposite of -.I interactive -scanners generated by -.B \-I -(see below). In general, you use -.B \-B -when you are -.I certain -that your scanner will never be used interactively, and you want to -squeeze a -.I little -more performance out of it. If your goal is instead to squeeze out a -.I lot -more performance, you should be using the -.B \-Cf -or -.B \-CF -options (discussed below), which turn on -.B \-B -automatically anyway. -.TP -.B \-F -specifies that the -.ul -fast -scanner table representation should be used (and stdio -bypassed). This representation is -about as fast as the full table representation -.B (-f), -and for some sets of patterns will be considerably smaller (and for -others, larger). In general, if the pattern set contains both "keywords" -and a catch-all, "identifier" rule, such as in the set: -.nf - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - -.fi -then you're better off using the full table representation. If only -the "identifier" rule is present and you then use a hash table or some such -to detect the keywords, you're better off using -.B -F. -.IP -This option is equivalent to -.B \-CFr -(see below). It cannot be used with -.B \-+. -.TP -.B \-I -instructs -.I flex -to generate an -.I interactive -scanner. An interactive scanner is one that only looks ahead to decide -what token has been matched if it absolutely must. It turns out that -always looking one extra character ahead, even if the scanner has already -seen enough text to disambiguate the current token, is a bit faster than -only looking ahead when necessary. But scanners that always look ahead -give dreadful interactive performance; for example, when a user types -a newline, it is not recognized as a newline token until they enter -.I another -token, which often means typing in another whole line. -.IP -.I Flex -scanners default to -.I interactive -unless you use the -.B \-Cf -or -.B \-CF -table-compression options (see below). That's because if you're looking -for high-performance you should be using one of these options, so if you -didn't, -.I flex -assumes you'd rather trade off a bit of run-time performance for intuitive -interactive behavior. Note also that you -.I cannot -use -.B \-I -in conjunction with -.B \-Cf -or -.B \-CF. -Thus, this option is not really needed; it is on by default for all those -cases in which it is allowed. -.IP -You can force a scanner to -.I not -be interactive by using -.B \-B -(see above). -.TP -.B \-L -instructs -.I flex -not to generate -.B #line -directives. Without this option, -.I flex -peppers the generated scanner -with #line directives so error messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -(Unfortunately -.I flex -does not presently generate the necessary directives -to "retarget" the line numbers for those parts of -.B lex.yy.c -which it generated. So if there is an error in the generated code, -a meaningless line number is reported.) -.TP -.B \-T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stderr -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B \-V -prints the version number to -.I stderr -and exits. -.TP -.B \-7 -instructs -.I flex -to generate a 7-bit scanner, i.e., one which can only recognized 7-bit -characters in its input. The advantage of using -.B \-7 -is that the scanner's tables can be up to half the size of those generated -using the -.B \-8 -option (see below). The disadvantage is that such scanners often hang -or crash if their input contains an 8-bit character. -.IP -Note, however, that unless you generate your scanner using the -.B \-Cf -or -.B \-CF -table compression options, use of -.B \-7 -will save only a small amount of table space, and make your scanner -considerably less portable. -.I Flex's -default behavior is to generate an 8-bit scanner unless you use the -.B \-Cf -or -.B \-CF, -in which case -.I flex -defaults to generating 7-bit scanners unless your site was always -configured to generate 8-bit scanners (as will often be the case -with non-USA sites). You can tell whether flex generated a 7-bit -or an 8-bit scanner by inspecting the flag summary in the -.B \-v -output as described above. -.IP -Note that if you use -.B \-Cfe -or -.B \-CFe -(those table compression options, but also using equivalence classes as -discussed see below), flex still defaults to generating an 8-bit -scanner, since usually with these compression options full 8-bit tables -are not much more expensive than 7-bit tables. -.TP -.B \-8 -instructs -.I flex -to generate an 8-bit scanner, i.e., one which can recognize 8-bit -characters. This flag is only needed for scanners generated using -.B \-Cf -or -.B \-CF, -as otherwise flex defaults to generating an 8-bit scanner anyway. -.IP -See the discussion of -.B \-7 -above for flex's default behavior and the tradeoffs between 7-bit -and 8-bit scanners. -.TP -.B \-+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ Scanners below for -details. -.TP -.B \-C[aefFmr] -controls the degree of table compression and, more generally, trade-offs -between small scanners and fast scanners. -.IP -.B \-Ca -("align") instructs flex to trade off larger tables in the -generated scanner for faster performance because the elements of -the tables are better aligned for memory access and computation. On some -RISC architectures, fetching and manipulating longwords is more efficient -than with smaller-sized datums such as shortwords. This option can -double the size of the tables used by your scanner. -.IP -.B \-Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties (for example, if the only -appearance of digits in the -.I flex -input is in the character class -"[0-9]" then the digits '0', '1', ..., '9' will all be put -in the same equivalence class). Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B \-Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B \-CF -specifies that the alternate fast scanner representation (described -above under the -.B \-F -flag) -should be used. This option cannot be used with -.B \-+. -.IP -.B \-Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -.B \-Cr -causes the generated scanner to -.I bypass -use of the standard I/O library (stdio) for input. Instead of calling -.B fread() -or -.B getc(), -the scanner will use the -.B read() -system call, resulting in a performance gain which varies from system -to system, but in general is probably negligible unless you are also using -.B \-Cf -or -.B \-CF. -Using -.B \-Cr -can cause strange behavior if, for example, you read from -.I yyin -using stdio prior to calling the scanner (because the scanner will miss -whatever text your previous reads left in the stdio input buffer). -.IP -.B \-Cr -has no effect if you define -.B YY_INPUT -(see The Generated Scanner above). -.IP -A lone -.B \-C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B \-Cf -or -.B \-CF -and -.B \-Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed, and are cumulative. -.IP -The default setting is -.B \-Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - -.fi -Note that scanners with the smallest tables are usually generated and -compiled the quickest, so -during development you will usually want to use the default, maximal -compression. -.IP -.B \-Cfe -is often a good compromise between speed and size for production -scanners. -.TP -.B \-Pprefix -changes the default -.I "yy" -prefix used by -.I flex -for all globally-visible variable and function names to instead be -.I prefix. -For example, -.B \-Pfoo -changes the name of -.B yytext -to -.B footext. -It also changes the name of the default output file from -.B lex.yy.c -to -.B lex.foo.c. -Here are all of the names affected: -.nf - - yyFlexLexer - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yyout - yyrestart - yytext - yywrap - -.fi -Within your scanner itself, you can still refer to the global variables -and functions using either version of their name; but eternally, they -have the modified name. -.IP -This option lets you easily link together multiple -.I flex -programs into the same executable. Note, though, that using this -option also renames -.B yywrap(), -so you now -.I must -provide your own (appropriately-named) version of the routine for your -scanner, as linking with -.B \-lfl -no longer provides one for you by default. -.TP -.B \-Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH PERFORMANCE CONSIDERATIONS -The main design goal of -.I flex -is that it generate high-performance scanners. It has been optimized -for dealing well with large sets of rules. Aside from the effects on -scanner speed of the table compression -.B \-C -options outlined above, -there are a number of options/actions which degrade performance. These -are, from most expensive to least: -.nf - - REJECT - - pattern sets that require backing up - arbitrary trailing context - - yymore() - '^' beginning-of-line operator - -.fi -with the first three all being quite expensive and the last two -being quite cheap. Note also that -.B unput() -is implemented as a routine call that potentially does quite a bit of -work, while -.B yyless() -is a quite-cheap macro; so if just putting back some excess text you -scanned, use -.B yyless(). -.PP -.B REJECT -should be avoided at all costs when performance is important. -It is a particularly expensive option. -.PP -Getting rid of backing up is messy and often may be an enormous -amount of work for a complicated scanner. In principal, one begins -by using the -.B \-b -flag to generate a -.I lex.backup -file. For example, on the input -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - -.fi -the file looks like: -.nf - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \\001-n p-\\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \\001-` b-\\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \\001-q s-\\177 ] - - Compressed tables always back up. - -.fi -The first few lines tell us that there's a scanner state in -which it can make a transition on an 'o' but not on any other -character, and that in that state the currently scanned text does not match -any rule. The state occurs when trying to match the rules found -at lines 2 and 3 in the input file. -If the scanner is in that state and then reads -something other than an 'o', it will have to back up to find -a rule which is matched. With -a bit of headscratching one can see that this must be the -state it's in when it has seen "fo". When this has happened, -if anything other than another 'o' is seen, the scanner will -have to back up to simply match the 'f' (by the default rule). -.PP -The comment regarding State #8 indicates there's a problem -when "foob" has been scanned. Indeed, on any character other -than an 'a', the scanner will have to back up to accept "foo". -Similarly, the comment for State #9 concerns when "fooba" has -been scanned and an 'r' does not follow. -.PP -The final comment reminds us that there's no point going to -all the trouble of removing backing up from the rules unless -we're using -.B \-Cf -or -.B \-CF, -since there's no performance gain doing so with compressed scanners. -.PP -The way to remove the backing up is to add "error" rules: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - -.fi -.PP -Eliminating backing up among a list of keywords can also be -done using a "catch-all" rule: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - -.fi -This is usually the best solution when appropriate. -.PP -Backing up messages tend to cascade. -With a complicated set of rules it's not uncommon to get hundreds -of messages. If one can decipher them, though, it often -only takes a dozen or so rules to eliminate the backing up (though -it's easy to make a mistake and have an error rule accidentally match -a valid token. A possible future -.I flex -feature will be to automatically add rules to eliminate backing up). -.PP -.I Variable -trailing context (where both the leading and trailing parts do not have -a fixed length) entails almost the same performance loss as -.B REJECT -(i.e., substantial). So when possible a rule like: -.nf - - %% - mouse|rat/(cat|dog) run(); - -.fi -is better written: -.nf - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - -.fi -or as -.nf - - %% - mouse|rat/cat run(); - mouse|rat/dog run(); - -.fi -Note that here the special '|' action does -.I not -provide any savings, and can even make things worse (see -.PP -A final note regarding performance: as mentioned above in the section -How the Input is Matched, dynamically resizing -.B yytext -to accomodate huge tokens is a slow process because it presently requires that -the (huge) token be rescanned from the beginning. Thus if performance is -vital, you should attempt to match "large" quantities of text but not -"huge" quantities, where the cutoff between the two is at about 8K -characters/token. -.PP -Another area where the user can increase a scanner's performance -(and one that's easier to implement) arises from the fact that -the longer the tokens matched, the faster the scanner will run. -This is because with long tokens the processing of most input -characters takes place in the (short) inner scanning loop, and -does not often have to go through the additional work of setting up -the scanning environment (e.g., -.B yytext) -for the action. Recall the scanner for C comments: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - "*"+[^*/\\n]* - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This could be sped up by writing it as: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - [^*\\n]*\\n ++line_num; - "*"+[^*/\\n]* - "*"+[^*/\\n]*\\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -Now instead of each newline requiring the processing of another -action, recognizing the newlines is "distributed" over the other rules -to keep the matched text as long as possible. Note that -.I adding -rules does -.I not -slow down the scanner! The speed of the scanner is independent -of the number of rules or (modulo the considerations given at the -beginning of this section) how complicated the rules are with -regard to operators such as '*' and '|'. -.PP -A final example in speeding up a scanner: suppose you want to scan -through a file containing identifiers and keywords, one per line -and with no other extraneous characters, and recognize all the -keywords. A natural first approach is: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\\n /* it's not a keyword */ - -.fi -To eliminate the back-tracking, introduce a catch-all rule: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Now, if it's guaranteed that there's exactly one word per line, -then we can reduce the total number of matches by a half by -merging in the recognition of newlines with that of the other -tokens: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - .|\\n /* it's not a keyword */ - -.fi -One has to be careful here, as we have now reintroduced backing up -into the scanner. In particular, while -.I we -know that there will never be any characters in the input stream -other than letters or newlines, -.I flex -can't figure this out, and it will plan for possibly needing to back up -when it has scanned a token like "auto" and then the next character -is something other than a newline or a letter. Previously it would -then just match the "auto" rule and be done, but now it has no "auto" -rule, only a "auto\\n" rule. To eliminate the possibility of backing up, -we could either duplicate all rules but without final newlines, or, -since we never expect to encounter such an input and therefore don't -how it's classified, we can introduce one more catch-all rule, this -one which doesn't include a newline: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Compiled with -.B \-Cf, -this is about as fast as one can get a -.I flex -scanner to go for this particular problem. -.PP -A final note: -.I flex -is slow when matching NUL's, particularly when a token contains -multiple NUL's. -It's best to write rules which match -.I short -amounts of text if it's anticipated that the text will often include NUL's. -.SH GENERATING C++ SCANNERS -.I flex -provides two different ways to generate scanners for use with C++. The -first way is to simply compile a scanner generated by -.I flex -using a C++ compiler instead of a C compiler. You should not encounter -any compilations errors (please report any you find to the email address -given in the Author section below). You can then use C++ code in your -rule actions instead of C code. Note that the default input source for -your scanner remains -.I yyin, -and default echoing is still done to -.I yyout. -Both of these remain -.I FILE * -variables and not C++ -.I streams. -.PP -You can also use -.I flex -to generate a C++ scanner class, using the -.B \-+ -option, which is automatically specified if the name of the flex -executable ends in a '+', such as -.I flex++. -When using this option, flex defaults to generating the scanner to the file -.B lex.yy.cc -instead of -.B lex.yy.c. -The generated scanner includes the header file -.I FlexLexer.h, -which defines the interface to two C++ classes. -.PP -The first class, -.B FlexLexer, -provides an abstract base class defining the general scanner class -interface. It provides the following member functions: -.TP -.B const char* YYText() -returns the text of the most recently matched token, the equivalent of -.B yytext. -.TP -.B int YYLeng() -returns the length of the most recently matched token, the equivalent of -.B yyleng. -.PP -Also provided are member functions equivalent to -.B yy_switch_to_buffer(), -.B yy_create_buffer() -(though the first argument is an -.B istream* -object pointer and not a -.B FILE*), -.B yy_delete_buffer(), -and -.B yyrestart() -(again, the first argument is a -.B istream* -object pointer). -.PP -The second class defined in -.I FlexLexer.h -is -.B yyFlexLexer, -which is derived from -.B FlexLexer. -It defines the following additional member functions: -.TP -.B -yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) -constructs a -.B yyFlexLexer -object using the given streams for input and output. If not specified, -the streams default to -.B cin -and -.B cout, -respectively. -.TP -.B virtual int yylex() -performs the same role is -.B yylex() -does for ordinary flex scanners: it scans the input stream, consuming -tokens, until a rule's action returns a value. -.PP -In addition, -.B yyFlexLexer -defines the following protected virtual functions which you can redefine -in derived classes to tailor the scanner: -.TP -.B -virtual int LexerInput( char* buf, int max_size ) -reads up to -.B max_size -characters into -.B buf -and returns the number of characters read. To indicate end-of-input, -return 0 characters. Note that "interactive" scanners (see the -.B \-B -and -.B \-I -flags) define the macro -.B YY_INTERACTIVE. -If you redefine -.B LexerInput() -and need to take different actions depending on whether or not -the scanner might be scanning an interactive input source, you can -test for the presence of this name via -.B #ifdef. -.TP -.B -virtual void LexerOutput( const char* buf, int size ) -writes out -.B size -characters from the buffer -.B buf, -which, while NUL-terminated, may also contain "internal" NUL's if -the scanner's rules can match text with NUL's in them. -.TP -.B -virtual void LexerError( const char* msg ) -reports a fatal error message. The default version of this function -writes the message to the stream -.B cerr -and exits. -.PP -Note that a -.B yyFlexLexer -object contains its -.I entire -scanning state. Thus you can use such objects to create reentrant -scanners. You can instantiate multiple instances of the same -.B yyFlexLexer -class, and you can also combine multiple C++ scanner classes together -in the same program using the -.B \-P -option discussed above. -.PP -Finally, note that the -.B %array -feature is not available to C++ scanner classes; you must use -.B %pointer -(the default). -.PP -Here is an example of a simple C++ scanner: -.nf - - // An example of using the flex C++ scanner class. - - %{ - int mylineno = 0; - %} - - string \\"[^\\n"]+\\" - - ws [ \\t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\\$)({alpha}|{dig}|[_.\\-/$])* - num1 [-+]?{dig}+\\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\\n'; - - \\n mylineno++; - - {name} cout << "name " << YYText() << '\\n'; - - {string} cout << "string " << YYText() << '\\n'; - - %% - - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } -.fi -IMPORTANT: the present form of the scanning class is -.I experimental -and may change considerably between major releases. -.SH INCOMPATIBILITIES WITH LEX AND POSIX -.I flex -is a rewrite of the AT&T Unix -.I lex -tool (the two implementations do not share any code, though), -with some extensions and incompatibilities, both of which -are of concern to those who wish to write scanners acceptable -to either implementation. The POSIX -.I lex -specification is closer to -.I flex's -behavior than that of the original -.I lex -implementation, but there also remain some incompatibilities between -.I flex -and POSIX. The intent is that ultimately -.I flex -will be fully POSIX-conformant. In this section we discuss all of -the known areas of incompatibility. -.PP -.I flex's -.B \-l -option turns on maximum compatibility with the original AT&T -.I lex -implementation, at the cost of a major loss in the generated scanner's -performance. We note below which incompatibilities can be overcome -using the -.B \-l -option. -.PP -.I flex -is fully compatible with -.I lex -with the following exceptions: -.IP - -The undocumented -.I lex -scanner internal variable -.B yylineno -is not supported unless -.B \-l -is used. -.IP -yylineno is not part of the POSIX specification. -.IP - -The -.B input() -routine is not redefinable, though it may be called to read characters -following whatever has been matched by a rule. If -.B input() -encounters an end-of-file the normal -.B yywrap() -processing is done. A ``real'' end-of-file is returned by -.B input() -as -.I EOF. -.IP -Input is instead controlled by defining the -.B YY_INPUT -macro. -.IP -The -.I flex -restriction that -.B input() -cannot be redefined is in accordance with the POSIX specification, -which simply does not specify any way of controlling the -scanner's input other than by making an initial assignment to -.I yyin. -.IP - -.I flex -scanners are not as reentrant as -.I lex -scanners. In particular, if you have an interactive scanner and -an interrupt handler which long-jumps out of the scanner, and -the scanner is subsequently called again, you may get the following -message: -.nf - - fatal flex scanner internal error--end of buffer missed - -.fi -To reenter the scanner, first use -.nf - - yyrestart( yyin ); - -.fi -Note that this call will throw away any buffered input; usually this -isn't a problem with an interactive scanner. -.IP -Also note that flex C++ scanner classes -.I are -reentrant, so if using C++ is an option for you, you should use -them instead. See "Generating C++ Scanners" above for details. -.IP - -.B output() -is not supported. -Output from the -.B ECHO -macro is done to the file-pointer -.I yyout -(default -.I stdout). -.IP -.B output() -is not part of the POSIX specification. -.IP - -.I lex -does not support exclusive start conditions (%x), though they -are in the POSIX specification. -.IP - -When definitions are expanded, -.I flex -encloses them in parentheses. -With lex, the following: -.nf - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf( "Found it\\n" ); - %% - -.fi -will not match the string "foo" because when the macro -is expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?" -and the precedence is such that the '?' is associated with -"[A-Z0-9]*". With -.I flex, -the rule will be expanded to -"foo([A-Z][A-Z0-9]*)?" and so the string "foo" will match. -.IP -Note that if the definition begins with -.B ^ -or ends with -.B $ -then it is -.I not -expanded with parentheses, to allow these operators to appear in -definitions without losing their special meanings. But the -.B , /, -and -.B <> -operators cannot be used in a -.I flex -definition. -.IP -Using -.B \-l -results in the -.I lex -behavior of no parentheses around the definition. -.IP -The POSIX specification is that the definition be enclosed in parentheses. -.IP - -The -.I lex -.B %r -(generate a Ratfor scanner) option is not supported. It is not part -of the POSIX specification. -.IP - -After a call to -.B unput(), -.I yytext -and -.I yyleng -are undefined until the next token is matched, unless the scanner -was built using -.B %array. -This is not the case with -.I lex -or the POSIX specification. The -.B \-l -option does away with this incompatibility. -.IP - -The precedence of the -.B {} -(numeric range) operator is different. -.I lex -interprets "abc{1,3}" as "match one, two, or -three occurrences of 'abc'", whereas -.I flex -interprets it as "match 'ab' -followed by one, two, or three occurrences of 'c'". The latter is -in agreement with the POSIX specification. -.IP - -The precedence of the -.B ^ -operator is different. -.I lex -interprets "^foo|bar" as "match either 'foo' at the beginning of a line, -or 'bar' anywhere", whereas -.I flex -interprets it as "match either 'foo' or 'bar' if they come at the beginning -of a line". The latter is in agreement with the POSIX specification. -.IP - -.I yyin -is -.I initialized -by -.I lex -to be -.I stdin; -.I flex, -on the other hand, -initializes -.I yyin -to NULL -and then -.I assigns -it to -.I stdin -the first time the scanner is called, providing -.I yyin -has not already been assigned to a non-NULL value. The difference is -subtle, but the net effect is that with -.I flex -scanners, -.I yyin -does not have a valid value until the scanner has been called. -.IP -The -.B \-l -option does away with this incompatibility. -.IP - -The special table-size declarations such as -.B %a -supported by -.I lex -are not required by -.I flex -scanners; -.I flex -ignores them. -.IP - -The name -.bd -FLEX_SCANNER -is #define'd so scanners may be written for use with either -.I flex -or -.I lex. -.PP -The following -.I flex -features are not included in -.I lex -or the POSIX specification: -.nf - - yyterminate() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - #line directives - %{}'s around actions - multiple actions on a line - -.fi -plus almost all of the flex flags. -The last feature in the list refers to the fact that with -.I flex -you can put multiple actions on the same line, separated with -semi-colons, while with -.I lex, -the following -.nf - - foo handle_foo(); ++num_foos_seen; - -.fi -is (rather surprisingly) truncated to -.nf - - foo handle_foo(); - -.fi -.I flex -does not truncate the action. Actions that are not enclosed in -braces are simply terminated at the end of the line. -.SH DIAGNOSTICS -.PP -.I warning, rule cannot be matched -indicates that the given rule -cannot be matched because it follows other rules that will -always match the same text as it. For -example, in the following "foo" cannot be matched because it comes after -an identifier "catch-all" rule: -.nf - - [a-z]+ got_identifier(); - foo got_foo(); - -.fi -Using -.B REJECT -in a scanner suppresses this warning. -.PP -.I warning, -.B \-s -.I -option given but default rule can be matched -means that it is possible (perhaps only in a particular start condition) -that the default rule (match any single character) is the only one -that will match a particular input. Since -.B \-s -was given, presumably this is not intended. -.PP -.I reject_used_but_not_detected undefined -or -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.PP -.I flex scanner jammed - -a scanner compiled with -.B \-s -has encountered an input string which wasn't matched by -any of its rules. This error can also occur due to internal problems. -.PP -.I token too large, exceeds YYLMAX - -your scanner uses -.B %array -and one of its rules matched a string longer than the -.B YYLMAX -constant (8K bytes by default). You can increase the value by -#define'ing -.B YYLMAX -in the definitions section of your -.I flex -input. -.PP -.I scanner requires \-8 flag to -.I use the character 'x' - -Your scanner specification includes recognizing the 8-bit character -.I 'x' -and you did not specify the \-8 flag, and your scanner defaulted to 7-bit -because you used the -.B \-Cf -or -.B \-CF -table compression options. See the discussion of the -.B \-7 -flag for details. -.PP -.I flex scanner push-back overflow - -you used -.B unput() -to push back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in -.B yytext. -Ideally the scanner should dynamically resize the buffer in this case, but at -present it does not. -.PP -.I -input buffer overflow, can't enlarge buffer because scanner uses REJECT - -the scanner was working on matching an extremely large token and needed -to expand the input buffer. This doesn't work with scanners that use -.B -REJECT. -.PP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -or, as noted above, switch to using the C++ scanner class. -.PP -.I too many start conditions in <> construct! - -you listed more start conditions in a <> construct than exist (so -you must have listed at least one of them twice). -.SH FILES -See flex(1). -.SH DEFICIENCIES / BUGS -Again, see flex(1). -.SH "SEE ALSO" -.PP -flex(1), lex(1), yacc(1), sed(1), awk(1). -.PP -M. E. Lesk and E. Schmidt, -.I LEX \- Lexical Analyzer Generator -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. The fast table -representation is a partial implementation of a design done by Van -Jacobson. The implementation was done by Kevin Gong and Vern Paxson. -.PP -Thanks to the many -.I flex -beta-testers, feedbackers, and contributors, especially Francois Pinard, -Casey Leedom, -Nelson H.F. Beebe, benson@odi.com, Peter A. Bigot, Keith Bostic, Frederic -Brehm, Nick Christopher, Jason Coughlin, Bill Cox, Dave Curtis, Scott David -Daniels, Chris G. Demetriou, Mike Donahue, Chuck Doucette, Tom Epperly, Leo -Eskin, Chris Faylor, Jon Forrest, Kaveh R. Ghazi, -Eric Goldman, Ulrich Grepel, Jan Hajic, -Jarkko Hietaniemi, Eric Hughes, John Interrante, -Ceriel Jacobs, Jeffrey R. Jones, Henry -Juengst, Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Marq Kole, Ronald -Lamprecht, Greg Lee, Craig Leres, John Levine, Steve Liddle, -Mohamed el Lozy, Brian Madsen, Chris -Metcalf, Luke Mewburn, Jim Meyering, G.T. Nicol, Landon Noll, Marc Nozell, -Richard Ohnemus, Sven Panne, Roland Pesch, Walter Pelissero, Gaumond -Pierre, Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Frederic Raimbault, -Rick Richardson, -Kevin Rodgers, Jim Roskind, -Doug Schmidt, Philippe Schnoebelen, Andreas Schwab, -Alex Siegel, Mike Stump, Paul Stuart, Dave Tallman, Chris Thewalt, -Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, Ken -Yap, Nathan Zelle, David Zuhn, and those whose names have slipped my marginal -mail-archiving skills but whose contributions are appreciated all the -same. -.PP -Thanks to Keith Bostic, Jon Forrest, Noah Friedman, -John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T. -Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various -distribution headaches. -.PP -Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to -Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom -Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to -Eric Hughes for support of multiple buffers. -.PP -This work was primarily done when I was with the Real Time Systems Group -at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there -for the support I received. -.PP -Send comments to: -.nf - - Vern Paxson - Systems Engineering - Bldg. 46A, Room 1123 - Lawrence Berkeley Laboratory - University of California - Berkeley, CA 94720 - - vern@ee.lbl.gov - -.fi diff --git a/usr.bin/m4/serv.c b/usr.bin/m4/serv.c deleted file mode 100644 index 54a2e59dce40..000000000000 --- a/usr.bin/m4/serv.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (c) 1989 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * This code is derived from software contributed to Berkeley by - * Ozan Yigit. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)serv.c 5.4 (Berkeley) 1/21/94"; -#endif /* not lint */ - -/* - * serv.c - * Facility: m4 macro processor - * by: oz - */ - -#include -#include -#include -#include "mdef.h" -#include "extr.h" -#include "pathnames.h" - -extern ndptr lookup(); -extern ndptr addent(); - -char *dumpfmt = "`%s'\t`%s'\n"; /* format string for dumpdef */ - -/* - * expand - user-defined macro expansion - * - */ -expand(argv, argc) -register char *argv[]; -register int argc; -{ - register char *t; - register char *p; - register int n; - register int argno; - - t = argv[0]; /* defn string as a whole */ - p = t; - while (*p) - p++; - p--; /* last character of defn */ - while (p > t) { - if (*(p-1) != ARGFLAG) - putback(*p); - else { - switch (*p) { - - case '#': - pbnum(argc-2); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if ((argno = *p - '0') < argc-1) - pbstr(argv[argno+1]); - break; - case '*': - for (n = argc - 1; n > 2; n--) { - pbstr(argv[n]); - putback(','); - } - pbstr(argv[2]); - break; - default : - putback(*p); - break; - } - p--; - } - p--; - } - if (p == t) /* do last character */ - putback(*p); -} - -/* - * dodefine - install definition in the table - * - */ -dodefine(name, defn) -register char *name; -register char *defn; -{ - register ndptr p; - - if (!*name) - error("m4: null definition."); - if (strcmp(name, defn) == 0) - error("m4: recursive definition."); - if ((p = lookup(name)) == nil) - p = addent(name); - else if (p->defn != null) - free(p->defn); - if (!*defn) - p->defn = null; - else - p->defn = strdup(defn); - p->type = MACRTYPE; -} - -/* - * dodefn - push back a quoted definition of - * the given name. - */ - -dodefn(name) -char *name; -{ - register ndptr p; - - if ((p = lookup(name)) != nil && p->defn != null) { - putback(rquote); - pbstr(p->defn); - putback(lquote); - } -} - -/* - * dopushdef - install a definition in the hash table - * without removing a previous definition. Since - * each new entry is entered in *front* of the - * hash bucket, it hides a previous definition from - * lookup. - */ -dopushdef(name, defn) -register char *name; -register char *defn; -{ - register ndptr p; - - if (!*name) - error("m4: null definition"); - if (strcmp(name, defn) == 0) - error("m4: recursive definition."); - p = addent(name); - if (!*defn) - p->defn = null; - else - p->defn = strdup(defn); - p->type = MACRTYPE; -} - -/* - * dodumpdef - dump the specified definitions in the hash - * table to stderr. If nothing is specified, the entire - * hash table is dumped. - * - */ -dodump(argv, argc) -register char *argv[]; -register int argc; -{ - register int n; - ndptr p; - - if (argc > 2) { - for (n = 2; n < argc; n++) - if ((p = lookup(argv[n])) != nil) - fprintf(stderr, dumpfmt, p->name, - p->defn); - } - else { - for (n = 0; n < HASHSIZE; n++) - for (p = hashtab[n]; p != nil; p = p->nxtptr) - fprintf(stderr, dumpfmt, p->name, - p->defn); - } -} - -/* - * doifelse - select one of two alternatives - loop. - * - */ -doifelse(argv,argc) -register char *argv[]; -register int argc; -{ - cycle { - if (strcmp(argv[2], argv[3]) == 0) - pbstr(argv[4]); - else if (argc == 6) - pbstr(argv[5]); - else if (argc > 6) { - argv += 3; - argc -= 3; - continue; - } - break; - } -} - -/* - * doinclude - include a given file. - * - */ -doincl(ifile) -char *ifile; -{ - if (ilevel+1 == MAXINP) - error("m4: too many include files."); - if ((infile[ilevel+1] = fopen(ifile, "r")) != NULL) { - ilevel++; - return (1); - } - else - return (0); -} - -#ifdef EXTENDED -/* - * dopaste - include a given file without any - * macro processing. - */ -dopaste(pfile) -char *pfile; -{ - FILE *pf; - register int c; - - if ((pf = fopen(pfile, "r")) != NULL) { - while((c = getc(pf)) != EOF) - putc(c, active); - (void) fclose(pf); - return(1); - } - else - return(0); -} -#endif - -/* - * dochq - change quote characters - * - */ -dochq(argv, argc) -register char *argv[]; -register int argc; -{ - if (argc > 2) { - if (*argv[2]) - lquote = *argv[2]; - if (argc > 3) { - if (*argv[3]) - rquote = *argv[3]; - } - else - rquote = lquote; - } - else { - lquote = LQUOTE; - rquote = RQUOTE; - } -} - -/* - * dochc - change comment characters - * - */ -dochc(argv, argc) -register char *argv[]; -register int argc; -{ - if (argc > 2) { - if (*argv[2]) - scommt = *argv[2]; - if (argc > 3) { - if (*argv[3]) - ecommt = *argv[3]; - } - else - ecommt = ECOMMT; - } - else { - scommt = SCOMMT; - ecommt = ECOMMT; - } -} - -/* - * dodivert - divert the output to a temporary file - * - */ -dodiv(n) -register int n; -{ - if (n < 0 || n >= MAXOUT) - n = 0; /* bitbucket */ - if (outfile[n] == NULL) { - m4temp[UNIQUE] = n + '0'; - if ((outfile[n] = fopen(m4temp, "w")) == NULL) - error("m4: cannot divert."); - } - oindex = n; - active = outfile[n]; -} - -/* - * doundivert - undivert a specified output, or all - * other outputs, in numerical order. - */ -doundiv(argv, argc) -register char *argv[]; -register int argc; -{ - register int ind; - register int n; - - if (argc > 2) { - for (ind = 2; ind < argc; ind++) { - n = atoi(argv[ind]); - if (n > 0 && n < MAXOUT && outfile[n] != NULL) - getdiv(n); - - } - } - else - for (n = 1; n < MAXOUT; n++) - if (outfile[n] != NULL) - getdiv(n); -} - -/* - * dosub - select substring - * - */ -dosub (argv, argc) -register char *argv[]; -register int argc; -{ - register char *ap, *fc, *k; - register int nc; - - if (argc < 5) - nc = MAXTOK; - else -#ifdef EXPR - nc = expr(argv[4]); -#else - nc = atoi(argv[4]); -#endif - ap = argv[2]; /* target string */ -#ifdef EXPR - fc = ap + expr(argv[3]); /* first char */ -#else - fc = ap + atoi(argv[3]); /* first char */ -#endif - if (fc >= ap && fc < ap+strlen(ap)) - for (k = fc+min(nc,strlen(fc))-1; k >= fc; k--) - putback(*k); -} - -/* - * map: - * map every character of s1 that is specified in from - * into s3 and replace in s. (source s1 remains untouched) - * - * This is a standard implementation of map(s,from,to) function of ICON - * language. Within mapvec, we replace every character of "from" with - * the corresponding character in "to". If "to" is shorter than "from", - * than the corresponding entries are null, which means that those - * characters dissapear altogether. Furthermore, imagine - * map(dest, "sourcestring", "srtin", "rn..*") type call. In this case, - * `s' maps to `r', `r' maps to `n' and `n' maps to `*'. Thus, `s' - * ultimately maps to `*'. In order to achieve this effect in an efficient - * manner (i.e. without multiple passes over the destination string), we - * loop over mapvec, starting with the initial source character. if the - * character value (dch) in this location is different than the source - * character (sch), sch becomes dch, once again to index into mapvec, until - * the character value stabilizes (i.e. sch = dch, in other words - * mapvec[n] == n). Even if the entry in the mapvec is null for an ordinary - * character, it will stabilize, since mapvec[0] == 0 at all times. At the - * end, we restore mapvec* back to normal where mapvec[n] == n for - * 0 <= n <= 127. This strategy, along with the restoration of mapvec, is - * about 5 times faster than any algorithm that makes multiple passes over - * destination string. - * - */ - -map(dest,src,from,to) -register char *dest; -register char *src; -register char *from; -register char *to; -{ - register char *tmp; - register char sch, dch; - static char mapvec[128] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127 - }; - - if (*src) { - tmp = from; - /* - * create a mapping between "from" and "to" - */ - while (*from) - mapvec[*from++] = (*to) ? *to++ : (char) 0; - - while (*src) { - sch = *src++; - dch = mapvec[sch]; - while (dch != sch) { - sch = dch; - dch = mapvec[sch]; - } - if (*dest = dch) - dest++; - } - /* - * restore all the changed characters - */ - while (*tmp) { - mapvec[*tmp] = *tmp; - tmp++; - } - } - *dest = (char) 0; -} diff --git a/usr.bin/man/Makefile b/usr.bin/man/Makefile deleted file mode 100644 index 728d038156f6..000000000000 --- a/usr.bin/man/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= man -SRCS= config.c man.c -MAN1= man.0 -MAN5= man.conf.0 - -.include diff --git a/usr.bin/man/config.c b/usr.bin/man/config.c deleted file mode 100644 index 1d875b55b79f..000000000000 --- a/usr.bin/man/config.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)config.c 8.7 (Berkeley) 1/3/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "pathnames.h" - -struct _head head; - -/* - * config -- - * - * Read the configuration file and build a doubly linked - * list that looks like: - * - * tag1 <-> record <-> record <-> record - * | - * tag2 <-> record <-> record <-> record - */ -void -config(fname) - char *fname; -{ - TAG *tp; - ENTRY *ep; - FILE *cfp; - size_t len; - int lcnt; - char *p, *t; - - if (fname == NULL) - fname = _PATH_MANCONF; - if ((cfp = fopen(fname, "r")) == NULL) - err(1, "%s", fname); - TAILQ_INIT(&head); - for (lcnt = 1; (p = fgetln(cfp, &len)) != NULL; ++lcnt) { - if (len == 1) /* Skip empty lines. */ - continue; - if (p[len - 1] != '\n') { /* Skip corrupted lines. */ - warnx("%s: line %d corrupted", fname, lcnt); - continue; - } - p[len - 1] = '\0'; /* Terminate the line. */ - - /* Skip leading space. */ - for (; *p != '\0' && isspace(*p); ++p); - /* Skip empty/comment lines. */ - if (*p == '\0' || *p == '#') - continue; - /* Find first token. */ - for (t = p; *t && !isspace(*t); ++t); - if (*t == '\0') /* Need more than one token.*/ - continue; - *t = '\0'; - - for (tp = head.tqh_first; /* Find any matching tag. */ - tp != NULL && strcmp(p, tp->s); tp = tp->q.tqe_next); - - if (tp == NULL) /* Create a new tag. */ - tp = addlist(p); - - /* - * Attach new records. The keyword _build takes the rest of - * the line as a single entity, everything else is white - * space separated. The reason we're not just using strtok(3) - * for all of the parsing is so we don't get caught if a line - * has only a single token on it. - */ - if (!strcmp(p, "_build")) { - while (*++t && isspace(*t)); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(t)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&tp->list, ep, q); - } else for (++t; (p = strtok(t, " \t\n")) != NULL; t = NULL) { - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(p)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&tp->list, ep, q); - } - } -} - -/* - * addlist -- - * Add a tag to the list. - */ -TAG * -addlist(name) - char *name; -{ - TAG *tp; - - if ((tp = calloc(1, sizeof(TAG))) == NULL || - (tp->s = strdup(name)) == NULL) - err(1, NULL); - TAILQ_INIT(&tp->list); - TAILQ_INSERT_TAIL(&head, tp, q); - return (tp); -} - -/* - * getlist -- - * Return the linked list of entries for a tag if it exists. - */ -TAG * -getlist(name) - char *name; -{ - TAG *tp; - - for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next) - if (!strcmp(name, tp->s)) - return (tp); - return (NULL); -} - -void -debug(l) - char *l; -{ - TAG *tp; - ENTRY *ep; - - (void)printf("%s ===============\n", l); - for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next) { - printf("%s\n", tp->s); - for (ep = tp->list.tqh_first; ep != NULL; ep = ep->q.tqe_next) - printf("\t%s\n", ep->s); - } -} diff --git a/usr.bin/man/config.h b/usr.bin/man/config.h deleted file mode 100644 index 52ea969f9e02..000000000000 --- a/usr.bin/man/config.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)config.h 8.4 (Berkeley) 12/18/93 - */ - -typedef struct _tag { - TAILQ_ENTRY(_tag) q; /* Queue of tags. */ - - TAILQ_HEAD(tqh, _entry) list; /* Queue of entries. */ - char *s; /* Associated string. */ - size_t len; /* Length of 's'. */ -} TAG; -typedef struct _entry { - TAILQ_ENTRY(_entry) q; /* Queue of entries. */ - - char *s; /* Associated string. */ - size_t len; /* Length of 's'. */ -} ENTRY; - -TAILQ_HEAD(_head, _tag); -extern struct _head head; - -TAG *addlist __P((char *)); -void config __P((char *)); -void debug __P((char *)); -TAG *getlist __P((char *)); diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 deleted file mode 100644 index 081e204aee28..000000000000 --- a/usr.bin/man/man.1 +++ /dev/null @@ -1,188 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)man.1 8.2 (Berkeley) 1/2/94 -.\" -.Dd January 2, 1994 -.Dt MAN 1 -.Os BSD 4 -.Sh NAME -.Nm man -.Nd display the on-line manual pages -.Sh SYNOPSIS -.Nm man -.Op Fl achw -.Op Fl C Ar file -.Op Fl M Ar path -.Op Fl m Ar path -.Op Ar section -.Ar name Ar ... -.Sh DESCRIPTION -The -.Nm man -utility -displays the -.Bx -manual pages entitled -.Ar name . -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl a -Display all of the manual pages for a specified -.Ar section -and -.Ar name -combination. -(Normally, only the first manual page found is displayed.) -.It Fl C -Use the specified -.Ar file -instead of the default configuration file. -This permits users to configure their own manual environment. -See -.Xr man.conf 5 -for a description of the contents of this file. -.It Fl c -Copy the manual page to the standard output instead of using -.Xr more 1 -to paginate it. -This is done by default if the standard output is not a terminal device. -.It Fl h -Display only the -.Dq Tn SYNOPSIS -lines of the requested manual pages. -.It Fl M -Override the list of standard directories which -.Nm man -searches for manual pages. -The supplied -.Ar path -must be a colon (``:'') separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -The subdirectories to be searched, and their search order, -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Fl m -Augment the list of standard directories which -.Nm man -searches for manual pages. -The supplied -.Ar path -must be a colon (``:'') separated list of directories. -These directories will be searched before the standard directories or -the directories specified using the -.Fl M -option or the -.Ev MANPATH -environment variable. -The subdirectories to be searched, and their search order, -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Fl w -List the pathnames of the manual pages which -.Nm man -would display for the specified -.Ar section -and -.Ar name -combination. -.El -.Pp -The optional -.Ar section -argument restricts the directories that -.Nm man -will search. -The -.Nm man -configuration file (see -.Xr man.conf 5 ) -specifies the possible -.Ar section -values that are currently available. -If only a single argument is specified or if the first argument is -not a valid section, -.Nm man -assumes that the argument is the name of a manual page to be displayed. -.Sh ENVIRONMENT -.Bl -tag -width MANPATHX -.It Ev MACHINE -As some manual pages are intended only for specific architectures, -.Nm man -searches any subdirectories, -with the same name as the current architecture, -in every directory which it searches. -Machine specific areas are checked before general areas. -The current machine type may be overridden by setting the environment -variable -.Ev MACHINE -to the name of a specific architecture. -.It Ev MANPATH -The standard search path used by -.Nm man -may be overridden by specifying a path in the -.Ev MANPATH -environment -variable. -The format of the path is a colon (``:'') separated list of directories. -The subdirectories to be searched as well as their search order -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Ev PAGER -Any value of the environment variable -.Ev PAGER -will be used instead of the standard pagination program, -.Xr more 1 . -.El -.Sh FILES -.Bl -tag -width /etc/man.conf -compact -.It Pa /etc/man.conf -default man configuration file. -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr whatis 1 , -.Xr whereis 1 , -.Xr man.conf 5 -.Sh BUGS -The on-line manual pages are, by necessity, forgiving toward stupid -display devices, causing a few manual pages to not as nicely formatted -as their typeset counterparts. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c deleted file mode 100644 index a320e312890d..000000000000 --- a/usr.bin/man/man.c +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)man.c 8.16 (Berkeley) 4/16/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "pathnames.h" - -int f_all, f_where; - -static void build_page __P((char *, char **)); -static void cat __P((char *)); -static char *check_pager __P((char *)); -static int cleanup __P((void)); -static void how __P((char *)); -static void jump __P((char **, char *, char *)); -static int manual __P((char *, TAG *, glob_t *)); -static void onsig __P((int)); -static void usage __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - extern int optind; - TAG *defp, *defnewp, *section, *sectnewp, *subp; - ENTRY *e_defp, *e_sectp, *e_subp, *ep; - glob_t pg; - size_t len; - int ch, f_cat, f_how, found; - char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *slashp; - char *conffile, buf[MAXPATHLEN * 2]; - - f_cat = f_how = 0; - conffile = p_add = p_path = NULL; - while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:w")) != EOF) - switch (ch) { - case 'a': - f_all = 1; - break; - case 'C': - conffile = optarg; - break; - case 'c': - case '-': /* Deprecated. */ - f_cat = 1; - break; - case 'h': - f_how = 1; - break; - case 'm': - p_add = optarg; - break; - case 'M': - case 'P': /* Backward compatibility. */ - p_path = optarg; - break; - /* - * The -f and -k options are backward compatible, - * undocumented ways of calling whatis(1) and apropos(1). - */ - case 'f': - jump(argv, "-f", "whatis"); - /* NOTREACHED */ - case 'k': - jump(argv, "-k", "apropos"); - /* NOTREACHED */ - case 'w': - f_all = f_where = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (!*argv) - usage(); - - if (!f_cat && !f_how && !f_where) - if (!isatty(1)) - f_cat = 1; - else if ((pager = getenv("PAGER")) != NULL) - pager = check_pager(pager); - else - pager = _PATH_PAGER; - - /* Read the configuration file. */ - config(conffile); - - /* Get the machine type. */ - if ((machine = getenv("MACHINE")) == NULL) - machine = MACHINE; - - /* If there's no _default list, create an empty one. */ - if ((defp = getlist("_default")) == NULL) - defp = addlist("_default"); - - /* - * 1: If the user specified a MANPATH variable, or set the -M - * option, we replace the _default list with the user's list, - * appending the entries in the _subdir list and the machine. - */ - if (p_path == NULL) - p_path = getenv("MANPATH"); - if (p_path != NULL) { - while ((e_defp = defp->list.tqh_first) != NULL) { - free(e_defp->s); - TAILQ_REMOVE(&defp->list, e_defp, q); - } - for (p = strtok(p_path, ":"); - p != NULL; p = strtok(NULL, ":")) { - slashp = p[strlen(p) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&defp->list, ep, q); - } - } - } - - /* - * 2: If the user did not specify MANPATH, -M or a section, rewrite - * the _default list to include the _subdir list and the machine. - */ - if (argv[1] == NULL) - section = NULL; - else if ((section = getlist(*argv)) != NULL) - ++argv; - if (p_path == NULL && section == NULL) { - defnewp = addlist("_default_new"); - e_defp = - defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first; - for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) { - slashp = - e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - e_defp->s, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&defnewp->list, ep, q); - } - } - defp = getlist("_default"); - while ((e_defp = defp->list.tqh_first) != NULL) { - free(e_defp->s); - TAILQ_REMOVE(&defp->list, e_defp, q); - } - free(defp->s); - TAILQ_REMOVE(&head, defp, q); - defnewp = getlist("_default_new"); - free(defnewp->s); - defnewp->s = "_default"; - defp = defnewp; - } - - /* - * 3: If the user set the -m option, insert the user's list before - * whatever list we have, again appending the _subdir list and - * the machine. - */ - if (p_add != NULL) - for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) { - slashp = p[strlen(p) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_HEAD(&defp->list, ep, q); - } - } - - /* - * 4: If none of MANPATH, -M, or -m were specified, and a section was, - * rewrite the section's paths (if they have a trailing slash) to - * append the _subdir list and the machine. This then becomes the - * _default list. - */ - if (p_path == NULL && p_add == NULL && section != NULL) { - sectnewp = addlist("_section_new"); - for (e_sectp = section->list.tqh_first; - e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) { - if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') { - (void)snprintf(buf, sizeof(buf), - "%s{/%s,}", e_sectp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(§newp->list, ep, q); - continue; - } - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s{/%s,}", - e_sectp->s, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(§newp->list, ep, q); - } - } - sectnewp->s = section->s; - defp = sectnewp; - TAILQ_REMOVE(&head, section, q); - } - - /* - * 5: Search for the files. Set up an interrupt handler, so the - * temporary files go away. - */ - (void)signal(SIGINT, onsig); - (void)signal(SIGHUP, onsig); - - memset(&pg, 0, sizeof(pg)); - for (found = 0; *argv; ++argv) - if (manual(*argv, defp, &pg)) - found = 1; - - /* 6: If nothing found, we're done. */ - if (!found) { - (void)cleanup(); - exit (1); - } - - /* 7: If it's simple, display it fast. */ - if (f_cat) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - cat(*ap); - } - exit (cleanup()); - } - if (f_how) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - how(*ap); - } - exit(cleanup()); - } - if (f_where) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - (void)printf("%s\n", *ap); - } - exit(cleanup()); - } - - /* - * 8: We display things in a single command; build a list of things - * to display. - */ - for (ap = pg.gl_pathv, len = strlen(pager) + 1; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - len += strlen(*ap) + 1; - } - if ((cmd = malloc(len)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - p = cmd; - len = strlen(pager); - memmove(p, pager, len); - p += len; - *p++ = ' '; - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - len = strlen(*ap); - memmove(p, *ap, len); - p += len; - *p++ = ' '; - } - *p = '\0'; - - /* Use system(3) in case someone's pager is "pager arg1 arg2". */ - (void)system(cmd); - - exit(cleanup()); -} - -/* - * manual -- - * Search the manuals for the pages. - */ -static int -manual(page, tag, pg) - char *page; - TAG *tag; - glob_t *pg; -{ - ENTRY *ep, *e_sufp, *e_tag; - TAG *missp, *sufp; - int anyfound, cnt, found; - char *p, buf[128]; - - anyfound = 0; - buf[0] = '*'; - - /* For each element in the list... */ - e_tag = tag == NULL ? NULL : tag->list.tqh_first; - for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page); - if (glob(buf, - GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE, - NULL, pg)) { - warn("globbing"); - (void)cleanup(); - exit(1); - } - if (pg->gl_matchc == 0) - continue; - - /* Find out if it's really a man page. */ - for (cnt = pg->gl_pathc - pg->gl_matchc; - cnt < pg->gl_pathc; ++cnt) { - - /* - * Try the _suffix key words first. - * - * XXX - * Older versions of man.conf didn't have the suffix - * key words, it was assumed that everything was a .0. - * We just test for .0 first, it's fast and probably - * going to hit. - */ - (void)snprintf(buf, sizeof(buf), "*/%s.0", page); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) - goto next; - - e_sufp = (sufp = getlist("_suffix")) == NULL ? - NULL : sufp->list.tqh_first; - for (found = 0; - e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) { - (void)snprintf(buf, - sizeof(buf), "*/%s%s", page, e_sufp->s); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { - found = 1; - break; - } - } - if (found) - goto next; - - /* Try the _build key words next. */ - e_sufp = (sufp = getlist("_build")) == NULL ? - NULL : sufp->list.tqh_first; - for (found = 0; - e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) { - for (p = e_sufp->s; - *p != '\0' && !isspace(*p); ++p); - if (*p == '\0') - continue; - *p = '\0'; - (void)snprintf(buf, - sizeof(buf), "*/%s%s", page, e_sufp->s); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { - if (!f_where) - build_page(p + 1, - &pg->gl_pathv[cnt]); - *p = ' '; - found = 1; - break; - } - *p = ' '; - } - if (found) { -next: anyfound = 1; - if (!f_all) { - /* Delete any other matches. */ - while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = ""; - break; - } - continue; - } - - /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = ""; - } - - if (anyfound && !f_all) - break; - } - - /* If not found, enter onto the missing list. */ - if (!anyfound) { - if ((missp = getlist("_missing")) == NULL) - missp = addlist("_missing"); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(page)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - TAILQ_INSERT_TAIL(&missp->list, ep, q); - } - return (anyfound); -} - -/* - * build_page -- - * Build a man page for display. - */ -static void -build_page(fmt, pathp) - char *fmt, **pathp; -{ - static int warned; - ENTRY *ep; - TAG *intmpp; - int fd; - char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[sizeof(_PATH_TMP)]; - - /* Let the user know this may take awhile. */ - if (!warned) { - warned = 1; - warnx("Formatting manual page..."); - } - - /* Add a remove-when-done list. */ - if ((intmpp = getlist("_intmp")) == NULL) - intmpp = addlist("_intmp"); - - /* Move to the printf(3) format string. */ - for (; *fmt && isspace(*fmt); ++fmt); - - /* - * Get a temporary file and build a version of the file - * to display. Replace the old file name with the new one. - */ - (void)strcpy(tpath, _PATH_TMP); - if ((fd = mkstemp(tpath)) == -1) { - warn("%s", tpath); - (void)cleanup(); - exit(1); - } - (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); - (void)snprintf(cmd, sizeof(cmd), buf, *pathp); - (void)system(cmd); - (void)close(fd); - if ((*pathp = strdup(tpath)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - - /* Link the built file into the remove-when-done list. */ - if ((ep = malloc(sizeof(ENTRY))) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - ep->s = *pathp; - TAILQ_INSERT_TAIL(&intmpp->list, ep, q); -} - -/* - * how -- - * display how information - */ -static void -how(fname) - char *fname; -{ - FILE *fp; - - int lcnt, print; - char *p, buf[256]; - - if (!(fp = fopen(fname, "r"))) { - warn("%s", fname); - (void)cleanup(); - exit (1); - } -#define S1 "SYNOPSIS" -#define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS" -#define D1 "DESCRIPTION" -#define D2 "D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN" - for (lcnt = print = 0; fgets(buf, sizeof(buf), fp);) { - if (!strncmp(buf, S1, sizeof(S1) - 1) || - !strncmp(buf, S2, sizeof(S2) - 1)) { - print = 1; - continue; - } else if (!strncmp(buf, D1, sizeof(D1) - 1) || - !strncmp(buf, D2, sizeof(D2) - 1)) - return; - if (!print) - continue; - if (*buf == '\n') - ++lcnt; - else { - for(; lcnt; --lcnt) - (void)putchar('\n'); - for (p = buf; isspace(*p); ++p); - (void)fputs(p, stdout); - } - } - (void)fclose(fp); -} - -/* - * cat -- - * cat out the file - */ -static void -cat(fname) - char *fname; -{ - int fd, n; - char buf[2048]; - - if ((fd = open(fname, O_RDONLY, 0)) < 0) { - warn("%s", fname); - (void)cleanup(); - exit(1); - } - while ((n = read(fd, buf, sizeof(buf))) > 0) - if (write(STDOUT_FILENO, buf, n) != n) { - warn("write"); - (void)cleanup(); - exit (1); - } - if (n == -1) { - warn("read"); - (void)cleanup(); - exit(1); - } - (void)close(fd); -} - -/* - * check_pager -- - * check the user supplied page information - */ -static char * -check_pager(name) - char *name; -{ - char *p, *save; - - /* - * if the user uses "more", we make it "more -s"; watch out for - * PAGER = "mypager /usr/ucb/more" - */ - for (p = name; *p && !isspace(*p); ++p); - for (; p > name && *p != '/'; --p); - if (p != name) - ++p; - - /* make sure it's "more", not "morex" */ - if (!strncmp(p, "more", 4) && (!p[4] || isspace(p[4]))){ - save = name; - /* allocate space to add the "-s" */ - if (!(name = - malloc((u_int)(strlen(save) + sizeof("-s") + 1)))) - err(1, NULL); - (void)sprintf(name, "%s %s", save, "-s"); - } - return(name); -} - -/* - * jump -- - * strip out flag argument and jump - */ -static void -jump(argv, flag, name) - char **argv, *flag, *name; -{ - char **arg; - - argv[0] = name; - for (arg = argv + 1; *arg; ++arg) - if (!strcmp(*arg, flag)) - break; - for (; *arg; ++arg) - arg[0] = arg[1]; - execvp(name, argv); - (void)fprintf(stderr, "%s: Command not found.\n", name); - exit(1); -} - -/* - * onsig -- - * If signaled, delete the temporary files. - */ -static void -onsig(signo) - int signo; -{ - (void)cleanup(); - - (void)signal(signo, SIG_DFL); - (void)kill(getpid(), signo); - - /* NOTREACHED */ - exit (1); -} - -/* - * cleanup -- - * Clean up temporary files, show any error messages. - */ -static int -cleanup() -{ - TAG *intmpp, *missp; - ENTRY *ep; - int rval; - - rval = 0; - ep = (missp = getlist("_missing")) == NULL ? - NULL : missp->list.tqh_first; - if (ep != NULL) - for (; ep != NULL; ep = ep->q.tqe_next) { - warnx("no entry for %s in the manual.", ep->s); - rval = 1; - } - - ep = (intmpp = getlist("_intmp")) == NULL ? - NULL : intmpp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - (void)unlink(ep->s); - return (rval); -} - -/* - * usage -- - * print usage message and die - */ -static void -usage() -{ - (void)fprintf(stderr, - "usage: man [-achw] [-C file] [-M path] [-m path] [section] title ...\n"); - exit(1); -} diff --git a/usr.bin/man/man.conf b/usr.bin/man/man.conf deleted file mode 100644 index 9faad52546e5..000000000000 --- a/usr.bin/man/man.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Sheer, raging paranoia... -_version BSD.2 - -# The whatis/apropos database. -_whatdb /usr/share/man/whatis.db - -# Subdirectories for paths ending in '/', IN SEARCH ORDER. -_subdir cat{1,8,6,2,3,4,5,7,3f} - -# Files typed by suffix and their commands. -# Note the order, .Z must come after .[1-9].Z, or it will match first. -_suffix .0 -_build .[1-9] /usr/bin/nroff -man %s -_build .[1-9].Z /usr/bin/zcat %s | /usr/bin/nroff -man -_build .Z /usr/bin/zcat %s -_build .0.Z /usr/bin/zcat %s -_build .gz /usr/contrib/bin/gunzip %s -_build .z /usr/contrib/bin/gunzip %s -_build .nr /usr/bin/nroff -man %s - -# Sections and their directories. -# All paths ending in '/' are the equivalent of entries specifying that -# directory with all of the subdirectories listed for the keyword _subdir. - -# default -_default /usr/{share,X11,contrib,local}/{man,man/old}/ - -# Other sections that represent complete man subdirectories. -X11 /usr/X11R4/man/ -X11R4 /usr/X11R4/man/ -contrib /usr/contrib/man/ -local /usr/local/man/ -new /usr/contrib/man/ -old /usr/share/man/old/ - -# Specific section/directory combinations. -1 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat1 -2 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat2 -3 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat3 -3F /usr/share/man/cat3f -3f /usr/share/man/cat3f -4 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat4 -5 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat5 -6 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat6 -7 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat7 -8 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat8 diff --git a/usr.bin/man/man.conf.5 b/usr.bin/man/man.conf.5 deleted file mode 100644 index 353a30236fb9..000000000000 --- a/usr.bin/man/man.conf.5 +++ /dev/null @@ -1,195 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)man.conf.5 8.5 (Berkeley) 1/2/94 -.\" -.Dd January 2, 1994 -.Dt MAN.CONF 5 -.Os -.Sh NAME -.Nm man.conf -.Nd configuration file for -.Xr man 1 -.Sh DESCRIPTION -The -.Xr man 1 , -.Xr apropos 1 , -and -.Xr whatis 1 -commands -search for manual pages or their database files as specified by the -.Nm man.conf -file. -Manual pages are normally expected to be preformatted (see -.Xr nroff 1 ) -and named with a trailing ``.0''. -.Pp -The -.Nm man.conf -file contains two types of lines. -.Pp -The first type of line is a ``section'' line, which contains a -section name followed by one or more directory paths. -The directory paths may contain the normal shell globbing characters, -including curly braces (``{}''); to escape a shell globbing character, -precede it with a backslash (``\e''). -Lines in this format specify that manual pages for the section -may be found in the following directories. -.Pp -Directories named with a trailing slash character (``/'') are expected -to contain subdirectories of manual pages, (see the keyword ``_subdir'' -below) instead of manual pages. -These subdirectories are searched instead of the directory. -.Pp -Before searching any directory for a manual page, the -.Xr man 1 -command always searches the subdirectory with the same name -as the current machine type, if it exists. -No specification of these subdirectories is necessary in the -.Nm man.conf -file. -.Pp -Section names are unrestricted except for the reserved words specified -below; in general, you should avoid anything with a leading underscore -(``_'') to avoid future incompatibilities. -.Pp -The section named ``_default'' is the list of directories that will -be searched if no section is specified by the user. -.Pp -The second type of line is preceded with a ``keyword''. -The possible keywords and their meanings are as follows: -.Pp -.Bl -tag -width "_version" -.It _build -Man file names, regardless of their format, are expected to end in -a ``.*'' pattern, i.e. a ``.'' followed by some suffix. -The first field of a _build line lists a suffix which indicates -files which need to be reformated or manipulated in some way before -being displayed to the user. -The suffix may contain the normal shell globbing characters (NOT -including curly braces (``{}'')). -The rest of the line must be a shell command line, the standard -output of which is the manual page in a format which may be directly -displayed to the user. -Any occurrences of the string ``%s'' in the shell command line will -be replaced by the name of the file which is being reformatted. -.It _subdir -The list (in search order) of subdirectories which will be searched in -any directory named with a trailing slash (``/'') character. -This list is also used when a path is specified to the -.Xr man 1 -utility by the user, using the -.Ev MANPATH -environment variable or the -.Fl M -and -.Fl m -options. -.It _suffix -Man file names, regardless of their format are expected to end in -a ``.*'' pattern, i.e. a ``.'' followed by some suffix. -Each field of a _suffix line is a suffix which indicates -files which do not need to be reformatted or manipulated -in any way, but which may be directly displayed to the user. -Each suffix may contain the normal shell globbing characters (NOT -including curly braces (``{}'')). -.It _version -The version of the configuration file. -.It _whatdb -The full pathname (not just a directory path) for a database to be used -by the -.Xr apropos 1 -and -.Xr whatis 1 -commands. -.El -.Pp -Multiple specifications for all types of lines are cumulative and the -entries are used in the order listed in the file; multiple entries may -be listed per line, as well. -.Pp -Empty lines or lines whose first non-whitespace character is a hash -mark (``#'') are ignored. -.Sh EXAMPLES -Given the following -.Nm man.conf -file: -.Bd -literal -offset indent -_version BSD.2 -_subdir cat[123] -_suffix .0 -_build .[1-9] nroff -man %s -_build .tbl tbl %s | nroff -man -_default /usr/share/man/ -sect3 /usr/share/man/{old/,}cat3 -.Ed -.Pp -By default, the command -.Dq Li man mktemp -will search for -``mktemp.'' and ``mktemp.tbl'' -in the directories -.Dq Pa /usr/share/man/cat1 , -.Dq Pa /usr/share/man/cat2 , -and -.Dq Pa /usr/share/man/cat3 . -If on a machine of type ``vax'', the subdirectory ``vax'' in each -directory would be searched as well, before the directory was -searched. -.Pp -If ``mktemp.tbl'' was found first, the command -.Dq Li tbl | nroff -man -would be run to build a man page for display to the user. -.Pp -The command -.Dq Li man sect3 mktemp -would search the directories -.Dq Pa /usr/share/man/old/cat3 -and -.Dq Pa /usr/share/man/cat3 , -in that order, for -the mktemp manual page. -If a subdirectory with the same name as the current machine type -existed in any of them, it would be searched as well, before each -of them were searched. -.Sh FILES -.Bl -tag -width /etc/man.conf -compact -.It Pa /etc/man.conf -Standard manual directory search path. -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr machine 1 , -.Xr man 1 , -.Xr whatis 1 , -.Xr whereis 1 , -.Xr fnmatch 3 , -.Xr glob 3 diff --git a/usr.bin/man/pathnames.h b/usr.bin/man/pathnames.h deleted file mode 100644 index 17284fe0d874..000000000000 --- a/usr.bin/man/pathnames.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.3 (Berkeley) 1/2/94 - */ - -#define _PATH_MANCONF "/etc/man.conf" -#define _PATH_PAGER "/usr/bin/more -s" -#define _PATH_TMP "/tmp/man.XXXXXX" -#define _PATH_WHATIS "whatis.db" diff --git a/usr.bin/mklocale/Japanese b/usr.bin/mklocale/Japanese deleted file mode 100644 index 55eb1559660f..000000000000 --- a/usr.bin/mklocale/Japanese +++ /dev/null @@ -1,158 +0,0 @@ -# @(#)Japanese 8.1 (Berkeley) 6/6/93 - -/* - * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets - */ - -ENCODING "EUC" - -/* JIS JIS JIS */ -/* X201 X208 X201 */ -/* 00-7f 84-fe */ - -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 - -/* - * Code Set 1 - */ -ALPHA 'A' - 'Z' 'a' - 'z' -CONTROL 0x00 - 0x1f 0x7f -DIGIT '0' - '9' -GRAPH 0x21 - 0x7e -LOWER 'a' - 'z' -PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e -SPACE 0x09 - 0x0d 0x20 -UPPER 'A' - 'Z' -XDIGIT 'a' - 'f' 'A' - 'F' -BLANK ' ' '\t' -PRINT 0x20 - 0x7e - -MAPLOWER < 'A' - 'Z' : 'a' > -MAPLOWER < 'a' - 'z' : 'a' > -MAPUPPER < 'A' - 'Z' : 'A' > -MAPUPPER < 'a' - 'z' : 'A' > -TODIGIT < '0' - '9' : 0 > -TODIGIT < 'A' - 'F' : 10 > -TODIGIT < 'a' - 'f' : 10 > - -/* - * Code Set 2 - */ - -SPACE 0xa1a1 -PHONOGRAM 0xa1bc -SPECIAL 0xa1a2 - 0xa1fe -PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ - -SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea -SPECIAL 0xa2f2 - 0xa2f9 0xa2fe - -DIGIT 0xa3b0 - 0xa3b9 -UPPER 0xa3c1 - 0xa3da /* Romaji */ -LOWER 0xa3e1 - 0xa3fa /* Romaji */ -MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ -MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ -MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > -MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > - -XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 - -TODIGIT < 0xa3b0 - 0xa3b9 : 0 > -TODIGIT < 0xa3c1 - 0xa3c6 : 10 > -TODIGIT < 0xa3e1 - 0xa3e6 : 10 > - -PHONOGRAM 0xa4a1 - 0xa4f3 -PHONOGRAM 0xa5a1 - 0xa5f6 - -UPPER 0xa6a1 - 0xa6b8 /* Greek */ -LOWER 0xa6c1 - 0xa6d8 /* Greek */ -MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > -MAPLOWER < 0xa6c1 - 0xa6d8 : 0xa6c1 > -MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > -MAPUPPER < 0xa6c1 - 0xa6d8 : 0xa6a1 > - -UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ -LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ -MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > -MAPLOWER < 0xa7d1 - 0xa7f1 : 0xa7d1 > -MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > -MAPUPPER < 0xa7d1 - 0xa7f1 : 0xa7a1 > - -SPECIAL 0xa8a1 - 0xa8c0 - -IDEOGRAM 0xb0a1 - 0xb0fe -IDEOGRAM 0xb1a1 - 0xb1fe -IDEOGRAM 0xb2a1 - 0xb2fe -IDEOGRAM 0xb3a1 - 0xb3fe -IDEOGRAM 0xb4a1 - 0xb4fe -IDEOGRAM 0xb5a1 - 0xb5fe -IDEOGRAM 0xb6a1 - 0xb6fe -IDEOGRAM 0xb7a1 - 0xb7fe -IDEOGRAM 0xb8a1 - 0xb8fe -IDEOGRAM 0xb9a1 - 0xb9fe -IDEOGRAM 0xbaa1 - 0xbafe -IDEOGRAM 0xbba1 - 0xbbfe -IDEOGRAM 0xbca1 - 0xbcfe -IDEOGRAM 0xbda1 - 0xbdfe -IDEOGRAM 0xbea1 - 0xbefe -IDEOGRAM 0xbfa1 - 0xbffe -IDEOGRAM 0xc0a1 - 0xc0fe -IDEOGRAM 0xc1a1 - 0xc1fe -IDEOGRAM 0xc2a1 - 0xc2fe -IDEOGRAM 0xc3a1 - 0xc3fe -IDEOGRAM 0xc4a1 - 0xc4fe -IDEOGRAM 0xc5a1 - 0xc5fe -IDEOGRAM 0xc6a1 - 0xc6fe -IDEOGRAM 0xc7a1 - 0xc7fe -IDEOGRAM 0xc8a1 - 0xc8fe -IDEOGRAM 0xc9a1 - 0xc9fe -IDEOGRAM 0xcaa1 - 0xcafe -IDEOGRAM 0xcba1 - 0xcbfe -IDEOGRAM 0xcca1 - 0xccfe -IDEOGRAM 0xcda1 - 0xcdfe -IDEOGRAM 0xcea1 - 0xcefe -IDEOGRAM 0xcfa1 - 0xcfd3 -IDEOGRAM 0xd0a1 - 0xd0fe -IDEOGRAM 0xd1a1 - 0xd1fe -IDEOGRAM 0xd2a1 - 0xd2fe -IDEOGRAM 0xd3a1 - 0xd3fe -IDEOGRAM 0xd4a1 - 0xd4fe -IDEOGRAM 0xd5a1 - 0xd5fe -IDEOGRAM 0xd6a1 - 0xd6fe -IDEOGRAM 0xd7a1 - 0xd7fe -IDEOGRAM 0xd8a1 - 0xd8fe -IDEOGRAM 0xd9a1 - 0xd9fe -IDEOGRAM 0xdaa1 - 0xdafe -IDEOGRAM 0xdba1 - 0xdbfe -IDEOGRAM 0xdca1 - 0xdcfe -IDEOGRAM 0xdda1 - 0xddfe -IDEOGRAM 0xdea1 - 0xdefe -IDEOGRAM 0xdfa1 - 0xdffe -IDEOGRAM 0xe0a1 - 0xe0fe -IDEOGRAM 0xe1a1 - 0xe1fe -IDEOGRAM 0xe2a1 - 0xe2fe -IDEOGRAM 0xe3a1 - 0xe3fe -IDEOGRAM 0xe4a1 - 0xe4fe -IDEOGRAM 0xe5a1 - 0xe5fe -IDEOGRAM 0xe6a1 - 0xe6fe -IDEOGRAM 0xe7a1 - 0xe7fe -IDEOGRAM 0xe8a1 - 0xe8fe -IDEOGRAM 0xe9a1 - 0xe9fe -IDEOGRAM 0xeaa1 - 0xeafe -IDEOGRAM 0xeba1 - 0xebfe -IDEOGRAM 0xeca1 - 0xecfe -IDEOGRAM 0xeda1 - 0xedfe -IDEOGRAM 0xeea1 - 0xeefe -IDEOGRAM 0xefa1 - 0xeffe -IDEOGRAM 0xf0a1 - 0xf0fe -IDEOGRAM 0xf1a1 - 0xf1fe -IDEOGRAM 0xf2a1 - 0xf2fe -IDEOGRAM 0xf3a1 - 0xf3fe -IDEOGRAM 0xf4a1 - 0xf4a4 - -/* - * This is for Code Set 3, half-width kana - */ -SPECIAL 0xa1 - 0xdf -PHONOGRAM 0xa1 - 0xdf -CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe diff --git a/usr.bin/ncftp/Makefile.ORIG b/usr.bin/ncftp/Makefile.ORIG deleted file mode 100644 index 7fe52b8bdcfe..000000000000 --- a/usr.bin/ncftp/Makefile.ORIG +++ /dev/null @@ -1,287 +0,0 @@ -# Makefile for ncftp -# -# Major sections delimited by a dash lines. If several lines set the same -# make variable, you can choose between the commented #samples, or just -# type what you want manually. -#-------------------------------------------------------------------------- - - -# System dependent definitions. See the README, part B. -#-------------------------------------------------------------------------- -SDEFS = - - -# Program definitions. See the README, part C. -#-------------------------------------------------------------------------- -PDEFS = -#PDEFS = -DGETLINE -#PDEFS = -DREADLINE -DCURSES -#PDEFS = -DSOCKS -#PDEFS = -DPASSIVEMODE -#PDEFS = -DDEBUG -DDB_ERRS - - -# Choose your compiler and flags below. Make sure you use an ANSI compiler -# that handles new style function declarations and prototypes (gcc should). -#-------------------------------------------------------------------------- -CC = cc -#CC = gcc - -#CFLAGS = $(TERM_INC) -O -CFLAGS = $(TERM_INC) -O2 -#CFLAGS = $(TERM_INC) -g - -LFLAGS = -s -#LFLAGS = - - -# Additional libraries and/or object files. -# -# For each library, add -lLIBNAME to the LIBS line below, for a library -# named libLIBNAME.a. -# -# For each object file, just add the pathname of the object file. -# -# Some may need any of -lsocket, -lnet, -linet, -lintl, or -lnsl. -# You'll need -lcurses or -ltermcap if CURSES is defined. -# You'll need -lreadline AND either -lcurses or -ltermcap if you -# want to use the GNU Readline library. -# You'll need -lgetline (compile it as a library) if you want to use -# getline. -# If your system is running Yellow Pages, you'll need to add the library -# that has the YP/NIS version of getpwuid() in it (Important!) -# You'll need to know where the Rconnect.o object file is if you want -# to use Socks. -#-------------------------------------------------------------------------- -LIBS = -#LIBS = -ldbmalloc -#LIBS = -lgetline -#LIBS = -lreadline -lcurses -#LIBS = ../lib/Rconnect.o -#LIBS = -lnet -lnsl -lsocket -lcurses -#LIBS = -lcurses -ltermcap - -# If the libraries are in a non-standard directory, or you if want to use -# getline or readline and they aren't installed system-wide, add the -# extra directories to look in here, using -L's. -#-------------------------------------------------------------------------- -LIBDIRS = -#LIBDIRS = -L../getline -#LIBDIRS = -L../readline - -# To make term sources define this to your term directory -TERM_INC = -TERM_LIB = -#TERM_INC = -include /usr/local/include/termnet.h -#TERM_LIB = -ltermnet - -# Additional headers. -# -# If you defined READLINE or GETLINE, you have to tell where it's header -# file can be found. -# -# For READLINE, provide a path which would find , -# so you would put the parent directory of the readline directory below. -# If you had '/usr/local/readline/readline.h' you would use -# -I/usr/local. -# -# For GETLINE, a little different. Just supply a path that would find -# . If you had '/usr/local/getline/getline.h' you would use -# -I/usr/local/getline. -#-------------------------------------------------------------------------- -HDRDIRS = -#HDRDIRS = -I../getline -#HDRDIRS = -I.. - - -# If you want to 'make install,' edit these variables, otherwise don't -# worry about it. -# To install MAN style pages, set MANDIR to the proper location. -# To install CATMAN style pages, set CATMANDIR, NROFF, and PACK to the proper -# locations. -# To inhibit the installation of either, unset MANDIR/CATMANDIR. -#-------------------------------------------------------------------------- -#BINDIR = /usr/lbin -BINDIR = /usr/local/bin -MANDIR = /usr/man/man1 -#MANDIR = -#CATMANDIR = /usr/catman/LOCAL/g1 -CATMANDIR = -NROFF = /usr/ucb/nroff -PACK = pack -TEST = test -RM = rm -f -CP = cp -CAT = cat - - -#************************************************ -#*** SHOULD NOT NEED TO EDIT BELOW THIS POINT *** -#************************************************ - -DEFS = $(PDEFS) $(SDEFS) -MK = $(CC) $(CFLAGS) $(DEFS) $(HDRDIRS) $(LFLAGS) $(LIBDIRS) $(LIBS) - -SRCS = cmds.c cmdtab.c ftp.c ftprc.c getpass.c glob.c main.c open.c set.c \ -tips.c util.c - -HEADERS = cmds.h copyright.h defaults.h ftp.h ftprc.h getpass.h glob.h \ -main.h open.h set.h sys.h util.h - -OBJS = cmds.o cmdtab.o ftp.o ftprc.o getpass.o glob.o main.o open.o set.o \ -tips.o util.o - -NAME = ncftp -MAN = ncftp.1 -CATMAN = ncftp.z -ALL = $(SRCS) $(HEADERS) patchlevel.h Blurb README Makefile $(MAN) \ -v2_Note - -C_COMPILE = $(CC) $(CFLAGS) $(DEFS) $(HDRDIRS) -C_COMPILE2 = $(CC) $(CFLAGS) $(DEFS) -DMK='"$(MK)"' $(HDRDIRS) - -all: $(NAME) done - -$(NAME): $(OBJS) - $(CC) $(LFLAGS) $(LIBDIRS) $(OBJS) -o $(NAME) $(LIBS) $(TERM_LIB) - -install: $(NAME) - if $(TEST) -f $(BINDIR)/term ; then \ - $(CP) $(BINDIR)/term $(BINDIR)/$(NAME) ; \ - $(CAT) $(NAME) > $(BINDIR)/$(NAME) ; \ - else \ - $(CP) $(NAME) $(BINDIR)/$(NAME) ; \ - fi - @if $(TEST) -n '$(MANDIR)'; then \ - $(MAKE) install_man ; else true ; fi - @if $(TEST) -n '$(CATMANDIR)'; then \ - $(MAKE) install_catman ; else true ; fi - -install_man: $(MAN) - $(CP) $(MAN) $(MANDIR)/$(MAN) - - -install_catman: $(CATMAN) - $(CP) $(CATMAN) $(CATMANDIR)/$(CATMAN) - -uninstall: - $(RM) $(BINDIR)/$(NAME) - $(RM) $(MANDIR)/$(MAN) - $(RM) $(CATMANDIR)/$(CATMAN) - -$(CATMAN): $(MAN) - $(RM) tmp - $(NROFF) -man -Tlp $(MAN) > tmp - $(PACK) -f tmp - mv tmp.z $(CATMAN) - -cmds.o: - $(C_COMPILE2) cmds.c -c - -.c.o: - $(C_COMPILE) -c $< - -done: $(NAME) - -@ls -l $(NAME) - -@echo 'Done.' - -clean: - rm -f $(OBJS) $(NAME) - -# Dependencies: -cmds.o: cmds.c -cmds.o: sys.h -cmds.o: util.h -cmds.o: cmds.h -cmds.o: main.h -cmds.o: ftp.h -cmds.o: ftprc.h -cmds.o: getpass.h -cmds.o: glob.h -cmds.o: open.h -cmds.o: set.h -cmds.o: defaults.h -cmds.o: copyright.h -cmdtab.o: cmdtab.c -cmdtab.o: sys.h -cmdtab.o: util.h -cmdtab.o: cmds.h -cmdtab.o: main.h -cmdtab.o: ftp.h -cmdtab.o: ftprc.h -cmdtab.o: glob.h -cmdtab.o: open.h -cmdtab.o: set.h -cmdtab.o: copyright.h -ftp.o: ftp.c -ftp.o: sys.h -ftp.o: util.h -ftp.o: ftp.h -ftp.o: cmds.h -ftp.o: main.h -ftp.o: ftprc.h -ftp.o: getpass.h -ftp.o: defaults.h -ftp.o: copyright.h -ftprc.o: ftprc.c -ftprc.o: sys.h -ftprc.o: util.h -ftprc.o: ftprc.h -ftprc.o: main.h -ftprc.o: cmds.h -ftprc.o: set.h -ftprc.o: defaults.h -ftprc.o: copyright.h -getpass.o: getpass.c -getpass.o: sys.h -getpass.o: util.h -getpass.o: cmds.h -getpass.o: getpass.h -getpass.o: copyright.h -glob.o: glob.c -glob.o: sys.h -glob.o: util.h -glob.o: glob.h -glob.o: cmds.h -glob.o: copyright.h -main.o: main.c -main.o: sys.h -main.o: util.h -main.o: cmds.h -main.o: main.h -main.o: ftp.h -main.o: ftprc.h -main.o: open.h -main.o: set.h -main.o: defaults.h -main.o: copyright.h -open.o: open.c -open.o: sys.h -open.o: util.h -open.o: open.h -open.o: cmds.h -open.o: ftp.h -open.o: ftprc.h -open.o: main.h -open.o: defaults.h -open.o: copyright.h -set.o: set.c -set.o: sys.h -set.o: util.h -set.o: cmds.h -set.o: main.h -set.o: set.h -set.o: defaults.h -set.o: copyright.h -tips.o: tips.c -tips.o: sys.h -tips.o: util.h -util.o: util.c -util.o: sys.h -util.o: util.h -util.o: cmds.h -util.o: main.h -util.o: ftp.h -util.o: ftprc.h -util.o: defaults.h -util.o: copyright.h diff --git a/usr.bin/ncftp/v2_Note b/usr.bin/ncftp/v2_Note deleted file mode 100644 index 6900bf29d9c2..000000000000 --- a/usr.bin/ncftp/v2_Note +++ /dev/null @@ -1,35 +0,0 @@ -Versions numbered between 1.5.0 and 1.9.9 are interim releases. No major -features are planned for these; only tweaks and fixes. - -Version 2.0 is much cooler, but I haven't had time to work on it. If -you send me email, I _will_ read it, but it may take me awhile to get to it, -and I may not answer. Please don't be offended. I really regret having -to release code that is such a mess. I should have wrote the code from -scratch, rather than built it upon the original BSD code (which is a mess -itself!). - -I apologize in advance for bugs I fixed in 2.0 but forgot to re-fix -in these interim releases (I think I got'em all, though). - -Here is a list of things that are in the 2.0 code but not this version: - -* Easy-to-read, better organized, commented code. -* Using my own "style guide," so source is coded uniformly. -* Unlimited global macros. These are really nice! They take arguments, - so you can make mini-scripts. The macros can be typed as if they - were commands; no more $macroname crap. -* No-longer using .netrc and it's format. This was necessary for the - global macros anyway, and it allowed me to add some other features, - like host aliases. Old .netrc's won't work. Sorry! -* Improved command line parser, that lets any command use > and |, so - it behaves like a real shell command line (almost). -* Improved 'redir' that works automatically, can reformat listings with - different ls flags, all without refetching it over the network. It - will also facilitate remote globbing... AND remote filename completion! -* Many little things I can't begin to list. - -Keep that in mind if you want to make a feature enhancement. I'm telling -you this now so you don't spend your time programming something that is -already done for the 2.0 release. Also note that patches would -have to be re-coded for 2.0. (The gist is that you should wait until -2.0 is done before doing anything major). diff --git a/usr.bin/passwd/kpasswd_proto.h b/usr.bin/passwd/kpasswd_proto.h deleted file mode 100644 index 465d4c7ad881..000000000000 --- a/usr.bin/passwd/kpasswd_proto.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kpasswd_proto.h 8.1 (Berkeley) 6/6/93 - */ - -/* - * kpasswd_proto - * - * definitions for the kpasswd "protocol" - * (We hope this to be temporary until a real admin protocol is worked out.) - */ - -struct kpasswd_data { - des_cblock random_key; - char secure_msg[_PASSWORD_LEN]; -}; - -struct update_data { - char pw[_PASSWORD_LEN]; - char secure_msg[_PASSWORD_LEN]; -}; -#define SERVICE "kpasswd" -#define SECURE_STRING \ - "Kerberos password update program -- 12/9/88 UC Berkeley" diff --git a/usr.bin/passwd/krb_passwd.c b/usr.bin/passwd/krb_passwd.c deleted file mode 100644 index d4a0f15be7bb..000000000000 --- a/usr.bin/passwd/krb_passwd.c +++ /dev/null @@ -1,319 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)krb_passwd.c 8.3 (Berkeley) 4/2/94"; -#endif /* not lint */ - -#ifdef KERBEROS - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kpasswd_proto.h" - -#include "extern.h" - -#define PROTO "tcp" - -static void send_update __P((int, char *, char *)); -static void recv_ack __P((int)); -static void cleanup __P((void)); -static void finish __P((void)); - -static struct timeval timeout = { CLIENT_KRB_TIMEOUT, 0 }; -static struct kpasswd_data proto_data; -static des_cblock okey; -static Key_schedule osched; -static KTEXT_ST ticket; -static Key_schedule random_schedule; -static long authopts; -static char realm[REALM_SZ], krbhst[MAX_HSTNM]; -static int sock; - -int -krb_passwd() -{ - struct servent *se; - struct hostent *host; - struct sockaddr_in sin; - CREDENTIALS cred; - fd_set readfds; - int rval; - char pass[_PASSWORD_LEN], password[_PASSWORD_LEN]; - static void finish(); - - static struct rlimit rl = { 0, 0 }; - - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGTSTP, SIG_IGN); - - if (setrlimit(RLIMIT_CORE, &rl) < 0) { - warn("setrlimit"); - return (1); - } - - if ((se = getservbyname(SERVICE, PROTO)) == NULL) { - warnx("couldn't find entry for service %s/%s", - SERVICE, PROTO); - return (1); - } - - if ((rval = krb_get_lrealm(realm,1)) != KSUCCESS) { - warnx("couldn't get local Kerberos realm: %s", - krb_err_txt[rval]); - return (1); - } - - if ((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) { - warnx("couldn't get Kerberos host: %s", - krb_err_txt[rval]); - return (1); - } - - if ((host = gethostbyname(krbhst)) == NULL) { - warnx("couldn't get host entry for krb host %s", - krbhst); - return (1); - } - - sin.sin_family = host->h_addrtype; - memmove((char *) &sin.sin_addr, host->h_addr, host->h_length); - sin.sin_port = se->s_port; - - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - warn("socket"); - return (1); - } - - if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - warn("connect"); - (void)close(sock); - return (1); - } - - rval = krb_sendauth( - authopts, /* NOT mutual */ - sock, - &ticket, /* (filled in) */ - SERVICE, - krbhst, /* instance (krbhst) */ - realm, /* dest realm */ - (u_long) getpid(), /* checksum */ - NULL, /* msg data */ - NULL, /* credentials */ - NULL, /* schedule */ - NULL, /* local addr */ - NULL, /* foreign addr */ - "KPWDV0.1" - ); - - if (rval != KSUCCESS) { - warnx("Kerberos sendauth error: %s", krb_err_txt[rval]); - return (1); - } - - krb_get_cred("krbtgt", realm, realm, &cred); - - (void)printf("Changing Kerberos password for %s.%s@%s.\n", - cred.pname, cred.pinst, realm); - - if (des_read_pw_string(pass, - sizeof(pass)-1, "Old Kerberos password:", 0)) { - warnx("error reading old Kerberos password"); - return (1); - } - - (void)des_string_to_key(pass, okey); - (void)des_key_sched(okey, osched); - (void)des_set_key(okey, osched); - - /* wait on the verification string */ - - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - - rval = - select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout); - - if ((rval < 1) || !FD_ISSET(sock, &readfds)) { - if(rval == 0) { - warnx("timed out (aborted)"); - cleanup(); - return (1); - } - warnx("select failed (aborted)"); - cleanup(); - return (1); - } - - /* read verification string */ - - if (des_read(sock, &proto_data, sizeof(proto_data)) != - sizeof(proto_data)) { - warnx("couldn't read verification string (aborted)"); - cleanup(); - return (1); - } - - (void)signal(SIGHUP, finish); - (void)signal(SIGINT, finish); - - if (strcmp(SECURE_STRING, proto_data.secure_msg) != 0) { - cleanup(); - /* don't complain loud if user just hit return */ - if (pass == NULL || (!*pass)) - return (0); - (void)fprintf(stderr, "Sorry\n"); - return (1); - } - - (void)des_key_sched(proto_data.random_key, random_schedule); - (void)des_set_key(proto_data.random_key, random_schedule); - (void)memset(pass, 0, sizeof(pass)); - - if (des_read_pw_string(pass, - sizeof(pass)-1, "New Kerberos password:", 0)) { - warnx("error reading new Kerberos password (aborted)"); - cleanup(); - return (1); - } - - if (des_read_pw_string(password, - sizeof(password)-1, "Retype new Kerberos password:", 0)) { - warnx("error reading new Kerberos password (aborted)"); - cleanup(); - return (1); - } - - if (strcmp(password, pass) != 0) { - warnx("password mismatch (aborted)"); - cleanup(); - return (1); - } - - if (strlen(pass) == 0) - (void)printf("using NULL password\n"); - - send_update(sock, password, SECURE_STRING); - - /* wait for ACK */ - - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - - rval = - select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout); - if ((rval < 1) || !FD_ISSET(sock, &readfds)) { - if(rval == 0) { - warnx("timed out reading ACK (aborted)"); - cleanup(); - exit(1); - } - warnx("select failed (aborted)"); - cleanup(); - exit(1); - } - recv_ack(sock); - cleanup(); - return (0); -} - -static void -send_update(dest, pwd, str) - int dest; - char *pwd, *str; -{ - static struct update_data ud; - - (void)strncpy(ud.secure_msg, str, _PASSWORD_LEN); - (void)strncpy(ud.pw, pwd, sizeof(ud.pw)); - if (des_write(dest, &ud, sizeof(ud)) != sizeof(ud)) { - warnx("couldn't write pw update (abort)"); - memset((char *)&ud, 0, sizeof(ud)); - cleanup(); - exit(1); - } -} - -static void -recv_ack(remote) - int remote; -{ - int cc; - char buf[BUFSIZ]; - - cc = des_read(remote, buf, sizeof(buf)); - if (cc <= 0) { - warnx("error reading acknowledgement (aborted)"); - cleanup(); - exit(1); - } - (void)printf("%s", buf); -} - -static void -cleanup() -{ - - (void)memset((char *)&proto_data, 0, sizeof(proto_data)); - (void)memset((char *)okey, 0, sizeof(okey)); - (void)memset((char *)osched, 0, sizeof(osched)); - (void)memset((char *)random_schedule, 0, sizeof(random_schedule)); -} - -static void -finish() -{ - - (void)close(sock); - exit(1); -} - -#endif /* KERBEROS */ diff --git a/usr.bin/patch/EXTERN.h b/usr.bin/patch/EXTERN.h deleted file mode 100644 index 0271074bbec9..000000000000 --- a/usr.bin/patch/EXTERN.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Header: EXTERN.h,v 2.0 86/09/17 15:35:37 lwall Exp $ - * - * $Log: EXTERN.h,v $ - * Revision 2.0 86/09/17 15:35:37 lwall - * Baseline for netwide release. - * - */ - -#undef EXT -#define EXT extern - -#undef INIT -#define INIT(x) - -#undef DOINIT diff --git a/usr.bin/patch/INTERN.h b/usr.bin/patch/INTERN.h deleted file mode 100644 index 8bf16f521b75..000000000000 --- a/usr.bin/patch/INTERN.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Header: INTERN.h,v 2.0 86/09/17 15:35:58 lwall Exp $ - * - * $Log: INTERN.h,v $ - * Revision 2.0 86/09/17 15:35:58 lwall - * Baseline for netwide release. - * - */ - -#undef EXT -#define EXT - -#undef INIT -#define INIT(x) = x - -#define DOINIT diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile deleted file mode 100644 index d6db9f702199..000000000000 --- a/usr.bin/patch/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= patch -SRCS= patch.c pch.c inp.c version.c util.c - -.include diff --git a/usr.bin/patch/README b/usr.bin/patch/README deleted file mode 100644 index 017b1a006ade..000000000000 --- a/usr.bin/patch/README +++ /dev/null @@ -1,79 +0,0 @@ - -The Makefile and config.h files in this directory work with the current -BSD release. Don't run the Configure script, you'll get wrong results. - -Keith Bostic 1/10/88 ------------------------------------------------------------------------------ - - Patch Kit, Version 2.0 - - Copyright (c) 1986, Larry Wall - -You may copy the patch kit in whole or in part as long as you don't try to -make money off it, or pretend that you wrote it. --------------------------------------------------------------------------- - -Please read all the directions below before you proceed any further, and -then follow them carefully. Failure to do so may void your warranty. :-) - -After you have unpacked your kit, you should have all the files listed -in MANIFEST. - -Installation - -1) Run Configure. This will figure out various things about your system. - Some things Configure will figure out for itself, other things it will - ask you about. It will then proceed to make config.h, config.sh, and - Makefile. - - You might possibly have to trim # comments from the front of Configure - if your sh doesn't handle them, but all other # comments will be taken - care of. - - If you don't have sh, you'll have to rip the prototype of config.h out - of Configure and generate the defines by hand. - -2) Glance through config.h to make sure system dependencies are correct. - Most of them should have been taken care of by running the Configure script. - - If you have any additional changes to make to the C definitions, they - can be done in the Makefile, or in config.h. Bear in mind that they may - get undone next time you run Configure. - -3) make - - This will attempt to make patch in the current directory. - -4) make install - - This will put patch into a public directory (normally /usr/local/bin). - It will also try to put the man pages in a reasonable place. It will not - nroff the man page, however. - -5) Read the manual entry before running patch. - -6) IMPORTANT! Help save the world! Communicate any problems and - suggested patches to me, lwall@sdcrdcf.UUCP (Larry Wall), so we can - keep the world in sync. If you have a problem, there's someone else - out there who either has had or will have the same problem. - - If possible, send in patches such that the patch program will apply them. - Context diffs are the best, then normal diffs. Don't send ed scripts-- - I've probably changed my copy since the version you have. - - Watch for patch patches in net.sources.bugs. Patches will generally be - in a form usable by the patch program. If you are just now bringing up - patch and aren't sure how many patches there are, write to me and I'll - send any you don't have. Your current patch level is shown in patchlevel.h. - - -NEW FEATURES IN THIS RELEASE - -(Correct) support for 4.3bsd-style context diffs. -Files can be created from scratch. -You can specify a fuzz-factor for context matching. -You can force patch to ask no questions. -You can specify how much of the leading pathname to strip off filenames. -Uses a Configure script for greater portability. -You are now asked if you want to apply a reversed patch. -No limit (apart from memory) on the size of hunks. diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h deleted file mode 100644 index 42d688312e36..000000000000 --- a/usr.bin/patch/common.h +++ /dev/null @@ -1,138 +0,0 @@ -/* $Header: common.h,v 2.0 86/09/17 15:36:39 lwall Exp $ - * - * $Log: common.h,v $ - * Revision 2.0 86/09/17 15:36:39 lwall - * Baseline for netwide release. - * - */ - -#define DEBUGGING - -#include "config.h" - -/* shut lint up about the following when return value ignored */ - -#define Signal (void)signal -#define Unlink (void)unlink -#define Lseek (void)lseek -#define Fseek (void)fseek -#define Fstat (void)fstat -#define Pclose (void)pclose -#define Close (void)close -#define Fclose (void)fclose -#define Fflush (void)fflush -#define Sprintf (void)sprintf -#define Mktemp (void)mktemp -#define Strcpy (void)strcpy -#define Strcat (void)strcat - -#include -#include -#include -#include -#include -#include - -/* constants */ - -#define TRUE (1) -#define FALSE (0) - -#define MAXHUNKSIZE 100000 /* is this enough lines? */ -#define INITHUNKMAX 125 /* initial dynamic allocation size */ -#define MAXLINELEN 1024 -#define BUFFERSIZE 1024 -#define ORIGEXT ".orig" -#define SCCSPREFIX "s." -#define GET "get -e %s" -#define RCSSUFFIX ",v" -#define CHECKOUT "co -l %s" - -/* handy definitions */ - -#define Null(t) ((t)0) -#define Nullch Null(char *) -#define Nullfp Null(FILE *) -#define Nulline Null(LINENUM) - -#define Ctl(ch) ((ch) & 037) - -#define strNE(s1,s2) (strcmp(s1, s2)) -#define strEQ(s1,s2) (!strcmp(s1, s2)) -#define strnNE(s1,s2,l) (strncmp(s1, s2, l)) -#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) - -/* typedefs */ - -typedef char bool; -typedef long LINENUM; /* must be signed */ -typedef unsigned MEM; /* what to feed malloc */ - -/* globals */ - -EXT int Argc; /* guess */ -EXT char **Argv; -EXT int Argc_last; /* for restarting plan_b */ -EXT char **Argv_last; - -EXT struct stat filestat; /* file statistics area */ -EXT int filemode INIT(0644); - -EXT char buf[MAXLINELEN]; /* general purpose buffer */ -EXT FILE *ofp INIT(Nullfp); /* output file pointer */ -EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */ - -EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */ -EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */ - -#define MAXFILEC 2 -EXT int filec INIT(0); /* how many file arguments? */ -EXT char *filearg[MAXFILEC]; -EXT bool ok_to_create_file INIT(FALSE); -EXT char *bestguess INIT(Nullch); /* guess at correct filename */ - -EXT char *outname INIT(Nullch); -EXT char rejname[128]; - -EXT char *origext INIT(Nullch); - -EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX"); -EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */ -EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX"); -EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX"); -EXT bool toutkeep INIT(FALSE); -EXT bool trejkeep INIT(FALSE); - -EXT LINENUM last_offset INIT(0); -#ifdef DEBUGGING -EXT int debug INIT(0); -#endif -EXT LINENUM maxfuzz INIT(2); -EXT bool force INIT(FALSE); -EXT bool verbose INIT(TRUE); -EXT bool reverse INIT(FALSE); -EXT bool noreverse INIT(FALSE); -EXT bool skip_rest_of_patch INIT(FALSE); -EXT int strippath INIT(957); -EXT bool canonicalize INIT(FALSE); - -#define CONTEXT_DIFF 1 -#define NORMAL_DIFF 2 -#define ED_DIFF 3 -#define NEW_CONTEXT_DIFF 4 -EXT int diff_type INIT(0); - -EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */ -EXT char if_defined[128]; /* #ifdef xyzzy */ -EXT char not_defined[128]; /* #ifndef xyzzy */ -EXT char else_defined[] INIT("#else\n");/* #else */ -EXT char end_defined[128]; /* #endif xyzzy */ - -EXT char *revision INIT(Nullch); /* prerequisite revision, if any */ - -char *malloc(); -char *realloc(); -char *strcpy(); -char *strcat(); -long atol(); -char *mktemp(); diff --git a/usr.bin/patch/config.h b/usr.bin/patch/config.h deleted file mode 100644 index 9318fe7cec1b..000000000000 --- a/usr.bin/patch/config.h +++ /dev/null @@ -1,16 +0,0 @@ -#define Reg1 register /**/ -#define Reg2 register /**/ -#define Reg3 register /**/ -#define Reg4 register /**/ -#define Reg5 register /**/ -#define Reg6 register /**/ -#define Reg7 register /**/ -#define Reg8 register /**/ -#define Reg9 register /**/ -#define Reg10 register /**/ -#define Reg11 /**/ -#define Reg12 /**/ -#define Reg13 /**/ -#define Reg14 /**/ -#define Reg15 /**/ -#define Reg16 /**/ diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c deleted file mode 100644 index a3eeb904363a..000000000000 --- a/usr.bin/patch/inp.c +++ /dev/null @@ -1,313 +0,0 @@ -/* $Header: inp.c,v 2.0 86/09/17 15:37:02 lwall Exp $ - * - * $Log: inp.c,v $ - * Revision 2.0 86/09/17 15:37:02 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "pch.h" -#include "INTERN.h" -#include "inp.h" - -/* Input-file-with-indexable-lines abstract type */ - -static long i_size; /* size of the input file */ -static char *i_womp; /* plan a buffer for entire file */ -static char **i_ptr; /* pointers to lines in i_womp */ - -static int tifd = -1; /* plan b virtual string array */ -static char *tibuf[2]; /* plan b buffers */ -static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */ -static LINENUM lines_per_buf; /* how many lines per buffer */ -static int tireclen; /* length of records in tmp file */ - -/* New patch--prepare to edit another file. */ - -void -re_input() -{ - if (using_plan_a) { - i_size = 0; -#ifndef lint - if (i_ptr != Null(char**)) - free((char *)i_ptr); -#endif - if (i_womp != Nullch) - free(i_womp); - i_womp = Nullch; - i_ptr = Null(char **); - } - else { - using_plan_a = TRUE; /* maybe the next one is smaller */ - Close(tifd); - tifd = -1; - free(tibuf[0]); - free(tibuf[1]); - tibuf[0] = tibuf[1] = Nullch; - tiline[0] = tiline[1] = -1; - tireclen = 0; - } -} - -/* Constuct the line index, somehow or other. */ - -void -scan_input(filename) -char *filename; -{ - if (!plan_a(filename)) - plan_b(filename); - if (verbose) { - say3("Patching file %s using Plan %s...\n", filename, - (using_plan_a ? "A" : "B") ); - } -} - -/* Try keeping everything in memory. */ - -bool -plan_a(filename) -char *filename; -{ - int ifd; - Reg1 char *s; - Reg2 LINENUM iline; - - if (ok_to_create_file && stat(filename, &filestat) < 0) { - if (verbose) - say2("(Creating file %s...)\n",filename); - makedirs(filename, TRUE); - close(creat(filename, 0666)); - } - if (stat(filename, &filestat) < 0) { - Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX); - if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) { - Sprintf(buf, CHECKOUT, filename); - if (verbose) - say2("Can't find %s--attempting to check it out from RCS.\n", - filename); - if (system(buf) || stat(filename, &filestat)) - fatal2("Can't check out %s.\n", filename); - } - else { - Sprintf(buf, "SCCS/%s%s", SCCSPREFIX, filename); - if (stat(buf, &filestat) >= 0 || stat(buf+5, &filestat) >= 0) { - Sprintf(buf, GET, filename); - if (verbose) - say2("Can't find %s--attempting to get it from SCCS.\n", - filename); - if (system(buf) || stat(filename, &filestat)) - fatal2("Can't get %s.\n", filename); - } - else - fatal2("Can't find %s.\n", filename); - } - } - filemode = filestat.st_mode; - if ((filemode & S_IFMT) & ~S_IFREG) - fatal2("%s is not a normal file--can't patch.\n", filename); - i_size = filestat.st_size; - if (out_of_mem) { - set_hunkmax(); /* make sure dynamic arrays are allocated */ - out_of_mem = FALSE; - return FALSE; /* force plan b because plan a bombed */ - } -#ifdef lint - i_womp = Nullch; -#else - i_womp = malloc((MEM)(i_size+2)); /* lint says this may alloc less than */ - /* i_size, but that's okay, I think. */ -#endif - if (i_womp == Nullch) - return FALSE; - if ((ifd = open(filename, 0)) < 0) - fatal2("Can't open file %s\n", filename); -#ifndef lint - if (read(ifd, i_womp, (int)i_size) != i_size) { - Close(ifd); /* probably means i_size > 15 or 16 bits worth */ - free(i_womp); /* at this point it doesn't matter if i_womp was */ - return FALSE; /* undersized. */ - } -#endif - Close(ifd); - if (i_size && i_womp[i_size-1] != '\n') - i_womp[i_size++] = '\n'; - i_womp[i_size] = '\0'; - - /* count the lines in the buffer so we know how many pointers we need */ - - iline = 0; - for (s=i_womp; *s; s++) { - if (*s == '\n') - iline++; - } -#ifdef lint - i_ptr = Null(char**); -#else - i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *))); -#endif - if (i_ptr == Null(char **)) { /* shucks, it was a near thing */ - free((char *)i_womp); - return FALSE; - } - - /* now scan the buffer and build pointer array */ - - iline = 1; - i_ptr[iline] = i_womp; - for (s=i_womp; *s; s++) { - if (*s == '\n') - i_ptr[++iline] = s+1; /* these are NOT null terminated */ - } - input_lines = iline - 1; - - /* now check for revision, if any */ - - if (revision != Nullch) { - if (!rev_in_string(i_womp)) { - if (force) { - if (verbose) - say2("\ -Warning: this file doesn't appear to be the %s version--patching anyway.\n", - revision); - } - else { - ask2("\ -This file doesn't appear to be the %s version--patch anyway? [n] ", - revision); - if (*buf != 'y') - fatal1("Aborted.\n"); - } - } - else if (verbose) - say2("Good. This file appears to be the %s version.\n", - revision); - } - return TRUE; /* plan a will work */ -} - -/* Keep (virtually) nothing in memory. */ - -void -plan_b(filename) -char *filename; -{ - Reg3 FILE *ifp; - Reg1 int i = 0; - Reg2 int maxlen = 1; - Reg4 bool found_revision = (revision == Nullch); - - using_plan_a = FALSE; - if ((ifp = fopen(filename, "r")) == Nullfp) - fatal2("Can't open file %s\n", filename); - if ((tifd = creat(TMPINNAME, 0666)) < 0) - fatal2("Can't open file %s\n", TMPINNAME); - while (fgets(buf, sizeof buf, ifp) != Nullch) { - if (revision != Nullch && !found_revision && rev_in_string(buf)) - found_revision = TRUE; - if ((i = strlen(buf)) > maxlen) - maxlen = i; /* find longest line */ - } - if (revision != Nullch) { - if (!found_revision) { - if (force) { - if (verbose) - say2("\ -Warning: this file doesn't appear to be the %s version--patching anyway.\n", - revision); - } - else { - ask2("\ -This file doesn't appear to be the %s version--patch anyway? [n] ", - revision); - if (*buf != 'y') - fatal1("Aborted.\n"); - } - } - else if (verbose) - say2("Good. This file appears to be the %s version.\n", - revision); - } - Fseek(ifp, 0L, 0); /* rewind file */ - lines_per_buf = BUFFERSIZE / maxlen; - tireclen = maxlen; - tibuf[0] = malloc((MEM)(BUFFERSIZE + 1)); - tibuf[1] = malloc((MEM)(BUFFERSIZE + 1)); - if (tibuf[1] == Nullch) - fatal1("Can't seem to get enough memory.\n"); - for (i=1; ; i++) { - if (! (i % lines_per_buf)) /* new block */ - if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE) - fatal1("patch: can't write temp file.\n"); - if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp) - == Nullch) { - input_lines = i - 1; - if (i % lines_per_buf) - if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE) - fatal1("patch: can't write temp file.\n"); - break; - } - } - Fclose(ifp); - Close(tifd); - if ((tifd = open(TMPINNAME, 0)) < 0) { - fatal2("Can't reopen file %s\n", TMPINNAME); - } -} - -/* Fetch a line from the input file, \n terminated, not necessarily \0. */ - -char * -ifetch(line,whichbuf) -Reg1 LINENUM line; -int whichbuf; /* ignored when file in memory */ -{ - if (line < 1 || line > input_lines) - return ""; - if (using_plan_a) - return i_ptr[line]; - else { - LINENUM offline = line % lines_per_buf; - LINENUM baseline = line - offline; - - if (tiline[0] == baseline) - whichbuf = 0; - else if (tiline[1] == baseline) - whichbuf = 1; - else { - tiline[whichbuf] = baseline; -#ifndef lint /* complains of long accuracy */ - Lseek(tifd, (off_t)baseline / lines_per_buf * BUFFERSIZE, 0); -#endif - if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0) - fatal2("Error reading tmp file %s.\n", TMPINNAME); - } - return tibuf[whichbuf] + (tireclen*offline); - } -} - -/* True if the string argument contains the revision number we want. */ - -bool -rev_in_string(string) -char *string; -{ - Reg1 char *s; - Reg2 int patlen; - - if (revision == Nullch) - return TRUE; - patlen = strlen(revision); - for (s = string; *s; s++) { - if (isspace(*s) && strnEQ(s+1, revision, patlen) && - isspace(s[patlen+1] )) { - return TRUE; - } - } - return FALSE; -} - diff --git a/usr.bin/patch/inp.h b/usr.bin/patch/inp.h deleted file mode 100644 index c6d2a917d5c4..000000000000 --- a/usr.bin/patch/inp.h +++ /dev/null @@ -1,18 +0,0 @@ -/* $Header: inp.h,v 2.0 86/09/17 15:37:25 lwall Exp $ - * - * $Log: inp.h,v $ - * Revision 2.0 86/09/17 15:37:25 lwall - * Baseline for netwide release. - * - */ - -EXT LINENUM input_lines INIT(0); /* how long is input file in lines */ -EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */ - /* irretractibly output */ - -bool rev_in_string(); -void scan_input(); -bool plan_a(); /* returns false if insufficient memory */ -void plan_b(); -char *ifetch(); - diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 deleted file mode 100644 index 3e4a12e020a8..000000000000 --- a/usr.bin/patch/patch.1 +++ /dev/null @@ -1,446 +0,0 @@ -''' $Header: patch.man,v 2.0 86/09/17 15:39:09 lwall Exp $ -''' -''' $Log: patch.man,v $ -''' Revision 2.0 86/09/17 15:39:09 lwall -''' Baseline for netwide release. -''' -''' Revision 1.4 86/08/01 19:23:22 lwall -''' Documented -v, -p, -F. -''' Added notes to patch senders. -''' -''' Revision 1.3 85/03/26 15:11:06 lwall -''' Frozen. -''' -''' Revision 1.2.1.4 85/03/12 16:14:27 lwall -''' Documented -p. -''' -''' Revision 1.2.1.3 85/03/12 16:09:41 lwall -''' Documented -D. -''' -''' Revision 1.2.1.2 84/12/05 11:06:55 lwall -''' Added -l switch, and noted bistability bug. -''' -''' Revision 1.2.1.1 84/12/04 17:23:39 lwall -''' Branch for sdcrdcf changes. -''' -''' Revision 1.2 84/12/04 17:22:02 lwall -''' Baseline version. -''' -.de Sh -.br -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp -.if t .sp .5v -.if n .sp -.. -''' -''' Set up \*(-- to give an unbreakable dash; -''' string Tr holds user defined translation string. -''' Bell System Logo is used as a dummy character. -''' -.ie n \{\ -.tr \(bs-\*(Tr -.ds -- \(bs- -.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch -.ds L" "" -.ds R" "" -.ds L' ' -.ds R' ' -'br\} -.el\{\ -.ds -- \(em\| -.tr \*(Tr -.ds L" `` -.ds R" '' -.ds L' ` -.ds R' ' -'br\} -.TH PATCH 1 "June 30, 1993" -.SH NAME -patch \- a program for applying a diff file to an original -.SH SYNOPSIS -.B patch -[options] orig patchfile [+ [options] orig] -.sp -but usually just -.sp -.B patch - -sets the maximum fuzz factor. -This switch only applied to context diffs, and causes -.I patch -to ignore up to that many lines in looking for places to install a hunk. -Note that a larger fuzz factor increases the odds of a faulty patch. -The default fuzz factor is 2, and it may not be set to more than -the number of lines of context in the context diff, ordinarily 3. -.TP 5 -.B \-l -causes the pattern matching to be done loosely, in case the tabs and -spaces have been munged in your input file. -Any sequence of whitespace in the pattern line will match any sequence -in the input file. -Normal characters must still match exactly. -Each line of the context must still match a line in the input file. -.TP 5 -.B \-n -forces -.I patch -to interpret the patch file as a normal diff. -.TP 5 -.B \-N -causes -.I patch -to ignore patches that it thinks are reversed or already applied. -See also -.B \-R . -.TP 5 -.B \-o -causes the next argument to be interpreted as the output file name. -.TP 5 -.B \-p -sets the pathname strip count, -which controls how pathnames found in the patch file are treated, in case -the you keep your files in a different directory than the person who sent -out the patch. -The strip count specifies how many backslashes are to be stripped from -the front of the pathname. -(Any intervening directory names also go away.) -For example, supposing the filename in the patch file was -.sp - /u/howard/src/blurfl/blurfl.c -.sp -setting -.B \-p -or -.B \-p0 -gives the entire pathname unmodified, -.B \-p1 -gives -.sp - u/howard/src/blurfl/blurfl.c -.sp -without the leading slash, -.B \-p4 -gives -.sp - blurfl/blurfl.c -.sp -and not specifying -.B \-p -at all just gives you "blurfl.c". -Whatever you end up with is looked for either in the current directory, -or the directory specified by the -.B \-d -switch. -.TP 5 -.B \-r -causes the next argument to be interpreted as the reject file name. -.TP 5 -.B \-R -tells -.I patch -that this patch was created with the old and new files swapped. -(Yes, I'm afraid that does happen occasionally, human nature being what it -is.) -.I Patch -will attempt to swap each hunk around before applying it. -Rejects will come out in the swapped format. -The -.B \-R -switch will not work with ed diff scripts because there is too little -information to reconstruct the reverse operation. -.Sp -If the first hunk of a patch fails, -.I patch -will reverse the hunk to see if it can be applied that way. -If it can, you will be asked if you want to have the -.B \-R -switch set. -If it can't, the patch will continue to be applied normally. -(Note: this method cannot detect a reversed patch if it is a normal diff -and if the first command is an append (i.e. it should have been a delete) -since appends always succeed, due to the fact that a null context will match -anywhere. -Luckily, most patches add or change lines rather than delete them, so most -reversed normal diffs will begin with a delete, which will fail, triggering -the heuristic.) -.TP 5 -.B \-s -makes -.I patch -do its work silently, unless an error occurs. -.TP 5 -.B \-S -causes -.I patch -to ignore this patch from the patch file, but continue on looking -for the next patch in the file. -Thus -.sp - patch -S + -S + -sets internal debugging flags, and is of interest only to -.I patch -patchers. -.SH ENVIRONMENT -No environment variables are used by -.IR patch . -.SH FILES -/tmp/patch* -.SH SEE ALSO -diff(1) -.SH NOTES FOR PATCH SENDERS -There are several things you should bear in mind if you are going to -be sending out patches. -First, you can save people a lot of grief by keeping a patchlevel.h file -which is patched to increment the patch level as the first diff in the -patch file you send out. -If you put a Prereq: line in with the patch, it won't let them apply -patches out of order without some warning. -Second, make sure you've specified the filenames right, either in a -context diff header, or with an Index: line. -If you are patching something in a subdirectory, be sure to tell the patch -user to specify a -.B \-p -switch as needed. -Third, you can create a file by sending out a diff that compares a -null file to the file you want to create. -This will only work if the file you want to create doesn't exist already in -the target directory. -Fourth, take care not to send out reversed patches, since it makes people wonder -whether they already applied the patch. -Fifth, while you may be able to get away with putting 582 diff listings into -one file, it is probably wiser to group related patches into separate files in -case something goes haywire. -.SH DIAGNOSTICS -Too many to list here, but generally indicative that -.I patch -couldn't parse your patch file. -.PP -The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in -the patch file and that -.I patch -is attempting to intuit whether there is a patch in that text and, if so, -what kind of patch it is. -.SH CAVEATS -.I Patch -cannot tell if the line numbers are off in an ed script, and can only detect -bad line numbers in a normal diff when it finds a \*(L"change\*(R" or -a \*(L"delete\*(R" command. -A context diff using fuzz factor 3 may have the same problem. -Until a suitable interactive interface is added, you should probably do -a context diff in these cases to see if the changes made sense. -Of course, compiling without errors is a pretty good indication that the patch -worked, but not always. -.PP -.I Patch -usually produces the correct results, even when it has to do a lot of -guessing. -However, the results are guaranteed to be correct only when the patch is -applied to exactly the same version of the file that the patch was -generated from. -.SH BUGS -Could be smarter about partial matches, excessively \&deviant offsets and -swapped code, but that would take an extra pass. -.PP -If code has been duplicated (for instance with #ifdef OLDCODE ... #else ... -#endif), -.I patch -is incapable of patching both versions, and, if it works at all, will likely -patch the wrong one, and tell you that it succeeded to boot. -.PP -If you apply a patch you've already applied, -.I patch -will think it is a reversed patch, and offer to un-apply the patch. -This could be construed as a feature. diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c deleted file mode 100644 index 0f91c5cd7fd1..000000000000 --- a/usr.bin/patch/patch.c +++ /dev/null @@ -1,800 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)patch.c 8.1 (Berkeley) 6/6/93"; -#endif not lint - -char rcsid[] = - "$Header: patch.c,v 2.0.1.4 87/02/16 14:00:04 lwall Exp $"; - -/* patch - a program to apply diffs to original files - * - * Copyright 1986, Larry Wall - * - * This program may be copied as long as you don't try to make any - * money off of it, or pretend that you wrote it. - * - * $Log: patch.c,v $ - * Revision 2.0.1.4 87/02/16 14:00:04 lwall - * Short replacement caused spurious "Out of sync" message. - * - * Revision 2.0.1.3 87/01/30 22:45:50 lwall - * Improved diagnostic on sync error. - * Moved do_ed_script() to pch.c. - * - * Revision 2.0.1.2 86/11/21 09:39:15 lwall - * Fuzz factor caused offset of installed lines. - * - * Revision 2.0.1.1 86/10/29 13:10:22 lwall - * Backwards search could terminate prematurely. - * - * Revision 2.0 86/09/17 15:37:32 lwall - * Baseline for netwide release. - * - * Revision 1.5 86/08/01 20:53:24 lwall - * Changed some %d's to %ld's. - * Linted. - * - * Revision 1.4 86/08/01 19:17:29 lwall - * Fixes for machines that can't vararg. - * Added fuzz factor. - * Generalized -p. - * General cleanup. - * - * 85/08/15 van%ucbmonet@berkeley - * Changes for 4.3bsd diff -c. - * - * Revision 1.3 85/03/26 15:07:43 lwall - * Frozen. - * - * Revision 1.2.1.9 85/03/12 17:03:35 lwall - * Changed pfp->_file to fileno(pfp). - * - * Revision 1.2.1.8 85/03/12 16:30:43 lwall - * Check i_ptr and i_womp to make sure they aren't null before freeing. - * Also allow ed output to be suppressed. - * - * Revision 1.2.1.7 85/03/12 15:56:13 lwall - * Added -p option from jromine@uci-750a. - * - * Revision 1.2.1.6 85/03/12 12:12:51 lwall - * Now checks for normalness of file to patch. - * - * Revision 1.2.1.5 85/03/12 11:52:12 lwall - * Added -D (#ifdef) option from joe@fluke. - * - * Revision 1.2.1.4 84/12/06 11:14:15 lwall - * Made smarter about SCCS subdirectories. - * - * Revision 1.2.1.3 84/12/05 11:18:43 lwall - * Added -l switch to do loose string comparison. - * - * Revision 1.2.1.2 84/12/04 09:47:13 lwall - * Failed hunk count not reset on multiple patch file. - * - * Revision 1.2.1.1 84/12/04 09:42:37 lwall - * Branch for sdcrdcf changes. - * - * Revision 1.2 84/11/29 13:29:51 lwall - * Linted. Identifiers uniqified. Fixed i_ptr malloc() bug. Fixed - * multiple calls to mktemp(). Will now work on machines that can only - * read 32767 chars. Added -R option for diffs with new and old swapped. - * Various cosmetic changes. - * - * Revision 1.1 84/11/09 17:03:58 lwall - * Initial revision - * - */ - -#include "INTERN.h" -#include "common.h" -#include "EXTERN.h" -#include "version.h" -#include "util.h" -#include "pch.h" -#include "inp.h" - -/* procedures */ - -void reinitialize_almost_everything(); -void get_some_switches(); -LINENUM locate_hunk(); -void abort_hunk(); -void apply_hunk(); -void init_output(); -void init_reject(); -void copy_till(); -void spew_output(); -void dump_line(); -bool patch_match(); -bool similar(); -void re_input(); -void my_exit(); - -/* Apply a set of diffs as appropriate. */ - -main(argc,argv) -int argc; -char **argv; -{ - LINENUM where; - LINENUM newwhere; - LINENUM fuzz; - LINENUM mymaxfuzz; - int hunk = 0; - int failed = 0; - int i; - - setbuf(stderr, serrbuf); - for (i = 0; i= 2) - fatal1("You may not change to a different patch file.\n"); -} - -/* Process switches and filenames up to next '+' or end of list. */ - -void -get_some_switches() -{ - Reg1 char *s; - - rejname[0] = '\0'; - Argc_last = Argc; - Argv_last = Argv; - if (!Argc) - return; - for (Argc--,Argv++; Argc; Argc--,Argv++) { - s = Argv[0]; - if (strEQ(s, "+")) { - return; /* + will be skipped by for loop */ - } - if (*s != '-' || !s[1]) { - if (filec == MAXFILEC) - fatal1("Too many file arguments.\n"); - filearg[filec++] = savestr(s); - } - else { - switch (*++s) { - case 'b': - origext = savestr(Argv[1]); - Argc--,Argv++; - break; - case 'c': - diff_type = CONTEXT_DIFF; - break; - case 'd': - if (!*++s) { - Argc--,Argv++; - s = Argv[0]; - } - if (chdir(s) < 0) - fatal2("Can't cd to %s.\n", s); - break; - case 'D': - do_defines = TRUE; - if (!*++s) { - Argc--,Argv++; - s = Argv[0]; - } - Sprintf(if_defined, "#ifdef %s\n", s); - Sprintf(not_defined, "#ifndef %s\n", s); - Sprintf(end_defined, "#endif /* %s */\n", s); - break; - case 'e': - diff_type = ED_DIFF; - break; - case 'f': - force = TRUE; - break; - case 'F': - if (*++s == '=') - s++; - maxfuzz = atoi(s); - break; - case 'l': - canonicalize = TRUE; - break; - case 'n': - diff_type = NORMAL_DIFF; - break; - case 'N': - noreverse = TRUE; - break; - case 'o': - outname = savestr(Argv[1]); - Argc--,Argv++; - break; - case 'p': - if (*++s == '=') - s++; - strippath = atoi(s); - break; - case 'r': - Strcpy(rejname, Argv[1]); - Argc--,Argv++; - break; - case 'R': - reverse = TRUE; - break; - case 's': - verbose = FALSE; - break; - case 'S': - skip_rest_of_patch = TRUE; - break; - case 'v': - version(); - break; -#ifdef DEBUGGING - case 'x': - debug = atoi(s+1); - break; -#endif - default: - fatal2("Unrecognized switch: %s\n", Argv[0]); - } - } - } -} - -/* Attempt to find the right place to apply this hunk of patch. */ - -LINENUM -locate_hunk(fuzz) -LINENUM fuzz; -{ - Reg1 LINENUM first_guess = pch_first() + last_offset; - Reg2 LINENUM offset; - LINENUM pat_lines = pch_ptrn_lines(); - Reg3 LINENUM max_pos_offset = input_lines - first_guess - - pat_lines + 1; - Reg4 LINENUM max_neg_offset = first_guess - last_frozen_line - 1 - + pch_context(); - - if (!pat_lines) /* null range matches always */ - return first_guess; - if (max_neg_offset >= first_guess) /* do not try lines < 0 */ - max_neg_offset = first_guess - 1; - if (first_guess <= input_lines && patch_match(first_guess, Nulline, fuzz)) - return first_guess; - for (offset = 1; ; offset++) { - Reg5 bool check_after = (offset <= max_pos_offset); - Reg6 bool check_before = (offset <= max_neg_offset); - - if (check_after && patch_match(first_guess, offset, fuzz)) { -#ifdef DEBUGGING - if (debug & 1) - say3("Offset changing from %ld to %ld\n", last_offset, offset); -#endif - last_offset = offset; - return first_guess+offset; - } - else if (check_before && patch_match(first_guess, -offset, fuzz)) { -#ifdef DEBUGGING - if (debug & 1) - say3("Offset changing from %ld to %ld\n", last_offset, -offset); -#endif - last_offset = -offset; - return first_guess-offset; - } - else if (!check_before && !check_after) - return Nulline; - } -} - -/* We did not find the pattern, dump out the hunk so they can handle it. */ - -void -abort_hunk() -{ - Reg1 LINENUM i; - Reg2 LINENUM pat_end = pch_end(); - /* add in last_offset to guess the same as the previous successful hunk */ - LINENUM oldfirst = pch_first() + last_offset; - LINENUM newfirst = pch_newfirst() + last_offset; - LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1; - LINENUM newlast = newfirst + pch_repl_lines() - 1; - char *stars = (diff_type == NEW_CONTEXT_DIFF ? " ****" : ""); - char *minuses = (diff_type == NEW_CONTEXT_DIFF ? " ----" : " -----"); - - fprintf(rejfp, "***************\n"); - for (i=0; i<=pat_end; i++) { - switch (pch_char(i)) { - case '*': - if (oldlast < oldfirst) - fprintf(rejfp, "*** 0%s\n", stars); - else if (oldlast == oldfirst) - fprintf(rejfp, "*** %ld%s\n", oldfirst, stars); - else - fprintf(rejfp, "*** %ld,%ld%s\n", oldfirst, oldlast, stars); - break; - case '=': - if (newlast < newfirst) - fprintf(rejfp, "--- 0%s\n", minuses); - else if (newlast == newfirst) - fprintf(rejfp, "--- %ld%s\n", newfirst, minuses); - else - fprintf(rejfp, "--- %ld,%ld%s\n", newfirst, newlast, minuses); - break; - case '\n': - fprintf(rejfp, "%s", pfetch(i)); - break; - case ' ': case '-': case '+': case '!': - fprintf(rejfp, "%c %s", pch_char(i), pfetch(i)); - break; - default: - say1("Fatal internal error in abort_hunk().\n"); - abort(); - } - } -} - -/* We found where to apply it (we hope), so do it. */ - -void -apply_hunk(where) -LINENUM where; -{ - Reg1 LINENUM old = 1; - Reg2 LINENUM lastline = pch_ptrn_lines(); - Reg3 LINENUM new = lastline+1; -#define OUTSIDE 0 -#define IN_IFNDEF 1 -#define IN_IFDEF 2 -#define IN_ELSE 3 - Reg4 int def_state = OUTSIDE; - Reg5 bool R_do_defines = do_defines; - Reg6 LINENUM pat_end = pch_end(); - - where--; - while (pch_char(new) == '=' || pch_char(new) == '\n') - new++; - - while (old <= lastline) { - if (pch_char(old) == '-') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == OUTSIDE) { - fputs(not_defined, ofp); - def_state = IN_IFNDEF; - } - else if (def_state == IN_IFDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - fputs(pfetch(old), ofp); - } - last_frozen_line++; - old++; - } - else if (new > pat_end) - break; - else if (pch_char(new) == '+') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == IN_IFNDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - else if (def_state == OUTSIDE) { - fputs(if_defined, ofp); - def_state = IN_IFDEF; - } - } - fputs(pfetch(new), ofp); - new++; - } - else { - if (pch_char(new) != pch_char(old)) { - say3("Out-of-sync patch, lines %ld,%ld--mangled text or line numbers, maybe?\n", - pch_hunk_beg() + old, - pch_hunk_beg() + new); -#ifdef DEBUGGING - say3("oldchar = '%c', newchar = '%c'\n", - pch_char(old), pch_char(new)); -#endif - my_exit(1); - } - if (pch_char(new) == '!') { - copy_till(where + old - 1); - if (R_do_defines) { - fputs(not_defined, ofp); - def_state = IN_IFNDEF; - } - while (pch_char(old) == '!') { - if (R_do_defines) { - fputs(pfetch(old), ofp); - } - last_frozen_line++; - old++; - } - if (R_do_defines) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - while (pch_char(new) == '!') { - fputs(pfetch(new), ofp); - new++; - } - if (R_do_defines) { - fputs(end_defined, ofp); - def_state = OUTSIDE; - } - } - else { - assert(pch_char(new) == ' '); - old++; - new++; - } - } - } - if (new <= pat_end && pch_char(new) == '+') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == OUTSIDE) { - fputs(if_defined, ofp); - def_state = IN_IFDEF; - } - else if (def_state == IN_IFNDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - } - while (new <= pat_end && pch_char(new) == '+') { - fputs(pfetch(new), ofp); - new++; - } - } - if (R_do_defines && def_state != OUTSIDE) { - fputs(end_defined, ofp); - } -} - -/* Open the new file. */ - -void -init_output(name) -char *name; -{ - ofp = fopen(name, "w"); - if (ofp == Nullfp) - fatal2("patch: can't create %s.\n", name); -} - -/* Open a file to put hunks we can't locate. */ - -void -init_reject(name) -char *name; -{ - rejfp = fopen(name, "w"); - if (rejfp == Nullfp) - fatal2("patch: can't create %s.\n", name); -} - -/* Copy input file to output, up to wherever hunk is to be applied. */ - -void -copy_till(lastline) -Reg1 LINENUM lastline; -{ - Reg2 LINENUM R_last_frozen_line = last_frozen_line; - - if (R_last_frozen_line > lastline) - say1("patch: misordered hunks! output will be garbled.\n"); - while (R_last_frozen_line < lastline) { - dump_line(++R_last_frozen_line); - } - last_frozen_line = R_last_frozen_line; -} - -/* Finish copying the input file to the output file. */ - -void -spew_output() -{ -#ifdef DEBUGGING - if (debug & 256) - say3("il=%ld lfl=%ld\n",input_lines,last_frozen_line); -#endif - if (input_lines) - copy_till(input_lines); /* dump remainder of file */ - Fclose(ofp); - ofp = Nullfp; -} - -/* Copy one line from input to output. */ - -void -dump_line(line) -LINENUM line; -{ - Reg1 char *s; - Reg2 char R_newline = '\n'; - - /* Note: string is not null terminated. */ - for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ; -} - -/* Does the patch pattern match at line base+offset? */ - -bool -patch_match(base, offset, fuzz) -LINENUM base; -LINENUM offset; -LINENUM fuzz; -{ - Reg1 LINENUM pline = 1 + fuzz; - Reg2 LINENUM iline; - Reg3 LINENUM pat_lines = pch_ptrn_lines() - fuzz; - - for (iline=base+offset+fuzz; pline <= pat_lines; pline++,iline++) { - if (canonicalize) { - if (!similar(ifetch(iline, (offset >= 0)), - pfetch(pline), - pch_line_len(pline) )) - return FALSE; - } - else if (strnNE(ifetch(iline, (offset >= 0)), - pfetch(pline), - pch_line_len(pline) )) - return FALSE; - } - return TRUE; -} - -/* Do two lines match with canonicalized white space? */ - -bool -similar(a,b,len) -Reg1 char *a; -Reg2 char *b; -Reg3 int len; -{ - while (len) { - if (isspace(*b)) { /* whitespace (or \n) to match? */ - if (!isspace(*a)) /* no corresponding whitespace? */ - return FALSE; - while (len && isspace(*b) && *b != '\n') - b++,len--; /* skip pattern whitespace */ - while (isspace(*a) && *a != '\n') - a++; /* skip target whitespace */ - if (*a == '\n' || *b == '\n') - return (*a == *b); /* should end in sync */ - } - else if (*a++ != *b++) /* match non-whitespace chars */ - return FALSE; - else - len--; /* probably not necessary */ - } - return TRUE; /* actually, this is not reached */ - /* since there is always a \n */ -} - -/* Exit with cleanup. */ - -void -my_exit(status) -int status; -{ - Unlink(TMPINNAME); - if (!toutkeep) { - Unlink(TMPOUTNAME); - } - if (!trejkeep) { - Unlink(TMPREJNAME); - } - Unlink(TMPPATNAME); - exit(status); -} diff --git a/usr.bin/patch/patchlevel.h b/usr.bin/patch/patchlevel.h deleted file mode 100644 index 618bca4808ad..000000000000 --- a/usr.bin/patch/patchlevel.h +++ /dev/null @@ -1 +0,0 @@ -#define PATCHLEVEL 9 diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c deleted file mode 100644 index 88372123353a..000000000000 --- a/usr.bin/patch/pch.c +++ /dev/null @@ -1,1108 +0,0 @@ -/* $Header: pch.c,v 2.0.1.6 87/06/04 16:18:13 lwall Exp $ - * - * $Log: pch.c,v $ - * Revision 2.0.1.6 87/06/04 16:18:13 lwall - * pch_swap didn't swap p_bfake and p_efake. - * - * Revision 2.0.1.5 87/01/30 22:47:42 lwall - * Improved responses to mangled patches. - * - * Revision 2.0.1.4 87/01/05 16:59:53 lwall - * New-style context diffs caused double call to free(). - * - * Revision 2.0.1.3 86/11/14 10:08:33 lwall - * Fixed problem where a long pattern wouldn't grow the hunk. - * Also restored p_input_line when backtracking so error messages are right. - * - * Revision 2.0.1.2 86/11/03 17:49:52 lwall - * New-style delete triggers spurious assertion error. - * - * Revision 2.0.1.1 86/10/29 15:52:08 lwall - * Could falsely report new-style context diff. - * - * Revision 2.0 86/09/17 15:39:37 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "INTERN.h" -#include "pch.h" - -/* Patch (diff listing) abstract type. */ - -static long p_filesize; /* size of the patch file */ -static LINENUM p_first; /* 1st line number */ -static LINENUM p_newfirst; /* 1st line number of replacement */ -static LINENUM p_ptrn_lines; /* # lines in pattern */ -static LINENUM p_repl_lines; /* # lines in replacement text */ -static LINENUM p_end = -1; /* last line in hunk */ -static LINENUM p_max; /* max allowed value of p_end */ -static LINENUM p_context = 3; /* # of context lines */ -static LINENUM p_input_line = 0; /* current line # from patch file */ -static char **p_line = Null(char**); /* the text of the hunk */ -static short *p_len = Null(short*); /* length of each line */ -static char *p_char = Nullch; /* +, -, and ! */ -static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ -static int p_indent; /* indent to patch */ -static LINENUM p_base; /* where to intuit this time */ -static LINENUM p_bline; /* line # of p_base */ -static LINENUM p_start; /* where intuit found a patch */ -static LINENUM p_sline; /* and the line number for it */ -static LINENUM p_hunk_beg; /* line number of current hunk */ -static LINENUM p_efake = -1; /* end of faked up lines--don't free */ -static LINENUM p_bfake = -1; /* beg of faked up lines */ - -/* Prepare to look for the next patch in the patch file. */ - -void -re_patch() -{ - p_first = Nulline; - p_newfirst = Nulline; - p_ptrn_lines = Nulline; - p_repl_lines = Nulline; - p_end = (LINENUM)-1; - p_max = Nulline; - p_indent = 0; -} - -/* Open the patch file at the beginning of time. */ - -void -open_patch_file(filename) -char *filename; -{ - if (filename == Nullch || !*filename || strEQ(filename, "-")) { - pfp = fopen(TMPPATNAME, "w"); - if (pfp == Nullfp) - fatal2("patch: can't create %s.\n", TMPPATNAME); - while (fgets(buf, sizeof buf, stdin) != Nullch) - fputs(buf, pfp); - Fclose(pfp); - filename = TMPPATNAME; - } - pfp = fopen(filename, "r"); - if (pfp == Nullfp) - fatal2("patch file %s not found\n", filename); - Fstat(fileno(pfp), &filestat); - p_filesize = filestat.st_size; - next_intuit_at(0L,1L); /* start at the beginning */ - set_hunkmax(); -} - -/* Make sure our dynamically realloced tables are malloced to begin with. */ - -void -set_hunkmax() -{ -#ifndef lint - if (p_line == Null(char**)) - p_line = (char**) malloc((MEM)hunkmax * sizeof(char *)); - if (p_len == Null(short*)) - p_len = (short*) malloc((MEM)hunkmax * sizeof(short)); -#endif - if (p_char == Nullch) - p_char = (char*) malloc((MEM)hunkmax * sizeof(char)); -} - -/* Enlarge the arrays containing the current hunk of patch. */ - -void -grow_hunkmax() -{ - hunkmax *= 2; - /* - * Note that on most systems, only the p_line array ever gets fresh memory - * since p_len can move into p_line's old space, and p_char can move into - * p_len's old space. Not on PDP-11's however. But it doesn't matter. - */ - assert(p_line != Null(char**) && p_len != Null(short*) && p_char != Nullch); -#ifndef lint - p_line = (char**) realloc((char*)p_line, (MEM)hunkmax * sizeof(char *)); - p_len = (short*) realloc((char*)p_len, (MEM)hunkmax * sizeof(short)); - p_char = (char*) realloc((char*)p_char, (MEM)hunkmax * sizeof(char)); -#endif - if (p_line != Null(char**) && p_len != Null(short*) && p_char != Nullch) - return; - if (!using_plan_a) - fatal1("patch: out of memory (grow_hunkmax)\n"); - out_of_mem = TRUE; /* whatever is null will be allocated again */ - /* from within plan_a(), of all places */ -} - -/* True if the remainder of the patch file contains a diff of some sort. */ - -bool -there_is_another_patch() -{ - if (p_base != 0L && p_base >= p_filesize) { - if (verbose) - say1("done\n"); - return FALSE; - } - if (verbose) - say1("Hmm..."); - diff_type = intuit_diff_type(); - if (!diff_type) { - if (p_base != 0L) { - if (verbose) - say1(" Ignoring the trailing garbage.\ndone\n"); - } - else - say1(" I can't seem to find a patch in there anywhere.\n"); - return FALSE; - } - if (verbose) - say3(" %sooks like %s to me...\n", - (p_base == 0L ? "L" : "The next patch l"), - diff_type == CONTEXT_DIFF ? "a context diff" : - diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" : - diff_type == NORMAL_DIFF ? "a normal diff" : - "an ed script" ); - if (p_indent && verbose) - say3("(Patch is indented %d space%s.)\n", p_indent, p_indent==1?"":"s"); - skip_to(p_start,p_sline); - while (filearg[0] == Nullch) { - if (force) { - say1("No file to patch. Skipping...\n"); - filearg[0] = savestr(bestguess); - return TRUE; - } - ask1("File to patch: "); - if (*buf != '\n') { - if (bestguess) - free(bestguess); - bestguess = savestr(buf); - filearg[0] = fetchname(buf, 0, FALSE); - } - if (filearg[0] == Nullch) { - ask1("No file found--skip this patch? [n] "); - if (*buf != 'y') { - continue; - } - if (verbose) - say1("Skipping patch...\n"); - filearg[0] = fetchname(bestguess, 0, TRUE); - skip_rest_of_patch = TRUE; - return TRUE; - } - } - return TRUE; -} - -/* Determine what kind of diff is in the remaining part of the patch file. */ - -int -intuit_diff_type() -{ - Reg4 long this_line = 0; - Reg5 long previous_line; - Reg6 long first_command_line = -1; - long fcl_line; - Reg7 bool last_line_was_command = FALSE; - Reg8 bool this_is_a_command = FALSE; - Reg9 bool stars_last_line = FALSE; - Reg10 bool stars_this_line = FALSE; - Reg3 int indent; - Reg1 char *s; - Reg2 char *t; - char *indtmp = Nullch; - char *oldtmp = Nullch; - char *newtmp = Nullch; - char *indname = Nullch; - char *oldname = Nullch; - char *newname = Nullch; - Reg11 int retval; - bool no_filearg = (filearg[0] == Nullch); - - ok_to_create_file = FALSE; - Fseek(pfp, p_base, 0); - p_input_line = p_bline - 1; - for (;;) { - previous_line = this_line; - last_line_was_command = this_is_a_command; - stars_last_line = stars_this_line; - this_line = ftell(pfp); - indent = 0; - p_input_line++; - if (fgets(buf, sizeof buf, pfp) == Nullch) { - if (first_command_line >= 0L) { - /* nothing but deletes!? */ - p_start = first_command_line; - p_sline = fcl_line; - retval = ED_DIFF; - goto scan_exit; - } - else { - p_start = this_line; - p_sline = p_input_line; - retval = 0; - goto scan_exit; - } - } - for (s = buf; *s == ' ' || *s == '\t'; s++) { - if (*s == '\t') - indent += 8 - (indent % 8); - else - indent++; - } - for (t=s; isdigit(*t) || *t == ','; t++) ; - this_is_a_command = (isdigit(*s) && - (*t == 'd' || *t == 'c' || *t == 'a') ); - if (first_command_line < 0L && this_is_a_command) { - first_command_line = this_line; - fcl_line = p_input_line; - p_indent = indent; /* assume this for now */ - } - if (!stars_last_line && strnEQ(s, "*** ", 4)) - oldtmp = savestr(s+4); - else if (strnEQ(s, "--- ", 4)) - newtmp = savestr(s+4); - else if (strnEQ(s, "Index:", 6)) - indtmp = savestr(s+6); - else if (strnEQ(s, "Prereq:", 7)) { - for (t=s+7; isspace(*t); t++) ; - revision = savestr(t); - for (t=revision; *t && !isspace(*t); t++) ; - *t = '\0'; - if (!*revision) { - free(revision); - revision = Nullch; - } - } - if ((!diff_type || diff_type == ED_DIFF) && - first_command_line >= 0L && - strEQ(s, ".\n") ) { - p_indent = indent; - p_start = first_command_line; - p_sline = fcl_line; - retval = ED_DIFF; - goto scan_exit; - } - stars_this_line = strnEQ(s, "********", 8); - if ((!diff_type || diff_type == CONTEXT_DIFF) && stars_last_line && - strnEQ(s, "*** ", 4)) { - if (!atol(s+4)) - ok_to_create_file = TRUE; - /* if this is a new context diff the character just before */ - /* the newline is a '*'. */ - while (*s != '\n') - s++; - p_indent = indent; - p_start = previous_line; - p_sline = p_input_line - 1; - retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF); - goto scan_exit; - } - if ((!diff_type || diff_type == NORMAL_DIFF) && - last_line_was_command && - (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) { - p_start = previous_line; - p_sline = p_input_line - 1; - p_indent = indent; - retval = NORMAL_DIFF; - goto scan_exit; - } - } - scan_exit: - if (no_filearg) { - if (indtmp != Nullch) - indname = fetchname(indtmp, strippath, ok_to_create_file); - if (oldtmp != Nullch) - oldname = fetchname(oldtmp, strippath, ok_to_create_file); - if (newtmp != Nullch) - newname = fetchname(newtmp, strippath, ok_to_create_file); - if (oldname && newname) { - if (strlen(oldname) < strlen(newname)) - filearg[0] = savestr(oldname); - else - filearg[0] = savestr(newname); - } - else if (oldname) - filearg[0] = savestr(oldname); - else if (newname) - filearg[0] = savestr(newname); - else if (indname) - filearg[0] = savestr(indname); - } - if (bestguess) { - free(bestguess); - bestguess = Nullch; - } - if (filearg[0] != Nullch) - bestguess = savestr(filearg[0]); - else if (indtmp != Nullch) - bestguess = fetchname(indtmp, strippath, TRUE); - else { - if (oldtmp != Nullch) - oldname = fetchname(oldtmp, strippath, TRUE); - if (newtmp != Nullch) - newname = fetchname(newtmp, strippath, TRUE); - if (oldname && newname) { - if (strlen(oldname) < strlen(newname)) - bestguess = savestr(oldname); - else - bestguess = savestr(newname); - } - else if (oldname) - bestguess = savestr(oldname); - else if (newname) - bestguess = savestr(newname); - } - if (indtmp != Nullch) - free(indtmp); - if (oldtmp != Nullch) - free(oldtmp); - if (newtmp != Nullch) - free(newtmp); - if (indname != Nullch) - free(indname); - if (oldname != Nullch) - free(oldname); - if (newname != Nullch) - free(newname); - return retval; -} - -/* Remember where this patch ends so we know where to start up again. */ - -void -next_intuit_at(file_pos,file_line) -long file_pos; -long file_line; -{ - p_base = file_pos; - p_bline = file_line; -} - -/* Basically a verbose fseek() to the actual diff listing. */ - -void -skip_to(file_pos,file_line) -long file_pos; -long file_line; -{ - char *ret; - - assert(p_base <= file_pos); - if (verbose && p_base < file_pos) { - Fseek(pfp, p_base, 0); - say1("The text leading up to this was:\n--------------------------\n"); - while (ftell(pfp) < file_pos) { - ret = fgets(buf, sizeof buf, pfp); - assert(ret != Nullch); - say2("|%s", buf); - } - say1("--------------------------\n"); - } - else - Fseek(pfp, file_pos, 0); - p_input_line = file_line - 1; -} - -/* True if there is more of the current diff listing to process. */ - -bool -another_hunk() -{ - Reg1 char *s; - Reg8 char *ret; - Reg2 int context = 0; - - while (p_end >= 0) { - if (p_end == p_efake) - p_end = p_bfake; /* don't free twice */ - else - free(p_line[p_end]); - p_end--; - } - assert(p_end == -1); - p_efake = -1; - - p_max = hunkmax; /* gets reduced when --- found */ - if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) { - long line_beginning = ftell(pfp); - /* file pos of the current line */ - LINENUM repl_beginning = 0; /* index of --- line */ - Reg4 LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */ - Reg5 LINENUM fillsrc; /* index of first line to copy */ - Reg6 LINENUM filldst; /* index of first missing line */ - bool ptrn_spaces_eaten = FALSE; /* ptrn was slightly misformed */ - Reg9 bool repl_could_be_missing = TRUE; - /* no + or ! lines in this hunk */ - bool repl_missing = FALSE; /* we are now backtracking */ - long repl_backtrack_position = 0; - /* file pos of first repl line */ - LINENUM repl_patch_line; /* input line number for same */ - Reg7 LINENUM ptrn_copiable = 0; - /* # of copiable lines in ptrn */ - - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch || strnNE(buf, "********", 8)) { - next_intuit_at(line_beginning,p_input_line); - return FALSE; - } - p_context = 100; - p_hunk_beg = p_input_line + 1; - while (p_end < p_max) { - line_beginning = ftell(pfp); - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) { - if (p_max - p_end < 4) - Strcpy(buf, " \n"); /* assume blank lines got chopped */ - else { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - fatal1("Unexpected end of file in patch.\n"); - } - } - p_end++; - assert(p_end < hunkmax); - p_char[p_end] = *buf; - p_line[p_end] = Nullch; - switch (*buf) { - case '*': - if (strnEQ(buf, "********", 8)) { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - else - fatal2("Unexpected end of hunk at line %ld.\n", - p_input_line); - } - if (p_end != 0) { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - fatal3("Unexpected *** at line %ld: %s", p_input_line, buf); - } - context = 0; - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - for (s=buf; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_first = (LINENUM) atol(s); - while (isdigit(*s)) s++; - if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_ptrn_lines = ((LINENUM)atol(s)) - p_first + 1; - } - else if (p_first) - p_ptrn_lines = 1; - else { - p_ptrn_lines = 0; - p_first = 1; - } - p_max = p_ptrn_lines + 6; /* we need this much at least */ - while (p_max >= hunkmax) - grow_hunkmax(); - p_max = hunkmax; - break; - case '-': - if (buf[1] == '-') { - if (repl_beginning || - (p_end != p_ptrn_lines + 1 + (p_char[p_end-1] == '\n'))) - { - if (p_end == 1) { - /* `old' lines were omitted - set up to fill */ - /* them in from 'new' context lines. */ - p_end = p_ptrn_lines + 1; - fillsrc = p_end + 1; - filldst = 1; - fillcnt = p_ptrn_lines; - } - else { - if (repl_beginning) { - if (repl_could_be_missing){ - repl_missing = TRUE; - goto hunk_done; - } - fatal3( -"Duplicate \"---\" at line %ld--check line numbers at line %ld.\n", - p_input_line, p_hunk_beg + repl_beginning); - } - else { - fatal4( -"%s \"---\" at line %ld--check line numbers at line %ld.\n", - (p_end <= p_ptrn_lines - ? "Premature" - : "Overdue" ), - p_input_line, p_hunk_beg); - } - } - } - repl_beginning = p_end; - repl_backtrack_position = ftell(pfp); - repl_patch_line = p_input_line; - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - p_char[p_end] = '='; - for (s=buf; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_newfirst = (LINENUM) atol(s); - while (isdigit(*s)) s++; - if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_repl_lines = ((LINENUM)atol(s)) - p_newfirst + 1; - } - else if (p_newfirst) - p_repl_lines = 1; - else { - p_repl_lines = 0; - p_newfirst = 1; - } - p_max = p_repl_lines + p_end; - if (p_max > MAXHUNKSIZE) - fatal4("Hunk too large (%ld lines) at line %ld: %s", - p_max, p_input_line, buf); - while (p_max >= hunkmax) - grow_hunkmax(); - if (p_repl_lines != ptrn_copiable) - repl_could_be_missing = FALSE; - break; - } - goto change_line; - case '+': case '!': - repl_could_be_missing = FALSE; - change_line: - if (!isspace(buf[1]) && buf[1] != '>' && buf[1] != '<' && - repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - if (context > 0) { - if (context < p_context) - p_context = context; - context = -1000; - } - p_line[p_end] = savestr(buf+2); - if (out_of_mem) { - p_end--; - return FALSE; - } - break; - case '\t': case '\n': /* assume the 2 spaces got eaten */ - if (repl_beginning && repl_could_be_missing && - (!ptrn_spaces_eaten || diff_type == NEW_CONTEXT_DIFF) ) { - repl_missing = TRUE; - goto hunk_done; - } - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - if (p_end != p_ptrn_lines + 1) { - ptrn_spaces_eaten |= (repl_beginning != 0); - context++; - if (!repl_beginning) - ptrn_copiable++; - p_char[p_end] = ' '; - } - break; - case ' ': - if (!isspace(buf[1]) && - repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - context++; - if (!repl_beginning) - ptrn_copiable++; - p_line[p_end] = savestr(buf+2); - if (out_of_mem) { - p_end--; - return FALSE; - } - break; - default: - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - goto malformed; - } - /* set up p_len for strncmp() so we don't have to */ - /* assume null termination */ - if (p_line[p_end]) - p_len[p_end] = strlen(p_line[p_end]); - else - p_len[p_end] = 0; - } - - hunk_done: - if (p_end >=0 && !repl_beginning) - fatal2("No --- found in patch at line %ld\n", pch_hunk_beg()); - - if (repl_missing) { - - /* reset state back to just after --- */ - p_input_line = repl_patch_line; - for (p_end--; p_end > repl_beginning; p_end--) - free(p_line[p_end]); - Fseek(pfp, repl_backtrack_position, 0); - - /* redundant 'new' context lines were omitted - set */ - /* up to fill them in from the old file context */ - fillsrc = 1; - filldst = repl_beginning+1; - fillcnt = p_repl_lines; - p_end = p_max; - } - - if (diff_type == CONTEXT_DIFF && - (fillcnt || (p_first > 1 && ptrn_copiable > 2*p_context)) ) { - if (verbose) - say1("\ -(Fascinating--this is really a new-style context diff but without the telltale\n\ -extra asterisks on the *** line that usually indicate the new style...)\n"); - diff_type = NEW_CONTEXT_DIFF; - } - - /* if there were omitted context lines, fill them in now */ - if (fillcnt) { - p_bfake = filldst; /* remember where not to free() */ - p_efake = filldst + fillcnt - 1; - while (fillcnt-- > 0) { - while (fillsrc <= p_end && p_char[fillsrc] != ' ') - fillsrc++; - if (fillsrc > p_end) - fatal2("Replacement text or line numbers mangled in hunk at line %ld\n", - p_hunk_beg); - p_line[filldst] = p_line[fillsrc]; - p_char[filldst] = p_char[fillsrc]; - p_len[filldst] = p_len[fillsrc]; - fillsrc++; filldst++; - } - while (fillsrc <= p_end && fillsrc != repl_beginning && - p_char[fillsrc] != ' ') - fillsrc++; -#ifdef DEBUGGING - if (debug & 64) - printf("fillsrc %ld, filldst %ld, rb %ld, e+1 %ld\n", - fillsrc,filldst,repl_beginning,p_end+1); -#endif - assert(fillsrc==p_end+1 || fillsrc==repl_beginning); - assert(filldst==p_end+1 || filldst==repl_beginning); - } - } - else { /* normal diff--fake it up */ - char hunk_type; - Reg3 int i; - LINENUM min, max; - long line_beginning = ftell(pfp); - - p_context = 0; - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch || !isdigit(*buf)) { - next_intuit_at(line_beginning,p_input_line); - return FALSE; - } - p_first = (LINENUM)atol(buf); - for (s=buf; isdigit(*s); s++) ; - if (*s == ',') { - p_ptrn_lines = (LINENUM)atol(++s) - p_first + 1; - while (isdigit(*s)) s++; - } - else - p_ptrn_lines = (*s != 'a'); - hunk_type = *s; - if (hunk_type == 'a') - p_first++; /* do append rather than insert */ - min = (LINENUM)atol(++s); - for (; isdigit(*s); s++) ; - if (*s == ',') - max = (LINENUM)atol(++s); - else - max = min; - if (hunk_type == 'd') - min++; - p_end = p_ptrn_lines + 1 + max - min + 1; - if (p_end > MAXHUNKSIZE) - fatal4("Hunk too large (%ld lines) at line %ld: %s", - p_end, p_input_line, buf); - while (p_end >= hunkmax) - grow_hunkmax(); - p_newfirst = min; - p_repl_lines = max - min + 1; - Sprintf(buf, "*** %ld,%ld\n", p_first, p_first + p_ptrn_lines - 1); - p_line[0] = savestr(buf); - if (out_of_mem) { - p_end = -1; - return FALSE; - } - p_char[0] = '*'; - for (i=1; i<=p_ptrn_lines; i++) { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '<') - fatal2("< expected at line %ld of patch.\n", p_input_line); - p_line[i] = savestr(buf+2); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_len[i] = strlen(p_line[i]); - p_char[i] = '-'; - } - if (hunk_type == 'c') { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '-') - fatal2("--- expected at line %ld of patch.\n", p_input_line); - } - Sprintf(buf, "--- %ld,%ld\n", min, max); - p_line[i] = savestr(buf); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_char[i] = '='; - for (i++; i<=p_end; i++) { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '>') - fatal2("> expected at line %ld of patch.\n", p_input_line); - p_line[i] = savestr(buf+2); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_len[i] = strlen(p_line[i]); - p_char[i] = '+'; - } - } - if (reverse) /* backwards patch? */ - if (!pch_swap()) - say1("Not enough memory to swap next hunk!\n"); -#ifdef DEBUGGING - if (debug & 2) { - int i; - char special; - - for (i=0; i <= p_end; i++) { - if (i == p_ptrn_lines) - special = '^'; - else - special = ' '; - fprintf(stderr, "%3d %c %c %s", i, p_char[i], special, p_line[i]); - Fflush(stderr); - } - } -#endif - if (p_end+1 < hunkmax) /* paranoia reigns supreme... */ - p_char[p_end+1] = '^'; /* add a stopper for apply_hunk */ - return TRUE; - -malformed: - fatal3("Malformed patch at line %ld: %s", p_input_line, buf); - /* about as informative as "Syntax error" in C */ - return FALSE; /* for lint */ -} - -/* Input a line from the patch file, worrying about indentation. */ - -char * -pgets(bf,sz,fp) -char *bf; -int sz; -FILE *fp; -{ - char *ret = fgets(bf, sz, fp); - Reg1 char *s; - Reg2 int indent = 0; - - if (p_indent && ret != Nullch) { - for (s=buf; indent < p_indent && (*s == ' ' || *s == '\t'); s++) { - if (*s == '\t') - indent += 8 - (indent % 7); - else - indent++; - } - if (buf != s) - Strcpy(buf, s); - } - return ret; -} - -/* Reverse the old and new portions of the current hunk. */ - -bool -pch_swap() -{ - char **tp_line; /* the text of the hunk */ - short *tp_len; /* length of each line */ - char *tp_char; /* +, -, and ! */ - Reg1 LINENUM i; - Reg2 LINENUM n; - bool blankline = FALSE; - Reg3 char *s; - - i = p_first; - p_first = p_newfirst; - p_newfirst = i; - - /* make a scratch copy */ - - tp_line = p_line; - tp_len = p_len; - tp_char = p_char; - p_line = Null(char**); /* force set_hunkmax to allocate again */ - p_len = Null(short*); - p_char = Nullch; - set_hunkmax(); - if (p_line == Null(char**) || p_len == Null(short*) || p_char == Nullch) { -#ifndef lint - if (p_line == Null(char**)) - free((char*)p_line); - p_line = tp_line; - if (p_len == Null(short*)) - free((char*)p_len); - p_len = tp_len; -#endif - if (p_char == Nullch) - free((char*)p_char); - p_char = tp_char; - return FALSE; /* not enough memory to swap hunk! */ - } - - /* now turn the new into the old */ - - i = p_ptrn_lines + 1; - if (tp_char[i] == '\n') { /* account for possible blank line */ - blankline = TRUE; - i++; - } - if (p_efake >= 0) { /* fix non-freeable ptr range */ - n = p_end - i + 1; - if (p_efake > i) - n = -n; - p_efake += n; - p_bfake += n; - } - for (n=0; i <= p_end; i++,n++) { - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - if (p_char[n] == '+') - p_char[n] = '-'; - p_len[n] = tp_len[i]; - } - if (blankline) { - i = p_ptrn_lines + 1; - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - p_len[n] = tp_len[i]; - n++; - } - assert(p_char[0] == '='); - p_char[0] = '*'; - for (s=p_line[0]; *s; s++) - if (*s == '-') - *s = '*'; - - /* now turn the old into the new */ - - assert(tp_char[0] == '*'); - tp_char[0] = '='; - for (s=tp_line[0]; *s; s++) - if (*s == '*') - *s = '-'; - for (i=0; n <= p_end; i++,n++) { - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - if (p_char[n] == '-') - p_char[n] = '+'; - p_len[n] = tp_len[i]; - } - assert(i == p_ptrn_lines + 1); - i = p_ptrn_lines; - p_ptrn_lines = p_repl_lines; - p_repl_lines = i; -#ifndef lint - if (tp_line == Null(char**)) - free((char*)tp_line); - if (tp_len == Null(short*)) - free((char*)tp_len); -#endif - if (tp_char == Nullch) - free((char*)tp_char); - return TRUE; -} - -/* Return the specified line position in the old file of the old context. */ - -LINENUM -pch_first() -{ - return p_first; -} - -/* Return the number of lines of old context. */ - -LINENUM -pch_ptrn_lines() -{ - return p_ptrn_lines; -} - -/* Return the probable line position in the new file of the first line. */ - -LINENUM -pch_newfirst() -{ - return p_newfirst; -} - -/* Return the number of lines in the replacement text including context. */ - -LINENUM -pch_repl_lines() -{ - return p_repl_lines; -} - -/* Return the number of lines in the whole hunk. */ - -LINENUM -pch_end() -{ - return p_end; -} - -/* Return the number of context lines before the first changed line. */ - -LINENUM -pch_context() -{ - return p_context; -} - -/* Return the length of a particular patch line. */ - -short -pch_line_len(line) -LINENUM line; -{ - return p_len[line]; -} - -/* Return the control character (+, -, *, !, etc) for a patch line. */ - -char -pch_char(line) -LINENUM line; -{ - return p_char[line]; -} - -/* Return a pointer to a particular patch line. */ - -char * -pfetch(line) -LINENUM line; -{ - return p_line[line]; -} - -/* Return where in the patch file this hunk began, for error messages. */ - -LINENUM -pch_hunk_beg() -{ - return p_hunk_beg; -} - -/* Apply an ed script by feeding ed itself. */ - -void -do_ed_script() -{ - Reg1 char *t; - Reg2 long beginning_of_this_line; - Reg3 bool this_line_is_command = FALSE; - Reg4 FILE *pipefp; - FILE *popen(); - - if (!skip_rest_of_patch) { - Unlink(TMPOUTNAME); - copy_file(filearg[0], TMPOUTNAME); - if (verbose) - Sprintf(buf, "/bin/ed %s", TMPOUTNAME); - else - Sprintf(buf, "/bin/ed - %s", TMPOUTNAME); - pipefp = popen(buf, "w"); - } - for (;;) { - beginning_of_this_line = ftell(pfp); - if (pgets(buf, sizeof buf, pfp) == Nullch) { - next_intuit_at(beginning_of_this_line,p_input_line); - break; - } - p_input_line++; - for (t=buf; isdigit(*t) || *t == ','; t++) ; - this_line_is_command = (isdigit(*buf) && - (*t == 'd' || *t == 'c' || *t == 'a') ); - if (this_line_is_command) { - if (!skip_rest_of_patch) - fputs(buf, pipefp); - if (*t != 'd') { - while (pgets(buf, sizeof buf, pfp) != Nullch) { - p_input_line++; - if (!skip_rest_of_patch) - fputs(buf, pipefp); - if (strEQ(buf, ".\n")) - break; - } - } - } - else { - next_intuit_at(beginning_of_this_line,p_input_line); - break; - } - } - if (skip_rest_of_patch) - return; - fprintf(pipefp, "w\n"); - fprintf(pipefp, "q\n"); - Fflush(pipefp); - Pclose(pipefp); - ignore_signals(); - if (move_file(TMPOUTNAME, outname) < 0) { - toutkeep = TRUE; - chmod(TMPOUTNAME, filemode); - } - else - chmod(outname, filemode); - set_signals(); -} diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h deleted file mode 100644 index 97a5b28a338f..000000000000 --- a/usr.bin/patch/pch.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $Header: pch.h,v 2.0.1.1 87/01/30 22:47:16 lwall Exp $ - * - * $Log: pch.h,v $ - * Revision 2.0.1.1 87/01/30 22:47:16 lwall - * Added do_ed_script(). - * - * Revision 2.0 86/09/17 15:39:57 lwall - * Baseline for netwide release. - * - */ - -EXT FILE *pfp INIT(Nullfp); /* patch file pointer */ - -void re_patch(); -void open_patch_file(); -void set_hunkmax(); -void grow_hunkmax(); -bool there_is_another_patch(); -int intuit_diff_type(); -void next_intuit_at(); -void skip_to(); -bool another_hunk(); -bool pch_swap(); -char *pfetch(); -short pch_line_len(); -LINENUM pch_first(); -LINENUM pch_ptrn_lines(); -LINENUM pch_newfirst(); -LINENUM pch_repl_lines(); -LINENUM pch_end(); -LINENUM pch_context(); -LINENUM pch_hunk_beg(); -char pch_char(); -char *pfetch(); -char *pgets(); -void do_ed_script(); diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c deleted file mode 100644 index 5582d1883379..000000000000 --- a/usr.bin/patch/util.c +++ /dev/null @@ -1,339 +0,0 @@ -#include "EXTERN.h" -#include "common.h" -#include "INTERN.h" -#include "util.h" - -/* Rename a file, copying it if necessary. */ - -int -move_file(from,to) -char *from, *to; -{ - char bakname[512]; - Reg1 char *s; - Reg2 int i; - Reg3 int fromfd; - - /* to stdout? */ - - if (strEQ(to, "-")) { -#ifdef DEBUGGING - if (debug & 4) - say2("Moving %s to stdout.\n", from); -#endif - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(1, buf, i) != 1) - fatal1("patch: write failed\n"); - Close(fromfd); - return 0; - } - - Strcpy(bakname, to); - Strcat(bakname, origext?origext:ORIGEXT); - if (stat(to, &filestat) >= 0) { /* output file exists */ - dev_t to_device = filestat.st_dev; - ino_t to_inode = filestat.st_ino; - char *simplename = bakname; - - for (s=bakname; *s; s++) { - if (*s == '/') - simplename = s+1; - } - /* find a backup name that is not the same file */ - while (stat(bakname, &filestat) >= 0 && - to_device == filestat.st_dev && to_inode == filestat.st_ino) { - for (s=simplename; *s && !islower(*s); s++) ; - if (*s) - *s = toupper(*s); - else - Strcpy(simplename, simplename+1); - } - while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */ -#ifdef DEBUGGING - if (debug & 4) - say3("Moving %s to %s.\n", to, bakname); -#endif - if (link(to, bakname) < 0) { - say3("patch: can't backup %s, output is in %s\n", - to, from); - return -1; - } - while (unlink(to) >= 0) ; - } -#ifdef DEBUGGING - if (debug & 4) - say3("Moving %s to %s.\n", from, to); -#endif - if (link(from, to) < 0) { /* different file system? */ - Reg4 int tofd; - - tofd = creat(to, 0666); - if (tofd < 0) { - say3("patch: can't create %s, output is in %s.\n", - to, from); - return -1; - } - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(tofd, buf, i) != i) - fatal1("patch: write failed\n"); - Close(fromfd); - Close(tofd); - } - Unlink(from); - return 0; -} - -/* Copy a file. */ - -void -copy_file(from,to) -char *from, *to; -{ - Reg3 int tofd; - Reg2 int fromfd; - Reg1 int i; - - tofd = creat(to, 0666); - if (tofd < 0) - fatal2("patch: can't create %s.\n", to); - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(tofd, buf, i) != i) - fatal2("patch: write (%s) failed\n", to); - Close(fromfd); - Close(tofd); -} - -/* Allocate a unique area for a string. */ - -char * -savestr(s) -Reg1 char *s; -{ - Reg3 char *rv; - Reg2 char *t; - - if (!s) - s = "Oops"; - t = s; - while (*t++); - rv = malloc((MEM) (t - s)); - if (rv == Nullch) { - if (using_plan_a) - out_of_mem = TRUE; - else - fatal1("patch: out of memory (savestr)\n"); - } - else { - t = rv; - while (*t++ = *s++); - } - return rv; -} - -#if defined(lint) && defined(CANVARARG) - -/*VARARGS ARGSUSED*/ -say(pat) char *pat; { ; } -/*VARARGS ARGSUSED*/ -fatal(pat) char *pat; { ; } -/*VARARGS ARGSUSED*/ -ask(pat) char *pat; { ; } - -#else - -/* Vanilla terminal output (buffered). */ - -void -say(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - fprintf(stderr, pat, arg1, arg2, arg3); - Fflush(stderr); -} - -/* Terminal output, pun intended. */ - -void /* very void */ -fatal(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - void my_exit(); - - say(pat, arg1, arg2, arg3); - my_exit(1); -} - -/* Get a response from the user, somehow or other. */ - -void -ask(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - int ttyfd; - int r; - bool tty2 = isatty(2); - - Sprintf(buf, pat, arg1, arg2, arg3); - Fflush(stderr); - write(2, buf, strlen(buf)); - if (tty2) { /* might be redirected to a file */ - r = read(2, buf, sizeof buf); - } - else if (isatty(1)) { /* this may be new file output */ - Fflush(stdout); - write(1, buf, strlen(buf)); - r = read(1, buf, sizeof buf); - } - else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) { - /* might be deleted or unwriteable */ - write(ttyfd, buf, strlen(buf)); - r = read(ttyfd, buf, sizeof buf); - Close(ttyfd); - } - else if (isatty(0)) { /* this is probably patch input */ - Fflush(stdin); - write(0, buf, strlen(buf)); - r = read(0, buf, sizeof buf); - } - else { /* no terminal at all--default it */ - buf[0] = '\n'; - r = 1; - } - if (r <= 0) - buf[0] = 0; - else - buf[r] = '\0'; - if (!tty2) - say1(buf); -} -#endif lint - -/* How to handle certain events when not in a critical region. */ - -void -set_signals() -{ - void my_exit(); - -#ifndef lint - if (signal(SIGHUP, SIG_IGN) != SIG_IGN) - Signal(SIGHUP, my_exit); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - Signal(SIGINT, my_exit); -#endif -} - -/* How to handle certain events when in a critical region. */ - -void -ignore_signals() -{ -#ifndef lint - Signal(SIGHUP, SIG_IGN); - Signal(SIGINT, SIG_IGN); -#endif -} - -/* Make sure we'll have the directories to create a file. */ - -void -makedirs(filename,striplast) -Reg1 char *filename; -bool striplast; -{ - char tmpbuf[256]; - Reg2 char *s = tmpbuf; - char *dirv[20]; - Reg3 int i; - Reg4 int dirvp = 0; - - while (*filename) { - if (*filename == '/') { - filename++; - dirv[dirvp++] = s; - *s++ = '\0'; - } - else { - *s++ = *filename++; - } - } - *s = '\0'; - dirv[dirvp] = s; - if (striplast) - dirvp--; - if (dirvp < 0) - return; - strcpy(buf, "mkdir"); - s = buf; - for (i=0; i<=dirvp; i++) { - while (*s) s++; - *s++ = ' '; - strcpy(s, tmpbuf); - *dirv[i] = '/'; - } - system(buf); -} - -/* Make filenames more reasonable. */ - -char * -fetchname(at,strip_leading,assume_exists) -char *at; -int strip_leading; -int assume_exists; -{ - char *s; - char *name; - Reg1 char *t; - char tmpbuf[200]; - - if (!at) - return Nullch; - s = savestr(at); - for (t=s; isspace(*t); t++) ; - name = t; -#ifdef DEBUGGING - if (debug & 128) - say4("fetchname %s %d %d\n",name,strip_leading,assume_exists); -#endif - if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */ - return Nullch; /* against /dev/null. */ - for (; *t && !isspace(*t); t++) - if (*t == '/') - if (--strip_leading >= 0) - name = t+1; - *t = '\0'; - if (name != s && *s != '/') { - name[-1] = '\0'; - if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) { - name[-1] = '/'; - name=s; - } - } - name = savestr(name); - Sprintf(tmpbuf, "RCS/%s", name); - free(s); - if (stat(name, &filestat) < 0 && !assume_exists) { - Strcat(tmpbuf, RCSSUFFIX); - if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) { - Sprintf(tmpbuf, "SCCS/%s%s", SCCSPREFIX, name); - if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+5, &filestat) < 0) { - free(name); - name = Nullch; - } - } - } - return name; -} diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h deleted file mode 100644 index 9896c63bc08b..000000000000 --- a/usr.bin/patch/util.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $Header: util.h,v 2.0 86/09/17 15:40:06 lwall Exp $ - * - * $Log: util.h,v $ - * Revision 2.0 86/09/17 15:40:06 lwall - * Baseline for netwide release. - * - */ - -/* and for those machine that can't handle a variable argument list */ - -#ifdef CANVARARG - -#define say1 say -#define say2 say -#define say3 say -#define say4 say -#define ask1 ask -#define ask2 ask -#define ask3 ask -#define ask4 ask -#define fatal1 fatal -#define fatal2 fatal -#define fatal3 fatal -#define fatal4 fatal - -#else /* hope they allow multi-line macro actual arguments */ - -#ifdef lint - -#define say1(a) say(a, 0, 0, 0) -#define say2(a,b) say(a, (b)==(b), 0, 0) -#define say3(a,b,c) say(a, (b)==(b), (c)==(c), 0) -#define say4(a,b,c,d) say(a, (b)==(b), (c)==(c), (d)==(d)) -#define ask1(a) ask(a, 0, 0, 0) -#define ask2(a,b) ask(a, (b)==(b), 0, 0) -#define ask3(a,b,c) ask(a, (b)==(b), (c)==(c), 0) -#define ask4(a,b,c,d) ask(a, (b)==(b), (c)==(c), (d)==(d)) -#define fatal1(a) fatal(a, 0, 0, 0) -#define fatal2(a,b) fatal(a, (b)==(b), 0, 0) -#define fatal3(a,b,c) fatal(a, (b)==(b), (c)==(c), 0) -#define fatal4(a,b,c,d) fatal(a, (b)==(b), (c)==(c), (d)==(d)) - -#else /* lint */ - /* if this doesn't work, try defining CANVARARG above */ -#define say1(a) say(a, Nullch, Nullch, Nullch) -#define say2(a,b) say(a, b, Nullch, Nullch) -#define say3(a,b,c) say(a, b, c, Nullch) -#define say4 say -#define ask1(a) ask(a, Nullch, Nullch, Nullch) -#define ask2(a,b) ask(a, b, Nullch, Nullch) -#define ask3(a,b,c) ask(a, b, c, Nullch) -#define ask4 ask -#define fatal1(a) fatal(a, Nullch, Nullch, Nullch) -#define fatal2(a,b) fatal(a, b, Nullch, Nullch) -#define fatal3(a,b,c) fatal(a, b, c, Nullch) -#define fatal4 fatal - -#endif /* lint */ - -/* if neither of the above work, join all multi-line macro calls. */ -#endif - -EXT char serrbuf[BUFSIZ]; /* buffer for stderr */ - -char *fetchname(); -int move_file(); -void copy_file(); -void say(); -void fatal(); -void ask(); -char *savestr(); -void set_signals(); -void ignore_signals(); -void makedirs(); diff --git a/usr.bin/patch/version.c b/usr.bin/patch/version.c deleted file mode 100644 index 17dfb81bfa40..000000000000 --- a/usr.bin/patch/version.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $Header: version.c,v 2.0 86/09/17 15:40:11 lwall Exp $ - * - * $Log: version.c,v $ - * Revision 2.0 86/09/17 15:40:11 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "INTERN.h" -#include "patchlevel.h" -#include "version.h" - -/* Print out the version number and die. */ - -void -version() -{ - extern char rcsid[]; - -#ifdef lint - rcsid[0] = rcsid[0]; -#else - fatal3("%s\nPatch level: %d\n", rcsid, PATCHLEVEL); -#endif -} diff --git a/usr.bin/patch/version.h b/usr.bin/patch/version.h deleted file mode 100644 index 08fe68d97388..000000000000 --- a/usr.bin/patch/version.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Header: version.h,v 2.0 86/09/17 15:40:14 lwall Exp $ - * - * $Log: version.h,v $ - * Revision 2.0 86/09/17 15:40:14 lwall - * Baseline for netwide release. - * - */ - -void version(); diff --git a/usr.bin/ranlib/ranlib.5.5 b/usr.bin/ranlib/ranlib.5.5 deleted file mode 100644 index e953c51056df..000000000000 --- a/usr.bin/ranlib/ranlib.5.5 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ranlib.5.5 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt RANLIB 5 -.Os -.Sh NAME -.Nm ranlib -.Nd archive (library) table-of-contents format -.Sh SYNOPSIS -.Fd #include -.Sh DESCRIPTION -The archive table-of-contents command -.Nm ranlib -creates a table of contents for archives, containing object files, to -be used by the link-editor -.Xr ld 1 . -It operates on archives created with the utility -.Xr ar 1 . -.Pp -The -.Nm Ranlib -function -prepends a new file to the archive which has three separate parts. -The first part is a standard archive header, which has a special name -field, "__.SYMDEF". -.Pp -The second part is a ``long'' followed by a list of ranlib structures. -The long is the size, in bytes, of the list of ranlib structures. -Each of the ranlib structures consists of a zero based offset into the -next section (a string table of symbols) and an offset from the beginning -of the archive to the start of the archive file which defines the symbol. -The actual number of ranlib structures is this number divided by the size -of an individual ranlib structure. -.Pp -The third part is a ``long'' followed by a string table. -The long is the size, in bytes of the string table. -.Sh SEE ALSO -.Xr ar 1 , -.Xr ranlib 1 diff --git a/usr.bin/rlogin/des_rw.c b/usr.bin/rlogin/des_rw.c deleted file mode 100644 index dbe47f0a67d7..000000000000 --- a/usr.bin/rlogin/des_rw.c +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)des_rw.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef CRYPT -#ifdef KERBEROS -#include - -#include -#include - -#include -#include -#include -#include - -static unsigned char des_inbuf[10240], storage[10240], *store_ptr; -static bit_64 *key; -static u_char *key_schedule; - -/* XXX these should be in a kerberos include file */ -int krb_net_read __P((int, char *, int)); -#ifdef notdef -/* XXX too hard to make this work */ -int des_pcbc_encrypt __P((des_cblock *, des_cblock *, long, - des_key_schedule, des_cblock *, int)); -#endif - -/* - * NB: These routines will not function properly if NBIO - * is set - */ - -/* - * des_set_key - * - * Set des encryption/decryption key for use by the des_read and - * des_write routines - * - * The inkey parameter is actually the DES initial vector, - * and the insched is the DES Key unwrapped for faster decryption - */ - -void -des_set_key(inkey, insched) - bit_64 *inkey; - u_char *insched; -{ - key = inkey; - key_schedule = insched; -} - -void -des_clear_key() -{ - bzero((char *) key, sizeof(C_Block)); - bzero((char *) key_schedule, sizeof(Key_schedule)); -} - - -int -des_read(fd, buf, len) - int fd; - register char *buf; - int len; -{ - int nreturned = 0; - long net_len, rd_len; - int nstored = 0; - - if (nstored >= len) { - (void) bcopy(store_ptr, buf, len); - store_ptr += len; - nstored -= len; - return(len); - } else if (nstored) { - (void) bcopy(store_ptr, buf, nstored); - nreturned += nstored; - buf += nstored; - len -= nstored; - nstored = 0; - } - - if (krb_net_read(fd, (char *)&net_len, sizeof(net_len)) != - sizeof(net_len)) { - /* XXX can't read enough, pipe - must have closed */ - return(0); - } - net_len = ntohl(net_len); - if (net_len <= 0 || net_len > sizeof(des_inbuf)) { - /* preposterous length; assume out-of-sync; only - recourse is to close connection, so return 0 */ - return(0); - } - /* the writer tells us how much real data we are getting, but - we need to read the pad bytes (8-byte boundary) */ - rd_len = roundup(net_len, 8); - if (krb_net_read(fd, (char *)des_inbuf, rd_len) != rd_len) { - /* pipe must have closed, return 0 */ - return(0); - } - (void) des_pcbc_encrypt(des_inbuf, /* inbuf */ - storage, /* outbuf */ - net_len, /* length */ - key_schedule, /* DES key */ - key, /* IV */ - DECRYPT); /* direction */ - - if(net_len < 8) - store_ptr = storage + 8 - net_len; - else - store_ptr = storage; - - nstored = net_len; - if (nstored > len) { - (void) bcopy(store_ptr, buf, len); - nreturned += len; - store_ptr += len; - nstored -= len; - } else { - (void) bcopy(store_ptr, buf, nstored); - nreturned += nstored; - nstored = 0; - } - - return(nreturned); -} - -static unsigned char des_outbuf[10240]; /* > longest write */ - -int -des_write(fd, buf, len) - int fd; - char *buf; - int len; -{ - static int seeded = 0; - static char garbage_buf[8]; - long net_len, garbage; - - if(len < 8) { - if(!seeded) { - seeded = 1; - srandom((int) time((long *)0)); - } - garbage = random(); - /* insert random garbage */ - (void) bcopy(&garbage, garbage_buf, MIN(sizeof(long),8)); - /* this "right-justifies" the data in the buffer */ - (void) bcopy(buf, garbage_buf + 8 - len, len); - } - /* pcbc_encrypt outputs in 8-byte (64 bit) increments */ - - (void) des_pcbc_encrypt((len < 8) ? garbage_buf : buf, - des_outbuf, - (len < 8) ? 8 : len, - key_schedule, /* DES key */ - key, /* IV */ - ENCRYPT); - - /* tell the other end the real amount, but send an 8-byte padded - packet */ - net_len = htonl(len); - (void) write(fd, &net_len, sizeof(net_len)); - (void) write(fd, des_outbuf, roundup(len,8)); - return(len); -} -#endif /* KERBEROS */ -#endif /* CRYPT */ diff --git a/usr.bin/sccs/Makefile b/usr.bin/sccs/Makefile deleted file mode 100644 index 0ee9d1b59e21..000000000000 --- a/usr.bin/sccs/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= sccs - -.include diff --git a/usr.bin/sccs/PSD.doc/Makefile b/usr.bin/sccs/PSD.doc/Makefile deleted file mode 100644 index 4d2ba7fdd809..000000000000 --- a/usr.bin/sccs/PSD.doc/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/8/93 - -DIR= psd/14.sccs -SRCS= sccs.me -MACROS= -me - -paper.ps: ${SRCS} - ${ROFF} ${SRCS} > ${.TARGET} - -.include diff --git a/usr.bin/sccs/PSD.doc/sccs.me b/usr.bin/sccs/PSD.doc/sccs.me deleted file mode 100644 index ab598c24d165..000000000000 --- a/usr.bin/sccs/PSD.doc/sccs.me +++ /dev/null @@ -1,1608 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sccs.me 8.1 (Berkeley) 6/8/93 -.\" -.eh '\fRPSD:14-%\fP''\fRAn Introduction to the Source Code Control System\fP' -.oh '\fRAn Introduction to the Source Code Control System\fP''\fRPSD:14-%\fP' -.ds S \s-1SCCS\s0 -.ds I \s-1SID\s0 -.nr bi 8n -.ev 1 \" only for keeps -.ss 16 -.ev -.\".he '\*S Introduction''%' -.+c -.(l C -.sz 14 -.b -An Introduction to the -Source Code Control System -.sz -.r -.sp -Eric Allman -.i "Project Ingres" -.i "University of California at Berkeley" -.)l -.sp 3 -.pp -.(f -This is version 1.21 of this document. -It was last modified on 12/5/80. -.)f -This document gives a quick introduction -to using the Source Code Control System -(\*S). -The presentation is geared to programmers -who are more concerned with -what -to do to get a task done -rather than how it works; -for this reason some of the examples -are not well explained. -For details of what the magic options do, -see the section on -.q "Further Information" . -.(l F -This is a working document. -Please send any comments or suggestions -to eric@Berkeley.Edu. -.)l -.sh 1 "Introduction" -.pp -\*S is a source management system. -Such a system maintains a record of versions of a system; -a record is kept with each set of changes -of what the changes are, -why they were made, -and who made them and when. -Old versions can be recovered, -and different versions can be maintained simultaneously. -In projects with more than one person, -\*S will insure that two people are not -editing the same file at the same time. -.pp -All versions of your program, -plus the log and other information, -is kept in a file called the -.q "s-file" . -There are three major operations -that can be performed on the s-file: -.np -Get a file for compilation (not for editing). -This operation retrieves a version of the file -from the s-file. -By default, the latest version is retrieved. -This file is intended for compilation, printing, or whatever; -it is specifically NOT intended to be edited -or changed in any way; -any changes made to a file retrieved -in this way will probably be lost. -.np -Get a file for editing. -This operation also retrieves a version of the file -from the s-file, -but this file is intended to be edited and then -incorporated back into the s-file. -Only one person may be editing a file at one time. -.np -Merge a file back into the s-file. -This is the companion operation to (2). -A new version number is assigned, -and comments are saved explaining why this change was made. -.sh 1 "Learning the Lingo" -.pp -There are a number of terms that are worth learning -before we go any farther. -.sh 2 "S-file" -.pp -The s-file -is a single file that holds all the different versions -of your file. -The s-file is stored in -differential format; -.i i.e. , -only the differences between versions are stored, -rather than the entire text of the new version. -This saves disk space -and allows selective changes to be removed later. -Also included in the s-file -is some header information for each version, -including the comments given by the person who -created the version explaining why the changes were made. -.sh 2 "Deltas" -.pp -Each set of changes to the s-file -(which is approximately [but not exactly!] equivalent -to a version of the file) -is called a -.i delta . -Although technically a delta only includes the -.i changes -made, -in practice -it is usual for -each delta to be made with respect to -all the deltas that have occurred before\**. -.(f -\**This matches normal usage, where the previous changes are not saved -at all, -so all changes are automatically based on all other changes -that have happened through history. -.)f -However, -it is possible to get a version of the file -that has selected deltas removed out of the middle -of the list of changes \*- -equivalent to removing your changes later. -.sh 2 "\*I's (or, version numbers)" -.pp -A \*I -(\*S Id) -is a number that represents a delta. -This is normally a two-part number -consisting of a -.q release -number and a -.q level -number. -Normally the release number stays the same, -however, -it is possible to move into a new release -if some major change is being made. -.pp -Since all past deltas are normally applied, -the \*I of the final delta applied -can be used to represent a version number of the file -as a whole. -.sh 2 "Id keywords" -.pp -When you get a version of a file -with intent to compile and install it -(\c -.i i.e. , -something other than edit it), -some special keywords are expanded inline -by \*S. -These -.i "Id Keywords" -can be used to include the current version number -or other information into the file. -All id keywords are of the form -.b % \c -.i x \c -.b % , -where -.i x -is an upper case letter. -For example, -.b %\&I\&% -is the \*I of the latest delta applied, -.b %\&W\&% -includes the module name, -\*I, -and a mark that makes it findable by a program, -and -.b %\&G\&% -is the date of the latest delta applied. -There are many others, -most of which are of dubious usefulness. -.pp -When you get a file for editing, -the id keywords are not expanded; -this is so that after you put them back in to the s-file, -they will be expanded automatically on each new version. -But notice: if you were to get them -expanded accidently, -then your file would appear to be the same version -forever more, -which would of course defeat the purpose. -Also, -if you should install a version of the program -without expanding the id keywords, -it will be impossible to tell what version it is -(since all it will have is -.q %\&W\&% -or whatever). -.sh 1 "Creating \*S Files" -.pp -To put source files -into -\*S -format, run the following shell script from csh: -.(b -mkdir SCCS save -foreach i (*.[ch]) - sccs admin \-i$i $i - mv $i save/$i -end -.)b -This will put the named files -into s-files -in the subdirectory -.q SCCS -The files will be removed from the current directory -and hidden away in the directory -.q save , -so the next thing you will probably want to do -is to get all the files -(described below). -When you are convinced that -\*S has correctly created the s-files, -you should remove the directory -.q save . -.pp -If you want to have id keywords in the files, -it is best to put them in before you create the s-files. -If you do not, -.i admin -will print -.q "No Id Keywords (cm7)" , -which is a warning message only. -.sh 1 "Getting Files for Compilation" -.pp -To get a copy of the latest version -of a file, -run -.(b -sccs get prog.c -.)b -\*S will respond: -.(b -1.1 -87 lines -.)b -meaning that version 1.1 was retrieved\** -.(f -\**Actually, -the \*I of the final delta applied was 1.1. -.)f -and that it has 87 lines. -The file -.i prog.c -will be created -in the current directory. -The file will be read-only -to remind you that you are not -supposed to change it. -.pp -This copy of the file -should not be changed, -since \*S is unable -to merge the changes -back into the s-file. -If you do make changes, -they will be lost the next time -someone does a -.i get . -.sh 1 "Changing Files (or, Creating Deltas)" -.sh 2 "Getting a copy to edit" -.pp -To edit a source file, -you must first get it, -requesting permission to edit it\**: -.(f -\**The -.q "edit" -command is equivalent to using the \-e -flag to -.i "get" , -as: -.(l -sccs get \-e prog.c -.)l -Keep this in mind when reading other documentation. -.)f -.(b -sccs edit prog.c -.)b -The response will be the same as with -.i get -except that it will also say: -.(b -New delta 1.2 -.)b -You then edit it, -using a standard text editor: -.(b -vi prog.c -.)b -.sh 2 "Merging the changes back into the s-file" -.pp -When the desired changes are made, -you can put your changes into the -\*S -file using the -.i delta -command: -.(b -sccs delta prog.c -.)b -.pp -Delta will prompt you for -.q "comments?" -before it merges the changes in. -At this prompt you should type a one-line description -of what the changes mean -(more lines can be entered by ending each line -except the last with a backslash\**). -.(f -\**Yes, this is a stupid default. -.)f -.i Delta -will then type: -.(b -1.2 -5 inserted -3 deleted -84 unchanged -.)b -saying that delta 1.2 was created, -and it inserted five lines, -removed three lines, -and left 84 lines unchanged\**. -.(f -\**Changes to a line are counted as a line deleted -and a line inserted. -.)f -The -.i prog.c -file will be removed; -it can be retrieved -using -.i get . -.sh 2 "When to make deltas" -.pp -It is probably unwise to make a delta -before every recompilation or test; -otherwise, -you tend to get a lot of deltas with comments like -.q "fixed compilation problem in previous delta" -or -.q "fixed botch in 1.3" . -However, -it is very important to delta everything -before installing a module for general use. -A good technique is to edit the files you need, -make all necessary changes and tests, -compiling and editing as often as necessary -without making deltas. -When you are satisfied that you have a working version, -delta everything being edited, -re-get them, -and recompile everything. -.sh 2 "What's going on: the info command" -.pp -To find out what files where being edited, -you can use: -.(b -sccs info -.)b -to print out all the files being edited -and other information such as the name of the user -who did the edit. -Also, -the command: -.(b -sccs check -.)b -is nearly equivalent to the -.i info -command, -except that it is silent if nothing is being edited, -and returns non-zero exit status if anything is being edited; -it can be used in an -.q install -entry in a makefile -to abort the install -if anything has not been properly deltaed. -.pp -If you know that everything being edited should be deltaed, -you can use: -.(b -sccs delta \`sccs tell\` -.)b -The -.i tell -command is similar to -.i info -except that only the names of files being edited -are output, -one per line. -.pp -All of these commands take a -.b \-b -flag -to ignore -.q branches -(alternate versions, described later) -and the -.b \-u -flag to only give files being edited by you. -The -.b \-u -flag takes an optional -.i user -argument, -giving only files being edited by that user. -For example, -.(b -sccs info \-ujohn -.)b -gives a listing of files being edited by john. -.sh 2 "ID keywords" -.pp -Id keywords can be inserted into your file -that will be expanded automatically by -.i get . -For example, -a line such as: -.(b -static char SccsId[] = "%\&W\&%\et%\&G\&%"; -.)b -will be replaced with something like: -.(b -static char SccsId[] = "@\&(#)prog.c 1.2 08/29/80"; -.)b -This tells you -the name and version -of the source file -and the time the delta was created. -The string -.q "@\&(#)" -is a special string -which signals the beginning -of an -\*S -Id keyword. -.sh 3 "The what command" -.pp -To find out what version of a program -is being run, -use: -.(b -sccs what prog.c /usr/bin/prog -.)b -which will print all strings -it finds that -begin with -.q "@\&(#)" . -This works on all types of files, -including binaries and libraries. -For example, the above command will output something like: -.(b -prog.c: - prog.c 1.2 08/29/80 -/usr/bin/prog: - prog.c 1.1 02/05/79 -.)b -From this I can see -that the source that I have in prog.c -will not compile into the same version -as the binary in /usr/bin/prog. -.sh 3 "Where to put id keywords" -.pp -ID keywords can be inserted anywhere, -including in comments, -but -Id Keywords that are compiled into the object module -are especially useful, -since it lets you find out what version of -the object is being run, -as well as the source. -However, -there is a cost: -data space is used up to store -the keywords, -and on small address space machines -this may be prohibitive. -.pp -When you put id keywords into header files, -it is important that you assign them to different variables. -For example, you might use: -.(b -static char AccessSid[] = "%\&W\&% %\&G\&%"; -.)b -in the file -.i access.h -and: -.(b -static char OpsysSid[] = "%\&W\&% %\&G\&%"; -.)b -in the file -.i opsys.h . -Otherwise, -you will get compilation errors because -.q SccsId -is redefined. -The problem with this is that if the header file -is included by many modules that are loaded together, -the version number of that header file is included -in the object module many times; -you may find it more to your taste -to put id keywords in header files -in comments. -.sh 2 "Keeping \*I's consistent across files" -.pp -With some care, -it is possible to keep the \*I's consistent -in multi-file systems. -The trick here is to always -.i edit -all files -at once. -The changes can then be made -to whatever files are necessary -and then all files -(even those not changed) -are redeltaed. -This can be done fairly easily -by just specifying the name of the directory -that the \*S files are in: -.(b -sccs edit SCCS -.)b -which will -.i edit -all files in that directory. -To make the delta, use: -.(b -sccs delta SCCS -.)b -You will be prompted for comments only once. -.sh 2 "Creating new releases" -.pp -When you want to create a new release -of a program, -you can specify the release number you want to create -on the -.i edit -command. -For example: -.(b -sccs edit \-r2 prog.c -.)b -will cause the next delta to be in release two -(that is, -it will be numbered 2.1). -Future deltas will automatically be in release two. -To change the release number -of an entire system, -use: -.(b -sccs edit \-r2 SCCS -.)b -.sh 1 "Restoring Old Versions" -.sh 2 "Reverting to old versions" -.pp -Suppose that after delta 1.2 -was stable -you made and released a delta 1.3. -But this introduced a bug, -so you made a delta 1.4 to correct it. -But 1.4 was still buggy, -and you decided you wanted to go back -to the old version. -You could -revert to delta 1.2 -by choosing the \*I in a get: -.(b -sccs get \-r1.2 prog.c -.)b -This will produce a version of -.i prog.c -that is delta 1.2 -that can be reinstalled so that work can proceed. -.pp -In some cases you don't know -what the \*I of the delta you want is. -However, -you can revert to the version of the program -that was running as of a certain date -by using the -.b \-c -(cutoff) flag. -For example, -.(b -sccs get \-c800722120000 prog.c -.)b -will retrieve whatever version was current -as of July 22, 1980 -at 12:00 noon. -Trailing components can be stripped off -(defaulting to their highest legal value), -and punctuation can be inserted in the obvious -places; -for example, -the above line could be equivalently stated: -.(b -sccs get \-c"80/07/22 12:00:00" prog.c -.)b -.sh 2 "Selectively deleting old deltas" -.pp -Suppose that you later decided -that you liked the changes in delta 1.4, -but that delta 1.3 should be removed. -You could do this by -.i excluding -delta 1.3: -.(b -sccs edit \-x1.3 prog.c -.)b -When delta 1.5 is made, -it will include the changes made -in delta 1.4, -but will exclude the changes made -in delta 1.3. -You can exclude a range of deltas -using a dash. -For example, -if you want to get rid of 1.3 and 1.4 -you can use: -.(b -sccs edit \-x1.3\-1.4 prog.c -.)b -which will exclude all deltas from 1.3 to 1.4. -Alternatively, -.(b -sccs edit \-x1.3\-1 prog.c -.)b -will exclude a range of deltas -from 1.3 to the current highest delta in release 1. -.pp -In certain cases when using -.b \-x -(or -.b \-i ; -see below) -there will be conflicts -between versions; -for example, it may be necessary -to both include and delete -a particular line. -If this happens, -\*S always prints out a message -telling the range of lines effected; -these lines should then be examined very carefully -to see if the version \*S got -is ok. -.pp -Since each delta -(in the sense of -.q "a set of changes" ) -can be excluded at will, -that this makes it most useful -to put each semantically distinct change -into its own delta. -.sh 1 "Auditing Changes" -.sh 2 "The prt command" -.pp -When you created a delta, -you presumably gave a reason for the delta -to the -.q "comments?" -prompt. -To print out these comments later, -use: -.(b -sccs prt prog.c -.)b -This will produce -a report -for each delta -of the \*I, -time and date of creation, -user who created the delta, -number of lines inserted, deleted, and unchanged, -and the comments associated with the delta. -For example, the output of the above command might be: -.(b -D 1.2 80/08/29 12:35:31 bill 2 1 00005/00003/00084 -removed "-q" option -.sp \n(psu -D 1.1 79/02/05 00:19:31 eric 1 0 00087/00000/00000 -date and time created 80/06/10 00:19:31 by eric -.)b -.sh 2 "Finding why lines were inserted" -.pp -To find out -why you inserted lines, -you can get a copy of the file -with each line -preceded by the \*I that created it: -.(b -sccs get \-m prog.c -.)b -You can then find out -what this delta did -by printing the comments using -.i prt . -.pp -To find out what lines are associated with a particular delta -(\c -.i e.g. , -1.3), -use: -.(b -sccs get \-m \-p prog.c \(bv grep \'^1.3\' -.)b -The -.b \-p -flag causes \*S to output the generated source -to the standard output rather than to a file. -.sh 2 "Finding what changes you have made" -.pp -When you are editing a file, -you can find out what changes you have made using: -.(b -sccs diffs prog.c -.)b -Most of the ``diff'' flags can be used. -To pass the -.b \-c -flag, -use -.b \-C . -.pp -To compare two versions that are in deltas, -use: -.(b -sccs sccsdiff -r1.3 -r1.6 prog.c -.)b -to see the differences between delta 1.3 and delta 1.6. -.sh 1 "Shorthand Notations" -.pp -There are several sequences of commands that get -executed frequently. -.i Sccs -tries to make it easy to do these. -.sh 2 "Delget" -.pp -A frequent requirement is to make a delta of some file -and then get that file. -This can be done by using: -.(b -sccs delget prog.c -.)b -which is entirely equivalent to using: -.(b -sccs delta prog.c -sccs get prog.c -.)b -The -.q deledit -command is equivalent to -.q delget -except that the -.q edit -command is used -instead of the -.q get -command. -.sh 2 "Fix" -.pp -Frequently, there are small bugs -in deltas, -e.g., compilation errors, -for which there is no reason to maintain an audit trail. -To -.i replace -a delta, use: -.(b -sccs fix \-r1.4 prog.c -.)b -This will get a copy of delta 1.4 of prog.c for you to edit -and then delete delta 1.4 from the \*S file. -When you do a delta of prog.c, -it will be delta 1.4 again. -The \-r flag must be specified, -and the delta that is specified must be a leaf delta, -i.e., no other deltas may have been made subsequent -to the creation of that delta. -.sh 2 "Unedit" -.pp -If you found you edited a file -that you did not want to edit, -you can back out by using: -.(b -sccs unedit prog.c -.)b -.sh 2 "The \-d flag" -.pp -If you are working on a project -where the \*S code is in a directory somewhere, -you may be able to simplify things -by using a shell alias. -For example, -the alias: -.(b -alias syssccs sccs \-d/usr/src -.)b -will allow you to issue commands such as: -.(b -syssccs edit cmd/who.c -.)b -which will look for the file -.q "/usr/src/cmd/SCCS/who.c" . -The file -.q who.c -will always be created in your current directory -regardless of the value of the \-d flag. -.sh 1 "Using \*S on a Project" -.pp -Working on a project with several people -has its own set of special problems. -The main problem occurs when two people -modify a file at the same time. -\*S prevents this by locking an s-file -while it is being edited. -.pp -As a result, -files should not be reserved for editing -unless they are actually being edited at the time, -since this will prevent other people on the project -from making necessary changes. -For example, -a good scenario for working might be: -.(b -sccs edit a.c g.c t.c -vi a.c g.c t.c -# do testing of the (experimental) version -sccs delget a.c g.c t.c -sccs info -# should respond "Nothing being edited" -make install -.)b -.pp -As a general rule, -all source files should be deltaed -before installing the program for general use. -This will insure that it is possible -to restore any version in use at any time. -.sh 1 "Saving Yourself" -.sh 2 "Recovering a munged edit file" -.pp -Sometimes you may find -that you have destroyed or trashed -a file that you were trying to edit\**. -.(f -\**Or given up and decided to start over. -.)f -Unfortunately, -you can't just remove it -and re-\c -.i edit -it; -\*S keeps track -of the fact -that someone is trying to edit it, -so it won't let you do it again. -Neither can you just get it using -.i get , -since that would expand the Id keywords. -Instead, -you can say: -.(b -sccs get \-k prog.c -.)b -This will not expand the Id keywords, -so it is safe to do a delta -with it. -.pp -Alternately, -you can -.i unedit -and -.i edit -the file. -.sh 2 "Restoring the s-file" -.pp -In particularly bad circumstances, -the \*S file itself -may get munged. -The most common way this happens -is that it gets edited. -Since \*S keeps a checksum, -you will get errors every time you read the file. -To fix this checksum, use: -.(b -sccs admin \-z prog.c -.)b -.sh 1 "Using the Admin Command" -.pp -There are a number of parameters that can be set -using the -.i admin -command. -The most interesting of these are flags. -Flags can be added by using the -.b \-f -flag. -For example: -.(b -sccs admin \-fd1 prog.c -.)b -sets the -.q d -flag to the value -.q 1 . -This flag can be deleted by using: -.(b -sccs admin \-dd prog.c -.)b -The most useful flags are: -.nr ii 7n -.ip "b" -Allow branches to be made using the -\-b -flag to -.i edit . -.ip "d\fISID\fP" -Default \*I to be used on a -.i get -or -.i edit . -If this is just a release number -it constrains the -version -to a particular release only. -.ip "i" -Give a fatal error -if there are no Id Keywords in a file. -This is useful to guarantee that a version of the -file does not get merged into the s-file -that has the Id Keywords inserted as constants -instead of internal forms. -.ip "y" -The -.q type -of the module. -Actually, -the value of this flag is unused by \*S -except that it replaces the -.b %\&Y\&% -keyword. -.pp -The -.b \-t\fIfile\fR -flag can be used -to store descriptive text -from -.i file . -This descriptive text might be the documentation -or a design and implementation document. -Using the -.b \-t -flag insures that if the \*S file is sent, -the documentation will be sent also. -If -.i file -is omitted, -the descriptive text is deleted. -To see the descriptive text, -use -.q "prt \-t" . -.pp -The -.i admin -command can be used safely -any number of times on files. -A file need not be gotten -for -.i admin -to work. -.sh 1 "Maintaining Different Versions (Branches)" -.pp -Sometimes it is convenient -to maintain an experimental version of a program -for an extended period -while normal maintenance continues -on the version in production. -This can be done using a -.q branch. -Normally deltas continue in a straight line, -each depending on the delta before. -Creating a branch -.q "forks off" -a version of the program. -.pp -The ability to create branches -must be enabled in advance using: -.(b -sccs admin \-fb prog.c -.)b -The -.b \-fb -flag can be specified when the -\*S file is first created. -.sh 2 "Creating a branch" -.pp -To create a branch, use: -.(b -sccs edit \-b prog.c -.)b -This will create a branch -with (for example) \*I 1.5.1.1. -The deltas for this version -will be numbered -1.5.1.\c -.i n . -.sh 2 "Getting from a branch" -.pp -Deltas in a branch are normally not included -when you do a get. -To get these versions, -you will have to say: -.(b -sccs get \-r1.5.1 prog.c -.)b -.sh 2 "Merging a branch back into the main trunk" -.pp -At some point you will have finished the experiment, -and if it was successful -you will want to incorporate it into the release version. -But in the meantime -someone may have created a delta 1.6 -that you don't want to lose. -The commands: -.(b -sccs edit \-i1.5.1.1\-1.5.1 prog.c -sccs delta prog.c -.)b -will merge all of your changes -into the release system. -If some of the changes conflict, -get will print an error; -the generated result -should be carefully examined -before the delta is made. -.sh 2 "A more detailed example" -.pp -The following technique might be used -to maintain a different version of a program. -First, -create a directory to contain the new version: -.(b -mkdir ../newxyz -cd ../newxyz -.)b -Edit a copy of the program -on a branch: -.(b -sccs \-d../xyz edit prog.c -.)b -When using the old version, -be sure to use the -.b \-b -flag to info, check, tell, and clean -to avoid confusion. -For example, use: -.(b -sccs info \-b -.)b -when in the directory -.q xyz . -.pp -If you want to save a copy of the program -(still on the branch) -back in the s-file, -you can use: -.(b -sccs -d../xyz deledit prog.c -.)b -which will do a delta on the branch -and reedit it for you. -.pp -When the experiment is complete, merge it back into the s-file -using delta: -.(b -sccs -d../xyz delta prog.c -.)b -At this point you must decide whether this version -should be merged back into the trunk -(\c -.i i.e. -the default version), -which may have undergone changes. -If so, it can be merged using the -.b \-i -flag to -.i edit -as described above. -.sh 2 "A warning" -.pp -Branches should be kept to a minimum. -After the first branch from the trunk, -\*I's are assigned rather haphazardly, -and the structure gets complex fast. -.sh 1 "Using \*S with Make" -.pp -\*S and make can be made to work together -with a little care. -A few sample makefiles -for common applications are shown. -.pp -There are a few basic entries that every makefile -ought to have. -These are: -.nr ii 1i -.ip a.out -(or whatever the makefile generates.) -This entry regenerates whatever this makefile is -supposed to regenerate. -If the makefile regenerates many things, -this should be called -.q all -and should in turn -have dependencies on everything -the makefile can generate. -.ip install -Moves the objects to the final -resting place, -doing any special -.i chmod 's -or -.i ranlib 's -as appropriate. -.ip sources -Creates all the source files from \*S files. -.ip clean -Removes all files from the current directory -that can be regenerated from \*S files. -.ip print -Prints the contents of the directory. -.lp -The examples shown below are only partial examples, -and may omit some of these entries -when they are deemed to be obvious. -.pp -The -.i clean -entry should not remove files that can be -regenerated from the \*S files. -It is sufficiently important to have the -source files around at all times -that the only time they should be removed -is when the directory is being mothballed. -To do this, the command: -.(b -sccs clean -.)b -can be used. -This will remove all files for which an s-file -exists, -but which is not being edited. -.sh 2 "To maintain single programs" -.pp -Frequently there are directories with several -largely unrelated programs -(such as simple commands). -These can be put into a single makefile: -.(b -LDFLAGS= \-i \-s -.sp \n(psu -prog: prog.o - $(CC) $(LDFLAGS) \-o prog prog.o -prog.o: prog.c prog.h -.sp \n(psu -example: example.o - $(CC) $(LDFLAGS) \-o example example.o -example.o: example.c -.sp \n(psu -\&.DEFAULT: - sccs get $< -.)b -The trick here -is that the .DEFAULT rule -is called every time -something is needed -that does not exist, -and no other rule exists to make it. -The explicit dependency of the -.b \&.o -file on the -.b \&.c -file is important. -Another way of doing the same thing is: -.(b -SRCS= prog.c prog.h example.c -.sp \n(psu -LDFLAGS= \-i \-s -.sp \n(psu -prog: prog.o - $(CC) $(LDFLAGS) \-o prog prog.o -prog.o: prog.h -.sp \n(psu -example: example.o - $(CC) $(LDFLAGS) \-o example example.o -.sp \n(psu -sources: $(SRCS) -$(SRCS): - sccs get $@ -.)b -There are a couple of advantages to this approach: -(1) the explicit dependencies of the .o on the .c files are -not needed, -(2) there is an entry called "sources" so if you want to get -all the sources you can just say -.q "make sources" , -and -(3) the makefile is less likely to do confusing things -since it won't try to -.i get -things that do not exist. -.sh 2 "To maintain a library" -.pp -Libraries that are largely static -are best updated using explicit commands, -since -.i make -doesn't know about updating them properly. -However, -libraries that are in the process of being developed -can be handled quite adequately. -The problem is that the .o files -have to be kept out of the library -as well as in the library. -.(b -# configuration information -OBJS= a.o b.o c.o d.o -SRCS= a.c b.c c.c d.s x.h y.h z.h -TARG= /usr/lib -.sp \n(psu -# programs -GET= sccs get -REL= -AR= \-ar -RANLIB= ranlib -.sp \n(psu -lib.a: $(OBJS) - $(AR) rvu lib.a $(OBJS) - $(RANLIB) lib.a -.sp \n(psu -install: lib.a - sccs check - cp lib.a $(TARG)/lib.a - $(RANLIB) $(TARG)/lib.a -.sp \n(psu -sources: $(SRCS) -$(SRCS): - $(GET) $(REL) $@ -.sp \n(psu -print: sources - pr *.h *.[cs] -clean: - rm \-f *.o - rm \-f core a.out $(LIB) -.)b -.pp -The -.q "$(REL)" -in the get -can be used to get old versions -easily; for example: -.(b -make b.o REL=\-r1.3 -.)b -.pp -The -.i install -entry includes the line -.q "sccs check" -before anything else. -This guarantees that all the s-files -are up to date -(\c -.i i.e. , -nothing is being edited), -and will abort the -.i make -if this condition is not met. -.sh 2 "To maintain a large program" -.(b -OBJS= a.o b.o c.o d.o -SRCS= a.c b.c c.y d.s x.h y.h z.h -.sp \n(psu -GET= sccs get -REL= -.sp \n(psu -a.out: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -.sp \n(psu -sources: $(SRCS) -$(SRCS): - $(GET) $(REL) $@ -.)b -(The -.i print -and -.i clean -entries are identical to the previous case.) -This makefile requires copies of the source and object files -to be kept during development. -It is probably also wise to include lines of the form: -.(b -a.o: x.h y.h -b.o: z.h -c.o: x.h y.h z.h -z.h: x.h -.)b -so that modules will be recompiled -if header files change. -.pp -Since -.i make -does not do transitive closure on dependencies, -you may find in some makefiles lines like: -.(b -z.h: x.h - touch z.h -.)b -This would be used in cases where file z.h -has a line: -.(b -#include "x.h" -.)b -in order to bring the mod date of z.h in line -with the mod date of x.h. -When you have a makefile such as above, -the -.i touch -command can be removed completely; -the equivalent effect will be achieved -by doing an automatic -.i get -on z.h. -.sh 1 "Further Information" -.pp -The -.i "SCCS/PWB User's Manual" -gives a deeper description -of how to use \*S. -Of particular interest -are the numbering of branches, -the l-file, -which gives a description of what deltas were used on a get, -and certain other \*S commands. -.pp -The \*S manual pages -are a good last resort. -These should be read by software managers -and by people who want to know -everything about everything. -.pp -Both of these documents were written without the -.i sccs -front end in mind, -so most of the examples are slightly different from those -in this document. -.bp -.sz 12 -.ce -.b "Quick Reference" -.sz -.sp 2 -.sh 1 Commands 1 -.pp -The following commands should all be preceded with -.q sccs . -This list is not exhaustive; -for more options see -.i "Further Information" . -.ip get 9n -Gets files for compilation (not for editing). -Id keywords are expanded. -.ba 9n -.nr ii 8n -.ip \-r\fI\*I\fP -Version to get. -.ip \-p -Send to standard output rather than to the actual file. -.ip \-k -Don't expand id keywords. -.ip \-i\fIlist\fP -List of deltas to include. -.ip \-x\fIlist\fP -List of deltas to exclude. -.ip \-m -Precede each line with \*I of creating delta. -.ip \-c\fIdate\fP -Don't apply any deltas created after -.i date. -.ba -.ip edit 9n -Gets files for editing. -Id keywords are not expanded. -Should be matched with a -.i delta -command. -.ba 9n -.nr ii 8n -.ip \-r\fI\*I\fP -Same as -.i get . -If -.i \*I -specifies a release that does not yet exist, -the highest numbered delta is retrieved -and the new delta is numbered with -.i \*I . -.ip \-b -Create a branch. -.ip \-i\fIlist\fP -Same as -.i get . -.ip \-x\fIlist\fP -Same as -.i get . -.ba -.ip delta 9n -Merge a file gotten using -.i edit -back into the s-file. -Collect comments about why this delta was made. -.ip unedit 9n -Remove a file that has been edited previously -without merging the changes into the s-file. -.ip prt 9n -Produce a report of changes. -.ba 9n -.nr ii 5n -.ip \-t -Print the descriptive text. -.ip \-e -Print (nearly) everything. -.ba -.ip info 9n -Give a list of all files being edited. -.ba 9n -.nr ii 5n -.ip \-b -Ignore branches. -.ip \-u[\fIuser\fP] -Ignore files not being edited by -.i user . -.ba -.ip check 9n -Same as -.i info , -except that nothing is printed if nothing is being edited -and exit status is returned. -.ip tell 9n -Same as -.i info , -except that one line is produced per file being edited containing -only the file name. -.ip clean 9n -Remove all files that can be regenerated from the -s-file. -.ip what 9n -Find and print id keywords. -.ip admin 9n -Create or set parameters on s-files. -.ba 9n -.nr ii 8n -.ip \-i\fIfile\fP -Create, using -.i file -as the initial contents. -.ip \-z -Rebuild the checksum in case -the file has been trashed. -.ip \-f\fIflag\fP -Turn on the -.i flag . -.ip \-d\fIflag\fP -Turn off (delete) the -.i flag . -.ip \-t\fIfile\fP -Replace the descriptive text -in the s-file with the contents of -.i file . -If -.i file -is omitted, -the text is deleted. -Useful for storing documentation -or -.q "design & implementation" -documents to insure they get distributed with the -s-file. -.lp -Useful flags are: -.ip b -Allow branches to be made using the \-b flag to -.i edit. -.ip d\fI\*I\fP -Default \*I to be used -on a -.i get -or -.i edit . -.ip i -Cause -.q "No Id Keywords" -error message -to be a fatal error rather than a warning. -.ip t -The module -.q type ; -the value of this flag replaces the -.b %\&Y\&% -keyword. -.ba -.ip fix 9n -Remove a delta and reedit it. -.ip delget 9n -Do a -.i delta -followed by a -.i get . -.ip deledit 9n -Do a -.i delta -followed by an -.i edit . -.sh 1 "Id Keywords" -.nr ii 6n -.ip "%\&Z\&%" -Expands to -.q @\&(#) -for the -.i what -command to find. -.ip "%\&M\&%" -The current module name, -.i e.g., -.q prog.c . -.ip "%\&I\&%" -The highest \*I applied. -.ip "%\&W\&%" -A shorthand for -.q "%\&Z\&%%\&M\&% %\&I\&%" . -.ip "%\&G\&%" -The date of the delta -corresponding to the -.q "%\&I\&%" -keyword. -.ip "%\&R\&%" -The current release number, -.i i.e. , -the first component of the -.q "%\&I\&%" -keyword. -.ip "%\&Y\&%" -Replaced by the value of the -.b t -flag -(set by -.i admin ). diff --git a/usr.bin/sccs/PSD.doc/spell.ok b/usr.bin/sccs/PSD.doc/spell.ok deleted file mode 100644 index fb2fe247b9b8..000000000000 --- a/usr.bin/sccs/PSD.doc/spell.ok +++ /dev/null @@ -1,77 +0,0 @@ -AccessSid -Admin -Allman -Berkeley.Edu -Delget -Ingres -LDFLAGS -LIB -LIBS -OBJS -OpsysSid -PS1:14 -PWB -REL -SCCS -SID -SRCS -Sccs -SccsId -System''PS1:14 -TARG -a.c -a.o -a.out -access.h -admin -b.c -b.o -backslash -bi -c.c -c.o -c.y -ch -cm7 -cmd -cs -d.o -d.s -deledit -delget -eric -example.c -example.o -fb -fd1 -foreach -g.c -info -inline -john -lib -lib.a -makefile -makefiles -mod -mothballed -newxyz -ok -opsys.h -prog -prog.c -prog.h -prog.o -prt -rvu -sccs -sccsdiff -src -syssccs -t.c -ujohn -who.c -x.h -xyz -y.h -z.h diff --git a/usr.bin/sccs/pathnames.h b/usr.bin/sccs/pathnames.h deleted file mode 100644 index 4da6874d3343..000000000000 --- a/usr.bin/sccs/pathnames.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#include - -#define _PATH_SCCSADMIN "/usr/local/bin/admin" -#define _PATH_SCCSBDIFF "/usr/local/bin/bdiff" -#define _PATH_SCCSCOMB "/usr/local/bin/comb" -#define _PATH_SCCSDELTA "/usr/local/bin/delta" -#define _PATH_SCCSDIFF "/usr/local/bin/sccsdiff" -#define _PATH_SCCSGET "/usr/local/bin/get" -#define _PATH_SCCSHELP "/usr/local/bin/help" -#define _PATH_SCCSPRS "/usr/local/bin/prs" -#define _PATH_SCCSPRT "/usr/local/bin/prt" -#define _PATH_SCCSRMDEL "/usr/local/bin/rmdel" -#define _PATH_SCCSVAL "/usr/local/bin/val" -#define _PATH_SCCSWHAT "/usr/local/bin/what" -#undef _PATH_TMP -#define _PATH_TMP "/tmp/sccsXXXXX" diff --git a/usr.bin/sccs/sccs.1 b/usr.bin/sccs/sccs.1 deleted file mode 100644 index 7f4990c34d16..000000000000 --- a/usr.bin/sccs/sccs.1 +++ /dev/null @@ -1,398 +0,0 @@ -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sccs.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt SCCS 1 -.Os BSD 4.2 -.Sh NAME -.Nm sccs -.Nd front end for the -.Li SCCS -subsystem -.Sh SYNOPSIS -.Nm sccs -.Op Fl r -.Op Fl d Ar path -.Op Fl p Ar path -.Ar command -.Op flags -.Op Ar -.Sh DESCRIPTION -.Nm Sccs -is a front end to the -.Li SCCS -programs -that -helps them mesh more cleanly -with -the rest of UNIX. -It -also includes the capability to run -.Dq set user id -to another user -to -provide additional protection. -.Pp -Basically, -.Nm sccs -runs the command with the specified -.Ar flags -and -.Ar args . -Each argument is normally modified to be prepended with -.Dq Li SCCS/s. . -.Pp -Flags to be interpreted by the -.Nm sccs -program must be before the -.Ar command -argument. -Flags to be passed to the actual -.Li SCCS -program must come after the -.Ar command -argument. -These flags are specific to the command and -are discussed in the documentation for that command. -.Pp -Besides the usual -.Li SCCS -commands, -several -.Dq pseudo-commands -can be issued. -These are: -.Bl -tag -width deledit -.It Cm edit -Equivalent -to -.Dq Li get \-e . -.It Cm delget -Perform a delta on the named files and -then get new versions. -The new versions will have id keywords expanded, and -will not be editable. -The -.Fl m , -.Fl p , -.Fl r , -.Fl s , -and -.Fl y -flags will be passed to -.Nm delta , -and the -.Fl b, -.Fl c , -.Fl e , -.Fl i , -.Fl k , -.Fl l , -.Fl s , -.\" anybody who has a bad xterm which is almost anyone -and -.Fl x -flags will be passed to get. -.It Cm deledit -Equivalent -to -.Nm delget -except that the -.Nm get -phase includes the -.Fl e -flag. -This -option is useful for making a -.Em checkpoint -of your current editing phase. The same flags will be passed to delta -as described above, and -all the flags listed for -.om get -above except -.Fl e -and -.Fl k -are -passed to -.Nm edit . -.It Cm create -Creates -an -.Li SCCS -file , -taking -the initial contents from the file of the same name. -Any -flags to -.Nm admin -are accepted. If the creation is successful, -the files are renamed with a comma on the front. -These should be removed when you are convinced that the -.Li SCCS -files -have been created successfully. -.It Cm fix -Must -be followed by a -.Fl r -flag. -This command essentially removes the named delta, but -leaves you with a copy of the delta -with the changes that were in it. It -is useful for fixing small compiler bugs, etc. -Since it doesn't leave audit trails, it should be used carefully. -.It Cm clean -This routine removes everything from the current directory -that can be recreated from SCCS files. -It will not remove any files being edited. -If the -.Fl b -flag is given, branches are ignored in the determination of -whether they are being edited; this -is dangerous if you are keeping the branches in the -same directory. -.It Cm unedit -This -is the opposite of an -.Nm edit -or -a -.Dq Li get \-e . -It should be used with extreme caution, since -any changes you made since the get will be irretrievably lost. -.It Cm info -Gives a listing of all files being edited. -If the -.Fl b -flag -is given, branches (i.e., -.Li SID Ns \&\'s -with two or fewer components) -are ignored. If the -.Fl u -flag is given (with an optional argument) then -only files being edited by you (or the named user) are listed. -.It Cm check -Like -.Nm info -except that nothing is printed if nothing is being edited, and -a non-zero exit status is returned if anything is being edited. -The intent is to have this included in an -.Em install -entry in a makefile to insure that everything is included into the -.Li SCCS -file before a version is installed. -.It Cm tell -Gives a newline-separated list of the files being edited -on the standard output. Takes the -.Fl b -and -.Fl u -flags like -.Nm info -and -.Nm check . -.It Cm diffs -Gives a -.Nm diff -listing between the current version of the -program(s) you have out for editing and the versions in -.Li SCCS -format. -The -.Fl r , -.Fl c , -.Fl i , -.Fl x , -and -.Fl t -flags are passed to -.if n \{\ -. br -.\} -.Nm get ; -the -.Fl l , -.Fl s , -.Fl e , -.Fl f , -.Fl h , -and -.Fl b -options are passed to -.if n \{\ -. br -.\} -.Nm diff . -The -.Fl C -flag is passed to -.Nm diff -as -.Fl c . -.It Cm print -This command prints out verbose information -about the named files. -.Pp -.It Fl r -Runs -.Nm sccs -as the real user rather than as whatever effective user -.Nm sccs -is -.Dq Li set user id -to. -.It Fl d -Specifies a root directory for the -.Li SCCS -files. -The default is the current directory. -If environment variable -.Ev PROJECT -is set, -it will be used to determine the -.Fl d -flag. -.It Fl p -Defines the pathname of the directory in which the -.Li SCCS -files will be found; -.Dq Li SCCS -is the default. -The -.Fl p -flag -differs from the -.Fl d -flag -in that the -.Fl d -argument is prepended to the entire pathname and the -.Fl p -argument is inserted before the final component of the pathname. -For example, -.Dq Li sccs \-d/x \-py get a/b -will convert to -.Dq Li get /x/a/y/s.b . -The intent here is to create aliases such as -.Dq Li alias syssccs sccs -d/usr/src -which -will be used as -.Dq Li syssccs get cmd/who.c . -.Pp -Certain -commands (such as -.Nm admin ) -cannot be run -.Dq Li set user id -by all users, since this would allow anyone to change the authorizations. -These commands are always run as the real user. -.Sh EXAMPLES -To get a file for editing, -edit it, -and produce a new delta: -.Pp -.Dl sccs get \-e file.c -.Dl ex file.c -.Dl sccs delta file.c -.Pp -To get a file from another directory: -.Pp -.Dl sccs \-p/usr/src/sccs/s. get cc.c -.Pp -or -.Pp -.Dl sccs get /usr/src/sccs/s.cc.c -.Pp -To make a delta of a large number of files -in the current directory: -.Pp -.Dl sccs delta *.c -.Pp -To get a list of files being edited that are not on branches: -.Pp -.Dl sccs info \-b -.Pp -To delta everything being edited by you: -.Pp -.Dl sccs delta \`sccs tell \-u\` -.Pp -In a makefile, to get source files -from an -.Li SCCS -file if it does not already exist: -.Pp -.Dl SRCS = -.Dl $(SRCS): -.Dl \&\tsccs get $(REL) $@ -.Sh ENVIRONMENT -.Bl -tag -width Ar -.It Ev PROJECT -The PROJECT environment variable is checked by the -.Fl d -flag. If -it begins with a slash, it is taken directly; otherwise, -the home directory of a user of that name is -examined for a subdirectory -.Dq Li src -or -.Dq Li source . -If such a directory is found, it is used. -.El -.Sh SEE ALSO -.Xr what 1 -.Xr admin SCCS , -.Xr chghist SCCS , -.Xr comb SCCS , -.Xr delta SCCS , -.Xr get SCCS , -.Xr help SCCS , -.Xr prt SCCS , -.Xr rmdel SCCS , -.Xr sccsdiff SCCS , -.Rs -.%A Eric Allman -.%T "An Introduction to the Source Code Control System" -.Re -.Sh HISTORY -The -.Nm sccs -command -appeared in -.Bx 4.3 . -.Sh BUGS -It should be able to take directory arguments on pseudo-commands -like the -.Li SCCS -commands do. diff --git a/usr.bin/sccs/sccs.c b/usr.bin/sccs/sccs.c deleted file mode 100644 index 2dfd76d4bd4e..000000000000 --- a/usr.bin/sccs/sccs.c +++ /dev/null @@ -1,1621 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)sccs.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" - -/* -** SCCS.C -- human-oriented front end to the SCCS system. -** -** Without trying to add any functionality to speak of, this -** program tries to make SCCS a little more accessible to human -** types. The main thing it does is automatically put the -** string "SCCS/s." on the front of names. Also, it has a -** couple of things that are designed to shorten frequent -** combinations, e.g., "delget" which expands to a "delta" -** and a "get". -** -** This program can also function as a setuid front end. -** To do this, you should copy the source, renaming it to -** whatever you want, e.g., "syssccs". Change any defaults -** in the program (e.g., syssccs might default -d to -** "/usr/src/sys"). Then recompile and put the result -** as setuid to whomever you want. In this mode, sccs -** knows to not run setuid for certain programs in order -** to preserve security, and so forth. -** -** Usage: -** sccs [flags] command [args] -** -** Flags: -** -d represents a directory to search -** out of. It should be a full pathname -** for general usage. E.g., if is -** "/usr/src/sys", then a reference to the -** file "dev/bio.c" becomes a reference to -** "/usr/src/sys/dev/bio.c". -** -p prepends to the final component -** of the pathname. By default, this is -** "SCCS". For example, in the -d example -** above, the path then gets modified to -** "/usr/src/sys/dev/SCCS/s.bio.c". In -** more common usage (without the -d flag), -** "prog.c" would get modified to -** "SCCS/s.prog.c". In both cases, the -** "s." gets automatically prepended. -** -r run as the real user. -** -** Commands: -** admin, -** get, -** delta, -** rmdel, -** cdc, -** etc. Straight out of SCCS; only difference -** is that pathnames get modified as -** described above. -** enter Front end doing "sccs admin -i " -** create Macro for "enter" followed by "get". -** edit Macro for "get -e". -** unedit Removes a file being edited, knowing -** about p-files, etc. -** delget Macro for "delta" followed by "get". -** deledit Macro for "delta" followed by "get -e". -** branch Macro for "get -b -e", followed by "delta -** -s -n", followd by "get -e -t -g". -** diffs "diff" the specified version of files -** and the checked-out version. -** print Macro for "prs -e" followed by "get -p -m". -** tell List what files are being edited. -** info Print information about files being edited. -** clean Remove all files that can be -** regenerated from SCCS files. -** check Like info, but return exit status, for -** use in makefiles. -** fix Remove a top delta & reedit, but save -** the previous changes in that delta. -** -** Compilation Flags: -** UIDUSER -- determine who the user is by looking at the -** uid rather than the login name -- for machines -** where SCCS gets the user in this way. -** SCCSDIR -- if defined, forces the -d flag to take on -** this value. This is so that the setuid -** aspects of this program cannot be abused. -** This flag also disables the -p flag. -** SCCSPATH -- the default for the -p flag. -** MYNAME -- the title this program should print when it -** gives error messages. -** -** Compilation Instructions: -** cc -O -n -s sccs.c -** The flags listed above can be -D defined to simplify -** recompilation for variant versions. -** -** Author: -** Eric Allman, UCB/INGRES -** Copyright 1980 Regents of the University of California -*/ - - -/******************* Configuration Information ********************/ - -# ifndef SCCSPATH -# define SCCSPATH "SCCS" /* pathname in which to find s-files */ -# endif NOT SCCSPATH - -# ifndef MYNAME -# define MYNAME "sccs" /* name used for printing errors */ -# endif NOT MYNAME - -/**************** End of Configuration Information ****************/ - -typedef char bool; -# define TRUE 1 -# define FALSE 0 - -# define bitset(bit, word) ((bool) ((bit) & (word))) - -struct sccsprog -{ - char *sccsname; /* name of SCCS routine */ - short sccsoper; /* opcode, see below */ - short sccsflags; /* flags, see below */ - char *sccspath; /* pathname of binary implementing */ -}; - -/* values for sccsoper */ -# define PROG 0 /* call a program */ -# define CMACRO 1 /* command substitution macro */ -# define FIX 2 /* fix a delta */ -# define CLEAN 3 /* clean out recreatable files */ -# define UNEDIT 4 /* unedit a file */ -# define SHELL 5 /* call a shell file (like PROG) */ -# define DIFFS 6 /* diff between sccs & file out */ -# define DODIFF 7 /* internal call to diff program */ -# define ENTER 8 /* enter new files */ - -/* bits for sccsflags */ -# define NO_SDOT 0001 /* no s. on front of args */ -# define REALUSER 0002 /* protected (e.g., admin) */ - -/* modes for the "clean", "info", "check" ops */ -# define CLEANC 0 /* clean command */ -# define INFOC 1 /* info command */ -# define CHECKC 2 /* check command */ -# define TELLC 3 /* give list of files being edited */ - -/* -** Description of commands known to this program. -** First argument puts the command into a class. Second arg is -** info regarding treatment of this command. Third arg is a -** list of flags this command accepts from macros, etc. Fourth -** arg is the pathname of the implementing program, or the -** macro definition, or the arg to a sub-algorithm. -*/ - -struct sccsprog SccsProg[] = { - "admin", PROG, REALUSER, _PATH_SCCSADMIN, - "cdc", PROG, 0, _PATH_SCCSRMDEL, - "comb", PROG, 0, _PATH_SCCSCOMB, - "delta", PROG, 0, _PATH_SCCSDELTA, - "get", PROG, 0, _PATH_SCCSGET, - "help", PROG, NO_SDOT, _PATH_SCCSHELP, - "prs", PROG, 0, _PATH_SCCSPRS, - "prt", PROG, 0, _PATH_SCCSPRT, - "rmdel", PROG, REALUSER, _PATH_SCCSRMDEL, - "val", PROG, 0, _PATH_SCCSVAL, - "what", PROG, NO_SDOT, _PATH_SCCSWHAT, - "sccsdiff", SHELL, REALUSER, _PATH_SCCSDIFF, - "edit", CMACRO, NO_SDOT, "get -e", - "delget", CMACRO, NO_SDOT, "delta:mysrp/get:ixbeskcl -t", - "deledit", CMACRO, NO_SDOT, - "delta:mysrp -n/get:ixbskcl -e -t -g", - "fix", FIX, NO_SDOT, NULL, - "clean", CLEAN, REALUSER|NO_SDOT, - (char *) CLEANC, - "info", CLEAN, REALUSER|NO_SDOT, - (char *) INFOC, - "check", CLEAN, REALUSER|NO_SDOT, - (char *) CHECKC, - "tell", CLEAN, REALUSER|NO_SDOT, - (char *) TELLC, - "unedit", UNEDIT, NO_SDOT, NULL, - "diffs", DIFFS, NO_SDOT|REALUSER, - NULL, - "-diff", DODIFF, NO_SDOT|REALUSER, - _PATH_SCCSBDIFF, - "print", CMACRO, 0, "prs -e/get -p -m -s", - "branch", CMACRO, NO_SDOT, - "get:ixrc -e -b/delta: -s -n -ybranch-place-holder/get:pl -e -t -g", - "enter", ENTER, NO_SDOT, NULL, - "create", CMACRO, NO_SDOT, "enter/get:ixbeskcl -t", - NULL, -1, 0, NULL -}; - -/* one line from a p-file */ -struct pfile -{ - char *p_osid; /* old SID */ - char *p_nsid; /* new SID */ - char *p_user; /* user who did edit */ - char *p_date; /* date of get */ - char *p_time; /* time of get */ - char *p_aux; /* extra info at end */ -}; - -char *SccsPath = SCCSPATH; /* pathname of SCCS files */ -# ifdef SCCSDIR -char *SccsDir = SCCSDIR; /* directory to begin search from */ -# else -char *SccsDir = ""; -# endif -char MyName[] = MYNAME; /* name used in messages */ -int OutFile = -1; /* override output file for commands */ -bool RealUser; /* if set, running as real user */ -# ifdef DEBUG -bool Debug; /* turn on tracing */ -# endif -# ifndef V6 -extern char *getenv(); -# endif V6 - -char *gstrcat(), *strcat(); -char *gstrncat(), *strncat(); -char *gstrcpy(), *strcpy(); -#define FBUFSIZ BUFSIZ -#define PFILELG 120 - -main(argc, argv) - int argc; - char **argv; -{ - register char *p; - extern struct sccsprog *lookup(); - register int i; -# ifndef V6 -# ifndef SCCSDIR - register struct passwd *pw; - extern struct passwd *getpwnam(); - char buf[FBUFSIZ]; - - /* pull "SccsDir" out of the environment (possibly) */ - p = getenv("PROJECTDIR"); - if (p != NULL && p[0] != '\0') - { - if (p[0] == '/') - SccsDir = p; - else - { - pw = getpwnam(p); - if (pw == NULL) - { - usrerr("user %s does not exist", p); - exit(EX_USAGE); - } - gstrcpy(buf, pw->pw_dir, sizeof(buf)); - gstrcat(buf, "/src", sizeof(buf)); - if (access(buf, 0) < 0) - { - gstrcpy(buf, pw->pw_dir, sizeof(buf)); - gstrcat(buf, "/source", sizeof(buf)); - if (access(buf, 0) < 0) - { - usrerr("project %s has no source!", p); - exit(EX_USAGE); - } - } - SccsDir = buf; - } - } -# endif SCCSDIR -# endif V6 - - /* - ** Detect and decode flags intended for this program. - */ - - if (argc < 2) - { - fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName); - exit(EX_USAGE); - } - argv[argc] = NULL; - - if (lookup(argv[0]) == NULL) - { - while ((p = *++argv) != NULL) - { - if (*p != '-') - break; - switch (*++p) - { - case 'r': /* run as real user */ - setuid(getuid()); - RealUser++; - break; - -# ifndef SCCSDIR - case 'p': /* path of sccs files */ - SccsPath = ++p; - if (SccsPath[0] == '\0' && argv[1] != NULL) - SccsPath = *++argv; - break; - - case 'd': /* directory to search from */ - SccsDir = ++p; - if (SccsDir[0] == '\0' && argv[1] != NULL) - SccsDir = *++argv; - break; -# endif - -# ifdef DEBUG - case 'T': /* trace */ - Debug++; - break; -# endif - - default: - usrerr("unknown option -%s", p); - break; - } - } - if (SccsPath[0] == '\0') - SccsPath = "."; - } - - i = command(argv, FALSE, ""); - exit(i); -} - -/* -** COMMAND -- look up and perform a command -** -** This routine is the guts of this program. Given an -** argument vector, it looks up the "command" (argv[0]) -** in the configuration table and does the necessary stuff. -** -** Parameters: -** argv -- an argument vector to process. -** forkflag -- if set, fork before executing the command. -** editflag -- if set, only include flags listed in the -** sccsklets field of the command descriptor. -** arg0 -- a space-seperated list of arguments to insert -** before argv. -** -** Returns: -** zero -- command executed ok. -** else -- error status. -** -** Side Effects: -** none. -*/ - -command(argv, forkflag, arg0) - char **argv; - bool forkflag; - char *arg0; -{ - register struct sccsprog *cmd; - register char *p; - char buf[FBUFSIZ]; - extern struct sccsprog *lookup(); - char *nav[1000]; - char **np; - register char **ap; - register int i; - register char *q; - extern bool unedit(); - int rval = 0; - extern char *index(); - extern char *makefile(); - char *editchs; - extern char *tail(); - -# ifdef DEBUG - if (Debug) - { - printf("command:\n\t\"%s\"\n", arg0); - for (np = argv; *np != NULL; np++) - printf("\t\"%s\"\n", *np); - } -# endif - - /* - ** Copy arguments. - ** Copy from arg0 & if necessary at most one arg - ** from argv[0]. - */ - - np = ap = &nav[1]; - editchs = NULL; - for (p = arg0, q = buf; *p != '\0' && *p != '/'; ) - { - *np++ = q; - while (*p == ' ') - p++; - while (*p != ' ' && *p != '\0' && *p != '/' && *p != ':') - *q++ = *p++; - *q++ = '\0'; - if (*p == ':') - { - editchs = q; - while (*++p != '\0' && *p != '/' && *p != ' ') - *q++ = *p; - *q++ = '\0'; - } - } - *np = NULL; - if (*ap == NULL) - *np++ = *argv++; - - /* - ** Look up command. - ** At this point, *ap is the command name. - */ - - cmd = lookup(*ap); - if (cmd == NULL) - { - usrerr("Unknown command \"%s\"", *ap); - return (EX_USAGE); - } - - /* - ** Copy remaining arguments doing editing as appropriate. - */ - - for (; *argv != NULL; argv++) - { - p = *argv; - if (*p == '-') - { - if (p[1] == '\0' || editchs == NULL || index(editchs, p[1]) != NULL) - *np++ = p; - } - else - { - if (!bitset(NO_SDOT, cmd->sccsflags)) - p = makefile(p); - if (p != NULL) - *np++ = p; - } - } - *np = NULL; - - /* - ** Interpret operation associated with this command. - */ - - switch (cmd->sccsoper) - { - case SHELL: /* call a shell file */ - *ap = cmd->sccspath; - *--ap = "sh"; - rval = callprog(_PATH_BSHELL, cmd->sccsflags, ap, forkflag); - break; - - case PROG: /* call an sccs prog */ - rval = callprog(cmd->sccspath, cmd->sccsflags, ap, forkflag); - break; - - case CMACRO: /* command macro */ - /* step through & execute each part of the macro */ - for (p = cmd->sccspath; *p != '\0'; p++) - { - q = p; - while (*p != '\0' && *p != '/') - p++; - rval = command(&ap[1], *p != '\0', q); - if (rval != 0) - break; - } - break; - - case FIX: /* fix a delta */ - if (ap[1]==0 || strncmp(ap[1], "-r", 2)!=0) - { - usrerr("-r flag needed for fix command"); - rval = EX_USAGE; - break; - } - - /* get the version with all changes */ - rval = command(&ap[1], TRUE, "get -k"); - - /* now remove that version from the s-file */ - if (rval == 0) - rval = command(&ap[1], TRUE, "rmdel:r"); - - /* and edit the old version (but don't clobber new vers) */ - if (rval == 0) - rval = command(&ap[2], FALSE, "get -e -g"); - break; - - case CLEAN: - rval = clean((int) cmd->sccspath, ap); - break; - - case UNEDIT: - for (argv = np = &ap[1]; *argv != NULL; argv++) - { - if (unedit(*argv)) - *np++ = *argv; - } - *np = NULL; - - /* get all the files that we unedited successfully */ - if (np > &ap[1]) - rval = command(&ap[1], FALSE, "get"); - break; - - case DIFFS: /* diff between s-file & edit file */ - /* find the end of the flag arguments */ - for (np = &ap[1]; *np != NULL && **np == '-'; np++) - continue; - argv = np; - - /* for each file, do the diff */ - p = argv[1]; - while (*np != NULL) - { - /* messy, but we need a null terminated argv */ - *argv = *np++; - argv[1] = NULL; - i = dodiff(ap, tail(*argv)); - if (rval == 0) - rval = i; - argv[1] = p; - } - break; - - case DODIFF: /* internal diff call */ - setuid(getuid()); - for (np = ap; *np != NULL; np++) - { - if ((*np)[0] == '-' && (*np)[1] == 'C') - (*np)[1] = 'c'; - } - - /* insert "-" argument */ - np[1] = NULL; - np[0] = np[-1]; - np[-1] = "-"; - - /* execute the diff program of choice */ -# ifndef V6 - execvp("diff", ap); -# endif - execv(cmd->sccspath, argv); - syserr("cannot exec %s", cmd->sccspath); - exit(EX_OSERR); - - case ENTER: /* enter new sccs files */ - /* skip over flag arguments */ - for (np = &ap[1]; *np != NULL && **np == '-'; np++) - continue; - argv = np; - - /* do an admin for each file */ - p = argv[1]; - while (*np != NULL) - { - printf("\n%s:\n", *np); - strcpy(buf, "-i"); - gstrcat(buf, *np, sizeof(buf)); - ap[0] = buf; - argv[0] = tail(*np); - argv[1] = NULL; - rval = command(ap, TRUE, "admin"); - argv[1] = p; - if (rval == 0) - { - strcpy(buf, ","); - gstrcat(buf, tail(*np), sizeof(buf)); - if (link(*np, buf) >= 0) - unlink(*np); - } - np++; - } - break; - - default: - syserr("oper %d", cmd->sccsoper); - exit(EX_SOFTWARE); - } -# ifdef DEBUG - if (Debug) - printf("command: rval=%d\n", rval); -# endif - return (rval); -} - -/* -** LOOKUP -- look up an SCCS command name. -** -** Parameters: -** name -- the name of the command to look up. -** -** Returns: -** ptr to command descriptor for this command. -** NULL if no such entry. -** -** Side Effects: -** none. -*/ - -struct sccsprog * -lookup(name) - char *name; -{ - register struct sccsprog *cmd; - - for (cmd = SccsProg; cmd->sccsname != NULL; cmd++) - { - if (strcmp(cmd->sccsname, name) == 0) - return (cmd); - } - return (NULL); -} - -/* -** CALLPROG -- call a program -** -** Used to call the SCCS programs. -** -** Parameters: -** progpath -- pathname of the program to call. -** flags -- status flags from the command descriptors. -** argv -- an argument vector to pass to the program. -** forkflag -- if true, fork before calling, else just -** exec. -** -** Returns: -** The exit status of the program. -** Nothing if forkflag == FALSE. -** -** Side Effects: -** Can exit if forkflag == FALSE. -*/ - -callprog(progpath, flags, argv, forkflag) - char *progpath; - short flags; - char **argv; - bool forkflag; -{ - register int i; - register int wpid; - auto int st; - register int sigcode; - register int coredumped; - register const char *sigmsg; - char sigmsgbuf[10+1]; /* "Signal 127" + terminating '\0' */ - -# ifdef DEBUG - if (Debug) - { - printf("callprog:\n"); - for (i = 0; argv[i] != NULL; i++) - printf("\t\"%s\"\n", argv[i]); - } -# endif - - if (*argv == NULL) - return (-1); - - /* - ** Fork if appropriate. - */ - - if (forkflag) - { -# ifdef DEBUG - if (Debug) - printf("Forking\n"); -# endif - i = fork(); - if (i < 0) - { - syserr("cannot fork"); - exit(EX_OSERR); - } - else if (i > 0) - { - while ((wpid = wait(&st)) != -1 && wpid != i) - ; - if ((sigcode = st & 0377) == 0) - st = (st >> 8) & 0377; - else - { - coredumped = sigcode & 0200; - sigcode &= 0177; - if (sigcode != SIGINT && sigcode != SIGPIPE) - { - if (sigcode < NSIG) - sigmsg = sys_siglist[sigcode]; - else - { - sprintf(sigmsgbuf, "Signal %d", - sigcode); - sigmsg = sigmsgbuf; - } - fprintf(stderr, "sccs: %s: %s%s", argv[0], - sigmsg, - coredumped ? " - core dumped": ""); - } - st = EX_SOFTWARE; - } - if (OutFile >= 0) - { - close(OutFile); - OutFile = -1; - } - return (st); - } - } - else if (OutFile >= 0) - { - syserr("callprog: setting stdout w/o forking"); - exit(EX_SOFTWARE); - } - - /* set protection as appropriate */ - if (bitset(REALUSER, flags)) - setuid(getuid()); - - /* change standard input & output if needed */ - if (OutFile >= 0) - { - close(1); - dup(OutFile); - close(OutFile); - } - - /* call real SCCS program */ - execv(progpath, argv); - syserr("cannot execute %s", progpath); - exit(EX_UNAVAILABLE); - /*NOTREACHED*/ -} - -/* -** MAKEFILE -- make filename of SCCS file -** -** If the name passed is already the name of an SCCS file, -** just return it. Otherwise, munge the name into the name -** of the actual SCCS file. -** -** There are cases when it is not clear what you want to -** do. For example, if SccsPath is an absolute pathname -** and the name given is also an absolute pathname, we go -** for SccsPath (& only use the last component of the name -** passed) -- this is important for security reasons (if -** sccs is being used as a setuid front end), but not -** particularly intuitive. -** -** Parameters: -** name -- the file name to be munged. -** -** Returns: -** The pathname of the sccs file. -** NULL on error. -** -** Side Effects: -** none. -*/ - -char * -makefile(name) - char *name; -{ - register char *p; - char buf[3*FBUFSIZ]; - extern char *malloc(); - extern char *rindex(); - extern bool safepath(); - extern bool isdir(); - register char *q; - - p = rindex(name, '/'); - if (p == NULL) - p = name; - else - p++; - - /* - ** Check to see that the path is "safe", i.e., that we - ** are not letting some nasty person use the setuid part - ** of this program to look at or munge some presumably - ** hidden files. - */ - - if (SccsDir[0] == '/' && !safepath(name)) - return (NULL); - - /* - ** Create the base pathname. - */ - - /* first the directory part */ - if (SccsDir[0] != '\0' && name[0] != '/' && strncmp(name, "./", 2) != 0) - { - gstrcpy(buf, SccsDir, sizeof(buf)); - gstrcat(buf, "/", sizeof(buf)); - } - else - gstrcpy(buf, "", sizeof(buf)); - - /* then the head of the pathname */ - gstrncat(buf, name, p - name, sizeof(buf)); - q = &buf[strlen(buf)]; - - /* now copy the final part of the name, in case useful */ - gstrcpy(q, p, sizeof(buf)); - - /* so is it useful? */ - if (strncmp(p, "s.", 2) != 0 && !isdir(buf)) - { - /* sorry, no; copy the SCCS pathname & the "s." */ - gstrcpy(q, SccsPath, sizeof(buf)); - gstrcat(buf, "/s.", sizeof(buf)); - - /* and now the end of the name */ - gstrcat(buf, p, sizeof(buf)); - } - - /* if i haven't changed it, why did I do all this? */ - if (strcmp(buf, name) == 0) - p = name; - else - { - /* but if I have, squirrel it away */ - p = malloc(strlen(buf) + 1); - if (p == NULL) - { - perror("Sccs: no mem"); - exit(EX_OSERR); - } - strcpy(p, buf); - } - - return (p); -} - -/* -** ISDIR -- return true if the argument is a directory. -** -** Parameters: -** name -- the pathname of the file to check. -** -** Returns: -** TRUE if 'name' is a directory, FALSE otherwise. -** -** Side Effects: -** none. -*/ - -bool -isdir(name) - char *name; -{ - struct stat stbuf; - - return (stat(name, &stbuf) >= 0 && (stbuf.st_mode & S_IFMT) == S_IFDIR); -} - -/* -** SAFEPATH -- determine whether a pathname is "safe" -** -** "Safe" pathnames only allow you to get deeper into the -** directory structure, i.e., full pathnames and ".." are -** not allowed. -** -** Parameters: -** p -- the name to check. -** -** Returns: -** TRUE -- if the path is safe. -** FALSE -- if the path is not safe. -** -** Side Effects: -** Prints a message if the path is not safe. -*/ - -bool -safepath(p) - register char *p; -{ - extern char *index(); - - if (*p != '/') - { - while (strncmp(p, "../", 3) != 0 && strcmp(p, "..") != 0) - { - p = index(p, '/'); - if (p == NULL) - return (TRUE); - p++; - } - } - - printf("You may not use full pathnames or \"..\"\n"); - return (FALSE); -} - -/* -** CLEAN -- clean out recreatable files -** -** Any file for which an "s." file exists but no "p." file -** exists in the current directory is purged. -** -** Parameters: -** mode -- tells whether this came from a "clean", "info", or -** "check" command. -** argv -- the rest of the argument vector. -** -** Returns: -** none. -** -** Side Effects: -** Removes files in the current directory. -** Prints information regarding files being edited. -** Exits if a "check" command. -*/ - -clean(mode, argv) - int mode; - char **argv; -{ - struct direct *dir; - char buf[FBUFSIZ]; - char *bufend; - register DIR *dirp; - register char *basefile; - bool gotedit; - bool gotpfent; - FILE *pfp; - bool nobranch = FALSE; - extern struct pfile *getpfent(); - register struct pfile *pf; - register char **ap; - extern char *username(); - char *usernm = NULL; - char *subdir = NULL; - char *cmdname; - - /* - ** Process the argv - */ - - cmdname = *argv; - for (ap = argv; *++ap != NULL; ) - { - if (**ap == '-') - { - /* we have a flag */ - switch ((*ap)[1]) - { - case 'b': - nobranch = TRUE; - break; - - case 'u': - if ((*ap)[2] != '\0') - usernm = &(*ap)[2]; - else if (ap[1] != NULL && ap[1][0] != '-') - usernm = *++ap; - else - usernm = username(); - break; - } - } - else - { - if (subdir != NULL) - usrerr("too many args"); - else - subdir = *ap; - } - } - - /* - ** Find and open the SCCS directory. - */ - - gstrcpy(buf, SccsDir, sizeof(buf)); - if (buf[0] != '\0') - gstrcat(buf, "/", sizeof(buf)); - if (subdir != NULL) - { - gstrcat(buf, subdir, sizeof(buf)); - gstrcat(buf, "/", sizeof(buf)); - } - gstrcat(buf, SccsPath, sizeof(buf)); - bufend = &buf[strlen(buf)]; - - dirp = opendir(buf); - if (dirp == NULL) - { - usrerr("cannot open %s", buf); - return (EX_NOINPUT); - } - - /* - ** Scan the SCCS directory looking for s. files. - ** gotedit tells whether we have tried to clean any - ** files that are being edited. - */ - - gotedit = FALSE; - while (dir = readdir(dirp)) { - if (strncmp(dir->d_name, "s.", 2) != 0) - continue; - - /* got an s. file -- see if the p. file exists */ - gstrcpy(bufend, "/p.", sizeof(buf)); - basefile = bufend + 3; - gstrcpy(basefile, &dir->d_name[2], sizeof(buf)); - - /* - ** open and scan the p-file. - ** 'gotpfent' tells if we have found a valid p-file - ** entry. - */ - - pfp = fopen(buf, "r"); - gotpfent = FALSE; - if (pfp != NULL) - { - /* the file exists -- report it's contents */ - while ((pf = getpfent(pfp)) != NULL) - { - if (nobranch && isbranch(pf->p_nsid)) - continue; - if (usernm != NULL && strcmp(usernm, pf->p_user) != 0 && mode != CLEANC) - continue; - gotedit = TRUE; - gotpfent = TRUE; - if (mode == TELLC) - { - printf("%s\n", basefile); - break; - } - printf("%12s: being edited: ", basefile); - putpfent(pf, stdout); - } - fclose(pfp); - } - - /* the s. file exists and no p. file exists -- unlink the g-file */ - if (mode == CLEANC && !gotpfent) - { - char unlinkbuf[FBUFSIZ]; - gstrcpy(unlinkbuf, &dir->d_name[2], sizeof(unlinkbuf)); - unlink(unlinkbuf); - } - } - - /* cleanup & report results */ - closedir(dirp); - if (!gotedit && mode == INFOC) - { - printf("Nothing being edited"); - if (nobranch) - printf(" (on trunk)"); - if (usernm == NULL) - printf("\n"); - else - printf(" by %s\n", usernm); - } - if (mode == CHECKC) - exit(gotedit); - return (EX_OK); -} - -/* -** ISBRANCH -- is the SID a branch? -** -** Parameters: -** sid -- the sid to check. -** -** Returns: -** TRUE if the sid represents a branch. -** FALSE otherwise. -** -** Side Effects: -** none. -*/ - -isbranch(sid) - char *sid; -{ - register char *p; - int dots; - - dots = 0; - for (p = sid; *p != '\0'; p++) - { - if (*p == '.') - dots++; - if (dots > 1) - return (TRUE); - } - return (FALSE); -} - -/* -** UNEDIT -- unedit a file -** -** Checks to see that the current user is actually editting -** the file and arranges that s/he is not editting it. -** -** Parameters: -** fn -- the name of the file to be unedited. -** -** Returns: -** TRUE -- if the file was successfully unedited. -** FALSE -- if the file was not unedited for some -** reason. -** -** Side Effects: -** fn is removed -** entries are removed from pfile. -*/ - -bool -unedit(fn) - char *fn; -{ - register FILE *pfp; - char *cp, *pfn; - static char tfn[] = _PATH_TMP; - FILE *tfp; - register char *q; - bool delete = FALSE; - bool others = FALSE; - char *myname; - extern char *username(); - struct pfile *pent; - extern struct pfile *getpfent(); - char buf[PFILELG]; - extern char *makefile(), *rindex(), *tail(); - - /* make "s." filename & find the trailing component */ - pfn = makefile(fn); - if (pfn == NULL) - return (FALSE); - q = rindex(pfn, '/'); - if (q == NULL) - q = &pfn[-1]; - if (q[1] != 's' || q[2] != '.') - { - usrerr("bad file name \"%s\"", fn); - return (FALSE); - } - - /* turn "s." into "p." & try to open it */ - *++q = 'p'; - - pfp = fopen(pfn, "r"); - if (pfp == NULL) - { - printf("%12s: not being edited\n", fn); - return (FALSE); - } - - /* create temp file for editing p-file */ - mktemp(tfn); - tfp = fopen(tfn, "w"); - if (tfp == NULL) - { - usrerr("cannot create \"%s\"", tfn); - exit(EX_OSERR); - } - - /* figure out who I am */ - myname = username(); - - /* - ** Copy p-file to temp file, doing deletions as needed. - */ - - while ((pent = getpfent(pfp)) != NULL) - { - if (strcmp(pent->p_user, myname) == 0) - { - /* a match */ - delete++; - } - else - { - /* output it again */ - putpfent(pent, tfp); - others++; - } - } - - /* - * Before changing anything, make sure we can remove - * the file in question (assuming it exists). - */ - if (delete) { - extern int errno; - - cp = tail(fn); - errno = 0; - if (access(cp, 0) < 0 && errno != ENOENT) - goto bad; - if (errno == 0) - /* - * This is wrong, but the rest of the program - * has built in assumptions about "." as well, - * so why make unedit a special case? - */ - if (access(".", 2) < 0) { - bad: - printf("%12s: can't remove\n", cp); - fclose(tfp); - fclose(pfp); - unlink(tfn); - return (FALSE); - } - } - /* do final cleanup */ - if (others) - { - /* copy it back (perhaps it should be linked?) */ - if (freopen(tfn, "r", tfp) == NULL) - { - syserr("cannot reopen \"%s\"", tfn); - exit(EX_OSERR); - } - if (freopen(pfn, "w", pfp) == NULL) - { - usrerr("cannot create \"%s\"", pfn); - return (FALSE); - } - while (fgets(buf, sizeof buf, tfp) != NULL) - fputs(buf, pfp); - } - else - { - /* it's empty -- remove it */ - unlink(pfn); - } - fclose(tfp); - fclose(pfp); - unlink(tfn); - - /* actually remove the g-file */ - if (delete) - { - /* - * Since we've checked above, we can - * use the return from unlink to - * determine if the file existed or not. - */ - if (unlink(cp) >= 0) - printf("%12s: removed\n", cp); - return (TRUE); - } - else - { - printf("%12s: not being edited by you\n", fn); - return (FALSE); - } -} - -/* -** DODIFF -- diff an s-file against a g-file -** -** Parameters: -** getv -- argv for the 'get' command. -** gfile -- name of the g-file to diff against. -** -** Returns: -** Result of get. -** -** Side Effects: -** none. -*/ - -dodiff(getv, gfile) - char **getv; - char *gfile; -{ - int pipev[2]; - int rval; - register int i; - register int pid; - auto int st; - extern int errno; - sig_t osig; - - printf("\n------- %s -------\n", gfile); - fflush(stdout); - - /* create context for diff to run in */ - if (pipe(pipev) < 0) - { - syserr("dodiff: pipe failed"); - exit(EX_OSERR); - } - if ((pid = fork()) < 0) - { - syserr("dodiff: fork failed"); - exit(EX_OSERR); - } - else if (pid > 0) - { - /* in parent; run get */ - OutFile = pipev[1]; - close(pipev[0]); - rval = command(&getv[1], TRUE, "get:rcixt -s -k -p"); - osig = signal(SIGINT, SIG_IGN); - while (((i = wait(&st)) >= 0 && i != pid) || errno == EINTR) - errno = 0; - signal(SIGINT, osig); - /* ignore result of diff */ - } - else - { - /* in child, run diff */ - if (close(pipev[1]) < 0 || close(0) < 0 || - dup(pipev[0]) != 0 || close(pipev[0]) < 0) - { - syserr("dodiff: magic failed"); - exit(EX_OSERR); - } - command(&getv[1], FALSE, "-diff:elsfhbC"); - } - return (rval); -} - -/* -** TAIL -- return tail of filename. -** -** Parameters: -** fn -- the filename. -** -** Returns: -** a pointer to the tail of the filename; e.g., given -** "cmd/ls.c", "ls.c" is returned. -** -** Side Effects: -** none. -*/ - -char * -tail(fn) - register char *fn; -{ - register char *p; - - for (p = fn; *p != 0; p++) - if (*p == '/' && p[1] != '\0' && p[1] != '/') - fn = &p[1]; - return (fn); -} - -/* -** GETPFENT -- get an entry from the p-file -** -** Parameters: -** pfp -- p-file file pointer -** -** Returns: -** pointer to p-file struct for next entry -** NULL on EOF or error -** -** Side Effects: -** Each call wipes out results of previous call. -*/ - -struct pfile * -getpfent(pfp) - FILE *pfp; -{ - static struct pfile ent; - static char buf[PFILELG]; - register char *p; - extern char *nextfield(); - - if (fgets(buf, sizeof buf, pfp) == NULL) - return (NULL); - - ent.p_osid = p = buf; - ent.p_nsid = p = nextfield(p); - ent.p_user = p = nextfield(p); - ent.p_date = p = nextfield(p); - ent.p_time = p = nextfield(p); - ent.p_aux = p = nextfield(p); - - return (&ent); -} - - -char * -nextfield(p) - register char *p; -{ - if (p == NULL || *p == '\0') - return (NULL); - while (*p != ' ' && *p != '\n' && *p != '\0') - p++; - if (*p == '\n' || *p == '\0') - { - *p = '\0'; - return (NULL); - } - *p++ = '\0'; - return (p); -} - /* -** PUTPFENT -- output a p-file entry to a file -** -** Parameters: -** pf -- the p-file entry -** f -- the file to put it on. -** -** Returns: -** none. -** -** Side Effects: -** pf is written onto file f. -*/ - -putpfent(pf, f) - register struct pfile *pf; - register FILE *f; -{ - fprintf(f, "%s %s %s %s %s", pf->p_osid, pf->p_nsid, - pf->p_user, pf->p_date, pf->p_time); - if (pf->p_aux != NULL) - fprintf(f, " %s", pf->p_aux); - else - fprintf(f, "\n"); -} - -/* -** USRERR -- issue user-level error -** -** Parameters: -** f -- format string. -** p1-p3 -- parameters to a printf. -** -** Returns: -** -1 -** -** Side Effects: -** none. -*/ - -/*VARARGS1*/ -usrerr(f, p1, p2, p3) - char *f; -{ - fprintf(stderr, "\n%s: ", MyName); - fprintf(stderr, f, p1, p2, p3); - fprintf(stderr, "\n"); - - return (-1); -} - -/* -** SYSERR -- print system-generated error. -** -** Parameters: -** f -- format string to a printf. -** p1, p2, p3 -- parameters to f. -** -** Returns: -** never. -** -** Side Effects: -** none. -*/ - -/*VARARGS1*/ -syserr(f, p1, p2, p3) - char *f; -{ - extern int errno; - - fprintf(stderr, "\n%s SYSERR: ", MyName); - fprintf(stderr, f, p1, p2, p3); - fprintf(stderr, "\n"); - if (errno == 0) - exit(EX_SOFTWARE); - else - { - perror(NULL); - exit(EX_OSERR); - } -} - /* -** USERNAME -- return name of the current user -** -** Parameters: -** none -** -** Returns: -** name of current user -** -** Side Effects: -** none -*/ - -char * -username() -{ -# ifdef UIDUSER - extern struct passwd *getpwuid(); - register struct passwd *pw; - - pw = getpwuid(getuid()); - if (pw == NULL) - { - syserr("who are you? (uid=%d)", getuid()); - exit(EX_OSERR); - } - return (pw->pw_name); -# else - extern char *getlogin(); - register char *p; - - p = getenv("USER"); - if (p == NULL || p[0] == '\0') - p = getlogin(); - return (p); -# endif UIDUSER -} - -/* -** Guarded string manipulation routines; the last argument -** is the length of the buffer into which the strcpy or strcat -** is to be done. -*/ -char *gstrcat(to, from, length) - char *to, *from; - int length; -{ - if (strlen(from) + strlen(to) >= length) { - gstrbotch(to, from); - } - return(strcat(to, from)); -} - -char *gstrncat(to, from, n, length) - char *to, *from; - int n; - int length; -{ - if (n + strlen(to) >= length) { - gstrbotch(to, from); - } - return(strncat(to, from, n)); -} - -char *gstrcpy(to, from, length) - char *to, *from; - int length; -{ - if (strlen(from) >= length) { - gstrbotch(from, (char *)0); - } - return(strcpy(to, from)); -} -gstrbotch(str1, str2) - char *str1, *str2; -{ - usrerr("Filename(s) too long: %s %s", str1, str2); -} diff --git a/usr.bin/sort/sort.1 b/usr.bin/sort/sort.1 deleted file mode 100644 index 0ff0633ce190..000000000000 --- a/usr.bin/sort/sort.1 +++ /dev/null @@ -1,310 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the Institute of Electrical and Electronics Engineers, Inc. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sort.1 8.1 (Berkeley) 6/10/93 -.\" -.Dd June 10, 1993 -.Dt SORT 1 -.Os -.Sh NAME -.Nm sort -.Nd sort or merge text files -.Sh SYNOPSIS -.Nm sort -.Op Fl mubdfinrtx -.Oo -.Cm \(pl Ns Ar pos1 -.Op Fl Ns Ar pos2 -.Oc -.Ar ... -.Op Fl o Ar output -.Op Fl T Ar directory -.Op Ar file -.Ar ... -.Sh DESCRIPTION -The -.Nm sort -utility -sorts text files by lines. -Comparisons are based on one or more sort keys (or fields) extracted -from each line of input, and are performed -lexicographically. By default, if keys are not given, -.Nm sort -regards each input line as a single field. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl c -Check that the single input file is sorted lexicographically. -If the file is not sorted, -.Nm sort -sorts it and writes the sorted output to the standard output or the -filename specified by the -.Fl o -option. -.It Fl m -Merge only; the input files are assumed to be pre-sorted. -.It Fl o Ar output -The argument given is the name of an -.Ar output -file to -be used instead of the standard output. -This file -can be the same as one of the input files. -.It Fl T Ar directory -The argument -.Ar directory -is used for creating temporary files. -.It Fl u -Unique: suppress all but one in each set of lines -having equal keys. -If used with the -.Fl c -option, -check that there are no lines with duplicate keys. -.El -.Pp -The following options override the default ordering rules. -When ordering options appear independent of key field -specifications, the requested field ordering rules are -applied globally to all sort keys. -.\" When attached to a -.\" specific key -.\" (see -.\" .Fl k ) , -.\" the specified ordering options override -.\" all global ordering options for that key. -.Bl -tag -width indent -.It Fl d -Only blank space and alphanumeric characters -.\" according -.\" to the current setting of LC_CTYPE -are used -in making comparisons. -.It Fl f -Considers all lowercase characters that have uppercase -equivalents to be the same for purposes of -comparison. -.It Fl i -Ignore all non-printable characters. -.It Fl n -An initial numeric string, consisting of optional -blank space, optional minus sign, and zero or more -digits (including decimal point) -.\" with -.\" optional radix character and thousands -.\" separator -.\" (as defined in the current locale), -is sorted by arithmetic value. -The -.Fl n -option implies -the -.Fl b -option. (See below.) -Note that the -.Fl b -option -is only effective when key fields have been specified -and that -.Fl \&0 -is considered equal to zero. -.optional It Fl r -Reverse the sense of comparisons. -.El -.Pp -The treatment of field separators can be altered using the -options: -.Bl -tag -width indent -.It Fl b -Leading blank spaces are ignored when determining the starting -ending positions of a restricted sort key. -If the -.Fl b -option is specified before the first -.Cm \(pl Ns Ar pos1 -argument, it shall be applied to all -.Cm \(pl Ns Ar pos1 -arguments. -Otherwise, the -.Fl b -option can be -attached independently to each -.Cm \(pl Ns Ar pos1 -or -.Fl Ar pos2 -argument (see below). -.It Fl t Ar char -.Ar Char -is used as the field separator character; -.Ar char -is not considered to be part of a field (although it -can be included in a sort key). -Each occurrence of -.Ar char -is significant (for example, -.Dq Ar charchar -delimits an empty field). -If -.Fl t -is not specified, -blank space characters are used as default field -separators. -.It Cm \(pl Ns Ar pos1 -Designates the start position of a key field. -.It Fl Ns Ar pos1 -Designates the end position of a key field. -.El -.Pp -The following operands are available: -.Bl -tag -width indent -.Ar file -The pathname of a file to be sorted, merged, or checked. -If no file -operands are specified, or if -a file operand is -.Fl , -the standard input is used. -.Pp -A field is -defined as a minimal sequence of characters followed by a -field separator or a newline character. -By default, the first -blank space of a sequence of blank spaces acts as the field separator. -All blank spaces in a sequence of blank spaces are considered -to be part of the next field; for example, all blank spaces at -the beginning of a line are considered to be part of the -first field. -.Pp -Fields are specified -by the -.Cm \(pl Ns Ar pos1 -and -.Fl Ar pos2 -arguments. A missing -.Cm \(pl Ns Ar pos1 -argument defaults to the beginning of a line. -A missing -.Fl Ar pos2 -argument defaults to the end of a line. -.Pp -The arguments -.Cm \(pl Ns Ar pos1 -and -.Fl Ar pos2 -have the form -.Em m.n -followed by one or more of the options -.Fl b , d , f , i , -.Fl n , r . -A -.Cm \(pl Ns Ar pos1 -position specified by -.Em m.n -is interpreted to -mean the -.Em n Ns th -character in the -.Em m Ns \(pl1th -field. -A missing -.Em \&.n -means -.Ql \&.0 , -indicating the first character of the -.Em m Ns \(pl1th -field. -If the -.Fl b -option is in effect, -.Em n -is counted from the first -non-blank character in the -.Em m Ns \(pl1th -field; -.Em m Ns \&.0b -refers to the first -non-blank character in the -.Em m Ns \(pl1th -field. -.Pp -A -.Fl Ar pos2 -position specified by -.Em m.n -is interpreted to mean -the -.Em n Ns th -character (including separators) after the last -character of the -.Em m Ns th -field. -A missing -.Em \&.n -means -.Ql \&.0 , -indicating -the last character of the -.Em m Ns th -field. -If the -.Fl b -option -is in effect, -.Em n -is counted from the last leading blank character in -the -.Em m Ns \(pl1th -field; -.Em m Ns \&.1b -refers to the first non-blank character in the -.Em m Ns \(pl1th -field. -.Sh FILES -.Bl -tag -width Pa -compact -.It Pa /var/tmp/stm*, /tmp/* -Default temporary directories (in order of search). -.El -.Sh SEE ALSO -.Xr comm 1 , -.Xr uniq 1 , -.Xr join 1 -.Sh DIAGNOSTICS -.Sh BUGS -Lines which are longer than 4096 are discarded and processing continues. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/tip/acu.c b/usr.bin/tip/acu.c deleted file mode 100644 index f7bde997241a..000000000000 --- a/usr.bin/tip/acu.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -static acu_t *acu = NOACU; -static int conflag; -static void acuabort(); -static acu_t *acutype(); -static jmp_buf jmpbuf; -/* - * Establish connection for tip - * - * If DU is true, we should dial an ACU whose type is AT. - * The phone numbers are in PN, and the call unit is in CU. - * - * If the PN is an '@', then we consult the PHONES file for - * the phone numbers. This file is /etc/phones, unless overriden - * by an exported shell variable. - * - * The data base files must be in the format: - * host-name[ \t]*phone-number - * with the possibility of multiple phone numbers - * for a single host acting as a rotary (in the order - * found in the file). - */ -char * -connect() -{ - register char *cp = PN; - char *phnum, string[256]; - FILE *fd; - int tried = 0; - - if (!DU) { /* regular connect message */ - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), "", DV, "call completed"); - return (NOSTR); - } - /* - * @ =>'s use data base in PHONES environment variable - * otherwise, use /etc/phones - */ - signal(SIGINT, acuabort); - signal(SIGQUIT, acuabort); - if (setjmp(jmpbuf)) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - printf("\ncall aborted\n"); - logent(value(HOST), "", "", "call aborted"); - if (acu != NOACU) { - boolean(value(VERBOSE)) = FALSE; - if (conflag) - disconnect(NOSTR); - else - (*acu->acu_abort)(); - } - return ("interrupt"); - } - if ((acu = acutype(AT)) == NOACU) - return ("unknown ACU type"); - if (*cp != '@') { - while (*cp) { - for (phnum = cp; *cp && *cp != ','; cp++) - ; - if (*cp) - *cp++ = '\0'; - - if (conflag = (*acu->acu_dialer)(phnum, CU)) { - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), phnum, acu->acu_name, - "call completed"); - return (NOSTR); - } else - logent(value(HOST), phnum, acu->acu_name, - "call failed"); - tried++; - } - } else { - if ((fd = fopen(PH, "r")) == NOFILE) { - printf("%s: ", PH); - return ("can't open phone number file"); - } - while (fgets(string, sizeof(string), fd) != NOSTR) { - for (cp = string; !any(*cp, " \t\n"); cp++) - ; - if (*cp == '\n') { - fclose(fd); - return ("unrecognizable host name"); - } - *cp++ = '\0'; - if (strcmp(string, value(HOST))) - continue; - while (any(*cp, " \t")) - cp++; - if (*cp == '\n') { - fclose(fd); - return ("missing phone number"); - } - for (phnum = cp; *cp && *cp != ',' && *cp != '\n'; cp++) - ; - if (*cp) - *cp++ = '\0'; - - if (conflag = (*acu->acu_dialer)(phnum, CU)) { - fclose(fd); - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), phnum, acu->acu_name, - "call completed"); - return (NOSTR); - } else - logent(value(HOST), phnum, acu->acu_name, - "call failed"); - tried++; - } - fclose(fd); - } - if (!tried) - logent(value(HOST), "", acu->acu_name, "missing phone number"); - else - (*acu->acu_abort)(); - return (tried ? "call failed" : "missing phone number"); -} - -disconnect(reason) - char *reason; -{ - if (!conflag) { - logent(value(HOST), "", DV, "call terminated"); - return; - } - if (reason == NOSTR) { - logent(value(HOST), "", acu->acu_name, "call terminated"); - if (boolean(value(VERBOSE))) - printf("\r\ndisconnecting..."); - } else - logent(value(HOST), "", acu->acu_name, reason); - (*acu->acu_disconnect)(); -} - -static void -acuabort(s) -{ - signal(s, SIG_IGN); - longjmp(jmpbuf, 1); -} - -static acu_t * -acutype(s) - register char *s; -{ - register acu_t *p; - extern acu_t acutable[]; - - for (p = acutable; p->acu_name != '\0'; p++) - if (!strcmp(s, p->acu_name)) - return (p); - return (NOACU); -} diff --git a/usr.bin/tip/aculib/biz22.c b/usr.bin/tip/aculib/biz22.c deleted file mode 100644 index 93c5e53fc24e..000000000000 --- a/usr.bin/tip/aculib/biz22.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define DISCONNECT_CMD "\20\04" /* disconnection string */ - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * Dial up on a BIZCOMP Model 1022 with either - * tone dialing (mod = "V") - * pulse dialing (mod = "W") - */ -static int -biz_dialer(num, mod) - char *num, *mod; -{ - register int connected = 0; - char cbuf[40]; - static int cmd(), detect(); - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - /* - * Disable auto-answer and configure for tone/pulse - * dialing - */ - if (cmd("\02K\r")) { - printf("can't initialize bizcomp..."); - return (0); - } - strcpy(cbuf, "\02.\r"); - cbuf[1] = *mod; - if (cmd(cbuf)) { - printf("can't set dialing mode..."); - return (0); - } - strcpy(cbuf, "\02D"); - strcat(cbuf, num); - strcat(cbuf, "\r"); - write(FD, cbuf, strlen(cbuf)); - if (!detect("7\r")) { - printf("can't get dial tone..."); - return (0); - } - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * 2 \r or 7 \r failure - * 1 \r success - */ - connected = detect("1\r"); -#ifdef ACULOG - if (timeout) { - char line[80]; - - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz1022", line); - } -#endif - if (timeout) - biz22_disconnect(); /* insurance */ - return (connected); -} - -biz22w_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "W")); -} - -biz22f_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "V")); -} - -biz22_disconnect() -{ - int rw = 2; - - write(FD, DISCONNECT_CMD, 4); - sleep(2); - ioctl(FD, TIOCFLUSH, &rw); -} - -biz22_abort() -{ - - write(FD, "\02", 1); -} - -static void -sigALRM() -{ - - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cmd(s) - register char *s; -{ - sig_t f; - char c; - - write(FD, s, strlen(s)); - f = signal(SIGALRM, sigALRM); - if (setjmp(timeoutbuf)) { - biz22_abort(); - signal(SIGALRM, f); - return (1); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - signal(SIGALRM, f); - c &= 0177; - return (c != '\r'); -} - -static int -detect(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - biz22_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; - if (c != *s++) - return (0); - } - signal(SIGALRM, f); - return (timeout == 0); -} diff --git a/usr.bin/tip/aculib/biz31.c b/usr.bin/tip/aculib/biz31.c deleted file mode 100644 index 412974de6e9e..000000000000 --- a/usr.bin/tip/aculib/biz31.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define MAXRETRY 3 /* sync up retry count */ -#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */ - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * Dial up on a BIZCOMP Model 1031 with either - * tone dialing (mod = "f") - * pulse dialing (mod = "w") - */ -static int -biz_dialer(num, mod) - char *num, *mod; -{ - register int connected = 0; - - if (!bizsync(FD)) { - logent(value(HOST), "", "biz", "out of sync"); - printf("bizcomp out of sync\n"); - delock(uucplock); - exit(0); - } - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - echo("#\rk$\r$\n"); /* disable auto-answer */ - echo("$>$.$ #\r"); /* tone/pulse dialing */ - echo(mod); - echo("$\r$\n"); - echo("$>$.$ #\re$ "); /* disconnection sequence */ - echo(DISCONNECT_CMD); - echo("\r$\n$\r$\n"); - echo("$>$.$ #\rr$ "); /* repeat dial */ - echo(num); - echo("\r$\n"); - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * `^G NO CONNECTION\r\n^G\r\n' failure - * ` CONNECTION\r\n^G' success - */ - connected = detect(" "); -#ifdef ACULOG - if (timeout) { - char line[80]; - - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz", line); - } -#endif - if (!connected) - flush(" NO CONNECTION\r\n\07\r\n"); - else - flush("CONNECTION\r\n\07"); - if (timeout) - biz31_disconnect(); /* insurance */ - return (connected); -} - -biz31w_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "w")); -} - -biz31f_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "f")); -} - -biz31_disconnect() -{ - - write(FD, DISCONNECT_CMD, 4); - sleep(2); - ioctl(FD, TIOCFLUSH); -} - -biz31_abort() -{ - - write(FD, "\33", 1); -} - -static int -echo(s) - register char *s; -{ - char c; - - while (c = *s++) switch (c) { - - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -static void -sigALRM() -{ - - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -detect(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - printf("\07timeout waiting for reply\n"); - biz31_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - if (c != *s++) - break; - } - signal(SIGALRM, f); - return (timeout == 0); -} - -static int -flush(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - while (*s++) { - if (setjmp(timeoutbuf)) - break; - alarm(10); - read(FD, &c, 1); - alarm(0); - } - signal(SIGALRM, f); - timeout = 0; /* guard against disconnection */ -} - -/* - * This convoluted piece of code attempts to get - * the bizcomp in sync. If you don't have the capacity or nread - * call there are gory ways to simulate this. - */ -static int -bizsync(fd) -{ -#ifdef FIOCAPACITY - struct capacity b; -# define chars(b) ((b).cp_nbytes) -# define IOCTL FIOCAPACITY -#endif -#ifdef FIONREAD - long b; -# define chars(b) (b) -# define IOCTL FIONREAD -#endif - register int already = 0; - char buf[10]; - -retry: - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0) - ioctl(fd, TIOCFLUSH); - write(fd, "\rp>\r", 4); - sleep(1); - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) { - if (chars(b) != 10) { - nono: - if (already > MAXRETRY) - return (0); - write(fd, DISCONNECT_CMD, 4); - sleep(2); - already++; - goto retry; - } else { - read(fd, buf, 10); - if (strncmp(buf, "p >\r\n\r\n>", 8)) - goto nono; - } - } - return (1); -} diff --git a/usr.bin/tip/aculib/courier.c b/usr.bin/tip/aculib/courier.c deleted file mode 100644 index 85f7b0dd9b0d..000000000000 --- a/usr.bin/tip/aculib/courier.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Courier modem. - * Derived from Hayes driver. - */ -#include "tip.h" -#include - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf, intbuf; -static int coursync(); - -cour_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; -#ifdef ACULOG - char line[80]; -#endif - static int cour_connect(), cour_swallow(); - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - ioctl(FD, TIOCHPCL, 0); - /* - * Get in synch. - */ - if (!coursync()) { -badsynch: - printf("can't synchronize with courier\n"); -#ifdef ACULOG - logent(value(HOST), num, "courier", "can't synch up"); -#endif - return (0); - } - cour_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - cour_verbose_read(); -#endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); - if (!cour_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - cour_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - cour_write(FD, num, strlen(num)); - cour_write(FD, "\r", 1); - connected = cour_connect(); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "cour", line); - } -#endif - if (timeout) - cour_disconnect(); - return (connected); -} - -cour_disconnect() -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - coursync(); /* reset */ - close(FD); -} - -cour_abort() -{ - cour_write(FD, "\r", 1); /* send anything to abort the call */ - cour_disconnect(); -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cour_swallow(match) - register char *match; - { - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -struct baud_msg { - char *msg; - int baud; -} baud_msg[] = { - "", B300, - " 1200", B1200, - " 2400", B2400, - " 9600", B9600, - " 9600/ARQ", B9600, - 0, 0, -}; - -static int -cour_connect() -{ - char c; - int nc, nl, n; - struct sgttyb sb; - char dialer_buf[64]; - struct baud_msg *bm; - sig_t f; - - if (cour_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - timeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (cour_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = baud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - perror("TIOCSETP"); - goto error; - } - signal(SIGALRM, f); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } -error1: - printf("%s\r\n", dialer_buf); -error: - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the courier in sync. - */ -static int -coursync() -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - cour_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("coursync: (\"%s\")\n\r", buf); -#endif - if (index(buf, '0') || - (index(buf, 'O') && index(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - cour_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - cour_write(FD, "\rAT Z\r", 6); - return (0); -} - -cour_write(fd, cp, n) -int fd; -char *cp; -int n; -{ - struct sgttyb sb; -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - cour_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - cour_nap(); - } -} - -#ifdef DEBUG -cour_verbose_read() -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the courier 50 milliseconds between characters */ - -static int ringring; - -cour_nap() -{ - - static void cour_napx(); - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; - - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, cour_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} - -static void -cour_napx() -{ - ringring = 1; -} diff --git a/usr.bin/tip/aculib/df.c b/usr.bin/tip/aculib/df.c deleted file mode 100644 index 5f294f99eb56..000000000000 --- a/usr.bin/tip/aculib/df.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Dial the DF02-AC or DF03-AC - */ - -#include "tip.h" - -static jmp_buf Sjbuf; -static void timeout(); - -df02_dialer(num, acu) - char *num, *acu; -{ - - return (df_dialer(num, acu, 0)); -} - -df03_dialer(num, acu) - char *num, *acu; -{ - - return (df_dialer(num, acu, 1)); -} - -df_dialer(num, acu, df03) - char *num, *acu; - int df03; -{ - register int f = FD; - struct sgttyb buf; - int speed = 0, rw = 2; - char c = '\0'; - - ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ - if (setjmp(Sjbuf)) { - printf("connection timed out\r\n"); - df_disconnect(); - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); -#ifdef TIOCMSET - if (df03) { - int st = TIOCM_ST; /* secondary Transmit flag */ - - ioctl(f, TIOCGETP, &buf); - if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ - speed = buf.sg_ospeed; - buf.sg_ospeed = buf.sg_ispeed = B1200; - ioctl(f, TIOCSETP, &buf); - ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ - } else - ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ - } -#endif - signal(SIGALRM, timeout); - alarm(5 * strlen(num) + 10); - ioctl(f, TIOCFLUSH, &rw); - write(f, "\001", 1); - sleep(1); - write(f, "\002", 1); - write(f, num, strlen(num)); - read(f, &c, 1); -#ifdef TIOCMSET - if (df03 && speed) { - buf.sg_ispeed = buf.sg_ospeed = speed; - ioctl(f, TIOCSETP, &buf); - } -#endif - return (c == 'A'); -} - -df_disconnect() -{ - int rw = 2; - - write(FD, "\001", 1); - sleep(1); - ioctl(FD, TIOCFLUSH, &rw); -} - - -df_abort() -{ - - df_disconnect(); -} - - -static void -timeout() -{ - - longjmp(Sjbuf, 1); -} diff --git a/usr.bin/tip/aculib/dn11.c b/usr.bin/tip/aculib/dn11.c deleted file mode 100644 index 152b376b0362..000000000000 --- a/usr.bin/tip/aculib/dn11.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for dialing up on DN-11 - */ -#include "tip.h" - -int dn_abort(); -void alarmtr(); -static jmp_buf jmpbuf; -static int child = -1, dn; - -dn_dialer(num, acu) - char *num, *acu; -{ - extern errno; - char *p, *q, phone[40]; - int lt, nw, connected = 1; - register int timelim; - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - if ((dn = open(acu, 1)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(dn); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - nw = write(dn, num, lt = strlen(num)); - exit(nw != lt); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, 2)) < 0) { - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(dn); - return (0); - } - alarm(0); - ioctl(dn, TIOCHPCL, 0); - signal(SIGALRM, SIG_DFL); - while ((nw = wait(<)) != child && nw != -1) - ; - fflush(stdout); - close(dn); - if (lt != 0) { - close(FD); - return (0); - } - return (1); -} - -void -alarmtr() -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -dn_disconnect() -{ - - sleep(2); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -dn_abort() -{ - - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (dn > 0) - close(dn); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} diff --git a/usr.bin/tip/aculib/hayes.c b/usr.bin/tip/aculib/hayes.c deleted file mode 100644 index a2196f4f780e..000000000000 --- a/usr.bin/tip/aculib/hayes.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Hayes Modem - * (based on the old VenTel driver). - * The modem is expected to be strapped for "echo". - * Also, the switches enabling the DTR and CD lines - * must be set correctly. - * NOTICE: - * The easy way to hang up a modem is always simply to - * clear the DTR signal. However, if the +++ sequence - * (which switches the modem back to local mode) is sent - * before modem is hung up, removal of the DTR signal - * has no effect (except that it prevents the modem from - * recognizing commands). - * (by Helge Skrivervik, Calma Company, Sunnyvale, CA. 1984) - */ -/* - * TODO: - * It is probably not a good idea to switch the modem - * state between 'verbose' and terse (status messages). - * This should be kicked out and we should use verbose - * mode only. This would make it consistent with normal - * interactive use thru the command 'tip dialer'. - */ -#include "tip.h" - -#define min(a,b) ((a < b) ? a : b) - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; -static char gobble(); -#define DUMBUFLEN 40 -static char dumbuf[DUMBUFLEN]; - -#define DIALING 1 -#define IDLE 2 -#define CONNECTED 3 -#define FAILED 4 -static int state = IDLE; - -hay_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; - register int connected = 0; - char dummy; -#ifdef ACULOG - char line[80]; -#endif - if (hay_sync() == 0) /* make sure we can talk to the modem */ - return(0); - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - ioctl(FD, TIOCHPCL, 0); - ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */ - write(FD, "ATv0\r", 5); /* tell modem to use short status codes */ - gobble("\r"); - gobble("\r"); - write(FD, "ATTD", 4); /* send dial command */ - write(FD, num, strlen(num)); - state = DIALING; - write(FD, "\r", 1); - connected = 0; - if (gobble("\r")) { - if ((dummy = gobble("01234")) != '1') - error_rep(dummy); - else - connected = 1; - } - if (connected) - state = CONNECTED; - else { - state = FAILED; - return (connected); /* lets get out of here.. */ - } - ioctl(FD, TIOCFLUSH, 0); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "hayes", line); - } -#endif - if (timeout) - hay_disconnect(); /* insurance */ - return (connected); -} - - -hay_disconnect() -{ - char c; - int len, rlen; - - /* first hang up the modem*/ -#ifdef DEBUG - printf("\rdisconnecting modem....\n\r"); -#endif - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - goodbye(); -} - -hay_abort() -{ - - char c; - - write(FD, "\r", 1); /* send anything to abort the call */ - hay_disconnect(); -} - -static void -sigALRM() -{ - - printf("\07timeout waiting for reply\n\r"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static char -gobble(match) - register char *match; -{ - char c; - sig_t f; - int i, status = 0; - - f = signal(SIGALRM, sigALRM); - timeout = 0; -#ifdef DEBUG - printf("\ngobble: waiting for %s\n", match); -#endif - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - printf("%c 0x%x ", c, c); -#endif - for (i = 0; i < strlen(match); i++) - if (c == match[i]) - status = c; - } while (status == 0); - signal(SIGALRM, SIG_DFL); -#ifdef DEBUG - printf("\n"); -#endif - return (status); -} - -error_rep(c) - register char c; -{ - printf("\n\r"); - switch (c) { - - case '0': - printf("OK"); - break; - - case '1': - printf("CONNECT"); - break; - - case '2': - printf("RING"); - break; - - case '3': - printf("NO CARRIER"); - break; - - case '4': - printf("ERROR in input"); - break; - - case '5': - printf("CONNECT 1200"); - break; - - default: - printf("Unknown Modem error: %c (0x%x)", c, c); - } - printf("\n\r"); - return; -} - -/* - * set modem back to normal verbose status codes. - */ -goodbye() -{ - int len, rlen; - char c; - - ioctl(FD, TIOCFLUSH, &len); /* get rid of trash */ - if (hay_sync()) { - sleep(1); -#ifndef DEBUG - ioctl(FD, TIOCFLUSH, 0); -#endif - write(FD, "ATH0\r", 5); /* insurance */ -#ifndef DEBUG - c = gobble("03"); - if (c != '0' && c != '3') { - printf("cannot hang up modem\n\r"); - printf("please use 'tip dialer' to make sure the line is hung up\n\r"); - } -#endif - sleep(1); - ioctl(FD, FIONREAD, &len); -#ifdef DEBUG - printf("goodbye1: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%d): %s\r\n", rlen, dumbuf); -#endif - write(FD, "ATv1\r", 5); - sleep(1); -#ifdef DEBUG - ioctl(FD, FIONREAD, &len); - printf("goodbye2: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%d): %s\r\n", rlen, dumbuf); -#endif - } - ioctl(FD, TIOCFLUSH, 0); /* clear the input buffer */ - ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */ - close(FD); -} - -#define MAXRETRY 5 - -hay_sync() -{ - int len, retry = 0; - - while (retry++ <= MAXRETRY) { - write(FD, "AT\r", 3); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, dumbuf, min(len, DUMBUFLEN)); - if (index(dumbuf, '0') || - (index(dumbuf, 'O') && index(dumbuf, 'K'))) - return(1); -#ifdef DEBUG - dumbuf[len] = '\0'; - printf("hay_sync: (\"%s\") %d\n\r", dumbuf, retry); -#endif - } - ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCSDTR, 0); - } - printf("Cannot synchronize with hayes...\n\r"); - return(0); -} diff --git a/usr.bin/tip/aculib/t3000.c b/usr.bin/tip/aculib/t3000.c deleted file mode 100644 index 5e07359d4d05..000000000000 --- a/usr.bin/tip/aculib/t3000.c +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Telebit T3000 modem. - * Derived from Courier driver. - */ -#include "tip.h" -#include - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf, intbuf; -static int t3000_sync(); - -t3000_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; -#ifdef ACULOG - char line[80]; -#endif - static int t3000_connect(), t3000_swallow(); - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - ioctl(FD, TIOCHPCL, 0); - /* - * Get in synch. - */ - if (!t3000_sync()) { -badsynch: - printf("can't synchronize with t3000\n"); -#ifdef ACULOG - logent(value(HOST), num, "t3000", "can't synch up"); -#endif - return (0); - } - t3000_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - t3000_verbose_read(); -#endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - t3000_write(FD, "AT E0 H0 Q0 X4 V1\r", 18); - if (!t3000_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - t3000_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - t3000_write(FD, num, strlen(num)); - t3000_write(FD, "\r", 1); - connected = t3000_connect(); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "t3000", line); - } -#endif - if (timeout) - t3000_disconnect(); - return (connected); -} - -t3000_disconnect() -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - t3000_sync(); /* reset */ - close(FD); -} - -t3000_abort() -{ - t3000_write(FD, "\r", 1); /* send anything to abort the call */ - t3000_disconnect(); -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -t3000_swallow(match) - register char *match; - { - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -#ifndef B19200 /* XXX */ -#define B19200 EXTA -#define B38400 EXTB -#endif - -struct tbaud_msg { - char *msg; - int baud; - int baud2; -} tbaud_msg[] = { - "", B300, 0, - " 1200", B1200, 0, - " 2400", B2400, 0, - " 4800", B4800, 0, - " 9600", B9600, 0, - " 14400", B19200, B9600, - " 19200", B19200, B9600, - " 38400", B38400, B9600, - " 57600", B38400, B9600, - " 7512", B9600, 0, - " 1275", B2400, 0, - " 7200", B9600, 0, - " 12000", B19200, B9600, - 0, 0, 0, -}; - -static int -t3000_connect() -{ - char c; - int nc, nl, n; - struct sgttyb sb; - char dialer_buf[64]; - struct tbaud_msg *bm; - sig_t f; - - if (t3000_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - timeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (t3000_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = tbaud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - if (bm->baud2) { - sb.sg_ispeed = - sb.sg_ospeed = - bm->baud2; - if (ioctl(FD, - TIOCSETP, - &sb) >= 0) - goto isok; - } - perror("TIOCSETP"); - goto error; - } -isok: - signal(SIGALRM, f); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } -error1: - printf("%s\r\n", dialer_buf); -error: - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the t3000 in sync. - */ -static int -t3000_sync() -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - t3000_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(2); - ioctl(FD, FIONREAD, &len); -#if 1 -if (len == 0) len = 1; -#endif - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("t3000_sync: (\"%s\")\n\r", buf); -#endif - if (index(buf, '0') || - (index(buf, 'O') && index(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - t3000_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - t3000_write(FD, "\rAT Z\r", 6); - return (0); -} - -t3000_write(fd, cp, n) -int fd; -char *cp; -int n; -{ - struct sgttyb sb; - -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - t3000_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - t3000_nap(); - } -} - -#ifdef DEBUG -t3000_verbose_read() -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the t3000 50 milliseconds between characters */ - -static int ringring; - -t3000_nap() -{ - - static void t3000_napx(); - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; - - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, t3000_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} - -static void -t3000_napx() -{ - ringring = 1; -} diff --git a/usr.bin/tip/aculib/v3451.c b/usr.bin/tip/aculib/v3451.c deleted file mode 100644 index 1623a58458f8..000000000000 --- a/usr.bin/tip/aculib/v3451.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Vadic 3451 Modem - */ -#include "tip.h" - -static jmp_buf Sjbuf; - -v3451_dialer(num, acu) - register char *num; - char *acu; -{ - sig_t func; - int ok; - int slow = number(value(BAUDRATE)) < 1200, rw = 2; - char phone[50]; -#ifdef ACULOG - char line[80]; -#endif - static int expect(); - static void vawrite(); - - /* - * Get in synch - */ - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("\005\r", 2 + slow); - if (!expect("READY")) { - printf("can't synchronize with vadic 3451\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "can't synch up"); -#endif - return (0); - } - ioctl(FD, TIOCHPCL, 0); - sleep(1); - vawrite("D\r", 2 + slow); - if (!expect("NUMBER?")) { - printf("Vadic will not accept dial command\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept dial"); -#endif - return (0); - } - strcpy(phone, num); - strcat(phone, "\r"); - vawrite(phone, 1 + slow); - if (!expect(phone)) { - printf("Vadic will not accept phone number\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept number"); -#endif - return (0); - } - func = signal(SIGINT,SIG_IGN); - /* - * You cannot interrupt the Vadic when its dialing; - * even dropping DTR does not work (definitely a - * brain damaged design). - */ - vawrite("\r", 1 + slow); - vawrite("\r", 1 + slow); - if (!expect("DIALING:")) { - printf("Vadic failed to dial\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "failed to dial"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - ok = expect("ON LINE"); - signal(SIGINT, func); - if (!ok) { - printf("call failed\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "call failed"); -#endif - return (0); - } - ioctl(FD, TIOCFLUSH, &rw); - return (1); -} - -v3451_disconnect() -{ - - close(FD); -} - -v3451_abort() -{ - - close(FD); -} - -static void -vawrite(cp, delay) - register char *cp; - int delay; -{ - - for (; *cp; sleep(delay), cp++) - write(FD, cp, 1); -} - -static -expect(cp) - register char *cp; -{ - char buf[300]; - register char *rp = buf; - int timeout = 30, online = 0; - static int notin(); - static void alarmtr(); - - if (strcmp(cp, "\"\"") == 0) - return (1); - *rp = 0; - /* - * If we are waiting for the Vadic to complete - * dialing and get a connection, allow more time - * Unfortunately, the Vadic times out 24 seconds after - * the last digit is dialed - */ - online = strcmp(cp, "ON LINE") == 0; - if (online) - timeout = number(value(DIALTIMEOUT)); - signal(SIGALRM, alarmtr); - if (setjmp(Sjbuf)) - return (0); - alarm(timeout); - while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) { - if (online && notin("FAILED CALL", buf) == 0) - return (0); - if (read(FD, rp, 1) < 0) { - alarm(0); - return (0); - } - if (*rp &= 0177) - rp++; - *rp = '\0'; - } - alarm(0); - return (1); -} - -static void -alarmtr() -{ - longjmp(Sjbuf, 1); -} - -static int -notin(sh, lg) - char *sh, *lg; -{ - static int prefix(); - - for (; *lg; lg++) - if (prefix(sh, lg)) - return (0); - return (1); -} - -static -prefix(s1, s2) - register char *s1, *s2; -{ - register char c; - - while ((c = *s1++) == *s2++) - if (c == '\0') - return (1); - return (c == '\0'); -} diff --git a/usr.bin/tip/aculib/v831.c b/usr.bin/tip/aculib/v831.c deleted file mode 100644 index 38aa23045ec6..000000000000 --- a/usr.bin/tip/aculib/v831.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for dialing up on Vadic 831 - */ -#include "tip.h" - -int v831_abort(); -static void alarmtr(); -extern int errno; - -static jmp_buf jmpbuf; -static int child = -1; - -v831_dialer(num, acu) - char *num, *acu; -{ - int status, pid, connected = 1; - register int timelim; - static int dialit(); - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); -#ifdef DEBUG - printf ("(acu=%s)\n", acu); -#endif - if ((AC = open(acu, O_RDWR)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(AC); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - exit(dialit(num, acu) != 'A'); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, O_RDWR)) < 0) { -#ifdef DEBUG - printf("(after open, errno=%d)\n", errno); -#endif - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(AC); - return (0); - } - alarm(0); -#ifdef notdef - ioctl(AC, TIOCHPCL, 0); -#endif - signal(SIGALRM, SIG_DFL); - while ((pid = wait(&status)) != child && pid != -1) - ; - if (status) { - close(AC); - return (0); - } - return (1); -} - -static void -alarmtr() -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -v831_disconnect() -{ - struct sgttyb cntrl; - - sleep(2); -#ifdef DEBUG - printf("[disconnect: FD=%d]\n", FD); -#endif - if (FD > 0) { - ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = 0; - ioctl(FD, TIOCSETP, &cntrl); - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); - } - close(FD); -} - -v831_abort() -{ - -#ifdef DEBUG - printf("[abort: AC=%d]\n", AC); -#endif - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (AC > 0) - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); - close(AC); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -/* - * Sigh, this probably must be changed at each site. - */ -struct vaconfig { - char *vc_name; - char vc_rack; - char vc_modem; -} vaconfig[] = { - { "/dev/cua0",'4','0' }, - { "/dev/cua1",'4','1' }, - { 0 } -}; - -#define pc(x) (c = x, write(AC,&c,1)) -#define ABORT 01 -#define SI 017 -#define STX 02 -#define ETX 03 - -static int -dialit(phonenum, acu) - register char *phonenum; - char *acu; -{ - register struct vaconfig *vp; - struct sgttyb cntrl; - char c; - int i, two = 2; - static char *sanitize(); - - phonenum = sanitize(phonenum); -#ifdef DEBUG - printf ("(dial phonenum=%s)\n", phonenum); -#endif - if (*phonenum == '<' && phonenum[1] == 0) - return ('Z'); - for (vp = vaconfig; vp->vc_name; vp++) - if (strcmp(vp->vc_name, acu) == 0) - break; - if (vp->vc_name == 0) { - printf("Unable to locate dialer (%s)\n", acu); - return ('K'); - } - ioctl(AC, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = B2400; - cntrl.sg_flags = RAW | EVENP | ODDP; - ioctl(AC, TIOCSETP, &cntrl); - ioctl(AC, TIOCFLUSH, &two); - pc(STX); - pc(vp->vc_rack); - pc(vp->vc_modem); - while (*phonenum && *phonenum != '<') - pc(*phonenum++); - pc(SI); - pc(ETX); - sleep(1); - i = read(AC, &c, 1); -#ifdef DEBUG - printf("read %d chars, char=%c, errno %d\n", i, c, errno); -#endif - if (i != 1) - c = 'M'; - if (c == 'B' || c == 'G') { - char cc, oc = c; - - pc(ABORT); - read(AC, &cc, 1); -#ifdef DEBUG - printf("abort response=%c\n", cc); -#endif - c = oc; - v831_disconnect(); - } - close(AC); -#ifdef DEBUG - printf("dialit: returns %c\n", c); -#endif - return (c); -} - -static char * -sanitize(s) - register char *s; -{ - static char buf[128]; - register char *cp; - - for (cp = buf; *s; s++) { - if (!isdigit(*s) && *s == '<' && *s != '_') - continue; - if (*s == '_') - *s = '='; - *cp++ = *s; - } - *cp++ = 0; - return (buf); -} diff --git a/usr.bin/tip/aculib/ventel.c b/usr.bin/tip/aculib/ventel.c deleted file mode 100644 index 28b0d2828655..000000000000 --- a/usr.bin/tip/aculib/ventel.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Ventel Modem - * The Ventel is expected to be strapped for local echo (just like uucp) - */ -#include "tip.h" - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * some sleep calls have been replaced by this macro - * because some ventel modems require two s in less than - * a second in order to 'wake up'... yes, it is dirty... - */ -#define delay(num,denom) busyloop(CPUSPEED*num/denom) -#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */ -#define DELAY(n) { register long N = (n); while (--N > 0); } -busyloop(n) { DELAY(n); } - -ven_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; - register int connected = 0; - char *msg, *index(), line[80]; - static int gobble(), vensync(); - static void echo(); - - /* - * Get in synch with a couple of carriage returns - */ - if (!vensync(FD)) { - printf("can't synchronize with ventel\n"); -#ifdef ACULOG - logent(value(HOST), num, "ventel", "can't synch up"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - ioctl(FD, TIOCHPCL, 0); - echo("#k$\r$\n$D$I$A$L$:$ "); - for (cp = num; *cp; cp++) { - delay(1, 10); - write(FD, cp, 1); - } - delay(1, 10); - write(FD, "\r", 1); - gobble('\n', line); - if (gobble('\n', line)) - connected = gobble('!', line); - ioctl(FD, TIOCFLUSH); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "ventel", line); - } -#endif - if (timeout) - ven_disconnect(); /* insurance */ - if (connected || timeout || !boolean(value(VERBOSE))) - return (connected); - /* call failed, parse response for user */ - cp = index(line, '\r'); - if (cp) - *cp = '\0'; - for (cp = line; cp = index(cp, ' '); cp++) - if (cp[1] == ' ') - break; - if (cp) { - while (*cp == ' ') - cp++; - msg = cp; - while (*cp) { - if (isupper(*cp)) - *cp = tolower(*cp); - cp++; - } - printf("%s...", msg); - } - return (connected); -} - -ven_disconnect() -{ - - close(FD); -} - -ven_abort() -{ - - write(FD, "\03", 1); - close(FD); -} - -static void -echo(s) - register char *s; -{ - char c; - - while (c = *s++) switch (c) { - - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -gobble(match, response) - register char match; - char response[]; -{ - register char *cp = response; - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - *cp = '\0'; - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, cp, 1); - alarm(0); - c = (*cp++ &= 0177); -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c != '\n' && c != match); - signal(SIGALRM, SIG_DFL); - *cp = '\0'; - return (c == match); -} - -#define min(a,b) ((a)>(b)?(b):(a)) -/* - * This convoluted piece of code attempts to get - * the ventel in sync. If you don't have FIONREAD - * there are gory ways to simulate this. - */ -static int -vensync(fd) -{ - int already = 0, nread; - char buf[60]; - - /* - * Toggle DTR to force anyone off that might have left - * the modem connected, and insure a consistent state - * to start from. - * - * If you don't have the ioctl calls to diddle directly - * with DTR, you can always try setting the baud rate to 0. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - while (already < MAXRETRY) { - /* - * After reseting the modem, send it two \r's to - * autobaud on. Make sure to delay between them - * so the modem can frame the incoming characters. - */ - write(fd, "\r", 1); - delay(1,10); - write(fd, "\r", 1); - sleep(2); - if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) { - perror("tip: ioctl"); - continue; - } - while (nread > 0) { - read(fd, buf, min(nread, 60)); - if ((buf[nread - 1] & 0177) == '$') - return (1); - nread -= min(nread, 60); - } - sleep(1); - already++; - } - return (0); -} - diff --git a/usr.bin/tip/acutab.c b/usr.bin/tip/acutab.c deleted file mode 100644 index 112b43e4fe96..000000000000 --- a/usr.bin/tip/acutab.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(), - biz31f_dialer(), biz31_disconnect(), biz31_abort(), - biz31w_dialer(), - biz22f_dialer(), biz22_disconnect(), biz22_abort(), - biz22w_dialer(), - ven_dialer(), ven_disconnect(), ven_abort(), - hay_dialer(), hay_disconnect(), hay_abort(), - cour_dialer(), cour_disconnect(), cour_abort(), - t3000_dialer(), t3000_disconnect(), t3000_abort(), - v3451_dialer(), v3451_disconnect(), v3451_abort(), - v831_dialer(), v831_disconnect(), v831_abort(), - dn_dialer(), dn_disconnect(), dn_abort(); - -acu_t acutable[] = { -#if BIZ1031 - "biz31f", biz31f_dialer, biz31_disconnect, biz31_abort, - "biz31w", biz31w_dialer, biz31_disconnect, biz31_abort, -#endif -#if BIZ1022 - "biz22f", biz22f_dialer, biz22_disconnect, biz22_abort, - "biz22w", biz22w_dialer, biz22_disconnect, biz22_abort, -#endif -#if DF02 - "df02", df02_dialer, df_disconnect, df_abort, -#endif -#if DF03 - "df03", df03_dialer, df_disconnect, df_abort, -#endif -#if DN11 - "dn11", dn_dialer, dn_disconnect, dn_abort, -#endif -#ifdef VENTEL - "ventel",ven_dialer, ven_disconnect, ven_abort, -#endif -#ifdef HAYES - "hayes",hay_dialer, hay_disconnect, hay_abort, -#endif -#ifdef COURIER - "courier",cour_dialer, cour_disconnect, cour_abort, -#endif -#ifdef T3000 - "t3000",t3000_dialer, t3000_disconnect, t3000_abort, -#endif -#ifdef V3451 -#ifndef V831 - "vadic",v3451_dialer, v3451_disconnect, v3451_abort, -#endif - "v3451",v3451_dialer, v3451_disconnect, v3451_abort, -#endif -#ifdef V831 -#ifndef V3451 - "vadic",v831_dialer, v831_disconnect, v831_abort, -#endif - "v831",v831_dialer, v831_disconnect, v831_abort, -#endif - 0, 0, 0, 0 -}; - diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c deleted file mode 100644 index 63bfee2c52c5..000000000000 --- a/usr.bin/tip/cmds.c +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" -#include "pathnames.h" - -/* - * tip - * - * miscellaneous commands - */ - -int quant[] = { 60, 60, 24 }; - -char null = '\0'; -char *sep[] = { "second", "minute", "hour" }; -static char *argv[10]; /* argument vector for take and put */ - -void timeout(); /* timeout function called on alarm */ -void stopsnd(); /* SIGINT handler during file transfers */ -void intcopy(); /* interrupt routine for file transfers */ - -/* - * FTP - remote ==> local - * get a file from the remote host - */ -getfl(c) - char c; -{ - char buf[256], *cp, *expand(); - - putchar(c); - /* - * get the UNIX receiving file's name - */ - if (prompt("Local file name? ", copyname)) - return; - cp = expand(copyname); - if ((sfd = creat(cp, 0666)) < 0) { - printf("\r\n%s: cannot creat\r\n", copyname); - return; - } - - /* - * collect parameters - */ - if (prompt("List command for remote system? ", buf)) { - unlink(copyname); - return; - } - transfer(buf, sfd, value(EOFREAD)); -} - -/* - * Cu-like take command - */ -cu_take(cc) - char cc; -{ - int fd, argc; - char line[BUFSIZ], *expand(), *cp; - - if (prompt("[take] ", copyname)) - return; - if ((argc = args(copyname, argv)) < 1 || argc > 2) { - printf("usage: from [to]\r\n"); - return; - } - if (argc == 1) - argv[1] = argv[0]; - cp = expand(argv[1]); - if ((fd = creat(cp, 0666)) < 0) { - printf("\r\n%s: cannot create\r\n", argv[1]); - return; - } - sprintf(line, "cat %s;echo \01", argv[0]); - transfer(line, fd, "\01"); -} - -static jmp_buf intbuf; -/* - * Bulk transfer routine -- - * used by getfl(), cu_take(), and pipefile() - */ -transfer(buf, fd, eofchars) - char *buf, *eofchars; -{ - register int ct; - char c, buffer[BUFSIZ]; - register char *p = buffer; - register int cnt, eof; - time_t start; - sig_t f; - char r; - - pwrite(FD, buf, size(buf)); - quit = 0; - kill(pid, SIGIOT); - read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */ - - /* - * finish command - */ - r = '\r'; - pwrite(FD, &r, 1); - do - read(FD, &c, 1); - while ((c&0177) != '\n'); - ioctl(0, TIOCSETC, &defchars); - - (void) setjmp(intbuf); - f = signal(SIGINT, intcopy); - start = time(0); - for (ct = 0; !quit;) { - eof = read(FD, &c, 1) <= 0; - c &= 0177; - if (quit) - continue; - if (eof || any(c, eofchars)) - break; - if (c == 0) - continue; /* ignore nulls */ - if (c == '\r') - continue; - *p++ = c; - - if (c == '\n' && boolean(value(VERBOSE))) - printf("\r%d", ++ct); - if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) { - if (write(fd, buffer, cnt) != cnt) { - printf("\r\nwrite error\r\n"); - quit = 1; - } - p = buffer; - } - } - if (cnt = (p-buffer)) - if (write(fd, buffer, cnt) != cnt) - printf("\r\nwrite error\r\n"); - - if (boolean(value(VERBOSE))) - prtime(" lines transferred in ", time(0)-start); - ioctl(0, TIOCSETC, &tchars); - write(fildes[1], (char *)&ccc, 1); - signal(SIGINT, f); - close(fd); -} - -/* - * FTP - remote ==> local process - * send remote input to local process via pipe - */ -pipefile() -{ - int cpid, pdes[2]; - char buf[256]; - int status, p; - extern int errno; - - if (prompt("Local command? ", buf)) - return; - - if (pipe(pdes)) { - printf("can't establish pipe\r\n"); - return; - } - - if ((cpid = fork()) < 0) { - printf("can't fork!\r\n"); - return; - } else if (cpid) { - if (prompt("List command for remote system? ", buf)) { - close(pdes[0]), close(pdes[1]); - kill (cpid, SIGKILL); - } else { - close(pdes[0]); - signal(SIGPIPE, intcopy); - transfer(buf, pdes[1], value(EOFREAD)); - signal(SIGPIPE, SIG_DFL); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } - } else { - register int f; - - dup2(pdes[0], 0); - close(pdes[0]); - for (f = 3; f < 20; f++) - close(f); - execute(buf); - printf("can't execl!\r\n"); - exit(0); - } -} - -/* - * Interrupt service routine for FTP - */ -void -stopsnd() -{ - - stop = 1; - signal(SIGINT, SIG_IGN); -} - -/* - * FTP - local ==> remote - * send local file to remote host - * terminate transmission with pseudo EOF sequence - */ -sendfile(cc) - char cc; -{ - FILE *fd; - char *fnamex; - char *expand(); - - putchar(cc); - /* - * get file name - */ - if (prompt("Local file name? ", fname)) - return; - - /* - * look up file - */ - fnamex = expand(fname); - if ((fd = fopen(fnamex, "r")) == NULL) { - printf("%s: cannot open\r\n", fname); - return; - } - transmit(fd, value(EOFWRITE), NULL); - if (!boolean(value(ECHOCHECK))) { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ - } -} - -/* - * Bulk transfer routine to remote host -- - * used by sendfile() and cu_put() - */ -transmit(fd, eofchars, command) - FILE *fd; - char *eofchars, *command; -{ - char *pc, lastc; - int c, ccount, lcount; - time_t start_t, stop_t; - sig_t f; - - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - stop = 0; - f = signal(SIGINT, stopsnd); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - if (command != NULL) { - for (pc = command; *pc; pc++) - send(*pc); - if (boolean(value(ECHOCHECK))) - read(FD, (char *)&c, 1); /* trailing \n */ - else { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ - sleep(5); /* wait for remote stty to take effect */ - } - } - lcount = 0; - lastc = '\0'; - start_t = time(0); - while (1) { - ccount = 0; - do { - c = getc(fd); - if (stop) - goto out; - if (c == EOF) - goto out; - if (c == 0177 && !boolean(value(RAWFTP))) - continue; - lastc = c; - if (c < 040) { - if (c == '\n') { - if (!boolean(value(RAWFTP))) - c = '\r'; - } - else if (c == '\t') { - if (!boolean(value(RAWFTP))) { - if (boolean(value(TABEXPAND))) { - send(' '); - while ((++ccount % 8) != 0) - send(' '); - continue; - } - } - } else - if (!boolean(value(RAWFTP))) - continue; - } - send(c); - } while (c != '\r' && !boolean(value(RAWFTP))); - if (boolean(value(VERBOSE))) - printf("\r%d", ++lcount); - if (boolean(value(ECHOCHECK))) { - timedout = 0; - alarm((int)value(ETIMEOUT)); - do { /* wait for prompt */ - read(FD, (char *)&c, 1); - if (timedout || stop) { - if (timedout) - printf("\r\ntimed out at eol\r\n"); - alarm(0); - goto out; - } - } while ((c&0177) != character(value(PROMPT))); - alarm(0); - } - } -out: - if (lastc != '\n' && !boolean(value(RAWFTP))) - send('\r'); - for (pc = eofchars; *pc; pc++) - send(*pc); - stop_t = time(0); - fclose(fd); - signal(SIGINT, f); - if (boolean(value(VERBOSE))) - if (boolean(value(RAWFTP))) - prtime(" chars transferred in ", stop_t-start_t); - else - prtime(" lines transferred in ", stop_t-start_t); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); -} - -/* - * Cu-like put command - */ -cu_put(cc) - char cc; -{ - FILE *fd; - char line[BUFSIZ]; - int argc; - char *expand(); - char *copynamex; - - if (prompt("[put] ", copyname)) - return; - if ((argc = args(copyname, argv)) < 1 || argc > 2) { - printf("usage: from [to]\r\n"); - return; - } - if (argc == 1) - argv[1] = argv[0]; - copynamex = expand(argv[0]); - if ((fd = fopen(copynamex, "r")) == NULL) { - printf("%s: cannot open\r\n", copynamex); - return; - } - if (boolean(value(ECHOCHECK))) - sprintf(line, "cat>%s\r", argv[1]); - else - sprintf(line, "stty -echo;cat>%s;stty echo\r", argv[1]); - transmit(fd, "\04", line); -} - -/* - * FTP - send single character - * wait for echo & handle timeout - */ -send(c) - char c; -{ - char cc; - int retry = 0; - - cc = c; - pwrite(FD, &cc, 1); -#ifdef notdef - if (number(value(CDELAY)) > 0 && c != '\r') - nap(number(value(CDELAY))); -#endif - if (!boolean(value(ECHOCHECK))) { -#ifdef notdef - if (number(value(LDELAY)) > 0 && c == '\r') - nap(number(value(LDELAY))); -#endif - return; - } -tryagain: - timedout = 0; - alarm((int)value(ETIMEOUT)); - read(FD, &cc, 1); - alarm(0); - if (timedout) { - printf("\r\ntimeout error (%s)\r\n", ctrl(c)); - if (retry++ > 3) - return; - pwrite(FD, &null, 1); /* poke it */ - goto tryagain; - } -} - -void -timeout() -{ - signal(SIGALRM, timeout); - timedout = 1; -} - -/* - * Stolen from consh() -- puts a remote file on the output of a local command. - * Identical to consh() except for where stdout goes. - */ -pipeout(c) -{ - char buf[256]; - int cpid, status, p; - time_t start; - - putchar(c); - if (prompt("Local command? ", buf)) - return; - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - /* - * Set up file descriptors in the child and - * let it go... - */ - if ((cpid = fork()) < 0) - printf("can't fork!\r\n"); - else if (cpid) { - start = time(0); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } else { - register int i; - - dup2(FD, 1); - for (i = 3; i < 20; i++) - close(i); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - execute(buf); - printf("can't find `%s'\r\n", buf); - exit(0); - } - if (boolean(value(VERBOSE))) - prtime("away for ", time(0)-start); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); -} - -#ifdef CONNECT -/* - * Fork a program with: - * 0 <-> remote tty in - * 1 <-> remote tty out - * 2 <-> local tty out - */ -consh(c) -{ - char buf[256]; - int cpid, status, p; - time_t start; - - putchar(c); - if (prompt("Local command? ", buf)) - return; - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - /* - * Set up file descriptors in the child and - * let it go... - */ - if ((cpid = fork()) < 0) - printf("can't fork!\r\n"); - else if (cpid) { - start = time(0); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } else { - register int i; - - dup2(FD, 0); - dup2(3, 1); - for (i = 3; i < 20; i++) - close(i); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - execute(buf); - printf("can't find `%s'\r\n", buf); - exit(0); - } - if (boolean(value(VERBOSE))) - prtime("away for ", time(0)-start); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); -} -#endif - -/* - * Escape to local shell - */ -shell() -{ - int shpid, status; - extern char **environ; - char *cp; - - printf("[sh]\r\n"); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - unraw(); - if (shpid = fork()) { - while (shpid != wait(&status)); - raw(); - printf("\r\n!\r\n"); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - return; - } else { - signal(SIGQUIT, SIG_DFL); - signal(SIGINT, SIG_DFL); - if ((cp = rindex(value(SHELL), '/')) == NULL) - cp = value(SHELL); - else - cp++; - shell_uid(); - execl(value(SHELL), cp, 0); - printf("\r\ncan't execl!\r\n"); - exit(1); - } -} - -/* - * TIPIN portion of scripting - * initiate the conversation with TIPOUT - */ -setscript() -{ - char c; - /* - * enable TIPOUT side for dialogue - */ - kill(pid, SIGEMT); - if (boolean(value(SCRIPT))) - write(fildes[1], value(RECORD), size(value(RECORD))); - write(fildes[1], "\n", 1); - /* - * wait for TIPOUT to finish - */ - read(repdes[0], &c, 1); - if (c == 'n') - printf("can't create %s\r\n", value(RECORD)); -} - -/* - * Change current working directory of - * local portion of tip - */ -chdirectory() -{ - char dirname[80]; - register char *cp = dirname; - - if (prompt("[cd] ", dirname)) { - if (stoprompt) - return; - cp = value(HOME); - } - if (chdir(cp) < 0) - printf("%s: bad directory\r\n", cp); - printf("!\r\n"); -} - -tipabort(msg) - char *msg; -{ - - kill(pid, SIGTERM); - disconnect(msg); - if (msg != NOSTR) - printf("\r\n%s", msg); - printf("\r\n[EOT]\r\n"); - daemon_uid(); - (void)uu_unlock(uucplock); - unraw(); - exit(0); -} - -finish() -{ - char *dismsg; - - if ((dismsg = value(DISCONNECT)) != NOSTR) { - write(FD, dismsg, strlen(dismsg)); - sleep(5); - } - tipabort(NOSTR); -} - -void -intcopy() -{ - raw(); - quit = 1; - longjmp(intbuf, 1); -} - -execute(s) - char *s; -{ - register char *cp; - - if ((cp = rindex(value(SHELL), '/')) == NULL) - cp = value(SHELL); - else - cp++; - shell_uid(); - execl(value(SHELL), cp, "-c", s, 0); -} - -args(buf, a) - char *buf, *a[]; -{ - register char *p = buf, *start; - register char **parg = a; - register int n = 0; - - do { - while (*p && (*p == ' ' || *p == '\t')) - p++; - start = p; - if (*p) - *parg = p; - while (*p && (*p != ' ' && *p != '\t')) - p++; - if (p != start) - parg++, n++; - if (*p) - *p++ = '\0'; - } while (*p); - - return(n); -} - -prtime(s, a) - char *s; - time_t a; -{ - register i; - int nums[3]; - - for (i = 0; i < 3; i++) { - nums[i] = (int)(a % quant[i]); - a /= quant[i]; - } - printf("%s", s); - while (--i >= 0) - if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0) - printf("%d %s%c ", nums[i], sep[i], - nums[i] == 1 ? '\0' : 's'); - printf("\r\n!\r\n"); -} - -variable() -{ - char buf[256]; - - if (prompt("[set] ", buf)) - return; - vlex(buf); - if (vtable[BEAUTIFY].v_access&CHANGED) { - vtable[BEAUTIFY].v_access &= ~CHANGED; - kill(pid, SIGSYS); - } - if (vtable[SCRIPT].v_access&CHANGED) { - vtable[SCRIPT].v_access &= ~CHANGED; - setscript(); - /* - * So that "set record=blah script" doesn't - * cause two transactions to occur. - */ - if (vtable[RECORD].v_access&CHANGED) - vtable[RECORD].v_access &= ~CHANGED; - } - if (vtable[RECORD].v_access&CHANGED) { - vtable[RECORD].v_access &= ~CHANGED; - if (boolean(value(SCRIPT))) - setscript(); - } - if (vtable[TAND].v_access&CHANGED) { - vtable[TAND].v_access &= ~CHANGED; - if (boolean(value(TAND))) - tandem("on"); - else - tandem("off"); - } - if (vtable[LECHO].v_access&CHANGED) { - vtable[LECHO].v_access &= ~CHANGED; - HD = boolean(value(LECHO)); - } - if (vtable[PARITY].v_access&CHANGED) { - vtable[PARITY].v_access &= ~CHANGED; - setparity(); - } -} - -/* - * Turn tandem mode on or off for remote tty. - */ -tandem(option) - char *option; -{ - struct sgttyb rmtty; - - ioctl(FD, TIOCGETP, &rmtty); - if (strcmp(option,"on") == 0) { - rmtty.sg_flags |= TANDEM; - arg.sg_flags |= TANDEM; - } else { - rmtty.sg_flags &= ~TANDEM; - arg.sg_flags &= ~TANDEM; - } - ioctl(FD, TIOCSETP, &rmtty); - ioctl(0, TIOCSETP, &arg); -} - -/* - * Send a break. - */ -genbrk() -{ - - ioctl(FD, TIOCSBRK, NULL); - sleep(1); - ioctl(FD, TIOCCBRK, NULL); -} - -/* - * Suspend tip - */ -suspend(c) - char c; -{ - - unraw(); - kill(c == CTRL('y') ? getpid() : 0, SIGTSTP); - raw(); -} - -/* - * expand a file name if it includes shell meta characters - */ - -char * -expand(name) - char name[]; -{ - static char xname[BUFSIZ]; - char cmdbuf[BUFSIZ]; - register int pid, l, rc; - register char *cp, *Shell; - int s, pivec[2], (*sigint)(); - - if (!anyof(name, "~{[*?$`'\"\\")) - return(name); - /* sigint = signal(SIGINT, SIG_IGN); */ - if (pipe(pivec) < 0) { - perror("pipe"); - /* signal(SIGINT, sigint) */ - return(name); - } - sprintf(cmdbuf, "echo %s", name); - if ((pid = vfork()) == 0) { - Shell = value(SHELL); - if (Shell == NOSTR) - Shell = _PATH_BSHELL; - close(pivec[0]); - close(1); - dup(pivec[1]); - close(pivec[1]); - close(2); - shell_uid(); - execl(Shell, Shell, "-c", cmdbuf, 0); - _exit(1); - } - if (pid == -1) { - perror("fork"); - close(pivec[0]); - close(pivec[1]); - return(NOSTR); - } - close(pivec[1]); - l = read(pivec[0], xname, BUFSIZ); - close(pivec[0]); - while (wait(&s) != pid); - ; - s &= 0377; - if (s != 0 && s != SIGPIPE) { - fprintf(stderr, "\"Echo\" failed\n"); - return(NOSTR); - } - if (l < 0) { - perror("read"); - return(NOSTR); - } - if (l == 0) { - fprintf(stderr, "\"%s\": No match\n", name); - return(NOSTR); - } - if (l == BUFSIZ) { - fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name); - return(NOSTR); - } - xname[l] = 0; - for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--) - ; - *++cp = '\0'; - return(xname); -} - -/* - * Are any of the characters in the two strings the same? - */ - -anyof(s1, s2) - register char *s1, *s2; -{ - register int c; - - while (c = *s1++) - if (any(c, s2)) - return(1); - return(0); -} diff --git a/usr.bin/tip/cmdtab.c b/usr.bin/tip/cmdtab.c deleted file mode 100644 index f6bcb60210f8..000000000000 --- a/usr.bin/tip/cmdtab.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern int shell(), getfl(), sendfile(), chdirectory(); -extern int finish(), help(), pipefile(), pipeout(), consh(), variable(); -extern int cu_take(), cu_put(), dollar(), genbrk(), suspend(); - -esctable_t etable[] = { - { '!', NORM, "shell", shell }, - { '<', NORM, "receive file from remote host", getfl }, - { '>', NORM, "send file to remote host", sendfile }, - { 't', NORM, "take file from remote UNIX", cu_take }, - { 'p', NORM, "put file to remote UNIX", cu_put }, - { '|', NORM, "pipe remote file", pipefile }, - { '$', NORM, "pipe local command to remote host", pipeout }, -#ifdef CONNECT - { 'C', NORM, "connect program to remote host",consh }, -#endif - { 'c', NORM, "change directory", chdirectory }, - { '.', NORM, "exit from tip", finish }, - {CTRL('d'),NORM,"exit from tip", finish }, - {CTRL('y'),NORM,"suspend tip (local+remote)", suspend }, - {CTRL('z'),NORM,"suspend tip (local only)", suspend }, - { 's', NORM, "set variable", variable }, - { '?', NORM, "get this summary", help }, - { '#', NORM, "send break", genbrk }, - { 0, 0, 0 } -}; diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c deleted file mode 100644 index fae2b3cc7524..000000000000 --- a/usr.bin/tip/cu.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -void cleanup(); - -/* - * Botch the interface to look like cu's - */ -cumain(argc, argv) - char *argv[]; -{ - register int i; - static char sbuf[12]; - - if (argc < 2) { - printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n"); - exit(8); - } - CU = DV = NOSTR; - BR = DEFBR; - for (; argc > 1; argv++, argc--) { - if (argv[1][0] != '-') - PN = argv[1]; - else switch (argv[1][1]) { - - case 't': - HW = 1, DU = -1; - --argc; - continue; - - case 'a': - CU = argv[2]; ++argv; --argc; - break; - - case 's': - if (argc < 3 || speed(atoi(argv[2])) == 0) { - fprintf(stderr, "cu: unsupported speed %s\n", - argv[2]); - exit(3); - } - BR = atoi(argv[2]); ++argv; --argc; - break; - - case 'l': - DV = argv[2]; ++argv; --argc; - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (CU) - CU[strlen(CU)-1] = argv[1][1]; - if (DV) - DV[strlen(DV)-1] = argv[1][1]; - break; - - default: - printf("Bad flag %s", argv[1]); - break; - } - } - signal(SIGINT, cleanup); - signal(SIGQUIT, cleanup); - signal(SIGHUP, cleanup); - signal(SIGTERM, cleanup); - - /* - * The "cu" host name is used to define the - * attributes of the generic dialer. - */ - (void)sprintf(sbuf, "cu%d", BR); - if ((i = hunt(sbuf)) == 0) { - printf("all ports busy\n"); - exit(3); - } - if (i == -1) { - printf("link down\n"); - (void)uu_unlock(uucplock); - exit(3); - } - setbuf(stdout, NULL); - loginit(); - user_uid(); - vinit(); - setparity("none"); - boolean(value(VERBOSE)) = 0; - if (HW) - ttysetup(speed(BR)); - if (connect()) { - printf("Connect failed\n"); - daemon_uid(); - (void)uu_unlock(uucplock); - exit(1); - } - if (!HW) - ttysetup(speed(BR)); -} diff --git a/usr.bin/tip/hunt.c b/usr.bin/tip/hunt.c deleted file mode 100644 index 650ac2601fd4..000000000000 --- a/usr.bin/tip/hunt.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern char *getremote(); -extern char *rindex(); - -static jmp_buf deadline; -static int deadfl; - -void -dead() -{ - deadfl = 1; - longjmp(deadline, 1); -} - -hunt(name) - char *name; -{ - register char *cp; - sig_t f; - - f = signal(SIGALRM, dead); - while (cp = getremote(name)) { - deadfl = 0; - uucplock = rindex(cp, '/')+1; - if (uu_lock(uucplock) < 0) - continue; - /* - * Straight through call units, such as the BIZCOMP, - * VADIC and the DF, must indicate they're hardwired in - * order to get an open file descriptor placed in FD. - * Otherwise, as for a DN-11, the open will have to - * be done in the "open" routine. - */ - if (!HW) - break; - if (setjmp(deadline) == 0) { - alarm(10); - FD = open(cp, O_RDWR); - } - alarm(0); - if (FD < 0) { - perror(cp); - deadfl = 1; - } - if (!deadfl) { - ioctl(FD, TIOCEXCL, 0); - ioctl(FD, TIOCHPCL, 0); - signal(SIGALRM, SIG_DFL); - return ((int)cp); - } - (void)uu_unlock(uucplock); - } - signal(SIGALRM, f); - return (deadfl ? -1 : (int)cp); -} diff --git a/usr.bin/tip/log.c b/usr.bin/tip/log.c deleted file mode 100644 index 5da2c45e4d57..000000000000 --- a/usr.bin/tip/log.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#ifdef ACULOG -static FILE *flog = NULL; - -/* - * Log file maintenance routines - */ - -logent(group, num, acu, message) - char *group, *num, *acu, *message; -{ - char *user, *timestamp; - struct passwd *pwd; - long t; - - if (flog == NULL) - return; - if (flock(fileno(flog), LOCK_EX) < 0) { - perror("tip: flock"); - return; - } - if ((user = getlogin()) == NOSTR) - if ((pwd = getpwuid(getuid())) == NOPWD) - user = "???"; - else - user = pwd->pw_name; - t = time(0); - timestamp = ctime(&t); - timestamp[24] = '\0'; - fprintf(flog, "%s (%s) <%s, %s, %s> %s\n", - user, timestamp, group, -#ifdef PRISTINE - "", -#else - num, -#endif - acu, message); - (void) fflush(flog); - (void) flock(fileno(flog), LOCK_UN); -} - -loginit() -{ - flog = fopen(value(LOG), "a"); - if (flog == NULL) - fprintf(stderr, "can't open log file %s.\r\n", value(LOG)); -} -#endif diff --git a/usr.bin/tip/partab.c b/usr.bin/tip/partab.c deleted file mode 100644 index 1da4e2398817..000000000000 --- a/usr.bin/tip/partab.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Even parity table for 0-0177 - */ -char evenpartab[] = { - 0000,0201,0202,0003,0204,0005,0006,0207, - 0210,0011,0012,0213,0014,0215,0216,0017, - 0220,0021,0022,0223,0024,0225,0226,0027, - 0030,0231,0232,0033,0234,0035,0036,0237, - 0240,0041,0042,0243,0044,0245,0246,0047, - 0050,0251,0252,0053,0254,0055,0056,0257, - 0060,0261,0262,0063,0264,0065,0066,0267, - 0270,0071,0072,0273,0074,0275,0276,0077, - 0300,0101,0102,0303,0104,0305,0306,0107, - 0110,0311,0312,0113,0314,0115,0116,0317, - 0120,0321,0322,0123,0324,0125,0126,0327, - 0330,0131,0132,0333,0134,0335,0336,0137, - 0140,0341,0342,0143,0344,0145,0146,0347, - 0350,0151,0152,0353,0154,0355,0356,0157, - 0360,0161,0162,0363,0164,0365,0366,0167, - 0170,0371,0372,0173,0374,0175,0176,0377, -}; diff --git a/usr.bin/tip/remcap.c b/usr.bin/tip/remcap.c deleted file mode 100644 index 7a7e0c2732ca..000000000000 --- a/usr.bin/tip/remcap.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)remcap.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * remcap - routines for dealing with the remote host data base - * - * derived from termcap - */ -#include -#include -#include -#include -#include "pathnames.h" - -#ifndef BUFSIZ -#define BUFSIZ 1024 -#endif -#define MAXHOP 32 /* max number of tc= indirections */ - -#define tgetent rgetent -#define tnchktc rnchktc -#define tnamatch rnamatch -#define tgetnum rgetnum -#define tgetflag rgetflag -#define tgetstr rgetstr -#define E_TERMCAP RM = _PATH_REMOTE -#define V_TERMCAP "REMOTE" -#define V_TERM "HOST" - -char *RM; - -/* - * termcap - routines for dealing with the terminal capability data base - * - * BUG: Should use a "last" pointer in tbuf, so that searching - * for capabilities alphabetically would not be a n**2/2 - * process when large numbers of capabilities are given. - * Note: If we add a last pointer now we will screw up the - * tc capability. We really should compile termcap. - * - * Essentially all the work here is scanning and decoding escapes - * in string capabilities. We don't use stdio because the editor - * doesn't, and because living w/o it is not hard. - */ - -static char *tbuf; -static int hopcount; /* detect infinite loops in termcap, init 0 */ -static char *tskip(); -char *tgetstr(); -static char *tdecode(); -static char *remotefile; - -/* - * Get an entry for terminal name in buffer bp, - * from the termcap file. Parse is very rudimentary; - * we just notice escaped newlines. - */ -tgetent(bp, name) - char *bp, *name; -{ - char lbuf[BUFSIZ], *cp, *p; - int rc1, rc2; - - remotefile = cp = getenv(V_TERMCAP); - if (cp == (char *)0 || strcmp(cp, _PATH_REMOTE) == 0) { - remotefile = cp = _PATH_REMOTE; - return (getent(bp, name, cp)); - } else { - if ((rc1 = getent(bp, name, cp)) != 1) - *bp = '\0'; - remotefile = cp = _PATH_REMOTE; - rc2 = getent(lbuf, name, cp); - if (rc1 != 1 && rc2 != 1) - return (rc2); - if (rc2 == 1) { - p = lbuf; - if (rc1 == 1) - while (*p++ != ':') - ; - if (strlen(bp) + strlen(p) > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); - return (-1); - } - strcat(bp, p); - } - tbuf = bp; - return (1); - } -} - -getent(bp, name, cp) - char *bp, *name, *cp; -{ - register int c; - register int i = 0, cnt = 0; - char ibuf[BUFSIZ], *cp2; - int tf; - - tbuf = bp; - tf = 0; - /* - * TERMCAP can have one of two things in it. It can be the - * name of a file to use instead of /etc/termcap. In this - * case it better start with a "/". Or it can be an entry to - * use so we don't have to read the file. In this case it - * has to already have the newlines crunched out. - */ - if (cp && *cp) { - if (*cp!='/') { - cp2 = getenv(V_TERM); - if (cp2 == (char *)0 || strcmp(name,cp2) == 0) { - strcpy(bp,cp); - return (tnchktc()); - } else - tf = open(E_TERMCAP, O_RDONLY); - } else - tf = open(RM = cp, O_RDONLY); - } - if (tf == 0) - tf = open(E_TERMCAP, O_RDONLY); - if (tf < 0) - return (-1); - for (;;) { - cp = bp; - for (;;) { - if (i == cnt) { - cnt = read(tf, ibuf, BUFSIZ); - if (cnt <= 0) { - close(tf); - return (0); - } - i = 0; - } - c = ibuf[i++]; - if (c == '\n') { - if (cp > bp && cp[-1] == '\\') { - cp--; - continue; - } - break; - } - if (cp >= bp+BUFSIZ) { - write(2,"Remcap entry too long\n", 23); - break; - } else - *cp++ = c; - } - *cp = 0; - - /* - * The real work for the match. - */ - if (tnamatch(name)) { - close(tf); - return (tnchktc()); - } - } -} - -/* - * tnchktc: check the last entry, see if it's tc=xxx. If so, - * recursively find xxx and append that entry (minus the names) - * to take the place of the tc=xxx entry. This allows termcap - * entries to say "like an HP2621 but doesn't turn on the labels". - * Note that this works because of the left to right scan. - */ -tnchktc() -{ - register char *p, *q; - char tcname[16]; /* name of similar terminal */ - char tcbuf[BUFSIZ]; - char *holdtbuf = tbuf; - int l; - char *cp; - - p = tbuf + strlen(tbuf) - 2; /* before the last colon */ - while (*--p != ':') - if (p MAXHOP) { - write(2, "Infinite tc= loop\n", 18); - return (0); - } - if (getent(tcbuf, tcname, remotefile) != 1) { - if (strcmp(remotefile, _PATH_REMOTE) == 0) - return (0); - else if (getent(tcbuf, tcname, _PATH_REMOTE) != 1) - return (0); - } - for (q = tcbuf; *q++ != ':'; ) - ; - l = p - holdtbuf + strlen(q); - if (l > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); - q[BUFSIZ - (p-holdtbuf)] = 0; - } - strcpy(p, q); - tbuf = holdtbuf; - return (1); -} - -/* - * Tnamatch deals with name matching. The first field of the termcap - * entry is a sequence of names separated by |'s, so we compare - * against each such name. The normal : terminator after the last - * name (before the first field) stops us. - */ -tnamatch(np) - char *np; -{ - register char *Np, *Bp; - - Bp = tbuf; - if (*Bp == '#') - return (0); - for (;;) { - for (Np = np; *Np && *Bp == *Np; Bp++, Np++) - continue; - if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) - return (1); - while (*Bp && *Bp != ':' && *Bp != '|') - Bp++; - if (*Bp == 0 || *Bp == ':') - return (0); - Bp++; - } -} - -/* - * Skip to the next field. Notice that this is very dumb, not - * knowing about \: escapes or any such. If necessary, :'s can be put - * into the termcap file in octal. - */ -static char * -tskip(bp) - register char *bp; -{ - - while (*bp && *bp != ':') - bp++; - if (*bp == ':') - bp++; - return (bp); -} - -/* - * Return the (numeric) option id. - * Numeric options look like - * li#80 - * i.e. the option string is separated from the numeric value by - * a # character. If the option is not found we return -1. - * Note that we handle octal numbers beginning with 0. - */ -tgetnum(id) - char *id; -{ - register int i, base; - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (*bp == 0) - return (-1); - if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) - continue; - if (*bp == '@') - return (-1); - if (*bp != '#') - continue; - bp++; - base = 10; - if (*bp == '0') - base = 8; - i = 0; - while (isdigit(*bp)) - i *= base, i += *bp++ - '0'; - return (i); - } -} - -/* - * Handle a flag option. - * Flag options are given "naked", i.e. followed by a : or the end - * of the buffer. Return 1 if we find the option, or 0 if it is - * not given. - */ -tgetflag(id) - char *id; -{ - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (!*bp) - return (0); - if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { - if (!*bp || *bp == ':') - return (1); - else if (*bp == '@') - return (0); - } - } -} - -/* - * Get a string valued option. - * These are given as - * cl=^Z - * Much decoding is done on the strings, and the strings are - * placed in area, which is a ref parameter which is updated. - * No checking on area overflow. - */ -char * -tgetstr(id, area) - char *id, **area; -{ - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (!*bp) - return (0); - if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) - continue; - if (*bp == '@') - return (0); - if (*bp != '=') - continue; - bp++; - return (tdecode(bp, area)); - } -} - -/* - * Tdecode does the grung work to decode the - * string capability escapes. - */ -static char * -tdecode(str, area) - register char *str; - char **area; -{ - register char *cp; - register int c; - register char *dp; - int i; - - cp = *area; - while ((c = *str++) && c != ':') { - switch (c) { - - case '^': - c = *str++ & 037; - break; - - case '\\': - dp = "E\033^^\\\\::n\nr\rt\tb\bf\f"; - c = *str++; -nextc: - if (*dp++ == c) { - c = *dp++; - break; - } - dp++; - if (*dp) - goto nextc; - if (isdigit(c)) { - c -= '0', i = 2; - do - c <<= 3, c |= *str++ - '0'; - while (--i && isdigit(*str)); - } - break; - } - *cp++ = c; - } - *cp++ = 0; - str = *area; - *area = cp; - return (str); -} diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c deleted file mode 100644 index 9b8606641372..000000000000 --- a/usr.bin/tip/remote.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include -#include - -#include "pathnames.h" -#include "tip.h" - -/* - * Attributes to be gleened from remote host description - * data base. - */ -static char **caps[] = { - &AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI, - &ES, &EX, &FO, &RC, &RE, &PA -}; - -static char *capstrings[] = { - "at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr", - "di", "es", "ex", "fo", "rc", "re", "pa", 0 -}; - -static char *db_array[3] = { _PATH_REMOTE, 0, 0 }; - -#define cgetflag(f) (cgetcap(bp, f, ':') != NULL) - -static -getremcap(host) - register char *host; -{ - register char **p, ***q; - char *bp; - char *rempath; - int stat; - - rempath = getenv("REMOTE"); - if (rempath != NULL) - if (*rempath != '/') - /* we have an entry */ - cgetset(rempath); - else { /* we have a path */ - db_array[1] = rempath; - db_array[2] = _PATH_REMOTE; - } - - if ((stat = cgetent(&bp, db_array, host)) < 0) { - if (DV || - host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) { - CU = DV; - HO = host; - HW = 1; - DU = 0; - if (!BR) - BR = DEFBR; - FS = DEFFS; - return; - } - switch(stat) { - case -1: - fprintf(stderr, "tip: unknown host %s\n", host); - break; - case -2: - fprintf(stderr, - "tip: can't open host description file\n"); - break; - case -3: - fprintf(stderr, - "tip: possible reference loop in host description file\n"); - break; - } - exit(3); - } - - for (p = capstrings, q = caps; *p != NULL; p++, q++) - if (**q == NULL) - cgetstr(bp, *p, *q); - if (!BR && (cgetnum(bp, "br", &BR) == -1)) - BR = DEFBR; - if (cgetnum(bp, "fs", &FS) == -1) - FS = DEFFS; - if (DU < 0) - DU = 0; - else - DU = cgetflag("du"); - if (DV == NOSTR) { - fprintf(stderr, "%s: missing device spec\n", host); - exit(3); - } - if (DU && CU == NOSTR) - CU = DV; - if (DU && PN == NOSTR) { - fprintf(stderr, "%s: missing phone number\n", host); - exit(3); - } - - HD = cgetflag("hd"); - - /* - * This effectively eliminates the "hw" attribute - * from the description file - */ - if (!HW) - HW = (CU == NOSTR) || (DU && equal(DV, CU)); - HO = host; - /* - * see if uppercase mode should be turned on initially - */ - if (cgetflag("ra")) - boolean(value(RAISE)) = 1; - if (cgetflag("ec")) - boolean(value(ECHOCHECK)) = 1; - if (cgetflag("be")) - boolean(value(BEAUTIFY)) = 1; - if (cgetflag("nb")) - boolean(value(BEAUTIFY)) = 0; - if (cgetflag("sc")) - boolean(value(SCRIPT)) = 1; - if (cgetflag("tb")) - boolean(value(TABEXPAND)) = 1; - if (cgetflag("vb")) - boolean(value(VERBOSE)) = 1; - if (cgetflag("nv")) - boolean(value(VERBOSE)) = 0; - if (cgetflag("ta")) - boolean(value(TAND)) = 1; - if (cgetflag("nt")) - boolean(value(TAND)) = 0; - if (cgetflag("rw")) - boolean(value(RAWFTP)) = 1; - if (cgetflag("hd")) - boolean(value(HALFDUPLEX)) = 1; - if (RE == NOSTR) - RE = (char *)"tip.record"; - if (EX == NOSTR) - EX = (char *)"\t\n\b\f"; - if (ES != NOSTR) - vstring("es", ES); - if (FO != NOSTR) - vstring("fo", FO); - if (PR != NOSTR) - vstring("pr", PR); - if (RC != NOSTR) - vstring("rc", RC); - if (cgetnum(bp, "dl", &DL) == -1) - DL = 0; - if (cgetnum(bp, "cl", &CL) == -1) - CL = 0; - if (cgetnum(bp, "et", &ET) == -1) - ET = 10; -} - -char * -getremote(host) - char *host; -{ - register char *cp; - static char *next; - static int lookedup = 0; - - if (!lookedup) { - if (host == NOSTR && (host = getenv("HOST")) == NOSTR) { - fprintf(stderr, "tip: no host specified\n"); - exit(3); - } - getremcap(host); - next = DV; - lookedup++; - } - /* - * We return a new device each time we're called (to allow - * a rotary action to be simulated) - */ - if (next == NOSTR) - return (NOSTR); - if ((cp = index(next, ',')) == NULL) { - DV = next; - next = NOSTR; - } else { - *cp++ = '\0'; - DV = next; - next = cp; - } - return (DV); -} diff --git a/usr.bin/tip/tip.1 b/usr.bin/tip/tip.1 deleted file mode 100644 index 10b8a3ef4c95..000000000000 --- a/usr.bin/tip/tip.1 +++ /dev/null @@ -1,451 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tip.1 8.4 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt TIP 1 -.Os BSD 4 -.Sh NAME -.Nm tip , -.Nm cu -.Nd connect to a remote system -.Sh SYNOPSIS -.Nm tip -.Op Fl v -.Fl Ns Ns Ar speed -.Ar system\-name -.Nm tip -.Op Fl v -.Fl Ns Ns Ar speed -.Ar phone\-number -.Nm cu -.Ar phone\-number -.Op Fl t -.Op Fl s Ar speed -.Op Fl a Ar acu -.Op Fl l Ar line -.Op Fl # -.Sh DESCRIPTION -.Nm Tip -and -.Ar cu -establish a full-duplex connection to another machine, -giving the appearance of being logged in directly on the -remote cpu. It goes without saying that you must have a login -on the machine (or equivalent) to which you wish to connect. -The preferred interface is -.Nm tip . -The -.Ar cu -interface is included for those people attached to the -``call -.Ux Ns '' -command of version 7. This manual page -describes only -.Nm tip . -.Pp -Available Option: -.Bl -tag -width indent -.It Fl v -Set verbose mode. -.El -.Pp -Typed characters are normally transmitted directly to the remote -machine (which does the echoing as well). A tilde (`~') appearing -as the first character of a line is an escape signal; the following -are recognized: -.Bl -tag -width flag -.It Ic \&~^D No or Ic \&~ . -Drop the connection and exit -(you may still be logged in on the -remote machine). -.It Ic \&~c Op Ar name -Change directory to -.Ar name -(no argument -implies change to your home directory). -.It Ic \&~! -Escape to a shell (exiting the shell will -return you to tip). -.It Ic \&~> -Copy file from local to remote. -.Nm Tip -prompts for the name of a local file to transmit. -.It Ic \&~< -Copy file from remote to local. -.Nm Tip -prompts first for the name of the file to be sent, then for -a command to be executed on the remote machine. -.It Ic \&~p Ar from Op Ar to -Send a file to a remote -.Ux -host. The put command causes the remote -.Ux -system to run the command string ``cat > 'to''', while -.Nm tip -sends it the ``from'' -file. If the ``to'' file isn't specified the ``from'' file name is used. -This command is actually a -.Ux -specific version of the ``~>'' command. -.It Ic \&~t Ar from Op Ar to -Take a file from a remote -.Ux -host. -As in the put command the ``to'' file -defaults to the ``from'' file name if it isn't specified. -The remote host -executes the command string ``cat 'from';echo ^A'' to send the file to -.Nm tip . -.It Ic \&~| -Pipe the output from a remote command to a local -.Ux -process. -The command string sent to the local -.Ux -system is processed by the shell. -.It Ic \&~$ -Pipe the output from a local -.Ux -process to the remote host. -The command string sent to the local -.Ux -system is processed by the shell. -.It Ic \&~C -Fork a child process on the local system to perform special protocols -such as \s-1XMODEM\s+1. The child program will be run with the following -somewhat unusual arrangement of file descriptors: -.nf -.in +1i -0 <-> local tty in -1 <-> local tty out -2 <-> local tty out -3 <-> remote tty in -4 <-> remote tty out -.in -1i -.fi -.It Ic \&~# -Send a -.Dv BREAK -to the remote system. -For systems which don't support the -necessary -.Ar ioctl -call the break is simulated by a sequence of line speed changes -and -.Dv DEL -characters. -.It Ic \&~s -Set a variable (see the discussion below). -.It Ic \&~^Z -Stop -.Nm tip -(only available with job control). -.It Ic \&~^Y -Stop only the ``local side'' of -.Nm tip -(only available with job control); -the ``remote side'' of -.Nm tip , -the side that displays output from the remote host, is left running. -.It Ic \&~? -Get a summary of the tilde escapes -.El -.Pp -.Nm Tip -uses the file -.Pa /etc/remote -to find how to reach a particular -system and to find out how it should operate while talking -to the system; -refer to -.Xr remote 5 -for a full description. -Each system has a default baud rate with which to -establish a connection. If this value is not suitable, the baud rate -to be used may be specified on the command line, e.g. -.Ql "tip -300 mds" . -.Pp -When -.Nm tip -establishes a connection it sends out a -connection message to the remote system; the default value, if any, -is defined in -.Pa /etc/remote -(see -.Xr remote 5 ) . -.Pp -When -.Nm tip -prompts for an argument (e.g. during setup of -a file transfer) the line typed may be edited with the standard -erase and kill characters. A null line in response to a prompt, -or an interrupt, will abort the dialogue and return you to the -remote machine. -.Pp -.Nm Tip -guards against multiple users connecting to a remote system -by opening modems and terminal lines with exclusive access, -and by honoring the locking protocol used by -.Xr uucico 8 . -.Pp -During file transfers -.Nm tip -provides a running count of the number of lines transferred. -When using the ~> and ~< commands, the ``eofread'' and ``eofwrite'' -variables are used to recognize end-of-file when reading, and -specify end-of-file when writing (see below). File transfers -normally depend on tandem mode for flow control. If the remote -system does not support tandem mode, ``echocheck'' may be set -to indicate -.Nm tip -should synchronize with the remote system on the echo of each -transmitted character. -.Pp -When -.Nm tip -must dial a phone number to connect to a system it will print -various messages indicating its actions. -.Nm Tip -supports the -.Tn DEC DN Ns-11 -and -Racal-Vadic 831 auto-call-units; -the -.Tn DEC DF Ns \&02 -and -.Tn DF Ns \&03 , -Ventel 212+, Racal-Vadic 3451, and -Bizcomp 1031 and 1032 integral call unit/modems. -.Ss VARIABLES -.Nm Tip -maintains a set of -.Ar variables -which control its operation. -Some of these variables are read-only to normal users (root is allowed -to change anything of interest). Variables may be displayed -and set through the ``s'' escape. The syntax for variables is patterned -after -.Xr vi 1 -and -.Xr Mail 1 . -Supplying ``all'' -as an argument to the set command displays all variables readable by -the user. Alternatively, the user may request display of a particular -variable by attaching a `?' to the end. For example ``escape?'' -displays the current escape character. -.Pp -Variables are numeric, string, character, or boolean values. Boolean -variables are set merely by specifying their name; they may be reset -by prepending a `!' to the name. Other variable types are set by -concatenating an `=' and the value. The entire assignment must not -have any blanks in it. A single set command may be used to interrogate -as well as set a number of variables. -Variables may be initialized at run time by placing set commands -(without the ``~s'' prefix in a file -.Pa .tiprc -in one's home directory). The -.Fl v -option causes -.Nm tip -to display the sets as they are made. -Certain common variables have abbreviations. -The following is a list of common variables, -their abbreviations, and their default values. -.Bl -tag -width Ar -.It Ar beautify -(bool) Discard unprintable characters when a session is being scripted; -abbreviated -.Ar be . -.It Ar baudrate -(num) The baud rate at which the connection was established; -abbreviated -.Ar ba . -.It Ar dialtimeout -(num) When dialing a phone number, the time (in seconds) -to wait for a connection to be established; abbreviated -.Ar dial . -.It Ar echocheck -(bool) Synchronize with the remote host during file transfer by -waiting for the echo of the last character transmitted; default is -.Ar off . -.It Ar eofread -(str) The set of characters which signify an end-of-transmission -during a ~< file transfer command; abbreviated -.Ar eofr . -.It Ar eofwrite -(str) The string sent to indicate end-of-transmission during -a ~> file transfer command; abbreviated -.Ar eofw . -.It Ar eol -(str) The set of characters which indicate an end-of-line. -.Nm Tip -will recognize escape characters only after an end-of-line. -.It Ar escape -(char) The command prefix (escape) character; abbreviated -.Ar es ; -default value is `~'. -.It Ar exceptions -(str) The set of characters which should not be discarded -due to the beautification switch; abbreviated -.Ar ex ; -default value is ``\et\en\ef\eb''. -.It Ar force -(char) The character used to force literal data transmission; -abbreviated -.Ar fo ; -default value is `^P'. -.It Ar framesize -(num) The amount of data (in bytes) to buffer between file system -writes when receiving files; abbreviated -.Ar fr . -.It Ar host -(str) The name of the host to which you are connected; abbreviated -.Ar ho . -.It Ar prompt -(char) The character which indicates an end-of-line on the remote -host; abbreviated -.Ar pr ; -default value is `\en'. This value is used to synchronize during -data transfers. The count of lines transferred during a file transfer -command is based on receipt of this character. -.It Ar raise -(bool) Upper case mapping mode; abbreviated -.Ar ra ; -default value is -.Ar off . -When this mode is enabled, all lower case letters will be mapped to -upper case by -.Nm tip -for transmission to the remote machine. -.It Ar raisechar -(char) The input character used to toggle upper case mapping mode; -abbreviated -.Ar rc ; -default value is `^A'. -.It Ar record -(str) The name of the file in which a session script is recorded; -abbreviated -.Ar rec ; -default value is ``tip.record''. -.It Ar script -(bool) Session scripting mode; abbreviated -.Ar sc ; -default is -.Ar off . -When -.Ar script -is -.Li true , -.Nm tip -will record everything transmitted by the remote machine in -the script record file specified in -.Ar record . -If the -.Ar beautify -switch is on, only printable -.Tn ASCII -characters will be included in -the script file (those characters betwee 040 and 0177). The -variable -.Ar exceptions -is used to indicate characters which are an exception to the normal -beautification rules. -.It Ar tabexpand -(bool) Expand tabs to spaces during file transfers; abbreviated -.Ar tab ; -default value is -.Ar false . -Each tab is expanded to 8 spaces. -.It Ar verbose -(bool) Verbose mode; abbreviated -.Ar verb ; -default is -.Ar true . -When verbose mode is enabled, -.Nm tip -prints messages while dialing, shows the current number -of lines transferred during a file transfer operations, -and more. -.El -.Sh ENVIRONMENT -.Nm Tip -uses the following environment variables: -.Bl -tag -width Fl -.It Ev SHELL -(str) The name of the shell to use for the ~! command; default -value is ``/bin/sh'', or taken from the environment. -.It Ev HOME -(str) The home directory to use for the ~c command; default -value is taken from the environment. -.It Ev HOST -Check for a default host if none specified. -.El -.Pp -The variables -.Ev ${REMOTE} -and -.Ev ${PHONES} -are also exported. -.Sh FILES -.Bl -tag -width /var/spool/uucp/LCK..* -compact -.It Pa /etc/remote -Global system descriptions. -.It Pa /etc/phones -Global phone number data base. -.It ${REMOTE} -Private system descriptions. -.It ${PHONES} -Private phone numbers. -.It ~/.tiprc -Initialization file. -.It Pa tip.record -Record file. -.It /var/log/aculog -Line access log. -.It Pa /var/spool/uucp/LCK..* -Lock file to avoid conflicts with -.Xr uucp . -.El -.Sh DIAGNOSTICS -Diagnostics are, hopefully, self explanatory. -.Sh SEE ALSO -.Xr remote 5 , -.Xr phones 5 -.Sh HISTORY -The -.Nm tip -appeared command in -.Bx 4.2 . -.Sh BUGS -The full set of variables is undocumented and should, probably, be -pared down. diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c deleted file mode 100644 index ce29a21d6476..000000000000 --- a/usr.bin/tip/value.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define MIDDLE 35 - -static value_t *vlookup(); -static int col = 0; - -/* - * Variable manipulation - */ -vinit() -{ - register value_t *p; - register char *cp; - FILE *f; - char file[256]; - - for (p = vtable; p->v_name != NULL; p++) { - if (p->v_type&ENVIRON) - if (cp = getenv(p->v_name)) - p->v_value = cp; - if (p->v_type&IREMOTE) - number(p->v_value) = *address(p->v_value); - } - /* - * Read the .tiprc file in the HOME directory - * for sets - */ - strcpy(file, value(HOME)); - strcat(file, "/.tiprc"); - if ((f = fopen(file, "r")) != NULL) { - register char *tp; - - while (fgets(file, sizeof(file)-1, f) != NULL) { - if (vflag) - printf("set %s", file); - if (tp = rindex(file, '\n')) - *tp = '\0'; - vlex(file); - } - fclose(f); - } - /* - * To allow definition of exception prior to fork - */ - vtable[EXCEPTIONS].v_access &= ~(WRITE<v_access, WRITE)) { - printf("access denied\r\n"); - return; - } - switch (p->v_type&TMASK) { - - case STRING: - if (p->v_value && equal(p->v_value, v)) - return; - if (!(p->v_type&(ENVIRON|INIT))) - free(p->v_value); - if ((p->v_value = malloc(size(v)+1)) == NOSTR) { - printf("out of core\r\n"); - return; - } - p->v_type &= ~(ENVIRON|INIT); - strcpy(p->v_value, v); - break; - - case NUMBER: - if (number(p->v_value) == number(v)) - return; - number(p->v_value) = number(v); - break; - - case BOOL: - if (boolean(p->v_value) == (*v != '!')) - return; - boolean(p->v_value) = (*v != '!'); - break; - - case CHAR: - if (character(p->v_value) == *v) - return; - character(p->v_value) = *v; - } - p->v_access |= CHANGED; -} - -static void vprint(); - -vlex(s) - register char *s; -{ - register value_t *p; - static void vtoken(); - - if (equal(s, "all")) { - for (p = vtable; p->v_name; p++) - if (vaccess(p->v_access, READ)) - vprint(p); - } else { - register char *cp; - - do { - if (cp = vinterp(s, ' ')) - cp++; - vtoken(s); - s = cp; - } while (s); - } - if (col > 0) { - printf("\r\n"); - col = 0; - } -} - -static void -vtoken(s) - register char *s; -{ - register value_t *p; - register char *cp; - char *expand(); - - if (cp = index(s, '=')) { - *cp = '\0'; - if (p = vlookup(s)) { - cp++; - if (p->v_type&NUMBER) - vassign(p, atoi(cp)); - else { - if (strcmp(s, "record") == 0) - cp = expand(cp); - vassign(p, cp); - } - return; - } - } else if (cp = index(s, '?')) { - *cp = '\0'; - if ((p = vlookup(s)) && vaccess(p->v_access, READ)) { - vprint(p); - return; - } - } else { - if (*s != '!') - p = vlookup(s); - else - p = vlookup(s+1); - if (p != NOVAL) { - vassign(p, s); - return; - } - } - printf("%s: unknown variable\r\n", s); -} - -static void -vprint(p) - register value_t *p; -{ - register char *cp; - extern char *interp(), *ctrl(); - - if (col > 0 && col < MIDDLE) - while (col++ < MIDDLE) - putchar(' '); - col += size(p->v_name); - switch (p->v_type&TMASK) { - - case BOOL: - if (boolean(p->v_value) == FALSE) { - col++; - putchar('!'); - } - printf("%s", p->v_name); - break; - - case STRING: - printf("%s=", p->v_name); - col++; - if (p->v_value) { - cp = interp(p->v_value, NULL); - col += size(cp); - printf("%s", cp); - } - break; - - case NUMBER: - col += 6; - printf("%s=%-5d", p->v_name, number(p->v_value)); - break; - - case CHAR: - printf("%s=", p->v_name); - col++; - if (p->v_value) { - cp = ctrl(character(p->v_value)); - col += size(cp); - printf("%s", cp); - } - break; - } - if (col >= MIDDLE) { - col = 0; - printf("\r\n"); - return; - } -} - - -static int -vaccess(mode, rw) - register unsigned mode, rw; -{ - if (mode & (rw<v_name; p++) - if (equal(p->v_name, s) || (p->v_abrev && equal(p->v_abrev, s))) - return (p); - return (NULL); -} - -char * -vinterp(s, stop) - register char *s; - char stop; -{ - register char *p = s, c; - int num; - - while ((c = *s++) && c != stop) - switch (c) { - - case '^': - if (*s) - *p++ = *s++ - 0100; - else - *p++ = c; - break; - - case '\\': - num = 0; - c = *s++; - if (c >= '0' && c <= '7') - num = (num<<3)+(c-'0'); - else { - register char *q = "n\nr\rt\tb\bf\f"; - - for (; *q; q++) - if (c == *q++) { - *p++ = *q; - goto cont; - } - *p++ = c; - cont: - break; - } - if ((c = *s++) >= '0' && c <= '7') { - num = (num<<3)+(c-'0'); - if ((c = *s++) >= '0' && c <= '7') - num = (num<<3)+(c-'0'); - else - s--; - } else - s--; - *p++ = num; - break; - - default: - *p++ = c; - } - *p = '\0'; - return (c == stop ? s-1 : NULL); -} - -/* - * assign variable s with value v (for NUMBER or STRING or CHAR types) - */ - -vstring(s,v) - register char *s; - register char *v; -{ - register value_t *p; - char *expand(); - - p = vlookup(s); - if (p == 0) - return (1); - if (p->v_type&NUMBER) - vassign(p, atoi(v)); - else { - if (strcmp(s, "record") == 0) - v = expand(v); - vassign(p, v); - } - return (0); -} diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c deleted file mode 100644 index debe01bed05e..000000000000 --- a/usr.bin/tip/vars.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" -#include "pathnames.h" - -/* - * Definition of variables - */ -value_t vtable[] = { - { "beautify", BOOL, (READ|WRITE)< -#include -#include -#ifdef vax -#ifdef BSD4_2 -#include -#else -#include -#endif -#endif /* vax */ -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" - -#define NDZLINE 8 /* lines/dz */ -#define NDHLINE 16 /* lines/dh */ -#define NDMFLINE 8 /* lines/dmf */ - -#define DZ11 1 -#define DH11 2 -#define DMF 3 - -#define NLVALUE(val) (nl[val].n_value) - -struct nlist nl[] = { -#define CDEVSW 0 - { "_cdevsw" }, - -#define DZOPEN 1 - { "_dzopen" }, -#define DZINFO 2 - { "_dzinfo" }, -#define NDZ11 3 - { "_dz_cnt" }, -#define DZSCAR 4 - { "_dzsoftCAR" }, - -#define DHOPEN 5 - { "_dhopen" }, -#define DHINFO 6 - { "_dhinfo" }, -#define NDH11 7 - { "_ndh11" }, -#define DHSCAR 8 - { "_dhsoftCAR" }, - -#define DMFOPEN 9 - { "_dmfopen" }, -#define DMFINFO 10 - { "_dmfinfo" }, -#define NDMF 11 - { "_ndmf" }, -#define DMFSCAR 12 - { "_dmfsoftCAR" }, - - { "\0" } -}; - -#define ENABLE 1 -#define DISABLE 0 - -char Etcttys[] = _PATH_TTYS; -#ifdef BSD4_3 -FILE *ttysfile, *nttysfile; -char NEtcttys[] = _PATH_NEWTTYS; -extern long ftell(); -#endif BSD4_3 -char Devhome[] = _PATH_DEV; - -char usage[] = "Usage: acucntrl {dis|en}able ttydX\n"; - -struct utmp utmp; -char resettty, resetmodem; -int etcutmp; -off_t utmploc; -off_t ttyslnbeg; -extern int errno; -extern char *sys_errlist[]; -off_t lseek(); - -#define NAMSIZ sizeof(utmp.ut_name) -#define LINSIZ sizeof(utmp.ut_line) - -main(argc, argv) -int argc; char *argv[]; -{ - register char *p; - register int i; - char uname[NAMSIZ], Uname[NAMSIZ]; - int enable ; - char *device; - int devfile; - int uid, gid; - struct passwd *getpwuid(); - char *rindex(); - - /* check input arguments */ - if (argc!=3 && argc != 4) { - fprintf(stderr, usage); - exit(1); - } - - /* interpret command type */ - if (prefix(argv[1], "disable") || strcmp(argv[1], "dialout")==0) - enable = 0; - else if (prefix(argv[1], "enable") || strcmp(argv[1], "dialin")==0) - enable = 1; - else { - fprintf(stderr, usage); - exit(1); - } - - device = rindex(argv[2], '/'); - device = (device == NULL) ? argv[2]: device+1; - - opnttys(device); - -#ifdef vax - /* Get nlist info */ - nlist(_PATH_UNIX, nl); -#endif vax - - /* Chdir to /dev */ - if(chdir(Devhome) < 0) { - fprintf(stderr, "Cannot chdir to %s: %s\r\n", - Devhome, sys_errlist[errno]); - exit(1); - } - - /* Get uid information */ - uid = getuid(); - gid = getgid(); - - p = getpwuid(uid)->pw_name; - if (p==NULL) { - fprintf(stderr, "cannot get uid name\n"); - exit(1); - } - - if (strcmp(p, "uucp") == 0 && argc == 4) - p = argv[3]; - - /* to upper case */ - i = 0; - do { - uname[i] = *p; - Uname[i++] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p; - } while (*p++ && i= 0 ; str++) - if (*str>='a' && *str<='z') - return(0); - return(1); -} - -/* Post name to public */ -post(device, name) -char *device, *name; -{ - (void)time((time_t *)&utmp.ut_time); - strncpy(utmp.ut_line, device, LINSIZ); - strncpy(utmp.ut_name, name, NAMSIZ); - if (lseek(etcutmp, utmploc, 0) < 0) - fprintf(stderr, "on lseek in %s: %s", - _PATH_UTMP, sys_errlist[errno]); - if (write(etcutmp, (char *)&utmp, sizeof(utmp)) < 0) - fprintf(stderr, "on write in %s: %s", - _PATH_UTMP, sys_errlist[errno]); -} - -/* poke process 1 and wait for it to do its thing */ -pokeinit(device, uname, enable) -char *uname, *device; int enable; -{ - struct utmp utmp; - register int i; - - post(device, uname); - - /* poke init */ - if (kill(1, SIGHUP)) { - fprintf(stderr, - "Cannot send hangup to init process: %s\n", - sys_errlist[errno]); - (void)settys(resettty); - (void)setmodem(device, resetmodem); - exit(1); - } - - if (enable) - return; - - /* wait till init has responded, clearing the utmp entry */ - i = 100; - do { - sleep(1); - if (lseek(etcutmp, utmploc, 0) < 0) - fprintf(stderr, "On lseek in %s: %s", - _PATH_UTMP, sys_errlist[errno]); - if (read(etcutmp, (char *)&utmp, sizeof utmp) < 0) - fprintf(stderr, "On read from %s: %s", - _PATH_UTMP, sys_errlist[errno]); - } while (utmp.ut_name[0] != '\0' && --i > 0); -} - -#ifdef BSD4_3 -/* identify terminal line in ttys */ -opnttys(device) -char *device; -{ - register int ndevice; - register char *p; - char *index(); - char linebuf[BUFSIZ]; - - ttysfile = NULL; - do { - if (ttysfile != NULL) { - fclose(ttysfile); - sleep(5); - } - ttysfile = fopen(Etcttys, "r"); - if(ttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - } while (flock(fileno(ttysfile), LOCK_NB|LOCK_EX) < 0); - nttysfile = fopen(NEtcttys, "w"); - if(nttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - - ndevice = strlen(device); -#ifndef BRL4_2 - utmploc = sizeof(utmp); -#else BRL4_2 - utmploc = 0; -#endif BRL4_2 - - while(fgets(linebuf, sizeof(linebuf) - 1, ttysfile) != NULL) { - if(strncmp(device, linebuf, ndevice) == 0) - return; - ttyslnbeg += strlen(linebuf); - if (linebuf[0] != '#' && linebuf[0] != '\0') - utmploc += sizeof(utmp); - if (fputs(linebuf, nttysfile) == NULL) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - - } - fprintf(stderr, "%s not found in %s\n", device, Etcttys); - exit(1); -} - -/* modify appropriate line in _PATH_TTYS to turn on/off the device */ -settys(enable) -int enable; -{ - register char *cp, *cp2; - char lbuf[BUFSIZ]; - int i; - char c1, c2; - - (void) fseek(ttysfile, ttyslnbeg, 0); - if(fgets(lbuf, BUFSIZ, ttysfile) == NULL) { - fprintf(stderr, "On %s read: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - /* format is now */ - /* ttyd0 std.100 dialup on secure # comment */ - /* except, 2nd item may have embedded spaces inside quotes, Hubert */ - cp = lbuf; - for (i=0;*cp && i<3;i++) { - if (*cp == '"') { - cp++; - while (*cp && *cp != '"') - cp++; - if (*cp != '\0') - cp++; - }else { - while (*cp && *cp != ' ' && *cp != '\t') - cp++; - } - while (*cp && (*cp == ' ' || *cp == '\t')) - cp++; - } - if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in %s:\n%s", - _PATH_TTYS, lbuf); - exit(1); - } - c1 = *--cp; - *cp++ = '\0'; - cp2 = cp; - while (*cp && *cp != ' ' && *cp != '\t' && *cp != '\n') - cp++; - if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in %s:\n%s", - _PATH_TTYS, lbuf); - exit(1); - } - c2 = *cp; - *cp++ = '\0'; - while (*cp && (*cp == ' ' || *cp == '\t')) - cp++; - resettty = strcmp("on", cp2) != 0; - fprintf(nttysfile,"%s%c%s%c%s", lbuf, c1, enable ? "on" : "off", c2, cp); - if (ferror(nttysfile)) { - fprintf(stderr, "On %s fprintf: %s\n", - NEtcttys, sys_errlist[errno]); - exit(1); - } - while(fgets(lbuf, sizeof(lbuf) - 1, ttysfile) != NULL) { - if (fputs(lbuf, nttysfile) == NULL) { - fprintf(stderr, "On %s write: %s\n", - NEtcttys, sys_errlist[errno]); - exit(1); - } - } - - if (enable^resettty) - (void) unlink(NEtcttys); - else { - struct stat statb; - if (stat(Etcttys, &statb) == 0) { - fchmod(fileno(nttysfile) ,statb.st_mode); - fchown(fileno(nttysfile), statb.st_uid, statb.st_gid); - } - (void) rename(NEtcttys, Etcttys); - } - (void) fclose(nttysfile); - (void) fclose(ttysfile); - return enable^resettty; -} - -#else !BSD4_3 - -/* identify terminal line in ttys */ -opnttys(device) -char *device; -{ - register FILE *ttysfile; - register int ndevice, lnsiz; - register char *p; - char *index(); - char linebuf[BUFSIZ]; - - ttysfile = fopen(Etcttys, "r"); - if(ttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - - ndevice = strlen(device); - ttyslnbeg = 0; - utmploc = 0; - - while(fgets(linebuf, sizeof(linebuf) - 1, ttysfile) != NULL) { - lnsiz = strlen(linebuf); - if ((p = index(linebuf, '\n')) != NULL) - *p = '\0'; - if(strncmp(device, &linebuf[2], ndevice) == 0) { - (void)fclose(ttysfile); -#ifdef sequent - /* Why is the sequent off by one? */ - utmploc += sizeof(utmp); -#endif sequent - return; - } - ttyslnbeg += lnsiz; - utmploc += sizeof(utmp); - } - fprintf(stderr, "%s not found in %s\n", device, Etcttys); - exit(1); -} - -/* modify appropriate line in _PATH_TTYS to turn on/off the device */ -settys(enable) -int enable; -{ - int ittysfil; - char out, in; - - ittysfil = open(Etcttys, 2); - if(ittysfil < 0) { - fprintf(stderr, "Cannot open %s for output: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - (void)lseek(ittysfil, ttyslnbeg, 0); - if(read(ittysfil, &in, 1)<0) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - resettty = (in == '1'); - out = enable ? '1' : '0'; - (void)lseek(ittysfil, ttyslnbeg, 0); - if(write(ittysfil, &out, 1)<0) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - (void)close(ittysfil); - return(in==out); -} -#endif !BSD4_3 - -#ifdef sequent -setmodem(ttyline, enable) -char *ttyline; int enable; -{ - char *sysbuf[BUFSIZ]; - sprintf(sysbuf,"/etc/ttyconfig /dev/%s -special %s", ttyline, - enable ? "-carrier" : "-nocarrier"); - system(sysbuf); -} -#endif /* sequent */ -#ifdef vax -/* - * Excerpted from (June 8, 1983 W.Sebok) - * > ttymodem.c - enable/disable modem control for tty lines. - * > - * > Knows about DZ11s and DH11/DM11s. - * > 23.3.83 - TS - * > modified to know about DMF's (hasn't been tested) Nov 8, 1984 - WLS - */ - - -setmodem(ttyline, enable) -char *ttyline; int enable; -{ - dev_t dev; - int kmem; - int unit, line, nlines, addr, tflags; - int devtype=0; - char cflags; short sflags; -#ifdef BSD4_2 - int flags; -#else - short flags; -#endif - struct uba_device *ubinfo; - struct stat statb; - struct cdevsw cdevsw; - - if(nl[CDEVSW].n_type == 0) { - fprintf(stderr, "No namelist.\n"); - return(-1); - } - - if((kmem = open(_PATH_KMEM, 2)) < 0) { - fprintf(stderr, "%s open: %s\n", _PATH_KMEM, - sys_errlist[errno]); - return(-1); - } - - if(stat(ttyline, &statb) < 0) { - fprintf(stderr, "%s stat: %s\n", ttyline, sys_errlist[errno]); - return(-1); - } - - if((statb.st_mode&S_IFMT) != S_IFCHR) { - fprintf(stderr, "%s is not a character device.\n",ttyline); - return(-1); - } - - dev = statb.st_rdev; - (void)lseek(kmem, - (off_t) &(((struct cdevsw *)NLVALUE(CDEVSW))[major(dev)]),0); - (void)read(kmem, (char *) &cdevsw, sizeof cdevsw); - - if((int)(cdevsw.d_open) == NLVALUE(DZOPEN)) { - devtype = DZ11; - unit = minor(dev) / NDZLINE; - line = minor(dev) % NDZLINE; - addr = (int) &(((int *)NLVALUE(DZINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDZ11), 0); - } else if((int)(cdevsw.d_open) == NLVALUE(DHOPEN)) { - devtype = DH11; - unit = minor(dev) / NDHLINE; - line = minor(dev) % NDHLINE; - addr = (int) &(((int *)NLVALUE(DHINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDH11), 0); - } else if((int)(cdevsw.d_open) == NLVALUE(DMFOPEN)) { - devtype = DMF; - unit = minor(dev) / NDMFLINE; - line = minor(dev) % NDMFLINE; - addr = (int) &(((int *)NLVALUE(DMFINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDMF), 0); - } else { - fprintf(stderr, "Device %s (%d/%d) unknown.\n", ttyline, - major(dev), minor(dev)); - return(-1); - } - - (void)read(kmem, (char *) &nlines, sizeof nlines); - if(minor(dev) >= nlines) { - fprintf(stderr, "Sub-device %d does not exist (only %d).\n", - minor(dev), nlines); - return(-1); - } - - (void)lseek(kmem, (off_t)addr, 0); - (void)read(kmem, (char *) &ubinfo, sizeof ubinfo); - (void)lseek(kmem, (off_t) &(ubinfo->ui_flags), 0); - (void)read(kmem, (char *) &flags, sizeof flags); - - tflags = 1<ui_flags), 0); - (void)write(kmem, (char *) &flags, sizeof flags); - switch(devtype) { - case DZ11: - if((addr = NLVALUE(DZSCAR)) == 0) { - fprintf(stderr, "No dzsoftCAR.\n"); - return(-1); - } - cflags = flags; - (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0); - (void)write(kmem, (char *) &cflags, sizeof cflags); - break; - case DH11: - if((addr = NLVALUE(DHSCAR)) == 0) { - fprintf(stderr, "No dhsoftCAR.\n"); - return(-1); - } - sflags = flags; - (void)lseek(kmem, (off_t) &(((short *)addr)[unit]), 0); - (void)write(kmem, (char *) &sflags, sizeof sflags); - break; - case DMF: - if((addr = NLVALUE(DMFSCAR)) == 0) { - fprintf(stderr, "No dmfsoftCAR.\n"); - return(-1); - } - cflags = flags; - (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0); - (void)write(kmem, (char *) &cflags, sizeof cflags); - break; - default: - fprintf(stderr, "Unknown device type\n"); - return(-1); - } - return(0); -} -#endif /* vax */ - -prefix(s1, s2) - register char *s1, *s2; -{ - register char c; - - while ((c = *s1++) == *s2++) - if (c == '\0') - return (1); - return (c == '\0'); -} -#else /* !DIALINOUT */ -main() -{ - fprintf(stderr,"acucntrl is not supported on this system\n"); -} -#endif /* !DIALINOUT */ diff --git a/usr.bin/uucp/uupoll/uupoll.8 b/usr.bin/uucp/uupoll/uupoll.8 deleted file mode 100644 index f6ee49b6c539..000000000000 --- a/usr.bin/uucp/uupoll/uupoll.8 +++ /dev/null @@ -1,111 +0,0 @@ -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uupoll.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUPOLL 8 -.Os BSD 4.3 -.Sh NAME -.Nm uupoll -.Nd poll a remote -.Tn UUCP -site -.Sh SYNOPSIS -.Nm uupoll -.Op Fl g Ns Ar grade -.Op Fl n -.Ar system -.Sh DESCRIPTION -.Nm Uupoll -is used to force a poll of a remote system. It queues a null job for the -remote system and then invokes -.Xr uucico 8 . -.Pp -The following options are available: -.Bl -tag -width Fl -.It Fl g Ns Ar grade -Only send jobs of grade -.Ar grade -or higher on this call. -.It Fl n -Queue the null job, but do not invoke -.Xr uucico . -.El -.Pp -.Nm Uupoll -is usually run by -.Xr cron 5 -or by a user who wants to hurry a job along. A typical entry in -.Em crontab -could be: -.Bd -literal -0 0,8,16 * * * daemon /usr/bin/uupoll ihnp4 -0 4,12,20 * * * daemon /usr/bin/uupoll ucbvax -.Ed -.Pp -This will poll -.Em ihnp4 -at midnight, 0800, and 1600, and -.Em ucbvax -at 0400, noon, and 2000. -.Pp -If the local machine is already running -.Xr uucico -every -hour and has a limited number of outgoing modems, a more elegant approach -might be: -.Bd -literal -0 0,8,16 * * * daemon /usr/bin/uupoll -n ihnp4 -0 4,12,20 * * * daemon /usr/bin/uupoll -n ucbvax -5 * * * * daemon /usr/lib/uucp/uucico -r1 -.Ed -.Pp -This will queue null jobs for the remote sites at the top of hour; they -will be processed by -.Xr uucico -when it runs five minutes later. -.Sh FILES -.Bl -tag -width /usr/lib/uucp/UUCP -compact -.It Pa /usr/lib/uucp/UUCP -internal files/utilities -.It Pa /var/spool/uucp/ -Spool directory -.El -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uucico 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.3 . diff --git a/usr.bin/uucp/uupoll/uupoll.c b/usr.bin/uucp/uupoll/uupoll.c deleted file mode 100644 index 5d5e662bcd22..000000000000 --- a/usr.bin/uucp/uupoll/uupoll.c +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * Copyright (c) 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1986, 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uupoll.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Poll named system(s). - * - * The poll occurs even if recent attempts have failed, - * but not if L.sys prohibits the call (e.g. wrong time of day). - * - * Original Author: Tom Truscott (rti!trt) - */ - -#include "uucp.h" - -int TransferSucceeded = 1; -struct timeb Now; - -main(argc, argv) -int argc; -char **argv; -{ - char wrkpre[MAXFULLNAME]; - char file[MAXFULLNAME]; - char grade = 'A'; - int nocall = 0; - int c; - char *sysname; - extern char *optarg; - extern int optind; - - if (argc < 2) { - fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n"); - cleanup(1); - } - - if (chdir(Spool) < 0) { - syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); - cleanup(1); - } - strcpy(Progname, "uupoll"); - uucpname(Myname); - - while ((c = getopt(argc, argv, "g:n")) != EOF) - switch(c) { - case 'g': - grade = *optarg; - break; - case 'n': - nocall++; - break; - case '?': - default: - fprintf(stderr, "unknown option %s\n", - argv[optind-1]); - } - - while(optind < argc) { - sysname = argv[optind++]; - if (strcmp(sysname, Myname) == SAME) { - fprintf(stderr, "This *is* %s!\n", Myname); - continue; - } - - if (versys(&sysname)) { - fprintf(stderr, "%s: unknown system.\n", sysname); - continue; - } - /* Remove any STST file that might stop the poll */ - sprintf(wrkpre, "%s/LCK..%.*s", LOCKDIR, MAXBASENAME, sysname); - if (access(wrkpre, 0) < 0) - rmstat(sysname); - sprintf(wrkpre, "%c.%.*s", CMDPRE, SYSNSIZE, sysname); - if (!iswrk(file, "chk", Spool, wrkpre)) { - sprintf(file, "%s/%c.%.*s%cPOLL", subdir(Spool, CMDPRE), - CMDPRE, SYSNSIZE, sysname, grade); - close(creat(file, 0666)); - } - /* Attempt the call */ - if (!nocall) - xuucico(sysname); - } - cleanup(0); -} - -cleanup(code) -int code; -{ - exit(code); -} diff --git a/usr.bin/uucp/uuq/Makefile b/usr.bin/uucp/uuq/Makefile deleted file mode 100644 index 60dbe0ba0d8c..000000000000 --- a/usr.bin/uucp/uuq/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= uuq -CFLAGS+=-I${.CURDIR}/../includes -BINMODE=6555 -DPADD= ${LIBCOMPAT} -LDADD= ${LIBUU} -lcompat - -.include diff --git a/usr.bin/uucp/uuq/uuq.1 b/usr.bin/uucp/uuq/uuq.1 deleted file mode 100644 index 783d4869c77f..000000000000 --- a/usr.bin/uucp/uuq/uuq.1 +++ /dev/null @@ -1,126 +0,0 @@ -.\" Copyright (c) 1988, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uuq.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUQ 1 -.Os BSD 4.3 -.Sh NAME -.Nm uuq -.Nd examine or manipulate the uucp queue -.Sh SYNOPSIS -.Nm uuq -.Op Fl l -.Op Fl h -.Op Fl s Ns Ar system -.Op Fl u Ns Ar user -.Op Fl d Ns Ar jobno -.Op Fl r Ns Ar sdir -.Op Fl b Ns Ar baud -.Sh DESCRIPTION -.Nm Uuq -is used to examine (and possibly delete) entries in the uucp queue. -.Pp -When listing jobs, -.Nm uuq -uses a format reminiscent of -.Xr ls . -For the long format, -information for each job listed includes -job number, number of files to transfer, user who -spooled the job, number of bytes to send, type of command requested -(S for sending files, R for receiving files, X for remote uucp), -and file or command desired. -.Pp -Several options are available: -.Bl -tag -width Ar -.It Fl h -Print only the summary lines for each system. Summary lines give system -name, number of jobs for the system, and total number of bytes to send. -.It Fl l -Specifies a long format listing. The default is to list only the -job numbers sorted across the page. -.It Fl s Ns Ar system -Limit output to jobs for systems whose system names begin with -.Ar system . -.It Fl u Ns Ar user -Limit output to jobs for users whose login names begin with -.Ar user . -.It Fl d Ns Ar jobno -Delete job number -.Ar jobno -(as obtained from a previous -.Nm uuq -command) -from the uucp queue. -Only the -.Tn UUCP -Administrator is permitted to delete jobs. -.It Fl r Ns Ar sdir -Look for files in the spooling directory -.Ar sdir -instead of the default -directory. -.It Fl b Ns Ar baud -Use -.Ar baud -to compute the transfer time instead of the default -1200 baud. -.El -.Sh FILES -.Bl -tag -width /usr/spool/uucp/Dhostname./D.x -compact -.It Pa /usr/spool/uucp/ -Default spool directory -.It Pa /usr/spool/uucp/C./C.* -Control files -.It Pa /usr/spool/uucp/D Ns Em hostname ./D.* -Outgoing data files -.It Pa /usr/spool/uucp/X./X.* -Outgoing execution files -.El -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uulog 1 , -.Xr uusnap 8 -.Sh BUGS -No information is available on work requested by the remote machine. -.Pp -The user who requests a remote uucp command is unknown. -.Pp -.Dq Li uq \-l -can be horrendously slow. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.3 . diff --git a/usr.bin/uucp/uuq/uuq.c b/usr.bin/uucp/uuq/uuq.c deleted file mode 100644 index 7abb25c42ab4..000000000000 --- a/usr.bin/uucp/uuq/uuq.c +++ /dev/null @@ -1,435 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uuq.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * uuq - looks at uucp queues - * - * Lou Salkind - * New York University - * - */ - -#include "uucp.h" -#include - -#ifdef NDIR -#include "libndir/ndir.h" -#else !NDIR -#include -#endif !NDIR -#include - -#define NOSYS (struct sys *)0 - -#define W_TYPE wrkvec[0] -#define W_FILE1 wrkvec[1] -#define W_FILE2 wrkvec[2] -#define W_USER wrkvec[3] -#define W_OPTNS wrkvec[4] -#define W_DFILE wrkvec[5] -#define W_MODE wrkvec[6] -#define WSUFSIZE 5 /* work file name suffix size */ - -struct sys { - char s_name[8]; - int s_njobs; - off_t s_bytes; - struct job *s_jobp; - struct sys *s_sysp; -}; - -struct job { - int j_files; - int j_flags; - char j_jobno[WSUFSIZE]; - char j_user[22]; - char j_fname[128]; - char j_grade; - off_t j_bytes; - time_t j_date; - struct job *j_jobp; -}; - -struct sys *syshead; -struct sys *getsys(); -int jcompare(); -char *sysname; -char *user; -char *rmjob; -int hflag; -int lflag; - -char *malloc(), *calloc(); -double atof(); -float baudrate = 2400.; -char Username[BUFSIZ]; -char Filename[BUFSIZ]; -int Maxulen = 0; -struct timeb Now; - -main(argc, argv) -int argc; -char **argv; -{ - register int i; - register struct sys *sp; - register struct job *jp; - struct job **sortjob; - int nsys; - extern char *optarg; - extern int optind; - - strcpy(Progname, "uuq"); - uucpname(Myname); - - while ((i = getopt(argc, argv, "r:S:s:u:d:b:hl")) != EOF) - switch (i) { - case 'r': - case 'S': - Spool = optarg; - break; - case 's': - sysname = optarg; - if (strlen(sysname) > SYSNSIZE) - sysname[SYSNSIZE] = '\0'; - break; - case 'u': - user = optarg; - break; - case 'd': - rmjob = optarg; - break; - case 'b': - baudrate = atof(optarg); - break; - case 'h': - hflag++; - break; - case 'l': - lflag++; - break; - default: - fprintf(stderr, - "usage: uuq [-l] [-h] [-ssystem] [-uuser] [-djobno] [-rspool] [-bbaudrate]\n"); - exit(0); - } - - subchdir(Spool); - baudrate *= 0.7; /* reduce speed because of protocol overhead */ - baudrate *= 7.5; /* convert to chars/minute (60/8) */ - gather(); - nsys = 0; - for (sp = syshead; sp; sp = sp->s_sysp) { - if (sp->s_njobs == 0) - continue; - if (!hflag && nsys++ > 0) - putchar('\n'); - printf("%s: %d %s", sp->s_name, - sp->s_njobs, sp->s_njobs > 1 ? "jobs" : "job"); - if (lflag) { - float minutes; - int hours; - /* The 80 * njobs is because of the uucp handshaking */ - minutes = (float)(sp->s_bytes + 80 * sp->s_njobs)/baudrate; - hours = minutes/60; - printf(", %ld bytes, ", sp->s_bytes); - if (minutes > 60){ - printf("%d hour%s, ",hours, - hours > 1 ? "s": ""); - minutes -= 60 * hours; - } - printf("%3.1f minutes (@ effective baudrate of %d)", - minutes,(int)(baudrate/6)); - } - putchar('\n'); - if (hflag) - continue; - /* sort them babies! */ - sortjob = (struct job **)calloc(sp->s_njobs, sizeof (struct job *)); - for (i=0, jp=sp->s_jobp; i < sp->s_njobs; i++, jp=jp->j_jobp) - sortjob[i] = jp; - qsort(sortjob, sp->s_njobs, sizeof (struct job *), jcompare); - for (i = 0; i < sp->s_njobs; i++) { - jp = sortjob[i]; - if (lflag) { - printf("%s %2d %-*s%7ld%5.1f %-12.12s %c %.*s\n", - jp->j_jobno, jp->j_files, Maxulen, jp->j_user, jp->j_bytes, jp->j_bytes/baudrate, - ctime(&jp->j_date) + 4, jp->j_flags, sizeof (jp->j_fname), jp->j_fname - ); - } else { - printf("%s", jp->j_jobno); - putchar((i+1)%10 ? '\t' : '\n'); - } - /* There's no need to keep the force poll if jobs > 1*/ - if (sp->s_njobs > 1 && strcmp("POLL", jp->j_jobno)==0) { - char pbuf[BUFSIZ]; - sprintf(pbuf,"%s/%c.%s%cPOLL", - subdir(Spool, CMDPRE), CMDPRE, - sp->s_name, jp->j_grade); - (void) unlink(pbuf); - } - } - if (!lflag && (sp->s_njobs%10)) - putchar('\n'); - } - exit(0); -} - -jcompare(j1, j2) -struct job **j1, **j2; -{ - int delta; - - delta = (*j1)->j_grade - (*j2)->j_grade; - if (delta) - return delta; - return(strcmp((*j1)->j_jobno,(*j2)->j_jobno)); -} - -/* - * Get all the command file names - */ -gather() -{ - struct direct *d; - DIR *df; - - /* - * Find all the spool files in the spooling directory - */ - if ((df = opendir(subdir(Spool, CMDPRE))) == NULL) { - fprintf(stderr, "can't examine spooling area\n"); - exit(1); - } - for (;;) { - if ((d = readdir(df)) == NULL) - break; - if (d->d_namlen <= 2 || d->d_name[0] != CMDPRE || - d->d_name[1] != '.') - continue; - if (analjob(d->d_name) < 0) { - fprintf(stderr, "out of memory\n"); - break; - } - } - closedir(df); -} - -/* - * analjob does the grunge work of verifying jobs - */ -#include -analjob(filename) -char *filename; -{ - struct job *jp; - struct sys *sp; - char sbuf[MAXNAMLEN+1], str[256], nbuf[256]; - char *jptr, *wrkvec[20]; - char grade; - FILE *fp, *df; - struct stat statb; - int files, gotname, i; - off_t bytes; - - strncpy(sbuf, filename, MAXNAMLEN); - sbuf[MAXNAMLEN] = '\0'; - jptr = sbuf + strlen(sbuf) - WSUFSIZE; - grade = *jptr; - *jptr++ = 0; - /* - * sbuf+2 now points to sysname name (null terminated) - * jptr now points to job number (null terminated) - */ - if (rmjob) { - if (strcmp(rmjob, jptr)) - return(0); - } else { - if ((sp = getsys(sbuf+2)) == NOSYS) - return(0); - if (!lflag) { - /* SHOULD USE A SMALLER STRUCTURE HERE */ - jp = (struct job *)malloc(sizeof(struct job)); - if (jp == (struct job *)0) - return(-1); - strcpy(jp->j_jobno, jptr); - jp->j_jobp = sp->s_jobp; - jp->j_grade = grade; - sp->s_jobp = jp; - sp->s_njobs++; - return(1); - } - } - if ((fp = fopen(subfile(filename), "r")) == NULL) { - perror(subfile(filename)); - return(0); - } - files = 0; - bytes = 0; - gotname = 0; - while (fgets(str, sizeof str, fp)) { - if (getargs(str, wrkvec, 20) <= 0) - continue; - if (rmjob) { - int myuid; - struct passwd *pw; - /* - * Make sure person who is removing data files is - * the person who created it or root. - */ - myuid = getuid(); - pw = getpwnam(W_USER); - if (myuid && (pw == NULL || myuid != pw->pw_uid)) { - fprintf(stderr, "Permission denied.\n"); - exit(1); - } - if (W_TYPE[0] == 'S' && !index(W_OPTNS, 'c')) { - unlink(subfile(W_DFILE)); - fprintf(stderr, "Removing data file %s\n", W_DFILE); - } - continue; - } - if (user && (W_TYPE[0] == 'X' || !prefix(user, W_USER))) { - fclose(fp); - return(0); - } - files++; - if (W_TYPE[0] == 'S') { - if (strcmp(W_DFILE, "D.0") && - stat(subfile(W_DFILE), &statb) >= 0) - bytes += statb.st_size; - else if (stat(subfile(W_FILE1), &statb) >= 0) - bytes += statb.st_size; - } - /* amusing heuristic */ -#define isXfile(s) (s[0]=='D' && s[strlen(s)-WSUFSIZE]=='X') - if (gotname == 0 && isXfile(W_FILE1)) { - if ((df = fopen(subfile(W_FILE1), "r")) == NULL) - continue; - while (fgets(nbuf, sizeof nbuf, df)) { - nbuf[strlen(nbuf) - 1] = '\0'; - if (nbuf[0] == 'C' && nbuf[1] == ' ') { - strcpy(Filename, nbuf+2); - gotname++; - } else if (nbuf[0] == 'R' && nbuf[1] == ' ') { - register char *p, *q, *r; - r = q = p = nbuf+2; - do { - if (*p == '!' || *p == '@'){ - r = q; - q = p+1; - } - } while (*p++); - - strcpy(Username, r); - W_USER = Username; - } - } - fclose(df); - } - } - fclose(fp); - if (rmjob) { - unlink(subfile(filename)); - fprintf(stderr, "Removing command file %s\n", filename); - exit(0); - } - if (files == 0) { - static char *wtype = "X"; - static char *wfile = "forced poll"; - if (strcmp("POLL", &filename[strlen(filename)-4])) { - fprintf(stderr, "%.14s: empty command file\n", filename); - return(0); - } - W_TYPE = wtype; - W_FILE1 = wfile; - } - jp = (struct job *)malloc(sizeof(struct job)); - if (jp == (struct job *)0) - return(-1); - strcpy(jp->j_jobno, jptr); - jp->j_files = files; - jp->j_bytes = bytes; - jp->j_grade = grade; - jp->j_flags = W_TYPE[0]; - strncpy(jp->j_user, W_TYPE[0]=='X' ? "---" : W_USER, 20 ); - jp->j_user[20] = '\0'; - i = strlen(jp->j_user); - if (i > Maxulen) - Maxulen = i; - /* SHOULD ADD ALL INFORMATION IN THE WHILE LOOP */ - if (gotname) - strncpy(jp->j_fname, Filename, sizeof jp->j_fname); - else - strncpy(jp->j_fname, W_FILE1, sizeof jp->j_fname); - stat(subfile(filename), &statb); - jp->j_date = statb.st_mtime; - jp->j_jobp = sp->s_jobp; - sp->s_jobp = jp; - sp->s_njobs++; - sp->s_bytes += jp->j_bytes; - return(1); -} - -struct sys * -getsys(s) -register char *s; -{ - register struct sys *sp; - - for (sp = syshead; sp; sp = sp->s_sysp) - if (strcmp(s, sp->s_name) == 0) - return(sp); - if (sysname && !prefix(sysname, s)) - return(NOSYS); - sp = (struct sys *)malloc(sizeof(struct sys)); - if (sp == NOSYS) - return(NOSYS); - strcpy(sp->s_name, s); - sp->s_njobs = 0; - sp->s_jobp = (struct job *)0; - sp->s_sysp = syshead; - sp->s_bytes = 0; - syshead = sp; - return(sp); -} diff --git a/usr.bin/uucp/uusend/Makefile b/usr.bin/uucp/uusend/Makefile deleted file mode 100644 index 6c13fb4e6dde..000000000000 --- a/usr.bin/uucp/uusend/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= uusend -LINKS= ${BINDIR}/uusend ${BINDIR}/ruusend - -.include diff --git a/usr.bin/uucp/uusend/uusend.1 b/usr.bin/uucp/uusend/uusend.1 deleted file mode 100644 index 937930715295..000000000000 --- a/usr.bin/uucp/uusend/uusend.1 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uusend.1 8.3 (Berkeley) 2/16/94 -.\" -.Dd February 16, 1994 -.Dt UUSEND 1 -.Os BSD 4 -.Sh NAME -.Nm uusend -.Nd send a file to a remote host -.Sh SYNOPSIS -.Nm uusend -.Op Fl m Ar mode -.Ar sourcefile -.Ar sys1!sys2!..!remotefile -.Sh DESCRIPTION -.Nm Uusend -sends a file to a given location on a remote system. -The system need not be directly connected to the local -system, but a chain of -.Xr uucp 1 -links must to connect the two systems. -.Pp -Available option: -.Bl -tag -width Fl -.It Fl m Ar mode -The mode of the file on the remote -end is taken from the octal number given. -Otherwise, the mode of the input file will be used. -.El -.Pp -The sourcefile -can be -.Ql Fl , -meaning to use the standard input. -Both of these options are primarily intended for internal use of -.Nm uusend . -.Pp -The remotefile can include the -.Em ~userid -syntax. -.Sh DIAGNOSTICS -If anything goes wrong any further away than the first system down -the line, you will never hear about it. -.Sh SEE ALSO -.Xr uux 1 , -.Xr uucp 1 , -.Xr uuencode 1 -.Sh BUGS -This command should not exist, since -.Xr uucp -should handle it. -.Pp -All systems along the line must have the -.Nm uusend -command available and allow remote execution of it. -.Pp -Some uucp systems have a bug where binary files cannot be the -input to a -.Xr uux 1 -command. If this bug exists in any system along the line, -the file will show up severely munged. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.0 . diff --git a/usr.bin/uucp/uusend/uusend.c b/usr.bin/uucp/uusend/uusend.c deleted file mode 100644 index 207108e93dca..000000000000 --- a/usr.bin/uucp/uusend/uusend.c +++ /dev/null @@ -1,403 +0,0 @@ -/*- - * Copyright (c) 1980, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uusend.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * uusend: primitive operation to allow uucp like copy of binary files - * but handle indirection over systems. - * - * usage: uusend [-r] [-m ooo] localfile sysname1!sysname2!...!destfile - * uusend [-r] [-m ooo] - sysname1!sysname2!...!destfile - * - * Author: Mark Horton, May 1980. - * - * "-r" switch added. Has same effect as "-r" in uux. 11/82 CCW - * - * Error recovery (a la uucp) added & ifdefs for ruusend (as in rmail). - * Checks for illegal access to /usr/lib/uucp. - * February 1983 Christopher Woodbury - * Fixed mode set[ug]id loophole. 4/8/83 CCW - * - * Add '-f' to make uusend syntax more similar to UUCP. "destname" - * can now be a directory. June 1983 CCW - */ - -#include -#include -#include -#include - -/* - * define RECOVER to permit requests like 'uusend file sys1!sys2!~uucp' - * (abbreviation for 'uusend file sys1!sys2!~uucp/file'). - * define DEBUG to keep log of uusend uusage. - * define RUUSEND if neighboring sites permit 'ruusend', - * which they certainly should to avoid security holes - */ -#define RECOVER -/*#define DEBUG "/usr/spool/uucp/uusend.log"/**/ - -FILE *in, *out; -FILE *dout; - -extern FILE *popen(); -extern char *index(), *strcpy(), *strcat(), *ctime(); - -#ifdef RUUSEND -int rsend; -#endif RUUSEND -int mode = -1; /* mode to chmod new file to */ -char *nextsys; /* next system in the chain */ -char dnbuf[200]; /* buffer for result of ~user/file */ -char cmdbuf[256]; /* buffer to build uux command in */ -char *rflg = ""; /* default value of rflg ccw -- 1 Nov '82 */ - -struct passwd *user; /* entry in /etc/passwd for ~user */ -struct passwd *getpwnam(); -struct stat stbuf; - -char *excl; /* location of first ! in destname */ -char *sl; /* location of first / in destname */ -char *sourcename; /* argv[1] */ -char *destname; /* argv[2] */ -char *UULIB = "/usr/lib/uucp"; /* UUCP lib directory */ - -#ifdef RECOVER -char *UUPUB = "/usr/spool/uucppublic/"; /* public UUCP directory */ -char *filename; /* file name from end of destname */ -char *getfname(); /* routine to get filename from destname */ -int fflg; -char f[100]; /* name of default output file */ -#else !RECOVER -char *f = ""; /* so we waste a little space */ -#endif !RECOVER - -main(argc, argv) -int argc; -char **argv; -{ - register int c; - long count; - extern char **environ; - -#ifdef DEBUG - long t; - umask(022); - dout = fopen(DEBUG, "a"); - if (dout == NULL) { - printf("Cannot append to %s\n", DEBUG); - exit(1); - } - freopen(DEBUG, "a", stdout); - fprintf(dout, "\nuusend run: "); - for (c=0; c 1 && argv[1][0] == '-' && argv[1][1]) { - switch(argv[1][1]) { - case 'm': - sscanf(argv[2], "%o", &mode); - mode &= 0777; /* fix set[ug]id loophole */ - argc--; argv++; - break; - case 'r': /* -r flag for uux */ - rflg = "-r "; - break; -#ifdef RECOVER - case 'f': - fflg++; - strcpy(f, argv[1]); - break; -#endif RECOVER - default: - fprintf(stderr, "Bad flag: %s\n", argv[1]); - break; - } - argc--; argv++; - } - - if (argc != 3) { - fprintf(stderr, "Usage: uusend [-m ooo] [-r] -/file sys!sys!..!rfile\n"); - exit(1); - } - - sourcename = argv[1]; - destname = argv[2]; - - if (sourcename[0] == '-') - in = stdin; - else { -#ifdef RUUSEND - if (rsend) { - fprintf(stderr, "illegal input\n"); - exit(2); - } -#endif RUUSEND - in = fopen(sourcename, "r"); - if (in == NULL) { - perror(argv[1]); - exit(2); - } - if (!fflg || f[2] == '\0') { - strcpy(f, "-f"); - strcat(f, getfname(sourcename)); - fflg++; - } - } - - excl = index(destname, '!'); - if (excl) { - /* - * destname is on a remote system. - */ - nextsys = destname; - *excl++ = 0; - destname = excl; - if (mode < 0) { - fstat(fileno(in), &stbuf); - mode = stbuf.st_mode & 0777; - } -#ifdef RUUSEND - sprintf(cmdbuf,"uux -gn -z %s- \"%s!ruusend %s -m %o - (%s)\"", -#else !RUUSEND - sprintf(cmdbuf, "uux -gn -z %s- \"%s!uusend %s -m %o - (%s)\"", -#endif !RUUSEND - rflg, nextsys, f, mode, destname); -#ifdef DEBUG - fprintf(dout, "remote: nextsys='%s', destname='%s', cmd='%s'\n", nextsys, destname, cmdbuf); -#endif DEBUG - out = popen(cmdbuf, "w"); - } else { - /* - * destname is local. - */ - if (destname[0] == '~') { -#ifdef DEBUG - fprintf(dout, "before ~: '%s'\n", destname); -fflush(dout); -#endif DEBUG - sl = index(destname, '/'); -#ifdef RECOVER - if (sl == NULL && !fflg) { - fprintf(stderr, "Illegal ~user\n"); - exit(3); - } - for (sl = destname; *sl != '\0'; sl++) - ; /* boy, is this a hack! */ -#else !RECOVER - if (sl == NULL) { - fprintf(stderr, "Illegal ~user\n"); - exit(3); - } - *sl++ = 0; -#endif !RECOVER - user = getpwnam(destname+1); - if (user == NULL) { - fprintf(stderr, "No such user as %s\n", - destname); -#ifdef RECOVER - if ((filename =getfname(sl)) == NULL && - !fflg) - exit(4); - strcpy(dnbuf, UUPUB); - if (fflg) - strcat(dnbuf, &f[2]); - else - strcat(dnbuf, filename); - } - else { - strcpy(dnbuf, user->pw_dir); - strcat(dnbuf, "/"); - strcat(dnbuf, sl); - } -#else !RECOVER - exit(4); - } - strcpy(dnbuf, user->pw_dir); - strcat(dnbuf, "/"); - strcat(dnbuf, sl); -#endif !RECOVER - destname = dnbuf; - } -#ifdef RECOVER - else - destname = strcpy(dnbuf, destname); -#endif !RECOVER - if(strncmp(UULIB, destname, strlen(UULIB)) == 0) { - fprintf(stderr, "illegal file: %s", destname); - exit(4); - } -#ifdef RECOVER - if (stat(destname, &stbuf) == 0 && - (stbuf.st_mode & S_IFMT) == S_IFDIR && - fflg) { - strcat(destname, "/"); - strcat(destname, &f[2]); - } -#endif RECOVER - out = fopen(destname, "w"); -#ifdef DEBUG - fprintf(dout, "local, file='%s'\n", destname); -#endif DEBUG - if (out == NULL) { - perror(destname); -#ifdef RECOVER - if (strncmp(destname,UUPUB,strlen(UUPUB)) == 0) - exit(5); /* forget it! */ - filename = getfname(destname); - if (destname == dnbuf) /* cmdbuf is scratch */ - filename = strcpy(cmdbuf, filename); - destname = strcpy(dnbuf, UUPUB); - if (user != NULL) { - strcat(destname, user->pw_name); - if (stat(destname, &stbuf) == -1) { - mkdir(destname, 0777); - } - strcat(destname, "/"); - } - if (fflg) - strcat(destname, &f[2]); - else - strcat(destname, filename); - if ((out = fopen(destname, "w")) == NULL) - exit(5); /* all for naught! */ -#else !RECOVER - exit(5); -#endif !RECOVER - } - if (mode > 0) - chmod(destname, mode); /* don't bother to check it */ - } - - /* - * Now, in any case, copy from in to out. - */ - - count = 0; - while ((c=getc(in)) != EOF) { - putc(c, out); - count++; - } -#ifdef DEBUG - fprintf(dout, "count %ld bytes\n", count); - fclose(dout); -#endif DEBUG - - fclose(in); - fclose(out); /* really should pclose in that case */ - exit(0); -} - -/* - * Return the ptr in sp at which the character c appears; - * NULL if not found. Included so I don't have to fight the - * index/strchr battle. - */ - -#define NULL 0 - -char * -index(sp, c) -register char *sp, c; -{ - do { - if (*sp == c) - return(sp); - } while (*sp++); - return(NULL); -} - -#ifdef RECOVER -char * -getfname(p) -register char *p; -{ - register char *s; - s = p; - while (*p != '\0') - p++; - if (p == s) - return (NULL); - for (;p != s; p--) - if (*p == '/') { - p++; - break; - } - return (p); -} - -#ifndef BSD4_2 -makedir(dirname, mode) -char *dirname; -int mode; -{ - register int pid; - int retcode, status; - switch ((pid = fork())) { - case -1: /* error */ - return (-1); - case 0: /* child */ - umask(0); - execl("/bin/mkdir", "mkdir", dirname, (char *)0); - exit(1); - /* NOTREACHED */ - default: /* parent */ - while ((retcode=wait(&status)) != pid && retcode != -1) - ; - if (retcode == -1) - return -1; - else { - chmod(dirname, mode); - return status; - } - } - /* NOTREACHED */ -} -#endif !BSD4_2 -#endif RECOVER diff --git a/usr.bin/uucp/uusnap/uusnap.8 b/usr.bin/uucp/uusnap/uusnap.8 deleted file mode 100644 index 92f0e3307e32..000000000000 --- a/usr.bin/uucp/uusnap/uusnap.8 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uusnap.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUSNAP 8 -.Os BSD 4.2 -.Sh NAME -.Nm uusnap -.Nd show snapshot of the -.Tn UUCP -system -.Sh SYNOPSIS -.Nm uusnap -.Sh DESCRIPTION -.Nm Uusnap -displays in tabular format a synopsis of the current -.Tn UUCP -situation. The format of each line is as follows: -.Bd -literal -offset indent -compact - -site N Cmds N Data N Xqts Message - -.Ed -Where "site" is the name of the site with work, "N" is a count of -each of the three possible types of work (command, data, or remote execute), -and "Message" is the current status message for that -site as found in the -.Tn STST -file. -.Pp -Included in "Message" may be the time left before -.Tn UUCP -can re-try the -call, and the count of the number of times that -.Tn UUCP -has tried -(unsuccessfully) to reach the site. -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uuq 1 , -.Xr uucico 8 -.Rs -.%T "UUCP Implementation Guide" -.Re -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/usr.bin/uucp/uusnap/uusnap.c b/usr.bin/uucp/uusnap/uusnap.c deleted file mode 100644 index 565c52af72ac..000000000000 --- a/usr.bin/uucp/uusnap/uusnap.c +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Adams. Originally by RJKing WECo-MG6565 May 83. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uusnap.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "uucp.h" -#include -#ifdef NDIR -#include "ndir.h" -#else -#include -#endif -#include - -#define NSYSTEM 300 /* max # of systems queued */ - -#define CMDSLEN 5 /* Length of trailer */ -#define DATALEN 5 /* Length of trailer */ -#define XEQTLEN 5 /* Length of trailer */ -#define NUMCTRS 3 /* # file types to count */ -#define CMDTYPE 0 /* Index into scnt.cntr */ -#define DATTYPE 1 /* Index into scnt.cntr */ -#define XEQTYPE 2 /* Index into scnt.cntr */ - -struct scnt { /* System count structure */ - char name[MAXBASENAME+1]; /* Name of system */ - short cntr[NUMCTRS]; /* Count */ - char stst[32]; /* STST Message */ - time_t locked; /* If LCK..sys present */ - int st_type; /* STST Type */ - int st_count; /* STST Count */ - time_t st_lastime; /* STST Last time tried */ - time_t st_retry; /* STST Secs to retry */ - }; - -int sndx; /* Number of systems */ -struct scnt sys[NSYSTEM]; /* Systems queued */ -int xqtisrunning = 0; - -main() -{ - register int i, j, nlen = 0; - time_t curtime, t; - - dodir(CMDSDIR, "C.", CMDSLEN, '\0', CMDTYPE); - dodir(DATADIR, "D.", DATALEN, '\0', DATTYPE); - dodir(XEQTDIR, "X.", XEQTLEN, 'X', XEQTYPE); - getstst(SPOOL); - time(&curtime); - for(i=0; i nlen) - nlen = j; - for(i=0; i1?"s":" "); - else - printf(" --- "); - if(sys[i].cntr[DATTYPE]) - printf("%3.d Data ", sys[i].cntr[DATTYPE]); - else - printf(" --- "); - if(sys[i].cntr[XEQTYPE]) - printf("%3.d Xqt%s ", sys[i].cntr[XEQTYPE], - sys[i].cntr[XEQTYPE]>1?"s":" "); - else - printf(" --- "); - if(*sys[i].stst == '\0' || sys[i].locked > sys[i].st_lastime) { - if(sys[i].locked) - printf("LOCKED\n"); - else - printf("\n"); - continue; - } - printf("%s ", sys[i].stst); - /* decide if STST info is worth pursuing */ - if (-t < ONEDAY*2 && (sys[i].st_count == 0 - || sys[i].st_type == SS_WRONGTIME - || (sys[i].st_type == SS_INPROGRESS && sys[i].locked))) { - printf("\n"); - continue; - } - t = (sys[i].st_lastime +sys[i].st_retry) - curtime; - if (-t < ONEDAY*2 && sys[i].st_type != SS_FAIL) - t = 0; - - if (sys[i].st_count > MAXRECALLS) - printf("at MAX RECALLS"); - else if (-t >= ONEDAY*2) - printf("%ld days ago", (long)-t/ONEDAY); - else if (t <= 0) - printf("Retry time reached"); - else if (t < 60) - printf("Retry time %ld sec%s", (long)(t%60), - (t%60)!=1? "s": ""); - else - printf("Retry time %ld min%s", (long)(t/60), - (t/60)!=1? "s": ""); - if(sys[i].st_count > 1) - printf(" Count: %d\n", sys[i].st_count); - else - printf("\n"); - } - if (xqtisrunning) - printf("\nUuxqt is running\n"); - exit(0); -} - -dodir(dnam, prfx, flen, fchr, type) -char *dnam, *prfx; -int flen; -char fchr; -int type; -{ - register struct direct *dentp; - register DIR *dirp; - register int i, fnamlen, plen; - char fnam[MAXNAMLEN+1]; - - plen = strlen(prfx); - if(chdir(dnam) < 0) { - perror(dnam); - exit(1); - } - if ((dirp = opendir(".")) == NULL) { - perror(dnam); - exit(1); - } - while((dentp = readdir(dirp)) != NULL) { - if(*dentp->d_name == '.') - continue; - if(strncmp(dentp->d_name, prfx, plen) != SAME) { - fprintf(stderr, "strange file (%s) in %s\n", - dentp->d_name, dnam); - continue; - } - strcpy(fnam, &dentp->d_name[plen]); - fnamlen = strlen(fnam); - if(flen > 0) { - fnamlen -= flen; - fnam[fnamlen] = '\0'; - fnamlen = MAXBASENAME; /* yes, after = '\0'*/ - } else { - for(; fnamlen>0; --fnamlen) { - if(fnam[fnamlen] == fchr) { - fnam[fnamlen] = '\0'; - break; - } - } - fnamlen = MAXBASENAME; - } - for(i=0; i= NSYSTEM) { - sndx = NSYSTEM-1; - fprintf(stderr,"Too many system names.\n"); - } - } - } - closedir(dirp); -} - -getstst(sdir) -char *sdir; -{ - register int i, csys; - register char *tp; - char fnam[MAXNAMLEN+1], buff[128]; - register struct direct *dentp; - register DIR *dirp; - register FILE *st; - struct stat stbuf; - long atol(); - - if (chdir(sdir) < 0) { - perror(sdir); - exit(1); - } - if ((dirp = opendir(LOCKDIR)) == NULL) { - perror(sdir); - exit(1); - } - while ((dentp = readdir(dirp)) != NULL) { - if (strcmp(&dentp->d_name[5], X_LOCK) == SAME) { - xqtisrunning++; - continue; - } - if(strncmp(dentp->d_name, "LCK..", 5) == SAME) { - if(strncmp(&dentp->d_name[5], "tty", 3) == SAME || - strncmp(&dentp->d_name[5], "cul", 3) == SAME) - continue; - strcpy(fnam, dentp->d_name); - for(csys=0; csysd_name == '.') - continue; - strcpy(fnam, dentp->d_name); - for(csys=0; csys diff --git a/usr.bin/whatis/whatis.1 b/usr.bin/whatis/whatis.1 deleted file mode 100644 index 0f1b0a1b04de..000000000000 --- a/usr.bin/whatis/whatis.1 +++ /dev/null @@ -1,105 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)whatis.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt WHATIS 1 -.Os BSD 4 -.Sh NAME -.Nm whatis -.Nd describe what a command is -.Sh SYNOPSIS -.Nm whatis -.Op Fl M Ar path -.Op Fl m Ar path -.Ar command Ar ... -.Sh DESCRIPTION -.Nm Whatis -looks up a given command and gives the header line from the manual page. -You can then use the -.Xr man 1 -command to get more information. -.Pp -The options are as follows: -.Bl -tag -width Fl -.It Fl M Ar path -Override the list of standard directories -.Nm whatis -searches for its database named -.Dq Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -.It Fl m Ar path -Augment the list of standard directories -.Nm whatis -searches for its database named -.Dq Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -These directories will be searched before the standard directories -or the directories supplied with the -.Fl M -option or the -.Ev MANPATH -environment variable are searched. -.El -.Sh ENVIRONMENT -.Bl -tag -width MANPATH -.It Ev MANPATH -The standard search path used by -.Xr man 1 -may be overridden by specifying a path in the -.Ev MANPATH -environment variable. -.El -.Sh FILES -.Bl -tag -width whatis.db -.It Pa whatis.db -name of the whatis database -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr man 1 , -.Xr whereis 1 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 3.0 . diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c deleted file mode 100644 index 904f0e479819..000000000000 --- a/usr.bin/whatis/whatis.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)whatis.c 8.5 (Berkeley) 1/2/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -#include "../man/config.h" -#include "../man/pathnames.h" - -#define MAXLINELEN 256 /* max line handled */ - -static int *found, foundman; - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - extern int optind; - ENTRY *ep; - TAG *tp; - int ch, rv; - char *beg, *conffile, **p, *p_augment, *p_path; - - conffile = NULL; - p_augment = p_path = NULL; - while ((ch = getopt(argc, argv, "C:M:m:P:")) != EOF) - switch (ch) { - case 'C': - conffile = optarg; - break; - case 'M': - case 'P': /* backward compatible */ - p_path = optarg; - break; - case 'm': - p_augment = optarg; - break; - case '?': - default: - usage(); - } - argv += optind; - argc -= optind; - - if (argc < 1) - usage(); - - if ((found = malloc((u_int)argc * sizeof(int))) == NULL) - err(1, NULL); - memset(found, 0, argc * sizeof(int)); - - for (p = argv; *p; ++p) /* trim full paths */ - if (beg = rindex(*p, '/')) - *p = beg + 1; - - if (p_augment) - whatis(argv, p_augment, 1); - if (p_path || (p_path = getenv("MANPATH"))) - whatis(argv, p_path, 1); - else { - config(conffile); - ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - whatis(argv, ep->s, 0); - } - - if (!foundman) { - fprintf(stderr, "whatis: no %s file found.\n", _PATH_WHATIS); - exit(1); - } - rv = 1; - for (p = argv; *p; ++p) - if (found[p - argv]) - rv = 0; - else - printf("%s: not found\n", *p); - exit(rv); -} - -whatis(argv, path, buildpath) - char **argv, *path; - int buildpath; -{ - register char *end, *name, **p; - char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; - - for (name = path; name; name = end) { /* through name list */ - if (end = index(name, ':')) - *end++ = '\0'; - - if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); - name = hold; - } - - if (!freopen(name, "r", stdin)) - continue; - - foundman = 1; - - /* for each file found */ - while (fgets(buf, sizeof(buf), stdin)) { - dashtrunc(buf, wbuf); - for (p = argv; *p; ++p) - if (match(wbuf, *p)) { - printf("%s", buf); - found[p - argv] = 1; - - /* only print line once */ - while (*++p) - if (match(wbuf, *p)) - found[p - argv] = 1; - break; - } - } - } -} - -/* - * match -- - * match a full word - */ -match(bp, str) - register char *bp, *str; -{ - register int len; - register char *start; - - if (!*str || !*bp) - return(0); - for (len = strlen(str);;) { - for (; *bp && !isdigit(*bp) && !isalpha(*bp); ++bp); - if (!*bp) - break; - for (start = bp++; - *bp && (*bp == '_' || isdigit(*bp) || isalpha(*bp)); ++bp); - if (bp - start == len && !strncasecmp(start, str, len)) - return(1); - } - return(0); -} - -/* - * dashtrunc -- - * truncate a string at " - " - */ -dashtrunc(from, to) - register char *from, *to; -{ - register int ch; - - for (; (ch = *from) && ch != '\n' && - (ch != ' ' || from[1] != '-' || from[2] != ' '); ++from) - *to++ = ch; - *to = '\0'; -} - -/* - * usage -- - * print usage message and die - */ -usage() -{ - (void)fprintf(stderr, - "usage: whatis [-C file] [-M path] [-m path] command ...\n"); - exit(1); -} diff --git a/usr.bin/which/which.sh b/usr.bin/which/which.sh deleted file mode 100755 index 7167140d8fbc..000000000000 --- a/usr.bin/which/which.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/csh -# -# -# Copyright (C) 1994, Joerg Wunsch -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# [whew!] -# -# $Id$ - -foreach i ($argv) - echo -n "${i}: " - - set a = `alias $i` - - if ("$a" != "") then # test for alias - echo "aliased to $a" - else if ("$i" =~ /*) then # absolute path name - if (! -x "$i") then - echo "not found" - else - echo "$i" - endif - else # search $path - set found = 0 - foreach p ($path) - - if (-x "$p/$i") then - echo "$p/$i" - set found = 1 - break - endif - end - if ($found == 0) echo "not found" - endif -end diff --git a/usr.sbin/arp/arp4.4 b/usr.sbin/arp/arp4.4 deleted file mode 100644 index 0cd716145005..000000000000 --- a/usr.sbin/arp/arp4.4 +++ /dev/null @@ -1,124 +0,0 @@ -.\" Copyright (c) 1985, 1986, 1988, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)arp4.4 6.5 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt ARP 4 -.Os BSD 4 -.Sh NAME -.Nm arp -.Nd Address Resolution Protocol -.Sh SYNOPSIS -.Em "pseudo-device ether" -.Sh DESCRIPTION -The Address Resolution Protocol (ARP) is a protocol used to dynamically -map between Internet host addresses and 10Mb/s Ethernet addresses. -It is used by all the 10Mb/s Ethernet interface drivers. -It is not specific to Internet protocols or to 10Mb/s Ethernet, -but this implementation currently supports only that combination. -.Pp -ARP caches Internet-Ethernet address mappings. -When an interface requests a mapping for an address not in the cache, -ARP queues the message which requires the mapping and broadcasts -a message on the associated network requesting the address mapping. -If a response is provided, the new mapping is cached and any pending -message is transmitted. -ARP will queue at most one packet while waiting for a response to a -mapping request; -only the most recently ``transmitted'' packet is kept. -If the target host does not respond after several requests, -the host is considered to be down for a short period (normally 20 seconds), -allowing an error to be returned to transmission attempts during this -interval. -The error is -.Li EHOSTDOWN -for a non-responding destination host, and -.Li EHOSTUNREACH -for a non-responding router. -.Pp -The ARP cache is stored in the system routing table as -dynamically-created host routes. -The route to a directly-attached Ethernet network is installed as a -.Dq cloning -route (one with the -.Li RTF_CLONING -flag set), -causing routes to individual hosts on that network to be created on -demand. -These routes time out periodically (normally 20 minutes after validated; -entries are not validated when not in use). -An entry for a host which is not responding is a -.Dq reject -route (one with the -.Li RTF_REJECT -flag set). -.Pp -ARP entries may be added, deleted or changed with the -.Xr arp 8 -utility. -Manually-added entries may be temporary or permanent, -and may be -.Dq published , -in which case the system will respond to ARP requests for that host -as if it were the target of the request. -.Pp -In the past, -ARP was used to negotiate the use of a trailer encapsulation. -This is no longer supported. -.Pp -ARP watches passively for hosts impersonating the local host (i.e. a host -which responds to an ARP mapping request for the local host's address). -.Sh DIAGNOSTICS -.Em "duplicate IP address %x!! sent from ethernet address: %x:%x:%x:%x:%x:%x." -ARP has discovered another host on the local network which responds to -mapping requests for its own Internet address with a different Ethernet -address, generally indicating that two hosts are attempting to use the -same Internet address. -.Sh SEE ALSO -.Xr inet 4 , -.Xr route 4 , -.Xr arp 8 , -.Xr ifconfig 8 , -.Xr route 8 -.sp -.Rs -.%A Plummer, D. -.%B "An Ethernet Address Resolution Protocol" -.%T RFC826 -.Re -.Rs -.%A Leffler, S.J. -.%A Karels, M.J. -.%B "Trailer Encapsulations -.%T RFC893 -.Re - diff --git a/usr.sbin/bootpd/Announce b/usr.sbin/bootpd/Announce deleted file mode 100644 index e4ae04c20d84..000000000000 --- a/usr.sbin/bootpd/Announce +++ /dev/null @@ -1,63 +0,0 @@ - -This is an enhanced version of the CMU BOOTP server which was derived -from the original BOOTP server created by Bill Croft at Stanford. -This version merges most of the enhancements and bug-fixes from the -NetBSD, Columbia, and other versions. - -New features in version 2.4 include: - - Added a simple BOOTP gateway program: bootpgw - Allow host name anywhere IP address is expected. - Automatically lookup the IP address when the name of a - bootptab entry is a valid hostname. - (Dummy entries names should start with '.') - Merged changes from NetBSD and Columbia versions. - Merged changes for Solaris-2.X and SVR4 systems. - Combined bootptest into the bootp release. - Merged tag 18 support (:ef=...:) from Jason Zions. - Use :ef=extension_file_name: and make the - extension files for all clients using bootpef. - Merged HP compatibility (:ra=...:) from David R Linn. - Allows you to override the reply address. - (i.e. send the reply to a broadcast address) - Add /etc/ethers support for NetBSD. - More systems support getether (Ultrix, OSF, NetBSD) - Added RFC 1533 tags 40,41,42 - :yd=:ys=:nt=: - ConvOldTab.sh to convert old (1.1) bootptab to new format. - Permits extended-length replies with more option data. - -Problems fixed in this version: - - Fixed references to free host structures. - (used to cause core dump on Solaris) - Remove change that added null terminator to string options. - (this annoyed some clients...) - Add missing symbols to dump routine, fix order. - Works (again) with no -DSYSLOGD defined. - Fixed several more NULL references in readfile. - Added proper length checks to option insertions. - Fixed bootptest IP address printing. - Cleaned-up signed/unsigned and byteorder bugs. - Added SVR4/Streams support to getif and getether - Removed extra newlines in syslog messages. - Specify facility code when calling syslog(3) - When lookup_hwa fails, assume numeric HW address. - -Systems on which I have seen this code work: - SunOS 4.X (Solaris 1.X) - SunOS 5.X (Solaris 2.X) - System V/386 Rel. 4.0 - -Systems on which others say this code works: - CDC EP/IX (1.4.3, 2.1.1) - DEC Ultrix (4.2, 4.3) - NetBSD (Current-8/94) - OSF/1 (DEC Alpha CPU) - -Please direct questions, comments, and bug reports to: - - -Gordon W. Ross Mercury Computer Systems -gwr@mc.com 199 Riverneck Road -508-256-1300 Chelmsford, MA 01824-2820 diff --git a/usr.sbin/bootpd/Changes b/usr.sbin/bootpd/Changes deleted file mode 100644 index 06165486acc5..000000000000 --- a/usr.sbin/bootpd/Changes +++ /dev/null @@ -1,245 +0,0 @@ -Changes, most recent first -Date, Real Name - what... - ---> bootp-2.4.0 - -08/20/94 gwr@mc.com (Gordon W. Ross) - Fix code to build bootfile name based on combination of - client requested name and bootfile specifications. - Behave similarly with or without CHECK_FILE_ACCESS. - -07/30/94 Dirk Koeppen - Add "min wait" option (mw) to cause bootpd to ignore - requests from clients that have not waited long enough. - Add code to honor client requests containing the DHCP - option "Maximum Message Size" and use its value to - determine the size of the reply message. - ---> bootp-2.3.8 - -06/25/94 Christos Zoulas - Add "-h" flag to override host name (affects default IP - address provided in reply messages. (Also minor bug fix) - -05/27/94 gwr@mc.com (Gordon W. Ross) - Add code to call "arp -s IPADDR HWADDR" on systems - that do not provide an SIOCSARP ioctl (i.e. NetBSD) - ---> bootp-2.3.7 - -05/05/94 Walter Wong - Reduce noize at debug level one, where log messages - are generated only for hosts that are recognized - and replied to by bootpd. (At request of HP folks.) - -04/30/94 gwr@mc.com (Gordon W. Ross) - Use memxxx functions unless USE_BFUNCS is defined. - Added -f option to bootptest (requested file). - -04/29/94 tpaquett@ita.lgc.com (Trevor Paquette) - Remove call to haddr_conv802() in sendreply(). - The setarp should get the non-transformed address. - -04/27/94 gwr@mc.com - Improve logic for building bootfile pathname, so a path - will be put in the reply if either the client or bootpd - specifies a boot file. (Needed for NetBSD diskless boot) - -04/25/94 shamash@boxhill.com (Ari Shamash) - Fix prs_inetaddr() so it allows '_' in hostnames. - -04/16/94 gwr@mc.com (Gordon W. Ross) - Fix setarp for SVR4 (needs to use I_STR ioctl) - Thanks to several people: (all sent the same fix) - Barney Wolff , - bear@upsys.se (Bj|rn Sj|holm), - Michael Kuschke , - -03/25/95 Ulrich Heuer - Make option string lengths not include a null terminator. - The trailing null breaks some clients. - -03/15/94 "Edmund J. Sutcliffe" - Add support for the "EX" option: Execute a program - before sending a BOOTREPLY to a client. Support for - this option is conditional on YORK_EX_OPTION. - -03/10/94 Nigel Metheringham - Make getether.c work on Linux. - -03/09/94 Koch@Math.Uni-Duisburg.DE (Peter Koch) - Add missing MANDIR definition to Makefile. - -03/08/94 Jeroen.Scheerder@let.ruu.nl - Fix args to report in getether code for Ultrix. - Run install individually for each program. - ---> bootp-2.3.6 -03/07/94 gwr@mc.com - Cleanup for release (run gnu indent, tab-size=4) - -02/24/94 Jeroen.Scheerder@let.ruu.nl - Allow underscore in host names - readfile.c:goodname() - Add ConvOldTab.sh - converts 1.1 bootptab to new format. - -02/20/94 gwr@mc.com (Gordon W. Ross) - Make readfile tolerant of hardware addresses that start - with a letter. (If lookup_hwa() fails, assume numeric.) - Fix whitespace skip before :vm= auto: and avoid lookup. - -02/12/94 walker@zk3.dec.com (Mary Walker) - Added support for 64-bit longs (for the DEC Alpha) - Allow ieee802 hardware address in bit-reversed oreder - -02/07/94 hl@tekla.fi (Harald Lundberg) - Fix conflict with DUMP_FILE in syslog.h on OSF1 - Use int for (struct bootp).bp_xid (for DEC Alpha) - Added Ultrix support to bootptest (getether) - -02/06/94 brezak@ch.hp.com (John Brezak) - Add man-page and install targets to Makefile.NetBSD - Add getether support for NetBSD - -02/05/94 gwr@mc.com (Gordon W. Ross) - Added tags 40,41,42 (NIS domain, NIS server, NTP server) - Add stub to getether for machines not yet supported. - ---> bootp-2.3.5 -01/29/94 gwr@mc.com (Gordon W. Ross) - Make bootpgw put a correct address in "giaddr" when - the client request came via broadcast. - -01/22/94 gwr@mc.com (Gordon W. Ross) - Fix syslog call (missing "facility" code) - Add SVR4/Streams support to getif() and getether() - Fix getif bug (matched when it should not) - Macro-ize lots of similar cases in readfile.c - -12/27/93 brezak@ch.hp.com (John Brezak) - Remove all newlines passed to syslog(3) - Add /etc/ethers support for NetBSD. - -12/18/93 gwr@mc.com (Gordon W. Ross) - Fix bootptest IP address printing. - Fix byte-order bugs in bootpgw and bootptest. - Clean-up signed/unsigned mismatches. - Back out SLIP support changes for now - (code fragment saved in ToDo). - ---> bootp-2.3.4 (beta test release) -12/12/93 gwr@mc.com (Gordon W. Ross) - Fixed several more NULL references in readfile. - Added proper length checks to option insertions. - ---> bootp-2.3.3 (beta test release) -12/09/93 gwr@mc.com (Gordon W. Ross) - Added ASSERT checks to readfile.c:fill_defaults() - -12/08/93 brezak@ch.hp.com (John Brezak) - New Makefile.NetBSD - Added setsid() and #ifdef TIOCNOTTY - (bootpd.c, bootpgw.c) - Moved #include out of #ifdef SUNOS - Fixed several multiple declaration problems - -12/04/93 gwr@mc.com (Gordon W. Ross) - Re-implemented Extension File support - based on work by Jason Zions - Added support for Reply-Address-Override to support - HP clients (need reply sent to broadcast address) - from David R. Linn - ---> bootp-2.3.2 (beta test release) -11/27/93 gwr@mc.com (Gordon W. Ross) - Incorporated bootptest into the bootp release. - Added ANSI function prototypes everywhere. - -11/17/93 dpm@depend.com (David P. Maynard) - Added automatic SLIP address determination. - (This is NOT dynamic IP address assignment.) - Cleaned up some type warnings from gcc. - -11/11/93 gwr@mc.com (Gordon W. Ross) - Works (again) with no -DSYSLOGD defined. - Provide a default value for the subnet mask. - More #ifdef's for SunOS specific code (lookup_hwa) - Added a simple BOOTP gateway program: bootpgw - Reorganized for more code sharing (with bootpgw) - ---> bootp-2.3.1 (alpha test release) -11/08/93 gwr@mc.com (Gordon W. Ross) - Back-out changes to honor option structure in request - (this needs to be a per-client option). - Merged changes from NetBSD and Columbia versions. - Allow host name anywhere IP address is expected. - Add null terminators to option strings. - Add missing symbols to dump routine, dump symbols - in alphabetical order, one tag per line. - ---> bootp-2.2.D (posted as patch 2) -10/19/93 gwr@mc.com (Gordon W. Ross) - Fix references to free memory (leads to core dumps). - ---> bootp-2.2.C (posted as patch 1) -10/14/93 gwr@mc.com (Gordon W. Ross) - Fix data access alignment problems on SPARC/Solaris. - ---> bootp-2.2.B (posted to usenet) -10/11/93 gwr@mc.com (Gordon W. Ross) - Allow extended-length BOOTP packets (more vendor options) - Honor option format specified in client requests. - Added Solaris-2.X changes from db@sunbim.be (Danny Backx). - -All history before this point may be inaccurate. Please send -changes if any of the credits are incorrect. -gwr - ---> bootp-2.2+NetBSD released -08/27/93 brezak@ch.hp.com (John Brezak) - Added RFC 1396 support (tags 14-17) - ---> bootp-2.2+NetBSD (version?) -??/??/93 mckim@lerc.nasa.gov (Jim McKim) - Ported to NetBSD (see Makefile.NetBSD) - Set server host name in responses. - Check all interfaces in address match routine. - ---> bootp-2.2+FdC released -01/27/93 Frank da Cruz - Added RFC 1395 information: Merit dump file, - client domain name, swap server address, root path. - ---> bootp-2.2alpha released -11/14/91 Walter L. Wimer - Add "td" to TFTP directory for "secure" (chroot) TFTP. - Add "sa" tag to set explicit server address. - Automatically determine if child of inetd. - Use RFC 1048 format when request has magic number zero. - Fixed various bugs. Give bootptab a separate man page. - ---> bootp-2.1 released -01/09/89 Walter L. Wimer - Check world read bit on TFTP boot file. - Add support for rfc1085 "bootfile size" tag. - Add generic tags. Fix byte order of rfc1048 data. - Fix various crashing bugs. - ---> bootp-2.0 released -07/15/88 Walter L. Wimer - Added vendor information to conform to RFC1048. - Adopted termcap-like file format to support above. - Added hash table lookup instead of linear search. - Other cleanups. - ---> bootp-1.3(?) released -07/24/87 Drew D. Perkins - Modified to use syslog instead of Kovar's - routines. Add debugging dumps. Many other fixups. - ---> bootp-1.2(?) released -07/30/86 David Kovar at Carnegie Mellon University - Modified to work at CMU. - ---> bootp-1.1 released -01/22/86 Bill Croft at Stanford University - Original created. diff --git a/usr.sbin/bootpd/ConvOldTab.sh b/usr.sbin/bootpd/ConvOldTab.sh deleted file mode 100644 index 00683f0c049c..000000000000 --- a/usr.sbin/bootpd/ConvOldTab.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# convert_bootptab Jeroen.Scheerder@let.ruu.nl 02/25/94 -# This script can be used to convert bootptab files in old format -# to new (termcap-like) bootptab files -# -# The old format - real entries are commented out by '###' -# -# Old-style bootp files consist of two sections. -# The first section has two entries: -# First, a line that specifies the home directory -# (where boot file paths are relative to) - -###/tftpboot - -# The next non-empty non-comment line specifies the default bootfile - -###no-file - -# End of first section - indicated by '%%' at the start of the line - -###%% - -# The remainder of this file contains one line per client -# interface with the information shown by the table headings -# below. The host name is also tried as a suffix for the -# bootfile when searching the home directory (that is, -# bootfile.host) -# -# Note that htype is always 1, indicating the hardware type Ethernet. -# Conversion therefore always yields ':ha=ether:'. -# -# host htype haddr iaddr bootfile -# - -###somehost 1 00:0b:ad:01:de:ad 128.128.128.128 dummy - -# That's all for the description of the old format. -# For the new-and-improved format, see bootptab(5). - -set -u$DX - -case $# -in 2 ) OLDTAB=$1 ; NEWTAB=$2 ;; - * ) echo "Usage: `basename $0` " - exit 1 -esac - -if [ ! -r $OLDTAB ] -then - echo "`basename $0`: $OLDTAB does not exist or is unreadable." - exit 1 -fi - -if touch $NEWTAB 2> /dev/null -then - : -else - echo "`basename $0`: cannot write to $NEWTAB." - exit 1 -fi - - -cat << END_OF_HEADER >> $NEWTAB -# /etc/bootptab: database for bootp server (/etc/bootpd) -# This file was generated automagically - -# Blank lines and lines beginning with '#' are ignored. -# -# Legend: (see bootptab.5) -# first field -- hostname (not indented) -# bf -- bootfile -# bs -- bootfile size in 512-octet blocks -# cs -- cookie servers -# df -- dump file name -# dn -- domain name -# ds -- domain name servers -# ef -- extension file -# gw -- gateways -# ha -- hardware address -# hd -- home directory for bootfiles -# hn -- host name set for client -# ht -- hardware type -# im -- impress servers -# ip -- host IP address -# lg -- log servers -# lp -- LPR servers -# ns -- IEN-116 name servers -# ra -- reply address -# rl -- resource location protocol servers -# rp -- root path -# sa -- boot server address -# sm -- subnet mask -# sw -- swap server -# tc -- template host (points to similar host entry) -# td -- TFTP directory -# to -- time offset (seconds) -# ts -- time servers -# vm -- vendor magic number -# Tn -- generic option tag n -# -# Be careful about including backslashes where they're needed. Weird (bad) -# things can happen when a backslash is omitted where one is intended. -# Also, note that generic option data must be either a string or a -# sequence of bytes where each byte is a two-digit hex value. - -# First, we define a global entry which specifies the stuff every host uses. -# (Host name lookups are relative to the domain: your.domain.name) - -END_OF_HEADER - -# Fix up HW addresses in aa:bb:cc:dd:ee:ff and aa-bb-cc-dd-ee-ff style first -# Then awk our stuff together -sed -e 's/[:-]//g' < $OLDTAB | \ -nawk 'BEGIN { PART = 0 ; FIELD=0 ; BOOTPATH="unset" ; BOOTFILE="unset" } - /^%%/ { - PART = 1 - printf ".default:\\\n\t:ht=ether:\\\n\t:hn:\\\n\t:dn=your.domain.name:\\\n\t:ds=your,dns,servers:\\\n\t:sm=255.255.0.0:\\\n\t:hd=%s:\\\n\t:rp=%s:\\\n\t:td=%s:\\\n\t:bf=%s:\\\n\t:to=auto:\n\n", BOOTPATH, BOOTPATH, BOOTPATH, BOOTFILE - next - } - /^$/ { next } - /^#/ { next } - { - if ( PART == 0 && FIELD < 2 ) - { - if ( FIELD == 0 ) BOOTPATH=$1 - if ( FIELD == 1 ) BOOTFILE=$1 - FIELD++ - } - } - { - if ( PART == 1 ) - { - HOST=$1 - HA=$3 - IP=$4 - BF=$5 - printf "%s:\\\n\t:tc=.default:\\\n\t:ha=0x%s:\\\n\t:ip=%s:\\\n\t:bf=%s:\n", HOST, HA, IP, BF - } - }' >> $NEWTAB - -exit 0 diff --git a/usr.sbin/bootpd/Installation b/usr.sbin/bootpd/Installation deleted file mode 100644 index 466cabce0cdb..000000000000 --- a/usr.sbin/bootpd/Installation +++ /dev/null @@ -1,29 +0,0 @@ - -Installation instructions for SunOS - -Compile the executable: -For SunOS 4.X: - make sunos4 -For SunOS 5.X: (Solaris) - make sunos5 - -Install the executables: - - make install - -Edit (or create) the bootptab: -(See bootptab.sample and bootptab.5 manual entry) - edit /etc/bootptab - -Edit /etc/services to add these two lines: -bootps 67/udp bootp # BOOTP Server -bootpc 68/udp # BOOTP Client - -Edit /etc/inetd.conf to add the line: -bootp dgram udp wait root /usr/etc/bootpd bootpd -i - -If you compiled report.c with LOG_LOCAL2 (defined in the Makefile) -then you may want to capture syslog messages from BOOTP by changing -your syslog.conf file. (See the sample syslog.conf file here). -Test the change with: logger -t test -p local2.info "message" - diff --git a/usr.sbin/bootpd/Makefile.UNIX b/usr.sbin/bootpd/Makefile.UNIX deleted file mode 100644 index e333ce5d2ca8..000000000000 --- a/usr.sbin/bootpd/Makefile.UNIX +++ /dev/null @@ -1,184 +0,0 @@ -# -# Makefile for the BOOTP programs: -# bootpd - BOOTP server daemon -# bootpef - BOOTP extension file builder -# bootpgw - BOOTP gateway daemon -# bootptest - BOOTP tester (client) -# - -# OPTion DEFinitions: -# Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format" -# in addition to the RFC1048 format. Leaving out DEBUG saves little. -OPTDEFS= -DSYSLOG -DVEND_CMU -DDEBUG - -# Uncomment and edit this to choose the facility code used for syslog. -# LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2" - -# SYStem DEFinitions: -# Either uncomment some of the following, or do: -# "make sunos4" (or "make sunos5", etc.) -# SYSDEFS= -DSUNOS -DETC_ETHERS -# SYSDEFS= -DSVR4 -# SYSLIBS= -lsocket -lnsl - -# Uncomment this if your system does not provide streror(3) -# STRERROR=strerror.o - -# FILE DEFinitions: -# The next few lines may be uncommented and changed to alter the default -# filenames bootpd uses for its configuration and dump files. -#CONFFILE= -DCONFIG_FILE=\"/usr/etc/bootptab\" -#DUMPFILE= -DDUMPTAB_FILE=\"/usr/etc/bootpd.dump\" -#FILEDEFS= $(CONFFILE) $(DUMPFILE) - -# MORE DEFinitions (whatever you might want to add) -# One might define NDEBUG (to remove "assert()" checks). -MOREDEFS= - -INSTALL=/usr/bin/install -DESTDIR= -BINDIR=/usr/etc -MANDIR=/usr/local/man - -CFLAGS= $(OPTDEFS) $(SYSDEFS) $(FILEDEFS) $(MOREDEFS) -PROGS= bootpd bootpef bootpgw bootptest -TESTS= trylook trygetif trygetea - -all: $(PROGS) - -tests: $(TESTS) - -system: install - -install: $(PROGS) - -for f in $(PROGS) ;\ - do \ - $(INSTALL) -c -s $$f $(DESTDIR)$(BINDIR) ;\ - done - -MAN5= bootptab.5 -MAN8= bootpd.8 bootpef.8 bootptest.8 -install.man: $(MAN5) $(MAN8) - -for f in $(MAN5) ;\ - do \ - $(INSTALL) -c -m 644 $$f $(DESTDIR)$(MANDIR)/man5 ;\ - done - -for f in $(MAN8) ;\ - do \ - $(INSTALL) -c -m 644 $$f $(DESTDIR)$(MANDIR)/man8 ;\ - done - -clean: - -rm -f core *.o - -rm -f $(PROGS) $(TESTS) - -distclean: - -rm -f *.BAK *.CKP *~ .emacs* - -# -# Handy targets for individual systems: -# - -# DEC/OSF1 on the Alpha -alpha: - $(MAKE) SYSDEFS="-DETC_ETHERS -Dint32=int -D_SOCKADDR_LEN" \ - STRERROR=strerror.o - -# Control Data EP/IX 1.4.3 system, BSD 4.3 mode -epix143: - $(MAKE) CC="cc -systype bsd43" \ - SYSDEFS="-Dconst= -D_SIZE_T -DNO_UNISTD -DUSE_BFUNCS" \ - STRERROR=strerror.o - -# Control Data EP/IX 2.1.1 system, SVR4 mode -epix211: - $(MAKE) CC="cc -systype svr4" \ - SYSDEFS="-DSVR4" \ - SYSLIBS="-lsocket -lnsl" - -# Silicon Graphics IRIX (no , so not SVR4) -irix: - $(MAKE) SYSDEFS="-DSYSV -DIRIX" - -# SunOS 4.X -sunos4: - $(MAKE) SYSDEFS="-DSUNOS -DETC_ETHERS" \ - STRERROR=strerror.o - -# Solaris 2.X (i.e. SunOS 5.X) -sunos5: - $(MAKE) SYSDEFS="-DSVR4 -DETC_ETHERS" \ - SYSLIBS="-lsocket -lnsl" - -# UNIX System V Rel. 4 (also: IRIX 5.X, others) -svr4: - $(MAKE) SYSDEFS="-DSVR4" \ - SYSLIBS="-lsocket -lnsl" - -# -# How to build each program: -# - -OBJ_D= bootpd.o dovend.o readfile.o hash.o dumptab.o \ - lookup.o getif.o hwaddr.o tzone.o report.o $(STRERROR) -bootpd: $(OBJ_D) - $(CC) -o $@ $(OBJ_D) $(SYSLIBS) - -OBJ_EF= bootpef.o dovend.o readfile.o hash.o dumptab.o \ - lookup.o hwaddr.o tzone.o report.o $(STRERROR) -bootpef: $(OBJ_EF) - $(CC) -o $@ $(OBJ_EF) $(SYSLIBS) - -OBJ_GW= bootpgw.o getif.o hwaddr.o report.o $(STRERROR) -bootpgw: $(OBJ_GW) - $(CC) -o $@ $(OBJ_GW) $(SYSLIBS) - -OBJ_TEST= bootptest.o print-bootp.o getif.o getether.o \ - report.o $(STRERROR) -bootptest: $(OBJ_TEST) - $(CC) -o $@ $(OBJ_TEST) $(SYSLIBS) - -# This is just for testing the lookup functions. -TRYLOOK= trylook.o lookup.o report.o $(STRERROR) -trylook : $(TRYLOOK) - $(CC) -o $@ $(TRYLOOK) $(SYSLIBS) - -# This is just for testing getif. -TRYGETIF= trygetif.o getif.o report.o $(STRERROR) -trygetif : $(TRYGETIF) - $(CC) -o $@ $(TRYGETIF) $(SYSLIBS) - -# This is just for testing getether. -TRYGETEA= trygetea.o getether.o report.o $(STRERROR) -trygetea : $(TRYGETEA) - $(CC) -o $@ $(TRYGETEA) $(SYSLIBS) - -# This rule just keeps the LOG_BOOTP define localized. -report.o : report.c - $(CC) $(CFLAGS) $(LOG_FACILITY) -c $< - -# Punt SunOS -target noise -.c.o: - $(CC) $(CFLAGS) -c $< - -# -# Header file dependencies: -# - -bootpd.o : bootp.h bptypes.h hash.h hwaddr.h bootpd.h dovend.h -bootpd.o : readfile.h report.h tzone.h patchlevel.h getif.h -bootpef.o : bootp.h bptypes.h hash.h hwaddr.h bootpd.h dovend.h -bootpef.o : readfile.h report.h tzone.h patchlevel.h -bootpgw.o : bootp.h bptypes.h getif.h hwaddr.h report.h patchlevel.h -bootptest.o : bootp.h bptypes.h bootptest.h getif.h patchlevel.h -dovend.o : bootp.h bptypes.h bootpd.h hash.h hwaddr.h report.h dovend.h -dumptab.o : bootp.h bptypes.h hash.h hwaddr.h report.h patchlevel.h bootpd.h -getif.o : getif.h report.h -hash.o : hash.h -hwaddr.o : bptypes.h hwaddr.h report.h -lookup.o : bootp.h bptypes.h lookup.h report.h -print-bootp.o : bootp.h bptypes.h bootptest.h -readfile.o : bootp.h bptypes.h hash.h hwaddr.h lookup.h readfile.h -readfile.o : report.h tzone.h bootpd.h -report.o : report.h -tzone.o : bptypes.h report.h tzone.h diff --git a/usr.sbin/bootpd/Problems b/usr.sbin/bootpd/Problems deleted file mode 100644 index 9478676eca40..000000000000 --- a/usr.sbin/bootpd/Problems +++ /dev/null @@ -1,47 +0,0 @@ - -Common problems and ways to work around them: - -Bootpd complains that it "can not get IP addr for HOSTNAME" - - If the entry is a "dummy" (not a real host) used only for - reference by other entries, put '.' in front of the name. - - If the entry is for a real client and the IP address for - the client can not be found using gethostbyname(), specify - the IP address for the client using numeric form. - -Bootpd takes a long time to finish parsing the bootptab file: - - Excessive startup time is usually caused by waiting for - timeouts on failed DNS lookup operations. If this is the - problem, find the client names for which DNS lookup fails - and change the bootptab to specify the IP addresses for - those clients using numeric form. - - When bootptab entries do not specify an ip address, bootpd - attempts to lookup the tagname as a host name to find the - IP address. To suppress this default action, either make - the entry a "dummy" or specify its IP numeric address. - - If your DNS lookups work but are just slow, consider either - running bootpd on the same machine as the DNS server or - running a caching DNS server on the host running bootpd. - -My huge bootptab file causes startup time to be so long that clients -give up waiting for a reply. - - Truly huge bootptab files make "inetd" mode impractical. - Start bootpd in "standalone" mode when the server boots. - - Another possibility is to run one bootpd on each network - segment so each one can have a smaller bootptab. Only one - instance of bootpd may run on one server, so you would need - to use a different server for each network segment. - -My bootp clients are given responses with a boot file name that is -not a fully specified path. - - Make sure the TFTP directory or home directory tags are set: - :td=/tftpboot: (or) - :hd=/usr/boot: (for example) - diff --git a/usr.sbin/bootpd/README b/usr.sbin/bootpd/README deleted file mode 100644 index c7755b786ddb..000000000000 --- a/usr.sbin/bootpd/README +++ /dev/null @@ -1,133 +0,0 @@ - -This is an enhanced version of the CMU BOOTP server which was derived -from the original BOOTP server created by Bill Croft at Stanford. -This version merges all the enhancements and bug-fixes from the -NetBSD, Columbia, and other versions. - -Please direct questions, comments, and bug reports to the list: - - -You can subscribe to this mailing list by sending mail to: - bootp-request@andrew.cmu.edu -(The body of the message should contain: "Add ") - -[ From the NetBSD README file: ] - -BOOTPD is a useful adjunct to the nfs diskless boot EPROM code. - -The alternatives for initiating a boot of a kernel across a network -are to use RARP protocol, or BOOTP protocol. BOOTP is more flexible; -it allows additional items of information to be returned to the -booting client; it also supports booting across gateways. - -[ From the CMU README file: ] - -Notes: -1) BOOTP was originally designed and implemented by Bill Croft at Stanford. - Much of the credit for the ideas and the code goes to him. We've added - code to support the vendor specific area of the packet as specified in - RFC1048. We've also improved the host lookup algorithm and added some - extra logging. - -2) The server now uses syslog to do logging. Specifically it uses the 4.3bsd - version. I've #ifdef'd all of these calls. If you are running 4.2 you - should compile without the -DSYSLOG switch. - -3) You must update your /etc/services file to contain the following two lines: - bootps 67/udp bootp # BOOTP Server - bootpc 68/udp # BOOTP Client - -4) Edit the bootptab. It has some explanitory comments, and there - is a manual entry describing its format (bootptab.5) - If you have any questions, just let us know. - -Construction: - [ See the file Installation which is more up-to-date. -gwr ] - - Make sure all of the files exist first. If anything is missing, - please contact either Walt Wimer or Drew Perkins by E-mail or phone. - Addresses and phone numbers are listed below. - - Type 'make'. The options at present are: -DSYSLOG which enables logging - code, -DDEBUG which enables table dumping via signals, and -DVEND_CMU - which enables the CMU extensions for CMU PC/IP. - - Edit the bootptab. The man page and the comments in the file should - explain how to go about doing so. If you have any problems, let me know. - - Type 'make install'. This should put all of the files in the right place. - - Edit your /etc/rc.local or /etc/inetd.conf file to start up bootpd upon - reboot. The following is a sample /etc/inetd.conf entry: - # BOOTP server - bootps dgram udp wait root /usr/etc/bootpd bootpd -i - -Care and feeding: - If you change the interface cards on your host or add new hosts you will - need to update /etc/bootptab. Just edit it as before. Once you write - it back out, bootpd will notice that there is a new copy and will - reread it the next time it gets a request. - - If your bootp clients don't get a response then several things might be - wrong. Most often, the entry for that host is not in the database. - Check the hardware address and then check the entry and make sure - everything is right. Other problems include the server machine crashing, - bad cables, and the like. If your network is very congested you should - try making your bootp clients send additional requests before giving up. - - -November 7, 1988 - - -Walter L. Wimer Drew D. Perkins -ww0n@andrew.cmu.edu ddp@andrew.cmu.edu -(412) 268-6252 (412) 268-8576 - -4910 Forbes Ave -Pittsburgh, PA 15213 - -[ Contents description by file: ] - -Announce* Text of release announcements -Changes Change history, reverse chronological -Installation Instructions for building and installing -Makefile* for "make" -README This file -ToDo Things not yet done -bootp.h The protocol header file -bootpd.8 Manual page for bootpd, boopgw -bootpd.c BOOTP server main module -bootpd.h header for above (and others) -bootpef.8 Manual page for bootpef -bootpef.c BOOTP extension file compiler -bootpgw.c BOOTP gateway main module -bootptab.5 A manual describing the bootptab format -bootptab.cmu A sample database file for the server -bootptab.mcs Another sample from -bootptest.8 Manual page for bootptest -bootptest.c BOOTP test program (fake client) -bootptest.h header for above -dovend.c Vendor Option builder (for bootpd, bootpef) -dovend.h header for above -dumptab.c Implements debugging dump for bootpd -getether.c For bootptest (not used yet) -getif.c Get network interface info. -getif.h header for above -hash.c The hash table module -hash.h header for above -hwaddr.c Hardware address support -hwaddr.h header for above -lookup.c Internet Protocol address lookup -lookup.h header for above -patchlevel.h Holds version numbers -print-bootp.c Prints BOOTP packets (taken from BSD tcpdump) -readfile.c The configuration file-reading routines -readfile.h header for above -report.c Does syslog-style messages -report.h header for above -strerror.c Library errno-to-string (for systems lacking it) -syslog.conf Sample config file for syslogd(8) -syslog.h For systems that lack syslog(3) -try*.c Test programs (for debugging) -tzone.c Get timezone offset -tzone.h header for above diff --git a/usr.sbin/bootpd/bootp.h b/usr.sbin/bootpd/bootp.h deleted file mode 100644 index 990bf58838b2..000000000000 --- a/usr.sbin/bootpd/bootp.h +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -/* - * Bootstrap Protocol (BOOTP). RFC951 and RFC1395. - * - * $Id: bootp.h,v 1.2 1994/08/22 22:14:40 gwr Exp $ - * - * - * This file specifies the "implementation-independent" BOOTP protocol - * information which is common to both client and server. - * - */ - -#include "bptypes.h" /* for int32, u_int32 */ - -#define BP_CHADDR_LEN 16 -#define BP_SNAME_LEN 64 -#define BP_FILE_LEN 128 -#define BP_VEND_LEN 64 -#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */ - -struct bootp { - unsigned char bp_op; /* packet opcode type */ - unsigned char bp_htype; /* hardware addr type */ - unsigned char bp_hlen; /* hardware addr length */ - unsigned char bp_hops; /* gateway hops */ - unsigned int32 bp_xid; /* transaction ID */ - unsigned short bp_secs; /* seconds since boot began */ - unsigned short bp_flags; /* RFC1532 broadcast, etc. */ - struct in_addr bp_ciaddr; /* client IP address */ - struct in_addr bp_yiaddr; /* 'your' IP address */ - struct in_addr bp_siaddr; /* server IP address */ - struct in_addr bp_giaddr; /* gateway IP address */ - unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */ - char bp_sname[BP_SNAME_LEN]; /* server host name */ - char bp_file[BP_FILE_LEN]; /* boot file name */ - unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */ - /* note that bp_vend can be longer, extending to end of packet. */ -}; - -/* - * UDP port numbers, server and client. - */ -#define IPPORT_BOOTPS 67 -#define IPPORT_BOOTPC 68 - -#define BOOTREPLY 2 -#define BOOTREQUEST 1 - -/* - * Hardware types from Assigned Numbers RFC. - */ -#define HTYPE_ETHERNET 1 -#define HTYPE_EXP_ETHERNET 2 -#define HTYPE_AX25 3 -#define HTYPE_PRONET 4 -#define HTYPE_CHAOS 5 -#define HTYPE_IEEE802 6 -#define HTYPE_ARCNET 7 - -/* - * Vendor magic cookie (v_magic) for CMU - */ -#define VM_CMU "CMU" - -/* - * Vendor magic cookie (v_magic) for RFC1048 - */ -#define VM_RFC1048 { 99, 130, 83, 99 } - - - -/* - * Tag values used to specify what information is being supplied in - * the vendor (options) data area of the packet. - */ -/* RFC 1048 */ -#define TAG_END ((unsigned char) 255) -#define TAG_PAD ((unsigned char) 0) -#define TAG_SUBNET_MASK ((unsigned char) 1) -#define TAG_TIME_OFFSET ((unsigned char) 2) -#define TAG_GATEWAY ((unsigned char) 3) -#define TAG_TIME_SERVER ((unsigned char) 4) -#define TAG_NAME_SERVER ((unsigned char) 5) -#define TAG_DOMAIN_SERVER ((unsigned char) 6) -#define TAG_LOG_SERVER ((unsigned char) 7) -#define TAG_COOKIE_SERVER ((unsigned char) 8) -#define TAG_LPR_SERVER ((unsigned char) 9) -#define TAG_IMPRESS_SERVER ((unsigned char) 10) -#define TAG_RLP_SERVER ((unsigned char) 11) -#define TAG_HOST_NAME ((unsigned char) 12) -#define TAG_BOOT_SIZE ((unsigned char) 13) -/* RFC 1395 */ -#define TAG_DUMP_FILE ((unsigned char) 14) -#define TAG_DOMAIN_NAME ((unsigned char) 15) -#define TAG_SWAP_SERVER ((unsigned char) 16) -#define TAG_ROOT_PATH ((unsigned char) 17) -/* RFC 1497 */ -#define TAG_EXTEN_FILE ((unsigned char) 18) -/* RFC 1533 */ -#define TAG_NIS_DOMAIN ((unsigned char) 40) -#define TAG_NIS_SERVER ((unsigned char) 41) -#define TAG_NTP_SERVER ((unsigned char) 42) -/* DHCP maximum message size. */ -#define TAG_MAX_MSGSZ ((unsigned char) 57) - -/* XXX - Add new tags here */ - - -/* - * "vendor" data permitted for CMU bootp clients. - */ - -struct cmu_vend { - char v_magic[4]; /* magic number */ - unsigned int32 v_flags; /* flags/opcodes, etc. */ - struct in_addr v_smask; /* Subnet mask */ - struct in_addr v_dgate; /* Default gateway */ - struct in_addr v_dns1, v_dns2; /* Domain name servers */ - struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ - struct in_addr v_ts1, v_ts2; /* Time servers */ - int32 v_unused[6]; /* currently unused */ -}; - - -/* v_flags values */ -#define VF_SMASK 1 /* Subnet mask field contains valid data */ diff --git a/usr.sbin/bootpd/bootpd.8 b/usr.sbin/bootpd/bootpd.8 deleted file mode 100644 index da59c21530cd..000000000000 --- a/usr.sbin/bootpd/bootpd.8 +++ /dev/null @@ -1,305 +0,0 @@ -.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University -.\" -.\" $Header: /b/source/CVS/src/usr.sbin/bootpd/bootpd.8,v 1.2 1994/08/22 22:14:41 gwr Exp $ -.\" -.TH BOOTPD 8 "November 06, 1993" "Carnegie Mellon University" -.SH NAME -bootpd, bootpgw \- Internet Boot Protocol server/gateway -.SH SYNOPSIS -.B bootpd -[ -.B \-i -.B \-s -.B \-t -timeout -.B \-d -level -.B \-c -chdir\-path -] -[ -.I bootptab -[ -.I dumpfile -] ] -.br -.B bootpgw -[ -.B \-i -.B \-s -.B \-t -timeout -.B \-d -level -] server -.SH DESCRIPTION -.I Bootpd -implements an Internet Bootstrap Protocol (BOOTP) server as defined in -RFC951, RFC1532, and RFC1533. -.I Bootpgw -implements a simple BOOTP gateway which can be used to forward -requests and responses between clients on one subnet and a -BOOTP server (i.e. -.IR bootpd ) -on another subnet. While either -.I bootpd -or -.I bootpgw -will forward BOOTREPLY packets, only -.I bootpgw -will forward BOOTREQUEST packets. -.PP -One host on each network segment is normally configured to run either -.I bootpd -or -.I bootpgw -from -.I inetd -by including one of the following lines in the file -.IR /etc/inetd.conf : -.IP -bootps dgram udp wait root /etc/bootpd bootpd bootptab -.br -bootps dgram udp wait root /etc/bootpgw bootpgw server -.PP -This mode of operation is referred to as "inetd mode" and causes -.I bootpd -(or -.IR bootpgw ) -to be started only when a boot request arrives. If it does not -receive another packet within fifteen minutes of the last one -it received, it will exit to conserve system resources. The -.B \-t -option controls this timeout (see OPTIONS). -.PP -It is also possible to run -.I bootpd -(or -.IR bootpgw ) -in "standalone mode" (without -.IR inetd ) -by simply invoking it from a shell like any other regular command. -Standalone mode is particularly useful when -.I bootpd -is used with a large configuration database, where the start up -delay might otherwise prevent timely response to client requests. -(Automatic start up in standalone mode can be done by invoking -.I bootpd -from within -.IR /etc/rc.local , -for example.) -Standalone mode is less useful for -.I bootgw -which -has very little start up delay because -it does not read a configuration file. -.PP -Either program automatically detects whether it was invoked from inetd -or from a shell and automatically selects the appropriate mode. -The -.B \-s -or -.B \-i -option may be used to force standalone or inetd mode respectively -(see OPTIONS). -.SH OPTIONS -.TP -.BI \-t \ timeout -Specifies the -.I timeout -value (in minutes) that a -.I bootpd -or -.I bootpgw -process will wait for a BOOTP packet before exiting. -If no packets are recieved for -.I timeout -seconds, then the program will exit. -A timeout value of zero means "run forever". -In standalone mode, this option is forced to zero. -.TP -.BI \-d \ debug\-level -Sets the -.I debug\-level -variable that controls the amount of debugging messages generated. -For example, -d4 or -d 4 will set the debugging level to 4. -For compatibility with older versions of -.IR bootpd , -omitting the numeric parameter (i.e. just -d) will -simply increment the debug level by one. -.TP -.BI \-c \ chdir\-path -Sets the current directory used by -.I bootpd -while checking the existence and size of client boot files. This is -useful when client boot files are specified as relative pathnames, and -.I bootpd -needs to use the same current directory as the TFTP server -(typically /tftpboot). This option is not recoginzed by -.IR bootpgw . -.TP -.B \-i -Force inetd mode. This option is obsolete, but remains for -compatibility with older versions of -.IR bootpd . -.TP -.B \-s -Force standalone mode. This option is obsolete, but remains for -compatibility with older versions of -.IR bootpd . -.TP -.I bootptab -Specifies the name of the configuration file from which -.I bootpd -loads its database of known clients and client options -.RI ( bootpd -only). -.TP -.I dumpfile -Specifies the name of the file that -.I bootpd -will dump its internal database into when it receives a -SIGUSR1 signal -.RI ( bootpd -only). This option is only recognized if -.I bootpd -was compiled with the -DDEBUG flag. -.TP -.I server -Specifies the name of a BOOTP server to which -.I bootpgw -will forward all BOOTREQUEST packets it receives -.RI ( bootpgw -only). -.SH OPERATION -.PP -Both -.I bootpd -and -.I bootpgw -operate similarly in that both listen for any packets sent to the -.I bootps -port, and both simply forward any BOOTREPLY packets. -They differ in their handling of BOOTREQUEST packets. -.PP -When -.I bootpgw -is started, it determines the address of a BOOTP server -whose name is provided as a command line parameter. When -.I bootpgw -receives a BOOTREQUEST packet, it sets the "gateway address" -and "hop count" fields in the packet and forwards the packet -to the BOOTP server at the address determined earlier. -Requests are forwarded only if they indicate that -the client has been waiting for at least three seconds. -.PP -When -.I bootpd -is started it reads a configuration file, (normally -.IR /etc/bootptab ) -that initializes the internal database of known clients and client -options. This internal database is reloaded -from the configuration file when -.I bootpd -receives a hangup signal (SIGHUP) or when it discovers that the -configuration file has changed. -.PP -When -.I bootpd -receives a BOOTREQUEST packet, it -.\" checks the modification time of the -.\" configuration file and reloads the database if necessary. Then it -looks for a database entry matching the client request. -If the client is known, -.I bootpd -composes a BOOTREPLY packet using the database entry found above, -and sends the reply to the client (possibly using a gateway). -If the client is unknown, the request is discarded -(with a notice if debug > 0). -.PP -If -.I bootpd -is compiled with the -DDEBUG option, receipt of a SIGUSR1 signal causes -it to dump its internal database to the file -.I /etc/bootpd.dump -or the dumpfile specified as a command line parameter. -.PP -During initialization, both programs -determine the UDP port numbers to be used by calling -.I getservbyname -(which nomally uses -.IR /etc/services). -Two service names (and port numbers) are used: -.IP -bootps \- BOOTP Server listening port -.br -bootpc \- BOOTP Client destination port -.LP -If the port numbers cannot -be determined using -.I getservbyname -then the values default to boopts=67 and bootpc=68. -.SH FILES -.TP 20 -/etc/bootptab -Database file read by -.IR bootpd . -.TP -/etc/bootpd.dump -Debugging dump file created by -.IR bootpd . -.TP -/etc/services -Internet service numbers. -.TP -/tftpboot -Current directory typically used by the TFTP server and -.IR bootpd . - -.SH BUGS -Individual host entries must not exceed 1024 characters. - -.SH CREDITS -.PP -This distribution is currently maintained by -Walter L. Wimer . -.PP -The original BOOTP server was created by -Bill Croft at Stanford University in January 1986. -.PP -The current version of -.I bootpd -is primarily the work of David Kovar, -Drew D. Perkins, and Walter L. Wimer, -at Carnegie Mellon University. -.TP -Enhancements and bug\-fixes have been contributed by: -(in alphabetical order) -.br -Danny Backx -.br -John Brezak -.br -Frank da Cruz -.br -David R. Linn -.br -Jim McKim -.br -Gordon W. Ross -.br -Jason Zions -.SH "SEE ALSO" -.LP -bootptab(5), inetd(8), tftpd(8) -.LP -DARPA Internet Request For Comments: -.TP 10 -RFC951 -Bootstrap Protocol -.TP 10 -RFC1532 -Clarifications and Extensions for the Bootstrap Protocol -.TP 10 -RFC1533 -DHCP Options and BOOTP Vendor Extensions diff --git a/usr.sbin/bootpd/bootpd.c b/usr.sbin/bootpd/bootpd.c deleted file mode 100644 index fc7a5dd51951..000000000000 --- a/usr.sbin/bootpd/bootpd.c +++ /dev/null @@ -1,1380 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: bootpd.c,v 1.4 1994/08/24 18:14:44 gwr Exp $"; -#endif - -/* - * BOOTP (bootstrap protocol) server daemon. - * - * Answers BOOTP request packets from booting client machines. - * See [SRI-NIC]RFC951.TXT for a description of the protocol. - * See [SRI-NIC]RFC1048.TXT for vendor-information extensions. - * See RFC 1395 for option tags 14-17. - * See accompanying man page -- bootpd.8 - * - * HISTORY - * See ./Changes - * - * BUGS - * See ./ToDo - */ - - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef NO_SETSID -# include /* for O_RDONLY, etc */ -#endif - -#ifdef SVR4 -/* Using sigset() avoids the need to re-arm each time. */ -#define signal sigset -#endif - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "bootpd.h" -#include "dovend.h" -#include "getif.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "patchlevel.h" - -#ifndef CONFIG_FILE -#define CONFIG_FILE "/etc/bootptab" -#endif -#ifndef DUMPTAB_FILE -#define DUMPTAB_FILE "/tmp/bootpd.dump" -#endif - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void dumptab P((char *)); - -PRIVATE void catcher P((int)); -PRIVATE int chk_access P((char *, int32 *)); -#ifdef VEND_CMU -PRIVATE void dovend_cmu P((struct bootp *, struct host *)); -#endif -PRIVATE void dovend_rfc1048 P((struct bootp *, struct host *, int32)); -PRIVATE void handle_reply P((void)); -PRIVATE void handle_request P((void)); -PRIVATE void sendreply P((int forward, int32 dest_override)); -PRIVATE void usage P((void)); - -#undef P - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in bind_addr; /* Listening */ -struct sockaddr_in recv_addr; /* Packet source */ -struct sockaddr_in send_addr; /* destination */ - - -/* - * option defaults - */ -int debug = 0; /* Debugging flag (level) */ -struct timeval actualtimeout = -{ /* fifteen minutes */ - 15 * 60L, /* tv_sec */ - 0 /* tv_usec */ -}; - -/* - * General - */ - -int s; /* Socket file descriptor */ -char *pktbuf; /* Receive packet buffer */ -int pktlen; -char *progname; -char *chdir_path; -char hostname[MAXHOSTNAMELEN]; /* System host name */ -struct in_addr my_ip_addr; - -/* Flags set by signal catcher. */ -PRIVATE int do_readtab = 0; -PRIVATE int do_dumptab = 0; - -/* - * Globals below are associated with the bootp database file (bootptab). - */ - -char *bootptab = CONFIG_FILE; -char *bootpd_dump = DUMPTAB_FILE; - - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ - -void -main(argc, argv) - int argc; - char **argv; -{ - struct timeval *timeout; - struct bootp *bp; - struct servent *servp; - struct hostent *hep; - char *stmp; - int n, ba_len, ra_len; - int nfound, readfds; - int standalone; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* - * Initialize logging. - */ - report_init(0); /* uses progname */ - - /* - * Log startup - */ - report(LOG_INFO, "version %s.%d", VERSION, PATCHLEVEL); - - /* Debugging for compilers with struct padding. */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - /* Get space for receiving packets and composing replies. */ - pktbuf = malloc(MAX_MSG_SIZE); - if (!pktbuf) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - bp = (struct bootp *) pktbuf; - - /* - * Check to see if a socket was passed to us from inetd. - * - * Use getsockname() to determine if descriptor 0 is indeed a socket - * (and thus we are probably a child of inetd) or if it is instead - * something else and we are running standalone. - */ - s = 0; - ba_len = sizeof(bind_addr); - bzero((char *) &bind_addr, ba_len); - errno = 0; - standalone = TRUE; - if (getsockname(s, (struct sockaddr *) &bind_addr, &ba_len) == 0) { - /* - * Descriptor 0 is a socket. Assume we are a child of inetd. - */ - if (bind_addr.sin_family == AF_INET) { - standalone = FALSE; - bootps_port = ntohs(bind_addr.sin_port); - } else { - /* Some other type of socket? */ - report(LOG_ERR, "getsockname: not an INET socket"); - } - } - - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - timeout = &actualtimeout; - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'c': /* chdir_path */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (stmp[0] != '/')) { - fprintf(stderr, - "bootpd: invalid chdir specification\n"); - break; - } - chdir_path = stmp; - break; - - case 'd': /* debug level */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid debug level\n", progname); - break; - } - debug = n; - break; - - case 'h': /* override hostname */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp) { - fprintf(stderr, - "bootpd: missing hostname\n"); - break; - } - strncpy(hostname, stmp, sizeof(hostname)-1); - break; - - case 'i': /* inetd mode */ - standalone = FALSE; - break; - - case 's': /* standalone mode */ - standalone = TRUE; - break; - - case 't': /* timeout */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid timeout specification\n", progname); - break; - } - actualtimeout.tv_sec = (int32) (60 * n); - /* - * If the actual timeout is zero, pass a NULL pointer - * to select so it blocks indefinitely, otherwise, - * point to the actual timeout value. - */ - timeout = (n > 0) ? &actualtimeout : NULL; - break; - - default: - fprintf(stderr, "%s: unknown switch: -%c\n", - progname, argv[0][1]); - usage(); - break; - - } /* switch */ - } /* for args */ - - /* - * Override default file names if specified on the command line. - */ - if (argc > 0) - bootptab = argv[0]; - - if (argc > 1) - bootpd_dump = argv[1]; - - /* - * Get my hostname and IP address. - */ - if (hostname[0] == '\0') { - if (gethostname(hostname, sizeof(hostname)) == -1) { - fprintf(stderr, "bootpd: can't get hostname\n"); - exit(1); - } - } - hep = gethostbyname(hostname); - if (!hep) { - fprintf(stderr, "Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, (char *)&my_ip_addr, sizeof(my_ip_addr)); - - if (standalone) { - /* - * Go into background and disassociate from controlling terminal. - */ - if (debug < 3) { - if (fork()) - exit(0); -#ifdef NO_SETSID - setpgrp(0,0); -#ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); - if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); - (void) close(n); - } -#endif /* TIOCNOTTY */ -#else /* SETSID */ - if (setsid() < 0) - perror("setsid"); -#endif /* SETSID */ - } /* if debug < 3 */ - - /* - * Nuke any timeout value - */ - timeout = NULL; - - } /* if standalone (1st) */ - - /* Set the cwd (i.e. to /tftpboot) */ - if (chdir_path) { - if (chdir(chdir_path) < 0) - report(LOG_ERR, "%s: chdir failed", chdir_path); - } - - /* Get the timezone. */ - tzone_init(); - - /* Allocate hash tables. */ - rdtab_init(); - - /* - * Read the bootptab file. - */ - readtab(1); /* force read */ - - if (standalone) { - - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "socket: %s", get_network_errmsg()); - exit(1); - } - - /* - * Get server's listening port number - */ - servp = getservbyname("bootps", "udp"); - if (servp) { - bootps_port = ntohs((u_short) servp->s_port); - } else { - bootps_port = (u_short) IPPORT_BOOTPS; - report(LOG_ERR, - "udp/bootps: unknown service -- assuming port %d", - bootps_port); - } - - /* - * Bind socket to BOOTPS port. - */ - bind_addr.sin_family = AF_INET; - bind_addr.sin_addr.s_addr = INADDR_ANY; - bind_addr.sin_port = htons(bootps_port); - if (bind(s, (struct sockaddr *) &bind_addr, - sizeof(bind_addr)) < 0) - { - report(LOG_ERR, "bind: %s", get_network_errmsg()); - exit(1); - } - } /* if standalone (2nd)*/ - - /* - * Get destination port number so we can reply to client - */ - servp = getservbyname("bootpc", "udp"); - if (servp) { - bootpc_port = ntohs(servp->s_port); - } else { - report(LOG_ERR, - "udp/bootpc: unknown service -- assuming port %d", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* - * Set up signals to read or dump the table. - */ - if ((int) signal(SIGHUP, catcher) < 0) { - report(LOG_ERR, "signal: %s", get_errmsg()); - exit(1); - } - if ((int) signal(SIGUSR1, catcher) < 0) { - report(LOG_ERR, "signal: %s", get_errmsg()); - exit(1); - } - - /* - * Process incoming requests. - */ - for (;;) { - readfds = 1 << s; - nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout); - if (nfound < 0) { - if (errno != EINTR) { - report(LOG_ERR, "select: %s", get_errmsg()); - } - /* - * Call readtab() or dumptab() here to avoid the - * dangers of doing I/O from a signal handler. - */ - if (do_readtab) { - do_readtab = 0; - readtab(1); /* force read */ - } - if (do_dumptab) { - do_dumptab = 0; - dumptab(bootpd_dump); - } - continue; - } - if (!(readfds & (1 << s))) { - if (debug > 1) - report(LOG_INFO, "exiting after %ld minutes of inactivity", - actualtimeout.tv_sec / 60); - exit(0); - } - ra_len = sizeof(recv_addr); - n = recvfrom(s, pktbuf, MAX_MSG_SIZE, 0, - (struct sockaddr *) &recv_addr, &ra_len); - if (n <= 0) { - continue; - } - if (debug > 1) { - report(LOG_INFO, "recvd pkt from IP addr %s", - inet_ntoa(recv_addr.sin_addr)); - } - if (n < sizeof(struct bootp)) { - if (debug) { - report(LOG_INFO, "received short packet"); - } - continue; - } - pktlen = n; - - readtab(0); /* maybe re-read bootptab */ - - switch (bp->bp_op) { - case BOOTREQUEST: - handle_request(); - break; - case BOOTREPLY: - handle_reply(); - break; - } - } -} - - - - -/* - * Print "usage" message and exit - */ - -PRIVATE void -usage() -{ - fprintf(stderr, - "usage: bootpd [-d level] [-i] [-s] [-t timeout] [configfile [dumpfile]]\n"); - fprintf(stderr, "\t -c n\tset current directory\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n"); - fprintf(stderr, "\t -s\tforce standalone mode (run without inetd)\n"); - fprintf(stderr, "\t -t n\tset inetd exit timeout to n minutes\n"); - exit(1); -} - -/* Signal catchers */ -PRIVATE void -catcher(sig) - int sig; -{ - if (sig == SIGHUP) - do_readtab = 1; - if (sig == SIGUSR1) - do_dumptab = 1; -#ifdef SYSV - /* For older "System V" derivatives with no sigset(). */ - /* XXX - Should just do it the POSIX way (sigaction). */ - signal(sig, catcher); -#endif -} - - - -/* - * Process BOOTREQUEST packet. - * - * Note: This version of the bootpd.c server never forwards - * a request to another server. That is the job of a gateway - * program such as the "bootpgw" program included here. - * - * (Also this version does not interpret the hostname field of - * the request packet; it COULD do a name->address lookup and - * forward the request there.) - */ -PRIVATE void -handle_request() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct host *hp = NULL; - struct host dummyhost; - int32 bootsize = 0; - unsigned hlen, hashcode; - int32 dest; - char realpath[1024]; - char *clntpath; - char *homedir, *bootfile; - int n; - - /* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */ - - /* - * If the servername field is set, compare it against us. - * If we're not being addressed, ignore this request. - * If the server name field is null, throw in our name. - */ - if (strlen(bp->bp_sname)) { - if (strcmp(bp->bp_sname, hostname)) { - if (debug) - report(LOG_INFO, "\ -ignoring request for server %s from client at %s address %s", - bp->bp_sname, netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - /* XXX - Is it correct to ignore such a request? -gwr */ - return; - } - } else { - strcpy(bp->bp_sname, hostname); - } - - /* Convert the request into a reply. */ - bp->bp_op = BOOTREPLY; - if (bp->bp_ciaddr.s_addr == 0) { - /* - * client doesnt know his IP address, - * search by hardware address. - */ - if (debug > 1) { - report(LOG_INFO, "request from %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - } - hlen = haddrlength(bp->bp_htype); - if (hlen != bp->bp_hlen) { - report(LOG_NOTICE, "bad addr len from from %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, hlen)); - } - dummyhost.htype = bp->bp_htype; - bcopy(bp->bp_chaddr, dummyhost.haddr, hlen); - hashcode = hash_HashFunction(bp->bp_chaddr, hlen); - hp = (struct host *) hash_Lookup(hwhashtable, hashcode, hwlookcmp, - &dummyhost); - if (hp == NULL && - bp->bp_htype == HTYPE_IEEE802) - { - /* Try again with address in "canonical" form. */ - haddr_conv802(bp->bp_chaddr, dummyhost.haddr, hlen); - if (debug > 1) { - report(LOG_INFO, "\ -HW addr type is IEEE 802. convert to %s and check again\n", - haddrtoa(dummyhost.haddr, bp->bp_hlen)); - } - hashcode = hash_HashFunction(dummyhost.haddr, hlen); - hp = (struct host *) hash_Lookup(hwhashtable, hashcode, - hwlookcmp, &dummyhost); - } - if (hp == NULL) { - /* - * XXX - Add dynamic IP address assignment? - */ - if (debug > 1) - report(LOG_INFO, "unknown client %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - return; /* not found */ - } - (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr; - - } else { - - /* - * search by IP address. - */ - if (debug > 1) { - report(LOG_INFO, "request from IP addr %s", - inet_ntoa(bp->bp_ciaddr)); - } - dummyhost.iaddr.s_addr = bp->bp_ciaddr.s_addr; - hashcode = hash_HashFunction((u_char *) &(bp->bp_ciaddr.s_addr), 4); - hp = (struct host *) hash_Lookup(iphashtable, hashcode, iplookcmp, - &dummyhost); - if (hp == NULL) { - if (debug > 1) { - report(LOG_NOTICE, "IP address not found: %s", - inet_ntoa(bp->bp_ciaddr)); - } - return; - } - } - - if (debug) { - report(LOG_INFO, "found %s (%s)", inet_ntoa(hp->iaddr), - hp->hostname->string); - } - - /* - * If there is a response delay threshold, ignore requests - * with a timestamp lower than the threshold. - */ - if (hp->flags.min_wait) { - u_int32 t = (u_int32) ntohs(bp->bp_secs); - if (t < hp->min_wait) { - if (debug > 1) - report(LOG_INFO, - "ignoring request due to timestamp (%d < %d)", - t, hp->min_wait); - return; - } - } - -#ifdef YORK_EX_OPTION - /* - * The need for the "ex" tag arose out of the need to empty - * shared networked drives on diskless PCs. This solution is - * not very clean but it does work fairly well. - * Written by Edmund J. Sutcliffe - * - * XXX - This could compromise security if a non-trusted user - * managed to write an entry in the bootptab with :ex=trojan: - * so I would leave this turned off unless you need it. -gwr - */ - /* Run a program, passing the client name as a parameter. */ - if (hp->flags.exec_file) { - char tst[100]; - /* XXX - Check string lengths? -gwr */ - strcpy (tst, hp->exec_file->string); - strcat (tst, " "); - strcat (tst, hp->hostname->string); - strcat (tst, " &"); - if (debug) - report(LOG_INFO, "executing %s", tst); - system(tst); /* Hope this finishes soon... */ - } -#endif /* YORK_EX_OPTION */ - - /* - * If a specific TFTP server address was specified in the bootptab file, - * fill it in, otherwise zero it. - * XXX - Rather than zero it, should it be the bootpd address? -gwr - */ - (bp->bp_siaddr).s_addr = (hp->flags.bootserver) ? - hp->bootserver.s_addr : 0L; - -#ifdef STANFORD_PROM_COMPAT - /* - * Stanford bootp PROMs (for a Sun?) have no way to leave - * the boot file name field blank (because the boot file - * name is automatically generated from some index). - * As a work-around, this little hack allows those PROMs to - * specify "sunboot14" with the same effect as a NULL name. - * (The user specifies boot device 14 or some such magic.) - */ - if (strcmp(bp->bp_file, "sunboot14") == 0) - bp->bp_file[0] = '\0'; /* treat it as unspecified */ -#endif - - /* - * Fill in the client's proper bootfile. - * - * If the client specifies an absolute path, try that file with a - * ".host" suffix and then without. If the file cannot be found, no - * reply is made at all. - * - * If the client specifies a null or relative file, use the following - * table to determine the appropriate action: - * - * Homedir Bootfile Client's file - * specified? specified? specification Action - * ------------------------------------------------------------------- - * No No Null Send null filename - * No No Relative Discard request - * No Yes Null Send if absolute else null - * No Yes Relative Discard request *XXX - * Yes No Null Send null filename - * Yes No Relative Lookup with ".host" - * Yes Yes Null Send home/boot or bootfile - * Yes Yes Relative Lookup with ".host" *XXX - * - */ - - /* - * XXX - I don't like the policy of ignoring a client when the - * boot file is not accessible. The TFTP server might not be - * running on the same machine as the BOOTP server, in which - * case checking accessibility of the boot file is pointless. - * - * Therefore, file accessibility is now demanded ONLY if you - * define CHECK_FILE_ACCESS in the Makefile options. -gwr - */ - - /* - * The "real" path is as seen by the BOOTP daemon on this - * machine, while the client path is relative to the TFTP - * daemon chroot directory (i.e. /tftpboot). - */ - if (hp->flags.tftpdir) { - strcpy(realpath, hp->tftpdir->string); - clntpath = &realpath[strlen(realpath)]; - } else { - realpath[0] = '\0'; - clntpath = realpath; - } - - /* - * Determine client's requested homedir and bootfile. - */ - homedir = NULL; - bootfile = NULL; - if (bp->bp_file[0]) { - homedir = bp->bp_file; - bootfile = strrchr(homedir, '/'); - if (bootfile) { - if (homedir == bootfile) - homedir = NULL; - *bootfile++ = '\0'; - } else { - /* no "/" in the string */ - bootfile = homedir; - homedir = NULL; - } - if (debug > 2) { - report(LOG_INFO, "requested path=\"%s\" file=\"%s\"", - (homedir) ? homedir : "", - (bootfile) ? bootfile : ""); - } - } - - /* - * Specifications in bootptab override client requested values. - */ - if (hp->flags.homedir) - homedir = hp->homedir->string; - if (hp->flags.bootfile) - bootfile = hp->bootfile->string; - - /* - * Construct bootfile path. - */ - if (homedir) { - if (homedir[0] != '/') - strcat(clntpath, "/"); - strcat(clntpath, homedir); - homedir = NULL; - } - if (bootfile) { - if (bootfile[0] != '/') - strcat(clntpath, "/"); - strcat(clntpath, bootfile); - bootfile = NULL; - } - - /* - * First try to find the file with a ".host" suffix - */ - n = strlen(clntpath); - strcat(clntpath, "."); - strcat(clntpath, hp->hostname->string); - if (chk_access(realpath, &bootsize) < 0) { - clntpath[n] = 0; /* Try it without the suffix */ - if (chk_access(realpath, &bootsize) < 0) { - /* neither "file.host" nor "file" was found */ -#ifdef CHECK_FILE_ACCESS - - if (bp->bp_file[0]) { - /* - * Client wanted specific file - * and we didn't have it. - */ - report(LOG_NOTICE, - "requested file not found: \"%s\"", clntpath); - return; - } - /* - * Client didn't ask for a specific file and we couldn't - * access the default file, so just zero-out the bootfile - * field in the packet and continue processing the reply. - */ - bzero(bp->bp_file, sizeof(bp->bp_file)); - goto null_file_name; - -#else /* CHECK_FILE_ACCESS */ - - /* Complain only if boot file size was needed. */ - if (hp->flags.bootsize_auto) { - report(LOG_ERR, "can not determine size of file \"%s\"", - clntpath); - } - -#endif /* CHECK_FILE_ACCESS */ - } - } - strncpy(bp->bp_file, clntpath, BP_FILE_LEN); - if (debug > 2) - report(LOG_INFO, "bootfile=\"%s\"", clntpath); - -null_file_name: - - - /* - * Handle vendor options based on magic number. - */ - - if (debug > 1) { - report(LOG_INFO, "vendor magic field is %d.%d.%d.%d", - (int) ((bp->bp_vend)[0]), - (int) ((bp->bp_vend)[1]), - (int) ((bp->bp_vend)[2]), - (int) ((bp->bp_vend)[3])); - } - /* - * If this host isn't set for automatic vendor info then copy the - * specific cookie into the bootp packet, thus forcing a certain - * reply format. Only force reply format if user specified it. - */ - if (hp->flags.vm_cookie) { - /* Slam in the user specified magic number. */ - bcopy(hp->vm_cookie, bp->bp_vend, 4); - } - /* - * Figure out the format for the vendor-specific info. - * Note that bp->bp_vend may have been set above. - */ - if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) { - /* RFC1048 conformant bootp client */ - dovend_rfc1048(bp, hp, bootsize); - if (debug > 1) { - report(LOG_INFO, "sending reply (with RFC1048 options)"); - } - } -#ifdef VEND_CMU - else if (!bcmp(bp->bp_vend, vm_cmu, 4)) { - dovend_cmu(bp, hp); - if (debug > 1) { - report(LOG_INFO, "sending reply (with CMU options)"); - } - } -#endif - else { - if (debug > 1) { - report(LOG_INFO, "sending reply (with no options)"); - } - } - - dest = (hp->flags.reply_addr) ? - hp->reply_addr.s_addr : 0L; - - /* not forwarded */ - sendreply(0, dest); -} - - -/* - * Process BOOTREPLY packet. - */ -PRIVATE void -handle_reply() -{ - if (debug) { - report(LOG_INFO, "processing boot reply"); - } - /* forwarded, no destination override */ - sendreply(1, 0); -} - - -/* - * Send a reply packet to the client. 'forward' flag is set if we are - * not the originator of this reply packet. - */ -PRIVATE void -sendreply(forward, dst_override) - int forward; - int32 dst_override; -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct in_addr dst; - u_short port = bootpc_port; - unsigned char *ha; - int len; - - /* - * XXX - Should honor bp_flags "broadcast" bit here. - * Temporary workaround: use the :ra=ADDR: option to - * set the reply address to the broadcast address. - */ - - /* - * If the destination address was specified explicitly - * (i.e. the broadcast address for HP compatiblity) - * then send the response to that address. Otherwise, - * act in accordance with RFC951: - * If the client IP address is specified, use that - * else if gateway IP address is specified, use that - * else make a temporary arp cache entry for the client's - * NEW IP/hardware address and use that. - */ - if (dst_override) { - dst.s_addr = dst_override; - if (debug > 1) { - report(LOG_INFO, "reply address override: %s", - inet_ntoa(dst)); - } - } else if (bp->bp_ciaddr.s_addr) { - dst = bp->bp_ciaddr; - } else if (bp->bp_giaddr.s_addr && forward == 0) { - dst = bp->bp_giaddr; - port = bootps_port; - if (debug > 1) { - report(LOG_INFO, "sending reply to gateway %s", - inet_ntoa(dst)); - } - } else { - dst = bp->bp_yiaddr; - ha = bp->bp_chaddr; - len = bp->bp_hlen; - if (len > MAXHADDRLEN) - len = MAXHADDRLEN; - - if (debug > 1) - report(LOG_INFO, "setarp %s - %s", - inet_ntoa(dst), haddrtoa(ha, len)); - setarp(s, &dst, ha, len); - } - - if ((forward == 0) && - (bp->bp_siaddr.s_addr == 0)) - { - struct ifreq *ifr; - struct in_addr siaddr; - /* - * If we are originating this reply, we - * need to find our own interface address to - * put in the bp_siaddr field of the reply. - * If this server is multi-homed, pick the - * 'best' interface (the one on the same net - * as the client). Of course, the client may - * be on the other side of a BOOTP gateway... - */ - ifr = getif(s, &dst); - if (ifr) { - struct sockaddr_in *sip; - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - siaddr = sip->sin_addr; - } else { - /* Just use my "official" IP address. */ - siaddr = my_ip_addr; - } - - /* XXX - No need to set bp_giaddr here. */ - - /* Finally, set the server address field. */ - bp->bp_siaddr = siaddr; - } - /* Set up socket address for send. */ - send_addr.sin_family = AF_INET; - send_addr.sin_port = htons(port); - send_addr.sin_addr = dst; - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} /* sendreply */ - - -/* nmatch() - now in getif.c */ -/* setarp() - now in hwaddr.c */ - - -/* - * This call checks read access to a file. It returns 0 if the file given - * by "path" exists and is publically readable. A value of -1 is returned if - * access is not permitted or an error occurs. Successful calls also - * return the file size in bytes using the long pointer "filesize". - * - * The read permission bit for "other" users is checked. This bit must be - * set for tftpd(8) to allow clients to read the file. - */ - -PRIVATE int -chk_access(path, filesize) - char *path; - int32 *filesize; -{ - struct stat st; - - if ((stat(path, &st) == 0) && (st.st_mode & (S_IREAD >> 6))) { - *filesize = (int32) st.st_size; - return 0; - } else { - return -1; - } -} - - -/* - * Now in dumptab.c : - * dumptab() - * dump_host() - * list_ipaddresses() - */ - -#ifdef VEND_CMU - -/* - * Insert the CMU "vendor" data for the host pointed to by "hp" into the - * bootp packet pointed to by "bp". - */ - -PRIVATE void -dovend_cmu(bp, hp) - struct bootp *bp; - struct host *hp; -{ - struct cmu_vend *vendp; - struct in_addr_list *taddr; - - /* - * Initialize the entire vendor field to zeroes. - */ - bzero(bp->bp_vend, sizeof(bp->bp_vend)); - - /* - * Fill in vendor information. Subnet mask, default gateway, - * domain name server, ien name server, time server - */ - vendp = (struct cmu_vend *) bp->bp_vend; - strcpy(vendp->v_magic, (char *)vm_cmu); - if (hp->flags.subnet_mask) { - (vendp->v_smask).s_addr = hp->subnet_mask.s_addr; - (vendp->v_flags) |= VF_SMASK; - if (hp->flags.gateway) { - (vendp->v_dgate).s_addr = hp->gateway->addr->s_addr; - } - } - if (hp->flags.domain_server) { - taddr = hp->domain_server; - if (taddr->addrcount > 0) { - (vendp->v_dns1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_dns2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - if (hp->flags.name_server) { - taddr = hp->name_server; - if (taddr->addrcount > 0) { - (vendp->v_ins1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_ins2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - if (hp->flags.time_server) { - taddr = hp->time_server; - if (taddr->addrcount > 0) { - (vendp->v_ts1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_ts2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - /* Log message now done by caller. */ -} /* dovend_cmu */ - -#endif /* VEND_CMU */ - - - -/* - * Insert the RFC1048 vendor data for the host pointed to by "hp" into the - * bootp packet pointed to by "bp". - */ -#define NEED(LEN, MSG) do \ - if (bytesleft < (LEN)) { \ - report(LOG_NOTICE, noroom, \ - hp->hostname->string, MSG); \ - return; \ - } while (0) -PRIVATE void -dovend_rfc1048(bp, hp, bootsize) - struct bootp *bp; - struct host *hp; - int32 bootsize; -{ - int bytesleft, len; - byte *vp; - char *tmpstr; - - static char noroom[] = "%s: No room for \"%s\" option"; - - vp = bp->bp_vend; - - if (hp->flags.msg_size) { - pktlen = hp->msg_size; - } else { - /* - * If the request was longer than the official length, build - * a response of that same length where the additional length - * is assumed to be part of the bp_vend (options) area. - */ - if (pktlen > sizeof(*bp)) { - if (debug > 1) - report(LOG_INFO, "request message length=%d", pktlen); - } - /* - * Check whether the request contains the option: - * Maximum DHCP Message Size (RFC1533 sec. 9.8) - * and if so, override the response length with its value. - * This request must lie within the first BP_VEND_LEN - * bytes of the option space. - */ - { - byte *p, *ep; - byte tag, len; - short msgsz = 0; - - p = vp + 4; - ep = p + BP_VEND_LEN - 4; - while (p < ep) { - tag = *p++; - /* Check for tags with no data first. */ - if (tag == TAG_PAD) - continue; - if (tag == TAG_END) - break; - /* Now scan the length byte. */ - len = *p++; - switch (tag) { - case TAG_MAX_MSGSZ: - if (len == 2) { - bcopy(p, (char*)&msgsz, 2); - msgsz = ntohs(msgsz); - } - break; - case TAG_SUBNET_MASK: - /* XXX - Should preserve this if given... */ - break; - } /* swtich */ - p += len; - } - - if (msgsz > sizeof(*bp)) { - if (debug > 1) - report(LOG_INFO, "request has DHCP msglen=%d", msgsz); - pktlen = msgsz; - } - } - } - - if (pktlen < sizeof(*bp)) { - report(LOG_ERR, "invalid response length=%d", pktlen); - pktlen = sizeof(*bp); - } - bytesleft = ((byte*)bp + pktlen) - vp; - if (pktlen > sizeof(*bp)) { - if (debug > 1) - report(LOG_INFO, "extended reply, length=%d, options=%d", - pktlen, bytesleft); - } - - /* Copy in the magic cookie */ - bcopy(vm_rfc1048, vp, 4); - vp += 4; - bytesleft -= 4; - - if (hp->flags.subnet_mask) { - /* always enough room here. */ - *vp++ = TAG_SUBNET_MASK;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(hp->subnet_mask.s_addr, &vp); /* -4 bytes */ - bytesleft -= 6; /* Fix real count */ - if (hp->flags.gateway) { - (void) insert_ip(TAG_GATEWAY, - hp->gateway, - &vp, &bytesleft); - } - } - if (hp->flags.bootsize) { - /* always enough room here */ - bootsize = (hp->flags.bootsize_auto) ? - ((bootsize + 511) / 512) : (hp->bootsize); /* Round up */ - *vp++ = TAG_BOOT_SIZE; - *vp++ = 2; - *vp++ = (byte) ((bootsize >> 8) & 0xFF); - *vp++ = (byte) (bootsize & 0xFF); - bytesleft -= 4; /* Tag, length, and 16 bit blocksize */ - } - /* - * This one is special: Remaining options go in the ext file. - * Only the subnet_mask, bootsize, and gateway should precede. - */ - if (hp->flags.exten_file) { - /* - * Check for room for exten_file. Add 3 to account for - * TAG_EXTEN_FILE, length, and TAG_END. - */ - len = strlen(hp->exten_file->string); - NEED((len + 3), "ef"); - *vp++ = TAG_EXTEN_FILE; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->exten_file->string, vp, len); - vp += len; - *vp++ = TAG_END; - bytesleft -= len + 3; - return; /* no more options here. */ - } - /* - * The remaining options are inserted by the following - * function (which is shared with bootpef.c). - * Keep back one byte for the TAG_END. - */ - len = dovend_rfc1497(hp, vp, bytesleft - 1); - vp += len; - bytesleft -= len; - - /* There should be at least one byte left. */ - NEED(1, "(end)"); - *vp++ = TAG_END; - bytesleft--; - - /* Log message done by caller. */ - if (bytesleft > 0) { - /* - * Zero out any remaining part of the vendor area. - */ - bzero(vp, bytesleft); - } -} /* dovend_rfc1048 */ -#undef NEED - - -/* - * Now in readfile.c: - * hwlookcmp() - * iplookcmp() - */ - -/* haddrtoa() - now in hwaddr.c */ -/* - * Now in dovend.c: - * insert_ip() - * insert_generic() - * insert_u_long() - */ - -/* get_errmsg() - now in report.c */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/bootpd.h b/usr.sbin/bootpd/bootpd.h deleted file mode 100644 index e5ce3417c04e..000000000000 --- a/usr.sbin/bootpd/bootpd.h +++ /dev/null @@ -1,211 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - - -/* - * bootpd.h -- common header file for all the modules of the bootpd program. - */ - -#include "bptypes.h" -#include "hash.h" -#include "hwaddr.h" - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef PRIVATE -#define PRIVATE static -#endif - -#ifndef SIGUSR1 -#define SIGUSR1 30 /* From 4.3 */ -#endif - -#define MAXSTRINGLEN 80 /* Max string length */ - -/* Local definitions: */ -#define MAX_MSG_SIZE (3*512) /* Maximum packet size */ - - -/* - * Return pointer to static string which gives full network error message. - */ -#define get_network_errmsg get_errmsg - - -/* - * Data structure used to hold an arbitrary-lengthed list of IP addresses. - * The list may be shared among multiple hosts by setting the linkcount - * appropriately. - */ - -struct in_addr_list { - unsigned int linkcount, addrcount; - struct in_addr addr[1]; /* Dynamically extended */ -}; - - -/* - * Data structures used to hold shared strings and shared binary data. - * The linkcount must be set appropriately. - */ - -struct shared_string { - unsigned int linkcount; - char string[1]; /* Dynamically extended */ -}; - -struct shared_bindata { - unsigned int linkcount, length; - byte data[1]; /* Dynamically extended */ -}; - - -/* - * Flag structure which indicates which symbols have been defined for a - * given host. This information is used to determine which data should or - * should not be reported in the bootp packet vendor info field. - */ - -struct flag { - unsigned bootfile :1, - bootserver :1, - bootsize :1, - bootsize_auto :1, - cookie_server :1, - domain_server :1, - gateway :1, - generic :1, - haddr :1, - homedir :1, - htype :1, - impress_server :1, - iaddr :1, - log_server :1, - lpr_server :1, - name_server :1, - name_switch :1, - rlp_server :1, - send_name :1, - subnet_mask :1, - tftpdir :1, - time_offset :1, - time_server :1, - dump_file :1, - domain_name :1, - swap_server :1, - root_path :1, - exten_file :1, - reply_addr :1, - nis_domain :1, - nis_server :1, - ntp_server :1, - exec_file :1, - msg_size :1, - min_wait :1, - /* XXX - Add new tags here */ - vm_cookie :1; -}; - - - -/* - * The flags structure contains TRUE flags for all the fields which - * are considered valid, regardless of whether they were explicitly - * specified or indirectly inferred from another entry. - * - * The gateway and the various server fields all point to a shared list of - * IP addresses. - * - * The hostname, home directory, and bootfile are all shared strings. - * - * The generic data field is a shared binary data structure. It is used to - * hold future RFC1048 vendor data until bootpd is updated to understand it. - * - * The vm_cookie field specifies the four-octet vendor magic cookie to use - * if it is desired to always send the same response to a given host. - * - * Hopefully, the rest is self-explanatory. - */ - -struct host { - unsigned linkcount; /* hash list inserts */ - struct flag flags; /* ALL valid fields */ - struct in_addr_list *cookie_server, - *domain_server, - *gateway, - *impress_server, - *log_server, - *lpr_server, - *name_server, - *rlp_server, - *time_server, - *nis_server, - *ntp_server; - struct shared_string *bootfile, - *hostname, - *domain_name, - *homedir, - *tftpdir, - *dump_file, - *exten_file, - *root_path, - *nis_domain, - *exec_file; - struct shared_bindata *generic; - byte vm_cookie[4], - htype, /* RFC826 says this should be 16-bits but - RFC951 only allocates 1 byte. . . */ - haddr[MAXHADDRLEN]; - int32 time_offset; - unsigned int32 bootsize, - msg_size, - min_wait; - struct in_addr bootserver, - iaddr, - swap_server, - reply_addr, - subnet_mask; - /* XXX - Add new tags here (or above as appropriate) */ -}; - - - -/* - * Variables shared among modules. - */ - -extern int debug; -extern char *bootptab; -extern char *progname; - -extern u_char vm_cmu[4]; -extern u_char vm_rfc1048[4]; - -extern hash_tbl *hwhashtable; -extern hash_tbl *iphashtable; -extern hash_tbl *nmhashtable; - diff --git a/usr.sbin/bootpd/bootpef.8 b/usr.sbin/bootpd/bootpef.8 deleted file mode 100644 index 0f0b1fc7b437..000000000000 --- a/usr.sbin/bootpd/bootpef.8 +++ /dev/null @@ -1,52 +0,0 @@ -.\" bootpef.8 -.TH BOOTPEF 8 "4 Dec 1993" "MAINTENANCE COMMANDS" -.SH NAME -bootpef \- BOOTP Extension File compiler -.SH SYNOPSIS -.LP -.B bootpef -.RI [ "-c chdir" ] -.RI [ "-d debug-level" ] -.RI [ "-f config-file" ] -.RI [ client-name " [...]]" -.SH DESCRIPTION -.B bootpef -builds the -.I Extension Path -files described by RFC 1497 (tag 18). -If any -.I client-name -arguments are specified, then -.I bootpef -compiles the extension files for only those clients. -.SH OPTIONS -.TP -.BI \-c \ chdir\-path -Sets the current directory used by -.I bootpef -while creating extension files. This is useful when the -extension file names are specified as relative pathnames, and -.I bootpef -needs to use the same current directory as the TFTP server -(typically /tftpboot). -.TP -.BI \-d \ debug\-level -Sets the -.I debug\-level -variable that controls the amount of debugging messages generated. -For example, -d4 or -d 4 will set the debugging level to 4. -.TP -.BI \-f \ config\-file -Set the name of the config file that specifies the option -data to be sent to each client. -.SH "SEE ALSO" -bootpd(8), tftpd(8) -.SH REFERENCES -.TP -RFC951 -BOOTSTRAP PROTOCOL (BOOTP) -.TP -RFC1497 -BOOTP Vendor Information Extensions - - diff --git a/usr.sbin/bootpd/bootpef.c b/usr.sbin/bootpd/bootpef.c deleted file mode 100644 index 4b2e3f405cde..000000000000 --- a/usr.sbin/bootpd/bootpef.c +++ /dev/null @@ -1,347 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: bootpef.c,v 1.2 1994/08/22 22:14:46 gwr Exp $"; -#endif - - -/* - * bootpef - BOOTP Extension File generator - * Makes an "Extension File" for each host entry that - * defines an and Extension File. (See RFC1497, tag 18.) - * - * HISTORY - * See ./Changes - * - * BUGS - * See ./ToDo - */ - - - -#ifdef __STDC__ -#include -#else -#include -#endif - -#include -#include - -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "bootpd.h" -#include "dovend.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "patchlevel.h" - -#define BUFFERSIZE 0x4000 - -#ifndef CONFIG_FILE -#define CONFIG_FILE "/etc/bootptab" -#endif - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void dovend_rfc1048 P((struct bootp *, struct host *, int32)); -static void mktagfile P((struct host *)); -static void usage P((void)); - -#undef P - - -/* - * General - */ - -char *progname; -char *chdir_path; -int debug = 0; /* Debugging flag (level) */ -byte *buffer; - -/* - * Globals below are associated with the bootp database file (bootptab). - */ - -char *bootptab = CONFIG_FILE; - - -/* - * Print "usage" message and exit - */ -static void -usage() -{ - fprintf(stderr, - "usage: $s [ -c chdir ] [-d level] [-f configfile] [host...]\n"); - fprintf(stderr, "\t -c n\tset current directory\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -f n\tconfig file name\n"); - exit(1); -} - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ -void -main(argc, argv) - int argc; - char **argv; -{ - struct host *hp; - char *stmp; - int n; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* Get work space for making tag 18 files. */ - buffer = (byte *) malloc(BUFFERSIZE); - if (!buffer) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'c': /* chdir_path */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (stmp[0] != '/')) { - fprintf(stderr, - "bootpd: invalid chdir specification\n"); - break; - } - chdir_path = stmp; - break; - - case 'd': /* debug */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "bootpd: invalid debug level\n"); - break; - } - debug = n; - break; - - case 'f': /* config file */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - bootptab = stmp; - break; - - default: - fprintf(stderr, "bootpd: unknown switch: -%c\n", - argv[0][1]); - usage(); - break; - } - } - - /* Get the timezone. */ - tzone_init(); - - /* Allocate hash tables. */ - rdtab_init(); - - /* - * Read the bootptab file. - */ - readtab(1); /* force read */ - - /* Set the cwd (i.e. to /tftpboot) */ - if (chdir_path) { - if (chdir(chdir_path) < 0) - report(LOG_ERR, "%s: chdir failed", chdir_path); - } - /* If there are host names on the command line, do only those. */ - if (argc > 0) { - unsigned int tlen, hashcode; - - while (argc) { - tlen = strlen(argv[0]); - hashcode = hash_HashFunction((u_char *)argv[0], tlen); - hp = (struct host *) hash_Lookup(nmhashtable, - hashcode, - nmcmp, argv[0]); - if (!hp) { - printf("%s: no matching entry\n", argv[0]); - exit(1); - } - if (!hp->flags.exten_file) { - printf("%s: no extension file\n", argv[0]); - exit(1); - } - mktagfile(hp); - argv++; - argc--; - } - exit(0); - } - /* No host names specified. Do them all. */ - hp = (struct host *) hash_FirstEntry(nmhashtable); - while (hp != NULL) { - mktagfile(hp); - hp = (struct host *) hash_NextEntry(nmhashtable); - } -} - - - -/* - * Make a "TAG 18" file for this host. - * (Insert the RFC1497 options.) - */ - -static void -mktagfile(hp) - struct host *hp; -{ - FILE *fp; - int bytesleft, len; - byte *vp; - char *tmpstr; - - if (!hp->flags.exten_file) - return; - - vp = buffer; - bytesleft = BUFFERSIZE; - bcopy(vm_rfc1048, vp, 4); /* Copy in the magic cookie */ - vp += 4; - bytesleft -= 4; - - /* - * The "extension file" options are appended by the following - * function (which is shared with bootpd.c). - */ - len = dovend_rfc1497(hp, vp, bytesleft); - vp += len; - bytesleft -= len; - - if (bytesleft < 1) { - report(LOG_ERR, "%s: too much option data", - hp->exten_file->string); - return; - } - *vp++ = TAG_END; - bytesleft--; - - /* Write the buffer to the extension file. */ - printf("Updating \"%s\"\n", hp->exten_file->string); - if ((fp = fopen(hp->exten_file->string, "w")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", - hp->exten_file->string, get_errmsg()); - return; - } - len = vp - buffer; - if (len != fwrite(buffer, 1, len, fp)) { - report(LOG_ERR, "write failed on \"%s\" : %s", - hp->exten_file->string, get_errmsg()); - } - fclose(fp); - -} /* dovend_rfc1048 */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/bootpgw.c b/usr.sbin/bootpd/bootpgw.c deleted file mode 100644 index f157ccac9e85..000000000000 --- a/usr.sbin/bootpd/bootpgw.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - * bootpgw.c - BOOTP GateWay - * This program forwards BOOTP Request packets to a BOOTP server. - */ - -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: bootpgw.c,v 1.2 1994/08/22 22:14:48 gwr Exp $"; -#endif - -/* - * BOOTPGW is typically used to forward BOOTP client requests from - * one subnet to a BOOTP server on a different subnet. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef NO_SETSID -# include /* for O_RDONLY, etc */ -#endif - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "getif.h" -#include "hwaddr.h" -#include "report.h" -#include "patchlevel.h" - -/* Local definitions: */ -#define MAX_MSG_SIZE (3*512) /* Maximum packet size */ -#define TRUE 1 -#define FALSE 0 -#define get_network_errmsg get_errmsg - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void usage P((void)); -static void handle_reply P((void)); -static void handle_request P((void)); - -#undef P - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in bind_addr; /* Listening */ -struct sockaddr_in recv_addr; /* Packet source */ -struct sockaddr_in send_addr; /* destination */ - - -/* - * option defaults - */ -int debug = 0; /* Debugging flag (level) */ -struct timeval actualtimeout = -{ /* fifteen minutes */ - 15 * 60L, /* tv_sec */ - 0 /* tv_usec */ -}; -u_int maxhops = 4; /* Number of hops allowed for requests. */ -u_int minwait = 3; /* Number of seconds client must wait before - its bootrequest packets are forwarded. */ - -/* - * General - */ - -int s; /* Socket file descriptor */ -char *pktbuf; /* Receive packet buffer */ -int pktlen; -char *progname; -char *servername; -int32 server_ipa; /* Real server IP address, network order. */ - -char myhostname[64]; -struct in_addr my_ip_addr; - - - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ - -void -main(argc, argv) - int argc; - char **argv; -{ - struct timeval *timeout; - struct bootp *bp; - struct servent *servp; - struct hostent *hep; - char *stmp; - int n, ba_len, ra_len; - int nfound, readfds; - int standalone; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* - * Initialize logging. - */ - report_init(0); /* uses progname */ - - /* - * Log startup - */ - report(LOG_INFO, "version %s.%d", VERSION, PATCHLEVEL); - - /* Debugging for compilers with struct padding. */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - /* Get space for receiving packets and composing replies. */ - pktbuf = malloc(MAX_MSG_SIZE); - if (!pktbuf) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - bp = (struct bootp *) pktbuf; - - /* - * Check to see if a socket was passed to us from inetd. - * - * Use getsockname() to determine if descriptor 0 is indeed a socket - * (and thus we are probably a child of inetd) or if it is instead - * something else and we are running standalone. - */ - s = 0; - ba_len = sizeof(bind_addr); - bzero((char *) &bind_addr, ba_len); - errno = 0; - standalone = TRUE; - if (getsockname(s, (struct sockaddr *) &bind_addr, &ba_len) == 0) { - /* - * Descriptor 0 is a socket. Assume we are a child of inetd. - */ - if (bind_addr.sin_family == AF_INET) { - standalone = FALSE; - bootps_port = ntohs(bind_addr.sin_port); - } else { - /* Some other type of socket? */ - report(LOG_INFO, "getsockname: not an INET socket"); - } - } - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - timeout = &actualtimeout; - gethostname(myhostname, sizeof(myhostname)); - hep = gethostbyname(myhostname); - if (!hep) { - printf("Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, (char *)&my_ip_addr, sizeof(my_ip_addr)); - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'd': /* debug level */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid debug level\n", progname); - break; - } - debug = n; - break; - - case 'h': /* hop count limit */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || - (n < 0) || (n > 16)) - { - fprintf(stderr, - "bootpgw: invalid hop count limit\n"); - break; - } - maxhops = (u_int)n; - break; - - case 'i': /* inetd mode */ - standalone = FALSE; - break; - - case 's': /* standalone mode */ - standalone = TRUE; - break; - - case 't': /* timeout */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid timeout specification\n", progname); - break; - } - actualtimeout.tv_sec = (int32) (60 * n); - /* - * If the actual timeout is zero, pass a NULL pointer - * to select so it blocks indefinitely, otherwise, - * point to the actual timeout value. - */ - timeout = (n > 0) ? &actualtimeout : NULL; - break; - - case 'w': /* wait time */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || - (n < 0) || (n > 60)) - { - fprintf(stderr, - "bootpgw: invalid wait time\n"); - break; - } - minwait = (u_int)n; - break; - - default: - fprintf(stderr, "%s: unknown switch: -%c\n", - progname, argv[0][1]); - usage(); - break; - - } /* switch */ - } /* for args */ - - /* Make sure server name argument is suplied. */ - servername = argv[0]; - if (!servername) { - fprintf(stderr, "bootpgw: missing server name\n"); - usage(); - } - /* - * Get address of real bootp server. - */ - if (isdigit(servername[0])) - server_ipa = inet_addr(servername); - else { - hep = gethostbyname(servername); - if (!hep) { - fprintf(stderr, "bootpgw: can't get addr for %s\n", servername); - exit(1); - } - bcopy(hep->h_addr, (char *)&server_ipa, sizeof(server_ipa)); - } - - if (standalone) { - /* - * Go into background and disassociate from controlling terminal. - * XXX - This is not the POSIX way (Should use setsid). -gwr - */ - if (debug < 3) { - if (fork()) - exit(0); -#ifdef NO_SETSID - setpgrp(0,0); -#ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); - if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); - (void) close(n); - } -#endif /* TIOCNOTTY */ -#else /* SETSID */ - if (setsid() < 0) - perror("setsid"); -#endif /* SETSID */ - } /* if debug < 3 */ - /* - * Nuke any timeout value - */ - timeout = NULL; - - /* - * Here, bootpd would do: - * chdir - * tzone_init - * rdtab_init - * readtab - */ - - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "socket: %s", get_network_errmsg()); - exit(1); - } - /* - * Get server's listening port number - */ - servp = getservbyname("bootps", "udp"); - if (servp) { - bootps_port = ntohs((u_short) servp->s_port); - } else { - bootps_port = (u_short) IPPORT_BOOTPS; - report(LOG_ERR, - "udp/bootps: unknown service -- assuming port %d", - bootps_port); - } - - /* - * Bind socket to BOOTPS port. - */ - bind_addr.sin_family = AF_INET; - bind_addr.sin_port = htons(bootps_port); - bind_addr.sin_addr.s_addr = INADDR_ANY; - if (bind(s, (struct sockaddr *) &bind_addr, - sizeof(bind_addr)) < 0) - { - report(LOG_ERR, "bind: %s", get_network_errmsg()); - exit(1); - } - } /* if standalone */ - /* - * Get destination port number so we can reply to client - */ - servp = getservbyname("bootpc", "udp"); - if (servp) { - bootpc_port = ntohs(servp->s_port); - } else { - report(LOG_ERR, - "udp/bootpc: unknown service -- assuming port %d", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* no signal catchers */ - - /* - * Process incoming requests. - */ - for (;;) { - readfds = 1 << s; - nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout); - if (nfound < 0) { - if (errno != EINTR) { - report(LOG_ERR, "select: %s", get_errmsg()); - } - continue; - } - if (!(readfds & (1 << s))) { - report(LOG_INFO, "exiting after %ld minutes of inactivity", - actualtimeout.tv_sec / 60); - exit(0); - } - ra_len = sizeof(recv_addr); - n = recvfrom(s, pktbuf, MAX_MSG_SIZE, 0, - (struct sockaddr *) &recv_addr, &ra_len); - if (n <= 0) { - continue; - } - if (debug > 3) { - report(LOG_INFO, "recvd pkt from IP addr %s", - inet_ntoa(recv_addr.sin_addr)); - } - if (n < sizeof(struct bootp)) { - if (debug) { - report(LOG_INFO, "received short packet"); - } - continue; - } - pktlen = n; - - switch (bp->bp_op) { - case BOOTREQUEST: - handle_request(); - break; - case BOOTREPLY: - handle_reply(); - break; - } - } -} - - - - -/* - * Print "usage" message and exit - */ - -static void -usage() -{ - fprintf(stderr, - "usage: bootpgw [-d level] [-i] [-s] [-t timeout] server\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -h n\tset max hop count\n"); - fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n"); - fprintf(stderr, "\t -s\tforce standalone mode (run without inetd)\n"); - fprintf(stderr, "\t -t n\tset inetd exit timeout to n minutes\n"); - fprintf(stderr, "\t -w n\tset min wait time (secs)\n"); - exit(1); -} - - - -/* - * Process BOOTREQUEST packet. - * - * Note, this just forwards the request to a real server. - */ -static void -handle_request() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct ifreq *ifr; - u_short secs, hops; - - /* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */ - - if (debug) { - report(LOG_INFO, "request from %s", - inet_ntoa(recv_addr.sin_addr)); - } - /* Has the client been waiting long enough? */ - secs = ntohs(bp->bp_secs); - if (secs < minwait) - return; - - /* Has this packet hopped too many times? */ - hops = ntohs(bp->bp_hops); - if (++hops > maxhops) { - report(LOG_NOTICE, "reqest from %s reached hop limit", - inet_ntoa(recv_addr.sin_addr)); - return; - } - bp->bp_hops = htons(hops); - - /* - * Here one might discard a request from the same subnet as the - * real server, but we can assume that the real server will send - * a reply to the client before it waits for minwait seconds. - */ - - /* If gateway address is not set, put in local interface addr. */ - if (bp->bp_giaddr.s_addr == 0) { -#if 0 /* BUG */ - struct sockaddr_in *sip; - /* - * XXX - This picks the wrong interface when the receive addr - * is the broadcast address. There is no portable way to - * find out which interface a broadcast was received on. -gwr - * (Thanks to for finding this bug!) - */ - ifr = getif(s, &recv_addr.sin_addr); - if (!ifr) { - report(LOG_NOTICE, "no interface for request from %s", - inet_ntoa(recv_addr.sin_addr)); - return; - } - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - bp->bp_giaddr = sip->sin_addr; -#else /* BUG */ - /* - * XXX - Just set "giaddr" to our "official" IP address. - * RFC 1532 says giaddr MUST be set to the address of the - * interface on which the request was received. Setting - * it to our "default" IP address is not strictly correct, - * but is good enough to allow the real BOOTP server to - * get the reply back here. Then, before we forward the - * reply to the client, the giaddr field is corrected. - * (In case the client uses giaddr, which it should not.) - * See handle_reply() - */ - bp->bp_giaddr = my_ip_addr; -#endif /* BUG */ - - /* - * XXX - DHCP says to insert a subnet mask option into the - * options area of the request (if vendor magic == std). - */ - } - /* Set up socket address for send. */ - send_addr.sin_family = AF_INET; - send_addr.sin_port = htons(bootps_port); - send_addr.sin_addr.s_addr = server_ipa; - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} - - - -/* - * Process BOOTREPLY packet. - */ -static void -handle_reply() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct ifreq *ifr; - struct sockaddr_in *sip; - u_char canon_haddr[MAXHADDRLEN]; - unsigned char *ha; - int len; - - if (debug) { - report(LOG_INFO, " reply for %s", - inet_ntoa(bp->bp_yiaddr)); - } - /* Make sure client is directly accessible. */ - ifr = getif(s, &(bp->bp_yiaddr)); - if (!ifr) { - report(LOG_NOTICE, "no interface for reply to %s", - inet_ntoa(bp->bp_yiaddr)); - return; - } -#if 1 /* Experimental (see BUG above) */ -/* #ifdef CATER_TO_OLD_CLIENTS ? */ - /* - * The giaddr field has been set to our "default" IP address - * which might not be on the same interface as the client. - * In case the client looks at giaddr, (which it should not) - * giaddr is now set to the address of the correct interface. - */ - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - bp->bp_giaddr = sip->sin_addr; -#endif - - /* Set up socket address for send to client. */ - send_addr.sin_family = AF_INET; - send_addr.sin_addr = bp->bp_yiaddr; - send_addr.sin_port = htons(bootpc_port); - - /* Create an ARP cache entry for the client. */ - ha = bp->bp_chaddr; - len = bp->bp_hlen; - if (len > MAXHADDRLEN) - len = MAXHADDRLEN; - if (bp->bp_htype == HTYPE_IEEE802) { - haddr_conv802(ha, canon_haddr, len); - ha = canon_haddr; - } - if (debug > 1) - report(LOG_INFO, "setarp %s - %s", - inet_ntoa(bp->bp_yiaddr), haddrtoa(ha, len)); - setarp(s, &bp->bp_yiaddr, ha, len); - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/bootptab.5 b/usr.sbin/bootpd/bootptab.5 deleted file mode 100644 index 2cf1147ceb56..000000000000 --- a/usr.sbin/bootpd/bootptab.5 +++ /dev/null @@ -1,395 +0,0 @@ -.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University -.\" -.\" $Header: /b/source/CVS/src/usr.sbin/bootpd/bootptab.5,v 1.2 1994/08/22 22:14:51 gwr Exp $ -.\" -.TH BOOTPTAB 5 "October 31, 1991" "Carnegie Mellon University" -.UC 6 - -.SH NAME -bootptab \- Internet Bootstrap Protocol server database -.SH DESCRIPTION -The -.I bootptab -file is the configuration database file for -.IR bootpd , -the Internet Bootstrap Protocol server. -It's format is similar to that of -.IR termcap (5) -in which two-character case-sensitive tag symbols are used to -represent host parameters. These parameter declarations are separated by -colons (:), with a general format of: -.PP -.I " hostname:tg=value. . . :tg=value. . . :tg=value. . . ." -.PP -where -.I hostname -is the actual name of a bootp client (or a "dummy entry"), and -.I tg -is a two-character tag symbol. Dummy entries have an invalid hostname -(one with a "." as the first character) and are used to provide -default values used by other entries via the -.B tc=.dummy-entry -mechanism. Most tags must be followed by an equals-sign -and a value as above. Some may also appear in a boolean form with no -value (i.e. -.RI : tg :). -The currently recognized tags are: -.PP -.br - bf Bootfile -.br - bs Bootfile size in 512-octet blocks -.br - cs Cookie server address list -.br - df Merit dump file -.br - dn Domain name -.br - ds Domain name server address list -.br - ef Extension file -.br - gw Gateway address list -.br - ha Host hardware address -.br - hd Bootfile home directory -.br - hn Send client's hostname to client -.br - ht Host hardware type (see Assigned Numbers RFC) -.br - im Impress server address list -.br - ip Host IP address -.br - lg Log server address list -.br - lp LPR server address list -.br - ns IEN-116 name server address list -.br - nt NTP (time) Server (RFC 1129) -.br - ra Reply address override -.br - rl Resource location protocol server address list -.br - rp Root path to mount as root -.br - sa TFTP server address client should use -.br - sm Host subnet mask -.br - sw Swap server address -.br - tc Table continuation (points to similar "template" host entry) -.br - td TFTP root directory used by "secure" TFTP servers -.br - to Time offset in seconds from UTC -.br - ts Time server address list -.br - vm Vendor magic cookie selector -.br - yd YP (NIS) domain name -.br - ys YP (NIS) server address - -.PP -There is also a generic tag, -.RI T n , -where -.I n -is an RFC1084 vendor field tag number. Thus it is possible to immediately -take advantage of future extensions to RFC1084 without being forced to modify -.I bootpd -first. Generic data may be represented as either a stream of hexadecimal -numbers or as a quoted string of ASCII characters. The length of the generic -data is automatically determined and inserted into the proper field(s) of the -RFC1084-style bootp reply. -.PP -The following tags take a whitespace-separated list of IP addresses: -.BR cs , -.BR ds , -.BR gw , -.BR im , -.BR lg , -.BR lp , -.BR ns , -.BR nt , -.BR ra , -.BR rl , -and -.BR ts . -The -.BR ip , -.BR sa , -.BR sw , -.BR sm , -and -.B ys -tags each take a single IP address. -All IP addresses are specified in standard Internet "dot" notation -and may use decimal, octal, or hexadecimal numbers -(octal numbers begin with 0, hexadecimal numbers begin with '0x' or '0X'). -Any IP addresses may alternatively be specified as a hostname, causing -.I bootpd -to lookup the IP address for that host name using gethostbyname(3). -If the -.B ip -tag is not specified, -.I bootpd -will determine the IP address using the entry name as the host name. -(Dummy entries use an invalid host name to avoid automatic IP lookup.) -.PP -The -.B ht -tag specifies the hardware type code as either an unsigned decimal, octal, or -hexadecimal integer or one of the following symbolic names: -.B ethernet -or -.B ether -for 10Mb Ethernet, -.B ethernet3 -or -.B ether3 -for 3Mb experimental Ethernet, -.BR ieee802 , -.BR tr , -or -.B token-ring -for IEEE 802 networks, -.B pronet -for Proteon ProNET Token Ring, or -.BR chaos , -.BR arcnet , -or -.B ax.25 -for Chaos, ARCNET, and AX.25 Amateur Radio networks, respectively. -The -.B ha -tag takes a hardware address which may be specified as a host name -or in numeric form. Note that the numeric form -.I must -be specified in hexadecimal; optional periods and/or a leading '0x' may be -included for readability. The -.B ha -tag must be preceded by the -.B ht -tag (either explicitly or implicitly; see -.B tc -below). -If the hardware address is not specified and the type is specified -as either "ethernet" or "ieee802", then -.I bootpd -will try to determine the hardware address using ether_hton(3). -.PP -The hostname, home directory, and bootfile are ASCII strings which may be -optionally surrounded by double quotes ("). The client's request and the -values of the -.B hd -and -.B bf -symbols determine how the server fills in the bootfile field of the bootp -reply packet. -.PP -If the client provides a file name it is left as is. -Otherwise, if the -.B bf -option is specified its value is copied into the reply packet. -If the -.B hd -option is specified as well, its value is prepended to the -boot file copied into the reply packet. -The existence of the boot file is checked only if the -.BR bs =auto -option is used (to determine the boot file size). -A reply may be sent whether or not the boot file exists. -.PP -Some newer versions of -.I tftpd -provide a security feature to change their root directory using -the -.IR chroot (2) -system call. -The -.B td -tag may be used to inform -.I bootpd -of this special root directory used by -.IR tftpd . -(One may alternatively use the -.I bootpd -"-c chdir" option.) -The -.B hd -tag is actually relative to the root directory specified by the -.B td -tag. -For example, if the real absolute path to your BOOTP client bootfile is -/tftpboot/bootfiles/bootimage, and -.IR tftpd -uses /tftpboot as its "secure" directory, then specify the following in -.IR bootptab : -.PP -.br - :td=/tftpboot:hd=/bootfiles:bf=bootimage: -.PP -If your bootfiles are located directly in /tftpboot, use: -.PP -.br - :td=/tftpboot:hd=/:bf=bootimage: -.PP -The -.B sa -tag may be used to specify the IP address of the particular TFTP server -you wish the client to use. In the absence of this tag, -.I bootpd -will tell the client to perform TFTP to the same machine -.I bootpd -is running on. -.PP -The time offset -.B to -may be either a signed decimal integer specifying the client's -time zone offset in seconds from UTC, or the keyword -.B auto -which uses the server's time zone offset. Specifying the -.B to -symbol as a boolean has the same effect as specifying -.B auto -as its value. -.PP -The bootfile size -.B bs -may be either a decimal, octal, or hexadecimal integer specifying the size of -the bootfile in 512-octet blocks, or the keyword -.B auto -which causes the server to automatically calculate the bootfile size at each -request. As with the time offset, specifying the -.B bs -symbol as a boolean has the same effect as specifying -.B auto -as its value. -.PP -The vendor magic cookie selector (the -.B vm -tag) may take one of the following keywords: -.B auto -(indicating that vendor information is determined by the client's request), -.B rfc1048 -or -.B rfc1084 -(which always forces an RFC1084-style reply), or -.B cmu -(which always forces a CMU-style reply). -.PP -The -.B hn -tag is strictly a boolean tag; it does not take the usual equals-sign and -value. It's presence indicates that the hostname should be sent to RFC1084 -clients. -.I Bootpd -attempts to send the entire hostname as it is specified in the configuration -file; if this will not fit into the reply packet, the name is shortened to -just the host field (up to the first period, if present) and then tried. -In no case is an arbitrarily-truncated hostname sent (if nothing reasonable -will fit, nothing is sent). -.PP -Often, many host entries share common values for certain tags (such as name -servers, etc.). Rather than repeatedly specifying these tags, a full -specification can be listed for one host entry and shared by others via the -.B tc -(table continuation) mechanism. -Often, the template entry is a dummy host which doesn't actually exist and -never sends bootp requests. This feature is similar to the -.B tc -feature of -.IR termcap (5) -for similar terminals. Note that -.I bootpd -allows the -.B tc -tag symbol to appear anywhere in the host entry, unlike -.I termcap -which requires it to be the last tag. Information explicitly specified for a -host always overrides information implied by a -.B tc -tag symbol, regardless of its location within the entry. The -value of the -.B tc -tag may be the hostname or IP address of any host entry -previously listed in the configuration file. -.PP -Sometimes it is necessary to delete a specific tag after it has been inferred -via -.BR tc . -This can be done using the construction -.IB tag @ -which removes the effect of -.I tag -as in -.IR termcap (5). -For example, to completely undo an IEN-116 name server specification, use -":ns@:" at an appropriate place in the configuration entry. After removal -with -.BR @ , -a tag is eligible to be set again through the -.B tc -mechanism. -.PP -Blank lines and lines beginning with "#" are ignored in the configuration -file. Host entries are separated from one another by newlines; a single host -entry may be extended over multiple lines if the lines end with a backslash -(\\). It is also acceptable for lines to be longer than 80 characters. Tags -may appear in any order, with the following exceptions: the hostname must be -the very first field in an entry, and the hardware type must precede the -hardware address. -.PP -An example -.I /etc/bootptab -file follows: -.PP -.nf - # Sample bootptab file (domain=andrew.cmu.edu) - - .default:\\ - :hd=/usr/boot:bf=null:\\ - :ds=netserver, lancaster:\\ - :ns=pcs2, pcs1:\\ - :ts=pcs2, pcs1:\\ - :sm=255.255.255.0:\\ - :gw=gw.cs.cmu.edu:\\ - :hn:to=-18000: - - carnegie:ht=6:ha=7FF8100000AF:tc=.default: - baldwin:ht=1:ha=0800200159C3:tc=.default: - wylie:ht=1:ha=00DD00CADF00:tc=.default: - arnold:ht=1:ha=0800200102AD:tc=.default: - bairdford:ht=1:ha=08002B02A2F9:tc=.default: - bakerstown:ht=1:ha=08002B0287C8:tc=.default: - - # Special domain name server and option tags for next host - butlerjct:ha=08002001560D:ds=128.2.13.42:\\ - :T37=0x12345927AD3BCF:\\ - :T99="Special ASCII string":\\ - :tc=.default: - - gastonville:ht=6:ha=7FFF81000A47:tc=.default: - hahntown:ht=6:ha=7FFF81000434:tc=.default: - hickman:ht=6:ha=7FFF810001BA:tc=.default: - lowber:ht=1:ha=00DD00CAF000:tc=.default: - mtoliver:ht=1:ha=00DD00FE1600:tc=.default: - -.fi -.SH FILES -/etc/bootptab - -.SH "SEE ALSO" -.br -bootpd(8), tftpd(8), -.br -DARPA Internet Request For Comments RFC951, RFC1048, RFC1084, Assigned Numbers diff --git a/usr.sbin/bootpd/bootptab.cmu b/usr.sbin/bootpd/bootptab.cmu deleted file mode 100644 index 66212d421a23..000000000000 --- a/usr.sbin/bootpd/bootptab.cmu +++ /dev/null @@ -1,124 +0,0 @@ -# /etc/bootptab: database for bootp server (/etc/bootpd) -# (I've hacked on this but can't test it... -gwr) - -# Blank lines and lines beginning with '#' are ignored. -# -# Legend: (see bootptab.5) -# first field -- hostname (not indented) -# bf -- bootfile -# bs -- bootfile size in 512-octet blocks -# cs -- cookie servers -# df -- dump file name -# dn -- domain name -# ds -- domain name servers -# ef -- extension file -# gw -- gateways -# ha -- hardware address -# hd -- home directory for bootfiles -# hn -- host name set for client -# ht -- hardware type -# im -- impress servers -# ip -- host IP address -# lg -- log servers -# lp -- LPR servers -# ns -- IEN-116 name servers -# ra -- reply address -# rl -- resource location protocol servers -# rp -- root path -# sa -- boot server address -# sm -- subnet mask -# sw -- swap server -# tc -- template host (points to similar host entry) -# td -- TFTP directory -# to -- time offset (seconds) -# ts -- time servers -# vm -- vendor magic number -# Tn -- generic option tag n -# -# Be careful about including backslashes where they're needed. Weird (bad) -# things can happen when a backslash is omitted where one is intended. -# Also, note that generic option data must be either a string or a -# sequence of bytes where each byte is a two-digit hex value. - -# First, we define a global entry which specifies the stuff every host uses. -# (Host name lookups are relative to the domain: andrew.cmu.edu) -.default:\ - :hn:dn=cmu.edu:\ - :hd=/usr/boot:\ - :ds=netserver, lancaster:\ - :ns=pcs2, pcs1:\ - :ts=pcs2, pcs1:\ - :sm=255.255.0.0:\ - :gw=gw.cs.cmu.edu:\ - to=auto: - - -# Next, we can define different master entries for each subnet. . . -.subnet13 :sm=255.255.255.0:gw=128.2.13.1 :tc=.default: -.subnet19 :sm=255.255.255.0:gw=128.2.19.1 :tc=.default: -.subnet232 :sm=255.255.255.0:gw=128.2.232.1 :tc=.default: - -# -# We should be able to use as many levels of indirection as desired. Use -# your imagination. . . -# - - -# Individual entries (could also have different servers for some/all of these -# hosts, but we don't really use this feature at CMU): - -carnegie:tc=.subnet13:ht=ieee802:ha=7FF8100000AF: -baldwin:tc=.subnet19:ha=0800200159C3: -wylie:tc=.subnet232:ha=00DD00CADF00: -arnold:tc=.subnet19:ha=0800200102AD: -bairdford:tc=.subnet19:ha=08002B02A2F9: -bakerstown:tc=.subnet19:ha=08002B0287C8: -butlerjct:tc=.subnet232:ha=08002001560D: -gastonville:tc=.subnet232:ht=ieee802:ha=7FFF81000A47: -hahntown:tc=.subnet13:ht=ieee802:ha=7FFF81000434: -hickman:tc=.subnet19:ht=ieee802:ha=7FFF810001BA: -lowber:tc=.subnet13:ha=00DD00CAF000: -mtoliver:tc=.subnet19:ha=00DD00FE1600: -osborne:tc=.subnet232:ha=00DD00CAD600: -russelton:tc=.subnet232:ha=080020017FC3: -thornburg:tc=.subnet13:ha=080020012A33: - - -# Hmmm. . . Let's throw in some whitespace for readability. . . . - -andrew: tc=.subnet19:ha=00DD00C88900: -birdville: tc=.subnet19:ha=00DD00FE2D00: -coudersport: tc=.subnet13:ha=00DD00CB1E00: -bridgeville: tc=.subnet232:ha=080020011394: -franklin: tc=.subnet19:ha=08002B02A5D5: -hollidaysburg: tc=.subnet19:ht=ieee802:ha=7FFF810002C8: -honesdale: tc=.subnet19:ha=08002B02F83F: -huntingdon: tc=.subnet19:ha=08002B02E410: -indiana: tc=.subnet13:ha=08002B029BEC: -jimthorpe: tc=.subnet232:ha=08002B02FBBA: -kittanning: tc=.subnet232:ha=08002B0273FC: -lebanon: tc=.subnet232:ha=08002B037F67: -lewisburg: tc=.subnet19:ha=50005A1A0DE4: -middleburg: tc=.subnet232:ha=00DD00FE1200: -aspinwall: tc=.subnet13:ha=08002B03C163: -berlin: tc=.subnet13:ha=00DD000A4400: -norristown: tc=.subnet13:ha=08002001455B: -pottsville: tc=.subnet13:ha=00DD000A3700: -ridgway: tc=.subnet19:ha=08002B029425: -scranton: tc=.subnet232:ha=0800200113A1: -chalfont: tc=.subnet13:ha=08002001124B: -washington: tc=.subnet19:ha=00DD00656E00: -wellsboro: tc=.subnet13:ha=00DD00CB1C00: -bb1: tc=.subnet19:ha=00DD000A1F00: -adamstown: tc=.subnet13:ha=08002B02D0E6: -beta: tc=.subnet19:ha=02070100B197: -carbondale: tc=.subnet232:ha=08002B022A73: -clairton: tc=.subnet19:ha=080020010FD1: -egypt: tc=.subnet13:ha=00DD00847B00: -fairchance: tc=.subnet232:ha=00DD000AB100: -fairhope: tc=.subnet232:ha=00DD00CB0800: -galeton: tc=.subnet232:ha=08002001138C: -imperial: tc=.subnet232:ha=08002001130C: -kingston: tc=.subnet232:ha=080020011382: -knox: tc=.subnet232:ha=50005A1A0D2A: -lakecity: tc=.subnet13:ha=080020011380: diff --git a/usr.sbin/bootpd/bootptab.mcs b/usr.sbin/bootpd/bootptab.mcs deleted file mode 100644 index 6fa04d1347eb..000000000000 --- a/usr.sbin/bootpd/bootptab.mcs +++ /dev/null @@ -1,92 +0,0 @@ -# /etc/bootptab: database for bootp server (/etc/bootpd) -# Last update: gwr, Sun Dec 12 19:00:00 EDT 1993 -# Blank lines and lines beginning with '#' are ignored. -# -# Legend: (see bootptab.5) -# first field -- hostname (not indented) -# bf -- bootfile -# bs -- bootfile size in 512-octet blocks -# cs -- cookie servers -# df -- dump file name -# dn -- domain name -# ds -- domain name servers -# ef -- extension file -# gw -- gateways -# ha -- hardware address -# hd -- home directory for bootfiles -# hn -- host name set for client -# ht -- hardware type -# im -- impress servers -# ip -- host IP address -# lg -- log servers -# lp -- LPR servers -# ns -- IEN-116 name servers -# ra -- reply address -# rl -- resource location protocol servers -# rp -- root path -# sa -- boot server address -# sm -- subnet mask -# sw -- swap server -# tc -- template host (points to similar host entry) -# td -- TFTP directory -# to -- time offset (seconds) -# ts -- time servers -# vm -- vendor magic number -# Tn -- generic option tag n -# -# Be careful about including backslashes where they're needed. Weird (bad) -# things can happen when a backslash is omitted where one is intended. -# Also, note that generic option data must be either a string or a -# sequence of bytes where each byte is a two-digit hex value. - -# First, we define a global entry which specifies the stuff every host uses. - -# If you leave "td" empty, run bootpd with the "-c /tftpboot" switch -# so path names (boot files) will be interpreted relative to the same -# directory as tftpd will use when opening files. -.default:\ - :hn:dn="mc.com":\ - :td=/tftpboot:\ - :ds=merlin, jericho:\ - :to=auto: - -# Next, we can define different master entries for each subnet. . . - -.subnet16:\ - :tc=.default:\ - :sm=255.255.255.0:\ - :gw=merlin:\ - :sa=merlin: - -.subnet17:\ - :tc=.default:\ - :sm=255.255.255.0:\ - :gw=merlin-gw:\ - :sa=merlin-gw: - -# -# We should be able to use as many levels of indirection as desired. Use -# your imagination. . . -# - -# Individual entries (could also have different servers for some/all of these -# hosts, but we don't really use this feature at CMU): - -# Emulex terminal server -emulex: tc=.subnet16:ha=00.00.C9.00.42.E0:bf=P4KTL0E: - -# Lantronix eps1 -eps1: tc=.subnet16:ha=00.80.A3.04.1D.78: - -# Tadpole 885 board. -tp885: tc=.subnet17:ha=08.00.4C.00.2F.74:bf=tp885sys2.cfe: - -# MVME147 VxWorks board. -#mvme147:tc=.subnet17:ha=08.00.3e.20.da.47:bf=mv147vxw.st: - -# These are just for testing - -walnut:tc=.subnet16:ha=walnut: -banana:tc=.subnet17:ha=banana: -thor:tc=.subnet17:ha=thor: -classic:tc=.subnet16:ha=classic: diff --git a/usr.sbin/bootpd/bootptest.8 b/usr.sbin/bootpd/bootptest.8 deleted file mode 100644 index d076c8bc25b6..000000000000 --- a/usr.sbin/bootpd/bootptest.8 +++ /dev/null @@ -1,74 +0,0 @@ -.\" bootptest.8 -.TH BOOTPTEST 8 "10 June 1993" "MAINTENANCE COMMANDS" -.SH NAME -bootptest \- send BOOTP queries and print responses -.SH SYNOPSIS -.LP -.B bootptest -[ -.B \-f -.I bootfile -] -[ -.B \-h -] -[ -.B \-m -.I magic_number -] -.I server\-name -.RI [ template-file ] -.SH DESCRIPTION -.B bootptest -sends BOOTP requests to the host specified as -.I server\-name -at one\-second intervals until either a response is received, -or until ten requests have gone unanswered. -After a response is received, -.B bootptest -will wait one more second listening for additional responses. -.SH OPTIONS -.TP -.B \-f -.I bootfile -Fill in the boot file field of the request with -.IR bootfile . -.TP -.B \-h -Use the hardware (Ethernet) address to identify the client. -By default, the IP address is copied into the request -indicating that this client already knows its IP address. -.TP -.B \-m -.I magic_number -Initialize the first word of the vendor options field with -.IR magic_number . -.LP -A -.I template-file -may be specified, in which case -.B bootptest -uses the (binary) contents of this file to initialize the -.I options -area of the request packet. -.SH CREDITS -.LP -The bootptest program is a combination of original and derived works. -The main program module (bootptest.c) is original work by -Gordon W. Ross . -The packet printing module (print-bootp.c) is a slightly modified -version of a file from the BSD tcpdump program. -.LP -This program includes software developed by the University of -California, Lawrence Berkeley Laboratory and its contributors. -(See the copyright notice in print-bootp.c) -.SH "SEE ALSO" -.LP -bootpd(8) -.SH REFERENCES -.TP -RFC951 -BOOTSTRAP PROTOCOL (BOOTP) -.TP -RFC1048 -BOOTP Vendor Information Extensions diff --git a/usr.sbin/bootpd/bootptest.c b/usr.sbin/bootpd/bootptest.c deleted file mode 100644 index bc235ac10650..000000000000 --- a/usr.sbin/bootpd/bootptest.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * bootptest.c - Test out a bootp server. - * - * This simple program was put together from pieces taken from - * various places, including the CMU BOOTP client and server. - * The packet printing routine is from the Berkeley "tcpdump" - * program with some enhancements I added. The print-bootp.c - * file was shared with my copy of "tcpdump" and therefore uses - * some unusual utility routines that would normally be provided - * by various parts of the tcpdump program. Gordon W. Ross - * - * Boilerplate: - * - * This program includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * (See the copyright notice in print-bootp.c) - * - * The remainder of this program is public domain. You may do - * whatever you like with it except claim that you wrote it. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * HISTORY: - * - * 12/02/93 Released version 1.4 (with bootp-2.3.2) - * 11/05/93 Released version 1.3 - * 10/14/93 Released version 1.2 - * 10/11/93 Released version 1.1 - * 09/28/93 Released version 1.0 - * 09/93 Original developed by Gordon W. Ross - */ - -char *usage = "bootptest [-h] server-name [vendor-data-template-file]"; - -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bootp.h" -#include "bootptest.h" -#include "getif.h" -#include "patchlevel.h" - -#define LOG_ERR 1 -#define BUFLEN 1024 -#define WAITSECS 1 -#define MAXWAIT 10 - -int vflag = 1; -int tflag = 0; -int thiszone; -char *progname; -unsigned char *packetp; -unsigned char *snapend; -int snaplen; - - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in sin_server; /* where to send requests */ -struct sockaddr_in sin_client; /* for bind and listen */ -struct sockaddr_in sin_from; /* Packet source */ -u_char eaddr[16]; /* Ethernet address */ - -/* - * General - */ - -int debug = 1; /* Debugging flag (level) */ -char hostname[64]; -char *sndbuf; /* Send packet buffer */ -char *rcvbuf; /* Receive packet buffer */ - -/* - * Vendor magic cookies for CMU and RFC1048 - */ - -unsigned char vm_cmu[4] = VM_CMU; -unsigned char vm_rfc1048[4] = VM_RFC1048; -short secs; /* How long client has waited */ - -char *get_errmsg(); -extern void bootp_print(); - -/* - * Initialization such as command-line processing is done, then - * the receiver loop is started. Die when interrupted. - */ - -main(argc, argv) - int argc; - char **argv; -{ - struct bootp *bp; - struct servent *sep; - struct hostent *hep; - - char *servername = NULL; - char *vendor_file = NULL; - char *bp_file = NULL; - int32 server_addr; /* inet addr, network order */ - int s; /* Socket file descriptor */ - int n, tolen, fromlen, recvcnt; - int use_hwa = 0; - int32 vend_magic; - int32 xid; - - progname = strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname = argv[0]; - argc--; - argv++; - - if (debug) - printf("%s: version %s.%d\n", progname, VERSION, PATCHLEVEL); - - /* - * Verify that "struct bootp" has the correct official size. - * (Catch evil compilers that do struct padding.) - */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - sndbuf = malloc(BUFLEN); - rcvbuf = malloc(BUFLEN); - if (!sndbuf || !rcvbuf) { - printf("malloc failed\n"); - exit(1); - } - - /* default magic number */ - bcopy(vm_rfc1048, (char*)&vend_magic, 4); - - /* Handle option switches. */ - while (argc > 0) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'f': /* File name to reqest. */ - if (argc < 2) - goto error; - argc--; argv++; - bp_file = *argv; - break; - - case 'h': /* Use hardware address. */ - use_hwa = 1; - break; - - case 'm': /* Magic number value. */ - if (argc < 2) - goto error; - argc--; argv++; - vend_magic = inet_addr(*argv); - break; - - error: - default: - puts(usage); - exit(1); - - } - argc--; - argv++; - } - - /* Get server name (or address) for query. */ - if (argc > 0) { - servername = *argv; - argc--; - argv++; - } - /* Get optional vendor-data-template-file. */ - if (argc > 0) { - vendor_file = *argv; - argc--; - argv++; - } - if (!servername) { - printf("missing server name.\n"); - puts(usage); - exit(1); - } - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("socket"); - exit(1); - } - /* - * Get server's listening port number - */ - sep = getservbyname("bootps", "udp"); - if (sep) { - bootps_port = ntohs((u_short) sep->s_port); - } else { - fprintf(stderr, "udp/bootps: unknown service -- using port %d\n", - IPPORT_BOOTPS); - bootps_port = (u_short) IPPORT_BOOTPS; - } - - /* - * Set up server socket address (for send) - */ - if (servername) { - if (isdigit(servername[0])) - server_addr = inet_addr(servername); - else { - hep = gethostbyname(servername); - if (!hep) { - fprintf(stderr, "%s: unknown host\n", servername); - exit(1); - } - bcopy(hep->h_addr, &server_addr, sizeof(server_addr)); - } - } else { - /* Get broadcast address */ - /* XXX - not yet */ - server_addr = INADDR_ANY; - } - sin_server.sin_family = AF_INET; - sin_server.sin_port = htons(bootps_port); - sin_server.sin_addr.s_addr = server_addr; - - /* - * Get client's listening port number - */ - sep = getservbyname("bootpc", "udp"); - if (sep) { - bootpc_port = ntohs(sep->s_port); - } else { - fprintf(stderr, "udp/bootpc: unknown service -- using port %d\n", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* - * Set up client socket address (for listen) - */ - sin_client.sin_family = AF_INET; - sin_client.sin_port = htons(bootpc_port); - sin_client.sin_addr.s_addr = INADDR_ANY; - - /* - * Bind client socket to BOOTPC port. - */ - if (bind(s, (struct sockaddr *) &sin_client, sizeof(sin_client)) < 0) { - perror("bind BOOTPC port"); - if (errno == EACCES) - fprintf(stderr, "You need to run this as root\n"); - exit(1); - } - /* - * Build a request. - */ - bp = (struct bootp *) sndbuf; - bzero(bp, sizeof(*bp)); - bp->bp_op = BOOTREQUEST; - xid = (int32) getpid(); - bp->bp_xid = (u_int32) htonl(xid); - if (bp_file) - strncpy(bp->bp_file, bp_file, BP_FILE_LEN); - - /* - * Fill in the hardware address (or client IP address) - */ - if (use_hwa) { - struct ifreq *ifr; - - ifr = getif(s, &sin_server.sin_addr); - if (!ifr) { - printf("No interface for %s\n", servername); - exit(1); - } - if (getether(ifr->ifr_name, eaddr)) { - printf("Can not get ether addr for %s\n", ifr->ifr_name); - exit(1); - } - /* Copy Ethernet address into request packet. */ - bp->bp_htype = 1; - bp->bp_hlen = 6; - bcopy(eaddr, bp->bp_chaddr, bp->bp_hlen); - } else { - /* Fill in the client IP address. */ - gethostname(hostname, sizeof(hostname)); - hep = gethostbyname(hostname); - if (!hep) { - printf("Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, &bp->bp_ciaddr, hep->h_length); - } - - /* - * Copy in the default vendor data. - */ - bcopy((char*)&vend_magic, bp->bp_vend, 4); - if (vend_magic) - bp->bp_vend[4] = TAG_END; - - /* - * Read in the "options" part of the request. - * This also determines the size of the packet. - */ - snaplen = sizeof(*bp); - if (vendor_file) { - int fd = open(vendor_file, 0); - if (fd < 0) { - perror(vendor_file); - exit(1); - } - /* Compute actual space for options. */ - n = BUFLEN - sizeof(*bp) + BP_VEND_LEN; - n = read(fd, bp->bp_vend, n); - close(fd); - if (n < 0) { - perror(vendor_file); - exit(1); - } - printf("read %d bytes of vendor template\n", n); - if (n > BP_VEND_LEN) { - printf("warning: extended options in use (len > %d)\n", - BP_VEND_LEN); - snaplen += (n - BP_VEND_LEN); - } - } - /* - * Set globals needed by print_bootp - * (called by send_request) - */ - packetp = (unsigned char *) eaddr; - snapend = (unsigned char *) sndbuf + snaplen; - - /* Send a request once per second while waiting for replies. */ - recvcnt = 0; - bp->bp_secs = secs = 0; - send_request(s); - while (1) { - struct timeval tv; - int readfds; - - tv.tv_sec = WAITSECS; - tv.tv_usec = 0L; - readfds = (1 << s); - n = select(s + 1, (fd_set *) & readfds, NULL, NULL, &tv); - if (n < 0) { - perror("select"); - break; - } - if (n == 0) { - /* - * We have not received a response in the last second. - * If we have ever received any responses, exit now. - * Otherwise, bump the "wait time" field and re-send. - */ - if (recvcnt > 0) - exit(0); - secs += WAITSECS; - if (secs > MAXWAIT) - break; - bp->bp_secs = htons(secs); - send_request(s); - continue; - } - fromlen = sizeof(sin_from); - n = recvfrom(s, rcvbuf, BUFLEN, 0, - (struct sockaddr *) &sin_from, &fromlen); - if (n <= 0) { - continue; - } - if (n < sizeof(struct bootp)) { - printf("received short packet\n"); - continue; - } - recvcnt++; - - /* Print the received packet. */ - printf("Recvd from %s", inet_ntoa(sin_from.sin_addr)); - /* set globals needed by bootp_print() */ - snaplen = n; - snapend = (unsigned char *) rcvbuf + snaplen; - bootp_print(rcvbuf, n, sin_from.sin_port, 0); - putchar('\n'); - /* - * This no longer exits immediately after receiving - * one response because it is useful to know if the - * client might get multiple responses. This code - * will now listen for one second after a response. - */ - } - fprintf(stderr, "no response from %s\n", servername); - exit(1); -} - -send_request(s) - int s; -{ - /* Print the request packet. */ - printf("Sending to %s", inet_ntoa(sin_server.sin_addr)); - bootp_print(sndbuf, snaplen, sin_from.sin_port, 0); - putchar('\n'); - - /* Send the request packet. */ - if (sendto(s, sndbuf, snaplen, 0, - (struct sockaddr *) &sin_server, - sizeof(sin_server)) < 0) - { - perror("sendto server"); - exit(1); - } -} - -/* - * Print out a filename (or other ascii string). - * Return true if truncated. - */ -int -printfn(s, ep) - register u_char *s, *ep; -{ - register u_char c; - - putchar('"'); - while (c = *s++) { - if (s > ep) { - putchar('"'); - return (1); - } - if (!isascii(c)) { - c = toascii(c); - putchar('M'); - putchar('-'); - } - if (!isprint(c)) { - c ^= 0x40; /* DEL to ?, others to alpha */ - putchar('^'); - } - putchar(c); - } - putchar('"'); - return (0); -} - -/* - * Convert an IP addr to a string. - * (like inet_ntoa, but ina is a pointer) - */ -char * -ipaddr_string(ina) - struct in_addr *ina; -{ - static char b[24]; - u_char *p; - - p = (u_char *) ina; - sprintf(b, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); - return (b); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/bootptest.h b/usr.sbin/bootpd/bootptest.h deleted file mode 100644 index 27f78ba963b7..000000000000 --- a/usr.sbin/bootpd/bootptest.h +++ /dev/null @@ -1,30 +0,0 @@ -/* bootptest.h */ -/* - * Hacks for sharing print-bootp.c between tcpdump and bootptest. - */ -#define ESRC(p) (p) -#define EDST(p) (p) - -#ifndef USE_BFUNCS -/* Use mem/str functions */ -/* There are no overlapped copies, so memcpy is OK. */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -extern int vflag; /* verbose flag */ - -/* global pointers to beginning and end of current packet (during printing) */ -extern unsigned char *packetp; -extern unsigned char *snapend; - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern char *ipaddr_string P((struct in_addr *)); - -#undef P diff --git a/usr.sbin/bootpd/bptypes.h b/usr.sbin/bootpd/bptypes.h deleted file mode 100644 index 537da4e5e57f..000000000000 --- a/usr.sbin/bootpd/bptypes.h +++ /dev/null @@ -1,23 +0,0 @@ -/* bptypes.h */ - -#ifndef BPTYPES_H -#define BPTYPES_H - -/* - * 32 bit integers are different types on various architectures - */ - -#ifndef int32 -#define int32 long -#endif -typedef unsigned int32 u_int32; - -/* - * Nice typedefs. . . - */ - -typedef int boolean; -typedef unsigned char byte; - - -#endif /* BPTYPES_H */ diff --git a/usr.sbin/bootpd/dovend.c b/usr.sbin/bootpd/dovend.c deleted file mode 100644 index ba6ab288b8b3..000000000000 --- a/usr.sbin/bootpd/dovend.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * dovend.c : Inserts all but the first few vendor options. - */ - -#include - -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -# define index strchr -#endif - -#include "bootp.h" -#include "bootpd.h" -#include "report.h" -#include "dovend.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -PRIVATE int insert_generic P((struct shared_bindata *, byte **, int *)); - -/* - * Insert the 2nd part of the options into an option buffer. - * Return amount of space used. - * - * This inserts everything EXCEPT: - * magic cookie, subnet mask, gateway, bootsize, extension file - * Those are handled separately (in bootpd.c) to allow this function - * to be shared between bootpd and bootpef. - * - * When an "extension file" is in use, the options inserted by - * this function go into the exten_file, not the bootp response. - */ - -int -dovend_rfc1497(hp, buf, len) - struct host *hp; - byte *buf; - int len; -{ - int bytesleft = len; - byte *vp = buf; - char *tmpstr; - - static char noroom[] = "%s: No room for \"%s\" option"; -#define NEED(LEN, MSG) do \ - if (bytesleft < (LEN)) { \ - report(LOG_NOTICE, noroom, \ - hp->hostname->string, MSG); \ - return (vp - buf); \ - } while (0) - - /* - * Note that the following have already been inserted: - * magic_cookie, subnet_mask, gateway, bootsize - * - * The remaining options are inserted in order of importance. - * (Of course the importance of each is a matter of opinion.) - * The option insertion order should probably be configurable. - * - * This is the order used in the NetBSD version. Can anyone - * explain why the time_offset and swap_server are first? - * Also, why is the hostname so far down the list? -gwr - */ - - if (hp->flags.time_offset) { - NEED(6, "to"); - *vp++ = TAG_TIME_OFFSET;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(htonl(hp->time_offset), &vp); /* -4 bytes */ - bytesleft -= 6; - } - /* - * swap server, root path, dump path - */ - if (hp->flags.swap_server) { - NEED(6, "sw"); - /* There is just one SWAP_SERVER, so it is not an iplist. */ - *vp++ = TAG_SWAP_SERVER;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(hp->swap_server.s_addr, &vp); /* -4 bytes */ - bytesleft -= 6; /* Fix real count */ - } - if (hp->flags.root_path) { - /* - * Check for room for root_path. Add 2 to account for - * TAG_ROOT_PATH and length. - */ - len = strlen(hp->root_path->string); - NEED((len + 2), "rp"); - *vp++ = TAG_ROOT_PATH; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->root_path->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - if (hp->flags.dump_file) { - /* - * Check for room for dump_file. Add 2 to account for - * TAG_DUMP_FILE and length. - */ - len = strlen(hp->dump_file->string); - NEED((len + 2), "df"); - *vp++ = TAG_DUMP_FILE; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->dump_file->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * DNS server and domain - */ - if (hp->flags.domain_server) { - if (insert_ip(TAG_DOMAIN_SERVER, - hp->domain_server, - &vp, &bytesleft)) - NEED(8, "ds"); - } - if (hp->flags.domain_name) { - /* - * Check for room for domain_name. Add 2 to account for - * TAG_DOMAIN_NAME and length. - */ - len = strlen(hp->domain_name->string); - NEED((len + 2), "dn"); - *vp++ = TAG_DOMAIN_NAME; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->domain_name->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * NIS (YP) server and domain - */ - if (hp->flags.nis_server) { - if (insert_ip(TAG_NIS_SERVER, - hp->nis_server, - &vp, &bytesleft)) - NEED(8, "ds"); - } - if (hp->flags.nis_domain) { - /* - * Check for room for nis_domain. Add 2 to account for - * TAG_NIS_DOMAIN and length. - */ - len = strlen(hp->nis_domain->string); - NEED((len + 2), "dn"); - *vp++ = TAG_NIS_DOMAIN; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->nis_domain->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* IEN 116 name server */ - if (hp->flags.name_server) { - if (insert_ip(TAG_NAME_SERVER, - hp->name_server, - &vp, &bytesleft)) - NEED(8, "ns"); - } - if (hp->flags.rlp_server) { - if (insert_ip(TAG_RLP_SERVER, - hp->rlp_server, - &vp, &bytesleft)) - NEED(8, "rl"); - } - /* Time server (RFC 868) */ - if (hp->flags.time_server) { - if (insert_ip(TAG_TIME_SERVER, - hp->time_server, - &vp, &bytesleft)) - NEED(8, "ts"); - } - /* NTP (time) Server (RFC 1129) */ - if (hp->flags.ntp_server) { - if (insert_ip(TAG_NTP_SERVER, - hp->ntp_server, - &vp, &bytesleft)) - NEED(8, "ts"); - } - /* - * I wonder: If the hostname were "promoted" into the BOOTP - * response part, might these "extension" files possibly be - * shared between several clients? - * - * Also, why not just use longer BOOTP packets with all the - * additional length used as option data. This bootpd version - * already supports that feature by replying with the same - * packet length as the client request packet. -gwr - */ - if (hp->flags.name_switch && hp->flags.send_name) { - /* - * Check for room for hostname. Add 2 to account for - * TAG_HOST_NAME and length. - */ - len = strlen(hp->hostname->string); -#if 0 - /* - * XXX - Too much magic. The user can always set the hostname - * to the short version in the bootptab file. -gwr - */ - if ((len + 2) > bytesleft) { - /* - * Not enough room for full (domain-qualified) hostname, try - * stripping it down to just the first field (host). - */ - tmpstr = hp->hostname->string; - len = 0; - while (*tmpstr && (*tmpstr != '.')) { - tmpstr++; - len++; - } - } -#endif - NEED((len + 2), "hn"); - *vp++ = TAG_HOST_NAME; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->hostname->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * The rest of these are less important, so they go last. - */ - if (hp->flags.lpr_server) { - if (insert_ip(TAG_LPR_SERVER, - hp->lpr_server, - &vp, &bytesleft)) - NEED(8, "lp"); - } - if (hp->flags.cookie_server) { - if (insert_ip(TAG_COOKIE_SERVER, - hp->cookie_server, - &vp, &bytesleft)) - NEED(8, "cs"); - } - if (hp->flags.log_server) { - if (insert_ip(TAG_LOG_SERVER, - hp->log_server, - &vp, &bytesleft)) - NEED(8, "lg"); - } - /* - * XXX - Add new tags here (to insert options) - */ - if (hp->flags.generic) { - if (insert_generic(hp->generic, &vp, &bytesleft)) - NEED(64, "(generic)"); - } - /* - * The end marker is inserted by the caller. - */ - return (vp - buf); -#undef NEED -} /* dovend_rfc1497 */ - - - -/* - * Insert a tag value, a length value, and a list of IP addresses into the - * memory buffer indirectly pointed to by "dest". "tag" is the RFC1048 tag - * number to use, "iplist" is a pointer to a list of IP addresses - * (struct in_addr_list), and "bytesleft" points to an integer which - * indicates the size of the "dest" buffer. - * - * Return zero if everything fits. - * - * This is used to fill the vendor-specific area of a bootp packet in - * conformance to RFC1048. - */ - -int -insert_ip(tag, iplist, dest, bytesleft) - byte tag; - struct in_addr_list *iplist; - byte **dest; - int *bytesleft; -{ - struct in_addr *addrptr; - unsigned addrcount = 1; - byte *d; - - if (iplist == NULL) - return (0); - - if (*bytesleft >= 6) { - d = *dest; /* Save pointer for later */ - **dest = tag; - (*dest) += 2; - (*bytesleft) -= 2; /* Account for tag and length */ - addrptr = iplist->addr; - addrcount = iplist->addrcount; - while ((*bytesleft >= 4) && (addrcount > 0)) { - insert_u_long(addrptr->s_addr, dest); - addrptr++; - addrcount--; - (*bytesleft) -= 4; /* Four bytes per address */ - } - d[1] = (byte) ((*dest - d - 2) & 0xFF); - } - return (addrcount); -} - - - -/* - * Insert generic data into a bootp packet. The data is assumed to already - * be in RFC1048 format. It is inserted using a first-fit algorithm which - * attempts to insert as many tags as possible. Tags and data which are - * too large to fit are skipped; any remaining tags are tried until they - * have all been exhausted. - * Return zero if everything fits. - */ - -static int -insert_generic(gendata, buff, bytesleft) - struct shared_bindata *gendata; - byte **buff; - int *bytesleft; -{ - byte *srcptr; - int length, numbytes; - int skipped = 0; - - if (gendata == NULL) - return (0); - - srcptr = gendata->data; - length = gendata->length; - while ((length > 0) && (*bytesleft > 0)) { - switch (*srcptr) { - case TAG_END: - length = 0; /* Force an exit on next iteration */ - break; - case TAG_PAD: - *(*buff)++ = *srcptr++; - (*bytesleft)--; - length--; - break; - default: - numbytes = srcptr[1] + 2; - if (*bytesleft < numbytes) - skipped += numbytes; - else { - bcopy(srcptr, *buff, numbytes); - (*buff) += numbytes; - (*bytesleft) -= numbytes; - } - srcptr += numbytes; - length -= numbytes; - break; - } - } /* while */ - return (skipped); -} - -/* - * Insert the unsigned long "value" into memory starting at the byte - * pointed to by the byte pointer (*dest). (*dest) is updated to - * point to the next available byte. - * - * Since it is desirable to internally store network addresses in network - * byte order (in struct in_addr's), this routine expects longs to be - * passed in network byte order. - * - * However, due to the nature of the main algorithm, the long must be in - * host byte order, thus necessitating the use of ntohl() first. - */ - -void -insert_u_long(value, dest) - u_int32 value; - byte **dest; -{ - byte *temp; - int n; - - value = ntohl(value); /* Must use host byte order here */ - temp = (*dest += 4); - for (n = 4; n > 0; n--) { - *--temp = (byte) (value & 0xFF); - value >>= 8; - } - /* Final result is network byte order */ -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/dovend.h b/usr.sbin/bootpd/dovend.h deleted file mode 100644 index b30c982d8e23..000000000000 --- a/usr.sbin/bootpd/dovend.h +++ /dev/null @@ -1,13 +0,0 @@ -/* dovend.h */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern int dovend_rfc1497 P((struct host *hp, u_char *buf, int len)); -extern int insert_ip P((int, struct in_addr_list *, u_char **, int *)); -extern void insert_u_long P((u_int32, u_char **)); - -#undef P diff --git a/usr.sbin/bootpd/dumptab.c b/usr.sbin/bootpd/dumptab.c deleted file mode 100644 index 8c049b99deba..000000000000 --- a/usr.sbin/bootpd/dumptab.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * dumptab.c - handles dumping the database - */ - -#include -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "report.h" -#include "patchlevel.h" -#include "bootpd.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void dump_generic P((FILE *, struct shared_bindata *)); -static void dump_host P((FILE *, struct host *)); -static void list_ipaddresses P((FILE *, struct in_addr_list *)); - -#undef P - -#ifndef DEBUG -void -dumptab(filename) - char *filename; -{ - report(LOG_INFO, "No dumptab support!"); -} - -#else /* DEBUG */ - -/* - * Dump the internal memory database to bootpd_dump. - */ - -void -dumptab(filename) - char *filename; -{ - int n; - struct host *hp; - FILE *fp; - long t; - /* Print symbols in alphabetical order for reader's convenience. */ - static char legend[] = "#\n# Legend:\t(see bootptab.5)\n\ -#\tfirst field -- hostname (not indented)\n\ -#\tbf -- bootfile\n\ -#\tbs -- bootfile size in 512-octet blocks\n\ -#\tcs -- cookie servers\n\ -#\tdf -- dump file name\n\ -#\tdn -- domain name\n\ -#\tds -- domain name servers\n\ -#\tef -- extension file\n\ -#\tex -- exec file (YORK_EX_OPTION)\n\ -#\tgw -- gateways\n\ -#\tha -- hardware address\n\ -#\thd -- home directory for bootfiles\n\ -#\thn -- host name set for client\n\ -#\tht -- hardware type\n\ -#\tim -- impress servers\n\ -#\tip -- host IP address\n\ -#\tlg -- log servers\n\ -#\tlp -- LPR servers\n\ -#\tms -- message size\n\ -#\tmw -- min wait (secs)\n\ -#\tns -- IEN-116 name servers\n\ -#\tnt -- NTP servers (RFC 1129)\n\ -#\tra -- reply address override\n\ -#\trl -- resource location protocol servers\n\ -#\trp -- root path\n\ -#\tsa -- boot server address\n\ -#\tsm -- subnet mask\n\ -#\tsw -- swap server\n\ -#\ttc -- template host (points to similar host entry)\n\ -#\ttd -- TFTP directory\n\ -#\tto -- time offset (seconds)\n\ -#\tts -- time servers\n\ -#\tvm -- vendor magic number\n\ -#\tyd -- YP (NIS) domain\n\ -#\tys -- YP (NIS) servers\n\ -#\tTn -- generic option tag n\n\ -\n"; - - /* - * Open bootpd.dump file. - */ - if ((fp = fopen(filename, "w")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", - filename, get_errmsg()); - exit(1); - } - t = time(NULL); - fprintf(fp, "\n# %s %s.%d\n", progname, VERSION, PATCHLEVEL); - fprintf(fp, "# %s: dump of bootp server database.\n", filename); - fprintf(fp, "# Dump taken %s", ctime(&t)); - fwrite(legend, 1, sizeof(legend) - 1, fp); - - n = 0; - for (hp = (struct host *) hash_FirstEntry(nmhashtable); hp != NULL; - hp = (struct host *) hash_NextEntry(nmhashtable)) { - dump_host(fp, hp); - fprintf(fp, "\n"); - n++; - } - fclose(fp); - - report(LOG_INFO, "dumped %d entries to \"%s\".", n, filename); -} - - - -/* - * Dump all the available information on the host pointed to by "hp". - * The output is sent to the file pointed to by "fp". - */ - -static void -dump_host(fp, hp) - FILE *fp; - struct host *hp; -{ - /* Print symbols in alphabetical order for reader's convenience. */ - if (hp) { - fprintf(fp, "%s:", (hp->hostname ? - hp->hostname->string : "?")); - if (hp->flags.bootfile) { - fprintf(fp, "\\\n\t:bf=%s:", hp->bootfile->string); - } - if (hp->flags.bootsize) { - fprintf(fp, "\\\n\t:bs="); - if (hp->flags.bootsize_auto) { - fprintf(fp, "auto:"); - } else { - fprintf(fp, "%d:", hp->bootsize); - } - } - if (hp->flags.cookie_server) { - fprintf(fp, "\\\n\t:cs="); - list_ipaddresses(fp, hp->cookie_server); - fprintf(fp, ":"); - } - if (hp->flags.dump_file) { - fprintf(fp, "\\\n\t:df=%s:", hp->dump_file->string); - } - if (hp->flags.domain_name) { - fprintf(fp, "\\\n\t:dn=%s:", hp->domain_name->string); - } - if (hp->flags.domain_server) { - fprintf(fp, "\\\n\t:ds="); - list_ipaddresses(fp, hp->domain_server); - fprintf(fp, ":"); - } - if (hp->flags.exten_file) { - fprintf(fp, "\\\n\t:ef=%s:", hp->exten_file->string); - } - if (hp->flags.exec_file) { - fprintf(fp, "\\\n\t:ex=%s:", hp->exec_file->string); - } - if (hp->flags.gateway) { - fprintf(fp, "\\\n\t:gw="); - list_ipaddresses(fp, hp->gateway); - fprintf(fp, ":"); - } - /* FdC: swap_server (see below) */ - if (hp->flags.homedir) { - fprintf(fp, "\\\n\t:hd=%s:", hp->homedir->string); - } - /* FdC: dump_file (see above) */ - /* FdC: domain_name (see above) */ - /* FdC: root_path (see below) */ - if (hp->flags.name_switch && hp->flags.send_name) { - fprintf(fp, "\\\n\t:hn:"); - } - if (hp->flags.htype) { - int hlen = haddrlength(hp->htype); - fprintf(fp, "\\\n\t:ht=%u:", (unsigned) hp->htype); - if (hp->flags.haddr) { - fprintf(fp, "ha=\"%s\":", - haddrtoa(hp->haddr, hlen)); - } - } - if (hp->flags.impress_server) { - fprintf(fp, "\\\n\t:im="); - list_ipaddresses(fp, hp->impress_server); - fprintf(fp, ":"); - } - /* NetBSD: swap_server (see below) */ - if (hp->flags.iaddr) { - fprintf(fp, "\\\n\t:ip=%s:", inet_ntoa(hp->iaddr)); - } - if (hp->flags.log_server) { - fprintf(fp, "\\\n\t:lg="); - list_ipaddresses(fp, hp->log_server); - fprintf(fp, ":"); - } - if (hp->flags.lpr_server) { - fprintf(fp, "\\\n\t:lp="); - list_ipaddresses(fp, hp->lpr_server); - fprintf(fp, ":"); - } - if (hp->flags.msg_size) { - fprintf(fp, "\\\n\t:ms=%d:", hp->msg_size); - } - if (hp->flags.min_wait) { - fprintf(fp, "\\\n\t:mw=%d:", hp->min_wait); - } - if (hp->flags.name_server) { - fprintf(fp, "\\\n\t:ns="); - list_ipaddresses(fp, hp->name_server); - fprintf(fp, ":"); - } - if (hp->flags.ntp_server) { - fprintf(fp, "\\\n\t:nt="); - list_ipaddresses(fp, hp->ntp_server); - fprintf(fp, ":"); - } - if (hp->flags.reply_addr) { - fprintf(fp, "\\\n\t:ra=%s:", inet_ntoa(hp->reply_addr)); - } - if (hp->flags.rlp_server) { - fprintf(fp, "\\\n\t:rl="); - list_ipaddresses(fp, hp->rlp_server); - fprintf(fp, ":"); - } - if (hp->flags.root_path) { - fprintf(fp, "\\\n\t:rp=%s:", hp->root_path->string); - } - if (hp->flags.bootserver) { - fprintf(fp, "\\\n\t:sa=%s:", inet_ntoa(hp->bootserver)); - } - if (hp->flags.subnet_mask) { - fprintf(fp, "\\\n\t:sm=%s:", inet_ntoa(hp->subnet_mask)); - } - if (hp->flags.swap_server) { - fprintf(fp, "\\\n\t:sw=%s:", inet_ntoa(hp->subnet_mask)); - } - if (hp->flags.tftpdir) { - fprintf(fp, "\\\n\t:td=%s:", hp->tftpdir->string); - } - /* NetBSD: rootpath (see above) */ - /* NetBSD: domainname (see above) */ - /* NetBSD: dumpfile (see above) */ - if (hp->flags.time_offset) { - fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset); - } - if (hp->flags.time_server) { - fprintf(fp, "\\\n\t:ts="); - list_ipaddresses(fp, hp->time_server); - fprintf(fp, ":"); - } - if (hp->flags.vm_cookie) { - fprintf(fp, "\\\n\t:vm="); - if (!bcmp(hp->vm_cookie, vm_rfc1048, 4)) { - fprintf(fp, "rfc1048:"); - } else if (!bcmp(hp->vm_cookie, vm_cmu, 4)) { - fprintf(fp, "cmu:"); - } else { - fprintf(fp, "%d.%d.%d.%d:", - (int) ((hp->vm_cookie)[0]), - (int) ((hp->vm_cookie)[1]), - (int) ((hp->vm_cookie)[2]), - (int) ((hp->vm_cookie)[3])); - } - } - if (hp->flags.nis_domain) { - fprintf(fp, "\\\n\t:yd=%s:", - hp->nis_domain->string); - } - if (hp->flags.nis_server) { - fprintf(fp, "\\\n\t:ys="); - list_ipaddresses(fp, hp->nis_server); - fprintf(fp, ":"); - } - /* - * XXX - Add new tags here (or above, - * so they print in alphabetical order). - */ - - if (hp->flags.generic) { - dump_generic(fp, hp->generic); - } - } -} - - -static void -dump_generic(fp, generic) - FILE *fp; - struct shared_bindata *generic; -{ - u_char *bp = generic->data; - u_char *ep = bp + generic->length; - u_char tag; - int len; - - while (bp < ep) { - tag = *bp++; - if (tag == TAG_PAD) - continue; - if (tag == TAG_END) - return; - len = *bp++; - if (bp + len > ep) { - fprintf(fp, " #junk in generic! :"); - return; - } - fprintf(fp, "\\\n\t:T%d=", tag); - while (len) { - fprintf(fp, "%02X", *bp); - bp++; - len--; - if (len) - fprintf(fp, "."); - } - fprintf(fp, ":"); - } -} - - - -/* - * Dump an entire struct in_addr_list of IP addresses to the indicated file. - * - * The addresses are printed in standard ASCII "dot" notation and separated - * from one another by a single space. A single leading space is also - * printed before the first adddress. - * - * Null lists produce no output (and no error). - */ - -static void -list_ipaddresses(fp, ipptr) - FILE *fp; - struct in_addr_list *ipptr; -{ - unsigned count; - struct in_addr *addrptr; - - if (ipptr) { - count = ipptr->addrcount; - addrptr = ipptr->addr; - while (count > 0) { - fprintf(fp, "%s", inet_ntoa(*addrptr++)); - count--; - if (count) - fprintf(fp, ", "); - } - } -} - -#endif /* DEBUG */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/getif.c b/usr.sbin/bootpd/getif.c deleted file mode 100644 index 6cc16496ae46..000000000000 --- a/usr.sbin/bootpd/getif.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * getif.c : get an interface structure - */ - -#include -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif -#ifdef SVR4 -#include -#endif - -#include /* for struct ifreq */ -#include - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include - -#include "getif.h" -#include "report.h" - -#ifdef __bsdi__ -#define BSD 43 -#endif - -static struct ifreq ifreq[10]; /* Holds interface configuration */ -static struct ifconf ifconf; /* points to ifreq */ - -static int nmatch(); - -/* Return a pointer to the interface struct for the passed address. */ -struct ifreq * -getif(s, addrp) - int s; /* socket file descriptor */ - struct in_addr *addrp; /* destination address on interface */ -{ - int maxmatch; - int len, m, incr; - struct ifreq *ifrq, *ifrmax; - struct sockaddr_in *sip; - char *p; - - /* If no address was supplied, just return NULL. */ - if (!addrp) - return (struct ifreq *) 0; - - /* Get the interface config if not done already. */ - if (ifconf.ifc_len == 0) { -#ifdef SVR4 - /* - * SysVr4 returns garbage if you do this the obvious way! - * This one took a while to figure out... -gwr - */ - struct strioctl ioc; - ioc.ic_cmd = SIOCGIFCONF; - ioc.ic_timout = 0; - ioc.ic_len = sizeof(ifreq); - ioc.ic_dp = (char *) ifreq; - m = ioctl(s, I_STR, (char *) &ioc); - ifconf.ifc_len = ioc.ic_len; - ifconf.ifc_req = ifreq; -#else /* SVR4 */ - ifconf.ifc_len = sizeof(ifreq); - ifconf.ifc_req = ifreq; - m = ioctl(s, SIOCGIFCONF, (caddr_t) & ifconf); -#endif /* SVR4 */ - if ((m < 0) || (ifconf.ifc_len <= 0)) { - report(LOG_ERR, "ioctl SIOCGIFCONF"); - return (struct ifreq *) 0; - } - } - maxmatch = 7; /* this many bits or less... */ - ifrmax = (struct ifreq *) 0;/* ... is not a valid match */ - p = (char *) ifreq; - len = ifconf.ifc_len; - while (len > 0) { - ifrq = (struct ifreq *) p; - sip = (struct sockaddr_in *) &ifrq->ifr_addr; - m = nmatch(addrp, &(sip->sin_addr)); - if (m > maxmatch) { - maxmatch = m; - ifrmax = ifrq; - } - /* XXX - Could this be just #ifndef IFNAMSIZ instead? -gwr */ -#if (BSD - 0) < 43 - /* BSD not defined or earlier than 4.3 */ - incr = sizeof(*ifrq); -#else /* NetBSD */ - incr = ifrq->ifr_addr.sa_len + IFNAMSIZ; -#endif /* NetBSD */ - - p += incr; - len -= incr; - } - - return ifrmax; -} - -/* - * Return the number of leading bits matching in the - * internet addresses supplied. - */ -static int -nmatch(ca, cb) - u_char *ca, *cb; /* ptrs to IP address, network order */ -{ - u_int m = 0; /* count of matching bits */ - u_int n = 4; /* bytes left, then bitmask */ - - /* Count matching bytes. */ - while (n && (*ca == *cb)) { - ca++; - cb++; - m += 8; - n--; - } - /* Now count matching bits. */ - if (n) { - n = 0x80; - while (n && ((*ca & n) == (*cb & n))) { - m++; - n >>= 1; - } - } - return (m); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/getif.h b/usr.sbin/bootpd/getif.h deleted file mode 100644 index c51dafd2095a..000000000000 --- a/usr.sbin/bootpd/getif.h +++ /dev/null @@ -1,7 +0,0 @@ -/* getif.h */ - -#ifdef __STDC__ -extern struct ifreq *getif(int, struct in_addr *); -#else -extern struct ifreq *getif(); -#endif diff --git a/usr.sbin/bootpd/hash.c b/usr.sbin/bootpd/hash.c deleted file mode 100644 index c1d33bb85ec6..000000000000 --- a/usr.sbin/bootpd/hash.c +++ /dev/null @@ -1,425 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: hash.c,v 1.2 1994/08/22 22:14:58 gwr Exp $"; -#endif - - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee of the - * Information Technology Center at Carnegie Mellon. - */ - - -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "hash.h" - -#define TRUE 1 -#define FALSE 0 -#ifndef NULL -#define NULL 0 -#endif - -/* - * This can be changed to make internal routines visible to debuggers, etc. - */ -#ifndef PRIVATE -#define PRIVATE static -#endif - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -PRIVATE void hashi_FreeMembers P((hash_member *, hash_freefp)); - -#undef P - - - -/* - * Hash table initialization routine. - * - * This routine creates and intializes a hash table of size "tablesize" - * entries. Successful calls return a pointer to the hash table (which must - * be passed to other hash routines to identify the hash table). Failed - * calls return NULL. - */ - -hash_tbl * -hash_Init(tablesize) - unsigned tablesize; -{ - register hash_tbl *hashtblptr; - register unsigned totalsize; - - if (tablesize > 0) { - totalsize = sizeof(hash_tbl) - + sizeof(hash_member *) * (tablesize - 1); - hashtblptr = (hash_tbl *) malloc(totalsize); - if (hashtblptr) { - bzero((char *) hashtblptr, totalsize); - hashtblptr->size = tablesize; /* Success! */ - hashtblptr->bucketnum = 0; - hashtblptr->member = (hashtblptr->table)[0]; - } - } else { - hashtblptr = NULL; /* Disallow zero-length tables */ - } - return hashtblptr; /* NULL if failure */ -} - - - -/* - * Frees an entire linked list of bucket members (used in the open - * hashing scheme). Does nothing if the passed pointer is NULL. - */ - -PRIVATE void -hashi_FreeMembers(bucketptr, free_data) - hash_member *bucketptr; - hash_freefp free_data; -{ - hash_member *nextbucket; - while (bucketptr) { - nextbucket = bucketptr->next; - (*free_data) (bucketptr->data); - free((char *) bucketptr); - bucketptr = nextbucket; - } -} - - - - -/* - * This routine re-initializes the hash table. It frees all the allocated - * memory and resets all bucket pointers to NULL. - */ - -void -hash_Reset(hashtable, free_data) - hash_tbl *hashtable; - hash_freefp free_data; -{ - hash_member **bucketptr; - unsigned i; - - bucketptr = hashtable->table; - for (i = 0; i < hashtable->size; i++) { - hashi_FreeMembers(*bucketptr, free_data); - *bucketptr++ = NULL; - } - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; -} - - - -/* - * Generic hash function to calculate a hash code from the given string. - * - * For each byte of the string, this function left-shifts the value in an - * accumulator and then adds the byte into the accumulator. The contents of - * the accumulator is returned after the entire string has been processed. - * It is assumed that this result will be used as the "hashcode" parameter in - * calls to other functions in this package. These functions automatically - * adjust the hashcode for the size of each hashtable. - * - * This algorithm probably works best when the hash table size is a prime - * number. - * - * Hopefully, this function is better than the previous one which returned - * the sum of the squares of all the bytes. I'm still open to other - * suggestions for a default hash function. The programmer is more than - * welcome to supply his/her own hash function as that is one of the design - * features of this package. - */ - -unsigned -hash_HashFunction(string, len) - unsigned char *string; - register unsigned len; -{ - register unsigned accum; - - accum = 0; - for (; len > 0; len--) { - accum <<= 1; - accum += (unsigned) (*string++ & 0xFF); - } - return accum; -} - - - -/* - * Returns TRUE if at least one entry for the given key exists; FALSE - * otherwise. - */ - -int -hash_Exists(hashtable, hashcode, compare, key) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; -{ - register hash_member *memberptr; - - memberptr = (hashtable->table)[hashcode % (hashtable->size)]; - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - return TRUE; /* Entry does exist */ - } - memberptr = memberptr->next; - } - return FALSE; /* Entry does not exist */ -} - - - -/* - * Insert the data item "element" into the hash table using "hashcode" - * to determine the bucket number, and "compare" and "key" to determine - * its uniqueness. - * - * If the insertion is successful 0 is returned. If a matching entry - * already exists in the given bucket of the hash table, or some other error - * occurs, -1 is returned and the insertion is not done. - */ - -int -hash_Insert(hashtable, hashcode, compare, key, element) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key, *element; -{ - hash_member *temp; - - hashcode %= hashtable->size; - if (hash_Exists(hashtable, hashcode, compare, key)) { - return -1; /* At least one entry already exists */ - } - temp = (hash_member *) malloc(sizeof(hash_member)); - if (!temp) - return -1; /* malloc failed! */ - - temp->data = element; - temp->next = (hashtable->table)[hashcode]; - (hashtable->table)[hashcode] = temp; - return 0; /* Success */ -} - - - -/* - * Delete all data elements which match the given key. If at least one - * element is found and the deletion is successful, 0 is returned. - * If no matching elements can be found in the hash table, -1 is returned. - */ - -int -hash_Delete(hashtable, hashcode, compare, key, free_data) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; - hash_freefp free_data; -{ - hash_member *memberptr, *tempptr; - hash_member *previous = NULL; - int retval; - - retval = -1; - hashcode %= hashtable->size; - - /* - * Delete the first member of the list if it matches. Since this moves - * the second member into the first position we have to keep doing this - * over and over until it no longer matches. - */ - memberptr = (hashtable->table)[hashcode]; - while (memberptr && (*compare) (key, memberptr->data)) { - (hashtable->table)[hashcode] = memberptr->next; - /* - * Stop hashi_FreeMembers() from deleting the whole list! - */ - memberptr->next = NULL; - hashi_FreeMembers(memberptr, free_data); - memberptr = (hashtable->table)[hashcode]; - retval = 0; - } - - /* - * Now traverse the rest of the list - */ - if (memberptr) { - previous = memberptr; - memberptr = memberptr->next; - } - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - tempptr = memberptr; - previous->next = memberptr = memberptr->next; - /* - * Put the brakes on hashi_FreeMembers(). . . . - */ - tempptr->next = NULL; - hashi_FreeMembers(tempptr, free_data); - retval = 0; - } else { - previous = memberptr; - memberptr = memberptr->next; - } - } - return retval; -} - - - -/* - * Locate and return the data entry associated with the given key. - * - * If the data entry is found, a pointer to it is returned. Otherwise, - * NULL is returned. - */ - -hash_datum * -hash_Lookup(hashtable, hashcode, compare, key) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; -{ - hash_member *memberptr; - - memberptr = (hashtable->table)[hashcode % (hashtable->size)]; - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - return (memberptr->data); - } - memberptr = memberptr->next; - } - return NULL; -} - - - -/* - * Return the next available entry in the hashtable for a linear search - */ - -hash_datum * -hash_NextEntry(hashtable) - hash_tbl *hashtable; -{ - register unsigned bucket; - register hash_member *memberptr; - - /* - * First try to pick up where we left off. - */ - memberptr = hashtable->member; - if (memberptr) { - hashtable->member = memberptr->next; /* Set up for next call */ - return memberptr->data; /* Return the data */ - } - /* - * We hit the end of a chain, so look through the array of buckets - * until we find a new chain (non-empty bucket) or run out of buckets. - */ - bucket = hashtable->bucketnum + 1; - while ((bucket < hashtable->size) && - !(memberptr = (hashtable->table)[bucket])) { - bucket++; - } - - /* - * Check to see if we ran out of buckets. - */ - if (bucket >= hashtable->size) { - /* - * Reset to top of table for next call. - */ - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; - /* - * But return end-of-table indication to the caller this time. - */ - return NULL; - } - /* - * Must have found a non-empty bucket. - */ - hashtable->bucketnum = bucket; - hashtable->member = memberptr->next; /* Set up for next call */ - return memberptr->data; /* Return the data */ -} - - - -/* - * Return the first entry in a hash table for a linear search - */ - -hash_datum * -hash_FirstEntry(hashtable) - hash_tbl *hashtable; -{ - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; - return hash_NextEntry(hashtable); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/hash.h b/usr.sbin/bootpd/hash.h deleted file mode 100644 index 51d0a5ebd33b..000000000000 --- a/usr.sbin/bootpd/hash.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef HASH_H -#define HASH_H -/* hash.h */ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee. - */ - - -/* - * The user must supply the following: - * - * 1. A comparison function which is declared as: - * - * int compare(data1, data2) - * hash_datum *data1, *data2; - * - * This function must compare the desired fields of data1 and - * data2 and return TRUE (1) if the data should be considered - * equivalent (i.e. have the same key value) or FALSE (0) - * otherwise. This function is called through a pointer passed to - * the various hashtable functions (thus pointers to different - * functions may be passed to effect different tests on different - * hash tables). - * - * Internally, all the functions of this package always call the - * compare function with the "key" parameter as the first parameter, - * and a full data element as the second parameter. Thus, the key - * and element arguments to functions such as hash_Lookup() may - * actually be of different types and the programmer may provide a - * compare function which compares the two different object types - * as desired. - * - * Example: - * - * int compare(key, element) - * char *key; - * struct some_complex_structure *element; - * { - * return !strcmp(key, element->name); - * } - * - * key = "John C. Doe" - * element = &some_complex_structure - * hash_Lookup(table, hashcode, compare, key); - * - * 2. A hash function yielding an unsigned integer value to be used - * as the hashcode (index into the hashtable). Thus, the user - * may hash on whatever data is desired and may use several - * different hash functions for various different hash tables. - * The actual hash table index will be the passed hashcode modulo - * the hash table size. - * - * A generalized hash function, hash_HashFunction(), is included - * with this package to make things a little easier. It is not - * guarenteed to use the best hash algorithm in existence. . . . - */ - - - -/* - * Various hash table definitions - */ - - -/* - * Define "hash_datum" as a universal data type - */ -#ifdef __STDC__ -typedef void hash_datum; -#else -typedef char hash_datum; -#endif - -typedef struct hash_memberstruct hash_member; -typedef struct hash_tblstruct hash_tbl; -typedef struct hash_tblstruct_hdr hash_tblhdr; - -struct hash_memberstruct { - hash_member *next; - hash_datum *data; -}; - -struct hash_tblstruct_hdr { - unsigned size, bucketnum; - hash_member *member; -}; - -struct hash_tblstruct { - unsigned size, bucketnum; - hash_member *member; /* Used for linear dump */ - hash_member *table[1]; /* Dynamically extended */ -}; - -/* ANSI function prototypes or empty arg list? */ -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -typedef int (*hash_cmpfp) P((hash_datum *, hash_datum *)); -typedef void (*hash_freefp) P((hash_datum *)); - -extern hash_tbl *hash_Init P((u_int tablesize)); - -extern void hash_Reset P((hash_tbl *tbl, hash_freefp)); - -extern unsigned hash_HashFunction P((u_char *str, u_int len)); - -extern int hash_Exists P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key)); - -extern int hash_Insert P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key, - hash_datum *element)); - -extern int hash_Delete P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key, - hash_freefp)); - -extern hash_datum *hash_Lookup P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key)); - -extern hash_datum *hash_FirstEntry P((hash_tbl *)); - -extern hash_datum *hash_NextEntry P((hash_tbl *)); - -#undef P - -#endif /* HASH_H */ diff --git a/usr.sbin/bootpd/hwaddr.h b/usr.sbin/bootpd/hwaddr.h deleted file mode 100644 index dea7158be8c7..000000000000 --- a/usr.sbin/bootpd/hwaddr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* hwaddr.h */ -#ifndef HWADDR_H -#define HWADDR_H - -#define MAXHADDRLEN 8 /* Max hw address length in bytes */ - -/* - * This structure holds information about a specific network type. The - * length of the network hardware address is stored in "hlen". - * The string pointed to by "name" is the cononical name of the network. - */ -struct hwinfo { - unsigned int hlen; - char *name; -}; - -extern struct hwinfo hwinfolist[]; -extern int hwinfocnt; - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void setarp P((int, struct in_addr *, u_char *, int)); -extern char *haddrtoa P((u_char *, int)); -extern void haddr_conv802 P((u_char *, u_char *, int)); - -#undef P - -/* - * Return the length in bytes of a hardware address of the given type. - * Return the canonical name of the network of the given type. - */ -#define haddrlength(type) ((hwinfolist[(int) (type)]).hlen) -#define netname(type) ((hwinfolist[(int) (type)]).name) - -#endif /* HWADDR_H */ diff --git a/usr.sbin/bootpd/lookup.c b/usr.sbin/bootpd/lookup.c deleted file mode 100644 index 2a30a59b2c39..000000000000 --- a/usr.sbin/bootpd/lookup.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * lookup.c - Lookup IP address, HW address, netmask - */ - -#include -#include - -#include -#include - -#ifdef ETC_ETHERS -#include -extern int ether_hostton(); -#endif - -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#endif - -#include "bootp.h" -#include "lookup.h" -#include "report.h" - -/* - * Lookup an Ethernet address and return it. - * Return NULL if addr not found. - */ -u_char * -lookup_hwa(hostname, htype) - char *hostname; - int htype; -{ - switch (htype) { - - /* XXX - How is this done on other systems? -gwr */ -#ifdef ETC_ETHERS - case HTYPE_ETHERNET: - case HTYPE_IEEE802: - { - static struct ether_addr ea; - /* This does a lookup in /etc/ethers */ - if (ether_hostton(hostname, &ea)) { - report(LOG_ERR, "no HW addr for host \"%s\"", - hostname); - return (u_char *) 0; - } - return (u_char *) & ea; - } -#endif /* ETC_ETHERS */ - - default: - report(LOG_ERR, "no lookup for HW addr type %d", htype); - } /* switch */ - - /* If the system can't do it, just return an error. */ - return (u_char *) 0; -} - - -/* - * Lookup an IP address. - * Return non-zero on failure. - */ -int -lookup_ipa(hostname, result) - char *hostname; - u_int32 *result; -{ - struct hostent *hp; - hp = gethostbyname(hostname); - if (!hp) - return -1; - bcopy(hp->h_addr, result, sizeof(*result)); - return 0; -} - - -/* - * Lookup a netmask - * Return non-zero on failure. - * - * XXX - This is OK as a default, but to really make this automatic, - * we would need to get the subnet mask from the ether interface. - * If this is wrong, specify the correct value in the bootptab. - */ -int -lookup_netmask(addr, result) - u_int32 addr; /* both in network order */ - u_int32 *result; -{ - int32 m, a; - - a = ntohl(addr); - m = 0; - - if (IN_CLASSA(a)) - m = IN_CLASSA_NET; - - if (IN_CLASSB(a)) - m = IN_CLASSB_NET; - - if (IN_CLASSC(a)) - m = IN_CLASSC_NET; - - if (!m) - return -1; - *result = htonl(m); - return 0; -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/lookup.h b/usr.sbin/bootpd/lookup.h deleted file mode 100644 index 04805d8915c6..000000000000 --- a/usr.sbin/bootpd/lookup.h +++ /dev/null @@ -1,15 +0,0 @@ -/* lookup.h */ - -#include "bptypes.h" /* for int32, u_int32 */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern u_char *lookup_hwa P((char *hostname, int htype)); -extern int lookup_ipa P((char *hostname, u_int32 *addr)); -extern int lookup_netmask P((u_int32 addr, u_int32 *mask)); - -#undef P diff --git a/usr.sbin/bootpd/patchlevel.h b/usr.sbin/bootpd/patchlevel.h deleted file mode 100644 index 782959e3c750..000000000000 --- a/usr.sbin/bootpd/patchlevel.h +++ /dev/null @@ -1,3 +0,0 @@ -/* patchlevel.h */ -#define VERSION "2.4" -#define PATCHLEVEL 1 diff --git a/usr.sbin/bootpd/print-bootp.c b/usr.sbin/bootpd/print-bootp.c deleted file mode 100644 index 1919e7f88660..000000000000 --- a/usr.sbin/bootpd/print-bootp.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Format and print bootp packets. - * - * This file was copied from tcpdump-2.1.1 and modified. - * There is an e-mail list for tcpdump: - */ -#ifndef lint -static char rcsid[] = "$Id: print-bootp.c,v 1.2 1994/08/22 22:15:01 gwr Exp $"; -/* 93/10/10 New data-driven option print routine. */ -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "bootp.h" -#include "bootptest.h" - -/* These decode the vendor data. */ -static void rfc1048_print(); -static void cmu_print(); -static void other_print(); -static void dump_hex(); - -/* - * Print bootp requests - */ -void -bootp_print(bp, length, sport, dport) - struct bootp *bp; - int length; - u_short sport, dport; -{ - static char tstr[] = " [|bootp]"; - static unsigned char vm_cmu[4] = VM_CMU; - static unsigned char vm_rfc1048[4] = VM_RFC1048; - u_char *ep; - int vdlen; - -#define TCHECK(var, l) if ((u_char *)&(var) > ep - l) goto trunc - - /* Note funny sized packets */ - if (length != sizeof(struct bootp)) - (void) printf(" [len=%d]", length); - - /* 'ep' points to the end of avaible data. */ - ep = (u_char *) snapend; - - switch (bp->bp_op) { - - case BOOTREQUEST: - /* Usually, a request goes from a client to a server */ - if (sport != IPPORT_BOOTPC || dport != IPPORT_BOOTPS) - printf(" (request)"); - break; - - case BOOTREPLY: - /* Usually, a reply goes from a server to a client */ - if (sport != IPPORT_BOOTPS || dport != IPPORT_BOOTPC) - printf(" (reply)"); - break; - - default: - printf(" bootp-#%d", bp->bp_op); - } - - /* The usual hardware address type is 1 (10Mb Ethernet) */ - if (bp->bp_htype != 1) - printf(" htype:%d", bp->bp_htype); - - /* The usual length for 10Mb Ethernet address is 6 bytes */ - if (bp->bp_hlen != 6) - printf(" hlen:%d", bp->bp_hlen); - - /* Client's Hardware address */ - if (bp->bp_hlen) { - register struct ether_header *eh; - register char *e; - - TCHECK(bp->bp_chaddr[0], 6); - eh = (struct ether_header *) packetp; - if (bp->bp_op == BOOTREQUEST) - e = (char *) ESRC(eh); - else if (bp->bp_op == BOOTREPLY) - e = (char *) EDST(eh); - else - e = 0; - if (e == 0 || bcmp((char *) bp->bp_chaddr, e, 6)) - dump_hex(bp->bp_chaddr, bp->bp_hlen); - } - /* Only print interesting fields */ - if (bp->bp_hops) - printf(" hops:%d", bp->bp_hops); - - if (bp->bp_xid) - printf(" xid:%d", ntohl(bp->bp_xid)); - - if (bp->bp_secs) - printf(" secs:%d", ntohs(bp->bp_secs)); - - /* Client's ip address */ - TCHECK(bp->bp_ciaddr, sizeof(bp->bp_ciaddr)); - if (bp->bp_ciaddr.s_addr) - printf(" C:%s", ipaddr_string(&bp->bp_ciaddr)); - - /* 'your' ip address (bootp client) */ - TCHECK(bp->bp_yiaddr, sizeof(bp->bp_yiaddr)); - if (bp->bp_yiaddr.s_addr) - printf(" Y:%s", ipaddr_string(&bp->bp_yiaddr)); - - /* Server's ip address */ - TCHECK(bp->bp_siaddr, sizeof(bp->bp_siaddr)); - if (bp->bp_siaddr.s_addr) - printf(" S:%s", ipaddr_string(&bp->bp_siaddr)); - - /* Gateway's ip address */ - TCHECK(bp->bp_giaddr, sizeof(bp->bp_giaddr)); - if (bp->bp_giaddr.s_addr) - printf(" G:%s", ipaddr_string(&bp->bp_giaddr)); - - TCHECK(bp->bp_sname[0], sizeof(bp->bp_sname)); - if (*bp->bp_sname) { - printf(" sname:"); - if (printfn(bp->bp_sname, ep)) { - fputs(tstr + 1, stdout); - return; - } - } - TCHECK(bp->bp_file[0], sizeof(bp->bp_file)); - if (*bp->bp_file) { - printf(" file:"); - if (printfn(bp->bp_file, ep)) { - fputs(tstr + 1, stdout); - return; - } - } - /* Don't try to decode the vendor buffer unless we're verbose */ - if (vflag <= 0) - return; - - vdlen = sizeof(bp->bp_vend); - /* Vendor data can extend to the end of the packet. */ - if (vdlen < (ep - bp->bp_vend)) - vdlen = (ep - bp->bp_vend); - - TCHECK(bp->bp_vend[0], vdlen); - printf(" vend"); - if (!bcmp(bp->bp_vend, vm_rfc1048, sizeof(u_int32))) - rfc1048_print(bp->bp_vend, vdlen); - else if (!bcmp(bp->bp_vend, vm_cmu, sizeof(u_int32))) - cmu_print(bp->bp_vend, vdlen); - else - other_print(bp->bp_vend, vdlen); - - return; - trunc: - fputs(tstr, stdout); -#undef TCHECK -} - -/* - * Option description data follows. - * These are decribed in: RFC-1048, RFC-1395, RFC-1497, RFC-1533 - * - * The first char of each option string encodes the data format: - * ?: unknown - * a: ASCII - * b: byte (8-bit) - * i: inet address - * l: int32 - * s: short (16-bit) - */ -char * -rfc1048_opts[] = { - /* Originally from RFC-1048: */ - "?PAD", /* 0: Padding - special, no data. */ - "iSM", /* 1: subnet mask (RFC950)*/ - "lTZ", /* 2: time offset, seconds from UTC */ - "iGW", /* 3: gateways (or routers) */ - "iTS", /* 4: time servers (RFC868) */ - "iINS", /* 5: IEN name servers (IEN116) */ - "iDNS", /* 6: domain name servers (RFC1035)(1034?) */ - "iLOG", /* 7: MIT log servers */ - "iCS", /* 8: cookie servers (RFC865) */ - "iLPR", /* 9: lpr server (RFC1179) */ - "iIPS", /* 10: impress servers (Imagen) */ - "iRLP", /* 11: resource location servers (RFC887) */ - "aHN", /* 12: host name (ASCII) */ - "sBFS", /* 13: boot file size (in 512 byte blocks) */ - - /* Added by RFC-1395: */ - "aDUMP", /* 14: Merit Dump File */ - "aDNAM", /* 15: Domain Name (for DNS) */ - "iSWAP", /* 16: Swap Server */ - "aROOT", /* 17: Root Path */ - - /* Added by RFC-1497: */ - "aEXTF", /* 18: Extensions Path (more options) */ - - /* Added by RFC-1533: (many, many options...) */ -#if 1 /* These might not be worth recognizing by name. */ - - /* IP Layer Parameters, per-host (RFC-1533, sect. 4) */ - "bIP-forward", /* 19: IP Forwarding flag */ - "bIP-srcroute", /* 20: IP Source Routing Enable flag */ - "iIP-filters", /* 21: IP Policy Filter (addr pairs) */ - "sIP-maxudp", /* 22: IP Max-UDP reassembly size */ - "bIP-ttlive", /* 23: IP Time to Live */ - "lIP-pmtuage", /* 24: IP Path MTU aging timeout */ - "sIP-pmtutab", /* 25: IP Path MTU plateau table */ - - /* IP parameters, per-interface (RFC-1533, sect. 5) */ - "sIP-mtu-sz", /* 26: IP MTU size */ - "bIP-mtu-sl", /* 27: IP MTU all subnets local */ - "bIP-bcast1", /* 28: IP Broadcast Addr ones flag */ - "bIP-mask-d", /* 29: IP do mask discovery */ - "bIP-mask-s", /* 30: IP do mask supplier */ - "bIP-rt-dsc", /* 31: IP do router discovery */ - "iIP-rt-sa", /* 32: IP router solicitation addr */ - "iIP-routes", /* 33: IP static routes (dst,router) */ - - /* Link Layer parameters, per-interface (RFC-1533, sect. 6) */ - "bLL-trailer", /* 34: do tralier encapsulation */ - "lLL-arp-tmo", /* 35: ARP cache timeout */ - "bLL-ether2", /* 36: Ethernet version 2 (IEEE 802.3) */ - - /* TCP parameters (RFC-1533, sect. 7) */ - "bTCP-def-ttl", /* 37: default time to live */ - "lTCP-KA-tmo", /* 38: keepalive time interval */ - "bTCP-KA-junk", /* 39: keepalive sends extra junk */ - - /* Application and Service Parameters (RFC-1533, sect. 8) */ - "aNISDOM", /* 40: NIS Domain (Sun YP) */ - "iNISSRV", /* 41: NIS Servers */ - "iNTPSRV", /* 42: NTP (time) Servers (RFC 1129) */ - "?VSINFO", /* 43: Vendor Specific Info (encapsulated) */ - "iNBiosNS", /* 44: NetBIOS Name Server (RFC-1001,1..2) */ - "iNBiosDD", /* 45: NetBIOS Datagram Dist. Server. */ - "bNBiosNT", /* 46: NetBIOS Note Type */ - "?NBiosS", /* 47: NetBIOS Scope */ - "iXW-FS", /* 48: X Window System Font Servers */ - "iXW-DM", /* 49: X Window System Display Managers */ - - /* DHCP extensions (RFC-1533, sect. 9) */ -#endif -}; -#define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0])) - -static void print_string(); - -static void -rfc1048_print(bp, length) - register u_char *bp; - int length; -{ - u_char tag; - u_char *ep; - register int len, j; - u_int32 ul; - u_short us; - struct in_addr ia; - char *optstr; - - printf("-rfc1395"); - - /* Step over magic cookie */ - bp += sizeof(int32); - /* Setup end pointer */ - ep = bp + length; - while (bp < ep) { - tag = *bp++; - /* Check for tags with no data first. */ - if (tag == TAG_PAD) - continue; - if (tag == TAG_END) - return; - if (tag < KNOWN_OPTIONS) { - optstr = rfc1048_opts[tag]; - printf(" %s:", optstr + 1); - } else { - printf(" T%d:", tag); - optstr = "?"; - } - /* Now scan the length byte. */ - len = *bp++; - if (bp + len > ep) { - /* truncated option */ - printf(" |(%d>%d)", len, ep - bp); - return; - } - /* Print the option value(s). */ - switch (optstr[0]) { - - case 'a': /* ASCII string */ - printfn(bp, bp + len); - bp += len; - len = 0; - break; - - case 's': /* Word formats */ - while (len >= 2) { - bcopy((char *) bp, (char *) &us, 2); - printf("%d", ntohs(us)); - bp += 2; - len -= 2; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'l': /* Long words */ - while (len >= 4) { - bcopy((char *) bp, (char *) &ul, 4); - printf("%d", ntohl(ul)); - bp += 4; - len -= 4; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'i': /* INET addresses */ - while (len >= 4) { - bcopy((char *) bp, (char *) &ia, 4); - printf("%s", ipaddr_string(&ia)); - bp += 4; - len -= 4; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'b': - default: - break; - - } /* switch */ - - /* Print as characters, if appropriate. */ - if (len) { - dump_hex(bp, len); - if (isascii(*bp) && isprint(*bp)) { - printf("("); - printfn(bp, bp + len); - printf(")"); - } - bp += len; - len = 0; - } - } /* while bp < ep */ -} - -static void -cmu_print(bp, length) - register u_char *bp; - int length; -{ - struct cmu_vend *v; - u_char *ep; - - printf("-cmu"); - - v = (struct cmu_vend *) bp; - if (length < sizeof(*v)) { - printf(" |L=%d", length); - return; - } - /* Setup end pointer */ - ep = bp + length; - - /* Subnet mask */ - if (v->v_flags & VF_SMASK) { - printf(" SM:%s", ipaddr_string(&v->v_smask)); - } - /* Default gateway */ - if (v->v_dgate.s_addr) - printf(" GW:%s", ipaddr_string(&v->v_dgate)); - - /* Domain name servers */ - if (v->v_dns1.s_addr) - printf(" DNS1:%s", ipaddr_string(&v->v_dns1)); - if (v->v_dns2.s_addr) - printf(" DNS2:%s", ipaddr_string(&v->v_dns2)); - - /* IEN-116 name servers */ - if (v->v_ins1.s_addr) - printf(" INS1:%s", ipaddr_string(&v->v_ins1)); - if (v->v_ins2.s_addr) - printf(" INS2:%s", ipaddr_string(&v->v_ins2)); - - /* Time servers */ - if (v->v_ts1.s_addr) - printf(" TS1:%s", ipaddr_string(&v->v_ts1)); - if (v->v_ts2.s_addr) - printf(" TS2:%s", ipaddr_string(&v->v_ts2)); - -} - - -/* - * Print out arbitrary, unknown vendor data. - */ - -static void -other_print(bp, length) - register u_char *bp; - int length; -{ - u_char *ep; /* end pointer */ - u_char *zp; /* points one past last non-zero byte */ - register int i, j; - - /* Setup end pointer */ - ep = bp + length; - - /* Find the last non-zero byte. */ - for (zp = ep; zp > bp; zp--) { - if (zp[-1] != 0) - break; - } - - /* Print the all-zero case in a compact representation. */ - if (zp == bp) { - printf("-all-zero"); - return; - } - printf("-unknown"); - - /* Are there enough trailing zeros to make "00..." worthwhile? */ - if (zp + 2 > ep) - zp = ep; /* print them all normally */ - - /* Now just print all the non-zero data. */ - while (bp < zp) { - printf(".%02X", *bp); - bp++; - } - - if (zp < ep) - printf(".00..."); - - return; -} - -static void -dump_hex(bp, len) - u_char *bp; - int len; -{ - while (len > 0) { - printf("%02X", *bp); - bp++; - len--; - if (len) printf("."); - } -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/readfile.c b/usr.sbin/bootpd/readfile.c deleted file mode 100644 index 1f70b453c07a..000000000000 --- a/usr.sbin/bootpd/readfile.c +++ /dev/null @@ -1,2097 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: readfile.c,v 1.2 1994/08/22 22:15:04 gwr Exp $"; -#endif - - -/* - * bootpd configuration file reading code. - * - * The routines in this file deal with reading, interpreting, and storing - * the information found in the bootpd configuration file (usually - * /etc/bootptab). - */ - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "lookup.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "bootpd.h" - -#define HASHTABLESIZE 257 /* Hash table size (prime) */ - -/* Non-standard hardware address type (see bootp.h) */ -#define HTYPE_DIRECT 0 - -/* Error codes returned by eval_symbol: */ -#define SUCCESS 0 -#define E_END_OF_ENTRY (-1) -#define E_SYNTAX_ERROR (-2) -#define E_UNKNOWN_SYMBOL (-3) -#define E_BAD_IPADDR (-4) -#define E_BAD_HWADDR (-5) -#define E_BAD_LONGWORD (-6) -#define E_BAD_HWATYPE (-7) -#define E_BAD_PATHNAME (-8) -#define E_BAD_VALUE (-9) - -/* Tag idendities. */ -#define SYM_NULL 0 -#define SYM_BOOTFILE 1 -#define SYM_COOKIE_SERVER 2 -#define SYM_DOMAIN_SERVER 3 -#define SYM_GATEWAY 4 -#define SYM_HWADDR 5 -#define SYM_HOMEDIR 6 -#define SYM_HTYPE 7 -#define SYM_IMPRESS_SERVER 8 -#define SYM_IPADDR 9 -#define SYM_LOG_SERVER 10 -#define SYM_LPR_SERVER 11 -#define SYM_NAME_SERVER 12 -#define SYM_RLP_SERVER 13 -#define SYM_SUBNET_MASK 14 -#define SYM_TIME_OFFSET 15 -#define SYM_TIME_SERVER 16 -#define SYM_VENDOR_MAGIC 17 -#define SYM_SIMILAR_ENTRY 18 -#define SYM_NAME_SWITCH 19 -#define SYM_BOOTSIZE 20 -#define SYM_BOOT_SERVER 22 -#define SYM_TFTPDIR 23 -#define SYM_DUMP_FILE 24 -#define SYM_DOMAIN_NAME 25 -#define SYM_SWAP_SERVER 26 -#define SYM_ROOT_PATH 27 -#define SYM_EXTEN_FILE 28 -#define SYM_REPLY_ADDR 29 -#define SYM_NIS_DOMAIN 30 /* RFC 1533 */ -#define SYM_NIS_SERVER 31 /* RFC 1533 */ -#define SYM_NTP_SERVER 32 /* RFC 1533 */ -#define SYM_EXEC_FILE 33 /* YORK_EX_OPTION */ -#define SYM_MSG_SIZE 34 -#define SYM_MIN_WAIT 35 -/* XXX - Add new tags here */ - -#define OP_ADDITION 1 /* Operations on tags */ -#define OP_DELETION 2 -#define OP_BOOLEAN 3 - -#define MAXINADDRS 16 /* Max size of an IP address list */ -#define MAXBUFLEN 256 /* Max temp buffer space */ -#define MAXENTRYLEN 2048 /* Max size of an entire entry */ - - - -/* - * Structure used to map a configuration-file symbol (such as "ds") to a - * unique integer. - */ - -struct symbolmap { - char *symbol; - int symbolcode; -}; - - -struct htypename { - char *name; - byte htype; -}; - - -PRIVATE int nhosts; /* Number of hosts (/w hw or IP address) */ -PRIVATE int nentries; /* Total number of entries */ -PRIVATE int32 modtime = 0; /* Last modification time of bootptab */ -PRIVATE char *current_hostname; /* Name of the current entry. */ -PRIVATE char current_tagname[8]; - -/* - * List of symbolic names used in the bootptab file. The order and actual - * values of the symbol codes (SYM_. . .) are unimportant, but they must - * all be unique. - */ - -PRIVATE struct symbolmap symbol_list[] = { - {"bf", SYM_BOOTFILE}, - {"bs", SYM_BOOTSIZE}, - {"cs", SYM_COOKIE_SERVER}, - {"df", SYM_DUMP_FILE}, - {"dn", SYM_DOMAIN_NAME}, - {"ds", SYM_DOMAIN_SERVER}, - {"ef", SYM_EXTEN_FILE}, - {"ex", SYM_EXEC_FILE}, /* YORK_EX_OPTION */ - {"gw", SYM_GATEWAY}, - {"ha", SYM_HWADDR}, - {"hd", SYM_HOMEDIR}, - {"hn", SYM_NAME_SWITCH}, - {"ht", SYM_HTYPE}, - {"im", SYM_IMPRESS_SERVER}, - {"ip", SYM_IPADDR}, - {"lg", SYM_LOG_SERVER}, - {"lp", SYM_LPR_SERVER}, - {"ms", SYM_MSG_SIZE}, - {"mw", SYM_MIN_WAIT}, - {"ns", SYM_NAME_SERVER}, - {"nt", SYM_NTP_SERVER}, - {"ra", SYM_REPLY_ADDR}, - {"rl", SYM_RLP_SERVER}, - {"rp", SYM_ROOT_PATH}, - {"sa", SYM_BOOT_SERVER}, - {"sm", SYM_SUBNET_MASK}, - {"sw", SYM_SWAP_SERVER}, - {"tc", SYM_SIMILAR_ENTRY}, - {"td", SYM_TFTPDIR}, - {"to", SYM_TIME_OFFSET}, - {"ts", SYM_TIME_SERVER}, - {"vm", SYM_VENDOR_MAGIC}, - {"yd", SYM_NIS_DOMAIN}, - {"ys", SYM_NIS_SERVER}, - /* XXX - Add new tags here */ -}; - - -/* - * List of symbolic names for hardware types. Name translates into - * hardware type code listed with it. Names must begin with a letter - * and must be all lowercase. This is searched linearly, so put - * commonly-used entries near the beginning. - */ - -PRIVATE struct htypename htnamemap[] = { - {"ethernet", HTYPE_ETHERNET}, - {"ethernet3", HTYPE_EXP_ETHERNET}, - {"ether", HTYPE_ETHERNET}, - {"ether3", HTYPE_EXP_ETHERNET}, - {"ieee802", HTYPE_IEEE802}, - {"tr", HTYPE_IEEE802}, - {"token-ring", HTYPE_IEEE802}, - {"pronet", HTYPE_PRONET}, - {"chaos", HTYPE_CHAOS}, - {"arcnet", HTYPE_ARCNET}, - {"ax.25", HTYPE_AX25}, - {"direct", HTYPE_DIRECT}, - {"serial", HTYPE_DIRECT}, - {"slip", HTYPE_DIRECT}, - {"ppp", HTYPE_DIRECT} -}; - - - -/* - * Externals and forward declarations. - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern boolean iplookcmp(); -boolean nmcmp P((hash_datum *, hash_datum *)); - -PRIVATE void - adjust P((char **)); -PRIVATE void - del_string P((struct shared_string *)); -PRIVATE void - del_bindata P((struct shared_bindata *)); -PRIVATE void - del_iplist P((struct in_addr_list *)); -PRIVATE void - eat_whitespace P((char **)); -PRIVATE int - eval_symbol P((char **, struct host *)); -PRIVATE void - fill_defaults P((struct host *, char **)); -PRIVATE void - free_host P((hash_datum *)); -PRIVATE struct in_addr_list * - get_addresses P((char **)); -PRIVATE struct shared_string * - get_shared_string P((char **)); -PRIVATE char * - get_string P((char **, char *, u_int *)); -PRIVATE u_int32 - get_u_long P((char **)); -PRIVATE boolean - goodname P((char *)); -PRIVATE boolean - hwinscmp P((hash_datum *, hash_datum *)); -PRIVATE int - interp_byte P((char **, byte *)); -PRIVATE void - makelower P((char *)); -PRIVATE boolean - nullcmp P((hash_datum *, hash_datum *)); -PRIVATE int - process_entry P((struct host *, char *)); -PRIVATE int - process_generic P((char **, struct shared_bindata **, u_int)); -PRIVATE byte * - prs_haddr P((char **, u_int)); -PRIVATE int - prs_inetaddr P((char **, u_int32 *)); -PRIVATE void - read_entry P((FILE *, char *, u_int *)); -PRIVATE char * - smalloc P((u_int)); - -#undef P - - -/* - * Vendor magic cookies for CMU and RFC1048 - */ -u_char vm_cmu[4] = VM_CMU; -u_char vm_rfc1048[4] = VM_RFC1048; - -/* - * Main hash tables - */ -hash_tbl *hwhashtable; -hash_tbl *iphashtable; -hash_tbl *nmhashtable; - -/* - * Allocate hash tables for hardware address, ip address, and hostname - * (shared by bootpd and bootpef) - */ -void -rdtab_init() -{ - hwhashtable = hash_Init(HASHTABLESIZE); - iphashtable = hash_Init(HASHTABLESIZE); - nmhashtable = hash_Init(HASHTABLESIZE); - if (!(hwhashtable && iphashtable && nmhashtable)) { - report(LOG_ERR, "Unable to allocate hash tables."); - exit(1); - } -} - - -/* - * Read bootptab database file. Avoid rereading the file if the - * write date hasn't changed since the last time we read it. - */ - -void -readtab(force) - int force; -{ - struct host *hp; - FILE *fp; - struct stat st; - unsigned hashcode, buflen; - static char buffer[MAXENTRYLEN]; - - /* - * Check the last modification time. - */ - if (stat(bootptab, &st) < 0) { - report(LOG_ERR, "stat on \"%s\": %s", - bootptab, get_errmsg()); - return; - } -#ifdef DEBUG - if (debug > 3) { - char timestr[28]; - strcpy(timestr, ctime(&(st.st_mtime))); - /* zap the newline */ - timestr[24] = '\0'; - report(LOG_INFO, "bootptab mtime: %s", - timestr); - } -#endif - if ((force == 0) && - (st.st_mtime == modtime) && - st.st_nlink) { - /* - * hasn't been modified or deleted yet. - */ - return; - } - if (debug) - report(LOG_INFO, "reading %s\"%s\"", - (modtime != 0L) ? "new " : "", - bootptab); - - /* - * Open bootptab file. - */ - if ((fp = fopen(bootptab, "r")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", bootptab, get_errmsg()); - return; - } - /* - * Record file modification time. - */ - if (fstat(fileno(fp), &st) < 0) { - report(LOG_ERR, "fstat: %s", get_errmsg()); - fclose(fp); - return; - } - modtime = st.st_mtime; - - /* - * Entirely erase all hash tables. - */ - hash_Reset(hwhashtable, free_host); - hash_Reset(iphashtable, free_host); - hash_Reset(nmhashtable, free_host); - - nhosts = 0; - nentries = 0; - while (TRUE) { - buflen = sizeof(buffer); - read_entry(fp, buffer, &buflen); - if (buflen == 0) { /* More entries? */ - break; - } - hp = (struct host *) smalloc(sizeof(struct host)); - bzero((char *) hp, sizeof(*hp)); - /* the link count it zero */ - - /* - * Get individual info - */ - if (process_entry(hp, buffer) < 0) { - hp->linkcount = 1; - free_host((hash_datum *) hp); - continue; - } - /* - * If this is not a dummy entry, and the IP or HW - * address is not yet set, try to get them here. - * Dummy entries have . as first char of name. - */ - if (goodname(hp->hostname->string)) { - char *hn = hp->hostname->string; - u_int32 value; - if (hp->flags.iaddr == 0) { - if (lookup_ipa(hn, &value)) { - report(LOG_ERR, "can not get IP addr for %s", hn); - report(LOG_ERR, "(dummy names should start with '.')"); - } else { - hp->iaddr.s_addr = value; - hp->flags.iaddr = TRUE; - } - } - /* Set default subnet mask. */ - if (hp->flags.subnet_mask == 0) { - if (lookup_netmask(hp->iaddr.s_addr, &value)) { - report(LOG_ERR, "can not get netmask for %s", hn); - } else { - hp->subnet_mask.s_addr = value; - hp->flags.subnet_mask = TRUE; - } - } - } - if (hp->flags.iaddr) { - nhosts++; - } - /* Register by HW addr if known. */ - if (hp->flags.htype && hp->flags.haddr) { - /* We will either insert it or free it. */ - hp->linkcount++; - hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype)); - if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) { - report(LOG_NOTICE, "duplicate %s address: %s", - netname(hp->htype), - haddrtoa(hp->haddr, hp->htype)); - free_host((hash_datum *) hp); - continue; - } - } - /* Register by IP addr if known. */ - if (hp->flags.iaddr) { - hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4); - if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) { - report(LOG_ERR, - "hash_Insert() failed on IP address insertion"); - } else { - /* Just inserted the host struct in a new hash list. */ - hp->linkcount++; - } - } - /* Register by Name (always known) */ - hashcode = hash_HashFunction((u_char *) hp->hostname->string, - strlen(hp->hostname->string)); - if (hash_Insert(nmhashtable, hashcode, nullcmp, - hp->hostname->string, hp) < 0) { - report(LOG_ERR, - "hash_Insert() failed on insertion of hostname: \"%s\"", - hp->hostname->string); - } else { - /* Just inserted the host struct in a new hash list. */ - hp->linkcount++; - } - - nentries++; - } - - fclose(fp); - if (debug) - report(LOG_INFO, "read %d entries (%d hosts) from \"%s\"", - nentries, nhosts, bootptab); - return; -} - - - -/* - * Read an entire host entry from the file pointed to by "fp" and insert it - * into the memory pointed to by "buffer". Leading whitespace and comments - * starting with "#" are ignored (removed). Backslashes (\) always quote - * the next character except that newlines preceeded by a backslash cause - * line-continuation onto the next line. The entry is terminated by a - * newline character which is not preceeded by a backslash. Sequences - * surrounded by double quotes are taken literally (including newlines, but - * not backslashes). - * - * The "bufsiz" parameter points to an unsigned int which specifies the - * maximum permitted buffer size. Upon return, this value will be replaced - * with the actual length of the entry (not including the null terminator). - * - * This code is a little scary. . . . I don't like using gotos in C - * either, but I first wrote this as an FSM diagram and gotos seemed like - * the easiest way to implement it. Maybe later I'll clean it up. - */ - -PRIVATE void -read_entry(fp, buffer, bufsiz) - FILE *fp; - char *buffer; - unsigned *bufsiz; -{ - int c, length; - - length = 0; - - /* - * Eat whitespace, blank lines, and comment lines. - */ - top: - c = fgetc(fp); - if (c < 0) { - goto done; /* Exit if end-of-file */ - } - if (isspace(c)) { - goto top; /* Skip over whitespace */ - } - if (c == '#') { - while (TRUE) { /* Eat comments after # */ - c = fgetc(fp); - if (c < 0) { - goto done; /* Exit if end-of-file */ - } - if (c == '\n') { - goto top; /* Try to read the next line */ - } - } - } - ungetc(c, fp); /* Other character, push it back to reprocess it */ - - - /* - * Now we're actually reading a data entry. Get each character and - * assemble it into the data buffer, processing special characters like - * double quotes (") and backslashes (\). - */ - - mainloop: - c = fgetc(fp); - switch (c) { - case EOF: - case '\n': - goto done; /* Exit on EOF or newline */ - case '\\': - c = fgetc(fp); /* Backslash, read a new character */ - if (c < 0) { - goto done; /* Exit on EOF */ - } - *buffer++ = c; /* Store the literal character */ - length++; - if (length < *bufsiz - 1) { - goto mainloop; - } else { - goto done; - } - case '"': - *buffer++ = '"'; /* Store double-quote */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - while (TRUE) { /* Special quote processing loop */ - c = fgetc(fp); - switch (c) { - case EOF: - goto done; /* Exit on EOF . . . */ - case '"': - *buffer++ = '"';/* Store matching quote */ - length++; - if (length < *bufsiz - 1) { - goto mainloop; /* And continue main loop */ - } else { - goto done; - } - case '\\': - if ((c = fgetc(fp)) < 0) { /* Backslash */ - goto done; /* EOF. . . .*/ - } /* else fall through */ - default: - *buffer++ = c; /* Other character, store it */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - } - } - case ':': - *buffer++ = c; /* Store colons */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - do { /* But remove whitespace after them */ - c = fgetc(fp); - if ((c < 0) || (c == '\n')) { - goto done; - } - } while (isspace(c)); /* Skip whitespace */ - - if (c == '\\') { /* Backslash quotes next character */ - c = fgetc(fp); - if (c < 0) { - goto done; - } - if (c == '\n') { - goto top; /* Backslash-newline continuation */ - } - } - /* fall through if "other" character */ - default: - *buffer++ = c; /* Store other characters */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - } - goto mainloop; /* Keep going */ - - done: - *buffer = '\0'; /* Terminate string */ - *bufsiz = length; /* Tell the caller its length */ -} - - - -/* - * Parse out all the various tags and parameters in the host entry pointed - * to by "src". Stuff all the data into the appropriate fields of the - * host structure pointed to by "host". If there is any problem with the - * entry, an error message is reported via report(), no further processing - * is done, and -1 is returned. Successful calls return 0. - * - * (Some errors probably shouldn't be so completely fatal. . . .) - */ - -PRIVATE int -process_entry(host, src) - struct host *host; - char *src; -{ - int retval; - char *msg; - - if (!host || *src == '\0') { - return -1; - } - host->hostname = get_shared_string(&src); -#if 0 - /* Be more liberal for the benefit of dummy tag names. */ - if (!goodname(host->hostname->string)) { - report(LOG_ERR, "bad hostname: \"%s\"", host->hostname->string); - del_string(host->hostname); - return -1; - } -#endif - current_hostname = host->hostname->string; - adjust(&src); - while (TRUE) { - retval = eval_symbol(&src, host); - if (retval == SUCCESS) { - adjust(&src); - continue; - } - if (retval == E_END_OF_ENTRY) { - /* The default subnet mask is set in readtab() */ - return 0; - } - /* Some kind of error. */ - switch (retval) { - case E_SYNTAX_ERROR: - msg = "bad syntax"; - break; - case E_UNKNOWN_SYMBOL: - msg = "unknown symbol"; - break; - case E_BAD_IPADDR: - msg = "bad INET address"; - break; - case E_BAD_HWADDR: - msg = "bad hardware address"; - break; - case E_BAD_LONGWORD: - msg = "bad longword value"; - break; - case E_BAD_HWATYPE: - msg = "bad HW address type"; - break; - case E_BAD_PATHNAME: - msg = "bad pathname (need leading '/')"; - case E_BAD_VALUE: - msg = "bad value"; - default: - msg = "unkown error"; - break; - } /* switch */ - report(LOG_ERR, "in entry named \"%s\", symbol \"%s\": %s", - current_hostname, current_tagname, msg); - return -1; - } -} - - -/* - * Macros for use in the function below: - */ - -/* Parse one INET address stored directly in MEMBER. */ -#define PARSE_IA1(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = FALSE; \ - if (optype == OP_ADDITION) { \ - if (prs_inetaddr(symbol, &value) < 0) \ - return E_BAD_IPADDR; \ - hp->MEMBER.s_addr = value; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* Parse a list of INET addresses pointed to by MEMBER */ -#define PARSE_IAL(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - if (hp->flags.MEMBER) { \ - hp->flags.MEMBER = FALSE; \ - assert(hp->MEMBER); \ - del_iplist(hp->MEMBER); \ - hp->MEMBER = NULL; \ - } \ - if (optype == OP_ADDITION) { \ - hp->MEMBER = get_addresses(symbol); \ - if (hp->MEMBER == NULL) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* Parse a shared string pointed to by MEMBER */ -#define PARSE_STR(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - if (hp->flags.MEMBER) { \ - hp->flags.MEMBER = FALSE; \ - assert(hp->MEMBER); \ - del_string(hp->MEMBER); \ - hp->MEMBER = NULL; \ - } \ - if (optype == OP_ADDITION) { \ - hp->MEMBER = get_shared_string(symbol); \ - if (hp->MEMBER == NULL) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* Parse an integer value for MEMBER */ -#define PARSE_INT(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = FALSE; \ - if (optype == OP_ADDITION) { \ - value = get_u_long(symbol); \ - hp->MEMBER = value; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* - * Evaluate the two-character tag symbol pointed to by "symbol" and place - * the data in the structure pointed to by "hp". The pointer pointed to - * by "symbol" is updated to point past the source string (but may not - * point to the next tag entry). - * - * Obviously, this need a few more comments. . . . - */ -PRIVATE int -eval_symbol(symbol, hp) - char **symbol; - struct host *hp; -{ - char tmpstr[MAXSTRINGLEN]; - byte *tmphaddr; - struct shared_string *ss; - struct symbolmap *symbolptr; - u_int32 value; - int32 timeoff; - int i, numsymbols; - unsigned len; - int optype; /* Indicates boolean, addition, or deletion */ - - eat_whitespace(symbol); - - /* Make sure this is set before returning. */ - current_tagname[0] = (*symbol)[0]; - current_tagname[1] = (*symbol)[1]; - current_tagname[2] = 0; - - if ((*symbol)[0] == '\0') { - return E_END_OF_ENTRY; - } - if ((*symbol)[0] == ':') { - return SUCCESS; - } - if ((*symbol)[0] == 'T') { /* generic symbol */ - (*symbol)++; - value = get_u_long(symbol); - sprintf(current_tagname, "T%d", value); - eat_whitespace(symbol); - if ((*symbol)[0] != '=') { - return E_SYNTAX_ERROR; - } - (*symbol)++; - if (!(hp->generic)) { - hp->generic = (struct shared_bindata *) - smalloc(sizeof(struct shared_bindata)); - } - if (process_generic(symbol, &(hp->generic), (byte) (value & 0xFF))) - return E_SYNTAX_ERROR; - hp->flags.generic = TRUE; - return SUCCESS; - } - /* - * Determine the type of operation to be done on this symbol - */ - switch ((*symbol)[2]) { - case '=': - optype = OP_ADDITION; - break; - case '@': - optype = OP_DELETION; - break; - case ':': - case '\0': - optype = OP_BOOLEAN; - break; - default: - return E_SYNTAX_ERROR; - } - - symbolptr = symbol_list; - numsymbols = sizeof(symbol_list) / sizeof(struct symbolmap); - for (i = 0; i < numsymbols; i++) { - if (((symbolptr->symbol)[0] == (*symbol)[0]) && - ((symbolptr->symbol)[1] == (*symbol)[1])) { - break; - } - symbolptr++; - } - if (i >= numsymbols) { - return E_UNKNOWN_SYMBOL; - } - /* - * Skip past the = or @ character (to point to the data) if this - * isn't a boolean operation. For boolean operations, just skip - * over the two-character tag symbol (and nothing else. . . .). - */ - (*symbol) += (optype == OP_BOOLEAN) ? 2 : 3; - - eat_whitespace(symbol); - - /* The cases below are in order by symbolcode value. */ - switch (symbolptr->symbolcode) { - - case SYM_BOOTFILE: - PARSE_STR(bootfile); - break; - - case SYM_COOKIE_SERVER: - PARSE_IAL(cookie_server); - break; - - case SYM_DOMAIN_SERVER: - PARSE_IAL(domain_server); - break; - - case SYM_GATEWAY: - PARSE_IAL(gateway); - break; - - case SYM_HWADDR: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.haddr = FALSE; - if (optype == OP_ADDITION) { - /* Default the HW type to Ethernet */ - if (hp->flags.htype == 0) { - hp->flags.htype = TRUE; - hp->htype = HTYPE_ETHERNET; - } - tmphaddr = prs_haddr(symbol, hp->htype); - if (!tmphaddr) - return E_BAD_HWADDR; - bcopy(tmphaddr, hp->haddr, haddrlength(hp->htype)); - hp->flags.haddr = TRUE; - } - break; - - case SYM_HOMEDIR: - PARSE_STR(homedir); - break; - - case SYM_HTYPE: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.htype = FALSE; - if (optype == OP_ADDITION) { - value = 0L; /* Assume an illegal value */ - eat_whitespace(symbol); - if (isdigit(**symbol)) { - value = get_u_long(symbol); - } else { - len = sizeof(tmpstr); - (void) get_string(symbol, tmpstr, &len); - makelower(tmpstr); - numsymbols = sizeof(htnamemap) / - sizeof(struct htypename); - for (i = 0; i < numsymbols; i++) { - if (!strcmp(htnamemap[i].name, tmpstr)) { - break; - } - } - if (i < numsymbols) { - value = htnamemap[i].htype; - } - } - if (value >= hwinfocnt) { - return E_BAD_HWATYPE; - } - hp->htype = (byte) (value & 0xFF); - hp->flags.htype = TRUE; - } - break; - - case SYM_IMPRESS_SERVER: - PARSE_IAL(impress_server); - break; - - case SYM_IPADDR: - PARSE_IA1(iaddr); - break; - - case SYM_LOG_SERVER: - PARSE_IAL(log_server); - break; - - case SYM_LPR_SERVER: - PARSE_IAL(lpr_server); - break; - - case SYM_NAME_SERVER: - PARSE_IAL(name_server); - break; - - case SYM_RLP_SERVER: - PARSE_IAL(rlp_server); - break; - - case SYM_SUBNET_MASK: - PARSE_IA1(subnet_mask); - break; - - case SYM_TIME_OFFSET: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.time_offset = FALSE; - if (optype == OP_ADDITION) { - len = sizeof(tmpstr); - (void) get_string(symbol, tmpstr, &len); - if (!strncmp(tmpstr, "auto", 4)) { - hp->time_offset = secondswest; - } else { - if (sscanf(tmpstr, "%d", &timeoff) != 1) - return E_BAD_LONGWORD; - hp->time_offset = timeoff; - } - hp->flags.time_offset = TRUE; - } - break; - - case SYM_TIME_SERVER: - PARSE_IAL(time_server); - break; - - case SYM_VENDOR_MAGIC: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.vm_cookie = FALSE; - if (optype == OP_ADDITION) { - if (strncmp(*symbol, "auto", 4)) { - /* The string is not "auto" */ - if (!strncmp(*symbol, "rfc", 3)) { - bcopy(vm_rfc1048, hp->vm_cookie, 4); - } else if (!strncmp(*symbol, "cmu", 3)) { - bcopy(vm_cmu, hp->vm_cookie, 4); - } else { - if (!isdigit(**symbol)) - return E_BAD_IPADDR; - if (prs_inetaddr(symbol, &value) < 0) - return E_BAD_IPADDR; - bcopy(&value, hp->vm_cookie, 4); - } - hp->flags.vm_cookie = TRUE; - } - } - break; - - case SYM_SIMILAR_ENTRY: - switch (optype) { - case OP_ADDITION: - fill_defaults(hp, symbol); - break; - default: - return E_SYNTAX_ERROR; - } - break; - - case SYM_NAME_SWITCH: - switch (optype) { - case OP_ADDITION: - return E_SYNTAX_ERROR; - case OP_DELETION: - hp->flags.send_name = FALSE; - hp->flags.name_switch = FALSE; - break; - case OP_BOOLEAN: - hp->flags.send_name = TRUE; - hp->flags.name_switch = TRUE; - break; - } - break; - - case SYM_BOOTSIZE: - switch (optype) { - case OP_ADDITION: - if (!strncmp(*symbol, "auto", 4)) { - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = TRUE; - } else { - hp->bootsize = (unsigned int) get_u_long(symbol); - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = FALSE; - } - break; - case OP_DELETION: - hp->flags.bootsize = FALSE; - break; - case OP_BOOLEAN: - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = TRUE; - break; - } - break; - - case SYM_BOOT_SERVER: - PARSE_IA1(bootserver); - break; - - case SYM_TFTPDIR: - PARSE_STR(tftpdir); - if ((hp->tftpdir != NULL) && - (hp->tftpdir->string[0] != '/')) - return E_BAD_PATHNAME; - break; - - case SYM_DUMP_FILE: - PARSE_STR(dump_file); - break; - - case SYM_DOMAIN_NAME: - PARSE_STR(domain_name); - break; - - case SYM_SWAP_SERVER: - PARSE_IA1(swap_server); - break; - - case SYM_ROOT_PATH: - PARSE_STR(root_path); - break; - - case SYM_EXTEN_FILE: - PARSE_STR(exten_file); - break; - - case SYM_REPLY_ADDR: - PARSE_IA1(reply_addr); - break; - - case SYM_NIS_DOMAIN: - PARSE_STR(nis_domain); - break; - - case SYM_NIS_SERVER: - PARSE_IAL(nis_server); - break; - - case SYM_NTP_SERVER: - PARSE_IAL(ntp_server); - break; - -#ifdef YORK_EX_OPTION - case SYM_EXEC_FILE: - PARSE_STR(exec_file); - break; -#endif - - case SYM_MSG_SIZE: - PARSE_INT(msg_size); - if (hp->msg_size < BP_MINPKTSZ || - hp->msg_size > MAX_MSG_SIZE) - return E_BAD_VALUE; - break; - - case SYM_MIN_WAIT: - PARSE_INT(min_wait); - if (hp->min_wait < 0) - return E_BAD_VALUE; - break; - - /* XXX - Add new tags here */ - - default: - return E_UNKNOWN_SYMBOL; - - } /* switch symbolcode */ - - return SUCCESS; -} -#undef PARSE_IA1 -#undef PARSE_IAL -#undef PARSE_STR - - - - -/* - * Read a string from the buffer indirectly pointed to through "src" and - * move it into the buffer pointed to by "dest". A pointer to the maximum - * allowable length of the string (including null-terminator) is passed as - * "length". The actual length of the string which was read is returned in - * the unsigned integer pointed to by "length". This value is the same as - * that which would be returned by applying the strlen() function on the - * destination string (i.e the terminating null is not counted as a - * character). Trailing whitespace is removed from the string. For - * convenience, the function returns the new value of "dest". - * - * The string is read until the maximum number of characters, an unquoted - * colon (:), or a null character is read. The return string in "dest" is - * null-terminated. - */ - -PRIVATE char * -get_string(src, dest, length) - char **src, *dest; - unsigned *length; -{ - int n, len, quoteflag; - - quoteflag = FALSE; - n = 0; - len = *length - 1; - while ((n < len) && (**src)) { - if (!quoteflag && (**src == ':')) { - break; - } - if (**src == '"') { - (*src)++; - quoteflag = !quoteflag; - continue; - } - if (**src == '\\') { - (*src)++; - if (!**src) { - break; - } - } - *dest++ = *(*src)++; - n++; - } - - /* - * Remove that troublesome trailing whitespace. . . - */ - while ((n > 0) && isspace(dest[-1])) { - dest--; - n--; - } - - *dest = '\0'; - *length = n; - return dest; -} - - - -/* - * Read the string indirectly pointed to by "src", update the caller's - * pointer, and return a pointer to a malloc'ed shared_string structure - * containing the string. - * - * The string is read using the same rules as get_string() above. - */ - -PRIVATE struct shared_string * -get_shared_string(src) - char **src; -{ - char retstring[MAXSTRINGLEN]; - struct shared_string *s; - unsigned length; - - length = sizeof(retstring); - (void) get_string(src, retstring, &length); - - s = (struct shared_string *) smalloc(sizeof(struct shared_string) - + length); - s->linkcount = 1; - strcpy(s->string, retstring); - - return s; -} - - - -/* - * Load RFC1048 generic information directly into a memory buffer. - * - * "src" indirectly points to the ASCII representation of the generic data. - * "dest" points to a string structure which is updated to point to a new - * string with the new data appended to the old string. The old string is - * freed. - * - * The given tag value is inserted with the new data. - * - * The data may be represented as either a stream of hexadecimal numbers - * representing bytes (any or all bytes may optionally start with '0x' and - * be separated with periods ".") or as a quoted string of ASCII - * characters (the quotes are required). - */ - -PRIVATE int -process_generic(src, dest, tagvalue) - char **src; - struct shared_bindata **dest; - u_int tagvalue; -{ - byte tmpbuf[MAXBUFLEN]; - byte *str; - struct shared_bindata *bdata; - u_int newlength, oldlength; - - str = tmpbuf; - *str++ = (tagvalue & 0xFF); /* Store tag value */ - str++; /* Skip over length field */ - if ((*src)[0] == '"') { /* ASCII data */ - newlength = sizeof(tmpbuf) - 2; /* Set maximum allowed length */ - (void) get_string(src, (char *) str, &newlength); - newlength++; /* null terminator */ - } else { /* Numeric data */ - newlength = 0; - while (newlength < sizeof(tmpbuf) - 2) { - if (interp_byte(src, str++) < 0) - break; - newlength++; - if (**src == '.') { - (*src)++; - } - } - } - if ((*src)[0] != ':') - return -1; - - tmpbuf[1] = (newlength & 0xFF); - oldlength = ((*dest)->length); - bdata = (struct shared_bindata *) smalloc(sizeof(struct shared_bindata) - + oldlength + newlength + 1); - if (oldlength > 0) { - bcopy((*dest)->data, bdata->data, oldlength); - } - bcopy(tmpbuf, bdata->data + oldlength, newlength + 2); - bdata->length = oldlength + newlength + 2; - bdata->linkcount = 1; - if (*dest) { - del_bindata(*dest); - } - *dest = bdata; - return 0; -} - - - -/* - * Verify that the given string makes sense as a hostname (according to - * Appendix 1, page 29 of RFC882). - * - * Return TRUE for good names, FALSE otherwise. - */ - -PRIVATE boolean -goodname(hostname) - register char *hostname; -{ - do { - if (!isalpha(*hostname++)) { /* First character must be a letter */ - return FALSE; - } - while (isalnum(*hostname) || - (*hostname == '-') || - (*hostname == '_') ) - { - hostname++; /* Alphanumeric or a hyphen */ - } - if (!isalnum(hostname[-1])) { /* Last must be alphanumeric */ - return FALSE; - } - if (*hostname == '\0') {/* Done? */ - return TRUE; - } - } while (*hostname++ == '.'); /* Dot, loop for next label */ - - return FALSE; /* If it's not a dot, lose */ -} - - - -/* - * Null compare function -- always returns FALSE so an element is always - * inserted into a hash table (i.e. there is never a collision with an - * existing element). - */ - -PRIVATE boolean -nullcmp(d1, d2) - hash_datum *d1, *d2; -{ - return FALSE; -} - - -/* - * Function for comparing a string with the hostname field of a host - * structure. - */ - -boolean -nmcmp(d1, d2) - hash_datum *d1, *d2; -{ - char *name = (char *) d1; /* XXX - OK? */ - struct host *hp = (struct host *) d2; - - return !strcmp(name, hp->hostname->string); -} - - -/* - * Compare function to determine whether two hardware addresses are - * equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE - * otherwise. - * - * If the hardware addresses of "host1" and "host2" are identical, but - * they are on different IP subnets, this function returns FALSE. - * - * This function is used when inserting elements into the hardware address - * hash table. - */ - -PRIVATE boolean -hwinscmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - if (host1->htype != host2->htype) { - return FALSE; - } - if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) { - return FALSE; - } - /* XXX - Is the subnet_mask field set yet? */ - if ((host1->subnet_mask.s_addr) == (host2->subnet_mask.s_addr)) { - if (((host1->iaddr.s_addr) & (host1->subnet_mask.s_addr)) != - ((host2->iaddr.s_addr) & (host2->subnet_mask.s_addr))) - { - return FALSE; - } - } - return TRUE; -} - - -/* - * Macros for use in the function below: - */ - -#define DUP_COPY(MEMBER) do \ -{ \ - if (!hp->flags.MEMBER) { \ - if ((hp->flags.MEMBER = hp2->flags.MEMBER) != 0) { \ - hp->MEMBER = hp2->MEMBER; \ - } \ - } \ -} while (0) - -#define DUP_LINK(MEMBER) do \ -{ \ - if (!hp->flags.MEMBER) { \ - if ((hp->flags.MEMBER = hp2->flags.MEMBER) != 0) { \ - assert(hp2->MEMBER); \ - hp->MEMBER = hp2->MEMBER; \ - (hp->MEMBER->linkcount)++; \ - } \ - } \ -} while (0) - -/* - * Process the "similar entry" symbol. - * - * The host specified as the value of the "tc" symbol is used as a template - * for the current host entry. Symbol values not explicitly set in the - * current host entry are inferred from the template entry. - */ -PRIVATE void -fill_defaults(hp, src) - struct host *hp; - char **src; -{ - unsigned int tlen, hashcode; - struct host *hp2; - char tstring[MAXSTRINGLEN]; - - tlen = sizeof(tstring); - (void) get_string(src, tstring, &tlen); - hashcode = hash_HashFunction((u_char *) tstring, tlen); - hp2 = (struct host *) hash_Lookup(nmhashtable, hashcode, nmcmp, tstring); - - if (hp2 == NULL) { - report(LOG_ERR, "can't find tc=\"%s\"", tstring); - return; - } - DUP_LINK(bootfile); - DUP_LINK(cookie_server); - DUP_LINK(domain_server); - DUP_LINK(gateway); - /* haddr not copied */ - DUP_LINK(homedir); - DUP_COPY(htype); - - DUP_LINK(impress_server); - /* iaddr not copied */ - DUP_LINK(log_server); - DUP_LINK(lpr_server); - DUP_LINK(name_server); - DUP_LINK(rlp_server); - - DUP_COPY(subnet_mask); - DUP_COPY(time_offset); - DUP_LINK(time_server); - - if (!hp->flags.vm_cookie) { - if ((hp->flags.vm_cookie = hp2->flags.vm_cookie)) { - bcopy(hp2->vm_cookie, hp->vm_cookie, 4); - } - } - if (!hp->flags.name_switch) { - if ((hp->flags.name_switch = hp2->flags.name_switch)) { - hp->flags.send_name = hp2->flags.send_name; - } - } - if (!hp->flags.bootsize) { - if ((hp->flags.bootsize = hp2->flags.bootsize)) { - hp->flags.bootsize_auto = hp2->flags.bootsize_auto; - hp->bootsize = hp2->bootsize; - } - } - DUP_COPY(bootserver); - - DUP_LINK(tftpdir); - DUP_LINK(dump_file); - DUP_LINK(domain_name); - - DUP_COPY(swap_server); - DUP_LINK(root_path); - DUP_LINK(exten_file); - - DUP_COPY(reply_addr); - - DUP_LINK(nis_domain); - DUP_LINK(nis_server); - DUP_LINK(ntp_server); - -#ifdef YORK_EX_OPTION - DUP_LINK(exec_file); -#endif - - DUP_COPY(msg_size); - DUP_COPY(min_wait); - - /* XXX - Add new tags here */ - - DUP_LINK(generic); - -} -#undef DUP_COPY -#undef DUP_LINK - - - -/* - * This function adjusts the caller's pointer to point just past the - * first-encountered colon. If it runs into a null character, it leaves - * the pointer pointing to it. - */ - -PRIVATE void -adjust(s) - char **s; -{ - register char *t; - - t = *s; - while (*t && (*t != ':')) { - t++; - } - if (*t) { - t++; - } - *s = t; -} - - - - -/* - * This function adjusts the caller's pointer to point to the first - * non-whitespace character. If it runs into a null character, it leaves - * the pointer pointing to it. - */ - -PRIVATE void -eat_whitespace(s) - char **s; -{ - register char *t; - - t = *s; - while (*t && isspace(*t)) { - t++; - } - *s = t; -} - - - -/* - * This function converts the given string to all lowercase. - */ - -PRIVATE void -makelower(s) - char *s; -{ - while (*s) { - if (isupper(*s)) { - *s = tolower(*s); - } - s++; - } -} - - - -/* - * - * N O T E : - * - * In many of the functions which follow, a parameter such as "src" or - * "symbol" is passed as a pointer to a pointer to something. This is - * done for the purpose of letting the called function update the - * caller's copy of the parameter (i.e. to effect call-by-reference - * parameter passing). The value of the actual parameter is only used - * to locate the real parameter of interest and then update this indirect - * parameter. - * - * I'm sure somebody out there won't like this. . . . - * (Yea, because it usually makes code slower... -gwr) - * - */ - - - -/* - * "src" points to a character pointer which points to an ASCII string of - * whitespace-separated IP addresses. A pointer to an in_addr_list - * structure containing the list of addresses is returned. NULL is - * returned if no addresses were found at all. The pointer pointed to by - * "src" is updated to point to the first non-address (illegal) character. - */ - -PRIVATE struct in_addr_list * -get_addresses(src) - char **src; -{ - struct in_addr tmpaddrlist[MAXINADDRS]; - struct in_addr *address1, *address2; - struct in_addr_list *result; - unsigned addrcount, totalsize; - - address1 = tmpaddrlist; - for (addrcount = 0; addrcount < MAXINADDRS; addrcount++) { - while (isspace(**src) || (**src == ',')) { - (*src)++; - } - if (!**src) { /* Quit if nothing more */ - break; - } - if (prs_inetaddr(src, &(address1->s_addr)) < 0) { - break; - } - address1++; /* Point to next address slot */ - } - if (addrcount < 1) { - result = NULL; - } else { - totalsize = sizeof(struct in_addr_list) - + (addrcount - 1) * sizeof(struct in_addr); - result = (struct in_addr_list *) smalloc(totalsize); - result->linkcount = 1; - result->addrcount = addrcount; - address1 = tmpaddrlist; - address2 = result->addr; - for (; addrcount > 0; addrcount--) { - address2->s_addr = address1->s_addr; - address1++; - address2++; - } - } - return result; -} - - - -/* - * prs_inetaddr(src, result) - * - * "src" is a value-result parameter; the pointer it points to is updated - * to point to the next data position. "result" points to an unsigned long - * in which an address is returned. - * - * This function parses the IP address string in ASCII "dot notation" pointed - * to by (*src) and places the result (in network byte order) in the unsigned - * long pointed to by "result". For malformed addresses, -1 is returned, - * (*src) points to the first illegal character, and the unsigned long pointed - * to by "result" is unchanged. Successful calls return 0. - */ - -PRIVATE int -prs_inetaddr(src, result) - char **src; - u_int32 *result; -{ - char tmpstr[MAXSTRINGLEN]; - register u_int32 value; - u_int32 parts[4], *pp; - int n; - char *s, *t; - -#if 1 /* XXX - experimental */ - /* Leading alpha char causes IP addr lookup. */ - if (isalpha(**src)) { - /* Lookup IP address. */ - s = *src; - t = tmpstr; - while ((isalnum(*s) || (*s == '.') || - (*s == '-') || (*s == '_') ) && - (t < &tmpstr[MAXSTRINGLEN - 1]) ) - *t++ = *s++; - *t = '\0'; - *src = s; - - n = lookup_ipa(tmpstr, result); - if (n < 0) - report(LOG_ERR, "can not get IP addr for %s", tmpstr); - return n; - } -#endif - - /* - * Parse an address in Internet format: - * a.b.c.d - * a.b.c (with c treated as 16-bits) - * a.b (with b treated as 24 bits) - */ - pp = parts; - loop: - /* If it's not a digit, return error. */ - if (!isdigit(**src)) - return -1; - *pp++ = get_u_long(src); - if (**src == '.') { - if (pp < (parts + 4)) { - (*src)++; - goto loop; - } - return (-1); - } -#if 0 - /* This is handled by the caller. */ - if (**src && !(isspace(**src) || (**src == ':'))) { - return (-1); - } -#endif - - /* - * Construct the address according to - * the number of parts specified. - */ - n = pp - parts; - switch (n) { - case 1: /* a -- 32 bits */ - value = parts[0]; - break; - case 2: /* a.b -- 8.24 bits */ - value = (parts[0] << 24) | (parts[1] & 0xFFFFFF); - break; - case 3: /* a.b.c -- 8.8.16 bits */ - value = (parts[0] << 24) | ((parts[1] & 0xFF) << 16) | - (parts[2] & 0xFFFF); - break; - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - value = (parts[0] << 24) | ((parts[1] & 0xFF) << 16) | - ((parts[2] & 0xFF) << 8) | (parts[3] & 0xFF); - break; - default: - return (-1); - } - *result = htonl(value); - return (0); -} - - - -/* - * "src" points to a pointer which in turn points to a hexadecimal ASCII - * string. This string is interpreted as a hardware address and returned - * as a pointer to the actual hardware address, represented as an array of - * bytes. - * - * The ASCII string must have the proper number of digits for the specified - * hardware type (e.g. twelve digits for a 48-bit Ethernet address). - * Two-digit sequences (bytes) may be separated with periods (.) and/or - * prefixed with '0x' for readability, but this is not required. - * - * For bad addresses, the pointer which "src" points to is updated to point - * to the start of the first two-digit sequence which was bad, and the - * function returns a NULL pointer. - */ - -PRIVATE byte * -prs_haddr(src, htype) - char **src; - u_int htype; -{ - static byte haddr[MAXHADDRLEN]; - byte *hap; - char tmpstr[MAXSTRINGLEN]; - u_int tmplen; - unsigned hal; - char *p; - - hal = haddrlength(htype); /* Get length of this address type */ - if (hal <= 0) { - report(LOG_ERR, "Invalid addr type for HW addr parse"); - return NULL; - } - tmplen = sizeof(tmpstr); - get_string(src, tmpstr, &tmplen); - p = tmpstr; - -#if 1 /* XXX - experimental */ - /* If it's a valid host name, try to lookup the HW address. */ - if (goodname(p)) { - /* Lookup Hardware Address for hostname. */ - if ((hap = lookup_hwa(p, htype)) != NULL) - return hap; /* success */ - report(LOG_ERR, "Add 0x prefix if hex value starts with A-F"); - /* OK, assume it must be numeric. */ - } -#endif - - hap = haddr; - while (hap < haddr + hal) { - if (*p == '.') - p++; - if (interp_byte(&p, hap++) < 0) { - return NULL; - } - } - return haddr; -} - - - -/* - * "src" is a pointer to a character pointer which in turn points to a - * hexadecimal ASCII representation of a byte. This byte is read, the - * character pointer is updated, and the result is deposited into the - * byte pointed to by "retbyte". - * - * The usual '0x' notation is allowed but not required. The number must be - * a two digit hexadecimal number. If the number is invalid, "src" and - * "retbyte" are left untouched and -1 is returned as the function value. - * Successful calls return 0. - */ - -PRIVATE int -interp_byte(src, retbyte) - char **src; - byte *retbyte; -{ - int v; - - if ((*src)[0] == '0' && - ((*src)[1] == 'x' || - (*src)[1] == 'X')) { - (*src) += 2; /* allow 0x for hex, but don't require it */ - } - if (!isxdigit((*src)[0]) || !isxdigit((*src)[1])) { - return -1; - } - if (sscanf(*src, "%2x", &v) != 1) { - return -1; - } - (*src) += 2; - *retbyte = (byte) (v & 0xFF); - return 0; -} - - - -/* - * The parameter "src" points to a character pointer which points to an - * ASCII string representation of an unsigned number. The number is - * returned as an unsigned long and the character pointer is updated to - * point to the first illegal character. - */ - -PRIVATE u_int32 -get_u_long(src) - char **src; -{ - register u_int32 value, base; - char c; - - /* - * Collect number up to first illegal character. Values are specified - * as for C: 0x=hex, 0=octal, other=decimal. - */ - value = 0; - base = 10; - if (**src == '0') { - base = 8; - (*src)++; - } - if (**src == 'x' || **src == 'X') { - base = 16; - (*src)++; - } - while ((c = **src)) { - if (isdigit(c)) { - value = (value * base) + (c - '0'); - (*src)++; - continue; - } - if (base == 16 && isxdigit(c)) { - value = (value << 4) + ((c & ~32) + 10 - 'A'); - (*src)++; - continue; - } - break; - } - return value; -} - - - -/* - * Routines for deletion of data associated with the main data structure. - */ - - -/* - * Frees the entire host data structure given. Does nothing if the passed - * pointer is NULL. - */ - -PRIVATE void -free_host(hmp) - hash_datum *hmp; -{ - struct host *hostptr = (struct host *) hmp; - if (hostptr == NULL) - return; - assert(hostptr->linkcount > 0); - if (--(hostptr->linkcount)) - return; /* Still has references */ - del_iplist(hostptr->cookie_server); - del_iplist(hostptr->domain_server); - del_iplist(hostptr->gateway); - del_iplist(hostptr->impress_server); - del_iplist(hostptr->log_server); - del_iplist(hostptr->lpr_server); - del_iplist(hostptr->name_server); - del_iplist(hostptr->rlp_server); - del_iplist(hostptr->time_server); - del_iplist(hostptr->nis_server); - del_iplist(hostptr->ntp_server); - - /* - * XXX - Add new tags here - * (if the value is an IP list) - */ - - del_string(hostptr->hostname); - del_string(hostptr->homedir); - del_string(hostptr->bootfile); - del_string(hostptr->tftpdir); - del_string(hostptr->root_path); - del_string(hostptr->domain_name); - del_string(hostptr->dump_file); - del_string(hostptr->exten_file); - del_string(hostptr->nis_domain); - -#ifdef YORK_EX_OPTION - del_string(hostptr->exec_file); -#endif - - /* - * XXX - Add new tags here - * (if it is a shared string) - */ - - del_bindata(hostptr->generic); - free((char *) hostptr); -} - - - -/* - * Decrements the linkcount on the given IP address data structure. If the - * linkcount goes to zero, the memory associated with the data is freed. - */ - -PRIVATE void -del_iplist(iplist) - struct in_addr_list *iplist; -{ - if (iplist) { - if (!(--(iplist->linkcount))) { - free((char *) iplist); - } - } -} - - - -/* - * Decrements the linkcount on a string data structure. If the count - * goes to zero, the memory associated with the string is freed. Does - * nothing if the passed pointer is NULL. - */ - -PRIVATE void -del_string(stringptr) - struct shared_string *stringptr; -{ - if (stringptr) { - if (!(--(stringptr->linkcount))) { - free((char *) stringptr); - } - } -} - - - -/* - * Decrements the linkcount on a shared_bindata data structure. If the - * count goes to zero, the memory associated with the data is freed. Does - * nothing if the passed pointer is NULL. - */ - -PRIVATE void -del_bindata(dataptr) - struct shared_bindata *dataptr; -{ - if (dataptr) { - if (!(--(dataptr->linkcount))) { - free((char *) dataptr); - } - } -} - - - - -/* smalloc() -- safe malloc() - * - * Always returns a valid pointer (if it returns at all). The allocated - * memory is initialized to all zeros. If malloc() returns an error, a - * message is printed using the report() function and the program aborts - * with a status of 1. - */ - -PRIVATE char * -smalloc(nbytes) - unsigned nbytes; -{ - char *retvalue; - - retvalue = malloc(nbytes); - if (!retvalue) { - report(LOG_ERR, "malloc() failure -- exiting"); - exit(1); - } - bzero(retvalue, nbytes); - return retvalue; -} - - -/* - * Compare function to determine whether two hardware addresses are - * equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE - * otherwise. - * - * This function is used when retrieving elements from the hardware address - * hash table. - */ - -boolean -hwlookcmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - if (host1->htype != host2->htype) { - return FALSE; - } - if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) { - return FALSE; - } - return TRUE; -} - - -/* - * Compare function for doing IP address hash table lookup. - */ - -boolean -iplookcmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - return (host1->iaddr.s_addr == host2->iaddr.s_addr); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/readfile.h b/usr.sbin/bootpd/readfile.h deleted file mode 100644 index 3913455857c3..000000000000 --- a/usr.sbin/bootpd/readfile.h +++ /dev/null @@ -1,19 +0,0 @@ -/* readfile.h */ - -#include "bptypes.h" -#include "hash.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern boolean hwlookcmp P((hash_datum *, hash_datum *)); -extern boolean iplookcmp P((hash_datum *, hash_datum *)); -extern boolean nmcmp P((hash_datum *, hash_datum *)); -extern void readtab P((int)); -extern void rdtab_init P((void)); - -#undef P - diff --git a/usr.sbin/bootpd/report.c b/usr.sbin/bootpd/report.c deleted file mode 100644 index 4f7f03616a2a..000000000000 --- a/usr.sbin/bootpd/report.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * report() - calls syslog - */ - -#ifdef __STDC__ -#include -#else -#include -#endif - -#include -#include - -#include "report.h" - -#ifndef LOG_NDELAY -#define LOG_NDELAY 0 -#endif -#ifndef LOG_DAEMON -#define LOG_DAEMON 0 -#endif -#ifndef LOG_BOOTP -#define LOG_BOOTP LOG_DAEMON -#endif - -extern int debug; -extern char *progname; - -/* - * This is initialized so you get stderr until you call - * report_init() - */ -static int stderr_only = 1; - -void -report_init(nolog) - int nolog; -{ - stderr_only = nolog; -#ifdef SYSLOG - if (!stderr_only) { - openlog(progname, LOG_PID | LOG_NDELAY, LOG_BOOTP); - } -#endif -} - -/* - * This routine reports errors and such via stderr and syslog() if - * appopriate. It just helps avoid a lot of "#ifdef SYSLOG" constructs - * from being scattered throughout the code. - * - * The syntax is identical to syslog(3), but %m is not considered special - * for output to stderr (i.e. you'll see "%m" in the output. . .). Also, - * control strings should normally end with \n since newlines aren't - * automatically generated for stderr output (whereas syslog strips out all - * newlines and adds its own at the end). - */ - -static char *levelnames[] = { -#ifdef LOG_SALERT - "level(0): ", - "alert(1): ", - "alert(2): ", - "emerg(3): ", - "error(4): ", - "crit(5): ", - "warn(6): ", - "note(7): ", - "info(8): ", - "debug(9): ", - "level(?): " -#else - "emerg(0): ", - "alert(1): ", - "crit(2): ", - "error(3): ", - "warn(4): ", - "note(5): ", - "info(6): ", - "debug(7): ", - "level(?): " -#endif -}; -static int numlevels = sizeof(levelnames) / sizeof(levelnames[0]); - - -/* - * Print a log message using syslog(3) and/or stderr. - * The message passed in should not include a newline. - */ -#ifdef __STDC__ -void -report(int priority, char *fmt,...) -#else -/*VARARGS2*/ -void -report(priority, fmt, va_alist) - int priority; - char *fmt; - va_dcl -#endif -{ - va_list ap; - static char buf[128]; - - if ((priority < 0) || (priority >= numlevels)) { - priority = numlevels - 1; - } -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vsprintf(buf, fmt, ap); - va_end(ap); - - /* - * Print the message - */ - if (stderr_only || (debug > 2)) { - fprintf(stderr, "%s: %s %s\n", - progname, levelnames[priority], buf); - } -#ifdef SYSLOG - if (!stderr_only) - syslog((priority | LOG_BOOTP), "%s", buf); -#endif -} - - - -/* - * Return pointer to static string which gives full filesystem error message. - */ -char * -get_errmsg() -{ - extern int errno; - extern char *strerror(); - - return strerror(errno); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/usr.sbin/bootpd/report.h b/usr.sbin/bootpd/report.h deleted file mode 100644 index 0bf63d60fbb1..000000000000 --- a/usr.sbin/bootpd/report.h +++ /dev/null @@ -1,13 +0,0 @@ -/* report.h */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void report_init P((int nolog)); -extern void report P((int, char *, ...)); -extern char *get_errmsg P((void)); - -#undef P diff --git a/usr.sbin/bootpd/syslog.conf b/usr.sbin/bootpd/syslog.conf deleted file mode 100644 index 2c135af4974e..000000000000 --- a/usr.sbin/bootpd/syslog.conf +++ /dev/null @@ -1,63 +0,0 @@ -# -# syslog configuration file for SunOS 4.X -# (modified to do local2 separately) -# -# This file is processed by m4 so be careful to quote (`') names -# that match m4 reserved words. Also, within ifdef's, arguments -# containing commas must be quoted. -# -# Note: Have to exclude user from most lines so that user.alert -# and user.emerg are not included, because old sendmails -# will generate them for debugging information. If you -# have no 4.2BSD based systems doing network logging, you -# can remove all the special cases for "user" logging. - -#*.err;kern.debug;auth.notice;user.none /dev/console -kern.debug;user,mail.crit;auth.notice /dev/console -daemon,syslog,lpr,news,uucp,cron.err /dev/console - -#*.err;kern.debug;daemon,auth.notice;mail.crit;user.none /var/adm/messages -kern.debug;user,mail.crit;auth.notice /var/adm/messages -daemon.notice;syslog,news,uucp,cron.err /var/adm/messages - -lpr.debug /var/adm/lpd-errs - -*.alert;kern.err;daemon.err;user.none operator -*.alert;user.none root - -*.emerg;user.none * - -# for loghost machines, to have authentication messages (su, login, etc.) -# logged to a file, un-comment out the following line and adjust the file name -# as appropriate. -# -# if a non-loghost machine chooses to have such messages -# sent to the loghost machine, un-comment out the following line. -# -#auth.notice ifdef(`LOGHOST', /var/log/authlog, @loghost) - -mail.debug ifdef(`LOGHOST', /var/log/syslog, @loghost) - -# following line for compatibility with old sendmails. they will send -# messages with no facility code, which will be turned into "user" messages -# by the local syslog daemon. only the "loghost" machine needs the following -# line, to cause these old sendmail log messages to be logged in the -# mail syslog file. -# -ifdef(`LOGHOST', -user.alert /var/log/syslog -) -# -# non-loghost machines will use the following lines to cause "user" -# log messages to be logged locally. -# -ifdef(`LOGHOST', , -user.err /dev/console -user.err /var/adm/messages -user.alert `root, operator' -user.emerg * -) - -# Local2: (bootpd, pppd) -local2.debug /dev/console -#local2.debug /var/log/local2 diff --git a/usr.sbin/bootpd/trygetea.c b/usr.sbin/bootpd/trygetea.c deleted file mode 100644 index e9314aede96d..000000000000 --- a/usr.sbin/bootpd/trygetea.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * trygetea.c - test program for getether.c - */ - -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif - -#include /* for struct ifreq */ -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - u_char ea[16]; /* Ethernet address */ - int i; - - progname = argv[0]; /* for report */ - - if (argc < 2) { - printf("need interface name\n"); - exit(1); - } - if ((i = getether(argv[1], ea)) < 0) { - printf("Could not get Ethernet address (rc=%d)\n", i); - exit(1); - } - printf("Ether-addr"); - for (i = 0; i < 6; i++) - printf(":%x", ea[i] & 0xFF); - printf("\n"); - - exit(0); -} diff --git a/usr.sbin/bootpd/trygetif.c b/usr.sbin/bootpd/trygetif.c deleted file mode 100644 index c6bb098ab03b..000000000000 --- a/usr.sbin/bootpd/trygetif.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * trygetif.c - test program for getif.c - */ - -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif - -#include /* for struct ifreq */ -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -#include "getif.h" - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - struct hostent *hep; - struct sockaddr ea; /* Ethernet address */ - struct sockaddr_in *sip; /* Interface address */ - struct ifreq *ifr; - struct in_addr dst_addr; - struct in_addr *dap; - int i, s; - - progname = argv[0]; /* for report */ - - dap = NULL; - if (argc > 1) { - dap = &dst_addr; - if (isdigit(argv[1][0])) - dst_addr.s_addr = inet_addr(argv[1]); - else { - hep = gethostbyname(argv[1]); - if (!hep) { - printf("gethostbyname(%s)\n", argv[1]); - exit(1); - } - memcpy(&dst_addr, hep->h_addr, sizeof(dst_addr)); - } - } - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - perror("socket open"); - exit(1); - } - ifr = getif(s, dap); - if (!ifr) { - printf("no interface for address\n"); - exit(1); - } - printf("Intf-name:%s\n", ifr->ifr_name); - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - printf("Intf-addr:%s\n", inet_ntoa(sip->sin_addr)); - - exit(0); -} diff --git a/usr.sbin/bootpd/trylook.c b/usr.sbin/bootpd/trylook.c deleted file mode 100644 index 40652a21159b..000000000000 --- a/usr.sbin/bootpd/trylook.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * trylook.c - test program for lookup.c - */ - -#include -#include -#include - -#include "report.h" -#include "lookup.h" - -extern char *ether_ntoa(); -extern char *inet_ntoa(); - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - int i; - struct in_addr in; - char *a; - u_char *hwa; - - progname = argv[0]; /* for report */ - - for (i = 1; i < argc; i++) { - - /* Host name */ - printf("%s:", argv[i]); - - /* IP addr */ - if (lookup_ipa(argv[i], &in.s_addr)) - a = "?"; - else - a = inet_ntoa(in); - printf(" ipa=%s", a); - - /* Ether addr */ - hwa = lookup_hwa(argv[i], 1); - if (!hwa) - a = "?"; - else - a = ether_ntoa(hwa); - printf(" hwa=%s\n", a); - - } - exit(0); -} diff --git a/usr.sbin/bootpd/tzone.c b/usr.sbin/bootpd/tzone.c deleted file mode 100644 index 4adc4ae25c63..000000000000 --- a/usr.sbin/bootpd/tzone.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * tzone.c - get the timezone - * - * This is shared by bootpd and bootpef - */ - -#ifdef SVR4 -/* XXX - Is this really SunOS specific? -gwr */ -/* This is in but only visible if (__STDC__ == 1). */ -extern long timezone; -#else /* SVR4 */ -/* BSD or SunOS */ -# include -# include -#endif /* SVR4 */ - -#include "bptypes.h" -#include "report.h" -#include "tzone.h" - -/* This is what other modules use. */ -int32 secondswest; - -/* - * Get our timezone offset so we can give it to clients if the - * configuration file doesn't specify one. - */ -void -tzone_init() -{ -#ifdef SVR4 - /* XXX - Is this really SunOS specific? -gwr */ - secondswest = timezone; -#else /* SVR4 */ - struct timezone tzp; /* Time zone offset for clients */ - struct timeval tp; /* Time (extra baggage) */ - if (gettimeofday(&tp, &tzp) < 0) { - secondswest = 0; /* Assume GMT for lack of anything better */ - report(LOG_ERR, "gettimeofday: %s", get_errmsg()); - } else { - secondswest = 60L * tzp.tz_minuteswest; /* Convert to seconds */ - } -#endif /* SVR4 */ -} diff --git a/usr.sbin/bootpd/tzone.h b/usr.sbin/bootpd/tzone.h deleted file mode 100644 index ddd67c4b625c..000000000000 --- a/usr.sbin/bootpd/tzone.h +++ /dev/null @@ -1,3 +0,0 @@ -/* tzone.h */ -extern int32 secondswest; -extern void tzone_init(); diff --git a/usr.sbin/sliplogin/slip.hosts b/usr.sbin/sliplogin/slip.hosts deleted file mode 100644 index f6ebf4095605..000000000000 --- a/usr.sbin/sliplogin/slip.hosts +++ /dev/null @@ -1,11 +0,0 @@ -# @(#)slip.hosts 8.1 (Berkeley) 6/6/93 -# -# login local-addr remote-addr mask opt1 opt2 -# (normal,compress,noicmp) -# -Schez vangogh chez 0xffffff00 compress -Sjun vangogh 128.32.130.36 0xffffff00 normal -Sleconte vangogh leconte 0xffffff00 compress -Sleeb vangogh leeb 0xffffff00 compress -Smjk vangogh pissaro-sl 0xffffff00 compress -Soxford vangogh oxford 0xffffff00 compress diff --git a/usr.sbin/sliplogin/slip.login b/usr.sbin/sliplogin/slip.login deleted file mode 100644 index 3c70095a2fcc..000000000000 --- a/usr.sbin/sliplogin/slip.login +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# -# @(#)slip.login 8.1 (Berkeley) 6/6/93 - -# -# generic login file for a slip line. sliplogin invokes this with -# the parameters: -# 1 2 3 4 5 6 7-n -# slipunit ttyspeed loginname local-addr remote-addr mask opt-args -# -/sbin/ifconfig sl$1 inet $4 $5 netmask $6 -exit diff --git a/usr.sbin/tcpdump/tcpdump/bpf_image.c b/usr.sbin/tcpdump/tcpdump/bpf_image.c deleted file mode 100644 index d36eab252f7c..000000000000 --- a/usr.sbin/tcpdump/tcpdump/bpf_image.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char rcsid[] = - "@(#) $Header: bpf_image.c,v 1.10 92/01/26 21:01:16 mccanne Exp $ (LBL)"; -#endif - -#include -#include - -#include -#include -#include - -char * -bpf_image(p, n) - struct bpf_insn *p; - int n; -{ - int v; - char *fmt, *op; - static char image[256]; - char operand[64]; - - v = p->k; - switch (p->code) { - - default: - op = "unimp"; - fmt = "0x%x"; - v = p->code; - break; - - case BPF_RET|BPF_K: - op = "ret"; - fmt = "#%d"; - break; - - case BPF_RET|BPF_A: - op = "ret"; - fmt = ""; - break; - - case BPF_LD|BPF_W|BPF_ABS: - op = "ld"; - fmt = "[%d]"; - break; - - case BPF_LD|BPF_H|BPF_ABS: - op = "ldh"; - fmt = "[%d]"; - break; - - case BPF_LD|BPF_B|BPF_ABS: - op = "ldb"; - fmt = "[%d]"; - break; - - case BPF_LD|BPF_W|BPF_LEN: - op = "ld"; - fmt = "#pktlen"; - break; - - case BPF_LD|BPF_W|BPF_IND: - op = "ld"; - fmt = "[x + %d]"; - break; - - case BPF_LD|BPF_H|BPF_IND: - op = "ldh"; - fmt = "[x + %d]"; - break; - - case BPF_LD|BPF_B|BPF_IND: - op = "ldb"; - fmt = "[x + %d]"; - break; - - case BPF_LD|BPF_IMM: - op = "ld"; - fmt = "#0x%x"; - break; - - case BPF_LDX|BPF_IMM: - op = "ldx"; - fmt = "#0x%x"; - break; - - case BPF_LDX|BPF_MSH|BPF_B: - op = "ldxb"; - fmt = "4*([%d]&0xf)"; - break; - - case BPF_LD|BPF_MEM: - op = "ld"; - fmt = "M[%d]"; - break; - - case BPF_LDX|BPF_MEM: - op = "ldx"; - fmt = "M[%d]"; - break; - - case BPF_ST: - op = "st"; - fmt = "M[%d]"; - break; - - case BPF_STX: - op = "stx"; - fmt = "M[%d]"; - break; - - case BPF_JMP|BPF_JA: - op = "ja"; - fmt = "%d"; - v = n + p->k; - break; - - case BPF_JMP|BPF_JGT|BPF_K: - op = "jgt"; - fmt = "#0x%x"; - break; - - case BPF_JMP|BPF_JGE|BPF_K: - op = "jge"; - fmt = "#0x%x"; - break; - - case BPF_JMP|BPF_JEQ|BPF_K: - op = "jeq"; - fmt = "#0x%x"; - break; - - case BPF_JMP|BPF_JSET|BPF_K: - op = "jset"; - fmt = "#0x%x"; - break; - - case BPF_JMP|BPF_JGT|BPF_X: - op = "jgt"; - fmt = "x"; - break; - - case BPF_JMP|BPF_JGE|BPF_X: - op = "jge"; - fmt = "x"; - break; - - case BPF_JMP|BPF_JEQ|BPF_X: - op = "jeq"; - fmt = "x"; - break; - - case BPF_JMP|BPF_JSET|BPF_X: - op = "jset"; - fmt = "x"; - break; - - case BPF_ALU|BPF_ADD|BPF_X: - op = "add"; - fmt = "x"; - break; - - case BPF_ALU|BPF_SUB|BPF_X: - op = "sub"; - fmt = "x"; - break; - - case BPF_ALU|BPF_MUL|BPF_X: - op = "mul"; - fmt = "x"; - break; - - case BPF_ALU|BPF_DIV|BPF_X: - op = "div"; - fmt = "x"; - break; - - case BPF_ALU|BPF_AND|BPF_X: - op = "and"; - fmt = "x"; - break; - - case BPF_ALU|BPF_OR|BPF_X: - op = "or"; - fmt = "x"; - break; - - case BPF_ALU|BPF_LSH|BPF_X: - op = "lsh"; - fmt = "x"; - break; - - case BPF_ALU|BPF_RSH|BPF_X: - op = "rsh"; - fmt = "x"; - break; - - case BPF_ALU|BPF_ADD|BPF_K: - op = "add"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_SUB|BPF_K: - op = "sub"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_MUL|BPF_K: - op = "mul"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_DIV|BPF_K: - op = "div"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_AND|BPF_K: - op = "and"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_OR|BPF_K: - op = "or"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_LSH|BPF_K: - op = "lsh"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_RSH|BPF_K: - op = "rsh"; - fmt = "#%d"; - break; - - case BPF_ALU|BPF_NEG: - op = "neg"; - fmt = ""; - break; - - case BPF_MISC|BPF_TAX: - op = "tax"; - fmt = ""; - break; - - case BPF_MISC|BPF_TXA: - op = "txa"; - fmt = ""; - break; - } - (void)sprintf(operand, fmt, v); - (void)sprintf(image, - (BPF_CLASS(p->code) == BPF_JMP && - BPF_OP(p->code) != BPF_JA) ? - "(%03d) %-8s %-16s jt %d\tjf %d" - : "(%03d) %-8s %s", - n, op, operand, n + 1 + p->jt, n + 1 + p->jf); - return image; -} diff --git a/usr.sbin/tcpdump/tcpdump/etherent.c b/usr.sbin/tcpdump/tcpdump/etherent.c deleted file mode 100644 index 9d7ee8009600..000000000000 --- a/usr.sbin/tcpdump/tcpdump/etherent.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#ifndef lint -static char rcsid[] = - "@(#) $Header: etherent.c,v 1.2 90/09/20 23:16:06 mccanne Exp $ (LBL)"; -#endif - -#include -#include -#include -#include "interface.h" - -#ifndef ETHER_SERVICE - -#include "etherent.h" - -/* Hex digit to integer. */ -static inline int -xdtoi(c) -{ - if (isdigit(c)) - return c - '0'; - else if (islower(c)) - return c - 'a' + 10; - else - return c - 'A' + 10; -} - -static inline int -skip_space(f) - FILE *f; -{ - int c; - - do { - c = getc(f); - } while (isspace(c) && c != '\n'); - - return c; -} - -static inline int -skip_line(f) - FILE *f; -{ - int c; - - do - c = getc(f); - while (c != '\n' && c != EOF); - - return c; -} - -struct etherent * -next_etherent(fp) - FILE *fp; -{ - register int c, d, i; - char *bp; - static struct etherent e; - static int nline = 1; - top: - while (nline) { - /* Find addr */ - c = skip_space(fp); - if (c == '\n') - continue; - /* If this is a comment, or first thing on line - cannot be etehrnet address, skip the line. */ - else if (!isxdigit(c)) - c = skip_line(fp); - else { - /* must be the start of an address */ - for (i = 0; i < 6; i += 1) { - d = xdtoi(c); - c = getc(fp); - if (c != ':') { - d <<= 4; - d |= xdtoi(c); - c = getc(fp); - } - e.addr[i] = d; - if (c != ':') - break; - c = getc(fp); - } - nline = 0; - } - if (c == EOF) - return 0; - } - - /* If we started a new line, 'c' holds the char past the ether addr, - which we assume is white space. If we are continuning a line, - 'c' is garbage. In either case, we can throw it away. */ - - c = skip_space(fp); - if (c == '\n') { - nline = 1; - goto top; - } - else if (c == '#') { - (void)skip_line(fp); - nline = 1; - goto top; - } - else if (c == EOF) - return 0; - - /* Must be a name. */ - bp = e.name; - /* Use 'd' to prevent buffer overflow. */ - d = sizeof(e.name) - 1; - do { - *bp++ = c; - c = getc(fp); - } while (!isspace(c) && c != EOF && --d > 0); - *bp = '\0'; - if (c == '\n') - nline = 1; - - return &e; -} - -#endif diff --git a/usr.sbin/tcpdump/tcpdump/etherent.h b/usr.sbin/tcpdump/tcpdump/etherent.h deleted file mode 100644 index 83ebaabb8647..000000000000 --- a/usr.sbin/tcpdump/tcpdump/etherent.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#) $Header: etherent.h,v 1.2 90/09/20 23:16:17 mccanne Exp $ (LBL) - */ - -/* File name of ethernet address data base. */ - -#define ETHERS_FILE "/etc/ethers" - -struct etherent { - u_char addr[6]; - char name[122]; -}; - -struct etherent *next_etherent(); - diff --git a/usr.sbin/tcpdump/tcpdump/etherproto.h b/usr.sbin/tcpdump/tcpdump/etherproto.h deleted file mode 100644 index 5c0e245cee72..000000000000 --- a/usr.sbin/tcpdump/tcpdump/etherproto.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#) $Header: etherproto.h,v 1.7 90/10/10 15:04:04 mccanne Exp $ (LBL) - */ - -/* Map between Ethernet protocol types and names */ - -/* Add other Ethernet packet types here */ -#ifndef ETHERTYPE_SPRITE -#define ETHERTYPE_SPRITE 0x0500 -#endif -#ifndef ETHERTYPE_MOPDL -#define ETHERTYPE_MOPDL 0x6001 -#endif -#ifndef ETHERTYPE_MOPRC -#define ETHERTYPE_MOPRC 0x6002 -#endif -#ifndef ETHERTYPE_DN -#define ETHERTYPE_DN 0x6003 -#endif -#ifndef ETHERTYPE_LAT -#define ETHERTYPE_LAT 0x6004 -#endif -#ifndef ETHERTYPE_LANBRIDGE -#define ETHERTYPE_LANBRIDGE 0x8038 -#endif -#ifndef ETHERTYPE_VEXP -#define ETHERTYPE_VEXP 0x805b -#endif -#ifndef ETHERTYPE_VPROD -#define ETHERTYPE_VPROD 0x805c -#endif -#ifndef ETHERTYPE_LOOPBACK -#define ETHERTYPE_LOOPBACK 0x9000 -#endif - -#ifndef ETHERTYPE_ATALK -#define ETHERTYPE_ATALK 0x809b /* XXX */ -#endif -#ifndef ETHERTYPE_AARP -#define ETHERTYPE_AARP 0x80f3 -#endif -#ifndef ETHERTYPE_NS -#define ETHERTYPE_NS 0x0600 -#endif - -struct eproto { - char *s; - u_short p; -}; - -extern struct eproto eproto_db[]; diff --git a/usr.sbin/tcpdump/tcpdump/gencode.c b/usr.sbin/tcpdump/tcpdump/gencode.c deleted file mode 100644 index 8cb48ea05483..000000000000 --- a/usr.sbin/tcpdump/tcpdump/gencode.c +++ /dev/null @@ -1,1384 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#ifndef lint -static char rcsid[] = - "@(#) $Header: gencode.c,v 1.33 92/05/22 16:38:39 mccanne Exp $ (LBL)"; -#endif - -#ifdef __STDC__ -#include -#endif -#include -#include -#include -#include -#include - -#include -#include - -#include "interface.h" -#include "gencode.h" -#include "nametoaddr.h" -#include "extract.h" - -#define JMP(c) ((c)|BPF_JMP|BPF_K) - -extern struct bpf_insn *icode_to_fcode(); -extern u_long net_mask(); -static void init_linktype(); - -static int alloc_reg(); -static void free_reg(); - -static struct block *root; - -/* - * We divy out chunks of memory rather than call malloc each time so - * we don't have to worry about leaking memory. It's probably - * not a big deal if all this memory was wasted but it this ever - * goes into a library that would probably not be a good idea. - */ -#define NCHUNKS 16 -#define CHUNK0SIZE 1024 -struct chunk { - u_int n_left; - void *m; -}; - -static struct chunk chunks[NCHUNKS]; -static int cur_chunk; - -static void * -newchunk(n) - u_int n; -{ - struct chunk *cp; - int k, size; - - /* XXX Round up to nearest long. */ - n = (n + sizeof(long) - 1) & ~(sizeof(long) - 1); - - cp = &chunks[cur_chunk]; - if (n > cp->n_left) { - ++cp, k = ++cur_chunk; - if (k >= NCHUNKS) - error("out of memory"); - size = CHUNK0SIZE << k; - cp->m = (void *)malloc(size); - bzero((char *)cp->m, size); - cp->n_left = size; - if (n > size) - error("out of memory"); - } - cp->n_left -= n; - return (void *)((char *)cp->m + cp->n_left); -} - -static void -freechunks() -{ - int i; - - for (i = 0; i < NCHUNKS; ++i) - if (chunks[i].m) - free(chunks[i].m); -} - -static inline struct block * -new_block(code) - int code; -{ - struct block *p; - - p = (struct block *)newchunk(sizeof(*p)); - p->s.code = code; - p->head = p; - - return p; -} - -static inline struct slist * -new_stmt(code) - int code; -{ - struct slist *p; - - p = (struct slist *)newchunk(sizeof(*p)); - p->s.code = code; - - return p; -} - -static struct block * -gen_retblk(v) - int v; -{ - struct block *b = new_block(BPF_RET|BPF_K); - - b->s.k = v; - return b; -} - -static inline void -syntax() -{ - error("syntax error in filter expression"); -} - -static u_long netmask; - -struct bpf_program * -parse(buf, Oflag, linktype, mask) - char *buf; - int Oflag; - int linktype; - u_long mask; -{ - extern int n_errors; - static struct bpf_program F; - struct bpf_insn *p; - int len; - - netmask = mask; - - F.bf_insns = 0; - F.bf_len = 0; - - lex_init(buf ? buf : ""); - init_linktype(linktype); - yyparse(); - - if (n_errors) - syntax(); - - if (root == 0) - root = gen_retblk(snaplen); - - if (Oflag) { - optimize(&root); - if (root == 0 || - (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0)) - error("expression rejects all packets"); - } - p = icode_to_fcode(root, &len); - F.bf_insns = p; - F.bf_len = len; - - freechunks(); - return &F; -} - -/* - * Backpatch the blocks in 'list' to 'target'. The 'sense' field indicates - * which of the jt and jf fields has been resolved and which is a pointer - * back to another unresolved block (or nil). At least one of the fields - * in each block is already resolved. - */ -static void -backpatch(list, target) - struct block *list, *target; -{ - struct block *next; - - while (list) { - if (!list->sense) { - next = JT(list); - JT(list) = target; - } else { - next = JF(list); - JF(list) = target; - } - list = next; - } -} - -/* - * Merge the lists in b0 and b1, using the 'sense' field to indicate - * which of jt and jf is the link. - */ -static void -merge(b0, b1) - struct block *b0, *b1; -{ - register struct block **p = &b0; - - /* Find end of list. */ - while (*p) - p = !((*p)->sense) ? &JT(*p) : &JF(*p); - - /* Concatenate the lists. */ - *p = b1; -} - -void -finish_parse(p) - struct block *p; -{ - backpatch(p, gen_retblk(snaplen)); - p->sense = !p->sense; - backpatch(p, gen_retblk(0)); - root = p->head; -} - -void -gen_and(b0, b1) - struct block *b0, *b1; -{ - backpatch(b0, b1->head); - b0->sense = !b0->sense; - b1->sense = !b1->sense; - merge(b1, b0); - b1->sense = !b1->sense; - b1->head = b0->head; -} - -void -gen_or(b0, b1) - struct block *b0, *b1; -{ - b0->sense = !b0->sense; - backpatch(b0, b1->head); - b0->sense = !b0->sense; - merge(b1, b0); - b1->head = b0->head; -} - -void -gen_not(b) - struct block *b; -{ - b->sense = !b->sense; -} - -static struct block * -gen_cmp(offset, size, v) - u_int offset, size; - long v; -{ - struct slist *s; - struct block *b; - - s = new_stmt(BPF_LD|BPF_ABS|size); - s->s.k = offset; - - b = new_block(JMP(BPF_JEQ)); - b->stmts = s; - b->s.k = v; - - return b; -} - -struct block * -gen_mcmp(offset, size, v, mask) - u_int offset, size; - long v; - u_long mask; -{ - struct block *b = gen_cmp(offset, size, v); - struct slist *s; - - if (mask != 0xffffffff) { - s = new_stmt(BPF_ALU|BPF_AND|BPF_K); - s->s.k = mask; - b->stmts->next = s; - } - return b; -} - -struct block * -gen_bcmp(offset, size, v) - u_int offset; - u_int size; - u_char *v; -{ - struct block *b, *tmp; - int k; - - b = 0; - while (size >= 4) { - k = size - 4; - tmp = gen_cmp(offset + k, BPF_W, EXTRACT_LONG(&v[k])); - if (b != 0) - gen_and(b, tmp); - b = tmp; - size -= 4; - } - while (size >= 2) { - k = size - 2; - tmp = gen_cmp(offset + k, BPF_H, (long)EXTRACT_SHORT(&v[k])); - if (b != 0) - gen_and(b, tmp); - b = tmp; - size -= 2; - } - if (size > 0) { - tmp = gen_cmp(offset, BPF_B, (long)v[0]); - if (b != 0) - gen_and(b, tmp); - b = tmp; - } - return b; -} - -/* - * Various code contructs need to know the layout of the data link - * layer. These variables give the necessary offsets. off_linktype - * is set to -1 for no encapsulation, in which case, IP is assumed. - */ -static u_int off_linktype; -static u_int off_nl; -static int linktype; - -static void -init_linktype(type) - int type; -{ - linktype = type; - - switch (type) { - - case DLT_EN10MB: - off_linktype = 12; - off_nl = 14; - return; - - case DLT_SLIP: - /* - * SLIP doesn't have a link level type. The 16 byte - * header is hacked into our SLIP driver. - */ - off_linktype = -1; - off_nl = 16; - return; - - case DLT_NULL: - off_linktype = -1; - off_nl = 0; - return; - - case DLT_PPP: - off_linktype = 2; - off_nl = 4; - return; - - case DLT_FDDI: - off_linktype = 19; - off_nl = 21; - return; - - case DLT_IEEE802: - off_linktype = 20; - off_nl = 22; - return; - } - error("unknown data link type 0x%x", linktype); - /* NOTREACHED */ -} - -static struct block * -gen_uncond(rsense) - int rsense; -{ - struct block *b; - struct slist *s; - - s = new_stmt(BPF_LD|BPF_IMM); - s->s.k = !rsense; - b = new_block(JMP(BPF_JEQ)); - b->stmts = s; - - return b; -} - -static inline struct block * -gen_true() -{ - return gen_uncond(1); -} - -static inline struct block * -gen_false() -{ - return gen_uncond(0); -} - -struct block * -gen_linktype(proto) - int proto; -{ - switch (linktype) { - case DLT_SLIP: - if (proto == ETHERTYPE_IP) - return gen_true(); - else - return gen_false(); - - case DLT_PPP: - if (proto == ETHERTYPE_IP) - proto = 0x0021; /* XXX - need ppp.h defs */ - break; - } - return gen_cmp(off_linktype, BPF_H, (long)proto); -} - -static struct block * -gen_hostop(addr, mask, dir, proto, src_off, dst_off) - u_long addr; - u_long mask; - int dir, proto; - u_int src_off, dst_off; -{ - struct block *b0, *b1; - u_int offset; - - switch (dir) { - - case Q_SRC: - offset = src_off; - break; - - case Q_DST: - offset = dst_off; - break; - - case Q_AND: - b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off); - b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off); - gen_and(b0, b1); - return b1; - - case Q_OR: - case Q_DEFAULT: - b0 = gen_hostop(addr, mask, Q_SRC, proto, src_off, dst_off); - b1 = gen_hostop(addr, mask, Q_DST, proto, src_off, dst_off); - gen_or(b0, b1); - return b1; - - default: - abort(); - } - b0 = gen_linktype(proto); - b1 = gen_mcmp(offset, BPF_W, (long)addr, mask); - gen_and(b0, b1); - return b1; -} - -static struct block * -gen_ehostop(eaddr, dir) - u_char *eaddr; - int dir; -{ - struct block *b0, *b1; - - switch (dir) { - case Q_SRC: - return gen_bcmp(6, 6, eaddr); - - case Q_DST: - return gen_bcmp(0, 6, eaddr); - - case Q_AND: - b0 = gen_ehostop(eaddr, Q_SRC); - b1 = gen_ehostop(eaddr, Q_DST); - gen_and(b0, b1); - return b1; - - case Q_DEFAULT: - case Q_OR: - b0 = gen_ehostop(eaddr, Q_SRC); - b1 = gen_ehostop(eaddr, Q_DST); - gen_or(b0, b1); - return b1; - } - abort(); - /* NOTREACHED */ -} - -static struct block * -gen_host(addr, mask, proto, dir) - u_long addr; - u_long mask; - int proto; - int dir; -{ - struct block *b0, *b1; - - switch (proto) { - - case Q_DEFAULT: - b0 = gen_host(addr, mask, Q_IP, dir); - b1 = gen_host(addr, mask, Q_ARP, dir); - gen_or(b0, b1); - b0 = gen_host(addr, mask, Q_RARP, dir); - gen_or(b1, b0); - return b0; - - case Q_IP: - return gen_hostop(addr, mask, dir, ETHERTYPE_IP, - off_nl + 12, off_nl + 16); - - case Q_RARP: - return gen_hostop(addr, mask, dir, ETHERTYPE_REVARP, - off_nl + 14, off_nl + 24); - - case Q_ARP: - return gen_hostop(addr, mask, dir, ETHERTYPE_ARP, - off_nl + 14, off_nl + 24); - - case Q_TCP: - error("'tcp' modifier applied to host"); - - case Q_UDP: - error("'udp' modifier applied to host"); - - case Q_ICMP: - error("'icmp' modifier applied to host"); - } - abort(); - /* NOTREACHED */ -} - -static struct block * -gen_gateway(eaddr, alist, proto, dir) - u_char *eaddr; - u_long **alist; - int proto; - int dir; -{ - struct block *b0, *b1, *tmp; - - if (dir != 0) - error("direction applied to 'gateway'"); - - switch (proto) { - case Q_DEFAULT: - case Q_IP: - case Q_ARP: - case Q_RARP: - b0 = gen_ehostop(eaddr, Q_OR); - b1 = gen_host(**alist++, 0xffffffffL, proto, Q_OR); - while (*alist) { - tmp = gen_host(**alist++, 0xffffffffL, proto, Q_OR); - gen_or(b1, tmp); - b1 = tmp; - } - gen_not(b1); - gen_and(b0, b1); - return b1; - } - error("illegal modifier of 'gateway'"); - /* NOTREACHED */ -} - -struct block * -gen_proto_abbrev(proto) - int proto; -{ - struct block *b0, *b1; - - switch (proto) { - - case Q_TCP: - b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_TCP); - gen_and(b0, b1); - break; - - case Q_UDP: - b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_UDP); - gen_and(b0, b1); - break; - - case Q_ICMP: - b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_ICMP); - gen_and(b0, b1); - break; - - case Q_IP: - b1 = gen_linktype(ETHERTYPE_IP); - break; - - case Q_ARP: - b1 = gen_linktype(ETHERTYPE_ARP); - break; - - case Q_RARP: - b1 = gen_linktype(ETHERTYPE_REVARP); - break; - - case Q_LINK: - error("link layer applied in wrong context"); - - default: - abort(); - } - return b1; -} - -static struct block * -gen_ipfrag() -{ - struct slist *s; - struct block *b; - - /* not ip frag */ - s = new_stmt(BPF_LD|BPF_H|BPF_ABS); - s->s.k = off_nl + 6; - b = new_block(JMP(BPF_JSET)); - b->s.k = 0x1fff; - b->stmts = s; - gen_not(b); - - return b; -} - -static struct block * -gen_portatom(off, v) - int off; - long v; -{ - struct slist *s; - struct block *b; - - s = new_stmt(BPF_LDX|BPF_MSH|BPF_B); - s->s.k = off_nl; - - s->next = new_stmt(BPF_LD|BPF_IND|BPF_H); - s->next->s.k = off_nl + off; - - b = new_block(JMP(BPF_JEQ)); - b->stmts = s; - b->s.k = v; - - return b; -} - -struct block * -gen_portop(port, proto, dir) - int port; - int proto; - int dir; -{ - struct block *b0, *b1, *tmp; - - /* ip proto 'proto' */ - tmp = gen_cmp(off_nl + 9, BPF_B, (long)proto); - b0 = gen_ipfrag(); - gen_and(tmp, b0); - - switch (dir) { - case Q_SRC: - b1 = gen_portatom(0, (long)port); - break; - - case Q_DST: - b1 = gen_portatom(2, (long)port); - break; - - case Q_OR: - case Q_DEFAULT: - tmp = gen_portatom(0, (long)port); - b1 = gen_portatom(2, (long)port); - gen_or(tmp, b1); - break; - - case Q_AND: - tmp = gen_portatom(0, (long)port); - b1 = gen_portatom(2, (long)port); - gen_and(tmp, b1); - break; - - default: - abort(); - } - gen_and(b0, b1); - - return b1; -} - -static struct block * -gen_port(port, ip_proto, dir) - int port; - int ip_proto; - int dir; -{ - struct block *b0, *b1, *tmp; - - /* ether proto ip */ - b0 = gen_linktype(ETHERTYPE_IP); - - switch (ip_proto) { - case IPPROTO_UDP: - case IPPROTO_TCP: - b1 = gen_portop(port, ip_proto, dir); - break; - - case PROTO_UNDEF: - tmp = gen_portop(port, IPPROTO_TCP, dir); - b1 = gen_portop(port, IPPROTO_UDP, dir); - gen_or(tmp, b1); - break; - - default: - abort(); - } - gen_and(b0, b1); - return b1; -} - -int -lookup_proto(name, proto) - char *name; - int proto; -{ - int v; - - switch (proto) { - case Q_DEFAULT: - case Q_IP: - v = s_nametoproto(name); - if (v == PROTO_UNDEF) - error("unknown ip proto '%s'", name); - break; - - case Q_LINK: - /* XXX should look up h/w protocol type based on linktype */ - v = s_nametoeproto(name); - if (v == PROTO_UNDEF) - error("unknown ether proto '%s'", name); - break; - - default: - v = PROTO_UNDEF; - break; - } - return v; -} - -struct block * -gen_proto(v, proto, dir) - int v; - int proto; - int dir; -{ - struct block *b0, *b1; - - if (dir != Q_DEFAULT) - error("direction applied to 'proto'"); - - switch (proto) { - case Q_DEFAULT: - case Q_IP: - b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)v); - gen_and(b0, b1); - return b1; - - case Q_ARP: - error("arp does not encapsulate another protocol"); - /* NOTREACHED */ - - case Q_RARP: - error("rarp does not encapsulate another protocol"); - /* NOTREACHED */ - - case Q_LINK: - return gen_linktype(v); - - case Q_UDP: - error("'udp proto' is bogus"); - - case Q_TCP: - error("'tcp proto' is bogus"); - - case Q_ICMP: - error("'icmp proto' is bogus"); - } - abort(); - /* NOTREACHED */ -} - -struct block * -gen_scode(name, q) - char *name; - struct qual q; -{ - int proto = q.proto; - int dir = q.dir; - u_char *eaddr; - u_long mask, addr, **alist; - struct block *b, *tmp; - int port, real_proto; - - switch (q.addr) { - - case Q_NET: - addr = s_nametonetaddr(name); - if (addr == 0) - error("unknown network '%s'", name); - mask = net_mask(&addr); - return gen_host(addr, mask, proto, dir); - - case Q_DEFAULT: - case Q_HOST: - if (proto == Q_LINK) { - /* XXX Should lookup hw addr based on link layer */ - eaddr = ETHER_hostton(name); - if (eaddr == 0) - error("unknown ether host '%s'", name); - return gen_ehostop(eaddr, dir); - - } else { - alist = s_nametoaddr(name); - if (alist == 0 || *alist == 0) - error("uknown host '%s'", name); - b = gen_host(**alist++, 0xffffffffL, proto, dir); - while (*alist) { - tmp = gen_host(**alist++, 0xffffffffL, - proto, dir); - gen_or(b, tmp); - b = tmp; - } - return b; - } - - case Q_PORT: - if (proto != Q_DEFAULT && proto != Q_UDP && proto != Q_TCP) - error("illegal qualifier of 'port'"); - if (s_nametoport(name, &port, &real_proto) == 0) - error("unknown port '%s'", name); - if (proto == Q_UDP) { - if (real_proto == IPPROTO_TCP) - error("port '%s' is tcp", name); - else - /* override PROTO_UNDEF */ - real_proto = IPPROTO_UDP; - } - if (proto == Q_TCP) { - if (real_proto == IPPROTO_UDP) - error("port '%s' is udp", name); - else - /* override PROTO_UNDEF */ - real_proto = IPPROTO_TCP; - } - return gen_port(port, real_proto, dir); - - case Q_GATEWAY: - eaddr = ETHER_hostton(name); - if (eaddr == 0) - error("unknown ether host: %s", name); - - alist = s_nametoaddr(name); - if (alist == 0 || *alist == 0) - error("uknown host '%s'", name); - return gen_gateway(eaddr, alist, proto, dir); - - case Q_PROTO: - real_proto = lookup_proto(name, proto); - if (real_proto >= 0) - return gen_proto(real_proto, proto, dir); - else - error("unknown protocol: %s", name); - - case Q_UNDEF: - syntax(); - /* NOTREACHED */ - } - abort(); - /* NOTREACHED */ -} - -struct block * -gen_ncode(v, q) - u_long v; - struct qual q; -{ - u_long mask; - int proto = q.proto; - int dir = q.dir; - - switch (q.addr) { - - case Q_DEFAULT: - case Q_HOST: - case Q_NET: - mask = net_mask(&v); - return gen_host(v, mask, proto, dir); - - case Q_PORT: - if (proto == Q_UDP) - proto = IPPROTO_UDP; - else if (proto == Q_TCP) - proto = IPPROTO_TCP; - else if (proto == Q_DEFAULT) - proto = PROTO_UNDEF; - else - error("illegal qualifier of 'port'"); - - return gen_port((int)v, proto, dir); - - case Q_GATEWAY: - error("'gateway' requires a name"); - /* NOTREACHED */ - - case Q_PROTO: - return gen_proto((int)v, proto, dir); - - case Q_UNDEF: - syntax(); - /* NOTREACHED */ - } - abort(); - /* NOTREACHED */ -} - -struct block * -gen_ecode(eaddr, q) - u_char *eaddr; - struct qual q; -{ - if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) - return gen_ehostop(eaddr, (int)q.dir); - else - error("ethernet address used in non-ether expression"); - /* NOTREACHED */ -} - -void -sappend(s0, s1) - struct slist *s0, *s1; -{ - /* - * This is definitely not the best way to do this, but the - * lists will rarely get long. - */ - while (s0->next) - s0 = s0->next; - s0->next = s1; -} - -struct slist * -xfer_to_x(a) - struct arth *a; -{ - struct slist *s; - - s = new_stmt(BPF_LDX|BPF_MEM); - s->s.k = a->regno; - return s; -} - -struct slist * -xfer_to_a(a) - struct arth *a; -{ - struct slist *s; - - s = new_stmt(BPF_LD|BPF_MEM); - s->s.k = a->regno; - return s; -} - -struct arth * -gen_load(proto, index, size) - int proto; - struct arth *index; - int size; -{ - struct slist *s, *tmp; - struct block *b; - int regno = alloc_reg(); - - free_reg(index->regno); - switch (size) { - - default: - error("data size must be 1, 2, or 4"); - - case 1: - size = BPF_B; - break; - - case 2: - size = BPF_H; - break; - - case 4: - size = BPF_W; - break; - } - switch (proto) { - default: - error("unsupported index operation"); - - case Q_LINK: - s = xfer_to_x(index); - tmp = new_stmt(BPF_LD|BPF_IND|size); - sappend(s, tmp); - sappend(index->s, s); - break; - - case Q_IP: - case Q_ARP: - case Q_RARP: - /* XXX Note that we assume a fixed link link header here. */ - s = xfer_to_x(index); - tmp = new_stmt(BPF_LD|BPF_IND|size); - tmp->s.k = off_nl; - sappend(s, tmp); - sappend(index->s, s); - - b = gen_proto_abbrev(proto); - if (index->b) - gen_and(index->b, b); - index->b = b; - break; - - case Q_TCP: - case Q_UDP: - case Q_ICMP: - s = new_stmt(BPF_LDX|BPF_MSH|BPF_B); - s->s.k = off_nl; - sappend(s, xfer_to_a(index)); - sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X)); - sappend(s, new_stmt(BPF_MISC|BPF_TAX)); - sappend(s, tmp = new_stmt(BPF_LD|BPF_IND|size)); - tmp->s.k = off_nl; - sappend(index->s, s); - - gen_and(gen_proto_abbrev(proto), b = gen_ipfrag()); - if (index->b) - gen_and(index->b, b); - index->b = b; - break; - } - index->regno = regno; - s = new_stmt(BPF_ST); - s->s.k = regno; - sappend(index->s, s); - - return index; -} - -struct block * -gen_relation(code, a0, a1, reversed) - int code; - struct arth *a0, *a1; - int reversed; -{ - struct slist *s0, *s1, *s2; - struct block *b, *tmp; - - s0 = xfer_to_x(a1); - s1 = xfer_to_a(a0); - s2 = new_stmt(BPF_ALU|BPF_SUB|BPF_X); - b = new_block(JMP(code)); - if (reversed) - gen_not(b); - - sappend(s1, s2); - sappend(s0, s1); - sappend(a1->s, s0); - sappend(a0->s, a1->s); - - b->stmts = a0->s; - - free_reg(a0->regno); - free_reg(a1->regno); - - /* 'and' together protocol checks */ - if (a0->b) { - if (a1->b) { - gen_and(a0->b, tmp = a1->b); - } - else - tmp = a0->b; - } else - tmp = a1->b; - - if (tmp) - gen_and(tmp, b); - - return b; -} - -struct arth * -gen_loadlen() -{ - int regno = alloc_reg(); - struct arth *a = (struct arth *)newchunk(sizeof(*a)); - struct slist *s; - - s = new_stmt(BPF_LD|BPF_LEN); - s->next = new_stmt(BPF_ST); - s->next->s.k = regno; - a->s = s; - a->regno = regno; - - return a; -} - -struct arth * -gen_loadi(val) - int val; -{ - struct arth *a; - struct slist *s; - int reg; - - a = (struct arth *)newchunk(sizeof(*a)); - - reg = alloc_reg(); - - s = new_stmt(BPF_LD|BPF_IMM); - s->s.k = val; - s->next = new_stmt(BPF_ST); - s->next->s.k = reg; - a->s = s; - a->regno = reg; - - return a; -} - -struct arth * -gen_neg(a) - struct arth *a; -{ - struct slist *s; - - s = xfer_to_a(a); - sappend(a->s, s); - s = new_stmt(BPF_ALU|BPF_NEG); - s->s.k = 0; - sappend(a->s, s); - s = new_stmt(BPF_ST); - s->s.k = a->regno; - sappend(a->s, s); - - return a; -} - -struct arth * -gen_arth(code, a0, a1) - int code; - struct arth *a0, *a1; -{ - struct slist *s0, *s1, *s2; - - s0 = xfer_to_x(a1); - s1 = xfer_to_a(a0); - s2 = new_stmt(BPF_ALU|BPF_X|code); - - sappend(s1, s2); - sappend(s0, s1); - sappend(a1->s, s0); - sappend(a0->s, a1->s); - - free_reg(a1->regno); - - s0 = new_stmt(BPF_ST); - a0->regno = s0->s.k = alloc_reg(); - sappend(a0->s, s0); - - return a0; -} - -/* - * Here we handle simple allocation of the scratch registers. - * If too many registers are alloc'd, the allocator punts. - */ -static int regused[BPF_MEMWORDS]; -static int curreg; - -/* - * Return the next free register. - */ -static int -alloc_reg() -{ - int n = BPF_MEMWORDS; - - while (--n >= 0) { - if (regused[curreg]) - curreg = (curreg + 1) % BPF_MEMWORDS; - else { - regused[curreg] = 1; - return curreg; - } - } - error("too many registers needed to evaluate expression"); - /* NOTREACHED */ -} - -/* - * Return a register to the table so it can - * be used later. - */ -static void -free_reg(n) - int n; -{ - regused[n] = 0; -} - -static struct block * -gen_len(jmp, n) - int jmp; - int n; -{ - struct slist *s; - struct block *b; - - s = new_stmt(BPF_LD|BPF_LEN); - s->next = new_stmt(BPF_SUB|BPF_IMM); - s->next->s.k = n; - b = new_block(JMP(jmp)); - b->stmts = s; - - return b; -} - -struct block * -gen_greater(n) - int n; -{ - return gen_len(BPF_JGE, n); -} - -struct block * -gen_less(n) - int n; -{ - struct block *b; - - b = gen_len(BPF_JGT, n); - gen_not(b); - - return b; -} - -struct block * -gen_byteop(op, idx, val) - int op; - int idx; - int val; -{ - struct block *b; - struct slist *s; - - switch (op) { - default: - abort(); - - case '=': - return gen_cmp((u_int)idx, BPF_B, (long)val); - - case '<': - b = gen_cmp((u_int)idx, BPF_B, (long)val); - b->s.code = JMP(BPF_JGE); - gen_not(b); - return b; - - case '>': - b = gen_cmp((u_int)idx, BPF_B, (long)val); - b->s.code = JMP(BPF_JGT); - return b; - - case '|': - s = new_stmt(BPF_ALU|BPF_AND|BPF_K); - break; - - case '&': - s = new_stmt(BPF_ALU|BPF_AND|BPF_K); - break; - } - s->s.k = val; - b = new_block(JMP(BPF_JEQ)); - b->stmts = s; - gen_not(b); - - return b; -} - -struct block * -gen_broadcast(proto) - int proto; -{ - u_long hostmask; - struct block *b0, *b1, *b2; - static u_char ebroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - - switch (proto) { - - case Q_DEFAULT: - case Q_LINK: - if (linktype == DLT_EN10MB) - return gen_ehostop(ebroadcast, Q_DST); - error("not a broadcast link"); - break; - - case Q_IP: - b0 = gen_linktype(ETHERTYPE_IP); - hostmask = ~netmask; - b1 = gen_mcmp(off_nl + 16, BPF_W, (long)0, hostmask); - b2 = gen_mcmp(off_nl + 16, BPF_W, - (long)(~0 & hostmask), hostmask); - gen_or(b1, b2); - gen_and(b0, b2); - return b2; - } - error("only ether/ip broadcast filters supported"); -} - -struct block * -gen_multicast(proto) - int proto; -{ - register struct block *b0, *b1, *b2; - register struct slist *s; - - switch (proto) { - - case Q_DEFAULT: - case Q_LINK: - if (linktype != DLT_EN10MB) - break; - - /* ether[0] & 1 != 0 */ - s = new_stmt(BPF_LD|BPF_B|BPF_ABS); - s->s.k = 0; - b0 = new_block(JMP(BPF_JSET)); - b0->s.k = 1; - b0->stmts = s; - return b0; - - case Q_IP: - b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 16, BPF_B, (long)224); - b1->s.code = JMP(BPF_JGE); - gen_and(b0, b1); - return b1; - } - error("only ether/ip multicast filters supported"); -} diff --git a/usr.sbin/tcpdump/tcpdump/gencode.h b/usr.sbin/tcpdump/tcpdump/gencode.h deleted file mode 100644 index b8f342d6b629..000000000000 --- a/usr.sbin/tcpdump/tcpdump/gencode.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#) $Header: gencode.h,v 1.14 92/02/14 15:18:55 mccanne Exp $ (LBL) - */ - -/* - * filter.h must be included before this file. - */ - -/* Address qualifers. */ - -#define Q_HOST 1 -#define Q_NET 2 -#define Q_PORT 3 -#define Q_GATEWAY 4 -#define Q_PROTO 5 - -/* Protocol qualifiers. */ - -#define Q_LINK 1 -#define Q_IP 2 -#define Q_ARP 3 -#define Q_RARP 4 -#define Q_TCP 5 -#define Q_UDP 6 -#define Q_ICMP 7 - -/* Directional qualifers. */ - -#define Q_SRC 1 -#define Q_DST 2 -#define Q_OR 3 -#define Q_AND 4 - -#define Q_DEFAULT 0 -#define Q_UNDEF 255 - -struct stmt { - int code; - long k; -}; - -struct slist { - struct stmt s; - struct slist *next; -}; - -/* - * A bit vector to represent definition sets. We assume TOT_REGISTERS - * is smaller than 8*sizeof(atomset). - */ -typedef u_long atomset; -#define ATOMMASK(n) (1 << (n)) -#define ATOMELEM(d, n) (d & ATOMMASK(n)) - -/* - * An unbounded set. - */ -typedef u_long *uset; - -/* - * Total number of atomic entities, including accumulator (A) and index (X). - * We treat all these guys similarly during flow analysis. - */ -#define N_ATOMS (BPF_MEMWORDS+2) - -struct edge { - int id; - int code; - uset edom; - struct block *succ; - struct block *pred; - struct edge *next; /* link list of incoming edges for a node */ -}; - -struct block { - int id; - struct slist *stmts; /* side effect stmts */ - struct stmt s; /* branch stmt */ - int mark; - int level; - int offset; - int sense; - struct edge et; - struct edge ef; - struct block *head; - struct block *link; /* link field used by optimizer */ - uset dom; - uset closure; - struct edge *in_edges; - atomset def, kill; - atomset in_use; - atomset out_use; - long oval; - long val[N_ATOMS]; -}; - -struct arth { - struct block *b; /* protocol checks */ - struct slist *s; /* stmt list */ - int regno; /* virtual register number of result */ -}; - -extern struct arth *gen_loadi(); -extern struct arth *gen_load(); -extern struct arth *gen_loadlen(); -extern struct arth *gen_neg(); -extern struct arth *gen_arth(); - -extern void gen_and(); -extern void gen_or(); -extern void gen_not(); - -extern struct block *gen_scode(); -extern struct block *gen_ecode(); -extern struct block *gen_ncode(); -extern struct block *gen_proto_abbrev(); -extern struct block *gen_relation(); -extern struct block *gen_less(); -extern struct block *gen_greater(); -extern struct block *gen_byteop(); -extern struct block *gen_broadcast(); -extern struct block *gen_multicast(); - -extern void optimize(); - -extern void finish_parse(); - -struct qual { - unsigned char addr; - unsigned char proto; - unsigned char dir; - unsigned char pad; -}; - -/* XXX */ -#define JT(b) ((b)->et.succ) -#define JF(b) ((b)->ef.succ) diff --git a/usr.sbin/tcpdump/tcpdump/inet.c b/usr.sbin/tcpdump/tcpdump/inet.c deleted file mode 100644 index 550129e1af55..000000000000 --- a/usr.sbin/tcpdump/tcpdump/inet.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char rcsid[] = - "@(#)$Header: inet.c,v 1.12 92/01/29 12:46:18 mccanne Exp $ (LBL)"; -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "interface.h" - -/* Not all systems have IFF_LOOPBACK */ -#ifdef IFF_LOOPBACK -#define ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK) -#else -#define ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0) -#endif - -/* - * Return the name of a network interface attached to the system, or 0 - * if none can be found. The interface must be configured up; the - * lowest unit number is preferred; loopback is ignored. - */ -char * -lookup_device() -{ - struct ifreq ibuf[16], *ifrp, *ifend, *mp; - struct ifconf ifc; - int fd; - int minunit, n; - char *cp; - static char device[sizeof(ifrp->ifr_name)]; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - perror("tcpdump: socket"); - exit(1); - } - ifc.ifc_len = sizeof ibuf; - ifc.ifc_buf = (caddr_t)ibuf; - - if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 || - ifc.ifc_len < sizeof(struct ifreq)) { - perror("tcpdump: SIOCGIFCONF: "); - exit(1); - } - ifrp = ibuf; - ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len); - - mp = 0; - minunit = 666; - while (ifrp < ifend) { - struct ifreq ifr; - /* - * Need a template to preserve address info that is - * used below to locate the next entry. (Otherwise, - * SIOCGIFFLAGS stomps over it because the requests - * are returned in a union.) - */ - bcopy(ifrp->ifr_name, ifr.ifr_name, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { - fprintf(stderr, "tcpdump: SIOCGIFFLAGS: "); - perror(ifrp->ifr_name); - exit(1); - } - if ((ifr.ifr_flags & IFF_UP) && !ISLOOPBACK(&ifr)) { - for (cp = ifrp->ifr_name; !isdigit(*cp); ++cp) - ; - n = atoi(cp); - if (n < minunit) { - minunit = n; - mp = ifrp; - } - } -#if BSD >= 199006 - n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name); - if (n < sizeof(*ifrp)) - ++ifrp; - else - ifrp = (struct ifreq *)((char *)ifrp + n); -#else - ++ifrp; -#endif - } - close(fd); - if (mp == 0) - return (0); - - (void)strcpy(device, mp->ifr_name); - return (device); -} - -/* - * Get the netmask of an IP address. This routine is used if - * SIOCGIFNETMASK doesn't work. - */ -static u_long -ipaddrtonetmask(addr) - u_long addr; -{ - if (IN_CLASSA(addr)) - return (IN_CLASSA_NET); - if (IN_CLASSB(addr)) - return (IN_CLASSB_NET); - if (IN_CLASSC(addr)) - return (IN_CLASSC_NET); - error("unknown IP address class: %08X", addr); - /* NOTREACHED */ -} - -void -lookup_net(device, netp, maskp) - char *device; - u_long *netp; - u_long *maskp; -{ - int fd; - struct ifreq ifr; - struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr; - - /* Use data gram socket to get IP address. */ - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("tcpdump: socket"); - exit(1); - } - (void)strncpy(ifr.ifr_name, device, sizeof ifr.ifr_name); - if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { - /* - * This will fail if an IP address hasn't been assigned. - */ - *netp = 0; - *maskp = 0; - return; - } - *netp = sin->sin_addr.s_addr; - if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) - *maskp = 0; - else - *maskp = sin->sin_addr.s_addr; - if (*maskp == 0) - *maskp = ipaddrtonetmask(*netp); - *netp &= *maskp; - (void)close(fd); -} diff --git a/usr.sbin/tcpdump/tcpdump/md.c b/usr.sbin/tcpdump/tcpdump/md.c deleted file mode 100644 index 6bb04b72cade..000000000000 --- a/usr.sbin/tcpdump/tcpdump/md.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char rcsid[] = - "@(#) $Header: md-vax.c,v 1.3 90/10/03 14:14:33 mccanne Locked $ (LBL)"; -#endif - -/* Vaxen appear to have clocks accurate to 1 us, - but packetfilter is timestamping to 10 ms. */ - -int -clock_sigfigs() -{ - return 2; -} - diff --git a/usr.sbin/tcpdump/tcpdump/nametoaddr.c b/usr.sbin/tcpdump/tcpdump/nametoaddr.c deleted file mode 100644 index 6f2330f141c1..000000000000 --- a/usr.sbin/tcpdump/tcpdump/nametoaddr.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Name to id translation routines used by the scanner. - * These functions are not time critical. - */ - -#ifndef lint -static char rcsid[] = - "@(#) $Header: nametoaddr.c,v 1.9 91/02/04 16:56:46 mccanne Exp $ (LBL)"; -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ultrix -#include -#include -#include -#endif - -#include "interface.h" -#include "etherent.h" -#include "nametoaddr.h" - -/* - * Convert host name to internet address. - * Return 0 upon failure. - */ -u_long ** -s_nametoaddr(name) - char *name; -{ -#ifndef h_addr - static u_long *hlist[2]; -#endif - u_long **p; - struct hostent *hp; - - if (hp = gethostbyname(name)) { -#ifndef h_addr - hlist[0] = (u_long *)hp->h_addr; - NTOHL(hp->h_addr); - return hlist; -#else - for (p = (u_long **)hp->h_addr_list; *p; ++p) - NTOHL(**p); - return (u_long **)hp->h_addr_list; -#endif - } - else - return 0; -} - -/* - * Convert net name to internet address. - * Return 0 upon failure. - */ -u_long -s_nametonetaddr(name) - char *name; -{ - struct netent *np; - - if (np = getnetbyname(name)) - return np->n_net; - else - return 0; -} - -/* - * Convert a port name to its port and protocol numbers. - * We assume only TCP or UDP. - * Return 0 upon failure. - */ -s_nametoport(name, port, proto) - char *name; - int *port; - int *proto; -{ - struct servent *sp; - char *other; - - sp = getservbyname(name, (char *)0); - if (sp != 0) { - NTOHS(sp->s_port); - *port = sp->s_port; - *proto = s_nametoproto(sp->s_proto); - /* - * We need to check /etc/services for ambiguous entries. - * If we find the ambiguous entry, and it has the - * same port number, change the proto to PROTO_UNDEF - * so both TCP and UDP will be checked. - */ - if (*proto == IPPROTO_TCP) - other = "udp"; - else - other = "tcp"; - - sp = getservbyname(name, other); - if (sp != 0) { - NTOHS(sp->s_port); - if (*port != sp->s_port) - /* Can't handle ambigous names that refer - to different port numbers. */ - warning("ambiguous port %s in /etc/services", - name); - *proto = PROTO_UNDEF; - } - return 1; - } -#ifdef ultrix - /* Special hack in case NFS isn't in /etc/services */ - if (strcmp(name, "nfs") == 0) { - *port = NFS_PORT; - *proto = PROTO_UNDEF; - return 1; - } -#endif - return 0; -} - -int -s_nametoproto(str) - char *str; -{ - struct protoent *p; - - p = getprotobyname(str); - if (p != 0) - return p->p_proto; - else - return PROTO_UNDEF; -} - -#include "etherproto.h" - -int -s_nametoeproto(s) - char *s; -{ - struct eproto *p = eproto_db; - - while (p->s != 0) { - if (strcmp(p->s, s) == 0) - return p->p; - p += 1; - } - return PROTO_UNDEF; -} - -/* Hex digit to integer. */ -static inline int -xdtoi(c) -{ - if (isdigit(c)) - return c - '0'; - else if (islower(c)) - return c - 'a' + 10; - else - return c - 'A' + 10; -} - -u_long -atoin(s) - char *s; -{ - u_long addr = 0; - u_int n; - - while (1) { - n = 0; - while (*s && *s != '.') - n = n * 10 + *s++ - '0'; - addr <<= 8; - addr |= n & 0xff; - if (*s == '\0') - return addr; - ++s; - } - /* NOTREACHED */ -} - - -/* - * Convert 's' which has the form "xx:xx:xx:xx:xx:xx" into a new - * ethernet address. Assumes 's' is well formed. - */ -u_char * -ETHER_aton(s) - char *s; -{ - register u_char *ep, *e; - register u_int d; - - e = ep = (u_char *)malloc(6); - - while (*s) { - if (*s == ':') - s += 1; - d = xdtoi(*s++); - if (isxdigit(*s)) { - d <<= 4; - d |= xdtoi(*s++); - } - *ep++ = d; - } - - return e; -} - -#ifndef ETHER_SERVICE -u_char * -ETHER_hostton(name) - char *name; -{ - struct etherent *ep; - FILE *fp; - u_char *ap; - - fp = fopen(ETHERS_FILE, "r"); - if (fp != 0) { - while (ep = next_etherent(fp)) { - if (strcmp(ep->name, name) == 0) { - ap = (u_char *)malloc(6); - bcopy(ep->addr, ap, 6); - return ap; - } - } - } - return (u_char *)0; -} -#endif diff --git a/usr.sbin/tcpdump/tcpdump/nametoaddr.h b/usr.sbin/tcpdump/tcpdump/nametoaddr.h deleted file mode 100644 index 23da3f2580f7..000000000000 --- a/usr.sbin/tcpdump/tcpdump/nametoaddr.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#) $Header: nametoaddr.h,v 1.6 90/09/24 12:50:41 mccanne Exp $ (LBL) - * - * Address to name translation routines. - */ - -extern u_long **s_nametoaddr(); -extern u_long s_nametonetaddr(); - -extern int s_nametoport(); -extern int s_nametoproto(); -extern int s_nametoeproto(); - -extern u_char *ETHER_hostton(); -extern u_char *ETHER_aton(); - -/* - * If a protocol is unknown, PROTO_UNDEF is returned. - * Also, s_nametoport() returns the protocol along with the port number. - * If there are ambiguous entried in /etc/services (i.e. domain - * can be either tcp or udp) PROTO_UNDEF is returned. - */ -#define PROTO_UNDEF -1 - diff --git a/usr.sbin/tcpdump/tcpdump/optimize.c b/usr.sbin/tcpdump/tcpdump/optimize.c deleted file mode 100644 index 50640112fb05..000000000000 --- a/usr.sbin/tcpdump/tcpdump/optimize.c +++ /dev/null @@ -1,1871 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Optimization module for tcpdump intermediate representation. - */ -#ifndef lint -static char rcsid[] = - "@(#) $Header: optimize.c,v 1.35 91/07/18 09:27:55 mccanne Exp $ (LBL)"; -#endif - -#include -#include - -#include -#include - -#include "interface.h" -#include "gencode.h" - -#define A_ATOM BPF_MEMWORDS -#define X_ATOM (BPF_MEMWORDS+1) - -#define NOP -1 - -/* - * This define is used to represent *both* the accumulator and - * x register in use-def computations. - * Currently, the use-def code assumes only one definition per instruction. - */ -#define AX_ATOM N_ATOMS - -/* - * A flag to indicate that further optimization is needed. - * Iterative passes are continued until a given pass yields no - * branch movement. - */ -static int done; - -/* - * A block is marked if only if its mark equals the current mark. - * Rather than traverse the code array, marking each item, 'cur_mark' is - * incremented. This automatically makes each element unmarked. - */ -static int cur_mark; -#define isMarked(p) ((p)->mark == cur_mark) -#define unMarkAll() cur_mark += 1 -#define Mark(p) ((p)->mark = cur_mark) - -static void opt_init(); -static void opt_cleanup(); - -static void make_marks(); -static void mark_code(); - -static void intern_blocks(); - -static int eq_slist(); - -static int n_blocks; -struct block **blocks; -static int n_edges; -struct edge **edges; - -/* - * A bit vector set representation of the dominators. - * We round up the set size to the next power of two. - */ -static int nodewords; -static int edgewords; -struct block **levels; -u_long *space; -#define BITS_PER_WORD (8*sizeof(u_long)) -/* - * True if a is in uset {p} - */ -#define SET_MEMBER(p, a) \ -((p)[(unsigned)(a) / BITS_PER_WORD] & (1 << ((unsigned)(a) % BITS_PER_WORD))) - -/* - * Add 'a' to uset p. - */ -#define SET_INSERT(p, a) \ -(p)[(unsigned)(a) / BITS_PER_WORD] |= (1 << ((unsigned)(a) % BITS_PER_WORD)) - -/* - * Delete 'a' from uset p. - */ -#define SET_DELETE(p, a) \ -(p)[(unsigned)(a) / BITS_PER_WORD] &= ~(1 << ((unsigned)(a) % BITS_PER_WORD)) - -/* - * a := a intersect b - */ -#define SET_INTERSECT(a, b, n)\ -{\ - register u_long *_x = a, *_y = b;\ - register int _n = n;\ - while (--_n >= 0) *_x++ &= *_y++;\ -} - -/* - * a := a - b - */ -#define SET_SUBTRACT(a, b, n)\ -{\ - register u_long *_x = a, *_y = b;\ - register int _n = n;\ - while (--_n >= 0) *_x++ &=~ *_y++;\ -} - -/* - * a := a union b - */ -#define SET_UNION(a, b, n)\ -{\ - register u_long *_x = a, *_y = b;\ - register int _n = n;\ - while (--_n >= 0) *_x++ |= *_y++;\ -} - -static uset all_dom_sets; -static uset all_closure_sets; -static uset all_edge_sets; - -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -static void -find_levels_r(b) - struct block *b; -{ - int level; - - if (isMarked(b)) - return; - - Mark(b); - b->link = 0; - - if (JT(b)) { - find_levels_r(JT(b)); - find_levels_r(JF(b)); - level = MAX(JT(b)->level, JF(b)->level) + 1; - } else - level = 0; - b->level = level; - b->link = levels[level]; - levels[level] = b; -} - -/* - * Level graph. The levels go from 0 at the leaves to - * N_LEVELS at the root. The levels[] array points to the - * first node of the level list, whose elements are linked - * with the 'link' field of the struct block. - */ -static void -find_levels(root) - struct block *root; -{ - bzero((char *)levels, n_blocks * sizeof(*levels)); - unMarkAll(); - find_levels_r(root); -} - -/* - * Find dominator relationships. - * Assumes graph has been leveled. - */ -static void -find_dom(root) - struct block *root; -{ - int i; - struct block *b; - u_long *x; - - /* - * Initialize sets to contain all nodes. - */ - x = all_dom_sets; - i = n_blocks * nodewords; - while (--i >= 0) - *x++ = ~0; - /* Root starts off empty. */ - for (i = nodewords; --i >= 0;) - root->dom[i] = 0; - - /* root->level is the highest level no found. */ - for (i = root->level; i >= 0; --i) { - for (b = levels[i]; b; b = b->link) { - SET_INSERT(b->dom, b->id); - if (JT(b) == 0) - continue; - SET_INTERSECT(JT(b)->dom, b->dom, nodewords); - SET_INTERSECT(JF(b)->dom, b->dom, nodewords); - } - } -} - -static void -propedom(ep) - struct edge *ep; -{ - SET_INSERT(ep->edom, ep->id); - if (ep->succ) { - SET_INTERSECT(ep->succ->et.edom, ep->edom, edgewords); - SET_INTERSECT(ep->succ->ef.edom, ep->edom, edgewords); - } -} - -/* - * Compute edge dominators. - * Assumes graph has been leveled and predecessors estabished. - */ -static void -find_edom(root) - struct block *root; -{ - int i; - uset x; - struct block *b; - - x = all_edge_sets; - for (i = n_edges * edgewords; --i >= 0; ) - x[i] = ~0; - - /* root->level is the highest level no found. */ - bzero(root->et.edom, edgewords * sizeof(*(uset)0)); - bzero(root->ef.edom, edgewords * sizeof(*(uset)0)); - for (i = root->level; i >= 0; --i) { - for (b = levels[i]; b != 0; b = b->link) { - propedom(&b->et); - propedom(&b->ef); - } - } -} - -/* - * Find the backwards transitive closure of the flow graph. These sets - * are backwards in the sense that we find the set of nodes that reach - * a given node, not the set of nodes that can be reached by a node. - * - * Assumes graph has been leveled. - */ -static void -find_closure(root) - struct block *root; -{ - int i; - struct block *b; - - /* - * Initialize sets to contain no nodes. - */ - bzero((char *)all_closure_sets, - n_blocks * nodewords * sizeof(*all_closure_sets)); - - /* root->level is the highest level no found. */ - for (i = root->level; i >= 0; --i) { - for (b = levels[i]; b; b = b->link) { - SET_INSERT(b->closure, b->id); - if (JT(b) == 0) - continue; - SET_UNION(JT(b)->closure, b->closure, nodewords); - SET_UNION(JF(b)->closure, b->closure, nodewords); - } - } -} - -/* - * Return the register number that is used by s. If A and X are both - * used, return AX_ATOM. If no register is used, return -1. - * - * The implementation should probably change to an array access. - */ -static int -atomuse(s) - struct stmt *s; -{ - register int c = s->code; - - if (c == NOP) - return -1; - - switch (BPF_CLASS(c)) { - - case BPF_RET: - return (BPF_RVAL(c) == BPF_A) ? A_ATOM : - (BPF_RVAL(c) == BPF_X) ? X_ATOM : -1; - - case BPF_LD: - case BPF_LDX: - return (BPF_MODE(c) == BPF_IND) ? X_ATOM : - (BPF_MODE(c) == BPF_MEM) ? s->k : -1; - - case BPF_ST: - return A_ATOM; - - case BPF_STX: - return X_ATOM; - - case BPF_JMP: - case BPF_ALU: - if (BPF_SRC(c) == BPF_X) - return AX_ATOM; - return A_ATOM; - - case BPF_MISC: - return BPF_MISCOP(c) == BPF_TXA ? X_ATOM : A_ATOM; - } - abort(); - /* NOTREACHED */ -} - -/* - * Return the register number that is defined by 's'. We assume that - * a single stmt cannot define more than one register. If no register - * is defined, return -1. - * - * The implementation should probably change to an array access. - */ -static int -atomdef(s) - struct stmt *s; -{ - if (s->code == NOP) - return -1; - - switch (BPF_CLASS(s->code)) { - - case BPF_LD: - case BPF_ALU: - return A_ATOM; - - case BPF_LDX: - return X_ATOM; - - case BPF_ST: - case BPF_STX: - return s->k; - - case BPF_MISC: - return BPF_MISCOP(s->code) == BPF_TAX ? X_ATOM : A_ATOM; - } - return -1; -} - -static void -compute_local_ud(b) - struct block *b; -{ - struct slist *s; - atomset def = 0, use = 0, kill = 0; - int atom; - - for (s = b->stmts; s; s = s->next) { - if (s->s.code == NOP) - continue; - atom = atomuse(&s->s); - if (atom >= 0) { - if (atom == AX_ATOM) { - if (!ATOMELEM(def, X_ATOM)) - use |= ATOMMASK(X_ATOM); - if (!ATOMELEM(def, A_ATOM)) - use |= ATOMMASK(A_ATOM); - } - else if (atom < N_ATOMS) { - if (!ATOMELEM(def, atom)) - use |= ATOMMASK(atom); - } - else - abort(); - } - atom = atomdef(&s->s); - if (atom >= 0) { - if (!ATOMELEM(atom, use)) - kill |= ATOMMASK(atom); - def |= ATOMMASK(atom); - } - } - if (!ATOMELEM(def, A_ATOM) && BPF_CLASS(b->s.code) == BPF_JMP) - use |= ATOMMASK(A_ATOM); - - b->def = def; - b->kill = kill; - b->in_use = use; -} - -/* - * Assume graph is already leveled. - */ -static void -find_ud(root) - struct block *root; -{ - int i, maxlevel; - struct block *p; - - /* - * root->level is the highest level no found; - * count down from there. - */ - maxlevel = root->level; - for (i = maxlevel; i >= 0; --i) - for (p = levels[i]; p; p = p->link) { - compute_local_ud(p); - p->out_use = 0; - } - - for (i = 1; i <= maxlevel; ++i) { - for (p = levels[i]; p; p = p->link) { - p->out_use |= JT(p)->in_use | JF(p)->in_use; - p->in_use |= p->out_use &~ p->kill; - } - } -} - -/* - * These data structures are used in a Cocke and Shwarz style - * value numbering scheme. Since the flowgraph is acyclic, - * exit values can be propagated from a node's predecessors - * provided it is uniquely defined. - */ -struct valnode { - int code; - long v0, v1; - long val; - struct valnode *next; -}; - -#define MODULUS 213 -static struct valnode *hashtbl[MODULUS]; -static int curval; -static int maxval; - -/* Integer constants mapped with the load immediate opcode. */ -#define K(i) F(BPF_LD|BPF_IMM|BPF_W, i, 0L) - -struct vmapinfo { - int is_const; - long const_val; -}; - -struct vmapinfo *vmap; -struct valnode *vnode_base; -struct valnode *next_vnode; - -static void -init_val() -{ - curval = 0; - next_vnode = vnode_base; - bzero((char *)vmap, maxval * sizeof(*vmap)); - bzero((char *)hashtbl, sizeof hashtbl); -} - -/* Because we really don't have an IR, this stuff is a little messy. */ -static long -F(code, v0, v1) - int code; - long v0, v1; -{ - u_int hash; - int val; - struct valnode *p; - - hash = (u_int)code ^ (v0 << 4) ^ (v1 << 8); - hash %= MODULUS; - - for (p = hashtbl[hash]; p; p = p->next) - if (p->code == code && p->v0 == v0 && p->v1 == v1) - return p->val; - - val = ++curval; - if (BPF_MODE(code) == BPF_IMM && - (BPF_CLASS(code) == BPF_LD || BPF_CLASS(code) == BPF_LDX)) { - vmap[val].const_val = v0; - vmap[val].is_const = 1; - } - p = next_vnode++; - p->val = val; - p->code = code; - p->v0 = v0; - p->v1 = v1; - p->next = hashtbl[hash]; - hashtbl[hash] = p; - - return val; -} - -static inline void -vstore(s, valp, newval, alter) - struct stmt *s; - long *valp; - long newval; - int alter; -{ - if (alter && *valp == newval) - s->code = NOP; - else - *valp = newval; -} - -static void -fold_op(s, v0, v1) - struct stmt *s; - long v0, v1; -{ - long a, b; - - a = vmap[v0].const_val; - b = vmap[v1].const_val; - - switch (BPF_OP(s->code)) { - case BPF_ADD: - a += b; - break; - - case BPF_SUB: - a -= b; - break; - - case BPF_MUL: - a *= b; - break; - - case BPF_DIV: - if (b == 0) - error("division by zero"); - a /= b; - break; - - case BPF_AND: - a &= b; - break; - - case BPF_OR: - a |= b; - break; - - case BPF_LSH: - a <<= b; - break; - - case BPF_RSH: - a >>= b; - break; - - case BPF_NEG: - a = -a; - break; - - default: - abort(); - } - s->k = a; - s->code = BPF_LD|BPF_IMM; - done = 0; -} - -static inline struct slist * -this_op(s) - struct slist *s; -{ - while (s != 0 && s->s.code == NOP) - s = s->next; - return s; -} - -static void -opt_not(b) - struct block *b; -{ - struct block *tmp = JT(b); - - JT(b) = JF(b); - JF(b) = tmp; -} - -static void -opt_peep(b) - struct block *b; -{ - struct slist *s; - struct slist *next, *last; - int val; - long v; - - s = b->stmts; - if (s == 0) - return; - - last = s; - while (1) { - s = this_op(s); - if (s == 0) - break; - next = this_op(s->next); - if (next == 0) - break; - last = next; - - /* - * st M[k] --> st M[k] - * ldx M[k] tax - */ - if (s->s.code == BPF_ST && - next->s.code == (BPF_LDX|BPF_MEM) && - s->s.k == next->s.k) { - done = 0; - next->s.code = BPF_MISC|BPF_TAX; - } - /* - * ld #k --> ldx #k - * tax txa - */ - if (s->s.code == (BPF_LD|BPF_IMM) && - next->s.code == (BPF_MISC|BPF_TAX)) { - s->s.code = BPF_LDX|BPF_IMM; - next->s.code = BPF_MISC|BPF_TXA; - done = 0; - } - /* - * This is an ugly special case, but it happens - * when you say tcp[k] or udp[k] where k is a constant. - */ - if (s->s.code == (BPF_LD|BPF_IMM)) { - struct slist *add, *tax, *ild; - - /* - * Check that X isn't used on exit from this - * block (which the optimizer might cause). - * We know the code generator won't generate - * any local dependencies. - */ - if (ATOMELEM(b->out_use, X_ATOM)) - break; - - if (next->s.code != (BPF_LDX|BPF_MSH|BPF_B)) - add = next; - else - add = this_op(next->next); - if (add == 0 || add->s.code != (BPF_ALU|BPF_ADD|BPF_X)) - break; - - tax = this_op(add->next); - if (tax == 0 || tax->s.code != (BPF_MISC|BPF_TAX)) - break; - - ild = this_op(tax->next); - if (ild == 0 || BPF_CLASS(ild->s.code) != BPF_LD || - BPF_MODE(ild->s.code) != BPF_IND) - break; - /* - * XXX We need to check that X is not - * subsequently used. We know we can eliminate the - * accumulator modifications since it is defined - * by the last stmt of this sequence. - * - * We want to turn this sequence: - * - * (004) ldi #0x2 {s} - * (005) ldxms [14] {next} -- optional - * (006) addx {add} - * (007) tax {tax} - * (008) ild [x+0] {ild} - * - * into this sequence: - * - * (004) nop - * (005) ldxms [14] - * (006) nop - * (007) nop - * (008) ild [x+2] - * - */ - ild->s.k += s->s.k; - s->s.code = NOP; - add->s.code = NOP; - tax->s.code = NOP; - done = 0; - } - s = next; - } - /* - * If we have a subtract to do a comparsion, and the X register - * is a known constant, we can merge this value into the - * comparison. - */ - if (last->s.code == (BPF_ALU|BPF_SUB|BPF_X) && - !ATOMELEM(b->out_use, A_ATOM)) { - val = b->val[X_ATOM]; - if (vmap[val].is_const) { - b->s.k += vmap[val].const_val; - last->s.code = NOP; - done = 0; - } else if (b->s.k == 0) { - /* - * sub x -> nop - * j #0 j x - */ - last->s.code = NOP; - b->s.code = BPF_CLASS(b->s.code) | BPF_OP(b->s.code) | - BPF_X; - done = 0; - } - } - /* - * Likewise, a constant subtract can be simplified. - */ - else if (last->s.code == (BPF_ALU|BPF_SUB|BPF_K) && - !ATOMELEM(b->out_use, A_ATOM)) { - b->s.k += last->s.k; - last->s.code = NOP; - done = 0; - } - /* - * and #k nop - * jeq #0 -> jset #k - */ - if (last->s.code == (BPF_ALU|BPF_AND|BPF_K) && - !ATOMELEM(b->out_use, A_ATOM) && b->s.k == 0) { - b->s.k = last->s.k; - b->s.code = BPF_JMP|BPF_K|BPF_JSET; - last->s.code = NOP; - done = 0; - opt_not(b); - } - /* - * If the accumulator is a known constant, we can compute the - * comparison result. - */ - val = b->val[A_ATOM]; - if (vmap[val].is_const && BPF_SRC(b->s.code) == BPF_K) { - v = vmap[val].const_val; - switch (BPF_OP(b->s.code)) { - - case BPF_JEQ: - v = v == b->s.k; - break; - - case BPF_JGT: - v = v > b->s.k; - break; - - case BPF_JGE: - v = v >= b->s.k; - break; - - case BPF_JSET: - v &= b->s.k; - break; - - default: - abort(); - } - if (JF(b) != JT(b)) - done = 0; - if (v) - JF(b) = JT(b); - else - JT(b) = JF(b); - } -} - -/* - * Compute the symbolic value of expression of 's', and update - * anything it defines in the value table 'val'. If 'alter' is true, - * do various optimizations. This code would be cleaner if symblic - * evaluation and code transformations weren't folded together. - */ -static void -opt_stmt(s, val, alter) - struct stmt *s; - long val[]; - int alter; -{ - int op; - long v; - - switch (s->code) { - - case BPF_LD|BPF_ABS|BPF_W: - case BPF_LD|BPF_ABS|BPF_H: - case BPF_LD|BPF_ABS|BPF_B: - v = F(s->code, s->k, 0L); - vstore(s, &val[A_ATOM], v, alter); - break; - - case BPF_LD|BPF_IND|BPF_W: - case BPF_LD|BPF_IND|BPF_H: - case BPF_LD|BPF_IND|BPF_B: - v = val[X_ATOM]; - if (alter && vmap[v].is_const) { - s->code = BPF_LD|BPF_ABS|BPF_SIZE(s->code); - s->k += vmap[v].const_val; - v = F(s->code, s->k, 0L); - done = 0; - } - else - v = F(s->code, s->k, v); - vstore(s, &val[A_ATOM], v, alter); - break; - - case BPF_LD|BPF_LEN: - v = F(s->code, 0L, 0L); - vstore(s, &val[A_ATOM], v, alter); - break; - - case BPF_LD|BPF_IMM: - v = K(s->k); - vstore(s, &val[A_ATOM], v, alter); - break; - - case BPF_LDX|BPF_IMM: - v = K(s->k); - vstore(s, &val[X_ATOM], v, alter); - break; - - case BPF_LDX|BPF_MSH|BPF_B: - v = F(s->code, s->k, 0L); - vstore(s, &val[X_ATOM], v, alter); - break; - - case BPF_ALU|BPF_NEG: - if (alter && vmap[val[A_ATOM]].is_const) { - s->code = BPF_LD|BPF_IMM; - s->k = -vmap[val[A_ATOM]].const_val; - val[A_ATOM] = K(s->k); - } - else - val[A_ATOM] = F(s->code, val[A_ATOM], 0L); - break; - - case BPF_ALU|BPF_ADD|BPF_K: - case BPF_ALU|BPF_SUB|BPF_K: - case BPF_ALU|BPF_MUL|BPF_K: - case BPF_ALU|BPF_DIV|BPF_K: - case BPF_ALU|BPF_AND|BPF_K: - case BPF_ALU|BPF_OR|BPF_K: - case BPF_ALU|BPF_LSH|BPF_K: - case BPF_ALU|BPF_RSH|BPF_K: - op = BPF_OP(s->code); - if (alter) { - if (s->k == 0) { - if (op == BPF_ADD || op == BPF_SUB || - op == BPF_LSH || op == BPF_RSH || - op == BPF_OR) { - s->code = NOP; - break; - } - if (op == BPF_MUL || op == BPF_AND) { - s->code = BPF_LD|BPF_IMM; - val[A_ATOM] = K(s->k); - break; - } - } - if (vmap[val[A_ATOM]].is_const) { - fold_op(s, val[A_ATOM], K(s->k)); - val[A_ATOM] = K(s->k); - break; - } - } - val[A_ATOM] = F(s->code, val[A_ATOM], K(s->k)); - break; - - case BPF_ALU|BPF_ADD|BPF_X: - case BPF_ALU|BPF_SUB|BPF_X: - case BPF_ALU|BPF_MUL|BPF_X: - case BPF_ALU|BPF_DIV|BPF_X: - case BPF_ALU|BPF_AND|BPF_X: - case BPF_ALU|BPF_OR|BPF_X: - case BPF_ALU|BPF_LSH|BPF_X: - case BPF_ALU|BPF_RSH|BPF_X: - op = BPF_OP(s->code); - if (alter && vmap[val[X_ATOM]].is_const) { - if (vmap[val[A_ATOM]].is_const) { - fold_op(s, val[A_ATOM], val[X_ATOM]); - val[A_ATOM] = K(s->k); - } - else { - s->code = BPF_ALU|BPF_K|op; - s->k = vmap[val[X_ATOM]].const_val; - done = 0; - val[A_ATOM] = - F(s->code, val[A_ATOM], K(s->k)); - } - break; - } - /* - * Check if we're doing something to an accumulator - * that is 0, and simplify. This may not seem like - * much of a simplification but it could open up further - * optimizations. - * XXX We could also check for mul by 1, and -1, etc. - */ - if (alter && vmap[val[A_ATOM]].is_const - && vmap[val[A_ATOM]].const_val == 0) { - if (op == BPF_ADD || op == BPF_OR || - op == BPF_LSH || op == BPF_RSH || op == BPF_SUB) { - s->code = BPF_MISC|BPF_TXA; - vstore(s, &val[A_ATOM], val[X_ATOM], alter); - break; - } - else if (op == BPF_MUL || op == BPF_DIV || - op == BPF_AND) { - s->code = BPF_LD|BPF_IMM; - s->k = 0; - vstore(s, &val[A_ATOM], K(s->k), alter); - break; - } - else if (op == BPF_NEG) { - s->code = NOP; - break; - } - } - val[A_ATOM] = F(s->code, val[A_ATOM], val[X_ATOM]); - break; - - case BPF_MISC|BPF_TXA: - vstore(s, &val[A_ATOM], val[X_ATOM], alter); - break; - - case BPF_LD|BPF_MEM: - v = val[s->k]; - if (alter && vmap[v].is_const) { - s->code = BPF_LD|BPF_IMM; - s->k = vmap[v].const_val; - done = 0; - } - vstore(s, &val[A_ATOM], v, alter); - break; - - case BPF_MISC|BPF_TAX: - vstore(s, &val[X_ATOM], val[A_ATOM], alter); - break; - - case BPF_LDX|BPF_MEM: - v = val[s->k]; - if (alter && vmap[v].is_const) { - s->code = BPF_LDX|BPF_IMM; - s->k = vmap[v].const_val; - done = 0; - } - vstore(s, &val[X_ATOM], v, alter); - break; - - case BPF_ST: - vstore(s, &val[s->k], val[A_ATOM], alter); - break; - - case BPF_STX: - vstore(s, &val[s->k], val[X_ATOM], alter); - break; - } -} - -static void -deadstmt(s, last) - register struct stmt *s; - register struct stmt *last[]; -{ - register int atom; - - atom = atomuse(s); - if (atom >= 0) { - if (atom == AX_ATOM) { - last[X_ATOM] = 0; - last[A_ATOM] = 0; - } - else - last[atom] = 0; - } - atom = atomdef(s); - if (atom >= 0) { - if (last[atom]) { - done = 0; - last[atom]->code = NOP; - } - last[atom] = s; - } -} - -static void -opt_deadstores(b) - register struct block *b; -{ - register struct slist *s; - register int atom; - struct stmt *last[N_ATOMS]; - - bzero((char *)last, sizeof last); - - for (s = b->stmts; s != 0; s = s->next) - deadstmt(&s->s, last); - deadstmt(&b->s, last); - - for (atom = 0; atom < N_ATOMS; ++atom) - if (last[atom] && !ATOMELEM(b->out_use, atom)) { - last[atom]->code = NOP; - done = 0; - } -} - -static void -opt_blk(b, do_stmts) - struct block *b; -{ - struct slist *s; - struct edge *p; - int i; - long aval; - - /* - * Initialize the atom values. - * If we have no predecessors, everything is undefined. - * Otherwise, we inherent our values from our predecessors. - * If any register has an ambiguous value (i.e. control paths are - * merging) give it the undefined value of 0. - */ - p = b->in_edges; - if (p == 0) - bzero((char *)b->val, sizeof(b->val)); - else { - bcopy((char *)p->pred->val, (char *)b->val, sizeof(b->val)); - while (p = p->next) { - for (i = 0; i < N_ATOMS; ++i) - if (b->val[i] != p->pred->val[i]) - b->val[i] = 0; - } - } - aval = b->val[A_ATOM]; - for (s = b->stmts; s; s = s->next) - opt_stmt(&s->s, b->val, do_stmts); - - /* - * This is a special case: if we don't use anything from this - * block, and we load the accumulator with value that is - * already there, eliminate all the statements. - */ - if (do_stmts && b->out_use == 0 && aval != 0 && - b->val[A_ATOM] == aval) - b->stmts = 0; - else { - opt_peep(b); - opt_deadstores(b); - } - /* - * Set up values for branch optimizer. - */ - if (BPF_SRC(b->s.code) == BPF_K) - b->oval = K(b->s.k); - else - b->oval = b->val[X_ATOM]; - b->et.code = b->s.code; - b->ef.code = -b->s.code; -} - -/* - * Return true if any register that is used on exit from 'succ', has - * an exit value that is different from the corresponding exit value - * from 'b'. - */ -static int -use_conflict(b, succ) - struct block *b, *succ; -{ - int atom; - atomset use = succ->out_use; - - if (use == 0) - return 0; - - for (atom = 0; atom < N_ATOMS; ++atom) - if (ATOMELEM(use, atom)) - if (b->val[atom] != succ->val[atom]) - return 1; - return 0; -} - -struct block * -fold_edge(child, ep) - struct block *child; - struct edge *ep; -{ - int sense; - int aval0, aval1, oval0, oval1; - int code = ep->code; - - if (code < 0) { - code = -code; - sense = 0; - } else - sense = 1; - - if (child->s.code != code) - return 0; - - aval0 = child->val[A_ATOM]; - oval0 = child->oval; - aval1 = ep->pred->val[A_ATOM]; - oval1 = ep->pred->oval; - - if (aval0 != aval1) - return 0; - - if (oval0 == oval1) - /* - * The operands are identical, so the - * result is true if a true branch was - * taken to get here, otherwise false. - */ - return sense ? JT(child) : JF(child); - - if (sense && code == (BPF_JMP|BPF_JEQ|BPF_K)) - /* - * At this point, we only know the comparison if we - * came down the true branch, and it was an equility - * comparison with a constant. We rely on the fact that - * distinct constants have distinct value numbers. - */ - return JF(child); - - return 0; -} - -static void -opt_j(ep) - struct edge *ep; -{ - register int i, k; - register struct block *target; - - if (JT(ep->succ) == 0) - return; - - if (JT(ep->succ) == JF(ep->succ)) { - /* - * Common branch targets can be eliminated, provided - * there is no data dependency. - */ - if (!use_conflict(ep->pred, ep->succ->et.succ)) { - done = 0; - ep->succ = JT(ep->succ); - } - } - /* - * For each edge dominator that matches the successor of this - * edge, promote the edge succesor to the its grandchild. - * - * XXX We violate the set abstraction here in favor a reasonbly - * efficient loop. - */ - top: - for (i = 0; i < edgewords; ++i) { - register u_long x = ep->edom[i]; - - while (x != 0) { - k = ffs(x) - 1; - x &=~ 1 << k; - k += i * BITS_PER_WORD; - - target = fold_edge(ep->succ, edges[k]); - /* - * Check that there is no data dependency between - * nodes that will be violated if we move the edge. - */ - if (target != 0 && !use_conflict(ep->pred, target)) { - done = 0; - ep->succ = target; - if (JT(target) != 0) - /* - * Start over unless we hit a leaf. - */ - goto top; - return; - } - } - } -} - - -static void -or_pullup(b) - struct block *b; -{ - int val, at_top; - struct block *pull; - struct block **diffp, **samep; - struct edge *ep; - - ep = b->in_edges; - if (ep == 0) - return; - - /* - * Make sure each predecessor loads the same value. - * XXX why? - */ - val = ep->pred->val[A_ATOM]; - for (ep = ep->next; ep != 0; ep = ep->next) - if (val != ep->pred->val[A_ATOM]) - return; - - if (JT(b->in_edges->pred) == b) - diffp = &JT(b->in_edges->pred); - else - diffp = &JF(b->in_edges->pred); - - at_top = 1; - while (1) { - if (*diffp == 0) - return; - - if (JT(*diffp) != JT(b)) - return; - - if (!SET_MEMBER((*diffp)->dom, b->id)) - return; - - if ((*diffp)->val[A_ATOM] != val) - break; - - diffp = &JF(*diffp); - at_top = 0; - } - samep = &JF(*diffp); - while (1) { - if (*samep == 0) - return; - - if (JT(*samep) != JT(b)) - return; - - if (!SET_MEMBER((*samep)->dom, b->id)) - return; - - if ((*samep)->val[A_ATOM] == val) - break; - - /* XXX Need to check that there are no data dependencies - between dp0 and dp1. Currently, the code generator - will not produce such dependencies. */ - samep = &JF(*samep); - } -#ifdef notdef - /* XXX This doesn't cover everything. */ - for (i = 0; i < N_ATOMS; ++i) - if ((*samep)->val[i] != pred->val[i]) - return; -#endif - /* Pull up the node. */ - pull = *samep; - *samep = JF(pull); - JF(pull) = *diffp; - - /* - * At the top of the chain, each predecessor needs to point at the - * pulled up node. Inside the chain, there is only one predecessor - * to worry about. - */ - if (at_top) { - for (ep = b->in_edges; ep != 0; ep = ep->next) { - if (JT(ep->pred) == b) - JT(ep->pred) = pull; - else - JF(ep->pred) = pull; - } - } - else - *diffp = pull; - - done = 0; -} - -static void -and_pullup(b) - struct block *b; -{ - int val, at_top; - struct block *pull; - struct block **diffp, **samep; - struct edge *ep; - - ep = b->in_edges; - if (ep == 0) - return; - - /* - * Make sure each predecessor loads the same value. - */ - val = ep->pred->val[A_ATOM]; - for (ep = ep->next; ep != 0; ep = ep->next) - if (val != ep->pred->val[A_ATOM]) - return; - - if (JT(b->in_edges->pred) == b) - diffp = &JT(b->in_edges->pred); - else - diffp = &JF(b->in_edges->pred); - - at_top = 1; - while (1) { - if (*diffp == 0) - return; - - if (JF(*diffp) != JF(b)) - return; - - if (!SET_MEMBER((*diffp)->dom, b->id)) - return; - - if ((*diffp)->val[A_ATOM] != val) - break; - - diffp = &JT(*diffp); - at_top = 0; - } - samep = &JT(*diffp); - while (1) { - if (*samep == 0) - return; - - if (JF(*samep) != JF(b)) - return; - - if (!SET_MEMBER((*samep)->dom, b->id)) - return; - - if ((*samep)->val[A_ATOM] == val) - break; - - /* XXX Need to check that there are no data dependencies - between diffp and samep. Currently, the code generator - will not produce such dependencies. */ - samep = &JT(*samep); - } -#ifdef notdef - /* XXX This doesn't cover everything. */ - for (i = 0; i < N_ATOMS; ++i) - if ((*samep)->val[i] != pred->val[i]) - return; -#endif - /* Pull up the node. */ - pull = *samep; - *samep = JT(pull); - JT(pull) = *diffp; - - /* - * At the top of the chain, each predecessor needs to point at the - * pulled up node. Inside the chain, there is only one predecessor - * to worry about. - */ - if (at_top) { - for (ep = b->in_edges; ep != 0; ep = ep->next) { - if (JT(ep->pred) == b) - JT(ep->pred) = pull; - else - JF(ep->pred) = pull; - } - } - else - *diffp = pull; - - done = 0; -} - -static void -opt_blks(root, do_stmts) - struct block *root; -{ - int i, maxlevel; - struct block *p; - - init_val(); - maxlevel = root->level; - for (i = maxlevel; i >= 0; --i) - for (p = levels[i]; p; p = p->link) - opt_blk(p, do_stmts); - - if (do_stmts) - /* - * No point trying to move branches; it can't possibly - * make a difference at this point. - */ - return; - - for (i = 1; i <= maxlevel; ++i) { - for (p = levels[i]; p; p = p->link) { - opt_j(&p->et); - opt_j(&p->ef); - } - } - for (i = 1; i <= maxlevel; ++i) { - for (p = levels[i]; p; p = p->link) { - or_pullup(p); - and_pullup(p); - } - } -} - -static inline void -link_inedge(parent, child) - struct edge *parent; - struct block *child; -{ - parent->next = child->in_edges; - child->in_edges = parent; -} - -static void -find_inedges(root) - struct block *root; -{ - int i; - struct block *b; - struct edge *ep; - - for (i = 0; i < n_blocks; ++i) - blocks[i]->in_edges = 0; - - /* - * Traverse the graph, adding each edge to the predecessor - * list of its sucessors. Skip the leaves (i.e. level 0). - */ - for (i = root->level; i > 0; --i) { - for (b = levels[i]; b != 0; b = b->link) { - link_inedge(&b->et, JT(b)); - link_inedge(&b->ef, JF(b)); - } - } -} - -static void -opt_root(b) - struct block **b; -{ - struct slist *tmp, *s; - - s = (*b)->stmts; - (*b)->stmts = 0; - while (BPF_CLASS((*b)->s.code) == BPF_JMP && JT(*b) == JF(*b)) - *b = JT(*b); - - tmp = (*b)->stmts; - if (tmp != 0) - sappend(s, tmp); - (*b)->stmts = s; -} - -static void -opt_loop(root, do_stmts) - struct block *root; - int do_stmts; -{ - int passes = 0; -#ifdef BDEBUG - if (dflag > 1) - opt_dump(root); -#endif - do { - done = 1; - find_levels(root); - find_dom(root); - find_closure(root); - find_inedges(root); - find_ud(root); - find_edom(root); - opt_blks(root, do_stmts); -#ifdef BDEBUG - if (dflag > 1) - opt_dump(root); -#endif - } while (!done); -} - -/* - * Optimize the filter code in its dag representation. - */ -void -optimize(rootp) - struct block **rootp; -{ - struct block *root; - - root = *rootp; - - opt_init(root); - opt_loop(root, 0); - opt_loop(root, 1); - intern_blocks(root); - opt_root(rootp); - opt_cleanup(); -} - -static void -make_marks(p) - struct block *p; -{ - if (!isMarked(p)) { - Mark(p); - if (BPF_CLASS(p->s.code) != BPF_RET) { - make_marks(JT(p)); - make_marks(JF(p)); - } - } -} - -/* - * Mark code array such that isMarked(i) is true - * only for nodes that are alive. - */ -static void -mark_code(p) - struct block *p; -{ - cur_mark += 1; - make_marks(p); -} - -/* - * True iff the two stmt lists load the same value from the packet into - * the accumulator. - */ -static int -eq_slist(x, y) - struct slist *x, *y; -{ - while (1) { - while (x && x->s.code == NOP) - x = x->next; - while (y && y->s.code == NOP) - y = y->next; - if (x == 0) - return y == 0; - if (y == 0) - return x == 0; - if (x->s.code != y->s.code || x->s.k != y->s.k) - return 0; - x = x->next; - y = y->next; - } -} - -static inline int -eq_blk(b0, b1) - struct block *b0, *b1; -{ - if (b0->s.code == b1->s.code && - b0->s.k == b1->s.k && - b0->et.succ == b1->et.succ && - b0->ef.succ == b1->ef.succ) - return eq_slist(b0->stmts, b1->stmts); - return 0; -} - -static void -intern_blocks(root) - struct block *root; -{ - struct block *p; - int i, j; - int done; - top: - done = 1; - for (i = 0; i < n_blocks; ++i) - blocks[i]->link = 0; - - mark_code(root); - - for (i = n_blocks - 1; --i >= 0; ) { - if (!isMarked(blocks[i])) - continue; - for (j = i + 1; j < n_blocks; ++j) { - if (!isMarked(blocks[j])) - continue; - if (eq_blk(blocks[i], blocks[j])) { - blocks[i]->link = blocks[j]->link ? - blocks[j]->link : blocks[j]; - break; - } - } - } - for (i = 0; i < n_blocks; ++i) { - p = blocks[i]; - if (JT(p) == 0) - continue; - if (JT(p)->link) { - done = 0; - JT(p) = JT(p)->link; - } - if (JF(p)->link) { - done = 0; - JF(p) = JF(p)->link; - } - } - if (!done) - goto top; -} - -static void -opt_cleanup() -{ - free((void *)vnode_base); - free((void *)vmap); - free((void *)edges); - free((void *)space); - free((void *)levels); - free((void *)blocks); -} - -/* - * Return the number of stmts in 's'. - */ -static int -slength(s) - struct slist *s; -{ - int n = 0; - - for (; s; s = s->next) - if (s->s.code != NOP) - ++n; - return n; -} - -/* - * Return the number of nodes reachable by 'p'. - * All nodes should be initially unmarked. - */ -static int -count_blocks(p) - struct block *p; -{ - if (p == 0 || isMarked(p)) - return 0; - Mark(p); - return count_blocks(JT(p)) + count_blocks(JF(p)) + 1; -} - -/* - * Do a depth first search on the flow graph, numbering the - * the basic blocks, and entering them into the 'blocks' array.` - */ -static void -number_blks_r(p) - struct block *p; -{ - int n; - - if (p == 0 || isMarked(p)) - return; - - Mark(p); - n = n_blocks++; - p->id = n; - blocks[n] = p; - - number_blks_r(JT(p)); - number_blks_r(JF(p)); -} - -/* - * Return the number of stmts in the flowgraph reachable by 'p'. - * The nodes should be unmarked before calling. - */ -static int -count_stmts(p) - struct block *p; -{ - int n; - - if (p == 0 || isMarked(p)) - return 0; - Mark(p); - n = count_stmts(JT(p)) + count_stmts(JF(p)); - return slength(p->stmts) + n + 1; -} - -/* - * Allocate memory. All allocation is done before optimization - * is begun. A linear bound on the size of all data structures is computed - * from the total number of blocks and/or statements. - */ -static void -opt_init(root) - struct block *root; -{ - u_long *p; - int i, n, max_stmts; - - /* - * First, count the blocks, so we can malloc an array to map - * block number to block. Then, put the blocks into the array. - */ - unMarkAll(); - n = count_blocks(root); - blocks = (struct block **)malloc(n * sizeof(*blocks)); - unMarkAll(); - n_blocks = 0; - number_blks_r(root); - - n_edges = 2 * n_blocks; - edges = (struct edge **)malloc(n_edges * sizeof(*edges)); - - /* - * The number of levels is bounded by the number of nodes. - */ - levels = (struct block **)malloc(n_blocks * sizeof(*levels)); - - edgewords = n_edges / (8 * sizeof(u_long)) + 1; - nodewords = n_blocks / (8 * sizeof(u_long)) + 1; - - /* XXX */ - space = (u_long *)malloc(2 * n_blocks * nodewords * sizeof(*space) - + n_edges * edgewords * sizeof(*space)); - p = space; - all_dom_sets = p; - for (i = 0; i < n; ++i) { - blocks[i]->dom = p; - p += nodewords; - } - all_closure_sets = p; - for (i = 0; i < n; ++i) { - blocks[i]->closure = p; - p += nodewords; - } - all_edge_sets = p; - for (i = 0; i < n; ++i) { - register struct block *b = blocks[i]; - - b->et.edom = p; - p += edgewords; - b->ef.edom = p; - p += edgewords; - b->et.id = i; - edges[i] = &b->et; - b->ef.id = n_blocks + i; - edges[n_blocks + i] = &b->ef; - b->et.pred = b; - b->ef.pred = b; - } - max_stmts = 0; - for (i = 0; i < n; ++i) - max_stmts += slength(blocks[i]->stmts) + 1; - /* - * We allocate at most 3 value numbers per statement, - * so this is an upper bound on the number of valnodes - * we'll need. - */ - maxval = 3 * max_stmts; - vmap = (struct vmapinfo *)malloc(maxval * sizeof(*vmap)); - vnode_base = (struct valnode *)malloc(maxval * sizeof(*vmap)); -} - -/* - * Some pointers used to convert the basic block form of the code, - * into the array form that BPF requires. 'fstart' will point to - * the malloc'd array while 'ftail' is used during the recursive traversal. - */ -static struct bpf_insn *fstart; -static struct bpf_insn *ftail; - -#ifdef BDEBUG -int bids[1000]; -#endif - -static void -convert_code_r(p) - struct block *p; -{ - struct bpf_insn *dst; - struct slist *src; - int slen; - u_int off; - - if (p == 0 || isMarked(p)) - return; - Mark(p); - - convert_code_r(JF(p)); - convert_code_r(JT(p)); - - slen = slength(p->stmts); - dst = ftail -= slen + 1; - - p->offset = dst - fstart; - - for (src = p->stmts; src; src = src->next) { - if (src->s.code == NOP) - continue; - dst->code = (u_short)src->s.code; - dst->k = src->s.k; - ++dst; - } -#ifdef BDEBUG - bids[dst - fstart] = p->id + 1; -#endif - dst->code = (u_short)p->s.code; - dst->k = p->s.k; - if (JT(p)) { - off = JT(p)->offset - (p->offset + slen) - 1; - if (off >= 256) - error("long jumps not supported"); - dst->jt = off; - off = JF(p)->offset - (p->offset + slen) - 1; - if (off >= 256) - error("long jumps not supported"); - dst->jf = off; - } -} - - -/* - * Convert flowgraph intermediate representation to the - * BPF array representation. Set *lenp to the number of instructions. - */ -struct bpf_insn * -icode_to_fcode(root, lenp) - struct block *root; - int *lenp; -{ - int n; - struct bpf_insn *fp; - - unMarkAll(); - n = *lenp = count_stmts(root); - - fp = (struct bpf_insn *)malloc(sizeof(*fp) * n); - bzero((char *)fp, sizeof(*fp) * n); - fstart = fp; - ftail = fp + n; - - unMarkAll(); - convert_code_r(root); - - return fp; -} - -#ifdef BDEBUG -opt_dump(root) - struct block *root; -{ - struct bpf_program f; - - bzero(bids, sizeof bids); - f.bf_insns = icode_to_fcode(root, &f.bf_len); - bpf_dump(&f, 1); - putchar('\n'); - free((char *)f.bf_insns); -} -#endif diff --git a/usr.sbin/tcpdump/tcpdump/os.c b/usr.sbin/tcpdump/tcpdump/os.c deleted file mode 100644 index 856fb5a2bc66..000000000000 --- a/usr.sbin/tcpdump/tcpdump/os.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char rcsid[] = - "@(#) $Header: os-bsd.c,v 1.2 90/09/21 02:12:17 mccanne Exp $ (LBL)"; -#endif - diff --git a/usr.sbin/tcpdump/tcpdump/pcap.c b/usr.sbin/tcpdump/tcpdump/pcap.c deleted file mode 100644 index 04c96953766b..000000000000 --- a/usr.sbin/tcpdump/tcpdump/pcap.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#ifndef lint -static char rcsid[] = - "@(#)$Header: pcap-bpf.c,v 1.29 92/06/02 17:57:29 mccanne Exp $ (LBL)"; -#endif - -#include -#include -#include -#include -#include -#include /* optionally get BSD define */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "interface.h" - -extern int errno; - -static void -bpf_stats(fd) - int fd; -{ - struct bpf_stat s; - - if (ioctl(fd, BIOCGSTATS, &s) < 0) - return; - - (void)fflush(stdout); - (void)fprintf(stderr, "%d packets received by filter\n", s.bs_recv); - (void)fprintf(stderr, "%d packets dropped by kernel\n", s.bs_drop); -} - -void -readloop(cnt, if_fd, fp, printit) - int cnt; - int if_fd; - struct bpf_program *fp; - void (*printit)(); -{ - u_char *buf; - u_int bufsize; - int cc; - - if (ioctl(if_fd, BIOCGBLEN, (caddr_t)&bufsize) < 0) { - perror("tcpdump: BIOCGBLEN"); - exit(1); - } - buf = (u_char *)malloc(bufsize); - - if (ioctl(if_fd, BIOCSETF, (caddr_t)fp) < 0) { - perror("tcpdump: BIOCSETF"); - exit(1); - } - while (1) { - register u_char *bp, *ep; - - if ((cc = read(if_fd, (char *)buf, (int)bufsize)) < 0) { - /* Don't choke when we get ptraced */ - if (errno == EINTR) - continue; -#if defined(sun) && !defined(BSD) - /* - * Due to a SunOS bug, after 2^31 bytes, the kernel - * file offset overflows and read fails with EINVAL. - * The lseek() to 0 will fix things. - */ - if (errno == EINVAL && - (long)(tell(if_fd) + bufsize) < 0) { - (void)lseek(if_fd, 0, 0); - continue; - } -#endif - perror("tcpdump: read"); - exit(1); - } - /* - * Loop through each packet. - */ -#define bhp ((struct bpf_hdr *)bp) - bp = buf; - ep = bp + cc; - while (bp < ep) { - register int caplen, hdrlen; - if (cnt >= 0 && --cnt < 0) - goto out; - (*printit)(bp + (hdrlen = bhp->bh_hdrlen), - &bhp->bh_tstamp, bhp->bh_datalen, - caplen = bhp->bh_caplen); - bp += BPF_WORDALIGN(caplen + hdrlen); - } -#undef bhp - } - out: - wrapup(if_fd); -} - -wrapup(fd) - int fd; -{ - bpf_stats(fd); - close(fd); -} - -static inline int -bpf_open() -{ - int fd; - int n = 0; - char device[sizeof "/dev/bpf000"]; - - /* - * Go through all the minors and find one that isn't in use. - */ - do { - (void)sprintf(device, "/dev/bpf%d", n++); - fd = open(device, O_RDONLY); - } while (fd < 0 && errno == EBUSY); - - if (fd < 0) { - (void) fprintf(stderr, "tcpdump: "); - perror(device); - exit(-1); - } - return fd; -} - -int -initdevice(device, pflag, linktype) - char *device; - int pflag; - int *linktype; -{ - struct timeval timeout; - int if_fd; - struct ifreq ifr; - struct bpf_version bv; - - if_fd = bpf_open(); - - if (ioctl(if_fd, BIOCVERSION, (caddr_t)&bv) < 0) - warning("kernel bpf interpreter may be out of date"); - else if (bv.bv_major != BPF_MAJOR_VERSION || - bv.bv_minor < BPF_MINOR_VERSION) - error("requires bpf language %d.%d or higher; kernel is %d.%d", - BPF_MAJOR_VERSION, BPF_MINOR_VERSION, - bv.bv_major, bv.bv_minor); - - (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); - if (ioctl(if_fd, BIOCSETIF, (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, "tcpdump: BIOCSETIF: "); - perror(device); - exit(-1); - } - /* Get the data link layer type. */ - if (ioctl(if_fd, BIOCGDLT, (caddr_t)linktype) < 0) { - perror("tcpdump: BIOCGDLT"); - exit(-1); - } - /* set timeout */ - timeout.tv_sec = 1; - timeout.tv_usec = 0; - if (ioctl(if_fd, BIOCSRTIMEOUT, (caddr_t)&timeout) < 0) { - perror("tcpdump: BIOCSRTIMEOUT"); - exit(-1); - } - /* set promiscuous mode if requested, but only for broadcast nets */ - if (pflag == 0) { - switch (*linktype) { - - case DLT_SLIP: - case DLT_PPP: - case DLT_NULL: - break; - - default: - if (ioctl(if_fd, BIOCPROMISC, (void *)0) < 0) { - perror("tcpdump: BIOCPROMISC"); - exit(-1); - } - } - } - return(if_fd); -} diff --git a/usr.sbin/tcpdump/tcpdump/savefile.c b/usr.sbin/tcpdump/tcpdump/savefile.c deleted file mode 100644 index 79bb9e8afc68..000000000000 --- a/usr.sbin/tcpdump/tcpdump/savefile.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 1990,1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#ifndef lint -static char rcsid[] = - "@(#)$Header: savefile.c,v 1.27 92/01/26 21:29:26 mccanne Exp $ (LBL)"; -#endif - -/* - * savefile.c - supports offline use of tcpdump - * Extraction/creation by Jeffrey Mogul, DECWRL - * Modified by Steve McCanne, LBL. - * - * Used to save the received packet headers, after filtering, to - * a file, and then read them later. - * The first record in the file contains saved values for the machine - * dependent values so we can print the dump file on any architecture. - */ - -#include -#include -#include -#include - -#include "version.h" -#include "savefile.h" - -#define TCPDUMP_MAGIC 0xa1b2c3d4 - -/* - * The first record in the file contains saved values for some - * of the flags used in the printout phases of tcpdump. - * Many fields here are longs so compilers won't insert unwanted - * padding; these files need to be interchangeable across architectures. - */ -struct file_header { - u_long magic; - u_short version_major; - u_short version_minor; - long thiszone; /* gmt to local correction */ - u_long sigfigs; /* accuracy of timestamps */ - u_long snaplen; /* max length saved portion of each pkt */ - u_long linktype; -}; - -int sf_swapped; - -FILE *sf_readfile; -FILE *sf_writefile; - -static int -sf_write_header(fp, linktype, thiszone, snaplen, precision) - FILE *fp; - int linktype; - int thiszone; - int snaplen; - int precision; -{ - struct file_header hdr; - - hdr.magic = TCPDUMP_MAGIC; - hdr.version_major = VERSION_MAJOR; - hdr.version_minor = VERSION_MINOR; - - hdr.thiszone = thiszone; - hdr.snaplen = snaplen; - hdr.sigfigs = precision; - hdr.linktype = linktype; - - if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) - return -1; - - return 0; -} - -static void -swap_hdr(hp) - struct file_header *hp; -{ - hp->version_major = SWAPSHORT(hp->version_major); - hp->version_minor = SWAPSHORT(hp->version_minor); - hp->thiszone = SWAPLONG(hp->thiszone); - hp->sigfigs = SWAPLONG(hp->sigfigs); - hp->snaplen = SWAPLONG(hp->snaplen); - hp->linktype = SWAPLONG(hp->linktype); -} - -int -sf_read_init(fname, linktypep, thiszonep, snaplenp, precision) - char *fname; - int *linktypep, *thiszonep, *snaplenp, *precision; -{ - register FILE *fp; - struct file_header hdr; - - if (fname[0] == '-' && fname[1] == '\0') - fp = stdin; - else { - fp = fopen(fname, "r"); - if (fp == 0) { - (void) fprintf(stderr, "tcpdump: fopen: "); - perror(fname); - exit(1); - } - } - if (fread((char *)&hdr, sizeof(hdr), 1, fp) != 1) { - (void) fprintf(stderr, "tcpdump: fread: "); - perror(fname); - exit(1); - } - if (hdr.magic != TCPDUMP_MAGIC) { - if (SWAPLONG(hdr.magic) != TCPDUMP_MAGIC) - return SFERR_BADF; - sf_swapped = 1; - swap_hdr(&hdr); - } - if (hdr.version_major < VERSION_MAJOR) - return SFERR_BADVERSION; - - *thiszonep = hdr.thiszone; - *snaplenp = hdr.snaplen; - *linktypep = hdr.linktype; - *precision = hdr.sigfigs; - - sf_readfile = fp; - - return 0; -} - -/* - * Print out packets stored in the file initilized by sf_read_init(). - * If cnt >= 0, return after 'cnt' packets, otherwise continue until eof. - */ -int -sf_read(filtp, cnt, snaplen, printit) - struct bpf_program *filtp; - int cnt, snaplen; - void (*printit)(); -{ - struct packet_header h; - u_char *buf; - struct bpf_insn *fcode = filtp->bf_insns; - int status = 0; - - buf = (u_char *)malloc(snaplen); - - while (status == 0) { - status = sf_next_packet(&h, buf, snaplen); - - if (status) - break; - /* - * XXX It's possible (and likely) for us to screw up the - * network layer alignment when we pass down packets from - * this point (ip_print deals by copying the ip header - * to an aligned buffer). There doesn't seem to be a - * clean way to fix this. We could compute an offset - * from the link type (which would have to be passed in), - * but that only works for fixed size headers. - */ - if (bpf_filter(fcode, buf, h.len, h.caplen)) { - if (cnt >= 0 && --cnt < 0) - break; - (*printit)(buf, &h.ts, h.len, h.caplen); - } - } - - if (status == SFERR_EOF) - /* treat EOF's as okay status */ - status = 0; - - free((char *)buf); - return status; -} - -/* - * Read sf_readfile and return the next packet. Return the header in hdr - * and the contents in buf. Return 0 on success, SFERR_EOF if there were - * no more packets, and SFERR_TRUNC if a partial packet was encountered. - */ -int -sf_next_packet(hdr, buf, buflen) - struct packet_header *hdr; - u_char *buf; - int buflen; -{ - FILE *fp = sf_readfile; - - /* read the stamp */ - if (fread((char *)hdr, sizeof(struct packet_header), 1, fp) != 1) { - /* probably an EOF, though could be a truncated packet */ - return SFERR_EOF; - } - - if (sf_swapped) { - /* these were written in opposite byte order */ - hdr->caplen = SWAPLONG(hdr->caplen); - hdr->len = SWAPLONG(hdr->len); - hdr->ts.tv_sec = SWAPLONG(hdr->ts.tv_sec); - hdr->ts.tv_usec = SWAPLONG(hdr->ts.tv_usec); - } - - if (hdr->caplen > buflen) - return SFERR_BADF; - - /* read the packet itself */ - - if (fread((char *)buf, hdr->caplen, 1, fp) != 1) - return SFERR_TRUNC; - - return 0; -} - -/* - * Initialize so that sf_write() will output to the file named 'fname'. - */ -void -sf_write_init(fname, linktype, thiszone, snaplen, precision) - char *fname; - int linktype; - int thiszone; - int snaplen; - int precision; -{ - if (fname[0] == '-' && fname[1] == '\0') - sf_writefile = stdout; - else { - sf_writefile = fopen(fname, "w"); - if (sf_writefile == 0) { - (void) fprintf(stderr, "tcpdump: fopen: "); - perror(fname); - exit(1); - } - } - (void)sf_write_header(sf_writefile, - linktype, thiszone, snaplen, precision); -} - -/* - * Output a packet to the intialized dump file. - */ -void -sf_write(sp, tvp, length, caplen) - u_char *sp; - struct timeval *tvp; - int length; - int caplen; -{ - struct packet_header h; - - h.ts.tv_sec = tvp->tv_sec; - h.ts.tv_usec = tvp->tv_usec; - h.len = length; - h.caplen = caplen; - - (void)fwrite((char *)&h, sizeof h, 1, sf_writefile); - (void)fwrite((char *)sp, caplen, 1, sf_writefile); -} - -void -sf_err(code) - int code; -{ - switch (code) { - case SFERR_BADVERSION: - error("archaic file format"); - /* NOTREACHED */ - - case SFERR_BADF: - error("bad dump file format"); - /* NOTREACHED */ - - case SFERR_TRUNC: - error("truncated dump file"); - /* NOTREACHED */ - - case SFERR_EOF: - error("EOF reading dump file"); - /* NOTREACHED */ - - default: - error("unknown dump file error code in sf_err()"); - /* NOTREACHED */ - } - abort(); -} diff --git a/usr.sbin/tcpdump/tcpdump/savefile.h b/usr.sbin/tcpdump/tcpdump/savefile.h deleted file mode 100644 index a5082f9fb276..000000000000 --- a/usr.sbin/tcpdump/tcpdump/savefile.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Header: savefile.h,v 1.10 90/12/17 13:48:58 mccanne Exp $ - * - * Header for offline storage info. - * Extraction/creation by Jeffrey Mogul, DECWRL. - * - * Used to save the received packet headers, after filtering, to - * a file, and then read them later. - */ - -/* - * Each packet in the dump file is prepended with this generic header. - * This gets around the problem of different headers for different - * packet interfaces. - */ -struct packet_header { - struct timeval ts; /* time stamp */ - u_long len; /* length this packet (off wire) */ - u_long caplen; /* length of portion present */ -}; - -/* true if the contents of the savefile being read are byte-swapped */ -extern int sf_swapped; - -/* macros for when sf_swapped is true: */ -/* - * We use the "receiver-makes-right" approach to byte order, - * because time is at a premium when we are writing the file. - * In other words, the file_header and packet_header records - * are written in host byte order. - * Note that the packets are always written in network byte order. - * - * ntoh[ls] aren't sufficient because we might need to swap on a big-endian - * machine (if the file was written in little-end order). - */ -#define SWAPLONG(y) \ -((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) -#define SWAPSHORT(y) \ - ( (((y)&0xff)<<8) | (((y)&0xff00)>>8) ) - - -extern FILE *sf_readfile; /* dump file being read from */ -extern FILE *sf_writefile; /* dump file being written to */ - -int sf_read_init(); -int sf_read(); -int sf_next_packet(); -void sf_write_init(); -void sf_write(); -void sf_err(); - -#define SFERR_TRUNC 1 -#define SFERR_BADVERSION 2 -#define SFERR_BADF 3 -#define SFERR_EOF 4 /* not really an error, just a status */ - diff --git a/usr.sbin/tcpdump/tcpdump/tcpgram.y b/usr.sbin/tcpdump/tcpdump/tcpgram.y deleted file mode 100644 index da235d0b1068..000000000000 --- a/usr.sbin/tcpdump/tcpdump/tcpgram.y +++ /dev/null @@ -1,232 +0,0 @@ -%{ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Grammar for tcpdump. - */ -#ifndef lint -static char rcsid[] = - "@(#) $Header: tcpgram.y,v 1.29 92/03/17 13:45:08 mccanne Exp $ (LBL)"; -#endif - -#include -#include -#include -#include -#include -#include - -#include "interface.h" - -#include -#include - -#include "gencode.h" - -#define QSET(q, p, d, a) (q).proto = (p),\ - (q).dir = (d),\ - (q).addr = (a) - -int n_errors = 0; - -static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF }; - -static void -yyerror() -{ - ++n_errors; -} - -%} - -%union { - int i; - u_long h; - u_char *e; - char *s; - struct stmt *stmt; - struct arth *a; - struct { - struct qual q; - struct block *b; - } blk; - struct block *rblk; -} - -%type expr id nid pid term rterm qid -%type head -%type pqual dqual aqual ndaqual -%type arth narth -%type byteop pname pnum relop irelop -%type and or paren not null prog -%type other - -%token DST SRC HOST GATEWAY -%token NET PORT LESS GREATER PROTO BYTE -%token ARP RARP IP TCP UDP ICMP -%token TK_BROADCAST TK_MULTICAST -%token NUM -%token LINK -%token GEQ LEQ NEQ -%token ID EID HID -%token LSH RSH -%token LEN - -%type ID -%type EID -%type HID -%type NUM - -%left OR AND -%nonassoc '!' -%left '|' -%left '&' -%left LSH RSH -%left '+' '-' -%left '*' '/' -%nonassoc UMINUS -%% -prog: null expr -{ - finish_parse($2.b); -} - | null - ; -null: /* null */ { $$.q = qerr; } - ; -expr: term - | expr and term { gen_and($1.b, $3.b); $$ = $3; } - | expr and id { gen_and($1.b, $3.b); $$ = $3; } - | expr or term { gen_or($1.b, $3.b); $$ = $3; } - | expr or id { gen_or($1.b, $3.b); $$ = $3; } - ; -and: AND { $$ = $0; } - ; -or: OR { $$ = $0; } - ; -id: nid - | pnum { $$.b = gen_ncode((u_long)$1, - $$.q = $0.q); } - | paren pid ')' { $$ = $2; } - ; -nid: ID { $$.b = gen_scode($1, $$.q = $0.q); } - | HID { $$.b = gen_ncode($1, $$.q = $0.q); } - | EID { $$.b = gen_ecode($1, $$.q = $0.q); } - | not id { gen_not($2.b); $$ = $2; } - ; -not: '!' { $$ = $0; } - ; -paren: '(' { $$ = $0; } - ; -pid: nid - | qid and id { gen_and($1.b, $3.b); $$ = $3; } - | qid or id { gen_or($1.b, $3.b); $$ = $3; } - ; -qid: pnum { $$.b = gen_ncode((u_long)$1, - $$.q = $0.q); } - | pid - ; -term: rterm - | not term { gen_not($2.b); $$ = $2; } - ; -head: pqual dqual aqual { QSET($$.q, $1, $2, $3); } - | pqual dqual { QSET($$.q, $1, $2, Q_DEFAULT); } - | pqual aqual { QSET($$.q, $1, Q_DEFAULT, $2); } - | pqual PROTO { QSET($$.q, $1, Q_DEFAULT, Q_PROTO); } - | pqual ndaqual { QSET($$.q, $1, Q_DEFAULT, $2); } - ; -rterm: head id { $$ = $2; } - | paren expr ')' { $$.b = $2.b; $$.q = $1.q; } - | pname { $$.b = gen_proto_abbrev($1); $$.q = qerr; } - | arth relop arth { $$.b = gen_relation($2, $1, $3, 0); - $$.q = qerr; } - | arth irelop arth { $$.b = gen_relation($2, $1, $3, 1); - $$.q = qerr; } - | other { $$.b = $1; $$.q = qerr; } - ; -/* protocol level qualifiers */ -pqual: pname - | { $$ = Q_DEFAULT; } - ; -/* 'direction' qualifiers */ -dqual: SRC { $$ = Q_SRC; } - | DST { $$ = Q_DST; } - | SRC OR DST { $$ = Q_OR; } - | DST OR SRC { $$ = Q_OR; } - | SRC AND DST { $$ = Q_AND; } - | DST AND SRC { $$ = Q_AND; } - ; -/* address type qualifiers */ -aqual: HOST { $$ = Q_HOST; } - | NET { $$ = Q_NET; } - | PORT { $$ = Q_PORT; } - ; -/* non-directional address type qualifiers */ -ndaqual: GATEWAY { $$ = Q_GATEWAY; } - ; -pname: LINK { $$ = Q_LINK; } - | IP { $$ = Q_IP; } - | ARP { $$ = Q_ARP; } - | RARP { $$ = Q_RARP; } - | TCP { $$ = Q_TCP; } - | UDP { $$ = Q_UDP; } - | ICMP { $$ = Q_ICMP; } - ; -other: pqual TK_BROADCAST { $$ = gen_broadcast($1); } - | pqual TK_MULTICAST { $$ = gen_multicast($1); } - | LESS NUM { $$ = gen_less($2); } - | GREATER NUM { $$ = gen_greater($2); } - | BYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); } - ; -relop: '>' { $$ = BPF_JGT; } - | GEQ { $$ = BPF_JGE; } - | '=' { $$ = BPF_JEQ; } - ; -irelop: LEQ { $$ = BPF_JGT; } - | '<' { $$ = BPF_JGE; } - | NEQ { $$ = BPF_JEQ; } - ; -arth: pnum { $$ = gen_loadi($1); } - | narth - ; -narth: pname '[' arth ']' { $$ = gen_load($1, $3, 1); } - | pname '[' arth ':' NUM ']' { $$ = gen_load($1, $3, $5); } - | arth '+' arth { $$ = gen_arth(BPF_ADD, $1, $3); } - | arth '-' arth { $$ = gen_arth(BPF_SUB, $1, $3); } - | arth '*' arth { $$ = gen_arth(BPF_MUL, $1, $3); } - | arth '/' arth { $$ = gen_arth(BPF_DIV, $1, $3); } - | arth '&' arth { $$ = gen_arth(BPF_AND, $1, $3); } - | arth '|' arth { $$ = gen_arth(BPF_OR, $1, $3); } - | arth LSH arth { $$ = gen_arth(BPF_LSH, $1, $3); } - | arth RSH arth { $$ = gen_arth(BPF_RSH, $1, $3); } - | '-' arth %prec UMINUS { $$ = gen_neg($2); } - | paren narth ')' { $$ = $2; } - | LEN { $$ = gen_loadlen(); } - ; -byteop: '&' { $$ = '&'; } - | '|' { $$ = '|'; } - | '<' { $$ = '<'; } - | '>' { $$ = '>'; } - | '=' { $$ = '='; } - ; -pnum: NUM - | paren pnum ')' { $$ = $2; } - ; -%% diff --git a/usr.sbin/update/Makefile b/usr.sbin/update/Makefile deleted file mode 100644 index ea20d0566b2e..000000000000 --- a/usr.sbin/update/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= update -MAN8= update.0 - -.include diff --git a/usr.sbin/update/update.8 b/usr.sbin/update/update.8 deleted file mode 100644 index 78665fafe71d..000000000000 --- a/usr.sbin/update/update.8 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)update.8 8.3 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt UPDATE 8 -.Os -.Sh NAME -.Nm update -.Nd flush internal filesystem caches to disk frequently -.Sh SYNOPSIS -.Nm update -.Sh DESCRIPTION -The -.Nm update -command helps protect the integrity of disk volumes -by flushing -volatile cached filesystem data -to disk at thirty second intervals. -.Nm Update -uses the -.Xr sync 2 -function call to do the task. -.Pp -.Nm Update -is commonly invoked at startup time by -.Xr rc 8 -when the system goes multi-user. -.Sh SEE ALSO -.Xr sync 2 , -.Xr fsck 8 , -.Xr init 8 , -.Xr rc 8 , -.Xr sync 8 -.Sh BUGS -It is possible on some systems that a -.Xr sync -occurring simultaneously with a crash may cause -file system damage. See -.Xr fsck 8 . -.Sh HISTORY -An -.Nm update -command appeared in -.At v6 . diff --git a/usr.sbin/update/update.c b/usr.sbin/update/update.c deleted file mode 100644 index ae83ad10b08c..000000000000 --- a/usr.sbin/update/update.c +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 1987, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1990, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include -#include -#include -#include -#include - -main() -{ - struct itimerval value; - void mysync(); - - daemon(0, 0); - - (void)signal(SIGALRM, mysync); - - value.it_interval.tv_sec = 30; - value.it_interval.tv_usec = 0; - value.it_value = value.it_interval; - if (setitimer(ITIMER_REAL, &value, NULL)) { - perror("update: setitimer"); - exit(1); - } - for (;;) - sigpause(sigblock(0L)); - /* NOTREACHED */ -} - -void -mysync() -{ - (void)sync(); -} diff --git a/usr.sbin/xntpd/Config b/usr.sbin/xntpd/Config deleted file mode 100644 index c15ec053a520..000000000000 --- a/usr.sbin/xntpd/Config +++ /dev/null @@ -1,200 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_FREEBSD -DSYS_386BSD -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lcrypt -RESLIB= -COPTS= -O2 -COMPILER= gcc -LIBDEFS= -DXNTP_LITTLE_ENDIAN -# This is the local configure file (distribution version). -# You must modify it to fit your particular configuration -# and name it Config.local -# The following configuratiions can be auto-generated: -# -# make Config.local.green -# make a Config.local that supports a local clock -# (i.e. allow fallback to use of the CPU's own clock) -# make Config.local.NO.clock -# make a Config.local that supports no clocks -# -# -# NOTE TO GREENHORNS -# -# For plug-'n-play and no radios or other complicated gadgetry, -# use "make Config.local.green" as above. -# -# Following defines can be set in the DEFS_OPT= define: -# -# The flag -DDEBUG includes some debugging code. To use this, include -# the define and start the daemon with one or more -d flags, depending -# on your calibration of pearannoya. The daemon will not detach your -# terminal in this case. Judicious use of grep will reduce the speaker -# volume to bearable levels. -# -# To change the location of the configuration file, use a -# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. -# -# The -DSYSLOG_FILE defines allows logging messages that are normally -# reported via syslof() in a file. The file name can be configured using -# the configuration line "logfile " in CONFIG_FILE. -# -# There are three serial port system software interfaces, each of -# which is peculiar to one or more Unix versions. Define -# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM -# for POSIX compatibility including System V Streams, and -# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three -# should be defined. If none are defined, HAVE_BSD_TTYS is assumed. -# Usually these defines are already set correctly. -# -DEFS_OPT=-DDEBUG - -# -# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that) -# and one of the following: -# -# The flag -DREFCLOCK causes the basic reference clock support to be -# compiled into the daemon. If you set this you may also want to -# configure the particular clock drivers you want in the CLOCKDEFS= line -# below. This flag affects xntpd only. This define is included by -# default when using the "make makeconfig" script. -# -# The next two sets of defines are meaningful only when radio clock -# drivers or special 1-pps signals are to be used. For systems without -# these features, these delicious complexities can be avoided. Ordinarily, -# the "make makeconfig" script figures out which ones to use, but your -# mileage may vary. -# -# There are three ways to utilize external 1-pps signals. Define -# -DPPS to include just the pps routine, such as used by the DCF77(PARSE) -# clock driver. Define -DPPSCLK to include a serial device driver -# which avoids much of the jitter due to upper level port -# processing. This requires a dedicated serial port and either the -# tty_clock line discipline or tty_clk_streams module, both of -# which are in the ./kernel directory. Define -DPPSCD to include a -# special driver which intercepts carrier-detect transitions -# generated by the pps signal. This requires a nondedicated serial -# port and the ppsclock streams module in the ./kernel directory. -# Only one of these three flags should be defined. -# -# The flag KERNEL_PLL causes code to be compiled for a special feature of -# the kernel that (a) implements the phase-lock loop and (b) provides -# a user interface to learn time, maximum error and estimated error. -# See the file README.kern in the doc directory for further info. -# This code is activated only if the relevant kernel features have -# been configured; it does not affect operation of unmodified kernels. -# To compile it, however, requires a few header files from the -# special distribution. -# -# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT) -DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DPPSPPS -DKERNEL_PLL - -# -# Radio clock support definitions (these only make sense if -DREFCLOCK -# used), which is normally the case. Note that a configuration can include -# no clocks, more than one type of clock and even multiple clocks of the -# same type. -# -# For most radio clocks operating with serial ports, accuracy can -# be considerably improved through use of the tty_clk line -# discipline or tty_clk_STREAMS streams module found in the -# ./kernel directory. These gizmos capture a timestamp upon -# occurrence of an intercept character and stuff it in the data -# stream for the clock driver to munch. To select this mode, -# postfix the driver name with the string CLK; that is, WWVB -# becomes WWVBCLK. If more than one clock is in use, the CLK -# postfix can be used with any or all of them. -# -# Alternatively, for the best accuracy, use the ppsclock streams -# module in the ./ppsclock directory to steal the carrier-detect -# transition and capture a precision timestamp. At present this -# works only with SunOS 4.1.1 or later. To select this mode, -# postfix the driver name with the string PPS; that is, AS2201 -# becomes AS2201PPS. If more than one clock is in use, the PPS -# postfix should be used with only one of them. If any PPS -# postfix is defined, the -DPPSPPS define should be used on the -# DEFS above. -# -# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a -# reference clock for those subnets without access to the real thing. -# Works in all systems and requires no hardware support. This is defined -# by default when using the "make makeconfig" script and greenhorn -# configuraiton. -# -# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver -# supports both the CLK and PPS modes. It should work in all systems -# with a serial port. -# -# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It -# should work in all systems with a serial port. The driver supports -# both the CLK and PPS modes if the requisite kernel support is installed. -# -# Define -DCHU for a special CHU receiver using an ordinary shortwave -# radio. This requires the chu_clk line discipline or chu_clk_STREAMS -# module in the ./kernel directory. At present, this driver works only -# on SunOS4.1.x; operation in other systems has not been confirmed. -# Construction details for a suitable modem can be found in the ./gadget -# directory. The driver supports # neither the CLK nor PPS modes. -# -# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance -# this requires a special parsestreams STREAMS (SunOS 4.x) module in the -# ./parse directory. Define -DPARSEPPS for PPS support via the -# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above. -# Define: -DCLOCK_MEINBERG for Meinberg clocks -# -DCLOCK_SCHMID for Schmid receivers -# -DCLOCK_DCF7000 for ELV DCF7000 -# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx) -# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver -# -# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this -# driver works only on SunOS4.1.x with CPU serial ports only. The PPS -# mode is required. -# -# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should -# work in all systems with a serial port. The driver does not support the -# CLK mode, but does support the PPS mode. If the radio is connected to -# more than one machine, the PPS mode is required. -# -# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This -# driver is known to work with some other TrueTime products as well, -# including the GPS-DC GPS receiver. It should work in all systems with -# a serial port. The driver does not support the CLK mode, but does -# support the PPS mode. -# -# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It -# should work in all systems with a serial port. The driver does not -# support the CLK mode, but does support the PPS mode. -# -# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This -# requires the SunOS interface driver available from KSI. The driver -# supports neither the CLK nor PPS modes. -# -# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for -# the HP 5061B Cesium Clock. It should work in all systems with a serial -# port. The driver does not support the CLK mode, but does support the -# PPS mode. -# -# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works -# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS -# files on cl.cam.ac.uk still has support for CLK and CBREAK modes. -# -# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of -# the Sun SPARCstations. This requires a modified BSD audio driver and -# exclusive access to the audio port. A memo describing how it works and -# how to install the driver is in the README.irig file in the ./doc -# directory. -# -# Note: The following defines result in compilation of all the above radio -# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and -# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes -# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile -# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC -# OSF/1 Alpha. -# -CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHU -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DMSFEESPPS -DLEITCH - -# -# Directory into which binaries should be installed (default /usr/local) -# -BINDIR= /usr/local/bin diff --git a/usr.sbin/xntpd/Config.local b/usr.sbin/xntpd/Config.local deleted file mode 100644 index 50bbe3a85f9e..000000000000 --- a/usr.sbin/xntpd/Config.local +++ /dev/null @@ -1,198 +0,0 @@ -# This is the local configure file (distribution version). -# You must modify it to fit your particular configuration -# and name it Config.local -# The following configuratiions can be auto-generated: -# -# make Config.local.green -# make a Config.local that supports a local clock -# (i.e. allow fallback to use of the CPU's own clock) -# make Config.local.NO.clock -# make a Config.local that supports no clocks -# -# -# NOTE TO GREENHORNS -# -# For plug-'n-play and no radios or other complicated gadgetry, -# use "make Config.local.green" as above. -# -# Following defines can be set in the DEFS_OPT= define: -# -# The flag -DDEBUG includes some debugging code. To use this, include -# the define and start the daemon with one or more -d flags, depending -# on your calibration of pearannoya. The daemon will not detach your -# terminal in this case. Judicious use of grep will reduce the speaker -# volume to bearable levels. -# -# To change the location of the configuration file, use a -# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. -# -# The -DSYSLOG_FILE defines allows logging messages that are normally -# reported via syslog() in a file. The file name can be configured using -# the configuration line "logfile " in CONFIG_FILE. -# -# There are three serial port system software interfaces, each of -# which is peculiar to one or more Unix versions. Define -# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM -# for POSIX compatibility including System V Streams, and -# HAVE_BSD_TTYS for 4.3bsd compatibility. -# Use HAVE_TERMIOS for POSIX (termios.h) without System V Streams. -# Only one of these three should be defined. If none are defined, -# HAVE_BSD_TTYS is assumed. -# Usually these defines are already set correctly. -# -DEFS_OPT=-DDEBUG - -# -# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that) -# and one of the following: -# -# The flag -DREFCLOCK causes the basic reference clock support to be -# compiled into the daemon. If you set this you may also want to -# configure the particular clock drivers you want in the CLOCKDEFS= line -# below. This flag affects xntpd only. This define is included by -# default when using the "make makeconfig" script. -# -# The next two sets of defines are meaningful only when radio clock -# drivers or special 1-pps signals are to be used. For systems without -# these features, these delicious complexities can be avoided. Ordinarily, -# the "make makeconfig" script figures out which ones to use, but your -# mileage may vary. -# -# There are three ways to utilize external 1-pps signals. Define -# -DPPS to include just the pps routine, such as used by the DCF77(PARSE) -# clock driver. Define -DPPSCLK to include a serial device driver -# which avoids much of the jitter due to upper level port -# processing. This requires a dedicated serial port and either the -# tty_clock line discipline or tty_clk_streams module, both of -# which are in the ./kernel directory. Define -DPPSCD to include a -# special driver which intercepts carrier-detect transitions -# generated by the pps signal. This requires a nondedicated serial -# port and the ppsclock streams module in the ./kernel directory. -# Only one of these three flags should be defined. -# -# The flag KERNEL_PLL causes code to be compiled for a special feature of -# the kernel that (a) implements the phase-lock loop and (b) provides -# a user interface to learn time, maximum error and estimated error. -# See the file README.kern in the doc directory for further info. -# This code is activated only if the relevant kernel features have -# been configured; it does not affect operation of unmodified kernels. -# To compile it, however, requires a few header files from the -# special distribution. -# -# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT) -DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL - -# -# Radio clock support definitions (these only make sense if -DREFCLOCK -# used), which is normally the case. Note that a configuration can include -# no clocks, more than one type of clock and even multiple clocks of the -# same type. -# -# For most radio clocks operating with serial ports, accuracy can -# be considerably improved through use of the tty_clk line -# discipline or tty_clk_STREAMS streams module found in the -# ./kernel directory. These gizmos capture a timestamp upon -# occurrence of an intercept character and stuff it in the data -# stream for the clock driver to munch. To select this mode, -# postfix the driver name with the string CLK; that is, WWVB -# becomes WWVBCLK. If more than one clock is in use, the CLK -# postfix can be used with any or all of them. -# -# Alternatively, for the best accuracy, use the ppsclock streams -# module in the ./ppsclock directory to steal the carrier-detect -# transition and capture a precision timestamp. At present this -# works only with SunOS 4.1.1 or later. To select this mode, -# postfix the driver name with the string PPS; that is, AS2201 -# becomes AS2201PPS. If more than one clock is in use, the PPS -# postfix should be used with only one of them. If any PPS -# postfix is defined, the -DPPSPPS define should be used on the -# DEFS above. -# -# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a -# reference clock for those subnets without access to the real thing. -# Works in all systems and requires no hardware support. This is defined -# by default when using the "make makeconfig" script and greenhorn -# configuraiton. -# -# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should -# work in all systems with a serial port. The driver does not support the -# CLK mode, but does support the PPS mode. If the radio is connected to -# more than one machine, the PPS mode is required. -# -# Define -DCHU for a special CHU receiver using an ordinary shortwave -# radio. This requires the chu_clk line discipline or chu_clk_STREAMS -# module in the ./kernel directory. At present, this driver works only -# on SunOS4.1.x; operation in other systems has not been confirmed. -# Construction details for a suitable modem can be found in the ./gadget -# directory. The driver supports # neither the CLK nor PPS modes. -# -# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This -# driver is known to work with some other TrueTime products as well, -# including the GPS-DC GPS receiver. It should work in all systems with -# a serial port. The driver does not support the CLK mode, but does -# support the PPS mode. -# -# Define -DGPSTM for a Kinemetrics/TrueTime GPS-TM/TMD receiver. It -# should work in all systems with a serial port. -# -# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of -# the Sun SPARCstations. This requires a modified BSD audio driver and -# exclusive access to the audio port. A memo describing how it works and -# how to install the driver is in the README.irig file in the ./doc -# directory. -# -# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for -# the HP 5061B Cesium Clock. It should work in all systems with a serial -# port. The driver does not support the CLK mode, but does support the -# PPS mode. -# -# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this -# driver works only on SunOS4.1.x with CPU serial ports only. The PPS -# mode is required. -# -# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works -# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS -# files on cl.cam.ac.uk still has support for CLK and CBREAK modes. -# -# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It -# should work in all systems with a serial port. The driver does not -# support the CLK mode, but does support the PPS mode. -# -# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance -# this requires a special parsestreams STREAMS (SunOS 4.x) module in the -# ./parse directory. Define -DPARSEPPS for PPS support via the -# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above. -# Define: -DCLOCK_MEINBERG for Meinberg clocks -# -DCLOCK_SCHMID for Schmid receivers -# -DCLOCK_DCF7000 for ELV DCF7000 -# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx) -# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver -# -# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver -# supports both the CLK and PPS modes. It should work in all systems -# with a serial port. -# -# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This -# requires the SunOS interface driver available from KSI. The driver -# supports neither the CLK nor PPS modes. -# -# Define -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface -# Module. The driver supports both the CLK and PPS modes. It should work -# in all systems with a serial port. -# -# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It -# should work in all systems with a serial port. The driver supports -# both the CLK and PPS modes if the requisite kernel support is installed. -# -# Note: The following defines result in compilation of all the above radio -# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and -# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes -# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile -# under Ultrix 4.2a/3 and DEC # OSF/1 Alpha. -# -CLOCKDEFS= -DLOCAL_CLOCK #TEST -DAS2201PPS -DCHU -DATUM -DGOES -DGPSTM -DIRIG -DLEITCH -DMSFEES -DMX4200PPS -DOMEGA -DPST -DTPRO -TRAK -DWWVB -DPARSE -DPARSEPPS -DCLOCK_MEINBERG -DCLOCK_RAWDCF -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMSV6 - -# -# Directory into which binaries should be installed (default /usr/local) -# -BINDIR= /usr/local/bin diff --git a/usr.sbin/xntpd/Config.local.dist b/usr.sbin/xntpd/Config.local.dist deleted file mode 100644 index 2f7386687d87..000000000000 --- a/usr.sbin/xntpd/Config.local.dist +++ /dev/null @@ -1,198 +0,0 @@ -# This is the local configure file (distribution version). -# You must modify it to fit your particular configuration -# and name it Config.local -# The following configuratiions can be auto-generated: -# -# make Config.local.green -# make a Config.local that supports a local clock -# (i.e. allow fallback to use of the CPU's own clock) -# make Config.local.NO.clock -# make a Config.local that supports no clocks -# -# -# NOTE TO GREENHORNS -# -# For plug-'n-play and no radios or other complicated gadgetry, -# use "make Config.local.green" as above. -# -# Following defines can be set in the DEFS_OPT= define: -# -# The flag -DDEBUG includes some debugging code. To use this, include -# the define and start the daemon with one or more -d flags, depending -# on your calibration of pearannoya. The daemon will not detach your -# terminal in this case. Judicious use of grep will reduce the speaker -# volume to bearable levels. -# -# To change the location of the configuration file, use a -# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. -# -# The -DSYSLOG_FILE defines allows logging messages that are normally -# reported via syslog() in a file. The file name can be configured using -# the configuration line "logfile " in CONFIG_FILE. -# -# There are three serial port system software interfaces, each of -# which is peculiar to one or more Unix versions. Define -# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM -# for POSIX compatibility including System V Streams, and -# HAVE_BSD_TTYS for 4.3bsd compatibility. -# Use HAVE_TERMIOS for POSIX (termios.h) without System V Streams. -# Only one of these three should be defined. If none are defined, -# HAVE_BSD_TTYS is assumed. -# Usually these defines are already set correctly. -# -DEFS_OPT=-DDEBUG - -# -# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that) -# and one of the following: -# -# The flag -DREFCLOCK causes the basic reference clock support to be -# compiled into the daemon. If you set this you may also want to -# configure the particular clock drivers you want in the CLOCKDEFS= line -# below. This flag affects xntpd only. This define is included by -# default when using the "make makeconfig" script. -# -# The next two sets of defines are meaningful only when radio clock -# drivers or special 1-pps signals are to be used. For systems without -# these features, these delicious complexities can be avoided. Ordinarily, -# the "make makeconfig" script figures out which ones to use, but your -# mileage may vary. -# -# There are three ways to utilize external 1-pps signals. Define -# -DPPS to include just the pps routine, such as used by the DCF77(PARSE) -# clock driver. Define -DPPSCLK to include a serial device driver -# which avoids much of the jitter due to upper level port -# processing. This requires a dedicated serial port and either the -# tty_clock line discipline or tty_clk_streams module, both of -# which are in the ./kernel directory. Define -DPPSCD to include a -# special driver which intercepts carrier-detect transitions -# generated by the pps signal. This requires a nondedicated serial -# port and the ppsclock streams module in the ./kernel directory. -# Only one of these three flags should be defined. -# -# The flag KERNEL_PLL causes code to be compiled for a special feature of -# the kernel that (a) implements the phase-lock loop and (b) provides -# a user interface to learn time, maximum error and estimated error. -# See the file README.kern in the doc directory for further info. -# This code is activated only if the relevant kernel features have -# been configured; it does not affect operation of unmodified kernels. -# To compile it, however, requires a few header files from the -# special distribution. -# -# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT) -DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL - -# -# Radio clock support definitions (these only make sense if -DREFCLOCK -# used), which is normally the case. Note that a configuration can include -# no clocks, more than one type of clock and even multiple clocks of the -# same type. -# -# For most radio clocks operating with serial ports, accuracy can -# be considerably improved through use of the tty_clk line -# discipline or tty_clk_STREAMS streams module found in the -# ./kernel directory. These gizmos capture a timestamp upon -# occurrence of an intercept character and stuff it in the data -# stream for the clock driver to munch. To select this mode, -# postfix the driver name with the string CLK; that is, WWVB -# becomes WWVBCLK. If more than one clock is in use, the CLK -# postfix can be used with any or all of them. -# -# Alternatively, for the best accuracy, use the ppsclock streams -# module in the ./ppsclock directory to steal the carrier-detect -# transition and capture a precision timestamp. At present this -# works only with SunOS 4.1.1 or later. To select this mode, -# postfix the driver name with the string PPS; that is, AS2201 -# becomes AS2201PPS. If more than one clock is in use, the PPS -# postfix should be used with only one of them. If any PPS -# postfix is defined, the -DPPSPPS define should be used on the -# DEFS above. -# -# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a -# reference clock for those subnets without access to the real thing. -# Works in all systems and requires no hardware support. This is defined -# by default when using the "make makeconfig" script and greenhorn -# configuraiton. -# -# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should -# work in all systems with a serial port. The driver does not support the -# CLK mode, but does support the PPS mode. If the radio is connected to -# more than one machine, the PPS mode is required. -# -# Define -DCHU for a special CHU receiver using an ordinary shortwave -# radio. This requires the chu_clk line discipline or chu_clk_STREAMS -# module in the ./kernel directory. At present, this driver works only -# on SunOS4.1.x; operation in other systems has not been confirmed. -# Construction details for a suitable modem can be found in the ./gadget -# directory. The driver supports # neither the CLK nor PPS modes. -# -# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This -# driver is known to work with some other TrueTime products as well, -# including the GPS-DC GPS receiver. It should work in all systems with -# a serial port. The driver does not support the CLK mode, but does -# support the PPS mode. -# -# Define -DGPSTM for a Kinemetrics/TrueTime GPS-TM/TMD receiver. It -# should work in all systems with a serial port. -# -# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of -# the Sun SPARCstations. This requires a modified BSD audio driver and -# exclusive access to the audio port. A memo describing how it works and -# how to install the driver is in the README.irig file in the ./doc -# directory. -# -# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for -# the HP 5061B Cesium Clock. It should work in all systems with a serial -# port. The driver does not support the CLK mode, but does support the -# PPS mode. -# -# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this -# driver works only on SunOS4.1.x with CPU serial ports only. The PPS -# mode is required. -# -# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works -# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS -# files on cl.cam.ac.uk still has support for CLK and CBREAK modes. -# -# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It -# should work in all systems with a serial port. The driver does not -# support the CLK mode, but does support the PPS mode. -# -# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance -# this requires a special parsestreams STREAMS (SunOS 4.x) module in the -# ./parse directory. Define -DPARSEPPS for PPS support via the -# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above. -# Define: -DCLOCK_MEINBERG for Meinberg clocks -# -DCLOCK_SCHMID for Schmid receivers -# -DCLOCK_DCF7000 for ELV DCF7000 -# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx) -# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver -# -# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver -# supports both the CLK and PPS modes. It should work in all systems -# with a serial port. -# -# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This -# requires the SunOS interface driver available from KSI. The driver -# supports neither the CLK nor PPS modes. -# -# Define -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface -# Module. The driver supports both the CLK and PPS modes. It should work -# in all systems with a serial port. -# -# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It -# should work in all systems with a serial port. The driver supports -# both the CLK and PPS modes if the requisite kernel support is installed. -# -# Note: The following defines result in compilation of all the above radio -# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and -# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes -# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile -# under Ultrix 4.2a/3 and DEC # OSF/1 Alpha. -# -CLOCKDEFS= #GREEN -DLOCAL_CLOCK #TEST -DAS2201PPS -DCHU -DATUM -DGOES -DGPSTM -DIRIG -DLEITCH -DMSFEES -DMX4200PPS -DOMEGA -DPST -DTPRO -TRAK -DWWVB -DPARSE -DPARSEPPS -DCLOCK_MEINBERG -DCLOCK_RAWDCF -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMSV6 - -# -# Directory into which binaries should be installed (default /usr/local) -# -BINDIR= /usr/local/bin diff --git a/usr.sbin/xntpd/Config.sed b/usr.sbin/xntpd/Config.sed deleted file mode 100644 index fe5a9b7927bd..000000000000 --- a/usr.sbin/xntpd/Config.sed +++ /dev/null @@ -1,14 +0,0 @@ -s~^RANLIB=.*~RANLIB= ranlib~ -s~^DEFS_LOCAL=.*~DEFS_LOCAL=-DREFCLOCK~ -s~^DEFS=.*~DEFS= -DSYS_FREEBSD -DSYS_386BSD~ -s~^AUTHDEFS=.*~AUTHDEFS= -DDES -DMD5~ -s~^CLOCKDEFS=.*~CLOCKDEFS= -DLOCAL_CLOCK~ -s~^DAEMONLIBS=.*~DAEMONLIBS= -lcrypt~ -s~^RESLIB=.*~RESLIB=~ -s~^COPTS=.*~COPTS= -O2~ -s~^COMPILER=.*~COMPILER= gcc~ -s~^LIBDEFS=.*~LIBDEFS= -DXNTP_LITTLE_ENDIAN~ -s~^DEFS_OPT=.*~DEFS_OPT=-DDEBUG~ -s~^DEFS_LOCAL=.*~DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DPPSPPS -DKERNEL_PLL~ -s~^CLOCKDEFS=.*~CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHU -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DMSFEESPPS -DLEITCH~ -s~^BINDIR=.*~BINDIR= /usr/local/bin~ diff --git a/usr.sbin/xntpd/adjtime/Makefile.tmpl b/usr.sbin/xntpd/adjtime/Makefile.tmpl deleted file mode 100644 index c2e8381165b8..000000000000 --- a/usr.sbin/xntpd/adjtime/Makefile.tmpl +++ /dev/null @@ -1,53 +0,0 @@ -######################################################################### -## (c) Copyright 1988, Hewlett-Packard Co. All Rights Reserved. ## -## ## -## Author: Tai Jin, Hewlett-Packard Laboratories. ## -######################################################################### - -## Makefile.tmpl,v 3.1 1993/07/06 01:04:40 jbj Exp - -# -PROGRAM = adjtimed -COMPILER= cc -CC= $(COMPILER) -BINDIR= /usr/local/etc -COPTS= -O -DEFS= -DEFS_OPT= -DEFS_LOCAL= -INCL= -I../include -LLIBS= -INSTALL= install - - -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LDFLAGS= -LIBS= $(LLIBS) -lc -OBJ= adjtime.o adjtimed.o -ALL= libadjtime.a adjtimed - -all: $(ALL) - -libadjtime.a: adjtime.o - ar vr libadjtime.a $? - -adjtimed: adjtimed.o ../lib/libntp.a - $(CC) $(LDFLAGS) -o adjtimed adjtimed.o ../lib/libntp.a $(LIBS) - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -clean: - -@rm -f *.a *.o adjtimed - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -install: $(PROGRAM) - cp $(PROGRAM) $(BINDIR) diff --git a/usr.sbin/xntpd/adjtime/README b/usr.sbin/xntpd/adjtime/README deleted file mode 100644 index fe8b7e51e78a..000000000000 --- a/usr.sbin/xntpd/adjtime/README +++ /dev/null @@ -1,23 +0,0 @@ ------------------------------------------------------------------------------- -The adjtimed daemon emulates the BSD adjtime(2) system call. The -adjtime() routine communicates with this daemon via SYSV messages. - -The emulation uses an undocumented kernel variable (as of 6.0/2.0 -and later releases) and as such it cannot be guaranteed to work in -future HP-UX releases. Perhaps HP-UX will have a real adjtime(2) -system call in the future. - -Author: Tai Jin (tai@sde.hp.com) ------------------------------------------------------------------------------- - -IMPORTANT NOTE: This stuff must be compiled with no optimization !! - -NOTE: This code is known to work as of 8.0 on s300's, s700's and s800's. - PLEASE do not modify it unless you have access to kernel sources - and fully understand the implications of any changes you are making. - One person already has trashed adjtimed by making it do "the right - thing". This is not an exact replacement for BSD adjtime(2), don't - try to make it into one. - - -- Ken - diff --git a/usr.sbin/xntpd/adjtime/adjtime.c b/usr.sbin/xntpd/adjtime/adjtime.c deleted file mode 100644 index 5b0475e1d31b..000000000000 --- a/usr.sbin/xntpd/adjtime/adjtime.c +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************/ -/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */ -/* Hewlett-Packard Laboratories. */ -/* */ -/* Permission is hereby granted for unlimited modification, use, and */ -/* distribution. This software is made available with no warranty of */ -/* any kind, express or implied. This copyright notice must remain */ -/* intact in all versions of this software. */ -/* */ -/* The author would appreciate it if any bug fixes and enhancements were */ -/* to be sent back to him for incorporation into future versions of this */ -/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */ -/*************************************************************************/ - -#ifndef lint -static char RCSid[] = "adjtime.c,v 3.1 1993/07/06 01:04:42 jbj Exp"; -#endif - -#include -#include -#include -#include -#include -#include "adjtime.h" - -#define abs(x) ((x) < 0 ? -(x) : (x)) -static LONG adjthresh = 400L; -static LONG saveup; - - -_clear_adjtime() -{ - saveup = 0L; -} - - -adjtime(delta, olddelta) - register struct timeval *delta; - register struct timeval *olddelta; -{ - struct timeval newdelta; - - /* If they are giving us seconds, ignore up to current threshold saved */ - if (delta->tv_sec) { - saveup = 0L; - return(_adjtime(delta, olddelta)); - } - - /* add in, needs check for overflow ? */ - saveup += delta->tv_usec; - - /* Broke the threshold, call adjtime() */ - if (abs(saveup) > adjthresh) { - newdelta.tv_sec = 0L; - newdelta.tv_usec = saveup; - saveup = 0L; - return(_adjtime(&newdelta, olddelta)); - } - - if (olddelta) - olddelta->tv_sec = olddelta->tv_usec = 0L; - return(0); -} - - -_adjtime(delta, olddelta) - register struct timeval *delta; - register struct timeval *olddelta; -{ - register int mqid; - MsgBuf msg; - register MsgBuf *msgp = &msg; - - /* - * get the key to the adjtime message queue - * (note that we must get it every time because the queue might have been - * removed and recreated) - */ - if ((mqid = msgget(KEY, 0)) == -1) - return (-1); - - msgp->msgb.mtype = CLIENT; - msgp->msgb.tv = *delta; - - if (olddelta) - msgp->msgb.code = DELTA2; - else - msgp->msgb.code = DELTA1; - - if (msgsnd(mqid, &msgp->msgp, MSGSIZE, 0) == -1) - return (-1); - - if (olddelta) { - if (msgrcv(mqid, &msgp->msgp, MSGSIZE, SERVER, 0) == -1) - return (-1); - - *olddelta = msgp->msgb.tv; - } - - return (0); -} diff --git a/usr.sbin/xntpd/adjtime/adjtime.h b/usr.sbin/xntpd/adjtime/adjtime.h deleted file mode 100644 index f063a4777bf1..000000000000 --- a/usr.sbin/xntpd/adjtime/adjtime.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************/ -/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */ -/* Hewlett-Packard Laboratories. */ -/* */ -/* Permission is hereby granted for unlimited modification, use, and */ -/* distribution. This software is made available with no warranty of */ -/* any kind, express or implied. This copyright notice must remain */ -/* intact in all versions of this software. */ -/* */ -/* The author would appreciate it if any bug fixes and enhancements were */ -/* to be sent back to him for incorporation into future versions of this */ -/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */ -/*************************************************************************/ - -/* "adjtime.h,v 3.1 1993/07/06 01:04:43 jbj Exp" */ -/* adjtime.h,v - * Revision 3.1 1993/07/06 01:04:43 jbj - * XNTP release 3.1 - * - * - * Revision 1.5 90/02/07 15:34:18 15:34:18 src (Source Hacker) - * CHANGED KEY !!! - * - * Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin (Guest)) - * *** empty log message *** - * - * Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin) - * added comment - * - * Revision 1.3 88/08/30 01:08:29 01:08:29 tai (Tai Jin) - * fix copyright notice again - * - * Revision 1.2 88/08/30 00:51:55 00:51:55 tai (Tai Jin) - * fix copyright notice - * - * Revision 1.1 88/04/02 14:56:54 14:56:54 tai (Tai Jin) - * Initial revision - * */ - -#include "ntp_types.h" - -#define KEY 659847L - -typedef union { - struct msgbuf msgp; - struct { - LONG mtype; - int code; - struct timeval tv; - } msgb; -} MsgBuf; - -#define MSGSIZE (sizeof(int) + sizeof(struct timeval)) -/* - * mtype values - */ -#define CLIENT 1L -#define SERVER 2L -/* - * code values - */ -#define DELTA1 0 -#define DELTA2 1 diff --git a/usr.sbin/xntpd/adjtime/adjtimed.c b/usr.sbin/xntpd/adjtime/adjtimed.c deleted file mode 100644 index 44e544441693..000000000000 --- a/usr.sbin/xntpd/adjtime/adjtimed.c +++ /dev/null @@ -1,496 +0,0 @@ -/*************************************************************************/ -/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */ -/* Hewlett-Packard Laboratories. */ -/* */ -/* Permission is hereby granted for unlimited modification, use, and */ -/* distribution. This software is made available with no warranty of */ -/* any kind, express or implied. This copyright notice must remain */ -/* intact in all versions of this software. */ -/* */ -/* The author would appreciate it if any bug fixes and enhancements were */ -/* to be sent back to him for incorporation into future versions of this */ -/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */ -/*************************************************************************/ - -#ifndef lint -static char RCSid[] = "adjtimed.c,v 3.1 1993/07/06 01:04:45 jbj Exp"; -#endif - -/* - * Adjust time daemon. - * This deamon adjusts the rate of the system clock a la BSD's adjtime(). - * The adjtime() routine uses SYSV messages to communicate with this daemon. - * - * Caveat: This emulation uses an undocumented kernel variable. As such, it - * cannot be guaranteed to work in future HP-UX releases. Perhaps a real - * adjtime(2) will be supported in the future. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ntp_syslog.h" -#include "adjtime.h" - -double atof(); -extern int ntp_optind; -extern char *ntp_optarg; - -int InitClockRate(); -int AdjustClockRate(); -#ifdef notdef -LONG GetClockRate(); -#endif -int SetClockRate(); -void ResetClockRate(); -void Cleanup(); -void Exit(); - -#define MILLION 1000000L - -#define tvtod(tv) ((double)(LONG)tv.tv_sec + \ - ((double)tv.tv_usec / (double)MILLION)) - -char *progname = NULL; -int verbose = 0; -int sysdebug = 0; -static int mqid; -static double oldrate = 0.0; -static double RATE = 0.25; -static double PERIOD = 6.666667; - - -main(argc, argv) - int argc; - char **argv; -{ - struct timeval remains; - struct sigvec vec; - MsgBuf msg; - char ch; - int nofork = 0; - int fd; - - progname = argv[0]; - -#ifdef LOG_LOCAL6 - openlog("adjtimed", LOG_PID, LOG_LOCAL6); -#else - openlog("adjtimed", LOG_PID); -#endif - - while ((ch = ntp_getopt(argc, argv, "hkrvdfp:")) != EOF) { - switch (ch) { - case 'k': - case 'r': - if ((mqid = msgget(KEY, 0)) != -1) { - if (msgctl(mqid, IPC_RMID, (struct msqid_ds *)0) == -1) { - syslog(LOG_ERR, "remove old message queue: %m"); - perror("adjtimed: remove old message queue"); - exit(1); - } - } - - if (ch == 'k') - exit(0); - - break; - - case 'v': - ++verbose, nofork = 1; - break; - - case 'd': - ++sysdebug; - break; - - case 'f': - nofork = 1; - break; - - case 'p': - if ((RATE = atof(ntp_optarg)) <= 0.0 || RATE >= 100.0) { - fputs("adjtimed: percentage must be between 0.0 and 100.0\n", stderr); - exit(1); - } - - RATE /= 100.0; - PERIOD = 1.0 / RATE; - break; - - default: - puts("usage: adjtimed -hkrvdf -p rate"); - puts("-h\thelp"); - puts("-k\tkill existing adjtimed, if any"); - puts("-r\trestart (kills existing adjtimed, if any)"); - puts("-v\tdebug output (repeat for more output)"); - puts("-d\tsyslog output (repeat for more output)"); - puts("-f\tno fork"); - puts("-p rate\tpercent rate of change"); - syslog(LOG_ERR, "usage error"); - exit(1); - } /* switch */ - } /* while */ - - if (!nofork) { - switch (fork()) { - case 0: - close(fileno(stdin)); - close(fileno(stdout)); - close(fileno(stderr)); - -#ifdef TIOCNOTTY - if ((fd = open("/dev/tty")) != -1) { - ioctl(fd, TIOCNOTTY, 0); - close(fd); - } -#else - setpgrp(); -#endif - break; - - case -1: - syslog(LOG_ERR, "fork: %m"); - perror("adjtimed: fork"); - exit(1); - - default: - exit(0); - } /* switch */ - } /* if */ - - if (nofork) { - setvbuf(stdout, NULL, _IONBF, BUFSIZ); - setvbuf(stderr, NULL, _IONBF, BUFSIZ); - } - - syslog(LOG_INFO, "started (rate %.2f%%)", RATE * 100.0); - if (verbose) printf("adjtimed: started (rate %.2f%%)\n", RATE * 100.0); - - if (InitClockRate() == -1) - Exit(2); - - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGQUIT, SIG_IGN); - (void)signal(SIGTERM, Cleanup); - - vec.sv_handler = ResetClockRate; - vec.sv_flags = 0; - vec.sv_mask = ~0; - sigvector(SIGALRM, &vec, (struct sigvec *)0); - - if (msgget(KEY, IPC_CREAT|IPC_EXCL) == -1) { - if (errno == EEXIST) { - syslog(LOG_ERR, "message queue already exists, use -r to remove it"); - fputs("adjtimed: message queue already exists, use -r to remove it\n", - stderr); - Exit(1); - } - - syslog(LOG_ERR, "create message queue: %m"); - perror("adjtimed: create message queue"); - Exit(1); - } - - if ((mqid = msgget(KEY, 0)) == -1) { - syslog(LOG_ERR, "get message queue id: %m"); - perror("adjtimed: get message queue id"); - Exit(1); - } - - if (plock(PROCLOCK)) { - syslog(LOG_ERR, "plock: %m"); - perror("adjtimed: plock"); - Cleanup(); - } - - for (;;) { - if (msgrcv(mqid, &msg.msgp, MSGSIZE, CLIENT, 0) == -1) { - if (errno == EINTR) continue; - syslog(LOG_ERR, "read message: %m"); - perror("adjtimed: read message"); - Cleanup(); - } - - switch (msg.msgb.code) { - case DELTA1: - case DELTA2: - AdjustClockRate(&msg.msgb.tv, &remains); - - if (msg.msgb.code == DELTA2) { - msg.msgb.tv = remains; - msg.msgb.mtype = SERVER; - - while (msgsnd(mqid, &msg.msgp, MSGSIZE, 0) == -1) { - if (errno == EINTR) continue; - syslog(LOG_ERR, "send message: %m"); - perror("adjtimed: send message"); - Cleanup(); - } - } - - if (remains.tv_sec + remains.tv_usec != 0L) { - if (verbose) { - printf("adjtimed: previous correction remaining %.6fs\n", - tvtod(remains)); - } - if (sysdebug) { - syslog(LOG_INFO, "previous correction remaining %.6fs", - tvtod(remains)); - } - } - break; - - default: - fprintf(stderr, "adjtimed: unknown message code %d\n", msg.msgb.code); - syslog(LOG_ERR, "unknown message code %d", msg.msgb.code); - } /* switch */ - } /* loop */ -} /* main */ - -/* - * Default clock rate (old_tick). - */ -#define DEFAULT_RATE (MILLION / HZ) -#define UNKNOWN_RATE 0L -#define SLEW_RATE (MILLION / DEFAULT_RATE) -#define MIN_DELTA SLEW_RATE -/* -#define RATE 0.005 -#define PERIOD (1.0 / RATE) -*/ -static LONG default_rate = DEFAULT_RATE; -static LONG slew_rate = SLEW_RATE; - -AdjustClockRate(delta, olddelta) - register struct timeval *delta, *olddelta; -{ - register LONG rate, dt; - struct itimerval period, remains; - static LONG leftover = 0; -/* - * rate of change - */ - dt = (delta->tv_sec * MILLION) + delta->tv_usec + leftover; - - if (dt < MIN_DELTA && dt > -MIN_DELTA) { - leftover += delta->tv_usec; - - if (olddelta) { - getitimer(ITIMER_REAL, &remains); - dt = ((remains.it_value.tv_sec * MILLION) + remains.it_value.tv_usec) * - oldrate; - olddelta->tv_sec = dt / MILLION; - olddelta->tv_usec = dt - (olddelta->tv_sec * MILLION); - } - - if (verbose > 2) printf("adjtimed: delta is too small: %dus\n", dt); - if (sysdebug > 2) syslog(LOG_INFO, "delta is too small: %dus", dt); - return (1); - } - - leftover = dt % MIN_DELTA; - dt -= leftover; - - if (verbose) - printf("adjtimed: new correction %.6fs\n", (double)dt / (double)MILLION); - if (sysdebug) - syslog(LOG_INFO, "new correction %.6fs", (double)dt / (double)MILLION); - if (verbose > 2) printf("adjtimed: leftover %dus\n", leftover); - if (sysdebug > 2) syslog(LOG_INFO, "leftover %dus", leftover); - rate = dt * RATE; - - if (rate < slew_rate && rate > -slew_rate) { - rate = (rate < 0L ? -slew_rate : slew_rate); - dt = abs(dt * (MILLION / slew_rate)); - period.it_value.tv_sec = dt / MILLION; - } else { - period.it_value.tv_sec = (LONG)PERIOD; - } -/* - * The adjustment will always be a multiple of the minimum adjustment. - * So the period will always be a whole second value. - */ - period.it_value.tv_usec = 0; - - if (verbose > 1) - printf("adjtimed: will be complete in %ds\n", period.it_value.tv_sec); - if (sysdebug > 1) - syslog(LOG_INFO, "will be complete in %ds", period.it_value.tv_sec); -/* - * adjust the clock rate - */ - if (SetClockRate((rate / slew_rate) + default_rate) == -1) { - syslog(LOG_ERR, "set clock rate: %m"); - perror("adjtimed: set clock rate"); - } -/* - * start the timer - * (do this after changing the rate because the period has been rounded down) - */ - period.it_interval.tv_sec = period.it_interval.tv_usec = 0L; - setitimer(ITIMER_REAL, &period, &remains); -/* - * return old delta - */ - if (olddelta) { - dt = ((remains.it_value.tv_sec * MILLION) + remains.it_value.tv_usec) * - oldrate; - olddelta->tv_sec = dt / MILLION; - olddelta->tv_usec = dt - (olddelta->tv_sec * MILLION); - } - - oldrate = (double)rate / (double)MILLION; -} /* AdjustClockRate */ - -static struct nlist nl[] = { -#ifdef hp9000s800 -#ifdef PRE7_0 - { "tick" }, -#else - { "old_tick" }, -#endif -#else - { "_old_tick" }, -#endif - { "" } -}; - -static int kmem; - -/* - * The return value is the clock rate in old_tick units or -1 if error. - */ -LONG -GetClockRate() -{ - LONG rate, mask; - - if (lseek(kmem, (LONG)nl[0].n_value, 0) == -1L) - return (-1L); - - mask = sigblock(sigmask(SIGALRM)); - - if (read(kmem, (caddr_t)&rate, sizeof(rate)) != sizeof(rate)) - rate = UNKNOWN_RATE; - - sigsetmask(mask); - return (rate); -} /* GetClockRate */ - -/* - * The argument is the new rate in old_tick units. - */ -SetClockRate(rate) - LONG rate; -{ - LONG mask; - - if (lseek(kmem, (LONG)nl[0].n_value, 0) == -1L) - return (-1); - - mask = sigblock(sigmask(SIGALRM)); - - if (write(kmem, (caddr_t)&rate, sizeof(rate)) != sizeof(rate)) { - sigsetmask(mask); - return (-1); - } - - sigsetmask(mask); - - if (rate != default_rate) { - if (verbose > 3) { - printf("adjtimed: clock rate (%lu) %ldus/s\n", rate, - (rate - default_rate) * slew_rate); - } - if (sysdebug > 3) { - syslog(LOG_INFO, "clock rate (%lu) %ldus/s", rate, - (rate - default_rate) * slew_rate); - } - } - - return (0); -} /* SetClockRate */ - -InitClockRate() -{ - if ((kmem = open("/dev/kmem", O_RDWR)) == -1) { - syslog(LOG_ERR, "open(/dev/kmem): %m"); - perror("adjtimed: open(/dev/kmem)"); - return (-1); - } - - nlist("/hp-ux", nl); - - if (nl[0].n_type == 0) { - fputs("adjtimed: /hp-ux has no symbol table\n", stderr); - syslog(LOG_ERR, "/hp-ux has no symbol table"); - return (-1); - } -/* - * Set the default to the system's original value - */ - default_rate = GetClockRate(); - if (default_rate == UNKNOWN_RATE) default_rate = DEFAULT_RATE; - slew_rate = (MILLION / default_rate); - - return (0); -} /* InitClockRate */ - -/* - * Reset the clock rate to the default value. - */ -void -ResetClockRate() -{ - struct itimerval it; - - it.it_value.tv_sec = it.it_value.tv_usec = 0L; - setitimer(ITIMER_REAL, &it, (struct itimerval *)0); - - if (verbose > 2) puts("adjtimed: resetting the clock"); - if (sysdebug > 2) syslog(LOG_INFO, "resetting the clock"); - - if (GetClockRate() != default_rate) { - if (SetClockRate(default_rate) == -1) { - syslog(LOG_ERR, "set clock rate: %m"); - perror("adjtimed: set clock rate"); - } - } - - oldrate = 0.0; -} /* ResetClockRate */ - -void -Cleanup() -{ - ResetClockRate(); - - if (msgctl(mqid, IPC_RMID, (struct msqid_ds *)0) == -1) { - if (errno != EINVAL) { - syslog(LOG_ERR, "remove message queue: %m"); - perror("adjtimed: remove message queue"); - } - } - - Exit(2); -} /* Cleanup */ - -void -Exit(status) - int status; -{ - syslog(LOG_ERR, "terminated"); - closelog(); - if (kmem != -1) close(kmem); - exit(status); -} /* Exit */ diff --git a/usr.sbin/xntpd/authstuff/Makefile.tmpl b/usr.sbin/xntpd/authstuff/Makefile.tmpl deleted file mode 100644 index ccafc5b6b25f..000000000000 --- a/usr.sbin/xntpd/authstuff/Makefile.tmpl +++ /dev/null @@ -1,92 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= authcert authspeed md5 -# -# authcert, authspeed - authentication utilities -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -DEFS= -DEFS_OPT= -DEFS_LOCAL= -COMPAT= -RESLIB= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -MAKE= make -# -CRTOBJS= authcert.o -SPDOBJS= authspeed.o -PAROBJS= keyparity.o -IFPOBJS= makeIPFP.o -PC1OBJS= makePC1.o -PC2OBJS= makePC2.o -SPOBJS= makeSP.o -RNDOBJS= mkrandkeys.o -OIFOBJS= omakeIPFP.o -UNXOBJS= unixcert.o -MD5OBJS= md5driver.o - -SOURCE= authcert.c authspeed.c keyparity.c makeIPFP.c makePC1.c \ - makePC2.c makeSP.c mkrandkeys.c omakeIPFP.c unixcert.c md5driver.c - -all: $(PROGRAM) - -authcert: $(CRTOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(CRTOBJS) $(LIB) $(COMPAT) $(RESLIB) - -authspeed: $(SPDOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(SPDOBJS) $(LIB) $(COMPAT) $(RESLIB) - -keyparity: $(PAROBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(PAROBJS) $(LIB) $(COMPAT) $(RESLIB) - -makeIPFP: $(IFPOBJS) - $(CC) $(COPTS) -o $@ $(IFPOBJS) - -makePC1: $(PC1OBJS) - $(CC) $(COPTS) -o $@ $(PC1OBJS) - -makePC2: $(PC2OBJS) - $(CC) $(COPTS) -o $@ $(PC2OBJS) - -makeSP: $(SPOBJS) - $(CC) $(COPTS) -o $@ $(SPOBJS) - -mkrandkeys: $(RNDOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(RNDOBJS) $(LIB) - -omakeIPFP: $(OIFBJS) - $(CC) $(COPTS) -o $@ $(OIFBJS) - -unixcert: $(UNXBJS) - $(CC) $(COPTS) -o $@ $(UNXBJS) - -md5: $(MD5OBJS) - $(CC) $(COPTS) -o $@ $(MD5OBJS) $(LIB) $(COMPAT) $(RESLIB) - -tags: - ctags *.c *.h - -install: - # Don't install any of this shit - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak keyparity \ - makeIPFP makePC1 makePC2 makeSP mkrandkeys omakeIPFP unixcert \ - lint.errs md5cert - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - diff --git a/usr.sbin/xntpd/clockstuff/Makefile.tmpl b/usr.sbin/xntpd/clockstuff/Makefile.tmpl deleted file mode 100644 index 9a0f9c184b43..000000000000 --- a/usr.sbin/xntpd/clockstuff/Makefile.tmpl +++ /dev/null @@ -1,60 +0,0 @@ -# -# Makefile.tmpl,v 3.1 1993/07/06 01:05:19 jbj Exp -# -PROGRAM= propdelay -# -# Makefile for clock miscellany -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -DEFS= -DEFS_OPT= -DEFS_LOCAL= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -INSTALL= install -# -SOURCE= chutest.c propdelay.c -OBJS= propdelay.o -CHUOBJS= chutest.o -CLKOBJS= clktest.o - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) - $(CC) $(COPTS) -o $@ $(OBJS) -lm $(COMPAT) - -chutest: $(CHUOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(CHUOBJS) $(LIB) - -clktest: $(CLKOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(CLKOBJS) $(LIB) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) -# $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak chutest clktest \ - lint.errs - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - diff --git a/usr.sbin/xntpd/compilers/README b/usr.sbin/xntpd/compilers/README deleted file mode 100644 index 46794dc5399c..000000000000 --- a/usr.sbin/xntpd/compilers/README +++ /dev/null @@ -1,5 +0,0 @@ -README file for directory ./compilers of the NTP Version 3 distribution - -This directory contains configuration files for the various machines -and compilers supported by the distribution. README and RELNOTES files in the -parent directory for directions on how to use these files. diff --git a/usr.sbin/xntpd/compilers/aux2.gcc b/usr.sbin/xntpd/compilers/aux2.gcc deleted file mode 100644 index 53672c45366e..000000000000 --- a/usr.sbin/xntpd/compilers/aux2.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=gcc -O -pipe -finline-functions -fomit-frame-pointer -D_POSIX_SOURCE diff --git a/usr.sbin/xntpd/compilers/aux3.gcc b/usr.sbin/xntpd/compilers/aux3.gcc deleted file mode 100644 index 53672c45366e..000000000000 --- a/usr.sbin/xntpd/compilers/aux3.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=gcc -O -pipe -finline-functions -fomit-frame-pointer -D_POSIX_SOURCE diff --git a/usr.sbin/xntpd/compilers/decosf1.gcc b/usr.sbin/xntpd/compilers/decosf1.gcc deleted file mode 100644 index d071385d7a79..000000000000 --- a/usr.sbin/xntpd/compilers/decosf1.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= gcc -Wall -O2 -finline-functions diff --git a/usr.sbin/xntpd/compilers/domainos.cc b/usr.sbin/xntpd/compilers/domainos.cc deleted file mode 100644 index eb4dd629860a..000000000000 --- a/usr.sbin/xntpd/compilers/domainos.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= cc diff --git a/usr.sbin/xntpd/compilers/hpux-adj.cc b/usr.sbin/xntpd/compilers/hpux-adj.cc deleted file mode 100644 index cf058ef46b5c..000000000000 --- a/usr.sbin/xntpd/compilers/hpux-adj.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=cc +O1 diff --git a/usr.sbin/xntpd/compilers/hpux-adj.gcc b/usr.sbin/xntpd/compilers/hpux-adj.gcc deleted file mode 100644 index e085a80112dd..000000000000 --- a/usr.sbin/xntpd/compilers/hpux-adj.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=gcc -O2 diff --git a/usr.sbin/xntpd/compilers/hpux.cc b/usr.sbin/xntpd/compilers/hpux.cc deleted file mode 100644 index cf058ef46b5c..000000000000 --- a/usr.sbin/xntpd/compilers/hpux.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=cc +O1 diff --git a/usr.sbin/xntpd/compilers/hpux.gcc b/usr.sbin/xntpd/compilers/hpux.gcc deleted file mode 100644 index e085a80112dd..000000000000 --- a/usr.sbin/xntpd/compilers/hpux.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=gcc -O2 diff --git a/usr.sbin/xntpd/compilers/hpux10+.cc b/usr.sbin/xntpd/compilers/hpux10+.cc deleted file mode 100644 index cf058ef46b5c..000000000000 --- a/usr.sbin/xntpd/compilers/hpux10+.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER=cc +O1 diff --git a/usr.sbin/xntpd/compilers/irix4.cc b/usr.sbin/xntpd/compilers/irix4.cc deleted file mode 100644 index c5ae3af3ed42..000000000000 --- a/usr.sbin/xntpd/compilers/irix4.cc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= cc -cckr -COPTS= -O2 diff --git a/usr.sbin/xntpd/compilers/linux.gcc b/usr.sbin/xntpd/compilers/linux.gcc deleted file mode 100644 index 1051fcb8e68d..000000000000 --- a/usr.sbin/xntpd/compilers/linux.gcc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= gcc -DUSE_PROTOTYPES -Wall -COPTS= -O2 -finline-functions -fomit-frame-pointer diff --git a/usr.sbin/xntpd/compilers/mips.cc b/usr.sbin/xntpd/compilers/mips.cc deleted file mode 100644 index dcd8697077ab..000000000000 --- a/usr.sbin/xntpd/compilers/mips.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= cc -systype bsd43 diff --git a/usr.sbin/xntpd/compilers/sinix-m.cc b/usr.sbin/xntpd/compilers/sinix-m.cc deleted file mode 100644 index e4712dc89ed6..000000000000 --- a/usr.sbin/xntpd/compilers/sinix-m.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= /usr/ucb/cc diff --git a/usr.sbin/xntpd/compilers/sinix-m.gcc b/usr.sbin/xntpd/compilers/sinix-m.gcc deleted file mode 100644 index fe6af589c439..000000000000 --- a/usr.sbin/xntpd/compilers/sinix-m.gcc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= gcc -traditional - diff --git a/usr.sbin/xntpd/compilers/sunos4.bsd.cc b/usr.sbin/xntpd/compilers/sunos4.bsd.cc deleted file mode 100644 index eb4dd629860a..000000000000 --- a/usr.sbin/xntpd/compilers/sunos4.bsd.cc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= cc diff --git a/usr.sbin/xntpd/compilers/sunos4.bsd.gcc b/usr.sbin/xntpd/compilers/sunos4.bsd.gcc deleted file mode 100644 index 09e841a2b4de..000000000000 --- a/usr.sbin/xntpd/compilers/sunos4.bsd.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= gcc -DUSE_PROTOTYPES -Wall -O2 -finline-functions -fdelayed-branch -fomit-frame-pointer diff --git a/usr.sbin/xntpd/compilers/sunos4.posix.gcc b/usr.sbin/xntpd/compilers/sunos4.posix.gcc deleted file mode 100644 index 09e841a2b4de..000000000000 --- a/usr.sbin/xntpd/compilers/sunos4.posix.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= gcc -DUSE_PROTOTYPES -Wall -O2 -finline-functions -fdelayed-branch -fomit-frame-pointer diff --git a/usr.sbin/xntpd/compilers/sunos5.1.gcc b/usr.sbin/xntpd/compilers/sunos5.1.gcc deleted file mode 100644 index fe6af589c439..000000000000 --- a/usr.sbin/xntpd/compilers/sunos5.1.gcc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= gcc -traditional - diff --git a/usr.sbin/xntpd/compilers/sunos5.2.gcc b/usr.sbin/xntpd/compilers/sunos5.2.gcc deleted file mode 100644 index fe6af589c439..000000000000 --- a/usr.sbin/xntpd/compilers/sunos5.2.gcc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= gcc -traditional - diff --git a/usr.sbin/xntpd/compilers/ultrix.bsd.cc b/usr.sbin/xntpd/compilers/ultrix.bsd.cc deleted file mode 100644 index 06f68830e503..000000000000 --- a/usr.sbin/xntpd/compilers/ultrix.bsd.cc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= cc -Olimit 800 - diff --git a/usr.sbin/xntpd/compilers/ultrix.bsd.gcc b/usr.sbin/xntpd/compilers/ultrix.bsd.gcc deleted file mode 100644 index 5ed9d554abc8..000000000000 --- a/usr.sbin/xntpd/compilers/ultrix.bsd.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= gcc -Wall -O2 -finline-functions -fdelayed-branch diff --git a/usr.sbin/xntpd/compilers/ultrix.posix.cc b/usr.sbin/xntpd/compilers/ultrix.posix.cc deleted file mode 100644 index 06f68830e503..000000000000 --- a/usr.sbin/xntpd/compilers/ultrix.posix.cc +++ /dev/null @@ -1,2 +0,0 @@ -COMPILER= cc -Olimit 800 - diff --git a/usr.sbin/xntpd/compilers/ultrix.posix.gcc b/usr.sbin/xntpd/compilers/ultrix.posix.gcc deleted file mode 100644 index 5ed9d554abc8..000000000000 --- a/usr.sbin/xntpd/compilers/ultrix.posix.gcc +++ /dev/null @@ -1 +0,0 @@ -COMPILER= gcc -Wall -O2 -finline-functions -fdelayed-branch diff --git a/usr.sbin/xntpd/gadget/README b/usr.sbin/xntpd/gadget/README deleted file mode 100644 index 35bbc18ad2b8..000000000000 --- a/usr.sbin/xntpd/gadget/README +++ /dev/null @@ -1,84 +0,0 @@ -Gadget Box - -The gadget box is a 5"x3"x2" aluminum minibox containing level-converter -and modem circuitry and intended for use with host time servers -supporting the Network Time Protocol. It includes two subcircuits. One -of these converts a TTL positive edge into a fixed-width pulse at EIA -levels and is for use with a timecode receiver or oscillator including a -TTL one-pulse-per-second (1-pps) output. The other converts the timecode -modulation broadcast by Canadian time/frequency standard station CHU -into a 300-bps serial character stream at EIA levels and is for use with -the clk_chu.c or clk_chu_STREAMS.c modules in the xntp3 distribution. - -This archive contains complete construction details for the gadget box, -including schematic, parts list and artwork for a two-sided, printed- -circuit board. All files are in PostScript, with the exception of this -file and an information file, which are in ASCII. The artwork is in the -1:1 scale and is suitable for direct printing on photographic resist for -each side of the board. While a plated-through-holes process is most -convenient, it is possible to bridge the two sides using soldered wires -where necessary. - -Following is a brief functional description of the device. See the -schematic diagram gadget.s01 for reference. The audio output of a -shortwave radio tuned to CHU at 3330, 7335 or 14670 kHz is connected to -J2. A level of at least 30 mV peak-peak is required, such as provided by -the recorder output on many receivers. The input level is adjusted by -potentiometer R8 so that the timecode modulation broadcast at 31-39 -seconds past the minute reliably lights green LED1, but the signals -broadcast during other seconds of the minute do not. - -Opamp U4A provides low-impedance drive for the bridged-tee bandpass -filter U4B. The filter has a bandpass of about 600 Hz at the 6-dB points -and a center frequency of about 2150 Hz. It is designed to avoid -aliasing effects with receivers of relatively wide bandpass -characteristics. The modem itself is implemented by U2 and its -associated circuitry. Resistors R4 and R1 are a 40-dB pad which matches -the filter output to the modem input. U2 is a TTL/EIA level converter -with integral power supply for bipolar signals. The modem output is -available at pin 3 (receive data) of DB25 connector J1. - -The TTL 1-pps signal is connected via J3 to a retriggerable one-shot -U3A, which generates a TTL pulse of width determined by potentiometer -R7. The pulse width is determined by the bit rate of the attached serial -port. In the common case the width is one bit-time, such as 26 us for -38.4 kbps, for example. This appears to the port as a single start bit -of zero followed by eight bits of ones and a stop bit of one. The second -one-shot U3B generates a 200-ms pulse suitable for driving the amber -LED3 as a visual monitor. The output of U3A is converted to EIA levels -by U1 and appears at pin 12 (secondary receive data) of J1. - -If only the 1-pps circuit is required, U2 and U4 can be deleted and the -gadget box powered from the EIA modem-control signal at pin 20 (terminal -ready) of J1, assuming this signal is placed in the on (positive -voltage) condition by the computer program. J1 is wired to keep most -finicky UARTs and terminal-driver programs happy. If the CHU circuit is -required, an external 12-volt AC transformer or 9-12-volt DC supply -connected to J4 is required. Red LED2 indicates power is supplied to the -box. - -Following is a list of files included in this archive. All files are in -PostScript, except this one (README) and the information file -(gadget.lst), which are in ASCII. The files gadget.s01, gadget.s02 and -gadget.lst were generated using the Schema schematic-capture program -from Omation. The printed-circuit files *.lpr were generated using -Schema-PCB, also from Omation. - -Files ----------------------------------------- -README this file -gadget.s01 circuit schematic -gadget.s02 minibox assembly drawing -gadget.lst net list, pin list, parts list, etc. -gen0102.lpr pcb x-ray diagram -art01.lpr pcb artword side 1 -art02.lpr pcb artwork side 2 -adt0127.lpr pcb assembly drawing -dd0124.lpr pcb drill drawing -sm0228.lpr pcb solder mask (side 2) -sst0126.lpr pcb silkscreen mask (side 1) - -Dave Mills -University of Delaware -6 July 1992 -Revised 21 August 1992 diff --git a/usr.sbin/xntpd/gadget/adt0127.lpr b/usr.sbin/xntpd/gadget/adt0127.lpr deleted file mode 100644 index f0359e897d5a..000000000000 --- a/usr.sbin/xntpd/gadget/adt0127.lpr +++ /dev/null @@ -1,1427 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:35:14 1992) show -gsave -Init -8000 10500 Clipto -4025 2626 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 0 [ -1350 4900 ] PLine --1350 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 0 ] PLine -1350 0 [ -1350 0 ] PLine -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -10 SetLine -400 5100 [ 1350 5100 ] PLine -10 SetLine -1350 5100 [ 1300 5150 ] PLine -10 SetLine -1350 5100 [ 1300 5050 ] PLine -10 SetLine --1525 4900 [ -1375 4900 ] PLine -10 SetLine --1350 5100 [ -375 5100 ] PLine -10 SetLine --1350 5100 [ -1300 5150 ] PLine -10 SetLine --1350 5100 [ -1300 5050 ] PLine -10 SetLine --1542 0 [ -1367 0 ] PLine -10 SetLine --1500 0 [ -1500 1965 ] PLine -10 SetLine --1500 0 [ -1450 50 ] PLine -10 SetLine --1500 0 [ -1550 50 ] PLine -10 SetLine --1500 4900 [ -1450 4850 ] PLine -10 SetLine --1500 4900 [ -1550 4850 ] PLine -10 SetLine -1350 5150 [ 1350 4925 ] PLine -10 SetLine --1350 5150 [ -1350 4925 ] PLine -10 SetLine --1500 4900 [ -1500 2750 ] PLine -10 SetLine --1050 1400 [ -1050 1200 ] PLine --1050 1200 [ -1150 1200 ] PLine --1150 1200 [ -1150 1400 ] PLine --1150 1400 [ -1050 1400 ] PLine -10 SetLine --50 3300 [ -100 3300 ] PLine -10 SetLine -250 3235 [ -50 3235 ] PLine --50 3235 [ -50 3365 ] PLine --50 3365 [ 250 3365 ] PLine -250 3365 [ 250 3235 ] PLine -10 SetLine -300 3300 [ 250 3300 ] PLine -10 SetLine -250 3100 [ 300 3100 ] PLine -10 SetLine --50 3165 [ 250 3165 ] PLine -250 3165 [ 250 3035 ] PLine -250 3035 [ -50 3035 ] PLine --50 3035 [ -50 3165 ] PLine -10 SetLine --100 3100 [ -50 3100 ] PLine -10 SetLine --50 3500 [ -100 3500 ] PLine -10 SetLine -250 3435 [ -50 3435 ] PLine --50 3435 [ -50 3565 ] PLine --50 3565 [ 250 3565 ] PLine -250 3565 [ 250 3435 ] PLine -10 SetLine -300 3500 [ 250 3500 ] PLine -10 SetLine --1150 3700 [ -1200 3700 ] PLine -10 SetLine --450 3575 [ -1150 3575 ] PLine --1150 3575 [ -1150 3825 ] PLine --1150 3825 [ -450 3825 ] PLine --450 3825 [ -450 3575 ] PLine -10 SetLine --400 3700 [ -450 3700 ] PLine -10 SetLine --850 1300 [ -900 1300 ] PLine -10 SetLine --150 1175 [ -850 1175 ] PLine --850 1175 [ -850 1425 ] PLine --850 1425 [ -150 1425 ] PLine --150 1425 [ -150 1175 ] PLine -10 SetLine --100 1300 [ -150 1300 ] PLine -10 SetLine -550 2800 [ 600 2800 ] PLine -10 SetLine --150 2925 [ 550 2925 ] PLine -550 2925 [ 550 2675 ] PLine -550 2675 [ -150 2675 ] PLine --150 2675 [ -150 2925 ] PLine -10 SetLine --200 2800 [ -150 2800 ] PLine -10 SetLine --450 2800 [ -400 2800 ] PLine -10 SetLine --1150 2925 [ -450 2925 ] PLine --450 2925 [ -450 2675 ] PLine --450 2675 [ -1150 2675 ] PLine --1150 2675 [ -1150 2925 ] PLine -10 SetLine --1200 2800 [ -1150 2800 ] PLine -10 SetLine -0 2150 [ 0 2100 ] PLine -10 SetLine -65 2450 [ 65 2150 ] PLine -65 2150 [ -65 2150 ] PLine --65 2150 [ -65 2450 ] PLine --65 2450 [ 65 2450 ] PLine -10 SetLine -0 2500 [ 0 2450 ] PLine -10 SetLine --1200 3050 [ -1200 3000 ] PLine -10 SetLine --1135 3350 [ -1135 3050 ] PLine --1135 3050 [ -1265 3050 ] PLine --1265 3050 [ -1265 3350 ] PLine --1265 3350 [ -1135 3350 ] PLine -10 SetLine --1200 3400 [ -1200 3350 ] PLine -10 SetLine --950 2250 [ -1150 2250 ] PLine --1150 2250 [ -1150 2350 ] PLine --1150 2350 [ -950 2350 ] PLine --950 2350 [ -950 2250 ] PLine -10 SetLine --1150 2550 [ -950 2550 ] PLine --950 2550 [ -950 2450 ] PLine --950 2450 [ -1150 2450 ] PLine --1150 2450 [ -1150 2550 ] PLine -10 SetLine -850 2850 [ 1050 2850 ] PLine -1050 2850 [ 1050 2750 ] PLine -1050 2750 [ 850 2750 ] PLine -850 2750 [ 850 2850 ] PLine -10 SetLine -500 1900 [ 450 1900 ] PLine -10 SetLine -1200 1775 [ 500 1775 ] PLine -500 1775 [ 500 2025 ] PLine -500 2025 [ 1200 2025 ] PLine -1200 2025 [ 1200 1775 ] PLine -10 SetLine -1250 1900 [ 1200 1900 ] PLine -10 SetLine --1150 900 [ -1200 900 ] PLine -10 SetLine --150 725 [ -1150 725 ] PLine --1150 725 [ -1150 1075 ] PLine --1150 1075 [ -150 1075 ] PLine --150 1075 [ -150 725 ] PLine -10 SetLine --100 900 [ -150 900 ] PLine -10 SetLine --1050 4000 [ -1100 4000 ] PLine -10 SetLine --750 3935 [ -1050 3935 ] PLine --1050 3935 [ -1050 4065 ] PLine --1050 4065 [ -750 4065 ] PLine --750 4065 [ -750 3935 ] PLine -10 SetLine --700 4000 [ -750 4000 ] PLine -10 SetLine -750 3000 [ 700 3000 ] PLine -10 SetLine -1050 2935 [ 750 2935 ] PLine -750 2935 [ 750 3065 ] PLine -750 3065 [ 1050 3065 ] PLine -1050 3065 [ 1050 2935 ] PLine -10 SetLine -1100 3000 [ 1050 3000 ] PLine -10 SetLine --250 3750 [ -50 3750 ] PLine --50 3750 [ -50 3650 ] PLine --50 3650 [ -250 3650 ] PLine --250 3650 [ -250 3750 ] PLine -10 SetLine -200 900 [ 150 900 ] PLine -10 SetLine -270 950 [ 270 850 ] PLine -10 SetLine -200 850 [ 200 950 ] PLine -200 950 [ 500 950 ] PLine -500 950 [ 500 850 ] PLine -500 850 [ 200 850 ] PLine -10 SetLine -500 900 [ 550 900 ] PLine -10 SetLine -250 850 [ 250 950 ] PLine -10 SetLine -260 850 [ 260 950 ] PLine -10 SetLine -600 3700 [ 650 3700 ] PLine -10 SetLine -530 3650 [ 530 3750 ] PLine -10 SetLine -600 3750 [ 600 3650 ] PLine -600 3650 [ 300 3650 ] PLine -300 3650 [ 300 3750 ] PLine -300 3750 [ 600 3750 ] PLine -10 SetLine -300 3700 [ 250 3700 ] PLine -10 SetLine -550 3750 [ 550 3650 ] PLine -10 SetLine -540 3750 [ 540 3650 ] PLine -10 SetLine --750 550 100 PCircle -10 SetLine -0 550 100 PCircle -10 SetLine -750 550 100 PCircle -10 SetLine -768 5000 [ 768 5248 ] PLine -768 5248 [ -768 5248 ] PLine --768 5248 [ -768 5000 ] PLine -10 SetLine -1058 4900 [ -1058 4900 ] PLine -10 SetLine -1058 5000 [ 1058 4408 ] PLine -1058 4408 [ -1058 4408 ] PLine --1058 4408 [ -1058 5000 ] PLine --1058 5000 [ 1058 5000 ] PLine -10 SetLine -1058 5000 [ -1058 5000 ] PLine -10 SetLine -768 4900 [ 768 4408 ] PLine -10 SetLine --768 4900 [ -768 4408 ] PLine -10 SetLine -900 200 [ 1100 200 ] PLine -1100 200 [ 1100 100 ] PLine -1100 100 [ 900 100 ] PLine -900 100 [ 900 200 ] PLine -10 SetLine --100 200 [ 100 200 ] PLine -100 200 [ 100 100 ] PLine -100 100 [ -100 100 ] PLine --100 100 [ -100 200 ] PLine -10 SetLine --1100 200 [ -900 200 ] PLine --900 200 [ -900 100 ] PLine --900 100 [ -1100 100 ] PLine --1100 100 [ -1100 200 ] PLine -10 SetLine -916 3493 [ 900 3456 ] PLine -900 3456 [ 939 3442 ] PLine -939 3442 [ 953 3477 ] PLine -10 SetLine -988 3612 140 PCircle -10 SetLine --1000 1529 [ -1039 1490 ] PLine -10 SetLine --1000 1490 [ -1000 1910 ] PLine --1000 1910 [ -1300 1910 ] PLine --1300 1910 [ -1300 1490 ] PLine --1300 1490 [ -1000 1490 ] PLine -10 SetLine -200 1730 [ 200 1670 ] PLine -200 1670 [ 0 1670 ] PLine -0 1670 [ 0 1730 ] PLine -0 1730 [ 200 1730 ] PLine -10 SetLine -200 1700 [ 260 1700 ] PLine -10 SetLine -0 1700 [ -50 1700 ] PLine -10 SetLine -300 1270 [ 300 1330 ] PLine -300 1330 [ 500 1330 ] PLine -500 1330 [ 500 1270 ] PLine -500 1270 [ 300 1270 ] PLine -10 SetLine -300 1300 [ 240 1300 ] PLine -10 SetLine -500 1300 [ 550 1300 ] PLine -10 SetLine --600 2270 [ -600 2330 ] PLine --600 2330 [ -400 2330 ] PLine --400 2330 [ -400 2270 ] PLine --400 2270 [ -600 2270 ] PLine -10 SetLine --600 2300 [ -660 2300 ] PLine -10 SetLine --400 2300 [ -350 2300 ] PLine -10 SetLine --800 4230 [ -800 4170 ] PLine --800 4170 [ -1000 4170 ] PLine --1000 4170 [ -1000 4230 ] PLine --1000 4230 [ -800 4230 ] PLine -10 SetLine --800 4200 [ -740 4200 ] PLine -10 SetLine --1000 4200 [ -1050 4200 ] PLine -10 SetLine -1000 3230 [ 1000 3170 ] PLine -1000 3170 [ 800 3170 ] PLine -800 3170 [ 800 3230 ] PLine -800 3230 [ 1000 3230 ] PLine -10 SetLine -1000 3200 [ 1060 3200 ] PLine -10 SetLine -800 3200 [ 750 3200 ] PLine -10 SetLine --600 2470 [ -600 2530 ] PLine --600 2530 [ -400 2530 ] PLine --400 2530 [ -400 2470 ] PLine --400 2470 [ -600 2470 ] PLine -10 SetLine --600 2500 [ -660 2500 ] PLine -10 SetLine --400 2500 [ -350 2500 ] PLine -10 SetLine --600 2070 [ -600 2130 ] PLine --600 2130 [ -400 2130 ] PLine --400 2130 [ -400 2070 ] PLine --400 2070 [ -600 2070 ] PLine -10 SetLine --600 2100 [ -660 2100 ] PLine -10 SetLine --400 2100 [ -350 2100 ] PLine -10 SetLine --900 2130 [ -900 2070 ] PLine --900 2070 [ -1100 2070 ] PLine --1100 2070 [ -1100 2130 ] PLine --1100 2130 [ -900 2130 ] PLine -10 SetLine --900 2100 [ -840 2100 ] PLine -10 SetLine --1100 2100 [ -1150 2100 ] PLine -10 SetLine -500 1130 [ 500 1070 ] PLine -500 1070 [ 300 1070 ] PLine -300 1070 [ 300 1130 ] PLine -300 1130 [ 500 1130 ] PLine -10 SetLine -500 1100 [ 560 1100 ] PLine -10 SetLine -300 1100 [ 250 1100 ] PLine -10 SetLine -1000 2521 [ 1039 2560 ] PLine -10 SetLine -1000 2560 [ 1000 2140 ] PLine -1000 2140 [ 1300 2140 ] PLine -1300 2140 [ 1300 2560 ] PLine -1300 2560 [ 1000 2560 ] PLine -10 SetLine -0 1870 [ 0 1930 ] PLine -0 1930 [ 200 1930 ] PLine -200 1930 [ 200 1870 ] PLine -200 1870 [ 0 1870 ] PLine -10 SetLine -0 1900 [ -60 1900 ] PLine -10 SetLine -200 1900 [ 250 1900 ] PLine -10 SetLine -100 1470 [ 100 1530 ] PLine -100 1530 [ 300 1530 ] PLine -300 1530 [ 300 1470 ] PLine -300 1470 [ 100 1470 ] PLine -10 SetLine -100 1500 [ 40 1500 ] PLine -10 SetLine -300 1500 [ 350 1500 ] PLine -10 SetLine --950 1650 [ -250 1650 ] PLine --250 1650 [ -250 1850 ] PLine --250 1850 [ -950 1850 ] PLine --950 1850 [ -950 1775 ] PLine --950 1775 [ -900 1775 ] PLine --900 1775 [ -900 1725 ] PLine --900 1725 [ -950 1725 ] PLine --950 1725 [ -950 1650 ] PLine -10 SetLine -150 2250 [ 950 2250 ] PLine -950 2250 [ 950 2450 ] PLine -950 2450 [ 150 2450 ] PLine -150 2450 [ 150 2375 ] PLine -150 2375 [ 200 2375 ] PLine -200 2375 [ 200 2325 ] PLine -200 2325 [ 150 2325 ] PLine -150 2325 [ 150 2250 ] PLine -10 SetLine -150 3950 [ 1150 3950 ] PLine -1150 3950 [ 1150 4150 ] PLine -1150 4150 [ 150 4150 ] PLine -150 4150 [ 150 4075 ] PLine -150 4075 [ 200 4075 ] PLine -200 4075 [ 200 4025 ] PLine -200 4025 [ 150 4025 ] PLine -150 4025 [ 150 3950 ] PLine -10 SetLine --1050 3150 [ -250 3150 ] PLine --250 3150 [ -250 3350 ] PLine --250 3350 [ -1050 3350 ] PLine --1050 3350 [ -1050 3275 ] PLine --1050 3275 [ -1000 3275 ] PLine --1000 3275 [ -1000 3225 ] PLine --1000 3225 [ -1050 3225 ] PLine --1050 3225 [ -1050 3150 ] PLine -10 SetLine -800 1075 [ 800 1675 ] PLine -800 1675 [ 1200 1675 ] PLine -1200 1675 [ 1200 1075 ] PLine -1200 1075 [ 800 1075 ] PLine -10 SetLine -875 1075 [ 875 825 ] PLine -875 825 [ 925 825 ] PLine -925 825 [ 925 1075 ] PLine -10 SetLine -1075 1075 [ 1075 825 ] PLine -1075 825 [ 1125 825 ] PLine -1125 825 [ 1125 1075 ] PLine -10 SetLine -975 1075 [ 975 825 ] PLine -975 825 [ 1025 825 ] PLine -1025 825 [ 1025 1075 ] PLine -10 SetLine -996 1549 75 PCircle -10 SetLine -800 1425 [ 1200 1425 ] PLine -10 SetLine --100 4200 [ -25 4200 ] PLine -10 SetLine --100 3900 [ -100 4300 ] PLine --100 4300 [ -500 4300 ] PLine --500 4300 [ -500 3900 ] PLine --500 3900 [ -100 3900 ] PLine -10 SetLine --100 4000 [ -25 4000 ] PLine -10 SetLine --1100 450 100 PCircle -10 SetLine -1100 450 100 PCircle -10 SetLine -1000 3430 [ 1000 3370 ] PLine -1000 3370 [ 800 3370 ] PLine -800 3370 [ 800 3430 ] PLine -800 3430 [ 1000 3430 ] PLine -10 SetLine -1000 3400 [ 1060 3400 ] PLine -10 SetLine -800 3400 [ 750 3400 ] PLine -10 SetText2 -0 -1175 1225 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1175 1279 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -1175 1310 [ [ -65 29 -65 6 -37 4 -40 6 -43 13 -43 20 -40 27 -34 31 -25 34 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 75 3375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3375 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 75 3175 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3175 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 75 3575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3575 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -825 3850 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 3850 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -575 1450 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -521 1450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -490 1450 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 125 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 179 2950 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 210 2950 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -825 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 2950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 -100 2250 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -100 2304 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -100 2335 [ [ -65 4 -65 29 -40 15 -40 22 -37 27 -34 29 -25 31 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 -1275 3200 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1275 3254 [ [ -50 2 -53 2 -59 4 -62 6 -65 11 -65 20 -62 25 -59 27 -53 29 -46 29 -40 27 -31 22 0 0 0 31 ] ] Char -10 SetText2 -0 -1100 2375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1100 2575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2575 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2575 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 900 2875 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 954 2875 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 985 2875 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 800 2050 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 854 2050 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 885 2050 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 -675 1100 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -621 1100 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -590 1100 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -925 4075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -871 4075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 875 3075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 929 3075 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -200 3775 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -146 3775 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 325 975 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 377 975 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 450 3775 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 502 3775 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -775 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -732 675 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -50 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -7 675 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 700 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 743 675 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -1175 4650 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -1132 4650 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 1172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 1274 125 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 274 125 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -875 125 [ [ 0 65 0 0 27 0 ] ] Char -0 -828 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -778 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -726 125 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1075 3425 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] [ 20 12 34 -6 ] ] Char -0 1131 3425 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1075 1475 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 -1127 1475 [ [ -11 -65 -4 -62 -2 -56 -2 -50 -4 -43 -9 -40 -18 -37 -25 -34 -29 -28 -31 -21 -31 -12 -29 -6 -27 -3 -20 0 -11 0 -4 -3 -2 -6 0 -12 0 -21 -2 -28 -6 -34 -13 -37 -22 -40 -27 -43 -29 -50 -29 -56 -27 -62 -20 -65 -11 -65 ] ] Char -10 SetText2 -0 25 1750 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 77 1750 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 108 1750 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 350 1350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1350 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1350 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2350 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -925 4250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -873 4250 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 850 3250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 902 3250 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -550 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2150 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 -1025 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -973 2150 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 350 1150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1150 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1150 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 1200 2125 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 1148 2125 [ [ -31 -65 -9 0 ] [ 0 -65 -31 -65 ] ] Char -10 SetText2 -0 50 1950 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 102 1950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 150 1550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 202 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 233 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -675 1950 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 1950 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 450 2550 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 502 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 500 4275 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 552 4275 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -675 3450 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 950 1700 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 1002 1700 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -350 4325 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -298 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1225 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -1169 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 -1117 600 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1181 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 1233 600 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 800 3450 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 852 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 883 3450 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -1075 1225 [ [ -65 0 0 0 ] [ -65 0 -65 15 -62 22 -56 27 -50 29 -40 31 -25 31 -15 29 -9 27 -3 22 0 15 0 0 ] ] Char -0 -1075 1277 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1075 1331 [ [ -65 18 0 0 ] [ -65 18 0 36 ] [ -21 6 -21 29 ] ] Char -0 -1075 1387 [ [ -65 0 0 0 ] [ -65 0 -65 20 -62 27 -59 29 -53 31 -43 31 -37 29 -34 27 -31 20 -31 0 ] ] Char -10 SetText2 -0 75 3275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 127 3275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 181 3275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 237 3275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 289 3275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 75 3075 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 127 3075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 181 3075 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 237 3075 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 289 3075 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 75 3475 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 127 3475 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 181 3475 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 237 3475 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 289 3475 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 -825 3750 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 3750 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -715 3750 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 -663 3750 [ [ 0 78 40 -21 ] ] Char -0 -602 3750 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -546 3750 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -490 3750 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -436 3750 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 -575 1350 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -521 1350 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -465 1350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 -413 1350 [ [ 0 78 40 -21 ] ] Char -0 -352 1350 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -296 1350 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -240 1350 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -186 1350 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 125 2850 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 179 2850 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 235 2850 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 287 2850 [ [ 0 78 40 -21 ] ] Char -0 348 2850 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 404 2850 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 460 2850 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 514 2850 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 -825 2850 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 2850 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -715 2850 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 -663 2850 [ [ 0 78 40 -21 ] ] Char -0 -602 2850 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -546 2850 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -490 2850 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -436 2850 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 0 2250 [ [ -65 0 0 0 ] [ -65 0 -65 15 -62 22 -56 27 -50 29 -40 31 -25 31 -15 29 -9 27 -3 22 0 15 0 0 ] ] Char -0 0 2302 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 0 2356 [ [ -65 18 0 0 ] [ -65 18 0 36 ] [ -21 6 -21 29 ] ] Char -0 0 2412 [ [ -65 0 0 0 ] [ -65 0 -65 20 -62 27 -59 29 -53 31 -43 31 -37 29 -34 27 -31 20 -31 0 ] ] Char -0 0 2464 [ [ -65 0 0 0 ] [ -65 0 -65 29 ] [ -34 0 -34 18 ] [ 0 0 0 29 ] ] Char -10 SetText2 -0 -1175 3200 [ [ -65 0 0 0 ] [ -65 0 -65 15 -62 22 -56 27 -50 29 -40 31 -25 31 -15 29 -9 27 -3 22 0 15 0 0 ] ] Char -0 -1175 3252 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1175 3306 [ [ -65 18 0 0 ] [ -65 18 0 36 ] [ -21 6 -21 29 ] ] Char -0 -1175 3362 [ [ -65 0 0 0 ] [ -65 0 -65 20 -62 27 -59 29 -53 31 -43 31 -37 29 -34 27 -31 20 -31 0 ] ] Char -0 -1175 3414 [ [ -65 0 0 0 ] [ -65 0 -65 29 ] [ -34 0 -34 18 ] [ 0 0 0 29 ] ] Char -10 SetText2 -0 -1100 2275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -1048 2275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -994 2275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -938 2275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -10 SetText2 -0 -1100 2475 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -1048 2475 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -994 2475 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -938 2475 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -10 SetText2 -0 900 2775 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 952 2775 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 1006 2775 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 1062 2775 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -10 SetText2 -0 800 1950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 854 1950 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 910 1950 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 962 1950 [ [ 0 78 40 -21 ] ] Char -0 1023 1950 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1079 1950 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 1135 1950 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 1189 1950 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 -675 1000 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -621 1000 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -565 1000 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 -513 1000 [ [ 0 78 40 -21 ] ] Char -0 -452 1000 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -396 1000 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -340 1000 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -0 -290 1000 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 -925 3975 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -873 3975 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -819 3975 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -763 3975 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 -711 3975 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 875 2975 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 927 2975 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 981 2975 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 1037 2975 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 1089 2975 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 -200 3675 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -148 3675 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -94 3675 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -38 3675 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -10 SetText2 -0 325 875 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 377 875 [ [ 0 65 0 0 ] ] Char -0 397 875 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 453 875 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 505 875 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 450 3675 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 502 3675 [ [ 0 65 0 0 ] ] Char -0 522 3675 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 578 3675 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 630 3675 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 -775 575 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -723 575 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 -671 575 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 -619 575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -10 SetText2 -0 -50 575 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 2 575 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 54 575 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 106 575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -10 SetText2 -0 700 575 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 752 575 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 804 575 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 856 575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -10 SetText2 -0 -1175 4550 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1121 4550 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 -1065 4550 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 -1013 4550 [ [ 0 78 40 -21 ] ] Char -0 -952 4550 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -900 4550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 -848 4550 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 -796 4550 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -742 4550 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 -690 4550 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] ] Char -10 SetText2 -0 1125 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 1177 25 [ [ 0 65 0 0 27 0 ] ] Char -0 1224 25 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1274 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -10 SetText2 -0 125 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 177 25 [ [ 0 65 0 0 27 0 ] ] Char -0 224 25 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 274 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -10 SetText2 -0 -875 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -823 25 [ [ 0 65 0 0 27 0 ] ] Char -0 -776 25 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -726 25 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -10 SetText2 -0 1075 3325 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 1127 3325 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 1179 3325 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 1231 3325 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -0 1281 3325 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 1333 3325 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 -1075 1575 [ [ 0 -65 0 0 ] [ 0 -65 -15 -65 -22 -62 -27 -56 -29 -50 -31 -40 -31 -25 -29 -15 -27 -9 -22 -3 -15 0 0 0 ] ] Char -0 -1127 1575 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -43 -29 -37 -27 -34 -20 -31 0 -31 ] ] Char -0 -1179 1575 [ [ -13 -65 -9 -62 -4 -56 -2 -50 0 -40 0 -25 -2 -15 -4 -9 -9 -3 -13 0 -22 0 -27 -3 -31 -9 -34 -15 -36 -25 -36 -40 -34 -50 -31 -56 -27 -62 -22 -65 -13 -65 ] ] Char -0 -1235 1575 [ [ -15 -65 -15 0 ] [ 0 -65 -31 -65 ] ] Char -10 SetText2 -0 25 1650 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 77 1650 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 129 1650 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 179 1650 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 350 1250 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 402 1250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 454 1250 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 504 1250 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -550 2250 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -498 2250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -446 2250 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -396 2250 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -925 4150 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -873 4150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -821 4150 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -771 4150 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 850 3150 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 902 3150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 954 3150 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1004 3150 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -550 2450 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -498 2450 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -446 2450 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -396 2450 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -550 2050 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -498 2050 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -446 2050 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -396 2050 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -1025 2050 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -973 2050 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -921 2050 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -871 2050 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 350 1050 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 402 1050 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 454 1050 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 504 1050 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 1200 2225 [ [ 0 -65 0 0 ] [ 0 -65 -15 -65 -22 -62 -27 -56 -29 -50 -31 -40 -31 -25 -29 -15 -27 -9 -22 -3 -15 0 0 0 ] ] Char -0 1148 2225 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -43 -29 -37 -27 -34 -20 -31 0 -31 ] ] Char -0 1096 2225 [ [ -13 -65 -9 -62 -4 -56 -2 -50 0 -40 0 -25 -2 -15 -4 -9 -9 -3 -13 0 -22 0 -27 -3 -31 -9 -34 -15 -36 -25 -36 -40 -34 -50 -31 -56 -27 -62 -22 -65 -13 -65 ] ] Char -0 1040 2225 [ [ -15 -65 -15 0 ] [ 0 -65 -31 -65 ] ] Char -10 SetText2 -0 50 1850 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 102 1850 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 154 1850 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 204 1850 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 150 1450 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 202 1450 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 254 1450 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 304 1450 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -675 1850 [ [ 0 65 0 0 27 0 ] ] Char -0 -628 1850 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -572 1850 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -520 1850 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 -468 1850 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 450 2450 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -0 502 2450 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -0 556 2450 [ [ 0 65 0 0 27 0 ] ] Char -0 603 2450 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -0 655 2450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 686 2450 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 738 2450 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 500 4175 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 556 4175 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 610 4175 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 641 4175 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -0 695 4175 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 749 4175 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -0 803 4175 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -0 857 4175 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -675 3350 [ [ 0 65 0 0 ] ] Char -0 -655 3350 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -601 3350 [ [ 0 65 0 0 27 0 ] ] Char -0 -554 3350 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 -502 3350 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -0 -450 3350 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 950 1600 [ [ 0 65 0 0 27 0 ] ] Char -0 997 1600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1053 1600 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -0 1105 1600 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -0 1157 1600 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 1209 1600 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -350 4225 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -298 4225 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -246 4225 [ [ 15 65 15 0 ] [ 0 65 31 65 ] ] Char -0 -194 4225 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -138 4225 [ [ 0 65 0 0 27 0 ] ] Char -10 SetText2 -0 -1225 500 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -1169 500 [ [ 15 65 15 0 ] [ 0 65 31 65 ] ] Char -0 -1117 500 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 -1065 500 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 -1009 500 [ [ 0 65 0 0 27 0 ] ] Char -0 -962 500 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -912 500 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 -860 500 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 1125 500 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1181 500 [ [ 15 65 15 0 ] [ 0 65 31 65 ] ] Char -0 1233 500 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 1285 500 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 1341 500 [ [ 0 65 0 0 27 0 ] ] Char -0 1388 500 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1438 500 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 1490 500 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 800 3350 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 852 3350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 904 3350 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 954 3350 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 -300 4725 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -0 -248 4725 [ [ 0 65 0 0 ] ] Char -0 -228 4725 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -176 4725 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -74 4725 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -300 5075 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -0 -248 5075 [ [ 2 6 0 3 2 0 4 3 2 6 ] ] Char -0 -223 5075 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -0 -171 5075 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 -119 5075 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 -15 5075 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -0 46 5075 [ [ 40 78 0 -21 ] ] Char -0 107 5075 [ [ 0 28 40 28 ] ] Char -0 220 5075 [ [ 2 6 0 3 2 0 4 3 2 6 ] ] Char -0 245 5075 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 297 5075 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -0 349 5075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1475 2025 [ [ -65 22 -21 0 -21 34 ] [ -65 22 0 22 ] ] Char -0 -1475 2079 [ [ -6 2 -3 0 0 2 -3 4 -6 2 ] ] Char -0 -1475 2104 [ [ -43 29 -34 27 -28 22 -25 15 -25 13 -28 6 -34 2 -43 0 -46 0 -56 2 -62 6 -65 13 -65 15 -62 22 -56 27 -43 29 -28 29 -12 27 -3 22 0 15 0 11 -3 4 -9 2 ] ] Char -0 -1475 2154 [ [ -65 13 -62 6 -53 2 -37 0 -28 0 -12 2 -3 6 0 13 0 18 -3 25 -12 29 -28 31 -37 31 -53 29 -62 25 -65 18 -65 13 ] ] Char -0 -1475 2206 [ [ -65 13 -62 6 -53 2 -37 0 -28 0 -12 2 -3 6 0 13 0 18 -3 25 -12 29 -28 31 -37 31 -53 29 -62 25 -65 18 -65 13 ] ] Char -0 -1475 2310 [ [ -56 20 0 20 ] [ -28 0 -28 40 ] ] Char -0 -1475 2371 [ [ -78 40 21 0 ] ] Char -0 -1475 2432 [ [ -28 0 -28 40 ] ] Char -0 -1475 2545 [ [ -6 2 -3 0 0 2 -3 4 -6 2 ] ] Char -0 -1475 2570 [ [ -65 13 -62 6 -53 2 -37 0 -28 0 -12 2 -3 6 0 13 0 18 -3 25 -12 29 -28 31 -37 31 -53 29 -62 25 -65 18 -65 13 ] ] Char -0 -1475 2622 [ [ -65 13 -62 6 -53 2 -37 0 -28 0 -12 2 -3 6 0 13 0 18 -3 25 -12 29 -28 31 -37 31 -53 29 -62 25 -65 18 -65 13 ] ] Char -0 -1475 2674 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/art01.lpr b/usr.sbin/xntpd/gadget/art01.lpr deleted file mode 100644 index d770fed357b2..000000000000 --- a/usr.sbin/xntpd/gadget/art01.lpr +++ /dev/null @@ -1,890 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:34:56 1992) show -gsave -Init -8000 10500 Clipto -4000 2800 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -0 0 60 /PRndPad SetFlash --1100 1450 Flash --1100 1150 Flash -300 3300 Flash --100 3300 Flash --100 3100 Flash -300 3100 Flash -300 3500 Flash --100 3500 Flash --400 3700 Flash --1200 3700 Flash --100 1300 Flash --900 1300 Flash --200 2800 Flash -600 2800 Flash --1200 2800 Flash --400 2800 Flash -0 2500 Flash -0 2100 Flash --1200 3400 Flash --1200 3000 Flash --900 2300 Flash --1200 2300 Flash --1200 2500 Flash --900 2500 Flash -800 2800 Flash -1100 2800 Flash -1250 1900 Flash -450 1900 Flash --100 900 Flash --1200 900 Flash --700 4000 Flash --1100 4000 Flash -1100 3000 Flash -700 3000 Flash --300 3700 Flash -0 3700 Flash -0 0 60 /PSqrPad SetFlash -100 900 Flash -0 0 60 /PRndPad SetFlash -600 900 Flash -0 0 60 /PSqrPad SetFlash -700 3700 Flash -0 0 60 /PRndPad SetFlash -200 3700 Flash -0 0 70 /PRndPad SetFlash --750 550 Flash --750 450 Flash -0 550 Flash -0 450 Flash -750 550 Flash -750 450 Flash --648 4479 Flash --540 4479 Flash --432 4479 Flash --324 4479 Flash --216 4479 Flash --108 4479 Flash -0 4479 Flash -108 4479 Flash -216 4479 Flash -324 4479 Flash -432 4479 Flash -540 4479 Flash -648 4479 Flash --594 4593 Flash --486 4593 Flash --378 4593 Flash --270 4593 Flash --162 4593 Flash --54 4593 Flash -54 4593 Flash -162 4593 Flash -270 4593 Flash -378 4593 Flash -486 4593 Flash -594 4593 Flash -0 0 177 /PRndPad SetFlash -940 4536 Flash --940 4536 Flash -0 0 60 /PSqrPad SetFlash -950 150 Flash -0 0 60 /PRndPad SetFlash -1050 150 Flash -0 0 60 /PSqrPad SetFlash --50 150 Flash -0 0 60 /PRndPad SetFlash -50 150 Flash -0 0 60 /PSqrPad SetFlash --1050 150 Flash -0 0 60 /PRndPad SetFlash --950 150 Flash -0 0 50 /PRndPad SetFlash -950 3524 Flash -1026 3612 Flash -950 3700 Flash -0 0 60 /PSqrPad SetFlash --1200 1600 Flash -0 0 60 /PRndPad SetFlash --1100 1700 Flash --1200 1800 Flash -300 1700 Flash --100 1700 Flash -200 1300 Flash -600 1300 Flash --700 2300 Flash --300 2300 Flash --700 4200 Flash --1100 4200 Flash -1100 3200 Flash -700 3200 Flash --700 2500 Flash --300 2500 Flash --700 2100 Flash --300 2100 Flash --800 2100 Flash --1200 2100 Flash -600 1100 Flash -200 1100 Flash -0 0 60 /PSqrPad SetFlash -1200 2450 Flash -0 0 60 /PRndPad SetFlash -1100 2350 Flash -1200 2250 Flash --100 1900 Flash -300 1900 Flash -0 1500 Flash -400 1500 Flash -0 0 60 /PSqrPad SetFlash --900 1600 Flash -0 0 60 /PRndPad SetFlash --800 1600 Flash --700 1600 Flash --600 1600 Flash --500 1600 Flash --400 1600 Flash --300 1600 Flash --300 1900 Flash --400 1900 Flash --500 1900 Flash --600 1900 Flash --700 1900 Flash --800 1900 Flash --900 1900 Flash -0 0 60 /PSqrPad SetFlash -200 2200 Flash -0 0 60 /PRndPad SetFlash -300 2200 Flash -400 2200 Flash -500 2200 Flash -600 2200 Flash -700 2200 Flash -800 2200 Flash -900 2200 Flash -900 2500 Flash -800 2500 Flash -700 2500 Flash -600 2500 Flash -500 2500 Flash -400 2500 Flash -300 2500 Flash -200 2500 Flash -0 0 60 /PSqrPad SetFlash -200 3900 Flash -0 0 60 /PRndPad SetFlash -300 3900 Flash -400 3900 Flash -500 3900 Flash -600 3900 Flash -700 3900 Flash -800 3900 Flash -900 3900 Flash -1000 3900 Flash -1100 3900 Flash -1100 4200 Flash -1000 4200 Flash -900 4200 Flash -800 4200 Flash -700 4200 Flash -600 4200 Flash -500 4200 Flash -400 4200 Flash -300 4200 Flash -200 4200 Flash -0 0 60 /PSqrPad SetFlash --1000 3100 Flash -0 0 60 /PRndPad SetFlash --900 3100 Flash --800 3100 Flash --700 3100 Flash --600 3100 Flash --500 3100 Flash --400 3100 Flash --300 3100 Flash --300 3400 Flash --400 3400 Flash --500 3400 Flash --600 3400 Flash --700 3400 Flash --800 3400 Flash --900 3400 Flash --1000 3400 Flash -0 0 70 /PRndPad SetFlash -900 800 Flash -1100 800 Flash -1000 800 Flash -0 0 177 /PRndPad SetFlash -1000 1550 Flash -0 0 60 /PRndPad SetFlash -0 4000 Flash -0 4200 Flash -0 0 250 /PRndPad SetFlash --1100 450 Flash -1100 450 Flash -0 0 60 /PRndPad SetFlash -1100 3400 Flash -700 3400 Flash -10 SetText2 -0 -300 4725 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -0 -248 4725 [ [ 0 65 0 0 ] ] Char -0 -228 4725 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -176 4725 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -74 4725 [ [ 0 53 4 56 11 65 11 0 ] ] Char -12 SetLine --100 900 [ -100 800 ] PLine --100 800 [ 100 800 ] PLine -100 900 [ 100 800 ] PLine -100 800 [ 900 800 ] PLine -300 1100 [ 600 1100 ] PLine --1100 1150 [ -700 1150 ] PLine --700 1150 [ -700 1600 ] PLine -175 3300 [ -100 3300 ] PLine -700 3000 [ 300 3000 ] PLine -300 3000 [ 300 3100 ] PLine -300 2500 [ 300 2650 ] PLine -300 2650 [ 800 2650 ] PLine -800 2800 [ 800 2650 ] PLine -800 2650 [ 1000 2650 ] PLine -400 2500 [ 400 2600 ] PLine -400 2600 [ 1100 2600 ] PLine -1100 2600 [ 1100 2800 ] PLine --900 2300 [ -700 2100 ] PLine --700 2100 [ -450 2100 ] PLine -500 2500 [ 550 2550 ] PLine -550 2550 [ 750 2550 ] PLine -750 2550 [ 800 2500 ] PLine --650 2600 [ -100 2600 ] PLine --100 2250 [ 450 2250 ] PLine -450 2250 [ 500 2200 ] PLine --1200 2300 [ -1050 2300 ] PLine --1050 2300 [ -1050 2100 ] PLine --1050 2100 [ -800 2100 ] PLine --900 2500 [ -700 2300 ] PLine --700 2300 [ -700 2200 ] PLine --700 2200 [ -300 2200 ] PLine --300 2200 [ -300 2100 ] PLine -1250 1900 [ 1250 1800 ] PLine -1250 1800 [ 800 1800 ] PLine -300 1900 [ 300 1800 ] PLine -300 1800 [ 800 1800 ] PLine -700 1900 [ 450 1900 ] PLine -300 1700 [ 600 1700 ] PLine -500 1600 [ -100 1600 ] PLine --100 1600 [ -100 1700 ] PLine -1000 3900 [ 1050 3950 ] PLine -1050 3950 [ 1050 4050 ] PLine -1050 4050 [ 50 4050 ] PLine -50 4050 [ 0 4000 ] PLine -0 4100 [ 900 4100 ] PLine -800 3000 [ 1100 3000 ] PLine -0 3700 [ 0 3850 ] PLine -0 3850 [ 450 3850 ] PLine -450 3850 [ 500 3900 ] PLine --400 3400 [ -400 3600 ] PLine --400 3600 [ 300 3600 ] PLine -300 3600 [ 300 3700 ] PLine -300 3700 [ 600 3700 ] PLine -450 2700 [ -400 2700 ] PLine --400 2300 [ -300 2300 ] PLine --700 4200 [ -650 4250 ] PLine --650 4250 [ 550 4250 ] PLine -550 4250 [ 600 4200 ] PLine -350 3800 [ 1100 3800 ] PLine -1100 3800 [ 1100 3900 ] PLine --800 3100 [ -800 2800 ] PLine --800 2800 [ -400 2800 ] PLine --850 3700 [ -400 3700 ] PLine -400 1300 [ 600 1300 ] PLine --1100 4200 [ -1050 4150 ] PLine --1050 4150 [ 650 4150 ] PLine -650 4150 [ 700 4200 ] PLine --300 3400 [ -250 3350 ] PLine --250 3350 [ 1200 3350 ] PLine -1200 3350 [ 1200 4200 ] PLine -1200 4200 [ 1100 4200 ] PLine --700 3100 [ -700 2875 ] PLine --700 2875 [ -200 2875 ] PLine --200 2875 [ -200 2800 ] PLine --600 3100 [ -600 2950 ] PLine --600 2950 [ 600 2950 ] PLine -600 2950 [ 600 2800 ] PLine --750 550 [ -750 1050 ] PLine --750 1050 [ -1050 1050 ] PLine -950 3200 [ 700 3200 ] PLine -850 1200 [ -600 1200 ] PLine --550 3900 [ -350 3900 ] PLine -540 4479 [ 540 4300 ] PLine -540 4300 [ -800 4300 ] PLine -432 4479 [ 432 4350 ] PLine -432 4350 [ -750 4350 ] PLine -400 3400 [ 700 3400 ] PLine -50 SetLine --1000 3400 [ -1000 3250 ] PLine --1000 3250 [ -200 3250 ] PLine --200 3250 [ -200 3100 ] PLine --200 3100 [ -100 3100 ] PLine -0 2500 [ 0 2350 ] PLine -0 2350 [ 200 2350 ] PLine -200 2350 [ 200 2500 ] PLine -0 2350 [ -200 2350 ] PLine --1000 3400 [ -1200 3400 ] PLine -200 2350 [ 1100 2350 ] PLine -1100 2350 [ 1100 2450 ] PLine -1100 2450 [ 1200 2450 ] PLine --600 1600 [ -600 1750 ] PLine --600 1750 [ -200 1750 ] PLine --1200 3700 [ -1000 3700 ] PLine --1000 3700 [ -1000 3400 ] PLine -1100 3200 [ 1250 3200 ] PLine -1250 3200 [ 1250 2450 ] PLine -1250 2450 [ 1200 2450 ] PLine -900 4200 [ 900 4300 ] PLine -900 4300 [ 1250 4300 ] PLine -1250 4300 [ 1250 3200 ] PLine --700 4000 [ -1000 4000 ] PLine --1000 4000 [ -1000 3700 ] PLine -900 4200 [ 800 4200 ] PLine -200 1400 [ 1100 1400 ] PLine -1100 1400 [ 1100 800 ] PLine --50 450 [ -50 150 ] PLine -950 150 [ 1100 450 ] PLine -1100 450 [ 1000 800 ] PLine --250 450 [ -250 1000 ] PLine --250 1000 [ 200 1000 ] PLine -200 1000 [ 200 1100 ] PLine -0 450 [ -750 450 ] PLine --750 450 [ -1100 450 ] PLine -0 4475 [ 0 4400 ] PLine -0 4400 [ -648 4400 ] PLine --648 4400 [ -648 4479 ] PLine -75 4000 [ 300 4000 ] PLine -300 4000 [ 300 3900 ] PLine -1100 450 [ 750 450 ] PLine -750 450 [ 0 450 ] PLine -900 2200 [ 900 2000 ] PLine -900 2000 [ 75 2000 ] PLine -75 2000 [ 75 2200 ] PLine -75 2200 [ 200 2200 ] PLine -300 4000 [ 1000 4000 ] PLine --1100 450 [ -1050 150 ] PLine --600 1900 [ -600 2000 ] PLine --600 2000 [ 75 2000 ] PLine -75 2100 [ 0 2100 ] PLine -0 0 55 /PRndPad SetFlash --200 2350 Flash --200 1750 Flash -200 1400 Flash -0 0 55 /PRndPad SetFlash -300 1100 Flash -0 0 55 /PRndPad SetFlash -175 3300 Flash -0 0 55 /PRndPad SetFlash -1000 2650 Flash -0 0 55 /PRndPad SetFlash --450 2100 Flash -0 0 55 /PRndPad SetFlash --650 2600 Flash --100 2600 Flash --100 2250 Flash -0 0 55 /PRndPad SetFlash -800 1800 Flash -0 0 55 /PRndPad SetFlash -700 1900 Flash -0 0 55 /PRndPad SetFlash -600 1700 Flash -0 0 55 /PRndPad SetFlash -500 1600 Flash -0 0 55 /PRndPad SetFlash -0 4100 Flash -900 4100 Flash -0 0 55 /PRndPad SetFlash -800 3000 Flash -0 0 55 /PRndPad SetFlash -600 3700 Flash -0 0 55 /PRndPad SetFlash -450 2700 Flash --400 2700 Flash --400 2300 Flash -0 0 55 /PRndPad SetFlash -350 3800 Flash -0 0 55 /PRndPad SetFlash --850 3700 Flash -0 0 55 /PRndPad SetFlash -400 1300 Flash -0 0 55 /PRndPad SetFlash --1050 1050 Flash -0 0 55 /PRndPad SetFlash -0 4475 Flash -75 4000 Flash -1000 4000 Flash -0 0 55 /PRndPad SetFlash -950 3200 Flash -0 0 55 /PRndPad SetFlash -850 1200 Flash --600 1200 Flash -0 0 55 /PRndPad SetFlash --550 3900 Flash --350 3900 Flash -0 0 55 /PRndPad SetFlash --800 4300 Flash -0 0 55 /PRndPad SetFlash --750 4350 Flash -0 0 55 /PRndPad SetFlash -400 3400 Flash -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/art02.lpr b/usr.sbin/xntpd/gadget/art02.lpr deleted file mode 100644 index 1b336f378254..000000000000 --- a/usr.sbin/xntpd/gadget/art02.lpr +++ /dev/null @@ -1,893 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:35:02 1992) show -gsave -Init -8000 10500 Clipto -4000 2800 translate --1 1 scale -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -0 0 60 /PRndPad SetFlash --1100 1450 Flash --1100 1150 Flash -300 3300 Flash --100 3300 Flash --100 3100 Flash -300 3100 Flash -300 3500 Flash --100 3500 Flash --400 3700 Flash --1200 3700 Flash --100 1300 Flash --900 1300 Flash --200 2800 Flash -600 2800 Flash --1200 2800 Flash --400 2800 Flash -0 2500 Flash -0 2100 Flash --1200 3400 Flash --1200 3000 Flash --900 2300 Flash --1200 2300 Flash --1200 2500 Flash --900 2500 Flash -800 2800 Flash -1100 2800 Flash -1250 1900 Flash -450 1900 Flash --100 900 Flash --1200 900 Flash --700 4000 Flash --1100 4000 Flash -1100 3000 Flash -700 3000 Flash --300 3700 Flash -0 3700 Flash -0 0 60 /PSqrPad SetFlash -100 900 Flash -0 0 60 /PRndPad SetFlash -600 900 Flash -0 0 60 /PSqrPad SetFlash -700 3700 Flash -0 0 60 /PRndPad SetFlash -200 3700 Flash -0 0 70 /PRndPad SetFlash --750 550 Flash --750 450 Flash -0 550 Flash -0 450 Flash -750 550 Flash -750 450 Flash --648 4479 Flash --540 4479 Flash --432 4479 Flash --324 4479 Flash --216 4479 Flash --108 4479 Flash -0 4479 Flash -108 4479 Flash -216 4479 Flash -324 4479 Flash -432 4479 Flash -540 4479 Flash -648 4479 Flash --594 4593 Flash --486 4593 Flash --378 4593 Flash --270 4593 Flash --162 4593 Flash --54 4593 Flash -54 4593 Flash -162 4593 Flash -270 4593 Flash -378 4593 Flash -486 4593 Flash -594 4593 Flash -0 0 177 /PRndPad SetFlash -940 4536 Flash --940 4536 Flash -0 0 60 /PSqrPad SetFlash -950 150 Flash -0 0 60 /PRndPad SetFlash -1050 150 Flash -0 0 60 /PSqrPad SetFlash --50 150 Flash -0 0 60 /PRndPad SetFlash -50 150 Flash -0 0 60 /PSqrPad SetFlash --1050 150 Flash -0 0 60 /PRndPad SetFlash --950 150 Flash -0 0 50 /PRndPad SetFlash -950 3524 Flash -1026 3612 Flash -950 3700 Flash -0 0 60 /PSqrPad SetFlash --1200 1600 Flash -0 0 60 /PRndPad SetFlash --1100 1700 Flash --1200 1800 Flash -300 1700 Flash --100 1700 Flash -200 1300 Flash -600 1300 Flash --700 2300 Flash --300 2300 Flash --700 4200 Flash --1100 4200 Flash -1100 3200 Flash -700 3200 Flash --700 2500 Flash --300 2500 Flash --700 2100 Flash --300 2100 Flash --800 2100 Flash --1200 2100 Flash -600 1100 Flash -200 1100 Flash -0 0 60 /PSqrPad SetFlash -1200 2450 Flash -0 0 60 /PRndPad SetFlash -1100 2350 Flash -1200 2250 Flash --100 1900 Flash -300 1900 Flash -0 1500 Flash -400 1500 Flash -0 0 60 /PSqrPad SetFlash --900 1600 Flash -0 0 60 /PRndPad SetFlash --800 1600 Flash --700 1600 Flash --600 1600 Flash --500 1600 Flash --400 1600 Flash --300 1600 Flash --300 1900 Flash --400 1900 Flash --500 1900 Flash --600 1900 Flash --700 1900 Flash --800 1900 Flash --900 1900 Flash -0 0 60 /PSqrPad SetFlash -200 2200 Flash -0 0 60 /PRndPad SetFlash -300 2200 Flash -400 2200 Flash -500 2200 Flash -600 2200 Flash -700 2200 Flash -800 2200 Flash -900 2200 Flash -900 2500 Flash -800 2500 Flash -700 2500 Flash -600 2500 Flash -500 2500 Flash -400 2500 Flash -300 2500 Flash -200 2500 Flash -0 0 60 /PSqrPad SetFlash -200 3900 Flash -0 0 60 /PRndPad SetFlash -300 3900 Flash -400 3900 Flash -500 3900 Flash -600 3900 Flash -700 3900 Flash -800 3900 Flash -900 3900 Flash -1000 3900 Flash -1100 3900 Flash -1100 4200 Flash -1000 4200 Flash -900 4200 Flash -800 4200 Flash -700 4200 Flash -600 4200 Flash -500 4200 Flash -400 4200 Flash -300 4200 Flash -200 4200 Flash -0 0 60 /PSqrPad SetFlash --1000 3100 Flash -0 0 60 /PRndPad SetFlash --900 3100 Flash --800 3100 Flash --700 3100 Flash --600 3100 Flash --500 3100 Flash --400 3100 Flash --300 3100 Flash --300 3400 Flash --400 3400 Flash --500 3400 Flash --600 3400 Flash --700 3400 Flash --800 3400 Flash --900 3400 Flash --1000 3400 Flash -0 0 70 /PRndPad SetFlash -900 800 Flash -1100 800 Flash -1000 800 Flash -0 0 177 /PRndPad SetFlash -1000 1550 Flash -0 0 60 /PRndPad SetFlash -0 4000 Flash -0 4200 Flash -0 0 250 /PRndPad SetFlash --1100 450 Flash -1100 450 Flash -0 0 60 /PRndPad SetFlash -1100 3400 Flash -700 3400 Flash -10 SetText2 -0 300 4725 [ [ -31 56 -27 62 -20 65 -11 65 -4 62 0 56 0 50 -2 43 -4 40 -9 37 -22 31 -27 28 -29 25 -31 18 -31 9 -27 3 -20 0 -11 0 -4 3 0 9 ] ] Char -0 248 4725 [ [ 0 65 0 0 ] ] Char -0 228 4725 [ [ 0 65 0 0 ] [ 0 65 -15 65 -22 62 -27 56 -29 50 -31 40 -31 25 -29 15 -27 9 -22 3 -15 0 0 0 ] ] Char -0 176 4725 [ [ 0 65 0 0 ] [ 0 65 -29 65 ] [ 0 34 -18 34 ] [ 0 0 -29 0 ] ] Char -0 74 4725 [ [ -2 50 -2 53 -4 59 -6 62 -11 65 -20 65 -25 62 -27 59 -29 53 -29 46 -27 40 -22 31 0 0 -31 0 ] ] Char -12 SetLine -700 3700 [ 750 3650 ] PLine -750 3650 [ 750 800 ] PLine -750 800 [ 900 800 ] PLine -0 550 [ 300 550 ] PLine -300 550 [ 300 1100 ] PLine -300 2200 [ 250 2150 ] PLine -250 2150 [ 250 1600 ] PLine -250 1600 [ 300 1550 ] PLine -300 1550 [ 300 1100 ] PLine --700 2500 [ -550 2500 ] PLine --550 2500 [ -550 1700 ] PLine --550 1700 [ -700 1700 ] PLine --700 1700 [ -700 1600 ] PLine -300 3500 [ 175 3500 ] PLine -175 3500 [ 175 3100 ] PLine -175 3100 [ 300 3100 ] PLine -300 4200 [ 250 4150 ] PLine -250 4150 [ 250 3800 ] PLine -250 3800 [ 300 3750 ] PLine -300 3750 [ 300 3500 ] PLine --300 2500 [ -250 2550 ] PLine --250 2550 [ -250 3300 ] PLine --250 3300 [ -100 3300 ] PLine -300 4200 [ 400 4200 ] PLine --900 1600 [ -800 1600 ] PLine --800 1600 [ -800 1500 ] PLine --800 1500 [ -500 1500 ] PLine --500 1500 [ -500 1600 ] PLine -1000 2650 [ 1000 2250 ] PLine -1000 2250 [ 1200 2250 ] PLine -400 1500 [ 400 2200 ] PLine -400 2200 [ 400 2300 ] PLine -400 2300 [ 700 2300 ] PLine -700 2300 [ 700 2500 ] PLine --450 2100 [ -450 1650 ] PLine --450 1650 [ -400 1600 ] PLine --500 3400 [ -500 3150 ] PLine --500 3150 [ -650 3150 ] PLine --650 3150 [ -650 2600 ] PLine --100 2600 [ -100 2250 ] PLine --1200 2500 [ -1200 2300 ] PLine --300 2100 [ -250 2050 ] PLine --250 2050 [ -250 1650 ] PLine --250 1650 [ -300 1600 ] PLine -800 1800 [ 800 2200 ] PLine -600 900 [ 600 550 ] PLine -600 550 [ 750 550 ] PLine -700 2200 [ 700 1900 ] PLine -600 1700 [ 600 2200 ] PLine -1050 150 [ 1050 250 ] PLine -1050 250 [ 500 250 ] PLine -500 250 [ 500 1600 ] PLine -0 4200 [ 0 4100 ] PLine -900 4100 [ 900 3900 ] PLine -800 3900 [ 800 3000 ] PLine -600 3700 [ 600 3900 ] PLine -600 4200 [ 600 4075 ] PLine -600 4075 [ 450 4075 ] PLine -450 4075 [ 450 2700 ] PLine --400 2700 [ -400 2300 ] PLine -300 3300 [ 350 3350 ] PLine -350 3350 [ 350 3800 ] PLine --1200 2800 [ -1000 2800 ] PLine --1000 2800 [ -1000 3100 ] PLine --900 3100 [ -850 3150 ] PLine --850 3150 [ -850 3700 ] PLine -50 150 [ 400 150 ] PLine -400 150 [ 400 1300 ] PLine --500 3100 [ -500 3000 ] PLine --500 3000 [ -350 3000 ] PLine --350 3000 [ -350 1300 ] PLine --350 1300 [ -100 1300 ] PLine -200 3700 [ 150 3750 ] PLine -150 3750 [ 150 4425 ] PLine -150 4425 [ 108 4479 ] PLine -108 4479 [ 54 4593 ] PLine --108 4479 [ 50 4600 ] PLine -50 4600 [ 54 4593 ] PLine --324 4479 [ -216 4479 ] PLine --1100 1700 [ -1100 1450 ] PLine --1050 1050 [ -1050 1800 ] PLine --1050 1800 [ -1200 1800 ] PLine -950 3524 [ 950 3200 ] PLine -950 3700 [ 850 3700 ] PLine -850 3700 [ 850 1200 ] PLine --600 1200 [ -600 150 ] PLine --600 150 [ -950 150 ] PLine --540 4479 [ -550 4479 ] PLine --550 4479 [ -550 3900 ] PLine --350 3900 [ -350 3150 ] PLine --350 3150 [ -300 3100 ] PLine --432 4479 [ -450 4479 ] PLine --450 4479 [ -450 3150 ] PLine --450 3150 [ -382 3100 ] PLine --382 3100 [ -400 3100 ] PLine --800 4300 [ -800 3400 ] PLine --750 4350 [ -750 3450 ] PLine --750 3450 [ -700 3400 ] PLine -400 3900 [ 400 3400 ] PLine -1100 3400 [ 1100 3600 ] PLine -1100 3600 [ 1026 3600 ] PLine -1026 3600 [ 1026 3612 ] PLine -50 SetLine --100 3100 [ 0 3100 ] PLine -0 3100 [ 0 2500 ] PLine --200 2350 [ -200 1900 ] PLine --200 1900 [ -100 1900 ] PLine --200 1900 [ -200 1500 ] PLine --200 1500 [ 0 1500 ] PLine -0 1500 [ 200 1500 ] PLine -200 1500 [ 200 1300 ] PLine -800 4200 [ 800 4050 ] PLine -800 4050 [ 700 4050 ] PLine -700 4050 [ 700 3900 ] PLine --750 450 [ -900 450 ] PLine --900 450 [ -900 1300 ] PLine --1200 1600 [ -1275 1600 ] PLine --1275 1600 [ -1275 900 ] PLine --900 900 [ -1275 900 ] PLine --600 1900 [ -600 1750 ] PLine --600 1750 [ -975 1750 ] PLine --975 1750 [ -975 1300 ] PLine --975 1300 [ -900 1300 ] PLine --1200 2100 [ -1275 2100 ] PLine --1275 2100 [ -1275 1600 ] PLine --1200 3000 [ -1275 3000 ] PLine --1275 3000 [ -1275 2100 ] PLine --900 3400 [ -900 3525 ] PLine --900 3525 [ -1275 3525 ] PLine --1100 4000 [ -1275 4000 ] PLine --1275 4000 [ -1275 3000 ] PLine -75 3500 [ 75 2100 ] PLine -75 2100 [ 0 2100 ] PLine -75 2200 [ 200 2200 ] PLine -0 4479 [ 0 4400 ] PLine -0 4400 [ 75 4400 ] PLine -75 4400 [ 75 3500 ] PLine --300 3700 [ -300 3500 ] PLine --300 3500 [ 75 3500 ] PLine -900 2500 [ 900 2200 ] PLine -1000 4000 [ 1000 4200 ] PLine -0 0 55 /PRndPad SetFlash --200 2350 Flash --200 1750 Flash -200 1400 Flash -0 0 55 /PRndPad SetFlash -300 1100 Flash -0 0 55 /PRndPad SetFlash -175 3300 Flash -0 0 55 /PRndPad SetFlash -1000 2650 Flash -0 0 55 /PRndPad SetFlash --450 2100 Flash -0 0 55 /PRndPad SetFlash --650 2600 Flash --100 2600 Flash --100 2250 Flash -0 0 55 /PRndPad SetFlash -800 1800 Flash -0 0 55 /PRndPad SetFlash -700 1900 Flash -0 0 55 /PRndPad SetFlash -600 1700 Flash -0 0 55 /PRndPad SetFlash -500 1600 Flash -0 0 55 /PRndPad SetFlash -0 4100 Flash -900 4100 Flash -0 0 55 /PRndPad SetFlash -800 3000 Flash -0 0 55 /PRndPad SetFlash -600 3700 Flash -0 0 55 /PRndPad SetFlash -450 2700 Flash --400 2700 Flash --400 2300 Flash -0 0 55 /PRndPad SetFlash -350 3800 Flash -0 0 55 /PRndPad SetFlash --850 3700 Flash -0 0 55 /PRndPad SetFlash -400 1300 Flash -0 0 55 /PRndPad SetFlash --1050 1050 Flash -0 0 55 /PRndPad SetFlash -0 4475 Flash -75 4000 Flash -1000 4000 Flash -0 0 55 /PRndPad SetFlash -950 3200 Flash -0 0 55 /PRndPad SetFlash -850 1200 Flash --600 1200 Flash -0 0 55 /PRndPad SetFlash --550 3900 Flash --350 3900 Flash -0 0 55 /PRndPad SetFlash --800 4300 Flash -0 0 55 /PRndPad SetFlash --750 4350 Flash -0 0 55 /PRndPad SetFlash -400 3400 Flash -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/dd0124.lpr b/usr.sbin/xntpd/gadget/dd0124.lpr deleted file mode 100644 index f6474d43864d..000000000000 --- a/usr.sbin/xntpd/gadget/dd0124.lpr +++ /dev/null @@ -1,813 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:35:28 1992) show -gsave -Init -8000 10500 Clipto -4002 3763 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 0 [ -1350 4900 ] PLine --1350 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 0 ] PLine -1350 0 [ -1350 0 ] PLine -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -10 80 /M4 SetMkr --1100 1450 Marker --1100 1150 Marker -300 3300 Marker --100 3300 Marker --100 3100 Marker -300 3100 Marker -300 3500 Marker --100 3500 Marker --400 3700 Marker --1200 3700 Marker --100 1300 Marker --900 1300 Marker --200 2800 Marker -600 2800 Marker --1200 2800 Marker --400 2800 Marker -0 2500 Marker -0 2100 Marker --1200 3400 Marker --1200 3000 Marker --900 2300 Marker --1200 2300 Marker --1200 2500 Marker --900 2500 Marker -800 2800 Marker -1100 2800 Marker -1250 1900 Marker -450 1900 Marker --100 900 Marker --1200 900 Marker --700 4000 Marker --1100 4000 Marker -1100 3000 Marker -700 3000 Marker --300 3700 Marker -0 3700 Marker -10 80 /M7 SetMkr -100 900 Marker -1 113 913 [ [ 25 52 0 0 ] [ 0 52 25 52 ] [ 0 0 25 0 ] ] Char -600 900 Marker -1 613 913 [ [ 25 52 0 0 ] [ 0 52 25 52 ] [ 0 0 25 0 ] ] Char -700 3700 Marker -1 713 3713 [ [ 25 52 0 0 ] [ 0 52 25 52 ] [ 0 0 25 0 ] ] Char -200 3700 Marker -1 213 3713 [ [ 25 52 0 0 ] [ 0 52 25 52 ] [ 0 0 25 0 ] ] Char -10 80 /M4 SetMkr --750 550 Marker --750 450 Marker -0 550 Marker -0 450 Marker -750 550 Marker -750 450 Marker --648 4479 Marker --540 4479 Marker --432 4479 Marker --324 4479 Marker --216 4479 Marker --108 4479 Marker -0 4479 Marker -108 4479 Marker -216 4479 Marker -324 4479 Marker -432 4479 Marker -540 4479 Marker -648 4479 Marker --594 4593 Marker --486 4593 Marker --378 4593 Marker --270 4593 Marker --162 4593 Marker --54 4593 Marker -54 4593 Marker -162 4593 Marker -270 4593 Marker -378 4593 Marker -486 4593 Marker -594 4593 Marker -10 80 /M7 SetMkr -940 4536 Marker -1 953 4549 [ [ 0 52 14 27 14 0 ] [ 29 52 14 27 ] ] Char --940 4536 Marker -1 -927 4549 [ [ 0 52 14 27 14 0 ] [ 29 52 14 27 ] ] Char -10 80 /M4 SetMkr -950 150 Marker -1050 150 Marker --50 150 Marker -50 150 Marker --1050 150 Marker --950 150 Marker -10 80 /M7 SetMkr -950 3524 Marker -1 963 3537 [ [ 0 52 25 0 ] [ 25 52 0 0 ] ] Char -1026 3612 Marker -1 1039 3625 [ [ 0 52 25 0 ] [ 25 52 0 0 ] ] Char -950 3700 Marker -1 963 3713 [ [ 0 52 25 0 ] [ 25 52 0 0 ] ] Char -10 80 /M7 SetMkr --1200 1600 Marker -1 -1187 1613 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char --1100 1700 Marker -1 -1087 1713 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char --1200 1800 Marker -1 -1187 1813 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char -10 80 /M4 SetMkr -300 1700 Marker --100 1700 Marker -200 1300 Marker -600 1300 Marker --700 2300 Marker --300 2300 Marker --700 4200 Marker --1100 4200 Marker -1100 3200 Marker -700 3200 Marker --700 2500 Marker --300 2500 Marker --700 2100 Marker --300 2100 Marker --800 2100 Marker --1200 2100 Marker -600 1100 Marker -200 1100 Marker -10 80 /M7 SetMkr -1200 2450 Marker -1 1213 2463 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char -1100 2350 Marker -1 1113 2363 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char -1200 2250 Marker -1 1213 2263 [ [ 0 52 9 0 ] [ 18 52 9 0 ] [ 18 52 27 0 ] [ 36 52 27 0 ] ] Char -10 80 /M4 SetMkr --100 1900 Marker -300 1900 Marker -0 1500 Marker -400 1500 Marker --900 1600 Marker --800 1600 Marker --700 1600 Marker --600 1600 Marker --500 1600 Marker --400 1600 Marker --300 1600 Marker --300 1900 Marker --400 1900 Marker --500 1900 Marker --600 1900 Marker --700 1900 Marker --800 1900 Marker --900 1900 Marker -200 2200 Marker -300 2200 Marker -400 2200 Marker -500 2200 Marker -600 2200 Marker -700 2200 Marker -800 2200 Marker -900 2200 Marker -900 2500 Marker -800 2500 Marker -700 2500 Marker -600 2500 Marker -500 2500 Marker -400 2500 Marker -300 2500 Marker -200 2500 Marker -200 3900 Marker -300 3900 Marker -400 3900 Marker -500 3900 Marker -600 3900 Marker -700 3900 Marker -800 3900 Marker -900 3900 Marker -1000 3900 Marker -1100 3900 Marker -1100 4200 Marker -1000 4200 Marker -900 4200 Marker -800 4200 Marker -700 4200 Marker -600 4200 Marker -500 4200 Marker -400 4200 Marker -300 4200 Marker -200 4200 Marker --1000 3100 Marker --900 3100 Marker --800 3100 Marker --700 3100 Marker --600 3100 Marker --500 3100 Marker --400 3100 Marker --300 3100 Marker --300 3400 Marker --400 3400 Marker --500 3400 Marker --600 3400 Marker --700 3400 Marker --800 3400 Marker --900 3400 Marker --1000 3400 Marker -900 800 Marker -1100 800 Marker -1000 800 Marker -10 80 /M7 SetMkr -1000 1550 Marker -1 1013 1563 [ [ 0 52 14 27 14 0 ] [ 29 52 14 27 ] ] Char -10 80 /M4 SetMkr -0 4000 Marker -0 4200 Marker -10 80 /M7 SetMkr --1100 450 Marker -1 -1087 463 [ [ 0 52 14 27 14 0 ] [ 29 52 14 27 ] ] Char -1100 450 Marker -1 1113 463 [ [ 0 52 14 27 14 0 ] [ 29 52 14 27 ] ] Char -10 80 /M4 SetMkr -1100 3400 Marker -700 3400 Marker -10 80 /M4 SetMkr --200 2350 Marker --200 1750 Marker -200 1400 Marker -10 80 /M4 SetMkr -300 1100 Marker -10 80 /M4 SetMkr -175 3300 Marker -10 80 /M4 SetMkr -1000 2650 Marker -10 80 /M4 SetMkr --450 2100 Marker -10 80 /M4 SetMkr --650 2600 Marker --100 2600 Marker --100 2250 Marker -10 80 /M4 SetMkr -800 1800 Marker -10 80 /M4 SetMkr -700 1900 Marker -10 80 /M4 SetMkr -600 1700 Marker -10 80 /M4 SetMkr -500 1600 Marker -10 80 /M4 SetMkr -0 4100 Marker -900 4100 Marker -10 80 /M4 SetMkr -800 3000 Marker -10 80 /M4 SetMkr -600 3700 Marker -10 80 /M4 SetMkr -450 2700 Marker --400 2700 Marker --400 2300 Marker -10 80 /M4 SetMkr -350 3800 Marker -10 80 /M4 SetMkr --850 3700 Marker -10 80 /M4 SetMkr -400 1300 Marker -10 80 /M4 SetMkr --1050 1050 Marker -10 80 /M4 SetMkr -0 4475 Marker -75 4000 Marker -1000 4000 Marker -10 80 /M4 SetMkr -950 3200 Marker -10 80 /M4 SetMkr -850 1200 Marker --600 1200 Marker -10 80 /M4 SetMkr --550 3900 Marker --350 3900 Marker -10 80 /M4 SetMkr --800 4300 Marker -10 80 /M4 SetMkr --750 4350 Marker -10 80 /M4 SetMkr -400 3400 Marker -10 SetLine --1355 -485 [ -275 -485 ] PLine --1355 -725 [ -275 -725 ] PLine --1355 -965 [ -275 -965 ] PLine --1355 -1205 [ -275 -1205 ] PLine --1355 -1445 [ -275 -1445 ] PLine --1355 -1685 [ -275 -1685 ] PLine --1355 -1925 [ -275 -1925 ] PLine --1355 -485 [ -1355 -1925 ] PLine --995 -485 [ -995 -1925 ] PLine --635 -485 [ -635 -1925 ] PLine --275 -485 [ -275 -1925 ] PLine -10 SetText2 -0 -1295 -665 [ [ 38 67 32 75 24 78 13 78 5 75 0 67 0 60 2 52 5 48 10 45 27 37 32 33 35 30 38 22 38 11 32 3 24 0 13 0 5 3 0 11 ] ] Char -0 -1233 -665 [ [ 0 78 0 0 ] ] Char -0 -1209 -665 [ [ 38 78 0 0 ] [ 0 78 38 78 ] [ 0 0 38 0 ] ] Char -0 -1147 -665 [ [ 0 78 0 0 ] [ 0 78 35 78 ] [ 0 41 21 41 ] [ 0 0 35 0 ] ] Char -10 SetText2 -0 -873 -665 [ [ 16 78 10 75 5 67 2 60 0 48 0 30 2 18 5 11 10 3 16 0 27 0 32 3 38 11 40 18 43 30 43 48 40 60 38 67 32 75 27 78 16 78 ] [ 24 15 40 -7 ] ] Char -0 -805 -665 [ [ 19 78 19 0 ] [ 0 78 38 78 ] ] Char -0 -743 -665 [ [ 0 78 21 41 21 0 ] [ 43 78 21 41 ] ] Char -10 SetText2 -0 -575 -665 [ [ 38 67 32 75 24 78 13 78 5 75 0 67 0 60 2 52 5 48 10 45 27 37 32 33 35 30 38 22 38 11 32 3 24 0 13 0 5 3 0 11 ] ] Char -0 -513 -665 [ [ 0 78 21 41 21 0 ] [ 43 78 21 41 ] ] Char -0 -445 -665 [ [ 0 78 0 0 ] [ 0 78 21 0 ] [ 43 78 21 0 ] [ 43 78 43 0 ] ] Char -10 SetText2 -0 -1233 -905 [ [ 5 78 35 78 19 48 27 48 32 45 35 41 38 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -0 -1171 -905 [ [ 38 78 10 0 ] [ 0 78 38 78 ] ] Char -10 SetText2 -0 -873 -905 [ [ 2 60 2 63 5 71 8 75 13 78 24 78 30 75 32 71 35 63 35 56 32 48 27 37 0 0 38 0 ] ] Char -0 -811 -905 [ [ 16 78 8 75 2 63 0 45 0 33 2 15 8 3 16 0 21 0 30 3 35 15 38 33 38 45 35 63 30 75 21 78 16 78 ] ] Char -0 -749 -905 [ [ 27 78 0 26 40 26 ] [ 27 78 27 0 ] ] Char -10 120 /M4 SetMkr --455 -845 Marker -10 SetText2 -0 -1233 -1145 [ [ 27 78 0 26 40 26 ] [ 27 78 27 0 ] ] Char -0 -1168 -1145 [ [ 0 63 5 67 13 78 13 0 ] ] Char -10 SetText2 -0 -749 -1145 [ [ 32 67 30 75 21 78 16 78 8 75 2 63 0 45 0 26 2 11 8 3 16 0 19 0 27 3 32 11 35 22 35 26 32 37 27 45 19 48 16 48 8 45 2 37 0 26 ] ] Char -10 SetText2 -0 -515 -1145 [ [ 0 78 13 0 ] [ 27 78 13 0 ] [ 27 78 40 0 ] [ 54 78 40 0 ] ] Char -10 SetText2 -0 -1233 -1385 [ [ 5 78 35 78 19 48 27 48 32 45 35 41 38 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -0 -1171 -1385 [ [ 2 60 2 63 5 71 8 75 13 78 24 78 30 75 32 71 35 63 35 56 32 48 27 37 0 0 38 0 ] ] Char -10 SetText2 -0 -749 -1385 [ [ 5 78 35 78 19 48 27 48 32 45 35 41 38 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -10 SetText2 -0 -515 -1385 [ [ 0 78 38 0 ] [ 38 78 0 0 ] ] Char -10 SetText2 -0 -1295 -1625 [ [ 0 63 5 67 13 78 13 0 ] ] Char -0 -1257 -1625 [ [ 2 60 2 63 5 71 8 75 13 78 24 78 30 75 32 71 35 63 35 56 32 48 27 37 0 0 38 0 ] ] Char -0 -1195 -1625 [ [ 16 78 8 75 2 63 0 45 0 33 2 15 8 3 16 0 21 0 30 3 35 15 38 33 38 45 35 63 30 75 21 78 16 78 ] ] Char -10 SetText2 -0 -749 -1625 [ [ 35 78 8 78 5 45 8 48 16 52 24 52 32 48 38 41 40 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -10 SetText2 -0 -515 -1625 [ [ 0 78 21 41 21 0 ] [ 43 78 21 41 ] ] Char -10 SetText2 -0 -1233 -1865 [ [ 5 78 35 78 19 48 27 48 32 45 35 41 38 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -0 -1171 -1865 [ [ 35 78 8 78 5 45 8 48 16 52 24 52 32 48 38 41 40 30 38 22 35 11 30 3 21 0 13 0 5 3 2 7 0 15 ] ] Char -10 SetText2 -0 -749 -1865 [ [ 27 78 0 26 40 26 ] [ 27 78 27 0 ] ] Char -10 SetText2 -0 -515 -1865 [ [ 38 78 0 0 ] [ 0 78 38 78 ] [ 0 0 38 0 ] ] Char -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/gadget.lst b/usr.sbin/xntpd/gadget/gadget.lst deleted file mode 100644 index a10aff3054a8..000000000000 --- a/usr.sbin/xntpd/gadget/gadget.lst +++ /dev/null @@ -1,332 +0,0 @@ - - - ---------------------------------------------------------------------------- - DESIGN RULE CHECK Tue Sep 15 01:23:56 1992 PAGE 1 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - - -FLOATING INPUTS: - NONE FOUND - -NETS WITH NO DRIVING SOURCE: - NONE FOUND - -NETS WITH MULTIPLE DRIVING SOURCES: - NONE FOUND - -NETS WITH MORE THAN ONE LABEL: - NONE FOUND - -NETS WITH A SINGLE PIN: - NONE FOUND - -REFERENCE DESIGNATORS USED TWO OR MORE TIMES: - NONE FOUND - - - ---------------------------------------------------------------------------- - REPORT REF. DES. Tue Sep 15 01:23:56 1992 PAGE 1 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -C1 DCAP A/01 -C10 DCAP A/01 -C11 DCAP A/01 -C12 DCAPE A/01 -C13 DCAP A/01 -C14 DCAP A/01 -C15 DCAP A/01 -C16 DCAPE A/01 -C17 DCAPE A/01 -C18 DCAPE A/01 -C2 DCAP A/01 -C3 DCAPE A/01 -C4 DCAP A/01 -C5 DCAP A/01 -C6 DCAP A/01 -C7 DCAP A/01 -C8 DCAP A/01 -C9 DCAPE A/01 -D1 DDIODE A/01 -D2 DDIODE A/01 -J1 DB25 A/01 -J2 DBNC A/01 -J3 DBNC A/01 -J4 DBNC A/01 -LED1 DLED A/01 -LED2 DLED A/01 -LED3 DLED A/01 -Q1 DPNP A/01 -R1 DRES A/01 -R10 DRES A/01 -R11 DRES A/01 -R12 DRES A/01 -R13 DRES A/01 -R14 DRES A/01 -R2 DRES A/01 -R3 DRES A/01 -R4 DRES A/01 -R5 DRES A/01 -R6 DRES A/01 -R7 DPOT A/01 -R8 DPOT A/01 -R9 DRES A/01 -U1 ICL232 A/01 -U2 MC145443 A/01 -U3A 74LS123 A/01 -U3B 74LS123 B/01 -U4A LM324 A/01 -U4B LM324 B/01 - - - ---------------------------------------------------------------------------- - REPORT REF. DES. Tue Sep 15 01:23:57 1992 PAGE 2 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -U5 LM7805 A/01 -X1 DXTAL A/01 - - - ---------------------------------------------------------------------------- - REPORT LABEL Tue Sep 15 01:23:57 1992 PAGE 1 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -+12 01 -+5 01 -AGND 01 -CGND 01 -GND 01 -VCC 01 - - - ---------------------------------------------------------------------------- - WIRE LIST Tue Sep 15 01:23:57 1992 PAGE 1 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -1 +12 C18-T D1-C D2-C - U5-1 - -2 +5 C1-T C13-T C2-T - C3-B C7-T R11-T - R12-L R2-T R7-1 - R7-2 R9-L U1-16 - U2-13 U2-14 U2-6 - U3A-16 U3B-16 U5-3 - -3 01007018 J2-1 R8-1 - -4 01007039 J3-1 R13-T U3A-2 - -5 01011019 C15-L R8-2 - -6 01013019 C15-R R3-T U4A-3 - -7 01013024 C5-T C6-B C7-B - C8-B R3-B U2-18 - U2-19 - -8 01015020 U4A-1 U4A-2 U4B-5 - -9 01017033 C14-T R7-3 U3A-15 - -10 01019043 R11-B U3A-3 U3B-11 - -11 01020035 C14-B U3A-14 - -12 01022016 C11-L R6-L U4B-6 - -13 01022039 U3A-13 U3B-10 - -14 01022040 U1-11 U3A-4 - -15 01024023 C10-L C11-R R5-T - -16 01027016 C10-R R4-L R6-R - U4B-7 - -17 01029043 C17-T R9-R U3B-7 - -18 01030057 D2-A J4-1 - -19 01031045 C17-B U3B-6 - -20 01033049 R10-L U3B-5 - -21 01036049 LED3-A R10-R - - - - ---------------------------------------------------------------------------- - WIRE LIST Tue Sep 15 01:23:57 1992 PAGE 2 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -22 01037023 U2-9 X1-L - -23 01038014 Q1-E R2-B - -24 01038017 LED1-A Q1-C - -25 01040015 Q1-B R14-L - -26 01041023 U2-8 X1-R - -27 01042022 C8-T U2-7 - -28 01045015 C4-B U2-4 - -29 01045018 R14-R U2-3 - -30 01045020 U1-10 U2-5 - -31 01046010 R1-L R4-R U2-16 - -32 01046025 C6-T U2-10 - -33 01047042 C9-T U1-1 - -34 01047044 C9-B U1-3 - -35 01048033 J1-2 U1-8 - -36 01049034 J1-11 U1-13 - -37 01051047 C3-T U1-2 - -38 01052057 LED2-A R12-R - -39 01054021 R1-R U2-15 - -40 01054025 U1-9 U2-11 - -41 01054047 C16-T U1-6 - -42 01055053 D1-A J1-20 J1-6 - J1-8 - -43 01057040 J1-12 U1-14 - -44 01057041 J1-3 U1-7 - -45 01057042 C12-T U1-4 - -46 01057044 C12-B U1-5 - - - - ---------------------------------------------------------------------------- - WIRE LIST Tue Sep 15 01:23:57 1992 PAGE 3 - 1-PPS/RS232 CONVERTER 100-0001-001 REV 1A 26 JUNE 1992 ---------------------------------------------------------------------------- - - -47 01068042 J1-4 J1-5 - -48 AGND C4-T C5-B LED1-C - R5-B R8-3 U2-2 - U4A-11 U4B-11 - -49 CGND J2-2 J3-2 J4-2 - -50 GND C1-B C13-B C16-B - C18-B C2-B J1-1 - J1-7 LED2-C LED3-C - R13-B U1-15 U2-12 - U3A-1 U3A-8 U3B-8 - U3B-9 U5-2 - -51 VCC U4A-4 U4B-4 - - - - ---------------------------------------------------------------------------------------------------------------- -BILL OF MATERIALS XYZ COMPUTER CORP. LORAN 150-0001-001 REV 1A Tue Sep 15 01:23:57 1992 PAGE 1 ---------------------------------------------------------------------------------------------------------------- - - - ITEM QUAN. PART NUMBER DESCRIPTION REF. DES. - - 1 7 CAPACITOR,100N, C1,C13,C2,C5,C6 - C7,C8 - - 2 1 CAPACITOR,100U C18 - - 3 5 CAPACITOR,10N, C10,C11,C14,C15 - C4 - - 4 5 CAPACITOR,22U C12,C16,C17,C3 - C9 - - 5 1 CRYSTAL, 3.59MHZ X1 - - 6 2 DIODE, 1N4002 D1,D2 - - 7 1 LIGHT EMITTING DIODE, AMBER LED3 - - 8 1 LIGHT EMITTING DIODE, GRN LED1 - - 9 1 LIGHT EMITTING DIODE, RED LED2 - - 10 1 PNP TRANSISTOR, 2N2907 Q1 - - 11 1 POTENTIOMETER, 10K R8 - - 12 1 POTENTIOMETER, 20K R7 - - 13 2 RESISTOR,100K, R13,R3 - - 14 1 RESISTOR,10K, R1 - - 15 1 RESISTOR,1MEG, R4 - - 16 2 RESISTOR,3.3K, R11,R14 - - 17 3 RESISTOR,330, R10,R12,R2 - - 18 1 RESISTOR,33K, R9 - - 19 1 RESISTOR,680, R5 - - 20 1 RESISTOR,68K, R6 - - 21 3 010-0002-001 CONNECTOR, BNC CHASSIS J2,J3,J4 - - 22 1 010-DB25-001 DB25 - 25-PIN CONNECTOR J1 - - 23 2 300-0123-001 74LS123 - LS TTL RETRIG MONOSTABLE MULTIVIBRATORS U3A,U3B - - - ---------------------------------------------------------------------------------------------------------------- -BILL OF MATERIALS XYZ COMPUTER CORP. LORAN 150-0001-001 REV 1A Tue Sep 15 01:23:57 1992 PAGE 2 ---------------------------------------------------------------------------------------------------------------- - - - ITEM QUAN. PART NUMBER DESCRIPTION REF. DES. - - 24 2 302-0324-001 LM324A - LOW POWER QUAD OP-AMP U4A,U4B - - 25 1 302-7805-001 LM7805C - VOLTAGE REGULATOR, +5VDC U5 - - 26 1 306-5443-001 MC145443 - 300-BPS MODEM U2 - - 27 1 310-0232-001 ICL232 - POWERED RS232 TRANSMITTER/RECEIVER U1 - diff --git a/usr.sbin/xntpd/gadget/gadget.s01 b/usr.sbin/xntpd/gadget/gadget.s01 deleted file mode 100644 index 314f7ba18a62..000000000000 --- a/usr.sbin/xntpd/gadget/gadget.s01 +++ /dev/null @@ -1,2277 +0,0 @@ -%!PS-Adobe-23.0 EPSF-1.2 -%%Creator: SCHEMA -%%BoundingBox: 0 0 1343.0 1023.0 -/scl 511804.0 0.072 mul 65536.0 div def -scl scl scale - -% Landscape Orientation -/xoff 256.0 65536.0 mul 511804.0 div def -/yoff 1343.0 -256.0 65536.0 mul 511804.0 div sub def -xoff yoff translate --90 rotate - -0 setgray - -/a { 1 setlinewidth newpath arcn stroke } def -/fa { 3 setlinewidth newpath arcn stroke } def -/c { 1 setlinewidth newpath 0 360 arc stroke } def -/fc { 1 setlinewidth newpath 0 360 arc fill } def -/l { 1 setlinewidth newpath moveto lineto stroke } def -/t { 3 setlinewidth newpath moveto lineto stroke } def -/ds { [4 4] 0 setdash 1 setlinewidth - newpath moveto lineto stroke [] 0 setdash } def -/dt { [2 2] 0 setdash 1 setlinewidth - newpath moveto lineto stroke [] 0 setdash } def - -8 7 8 1015 t -1328 7 912 7 t -1336 1015 8 1015 t -1336 7 1336 1015 t -912 7 8 7 t -1336 7 1328 7 t - -/reencsmalldict 12 dict def %% Schema font definitions -/ReEncodeSmall - { reencsmalldict begin - /newcodesandnames exch def - /newfontname exch def - /basefontname exch def - /basefontdict basefontname findfont def - /newfont basefontdict maxlength dict def - basefontdict - { exch dup /FID ne - { dup /Encoding eq - { exch dup length array copy newfont 3 1 roll put } - { exch newfont 3 1 roll put } - ifelse - } - { pop pop } - ifelse - } forall - newfont /FontName newfontname put - newcodesandnames aload pop - newcodesandnames length 2 idiv - { newfont /Encoding get 3 1 roll put } - repeat - newfontname newfont definefont pop - end - } def -/schfontvec [ 8#200 /Ccedilla 8#201 /udieresis 8#202 /eacute 8#203 /acircumflex -8#204 /adieresis 8#205 /agrave 8#207 /ccedilla 8#210 /ecircumflex -8#211 /edieresis 8#212 /egrave 8#213 /idieresis 8#214 /icircumflex -8#215 /igrave 8#216 /Adieresis 8#220 /Eacute 8#223 /ocircumflex -8#224 /odieresis 8#225 /ograve 8#226 /ucircumflex 8#227 /ugrave -8#230 /ydieresis 8#231 /Odieresis 8#232 /Udieresis 8#240 /aacute 8#241 /iacute -8#242 /oacute 8#243 /uacute 8#244 /ntilde 8#245 /Ntilde ] def -/schsymbvec [ 8#341 /beta 8#346 /mu 8#352 /Omega ] def -/Courier-Bold /Schfont schfontvec ReEncodeSmall -/Symbol /Schsymb schsymbvec ReEncodeSmall - - -/htdict 4 dict def %% HTEXT - variable spacing horizontal text routine -/ht - { htdict begin - /textstring exch def - /xskip exch def - 0 text_height neg rmoveto - /Schfont findfont text_height scalefont setfont - textstring - { - /charcode exch def - /thechar ( ) dup 0 charcode put def - gsave - charcode 8#245 gt - { /Schsymb findfont text_height scalefont setfont - thechar show - /Schfont findfont text_height scalefont setfont } - { thechar show } - ifelse - grestore - currentpoint moveto - xskip 0 rmoveto - } forall - end - } def - -/text_height 12 def -/text_width 6 def -1304 27 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -1272 27 moveto 9 (OF) ht -/text_height 12 def -/text_width 6 def -1248 27 moveto 9 (1) ht -/text_height 12 def -/text_width 6 def -1192 27 moveto 9 (SHEET) ht -1176 31 1176 7 l -1336 55 992 55 l -1336 31 992 31 l -992 7 992 87 t -1336 87 992 87 t -/text_height 20 def -/text_width 9 def -1032 87 moveto 13 (1-PPS/RS232 Converter) ht -/text_height 12 def -/text_width 6 def -1040 27 moveto 9 (26 June 1992) ht -1176 55 1176 31 l -/text_height 12 def -/text_width 6 def -1032 51 moveto 9 (100-0001-001) ht -/text_height 12 def -/text_width 6 def -1216 51 moveto 9 (REV) ht -/text_height 12 def -/text_width 6 def -1264 51 moveto 9 (1A) ht -584 54 568 54 l -576 54 576 63 l -581 51 571 51 l -578 48 574 48 l -/b { newpath 0.5 0 360 arc fill } def -576 45 b -760 54 744 54 l -752 54 752 63 l -757 51 747 51 l -754 48 750 48 l -752 45 b -752 103 752 95 l -752 103 2 fc -288 487 288 455 l -320 487 288 487 l -288 487 2 fc -248 383 248 367 l -456 103 8 c -456 71 456 95 l -/text_height 12 def -/text_width 6 def -441 129 moveto 9 (J4) ht -456 105 b -457 105 b -455 104 b -456 104 b -457 104 b -458 104 b -455 103 b -456 103 b -457 103 b -458 103 b -456 102 b -457 102 b -480 103 456 103 l -583 81 569 81 l -576 59 18 111 69 a -576 81 576 95 l -576 63 576 77 l -/text_height 12 def -/text_width 6 def -589 81 moveto 9 (100U) ht -/text_height 12 def -/text_width 6 def -590 94 moveto 9 (C18) ht -/text_height 12 def -/text_width 6 def -561 96 moveto 9 (+) ht -/text_height 12 def -/text_width 6 def -765 94 moveto 9 (C1) ht -/text_height 12 def -/text_width 6 def -765 81 moveto 9 (100N) ht -759 81 745 81 l -752 59 18 111 69 a -752 81 752 95 l -752 63 752 77 l -509 109 b -509 108 b -510 108 b -515 108 b -509 107 b -510 107 b -511 107 b -515 107 b -509 106 b -510 106 b -511 106 b -512 106 b -515 106 b -509 105 b -510 105 b -511 105 b -512 105 b -513 105 b -515 105 b -509 104 b -510 104 b -511 104 b -512 104 b -513 104 b -514 104 b -515 104 b -509 103 b -510 103 b -511 103 b -512 103 b -513 103 b -514 103 b -515 103 b -509 102 b -510 102 b -511 102 b -512 102 b -513 102 b -514 102 b -515 102 b -509 101 b -510 101 b -511 101 b -512 101 b -513 101 b -515 101 b -509 100 b -510 100 b -511 100 b -512 100 b -515 100 b -509 99 b -510 99 b -511 99 b -515 99 b -509 98 b -510 98 b -515 98 b -509 97 b -516 103 b -510 103 496 103 l -528 103 517 103 l -/text_height 12 def -/text_width 6 def -496 99 moveto 9 (1N4002) ht -/text_height 12 def -/text_width 6 def -497 124 moveto 9 (D2) ht -576 103 576 95 l -560 103 528 103 l -560 103 2 fc -592 103 576 103 l -576 103 560 103 l -576 103 2 fc -496 103 480 103 l -240 695 240 671 l -328 671 240 671 l -328 703 328 671 l -240 711 208 711 l -208 711 208 687 l -384 703 328 703 l -136 735 112 735 l -392 767 352 767 l -384 687 352 687 l -408 647 408 631 l -208 676 208 687 l -/text_height 12 def -/text_width 6 def -218 677 moveto 9 (R3) ht -/text_height 12 def -/text_width 6 def -218 664 moveto 9 (100K) ht -213 673 208 675 l -213 657 204 653 l -213 657 204 661 l -213 665 204 669 l -213 665 204 661 l -208 649 208 651 l -208 652 204 653 l -208 639 208 650 l -213 673 204 669 l -208 675 208 677 l -208 650 208 652 l -208 711 2 fc -328 703 2 fc -352 687 352 647 l -352 767 352 687 l -352 687 2 fc -432 647 408 647 l -408 647 384 647 l -408 647 2 fc -904 751 872 751 l -904 735 872 735 l -968 687 872 687 l -968 703 968 687 l -/text_height 12 def -/text_width 6 def -616 695 moveto 9 (X1) ht -/text_height 12 def -/text_width 6 def -616 683 moveto 9 (3.59MHZ) ht -628 645 628 665 l -637 645 637 665 l -634 667 631 667 l -634 643 634 667 l -634 643 631 643 l -631 643 631 667 l -628 655 600 655 l -664 655 637 655 l -920 607 904 607 l -920 655 920 647 l -744 575 744 559 l -752 623 744 623 l -744 623 744 607 l -752 671 696 671 l -752 655 664 655 l -600 655 600 639 l -752 639 600 639 l -680 575 680 559 l -680 671 680 607 l -752 703 728 703 l -712 815 712 751 l -752 751 712 751 l -728 783 728 719 l -752 719 728 719 l -696 671 680 671 l -888 863 736 863 l -688 863 480 863 l -/text_height 12 def -/text_width 6 def -590 855 moveto 9 (+5) ht -744 559 2 fc -904 607 2 fc -920 655 872 655 l -920 655 2 fc -920 703 888 703 l -888 703 872 703 l -888 703 2 fc -728 815 712 815 l -712 815 696 815 l -712 815 2 fc -888 863 888 703 l -904 607 904 559 l -904 735 904 607 l -904 751 904 735 l -904 735 2 fc -248 399 128 399 l -128 399 2 fc -136 342 120 342 l -128 342 128 351 l -133 339 123 339 l -130 336 126 336 l -128 333 b -256 358 240 358 l -248 358 248 367 l -253 355 243 355 l -250 352 246 352 l -248 349 b -560 175 560 103 l -464 327 464 295 l -496 327 464 327 l -880 94 864 94 l -872 94 872 103 l -877 91 867 91 l -874 88 870 88 l -872 85 b -872 103 864 103 l -424 223 424 207 l -416 327 400 327 l -400 327 400 303 l -400 255 400 167 l -480 167 400 167 l -432 198 416 198 l -424 198 424 207 l -429 195 419 195 l -426 192 422 192 l -424 189 b -464 327 2 fc -480 767 440 767 l -480 767 480 695 l -480 863 480 767 l -480 767 2 fc -480 695 480 647 l -480 647 464 647 l -480 695 2 fc -88 735 8 c -88 703 88 727 l -/text_height 12 def -/text_width 6 def -73 761 moveto 9 (J2) ht -88 737 b -89 737 b -87 736 b -88 736 b -89 736 b -90 736 b -87 735 b -88 735 b -89 735 b -90 735 b -88 734 b -89 734 b -112 735 88 735 l -/text_height 12 def -/text_width 6 def -333 486 moveto 9 (C14) ht -/text_height 12 def -/text_width 6 def -333 473 moveto 9 (10N) ht -327 473 313 473 l -320 451 18 111 69 a -320 473 320 487 l -320 455 320 469 l -698 863 688 863 l -736 863 726 863 l -/text_height 12 def -/text_width 6 def -691 883 moveto 9 (1MEG) ht -/text_height 12 def -/text_width 6 def -691 895 moveto 9 (R4) ht -702 868 700 863 l -706 859 702 868 l -710 868 706 859 l -714 859 710 868 l -718 868 714 859 l -722 859 718 868 l -724 863 722 859 l -726 863 724 863 l -700 863 699 863 l -930 703 920 703 l -968 703 958 703 l -/text_height 12 def -/text_width 6 def -923 723 moveto 9 (10K) ht -/text_height 12 def -/text_width 6 def -923 735 moveto 9 (R1) ht -934 708 932 703 l -938 699 934 708 l -942 708 938 699 l -946 699 942 708 l -950 708 946 699 l -954 699 950 708 l -956 703 954 699 l -958 703 956 703 l -932 703 931 703 l -784 103 768 103 l -768 103 752 103 l -288 487 272 487 l -480 695 472 695 l -920 607 920 599 l -920 615 920 607 l -920 607 2 fc -792 399 776 399 l -792 383 360 383 l -728 703 728 367 l -792 367 728 367 l -400 292 400 303 l -/text_height 12 def -/text_width 6 def -410 293 moveto 9 (R11) ht -/text_height 12 def -/text_width 6 def -410 280 moveto 9 (3.3K) ht -405 289 400 291 l -405 273 396 269 l -405 273 396 277 l -405 281 396 285 l -405 281 396 277 l -400 265 400 267 l -400 268 396 269 l -400 255 400 266 l -405 289 396 285 l -400 291 400 293 l -400 266 400 268 l -128 388 128 399 l -/text_height 12 def -/text_width 6 def -138 389 moveto 9 (R13) ht -/text_height 12 def -/text_width 6 def -138 376 moveto 9 (100K) ht -133 385 128 387 l -133 369 124 365 l -133 369 124 373 l -133 377 124 381 l -133 377 124 373 l -128 361 128 363 l -128 364 124 365 l -128 351 128 362 l -133 385 124 381 l -128 387 128 389 l -128 362 128 364 l -88 399 8 c -88 367 88 391 l -/text_height 12 def -/text_width 6 def -73 425 moveto 9 (J3) ht -88 401 b -89 401 b -87 400 b -88 400 b -89 400 b -90 400 b -87 399 b -88 399 b -89 399 b -90 399 b -88 398 b -89 398 b -112 399 88 399 l -128 399 112 399 l -376 399 360 399 l -376 399 376 239 l -424 239 376 239 l -608 836 608 847 l -/text_height 12 def -/text_width 6 def -618 837 moveto 9 (R2) ht -/text_height 12 def -/text_width 6 def -618 824 moveto 9 (330) ht -613 833 608 835 l -613 817 604 813 l -613 817 604 821 l -613 825 604 829 l -613 825 604 821 l -608 809 608 811 l -608 812 604 813 l -608 799 608 810 l -613 833 604 829 l -608 835 608 837 l -608 810 608 812 l -224 487 208 487 l -400 327 360 327 l -224 487 2 fc -400 327 2 fc -/text_height 12 def -/text_width 6 def -190 495 moveto 9 (+5) ht -/text_height 12 def -/text_width 6 def -342 335 moveto 9 (+5) ht -944 655 920 655 l -680 559 208 559 l -744 559 680 559 l -208 639 208 559 l -680 559 2 fc -/text_height 12 def -/text_width 6 def -947 663 moveto 9 (+5) ht -768 127 768 103 l -768 103 2 fc - -/vtdict 4 dict def %% VTEXT - variable spacing verticle text routine -/vt - { vtdict begin - /thestring exch def - /yskip exch def - 0 text_height neg rmoveto - /Schfont findfont text_height scalefont setfont - thestring - { - /charcode exch def - /thechar ( ) dup 0 charcode put def - gsave - charcode 8#245 gt - { /Schsymb findfont text_height scalefont setfont - thechar show - /Schfont findfont text_height scalefont setfont } - { thechar show } - ifelse - grestore - currentpoint moveto - 0 yskip neg rmoveto - } forall - end - } def - -/text_height 12 def -/text_width 6 def -765 153 moveto 11 (+5) vt -234 487 224 487 l -272 487 262 487 l -238 492 b -238 491 b -237 490 b -239 490 b -237 489 b -239 489 b -236 488 b -240 488 b -235 487 b -236 487 b -240 487 b -241 486 b -241 485 b -246 492 b -246 491 b -245 490 b -247 490 b -245 489 b -247 489 b -244 488 b -248 488 b -244 487 b -248 487 b -243 486 b -243 485 b -242 484 b -242 483 b -254 492 b -254 491 b -253 490 b -255 490 b -253 489 b -255 489 b -252 488 b -252 487 b -249 486 b -251 486 b -249 485 b -251 485 b -250 484 b -250 483 b -256 488 b -256 487 b -260 487 b -261 487 b -257 486 b -259 486 b -257 485 b -259 485 b -258 484 b -258 483 b -248 463 248 479 l -248 481 b -247 480 b -248 480 b -249 480 b -246 479 b -247 479 b -248 479 b -249 479 b -250 479 b -245 478 b -246 478 b -247 478 b -248 478 b -249 478 b -250 478 b -244 477 b -245 477 b -246 477 b -247 477 b -248 477 b -249 477 b -250 477 b -251 478 b -251 477 b -252 477 b -/text_height 12 def -/text_width 6 def -233 508 moveto 9 (R7) ht -/text_height 12 def -/text_width 6 def -225 488 moveto 9 (1) ht -/text_height 12 def -/text_width 6 def -238 478 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -263 488 moveto 9 (3) ht -/text_height 12 def -/text_width 6 def -257 475 moveto 9 (20K) ht -752 103 736 103 l -672 54 656 54 l -664 54 664 63 l -669 51 659 51 l -666 48 662 48 l -664 45 b -/text_height 12 def -/text_width 6 def -272 811 moveto 9 (2000+-500 Hz) ht -/text_height 12 def -/text_width 6 def -256 827 moveto 9 (bandpass filter) ht -/text_height 12 def -/text_width 6 def -272 515 moveto 9 (\(for 38.4 baud\)) ht -/text_height 12 def -/text_width 6 def -280 531 moveto 9 (26-us one-shot) ht -/text_height 12 def -/text_width 6 def -448 363 moveto 9 (200-ms one shot) ht -224 487 224 463 l -248 463 224 463 l -304 327 304 167 l -400 167 304 167 l -400 167 2 fc -/text_height 12 def -/text_width 6 def -384 99 moveto 9 (\(6-12V\)) ht -/text_height 12 def -/text_width 6 def -32 731 moveto 9 (\(BNC\)) ht -/text_height 12 def -/text_width 6 def -32 747 moveto 9 (audio) ht -/text_height 12 def -/text_width 6 def -40 411 moveto 9 (1pps) ht -/text_height 12 def -/text_width 6 def -32 395 moveto 9 (\(BNC\)) ht -/text_height 12 def -/text_width 6 def -400 115 moveto 9 (power) ht -767 337 753 337 l -760 315 18 111 69 a -760 337 760 351 l -760 319 760 333 l -/text_height 12 def -/text_width 6 def -773 337 moveto 9 (22U) ht -/text_height 12 def -/text_width 6 def -774 350 moveto 9 (C9) ht -/text_height 12 def -/text_width 6 def -745 352 moveto 9 (+) ht -935 337 921 337 l -928 315 18 111 69 a -928 337 928 351 l -928 319 928 333 l -/text_height 12 def -/text_width 6 def -941 337 moveto 9 (22U) ht -/text_height 12 def -/text_width 6 def -942 350 moveto 9 (C12) ht -/text_height 12 def -/text_width 6 def -913 352 moveto 9 (+) ht -880 257 880 271 l -880 239 880 253 l -/text_height 12 def -/text_width 6 def -893 257 moveto 9 (22U) ht -/text_height 12 def -/text_width 6 def -894 270 moveto 9 (C16) ht -873 259 b -874 259 b -875 258 b -876 258 b -877 258 b -878 257 b -879 257 b -873 254 b -874 254 b -875 254 b -876 254 b -877 254 b -878 254 b -879 254 b -886 259 b -883 258 b -884 258 b -885 258 b -880 257 b -881 257 b -882 257 b -880 254 b -881 254 b -882 254 b -883 254 b -884 254 b -885 254 b -886 254 b -887 259 b -887 254 b -/text_height 12 def -/text_width 6 def -865 255 moveto 9 (+) ht -831 257 817 257 l -824 235 18 111 69 a -824 257 824 271 l -824 239 824 253 l -/text_height 12 def -/text_width 6 def -837 257 moveto 9 (22U) ht -/text_height 12 def -/text_width 6 def -838 270 moveto 9 (C3) ht -/text_height 12 def -/text_width 6 def -809 272 moveto 9 (+) ht -888 230 872 230 l -880 230 880 239 l -885 227 875 227 l -882 224 878 224 l -880 221 b -792 351 760 351 l -792 319 760 319 l -928 351 912 351 l -928 319 912 319 l -832 271 824 271 l -880 271 872 271 l -/text_height 12 def -/text_width 6 def -821 240 moveto 11 (+5) vt -/text_height 12 def -/text_width 6 def -624 307 moveto 9 (EIA level converter) ht -936 399 912 399 l -872 671 872 655 l -872 655 2 fc -/text_height 12 def -/text_width 6 def -752 835 moveto 9 (300-baud modem) ht -88 359 88 367 l -81 357 b -80 356 b -79 355 b -78 354 b -77 353 b -76 352 b -75 351 b -82 358 b -88 357 b -87 356 b -86 355 b -85 354 b -84 353 b -83 352 b -82 351 b -89 358 b -95 357 b -94 356 b -93 355 b -92 354 b -91 353 b -90 352 b -89 351 b -96 358 b -96 358 82 358 l -88 695 88 703 l -81 693 b -80 692 b -79 691 b -78 690 b -77 689 b -76 688 b -75 687 b -82 694 b -88 693 b -87 692 b -86 691 b -85 690 b -84 689 b -83 688 b -82 687 b -89 694 b -95 693 b -94 692 b -93 691 b -92 690 b -91 689 b -90 688 b -89 687 b -96 694 b -96 694 82 694 l -456 63 456 71 l -449 61 b -448 60 b -447 59 b -446 58 b -445 57 b -444 56 b -443 55 b -450 62 b -456 61 b -455 60 b -454 59 b -453 58 b -452 57 b -451 56 b -450 55 b -457 62 b -463 61 b -462 60 b -461 59 b -460 58 b -459 57 b -458 56 b -457 55 b -464 62 b -464 62 450 62 l -696 807 696 815 l -688 806 b -689 806 b -690 806 b -691 806 b -692 806 b -693 806 b -694 806 b -689 805 b -690 804 b -691 803 b -692 802 b -693 801 b -694 800 b -696 807 b -695 806 b -696 806 b -697 806 b -698 806 b -699 806 b -700 806 b -701 806 b -701 803 b -700 802 b -699 801 b -698 800 b -695 799 b -697 799 b -696 798 b -702 806 b -703 806 b -704 806 b -703 805 b -702 804 b -920 559 920 567 l -912 558 b -913 558 b -914 558 b -915 558 b -916 558 b -917 558 b -918 558 b -913 557 b -914 556 b -915 555 b -916 554 b -917 553 b -918 552 b -920 559 b -919 558 b -920 558 b -921 558 b -922 558 b -923 558 b -924 558 b -925 558 b -925 555 b -924 554 b -923 553 b -922 552 b -919 551 b -921 551 b -920 550 b -926 558 b -927 558 b -928 558 b -927 557 b -926 556 b -136 679 136 687 l -128 678 b -129 678 b -130 678 b -131 678 b -132 678 b -133 678 b -134 678 b -129 677 b -130 676 b -131 675 b -132 674 b -133 673 b -134 672 b -136 679 b -135 678 b -136 678 b -137 678 b -138 678 b -139 678 b -140 678 b -141 678 b -141 675 b -140 674 b -139 673 b -138 672 b -135 671 b -137 671 b -136 670 b -142 678 b -143 678 b -144 678 b -143 677 b -142 676 b -408 575 408 583 l -400 574 b -401 574 b -402 574 b -403 574 b -404 574 b -405 574 b -406 574 b -401 573 b -402 572 b -403 571 b -404 570 b -405 569 b -406 568 b -408 575 b -407 574 b -408 574 b -409 574 b -410 574 b -411 574 b -412 574 b -413 574 b -413 571 b -412 570 b -411 569 b -410 568 b -407 567 b -409 567 b -408 566 b -414 574 b -415 574 b -416 574 b -415 573 b -414 572 b -794 103 784 103 l -832 103 822 103 l -/text_height 12 def -/text_width 6 def -787 123 moveto 9 (330) ht -/text_height 12 def -/text_width 6 def -787 135 moveto 9 (R12) ht -798 108 796 103 l -802 99 798 108 l -806 108 802 99 l -810 99 806 108 l -814 108 810 99 l -818 99 814 108 l -820 103 818 99 l -822 103 820 103 l -796 103 795 103 l -/text_height 12 def -/text_width 6 def -528 118 moveto 9 (+12) ht -712 119 616 119 l -712 87 712 119 l -616 87 616 119 l -712 87 616 87 l -616 103 592 103 l -664 63 664 87 l -/text_height 12 def -/text_width 6 def -652 101 moveto 9 (GND) ht -/text_height 12 def -/text_width 6 def -619 111 moveto 9 (IN) ht -/text_height 12 def -/text_width 6 def -685 111 moveto 9 (OUT) ht -/text_height 12 def -/text_width 6 def -602 118 moveto 9 (1) ht -/text_height 12 def -/text_width 6 def -640 136 moveto 9 (LM7805) ht -/text_height 12 def -/text_width 6 def -640 149 moveto 9 (U5) ht -/text_height 12 def -/text_width 6 def -667 83 moveto 9 (2) ht -736 103 712 103 l -/text_height 12 def -/text_width 6 def -720 118 moveto 9 (3) ht -862 180 b -867 180 b -862 179 b -866 179 b -867 179 b -862 178 b -865 178 b -866 178 b -867 178 b -862 177 b -864 177 b -865 177 b -866 177 b -867 177 b -862 176 b -863 176 b -864 176 b -865 176 b -866 176 b -867 176 b -861 175 b -862 175 b -863 175 b -864 175 b -865 175 b -866 175 b -867 175 b -862 174 b -863 174 b -864 174 b -865 174 b -866 174 b -867 174 b -862 173 b -864 173 b -865 173 b -866 173 b -867 173 b -862 172 b -865 172 b -866 172 b -867 172 b -862 171 b -866 171 b -867 171 b -862 170 b -867 170 b -868 181 b -868 180 b -868 179 b -868 178 b -868 177 b -868 176 b -868 175 b -868 174 b -868 173 b -868 172 b -868 171 b -868 170 b -868 169 b -862 175 848 175 l -880 175 867 175 l -/text_height 12 def -/text_width 6 def -850 196 moveto 9 (D1) ht -/text_height 12 def -/text_width 6 def -849 171 moveto 9 (1N4002) ht -848 175 560 175 l -810 383 792 383 l -813 383 3 c -810 367 792 367 l -813 367 3 c -816 415 792 415 l -816 399 792 399 l -891 399 3 c -912 399 894 399 l -912 383 888 383 l -912 367 888 367 l -891 415 3 c -912 415 894 415 l -/text_height 12 def -/text_width 6 def -903 430 moveto 16 (2 4) vt -/text_height 12 def -/text_width 6 def -796 430 moveto 16 (1 11) vt -/text_height 12 def -/text_width 6 def -870 424 moveto 16 (12122 2) vt -912 351 888 351 l -912 319 888 319 l -816 351 792 351 l -816 319 792 319 l -/text_height 12 def -/text_width 6 def -804 430 moveto 16 (38101 3) vt -888 431 816 431 l -/text_height 12 def -/text_width 6 def -879 424 moveto 16 (OOOO+ -) vt -/text_height 12 def -/text_width 6 def -895 430 moveto 16 (19174 5) vt -/text_height 12 def -/text_width 6 def -836 288 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -875 288 moveto 9 (6) ht -888 295 816 295 l -832 271 832 295 l -872 271 872 295 l -816 295 816 431 l -888 295 888 431 l -/text_height 12 def -/text_width 6 def -820 447 moveto 9 (ICL232) ht -/text_height 12 def -/text_width 6 def -831 460 moveto 9 (U1) ht -/text_height 12 def -/text_width 6 def -820 424 moveto 16 (RRTTC C) vt -/text_height 12 def -/text_width 6 def -829 424 moveto 16 (12121 1) vt -/text_height 12 def -/text_width 6 def -837 424 moveto 16 (IIII+ -) vt -/text_height 12 def -/text_width 6 def -861 424 moveto 16 (RRTTC C) vt -/text_height 12 def -/text_width 6 def -827 313 moveto 9 (V+) ht -/text_height 12 def -/text_width 6 def -865 313 moveto 9 (V-) ht -992 471 792 471 l -776 487 776 399 l -792 471 792 415 l -936 503 936 399 l -776 655 752 655 l -776 703 752 703 l -776 671 752 671 l -848 607 776 607 l -872 735 848 735 l -872 719 848 719 l -/text_height 12 def -/text_width 6 def -780 776 moveto 16 (DLCCR CXXF) vt -776 623 752 623 l -776 639 752 639 l -776 767 752 767 l -/text_height 12 def -/text_width 6 def -764 782 moveto 16 (12345 7890) vt -776 719 752 719 l -770 751 752 751 l -773 751 3 c -/text_height 12 def -/text_width 6 def -756 782 moveto 16 ( 1) vt -770 735 752 735 l -773 735 3 c -872 751 848 751 l -872 703 848 703 l -872 687 848 687 l -872 671 848 671 l -872 655 848 655 l -872 623 848 623 l -/text_height 12 def -/text_width 6 def -852 782 moveto 16 (21111111 1) vt -/text_height 12 def -/text_width 6 def -860 782 moveto 16 (09876543 1) vt -872 767 848 767 l -/text_height 12 def -/text_width 6 def -821 776 moveto 16 (TUETRRSO T) vt -/text_height 12 def -/text_width 6 def -797 776 moveto 16 (I TD A) vt -/text_height 12 def -/text_width 6 def -788 776 moveto 16 (SBDDX DIOB) vt -/text_height 12 def -/text_width 6 def -812 664 moveto 9 (M) ht -848 783 776 783 l -776 607 776 783 l -848 607 848 783 l -/text_height 12 def -/text_width 6 def -779 799 moveto 9 (MC145443) ht -/text_height 12 def -/text_width 6 def -790 812 moveto 9 (U2) ht -/text_height 12 def -/text_width 6 def -839 776 moveto 16 (AGLA12TE D) vt -/text_height 12 def -/text_width 6 def -830 776 moveto 16 (LAXXXXQD X) vt -904 559 744 559 l -880 623 872 623 l -880 623 880 503 l -936 503 880 503 l -1040 726 1024 726 l -1032 726 1032 735 l -1037 723 1027 723 l -1034 720 1030 720 l -1032 717 b -1096 726 1080 726 l -1088 726 1088 735 l -1093 723 1083 723 l -1090 720 1086 720 l -1088 717 b -1088 767 1032 767 l -1088 799 1088 767 l -/text_height 12 def -/text_width 6 def -1085 825 moveto 11 (+5) vt -1088 767 2 fc -/text_height 12 def -/text_width 6 def -1024 715 moveto 9 (U2) ht -/text_height 12 def -/text_width 6 def -1080 715 moveto 9 (U4) ht -1096 351 1096 335 l -1096 319 1032 319 l -1096 287 1032 287 l -1032 319 1032 287 l -1032 287 2 fc -1032 287 1032 175 l -/text_height 12 def -/text_width 6 def -1072 363 moveto 9 (RS) ht -/text_height 12 def -/text_width 6 def -1072 347 moveto 9 (CS) ht -/text_height 12 def -/text_width 6 def -1040 451 moveto 9 (\(DB25 female DCE\)) ht -1096 303 1064 303 l -1008 487 776 487 l -1072 270 1056 270 l -1064 270 1064 279 l -1069 267 1059 267 l -1066 264 1062 264 l -1064 261 b -1064 303 1064 279 l -1064 303 2 fc -1184 175 1032 175 l -1032 175 880 175 l -1032 175 2 fc -1096 399 1064 399 l -1064 399 1064 303 l -/text_height 12 def -/text_width 6 def -1112 467 moveto 9 (modem) ht -/text_height 12 def -/text_width 6 def -1074 415 moveto 9 (FG) ht -/text_height 12 def -/text_width 6 def -1074 398 moveto 9 (TD) ht -/text_height 12 def -/text_width 6 def -1074 383 moveto 9 (RD) ht -/text_height 12 def -/text_width 6 def -1073 334 moveto 9 (MR) ht -/text_height 12 def -/text_width 6 def -1073 318 moveto 9 (CG) ht -/text_height 12 def -/text_width 6 def -1073 302 moveto 9 (CD) ht -/text_height 12 def -/text_width 6 def -1069 254 moveto 9 (STD) ht -1114 367 1096 367 l -1117 367 3 c -1114 351 1096 351 l -1117 351 3 c -1114 335 1096 335 l -1117 335 3 c -1114 319 1096 319 l -1117 319 3 c -1114 303 1096 303 l -1117 303 3 c -1114 287 1096 287 l -1117 287 3 c -1114 239 1096 239 l -1117 239 3 c -1114 223 1096 223 l -1117 223 3 c -1114 271 1096 271 l -1117 271 3 c -1131 375 3 c -1152 375 1134 375 l -1131 359 3 c -1152 359 1134 359 l -1131 343 3 c -1152 343 1134 343 l -1131 327 3 c -1152 327 1134 327 l -1131 311 3 c -1152 311 1134 311 l -1131 295 3 c -1152 295 1134 295 l -1131 263 3 c -1152 263 1134 263 l -1131 247 3 c -1152 247 1134 247 l -1131 231 3 c -1152 231 1134 231 l -1131 215 3 c -1152 215 1134 215 l -/text_height 12 def -/text_width 6 def -1097 270 moveto 16 (1111) vt -/text_height 12 def -/text_width 6 def -1136 405 moveto 16 (111111222222) vt -/text_height 12 def -/text_width 6 def -1144 405 moveto 16 (456789012345) vt -/text_height 12 def -/text_width 6 def -1105 414 moveto 16 (1234567890123) vt -1131 391 3 c -1152 391 1134 391 l -1114 255 1096 255 l -1117 255 3 c -1114 207 1096 207 l -1117 207 3 c -1114 383 1096 383 l -1117 383 3 c -1114 399 1096 399 l -1117 399 3 c -1131 279 3 c -1152 279 1134 279 l -/text_height 12 def -/text_width 6 def -1118 420 moveto 9 (DB25) ht -/text_height 12 def -/text_width 6 def -1118 432 moveto 9 (J1) ht -/text_height 12 def -/text_width 6 def -1069 238 moveto 9 (SRD) ht -1184 295 1152 295 l -/text_height 12 def -/text_width 6 def -1160 315 moveto 9 (TR) ht -1184 295 1184 175 l -190 704 190 718 l -213 711 18 201 159 a -190 711 176 711 l -208 711 195 711 l -/text_height 12 def -/text_width 6 def -179 734 moveto 9 (C15) ht -/text_height 12 def -/text_width 6 def -173 704 moveto 9 (10N) ht -366 640 366 654 l -389 647 18 201 159 a -366 647 352 647 l -384 647 371 647 l -/text_height 12 def -/text_width 6 def -355 670 moveto 9 (C11) ht -/text_height 12 def -/text_width 6 def -349 640 moveto 9 (10N) ht -446 640 446 654 l -469 647 18 201 159 a -446 647 432 647 l -464 647 451 647 l -/text_height 12 def -/text_width 6 def -435 670 moveto 9 (C10) ht -/text_height 12 def -/text_width 6 def -429 640 moveto 9 (10N) ht -/text_height 12 def -/text_width 6 def -693 606 moveto 9 (C8) ht -/text_height 12 def -/text_width 6 def -693 593 moveto 9 (100N) ht -687 593 673 593 l -680 571 18 111 69 a -680 593 680 607 l -680 575 680 589 l -/text_height 12 def -/text_width 6 def -933 598 moveto 9 (C5) ht -/text_height 12 def -/text_width 6 def -933 585 moveto 9 (100N) ht -927 585 913 585 l -920 563 18 111 69 a -920 585 920 599 l -920 567 920 581 l -/text_height 12 def -/text_width 6 def -933 646 moveto 9 (C7) ht -/text_height 12 def -/text_width 6 def -933 633 moveto 9 (100N) ht -927 633 913 633 l -920 611 18 111 69 a -920 633 920 647 l -920 615 920 629 l -/text_height 12 def -/text_width 6 def -741 814 moveto 9 (C4) ht -/text_height 12 def -/text_width 6 def -741 801 moveto 9 (10N) ht -735 801 721 801 l -728 779 18 111 69 a -728 801 728 815 l -728 783 728 797 l -/text_height 12 def -/text_width 6 def -757 606 moveto 9 (C6) ht -/text_height 12 def -/text_width 6 def -757 593 moveto 9 (100N) ht -751 593 737 593 l -744 571 18 111 69 a -744 593 744 607 l -744 575 744 589 l -/text_height 12 def -/text_width 6 def -1045 766 moveto 9 (C13) ht -/text_height 12 def -/text_width 6 def -1045 753 moveto 9 (100N) ht -1039 753 1025 753 l -1032 731 18 111 69 a -1032 753 1032 767 l -1032 735 1032 749 l -/text_height 12 def -/text_width 6 def -1101 766 moveto 9 (C2) ht -/text_height 12 def -/text_width 6 def -1101 753 moveto 9 (100N) ht -1095 753 1081 753 l -1088 731 18 111 69 a -1088 753 1088 767 l -1088 735 1088 749 l -546 239 536 239 l -584 239 574 239 l -/text_height 12 def -/text_width 6 def -539 259 moveto 9 (330) ht -/text_height 12 def -/text_width 6 def -539 271 moveto 9 (R10) ht -550 244 548 239 l -554 235 550 244 l -558 244 554 235 l -562 235 558 244 l -566 244 562 235 l -570 235 566 244 l -572 239 570 235 l -574 239 572 239 l -548 239 547 239 l -845 109 b -845 108 b -846 108 b -851 108 b -845 107 b -846 107 b -847 107 b -851 107 b -845 106 b -846 106 b -847 106 b -848 106 b -851 106 b -845 105 b -846 105 b -847 105 b -848 105 b -849 105 b -851 105 b -845 104 b -846 104 b -847 104 b -848 104 b -849 104 b -850 104 b -851 104 b -845 103 b -846 103 b -847 103 b -848 103 b -849 103 b -850 103 b -851 103 b -845 102 b -846 102 b -847 102 b -848 102 b -849 102 b -850 102 b -851 102 b -845 101 b -846 101 b -847 101 b -848 101 b -849 101 b -851 101 b -845 100 b -846 100 b -847 100 b -848 100 b -851 100 b -845 99 b -846 99 b -847 99 b -851 99 b -845 98 b -846 98 b -851 98 b -845 97 b -852 103 b -846 103 832 103 l -864 103 853 103 l -/text_height 12 def -/text_width 6 def -832 131 moveto 9 (LED2) ht -859 116 b -857 115 b -858 115 b -857 114 b -858 114 b -856 113 b -855 112 b -855 111 b -856 111 b -857 111 b -858 111 b -859 111 b -860 111 b -860 110 b -859 109 b -858 108 b -857 107 b -/text_height 12 def -/text_width 6 def -833 97 moveto 9 (RED) ht -/text_height 12 def -/text_width 6 def -584 219 moveto 9 (1 pps) ht -/text_height 12 def -/text_width 6 def -832 83 moveto 9 (power) ht -328 703 304 703 l -264 679 264 727 l -264 711 240 711 l -264 695 240 695 l -/text_height 12 def -/text_width 6 def -267 719 moveto 9 (+) ht -/text_height 12 def -/text_width 6 def -267 703 moveto 9 (-) ht -/text_height 12 def -/text_width 6 def -250 726 moveto 9 (3) ht -/text_height 12 def -/text_width 6 def -250 710 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -312 718 moveto 9 (1) ht -/text_height 12 def -/text_width 6 def -264 744 moveto 9 (LM324) ht -/text_height 12 def -/text_width 6 def -264 757 moveto 9 (U4A) ht -304 703 264 727 l -304 703 264 679 l -472 695 448 695 l -408 671 408 719 l -/text_height 12 def -/text_width 6 def -411 711 moveto 9 (+) ht -/text_height 12 def -/text_width 6 def -411 695 moveto 9 (-) ht -/text_height 12 def -/text_width 6 def -408 736 moveto 9 (LM324) ht -/text_height 12 def -/text_width 6 def -408 749 moveto 9 (U4B) ht -408 703 384 703 l -408 687 384 687 l -/text_height 12 def -/text_width 6 def -394 718 moveto 9 (5) ht -/text_height 12 def -/text_width 6 def -394 702 moveto 9 (6) ht -/text_height 12 def -/text_width 6 def -456 710 moveto 9 (7) ht -448 695 408 719 l -448 695 408 671 l -336 431 272 431 l -272 351 272 431 l -336 351 272 351 l -336 351 336 431 l -272 399 248 399 l -266 383 248 383 l -269 383 3 c -360 399 336 399 l -288 431 288 455 l -320 431 320 455 l -304 345 304 327 l -304 348 3 c -/text_height 12 def -/text_width 6 def -275 407 moveto 16 (BA) vt -/text_height 12 def -/text_width 6 def -277 433 moveto 9 (R/C) ht -/text_height 12 def -/text_width 6 def -313 433 moveto 9 (CE) ht -/text_height 12 def -/text_width 6 def -297 366 moveto 9 (CL) ht -/text_height 12 def -/text_width 6 def -258 414 moveto 16 (21) vt -/text_height 12 def -/text_width 6 def -344 414 moveto 9 (13) ht -/text_height 12 def -/text_width 6 def -344 398 moveto 9 (4) ht -/text_height 12 def -/text_width 6 def -307 347 moveto 9 (3) ht -/text_height 12 def -/text_width 6 def -344 448 moveto 9 (74LS123) ht -/text_height 12 def -/text_width 6 def -344 461 moveto 9 (U3A) ht -/text_height 12 def -/text_width 6 def -292 457 moveto 11 (15) vt -/text_height 12 def -/text_width 6 def -324 457 moveto 11 (14) vt -/text_height 12 def -/text_width 6 def -327 407 moveto 16 (QQ) vt -/text_height 12 def -/text_width 6 def -326 403 moveto 9 (_) ht -339 383 3 c -360 383 342 383 l -512 271 448 271 l -448 191 448 271 l -512 191 448 191 l -512 191 512 271 l -464 271 464 295 l -496 271 496 295 l -/text_height 12 def -/text_width 6 def -451 247 moveto 16 (BA) vt -/text_height 12 def -/text_width 6 def -453 273 moveto 9 (R/C) ht -/text_height 12 def -/text_width 6 def -489 273 moveto 9 (CE) ht -/text_height 12 def -/text_width 6 def -473 206 moveto 9 (CL) ht -480 185 480 167 l -480 188 3 c -536 239 512 239 l -448 239 424 239 l -442 223 424 223 l -445 223 3 c -/text_height 12 def -/text_width 6 def -425 254 moveto 9 (10) ht -/text_height 12 def -/text_width 6 def -434 238 moveto 9 (9) ht -/text_height 12 def -/text_width 6 def -520 238 moveto 9 (12) ht -/text_height 12 def -/text_width 6 def -520 254 moveto 9 (5) ht -/text_height 12 def -/text_width 6 def -483 198 moveto 11 ( 11) vt -/text_height 12 def -/text_width 6 def -467 291 moveto 9 (7) ht -/text_height 12 def -/text_width 6 def -499 291 moveto 9 (6) ht -/text_height 12 def -/text_width 6 def -520 288 moveto 9 (74LS123) ht -/text_height 12 def -/text_width 6 def -520 301 moveto 9 (U3B) ht -/text_height 12 def -/text_width 6 def -503 247 moveto 16 (QQ) vt -/text_height 12 def -/text_width 6 def -502 243 moveto 9 (_) ht -515 223 3 c -536 223 518 223 l -136 724 b -136 723 b -137 723 b -138 722 b -138 720 b -136 719 b -137 719 b -134 718 b -135 718 b -132 717 b -133 717 b -134 716 b -135 716 b -136 715 b -137 715 b -138 714 b -138 712 b -136 711 b -137 711 b -134 710 b -135 710 b -132 709 b -133 709 b -134 708 b -135 708 b -136 707 b -137 707 b -138 706 b -138 704 b -136 703 b -137 703 b -134 702 b -135 702 b -132 701 b -133 701 b -134 700 b -135 700 b -136 699 b -139 722 b -140 721 b -141 721 b -139 720 b -139 714 b -140 713 b -141 713 b -139 712 b -139 706 b -140 705 b -141 705 b -139 704 b -136 724 136 735 l -136 687 136 698 l -176 711 152 711 l -147 715 b -146 714 b -147 714 b -145 713 b -146 713 b -147 713 b -144 712 b -145 712 b -146 712 b -147 712 b -143 711 b -144 711 b -145 711 b -146 711 b -147 711 b -148 711 b -149 711 b -144 710 b -145 710 b -146 710 b -147 710 b -145 709 b -146 709 b -147 709 b -146 708 b -147 708 b -147 707 b -150 711 b -151 711 b -152 711 b -153 711 b -/text_height 12 def -/text_width 6 def -148 708 moveto 9 (10K) ht -/text_height 12 def -/text_width 6 def -128 736 moveto 9 (1) ht -/text_height 12 def -/text_width 6 def -126 702 moveto 9 (3) ht -/text_height 12 def -/text_width 6 def -150 726 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -144 738 moveto 9 (R8) ht -608 751 608 762 l -640 775 616 775 l -616 767 616 783 l -608 788 608 799 l -614 768 b -613 767 b -612 766 b -611 765 b -610 764 b -609 763 b -608 762 b -616 770 b -615 769 b -608 788 b -609 787 b -610 786 b -613 786 b -611 785 b -612 785 b -613 785 b -611 784 b -612 784 b -613 784 b -610 783 b -611 783 b -612 783 b -613 783 b -614 783 b -613 782 b -614 782 b -615 781 b -616 780 b -613 775 16 c -/text_height 12 def -/text_width 6 def -632 795 moveto 9 (2N2907) ht -/text_height 12 def -/text_width 6 def -632 808 moveto 9 (Q1) ht -608 711 608 719 l -600 710 b -601 710 b -602 710 b -603 710 b -604 710 b -605 710 b -606 710 b -601 709 b -602 708 b -603 707 b -604 706 b -605 705 b -606 704 b -608 711 b -607 710 b -608 710 b -609 710 b -610 710 b -611 710 b -612 710 b -613 710 b -613 707 b -612 706 b -611 705 b -610 704 b -607 703 b -609 703 b -608 702 b -614 710 b -615 710 b -616 710 b -615 709 b -614 708 b -/text_height 12 def -/text_width 6 def -624 723 moveto 9 (car det) ht -664 775 664 735 l -664 775 640 775 l -1096 367 912 367 l -1008 487 1008 383 l -1096 383 1008 383 l -992 471 992 239 l -1096 239 992 239 l -976 383 912 383 l -976 383 976 223 l -1096 223 976 223 l -602 738 b -603 738 b -604 738 b -605 738 b -606 738 b -607 738 b -608 738 b -603 737 b -604 737 b -605 737 b -606 737 b -607 737 b -608 737 b -604 736 b -605 736 b -606 736 b -607 736 b -608 736 b -605 735 b -606 735 b -607 735 b -608 735 b -606 734 b -607 734 b -608 734 b -607 733 b -608 733 b -603 732 b -604 732 b -605 732 b -606 732 b -607 732 b -608 732 b -608 731 b -609 738 b -610 738 b -611 738 b -612 738 b -613 738 b -614 738 b -609 737 b -610 737 b -611 737 b -612 737 b -613 737 b -609 736 b -610 736 b -611 736 b -612 736 b -609 735 b -610 735 b -611 735 b -609 734 b -610 734 b -609 733 b -609 732 b -610 732 b -611 732 b -612 732 b -613 732 b -608 738 608 751 l -608 719 608 731 l -593 738 b -592 737 b -591 736 b -591 735 b -592 735 b -593 735 b -594 735 b -595 735 b -595 734 b -593 733 b -594 733 b -593 732 b -594 732 b -592 731 b -/text_height 12 def -/text_width 6 def -619 737 moveto 9 (GRN) ht -/text_height 12 def -/text_width 6 def -619 750 moveto 9 (LED1) ht -682 735 672 735 l -720 735 710 735 l -/text_height 12 def -/text_width 6 def -675 755 moveto 9 (3.3K) ht -/text_height 12 def -/text_width 6 def -675 767 moveto 9 (R14) ht -686 740 684 735 l -690 731 686 740 l -694 740 690 731 l -698 731 694 740 l -702 740 698 731 l -706 731 702 740 l -708 735 706 731 l -710 735 708 735 l -684 735 683 735 l -672 735 664 735 l -752 735 720 735 l -597 245 b -597 244 b -598 244 b -603 244 b -597 243 b -598 243 b -599 243 b -603 243 b -597 242 b -598 242 b -599 242 b -600 242 b -603 242 b -597 241 b -598 241 b -599 241 b -600 241 b -601 241 b -603 241 b -597 240 b -598 240 b -599 240 b -600 240 b -601 240 b -602 240 b -603 240 b -597 239 b -598 239 b -599 239 b -600 239 b -601 239 b -602 239 b -603 239 b -597 238 b -598 238 b -599 238 b -600 238 b -601 238 b -602 238 b -603 238 b -597 237 b -598 237 b -599 237 b -600 237 b -601 237 b -603 237 b -597 236 b -598 236 b -599 236 b -600 236 b -603 236 b -597 235 b -598 235 b -599 235 b -603 235 b -597 234 b -598 234 b -603 234 b -597 233 b -604 239 b -598 239 584 239 l -616 239 605 239 l -/text_height 12 def -/text_width 6 def -584 267 moveto 9 (LED3) ht -611 252 b -609 251 b -610 251 b -609 250 b -610 250 b -608 249 b -607 248 b -607 247 b -608 247 b -609 247 b -610 247 b -611 247 b -612 247 b -612 246 b -611 245 b -610 244 b -609 243 b -/text_height 12 def -/text_width 6 def -585 233 moveto 9 (AMBER) ht -648 230 632 230 l -640 230 640 239 l -645 227 635 227 l -642 224 638 224 l -640 221 b -640 239 616 239 l -402 767 392 767 l -440 767 430 767 l -/text_height 12 def -/text_width 6 def -395 787 moveto 9 (68K) ht -/text_height 12 def -/text_width 6 def -395 799 moveto 9 (R6) ht -406 772 404 767 l -410 763 406 772 l -414 772 410 763 l -418 763 414 772 l -422 772 418 763 l -426 763 422 772 l -428 767 426 763 l -430 767 428 767 l -404 767 403 767 l -408 620 408 631 l -/text_height 12 def -/text_width 6 def -418 621 moveto 9 (R5) ht -/text_height 12 def -/text_width 6 def -418 608 moveto 9 (680) ht -413 617 408 619 l -413 601 404 597 l -413 601 404 605 l -413 609 404 613 l -413 609 404 605 l -408 593 408 595 l -408 596 404 597 l -408 583 408 594 l -413 617 404 613 l -408 619 408 621 l -408 594 408 596 l -426 327 416 327 l -464 327 454 327 l -/text_height 12 def -/text_width 6 def -419 347 moveto 9 (33K) ht -/text_height 12 def -/text_width 6 def -419 359 moveto 9 (R9) ht -430 332 428 327 l -434 323 430 332 l -438 332 434 323 l -442 323 438 332 l -446 332 442 323 l -450 323 446 332 l -452 327 450 323 l -454 327 452 327 l -428 327 427 327 l -503 313 489 313 l -496 291 18 111 69 a -496 313 496 327 l -496 295 496 309 l -/text_height 12 def -/text_width 6 def -509 313 moveto 9 (22U) ht -/text_height 12 def -/text_width 6 def -510 326 moveto 9 (C17) ht -/text_height 12 def -/text_width 6 def -481 328 moveto 9 (+) ht - -showpage diff --git a/usr.sbin/xntpd/gadget/gadget.s02 b/usr.sbin/xntpd/gadget/gadget.s02 deleted file mode 100644 index 6af4a6ec77e6..000000000000 --- a/usr.sbin/xntpd/gadget/gadget.s02 +++ /dev/null @@ -1,288 +0,0 @@ -%!PS-Adobe-23.0 EPSF-1.2 -%%Creator: SCHEMA -%%BoundingBox: 0 0 1343.0 1023.0 -/scl 511804.0 0.072 mul 65536.0 div def -scl scl scale - -% Landscape Orientation -/xoff 256.0 65536.0 mul 511804.0 div def -/yoff 1343.0 -256.0 65536.0 mul 511804.0 div sub def -xoff yoff translate --90 rotate - -0 setgray - -/a { 1 setlinewidth newpath arcn stroke } def -/fa { 3 setlinewidth newpath arcn stroke } def -/c { 1 setlinewidth newpath 0 360 arc stroke } def -/fc { 1 setlinewidth newpath 0 360 arc fill } def -/l { 1 setlinewidth newpath moveto lineto stroke } def -/t { 3 setlinewidth newpath moveto lineto stroke } def -/ds { [4 4] 0 setdash 1 setlinewidth - newpath moveto lineto stroke [] 0 setdash } def -/dt { [2 2] 0 setdash 1 setlinewidth - newpath moveto lineto stroke [] 0 setdash } def - -8 7 8 1015 t -1328 7 912 7 t -1336 1015 8 1015 t -1336 7 1336 1015 t -912 7 8 7 t -1336 7 1328 7 t - -/reencsmalldict 12 dict def %% Schema font definitions -/ReEncodeSmall - { reencsmalldict begin - /newcodesandnames exch def - /newfontname exch def - /basefontname exch def - /basefontdict basefontname findfont def - /newfont basefontdict maxlength dict def - basefontdict - { exch dup /FID ne - { dup /Encoding eq - { exch dup length array copy newfont 3 1 roll put } - { exch newfont 3 1 roll put } - ifelse - } - { pop pop } - ifelse - } forall - newfont /FontName newfontname put - newcodesandnames aload pop - newcodesandnames length 2 idiv - { newfont /Encoding get 3 1 roll put } - repeat - newfontname newfont definefont pop - end - } def -/schfontvec [ 8#200 /Ccedilla 8#201 /udieresis 8#202 /eacute 8#203 /acircumflex -8#204 /adieresis 8#205 /agrave 8#207 /ccedilla 8#210 /ecircumflex -8#211 /edieresis 8#212 /egrave 8#213 /idieresis 8#214 /icircumflex -8#215 /igrave 8#216 /Adieresis 8#220 /Eacute 8#223 /ocircumflex -8#224 /odieresis 8#225 /ograve 8#226 /ucircumflex 8#227 /ugrave -8#230 /ydieresis 8#231 /Odieresis 8#232 /Udieresis 8#240 /aacute 8#241 /iacute -8#242 /oacute 8#243 /uacute 8#244 /ntilde 8#245 /Ntilde ] def -/schsymbvec [ 8#341 /beta 8#346 /mu 8#352 /Omega ] def -/Courier-Bold /Schfont schfontvec ReEncodeSmall -/Symbol /Schsymb schsymbvec ReEncodeSmall - - -/htdict 4 dict def %% HTEXT - variable spacing horizontal text routine -/ht - { htdict begin - /textstring exch def - /xskip exch def - 0 text_height neg rmoveto - /Schfont findfont text_height scalefont setfont - textstring - { - /charcode exch def - /thechar ( ) dup 0 charcode put def - gsave - charcode 8#245 gt - { /Schsymb findfont text_height scalefont setfont - thechar show - /Schfont findfont text_height scalefont setfont } - { thechar show } - ifelse - grestore - currentpoint moveto - xskip 0 rmoveto - } forall - end - } def - -/text_height 12 def -/text_width 6 def -1304 27 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -1272 27 moveto 9 (OF) ht -/text_height 12 def -/text_width 6 def -1192 27 moveto 9 (SHEET) ht -1176 31 1176 7 l -1336 55 992 55 l -1336 31 992 31 l -992 7 992 87 t -1336 87 992 87 t -/text_height 20 def -/text_width 9 def -1032 87 moveto 13 (1-PPS/RS232 Converter) ht -/text_height 12 def -/text_width 6 def -1040 27 moveto 9 (26 June 1992) ht -1176 55 1176 31 l -/text_height 12 def -/text_width 6 def -1032 51 moveto 9 (100-0001-001) ht -/text_height 12 def -/text_width 6 def -1216 51 moveto 9 (REV) ht -/text_height 12 def -/text_width 6 def -1264 51 moveto 9 (1A) ht -640 303 240 303 l -240 463 240 303 l -640 463 240 463 l -640 463 640 303 l -240 783 240 543 l -640 543 240 543 l -640 783 640 543 l -640 783 240 783 l -1040 463 800 463 l -800 463 800 303 l -1040 463 1040 303 l -1040 303 800 303 l -632 327 248 327 l -632 335 632 327 l -248 335 248 327 l -632 335 248 335 l -656 367 640 367 l -656 367 656 351 l -656 351 640 351 l -640 367 624 367 l -624 367 624 351 l -640 351 624 351 l -248 335 240 335 l -224 367 224 335 l -240 335 224 335 l -624 359 616 359 l -616 359 616 335 l -288 367 288 335 l -288 367 224 367 l -624 327 624 303 l -592 327 592 303 l -844 419 20 c -996 419 20 c -1032 335 808 335 ds -1032 327 1032 335 ds -808 327 808 335 ds -1032 327 808 327 ds -816 303 816 327 ds -848 303 848 327 ds -1024 303 1024 327 ds -992 303 992 327 ds -632 775 248 775 l -632 775 632 551 l -632 551 248 551 l -248 775 248 551 l -288 751 248 751 l -288 575 248 575 l -288 751 288 575 l -600 751 16 c -/text_height 20 def -/text_width 9 def -344 223 moveto 13 (Assembly Drawing) ht -/text_height 12 def -/text_width 6 def -896 283 moveto 9 (End View) ht -/text_height 12 def -/text_width 6 def -280 163 moveto 9 (Material: 2" x 3" x 5" aluminum minibox) ht -600 575 16 c -842 357 10 c -1002 357 10 c -920 418 20 c -921 358 10 c -/text_height 12 def -/text_width 6 def -976 395 moveto 9 (POWER) ht -/text_height 12 def -/text_width 6 def -824 395 moveto 9 (AUDIO) ht -/text_height 12 def -/text_width 6 def -912 395 moveto 9 (PPS) ht -384 735 224 735 ds -384 591 224 591 ds -600 751 520 751 ds -600 575 520 575 ds -272 399 200 399 l -272 439 200 439 l -272 439 272 399 l -200 439 200 399 l -280 423 272 423 l -272 759 200 759 l -288 599 224 599 l -272 607 272 567 l -288 727 224 727 l -272 719 200 719 l -272 759 272 719 l -200 759 200 719 l -656 575 624 575 l -656 591 656 575 l -656 591 624 591 l -624 591 624 575 l -656 751 624 751 l -656 751 656 735 l -656 735 624 735 l -624 751 624 735 l -656 655 624 655 l -656 671 656 655 l -624 671 624 655 l -656 671 624 671 l -280 423 280 415 l -280 415 272 415 l -280 591 272 591 l -280 591 280 583 l -280 583 272 583 l -272 663 272 655 l -272 743 272 735 l -280 735 272 735 l -280 743 280 735 l -280 743 272 743 l -273 683 201 683 l -201 682 201 642 l -272 683 272 643 l -273 643 201 643 l -281 667 273 667 l -280 658 272 658 l -280 666 280 658 l -232 607 232 567 l -272 607 232 607 l -272 567 232 567 l -232 439 232 399 l -/text_height 12 def -/text_width 6 def -672 587 moveto 9 (LED1 \(green\)) ht -/text_height 12 def -/text_width 6 def -136 355 moveto 9 (J1 \(DB25\)) ht -/text_height 12 def -/text_width 6 def -120 747 moveto 9 (J2 \(BNC\)) ht -/text_height 12 def -/text_width 6 def -120 675 moveto 9 (J3 \(BNC\)) ht -/text_height 12 def -/text_width 6 def -128 611 moveto 9 (J4 \(power\)) ht -224 727 224 599 l -/text_height 12 def -/text_width 6 def -352 283 moveto 9 (Side View \(cover removed\)) ht -/text_height 12 def -/text_width 6 def -344 523 moveto 9 (Top View \(cover removed\)) ht -384 591 384 735 ds -528 575 528 751 ds -608 599 608 727 ds -/text_height 12 def -/text_width 6 def -416 619 moveto 9 (#4 x 1/4" spacers \(2\)) ht -/text_height 12 def -/text_width 6 def -400 699 moveto 9 (#4 screws \(4\)) ht -/text_height 12 def -/text_width 6 def -1248 27 moveto 9 (2) ht -/text_height 12 def -/text_width 6 def -672 667 moveto 9 (LED2 \(red\)) ht -/text_height 12 def -/text_width 6 def -672 747 moveto 9 (LED3 \(amber\)) ht - -showpage diff --git a/usr.sbin/xntpd/gadget/gen0102.lpr b/usr.sbin/xntpd/gadget/gen0102.lpr deleted file mode 100644 index cc4fd8e5a38d..000000000000 --- a/usr.sbin/xntpd/gadget/gen0102.lpr +++ /dev/null @@ -1,1973 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:34:44 1992) show -gsave -Init -8000 10500 Clipto -4015 2626 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -12 SetLine --100 900 [ -100 800 ] PLine --100 800 [ 100 800 ] PLine -100 900 [ 100 800 ] PLine -100 800 [ 900 800 ] PLine -300 1100 [ 600 1100 ] PLine --1100 1150 [ -700 1150 ] PLine --700 1150 [ -700 1600 ] PLine -175 3300 [ -100 3300 ] PLine -700 3000 [ 300 3000 ] PLine -300 3000 [ 300 3100 ] PLine -300 2500 [ 300 2650 ] PLine -300 2650 [ 800 2650 ] PLine -800 2800 [ 800 2650 ] PLine -800 2650 [ 1000 2650 ] PLine -400 2500 [ 400 2600 ] PLine -400 2600 [ 1100 2600 ] PLine -1100 2600 [ 1100 2800 ] PLine --900 2300 [ -700 2100 ] PLine --700 2100 [ -450 2100 ] PLine -500 2500 [ 550 2550 ] PLine -550 2550 [ 750 2550 ] PLine -750 2550 [ 800 2500 ] PLine --650 2600 [ -100 2600 ] PLine --100 2250 [ 450 2250 ] PLine -450 2250 [ 500 2200 ] PLine --1200 2300 [ -1050 2300 ] PLine --1050 2300 [ -1050 2100 ] PLine --1050 2100 [ -800 2100 ] PLine --900 2500 [ -700 2300 ] PLine --700 2300 [ -700 2200 ] PLine --700 2200 [ -300 2200 ] PLine --300 2200 [ -300 2100 ] PLine -1250 1900 [ 1250 1800 ] PLine -1250 1800 [ 800 1800 ] PLine -300 1900 [ 300 1800 ] PLine -300 1800 [ 800 1800 ] PLine -700 1900 [ 450 1900 ] PLine -300 1700 [ 600 1700 ] PLine -500 1600 [ -100 1600 ] PLine --100 1600 [ -100 1700 ] PLine -1000 3900 [ 1050 3950 ] PLine -1050 3950 [ 1050 4050 ] PLine -1050 4050 [ 50 4050 ] PLine -50 4050 [ 0 4000 ] PLine -0 4100 [ 900 4100 ] PLine -800 3000 [ 1100 3000 ] PLine -0 3700 [ 0 3850 ] PLine -0 3850 [ 450 3850 ] PLine -450 3850 [ 500 3900 ] PLine --400 3400 [ -400 3600 ] PLine --400 3600 [ 300 3600 ] PLine -300 3600 [ 300 3700 ] PLine -300 3700 [ 600 3700 ] PLine -450 2700 [ -400 2700 ] PLine --400 2300 [ -300 2300 ] PLine --700 4200 [ -650 4250 ] PLine --650 4250 [ 550 4250 ] PLine -550 4250 [ 600 4200 ] PLine -350 3800 [ 1100 3800 ] PLine -1100 3800 [ 1100 3900 ] PLine --800 3100 [ -800 2800 ] PLine --800 2800 [ -400 2800 ] PLine --850 3700 [ -400 3700 ] PLine -400 1300 [ 600 1300 ] PLine --1100 4200 [ -1050 4150 ] PLine --1050 4150 [ 650 4150 ] PLine -650 4150 [ 700 4200 ] PLine --300 3400 [ -250 3350 ] PLine --250 3350 [ 1200 3350 ] PLine -1200 3350 [ 1200 4200 ] PLine -1200 4200 [ 1100 4200 ] PLine --700 3100 [ -700 2875 ] PLine --700 2875 [ -200 2875 ] PLine --200 2875 [ -200 2800 ] PLine --600 3100 [ -600 2950 ] PLine --600 2950 [ 600 2950 ] PLine -600 2950 [ 600 2800 ] PLine --750 550 [ -750 1050 ] PLine --750 1050 [ -1050 1050 ] PLine -950 3200 [ 700 3200 ] PLine -850 1200 [ -600 1200 ] PLine --550 3900 [ -350 3900 ] PLine -540 4479 [ 540 4300 ] PLine -540 4300 [ -800 4300 ] PLine -432 4479 [ 432 4350 ] PLine -432 4350 [ -750 4350 ] PLine -400 3400 [ 700 3400 ] PLine -50 SetLine --1000 3400 [ -1000 3250 ] PLine --1000 3250 [ -200 3250 ] PLine --200 3250 [ -200 3100 ] PLine --200 3100 [ -100 3100 ] PLine -0 2500 [ 0 2350 ] PLine -0 2350 [ 200 2350 ] PLine -200 2350 [ 200 2500 ] PLine -0 2350 [ -200 2350 ] PLine --1000 3400 [ -1200 3400 ] PLine -200 2350 [ 1100 2350 ] PLine -1100 2350 [ 1100 2450 ] PLine -1100 2450 [ 1200 2450 ] PLine --600 1600 [ -600 1750 ] PLine --600 1750 [ -200 1750 ] PLine --1200 3700 [ -1000 3700 ] PLine --1000 3700 [ -1000 3400 ] PLine -1100 3200 [ 1250 3200 ] PLine -1250 3200 [ 1250 2450 ] PLine -1250 2450 [ 1200 2450 ] PLine -900 4200 [ 900 4300 ] PLine -900 4300 [ 1250 4300 ] PLine -1250 4300 [ 1250 3200 ] PLine --700 4000 [ -1000 4000 ] PLine --1000 4000 [ -1000 3700 ] PLine -900 4200 [ 800 4200 ] PLine -200 1400 [ 1100 1400 ] PLine -1100 1400 [ 1100 800 ] PLine --50 450 [ -50 150 ] PLine -950 150 [ 1100 450 ] PLine -1100 450 [ 1000 800 ] PLine --250 450 [ -250 1000 ] PLine --250 1000 [ 200 1000 ] PLine -200 1000 [ 200 1100 ] PLine -0 450 [ -750 450 ] PLine --750 450 [ -1100 450 ] PLine -0 4475 [ 0 4400 ] PLine -0 4400 [ -648 4400 ] PLine --648 4400 [ -648 4479 ] PLine -75 4000 [ 300 4000 ] PLine -300 4000 [ 300 3900 ] PLine -1100 450 [ 750 450 ] PLine -750 450 [ 0 450 ] PLine -900 2200 [ 900 2000 ] PLine -900 2000 [ 75 2000 ] PLine -75 2000 [ 75 2200 ] PLine -75 2200 [ 200 2200 ] PLine -300 4000 [ 1000 4000 ] PLine --1100 450 [ -1050 150 ] PLine --600 1900 [ -600 2000 ] PLine --600 2000 [ 75 2000 ] PLine -75 2100 [ 0 2100 ] PLine -12 SetLine -700 3700 [ 750 3650 ] PLine -750 3650 [ 750 800 ] PLine -750 800 [ 900 800 ] PLine -0 550 [ 300 550 ] PLine -300 550 [ 300 1100 ] PLine -300 2200 [ 250 2150 ] PLine -250 2150 [ 250 1600 ] PLine -250 1600 [ 300 1550 ] PLine -300 1550 [ 300 1100 ] PLine --700 2500 [ -550 2500 ] PLine --550 2500 [ -550 1700 ] PLine --550 1700 [ -700 1700 ] PLine --700 1700 [ -700 1600 ] PLine -300 3500 [ 175 3500 ] PLine -175 3500 [ 175 3100 ] PLine -175 3100 [ 300 3100 ] PLine -300 4200 [ 250 4150 ] PLine -250 4150 [ 250 3800 ] PLine -250 3800 [ 300 3750 ] PLine -300 3750 [ 300 3500 ] PLine --300 2500 [ -250 2550 ] PLine --250 2550 [ -250 3300 ] PLine --250 3300 [ -100 3300 ] PLine -300 4200 [ 400 4200 ] PLine --900 1600 [ -800 1600 ] PLine --800 1600 [ -800 1500 ] PLine --800 1500 [ -500 1500 ] PLine --500 1500 [ -500 1600 ] PLine -1000 2650 [ 1000 2250 ] PLine -1000 2250 [ 1200 2250 ] PLine -400 1500 [ 400 2200 ] PLine -400 2200 [ 400 2300 ] PLine -400 2300 [ 700 2300 ] PLine -700 2300 [ 700 2500 ] PLine --450 2100 [ -450 1650 ] PLine --450 1650 [ -400 1600 ] PLine --500 3400 [ -500 3150 ] PLine --500 3150 [ -650 3150 ] PLine --650 3150 [ -650 2600 ] PLine --100 2600 [ -100 2250 ] PLine --1200 2500 [ -1200 2300 ] PLine --300 2100 [ -250 2050 ] PLine --250 2050 [ -250 1650 ] PLine --250 1650 [ -300 1600 ] PLine -800 1800 [ 800 2200 ] PLine -600 900 [ 600 550 ] PLine -600 550 [ 750 550 ] PLine -700 2200 [ 700 1900 ] PLine -600 1700 [ 600 2200 ] PLine -1050 150 [ 1050 250 ] PLine -1050 250 [ 500 250 ] PLine -500 250 [ 500 1600 ] PLine -0 4200 [ 0 4100 ] PLine -900 4100 [ 900 3900 ] PLine -800 3900 [ 800 3000 ] PLine -600 3700 [ 600 3900 ] PLine -600 4200 [ 600 4075 ] PLine -600 4075 [ 450 4075 ] PLine -450 4075 [ 450 2700 ] PLine --400 2700 [ -400 2300 ] PLine -300 3300 [ 350 3350 ] PLine -350 3350 [ 350 3800 ] PLine --1200 2800 [ -1000 2800 ] PLine --1000 2800 [ -1000 3100 ] PLine --900 3100 [ -850 3150 ] PLine --850 3150 [ -850 3700 ] PLine -50 150 [ 400 150 ] PLine -400 150 [ 400 1300 ] PLine --500 3100 [ -500 3000 ] PLine --500 3000 [ -350 3000 ] PLine --350 3000 [ -350 1300 ] PLine --350 1300 [ -100 1300 ] PLine -200 3700 [ 150 3750 ] PLine -150 3750 [ 150 4425 ] PLine -150 4425 [ 108 4479 ] PLine -108 4479 [ 54 4593 ] PLine --108 4479 [ 50 4600 ] PLine -50 4600 [ 54 4593 ] PLine --324 4479 [ -216 4479 ] PLine --1100 1700 [ -1100 1450 ] PLine --1050 1050 [ -1050 1800 ] PLine --1050 1800 [ -1200 1800 ] PLine -950 3524 [ 950 3200 ] PLine -950 3700 [ 850 3700 ] PLine -850 3700 [ 850 1200 ] PLine --600 1200 [ -600 150 ] PLine --600 150 [ -950 150 ] PLine --540 4479 [ -550 4479 ] PLine --550 4479 [ -550 3900 ] PLine --350 3900 [ -350 3150 ] PLine --350 3150 [ -300 3100 ] PLine --432 4479 [ -450 4479 ] PLine --450 4479 [ -450 3150 ] PLine --450 3150 [ -382 3100 ] PLine --382 3100 [ -400 3100 ] PLine --800 4300 [ -800 3400 ] PLine --750 4350 [ -750 3450 ] PLine --750 3450 [ -700 3400 ] PLine -400 3900 [ 400 3400 ] PLine -1100 3400 [ 1100 3600 ] PLine -1100 3600 [ 1026 3600 ] PLine -1026 3600 [ 1026 3612 ] PLine -50 SetLine --100 3100 [ 0 3100 ] PLine -0 3100 [ 0 2500 ] PLine --200 2350 [ -200 1900 ] PLine --200 1900 [ -100 1900 ] PLine --200 1900 [ -200 1500 ] PLine --200 1500 [ 0 1500 ] PLine -0 1500 [ 200 1500 ] PLine -200 1500 [ 200 1300 ] PLine -800 4200 [ 800 4050 ] PLine -800 4050 [ 700 4050 ] PLine -700 4050 [ 700 3900 ] PLine --750 450 [ -900 450 ] PLine --900 450 [ -900 1300 ] PLine --1200 1600 [ -1275 1600 ] PLine --1275 1600 [ -1275 900 ] PLine --900 900 [ -1275 900 ] PLine --600 1900 [ -600 1750 ] PLine --600 1750 [ -975 1750 ] PLine --975 1750 [ -975 1300 ] PLine --975 1300 [ -900 1300 ] PLine --1200 2100 [ -1275 2100 ] PLine --1275 2100 [ -1275 1600 ] PLine --1200 3000 [ -1275 3000 ] PLine --1275 3000 [ -1275 2100 ] PLine --900 3400 [ -900 3525 ] PLine --900 3525 [ -1275 3525 ] PLine --1100 4000 [ -1275 4000 ] PLine --1275 4000 [ -1275 3000 ] PLine -75 3500 [ 75 2100 ] PLine -75 2100 [ 0 2100 ] PLine -75 2200 [ 200 2200 ] PLine -0 4479 [ 0 4400 ] PLine -0 4400 [ 75 4400 ] PLine -75 4400 [ 75 3500 ] PLine --300 3700 [ -300 3500 ] PLine --300 3500 [ 75 3500 ] PLine -900 2500 [ 900 2200 ] PLine -1000 4000 [ 1000 4200 ] PLine -25 sg -0 sg -10 SetLine --1350 0 [ -1350 4900 ] PLine --1350 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 0 ] PLine -1350 0 [ -1350 0 ] PLine -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -10 SetLine --1050 1400 [ -1050 1200 ] PLine --1050 1200 [ -1150 1200 ] PLine --1150 1200 [ -1150 1400 ] PLine --1150 1400 [ -1050 1400 ] PLine -10 SetLine --50 3300 [ -100 3300 ] PLine -10 SetLine -250 3235 [ -50 3235 ] PLine --50 3235 [ -50 3365 ] PLine --50 3365 [ 250 3365 ] PLine -250 3365 [ 250 3235 ] PLine -10 SetLine -300 3300 [ 250 3300 ] PLine -10 SetLine -250 3100 [ 300 3100 ] PLine -10 SetLine --50 3165 [ 250 3165 ] PLine -250 3165 [ 250 3035 ] PLine -250 3035 [ -50 3035 ] PLine --50 3035 [ -50 3165 ] PLine -10 SetLine --100 3100 [ -50 3100 ] PLine -10 SetLine --50 3500 [ -100 3500 ] PLine -10 SetLine -250 3435 [ -50 3435 ] PLine --50 3435 [ -50 3565 ] PLine --50 3565 [ 250 3565 ] PLine -250 3565 [ 250 3435 ] PLine -10 SetLine -300 3500 [ 250 3500 ] PLine -10 SetLine --1150 3700 [ -1200 3700 ] PLine -10 SetLine --450 3575 [ -1150 3575 ] PLine --1150 3575 [ -1150 3825 ] PLine --1150 3825 [ -450 3825 ] PLine --450 3825 [ -450 3575 ] PLine -10 SetLine --400 3700 [ -450 3700 ] PLine -10 SetLine --850 1300 [ -900 1300 ] PLine -10 SetLine --150 1175 [ -850 1175 ] PLine --850 1175 [ -850 1425 ] PLine --850 1425 [ -150 1425 ] PLine --150 1425 [ -150 1175 ] PLine -10 SetLine --100 1300 [ -150 1300 ] PLine -10 SetLine -550 2800 [ 600 2800 ] PLine -10 SetLine --150 2925 [ 550 2925 ] PLine -550 2925 [ 550 2675 ] PLine -550 2675 [ -150 2675 ] PLine --150 2675 [ -150 2925 ] PLine -10 SetLine --200 2800 [ -150 2800 ] PLine -10 SetLine --450 2800 [ -400 2800 ] PLine -10 SetLine --1150 2925 [ -450 2925 ] PLine --450 2925 [ -450 2675 ] PLine --450 2675 [ -1150 2675 ] PLine --1150 2675 [ -1150 2925 ] PLine -10 SetLine --1200 2800 [ -1150 2800 ] PLine -10 SetLine -0 2150 [ 0 2100 ] PLine -10 SetLine -65 2450 [ 65 2150 ] PLine -65 2150 [ -65 2150 ] PLine --65 2150 [ -65 2450 ] PLine --65 2450 [ 65 2450 ] PLine -10 SetLine -0 2500 [ 0 2450 ] PLine -10 SetLine --1200 3050 [ -1200 3000 ] PLine -10 SetLine --1135 3350 [ -1135 3050 ] PLine --1135 3050 [ -1265 3050 ] PLine --1265 3050 [ -1265 3350 ] PLine --1265 3350 [ -1135 3350 ] PLine -10 SetLine --1200 3400 [ -1200 3350 ] PLine -10 SetLine --950 2250 [ -1150 2250 ] PLine --1150 2250 [ -1150 2350 ] PLine --1150 2350 [ -950 2350 ] PLine --950 2350 [ -950 2250 ] PLine -10 SetLine --1150 2550 [ -950 2550 ] PLine --950 2550 [ -950 2450 ] PLine --950 2450 [ -1150 2450 ] PLine --1150 2450 [ -1150 2550 ] PLine -10 SetLine -850 2850 [ 1050 2850 ] PLine -1050 2850 [ 1050 2750 ] PLine -1050 2750 [ 850 2750 ] PLine -850 2750 [ 850 2850 ] PLine -10 SetLine -500 1900 [ 450 1900 ] PLine -10 SetLine -1200 1775 [ 500 1775 ] PLine -500 1775 [ 500 2025 ] PLine -500 2025 [ 1200 2025 ] PLine -1200 2025 [ 1200 1775 ] PLine -10 SetLine -1250 1900 [ 1200 1900 ] PLine -10 SetLine --1150 900 [ -1200 900 ] PLine -10 SetLine --150 725 [ -1150 725 ] PLine --1150 725 [ -1150 1075 ] PLine --1150 1075 [ -150 1075 ] PLine --150 1075 [ -150 725 ] PLine -10 SetLine --100 900 [ -150 900 ] PLine -10 SetLine --1050 4000 [ -1100 4000 ] PLine -10 SetLine --750 3935 [ -1050 3935 ] PLine --1050 3935 [ -1050 4065 ] PLine --1050 4065 [ -750 4065 ] PLine --750 4065 [ -750 3935 ] PLine -10 SetLine --700 4000 [ -750 4000 ] PLine -10 SetLine -750 3000 [ 700 3000 ] PLine -10 SetLine -1050 2935 [ 750 2935 ] PLine -750 2935 [ 750 3065 ] PLine -750 3065 [ 1050 3065 ] PLine -1050 3065 [ 1050 2935 ] PLine -10 SetLine -1100 3000 [ 1050 3000 ] PLine -10 SetLine --250 3750 [ -50 3750 ] PLine --50 3750 [ -50 3650 ] PLine --50 3650 [ -250 3650 ] PLine --250 3650 [ -250 3750 ] PLine -10 SetLine -200 900 [ 150 900 ] PLine -10 SetLine -270 950 [ 270 850 ] PLine -10 SetLine -200 850 [ 200 950 ] PLine -200 950 [ 500 950 ] PLine -500 950 [ 500 850 ] PLine -500 850 [ 200 850 ] PLine -10 SetLine -500 900 [ 550 900 ] PLine -10 SetLine -250 850 [ 250 950 ] PLine -10 SetLine -260 850 [ 260 950 ] PLine -10 SetLine -600 3700 [ 650 3700 ] PLine -10 SetLine -530 3650 [ 530 3750 ] PLine -10 SetLine -600 3750 [ 600 3650 ] PLine -600 3650 [ 300 3650 ] PLine -300 3650 [ 300 3750 ] PLine -300 3750 [ 600 3750 ] PLine -10 SetLine -300 3700 [ 250 3700 ] PLine -10 SetLine -550 3750 [ 550 3650 ] PLine -10 SetLine -540 3750 [ 540 3650 ] PLine -10 SetLine --750 550 100 PCircle -10 SetLine -0 550 100 PCircle -10 SetLine -750 550 100 PCircle -10 SetLine -768 5000 [ 768 5248 ] PLine -768 5248 [ -768 5248 ] PLine --768 5248 [ -768 5000 ] PLine -10 SetLine -1058 4900 [ -1058 4900 ] PLine -10 SetLine -1058 5000 [ 1058 4408 ] PLine -1058 4408 [ -1058 4408 ] PLine --1058 4408 [ -1058 5000 ] PLine --1058 5000 [ 1058 5000 ] PLine -10 SetLine -1058 5000 [ -1058 5000 ] PLine -10 SetLine -768 4900 [ 768 4408 ] PLine -10 SetLine --768 4900 [ -768 4408 ] PLine -10 SetLine -900 200 [ 1100 200 ] PLine -1100 200 [ 1100 100 ] PLine -1100 100 [ 900 100 ] PLine -900 100 [ 900 200 ] PLine -10 SetLine --100 200 [ 100 200 ] PLine -100 200 [ 100 100 ] PLine -100 100 [ -100 100 ] PLine --100 100 [ -100 200 ] PLine -10 SetLine --1100 200 [ -900 200 ] PLine --900 200 [ -900 100 ] PLine --900 100 [ -1100 100 ] PLine --1100 100 [ -1100 200 ] PLine -10 SetLine -916 3493 [ 900 3456 ] PLine -900 3456 [ 939 3442 ] PLine -939 3442 [ 953 3477 ] PLine -10 SetLine -988 3612 140 PCircle -10 SetLine --1000 1529 [ -1039 1490 ] PLine -10 SetLine --1000 1490 [ -1000 1910 ] PLine --1000 1910 [ -1300 1910 ] PLine --1300 1910 [ -1300 1490 ] PLine --1300 1490 [ -1000 1490 ] PLine -10 SetLine -200 1730 [ 200 1670 ] PLine -200 1670 [ 0 1670 ] PLine -0 1670 [ 0 1730 ] PLine -0 1730 [ 200 1730 ] PLine -10 SetLine -200 1700 [ 260 1700 ] PLine -10 SetLine -0 1700 [ -50 1700 ] PLine -10 SetLine -300 1270 [ 300 1330 ] PLine -300 1330 [ 500 1330 ] PLine -500 1330 [ 500 1270 ] PLine -500 1270 [ 300 1270 ] PLine -10 SetLine -300 1300 [ 240 1300 ] PLine -10 SetLine -500 1300 [ 550 1300 ] PLine -10 SetLine --600 2270 [ -600 2330 ] PLine --600 2330 [ -400 2330 ] PLine --400 2330 [ -400 2270 ] PLine --400 2270 [ -600 2270 ] PLine -10 SetLine --600 2300 [ -660 2300 ] PLine -10 SetLine --400 2300 [ -350 2300 ] PLine -10 SetLine --800 4230 [ -800 4170 ] PLine --800 4170 [ -1000 4170 ] PLine --1000 4170 [ -1000 4230 ] PLine --1000 4230 [ -800 4230 ] PLine -10 SetLine --800 4200 [ -740 4200 ] PLine -10 SetLine --1000 4200 [ -1050 4200 ] PLine -10 SetLine -1000 3230 [ 1000 3170 ] PLine -1000 3170 [ 800 3170 ] PLine -800 3170 [ 800 3230 ] PLine -800 3230 [ 1000 3230 ] PLine -10 SetLine -1000 3200 [ 1060 3200 ] PLine -10 SetLine -800 3200 [ 750 3200 ] PLine -10 SetLine --600 2470 [ -600 2530 ] PLine --600 2530 [ -400 2530 ] PLine --400 2530 [ -400 2470 ] PLine --400 2470 [ -600 2470 ] PLine -10 SetLine --600 2500 [ -660 2500 ] PLine -10 SetLine --400 2500 [ -350 2500 ] PLine -10 SetLine --600 2070 [ -600 2130 ] PLine --600 2130 [ -400 2130 ] PLine --400 2130 [ -400 2070 ] PLine --400 2070 [ -600 2070 ] PLine -10 SetLine --600 2100 [ -660 2100 ] PLine -10 SetLine --400 2100 [ -350 2100 ] PLine -10 SetLine --900 2130 [ -900 2070 ] PLine --900 2070 [ -1100 2070 ] PLine --1100 2070 [ -1100 2130 ] PLine --1100 2130 [ -900 2130 ] PLine -10 SetLine --900 2100 [ -840 2100 ] PLine -10 SetLine --1100 2100 [ -1150 2100 ] PLine -10 SetLine -500 1130 [ 500 1070 ] PLine -500 1070 [ 300 1070 ] PLine -300 1070 [ 300 1130 ] PLine -300 1130 [ 500 1130 ] PLine -10 SetLine -500 1100 [ 560 1100 ] PLine -10 SetLine -300 1100 [ 250 1100 ] PLine -10 SetLine -1000 2521 [ 1039 2560 ] PLine -10 SetLine -1000 2560 [ 1000 2140 ] PLine -1000 2140 [ 1300 2140 ] PLine -1300 2140 [ 1300 2560 ] PLine -1300 2560 [ 1000 2560 ] PLine -10 SetLine -0 1870 [ 0 1930 ] PLine -0 1930 [ 200 1930 ] PLine -200 1930 [ 200 1870 ] PLine -200 1870 [ 0 1870 ] PLine -10 SetLine -0 1900 [ -60 1900 ] PLine -10 SetLine -200 1900 [ 250 1900 ] PLine -10 SetLine -100 1470 [ 100 1530 ] PLine -100 1530 [ 300 1530 ] PLine -300 1530 [ 300 1470 ] PLine -300 1470 [ 100 1470 ] PLine -10 SetLine -100 1500 [ 40 1500 ] PLine -10 SetLine -300 1500 [ 350 1500 ] PLine -10 SetLine --950 1650 [ -250 1650 ] PLine --250 1650 [ -250 1850 ] PLine --250 1850 [ -950 1850 ] PLine --950 1850 [ -950 1775 ] PLine --950 1775 [ -900 1775 ] PLine --900 1775 [ -900 1725 ] PLine --900 1725 [ -950 1725 ] PLine --950 1725 [ -950 1650 ] PLine -10 SetLine -150 2250 [ 950 2250 ] PLine -950 2250 [ 950 2450 ] PLine -950 2450 [ 150 2450 ] PLine -150 2450 [ 150 2375 ] PLine -150 2375 [ 200 2375 ] PLine -200 2375 [ 200 2325 ] PLine -200 2325 [ 150 2325 ] PLine -150 2325 [ 150 2250 ] PLine -10 SetLine -150 3950 [ 1150 3950 ] PLine -1150 3950 [ 1150 4150 ] PLine -1150 4150 [ 150 4150 ] PLine -150 4150 [ 150 4075 ] PLine -150 4075 [ 200 4075 ] PLine -200 4075 [ 200 4025 ] PLine -200 4025 [ 150 4025 ] PLine -150 4025 [ 150 3950 ] PLine -10 SetLine --1050 3150 [ -250 3150 ] PLine --250 3150 [ -250 3350 ] PLine --250 3350 [ -1050 3350 ] PLine --1050 3350 [ -1050 3275 ] PLine --1050 3275 [ -1000 3275 ] PLine --1000 3275 [ -1000 3225 ] PLine --1000 3225 [ -1050 3225 ] PLine --1050 3225 [ -1050 3150 ] PLine -10 SetLine -800 1075 [ 800 1675 ] PLine -800 1675 [ 1200 1675 ] PLine -1200 1675 [ 1200 1075 ] PLine -1200 1075 [ 800 1075 ] PLine -10 SetLine -875 1075 [ 875 825 ] PLine -875 825 [ 925 825 ] PLine -925 825 [ 925 1075 ] PLine -10 SetLine -1075 1075 [ 1075 825 ] PLine -1075 825 [ 1125 825 ] PLine -1125 825 [ 1125 1075 ] PLine -10 SetLine -975 1075 [ 975 825 ] PLine -975 825 [ 1025 825 ] PLine -1025 825 [ 1025 1075 ] PLine -10 SetLine -996 1549 75 PCircle -10 SetLine -800 1425 [ 1200 1425 ] PLine -10 SetLine --100 4200 [ -25 4200 ] PLine -10 SetLine --100 3900 [ -100 4300 ] PLine --100 4300 [ -500 4300 ] PLine --500 4300 [ -500 3900 ] PLine --500 3900 [ -100 3900 ] PLine -10 SetLine --100 4000 [ -25 4000 ] PLine -10 SetLine --1100 450 100 PCircle -10 SetLine -1100 450 100 PCircle -10 SetLine -1000 3430 [ 1000 3370 ] PLine -1000 3370 [ 800 3370 ] PLine -800 3370 [ 800 3430 ] PLine -800 3430 [ 1000 3430 ] PLine -10 SetLine -1000 3400 [ 1060 3400 ] PLine -10 SetLine -800 3400 [ 750 3400 ] PLine -10 SetText2 -0 -1175 1225 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1175 1279 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -1175 1310 [ [ -65 29 -65 6 -37 4 -40 6 -43 13 -43 20 -40 27 -34 31 -25 34 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 75 3375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3375 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 75 3175 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3175 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 75 3575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3575 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -825 3850 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 3850 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -575 1450 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -521 1450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -490 1450 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 125 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 179 2950 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 210 2950 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -825 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 2950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 -100 2250 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -100 2304 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -100 2335 [ [ -65 4 -65 29 -40 15 -40 22 -37 27 -34 29 -25 31 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 -1275 3200 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1275 3254 [ [ -50 2 -53 2 -59 4 -62 6 -65 11 -65 20 -62 25 -59 27 -53 29 -46 29 -40 27 -31 22 0 0 0 31 ] ] Char -10 SetText2 -0 -1100 2375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1100 2575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2575 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2575 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 900 2875 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 954 2875 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 985 2875 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 800 2050 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 854 2050 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 885 2050 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 -675 1100 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -621 1100 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -590 1100 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -925 4075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -871 4075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 875 3075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 929 3075 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -200 3775 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -146 3775 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 325 975 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 377 975 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 450 3775 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 502 3775 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -775 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -732 675 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -50 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -7 675 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 700 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 743 675 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -1175 4650 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -1132 4650 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 1172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 1274 125 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 274 125 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -875 125 [ [ 0 65 0 0 27 0 ] ] Char -0 -828 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -778 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -726 125 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1075 3425 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] [ 20 12 34 -6 ] ] Char -0 1131 3425 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1075 1475 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 -1127 1475 [ [ -11 -65 -4 -62 -2 -56 -2 -50 -4 -43 -9 -40 -18 -37 -25 -34 -29 -28 -31 -21 -31 -12 -29 -6 -27 -3 -20 0 -11 0 -4 -3 -2 -6 0 -12 0 -21 -2 -28 -6 -34 -13 -37 -22 -40 -27 -43 -29 -50 -29 -56 -27 -62 -20 -65 -11 -65 ] ] Char -10 SetText2 -0 25 1750 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 77 1750 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 108 1750 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 350 1350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1350 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1350 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2350 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -925 4250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -873 4250 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 850 3250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 902 3250 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -550 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2150 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 -1025 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -973 2150 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 350 1150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1150 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1150 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 1200 2125 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 1148 2125 [ [ -31 -65 -9 0 ] [ 0 -65 -31 -65 ] ] Char -10 SetText2 -0 50 1950 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 102 1950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 150 1550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 202 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 233 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -675 1950 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 1950 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 450 2550 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 502 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 500 4275 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 552 4275 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -675 3450 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 950 1700 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 1002 1700 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -350 4325 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -298 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1225 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -1169 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 -1117 600 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1181 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 1233 600 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 800 3450 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 852 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 883 3450 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -0 0 60 /PRndPad SetFlash --1100 1450 Flash --1100 1150 Flash -300 3300 Flash --100 3300 Flash --100 3100 Flash -300 3100 Flash -300 3500 Flash --100 3500 Flash --400 3700 Flash --1200 3700 Flash --100 1300 Flash --900 1300 Flash --200 2800 Flash -600 2800 Flash --1200 2800 Flash --400 2800 Flash -0 2500 Flash -0 2100 Flash --1200 3400 Flash --1200 3000 Flash --900 2300 Flash --1200 2300 Flash --1200 2500 Flash --900 2500 Flash -800 2800 Flash -1100 2800 Flash -1250 1900 Flash -450 1900 Flash --100 900 Flash --1200 900 Flash --700 4000 Flash --1100 4000 Flash -1100 3000 Flash -700 3000 Flash --300 3700 Flash -0 3700 Flash -0 0 60 /PSqrPad SetFlash -100 900 Flash -0 0 60 /PRndPad SetFlash -600 900 Flash -0 0 60 /PSqrPad SetFlash -700 3700 Flash -0 0 60 /PRndPad SetFlash -200 3700 Flash -0 0 70 /PRndPad SetFlash --750 550 Flash --750 450 Flash -0 550 Flash -0 450 Flash -750 550 Flash -750 450 Flash --648 4479 Flash --540 4479 Flash --432 4479 Flash --324 4479 Flash --216 4479 Flash --108 4479 Flash -0 4479 Flash -108 4479 Flash -216 4479 Flash -324 4479 Flash -432 4479 Flash -540 4479 Flash -648 4479 Flash --594 4593 Flash --486 4593 Flash --378 4593 Flash --270 4593 Flash --162 4593 Flash --54 4593 Flash -54 4593 Flash -162 4593 Flash -270 4593 Flash -378 4593 Flash -486 4593 Flash -594 4593 Flash -0 0 177 /PRndPad SetFlash -940 4536 Flash --940 4536 Flash -0 0 60 /PSqrPad SetFlash -950 150 Flash -0 0 60 /PRndPad SetFlash -1050 150 Flash -0 0 60 /PSqrPad SetFlash --50 150 Flash -0 0 60 /PRndPad SetFlash -50 150 Flash -0 0 60 /PSqrPad SetFlash --1050 150 Flash -0 0 60 /PRndPad SetFlash --950 150 Flash -0 0 50 /PRndPad SetFlash -950 3524 Flash -1026 3612 Flash -950 3700 Flash -0 0 60 /PSqrPad SetFlash --1200 1600 Flash -0 0 60 /PRndPad SetFlash --1100 1700 Flash --1200 1800 Flash -300 1700 Flash --100 1700 Flash -200 1300 Flash -600 1300 Flash --700 2300 Flash --300 2300 Flash --700 4200 Flash --1100 4200 Flash -1100 3200 Flash -700 3200 Flash --700 2500 Flash --300 2500 Flash --700 2100 Flash --300 2100 Flash --800 2100 Flash --1200 2100 Flash -600 1100 Flash -200 1100 Flash -0 0 60 /PSqrPad SetFlash -1200 2450 Flash -0 0 60 /PRndPad SetFlash -1100 2350 Flash -1200 2250 Flash --100 1900 Flash -300 1900 Flash -0 1500 Flash -400 1500 Flash -0 0 60 /PSqrPad SetFlash --900 1600 Flash -0 0 60 /PRndPad SetFlash --800 1600 Flash --700 1600 Flash --600 1600 Flash --500 1600 Flash --400 1600 Flash --300 1600 Flash --300 1900 Flash --400 1900 Flash --500 1900 Flash --600 1900 Flash --700 1900 Flash --800 1900 Flash --900 1900 Flash -0 0 60 /PSqrPad SetFlash -200 2200 Flash -0 0 60 /PRndPad SetFlash -300 2200 Flash -400 2200 Flash -500 2200 Flash -600 2200 Flash -700 2200 Flash -800 2200 Flash -900 2200 Flash -900 2500 Flash -800 2500 Flash -700 2500 Flash -600 2500 Flash -500 2500 Flash -400 2500 Flash -300 2500 Flash -200 2500 Flash -0 0 60 /PSqrPad SetFlash -200 3900 Flash -0 0 60 /PRndPad SetFlash -300 3900 Flash -400 3900 Flash -500 3900 Flash -600 3900 Flash -700 3900 Flash -800 3900 Flash -900 3900 Flash -1000 3900 Flash -1100 3900 Flash -1100 4200 Flash -1000 4200 Flash -900 4200 Flash -800 4200 Flash -700 4200 Flash -600 4200 Flash -500 4200 Flash -400 4200 Flash -300 4200 Flash -200 4200 Flash -0 0 60 /PSqrPad SetFlash --1000 3100 Flash -0 0 60 /PRndPad SetFlash --900 3100 Flash --800 3100 Flash --700 3100 Flash --600 3100 Flash --500 3100 Flash --400 3100 Flash --300 3100 Flash --300 3400 Flash --400 3400 Flash --500 3400 Flash --600 3400 Flash --700 3400 Flash --800 3400 Flash --900 3400 Flash --1000 3400 Flash -0 0 70 /PRndPad SetFlash -900 800 Flash -1100 800 Flash -1000 800 Flash -0 0 177 /PRndPad SetFlash -1000 1550 Flash -0 0 60 /PRndPad SetFlash -0 4000 Flash -0 4200 Flash -0 0 250 /PRndPad SetFlash --1100 450 Flash -1100 450 Flash -0 0 60 /PRndPad SetFlash -1100 3400 Flash -700 3400 Flash -0 0 60 /PRndPad SetFlash --1100 1450 Flash --1100 1150 Flash -300 3300 Flash --100 3300 Flash --100 3100 Flash -300 3100 Flash -300 3500 Flash --100 3500 Flash --400 3700 Flash --1200 3700 Flash --100 1300 Flash --900 1300 Flash --200 2800 Flash -600 2800 Flash --1200 2800 Flash --400 2800 Flash -0 2500 Flash -0 2100 Flash --1200 3400 Flash --1200 3000 Flash --900 2300 Flash --1200 2300 Flash --1200 2500 Flash --900 2500 Flash -800 2800 Flash -1100 2800 Flash -1250 1900 Flash -450 1900 Flash --100 900 Flash --1200 900 Flash --700 4000 Flash --1100 4000 Flash -1100 3000 Flash -700 3000 Flash --300 3700 Flash -0 3700 Flash -0 0 60 /PSqrPad SetFlash -100 900 Flash -0 0 60 /PRndPad SetFlash -600 900 Flash -0 0 60 /PSqrPad SetFlash -700 3700 Flash -0 0 60 /PRndPad SetFlash -200 3700 Flash -0 0 70 /PRndPad SetFlash --750 550 Flash --750 450 Flash -0 550 Flash -0 450 Flash -750 550 Flash -750 450 Flash --648 4479 Flash --540 4479 Flash --432 4479 Flash --324 4479 Flash --216 4479 Flash --108 4479 Flash -0 4479 Flash -108 4479 Flash -216 4479 Flash -324 4479 Flash -432 4479 Flash -540 4479 Flash -648 4479 Flash --594 4593 Flash --486 4593 Flash --378 4593 Flash --270 4593 Flash --162 4593 Flash --54 4593 Flash -54 4593 Flash -162 4593 Flash -270 4593 Flash -378 4593 Flash -486 4593 Flash -594 4593 Flash -0 0 177 /PRndPad SetFlash -940 4536 Flash --940 4536 Flash -0 0 60 /PSqrPad SetFlash -950 150 Flash -0 0 60 /PRndPad SetFlash -1050 150 Flash -0 0 60 /PSqrPad SetFlash --50 150 Flash -0 0 60 /PRndPad SetFlash -50 150 Flash -0 0 60 /PSqrPad SetFlash --1050 150 Flash -0 0 60 /PRndPad SetFlash --950 150 Flash -0 0 50 /PRndPad SetFlash -950 3524 Flash -1026 3612 Flash -950 3700 Flash -0 0 60 /PSqrPad SetFlash --1200 1600 Flash -0 0 60 /PRndPad SetFlash --1100 1700 Flash --1200 1800 Flash -300 1700 Flash --100 1700 Flash -200 1300 Flash -600 1300 Flash --700 2300 Flash --300 2300 Flash --700 4200 Flash --1100 4200 Flash -1100 3200 Flash -700 3200 Flash --700 2500 Flash --300 2500 Flash --700 2100 Flash --300 2100 Flash --800 2100 Flash --1200 2100 Flash -600 1100 Flash -200 1100 Flash -0 0 60 /PSqrPad SetFlash -1200 2450 Flash -0 0 60 /PRndPad SetFlash -1100 2350 Flash -1200 2250 Flash --100 1900 Flash -300 1900 Flash -0 1500 Flash -400 1500 Flash -0 0 60 /PSqrPad SetFlash --900 1600 Flash -0 0 60 /PRndPad SetFlash --800 1600 Flash --700 1600 Flash --600 1600 Flash --500 1600 Flash --400 1600 Flash --300 1600 Flash --300 1900 Flash --400 1900 Flash --500 1900 Flash --600 1900 Flash --700 1900 Flash --800 1900 Flash --900 1900 Flash -0 0 60 /PSqrPad SetFlash -200 2200 Flash -0 0 60 /PRndPad SetFlash -300 2200 Flash -400 2200 Flash -500 2200 Flash -600 2200 Flash -700 2200 Flash -800 2200 Flash -900 2200 Flash -900 2500 Flash -800 2500 Flash -700 2500 Flash -600 2500 Flash -500 2500 Flash -400 2500 Flash -300 2500 Flash -200 2500 Flash -0 0 60 /PSqrPad SetFlash -200 3900 Flash -0 0 60 /PRndPad SetFlash -300 3900 Flash -400 3900 Flash -500 3900 Flash -600 3900 Flash -700 3900 Flash -800 3900 Flash -900 3900 Flash -1000 3900 Flash -1100 3900 Flash -1100 4200 Flash -1000 4200 Flash -900 4200 Flash -800 4200 Flash -700 4200 Flash -600 4200 Flash -500 4200 Flash -400 4200 Flash -300 4200 Flash -200 4200 Flash -0 0 60 /PSqrPad SetFlash --1000 3100 Flash -0 0 60 /PRndPad SetFlash --900 3100 Flash --800 3100 Flash --700 3100 Flash --600 3100 Flash --500 3100 Flash --400 3100 Flash --300 3100 Flash --300 3400 Flash --400 3400 Flash --500 3400 Flash --600 3400 Flash --700 3400 Flash --800 3400 Flash --900 3400 Flash --1000 3400 Flash -0 0 70 /PRndPad SetFlash -900 800 Flash -1100 800 Flash -1000 800 Flash -0 0 177 /PRndPad SetFlash -1000 1550 Flash -0 0 60 /PRndPad SetFlash -0 4000 Flash -0 4200 Flash -0 0 250 /PRndPad SetFlash --1100 450 Flash -1100 450 Flash -0 0 60 /PRndPad SetFlash -1100 3400 Flash -700 3400 Flash -10 SetText2 -0 -225 875 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 1125 1875 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -125 2775 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -1125 2775 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -525 3675 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -700 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -750 275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 34 25 ] [ 22 25 34 25 ] ] Char -0 -696 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -640 275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -588 275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 34 25 ] [ 22 25 34 25 ] ] Char -0 -534 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -484 275 [ [ 15 65 15 0 ] [ 0 65 31 65 ] ] Char -0 -380 275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 -328 275 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 -272 275 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -168 275 [ [ 0 28 40 28 ] ] Char -0 -55 275 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -3 275 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 49 275 [ [ 0 65 0 0 ] ] Char -0 69 275 [ [ 0 65 18 0 ] [ 36 65 18 0 ] ] Char -0 177 275 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 233 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] ] Char -0 335 275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 387 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 437 275 [ [ 0 65 0 0 27 0 ] ] Char -0 484 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 540 275 [ [ 0 65 11 0 ] [ 22 65 11 0 ] [ 22 65 34 0 ] [ 45 65 34 0 ] ] Char -0 605 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 661 275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 713 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 125 600 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 177 600 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 229 600 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 500 600 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -0 561 600 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 592 600 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -625 600 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -569 600 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -517 600 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -465 600 [ [ 0 65 0 0 ] ] Char -0 -445 600 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -10 SetText2 -0 -300 4725 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -0 -248 4725 [ [ 0 65 0 0 ] ] Char -0 -228 4725 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -176 4725 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -74 4725 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 300 4725 [ [ -31 56 -27 62 -20 65 -11 65 -4 62 0 56 0 50 -2 43 -4 40 -9 37 -22 31 -27 28 -29 25 -31 18 -31 9 -27 3 -20 0 -11 0 -4 3 0 9 ] ] Char -0 248 4725 [ [ 0 65 0 0 ] ] Char -0 228 4725 [ [ 0 65 0 0 ] [ 0 65 -15 65 -22 62 -27 56 -29 50 -31 40 -31 25 -29 15 -27 9 -22 3 -15 0 0 0 ] ] Char -0 176 4725 [ [ 0 65 0 0 ] [ 0 65 -29 65 ] [ 0 34 -18 34 ] [ 0 0 -29 0 ] ] Char -0 74 4725 [ [ -2 50 -2 53 -4 59 -6 62 -11 65 -20 65 -25 62 -27 59 -29 53 -29 46 -27 40 -22 31 0 0 -31 0 ] ] Char -10 SetText2 -0 1100 2075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1050 1925 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 875 675 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1075 675 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 975 675 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -925 1475 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 175 3775 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1050 2975 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 625 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 656 4325 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -825 1275 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -0 0 55 /PRndPad SetFlash --200 2350 Flash --200 1750 Flash -200 1400 Flash -0 0 55 /PRndPad SetFlash --200 2350 Flash --200 1750 Flash -200 1400 Flash -0 0 55 /PRndPad SetFlash -300 1100 Flash -0 0 55 /PRndPad SetFlash -300 1100 Flash -0 0 55 /PRndPad SetFlash -175 3300 Flash -0 0 55 /PRndPad SetFlash -175 3300 Flash -0 0 55 /PRndPad SetFlash -1000 2650 Flash -0 0 55 /PRndPad SetFlash -1000 2650 Flash -0 0 55 /PRndPad SetFlash --450 2100 Flash -0 0 55 /PRndPad SetFlash --450 2100 Flash -0 0 55 /PRndPad SetFlash --650 2600 Flash --100 2600 Flash --100 2250 Flash -0 0 55 /PRndPad SetFlash --650 2600 Flash --100 2600 Flash --100 2250 Flash -0 0 55 /PRndPad SetFlash -800 1800 Flash -0 0 55 /PRndPad SetFlash -800 1800 Flash -0 0 55 /PRndPad SetFlash -700 1900 Flash -0 0 55 /PRndPad SetFlash -700 1900 Flash -0 0 55 /PRndPad SetFlash -600 1700 Flash -0 0 55 /PRndPad SetFlash -600 1700 Flash -0 0 55 /PRndPad SetFlash -500 1600 Flash -0 0 55 /PRndPad SetFlash -500 1600 Flash -0 0 55 /PRndPad SetFlash -0 4100 Flash -900 4100 Flash -0 0 55 /PRndPad SetFlash -0 4100 Flash -900 4100 Flash -0 0 55 /PRndPad SetFlash -800 3000 Flash -0 0 55 /PRndPad SetFlash -800 3000 Flash -0 0 55 /PRndPad SetFlash -600 3700 Flash -0 0 55 /PRndPad SetFlash -600 3700 Flash -0 0 55 /PRndPad SetFlash -450 2700 Flash --400 2700 Flash --400 2300 Flash -0 0 55 /PRndPad SetFlash -450 2700 Flash --400 2700 Flash --400 2300 Flash -0 0 55 /PRndPad SetFlash -350 3800 Flash -0 0 55 /PRndPad SetFlash -350 3800 Flash -0 0 55 /PRndPad SetFlash --850 3700 Flash -0 0 55 /PRndPad SetFlash --850 3700 Flash -0 0 55 /PRndPad SetFlash -400 1300 Flash -0 0 55 /PRndPad SetFlash -400 1300 Flash -0 0 55 /PRndPad SetFlash --1050 1050 Flash -0 0 55 /PRndPad SetFlash --1050 1050 Flash -0 0 55 /PRndPad SetFlash -0 4475 Flash -75 4000 Flash -1000 4000 Flash -0 0 55 /PRndPad SetFlash -0 4475 Flash -75 4000 Flash -1000 4000 Flash -0 0 55 /PRndPad SetFlash -950 3200 Flash -0 0 55 /PRndPad SetFlash -950 3200 Flash -0 0 55 /PRndPad SetFlash -850 1200 Flash --600 1200 Flash -0 0 55 /PRndPad SetFlash -850 1200 Flash --600 1200 Flash -0 0 55 /PRndPad SetFlash --550 3900 Flash --350 3900 Flash -0 0 55 /PRndPad SetFlash --550 3900 Flash --350 3900 Flash -0 0 55 /PRndPad SetFlash --800 4300 Flash -0 0 55 /PRndPad SetFlash --800 4300 Flash -0 0 55 /PRndPad SetFlash --750 4350 Flash -0 0 55 /PRndPad SetFlash --750 4350 Flash -0 0 55 /PRndPad SetFlash -400 3400 Flash -0 0 55 /PRndPad SetFlash -400 3400 Flash -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/sm0228.lpr b/usr.sbin/xntpd/gadget/sm0228.lpr deleted file mode 100644 index cd39c9ca9291..000000000000 --- a/usr.sbin/xntpd/gadget/sm0228.lpr +++ /dev/null @@ -1,744 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:35:33 1992) show -gsave -Init -8000 10500 Clipto -4000 2800 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -0 0 70 /PRndPad SetFlash --1100 1450 Flash --1100 1150 Flash -300 3300 Flash --100 3300 Flash --100 3100 Flash -300 3100 Flash -300 3500 Flash --100 3500 Flash --400 3700 Flash --1200 3700 Flash --100 1300 Flash --900 1300 Flash --200 2800 Flash -600 2800 Flash --1200 2800 Flash --400 2800 Flash -0 2500 Flash -0 2100 Flash --1200 3400 Flash --1200 3000 Flash --900 2300 Flash --1200 2300 Flash --1200 2500 Flash --900 2500 Flash -800 2800 Flash -1100 2800 Flash -1250 1900 Flash -450 1900 Flash --100 900 Flash --1200 900 Flash --700 4000 Flash --1100 4000 Flash -1100 3000 Flash -700 3000 Flash --300 3700 Flash -0 3700 Flash -0 0 70 /PSqrPad SetFlash -100 900 Flash -0 0 70 /PRndPad SetFlash -600 900 Flash -0 0 70 /PSqrPad SetFlash -700 3700 Flash -0 0 70 /PRndPad SetFlash -200 3700 Flash -0 0 80 /PRndPad SetFlash --750 550 Flash --750 450 Flash -0 550 Flash -0 450 Flash -750 550 Flash -750 450 Flash --648 4479 Flash --540 4479 Flash --432 4479 Flash --324 4479 Flash --216 4479 Flash --108 4479 Flash -0 4479 Flash -108 4479 Flash -216 4479 Flash -324 4479 Flash -432 4479 Flash -540 4479 Flash -648 4479 Flash --594 4593 Flash --486 4593 Flash --378 4593 Flash --270 4593 Flash --162 4593 Flash --54 4593 Flash -54 4593 Flash -162 4593 Flash -270 4593 Flash -378 4593 Flash -486 4593 Flash -594 4593 Flash -0 0 187 /PRndPad SetFlash -940 4536 Flash --940 4536 Flash -0 0 70 /PSqrPad SetFlash -950 150 Flash -0 0 70 /PRndPad SetFlash -1050 150 Flash -0 0 70 /PSqrPad SetFlash --50 150 Flash -0 0 70 /PRndPad SetFlash -50 150 Flash -0 0 70 /PSqrPad SetFlash --1050 150 Flash -0 0 70 /PRndPad SetFlash --950 150 Flash -0 0 60 /PRndPad SetFlash -950 3524 Flash -1026 3612 Flash -950 3700 Flash -0 0 70 /PSqrPad SetFlash --1200 1600 Flash -0 0 70 /PRndPad SetFlash --1100 1700 Flash --1200 1800 Flash -300 1700 Flash --100 1700 Flash -200 1300 Flash -600 1300 Flash --700 2300 Flash --300 2300 Flash --700 4200 Flash --1100 4200 Flash -1100 3200 Flash -700 3200 Flash --700 2500 Flash --300 2500 Flash --700 2100 Flash --300 2100 Flash --800 2100 Flash --1200 2100 Flash -600 1100 Flash -200 1100 Flash -0 0 70 /PSqrPad SetFlash -1200 2450 Flash -0 0 70 /PRndPad SetFlash -1100 2350 Flash -1200 2250 Flash --100 1900 Flash -300 1900 Flash -0 1500 Flash -400 1500 Flash -0 0 70 /PSqrPad SetFlash --900 1600 Flash -0 0 70 /PRndPad SetFlash --800 1600 Flash --700 1600 Flash --600 1600 Flash --500 1600 Flash --400 1600 Flash --300 1600 Flash --300 1900 Flash --400 1900 Flash --500 1900 Flash --600 1900 Flash --700 1900 Flash --800 1900 Flash --900 1900 Flash -0 0 70 /PSqrPad SetFlash -200 2200 Flash -0 0 70 /PRndPad SetFlash -300 2200 Flash -400 2200 Flash -500 2200 Flash -600 2200 Flash -700 2200 Flash -800 2200 Flash -900 2200 Flash -900 2500 Flash -800 2500 Flash -700 2500 Flash -600 2500 Flash -500 2500 Flash -400 2500 Flash -300 2500 Flash -200 2500 Flash -0 0 70 /PSqrPad SetFlash -200 3900 Flash -0 0 70 /PRndPad SetFlash -300 3900 Flash -400 3900 Flash -500 3900 Flash -600 3900 Flash -700 3900 Flash -800 3900 Flash -900 3900 Flash -1000 3900 Flash -1100 3900 Flash -1100 4200 Flash -1000 4200 Flash -900 4200 Flash -800 4200 Flash -700 4200 Flash -600 4200 Flash -500 4200 Flash -400 4200 Flash -300 4200 Flash -200 4200 Flash -0 0 70 /PSqrPad SetFlash --1000 3100 Flash -0 0 70 /PRndPad SetFlash --900 3100 Flash --800 3100 Flash --700 3100 Flash --600 3100 Flash --500 3100 Flash --400 3100 Flash --300 3100 Flash --300 3400 Flash --400 3400 Flash --500 3400 Flash --600 3400 Flash --700 3400 Flash --800 3400 Flash --900 3400 Flash --1000 3400 Flash -0 0 80 /PRndPad SetFlash -900 800 Flash -1100 800 Flash -1000 800 Flash -0 0 187 /PRndPad SetFlash -1000 1550 Flash -0 0 70 /PRndPad SetFlash -0 4000 Flash -0 4200 Flash -0 0 260 /PRndPad SetFlash --1100 450 Flash -1100 450 Flash -0 0 70 /PRndPad SetFlash -1100 3400 Flash -700 3400 Flash -0 0 65 /PRndPad SetFlash --200 2350 Flash --200 1750 Flash -200 1400 Flash -0 0 65 /PRndPad SetFlash -300 1100 Flash -0 0 65 /PRndPad SetFlash -175 3300 Flash -0 0 65 /PRndPad SetFlash -1000 2650 Flash -0 0 65 /PRndPad SetFlash --450 2100 Flash -0 0 65 /PRndPad SetFlash --650 2600 Flash --100 2600 Flash --100 2250 Flash -0 0 65 /PRndPad SetFlash -800 1800 Flash -0 0 65 /PRndPad SetFlash -700 1900 Flash -0 0 65 /PRndPad SetFlash -600 1700 Flash -0 0 65 /PRndPad SetFlash -500 1600 Flash -0 0 65 /PRndPad SetFlash -0 4100 Flash -900 4100 Flash -0 0 65 /PRndPad SetFlash -800 3000 Flash -0 0 65 /PRndPad SetFlash -600 3700 Flash -0 0 65 /PRndPad SetFlash -450 2700 Flash --400 2700 Flash --400 2300 Flash -0 0 65 /PRndPad SetFlash -350 3800 Flash -0 0 65 /PRndPad SetFlash --850 3700 Flash -0 0 65 /PRndPad SetFlash -400 1300 Flash -0 0 65 /PRndPad SetFlash --1050 1050 Flash -0 0 65 /PRndPad SetFlash -0 4475 Flash -75 4000 Flash -1000 4000 Flash -0 0 65 /PRndPad SetFlash -950 3200 Flash -0 0 65 /PRndPad SetFlash -850 1200 Flash --600 1200 Flash -0 0 65 /PRndPad SetFlash --550 3900 Flash --350 3900 Flash -0 0 65 /PRndPad SetFlash --800 4300 Flash -0 0 65 /PRndPad SetFlash --750 4350 Flash -0 0 65 /PRndPad SetFlash -400 3400 Flash -grestore -showpage diff --git a/usr.sbin/xntpd/gadget/sst0126.lpr b/usr.sbin/xntpd/gadget/sst0126.lpr deleted file mode 100644 index c3f19867cde1..000000000000 --- a/usr.sbin/xntpd/gadget/sst0126.lpr +++ /dev/null @@ -1,1118 +0,0 @@ -%!PS-Adobe-2.0 -%%Title: PADS Postscript Driver Header -%%Creator: Andy Montalvo, 18 Lupine St., Lowell, MA 01851 -%%CreationDate: 06/08/90 -%%For: CAD Software, Littleton, MA -%%EndComments -%%BeginProcSet: Markers 1.0 0 -% marker attributes -/MAttr_Width 1 def -/MAttr_Size 0 def -/MAttr_Type /M1 def -% procedures -/M1 { %def -% draw marker 1: plus -% Stack: - M1 - - -2 0 rmoveto - 4 0 rlineto - -2 2 rmoveto - 0 -4 rlineto -} bind def -/M2 { %def -% draw marker 2: cross -% Stack: - M2 - - -2 -2 rmoveto - 4 4 rlineto - -4 0 rmoveto - 4 -4 rlineto -} bind def -/M3 { %def -% draw marker 3: square -% Stack: - M3 - - 0 2 rlineto - 2 0 rlineto - 0 -4 rlineto - -4 0 rlineto - 0 4 rlineto - 2 0 rlineto -} bind def -/M4 { %def -% draw marker 4: diamond -% Stack: - M4 - - 0 2 rlineto - 2 -2 rlineto - -2 -2 rlineto - -2 2 rlineto - 2 2 rlineto -} bind def -/M5 { %def -% draw marker 5: hourglass -% Stack: - M5 - - 2 2 rlineto - -4 0 rlineto - 4 -4 rlineto - -4 0 rlineto - 2 2 rlineto -} bind def -/M6 { %def -% draw marker 6: bowtie -% Stack: - M6 - - 2 2 rlineto - 0 -4 rlineto - -4 4 rlineto - 0 -4 rlineto - 2 2 rlineto -} bind def -/M7 { %def -% draw marker 7: small plus (goes with char marker) -% Stack: - M7 - - -1 0 rmoveto - 2 0 rlineto - -1 1 rmoveto - 0 -2 rlineto -} bind def -/Marker { %def -% Command from driver: draw marker -% STACK: x y Marker - - MAttr_Size 0 gt - { - gsave - moveto - MAttr_Size 4 div dup scale - MAttr_Type load exec - 4 MAttr_Size div dup scale - MAttr_Width setlinewidth - stroke - grestore - } if -} def -%%EndProcSet: Markers 1.0 0 -%%BeginProcSet: Lib 1.0 0 -/sg { %def -% Command from driver: set the gray scale 0 - 100 -% STACK: greylevel sg - 100 div dup setgray /glev exch def -} bind def -/Circle { %def -% draw a circle -% STACK: x y radius Circle - - 0 360 arc -} bind def -/RndAper { %def -% select a round aperture -% STACK: - RndAper - - 1 setlinejoin - 1 setlinecap -} bind def -/SqrAper { %def -% select a square aperture -% STACK: - SqrAper - - 0 setlinejoin - 2 setlinecap -} bind def -/Line { %def -% draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] Line - - 3 1 roll - moveto - true - exch - % This pushes the x then the y then does lineto - { exch { false } { lineto true } ifelse } forall - pop -} bind def -/Clipto { %def -% set clipping rectangle from 0,0 to new values -% STACK: x y Clipto - - 0 0 moveto - dup 0 exch lineto - 2 copy lineto - pop - 0 lineto - closepath - clip - newpath -} bind def -/Clip4 { %def -% set clipping rectangle from xmin,ymin to xmax,ymax -% STACK: xmin ymin xmax ymax Clip4 - - 4 copy pop pop moveto - 4 copy pop exch lineto pop - 2 copy lineto - exch pop exch pop lineto - closepath - clip - newpath -} bind def -%%EndProcSet: Lib 1.0 0 -%%BeginProcSet: Lines 1.0 0 -% line attributes % -/LAttr_Width 1 def -% line procedures -/PLine { %def -% Cammand from driver: draw a set of connected lines -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - LAttr_Width setlinewidth - stroke -} bind def % PLine -/Char { %def -% Command from driver: draw a character at the current position -% STACK: type x y stroke_array Char - -% stroke array -- [ stroke1 stroke2 ... stroken ] -% stroke -- connected staight lines -% type = 0 if text 1 if marker - gsave - 4 1 roll - translate - 0 eq { TAttr_Width } { MAttr_Width } ifelse setlinewidth - { - dup length 2 gt - { - dup dup 0 get exch 1 get % get starting point - 3 -1 roll % put x y before array - dup length 2 sub 2 exch getinterval % delete first items from array - Line - stroke - } - { - aload pop currentlinewidth 2 div Circle fill - } ifelse - } forall - grestore -} bind def % Char -/PArc { %def -% Command from driver: draw an arc -% STACK: x y radius startangle deltaangle Arc - - 10 div exch 10 div exch - 2 copy pop add - arc - LAttr_Width setlinewidth - stroke -} bind def -/PCircle { %def -% Command from driver: draw an circle -% STACK: x y radius PCircle - - Circle - LAttr_Width setlinewidth - stroke -} bind def -%%EndProcSet: Lines 1.0 0 -%%BeginProcSet: Polygon 1.0 0 -% polygon attributes % -/PAttr_ExtWidth 1 def -/PAttr_IntWidth 1 def -/PAttr_Grid 1 def -% polygon procedures -/LoopSet { %def -% set up for loop condition -% STACK: start end LoopSet low gridwidth high - 2 copy lt { exch } if - % make grid line up to absolute coordinates - PAttr_Grid div truncate PAttr_Grid mul exch - PAttr_Grid exch -} bind def -/Hatch { %def -% draw cross hatch pattern in current path -% STACK: - Hatch - - pathbbox - /ury exch def - /urx exch def - /lly exch def - /llx exch def - clip - newpath - llx urx LoopSet - { % x loop - dup lly exch ury moveto lineto - } for - lly ury LoopSet - { % y loop - llx exch dup urx exch moveto lineto - } for - PAttr_IntWidth setlinewidth - stroke -} bind def -/PPoly { %def -% Command from driver: draw a plygon -% STACK: x1 y1 [ x2 y2 ... xn yn ] PLine - - Line - closepath - gsave - PAttr_IntWidth PAttr_Grid ge {fill} {Hatch} ifelse - grestore - PAttr_ExtWidth setlinewidth - stroke -} bind def -%%EndProcSet: Polygon 1.0 0 -%%BeginProcSet: Text 1.0 0 -% text attributes % -/TAttr_Mirr 0 def -/TAttr_Orient 0 def -/TAttr_Width 1 def -% text procedures -/Text { %def -% Command from driver: Draw text -% STACK: x y width string Text - - gsave - 4 2 roll - translate - TAttr_Mirr 0 gt - { - -1 1 scale - } if - TAttr_Orient rotate - 0 0 moveto - dup length dup 1 gt - { - exch dup stringwidth pop - 4 -1 roll - exch 2 copy - lt - { - div 1 scale show - } - { - sub - 3 -1 roll 1 sub div - 0 3 -1 roll ashow - } - ifelse - } - { - pop - show - } ifelse - grestore -} bind def -%%EndProcSet: Text 1.0 0 -%%BeginProcSet: FlashSymbols 1.0 0 -% flash symbol attributes % -/FAttr_Type /PRndPad def -/FAttr_Width 0 def -/FAttr_Length 1 def -/FAttr_Orient 0 def -% flash symbol procedures -/PRndPad { %def -% Command from driver: draw an circular pad -% STACK: - PCirclePad - - FAttr_Width dup scale - 0 0 .5 Circle - fill -} bind def -/PSqrPad { %def -% Draw an Square pad -% STACK: - PRectPad - - FAttr_Width dup scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/PRectPad { %def -% Draw an rectangular pad -% STACK: - PRectPad - - FAttr_Length FAttr_Width scale - .5 .5 moveto - -.5 .5 lineto - -.5 -.5 lineto - .5 -.5 lineto - closepath - fill -} bind def -/POvalPad { %def -% Draw an oval pad -% STACK: - POvalPad - - FAttr_Width setlinewidth - FAttr_Length FAttr_Width sub 2 div dup - neg 0 moveto - 0 lineto - RndAper - stroke -} bind def -/Anl { %def - 0 0 .5 Circle - fill - FAttr_Length FAttr_Width lt - { % inner circle - 0 0 - FAttr_Length 0 gt { FAttr_Length FAttr_Width div } { .5 } ifelse - 2 div Circle - 1 setgray - fill - glev setgray - } if -} bind def -/PAnlPad { %def -% Draw an annular pad -% STACK: - PAnlPad - - FAttr_Width dup scale - Anl -} bind def -/PRelPad { %def -% Draw an thermal relief pad -% STACK: - PRelPad - - PAnlPad - 1 setgray - .17 setlinewidth - 0 setlinecap % the x - 45 rotate - .5 0 moveto -.5 0 lineto - 0 .5 moveto 0 -.5 lineto - stroke - glev setgray -} bind def -/Flash { %def -% Command from driver: Flash a symbol -% STACK: x y Flash - - FAttr_Width 0 gt - { - gsave - translate - FAttr_Orient rotate - FAttr_Type load exec - grestore - } if -} def -%%EndProcSet: FlashSymbols 1.0 0 -%%BeginProcSet: SetAttr 1.0 0 -/SetLine { %def -% Set the width of the lines -% STACK: linewidth SetLine - - /LAttr_Width exch def - RndAper -} bind def -/SetPoly { %def -% Set attribute of polygon -% STACK: external_width internal_grid_width grid_spacing SetPoly - - /PAttr_Grid exch def - /PAttr_IntWidth exch def - /PAttr_ExtWidth exch def - RndAper -} bind def -/SetFlash { %def -% Set Attributed of flash pad -% STACK: orientation_angle length width aperture_type SetFlash - - /FAttr_Type exch def - FAttr_Type /PSqrPad eq FAttr_Type /PRectPad eq or - { SqrAper } { RndAper } ifelse - /FAttr_Width exch def - /FAttr_Length exch def - /FAttr_Orient exch 10 div def -} bind def -/SetMkr { %def -% Set attributes of markers -% STACK: linewidth size type SetMkr - - /MAttr_Type exch def - /MAttr_Size exch def - /MAttr_Width exch def - RndAper -} bind def -/SetText1 { %def -% Set attributes of text -% STACK: fontname height orient mirror SetMkr - - /TAttr_Mirr exch def - /TAttr_Orient exch 10 div def - exch findfont exch scalefont setfont - RndAper -} bind def -/SetText2 { %def -% Set attributes of text -% STACK: linewidth height mirror orient SetMkr - - /TAttr_Width exch def - RndAper -} bind def -%%EndProcSet: SetAttr 1.0 0 -%%BeginProcSet: Initialize 1.0 0 -/Init { %def -% Initialize the driver -% STACK: Init - - 72 1000 div dup scale % Scale to 1/1000 inch - 250 250 translate % make origin 1/4 inch from bottom left - 1.5 setmiterlimit 1 RndAper % set line defaults - 0 setgray % set color default - /glev 0 def -} def -%%EndProcSet: Initialize 1.0 0 -%%EndProlog -/Helvetica findfont 12 scalefont setfont -35 760 moveto -(gadget.job - Fri Aug 21 03:35:07 1992) show -gsave -Init -8000 10500 Clipto -4015 2626 translate -0 rotate -1 1 div dup scale -75 sg -50 sg -25 sg -0 sg -10 SetLine --1350 4700 [ -1350 4900 ] PLine --1350 4900 [ -1150 4900 ] PLine -10 SetLine -1150 4900 [ 1350 4900 ] PLine -1350 4900 [ 1350 4700 ] PLine -10 SetLine -1150 0 [ 1350 0 ] PLine -1350 0 [ 1350 200 ] PLine -10 SetLine --1350 200 [ -1350 0 ] PLine --1350 0 [ -1150 0 ] PLine -10 SetLine --1050 1400 [ -1050 1200 ] PLine --1050 1200 [ -1150 1200 ] PLine --1150 1200 [ -1150 1400 ] PLine --1150 1400 [ -1050 1400 ] PLine -10 SetLine --50 3300 [ -100 3300 ] PLine -10 SetLine -250 3235 [ -50 3235 ] PLine --50 3235 [ -50 3365 ] PLine --50 3365 [ 250 3365 ] PLine -250 3365 [ 250 3235 ] PLine -10 SetLine -300 3300 [ 250 3300 ] PLine -10 SetLine -250 3100 [ 300 3100 ] PLine -10 SetLine --50 3165 [ 250 3165 ] PLine -250 3165 [ 250 3035 ] PLine -250 3035 [ -50 3035 ] PLine --50 3035 [ -50 3165 ] PLine -10 SetLine --100 3100 [ -50 3100 ] PLine -10 SetLine --50 3500 [ -100 3500 ] PLine -10 SetLine -250 3435 [ -50 3435 ] PLine --50 3435 [ -50 3565 ] PLine --50 3565 [ 250 3565 ] PLine -250 3565 [ 250 3435 ] PLine -10 SetLine -300 3500 [ 250 3500 ] PLine -10 SetLine --1150 3700 [ -1200 3700 ] PLine -10 SetLine --450 3575 [ -1150 3575 ] PLine --1150 3575 [ -1150 3825 ] PLine --1150 3825 [ -450 3825 ] PLine --450 3825 [ -450 3575 ] PLine -10 SetLine --400 3700 [ -450 3700 ] PLine -10 SetLine --850 1300 [ -900 1300 ] PLine -10 SetLine --150 1175 [ -850 1175 ] PLine --850 1175 [ -850 1425 ] PLine --850 1425 [ -150 1425 ] PLine --150 1425 [ -150 1175 ] PLine -10 SetLine --100 1300 [ -150 1300 ] PLine -10 SetLine -550 2800 [ 600 2800 ] PLine -10 SetLine --150 2925 [ 550 2925 ] PLine -550 2925 [ 550 2675 ] PLine -550 2675 [ -150 2675 ] PLine --150 2675 [ -150 2925 ] PLine -10 SetLine --200 2800 [ -150 2800 ] PLine -10 SetLine --450 2800 [ -400 2800 ] PLine -10 SetLine --1150 2925 [ -450 2925 ] PLine --450 2925 [ -450 2675 ] PLine --450 2675 [ -1150 2675 ] PLine --1150 2675 [ -1150 2925 ] PLine -10 SetLine --1200 2800 [ -1150 2800 ] PLine -10 SetLine -0 2150 [ 0 2100 ] PLine -10 SetLine -65 2450 [ 65 2150 ] PLine -65 2150 [ -65 2150 ] PLine --65 2150 [ -65 2450 ] PLine --65 2450 [ 65 2450 ] PLine -10 SetLine -0 2500 [ 0 2450 ] PLine -10 SetLine --1200 3050 [ -1200 3000 ] PLine -10 SetLine --1135 3350 [ -1135 3050 ] PLine --1135 3050 [ -1265 3050 ] PLine --1265 3050 [ -1265 3350 ] PLine --1265 3350 [ -1135 3350 ] PLine -10 SetLine --1200 3400 [ -1200 3350 ] PLine -10 SetLine --950 2250 [ -1150 2250 ] PLine --1150 2250 [ -1150 2350 ] PLine --1150 2350 [ -950 2350 ] PLine --950 2350 [ -950 2250 ] PLine -10 SetLine --1150 2550 [ -950 2550 ] PLine --950 2550 [ -950 2450 ] PLine --950 2450 [ -1150 2450 ] PLine --1150 2450 [ -1150 2550 ] PLine -10 SetLine -850 2850 [ 1050 2850 ] PLine -1050 2850 [ 1050 2750 ] PLine -1050 2750 [ 850 2750 ] PLine -850 2750 [ 850 2850 ] PLine -10 SetLine -500 1900 [ 450 1900 ] PLine -10 SetLine -1200 1775 [ 500 1775 ] PLine -500 1775 [ 500 2025 ] PLine -500 2025 [ 1200 2025 ] PLine -1200 2025 [ 1200 1775 ] PLine -10 SetLine -1250 1900 [ 1200 1900 ] PLine -10 SetLine --1150 900 [ -1200 900 ] PLine -10 SetLine --150 725 [ -1150 725 ] PLine --1150 725 [ -1150 1075 ] PLine --1150 1075 [ -150 1075 ] PLine --150 1075 [ -150 725 ] PLine -10 SetLine --100 900 [ -150 900 ] PLine -10 SetLine --1050 4000 [ -1100 4000 ] PLine -10 SetLine --750 3935 [ -1050 3935 ] PLine --1050 3935 [ -1050 4065 ] PLine --1050 4065 [ -750 4065 ] PLine --750 4065 [ -750 3935 ] PLine -10 SetLine --700 4000 [ -750 4000 ] PLine -10 SetLine -750 3000 [ 700 3000 ] PLine -10 SetLine -1050 2935 [ 750 2935 ] PLine -750 2935 [ 750 3065 ] PLine -750 3065 [ 1050 3065 ] PLine -1050 3065 [ 1050 2935 ] PLine -10 SetLine -1100 3000 [ 1050 3000 ] PLine -10 SetLine --250 3750 [ -50 3750 ] PLine --50 3750 [ -50 3650 ] PLine --50 3650 [ -250 3650 ] PLine --250 3650 [ -250 3750 ] PLine -10 SetLine -200 900 [ 150 900 ] PLine -10 SetLine -270 950 [ 270 850 ] PLine -10 SetLine -200 850 [ 200 950 ] PLine -200 950 [ 500 950 ] PLine -500 950 [ 500 850 ] PLine -500 850 [ 200 850 ] PLine -10 SetLine -500 900 [ 550 900 ] PLine -10 SetLine -250 850 [ 250 950 ] PLine -10 SetLine -260 850 [ 260 950 ] PLine -10 SetLine -600 3700 [ 650 3700 ] PLine -10 SetLine -530 3650 [ 530 3750 ] PLine -10 SetLine -600 3750 [ 600 3650 ] PLine -600 3650 [ 300 3650 ] PLine -300 3650 [ 300 3750 ] PLine -300 3750 [ 600 3750 ] PLine -10 SetLine -300 3700 [ 250 3700 ] PLine -10 SetLine -550 3750 [ 550 3650 ] PLine -10 SetLine -540 3750 [ 540 3650 ] PLine -10 SetLine --750 550 100 PCircle -10 SetLine -0 550 100 PCircle -10 SetLine -750 550 100 PCircle -10 SetLine -768 5000 [ 768 5248 ] PLine -768 5248 [ -768 5248 ] PLine --768 5248 [ -768 5000 ] PLine -10 SetLine -1058 4900 [ -1058 4900 ] PLine -10 SetLine -1058 5000 [ 1058 4408 ] PLine -1058 4408 [ -1058 4408 ] PLine --1058 4408 [ -1058 5000 ] PLine --1058 5000 [ 1058 5000 ] PLine -10 SetLine -1058 5000 [ -1058 5000 ] PLine -10 SetLine -768 4900 [ 768 4408 ] PLine -10 SetLine --768 4900 [ -768 4408 ] PLine -10 SetLine -900 200 [ 1100 200 ] PLine -1100 200 [ 1100 100 ] PLine -1100 100 [ 900 100 ] PLine -900 100 [ 900 200 ] PLine -10 SetLine --100 200 [ 100 200 ] PLine -100 200 [ 100 100 ] PLine -100 100 [ -100 100 ] PLine --100 100 [ -100 200 ] PLine -10 SetLine --1100 200 [ -900 200 ] PLine --900 200 [ -900 100 ] PLine --900 100 [ -1100 100 ] PLine --1100 100 [ -1100 200 ] PLine -10 SetLine -916 3493 [ 900 3456 ] PLine -900 3456 [ 939 3442 ] PLine -939 3442 [ 953 3477 ] PLine -10 SetLine -988 3612 140 PCircle -10 SetLine --1000 1529 [ -1039 1490 ] PLine -10 SetLine --1000 1490 [ -1000 1910 ] PLine --1000 1910 [ -1300 1910 ] PLine --1300 1910 [ -1300 1490 ] PLine --1300 1490 [ -1000 1490 ] PLine -10 SetLine -200 1730 [ 200 1670 ] PLine -200 1670 [ 0 1670 ] PLine -0 1670 [ 0 1730 ] PLine -0 1730 [ 200 1730 ] PLine -10 SetLine -200 1700 [ 260 1700 ] PLine -10 SetLine -0 1700 [ -50 1700 ] PLine -10 SetLine -300 1270 [ 300 1330 ] PLine -300 1330 [ 500 1330 ] PLine -500 1330 [ 500 1270 ] PLine -500 1270 [ 300 1270 ] PLine -10 SetLine -300 1300 [ 240 1300 ] PLine -10 SetLine -500 1300 [ 550 1300 ] PLine -10 SetLine --600 2270 [ -600 2330 ] PLine --600 2330 [ -400 2330 ] PLine --400 2330 [ -400 2270 ] PLine --400 2270 [ -600 2270 ] PLine -10 SetLine --600 2300 [ -660 2300 ] PLine -10 SetLine --400 2300 [ -350 2300 ] PLine -10 SetLine --800 4230 [ -800 4170 ] PLine --800 4170 [ -1000 4170 ] PLine --1000 4170 [ -1000 4230 ] PLine --1000 4230 [ -800 4230 ] PLine -10 SetLine --800 4200 [ -740 4200 ] PLine -10 SetLine --1000 4200 [ -1050 4200 ] PLine -10 SetLine -1000 3230 [ 1000 3170 ] PLine -1000 3170 [ 800 3170 ] PLine -800 3170 [ 800 3230 ] PLine -800 3230 [ 1000 3230 ] PLine -10 SetLine -1000 3200 [ 1060 3200 ] PLine -10 SetLine -800 3200 [ 750 3200 ] PLine -10 SetLine --600 2470 [ -600 2530 ] PLine --600 2530 [ -400 2530 ] PLine --400 2530 [ -400 2470 ] PLine --400 2470 [ -600 2470 ] PLine -10 SetLine --600 2500 [ -660 2500 ] PLine -10 SetLine --400 2500 [ -350 2500 ] PLine -10 SetLine --600 2070 [ -600 2130 ] PLine --600 2130 [ -400 2130 ] PLine --400 2130 [ -400 2070 ] PLine --400 2070 [ -600 2070 ] PLine -10 SetLine --600 2100 [ -660 2100 ] PLine -10 SetLine --400 2100 [ -350 2100 ] PLine -10 SetLine --900 2130 [ -900 2070 ] PLine --900 2070 [ -1100 2070 ] PLine --1100 2070 [ -1100 2130 ] PLine --1100 2130 [ -900 2130 ] PLine -10 SetLine --900 2100 [ -840 2100 ] PLine -10 SetLine --1100 2100 [ -1150 2100 ] PLine -10 SetLine -500 1130 [ 500 1070 ] PLine -500 1070 [ 300 1070 ] PLine -300 1070 [ 300 1130 ] PLine -300 1130 [ 500 1130 ] PLine -10 SetLine -500 1100 [ 560 1100 ] PLine -10 SetLine -300 1100 [ 250 1100 ] PLine -10 SetLine -1000 2521 [ 1039 2560 ] PLine -10 SetLine -1000 2560 [ 1000 2140 ] PLine -1000 2140 [ 1300 2140 ] PLine -1300 2140 [ 1300 2560 ] PLine -1300 2560 [ 1000 2560 ] PLine -10 SetLine -0 1870 [ 0 1930 ] PLine -0 1930 [ 200 1930 ] PLine -200 1930 [ 200 1870 ] PLine -200 1870 [ 0 1870 ] PLine -10 SetLine -0 1900 [ -60 1900 ] PLine -10 SetLine -200 1900 [ 250 1900 ] PLine -10 SetLine -100 1470 [ 100 1530 ] PLine -100 1530 [ 300 1530 ] PLine -300 1530 [ 300 1470 ] PLine -300 1470 [ 100 1470 ] PLine -10 SetLine -100 1500 [ 40 1500 ] PLine -10 SetLine -300 1500 [ 350 1500 ] PLine -10 SetLine --950 1650 [ -250 1650 ] PLine --250 1650 [ -250 1850 ] PLine --250 1850 [ -950 1850 ] PLine --950 1850 [ -950 1775 ] PLine --950 1775 [ -900 1775 ] PLine --900 1775 [ -900 1725 ] PLine --900 1725 [ -950 1725 ] PLine --950 1725 [ -950 1650 ] PLine -10 SetLine -150 2250 [ 950 2250 ] PLine -950 2250 [ 950 2450 ] PLine -950 2450 [ 150 2450 ] PLine -150 2450 [ 150 2375 ] PLine -150 2375 [ 200 2375 ] PLine -200 2375 [ 200 2325 ] PLine -200 2325 [ 150 2325 ] PLine -150 2325 [ 150 2250 ] PLine -10 SetLine -150 3950 [ 1150 3950 ] PLine -1150 3950 [ 1150 4150 ] PLine -1150 4150 [ 150 4150 ] PLine -150 4150 [ 150 4075 ] PLine -150 4075 [ 200 4075 ] PLine -200 4075 [ 200 4025 ] PLine -200 4025 [ 150 4025 ] PLine -150 4025 [ 150 3950 ] PLine -10 SetLine --1050 3150 [ -250 3150 ] PLine --250 3150 [ -250 3350 ] PLine --250 3350 [ -1050 3350 ] PLine --1050 3350 [ -1050 3275 ] PLine --1050 3275 [ -1000 3275 ] PLine --1000 3275 [ -1000 3225 ] PLine --1000 3225 [ -1050 3225 ] PLine --1050 3225 [ -1050 3150 ] PLine -10 SetLine -800 1075 [ 800 1675 ] PLine -800 1675 [ 1200 1675 ] PLine -1200 1675 [ 1200 1075 ] PLine -1200 1075 [ 800 1075 ] PLine -10 SetLine -875 1075 [ 875 825 ] PLine -875 825 [ 925 825 ] PLine -925 825 [ 925 1075 ] PLine -10 SetLine -1075 1075 [ 1075 825 ] PLine -1075 825 [ 1125 825 ] PLine -1125 825 [ 1125 1075 ] PLine -10 SetLine -975 1075 [ 975 825 ] PLine -975 825 [ 1025 825 ] PLine -1025 825 [ 1025 1075 ] PLine -10 SetLine -996 1549 75 PCircle -10 SetLine -800 1425 [ 1200 1425 ] PLine -10 SetLine --100 4200 [ -25 4200 ] PLine -10 SetLine --100 3900 [ -100 4300 ] PLine --100 4300 [ -500 4300 ] PLine --500 4300 [ -500 3900 ] PLine --500 3900 [ -100 3900 ] PLine -10 SetLine --100 4000 [ -25 4000 ] PLine -10 SetLine --1100 450 100 PCircle -10 SetLine -1100 450 100 PCircle -10 SetLine -1000 3430 [ 1000 3370 ] PLine -1000 3370 [ 800 3370 ] PLine -800 3370 [ 800 3430 ] PLine -800 3430 [ 1000 3430 ] PLine -10 SetLine -1000 3400 [ 1060 3400 ] PLine -10 SetLine -800 3400 [ 750 3400 ] PLine -10 SetText2 -0 -1175 1225 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1175 1279 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -1175 1310 [ [ -65 29 -65 6 -37 4 -40 6 -43 13 -43 20 -40 27 -34 31 -25 34 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 75 3375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3375 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 75 3175 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3175 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 75 3575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 129 3575 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -825 3850 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 3850 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -575 1450 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -521 1450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -490 1450 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 125 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 179 2950 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 210 2950 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -825 2950 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -771 2950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 -100 2250 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -100 2304 [ [ -53 0 -56 4 -65 11 0 11 ] ] Char -0 -100 2335 [ [ -65 4 -65 29 -40 15 -40 22 -37 27 -34 29 -25 31 -18 31 -9 29 -3 25 0 18 0 11 -3 4 -6 2 -12 0 ] ] Char -10 SetText2 -0 -1275 3200 [ [ -50 34 -56 31 -62 27 -65 22 -65 13 -62 9 -56 4 -50 2 -40 0 -25 0 -15 2 -9 4 -3 9 0 13 0 22 -3 27 -9 31 -15 34 ] ] Char -0 -1275 3254 [ [ -50 2 -53 2 -59 4 -62 6 -65 11 -65 20 -62 25 -59 27 -53 29 -46 29 -40 27 -31 22 0 0 0 31 ] ] Char -10 SetText2 -0 -1100 2375 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2375 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1100 2575 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -1046 2575 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -1015 2575 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 900 2875 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 954 2875 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 985 2875 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 800 2050 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 854 2050 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 885 2050 [ [ 31 65 9 0 ] [ 0 65 31 65 ] ] Char -10 SetText2 -0 -675 1100 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -621 1100 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 -590 1100 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -925 4075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -871 4075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 875 3075 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 929 3075 [ [ 11 65 4 62 2 56 2 50 4 43 9 40 18 37 25 34 29 28 31 21 31 12 29 6 27 3 20 0 11 0 4 3 2 6 0 12 0 21 2 28 6 34 13 37 22 40 27 43 29 50 29 56 27 62 20 65 11 65 ] ] Char -10 SetText2 -0 -200 3775 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 ] ] Char -0 -146 3775 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 325 975 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 377 975 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 450 3775 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 502 3775 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -775 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -732 675 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -50 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -7 675 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 700 675 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 743 675 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -1175 4650 [ [ 22 65 22 15 20 6 18 3 13 0 9 0 4 3 2 6 0 15 0 21 ] ] Char -0 -1132 4650 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 1172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 1222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 1274 125 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 125 125 [ [ 0 65 0 0 27 0 ] ] Char -0 172 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 222 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 274 125 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -875 125 [ [ 0 65 0 0 27 0 ] ] Char -0 -828 125 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -778 125 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -726 125 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1075 3425 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] [ 20 12 34 -6 ] ] Char -0 1131 3425 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1075 1475 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 -1127 1475 [ [ -11 -65 -4 -62 -2 -56 -2 -50 -4 -43 -9 -40 -18 -37 -25 -34 -29 -28 -31 -21 -31 -12 -29 -6 -27 -3 -20 0 -11 0 -4 -3 -2 -6 0 -12 0 -21 -2 -28 -6 -34 -13 -37 -22 -40 -27 -43 -29 -50 -29 -56 -27 -62 -20 -65 -11 -65 ] ] Char -10 SetText2 -0 25 1750 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 77 1750 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 108 1750 [ [ 13 65 6 62 2 53 0 37 0 28 2 12 6 3 13 0 18 0 25 3 29 12 31 28 31 37 29 53 25 62 18 65 13 65 ] ] Char -10 SetText2 -0 350 1350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1350 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1350 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2350 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2350 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -925 4250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -873 4250 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 850 3250 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 902 3250 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -550 2550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -550 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -498 2150 [ [ 27 56 25 62 18 65 13 65 6 62 2 53 0 37 0 21 2 9 6 3 13 0 15 0 22 3 27 9 29 18 29 21 27 31 22 37 15 40 13 40 6 37 2 31 0 21 ] ] Char -10 SetText2 -0 -1025 2150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 -973 2150 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 350 1150 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 402 1150 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 433 1150 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 1200 2125 [ [ 0 -65 0 0 ] [ 0 -65 -20 -65 -27 -62 -29 -59 -31 -53 -31 -46 -29 -40 -27 -37 -20 -34 0 -34 ] [ -15 -34 -31 0 ] ] Char -0 1148 2125 [ [ -31 -65 -9 0 ] [ 0 -65 -31 -65 ] ] Char -10 SetText2 -0 50 1950 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 102 1950 [ [ 29 43 27 34 22 28 15 25 13 25 6 28 2 34 0 43 0 46 2 56 6 62 13 65 15 65 22 62 27 56 29 43 29 28 27 12 22 3 15 0 11 0 4 3 2 9 ] ] Char -10 SetText2 -0 150 1550 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 202 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 233 1550 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -675 1950 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 1950 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 450 2550 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 502 2550 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 500 4275 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 552 4275 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -675 3450 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -623 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 950 1700 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 1002 1700 [ [ 29 65 6 65 4 37 6 40 13 43 20 43 27 40 31 34 34 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -350 4325 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -298 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1225 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 -1169 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 -1117 600 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1125 600 [ [ 0 65 0 0 ] [ 0 65 18 0 ] [ 36 65 18 0 ] [ 36 65 36 0 ] ] Char -0 1181 600 [ [ 0 65 0 0 ] [ 31 65 31 0 ] [ 0 34 31 34 ] ] Char -0 1233 600 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 800 3450 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 852 3450 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 883 3450 [ [ 22 65 0 21 34 21 ] [ 22 65 22 0 ] ] Char -10 SetText2 -0 -225 875 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 1125 1875 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -125 2775 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -1125 2775 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -525 3675 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -10 SetText2 -0 -700 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -750 275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 34 25 ] [ 22 25 34 25 ] ] Char -0 -696 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -640 275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -588 275 [ [ 34 50 31 56 27 62 22 65 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 34 25 ] [ 22 25 34 25 ] ] Char -0 -534 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 -484 275 [ [ 15 65 15 0 ] [ 0 65 31 65 ] ] Char -0 -380 275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 ] [ 0 34 20 34 27 31 29 28 31 21 31 12 29 6 27 3 20 0 0 0 ] ] Char -0 -328 275 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 -272 275 [ [ 0 65 31 0 ] [ 31 65 0 0 ] ] Char -0 -168 275 [ [ 0 28 40 28 ] ] Char -0 -55 275 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -3 275 [ [ 0 65 0 0 ] [ 0 65 31 0 ] [ 31 65 31 0 ] ] Char -0 49 275 [ [ 0 65 0 0 ] ] Char -0 69 275 [ [ 0 65 18 0 ] [ 36 65 18 0 ] ] Char -0 177 275 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -0 233 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] ] Char -0 335 275 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 387 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -0 437 275 [ [ 0 65 0 0 27 0 ] ] Char -0 484 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 540 275 [ [ 0 65 11 0 ] [ 22 65 11 0 ] [ 22 65 34 0 ] [ 45 65 34 0 ] ] Char -0 605 275 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 661 275 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 46 29 40 27 37 20 34 0 34 ] [ 15 34 31 0 ] ] Char -0 713 275 [ [ 0 65 0 0 ] [ 0 65 29 65 ] [ 0 34 18 34 ] [ 0 0 29 0 ] ] Char -10 SetText2 -0 125 600 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 177 600 [ [ 0 65 0 0 ] [ 0 65 20 65 27 62 29 59 31 53 31 43 29 37 27 34 20 31 0 31 ] ] Char -0 229 600 [ [ 31 56 27 62 20 65 11 65 4 62 0 56 0 50 2 43 4 40 9 37 22 31 27 28 29 25 31 18 31 9 27 3 20 0 11 0 4 3 0 9 ] ] Char -10 SetText2 -0 500 600 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -0 561 600 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 592 600 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 -625 600 [ [ 18 65 0 0 ] [ 18 65 36 0 ] [ 6 21 29 21 ] ] Char -0 -569 600 [ [ 0 65 0 18 2 9 6 3 13 0 18 0 25 3 29 9 31 18 31 65 ] ] Char -0 -517 600 [ [ 0 65 0 0 ] [ 0 65 15 65 22 62 27 56 29 50 31 40 31 25 29 15 27 9 22 3 15 0 0 0 ] ] Char -0 -465 600 [ [ 0 65 0 0 ] ] Char -0 -445 600 [ [ 13 65 9 62 4 56 2 50 0 40 0 25 2 15 4 9 9 3 13 0 22 0 27 3 31 9 34 15 36 25 36 40 34 50 31 56 27 62 22 65 13 65 ] ] Char -10 SetText2 -0 1100 2075 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1050 1925 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 875 675 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 1075 675 [ [ 2 50 2 53 4 59 6 62 11 65 20 65 25 62 27 59 29 53 29 46 27 40 22 31 0 0 31 0 ] ] Char -10 SetText2 -0 975 675 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -925 1475 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 175 3775 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 -1050 2975 [ [ 0 53 4 56 11 65 11 0 ] ] Char -10 SetText2 -0 625 4325 [ [ 0 53 4 56 11 65 11 0 ] ] Char -0 656 4325 [ [ 4 65 29 65 15 40 22 40 27 37 29 34 31 25 31 18 29 9 25 3 18 0 11 0 4 3 2 6 0 12 ] ] Char -10 SetText2 -0 -825 1275 [ [ 20 56 20 0 ] [ 0 28 40 28 ] ] Char -grestore -showpage diff --git a/usr.sbin/xntpd/hints/README b/usr.sbin/xntpd/hints/README deleted file mode 100644 index f7fdb72aaa6b..000000000000 --- a/usr.sbin/xntpd/hints/README +++ /dev/null @@ -1,12 +0,0 @@ -README file for directory ./hints of the NTP Version 3 distribution - -This directory contains files with hints for particular architectures. - -All files are derived from the earlier README. files. -I have tried to adjust these files to match the current state of -affairs of this xntp distribution. The information contained in the -files may or may not be completely correct. But these files contain -valuable hints for specific architectures. - -Frank Kardel 93/12/3 - diff --git a/usr.sbin/xntpd/hints/aux b/usr.sbin/xntpd/hints/aux deleted file mode 100644 index aa7ccbb2c420..000000000000 --- a/usr.sbin/xntpd/hints/aux +++ /dev/null @@ -1,159 +0,0 @@ -Last revision: 09-Aug-1993 - -Included in this distribution of XNTP V3 is a configuration file suitable -for use under Apple's A/UX Version 3.0.x While it may work with -other versions, it has not been tested. To make the executables follow -the steps outlined below. - -*** NOTE: You must have gcc installed to successfully compile the current -distribution; the native cc supplied with A/UX will NOT correctly compile -this source. See the FAQ in comp.unix.aux for places to obtain gcc from -and how to install it. - -Now, you need to create the makefiles: - - % make refconf - -First of all, you need to edit Config.local to make sure that BINDIR is -correct for where you wish the programs to be "installed". The default -(and what I use) is /usr/local/etc. Make sure that DEFS_LOCAL and -CLOCKDEFS are commented out! - - -After this is done (you should be told that your system is A/UX 3), make -xntpd (the options to 'gcc' are held in compilers/aux3.gcc): - - % make - -I do not normally use the `make install' option and so have not verified its -compatibility with A/UX. Rather, I pull out each of the executables and -place them in the locally appropriate locations. - -At this point you need to set things up so that 'xntpd' is started upon -boot-up. You can do this in 1 of 2 ways: either add entries in /etc/inittab -or create and use an /etc/rc.local file. - -By default, A/UX doesn't have one, so you'll need to add the following to -/etc/inittab: - - net6:2:wait:/etc/syslogd # set to "wait" to run a syslog daemon -+ jmj0:2:wait:/etc/rc.local 1>/dev/syscon 2>&1 # Local stuff - dbg2::wait:/etc/telinit v # turn off init's verbose mode - -Now, the look of /etc/rc.local is as follows: - - #!/bin/sh - : - : rc.local - : - # @(#)Copyright Apple Computer 1987 Version 1.17 of rc.sh on 91/11/08 15:56:21 (ATT 1.12) - - - # Push line discipline/set the device so it will print - /etc/line_sane 1 - echo " " - echo "Entering rc.local..." - - set `/bin/who -r` - if [ "$7" = 2 ] - then - /bin/echo " now setting the time..." - /usr/local/etc/ntpdate -s -b - sleep 5 - # - # start up xntpd if we want - # - if [ -f /etc/ntp.conf ] - then - /bin/echo " setting tick and tickadj..." - /usr/local/etc/tickadj -t 16672 -a 54 - sleep 5 - /bin/echo " starting xntpd..." - /usr/local/etc/xntpd <&- > /dev/null 2>&1 - sleep 5 - fi - # - fi - - echo "Leaving rc.local..." - -There are a few things to notice about the above: - - o When run, 'ntpdate' forces your clock to the time returned by the - host(s) specified by (you'll need to replace this - be the IP address(es) of your timehosts. This is good since it gets - things close to start off with. - - o 'tickadj' is also called. This does two things: changes the - default value of 'tick' (which the the amount of time, in ms, that - is added to the clock every 1/60 seconds) and changes the value - of 'tickadj' which the the amount that is added or subtracted - from 'tickadj' when adjtime() is called. - - Now Mac clocks are pretty bad and tend to be slow. Sooo, instead of - having A/UX add the default of 16666ms every 1/60th of a second, - you want it to add more so that it keeps better time. The above - value works for me but your "best" value may be different and will - likely require some fooling around to find the best value. - - A/UX's default value of 'tickadj' is 1666 which is too big for - 'xntpd'... so it also needs to be adjusted. - - -Finally, before A/UX and 'xntpd' will work happily together, you need to -patch the kernel. This is due to the fact that A/UX attempts to keep the -UNIX-software clock and the Mac-hardware clock in sync. Now both of these -are too good. Also, 'xntpd' will be attempting to adjust the software -clock as well, so having A/UX muck around with it is asking for headaches. -What you therefore need to do is tell the kernel _not_ to sync the s/w clock -with the h/w one. This is done using 'adb'. The following is a shell script -that will do the patch for you: - - #! /bin/sh - adb -w /unix < cd machines - -> vi hpux - -> (change -DSYS_HPUX=? to match whatever you are running [7,8,9]) - -> cd .. - - * Say "make makeconfig" - - * Say "make", sit back for a few minutes. - - * cd authstuff - * Say "./authcert < certdata" and check the output. Every line should - end with "OK" ... if not, we got trouble. - * Now try "./authspeed auth.samplekeys". What we want to - remember here is the "authentication delay in CPU time" - * cd .. - - * Say "make install" - - * I'd suggest reading the xntp docs about now :-) ... seriously !! - - * One thing I have added to this version of xntpd is a way to select - config files if you are sharing /usr/local thru NFS or whatever. - If the file /usr/local/etc/xntp.conf happens to be a directory, the - files in that directory are searched until a match is found. The - rules for a match are: - - 1. Our hostname - 2. default. (as in default.375 or default.850) - 3. default - - * Ok, make sure adjtimed is running (just start it up for now with - "/usr/local/etc/adjtimed"). Using -z as an option will get you - a usage message. - - * Now start up xntpd and watch it work. - - * Make sure that adjtimed gets started at boot right before xntpd. - We do this in /etc/netbsdsrc. They must both run as root !! - -Possible problems ? - - * On some 320's and 835's we have had to run adjtimed with "-p 45" or - so to get rid of syslog messages about "last adjust did not finish". - - * At 9.0, there is a problem with DIAGMON (patch available from the - response center) which causes it to delete the message queue that - adjtimed/xntpd use to communicate. (see next note for result) - - * Xntpd has been known to get really ticked off when adjtime() fails - which is usually only while running the emulation code on HP-UX. - When it gets mad, it usually jumps the clock into never never land. - Possible reasons for this are adjtimed being killed or just never - started or adjtimed being completely swapped out on a really busy - machine (newer adjtimed try to lock themselves in memory to prevent - this one). - -Anything else ... just drop me a line at ken@sdd.hp.com diff --git a/usr.sbin/xntpd/hints/linux b/usr.sbin/xntpd/hints/linux deleted file mode 100644 index 0efc12bb75fc..000000000000 --- a/usr.sbin/xntpd/hints/linux +++ /dev/null @@ -1,9 +0,0 @@ - -Requirements: kernel 0.99.14y or newer, libc 4.5.21 or newer ------------- - - With this configuration, xntp should build an run right out of the box -(see generic hints for how-to). If you really need to run xntp on any earlier -versions of the kernel or libc, or have any other question not covered in the -READMEs / hint files (sorry, necessary comment in the Linux community ;-) feel -free to ask me (duwe@informatik.uni-erlangen.de) diff --git a/usr.sbin/xntpd/hints/notes-xntp-v3 b/usr.sbin/xntpd/hints/notes-xntp-v3 deleted file mode 100644 index ba027f2105fe..000000000000 --- a/usr.sbin/xntpd/hints/notes-xntp-v3 +++ /dev/null @@ -1,119 +0,0 @@ -Notes for NTP Version 3 - -This version operates in much the same manner as Version 2 with the -following changes and additions: - -1. The protocol machinery operates in conformance with the RFC1305 NTP - Version 3 specification. The most visible characteristic of this - version is that the poll intervals for all polls, even selected - ones, is significantly increased. This is especially desirable when - serving a large client population. This implementation supports - previous versions as non-configured peers; for version-2 configured - peers a "version 2" keyword should be included on the "peer" line. - -2. The configuration file has a new keyword: statfile , where - is the name of a statistics file." When present, each clock - update generates an entry of the form: - - . - - where is the modified Julian day, . is the time of - day, is the peer address and is the peer status. - The , and are the measured offset, delay and - dispersion, respectively, of the peer clock relative to the local - clock. About once per day the current file is closed and a new one - created with names ., where starts at one and - increments for each new generation. - -3. A number of additional platforms are supported. See ./Config file - for details. - -4. A driver for the TrueTime 468DC GOES Synchronized Clock is - included. This driver (refclock_goes.c) should also work for other - TrueTime radio clocks, since all use the same format. - -5. A replacement driver for the Spectracom 8170 WWVB Synchronized - Clock is included. This driver (refclock_wwvb.c) (a) does not - require a 1-pulse-per-second signal, (b) supports both format 0 - (original 8170) and format 2 (Netclock/2 and upgraded 8170), (c) - can be connected to more than one computer and (d) automatically - compensates for all serial baud rates. - -6. A driver for the German time/frequency station DCF77 is included. - This requires a special STREAMS module. - -7. In Version 2 special line-discipline modules were required for the - CHU and WWVB drivers. This code continues to work in Version 3, - although it is no longer needed for the WWVB driver. However, this - code does not work under STREAMS, as used in SunOS 4.1.1. - Equivalent STREAMS modules are supplied with Version 3. - -8. Support for an external 1-pulse-per-second (pps) signal is - provided. The signal is connected to a serial port (see - xntpd/ntp_loopfilter.c for details). When present the leading edge - of the pulse establishes the on-time epoch within an interval - established by the selected radio clock or other NTP time server. - Use of the pps is indicated when the tattletale displayed by ntpq - changes from "*" to "o". - -9. The clock-selection and poll-update procedures have been modified - slightly in order to achieve better performance on high speed LANs - with compromise in performance on typical WANs. - -10. In order to comply with U.S. Commerce Department regulations, the DES - encryption routine lib/authdes.c cannot be exported. For exportable - versions of this distribution a DES-encrypted version of this routine - lib/authdes.c.des is included along with an unencrypted version - lib/authdes.c.export, which allows normal operation, but without the - NTP authentication feature. Further information is available in the - lib/authdes.c.export file. - -11. As an alternative to the DES-based authentication mechanism, an - implementation of the RSA Message Digest 5 algorithm is provided. - (see applicable copyright information in the library files). - -12. A driver for the Magnavox MX4200 GPS clock. - -13. A STREAMS module which captures carrier-detect data-lead transitions to - connect a precision source of 1-pps, yet avoid the ugly overhead in the - usual STREAMS processing. See the ppsclock subdirectory. - -14. Support for the Apple A/UX operating system and enhanced support for the - Hewlet-Packard HP/UX operating system. See the various README and Config - files for further information. - -See the COPYRIGHT file for authors and copyright information. Note that some -modules in this distribution contain copyright information that supersedes -the copyright information in that file. - -If I missed something or neglected to give due credit, please advise. - -David L. Mills -University of Delaware -31 May 1992, amended 23 July 1992, 25 October 1992 - -Bugs and notes - -A bug in the original tty_clk_STREAMS.c module has been fixed. - -The poll-interval randomization feature of poll_update (in -xntpd/ntp_proto.c) has been extended to apply when the poll interval is -increased, as well as reduced. This spreads the update messages in time -and helps avoid unpleasant bursts of messages. - -In the clock_select algorithm the peers selected for combining are -limited to those survivors at the lowest stratum, not the entire list. -This helps avoid whiplash when large numbers of peers are at the same -stratum. - -The number formerly displayed by ntpq as "compliance" is now the time -constant of integration. - -The DNS resolver xntpd/ntp_intres.c is now integrated into xntpd, making -configuration of multiple hosts easier. - -System and peer event are now written to the system log at priority -LOG_INFO. - -The leap-second code was fixed to avoid broadcasting leap warnings on -all except the last day of June and December. diff --git a/usr.sbin/xntpd/hints/parse b/usr.sbin/xntpd/hints/parse deleted file mode 100644 index d2523515e839..000000000000 --- a/usr.sbin/xntpd/hints/parse +++ /dev/null @@ -1,105 +0,0 @@ -Compilation: - Usual thing: rm -f Config.local ; make for vanilla - make refconf for reference clock (e. g. DCF77) - -Directory contents: - - hints/PARSE - this file - - xntpd/refclock_parse.c - - reference clock support for DCF77/GPS in xntp - parse/parse.c - - Reference clock data parser framework - parse/parse_conf.c - - parser configuration (clock types) - parse/clk_meinberg.c - - Meinberg clock formats (DCF U/A 31, PZF 535, GPS166) - parse/clk_schmid.c - - Schmid receiver (DCF77) - parse/clk_rawdcf.c - - 100/200ms pulses via 50 Baud line (DCF77) - parse/clk_dcf7000.c - - ELV DCF7000 (DCF77) - parse/clk_trimble.c - - Trimble SV6 GPS receiver - - If you want to add new clock types please check - with kardel@informatik.uni-erlangen.de. These files - implement the conversion of RS232 data streams into - timing information used by refclock_parse.c which is - mostly generic except for NTP configuration constants. - - parse/Makefile.kernel - - *SIMPLE* makefile to build a loadable STREAMS - module for SunOS 4.x / SunOS 5.x systems - - parse/parsestreams.c - - SUN Streams module (loadable) for radio clocks - This streams module is designed for SunOS 4.1.X. - - parse/parsesolaris.c - - SUN Streams module (loadable) for radio clocks. - This streams module is designed for SunOS 5.x - Beware this is still new - so it might crash - your machine (we have seen it working, though). - - parse/parsetest.c - - simple test program for STREAMS module. Its so simple, - that it doesn't even set TTY-modes, thus they got to - be correct on startup - works for Meinberg receivers - - parse/testdcf.c - - test program for raw DCF77 (100/200ms pulses) - receivers - - include/parse.h - interface to "parse" module and more - include/parse_conf.h - - interface to "parse" configuration - - include/sys/parsestreams.h - - STREAMS specific definitions - - scripts/support - - scripts (perl & sh) for statistics and rc startup - the startup scripts are used in Erlangen for - starting the daemon on a variety of Suns and HPs - and for Reference Clock startup on Suns - These scripts may or may not be helpful to you. - -Supported clocks: - Meinberg DCF U/A 31 - Meinberg PZF535/TCXO (Software revision PZFUERL 4.6) - Meinberg PZF535/OCXO (Software revision PZFUERL 4.6) - Meinberg GPS166 (Software version for Uni-Erlangen) - ELV DCF7000 (not recommended - casual/emergency use only) - Conrad DCF77 receiver (email: time@informatik.uni-erlangen.de) - + level converter - TimeBrick (email: time@informatik.uni-erlangen.de) - Schmid Receiver Kit - Trimble SV6 GPS receiver - -Addresses: - Meinberg Funkuhren - Auf der Landwehr 22 - 31812 Bad Pyrmont - Germany - Tel.: 05281/20 18 - FAX: 05281/60 81 80 - - ELV Kundenservice - Postfach 1000 - 26787 Leer - Germany - Tel.: 0491/60 08 88 - - Walter Schmidt - Eichwisrain 14 - 8634 Hombrechtikon - Switzerland - -If you have problems mail to: - - time@informatik.uni-erlangen.de - -We'll help (conditions permitting) - diff --git a/usr.sbin/xntpd/hints/refclocks b/usr.sbin/xntpd/hints/refclocks deleted file mode 100644 index 34b2ea934446..000000000000 --- a/usr.sbin/xntpd/hints/refclocks +++ /dev/null @@ -1,32 +0,0 @@ -This is a short overview for the reference clocks currently supported -by xntp V3. (Ultimate wisdom can be obtained from xntpd/refclock_*.c -this file was derived from that information - unfortunately some comments -in the files tend to get stale - so use with caution) - -Refclock address Type -127.127.0.x no clock (fails to configure) -127.127.1.x local clock - use local clock as reference -127.127.2.x no clock (fails to configure) -127.127.3.x PSTI 1010/1020 WWV Clock -127.127.4.x SPECTRACOM WWVB receiver 8170 and Netclock/2 -127.127.5.x Kinimetric Truetime 468-DC GOES receiver -127.127.6.x IRIG audio decode (Sun & modified BSD audio driver) -127.127.7.x CHU Timecode (via normal receiver & Bell 103 modem) -127.127.8.x PARSE (generic driver for a bunch of DCF/GPS clocks - can be extended for other clocks too) - 8.0-3 Meinberg PZF535/TCXO - 8.4-7 Meinberg PZF535/OCXO - 8.8-11 Meinberg DCF U/A 31 - 8.12-15 ELV DCF7000 - 8.16-19 Walter Schmid DCF receiver (Kit) - 8.20-23 Conrad DCF77 receiver module + level converter (Kit) - 8.24-27 TimeBrick (limited availability ask - time@informatik.uni-erlangen.de) - 8.28-31 Meinberg GPS166 - 8.32-35 Trimble SV6 GPS receiver -127.127.9.x MX4200 GPS receiver -127.127.10.x Austron 2201A GPS Timing Receiver -127.127.11.x Kinemetrics Truetime OM-DC OMEGA Receiver -127.127.12.x KSI/Odetecs TPRO-S IRIG-B / TPRO-SAT GPS -127.127.13.x Leitch: CSD 5300 Master Clock System Driver -127.127.14.x MSFEES diff --git a/usr.sbin/xntpd/hints/rs6000 b/usr.sbin/xntpd/hints/rs6000 deleted file mode 100644 index 8561ac29b1b0..000000000000 --- a/usr.sbin/xntpd/hints/rs6000 +++ /dev/null @@ -1,56 +0,0 @@ -15.7.1993 -xntp3 compiles now again on AIX. I have disabled prototyping and added -the switch -D_NO_PROTO which disables prototyping in the system include -files. - -Matthias Ernst maer@nmr.lpc.ethz.ch --------------------------------------------------------------------------------- -Xntp version 3 now support the cc compiler for AIX. -The Config.aix will now use cc by default. You can still compile xntp -with the bsd compiler by changing "COMP= cc" to "COMP= bsdcc" and -and removing the "-DSTUPID_SIGNAL" option from the "DEFS" option. - -xntp and tickadj was also modified so that the value of tickadj is read -form the kernel and can be set by tickadj. For now I would not set -tickadj below 40 us. - -Bill Jones -jones@chpc.utexas.edu -------------------------------------------------------------------------------- - -This is a modified version of xntp version 3 for the RS6000. It works for -AIX 3.2 and these are the same changes as have been applied tothe version 2 -implementation of xntp. It works fine for us but I have not tested all of -the features, especially the local clock support for the RS6000 is not tested -at all. - -Matthias Ernst, ETH-Zuerich, Switzerland - maer@nmr.lpc.ethz.ch - --------------------------------------------------------------------------------- - -Here the original README.rs6000 for the version 2 implementation: - -A hacked version of xntp for the IBM RS/6000 under AIX 3.1 can be found -in xntp.rs6000.tar.Z. [ if still available at all - Frank Kardel 93/12/3 ] - -This will not work on older versions of AIX due to a kernel bug; to find -out whether you have the kernel bug, compile and run testrs6000.c (see -comments in the code for instructions). - -xntp and testrs6000 require "bsdcc" to compile. This is simply another -entry point into the xlc compiler with various options set for BSD -compatibility. If your system does not have bsdcc, do the following: - -link /bin/bsdcc to /bin/xlc - -put the following into /etc/xlc.cfg: - -* BSD compatibility -bsdcc: use = DEFLT - crt = /lib/crt0.o - mcrt = /lib/mcrt0.o - gcrt = /lib/gcrt0.o - libraries = -lbsd, -lc - proflibs = -L/lib/profiled,-L/usr/lib/profiled - options = -H512,-T512, -qlanglvl=extended, -qnoro, -D_BSD, -D_NONSTD_TYPES, -D_NO_PROTO, -tp,-B/lib/ - diff --git a/usr.sbin/xntpd/hints/sgi b/usr.sbin/xntpd/hints/sgi deleted file mode 100644 index 5e4f7de6d597..000000000000 --- a/usr.sbin/xntpd/hints/sgi +++ /dev/null @@ -1,74 +0,0 @@ -adjtime, tick and tickadj: --------------------------- - -The SGI value for HZ is 100 under Irix 4, with the system clock running -in nominal mode (ftimer off), so the value for tick is 10000 usec. -Tickadj is a bit more tricky because of the behaviour of adjtime(), -which seems to try to perform the correction over 100-200 seconds, with -a rate limit of 0.04 secs/sec for large corrections. Corrections of -less than 0.017 seconds generally complete in less than a second, -however. - -Some measured rates are as follows: - - Delta Rate (sec/sec) - - > 1 0.04 - 0.75 0.04 - 0.6 0.004 - 0.5 0.004 - 0.4 0.0026 - 0.3 0.0026 - 0.2 0.0013 - 0.1 0.0015 - 0.05 0.0015 - 0.02 0.0003 - 0.01 0.015 -Strange. Anyway, since adjtime will complete adjustments of less than -17msec in less than a second, whether the fast clock is on or off, I -have used a value of 150usec/tick for the tickadj value. - -Fast clock: ------------ - -I get smoother timekeeping if I turn on the fast clock, thereby making -the clock tick at 1kHz rather than 100Hz. With the fast clock off, I -see a sawtooth clock offset with an amplitude of 5msec. With it on, -the amplitude drops to 0.5msec (surprise!). This may be a consequence -of having a local reference clock which spits out the time at exactly -one-second intervals - I am probably seeing sampling aliasing between -that and the machine clock. This may all be irrelevant for machines -without a local reference clock. Fiddling with the fast clock doesn't -seem to compromise the above choices for tick and tickadj. - -I use the "ftimer" program to switch the fast clock on when the system -goes into multiuser mode, but you can set the "fastclock" flag in -/usr/sysgen/master.d/kernel to have it on by default. See ftimer(1). - -timetrim: ---------- - -Irix has a kernel variable called timetrim which adjusts the system -time increment, effectively trimming the clock frequency. Xntpd could -use this rather than adjtime() to do it's frequency trimming, but I -haven't the time to explore this. There is a utility program, -"timetrim", in the util directory which allows manipulation of the -timetrim value in both SGI and xntpd native units. You can fiddle with -default timetrim value in /usr/sysgen/master.d/kernel, but I think -that's ugly. I just use xntpd to figure out the right value for -timetrim for a particular CPU and then set it using "timetrim" when -going to multiuser mode. - -Serial I/O latency: -------------------- - -If you use a local clock on an RS-232 line, look into the kernel -configuration stuff with regard to improving the input latency (check -out /usr/sysgen/master.d/[sduart|cdsio]). I have a Kinemetrics OM-DC -hooked onto /dev/ttyd2 (the second CPU board RS-232 port) on an SGI -Crimson, and setting the duart_rsrv_duration flag to 0 improves things -a bit. - - -12 Jan 93 -Steve Clift, CSIRO Marine Labs, Hobart, Australia (clift@ml.csiro.au) diff --git a/usr.sbin/xntpd/hints/solaris b/usr.sbin/xntpd/hints/solaris deleted file mode 100644 index 1d0e47fc473e..000000000000 --- a/usr.sbin/xntpd/hints/solaris +++ /dev/null @@ -1,87 +0,0 @@ - A quick summary of how to compile under Solaris: - - If you are running Solaris 2.0, you should upgrade to a later version of -Solaris immediately. - If you are running Solaris 2.1 or later, all should be fine (i hope) - - Solaris 2.1 contains fairly traditional clock code, with tick and tickadj. -Solaris 2.2 and later contains completely re-written clock code to provide -high resolution microsecond timers. A benefit of the re-written clock code -is that adjtime does not round off its adjustments, so xntp does not have to -compensate for this rounding. On Solaris 2.2 and later we #define -ADJTIME_IS_ACCURATE, and do not look for the tickadj kernel variable. - - If you are running both Solaris 2.1 and 2.2 on your net, you will need to -maintain two sets of xntp binaries. The Config.solaris2.2 file will compile -on Solaris 2.1, but the resulting binaries will not work correctly. - -ADDITIONAL NOTES FOR SOLARIS 2.1 -(by William L. Jones jones@chpc.utexas.edu) - -Since settimeofday under Solaris 2.1 only sets the seconds part of timeval -care must be used in starting xntpd. I suggest the following start -up script: - - tickadj -s -a 1000 - ntpdate -v server1 server2 - sleep 20 - ntpdate -v server1 server2 - sleep 20 - tickadj -a 200 - xntpd - -The first tickadj turns of the time of day clock and sets the tick adjust -value to 1 ms. This will insure that an adjtime value of at most 2 -seconds will complete in 20 seconds. - -The first ntpdate will set the time to within two seconds -using settimeofday or it will adjust time using adjtime. - -The first sleep insures the adjtime has completed for the first ntpdate. - -The second ntpdate will use adjtime to set the time of day since the -clock should be within 2 seconds of the correct time. - -The second tickadj set the tick adjust system value to 5 us. - -The second sleeps insure that adjtime will complete before starting -the next xntpd. - -I tried running with a tickadj of 5 us with out much success. -200 us seems to work well. - - -ADDITIONAL NOTES FOR SOLARIS 2.2 AND LATER: - You still need to turn off dosynctodr for XNTP to be able to keep accurate -time. You can either do this in the /etc/system file (consulted at boot to set -various kernel variables) by putting in the following line: -set dosynctodr=0 -or you can use the tickadj program to force the variable to 0 in the running -kernel. Fiddling with a running kernel is almost never a good idea, I'd -recommend using /etc/system. - I would recommend starting xntp from the following script, placed in -/etc/rc2.d and named S99xntpd - -#!/bin/sh - -if [ $1 = "start" ]; then - if [ -x /usr/local/bin/xntpd ]; then - echo "Starting NTP daemon, takes about 1 minute... " - # The following line is unnecessary if you turn off - # dosynctodr in /etc/system. - /usr/local/bin/tickadj -s - /usr/local/bin/ntpdate -v server1 server2 - sleep 5 - /usr/local/bin/xntpd - fi -else - if [ $1 = "stop" ]; then - pid=`/usr/bin/ps -e | /usr/bin/grep xntpd | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` - if [ "${pid}" != "" ]; then - echo "Stopping Network Time Protocol daemon " - /usr/bin/kill ${pid} - fi - fi -fi - -Denny Gentry denny@eng.sun.com diff --git a/usr.sbin/xntpd/hints/sun4 b/usr.sbin/xntpd/hints/sun4 deleted file mode 100644 index 6dc36ea5429d..000000000000 --- a/usr.sbin/xntpd/hints/sun4 +++ /dev/null @@ -1,17 +0,0 @@ -Notes on CPU clock oscillator tolerance with SunOS 4.1.1 and 4.1.3 - -A bug in SunOS 4.1.1 results in the kernel time losing 1 microsecond -per tick of the system clock. The bug was fixed (bugid 1094383) for -SunOS 4.1.1 and corrected in SunOS 4.1.3. The easiest way to fix this -is to replace the 4.1.1 binary clock.o with the corresponding 4.1.3 -binary. Without this change it is necessary to use the tickadj program -included in this distribution with the -t 9999 option. - -The tickadj option will work in all cases except when the kernel has -been modified to correct the CPU clock oscillator frequency using a -1-pps signal from a precision source. The bugfix must be installed for -this wrinkle to work properly. - -Dave Mills (mills@udle.edu) - - diff --git a/usr.sbin/xntpd/hints/svr4-dell b/usr.sbin/xntpd/hints/svr4-dell deleted file mode 100644 index b6d015752dd7..000000000000 --- a/usr.sbin/xntpd/hints/svr4-dell +++ /dev/null @@ -1,6 +0,0 @@ -Notes on the DELL SVR4. - -You should use -DSETTIMEOFDAY_BROKEN. - -Philip.Gladstone@mail.citicorp.com - diff --git a/usr.sbin/xntpd/kernel/Makefile.tmpl b/usr.sbin/xntpd/kernel/Makefile.tmpl deleted file mode 100644 index 8b40f4a92e05..000000000000 --- a/usr.sbin/xntpd/kernel/Makefile.tmpl +++ /dev/null @@ -1,59 +0,0 @@ -# -# /src/NTP/REPOSITORY/v3/kernel/Makefile.tmpl,v 3.6 1994/01/25 19:04:35 kardel Exp -# -# parse routine that could be used in two places -# -COMPILER= cc -COPTS= -O -AUTHDEFS=-DDES -LIBDEFS= -DBIG_ENDIAN -RANLIB= ranlib -INSTALL= install -CLOCKDEFS= -DEFS= -DEFS_OPT= -DEFS_LOCAL= -CLK_VDOBJS=clkinit.o tty_clk_STREAMS.o -CHU_VDOBJS=chuinit.o tty_chu_STREAMS.o -INCL=-I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -DKERNEL -CC= $(COMPILER) -# - -all: - @echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \ - awk '/-DREFCLOCK/ && ( /-D.*CLK/ || /-D.*PPS/ ) { makeit=1; }\ - END { if (makeit) \ - { print ""; \ - print "### STREAMS kernel modules ppsclock, ppsclocd or line disciplines must"; \ - print "### be installed manually if needed"; \ - print "### see kernel/README* for details"; \ - print "### The parse refclock implementation has their own support in"; \ - print "### parse/*."; } }' - -loadable: clk.o chu.o - -clk.o: ${CLK_VDOBJS} - ld -r ${OBJS} -o clk.o - -clk.h: - echo "#define NCLK 2" > clk.h - -tty_clk_STREAMS.o: clk.h tty_clk_STREAMS.c - cc ${CFLAGS} tty_clk_STREAMS.c -c tty_clk_STREAMS.o - -chu.o: ${CHU_VDOBJS} - ld -r ${OBJS} -o chu.o - -chu.h: - echo "#define NCHU 2" > chu.h - -tty_chu_STREAMS.o: chu.h tty_chu_STREAMS.c - cc ${CFLAGS} tty_chu_STREAMS.c -c tty_chu_STREAMS.o - -clean: - -@rm -f *~ *.o *.out *.ln make.log Makefile.bak \ - lintlib.errs lint.errs - -distclean: clean - -@rm -f *.orig *.rej .version Makefile diff --git a/usr.sbin/xntpd/kernel/README b/usr.sbin/xntpd/kernel/README deleted file mode 100644 index cf69b137286b..000000000000 --- a/usr.sbin/xntpd/kernel/README +++ /dev/null @@ -1,90 +0,0 @@ -This directory contains code for two line disciplines which may -work with BSD-style terminal drivers. While I'll try to cover -installation details for the more useful one here as best I can, -you really should know what you are doing before attempting to -put one of these in your kernel since the details seem to vary -from BSD variant to BSD variant. - -Tty_clk.c contains a generic clock support line discipline. -The terminal driver is actually run in raw mode, giving you an -eight bit data path. Instead of delivering the data -character-by-character, however, the line discipline collects -characters until one of two magic characters (your current erase -and kill characters. Don't throw up) is received. A timestamp -is then taken (by calling microtime()), inserted in the input -buffer after the magic character, and the whole mess made available -for input by the application. Both select() and SIGIO are supported -by the discipline. - -Tty_chu.c is a special purpose line discipline for receiving -the CHU time code. It understands enough about the format of the -code CHU transmits to filter out errors, and delivers an entire -ten character code group to the application all at once, including -a timestamp for each character. The structure the code group is -delivered in is defined in chudefs.h. Note that this line discipline -is old and could use some rewriting for better portability. Please -drop me a line if you are interested in using this. - -To install the clock line discipline, do something like the following: - -(1) Copy tty_clk.c into /sys/sys - -(2) Edit /sys/sys/tty_conf.c. You will want to include some facsimile - of the following lines: - -#include "clk.h" -#if NCLK > 0 -int clkopen(), clkclose(), clkwrite(), clkinput(), clkioctl(); -#endif - -#if NCLK > 0 - { clkopen, clkclose, ttread, clkwrite, clkioctl, - clkinput, nodev, nulldev, ttstart, nullmodem, /* 10- CLKLDISC */ - ttselect }, -#else - { nodev, nodev, nodev, nodev, nodev, - nodev, nodev, nodev, nodev, nodev, - nodev }, -#endif - - In Ultrix 4.2a and 4.3 the file to edit is /sys/data/tty_conf_data.c. - The lines should be - -#if NCLK > 0 - clkopen, clkclose, ttread, clkwrite, clkioctl, /* 10 */ - clkinput, nodev, nulldev, ttstart, nulldev, -#else - nodev, nodev, nodev, nodev, nodev, - nodev, nodev, nodev, nodev, nodev, -#endif - - Note that if your kernel doesn't include the ??select() entry in - the structure (i.e. there are only 10 entry points in the structure) - just leave it out. Also note that the number you give the line - discipline (10 in my kernel) will be specific to your kernel and - will depend on what is in there already. The entries sould be in - order with no missing space; that is, if there are only seven - disciplines already defined and you want to use 10 for good reason, - you should define a dummy 9th entry like this - - nodev, nodev, nodev, nodev, nodev, /* 9 */ - nodev, nodev, nodev, nodev, nodev, - -(3) Edit /sys/h/ioctl.h and include a line (somewhere near where other - line disciplines are defined) like: - -#define CLKLDISC 10 /* clock line discipline */ - - The `10' should match what you used in /sys/sys/tty_conf.c. - -(4) Edit /sys/conf/files and add a line which looks like: - -sys/tty_clk.c optional clk - -(5) Edit the configuration file for the machine you want to use - the clock line discipline on to include the following: - -pseudo-device clk 4 - -(6) Run config, then make clean, then make depend, then make vmunix. - Then reboot the new kernel. diff --git a/usr.sbin/xntpd/kernel/README.streams b/usr.sbin/xntpd/kernel/README.streams deleted file mode 100644 index 26c2825b50df..000000000000 --- a/usr.sbin/xntpd/kernel/README.streams +++ /dev/null @@ -1,86 +0,0 @@ -Some kernels don't support additional user defined line disciplines. -Especially notable in this regard is SunOS and System V. They -provide similar support in the form of "Streams". Accordingly, -included in this directory is a pair of STREAMS modules to -replace the line disciplines that provide clock support for -xntpd. Notice that the "clkdefs.h" file is not used in the -original line discipline, but the "chudefs.h" file is the -same one used in the original line discipline. - -TO INSTALL A NEW STREAMS DRIVER: - -1. Copy your choice to /sys/os, removing the "_STREAMS" in the -filename. - -2. Copy the appropriate *defs.h file to /usr/include/sys, -then link it (with ln) to /sys/sys. - -In the following steps, substitute "clk" for "chu" if you're -installing the clk driver. - -3. Append to /sys/conf.common/files.cmn: - -os/tty_chu.c optional chu - -4. Edit /sys/sun/str_conf.c. You'll want to add lines in three -places. It'll be sort of clear where when you see the file. - -. -. -. -#include "chu.h" -. -. -. -#if NCHU > 0 -extern struct streamtab chuinfo; -#endif -. -. -. -#if NCHU > 0 - { "chu", &chuinfo }, -#endif -. -. -. - -At this point, the kernel-making "config [k-name] ; cd ../[k-name] ; make" -should produce a kernel just as it did before. If it fouls up, -something's wrong. - -5. Edit /sys/[arch]/conf/[k-name] (substituting the architecture and -kernel name) to stick in: - -pseudo-device chu4 # CHU clock support - -You can change 4 to anything you like. It will limit the number -of instantiations of the chu driver you can use at the same time. - -6. Make a new kernel and boot it. - -HOW TO USE THE CHU STREAMS DRIVER: - -The driver should act exactly like the line discipline. -After setting the raw mode, and exclusive access (if you want), -pop off all the extra streams, then push the chu module -on. From then on, any reads from the file in question -will return chucode structures as defined in chudefs.h. -Depending on the settings of PEDANTIC and ANAL_RETENTIVE -used when compiling the kernel, some checking of the -data may or may not be necessary. - -HOW TO USE THE CLK STREAMS DRIVER: - -First, it should be noted that a new ioctl() has been defined. -The CLK_SETSTR ioctl takes a pointer to a string of no more -than CLK_MAXSTRSIZE characters. Until the first CLK_SETSTR -is performed, the driver will simply pass through characters. -Once it is passed a string, then any character in that string -will be immediately followed by a struct timeval. You can -change the string whenever you want by doing another -CLK_SETSTR. The character must be an exact, 8 bit match. -The character '\000' cannot, unfortunately, be stamped. -Passing an empty string to CLK_SETSTR turns off stamping. -Passing NULL will produce undefined results. - diff --git a/usr.sbin/xntpd/kernel/tty_chu.c b/usr.sbin/xntpd/kernel/tty_chu.c deleted file mode 100644 index 4615875e77e0..000000000000 --- a/usr.sbin/xntpd/kernel/tty_chu.c +++ /dev/null @@ -1,276 +0,0 @@ -/* tty_chu.c,v 3.1 1993/07/06 01:07:30 jbj Exp - * tty_chu.c - CHU line driver - */ - -#include "chu.h" -#if NCHU > 0 - -#include "../h/param.h" -#include "../h/types.h" -#include "../h/systm.h" -#include "../h/dir.h" -#include "../h/user.h" -#include "../h/ioctl.h" -#include "../h/tty.h" -#include "../h/proc.h" -#include "../h/file.h" -#include "../h/conf.h" -#include "../h/buf.h" -#include "../h/uio.h" - -#include "../h/chudefs.h" - -/* - * Line discipline for receiving CHU time codes. - * Does elementary noise elimination, takes time stamps after - * the arrival of each character, returns a buffer full of the - * received 10 character code and the associated time stamps. - */ -#define NUMCHUBUFS 3 - -struct chudata { - u_char used; /* Set to 1 when structure in use */ - u_char lastindex; /* least recently used buffer */ - u_char curindex; /* buffer to use */ - u_char sleeping; /* set to 1 when we're sleeping on a buffer */ - struct chucode chubuf[NUMCHUBUFS]; -} chu_data[NCHU]; - -/* - * Number of microseconds we allow between - * character arrivals. The speed is 300 baud - * so this should be somewhat more than 30 msec - */ -#define CHUMAXUSEC (50*1000) /* 50 msec */ - -int chu_debug = 0; - -/* - * Open as CHU time discipline. Called when discipline changed - * with ioctl, and changes the interpretation of the information - * in the tty structure. - */ -/*ARGSUSED*/ -chuopen(dev, tp) - dev_t dev; - register struct tty *tp; -{ - register struct chudata *chu; - - /* - * Don't allow multiple opens. This will also protect us - * from someone opening /dev/tty - */ - if (tp->t_line == CHULDISC) - return (EBUSY); - ttywflush(tp); - for (chu = chu_data; chu < &chu_data[NCHU]; chu++) - if (!chu->used) - break; - if (chu >= &chu[NCHU]) - return (EBUSY); - chu->used++; - chu->lastindex = chu->curindex = 0; - chu->sleeping = 0; - chu->chubuf[0].ncodechars = 0; - tp->T_LINEP = (caddr_t) chu; - return (0); -} - -/* - * Break down... called when discipline changed or from device - * close routine. - */ -chuclose(tp) - register struct tty *tp; -{ - register int s = spl5(); - - ((struct chudata *) tp->T_LINEP)->used = 0; - tp->t_cp = 0; - tp->t_inbuf = 0; - tp->t_rawq.c_cc = 0; /* clear queues -- paranoid */ - tp->t_canq.c_cc = 0; - tp->t_line = 0; /* paranoid: avoid races */ - splx(s); -} - -/* - * Read a CHU buffer. Sleep on the current buffer - */ -churead(tp, uio) - register struct tty *tp; - struct uio *uio; -{ - register struct chudata *chu; - register struct chucode *chucode; - register int s; - - if ((tp->t_state&TS_CARR_ON)==0) - return (EIO); - - chu = (struct chudata *) (tp->T_LINEP); - - s = spl5(); - chucode = &(chu->chubuf[chu->lastindex]); - while (chu->curindex == chu->lastindex) { - chu->sleeping = 1; - sleep((caddr_t)chucode, TTIPRI); - } - chu->sleeping = 0; - if (++(chu->lastindex) >= NUMCHUBUFS) - chu->lastindex = 0; - splx(s); - - return (uiomove((caddr_t)chucode, sizeof(*chucode), UIO_READ, uio)); -} - -/* - * Low level character input routine. - * If the character looks okay, grab a time stamp. If the stuff in - * the buffer is too old, dump it and start fresh. If the character is - * non-BCDish, everything in the buffer too. - */ -chuinput(c, tp) - register int c; - register struct tty *tp; -{ - register struct chudata *chu = (struct chudata *) tp->T_LINEP; - register struct chucode *chuc; - register int i; - long sec, usec; - struct timeval tv; - - /* - * Do a check on the BSDness of the character. This delays - * the time stamp a bit but saves a fair amount of overhead - * when the static is bad. - */ - if (((c) & 0xf) > 9 || (((c)>>4) & 0xf) > 9) { - chuc = &(chu->chubuf[chu->curindex]); - chuc->ncodechars = 0; /* blow all previous away */ - return; - } - - /* - * Call microtime() to get the current time of day - */ - microtime(&tv); - - /* - * Compute the difference in this character's time stamp - * and the last. If it exceeds the margin, blow away all - * the characters currently in the buffer. - */ - chuc = &(chu->chubuf[chu->curindex]); - i = (int)chuc->ncodechars; - if (i > 0) { - sec = tv.tv_sec - chuc->codetimes[i-1].tv_sec; - usec = tv.tv_usec - chuc->codetimes[i-1].tv_usec; - if (usec < 0) { - sec -= 1; - usec += 1000000; - } - if (sec != 0 || usec > CHUMAXUSEC) { - i = 0; - chuc->ncodechars = 0; - } - } - - /* - * Store the character. If we're done, have to tell someone - */ - chuc->codechars[i] = (u_char)c; - chuc->codetimes[i] = tv; - - if (++i < NCHUCHARS) { - /* - * Not much to do here. Save the count and wait - * for another character. - */ - chuc->ncodechars = (u_char)i; - } else { - /* - * Mark this buffer full and point at next. If the - * next buffer is full we overwrite it by bumping the - * next pointer. - */ - chuc->ncodechars = NCHUCHARS; - if (++(chu->curindex) >= NUMCHUBUFS) - chu->curindex = 0; - if (chu->curindex == chu->lastindex) - if (++(chu->lastindex) >= NUMCHUBUFS) - chu->lastindex = 0; - chu->chubuf[chu->curindex].ncodechars = 0; - - /* - * Wake up anyone sleeping on this. Also wake up - * selectors and/or deliver a SIGIO as required. - */ - if (tp->t_rsel) { - selwakeup(tp->t_rsel, tp->t_state&TS_RCOLL); - tp->t_state &= ~TS_RCOLL; - tp->t_rsel = 0; - } - if (tp->t_state & TS_ASYNC) - gsignal(tp->t_pgrp, SIGIO); - if (chu->sleeping) - (void) wakeup((caddr_t)chuc); - } -} - -/* - * Handle ioctls. We reject all tty-style except those that - * change the line discipline. - */ -chuioctl(tp, cmd, data, flag) - struct tty *tp; - int cmd; - caddr_t data; - int flag; -{ - - if ((cmd>>8) != 't') - return (-1); - switch (cmd) { - case TIOCSETD: - case TIOCGETD: - case TIOCGETP: - case TIOCGETC: - return (-1); - } - return (ENOTTY); /* not quite appropriate */ -} - - -chuselect(dev, rw) - dev_t dev; - int rw; -{ - register struct tty *tp = &cdevsw[major(dev)].d_ttys[minor(dev)]; - struct chudata *chu; - int s = spl5(); - - chu = (struct chudata *) (tp->T_LINEP); - - switch (rw) { - - case FREAD: - if (chu->curindex != chu->lastindex) - goto win; - if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait) - tp->t_state |= TS_RCOLL; - else - tp->t_rsel = u.u_procp; - break; - - case FWRITE: - goto win; - } - splx(s); - return (0); -win: - splx(s); - return (1); -} -#endif NCHU diff --git a/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c b/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c deleted file mode 100644 index f46e25d2ab51..000000000000 --- a/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c +++ /dev/null @@ -1,603 +0,0 @@ -/* - * CHU STREAMS module for SunOS - * - * Version 2.6 - * - * Copyright 1991-1994, Nick Sayer - * - * Special thanks to Greg Onufer for his debug assists. - * Special thanks to Matthias Urlichs for the 4.1.x loadable driver support - * code. - * Special wet-noodle whippings to Sun for not properly documenting - * ANYTHING that makes this stuff at all possible. - * - * Should be PUSHed directly on top of a serial I/O channel. - * Provides complete chucode structures to user space. - * - * COMPILATION: - * - * - * To make a SunOS 4.1.x compatable loadable module (from the ntp kernel - * directory): - * - * % cc -c -I../include -DLOADABLE tty_chu_STREAMS.c - * - * The resulting .o file is the loadable module. Modload it - * thusly: - * - * % modload tty_chu_STREAMS.o -entry _chuinit - * - * When none of the instances are pushed in a STREAM, you can - * modunload the driver in the usual manner if you wish. - * - * As an alternative to loading it dynamically you can compile it - * directly into the kernel by hacking str_conf.c. See the README - * file for more details on doing it the old fashioned way. - * - * - * To make a Solaris 2.x compatable module (from the ntp kernel - * directory): - * - * % {gcc,cc} -c -I../include -DSOLARIS2 tty_chu_STREAMS.c - * % ld -r -o /usr/kernel/strmod/chu tty_chu_STREAMS.o - * % chmod 755 /usr/kernel/strmod/chu - * - * The OS will load it for you automagically when it is first pushed. - * - * If you get syntax errors from (really references - * to types that weren't typedef'd in gcc's version of types.h), - * add -D_SYS_TIMER_H to blot out the miscreants. - * - * Under Solaris 2.2 and previous, do not attempt to modunload the - * module unless you're SURE it's not in use. I haven't tried it, but - * I've been told it won't do the right thing. Under Solaris 2.3 (and - * presumably future revs) an attempt to unload the module when it's in - * use will properly refuse with a "busy" message. - * - * - * HISTORY: - * - * v2.6 - Mutexed the per-instance chucode just to be safe. - * v2.5 - Fixed show-stopper bug in Solaris 2.x - qprocson(). - * v2.4 - Added dynamic allocation support for Solaris 2.x. - * v2.3 - Added support for Solaris 2.x. - * v2.2 - Added SERVICE IMMEDIATE hack. - * v2.1 - Added 'sixth byte' heuristics. - * v2.0 - first version with an actual version number. - * Added support for new CHU 'second 31' data format. - * Deleted PEDANTIC and ANAL_RETENTIVE. - * - */ - -#ifdef SOLARIS2 -# ifndef NCHU -# define NCHU 1 -# endif -# define _KERNEL -#elif defined(LOADABLE) -# ifndef NCHU -# define NCHU 3 -# define KERNEL -# endif -#else -# include "chu.h" -#endif - -#if NCHU > 0 - -/* - * Number of microseconds we allow between - * character arrivals. The speed is 300 baud - * so this should be somewhat more than 30 msec - */ -#define CHUMAXUSEC (60*1000) /* 60 msec */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef SOLARIS2 - -#include -#include -#include -#include -#include -#include -#include -#include - -#endif - -#ifdef LOADABLE - -#include -#include -#include -#include -#include -#include - -#endif - - -static struct module_info rminfo = { 0, "chu", 0, INFPSZ, 0, 0 }; -static struct module_info wminfo = { 0, "chu", 0, INFPSZ, 0, 0 }; -static int chuopen(), churput(), chuwput(), chuclose(); - -static struct qinit rinit = { churput, NULL, chuopen, chuclose, NULL, - &rminfo, NULL }; - -static struct qinit winit = { chuwput, NULL, NULL, NULL, NULL, - &wminfo, NULL }; - -struct streamtab chuinfo = { &rinit, &winit, NULL, NULL }; - -/* - * Here's our private data type and structs - */ -struct priv_data -{ -#ifdef SOLARIS2 - kmutex_t chucode_mutex; -#else - char in_use; -#endif - struct chucode chu_struct; -}; - -#ifndef SOLARIS2 -struct priv_data our_priv_data[NCHU]; -#endif - -#ifdef SOLARIS2 - -static struct fmodsw fsw = -{ - "chu", - &chuinfo, - D_NEW | D_MP -}; - -extern struct mod_ops mod_strmodops; - -static struct modlstrmod modlstrmod = -{ - &mod_strmodops, - "CHU timecode decoder v2.6", - &fsw -}; - -static struct modlinkage modlinkage = -{ - MODREV_1, - (void*) &modlstrmod, - NULL -}; - -int _init() -{ - return mod_install(&modlinkage); -} - -int _info(foo) -struct modinfo *foo; -{ - return mod_info(&modlinkage,foo); -} - -int _fini() -{ - return mod_remove(&modlinkage); -} - -#endif /* SOLARIS2 */ - -#ifdef LOADABLE - -# ifdef sun - -static struct vdldrv vd = -{ - VDMAGIC_PSEUDO, - "chu", - NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0, -}; - -static struct fmodsw *chu_fmod; - -/*ARGSUSED*/ -chuinit (fc, vdp, vdi, vds) - unsigned int fc; - struct vddrv *vdp; - addr_t vdi; - struct vdstat *vds; -{ - switch (fc) { - case VDLOAD: - { - int dev, i; - - /* Find free entry in fmodsw */ - for (dev = 0; dev < fmodcnt; dev++) { - if (fmodsw[dev].f_str == NULL) - break; - } - if (dev == fmodcnt) - return (ENODEV); - chu_fmod = &fmodsw[dev]; - - /* If you think a kernel would have strcpy() you're mistaken. */ - for (i = 0; i <= FMNAMESZ; i++) - chu_fmod->f_name[i] = wminfo.mi_idname[i]; - - chu_fmod->f_str = &chuinfo; - } - vdp->vdd_vdtab = (struct vdlinkage *) & vd; - - { - int i; - - for (i=0; if_name[0] = '\0'; - chu_fmod->f_str = NULL; - return 0; - case VDSTAT: - return 0; - default: - return EIO; - } -} - -# endif /* sun */ - -#endif /* LOADABLE */ - -#if !defined(LOADABLE) && !defined(SOLARIS2) - -char chu_first_open=1; - -#endif - -/*ARGSUSED*/ -static int chuopen(q, dev, flag, sflag) -queue_t *q; -dev_t dev; -int flag; -int sflag; -{ - int i; - -#if !defined(LOADABLE) && !defined(SOLARIS2) - if (chu_first_open) - { - chu_first_open=0; - - for(i=0;iq_ptr = kmem_alloc( sizeof(struct priv_data), KM_SLEEP ); - ((struct priv_data *) q->q_ptr)->chu_struct.ncodechars = 0; - - mutex_init(&((struct priv_data *) q->q_ptr)->chucode_mutex,"Chucode Mutex",MUTEX_DRIVER,NULL); - qprocson(q); - - if (!putnextctl1(WR(q), M_CTL, MC_SERVICEIMM)) - { - qprocsoff(q); - mutex_destroy(&((struct priv_data *)q->q_ptr)->chucode_mutex); - kmem_free(q->q_ptr, sizeof(struct chucode) ); - return (EFAULT); - } - - return 0; - -#else - for(i=0;iq_ptr))=&(our_priv_data[i]); - our_priv_data[i].in_use++; - our_priv_data[i].chu_struct.ncodechars = 0; - if (!putctl1(WR(q)->q_next, M_CTL, MC_SERVICEIMM)) - { - our_priv_data[i].in_use=0; - u.u_error = EFAULT; - return (OPENFAIL); - } - return 0; - } - - u.u_error = EBUSY; - return (OPENFAIL); -#endif - -} - -/*ARGSUSED*/ -static int chuclose(q, flag) -queue_t *q; -int flag; -{ -#ifdef SOLARIS2 - qprocsoff(q); - mutex_destroy(&((struct priv_data *)q->q_ptr)->chucode_mutex); - kmem_free(q->q_ptr, sizeof(struct chucode) ); -#else - ((struct priv_data *) (q->q_ptr))->in_use=0; -#endif - return (0); -} - -/* - * Now the crux of the biscuit. - * - * We will be passed data from the man downstairs. If it's not a data - * packet, it must be important, so pass it along unmunged. If, however, - * it is a data packet, we're gonna do special stuff to it. We're going - * to pass each character we get to the old line discipline code we - * include below for just such an occasion. When the old ldisc code - * gets a full chucode struct, we'll hand it back upstairs. - * - * chuinput takes a single character and q (as quickly as possible). - * passback takes a pointer to a chucode struct and q and sends it upstream. - */ - -void chuinput(); -void passback(); - -static int churput(q, mp) -queue_t *q; -mblk_t *mp; -{ - mblk_t *bp; - - switch(mp->b_datap->db_type) - { - case M_DATA: - for(bp=mp; bp!=NULL; bp=bp->b_cont) - { - while(bp->b_rptr < bp->b_wptr) - chuinput( ((u_char)*(bp->b_rptr++)) , q ); - } - freemsg(mp); - break; - default: - putnext(q,mp); - break; - } - -} - -/* - * Writing to a chu device doesn't make sense, but we'll pass them - * through in case they're important. - */ - -static int chuwput(q, mp) -queue_t *q; -mblk_t *mp; -{ - putnext(q,mp); -} - -/* - * Take a pointer to a filled chucode struct and a queue and - * send the chucode stuff upstream - */ - -void passback(outdata,q) -struct chucode *outdata; -queue_t *q; -{ - mblk_t *mp; - int j; - - mp=(mblk_t*) allocb(sizeof(struct chucode),BPRI_LO); - - if (mp==NULL) - { -#ifdef SOLARIS2 - cmn_err(CE_WARN,"chu module couldn't allocate message block"); -#else - log(LOG_ERR,"chu: cannot allocate message"); -#endif - return; - } - - for(j=0;jb_wptr++ = *( ((char*)outdata) + j ); - - putnext(q,mp); -} - -/* - * This routine was copied nearly verbatim from the old line discipline. - */ -void chuinput(c,q) -register u_char c; -queue_t *q; -{ - register struct chucode *chuc; - register int i; - long sec, usec; - struct timeval tv; - - /* - * Quick, Batman, get a timestamp! We need to do this - * right away. The time between the end of the stop bit - * and this point is critical, and should be as nearly - * constant and as short as possible. (Un)fortunately, - * the Sun's clock granularity is so big this isn't a - * major problem. - * - * uniqtime() is totally undocumented, but there you are. - */ - uniqtime(&tv); - -#ifdef SOLARIS2 - mutex_enter(&((struct priv_data *)q->q_ptr)->chucode_mutex); -#endif - - /* - * Now, locate the chu struct once so we don't have to do it - * over and over. - */ - chuc=&(((struct priv_data *) (q->q_ptr))->chu_struct); - - /* - * Compute the difference in this character's time stamp - * and the last. If it exceeds the margin, blow away all - * the characters currently in the buffer. - */ - i = (int)chuc->ncodechars; - if (i > 0) - { - sec = tv.tv_sec - chuc->codetimes[i-1].tv_sec; - usec = tv.tv_usec - chuc->codetimes[i-1].tv_usec; - if (usec < 0) - { - sec -= 1; - usec += 1000000; - } - if (sec != 0 || usec > CHUMAXUSEC) - { - i = 0; - chuc->ncodechars = 0; - } - } - - /* - * Store the character. - */ - chuc->codechars[i] = (u_char)c; - chuc->codetimes[i] = tv; - - /* - * Now we perform the 'sixth byte' heuristics. - * - * This is a long story. - * - * We used to be able to count on the first byte of the code - * having a '6' in the LSD. This prevented most code framing - * errors (garbage before the first byte wouldn't typically - * have a 6 in the LSD). That's no longer the case. - * - * We can get around this, however, by noting that the 6th byte - * must be either equal to or one's complement of the first. - * If we get a sixth byte that ISN'T like that, then it may - * well be that the first byte is garbage. The right thing - * to do is to left-shift the whole buffer one count and - * continue to wait for the sixth byte. - */ - if (i == NCHUCHARS/2) - { - register u_char temp_byte; - - temp_byte=chuc->codechars[i] ^ chuc->codechars[0]; - - if ( (temp_byte) && (temp_byte!=0xff) ) - { - register int t; - /* - * No match. Left-shift the buffer and try again - */ - for(t=0;t<=NCHUCHARS/2;t++) - { - chuc->codechars[t]=chuc->codechars[t+1]; - chuc->codetimes[t]=chuc->codetimes[t+1]; - } - - i--; /* This is because of the ++i immediately following */ - } - } - - /* - * We done yet? - */ - if (++i < NCHUCHARS) - { - /* - * We're not done. Not much to do here. Save the count and wait - * for another character. - */ - chuc->ncodechars = (u_char)i; - } - else - { - /* - * We are done. Mark this buffer full and pass it along. - */ - chuc->ncodechars = NCHUCHARS; - - /* - * Now we have a choice. Either the front half and back half - * have to match, or be one's complement of each other. - * - * So let's try the first byte and see - */ - - if(chuc->codechars[0] == chuc->codechars[NCHUCHARS/2]) - { - chuc->chutype = CHU_TIME; - for( i=0; i<(NCHUCHARS/2); i++) - if (chuc->codechars[i] != chuc->codechars[i+(NCHUCHARS/2)]) - { - chuc->ncodechars = 0; -#ifdef SOLARIS2 - mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex); -#endif - return; - } - } - else - { - chuc->chutype = CHU_YEAR; - for( i=0; i<(NCHUCHARS/2); i++) - if (((chuc->codechars[i] ^ chuc->codechars[i+(NCHUCHARS/2)]) & 0xff) - != 0xff ) - { - chuc->ncodechars = 0; -#ifdef SOLARIS2 - mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex); -#endif - return; - } - } - - passback(chuc,q); /* We're done! */ - chuc->ncodechars = 0; /* Start all over again! */ - } -#ifdef SOLARIS2 - mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex); -#endif -} - -#endif /* NCHU > 0 */ diff --git a/usr.sbin/xntpd/kernel/tty_clk.c b/usr.sbin/xntpd/kernel/tty_clk.c deleted file mode 100644 index 072061039bf3..000000000000 --- a/usr.sbin/xntpd/kernel/tty_clk.c +++ /dev/null @@ -1,317 +0,0 @@ -/* tty_clk.c,v 3.1 1993/07/06 01:07:33 jbj Exp - * tty_clk.c - Generic line driver for receiving radio clock timecodes - */ - -#include "clk.h" -#if NCLK > 0 - -#include "../h/param.h" -#include "../h/types.h" -#include "../h/systm.h" -#include "../h/dir.h" -#include "../h/user.h" -#include "../h/ioctl.h" -#include "../h/tty.h" -#include "../h/proc.h" -#include "../h/file.h" -#include "../h/conf.h" -#include "../h/buf.h" -#include "../h/uio.h" -#include "../h/clist.h" - -/* - * This line discipline is intended to provide well performing - * generic support for the reception and time stamping of radio clock - * timecodes. Most radio clock devices return a string where a - * particular character in the code (usually a \r) is on-time - * synchronized with the clock. The idea here is to collect characters - * until (one of) the synchronization character(s) (we allow two) is seen. - * When the magic character arrives we take a timestamp by calling - * microtime() and insert the eight bytes of struct timeval into the - * buffer after the magic character. We then wake up anyone waiting - * for the buffer and return the whole mess on the next read. - * - * To use this the calling program is expected to first open the - * port, and then to set the port into raw mode with the speed - * set appropriately with a TIOCSETP ioctl(), with the erase and kill - * characters set to those to be considered magic (yes, I know this - * is gross, but they were so convenient). If only one character is - * magic you can set then both the same, or perhaps to the alternate - * parity versions of said character. After getting all this set, - * change the line discipline to CLKLDISC and you are on your way. - * - * The only other bit of magic we do in here is to flush the receive - * buffers on writes if the CRMOD flag is set (hack, hack). - */ - -/* - * We run this very much like a raw mode terminal, with the exception - * that we store up characters locally until we hit one of the - * magic ones and then dump it into the rawq all at once. We keep - * the buffered data in clists since we can then often move it to - * the rawq without copying. For sanity we limit the number of - * characters between specials, and the total number of characters - * before we flush the rawq, as follows. - */ -#define CLKLINESIZE (256) -#define NCLKCHARS (CLKLINESIZE*4) - -struct clkdata { - int inuse; - struct clist clkbuf; -}; -#define clk_cc clkbuf.c_cc -#define clk_cf clkbuf.c_cf -#define clk_cl clkbuf.c_cl - -struct clkdata clk_data[NCLK]; - -/* - * Routine for flushing the internal clist - */ -#define clk_bflush(clk) (ndflush(&((clk)->clkbuf), (clk)->clk_cc)) - -int clk_debug = 0; - -/*ARGSUSED*/ -clkopen(dev, tp) - dev_t dev; - register struct tty *tp; -{ - register struct clkdata *clk; - - /* - * Don't allow multiple opens. This will also protect us - * from someone opening /dev/tty - */ - if (tp->t_line == CLKLDISC) - return (EBUSY); - ttywflush(tp); - for (clk = clk_data; clk < &clk_data[NCLK]; clk++) - if (!clk->inuse) - break; - if (clk >= &clk_data[NCLK]) - return (EBUSY); - clk->inuse++; - clk->clk_cc = 0; - clk->clk_cf = clk->clk_cl = NULL; - tp->T_LINEP = (caddr_t) clk; - return (0); -} - - -/* - * Break down... called when discipline changed or from device - * close routine. - */ -clkclose(tp) - register struct tty *tp; -{ - register struct clkdata *clk; - register int s = spltty(); - - clk = (struct clkdata *)tp->T_LINEP; - if (clk->clk_cc > 0) - clk_bflush(clk); - clk->inuse = 0; - tp->t_line = 0; /* paranoid: avoid races */ - splx(s); -} - - -/* - * Receive a write request. We pass these requests on to the terminal - * driver, except that if the CRMOD bit is set in the flags we - * first flush the input queues. - */ -clkwrite(tp, uio) - register struct tty *tp; - struct uio *uio; -{ - if (tp->t_flags & CRMOD) { - register struct clkdata *clk; - int s; - - s = spltty(); - if (tp->t_rawq.c_cc > 0) - ndflush(&tp->t_rawq, tp->t_rawq.c_cc); - clk = (struct clkdata *) tp->T_LINEP; - if (clk->clk_cc > 0) - clk_bflush(clk); - (void)splx(s); - } - ttwrite(tp, uio); -} - - -/* - * Low level character input routine. - * If the character looks okay, grab a time stamp. If the stuff in - * the buffer is too old, dump it and start fresh. If the character is - * non-BCDish, everything in the buffer too. - */ -clkinput(c, tp) - register int c; - register struct tty *tp; -{ - register struct clkdata *clk; - register int i; - register long s; - struct timeval tv; - - /* - * Check to see whether this isn't the magic character. If not, - * save the character and return. - */ -#ifdef ultrix - if (c != tp->t_cc[VERASE] && c != tp->t_cc[VKILL]) { -#else - if (c != tp->t_erase && c != tp->t_kill) { -#endif - clk = (struct clkdata *) tp->T_LINEP; - if (clk->clk_cc >= CLKLINESIZE) - clk_bflush(clk); - if (putc(c, &clk->clkbuf) == -1) { - /* - * Hopeless, no clists. Flush what we have - * and hope things improve. - */ - clk_bflush(clk); - } - return; - } - - /* - * Here we have a magic character. Get a timestamp and store - * everything. - */ - microtime(&tv); - clk = (struct clkdata *) tp->T_LINEP; - - if (putc(c, &clk->clkbuf) == -1) - goto flushout; - -#ifdef CLKLDISC - /* - * STREAMS people started writing timestamps this way. - * It's not my fault, I am just going along with the flow... - */ - for (i = 0; i < sizeof(struct timeval); i++) - if (putc(*( ((char*)&tv) + i ), &clk->clkbuf) == -1) - goto flushout; -#else - /* - * This is a machine independant way of puting longs into - * the datastream. It has fallen into disuse... - */ - s = tv.tv_sec; - for (i = 0; i < sizeof(long); i++) { - if (putc((s >> 24) & 0xff, &clk->clkbuf) == -1) - goto flushout; - s <<= 8; - } - - s = tv.tv_usec; - for (i = 0; i < sizeof(long); i++) { - if (putc((s >> 24) & 0xff, &clk->clkbuf) == -1) - goto flushout; - s <<= 8; - } -#endif - - /* - * If the length of the rawq exceeds our sanity limit, dump - * all the old crap in there before copying this in. - */ - if (tp->t_rawq.c_cc > NCLKCHARS) - ndflush(&tp->t_rawq, tp->t_rawq.c_cc); - - /* - * Now copy the buffer in. There is a special case optimization - * here. If there is nothing on the rawq at present we can - * just copy the clists we own over. Otherwise we must concatenate - * the present data on the end. - */ - s = (long)spltty(); - if (tp->t_rawq.c_cc <= 0) { - tp->t_rawq = clk->clkbuf; - clk->clk_cc = 0; - clk->clk_cl = clk->clk_cf = NULL; - (void) splx((int)s); - } else { - (void) splx((int)s); - catq(&clk->clkbuf, &tp->t_rawq); - clk_bflush(clk); - } - - /* - * Tell the world - */ - ttwakeup(tp); - return; - -flushout: - /* - * It would be nice if this never happened. Flush the - * internal clists and hope someone else frees some of them - */ - clk_bflush(clk); - return; -} - - -/* - * Handle ioctls. We reject most tty-style except those that - * change the line discipline and a couple of others.. - */ -clkioctl(tp, cmd, data, flag) - struct tty *tp; - int cmd; - caddr_t data; - int flag; -{ - int flags; - struct sgttyb *sg; - - if ((cmd>>8) != 't') - return (-1); - switch (cmd) { - case TIOCSETD: - case TIOCGETD: - case TIOCGETP: - case TIOCGETC: - case TIOCOUTQ: - return (-1); - - case TIOCSETP: - /* - * He likely wants to set new magic characters in. - * Do this part. - */ - sg = (struct sgttyb *)data; -#ifdef ultrix - tp->t_cc[VERASE] = sg->sg_erase; - tp->t_cc[VKILL] = sg->sg_kill; -#else - tp->t_erase = sg->sg_erase; - tp->t_kill = sg->sg_kill; -#endif - return (0); - - case TIOCFLUSH: - flags = *(int *)data; - if (flags == 0 || (flags & FREAD)) { - register struct clkdata *clk; - - clk = (struct clkdata *) tp->T_LINEP; - if (clk->clk_cc > 0) - clk_bflush(clk); - } - return (-1); - - default: - break; - } - return (ENOTTY); /* not quite appropriate */ -} -#endif NCLK diff --git a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c b/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c deleted file mode 100644 index 13b0a25f1d89..000000000000 --- a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c +++ /dev/null @@ -1,266 +0,0 @@ -/* tty_clk_STREAMS.c,v 3.1 1993/07/06 01:07:34 jbj Exp - * Timestamp STREAMS module for SunOS 4.1 - * - * Copyright 1991, Nick Sayer - * - * Special thanks to Greg Onufer for his debug assists. - * - * Should be PUSHed directly on top of a serial I/O channel. - * For any character in a user-designated set, adds a kernel - * timestamp to that character. - * - * BUGS: - * - * Only so many characters can be timestamped. This number, however, - * is adjustable. - * - * The null character ($00) cannot be timestamped. - * - * The M_DATA messages passed upstream will not be the same - * size as when they arrive from downstream, even if no - * timestamp character is in the message. This, however, - * should not affect anything. - * - */ - -#include "clk.h" -#if NCLK > 0 -/* - * How big should the messages we pass upstream be? - */ -#define MESSAGE_SIZE 128 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static struct module_info rminfo = { 0, "clk", 0, INFPSZ, 0, 0 }; -static struct module_info wminfo = { 0, "clk", 0, INFPSZ, 0, 0 }; -static int clkopen(), clkrput(), clkwput(), clkclose(); - -static struct qinit rinit = { clkrput, NULL, clkopen, clkclose, NULL, - &rminfo, NULL }; - -static struct qinit winit = { clkwput, NULL, NULL, NULL, NULL, - &wminfo, NULL }; - -struct streamtab clkinfo = { &rinit, &winit, NULL, NULL }; - -struct priv_data_type -{ - char in_use; - char string[CLK_MAXSTRSIZE]; -} priv_data[NCLK]; - -char first_open=1; - -/* - * God only knows why, but linking with strchr() fails - * on my system, so here's a renamed copy. - */ - -u_char *str_chr(s,c) -u_char *s; -int c; -{ - while (*s) - if(*s++ == c) - return (s-1); - return NULL; -} - -/*ARGSUSED*/ -static int clkopen(q, dev, flag, sflag) -queue_t *q; -dev_t dev; -int flag; -int sflag; -{ - int i; - -/* Damn it! We can't even have the global data struct properly - initialized! So we have a mark to tell us to init the global - data on the first open */ - - if (first_open) - { - first_open=0; - - for(i=0;iq_ptr))=priv_data+i; - priv_data[i].string[0]=0; - return (0); - } - u.u_error = EBUSY; - return (OPENFAIL); -} - -/*ARGSUSED*/ -static int clkclose(q, flag) -queue_t *q; -int flag; -{ - ((struct priv_data_type *) (q->q_ptr))->in_use=0; - - return (0); -} - -/* - * Now the crux of the biscuit. - * - * If it's an M_DATA package, we take each character and pass - * it to clkchar. - */ - -void clkchar(); - -static int clkrput(q, mp) -queue_t *q; -mblk_t *mp; -{ - mblk_t *bp; - - switch(mp->b_datap->db_type) - { - case M_DATA: - clkchar(0,q,2); - for(bp=mp; bp!=NULL; bp=bp->b_cont) - { - while(bp->b_rptr < bp->b_wptr) - clkchar( ((u_char)*(bp->b_rptr++)) , q , 0 ); - } - clkchar(0,q,1); - freemsg(mp); - break; - default: - putnext(q,mp); - break; - } - -} - -/* - * If it's a matching M_IOCTL, handle it. - */ - -static int clkwput(q, mp) -queue_t *q; -mblk_t *mp; -{ - struct iocblk *iocp; - - switch(mp->b_datap->db_type) - { - case M_IOCTL: - iocp=(struct iocblk*) mp->b_rptr; - if (iocp->ioc_cmd==CLK_SETSTR) - { - strncpy( ((struct priv_data_type *) (RD(q)->q_ptr))->string, - (char *) mp->b_cont->b_rptr,CLK_MAXSTRSIZE); - /* make sure it's null terminated */ - ((struct priv_data_type *) (RD(q)->q_ptr))->string[CLK_MAXSTRSIZE-1]=0; - mp->b_datap->db_type = M_IOCACK; - qreply(q,mp); - } - else - putnext(q,mp); - break; - default: - putnext(q,mp); - break; - } -} - -/* - * Now clkchar. It takes a character, a queue pointer and an action - * flag and depending on the flag either: - * - * 0 - adds the character to the current message. If there's a - * timestamp to be done, do that too. If the message is less than - * 8 chars from being full, link in a new one, and set it up for - * the next call. - * - * 1 - sends the whole mess to Valhala. - * - * 2 - set things up. - * - * Yeah, it's an ugly hack. Complaints may be filed with /dev/null. - */ - - -void clkchar(c,q,f) - register u_char c; - queue_t *q; - char f; -{ - static char error; - static mblk_t *message,*mp; - struct timeval tv; - -/* Get a timestamp ASAP! */ - uniqtime(&tv); - - switch(f) - { - case 1: - if (!error) - putnext(q,message); - break; - case 2: - mp=message= (mblk_t*) allocb(MESSAGE_SIZE,BPRI_LO); - error=(message==NULL); - if (error) - log(LOG_ERR,"clk: cannot allocate message - data lost"); - break; - case 0: - if (error) /* If we had an error, forget it. */ - return; - - *mp->b_wptr++=c; /* Put the char away first. - - /* If it's in the special string, append a struct timeval */ - - if (str_chr( ((struct priv_data_type *) (q->q_ptr))->string , - c )!=NULL) - { - int i; - - for (i=0;ib_wptr++= *( ((char*)&tv) + i ); - } - - /* If we don't have space for a complete struct timeval, and a - char, it's time for a new mp block */ - - if (((mp->b_wptr-mp->b_rptr)+sizeof(struct timeval)+2)>MESSAGE_SIZE) - { - mp->b_cont= (mblk_t*) allocb(MESSAGE_SIZE,BPRI_LO); - error=(mp->b_cont==NULL); - if (error) - { - log(LOG_ERR,"clk: cannot allocate message - data lost"); - freemsg(message); - } - mp=mp->b_cont; - } - - break; - } -} - -#endif diff --git a/usr.sbin/xntpd/lib/Makefile.tmpl b/usr.sbin/xntpd/lib/Makefile.tmpl deleted file mode 100644 index 1a8d020bd886..000000000000 --- a/usr.sbin/xntpd/lib/Makefile.tmpl +++ /dev/null @@ -1,75 +0,0 @@ -# -# Makefile.tmpl -# -LIBNAME= libntp -# -# xntp routines which are used a lot of places -# -COMPILER= cc -COPTS= -O -AUTHDEFS=-DDES -LIBDEFS= -DBIG_ENDIAN -RANLIB= ranlib -INSTALL= install -CLOCKDEFS= -DEFS= -DEFS_OPT= -DEFS_LOCAL= -# -INCL=-I../include -CFLAGS= $(COPTS) $(AUTHDEFS) $(LIBDEFS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -# -SOURCE= atoint.c atolfp.c atouint.c auth12crypt.c authdecrypt.c authdes.c \ - authencrypt.c authkeys.c authparity.c authreadkeys.c authusekey.c \ - buftvtots.c caljulian.c calleapwhen.c caltontp.c calyearstart.c \ - clocktime.c dofptoa.c dolfptoa.c emalloc.c fptoa.c fptoms.c getopt.c \ - gettstamp.c hextoint.c hextolfp.c humandate.c inttoa.c \ - lib_strbuf.c mfptoa.c mfptoms.c modetoa.c mstolfp.c \ - msutotsf.c numtoa.c refnumtoa.c numtohost.c octtoint.c \ - prettydate.c ranny.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \ - uglydate.c uinttoa.c utvtoa.c machines.c clocktypes.c \ - md5.c a_md5encrypt.c a_md5decrypt.c \ - a_md512crypt.c decodenetnum.c systime.c msyslog.c syssignal.c \ - findconfig.c netof.c - -OBJS= atoint.o atolfp.o atouint.o auth12crypt.o authdecrypt.o authdes.o \ - authencrypt.o authkeys.o authparity.o authreadkeys.o authusekey.o \ - buftvtots.o caljulian.o calleapwhen.o caltontp.o calyearstart.o \ - clocktime.o dofptoa.o dolfptoa.o emalloc.o fptoa.o fptoms.o getopt.o \ - gettstamp.o hextoint.o hextolfp.o humandate.o inttoa.o \ - lib_strbuf.o mfptoa.o mfptoms.o modetoa.o mstolfp.o \ - msutotsf.o numtoa.o refnumtoa.o numtohost.o octtoint.o \ - prettydate.o ranny.o tsftomsu.o tstotv.o tvtoa.o tvtots.o \ - uglydate.o uinttoa.o utvtoa.o machines.o clocktypes.o \ - md5.o a_md5encrypt.o a_md5decrypt.o \ - a_md512crypt.o decodenetnum.o systime.o msyslog.o syssignal.o \ - findconfig.o netof.o - -$(LIBNAME).a: $(OBJS) - ar rv $@ $? - -rm -f $? - @if ( ../scripts/hpadjtime.sh ) > /dev/null 2>&1; then \ - ( cd ../adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" ) && ar rv $@ ../adjtime/adjtime.o; \ - else \ - :; \ - fi - $(RANLIB) $@ - -lintlib: llib-l$(LIBNAME).ln - -llib-l$(LIBNAME).ln: $(SOURCE) - lint -C$(LIBNAME) $(INCL) $(CLOCKDEFS) $(AUTHDEFS) $(LIBDEFS) $(SOURCE) >lintlib.errs - -lint: - lint -u $(DEFS) $(INCL) $(CLOCKDEFS) $(AUTHDEFS) $(LIBDEFS) $(SOURCE) >lint.errs - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(LIBNAME).a *.o *.out *.ln make.log Makefile.bak \ - lintlib.errs lint.errs - -distclean: clean - -@rm -f *.orig *.rej .version Makefile diff --git a/usr.sbin/xntpd/lib/authdes.c b/usr.sbin/xntpd/lib/authdes.c deleted file mode 100644 index dd122decf6b6..000000000000 --- a/usr.sbin/xntpd/lib/authdes.c +++ /dev/null @@ -1,845 +0,0 @@ -/* - * authdes.c - an implementation of the DES cipher algorithm for NTP - */ -#include "ntp_stdlib.h" - -/* - * There are two entries in here. auth_subkeys() called to - * compute the encryption and decryption key schedules, while - * auth_des() is called to do the actual encryption/decryption - */ - -/* - * Key setup. Here we entirely permute a key, saving the results - * for both the encryption and decryption. Note that while the - * decryption subkeys are simply the encryption keys reordered, - * we save both so that a common cipher routine may be used. - */ - -/* - * Permuted choice 1 tables. These are used to extract bits - * from the left and right parts of the key to form Ci and Di. - * The code that uses these tables knows which bits from which - * part of each key are used to form Ci and Di. - */ -static U_LONG PC1_CL[8] = { - 0x00000000, 0x00000010, 0x00001000, 0x00001010, - 0x00100000, 0x00100010, 0x00101000, 0x00101010 -}; - -static U_LONG PC1_DL[16] = { - 0x00000000, 0x00100000, 0x00001000, 0x00101000, - 0x00000010, 0x00100010, 0x00001010, 0x00101010, - 0x00000001, 0x00100001, 0x00001001, 0x00101001, - 0x00000011, 0x00100011, 0x00001011, 0x00101011 -}; - -static U_LONG PC1_CR[16] = { - 0x00000000, 0x00000001, 0x00000100, 0x00000101, - 0x00010000, 0x00010001, 0x00010100, 0x00010101, - 0x01000000, 0x01000001, 0x01000100, 0x01000101, - 0x01010000, 0x01010001, 0x01010100, 0x01010101 -}; - -static U_LONG PC1_DR[8] = { - 0x00000000, 0x01000000, 0x00010000, 0x01010000, - 0x00000100, 0x01000100, 0x00010100, 0x01010100 -}; - - -/* - * At the start of some iterations of the key schedule we do - * a circular left shift by one place, while for others we do a shift by - * two places. This has bits set for the iterations where we do 2 bit - * shifts, starting at the low order bit. - */ -#define TWO_BIT_SHIFTS 0x7efc - -/* - * Permuted choice 2 tables. The first actually produces the low order - * 24 bits of the subkey Ki from the 28 bit value of Ci. The second produces - * the high order 24 bits from Di. The tables are indexed by six bit - * segments of Ci and Di respectively. The code is handcrafted to compute - * the appropriate 6 bit chunks. - * - * Note that for ease of computation, the 24 bit values are produced with - * six bits going into each byte. - */ -static U_LONG PC2_C[4][64] = { - { 0x00000000, 0x00040000, 0x01000000, 0x01040000, - 0x00000400, 0x00040400, 0x01000400, 0x01040400, - 0x00200000, 0x00240000, 0x01200000, 0x01240000, - 0x00200400, 0x00240400, 0x01200400, 0x01240400, - 0x00000001, 0x00040001, 0x01000001, 0x01040001, - 0x00000401, 0x00040401, 0x01000401, 0x01040401, - 0x00200001, 0x00240001, 0x01200001, 0x01240001, - 0x00200401, 0x00240401, 0x01200401, 0x01240401, - 0x02000000, 0x02040000, 0x03000000, 0x03040000, - 0x02000400, 0x02040400, 0x03000400, 0x03040400, - 0x02200000, 0x02240000, 0x03200000, 0x03240000, - 0x02200400, 0x02240400, 0x03200400, 0x03240400, - 0x02000001, 0x02040001, 0x03000001, 0x03040001, - 0x02000401, 0x02040401, 0x03000401, 0x03040401, - 0x02200001, 0x02240001, 0x03200001, 0x03240001, - 0x02200401, 0x02240401, 0x03200401, 0x03240401 }, - - { 0x00000000, 0x00000002, 0x00000800, 0x00000802, - 0x08000000, 0x08000002, 0x08000800, 0x08000802, - 0x00010000, 0x00010002, 0x00010800, 0x00010802, - 0x08010000, 0x08010002, 0x08010800, 0x08010802, - 0x00000100, 0x00000102, 0x00000900, 0x00000902, - 0x08000100, 0x08000102, 0x08000900, 0x08000902, - 0x00010100, 0x00010102, 0x00010900, 0x00010902, - 0x08010100, 0x08010102, 0x08010900, 0x08010902, - 0x00000010, 0x00000012, 0x00000810, 0x00000812, - 0x08000010, 0x08000012, 0x08000810, 0x08000812, - 0x00010010, 0x00010012, 0x00010810, 0x00010812, - 0x08010010, 0x08010012, 0x08010810, 0x08010812, - 0x00000110, 0x00000112, 0x00000910, 0x00000912, - 0x08000110, 0x08000112, 0x08000910, 0x08000912, - 0x00010110, 0x00010112, 0x00010910, 0x00010912, - 0x08010110, 0x08010112, 0x08010910, 0x08010912 }, - - { 0x00000000, 0x04000000, 0x00002000, 0x04002000, - 0x10000000, 0x14000000, 0x10002000, 0x14002000, - 0x00000020, 0x04000020, 0x00002020, 0x04002020, - 0x10000020, 0x14000020, 0x10002020, 0x14002020, - 0x00080000, 0x04080000, 0x00082000, 0x04082000, - 0x10080000, 0x14080000, 0x10082000, 0x14082000, - 0x00080020, 0x04080020, 0x00082020, 0x04082020, - 0x10080020, 0x14080020, 0x10082020, 0x14082020, - 0x20000000, 0x24000000, 0x20002000, 0x24002000, - 0x30000000, 0x34000000, 0x30002000, 0x34002000, - 0x20000020, 0x24000020, 0x20002020, 0x24002020, - 0x30000020, 0x34000020, 0x30002020, 0x34002020, - 0x20080000, 0x24080000, 0x20082000, 0x24082000, - 0x30080000, 0x34080000, 0x30082000, 0x34082000, - 0x20080020, 0x24080020, 0x20082020, 0x24082020, - 0x30080020, 0x34080020, 0x30082020, 0x34082020 }, - - { 0x00000000, 0x00100000, 0x00000008, 0x00100008, - 0x00000200, 0x00100200, 0x00000208, 0x00100208, - 0x00020000, 0x00120000, 0x00020008, 0x00120008, - 0x00020200, 0x00120200, 0x00020208, 0x00120208, - 0x00000004, 0x00100004, 0x0000000c, 0x0010000c, - 0x00000204, 0x00100204, 0x0000020c, 0x0010020c, - 0x00020004, 0x00120004, 0x0002000c, 0x0012000c, - 0x00020204, 0x00120204, 0x0002020c, 0x0012020c, - 0x00001000, 0x00101000, 0x00001008, 0x00101008, - 0x00001200, 0x00101200, 0x00001208, 0x00101208, - 0x00021000, 0x00121000, 0x00021008, 0x00121008, - 0x00021200, 0x00121200, 0x00021208, 0x00121208, - 0x00001004, 0x00101004, 0x0000100c, 0x0010100c, - 0x00001204, 0x00101204, 0x0000120c, 0x0010120c, - 0x00021004, 0x00121004, 0x0002100c, 0x0012100c, - 0x00021204, 0x00121204, 0x0002120c, 0x0012120c } -}; - -static U_LONG PC2_D[4][64] = { - { 0x00000000, 0x00000200, 0x00020000, 0x00020200, - 0x00000001, 0x00000201, 0x00020001, 0x00020201, - 0x08000000, 0x08000200, 0x08020000, 0x08020200, - 0x08000001, 0x08000201, 0x08020001, 0x08020201, - 0x00200000, 0x00200200, 0x00220000, 0x00220200, - 0x00200001, 0x00200201, 0x00220001, 0x00220201, - 0x08200000, 0x08200200, 0x08220000, 0x08220200, - 0x08200001, 0x08200201, 0x08220001, 0x08220201, - 0x00000002, 0x00000202, 0x00020002, 0x00020202, - 0x00000003, 0x00000203, 0x00020003, 0x00020203, - 0x08000002, 0x08000202, 0x08020002, 0x08020202, - 0x08000003, 0x08000203, 0x08020003, 0x08020203, - 0x00200002, 0x00200202, 0x00220002, 0x00220202, - 0x00200003, 0x00200203, 0x00220003, 0x00220203, - 0x08200002, 0x08200202, 0x08220002, 0x08220202, - 0x08200003, 0x08200203, 0x08220003, 0x08220203 }, - - { 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00100000, 0x00100010, 0x20100000, 0x20100010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00100800, 0x00100810, 0x20100800, 0x20100810, - 0x04000000, 0x04000010, 0x24000000, 0x24000010, - 0x04100000, 0x04100010, 0x24100000, 0x24100010, - 0x04000800, 0x04000810, 0x24000800, 0x24000810, - 0x04100800, 0x04100810, 0x24100800, 0x24100810, - 0x00000004, 0x00000014, 0x20000004, 0x20000014, - 0x00100004, 0x00100014, 0x20100004, 0x20100014, - 0x00000804, 0x00000814, 0x20000804, 0x20000814, - 0x00100804, 0x00100814, 0x20100804, 0x20100814, - 0x04000004, 0x04000014, 0x24000004, 0x24000014, - 0x04100004, 0x04100014, 0x24100004, 0x24100014, - 0x04000804, 0x04000814, 0x24000804, 0x24000814, - 0x04100804, 0x04100814, 0x24100804, 0x24100814 }, - - { 0x00000000, 0x00001000, 0x00010000, 0x00011000, - 0x02000000, 0x02001000, 0x02010000, 0x02011000, - 0x00000020, 0x00001020, 0x00010020, 0x00011020, - 0x02000020, 0x02001020, 0x02010020, 0x02011020, - 0x00040000, 0x00041000, 0x00050000, 0x00051000, - 0x02040000, 0x02041000, 0x02050000, 0x02051000, - 0x00040020, 0x00041020, 0x00050020, 0x00051020, - 0x02040020, 0x02041020, 0x02050020, 0x02051020, - 0x00002000, 0x00003000, 0x00012000, 0x00013000, - 0x02002000, 0x02003000, 0x02012000, 0x02013000, - 0x00002020, 0x00003020, 0x00012020, 0x00013020, - 0x02002020, 0x02003020, 0x02012020, 0x02013020, - 0x00042000, 0x00043000, 0x00052000, 0x00053000, - 0x02042000, 0x02043000, 0x02052000, 0x02053000, - 0x00042020, 0x00043020, 0x00052020, 0x00053020, - 0x02042020, 0x02043020, 0x02052020, 0x02053020 }, - - { 0x00000000, 0x00000400, 0x01000000, 0x01000400, - 0x00000100, 0x00000500, 0x01000100, 0x01000500, - 0x10000000, 0x10000400, 0x11000000, 0x11000400, - 0x10000100, 0x10000500, 0x11000100, 0x11000500, - 0x00080000, 0x00080400, 0x01080000, 0x01080400, - 0x00080100, 0x00080500, 0x01080100, 0x01080500, - 0x10080000, 0x10080400, 0x11080000, 0x11080400, - 0x10080100, 0x10080500, 0x11080100, 0x11080500, - 0x00000008, 0x00000408, 0x01000008, 0x01000408, - 0x00000108, 0x00000508, 0x01000108, 0x01000508, - 0x10000008, 0x10000408, 0x11000008, 0x11000408, - 0x10000108, 0x10000508, 0x11000108, 0x11000508, - 0x00080008, 0x00080408, 0x01080008, 0x01080408, - 0x00080108, 0x00080508, 0x01080108, 0x01080508, - 0x10080008, 0x10080408, 0x11080008, 0x11080408, - 0x10080108, 0x10080508, 0x11080108, 0x11080508 } -}; - - - -/* - * Permute the key to give us our key schedule. - */ -void -DESauth_subkeys(key, encryptkeys, decryptkeys) - const U_LONG *key; - u_char *encryptkeys; - u_char *decryptkeys; -{ - register U_LONG tmp; - register U_LONG c, d; - register u_char *ek, *dk; - register int two_bit_shifts; - register int i; - - /* - * The first permutted choice gives us the 28 bits for C0 and - * 28 for D0. C0 gets 12 bits from the left key and 16 from - * the right, while D0 gets 16 from the left and 12 from the - * right. The code knows which bits go where. - */ - tmp = *key; /* left part of key */ - c = PC1_CL[(tmp >> 29) & 0x7] - | (PC1_CL[(tmp >> 21) & 0x7] << 1) - | (PC1_CL[(tmp >> 13) & 0x7] << 2) - | (PC1_CL[(tmp >> 5) & 0x7] << 3); - d = PC1_DL[(tmp >> 25) & 0xf] - | (PC1_DL[(tmp >> 17) & 0xf] << 1) - | (PC1_DL[(tmp >> 9) & 0xf] << 2) - | (PC1_DL[(tmp >> 1) & 0xf] << 3); - - tmp = *(key+1); /* right part of key */ - c |= PC1_CR[(tmp >> 28) & 0xf] - | (PC1_CR[(tmp >> 20) & 0xf] << 1) - | (PC1_CR[(tmp >> 12) & 0xf] << 2) - | (PC1_CR[(tmp >> 4) & 0xf] << 3); - d |= PC1_DR[(tmp >> 25) & 0x7] - | (PC1_DR[(tmp >> 17) & 0x7] << 1) - | (PC1_DR[(tmp >> 9) & 0x7] << 2) - | (PC1_DR[(tmp >> 1) & 0x7] << 3); - - /* - * Now iterate to compute the key schedule. Note that we - * record the entire set of subkeys in 6 bit chunks since - * they are used that way. At 6 bits/char, we need - * 48/6 char's/subkey * 16 subkeys/encryption == 128 chars. - * encryptkeys and decryptkeys must be this big. - */ - ek = encryptkeys; - dk = decryptkeys + (8 * 15); - two_bit_shifts = TWO_BIT_SHIFTS; - for (i = 16; i > 0; i--) { - /* - * Do the rotation. One bit and two bit rotations - * are done separately. Note C and D are 28 bits. - */ - if (two_bit_shifts & 0x1) { - c = ((c << 2) & 0xffffffc) | (c >> 26); - d = ((d << 2) & 0xffffffc) | (d >> 26); - } else { - c = ((c << 1) & 0xffffffe) | (c >> 27); - d = ((d << 1) & 0xffffffe) | (d >> 27); - } - two_bit_shifts >>= 1; - - /* - * Apply permutted choice 2 to C to get the first - * 24 bits worth of keys. Note that bits 9, 18, 22 - * and 25 (using DES numbering) in C are unused. The - * shift-mask stuff is done to delete these bits from - * the indices, since this cuts the table size in half. - */ - tmp = PC2_C[0][((c >> 22) & 0x3f)] - | PC2_C[1][((c >> 15) & 0xf) | ((c >> 16) & 0x30)] - | PC2_C[2][((c >> 4) & 0x3) | ((c >> 9) & 0x3c)] - | PC2_C[3][((c ) & 0x7) | ((c >> 4) & 0x38)]; - *ek++ = *dk++ = (u_char)(tmp >> 24); - *ek++ = *dk++ = (u_char)(tmp >> 16); - *ek++ = *dk++ = (u_char)(tmp >> 8); - *ek++ = *dk++ = (u_char)tmp; - - /* - * Apply permutted choice 2 to D to get the other half. - * Here, bits 7, 10, 15 and 26 go unused. The sqeezing - * actually turns out to be cheaper here. - */ - tmp = PC2_D[0][((d >> 22) & 0x3f)] - | PC2_D[1][((d >> 14) & 0xf) | ((d >> 15) & 0x30)] - | PC2_D[2][((d >> 7) & 0x3f)] - | PC2_D[3][((d ) & 0x3) | ((d >> 1) & 0x3c)]; - *ek++ = *dk++ = (u_char)(tmp >> 24); - *ek++ = *dk++ = (u_char)(tmp >> 16); - *ek++ = *dk++ = (u_char)(tmp >> 8); - *ek++ = *dk++ = (u_char)tmp; - - /* - * We are filling in the decryption subkeys from the end. - * Space it back 16 elements to get to the start of the - * next set. - */ - dk -= 16; - } -} - -/* - * The DES algorithm. This is intended to be fairly speedy at the - * expense of some memory. - * - * This uses all the standard hacks. The S boxes and the P permutation - * are precomputed into one table. The E box never actually appears - * explicitly since it is easy to apply this algorithmically. The - * initial permutation and final (inverse initial) permuation are - * computed from tables designed to permute four bits at a time. This - * should run pretty fast on machines with 32 bit words and - * bit field/multiple bit shift instructions which are fast. - */ - -/* - * The initial permutation array. This is used to compute both the - * left and the right halves of the initial permutation using bytes - * from words made from the following operations: - * - * ((left & 0x55555555) << 1) | (right & 0x55555555) for left half - * (left & 0xaaaaaaaa) | ((right & 0xaaaaaaaa) >> 1) for right half - * - * The scheme is that we index into the table using each byte. The - * result from the high order byte is or'd with the result from the - * next byte shifted left once is or'd with the result from the next - * byte shifted left twice if or'd with the result from the low order - * byte shifted left by three. Clear? - */ -static U_LONG IP[256] = { - 0x00000000, 0x00000010, 0x00000001, 0x00000011, - 0x00001000, 0x00001010, 0x00001001, 0x00001011, - 0x00000100, 0x00000110, 0x00000101, 0x00000111, - 0x00001100, 0x00001110, 0x00001101, 0x00001111, - 0x00100000, 0x00100010, 0x00100001, 0x00100011, - 0x00101000, 0x00101010, 0x00101001, 0x00101011, - 0x00100100, 0x00100110, 0x00100101, 0x00100111, - 0x00101100, 0x00101110, 0x00101101, 0x00101111, - 0x00010000, 0x00010010, 0x00010001, 0x00010011, - 0x00011000, 0x00011010, 0x00011001, 0x00011011, - 0x00010100, 0x00010110, 0x00010101, 0x00010111, - 0x00011100, 0x00011110, 0x00011101, 0x00011111, - 0x00110000, 0x00110010, 0x00110001, 0x00110011, - 0x00111000, 0x00111010, 0x00111001, 0x00111011, - 0x00110100, 0x00110110, 0x00110101, 0x00110111, - 0x00111100, 0x00111110, 0x00111101, 0x00111111, - 0x10000000, 0x10000010, 0x10000001, 0x10000011, - 0x10001000, 0x10001010, 0x10001001, 0x10001011, - 0x10000100, 0x10000110, 0x10000101, 0x10000111, - 0x10001100, 0x10001110, 0x10001101, 0x10001111, - 0x10100000, 0x10100010, 0x10100001, 0x10100011, - 0x10101000, 0x10101010, 0x10101001, 0x10101011, - 0x10100100, 0x10100110, 0x10100101, 0x10100111, - 0x10101100, 0x10101110, 0x10101101, 0x10101111, - 0x10010000, 0x10010010, 0x10010001, 0x10010011, - 0x10011000, 0x10011010, 0x10011001, 0x10011011, - 0x10010100, 0x10010110, 0x10010101, 0x10010111, - 0x10011100, 0x10011110, 0x10011101, 0x10011111, - 0x10110000, 0x10110010, 0x10110001, 0x10110011, - 0x10111000, 0x10111010, 0x10111001, 0x10111011, - 0x10110100, 0x10110110, 0x10110101, 0x10110111, - 0x10111100, 0x10111110, 0x10111101, 0x10111111, - 0x01000000, 0x01000010, 0x01000001, 0x01000011, - 0x01001000, 0x01001010, 0x01001001, 0x01001011, - 0x01000100, 0x01000110, 0x01000101, 0x01000111, - 0x01001100, 0x01001110, 0x01001101, 0x01001111, - 0x01100000, 0x01100010, 0x01100001, 0x01100011, - 0x01101000, 0x01101010, 0x01101001, 0x01101011, - 0x01100100, 0x01100110, 0x01100101, 0x01100111, - 0x01101100, 0x01101110, 0x01101101, 0x01101111, - 0x01010000, 0x01010010, 0x01010001, 0x01010011, - 0x01011000, 0x01011010, 0x01011001, 0x01011011, - 0x01010100, 0x01010110, 0x01010101, 0x01010111, - 0x01011100, 0x01011110, 0x01011101, 0x01011111, - 0x01110000, 0x01110010, 0x01110001, 0x01110011, - 0x01111000, 0x01111010, 0x01111001, 0x01111011, - 0x01110100, 0x01110110, 0x01110101, 0x01110111, - 0x01111100, 0x01111110, 0x01111101, 0x01111111, - 0x11000000, 0x11000010, 0x11000001, 0x11000011, - 0x11001000, 0x11001010, 0x11001001, 0x11001011, - 0x11000100, 0x11000110, 0x11000101, 0x11000111, - 0x11001100, 0x11001110, 0x11001101, 0x11001111, - 0x11100000, 0x11100010, 0x11100001, 0x11100011, - 0x11101000, 0x11101010, 0x11101001, 0x11101011, - 0x11100100, 0x11100110, 0x11100101, 0x11100111, - 0x11101100, 0x11101110, 0x11101101, 0x11101111, - 0x11010000, 0x11010010, 0x11010001, 0x11010011, - 0x11011000, 0x11011010, 0x11011001, 0x11011011, - 0x11010100, 0x11010110, 0x11010101, 0x11010111, - 0x11011100, 0x11011110, 0x11011101, 0x11011111, - 0x11110000, 0x11110010, 0x11110001, 0x11110011, - 0x11111000, 0x11111010, 0x11111001, 0x11111011, - 0x11110100, 0x11110110, 0x11110101, 0x11110111, - 0x11111100, 0x11111110, 0x11111101, 0x11111111 -}; - -/* - * The final permutation array. Like the IP array, used - * to compute both the left and right results from the nibbles - * of words computed from: - * - * ((left & 0x0f0f0f0f) << 4) | (right & 0x0f0f0f0f) for left result - * (left & 0xf0f0f0f0) | ((right & 0xf0f0f0f0) >> 4) for right result - * - * The result from the high order byte is shifted left 6 bits and - * or'd with the result from the next byte shifted left 4 bits, which - * is or'd with the result from the next byte shifted left 2 bits, - * which is or'd with the result from the low byte. - * - * There is one of these for big end machines (the natural order for - * DES) and a second for little end machines. One is a byte swapped - * version of the other. - */ -#ifndef XNTP_LITTLE_ENDIAN - /* - * Big end version - */ -static U_LONG FP[256] = { - 0x00000000, 0x02000000, 0x00020000, 0x02020000, - 0x00000200, 0x02000200, 0x00020200, 0x02020200, - 0x00000002, 0x02000002, 0x00020002, 0x02020002, - 0x00000202, 0x02000202, 0x00020202, 0x02020202, - 0x01000000, 0x03000000, 0x01020000, 0x03020000, - 0x01000200, 0x03000200, 0x01020200, 0x03020200, - 0x01000002, 0x03000002, 0x01020002, 0x03020002, - 0x01000202, 0x03000202, 0x01020202, 0x03020202, - 0x00010000, 0x02010000, 0x00030000, 0x02030000, - 0x00010200, 0x02010200, 0x00030200, 0x02030200, - 0x00010002, 0x02010002, 0x00030002, 0x02030002, - 0x00010202, 0x02010202, 0x00030202, 0x02030202, - 0x01010000, 0x03010000, 0x01030000, 0x03030000, - 0x01010200, 0x03010200, 0x01030200, 0x03030200, - 0x01010002, 0x03010002, 0x01030002, 0x03030002, - 0x01010202, 0x03010202, 0x01030202, 0x03030202, - 0x00000100, 0x02000100, 0x00020100, 0x02020100, - 0x00000300, 0x02000300, 0x00020300, 0x02020300, - 0x00000102, 0x02000102, 0x00020102, 0x02020102, - 0x00000302, 0x02000302, 0x00020302, 0x02020302, - 0x01000100, 0x03000100, 0x01020100, 0x03020100, - 0x01000300, 0x03000300, 0x01020300, 0x03020300, - 0x01000102, 0x03000102, 0x01020102, 0x03020102, - 0x01000302, 0x03000302, 0x01020302, 0x03020302, - 0x00010100, 0x02010100, 0x00030100, 0x02030100, - 0x00010300, 0x02010300, 0x00030300, 0x02030300, - 0x00010102, 0x02010102, 0x00030102, 0x02030102, - 0x00010302, 0x02010302, 0x00030302, 0x02030302, - 0x01010100, 0x03010100, 0x01030100, 0x03030100, - 0x01010300, 0x03010300, 0x01030300, 0x03030300, - 0x01010102, 0x03010102, 0x01030102, 0x03030102, - 0x01010302, 0x03010302, 0x01030302, 0x03030302, - 0x00000001, 0x02000001, 0x00020001, 0x02020001, - 0x00000201, 0x02000201, 0x00020201, 0x02020201, - 0x00000003, 0x02000003, 0x00020003, 0x02020003, - 0x00000203, 0x02000203, 0x00020203, 0x02020203, - 0x01000001, 0x03000001, 0x01020001, 0x03020001, - 0x01000201, 0x03000201, 0x01020201, 0x03020201, - 0x01000003, 0x03000003, 0x01020003, 0x03020003, - 0x01000203, 0x03000203, 0x01020203, 0x03020203, - 0x00010001, 0x02010001, 0x00030001, 0x02030001, - 0x00010201, 0x02010201, 0x00030201, 0x02030201, - 0x00010003, 0x02010003, 0x00030003, 0x02030003, - 0x00010203, 0x02010203, 0x00030203, 0x02030203, - 0x01010001, 0x03010001, 0x01030001, 0x03030001, - 0x01010201, 0x03010201, 0x01030201, 0x03030201, - 0x01010003, 0x03010003, 0x01030003, 0x03030003, - 0x01010203, 0x03010203, 0x01030203, 0x03030203, - 0x00000101, 0x02000101, 0x00020101, 0x02020101, - 0x00000301, 0x02000301, 0x00020301, 0x02020301, - 0x00000103, 0x02000103, 0x00020103, 0x02020103, - 0x00000303, 0x02000303, 0x00020303, 0x02020303, - 0x01000101, 0x03000101, 0x01020101, 0x03020101, - 0x01000301, 0x03000301, 0x01020301, 0x03020301, - 0x01000103, 0x03000103, 0x01020103, 0x03020103, - 0x01000303, 0x03000303, 0x01020303, 0x03020303, - 0x00010101, 0x02010101, 0x00030101, 0x02030101, - 0x00010301, 0x02010301, 0x00030301, 0x02030301, - 0x00010103, 0x02010103, 0x00030103, 0x02030103, - 0x00010303, 0x02010303, 0x00030303, 0x02030303, - 0x01010101, 0x03010101, 0x01030101, 0x03030101, - 0x01010301, 0x03010301, 0x01030301, 0x03030301, - 0x01010103, 0x03010103, 0x01030103, 0x03030103, - 0x01010303, 0x03010303, 0x01030303, 0x03030303 -}; -#else - /* - * Byte swapped for little end machines. - */ -static U_LONG FP[256] = { - 0x00000000, 0x00000002, 0x00000200, 0x00000202, - 0x00020000, 0x00020002, 0x00020200, 0x00020202, - 0x02000000, 0x02000002, 0x02000200, 0x02000202, - 0x02020000, 0x02020002, 0x02020200, 0x02020202, - 0x00000001, 0x00000003, 0x00000201, 0x00000203, - 0x00020001, 0x00020003, 0x00020201, 0x00020203, - 0x02000001, 0x02000003, 0x02000201, 0x02000203, - 0x02020001, 0x02020003, 0x02020201, 0x02020203, - 0x00000100, 0x00000102, 0x00000300, 0x00000302, - 0x00020100, 0x00020102, 0x00020300, 0x00020302, - 0x02000100, 0x02000102, 0x02000300, 0x02000302, - 0x02020100, 0x02020102, 0x02020300, 0x02020302, - 0x00000101, 0x00000103, 0x00000301, 0x00000303, - 0x00020101, 0x00020103, 0x00020301, 0x00020303, - 0x02000101, 0x02000103, 0x02000301, 0x02000303, - 0x02020101, 0x02020103, 0x02020301, 0x02020303, - 0x00010000, 0x00010002, 0x00010200, 0x00010202, - 0x00030000, 0x00030002, 0x00030200, 0x00030202, - 0x02010000, 0x02010002, 0x02010200, 0x02010202, - 0x02030000, 0x02030002, 0x02030200, 0x02030202, - 0x00010001, 0x00010003, 0x00010201, 0x00010203, - 0x00030001, 0x00030003, 0x00030201, 0x00030203, - 0x02010001, 0x02010003, 0x02010201, 0x02010203, - 0x02030001, 0x02030003, 0x02030201, 0x02030203, - 0x00010100, 0x00010102, 0x00010300, 0x00010302, - 0x00030100, 0x00030102, 0x00030300, 0x00030302, - 0x02010100, 0x02010102, 0x02010300, 0x02010302, - 0x02030100, 0x02030102, 0x02030300, 0x02030302, - 0x00010101, 0x00010103, 0x00010301, 0x00010303, - 0x00030101, 0x00030103, 0x00030301, 0x00030303, - 0x02010101, 0x02010103, 0x02010301, 0x02010303, - 0x02030101, 0x02030103, 0x02030301, 0x02030303, - 0x01000000, 0x01000002, 0x01000200, 0x01000202, - 0x01020000, 0x01020002, 0x01020200, 0x01020202, - 0x03000000, 0x03000002, 0x03000200, 0x03000202, - 0x03020000, 0x03020002, 0x03020200, 0x03020202, - 0x01000001, 0x01000003, 0x01000201, 0x01000203, - 0x01020001, 0x01020003, 0x01020201, 0x01020203, - 0x03000001, 0x03000003, 0x03000201, 0x03000203, - 0x03020001, 0x03020003, 0x03020201, 0x03020203, - 0x01000100, 0x01000102, 0x01000300, 0x01000302, - 0x01020100, 0x01020102, 0x01020300, 0x01020302, - 0x03000100, 0x03000102, 0x03000300, 0x03000302, - 0x03020100, 0x03020102, 0x03020300, 0x03020302, - 0x01000101, 0x01000103, 0x01000301, 0x01000303, - 0x01020101, 0x01020103, 0x01020301, 0x01020303, - 0x03000101, 0x03000103, 0x03000301, 0x03000303, - 0x03020101, 0x03020103, 0x03020301, 0x03020303, - 0x01010000, 0x01010002, 0x01010200, 0x01010202, - 0x01030000, 0x01030002, 0x01030200, 0x01030202, - 0x03010000, 0x03010002, 0x03010200, 0x03010202, - 0x03030000, 0x03030002, 0x03030200, 0x03030202, - 0x01010001, 0x01010003, 0x01010201, 0x01010203, - 0x01030001, 0x01030003, 0x01030201, 0x01030203, - 0x03010001, 0x03010003, 0x03010201, 0x03010203, - 0x03030001, 0x03030003, 0x03030201, 0x03030203, - 0x01010100, 0x01010102, 0x01010300, 0x01010302, - 0x01030100, 0x01030102, 0x01030300, 0x01030302, - 0x03010100, 0x03010102, 0x03010300, 0x03010302, - 0x03030100, 0x03030102, 0x03030300, 0x03030302, - 0x01010101, 0x01010103, 0x01010301, 0x01010303, - 0x01030101, 0x01030103, 0x01030301, 0x01030303, - 0x03010101, 0x03010103, 0x03010301, 0x03010303, - 0x03030101, 0x03030103, 0x03030301, 0x03030303 -}; -#endif - - -/* - * The SP table is actually the S boxes and the P permutation - * table combined. - */ -static U_LONG SP[8][64] = { - { 0x00808200, 0x00000000, 0x00008000, 0x00808202, - 0x00808002, 0x00008202, 0x00000002, 0x00008000, - 0x00000200, 0x00808200, 0x00808202, 0x00000200, - 0x00800202, 0x00808002, 0x00800000, 0x00000002, - 0x00000202, 0x00800200, 0x00800200, 0x00008200, - 0x00008200, 0x00808000, 0x00808000, 0x00800202, - 0x00008002, 0x00800002, 0x00800002, 0x00008002, - 0x00000000, 0x00000202, 0x00008202, 0x00800000, - 0x00008000, 0x00808202, 0x00000002, 0x00808000, - 0x00808200, 0x00800000, 0x00800000, 0x00000200, - 0x00808002, 0x00008000, 0x00008200, 0x00800002, - 0x00000200, 0x00000002, 0x00800202, 0x00008202, - 0x00808202, 0x00008002, 0x00808000, 0x00800202, - 0x00800002, 0x00000202, 0x00008202, 0x00808200, - 0x00000202, 0x00800200, 0x00800200, 0x00000000, - 0x00008002, 0x00008200, 0x00000000, 0x00808002 }, - - { 0x40084010, 0x40004000, 0x00004000, 0x00084010, - 0x00080000, 0x00000010, 0x40080010, 0x40004010, - 0x40000010, 0x40084010, 0x40084000, 0x40000000, - 0x40004000, 0x00080000, 0x00000010, 0x40080010, - 0x00084000, 0x00080010, 0x40004010, 0x00000000, - 0x40000000, 0x00004000, 0x00084010, 0x40080000, - 0x00080010, 0x40000010, 0x00000000, 0x00084000, - 0x00004010, 0x40084000, 0x40080000, 0x00004010, - 0x00000000, 0x00084010, 0x40080010, 0x00080000, - 0x40004010, 0x40080000, 0x40084000, 0x00004000, - 0x40080000, 0x40004000, 0x00000010, 0x40084010, - 0x00084010, 0x00000010, 0x00004000, 0x40000000, - 0x00004010, 0x40084000, 0x00080000, 0x40000010, - 0x00080010, 0x40004010, 0x40000010, 0x00080010, - 0x00084000, 0x00000000, 0x40004000, 0x00004010, - 0x40000000, 0x40080010, 0x40084010, 0x00084000 }, - - { 0x00000104, 0x04010100, 0x00000000, 0x04010004, - 0x04000100, 0x00000000, 0x00010104, 0x04000100, - 0x00010004, 0x04000004, 0x04000004, 0x00010000, - 0x04010104, 0x00010004, 0x04010000, 0x00000104, - 0x04000000, 0x00000004, 0x04010100, 0x00000100, - 0x00010100, 0x04010000, 0x04010004, 0x00010104, - 0x04000104, 0x00010100, 0x00010000, 0x04000104, - 0x00000004, 0x04010104, 0x00000100, 0x04000000, - 0x04010100, 0x04000000, 0x00010004, 0x00000104, - 0x00010000, 0x04010100, 0x04000100, 0x00000000, - 0x00000100, 0x00010004, 0x04010104, 0x04000100, - 0x04000004, 0x00000100, 0x00000000, 0x04010004, - 0x04000104, 0x00010000, 0x04000000, 0x04010104, - 0x00000004, 0x00010104, 0x00010100, 0x04000004, - 0x04010000, 0x04000104, 0x00000104, 0x04010000, - 0x00010104, 0x00000004, 0x04010004, 0x00010100 }, - - { 0x80401000, 0x80001040, 0x80001040, 0x00000040, - 0x00401040, 0x80400040, 0x80400000, 0x80001000, - 0x00000000, 0x00401000, 0x00401000, 0x80401040, - 0x80000040, 0x00000000, 0x00400040, 0x80400000, - 0x80000000, 0x00001000, 0x00400000, 0x80401000, - 0x00000040, 0x00400000, 0x80001000, 0x00001040, - 0x80400040, 0x80000000, 0x00001040, 0x00400040, - 0x00001000, 0x00401040, 0x80401040, 0x80000040, - 0x00400040, 0x80400000, 0x00401000, 0x80401040, - 0x80000040, 0x00000000, 0x00000000, 0x00401000, - 0x00001040, 0x00400040, 0x80400040, 0x80000000, - 0x80401000, 0x80001040, 0x80001040, 0x00000040, - 0x80401040, 0x80000040, 0x80000000, 0x00001000, - 0x80400000, 0x80001000, 0x00401040, 0x80400040, - 0x80001000, 0x00001040, 0x00400000, 0x80401000, - 0x00000040, 0x00400000, 0x00001000, 0x00401040 }, - - { 0x00000080, 0x01040080, 0x01040000, 0x21000080, - 0x00040000, 0x00000080, 0x20000000, 0x01040000, - 0x20040080, 0x00040000, 0x01000080, 0x20040080, - 0x21000080, 0x21040000, 0x00040080, 0x20000000, - 0x01000000, 0x20040000, 0x20040000, 0x00000000, - 0x20000080, 0x21040080, 0x21040080, 0x01000080, - 0x21040000, 0x20000080, 0x00000000, 0x21000000, - 0x01040080, 0x01000000, 0x21000000, 0x00040080, - 0x00040000, 0x21000080, 0x00000080, 0x01000000, - 0x20000000, 0x01040000, 0x21000080, 0x20040080, - 0x01000080, 0x20000000, 0x21040000, 0x01040080, - 0x20040080, 0x00000080, 0x01000000, 0x21040000, - 0x21040080, 0x00040080, 0x21000000, 0x21040080, - 0x01040000, 0x00000000, 0x20040000, 0x21000000, - 0x00040080, 0x01000080, 0x20000080, 0x00040000, - 0x00000000, 0x20040000, 0x01040080, 0x20000080 }, - - { 0x10000008, 0x10200000, 0x00002000, 0x10202008, - 0x10200000, 0x00000008, 0x10202008, 0x00200000, - 0x10002000, 0x00202008, 0x00200000, 0x10000008, - 0x00200008, 0x10002000, 0x10000000, 0x00002008, - 0x00000000, 0x00200008, 0x10002008, 0x00002000, - 0x00202000, 0x10002008, 0x00000008, 0x10200008, - 0x10200008, 0x00000000, 0x00202008, 0x10202000, - 0x00002008, 0x00202000, 0x10202000, 0x10000000, - 0x10002000, 0x00000008, 0x10200008, 0x00202000, - 0x10202008, 0x00200000, 0x00002008, 0x10000008, - 0x00200000, 0x10002000, 0x10000000, 0x00002008, - 0x10000008, 0x10202008, 0x00202000, 0x10200000, - 0x00202008, 0x10202000, 0x00000000, 0x10200008, - 0x00000008, 0x00002000, 0x10200000, 0x00202008, - 0x00002000, 0x00200008, 0x10002008, 0x00000000, - 0x10202000, 0x10000000, 0x00200008, 0x10002008 }, - - { 0x00100000, 0x02100001, 0x02000401, 0x00000000, - 0x00000400, 0x02000401, 0x00100401, 0x02100400, - 0x02100401, 0x00100000, 0x00000000, 0x02000001, - 0x00000001, 0x02000000, 0x02100001, 0x00000401, - 0x02000400, 0x00100401, 0x00100001, 0x02000400, - 0x02000001, 0x02100000, 0x02100400, 0x00100001, - 0x02100000, 0x00000400, 0x00000401, 0x02100401, - 0x00100400, 0x00000001, 0x02000000, 0x00100400, - 0x02000000, 0x00100400, 0x00100000, 0x02000401, - 0x02000401, 0x02100001, 0x02100001, 0x00000001, - 0x00100001, 0x02000000, 0x02000400, 0x00100000, - 0x02100400, 0x00000401, 0x00100401, 0x02100400, - 0x00000401, 0x02000001, 0x02100401, 0x02100000, - 0x00100400, 0x00000000, 0x00000001, 0x02100401, - 0x00000000, 0x00100401, 0x02100000, 0x00000400, - 0x02000001, 0x02000400, 0x00000400, 0x00100001 }, - - { 0x08000820, 0x00000800, 0x00020000, 0x08020820, - 0x08000000, 0x08000820, 0x00000020, 0x08000000, - 0x00020020, 0x08020000, 0x08020820, 0x00020800, - 0x08020800, 0x00020820, 0x00000800, 0x00000020, - 0x08020000, 0x08000020, 0x08000800, 0x00000820, - 0x00020800, 0x00020020, 0x08020020, 0x08020800, - 0x00000820, 0x00000000, 0x00000000, 0x08020020, - 0x08000020, 0x08000800, 0x00020820, 0x00020000, - 0x00020820, 0x00020000, 0x08020800, 0x00000800, - 0x00000020, 0x08020020, 0x00000800, 0x00020820, - 0x08000800, 0x00000020, 0x08000020, 0x08020000, - 0x08020020, 0x08000000, 0x00020000, 0x08000820, - 0x00000000, 0x08020820, 0x00020020, 0x08000020, - 0x08020000, 0x08000800, 0x08000820, 0x00000000, - 0x08020820, 0x00020800, 0x00020800, 0x00000820, - 0x00000820, 0x00020020, 0x08000000, 0x08020800 } -}; - - - -/* - * DESauth_des - perform an in place DES encryption on 64 bits - * - * Note that the `data' argument is always in big-end-first - * byte order, i.e. *(char *)data is the high order byte of - * the 8 byte data word. We modify the initial and final - * permutation computations for little-end-first machines to - * swap bytes into the natural host order at the beginning and - * back to big-end order at the end. This is unclean but avoids - * a byte swapping performance penalty on Vaxes (which are slow already). - */ -void -DESauth_des(data, subkeys) - U_LONG *data; - u_char *subkeys; -{ - register U_LONG left, right; - register U_LONG temp; - register u_char *kp; - register int i; - - /* - * Do the initial permutation. The first operation gets - * all the bits which are used to form the left half of the - * permutted result in one word, which is then used to - * index the appropriate table a byte at a time. - */ - temp = ((*data & 0x55555555) << 1) | (*(data+1) & 0x55555555); -#ifdef XNTP_LITTLE_ENDIAN - /* - * Modify the computation to use the opposite set of bytes. - */ - left = (IP[(temp >> 24) & 0xff] << 3) - | (IP[(temp >> 16) & 0xff] << 2) - | (IP[(temp >> 8) & 0xff] << 1) - | IP[temp & 0xff]; -#else - left = IP[(temp >> 24) & 0xff] - | (IP[(temp >> 16) & 0xff] << 1) - | (IP[(temp >> 8) & 0xff] << 2) - | (IP[temp & 0xff] << 3); -#endif - - /* - * Same thing again except for the right half. - */ - temp = (*data & 0xaaaaaaaa) | ((*(data+1) & 0xaaaaaaaa) >> 1); -#ifdef XNTP_LITTLE_ENDIAN - right = (IP[(temp >> 24) & 0xff] << 3) - | (IP[(temp >> 16) & 0xff] << 2) - | (IP[(temp >> 8) & 0xff] << 1) - | IP[temp & 0xff]; -#else - right = IP[(temp >> 24) & 0xff] - | (IP[(temp >> 16) & 0xff] << 1) - | (IP[(temp >> 8) & 0xff] << 2) - | (IP[temp & 0xff] << 3); -#endif - - /* - * Do the 16 rounds through the cipher function. We actually - * do two at a time, one on the left half and one on the right - * half. - */ - kp = subkeys; - for (i = 0; i < 8; i++) { - /* - * The E expansion is easy to compute algorithmically. - * Take a look at its form and compare it to - * everything involving temp below. Note that - * since SP[0-7] don't have any bits in common set - * it is okay to do the successive xor's. - */ - temp = (right >> 1) | ((right & 1) ? 0x80000000 : 0); - left ^= SP[0][((temp >> 26) & 0x3f) ^ *kp++]; - left ^= SP[1][((temp >> 22) & 0x3f) ^ *kp++]; - left ^= SP[2][((temp >> 18) & 0x3f) ^ *kp++]; - left ^= SP[3][((temp >> 14) & 0x3f) ^ *kp++]; - left ^= SP[4][((temp >> 10) & 0x3f) ^ *kp++]; - left ^= SP[5][((temp >> 6) & 0x3f) ^ *kp++]; - left ^= SP[6][((temp >> 2) & 0x3f) ^ *kp++]; - left ^= SP[7][(((right << 1) | ((right & 0x80000000)?1:0)) - & 0x3f) ^ *kp++]; - - /* - * Careful here. Right now `right' is actually the - * left side and `left' is the right side. Do the - * same thing again, except swap `left' and `right' - */ - temp = (left >> 1) | ((left & 1) ? 0x80000000 : 0); - right ^= SP[0][((temp >> 26) & 0x3f) ^ *kp++]; - right ^= SP[1][((temp >> 22) & 0x3f) ^ *kp++]; - right ^= SP[2][((temp >> 18) & 0x3f) ^ *kp++]; - right ^= SP[3][((temp >> 14) & 0x3f) ^ *kp++]; - right ^= SP[4][((temp >> 10) & 0x3f) ^ *kp++]; - right ^= SP[5][((temp >> 6) & 0x3f) ^ *kp++]; - right ^= SP[6][((temp >> 2) & 0x3f) ^ *kp++]; - right ^= SP[7][(((left << 1) | ((left & 0x80000000)?1:0)) - & 0x3f) ^ *kp++]; - - /* - * By the time we get here, all is straightened out - * again. `left' is left and `right' is right. - */ - } - - /* - * Now the final permutation. Note this is like the IP above - * except that the data is computed from - * - * ((left & 0x0f0f0f0f) << 4) | (right & 0x0f0f0f0f) for left result - * (left & 0xf0f0f0f0) | ((right & 0xf0f0f0f0) >> 4) for right result - * - * Just to confuse things more, we're supposed to swap the right - * and the left halves before doing this. Instead, we'll just - * switch which goes where when computing the temporary. - * - * This operation also byte swaps stuff back into big end byte - * order. This is accomplished by modifying the FP table for - * little end machines, however, so we don't have to worry about - * it here. - */ - temp = ((right & 0x0f0f0f0f) << 4) | (left & 0x0f0f0f0f); - *data = (FP[(temp >> 24) & 0xff] << 6) - | (FP[(temp >> 16) & 0xff] << 4) - | (FP[(temp >> 8) & 0xff] << 2) - | FP[temp & 0xff]; - - temp = (right & 0xf0f0f0f0) | ((left & 0xf0f0f0f0) >> 4); - *(data+1) = (FP[(temp >> 24) & 0xff] << 6) - | (FP[(temp >> 16) & 0xff] << 4) - | (FP[(temp >> 8) & 0xff] << 2) - | FP[temp & 0xff]; -} diff --git a/usr.sbin/xntpd/machines/README b/usr.sbin/xntpd/machines/README deleted file mode 100644 index b12db88d9c61..000000000000 --- a/usr.sbin/xntpd/machines/README +++ /dev/null @@ -1,5 +0,0 @@ -README file for directory ./machines of the NTP Version 3 distribution - -This directory contains configuration files for the various machines -and compilers supported by the distribution. README and RELNOTES files in the -parent directory contain directions on how to use these files. diff --git a/usr.sbin/xntpd/machines/aix3.2 b/usr.sbin/xntpd/machines/aix3.2 deleted file mode 100644 index 93a0181ca63d..000000000000 --- a/usr.sbin/xntpd/machines/aix3.2 +++ /dev/null @@ -1,10 +0,0 @@ -RANLIB= : -DEFS_LOCAL= -DREFCLOCK -DEFS= -DRS6000 -DSYS_AIX -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -INSTALL= /usr/ucb/install -COPTS= -O -COMPAT= diff --git a/usr.sbin/xntpd/machines/aux2 b/usr.sbin/xntpd/machines/aux2 deleted file mode 100644 index 0aa8ee0528f8..000000000000 --- a/usr.sbin/xntpd/machines/aux2 +++ /dev/null @@ -1,9 +0,0 @@ -RANLIB= true # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_AUX2 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -DFASTMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COMPAT= -lposix -lbsd -lmalloc -s -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/aux3 b/usr.sbin/xntpd/machines/aux3 deleted file mode 100644 index 1c6313b37ec9..000000000000 --- a/usr.sbin/xntpd/machines/aux3 +++ /dev/null @@ -1,9 +0,0 @@ -RANLIB= true # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_AUX3 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -DFASTMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COMPAT= -lposix -lbsd -lmalloc -s -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/bsdi b/usr.sbin/xntpd/machines/bsdi deleted file mode 100644 index 3145bd63984e..000000000000 --- a/usr.sbin/xntpd/machines/bsdi +++ /dev/null @@ -1,8 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_BSDI -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lkvm -RESLIB= -COPTS= -g -O diff --git a/usr.sbin/xntpd/machines/convexos10 b/usr.sbin/xntpd/machines/convexos10 deleted file mode 100644 index 39eb38456c6f..000000000000 --- a/usr.sbin/xntpd/machines/convexos10 +++ /dev/null @@ -1,10 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_CONVEXOS10 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= - diff --git a/usr.sbin/xntpd/machines/convexos9 b/usr.sbin/xntpd/machines/convexos9 deleted file mode 100644 index a0276b8f4ca5..000000000000 --- a/usr.sbin/xntpd/machines/convexos9 +++ /dev/null @@ -1,9 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_CONVEXOS9 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= diff --git a/usr.sbin/xntpd/machines/decosf1 b/usr.sbin/xntpd/machines/decosf1 deleted file mode 100644 index 0f9235163d24..000000000000 --- a/usr.sbin/xntpd/machines/decosf1 +++ /dev/null @@ -1,9 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSTREAM -DSYS_DECOSF1 -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/dell.svr4 b/usr.sbin/xntpd/machines/dell.svr4 deleted file mode 100644 index 5b53a2b16a4f..000000000000 --- a/usr.sbin/xntpd/machines/dell.svr4 +++ /dev/null @@ -1,9 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_SVR4 -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -lnsl -lsocket -lelf -INSTALL= /usr/ucb/install diff --git a/usr.sbin/xntpd/machines/domainos b/usr.sbin/xntpd/machines/domainos deleted file mode 100644 index 0ca6713304c2..000000000000 --- a/usr.sbin/xntpd/machines/domainos +++ /dev/null @@ -1,7 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -COMPAT= diff --git a/usr.sbin/xntpd/machines/freebsd b/usr.sbin/xntpd/machines/freebsd deleted file mode 100644 index 9380c0e8455d..000000000000 --- a/usr.sbin/xntpd/machines/freebsd +++ /dev/null @@ -1,8 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_FREEBSD -DSYS_386BSD -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lcrypt -RESLIB= -COPTS= -O2 diff --git a/usr.sbin/xntpd/machines/hpux b/usr.sbin/xntpd/machines/hpux deleted file mode 100644 index fdb07897c900..000000000000 --- a/usr.sbin/xntpd/machines/hpux +++ /dev/null @@ -1,8 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_TERMIOS -DSYS_HPUX=8 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -COPTS= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/hpux-adj b/usr.sbin/xntpd/machines/hpux-adj deleted file mode 100644 index 0119b6329d7e..000000000000 --- a/usr.sbin/xntpd/machines/hpux-adj +++ /dev/null @@ -1,8 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_TERMIOS -DSYS_HPUX=10 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -COPTS= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/hpux10+ b/usr.sbin/xntpd/machines/hpux10+ deleted file mode 100644 index 0119b6329d7e..000000000000 --- a/usr.sbin/xntpd/machines/hpux10+ +++ /dev/null @@ -1,8 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_TERMIOS -DSYS_HPUX=10 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -COPTS= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/i386 b/usr.sbin/xntpd/machines/i386 deleted file mode 100644 index c5d93572061d..000000000000 --- a/usr.sbin/xntpd/machines/i386 +++ /dev/null @@ -1,7 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_I386 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -COMPAT= diff --git a/usr.sbin/xntpd/machines/i386svr4 b/usr.sbin/xntpd/machines/i386svr4 deleted file mode 100644 index bc3fadb96c36..000000000000 --- a/usr.sbin/xntpd/machines/i386svr4 +++ /dev/null @@ -1,9 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -lnsl -lsocket -lelf -INSTALL= /usr/ucb/install diff --git a/usr.sbin/xntpd/machines/irix4 b/usr.sbin/xntpd/machines/irix4 deleted file mode 100644 index ae2bbf8ba8d8..000000000000 --- a/usr.sbin/xntpd/machines/irix4 +++ /dev/null @@ -1,9 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_SYSV_TTYS -DSYS_IRIX4 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lmld -RESLIB= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/irix5 b/usr.sbin/xntpd/machines/irix5 deleted file mode 100644 index a808b9767c49..000000000000 --- a/usr.sbin/xntpd/machines/irix5 +++ /dev/null @@ -1,9 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_SYSV_TTYS -DSYS_IRIX5 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lmld -RESLIB= -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/linux b/usr.sbin/xntpd/machines/linux deleted file mode 100644 index d7a8ac4e1871..000000000000 --- a/usr.sbin/xntpd/machines/linux +++ /dev/null @@ -1,8 +0,0 @@ -SHELL= /bin/sh -RANLIB= ranlib -DEFS= -DSYS_LINUX -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -INCL= -I../include -I/usr/include/bsd -CLOCKDEFS= -DAEMONLIBS= -COMPAT= diff --git a/usr.sbin/xntpd/machines/mips b/usr.sbin/xntpd/machines/mips deleted file mode 100644 index a624e8f9f866..000000000000 --- a/usr.sbin/xntpd/machines/mips +++ /dev/null @@ -1,9 +0,0 @@ -#RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_MIPS -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lmld -RESLIB= -COMPAT= - diff --git a/usr.sbin/xntpd/machines/netbsd b/usr.sbin/xntpd/machines/netbsd deleted file mode 100644 index 1cfd8e1080ad..000000000000 --- a/usr.sbin/xntpd/machines/netbsd +++ /dev/null @@ -1,8 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_NETBSD -DSYS_386BSD -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lcrypt -lutil -RESLIB= -COPTS= -O diff --git a/usr.sbin/xntpd/machines/next b/usr.sbin/xntpd/machines/next deleted file mode 100644 index 9125f7d31dfb..000000000000 --- a/usr.sbin/xntpd/machines/next +++ /dev/null @@ -1,9 +0,0 @@ -RANLIB= ranlib -c -s -DEFS= -DSYS_NEXT -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -DFAST_MD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -O -pipe -COMPAT= - diff --git a/usr.sbin/xntpd/machines/ptx b/usr.sbin/xntpd/machines/ptx deleted file mode 100644 index 4759851a4724..000000000000 --- a/usr.sbin/xntpd/machines/ptx +++ /dev/null @@ -1,8 +0,0 @@ -RANLIB= : -DEFS_LOCAL= -DREFCLOCK -DEFS= -DREADKMEM -DSYS_PTX -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -lseq -lsocket -linet -lnsl -COPTS= -O diff --git a/usr.sbin/xntpd/machines/sequent b/usr.sbin/xntpd/machines/sequent deleted file mode 100644 index 9962788cb981..000000000000 --- a/usr.sbin/xntpd/machines/sequent +++ /dev/null @@ -1,8 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -O diff --git a/usr.sbin/xntpd/machines/sinix-m b/usr.sbin/xntpd/machines/sinix-m deleted file mode 100644 index fb01a0135f41..000000000000 --- a/usr.sbin/xntpd/machines/sinix-m +++ /dev/null @@ -1,11 +0,0 @@ -RANLIB= : -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSYS_SINIXM -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= -lsocket -lnsl -lelf -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/sony b/usr.sbin/xntpd/machines/sony deleted file mode 100644 index 890e9f539aa0..000000000000 --- a/usr.sbin/xntpd/machines/sony +++ /dev/null @@ -1,6 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_SONY -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lmld diff --git a/usr.sbin/xntpd/machines/sunos4.bsd b/usr.sbin/xntpd/machines/sunos4.bsd deleted file mode 100644 index f18ffda25e44..000000000000 --- a/usr.sbin/xntpd/machines/sunos4.bsd +++ /dev/null @@ -1,11 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_SUNOS4 -DHAVE_BSD_TTYS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lkvm -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= - diff --git a/usr.sbin/xntpd/machines/sunos4.posix b/usr.sbin/xntpd/machines/sunos4.posix deleted file mode 100644 index 86716e18c2ae..000000000000 --- a/usr.sbin/xntpd/machines/sunos4.posix +++ /dev/null @@ -1,11 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSTREAM -DSYS_SUNOS4 -DNTP_POSIX_SOURCE -DHAVE_SIGNALED_IO -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -lkvm -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= - diff --git a/usr.sbin/xntpd/machines/sunos5.1 b/usr.sbin/xntpd/machines/sunos5.1 deleted file mode 100644 index 16ab8ff00872..000000000000 --- a/usr.sbin/xntpd/machines/sunos5.1 +++ /dev/null @@ -1,11 +0,0 @@ -RANLIB= : -DEFS_LOCAL=-DREFCLOCK -DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= -lsocket -lnsl -lelf -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/sunos5.2 b/usr.sbin/xntpd/machines/sunos5.2 deleted file mode 100644 index 3e09c15714e0..000000000000 --- a/usr.sbin/xntpd/machines/sunos5.2 +++ /dev/null @@ -1,11 +0,0 @@ -RANLIB= : -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= -COPTS= -O -ADJLIB= -COMPAT= -lsocket -lnsl -lelf -INSTALL=$(TOP)scripts/install.sh diff --git a/usr.sbin/xntpd/machines/svr4 b/usr.sbin/xntpd/machines/svr4 deleted file mode 100644 index 63997b6c2bda..000000000000 --- a/usr.sbin/xntpd/machines/svr4 +++ /dev/null @@ -1,10 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DAEMONLIBS= -lnet -lnsl -lsocket -lelf -RESLIB= -lnet -lnsl -lsocket -lelf -INSTALL=$(TOP)scripts/install.sh -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V diff --git a/usr.sbin/xntpd/machines/ultrix.bsd b/usr.sbin/xntpd/machines/ultrix.bsd deleted file mode 100644 index a8e9f1dc340f..000000000000 --- a/usr.sbin/xntpd/machines/ultrix.bsd +++ /dev/null @@ -1,7 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_ULTRIX -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -COMPAT= diff --git a/usr.sbin/xntpd/machines/ultrix.posix b/usr.sbin/xntpd/machines/ultrix.posix deleted file mode 100644 index 7db6993e142f..000000000000 --- a/usr.sbin/xntpd/machines/ultrix.posix +++ /dev/null @@ -1,7 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_ULTRIX -DNTP_POSIX_SOURCE -DHAVE_SIGNALED_IO -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -COMPAT= diff --git a/usr.sbin/xntpd/machines/univel b/usr.sbin/xntpd/machines/univel deleted file mode 100644 index 23d683a661aa..000000000000 --- a/usr.sbin/xntpd/machines/univel +++ /dev/null @@ -1,10 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS= -DSYS_UNIVEL -DSTREAMS_TLI -DHAVE_TERMIOS -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DAEMONLIBS= -lnsl -lsocket -lelf -RESLIB= -lnsl -lsocket -lelf -INSTALL=$(TOP)scripts/install.sh -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V diff --git a/usr.sbin/xntpd/machines/unixware1 b/usr.sbin/xntpd/machines/unixware1 deleted file mode 100644 index 770737676d86..000000000000 --- a/usr.sbin/xntpd/machines/unixware1 +++ /dev/null @@ -1,10 +0,0 @@ -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS= -DSYS_UNIXWARE1 -DSTREAMS_TLI -DHAVE_TERMIOS -DCONFIG_FILE=\\"/usr/local/etc/ntp.conf\\" -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DAEMONLIBS= -lnsl -lsocket -lelf -RESLIB= -lnsl -lsocket -lelf -INSTALL=$(TOP)scripts/install.sh -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V diff --git a/usr.sbin/xntpd/machines/vax b/usr.sbin/xntpd/machines/vax deleted file mode 100644 index 55e8c442cc40..000000000000 --- a/usr.sbin/xntpd/machines/vax +++ /dev/null @@ -1,6 +0,0 @@ -RANLIB= ranlib -DEFS_LOCAL= -DREFCLOCK -DEFS= -DSYS_VAX -DHAVE_BSD_TTYS -CLOCKDEFS= -DLOCAL_CLOCK -DAEMONLIBS= -RESLIB= diff --git a/usr.sbin/xntpd/ntpdate/Makefile.tmpl b/usr.sbin/xntpd/ntpdate/Makefile.tmpl deleted file mode 100644 index 34f8f666c4a4..000000000000 --- a/usr.sbin/xntpd/ntpdate/Makefile.tmpl +++ /dev/null @@ -1,70 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= ntpdate -# -# ntpdate - private mode query program for ntpdate -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -RESLIB= -ADJLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -OBJS= ntpdate.o -SOURCE= ntpdate.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(RESLIB) \ - $(ADJLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak lint.errs .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(DEFS_LOCAL) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version diff --git a/usr.sbin/xntpd/ntpq/Makefile.tmpl b/usr.sbin/xntpd/ntpq/Makefile.tmpl deleted file mode 100644 index 76a09ad6b7e1..000000000000 --- a/usr.sbin/xntpd/ntpq/Makefile.tmpl +++ /dev/null @@ -1,68 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= ntpq -# -# ntpq - control mode query program -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -RESLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -OBJS= ntpq.o ntpq_ops.o -SOURCE= ntpq.c ntpq_ops.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(RESLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak lint.errs .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(DEFS_LOCAL) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version diff --git a/usr.sbin/xntpd/ntptrace/Makefile.tmpl b/usr.sbin/xntpd/ntptrace/Makefile.tmpl deleted file mode 100644 index ca321f13931d..000000000000 --- a/usr.sbin/xntpd/ntptrace/Makefile.tmpl +++ /dev/null @@ -1,70 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= ntptrace -# -# ntptrace - private mode query program for ntptrace -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -RESLIB= -ADJLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -OBJS= ntptrace.o -SOURCE= ntptrace.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(RESLIB) \ - $(ADJLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak lint.errs .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(DEFS_LOCAL) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version diff --git a/usr.sbin/xntpd/parse/Makefile.kernel b/usr.sbin/xntpd/parse/Makefile.kernel deleted file mode 100644 index 4cd0acede737..000000000000 --- a/usr.sbin/xntpd/parse/Makefile.kernel +++ /dev/null @@ -1,76 +0,0 @@ -# -# very simple makefile (SunOS!) -# -# Possible defines: -# DEBUG_PARSE: include debug code (STREAMS mechanism and parsing) -# DEBUG_CD: include signal propagation to sun4c LED (sun4c only) -# -# Possible defines (parsestreams variants only): -# KERNEL: must define -# VDDRV: loadable driver support - recommended -# KARCH: must define at make call for correct kernel module -# (currently only needed for parsestreams variants) -# -KARCH= -DEFS=-DSTREAM -DKERNEL -DVDDRV -D$(KARCH) -MICROTIME=../ppsclock/sys/$(KARCH)/microtime.s - -all: - @if [ -f /kernel/unix ]; then \ - $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" KARCH="`(arch -k) 2>/dev/null || uname -a | awk '{ print $5 }'`" -f Makefile.kernel parse; \ - else \ - $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" KARCH="`(arch -k) 2>/dev/null || uname -a | awk '{ print $5 }'`" -f Makefile.kernel parsestreams.o; \ - fi - -parse: parsesolaris.c libparse_kernel.a ../lib/libntp.a - @echo "--- WARNING: SunOS5 support is fresh and hardly tested" - @echo "--- This code could lead to kernel panics more" - @echo "--- easily than other streams modules" - $(CC) -c -I../include -D_KERNEL parsesolaris.c - ld -r -o parse parsesolaris.o libparse_kernel.a ../lib/libntp.a - @echo "--- Install 'parse' in /kernel/strmod for automatic loading" - -mparsestreams.o: mparsestreams.$(KARCH).o - @echo "--- You may load mparsestreams.$(KARCH).o via 'modload mparsestreams.$(KARCH).o' into the kernel" - -mparsestreams.$(KARCH).o: parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c - ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a \ - microtime.o - rm -f parsestreams.o - -parsestreams.o: parsestreams.$(KARCH).o - @echo "--- You may load parsestreams.$(KARCH).o via 'modload parsestreams.o' (put in e.g. /sys//OBJ) into the kernel" - -parsestreams.$(KARCH).o: parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c - ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a - rm -f parsestreams.o - -microtime.o: $(MICROTIME) assym.s - cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i - as -o $@ $@.i - rm -f $@.i assym.s - -assym.s: genassym - ./genassym > $@ - -genassym: ../ppsclock/sys/genassym/genassym.c - cc -o $@ $? - -libparse_kernel.a: - $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" libparse_kernel.a - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -lint: parsestreams.c ../include/parse.h ../include/sys/parsestreams.h ../lib/llib-llibntp.ln - lint -u -I../include $(DEFS) parsestreams.c ../lib/llib-llibntp.ln - -../lib/llib-llibntp.ln: - cd ../lib && make lintlib - -clean: - rm -f *.o genassym assym.s parsestreams - -distclean: clean diff --git a/usr.sbin/xntpd/parse/Makefile.tmpl b/usr.sbin/xntpd/parse/Makefile.tmpl deleted file mode 100644 index 781fed69e5d1..000000000000 --- a/usr.sbin/xntpd/parse/Makefile.tmpl +++ /dev/null @@ -1,111 +0,0 @@ -# -# /src/NTP/REPOSITORY/v3/parse/Makefile.tmpl,v 3.6 1993/10/10 22:44:36 kardel Exp -# -LIBNAME= libparse -KLIBNAME= libparse_kernel -# -# parse routine that could be used in two places -# -COMPILER= cc -COPTS= -O -AUTHDEFS=-DDES -LIBDEFS= -DBIG_ENDIAN -RANLIB= ranlib -INSTALL= install -CLOCKDEFS= -DEFS= -DEFS_OPT= -DEFS_LOCAL= -# -INCL=-I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -# -SOURCE= parse.c parse_conf.c clk_meinberg.c clk_schmid.c clk_rawdcf.c \ - clk_dcf7000.c clk_trimtaip.c clk_trimtsip.c - -OBJS= parse.o parse_conf.o clk_meinberg.o clk_schmid.o clk_rawdcf.o \ - clk_dcf7000.o clk_trimtaip.o clk_trimtsip.o - -all: - @echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \ - awk '/-DREFCLOCK/ && /-DPARSE/ && /-DCLOCK_/ { makeit=1; }\ - END { if (makeit) \ - { print "echo ; echo --- creating parse libraries ; $(MAKE) $(MFLAGS) MFLAGS=\"$(MFLAGS)\" MAKE=\"$(MAKE)\" libs"; } \ - else \ - { print "echo ; echo --- creating parse placebo libraries ; $(MAKE) $(MFLAGS) MFLAGS=\"$(MFLAGS)\" MAKE=\"$(MAKE)\" emptyplacebolibs";} }' |\ - sh - @echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \ - awk '/-DREFCLOCK/ && /-DPARSE/ && /-DCLOCK_/ {makeit=1; }\ - END { if (makeit) \ - { print "echo ; echo --- creating utility programs ; cd util && $(MAKE) $(MFLAGS) MFLAGS=\"$(MFLAGS)\" MAKE=\"$(MAKE)\" -k"; } \ - else \ - { print ":";} }' |\ - sh - @if (sun) > /dev/null 2>&1; then \ - echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS); \ - else :; fi | \ - awk '/-DSTREAM/ && /-DREFCLOCK/ && /-DPARSE/ && /-DCLOCK_/ { makeit=1; }\ - END { if (makeit) \ - { print "echo ; echo --- creating kernel files ; $(MAKE) $(MFLAGS) MFLAGS=\"$(MFLAGS)\" MAKE=\"$(MAKE)\" -f Makefile.kernel"; } \ - else \ - { print ":";} }' |\ - sh - -emptyplacebolibs: empty.c - @if [ ! -f "$(LIBNAME).a" -o ! -f "$(KLIBNAME).a" ]; then \ - $(CC) -c empty.c; \ - rm -f $(LIBNAME).a $(KLIBNAME).a; \ - ar r $(LIBNAME).a empty.o; \ - $(RANLIB) $(LIBNAME).a; \ - ar r $(KLIBNAME).a empty.o; \ - $(RANLIB) $(KLIBNAME).a; \ - rm -f empty.o; \ - else \ - : sorry guys - but i always get bitten by the broken ultrix sh; \ - fi - -libs: $(LIBNAME).a $(KLIBNAME).a - -$(LIBNAME).a: $(SOURCE) - $(CC) -c $(CFLAGS) $(CLOCKDEFS) -UPARSESTREAM $(SOURCE) - ar rv $@ $(OBJS) - rm -f $(OBJS) - $(RANLIB) $@ - -$(KLIBNAME).a: $(SOURCE) $(LIBNAME).a - $(CC) -c $(CFLAGS) $(CLOCKDEFS) -DPARSESTREAM $(SOURCE) - ar rv $@ $(OBJS) - rm -f $(OBJS) - $(RANLIB) $@ - -lintlib: llib-l$(LIBNAME).ln - -llib-l$(LIBNAME).ln: $(SOURCE) - lint -C$(LIBNAME) $(INCL) $(CLOCKDEFS) $(AUTHDEFS) $(LIBDEFS) $(SOURCE) >lintlib.errs - -lint: - lint -u $(DEFS) $(INCL) $(CLOCKDEFS) $(AUTHDEFS) $(LIBDEFS) $(SOURCE) >lint.errs - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(LIBNAME).a $(KLIBNAME).a *.o *.out *.ln make.log Makefile.bak \ - lintlib.errs lint.errs genassym assym.s parsestreams parse parsestreams.o.* - -@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl clean - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl distclean - -install: all - @echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \ - awk '/-DREFCLOCK/ && /-DPARSE/ && /-DCLOCK_/ { makeit=1; }\ - END { if (makeit) \ - { print "echo --- installing utility programs ; cd util && $(MAKE) MAKE=\"$(MAKE)\" $@"; } \ - else \ - { print ":";} }' |\ - sh - @echo "--- Kernel modules like "parse" or "parsestreams.o" must be installed manually" - @echo "--- if applicable." diff --git a/usr.sbin/xntpd/patches/patch.1 b/usr.sbin/xntpd/patches/patch.1 deleted file mode 100644 index a6089ffd321c..000000000000 --- a/usr.sbin/xntpd/patches/patch.1 +++ /dev/null @@ -1,790 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa12064; 26 Jan 94 16:33 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa12284; - 26 Jan 94 16:26 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA16418 (5.65c-6/7.3v-FAU); Wed, 26 Jan 1994 22:26:48 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA29418 (5.65c-6/7.3m-FAU); Wed, 26 Jan 1994 22:26:45 +0100 -From: Frank Kardel -Message-Id: <199401262126.AA29418@faui43.informatik.uni-erlangen.de> -Subject: Re: Solaribum -To: Mills@udel.edu -Date: Wed, 26 Jan 94 22:26:38 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, Piete.Brooks@cl.cam.ac.uk, - Paul_Vixie@corpmis.sjc.hw.sony.com -In-Reply-To: <9401261207.aa10860@huey.udel.edu>; from "Mills@udel.edu" at Jan 26, 94 12:07 pm -X-Mailer: ELM [version 2.3 PL11] - - -> Frank, - -> Your command-line weenie sounds rather useful, especially in cases where -> 1-pps signals, kernel mods, etc., are involved. Better be quick about -> patches, though. Paul Vixie is burning rubber on changes. - -> Dave - -Ok, you overan me with 3.3c - thus the following patches will be -relative to 3.3c around Jan 26th 11:something. - -The patches include additional sys and refclock variables, the -adjtime fix from Lewis, doc fixes and a include botch fix for -lib/numtohost.c. - -For examples how to add extra refclock variables see refclock_parse.c -(as usual 8-). The variable mechanism is documented in doc/xntpd.8. - -Ok, here it goes... - -begin 644 patches-fau.Z -M'YV09-*8,0.BQ1@05)X0>:(CA@N'#F<@5,APAHL:"E1HG+BPX<./,Q)<*4,& -MA)(P;D#(L*$RA@X:-E[> !$C1PX:"EKHY/A$)$F3*%6RE.$2YDL<-&WBU,BT -MJ5,5&3?&8%$#1%,%($",4!!"*T\6=D!8I)'TY@L8,5[(D!CC1L,<.F"P7!-& -M#IDR;$ 4P0,'JU:_5-"DF0/"3!HV94",>>.&3I@T;@C#D?-&#.(VA->X>7,G -M)9TW(.B@21RFCN@W<@B+#D,'Q!PZA_.Z*?/S,P@QB>O%U'V""$688 -M8M(U]EAD($Q6V669;=99>>N19AH:J*F&!FNNP<:&;+259!MN(.@V6V]9_1;< -M<,4=)T=RR]'1G'?1+89C==>YIAUW0((G'GFVG9?>>NV]IT! Q5TD&YCO(!' -M8W"0X0(.'D'T4 PQOI'EEG1T^:4.%A$5E0IEGLFEEV"*"5$,/I5T4DHKM233 -M@63]AU-]<6HYYY=Y L7G4$6YA6!92STE*51,@7 ##2SK(.#@5QAD% ="K0"[44<;N(5GFVB)T1'K -MK"6A# (;@[7::Q(?MQ"6R+F2;/(<>:&86> )S%CA6T,PF @[,B&Q';@!; 9.R;FL!QML.9" -M5D-HMUUC<[ G&!CH %"YP#CEJZZ&KT) @TWL4#[IO/N5 ,,F-8P UGY0@CY -M8FUT[D9)D%>6'6(^!GP\")NU%D:QATU+(63K05YY:FDPWEVY:*J9*A10,+OJ -M'&70D32T2$M+[&PKXN,.AIG,#3,D< -MZI"Z@)F(-&,8 \' -MRI5P+(U>\N3)/)225)JIACZ\(W#,6, [A*%H0-Q>&N[B/( E -MDF,Q*H-A9D.&.BXG1.Q#G_KJ$JSMI XE@VE#;WIUOUP-,I1%$DWFJL,C1+I/ -MD>M!D>$<@[T>'A&:02Q@7IX)Q!WFJH=S" -YSM >. @RB_ [X!>2]H6M=9%$ -MQ'DA] 2*3X+HF(Y36/L%UA&-H=)$U?&5#W9.D5T,8)"#& -M8R8GAL,($&!!)-\4'GG"Q<$U661[%5O+( .N%*8.9#B#YL)@L(?-@41W$"*5 -MC+JCI"8&-W2X@X^0*D2]+@D[CFG#Q_A'U.24 0XI-.Q@*R;:?@J1D#K.E,)KM9G;D -M)0@!5EBO,L/DS@ #OR!U@82!3"5;,R'>3NRV_UL=29:3DO*"=)BBJ1!L5":< -M10H4#CASPQDXZBF:Q$ &.#BKNPI"JK6.AS=^><)? T8]NMJ5#G@EB&R-0/3L'Z180O1FJRV[?"SE9U4&? (.!"T%@9"2K=L=0V&N/:4M"R.$& -M9V6H'/(\@*UM.58678L+,AB2;=P,DSNB9]IU-Q7/-,0A[[."^0 -M"_,Q&^;8(QDV8MEQ@UL'62[MAH&[WAVA,,5KFL:)#:3G;2#D!+:=@ 3%O>$I -M8WSG"9DZU-$$I1QN7&O+"FSJ0Z^%- -M2;A:[%7!#6G 0V'Z2H=YXYDQ)3%,O*/X9"29(;FVJ0(5A@ "%%2X-4A 0A.: -M$$A=C@$\E:5#HT&#2W -MW:'V\.3; R5W4"O)%0',Y5L.LFX;X\#!$%J7(#YR7E:;[2B" *DVQ>1/L(>2 -M,U!(#+K%:?H(PP,0^.!S00!!'*0N$(Q96,?)ZLI=LNVB+E?]XE9WV(HX,S$A -M4OT-=YGWY%Z3(7@K-8@4)K@(#9MOH+YA>Q>-E1L KM_/>KF'C/UX&X9CRL]* -M\97F9NK5*]>8BOEH#FYU051!\&\!7CVI@)]8M>G5K@#'H"TR(+!]G)VF.$#[ -MP%6G-MGNUY5K>_NWXL:I1J%Y[NY4>])]!GVI /?>QD/QU?.^54' -MAC5T4;..TR\,EO$2W??4NZQKU?6P.P^'=,0G7G&\9WSC@;0V4#^>9J2*7+AY -M9G*FA7+AH7(LAT9< QGA]RKCQU1?X&)T("M/5W.&5'2% 6X1&$H&N&= !73O -M521O0'0$9'2WE("])&1,QS%.IW\P%('\9G> UQR$@70EM(#8%H,3J'9L9V=O -M1Q!PE!PQ6'?D<7<$EW=3Q'>5IX"%QH#21'XY=7%/=VV#UQIP8'A(TGV1Q#B- -MQQW1EQ>21WD4LUJDA7DQM#*#Y6*BE7JKUWJM@76QIU_5-EE64D(VA5AE\ )<\@7S1!FVA09A\A%5 -M 1G'>!?*F";,R!@R4T,N (T680.R0XU-9(W+V(S<"(UV(UPD(V-X8S=N(Y!T2=$<10Z$(]*46SJ(E8V8%9MD5:=DA4C\#5R -ME@!#, 5?, 59, 544 1-D !M<1\..1L0*9%+4 19D 1$H)$BPY =608?^052 -M4 1&, 4A>04:F0.&U9#2]) 1^0564 2MJ#<)( /=E14UF9(KV01!@ 5IHRTK -MN9,].2Y^X19,> -MF9,4:9$8J9$WP)%HJ9(Y&9(C69(Q<)):090YV9(O&9,S.91Q"0(Y:05!( 5, -MD 06^9-!"0* .6)%>91)601+69B':9%/F151Z1=4:97O%5/ L3!<66_\0Y"3 -M(CM B2E$D7MJE9=Q"9%0,)%%X 14D ), .%=9:..02O23<7*052\ 124)LS -M )>YN9M,$ 374ILXD1]Z^9I$@)A00)LS@!',V9JZ^05&B90*(9G7^9Q34#Y" -MB9E2F15P,@2BYYE:60>AZ975-)4J\ +]=9HL0!0289:L69RP*9O2>9OWB9.[ -MF01,T)N_&9PS,)RXZ9]?8 3'F9R_TYAR)IBO29B&B9BS.9U/F2LVB9_9&9FN -MJ9.42:'! I7C297F.6Y8^9E;&8OLJ9GO29J28IHR( /S*0.XLY#]F99#D*!5 -M0 1'4 2$R00RH)&+F:$XF:,*&@1', 4:&0/$6:1?H"U6D 1#()G_]935F9LY -MNJ';"9$Y"J526@27"0*9Z9[9@I8AY#T^"%0;Q$(9N##HLV6\55N-9AO8)S/& -M@85^U1N$$J-FM19E66 W*I=&NJ,]^J-!.E9-BJ,)>IQ)NJ2)*JA/ZJ-?JI&% -MA:$I*9@Y*J&5.9LQ8*",>:5.JJ5*.029^J&6&9YB.J)P0@1F&HAPER*Q8C [ -MQV1O6D)QBF0@4J>Z]3&)!X@BU!O$:!#&.([)N(P34@:*)6KH^!$1,:SU:*P; -MDZS=R"8N\):50H_DB(W'*JW+*B8A,1)ZTH^, I Q"BGSF%3$:H]?L*U(M8_@ -MJBCM^(_O&)"Y)X]@M2Y2017,-IZ9V154":V(P:U@(18NP!+_,0-GD0-G02;_ -M6 ,N(0-DH2!AUB!]X9XL*F*0<:88LCD@()M0X&J)D:SMED*+5 ?'@1IC0YY@ -MJ:_VV:_D"3W:&JWMB@8#:Q$S(2@+*R!)$1 -M"[(@(+*Z1;*N8;*7) ",2/=^A&;DK7JRK5R-JT. -M ;'AB*[/NK6,U;6\\;4.D0/\N"CN"(\W.Y"$(K;+2+9>.[?Q6A1V:Z[WVBGL -MLA;P\CO[&J99@01!L)-?4 5.0*%$\ 78,I4% 0)-<$PP0F9# B.YY48$X;%? -M 5/, 5)@ 43^01N,Z4@\ -AF@5!4F8@H :R0H6M]H,CMFA"I"TO>4NS44*K -MT[9R-@R*58SK9P22PI!A!H1L90ADOH[U]1UJMU)7QU!JT -M%#U M& !509',[X"K+Q+"VD"\TV1$3.@D5G+1 84TKY7V$.&@SB*$XBY)5!K -MQ%O_P[_=NS&_1QYBL$8_P3C$@U\@]0)\:V[:45B 3E9 -M"[)/-P6T42&5@P>F\Q@"1UHKE!(5/%L7+$+KEAB0)1VBA1@"YWJ*57!AVJ*6 -M"Y:&VZE(89^:"0*,Z[B0*[F4:[F7F[EYL+DDTKF)\;FN);JD:[JH.P6J*P6L -MZ[I"F2N\FP21&S=[,S? "0)K>9%- (F8 )5^9M3.@5R+ 7!DA46*04369&" -M3,93^2E,Y$2N1ZVT.\NU?YU1PIL<+$:[QS@+P;8\#,Z[S4&#.N1!K3 -M2WA!9(HA%QK:RWP?_+W[.S6:7+[GF[[34P;L>R393$ME,K^CU,#V6WGX&[TF -M(D\HX;^, U!A(, 85I"@*M: ,P$-A8 -M'::9Z=.4(A4VD-1DF;CT<@,(B0-_NGM:W9)48+I'0 59 62:0=OL$R/F@"B -MNY9#$ 1,P 1?T*.<:IN?'=H5.=JE_05!0 1*H)$T\)886M9?X\F0_-9K;:F! -MZ=:2#-[JIN[I@"MZ)P=6P3054 )M4 5'( 7@&:A>W+A=#3?M'=9@ -M>MMF8-:ZG=:"S-:__#2?;'&[0;(70,/ -M 43A4>$7[@*Y]S!34$/&0A@RD.$@+N)*0^(>[J)/(58Y$&! *1':3113012; -M8I]$^KOJC=_N#=_R_:CU[;@\KM] OJ.O>04 2@2C+063JRV'R919,-:X+4W_ -MS=L"/F)5'MR#/-P)7MPH#CDEOMQC[=P._M2H6M@^#:,U+@-%W2E[.@,W,)\P -MH7O?3=_B#4/:NB3S.6G^P*A@](Q -M5[H-'N%/C=<2?N:J"@))X"U8D-R=3EJ;?KH@@.%XP.)A52EK40-RKF0S7@.H -M:0.YA^.7VN?M/05%\-Z #N3J7=632^3HW;'O/;KC'<=S+-:$GMN*CI&(_KO) -MON7$'>I8P-R";N:4'MV8;NKX"B<0&^OV[=6]_J6? -M3=F6C=F:G0"<[=GH#=K!+MJDS002:9%$(.7]C>P$;N6^C>7-'M==7@5BHS1B -M7N;1;>G4+J(7&P15@ 783K@;P>;/I?>Z\_@7L -M79% S@1/< 1@_=X@H/(LK_*NS:2_KMZ6[02D7023*R[\7NC_KN7+GA@#S^AS -M#?'1/N:77NUZS9CB.?$_7?$XT*M?[>M\?NY. -M\+CDPI#JF=MW3MYR;-X][^^[#?0!G^@_K]8$W^A.$'-T,.G3OO!*/^%DB@10 -M$/%./]UB@199+Q??_BD%*J._L_5,C1?65_/GWI*QO01-H.P*#^%DW>]4WNQ! -MG^5T3_0O /@1+^UDWO?7;MBR<_53K!C_I]/757_,[:\NMM]&WH$3?UTIVQTPI3 -MS@"^O4.7_(3> :Q[X-)S>&1*6Z2-*6 $F)3VVPB_(]E,IPSH -MYJQ>#I!1[L+QA;Q+Y?ORG%B;=ZR-6]R[?$<%]MV\:X%@C0#"0,XG PL< I1^ -M"K#+"<'2502A'[7;>S^PZ1U!.#&=+F#X^W[N E/0@$Y%YW3=Y"L"E>_R#3(@ -M)Y&& .."9'G,">@\"<@"2=X ?(&;S^?-0.27 &^@Z$L"%M &\,!!%P&!X,MJ -M FD #G2,.0C^[ 6<4TA5[U/L055' ]9"'V1(SB$ED0$4L):PT[>8 BD R#F! -M)T "!V$ 1'=A$!+&0-!'"=&@)21NH% 4ND$(" GAA\MPZ35#5$4!*\4>!(BN4+O5-E:( Y;:% Q,NW BL0U%.+D, -M86&*5$. "3!"<^>X1& O](/"[Q'NMS$H"==A2FR'G9-^0?'FZ;PO8!0181%(BDO1]C5%0#@" -M!6%>!(&.T 5.Q71H$JUB)3R)SJ[+C<68B/T@H(AB3/Z0!K#"1[&:I)_,6P*C -M2Y0I,D)8D:R R4L"E^\)& $B$ 2BW*\S75J@JU$VMT$4OX >HVI5P @8 9Y4 -MDYQ;5ZA) L'M <*,1)NBDF[;C8_CB<$;PM";FH"XV"LM*C\,0_56'(^C@])Q -MYZXYEJ[&*!-/7W_9'D5Q,W DS0 -M@S9@&E[';D<59L"-JWU8+@NZ-GPWD;I@D;-UWS$AN+MM4>2(P)%+3HEP!O(_L\!BJP2=@E/28I$-Z^+ 9PC+^IAN# &], +[QD0''\8!?AB-" -MX$G&$;FUJ!/)'(&DF+BR@H)0.4Y@2-P6!)+EBD@,F D -M@H $ !*_27C@/R$' LD*24DIF=&)" ]3B-TTAHO8%3JEI=Q*%V0+Q( N("G[ -M@*3,"6 QTTD!:7**E$H;2@(OX G *C:UR]K5E(6K!-Z3!2NU)7^LDWYRBH -M+$&#L"26SL-6@91D>5G21XIQ \VR SU+BIE\U,.TW![54HA\B,]R8LYED@!V1-2B U] 5-*!T#DZCR7[DAELRJ6\ -M%Q7@.E]EKO":V,@,HJ#?0P[%1DF!R!R#$(DV7)68ZE -MY20AFJR1P8EM ]U6V>7!>P,'$#V5P98K2J?!8 ,")YPP@ALE_;11#B&^(1/-1 B!8&Q)P(3 -M S V@AZ$G0L7<%O,5%LJ 8M%(QII3(NVC3!05*&A0*Q+;GM"A-*!YP%QJT -M"#P!*^!"<4!WF9&3K2>@@-%&0?EB+HR@5T"'\M OT$&3P$7ZH9--)NW0" -M8QL?&*)%](B&J%P1._U,X5B7<")@E R!*3I)I_3D7P$S:7 *T]$0.6))\(AG -M@'4VAN(9+*IH2D :F=-R80[:H%.>3Q=UGV$T7Q+/U]E&*Z<5A:/+Q')I$RXZ -M.O$H_!2C&L%T % RNA%I2T=$?VJ4#K!1*NI'WVB\*PE3:9 J%#':11?I5G*( -MCU2_1-))&BMAUCTZEE3%!3#/K.9&9Z?F7$:HE&/P3A1P2=FH4 I6!T%LY1;T -M\28_ DO0I76!EWJCAS"EM*L -M6VPBFMZ$ @DGID+&XU=0P5_!B14! Y;*H$CDUIR\ G:K3\<9.W2D\?0'R]&T=5+9P3P-$M]M9O",@ -MD0F)!5 =A,42ITIGGH9-/HBSO.J X%EBU9\NB(AJ5HG6RZJH%[6;51R.ZE&3 -MS7\0J3:!I-H$DUI60.HV5:DL%02XU+D*4^'-M*2I-C7FX-3PH%.[$D^%-#\U -MJ"8KHFI4W0!2Y:8T0=4MF\HX#/F?"FU%70T)\#\@9UH+$X94K5_@/@B$!! " -M4$ WS"^2% 3P 3Z L:@)"N!_1\ )5($<]05,L8RV0)= -MH >(@((*-@D60FVK:2&?,E1^^E 9J]":&Q!/!$C*KRA;U>396$:%$_6@@;Y! -M+T2K=Y.M]K&UHE;*M5I_G7Q]K?5U#-)6VQJ79B%N[:B[M;>2A-]ZVH0K<36N -M_@JY'H13R5S-:8\A ]!5NE+7K9I0W2I8[5G+AJS2U8]A!,+K>+6.L-"\B@#T -M:C>[4=]XAC9 ]AW$[S<#4FS6RS� -M,Q:!#U;8[%H5+FQK%FY;#D:-8U]PQ9 -MM2 1:,)V=:A90<->+$%A.J%L]4@M%@N7_DQDBH_,0"]U"-,H3[+9"F8F+T+: -M@IISEC&XV9Y9 ZYIU603=VN;/LUC&DS+0)N5FO#J3S+-0!LIJ!N[R!2'<@*B -MU:=Z3M];.BT"ZQ0X6=5X*F<+[:&MKF-ARVK7?9HVD6Q9'5I4"ZWFV<-A4,-F -MH.BJ3=;+DEH8,!,T[-O$L20J!.75C+I7.^K!,JPX ;&BA);Z4E>J8YVI:*"F -MWM30Q'H SDYU#)@5J':=H5I4+>=GI1>0MF6%TY=%::.JI9VJIJNJOE-.BV<] -M+9T%M1=!U+[5L.H*;:U$55FJUMSJV59+L 8$D]59-0&NMMN7^FZI%D75M1@5 -M??7:LH!2#^O+6JG#5K$6VYCZ6)-M9,4#D[794LO+ZE.EK5!U YS5VH*4I$H* -MA]I\0H7C"4J"@/O:U=*&$S "]#6VVM?1Y5I+KMI(N?!UO][6UJE;>6LW!*X& -MEO\AV$R*AY+KJ20#8\ ,--<'&V&GJ[QEM>CVU=[;4=M0::VIW;#@M0J(5R=Y -M[=KKQXVQ(I?DTL67"UM9*\N=KR87Y7;=;2AS^RL*^*\U5\#.0IP[7'5N+DRP -M$,CGKDN@*W0=['.-KD:WFGY:>FIO:0 ^7;<85B*X6[X0=:HL%XJZGC%2CJE5K=GCN;KA8O,KV\D+=G,M,^*:ZP*0U0 -MNH-BFN9)S]MX9<;C5:]^EDZ>7L'%.&D"I%U-376 -MROMY72_FI;=!5LE@5RXK:QLJ0AV\J';;$M36&S%"[T%5OK"6^>I3YYM[H*] -M_;<6->!J5+Y:$S[J7S6L@O4)&M:"&VP/;F)=K!/+V,I4C.%PEVTLDKC/MJ?J -M!8N[6:OM4=VX2C7&YEXQM7N];>\%MT94TP;?R4N\BF_U5:\'E4PLWZ^:;\.J -MQWNZMQ;>YECJ^WJ1[YA0MT;V GM?7%N> *Y>W:B^]L7YU9"*?@TK866_%POA -MN@%BRUCE;\-5MI*5V596[@%M*ZYFI;:=];-V7)0::15GS*VM,W>-IMV;6V#; -M;G%]NSQ78BS8Y5IH,=[0O;L2E@,?7W0[5D3M0B6USY??\@7#FP^UPMFC1YNOONF#R \$&*I*54Q+517P517& -MQ+@6\P9]L*R%,S) -ML!.A@D5 0/&D'J 8QL#*VHY,K29%8][K>ZLQ\+W&IW@8T^)0_,3HJ3;U -MNQ:V C?B[AJTZJHY]@K(-'*HXP>U&CR8&J-56\3C -MNB$%^'$,R<3%"&>( 7):-0Z,*B7%75@FTV1)Q!O&@$>P5AM!)X\OF^R3T]%8 -M0<:[(RY@7T&[$X1R36XK8P IPP"EO(SOE6FR@/,)QE;&TY< ^L!3^A0)0*'8 -M(?BC35P _*P#:0 $\&.RG#Z^0!JXB&!9+#L@MEQPSC)!6,L#89": ;@L 1. -M%^!)4L!T -MH V4T+S*F1@B [9,%/L?'0 "2D ;$ %\%#(W$A+"CV$ O^S*5X<-1+Y)63N9 -MB%JF":]R&^8V;1$?X]L4 &R![5X>D,E9?9-FCG_/:"G7 900 F8 RF -M--/EV_R -^0 MP"8TYB(%FTY$# -M4@#KG .SX0S\ !'0 D2 #A !V7D[6ZZ5\9T_0QA 739+9N. &T&V#,;+97# -M^0U09LN,F35S"2@)#[HT0V@R<)VS<\6AN87Y%A=,/*.=2V4"0 $8&C2K#PW] -M!1C&&# =(%H))V81;0=(-(>^T&MT.Z]H_=>BU4>)QC.I6>GU-=Y[-4_F4 G:%M-)ZA?ZTY[<[H$6VC3322!@&-F9 9,A30.?# %]@,V>B)I8_$ -M $4:LV/>SG. "E@!#3D%!O.2-LR$;$E#Y]><*&$;$2 "@UDN>R*Z?)C5-!_U -MT EZ01OG*U"8(M>BU,QST\?^FL\K[F1RO'H -M(["=__)=Z" 4 XK0 "A,FR+S'"#.EGE2=VC:S)VGD@@(U,/RUP3F[8 ".BHU -MHFA;VG10E64B=:CS'*C0H[I36R[UX9_-M&+.T+ -M!C.:RWDY?9CE$IV6\7+\P9UO&4Q[[+$1DKRM.69M9,VY^DI&: -M($SJOQ;8NDO'_M0*^ED?Y\Q\-I3S4&;5SSDZQ^SDPH^K\ZW&SM4Z 7AG\/R? -M 3-H)L_F&3V[9RVJ!@ST>X[/\[D^W^?\[*$IY=3NU0$Z#0SHEKVN#/2=ILT& -MVS@WZ+,1H>OVA,;5,#JW%ND-G1RB=HK6VRR:1)MH%$USS[2+[MMYFU/3)L/= -MI''TAWUP.[H(]&:>+=CDL+ F"$0Z$J!4U0TO6CAI8Y^QL(;E[=.SV -MRYC[4KN'X+VIOW?Q#MJANGM3:_-MN9JWH(;>_+I5&Z-R#93 -M#;!NWX^)<[LG3OLD6^U$5FGD4F+1,0 '..6.. -97+GJ43?0Q4LX%D]H8CP\ -MJ N[M3\IU\N/6MGE/R$BYTN_7 :?W];(#MIJMC$*NMXS_W#KJR!YO&C]*/J -MAA/HXT)IB<.Z/G606)V-2@!W0#!0B(WZ,A>Q"LS+K($-0P!J' QTU -MDW_R)WT"N( <. %2VBIP<5)^G4^ <87,7'P%K !.2<9O\R4K Z\YDCL.2BZP -M%4._P.2&;)2/;L'! ESY=E8!9%R6W^9/+LLYI2Z?Y+4 -M$C(YB-[DU]R3<_%0'LQ7^3 OY:<\E0OSH+^9@U]3,I.Z"Z*M;&+J"IQW"D[!)NC]/<"5:]&/,& -M8,Q"BXZ7QXAS >8A#8@!-BN,78# -M< $NX 7H9)G,)?QZN@0"R8%$G U"D00B@V-H*2< F:)R[/$"L/$&V=8)YV&4 -MAL\020[">2 9$V/2&1;1HH4A[QL@S8;X^!X$\S4&Z)=-!@V 7;#K==DN!@J[ -MP)#)?#TA^W5A$=BS:C?B[<(7:K)>RVM\0V^ZC"'%J 40 >/8+50W:+0;) % -M]+*.V@*20&S/8:D=\OIC1/G6XSIH( % H*X7=]0#VP/[8-?KMOV6['5/V]<% -M!A=(EQ^=M;OVMG)' GW;Q'N$/0FP_[[4]3>QVW,[> -M=?M?[^V=MIK^]NL^?!MP:5>OQ_T@"*OH/MT+@G5'\463PW=@?UPJNWM!^.[A -M';P#=Q"?WDF\WFWO_#VQ_W="(>!9Q\TH\!H^P0N,!0]X&KR./[YO8,*_# N? -MD$5[5I#OH^2UD^;HSMQ_4[BX?!UUC1 -<4(X_J>,MQO5_7.0>2EEYI\[@'TT -M):$%=.L7P 5<@->I#"2D1 .<.#!87@ 90.50!+R[@#307]2ZPXJQ"<#'RW5T -M7->_''E7[[G=S^"%W?[A9SMA%_%AX+ K^<6^$QJ[BX'LDAUX5?:$3$YE!F9/ -MGP'#-&@'*?SD0;M^P? &_L7C==+\X#/)>,?K+B"Z+X'"9 @Y=7]7[ #^4S3Y -M^6?E>SW'^/5O(-BC@&%/QY! 1QV64Y[!%WAG#WK)N[2G]L5>RU?XQ'#A#]2NZU<[QICOO*&\TW;:7N3U>J;_,YP>QQ-:%:\Z6+QP)[ZZ'CX@ -M2N0NK)1[F7?NEP\$T'B7A MMO+\G5E=>NZ=+20_D(_ZE[_0S^=,;E-MN[TN\ -MIKPF_[_E=UQ^7VYCA53Z[A_ =.-H+>W5O[$=]L@7#?"Q/](O]R_?U'7[(>WKT#NHQ -MO4'0IP%"?V ,/:)W^XM^A1\$I6Y3<@K=/8B! -MC8>+B9E ^MF Z0^ZJ!\&V/"'@,,W0NM__68@]JO^CW #RGI8^NJ?XO9_@=/? -MLXUX,RV]#:NK,UK0.A6RFXW:?&H7!?"EI @>EP _KSC=L!(#6)MK=BNQ7G&= -MJ;P;4O\A@!F5G!&(_=Y\ '?;:?Q[-^W73T:E?_C#_N)_HL-F$H?(L7;[NH1' -M/X)?UJ=Z6?$?\9?ZU7\$R_VG4#5?^]]8-8Z18'H!$_ TF'^Q'\VT+0E4V!:Y -M$_+$0F;7]'<977]TF)PQ"VE_2UCWUW)]?]>?^.<=08 ]6_HG?>E>TMBW18V% -M6]88PB+\"8"R'P&8?(%@%5@-4&KU?U3)_T>5!(#SWP!X?>& !((.Z'3Q@)G. -MB/0 #@'G7\\F 3(-:1;.)*P(?]L!9(!4[7X. >M7:+T \5\5Z%EM7+/?YE4I -M4(%E@!4(!A9E7U+O=_SU8@>"\@?\H6-E_@ (&UF]E49?@4I%3T(%GX! X@7UA -M#4O$L@#:551)$U &?H&?8,OTM)PL4@L%*!_\@3@.!EB'27\NR?AG_5%TAB!J -MA0@F@[8."1C^F5W&("0H"5*"EN"D58"Q?P:9^]<)XH*@8 1&!#I4#8&2@00F -M?0"@',@*?H*JE#++:@)T@QM"$K!"\XM4PW5IE-U"[8#C4! -M'K0/MD+DCV1#E& )8"F*$9 J9]61UA%(68R!0)75; -M8/RG6]P!=!<66*W @3)A&$ 3!EVS'TTR!L:$Z+"\!5496"%6_(&D%3>4 1:#&R R* (J@R'@,*@(XD(E(#3H';T- -M5X#Y5PUR6]>@"]C^!5])H4XX%-)3>R#^IQ;4*P]+S^+5C8,^8$(8%+J%2R%< -M*&K1A0&)7:@ >E=UE;\5,>F$V0(3:*]5$K)9Q:1\U(.WDR]XU "#3(TPZ $2 -M@T: ,5@(;H6VSC+(&6):BV!8. Q&@V2A6>CP6(,MX 'V B9@!YD,"!3F%$JA -MFQ4*&H 161'8$'1?LV /F KFA#NA;$A/T89$5D5X&YJ"A:&LA!A"@*S?!PB!'R6!IAF<42^A7B4Y5%'HZ$2,%?F!7<'H&A61=F0507BV& -M!_P$GL6)<#P(&R^A%#CZO88/2.I@OG@)1"'OAQ/*@7. @KA,A(&U'YP@_$6( -M:,"":!.J@4WAG_04RG# 6/"'(&*(&B)3.#4YA0_+4M9HY8/YBO/7U@6"5V%F -MF!7:<\R@X=<57H9?(2-HR#B"Y-]$8@@91T3 6>A4I86JX5K("8Z($B*#^!N. -M@@S5_O>S$(;1%SGX T*(26(Z:/\QB6+5@? D5F31%X63).J"D*%S:+%4@%B7 -M9>A;#8+DWV;H%1Z"-Z)OE2.*AI=A-,@M:!PDB9"("1I@!1D,V!J^?W%@3D$B -M3HBA8!>V#@J'0PUQ&"7FA:I@@I@A HJNH"+&#C8$%-FIU1U"3U\BU -M5UAB>VAED).F.)8 9-BA%T-C(0P'H6$X)?J)56+]YQ#.AQ$A23@H$HI%EIC% -M'LJ%KM!*&&7!AU06F?(0EHWHIHELH"$U93 -M?:+YH32P#+98@WBV/(@YAX9J(6CF#C:!8^ A^ -M,J#1%& %V !VXD"&)VJ",2"?:"X^B^BB0T9PO0!CQ0MP@9$5+T'/(AD9BI,B -MG$ %,(P4@L#($EB*D:'>](^5B5;A,%@OJHDX(IN(AWV&_.*.Z"_VB !C$^ Q -M%HSKGUJ8#;*%W"+'V)/14XS6WT4HUEJY8::S,5Z+'>/ ""8VA[V@R-AQR05G -M!<@%EC"-MT??=+%HAP9AQI@HGHO18D/(8^V*(^%,@![:AFW!L)ADS8H'H*WH -M$;J$N>)X*!*VBBS!PQ@Q7F!0&EQP>KT$L2)_2*88#A7("%+3G(WMQ0)E4X ; -M*D.7N"RB#^_?A@@'%E0^69#E$]I^6R#B2(IQB">BAU@7OH%*'>(8+J)>S!]5 -M^/S-B[/0R:@5ZHN=89LX8+V)IR%:F!KFB:RA-M@X%EI6HG45%QZ I" 2AS&2 -M*8@BXGA0O8Y>%2RX_VT*[^ ^5&B%!YC=M@3K%16UDF.X!DB&MI<%^!9QCIBA -M9O@YIHQC@CCGE@YLHZ!(G"(;]F&,AQ>F K:CFN5][B( -M@8/A8]!XL4 !O^,3J#D\#,0CM&0\8HI]H$K W;B(JLK>1'8A8687VB4]7H9L -MUX$%A=EQI](@!EW=9GD7+Q4HXH[Y7[ H.T)?D1B(!0.)6(M7>F5BQ2?W8XQE -MA.V/':!OY3]R?\-@ .EV(1=_W!UG0)H*_%@"N3.6C]_@QQ.0B(./6 1)((58 -M.9X(4$&66.L5\]>I^%7MPM9$#CC12@KOBSMH=G8$J),:2-5PC6VBG>)$]D>FH2R(TKXLJB$'"&RN'A$ -M@5?2@<@LKEJRX>-X.!Y=;62054PQCFLD'+DAAHM]%U*X.NI==%:ZZ$SY"1]B -M'MEQ:8XO(O/H.=Z+TV.^"#TV@Z&A]7@G8H-ZHNI81_*1\U:@:$^UA]N7#! 7 -MX(90XL52.]J1EB26&*-LDK,C2,@^5E.7DIZ%Q, TP8RV1"%P+/$CR^2$M'E4 -M"YD8#):,E^$A.:75B(JDFS@"-I)-#VJ8":Z&FZ!K.$G6?7TDA34HIH?[5B=) -M.XZ/H*0R^40RD^*8,VE*MH\#31+#. 2/KR3\N#*A(K,D_<@BP@F0S;<4+_87 -MY>34HT%FAT9DJ9CIL)%6HA()$3*1Q)0722L66=2DV(@79(2TXD9H.)B1:"-( -MN$72DPA529A)DI)B)%5"1OZ3?&.!F$:^D9:7I6<3D@7;8T0Y.:0X/6%5MT=F -M$A*EM.@"T #AXD.F1QZ3'$-'&2XN?X.D,Q9,FH[#I)%H3!*.GU='Z1?^B@X@3$12G0%GP)RLP0 *"R943G_7 S0 -M1;* ;0V1CJ3!"$FFCC@C26G7892S80NI _8)XF-.R5%>E$Y'7;E,@H];HJ3( -M !*5,J/[.#Q^D]'2N-%45AP<3E2IW$R5H\1A854^>S_!IZ!59&("5 -M7X9B15;R)&8EP(!6Y@6N0\,F45^)?B3X& -MEAL6;^D8R4&9HH,$+UR,N)<*4)@D*56 K4,$V#_'TLB5L= !M%3FY,V9;GU8 -M"5E LHINP &90IY)9-@5I4>5#E;!%& Z!%"2$JKB6\H'UF6\((!IEU( =^E= -M@I>EAUL&<)"7M91?@%XJ6"8D>^E>G@WF87QYQZD ]*4*8%]:!?;2%6.YH#GU -MX^VA*9P5AI)VXV'RD!W0.BDJ%H2DHM5(6^Z46J/:.$\6@/:DSR@<]@GK(179 -M3QZ+#646"2<,E 1+??@K-E^YI3[)!A2+-P&.>44ZE)H81 GVJ7:D&$M042Z9 -MVIWF55C\A'+EK^=1CEZ1X[KXL,2%(R5,V>Z%BUQF2AEIJ7]$(NI83/*)!UZ@ -MV"["CC_E#A@T2HG;(M]G6ZJ#BA@L"%0"C=:DJ0@G$)9&I2N)5-(AQ6/+M%@^ -ME1;.%$ #*#>YT%KY7Z:"-6.1>#,>B55FAW=079+WI'#HB.69J*!>^>Q)FFL5 -MI>DSIH>7)I=H-?*9AB4LB5@:CX-F8WEHX@&Y4,=E+Y0KJXEJ*7(5EPPF;$ET -MH9!G0YI)9V*2;>81&$,.<-/E!%E#WI#;RP5)+[R: 2$1*8=M0_X-K7E:0IJ5HA19$6B0<)9,50#[7A;E9 -MNMU+Z>5KB5PZF+BF"" 1DF&E&@!585Z8^&6ZA*J4:AM$4F%1@6AF0!O0 O@ -M9L"51E&8#FW /6$Z& %- ,YS^4P!6@ ?]5N*F^\5HI2O43+H9A=#R7AT[29L -M ,A]&TOD@REOUE/TIGRIQMV;]V6&.2GMF^FEG\'%Y0$ I\!)*X&,TRG^G/#"2@ J*ILGYG;H3EXLTZ8\R2L6E*\B -MJ"E%\H=D8^YH9.** B5[:5U-A#]F3>DUBEDIH;%H1<*':&22J=29!H?!4L>* -MC6(Q'!R(=BID5QU#YHH%65,F'4DXOIUJIS'&=O9P95U:%"*ZG2I"WKF-/3%] -M9[N8.:*6+Z) UFB:F0GCV1EX1G5Z)WZQ:R(LMP?$>+,8"+_#<-C_760IV4JV -MC_5C?D$OTP.L+)/320:-+9[9HR1Y=SZ><>?:*7E2F\ZE"^D@E9*<)SZFC[5D -MH&=6('J*?H!GVDEW,8BD&$6Y!>*=OV<8.#39GE'(G\)8/09%1H;CY9**6FQE %-F -MFB^+^;E629\WYD%9* J55 ER2!,$-FI!8(,99 C*(78P#Z4.E ' $5 $(O*/ -M ,,X: @$A4!1<6![HPX,( 24!B4!;$%"_#+>7"WY"[*5*^7UV%(^FB]E\EE^ -M+I^M8Y#5=WV:MF$KM'["F3$""!HHCJ"U(3AH@M*?JXIB>+/@GT )#+!_,H8/ -M!-&05+ 'C,%@8&$4H-M:+T$9)*!' RUU3>P.#RAB\6@H$'D!!2I.OHL;@6-C -M5EP*CEQ;1Z:H>2L#.]8::"6&P_802P ?,0A\T;4($>I)P/$"2!P4QVEA)J@. -M1&2.Y8R@/] $$[%,W!6N!2PR6[@>6V4PI7$F1U/)7^:$#)QY:'A0=M0$@0T4 -M9KG\H3Y ( H"K #\V%CAFO5&< (6((DJ%\\%H $:N!XJ0E[ P E3Y!JJ0]9 -M+G#"YD%XJ"\E$V=5.1228E6!XYF0/GL+J7FH43*+>*="NA0RI'UG'DDH.*3#F$4J&V:D -MVV=!TGV.F2N@6VDS1I)QY>KYD+X&;V'8U%,R79ID^HAIHJ >:0@*)M&4;:9, -M*FHR@#V&EI88GG\S* R0?]J@DD'_&1H\>^8,$;J 'J$.* 2ZA,86ODL94('^ -MD),A!OI]:J#AITO))U:D$&E?V%Q.DR5HI+AA>9*I8$WJ5X*E+JA8FH'IF:X! -MCT0AV)^.Z%!Z@QJE5V52REPLI0(#$NJ42J!-J)PQE?*>$:+24%R\ $> $\'* -MN "/19/I&K1VH1 ,0Y@:IJA'8GHGR Z!:6-*O!2F,P1B*GHA99JD5_=W5J:# -M*69ZF#X6G.EPB#5UF,#E:D*;/"\!QP'GS75JB<,,T0.PIGC 0??)0 [ )M6 -MQ& 2'17\\D"( "2 /52#0&8)P*$9 Q!/2PMD*EWMIG- @ 0"Y*:W*883 _2F -MR:EL:D.J)YB$="H"/*I>#H'S*892VW:!MRFT"F>5I[R 7/E8*"X)0 3Q&\:G&ZG"@AQ:IPB -MI_(I>;H9-*?I:7IUNJ!JI]QI=.H"@*?5Z7@JH6:G'DZ#"EHA<2Q -MBD5NTB81ZFQ !X@!

A"!(>A0C@&4@MA\"E$+\Z,MN'4 -ME C[RW:F'\@O_@LJVF@02XV!0(!%E('A 7*CGFPE%(5;09OH!T; @S+$T32O -M@I.@'J (P@%,85DQ#J0%B= OP'?Z04>T4.0'KI!>!!S]$C*P?_17P V -M(6I[2IR6J.D#BJJBXJ+CAJ(@*H\J@=F8]:S@2IX 8) -M0J3"!O]"B$ P=);8@WK2I(*IG"ENA%*PD[%I3X/7NIU\:1F -M,YL!F4H&F*F-(9H:;JRCP4N;NG? J7>!G,JJVJE' YX:&^RIZD61&L\ %9NJ -MH,H7V! "!"?!>^)-ZLI 8Q-VD=QJ.:)*@H+4BIM0*82KR=.X^JW&2<_GNJA) -MRHY_)[IZCWBKUR<;Z#M09:?I.+EDF14OSO=36-D$6->E$G:Q#:-+E$&;H"WS -MSL#*\N1C1 #=()G\)!A!PJHV$*PPC\-ZL((C*9'"ZMY(* ?K6X*JB#P0R.A"*U&JV3$M+*M#:M:P/+ [DL -M ;O0%> $2*U^P<.4R*5U84G6 VL^?Z>/&S5A1JG'PZ.#.+1J^24E T AH/<$ -MO_1LJG'APQ<0@C@M*>2TX)/=!3J &: #K $Z0"X&!^@ 8AB48@K1:&XJI=85./Z -MN"HQ"*3DJ@-0KI8KYJJY*^BJ ]@!.H 5(+J&*;5K8V"ZI@^H*U(Q!ZRN -M^IA5\+KJ4?.K&A>[EA[ :\>97-FNK 'N:BOHKEC4[Q2KM :]*VKPN[)1S]"E -MD/5 -B/J")70?6BU5&$P&QY(9X$7% -M(G) M=:^R0JG1AD@L1$&6T!!( :4!+M",3+0K"N.0Q> MT6OVT&.1IO$' ($ -M"B #Z+ CW/7Z/%QLD*C]!FD(L:<$54&CXC3IP^/:4 PVA *<8PJ)"I!>N3DI -M/;"86P0[P2II%FQ)@,%^@AOL=E9>+A,=U7>F-#0&(BQ+&L%J9BBL8K'"G@H% -MP;0 P\*QPLH,>ZSH"G1L8H!U( PB2$J@:0 ,-BS4EI3>$Q]?K!G+!V0 -MQM(!)*QFQ@70 8]L"XO?#1$MD1.15%P.-2P=JQ[8#'=L#-L"-*$*FM(2R*)K -M'MH8"T@@LB'L"+O&G@V/;"1;$'P,54C"D -M KT%!&I&C:4K5&B%K"E;QH*P:*PJFV8XLI L'2#)QA(S U9I,WBR8<$!@8AX -MLD]#'.&\(!/\Q"BKPR8 /"QY^<-R2D%L%WN;G:.^$55QQ)JSMH$2VT8<,)\! -M:O'$MBC^$("!%@F=,RL-8)N@1(G$ -M@*#%*B4?_,R+8?;;",L$I.:P] -MRMRJ K K%NU3$AF9%:<7_MA?M+2V@^P8+E$5ZPHYU[%4 :4-IT2*LDDE)1L0 -M=/!C.RU ZSC0<7?,I)29Y$]4"61PZN4% L-FX,=*$_,#(J+^$*M *.-@JV*1 -M*V?S9,B2L=5!(BO"_C*:657K!BP4%6T/P 6( -89?F8Z4+3< V/ 1^5/FI3' -MEC2<77*& (L8N&L4Z HP%?@U3\!;RPAM;RV)'., =C5Z3&^"\[AAZUI/6SD8 -MF+=*7M"(9IL?*DP@.3F-A *"$.?4 (E-%0N;T7051V/6G8(=X,8:T)W.3P J -M"2,XV $G /B1/Y6V#\0)8 6DMJ1M6-:6;5)U 8"&6F2P=BU28=O2J&= "J#7 -MF@Y2P!4@^8U.!P%+Y]IB=#\ ]V8$@ "DF9?FQM$FH*TJ-MI"9MKL0=BI:;%L -MP!G0S#%_F=#ATHFJIKK:5(("R$MU00KP4<@!* .*1M[* >;M2V& ?+-6;*<6 -MW8JVL1M\-\*-<,9L89!UH \6!RB7SATU[@))M0<]2%9<>)L5C+>>4GE[WJ:W -M%<=ZV]Z.3#T'?#O"0;<1 WW+\AUTIBW9*J85)N#'[H:Y47BI*]FA$ORG60$' -M^]$Y<$.;\F9NCEB@P33'L82M^5+SD>=%I8\#;<&MJ:B%;*DFTUVWC6'L5N+Z -MN)G4;"O7UK;M:V2@*G4!N:V[5N3. 4>N;[O7!K>ZE?DV.HU.(*[[&KS]L*E< -M"+!!C &B!0JPY&X!,@"2>S9HLZ@9^)?<\B[,K?"6X\9TL=M\2[/=M^E2?EN' -MG ?\[7?&1W5J$R]4H50I35#;"#6U33^;V()Q:!P Q<5Y<6><E@$U -M!*)+Z"JZI0>(Z\9]<6%<>*G1S7%0VNB:,.F;"53R:JE6+X9!O5$>I*[,'TS@ -M5]4VYR2B!.*>L\[<0X<"A ",;KRV;D)F1:Y#L06 N+(<[:N+F,A0 -M3( ^!\IEN8C)=Q($3"G"+D='FR!T--M?]NL^ <'N)P?^/6:DVBA'T!UUMVFL -M>YO% /^MG\OQW O]5+BTZA*UDU*O"^O6$ 0;;5;KY@RW+NJ:Z]YFNZZ'9NX^ -MN]'N/D?1A0#%K@J%[$J[&9VOL=']IY>N2$?2I71J63GGTKUM\)VS:^M N\EN -MNMNI6;M%';9+G&J[C^VV.B=TJ]J(/N)1%HKRJN>D\9:K1M!&T/$J3]]JG]6N -M I+\E.%)*(R\&2\W4J\ZA?P4I9DY^I"&!?(TK[:\R]-!]3#26F83E-;5=742 -M@1K0-JVE<(*XFH^XO)<+57%)S!2@@?*D7K R*6S,1(@4!SKH06"GB$(L2E9# -MUIA7/ !+VCUT(SX W]0'_4UP4[IZ]"Y/22_'L/2>$DZO4!%0*!92[T2W1OR? -ML()QT%1JO3E,U\O(?KUH0-A+"MD 4T%FJ]T OB&J5>J'N5( :L T7C@ALY3O -MM"O]2VT2!"*_VBJVE-*#CM:+BM/A:T@)3&M4;YOP0#\"K^4+_'[QR&^OX5.$4'TOK&O\YLZ -M3;ZMTYU;>T4]9P4^.YXD #AK4-22A$/; A6 M5I0=&M,]RI]"K!29O(I0$]? -MU*S"L5A/GYJ%H3W!$]R3L=08?$\&1-4@P,!*5 GY%!"83V,(^@2%$, MRJ

*5H+,M@8TC#8+HQT6>H >@/FQ$@M""9LM[0ARG1SPRT*NHN -M_ EG-^VP*"R1\"4P21%P!=#"(@ J;&*HP]U4*WPOZ<,>RH1BD0#$M.U.D3-T -MPKY1+YP/_\*T23!<"P_#^5HQ'"QHOK[O^\3YXCW+V1P@,)%T#[ :EP*X9B%* -M/;IG(L/HR1J3R'8-(D94FZ)!P]+P16' @A0()[>6#6_#K$PWS/SY#O>"@H0H -MY22BT4MRZZ"M*PD1X"T8 >IONI23=)Z'R00UI6AG8-E@8K+.PNG28J(1TPO[ -M;*?"5IJ6W X,(+/VN6V!GLO ADNB\&MBZ\@F#+'_01"+!:K)1'R=\":8&7 " -M$.,:E($<\!87*(J3.VR<("=(P%T\>*Q7]C =-(_.3VEQ0KRI ,3GK4YA,.4] -M9VM?TS3YPN]"13Q#"T%8/0I@' 4)Y:P.59I -M6 0](<.D!>?$RCP,1@O)4@8[$(E!GIH7*# >QOT+5(!Q>L"V=ALD9G;!'@Q! -M#9=ED)4S[S0[M;!C3+ R6<3(&M&BTPMK)YH!IP!=@8C\3T; -M,?6:+VT0(;'5\& V._[3X@JK?"*4P2K3RES(!(Z '!X!)Z.K=ZPQ[BJ/;YM" -M?8 OT%P$3!H'U.#41%9P!WH0Q#S/$R]S%^,0E+%*-ZG1SQ>'!"TE+$ 2#RP -MI0?60 9(2A$P0GN\ E!L+4?#*<%/WUEH(%IHNG. KM%"!,E*PRD; =QFN1"(B$\A20(=K)L-//[+,L":+Q$F# -MFVPH(\C B9T, IL.!_* K,C8Q?I9)I4&Z &,K@B;*8_(4@!U1Q,(RA4NIQ2@ -M)@;DL%JC*"^[9S(,XR@WQ)*R&60IX\GWD0GK*8/*W0$M= "9RM,IS38H#WR% -M;)&.RZ=Q!(GEYS8%)WV6KBD -M+'\BS+*:3"N_R8"0G S!UC)UW*??(\ RA,#JAS:JLK%\J&\*2?* -MVYF/;!IL$,YRI)R3V,N+S+1,!PBP'+*9,$.@!KIR'_8IA\JP;\'L(:,&P+*\ -M+-T2R@]$JRS(O,K?@#''S/PRS5RR -M-B6'7+H\,(, 3;((,3)O$'JLR)

FN:8M0]$3*T "C Y;($Q ;#DRON ^L\D[ /V3/P^<&X@) 2_3B>#+*<\3R6,,QE3LL$J:?,:,'""P.NS HVY -MS0$K0!J@UYH=LK-4VN:NS*FS!%UQ$ ;#G"05NU&8REPY5\R-SH*4S/!RGL\G -MPP.-]T30@E3[_#B@T'2K_5RJX<_ZL_&*.S7$_;-ZD,G55@XTP=ES$#(#= ]M -M0'?*/VX'+4C%SBVT#P "T]!9P5^FY4)GL1NOH3+@$CV5]+H4)F$@RK$R -MI%P/8,R5;:S,=FM#4S(+-!C]*0313S02W8=.T!7T!9U$G!'_Z:"L14?1$_23 -M)D*7;23T27?10=&PBK\)<]*7;#2NG ; T)F4#(TZR\]3B4S7*1O/*T#N,4T[ LN,[*LP7^6.K$O667P:SIXMMO9 -MA#LL3TH9<:EKS[8+?+&("1/HN;N#52HT0RCYB>(,W\7,:3)YV1C[RVKQ.'0S -MG[<#)R$B2:G,\_+\=#A'*(FS:DN;R4^K;>.<.D'.DO-10CE3 9:S(=?'5=.D -MUHV,X$0?NT -M,/?*N_/E\CZC ,-TQWR= ,\6B?!\N1#/]K3Q'+Q1TN!T5L \I[.A:J.!1B40 -M[\_T7#U_"M?SBI ]V]/VM/<\2)L. 373#$TKQ%3 ^-Q1J]#F,WTI J3/Z!HX -M31B4H_\T[ 9.MP;NL_]D3^/0MUE(W3\#T0#T$"U SU $]!IP1#?4ZR91'473 -MSS)# ^U"RQQ^[?9LN4#2%C29,$EKT*MM C H&]6/0QX=0B-1#R\%[4>? ">T -M/9U"FU/?L^E02#/5[#09\U+S8RD;4>V5R=.E&B0M26?07/5'=U5?TN!T)FWP -M!T;FTZMP9M-2,M7(<' -M[W0\'5C/T_AT6ET[.\[Y=.[,3P>_O'-2K=LFQP(U:KVI&-2J4%JM4"//5#4C -M[5"GRLUS1/T\4PS1,T5A45O/V+,:=Q]OSR754^V %T$5U 5]A$ -M-6M]8O=A3'2'G58_U9C;%+UB6]%.Q),]E;S87#08_46#T.6<&+UBE]$)'5R- -M1M//-FH3W49CU5"U'$UB5]4F]D<'8I-.*G9LVV*#U8#UDAU(Q]AF]8S-.A78 -M,70Y6ES;V12F)OU76]DY-C@M5V/0=+2%W687M=OSG.W2I=6!]K4+6-O3@W4I -M;5BKTHBU98EIL]*K;6--X3;3%N?;3!)U7 Y+G#/4[*TSJU)C:J=855R=0^U> -M<>ETBBQ*(U)V@*,K3F]Q<$#*6<;!M25DZTSQEFZ_L%YP&4NMG)*&?$W_%SC -M09LN<9CZZJEM>_@.XB]8DF+Y58F-58K%5AP[0AR 6B#:V;93\YI><>U:ICM% -M34I_F7*<,Q2\'W1'G$>9Q(W9_*0ZA]LF0*S+*2W;XR]5P@3(JK">P!#J$AZ6 -M$HCQ7MRNJL.T&C.<&KZ2#H&BV,$_,58VU+PCY*:Y2TOUU!&V(3- .[S@6\51 -M6]D!$/?*0O -M*W-_&W' 1)?3X7.=G+3[;7=JS.YM6G'S&2PXUQ0]@:M\0-5%/<4K3('4!SW#JPSBS0K7(L739W=D/0)??)S="EW+$; -M%WURO]SGG$#W=W?9J%PFMW1KW7/WS8UA#KNO-M4-='>G/W?/3:H-W5>W)Z=W -M2]J(H.6M>)\ 7G;2[>H>WBV1TVW(Z'3YG-1M=>_G=G73W?P8XLUUL]Y> -M][KI:HH*\$*"-!:;<;'V.UUKX]Z5[CKMS^I1MUP95RJMM\ !2@##; $[E$0B -MJA0!/L!ULGQW5,EM\BU;:R?:@E[;49%F.]1KLGQ;WWV ->?4^G:6[V/7U' -M)M:WION7E=_CL7)0$J3?%#>S#85V4PF28N-T@;=R !RP!A0<[])MAK[(,!N5 -MR'% O$NMVC>[@7,,'NUI0!?D 5.W1ZQ0J QM0.Y4+S'1*+&')@: RI0!<8M% -MI0 !. QC.D3@U'<1D('#=P6X&$7NTB:]+BT%[WJ^Z0/HVP8LS8=9\ W^#7/J -M]VU:;F?<7K2P;04,;_R;1QS!H@8[%&9&]L"M3X#<*J'DN.#V"=>=3KB0G/'- -MY)[=V0:NR>W&I^%WOE3QT@M1CT@E*K3:\%T*OH(CIKXL$_V"1P8QN&Q6--#@ -MHC7YC8-O=B3"#MZ#!TP_^,H@A+M+K.YV5H7G2^5HZXL[S;4@<4-"D.F67A88%+QH7# -M!E8#&$[(B.$=%1E>.B].?;C+?B;'(8?LJ<%F,X -MZ6;BNMDHMMOM4ZOA;+CJC8X7#@'3&[XQ3RF^R1P>MSH!=[C*W:G-4@PCB!7DQ7O$>Y%0V%IV-4S*P -MV9EZCJN;;FY?P[D0!QO7/-9WI3'MCDYJZM#<^5BU ^- H#CD'+'?)2[ &^W -MD2V4K]C:>&'NAV\!%O1/OIWHM8=Y5?V.B]+C!6']GU'FS_)E?BG'M@8N ZW; -MLN:1LFO^0J_2:WE;'I7/WU0Y!UQ5P^7J]NRKQA%,5GD"@#]GY?S85LY#JW)@ -MN6LFEA_1%[GA&BL#R7];"J"6J]PX-#=.F]<%/718()D33&CXQFUD$TS0.:G6 -MF5<JID*SH)'XB[X9T")OT_G+0U^WF;B-[A( -MS(FG!\?$U(U,^P! ^"A..I3B1C@2[HO[XW4!\12,\](+.3%>B!_@XO8Q[NIJ -MXKOA:08<3H]#,F_K -M/9Z/6]T#>4HK=-^F*CE+7@:XY(CX6G27 *S>LB/^H"N_$3H,3J&_%!;Z2X&A -M8V[E]XC H?/@M^F''J+K3D0XFP:+WV:R^!)>B^\=8P N_J(7LKQX$HZBRP$J -MNA\NC._I-)M$'J/39LCX%FZC=^'->$C-HSL1/GKG-HT+Z>&YVKV&&^E4=SR> -MI,_C3I"CY%3Z9VZEN^0=%Z&DH!,U -MWP\ANH(5BMZR<8Z5V[1;N4YMR AK@H*, K#2;&ZN/W6,)IYAJ/T%)35F1;!+)I,2FB3&H -MG*\V%JFF]C:^K4X(!^^!&#%]^$I$P,J08[0:* *E2C 0'@[1GM$> -M8(N<;CN0OHYCP4:4X5=RN^Q*NARNV2A)Q:[> -_:[/CYY59QJ #!]]$- -MCPL!L0W#20YUIT@[9#9T;^,DA"'C!\#) -MK\DN%"[L#5F $S $G.QE.'&:MIG&F-( -MLQO(-/MG0#$C.#+?C"SZ=/1O?.AJ:B6C 2)WMM&.[]+D@RS' -M;NZRITO2.;A,A,IM22^[F'NY/"=/:QASI->O \IT.NA>0(CN'#1M5MU6T9KZ -MR[ZDDSW?R5WT.A6Q6>J'P47(:N;U8%.VA>VT&9PKE$R$CL00;''$D#%OJW,T!8:NW# L3/ODO#'WHTSZC@ZR?Z,U^OE -M.,JN9(.S,L=(?*@3W92Z>FZI3^Z5-S?N$8OLDWG[;KZ; -"XI(Z-\V\J^SI^ -MC9_CW[(\3K?;XY_ZDWZ0(^W$&^7-OJ_BAOC-5K9E;!KY]S:ZC]9].VV6LU?J -M@LD3W+-?[7)[[1ZTU^-#NW&DR!CM8/O>OJJ+[95:E T21^93&M->KSOM@3?4 -M+K4WRU7[^1ZO@?"DVMQ^N]OM7KO>WJXMZTK[J_O"YTOVG&UFMJ/M8(USQ[:[ -M[7#[SR[":^UU>VR#MQM^*?P0G\&W\!7'$<_>_N]4=^=\F]WI-P7LFS;?W2_T -M"O!/B^&1-"+]O.I18W, 15.[!J_S'3V5S/%H_ #5=[NZ 93@'4:/T>8YADD' -ME- 8IAE-JHW0=, @_U6+T2IW^4Q>)O*F@QA>QY]N0FYEOC&#SP,VZ>3D1O)H -M>(ZKG\?/H_5_7K:Y++I:X)X\_"[H@P!C7QSN@$SB+D L[HR[21Z6/>Z1>PQ" -MOQ_.$@G:GKKC\I=SG*RYI^ZJNW'@N3>X^WH*$+I;\+$[U5VZQ\FG^Z($S ?L -M=4%*\+D7\\<\\7;!)P"S._'FPW?J>X-F\[8C3.AH[PXV_.[\* G2N&_/JGI* -M.\%G\%8L\X<#$+YWB0W@?4KE^+?O/>BZTP/Z55*@OQ2J,O]=K_O?^WKQG9#' -MQ@OY0?O&X30O>K'=_))).(7DZX34Y9_":=*G\ X$;IU#ST.ZQ/7][5S$Y?J\ -M@3ZOJW']][WT?\/BG!(!GM#[<=DO0[\&./1,A6:<*4X]M@>9C'B.OV$1=P8G -M&-Q:20&.IAX5*$H^*C#(Y;I<"S%KM$R^TA$ :80T[Y*3VA>W21YO#3&8?>B[ -M%\E@#<.^P5/DBX>8ZN\"(>.$Y&CT-J?[\N#;'(MG,HQR.B0. -MI@.U$OH<4(F7?C2X";#5Z["&>A$^*?7I)[JE%*B3#D]XEB*!2^'!\KTDOM_O -MY/O('H[K\)!Z^AZW:_#Q^\I^RT_Q![S,#JJ7RC6["B^E%^_P794^< ;B,3D5 -M_J)W]GL*#" FTSCC.J)4TU,E.'W($EDV,SU]XO[37R5!O>HPU#LA1?U1#SDD -M]1V[,\U49'4%T_-!$@?GG.])[,:9<7.N)Z(\/?4O13)M3DGU*%KI9-6C",13 -M5B_7,Q5KI4USMTNQR-/KXSXS@Z=FT-\^_H>Q2?LC?V GR1GD"CT9B;@D_8,_A?.&UO -MW^<,)7ND+HV#\7;VFZVS1]SL.(E?XHO2!OSM+MDK\/R;<=ZLZ_6G.ND0D//C -M=53.0-^721_^:Q"0,_#\FP.ODKOW43A\_ZIW]L2;H3Z(:_/:2*]AD4_>HGP@ -M3\ETY+[11SZNX:/&P2]'_PCODS<[CY ?WT=^Q0N9*?D#^PB>%-0$(-4%-N/< -M'J_F#EG%-N:/+4_. _CD?GT4+I@/Y:1:4?Z9'^7#>JSLA(!HAYD38CH$]JLM -MG!^6UU8>?F_/[E[FCOV=OV+K^0EY:%[G8^"K$F=N;K[G_UFB_QB#YB S;'[B -M9O*:OJUKFS/5N+E_7L&K9N\Z53X&/+?J>O#$K@_GN_>^J:N'!QM5<2MB?&R> -M2(.MRAT$9'BP/@8,YCV\G\]4&.O6>0P1Z#,5I7Y^OF,33#TVCZ_H'TPG@W=N -MR #1)W[:S8YWYT,U(WUUI^=O-WL>V[KGL;)JGC_G\6/S/UV?D_KW>:@M3^OG -M?[J +U-/2CA^TN!0[/A=4H]/8_=E'C&U_EAZZ=RK]"S]N*&/,_7'O0D U2_W@092K'JG -MVRE]<=_07_71O<>OJTWWXP9\&S./!G@ "A 04_R1>'[FWZ:&_DZ>ELWYQ7%@_C@ ^[&YY5*6TP%_OMJFU2/[Z3YFG_FD*O6B)$S! -M!ZM;KV:,(&@6_"WPP=_FI'P6P$+OS'H\.LFY!"F+O$O]"+_2G_5/_2Q -M6W*]>]O0 &I]_^S/\53]O_3J8_63?*>&\>.\R#U(H=Q/$!W_Z0WR5_4P/W1_ -M$IO\_1O*CU.H_+$RR^_R/_?EO/.G]SF_XK\&D%(\/U\>D\OY -M=/X%OITX^K>INGGT)_W'_KB1[%?5V7FS7^_/_=WYD,WM5_AK.+:/9$OY'O2X -MS\%[^U6UN@GNZ\WB_KE?[F?RPO_6QFDOUZ,Z'27OZ_BA?LZPEE-'4#]66/U) -M_?\YP%\0\<@T[Y[RCM0XNP/Q:IX;_%W_ N2_M) -MODI^IS?NC.;/KV5U6_G%'!Y_A;_('^)O>8,"J/E9_D0..#_EE\Z/NL< ]+GU -M_/QR0#\B'U!NZ(?GP_T9_6)FJ+^EG^KO/F>::_TMV)Q]0;9HG^ROVF>-F[!% -M^[)]'S]STU]F]H?BX_W%^'Y_H[3@'[DOR:7[&[FA^XY_L+EX7UU@WM?\\_'M -MX:!_48FH7SOLWV<=\WCT*3P>,[WX!+2-/57;@/0 X=XG(PS=@$T+):;J6AG, -MO9(*F &-&[FKT,9@*J,X4LXHZ(]@@7QOKK7YZV0DU_PGK+5V&AK'#?@0F:BM -M^L9MA8-2W//D=+#+\:%-^_)GLAP.WL2MDU$XV&[A4-YM)QS% %EW 9 B1IL -M4>B :)H> ZC,=/ U0**HU8![B!1XVNYM$#B5X .&4B@&FD#@&AJM]/ UP -V -M,GASC90^(/I#$O@*?-?= 0&!B@%XEW# ]377$@4R >!.311H/^$/,'LJ_^! -M FE?_+T\W4:EC4=AVJ>9S%Q]ZS92RINM#D@*O+!-^18#_R9G'?%D#8"BF<6) -M MD7SD "X*RMO+7&\6M1,MA]L[C-WS"PD88+].003%( 6X Q@)VLZ@#O6@>Z -M ^T \$!YH-@L*T#2V>]U#O!TI).%F3EP:?<.C ?:R380R3EI@CW0%Q@/),VI -M4L)0@D#Q%D/PU[A<6Z!@\#YVVXMW_0(S*I9W%1S:1D$23C6PL786U**0 -M >9[!!.78/VF$[@.O W^FS2#H0'IH%^+#8@2;)]4\N9[V,%4("=0FJ 5Q GJ -M!&^"J:\WX.H+%;@P PK"ZUJ!1$$[H$JPMA5OT]\=]L*#"[/QH!E@.SANZPXR -M!G-\KX%Q7WF0_K9N&YB, JV!!$*:(#QM';@#Q ?>!(N"%R^ !;(B1HB4L1&&I$H3CY8L8 :JZ!6S@!&N -M"!M%906(D0S@+" 1*! <"'1 39/)0!T 8' *\B2YI008I+@[%M/"KU"RL ?! -M>CP6GB2KU<9 ZM5SV5F!+%)@OZ#2TU6*2'B/,!&&DF)/,8&[D/J(=G0E--1H -M#"@$6T*G19A((L*Q !/2CL2$\ 0B1IG0XW0FM'CM3/0DE:QGS[=*(M#QRK89 -MI@H.+,).A8LP1XB-NY@L$\I+#_0&:A0F"E\#QA\:X::PBY2O,O/1 -M.&H<;+XHSNT!5=@/RM5EV_H?. 72"+1 -MUH( 0CR^'0L/KM8$I/O9_S*"?9DK3MJOJ<<&&,P(#:9Z$S\#(,GO\*<"7/Q9 -MY3 &FSVF@E3O-O,L1$Q!!OH?)0,Y &(*7!AH*/-QGRH>R+:/2RT-*A9V #5XMCYQ8$>K#4$\V=;L"#X1*[CF5:@-4:+O0P-@ -M#,E+?!02X<6+J>H1\@F. H-DEQ:VY#HCRX)^X,O$AU]@'Y)U:,AH4G*T822NJJ@ -M#'.&Y"."A3YK%!03 ##T#-=/J:"7H0*)GC(UI"E5#:TFO*,YX>1+BAZ!D!9)U".##ID)>R1^VA,] -M#9>%4<.Q LJ.%2!J1KBF792&ABJA-9PA20U'!Q^C^("AD.L(9F";'@0,!L: -MCV($LH@"Q-JP# 0S>4*="[LI-(K#A9!PVY3V42%=D#Y6SH$00#<@\;!XZ#Y^'SD,LAE^E:1(,$K%05[P\8Q#ZQ^J05\@MB$C4 -MB6"'_2.:R^S0[")"LAT:ER1D2:784M%E<6B3NAC!"0,2A\-3BW1)VQ25,!Y" -M#^^'^,/\H?X0>0A:@5CT*1AN,PY]EIRCHK>' A/1&=H."Y9QE38)94+&L']D -M!:!D'P/?WY0OHJ'+R@/TS\Q-OI$VA/HA0W B>"!,9YHG#\2:E@21DA&)^&-= -M$#&(>B$3Q08Q$L%!-&U]$.E1$Y &(I@(#\'$X!\(&UX MA.4A>QAB5.P\WAX -MQC8>IA"Q6, **,(KC$V4)+9:)0%/3@J@!C>DH(+P"G^%M E3%E9/%\(KW!4J -M2> &%['/1U!$K^#D*(V0,1830 [SCVODB"@",/\,PWPCE,.?E.)$^B%&M)R1 -M)&IAYI\PP!D13F CB29PDRP,]*S:"^W@LB5$U(G8!*@"X:[R!R %DZ+*@9_H -M!(M8&T2HX'5 W_8PF*Y,$;93W@0!43A!<9(5 (E$R<11\!/*P"C!A%C$TB0R -MLBJ(E$360^6O< _&6&\*2J(X+P,8KND]#"=^128 L\H(D3, 9 O.-H -M$]<5!(=4(IS /\1I $0,-J!#>:N@!F5+=X#F"VJH"2T709%?(=K* T6?XG$"J$C),/^X -M%>&*1L6'XEPQJ3A3+%@Q%?>*4D78QD:QK?A6C %@%4>*6T7G55?QBJA2K+T0 -M-=X%1(TL8&7K!F O>.*4]I2*-$5NFDU1,=2SB2MV09J*=47.8F"CH7A4!"Q. -M%'F%7$30(AFCC3A8#"TV@4:+V@*1HE91;\!5K")Z%>$&8$7'(G:#*E!6^'X@ -M<50=@(V*$QGC"F#5R"CJ$YU7Q$4Q8D_QLPA8I&0D%S.*>46+XDUPJ2A=="T* -M%J.*SL7B(LHEMIA5)"DZ 3B*ST64"TH1MPA: 6S8"P!?\\1/ > +4P#K$(=A -M%K=I00".8FDHH[A+)44RQGQ1O'A;;"S6C]8Y(2H:Q??C(&%6.$@0$$V*F<7XHO-JP>A9_"]. -M)0H_0@!O08]HOVA:?"^F%IN+J\4 8VN1C %B%#&6?[8%W<7$(B6#PSA>=##J -MJ\(?,HKP!UEQ)Y!BR3$^<=**68$C0)0A+&$#@"]R%(6,4P B8X=1M6BY0#(J -M&4F,$<7I(FJQHLADG$HX&1,;*\8FXY 1R\A=1"S2%IU75\8B8XTQM_A@1%0E -M-B2+/$:R1.'+*F6YB!D) >H&'B,CH_/*S0AG'!@M&5&,;49O01/@S;@ML#-" -M&8&*_<438Y21DD%G[#,6&;&++$8](Y\QSMAE1#!^%^>,BL8ZHYBQP4AFU%?9 -M.& <,8XH#E'@7: CT_IE!9 I R=3(DF@@CBR0Y/Z^@#X#KN -M[)@ 7T?[QH]B.J4%+-BM!,9-7(SS7(IFZ_C-Z#K"'2D7]HVPXVN*XT1N%#@F -M&\4,MQFVX[YPL( NV1A*0#!\,!J^8^7 [QAWW$G,':6.]:.5 )HOZ.1]>K.I -M8RI0"#2LHU'0N?!*?'F,2YX61P,Z3H*%./BN Z"HG"@9K;Y_B2@&P]0&0#I. -M)>!R^Q/3P&)@(&![U /JUM8E#I'>X^AQN'9C4S<-%LP/2X)7R>J1XSAR;#OV -M'4.#@HF_(]CQN1,#>*)('^6.I(WJH]<1\+B3.%(< ;2/U\?N(Z-"!F!]K#RZ -M)!@5,P#AH\R1J0!:L_7-&_4NY\9E8OM1,)5"&%VE')N/B\<#@[VP\$AL7#=: -M*=, -M)]A3^ )!XE_F\^B\HG;!'E-]/<&2 +YNA9!Z%+9=L -M 6 N*9/VB3O_GAS=#Y.'J&/V\?IX^4#_&A^##N6'[F/IC$F !42"^E]W$)R -M-;R/Y,<6L!QX-@O$#;.'QM3(@3[(Q%2 ?GYV@[L -M'W.-_<=C@O(Q =F$S#]N!W(/ ,=JRK?Q\*B'5#M:+E2.^T(F0@-R3P:!]/O] -M_^P4$0@A9/\PQ<+MJ+:-J"1A,<.)P2"XT[OB0 $-'">/Q-G.#)#O. -M(9N0;L<(&Q_ )Q=^O'4\=QJ/H\BDX\HI7R-Z](Y1,A0F+05B%<1YHI4$B7"1-H&)3#EJ(@N/K4A/"RCR.\,I 4!. -M)$Z1J4C%FL8OX!B0U+N\(GD#L$=6#-H?=H%Y9#VR-Z#(>>=E9?J(CQR%&?>NG+,"X*0Y -M'H\KNYKQ@!I2$+ER;"L &VTRWYE28UKF4Z $8*+4! XB_)*1I KMWU2$C,0I -M4@8+@QFVPH'&W#3'VR"84]@# )I]F6NRJ*.H>=OH)$, (K2C%=EQCM>:!-.U -M3S)YQ .0B$:+S\ %L*#\X%R3I9HY'D;R./F>-$E^1=#'$4FA'0M58DH@P9,XX8YT [< -M##88_"@7P=(AH)!G8!RD:"X.%HC@PFM*9,2GA%/:%I IIZLQ@ O@$TE#U*UL -M(LL G<@B9=T' I$8, $(_@YS#@M -M*\%XJLGE'GDI.2DKT,R<#9Z49(S\5J_21_"KA ,$*S&5["M-):>2.3"@T4T: -M)^=SN4E9F?(+26FYV'&UG"8(TTIS97F/!;"=X@%0;%J#LDI@I,B/8Q&B'&6I)%EV+-DL8<"+ X+RBO6?W&>Q.3*05AP\Y51"3TG^*DK. -M\9"2B9#>V -M!D][ "! I6=A U&H/!I,(1*5=:_(P"PQ)?"H5#SHC225^B9L5-RR9@FN3.2) -M*X.2S %/)4!R+#FJ[%2:*@6 XJU6I5Z!5=ER454:RA9!>\A2C;:R]>*KI%MR -M+.V6'LODEX\ 6>EALY^]*\UG54D1P(WR=<:GS%=Z*_>5=4ND7^12%<>IZ >:Y>WR<2FZQ%G*+ $1.\L$0/_0L<'MD-61 -MFX26YZ;G)%&2/:FRA%C2*RL.',H>95+!?.:][%U^*PLM4 B<9? K9&F^!%VB -M+PD.H\M=8.721$8N+5@#K@0X!')E9U6.!$4% -M:6B3O,B%Y4L-7=FZE$-&"&E]"S3GW,]OYPCV:V]D)TA_PLG_).%KW.%>;$[J -M*+6714OVY((2:;F17$IV)$,&6;VGY822>VFAS%PR]2X.6,LL&OW2Y82Y')LY -M+JLIZ4M/R^[2&G;#1!_D,(67:Q21I,H2DJ>Y5)_M+)N1_4L9XAD @,DZZU3J -MK#Q.!4Q*Y1!R5W.TU$ANS)26 R>F90T*) FU- (L)\=J*S079LZ05#F?VEQ2 -M*-<*'LJM99.R:RF?S H8^B28?[DI105S^H;!)$K.*1,D69D2T]6QC-W%L*%998)(%N%YOCVP5@@%C$ -M6.*6QC,_9MPRB::K[&I1+1TT,"4&0R,OYM'@E[D="&;>\5R.Q$PEES$S&6F\FV)6 -M**64)TEGIGH"#/%96&%E*6\&U4S8)#931-FAS$@^!Y.6#DJ'@NE@G\77^F+^ -M-/^95LF-+4/$I:,0F02\L3IE/R-S$0%*2T -M,*N66DWM0 R"JWG4Q$,FKR8&H<;GX!NRC_4++&LR**&:)LP'9=,RP%#5Y! N -M,Q59,$J4I ,B;1A2N&JES]B'H2#W(5I*+@ _-!29,6$9ZB:5(S<3(MC._*>% -M,S.;V\P-1CESW BQ3&9A 27HSG3G?GL:2/$,T$K'@_'I,>#3,9B^2]$ -M0SH5[D5S4SGQ$-FRV4QJ$PX,Y4:R)(J2K$G),&W,;A S+9M5Y!J2$,F#\UKJ -M)'F2:TIMP29SL!#<[%LR!WXZK[8W6Q/ -3(%Z%%$ 0 T X&1C=(/_C"R4:R= -M9U9I> ;2L\F!22E@6W./K(>=1 6BX.$\>$N6-[)6-I)5B/(9HM)BZ1U$AS& -MF"PL8)7(88V)*E%%*B/EF%066Z/^YD>)+( ><@O8)O8I0B8EBS9A_Z7'JIQP -M)4H",87XD*Y(P3DU-"@%#V=/":7L4'3$2(+<0*5H2V0([0EED8&H(" '2$<@ -M!70R0+C/ (D 5.B/J13 .%<&,D[JA4TH3C*!&0I,9?X+;:#^PHVS#9#CI''. -M))8NXPI]2@9ED&19NT#]EZ '.,XWP(P34JCS&IOPO! ?:!/1WDM R2#T4@X1"XFEV)1#HB%Q -8FY81&X3S0IV3=,A,,"*D#\@ 8@"PUU," - -end - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.10 b/usr.sbin/xntpd/patches/patch.10 deleted file mode 100644 index 1771b5fef717..000000000000 --- a/usr.sbin/xntpd/patches/patch.10 +++ /dev/null @@ -1,1925 +0,0 @@ -diff -c COPYRIGHT:1.1.1.16 COPYRIGHT:1.21 -*** COPYRIGHT:1.1.1.16 Wed Feb 2 18:09:17 1994 ---- COPYRIGHT Wed Feb 2 18:09:18 1994 -*************** -*** 1,6 **** - /****************************************************************************** - * * -! * Copyright (c) David L. Mills 1992, 1993, 1994 * - * * - * Permission to use, copy, modify, and distribute this software and its * - * documentation for any purpose and without fee is hereby granted, provided * ---- 1,6 ---- - /****************************************************************************** - * * -! * Copyright (c) David L. Mills 1992, 1993, 1994 * - * * - * Permission to use, copy, modify, and distribute this software and its * - * documentation for any purpose and without fee is hereby granted, provided * -*************** -*** 55,58 **** - * Torsten Duwe (Linux Port) - * Paul A Vixie (TrueTime GPS driver) - * Jim Jagielski (A/UX port) -! */ ---- 55,58 ---- - * Torsten Duwe (Linux Port) - * Paul A Vixie (TrueTime GPS driver) - * Jim Jagielski (A/UX port) -! */ -diff -c doc/xntpd.8:1.1.1.12 doc/xntpd.8:3.24 -*** doc/xntpd.8:1.1.1.12 Wed Feb 2 18:10:44 1994 ---- doc/xntpd.8 Wed Feb 2 18:10:45 1994 -*************** -*** 446,451 **** ---- 446,467 ---- - .Ip notrust 10 - Treat these hosts normally in other respects, but never use them as - synchronization sources. -+ .Ip limited 10 -+ These hosts are subject to limitation of number of clients from the -+ same net. Net in this context refers to the IP notion of net (class A, -+ class B, class C, etc.). Only the first \*(L"client_limit\*(R" hosts -+ that have shown up at the server and that have been active during the -+ last \*(L"client_limit_period\*(R" seconds are accepted. Requests from -+ other clients from the same net are rejected. Only time request -+ packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R", -+ and \*(L"broadcast\*(R" packets are not subject to client limitation -+ and therefore are not contributing to client count. History of clients -+ is kept using the monitoring capability of -+ .IR xntpd . -+ Thus, monitoring is active as long as there is a restriction entry -+ with the \*(L"limited\*(R" flag. The default value for -+ \*(L"client_limit\*(R" is 3. The default value for -+ \*(L"client_limit_period\*(R" is 3600 seconds. - .Ip ntpport 10 - This is actually a match algorithm modifier, rather than a restriction - flag. Its presence causes the restriction entry to be matched only if -*************** -*** 469,474 **** ---- 485,505 ---- - considered an alternative to the standard NTP authentication facility. Source - address based restrictions are easily circumvented by a determined cracker. - .PP -+ .B clientlimit -+ .I limit -+ .PP -+ Sets \*(L"client_limit\*(R" to \*(L"limit\*(R", allows configuration -+ of client limitation policy. This variable defines the number of -+ clients from the same network that are allowed to use the server. -+ .PP -+ .B clientperiod -+ .I period -+ .PP -+ Sets \*(L"client_limit_period\*(R", allows configuration of client -+ limitation policy. This variable specifies the number -+ of seconds after which a client is considered inactive and thus no -+ longer is counted for client limit restriction. -+ .PP - .B trap - .I host_address - [ -diff -c doc/xntpdc.8:1.1.1.2 doc/xntpdc.8:3.4 -*** doc/xntpdc.8:1.1.1.2 Wed Feb 2 18:10:46 1994 ---- doc/xntpdc.8 Wed Feb 2 18:10:47 1994 -*************** -*** 539,544 **** ---- 539,555 ---- - Ignore all NTP mode 7 packets which attempt to modify the state of the - server (i.e. run time reconfiguration). Queries which return information - are permitted. -+ .Ip notrap 10 -+ Decline to provide mode 6 control message trap service to matching -+ hosts. The trap service is a subsystem of the mode 6 control message -+ protocol which is intended for use by remote event logging programs. -+ .Ip lowpriotrap 10 -+ Declare traps set by matching hosts to be low priority. The number -+ of traps a server can maintain is limited (the current limit is 3). -+ Traps are usually assigned on a first come, first served basis, with -+ later trap requestors being denied service. This flag modifies the -+ assignment algorithm by allowing low priority traps to be overridden -+ by later requests for normal priority traps. - .Ip noserve 10 - Ignore NTP packets whose mode is other than 7. In effect, time service is - denied, though queries may still be permitted. -*************** -*** 549,554 **** ---- 560,582 ---- - .Ip notrust 10 - Treat these hosts normally in other respects, but never use them as - synchronization sources. -+ .Ip limited 10 -+ These hosts are subject to limitation of number of clients from the -+ same net. Net in this context refers to the IP notion of net (class A, -+ class B, class C, etc.). Only the first \*(L"client_limit\*(R" hosts -+ that have shown up at the server and that have been active during the -+ last \*(L"client_limit_period\*(R" seconds are accepted. Requests from -+ other clients from the same net are rejected. Only time request -+ packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R", -+ and \*(L"broadcast\*(R" packets are not subject to client limitation -+ and therefore are not contributing to client count. History of clients -+ is kept using the monitoring capability of -+ .IR xntpd. -+ Thus, monitoring is active as long as there is a restriction entry -+ with the \*(L"limited\*(R" flag. The default value for -+ \*(L"client_limit\*(R" is 3. The default value for -+ \*(L"client_limit_period\*(R" is 3600 seconds. Currently both -+ variables are not runtime configurable. - .Ip ntpport 10 - This is actually a match algorithm modifier, rather than a restriction - flag. Its presence causes the restriction entry to be matched only if -diff -c hints/linux:1.1.1.1 hints/linux:1.2 -*** hints/linux:1.1.1.1 Wed Feb 2 18:10:58 1994 ---- hints/linux Wed Feb 2 18:10:59 1994 -*************** -*** 1,29 **** - -! Requirements: kernel 0.99.14 or newer, libc 4.5 or newer - ------------ - -! With this configuration, xntp should build an run right out of the -! box (see generic hints for how-to), with one big limitation: tickadj doesn't -! work yet. This is especially painful since PCs are usually equipped with -! untuned, badly-drifting quartzes, values up to 200 ppm being no exception. -! Because the loop filter algorithms are limited to compensating no more than -! 100 ppm, currently only one workaround is possible: -! Compile your own kernel and adjust linux/include/linux/timex.h, -! line 67 (in pl14): -! -! #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ -! -! Since this is surely not true for your hardware, adjust the hundreds -! to match your quartz. Adding 100 compensates for a drift of -83.8 ppm -! (1/CLOCK_TICK_RATE). The number gets rounded to the nearest 100 so don't -! bother to tune any finer. -! -! Fixing tickadj is already in my work queue, so the previous comment should be -! obsolete RSN. If you really need to run xntp on any earlier versions of the -! kernel or libc, or have any other question not covered in the READMEs / hint -! files (sorry, necessary comment in the Linux community ;-) feel free to ask -! me (duwe@informatik.uni-erlangen.de) -! -! xntp3.3b of 1993/12/06 : remember to change #define ntp_adjtime adjtimex to -! __adjtimex in the Linux section (line 316). This is hopefully done if you -! (don't :-) see this paragraph in the xntp3.x distribution. ---- 1,9 ---- - -! Requirements: kernel 0.99.14y or newer, libc 4.5.8 or newer - ------------ - -! With this configuration, xntp should build an run right out of the box -! (see generic hints for how-to). If you really need to run xntp on any earlier -! versions of the kernel or libc, or have any other question not covered in the -! READMEs / hint files (sorry, necessary comment in the Linux community ;-) feel -! free to ask me (duwe@informatik.uni-erlangen.de) -diff -c include/ntp.h:1.1.1.17 include/ntp.h:3.23 -*** include/ntp.h:1.1.1.17 Wed Feb 2 18:11:18 1994 ---- include/ntp.h Wed Feb 2 18:11:18 1994 -*************** -*** 612,617 **** ---- 612,620 ---- - struct mon_data *hash_prev; /* previous structure in hash list */ - struct mon_data *mru_next; /* next structure in MRU list */ - struct mon_data *mru_prev; /* previous structure in MRU list */ -+ struct mon_data *fifo_next; /* next structure in FIFO list */ -+ struct mon_data *fifo_prev; /* previous structure in FIFO list */ -+ U_LONG lastdrop; /* last time dropped due to RES_LIMIT*/ - U_LONG lasttime; /* last time data updated */ - U_LONG firsttime; /* time structure initialized */ - U_LONG count; /* count we have seen */ -*************** -*** 621,627 **** - u_char version; /* version of incoming packet */ - }; - -! - /* - * Structure used for restrictlist entries - */ ---- 624,635 ---- - u_char version; /* version of incoming packet */ - }; - -! /* -! * Values used with mon_enabled to indicate reason for enabling monitoring -! */ -! #define MON_OFF 0x00 /* no monitoring */ -! #define MON_ON 0x01 /* monitoring explicitly enabled */ -! #define MON_RES 0x02 /* implicit monitoring for RES_LIMITED */ - /* - * Structure used for restrictlist entries - */ -*************** -*** 645,654 **** - #define RES_NOPEER 0x20 /* don't allocate memory resources */ - #define RES_NOTRAP 0x40 /* don't allow him to set traps */ - #define RES_LPTRAP 0x80 /* traps set by him are low priority */ - - #define RES_ALLFLAGS \ - (RES_IGNORE|RES_DONTSERVE|RES_DONTTRUST|RES_NOQUERY\ -! |RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP) - - /* - * Match flags ---- 653,663 ---- - #define RES_NOPEER 0x20 /* don't allocate memory resources */ - #define RES_NOTRAP 0x40 /* don't allow him to set traps */ - #define RES_LPTRAP 0x80 /* traps set by him are low priority */ -+ #define RES_LIMITED 0x100 /* limit per net number of clients */ - - #define RES_ALLFLAGS \ - (RES_IGNORE|RES_DONTSERVE|RES_DONTTRUST|RES_NOQUERY\ -! |RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP|RES_LIMITED) - - /* - * Match flags -diff -c include/ntp_request.h:1.1.1.7 include/ntp_request.h:3.7 -*** include/ntp_request.h:1.1.1.7 Wed Feb 2 18:11:27 1994 ---- include/ntp_request.h Wed Feb 2 18:11:28 1994 -*************** -*** 429,438 **** ---- 429,456 ---- - U_LONG processed; /* packets processed */ - U_LONG badauth; /* packets dropped because of authorization */ - U_LONG wanderhold; -+ U_LONG limitrejected; /* rejected because of client limitation */ - }; - - - /* -+ * System stats - old version -+ */ -+ struct old_info_sys_stats { -+ U_LONG timeup; /* time we have been up and running */ -+ U_LONG timereset; /* time since these were last cleared */ -+ U_LONG badstratum; /* packets claiming an invalid stratum */ -+ U_LONG oldversionpkt; /* old version packets received */ -+ U_LONG newversionpkt; /* new version packets received */ -+ U_LONG unknownversion; /* don't know version packets */ -+ U_LONG badlength; /* packets with bad length */ -+ U_LONG processed; /* packets processed */ -+ U_LONG badauth; /* packets dropped because of authorization */ -+ U_LONG wanderhold; -+ }; -+ -+ -+ /* - * Peer memory statistics. Collected in the peer module. - */ - struct info_mem_stats { -*************** -*** 546,551 **** ---- 564,570 ---- - struct info_monitor { - U_LONG lasttime; /* last packet from this host */ - U_LONG firsttime; /* first time we received a packet */ -+ U_LONG lastdrop; /* last time we rejected a packet due to client limitation policy */ - U_LONG count; /* count of packets received */ - U_LONG addr; /* host address */ - u_short port; /* port number of last reception */ -*************** -*** 553,558 **** ---- 572,589 ---- - u_char version; /* version number of last packet */ - }; - -+ /* -+ * Structure used for returning monitor data (old format -+ */ -+ struct old_info_monitor { -+ U_LONG lasttime; /* last packet from this host */ -+ U_LONG firsttime; /* first time we received a packet */ -+ U_LONG count; /* count of packets received */ -+ U_LONG addr; /* host address */ -+ u_short port; /* port number of last reception */ -+ u_char mode; /* mode of last packet */ -+ u_char version; /* version number of last packet */ -+ }; - - /* - * Structure used for passing indication of flags to clear -diff -c include/ntp_stdlib.h:1.1.1.7 include/ntp_stdlib.h:1.2 -*** include/ntp_stdlib.h:1.1.1.7 Wed Feb 2 18:11:31 1994 ---- include/ntp_stdlib.h Wed Feb 2 18:11:31 1994 -*************** -*** 79,84 **** ---- 79,85 ---- - extern char * mfptoa P((U_LONG, U_LONG, int)); - extern char * mfptoms P((U_LONG, U_LONG, int)); - extern char * modetoa P((int)); -+ extern U_LONG netof P((U_LONG)); - extern char * numtoa P((U_LONG)); - extern char * numtohost P((U_LONG)); - extern int octtoint P((const char *, U_LONG *)); -diff -c include/ntpd.h:1.1.1.7 include/ntpd.h:1.6 -*** include/ntpd.h:1.1.1.7 Wed Feb 2 18:11:38 1994 ---- include/ntpd.h Wed Feb 2 18:11:38 1994 -*************** -*** 93,100 **** - - /* ntp_monitor.c */ - extern void init_mon P((void)); -! extern void mon_start P((void)); -! extern void mon_stop P((void)); - extern void monitor P((struct recvbuf *)); - - /* ntp_peer.c */ ---- 93,100 ---- - - /* ntp_monitor.c */ - extern void init_mon P((void)); -! extern void mon_start P((int)); -! extern void mon_stop P((int)); - extern void monitor P((struct recvbuf *)); - - /* ntp_peer.c */ -diff -c lib/Makefile.tmpl:1.1.1.14 lib/Makefile.tmpl:3.25 -*** lib/Makefile.tmpl:1.1.1.14 Wed Feb 2 18:12:06 1994 ---- lib/Makefile.tmpl Wed Feb 2 18:12:07 1994 -*************** -*** 31,37 **** - uglydate.c uinttoa.c utvtoa.c machines.c clocktypes.c \ - md5.c a_md5encrypt.c a_md5decrypt.c \ - a_md512crypt.c decodenetnum.c systime.c msyslog.c syssignal.c \ -! findconfig.c - - OBJS= atoint.o atolfp.o atouint.o auth12crypt.o authdecrypt.o authdes.o \ - authencrypt.o authkeys.o authparity.o authreadkeys.o authusekey.o \ ---- 31,37 ---- - uglydate.c uinttoa.c utvtoa.c machines.c clocktypes.c \ - md5.c a_md5encrypt.c a_md5decrypt.c \ - a_md512crypt.c decodenetnum.c systime.c msyslog.c syssignal.c \ -! findconfig.c netof.c - - OBJS= atoint.o atolfp.o atouint.o auth12crypt.o authdecrypt.o authdes.o \ - authencrypt.o authkeys.o authparity.o authreadkeys.o authusekey.o \ -*************** -*** 44,50 **** - uglydate.o uinttoa.o utvtoa.o machines.o clocktypes.o \ - md5.o a_md5encrypt.o a_md5decrypt.o \ - a_md512crypt.o decodenetnum.o systime.o msyslog.o syssignal.o \ -! findconfig.o - - $(LIBNAME).a: $(OBJS) - ar rv $@ $? ---- 44,50 ---- - uglydate.o uinttoa.o utvtoa.o machines.o clocktypes.o \ - md5.o a_md5encrypt.o a_md5decrypt.o \ - a_md512crypt.o decodenetnum.o systime.o msyslog.o syssignal.o \ -! findconfig.o netof.o - - $(LIBNAME).a: $(OBJS) - ar rv $@ $? -diff -c /dev/null lib/netof.c:3.1 -*** /dev/null Wed Feb 2 18:13:07 1994 ---- lib/netof.c Wed Feb 2 18:13:07 1994 -*************** -*** 0 **** ---- 1,25 ---- -+ /* -+ * netof - return the net address part of an ip address -+ * (zero out host part) -+ */ -+ #include -+ -+ #include "ntp_fp.h" -+ #include "ntp_stdlib.h" -+ -+ U_LONG -+ netof(num) -+ U_LONG num; -+ { -+ register U_LONG netnum; -+ -+ netnum = num; -+ -+ if(IN_CLASSC(netnum)) -+ netnum &= IN_CLASSC_NET; -+ else if (IN_CLASSB(netnum)) -+ netnum &= IN_CLASSB_NET; -+ else /* treat als other like class A */ -+ netnum &= IN_CLASSA_NET; -+ return netnum; -+ } -diff -c /dev/null parse/README.new_clocks:3.2 -*** /dev/null Wed Feb 2 18:14:30 1994 ---- parse/README.new_clocks Wed Feb 2 18:14:30 1994 -*************** -*** 0 **** ---- 1,203 ---- -+ Here is an attempt to scetch out what you need to do in order to -+ add another clock to the parse driver: -+ -+ Prerequsites: -+ - Does the system you want the clock connect to have -+ termio.h or termios.h ? (You need that for the parse driver) -+ -+ What to do: -+ -+ Make a conversion module (parse/clk_*.c) -+ -+ - What ist the time code format ? -+ - find year, month, day, hour, minute, second, status (synchronised or -+ not), possibly time zone information (you need to give the offset to UTC) -+ You will have to convert the data from a string into a struct clocktime: -+ struct clocktime /* clock time broken up from time code */ -+ { -+ LONG day; -+ LONG month; -+ LONG year; -+ LONG hour; -+ LONG minute; -+ LONG second; -+ LONG usecond; -+ LONG utcoffset; /* in seconds */ -+ LONG flags; /* current clock status */ -+ }; -+ -+ Conversion is usually simple and straight forward. For the flags following -+ values can be OR'ed together: -+ -+ PARSEB_ANNOUNCE switch time zone warning (informational only) -+ PARSEB_POWERUP no synchronisation - clock confused (must set then) -+ PARSEB_NOSYNC timecode currently not confirmed (must set then) -+ usually on reception error when the is still a -+ chance the the generated time is still ok. -+ -+ PARSEB_DST DST in effect (informational only) -+ PARSEB_UTC timecode contains UTC time (informational only) -+ PARSEB_LEAP LEAP warning (prior to leap happening - must set when imminent) -+ PARSEB_ALTERNATE backup transmitter (informational only) -+ PARSEB_POSITION geographic position available (informational only) -+ PARSEB_LEAPSECOND actual leap second (this time code is the leap -+ second - informational only) -+ -+ These are feature flags denoting items that are supported by the clock: -+ PARSEB_S_LEAP supports LEAP - might set PARSEB_LEAP -+ PARSEB_S_ANTENNA supports ANTENNA - might set PARSEB_ALTERNATE -+ PARSEB_S_PPS supports PPS time stamping -+ PARSEB_S_POSITION supports position information (GPS) -+ -+ Conversion is done in the cvt_* routine in parse/clk_*.c files. look in -+ them for examples. The basic structure is: -+ -+ struct clockformat _format = { -+ lots of field for you to fill out (see below) -+ }; -+ -+ static cvt_() -+ ... -+ { -+ if () { -+ return CVT_NONE; -+ } else { -+ if () { -+ ; -+ return CVT_OK; -+ } else { -+ return CVT_FAIL|CVT_BADFMT; -+ } -+ } -+ -+ The struct clockformat is the interface to the rest of the parse -+ driver - it holds all information necessary for finding the -+ clock message and doing the appropriate time stamping. -+ -+ struct clockformat -+ { -+ unsigned LONG (*convert)(); -+ /* conversion routine - your routine - cvt_ */ -+ void (*syncevt)(); -+ /* routine for handling RS232 sync events (time stamps) - usually sync_simple */ -+ unsigned LONG (*syncpps)(); -+ /* PPS input routine - usually pps_simple */ -+ unsigned LONG (*synth)(); -+ /* time code synthesizer - usually not used - (LONG (*)())0 */ -+ void *data; -+ /* local parameters - any parameters/data/configuration info your conversion -+ routine might need */ -+ char *name; -+ /* clock format name - Name of the time code */ -+ unsigned short length; -+ /* maximum length of data packet for your clock format */ -+ unsigned LONG flags; -+ /* information for the parser what to look for */ -+ struct timeval timeout; -+ /* buffer restart after timeout (us) - some clocks preceede new data by -+ a longer period of silence - unsually not used */ -+ unsigned char startsym; -+ /* start symbol - character at the beginning of the clock data */ -+ unsigned char endsym; -+ /* end symbol - character at the end of the clock data */ -+ unsigned char syncsym; -+ /* sync symbol - character that is "on time" - where the time stamp should be taken */ -+ }; -+ -+ The flags: -+ F_START use startsym to find the beginning of the clock data -+ F_END use endsym to find the end of the clock data -+ SYNC_TIMEOUT packet restart after timeout in timeout field -+ SYNC_START packet start is sync event (time stamp at paket start) -+ SYNC_END packet end is sync event (time stamp at paket end) -+ SYNC_CHAR special character (syncsym) is sync event -+ SYNC_ONE PPS synchronize on 'ONE' transition -+ SYNC_ZERO PPS synchronize on 'ZERO' transition -+ SYNC_SYNTHESIZE generate intermediate time stamps (very special case!) -+ CVT_FIXEDONLY convert only in fixed configuration - (data format not -+ suitable for auto-configuration) -+ -+ -+ The above should have given you some hints on how to build a clk_*.c -+ file with the time code conversion. See the examples and pick a clock -+ closest to yours and tweak the code to match your clock. -+ -+ In order to make your clk_*.c file usable a referenc to the clockformat -+ structure must be put into parse_conf.c. -+ -+ -+ -+ TTY setup and initialisation/configuration will be done in -+ xntpd/refclock_parse.c -+ -+ - Find out the exact tty settings for your clock (baud rate, parity, -+ stop bits, character size, ...) and note them in terms of -+ termio*.h c_cflag macros. -+ -+ - in xntpd/refclock_parse.c fill out a new the struct clockinfo element -+ (allocates a new "IP" address - see comments) -+ (see all the other clocks for example) -+ struct clockinfo -+ { -+ U_LONG cl_flags; /* operation flags (io modes) */ -+ PARSE_F_NOPOLLONLY always do async io - read whenever input comes -+ PARSE_F_POLLONLY never do async io - only read when expecting data -+ PARSE_F_PPSPPS use loopfilter PPS code (CIOGETEV) -+ PARSE_F_PPSONSECOND PPS pulses are on second -+ usually flags stay 0 as they are used only for special setups -+ -+ void (*cl_poll)(); /* active poll routine */ -+ The routine to call when the clock needs data sent to it in order to -+ get a time code from the clock (e.g. Trimble clock) -+ int (*cl_init)(); /* active poll init routine */ -+ The routine to call for very special initializations. -+ void (*cl_end)(); /* active poll end routine */ -+ The routine to call to undo any special initialisation (free memory/timers) -+ void *cl_data; /* local data area for "poll" mechanism */ -+ local data for polling routines -+ u_fp cl_rootdelay; /* rootdelay */ -+ NTP rottdelay estimate (usually 0) -+ U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional par -+ time (fraction) by which the RS232 time code is delayed from the actual time. -+ t */ -+ U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional -+ time (fraction) by which the PPS time stamp is delayed (usually 0) -+ part */ -+ char *cl_id; /* ID code (usually "DCF") */ -+ Refclock id - (max 4 chars) -+ char *cl_description; /* device name */ -+ Name of this device. -+ char *cl_format; /* fixed format */ -+ If the data format cann not ne detected automatically this is the name -+ as in clk_*.c clockformat. -+ u_char cl_type; /* clock type (ntp control) */ -+ Type if clock as in clock status word (ntp control messages) - usually 0 -+ U_LONG cl_maxunsync; /* time to trust oscillator after loosing synch -+ */ -+ seconds a clock can be trusted after loosing synchronisation. -+ -+ U_LONG cl_cflag; /* terminal io flags */ -+ U_LONG cl_iflag; /* terminal io flags */ -+ U_LONG cl_oflag; /* terminal io flags */ -+ U_LONG cl_lflag; /* terminal io flags */ -+ termio*.h tty modes. -+ } clockinfo[] = { -+ ...,,... -+ { < your parameters> }, -+ }; -+ -+ -+ Well, this is very sketchy, i know. But I hope it helps a little bit. -+ The best way is to look which clock comes closet to your and tweak that -+ code. -+ Two sorts of clocks are used with parse. Clocks that automatically sent -+ thier time code (once a second) do not nee entries in the poll routines because -+ they sent the data all the time. The second sort are the clocks that need a -+ command sent to then in order to reply with a time code (like the Trimble -+ clock). -+ -+ For questions: kardel@informatik.uni-erlangen.de. Please include -+ an exact description on how your clock works. (initialisation, -+ TTY modes, strings to be sent to it, responses received from the clock). -+ -+ Frank Kardel -diff -c /dev/null parse/README.parse_clocks:3.1 -*** /dev/null Wed Feb 2 18:14:33 1994 ---- parse/README.parse_clocks Wed Feb 2 18:14:33 1994 -*************** -*** 0 **** ---- 1,263 ---- -+ The parse driver currently supports several clock with different -+ query mechanisms. In order for you to find a sample that might be -+ similar to a clock you might want to integrate into parse i'll sum -+ up the major features of the clocks (this information is distributed -+ in the parse/clk_*.c and xntpd/refclock_parse.c files). -+ -+ --- -+ Meinberg: 127.127.8. 0- 3 (PZF535TCXO) -+ 127.127.8. 4- 7 (PZF535OCXO) -+ 127.127.8. 8-11 (DCFUA31) -+ 127.127.8.28-31 (GPS166) -+ Meinberg: start=, end=, sync on start -+ pattern="\2D: . . ;T: ;U: . . ; \3" -+ pattern="\2 . . ; ; : : ; \3" -+ pattern="\2 . . ; ; : : ; : ; ; . . " -+ -+ Meinberg is a german manufacturer of time code receivers. Those clocks -+ have a pretty common output format in the stock version. In order to -+ support NTP Meinberg was so kind to produce some special versions of -+ the firmware for the use with NTP. So, if you are going to use a -+ Meinberg clock please ask whether there is a special Uni Erlangen -+ version. -+ -+ General characteristics: -+ Meinberg clocks primarily output pulse per second and a describing -+ ASCII string. This string can be produced in two modes. either upon -+ the reception of a question mark or every second. NTP uses the latter -+ mechanism. The DCF77 variants have a pretty good relationship between -+ RS232 time code and the PPS signal while the GPS receiver has no fixed -+ timeing between the datagram and the pulse (you need to use PPS with -+ GPS!) on DCF77 you might get away without the PPS signal. -+ -+ The preferred tty setting for Meinberg is: -+ CFLAG (B9600|CS7|PARENB|CREAD|HUPCL) -+ IFLAG (IGNBRK|IGNPAR|ISTRIP) -+ OFLAG 0 -+ LFLAG 0 -+ -+ The clock is run at datagram once per second. -+ Stock dataformat is: -+ -+ D:

..;T:;U:::; -+ pos: 0 00 00 0 00 0 11 111 1 111 12 2 22 2 22 2 2 2 3 3 3 -+ 1 23 45 6 78 9 01 234 5 678 90 1 23 4 56 7 8 9 0 1 2 -+ -+ = '\002' ASCII start of text -+ = '\003' ASCII end of text -+
,, = day, month, year(2 digits!!) -+ = day of week (sunday= 0) -+ ,, = hour, minute, second -+ = '#' if never synced since powerup else ' ' for DCF U/A 31 -+ '#' if not PZF sychronisation available else ' ' for PZF 535 -+ = '*' if time comes from internal quartz else ' ' -+ = 'S' if daylight saving time is active else ' ' -+ = '!' during the hour preceeding an daylight saving time -+ start/end change -+ -+ For the university of Erlangen a special format was implemented to support -+ LEAP announcement and anouncement of alternate antenna. -+ -+ Version for UNI-ERLANGEN Software is: PZFUERL V4.6 (Meinberg) -+ -+ The use of this software release (or higher) is *ABSOLUTELY* -+ recommended (ask for PZFUERL version as some minor HW fixes have -+ been introduced) due to the LEAP second support and UTC indication. -+ The standard timecode does not indicate when the timecode is in -+ UTC (by front panel configuration) thus we have no chance to find -+ the correct utc offset. For the standard format do not ever use -+ UTC display as this is not detectable in the time code !!! -+ -+
..; ; ::; -+ pos: 0 00 0 00 0 00 11 1 11 11 1 11 2 22 22 2 2 2 2 2 3 3 3 -+ 1 23 4 56 7 89 01 2 34 56 7 89 0 12 34 5 6 7 8 9 0 1 2 -+ = '\002' ASCII start of text -+ = '\003' ASCII end of text -+
,, = day, month, year(2 digits!!) -+ = day of week (sunday= 0) -+ ,, = hour, minute, second -+ = 'U' UTC time display -+ = '#' if never synced since powerup else ' ' for DCF U/A 31 -+ '#' if not PZF sychronisation available else ' ' for PZF 535 -+ = '*' if time comes from internal quartz else ' ' -+ = 'S' if daylight saving time is active else ' ' -+ = '!' during the hour preceeding an daylight saving time -+ start/end change -+ = 'A' LEAP second announcement -+ = 'R' alternate antenna -+ -+ Meinberg GPS166 receiver -+ -+ You must get the Uni-Erlangen firmware for the GPS receiver support -+ to work to full satisfaction ! -+ -+
..; ; ::; <+/-><00:00>; ; -+ * -+ 000000000111111111122222222223333333333444444444455555555556666666 -+ 123456789012345678901234567890123456789012345678901234567890123456 -+ \x0209.07.93; 5; 08:48:26; +00:00; ; 49.5736N 11.0280E 373m\x03 -+ * -+ -+ = '\002' ASCII start of text -+ = '\003' ASCII end of text -+
,, = day, month, year(2 digits!!) -+ = day of week (sunday= 0) -+ ,, = hour, minute, second -+ <+/->,<00:00> = offset to UTC -+ = '#' if never synced since powerup else ' ' for DCF U/A 31 -+ '#' if not PZF sychronisation available else ' ' for PZF 535 -+ = 'U' UTC time display -+ = '*' if time comes from internal quartz else ' ' -+ = 'S' if daylight saving time is active else ' ' -+ = '!' during the hour preceeding an daylight saving time -+ start/end change -+ = 'A' LEAP second announcement -+ = 'R' alternate antenna (reminiscent of PZF535) usually ' ' -+ = 'L' on 23:59:60 -+ -+ -+ For the Meinberg parse look into clock_meinberg.c -+ -+ --- -+ RAWDCF: 127.127.8.20-23 (Conrad receiver module - delay 210ms) -+ 127.127.8.24-27 (FAU receiver - delay 258ms) -+ RAWDCF: end=TIMEOUT>1.5s, sync each char (any char),generate psuedo time -+ codes, fixed format -+ -+ direct DCF77 code input -+ In Europe it is relatively easy/cheap the receive the german time code -+ transmitter DCF77. The simplest version to process its signal is to -+ feed the 100/200ms pulse of the demodulated AM signal via a level -+ converter to an RS232 port at 50Baud. parse/clk_rawdcf.c holds all -+ necessary decoding logic for the time code which is transmitted each -+ minute for one minute. A bit of the time code is sent once a second. -+ -+ The preferred tty setting is: -+ CFLAG (B50|CS8|CREAD|CLOCAL) -+ IFLAG 0 -+ OFLAG 0 -+ LFLAG 0 -+ -+ DCF77 raw time code -+ -+ From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig -+ und Berlin, Maerz 1989 -+ -+ Timecode transmission: -+ AM: -+ time marks are send every second except for the second before the -+ next minute mark -+ time marks consist of a reduction of transmitter power to 25% -+ of the nominal level -+ the falling edge is the time indication (on time) -+ time marks of a 100ms duration constitute a logical 0 -+ time marks of a 200ms duration constitute a logical 1 -+ FM: -+ see the spec. (basically a (non-)inverted psuedo random phase shift) -+ -+ Encoding: -+ Second Contents -+ 0 - 10 AM: free, FM: 0 -+ 11 - 14 free -+ 15 R - alternate antenna -+ 16 A1 - expect zone change (1 hour before) -+ 17 - 18 Z1,Z2 - time zone -+ 0 0 illegal -+ 0 1 MEZ (MET) -+ 1 0 MESZ (MED, MET DST) -+ 1 1 illegal -+ 19 A2 - expect leap insertion/deletion (1 hour before) -+ 20 S - start of time code (1) -+ 21 - 24 M1 - BCD (lsb first) Minutes -+ 25 - 27 M10 - BCD (lsb first) 10 Minutes -+ 28 P1 - Minute Parity (even) -+ 29 - 32 H1 - BCD (lsb first) Hours -+ 33 - 34 H10 - BCD (lsb first) 10 Hours -+ 35 P2 - Hour Parity (even) -+ 36 - 39 D1 - BCD (lsb first) Days -+ 40 - 41 D10 - BCD (lsb first) 10 Days -+ 42 - 44 DW - BCD (lsb first) day of week (1: Monday -> 7: Sunday) -+ 45 - 49 MO - BCD (lsb first) Month -+ 50 MO0 - 10 Months -+ 51 - 53 Y1 - BCD (lsb first) Years -+ 54 - 57 Y10 - BCD (lsb first) 10 Years -+ 58 P3 - Date Parity (even) -+ 59 - usually missing (minute indication), except for leap insertion -+ -+ --- -+ Schmid clock: 127.127.8.16-19 -+ Schmid clock: needs poll, binary input, end='\xFC', sync start -+ -+ The Schmid clock is a DCF77 receiver that sends a binary -+ time code at the reception of a flag byte. The contents -+ if the flag byte determined the time code format. The -+ binary time code is delimited by the byte 0xFC. -+ -+ TTY setup is: -+ CFLAG (B1200|CS8|CREAD|CLOCAL) -+ IFLAG 0 -+ OFLAG 0 -+ LFLAG 0 -+ -+ The command to Schmid's DCF77 clock is a single byte; each bit -+ allows the user to select some part of the time string, as follows (the -+ output for the lsb is sent first). -+ -+ Bit 0: time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.tenths -+ Bit 1: date 3 bytes *binary, not BCD: dd.mm.yy -+ Bit 2: week day, 1 byte (unused here) -+ Bit 3: time zone, 1 byte, 0=MET, 1=MEST. (unused here) -+ Bit 4: clock status, 1 byte, 0=time invalid, -+ 1=time from crystal backup, -+ 3=time from DCF77 -+ Bit 5: transmitter status, 1 byte, -+ bit 0: backup antenna -+ bit 1: time zone change within 1h -+ bit 3,2: TZ 01=MEST, 10=MET -+ bit 4: leap second will be -+ added within one hour -+ bits 5-7: Zero -+ Bit 6: time in backup mode, units of 5 minutes (unused here) -+ -+ -+ --- -+ Trimble SV6: 127.127.8.32-35 -+ Trimble SV6: needs poll, ascii timecode, start='>', end='<', -+ query='>QTM<', eol='<' -+ -+ Trimble SV6 is a GPS receiver with PPS output. It needs to be polled. -+ It also need a special tty mode setup (EOL='<'). -+ -+ TTY setup is: -+ CFLAG (B4800|CS8|CREAD) -+ IFLAG (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON) -+ OFLAG (OPOST|ONLCR) -+ LFLAG (ICANON|ECHOK) -+ -+ Special flags are: -+ PARSE_F_PPSPPS - use CIOGETEV for PPS time stamping -+ PARSE_F_PPSONSECOND - the time code is not related to -+ the PPS pulse (so use the time code -+ only for the second epoch) -+ -+ Timecode -+ 0000000000111111111122222222223333333 / char -+ 0123456789012345678901234567890123456 \ posn -+ >RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx< Actual -+ ----33445566600112222BB7__-_____--99- Parse -+ >RTM 1 ;* <", Check -+ -+ --- -+ ELV DCF7000: 127.127.8.12-15 -+ ELV DCF7000: end='\r', pattern=" - - - - - - - \r" -+ -+ The ELV DCF7000 is a cheap DCF77 receiver sending each second -+ a time code (though not very precise!) delimited by '`r' -+ -+ Timecode -+ YY-MM-DD-HH-MM-SS-FF\r -+ -+ FF&0x1 - DST -+ FF&0x2 - DST switch warning -+ FF&0x4 - unsynchronised -+ -diff -c parse/parsesolaris.c:1.1.1.5 parse/parsesolaris.c:3.11 -*** parse/parsesolaris.c:1.1.1.5 Wed Feb 2 18:14:49 1994 ---- parse/parsesolaris.c Wed Feb 2 18:14:49 1994 -*************** -*** 65,71 **** - { - "parse", /* module name */ - &parseinfo, /* module information */ -! 0, /* not clean yet */ - /* lock ptr */ - }; - ---- 65,71 ---- - { - "parse", /* module name */ - &parseinfo, /* module information */ -! D_NEW, /* not clean yet */ - /* lock ptr */ - }; - -diff -c scripts/support/bin/monl:1.1.1.1 scripts/support/bin/monl:1.2 -*** scripts/support/bin/monl:1.1.1.1 Wed Feb 2 18:16:01 1994 ---- scripts/support/bin/monl Wed Feb 2 18:16:01 1994 -*************** -*** 143,149 **** - { - chop; - split; -! ($host, $count, $mode, $version, $lasttime, $firsttime) = (@_[$[, $[+2 .. $[+6]); - - $Seen{$host, $mode} = 1; - ---- 143,150 ---- - { - chop; - split; -! ($host, $count, $mode, $version, $lasttime, $firsttime) = -! (@_[$[, $[+2 .. $[+4, $#_-1,$#_]); - - $Seen{$host, $mode} = 1; - -diff -c util/tickadj.c:1.1.1.16 util/tickadj.c:3.17 -*** util/tickadj.c:1.1.1.16 Wed Feb 2 18:16:23 1994 ---- util/tickadj.c Wed Feb 2 18:16:23 1994 -*************** -*** 1,4 **** -! /* tickadj.c,v 3.1 1993/07/06 01:11:05 jbj Exp - * tickadj - read, and possibly modify, the kernel `tick' and - * `tickadj' variables, as well as `dosynctodr'. Note that - * this operates on the running kernel only. I'd like to be ---- 1,4 ---- -! /* - * tickadj - read, and possibly modify, the kernel `tick' and - * `tickadj' variables, as well as `dosynctodr'. Note that - * this operates on the running kernel only. I'd like to be -*************** -*** 6,11 **** ---- 6,46 ---- - * mastered this yet. - */ - #include -+ -+ #ifdef SYS_LINUX -+ #include -+ -+ struct timex txc; -+ -+ int -+ main(int argc, char ** argv) -+ { -+ if (argc > 2) -+ { -+ fprintf(stderr, "Usage: %s [tick_value]\n", argv[0]); -+ exit(-1); -+ } -+ else if (argc == 2) -+ { -+ if ( (txc.tick = atoi(argv[1])) < 1 ) -+ { -+ fprintf(stderr, "Silly value for tick: %s\n", argv[1]); -+ exit(-1); -+ } -+ txc.mode = ADJ_TICK; -+ } -+ else -+ txc.mode = 0; -+ -+ if (__adjtimex(&txc) < 0) -+ perror("adjtimex"); -+ else -+ printf("tick = %d\n", txc.tick); -+ -+ return(0); -+ } -+ #else /* not Linux... kmem tweaking: */ -+ - #include - #include - #include -*************** -*** 513,515 **** ---- 548,551 ---- - exit(1); - } - } -+ #endif /* not Linux */ -diff -c xntpd/ntp_config.c:1.1.1.19 xntpd/ntp_config.c:3.24 -*** xntpd/ntp_config.c:1.1.1.19 Wed Feb 2 18:16:36 1994 ---- xntpd/ntp_config.c Wed Feb 2 18:16:37 1994 -*************** -*** 58,63 **** ---- 58,64 ---- - * statsdir /var/NTP/ - * filegen peerstats [ file peerstats ] [ type day ] [ link ] - * resolver /path/progname -+ * netlimit integer - * - * And then some. See the manual page. - */ -*************** -*** 94,99 **** ---- 95,102 ---- - #define CONFIG_PIDFILE 25 - #define CONFIG_LOGFILE 26 - #define CONFIG_SETVAR 27 -+ #define CONFIG_CLIENTLIMIT 28 -+ #define CONFIG_CLIENTPERIOD 29 - - #define CONF_MOD_VERSION 1 - #define CONF_MOD_KEY 2 -*************** -*** 114,119 **** ---- 117,123 ---- - #define CONF_RES_NOTRAP 8 - #define CONF_RES_LPTRAP 9 - #define CONF_RES_NTPPORT 10 -+ #define CONF_RES_LIMITED 11 - - #define CONF_TRAP_PORT 1 - #define CONF_TRAP_INTERFACE 2 -*************** -*** 179,184 **** ---- 183,190 ---- - { "pidfile", CONFIG_PIDFILE }, - { "logfile", CONFIG_LOGFILE }, - { "setvar", CONFIG_SETVAR }, -+ { "clientlimit", CONFIG_CLIENTLIMIT }, -+ { "clientperiod", CONFIG_CLIENTPERIOD }, - { "", CONFIG_UNKNOWN } - }; - -*************** -*** 217,222 **** ---- 223,229 ---- - { "notrap", CONF_RES_NOTRAP }, - { "lowpriotrap", CONF_RES_LPTRAP }, - { "ntpport", CONF_RES_NTPPORT }, -+ { "limited", CONF_RES_LIMITED }, - { "", CONFIG_UNKNOWN } - }; - -*************** -*** 817,825 **** - errflg = 0; - if (ntokens >= 2) { - if (STREQ(tokens[1], "yes")) -! mon_start(); - else if (STREQ(tokens[1], "no")) -! mon_stop(); - else - errflg++; - } else { ---- 824,832 ---- - errflg = 0; - if (ntokens >= 2) { - if (STREQ(tokens[1], "yes")) -! mon_start(MON_ON); - else if (STREQ(tokens[1], "no")) -! mon_stop(MON_ON); - else - errflg++; - } else { -*************** -*** 965,970 **** ---- 972,981 ---- - peerkey |= RESM_NTPONLY; - break; - -+ case CONF_RES_LIMITED: -+ peerversion |= RES_LIMITED; -+ break; -+ - case CONFIG_UNKNOWN: - errflg++; - break; -*************** -*** 1413,1418 **** ---- 1424,1483 ---- - set_sys_var(tokens[1], strlen(tokens[1])+1, RW | - ((((ntokens > 2) && !strcmp(tokens[2], "default"))) ? DEF : 0)); - } -+ break; -+ -+ case CONFIG_CLIENTLIMIT: -+ if (ntokens < 2) -+ { -+ syslog(LOG_ERR, -+ "no value for clientlimit command - line ignored"); -+ } -+ else -+ { -+ U_LONG i; -+ if (!atouint(tokens[1], &i) || !i) -+ { -+ syslog(LOG_ERR, -+ "illegal value for clientlimit command - line ignored"); -+ } -+ else -+ { -+ extern U_LONG client_limit; -+ char bp[80]; -+ -+ sprintf(bp, "client_limit=%d", i); -+ set_sys_var(bp, strlen(bp)+1, RO); -+ -+ client_limit = i; -+ } -+ } -+ break; -+ -+ case CONFIG_CLIENTPERIOD: -+ if (ntokens < 2) -+ { -+ syslog(LOG_ERR, -+ "no value for clientperiod command - line ignored"); -+ } -+ else -+ { -+ U_LONG i; -+ if (!atouint(tokens[1], &i) || i < 64) -+ { -+ syslog(LOG_ERR, -+ "illegal value for clientperiod command - line ignored"); -+ } -+ else -+ { -+ extern U_LONG client_limit_period; -+ char bp[80]; -+ -+ sprintf(bp, "client_limit_period=%d", i); -+ set_sys_var(bp, strlen(bp)+1, RO); -+ -+ client_limit_period = i; -+ } -+ } - break; - } - } -diff -c xntpd/ntp_monitor.c:1.1.1.10 xntpd/ntp_monitor.c:3.9 -*** xntpd/ntp_monitor.c:1.1.1.10 Wed Feb 2 18:16:48 1994 ---- xntpd/ntp_monitor.c Wed Feb 2 18:16:48 1994 -*************** -*** 58,64 **** - static struct mon_data *mon_hash; /* Pointer to array of hash buckets */ - static int *mon_hash_count; /* Point to hash count stats keeper */ - struct mon_data mon_mru_list; -! - /* - * List of free structures structures, and counters of free and total - * structures. The free structures are linked with the hash_next field. ---- 58,64 ---- - static struct mon_data *mon_hash; /* Pointer to array of hash buckets */ - static int *mon_hash_count; /* Point to hash count stats keeper */ - struct mon_data mon_mru_list; -! struct mon_data mon_fifo_list; - /* - * List of free structures structures, and counters of free and total - * structures. The free structures are linked with the hash_next field. -*************** -*** 93,99 **** - * Don't do much of anything here. We don't allocate memory - * until someone explicitly starts us. - */ -! mon_enabled = 0; - mon_have_memory = 0; - - mon_free_mem = 0; ---- 93,99 ---- - * Don't do much of anything here. We don't allocate memory - * until someone explicitly starts us. - */ -! mon_enabled = MON_OFF; - mon_have_memory = 0; - - mon_free_mem = 0; -*************** -*** 103,108 **** ---- 103,109 ---- - mon_hash = 0; - mon_hash_count = 0; - memset((char *)&mon_mru_list, 0, sizeof mon_mru_list); -+ memset((char *)&mon_fifo_list, 0, sizeof mon_fifo_list); - } - - -*************** -*** 110,122 **** - * mon_start - start up the monitoring software - */ - void -! mon_start() - { - register struct mon_data *md; - register int i; - -! if (mon_enabled) - return; - - if (!mon_have_memory) { - mon_hash = (struct mon_data *) ---- 111,128 ---- - * mon_start - start up the monitoring software - */ - void -! mon_start(mode) -! int mode; - { - register struct mon_data *md; - register int i; - -! if (mon_enabled != MON_OFF) { -! mon_enabled |= mode; - return; -+ } -+ if (mode == MON_OFF) -+ return; /* Ooops.. */ - - if (!mon_have_memory) { - mon_hash = (struct mon_data *) -*************** -*** 142,148 **** - mon_mru_list.mru_next = &mon_mru_list; - mon_mru_list.mru_prev = &mon_mru_list; - -! mon_enabled = 1; - } - - ---- 148,157 ---- - mon_mru_list.mru_next = &mon_mru_list; - mon_mru_list.mru_prev = &mon_mru_list; - -! mon_fifo_list.fifo_next = &mon_fifo_list; -! mon_fifo_list.fifo_prev = &mon_fifo_list; -! -! mon_enabled = mode; - } - - -*************** -*** 150,161 **** - * mon_stop - stop the monitoring software - */ - void -! mon_stop() - { - register struct mon_data *md; - register int i; - -! if (!mon_enabled) - return; - - /* ---- 159,177 ---- - * mon_stop - stop the monitoring software - */ - void -! mon_stop(mode) -! int mode; - { - register struct mon_data *md; - register int i; - -! if (mon_enabled == MON_OFF) -! return; -! if ((mon_enabled & mode) == 0 || mode == MON_OFF) -! return; -! -! mon_enabled &= ~mode; -! if (mon_enabled != MON_OFF) - return; - - /* -*************** -*** 176,182 **** - mon_mru_list.mru_next = &mon_mru_list; - mon_mru_list.mru_prev = &mon_mru_list; - -! mon_enabled = 0; - } - - ---- 192,199 ---- - mon_mru_list.mru_next = &mon_mru_list; - mon_mru_list.mru_prev = &mon_mru_list; - -! mon_fifo_list.fifo_next = &mon_fifo_list; -! mon_fifo_list.fifo_prev = &mon_fifo_list; - } - - -*************** -*** 194,200 **** - register int mode; - register struct mon_data *mdhash; - -! if (!mon_enabled) - return; - - pkt = &rbufp->recv_pkt; ---- 211,217 ---- - register int mode; - register struct mon_data *mdhash; - -! if (mon_enabled == MON_OFF) - return; - - pkt = &rbufp->recv_pkt; -*************** -*** 220,225 **** ---- 237,243 ---- - md->mru_prev = &mon_mru_list; - mon_mru_list.mru_next->mru_prev = md; - mon_mru_list.mru_next = md; -+ - return; - } - md = md->hash_next; -*************** -*** 240,245 **** ---- 258,269 ---- - md->hash_next->hash_prev = md->hash_prev; - md->hash_prev->hash_next = md->hash_next; - *(mon_hash_count + MON_HASH(md->rmtadr)) -= 1; -+ /* -+ * Get it from FIFO list -+ */ -+ md->fifo_prev->fifo_next = md->fifo_next; -+ md->fifo_next->fifo_prev = md->fifo_prev; -+ - } else { - if (mon_free_mem == 0) - mon_getmoremem(); -*************** -*** 252,257 **** ---- 276,282 ---- - * Got one, initialize it - */ - md->lasttime = md->firsttime = current_time; -+ md->lastdrop = 0; - md->count = 1; - md->rmtadr = netnum; - md->rmtport = NSRCPORT(&rbufp->recv_srcadr); -*************** -*** 260,266 **** - - /* - * Shuffle him into the hash table, inserting him at the -! * end. Also put him on top of the MRU list. - */ - mdhash = mon_hash + MON_HASH(netnum); - md->hash_next = mdhash; ---- 285,292 ---- - - /* - * Shuffle him into the hash table, inserting him at the -! * end. Also put him on top of the MRU list -! * and at bottom of FIFO list - */ - mdhash = mon_hash + MON_HASH(netnum); - md->hash_next = mdhash; -*************** -*** 273,278 **** ---- 299,309 ---- - md->mru_prev = &mon_mru_list; - mon_mru_list.mru_next->mru_prev = md; - mon_mru_list.mru_next = md; -+ -+ md->fifo_prev = mon_fifo_list.fifo_prev; -+ md->fifo_next = &mon_fifo_list; -+ mon_fifo_list.fifo_prev->fifo_next = md; -+ mon_fifo_list.fifo_prev = md; - } - - -diff -c xntpd/ntp_proto.c:1.1.1.19 xntpd/ntp_proto.c:3.21 -*** xntpd/ntp_proto.c:1.1.1.19 Wed Feb 2 18:16:51 1994 ---- xntpd/ntp_proto.c Wed Feb 2 18:16:52 1994 -*************** -*** 49,54 **** ---- 49,55 ---- - U_LONG sys_processed; /* packets processed */ - U_LONG sys_badauth; /* packets dropped because of authorization */ - U_LONG sys_wanderhold; /* sys_peer held to prevent wandering */ -+ U_LONG sys_limitrejected; /* pkts rejected due toclient count per net */ - - /* - * Imported from ntp_timer.c -*************** -*** 373,378 **** ---- 374,394 ---- - return; - - /* -+ * See if we only accept limited number of clients -+ * from the net this guy is from. -+ * Note: the flag is determined dynamically within restrictions() -+ */ -+ if (restrict & RES_LIMITED) { -+ extern U_LONG client_limit; -+ -+ sys_limitrejected++; -+ syslog(LOG_NOTICE, -+ "rejected mode %d request from %s - per net client limit (%d) exceeded", -+ PKT_MODE(pkt->li_vn_mode), -+ ntoa(&rbufp->recv_srcadr), client_limit); -+ return; -+ } -+ /* - * Dump anything with a putrid stratum. These will most likely - * come from someone trying to poll us with ntpdc. - */ -*************** -*** 2165,2168 **** ---- 2181,2185 ---- - sys_badauth = 0; - sys_wanderhold = 0; - sys_stattime = current_time; -+ sys_limitrejected = 0; - } -diff -c xntpd/ntp_request.c:1.1.1.14 xntpd/ntp_request.c:3.15 -*** xntpd/ntp_request.c:1.1.1.14 Wed Feb 2 18:16:55 1994 ---- xntpd/ntp_request.c Wed Feb 2 18:16:55 1994 -*************** -*** 916,921 **** ---- 916,922 ---- - extern U_LONG sys_processed; - extern U_LONG sys_badauth; - extern U_LONG sys_wanderhold; -+ extern U_LONG sys_limitrejected; - - ss = (struct info_sys_stats *)prepare_pkt(srcadr, inter, inpkt, - sizeof(struct info_sys_stats)); -*************** -*** 930,936 **** - ss->processed = htonl(sys_processed); - ss->badauth = htonl(sys_badauth); - ss->wanderhold = htonl(sys_wanderhold); -! - (void) more_pkt(); - flush_pkt(); - } ---- 931,937 ---- - ss->processed = htonl(sys_processed); - ss->badauth = htonl(sys_badauth); - ss->wanderhold = htonl(sys_wanderhold); -! ss->limitrejected = htonl(sys_limitrejected); - (void) more_pkt(); - flush_pkt(); - } -*************** -*** 1311,1317 **** - struct interface *inter; - struct req_pkt *inpkt; - { -! mon_start(); - req_ack(srcadr, inter, inpkt, INFO_OKAY); - } - ---- 1312,1318 ---- - struct interface *inter; - struct req_pkt *inpkt; - { -! mon_start(MON_ON); - req_ack(srcadr, inter, inpkt, INFO_OKAY); - } - -*************** -*** 1325,1331 **** - struct interface *inter; - struct req_pkt *inpkt; - { -! mon_stop(); - req_ack(srcadr, inter, inpkt, INFO_OKAY); - } - ---- 1326,1332 ---- - struct interface *inter; - struct req_pkt *inpkt; - { -! mon_stop(MON_ON); - req_ack(srcadr, inter, inpkt, INFO_OKAY); - } - -*************** -*** 1497,1502 **** ---- 1498,1507 ---- - md = md->mru_next) { - im->lasttime = htonl(current_time - md->lasttime); - im->firsttime = htonl(current_time - md->firsttime); -+ if (md->lastdrop) -+ im->lastdrop = htonl(current_time - md->lastdrop); -+ else -+ im->lastdrop = 0; - im->count = htonl(md->count); - im->addr = md->rmtadr; - im->port = md->rmtport; -diff -c xntpd/ntp_restrict.c:1.1.1.10 xntpd/ntp_restrict.c:3.10 -*** xntpd/ntp_restrict.c:1.1.1.10 Wed Feb 2 18:16:57 1994 ---- xntpd/ntp_restrict.c Wed Feb 2 18:16:57 1994 -*************** -*** 1,4 **** -! /* ntp_restrict.c,v 3.1 1993/07/06 01:11:28 jbj Exp - * ntp_restrict.c - find out what restrictions this host is running under - */ - #include ---- 1,4 ---- -! /* - * ntp_restrict.c - find out what restrictions this host is running under - */ - #include -*************** -*** 60,65 **** ---- 60,80 ---- - U_LONG res_timereset; - - /* -+ * Parameters of the RES_LIMITED restriction option. -+ * client_limit is the number of hosts allowed per source net -+ * client_limit_period is the number of seconds after which an entry -+ * is no longer considered for client limit determination -+ */ -+ U_LONG client_limit; -+ U_LONG client_limit_period; -+ /* -+ * count number of restriction entries referring to RES_LIMITED -+ * controls activation/deactivation of monitoring -+ * (with respect ro RES_LIMITED control) -+ */ -+ U_LONG res_limited_refcnt; -+ -+ /* - * Our initial allocation of list entries. - */ - static struct restrictlist resinit[INITRESLIST]; -*************** -*** 70,81 **** ---- 85,102 ---- - extern U_LONG current_time; - - /* -+ * debug flag -+ */ -+ extern int debug; -+ -+ /* - * init_restrict - initialize the restriction data structures - */ - void - init_restrict() - { - register int i; -+ char bp[80]; - - /* - * Zero the list and put all but one on the free list -*************** -*** 108,113 **** ---- 129,146 ---- - res_found = 0; - res_not_found = 0; - res_timereset = 0; -+ -+ /* -+ * set default values for RES_LIMIT functionality -+ */ -+ client_limit = 3; -+ client_limit_period = 3600; -+ res_limited_refcnt = 0; -+ -+ sprintf(bp, "client_limit=%d", client_limit); -+ set_sys_var(bp, strlen(bp)+1, RO); -+ sprintf(bp, "client_limit_period=%d", client_limit_period); -+ set_sys_var(bp, strlen(bp)+1, RO); - } - - -*************** -*** 150,155 **** ---- 183,302 ---- - else - res_found++; - -+ /* -+ * The following implements limiting the number of clients -+ * accepted from a given network. The notion of "same network" -+ * is determined by the mask and addr fields of the restrict -+ * list entry. The monitor mechanism has to be enabled for -+ * collecting info on current clients. -+ * -+ * The policy is as follows: -+ * - take the list of clients recorded -+ * from the given "network" seen within the last -+ * client_limit_period seconds -+ * - if there are at most client_limit entries: -+ * --> access allowed -+ * - otherwise sort by time first seen -+ * - current client among the first client_limit seen -+ * hosts? -+ * if yes: access allowed -+ * else: eccess denied -+ */ -+ if (match->flags & RES_LIMITED) { -+ int lcnt; -+ struct mon_data *md, *this_client; -+ extern int mon_enabled; -+ extern struct mon_data mon_fifo_list, mon_mru_list; -+ -+ #ifdef DEBUG -+ if (debug > 2) -+ printf("limited clients check: %d clients, period %d seconds, net is 0x%X\n", -+ client_limit, client_limit_period, -+ netof(hostaddr)); -+ #endif /*DEBUG*/ -+ if (mon_enabled == MON_OFF) { -+ #ifdef DEBUG -+ if (debug > 4) -+ printf("no limit - monitoring is off\n"); -+ #endif -+ return (int)(match->flags & ~RES_LIMITED); -+ } -+ -+ /* -+ * How nice, MRU list provides our current client as the -+ * first entry in the list. -+ * Monitoring was verified to be active above, thus we -+ * know an entry for our client must exist, or some -+ * brain dead set the memory limit for mon entries to ZERO!!! -+ */ -+ this_client = mon_mru_list.mru_next; -+ -+ for (md = mon_fifo_list.fifo_next,lcnt = 0; -+ md != &mon_fifo_list; -+ md = md->fifo_next) { -+ if ((current_time - md->lasttime) -+ > client_limit_period) { -+ #ifdef DEBUG -+ if (debug > 5) -+ printf("checking: %s: ignore: too old: %d\n", -+ numtoa(md->rmtadr), -+ current_time - md->lasttime); -+ #endif -+ continue; -+ } -+ if (md->mode == MODE_BROADCAST || -+ md->mode == MODE_CONTROL || -+ md->mode == MODE_PRIVATE) { -+ #ifdef DEBUG -+ if (debug > 5) -+ printf("checking: %s: ignore mode %d\n", -+ numtoa(md->rmtadr), -+ md->mode); -+ #endif -+ continue; -+ } -+ if (netof(md->rmtadr) != -+ netof(hostaddr)) { -+ #ifdef DEBUG -+ if (debug > 5) -+ printf("checking: %s: different net 0x%X\n", -+ numtoa(md->rmtadr), -+ netof(md->rmtadr)); -+ #endif -+ continue; -+ } -+ lcnt++; -+ if (lcnt > client_limit || -+ md->rmtadr == hostaddr) { -+ #ifdef DEBUG -+ if (debug > 5) -+ printf("considering %s: found host\n", -+ numtoa(md->rmtadr)); -+ #endif -+ break; -+ } -+ #ifdef DEBUG -+ else { -+ if (debug > 5) -+ printf("considering %s: same net\n", -+ numtoa(md->rmtadr)); -+ } -+ #endif -+ -+ } -+ #ifdef DEBUG -+ if (debug > 4) -+ printf("this one is rank %d in list, limit is %d: %s\n", -+ lcnt, client_limit, -+ (lcnt <= client_limit) ? "ALLOW" : "REJECT"); -+ #endif -+ if (lcnt <= client_limit) { -+ this_client->lastdrop = 0; -+ return (int)(match->flags & ~RES_LIMITED); -+ } else { -+ this_client->lastdrop = current_time; -+ } -+ } - return (int)match->flags; - } - -*************** -*** 257,262 **** ---- 404,413 ---- - rlprev->next = rl; - restrictcount++; - } -+ if ((rl->flags ^ (u_short)flags) & RES_LIMITED) { -+ res_limited_refcnt++; -+ mon_start(MON_RES); /* ensure data gets collected */ -+ } - rl->flags |= (u_short)flags; - break; - -*************** -*** 265,272 **** - * Remove some bits from the flags. If we didn't - * find this one, just return. - */ -! if (rl != 0) - rl->flags &= (u_short)~flags; - break; - - case RESTRICT_REMOVE: ---- 416,429 ---- - * Remove some bits from the flags. If we didn't - * find this one, just return. - */ -! if (rl != 0) { -! if ((rl->flags ^ (u_short)flags) & RES_LIMITED) { -! res_limited_refcnt--; -! if (res_limited_refcnt == 0) -! mon_stop(MON_RES); -! } - rl->flags &= (u_short)~flags; -+ } - break; - - case RESTRICT_REMOVE: -*************** -*** 280,285 **** ---- 437,447 ---- - && !(rl->mflags & RESM_INTERFACE)) { - rlprev->next = rl->next; - restrictcount--; -+ if (rl->flags & RES_LIMITED) { -+ res_limited_refcnt--; -+ if (res_limited_refcnt == 0) -+ mon_stop(MON_RES); -+ } - memset((char *)rl, 0, sizeof(struct restrictlist)); - - rl->next = resfree; -diff -c xntpd/ntp_unixclock.c:1.1.1.27 xntpd/ntp_unixclock.c:3.29 -*** xntpd/ntp_unixclock.c:1.1.1.27 Wed Feb 2 18:17:00 1994 ---- xntpd/ntp_unixclock.c Wed Feb 2 18:17:01 1994 -*************** -*** 556,568 **** - #endif /* SOLARIS */ - - #ifdef SYS_LINUX -! /* XXX should look this up somewhere ! */ - static void - clock_parms(tickadj, tick) - U_LONG *tickadj; - U_LONG *tick; - { -! *tickadj = (U_LONG)1; -! *tick = (U_LONG)10000; - } - #endif /* SYS_LINUX */ ---- 556,573 ---- - #endif /* SOLARIS */ - - #ifdef SYS_LINUX -! #include - static void - clock_parms(tickadj, tick) - U_LONG *tickadj; - U_LONG *tick; - { -! struct timex txc; -! -! txc.mode = 0; -! __adjtimex(&txc); -! -! *tickadj = (U_LONG)1; /* our adjtime is accurate */ -! *tick = (U_LONG)txc.tick; - } - #endif /* SYS_LINUX */ -diff -c xntpdc/ntpdc_ops.c:1.1.1.12 xntpdc/ntpdc_ops.c:3.16 -*** xntpdc/ntpdc_ops.c:1.1.1.12 Wed Feb 2 18:17:35 1994 ---- xntpdc/ntpdc_ops.c Wed Feb 2 18:17:36 1994 -*************** -*** 846,853 **** - if (!check1item(items, fp)) - return; - -! if (!checkitemsize(itemsize, sizeof(struct info_sys_stats))) - return; - - (void) fprintf(fp, "system uptime: %d\n", - ntohl(ss->timeup)); ---- 846,857 ---- - if (!check1item(items, fp)) - return; - -! if (itemsize != sizeof(struct info_sys_stats) && -! itemsize != sizeof(struct old_info_sys_stats)) { -! /* issue warning according to new structure size */ -! checkitemsize(itemsize, sizeof(struct info_sys_stats)); - return; -+ } - - (void) fprintf(fp, "system uptime: %d\n", - ntohl(ss->timeup)); -*************** -*** 869,874 **** ---- 873,883 ---- - ntohl(ss->badauth)); - (void) fprintf(fp, "wander hold downs: %d\n", - ntohl(ss->wanderhold)); -+ if (itemsize != sizeof(struct info_sys_stats)) -+ return; -+ -+ (void) fprintf(fp, "limitation rejects: %d\n", -+ ntohl(ss->limitrejected)); - } - - -*************** -*** 1243,1248 **** ---- 1252,1258 ---- - { "nopeer", RES_NOPEER }, - { "notrap", RES_NOTRAP }, - { "lptrap", RES_LPTRAP }, -+ { "limited", RES_LIMITED }, - { "", 0 } - }; - -*************** -*** 1463,1468 **** ---- 1473,1479 ---- - FILE *fp; - { - struct info_monitor *ml; -+ struct old_info_monitor *oml; - int items; - int itemsize; - int res; -*************** -*** 1476,1498 **** - if (!checkitems(items, fp)) - return; - -! if (!checkitemsize(itemsize, sizeof(struct info_monitor))) -! return; - -! (void) fprintf(fp, -! " address port count mode version lasttime firsttime\n"); -! (void) fprintf(fp, -! "=====================================================================\n"); -! while (items > 0) { -! (void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u\n", -! nntohost(ml->addr), -! ntohs(ml->port), -! ntohl(ml->count), -! ml->mode, ml->version, -! ntohl(ml->lasttime), -! ntohl(ml->firsttime)); -! ml++; -! items--; - } - } - ---- 1487,1535 ---- - if (!checkitems(items, fp)) - return; - -! if (itemsize == sizeof(struct info_monitor)) { - -! (void) fprintf(fp, -! " address port count mode version lastdrop lasttime firsttime\n"); -! (void) fprintf(fp, -! "===============================================================================\n"); -! while (items > 0) { -! (void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u %9u\n", -! nntohost(ml->addr), -! ntohs(ml->port), -! ntohl(ml->count), -! ml->mode, -! ml->version, -! ntohl(ml->lastdrop), -! ntohl(ml->lasttime), -! ntohl(ml->firsttime)); -! ml++; -! items--; -! } -! } else { -! if (itemsize != sizeof(struct old_info_monitor)) { -! /* issue warning according to new info_monitor size */ -! checkitemsize(itemsize, sizeof(struct info_monitor)); -! return; -! } -! -! oml = (struct old_info_monitor *)ml; -! (void) fprintf(fp, -! " address port count mode version lasttime firsttime\n"); -! (void) fprintf(fp, -! "======================================================================\n"); -! while (items > 0) { -! (void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u\n", -! nntohost(oml->addr), -! ntohs(oml->port), -! ntohl(oml->count), -! oml->mode, -! oml->version, -! ntohl(oml->lasttime), -! ntohl(oml->firsttime)); -! oml++; -! items--; -! } - } - } - diff --git a/usr.sbin/xntpd/patches/patch.11 b/usr.sbin/xntpd/patches/patch.11 deleted file mode 100644 index 8554d88fae5e..000000000000 --- a/usr.sbin/xntpd/patches/patch.11 +++ /dev/null @@ -1,536 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa05908; 9 Feb 94 18:18 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa21398; - 9 Feb 94 18:13 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA29809 (5.65c-6/7.3v-FAU); Thu, 10 Feb 1994 00:12:50 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA11633 (5.65c-6/7.3m-FAU); Thu, 10 Feb 1994 00:12:46 +0100 -From: Frank Kardel -Message-Id: <199402092312.AA11633@faui43.informatik.uni-erlangen.de> -Subject: .zz Patches -To: Mills@udel.edu -Date: Thu, 10 Feb 94 0:12:41 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, - Paul_Vixie@corpmis.sjc.hw.sony.com, Piete.Brooks@cl.cam.ac.uk -X-Mailer: ELM [version 2.3 PL11] - -Guys, - -Ok, here are some patches (including some WWVB cleanup 8-) relative -to the zz version. The KERNEL stuff in ntp_timex.h must still -be resolved. - -diff -c Makefile:1.1.1.11 Makefile:3.46 -*** Makefile:1.1.1.11 Wed Feb 9 23:54:57 1994 ---- Makefile Wed Feb 9 23:54:57 1994 -*************** -*** 162,168 **** - FRC: - - savebin: -! @test -d bin || mkdir bin - @echo - @echo '### saving $(TARGETS) $(OPTTARG) in bin' - -@for f in $(TARGETS) $(OPTTARG); \ ---- 162,168 ---- - FRC: - - savebin: -! -@test -d bin || mkdir bin - @echo - @echo '### saving $(TARGETS) $(OPTTARG) in bin' - -@for f in $(TARGETS) $(OPTTARG); \ -diff -c include/ntp_machine.h:1.1.1.11 include/ntp_machine.h:1.27 -*** include/ntp_machine.h:1.1.1.11 Wed Feb 9 23:56:27 1994 ---- include/ntp_machine.h Wed Feb 9 23:56:27 1994 -*************** -*** 274,280 **** - #ifndef STR_SYSTEM - #define STR_SYSTEM "UNIX/Ultrix" - #endif -- #define HAVE_TERMIOS - #endif - - /* ---- 274,279 ---- -diff -c lib/systime.c:1.1.1.11 lib/systime.c:1.9 -*** lib/systime.c:1.1.1.11 Wed Feb 9 23:57:45 1994 ---- lib/systime.c Wed Feb 9 23:57:45 1994 -*************** -*** 47,58 **** - * We also remember the clock precision we computed from the kernel in - * case someone asks us. - */ - LONG adj_precision; /* adj precision in usec (tickadj) */ - LONG tvu_maxslew; /* maximum adjust doable in 1< -Message-Id: <199402111326.AA24390@faui43.informatik.uni-erlangen.de> -Subject: Re: Beep, beep, beep -To: Mills@udel.edu -Date: Fri, 11 Feb 94 14:26:25 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, - Paul_Vixie@corpmis.sjc.hw.sony.com, Piete.Brooks@cl.cam.ac.uk -In-Reply-To: <9402101138.aa10259@huey.udel.edu>; from "Mills@udel.edu" at Feb 10, 94 11:38 am -X-Mailer: ELM [version 2.3 PL11] - - -> Frank, - -> In the latest xntp3.3zz.tar.Z the Ultrix kernel finds joy of clock. -> (Whew). - -Ok, I just dug out an old allocation failure in xntpdc. While -reading respones the input buffer might be realloced(and MOVED) without -telling the rest of the system. This was fatal when stdio needed a -buffer for non terminal operation. Net result was confused output. - -Ok, here ist the patch: - -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/xntpdc/ntpdc.c,v -retrieving revision 3.17 -diff -c -r3.17 xntpdc/ntpdc.c -*** xntpdc/ntpdc.c:3.17 1994/01/28 14:07:13 ---- xntpdc/ntpdc.c 1994/02/11 13:20:56 -*************** -*** 598,605 **** - /* - * So far, so good. Copy this data into the output array. - */ -! if ((datap + datasize) > (pktdata + pktdatasize)) - growpktdata(); - memmove(datap, (char *)rpkt.data, datasize); - datap += datasize; - if (firstpkt) { ---- 598,609 ---- - /* - * So far, so good. Copy this data into the output array. - */ -! if ((datap + datasize) > (pktdata + pktdatasize)) { -! int offset = datap - pktdata; - growpktdata(); -+ *rdata = pktdata; /* might have been realloced ! */ -+ datap = pktdata + offset; -+ } - memmove(datap, (char *)rpkt.data, datasize); - datap += datasize; - if (firstpkt) { - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.13 b/usr.sbin/xntpd/patches/patch.13 deleted file mode 100644 index 17363e24ed0b..000000000000 --- a/usr.sbin/xntpd/patches/patch.13 +++ /dev/null @@ -1,68 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id af16153; 14 Feb 94 7:27 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa27498; - 13 Feb 94 13:23 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA22387 (5.65c-6/7.3v-FAU); Sun, 13 Feb 1994 19:22:59 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA27117 (5.65c-6/7.3m-FAU); Sun, 13 Feb 1994 19:22:57 +0100 -From: Frank Kardel -Message-Id: <199402131822.AA27117@faui43.informatik.uni-erlangen.de> -Subject: compilation setup for solaris -To: mills@udel.edu -Date: Sun, 13 Feb 94 19:22:53 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave. - -Just to remove some compilation noise in solaris (NTP_POSIX_SOURCE -redefined): - -For 3.3e: -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/machines/sunos5.1,v -retrieving revision 1.4 -diff -c -r1.4 machines/sunos5.1 -*** machines/sunos5.1:1.4 1994/02/01 23:30:54 ---- machines/sunos5.1 1994/02/13 18:16:24 -*************** -*** 1,6 **** - RANLIB= : - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DNTP_POSIX_SOURCE - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= : - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/machines/sunos5.2,v -retrieving revision 1.4 -diff -c -r1.4 machines/sunos5.2 -*** machines/sunos5.2:1.4 1994/02/01 23:30:56 ---- machines/sunos5.2 1994/02/13 18:16:27 -*************** -*** 1,6 **** - RANLIB= : - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE -DNTP_POSIX_SOURCE - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= : - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.14 b/usr.sbin/xntpd/patches/patch.14 deleted file mode 100644 index 775f9dae7e94..000000000000 --- a/usr.sbin/xntpd/patches/patch.14 +++ /dev/null @@ -1,116 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa16187; 14 Feb 94 7:27 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa27096; - 13 Feb 94 13:04 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA21590 (5.65c-6/7.3v-FAU); Sun, 13 Feb 1994 19:04:48 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA26947 (5.65c-6/7.3m-FAU); Sun, 13 Feb 1994 19:04:46 +0100 -From: Frank Kardel -Message-Id: <199402131804.AA26947@faui43.informatik.uni-erlangen.de> -Subject: patches for 3.3e -To: mills@udel.edu -Date: Sun, 13 Feb 94 19:04:42 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave. - -Here is something to make Sequent PTX happier. -I also changed the version number from 3.3zz to 3.3e. -The patch is relative to the current 3.3e version. - -diff -c Makefile:1.1.1.12 Makefile:3.47 -*** Makefile:1.1.1.12 Sun Feb 13 18:53:06 1994 ---- Makefile Sun Feb 13 18:53:07 1994 -*************** -*** 144,150 **** - @echo '###' creating XNTPRES utility - @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" - -! util/tickadj: util/Makefile FRC - @echo - @echo '###' creating TICKADJ utility - @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" ---- 144,150 ---- - @echo '###' creating XNTPRES utility - @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" - -! util/tickadj: util/Makefile lib/libntp.a FRC - @echo - @echo '###' creating TICKADJ utility - @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" -diff -c VERSION:1.1.1.7 VERSION:3.12 -*** VERSION:1.1.1.7 Sun Feb 13 18:53:10 1994 ---- VERSION Sun Feb 13 18:53:10 1994 -*************** -*** 1 **** -! version=3.3zz (beta) ---- 1 ---- -! version=3.3e (beta) -diff -c authstuff/Makefile.tmpl:1.1.1.9 authstuff/Makefile.tmpl:3.12 -*** authstuff/Makefile.tmpl:1.1.1.9 Sun Feb 13 18:53:18 1994 ---- authstuff/Makefile.tmpl Sun Feb 13 18:53:18 1994 -*************** -*** 38,50 **** - all: $(PROGRAM) - - authcert: $(CRTOBJS) $(LIB) -! $(CC) $(COPTS) -o $@ $(CRTOBJS) $(LIB) - - authspeed: $(SPDOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(SPDOBJS) $(LIB) $(COMPAT) $(RESLIB) - - keyparity: $(PAROBJS) $(LIB) -! $(CC) $(COPTS) -o $@ $(PAROBJS) $(LIB) - - makeIPFP: $(IFPOBJS) - $(CC) $(COPTS) -o $@ $(IFPOBJS) ---- 38,50 ---- - all: $(PROGRAM) - - authcert: $(CRTOBJS) $(LIB) -! $(CC) $(COPTS) -o $@ $(CRTOBJS) $(LIB) $(COMPAT) $(RESLIB) - - authspeed: $(SPDOBJS) $(LIB) - $(CC) $(COPTS) -o $@ $(SPDOBJS) $(LIB) $(COMPAT) $(RESLIB) - - keyparity: $(PAROBJS) $(LIB) -! $(CC) $(COPTS) -o $@ $(PAROBJS) $(LIB) $(COMPAT) $(RESLIB) - - makeIPFP: $(IFPOBJS) - $(CC) $(COPTS) -o $@ $(IFPOBJS) -*************** -*** 68,74 **** - $(CC) $(COPTS) -o $@ $(UNXBJS) - - md5: $(MD5OBJS) -! $(CC) $(COPTS) -o $@ $(MD5OBJS) $(LIB) - - tags: - ctags *.c *.h ---- 68,74 ---- - $(CC) $(COPTS) -o $@ $(UNXBJS) - - md5: $(MD5OBJS) -! $(CC) $(COPTS) -o $@ $(MD5OBJS) $(LIB) $(COMPAT) $(RESLIB) - - tags: - ctags *.c *.h -diff -c include/ntp_machine.h:1.1.1.12 include/ntp_machine.h:1.28 -*** include/ntp_machine.h:1.1.1.12 Sun Feb 13 18:54:32 1994 ---- include/ntp_machine.h Sun Feb 13 18:54:32 1994 -*************** -*** 457,462 **** ---- 457,463 ---- - #define HAVE_READKMEM - #define UDP_WILDCARD_DELIVERY - #define NTP_POSIX_SOURCE -+ #define memmove(x, y, z) memcpy(x, y, z) - struct timezone { int __0; }; /* unused placebo */ - /* - * no comment !@! --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.15 b/usr.sbin/xntpd/patches/patch.15 deleted file mode 100644 index 1ef861d502be..000000000000 --- a/usr.sbin/xntpd/patches/patch.15 +++ /dev/null @@ -1,39 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aq16153; 14 Feb 94 7:28 EST -Received: from jagubox.gsfc.nasa.gov by louie.udel.edu id aa24615; - 14 Feb 94 6:34 EST -Received: by jagubox.gsfc.nasa.gov (Smail3.1.28.1 #1) - id m0pW1Zk-000C8UC; Mon, 14 Feb 94 06:34 EST -Message-Id: -From: Jim Jagielski -Subject: xntp 3.3e (or is that zz ;) ) -To: Mills@udel.edu -Date: Mon, 14 Feb 1994 06:34:52 -0500 (EST) -Reply-To: Jim Jagielski -In-Reply-To: <9308051324.aa24396@huey.udel.edu> from "Mills@udel.edu" at Aug 5, 93 01:24:24 pm -X-Mailer: ELM [version 2.4 PL23] -Content-Type: text -Content-Length: 621 - -This latest version requires the NTP_NEED_BOPS define in ntp_machine.h for -A/UX: - -*** ntp_machine.h.orig Mon Feb 14 06:34:34 1994 ---- ntp_machine.h Mon Feb 14 06:20:57 1994 -*************** -*** 299,304 **** ---- 299,305 ---- - #define HAVE_BSD_TTYS - #define LOG_NTP LOG_LOCAL1 - #define HAVE_SIGNALED_IO -+ #define NTP_NEED_BOPS - #ifndef STR_SYSTEM - #define STR_SYSTEM "UNIX/AUX" - #endif --- -#include - Jim Jagielski | - jim@jagubox.gsfc.nasa.gov | "Ahh... west and wewaxation at wast" - NASA/GSFC, Code 734.4 | Elmer Fudd - Greenbelt, MD 20771 | - diff --git a/usr.sbin/xntpd/patches/patch.16 b/usr.sbin/xntpd/patches/patch.16 deleted file mode 100644 index 909f0c70c8e9..000000000000 --- a/usr.sbin/xntpd/patches/patch.16 +++ /dev/null @@ -1,267 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa25712; 15 Feb 94 17:54 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa18345; - 15 Feb 94 17:51 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA15109 (5.65c-6/7.3v-FAU); Tue, 15 Feb 1994 23:50:53 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA17375 (5.65c-6/7.3m-FAU); Tue, 15 Feb 1994 23:50:51 +0100 -From: Frank Kardel -Message-Id: <199402152250.AA17375@faui43.informatik.uni-erlangen.de> -Subject: fixed for parse kernel stuff... -To: mills@udel.edu -Date: Tue, 15 Feb 94 23:50:47 MET -X-Mailer: ELM [version 2.3 PL11] - - -Hi, Dave ! - -Here are some fixes for the PARSE kernel modules. Basically they -fix a memory leak on an open error condition and pronounce the -Solaris 2.x stream module MT safe. - -Well, actually I should put something for you to eat here 8-). - -RCS file: /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v -retrieving revision 1.1.1.7 -diff -c -r1.1.1.7 parsesolaris.c -*** parse/parsesolaris.c:1.1.1.7 1994/02/12 09:53:42 ---- parse/parsesolaris.c 1994/02/15 22:20:51 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.12 1994/02/02 17:45:35 kardel Exp - * -! * parsesolaris.c,v 3.12 1994/02/02 17:45:35 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp - * -! * parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be -*************** -*** 19,25 **** - */ - - #ifndef lint -! static char rcsid[] = "parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp"; - #endif - - /* ---- 19,25 ---- - */ - - #ifndef lint -! static char rcsid[] = "parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp"; - #endif - - /* -*************** -*** 65,71 **** - { - "parse", /* module name */ - &parseinfo, /* module information */ -! D_NEW, /* not clean yet */ - /* lock ptr */ - }; - ---- 65,71 ---- - { - "parse", /* module name */ - &parseinfo, /* module information */ -! D_NEW|D_MP|D_MTQPAIR, /* exclusive for q pair */ - /* lock ptr */ - }; - -*************** -*** 139,145 **** - /*ARGSUSED*/ - int _init(void) - { -! static char revision[] = "3.12"; - char *s, *S, *t; - - /* ---- 139,145 ---- - /*ARGSUSED*/ - int _init(void) - { -! static char revision[] = "3.15"; - char *s, *S, *t; - - /* -*************** -*** 413,418 **** ---- 413,420 ---- - parse->parse_ppsclockev.tv.tv_usec = 0; - parse->parse_ppsclockev.serial = 0; - -+ qprocson(q); -+ - parseprintf(DD_OPEN,("parse: OPEN - initializing io subsystem q=%x\n", q)); - - if (!parse_ioinit(&parse->parse_io)) -*************** -*** 420,425 **** ---- 422,429 ---- - /* - * ok guys - beat it - */ -+ qprocsoff(q); -+ - kmem_free((caddr_t)parse, sizeof(parsestream_t)); - - parsebusy--; -*************** -*** 441,447 **** - */ - if (!notice) - { -! printf("%s: Copyright (c) 1991-1993, Frank Kardel\n", modlstrmod.strmod_linkinfo); - notice = 1; - } - ---- 445,451 ---- - */ - if (!notice) - { -! printf("%s: Copyright (c) 1991-1994, Frank Kardel\n", modlstrmod.strmod_linkinfo); - notice = 1; - } - -*************** -*** 449,455 **** ---- 453,464 ---- - } - else - { -+ qprocsoff(q); -+ -+ kmem_free((caddr_t)parse, sizeof(parsestream_t)); -+ - parsebusy--; -+ - return EIO; - } - } -*************** -*** 462,467 **** ---- 471,478 ---- - - parseprintf(DD_CLOSE,("parse: CLOSE\n")); - -+ qprocsoff(q); -+ - s = splhigh(); - - if (parse->parse_dqueue) -*************** -*** 1178,1184 **** - /* - * History: - * -! * parsesolaris.c,v - * Revision 3.12 1994/02/02 17:45:35 kardel - * rcs ids fixed - * ---- 1189,1204 ---- - /* - * History: - * -! * parsesolaris.c,v -! * Revision 3.15 1994/02/15 22:20:51 kardel -! * rcsid fixed -! * -! * Revision 3.14 1994/02/15 22:06:04 kardel -! * added qprocsx & flags for MT capability -! * -! * Revision 3.13 1994/02/13 19:16:47 kardel -! * updated verbose Copyright message -! * - * Revision 3.12 1994/02/02 17:45:35 kardel - * rcs ids fixed - * -RCS file: /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v -retrieving revision 1.1.1.8 -diff -c -r1.1.1.8 parsestreams.c -*** parse/parsestreams.c:1.1.1.8 1994/02/12 09:53:45 ---- parse/parsestreams.c 1994/02/15 22:39:50 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.14 1994/02/02 17:45:38 kardel Exp - * -! * parsestreams.c,v 3.14 1994/02/02 17:45:38 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.16 1994/02/15 22:39:50 kardel Exp - * -! * parsestreams.c,v 3.16 1994/02/15 22:39:50 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) -*************** -*** 527,533 **** - */ - if (!notice) - { -! printf("%s: Copyright (c) 1991-1993, Frank Kardel\n", parsesync_vd.Drv_name); - notice = 1; - } - ---- 527,533 ---- - */ - if (!notice) - { -! printf("%s: Copyright (c) 1991-1994, Frank Kardel\n", parsesync_vd.Drv_name); - notice = 1; - } - -*************** -*** 535,540 **** ---- 535,542 ---- - } - else - { -+ kmem_free((caddr_t)parse, sizeof(parsestream_t)); -+ - #ifdef VDDRV - parsebusy--; - #endif -*************** -*** 1257,1263 **** - /* - * History: - * -! * parsestreams.c,v - * Revision 3.14 1994/02/02 17:45:38 kardel - * rcs ids fixed - * ---- 1259,1271 ---- - /* - * History: - * -! * parsestreams.c,v -! * Revision 3.16 1994/02/15 22:39:50 kardel -! * memory leak on open failure closed -! * -! * Revision 3.15 1994/02/13 19:16:50 kardel -! * updated verbose Copyright message -! * - * Revision 3.14 1994/02/02 17:45:38 kardel - * rcs ids fixed - * - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.17 b/usr.sbin/xntpd/patches/patch.17 deleted file mode 100644 index f98f75403a11..000000000000 --- a/usr.sbin/xntpd/patches/patch.17 +++ /dev/null @@ -1,50 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa00480; 16 Feb 94 12:17 EST -Received: from quack.kfu.com by louie.udel.edu id aa24950; 16 Feb 94 12:12 EST -Received: by quack.kfu.com id AA03532 - (5.65c8/IDA-1.4.4 for mills@udel.edu); Wed, 16 Feb 1994 09:12:04 -0800 -Date: Wed, 16 Feb 1994 09:12:04 -0800 -From: Nick Sayer -Message-Id: <199402161712.AA03532@quack.kfu.com> -To: mills@udel.edu -Subject: CHU debug patch - -I don't know what you think about this, but I thought I'd pass it -along. I'm sorry I don't have a proper 'patch' format patch, but -it should be aparent from the context where this goes in refclock_chu.c: - - return; - } - - /* - * Get the clock this applies to and a pointer to the data - */ - chu = (struct chuunit *)rbufp->recv_srcclock; - chuc = (struct chucode *)&rbufp->recv_space; - chu->responses++; - chu->lastupdate = current_time; - - /* - * Just for fun, we can debug the whole frame if - * we want. - */ - -#ifndef NO_CHU_DEBUG - syslog(LOG_DEBUG,"CHU %s packet:",(chuc->chutype==CHU_YEAR)? - "year":"time"); - for (i=0;icodechars[i]&0xf], - hexstring[chuc->codechars[i]>>4], - ctime(&(chuc->codetimes[i].tv_sec))); - c[strlen(c)-1]=0; /* ctime() adds a damn \n */ - syslog(LOG_DEBUG,"%s .%06d",c,chuc->codetimes[i].tv_usec); - } -#endif - - /* - * At this point we're assured that both halves of the - * data match because of what the kernel has done. - diff --git a/usr.sbin/xntpd/patches/patch.18 b/usr.sbin/xntpd/patches/patch.18 deleted file mode 100644 index e81eb627c859..000000000000 --- a/usr.sbin/xntpd/patches/patch.18 +++ /dev/null @@ -1,99 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa00679; 16 Feb 94 13:00 EST -Received: from spatula.csv.warwick.ac.uk by louie.udel.edu id aa26092; - 16 Feb 94 12:48 EST -Date: Wed, 16 Feb 1994 17:47:50 GMT -From: Ian Dickinson -Message-Id: <7051.199402161747@spatula.csv.warwick.ac.uk> -Received: from localhost by spatula.csv.warwick.ac.uk - id RAA07051; Wed, 16 Feb 1994 17:47:50 GMT -In-Reply-To: Mills@udel.edu - "Re: xntp sunos5 config" (Feb 16, 10:50am) -X-Mailer: Mail User's Shell (7.2.4 2/2/92) -To: Mills@udel.edu -Subject: Re: xntp sunos5 config -MIME-Version: 1.0 -Content-Type: text/plain; charset=US-ASCII - -On Feb 16, 10:50am, Mills@udel.edu wrote: -} Subject: Re: xntp sunos5 config - -BTW, 3.3f seems to work fine on an SC2000 sunos5.3 (including the patch below) - -> Your message did not say in which file sunos5.1 or sunos5.2 or both -> you wanted the -DLOCK_PROCESS. I'll wait for your patches. - -I've never done any heavy work on a sunos5.1 machine, so I can't remember if -plock() exists there. I *think* sunso5.2 will work with it. -Perhaps it's time to create a sunos5.3 file which has -DLOCK_PROCESS and is -otherwise identical to sunos5.2, though this is getting silly for supposedly -a single SVR4-based operating system. - -As far as I'm aware, the choice between plock() and mlockall() can be done -with feature testing and doesn't need a seperate #define. - -This patch applies to 3.3b and 3.3f (with line fuzz). -I'm certainly not sure this is the best way to do this, but it does work here. -Perhaps it's worth asking around how widely this works in sunos5.x - -*** 1.1 1994/02/01 17:16:13 ---- xntpd/ntpd.c 1994/02/16 16:32:47 -*************** -*** 28,35 **** ---- 28,39 ---- - #include "ntp_stdlib.h" - - #ifdef LOCK_PROCESS -+ #ifdef SYS_SOLARIS -+ #include -+ #else - #include - #endif -+ #endif - - /* - * Signals we catch for debugging. If not debugging we ignore them. -*************** -*** 218,229 **** - if (rtprio(0, 120) < 0) - syslog(LOG_ERR, "rtprio() error: %m"); - #else -! #if defined(PROCLOCK) && defined(LOCK_PROCESS) - /* - * lock the process into memory - */ - if (plock(PROCLOCK) < 0) - syslog(LOG_ERR, "plock(): %m"); - #endif - #if defined(NTPD_PRIO) && NTPD_PRIO != 0 - /* ---- 222,243 ---- - if (rtprio(0, 120) < 0) - syslog(LOG_ERR, "rtprio() error: %m"); - #else -! #if defined(LOCK_PROCESS) -! #if defined(MCL_CURRENT) && defined(MCL_FUTURE) -! /* -! * lock the process into memory -! */ -! if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) -! syslog(LOG_ERR, "mlockall(): %m"); -! #else -! #if defined(PROCLOCK) - /* - * lock the process into memory - */ - if (plock(PROCLOCK) < 0) - syslog(LOG_ERR, "plock(): %m"); -+ #endif -+ #endif - #endif - #if defined(NTPD_PRIO) && NTPD_PRIO != 0 - /* - - - -Cheers, --- -Ian - diff --git a/usr.sbin/xntpd/patches/patch.19 b/usr.sbin/xntpd/patches/patch.19 deleted file mode 100644 index 396f16f34264..000000000000 --- a/usr.sbin/xntpd/patches/patch.19 +++ /dev/null @@ -1,599 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa08047; 17 Feb 94 15:26 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa17403; - 17 Feb 94 15:15 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA04056 (5.65c-6/7.3v-FAU); Thu, 17 Feb 1994 21:14:43 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA29721 (5.65c-6/7.3m-FAU); Thu, 17 Feb 1994 21:14:39 +0100 -From: Frank Kardel -Message-Id: <199402172014.AA29721@faui43.informatik.uni-erlangen.de> -Subject: Re: Beep, beep, beep -To: Mills@udel.edu -Date: Thu, 17 Feb 94 21:14:33 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, - Paul_Vixie@corpmis.sjc.hw.sony.com, Piete.Brooks@cl.cam.ac.uk -In-Reply-To: <9402171155.aa07032@huey.udel.edu>; from "Mills@udel.edu" at Feb 17, 94 11:55 am -X-Mailer: ELM [version 2.3 PL11] - - -> Guys, - -> Trouble with HAVE_BSD_TTYS on a VAX - -> ### creating NTP library -> cc -O -DDES -DXNTP_LITTLE_ENDIAN -DSYS_VAX -DDEBUG -DREFCLOCK -I../include -c atoint.c -> "../include/ntp_machine.h", line 570: syntax error -Yupp, nit TTY define set. - -> "atoint.c", line 12: redeclaration of ival -> "atoint.c", line 13: syntax error -> ... - -Well, I guess the trouble is more that none of the tty defines was -defined. For the sake of completeness i have added the tty defines to -(hopefully) all machine/* files. Some configurations were unknown to -me so I assumed HAVE_BSD_TTYS. Would be nice if someone could run -the whole suite 8-). -I have put the tty defines into the machine files so that the -refconf scripts can pick up the define without having to run the -preprocessor to dig out the configuration. -Hope this works. - -diff -c include/ntp_machine.h:1.1.1.13 include/ntp_machine.h:1.30 -*** include/ntp_machine.h:1.1.1.13 Thu Feb 17 20:17:59 1994 ---- include/ntp_machine.h Thu Feb 17 20:17:59 1994 -*************** -*** 44,54 **** - WHICH TERMINAL MODEL TO USE - I would assume HAVE_TERMIOS if - NTP_POSIX_SOURCE was set but can't. The - posix tty driver is too restrictive on most systems. -! It defined if you define STREAMS. - - HAVE_SYSV_TTYS - Use SYSV termio.h - HAVE_BSD_TTYS - Use BSD stty.h -- HAVE_TERMIOS - Use POSIX termios.h - - THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about - kernel mucking. ---- 44,59 ---- - WHICH TERMINAL MODEL TO USE - I would assume HAVE_TERMIOS if - NTP_POSIX_SOURCE was set but can't. The - posix tty driver is too restrictive on most systems. -! It is defined if you define STREAMS. - -+ We do not put these defines in the ntp_machine.h as some systems -+ offer multiple interfaces and refclock configuration likes to -+ peek into the configuration defines for tty model restrictions. -+ Thus all tty definitions should be in the files in the machines directory. -+ -+ HAVE_TERMIOS - Use POSIX termios.h - HAVE_SYSV_TTYS - Use SYSV termio.h - HAVE_BSD_TTYS - Use BSD stty.h - - THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about - kernel mucking. -*************** -*** 296,302 **** - #define FORCE_NTPDATE_STEP - #define RETSIGTYPE void - #define HAVE_ATT_SETPGRP -- #define HAVE_BSD_TTYS - #define LOG_NTP LOG_LOCAL1 - #define HAVE_SIGNALED_IO - #define NTP_NEED_BOPS ---- 301,306 ---- -*************** -*** 352,359 **** - #ifndef STR_SYSTEM - #define STR_SYSTEM "UNIX/BSDI" - #endif -- #define HAVE_BSD_TTYS -- #define HAVE_TERMIOS - #endif - - /* ---- 356,361 ---- -*************** -*** 441,449 **** - */ - #if defined(SYS_PTX) - #define NO_SIGNED_CHAR_DECL -- #ifndef HAVE_SYSV_TTYS -- #define HAVE_SYSV_TTYS -- #endif - #define STREAMS_TLI - #define HAVE_ATT_SETPGRP - #define HAVE_SIGNALED_IO ---- 443,448 ---- -*************** -*** 528,534 **** - #define HAVE_BSD_NICE - #define NOKMEM - #define HAVE_SIGNALED_IO -- #define HAVE_BSD_TTYS - #define NTP_SYSCALLS_STD - #define USE_PROTOTYPES - #define UDP_WILDCARD_DELIVERY ---- 527,532 ---- -*************** -*** 565,570 **** ---- 563,582 ---- - && !defined(HAVE_NO_NICE) - ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines - #endif -+ -+ /* -+ * use only one tty model - no use in initialising -+ * a tty in three ways -+ * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS -+ */ -+ #ifdef HAVE_TERMIOS -+ #undef HAVE_BSD_TTYS -+ #undef HAVE_SYSV_TTYS -+ #endif -+ -+ #ifdef HAVE_SYSV_TTYS -+ #undef HAVE_BSD_TTYS -+ #endif - - #if !defined(HAVE_SYSV_TTYS) \ - && !defined(HAVE_BSD_TTYS) \ -diff -c machines/aux2:1.1.1.2 machines/aux2:1.4 -*** machines/aux2:1.1.1.2 Thu Feb 17 20:19:50 1994 ---- machines/aux2 Thu Feb 17 20:19:50 1994 -*************** -*** 1,6 **** - RANLIB= true # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_AUX2 - AUTHDEFS= -DDES -DMD5 -DFASTMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= true # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_AUX2 -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 -DFASTMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/aux3:1.1.1.2 machines/aux3:1.4 -*** machines/aux3:1.1.1.2 Thu Feb 17 20:19:52 1994 ---- machines/aux3 Thu Feb 17 20:19:52 1994 -*************** -*** 1,6 **** - RANLIB= true # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_AUX3 - AUTHDEFS= -DDES -DMD5 -DFASTMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= true # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_AUX3 -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 -DFASTMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/bsdi:1.1.1.4 machines/bsdi:1.6 -*** machines/bsdi:1.1.1.4 Thu Feb 17 20:19:53 1994 ---- machines/bsdi Thu Feb 17 20:19:53 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_BSDI - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lkvm ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_BSDI -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lkvm -diff -c machines/convexos10:1.1.1.2 machines/convexos10:1.3 -*** machines/convexos10:1.1.1.2 Thu Feb 17 20:19:54 1994 ---- machines/convexos10 Thu Feb 17 20:19:54 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_CONVEXOS10 - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - RESLIB= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_CONVEXOS10 -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - RESLIB= -diff -c machines/convexos9:1.1.1.2 machines/convexos9:1.3 -*** machines/convexos9:1.1.1.2 Thu Feb 17 20:19:55 1994 ---- machines/convexos9 Thu Feb 17 20:19:56 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_CONVEXOS9 - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - RESLIB= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_CONVEXOS9 -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - RESLIB= -diff -c machines/decosf1:1.1.1.2 machines/decosf1:1.4 -*** machines/decosf1:1.1.1.2 Thu Feb 17 20:19:57 1994 ---- machines/decosf1 Thu Feb 17 20:19:57 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSTREAM -DSYS_DECOSF1 - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSTREAM -DSYS_DECOSF1 -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/dell.svr4:1.1.1.1 machines/dell.svr4:1.2 -*** machines/dell.svr4:1.1.1.1 Thu Feb 17 20:19:58 1994 ---- machines/dell.svr4 Thu Feb 17 20:19:58 1994 -*************** -*** 1,7 **** - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SVR4 - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,7 ---- - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SVR4 -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/domainos:1.1.1.1 machines/domainos:1.2 -*** machines/domainos:1.1.1.1 Thu Feb 17 20:19:59 1994 ---- machines/domainos Thu Feb 17 20:19:59 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/i386:1.1.1.2 machines/i386:1.3 -*** machines/i386:1.1.1.2 Thu Feb 17 20:20:04 1994 ---- machines/i386 Thu Feb 17 20:20:05 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_I386 - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_I386 -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/i386svr4:1.1.1.3 machines/i386svr4:1.4 -*** machines/i386svr4:1.1.1.3 Thu Feb 17 20:20:05 1994 ---- machines/i386svr4 Thu Feb 17 20:20:05 1994 -*************** -*** 1,7 **** - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SVR4 -DSTREAMS_TLI - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,7 ---- - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/mips:1.1.1.2 machines/mips:1.3 -*** machines/mips:1.1.1.2 Thu Feb 17 20:20:10 1994 ---- machines/mips Thu Feb 17 20:20:10 1994 -*************** -*** 1,7 **** - #RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK - DEFS= -! AUTHDEFS= -DDES -DMD5 -DSYS_MIPS - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lmld - RESLIB= ---- 1,7 ---- - #RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK - DEFS= -! AUTHDEFS= -DDES -DMD5 -DSYS_MIPS -DHAVE_BSD_TTYS - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lmld - RESLIB= -diff -c machines/next:1.1.1.1 machines/next:1.2 -*** machines/next:1.1.1.1 Thu Feb 17 20:20:12 1994 ---- machines/next Thu Feb 17 20:20:13 1994 -*************** -*** 1,6 **** - RANLIB= ranlib -c -s - DEFS= -DSYS_NEXT -! AUTHDEFS= -DDES -DMD5 -DFAST_MD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= ---- 1,6 ---- - RANLIB= ranlib -c -s - DEFS= -DSYS_NEXT -! AUTHDEFS= -DDES -DMD5 -DFAST_MD5 -DHAVE_BSD_TTYS - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= -diff -c machines/sequent:1.1.1.3 machines/sequent:1.4 -*** machines/sequent:1.1.1.3 Thu Feb 17 20:20:14 1994 ---- machines/sequent Thu Feb 17 20:20:14 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT -DHAVE_BSD_TTYS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/sinix-m:1.1.1.2 machines/sinix-m:1.5 -*** machines/sinix-m:1.1.1.2 Thu Feb 17 20:20:15 1994 ---- machines/sinix-m Thu Feb 17 20:20:15 1994 -*************** -*** 1,6 **** - RANLIB= : - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_SINIXM - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= ---- 1,6 ---- - RANLIB= : - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_SINIXM -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -diff -c machines/sony:1.1.1.2 machines/sony:1.3 -*** machines/sony:1.1.1.2 Thu Feb 17 20:20:16 1994 ---- machines/sony Thu Feb 17 20:20:16 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SONY - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lmld ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_SONY -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= -lmld -diff -c machines/svr4:1.1.1.4 machines/svr4:1.4 -*** machines/svr4:1.1.1.4 Thu Feb 17 20:20:20 1994 ---- machines/svr4 Thu Feb 17 20:20:20 1994 -*************** -*** 1,6 **** - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V -! DEFS= -DSYS_SVR4 -DSTREAMS_TLI - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= - DAEMONLIBS= -lnet -lnsl -lsocket -lelf ---- 1,6 ---- - SHELL= /bin/sh - RANLIB= ls # ar does the work of ranlib under System V -! DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= - DAEMONLIBS= -lnet -lnsl -lsocket -lelf -diff -c machines/vax:1.1.1.2 machines/vax:1.3 -*** machines/vax:1.1.1.2 Thu Feb 17 20:20:23 1994 ---- machines/vax Thu Feb 17 20:20:23 1994 -*************** -*** 1,6 **** - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_VAX - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= ---- 1,6 ---- - RANLIB= ranlib - DEFS_LOCAL= -DREFCLOCK -! DEFS= -DSYS_VAX -DHAVE_BSD_TTYS - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= -RCS file: /src/NTP/REPOSITORY/v3/parse/README.new_clocks,v -retrieving revision 1.1.1.2 -retrieving revision 3.3 -diff -c -r1.1.1.2 -r3.3 -*** parse/README.new_clocks:1.1.1.2 1994/02/12 09:53:48 ---- parse/README.new_clocks 1994/02/17 20:09:58 -*************** -*** 1,7 **** -! Here is an attempt to scetch out what you need to do in order to - add another clock to the parse driver: - -! Prerequsites: - - Does the system you want the clock connect to have - termio.h or termios.h ? (You need that for the parse driver) - ---- 1,7 ---- -! Here is an attempt to sketch out what you need to do in order to - add another clock to the parse driver: - -! Prerequisites: - - Does the system you want the clock connect to have - termio.h or termios.h ? (You need that for the parse driver) - -*************** -*** 32,38 **** - PARSEB_ANNOUNCE switch time zone warning (informational only) - PARSEB_POWERUP no synchronisation - clock confused (must set then) - PARSEB_NOSYNC timecode currently not confirmed (must set then) -! usually on reception error when the is still a - chance the the generated time is still ok. - - PARSEB_DST DST in effect (informational only) ---- 32,38 ---- - PARSEB_ANNOUNCE switch time zone warning (informational only) - PARSEB_POWERUP no synchronisation - clock confused (must set then) - PARSEB_NOSYNC timecode currently not confirmed (must set then) -! usually on reception error when there is still a - chance the the generated time is still ok. - - PARSEB_DST DST in effect (informational only) -*************** -*** 53,59 **** - them for examples. The basic structure is: - - struct clockformat _format = { -! lots of field for you to fill out (see below) - }; - - static cvt_() ---- 53,59 ---- - them for examples. The basic structure is: - - struct clockformat _format = { -! lots of fields for you to fill out (see below) - }; - - static cvt_() -*************** -*** 122,132 **** - file with the time code conversion. See the examples and pick a clock - closest to yours and tweak the code to match your clock. - -! In order to make your clk_*.c file usable a referenc to the clockformat - structure must be put into parse_conf.c. - -- -- - TTY setup and initialisation/configuration will be done in - xntpd/refclock_parse.c - ---- 122,130 ---- - file with the time code conversion. See the examples and pick a clock - closest to yours and tweak the code to match your clock. - -! In order to make your clk_*.c file usable a reference to the clockformat - structure must be put into parse_conf.c. - - TTY setup and initialisation/configuration will be done in - xntpd/refclock_parse.c - -*************** -*** 135,141 **** - termio*.h c_cflag macros. - - - in xntpd/refclock_parse.c fill out a new the struct clockinfo element -! (allocates a new "IP" address - see comments) - (see all the other clocks for example) - struct clockinfo - { ---- 133,139 ---- - termio*.h c_cflag macros. - - - in xntpd/refclock_parse.c fill out a new the struct clockinfo element -! (that allocates a new "IP" address - see comments) - (see all the other clocks for example) - struct clockinfo - { -*************** -*** 188,199 **** - - - Well, this is very sketchy, i know. But I hope it helps a little bit. -! The best way is to look which clock comes closet to your and tweak that - code. -! Two sorts of clocks are used with parse. Clocks that automatically sent -! thier time code (once a second) do not nee entries in the poll routines because -! they sent the data all the time. The second sort are the clocks that need a -! command sent to then in order to reply with a time code (like the Trimble - clock). - - For questions: kardel@informatik.uni-erlangen.de. Please include ---- 186,197 ---- - - - Well, this is very sketchy, i know. But I hope it helps a little bit. -! The best way is to look which clock comes closest to your and tweak that - code. -! Two sorts of clocks are used with parse. Clocks that automatically send -! their time code (once a second) do not need entries in the poll routines because -! they send the data all the time. The second sort are the clocks that need a -! command sent to them in order to reply with a time code (like the Trimble - clock). - - For questions: kardel@informatik.uni-erlangen.de. Please include -RCS file: /src/NTP/REPOSITORY/v3/parse/README.parse_clocks,v -retrieving revision 1.1.1.1 -retrieving revision 3.2 -diff -c -r1.1.1.1 -r3.2 -*** parse/README.parse_clocks:1.1.1.1 1994/01/01 00:00:00 ---- parse/README.parse_clocks 1994/02/17 20:10:02 -*************** -*** 1,4 **** -! The parse driver currently supports several clock with different - query mechanisms. In order for you to find a sample that might be - similar to a clock you might want to integrate into parse i'll sum - up the major features of the clocks (this information is distributed ---- 1,4 ---- -! The parse driver currently supports several clocks with different - query mechanisms. In order for you to find a sample that might be - similar to a clock you might want to integrate into parse i'll sum - up the major features of the clocks (this information is distributed --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.2 b/usr.sbin/xntpd/patches/patch.2 deleted file mode 100644 index 50a102355f7c..000000000000 --- a/usr.sbin/xntpd/patches/patch.2 +++ /dev/null @@ -1,129 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa12171; 26 Jan 94 17:04 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa15368; - 26 Jan 94 17:00 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA17953 (5.65c-6/7.3v-FAU); Wed, 26 Jan 1994 23:00:40 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA29710 (5.65c-6/7.3m-FAU); Wed, 26 Jan 1994 23:00:37 +0100 -From: Frank Kardel -Message-Id: <199401262200.AA29710@faui43.informatik.uni-erlangen.de> -Subject: Re: Solaribum -To: Mills@udel.edu -Date: Wed, 26 Jan 94 23:00:31 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, Piete.Brooks@cl.cam.ac.uk, - Paul_Vixie@corpmis.sjc.hw.sony.com -In-Reply-To: <9401261207.aa10860@huey.udel.edu>; from "Mills@udel.edu" at Jan 26, 94 12:07 pm -X-Mailer: ELM [version 2.3 PL11] - - -Sorry, guys - i tripped over a backward compatibility -variable. Thus the second patch: - -diff -c include/ntp_control.h:3.6 include/ntp_control.h:3.7 -*** include/ntp_control.h:3.6 Wed Jan 26 22:57:52 1994 ---- include/ntp_control.h Wed Jan 26 22:57:52 1994 -*************** -*** 204,210 **** - #define CP_SENT 32 - #define CP_FILTERROR 33 - #define CP_FLASH 34 -! #define CP_VARLIST 35 - - #define CP_MAXCODE CP_VARLIST - ---- 204,211 ---- - #define CP_SENT 32 - #define CP_FILTERROR 33 - #define CP_FLASH 34 -! #define CP_DISP 35 -! #define CP_VARLIST 36 - - #define CP_MAXCODE CP_VARLIST - -diff -c xntpd/ntp_control.c:3.21 xntpd/ntp_control.c:3.22 -*** xntpd/ntp_control.c:3.21 Wed Jan 26 22:58:30 1994 ---- xntpd/ntp_control.c Wed Jan 26 22:58:31 1994 -*************** -*** 175,181 **** - { CP_SENT, RO, "sent" }, /* 32 */ - { CP_FILTERROR, RO, "filterror" }, /* 33 */ - { CP_FLASH, RO, "flash" }, /* 34 */ -! { CP_VARLIST, RO, "peer_var_list" }, /* 35 */ - { 0, EOV, "" } - }; - ---- 175,182 ---- - { CP_SENT, RO, "sent" }, /* 32 */ - { CP_FILTERROR, RO, "filterror" }, /* 33 */ - { CP_FLASH, RO, "flash" }, /* 34 */ -! { CP_DISP, PADDING,"" }, /* 35 */ -! { CP_VARLIST, RO, "peer_var_list" }, /* 36 */ - { 0, EOV, "" } - }; - -*************** -*** 1298,1303 **** ---- 1299,1307 ---- - - for (k = sys_var; !(k->flags &EOV); k++) - { -+ if (k->flags & PADDING) -+ continue; -+ - i = strlen(k->text); - if (s+i+1 >= be) - break; -*************** -*** 1309,1314 **** ---- 1313,1321 ---- - - for (k = ext_sys_var; k && !(k->flags &EOV); k++) - { -+ if (k->flags & PADDING) -+ continue; -+ - ss = k->text; - if (!ss) - continue; -*************** -*** 1484,1489 **** ---- 1491,1499 ---- - - for (k = peer_var; !(k->flags &EOV); k++) - { -+ if (k->flags & PADDING) -+ continue; -+ - i = strlen(k->text); - if (s+i+1 >= be) - break; -*************** -*** 1594,1599 **** ---- 1604,1612 ---- - - for (k = clock_var; !(k->flags &EOV); k++) - { -+ if (k->flags & PADDING) -+ continue; -+ - i = strlen(k->text); - if (s+i+1 >= be) - break; -*************** -*** 1605,1610 **** ---- 1618,1626 ---- - - for (k = clock->kv_list; k && !(k->flags &EOV); k++) - { -+ if (k->flags & PADDING) -+ continue; -+ - ss = k->text; - if (!ss) - continue; --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.20 b/usr.sbin/xntpd/patches/patch.20 deleted file mode 100644 index 39755074a363..000000000000 --- a/usr.sbin/xntpd/patches/patch.20 +++ /dev/null @@ -1,1031 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa03713; 20 Feb 94 10:36 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa02155; - 20 Feb 94 10:26 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA03871 (5.65c-6/7.3v-FAU); Sun, 20 Feb 1994 16:26:26 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA04409 (5.65c-6/7.3m-FAU); Sun, 20 Feb 1994 16:26:24 +0100 -From: Frank Kardel -Message-Id: <199402201526.AA04409@faui43.informatik.uni-erlangen.de> -Subject: 3.3g patches -To: mills@udel.edu -Date: Sun, 20 Feb 94 16:26:19 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave, - -here are some more patches. They fix the following: - - nroff macros from John Line - - parse add/delete leap second (as opposed to just add second) - - some rcs ids - - linux support - - xntpd.8 leap variable documentation - -And here we go... - -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/compilers/linux.gcc,v -retrieving revision 1.2 -diff -c -r1.2 linux.gcc -*** 1.2 1993/10/10 23:10:03 ---- compilers/linux.gcc 1994/02/20 13:03:27 -*************** -*** 1,2 **** - COMPILER= gcc -DUSE_PROTOTYPES -Wall -! COPTS= -O6 -finline-functions -fomit-frame-pointer ---- 1,2 ---- - COMPILER= gcc -DUSE_PROTOTYPES -Wall -! COPTS= -O2 -finline-functions -fomit-frame-pointer -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/notes.txt,v -retrieving revision 1.3 -diff -c -r1.3 notes.txt -*** 1.3 1993/08/24 21:24:55 ---- doc/notes.txt 1994/02/20 11:57:24 -*************** -*** 785,791 **** - with mode-6 messages is set the leap-second warning bits) and the ntpq - program provides generic support for the latter. The leap bits that can be - set in the leap_warning variable (up to one month ahead) and in the -! leap_indication variable have a slighly different encoding than the - usual interpretation: - - Value Action ---- 785,791 ---- - with mode-6 messages is set the leap-second warning bits) and the ntpq - program provides generic support for the latter. The leap bits that can be - set in the leap_warning variable (up to one month ahead) and in the -! leap_indication variable have a slightly different encoding than the - usual interpretation: - - Value Action -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/ntpdate.8,v -retrieving revision 3.0 -diff -c -r3.0 ntpdate.8 -*** 3.0 1992/08/14 15:11:44 ---- doc/ntpdate.8 1994/02/20 11:27:53 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/ntpq.8,v -retrieving revision 3.3 -diff -c -r3.3 ntpq.8 -*** 3.3 1993/10/22 14:26:57 ---- doc/ntpq.8 1994/02/20 11:27:55 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/ntptrace.8,v -retrieving revision 1.1.1.2 -diff -c -r1.1.1.2 ntptrace.8 -*** 1.1.1.2 1993/01/26 18:55:43 ---- doc/ntptrace.8 1994/02/20 11:27:58 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/tickadj.8,v -retrieving revision 3.0 -diff -c -r3.0 tickadj.8 -*** 3.0 1992/08/14 15:11:53 ---- doc/tickadj.8 1994/02/20 11:28:00 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/xntpd.8,v -retrieving revision 3.24 -diff -c -r3.24 xntpd.8 -*** 3.24 1994/02/02 16:42:25 ---- doc/xntpd.8 1994/02/20 11:57:28 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -*************** -*** 374,380 **** - Certain changes can be made to the - .I xntpd - server via mode 6 control messages, in particular the setting of -! leap second indications in a server with a radio clock. The - .B controlkey - statement specifies an encription key number to be used for authenticating - such messages. Omitting this statement will cause control messages ---- 374,381 ---- - Certain changes can be made to the - .I xntpd - server via mode 6 control messages, in particular the setting of -! leap second indications in a server with a radio clock. -! The - .B controlkey - statement specifies an encription key number to be used for authenticating - such messages. Omitting this statement will cause control messages -*************** -*** 1401,1406 **** ---- 1402,1432 ---- - If flag3 is set, then the sample information is dumped. - If flag4 is set, then the input data is smoothed, and all data - points are used. -+ .PP -+ .SH VARIABLES -+ Most variables used by the NTP protocol can be examined with the xntpdc -+ (mode 7 messages) and the ntpq (mode 6 messages). Currently very few variables -+ can be modified via mode 6 messages. These variables are either created with the -+ .I setvar -+ directive or the leap warning variables. The leap warning bits that can be -+ set in the -+ .B leapwarning -+ variable (up to one month ahead). Both, the -+ .B leapwarning and in the -+ .B leapindication -+ variable, have a slightly different encoding than the usual -+ .B leap -+ bits interpretation: -+ .P -+ .Ip 00 8 -+ The daemon passes the leap bits of its synchronisation source (usual mode of -+ operation). -+ .Ip 01/10 8 -+ A leap second is added/deleted (operator forced leap second). -+ .Ip 11 8 -+ Leap information from the sychronisation source is ignored (thus LEAP_NOWARNING -+ is passed on). -+ .PP - .SH FILES - .Ip /etc/ntp.conf 20 - the default name of the configuration file -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/doc/xntpdc.8,v -retrieving revision 3.4 -diff -c -r3.4 xntpdc.8 -*** 3.4 1994/02/02 15:54:14 ---- doc/xntpdc.8 1994/02/20 11:28:06 -*************** -*** 20,32 **** - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Bell System Logo is used as a dummy character. - ''' -! .tr \(bs-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(bs- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' ---- 20,32 ---- - ''' - ''' Set up \*(-- to give an unbreakable dash; - ''' string Tr holds user defined translation string. -! ''' Greek uppercase omega is used as a dummy character. - ''' -! .tr \(*W-|\(bv\*(Tr - .ie n \{\ -! .ds -- \(*W- -! .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -! .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch - .ds L" "" - .ds R" "" - .ds L' ' -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/hints/linux,v -retrieving revision 1.2 -diff -c -r1.2 linux -*** 1.2 1994/02/01 23:19:26 ---- hints/linux 1994/02/20 11:26:44 -*************** -*** 1,5 **** - -! Requirements: kernel 0.99.14y or newer, libc 4.5.8 or newer - ------------ - - With this configuration, xntp should build an run right out of the box ---- 1,5 ---- - -! Requirements: kernel 0.99.14y or newer, libc 4.5.20 or newer - ------------ - - With this configuration, xntp should build an run right out of the box -*************** -*** 7,9 **** ---- 7,14 ---- - versions of the kernel or libc, or have any other question not covered in the - READMEs / hint files (sorry, necessary comment in the Linux community ;-) feel - free to ask me (duwe@informatik.uni-erlangen.de) -+ -+ [NOTE: libc-4.5.20 is (or was ? ;-) a beta testing release, but the first -+ binary compiled under the appropriate kernel. Get this one from -+ tsx-11:.../GCC/private/dontuse , compile 4.5.19 yourself or wait for the next -+ puplic relase after 4.5.20] -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/include/parse.h,v -retrieving revision 3.14 -diff -c -r3.14 parse.h -*** 3.14 1994/01/28 14:03:35 ---- include/parse.h 1994/02/20 13:04:26 -*************** -*** 81,115 **** - /* - * state flags - */ -! #define PARSEB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ -! #define PARSEB_POWERUP 0x0002 /* no synchronisation */ -! #define PARSEB_NOSYNC 0x0004 /* timecode currently not confirmed */ -! #define PARSEB_DST 0x0008 /* DST in effect */ -! #define PARSEB_UTC 0x0010 /* UTC time */ -! #define PARSEB_LEAP 0x0020 /* LEAP warning (1 hour prior to occurence) */ -! #define PARSEB_ALTERNATE 0x0040 /* alternate antenna used */ -! #define PARSEB_POSITION 0x0080 /* position available */ -! #define PARSEB_LEAPSECOND 0x0100 /* actual leap second */ -! -! #define PARSEB_S_LEAP 0x0200 /* supports LEAP */ -! #define PARSEB_S_ANTENNA 0x0400 /* supports antenna information */ -! #define PARSEB_S_PPS 0x0800 /* supports PPS time stamping */ -! #define PARSEB_S_POSITION 0x1000 /* supports position information (GPS) */ - -! #define PARSEB_TIMECODE 0x2000 /* valid time code sample */ -! #define PARSEB_PPS 0x4000 /* valid PPS sample */ - - #define PARSE_TCINFO (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\ -! PARSEB_UTC|PARSEB_LEAP|PARSEB_ALTERNATE|PARSEB_S_LEAP|\ - PARSEB_S_LOCATION|PARSEB_TIMECODE) - -! #define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP) -! #define PARSE_NOSYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == PARSEB_NOSYNC) -! #define PARSE_SYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == 0) -! #define PARSE_ANNOUNCE(x) ((x) & PARSEB_ANNOUNCE) -! #define PARSE_DST(x) ((x) & PARSEB_DST) - #define PARSE_UTC(x) ((x) & PARSEB_UTC) -! #define PARSE_LEAP(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP)) - #define PARSE_ALTERNATE(x) ((x) & PARSEB_ALTERNATE) - #define PARSE_LEAPSECOND(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND)) - ---- 81,135 ---- - /* - * state flags - */ -! #define PARSEB_POWERUP 0x00000001 /* no synchronisation */ -! #define PARSEB_NOSYNC 0x00000002 /* timecode currently not confirmed */ - -! /* -! * time zone information -! */ -! #define PARSEB_ANNOUNCE 0x00000010 /* switch time zone warning (DST switch) */ -! #define PARSEB_DST 0x00000020 /* DST in effect */ -! #define PARSEB_UTC 0x00000040 /* UTC time */ -! -! /* -! * leap information -! */ -! #define PARSEB_LEAPDEL 0x00000100 /* LEAP deletion warning */ -! #define PARSEB_LEAPADD 0x00000200 /* LEAP addition warning */ -! #define PARSEB_LEAPS 0x00000300 /* LEAP warnings */ -! #define PARSEB_LEAPSECOND 0x00000400 /* actual leap second */ -! /* -! * optional status information -! */ -! #define PARSEB_ALTERNATE 0x00001000 /* alternate antenna used */ -! #define PARSEB_POSITION 0x00002000 /* position available */ -! -! /* -! * feature information -! */ -! #define PARSEB_S_LEAP 0x00010000 /* supports LEAP */ -! #define PARSEB_S_ANTENNA 0x00020000 /* supports antenna information */ -! #define PARSEB_S_PPS 0x00040000 /* supports PPS time stamping */ -! #define PARSEB_S_POSITION 0x00080000 /* supports position information (GPS) */ -! -! /* -! * time stamp availality -! */ -! #define PARSEB_TIMECODE 0x10000000 /* valid time code sample */ -! #define PARSEB_PPS 0x20000000 /* valid PPS sample */ - - #define PARSE_TCINFO (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\ -! PARSEB_UTC|PARSEB_LEAPS|PARSEB_ALTERNATE|PARSEB_S_LEAP|\ - PARSEB_S_LOCATION|PARSEB_TIMECODE) - -! #define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP) -! #define PARSE_NOSYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == PARSEB_NOSYNC) -! #define PARSE_SYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == 0) -! #define PARSE_ANNOUNCE(x) ((x) & PARSEB_ANNOUNCE) -! #define PARSE_DST(x) ((x) & PARSEB_DST) - #define PARSE_UTC(x) ((x) & PARSEB_UTC) -! #define PARSE_LEAPADD(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPADD)) -! #define PARSE_LEAPDEL(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPDEL)) - #define PARSE_ALTERNATE(x) ((x) & PARSEB_ALTERNATE) - #define PARSE_LEAPSECOND(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND)) - -*************** -*** 118,126 **** - #define PARSE_S_PPS(x) ((x) & PARSEB_S_PPS) - #define PARSE_S_POSITION(x) ((x) & PARSEB_S_POSITION) - -! #define PARSE_TIMECODE(x) ((x) & PARSEB_TIMECODE) - #define PARSE_PPS(x) ((x) & PARSEB_PPS) -! #define PARSE_POSITION(x) ((x) & PARSEB_POSITION) - - /* - * operation flags - some are also fudge flags ---- 138,146 ---- - #define PARSE_S_PPS(x) ((x) & PARSEB_S_PPS) - #define PARSE_S_POSITION(x) ((x) & PARSEB_S_POSITION) - -! #define PARSE_TIMECODE(x) ((x) & PARSEB_TIMECODE) - #define PARSE_PPS(x) ((x) & PARSEB_PPS) -! #define PARSE_POSITION(x) ((x) & PARSEB_POSITION) - - /* - * operation flags - some are also fudge flags -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/README.new_clocks,v -retrieving revision 3.3 -diff -c -r3.3 README.new_clocks -*** 3.3 1994/02/17 20:09:58 ---- parse/README.new_clocks 1994/02/20 13:04:34 -*************** -*** 37,43 **** - - PARSEB_DST DST in effect (informational only) - PARSEB_UTC timecode contains UTC time (informational only) -! PARSEB_LEAP LEAP warning (prior to leap happening - must set when imminent) - PARSEB_ALTERNATE backup transmitter (informational only) - PARSEB_POSITION geographic position available (informational only) - PARSEB_LEAPSECOND actual leap second (this time code is the leap ---- 37,46 ---- - - PARSEB_DST DST in effect (informational only) - PARSEB_UTC timecode contains UTC time (informational only) -! PARSEB_LEAPADD LEAP addition warning (prior to leap happening - must set when imminent) -! also used for time code that do not encode the -! direction (as this is currently the default). -! PARSEB_LEAPDEL LEAP deletion warning (prior to leap happening - must set when imminent) - PARSEB_ALTERNATE backup transmitter (informational only) - PARSEB_POSITION geographic position available (informational only) - PARSEB_LEAPSECOND actual leap second (this time code is the leap -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v -retrieving revision 3.13 -diff -c -r3.13 clk_meinberg.c -*** 3.13 1994/02/02 17:45:21 ---- parse/clk_meinberg.c 1994/02/20 13:04:37 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.13 1994/02/02 17:45:21 kardel Exp - * -! * clk_meinberg.c,v 3.13 1994/02/02 17:45:21 kardel Exp - * - * Meinberg clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp - * -! * clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp - * - * Meinberg clock support - * -*************** -*** 284,291 **** - clock->flags |= PARSEB_S_LEAP; - clock->flags |= PARSEB_S_ANTENNA; - - if (f[4] == 'A') -! clock->flags |= PARSEB_LEAP; - - if (f[5] == 'R') - clock->flags |= PARSEB_ALTERNATE; ---- 284,296 ---- - clock->flags |= PARSEB_S_LEAP; - clock->flags |= PARSEB_S_ANTENNA; - -+ /* -+ * DCF77 does not encode the direction - -+ * so we take the current default - -+ * earth slowing down -+ */ - if (f[4] == 'A') -! clock->flags |= PARSEB_LEAPADD; - - if (f[5] == 'R') - clock->flags |= PARSEB_ALTERNATE; -*************** -*** 394,402 **** - - /* - * oncoming leap second - */ - if (f[5] == 'A') -! clock->flags |= PARSEB_LEAP; - - /* - * this is the leap second ---- 399,410 ---- - - /* - * oncoming leap second -+ * data format does not (yet) specify whether -+ * to add or to delete a second - thus we -+ * pick the current default - */ - if (f[5] == 'A') -! clock->flags |= PARSEB_LEAPADD; - - /* - * this is the leap second -*************** -*** 413,419 **** - /* - * History: - * -! * clk_meinberg.c,v - * Revision 3.13 1994/02/02 17:45:21 kardel - * rcs ids fixed - * ---- 421,430 ---- - /* - * History: - * -! * clk_meinberg.c,v -! * Revision 3.14 1994/02/20 13:04:37 kardel -! * parse add/delete second support -! * - * Revision 3.13 1994/02/02 17:45:21 kardel - * rcs ids fixed - * -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v -retrieving revision 3.11 -diff -c -r3.11 clk_rawdcf.c -*** 3.11 1994/02/02 17:45:23 ---- parse/clk_rawdcf.c 1994/02/20 13:04:39 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.11 1994/02/02 17:45:23 kardel Exp - * -! * clk_rawdcf.c,v 3.11 1994/02/02 17:45:23 kardel Exp - * - * Raw DCF77 pulse clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.12 1994/02/20 13:04:39 kardel Exp - * -! * clk_rawdcf.c,v 3.12 1994/02/20 13:04:39 kardel Exp - * - * Raw DCF77 pulse clock support - * -*************** -*** 278,284 **** - clock->flags |= PARSEB_ANNOUNCE; - - if (ext_bf(buffer, DCF_A2, dcfparam->zerobits)) -! clock->flags |= PARSEB_LEAP; - - if (ext_bf(buffer, DCF_R, dcfparam->zerobits)) - clock->flags |= PARSEB_ALTERNATE; ---- 278,284 ---- - clock->flags |= PARSEB_ANNOUNCE; - - if (ext_bf(buffer, DCF_A2, dcfparam->zerobits)) -! clock->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */ - - if (ext_bf(buffer, DCF_R, dcfparam->zerobits)) - clock->flags |= PARSEB_ALTERNATE; -*************** -*** 528,534 **** - /* - * History: - * -! * clk_rawdcf.c,v - * Revision 3.11 1994/02/02 17:45:23 kardel - * rcs ids fixed - * ---- 528,537 ---- - /* - * History: - * -! * clk_rawdcf.c,v -! * Revision 3.12 1994/02/20 13:04:39 kardel -! * parse add/delete second support -! * - * Revision 3.11 1994/02/02 17:45:23 kardel - * rcs ids fixed - * -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v -retrieving revision 3.12 -diff -c -r3.12 clk_schmid.c -*** 3.12 1994/02/02 17:45:25 ---- parse/clk_schmid.c 1994/02/20 13:04:41 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.12 1994/02/02 17:45:25 kardel Exp - * -! * clk_schmid.c,v 3.12 1994/02/02 17:45:25 kardel Exp - * - * Schmid clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp - * -! * clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp - * - * Schmid clock support - * -*************** -*** 152,158 **** - - if (buffer[8] & WS_LEAP) - { -! clock->flags |= PARSEB_LEAP; - } - } - ---- 152,158 ---- - - if (buffer[8] & WS_LEAP) - { -! clock->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */ - } - } - -*************** -*** 167,173 **** - /* - * History: - * -! * clk_schmid.c,v - * Revision 3.12 1994/02/02 17:45:25 kardel - * rcs ids fixed - * ---- 167,176 ---- - /* - * History: - * -! * clk_schmid.c,v -! * Revision 3.13 1994/02/20 13:04:41 kardel -! * parse add/delete second support -! * - * Revision 3.12 1994/02/02 17:45:25 kardel - * rcs ids fixed - * -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v -retrieving revision 3.47 -diff -c -r3.47 refclock_parse.c -*** 3.47 1994/02/02 17:44:30 ---- xntpd/refclock_parse.c 1994/02/20 13:26:00 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.47 1994/02/02 17:44:30 kardel Exp - * -! * refclock_parse.c,v 3.47 1994/02/02 17:44:30 kardel Exp - * - * generic reference clock driver for receivers - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * -! * refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * - * generic reference clock driver for receivers - * -*************** -*** 129,135 **** - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp"; - #endif - - /**=========================================================================== ---- 129,135 ---- - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp"; - #endif - - /**=========================================================================== -*************** -*** 1706,1712 **** - { PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" }, - { PARSEB_DST, "DST" }, - { PARSEB_UTC, "UTC DISPLAY" }, -! { PARSEB_LEAP, "LEAP WARNING" }, - { PARSEB_LEAPSECOND, "LEAP SECOND" }, - { PARSEB_ALTERNATE,"ALTERNATE ANTENNA" }, - { PARSEB_TIMECODE, "TIME CODE" }, ---- 1706,1713 ---- - { PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" }, - { PARSEB_DST, "DST" }, - { PARSEB_UTC, "UTC DISPLAY" }, -! { PARSEB_LEAPADD, "LEAP ADD WARNING" }, -! { PARSEB_LEAPDEL, "LEAP DELETE WARNING" }, - { PARSEB_LEAPSECOND, "LEAP SECOND" }, - { PARSEB_ALTERNATE,"ALTERNATE ANTENNA" }, - { PARSEB_TIMECODE, "TIME CODE" }, -*************** -*** 2539,2547 **** - parse_leap() - { - /* -- * PARSE does encode a leap warning... we are aware but not afraid of that -- * as long as we get a little help for the direction from the operator until - * PARSE encodes the LEAP correction direction. - */ - } - ---- 2540,2549 ---- - parse_leap() - { - /* - * PARSE encodes the LEAP correction direction. -+ * For timecodes that do not pass on the leap correction direction -+ * the default PARSEB_LEAPADD must be used. It may then be modified -+ * with a fudge flag (flag2). - */ - } - -*************** -*** 2821,2827 **** - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; ---- 2823,2829 ---- - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; -*************** -*** 3245,3258 **** - } - else - { -! if (PARSE_LEAP(parsetime->parse_state)) - { - leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND; - } - else -! { -! leap = LEAP_NOWARNING; -! } - } - - refclock_receive(parse->peer, &off, 0, LFPTOFP(&dispersion), &reftime, &rectime, leap); ---- 3247,3270 ---- - } - else - { -! if (PARSE_LEAPADD(parsetime->parse_state)) - { -+ /* -+ * we pick this state also for time code that pass leap warnings -+ * without direction information (as earth is currently slowing -+ * down). -+ */ - leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND; - } - else -! if (PARSE_LEAPDEL(parsetime->parse_state)) -! { -! leap = LEAP_DELSECOND; -! } -! else -! { -! leap = LEAP_NOWARNING; -! } - } - - refclock_receive(parse->peer, &off, 0, LFPTOFP(&dispersion), &reftime, &rectime, leap); -*************** -*** 3395,3401 **** - /* - * History: - * -! * refclock_parse.c,v - * Revision 3.47 1994/02/02 17:44:30 kardel - * rcs ids fixed - * ---- 3407,3419 ---- - /* - * History: - * -! * refclock_parse.c,v -! * Revision 3.49 1994/02/20 13:26:00 kardel -! * rcs id cleanup -! * -! * Revision 3.48 1994/02/20 13:04:56 kardel -! * parse add/delete second support -! * - * Revision 3.47 1994/02/02 17:44:30 kardel - * rcs ids fixed - * -*** parse/util/parsetest.c Sun Feb 20 15:54:11 1994 ---- parse/util/parsetest.c Sun Feb 20 14:04:46 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/kernel/parsetest.c,v 3.4 1993/03/17 17:16:57 kardel Exp - * -! * parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/util/parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp - * -! * parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 10,26 **** - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * -! * parsetest.c,v -! * Revision 3.4 1993/03/17 17:16:57 kardel -! * DEC OSF/1 ALPHA Integration - 930314 - * -! * Revision 3.3 1993/01/18 09:24:33 kardel -! * updated copyright conditions in conjunction with -! * conditions set up in the COPYRIGHT file - * -- * Revision 3.2 1993/01/17 13:43:00 kardel -- * 1993 initial update -- * - */ - - #ifndef STREAM ---- 10,22 ---- - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * -! * parsetest.c,v -! * Revision 3.13 1994/02/20 13:04:46 kardel -! * parse add/delete second support - * -! * Revision 3.12 1994/02/02 17:45:51 kardel -! * rcs ids fixed - * - */ - - #ifndef STREAM -*************** -*** 199,205 **** - parsetime_t parsetime; - struct strioctl strioc; - -! printf("parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp\n"); - - while (ioctl(fd, I_POP, 0) == 0) - ; ---- 195,201 ---- - parsetime_t parsetime; - struct strioctl strioc; - -! printf("parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp\n"); - - while (ioctl(fd, I_POP, 0) == 0) - ; -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v -retrieving revision 3.16 -diff -c -r3.16 parsestreams.c -*** 3.16 1994/02/15 22:39:50 ---- parse/parsestreams.c 1994/02/20 15:18:02 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.16 1994/02/15 22:39:50 kardel Exp - * -! * parsestreams.c,v 3.16 1994/02/15 22:39:50 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp - * -! * parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) -*************** -*** 16,22 **** - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp"; - #endif - - #include "sys/types.h" ---- 16,22 ---- - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp"; - #endif - - #include "sys/types.h" -*************** -*** 195,201 **** - } - else - { -! static char revision[] = "3.12"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); ---- 195,201 ---- - } - else - { -! static char revision[] = "3.17"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); -*************** -*** 1259,1265 **** - /* - * History: - * -! * parsestreams.c,v - * Revision 3.16 1994/02/15 22:39:50 kardel - * memory leak on open failure closed - * ---- 1259,1268 ---- - /* - * History: - * -! * parsestreams.c,v -! * Revision 3.17 1994/02/20 15:18:02 kardel -! * rcs id cleanup -! * - * Revision 3.16 1994/02/15 22:39:50 kardel - * memory leak on open failure closed - * --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.21 b/usr.sbin/xntpd/patches/patch.21 deleted file mode 100644 index 929997130909..000000000000 --- a/usr.sbin/xntpd/patches/patch.21 +++ /dev/null @@ -1,54 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa25363; 23 Feb 94 18:50 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa28210; - 23 Feb 94 18:44 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA07903 (5.65c-6/7.3v-FAU); Thu, 24 Feb 1994 00:44:18 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA19013 (5.65c-6/7.3m-FAU); Thu, 24 Feb 1994 00:44:17 +0100 -From: Frank Kardel -Message-Id: <199402232344.AA19013@faui43.informatik.uni-erlangen.de> -Subject: TRAK clock -To: mills@udel.edu -Date: Thu, 24 Feb 94 0:44:12 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave - some obvious things about the TRAK clock: - - please removed the 4 ^A at the end of the - xntpd/reflock_trak.c file (email leftovers). - - add following refclocks/rclk.TRAK file - -#!/bin/sh - -CMD="$1" -shift; - -. refclocks/setup - -case "$CMD" in - info) - echo " TRAK - TRAK 8810 GPS station clock" - ;; - check) - if check "$RCONFIG" '$0 ~ /TRAK/'; then - echo "TRAK - TRAK 8810 GPS station clock" - fi - ;; - config) - if check "$REFCONF" '$0 ~ /TRAK/' || - ( [ ! "$REFCONF" ] && query "Include TRAK 8810 GPS station clock (TRAK)" n); then - if check "$PPSFEATURES" '$0 ~ /CD/' && - [ "$PPSOK" -eq 1 ] && - (check "$REFCONF" '$0 ~ /TRAKPPS/' || - ( [ ! "$REFCONF" ] && query " Use TRAK for PPS" n)); then - echo "-DTRAKPPS" >> $RCONFIG - else - echo "-DTRAK" >> $RCONFIG - fi - fi - ;; -esac --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.22 b/usr.sbin/xntpd/patches/patch.22 deleted file mode 100644 index 8b4296c79926..000000000000 --- a/usr.sbin/xntpd/patches/patch.22 +++ /dev/null @@ -1,296 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa02110; 24 Feb 94 18:54 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa13897; - 24 Feb 94 18:53 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA27796 (5.65c-6/7.3v-FAU); Fri, 25 Feb 1994 00:53:32 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA16114 (5.65c-6/7.3m-FAU); Fri, 25 Feb 1994 00:53:31 +0100 -From: Frank Kardel -Message-Id: <199402242353.AA16114@faui43.informatik.uni-erlangen.de> -Subject: patches (parse pps/pll control) -To: mills@udel.edu -Date: Fri, 25 Feb 94 0:52:59 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi, here are some patches. - -pps pll control is nor supported by parse. -pps output variable are readable via mode 6 messages. - -diff -c v3/parse/parsestreams.c:1.1.1.10 v3/parse/parsestreams.c:3.19 -*** v3/parse/parsestreams.c:1.1.1.10 Fri Feb 25 00:44:41 1994 ---- v3/parse/parsestreams.c Fri Feb 25 00:44:41 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp - * -! * parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp - * -! * parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) -*************** -*** 16,22 **** - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.17 1994/02/20 15:18:02 kardel Exp"; - #endif - - #include "sys/types.h" ---- 16,22 ---- - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp"; - #endif - - #include "sys/types.h" -*************** -*** 195,201 **** - } - else - { -! static char revision[] = "3.17"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); ---- 195,201 ---- - } - else - { -! static char revision[] = "3.19"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); -*************** -*** 1076,1081 **** ---- 1076,1086 ---- - - #define MAXDEPTH 50 /* maximum allowed stream crawl */ - -+ #ifdef PPS_SYNC -+ extern hardpps(); -+ extern struct timeval time; -+ #endif -+ - /* - * take external status interrupt (only CD interests us) - */ -*************** -*** 1087,1101 **** - register queue_t *q; - register unsigned char zsstatus; - register int loopcheck; -- register unsigned char cdstate; - register char *dname; - - /* - * pick up current state - */ - zsstatus = zsaddr->zscc_control; - -! if (za->za_rr0 ^ (cdstate = zsstatus & ZSRR0_CD)) - { - timestamp_t cdevent; - register int status; ---- 1092,1109 ---- - register queue_t *q; - register unsigned char zsstatus; - register int loopcheck; - register char *dname; -+ #ifdef PPS_SYNC -+ register int s; -+ register long usec; -+ #endif - - /* - * pick up current state - */ - zsstatus = zsaddr->zscc_control; - -! if ((za->za_rr0 ^ zsstatus) & (ZSRR0_CD|ZSRR0_SYNC)) - { - timestamp_t cdevent; - register int status; -*************** -*** 1103,1129 **** - /* - * CONDITIONAL external measurement support - */ -! SET_LED(cdstate); /* - * inconsistent with upper SET_LED, but this - * is for oscilloscope business anyway and we - * are just interested in edge delays in the - * lower us range - */ -! - /* - * time stamp - */ - uniqtime(&cdevent.tv); -! -! TIMEVAL_USADD(&cdevent.tv, xsdelay); -! -! q = za->za_ttycommon.t_readq; - - /* - * logical state - */ -! status = cd_invert ? cdstate == 0 : cdstate != 0; - - /* - * ok - now the hard part - find ourself - */ ---- 1111,1155 ---- - /* - * CONDITIONAL external measurement support - */ -! SET_LED(zsstatus & (ZSRR0_CD|ZSRR0_SYNC)); /* - * inconsistent with upper SET_LED, but this - * is for oscilloscope business anyway and we - * are just interested in edge delays in the - * lower us range - */ -! #ifdef PPS_SYNC -! s = splclock(); -! usec = time.tv_usec; -! #endif - /* - * time stamp - */ - uniqtime(&cdevent.tv); -! -! #ifdef PPS_SYNC -! splx(s); -! #endif - - /* - * logical state - */ -! status = cd_invert ? (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) == 0 : (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) != 0; - -+ #ifdef PPS_SYNC -+ if (status) -+ { -+ usec = cdevent.tv.tv_usec - usec; -+ if (usec < 0) -+ usec += 1000000; -+ -+ hardpps(&cdevent.tv, usec); -+ } -+ #endif -+ -+ TIMEVAL_USADD(&cdevent.tv, xsdelay); -+ -+ q = za->za_ttycommon.t_readq; -+ - /* - * ok - now the hard part - find ourself - */ -*************** -*** 1179,1188 **** - /* - * only pretend that CD has been handled - */ -! za->za_rr0 = za->za_rr0 & ~ZSRR0_CD | zsstatus & ZSRR0_CD; - ZSDELAY(2); - -! if (!((za->za_rr0 ^ zsstatus) & ~ZSRR0_CD)) - { - /* - * all done - kill status indication and return ---- 1205,1214 ---- - /* - * only pretend that CD has been handled - */ -! za->za_rr0 = za->za_rr0 & ~(ZSRR0_CD|ZSRR0_SYNC) | zsstatus & (ZSRR0_CD|ZSRR0_SYNC); - ZSDELAY(2); - -! if (!((za->za_rr0 ^ zsstatus) & ~(ZSRR0_CD|ZSRR0_SYNC))) - { - /* - * all done - kill status indication and return -*************** -*** 1260,1265 **** ---- 1286,1297 ---- - * History: - * - * parsestreams.c,v -+ * Revision 3.19 1994/02/24 16:33:54 kardel -+ * CD events can also be posted on sync flag -+ * -+ * Revision 3.18 1994/02/24 14:12:58 kardel -+ * initial PPS_SYNC support version -+ * - * Revision 3.17 1994/02/20 15:18:02 kardel - * rcs id cleanup - * -diff -c v3/xntpd/ntp_loopfilter.c:1.1.1.33 v3/xntpd/ntp_loopfilter.c:3.40 -*** v3/xntpd/ntp_loopfilter.c:1.1.1.33 Fri Feb 25 00:46:20 1994 ---- v3/xntpd/ntp_loopfilter.c Fri Feb 25 00:46:21 1994 -*************** -*** 522,529 **** ---- 522,545 ---- - ntv.maxerror = sys_rootdispersion + sys_rootdelay / 2; - ntv.esterror = sys_rootdispersion; - ntv.time_constant = time_constant; -+ ntv.shift = 0; - (void)ntp_adjtime(&ntv); - drift_comp = ntv.frequency; -+ if (ntv.shift != 0) { -+ char buf[128]; -+ (void) sprintf(buf, "pps_freq=%s", fptoa(ntv.ybar, 3)); -+ set_sys_var(buf, strlen(buf)+1, RO|DEF); -+ (void) sprintf(buf, "pps_disp=%s", fptoa(ntv.disp, 3)); -+ set_sys_var(buf, strlen(buf)+1, RO|DEF); -+ (void) sprintf(buf, "pps_interval=%ld",1 << ntv.shift); -+ set_sys_var(buf, strlen(buf)+1, RO); -+ (void) sprintf(buf, "pps_intervals=%ld", ntv.calcnt); -+ set_sys_var(buf, strlen(buf)+1, RO); -+ (void) sprintf(buf, "pps_jitterexceeded=%ld", ntv.jitcnt); -+ set_sys_var(buf, strlen(buf)+1, RO); -+ (void) sprintf(buf, "pps_dispersionexceeded=%ld", ntv.discnt); -+ set_sys_var(buf, strlen(buf)+1, RO); -+ } - #endif /* KERNEL_PLL */ - } else { - if (offset < 0) { -*************** -*** 725,730 **** ---- 741,748 ---- - "loop_config: skew compensation %s too large", - fptoa(tmp, 5)); - } else { -+ char var[40]; -+ - drift_comp = tmp; - - #if defined(KERNEL_PLL) -*************** -*** 751,756 **** ---- 769,778 ---- - syslog(LOG_NOTICE, - "%susing kernel phase-lock loop", - (pll_control) ? "" : "Not "); -+ (void)sprintf(var, "kernel_pll=%s", pll_control ? "true" : "false"); -+ -+ set_sys_var(var, strlen(var)+1, RO); -+ - #if DEBUG - if (debug) - printf("pll_control %d\n", pll_control); --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.23 b/usr.sbin/xntpd/patches/patch.23 deleted file mode 100644 index 5fee16f35e9c..000000000000 --- a/usr.sbin/xntpd/patches/patch.23 +++ /dev/null @@ -1,80 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa18634; 27 Feb 94 13:54 EST -Received: from rincewind.mech.virginia.edu by louie.udel.edu id aa11711; - 27 Feb 94 13:53 EST -Received: from localhost (dmm0t@localhost) by rincewind.mech.virginia.edu (8.6.5/8.6.5) id NAA04646 for mills@udel.edu; Sun, 27 Feb 1994 13:53:35 -0500 -From: David Meyer -Message-Id: <199402271853.NAA04646@rincewind.mech.virginia.edu> -Subject: patches to xntpd-3.3j for NeXT -To: mills@udel.edu -Date: Sun, 27 Feb 1994 13:53:34 -0500 (EST) -X-Mailer: ELM [version 2.4 PL23] -MIME-Version: 1.0 -Content-Type: text/plain; charset=US-ASCII -Content-Transfer-Encoding: 7bit -Content-Length: 2043 - -I have a couple of patches to make the 3.3j beta compile on a NeXT -running NS3.1. - -The first patch just defines RETSIGTYPE. The second patch puts -HAVE_BSD_TTYS in DEFS rather than AUTHDEFS. The last patch just fixes -a type - using # rather than * in a comment block. - -*** ../orig/include/ntp_machine.h Sun Feb 20 22:23:29 1994 ---- include/ntp_machine.h Sun Feb 27 13:47:59 1994 -*************** -*** 313,318 **** ---- 313,319 ---- - * Next - */ - #if defined(SYS_NEXT) -+ #define RETSIGTYPE void - #define DOSYNCTODR - #define HAVE_READKMEM - #define HAVE_BSD_NICE - -*** ../orig/machines/next Sun Feb 20 22:23:36 1994 ---- machines/next Sun Feb 27 13:47:15 1994 -*************** -*** 1,6 **** - RANLIB= ranlib -c -s -! DEFS= -DSYS_NEXT -! AUTHDEFS= -DDES -DMD5 -DFAST_MD5 -DHAVE_BSD_TTYS - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= ---- 1,6 ---- - RANLIB= ranlib -c -s -! DEFS= -DSYS_NEXT -DHAVE_BSD_TTYS -! AUTHDEFS= -DDES -DMD5 -DFAST_MD5 - CLOCKDEFS= -DLOCAL_CLOCK - DAEMONLIBS= - RESLIB= - -*** ../orig/xntpd/refclock_irig.c Thu Jan 27 09:03:58 1994 ---- xntpd/refclock_irig.c Sun Feb 27 13:36:30 1994 -*************** -*** 19,25 **** - * This driver supports the IRIG audio decoder. This clever gadget uses - * a modified BSD audio driver for the Sun SPARCstation which provides - * a timestamp, raw binary timecode, status byte and decoded ASCII -! # timecode. The data are represented in the structure: - * - * struct irig_time { - * struct timeval stamp; timestamp ---- 19,25 ---- - * This driver supports the IRIG audio decoder. This clever gadget uses - * a modified BSD audio driver for the Sun SPARCstation which provides - * a timestamp, raw binary timecode, status byte and decoded ASCII -! * timecode. The data are represented in the structure: - * - * struct irig_time { - * struct timeval stamp; timestamp - - --- -David M. Meyer Mechanical & Aerospace Engineering -dmm0t@rincewind.mech.virginia.edu University of Virginia -NeXTmail ok - diff --git a/usr.sbin/xntpd/patches/patch.24 b/usr.sbin/xntpd/patches/patch.24 deleted file mode 100644 index 6ab00e2a8391..000000000000 --- a/usr.sbin/xntpd/patches/patch.24 +++ /dev/null @@ -1,474 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa16943; 4 Mar 94 6:43 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa02686; - 4 Mar 94 6:34 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA12349 (5.65c-6/7.3v-FAU); Fri, 4 Mar 1994 12:34:08 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA26044 (5.65c-6/7.3m-FAU); Fri, 4 Mar 1994 12:34:06 +0100 -From: Frank Kardel -Message-Id: <199403041134.AA26044@faui43.informatik.uni-erlangen.de> -Subject: Re: patches for 3.3l -To: Mills@udel.edu -Date: Fri, 4 Mar 94 12:33:49 MET -In-Reply-To: <9403040253.aa16147@huey.udel.edu>; from "Mills@udel.edu" at Mar 4, 94 2:53 am -X-Mailer: ELM [version 2.3 PL11] - - -> Frank, - - -> ld: ../lib/libntp.a: warning: archive has no table of contents; add one using ranlib(1) -I didn't fiddle with lib/* this round. Thus it must be some problem -with the lib building process. Try make clean and again. I just checked -the patches with my 3.3l tree - fine. I do admit being a bit lax when -sending you the patches - you might have had to enter some paths -manually. - -> ld: Undefined symbol -> _DESauth1crypt .... -Happens if ranlib isn't run. - -> Obviously, it bombed. -Not likely being a problem from my patches - the lib/libntp.a got -inconsistent. -Usually this should not happen (ranlib need to be run on BSD systems). -Try building again from scratch (make clean all). If the problem -persists look (or send me) at the output of the lib building step -something is amiss there at your site. - -I'll include the patches here again not properly prepared for a -plain "patch < patchfile". - - -Hi, Dave, - -Here are some more patches: - - allow parse conversion routines to deliver UTC directly - - irix4 machine/cc from Amos - - rcs id fixing - - linux hints - - modload hints - - full integration of trak refclock driver (was only partially integrated) - -diff -c /dev/null compilers/irix4.cc:1.1 -*** /dev/null Thu Mar 3 10:29:50 1994 ---- compilers/irix4.cc Thu Mar 3 10:29:50 1994 -*************** -*** 0 **** ---- 1,2 ---- -+ COMPILER= cc -cckr -+ COPTS= -O2 -diff -c hints/linux:1.1.1.3 hints/linux:1.5 -*** hints/linux:1.1.1.3 Thu Mar 3 10:30:53 1994 ---- hints/linux Thu Mar 3 10:30:53 1994 -*************** -*** 1,5 **** - -! Requirements: kernel 0.99.14y or newer, libc 4.5.20 or newer - ------------ - - With this configuration, xntp should build an run right out of the box ---- 1,5 ---- - -! Requirements: kernel 0.99.14y or newer, libc 4.5.21 or newer - ------------ - - With this configuration, xntp should build an run right out of the box -*************** -*** 7,14 **** - versions of the kernel or libc, or have any other question not covered in the - READMEs / hint files (sorry, necessary comment in the Linux community ;-) feel - free to ask me (duwe@informatik.uni-erlangen.de) -- -- [NOTE: libc-4.5.20 is (or was ? ;-) a beta testing release, but the first -- binary compiled under the appropriate kernel. Get this one from -- tsx-11:.../GCC/private/dontuse , compile 4.5.19 yourself or wait for the next -- puplic relase after 4.5.20] ---- 7,9 ---- -diff -c include/parse.h:1.1.1.8 include/parse.h:3.17 -*** include/parse.h:1.1.1.8 Thu Mar 3 10:31:37 1994 ---- include/parse.h Thu Mar 3 10:31:37 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * -! * parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp - * -! * parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 15,21 **** - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp FAU"; - #endif - - #include "ntp_types.h" ---- 15,21 ---- - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp"; - #endif - - #include "ntp_types.h" -*************** -*** 301,306 **** ---- 301,307 ---- - LONG second; - LONG usecond; - LONG utcoffset; /* in seconds */ -+ time_t utctime; /* the actual time - alternative to date/time */ - LONG flags; /* current clock status */ - }; - -*************** -*** 385,390 **** ---- 386,394 ---- - * History: - * - * parse.h,v -+ * Revision 3.17 1994/03/03 09:27:20 kardel -+ * rcs ids fixed -+ * - * Revision 3.13 1994/01/25 19:04:21 kardel - * 94/01/23 reconcilation - * -diff -c parse/Makefile.kernel:1.1.1.3 parse/Makefile.kernel:3.9 -*** parse/Makefile.kernel:1.1.1.3 Thu Mar 3 10:35:48 1994 ---- parse/Makefile.kernel Thu Mar 3 10:35:48 1994 -*************** -*** 40,46 **** - rm -f parsestreams.o - - parsestreams.o: parsestreams.o.$(KARCH) -! @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o.$(KARCH)' into the kernel" - - parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c ---- 40,46 ---- - rm -f parsestreams.o - - parsestreams.o: parsestreams.o.$(KARCH) -! @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o' (put in e.g. /sys//OBJ) into the kernel" - - parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c -diff -c parse/README.new_clocks:1.1.1.3 parse/README.new_clocks:3.5 -*** parse/README.new_clocks:1.1.1.3 Thu Mar 3 10:35:52 1994 ---- parse/README.new_clocks Thu Mar 3 10:35:53 1994 -*************** -*** 23,28 **** ---- 23,29 ---- - LONG second; - LONG usecond; - LONG utcoffset; /* in seconds */ -+ time_t utcoffset; /* true utc time instead of date/time */ - LONG flags; /* current clock status */ - }; - -*************** -*** 52,57 **** ---- 53,65 ---- - PARSEB_S_PPS supports PPS time stamping - PARSEB_S_POSITION supports position information (GPS) - -+ If the utctime field is non zero this value will be take as -+ time code value. This allows for conversion routines that -+ already have the utc time value. The utctime field gives the seconds -+ since Jan 1st 1970, 0:00:00. The useconds field gives the respective -+ usec value. The fields for date and time (down to second resolution) -+ will be ignored. -+ - Conversion is done in the cvt_* routine in parse/clk_*.c files. look in - them for examples. The basic structure is: - -diff -c parse/parse.c:1.1.1.9 parse/parse.c:3.22 -*** parse/parse.c:1.1.1.9 Thu Mar 3 10:36:06 1994 ---- parse/parse.c Thu Mar 3 10:36:07 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.21 1994/02/02 17:45:30 kardel Exp - * -! * parse.c,v 3.21 1994/02/02 17:45:30 kardel Exp - * - * Parser module for reference clock - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * -! * parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * - * Parser module for reference clock - * -*************** -*** 556,561 **** ---- 556,564 ---- - register int i; - time_t t; - -+ if (clock->utctime) -+ return clock->utctime; /* if the conversion routine gets it right away - why not */ -+ - if (clock->year < 100) - clock->year += 1900; - -*************** -*** 628,633 **** ---- 631,639 ---- - t += clock->utcoffset; /* warp to UTC */ - - /* done */ -+ -+ clock->utctime = t; /* documentray only */ -+ - return t; - } - -*************** -*** 890,895 **** ---- 896,903 ---- - - if (parseio->parse_flags & PARSE_FIXED_FMT) - { -+ clock.utctime = 0; -+ - switch ((cvtrtc = clockformats[format]->convert ? clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : CVT_NONE) & CVT_MASK) - { - case CVT_FAIL: -*************** -*** 941,946 **** ---- 949,956 ---- - { - do - { -+ clock.utctime = 0; -+ - switch ((cvtrtc = (clockformats[format]->convert && !(clockformats[format]->flags & CVT_FIXEDONLY)) ? - clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : - CVT_NONE) & CVT_MASK) -*************** -*** 1148,1153 **** ---- 1158,1166 ---- - * History: - * - * parse.c,v -+ * Revision 3.22 1994/02/25 12:34:49 kardel -+ * allow for converter generated utc times -+ * - * Revision 3.21 1994/02/02 17:45:30 kardel - * rcs ids fixed - * -diff -c parse/util/testdcf.c:1.1.1.6 parse/util/testdcf.c:3.11 -*** parse/util/testdcf.c:1.1.1.6 Thu Mar 3 10:36:27 1994 ---- parse/util/testdcf.c Thu Mar 3 10:36:27 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * -! * testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp - * -! * testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * -diff -c xntpd/Makefile.tmpl:1.1.1.18 xntpd/Makefile.tmpl:3.28 -*** xntpd/Makefile.tmpl:1.1.1.18 Thu Mar 3 10:38:13 1994 ---- xntpd/Makefile.tmpl Thu Mar 3 10:38:13 1994 -*************** -*** 34,40 **** - refclock_wwvb.c refclock_goes.c refclock_mx4200.c \ - refclock_parse.c refclock_as2201.c refclock_omega.c \ - refclock_tpro.c refclock_leitch.c refclock_irig.c \ -! refclock_msfees.c refclock_gpstm.c ntp_intres.c ntp_filegen.c - - OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \ - ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \ ---- 34,41 ---- - refclock_wwvb.c refclock_goes.c refclock_mx4200.c \ - refclock_parse.c refclock_as2201.c refclock_omega.c \ - refclock_tpro.c refclock_leitch.c refclock_irig.c \ -! refclock_msfees.c refclock_gpstm.c refclock_trak.c \ -! ntp_intres.c ntp_filegen.c - - OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \ - ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \ -*************** -*** 44,50 **** - refclock_wwvb.o refclock_goes.o refclock_mx4200.o \ - refclock_parse.o refclock_as2201.o refclock_omega.o \ - refclock_tpro.o refclock_leitch.o refclock_irig.o \ -! refclock_msfees.o refclock_gpstm.o ntp_intres.o ntp_filegen.o - - all: $(PROGRAM) - ---- 45,52 ---- - refclock_wwvb.o refclock_goes.o refclock_mx4200.o \ - refclock_parse.o refclock_as2201.o refclock_omega.o \ - refclock_tpro.o refclock_leitch.o refclock_irig.o \ -! refclock_msfees.o refclock_gpstm.o refclock_trak.o \ -! ntp_intres.o ntp_filegen.o - - all: $(PROGRAM) - -*************** -*** 136,141 **** ---- 138,146 ---- - - refclock_msfees.o: refclock_msfees.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c -+ -+ refclock_trak.o: refclock_trak.c -+ $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - - refclock_gpstm.o: refclock_gpstm.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c -diff -c xntpd/ntp_control.c:1.1.1.17 xntpd/ntp_control.c:3.26 -*** xntpd/ntp_control.c:1.1.1.17 Thu Mar 3 10:38:16 1994 ---- xntpd/ntp_control.c Thu Mar 3 10:38:17 1994 -*************** -*** 301,307 **** - static u_char clocktypes[] = { - CTL_SST_TS_NTP, /* REFCLK_NONE */ - CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */ -! CTL_SST_TS_HF, /* REFCLK_WWV_HEATH */ - CTL_SST_TS_HF, /* REFCLK_WWV_PST */ - CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */ - CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */ ---- 301,307 ---- - static u_char clocktypes[] = { - CTL_SST_TS_NTP, /* REFCLK_NONE */ - CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */ -! CTL_SST_TS_HF, /* REFCLK_GPS_TRAK */ - CTL_SST_TS_HF, /* REFCLK_WWV_PST */ - CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */ - CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */ -diff -c xntpd/refclock_conf.c:1.1.1.22 xntpd/refclock_conf.c:3.21 -*** xntpd/refclock_conf.c:1.1.1.22 Thu Mar 3 10:38:54 1994 ---- xntpd/refclock_conf.c Thu Mar 3 10:38:54 1994 -*************** -*** 113,119 **** - struct refclock *refclock_conf[] = { - &refclock_none, /* 0 REFCLK_NONE */ - &refclock_local, /* 1 REFCLK_LOCAL */ -! &refclock_none, /* 2 REFCLK_WWV_HEATH */ - &refclock_pst, /* 3 REFCLK_WWV_PST */ - &refclock_wwvb, /* 4 REFCLK_WWVB_SPECTRACOM */ - &refclock_goes, /* 5 REFCLK_GOES_TRUETIME */ ---- 113,119 ---- - struct refclock *refclock_conf[] = { - &refclock_none, /* 0 REFCLK_NONE */ - &refclock_local, /* 1 REFCLK_LOCAL */ -! &refclock_trak, /* 2 REFCLK_GPS_TRAK */ - &refclock_pst, /* 3 REFCLK_WWV_PST */ - &refclock_wwvb, /* 4 REFCLK_WWVB_SPECTRACOM */ - &refclock_goes, /* 5 REFCLK_GOES_TRUETIME */ -RCS file: /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v -retrieving revision 1.1.1.12 -diff -c -r1.1.1.12 xntpd/refclock_parse.c -*** xntpd/refclock_parse.c:1.1.1.12 1994/02/22 21:57:57 ---- xntpd/refclock_parse.c 1994/03/03 09:49:54 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * -! * refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * - * generic reference clock driver for receivers - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * -! * refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * - * generic reference clock driver for receivers - * -*************** -*** 129,135 **** - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp"; - #endif - - /**=========================================================================== ---- 129,135 ---- - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp"; - #endif - - /**=========================================================================== -*************** -*** 1653,1659 **** - * done if no more characters are available - */ - FD_SET(fd, &fdmask); -! if (select(fd + 1, &fdmask, 0, 0, &null_time) == 0) - return; - } - } ---- 1653,1660 ---- - * done if no more characters are available - */ - FD_SET(fd, &fdmask); -! if ((i == 0) && -! (select(fd + 1, &fdmask, 0, 0, &null_time) == 0)) - return; - } - } -*************** -*** 2823,2829 **** - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; ---- 2824,2830 ---- - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.25 b/usr.sbin/xntpd/patches/patch.25 deleted file mode 100644 index 6ab00e2a8391..000000000000 --- a/usr.sbin/xntpd/patches/patch.25 +++ /dev/null @@ -1,474 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa16943; 4 Mar 94 6:43 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa02686; - 4 Mar 94 6:34 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA12349 (5.65c-6/7.3v-FAU); Fri, 4 Mar 1994 12:34:08 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA26044 (5.65c-6/7.3m-FAU); Fri, 4 Mar 1994 12:34:06 +0100 -From: Frank Kardel -Message-Id: <199403041134.AA26044@faui43.informatik.uni-erlangen.de> -Subject: Re: patches for 3.3l -To: Mills@udel.edu -Date: Fri, 4 Mar 94 12:33:49 MET -In-Reply-To: <9403040253.aa16147@huey.udel.edu>; from "Mills@udel.edu" at Mar 4, 94 2:53 am -X-Mailer: ELM [version 2.3 PL11] - - -> Frank, - - -> ld: ../lib/libntp.a: warning: archive has no table of contents; add one using ranlib(1) -I didn't fiddle with lib/* this round. Thus it must be some problem -with the lib building process. Try make clean and again. I just checked -the patches with my 3.3l tree - fine. I do admit being a bit lax when -sending you the patches - you might have had to enter some paths -manually. - -> ld: Undefined symbol -> _DESauth1crypt .... -Happens if ranlib isn't run. - -> Obviously, it bombed. -Not likely being a problem from my patches - the lib/libntp.a got -inconsistent. -Usually this should not happen (ranlib need to be run on BSD systems). -Try building again from scratch (make clean all). If the problem -persists look (or send me) at the output of the lib building step -something is amiss there at your site. - -I'll include the patches here again not properly prepared for a -plain "patch < patchfile". - - -Hi, Dave, - -Here are some more patches: - - allow parse conversion routines to deliver UTC directly - - irix4 machine/cc from Amos - - rcs id fixing - - linux hints - - modload hints - - full integration of trak refclock driver (was only partially integrated) - -diff -c /dev/null compilers/irix4.cc:1.1 -*** /dev/null Thu Mar 3 10:29:50 1994 ---- compilers/irix4.cc Thu Mar 3 10:29:50 1994 -*************** -*** 0 **** ---- 1,2 ---- -+ COMPILER= cc -cckr -+ COPTS= -O2 -diff -c hints/linux:1.1.1.3 hints/linux:1.5 -*** hints/linux:1.1.1.3 Thu Mar 3 10:30:53 1994 ---- hints/linux Thu Mar 3 10:30:53 1994 -*************** -*** 1,5 **** - -! Requirements: kernel 0.99.14y or newer, libc 4.5.20 or newer - ------------ - - With this configuration, xntp should build an run right out of the box ---- 1,5 ---- - -! Requirements: kernel 0.99.14y or newer, libc 4.5.21 or newer - ------------ - - With this configuration, xntp should build an run right out of the box -*************** -*** 7,14 **** - versions of the kernel or libc, or have any other question not covered in the - READMEs / hint files (sorry, necessary comment in the Linux community ;-) feel - free to ask me (duwe@informatik.uni-erlangen.de) -- -- [NOTE: libc-4.5.20 is (or was ? ;-) a beta testing release, but the first -- binary compiled under the appropriate kernel. Get this one from -- tsx-11:.../GCC/private/dontuse , compile 4.5.19 yourself or wait for the next -- puplic relase after 4.5.20] ---- 7,9 ---- -diff -c include/parse.h:1.1.1.8 include/parse.h:3.17 -*** include/parse.h:1.1.1.8 Thu Mar 3 10:31:37 1994 ---- include/parse.h Thu Mar 3 10:31:37 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * -! * parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp - * -! * parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 15,21 **** - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp FAU"; - #endif - - #include "ntp_types.h" ---- 15,21 ---- - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp"; - #endif - - #include "ntp_types.h" -*************** -*** 301,306 **** ---- 301,307 ---- - LONG second; - LONG usecond; - LONG utcoffset; /* in seconds */ -+ time_t utctime; /* the actual time - alternative to date/time */ - LONG flags; /* current clock status */ - }; - -*************** -*** 385,390 **** ---- 386,394 ---- - * History: - * - * parse.h,v -+ * Revision 3.17 1994/03/03 09:27:20 kardel -+ * rcs ids fixed -+ * - * Revision 3.13 1994/01/25 19:04:21 kardel - * 94/01/23 reconcilation - * -diff -c parse/Makefile.kernel:1.1.1.3 parse/Makefile.kernel:3.9 -*** parse/Makefile.kernel:1.1.1.3 Thu Mar 3 10:35:48 1994 ---- parse/Makefile.kernel Thu Mar 3 10:35:48 1994 -*************** -*** 40,46 **** - rm -f parsestreams.o - - parsestreams.o: parsestreams.o.$(KARCH) -! @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o.$(KARCH)' into the kernel" - - parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c ---- 40,46 ---- - rm -f parsestreams.o - - parsestreams.o: parsestreams.o.$(KARCH) -! @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o' (put in e.g. /sys//OBJ) into the kernel" - - parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c -diff -c parse/README.new_clocks:1.1.1.3 parse/README.new_clocks:3.5 -*** parse/README.new_clocks:1.1.1.3 Thu Mar 3 10:35:52 1994 ---- parse/README.new_clocks Thu Mar 3 10:35:53 1994 -*************** -*** 23,28 **** ---- 23,29 ---- - LONG second; - LONG usecond; - LONG utcoffset; /* in seconds */ -+ time_t utcoffset; /* true utc time instead of date/time */ - LONG flags; /* current clock status */ - }; - -*************** -*** 52,57 **** ---- 53,65 ---- - PARSEB_S_PPS supports PPS time stamping - PARSEB_S_POSITION supports position information (GPS) - -+ If the utctime field is non zero this value will be take as -+ time code value. This allows for conversion routines that -+ already have the utc time value. The utctime field gives the seconds -+ since Jan 1st 1970, 0:00:00. The useconds field gives the respective -+ usec value. The fields for date and time (down to second resolution) -+ will be ignored. -+ - Conversion is done in the cvt_* routine in parse/clk_*.c files. look in - them for examples. The basic structure is: - -diff -c parse/parse.c:1.1.1.9 parse/parse.c:3.22 -*** parse/parse.c:1.1.1.9 Thu Mar 3 10:36:06 1994 ---- parse/parse.c Thu Mar 3 10:36:07 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.21 1994/02/02 17:45:30 kardel Exp - * -! * parse.c,v 3.21 1994/02/02 17:45:30 kardel Exp - * - * Parser module for reference clock - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * -! * parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * - * Parser module for reference clock - * -*************** -*** 556,561 **** ---- 556,564 ---- - register int i; - time_t t; - -+ if (clock->utctime) -+ return clock->utctime; /* if the conversion routine gets it right away - why not */ -+ - if (clock->year < 100) - clock->year += 1900; - -*************** -*** 628,633 **** ---- 631,639 ---- - t += clock->utcoffset; /* warp to UTC */ - - /* done */ -+ -+ clock->utctime = t; /* documentray only */ -+ - return t; - } - -*************** -*** 890,895 **** ---- 896,903 ---- - - if (parseio->parse_flags & PARSE_FIXED_FMT) - { -+ clock.utctime = 0; -+ - switch ((cvtrtc = clockformats[format]->convert ? clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : CVT_NONE) & CVT_MASK) - { - case CVT_FAIL: -*************** -*** 941,946 **** ---- 949,956 ---- - { - do - { -+ clock.utctime = 0; -+ - switch ((cvtrtc = (clockformats[format]->convert && !(clockformats[format]->flags & CVT_FIXEDONLY)) ? - clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : - CVT_NONE) & CVT_MASK) -*************** -*** 1148,1153 **** ---- 1158,1166 ---- - * History: - * - * parse.c,v -+ * Revision 3.22 1994/02/25 12:34:49 kardel -+ * allow for converter generated utc times -+ * - * Revision 3.21 1994/02/02 17:45:30 kardel - * rcs ids fixed - * -diff -c parse/util/testdcf.c:1.1.1.6 parse/util/testdcf.c:3.11 -*** parse/util/testdcf.c:1.1.1.6 Thu Mar 3 10:36:27 1994 ---- parse/util/testdcf.c Thu Mar 3 10:36:27 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * -! * testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp - * -! * testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * -diff -c xntpd/Makefile.tmpl:1.1.1.18 xntpd/Makefile.tmpl:3.28 -*** xntpd/Makefile.tmpl:1.1.1.18 Thu Mar 3 10:38:13 1994 ---- xntpd/Makefile.tmpl Thu Mar 3 10:38:13 1994 -*************** -*** 34,40 **** - refclock_wwvb.c refclock_goes.c refclock_mx4200.c \ - refclock_parse.c refclock_as2201.c refclock_omega.c \ - refclock_tpro.c refclock_leitch.c refclock_irig.c \ -! refclock_msfees.c refclock_gpstm.c ntp_intres.c ntp_filegen.c - - OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \ - ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \ ---- 34,41 ---- - refclock_wwvb.c refclock_goes.c refclock_mx4200.c \ - refclock_parse.c refclock_as2201.c refclock_omega.c \ - refclock_tpro.c refclock_leitch.c refclock_irig.c \ -! refclock_msfees.c refclock_gpstm.c refclock_trak.c \ -! ntp_intres.c ntp_filegen.c - - OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \ - ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \ -*************** -*** 44,50 **** - refclock_wwvb.o refclock_goes.o refclock_mx4200.o \ - refclock_parse.o refclock_as2201.o refclock_omega.o \ - refclock_tpro.o refclock_leitch.o refclock_irig.o \ -! refclock_msfees.o refclock_gpstm.o ntp_intres.o ntp_filegen.o - - all: $(PROGRAM) - ---- 45,52 ---- - refclock_wwvb.o refclock_goes.o refclock_mx4200.o \ - refclock_parse.o refclock_as2201.o refclock_omega.o \ - refclock_tpro.o refclock_leitch.o refclock_irig.o \ -! refclock_msfees.o refclock_gpstm.o refclock_trak.o \ -! ntp_intres.o ntp_filegen.o - - all: $(PROGRAM) - -*************** -*** 136,141 **** ---- 138,146 ---- - - refclock_msfees.o: refclock_msfees.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c -+ -+ refclock_trak.o: refclock_trak.c -+ $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - - refclock_gpstm.o: refclock_gpstm.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c -diff -c xntpd/ntp_control.c:1.1.1.17 xntpd/ntp_control.c:3.26 -*** xntpd/ntp_control.c:1.1.1.17 Thu Mar 3 10:38:16 1994 ---- xntpd/ntp_control.c Thu Mar 3 10:38:17 1994 -*************** -*** 301,307 **** - static u_char clocktypes[] = { - CTL_SST_TS_NTP, /* REFCLK_NONE */ - CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */ -! CTL_SST_TS_HF, /* REFCLK_WWV_HEATH */ - CTL_SST_TS_HF, /* REFCLK_WWV_PST */ - CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */ - CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */ ---- 301,307 ---- - static u_char clocktypes[] = { - CTL_SST_TS_NTP, /* REFCLK_NONE */ - CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */ -! CTL_SST_TS_HF, /* REFCLK_GPS_TRAK */ - CTL_SST_TS_HF, /* REFCLK_WWV_PST */ - CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */ - CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */ -diff -c xntpd/refclock_conf.c:1.1.1.22 xntpd/refclock_conf.c:3.21 -*** xntpd/refclock_conf.c:1.1.1.22 Thu Mar 3 10:38:54 1994 ---- xntpd/refclock_conf.c Thu Mar 3 10:38:54 1994 -*************** -*** 113,119 **** - struct refclock *refclock_conf[] = { - &refclock_none, /* 0 REFCLK_NONE */ - &refclock_local, /* 1 REFCLK_LOCAL */ -! &refclock_none, /* 2 REFCLK_WWV_HEATH */ - &refclock_pst, /* 3 REFCLK_WWV_PST */ - &refclock_wwvb, /* 4 REFCLK_WWVB_SPECTRACOM */ - &refclock_goes, /* 5 REFCLK_GOES_TRUETIME */ ---- 113,119 ---- - struct refclock *refclock_conf[] = { - &refclock_none, /* 0 REFCLK_NONE */ - &refclock_local, /* 1 REFCLK_LOCAL */ -! &refclock_trak, /* 2 REFCLK_GPS_TRAK */ - &refclock_pst, /* 3 REFCLK_WWV_PST */ - &refclock_wwvb, /* 4 REFCLK_WWVB_SPECTRACOM */ - &refclock_goes, /* 5 REFCLK_GOES_TRUETIME */ -RCS file: /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v -retrieving revision 1.1.1.12 -diff -c -r1.1.1.12 xntpd/refclock_parse.c -*** xntpd/refclock_parse.c:1.1.1.12 1994/02/22 21:57:57 ---- xntpd/refclock_parse.c 1994/03/03 09:49:54 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * -! * refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp - * - * generic reference clock driver for receivers - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * -! * refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * - * generic reference clock driver for receivers - * -*************** -*** 129,135 **** - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp"; - #endif - - /**=========================================================================== ---- 129,135 ---- - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp"; - #endif - - /**=========================================================================== -*************** -*** 1653,1659 **** - * done if no more characters are available - */ - FD_SET(fd, &fdmask); -! if (select(fd + 1, &fdmask, 0, 0, &null_time) == 0) - return; - } - } ---- 1653,1660 ---- - * done if no more characters are available - */ - FD_SET(fd, &fdmask); -! if ((i == 0) && -! (select(fd + 1, &fdmask, 0, 0, &null_time) == 0)) - return; - } - } -*************** -*** 2823,2829 **** - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.49 1994/02/20 13:26:00 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; ---- 2824,2830 ---- - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.26 b/usr.sbin/xntpd/patches/patch.26 deleted file mode 100644 index a55360dbd623..000000000000 --- a/usr.sbin/xntpd/patches/patch.26 +++ /dev/null @@ -1,36 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa24501; 5 Mar 94 21:23 EST -Received: from goofus.wustl.edu by louie.udel.edu id aa01087; 5 Mar 94 21:15 EST -Received: from mumps.pfcs.com by goofus.wustl.edu with UUCP id AA17154 - (5.67a+/IDA-1.5 for mills@udel.edu); Sat, 5 Mar 1994 20:15:06 -0600 -Received: by mumps.pfcs.com id AA09821 - (5.65c/IDA-1.4.4 for mills@udel.edu); Sat, 5 Mar 1994 19:10:18 -0600 -Date: Sat, 5 Mar 1994 19:10:18 -0600 -From: Harlan Stenn -Message-Id: <199403060110.AA09821@mumps.pfcs.com> -To: mills@udel.edu -Subject: xntpd/Makefile and 3.3l - -Dave, - -xntpd/Makefile doesn't get -DSYS_whatever and -DHAVE_xxx_TTYS "installed" -when the Makefile gets created. This is for OS=mips. - -Same for xntpdc/Makefile. - -A patch follows... - -Harlan - -PS - might you have a copy of the message I sent you a couple of weeks -ago where I asked about broadcast servers and clients and the ntp.conf -file? I was going to send it to the maling list but I lost my copy. - -machines/mips -3,4c3,4 -< DEFS= -< AUTHDEFS= -DDES -DMD5 -DSYS_MIPS -DHAVE_BSD_TTYS ---- -> DEFS= -DSYS_MIPS -DHAVE_BSD_TTYS -> AUTHDEFS= -DDES -DMD5 - diff --git a/usr.sbin/xntpd/patches/patch.27 b/usr.sbin/xntpd/patches/patch.27 deleted file mode 100644 index 5d450d44f934..000000000000 --- a/usr.sbin/xntpd/patches/patch.27 +++ /dev/null @@ -1,86 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa23654; 11 Mar 94 7:49 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa14038; - 10 Mar 94 14:14 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA13885 (5.65c-6/7.3v-FAU); Thu, 10 Mar 1994 20:10:36 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA03872 (5.65c-6/7.3m-FAU); Thu, 10 Mar 1994 20:10:33 +0100 -From: Frank Kardel -Message-Id: <199403101910.AA03872@faui43.informatik.uni-erlangen.de> -Subject: RAW dcf77 showstopper 8-(. -To: mills@udel.edu -Date: Thu, 10 Mar 94 20:10:25 MET -Cc: dpk@morgan.com, Frank.Kardel@informatik.uni-erlangen.de, - Piete.Brooks@cl.cam.ac.uk, jcs@bear.zoo.bt.co.uk -X-Mailer: ELM [version 2.3 PL11] - -Hi, my changes for 3.3m introduced a subtle reliability problem for -the cheap DCF77 receiver code - it only returned somtimes the -correct time 8-(. - -Well, here is the patch. (I'll post this one to the news group -also as it is a show stopper for the cheap clocks 8-(). So -don't be confused. - - -RCS file: /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v -retrieving revision 3.12 -diff -c -r3.12 clk_rawdcf.c -*** parse/clk_rawdcf.c:3.12 1994/02/20 13:04:39 ---- parse/clk_rawdcf.c 1994/03/10 19:00:43 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.12 1994/02/20 13:04:39 kardel Exp - * -! * clk_rawdcf.c,v 3.12 1994/02/20 13:04:39 kardel Exp - * - * Raw DCF77 pulse clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp - * -! * clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp - * - * Raw DCF77 pulse clock support - * -*************** -*** 245,250 **** ---- 245,251 ---- - parseprintf(DD_RAWDCF,("parse: convert_rawdcf: parity check passed\n")); - - clock->flags = PARSEB_S_ANTENNA|PARSEB_S_LEAP; -+ clock->utctime= 0; - clock->usecond= 0; - clock->second = 0; - clock->minute = ext_bf(buffer, DCF_M10, dcfparam->zerobits); -*************** -*** 528,534 **** - /* - * History: - * -! * clk_rawdcf.c,v - * Revision 3.12 1994/02/20 13:04:39 kardel - * parse add/delete second support - * ---- 529,538 ---- - /* - * History: - * -! * clk_rawdcf.c,v -! * Revision 3.13 1994/03/10 19:00:43 kardel -! * clear utctime field to avoid confusion on synthesize time stamps -! * - * Revision 3.12 1994/02/20 13:04:39 kardel - * parse add/delete second support - * - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.28 b/usr.sbin/xntpd/patches/patch.28 deleted file mode 100644 index 37e2065d2edd..000000000000 --- a/usr.sbin/xntpd/patches/patch.28 +++ /dev/null @@ -1,454 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa07183; 13 Mar 94 23:57 EST -Received: from hpsdlo.sdd.hp.com by louie.udel.edu id aa17483; - 13 Mar 94 23:50 EST -Received: from hpsdlz.sdd.hp.com by hpsdlo.sdd.hp.com with SMTP - (1.36.108.4/15.5+IOS 3.21+sdd) id AA07032; Sun, 13 Mar 1994 20:50:23 -0800 -Received: from localhost by hpsdlz.sdd.hp.com with SMTP - (1.36.108.4/15.5+IOS 3.21+sdd) id AA05726; Sun, 13 Mar 1994 20:50:21 -0800 -Message-Id: <9403140450.AA05726@hpsdlz.sdd.hp.com> -To: mills@udel.edu -Subject: patches for xntpd -Date: Sun, 13 Mar 1994 20:50:21 -0800 -From: Ken Stone - - -Ok Dave, - -I guess I'll take a poke at the "m" version for cleanup and updates. This -should take care of the newly released 9.03 for s300/s400 which has the -adjtime(2) syscall. Also, cleanup in readiness for 10.0 all around. - - -- Ken - -P.S. How is your HP hardware/software deal going ? I haven't heard anything - lately. - - - -First do a "rm */hpux10+*" as I have renamed all that to hpux-adj ... that -9.03 blew me out of the water on the naming scheme :-) - -Then unshar the following ... it will add a few new files and give you -diff to apply (diffs.hpux). - - -#---------------------------------- cut here ---------------------------------- -# This is a shell archive. Remove anything before this line, -# then unpack it by saving it in a file and typing "sh file". -# -# Wrapped by Source Hacker on Sun Mar 13 20:47:57 1994 -# -# This archive contains: -# compilers/hpux-adj.cc compilers/hpux-adj.gcc -# machines/hpux-adj scripts/hpadjtime.sh -# diffs.hpux -# -# Error checking via wc(1) will be performed. -# Error checking via sum(1) will be performed. - -LANG=""; export LANG -PATH=/bin:/usr/bin:$PATH; export PATH - -if sum -r /dev/null 2>&1 -then - sumopt='-r' -else - sumopt='' -fi - -echo x - compilers/hpux-adj.cc -cat >compilers/hpux-adj.cc <<'@EOF' -COMPILER=cc +O1 -@EOF -set `sum $sumopt compilers/hpux-adj.gcc <<'@EOF' -COMPILER=gcc -O2 -@EOF -set `sum $sumopt machines/hpux-adj <<'@EOF' -SHELL= /bin/sh -RANLIB= ls # ar does the work of ranlib under System V -DEFS_LOCAL= -DREFCLOCK -DEFS= -DHAVE_TERMIOS -DSYS_HPUX=10 -AUTHDEFS= -DDES -DMD5 -CLOCKDEFS= -DLOCAL_CLOCK -COPTS= -INSTALL=$(TOP)scripts/install.sh -@EOF -set `sum $sumopt scripts/hpadjtime.sh <<'@EOF' -#! /bin/sh - -if [ -f /bin/uname -o -f /usr/bin/uname ]; then - set `uname -a | tr '[A-Z]' '[a-z]'` - case "$1" in - hp-ux) case "$3" in - *.10.*) val=1 ;; - *.09.03) case "$5" in - 9000/3*) val=1 ;; - *) val=0 ;; - esac ;; - *) val=0 ;; - esac - ;; - *) - esac -fi -exit $val -@EOF -set `sum $sumopt diffs.hpux <<'@EOF' -*** xntp3.3m.orig/compilers/hpux.cc Thu Sep 2 13:19:56 1993 ---- xntp3.3m/compilers/hpux.cc Sun Mar 13 12:10:23 1994 -*************** -*** 1,2 **** -! COMPILER=cc -! COPTS=+O1 ---- 1 ---- -! COMPILER=cc +O1 -*** xntp3.3m.orig/compilers/hpux.gcc Thu Sep 2 13:19:59 1993 ---- xntp3.3m/compilers/hpux.gcc Sun Mar 13 12:10:29 1994 -*************** -*** 1,2 **** -! COMPILER=gcc -! COPTS=-O2 ---- 1 ---- -! COMPILER=gcc -O2 -*** xntp3.3m.orig/hints/hpux Fri Dec 3 02:28:57 1993 ---- xntp3.3m/hints/hpux Sun Mar 13 20:20:38 1994 -*************** -*** 1,59 **** - This file hopefully describes the whatever and however of how to get xntp -! running on hpux 8.0 and later s300, s700, and s800. - - First off, all the standard disclaimers hold here ... HP doesn't have anthing - to do with this stuff. I fool with it in my spare time because we use it and - because I like to. We just happen to have a lot of HP machines around here :-) -! Xntp has been in use here for several months and has a fair amount of mileage - on various HP platforms within the company. I can't really guarantee bug fixes - but I'd certainly like to hear about bugs and I won't hestitate to look at - any fixes sent to me. - -! Now lets talk OS. If you don't have 8.0 or later, pretty much hang it up now. -! This stuff has run here on 8.0 s300, s700, and s800. Its possible that it -! runs on 7.0 but I have not tried v3 code on 7.0 at all. - -! [Note that recent reports state that this release does in fact run on HP -! 300 and 400 boxes, which run 7.0 - Ed.] - -! Next, let me explain a bit about how this stuff works on HP-UX since we don't - have adjtime(2). The directory adjtime contains libadjtime.a and the adjtimed - daemon. Instead of the adjtime(2) system call, we use a library routine to - talk to adjtimed thru message queues. Adjtimed munges into /dev/kmem and - causes the clock to skew properly as needed. PLEASE NOTE that the adjtime - code provided here is NOT a general replacement for adjtime(2) ... use of -! this adjtime(3)/adjtimed(8) other than here may yield very odd results. - - What to do to get this stuff running ? - -! * cd .. -! * Say "make makeconfig" - -! * cd .. -! * Say "make", sit back for a few minutes. - - * cd authstuff - * Say "./authcert < certdata" and check the output. Every line should - end with "OK" ... if not, we got trouble. - * Now try "./authspeed auth.samplekeys". What we want to - remember here is the "authentication delay in CPU time" - -! * cd .. -! * Now we need to install this stuff ... make install will not work -! unless you have replaced the SYSV install command with a BSD -! compatible version. So ... the simplest thing to do is run -! make -n install and do manually what it would have done. - - * I'd suggest reading the xntp docs about now :-) ... seriously !! - -! * Check out the docs and the stuff in xntp/conf and build a config -! file ... put it in /usr/local/etc/xntp.conf (or where ever you -! defined the config file to be in Config). One thing we have -! added to this version of xntpd is a way to select config files -! if you are sharing /usr/local thru NFS or whatever. If the -! file /usr/local/etc/xntp.conf happens to be a directory, the files -! in that directory are searched until a match is found. The rules -! for a match are: - - 1. Our hostname - 2. default. (as in default.375 or default.850) ---- 1,63 ---- -+ Last update: Sun Mar 13 15:05:31 PST 1994 -+ - This file hopefully describes the whatever and however of how to get xntp -! running on hpux 7.0 and later s300. s400, s700, and s800. - - First off, all the standard disclaimers hold here ... HP doesn't have anthing - to do with this stuff. I fool with it in my spare time because we use it and - because I like to. We just happen to have a lot of HP machines around here :-) -! Xntpd has been in use here for several years and has a fair amount of mileage - on various HP platforms within the company. I can't really guarantee bug fixes - but I'd certainly like to hear about bugs and I won't hestitate to look at - any fixes sent to me. - -! Now lets talk OS. If you don't have 7.0 or later, pretty much hang it up now. -! This stuff has run here on pretty much everything from 8.0 upward on s300, -! s700, and s800. It is known to run on 7.0 s300/s400 but all reports are -! from the field and not my personal experience. - -! If you are lucky enough to have a s300 or s400 with 9.03, then you no longer -! have to worry about adjtimed as HP-UX now has adjtime(2). The rest of you -! will have to wait on 10.0 which will have adjtime(2) and a supported though -! a bit older version of xntpd. - -! Next, let me explain a bit about how this stuff works on HP-UX's that do not - have adjtime(2). The directory adjtime contains libadjtime.a and the adjtimed - daemon. Instead of the adjtime(2) system call, we use a library routine to - talk to adjtimed thru message queues. Adjtimed munges into /dev/kmem and - causes the clock to skew properly as needed. PLEASE NOTE that the adjtime - code provided here is NOT a general replacement for adjtime(2) ... use of -! this adjtime(3)/adjtimed(8) other than with xntpd may yield very odd results. - - What to do to get this stuff running ? - -! * If you are running an OS less than 10.0 or do not have a s300/s400 -! with 9.03 or better -! -> cd machines -! -> vi hpux -! -> (change -DSYS_HPUX=? to match whatever you are running [7,8,9]) -! -> cd .. - -! * Say "make makeconfig" - -+ * Say "make", sit back for a few minutes. -+ - * cd authstuff - * Say "./authcert < certdata" and check the output. Every line should - end with "OK" ... if not, we got trouble. - * Now try "./authspeed auth.samplekeys". What we want to - remember here is the "authentication delay in CPU time" -+ * cd .. - -! * Say "make install" - - * I'd suggest reading the xntp docs about now :-) ... seriously !! - -! * One thing I have added to this version of xntpd is a way to select -! config files if you are sharing /usr/local thru NFS or whatever. -! If the file /usr/local/etc/xntp.conf happens to be a directory, the -! files in that directory are searched until a match is found. The -! rules for a match are: - - 1. Our hostname - 2. default. (as in default.375 or default.850) -*************** -*** 72,76 **** ---- 76,92 ---- - - * On some 320's and 835's we have had to run adjtimed with "-p 45" or - so to get rid of syslog messages about "last adjust did not finish". -+ -+ * At 9.0, there is a problem with DIAGMON (patch available from the -+ response center) which causes it to delete the message queue that -+ adjtimed/xntpd use to communicate. (see next note for result) -+ -+ * Xntpd has been known to get really ticked off when adjtime() fails -+ which is usually only while running the emulation code on HP-UX. -+ When it gets mad, it usually jumps the clock into never never land. -+ Possible reasons for this are adjtimed being killed or just never -+ started or adjtimed being completely swapped out on a really busy -+ machine (newer adjtimed try to lock themselves in memory to prevent -+ this one). - - Anything else ... just drop me a line at ken@sdd.hp.com -*** xntp3.3m.orig/include/ntp_machine.h Sun Feb 27 19:34:59 1994 ---- xntp3.3m/include/ntp_machine.h Sun Mar 13 15:35:33 1994 -*************** -*** 334,341 **** - #define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0) - #define NO_SIGNED_CHAR_DECL - #define LOCK_PROCESS -- #define HAVE_NO_NICE /* HPUX uses rtprio instead */ - #define RETSIGTYPE void - #if (SYS_HPUX < 10) - #define NOKMEM - #else ---- 334,345 ---- - #define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0) - #define NO_SIGNED_CHAR_DECL - #define LOCK_PROCESS - #define RETSIGTYPE void -+ #if (SYS_HPUX < 9) -+ #define HAVE_NO_NICE /* HPUX uses rtprio instead */ -+ #else -+ #define HAVE_BSD_NICE /* new at 9.X */ -+ #endif - #if (SYS_HPUX < 10) - #define NOKMEM - #else -*** xntp3.3m.orig/lib/Makefile.tmpl Wed Feb 2 21:20:13 1994 ---- xntp3.3m/lib/Makefile.tmpl Sun Mar 13 16:27:50 1994 -*************** -*** 49,55 **** - $(LIBNAME).a: $(OBJS) - ar rv $@ $? - -rm -f $? -! @if ( hp-pa || hp-mc680x0 ) > /dev/null 2>&1; then \ - ( cd ../adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" ) && ar rv $@ ../adjtime/adjtime.o; \ - else \ - :; \ ---- 49,55 ---- - $(LIBNAME).a: $(OBJS) - ar rv $@ $? - -rm -f $? -! @if ( ../scripts/hpadjtime.sh ) > /dev/null 2>&1; then \ - ( cd ../adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" ) && ar rv $@ ../adjtime/adjtime.o; \ - else \ - :; \ -*** xntp3.3m.orig/scripts/Guess.sh Wed Jan 26 15:26:03 1994 ---- xntp3.3m/scripts/Guess.sh Sun Mar 13 14:10:19 1994 -*************** -*** 40,46 **** - guess="ultrix" - ;; - hp-ux) case "$3" in -! *.10.*) guess="hpux10+" ;; - *) guess="hpux" ;; - esac - ;; ---- 40,50 ---- - guess="ultrix" - ;; - hp-ux) case "$3" in -! *.10.*) guess="hpux-adj" ;; -! *.09.03) case "$5" in -! 9000/3*) guess="hpux-adj" ;; -! *) guess="hpux" ;; -! esac ;; - *) guess="hpux" ;; - esac - ;; -*** xntp3.3m.orig/util/tickadj.c Wed Feb 2 21:20:17 1994 ---- xntp3.3m/util/tickadj.c Sun Mar 13 13:55:53 1994 -*************** -*** 388,393 **** ---- 388,409 ---- - #endif - #endif - -+ #if defined(SYS_HPUX) -+ #define X_TICKADJ 0 -+ #define X_TICK 1 -+ #define X_DEF -+ static struct nlist nl[] = -+ #ifdef hp9000s300 -+ { {"_tickadj"}, -+ {"_old_tick"}, -+ #else -+ { {"tickadj"}, -+ {"old_tick"}, -+ #endif -+ {""}, -+ }; -+ #endif -+ - #if !defined(X_DEF) - #define X_TICKADJ 0 - #define X_TICK 1 -*************** -*** 408,413 **** ---- 424,430 ---- - "/kernel/unix", - "/386bsd", - "/netbsd", -+ "/hp-ux", - NULL - }; - struct stat stbuf; -*** xntp3.3m.orig/xntpd/ntp_loopfilter.c Sun Feb 27 19:36:16 1994 ---- xntp3.3m/xntpd/ntp_loopfilter.c Sun Mar 13 14:03:54 1994 -*************** -*** 349,356 **** - } - } - #endif /* HAVE_BSD_TTYS */ -- fdpps = fd232; - #endif /* HPUXGADGET */ - - /* - * Insert in device list. ---- 349,356 ---- - } - } - #endif /* HAVE_BSD_TTYS */ - #endif /* HPUXGADGET */ -+ fdpps = fd232; - - /* - * Insert in device list. -@EOF -set `sum $sumopt -Message-Id: <199403162257.AA18230@faui43.informatik.uni-erlangen.de> -Subject: hpadjtime.sh -To: mills@udel.edu, ken@sdd.hp.com -Date: Wed, 16 Mar 94 23:57:32 MET -Return-Receipt-To: "Frank Kardel" -X-Mailer: ELM [version 2.3 PL11] - -Hi, 3.3n is somewhat broken... - -First of all - - scripts/hpadjtime.sh is missing (it's in patch.28) - -And - - scripts/hpadjtime.sh is broken for non hp-ux - (will try to build adjtime libs on non hp-ux architectures - as a default value was no set) - -Please use this version of scripts/hpadjtime.sh for increased safety: - -#! /bin/sh -val=1 -if [ -f /bin/uname -o -f /usr/bin/uname ]; then - set `uname -a | tr '[A-Z]' '[a-z]'` - case "$1" in - hp-ux) case "$3" in - *.10.*) val=1 ;; - *.09.03) case "$5" in - 9000/3*) val=1 ;; - *) val=0 ;; - esac ;; - *) val=0 ;; - esac - ;; - *) - esac -fi -exit $val - --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.3 b/usr.sbin/xntpd/patches/patch.3 deleted file mode 100644 index beba805e39d9..000000000000 --- a/usr.sbin/xntpd/patches/patch.3 +++ /dev/null @@ -1,3032 +0,0 @@ -diff -c TODO:1.1.1.3 TODO:3.5 -*** TODO:1.1.1.3 Wed Jan 26 21:46:47 1994 ---- TODO Wed Jan 26 21:46:48 1994 -*************** -*** 1,5 **** - # -! # TODO,v 3.4 1994/01/23 17:19:06 kardel Exp - # - This file contains problems known to the authors that still need to be done. - We would appreciate if you could spare some of your time to look through ---- 1,5 ---- - # -! # TODO,v 3.5 1994/01/25 19:03:55 kardel Exp - # - This file contains problems known to the authors that still need to be done. - We would appreciate if you could spare some of your time to look through -diff -c doc/xntpd.8:1.1.1.11 doc/xntpd.8:3.21 -*** doc/xntpd.8:1.1.1.11 Wed Jan 26 21:47:54 1994 ---- doc/xntpd.8 Wed Jan 26 21:47:55 1994 -*************** -*** 74,79 **** ---- 74,85 ---- - ] [ - .B -t - .I trustedkey -+ ] [ -+ .B -v -+ .I variable -+ ] [ -+ .B -V -+ .I variable - ] - .SH DESCRIPTION - .I Xntpd -*************** -*** 140,145 **** ---- 146,155 ---- - specify a directory to be used for creating statistics files - .Ip -t 8 - add a key number to the trusted key list -+ .Ip -v 8 -+ add a system variable -+ .Ip -V 8 -+ add a system variable listed by default - .SH "CONFIGURATION FILE OPTIONS" - .IR Xntpd 's - configuration file is relatively free format. Comments, which may be -*************** -*** 494,499 **** ---- 504,534 ---- - This command is obsolete and not available in this version of - .I xntpd. - .PP -+ .B setvar -+ .I variable -+ .I [default] -+ .PP -+ This command adds an additional system variable. These variables can be -+ used to distribute additional information such as the access policy. If -+ the variable of the from = is followed by the -+ .I default -+ keyword the variable will be listed as part of the default system -+ variables (ntpq rv command). These additional variables serve informational -+ purposes only. They are not related to the protocol other that they can be -+ listed. The known protocol variables will always overide any variables defined -+ via the -+ .I setvar -+ mechanism. -+ .PP -+ There are three special variables that contain the names of all variable of -+ the same group. The -+ .I sys_var_list -+ holds the names of all system variables. The -+ .I peer_var_list -+ holds the names of all peer variables and the -+ .I clock_var_list -+ hold the names of the reference clock variables. -+ .PP - .B resolver - .I /path/xntpres - .PP -*************** -*** 1093,1101 **** - time. - On the availability of PPS information the - .I time2 -! fudge factor show the difference betwteen the PPS time stamp and the reception -! time stamp of the serial signal. This parameter is read only attempts to -! set this parameter will be ignored. - The - .I flag0 - enables input filtering. This a median filter with continuous sampling. The ---- 1128,1140 ---- - time. - On the availability of PPS information the - .I time2 -! fudge factor defines the skew between the PPS time stamp and the reception -! time stamp of the PPS signal. This parameter is usually 0 as usually -! the PPS signal is believed in time and OS delays should be corrected -! in the machine specific section of the kernel driver. -! .I time2 -! needs only be set when the actial PPS signal is delayed for some -! reason. - The - .I flag0 - enables input filtering. This a median filter with continuous sampling. The -*************** -*** 1109,1121 **** - .I ntpq - timecode variable - .PP -! The timecode variable in the ntpq read clock variable command contains several -! fields. The first field is the local time in Unix format. The second field is -! the offset to UTC (format HHMM). The currently active receiver flags are listed -! next. Additional feature flags of the receiver are optionally listed in paranthesis. -! The actual time code is enclosed in angle brackets < >. A qualification of the -! decoded time code format is following the time code. The last piece of information -! is the overall running time and the accumulated times for the clock event states. - .PP - Unit encoding - .PP ---- 1148,1172 ---- - .I ntpq - timecode variable - .PP -! The ntpq read clock variables command list several variables. These -! hold followinf information: -! .I refclock_time -! is the local time with the offset to UTC (format HHMM). -! The currently active receiver flags are listed in -! .I refclock_status. -! Additional feature flags of the receiver are optionally listed in paranthesis. -! The actual time code is listed in -! .I timecode. -! A qualification of the decoded time code format is following in -! .I refclock_format. -! The last piece of information is the overall running time and the accumulated -! times for the clock event states in -! .I refclock_states. -! When PPS information is present additional variable are available. -! .I refclock_ppstime -! lists then the PPS timestamp and -! .I refclock_ppsskew -! lists the difference between RS232 derived timestamp and the PPS timestamp. - .PP - Unit encoding - .PP -diff -c include/ntp_control.h:1.1.1.5 include/ntp_control.h:3.6 -*** include/ntp_control.h:1.1.1.5 Wed Jan 26 21:48:21 1994 ---- include/ntp_control.h Wed Jan 26 21:48:21 1994 -*************** -*** 163,171 **** - #define CS_SYSTEM 17 - #define CS_KEYID 18 - #define CS_REFSKEW 19 -! #define CS_VERSION 20 - -! #define CS_MAXCODE CS_VERSION - - /* - * Peer variables we understand ---- 163,171 ---- - #define CS_SYSTEM 17 - #define CS_KEYID 18 - #define CS_REFSKEW 19 -! #define CS_VARLIST 20 - -! #define CS_MAXCODE CS_VARLIST - - /* - * Peer variables we understand -*************** -*** 204,212 **** - #define CP_SENT 32 - #define CP_FILTERROR 33 - #define CP_FLASH 34 -! #define CP_DISP 35 -! #define CP_MAXCODE CP_DISP - - /* - * Clock variables we understand - */ ---- 204,213 ---- - #define CP_SENT 32 - #define CP_FILTERROR 33 - #define CP_FLASH 34 -! #define CP_VARLIST 35 - -+ #define CP_MAXCODE CP_VARLIST -+ - /* - * Clock variables we understand - */ -*************** -*** 222,229 **** - #define CC_FUDGEVAL2 10 - #define CC_FLAGS 11 - #define CC_DEVICE 12 - -! #define CC_MAXCODE CC_DEVICE - - /* - * Definition of the structure used internally to hold trap information. ---- 223,231 ---- - #define CC_FUDGEVAL2 10 - #define CC_FLAGS 11 - #define CC_DEVICE 12 -+ #define CC_VARLIST 13 - -! #define CC_MAXCODE CC_VARLIST - - /* - * Definition of the structure used internally to hold trap information. -diff -c include/ntp_filegen.h:1.1.1.3 include/ntp_filegen.h:3.7 -*** include/ntp_filegen.h:1.1.1.3 Wed Jan 26 21:48:22 1994 ---- include/ntp_filegen.h Wed Jan 26 21:48:22 1994 -*************** -*** 1,5 **** - /* -! * ntp_filegen.h,v 3.6 1993/09/01 21:51:24 kardel Exp - * - * definitions for NTP file generations support - * ---- 1,5 ---- - /* -! * ntp_filegen.h,v 3.7 1994/01/25 19:04:16 kardel Exp - * - * definitions for NTP file generations support - * -diff -c include/ntp_machine.h:1.1.1.9 include/ntp_machine.h:1.24 -*** include/ntp_machine.h:1.1.1.9 Wed Jan 26 21:48:27 1994 ---- include/ntp_machine.h Wed Jan 26 21:48:27 1994 -*************** -*** 123,134 **** - - HAVE_UNISTD_H - Maybe should be part of NTP_POSIX_SOURCE ? - - You could just put the defines on the DEFS line in machines/ file. - I don't since there are lost of different types compiler that a systemm might - have, some that can do proto typing and others that cannot on the saem system. - I get a chanse to twiddle some of the configuration paramasters at compile - time based on compler/machine combinatsions by using this include file. -! See convex, aix and sun configurations see how complex it get. - - */ - ---- 123,138 ---- - - HAVE_UNISTD_H - Maybe should be part of NTP_POSIX_SOURCE ? - -+ DEFINITIONS FOR SYSTEM && PROCESSOR -+ STR_SYSTEM - value of system variable -+ STR_PROCESSOR - value of processor variable -+ - You could just put the defines on the DEFS line in machines/ file. - I don't since there are lost of different types compiler that a systemm might - have, some that can do proto typing and others that cannot on the saem system. - I get a chanse to twiddle some of the configuration paramasters at compile - time based on compler/machine combinatsions by using this include file. -! See convex, aix and sun configurations see how complex it gets. - - */ - -*************** -*** 152,157 **** ---- 156,164 ---- - #endif - #endif /*_BSD */ - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/AIX" -+ #endif - #endif /* RS6000 */ - - /* -*************** -*** 166,171 **** ---- 173,181 ---- - #define RETSIGTYPE void - #define NTP_SYSCALL_GET 132 - #define NTP_SYSCALL_ADJ 147 -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/SunOS 4.x" -+ #endif - #endif - - /* -*************** -*** 182,188 **** ---- 192,201 ---- - #define NTP_POSIX_SOURCE - #define HAVE_ATT_SETPGRP - #define HAVE_ATT_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/SINIX-M" - #endif -+ #endif - - /* - * SunOS 5.1 or SunOS 5.2 or Solaris 2.1 or Solaris 2.2 -*************** -*** 198,203 **** ---- 211,219 ---- - #define HAVE_ATT_SETPGRP - #define HAVE_ATT_NICE - #define UDP_WILDCARD_DELIVERY -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Solaris 2.x" -+ #endif - #endif - - /* -*************** -*** 221,227 **** ---- 237,246 ---- - #define NTP_POSIX_SOURCE - #define HAVE_ATT_SETPGRP - #endif -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/ConvexOS" - #endif -+ #endif - - /* - * IRIX 4.X and IRIX 5.x -*************** -*** 235,240 **** ---- 254,262 ---- - #define HAVE_ATT_SETPGRP - #define HAVE_BSD_NICE - #define NTP_POSIX_SOURCE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/IRIX" -+ #endif - #endif - - /* -*************** -*** 247,253 **** ---- 269,278 ---- - #define HAVE_BSD_NICE - #define RETSIGTYPE void - #define NTP_SYSCALLS_STD -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Ultrix" - #endif -+ #endif - - /* - * AUX -*************** -*** 272,277 **** ---- 297,305 ---- - #define HAVE_BSD_TTYS - #define LOG_NTP LOG_LOCAL1 - #define HAVE_SIGNALED_IO -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/AUX" -+ #endif - #endif - - /* -*************** -*** 283,289 **** ---- 311,320 ---- - #define HAVE_BSD_NICE - #define HAVE_N_UN - #undef NTP_POSIX_SOURCE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Next" - #endif -+ #endif - - /* - * HPUX -*************** -*** 301,306 **** ---- 332,340 ---- - #else - #define HAVE_READKMEM - #endif -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/HPUX" -+ #endif - #endif - - /* -*************** -*** 311,316 **** ---- 345,353 ---- - #define HAVE_LIBKVM - #define NTP_POSIX_SOURCE - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/BSDI" -+ #endif - #define HAVE_BSD_TTYS - #endif - -*************** -*** 327,332 **** ---- 364,372 ---- - * along with a standard name one day ! */ - #define ntp_adjtime __adjtimex - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Linux" -+ #endif - #endif - - /* -*************** -*** 338,344 **** ---- 378,387 ---- - #define HAVE_READKMEM - #define NTP_POSIX_SOURCE - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/*BSD" - #endif -+ #endif - - /* - * DECOSF1 -*************** -*** 349,354 **** ---- 392,400 ---- - #define NTP_POSIX_SOURCE - #define NTP_SYSCALLS_STD - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/DECOSF1" -+ #endif - #endif - - /* -*************** -*** 358,364 **** ---- 404,413 ---- - #define HAVE_READKMEM - #define S_CHAR_DEFINED - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/I386" - #endif -+ #endif - - /* - * Mips -*************** -*** 366,371 **** ---- 415,423 ---- - #if defined(SYS_MIPS) - #define NOKMEM - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Mips" -+ #endif - #endif - - /* -*************** -*** 373,379 **** ---- 425,434 ---- - */ - #if defined(SYS_SEQUENT) - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Sequent Dynix 3" - #endif -+ #endif - - /* - * PTX -*************** -*** 407,412 **** ---- 462,470 ---- - typedef unsigned short u_short; - typedef unsigned long u_long; - #endif -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Sequent PTX" -+ #endif - #endif - - -*************** -*** 417,423 **** ---- 475,484 ---- - #define NO_SIGNED_CHAR_DECL - #define HAVE_READKMEM - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Sony" - #endif -+ #endif - - /* - * VAX -*************** -*** 426,431 **** ---- 487,495 ---- - #define NO_SIGNED_CHAR_DECL - #define HAVE_READKMEM - #define HAVE_BSD_NICE -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/VAX" -+ #endif - #endif - - /* -*************** -*** 445,455 **** - #define LOCK_PROCESS - #define SYSV_TIMEOFDAY - #define SIZE_RETURNED_IN_BUFFER -! #endif -! -! #ifdef STREAM /* STREAM implies TERMIOS */ -! #ifndef HAVE_TERMIOS -! #define HAVE_TERMIOS - #endif - #endif - ---- 509,516 ---- - #define LOCK_PROCESS - #define SYSV_TIMEOFDAY - #define SIZE_RETURNED_IN_BUFFER -! #ifndef STR_SYSTEM -! #define STR_SYSTEM "UNIX/SysVR4" - #endif - #endif - -*************** -*** 464,469 **** ---- 525,539 ---- - #define NTP_SYSCALLS_STD - #define USE_PROTOTYPES - #define UDP_WILDCARD_DELIVERY -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/DOMAINOS" -+ #endif -+ #endif -+ -+ #ifdef STREAM /* STREAM implies TERMIOS */ -+ #ifndef HAVE_TERMIOS -+ #define HAVE_TERMIOS -+ #endif - #endif - - #ifndef RETSIGTYPE -diff -c include/ntp_refclock.h:1.1.1.8 include/ntp_refclock.h:3.8 -*** include/ntp_refclock.h:1.1.1.8 Wed Jan 26 21:48:28 1994 ---- include/ntp_refclock.h Wed Jan 26 21:48:28 1994 -*************** -*** 75,84 **** - LONG fudgeval2; - u_char currentstatus; - u_char lastevent; -! u_char unused[1]; - }; - -- - /* - * Reference clock I/O structure. Used to provide an interface between - * the reference clock drivers and the I/O module. ---- 75,84 ---- - LONG fudgeval2; - u_char currentstatus; - u_char lastevent; -! u_char unused; -! struct ctl_var *kv_list; /* additional variables */ - }; - - /* - * Reference clock I/O structure. Used to provide an interface between - * the reference clock drivers and the I/O module. -diff -c include/ntpd.h:1.1.1.6 include/ntpd.h:1.5 -*** include/ntpd.h:1.1.1.6 Wed Jan 26 21:48:35 1994 ---- include/ntpd.h Wed Jan 26 21:48:35 1994 -*************** -*** 1,4 **** -! /* ntpd.h,v 3.1 1993/07/06 01:07:03 jbj Exp - * ntpd.h - Prototypes for xntpd. - */ - ---- 1,4 ---- -! /* - * ntpd.h - Prototypes for xntpd. - */ - -*************** -*** 21,26 **** ---- 21,55 ---- - extern void process_control P((struct recvbuf *, int)); - extern void report_event P((int, struct peer *)); - -+ /* ntp_control.c */ -+ /* -+ * Structure for translation tables between internal system -+ * variable indices and text format. -+ */ -+ struct ctl_var { -+ u_short code; -+ u_short flags; -+ char *text; -+ }; -+ /* -+ * Flag values -+ */ -+ #define CAN_READ 0x01 -+ #define CAN_WRITE 0x02 -+ -+ #define DEF 0x20 -+ #define PADDING 0x40 -+ #define EOV 0x80 -+ -+ #define RO (CAN_READ) -+ #define WO (CAN_WRITE) -+ #define RW (CAN_READ|CAN_WRITE) -+ -+ extern char * add_var P((struct ctl_var **, unsigned long, int)); -+ extern void free_varlist P((struct ctl_var *)); -+ extern void set_var P((struct ctl_var **, char *, unsigned long, int)); -+ extern void set_sys_var P((char *, unsigned long, int)); -+ - /* ntp_intres.c */ - extern void ntp_intres P((void)); - -diff -c include/parse.h:1.1.1.6 include/parse.h:3.13 -*** include/parse.h:1.1.1.6 Wed Jan 26 21:48:36 1994 ---- include/parse.h Wed Jan 26 21:48:36 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.12 1994/01/23 17:23:05 kardel Exp - * -! * parse.h,v 3.12 1994/01/23 17:23:05 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * -! * parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 15,21 **** - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.12 1994/01/23 17:23:05 kardel Exp FAU"; - #endif - - #include "ntp_types.h" ---- 15,21 ---- - #ifndef __PARSE_H__ - #define __PARSE_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char parsehrcsid[]="parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp FAU"; - #endif - - #include "ntp_types.h" -*************** -*** 365,370 **** ---- 365,373 ---- - * History: - * - * parse.h,v -+ * Revision 3.13 1994/01/25 19:04:21 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.12 1994/01/23 17:23:05 kardel - * 1994 reconcilation - * -diff -c include/parse_conf.h:1.1.1.5 include/parse_conf.h:3.5 -*** include/parse_conf.h:1.1.1.5 Wed Jan 26 21:48:37 1994 ---- include/parse_conf.h Wed Jan 26 21:48:37 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.4 1994/01/23 17:23:07 kardel Exp - * -! * parse_conf.h,v 3.4 1994/01/23 17:23:07 kardel Exp - * - * Copyright (c) 1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp - * -! * parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp - * - * Copyright (c) 1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 15,21 **** - #ifndef __PARSE_CONF_H__ - #define __PARSE_CONF_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char dcfhrcsid[]="parse_conf.h,v 3.4 1994/01/23 17:23:07 kardel Exp FAU"; - #endif - - /* ---- 15,21 ---- - #ifndef __PARSE_CONF_H__ - #define __PARSE_CONF_H__ - #if !(defined(lint) || defined(__GNUC__)) -! static char dcfhrcsid[]="parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp FAU"; - #endif - - /* -diff -c include/sys/parsestreams.h:1.1.1.6 include/sys/parsestreams.h:3.11 -*** include/sys/parsestreams.h:1.1.1.6 Wed Jan 26 21:48:44 1994 ---- include/sys/parsestreams.h Wed Jan 26 21:48:44 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.10 1994/01/23 17:23:12 kardel Exp - * -! * parsestreams.h,v 3.10 1994/01/23 17:23:12 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp - * -! * parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg -*************** -*** 13,19 **** - */ - - #if !(defined(lint) || defined(__GNUC__)) -! static char parse77hrcsid[]="parsestreams.h,v 3.10 1994/01/23 17:23:12 kardel Exp"; - #endif - - #undef PARSEKERNEL ---- 13,19 ---- - */ - - #if !(defined(lint) || defined(__GNUC__)) -! static char parse77hrcsid[]="parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp"; - #endif - - #undef PARSEKERNEL -diff -c kernel/Makefile.tmpl:1.1.1.3 kernel/Makefile.tmpl:3.6 -*** kernel/Makefile.tmpl:1.1.1.3 Wed Jan 26 21:48:49 1994 ---- kernel/Makefile.tmpl Wed Jan 26 21:48:49 1994 -*************** -*** 1,7 **** - # -! # /src/NTP/REPOSITORY/v3/kernel/Makefile.tmpl,v 3.5 1994/01/23 17:37:53 kardel Exp - # -- # - # parse routine that could be used in two places - # - COMPILER= cc ---- 1,6 ---- - # -! # /src/NTP/REPOSITORY/v3/kernel/Makefile.tmpl,v 3.6 1994/01/25 19:04:35 kardel Exp - # - # parse routine that could be used in two places - # - COMPILER= cc -diff -c lib/systime.c:1.1.1.10 lib/systime.c:1.7 -*** lib/systime.c:1.1.1.10 Wed Jan 26 21:50:00 1994 ---- lib/systime.c Wed Jan 26 21:50:00 1994 -*************** -*** 238,273 **** - #endif - } - -- sys_clock_offset.l_ui = offset_i; -- sys_clock_offset.l_uf = offset_f; -- - if (adjtime(&adjtv, &oadjtv) < 0) { - syslog(LOG_ERR, "Can't do time adjustment: %m"); - rval = 0; -! } else - rval = 1; - - #ifdef DEBUGRS6000 -! syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n", -! mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"", -! umfptoa(offset_i, offset_f, 9)); -! syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec, -! (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int) -! oadjtv.tv_usec); - #endif /* DEBUGRS6000 */ - -! if ((oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) && (max_no_complete > 0)) { -! sTVTOTS(&oadjtv, &oadjts); -! L_ADD(&sys_clock_offset, &oadjts); -! syslog(LOG_WARNING, "Previous time adjustment didn't complete"); - #ifdef DEBUG -! if (debug > 4) -! syslog(LOG_DEBUG, -! "Previous adjtime() incomplete, residual = %s\n", -! tvtoa(&oadjtv)); - #endif -! if (--max_no_complete == 0) syslog(LOG_WARNING, -! "*** No more 'Prev time adj didn't complete'"); - } - return(rval); - } ---- 238,277 ---- - #endif - } - - if (adjtime(&adjtv, &oadjtv) < 0) { - syslog(LOG_ERR, "Can't do time adjustment: %m"); - rval = 0; -! } else { -! sys_clock_offset.l_ui = offset_i; -! sys_clock_offset.l_uf = offset_f; - rval = 1; - - #ifdef DEBUGRS6000 -! syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n", -! mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"", -! umfptoa(offset_i, offset_f, 9)); -! syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec, -! (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int) -! oadjtv.tv_usec); - #endif /* DEBUGRS6000 */ - -! if (oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) { -! sTVTOTS(&oadjtv, &oadjts); -! L_ADD(&sys_clock_offset, &oadjts); -! if (max_no_complete > 0) { -! syslog(LOG_WARNING, -! "Previous time adjustment didn't complete"); - #ifdef DEBUG -! if (debug > 4) -! syslog(LOG_DEBUG, -! "Previous adjtime() incomplete, residual = %s\n", -! tvtoa(&oadjtv)); - #endif -! if (--max_no_complete == 0) -! syslog(LOG_WARNING, -! "*** No more 'Prev time adj didn't complete'"); -! } -! } - } - return(rval); - } -diff -c ntpq/ntpq.c:1.1.1.20 ntpq/ntpq.c:3.20 -*** ntpq/ntpq.c:1.1.1.20 Wed Jan 26 21:50:59 1994 ---- ntpq/ntpq.c Wed Jan 26 21:50:59 1994 -*************** -*** 2577,2582 **** ---- 2577,2583 ---- - register char *cp; - register char *np; - register char *cpend; -+ int quoted = 0; - static char name[MAXVARLEN]; - static char value[MAXVALLEN]; - -*************** -*** 2623,2630 **** - while (cp < cpend && (isspace(*cp) && *cp != '\r' && *cp != '\n')) - cp++; - np = value; -! while (cp < cpend && *cp != ',') -! *np++ = *cp++; - while (np > value && isspace(*(np-1))) - np--; - *np = '\0'; ---- 2624,2634 ---- - while (cp < cpend && (isspace(*cp) && *cp != '\r' && *cp != '\n')) - cp++; - np = value; -! while (cp < cpend && ((*cp != ',') || quoted)) -! { -! quoted ^= ((*np++ = *cp++) == '"'); -! } -! - while (np > value && isspace(*(np-1))) - np--; - *np = '\0'; -diff -c parse/Makefile.kernel:1.1.1.2 parse/Makefile.kernel:3.8 -*** parse/Makefile.kernel:1.1.1.2 Wed Jan 26 21:51:11 1994 ---- parse/Makefile.kernel Wed Jan 26 21:51:11 1994 -*************** -*** 30,46 **** - ld -r -o parse parsesolaris.o libparse_kernel.a ../lib/libntp.a - @echo "--- Install 'parse' in /kernel/strmod for automatic loading" - -! mparsestreams.o: parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c - ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a \ - microtime.o - rm -f parsestreams.o -! @echo "--- You may load mparsestreams.o via 'modload mparsestreams.o' into the kernel" - -! parsestreams.o: parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c -! ld -r -o $@ $@ ../lib/libntp.a libparse_kernel.a -! @echo "--- You may load parsestreams.o via 'modload parsestreams.o' into the kernel" - - microtime.o: $(MICROTIME) assym.s - cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i ---- 30,51 ---- - ld -r -o parse parsesolaris.o libparse_kernel.a ../lib/libntp.a - @echo "--- Install 'parse' in /kernel/strmod for automatic loading" - -! mparsestreams.o: mparsestreams.o.$(KARCH) -! @echo "--- You may load mparsestreams.o.$(KARCH) via 'modload mparsestreams.o.$(KARCH)' into the kernel" -! -! mparsestreams.o.$(KARCH): parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c - ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a \ - microtime.o - rm -f parsestreams.o -! -! parsestreams.o: parsestreams.o.$(KARCH) -! @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o.$(KARCH)' into the kernel" - -! parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h - cc -c $(DEFS) -I../include parsestreams.c -! ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a -! rm -f parsestreams.o - - microtime.o: $(MICROTIME) assym.s - cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i -diff -c parse/clk_dcf7000.c:1.1.1.7 parse/clk_dcf7000.c:3.10 -*** parse/clk_dcf7000.c:1.1.1.7 Wed Jan 26 21:51:16 1994 ---- parse/clk_dcf7000.c Wed Jan 26 21:51:17 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.9 1994/01/23 17:21:51 kardel Exp - * -! * clk_dcf7000.c,v 3.9 1994/01/23 17:21:51 kardel Exp - * - * ELV DCF7000 module - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp - * -! * clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp - * - * ELV DCF7000 module - * -diff -c parse/clk_meinberg.c:1.1.1.7 parse/clk_meinberg.c:3.11 -*** parse/clk_meinberg.c:1.1.1.7 Wed Jan 26 21:51:17 1994 ---- parse/clk_meinberg.c Wed Jan 26 21:51:18 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.10 1994/01/23 17:21:54 kardel Exp - * -! * clk_meinberg.c,v 3.10 1994/01/23 17:21:54 kardel Exp - * - * Meinberg clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp - * -! * clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp - * - * Meinberg clock support - * -*************** -*** 414,419 **** ---- 414,422 ---- - * History: - * - * clk_meinberg.c,v -+ * Revision 3.11 1994/01/25 19:05:10 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.10 1994/01/23 17:21:54 kardel - * 1994 reconcilation - * -diff -c parse/clk_rawdcf.c:1.1.1.7 parse/clk_rawdcf.c:3.9 -*** parse/clk_rawdcf.c:1.1.1.7 Wed Jan 26 21:51:19 1994 ---- parse/clk_rawdcf.c Wed Jan 26 21:51:19 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.8 1994/01/22 11:24:11 kardel Exp - * -! * clk_rawdcf.c,v 3.8 1994/01/22 11:24:11 kardel Exp - * - * Raw DCF77 pulse clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp - * -! * clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp - * - * Raw DCF77 pulse clock support - * -*************** -*** 529,534 **** ---- 529,537 ---- - * History: - * - * clk_rawdcf.c,v -+ * Revision 3.9 1994/01/25 19:05:12 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.8 1994/01/22 11:24:11 kardel - * fixed PPS handling - * -diff -c parse/clk_schmid.c:1.1.1.7 parse/clk_schmid.c:3.10 -*** parse/clk_schmid.c:1.1.1.7 Wed Jan 26 21:51:20 1994 ---- parse/clk_schmid.c Wed Jan 26 21:51:20 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.9 1994/01/23 17:21:56 kardel Exp - * -! * clk_schmid.c,v 3.9 1994/01/23 17:21:56 kardel Exp - * - * Schmid clock support - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp - * -! * clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp - * - * Schmid clock support - * -*************** -*** 168,173 **** ---- 168,176 ---- - * History: - * - * clk_schmid.c,v -+ * Revision 3.10 1994/01/25 19:05:15 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.9 1994/01/23 17:21:56 kardel - * 1994 reconcilation - * -diff -c parse/clk_trimble.c:1.1.1.2 parse/clk_trimble.c:3.7 -*** parse/clk_trimble.c:1.1.1.2 Wed Jan 26 21:51:21 1994 ---- parse/clk_trimble.c Wed Jan 26 21:51:21 1994 -*************** -*** 1,6 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMSV6) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.6 1993/10/30 09:44:45 kardel Exp - * - * Trimble SV6 clock support - */ ---- 1,6 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMSV6) - /* -! * /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.7 1994/01/25 19:05:17 kardel Exp - * - * Trimble SV6 clock support - */ -*************** -*** 106,111 **** ---- 106,114 ---- - * History: - * - * clk_trimble.c,v -+ * Revision 3.7 1994/01/25 19:05:17 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.6 1993/10/30 09:44:45 kardel - * conditional compilation flag cleanup - * -diff -c parse/parse.c:1.1.1.7 parse/parse.c:3.19 -*** parse/parse.c:1.1.1.7 Wed Jan 26 21:51:24 1994 ---- parse/parse.c Wed Jan 26 21:51:24 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.18 1994/01/23 17:21:59 kardel Exp - * -! * parse.c,v 3.18 1994/01/23 17:21:59 kardel Exp - * - * Parser module for reference clock - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp - * -! * parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp - * - * Parser module for reference clock - * -*************** -*** 22,28 **** - */ - - #if !(defined(lint) || defined(__GNUC__)) -! static char rcsid[] = "parse.c,v 3.18 1994/01/23 17:21:59 kardel Exp"; - #endif - - #include "sys/types.h" ---- 22,28 ---- - */ - - #if !(defined(lint) || defined(__GNUC__)) -! static char rcsid[] = "parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp"; - #endif - - #include "sys/types.h" -*************** -*** 1139,1144 **** ---- 1139,1147 ---- - * History: - * - * parse.c,v -+ * Revision 3.19 1994/01/25 19:05:20 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.18 1994/01/23 17:21:59 kardel - * 1994 reconcilation - * -diff -c parse/parse_conf.c:1.1.1.7 parse/parse_conf.c:3.13 -*** parse/parse_conf.c:1.1.1.7 Wed Jan 26 21:51:25 1994 ---- parse/parse_conf.c Wed Jan 26 21:51:25 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.12 1994/01/23 17:22:02 kardel Exp - * -! * parse_conf.c,v 3.12 1994/01/23 17:22:02 kardel Exp - * - * Parser configuration module for reference clocks - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp - * -! * parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp - * - * Parser configuration module for reference clocks - * -*************** -*** 81,86 **** ---- 81,89 ---- - * History: - * - * parse_conf.c,v -+ * Revision 3.13 1994/01/25 19:05:23 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.12 1994/01/23 17:22:02 kardel - * 1994 reconcilation - * -diff -c parse/parsesolaris.c:1.1.1.4 parse/parsesolaris.c:3.9 -*** parse/parsesolaris.c:1.1.1.4 Wed Jan 26 21:51:26 1994 ---- parse/parsesolaris.c Wed Jan 26 21:51:27 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.8 1994/01/23 17:22:04 kardel Exp - * -! * parsesolaris.c,v 3.8 1994/01/23 17:22:04 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp - * -! * parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be -*************** -*** 19,25 **** - */ - - #ifndef lint -! static char rcsid[] = "parsesolaris.c,v 3.8 1994/01/23 17:22:04 kardel Exp"; - #endif - - /* ---- 19,25 ---- - */ - - #ifndef lint -! static char rcsid[] = "parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp"; - #endif - - /* -*************** -*** 139,145 **** - /*ARGSUSED*/ - int _init(void) - { -! static char revision[] = "3.8"; - char *s, *S, *t; - - /* ---- 139,145 ---- - /*ARGSUSED*/ - int _init(void) - { -! static char revision[] = "3.9"; - char *s, *S, *t; - - /* -*************** -*** 1179,1184 **** ---- 1179,1187 ---- - * History: - * - * parsesolaris.c,v -+ * Revision 3.9 1994/01/25 19:05:26 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.8 1994/01/23 17:22:04 kardel - * 1994 reconcilation - * -diff -c parse/parsestreams.c:1.1.1.6 parse/parsestreams.c:3.12 -*** parse/parsestreams.c:1.1.1.6 Wed Jan 26 21:51:28 1994 ---- parse/parsestreams.c Wed Jan 26 21:51:28 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.11 1994/01/23 17:22:07 kardel Exp - * -! * parsestreams.c,v 3.11 1994/01/23 17:22:07 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp - * -! * parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp - * - * STREAMS module for reference clocks - * (SunOS4.x) -*************** -*** 16,22 **** - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.11 1994/01/23 17:22:07 kardel Exp"; - #endif - - #include "sys/types.h" ---- 16,22 ---- - */ - - #ifndef lint -! static char rcsid[] = "parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp"; - #endif - - #include "sys/types.h" -*************** -*** 195,201 **** - } - else - { -! static char revision[] = "3.11"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); ---- 195,201 ---- - } - else - { -! static char revision[] = "3.12"; - char *s, *S, *t; - - strncpy(ifm->f_name, mname, FMNAMESZ); -*************** -*** 1258,1263 **** ---- 1258,1266 ---- - * History: - * - * parsestreams.c,v -+ * Revision 3.12 1994/01/25 19:05:30 kardel -+ * 94/01/23 reconcilation -+ * - * Revision 3.11 1994/01/23 17:22:07 kardel - * 1994 reconcilation - * -diff -c parse/util/Makefile.tmpl:1.1.1.2 parse/util/Makefile.tmpl:3.12 -*** parse/util/Makefile.tmpl:1.1.1.2 Wed Jan 26 21:51:31 1994 ---- parse/util/Makefile.tmpl Wed Jan 26 21:51:31 1994 -*************** -*** 1,5 **** - # -! # /src/NTP/REPOSITORY/v3/parse/util/Makefile.tmpl,v 3.11 1993/11/17 13:34:12 kardel Exp - # - COMPILER= cc - DEFS= ---- 1,5 ---- - # -! # /src/NTP/REPOSITORY/v3/parse/util/Makefile.tmpl,v 3.12 1994/01/25 19:05:39 kardel Exp - # - COMPILER= cc - DEFS= -diff -c parse/util/dcfd.c:1.1.1.4 parse/util/dcfd.c:3.15 -*** parse/util/dcfd.c:1.1.1.4 Wed Jan 26 21:51:33 1994 ---- parse/util/dcfd.c Wed Jan 26 21:51:33 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.13 1994/01/23 17:22:15 kardel Exp - * -! * dcfd.c,v 3.13 1994/01/23 17:22:15 kardel Exp - * - * DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line) - * ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp - * -! * dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp - * - * DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line) - * -*************** -*** 733,740 **** - * assume that we convert timecode within the unix/UTC epoch - - * prolonges validity of 2 digit years - */ -! if (clock->year < 1900) -! clock->year += 100; /* XXX this will do it till <2092 */ - - /* - * must have been a really negative year code - drop it ---- 733,740 ---- - * assume that we convert timecode within the unix/UTC epoch - - * prolonges validity of 2 digit years - */ -! if (clock->year < 1994) -! clock->year += 100; /* XXX this will do it till <2094 */ - - /* - * must have been a really negative year code - drop it -diff -c parse/util/testdcf.c:1.1.1.5 parse/util/testdcf.c:3.9 -*** parse/util/testdcf.c:1.1.1.5 Wed Jan 26 21:51:35 1994 ---- parse/util/testdcf.c Wed Jan 26 21:51:35 1994 -*************** -*** 1,7 **** - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.8 1994/01/23 17:22:20 kardel Exp - * -! * testdcf.c,v 3.8 1994/01/23 17:22:20 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * ---- 1,7 ---- - /* -! * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * -! * testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp - * - * simple DCF77 100/200ms pulse test program (via 50Baud serial line) - * -diff -c scripts/Guess.sh:1.1.1.6 scripts/Guess.sh:1.11 -*** scripts/Guess.sh:1.1.1.6 Wed Jan 26 21:52:11 1994 ---- scripts/Guess.sh Wed Jan 26 21:52:12 1994 -*************** -*** 19,25 **** - sinix-m) - guess=sinix-m - ;; -! sunos) case "$3" in - 4.1*) guess="sunos4" ;; - 5.1) guess="sunos5.1" ;; - 5.*) guess="sunos5.2" ;; ---- 19,26 ---- - sinix-m) - guess=sinix-m - ;; -! sunos|solaris) -! case "$3" in - 4.1*) guess="sunos4" ;; - 5.1) guess="sunos5.1" ;; - 5.*) guess="sunos5.2" ;; -*************** -*** 59,65 **** - guess="netbsd" - ;; - # now the fun starts - there are vendors that -! # do not really identify their OS un uname. - # Fine - now I look at our version and hope - # that nobody else had this marvellous idea. - # I am not willing to mention the vendor explicitly ---- 60,66 ---- - guess="netbsd" - ;; - # now the fun starts - there are vendors that -! # do not really identify their OS in uname. - # Fine - now I look at our version and hope - # that nobody else had this marvellous idea. - # I am not willing to mention the vendor explicitly -diff -c xntpd/ntp_config.c:1.1.1.18 xntpd/ntp_config.c:3.21 -*** xntpd/ntp_config.c:1.1.1.18 Wed Jan 26 21:52:59 1994 ---- xntpd/ntp_config.c Wed Jan 26 21:53:00 1994 -*************** -*** 93,98 **** ---- 93,99 ---- - #define CONFIG_PPS 24 - #define CONFIG_PIDFILE 25 - #define CONFIG_LOGFILE 26 -+ #define CONFIG_SETVAR 27 - - #define CONF_MOD_VERSION 1 - #define CONF_MOD_KEY 2 -*************** -*** 177,182 **** ---- 178,184 ---- - { "statistics", CONFIG_STATISTICS }, - { "pidfile", CONFIG_PIDFILE }, - { "logfile", CONFIG_LOGFILE }, -+ { "setvar", CONFIG_SETVAR }, - { "", CONFIG_UNKNOWN } - }; - -*************** -*** 316,322 **** - #endif - extern char *FindConfig(); - char *progname; -! static char *xntp_options = "abc:de:f:k:l:p:r:s:t:"; - - static int gettokens P((FILE *, char *, char **, int *)); - static int matchkey P((char *, struct keyword *)); ---- 318,324 ---- - #endif - extern char *FindConfig(); - char *progname; -! static char *xntp_options = "abc:de:f:k:l:p:r:s:t:v:V:"; - - static int gettokens P((FILE *, char *, char **, int *)); - static int matchkey P((char *, struct keyword *)); -*************** -*** 374,381 **** - } - - if (errflg || optind != argc) { -! (void) fprintf(stderr, -! "usage: %s [ -bd ] [ -c config_file ]\n", progname); - exit(2); - } - optind = 0; /* reset optind to restart getopt_l */ ---- 376,385 ---- - } - - if (errflg || optind != argc) { -! (void) fprintf(stderr, "usage: %s [ -abd ] [ -c config_file ] [ -e encryption delay ]\n", progname); -! (void) fprintf(stderr, "\t\t[ -f frequency file ] [ -k key file ] [ -l log file ]\n"); -! (void) fprintf(stderr, "\t\t[ -p pid file ] [ -r broadcast delay ] [ -s status directory ]\n"); -! (void) fprintf(stderr, "\t\t[ -t trusted key ] [ -v sys variable ] [ -V default sys variable ]\n"); - exit(2); - } - optind = 0; /* reset optind to restart getopt_l */ -*************** -*** 428,433 **** ---- 432,438 ---- - char keyfile[MAXFILENAME]; - extern int optind; - extern char *optarg; -+ extern char *Version; - extern U_LONG info_auth_keyid; - FILEGEN *filegen; - -*************** -*** 443,448 **** ---- 448,459 ---- - res_fp = NULL; - have_resolver = have_keyfile = 0; - -+ /* -+ * install a non default variable with this daemon version -+ */ -+ (void) sprintf(line, "daemon_version=\"%s\"", Version); -+ set_sys_var(line, strlen(line)+1, RO); -+ - #ifdef RESOLVE_INTERNAL - resolve_internal = 1; - #endif -*************** -*** 546,551 **** ---- 557,566 ---- - } while (0); - break; - -+ case 'v': -+ case 'V': -+ set_sys_var(optarg, strlen(optarg)+1, RW | ((c == 'V') ? DEF : 0)); -+ break; - - default: - errflg++; -*************** -*** 1386,1392 **** - (u_char)peerkey, (u_char)peerflags); - } - break; -! - } - } - (void) fclose(fp); ---- 1401,1419 ---- - (u_char)peerkey, (u_char)peerflags); - } - break; -! -! case CONFIG_SETVAR: -! if (ntokens < 2) -! { -! syslog(LOG_ERR, -! "no value for setvar command - line ignored"); -! } -! else -! { -! set_sys_var(tokens[1], strlen(tokens[1])+1, RW | -! ((((ntokens > 2) && !strcmp(tokens[2], "default"))) ? DEF : 0)); -! } -! break; - } - } - (void) fclose(fp); -*************** -*** 1445,1450 **** ---- 1472,1478 ---- - register char *cp; - register int eol; - register int ntok; -+ register int quoted = 0; - - /* - * Find start of first token -*************** -*** 1469,1476 **** - ntok = 0; - while (!eol) { - tokenlist[ntok++] = cp; -! while (!ISEOL(*cp) && !ISSPACE(*cp)) -! cp++; - if (ISEOL(*cp)) { - *cp = '\0'; - eol = 1; ---- 1497,1505 ---- - ntok = 0; - while (!eol) { - tokenlist[ntok++] = cp; -! while (!ISEOL(*cp) && (!ISSPACE(*cp) || quoted)) -! quoted ^= (*cp++ == '"'); -! - if (ISEOL(*cp)) { - *cp = '\0'; - eol = 1; -diff -c xntpd/ntp_control.c:1.1.1.15 xntpd/ntp_control.c:3.21 -*** xntpd/ntp_control.c:1.1.1.15 Wed Jan 26 21:53:01 1994 ---- xntpd/ntp_control.c Wed Jan 26 21:53:02 1994 -*************** -*** 1,4 **** -! /* ntp_control.c,v 3.1 1993/07/06 01:11:13 jbj Exp - * ntp_control.c - respond to control messages and send async traps - */ - #include ---- 1,4 ---- -! /* - * ntp_control.c - respond to control messages and send async traps - */ - #include -*************** -*** 61,66 **** ---- 61,67 ---- - static void ctl_putclock P((int, struct refclockstat *, int)); - #endif /* REFCLOCK */ - static struct ctl_var *ctl_getitem P((struct ctl_var *, char **)); -+ static unsigned long count_var P((struct ctl_var *)); - static void control_unspec P((struct recvbuf *, int)); - static void read_status P((struct recvbuf *, int)); - static void read_variables P((struct recvbuf *, int)); -*************** -*** 83,113 **** - { NO_REQUEST, 0 } - }; - -- -- /* -- * Structure for translation tables between internal system -- * variable indices and text format. -- */ -- struct ctl_var { -- u_short code; -- u_short flags; -- char *text; -- }; -- - /* -- * Flag values -- */ -- #define CAN_READ 0x1 -- #define CAN_WRITE 0x2 -- #define PADDING 0x80 -- #define EOV 0x40 -- -- #define RO (CAN_READ) -- #define WO (CAN_WRITE) -- #define RW (CAN_READ|CAN_WRITE) -- -- -- /* - * System variable values. The array can be indexed by - * the variable index to find the textual name. - */ ---- 84,90 ---- -*************** -*** 132,141 **** - { CS_SYSTEM, RO, "system" }, /* 17 */ - { CS_KEYID, RO, "keyid" }, /* 18 */ - { CS_REFSKEW, RO, "refskew" }, /* 19 */ -! { CS_VERSION, RO, "daemon_version" }, /* 20 */ - { 0, EOV, "" } - }; - - /* - * System variables we print by default (in fuzzball order, more-or-less) - */ ---- 109,120 ---- - { CS_SYSTEM, RO, "system" }, /* 17 */ - { CS_KEYID, RO, "keyid" }, /* 18 */ - { CS_REFSKEW, RO, "refskew" }, /* 19 */ -! { CS_VARLIST, RO, "sys_var_list" },/* 20 */ - { 0, EOV, "" } - }; - -+ static struct ctl_var *ext_sys_var = (struct ctl_var *)0; -+ - /* - * System variables we print by default (in fuzzball order, more-or-less) - */ -*************** -*** 153,159 **** - CS_OFFSET, - CS_DRIFT, - CS_COMPLIANCE, -- CS_VERSION, - 0 - }; - ---- 132,137 ---- -*************** -*** 197,202 **** ---- 175,181 ---- - { CP_SENT, RO, "sent" }, /* 32 */ - { CP_FILTERROR, RO, "filterror" }, /* 33 */ - { CP_FLASH, RO, "flash" }, /* 34 */ -+ { CP_VARLIST, RO, "peer_var_list" }, /* 35 */ - { 0, EOV, "" } - }; - -*************** -*** 255,260 **** ---- 234,240 ---- - { CC_FUDGEVAL2, RO, "fudgeval2" }, /* 10 */ - { CC_FLAGS, RO, "flags" }, /* 11 */ - { CC_DEVICE, RO, "device" }, /* 12 */ -+ { CC_VARLIST, RO, "clock_var_list" },/* 13 */ - { 0, EOV, "" } - }; - -*************** -*** 283,290 **** ---- 263,277 ---- - /* - * System and processor definitions. These will change for the gizmo board. - */ -+ #ifndef STR_SYSTEM - #define STR_SYSTEM "UNIX" -+ #endif -+ #ifndef STR_PROCESSOR - #define STR_PROCESSOR "unknown" -+ #endif -+ -+ static char str_system[] = STR_SYSTEM; -+ static char str_processor[] = STR_PROCESSOR; - - /* - * Trap structures. We only allow a few of these, and send -*************** -*** 1221,1227 **** - ctl_putsys(varid) - int varid; - { -- extern char *Version; - l_fp tmp; - - switch (varid) { ---- 1208,1213 ---- -*************** -*** 1280,1291 **** - ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning); - break; - case CS_PROCESSOR: -! ctl_putstr(sys_var[CS_PROCESSOR].text, STR_PROCESSOR, -! sizeof(STR_PROCESSOR) - 1); - break; - case CS_SYSTEM: -! ctl_putstr(sys_var[CS_SYSTEM].text, STR_SYSTEM, -! sizeof(STR_SYSTEM) - 1); - break; - case CS_KEYID: - ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0); ---- 1266,1277 ---- - ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning); - break; - case CS_PROCESSOR: -! ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor, -! sizeof(str_processor) - 1); - break; - case CS_SYSTEM: -! ctl_putstr(sys_var[CS_SYSTEM].text, str_system, -! sizeof(str_system) - 1); - break; - case CS_KEYID: - ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0); -*************** -*** 1293,1301 **** - case CS_REFSKEW: - ctl_putlfp(sys_var[CS_REFSKEW].text, &sys_refskew); - break; -! case CS_VERSION: -! ctl_putstr(sys_var[CS_VERSION].text, Version, -! strlen(Version)); - break; - } - } ---- 1279,1338 ---- - case CS_REFSKEW: - ctl_putlfp(sys_var[CS_REFSKEW].text, &sys_refskew); - break; -! case CS_VARLIST: -! { -! char buf[CTL_MAX_DATA_LEN]; -! register char *s, *ss, *t, *be; -! register int i; -! register struct ctl_var *k; -! -! s = buf; -! be = buf + sizeof(buf) - strlen(sys_var[CS_VARLIST].text) - 4; -! if (s > be) -! break; /* really long var name 8-( - Killer */ -! -! strcpy(s, sys_var[CS_VARLIST].text); -! strcat(s, "=\""); -! s += strlen(s); -! t = s; -! -! for (k = sys_var; !(k->flags &EOV); k++) -! { -! i = strlen(k->text); -! if (s+i+1 >= be) -! break; -! if (s != t) -! *s++ = ','; -! strcpy(s, k->text); -! s += i; -! } -! -! for (k = ext_sys_var; k && !(k->flags &EOV); k++) -! { -! ss = k->text; -! if (!ss) -! continue; -! -! while (*ss && *ss != '=') -! ss++; -! -! i = ss - k->text; -! if (s+i+1 >= be) -! break; -! if (s != t) -! *s++ = ','; -! strncpy(s, k->text, i); -! s += i; -! } -! -! if (s+2 >= be) -! break; -! -! *s++ = '"'; -! *s = '\0'; -! -! ctl_putdata(buf, s - buf, 0); -! } - break; - } - } -*************** -*** 1428,1433 **** ---- 1465,1507 ---- - case CP_SENT: - ctl_putuint(peer_var[CP_SENT].text, peer->sent); - break; -+ case CP_VARLIST: -+ { -+ char buf[CTL_MAX_DATA_LEN]; -+ register char *s, *t, *be; -+ register int i; -+ register struct ctl_var *k; -+ -+ s = buf; -+ be = buf + sizeof(buf) - strlen(peer_var[CP_VARLIST].text) - 4; -+ if (s > be) -+ break; /* really long var name 8-( - Killer */ -+ -+ strcpy(s, peer_var[CP_VARLIST].text); -+ strcat(s, "=\""); -+ s += strlen(s); -+ t = s; -+ -+ for (k = peer_var; !(k->flags &EOV); k++) -+ { -+ i = strlen(k->text); -+ if (s+i+1 >= be) -+ break; -+ if (s != t) -+ *s++ = ','; -+ strcpy(s, k->text); -+ s += i; -+ } -+ -+ if (s+2 >= be) -+ break; -+ -+ *s++ = '"'; -+ *s = '\0'; -+ -+ ctl_putdata(buf, s - buf, 0); -+ } -+ break; - } - } - -*************** -*** 1501,1506 **** ---- 1575,1636 ---- - strlen(clock->clockdesc)); - } - break; -+ case CC_VARLIST: -+ { -+ char buf[CTL_MAX_DATA_LEN]; -+ register char *s, *ss, *t, *be; -+ register int i; -+ register struct ctl_var *k; -+ -+ s = buf; -+ be = buf + sizeof(buf) - strlen(clock_var[CC_VARLIST].text) - 4; -+ if (s > be) -+ break; /* really long var name 8-( - Killer */ -+ -+ strcpy(s, clock_var[CC_VARLIST].text); -+ strcat(s, "=\""); -+ s += strlen(s); -+ t = s; -+ -+ for (k = clock_var; !(k->flags &EOV); k++) -+ { -+ i = strlen(k->text); -+ if (s+i+1 >= be) -+ break; -+ if (s != t) -+ *s++ = ','; -+ strcpy(s, k->text); -+ s += i; -+ } -+ -+ for (k = clock->kv_list; k && !(k->flags &EOV); k++) -+ { -+ ss = k->text; -+ if (!ss) -+ continue; -+ -+ while (*ss && *ss != '=') -+ ss++; -+ -+ i = ss - k->text; -+ if (s+i+1 >= be) -+ break; -+ if (s != t) -+ *s++ = ','; -+ strncpy(s, k->text, i); -+ s += i; -+ *s = '\0'; -+ } -+ -+ if (s+2 >= be) -+ break; -+ -+ *s++ = '"'; -+ *s = '\0'; -+ -+ ctl_putdata(buf, s - buf, 0); -+ } -+ break; - } - } - #endif -*************** -*** 1517,1522 **** ---- 1647,1653 ---- - { - register struct ctl_var *v; - register char *cp, *tp; -+ static struct ctl_var eol = { 0, EOV, }; - static char buf[128]; - - /* -*************** -*** 1528,1533 **** ---- 1659,1667 ---- - - if (reqpt >= reqend) - return 0; -+ -+ if (var_list == (struct ctl_var *)0) -+ return &eol; - - /* - * Look for a first character match on the tag. If we find -*************** -*** 1538,1548 **** - while (!(v->flags & EOV)) { - if (!(v->flags & PADDING) && *cp == *(v->text)) { - tp = v->text; -! while (*tp != '\0' && cp < reqend && *cp == *tp) { - cp++; - tp++; - } -! if (*tp == '\0') { - while (cp < reqend && isspace(*cp)) - cp++; - if (cp == reqend || *cp == ',') { ---- 1672,1682 ---- - while (!(v->flags & EOV)) { - if (!(v->flags & PADDING) && *cp == *(v->text)) { - tp = v->text; -! while (*tp != '\0' && *tp != '=' && cp < reqend && *cp == *tp) { - cp++; - tp++; - } -! if ((*tp == '\0') || (*tp == '=')) { - while (cp < reqend && isspace(*cp)) - cp++; - if (cp == reqend || *cp == ',') { -*************** -*** 1685,1692 **** - register struct ctl_var *v; - register int i; - char *valuep; -! u_char wants[(CS_MAXCODE>CP_MAXCODE) ? (CS_MAXCODE+1) : (CP_MAXCODE+1)]; -! int gotvar; - - if (res_associd == 0) { - /* ---- 1819,1826 ---- - register struct ctl_var *v; - register int i; - char *valuep; -! u_char *wants; -! int gotvar = (CS_MAXCODE>CP_MAXCODE) ? (CS_MAXCODE+1) : (CP_MAXCODE+1); - - if (res_associd == 0) { - /* -*************** -*** 1696,1707 **** - rpkt.status = htons(ctlsysstatus()); - if (res_authokay) - ctl_sys_num_events = 0; -! bzero((char *)wants, CS_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! return; - } - wants[v->code] = 1; - gotvar = 1; ---- 1830,1853 ---- - rpkt.status = htons(ctlsysstatus()); - if (res_authokay) - ctl_sys_num_events = 0; -! gotvar += count_var(ext_sys_var); -! wants = (u_char *)emalloc(gotvar); -! bzero((char *)wants, gotvar); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -! if ((v = ctl_getitem(ext_sys_var, &valuep)) != 0) { -! if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! free((char *)wants); -! return; -! } -! wants[CS_MAXCODE+1+v->code] = 1; -! gotvar = 1; -! continue; -! } else { -! break; /* shouldn't happen ! */ -! } - } - wants[v->code] = 1; - gotvar = 1; -*************** -*** 1710,1721 **** - for (i = 1; i <= CS_MAXCODE; i++) - if (wants[i]) - ctl_putsys(i); - } else { - register u_char *cs; - - for (cs = def_sys_var; *cs != 0; cs++) -! ctl_putsys((int)*cs); - } - } else { - register struct peer *peer; - ---- 1856,1876 ---- - for (i = 1; i <= CS_MAXCODE; i++) - if (wants[i]) - ctl_putsys(i); -+ for (i = 0; ext_sys_var && !(ext_sys_var[i].flags & EOV); i++) -+ if (wants[i+CS_MAXCODE+1]) -+ ctl_putdata(ext_sys_var[i].text, -+ strlen(ext_sys_var[i].text), 0); - } else { - register u_char *cs; -+ register struct ctl_var *kv; - - for (cs = def_sys_var; *cs != 0; cs++) -! ctl_putsys((int)*cs); -! for (kv = ext_sys_var; kv && !(kv->flags & EOV); kv++) -! if (kv->flags & DEF) -! ctl_putdata(kv->text, strlen(kv->text), 0); - } -+ free((char *)wants); - } else { - register struct peer *peer; - -*************** -*** 1732,1742 **** - rpkt.status = htons(ctlpeerstatus(peer)); - if (res_authokay) - peer->num_events = 0; -! bzero((char*)wants, CP_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { - if (v->flags & EOV) { - ctl_error(CERR_UNKNOWNVAR); - return; - } - wants[v->code] = 1; ---- 1887,1899 ---- - rpkt.status = htons(ctlpeerstatus(peer)); - if (res_authokay) - peer->num_events = 0; -! wants = (u_char *)emalloc(gotvar); -! bzero((char*)wants, gotvar); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { - if (v->flags & EOV) { - ctl_error(CERR_UNKNOWNVAR); -+ free((char *)wants); - return; - } - wants[v->code] = 1; -*************** -*** 1752,1757 **** ---- 1909,1915 ---- - for (cp = def_peer_var; *cp != 0; cp++) - ctl_putpeer((int)*cp, peer); - } -+ free((char *)wants); - } - ctl_flushpkt(0); - } -*************** -*** 1768,1773 **** ---- 1926,1932 ---- - int restrict; - { - register struct ctl_var *v; -+ register int ext_var; - char *valuep; - LONG val; - u_char leapind, leapwarn; -*************** -*** 1795,1831 **** - * Look through the variables. Dump out at the first sign of trouble. - */ - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! return; - } - if (!(v->flags & CAN_WRITE)) { - ctl_error(CERR_PERMISSION); - return; - } -! if (*valuep == '\0' || !atoint(valuep, &val)) { - ctl_error(CERR_BADFMT); - return; - } -! if ((val & ~LEAP_NOTINSYNC) != 0) { - ctl_error(CERR_BADVALUE); - return; - } - -! /* -! * This one seems sane. Save it. -! */ -! switch(v->code) { -! case CS_LEAP: -! case CS_LEAPIND: -! leapind = (u_char)val; -! break; -! case CS_LEAPWARNING: -! leapwarn = (u_char)val; -! break; -! default: -! ctl_error(CERR_UNSPEC); /* our fault, really */ -! return; - } - } - ---- 1954,2013 ---- - * Look through the variables. Dump out at the first sign of trouble. - */ - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { -+ ext_var = 0; - if (v->flags & EOV) { -! if ((v = ctl_getitem(ext_sys_var, &valuep)) != 0) { -! if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! return; -! } -! ext_var = 1; -! } else { -! break; -! } - } - if (!(v->flags & CAN_WRITE)) { - ctl_error(CERR_PERMISSION); - return; - } -! if (!ext_var && (*valuep == '\0' || !atoint(valuep, &val))) { - ctl_error(CERR_BADFMT); - return; - } -! if (!ext_var && (val & ~LEAP_NOTINSYNC) != 0) { - ctl_error(CERR_BADVALUE); - return; - } - -! if (ext_var) { -! char *s = emalloc(strlen(v->text)+strlen(valuep)+2); -! char *t, *tt = s; -! -! t = v->text; -! while (*t && *t != '=') -! *tt++ = *t++; -! -! *tt++ = '='; -! strcat(tt, valuep); -! -! set_sys_var(s, strlen(s)+1, v->flags); -! free(s); -! } else { -! /* -! * This one seems sane. Save it. -! */ -! switch(v->code) { -! case CS_LEAP: -! case CS_LEAPIND: -! leapind = (u_char)val; -! break; -! case CS_LEAPWARNING: -! leapwarn = (u_char)val; -! break; -! default: -! ctl_error(CERR_UNSPEC); /* our fault, really */ -! return; -! } - } - } - -*************** -*** 1861,1867 **** - register int i; - register struct peer *peer; - char *valuep; -! u_char wants[CC_MAXCODE+1]; - int gotvar; - struct refclockstat clock; - ---- 2043,2049 ---- - register int i; - register struct peer *peer; - char *valuep; -! u_char *wants; - int gotvar; - struct refclockstat clock; - -*************** -*** 1898,1915 **** - /* - * If we got here we have a peer which is a clock. Get his status. - */ - refclock_control(&peer->srcadr, (struct refclockstat *)0, &clock); - - /* - * Look for variables in the packet. - */ - rpkt.status = htons(ctlclkstatus(&clock)); - gotvar = 0; -! bzero((char*)wants, CC_MAXCODE+1); -! while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! return; - } - wants[v->code] = 1; - gotvar = 1; ---- 2080,2112 ---- - /* - * If we got here we have a peer which is a clock. Get his status. - */ -+ clock.kv_list = (struct ctl_var *)0; -+ - refclock_control(&peer->srcadr, (struct refclockstat *)0, &clock); - - /* - * Look for variables in the packet. - */ - rpkt.status = htons(ctlclkstatus(&clock)); -+ gotvar = CC_MAXCODE+1+count_var(clock.kv_list); -+ wants = (u_char *)emalloc(gotvar); -+ bzero((char*)wants, gotvar); - gotvar = 0; -! while ((v = ctl_getitem(clock_var, &valuep)) != 0) { - if (v->flags & EOV) { -! if ((v = ctl_getitem(clock.kv_list, &valuep)) != 0) { -! if (v->flags & EOV) { -! ctl_error(CERR_UNKNOWNVAR); -! free((char*)wants); -! free_varlist(clock.kv_list); -! return; -! } -! wants[CC_MAXCODE+1+v->code] = 1; -! gotvar = 1; -! continue; -! } else { -! break; /* shouldn't happen ! */ -! } - } - wants[v->code] = 1; - gotvar = 1; -*************** -*** 1919,1930 **** ---- 2116,2139 ---- - for (i = 1; i <= CC_MAXCODE; i++) - if (wants[i]) - ctl_putclock(i, &clock, 1); -+ for (i = 0; !(clock.kv_list[i].flags & EOV); i++) -+ if (wants[i+CC_MAXCODE+1]) -+ ctl_putdata(clock.kv_list[i].text, -+ strlen(clock.kv_list[i].text), 0); - } else { - register u_char *cc; -+ register struct ctl_var *kv; - - for (cc = def_clock_var; *cc != 0; cc++) - ctl_putclock((int)*cc, &clock, 0); -+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++) -+ if (kv->flags & DEF) -+ ctl_putdata(kv->text, strlen(kv->text), 0); - } -+ -+ free((char*)wants); -+ free_varlist(clock.kv_list); -+ - ctl_flushpkt(0); - #endif - } -*************** -*** 2237,2249 **** - */ - if (err == EVNT_CLOCKEXCPT) { - struct refclockstat clock; -! refclock_control(&peer->srcadr, - (struct refclockstat *)0, - &clock); - ctl_puthex("refclockstatus", - (U_LONG)ctlclkstatus(&clock)); - for (i = 1; i <= CC_MAXCODE; i++) - ctl_putclock(i, &clock, 0); - } - #endif /*REFCLOCK*/ - } else { ---- 2446,2468 ---- - */ - if (err == EVNT_CLOCKEXCPT) { - struct refclockstat clock; -! struct ctl_var *kv; -! -! clock.kv_list = (struct ctl_var *)0; -! -! refclock_control(&peer->srcadr, - (struct refclockstat *)0, - &clock); - ctl_puthex("refclockstatus", - (U_LONG)ctlclkstatus(&clock)); -+ - for (i = 1; i <= CC_MAXCODE; i++) - ctl_putclock(i, &clock, 0); -+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++) -+ if (kv->flags & DEF) -+ ctl_putdata(kv->text, strlen(kv->text), 0); -+ -+ free_varlist(clock.kv_list); - } - #endif /*REFCLOCK*/ - } else { -*************** -*** 2262,2274 **** ---- 2481,2504 ---- - */ - if (err == EVNT_PEERCLOCK) { - struct refclockstat clock; -+ struct ctl_var *kv; -+ -+ clock.kv_list = (struct ctl_var *)0; -+ - refclock_control(&peer->srcadr, - (struct refclockstat *)0, - &clock); -+ - ctl_puthex("refclockstatus", - (U_LONG)ctlclkstatus(&clock)); -+ - for (i = 1; i <= CC_MAXCODE; i++) - ctl_putclock(i, &clock, 0); -+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++) -+ if (kv->flags & DEF) -+ ctl_putdata(kv->text, strlen(kv->text), 0); -+ -+ free_varlist(clock.kv_list); - } - #endif /*REFCLOCK*/ - } -*************** -*** 2303,2305 **** ---- 2533,2647 ---- - numctlbadop = 0; - numasyncmsgs = 0; - } -+ -+ static unsigned long -+ count_var(k) -+ struct ctl_var *k; -+ { -+ register unsigned long c; -+ -+ c = 0; -+ while (k && !(k++->flags & EOV)) -+ c++; -+ -+ return c; -+ } -+ -+ char * -+ add_var(kv, size, def) -+ struct ctl_var **kv; -+ unsigned long size; -+ int def; -+ { -+ register unsigned long c; -+ register struct ctl_var *k; -+ -+ c = count_var(*kv); -+ -+ k = *kv; -+ *kv = (struct ctl_var *)emalloc((c+2)*sizeof(struct ctl_var)); -+ if (k) -+ { -+ bcopy((char *)k, (char *)*kv, sizeof(struct ctl_var)*c); -+ free((char *)k); -+ } -+ -+ (*kv)[c].code = c; -+ (*kv)[c].text = (char *)emalloc(size); -+ (*kv)[c].flags = def; -+ (*kv)[c+1].code = 0; -+ (*kv)[c+1].text = (char *)0; -+ (*kv)[c+1].flags = EOV; -+ return (*kv)[c].text; -+ } -+ -+ void -+ set_var(kv, data, size, def) -+ struct ctl_var **kv; -+ char *data; -+ unsigned long size; -+ int def; -+ { -+ register struct ctl_var *k; -+ register char *s, *t; -+ -+ if (!data || !size) -+ return; -+ -+ if ((k = *kv)) -+ { -+ while (!(k->flags & EOV)) -+ { -+ s = data; -+ t = k->text; -+ if (t) -+ { -+ while (*t != '=' && *s - *t == 0) -+ { -+ s++; -+ t++; -+ } -+ if (*s == *t && ((*t == '=') || !*t)) -+ { -+ free(k->text); -+ k->text = (char *)emalloc(size); -+ bcopy(data, k->text, size); -+ k->flags = def; -+ return; -+ } -+ } -+ else -+ { -+ k->text = (char *)emalloc(size); -+ bcopy(data, k->text, size); -+ k->flags = def; -+ return; -+ } -+ k++; -+ } -+ } -+ t = add_var(kv, size, def); -+ bcopy(data, t, size); -+ } -+ -+ void -+ set_sys_var(data, size, def) -+ char *data; -+ unsigned long size; -+ int def; -+ { -+ set_var(&ext_sys_var, data, size, def); -+ } -+ -+ void -+ free_varlist(kv) -+ struct ctl_var *kv; -+ { -+ struct ctl_var *k; -+ if (kv) -+ { -+ for (k = kv; !(k->flags & EOV); k++) -+ free(k->text); -+ free((char *)kv); -+ } -+ } -diff -c xntpd/ntp_filegen.c:1.1.1.5 xntpd/ntp_filegen.c:3.12 -*** xntpd/ntp_filegen.c:1.1.1.5 Wed Jan 26 21:53:04 1994 ---- xntpd/ntp_filegen.c Wed Jan 26 21:53:04 1994 -*************** -*** 1,5 **** - /* -! * ntp_filegen.c,v 3.10 1993/12/03 03:55:35 pruy Exp - * - * implements file generations support for NTP - * logfiles and statistic files ---- 1,5 ---- - /* -! * ntp_filegen.c,v 3.12 1994/01/25 19:06:11 kardel Exp - * - * implements file generations support for NTP - * logfiles and statistic files -diff -c xntpd/ntp_request.c:1.1.1.13 xntpd/ntp_request.c:3.13 -*** xntpd/ntp_request.c:1.1.1.13 Wed Jan 26 21:53:18 1994 ---- xntpd/ntp_request.c Wed Jan 26 21:53:18 1994 -*************** -*** 2111,2116 **** ---- 2111,2119 ---- - req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA); - return; - } -+ -+ clock.kv_list = (struct ctl_var *)0; -+ - refclock_control(&addr, (struct refclockstat *)0, &clock); - - ic->clockadr = addr.sin_addr.s_addr; -*************** -*** 2128,2133 **** ---- 2131,2138 ---- - ic->fudgeval1 = htonl(clock.fudgeval1); - ic->fudgeval2 = htonl(clock.fudgeval2); - -+ free_varlist(clock.kv_list); -+ - ic = (struct info_clock *)more_pkt(); - } - flush_pkt(); -diff -c xntpd/refclock_parse.c:1.1.1.9 xntpd/refclock_parse.c:3.45 -*** xntpd/refclock_parse.c:1.1.1.9 Wed Jan 26 21:53:39 1994 ---- xntpd/refclock_parse.c Wed Jan 26 21:53:39 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.43 1994/01/23 16:28:39 kardel Exp - * -! * refclock_parse.c,v 3.43 1994/01/23 16:28:39 kardel Exp - * - * generic reference clock driver for receivers - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp - * -! * refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp - * - * generic reference clock driver for receivers - * -*************** -*** 129,135 **** - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.43 1994/01/23 16:28:39 kardel Exp"; - #endif - - /**=========================================================================== ---- 129,135 ---- - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp"; - #endif - - /**=========================================================================== -*************** -*** 243,248 **** ---- 243,249 ---- - * clock specific configuration - */ - l_fp basedelay; /* clock local phase offset */ -+ l_fp ppsdelay; /* clock local pps phase offset */ - - /* - * clock state handling/reporting -*************** -*** 295,300 **** ---- 296,302 ---- - #define NO_END (void (*)())0 - #define NO_DATA (void *)0 - #define NO_FORMAT "" -+ #define NO_PPSDELAY 0 - - #define DCF_ID "DCF" /* generic DCF */ - #define DCF_A_ID "DCFa" /* AM demodulation */ -*************** -*** 497,502 **** ---- 499,505 ---- - void *cl_data; /* local data area for "poll" mechanism */ - u_fp cl_rootdelay; /* rootdelay */ - U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional part */ -+ U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional part */ - char *cl_id; /* ID code (usually "DCF") */ - char *cl_description; /* device name */ - char *cl_format; /* fixed format */ -*************** -*** 516,521 **** ---- 519,525 ---- - NO_DATA, - DCFPZF535_ROOTDELAY, - DCFPZF535_BASEDELAY, -+ NO_PPSDELAY, - DCF_P_ID, - DCFPZF535_DESCRIPTION, - NO_FORMAT, -*************** -*** 534,539 **** ---- 538,544 ---- - NO_DATA, - DCFPZF535OCXO_ROOTDELAY, - DCFPZF535OCXO_BASEDELAY, -+ NO_PPSDELAY, - DCF_P_ID, - DCFPZF535OCXO_DESCRIPTION, - NO_FORMAT, -*************** -*** 552,557 **** ---- 557,563 ---- - NO_DATA, - DCFUA31_ROOTDELAY, - DCFUA31_BASEDELAY, -+ NO_PPSDELAY, - DCF_A_ID, - DCFUA31_DESCRIPTION, - NO_FORMAT, -*************** -*** 570,575 **** ---- 576,582 ---- - NO_DATA, - DCF7000_ROOTDELAY, - DCF7000_BASEDELAY, -+ NO_PPSDELAY, - DCF_A_ID, - DCF7000_DESCRIPTION, - NO_FORMAT, -*************** -*** 588,593 **** ---- 595,601 ---- - WSDCF_DATA, - WSDCF_ROOTDELAY, - WSDCF_BASEDELAY, -+ NO_PPSDELAY, - DCF_A_ID, - WSDCF_DESCRIPTION, - WSDCF_FORMAT, -*************** -*** 606,611 **** ---- 614,620 ---- - NO_DATA, - RAWDCF_ROOTDELAY, - CONRAD_BASEDELAY, -+ NO_PPSDELAY, - DCF_A_ID, - CONRAD_DESCRIPTION, - RAWDCF_FORMAT, -*************** -*** 624,629 **** ---- 633,639 ---- - NO_DATA, - RAWDCF_ROOTDELAY, - TIMEBRICK_BASEDELAY, -+ NO_PPSDELAY, - DCF_A_ID, - TIMEBRICK_DESCRIPTION, - RAWDCF_FORMAT, -*************** -*** 642,647 **** ---- 652,658 ---- - GPS166_DATA, - GPS166_ROOTDELAY, - GPS166_BASEDELAY, -+ NO_PPSDELAY, - GPS166_ID, - GPS166_DESCRIPTION, - GPS166_FORMAT, -*************** -*** 660,665 **** ---- 671,677 ---- - TRIMBLESV6_DATA, - TRIMBLESV6_ROOTDELAY, - TRIMBLESV6_BASEDELAY, -+ NO_PPSDELAY, - TRIMBLESV6_ID, - TRIMBLESV6_DESCRIPTION, - TRIMBLESV6_FORMAT, -*************** -*** 2198,2203 **** ---- 2210,2218 ---- - parse->basedelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ - parse->basedelay.l_uf = parse->parse_type->cl_basedelay; - -+ parse->ppsdelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ -+ parse->ppsdelay.l_uf = parse->parse_type->cl_ppsdelay; -+ - peer->rootdelay = parse->parse_type->cl_rootdelay; - peer->sstclktype = parse->parse_type->cl_type; - peer->precision = sys_precision; -*************** -*** 2554,2559 **** ---- 2569,2575 ---- - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; -+ out->kv_list = (struct ctl_var *)0; - } - - if (unit >= MAXUNITS) -*************** -*** 2579,2585 **** - - if (in->haveflags & CLK_HAVETIME2) - { -! /* not USED */ - } - - if (in->haveflags & CLK_HAVEVAL1) ---- 2595,2601 ---- - - if (in->haveflags & CLK_HAVETIME2) - { -! parse->ppsdelay = in->fudgetime2; - } - - if (in->haveflags & CLK_HAVEVAL1) -*************** -*** 2619,2637 **** - if (out) - { - register unsigned LONG sum = 0; -! register char *t; - register struct tm *tm; - register short utcoff; - register char sign; - register int i; - time_t tim; - -! out->haveflags = CLK_HAVETIME1|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3; - out->clockdesc = parse->parse_type->cl_description; - - out->fudgetime1 = parse->basedelay; - -! L_CLR(&out->fudgetime2); - - out->fudgeval1 = (LONG)parse->peer->stratum; - ---- 2635,2655 ---- - if (out) - { - register unsigned LONG sum = 0; -! register char *t, *tt; - register struct tm *tm; - register short utcoff; - register char sign; - register int i; - time_t tim; - -! outstatus[0] = '\0'; -! -! out->haveflags = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3; - out->clockdesc = parse->parse_type->cl_description; - - out->fudgetime1 = parse->basedelay; - -! out->fudgetime2 = parse->ppsdelay; - - out->fudgeval1 = (LONG)parse->peer->stratum; - -*************** -*** 2657,2667 **** - */ - off = parse->time.parse_stime.fp; - L_SUB(&off, &parse->time.parse_ptime.fp); /* true offset */ -! out->fudgetime2 = off; -! out->haveflags |= CLK_HAVETIME2; - } - } - - /* - * all this for just finding out the +-xxxx part (there are always - * new and changing fields in the standards 8-(). ---- 2675,2691 ---- - */ - off = parse->time.parse_stime.fp; - L_SUB(&off, &parse->time.parse_ptime.fp); /* true offset */ -! tt = add_var(&out->kv_list, 40, RO); -! sprintf(tt, "refclock_ppsskew=%s", lfptoms(&off, 6)); - } - } - -+ if (PARSE_PPS(parse->time.parse_state)) -+ { -+ tt = add_var(&out->kv_list, 80, RO|DEF); -+ sprintf(tt, "refclock_ppstime=\"%s\"", prettydate(&parse->time.parse_ptime.fp)); -+ } -+ - /* - * all this for just finding out the +-xxxx part (there are always - * new and changing fields in the standards 8-(). -*************** -*** 2686,2702 **** - sign = '+'; - } - -! tim = parse->time.parse_time.fp.l_ui - JAN_1970; -! strcpy(outstatus, ctime(&tim)); -! t = strrchr(outstatus, '\n'); -! if (!t) - { -! t = outstatus + strlen(outstatus); -! } - else - { -! sprintf(t, " %c%02d%02d", sign, utcoff / 60, utcoff % 60); -! t += strlen(t); - } - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) ---- 2710,2729 ---- - sign = '+'; - } - -! tt = add_var(&out->kv_list, 128, RO|DEF); -! sprintf(tt, "refclock_time=\""); -! tt += strlen(tt); -! -! if (parse->time.parse_time.fp.l_ui == 0) - { -! strcpy(tt, "\""); -! } - else - { -! strcpy(tt, prettydate(&parse->time.parse_time.fp)); -! t = tt + strlen(tt); -! -! sprintf(t, " (%c%02d%02d)\"", sign, utcoff / 60, utcoff % 60); - } - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) -*************** -*** 2705,2731 **** - } - else - { - /* - * copy PPS flags from last read transaction (informational only) - */ - tmpctl.parsegettc.parse_state |= parse->time.parse_state & - (PARSEB_PPS|PARSEB_S_PPS); - -! if (t) -! { -! *t = ' '; -! (void) parsestate(tmpctl.parsegettc.parse_state, t+1); -! } -! else -! { -! strcat(outstatus, " "); -! (void) parsestate(tmpctl.parsegettc.parse_state, outstatus + strlen(outstatus)); -! } -! strcat(outstatus," <"); - if (tmpctl.parsegettc.parse_count) -! mkascii(outstatus+strlen(outstatus), sizeof(outstatus) - strlen(outstatus) - 1, - tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1); -! strcat(outstatus,">"); - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - ---- 2732,2755 ---- - } - else - { -+ tt = add_var(&out->kv_list, 128, RO|DEF); -+ sprintf(tt, "refclock_status=\""); -+ tt += strlen(tt); -+ - /* - * copy PPS flags from last read transaction (informational only) - */ - tmpctl.parsegettc.parse_state |= parse->time.parse_state & - (PARSEB_PPS|PARSEB_S_PPS); - -! (void) parsestate(tmpctl.parsegettc.parse_state, tt); -! -! strcat(tt, "\""); -! - if (tmpctl.parsegettc.parse_count) -! mkascii(outstatus+strlen(outstatus), sizeof(outstatus)- strlen(outstatus) - 1, - tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1); -! - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - -*************** -*** 2737,2752 **** - } - else - { -! strcat(outstatus," ("); -! strncat(outstatus, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count); -! strcat(outstatus,")"); - } - - /* - * gather state statistics - */ - -! t = outstatus + strlen(outstatus); - - for (i = 0; i <= CEVNT_MAX; i++) - { ---- 2761,2780 ---- - } - else - { -! tt = add_var(&out->kv_list, 80, RO|DEF); -! sprintf(tt, "refclock_format=\""); -! -! strncat(tt, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count); -! strcat(tt,"\""); - } - - /* - * gather state statistics - */ - -! tt = add_var(&out->kv_list, 200, RO|DEF); -! strcpy(tt, "refclock_states=\""); -! tt += strlen(tt); - - for (i = 0; i <= CEVNT_MAX; i++) - { -*************** -*** 2769,2787 **** - - if (stime) - { -! sprintf(t, "%s%s%s: %s (%d.%02d%%)", -! sum ? "; " : " [", - (parse->status == i) ? "*" : "", - clockstatus(i), - l_mktime(stime), - percent / 100, percent % 100); - sum += stime; -! t += strlen(t); - } - } - -! sprintf(t, "; running time: %s]", l_mktime(sum)); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; - out->timereset = parse->timestarted; ---- 2797,2824 ---- - - if (stime) - { -! sprintf(tt, "%s%s%s: %s (%d.%02d%%)", -! sum ? "; " : "", - (parse->status == i) ? "*" : "", - clockstatus(i), - l_mktime(stime), - percent / 100, percent % 100); - sum += stime; -! tt += strlen(tt); - } - } - -! sprintf(tt, "; running time: %s\"", l_mktime(sum)); -! -! tt = add_var(&out->kv_list, 32, RO); -! sprintf(tt, "refclock_id=\"%s\"", parse->parse_type->cl_id); - -+ tt = add_var(&out->kv_list, 80, RO); -+ sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); -+ -+ tt = add_var(&out->kv_list, 128, RO); -+ sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp\""); -+ - out->lencode = strlen(outstatus); - out->lastcode = outstatus; - out->timereset = parse->timestarted; -*************** -*** 3086,3091 **** ---- 3123,3130 ---- - */ - offset = parsetime->parse_ptime.fp; - -+ L_ADD(&offset, &parse->ppsdelay); -+ - if (PARSE_TIMECODE(parsetime->parse_state)) - { - if (M_ISGEQ(off.l_i, off.l_f, -1, 0x80000000) && -*************** -*** 3353,3358 **** ---- 3392,3403 ---- - * History: - * - * refclock_parse.c,v -+ * Revision 3.45 1994/01/25 19:06:27 kardel -+ * 94/01/23 reconcilation -+ * -+ * Revision 3.44 1994/01/25 17:32:23 kardel -+ * settable extended variables -+ * - * Revision 3.43 1994/01/23 16:28:39 kardel - * HAVE_TERMIOS introduced - * -diff -c -r1.1.1.8 lib/numtohost.c -*** lib/numtohost.c:1.1.1.8 1994/01/26 20:12:51 ---- lib/numtohost.c 1994/01/26 21:17:01 -*************** -*** 1,6 **** ---- 1,7 ---- - /* numtohost.c,v 3.1 1993/07/06 01:08:40 jbj Exp - * numtohost - convert network number to host name. - */ -+ #include "ntp_types.h" - #include "ntp_string.h" - #include - diff --git a/usr.sbin/xntpd/patches/patch.30 b/usr.sbin/xntpd/patches/patch.30 deleted file mode 100644 index 55897f971755..000000000000 --- a/usr.sbin/xntpd/patches/patch.30 +++ /dev/null @@ -1,73 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa14619; 22 Mar 94 11:53 EST -Received: from jagubox.gsfc.nasa.gov by louie.udel.edu id aa24926; - 22 Mar 94 11:48 EST -Received: by jagubox.gsfc.nasa.gov (Smail3.1.28.1 #2) - id m0pj9dD-000C8UC; Tue, 22 Mar 94 11:48 EST -Message-Id: -From: Jim Jagielski -Subject: Small patch for xntpd 3.3p and A/UX (tickadj) -To: Mills@udel.edu -Date: Tue, 22 Mar 1994 11:48:42 -0500 (EST) -Reply-To: Jim Jagielski -In-Reply-To: <9308051324.aa24396@huey.udel.edu> from "Mills@udel.edu" at Aug 5, 93 01:24:24 pm -X-Mailer: ELM [version 2.4 PL23] -Content-Type: text -Content-Length: 1355 - -This little patch streamlines things a bit for tickadj and A/UX: - ------------>8 cut here -------------------------------- - -*** tickadj.c.orig Mon Mar 14 02:47:28 1994 ---- tickadj.c Tue Mar 22 11:41:19 1994 -*************** -*** 333,342 **** - - #if defined(SYS_AUX3) || defined(SYS_AUX2) - #define X_TICKADJ 0 -! #define X_V 1 -! #define X_TICK 2 - #define X_DEF -! static struct nlist nl[4]; - #endif - - #ifdef NeXT ---- 333,345 ---- - - #if defined(SYS_AUX3) || defined(SYS_AUX2) - #define X_TICKADJ 0 -! #define X_TICK 1 - #define X_DEF -! static struct nlist nl[] = -! { {"tickadj"}, -! {"tick"}, -! {""}, -! }; - #endif - - #ifdef NeXT -*************** -*** 428,440 **** - NULL - }; - struct stat stbuf; -- -- #if defined(SYS_AUX3) || defined(SYS_AUX2) -- strcpy (nl[X_TICKADJ].n_name, "tickadj"); -- strcpy (nl[X_V].n_name, "v"); -- strcpy (nl[X_TICK].n_name, "tick"); -- nl[3].n_name[0] = '\0'; -- #endif - - for (kname = kernels; *kname != NULL; kname++) { - if (stat(*kname, &stbuf) == -1) ---- 431,436 ---- ------------>8 cut here -------------------------------- --- -#include - Jim Jagielski | - jim@jagubox.gsfc.nasa.gov | "Dead or alive, you're coming with me." - NASA/GSFC, Code 734.4 | RoboCop - Greenbelt, MD 20771 | - diff --git a/usr.sbin/xntpd/patches/patch.31 b/usr.sbin/xntpd/patches/patch.31 deleted file mode 100644 index 33048f9de143..000000000000 --- a/usr.sbin/xntpd/patches/patch.31 +++ /dev/null @@ -1,83 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa12734; 27 Mar 94 8:52 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa20329; - 27 Mar 94 8:48 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA05771 (5.65c-6/7.3v-FAU); Sun, 27 Mar 1994 15:48:38 +0200 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA01229 (5.65c-6/7.3m-FAU); Sun, 27 Mar 1994 14:48:37 +0100 -From: Frank Kardel -Message-Id: <199403271348.AA01229@faui43.informatik.uni-erlangen.de> -Subject: minor patches -To: mills@udel.edu -Date: Sun, 27 Mar 94 15:48:32 MET DST -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave, - -I just got through manually read news (in the spool area 8-( - when -will they ever fix our news installation). - -In order to avoid ptx being picked up in AT&T machine i added hope-fully -an additional check. Why do vendor have to make machine look the -same when they aren't ? I though uname was supposed to find out - I -guess I was wrong - every vendor seems to have his own ideas about -uname and they all do not mix very well. - -The fix to numtohost allows it to compile on ptx - I hope it still -compiles on all others (should though). - -diff -c lib/numtohost.c:1.1.1.9 lib/numtohost.c:3.7 -*** lib/numtohost.c:1.1.1.9 Sun Mar 27 15:36:54 1994 ---- lib/numtohost.c Sun Mar 27 15:36:54 1994 -*************** -*** 1,12 **** -! /* numtohost.c,v 3.1 1993/07/06 01:08:40 jbj Exp - * numtohost - convert network number to host name. - */ -- #include "ntp_types.h" - #include - - #include "ntp_fp.h" -- #include "lib_strbuf.h" - #include "ntp_stdlib.h" - - #define LOOPBACKNET 0x7f000000 - #define LOOPBACKHOST 0x7f000001 ---- 1,11 ---- -! /* - * numtohost - convert network number to host name. - */ - #include - - #include "ntp_fp.h" - #include "ntp_stdlib.h" -+ #include "lib_strbuf.h" - - #define LOOPBACKNET 0x7f000000 - #define LOOPBACKHOST 0x7f000001 -diff -c scripts/Guess.sh:1.1.1.8 scripts/Guess.sh:1.13 -*** scripts/Guess.sh:1.1.1.8 Sun Mar 27 15:38:53 1994 ---- scripts/Guess.sh Sun Mar 27 15:38:53 1994 -*************** -*** 78,84 **** - 3.2.*) - case "$4" in - v*) -! (i386) >/dev/null 2>&1 && guess=ptx;; - esac - esac - fi ---- 78,84 ---- - 3.2.*) - case "$4" in - v*) -! (i386) >/dev/null 2>&1 && [ -f /usr/lib/libseq.a ] && guess=ptx;; - esac - esac - fi --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.32 b/usr.sbin/xntpd/patches/patch.32 deleted file mode 100644 index 2e951cb73ef8..000000000000 --- a/usr.sbin/xntpd/patches/patch.32 +++ /dev/null @@ -1,89 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa12910; 27 Mar 94 10:06 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa22473; - 27 Mar 94 10:05 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA09307 (5.65c-6/7.3v-FAU); Sun, 27 Mar 1994 17:05:03 +0200 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA05359 (5.65c-6/7.3m-FAU); Sun, 27 Mar 1994 16:05:01 +0100 -From: Frank Kardel -Message-Id: <199403271505.AA05359@faui43.informatik.uni-erlangen.de> -Subject: more PTX related patches... -To: mills@udel.edu -Date: Sun, 27 Mar 94 17:04:56 MET DST -X-Mailer: ELM [version 2.3 PL11] - -Hi, Dave ! - -And another patche to make parse compile on PTX (Sequents -SysVR2 version). - -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/parse/parse.c,v -retrieving revision 3.23 -retrieving revision 3.24 -diff -c -r3.23 -r3.24 -*** parse/parse.c:3.23 1994/03/25 13:09:02 ---- parse/parse.c 1994/03/27 15:01:36 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp - * -! * parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp - * - * Parser module for reference clock - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.24 1994/03/27 15:01:36 kardel Exp - * -! * parse.c,v 3.24 1994/03/27 15:01:36 kardel Exp - * - * Parser module for reference clock - * -*************** -*** 29,34 **** ---- 29,38 ---- - #include "sys/time.h" - #include "sys/errno.h" - -+ #include "ntp_fp.h" -+ #include "ntp_unixtime.h" -+ #include "ntp_calendar.h" -+ - #include "ntp_machine.h" - - #if defined(PARSESTREAM) && (defined(SYS_SUNOS4) || defined(SYS_SOLARIS)) && defined(STREAM) -*************** -*** 49,58 **** - #endif - #endif - -- #include "ntp_fp.h" -- #include "ntp_unixtime.h" -- #include "ntp_calendar.h" -- - #include "parse.h" - - #include "ntp_stdlib.h" ---- 53,58 ---- -*************** -*** 1162,1167 **** ---- 1162,1170 ---- - * History: - * - * parse.c,v -+ * Revision 3.24 1994/03/27 15:01:36 kardel -+ * reorder include file to cope with PTX -+ * - * Revision 3.23 1994/03/25 13:09:02 kardel - * considering FIXEDONLY entries only in FIXEDONLY mode - * --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.33 b/usr.sbin/xntpd/patches/patch.33 deleted file mode 100644 index e7d193409b6c..000000000000 --- a/usr.sbin/xntpd/patches/patch.33 +++ /dev/null @@ -1,75 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa13737; 27 Mar 94 15:27 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa29101; - 27 Mar 94 15:23 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA24270 (5.65c-6/7.3v-FAU); Sun, 27 Mar 1994 22:23:35 +0200 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA07515 (5.65c-6/7.3m-FAU); Sun, 27 Mar 1994 21:23:34 +0100 -From: Frank Kardel -Message-Id: <199403272023.AA07515@faui43.informatik.uni-erlangen.de> -Subject: and for patch 33? -To: mills@udel.edu -Date: Sun, 27 Mar 94 22:23:30 MET DST -X-Mailer: ELM [version 2.3 PL11] - -This should get you to Patch 33. or higher. - - gcc 2.5.8 (from Per Hedeland - gcc 2.5.8 is just - causing to many poeple to complain 8-()_ - - a an note what one can do in Config.local in HACKermode. - -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/RELNOTES,v -retrieving revision 1.1.1.11 -diff -c -r1.1.1.11 RELNOTES -*** 1.1.1.11 1994/01/30 17:08:20 ---- RELNOTES 1994/03/27 19:40:27 -*************** -*** 31,36 **** ---- 31,40 ---- - For custom tailored configuration copying Config.local.dist to Config.local - and editing Config.local to suit the local needs is neccessary (at most - 3 lines to change), or use one of the make's above and then tweak it. -+ Config.local can also be used to override common settings from the -+ machines/* files like the AUTHDEFS= to select very specific configurations. -+ Please use this feature with care and don't be disappointed if it doesn't -+ work the way you expect. - - (2) Type "make" to compile everything of general interest. Expect few or - no warnings using cc and a moderate level of warnings using gcc. -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/include/l_stdlib.h,v -retrieving revision 1.1.1.6 -diff -c -r1.1.1.6 l_stdlib.h -*** include/l_stdlib.h:1.1.1.6 1994/01/28 13:07:49 ---- include/l_stdlib.h 1994/03/27 19:34:40 -*************** -*** 70,80 **** - - extern int close P((int)); - extern int ioctl P((int, int, char *)); -! extern int read P((int, char *, unsigned)); - extern int rename P((char *, char *)); -! extern int write P((int, char *, int)); -! extern int unlink P((char *)); -! extern int link P((char *, char *)); - - #ifdef FILE - extern int fclose P((FILE *)); ---- 70,80 ---- - - extern int close P((int)); - extern int ioctl P((int, int, char *)); -! extern int read P((int, void *, unsigned)); - extern int rename P((char *, char *)); -! extern int write P((int, const void *, unsigned)); -! extern int unlink P((const char *)); -! extern int link P((const char *, const char *)); - - #ifdef FILE - extern int fclose P((FILE *)); --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.34 b/usr.sbin/xntpd/patches/patch.34 deleted file mode 100644 index a3828895ab86..000000000000 --- a/usr.sbin/xntpd/patches/patch.34 +++ /dev/null @@ -1,303 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa02155; 25 Mar 94 8:47 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa05544; - 25 Mar 94 8:45 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA27199 (5.65c-6/7.3v-FAU); Fri, 25 Mar 1994 14:45:13 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA06935 (5.65c-6/7.3m-FAU); Fri, 25 Mar 1994 14:45:11 +0100 -From: Frank Kardel -Message-Id: <199403251345.AA06935@faui43.informatik.uni-erlangen.de> -Subject: bugfixes for parse & ntpq enhancements -To: mills@udel.edu -Date: Fri, 25 Mar 94 14:45:05 MET -X-Mailer: ELM [version 2.3 PL11] - -Hi Dave, - -I have a 2 bug fixes and an ntpq enhancement: - - parse bitmap initialisation fixed - - allow for large offsets in refclock_parse (>4 min 8-() - - decode the flash bits in cooked mode - -diff -c ntpq/ntpq.c:1.1.1.21 ntpq/ntpq.c:3.22 -*** ntpq/ntpq.c:1.1.1.21 Fri Mar 25 14:32:38 1994 ---- ntpq/ntpq.c Fri Mar 25 14:32:38 1994 -*************** -*** 75,80 **** ---- 75,81 ---- - #define OC 12 /* integer, print in octal */ - #define MD 13 /* mode */ - #define AR 14 /* array of times */ -+ #define TST 15 /* test flags */ - #define EOV 255 /* end of table */ - - -*************** -*** 145,151 **** - { CP_RECEIVED, UI, "received" }, /* 31 */ - { CP_SENT, UI, "sent" }, /* 32 */ - { CP_FILTERROR, AR, "filterror" }, /* 33 */ -! { CP_FLASH, ST, "flash"}, /* 34 */ - { CP_DISP, AR, "disp" }, /* 35 */ - /* - * These are duplicate entires so that we can ---- 146,152 ---- - { CP_RECEIVED, UI, "received" }, /* 31 */ - { CP_SENT, UI, "sent" }, /* 32 */ - { CP_FILTERROR, AR, "filterror" }, /* 33 */ -! { CP_FLASH, TST, "flash"}, /* 34 */ - { CP_DISP, AR, "disp" }, /* 35 */ - /* - * These are duplicate entires so that we can -*************** -*** 189,194 **** ---- 190,209 ---- - }; - - /* -+ * flasher bits -+ */ -+ static char *tstflagnames[] = { -+ "DUPLICATE PKT", -+ "BOGUS PKT", -+ "PROTO UNSYNC", -+ "PEER BOUNDS", -+ "BAD AUTH", -+ "PEER CLOCK UNSYNC", -+ "BAD STRATUM", -+ "ROOT BOUNDS" -+ }; -+ -+ /* - * Leap values - */ - struct codestring leap_codes[] = { -*************** -*** 2836,2842 **** - output(fp, name, buf); - } - -! - - /* - * cookedprint - output variables in cooked mode ---- 2851,2895 ---- - output(fp, name, buf); - } - -! static char * -! tstflags(val) -! U_LONG val; -! { -! register char *cb, *s; -! register int i; -! register char *sep; -! -! sep = ""; -! i = 0; -! s = cb = &circ_buf[nextcb][0]; -! if (++nextcb >= NUMCB) -! nextcb = 0; -! -! sprintf(cb, "0x%x", val); -! cb += strlen(cb); -! if (val <= ((1<<8)-1)) { -! if (!val) { -! strcat(cb, ""); -! cb += strlen(cb); -! } else { -! *cb++ = '<'; -! while (val) { -! if (val & 0x1) { -! sprintf(cb, "%s%s", sep, tstflagnames[i]); -! sep = ";"; -! cb += strlen(cb); -! } -! i++; -! val >>= 1; -! } -! *cb++ = '>'; -! } -! } else { -! *cb++ = '?'; -! } -! *cb = '\0'; -! return s; -! } - - /* - * cookedprint - output variables in cooked mode -*************** -*** 2994,2999 **** ---- 3047,3059 ---- - outputarr(fp, name, narr, lfparr); - break; - -+ case TST: -+ if (!decodeuint(value, &uval)) -+ output_raw = '?'; -+ else -+ output(fp, name, tstflags(uval)); -+ break; -+ - default: - (void) fprintf(stderr, - "Internal error in cookedprint, %s=%s, fmt %d\n", -diff -c parse/parse.c:1.1.1.10 parse/parse.c:3.23 -*** parse/parse.c:1.1.1.10 Fri Mar 25 14:33:02 1994 ---- parse/parse.c Fri Mar 25 14:33:02 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * -! * parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp - * - * Parser module for reference clock - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp - * -! * parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp - * - * Parser module for reference clock - * -*************** -*** 178,183 **** ---- 178,187 ---- - { - fmt = clockformats[i]; - -+ if (!(parseio->parse_flags & PARSE_FIXED_FMT) && -+ (fmt->flags & CVT_FIXEDONLY)) -+ continue; -+ - if (fmt->flags & F_START) - { - index = fmt->startsym / 8; -*************** -*** 1158,1163 **** ---- 1162,1170 ---- - * History: - * - * parse.c,v -+ * Revision 3.23 1994/03/25 13:09:02 kardel -+ * considering FIXEDONLY entries only in FIXEDONLY mode -+ * - * Revision 3.22 1994/02/25 12:34:49 kardel - * allow for converter generated utc times - * -diff -c xntpd/refclock_parse.c:1.1.1.13 xntpd/refclock_parse.c:3.53 -*** xntpd/refclock_parse.c:1.1.1.13 Fri Mar 25 14:35:07 1994 ---- xntpd/refclock_parse.c Fri Mar 25 14:35:08 1994 -*************** -*** 1,8 **** - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * -! * refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp - * - * generic reference clock driver for receivers - * ---- 1,8 ---- - #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) - /* -! * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp - * -! * refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp - * - * generic reference clock driver for receivers - * -*************** -*** 129,135 **** - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp"; - #endif - - /**=========================================================================== ---- 129,135 ---- - #include "parse.h" - - #if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -! static char rcsid[]="refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp"; - #endif - - /**=========================================================================== -*************** -*** 2824,2830 **** - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; ---- 2824,2830 ---- - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); -! sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; -*************** -*** 3103,3109 **** - L_ADD(&off, &offset); - rectime = off; /* this makes org time and xmt time somewhat artificial */ - -! if (parse->flags & PARSE_STAT_FILTER) - { - struct timeval usecerror; - /* ---- 3103,3113 ---- - L_ADD(&off, &offset); - rectime = off; /* this makes org time and xmt time somewhat artificial */ - -! L_SUB(&off, &parsetime->parse_stime.fp); -! -! if ((parse->flags & PARSE_STAT_FILTER) && -! (off.l_i > -60) && -! (off.l_i < 60)) /* take usec error only if within +- 60 secs */ - { - struct timeval usecerror; - /* -*************** -*** 3115,3124 **** - sTVTOTS(&usecerror, &off); - L_ADD(&off, &offset); - } -- else -- { -- L_SUB(&off, &parsetime->parse_stime.fp); -- } - } - - if (PARSE_PPS(parsetime->parse_state) && CL_PPS(parse->unit)) ---- 3119,3124 ---- -*************** -*** 3409,3414 **** ---- 3409,3420 ---- - * History: - * - * refclock_parse.c,v -+ * Revision 3.53 1994/03/25 13:07:39 kardel -+ * fixed offset calculation for large (>4 Min) offsets -+ * -+ * Revision 3.52 1994/03/03 09:58:00 kardel -+ * stick -kv in cvs is no fun -+ * - * Revision 3.49 1994/02/20 13:26:00 kardel - * rcs id cleanup - * --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.35 b/usr.sbin/xntpd/patches/patch.35 deleted file mode 100644 index e6b1ea4436d7..000000000000 --- a/usr.sbin/xntpd/patches/patch.35 +++ /dev/null @@ -1,914 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa25410; 3 Apr 94 18:04 EDT -Received: from adrastea.lcs.mit.edu by louie.udel.edu id aa09227; - 3 Apr 94 17:56 EDT -Received: by adrastea.lcs.mit.edu; id AA26407; Sun, 3 Apr 1994 17:56:48 -0400 -Date: Sun, 3 Apr 1994 17:56:48 -0400 -From: Garrett Wollman -Message-Id: <9404032156.AA26407@adrastea.lcs.mit.edu> -To: Dave Mills -Subject: xntpd 3.3p changes for FreeBSD - -This still doesn't solve the 18-second discrepancy. However, the -patch file below shows the current differences between xntp3.3p and -the FreeBSD version of same, deleted files not included. I have also -included the Makefiles that we use to provide some idea of our build -structure. (Thankfully, xntp---unlike some other popular pieces of -software---has a sane directory structure to begin with, so it isn't -nearly as difficult to handle this sort of thing than it is with, say, -GCC.) - -diff -c /dev/null 386BSD/src/contrib/xntpd/Makefile.inc:1.3 -*** /dev/null Sun Apr 3 13:42:15 1994 ---- 386BSD/src/contrib/xntpd/Makefile.inc Sun Apr 3 13:42:15 1994 -*************** -*** 0 **** ---- 1,7 ---- -+ DEFS_LOCAL=-DREFCLOCK -DPARSE -+ NTPDEFS= -DSYS_FREEBSD -DSYS_386BSD -DHAVE_TERMIOS -+ AUTHDEFS= -DMD5 -+ CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DAS2201 -DGOES -DGPSTM -DOMEGA \ -+ -DLEITCH -DTRAK -+ CFLAGS+= ${NTPDEFS} ${DEFS_LOCAL} ${AUTHDEFS} ${CLOCKDEFS} ${COPTS} -+ BINDIR?= /usr/sbin -diff -c /dev/null 386BSD/src/contrib/xntpd/README.FreeBSD:1.5 -*** /dev/null Sun Apr 3 13:42:15 1994 ---- 386BSD/src/contrib/xntpd/README.FreeBSD Sun Apr 3 13:42:15 1994 -*************** -*** 0 **** ---- 1,78 ---- -+ This version of NTP was converted to the BSD-style Makefile system by -+ Garrett Wollman (wollman@freefall.cdrom.com); it is based on version -+ 3.3p (late beta) from the University of Delaware. -+ -+ Besides the Makefile changes, the DES code has been completely removed -+ in order to make this code exportable. If you have a legal copy of -+ `authdes.c', you can just add it to the lib/ directory and add `-DDES' -+ to the AUTHDEFS in Makefile.inc. -+ -+ You can change CLOCKDEFS in the same file to add other reference clocks. -+ -+ ---------------------------------------------------- -+ Support for Conrad electronic's "DCF-77 Uhr, Mobil". -+ ---------------------------------------------------- -+ Conrad electronic in Germany,, Phone (+49) 962230111 (?), sells a gadget -+ called "DCF77 Uhr, mobil", which is a DCF77 timecode receiver with a -+ rs-232 interface. The price is around DM130. -+ 9-pin interface is Order# 97 94 57 66 -+ 25-pin interface is Order# 97 94 81 66 -+ -+ You must define -+ -DDCF77 -DPPS -DFREEBSD_CONRAD -DDEBUG -+ when you compile xntpd. You can later remove -DDEBUG, if you feel like it. -+ -+ You must also have -+ options COM_BIDIR -+ defined in your kernel, and finally the ttyport you intend to use must -+ have special interrupt vector: -+ device sio1 at isa? port "IO_COM2" tty irq 3 vector siointrts -+ ^^^^^^^^^^^^ -+ connect the radio-clock to the tty port and link it to /dev/refclock-0: -+ -+ cd /dev -+ sh MAKEDEV cua1 -+ ln -s /dev/cua01 /dev/refclock-0 -+ -+ make a directory to gather statistics in: -+ mkdir /var/tmp/ntp -+ -+ Create a /etc/ntp.conf along these lines: -+ -+ # DCF77 without PPS -+ server 127.127.8.20 -+ # DCF77 with PPS -+ #server 127.127.8.148 prefer -+ -+ driftfile /var/tmp/ntp/ntp.drift -+ statsdir /var/tmp/ntp -+ statistics loopstats -+ statistics peerstats -+ statistics clockstats -+ filegen peerstats file peerstats type day enable -+ filegen loopstats file loopstats type day enable -+ filegen clockstats file clockstats type day enable -+ -+ Try to start it: -+ comcontrol ttyd1 bidir -+ tickadj -A -+ xntpd -d -d -d -+ -+ You should see the red LED flash on the receiver every second now. You -+ may have to experiment a bit with the location, and possibly adjust the -+ minute variable resistor inside to get a good signal. Be aware, that just -+ because you see the light flash, is not the same as the signal being -+ received by the computer. The chip doing the work in the reciver uses -+ less than 1 micro-ampere, so even if RTS isn't pulled low, it will happily -+ receive, but be unable to buffer the signal to the rs-232 levels needed. -+ -+ You can see what's going on in /var/log/messages, and query the -+ daemon using xntpdc and ntpq, in particular the "clockvar" command -+ of ntpq will tell about the clocks healt. -+ -+ I live in Slagelse, Denmark, which is ~1000 Km from Mainflingen, yet -+ I have +/- 2 ms precision from this cheap gadget. If you have a very -+ stable signal, you can use the 'pps' address instead to improve your -+ timing. -+ -+ Have fun... Poul-Henning Kamp -diff -c /dev/null 386BSD/src/contrib/xntpd/authstuff/Makefile:1.2 -*** /dev/null Sun Apr 3 13:42:19 1994 ---- 386BSD/src/contrib/xntpd/authstuff/Makefile Sun Apr 3 13:42:20 1994 -*************** -*** 0 **** ---- 1,27 ---- -+ # -+ # $Id: Makefile,v 1.2 1993/12/22 11:32:10 rgrimes Exp $ -+ # -+ # Most of the programs in this directory are completely useless for the -+ # NTP configuration that we provide by default. -+ # We provide the `md5' program as a public service. -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= ${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= ${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= md5 -+ -+ SRCS= md5driver.c -+ NOMAN= -+ -+ install: -+ -+ .include -diff -c 386BSD/src/contrib/xntpd/authstuff/md5driver.c:1.1.1.2 386BSD/src/contrib/xntpd/authstuff/md5driver.c:1.2 -*** 386BSD/src/contrib/xntpd/authstuff/md5driver.c:1.1.1.2 Sun Apr 3 13:42:20 1994 ---- 386BSD/src/contrib/xntpd/authstuff/md5driver.c Sun Apr 3 13:42:20 1994 -*************** -*** 30,36 **** ---- 30,38 ---- - #endif /* SYS_BSDI */ - #include "md5.h" - -+ #ifndef MD5 - #define MD5 -+ #endif - #include "ntp_string.h" - #include "ntp_stdlib.h" - -diff -c /dev/null 386BSD/src/contrib/xntpd/clockstuff/Makefile:1.1 -*** /dev/null Sun Apr 3 13:42:21 1994 ---- 386BSD/src/contrib/xntpd/clockstuff/Makefile Sun Apr 3 13:42:21 1994 -*************** -*** 0 **** ---- 1,16 ---- -+ # -+ # $Id: Makefile,v 1.1 1993/12/21 21:06:24 wollman Exp $ -+ # -+ -+ PROG= propdelay -+ LIBADD= -L${.CURDIR}/../lib -lntp -lm -+ DPADD= ${.CURDIR}/../lib/libntp.a -+ -+ SRCS= propdelay.c -+ NOMAN= -+ -+ install: -+ -+ CLEANFILES+= chutest clktest chutest.o clktest.o -+ -+ .include -diff -c /dev/null 386BSD/src/contrib/xntpd/lib/Makefile:1.5 -*** /dev/null Sun Apr 3 13:43:01 1994 ---- 386BSD/src/contrib/xntpd/lib/Makefile Sun Apr 3 13:43:01 1994 -*************** -*** 0 **** ---- 1,30 ---- -+ # -+ # $Id: Makefile,v 1.5 1994/04/03 20:37:05 wollman Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ SRCS= atoint.c atolfp.c atouint.c auth12crypt.c authdecrypt.c authdes.c \ -+ authencrypt.c authkeys.c authparity.c authreadkeys.c authusekey.c \ -+ buftvtots.c caljulian.c calleapwhen.c caltontp.c calyearstart.c \ -+ clocktime.c dofptoa.c dolfptoa.c emalloc.c fptoa.c fptoms.c \ -+ gettstamp.c hextoint.c hextolfp.c humandate.c inttoa.c \ -+ lib_strbuf.c mfptoa.c mfptoms.c modetoa.c mstolfp.c \ -+ msutotsf.c netof.c numtoa.c refnumtoa.c numtohost.c octtoint.c \ -+ prettydate.c ranny.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \ -+ uglydate.c uinttoa.c utvtoa.c clocktypes.c \ -+ md5.c a_md5encrypt.c a_md5decrypt.c \ -+ a_md512crypt.c decodenetnum.c systime.c msyslog.c syssignal.c \ -+ findconfig.c getopt.c -+ -+ NOMAN= -+ NOPROFILE= -+ LIB= ntp -+ CLEANFILES+=authdes.c -+ -+ install: -+ -+ authdes.c: authdes.c.export -+ cp ${.CURDIR}/authdes.c.export authdes.c -+ -+ .include -diff -c /dev/null 386BSD/src/contrib/xntpd/ntpdate/Makefile:1.3 -*** /dev/null Sun Apr 3 13:43:27 1994 ---- 386BSD/src/contrib/xntpd/ntpdate/Makefile Sun Apr 3 13:43:27 1994 -*************** -*** 0 **** ---- 1,28 ---- -+ # -+ # $Id: Makefile,v 1.3 1993/12/22 11:32:56 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= ntpdate -+ MAN8= ${.CURDIR}/../doc/ntpdate.8 -+ CLEANFILES+= .version version.c -+ -+ SRCS= ntpdate.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion ntpdate -+ -+ .include -diff -c /dev/null 386BSD/src/contrib/xntpd/ntpq/Makefile:1.3 -*** /dev/null Sun Apr 3 13:43:28 1994 ---- 386BSD/src/contrib/xntpd/ntpq/Makefile Sun Apr 3 13:43:29 1994 -*************** -*** 0 **** ---- 1,29 ---- -+ # -+ # $Id: Makefile,v 1.3 1993/12/22 11:33:07 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= ntpq -+ MAN8= ${.CURDIR}/../doc/ntpq.8 -+ CLEANFILES+= .version version.c -+ BINDIR= /usr/bin -+ -+ SRCS= ntpq.c ntpq_ops.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion ntpq -+ -+ .include -diff -c 386BSD/src/contrib/xntpd/ntpq/ntpq.c:1.1.1.2 386BSD/src/contrib/xntpd/ntpq/ntpq.c:1.2 -*** 386BSD/src/contrib/xntpd/ntpq/ntpq.c:1.1.1.2 Sun Apr 3 13:43:30 1994 ---- 386BSD/src/contrib/xntpd/ntpq/ntpq.c Sun Apr 3 13:43:30 1994 -*************** -*** 301,307 **** - static int decodearr P((char *, int *, l_fp *)); - static char * getcode P((int, struct codestring *)); - static void help P((struct parse *, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) - static int helpsort P((const void *, const void *)); - #else - static int helpsort P((char **, char **)); ---- 301,307 ---- - static int decodearr P((char *, int *, l_fp *)); - static char * getcode P((int, struct codestring *)); - static void help P((struct parse *, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - static int helpsort P((const void *, const void *)); - #else - static int helpsort P((char **, char **)); -*************** -*** 335,341 **** - static void endoutput P((FILE *)); - static void outputarr P((FILE *, char *, int, l_fp *)); - static void cookedprint P((int, int, char *, int, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) - static int assoccmp P((const void *, const void *)); - #else - static int assoccmp P((struct association *, struct association *)); ---- 335,341 ---- - static void endoutput P((FILE *)); - static void outputarr P((FILE *, char *, int, l_fp *)); - static void cookedprint P((int, int, char *, int, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - static int assoccmp P((const void *, const void *)); - #else - static int assoccmp P((struct association *, struct association *)); -*************** -*** 1888,1894 **** - for (xcp = opcmds; xcp->keyword != 0; xcp++) - cmdsort[n++] = xcp->keyword; - -! #if defined(sgi) || defined(SYS_BSDI) - qsort((void *)cmdsort, n, sizeof(char *), helpsort); - #else - qsort((char *)cmdsort, n, sizeof(char *), helpsort); ---- 1888,1894 ---- - for (xcp = opcmds; xcp->keyword != 0; xcp++) - cmdsort[n++] = xcp->keyword; - -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - qsort((void *)cmdsort, n, sizeof(char *), helpsort); - #else - qsort((char *)cmdsort, n, sizeof(char *), helpsort); -*************** -*** 1934,1940 **** - * helpsort - do hostname qsort comparisons - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) - helpsort(t1, t2) - const void *t1; - const void *t2; ---- 1934,1940 ---- - * helpsort - do hostname qsort comparisons - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - helpsort(t1, t2) - const void *t1; - const void *t2; -*************** -*** 3028,3034 **** - sortassoc() - { - if (numassoc > 1) -! #if defined(sgi) || defined(SYS_BSDI) - qsort((void *)assoc_cache, numassoc, - sizeof(struct association), assoccmp); - #else ---- 3028,3034 ---- - sortassoc() - { - if (numassoc > 1) -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - qsort((void *)assoc_cache, numassoc, - sizeof(struct association), assoccmp); - #else -*************** -*** 3042,3048 **** - * assoccmp - compare two associations - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) - assoccmp(t1, t2) - const void *t1; - const void *t2; ---- 3042,3048 ---- - * assoccmp - compare two associations - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - assoccmp(t1, t2) - const void *t1; - const void *t2; -diff -c /dev/null 386BSD/src/contrib/xntpd/ntptrace/Makefile:1.2 -*** /dev/null Sun Apr 3 13:43:31 1994 ---- 386BSD/src/contrib/xntpd/ntptrace/Makefile Sun Apr 3 13:43:31 1994 -*************** -*** 0 **** ---- 1,28 ---- -+ # -+ # $Id: Makefile,v 1.2 1993/12/22 11:33:14 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= ntptrace -+ MAN8= ${.CURDIR}/../doc/ntptrace.8 -+ CLEANFILES+= .version version.c -+ -+ SRCS= ntptrace.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion ntptrace -+ -+ .include -diff -c /dev/null 386BSD/src/contrib/xntpd/parse/Makefile:1.1 -*** /dev/null Sun Apr 3 13:43:32 1994 ---- 386BSD/src/contrib/xntpd/parse/Makefile Sun Apr 3 13:43:32 1994 -*************** -*** 0 **** ---- 1,19 ---- -+ # -+ # $Id: Makefile,v 1.1 1993/12/21 20:04:14 wollman Exp $ -+ # -+ -+ PARSEFLAGS= -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_MEINBERG \ -+ -DCLOCK_RAWDCF -DCLOCK_TRIMSV6 -+ -+ CFLAGS+= -I${.CURDIR}/../include ${PARSEFLAGS} -+ -+ SRCS= parse.c parse_conf.c clk_meinberg.c clk_schmid.c clk_rawdcf.c \ -+ clk_dcf7000.c clk_trimble.c -+ -+ NOMAN= -+ NOPROFILE= -+ LIB= parse -+ -+ install: -+ -+ .include -diff -c 386BSD/src/contrib/xntpd/scripts/mkversion:1.1.1.1 386BSD/src/contrib/xntpd/scripts/mkversion:1.2 -*** 386BSD/src/contrib/xntpd/scripts/mkversion:1.1.1.1 Sun Apr 3 13:43:49 1994 ---- 386BSD/src/contrib/xntpd/scripts/mkversion Sun Apr 3 13:43:49 1994 -*************** -*** 9,20 **** - echo $RUN > .version - - DATE="`date`" - - if [ -r VERSION ]; then - VERSION=VERSION - else - VERSION=../VERSION -! fi - - if [ -f "$VERSION" ]; then - FLAGS="`egrep '^[0-9a-zA-Z_]+=' "$VERSION" | tr '\012' ';'` " ---- 9,23 ---- - echo $RUN > .version - - DATE="`date`" -+ TOPDIR=`echo $0 | sed -e 's;mkversion;..;'` - - if [ -r VERSION ]; then - VERSION=VERSION -+ else if [ -r ${TOPDIR}/VERSION ]; then -+ VERSION=${TOPDIR}/VERSION - else - VERSION=../VERSION -! fi; fi - - if [ -f "$VERSION" ]; then - FLAGS="`egrep '^[0-9a-zA-Z_]+=' "$VERSION" | tr '\012' ';'` " -diff -c /dev/null 386BSD/src/contrib/xntpd/util/Makefile:1.2 -*** /dev/null Sun Apr 3 13:43:53 1994 ---- 386BSD/src/contrib/xntpd/util/Makefile Sun Apr 3 13:43:54 1994 -*************** -*** 0 **** ---- 1,28 ---- -+ # -+ # $Id: Makefile,v 1.2 1993/12/22 11:33:28 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= tickadj -+ MAN8= ${.CURDIR}/../doc/tickadj.8 -+ CLEANFILES+= .version version.c -+ -+ SRCS= tickadj.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion tickadj -+ -+ .include -diff -c /dev/null 386BSD/src/contrib/xntpd/xntpd/Makefile:1.5 -*** /dev/null Sun Apr 3 13:43:56 1994 ---- 386BSD/src/contrib/xntpd/xntpd/Makefile Sun Apr 3 13:43:56 1994 -*************** -*** 0 **** ---- 1,45 ---- -+ # -+ # $Id: Makefile,v 1.5 1994/04/03 20:37:26 wollman Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= ${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= ${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ .if exists(${.CURDIR}/../parse/obj) -+ LDADD+= -L${.CURDIR}/../parse/obj -+ DPADD+= ${.CURDIR}/../parse/obj/libparse.a -+ .else -+ LDADD+= -L${.CURDIR}/../parse -+ DPADD+= ${.CURDIR}/../parse/libparse.a -+ .endif -+ -+ LDADD+= -lntp -lparse -+ -+ PROG= xntpd -+ MAN8= ${.CURDIR}/../doc/xntpd.8 -+ CLEANFILES+= .version version.c -+ -+ SRCS= ntp_config.c ntp_control.c ntp_io.c ntp_leap.c \ -+ ntp_loopfilter.c ntp_monitor.c ntp_peer.c ntp_proto.c \ -+ ntp_refclock.c ntp_request.c ntp_restrict.c ntp_timer.c \ -+ ntp_unixclock.c ntp_util.c ntpd.c refclock_chu.c \ -+ refclock_conf.c refclock_local.c refclock_pst.c \ -+ refclock_wwvb.c refclock_goes.c refclock_mx4200.c \ -+ refclock_parse.c refclock_as2201.c refclock_omega.c \ -+ refclock_tpro.c refclock_leitch.c refclock_irig.c \ -+ refclock_msfees.c refclock_gpstm.c refclock_trak.c ntp_intres.c \ -+ ntp_filegen.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion xntpd -+ -+ .include -diff -c 386BSD/src/contrib/xntpd/xntpd/ntp_control.c:1.1.1.3 386BSD/src/contrib/xntpd/xntpd/ntp_control.c:1.3 -*** 386BSD/src/contrib/xntpd/xntpd/ntp_control.c:1.1.1.3 Sun Apr 3 13:43:59 1994 ---- 386BSD/src/contrib/xntpd/xntpd/ntp_control.c Sun Apr 3 13:44:00 1994 -*************** -*** 264,278 **** - /* - * System and processor definitions. These will change for the gizmo board. - */ -! #ifndef STR_SYSTEM -! #define STR_SYSTEM "UNIX" -! #endif -! #ifndef STR_PROCESSOR -! #define STR_PROCESSOR "unknown" -! #endif -! -! static char str_system[] = STR_SYSTEM; -! static char str_processor[] = STR_PROCESSOR; - - /* - * Trap structures. We only allow a few of these, and send ---- 264,271 ---- - /* - * System and processor definitions. These will change for the gizmo board. - */ -! #include -! static struct utsname utsname; - - /* - * Trap structures. We only allow a few of these, and send -*************** -*** 433,438 **** ---- 426,433 ---- - { - int i; - -+ uname(&utsname); -+ - ctl_clr_stats(); - - ctl_auth_keyid = 0; -*************** -*** 1267,1278 **** - ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning); - break; - case CS_PROCESSOR: -! ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor, -! sizeof(str_processor) - 1); - break; - case CS_SYSTEM: -! ctl_putstr(sys_var[CS_SYSTEM].text, str_system, -! sizeof(str_system) - 1); - break; - case CS_KEYID: - ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0); ---- 1262,1273 ---- - ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning); - break; - case CS_PROCESSOR: -! ctl_putstr(sys_var[CS_PROCESSOR].text, utsname.machine, -! strlen(utsname.machine)); - break; - case CS_SYSTEM: -! ctl_putstr(sys_var[CS_SYSTEM].text, utsname.sysname, -! strlen(utsname.sysname)); - break; - case CS_KEYID: - ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0); -diff -c 386BSD/src/contrib/xntpd/xntpd/refclock_parse.c:1.1.1.3 386BSD/src/contrib/xntpd/xntpd/refclock_parse.c:1.3 -*** 386BSD/src/contrib/xntpd/xntpd/refclock_parse.c:1.1.1.3 Sun Apr 3 13:44:01 1994 ---- 386BSD/src/contrib/xntpd/xntpd/refclock_parse.c Sun Apr 3 13:44:01 1994 -*************** -*** 30,35 **** ---- 30,37 ---- - * PPS - supply loopfilter with PPS samples (if configured) - * PPSPPS - notify loopfilter of PPS file descriptor - * -+ * FREEBSD_CONRAD - Make very cheap "Conrad DCF77 RS-232" gadget work -+ * with FreeBSD. - * TTY defines: - * HAVE_BSD_TTYS - currently unsupported - * HAVE_SYSV_TTYS - will use termio.h -*************** -*** 82,87 **** ---- 84,92 ---- - #include - - #include -+ #ifdef FREEBSD_CONRAD -+ #include -+ #endif - extern int errno; - - #if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS) -*************** -*** 440,446 **** ---- 445,456 ---- - #define RAWDCF_ROOTDELAY 0x00000364 /* 13 ms */ - #define RAWDCF_FORMAT "RAW DCF77 Timecode" - #define RAWDCF_MAXUNSYNC (0) /* sorry - its a true receiver - no signal - no time */ -+ -+ #ifdef FREEBSD_CONRAD -+ #define RAWDCF_CFLAG (CS8|CREAD|CLOCAL) -+ #else - #define RAWDCF_CFLAG (B50|CS8|CREAD|CLOCAL) -+ #endif - #define RAWDCF_IFLAG 0 - #define RAWDCF_OFLAG 0 - #define RAWDCF_LFLAG 0 -*************** -*** 1482,1492 **** ---- 1492,1513 ---- - struct parseunit *parse = (struct parseunit *)rbufp->recv_srcclock; - register int count; - register char *s; -+ #ifdef FREEBSD_CONRAD -+ struct timeval foo; -+ #endif -+ - /* - * eat all characters, parsing then and feeding complete samples - */ - count = rbufp->recv_length; - s = rbufp->recv_buffer; -+ #ifdef FREEBSD_CONRAD -+ ioctl(parse->fd,TIOCTIMESTAMP,&foo); -+ TVTOTS(&foo, &rbufp->recv_time); -+ rbufp->recv_time.l_uf += TS_ROUNDBIT; -+ rbufp->recv_time.l_ui += JAN_1970; -+ rbufp->recv_time.l_uf &= TS_MASK; -+ #endif - - while (count--) - { -*************** -*** 2271,2277 **** - tm.c_iflag = clockinfo[type].cl_iflag; - tm.c_oflag = clockinfo[type].cl_oflag; - tm.c_lflag = clockinfo[type].cl_lflag; -! - if (TTY_SETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcsetattr(%d, &tm): %m", unit, fd232); ---- 2292,2301 ---- - tm.c_iflag = clockinfo[type].cl_iflag; - tm.c_oflag = clockinfo[type].cl_oflag; - tm.c_lflag = clockinfo[type].cl_lflag; -! #ifdef FREEBSD_CONRAD -! tm.c_ispeed = 50; -! tm.c_ospeed = 50; -! #endif - if (TTY_SETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcsetattr(%d, &tm): %m", unit, fd232); -*************** -*** 2314,2319 **** ---- 2338,2358 ---- - return 0; /* well, ok - special initialisation broke */ - } - -+ #ifdef FREEBSD_CONRAD -+ { -+ int i,j; -+ struct timeval tv; -+ ioctl(parse->fd,TIOCTIMESTAMP,&tv); -+ j = TIOCM_RTS; -+ i = ioctl(fd232, TIOCMBIC, &j); -+ if (i < 0) { -+ syslog(LOG_ERR, -+ "PARSE receiver #%d: lowrts_poll: failed to lower RTS: %m", -+ CL_UNIT(parse->unit)); -+ } -+ } -+ #endif -+ - strcpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format); - tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer); - -diff -c 386BSD/src/contrib/xntpd/xntpd/refclock_trak.c:1.1.1.1 386BSD/src/contrib/xntpd/xntpd/refclock_trak.c:1.2 -*** 386BSD/src/contrib/xntpd/xntpd/refclock_trak.c:1.1.1.1 Sun Apr 3 13:44:02 1994 ---- 386BSD/src/contrib/xntpd/xntpd/refclock_trak.c Sun Apr 3 13:44:02 1994 -*************** -*** 14,19 **** ---- 14,21 ---- - #include "ntp_refclock.h" - #include "ntp_unixtime.h" - -+ static void gps_send(); -+ - #if defined(HAVE_BSD_TTYS) - #include - #endif /* HAVE_BSD_TTYS */ -*************** -*** 841,847 **** - /* - * usually trak_receive can get a timestamp every second - */ -! #ifndef TRAKPPS && TRAKCLK - gettstamp(&gps->lastrec); - #endif - gps->polls++; ---- 843,849 ---- - /* - * usually trak_receive can get a timestamp every second - */ -! #if !defined(TRAKPPS) && !defined(TRAKCLK) - gettstamp(&gps->lastrec); - #endif - gps->polls++; -diff -c /dev/null 386BSD/src/contrib/xntpd/xntpdc/Makefile:1.2 -*** /dev/null Sun Apr 3 13:44:03 1994 ---- 386BSD/src/contrib/xntpd/xntpdc/Makefile Sun Apr 3 13:44:03 1994 -*************** -*** 0 **** ---- 1,28 ---- -+ # -+ # $Id: Makefile,v 1.2 1993/12/22 11:34:00 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= xntpdc -+ MAN8= ${.CURDIR}/../doc/xntpdc.8 -+ CLEANFILES+= .version version.c -+ -+ SRCS= ntpdc.c ntpdc_ops.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion xntpdc -+ -+ .include -diff -c 386BSD/src/contrib/xntpd/xntpdc/ntpdc.c:1.1.1.3 386BSD/src/contrib/xntpd/xntpdc/ntpdc.c:1.2 -*** 386BSD/src/contrib/xntpd/xntpdc/ntpdc.c:1.1.1.3 Sun Apr 3 13:44:04 1994 ---- 386BSD/src/contrib/xntpd/xntpdc/ntpdc.c Sun Apr 3 13:44:04 1994 -*************** -*** 53,59 **** - static int getarg P((char *, int, arg_v *)); - static int getnetnum P((char *, U_LONG *, char *)); - static void help P((struct parse *, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) - static int helpsort P((const void *, const void *)); - #else - static int helpsort P((char **, char **)); ---- 53,59 ---- - static int getarg P((char *, int, arg_v *)); - static int getnetnum P((char *, U_LONG *, char *)); - static void help P((struct parse *, FILE *)); -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - static int helpsort P((const void *, const void *)); - #else - static int helpsort P((char **, char **)); -*************** -*** 1153,1159 **** - for (xcp = opcmds; xcp->keyword != 0; xcp++) - cmdsort[n++] = xcp->keyword; - -! #if defined(sgi) || defined(SYS_BSDI) - qsort((void *)cmdsort, n, sizeof(char *), helpsort); - #else - qsort((char *)cmdsort, n, sizeof(char *), helpsort); ---- 1153,1159 ---- - for (xcp = opcmds; xcp->keyword != 0; xcp++) - cmdsort[n++] = xcp->keyword; - -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - qsort((void *)cmdsort, n, sizeof(char *), helpsort); - #else - qsort((char *)cmdsort, n, sizeof(char *), helpsort); -*************** -*** 1199,1205 **** - * helpsort - do hostname qsort comparisons - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) - helpsort(t1, t2) - const void *t1; - const void *t2; ---- 1199,1205 ---- - * helpsort - do hostname qsort comparisons - */ - static int -! #if defined(sgi) || defined(SYS_BSDI) || defined(__STDC__) - helpsort(t1, t2) - const void *t1; - const void *t2; -diff -c /dev/null 386BSD/src/contrib/xntpd/xntpres/Makefile:1.2 -*** /dev/null Sun Apr 3 13:44:05 1994 ---- 386BSD/src/contrib/xntpd/xntpres/Makefile Sun Apr 3 13:44:05 1994 -*************** -*** 0 **** ---- 1,28 ---- -+ # -+ # $Id: Makefile,v 1.2 1993/12/22 11:34:09 rgrimes Exp $ -+ # -+ -+ CFLAGS+= -I${.CURDIR}/../include -+ -+ .if exists(${.CURDIR}/../lib/obj) -+ LDADD+= -L${.CURDIR}/../lib/obj -+ DPADD+= -L${.CURDIR}/../lib/obj/libntp.a -+ .else -+ LDADD+= -L${.CURDIR}/../lib -+ DPADD+= -L${.CURDIR}/../lib/libntp.a -+ .endif -+ -+ LDADD+= -lntp -+ -+ PROG= xntpres -+ NOMAN= -+ CLEANFILES+= .version version.c -+ -+ SRCS= xntpres.c version.c -+ -+ beforedepend: version.c -+ -+ version.c: ${.CURDIR}/../VERSION -+ ${.CURDIR}/../scripts/mkversion xntpres -+ -+ .include - --GAWollman - --- -Garrett A. Wollman | Shashish is simple, it's discreet, it's brief. ... -wollman@lcs.mit.edu | Shashish is the bonding of hearts in spite of distance. -formerly known as | It is a bond more powerful than absence. We like people -wollman@emba.uvm.edu | who like Shashish. - Claude McKenzie + Florent Vollant -[no save] - diff --git a/usr.sbin/xntpd/patches/patch.36 b/usr.sbin/xntpd/patches/patch.36 deleted file mode 100644 index b90df0d4c2eb..000000000000 --- a/usr.sbin/xntpd/patches/patch.36 +++ /dev/null @@ -1,42 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa18708; 7 Apr 94 14:50 EDT -Received: from mudshark.artisoft.com by louie.udel.edu id aa16541; - 7 Apr 94 14:46 EDT -Received: by mudshark.artisoft.com id AA11987 - (5.67b/IDA-1.5 for mills@udel.edu); Thu, 7 Apr 1994 11:46:32 -0700 -Date: Thu, 7 Apr 1994 11:46:32 -0700 -From: Matt Day -Message-Id: <199404071846.AA11987@mudshark.artisoft.com> -To: mills@udel.edu -Subject: XNTP bug on Linux - -adjtime() on Linux fails if you try to adjust more than 131072 -microseconds. This causes `ntpdate' to fail on Linux when the system -clock is off by more than 131072 microseconds but less than -NTPDATE_THRESHOLD (500 ms). - -Reducing NTPDATE_THRESHOLD to less than 131072 microseconds fixed the -problem. - -From the comments in the code for Linux's adjtime(), it looks like this -problem might go away someday. - -Thanks! - -*** ntpdate.h- Tue Aug 24 14:29:30 1993 ---- ntpdate.h Thu Apr 7 11:33:53 1994 -*************** -*** 54,60 **** ---- 54,64 ---- - * are close, or step the time if the times are farther apart. The - * following defines what is "close". - */ -+ #ifdef linux -+ #define NTPDATE_THRESHOLD (FP_SECOND / 8) /* 1/8 second */ -+ #else - #define NTPDATE_THRESHOLD (FP_SECOND >> 1) /* 1/2 second */ -+ #endif - - /* - * When doing adjustments, ntpdate actually overadjusts (currently - diff --git a/usr.sbin/xntpd/patches/patch.37 b/usr.sbin/xntpd/patches/patch.37 deleted file mode 100644 index e17267f57e97..000000000000 --- a/usr.sbin/xntpd/patches/patch.37 +++ /dev/null @@ -1,204 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa25219; 8 Apr 94 17:07 EDT -Received: from ni.umd.edu by louie.udel.edu id aa03359; 8 Apr 94 16:58 EDT -Received: by ni.umd.edu id AA18341 - (5.65c/IDA-1.4.4 for ntp-list); Fri, 8 Apr 1994 16:55:09 -0400 -Received: from RUTGERS.EDU by ni.umd.edu with SMTP id AA18337 - (5.65c/IDA-1.4.4 for ); Fri, 8 Apr 1994 16:55:02 -0400 -Received: from unipress-link.rutgers.edu by rutgers.edu (5.59/SMI4.0/RU1.5/3.08) - id AA16356; Fri, 8 Apr 94 16:54:44 EDT -Received: from huh.unipress.com by repo.unipress.com (4.1/SMI-4.1/UniPress022294.2) - id AA10459; Fri, 8 Apr 94 16:54:36 EDT via -Message-Id: <9404082054.AA10459@repo.unipress.com> -To: ntp@ni.umd.edu -Subject: Re: xntp for univel/unix-ware on x86 -Date: Fri, 08 Apr 94 16:54:31 -0400 -From: Ray Schnitzler - - -I am happy (but not particularly proud - it's more than a - little rough around the edges) to report a working - xntpd for Univel. - -It wound up being a hack on solaris, svr4, and (for the lack - of kernel tickadj) irix. - -util/tickadj does *not* work, even for controlling 'tick'. - I'm not sure what the right behavior should be. - -Most of the changes are signalled by SYS_UNIVEL, as - initiated by OS=univel. - -There are many additional loose ends, which are not terribly - important to me to clean up, since the univel is a - very low usage machine, here, and my because - employer expects me to be working on other things, - altogether. - -Nevertheless, it seems to work. - -Special thanks go to Denton Gentry for advice along the way. - - -Enjoy. - - -Here are the changes I made. First, the (new) - machines/univel file, and then the (rest of the) - context diffs: - -*** /dev/null Fri Apr 8 16:49:24 1994 ---- machines/univel Fri Apr 8 12:38:20 1994 -*************** -*** 0 **** ---- 1,10 ---- -+ SHELL= /bin/sh -+ RANLIB= ls # ar does the work of ranlib under System V -+ DEFS= -DSYS_UNIVEL -DSTREAMS_TLI -DHAVE_TERMIOS -+ AUTHDEFS= -DDES -DMD5 -+ CLOCKDEFS= -+ DAEMONLIBS= -lnsl -lsocket -lelf -+ RESLIB= -lnsl -lsocket -lelf -+ INSTALL=$(TOP)scripts/install.sh -+ SHELL= /bin/sh -+ RANLIB= ls # ar does the work of ranlib under System V -*** authstuff/authspeed.c.orig Thu Jan 27 09:03:12 1994 ---- authstuff/authspeed.c Fri Apr 8 14:19:35 1994 -*************** -*** 2,8 **** - * authspeed - figure out how LONG it takes to do an NTP encryption - */ - -! #if defined(SYS_HPUX) || defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SOLARIS) || defined(SYS_SVR4) || defined(SYS_PTX) - #define FAKE_RUSAGE - #endif - ---- 2,8 ---- - * authspeed - figure out how LONG it takes to do an NTP encryption - */ - -! #if defined(SYS_HPUX) || defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SOLARIS) || defined(SYS_SVR4) || defined(SYS_PTX) || defined(SYS_UNIVEL) - #define FAKE_RUSAGE - #endif -*** include/ntp_if.h.orig Mon Nov 15 16:21:29 1993 ---- include/ntp_if.h Fri Apr 8 14:51:49 1994 -*************** -*** 16,21 **** ---- 16,25 ---- - #include - #endif - -+ #if defined(SYS_UNIVEL) -+ #include -+ #endif -+ - #if defined(SYS_PTX) || defined(SYS_SINIXM) - #include - #include -*** include/ntp_machine.h.orig Mon Mar 14 02:47:02 1994 ---- include/ntp_machine.h Fri Apr 8 14:45:42 1994 -*************** -*** 526,531 **** ---- 526,563 ---- - #endif - - /* -+ * Univel SVR4 on intel x86 processor -+ */ -+ #if defined(SYS_UNIVEL) -+ /* #define _POSIX_SOURCE */ -+ #define NTP_POSIX_SOURCE -+ #define HAVE_ATT_NICE -+ #define HAVE_READKMEM -+ #define USE_PROTOTYPES -+ #undef HAVE_ATT_SETPGRP -+ #define UDP_WILDCARD_DELIVERY -+ #define HAVE_SIGNALED_IO -+ #define USE_TTY_SIGPOLL -+ #define USE_UDP_SIGPOLL -+ #define STREAM -+ #define STREAMS -+ #ifndef STREAMS_TLI -+ /*#define STREAMS_TLI*/ -+ #endif -+ /* #define USE_STREAMS_DEVICE_FOR_IF_CONFIG */ -+ #undef STEP_SLEW /* TWO step */ -+ #define LOCK_PROCESS -+ #undef SYSV_TIMEOFDAY -+ #define SIZE_RETURNED_IN_BUFFER -+ #define RETSIGTYPE void -+ #include -+ #include -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Univel" -+ #endif -+ #endif -+ -+ /* - * DomainOS - */ - #if defined(SYS_DOMAINOS) -*** xntpd/ntp_unixclock.c.orig Thu Feb 3 00:20:20 1994 ---- xntpd/ntp_unixclock.c Fri Apr 8 14:40:55 1994 -*************** -*** 255,260 **** ---- 255,277 ---- - /* Define the following to be what the tick and tickadj variables are - * called in your kernel. - */ -+ #if defined(SYS_UNIVEL) -+ /* -+ * clock_parms - return the local clock tickadj and tick parameters -+ * -+ * The values set here were determined experimentally on a 486 system -+ * I'm not confident in them. - RAS -+ * -+ */ -+ static void -+ clock_parms(tickadj, tick) -+ U_LONG *tickadj; -+ U_LONG *tick; -+ { -+ *tick = 10000; /* microseconds */ -+ *tickadj = 80; /* microseconds */ -+ } -+ #else /* SYS_UNIVEL */ - - #if defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SYS_SVR4) || defined(SYS_PTX) - #define K_TICKADJ_NAME "tickadj" -*************** -*** 421,427 **** - } - #endif /* sgi */ - -- - #ifdef NOKMEM - - #ifndef HZ ---- 438,443 ---- -*************** -*** 571,573 **** ---- 587,590 ---- - *tick = (U_LONG)txc.tick; - } - #endif /* SYS_LINUX */ -+ #endif /* SYS_UNIVEL */ -*** xntpd/ntpd.c.orig Wed Feb 16 22:09:35 1994 ---- xntpd/ntpd.c Fri Apr 8 16:35:57 1994 -*************** -*** 14,20 **** - #include - #endif - -! #if defined(SYS_SVR4) - #include - #endif - ---- 14,20 ---- - #include - #endif - -! #if defined(SYS_SVR4) || defined (SYS_UNIVEL) - #include - #endif - diff --git a/usr.sbin/xntpd/patches/patch.38 b/usr.sbin/xntpd/patches/patch.38 deleted file mode 100644 index dddba69eb06c..000000000000 --- a/usr.sbin/xntpd/patches/patch.38 +++ /dev/null @@ -1,226 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa09565; 11 Apr 94 13:04 EDT -Received: from ni.umd.edu by louie.udel.edu id aa10661; 11 Apr 94 12:57 EDT -Received: by ni.umd.edu id AA00787 - (5.65c/IDA-1.4.4 for ntp-list); Mon, 11 Apr 1994 12:50:20 -0400 -Received: from RUTGERS.EDU by ni.umd.edu with SMTP id AA00783 - (5.65c/IDA-1.4.4 for ); Mon, 11 Apr 1994 12:50:13 -0400 -Received: from unipress-link.rutgers.edu by rutgers.edu (5.59/SMI4.0/RU1.5/3.08) - id AA26905; Mon, 11 Apr 94 12:49:43 EDT -Received: from huh.unipress.com by repo.unipress.com (4.1/SMI-4.1/UniPress022294.2) - id AA03031; Mon, 11 Apr 94 12:49:27 EDT via -Message-Id: <9404111649.AA03031@repo.unipress.com> -To: ntp@ni.umd.edu -Subject: Re: xntp for univel/unix-ware on x86 -Date: Mon, 11 Apr 94 12:49:25 -0400 -From: Ray Schnitzler - - -As seems usual, every patch is followed by a re-patch. This - is a (modified) re-posting of patches to make xntp - work on unixware svr4. It now uses - machines/unixware1 and SYS_UNIXWARE1 (instead of - univel, as suggested by J J Farrell), and now - includes some RELNOTES and COPYRIGHT text (as - suggested by Dave) - -It is still rough, but it still works. The tickadj utility - still does *not* work, even for controlling 'tick'. - I'm not sure what the right behavior should be since - there is no 'tickadj' kernel var. - -In addition to the credits I mentioned above, special thanks - go to Denton Gentry for advice along the way. - - -Enjoy. - -Ray Schnitzler -UniPress Software, Inc. ------------------------------------------------------------- -Here are the changes I made. First, the (new) - machines/univel file, and then the (rest of the) - context diffs: - -*** machines/unixware1.3.3p Fri Apr 8 16:48:35 1994 ---- machines/unixware1 Mon Apr 11 11:08:10 1994 -*************** -*** 0 **** ---- 1,10 ---- -+ SHELL= /bin/sh -+ RANLIB= ls # ar does the work of ranlib under System V -+ DEFS= -DSYS_UNIXWARE1 -DSTREAMS_TLI -DHAVE_TERMIOS -DCONFIG_FILE=\\"/usr/local/etc/ntp.conf\\" -+ AUTHDEFS= -DDES -DMD5 -+ CLOCKDEFS= -+ DAEMONLIBS= -lnsl -lsocket -lelf -+ RESLIB= -lnsl -lsocket -lelf -+ INSTALL=$(TOP)scripts/install.sh -+ SHELL= /bin/sh -+ RANLIB= ls # ar does the work of ranlib under System V -*** COPYRIGHT.3.3p Thu Feb 3 00:20:07 1994 ---- COPYRIGHT Mon Apr 11 10:47:24 1994 -*************** -*** 55,58 **** ---- 55,59 ---- - * Torsten Duwe (Linux Port) - * Paul A Vixie (TrueTime GPS driver) - * Jim Jagielski (A/UX port) -+ * Ray Schnitzler (First pass at a Unixware1 port.) - */ -*** RELNOTES.3.3p Thu Jan 27 09:33:09 1994 ---- RELNOTES Mon Apr 11 11:14:35 1994 -*************** -*** 140,145 **** ---- 140,146 ---- - PC BSD/386 1.0 gcc LOCAL_CLOCK possibly see "build problems" - PC Linux (pl14) gcc LOCAL_CLOCK (dw 93/10/30) - PC Dell SVR4 v2.2 gcc ? (tl 93/12/30) -+ PC Unixware1/SVR4 cc no tickadj, ? (ras 93/04/11) - NCR3445 NCR SVR4 cc LOCAL_CLOCK (tm 93/11/29) - - pb: Piete Brooks -*************** -*** 149,154 **** ---- 150,156 ---- - tl: Tony Lill - tm: Tom Moore - jmj: Jim Jagielski -+ ras: Ray Schnitzler - - Build Problems (and workaround): - -*** authstuff/authspeed.c.3.3p Thu Jan 27 09:03:12 1994 ---- authstuff/authspeed.c Mon Apr 11 10:29:47 1994 -*************** -*** 2,8 **** - * authspeed - figure out how LONG it takes to do an NTP encryption - */ - -! #if defined(SYS_HPUX) || defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SOLARIS) || defined(SYS_SVR4) || defined(SYS_PTX) - #define FAKE_RUSAGE - #endif - ---- 2,8 ---- - * authspeed - figure out how LONG it takes to do an NTP encryption - */ - -! #if defined(SYS_HPUX) || defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SOLARIS) || defined(SYS_SVR4) || defined(SYS_PTX) || defined(SYS_UNIXWARE1) - #define FAKE_RUSAGE - #endif - -*** include/ntp_if.h.3.3p Mon Nov 15 16:21:29 1993 ---- include/ntp_if.h Mon Apr 11 10:30:21 1994 -*************** -*** 16,21 **** ---- 16,25 ---- - #include - #endif - -+ #if defined(SYS_UNIXWARE1) -+ #include -+ #endif -+ - #if defined(SYS_PTX) || defined(SYS_SINIXM) - #include - #include -*** include/ntp_machine.h.3.3p Mon Mar 14 02:47:02 1994 ---- include/ntp_machine.h Mon Apr 11 10:31:11 1994 -*************** -*** 526,531 **** ---- 526,565 ---- - #endif - - /* -+ * (Univel/Novell) Unixware1 SVR4 on intel x86 processor -+ */ -+ #if defined(SYS_UNIXWARE1) -+ /* #define _POSIX_SOURCE */ -+ #undef HAVE_ATT_SETPGRP -+ #define USE_PROTOTYPES -+ #define NTP_POSIX_SOURCE -+ #define HAVE_ATT_NICE -+ #define HAVE_READKMEM -+ #define USE_TTY_SIGPOLL -+ #define USE_UDP_SIGPOLL -+ #define UDP_WILDCARD_DELIVERY -+ #undef HAVE_SIGNALED_IO -+ #define STREAM -+ #define STREAMS -+ #ifndef STREAMS_TLI -+ /*#define STREAMS_TLI*/ -+ #endif -+ /* #define USE_STREAMS_DEVICE_FOR_IF_CONFIG */ -+ #undef STEP_SLEW /* TWO step */ -+ #define LOCK_PROCESS -+ #define NO_SIGNED_CHAR_DECL -+ #undef SYSV_TIMEOFDAY -+ #define SIZE_RETURNED_IN_BUFFER -+ #define RETSIGTYPE void -+ #include -+ #include -+ #include -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX/Unixware1" -+ #endif -+ #endif -+ -+ /* - * DomainOS - */ - #if defined(SYS_DOMAINOS) -*** xntpd/ntp_unixclock.c.3.3p Thu Feb 3 00:20:20 1994 ---- xntpd/ntp_unixclock.c Mon Apr 11 10:33:23 1994 -*************** -*** 255,260 **** ---- 255,277 ---- - /* Define the following to be what the tick and tickadj variables are - * called in your kernel. - */ -+ #if defined(SYS_UNIXWARE1) -+ /* -+ * clock_parms - return the local clock tickadj and tick parameters -+ * -+ * The values set here were determined experimentally on a 486 system -+ * I'm not confident in them. - RAS -+ * -+ */ -+ static void -+ clock_parms(tickadj, tick) -+ U_LONG *tickadj; -+ U_LONG *tick; -+ { -+ *tick = 10000; /* microseconds */ -+ *tickadj = 80; /* microseconds */ -+ } -+ #else /* SYS_UNIXWARE1 */ - - #if defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SYS_SVR4) || defined(SYS_PTX) - #define K_TICKADJ_NAME "tickadj" -*************** -*** 571,573 **** ---- 587,590 ---- - *tick = (U_LONG)txc.tick; - } - #endif /* SYS_LINUX */ -+ #endif /* SYS_UNIXWARE1 */ -*** xntpd/ntpd.c.3.3p Wed Feb 16 22:09:35 1994 ---- xntpd/ntpd.c Mon Apr 11 10:33:58 1994 -*************** -*** 14,20 **** - #include - #endif - -! #if defined(SYS_SVR4) - #include - #endif - ---- 14,21 ---- - #include - #endif - -! /* Shouldn't this test for HAVE_TERMIOS - RAS */ -! #if defined(SYS_SVR4) || defined (SYS_UNIXWARE1) - #include - #endif - - diff --git a/usr.sbin/xntpd/patches/patch.39 b/usr.sbin/xntpd/patches/patch.39 deleted file mode 100644 index 12e09fefcdf7..000000000000 --- a/usr.sbin/xntpd/patches/patch.39 +++ /dev/null @@ -1,78 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa21593; 13 Apr 94 8:23 EDT -Received: from jagubox.gsfc.nasa.gov by louie.udel.edu id aa20245; - 13 Apr 94 8:15 EDT -Received: by jagubox.gsfc.nasa.gov (Smail3.1.28.1 #2) - id m0pr3rH-0005s0C; Wed, 13 Apr 94 08:15 EDT -Message-Id: -From: Jim Jagielski -Subject: Minor change for ntp_loopfilter (and loop.c) in 3.3q -To: Mills@udel.edu -Date: Wed, 13 Apr 1994 08:15:55 -0400 (EDT) -Reply-To: Jim Jagielski -In-Reply-To: <9308051324.aa24396@huey.udel.edu> from "Mills@udel.edu" at Aug 5, 93 01:24:24 pm -X-Mailer: ELM [version 2.4 PL23] -Content-Type: text -Content-Length: 1738 - -One of the changes between 3.3p and 3.3q was the format change of the syslog -message when the clock is reset when xntpd sees a "large" offset. This change -is nice, but it would be "better" is the notice also made mention of whether -the reset was a step or slew (as defined by SLEWALWAYS). - -This patch adds that: -*** xntpd/Oloop.c Wed Apr 13 08:05:09 1994 ---- xntpd/loop.c Wed Apr 13 08:06:32 1994 -*************** -*** 458,464 **** - lfptoa(fp_offset, 6)); - return (0); - } -! syslog(LOG_NOTICE, "clock reset %s\n", - lfptoa(fp_offset, 6)); - step_systime(fp_offset); - clock_adjust = 0; ---- 458,469 ---- - lfptoa(fp_offset, 6)); - return (0); - } -! syslog(LOG_NOTICE, "clock reset (%s) %s\n", -! #ifdef SLEWALWAYS -! "slew", -! #else -! "step", -! #endif - lfptoa(fp_offset, 6)); - step_systime(fp_offset); - clock_adjust = 0; -*** xntpd/Ontp_loopfilter.c Wed Apr 13 08:05:23 1994 ---- xntpd/ntp_loopfilter.c Wed Apr 13 08:07:03 1994 -*************** -*** 458,464 **** - lfptoa(fp_offset, 6)); - return (0); - } -! syslog(LOG_NOTICE, "clock reset %s\n", - lfptoa(fp_offset, 6)); - step_systime(fp_offset); - clock_adjust = 0; ---- 458,469 ---- - lfptoa(fp_offset, 6)); - return (0); - } -! syslog(LOG_NOTICE, "clock reset (%s) %s\n", -! #ifdef SLEWALWAYS -! "slew", -! #else -! "step", -! #endif - lfptoa(fp_offset, 6)); - step_systime(fp_offset); - clock_adjust = 0; --- -#include - Jim Jagielski | "Is this something you can share with - jim@jagubox.gsfc.nasa.gov | the rest of us Amazing Larry!!??" - NASA/GSFC, Code 734.4 | Pee Wee - Greenbelt, MD 20771 | - diff --git a/usr.sbin/xntpd/patches/patch.4 b/usr.sbin/xntpd/patches/patch.4 deleted file mode 100644 index ef06ee907f04..000000000000 --- a/usr.sbin/xntpd/patches/patch.4 +++ /dev/null @@ -1,4719 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa12898; 26 Jan 94 21:06 EST -Received: from sony.com by louie.udel.edu id aa05924; 26 Jan 94 21:01 EST -Received: by sony.com id AA18168; Wed, 26 Jan 94 18:00:44 -0800 -X-Btw: sony.com is also sonygate.sony.com -Received: by mail1.gw.in.sel.sony.com id AA25072; Wed, 26 Jan 94 18:00:43 -0800 -Received: by mail1.sjc.in.sel.sony.com id AA13634; Wed, 26 Jan 94 18:00:41 -0800 -Received: by morality.sjc.hw.sony.com; id AA23624; Wed, 26 Jan 94 18:00:40 -0800 -Date: Wed, 26 Jan 94 18:00:40 -0800 -From: Paul Vixie -Message-Id: <9401270200.AA23624@morality.sjc.hw.sony.com> -To: mills@udel.edu -Subject: diffs against 3.3c (26-jan 11:36) -Cc: paul@vix.com - -These have been tested on BSD/386 1.0 and on HP-UX 8.??. I have more to do, -but this is the last I'm going to do before 3.3d (or whatever) comes out with -the other patches you're expecting. I need to have a day with just me and NTP -and everybody else with their mits outa the code while I finish the portability -stuff. - -*** /tmp/RCSA023397 Wed Jan 26 17:56:22 1994 ---- adjtime/adjtimed.c Wed Jan 26 16:33:27 1994 -*************** -*** 42,47 **** - - double atof(); -! extern int optind; -! extern char *optarg; - - int InitClockRate(); ---- 42,47 ---- - - double atof(); -! extern int ntp_optind; -! extern char *ntp_optarg; - - int InitClockRate(); -*************** -*** 84,88 **** - openlog("adjtimed", LOG_PID, LOG_LOCAL6); - -! while ((ch = getopt(argc, argv, "hkrvdfp:")) != EOF) { - switch (ch) { - case 'k': ---- 84,88 ---- - openlog("adjtimed", LOG_PID, LOG_LOCAL6); - -! while ((ch = ntp_getopt(argc, argv, "hkrvdfp:")) != EOF) { - switch (ch) { - case 'k': -*************** -*** 114,118 **** - - case 'p': -! if ((RATE = atof(optarg)) <= 0.0 || RATE >= 100.0) { - fputs("adjtimed: percentage must be between 0.0 and 100.0\n", stderr); - exit(1); ---- 114,118 ---- - - case 'p': -! if ((RATE = atof(ntp_optarg)) <= 0.0 || RATE >= 100.0) { - fputs("adjtimed: percentage must be between 0.0 and 100.0\n", stderr); - exit(1); -*** /tmp/RCSA023401 Wed Jan 26 17:56:23 1994 ---- authstuff/authspeed.c Wed Jan 26 16:33:28 1994 -*************** -*** 66,75 **** - int i; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; - loops = DEFLOOPS; -! while ((c = getopt_l(argc, argv, "cdmn:")) != EOF) - switch (c) { - case 'c': ---- 66,75 ---- - int i; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; - loops = DEFLOOPS; -! while ((c = ntp_getopt(argc, argv, "cdmn:")) != EOF) - switch (c) { - case 'c': -*************** -*** 83,91 **** - break; - case 'n': -! loops = atoi(optarg); - if (loops <= 0) { - (void) fprintf(stderr, - "%s: %s is unlikely to be a useful number of loops\n", -! progname, optarg); - errflg++; - } ---- 83,91 ---- - break; - case 'n': -! loops = atoi(ntp_optarg); - if (loops <= 0) { - (void) fprintf(stderr, - "%s: %s is unlikely to be a useful number of loops\n", -! progname, ntp_optarg); - errflg++; - } -*************** -*** 95,99 **** - break; - } -! if (errflg || optind == argc) { - (void) fprintf(stderr, - "usage: %s [-d] [-n loops] [ -c ] auth.samplekeys\n", ---- 95,99 ---- - break; - } -! if (errflg || ntp_optind == argc) { - (void) fprintf(stderr, - "usage: %s [-d] [-n loops] [ -c ] auth.samplekeys\n", -*************** -*** 109,113 **** - - init_auth(); -! authreadkeys(argv[optind]); - for (i = 0; i < 16; i++) { - if (!auth_havekey(i + domd5)) { ---- 109,113 ---- - - init_auth(); -! authreadkeys(argv[ntp_optind]); - for (i = 0; i < 16; i++) { - if (!auth_havekey(i + domd5)) { -*** /tmp/RCSA023401 Wed Jan 26 17:56:23 1994 ---- authstuff/keyparity.c Wed Jan 26 16:33:28 1994 -*************** -*** 50,58 **** - int keytype; - U_LONG key[2]; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "adno:s")) != EOF) - switch (c) { - case 'a': ---- 50,58 ---- - int keytype; - U_LONG key[2]; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "adno:s")) != EOF) - switch (c) { - case 'a': -*************** -*** 69,76 **** - break; - case 'o': -! if (*optarg == 'n') { - ntpoutflag = 1; - gotoopt = 1; -! } else if (*optarg == 's') { - ntpoutflag = 0; - gotoopt = 1; ---- 69,76 ---- - break; - case 'o': -! if (*ntp_optarg == 'n') { - ntpoutflag = 1; - gotoopt = 1; -! } else if (*ntp_optarg == 's') { - ntpoutflag = 0; - gotoopt = 1; -*************** -*** 86,90 **** - break; - } -! if (errflg || optind == argc) { - (void) fprintf(stderr, - "usage: %s -n|-s [-a] [-o n|s] key [...]\n", ---- 86,90 ---- - break; - } -! if (errflg || ntp_optind == argc) { - (void) fprintf(stderr, - "usage: %s -n|-s [-a] [-o n|s] key [...]\n", -*************** -*** 119,127 **** - keytype = KEY_TYPE_STD; - -! for (; optind < argc; optind++) { -! if (!decodekey(keytype, argv[optind], key)) { - (void) fprintf(stderr, - "%s: format of key %s invalid\n", -! progname, argv[optind]); - exit(1); - } ---- 119,127 ---- - keytype = KEY_TYPE_STD; - -! for (; ntp_optind < argc; ntp_optind++) { -! if (!decodekey(keytype, argv[ntp_optind], key)) { - (void) fprintf(stderr, - "%s: format of key %s invalid\n", -! progname, argv[ntp_optind]); - exit(1); - } -*************** -*** 243,247 **** - * Make up key from ascii representation - */ -! bzero(keybytes, sizeof(keybytes)); - for (i = 0; i < 8 && i < len; i++) - keybytes[i] = *cp++ << 1; ---- 243,247 ---- - * Make up key from ascii representation - */ -! memset(keybytes, 0, sizeof(keybytes)); - for (i = 0; i < 8 && i < len; i++) - keybytes[i] = *cp++ << 1; -*** /tmp/RCSA023401 Wed Jan 26 17:56:23 1994 ---- authstuff/makeIPFP.c Wed Jan 26 16:33:28 1994 -*************** -*** 29,37 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "d")) != EOF) - switch (c) { - case 'd': ---- 29,37 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "d")) != EOF) - switch (c) { - case 'd': -*************** -*** 184,188 **** - int octbits; - -! bzero((char *)bits, sizeof bits); - - /* ---- 184,188 ---- - int octbits; - -! memset((char *)bits, 0, sizeof bits); - - /* -*** /tmp/RCSA023401 Wed Jan 26 17:56:23 1994 ---- authstuff/makePC1.c Wed Jan 26 16:33:28 1994 -*************** -*** 26,34 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "d")) != EOF) - switch (c) { - case 'd': ---- 26,34 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "d")) != EOF) - switch (c) { - case 'd': -*************** -*** 83,88 **** - u_char d[28]; - -! bzero((char *)c, sizeof c); -! bzero((char *)d, sizeof d); - - for (i = 0; i < 28; i++) { ---- 83,88 ---- - u_char d[28]; - -! memset((char *)c, 0, sizeof c); -! memset((char *)d, 0, sizeof d); - - for (i = 0; i < 28; i++) { -*************** -*** 141,145 **** - u_char bits[64]; - -! bzero((char *)bits, sizeof bits); - - printf("static U_LONG PC1_CL[8] = {"); ---- 141,145 ---- - u_char bits[64]; - -! memset((char *)bits, 0, sizeof bits); - - printf("static U_LONG PC1_CL[8] = {"); -*** /tmp/RCSA023401 Wed Jan 26 17:56:24 1994 ---- authstuff/makePC2.c Wed Jan 26 16:33:28 1994 -*************** -*** 27,35 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "d")) != EOF) - switch (c) { - case 'd': ---- 27,35 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "d")) != EOF) - switch (c) { - case 'd': -*************** -*** 88,92 **** - u_char res[24]; - -! bzero((char *)res, sizeof res); - - for (i = 0; i < 24; i++) { ---- 88,92 ---- - u_char res[24]; - -! memset((char *)res, 0, sizeof res); - - for (i = 0; i < 24; i++) { -*************** -*** 118,122 **** - u_char res[24]; - -! bzero((char *)res, sizeof res); - - for (i = 0; i < 24; i++) { ---- 118,122 ---- - u_char res[24]; - -! memset((char *)res, 0, sizeof res); - - for (i = 0; i < 24; i++) { -*************** -*** 169,173 **** - u_char bits[28]; - -! bzero((char *)bits, sizeof bits); - - printf("static U_LONG PC2_C[4][64] = {"); ---- 169,173 ---- - u_char bits[28]; - -! memset((char *)bits, 0, sizeof bits); - - printf("static U_LONG PC2_C[4][64] = {"); -*** /tmp/RCSA023401 Wed Jan 26 17:56:24 1994 ---- authstuff/makeSP.c Wed Jan 26 16:33:28 1994 -*************** -*** 26,34 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "d")) != EOF) - switch (c) { - case 'd': ---- 26,34 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "d")) != EOF) - switch (c) { - case 'd': -*************** -*** 166,170 **** - int sixbits; - -! bzero((char *)bits, sizeof bits); - printf("static U_LONG SP[8][64] = {"); - for (selno = 0; selno < 8; selno++) { ---- 166,170 ---- - int sixbits; - -! memset((char *)bits, 0, sizeof bits); - printf("static U_LONG SP[8][64] = {"); - for (selno = 0; selno < 8; selno++) { -*** /tmp/RCSA023401 Wed Jan 26 17:56:24 1994 ---- authstuff/mkrandkeys.c Wed Jan 26 16:33:28 1994 -*************** -*** 35,40 **** - U_LONG tmp; - char *passwd; -! extern int optind; -! extern char *optarg; - extern char *getpass(); - ---- 35,40 ---- - U_LONG tmp; - char *passwd; -! extern int ntp_optind; -! extern char *ntp_optarg; - extern char *getpass(); - -*************** -*** 42,46 **** - progname = argv[0]; - passwd = NULL; -! while ((c = getopt_l(argc, argv, "dnp:s")) != EOF) - switch (c) { - case 'd': ---- 42,46 ---- - progname = argv[0]; - passwd = NULL; -! while ((c = ntp_getopt(argc, argv, "dnp:s")) != EOF) - switch (c) { - case 'd': -*************** -*** 51,55 **** - break; - case 'p': -! passwd = optarg; - break; - case 's': ---- 51,55 ---- - break; - case 'p': -! passwd = ntp_optarg; - break; - case 's': -*************** -*** 62,70 **** - - numkeys = 0; -! for (; !errflg && optind < argc; optind++) { -! c = atoi(argv[optind]); - if (c <= 0 || c > 15) { - (void) fprintf(stderr, "%s: invalid key number `%s'\n", -! progname, argv[optind]); - exit(2); - } ---- 62,70 ---- - - numkeys = 0; -! for (; !errflg && ntp_optind < argc; ntp_optind++) { -! c = atoi(argv[ntp_optind]); - if (c <= 0 || c > 15) { - (void) fprintf(stderr, "%s: invalid key number `%s'\n", -! progname, argv[ntp_optind]); - exit(2); - } -*** /tmp/RCSA023401 Wed Jan 26 17:56:24 1994 ---- authstuff/omakeIPFP.c Wed Jan 26 16:33:29 1994 -*************** -*** 35,43 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "d")) != EOF) - switch (c) { - case 'd': ---- 35,43 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "d")) != EOF) - switch (c) { - case 'd': -*************** -*** 189,193 **** - int quadbits; - -! bzero((char *)bits, sizeof bits); - - /* ---- 189,193 ---- - int quadbits; - -! memset((char *)bits, 0, sizeof bits); - - /* -*** /tmp/RCSA023419 Wed Jan 26 17:56:25 1994 ---- clockstuff/chutest.c Wed Jan 26 16:33:29 1994 -*************** -*** 69,78 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - void init_chu(); - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "cdfpt")) != EOF) - switch (c) { - case 'c': ---- 69,78 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - void init_chu(); - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "cdfpt")) != EOF) - switch (c) { - case 'c': -*************** -*** 108,112 **** - break; - } -! if (errflg || optind+1 != argc) { - #ifdef STREAM - (void) fprintf(stderr, "usage: %s [-dft] tty_device\n", ---- 108,112 ---- - break; - } -! if (errflg || ntp_optind+1 != argc) { - #ifdef STREAM - (void) fprintf(stderr, "usage: %s [-dft] tty_device\n", -*************** -*** 127,131 **** - - (void) gettimeofday(&lasttv, (struct timezone *)0); -! c = openterm(argv[optind]); - init_chu(); - #ifdef STREAM ---- 127,131 ---- - - (void) gettimeofday(&lasttv, (struct timezone *)0); -! c = openterm(argv[ntp_optind]); - init_chu(); - #ifdef STREAM -*** /tmp/RCSA023419 Wed Jan 26 17:56:25 1994 ---- clockstuff/clktest.c Wed Jan 26 16:33:29 1994 -*************** -*** 106,111 **** - struct sgttyb ttyb; - struct itimerval itimer; -! extern int optind; -! extern char *optarg; - int alarming(); - int ioready(); ---- 106,111 ---- - struct sgttyb ttyb; - struct itimerval itimer; -! extern int ntp_optind; -! extern char *ntp_optarg; - int alarming(); - int ioready(); -*************** -*** 115,119 **** - magic[0] = 0; - #endif -! while ((c = getopt_l(argc, argv, "a:b:c:dfs:t:")) != EOF) - switch (c) { - #ifdef CLKLDISC ---- 115,119 ---- - magic[0] = 0; - #endif -! while ((c = ntp_getopt(argc, argv, "a:b:c:dfs:t:")) != EOF) - switch (c) { - #ifdef CLKLDISC -*************** -*** 121,125 **** - #endif - case 'c': -! if (!atouint(optarg, &tmp)) { - (void) fprintf(stderr, - "%s: argument for -%c must be integer\n", ---- 121,125 ---- - #endif - case 'c': -! if (!atouint(ntp_optarg, &tmp)) { - (void) fprintf(stderr, - "%s: argument for -%c must be integer\n", -*************** -*** 140,144 **** - break; - case 'b': -! if (!atouint(optarg, &tmp)) { - errflg++; - break; ---- 140,144 ---- - break; - case 'b': -! if (!atouint(ntp_optarg, &tmp)) { - errflg++; - break; -*************** -*** 164,175 **** - break; - case 's': -! cmdlen = strlen(optarg); - if (cmdlen == 0) - errflg++; - else -! cmd = optarg; - break; - case 't': -! if (!atouint(optarg, &tmp)) - errflg++; - else { ---- 164,175 ---- - break; - case 's': -! cmdlen = strlen(ntp_optarg); - if (cmdlen == 0) - errflg++; - else -! cmd = ntp_optarg; - break; - case 't': -! if (!atouint(ntp_optarg, &tmp)) - errflg++; - else { -*************** -*** 182,186 **** - break; - } -! if (errflg || optind+1 != argc) { - (void) fprintf(stderr, - #ifdef CLKLDISC ---- 182,186 ---- - break; - } -! if (errflg || ntp_optind+1 != argc) { - (void) fprintf(stderr, - #ifdef CLKLDISC -*************** -*** 200,209 **** - - if (docmd) -! fd = open(argv[optind], O_RDWR, 0777); - else -! fd = open(argv[optind], O_RDONLY, 0777); - if (fd == -1) { - (void) fprintf(stderr, "%s: open(%s): ", progname, -! argv[optind]); - perror(""); - exit(1); ---- 200,209 ---- - - if (docmd) -! fd = open(argv[ntp_optind], O_RDWR, 0777); - else -! fd = open(argv[ntp_optind], O_RDONLY, 0777); - if (fd == -1) { - (void) fprintf(stderr, "%s: open(%s): ", progname, -! argv[ntp_optind]); - perror(""); - exit(1); -*** /tmp/RCSA023419 Wed Jan 26 17:56:25 1994 ---- clockstuff/propdelay.c Wed Jan 26 16:33:29 1994 -*************** -*** 141,149 **** - double lat2, long2; - double lat3, long3; -! extern int optind; -! extern char *optarg; - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "dh:CWG")) != EOF) - switch (c) { - case 'd': ---- 141,149 ---- - double lat2, long2; - double lat3, long3; -! extern int ntp_optind; -! extern char *ntp_optarg; - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "dh:CWG")) != EOF) - switch (c) { - case 'd': -*************** -*** 152,159 **** - case 'h': - hflag++; -! height = atof(optarg); - if (height <= 0.0) { - (void) fprintf(stderr, "height %s unlikely\n", -! optarg); - errflg++; - } ---- 152,159 ---- - case 'h': - hflag++; -! height = atof(ntp_optarg); - if (height <= 0.0) { - (void) fprintf(stderr, "height %s unlikely\n", -! ntp_optarg); - errflg++; - } -*************** -*** 172,177 **** - break; - } -! if (errflg || (!(Cflag || Wflag || Gflag) && optind+4 != argc) || -! ((Cflag || Wflag || Gflag) && optind+2 != argc)) { - (void) fprintf(stderr, - "usage: %s [-d] [-h height] lat1 long1 lat2 long2\n", ---- 172,177 ---- - break; - } -! if (errflg || (!(Cflag || Wflag || Gflag) && ntp_optind+4 != argc) || -! ((Cflag || Wflag || Gflag) && ntp_optind+2 != argc)) { - (void) fprintf(stderr, - "usage: %s [-d] [-h height] lat1 long1 lat2 long2\n", -*************** -*** 186,193 **** - - if (!(Cflag || Wflag || Gflag)) { -! lat1 = latlong(argv[optind], 1); -! long1 = latlong(argv[optind + 1], 0); -! lat2 = latlong(argv[optind + 2], 1); -! long2 = latlong(argv[optind + 3], 0); - if (hflag) { - doit(lat1, long1, lat2, long2, height, ""); ---- 186,193 ---- - - if (!(Cflag || Wflag || Gflag)) { -! lat1 = latlong(argv[ntp_optind], 1); -! long1 = latlong(argv[ntp_optind + 1], 0); -! lat2 = latlong(argv[ntp_optind + 2], 1); -! long2 = latlong(argv[ntp_optind + 3], 0); - if (hflag) { - doit(lat1, long1, lat2, long2, height, ""); -*************** -*** 202,207 **** - * Compute delay from WWV - */ -! lat1 = latlong(argv[optind], 1); -! long1 = latlong(argv[optind + 1], 0); - lat2 = latlong(wwvlat, 1); - long2 = latlong(wwvlong, 0); ---- 202,207 ---- - * Compute delay from WWV - */ -! lat1 = latlong(argv[ntp_optind], 1); -! long1 = latlong(argv[ntp_optind + 1], 0); - lat2 = latlong(wwvlat, 1); - long2 = latlong(wwvlong, 0); -*************** -*** 229,234 **** - } - } else if (Cflag) { -! lat1 = latlong(argv[optind], 1); -! long1 = latlong(argv[optind + 1], 0); - lat2 = latlong(chulat, 1); - long2 = latlong(chulong, 0); ---- 229,234 ---- - } - } else if (Cflag) { -! lat1 = latlong(argv[ntp_optind], 1); -! long1 = latlong(argv[ntp_optind + 1], 0); - lat2 = latlong(chulat, 1); - long2 = latlong(chulong, 0); -*************** -*** 244,249 **** - lat1 = latlong(goes_up_lat, 1); - long1 = latlong(goes_up_long, 0); -! lat3 = latlong(argv[optind], 1); -! long3 = latlong(argv[optind + 1], 0); - - lat2 = latlong(goes_sat_lat, 1); ---- 244,249 ---- - lat1 = latlong(goes_up_lat, 1); - long1 = latlong(goes_up_long, 0); -! lat3 = latlong(argv[ntp_optind], 1); -! long3 = latlong(argv[ntp_optind + 1], 0); - - lat2 = latlong(goes_sat_lat, 1); -*** /tmp/RCSA023428 Wed Jan 26 17:56:27 1994 ---- conf/Config.CHATHAM Wed Jan 26 16:33:29 1994 -*************** -*** 90,96 **** - # CLOCKDEFS= line below. This flag affects xntpd only. - # -- # There is an occurance of a call to rindex() in the daemon. You may -- # have to include a -Drindex=strrchr to get this to load right. -- # - # To change the location of the configuration file, use a - # -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. ---- 90,93 ---- -*************** -*** 110,114 **** - # generated by the pps signal. Only one of these flags should be defined. - # -! DEFS= -DUSELIBKVM -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DPPS -DPPSDEV -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H - - # ---- 107,111 ---- - # generated by the pps signal. Only one of these flags should be defined. - # -! DEFS= -DUSELIBKVM -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DPPS -DPPSDEV -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE - - # -*** /tmp/RCSA023428 Wed Jan 26 17:56:27 1994 ---- conf/Config.MONOMOY Wed Jan 26 16:33:29 1994 -*************** -*** 85,91 **** - # CLOCKDEFS= line below. This flag affects xntpd only. - # -- # There is an occurance of a call to rindex() in the daemon. You may -- # have to include a -Drindex=strrchr to get this to load right. -- # - # To change the location of the configuration file, use a - # -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. ---- 85,88 ---- -*************** -*** 105,109 **** - # be used) - # -! DEFS= -DBSDI -DUSELIBKVM -DDEBUG -DREFCLOCK -DPPS -DCONFIG_FILE=\\"/usr/local/etc/xntp.conf\\" -DHAVE_UNISTD_H - - # ---- 102,106 ---- - # be used) - # -! DEFS= -DBSDI -DUSELIBKVM -DDEBUG -DREFCLOCK -DPPS -DCONFIG_FILE=\\"/usr/local/etc/xntp.conf\\" -DNTP_POSIX_SOURCE - - # -*** /tmp/RCSA023428 Wed Jan 26 17:56:27 1994 ---- conf/Config.TIGER Wed Jan 26 16:33:30 1994 -*************** -*** 81,87 **** - # CLOCKDEFS= line below. This flag affects xntpd only. - # -- # There is an occurance of a call to rindex() in the daemon. You may -- # have to include a -Drindex=strrchr to get this to load right. -- # - # To change the location of the configuration file, use a - # -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. ---- 81,84 ---- -*************** -*** 101,105 **** - # be used) - # -! DEFS= -DREFCLOCK -DS_CHAR_DEFINED -DREADKMEM -DDEBUG -DPLL -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H - - # ---- 98,102 ---- - # be used) - # -! DEFS= -DREFCLOCK -DS_CHAR_DEFINED -DREADKMEM -DDEBUG -DPLL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE - - # -*** /tmp/RCSA023428 Wed Jan 26 17:56:27 1994 ---- conf/Config.TRURO Wed Jan 26 16:33:30 1994 -*************** -*** 87,93 **** - # CLOCKDEFS= line below. This flag affects xntpd only. - # -- # There is an occurance of a call to rindex() in the daemon. You may -- # have to include a -Drindex=strrchr to get this to load right. -- # - # To change the location of the configuration file, use a - # -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar. ---- 87,90 ---- -*************** -*** 110,114 **** - # generated by the pps signal. Only one of these flags should be defined. - # -! DEFS= -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DSLEWALWAYS -DSOLARIS -DPPS -DSTUPID_SIGNAL -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H - - # ---- 107,111 ---- - # generated by the pps signal. Only one of these flags should be defined. - # -! DEFS= -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DSLEWALWAYS -DSOLARIS -DPPS -DSTUPID_SIGNAL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE - - # -*** /tmp/RCSA023441 Wed Jan 26 17:56:29 1994 ---- include/l_stdlib.h Wed Jan 26 16:33:30 1994 -*************** -*** 39,43 **** - #if !defined(NTP_POSIX_SOURCE) - extern int atoi P((char *)); -- extern void bcopy P((char *, char *, int)); - extern int dup2 P((int, int)); - extern int execve P((char *, char **,char **)); ---- 39,42 ---- -*************** -*** 51,58 **** - #endif - -- #ifndef bzero /* XXX macro prototyping clash */ -- extern void bzero P((char *, int)); -- extern int bcmp P((char *, char *, int)); -- #endif - extern char *mktemp P((char *)); - ---- 50,53 ---- -*************** -*** 193,200 **** - #ifndef NTP_POSIX_SOURCE - extern int atoi P((char *)); -- extern void bcopy P((char *, char *, int)); -- extern void bzero P((char *, int)); -- extern int bcmp P((char *, char *, int)); -- extern void bcopy P((char *, char *, int)); - extern int execve P((char *, char **,char **)); - extern int fork P((void)); ---- 188,191 ---- -*** /tmp/RCSA023441 Wed Jan 26 17:56:29 1994 ---- include/ntp.h Wed Jan 26 16:33:30 1994 -*************** -*** 329,333 **** - - /* -! * Definitions for the clear() routine. We use bzero() to clear - * the parts of the peer structure which go to zero. These are - * used to calculate the start address and length of the area. ---- 329,333 ---- - - /* -! * Definitions for the clear() routine. We use memset() to clear - * the parts of the peer structure which go to zero. These are - * used to calculate the start address and length of the area. -*** /tmp/RCSA023441 Wed Jan 26 17:56:29 1994 ---- include/ntp_machine.h Wed Jan 26 16:33:31 1994 -*************** -*** 1,3 **** -! /* ntp_compat.h,v 3.1 1993/07/06 01:06:49 jbj Exp - * Collect all machine dependent idiosyncrasies in one place. - */ ---- 1,3 ---- -! /* ntp_machine.h,v 3.1 1993/07/06 01:06:49 jbj Exp - * Collect all machine dependent idiosyncrasies in one place. - */ -*************** -*** 53,61 **** - - THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about -! kernal mucking. - - NTP_POSIX_SOURCE - Use POSIX functions over bsd functions and att functions. - This is NOT the same as _POSIX_SOURCE. -! It is much weeker! - - ---- 53,61 ---- - - THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about -! kernel mucking. - - NTP_POSIX_SOURCE - Use POSIX functions over bsd functions and att functions. - This is NOT the same as _POSIX_SOURCE. -! It is much weaker! - - -*************** -*** 95,99 **** - UNIX V.4 machines implement a sockets library on top of streams. - When requesting the IP interface configuration with an ioctl(2) calll, -! an arrat of ifreq structures are placed in the provided buffer. Some - implementations also place the length of the buffer information in - the first integer position of the buffer. ---- 95,99 ---- - UNIX V.4 machines implement a sockets library on top of streams. - When requesting the IP interface configuration with an ioctl(2) calll, -! an array of ifreq structures are placed in the provided buffer. Some - implementations also place the length of the buffer information in - the first integer position of the buffer. -*************** -*** 115,121 **** - RETSIGTYPE - Define signal function type. - NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h -! LOCK_PROCESS - Have plock. - UDP_WILDCARD_DELIVERY -! - these systems deliver broadcast pakets to the wildcard - port instead to a port bound to the interface bound - to the correct broadcast address - are these ---- 115,121 ---- - RETSIGTYPE - Define signal function type. - NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h -! LOCK_PROCESS - Have plock. - UDP_WILDCARD_DELIVERY -! - these systems deliver broadcast packets to the wildcard - port instead to a port bound to the interface bound - to the correct broadcast address - are these -*************** -*** 122,133 **** - implementations broken or did the spec change ? - -- HAVE_UNISTD_H - Maybe should be part of NTP_POSIX_SOURCE ? -- - You could just put the defines on the DEFS line in machines/ file. -! I don't since there are lost of different types compiler that a systemm might -! have, some that can do proto typing and others that cannot on the saem system. -! I get a chanse to twiddle some of the configuration paramasters at compile -! time based on compler/machine combinatsions by using this include file. -! See convex, aix and sun configurations see how complex it get. - - */ ---- 122,135 ---- - implementations broken or did the spec change ? - - You could just put the defines on the DEFS line in machines/ file. -! I don't since there are lots of different types of compiler that a system might -! have, some that can do prototyping and others that cannot on the saem system. -! I get a chance to twiddle some of the configuration paramasters at compile -! time based on compler/machine combinations by using this include file. -! See convex, aix and sun configurations see how complex it gets. -! -! Note that it _is_ considered reasonable to add some system-specific defines -! to the machine/ file if it would be too inconvenient to puzzle them out -! in this file. - - */ -*************** -*** 145,152 **** - * Keep USE_PROTOTYPES and _NO_PROTO in step. - */ -! #if defined(_NO_PROTO)&&defined(USE_PROTOTYPES) - #undef USE_PROTOTYPES - #endif -! #if !defined(_NO_PROTO)&&!defined(USE_PROTOTYPES) - #define USE_PROTOTYPES - #endif ---- 147,154 ---- - * Keep USE_PROTOTYPES and _NO_PROTO in step. - */ -! #if defined(_NO_PROTO) && defined(USE_PROTOTYPES) - #undef USE_PROTOTYPES - #endif -! #if !defined(_NO_PROTO) && !defined(USE_PROTOTYPES) - #define USE_PROTOTYPES - #endif -*************** -*** 204,208 **** - * Convex - */ -! #if defined(SYS_CONVEXOS10)||defined(SYS_CONVEXOS9) - #define HAVE_SIGNALED_IO - #define HAVE_N_UN ---- 206,210 ---- - * Convex - */ -! #if defined(SYS_CONVEXOS10) || defined(SYS_CONVEXOS9) - #define HAVE_SIGNALED_IO - #define HAVE_N_UN -*************** -*** 213,221 **** - #define NO_SIGNED_CHAR_DECL - #else -! #if defined(__stdc__)&&!defined(USE_PROTOTYPES) - #define USE_PROTOTYPES - #endif -! #if !defined(__stdc__)&&defined(USE_PROTOTYPES) -! #undef USE_PROTOTYPES - #endif - #define NTP_POSIX_SOURCE ---- 215,223 ---- - #define NO_SIGNED_CHAR_DECL - #else -! #if defined(__stdc__) && !defined(USE_PROTOTYPES) - #define USE_PROTOTYPES - #endif -! #if !defined(__stdc__) && defined(USE_PROTOTYPES) -! #undef USE_PROTOTYPES - #endif - #define NTP_POSIX_SOURCE -*************** -*** 253,257 **** - * AUX - */ -! #if defined(SYS_AUX2)||defined(SYS_AUX3) - #define NO_SIGNED_CHAR_DECL - #define HAVE_READKMEM ---- 255,259 ---- - * AUX - */ -! #if defined(SYS_AUX2) || defined(SYS_AUX3) - #define NO_SIGNED_CHAR_DECL - #define HAVE_READKMEM -*************** -*** 292,296 **** - #define NTP_POSIX_SOURCE - #define HAVE_SIGNALED_IO -- #define HAVE_UNISTD_H - #define NO_SIGNED_CHAR_DECL - #define LOCK_PROCESS ---- 294,297 ---- -*************** -*** 302,305 **** ---- 303,308 ---- - #define HAVE_READKMEM - #endif -+ #define getdtablesize() sysconf(_SC_OPEN_MAX) -+ #define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0) - #endif - -*************** -*** 313,316 **** ---- 316,320 ---- - #define HAVE_BSD_NICE - #define HAVE_BSD_TTYS -+ #define HAVE_TERMIOS - #endif - -*************** -*** 342,346 **** - - /* -! * DECOSF1 - */ - #if defined(SYS_DECOSF1) ---- 346,350 ---- - - /* -! * DEC AXP OSF/1 - */ - #if defined(SYS_DECOSF1) -*************** -*** 354,357 **** ---- 358,362 ---- - /* - * I386 -+ * XXX - what OS? - */ - #if defined(SYS_I386) -*************** -*** 412,416 **** - - /* -! * Sony - */ - #if defined(SYS_SONY) ---- 417,421 ---- - - /* -! * Sony NEWS - */ - #if defined(SYS_SONY) -*************** -*** 422,425 **** ---- 427,431 ---- - /* - * VAX -+ * XXX - VMS? - */ - #if defined(SYS_VAX) -*************** -*** 435,439 **** - #define HAVE_ATT_SETPGRP - #define USE_PROTOTYPES -- #define HAVE_UNISTD_H - #define NTP_POSIX_SOURCE - #define HAVE_ATT_NICE ---- 441,444 ---- -*************** -*** 484,490 **** - #endif /* NTP_SYSCALLS_STD */ - -! #if !defined(HAVE_ATT_NICE) && !defined(HAVE_BSD_NICE) && !defined(HAVE_NO_NICE) - ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines - #endif - - #endif /* __ntp_machine */ ---- 489,545 ---- - #endif /* NTP_SYSCALLS_STD */ - -! #if !defined(HAVE_ATT_NICE) \ -! && !defined(HAVE_BSD_NICE) \ -! && !defined(HAVE_NO_NICE) - ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines - #endif -+ -+ -+ #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) -+ -+ # if defined(XNTP_AUTO_ENDIAN) -+ # include -+ -+ # if BYTE_ORDER == BIG_ENDIAN -+ # define XNTP_BIG_ENDIAN -+ # endif -+ # if BYTE_ORDER == LITTLE_ENDIAN -+ # define XNTP_LITTLE_ENDIAN -+ # endif -+ -+ # else /* AUTO */ -+ -+ # ifdef WORDS_BIGENDIAN -+ # define XNTP_BIG_ENDIAN 1 -+ # else -+ # define XNTP_LITTLE_ENDIAN 1 -+ # endif -+ -+ # endif /* AUTO */ -+ -+ #endif /* !BIG && !LITTLE */ -+ -+ /* -+ * Byte order woes. The DES code is sensitive to byte order. This -+ * used to be resolved by calling ntohl() and htonl() to swap things -+ * around, but this turned out to be quite costly on Vaxes where those -+ * things are actual functions. The code now straightens out byte -+ * order troubles on its own, with no performance penalty for little -+ * end first machines, but at great expense to cleanliness. -+ */ -+ #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) -+ /* -+ * Pick one or the other. -+ */ -+ BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -+ #endif -+ -+ #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN) -+ /* -+ * Pick one or the other. -+ */ -+ BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -+ #endif -+ - - #endif /* __ntp_machine */ -*** /tmp/RCSA023441 Wed Jan 26 17:56:30 1994 ---- include/ntp_select.h Wed Jan 26 16:33:31 1994 -*************** -*** 15,19 **** - #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) - #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -! #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) - #endif - ---- 15,19 ---- - #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) - #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -! #define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p))) - #endif - -*** /tmp/RCSA023441 Wed Jan 26 17:56:30 1994 ---- include/ntp_stdlib.h Wed Jan 26 16:33:31 1994 -*************** -*** 48,52 **** - extern int clocktime P((int, int, int, int, int, U_LONG, U_LONG *, U_LONG *)); - extern char * emalloc P((u_int)); -! extern int getopt_l P((int, char **, char *)); - extern void init_auth P((void)); - extern void init_lib P((void)); ---- 48,52 ---- - extern int clocktime P((int, int, int, int, int, U_LONG, U_LONG *, U_LONG *)); - extern char * emalloc P((u_int)); -! extern int ntp_getopt P((int, char **, char *)); - extern void init_auth P((void)); - extern void init_lib P((void)); -*** /tmp/RCSA023441 Wed Jan 26 17:56:30 1994 ---- include/ntp_string.h Wed Jan 26 16:33:31 1994 -*************** -*** 1,4 **** - /* -! * Define bcopy, bzero, and bcmp and string op's - */ - ---- 1,4 ---- - /* -! * Define string ops: strchr strrchr memcmp memmove memset - */ - -*************** -*** 8,27 **** - #ifdef NTP_POSIX_SOURCE - -! #if defined(HAVE_MEMORY_H) -! #include -! #endif -! -! #include -! -! #define bcopy(s1,s2,n) memcpy(s2, s1, n) -! #define bzero(s,n) memset(s, 0, n) -! #define bcmp(s1,s2,n) memcmp(s1, s2, n) - - #else /* NTP_POSIX_SOURCE */ - -! #include - -! #define strrchr rindex -! #define strchr index - - #endif /* NTP_POSIX_SOURCE */ ---- 8,27 ---- - #ifdef NTP_POSIX_SOURCE - -! # if defined(HAVE_MEMORY_H) -! # include -! # endif - -+ # include -+ - #else /* NTP_POSIX_SOURCE */ - -! # include - -! # define strchr(s,c) index(s,c) -! # define strrchr(s,c) rindex(s,c) -! # define memcmp(a,b,c) bcmp(a,b,c) -! # define memmove(t,f,c) bcopy(f,t,c) -! # define memset(a,x,c) if (x == 0x00) bzero(a,c) else ntp_memset((char*)a,x,c) -! void ntp_memset P((char *, int, int)); - - #endif /* NTP_POSIX_SOURCE */ -*** /tmp/RCSA023456 Wed Jan 26 17:56:31 1994 ---- kernel/tty_clk_STREAMS.c Wed Jan 26 16:33:31 1994 -*************** -*** 63,67 **** - - /* -! * God only knows why, but linking with strchr() and index() fail - * on my system, so here's a renamed copy. - */ ---- 63,67 ---- - - /* -! * God only knows why, but linking with strchr() fails - * on my system, so here's a renamed copy. - */ -*** /tmp/RCSA023460 Wed Jan 26 17:56:32 1994 ---- lib/a_md512crypt.c Wed Jan 26 16:33:31 1994 -*************** -*** 81,86 **** - MD5Final(&ctx); - -! bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)], -! BLOCK_OCTETS); -! return 4 + BLOCK_OCTETS; - } ---- 81,87 ---- - MD5Final(&ctx); - -! memmove((char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)], -! (char *) ctx.digest, -! BLOCK_OCTETS); -! return (4 + BLOCK_OCTETS); - } -*** /tmp/RCSA023460 Wed Jan 26 17:56:33 1994 ---- lib/a_md5decrypt.c Wed Jan 26 16:33:32 1994 -*************** -*** 55,58 **** - MD5Final(&ctx); - -! return (0 == bcmp((char *)ctx.digest, (char *)pkt + length + 4, BLOCK_OCTETS)); - } ---- 55,60 ---- - MD5Final(&ctx); - -! return (!memcmp((char *)ctx.digest, -! (char *)pkt + length + 4, -! BLOCK_OCTETS)); - } -*** /tmp/RCSA023460 Wed Jan 26 17:56:33 1994 ---- lib/a_md5encrypt.c Wed Jan 26 16:33:32 1994 -*************** -*** 64,68 **** - MD5Final(&ctx); - -! bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + len], BLOCK_OCTETS); -! return 4 + BLOCK_OCTETS; /* return size of key and MAC */ - } ---- 64,70 ---- - MD5Final(&ctx); - -! memmove((char *)&pkt[NOCRYPT_LONGS + len], -! (char *)ctx.digest, -! BLOCK_OCTETS); -! return (4 + BLOCK_OCTETS); /* return size of key and MAC */ - } -*** /tmp/RCSA023460 Wed Jan 26 17:56:33 1994 ---- lib/authdes.c Wed Jan 26 16:33:32 1994 -*************** -*** 4,31 **** - #include "ntp_stdlib.h" - -- #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) -- -- #if defined(XNTP_AUTO_ENDIAN) -- #include -- -- #if BYTE_ORDER == BIG_ENDIAN -- #define XNTP_BIG_ENDIAN -- #endif -- #if BYTE_ORDER == LITTLE_ENDIAN -- #define XNTP_LITTLE_ENDIAN -- #endif -- -- #else /* AUTO */ -- -- #ifdef WORDS_BIGENDIAN -- #define XNTP_BIG_ENDIAN 1 -- #else -- #define XNTP_LITTLE_ENDIAN 1 -- #endif -- -- #endif /* AUTO */ -- -- #endif /* !BIG && !LITTLE */ -- - /* - * There are two entries in here. auth_subkeys() called to ---- 4,7 ---- -*************** -*** 33,58 **** - * auth_des() is called to do the actual encryption/decryption - */ -- -- /* -- * Byte order woes. The DES code is sensitive to byte order. This -- * used to be resolved by calling ntohl() and htonl() to swap things -- * around, but this turned out to be quite costly on Vaxes where those -- * things are actual functions. The code now straightens out byte -- * order troubles on its own, with no performance penalty for little -- * end first machines, but at great expense to cleanliness. -- */ -- #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) -- /* -- * Pick one or the other. -- */ -- BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -- #endif -- -- #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN) -- /* -- * Pick one or the other. -- */ -- BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -- #endif - - /* ---- 9,12 ---- -*** /tmp/RCSA023460 Wed Jan 26 17:56:33 1994 ---- lib/authkeys.c Wed Jan 26 16:33:32 1994 -*************** -*** 110,114 **** - * Initialize hash table and free list - */ -! bzero((char *)key_hash, sizeof key_hash); - cache_flags = cache_keyid = 0; - ---- 110,114 ---- - * Initialize hash table and free list - */ -! memset((char *)key_hash, 0, sizeof key_hash); - cache_flags = cache_keyid = 0; - -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/authusekey.c Wed Jan 26 16:33:32 1994 -*************** -*** 97,101 **** - * Make up key from ascii representation - */ -! bzero((char *) keybytes, sizeof(keybytes)); - for (i = 0; i < 8 && i < len; i++) - keybytes[i] = *cp++ << 1; ---- 97,101 ---- - * Make up key from ascii representation - */ -! memset((char *) keybytes, 0, sizeof(keybytes)); - for (i = 0; i < 8 && i < len; i++) - keybytes[i] = *cp++ << 1; -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/dofptoa.c Wed Jan 26 16:33:33 1994 -*************** -*** 32,36 **** - * Zero out the buffer - */ -! bzero((char *)cbuf, sizeof cbuf); - - /* ---- 32,36 ---- - * Zero out the buffer - */ -! memset((char *)cbuf, 0, sizeof cbuf); - - /* -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/dolfptoa.c Wed Jan 26 16:33:33 1994 -*************** -*** 33,37 **** - * Zero the character buffer - */ -! bzero((char *) cbuf, sizeof(cbuf)); - - /* ---- 33,37 ---- - * Zero the character buffer - */ -! memset((char *) cbuf, 0, sizeof(cbuf)); - - /* -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/getopt.c Wed Jan 26 16:33:33 1994 -*************** -*** 5,9 **** - * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). - * It allows rescanning of an option list by setting optind to 0 before -! * calling. Thanks to Dennis Ferguson for the appropriate modifications. - * - * This file is in the Public Domain. ---- 5,11 ---- - * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). - * It allows rescanning of an option list by setting optind to 0 before -! * calling, which is why we use it even if the system has its own (in fact, -! * this one has a unique name so as not to conflict with the system's). -! * Thanks to Dennis Ferguson for the appropriate modifications. - * - * This file is in the Public Domain. -*************** -*** 21,57 **** - #endif /* lint */ - -! char *optarg; /* Global argument pointer. */ -! #ifndef __convex__ -! int optind = 0; /* Global argv index. */ -! #else /* __convex__ */ -! extern int optind; /* Global argv index. */ -! #endif /* __convex__ */ - -- /* -- * N.B. use following at own risk -- */ -- #ifndef __convex__ -- int opterr = 1; /* for compatibility, should error be printed? */ -- #else /* __convex__ */ -- extern int opterr; /* for compatibility, should error be printed? */ -- #endif /* __convex__ */ -- int optopt; /* for compatibility, option character checked */ -- - static char *scan = NULL; /* Private scan pointer. */ - - /* -! * Print message about a bad option. Watch this definition, it's -! * not a single statement. - */ -! #define BADOPT(mess, ch) if (opterr) { \ -! fputs(argv[0], stderr); \ -! fputs(mess, stderr); \ -! (void) putc(ch, stderr); \ -! (void) putc('\n', stderr); \ -! } \ -! return('?') - - int -! getopt_l(argc, argv, optstring) - int argc; - char *argv[]; ---- 23,53 ---- - #endif /* lint */ - -! char *ntp_optarg; /* Global argument pointer. */ -! int ntp_optind = 0; /* Global argv index. */ -! int ntp_opterr = 1; /* for compatibility, should error be printed? */ -! int ntp_optopt; /* for compatibility, option character checked */ - - static char *scan = NULL; /* Private scan pointer. */ -+ static char *prog = "amnesia"; - - /* -! * Print message about a bad option. - */ -! static int -! badopt(mess, ch) -! char *mess; -! int ch; -! { -! if (ntp_opterr) { -! fputs(prog, stderr); -! fputs(mess, stderr); -! (void) putc(ch, stderr); -! (void) putc('\n', stderr); -! } -! return ('?'); -! } - - int -! ntp_getopt(argc, argv, optstring) - int argc; - char *argv[]; -*************** -*** 61,85 **** - register char *place; - -! optarg = NULL; - -! if (optind == 0) { - scan = NULL; -! optind++; - } - - if (scan == NULL || *scan == '\0') { -! if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') -! return EOF; -! if (argv[optind][1] == '-' && argv[optind][2] == '\0') { -! optind++; -! return EOF; - } - -! scan = argv[optind]+1; -! optind++; - } - - c = *scan++; -! optopt = c & 0377; - for (place = optstring; place != NULL && *place != '\0'; ++place) - if (*place == c) ---- 57,85 ---- - register char *place; - -! prog = argv[0]; -! ntp_optarg = NULL; - -! if (ntp_optind == 0) { - scan = NULL; -! ntp_optind++; - } - - if (scan == NULL || *scan == '\0') { -! if (ntp_optind >= argc -! || argv[ntp_optind][0] != '-' -! || argv[ntp_optind][1] == '\0') { -! return (EOF); -! } -! if (argv[ntp_optind][1] == '-' -! && argv[ntp_optind][2] == '\0') { -! ntp_optind++; -! return (EOF); - } - -! scan = argv[ntp_optind++]+1; - } - - c = *scan++; -! ntp_optopt = c & 0377; - for (place = optstring; place != NULL && *place != '\0'; ++place) - if (*place == c) -*************** -*** 87,91 **** - - if (place == NULL || *place == '\0' || c == ':' || c == '?') { -! BADOPT(": unknown option -", c); - } - ---- 87,91 ---- - - if (place == NULL || *place == '\0' || c == ':' || c == '?') { -! return (badopt(": unknown option -", c)); - } - -*************** -*** 93,106 **** - if (*place == ':') { - if (*scan != '\0') { -! optarg = scan; - scan = NULL; -! } else if (optind >= argc) { -! BADOPT(": option requires argument -", c); - } else { -! optarg = argv[optind]; -! optind++; - } - } - -! return c&0377; - } ---- 93,105 ---- - if (*place == ':') { - if (*scan != '\0') { -! ntp_optarg = scan; - scan = NULL; -! } else if (ntp_optind >= argc) { -! return (badopt(": option requires argument -", c)); - } else { -! ntp_optarg = argv[ntp_optind++]; - } - } - -! return (c & 0377); - } -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/machines.c Wed Jan 26 16:33:33 1994 -*************** -*** 1,18 **** -! /* -! * provide special support for peculiar architectures - * - * Real bummers unite ! - */ - - #ifdef SYS_PTX - #include - #include -! int settimeofday(tvp) - struct timeval *tvp; - { -! return stime(&tvp->tv_sec); /* lie as bad as SysVR4 */ - } - -! int gettimeofday(tvp) - struct timeval *tvp; - { ---- 1,24 ---- -! /* machines.c - provide special support for peculiar architectures - * - * Real bummers unite ! -+ * -+ * $Id:$ - */ - -+ #include "ntp_stdlib.h" -+ - #ifdef SYS_PTX - #include - #include -! -! int -! settimeofday(tvp) - struct timeval *tvp; - { -! return (stime(&tvp->tv_sec)); /* lie as bad as SysVR4 */ - } - -! int -! gettimeofday(tvp) - struct timeval *tvp; - { -*************** -*** 21,118 **** - * this is also the most logical syscall for such a function - */ -! return get_process_stats(tvp, PS_SELF, (struct procstats *) 0, -! (struct procstats *) 0); -! } -! #endif -! -! #ifdef SYS_HPUX -! /* hpux.c,v 3.1 1993/07/06 01:08:23 jbj Exp -! * hpux.c -- compatibility routines for HP-UX. -! * XXX many of these are not needed anymore. -! */ -! #include "ntp_machine.h" -! -! #ifdef HAVE_UNISTD_H -! #include -! #endif -! #include -! -! #include "ntp_stdlib.h" -! -! #if (SYS_HPUX < 8) -! char -! *index(s, c) -! register char *s; -! register int c; -! { -! return strchr (s, c); -! } -! -! -! char -! *rindex(s, c) -! register char *s; -! register int c; -! { -! return strrchr (s, c); -! } -! -! -! int -! bcmp(a, b, count) -! register char *a, *b; -! register int count; -! { -! return memcmp (a, b, count); -! } -! -! -! void -! bcopy(from, to, count) -! register char *from; -! register char *to; -! register int count; -! { -! if ((to == from) || (count <= 0)) -! return; -! -! if ((to > from) && (to <= (from + count))) { -! to += count; -! from += count; -! -! do { -! *--to = *--from; -! } while (--count); -! } -! else { -! do { -! *to++ = *from++; -! } while (--count); -! } -! } -! -! -! void -! bzero(area, count) -! register char *area; -! register int count; -! { -! memset(area, 0, count); - } - #endif - -! -! getdtablesize() -! { -! return(sysconf(_SC_OPEN_MAX)); -! } -! -! -! int -! setlinebuf(a_stream) -! FILE *a_stream; - { -! return setvbuf(a_stream, (char *) NULL, _IOLBF, 0); - } -! -! #endif ---- 27,43 ---- - * this is also the most logical syscall for such a function - */ -! return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0, -! (struct procstats *) 0)); - } - #endif - -! #if !defined(NTP_POSIX_SOURCE) -! void -! ntp_memset(a, x, c) -! char *a; -! int x, c; - { -! while (c-- > 0) -! *a++ = x; - } -! #endif /*POSIX*/ -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/numtohost.c Wed Jan 26 16:37:59 1994 -*************** -*** 2,6 **** - * numtohost - convert network number to host name. - */ -- #include "ntp_string.h" - #include - ---- 2,5 ---- -*** /tmp/RCSA023460 Wed Jan 26 17:56:34 1994 ---- lib/systime.c Wed Jan 26 16:33:33 1994 -*************** -*** 346,350 **** - */ - if (oldtime != timetv.tv_sec) { -! bzero((char *)&ut, sizeof(ut)); - ut.ut_type = OLD_TIME; - ut.ut_time = oldtime; ---- 346,350 ---- - */ - if (oldtime != timetv.tv_sec) { -! memset((char *)&ut, 0, sizeof(ut)); - ut.ut_type = OLD_TIME; - ut.ut_time = oldtime; -*** /tmp/RCSA023486 Wed Jan 26 17:56:35 1994 ---- machines/bsdi Wed Jan 26 16:33:33 1994 -*************** -*** 1,5 **** - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_BSDI -DHAVE_TERMIOS - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK ---- 1,5 ---- - RANLIB= ranlib - DEFS_LOCAL=-DREFCLOCK -! DEFS= -DSYS_BSDI - AUTHDEFS= -DDES -DMD5 - CLOCKDEFS= -DLOCAL_CLOCK -*** /tmp/RCSA023490 Wed Jan 26 17:56:36 1994 ---- ntpdate/ntpdate.c Wed Jan 26 16:33:34 1994 -*************** -*** 168,173 **** - int errflg; - int c; -! extern char *optarg; -! extern int optind; - extern char *Version; - ---- 168,173 ---- - int errflg; - int c; -! extern char *ntp_optarg; -! extern int ntp_optind; - extern char *Version; - -*************** -*** 179,186 **** - * Decode argument list - */ -! while ((c = getopt_l(argc, argv, "a:bde:k:o:p:qst:v")) != EOF) - switch (c) { - case 'a': -! c = atoi(optarg); - sys_authenticate = 1; - sys_authkey = (U_LONG)c; ---- 179,186 ---- - * Decode argument list - */ -! while ((c = ntp_getopt(argc, argv, "a:bde:k:o:p:qst:v")) != EOF) - switch (c) { - case 'a': -! c = atoi(ntp_optarg); - sys_authenticate = 1; - sys_authkey = (U_LONG)c; -*************** -*** 193,201 **** - break; - case 'e': -! if (!atolfp(optarg, &tmp) - || tmp.l_ui != 0) { - (void) fprintf(stderr, - "%s: encryption delay %s is unlikely\n", -! progname, optarg); - errflg++; - } else { ---- 193,201 ---- - break; - case 'e': -! if (!atolfp(ntp_optarg, &tmp) - || tmp.l_ui != 0) { - (void) fprintf(stderr, - "%s: encryption delay %s is unlikely\n", -! progname, ntp_optarg); - errflg++; - } else { -*************** -*** 204,214 **** - break; - case 'k': -! key_file = optarg; - break; - case 'o': -! sys_version = atoi(optarg); - break; - case 'p': -! c = atoi(optarg); - if (c <= 0 || c > NTP_SHIFT) { - (void) fprintf(stderr, ---- 204,214 ---- - break; - case 'k': -! key_file = ntp_optarg; - break; - case 'o': -! sys_version = atoi(ntp_optarg); - break; - case 'p': -! c = atoi(ntp_optarg); - if (c <= 0 || c > NTP_SHIFT) { - (void) fprintf(stderr, -*************** -*** 227,234 **** - break; - case 't': -! if (!atolfp(optarg, &tmp)) { - (void) fprintf(stderr, - "%s: timeout %s is undecodeable\n", -! progname, optarg); - errflg++; - } else { ---- 227,234 ---- - break; - case 't': -! if (!atolfp(ntp_optarg, &tmp)) { - (void) fprintf(stderr, - "%s: timeout %s is undecodeable\n", -! progname, ntp_optarg); - errflg++; - } else { -*************** -*** 249,253 **** - } - -! sys_maxservers = argc - optind; - if (errflg || sys_maxservers == 0) { - (void) fprintf(stderr, ---- 249,253 ---- - } - -! sys_maxservers = argc - ntp_optind; - if (errflg || sys_maxservers == 0) { - (void) fprintf(stderr, -*************** -*** 294,299 **** - * Add servers we are going to be polling - */ -! for ( ; optind < argc; optind++) -! addserver(argv[optind]); - - if (sys_numservers == 0) { ---- 294,299 ---- - * Add servers we are going to be polling - */ -! for ( ; ntp_optind < argc; ntp_optind++) -! addserver(argv[ntp_optind]); - - if (sys_numservers == 0) { -*************** -*** 1031,1035 **** - - server = (struct server *)emalloc(sizeof(struct server)); -! bzero((char *)server, sizeof(struct server)); - - server->srcadr.sin_family = AF_INET; ---- 1031,1035 ---- - - server = (struct server *)emalloc(sizeof(struct server)); -! memset((char *)server, 0, sizeof(struct server)); - - server->srcadr.sin_family = AF_INET; -*************** -*** 1189,1193 **** - struct sockaddr_in addr; - -! bzero((char *)&addr, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); ---- 1189,1193 ---- - struct sockaddr_in addr; - -! memset((char *)&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); -*************** -*** 1483,1490 **** - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! bcopy(hp->h_addr, (char *)num, sizeof(U_LONG)); -! return 1; - } -! return 0; - } - ---- 1483,1490 ---- - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! memmove((char *)num, hp->h_addr, sizeof(U_LONG)); -! return (1); - } -! return (0); - } - -*************** -*** 1520,1524 **** - if (pp->stratum == 1) { - junk[4] = 0; -! bcopy((char *)&pp->refid, junk, 4); - str = junk; - } else { ---- 1520,1524 ---- - if (pp->stratum == 1) { - junk[4] = 0; -! memmove(junk, (char *)&pp->refid, 4); - str = junk; - } else { -*** /tmp/RCSA023494 Wed Jan 26 17:56:37 1994 ---- ntpq/ntpq.c Wed Jan 26 16:33:34 1994 -*************** -*** 510,515 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - delay_time.l_ui = 0; ---- 510,515 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - delay_time.l_ui = 0; -*************** -*** 517,524 **** - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "c:dinp")) != EOF) - switch (c) { - case 'c': -! ADDCMD(optarg); - break; - case 'd': ---- 517,524 ---- - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "c:dinp")) != EOF) - switch (c) { - case 'c': -! ADDCMD(ntp_optarg); - break; - case 'd': -*************** -*** 544,552 **** - exit(2); - } -! if (optind == argc) { - ADDHOST(DEFHOST); - } else { -! for (; optind < argc; optind++) -! ADDHOST(argv[optind]); - } - ---- 544,552 ---- - exit(2); - } -! if (ntp_optind == argc) { - ADDHOST(DEFHOST); - } else { -! for (; ntp_optind < argc; ntp_optind++) -! ADDHOST(argv[ntp_optind]); - } - -*************** -*** 983,987 **** - * Copy the data into the data buffer. - */ -! bcopy((char *)rpkt.data, (char *)pktdata + offset, count); - - /* ---- 983,987 ---- - * Copy the data into the data buffer. - */ -! memmove((char *)pktdata + offset, (char *)rpkt.data, count); - - /* -*************** -*** 1051,1055 **** - */ - if (qsize > 0) { -! bcopy(qdata, (char *)qpkt.data, qsize); - pktsize = qsize + CTL_HEADER_LEN; - while (pktsize & (sizeof(U_LONG)-1)) { ---- 1051,1055 ---- - */ - if (qsize > 0) { -! memmove((char *)qpkt.data, qdata, qsize); - pktsize = qsize + CTL_HEADER_LEN; - while (pktsize & (sizeof(U_LONG)-1)) { -*************** -*** 1542,1546 **** - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! bcopy(hp->h_addr, (char *)num, sizeof(U_LONG)); - if (fullhost != 0) - (void) strcpy(fullhost, hp->h_name); ---- 1542,1546 ---- - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! memmove((char *)num, hp->h_addr, sizeof(U_LONG)); - if (fullhost != 0) - (void) strcpy(fullhost, hp->h_name); -*** /tmp/RCSA023494 Wed Jan 26 17:56:37 1994 ---- ntpq/ntpq_ops.c Wed Jan 26 16:33:34 1994 -*************** -*** 218,221 **** ---- 218,222 ---- - /* - * strsave - save a string -+ * XXX - should be in libntp.a - */ - static char * -*************** -*** 232,237 **** - } - -! bcopy(str, cp, len); -! return cp; - } - ---- 233,238 ---- - } - -! memmove(cp, str, len); -! return (cp); - } - -*************** -*** 373,381 **** - if (cp != data) - *cp++ = ','; -! bcopy(vl->name, cp, namelen); - cp += namelen; - if (valuelen != 0) { - *cp++ = '='; -! bcopy(vl->value, cp, valuelen); - cp += valuelen; - } ---- 374,382 ---- - if (cp != data) - *cp++ = ','; -! memmove(cp, vl->name, namelen); - cp += namelen; - if (valuelen != 0) { - *cp++ = '='; -! memmove(cp, vl->value, valuelen); - cp += valuelen; - } -*************** -*** 601,605 **** - return; - -! bzero((char *)tmplist, sizeof(tmplist)); - if (pcmd->nargs >= 2) - doaddvlist(tmplist, pcmd->argval[1].string); ---- 602,606 ---- - return; - -! memset((char *)tmplist, 0, sizeof(tmplist)); - if (pcmd->nargs >= 2) - doaddvlist(tmplist, pcmd->argval[1].string); -*************** -*** 632,636 **** - return; - -! bzero((char *)tmplist, sizeof(tmplist)); - doaddvlist(tmplist, pcmd->argval[1].string); - ---- 633,637 ---- - return; - -! memset((char *)tmplist, 0, sizeof(tmplist)); - doaddvlist(tmplist, pcmd->argval[1].string); - -*************** -*** 691,695 **** - return; - -! bzero((char *)tmplist, sizeof(tmplist)); - if (pcmd->nargs >= 2) - doaddvlist(tmplist, pcmd->argval[1].string); ---- 692,696 ---- - return; - -! memset((char *)tmplist, 0, sizeof(tmplist)); - if (pcmd->nargs >= 2) - doaddvlist(tmplist, pcmd->argval[1].string); -*************** -*** 803,807 **** - return; - -! bzero((char *)tmplist, sizeof(tmplist)); - if (pcmd->nargs >= 3) - doaddvlist(tmplist, pcmd->argval[2].string); ---- 804,808 ---- - return; - -! memset((char *)tmplist, 0, sizeof(tmplist)); - if (pcmd->nargs >= 3) - doaddvlist(tmplist, pcmd->argval[2].string); -*************** -*** 1283,1287 **** - extern struct ctl_var peer_var[]; - -! bzero((char *)havevar, sizeof(havevar)); - gettstamp(&ts); - ---- 1284,1288 ---- - extern struct ctl_var peer_var[]; - -! memset((char *)havevar, 0, sizeof(havevar)); - gettstamp(&ts); - -*** /tmp/RCSA023500 Wed Jan 26 17:56:38 1994 ---- ntptrace/ntptrace.c Wed Jan 26 16:33:35 1994 -*************** -*** 112,117 **** - int errflg; - int c; -! extern char *optarg; -! extern int optind; - extern char *Version; - ---- 112,117 ---- - int errflg; - int c; -! extern char *ntp_optarg; -! extern int ntp_optind; - extern char *Version; - -*************** -*** 122,126 **** - * Decode argument list - */ -! while ((c = getopt_l(argc, argv, "do:nr:t:v")) != EOF) - switch (c) { - case 'd': ---- 122,126 ---- - * Decode argument list - */ -! while ((c = ntp_getopt(argc, argv, "do:nr:t:v")) != EOF) - switch (c) { - case 'd': -*************** -*** 131,138 **** - break; - case 'o': -! sys_version = atoi(optarg); - break; - case 'r': -! sys_retries = atoi(optarg); - if (sys_retries < 1) { - (void)fprintf(stderr, ---- 131,138 ---- - break; - case 'o': -! sys_version = atoi(ntp_optarg); - break; - case 'r': -! sys_retries = atoi(ntp_optarg); - if (sys_retries < 1) { - (void)fprintf(stderr, -*************** -*** 143,147 **** - break; - case 't': -! sys_timeout = atoi(optarg); - if (sys_timeout < 1) { - (void)fprintf(stderr, ---- 143,147 ---- - break; - case 't': -! sys_timeout = atoi(ntp_optarg); - if (sys_timeout < 1) { - (void)fprintf(stderr, -*************** -*** 161,165 **** - } - -! if (errflg || (argc - optind) > 1) { - (void) fprintf(stderr, - "usage: %s [-vnd] [-r retries] [-t timeout] [server]\n", ---- 161,165 ---- - } - -! if (errflg || (argc - ntp_optind) > 1) { - (void) fprintf(stderr, - "usage: %s [-vnd] [-r retries] [-t timeout] [server]\n", -*************** -*** 183,188 **** - syslog(LOG_NOTICE, "%s", Version); - -! if ((argc - optind) == 1) -! firstserver = addservbyname(argv[optind]); - else - firstserver = addservbyname("localhost"); ---- 183,188 ---- - syslog(LOG_NOTICE, "%s", Version); - -! if ((argc - ntp_optind) == 1) -! firstserver = addservbyname(argv[ntp_optind]); - else - firstserver = addservbyname("localhost"); -*************** -*** 503,507 **** - - server = (struct server *)emalloc(sizeof(struct server)); -! bzero((char *)server, sizeof(struct server)); - - server->srcadr.sin_family = AF_INET; ---- 503,507 ---- - - server = (struct server *)emalloc(sizeof(struct server)); -! memset((char *)server, 0, sizeof(struct server)); - - server->srcadr.sin_family = AF_INET; -*************** -*** 617,621 **** - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! bcopy(hp->h_addr, (char *)num, sizeof(U_LONG)); - return 1; - } ---- 617,621 ---- - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! memmove((char *)num, hp->h_addr, sizeof(U_LONG)); - return 1; - } -*************** -*** 736,740 **** - if (pp->stratum == 1) { - junk[4] = 0; -! bcopy((char *)&pp->refid, junk, 4); - str = junk; - (void) fprintf(fp, "'%s'", str); ---- 736,740 ---- - if (pp->stratum == 1) { - junk[4] = 0; -! memmove(junk, (char *)&pp->refid, 4); - str = junk; - (void) fprintf(fp, "'%s'", str); -*** /tmp/RCSA023505 Wed Jan 26 17:56:39 1994 ---- parse/util/testdcf.c Wed Jan 26 16:33:35 1994 -*************** -*** 353,357 **** - } - -! bzero(term.c_cc, sizeof(term.c_cc)); - term.c_cc[VMIN] = 1; - term.c_cflag = B50|CS8|CREAD|CLOCAL; ---- 353,357 ---- - } - -! memset(term.c_cc, 0, sizeof(term.c_cc)); - term.c_cc[VMIN] = 1; - term.c_cflag = B50|CS8|CREAD|CLOCAL; -*** /tmp/RCSA023510 Wed Jan 26 17:56:40 1994 ---- ppsclock/ppstest/ppstest.c Wed Jan 26 16:33:35 1994 -*************** -*** 103,107 **** - speed_t speed = B4800; - -! bzero((char *)&termios, sizeof(termios)); - termios.c_cflag = CS8 | CREAD | CLOCAL; - termios.c_iflag = IGNCR; ---- 103,107 ---- - speed_t speed = B4800; - -! memset((char *)&termios, 0, sizeof(termios)); - termios.c_cflag = CS8 | CREAD | CLOCAL; - termios.c_iflag = IGNCR; -*** /tmp/RCSA023525 Wed Jan 26 17:56:43 1994 ---- scripts/autoconf Wed Jan 26 16:33:35 1994 -*************** -*** 324,329 **** - { - test -n "$verbose" && \ -! echo ' defining' HAVE_UNISTD_H -! DEFS="$DEFS -DHAVE_UNISTD_H=1" - } - ---- 324,329 ---- - { - test -n "$verbose" && \ -! echo ' defining' NTP_POSIX_SOURCE -! DEFS="$DEFS -DNTP_POSIX_SOURCE=1" - } - -*** /tmp/RCSA023535 Wed Jan 26 17:56:46 1994 ---- util/Makefile.tmpl Wed Jan 26 16:33:35 1994 -*************** -*** 33,37 **** - - tickadj: $(TKOBJS) -! $(CC) $(COPTS) -o $@ $(TKOBJS) $(DAEMONLIBS) $(RESLIB) $(COMPAT) - - ntptime: $(NTOBJS) ---- 33,37 ---- - - tickadj: $(TKOBJS) -! $(CC) $(COPTS) -o $@ $(TKOBJS) $(LIB) $(DAEMONLIBS) $(RESLIB) $(COMPAT) - - ntptime: $(NTOBJS) -*** /tmp/RCSA023535 Wed Jan 26 17:56:47 1994 ---- util/ntptime.c Wed Jan 26 16:33:36 1994 -*************** -*** 38,42 **** - extern int sigvec P((int, struct sigvec *, struct sigvec *)); - void pll_trap P((void)); -- extern int getopt_l P((int, char **, char *)); - - static struct sigvec newsigsys; /* new sigvec status */ ---- 38,41 ---- -*************** -*** 52,57 **** - char *argv[]; - { -! extern int optind; -! extern char *optarg; - int status; - struct ntptimeval ntv; ---- 51,56 ---- - char *argv[]; - { -! extern int ntp_optind; -! extern char *ntp_optarg; - int status; - struct ntptimeval ntv; -*************** -*** 67,71 **** - ntx.mode = 0; - progname = argv[0]; -! while ((c = getopt_l(argc, argv, optargs)) != EOF) switch (c) { - case 'c': - cost++; ---- 66,70 ---- - ntx.mode = 0; - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, optargs)) != EOF) switch (c) { - case 'c': - cost++; -*************** -*** 73,81 **** - case 'e': - ntx.mode |= ADJ_ESTERROR; -! ntx.esterror = atoi(optarg); - break; - case 'f': - ntx.mode |= ADJ_FREQUENCY; -! ntx.frequency = (int) (atof(optarg) * (1 << SHIFT_USEC)); - if (ntx.frequency < (-100 << SHIFT_USEC) - || ntx.frequency > ( 100 << SHIFT_USEC)) errflg++; ---- 72,81 ---- - case 'e': - ntx.mode |= ADJ_ESTERROR; -! ntx.esterror = atoi(ntp_optarg); - break; - case 'f': - ntx.mode |= ADJ_FREQUENCY; -! ntx.frequency = (int) (atof(ntp_optarg) -! * (1 << SHIFT_USEC)); - if (ntx.frequency < (-100 << SHIFT_USEC) - || ntx.frequency > ( 100 << SHIFT_USEC)) errflg++; -*************** -*** 83,91 **** - case 'm': - ntx.mode |= ADJ_MAXERROR; -! ntx.maxerror = atoi(optarg); - break; - case 'o': - ntx.mode |= ADJ_OFFSET; -! ntx.offset = atoi(optarg); - break; - case 'r': ---- 83,91 ---- - case 'm': - ntx.mode |= ADJ_MAXERROR; -! ntx.maxerror = atoi(ntp_optarg); - break; - case 'o': - ntx.mode |= ADJ_OFFSET; -! ntx.offset = atoi(ntp_optarg); - break; - case 'r': -*************** -*** 94,98 **** - case 's': - ntx.mode |= ADJ_STATUS; -! ntx.status = atoi(optarg); - if (ntx.status < 0 || ntx.status > 4) errflg++; - break; ---- 94,98 ---- - case 's': - ntx.mode |= ADJ_STATUS; -! ntx.status = atoi(ntp_optarg); - if (ntx.status < 0 || ntx.status > 4) errflg++; - break; -*************** -*** 99,103 **** - case 't': - ntx.mode |= ADJ_TIMECONST; -! ntx.time_constant = atoi(optarg); - if (ntx.time_constant < 0 || ntx.time_constant > MAXTC) - errflg++; ---- 99,103 ---- - case 't': - ntx.mode |= ADJ_TIMECONST; -! ntx.time_constant = atoi(ntp_optarg); - if (ntx.time_constant < 0 || ntx.time_constant > MAXTC) - errflg++; -*************** -*** 106,110 **** - errflg++; - } -! if (errflg || (optind != argc)) { - (void) fprintf(stderr, - "usage: %s [-%s]\n\n\ ---- 106,110 ---- - errflg++; - } -! if (errflg || (ntp_optind != argc)) { - (void) fprintf(stderr, - "usage: %s [-%s]\n\n\ -*** /tmp/RCSA023535 Wed Jan 26 17:56:47 1994 ---- util/tickadj.c Wed Jan 26 16:33:36 1994 -*************** -*** 62,68 **** - static void writevar P((int, unsigned long, int)); - static void readvar P((int, unsigned long, int *)); -- #ifndef NTP_POSIX_SOURCE -- extern int getopt P((int, char **, char *)); -- #endif - - /* ---- 62,65 ---- -*************** -*** 76,81 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - unsigned long tickadj_offset; - unsigned long tick_offset; ---- 73,78 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - unsigned long tickadj_offset; - unsigned long tick_offset; -*************** -*** 95,99 **** - - progname = argv[0]; -! while ((c = getopt(argc, argv, "a:Adkqpst:")) != EOF) - switch (c) { - case 'd': ---- 92,96 ---- - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "a:Adkqpst:")) != EOF) - switch (c) { - case 'd': -*************** -*** 110,118 **** - break; - case 'a': -! writetickadj = atoi(optarg); - if (writetickadj <= 0) { - (void) fprintf(stderr, - "%s: unlikely value for tickadj: %s\n", -! progname, optarg); - errflg++; - } ---- 107,115 ---- - break; - case 'a': -! writetickadj = atoi(ntp_optarg); - if (writetickadj <= 0) { - (void) fprintf(stderr, - "%s: unlikely value for tickadj: %s\n", -! progname, ntp_optarg); - errflg++; - } -*************** -*** 125,133 **** - break; - case 't': -! writetick = atoi(optarg); - if (writetick <= 0) { - (void) fprintf(stderr, - "%s: unlikely value for tick: %s\n", -! progname, optarg); - errflg++; - } ---- 122,130 ---- - break; - case 't': -! writetick = atoi(ntp_optarg); - if (writetick <= 0) { - (void) fprintf(stderr, - "%s: unlikely value for tick: %s\n", -! progname, ntp_optarg); - errflg++; - } -*************** -*** 137,141 **** - break; - } -! if (errflg || optind != argc) { - (void) fprintf(stderr, - "usage: %s [-Aqsp] [-a newadj] [-t newtick]\n", progname); ---- 134,138 ---- - break; - } -! if (errflg || ntp_optind != argc) { - (void) fprintf(stderr, - "usage: %s [-Aqsp] [-a newadj] [-t newtick]\n", progname); -*** /tmp/RCSA023543 Wed Jan 26 17:56:49 1994 ---- xntpd/ntp_config.c Wed Jan 26 16:33:36 1994 -*************** -*** 341,345 **** - int errflg; - int c; -! extern int optind; - - debug = 0; /* no debugging by default */ ---- 341,345 ---- - int errflg; - int c; -! extern int ntp_optind; - - debug = 0; /* no debugging by default */ -*************** -*** 353,357 **** - * the terminal, but we won't know to do that until we've - * parsed the command line. Do that now, crudely, and do it -! * again later. Our getopt_l() is explicitly reusable, by the - * way. Your own mileage may vary. - */ ---- 353,357 ---- - * the terminal, but we won't know to do that until we've - * parsed the command line. Do that now, crudely, and do it -! * again later. Our ntp_getopt() is explicitly reusable, by the - * way. Your own mileage may vary. - */ -*************** -*** 362,366 **** - * Decode argument list - */ -! while ((c = getopt_l(argc, argv, xntp_options)) != EOF) - switch (c) { - case 'd': ---- 362,366 ---- - * Decode argument list - */ -! while ((c = ntp_getopt(argc, argv, xntp_options)) != EOF) - switch (c) { - case 'd': -*************** -*** 374,378 **** - } - -! if (errflg || optind != argc) { - (void) fprintf(stderr, - "usage: %s [ -bd ] [ -c config_file ]\n", progname); ---- 374,378 ---- - } - -! if (errflg || ntp_optind != argc) { - (void) fprintf(stderr, - "usage: %s [ -bd ] [ -c config_file ]\n", progname); -*************** -*** 379,383 **** - exit(2); - } -! optind = 0; /* reset optind to restart getopt_l */ - - if (debug) { ---- 379,383 ---- - exit(2); - } -! ntp_optind = 0; /* reset optind to restart ntp_getopt() */ - - if (debug) { -*************** -*** 427,432 **** - int have_keyfile; - char keyfile[MAXFILENAME]; -! extern int optind; -! extern char *optarg; - extern U_LONG info_auth_keyid; - FILEGEN *filegen; ---- 427,432 ---- - int have_keyfile; - char keyfile[MAXFILENAME]; -! extern int ntp_optind; -! extern char *ntp_optarg; - extern U_LONG info_auth_keyid; - FILEGEN *filegen; -*************** -*** 451,455 **** - * Decode argument list - */ -! while ((c = getopt_l(argc, argv, xntp_options)) != EOF) { - switch (c) { - case 'a': ---- 451,455 ---- - * Decode argument list - */ -! while ((c = ntp_getopt(argc, argv, xntp_options)) != EOF) { - switch (c) { - case 'a': -*************** -*** 460,464 **** - break; - case 'c': -! config_file = optarg; - break; - case 'd': ---- 460,464 ---- - break; - case 'c': -! config_file = ntp_optarg; - break; - case 'd': -*************** -*** 474,481 **** - l_fp tmp; - -! if (!atolfp(optarg, &tmp)) { - syslog(LOG_ERR, - "command line encryption delay value %s undecodable", -! optarg); - errflg++; - } else if (tmp.l_ui != 0) { ---- 474,481 ---- - l_fp tmp; - -! if (!atolfp(ntp_optarg, &tmp)) { - syslog(LOG_ERR, - "command line encryption delay value %s undecodable", -! ntp_optarg); - errflg++; - } else if (tmp.l_ui != 0) { -*************** -*** 482,486 **** - syslog(LOG_ERR, - "command line encryption delay value %s is unlikely", -! optarg); - errflg++; - } else { ---- 482,486 ---- - syslog(LOG_ERR, - "command line encryption delay value %s is unlikely", -! ntp_optarg); - errflg++; - } else { -*************** -*** 491,500 **** - - case 'f': -! stats_config(STATS_FREQ_FILE, optarg); - break; - - case 'k': -! getauthkeys(optarg); -! if ((int)strlen(optarg) >= MAXFILENAME) { - syslog(LOG_ERR, - "key file name too LONG (>%d, sigh), no name resolution possible", ---- 491,500 ---- - - case 'f': -! stats_config(STATS_FREQ_FILE, ntp_optarg); - break; - - case 'k': -! getauthkeys(ntp_optarg); -! if ((int)strlen(ntp_optarg) >= MAXFILENAME) { - syslog(LOG_ERR, - "key file name too LONG (>%d, sigh), no name resolution possible", -*************** -*** 502,506 **** - } else { - have_keyfile = 1; -! (void)strcpy(keyfile, optarg); - } - break; ---- 502,506 ---- - } else { - have_keyfile = 1; -! (void)strcpy(keyfile, ntp_optarg); - } - break; -*************** -*** 507,511 **** - - case 'p': -! stats_config(STATS_PID_FILE, optarg); - break; - ---- 507,511 ---- - - case 'p': -! stats_config(STATS_PID_FILE, ntp_optarg); - break; - -*************** -*** 514,525 **** - l_fp tmp; - -! if (!atolfp(optarg, &tmp)) { - syslog(LOG_ERR, - "command line broadcast delay value %s undecodable", -! optarg); - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line broadcast delay value %s is unlikely", -! optarg); - } else { - proto_config(PROTO_BROADDELAY, tmp.l_f); ---- 514,525 ---- - l_fp tmp; - -! if (!atolfp(ntp_optarg, &tmp)) { - syslog(LOG_ERR, - "command line broadcast delay value %s undecodable", -! ntp_optarg); - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line broadcast delay value %s is unlikely", -! ntp_optarg); - } else { - proto_config(PROTO_BROADDELAY, tmp.l_f); -*************** -*** 529,533 **** - - case 's': -! stats_config(STATS_STATSDIR, optarg); - break; - ---- 529,533 ---- - - case 's': -! stats_config(STATS_STATSDIR, ntp_optarg); - break; - -*************** -*** 536,544 **** - int tkey; - -! tkey = atoi(optarg); - if (tkey <= 0 || tkey > NTP_MAXKEY) { - syslog(LOG_ERR, - "command line trusted key %s is unlikely", -! optarg); - } else { - authtrust(tkey, (LONG)1); ---- 536,544 ---- - int tkey; - -! tkey = atoi(ntp_optarg); - if (tkey <= 0 || tkey > NTP_MAXKEY) { - syslog(LOG_ERR, - "command line trusted key %s is unlikely", -! ntp_optarg); - } else { - authtrust(tkey, (LONG)1); -*************** -*** 554,558 **** - } - -! if (errflg || optind != argc) { - (void) fprintf(stderr, - "usage: %s [ -bd ] [ -c config_file ]\n", progname); ---- 554,558 ---- - } - -! if (errflg || ntp_optind != argc) { - (void) fprintf(stderr, - "usage: %s [ -bd ] [ -c config_file ]\n", progname); -*************** -*** 1130,1134 **** - } - -! bzero((char *)&clock, sizeof clock); - errflg = 0; - for (i = 2; i < ntokens-1; i++) { ---- 1130,1134 ---- - } - -! memset((char *)&clock, 0, sizeof clock); - errflg = 0; - for (i = 2; i < ntokens-1; i++) { -*************** -*** 1582,1586 **** - * make up socket address. Clear it out for neatness. - */ -! bzero((char *)addr, sizeof(struct sockaddr_in)); - addr->sin_family = AF_INET; - addr->sin_port = htons(NTP_PORT); ---- 1582,1586 ---- - * make up socket address. Clear it out for neatness. - */ -! memset((char *)addr, 0, sizeof(struct sockaddr_in)); - addr->sin_family = AF_INET; - addr->sin_port = htons(NTP_PORT); -*** /tmp/RCSA023543 Wed Jan 26 17:56:49 1994 ---- xntpd/ntp_control.c Wed Jan 26 16:33:36 1994 -*************** -*** 873,877 **** - } - -! bcopy(dp, (char *)datapt, dlen); - datapt += dlen; - datalinelen += dlen; ---- 873,877 ---- - } - -! memmove((char *)datapt, dp, dlen); - datapt += dlen; - datalinelen += dlen; -*************** -*** 901,905 **** - if (len > (sizeof(buffer) - (cp - buffer) - 1)) - len = sizeof(buffer) - (cp - buffer) - 1; -! bcopy(data, cp, len); - cp += len; - *cp++ = '"'; ---- 901,905 ---- - if (len > (sizeof(buffer) - (cp - buffer) - 1)) - len = sizeof(buffer) - (cp - buffer) - 1; -! memmove(cp, data, len); - cp += len; - *cp++ = '"'; -*************** -*** 1697,1701 **** - if (res_authokay) - ctl_sys_num_events = 0; -! bzero((char *)wants, CS_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { ---- 1697,1701 ---- - if (res_authokay) - ctl_sys_num_events = 0; -! memset((char *)wants, 0, CS_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { -*************** -*** 1733,1737 **** - if (res_authokay) - peer->num_events = 0; -! bzero((char*)wants, CP_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { ---- 1733,1737 ---- - if (res_authokay) - peer->num_events = 0; -! memset((char*)wants, 0, CP_MAXCODE+1); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { -*************** -*** 1906,1910 **** - rpkt.status = htons(ctlclkstatus(&clock)); - gotvar = 0; -! bzero((char*)wants, CC_MAXCODE+1); - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { ---- 1906,1910 ---- - rpkt.status = htons(ctlclkstatus(&clock)); - gotvar = 0; -! memset((char*)wants, 0, CC_MAXCODE+1); - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -*** /tmp/RCSA023543 Wed Jan 26 17:56:50 1994 ---- xntpd/ntp_intres.c Wed Jan 26 16:33:37 1994 -*************** -*** 295,299 **** - len = strlen(name) + 1; - cp = emalloc((unsigned)len); -! bcopy(name, cp, len); - - ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry)); ---- 295,299 ---- - len = strlen(name) + 1; - cp = emalloc((unsigned)len); -! memmove(cp, name, len); - - ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry)); -*************** -*** 348,354 **** - - if (h_errno == TRY_AGAIN) -! return 1; - #endif -! return 0; - } - ---- 348,354 ---- - - if (h_errno == TRY_AGAIN) -! return (1); - #endif -! return (0); - } - -*************** -*** 358,364 **** - * only return one. - */ -! (void) bcopy(hp->h_addr, (char *)&(entry->ce_peeraddr), -! sizeof(struct in_addr)); -! return 1; - } - ---- 358,365 ---- - * only return one. - */ -! memmove((char *)&(entry->ce_peeraddr), -! (char *)hp->h_addr, -! sizeof(struct in_addr)); -! return (1); - } - -*************** -*** 381,385 **** - } - -! bzero((char *)&saddr, sizeof(saddr)); - saddr.sin_family = AF_INET; - saddr.sin_port = htons(NTP_PORT); /* trash */ ---- 382,386 ---- - } - -! memset((char *)&saddr, 0, sizeof(saddr)); - saddr.sin_family = AF_INET; - saddr.sin_port = htons(NTP_PORT); /* trash */ -*************** -*** 449,453 **** - * Make up a request packet with the configuration info - */ -! bzero((char *)&reqpkt, sizeof(reqpkt)); - - reqpkt.rm_vn_mode = RM_VN_MODE(0, 0); ---- 450,454 ---- - * Make up a request packet with the configuration info - */ -! memset((char *)&reqpkt, 0, sizeof(reqpkt)); - - reqpkt.rm_vn_mode = RM_VN_MODE(0, 0); -*************** -*** 457,461 **** - reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */ - reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer)); -! bcopy((char *)conf, reqpkt.data, sizeof(struct conf_peer)); - reqpkt.keyid = htonl(req_keyid); - ---- 458,462 ---- - reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */ - reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer)); -! memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer)); - reqpkt.keyid = htonl(req_keyid); - -*** /tmp/RCSA023543 Wed Jan 26 17:56:50 1994 ---- xntpd/ntp_monitor.c Wed Jan 26 16:33:37 1994 -*************** -*** 103,107 **** - mon_hash = 0; - mon_hash_count = 0; -! bzero((char *)&mon_mru_list, sizeof mon_mru_list); - } - ---- 103,107 ---- - mon_hash = 0; - mon_hash_count = 0; -! memset((char *)&mon_mru_list, 0, sizeof mon_mru_list); - } - -*************** -*** 122,126 **** - mon_hash = (struct mon_data *) - emalloc(MON_HASH_SIZE * sizeof(struct mon_data)); -! bzero((char *)mon_hash, MON_HASH_SIZE*sizeof(struct mon_data)); - mon_hash_count = (int *)emalloc(MON_HASH_SIZE * sizeof(int)); - mon_free_mem = 0; ---- 122,127 ---- - mon_hash = (struct mon_data *) - emalloc(MON_HASH_SIZE * sizeof(struct mon_data)); -! memset((char *)mon_hash, 0, -! MON_HASH_SIZE*sizeof(struct mon_data)); - mon_hash_count = (int *)emalloc(MON_HASH_SIZE * sizeof(int)); - mon_free_mem = 0; -*** /tmp/RCSA023543 Wed Jan 26 17:56:50 1994 ---- xntpd/ntp_peer.c Wed Jan 26 16:33:37 1994 -*************** -*** 440,444 **** - * Zero the whole thing for now. We might be pickier later. - */ -! bzero((char *)peer, sizeof(struct peer)); - - peer->srcadr = *srcadr; ---- 440,444 ---- - * Zero the whole thing for now. We might be pickier later. - */ -! memset((char *)peer, 0, sizeof(struct peer)); - - peer->srcadr = *srcadr; -*** /tmp/RCSA023543 Wed Jan 26 17:56:51 1994 ---- xntpd/ntp_proto.c Wed Jan 26 16:33:37 1994 -*************** -*** 1079,1083 **** - else { - if (pps_control) -! bcopy(PPSREFID, (char *)&sys_refid, 4); - else - sys_refid = peer->srcadr.sin_addr.s_addr; ---- 1079,1083 ---- - else { - if (pps_control) -! memmove((char *)&sys_refid, PPSREFID, 4); - else - sys_refid = peer->srcadr.sin_addr.s_addr; -*************** -*** 1128,1132 **** - sys_refid = peer->refid; - else -! bcopy(PPSREFID, (char *)&sys_refid, 4); - } - } ---- 1128,1132 ---- - sys_refid = peer->refid; - else -! memmove((char *)&sys_refid, PPSREFID, 4); - } - } -*************** -*** 1251,1255 **** - printf("clear(%s)\n", ntoa(&peer->srcadr)); - #endif -! bzero(CLEAR_TO_ZERO(peer), LEN_CLEAR_TO_ZERO); - peer->hpoll = peer->minpoll; - peer->dispersion = NTP_MAXDISPERSE; ---- 1251,1255 ---- - printf("clear(%s)\n", ntoa(&peer->srcadr)); - #endif -! memset(CLEAR_TO_ZERO(peer), 0, LEN_CLEAR_TO_ZERO); - peer->hpoll = peer->minpoll; - peer->dispersion = NTP_MAXDISPERSE; -*** /tmp/RCSA023543 Wed Jan 26 17:56:51 1994 ---- xntpd/ntp_request.c Wed Jan 26 16:33:38 1994 -*************** -*** 313,317 **** - * Copy data out of exbuf into the packet. - */ -! bcopy(exbuf, &rpkt.data[0], itemsize); - seqno++; - databytes = 0; ---- 313,317 ---- - * Copy data out of exbuf into the packet. - */ -! memmove(&rpkt.data[0], exbuf, itemsize); - seqno++; - databytes = 0; -*************** -*** 683,687 **** - extern struct peer *sys_peer; - -! bzero((char *)&addr, sizeof addr); - addr.sin_family = AF_INET; - items = INFO_NITEMS(inpkt->err_nitems); ---- 683,687 ---- - extern struct peer *sys_peer; - -! memset((char *)&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - items = INFO_NITEMS(inpkt->err_nitems); -*************** -*** 774,778 **** - extern struct peer *sys_peer; - -! bzero((char *)&addr, sizeof addr); - addr.sin_family = AF_INET; - items = INFO_NITEMS(inpkt->err_nitems); ---- 774,778 ---- - extern struct peer *sys_peer; - -! memset((char *)&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - items = INFO_NITEMS(inpkt->err_nitems); -*************** -*** 1142,1146 **** - items = INFO_NITEMS(inpkt->err_nitems); - cp = (struct conf_peer *)inpkt->data; -! bzero((char *)&peeraddr, sizeof(struct sockaddr_in)); - peeraddr.sin_family = AF_INET; - peeraddr.sin_port = htons(NTP_PORT); ---- 1142,1146 ---- - items = INFO_NITEMS(inpkt->err_nitems); - cp = (struct conf_peer *)inpkt->data; -! memset((char *)&peeraddr, 0, sizeof(struct sockaddr_in)); - peeraddr.sin_family = AF_INET; - peeraddr.sin_port = htons(NTP_PORT); -*************** -*** 1452,1457 **** - items = INFO_NITEMS(inpkt->err_nitems); - cr = (struct conf_restrict *)inpkt->data; -! bzero((char *)&matchaddr, sizeof(struct sockaddr_in)); -! bzero((char *)&matchmask, sizeof(struct sockaddr_in)); - matchaddr.sin_family = AF_INET; - matchmask.sin_family = AF_INET; ---- 1452,1457 ---- - items = INFO_NITEMS(inpkt->err_nitems); - cr = (struct conf_restrict *)inpkt->data; -! memset((char *)&matchaddr, 0, sizeof(struct sockaddr_in)); -! memset((char *)&matchmask, 0, sizeof(struct sockaddr_in)); - matchaddr.sin_family = AF_INET; - matchmask.sin_family = AF_INET; -*************** -*** 1870,1874 **** - * Prepare sockaddr_in structure - */ -! bzero((char *)&laddr, sizeof laddr); - laddr.sin_family = AF_INET; - laddr.sin_port = ntohs(NTP_PORT); ---- 1870,1874 ---- - * Prepare sockaddr_in structure - */ -! memset((char *)&laddr, 0, sizeof laddr); - laddr.sin_family = AF_INET; - laddr.sin_port = ntohs(NTP_PORT); -*************** -*** 2096,2100 **** - struct sockaddr_in addr; - -! bzero((char *)&addr, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); ---- 2096,2100 ---- - struct sockaddr_in addr; - -! memset((char *)&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); -*************** -*** 2150,2155 **** - struct sockaddr_in addr; - -! bzero((char *)&addr, sizeof addr); -! bzero((char *)&clock, sizeof clock); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); ---- 2150,2155 ---- - struct sockaddr_in addr; - -! memset((char *)&addr, 0, sizeof addr); -! memset((char *)&clock, 0, sizeof clock); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); -*************** -*** 2287,2291 **** - struct sockaddr_in addr; - -! bzero((char *)&addr, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); ---- 2287,2291 ---- - struct sockaddr_in addr; - -! memset((char *)&addr, 0, sizeof addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(NTP_PORT); -*************** -*** 2304,2308 **** - } - -! bzero((char *)&bug, sizeof bug); - refclock_buginfo(&addr, &bug); - if (bug.nvalues == 0 && bug.ntimes == 0) { ---- 2304,2308 ---- - } - -! memset((char *)&bug, 0, sizeof bug); - refclock_buginfo(&addr, &bug); - if (bug.nvalues == 0 && bug.ntimes == 0) { -*** /tmp/RCSA023543 Wed Jan 26 17:56:52 1994 ---- xntpd/ntp_restrict.c Wed Jan 26 16:33:38 1994 -*************** -*** 82,86 **** - */ - resfree = 0; -! bzero((char *)resinit, sizeof resinit); - - for (i = 1; i < INITRESLIST; i++) { ---- 82,86 ---- - */ - resfree = 0; -! memset((char *)resinit, 0, sizeof resinit); - - for (i = 1; i < INITRESLIST; i++) { -*************** -*** 235,239 **** - rl = (struct restrictlist *) emalloc( - INCRESLIST*sizeof(struct restrictlist)); -! bzero((char *)rl, - INCRESLIST*sizeof(struct restrictlist)); - ---- 235,239 ---- - rl = (struct restrictlist *) emalloc( - INCRESLIST*sizeof(struct restrictlist)); -! memset((char *)rl, 0, - INCRESLIST*sizeof(struct restrictlist)); - -*************** -*** 281,285 **** - rlprev->next = rl->next; - restrictcount--; -! bzero((char *)rl, sizeof(struct restrictlist)); - - rl->next = resfree; ---- 281,285 ---- - rlprev->next = rl->next; - restrictcount--; -! memset((char *)rl, 0, sizeof(struct restrictlist)); - - rl->next = resfree; -*** /tmp/RCSA023543 Wed Jan 26 17:56:52 1994 ---- xntpd/ntp_util.c Wed Jan 26 16:33:39 1994 -*************** -*** 224,230 **** - stats_drift_file = emalloc((u_int)(len + 1)); - stats_temp_file = emalloc((u_int)(len + sizeof(".TEMP"))); -! bcopy(value, stats_drift_file, len+1); -! bcopy(value, stats_temp_file, len); -! bcopy(".TEMP", stats_temp_file + len, sizeof(".TEMP")); - L_CLR(&old_drift); - ---- 224,230 ---- - stats_drift_file = emalloc((u_int)(len + 1)); - stats_temp_file = emalloc((u_int)(len + sizeof(".TEMP"))); -! memmove(stats_drift_file, value, len+1); -! memmove(stats_temp_file, value, len); -! memmove(stats_temp_file + len, ".TEMP", sizeof(".TEMP")); - L_CLR(&old_drift); - -*************** -*** 450,454 **** - key_file_name = emalloc((u_int)(len + 1)); - -! bcopy(keyfile, key_file_name, len+1); - - authreadkeys(key_file_name); ---- 450,454 ---- - key_file_name = emalloc((u_int)(len + 1)); - -! memmove(key_file_name, keyfile, len+1); - - authreadkeys(key_file_name); -*** /tmp/RCSA023543 Wed Jan 26 17:56:52 1994 ---- xntpd/refclock_as2201.c Wed Jan 26 16:33:39 1994 -*************** -*** 251,256 **** - * Just zero the data arrays - */ -! bzero((char *)gpsunits, sizeof gpsunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 251,256 ---- - * Just zero the data arrays - */ -! memset((char *)gpsunits, 0, sizeof gpsunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 442,446 **** - } - } -! bzero((char *)gps, sizeof(struct gpsunit)); - gpsunits[unit] = gps; - ---- 442,446 ---- - } - } -! memset((char *)gps, 0, sizeof(struct gpsunit)); - gpsunits[unit] = gps; - -*************** -*** 480,484 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(GPSREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(GPSHSREFID); ---- 480,484 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, GPSREFID, 4); - else - peer->refid = htonl(GPSHSREFID); -*************** -*** 908,913 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(GPSREFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(GPSHSREFID); ---- 908,913 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! GPSREFID, 4); - else - peer->refid = htonl(GPSHSREFID); -*** /tmp/RCSA023543 Wed Jan 26 17:56:52 1994 ---- xntpd/refclock_chu.c Wed Jan 26 16:33:39 1994 -*************** -*** 294,299 **** - * Just zero the data arrays - */ -! bzero((char *)chuunits, sizeof chuunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 294,299 ---- - * Just zero the data arrays - */ -! memset((char *)chuunits, 0, sizeof chuunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 462,466 **** - } - } -! bzero((char *)chu, sizeof(struct chuunit)); - chuunits[unit] = chu; - ---- 462,466 ---- - } - } -! memset((char *)chu, 0, sizeof(struct chuunit)); - chuunits[unit] = chu; - -*************** -*** 499,507 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(CHUREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(CHUHSREFID); - unitinuse[unit] = 1; -! return 1; - - /* ---- 499,507 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, CHUREFID, 4); - else - peer->refid = htonl(CHUHSREFID); - unitinuse[unit] = 1; -! return (1); - - /* -*************** -*** 1091,1095 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(CHUREFID, (char *)&peer->refid,4); - else - peer->refid = htonl(CHUHSREFID); ---- 1091,1096 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! CHUREFID, 4); - else - peer->refid = htonl(CHUHSREFID); -*** /tmp/RCSA023543 Wed Jan 26 17:56:53 1994 ---- xntpd/refclock_goes.c Wed Jan 26 16:33:39 1994 -*************** -*** 211,216 **** - * Just zero the data arrays - */ -! bzero((char *)goesunits, sizeof goesunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 211,216 ---- - * Just zero the data arrays - */ -! memset((char *)goesunits, 0, sizeof goesunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 401,405 **** - } - } -! bzero((char *)goes, sizeof(struct goesunit)); - goesunits[unit] = goes; - ---- 401,405 ---- - } - } -! memset((char *)goes, 0, sizeof(struct goesunit)); - goesunits[unit] = goes; - -*************** -*** 429,433 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(GOESREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(GOESHSREFID); ---- 429,433 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, GOESREFID, 4); - else - peer->refid = htonl(GOESHSREFID); -*************** -*** 924,929 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(GOESREFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(GOESHSREFID); ---- 924,929 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! GOESREFID, 4); - else - peer->refid = htonl(GOESHSREFID); -*** /tmp/RCSA023543 Wed Jan 26 17:56:53 1994 ---- xntpd/refclock_gpstm.c Wed Jan 26 16:52:22 1994 -*************** -*** 18,22 **** - #ifdef SYS_BSDI - #undef HAVE_BSD_TTYS -- #define HAVE_POSIX_TTYS - #include - #endif ---- 18,21 ---- -*************** -*** 30,34 **** - #endif /* HAVE_SYSV_TTYS */ - -! #if defined(HAVE_POSIX_TTYS) - #include - #endif ---- 29,33 ---- - #endif /* HAVE_SYSV_TTYS */ - -! #if defined(HAVE_TERMIOS) - #include - #endif -*************** -*** 203,208 **** - * Just zero the data arrays - */ -! bzero((char *)gpstm_units, sizeof gpstm_units); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 202,207 ---- - * Just zero the data arrays - */ -! memset((char *)gpstm_units, 0, sizeof gpstm_units); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 278,282 **** - } - #endif /* HAVE_SYSV_TTYS */ -! #if defined(HAVE_POSIX_TTYS) - /* - * POSIX serial line parameters (termios interface) ---- 277,281 ---- - } - #endif /* HAVE_SYSV_TTYS */ -! #if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) -*************** -*** 331,335 **** - #endif /* STREAM */ - } -! #endif /* HAVE_POSIX_TTYS */ - #if defined(HAVE_BSD_TTYS) - /* ---- 330,334 ---- - #endif /* STREAM */ - } -! #endif /* HAVE_TERMIOS */ - #if defined(HAVE_BSD_TTYS) - /* -*************** -*** 393,397 **** - } - } -! bzero((char *)gpstm, sizeof(struct gpstm_unit)); - gpstm_units[unit] = gpstm; - ---- 392,396 ---- - } - } -! memset((char *)gpstm, 0, sizeof(struct gpstm_unit)); - gpstm_units[unit] = gpstm; - -*************** -*** 420,424 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(REFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(HSREFID); ---- 419,423 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, REFID, 4); - else - peer->refid = htonl(HSREFID); -*************** -*** 928,932 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(REFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(HSREFID); ---- 927,932 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! REFID, 4); - else - peer->refid = htonl(HSREFID); -*** /tmp/RCSA023543 Wed Jan 26 17:56:53 1994 ---- xntpd/refclock_irig.c Wed Jan 26 16:33:40 1994 -*************** -*** 170,175 **** - * Just zero the data arrays - */ -! bzero((char *) irigunits, sizeof irigunits); -! bzero((char *) unitinuse, sizeof unitinuse); - - /* ---- 170,175 ---- - * Just zero the data arrays - */ -! memset((char *) irigunits, 0, sizeof irigunits); -! memset((char *) unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 251,255 **** - } - } -! bzero((char *) irig, sizeof(struct irigunit)); - - irigunits[unit] = irig; ---- 251,255 ---- - } - } -! memset((char *) irig, 0, sizeof(struct irigunit)); - - irigunits[unit] = irig; -*************** -*** 277,281 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(IRIGREFID, (char *) &peer->refid, 4); - else - peer->refid = htonl(IRIGHSREFID); ---- 277,281 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *) &peer->refid, IRIGREFID, 4); - else - peer->refid = htonl(IRIGHSREFID); -*************** -*** 486,491 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(IRIGREFID, (char *) &peer->refid, -! 4); - else - peer->refid = htonl(IRIGHSREFID); ---- 486,491 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *) &peer->refid, -! IRIGREFID, 4); - else - peer->refid = htonl(IRIGHSREFID); -*** /tmp/RCSA023543 Wed Jan 26 17:56:53 1994 ---- xntpd/refclock_leitch.c Wed Jan 26 16:33:40 1994 -*************** -*** 145,150 **** - leitch_init() - { -! bzero((char*)leitchunits,sizeof(leitchunits)); -! bzero((char*)unitinuse,sizeof(unitinuse)); - } - ---- 145,150 ---- - leitch_init() - { -! memset((char*)leitchunits, 0, sizeof(leitchunits)); -! memset((char*)unitinuse, 0, sizeof(unitinuse)); - } - -*************** -*** 271,275 **** - - leitch = &leitchunits[unit]; -! bzero((char*)leitch,sizeof(*leitch)); - - #if defined(HAVE_SYSV_TTYS) ---- 271,275 ---- - - leitch = &leitchunits[unit]; -! memset((char*)leitch, 0, sizeof(*leitch)); - - #if defined(HAVE_SYSV_TTYS) -*** /tmp/RCSA023543 Wed Jan 26 17:56:54 1994 ---- xntpd/refclock_local.c Wed Jan 26 16:33:40 1994 -*************** -*** 101,106 **** - * Just zero the data arrays - */ -! bzero((char *)lclunits, sizeof lclunits); -! bzero((char *)unitinuse, sizeof unitinuse); - } - ---- 101,106 ---- - * Just zero the data arrays - */ -! memset((char *)lclunits, 0, sizeof lclunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - } - -*************** -*** 149,153 **** - } - } -! bzero((char *)lcl, sizeof(struct lclunit)); - lclunits[unit] = lcl; - ---- 149,153 ---- - } - } -! memset((char *)lcl, 0, sizeof(struct lclunit)); - lclunits[unit] = lcl; - -*************** -*** 167,171 **** - peer->stratum = (u_char)unit; - if (unit <= 1) -! bcopy(LCLREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(LCLHSREFID); ---- 167,171 ---- - peer->stratum = (u_char)unit; - if (unit <= 1) -! memmove((char *)&peer->refid, LCLREFID, 4); - else - peer->refid = htonl(LCLHSREFID); -*** /tmp/RCSA023576 Wed Jan 26 17:56:54 1994 ---- xntpd/refclock_msfees.c Wed Jan 26 16:33:41 1994 -*************** -*** 380,385 **** - register int i; - /* Just zero the data arrays */ -! bzero((char *)eesunits, sizeof eesunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - acceptable_slop.l_ui = 0; ---- 380,385 ---- - register int i; - /* Just zero the data arrays */ -! memset((char *)eesunits, 0, sizeof eesunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - acceptable_slop.l_ui = 0; -*************** -*** 507,511 **** - else ees = (struct eesunit *) emalloc(sizeof(struct eesunit)); - } -! bzero((char *)ees, sizeof(struct eesunit)); - eesunits[unit] = ees; - ---- 507,511 ---- - else ees = (struct eesunit *) emalloc(sizeof(struct eesunit)); - } -! memset((char *)ees, 0, sizeof(struct eesunit)); - eesunits[unit] = ees; - -*************** -*** 548,553 **** - if (!io_addclock(&ees->io)) { - /* Oh shit. Just close and return. */ -! syslog(LOG_ERR, "ees clock: io_addclock(%s): %m", -! eesdev); - goto screwed; - } ---- 548,552 ---- - if (!io_addclock(&ees->io)) { - /* Oh shit. Just close and return. */ -! syslog(LOG_ERR, "ees clock: io_addclock(%s): %m", eesdev); - goto screwed; - } -*************** -*** 560,575 **** - peer->rootdelay = 0; /* ++++ */ - peer->rootdispersion = 0; /* ++++ */ -! if (stratumtouse[unit] <= 1) -! { bcopy(EESREFID, (char *)&peer->refid, 4); -! if (unit>0 && unit<10) ((char *)&peer->refid)[3] = '0' + unit; - } -- else peer->refid = htonl(EESHSREFID); - unitinuse[unit] = 1; - syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit); -! return 1; - - screwed: -! if (fd232 != -1) (void) close(fd232); -! return 0; - } - ---- 559,577 ---- - peer->rootdelay = 0; /* ++++ */ - peer->rootdispersion = 0; /* ++++ */ -! if (stratumtouse[unit] <= 1) { -! memmove((char *)&peer->refid, EESREFID, 4); -! if (unit > 0 && unit < 10) -! ((char *)&peer->refid)[3] = '0' + unit; -! } else { -! peer->refid = htonl(EESHSREFID); - } - unitinuse[unit] = 1; - syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit); -! return (1); - - screwed: -! if (fd232 != -1) -! (void) close(fd232); -! return (0); - } - -*************** -*** 860,864 **** - sincelast = this_uisec - ees->last_step; - -! bzero(&ppsclockev, sizeof ppsclockev); - - rc = ioctl(ees->io.fd, CIOGETEV, (char *) &ppsclockev); ---- 862,866 ---- - sincelast = this_uisec - ees->last_step; - -! memset(&ppsclockev, 0, sizeof ppsclockev); - - rc = ioctl(ees->io.fd, CIOGETEV, (char *) &ppsclockev); -*************** -*** 1444,1449 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) { -! bcopy(EESREFID, (char *)&peer->refid, -! 4); - if (unit>0 && unit<10) - ((char *)&peer->refid)[3] = ---- 1446,1451 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) { -! memmove((char *)&peer->refid, -! EESREFID, 4); - if (unit>0 && unit<10) - ((char *)&peer->refid)[3] = -*** /tmp/RCSA023576 Wed Jan 26 17:56:55 1994 ---- xntpd/refclock_mx4200.c Wed Jan 26 16:33:41 1994 -*************** -*** 263,268 **** - * Just zero the data arrays - */ -! bzero((char *)mx4200units, sizeof mx4200units); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 263,268 ---- - * Just zero the data arrays - */ -! memset((char *)mx4200units, 0, sizeof mx4200units); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 487,491 **** - } - -! bzero((char *)mx4200, sizeof(struct mx4200unit)); - mx4200units[unit] = mx4200; - ---- 487,491 ---- - } - -! memset((char *)mx4200, 0, sizeof(struct mx4200unit)); - mx4200units[unit] = mx4200; - -*************** -*** 513,517 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(MX4200REFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(MX4200HSREFID); ---- 513,517 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, MX4200REFID, 4); - else - peer->refid = htonl(MX4200HSREFID); -*************** -*** 702,706 **** - return; - mx4200->lencode = n; -! bcopy(dpt, mx4200->lastcode, n); - - /* ---- 702,706 ---- - return; - mx4200->lencode = n; -! memmove(mx4200->lastcode, dpt, n); - - /* -*************** -*** 1052,1057 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(MX4200REFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(MX4200HSREFID); ---- 1052,1057 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! MX4200REFID, 4); - else - peer->refid = htonl(MX4200HSREFID); -*************** -*** 1116,1120 **** - mx4200 = mx4200units[unit]; - -! bzero((char *)bug, sizeof(*bug)); - bug->nvalues = 10; - bug->ntimes = 2; ---- 1116,1120 ---- - mx4200 = mx4200units[unit]; - -! memset((char *)bug, 0, sizeof(*bug)); - bug->nvalues = 10; - bug->ntimes = 2; -*************** -*** 1212,1216 **** - - cp = buf; -! bzero((char *)jt, sizeof(*jt)); - - if ((cp = strchr(cp, ',')) == NULL) ---- 1212,1216 ---- - - cp = buf; -! memset((char *)jt, 0, sizeof(*jt)); - - if ((cp = strchr(cp, ',')) == NULL) -*** /tmp/RCSA023576 Wed Jan 26 17:56:55 1994 ---- xntpd/refclock_omega.c Wed Jan 26 16:33:42 1994 -*************** -*** 227,232 **** - * Just zero the data arrays - */ -! bzero((char *)omegaunits, sizeof omegaunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 227,232 ---- - * Just zero the data arrays - */ -! memset((char *)omegaunits, 0, sizeof omegaunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 417,421 **** - } - } -! bzero((char *)omega, sizeof(struct omegaunit)); - omegaunits[unit] = omega; - ---- 417,421 ---- - } - } -! memset((char *)omega, 0, sizeof(struct omegaunit)); - omegaunits[unit] = omega; - -*************** -*** 445,449 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(OMEGAREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(OMEGAHSREFID); ---- 445,449 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, OMEGAREFID, 4); - else - peer->refid = htonl(OMEGAHSREFID); -*************** -*** 928,933 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(OMEGAREFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(OMEGAHSREFID); ---- 928,933 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! OMEGAREFID, 4); - else - peer->refid = htonl(OMEGAHSREFID); -*** /tmp/RCSA023576 Wed Jan 26 17:56:56 1994 ---- xntpd/refclock_parse.c Wed Jan 26 16:33:42 1994 -*************** -*** 1068,1072 **** - return; - } -! bcopy((caddr_t)&rbufp->recv_space, (caddr_t)&parsetime, sizeof(parsetime_t)); - - /* ---- 1068,1074 ---- - return; - } -! memmove((caddr_t)&parsetime, -! (caddr_t)&rbufp->recv_space, -! sizeof(parsetime_t)); - - /* -*************** -*** 2009,2013 **** - parse_init() - { -! bzero((caddr_t)parseunits, sizeof parseunits); - } - ---- 2011,2015 ---- - parse_init() - { -! memset((caddr_t)parseunits, 0, sizeof parseunits); - } - -*************** -*** 2169,2173 **** - } - -! bzero((char *)parse, sizeof(struct parseunit)); - parseunits[unit] = parse; - ---- 2171,2175 ---- - } - -! memset((char *)parse, 0, sizeof(struct parseunit)); - parseunits[unit] = parse; - -*************** -*** 2204,2208 **** - peer->stratum = STRATUM_REFCLOCK; - if (peer->stratum <= 1) -! bcopy(parse->parse_type->cl_id, (char *)&peer->refid, 4); - else - peer->refid = htonl(PARSEHSREFID); ---- 2206,2210 ---- - peer->stratum = STRATUM_REFCLOCK; - if (peer->stratum <= 1) -! memmove((char *)&peer->refid, parse->parse_type->cl_id, 4); - else - peer->refid = htonl(PARSEHSREFID); -*************** -*** 2233,2237 **** - { - #ifndef _PC_VDISABLE -! bzero((char *)tm.c_cc, sizeof(tm.c_cc)); - #else - int disablec; ---- 2235,2239 ---- - { - #ifndef _PC_VDISABLE -! memset((char *)tm.c_cc, 0, sizeof(tm.c_cc)); - #else - int disablec; -*************** -*** 2587,2591 **** - parse->peer->stratum = (u_char)(in->fudgeval1 & 0xf); - if (parse->peer->stratum <= 1) -! bcopy(parse->parse_type->cl_id, (char *)&parse->peer->refid, 4); - else - parse->peer->refid = htonl(PARSEHSREFID); ---- 2589,2595 ---- - parse->peer->stratum = (u_char)(in->fudgeval1 & 0xf); - if (parse->peer->stratum <= 1) -! memmove((char *)&parse->peer->refid, -! parse->parse_type->cl_id, -! 4); - else - parse->peer->refid = htonl(PARSEHSREFID); -*************** -*** 3280,3284 **** - { - parse->localdata = (void *)malloc(sizeof(poll_timer_t)); -! bzero((char *)parse->localdata, sizeof(poll_timer_t)); - - pt = (poll_timer_t *)parse->localdata; ---- 3284,3288 ---- - { - parse->localdata = (void *)malloc(sizeof(poll_timer_t)); -! memset((char *)parse->localdata, 0, sizeof(poll_timer_t)); - - pt = (poll_timer_t *)parse->localdata; -*** /tmp/RCSA023576 Wed Jan 26 17:56:56 1994 ---- xntpd/refclock_pst.c Wed Jan 26 16:33:42 1994 -*************** -*** 438,443 **** - * Just zero the data arrays - */ -! bzero((char *)pstunits, sizeof pstunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 438,443 ---- - * Just zero the data arrays - */ -! memset((char *)pstunits, 0, sizeof pstunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 630,634 **** - } - } -! bzero((char *)pst, sizeof(struct pstunit)); - pstunits[unit] = pst; - ---- 630,634 ---- - } - } -! memset((char *)pst, 0, sizeof(struct pstunit)); - pstunits[unit] = pst; - -*************** -*** 663,667 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(WWVREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(PSTHSREFID); ---- 663,667 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, WWVREFID, 4); - else - peer->refid = htonl(PSTHSREFID); -*************** -*** 1461,1467 **** - if (stratumtouse[pst->unit] <= 1) { - if (pst->station >= 0) -! bcopy(WWVREFID, (char *)&pst->peer->refid, 4); - else -! bcopy(WWVHREFID, (char *)&pst->peer->refid, 4); - } - ---- 1461,1467 ---- - if (stratumtouse[pst->unit] <= 1) { - if (pst->station >= 0) -! memmove((char *)&pst->peer->refid, WWVREFID, 4); - else -! memmove((char *)&pst->peer->refid, WWVHREFID, 4); - } - -*** /tmp/RCSA023576 Wed Jan 26 17:56:57 1994 ---- xntpd/refclock_tpro.c Wed Jan 26 16:33:43 1994 -*************** -*** 131,136 **** - * Just zero the data arrays - */ -! bzero((char *)tprounits, sizeof tprounits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 131,136 ---- - * Just zero the data arrays - */ -! memset((char *)tprounits, 0, sizeof tprounits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 201,205 **** - } - } -! bzero((char *)tpro, sizeof(struct tprounit)); - tprounits[unit] = tpro; - ---- 201,205 ---- - } - } -! memset((char *)tpro, 0, sizeof(struct tprounit)); - tprounits[unit] = tpro; - -*************** -*** 226,230 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(TPROREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(TPROHSREFID); ---- 226,230 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, TPROREFID, 4); - else - peer->refid = htonl(TPROHSREFID); -*************** -*** 416,421 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(TPROREFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(TPROHSREFID); ---- 416,421 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! TPROREFID, 4); - else - peer->refid = htonl(TPROHSREFID); -*** /tmp/RCSA023576 Wed Jan 26 17:56:57 1994 ---- xntpd/refclock_wwvb.c Wed Jan 26 16:33:43 1994 -*************** -*** 220,225 **** - * Just zero the data arrays - */ -! bzero((char *)wwvbunits, sizeof wwvbunits); -! bzero((char *)unitinuse, sizeof unitinuse); - - /* ---- 220,225 ---- - * Just zero the data arrays - */ -! memset((char *)wwvbunits, 0, sizeof wwvbunits); -! memset((char *)unitinuse, 0, sizeof unitinuse); - - /* -*************** -*** 408,412 **** - } - } -! bzero((char *)wwvb, sizeof(struct wwvbunit)); - wwvbunits[unit] = wwvb; - ---- 408,412 ---- - } - } -! memset((char *)wwvb, 0, sizeof(struct wwvbunit)); - wwvbunits[unit] = wwvb; - -*************** -*** 436,440 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(WWVBREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(WWVBHSREFID); ---- 436,440 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, WWVBREFID, 4); - else - peer->refid = htonl(WWVBHSREFID); -*************** -*** 957,962 **** - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! bcopy(WWVBREFID, (char *)&peer->refid, -! 4); - else - peer->refid = htonl(WWVBHSREFID); ---- 957,962 ---- - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) -! memmove((char *)&peer->refid, -! WWVBREFID, 4); - else - peer->refid = htonl(WWVBHSREFID); -*** /tmp/RCSA023592 Wed Jan 26 17:56:58 1994 ---- xntpdc/ntpdc.c Wed Jan 26 16:33:43 1994 -*************** -*** 222,227 **** - int c; - int errflg = 0; -! extern int optind; -! extern char *optarg; - - delay_time.l_ui = 0; ---- 222,227 ---- - int c; - int errflg = 0; -! extern int ntp_optind; -! extern char *ntp_optarg; - - delay_time.l_ui = 0; -*************** -*** 229,236 **** - - progname = argv[0]; -! while ((c = getopt_l(argc, argv, "c:dilnps")) != EOF) - switch (c) { - case 'c': -! ADDCMD(optarg); - break; - case 'd': ---- 229,236 ---- - - progname = argv[0]; -! while ((c = ntp_getopt(argc, argv, "c:dilnps")) != EOF) - switch (c) { - case 'c': -! ADDCMD(ntp_optarg); - break; - case 'd': -*************** -*** 262,270 **** - exit(2); - } -! if (optind == argc) { - ADDHOST(DEFHOST); - } else { -! for (; optind < argc; optind++) -! ADDHOST(argv[optind]); - } - ---- 262,270 ---- - exit(2); - } -! if (ntp_optind == argc) { - ADDHOST(DEFHOST); - } else { -! for (; ntp_optind < argc; ntp_optind++) -! ADDHOST(argv[ntp_optind]); - } - -*************** -*** 440,444 **** - *rdata = datap = pktdata; - lastseq = 999; /* too big to be a sequence number */ -! bzero(haveseq, sizeof(haveseq)); - FD_ZERO(&fds); - ---- 440,444 ---- - *rdata = datap = pktdata; - lastseq = 999; /* too big to be a sequence number */ -! memset(haveseq, 0, sizeof(haveseq)); - FD_ZERO(&fds); - -*************** -*** 601,605 **** - if ((datap + datasize) > (pktdata + pktdatasize)) - growpktdata(); -! bcopy((char *)rpkt.data, datap, datasize); - datap += datasize; - if (firstpkt) { ---- 601,605 ---- - if ((datap + datasize) > (pktdata + pktdatasize)) - growpktdata(); -! memmove(datap, (char *)rpkt.data, datasize); - datap += datasize; - if (firstpkt) { -*************** -*** 635,639 **** - int datasize; - -! bzero((char *)&qpkt, sizeof qpkt); - - qpkt.rm_vn_mode = RM_VN_MODE(0, 0); ---- 635,639 ---- - int datasize; - -! memset((char *)&qpkt, 0, sizeof qpkt); - - qpkt.rm_vn_mode = RM_VN_MODE(0, 0); -*************** -*** 643,647 **** - datasize = qitems * qsize; - if (datasize != 0 && qdata != NULL) { -! bcopy(qdata, (char *)qpkt.data, datasize); - qpkt.err_nitems = ERR_NITEMS(0, qitems); - qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize); ---- 643,647 ---- - datasize = qitems * qsize; - if (datasize != 0 && qdata != NULL) { -! memmove((char *)qpkt.data, qdata, datasize); - qpkt.err_nitems = ERR_NITEMS(0, qitems); - qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize); -*************** -*** 1092,1096 **** - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! bcopy(hp->h_addr, (char *)num, sizeof(U_LONG)); - if (fullhost != 0) - (void) strcpy(fullhost, hp->h_name); ---- 1092,1096 ---- - return 1; - } else if ((hp = gethostbyname(host)) != 0) { -! memmove((char *)num, hp->h_addr, sizeof(U_LONG)); - if (fullhost != 0) - (void) strcpy(fullhost, hp->h_name); -*** /tmp/RCSA023592 Wed Jan 26 17:56:58 1994 ---- xntpdc/ntpdc_ops.c Wed Jan 26 16:33:44 1994 -*************** -*** 443,447 **** - if (pp->stratum <= 1) { - junk[4] = 0; -! bcopy((char *)&pp->refid, junk, 4); - str = junk; - } else { ---- 443,447 ---- - if (pp->stratum <= 1) { - junk[4] = 0; -! memmove(junk, (char *)&pp->refid, 4); - str = junk; - } else { -*************** -*** 789,793 **** - if (is->stratum <= 1) { - junk[4] = 0; -! bcopy((char *)&is->refid, junk, 4); - str = junk; - } else { ---- 789,793 ---- - if (is->stratum <= 1) { - junk[4] = 0; -! memmove(junk, (char *)&is->refid, 4); - str = junk; - } else { -*************** -*** 2193,2197 **** - - err = 0; -! bzero((char *)&fudgedata, sizeof fudgedata); - fudgedata.clockadr = pcmd->argval[0].netnum; - ---- 2193,2197 ---- - - err = 0; -! memset((char *)&fudgedata, 0, sizeof fudgedata); - fudgedata.clockadr = pcmd->argval[0].netnum; - -*** /tmp/RCSA023598 Wed Jan 26 17:56:59 1994 ---- xntpres/xntpres.c Wed Jan 26 16:33:44 1994 -*************** -*** 149,153 **** - char *cp; - FILE *in; -! extern int optind; - - progname = argv[0]; ---- 149,153 ---- - char *cp; - FILE *in; -! extern int ntp_optind; - - progname = argv[0]; -*************** -*** 181,185 **** - syslog(LOG_NOTICE, Version); - -! while ((c = getopt_l(argc, argv, "dr")) != EOF) - switch (c) { - case 'd': ---- 181,185 ---- - syslog(LOG_NOTICE, Version); - -! while ((c = ntp_getopt(argc, argv, "dr")) != EOF) - switch (c) { - case 'd': -*************** -*** 193,197 **** - break; - } -! if (errflg || (optind + 3) != argc) { - (void) fprintf(stderr, - "usage: %s [-d] [-r] keyid keyfile conffile\n", progname); ---- 193,197 ---- - break; - } -! if (errflg || (ntp_optind + 3) != argc) { - (void) fprintf(stderr, - "usage: %s [-d] [-r] keyid keyfile conffile\n", progname); -*************** -*** 200,210 **** - } - -! if (!atouint(argv[optind], &req_keyid)) { -! syslog(LOG_ERR, "undecodeable keyid %s", argv[optind]); - exit(1); - } - -! keyfile = argv[optind+1]; -! conffile = argv[optind+2]; - - /* ---- 200,210 ---- - } - -! if (!atouint(argv[ntp_optind], &req_keyid)) { -! syslog(LOG_ERR, "undecodeable keyid %s", argv[ntp_optind]); - exit(1); - } - -! keyfile = argv[ntp_optind+1]; -! conffile = argv[ntp_optind+2]; - - /* -*************** -*** 354,358 **** - len = strlen(name) + 1; - cp = emalloc((unsigned)len); -! bcopy(name, cp, len); - - ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry)); ---- 354,358 ---- - len = strlen(name) + 1; - cp = emalloc((unsigned)len); -! memmove(cp, name, len); - - ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry)); -*************** -*** 409,413 **** - return 1; - #endif -! return 0; - } - ---- 409,413 ---- - return 1; - #endif -! return (0); - } - -*************** -*** 417,423 **** - * only return one. - */ -! (void) bcopy(hp->h_addr, (char *)&(entry->ce_peeraddr), -! sizeof(struct in_addr)); -! return 1; - } - ---- 417,424 ---- - * only return one. - */ -! memmove((char *)&(entry->ce_peeraddr), -! hp->h_addr, -! sizeof(struct in_addr)); -! return (1); - } - -*************** -*** 440,444 **** - } - -! bzero((char *)&saddr, sizeof(saddr)); - saddr.sin_family = AF_INET; - saddr.sin_port = htons(NTP_PORT); /* trash */ ---- 441,445 ---- - } - -! memset((char *)&saddr, 0, sizeof(saddr)); - saddr.sin_family = AF_INET; - saddr.sin_port = htons(NTP_PORT); /* trash */ -*************** -*** 500,504 **** - * Make up a request packet with the configuration info - */ -! bzero((char *)&reqpkt, sizeof(reqpkt)); - - reqpkt.rm_vn_mode = RM_VN_MODE(0, 0); ---- 501,505 ---- - * Make up a request packet with the configuration info - */ -! memset((char *)&reqpkt, 0, sizeof(reqpkt)); - - reqpkt.rm_vn_mode = RM_VN_MODE(0, 0); -*************** -*** 508,512 **** - reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */ - reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer)); -! bcopy((char *)conf, reqpkt.data, sizeof(struct conf_peer)); - reqpkt.keyid = htonl(req_keyid); - ---- 509,513 ---- - reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */ - reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer)); -! memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer)); - reqpkt.keyid = htonl(req_keyid); - - diff --git a/usr.sbin/xntpd/patches/patch.40 b/usr.sbin/xntpd/patches/patch.40 deleted file mode 100644 index 7f1941d3a760..000000000000 --- a/usr.sbin/xntpd/patches/patch.40 +++ /dev/null @@ -1,92 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa23994; 13 Apr 94 15:58 EDT -Received: from adrastea.lcs.mit.edu by louie.udel.edu id aa07113; - 13 Apr 94 15:44 EDT -Received: by adrastea.lcs.mit.edu; id AA04845; Wed, 13 Apr 1994 15:44:23 -0400 -Date: Wed, 13 Apr 1994 15:44:23 -0400 -From: Garrett Wollman -Message-Id: <9404131944.AA04845@adrastea.lcs.mit.edu> -To: Mills@udel.edu -Cc: Garrett Wollman , - Frank Kardel -Subject: Re: You xntp modifications... -In-Reply-To: <9404122159.aa18355@huey.udel.edu> -References: <9404122159.aa18355@huey.udel.edu> - -< Note that we are two versions further along, what with the average of -> a patch per day, so it would be survivable if this issue could be -> cleared up ASAP. - -This patch, applied relative to my previous patch, provides for both -behaviors. - - -*** xntpd/xntpd/ntp_control.c Wed Apr 13 12:37:51 1994 ---- ntp_control.c Wed Apr 13 12:38:42 1994 -*************** -*** 264,271 **** ---- 264,283 ---- - /* - * System and processor definitions. These will change for the gizmo board. - */ -+ #ifndef HAVE_UNAME -+ #ifndef STR_SYSTEM -+ #define STR_SYSTEM "UNIX" -+ #endif -+ #ifndef STR_PROCESSOR -+ #define STR_PROCESSOR "unknown" -+ #endif -+ -+ static char str_system[] = STR_SYSTEM; -+ static char str_processor[] = STR_PROCESSOR; -+ #else - #include - static struct utsname utsname; -+ #endif /* HAVE_UNAME */ - - /* - * Trap structures. We only allow a few of these, and send -*************** -*** 426,433 **** ---- 438,447 ---- - { - int i; - -+ #ifdef HAVE_UNAME - uname(&utsname); - -+ #endif /* HAVE_UNAME */ - ctl_clr_stats(); - - ctl_auth_keyid = 0; -*************** -*** 1262,1273 **** ---- 1276,1297 ---- - ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning); - break; - case CS_PROCESSOR: -+ #ifndef HAVE_UNAME -+ ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor, -+ sizeof(str_processor) - 1); -+ #else - ctl_putstr(sys_var[CS_PROCESSOR].text, utsname.machine, - strlen(utsname.machine)); -+ #endif /* HAVE_UNAME */ - break; - case CS_SYSTEM: -+ #ifndef HAVE_UNAME -+ ctl_putstr(sys_var[CS_SYSTEM].text, str_system, -+ sizeof(str_system) - 1); -+ #else - ctl_putstr(sys_var[CS_SYSTEM].text, utsname.sysname, - strlen(utsname.sysname)); -+ #endif /* HAVE_UNAME */ - break; - case CS_KEYID: - ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0); - - -[no save] - diff --git a/usr.sbin/xntpd/patches/patch.41 b/usr.sbin/xntpd/patches/patch.41 deleted file mode 100644 index 5d1f91c821f1..000000000000 --- a/usr.sbin/xntpd/patches/patch.41 +++ /dev/null @@ -1,50 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa13197; 16 Apr 94 22:05 EDT -Received: from motgate.mot.com by louie.udel.edu id aa18176; 16 Apr 94 21:57 EDT -Received: from pobox.mot.com ([129.188.137.100]) by motgate.mot.com with SMTP (5.67b/IDA-1.4.4/MOT-3.1 for ) - id AA01015; Sat, 16 Apr 1994 20:57:21 -0500 -Received: from merlin.dev.cdx.mot.com by pobox.mot.com with SMTP (5.67b/IDA-1.4.4/MOT-3.1 for ) - id AA29067; Sat, 16 Apr 1994 20:57:19 -0500 -Received: from ronald.dev.cdx.mot.com (ronald.dev.cdx.mot.com [134.33.39.18]) by merlin.dev.cdx.mot.com (8.6.5/8.6.5) with ESMTP id VAA06544; Sat, 16 Apr 1994 21:57:12 -0400 -From: "Gregory M. Paris" -Received: from localhost (paris@localhost) by ronald.dev.cdx.mot.com (8.6.5/8.6.5) id VAA22231; Sat, 16 Apr 1994 21:57:11 -0400 -Date: Sat, 16 Apr 1994 21:57:11 -0400 -Message-Id: <199404170157.VAA22231@ronald.dev.cdx.mot.com> -To: mills@udel.edu -Subject: 3.3y patch - -Dave, - -I had the same problem compiling 3.3p as I got with 3.3y. The fix -was to move a #endif that seems to be out of place in xntpd/ntp_unixclock.c. -It now compiles fine on my HP-UX 9.03. Here's the patch. - -Greg - --- -Greg Paris -Motorola Inc, Information Systems Group, 20 Cabot Blvd, Mansfield, MA 02048-1193 -"Your Plastic Pal who's fun to be with." TM Sirius Cybernetics -These posts are self-disclamatory. - -################################################## -*** xntpd/ntp_unixclock.c.orig Mon Apr 11 22:19:21 1994 ---- xntpd/ntp_unixclock.c Sat Apr 16 21:49:15 1994 -*************** -*** 386,391 **** ---- 386,392 ---- - #undef K_TICK_NAME - #undef N_NAME - } -+ #endif /* SYS_UNIXWARE1 */ - #endif /* HAVE_READKMEM */ - - #if defined(SOLARIS)&&defined(ADJTIME_IS_ACCURATE) -*************** -*** 583,586 **** - *tick = (U_LONG)txc.tick; - } - #endif /* SYS_LINUX */ -- #endif /* SYS_UNIXWARE1 */ ---- 584,586 ---- - diff --git a/usr.sbin/xntpd/patches/patch.42 b/usr.sbin/xntpd/patches/patch.42 deleted file mode 100644 index 78c9bdfdda26..000000000000 --- a/usr.sbin/xntpd/patches/patch.42 +++ /dev/null @@ -1,38 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa00358; 19 Apr 94 17:48 EDT -Received: from swan.cl.cam.ac.uk by louie.udel.edu id aa12986; - 19 Apr 94 17:40 EDT -Received: from labes.cl.cam.ac.uk (user pb (rfc931)) by swan.cl.cam.ac.uk - with SMTP (PP-6.5) to cl; Tue, 19 Apr 1994 22:39:48 +0100 -To: Mills@udel.edu -cc: Piete Brooks -Subject: Re: Multicast NTP - take 1 -In-reply-to: Your message of Tue, 19 Apr 1994 12:29:25 -0400. <9404191229.aa28742@huey.udel.edu> -Date: Tue, 19 Apr 1994 22:39:44 +0100 -From: Piete Brooks -Message-ID: <"swan.cl.cam.:138990:940419214000"@cl.cam.ac.uk> - -Shucks ! - -I omitted the "-c" to diff ... - -*** xntpd/refclock_msfees.c.dist Thu Jan 27 14:03:59 1994 ---- xntpd/refclock_msfees.c Tue Apr 19 10:58:57 1994 -*************** -*** 139,145 **** - #define INH_DELAY_PPS BITS_TO_L_FP( 0, 9600) - - #ifndef STREAM_PP1 -! #define STREAM_PP1 "ppsclockd\0<-- patch space for module name1 -->" - #endif - #ifndef STREAM_PP2 - #define STREAM_PP2 "ppsclock\0<-- patch space for module name2 -->" ---- 139,145 ---- - #define INH_DELAY_PPS BITS_TO_L_FP( 0, 9600) - - #ifndef STREAM_PP1 -! #define STREAM_PP1 "ppsclocd\0<-- patch space for module name1 -->" - #endif - #ifndef STREAM_PP2 - #define STREAM_PP2 "ppsclock\0<-- patch space for module name2 -->" - diff --git a/usr.sbin/xntpd/patches/patch.43 b/usr.sbin/xntpd/patches/patch.43 deleted file mode 100644 index 92f9200c735e..000000000000 --- a/usr.sbin/xntpd/patches/patch.43 +++ /dev/null @@ -1,48 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa00412; 19 Apr 94 18:04 EDT -Received: from swan.cl.cam.ac.uk by louie.udel.edu id aa13181; - 19 Apr 94 17:44 EDT -Received: from labes.cl.cam.ac.uk (user pb (rfc931)) by swan.cl.cam.ac.uk - with SMTP (PP-6.5) to cl; Tue, 19 Apr 1994 22:44:05 +0100 -To: Mills@udel.edu -cc: Piete Brooks -Subject: Re: Cisco/Multicast/ntp3.3m -In-reply-to: Your message of Tue, 19 Apr 1994 12:24:31 -0400. <9404191224.aa28707@huey.udel.edu> -Date: Tue, 19 Apr 1994 22:43:58 +0100 -From: Piete Brooks -Message-ID: <"swan.cl.cam.:140740:940419214417"@cl.cam.ac.uk> - -> Yes, I think you have caught all the gotchas. - -I fear not :-(( - -> I take it you have the latest kernel mods. - -Look for a call sign I assume .... -Do I take it that they are **REQUIRED** ? :-((( - - -Other problems ..... - -It appears that you have your own in.h in include/ntp_in.h - -I suspect that that is why things are failing ... -Why not use the syatem's own in.h ?? - -To make it compile I added: - -*** include/ntp_in.h.dist Thu Apr 14 16:20:29 1994 ---- include/ntp_in.h Tue Apr 19 21:40:12 1994 -*************** -*** 19,24 **** ---- 19,27 ---- - - #ifndef _netinet_in_h - #define _netinet_in_h -+ #define _NETINET_IN_H_ -+ #define _SYS_IN_INCLUDED -+ #define __IN_HEADER - - /* - * Protocols - diff --git a/usr.sbin/xntpd/patches/patch.5 b/usr.sbin/xntpd/patches/patch.5 deleted file mode 100644 index 2225804037c7..000000000000 --- a/usr.sbin/xntpd/patches/patch.5 +++ /dev/null @@ -1,49 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa14816; 27 Jan 94 5:15 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa11733; - 27 Jan 94 5:09 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA25056 (5.65c-6/7.3v-FAU); Thu, 27 Jan 1994 11:09:06 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA09091 (5.65c-6/7.3m-FAU); Thu, 27 Jan 1994 11:09:03 +0100 -From: Frank Kardel -Message-Id: <199401271009.AA09091@faui43.informatik.uni-erlangen.de> -Subject: Re: Solaribum -To: Mills@udel.edu -Date: Thu, 27 Jan 94 11:08:55 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, Piete.Brooks@cl.cam.ac.uk, - Paul_Vixie@corpmis.sjc.hw.sony.com -In-Reply-To: <9401261207.aa10860@huey.udel.edu>; from "Mills@udel.edu" at Jan 26, 94 12:07 pm -X-Mailer: ELM [version 2.3 PL11] - - -And another corer generator to be removed: - -=================================================================== -RCS file: /src/NTP/REPOSITORY/v3/xntpd/ntp_control.c,v -retrieving revision 3.22 -diff -c -r3.22 xntpd/ntp_control.c -*** xntpd/ntp_control.c:3.22 1994/01/26 21:56:23 ---- xntpd/ntp_control.c 1994/01/27 10:03:01 -*************** -*** 2132,2138 **** - for (i = 1; i <= CC_MAXCODE; i++) - if (wants[i]) - ctl_putclock(i, &clock, 1); -! for (i = 0; !(clock.kv_list[i].flags & EOV); i++) - if (wants[i+CC_MAXCODE+1]) - ctl_putdata(clock.kv_list[i].text, - strlen(clock.kv_list[i].text), 0); ---- 2132,2138 ---- - for (i = 1; i <= CC_MAXCODE; i++) - if (wants[i]) - ctl_putclock(i, &clock, 1); -! for (i = 0; clock.kv_list && !(clock.kv_list[i].flags & EOV); i++) - if (wants[i+CC_MAXCODE+1]) - ctl_putdata(clock.kv_list[i].text, - strlen(clock.kv_list[i].text), 0); --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.6 b/usr.sbin/xntpd/patches/patch.6 deleted file mode 100644 index 220acad2ed19..000000000000 --- a/usr.sbin/xntpd/patches/patch.6 +++ /dev/null @@ -1,550 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa17107; 27 Jan 94 14:37 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa16998; - 27 Jan 94 14:34 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA29914 (5.65c-6/7.3v-FAU); Thu, 27 Jan 1994 20:34:08 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA23509 (5.65c-6/7.3m-FAU); Thu, 27 Jan 1994 20:34:05 +0100 -From: Frank Kardel -Message-Id: <199401271934.AA23509@faui43.informatik.uni-erlangen.de> -Subject: Re: Solaribum -To: Mills@udel.edu -Date: Thu, 27 Jan 94 20:33:59 MET -Cc: Frank.Kardel@informatik.uni-erlangen.de, Piete.Brooks@cl.cam.ac.uk, - Paul_Vixie@corpmis.sjc.hw.sony.com -In-Reply-To: <9401271111.aa16183@huey.udel.edu>; from "Mills@udel.edu" at Jan 27, 94 11:11 am -X-Mailer: ELM [version 2.3 PL11] - - -> Guys, - -> Two masive patches collided in midair here, leaving broken parts scattered -> over three counties. The National Time Safety Board has investigated, -> but been unable, ... - -Additional efforts of the european branch of the NTPSB have uncovered -that the collision was due to low visibility across the atlantic. - -And I wanted to go on: - All measures have been taken to limit the effects of the crash to a - minimum and to resume normal aircraft operation as soon as possible. - - All crew members and passengers are required to apply following patch - to xntp3.3y.tar.Z for increased comfort and safety. This patch should - enable us to resume normal operation again. - - After applying the patches you may remove following debris: - - include/ntp_machine.h.rej - xntpd/ntp_config.c.rej - xntpd/ntp_control.c.rej - -Unfortunately I did a test compile and the results of that will -extend the ground stay of the 3.3y aircraft considerably. -(You may start thinking about bringing up 3.3xx - see below) - -SunOS 4.x.x does NOT have the new highly portable "memmove()" -routine. The lack of this will mean that we will have to -#define memmove(a, b, c) memcpy(a, b, c) -or find something else. I'd like to leave this to Paul. -Also on Sunos 4.x there are implicit declarations of bzero due -the the FDSET macro from the system header files. So I am not -so sure whether strictly using mem* is the best or whether we should -add b* prototypes to l_stdlib.h. I think Paul has now something -to work on. Anyhow, the patches below will rectify some problems -but the resulting code still needs much polishing (providing memmove -where it is missing e.g. SunOS4.x). - -In order to get a flying version fast (3.3xx) Dave could apply my -patch he is holding to 3.3x - that should then make a workable -version. 3.3y can then be cleaned up slowly (starting with the -patches below and then port it again to the rest of the systems). - -Sorry about the bad news. - -> I have one more patch from Frank which I will hold on to until the aircraft -> is recertified. - -That one is still to be applied because without it, it is possible -to shoot down any plane around the NTP universe that is bearing -the 3.3x banner (but can be applied to 3.3x). - - -For the 3.3y construction crew: - -diff -c -r ../yy/include/ntp_machine.h ./include/ntp_machine.h -*** ../yy/include/ntp_machine.h Thu Jan 27 15:03:23 1994 ---- ./include/ntp_machine.h Thu Jan 27 19:13:35 1994 -*************** -*** 121,139 **** - to the correct broadcast address - are these - implementations broken or did the spec change ? - -- HAVE_UNISTD_H - Maybe should be part of NTP_POSIX_SOURCE ? -- - DEFINITIONS FOR SYSTEM && PROCESSOR - STR_SYSTEM - value of system variable - STR_PROCESSOR - value of processor variable - - You could just put the defines on the DEFS line in machines/ file. -! I don't since there are lost of different types compiler that a systemm might -! have, some that can do proto typing and others that cannot on the saem system. -! I get a chanse to twiddle some of the configuration paramasters at compile -! time based on compler/machine combinatsions by using this include file. -! See convex, aix and sun configurations see how complex it gets. -! - */ - - ---- 121,141 ---- - to the correct broadcast address - are these - implementations broken or did the spec change ? - - DEFINITIONS FOR SYSTEM && PROCESSOR - STR_SYSTEM - value of system variable - STR_PROCESSOR - value of processor variable - - You could just put the defines on the DEFS line in machines/ file. -! I don't since there are lots of different types of compilers that a system might -! have, some that can do proto typing and others that cannot on the same system. -! I get a chance to twiddle some of the configuration parameters at compile -! time based on compiler/machine combinations by using this include file. -! See convex, aix and sun configurations see how complex it get. -! -! Note that it _is_ considered reasonable to add some system-specific defines -! to the machine/ file if it would be too inconvenient to puzzle them out -! in this file. -! - */ - - -diff -c -r ../yy/parse/parse.c ./parse/parse.c -*** ../yy/parse/parse.c Thu Jan 27 00:25:18 1994 ---- ./parse/parse.c Thu Jan 27 20:18:58 1994 -*************** -*** 29,40 **** - #include "sys/time.h" - #include "sys/errno.h" - -- #include "ntp_fp.h" -- #include "ntp_unixtime.h" -- #include "ntp_calendar.h" -- -- #include "parse.h" -- - #if defined(PARSESTREAM) && (defined(SYS_SUNOS4) || defined(SYS_SOLARIS)) && defined(STREAM) - /* - * Sorry, but in SunOS 4.x kernels there are no ---- 29,34 ---- -*************** -*** 44,51 **** ---- 38,54 ---- - #define _ntp_string_h - extern void bcopy(); - extern void bzero(); -+ #else -+ #define bzero(_X_, _Y_) memset(_X_, 0, _Y_) -+ #define bcopy(_X_, _Y_, _Z_) memmove(_Y_, _X_, _Z_) - #endif - -+ #include "ntp_fp.h" -+ #include "ntp_unixtime.h" -+ #include "ntp_calendar.h" -+ -+ #include "parse.h" -+ - #include "ntp_stdlib.h" - - #ifdef PARSESTREAM -diff -c -r ../yy/xntpd/ntp_config.c ./xntpd/ntp_config.c -*** ../yy/xntpd/ntp_config.c Thu Jan 27 15:03:47 1994 ---- ./xntpd/ntp_config.c Thu Jan 27 19:18:40 1994 -*************** -*** 1,4 **** -! /* ntp_config.c,v 3.1 1993/07/06 01:11:12 jbj Exp - * ntp_config.c - read and apply configuration information - */ - #define RESOLVE_INTERNAL /* gdt */ ---- 1,4 ---- -! /* - * ntp_config.c - read and apply configuration information - */ - #define RESOLVE_INTERNAL /* gdt */ -*************** -*** 375,388 **** - break; - } - -! if (errflg || optind != argc) { - (void) fprintf(stderr, "usage: %s [ -abd ] [ -c config_file ] [ -e encryption delay ]\n", progname); - (void) fprintf(stderr, "\t\t[ -f frequency file ] [ -k key file ] [ -l log file ]\n"); - (void) fprintf(stderr, "\t\t[ -p pid file ] [ -r broadcast delay ] [ -s status directory ]\n"); - (void) fprintf(stderr, "\t\t[ -t trusted key ] [ -v sys variable ] [ -V default sys variable ]\n"); - exit(2); - } -! optind = 0; /* reset optind to restart getopt_l */ - - if (debug) { - #ifdef NTP_POSIX_SOURCE ---- 375,388 ---- - break; - } - -! if (errflg || ntp_optind != argc) { - (void) fprintf(stderr, "usage: %s [ -abd ] [ -c config_file ] [ -e encryption delay ]\n", progname); - (void) fprintf(stderr, "\t\t[ -f frequency file ] [ -k key file ] [ -l log file ]\n"); - (void) fprintf(stderr, "\t\t[ -p pid file ] [ -r broadcast delay ] [ -s status directory ]\n"); - (void) fprintf(stderr, "\t\t[ -t trusted key ] [ -v sys variable ] [ -V default sys variable ]\n"); - exit(2); - } -! ntp_optind = 0; /* reset ntp_optind to restart ntp_getopt */ - - if (debug) { - #ifdef NTP_POSIX_SOURCE -*************** -*** 430,437 **** - char resolver_name[MAXFILENAME]; - int have_keyfile; - char keyfile[MAXFILENAME]; -! extern int optind; -! extern char *optarg; - extern char *Version; - extern U_LONG info_auth_keyid; - FILEGEN *filegen; ---- 430,437 ---- - char resolver_name[MAXFILENAME]; - int have_keyfile; - char keyfile[MAXFILENAME]; -! extern int ntp_optind; -! extern char *ntp_optarg; - extern char *Version; - extern U_LONG info_auth_keyid; - FILEGEN *filegen; -*************** -*** 461,467 **** - /* - * Decode argument list - */ -! while ((c = getopt_l(argc, argv, xntp_options)) != EOF) { - switch (c) { - case 'a': - proto_config(PROTO_AUTHENTICATE, (LONG)1); ---- 461,467 ---- - /* - * Decode argument list - */ -! while ((c = ntp_getopt(argc, argv, xntp_options)) != EOF) { - switch (c) { - case 'a': - proto_config(PROTO_AUTHENTICATE, (LONG)1); -*************** -*** 470,476 **** - proto_config(PROTO_BROADCLIENT, (LONG)1); - break; - case 'c': -! config_file = optarg; - break; - case 'd': - #ifdef DEBUG ---- 470,476 ---- - proto_config(PROTO_BROADCLIENT, (LONG)1); - break; - case 'c': -! config_file = ntp_optarg; - break; - case 'd': - #ifdef DEBUG -*************** -*** 484,498 **** - do { - l_fp tmp; - -! if (!atolfp(optarg, &tmp)) { - syslog(LOG_ERR, - "command line encryption delay value %s undecodable", -! optarg); - errflg++; - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line encryption delay value %s is unlikely", -! optarg); - errflg++; - } else { - proto_config(PROTO_AUTHDELAY, tmp.l_f); ---- 484,498 ---- - do { - l_fp tmp; - -! if (!atolfp(ntp_optarg, &tmp)) { - syslog(LOG_ERR, - "command line encryption delay value %s undecodable", -! ntp_optarg); - errflg++; - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line encryption delay value %s is unlikely", -! ntp_optarg); - errflg++; - } else { - proto_config(PROTO_AUTHDELAY, tmp.l_f); -*************** -*** 501,537 **** - break; - - case 'f': -! stats_config(STATS_FREQ_FILE, optarg); - break; - - case 'k': -! getauthkeys(optarg); -! if ((int)strlen(optarg) >= MAXFILENAME) { - syslog(LOG_ERR, - "key file name too LONG (>%d, sigh), no name resolution possible", - MAXFILENAME); - } else { - have_keyfile = 1; -! (void)strcpy(keyfile, optarg); - } - break; - - case 'p': -! stats_config(STATS_PID_FILE, optarg); - break; - - case 'r': - do { - l_fp tmp; - -! if (!atolfp(optarg, &tmp)) { - syslog(LOG_ERR, - "command line broadcast delay value %s undecodable", -! optarg); - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line broadcast delay value %s is unlikely", -! optarg); - } else { - proto_config(PROTO_BROADDELAY, tmp.l_f); - } ---- 501,537 ---- - break; - - case 'f': -! stats_config(STATS_FREQ_FILE, ntp_optarg); - break; - - case 'k': -! getauthkeys(ntp_optarg); -! if ((int)strlen(ntp_optarg) >= MAXFILENAME) { - syslog(LOG_ERR, - "key file name too LONG (>%d, sigh), no name resolution possible", - MAXFILENAME); - } else { - have_keyfile = 1; -! (void)strcpy(keyfile, ntp_optarg); - } - break; - - case 'p': -! stats_config(STATS_PID_FILE, ntp_optarg); - break; - - case 'r': - do { - l_fp tmp; - -! if (!atolfp(ntp_optarg, &tmp)) { - syslog(LOG_ERR, - "command line broadcast delay value %s undecodable", -! ntp_optarg); - } else if (tmp.l_ui != 0) { - syslog(LOG_ERR, - "command line broadcast delay value %s is unlikely", -! ntp_optarg); - } else { - proto_config(PROTO_BROADDELAY, tmp.l_f); - } -*************** -*** 539,556 **** - break; - - case 's': -! stats_config(STATS_STATSDIR, optarg); - break; - - case 't': - do { - int tkey; - -! tkey = atoi(optarg); - if (tkey <= 0 || tkey > NTP_MAXKEY) { - syslog(LOG_ERR, - "command line trusted key %s is unlikely", -! optarg); - } else { - authtrust(tkey, (LONG)1); - } ---- 539,556 ---- - break; - - case 's': -! stats_config(STATS_STATSDIR, ntp_optarg); - break; - - case 't': - do { - int tkey; - -! tkey = atoi(ntp_optarg); - if (tkey <= 0 || tkey > NTP_MAXKEY) { - syslog(LOG_ERR, - "command line trusted key %s is unlikely", -! ntp_optarg); - } else { - authtrust(tkey, (LONG)1); - } -*************** -*** 559,565 **** - - case 'v': - case 'V': -! set_sys_var(optarg, strlen(optarg)+1, RW | ((c == 'V') ? DEF : 0)); - break; - - default: ---- 559,565 ---- - - case 'v': - case 'V': -! set_sys_var(ntp_optarg, strlen(ntp_optarg)+1, RW | ((c == 'V') ? DEF : 0)); - break; - - default: -diff -c -r ../yy/xntpd/ntp_control.c ./xntpd/ntp_control.c -*** ../yy/xntpd/ntp_control.c Thu Jan 27 15:03:48 1994 ---- ./xntpd/ntp_control.c Thu Jan 27 19:29:06 1994 -*************** -*** 1848,1854 **** - ctl_sys_num_events = 0; - gotvar += count_var(ext_sys_var); - wants = (u_char *)emalloc(gotvar); -! bzero((char *)wants, gotvar); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { ---- 1848,1854 ---- - ctl_sys_num_events = 0; - gotvar += count_var(ext_sys_var); - wants = (u_char *)emalloc(gotvar); -! memset((char *)wants, 0, gotvar); - gotvar = 0; - while ((v = ctl_getitem(sys_var, &valuep)) != 0) { - if (v->flags & EOV) { -*************** -*** 1904,1910 **** - if (res_authokay) - peer->num_events = 0; - wants = (u_char *)emalloc(gotvar); -! bzero((char*)wants, gotvar); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { - if (v->flags & EOV) { ---- 1904,1910 ---- - if (res_authokay) - peer->num_events = 0; - wants = (u_char *)emalloc(gotvar); -! memset((char*)wants, 0, gotvar); - gotvar = 0; - while ((v = ctl_getitem(peer_var, &valuep)) != 0) { - if (v->flags & EOV) { -*************** -*** 2106,2112 **** - rpkt.status = htons(ctlclkstatus(&clock)); - gotvar = CC_MAXCODE+1+count_var(clock.kv_list); - wants = (u_char *)emalloc(gotvar); -! bzero((char*)wants, gotvar); - gotvar = 0; - while ((v = ctl_getitem(clock_var, &valuep)) != 0) { - if (v->flags & EOV) { ---- 2106,2112 ---- - rpkt.status = htons(ctlclkstatus(&clock)); - gotvar = CC_MAXCODE+1+count_var(clock.kv_list); - wants = (u_char *)emalloc(gotvar); -! memset((char*)wants, 0, gotvar); - gotvar = 0; - while ((v = ctl_getitem(clock_var, &valuep)) != 0) { - if (v->flags & EOV) { -*************** -*** 2578,2584 **** - *kv = (struct ctl_var *)emalloc((c+2)*sizeof(struct ctl_var)); - if (k) - { -! bcopy((char *)k, (char *)*kv, sizeof(struct ctl_var)*c); - free((char *)k); - } - ---- 2578,2584 ---- - *kv = (struct ctl_var *)emalloc((c+2)*sizeof(struct ctl_var)); - if (k) - { -! memmove((char *)*kv, (char *)k, sizeof(struct ctl_var)*c); - free((char *)k); - } - -*************** -*** 2621,2627 **** - { - free(k->text); - k->text = (char *)emalloc(size); -! bcopy(data, k->text, size); - k->flags = def; - return; - } ---- 2621,2627 ---- - { - free(k->text); - k->text = (char *)emalloc(size); -! memmove(k->text, data, size); - k->flags = def; - return; - } -*************** -*** 2629,2635 **** - else - { - k->text = (char *)emalloc(size); -! bcopy(data, k->text, size); - k->flags = def; - return; - } ---- 2629,2635 ---- - else - { - k->text = (char *)emalloc(size); -! memmove(k->text, data, size); - k->flags = def; - return; - } -*************** -*** 2637,2643 **** - } - } - t = add_var(kv, size, def); -! bcopy(data, t, size); - } - - void ---- 2637,2643 ---- - } - } - t = add_var(kv, size, def); -! memmove(t, data, size); - } - - void --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.7 b/usr.sbin/xntpd/patches/patch.7 deleted file mode 100644 index 682065fc558a..000000000000 --- a/usr.sbin/xntpd/patches/patch.7 +++ /dev/null @@ -1,274 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa21105; 28 Jan 94 9:25 EST -Received: from faui45.informatik.uni-erlangen.de by louie.udel.edu id aa08838; - 28 Jan 94 9:20 EST -Received: from faui43.informatik.uni-erlangen.de by uni-erlangen.de with SMTP; - id AA29169 (5.65c-6/7.3v-FAU); Fri, 28 Jan 1994 15:19:56 +0100 -Received: from faui45x.informatik.uni-erlangen.de by immd4.informatik.uni-erlangen.de with SMTP; - id AA11999 (5.65c-6/7.3m-FAU); Fri, 28 Jan 1994 15:19:51 +0100 -From: Frank Kardel -Message-Id: <199401281419.AA11999@faui43.informatik.uni-erlangen.de> -Subject: Re: Solaribum -To: Paul A Vixie -Date: Fri, 28 Jan 94 14:02:02 MET -Cc: Mills@udel.edu, Frank.Kardel@informatik.uni-erlangen.de, - Piete.Brooks@cl.cam.ac.uk, Paul_Vixie@corpmis.sjc.hw.sony.com -In-Reply-To: <9401272236.AA27835@morality.sjc.hw.sony.com>; from "Paul A Vixie" at Jan 27, 94 2:36 pm -X-Mailer: ELM [version 2.3 PL11] - - -> >memmove() and crumps in loading with an unknown external. If the missing -> >routine is not there in SunOS 4, why not conditionally compile one -> >and be done with it? - -> as i said in earlier mail, there is already a macro for memmove, to define -> it in terms of bcopy, but it is only enabled on systems that don't have a -> native memmove. include/*.h tells the story. - -Ok, in order to cope with the problems (non existent memmove() and -sys header files that use bops) I fixed SUNOS4 and ULTRIX to use the -b-ops (via the NTP_NEED_BOPS define). All other should to my knowledge -use the mem* stuff (I'd rather use either mem* or b* instead of mixtures -of both). - -Now, the following patch should get 3.3y (and 3.3yy) to fly -(=compile) on suns. Functional test have not been done. ULTRIX -has not been tested. - -> there are too many x's and y's now. i'm confused. i promise not to send -> any more patches until the dust clears.. - -With this patch we should get to 3.3yyy which should be the -base for all next efforts (-> and 3.3{x,xx,y,yy} can be deleted). - -May the source be with us: - -diff -c -r ../yy/include/l_stdlib.h ./include/l_stdlib.h -*** ../yy/include/l_stdlib.h Thu Jan 27 15:03:21 1994 ---- ./include/l_stdlib.h Fri Jan 28 12:46:31 1994 -*************** -*** 47,54 **** ---- 47,60 ---- - extern int rand P((void)); - extern int setpgrp P((int, int)); - extern void srand P((unsigned int)); -+ extern void bcopy P((char *, char *, int)); - #endif - -+ #ifndef bzero /* XXX macro prototyping clash */ -+ extern void bzero P((char *, int)); -+ extern int bcmp P((char *, char *, int)); -+ extern void bcopy P((char *, char *, int)); -+ #endif - extern char *mktemp P((char *)); - - extern int tolower P((int)); -*************** -*** 92,102 **** ---- 98,110 ---- - - #ifdef _ntp_string_h - #ifdef NTP_POSIX_SOURCE /* these are builtins */ -+ #ifndef NTP_NEED_BOPS /* but may be emulated by bops */ - extern char *memcpy(); - extern char *memset(); - extern int memcmp(); - #endif - #endif -+ #endif - - #ifdef _sys_socket_h - extern int bind P((int, struct sockaddr *, int)); -*************** -*** 187,192 **** ---- 195,203 ---- - - #ifndef NTP_POSIX_SOURCE - extern int atoi P((char *)); -+ extern void bzero P((char *, int)); -+ extern int bcmp P((char *, char *, int)); -+ extern void bcopy P((char *, char *, int)); - extern int execve P((char *, char **,char **)); - extern int fork P((void)); - extern int getdtablesize P((void)); -diff -c -r ../yy/include/ntp_machine.h ./include/ntp_machine.h -*** ../yy/include/ntp_machine.h Fri Jan 28 13:32:33 1994 ---- ./include/ntp_machine.h Fri Jan 28 12:25:29 1994 -*************** -*** 168,173 **** ---- 168,174 ---- - * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO - */ - #if defined(SYS_SUNOS4) -+ #define NTP_NEED_BOPS - #define NO_SIGNED_CHAR_DECL - #define HAVE_LIBKVM - #define HAVE_MALLOC_H -*************** -*** 266,271 **** ---- 267,273 ---- - * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO - */ - #if defined(SYS_ULTRIX) -+ #define NTP_NEED_BOPS - #define S_CHAR_DEFINED - #define HAVE_READKMEM - #define HAVE_BSD_NICE -diff -c -r ../yy/include/ntp_string.h ./include/ntp_string.h -*** ../yy/include/ntp_string.h Thu Jan 27 15:03:24 1994 ---- ./include/ntp_string.h Fri Jan 28 12:36:44 1994 -*************** -*** 5,11 **** - #ifndef _ntp_string_h - #define _ntp_string_h - -! #ifdef NTP_POSIX_SOURCE - - # if defined(HAVE_MEMORY_H) - # include ---- 5,11 ---- - #ifndef _ntp_string_h - #define _ntp_string_h - -! #if defined(NTP_POSIX_SOURCE) - - # if defined(HAVE_MEMORY_H) - # include -*************** -*** 13,29 **** - - # include - -! #else /* NTP_POSIX_SOURCE */ - - # include -- - # define strchr(s,c) index(s,c) - # define strrchr(s,c) rindex(s,c) - # define memcmp(a,b,c) bcmp(a,b,c) - # define memmove(t,f,c) bcopy(f,t,c) -! # define memset(a,x,c) if (x == 0x00) bzero(a,c) else ntp_memset((char*)a,x,c) - void ntp_memset P((char *, int, int)); - -! #endif /* NTP_POSIX_SOURCE */ - - #endif /* _ntp_string_h */ ---- 13,35 ---- - - # include - -! #else - - # include - # define strchr(s,c) index(s,c) - # define strrchr(s,c) rindex(s,c) -+ # ifndef NTP_NEED_BOPS -+ # define NTP_NEED_BOPS -+ # endif -+ #endif /* NTP_POSIX_SOURCE */ -+ -+ #ifdef NTP_NEED_BOPS -+ - # define memcmp(a,b,c) bcmp(a,b,c) - # define memmove(t,f,c) bcopy(f,t,c) -! # define memset(a,x,c) if (x == 0x00) bzero(a,c); else ntp_memset((char*)a,x,c) - void ntp_memset P((char *, int, int)); - -! #endif /* NTP_NEED_BOPS */ - - #endif /* _ntp_string_h */ -diff -c -r ../yy/lib/machines.c ./lib/machines.c -*** ../yy/lib/machines.c Thu Jan 27 15:03:35 1994 ---- ./lib/machines.c Fri Jan 28 13:55:26 1994 -*************** -*** 31,37 **** - } - #endif - -! #if !defined(NTP_POSIX_SOURCE) - void - ntp_memset(a, x, c) - char *a; ---- 31,37 ---- - } - #endif - -! #if !defined(NTP_POSIX_SOURCE) || defined(NTP_NEED_BOPS) - void - ntp_memset(a, x, c) - char *a; -diff -c -r ../yy/parse/Makefile.tmpl ./parse/Makefile.tmpl -*** ../yy/parse/Makefile.tmpl Fri Nov 26 05:28:30 1993 ---- ./parse/Makefile.tmpl Fri Jan 28 13:47:30 1994 -*************** -*** 92,98 **** - - clean: - -@rm -f $(LIBNAME).a $(KLIBNAME).a *.o *.out *.ln make.log Makefile.bak \ -! lintlib.errs lint.errs genassym assym.s parsestreams parse - -@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl clean - - distclean: clean ---- 92,98 ---- - - clean: - -@rm -f $(LIBNAME).a $(KLIBNAME).a *.o *.out *.ln make.log Makefile.bak \ -! lintlib.errs lint.errs genassym assym.s parsestreams parse parsestreams.o.* - -@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl clean - - distclean: clean -diff -c -r ../yy/parse/parse.c ./parse/parse.c -*** ../yy/parse/parse.c Fri Jan 28 13:32:34 1994 ---- ./parse/parse.c Fri Jan 28 13:08:01 1994 -*************** -*** 29,47 **** - #include "sys/time.h" - #include "sys/errno.h" - - #if defined(PARSESTREAM) && (defined(SYS_SUNOS4) || defined(SYS_SOLARIS)) && defined(STREAM) - /* -! * Sorry, but in SunOS 4.x kernels there are no - * mem* operations. I don't want them - bcopy, bzero - * are fine in the kernel - */ -! #define _ntp_string_h -! extern void bcopy(); -! extern void bzero(); - #else - #define bzero(_X_, _Y_) memset(_X_, 0, _Y_) - #define bcopy(_X_, _Y_, _Z_) memmove(_Y_, _X_, _Z_) - #endif - - #include "ntp_fp.h" - #include "ntp_unixtime.h" ---- 29,53 ---- - #include "sys/time.h" - #include "sys/errno.h" - -+ #include "ntp_machine.h" -+ - #if defined(PARSESTREAM) && (defined(SYS_SUNOS4) || defined(SYS_SOLARIS)) && defined(STREAM) - /* -! * Sorry, but in SunOS 4.x AND Solaris 2.x kernels there are no - * mem* operations. I don't want them - bcopy, bzero - * are fine in the kernel - */ -! #ifndef NTP_NEED_BOPS -! #define NTP_NEED_BOPS -! #endif - #else -+ #ifndef NTP_NEED_BOPS -+ #ifndef bzero - #define bzero(_X_, _Y_) memset(_X_, 0, _Y_) - #define bcopy(_X_, _Y_, _Z_) memmove(_Y_, _X_, _Z_) - #endif -+ #endif -+ #endif - - #include "ntp_fp.h" - #include "ntp_unixtime.h" --- - Frank Kardel (kardel@informatik.uni-erlangen.de) - All SCSI disks will from now on be required to send an email - notice 24 hours prior to complete hardware failure! - diff --git a/usr.sbin/xntpd/patches/patch.8 b/usr.sbin/xntpd/patches/patch.8 deleted file mode 100644 index 52e928cf6f66..000000000000 --- a/usr.sbin/xntpd/patches/patch.8 +++ /dev/null @@ -1,44 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa21136; 28 Jan 94 9:30 EST -Received: from relay1.uu.net by louie.udel.edu id aa09355; 28 Jan 94 9:29 EST -Received: from outpost.wg.waii.com by relay1.UU.NET with SMTP - (5.61/UUNET-internet-primary) id AAwaur00219; Fri, 28 Jan 94 09:29:28 -0500 -Received: from airgun.wg.waii.com by outpost.wg.waii.com with SMTP id AA18918 - (5.65c/IDA-1.4.4 for ); Fri, 28 Jan 1994 08:29:23 -0600 -Received: from merlin.london.waii.com by airgun.wg.waii.com with SMTP id AA18376 - (5.65c/IDA-1.4.4 for ); Fri, 28 Jan 1994 08:29:16 -0600 -Received: from phoenix.london.waii.com by merlin.london.waii.com with SMTP id AA21698 - (5.65c/IDA-1.4.4 for ); Fri, 28 Jan 1994 14:24:29 GMT -Received: by phoenix.london.waii.com (4.1/SMI-4.1) - id AA21825; Fri, 28 Jan 94 14:29:12 GMT -Date: Fri, 28 Jan 94 14:29:12 GMT -From: Marc Brett -Message-Id: <9401281429.AA21825@phoenix.london.waii.com> -To: mills@udel.edu -Subject: Bug in export version of xntp.3.3c - -Dave, - -The crippled DES routine fails to compile on my machine (SunOS 1.4.3, cc). -It complains about U_LONG being unrecognized. Luckily, the fix is a -one-liner. - -*** authdes.c.export Tue Aug 24 22:26:45 1993 ---- authdes.c Fri Jan 28 12:18:40 1994 -*************** -*** 15,20 **** ---- 15,21 ---- - * to its exportable state, copy this file to authdes.c . - */ - #include -+ #include "ntp_stdlib.h" - - /* - * This routine is normally called to compute the key schedule. - - -Regards, - -Marc Brett marc.brett@london.waii.com -Western Geophysical Tel: +44 81 560 3160 - diff --git a/usr.sbin/xntpd/patches/patch.9 b/usr.sbin/xntpd/patches/patch.9 deleted file mode 100644 index 76b330985770..000000000000 --- a/usr.sbin/xntpd/patches/patch.9 +++ /dev/null @@ -1,83 +0,0 @@ - -Received: from louie.udel.edu by huey.udel.edu id aa04410; 31 Jan 94 4:58 EST -Received: from gw.home.vix.com by louie.udel.edu id aa00370; 31 Jan 94 4:52 EST -Received: by gw.home.vix.com id AA12643; Mon, 31 Jan 94 01:52:12 -0800 -Message-Id: <9401310952.AA12643@gw.home.vix.com> -X-Btw: vix.com is also gw.home.vix.com and vixie.sf.ca.us -To: Mills@udel.edu -Cc: Frank.Kardel@informatik.uni-erlangen.de, Piete.Brooks@cl.cam.ac.uk -Subject: diffs to yyy to make ultrix/GOES happy -Date: Mon, 31 Jan 94 01:52:11 PST -From: Paul A Vixie - -diff -r -c2 yyy.ref/adjtime/adjtimed.c xntp3.3yyy/adjtime/adjtimed.c -*** yyy.ref/adjtime/adjtimed.c Thu Jan 27 06:03:11 1994 ---- xntp3.3yyy/adjtime/adjtimed.c Mon Jan 31 01:24:49 1994 -*************** -*** 82,86 **** ---- 82,90 ---- - progname = argv[0]; - -+ #ifdef LOG_LOCAL6 - openlog("adjtimed", LOG_PID, LOG_LOCAL6); -+ #else -+ openlog("adjtimed", LOG_PID); -+ #endif - - while ((ch = ntp_getopt(argc, argv, "hkrvdfp:")) != EOF) { -diff -r -c2 yyy.ref/include/ntp_machine.h xntp3.3yyy/include/ntp_machine.h -*** yyy.ref/include/ntp_machine.h Fri Jan 28 07:26:11 1994 ---- xntp3.3yyy/include/ntp_machine.h Mon Jan 31 01:01:11 1994 -*************** -*** 42,47 **** - - -! WHICH TERMINAL MODEL TO USE - I would assume HAVE_POSIX_TTYS if -! NTP_POSIX_SOURCE was set but cann't. The - posix tty driver is too restrictive on most systems. - It defined if you define STREAMS. ---- 42,47 ---- - - -! WHICH TERMINAL MODEL TO USE - I would assume HAVE_TERMIOS if -! NTP_POSIX_SOURCE was set but can't. The - posix tty driver is too restrictive on most systems. - It defined if you define STREAMS. -*************** -*** 50,54 **** - HAVE_BSD_TTYS - Use BSD stty.h - HAVE_TERMIOS - Use POSIX termios.h -- HAVE_POSIX_TTYS - "struct termios" has c_line defined - - THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about ---- 50,53 ---- -*************** -*** 268,272 **** - */ - #if defined(SYS_ULTRIX) -- #define NTP_NEED_BOPS - #define S_CHAR_DEFINED - #define HAVE_READKMEM ---- 267,270 ---- -*************** -*** 277,280 **** ---- 275,279 ---- - #define STR_SYSTEM "UNIX/Ultrix" - #endif -+ #define HAVE_TERMIOS - #endif - -*************** -*** 565,568 **** ---- 564,573 ---- - && !defined(HAVE_NO_NICE) - ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines -+ #endif -+ -+ #if !defined(HAVE_SYSV_TTYS) \ -+ && !defined(HAVE_BSD_TTYS) \ -+ && !defined(HAVE_TERMIOS) -+ ERROR no_tty_type_defined - #endif - - diff --git a/usr.sbin/xntpd/scripts/hpadjtime.sh b/usr.sbin/xntpd/scripts/hpadjtime.sh deleted file mode 100644 index 07773dc30a2f..000000000000 --- a/usr.sbin/xntpd/scripts/hpadjtime.sh +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/sh -val=1 -if [ -f /bin/uname -o -f /usr/bin/uname ]; then - set `uname -a | tr '[A-Z]' '[a-z]'` - case "$1" in - hp-ux) case "$3" in - *.10.*) val=1 ;; - *.09.03) case "$5" in - 9000/3*) val=1 ;; - *) val=0 ;; - esac ;; - *) val=0 ;; - esac - ;; - *) - esac -fi -exit $val diff --git a/usr.sbin/xntpd/util/Makefile.tmpl b/usr.sbin/xntpd/util/Makefile.tmpl deleted file mode 100644 index e30292f3e1ce..000000000000 --- a/usr.sbin/xntpd/util/Makefile.tmpl +++ /dev/null @@ -1,62 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= tickadj -# -# Makefile for utilities -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -DAEMONLIBS= -RESLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -SOURCE= tickadj.c ntptime.c -TKOBJS= tickadj.o -NTOBJS= ntptime.o -EXECS= ntptime jitter timetrim kern byteorder longsize precision - -all: $(PROGRAM) - -tickadj: $(TKOBJS) - $(CC) $(COPTS) -o $@ $(TKOBJS) $(LIB) $(DAEMONLIBS) $(RESLIB) $(COMPAT) - -ntptime: $(NTOBJS) - $(CC) $(COPTS) -o $@ $(NTOBJS) $(LIB) - -precision: precision.o - $(CC) $(COPTS) -o $@ $@.o - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) $(EXECS) *.o *.out tags make.log Makefile.bak lint.errs - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) $(MFLAGS) MFLAGS="$(MFLAGS)" - diff --git a/usr.sbin/xntpd/xntpd/Makefile.tmpl b/usr.sbin/xntpd/xntpd/Makefile.tmpl deleted file mode 100644 index 919d2a0c9174..000000000000 --- a/usr.sbin/xntpd/xntpd/Makefile.tmpl +++ /dev/null @@ -1,168 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= xntpd -# -# xntpd - NTP daemon -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -CLOCKDEFS= -DAEMONLIBS= -RESLIB= -ADJLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a ../parse/libparse.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -SOURCE= ntp_config.c ntp_control.c ntp_io.c ntp_leap.c \ - ntp_loopfilter.c ntp_monitor.c ntp_peer.c ntp_proto.c \ - ntp_refclock.c ntp_request.c ntp_restrict.c ntp_timer.c \ - ntp_unixclock.c ntp_util.c ntp_intres.c ntp_filegen.c ntpd.c \ - refclock_conf.c refclock_chu.c refclock_local.c \ - refclock_pst.c refclock_wwvb.c refclock_goes.c \ - refclock_mx4200.c refclock_parse.c refclock_as2201.c \ - refclock_omega.c refclock_tpro.c refclock_leitch.c \ - refclock_irig.c refclock_msfees.c refclock_gpstm.c \ - refclock_trak.c refclock_datum.c refclock_acts.c \ - refclock_heath.c, refclock_nmea.c refclock_moto.c \ - refclock_atom.c - -OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \ - ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \ - ntp_refclock.o ntp_request.o ntp_restrict.o ntp_timer.o \ - ntp_unixclock.o ntp_util.o ntp_intres.o ntp_filegen.o ntpd.o \ - refclock_conf.o refclock_chu.o refclock_local.o \ - refclock_pst.o refclock_wwvb.o refclock_goes.o \ - refclock_mx4200.o refclock_parse.o refclock_as2201.o \ - refclock_omega.o refclock_tpro.o refclock_leitch.o \ - refclock_irig.o refclock_msfees.o refclock_gpstm.o \ - refclock_trak.o refclock_datum.o refclock_acts.o \ - refclock_heath.o refclock_nmea.o refclock_moto.o \ - refclock_atom.o - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - -rm -f $(PROGRAM) - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(DAEMONLIBS) \ - $(RESLIB) $(ADJLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags oxntpd make.log Makefile.bak lint.errs - -@rm -f .depend *~ .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -../parse/libparse.a: - cd ../parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version -# -# These guys require knowledge of our clock configuration -# -refclock_chu.o: refclock_chu.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_conf.o: refclock_conf.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_local.o: refclock_local.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_pst.o: refclock_pst.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_goes.o: refclock_goes.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_wwvb.o: refclock_wwvb.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_parse.o: refclock_parse.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_mx4200.o: refclock_mx4200.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_as2201.o: refclock_as2201.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_omega.o: refclock_omega.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_tpro.o: refclock_tpro.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_leitch.o: refclock_leitch.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_irig.o: refclock_irig.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_msfees.o: refclock_msfees.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_trak.o: refclock_trak.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_gpstm.o: refclock_gpstm.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_datum.o: refclock_datum.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_acts.o: refclock_acts.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_heath.o: refclock_heath.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_nmea.o: refclock_nmea.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_moto.o: refclock_moto.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c - -refclock_atom.o: refclock_atom.c - $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c deleted file mode 100644 index 2ce53a7d2c43..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * refclock_datum.c - clock driver for the Datum/Bancomm - * bc635VME Time and Frequency Processor. - * R. Schmidt, Time Service, US Naval Obs. May 94 - * modelled after the TPRO NTP driver. - * - * This requires the Datum HP-UX V9.01 kernel driver and the HP-UX vme2 - * driver subsystem. It has been tested on an HP9000/747i at HP-UX 9.03. - * There are no restrictions on release and use of the following code. - * The refclock type has been defined as 16. - */ -#if defined(REFCLOCK) && defined(DATUM) -#include -#include -#include -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" -#include "/etc/conf/machine/vme2.h" -#include "/etc/conf/h/io.h" -#include "ntp_datum.h" -#include "ntp_stdlib.h" - -/* - * Definitions - */ -#define MAXUNITS 1 /* max number of VME units */ -#define BMAX 50 /* timecode buffer length */ - -/* - * VME interface parameters. The "IRIG" can be changed to "GPS" for the - * VME-GPS. - */ -#define VMEPRECISION (-21) /* precision assumed (1 us) */ -#define VMEREFID "IRIG" /* reference id */ -#define VMEDESCRIPTION "Datum/ VME IRIG-B Reader" /* who we are */ -#define VMEHSREFID 0x7f7f1000 /* 127.127.16.00 refid hi strata */ -#define GMT 0 /* hour offset from Greenwich */ - -/* - * Imported from ntp_timer module - */ -extern u_long current_time; /* current time (s) */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * VME unit control structure. - */ -struct vmeunit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - struct vmedate vmedata; /* data returned from vme read */ - l_fp lastrec; /* last local time */ - l_fp lastref; /* last timecode time */ - char lastcode[BMAX]; /* last timecode received */ - u_short lencode; /* length of last timecode */ - u_long lasttime; /* last time clock heard from */ - u_short unit; /* unit number for this guy */ - u_short status; /* clock status */ - u_short lastevent; /* last clock event */ - u_short year; /* year of eternity */ - u_short day; /* day of year */ - u_short hour; /* hour of day */ - u_short minute; /* minute of hour */ - u_short second; /* seconds of minute */ - u_long usec; /* microsecond of second */ - u_long yearstart; /* start of current year */ - u_short leap; /* leap indicators */ - /* - * Status tallies - */ - u_long polls; /* polls sent */ - u_long noreply; /* no replies to polls */ - u_long coderecv; /* timecodes received */ - u_long badformat; /* bad format */ - u_long baddata; /* bad data */ - u_long timestarted; /* time we started this */ -}; - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct vmeunit *vmeunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char sloppyclockflag[MAXUNITS]; - -/* - * Function prototypes - */ -static void vme_init P(()); -static int vme_start P((u_int, struct peer *)); -static void vme_shutdown P((int)); -static void vme_report_event P((struct vmeunit *, int)); -static void vme_receive P((struct recvbuf *)); -static void vme_poll P((int unit, struct peer *)); -static void vme_control P((u_int, struct refclockstat *, struct refclockstat *)); -static void vme_buginfo P((int, struct refclockbug *)); -struct vmedate *get_datumtime(); - -/* - * Transfer vector - */ -struct refclock refclock_vme = { - vme_start, vme_shutdown, vme_poll, - vme_control, vme_init, vme_buginfo, NOFLAGS -}; - -int fd_vme; /* file descriptor for ioctls */ -int regvalue; - -/* - * vme_init - initialize internal vme driver data - */ -static void -vme_init() -{ - register int i; - /* - * Just zero the data arrays - */ - /* - bzero((char *)vmeunits, sizeof vmeunits); - bzero((char *)unitinuse, sizeof unitinuse); - */ - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor[i].l_ui = 0; - fudgefactor[i].l_uf = 0; - stratumtouse[i] = 0; - sloppyclockflag[i] = 0; - } -} - -/* - * vme_start - open the VME device and initialize data for processing - */ -static int -vme_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct vmeunit *vme; - register int i; - int dummy; - char vmedev[20]; - - /* - * Check configuration info. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "vme_start: unit %d invalid", unit); - return (0); - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "vme_start: unit %d in use", unit); - return (0); - } - - /* - * Open VME device - */ - - if ( (fd_vme = open(VMEFD, O_RDWR)) < 0) { - syslog(LOG_ERR, "vme_start: failed open of %s: %m", vmedev); - return (0); - } - else { /* Release capture lockout in case it was set from before. */ - if( ioctl( fd_vme, RUNLOCK, &dummy ) ) - syslog(LOG_ERR, "vme_start: RUNLOCK failed %m"); - - regvalue = 0; /* More esoteric stuff to do... */ - if( ioctl( fd_vme, WCR0, ®value ) ) - syslog(LOG_ERR, "vme_start: WCR0 failed %m"); - } - - /* - * Allocate unit structure - */ - if (vmeunits[unit] != 0) { - vme = vmeunits[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && vmeunits[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - vme = vmeunits[i]; - vmeunits[i] = 0; - } else { - vme = (struct vmeunit *) - emalloc(sizeof(struct vmeunit)); - } - } - bzero((char *)vme, sizeof(struct vmeunit)); - vmeunits[unit] = vme; - - /* - * Set up the structures - */ - vme->peer = peer; - vme->unit = (u_short)unit; - vme->timestarted = current_time; - - vme->io.clock_recv = vme_receive; - vme->io.srcclock = (caddr_t)vme; - vme->io.datalen = 0; - vme->io.fd = fd_vme; - - /* - * All done. Initialize a few random peer variables, then - * return success. Note that root delay and root dispersion are - * always zero for this clock. - */ - peer->precision = VMEPRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) - bcopy(VMEREFID, (char *)&peer->refid, 4); - else - peer->refid = htonl(VMEHSREFID); - unitinuse[unit] = 1; - return (1); -} - - -/* - * vme_shutdown - shut down a VME clock - */ -static void -vme_shutdown(unit) - int unit; -{ - register struct vmeunit *vme; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "vme_shutdown: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "vme_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - vme = vmeunits[unit]; - io_closeclock(&vme->io); - unitinuse[unit] = 0; -} - -/* - * vme_report_event - note the occurance of an event - * - * This routine presently just remembers the report and logs it, but - * does nothing heroic for the trap handler. - */ -static void -vme_report_event(vme, code) - struct vmeunit *vme; - int code; -{ - struct peer *peer; - - peer = vme->peer; - if (vme->status != (u_short)code) { - vme->status = (u_short)code; - if (code != CEVNT_NOMINAL) - vme->lastevent = (u_short)code; - syslog(LOG_INFO, - "clock %s event %x", ntoa(&peer->srcadr), code); - } -} - - -/* - * vme_receive - receive data from the VME device. - * - * Note: This interface would be interrupt-driven. We don't use that - * now, but include a dummy routine for possible future adventures. - */ -static void -vme_receive(rbufp) - struct recvbuf *rbufp; -{ -} - -/* - * vme_poll - called by the transmit procedure - */ -static void -vme_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct vmedate *tptr; - struct vmeunit *vme; - l_fp tstmp; - time_t tloc; - struct tm *tadr; - - - vme = (struct vmeunit *)emalloc(sizeof(struct vmeunit *)); - tptr = (struct vmedate *)emalloc(sizeof(struct vmedate *)); - - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "vme_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "vme_poll: unit %d not in use", unit); - return; - } - vme = vmeunits[unit]; /* Here is the structure */ - vme->polls++; - - tptr = &vme->vmedata; - if ((tptr = get_datumtime()) == NULL ) { - vme_report_event(vme, CEVNT_BADREPLY); - return; - } - - gettstamp(&vme->lastrec); - vme->lasttime = current_time; - - /* - * Get VME time and convert to timestamp format. - * The year must come from the system clock. - */ - - time(&tloc); - tadr = gmtime(&tloc); - tptr->year = (unsigned short)(tadr->tm_year + 1900); - - sprintf(vme->lastcode, - "%3.3d %2.2d:%2.2d:%2.2d.%.6d %1d\0", - tptr->doy, tptr->hr, tptr->mn, - tptr->sec, tptr->frac, tptr->status); - - record_clock_stats(&(vme->peer->srcadr), vme->lastcode); - vme->lencode = (u_short) strlen(vme->lastcode); - - vme->day = tptr->doy; - vme->hour = tptr->hr; - vme->minute = tptr->mn; - vme->second = tptr->sec; - vme->usec = tptr->frac; - -#ifdef DEBUG - if (debug) - printf("vme: %3d %02d:%02d:%02d.%06ld %1x\n", - vme->day, vme->hour, vme->minute, vme->second, - vme->usec, tptr->status); -#endif - if (tptr->status ) { /* Status 0 is locked to ref., 1 is not */ - vme_report_event(vme, CEVNT_BADREPLY); - return; - } - - /* - * Now, compute the reference time value. Use the heavy - * machinery for the seconds and the millisecond field for the - * fraction when present. If an error in conversion to internal - * format is found, the program declares bad data and exits. - * Note that this code does not yet know how to do the years and - * relies on the clock-calendar chip for sanity. - */ - if (!clocktime(vme->day, vme->hour, vme->minute, - vme->second, GMT, vme->lastrec.l_ui, - &vme->yearstart, &vme->lastref.l_ui)) { - vme->baddata++; - vme_report_event(vme, CEVNT_BADTIME); - syslog(LOG_ERR, "refclock_datum: bad data!!"); - return; - } - TVUTOTSF(vme->usec, vme->lastref.l_uf); - tstmp = vme->lastref; - - L_SUB(&tstmp, &vme->lastrec); - vme->coderecv++; - - L_ADD(&tstmp, &(fudgefactor[vme->unit])); - - refclock_receive(vme->peer, &tstmp, GMT, 0, - &vme->lastrec, &vme->lastrec, vme->leap); -} - -/* - * vme_control - set fudge factors, return statistics - */ -static void -vme_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct vmeunit *vme; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "vme_control: unit %d invalid)", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVEVAL1) { - stratumtouse[unit] = (u_char)(in->fudgeval1 & 0xf); - if (unitinuse[unit]) { - struct peer *peer; - - /* - * Should actually reselect clock, but - * will wait for the next timecode - */ - vme = vmeunits[unit]; - peer = vme->peer; - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) - bcopy(VMEREFID, (char *)&peer->refid, - 4); - else - peer->refid = htonl(VMEHSREFID); - } - } - if (in->haveflags & CLK_HAVEFLAG1) { - sloppyclockflag[unit] = in->flags & CLK_FLAG1; - } - } - - if (out != 0) { -/* out->type = REFCLK_IRIG_VME; */ - out->type = 16; /* made up by RES */ - out->haveflags - = CLK_HAVETIME1|CLK_HAVEVAL1|CLK_HAVEVAL2|CLK_HAVEFLAG1; - out->clockdesc = VMEDESCRIPTION; - out->fudgetime1 = fudgefactor[unit]; - out->fudgetime2.l_ui = 0; - out->fudgetime2.l_uf = 0; - out->fudgeval1 = (LONG)stratumtouse[unit]; - out->fudgeval2 = 0; - out->flags = sloppyclockflag[unit]; - if (unitinuse[unit]) { - vme = vmeunits[unit]; - out->lencode = vme->lencode; - out->lastcode = vme->lastcode; - out->timereset = current_time - vme->timestarted; - out->polls = vme->polls; - out->noresponse = vme->noreply; - out->badformat = vme->badformat; - out->baddata = vme->baddata; - out->lastevent = vme->lastevent; - out->currentstatus = vme->status; - } else { - out->lencode = 0; - out->lastcode = ""; - out->polls = out->noresponse = 0; - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; - } - } -} - -/* - * vme_buginfo - return clock dependent debugging info - */ -static void -vme_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct vmeunit *vme; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "vme_buginfo: unit %d invalid)", unit); - return; - } - - if (!unitinuse[unit]) - return; - vme = vmeunits[unit]; - - bug->nvalues = 11; - bug->ntimes = 5; - if (vme->lasttime != 0) - bug->values[0] = current_time - vme->lasttime; - else - bug->values[0] = 0; - bug->values[2] = (u_long)vme->year; - bug->values[3] = (u_long)vme->day; - bug->values[4] = (u_long)vme->hour; - bug->values[5] = (u_long)vme->minute; - bug->values[6] = (u_long)vme->second; - bug->values[7] = (u_long)vme->usec; - bug->values[9] = vme->yearstart; - bug->stimes = 0x1c; - bug->times[0] = vme->lastref; - bug->times[1] = vme->lastrec; -} - -struct vmedate *get_datumtime() -{ - unsigned short status; - char cbuf[7]; - struct vmedate *time_vme; - struct btfp_time vts; - time_vme = (struct vmedate *)malloc(sizeof(struct vmedate )); - - if( ioctl(fd_vme, READTIME, &vts)) - syslog(LOG_ERR, "get_datumtime error: %m"); - -/* sprintf converts BCD to ASCII */ -/* Get doy */ - sprintf(cbuf,"%3.3x\0", ((vts.btfp_time[ 0 ] & 0x000f) <<8) + - ((vts.btfp_time[ 1 ] & 0xff00) >> 8)); - - if (isdigit(cbuf[0]) && isdigit(cbuf[1]) && isdigit(cbuf[2]) ) - time_vme->doy = (unsigned short)atoi(cbuf); - else - time_vme->doy = (unsigned short) 0; - -/* Get hour */ - sprintf(cbuf,"%2.2x\0", vts.btfp_time[ 1 ] & 0x00ff); - - if (isdigit(cbuf[0]) && isdigit(cbuf[1])) - time_vme->hr = (unsigned short)atoi(cbuf); - else - time_vme->hr = (unsigned short) 0; - -/* Get minutes */ - sprintf(cbuf,"%2.2x\0", (vts.btfp_time[ 2 ] & 0xff00) >>8); - if (isdigit(cbuf[0]) && isdigit(cbuf[1])) - time_vme->mn = (unsigned short)atoi(cbuf); - else - time_vme->mn = (unsigned short) 0; - -/* Get seconds */ - sprintf(cbuf,"%2.2x\0", vts.btfp_time[ 2 ] & 0x00ff); - - if (isdigit(cbuf[0]) && isdigit(cbuf[1])) - time_vme->sec = (unsigned short)atoi(cbuf); - else - time_vme->sec = (unsigned short) 0; - -/* Get microseconds. Yes, we ignore the 0.1 microsecond digit so we can -use the TVTOTSF function later on...*/ - - sprintf(cbuf,"%4.4x%2.2x\0", vts.btfp_time[ 3 ], - vts.btfp_time[ 4 ]>>8); - - if (isdigit(cbuf[0]) && isdigit(cbuf[1]) && isdigit(cbuf[2]) - && isdigit(cbuf[3]) && isdigit(cbuf[4]) && isdigit(cbuf[5])) - time_vme->frac = (u_long) atoi(cbuf); - else - time_vme->frac = (u_long) 0; - -/* Get status bit */ - status = (vts.btfp_time[0] & 0x0010) >>4; - time_vme->status = status; /* Status=0 if locked to ref. */ - /* Status=1 if flywheeling */ - if (status) { /* lost lock ? */ - return ((void *)NULL); - } - else - return (time_vme); -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c deleted file mode 100644 index deab7f46ef6b..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c +++ /dev/null @@ -1,999 +0,0 @@ -/* - * refclock_gpstm - clock driver for the Kinimetrics Truetime GPSTM/TMD rcvr - * Version 1.0 (from Version 2.0 of the GOES driver, as of 03Jan94) - */ - -#if defined(REFCLOCK) && (defined(GPSTM) || defined(GPSTMCLK) \ - || defined(GPSTMPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#ifdef SYS_BSDI -#undef HAVE_BSD_TTYS -#include -#endif - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif - -#if defined(STREAM) -#include -#if defined(GPSTMCLK) -#include -#endif /* GPSTMCLK */ -#endif /* STREAM */ - -#if defined(GPSTMPPS) -#include -#endif /* GPSTMPPS */ - -#include "ntp_stdlib.h" - -/* - * Support for Kinemetrics Truetime GPS-TM/TMD Receiver - * - * Most of this code is copied from refclock_goes.c with thanks. - * - * the time code looks like follows: - * - * ADDD:HH:MM:SSQCL - * A - control A - * Q Quality indication: indicates possible error of - * ? +/- 500 milliseconds # +/- 50 milliseconds - * * +/- 5 milliseconds . +/- 1 millisecond - * space less than 1 millisecond - * C - Carriage return - * L - Line feed - * The carriage return start bit begins on 0 seconds and extends to 1 bit time. - * - * Flag1 set to 1 will silence the clock side of xntpd, just reading the - * clock without trying to write to it. This is usefull if several - * xntpds listen to the same clock. This has not been tested yet... - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* max number of GPSTM units */ -#define GPSTM232 "/dev/gpstm%d" -#define SPEED232 B9600 /* 9600 baud */ - -/* - * Radio interface parameters - */ -#define MAXDISPERSE (FP_SECOND>>1) /* max error for synchronized clock (0.5 s as an u_fp) */ -#define PRECISION (-20) /* precision assumed (about 1 ms) */ -#define REFID "GPS\0" /* reference id */ -#define DESCRIPTION "Kinemetrics GPS-TM/TMD Receiver" /* who we are */ -#define GMT 0 /* hour offset from Greenwich */ -#define NCODES 3 /* stages of median filter */ -#define BMAX 99 /* timecode buffer length */ -#define CODEDIFF 0x20000000 /* 0.125 seconds as an l_fp fraction */ -#define TIMEOUT 180 /* ping the clock if it's silent this long */ - -/* - * used by the state machine - */ -enum gpstm_event {e_Init, e_F18, e_F50, e_F51, e_TS}; -static enum {Base, Start, F18, F50, F51, F08} State[MAXUNITS]; -static void gpstm_doevent P((int, enum gpstm_event)); -static void gpstm_initstate P((int)); - -/* - * Hack to avoid excercising the multiplier. I have no pride. - */ -#define MULBY10(x) (((x)<<3) + ((x)<<1)) - -/* - * Imported from the timer module - */ -extern u_long current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * GPSTM unit control structure - */ -struct gpstm_unit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ - l_fp offset[NCODES]; /* recent sample offsets */ - char lastcode[BMAX]; /* last timecode received */ - u_short polled; /* Hand in a time sample? */ - u_char lencode; /* length of last timecode */ - u_long lasttime; /* last time clock heard from */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char year; /* year of eternity */ - u_short day; /* day of year */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - u_short msec; /* millisecond of second */ - u_char quality; /* quality character */ - u_long yearstart; /* start of current year */ - /* - * Status tallies - */ - u_long polls; /* polls sent */ - u_long noreply; /* no replies to polls */ - u_long coderecv; /* timecodes received */ - u_long badformat; /* bad format */ - u_long baddata; /* bad data */ - u_long timestarted; /* time we started this */ -}; - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct gpstm_unit *gpstm_units[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor1[MAXUNITS]; -static l_fp fudgefactor2[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char readonlyclockflag[MAXUNITS]; -static u_long refid[MAXUNITS]; - -/* - * Function prototypes - */ -static void gpstm_init P((void)); -static int gpstm_start P((u_int, struct peer *)); -static void gpstm_shutdown P((int)); -static void gpstm_rep_event P((struct gpstm_unit *, int)); -static void gpstm_receive P((struct recvbuf *)); -static char gpstm_process P((struct gpstm_unit *, l_fp *, u_fp *)); -static void gpstm_poll P((int, struct peer *)); -static void gpstm_control P((u_int, struct refclockstat *, - struct refclockstat *)); -static void gpstm_buginfo P((int, struct refclockbug *)); -static void gpstm_send P((struct gpstm_unit *, char *)); - -struct refclock refclock_gpstm = { - gpstm_start, gpstm_shutdown, gpstm_poll, - gpstm_control, gpstm_init, gpstm_buginfo, NOFLAGS -}; - -/* - * gpstm_init - initialize internal driver data - */ -static void -gpstm_init() -{ - register int i; - /* - * Just zero the data arrays - */ - memset((char *)gpstm_units, 0, sizeof gpstm_units); - memset((char *)unitinuse, 0, sizeof unitinuse); - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor1[i].l_ui = 0; - fudgefactor1[i].l_uf = 0; - fudgefactor2[i].l_ui = 0; - fudgefactor2[i].l_uf = 0; - stratumtouse[i] = 0; - readonlyclockflag[i] = 0; - memcpy((char *)&refid[i], REFID, 4); - } -} - - -/* - * gpstm_start - open the device and initialize data for processing - */ -static int -gpstm_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct gpstm_unit *gpstm; - register int i; - int fd232; - char dev[20]; - - /* - * Check configuration info - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_start: unit %d invalid", unit); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_start: unit %d in use", unit); - return 0; - } - - /* - * Open serial port - */ - (void) sprintf(dev, GPSTM232, unit); - fd232 = open(dev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "gpstm_start: open of %s: %m", dev); - return 0; - } - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TCGETA): %m", dev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TCSETA): %m", dev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The GPSTMCLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The GPSTMPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - ttyp = &ttyb; - - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcgetattr(%s): %m", dev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcsetattr(%s): %m", dev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcflush(%s): %m", dev); - goto screwed; - } -#if defined(STREAM) -#if defined(GPSTMCLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, I_PUSH, clk): %m", dev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, CLK_SETSTR): %m", dev); -#endif /* GPSTMCLK */ -#if defined(GPSTMPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, I_PUSH, ppsclock): %m", dev); - else - fdpps = fd232; -#endif /* GPSTMPPS */ -#endif /* STREAM */ - } -#endif /* HAVE_TERMIOS */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The GPSTMCLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(GPSTMCLK) - int ldisc = CLKLDISC; -#endif /* GPSTMCLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCGETP): %m", dev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(GPSTMCLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* GPSTMCLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCSETP): %m", dev); - goto screwed; - } -#if defined(GPSTMCLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCSETD): %m", dev); - goto screwed; - } -#endif /* GPSTMCLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Allocate unit structure - */ - if (gpstm_units[unit] != 0) { - gpstm = gpstm_units[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && gpstm_units[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - gpstm = gpstm_units[i]; - gpstm_units[i] = 0; - } else { - gpstm = (struct gpstm_unit *) - emalloc(sizeof(struct gpstm_unit)); - } - } - memset((char *)gpstm, 0, sizeof(struct gpstm_unit)); - gpstm_units[unit] = gpstm; - - /* - * Set up the structures - */ - gpstm->peer = peer; - gpstm->unit = (u_char)unit; - gpstm->timestarted = current_time; - - gpstm->io.clock_recv = gpstm_receive; - gpstm->io.srcclock = (caddr_t)gpstm; - gpstm->io.datalen = 0; - gpstm->io.fd = fd232; - if (!io_addclock(&gpstm->io)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. - */ - peer->precision = PRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - gpstm_initstate(unit); - return 1; - - /* - * Something broke; abandon ship - */ -screwed: - (void) close(fd232); - return 0; -} - -/* - * gpstm_shutdown - shut down a clock - */ -static void -gpstm_shutdown(unit) - int unit; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_shutdown: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - gpstm = gpstm_units[unit]; - io_closeclock(&gpstm->io); - unitinuse[unit] = 0; -} - - -/* - * gpstm_rep_event - note the occurance of an event - */ -static void -gpstm_rep_event(gpstm, code) - struct gpstm_unit *gpstm; - int code; -{ - struct peer *peer; - - peer = gpstm->peer; - if (gpstm->status != (u_char)code) { - gpstm->status = (u_char)code; - if (code != CEVNT_NOMINAL) - gpstm->lastevent = (u_char)code; - syslog(LOG_INFO, - "clock %s event %x\n", ntoa(&peer->srcadr), code); -#ifdef DEBUG - if (debug) { - printf("gpstm_rep_event(gpstm%d, code %d)\n", - gpstm->unit, code); - } -#endif - } - if (code == CEVNT_BADREPLY) - gpstm_initstate(gpstm->unit); -} - - -/* - * gpstm_receive - receive data from the serial interface on a clock - */ -static void -gpstm_receive(rbufp) - struct recvbuf *rbufp; -{ - register int i; - register struct gpstm_unit *gpstm; - register u_char *dpt; - register char *cp; - register u_char *dpend; - l_fp tstmp; - u_fp dispersion; - - /* - * Get the clock this applies to and a pointers to the data - */ - gpstm = (struct gpstm_unit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - - /* - * Edit timecode to remove control chars - */ - dpend = dpt + rbufp->recv_length; - cp = gpstm->lastcode; - while (dpt < dpend) { - if ((*cp = 0x7f & *dpt++) >= ' ') cp++; -#ifdef GPSTMCLK - else if (*cp == '\r') { - if (dpend - dpt < 8) { - /* short timestamp */ - return; - } - if (!buftvtots(dpt,&gpstm->lastrec)) { - /* screwy timestamp */ - return; - } - dpt += 8; - } -#endif - } - *cp = '\0'; - gpstm->lencode = cp - gpstm->lastcode; - if (gpstm->lencode == 0) - return; -#ifndef GPSTMCLK - gpstm->lastrec = rbufp->recv_time; -#endif /* GPSTMCLK */ -#if !defined(GPSTMCLK) && !defined(GPSTMPPS) && defined(TIOCMODT) - do { - auto struct timeval cur, now; - register long usec; - - if (ioctl(gpstm->io.fd, TIOCMODT, &cur) < 0) { - syslog(LOG_ERR, "TIOCMODT: %m"); -#ifdef DEBUG - if (debug) perror("TIOCMODT"); - break; -#endif - } - if (cur.tv_sec == 0) { - /* no timestamps yet */ - if (debug) printf("MODT tv_sec == 0\n"); - break; - } - - gettimeofday(&now, NULL); - usec = 1000000 * (now.tv_sec - cur.tv_sec) - + (now.tv_usec - cur.tv_usec); -#ifdef DEBUG - if (debug) printf("lastmodem: delay=%d us\n", usec); -#endif - if (usec < 0 || usec > 10000) { - /* time warp or stale timestamp */ - break; - } - if (!buftvtots((char *)&cur, &gpstm->lastrec)) { - /* screwy timestamp */ - break; - } - } while (0); -#endif /*TIOCMODT*/ - -#ifdef DEBUG - if (debug) - printf("gpstm: timecode %d %s\n", - gpstm->lencode, gpstm->lastcode); -#endif - - cp = gpstm->lastcode; - gpstm->leap = 0; - if ((cp[0] == 'F' && isdigit(cp[1]) && isdigit(cp[2])) - || (cp[0] == ' ' && cp[1] == 'T' && cp[2] == 'R')) { - enum gpstm_event event; - - syslog(LOG_NOTICE, "gpstm%d: \"%s\"", gpstm->unit, cp); - if (cp[1] == '5' && cp[2] == '0') - event = e_F50; - else if (cp[1] == '5' && cp[2] == '1') - event = e_F51; - else if (!strncmp(" TRUETIME Mk III", cp, 16)) - event = e_F18; - else { - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - gpstm_doevent(gpstm->unit, event); - return; - } else if (gpstm->lencode == 13) { - /* - * Check timecode format 0 - */ - if (!isdigit(cp[0]) /* day of year */ - || !isdigit(cp[1]) - || !isdigit(cp[2]) - || cp[3] != ':' /* : separator */ - || !isdigit(cp[4]) /* hours */ - || !isdigit(cp[5]) - || cp[6] != ':' /* : separator */ - || !isdigit(cp[7]) /* minutes */ - || !isdigit(cp[8]) - || cp[9] != ':' /* : separator */ - || !isdigit(cp[10]) /* seconds */ - || !isdigit(cp[11])) - { - gpstm->badformat++; - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - - /* - * Convert format 0 and check values - */ - gpstm->year = 0; /* fake */ - gpstm->day = cp[0] - '0'; - gpstm->day = MULBY10(gpstm->day) + cp[1] - '0'; - gpstm->day = MULBY10(gpstm->day) + cp[2] - '0'; - gpstm->hour = MULBY10(cp[4] - '0') + cp[5] - '0'; - gpstm->minute = MULBY10(cp[7] - '0') + cp[8] - '0'; - gpstm->second = MULBY10(cp[10] - '0') + cp[11] - '0'; - gpstm->msec = 0; - - if (cp[12] != ' ' && cp[12] != '.' && cp[12] != '*') - gpstm->leap = LEAP_NOTINSYNC; - else - gpstm->lasttime = current_time; - - if (gpstm->day < 1 || gpstm->day > 366) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADDATE); - return; - } - if (gpstm->hour > 23 || gpstm->minute > 59 - || gpstm->second > 59) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - gpstm_doevent(gpstm->unit, e_TS); - } else { - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - - /* - * The clock will blurt a timecode every second but we only - * want one when polled. If we havn't been polled, bail out. - */ - if (!gpstm->polled) - return; - - /* - * Now, compute the reference time value. Use the heavy - * machinery for the seconds and the millisecond field for the - * fraction when present. - * - * this code does not yet know how to do the years - */ - tstmp = gpstm->lastrec; - if (!clocktime(gpstm->day, gpstm->hour, gpstm->minute, - gpstm->second, GMT, tstmp.l_ui, - &gpstm->yearstart, &gpstm->lastref.l_ui)) - { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - MSUTOTSF(gpstm->msec, gpstm->lastref.l_uf); - - i = ((int)(gpstm->coderecv)) % NCODES; - gpstm->offset[i] = gpstm->lastref; - L_SUB(&gpstm->offset[i], &tstmp); - if (gpstm->coderecv == 0) - for (i = 1; i < NCODES; i++) - gpstm->offset[i] = gpstm->offset[0]; - - gpstm->coderecv++; - - /* - * Process the median filter, and pass the - * offset and dispersion along. We use lastrec as both the - * reference time and receive time in order to avoid being cute, - * like setting the reference time later than the receive time, - * which may cause a paranoid protocol module to chuck out the - * data. - */ - if (!gpstm_process(gpstm, &tstmp, &dispersion)) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - refclock_receive(gpstm->peer, &tstmp, GMT, dispersion, - &gpstm->lastrec, &gpstm->lastrec, gpstm->leap); - - /* - * We have succedded in answering the poll. Turn off the flag - */ - gpstm->polled = 0; -} - -/* - * gpstm_send - time to send the clock a signal to cough up a time sample - */ -static void -gpstm_send(gpstm, cmd) - struct gpstm_unit *gpstm; - char *cmd; -{ -#ifdef DEBUG - if (debug) { - printf("gpstm_send(gpstm%d): %s\n", gpstm->unit, cmd); - } -#endif - if (!readonlyclockflag[gpstm->unit]) { - register int len = strlen(cmd); - - if (write(gpstm->io.fd, cmd, len) != len) { - syslog(LOG_ERR, "gpstm_send: unit %d: %m", - gpstm->unit); - gpstm_rep_event(gpstm, CEVNT_FAULT); - } - } -} - -/* - * state machine for initializing the clock - */ - -static void -gpstm_doevent(unit, event) - int unit; - enum gpstm_event event; -{ - struct gpstm_unit *gpstm = gpstm_units[unit]; - -#ifdef DEBUG - if (debug) { - printf("gpstm_doevent(gpstm%d, %d)\n", unit, (int)event); - } -#endif - if (event == e_TS && State[unit] != F51 && State[unit] != F08) { - gpstm_send(gpstm, "\03\r"); - } - - switch (event) { - case e_Init: - gpstm_send(gpstm, "F18\r"); - State[unit] = Start; - break; - case e_F18: - gpstm_send(gpstm, "F50\r"); - State[unit] = F18; - break; - case e_F50: - gpstm_send(gpstm, "F51\r"); - State[unit] = F50; - break; - case e_F51: - gpstm_send(gpstm, "F08\r"); - State[unit] = F51; - break; - case e_TS: - /* nothing to send - we like this mode */ - State[unit] = F08; - break; - } -} - -static void -gpstm_initstate(unit) - int unit; -{ - State[unit] = Base; /* just in case */ - gpstm_doevent(unit, e_Init); -} - -/* - * gpstm_process - process a pile of samples from the clock - */ -static char -gpstm_process(gpstm, offset, dispersion) - struct gpstm_unit *gpstm; - l_fp *offset; - u_fp *dispersion; -{ - register int i, j; - register u_long tmp_ui, tmp_uf; - int not_median1 = -1; /* XXX correct? */ - int not_median2 = -1; /* XXX correct? */ - int median; - u_fp disp_tmp, disp_tmp2; - - /* - * This code implements a three-stage median filter. First, we - * check if the samples are within 125 ms of each other. If not, - * dump the sample set. We take the median of the three offsets - * and use that as the sample offset. We take the maximum - * difference and use that as the sample dispersion. There - * probably is not much to be gained by a longer filter, since - * the clock filter in ntp_proto should do its thing. - */ - disp_tmp2 = 0; - for (i = 0; i < NCODES-1; i++) { - for (j = i+1; j < NCODES; j++) { - tmp_ui = gpstm->offset[i].l_ui; - tmp_uf = gpstm->offset[i].l_uf; - M_SUB(tmp_ui, tmp_uf, gpstm->offset[j].l_ui, - gpstm->offset[j].l_uf); - if (M_ISNEG(tmp_ui, tmp_uf)) { - M_NEG(tmp_ui, tmp_uf); - } - if (tmp_ui != 0 || tmp_uf > CODEDIFF) { - return 0; - } - disp_tmp = MFPTOFP(0, tmp_uf); - if (disp_tmp > disp_tmp2) { - disp_tmp2 = disp_tmp; - not_median1 = i; - not_median2 = j; - } - } - } - - /* - * It seems as if all are within 125 ms of each other. - * Now to determine the median of the three. Whlie the - * 125 ms check was going on, we also subtly catch the - * dispersion and set-up for a very easy median calculation. - * The largest difference between any two samples constitutes - * the dispersion. The sample not involve in the dispersion is - * the median sample. EASY! - */ - if (gpstm->lasttime == 0 || disp_tmp2 > MAXDISPERSE) - disp_tmp2 = MAXDISPERSE; - if (not_median1 == 0) { - if (not_median2 == 1) - median = 2; - else - median = 1; - } else { - median = 0; - } - *offset = gpstm->offset[median]; - *dispersion = disp_tmp2; - return 1; -} - -/* - * gpstm_poll - called by the transmit procedure - */ -static void -gpstm_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct gpstm_unit *gpstm; - - /* - * You don't need to poll this clock. It puts out timecodes - * once per second. If asked for a timestamp, take note. - * The next time a timecode comes in, it will be fed back. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_poll: unit %d not in use", unit); - return; - } - gpstm = gpstm_units[unit]; - if ((current_time - gpstm->lasttime) > 150) { - gpstm->noreply++; - gpstm_rep_event(gpstm_units[unit], CEVNT_TIMEOUT); - gpstm_initstate(gpstm->unit); - } - - /* - * polled every 64 seconds. Ask our receiver to hand in a timestamp. - */ - gpstm->polled = 1; - gpstm->polls++; -} - -/* - * gpstm_control - set fudge factors, return statistics - */ -static void -gpstm_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_control: unit %d invalid", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor1[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - fudgefactor2[unit] = in->fudgetime2; - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (in->haveflags & CLK_HAVEFLAG1) - readonlyclockflag[unit] = in->flags & CLK_FLAG1; - if (unitinuse[unit]) { - struct peer *peer; - - peer = gpstm_units[unit]->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out != 0) { - memset((char *)out, 0, sizeof (struct refclockstat)); - out->type = REFCLK_GPSTM_TRUETIME; - out->haveflags = CLK_HAVETIME1 | CLK_HAVETIME2 | CLK_HAVEVAL1 | - CLK_HAVEVAL2 | CLK_HAVEFLAG1; - out->clockdesc = DESCRIPTION; - out->fudgetime1 = fudgefactor1[unit]; - out->fudgetime2 = fudgefactor2[unit]; - out->fudgeval1 = stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->flags = readonlyclockflag[unit]; - if (unitinuse[unit]) { - gpstm = gpstm_units[unit]; - out->lencode = gpstm->lencode; - out->lastcode = gpstm->lastcode; - out->timereset = current_time - gpstm->timestarted; - out->polls = gpstm->polls; - out->noresponse = gpstm->noreply; - out->badformat = gpstm->badformat; - out->baddata = gpstm->baddata; - out->lastevent = gpstm->lastevent; - out->currentstatus = gpstm->status; - } - } -} - -/* - * gpstm_buginfo - return clock dependent debugging info - */ -static void -gpstm_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_buginfo: unit %d invalid", unit); - return; - } - - if (!unitinuse[unit]) - return; - gpstm = gpstm_units[unit]; - - bug->nvalues = 11; - bug->ntimes = 5; - if (gpstm->lasttime != 0) - bug->values[0] = current_time - gpstm->lasttime; - else - bug->values[0] = 0; - bug->values[1] = gpstm->reason; - bug->values[2] = gpstm->year; - bug->values[3] = gpstm->day; - bug->values[4] = gpstm->hour; - bug->values[5] = gpstm->minute; - bug->values[6] = gpstm->second; - bug->values[7] = gpstm->msec; - bug->values[8] = gpstm->noreply; - bug->values[9] = gpstm->yearstart; - bug->values[10] = gpstm->quality; - bug->stimes = 0x1c; - bug->times[0] = gpstm->lastref; - bug->times[1] = gpstm->lastrec; - bug->times[2] = gpstm->offset[0]; - bug->times[3] = gpstm->offset[1]; - bug->times[4] = gpstm->offset[2]; -} - -#endif /*GPSTM et al*/ diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_leitch.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_leitch.c deleted file mode 100644 index b2a0e7fa76bf..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_leitch.c +++ /dev/null @@ -1,718 +0,0 @@ -/* - * refclock_leitch - clock driver for the Leitch CSD-5300 Master Clock - */ -#if defined(REFCLOCK) && (defined(LEITCH) || defined(LEITCHCLK) || defined(LEITCHPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#ifdef STREAM -#include -#if defined(LEITCHCLK) -#include -#endif /* LEITCHCLK */ -#endif /* STREAM */ - -#if defined (LEITCHPPS) -#include -#endif /* LEITCHPPS */ - -#include "ntp_stdlib.h" - -/* - * Driver for Leitch CSD-5300 Master Clock System - * - * COMMANDS: - * DATE: D - * TIME: T - * STATUS: S - * LOOP: L - * - * FORMAT: - * DATE: YYMMDD - * TIME: /HHMMSS /HHMMSS /HHMMSS / - * second bondaried on the stop bit of the - * second boundaries at '/' above. - * STATUS: G (good), D (diag fail), T (time not provided) or - * P (last phone update failed) - */ -#define MAXUNITS 1 /* max number of LEITCH units */ -#define LEITCHREFID "ATOM" /* reference id */ -#define LEITCH_DESCRIPTION "Leitch: CSD 5300 Master Clock System Driver" -#define LEITCH232 "/dev/leitch%d" /* name of radio device */ -#define SPEED232 B300 /* uart speed (300 baud) */ -#define leitch_send(A,M) \ - if (debug) fprintf(stderr,"write leitch %s\n",M); \ - if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\ - if (debug) \ - fprintf(stderr, "leitch_send: unit %d send failed\n", A->unit); \ - else \ - syslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);} - -#define STATE_IDLE 0 -#define STATE_DATE 1 -#define STATE_TIME1 2 -#define STATE_TIME2 3 -#define STATE_TIME3 4 - -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * LEITCH unit control structure - */ -struct leitchunit { - struct peer *peer; - struct event leitchtimer; - struct refclockio leitchio; - u_char unit; - short year; - short yearday; - short month; - short day; - short hour; - short second; - short minute; - short state; - u_short fudge1; - l_fp reftime1; - l_fp reftime2; - l_fp reftime3; - l_fp codetime1; - l_fp codetime2; - l_fp codetime3; - u_long yearstart; -}; - -/* - * Function prototypes - */ -static void leitch_init P((void)); -static int leitch_start P((u_int, struct peer *)); -static void leitch_shutdown P((int)); -static void leitch_poll P((int, struct peer *)); -static void leitch_control P((u_int, struct refclockstat *, struct refclockstat *)); -#define leitch_buginfo noentry -static void leitch_receive P((struct recvbuf *)); -static void leitch_process P((struct leitchunit *)); -static void leitch_timeout P((struct peer *)); -static int leitch_get_date P((struct recvbuf *, struct leitchunit *)); -static int leitch_get_time P((struct recvbuf *, struct leitchunit *, int)); -static int dysize P((int)); - -static struct leitchunit leitchunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_long refid[MAXUNITS]; - -static char days_in_month [] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - -/* - * Transfer vector - */ -struct refclock refclock_leitch = { - leitch_start, leitch_shutdown, leitch_poll, - leitch_control, leitch_init, leitch_buginfo, NOFLAGS -}; - -/* - * leitch_init - initialize internal leitch driver data - */ -static void -leitch_init() -{ - int i; - - memset((char*)leitchunits, 0, sizeof(leitchunits)); - memset((char*)unitinuse, 0, sizeof(unitinuse)); - for (i = 0; i < MAXUNITS; i++) - memcpy((char *)&refid[i], LEITCHREFID, 4); -} - -/* - * leitch_shutdown - shut down a LEITCH clock - */ -static void -leitch_shutdown(unit) -int unit; -{ -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_shutdown()\n"); -#endif -} - -/* - * leitch_poll - called by the transmit procedure - */ -static void -leitch_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct leitchunit *leitch; - - /* start the state machine rolling */ - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_poll()\n"); -#endif - if (unit > MAXUNITS) { - /* XXXX syslog it */ - return; - } - - leitch = &leitchunits[unit]; - - if (leitch->state != STATE_IDLE) { - /* reset and wait for next poll */ - /* XXXX syslog it */ - leitch->state = STATE_IDLE; - } else { - leitch_send(leitch,"D\r"); - leitch->state = STATE_DATE; - } -} - -static void -leitch_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "leitch_control: unit %d invalid", unit); - return; - } - - if (in) { - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (unitinuse[unit]) { - struct peer *peer; - - peer = (&leitchunits[unit])->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out) { - memset((char *)out, 0, sizeof (struct refclockstat)); - out->type = REFCLK_ATOM_LEITCH; - out->haveflags = CLK_HAVEVAL1 | CLK_HAVEVAL2; - out->fudgeval1 = stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->lastcode = ""; - out->clockdesc = LEITCH_DESCRIPTION; - } -} - -/* - * leitch_start - open the LEITCH devices and initialize data for processing - */ -static int -leitch_start(unit, peer) - u_int unit; - struct peer *peer; -{ - struct leitchunit *leitch; - int fd232; - char leitchdev[20]; - - /* - * Check configuration info. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "leitch_start: unit %d invalid", unit); - return (0); - } - - if (unitinuse[unit]) { - syslog(LOG_ERR, "leitch_start: unit %d in use", unit); - return (0); - } - - /* - * Open serial port. - */ - (void) sprintf(leitchdev, LEITCH232, unit); - fd232 = open(leitchdev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, - "leitch_start: open of %s: %m", leitchdev); - return (0); - } - - leitch = &leitchunits[unit]; - memset((char*)leitch, 0, sizeof(*leitch)); - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TCGETA): %m", leitchdev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TCSETA): %m", leitchdev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The LEITCHCLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The LEITCHPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "leitch_start: tcgetattr(%s): %m", leitchdev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "leitch_start: tcsetattr(%s): %m", leitchdev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "leitch_start: tcflush(%s): %m", leitchdev); - goto screwed; - } - } -#endif /* HAVE_TERMIOS */ -#ifdef STREAM -#if defined(LEITCHCLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, I_PUSH, clk): %m", leitchdev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, CLK_SETSTR): %m", leitchdev); -#endif /* LEITCHCLK */ -#if defined(LEITCHPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, I_PUSH, ppsclock): %m", leitchdev); - else - fdpps = fd232; -#endif /* LEITCHPPS */ -#endif /* STREAM */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The LEITCHCLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(LEITCHCLK) - int ldisc = CLKLDISC; -#endif /* LEITCHCLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCGETP): %m", leitchdev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(LEITCHCLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* LEITCHCLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCSETP): %m", leitchdev); - goto screwed; - } -#if defined(LEITCHCLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCSETD): %m",leitchdev); - goto screwed; - } -#endif /* LEITCHCLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Set up the structures - */ - leitch->peer = peer; - leitch->unit = unit; - leitch->state = STATE_IDLE; - leitch->fudge1 = 15; /* 15ms */ - - leitch->leitchio.clock_recv = leitch_receive; - leitch->leitchio.srcclock = (caddr_t) leitch; - leitch->leitchio.datalen = 0; - leitch->leitchio.fd = fd232; - if (!io_addclock(&leitch->leitchio)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. Note that root delay and root dispersion are - * always zero for this clock. - */ - peer->precision = 0; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - return(1); - - /* - * Something broke; abandon ship. - */ -screwed: - close(fd232); - return(0); -} - -/* - * leitch_receive - receive data from the serial interface on a leitch - * clock - */ -static void -leitch_receive(rbufp) - struct recvbuf *rbufp; -{ - struct leitchunit *leitch = (struct leitchunit *)rbufp->recv_srcclock; - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_recieve(%*.*s)\n", - rbufp->recv_length, rbufp->recv_length, - rbufp->recv_buffer); -#endif - if (rbufp->recv_length != 7) - return; /* The date is return with a trailing newline, - discard it. */ - - switch (leitch->state) { - case STATE_IDLE: /* unexpected, discard and resync */ - return; - case STATE_DATE: - if (!leitch_get_date(rbufp,leitch)) { - leitch->state = STATE_IDLE; - break; - } - leitch_send(leitch,"T\r"); -#ifdef DEBUG - if (debug) - fprintf(stderr, "%u\n",leitch->yearday); -#endif - leitch->state = STATE_TIME1; - break; - case STATE_TIME1: - if (!leitch_get_time(rbufp,leitch,1)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime1.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%lu\n", (u_long)leitch->reftime1.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime1.l_uf); - leitch->codetime1 = rbufp->recv_time; - leitch->state = STATE_TIME2; - break; - case STATE_TIME2: - if (!leitch_get_time(rbufp,leitch,2)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime2.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%lu\n", (u_long)leitch->reftime2.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime2.l_uf); - leitch->codetime2 = rbufp->recv_time; - leitch->state = STATE_TIME3; - break; - case STATE_TIME3: - if (!leitch_get_time(rbufp,leitch,3)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime3.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%lu\n", (u_long)leitch->reftime3.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime3.l_uf); - leitch->codetime3 = rbufp->recv_time; - leitch_process(leitch); - leitch->state = STATE_IDLE; - break; - default: - syslog(LOG_ERR, - "leitech_receive: invalid state %d unit %d", - leitch->state, leitch->unit); - } -} - -/* - * leitch_process - process a pile of samples from the clock - * - * This routine uses a three-stage median filter to calculate offset and - * dispersion. reduce jitter. The dispersion is calculated as the span - * of the filter (max - min), unless the quality character (format 2) is - * non-blank, in which case the dispersion is calculated on the basis of - * the inherent tolerance of the internal radio oscillator, which is - * +-2e-5 according to the radio specifications. - */ -static void -leitch_process(leitch) - struct leitchunit *leitch; -{ - l_fp off; - s_fp delay; - l_fp codetime; - l_fp tmp_fp; - int isinsync = 1; - u_fp dispersion = 10; - - delay = 20; - - codetime = leitch->codetime3; - - off = leitch->reftime1; - L_SUB(&off,&leitch->codetime1); - -#ifdef DEBUG - if (debug) - fprintf(stderr,"%lu %lu %lu %lu %ld %ld\n", - (u_long)leitch->codetime1.l_ui, - (u_long)leitch->codetime1.l_uf, - (u_long)leitch->reftime1.l_ui, - (u_long)leitch->reftime1.l_uf, - (u_long)off.l_i, - (u_long)off.l_f); -#endif - tmp_fp = leitch->reftime2; - L_SUB(&tmp_fp,&leitch->codetime2); - if (L_ISGEQ(&off,&tmp_fp)) - off = tmp_fp; -#ifdef DEBUG - if (debug) - fprintf(stderr,"%lu %lu %lu %lu %ld %ld\n", - (u_long)leitch->codetime2.l_ui, - (u_long)leitch->codetime2.l_uf, - (u_long)leitch->reftime2.l_ui, - (u_long)leitch->reftime2.l_uf, - (u_long)off.l_i, - (u_long)off.l_f); -#endif - tmp_fp = leitch->reftime3; - L_SUB(&tmp_fp,&leitch->codetime3); - - if (L_ISGEQ(&off,&tmp_fp)) - off = tmp_fp; - -#ifdef DEBUG - if (debug) - fprintf(stderr,"%lu %lu %lu %lu %ld %ld\n", - (u_long)leitch->codetime3.l_ui, - (u_long)leitch->codetime3.l_uf, - (u_long)leitch->reftime3.l_ui, - (u_long)leitch->reftime3.l_uf, - (u_long)off.l_i, - (u_long)off.l_f); -#endif - refclock_receive(leitch->peer, &off, 0, dispersion, &codetime, - &codetime, isinsync); -} - -/* - * leitch_timeout - */ -static void -leitch_timeout(fp) - struct peer *fp; -{ - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_timeout()\n"); -#endif - -#ifdef NOTYET - { struct leitchunit *leitch = (struct leitchunit *)fp; - - switch(leitch->state) { - case STATE_IDLE: - leitch_send(leitch,"D\r"); - leitch->state = STATE_DATE; - break; - case STATE_DATE: - leitch_send(leitch,"T\r"); - leitch->state = STATE_TIME1; - break; - case STATE_TIME1: - case STATE_TIME2: - case STATE_TIME3: - default: - break; - } - - leitch->leitchtimer.event_time += 30; - TIMER_ENQUEUE(timerqueue, &leitch->leitchtimer); - } -#endif /* NOTYET */ -} - -/* - * dysize - */ -static int -dysize(year) -int year; -{ - if (year%4) { /* not a potential leap year */ - return (365); - } else { - if (year % 100) { /* is a leap year */ - return (366); - } else { - if (year % 400) { - return (365); - } else { - return (366); - } - } - } -} - -static int -leitch_get_date(rbufp,leitch) - struct recvbuf *rbufp; - struct leitchunit *leitch; -{ - int i; - - if (rbufp->recv_length < 6) - return(0); -#define BAD(A) (rbufp->recv_buffer[A] < '0') || (rbufp->recv_buffer[A] > '9') - if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5)) - return(0); -#define ATOB(A) ((rbufp->recv_buffer[A])-'0') - leitch->year = ATOB(0)*10 + ATOB(1); - leitch->month = ATOB(2)*10 + ATOB(3); - leitch->day = ATOB(4)*10 + ATOB(5); - - /* sanity checks */ - if (leitch->month > 12) - return(0); - if (leitch->day > days_in_month[leitch->month-1]) - return(0); - - /* calculate yearday */ - i = 0; - leitch->yearday = leitch->day; - - while ( i < (leitch->month-1) ) - leitch->yearday += days_in_month[i++]; - - if ((dysize((leitch->year>90?1900:2000)+leitch->year)==365) && - leitch->month > 2) - leitch->yearday--; - - return(1); -} - -/* - * leitch_get_time - */ -static int -leitch_get_time(rbufp,leitch,which) - struct recvbuf *rbufp; - struct leitchunit *leitch; - int which; -{ - if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5)) - return(0); - leitch->hour = ATOB(0)*10 +ATOB(1); - leitch->minute = ATOB(2)*10 +ATOB(3); - leitch->second = ATOB(4)*10 +ATOB(5); - - if ((leitch->hour > 23) || (leitch->minute > 60) || - (leitch->second > 60)) - return(0); - return(1); -} - -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_msfees.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_msfees.c deleted file mode 100644 index 5a6307c3b6f6..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_msfees.c +++ /dev/null @@ -1,1575 +0,0 @@ -/* refclock_ees - clock driver for the EES M201 receiver */ - -#if defined(REFCLOCK) && defined(MSFEESPPS) && defined(STREAM) - -/* Currently REQUIRES STREAM and PPSCD. CLK and CBREAK modes - * were removed as the code was overly hairy, they weren't in use - * (hence probably didn't work). Still in RCS file at cl.cam.ac.uk - */ - -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" -#include "ntp_calendar.h" -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ -#include -#include -#include -#include "ntp_stdlib.h" - - /* - fudgefactor = fudgetime1; - os_delay = fudgetime2; - offset_fudge = os_delay + fudgefactor + inherent_delay; - stratumtouse = fudgeval1 & 0xf - debug = fudgeval2; - sloppyclockflag = flags & CLK_FLAG1; - 1 log smoothing summary when processing sample - 4 dump the buffer from the clock - 8 EIOGETKD the last n uS time stamps - if (flags & CLK_FLAG2 && unitinuse) ees->leaphold = 0; - ees->dump_vals = flags & CLK_FLAG3; - ees->usealldata = flags & CLK_FLAG4; - - - bug->values[0] = (ees->lasttime) ? current_time - ees->lasttime : 0; - bug->values[1] = (ees->clocklastgood)?current_time-ees->clocklastgood:0; - bug->values[2] = ees->status; - bug->values[3] = ees->lastevent; - bug->values[4] = ees->reason; - bug->values[5] = ees->nsamples; - bug->values[6] = ees->codestate; - bug->values[7] = ees->day; - bug->values[8] = ees->hour; - bug->values[9] = ees->minute; - bug->values[10] = ees->second; - bug->values[11] = ees->tz; - bug->values[12] = ees->yearstart; - bug->values[13] = (ees->leaphold > current_time) ? - ees->leaphold - current_time : 0; - bug->values[14] = inherent_delay[unit].l_uf; - bug->values[15] = offset_fudge[unit].l_uf; - - bug->times[0] = ees->reftime; - bug->times[1] = ees->arrvtime; - bug->times[2] = ees->lastsampletime; - bug->times[3] = ees->offset; - bug->times[4] = ees->lowoffset; - bug->times[5] = ees->highoffset; - bug->times[6] = inherent_delay[unit]; - bug->times[8] = os_delay[unit]; - bug->times[7] = fudgefactor[unit]; - bug->times[9] = offset_fudge[unit]; - bug->times[10]= ees->yearstart, 0; - */ - -/* This should support the use of an EES M201 receiver with RS232 - * output (modified to transmit time once per second). - * - * For the format of the message sent by the clock, see the EESM_ - * definitions below. - * - * It appears to run free for an integral number of minutes, until the error - * reaches 4mS, at which point it steps at second = 01. - * It appears that sometimes it steps 4mS (say at 7 min interval), - * then the next minute it decides that it was an error, so steps back. - * On the next minute it steps forward again :-( - * This is typically 16.5uS/S then 3975uS at the 4min re-sync, - * or 9.5uS/S then 3990.5uS at a 7min re-sync, - * at which point it may loose the "00" second time stamp. - * I assume that the most accurate time is just AFTER the re-sync. - * Hence remember the last cycle interval, - * - * Can run in any one of: - * - * PPSCD PPS signal sets CD which interupts, and grabs the current TOD - * (sun) *in the interupt code*, so as to avoid problems with - * the STREAMS scheduling. - * - * It appears that it goes 16.5 uS slow each second, then every 4 mins it - * generates no "00" second tick, and gains 3975 uS. Ho Hum ! (93/2/7) - */ - -/* Definitions */ -#ifndef MAXUNITS -#define MAXUNITS 4 /* maximum number of EES units permitted */ -#endif - -#ifndef EES232 -#define EES232 "/dev/ees%d" /* Device to open to read the data */ -#endif - -/* Other constant stuff */ -#ifndef EESPRECISION -#define EESPRECISION (-10) /* what the heck - 2**-10 = 1ms */ -#endif -#ifndef EESREFID -#define EESREFID "MSF\0" /* String to identify the clock */ -#endif -#ifndef EESHSREFID -#define EESHSREFID (0x7f7f0000 | ((REFCLK_MSF_EES) << 8)) /* Numeric refid */ -#endif - -/* Description of clock */ -#define EESDESCRIPTION "EES M201 MSF Receiver" - -/* Speed we run the clock port at. If this is changed the UARTDELAY - * value should be recomputed to suit. - */ -#ifndef SPEED232 -#define SPEED232 B9600 /* 9600 baud */ -#endif - -/* What is the inherent delay for this mode of working, i.e. when is the - * data time stamped. - */ -#define SAFETY_SHIFT 10 /* Split the shift to avoid overflow */ -#define BITS_TO_L_FP(bits, baud) \ - (((((bits)*2 +1) << (FRACTION_PREC-SAFETY_SHIFT)) / (2*baud)) << SAFETY_SHIFT) -#define INH_DELAY_CBREAK BITS_TO_L_FP(119, 9600) -#define INH_DELAY_PPS BITS_TO_L_FP( 0, 9600) - -#ifndef STREAM_PP1 -#define STREAM_PP1 "ppsclocd\0<-- patch space for module name1 -->" -#endif -#ifndef STREAM_PP2 -#define STREAM_PP2 "ppsclock\0<-- patch space for module name2 -->" -#endif - -/* Offsets of the bytes of the serial line code. The clock gives - * local time with a GMT/BST indication. The EESM_ definitions - * give offsets into ees->lastcode. - */ -#define EESM_CSEC 0 /* centiseconds - always zero in our clock */ -#define EESM_SEC 1 /* seconds in BCD */ -#define EESM_MIN 2 /* minutes in BCD */ -#define EESM_HOUR 3 /* hours in BCD */ -#define EESM_DAYWK 4 /* day of week (Sun = 0 etc) */ -#define EESM_DAY 5 /* day of month in BCD */ -#define EESM_MON 6 /* month in BCD */ -#define EESM_YEAR 7 /* year MOD 100 in BCD */ -#define EESM_LEAP 8 /* 0x0f if leap year, otherwise zero */ -#define EESM_BST 9 /* 0x03 if BST, 0x00 if GMT */ -#define EESM_MSFOK 10 /* 0x3f if radio good, otherwise zero */ - /* followed by a frame alignment byte (0xff) / - / which is not put into the lastcode buffer*/ - -/* Length of the serial time code, in characters. The first length - * is less the frame alignment byte. - */ -#define LENEESPRT (EESM_MSFOK+1) -#define LENEESCODE (LENEESPRT+1) - -/* Code state. */ -#define EESCS_WAIT 0 /* waiting for start of timecode */ -#define EESCS_GOTSOME 1 /* have an incomplete time code buffered */ - -/* Default fudge factor and character to receive */ -#define DEFFUDGETIME 0 /* Default user supplied fudge factor */ -#ifndef DEFOSTIME -#define DEFOSTIME 0 /* Default OS delay -- passed by Make ? */ -#endif -#define DEFINHTIME INH_DELAY_PPS /* inherent delay due to sample point*/ - -/* Limits on things. Reduce the number of samples to SAMPLEREDUCE by median - * elimination. If we're running with an accurate clock, chose the BESTSAMPLE - * as the estimated offset, otherwise average the remainder. - */ -#define FULLSHIFT 6 /* NCODES root 2 */ -#define NCODES (1<< FULLSHIFT) /* 64 */ -#define REDUCESHIFT (FULLSHIFT -1) /* SAMPLEREDUCE root 2 */ - -/* Towards the high ( Why ?) end of half */ -#define BESTSAMPLE ((samplereduce * 3) /4) /* 24 */ - -/* Leap hold time. After a leap second the clock will no longer be - * reliable until it resynchronizes. Hope 40 minutes is enough. */ -#define EESLEAPHOLD (40 * 60) - -#define EES_STEP_F (1 << 24) /* the receiver steps in units of about 4ms */ -#define EES_STEP_F_GRACE (EES_STEP_F/8) /*Allow for slop of 1/8 which is .5ms*/ -#define EES_STEP_NOTE (1 << 21)/* Log any unexpected jumps, say .5 ms .... */ -#define EES_STEP_NOTES 50 /* Only do a limited number */ -#define MAX_STEP 16 /* Max number of steps to remember */ - -/* debug is a bit mask of debugging that is wanted */ -#define DB_SYSLOG_SMPLI 0x0001 -#define DB_SYSLOG_SMPLE 0x0002 -#define DB_SYSLOG_SMTHI 0x0004 -#define DB_SYSLOG_NSMTHE 0x0008 -#define DB_SYSLOG_NSMTHI 0x0010 -#define DB_SYSLOG_SMTHE 0x0020 -#define DB_PRINT_EV 0x0040 -#define DB_PRINT_CDT 0x0080 -#define DB_PRINT_CDTC 0x0100 -#define DB_SYSLOG_KEEPD 0x0800 -#define DB_SYSLOG_KEEPE 0x1000 -#define DB_LOG_DELTAS 0x2000 -#define DB_PRINT_DELTAS 0x4000 -#define DB_LOG_AWAITMORE 0x8000 -#define DB_LOG_SAMPLES 0x10000 -#define DB_NO_PPS 0x20000 -#define DB_INC_PPS 0x40000 -#define DB_DUMP_DELTAS 0x80000 - -struct eesunit { /* EES unit control structure. */ - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp reftime; /* reference time */ - l_fp lastsampletime; /* time as in txt from last EES msg */ - l_fp arrvtime; /* Time at which pkt arrived */ - l_fp codeoffsets[NCODES]; /* the time of arrival of 232 codes */ - l_fp offset; /* chosen offset (for clkbug) */ - l_fp lowoffset; /* lowest sample offset (for clkbug) */ - l_fp highoffset; /* highest " " (for clkbug) */ - char lastcode[LENEESCODE+6]; /* last time code we received */ - u_long lasttime; /* last time clock heard from */ - u_long clocklastgood; /* last time good radio seen */ - u_char lencode; /* length of code in buffer */ - u_char nsamples; /* number of samples we've collected */ - u_char codestate; /* state of 232 code reception */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - char tz; /* timezone from clock */ - u_char ttytype; /* method used */ - u_char dump_vals; /* Should clock values be dumped */ - u_char usealldata; /* Use ALL samples */ - u_short day; /* day of year from last code */ - u_long yearstart; /* start of current year */ - u_long leaphold; /* time of leap hold expiry */ - u_long badformat; /* number of bad format codes */ - u_long baddata; /* number of invalid time codes */ - u_long timestarted; /* time we started this */ - long last_pps_no; /* The serial # of the last PPS */ - char fix_pending; /* Is a "sync to time" pending ? */ - /* Fine tuning - compensate for 4 mS ramping .... */ - l_fp last_l; /* last time stamp */ - u_char last_steps[MAX_STEP]; /* Most recent n steps */ - int best_av_step; /* Best guess at average step */ - char best_av_step_count; /* # of steps over used above */ - char this_step; /* Current pos in buffer */ - int last_step_late; /* How late the last step was (0-59) */ - long jump_fsecs; /* # of fractions of a sec last jump */ - u_long last_step; /* time of last step */ - int last_step_secs; /* Number of seconds in last step */ - int using_ramp; /* 1 -> noemal, -1 -> over stepped */ -}; -#define last_sec last_l.l_ui -#define last_sfsec last_l.l_f -#define this_uisec ((ees->arrvtime).l_ui) -#define this_sfsec ((ees->arrvtime).l_f) -#define msec(x) ((x) / (1<<22)) -#define LAST_STEPS (sizeof ees->last_steps / sizeof ees->last_steps[0]) -#define subms(x) ((((((x < 0) ? (-(x)) : (x)) % (1<<22))/2) * 625) / (1<<(22 -5))) - -/* Bitmask for what methods to try to use -- currently only PPS enabled */ -#define T_CBREAK 1 -#define T_PPS 8 -/* macros to test above */ -#define is_cbreak(x) ((x)->ttytype & T_CBREAK) -#define is_pps(x) ((x)->ttytype & T_PPS) -#define is_any(x) ((x)->ttytype) - -#define CODEREASON 20 /* reason codes */ - -/* Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. */ -static struct eesunit *eesunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* Keep the fudge factors separately so they can be set even - * when no clock is configured. */ -static l_fp inherent_delay[MAXUNITS]; /* when time stamp is taken */ -static l_fp fudgefactor[MAXUNITS]; /* fudgetime1 */ -static l_fp os_delay[MAXUNITS]; /* fudgetime2 */ -static l_fp offset_fudge[MAXUNITS]; /* Sum of above */ -static u_char stratumtouse[MAXUNITS]; -static u_char sloppyclockflag[MAXUNITS]; - -static int deltas[60]; - -static l_fp acceptable_slop; /* = { 0, 1 << (FRACTION_PREC -2) }; */ -static l_fp onesec; /* = { 1, 0 }; */ - -/* Imported from the timer module */ -extern u_long current_time; - -#ifdef DEBUG -static int debug; -#endif - -#ifndef DUMP_BUF_SIZE /* Size of buffer to be used by dump_buf */ -#define DUMP_BUF_SIZE 10112 -#endif - -/* ees_reset - reset the count back to zero */ -#define ees_reset(ees) (ees)->nsamples = 0; \ - (ees)->codestate = EESCS_WAIT - -/* ees_event - record and report an event */ -#define ees_event(ees, evcode) if ((ees)->status != (u_char)(evcode)) \ - ees_report_event((ees), (evcode)) - -/* Find the precision of the system clock by reading it */ -#define USECS 1000000 -#define MINSTEP 5 /* some systems increment uS on each call */ -#define MAXLOOPS (USECS/9) -static int ees_get_precision() -{ - struct timeval tp; - struct timezone tzp; - long last; - int i; - long diff; - long val; - gettimeofday(&tp, &tzp); - - last = tp.tv_usec; - for (i=0; i< 100000; i++) { - gettimeofday(&tp, &tzp); - diff = tp.tv_usec - last; - if (diff < 0) diff += USECS; - if (diff > MINSTEP) break; - last = tp.tv_usec; - } - syslog(LOG_INFO, - "I: ees: precision calculation given %duS after %d loop%s", - diff, i, (i==1) ? "" : "s"); - - if (i == 0) return -20 /* assume 1uS */; - if (i >= MAXLOOPS) return EESPRECISION /* Lies ! */; - for (i=0, val=USECS; val > 0; i--, val /= 2) if (diff > val) return i; - return EESPRECISION /* Lies ! */; -} - -static void dump_buf(coffs, from, to, text) -l_fp *coffs; -int from; -int to; -char *text; -{ - char buff[DUMP_BUF_SIZE + 80]; - int i; - register char *ptr = buff; - sprintf(ptr, text); - for (i=from; i DUMP_BUF_SIZE) syslog(LOG_DEBUG, "D: %s", ptr=buff); - sprintf(ptr, " %06d", ((int)coffs[i].l_f) / 4295); - } - syslog(LOG_DEBUG, "D: %s", buff); -} - -/* msfees_init - initialize internal ees driver data */ -static void msfees_init() -{ - register int i; - /* Just zero the data arrays */ - memset((char *)eesunits, 0, sizeof eesunits); - memset((char *)unitinuse, 0, sizeof unitinuse); - - acceptable_slop.l_ui = 0; - acceptable_slop.l_uf = 1 << (FRACTION_PREC -2); - - onesec.l_ui = 1; - onesec.l_uf = 0; - - /* Initialize fudge factors to default. */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor[i].l_ui = 0; - fudgefactor[i].l_uf = DEFFUDGETIME; - os_delay[i].l_ui = 0; - os_delay[i].l_uf = DEFOSTIME; - inherent_delay[i].l_ui = 0; - inherent_delay[i].l_uf = DEFINHTIME; - offset_fudge[i] = os_delay[i]; - L_ADD(&offset_fudge[i], &fudgefactor[i]); - L_ADD(&offset_fudge[i], &inherent_delay[i]); - stratumtouse[i] = 0; - sloppyclockflag[i] = 0; - } -} - - -/* msfees_start - open the EES devices and initialize data for processing */ -static int msfees_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct eesunit *ees; - register int i; - int fd232 = -1; - char eesdev[20]; - struct termios ttyb, *ttyp; - static void ees_receive(); - extern int io_addclock(); - extern void io_closeclock(); - extern char *emalloc(); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit number %d invalid (max %d)", - unit, MAXUNITS-1); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "ees clock: unit number %d in use", unit); - return 0; - } - - /* Unit okay, attempt to open the devices. We do them both at - * once to make sure we can */ - (void) sprintf(eesdev, EES232, unit); - - fd232 = open(eesdev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "ees clock: open of %s failed: %m", eesdev); - return 0; - } - -#ifdef TIOCEXCL - /* Set for exclusive use */ - if (ioctl(fd232, TIOCEXCL, (char *)0) < 0) { - syslog(LOG_ERR, "ees clock: ioctl(%s, TIOCEXCL): %m", eesdev); - goto screwed; - } -#endif - - /* STRIPPED DOWN VERSION: Only PPS CD is supported at the moment */ - - /* Set port characteristics. If we don't have a STREAMS module or - * a clock line discipline, cooked mode is just usable, even though it - * strips the top bit. The only EES byte which uses the top - * bit is the year, and we don't use that anyway. If we do - * have the line discipline, we choose raw mode, and the - * line discipline code will block up the messages. - */ - - /* STIPPED DOWN VERSION: Only PPS CD is supported at the moment */ - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, "msfees_start: tcgetattr(%s): %m", eesdev); - goto screwed; - } - - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_oflag = 0; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, "msfees_start: tcsetattr(%s): %m", eesdev); - goto screwed; - } - - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, "msfees_start: tcflush(%s): %m", eesdev); - goto screwed; - } - - inherent_delay[unit].l_uf = INH_DELAY_PPS; - - /* offset fudge (how *late* the timestamp is) = fudge + os delays */ - offset_fudge[unit] = os_delay[unit]; - L_ADD(&offset_fudge[unit], &fudgefactor[unit]); - L_ADD(&offset_fudge[unit], &inherent_delay[unit]); - - /* Looks like this might succeed. Find memory for the structure. - * Look to see if there are any unused ones, if not we malloc() one. - */ - if (eesunits[unit] != 0) /* The one we want is okay */ - ees = eesunits[unit]; - else { - /* Look for an unused, but allocated struct */ - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && eesunits[i] != 0) - break; - } - - if (i < MAXUNITS) { /* Reclaim this one */ - ees = eesunits[i]; - eesunits[i] = 0; - } /* no spare -- make a new one */ - else ees = (struct eesunit *) emalloc(sizeof(struct eesunit)); - } - memset((char *)ees, 0, sizeof(struct eesunit)); - eesunits[unit] = ees; - - /* Set up the structures */ - ees->peer = peer; - ees->unit = (u_char)unit; - ees->timestarted= current_time; - ees->ttytype = 0; - ees->io.clock_recv= ees_receive; - ees->io.srcclock= (caddr_t)ees; - ees->io.datalen = 0; - ees->io.fd = fd232; - - /* Okay. Push one of the two (linked into the kernel, or dynamically - * loaded) STREAMS module, and give it to the I/O code to start - * receiving stuff. - */ - - { - int rc1; - /* Pop any existing onews first ... */ - while (ioctl(fd232, I_POP, 0 ) >= 0) ; - - /* Now try pushing either of the possible modules */ - if ((rc1=ioctl(fd232, I_PUSH, STREAM_PP1)) < 0 && - ioctl(fd232, I_PUSH, STREAM_PP2) < 0) { - syslog(LOG_ERR, - "ees clock: Push of `%s' and `%s' to %s failed %m", - STREAM_PP1, STREAM_PP2, eesdev); - goto screwed; - } - else { - syslog(LOG_INFO, "I: ees clock: PUSHed %s on %s", - (rc1 >= 0) ? STREAM_PP1 : STREAM_PP2, eesdev); - ees->ttytype |= T_PPS; - } - } - - /* Add the clock */ - if (!io_addclock(&ees->io)) { - /* Oh shit. Just close and return. */ - syslog(LOG_ERR, "ees clock: io_addclock(%s): %m", eesdev); - goto screwed; - } - - - /* All done. Initialize a few random peer variables, then - * return success. */ - peer->precision = ees_get_precision(); - peer->stratum = stratumtouse[unit]; - peer->rootdelay = 0; /* ++++ */ - peer->rootdispersion = 0; /* ++++ */ - if (stratumtouse[unit] <= 1) { - memmove((char *)&peer->refid, EESREFID, 4); - if (unit > 0 && unit < 10) - ((char *)&peer->refid)[3] = '0' + unit; - } else { - peer->refid = htonl(EESHSREFID); - } - unitinuse[unit] = 1; - syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit); - return (1); - -screwed: - if (fd232 != -1) - (void) close(fd232); - return (0); -} - - -/* msfees_shutdown - shut down a EES clock */ -static void msfees_shutdown(unit) - int unit; -{ - register struct eesunit *ees; - extern void io_closeclock(); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "ees clock: INTERNAL ERROR, unit number %d invalid (max %d)", - unit, MAXUNITS); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, - "ees clock: INTERNAL ERROR, unit number %d not in use", unit); - return; - } - - /* Tell the I/O module to turn us off. We're history. */ - ees = eesunits[unit]; - io_closeclock(&ees->io); - unitinuse[unit] = 0; -} - - -/* ees_report_event - note the occurance of an event */ -static void ees_report_event(ees, code) - struct eesunit *ees; - int code; -{ - if (ees->status != (u_char)code) { - ees->status = (u_char)code; - if (code != CEVNT_NOMINAL) - ees->lastevent = (u_char)code; - /* Should report event to trap handler in here. - * Soon... - */ - } -} - - -/* ees_receive - receive data from the serial interface on an EES clock */ -static void ees_receive(rbufp) - struct recvbuf *rbufp; -{ - register int n_sample; - register int day; - register struct eesunit *ees; - register u_char *dpt; /* Data PoinTeR: move along ... */ - register u_char *dpend; /* Points just *after* last data char */ - register char *cp; - l_fp tmp; - static void ees_process(); - int call_pps_sample = 0; - l_fp pps_arrvstamp; - int sincelast; - int pps_step = 0; - int suspect_4ms_step = 0; - struct ppsclockev ppsclockev; - long *ptr = (long *) &ppsclockev; - extern errno; - int rc; - - /* Get the clock this applies to and a pointer to the data */ - ees = (struct eesunit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - dpend = dpt + rbufp->recv_length; - if ((debug & DB_LOG_AWAITMORE) && (rbufp->recv_length != LENEESCODE)) - printf("[%d] ", rbufp->recv_length); - - /* Check out our state and process appropriately */ - switch (ees->codestate) { - case EESCS_WAIT: - /* Set an initial guess at the timestamp as the recv time. - * If just running in CBREAK mode, we can't improve this. - * If we have the CLOCK Line Discipline, PPSCD, or sime such, - * then we will do better later .... - */ - ees->arrvtime = rbufp->recv_time; - ees->codestate = EESCS_GOTSOME; - ees->lencode = 0; - /*FALLSTHROUGH*/ - - case EESCS_GOTSOME: - cp = &(ees->lastcode[ees->lencode]); - - /* Gobble the bytes until the final (possibly stripped) 0xff */ - while (dpt < dpend && (*dpt & 0x7f) != 0x7f) { - *cp++ = (char)*dpt++; - ees->lencode++; - /* Oh dear -- too many bytes .. */ - if (ees->lencode > LENEESPRT) { - syslog(LOG_INFO, -"I: ees clock: %d + %d > %d [%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x]", - ees->lencode, dpend - dpt, LENEESPRT, -#define D(x) (ees->lastcode[x]) - D(0), D(1), D(2), D(3), D(4), D(5), D(6), - D(7), D(8), D(9), D(10), D(11), D(12)); -#undef D - ees->badformat++; - ees->reason = CODEREASON + 1; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - } - /* Gave up because it was end of the buffer, rather than ff */ - if (dpt == dpend) { - /* Incomplete. Wait for more. */ - if (debug & DB_LOG_AWAITMORE) syslog(LOG_INFO, - "I: ees clock %d: %d == %d: await more", - ees->unit, dpt, dpend); - return; - } - - /* This shouldn't happen ... ! */ - if ((*dpt & 0x7f) != 0x7f) { - syslog(LOG_INFO, "I: ees clock: %0x & 0x7f != 0x7f", *dpt); - ees->badformat++; - ees->reason = CODEREASON + 2; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* Skip the 0xff */ - dpt++; - - /* Finally, got a complete buffer. Mainline code will - * continue on. */ - cp = ees->lastcode; - break; - - default: - syslog(LOG_ERR, "ees clock: INTERNAL ERROR: %d state %d", - ees->unit, ees->codestate); - ees->reason = CODEREASON + 5; - ees_event(ees, CEVNT_FAULT); - ees_reset(ees); - return; - } - - /* Boy! After all that crap, the lastcode buffer now contains - * something we hope will be a valid time code. Do length - * checks and sanity checks on constant data. - */ - ees->codestate = EESCS_WAIT; - ees->lasttime = current_time; - if (ees->lencode != LENEESPRT) { - ees->badformat++; - ees->reason = CODEREASON + 6; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - cp = ees->lastcode; - - /* Check that centisecond is zero */ - if (cp[EESM_CSEC] != 0) { - ees->baddata++; - ees->reason = CODEREASON + 7; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* Check flag formats */ - if (cp[EESM_LEAP] != 0 && cp[EESM_LEAP] != 0x0f) { - ees->badformat++; - ees->reason = CODEREASON + 8; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - if (cp[EESM_BST] != 0 && cp[EESM_BST] != 0x03) { - ees->badformat++; - ees->reason = CODEREASON + 9; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - if (cp[EESM_MSFOK] != 0 && cp[EESM_MSFOK] != 0x3f) { - ees->badformat++; - ees->reason = CODEREASON + 10; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* So far, so good. Compute day, hours, minutes, seconds, - * time zone. Do range checks on these. - */ - -#define bcdunpack(val) ( (((val)>>4) & 0x0f) * 10 + ((val) & 0x0f) ) -#define istrue(x) ((x)?1:0) - - ees->second = bcdunpack(cp[EESM_SEC]); /* second */ - ees->minute = bcdunpack(cp[EESM_MIN]); /* minute */ - ees->hour = bcdunpack(cp[EESM_HOUR]); /* hour */ - - day = bcdunpack(cp[EESM_DAY]); /* day of month */ - - switch (bcdunpack(cp[EESM_MON])) { /* month */ - - /* Add in lengths of all previous months. Add one more - if it is a leap year and after February. - */ - case 12: day += NOV; /*FALLSTHROUGH*/ - case 11: day += OCT; /*FALLSTHROUGH*/ - case 10: day += SEP; /*FALLSTHROUGH*/ - case 9: day += AUG; /*FALLSTHROUGH*/ - case 8: day += JUL; /*FALLSTHROUGH*/ - case 7: day += JUN; /*FALLSTHROUGH*/ - case 6: day += MAY; /*FALLSTHROUGH*/ - case 5: day += APR; /*FALLSTHROUGH*/ - case 4: day += MAR; /*FALLSTHROUGH*/ - case 3: day += FEB; - if (istrue(cp[EESM_LEAP])) day++; /*FALLSTHROUGH*/ - case 2: day += JAN; /*FALLSTHROUGH*/ - case 1: break; - default: ees->baddata++; - ees->reason = CODEREASON + 11; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - - ees->day = day; - - /* Get timezone. The clocktime routine wants the number - * of hours to add to the delivered time to get UT. - * Currently -1 if BST flag set, 0 otherwise. This - * is the place to tweak things if double summer time - * ever happens. - */ - ees->tz = istrue(cp[EESM_BST]) ? -1 : 0; - - if (ees->day > 366 || ees->day < 1 || - ees->hour > 23 || ees->minute > 59 || ees->second > 59) { - ees->baddata++; - ees->reason = CODEREASON + 12; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - - n_sample = ees->nsamples; - - /* Now, compute the reference time value: text -> tmp.l_ui */ - if (!clocktime(ees->day, ees->hour, ees->minute, ees->second, - ees->tz, rbufp->recv_time.l_ui, &ees->yearstart, - &tmp.l_ui)) { - ees->baddata++; - ees->reason = CODEREASON + 13; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - tmp.l_uf = 0; - - /* DON'T use ees->arrvtime -- it may be < reftime */ - ees->lastsampletime = tmp; - - /* If we are synchronised to the radio, update the reference time. - * Also keep a note of when clock was last good. - */ - if (istrue(cp[EESM_MSFOK])) { - ees->reftime = tmp; - ees->clocklastgood = current_time; - } - - - /* Compute the offset. For the fractional part of the - * offset we use the expected delay for the message. - */ - ees->codeoffsets[n_sample].l_ui = tmp.l_ui; - ees->codeoffsets[n_sample].l_uf = 0; - - /* Number of seconds since the last step */ - sincelast = this_uisec - ees->last_step; - - memset(&ppsclockev, 0, sizeof ppsclockev); - - rc = ioctl(ees->io.fd, CIOGETEV, (char *) &ppsclockev); - if (debug & DB_PRINT_EV) fprintf(stderr, - "[%x] CIOGETEV u%d %d (%x %d) gave %d (%d): %08x %08x %d\n", - DB_PRINT_EV, ees->unit, ees->io.fd, CIOGETEV, is_pps(ees), - rc, errno, ptr[0], ptr[1], ptr[2]); - - /* If we managed to get the time of arrival, process the info */ - if (rc >= 0) { - int conv = -1; - pps_step = ppsclockev.serial - ees->last_pps_no; - - /* Possible that PPS triggered, but text message didn't */ - if (pps_step == 2) syslog(LOG_ERR, "pps step = 2 @ %02d", ees->second); - if (pps_step == 2 && ees->second == 1) suspect_4ms_step |= 1; - if (pps_step == 2 && ees->second == 2) suspect_4ms_step |= 4; - - /* allow for single loss of PPS only */ - if (pps_step != 1 && pps_step != 2) - fprintf(stderr, "PPS step: %d too far off %d (%d)\n", - ppsclockev.serial, ees->last_pps_no, pps_step); - else if (!buftvtots((char *) &(ppsclockev.tv), &pps_arrvstamp)) - fprintf(stderr, "buftvtots failed\n"); - else { /* if ((ABS(time difference) - 0.25) < 0) - * then believe it ... - */ - l_fp diff; - diff = pps_arrvstamp; - conv = 0; - L_SUB(&diff, &ees->arrvtime); -if (debug & DB_PRINT_CDT) printf("[%x] Have %x.%08x and %x.%08x -> %x.%08x @ %s", - DB_PRINT_CDT, ees->arrvtime.l_ui, ees->arrvtime.l_uf, - pps_arrvstamp.l_ui, pps_arrvstamp.l_uf, - diff.l_ui, diff.l_uf, - ctime(&(ppsclockev.tv.tv_sec))); - if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf); - L_SUB(&diff, &acceptable_slop); - if (L_ISNEG(&diff)) { /* AOK -- pps_sample */ - ees->arrvtime = pps_arrvstamp; - conv++; - call_pps_sample++; - } - /* Some loss of some signals around sec = 1 */ - else if (ees->second == 1) { - diff = pps_arrvstamp; - L_ADD(&diff, &onesec); - L_SUB(&diff, &ees->arrvtime); - if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf); - L_SUB(&diff, &acceptable_slop); -syslog(LOG_ERR, "Have sec==1 slip %ds a=%08x-p=%08x -> %x.%08x (u=%d) %s", - pps_arrvstamp.l_ui - ees->arrvtime.l_ui, - pps_arrvstamp.l_uf, - ees->arrvtime.l_uf, - diff.l_ui, diff.l_uf, - ppsclockev.tv.tv_usec, - ctime(&(ppsclockev.tv.tv_sec))); - if (L_ISNEG(&diff)) { /* AOK -- pps_sample */ - suspect_4ms_step |= 2; - ees->arrvtime = pps_arrvstamp; - L_ADD(&ees->arrvtime, &onesec); - conv++; - call_pps_sample++; - } - } - } - ees->last_pps_no = ppsclockev.serial; - if (debug & DB_PRINT_CDTC) printf( - "[%x] %08x %08x %d u%d (%d %d)\n", - DB_PRINT_CDTC, pps_arrvstamp.l_ui, - pps_arrvstamp.l_uf, conv, ees->unit, - call_pps_sample, pps_step); - } - - /* See if there has been a 4ms jump at a minute boundry */ - { l_fp delta; -#define delta_isec delta.l_ui -#define delta_ssec delta.l_i -#define delta_sfsec delta.l_f - long delta_f_abs; - - delta.l_i = ees->arrvtime.l_i; - delta.l_f = ees->arrvtime.l_f; - - L_SUB(&delta, &ees->last_l); - delta_f_abs = delta_sfsec; - if (delta_f_abs < 0) delta_f_abs = -delta_f_abs; - - /* Dump the deltas each minute */ - if (debug & DB_DUMP_DELTAS) - { if (0 <= ees->second && - ees->second < ((sizeof deltas) / (sizeof deltas[0]))) deltas[ees->second] = delta_sfsec; - /* Dump on second 1, as second 0 sometimes missed */ - if (ees->second == 1) { - char text[16 * ((sizeof deltas) / (sizeof deltas[0]))]; - char *ptr=text; - int i; - for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) { - sprintf(ptr, " %d.%04d", - msec(deltas[i]), subms(deltas[i])); - while (*ptr) ptr++; - } - syslog(LOG_ERR, "Deltas: %d.%04d<->%d.%04d: %s", - msec(EES_STEP_F - EES_STEP_F_GRACE), subms(EES_STEP_F - EES_STEP_F_GRACE), - msec(EES_STEP_F + EES_STEP_F_GRACE), subms(EES_STEP_F + EES_STEP_F_GRACE), - text+1); - for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) deltas[i] = 0; - } - } - - /* Lets see if we have a 4 mS step at a minute boundaary */ - if ( ((EES_STEP_F - EES_STEP_F_GRACE) < delta_f_abs) && - (delta_f_abs < (EES_STEP_F + EES_STEP_F_GRACE)) && - (ees->second == 0 || ees->second == 1 || ees->second == 2) && - (sincelast < 0 || sincelast > 122) - ) { /* 4ms jump at min boundry */ - int old_sincelast; - int count=0; - int sum = 0; - /* Yes -- so compute the ramp time */ - if (ees->last_step == 0) sincelast = 0; - old_sincelast = sincelast; - - /* First time in, just set "ees->last_step" */ - if(ees->last_step) { - int other_step = 0; - int third_step = 0; - int this_step = (sincelast + (60 /2)) / 60; - int p_step = ees->this_step; - int p; - ees->last_steps[p_step] = this_step; - p= p_step; - p_step++; - if (p_step >= LAST_STEPS) p_step = 0; - ees->this_step = p_step; - /* Find the "average" interval */ - while (p != p_step) { - int this = ees->last_steps[p]; - if (this == 0) break; - if (this != this_step) { - if (other_step == 0 && ( - this== (this_step +2) || - this== (this_step -2) || - this== (this_step +1) || - this== (this_step -1))) - other_step = this; - if (other_step != this) { - int delta = (this_step - other_step); - if (delta < 0) delta = - delta; - if (third_step == 0 && ( - (delta == 1) ? ( - this == (other_step +1) || - this == (other_step -1) || - this == (this_step +1) || - this == (this_step -1)) - : - ( - this == (this_step + other_step)/2 - ) - )) third_step = this; - if (third_step != this) break; - } - } - sum += this; - p--; - if (p < 0) p += LAST_STEPS; - count++; - } -syslog(LOG_ERR, "MSF%d: %d: This=%d (%d), other=%d/%d, sum=%d, count=%d, pps_step=%d, suspect=%x", ees->unit, p, ees->last_steps[p], this_step, other_step, third_step, sum, count, pps_step, suspect_4ms_step); - if (count != 0) sum = ((sum * 60) + (count /2)) / count; -#define SV(x) (ees->last_steps[(x + p_step) % LAST_STEPS]) -syslog(LOG_ERR, "MSF%d: %x steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", - ees->unit, suspect_4ms_step, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6), - SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15)); -printf("MSF%d: steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", - ees->unit, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6), - SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15)); -#undef SV - ees->jump_fsecs = delta_sfsec; - ees->using_ramp = 1; - if (sincelast > 170) - ees->last_step_late += sincelast - ((sum) ? sum : ees->last_step_secs); - else ees->last_step_late = 30; - if (ees->last_step_late < -60 || ees->last_step_late > 120) ees->last_step_late = 30; - if (ees->last_step_late < 0) ees->last_step_late = 0; - if (ees->last_step_late >= 60) ees->last_step_late = 59; - sincelast = 0; - } - else { /* First time in -- just save info */ - ees->last_step_late = 30; - ees->jump_fsecs = delta_sfsec; - ees->using_ramp = 1; - sum = 4 * 60; - } - ees->last_step = this_uisec; -printf("MSF%d: d=%3d.%04d@%d :%d:%d:$%d:%d:%d\n", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, old_sincelast, ees->last_step_late, count, sum, ees->last_step_secs); -syslog(LOG_ERR, "MSF%d: d=%3d.%04d@%d :%d:%d:%d:%d:%d", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, old_sincelast, ees->last_step_late, count, sum, ees->last_step_secs); - if (sum) ees->last_step_secs = sum; - } - /* OK, so not a 4ms step at a minute boundry */ - else { - if (suspect_4ms_step) syslog(LOG_ERR, - "MSF%d: suspect = %x, but delta of %d.%04d [%d.%04d<%d.%04d<%d.%04d: %d %d]", - ees->unit, suspect_4ms_step, msec(delta_sfsec), subms(delta_sfsec), - msec(EES_STEP_F - EES_STEP_F_GRACE), - subms(EES_STEP_F - EES_STEP_F_GRACE), - msec(delta_f_abs), - subms(delta_f_abs), - msec(EES_STEP_F + EES_STEP_F_GRACE), - subms(EES_STEP_F + EES_STEP_F_GRACE), - ees->second, - sincelast); - if ((delta_f_abs > EES_STEP_NOTE) && ees->last_l.l_i) { - static ees_step_notes = EES_STEP_NOTES; - if (ees_step_notes > 0) { - ees_step_notes--; -printf("MSF%d: D=%3d.%04d@%02d :%d%s\n", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, sincelast, ees_step_notes ? "" : " -- NO MORE !"); -syslog(LOG_ERR, "MSF%d: D=%3d.%04d@%02d :%d%s", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, (ees->last_step) ? sincelast : -1, ees_step_notes ? "" : " -- NO MORE !"); - } - } - } - } - ees->last_l = ees->arrvtime; - - /* IF we have found that it's ramping - * && it's within twice the expected ramp period - * && there is a non zero step size (avoid /0 !) - * THEN we twiddle things - */ - if (ees->using_ramp && - sincelast < (ees->last_step_secs)*2 && - ees->last_step_secs) - { long sec_of_ramp = sincelast + ees->last_step_late; - long fsecs; - l_fp inc; - - /* Ramp time may vary, so may ramp for longer than last time */ - if (sec_of_ramp > (ees->last_step_secs + 120)) - sec_of_ramp = ees->last_step_secs; - - /* sec_of_ramp * ees->jump_fsecs may overflow 2**32 */ - fsecs = sec_of_ramp * (ees->jump_fsecs / ees->last_step_secs); - - if (debug & DB_LOG_DELTAS) syslog(LOG_ERR, - "[%x] MSF%d: %3d/%03d -> d=%11d (%d|%d)", - DB_LOG_DELTAS, - ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, - pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); - if (debug & DB_PRINT_DELTAS) printf( - "MSF%d: %3d/%03d -> d=%11d (%d|%d)\n", - ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, - pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); - - /* Must sign extend the result */ - inc.l_i = (fsecs < 0) ? -1 : 0; - inc.l_f = fsecs; - if (debug & DB_INC_PPS) - { L_SUB(&pps_arrvstamp, &inc); - L_SUB(&ees->arrvtime, &inc); - } - else - { L_ADD(&pps_arrvstamp, &inc); - L_ADD(&ees->arrvtime, &inc); - } - } - else { - if (debug & DB_LOG_DELTAS) syslog(LOG_ERR, - "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x", - DB_LOG_DELTAS, - ees->unit, ees->using_ramp, - sincelast, - (ees->last_step_secs)*2, - ees->last_step_secs); - if (debug & DB_PRINT_DELTAS) printf( - "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x\n", - DB_LOG_DELTAS, - ees->unit, ees->using_ramp, - sincelast, - (ees->last_step_secs)*2, - ees->last_step_secs); - } - - L_SUB(&ees->arrvtime, &offset_fudge[ees->unit]); - L_SUB(&pps_arrvstamp, &offset_fudge[ees->unit]); - - if (call_pps_sample && !(debug & DB_NO_PPS)) { - /* Sigh -- it expects its args negated */ - L_NEG(&pps_arrvstamp); - (void) pps_sample(&pps_arrvstamp); - } - - /* Subtract off the local clock time stamp */ - L_SUB(&ees->codeoffsets[n_sample], &ees->arrvtime); - if (debug & DB_LOG_SAMPLES) syslog(LOG_ERR, - "MSF%d: [%x] %d (ees: %d %d) (pps: %d %d)%s", - ees->unit, DB_LOG_DELTAS, n_sample, - ees->codeoffsets[n_sample].l_f, - ees->codeoffsets[n_sample].l_f / 4295, - pps_arrvstamp.l_f, - pps_arrvstamp.l_f /4295, - (debug & DB_NO_PPS) ? " [no PPS]" : ""); - - if (ees->nsamples++ == NCODES-1) ees_process(ees); - - /* Done! */ -} - - -static void set_x(fp_offset) -l_fp *fp_offset; -{ - step_systime_real(fp_offset); -} - - -/* offcompare - auxiliary comparison routine for offset sort */ - -static int -offcompare(a, b) -l_fp *a, *b; -{ - return(L_ISGEQ(a, b) ? (L_ISEQU(a, b) ? 0 : 1) : -1); -} - - -/* ees_process - process a pile of samples from the clock */ -static void ees_process(ees) - struct eesunit *ees; -{ - static last_samples = -1; - register int i, j; - register int noff; - register l_fp *coffs = ees->codeoffsets; - l_fp offset, tmp; - u_fp dispersion; /* ++++ */ - int lostsync, isinsync; - int samples = ees->nsamples; - int samplelog; - int samplereduce = (samples + 1) / 2; - - /* Reset things to zero so we don't have to worry later */ - ees_reset(ees); - - if (sloppyclockflag[ees->unit]) { - samplelog = (samples < 2) ? 0 : - (samples < 5) ? 1 : - (samples < 9) ? 2 : - (samples < 17) ? 3 : - (samples < 33) ? 4 : 5; - samplereduce = (1 << samplelog); - } - - if (samples != last_samples && - ((samples != (last_samples-1)) || samples < 3)) { - syslog(LOG_ERR, "Samples=%d (%d), samplereduce=%d ....", - samples, last_samples, samplereduce); - last_samples = samples; - } - if (samples < 1) return; - - /* If requested, dump the raw data we have in the buffer */ - if (ees->dump_vals) dump_buf(coffs, 0, samples, "Raw data is:"); - - /* Sort the offsets, trim off the extremes, then choose one. */ - qsort((char *) coffs, samples, sizeof(l_fp), offcompare); - - noff = samples; - i = 0; - while ((noff - i) > samplereduce) { - /* Trim off the sample which is further away - * from the median. We work this out by doubling - * the median, subtracting off the end samples, and - * looking at the sign of the answer, using the - * identity (c-b)-(b-a) == 2*b-a-c - */ - tmp = coffs[(noff + i)/2]; - L_ADD(&tmp, &tmp); - L_SUB(&tmp, &coffs[i]); - L_SUB(&tmp, &coffs[noff-1]); - if (L_ISNEG(&tmp)) noff--; else i++; - } - - /* If requested, dump the reduce data we have in the buffer */ - if (ees->dump_vals) dump_buf(coffs, i, noff, "Reduced to:"); - - /* What we do next depends on the setting of the sloppy clock flag. - * If it is on, average the remainder to derive our estimate. - * Otherwise, just pick a representative value from the remaining stuff - */ - if (sloppyclockflag[ees->unit]) { - offset.l_ui = offset.l_uf = 0; - for (j = i; j < noff; j++) - L_ADD(&offset, &coffs[j]); - for (j = samplelog; j > 0; j--) - L_RSHIFTU(&offset); - } - else offset = coffs[i+BESTSAMPLE]; - - /* Compute the dispersion as the difference between the - * lowest and highest offsets that remain in the - * consideration list. - * - * It looks like MOST clocks have MOD (max error), so halve it ! - */ - tmp = coffs[noff-1]; - L_SUB(&tmp, &coffs[i]); -#define FRACT_SEC(n) ((1 << 30) / (n/2)) - dispersion = LFPTOFP(&tmp) / 2; /* ++++ */ - if (debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE)) syslog( - (debug & DB_SYSLOG_SMPLE) ? LOG_ERR : LOG_INFO, - "I: [%x] Offset=%06d (%d), disp=%06d%s [%d], %d %d=%d %d:%d %d=%d %d", - debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE), - offset.l_f / 4295, offset.l_f, - (dispersion * 1526) / 100, - (sloppyclockflag[ees->unit]) ? " by averaging" : "", - FRACT_SEC(10) / 4295, - (coffs[0].l_f) / 4295, - i, - (coffs[i].l_f) / 4295, - (coffs[samples/2].l_f) / 4295, - (coffs[i+BESTSAMPLE].l_f) / 4295, - noff-1, - (coffs[noff-1].l_f) / 4295, - (coffs[samples-1].l_f) / 4295); - - /* Are we playing silly wotsits ? - * If we are using all data, see if there is a "small" delta, - * and if so, blurr this with 3/4 of the delta from the last value - */ - if (ees->usealldata && ees->offset.l_uf) { - long diff = (long) (ees->offset.l_uf - offset.l_uf); - - /* is the delta small enough ? */ - if ((- FRACT_SEC(100)) < diff && diff < FRACT_SEC(100)) { - int samd = (64 * 4) / samples; - long new; - if (samd < 2) samd = 2; - new = offset.l_uf + ((diff * (samd -1)) / samd); - - /* Sign change -> need to fix up int part */ - if ((new & (1 << 31)) != - (((long) offset.l_uf) & ( 1 << 31))) - { syslog(LOG_INFO, "I: %x != %x (%x %x), so add %d", - new & (1 << 31), - ((long) offset.l_uf) & ( 1 << 31), - new, (long) offset.l_uf, - (new < 0) ? -1 : 1); - offset.l_ui += (new < 0) ? -1 : 1; - } - dispersion /= 4; - if (debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE)) syslog( - (debug & DB_SYSLOG_SMTHE) ? LOG_ERR : LOG_INFO, - "I: [%x] Smooth data: %d -> %d, dispersion now %d", - debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE), - ((long) offset.l_uf) / 4295, new / 4295, - (dispersion * 1526) / 100); - offset.l_uf = new; - } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) syslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, - "[%x] No smooth as delta not %d < %d < %d", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), - - FRACT_SEC(100), diff, FRACT_SEC(100)); - } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) syslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, - "I: [%x] No smooth as flag=%x and old=%x=%d (%d:%d)", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), - ees->usealldata, ees->offset.l_f, ees->offset.l_uf, - offset.l_f, ees->offset.l_f - offset.l_f); - - /* Collect offset info for debugging info */ - ees->offset = offset; - ees->lowoffset = coffs[i]; - ees->highoffset = coffs[noff-1]; - - /* Determine synchronization status. Can be unsync'd either - * by a report from the clock or by a leap hold. - * - * Loss of the radio signal for a short time does not cause - * us to go unsynchronised, since the receiver keeps quite - * good time on its own. The spec says 20ms in 4 hours; the - * observed drift in our clock (Cambridge) is about a second - * a day, but even that keeps us within the inherent tolerance - * of the clock for about 15 minutes. Observation shows that - * the typical "short" outage is 3 minutes, so to allow us - * to ride out those, we will give it 5 minutes. - */ - lostsync = current_time - ees->clocklastgood > 300 ? 1 : 0; - isinsync = (lostsync || ees->leaphold > current_time) ? 0 : 1; - - /* Done. Use time of last good, synchronised code as the - * reference time, and lastsampletime as the receive time. - */ - if (ees->fix_pending) { - syslog(LOG_ERR, "MSF%d: fix_pending=%d -> jump %x.%08x\n", - ees->fix_pending, ees->unit, offset.l_i, offset.l_f); - ees->fix_pending = 0; - set_x(&offset); - L_CLR(&offset); - } - refclock_receive(ees->peer, - &offset, - 0, /* delay */ - dispersion, - &ees->reftime, - &ees->lastsampletime, /* receive time */ - (isinsync) ? 0 : LEAP_NOTINSYNC); - ees_event(ees, lostsync ? CEVNT_PROP : CEVNT_NOMINAL); -} - -/* msfees_poll - called by the transmit procedure */ -static void msfees_poll(unit, peer) - int unit; - char *peer; -{ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d invalid", - unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d unused", - unit); - return; - } - - ees_process(eesunits[unit]); - - if ((current_time - eesunits[unit]->lasttime) > 150) - ees_event(eesunits[unit], CEVNT_FAULT); -} - -/* msfees_leap - called when a leap second occurs */ -static void msfees_leap() -{ - register int i; - - /* This routine should be entered a few seconds after - * midnight UTC when a leap second occurs. To ensure we - * don't believe foolish time from the clock(s) we set a - * 40 minute hold on them. It shouldn't take anywhere - * near this amount of time to adjust if the clock is getTING - * data, but doing anything else is complicated. - */ - for (i = 0; i < MAXUNITS; i++) if (unitinuse[i]) - eesunits[i]->leaphold = current_time + EESLEAPHOLD; -} - -/* msfees_control - set fudge factors, return statistics */ -static void msfees_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct eesunit *ees = eesunits[unit]; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit %d invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - os_delay[unit] = in->fudgetime2; - offset_fudge[unit] = os_delay[unit]; - L_ADD(&offset_fudge[unit], &fudgefactor[unit]); - L_ADD(&offset_fudge[unit], &inherent_delay[unit]); - if (in->haveflags & CLK_HAVEVAL1) { - stratumtouse[unit] = (u_char)(in->fudgeval1 & 0xf); - if (unitinuse[unit]) { - /* Should actually reselect clock, but - * will wait for the next timecode - */ - struct peer *peer = ees->peer; - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) { - memmove((char *)&peer->refid, - EESREFID, 4); - if (unit>0 && unit<10) - ((char *)&peer->refid)[3] = - '0' + unit; - } - else peer->refid = htonl(EESHSREFID); - } - } - if (in->haveflags & CLK_HAVEVAL2) { - printf("Debug: %x -> %x\n", debug, in->fudgeval2); - syslog(LOG_ERR, "MSF%d: debug %x -> %x", - unit, debug, in->fudgeval2); - debug = in->fudgeval2; - } - if (in->haveflags & CLK_HAVEFLAG1) { - sloppyclockflag[unit] = in->flags & CLK_FLAG1; - } - if (in->haveflags & CLK_HAVEFLAG2) { - ees->fix_pending++; - /* if (in->flags & CLK_FLAG2 && unitinuse[unit]) - ees->leaphold = 0; */ - } - if (in->haveflags & CLK_HAVEFLAG3 && unitinuse[unit]) { - printf("dump_vals: %x -> %x\n", ees->dump_vals, in->flags & CLK_FLAG3); - ees->dump_vals = in->flags & CLK_FLAG3; - } - if (in->haveflags & CLK_HAVEFLAG4 && unitinuse[unit]) { - ees->usealldata = in->flags & CLK_FLAG4; - } - } - - if (out != 0) { - out->type = REFCLK_MSF_EES; - out->haveflags - = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEVAL2|CLK_HAVEFLAG1|CLK_HAVEFLAG3|CLK_HAVEFLAG4; - out->clockdesc = EESDESCRIPTION; - out->fudgetime1 = fudgefactor[unit]; - out->fudgetime2 = os_delay[unit]; - out->fudgeval1 = stratumtouse[unit]; - /*out->fudgeval2= debug*/; - memmove((char *)&out->fudgeval2, EESREFID, 4); - if (unit > 0 && unit < 10) - ((char *)&out->fudgeval2)[3] = '0' + unit; - out->flags = sloppyclockflag[unit]; - if (unitinuse[unit]) { - out->flags |= ees->dump_vals | ees->usealldata; - out->lencode = ees->lencode; - out->lastcode = ees->lastcode; - out->timereset = current_time - ees->timestarted; - out->polls = 0; /* we don't poll */ - out->noresponse = 0; /* ditto */ - out->badformat = ees->badformat; - out->baddata = ees->baddata; - out->lastevent = ees->lastevent; - out->currentstatus = ees->status; - } else { - out->lencode = 0; - out->lastcode = ""; - out->polls = out->noresponse = 0; - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; - } - } -} - - -/* msfees_buginfo - return clock dependent debugging info */ -static void msfees_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct eesunit *ees; - - bug->nvalues = bug->ntimes = 0; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit %d invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - if (!unitinuse[unit]) - return; - ees = eesunits[unit]; - - bug->nvalues = 16; - bug->svalues = 0x0800; - bug->values[0] = (ees->lasttime) ? current_time - ees->lasttime : 0; - bug->values[1] = (ees->clocklastgood)?current_time-ees->clocklastgood:0; - bug->values[2] = ees->status; - bug->values[3] = ees->lastevent; - bug->values[4] = ees->reason; - bug->values[5] = ees->nsamples; - bug->values[6] = ees->codestate; - bug->values[7] = ees->day; - bug->values[8] = ees->hour; - bug->values[9] = ees->minute; - bug->values[10] = ees->second; - bug->values[11] = ees->tz; - bug->values[12] = ees->yearstart; - bug->values[13] = (ees->leaphold > current_time) ? - ees->leaphold - current_time : 0; - bug->values[14] = inherent_delay[unit].l_uf; - bug->values[15] = offset_fudge[unit].l_uf; - - bug->ntimes = 11; - bug->stimes = 0x3f8; - bug->times[0] = ees->reftime; - bug->times[1] = ees->arrvtime; - bug->times[2] = ees->lastsampletime; - bug->times[3] = ees->offset; - bug->times[4] = ees->lowoffset; - bug->times[5] = ees->highoffset; - bug->times[6] = inherent_delay[unit]; - bug->times[8] = os_delay[unit]; - bug->times[7] = fudgefactor[unit]; - bug->times[9] = offset_fudge[unit]; - bug->times[10].l_ui = ees->yearstart; - bug->times[10].l_uf = 0; -} - -struct refclock refclock_msfees = { - msfees_start, msfees_shutdown, msfees_poll, - msfees_control, msfees_init, msfees_buginfo, NOFLAGS -}; -#endif /* defined(REFCLOCK) && defined(MSFEESPPS) && defined(STREAM) */ diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_mx4200.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_mx4200.c deleted file mode 100644 index caf5951c55ed..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_mx4200.c +++ /dev/null @@ -1,977 +0,0 @@ -/* - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66. - * - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * 4. The name of the University may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(REFCLOCK) && defined(MX4200) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_calendar.h" -#include "ntp_unixtime.h" - -#if __STDC__ -#include -#else -#include -#endif - -#include - -#include "mx4200.h" -#include "ntp_stdlib.h" - -/* - * This driver supports the Magnavox Model MX4200 GPS Receiver. - */ - -/* - * Definitions - */ -#define MAXUNITS 2 /* max number of mx4200 units */ -#define MX4200FD "/dev/gps%d" -#define SPEED232 B4800 /* baud */ - -/* - * The number of raw samples which we acquire to derive a single estimate. - */ -#define NSTMPS 64 - -/* - * Radio interface parameters - */ -#define MX4200PRECISION (-18) /* precision assumed (about 4 us) */ -#define MX4200REFID "GPS" /* reference id */ -#define MX4200DESCRIPTION "Magnavox MX4200 GPS Receiver" /* WRU */ -#define DEFFUDGETIME 0 /* default fudge time (ms) */ - -/* Leap stuff */ -extern u_long leap_hoursfromleap; -extern u_long leap_happened; -static int leap_debug; - -/* - * mx4200_reset - reset the count back to zero - */ -#define mx4200_reset(up) \ - do { \ - (up)->nsamples = 0; \ - } while (0) - -/* - * Imported from the timer module - */ -extern u_long current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * MX4200 unit control structure. - */ -struct mx4200unit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - u_long gpssamples[NSTMPS]; /* the GPS time samples */ - l_fp unixsamples[NSTMPS]; /* the UNIX time samples */ - - - l_fp lastsampletime; /* time of last estimate */ - u_int lastserial; /* last pps serial number */ -#ifdef notdef - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ -#endif - char lastcode[RX_BUFF_SIZE]; /* last timecode received */ - u_long lasttime; /* last time clock heard from */ - u_char nsamples; /* number of samples we've collected */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char lencode; /* length of last timecode */ - u_char year; /* year of eternity */ - u_short monthday; /* day of month */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - /* - * Status tallies - */ -#ifdef notdef - u_long polls; /* polls sent */ - u_long noresponse; /* number of nonresponses */ -#endif - u_long badformat; /* bad format */ - u_long baddata; /* bad data */ - u_long timestarted; /* time we started this */ -}; - -/* - * We demand that consecutive PPS samples are more than 0.995 seconds - * and less than 1.005 seconds apart. - */ -#define PPSLODIFF_UI 0 /* 0.900 as an l_fp */ -#define PPSLODIFF_UF 0xe6666610 - -#define PPSHIDIFF_UI 1 /* 1.100 as an l_fp */ -#define PPSHIDIFF_UF 0x19999990 - -/* - * reason codes - */ -#define PPSREASON 20 -#define CODEREASON 40 -#define PROCREASON 60 - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct mx4200unit *mx4200units[MAXUNITS]; - -static const char pmvxg[] = "PMVXG"; - -/* - * Function prototypes - */ -static int mx4200_start P((int, struct peer *)); -static void mx4200_shutdown P((int, struct peer *)); -static void mx4200_receive P((struct recvbuf *)); -static void mx4200_process P((struct mx4200unit *)); -static void mx4200_poll P((int, struct peer *)); - -static char * mx4200_parse P((char *, struct calendar *, int *, int *)); -static int mx4200_needconf P((char *)); -static void mx4200_config P((struct mx4200unit *)); -static void mx4200_send P((int, const char *, ...)); -static int mx4200_cmpl_fp P((void *, void *)); -static u_char cksum P((char *, u_int)); - -#ifdef DEBUG -static void opendfile P((int)); -static void checkdfile P((void)); -#endif /* DEBUG */ - -/* - * Transfer vector - */ -struct refclock refclock_mx4200 = { - mx4200_start, /* start up driver */ - mx4200_shutdown, /* shut down driver */ - mx4200_poll, /* transmit poll message */ - noentry, /* not used (old mx4200_control) */ - noentry, /* initialize driver (not used) */ - noentry, /* not used (old mx4200_buginfo) */ - NOFLAGS /* not used */ -}; - -#ifdef DEBUG -static char dfile[] = "/var/tmp/MX4200.debug"; -static FILE *df = NULL; - -static void -opendfile(create) - int create; -{ - if (!create && access(dfile, F_OK) < 0) { - syslog(LOG_ERR, "mx4200: open %s: %m", dfile); - return; - } - df = fopen(dfile, "a"); - if (df == NULL) - syslog(LOG_ERR, "mx4200: open %s: %m", dfile); - else if (setvbuf(df, NULL, _IOLBF, 0) < 0) - syslog(LOG_ERR, "mx4200: setvbuf %s: %m", dfile); -} - -static void -checkdfile() -{ - - if (df == NULL) - return; - - if (access(dfile, F_OK) < 0) { - fclose(df); - opendfile(1); - } -} - -#endif - - -/* - * mx4200_start - open the devices and initialize data for processing - */ -static int -mx4200_start(unit, peer) - int unit; - struct peer *peer; -{ - register struct mx4200unit *up; - struct refclockproc *pp; - int fd; - char device[20]; - - /* - * Open serial port - */ - (void)sprintf(device, MX4200FD, unit); - if (!(fd = refclock_open(device, SPEED232, 0))) - return (0); - - /* - * Allocate and initialize unit structure - */ - if (!(up = (struct mx4200unit *) - emalloc(sizeof(struct mx4200unit)))) { - (void) close(fd); - return (0); - } - memset((char *)up, 0, sizeof(struct mx4200unit)); - up->io.clock_recv = mx4200_receive; - up->io.srcclock = (caddr_t)up; - up->io.datalen = 0; - up->io.fd = fd; - if (!io_addclock(&up->io)) { - (void) close(fd); - free(up); - return (0); - } - up->peer = peer; - pp = peer->procptr; - pp->unitptr = (caddr_t)up; - - /* - * Initialize miscellaneous variables - */ - peer->precision = MX4200PRECISION; - pp->clockdesc = MX4200DESCRIPTION; - memcpy((char *)&pp->refid, MX4200REFID, 4); - - /* Insure the receiver is properly configured */ - mx4200_config(up); - -#ifdef DEBUG - opendfile(0); -#endif - return (1); -} - - -/* - * mx4200_shutdown - shut down the clock - */ -static void -mx4200_shutdown(unit, peer) - int unit; - struct peer *peer; -{ - register struct mx4200unit *up; - struct refclockproc *pp; - - pp = peer->procptr; - up = (struct mx4200unit *)pp->unitptr; - io_closeclock(&up->io); - free(up); -} - - -static void -mx4200_config(up) - register struct mx4200unit *up; -{ - register int fd = up->io.fd; - -syslog(LOG_DEBUG, "mx4200_config"); - - /* Zero the output list (do it twice to flush possible junk) */ - mx4200_send(fd, "%s,%03d,,%d,,,,,,", pmvxg, PMVXG_S_PORTCONF, 1); - mx4200_send(fd, "%s,%03d,,%d,,,,,,", pmvxg, PMVXG_S_PORTCONF, 1); - - /* Switch to 2d mode */ - mx4200_send(fd, "%s,%03d,%d,,%.1f,%.1f,,%d,%d,%c,%d", - pmvxg, PMVXG_S_INITMODEB, - 2, /* 2d mode */ - 0.1, /* hor accel fact as per Steve */ - 0.1, /* ver accel fact as per Steve */ - 10, /* hdop limit as per Steve */ - 5, /* elevation limit as per Steve */ - 'U', /* time output mode */ - 0); /* local time offset from gmt */ - - /* Configure time recovery */ - mx4200_send(fd, "%s,%03d,%c,%c,%c,%d,%d,%d,", - pmvxg, PMVXG_S_TRECOVCONF, -#ifdef notdef - 'K', /* known position */ - 'D', /* dynamic position */ -#else - 'S', /* static position */ -#endif - 'U', /* steer clock to gps time */ - 'A', /* always output time pulse */ - 500, /* max time error in ns */ - 0, /* user bias in ns */ - 1); /* output to control port */ -} - - -/* - * mx4200_poll - mx4200 watchdog routine - */ -static void -mx4200_poll(unit, peer) - int unit; - struct peer *peer; -{ - register struct mx4200unit *up; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_poll: unit %d invalid", unit); - return; - } - - up = mx4200units[unit]; - if ((current_time - up->lasttime) > 150) { - refclock_report(peer, CEVNT_FAULT); - - /* Request a status message which should trigger a reconfig */ - mx4200_send(up->io.fd, "%s,%03d", "CDGPQ", PMVXG_D_STATUS); - syslog(LOG_DEBUG, "mx4200_poll: request status"); - } -} - -static const char char2hex[] = "0123456789ABCDEF"; - - -/* - * mx4200_receive - receive gps data - */ -static void -mx4200_receive(rbufp) - struct recvbuf *rbufp; -{ - register struct mx4200unit *up; - struct peer *peer; - register char *dpt, *cp; - register u_long tmp_ui; - register u_long tmp_uf; - register u_long gpstime; - struct ppsclockev ev; - register struct calendar *jt; - struct calendar sjt; - register int n; - int valid, leapsec; - register u_char ck; - - up = (struct mx4200unit *)rbufp->recv_srcclock; - peer = up->peer; -#ifdef DEBUG - if (debug > 3) - printf("mx4200_receive: nsamples = %d\n", up->nsamples); -#endif - - /* Record the time of this event */ - up->lasttime = current_time; - - /* Get the pps value */ - if (ioctl(up->io.fd, CIOGETEV, (char *)&ev) < 0) { - /* XXX Actually, if this fails, we're pretty much screwed */ -#ifdef DEBUG - if (debug) { - fprintf(stderr, "mx4200_receive: "); - perror("CIOGETEV"); - } -#endif - refclock_report(peer, CEVNT_FAULT); - mx4200_reset(up); - return; - } - tmp_ui = ev.tv.tv_sec + JAN_1970; - TVUTOTSF(ev.tv.tv_usec, tmp_uf); - - /* Get buffer and length; sock away last timecode */ - n = rbufp->recv_length; - dpt = rbufp->recv_buffer; - if (n <= 1) - return; - up->lencode = n; - memmove(up->lastcode, dpt, n); - - /* - * We expect to see something like: - * - * $PMVXG,830,T,1992,07,09,04:18:34,U,S,-02154,00019,000000,00*1D\n - * - * Reject if any important landmarks are missing. - */ - cp = dpt + n - 4; - if (cp < dpt || *dpt != '$' || cp[0] != '*' || cp[3] != '\n') { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad format\n"); -#endif - refclock_report(peer, CEVNT_BADREPLY); - mx4200_reset(up); - return; - } - - /* Check checksum */ - ck = cksum(&dpt[1], n - 5); - if (char2hex[ck >> 4] != cp[1] || char2hex[ck & 0xf] != cp[2]) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad checksum\n"); -#endif - refclock_report(peer, CEVNT_BADREPLY); - mx4200_reset(up); - return; - } - - /* Truncate checksum (and the buffer for that matter) */ - *cp = '\0'; - - /* Leap second debugging stuff */ - if ((leap_hoursfromleap && !leap_happened) || leap_debug > 0) { - /* generate reports for awhile after leap */ - if (leap_hoursfromleap && !leap_happened) - leap_debug = 3600; - else - --leap_debug; - syslog(LOG_INFO, "mx4200 leap: %s \"%s\"", - umfptoa(tmp_ui, tmp_uf, 6), dpt); - } - - /* Parse time recovery message */ - jt = &sjt; - if ((cp = mx4200_parse(dpt, jt, &valid, &leapsec)) != NULL) { - /* Configure the receiver if necessary */ - if (mx4200_needconf(dpt)) - mx4200_config(up); -#ifdef DEBUG - if (debug) - printf("mx4200_receive: mx4200_parse: %s\n", cp); -#endif - refclock_report(peer, CEVNT_BADREPLY); - mx4200_reset(up); - return; - } - - /* Setup leap second indicator */ - if (leapsec == 0) - up->leap = LEAP_NOWARNING; - else if (leapsec == 1) - up->leap = LEAP_ADDSECOND; - else if (leapsec == -1) - up->leap = LEAP_DELSECOND; - else - up->leap = LEAP_NOTINSYNC; /* shouldn't happen */ - - /* Check parsed time (allow for possible leap seconds) */ - if (jt->second >= 61 || jt->minute >= 60 || jt->hour >= 24) { -#ifdef DEBUG - if (debug) { - printf("mx4200_receive: bad time %d:%02d:%02d", - jt->hour, jt->minute, jt->second); - if (leapsec != 0) - printf(" (leap %+d)", leapsec); - putchar('\n'); - } -#endif - refclock_report(peer, CEVNT_BADTIME); - mx4200_reset(up); - /* Eat the next pulse which the clock claims will be bad */ - up->nsamples = -1; - return; - } - - /* Check parsed date */ - if (jt->monthday > 31 || jt->month > 12 || jt->year < 1900) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad date (%d/%d/%d)\n", - jt->monthday, jt->month, jt->year); -#endif - refclock_report(peer, CEVNT_BADDATE); - mx4200_reset(up); - return; - } - - /* Convert to ntp time */ - gpstime = caltontp(jt); - - /* The gps message describes the *next* pulse; pretend it's this one */ - --gpstime; - - /* Debugging */ -#ifdef DEBUG - checkdfile(); - if (df != NULL) { - l_fp t; - - t.l_ui = gpstime; - t.l_uf = 0; - M_SUB(t.l_ui, t.l_uf, tmp_ui, tmp_uf); - fprintf(df, "%s\t%s", - umfptoa(tmp_ui, tmp_uf, 6), mfptoa(t.l_ui, t.l_uf, 6)); - if (debug > 3) - fprintf(df, "\t(gps: %lu)", gpstime); - if (leapsec != 0) - fprintf(df, "\t(leap sec %+d)", leapsec); - if (!valid) - fprintf(df, "\t(pulse not valid)"); - fputc('\n', df); - } -#endif - - /* Check pps serial number against last one */ - if (up->lastserial + 1 != ev.serial && up->lastserial != 0) { -#ifdef DEBUG - if (debug) { - if (ev.serial == up->lastserial) - printf("mx4200_receive: no new pps event\n"); - else - printf("mx4200_receive: missed %d pps events\n", - ev.serial - up->lastserial - 1); - } -#endif - refclock_report(peer, CEVNT_FAULT); - mx4200_reset(up); - /* fall through and this one collect as first sample */ - } - up->lastserial = ev.serial; - -/* - * XXX - * Since this message is for the next pulse, it's really the next pulse - * that the clock might be telling us will be invalid. - */ - /* Toss if not designated "valid" by the gps */ - if (!valid) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: pps not valid\n"); -#endif - refclock_report(peer, CEVNT_BADTIME); - mx4200_reset(up); - return; - } - - /* Copy time into mx4200unit struct */ - /* XXX (why?) */ - up->year = jt->year; - up->monthday = jt->monthday; - up->hour = jt->hour; - up->minute = jt->minute; - up->second = jt->second; - - /* Sock away the GPS and UNIX timesamples */ - n = up->nsamples++; - if (n < 0) - return; /* oops, this pulse is bad */ - up->gpssamples[n] = gpstime; - up->unixsamples[n].l_ui = up->lastsampletime.l_ui = tmp_ui; - up->unixsamples[n].l_uf = up->lastsampletime.l_uf = tmp_uf; - if (up->nsamples >= NSTMPS) { - /* - * Here we've managed to complete an entire NSTMPS - * second cycle without major mishap. Process what has - * been received. - */ - mx4200_process(up); - mx4200_reset(up); - } -} - -/* - * Compare two l_fp's, used with qsort() - */ -static int -mx4200_cmpl_fp(p1, p2) - register void *p1, *p2; -{ - - if (!L_ISGEQ((l_fp *)p1, (l_fp *)p2)) - return (-1); - if (L_ISEQU((l_fp *)p1, (l_fp *)p2)) - return (0); - return (1); -} - -/* - * mx4200_process - process a pile of samples from the clock - */ -static void -mx4200_process(up) - struct mx4200unit *up; -{ - struct peer *peer; - struct refclockproc *pp; - register int i, n; - register l_fp *fp, *op; - register u_long *lp; - l_fp off[NSTMPS]; - register u_long tmp_ui, tmp_uf; - register u_long date_ui, date_uf; - u_fp dispersion; - - /* Compute offsets from the raw data. */ - peer = up->peer; - pp = peer->procptr; - fp = up->unixsamples; - op = off; - lp = up->gpssamples; - for (i = 0; i < NSTMPS; ++i, ++lp, ++op, ++fp) { - op->l_ui = *lp; - op->l_uf = 0; - L_SUB(op, fp); - } - - /* Sort offsets into ascending order. */ - qsort((char *)off, NSTMPS, sizeof(l_fp), mx4200_cmpl_fp); - - /* - * Reject the furthest from the median until 8 samples left - */ - i = 0; - n = NSTMPS; - while ((n - i) > 8) { - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - date_ui = off[(n+i)/2].l_ui; - date_uf = off[(n+i)/2].l_uf; - M_SUB(tmp_ui, tmp_uf, date_ui, date_uf); - M_SUB(date_ui, date_uf, off[i].l_ui, off[i].l_uf); - if (M_ISHIS(date_ui, date_uf, tmp_ui, tmp_uf)) { - /* - * reject low end - */ - i++; - } else { - /* - * reject high end - */ - n--; - } - } - - /* - * Compute the dispersion based on the difference between the - * extremes of the remaining offsets. - */ - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - M_SUB(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - dispersion = MFPTOFP(tmp_ui, tmp_uf); - - /* - * Now compute the offset estimate. If the sloppy clock - * flag is set, average the remainder, otherwise pick the - * median. - */ - if (pp->sloppyclockflag) { - tmp_ui = tmp_uf = 0; - while (i < n) { - M_ADD(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - i++; - } - M_RSHIFT(tmp_ui, tmp_uf); - M_RSHIFT(tmp_ui, tmp_uf); - M_RSHIFT(tmp_ui, tmp_uf); - i = 0; - off[0].l_ui = tmp_ui; - off[0].l_uf = tmp_uf; - } else { - i = (n + i) / 2; - } - - /* - * Add the default MX4200 QT delay into this. - */ -#ifdef notdef - L_ADDUF(&off[i], MX4200QTFUDGE); -#endif - - /* - * Done. Use lastref as the reference time and lastrec - * as the receive time. ** note this can result in tossing - * out the peer in the protocol module if lastref > lastrec, - * so last rec is used for both values - dlm *** - */ - refclock_receive(up->peer, &off[i], - (s_fp)0, /* delay */ - dispersion, - &up->unixsamples[NSTMPS-1], /* reftime */ - &up->unixsamples[NSTMPS-1], /* rectime */ - up->leap); - - refclock_report(peer, CEVNT_NOMINAL); -} - - -/* - * Returns true if the this is a status message. We use this as - * an indication that the receiver needs to be initialized. - */ -static int -mx4200_needconf(buf) - char *buf; -{ - register long v; - char *cp; - - cp = buf; - - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Record type */ - v = strtol(cp, &cp, 10); - if (v != PMVXG_D_STATUS) - return (0); - /* - * XXX - * Since we configure the receiver to not give us status - * messages and since the receiver outputs status messages by - * default after being reset to factory defaults when sent the - * "$PMVXG,018,C\r\n" message, any status message we get - * indicates the reciever needs to be initialized; thus, it is - * not necessary to decode the status message. - */ -#ifdef notdef - ++cp; - - /* Receiver status */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Number of satellites which should be visible */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Number of satellites being tracked */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Time since last NAV */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Initialization status */ - v = strtol(cp, &cp, 10); - if (v == 0) -#endif - return (1); -} - -/* Parse a mx4200 time recovery message. Returns a string if error */ -static char * -mx4200_parse(buf, jt, validp, leapsecp) - register char *buf; - register struct calendar *jt; - register int *validp, *leapsecp; -{ - register long v; - char *cp; - - cp = buf; - memset((char *)jt, 0, sizeof(*jt)); - - if ((cp = strchr(cp, ',')) == NULL) - return ("no rec-type"); - ++cp; - - /* Record type */ - v = strtol(cp, &cp, 10); - if (v != PMVXG_D_TRECOVOUT) - return ("wrong rec-type"); - - /* Pulse valid indicator */ - if (*cp++ != ',') - return ("no pulse-valid"); - if (*cp == 'T') - *validp = 1; - else if (*cp == 'F') - *validp = 0; - else - return ("bad pulse-valid"); - ++cp; - - /* Year */ - if (*cp++ != ',') - return ("no year"); - jt->year = strtol(cp, &cp, 10); - - /* Month of year */ - if (*cp++ != ',') - return ("no month"); - jt->month = strtol(cp, &cp, 10); - - /* Day of month */ - if (*cp++ != ',') - return ("no month day"); - jt->monthday = strtol(cp, &cp, 10); - - /* Hour */ - if (*cp++ != ',') - return ("no hour"); - jt->hour = strtol(cp, &cp, 10); - - /* Minute */ - if (*cp++ != ':') - return ("no minute"); - jt->minute = strtol(cp, &cp, 10); - - /* Second */ - if (*cp++ != ':') - return ("no second"); - jt->second = strtol(cp, &cp, 10); - - /* Time indicator */ - if (*cp++ != ',' || *cp++ == '\0') - return ("no time indicator"); - - /* Time recovery mode */ - if (*cp++ != ',' || *cp++ == '\0') - return ("no time mode"); - - /* Oscillator offset */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no osc off"); - ++cp; - - /* Time mark error */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no time mark err"); - ++cp; - - /* User time bias */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no user bias"); - ++cp; - - /* Leap second flag */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no leap"); - ++cp; - *leapsecp = strtol(cp, &cp, 10); - - return (NULL); -} - -/* Calculate the checksum */ -static u_char -cksum(cp, n) - register char *cp; - register u_int n; -{ - register u_char ck; - - for (ck = 0; n-- > 0; ++cp) - ck ^= *cp; - return (ck); -} - -static void -#if __STDC__ -mx4200_send(register int fd, const char *fmt, ...) -#else -mx4200_send(fd, fmt, va_alist) - register int fd; - const char *fmt; - va_dcl -#endif -{ - register char *cp; - register int n, m; - va_list ap; - char buf[1024]; - u_char ck; - -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - cp = buf; - *cp++ = '$'; -#ifdef notdef - /* BSD is rational */ - n = vsnprintf(cp, sizeof(buf) - 1, fmt, ap); -#else - /* SunOS sucks */ - (void)vsprintf(cp, fmt, ap); - n = strlen(cp); -#endif - ck = cksum(cp, n); - cp += n; - ++n; -#ifdef notdef - /* BSD is rational */ - n += snprintf(cp, sizeof(buf) - n - 5, "*%02X\r\n", ck); -#else - /* SunOS sucks */ - sprintf(cp, "*%02X\r\n", ck); - n += strlen(cp); -#endif - - m = write(fd, buf, n); - if (m < 0) - syslog(LOG_ERR, "mx4200_send: write: %m (%s)", buf); - else if (m != n) - syslog(LOG_ERR, "mx4200_send: write: %d != %d (%s)", m, n, buf); - va_end(ap); -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c deleted file mode 100644 index e62b668956f3..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c +++ /dev/null @@ -1,999 +0,0 @@ -/* - * refclock_omega - clock driver for the Kinemetrics Truetime OM-DC OMEGA - * receiver. - * - * Version 1.0 11-Dec-92 Steve Clift (clift@ml.csiro.au) - * Initial version, mostly lifted from refclock_goes.c. - * - * 1.1 03-May-93 Steve Clift - * Tarted up the sample filtering mechanism to give improved - * one-off measurements. Improved measurement dispersion code - * to account for accumulated drift when the clock loses lock. - * - */ - -#if defined(REFCLOCK) && (defined(OMEGA) || defined(OMEGACLK) || defined(OMEGAPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#if defined(STREAM) -#include -#if defined(OMEGACLK) -#include -#endif /* OMEGACLK */ -#endif /* STREAM */ - -#if defined (OMEGAPPS) -#include -#endif /* OMEGAPPS */ - -#include "ntp_stdlib.h" - -/* - * Support for Kinemetrics Truetime OM-DC OMEGA Receiver - * - * Most of this code is copied from refclock_goes.c with thanks. - * - * the time code looks like follows; Send the clock a R or C and once per - * second a timestamp will appear that looks like this: - * ADDD:HH:MM:SSQCL - * A - control A - * Q Quality indication: indicates possible error of - * > >+- 5 seconds - * ? >+/- 500 milliseconds # >+/- 50 milliseconds - * * >+/- 5 milliseconds . >+/- 1 millisecond - * A-H less than 1 millisecond. Character indicates which station - * is being received as follows: - * A = Norway, B = Liberia, C = Hawaii, D = North Dakota, - * E = La Reunion, F = Argentina, G = Australia, H = Japan. - * C - Carriage return - * L - Line feed - * The carriage return start bit begins on 0 seconds and extends to 1 bit time. - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* max number of OMEGA units */ -#define OMEGA232 "/dev/omega%d" -#define SPEED232 B9600 /* 9600 baud */ - -/* - * Radio interface parameters - */ -#define OMEGADESCRIPTION "Kinemetrics OM-DC OMEGA Receiver" /* who we are */ -#define OMEGAMAXDISPERSE (FP_SECOND/32) /* max allowed sample dispersion */ -#define OMEGAPRECISION (-10) /* precision assumed (about 1 ms) */ -#define OMEGAREFID "VLF\0" /* reference id */ -#define LENOMEGA 13 /* length of standard response */ -#define GMT 0 /* hour offset from Greenwich */ -#define NSTAMPS 9 /* samples collected when polled */ -#define NSKEEP 5 /* samples to keep after discards */ -#define BMAX 50 /* timecode buffer length */ - -/* - * The OM-DC puts out the start bit of the on the second, but - * we see the result after the is received, about 2ms later at - * 9600 baud. Use this as the default fudge time, and let the user - * fiddle it to account for driver latency etc. - */ -#define DEFFUDGETIME 0x00830000 /* default fudge time (~2ms) */ - -/* - * Clock drift errors as u_fp values. - */ -#define U_FP5000MS (5*FP_SECOND) /* 5 seconds */ -#define U_FP500MS (FP_SECOND/2) /* 500 msec */ -#define U_FP50MS (FP_SECOND/20) /* 50 msec */ -#define U_FP5MS (FP_SECOND/200) /* 5 msec */ - -/* - * Station codes - */ -#define STATION_NONE 0 -#define STATION_NORWAY 1 -#define STATION_LIBERIA 2 -#define STATION_HAWAII 3 -#define STATION_N_DAKOTA 4 -#define STATION_LA_REUNION 5 -#define STATION_ARGENTINA 6 -#define STATION_AUSTRALIA 7 -#define STATION_JAPAN 8 - -/* - * Hack to avoid excercising the multiplier. I have no pride. - */ -#define MULBY10(x) (((x)<<3) + ((x)<<1)) - -/* - * Imported from the timer module - */ -extern u_long current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * OMEGA unit control structure - */ -struct omegaunit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ - l_fp offset[NSTAMPS]; /* recent sample offsets */ - char lastcode[BMAX]; /* last timecode received */ - u_short station; /* which station we're locked to */ - u_short polled; /* Hand in a time sample? */ - u_long coderecv; /* timecodes received */ - u_char lencode; /* length of last timecode */ - u_long lasttime; /* last time clock heard from */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last failure */ - u_char year; /* year of eternity */ - u_short day; /* day of year */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - u_short msec; /* millisecond of second */ - u_char quality; /* quality char from last timecode */ - u_long yearstart; /* start of current year */ - /* - * Status tallies - */ - u_long polls; /* polls sent */ - u_long noreply; /* no replies to polls */ - u_long badformat; /* bad format */ - u_long baddata; /* bad data */ - u_long timestarted; /* time we started this */ -}; - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct omegaunit *omegaunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor1[MAXUNITS]; -static l_fp fudgefactor2[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char readonlyclockflag[MAXUNITS]; -static u_long refid[MAXUNITS]; - -/* - * Function prototypes - */ -static void omega_init P((void)); -static int omega_start P((u_int, struct peer *)); -static void omega_shutdown P((int)); -static void omega_report_event P((struct omegaunit *, int)); -static void omega_receive P((struct recvbuf *)); -static char omega_process P((struct omegaunit *, l_fp *, u_fp *)); -static void omega_poll P((int, struct peer *)); -static void omega_control P((u_int, struct refclockstat *, struct refclockstat *)); -static void omega_buginfo P((int, struct refclockbug *)); -static void omega_send P((struct omegaunit *, char *)); - -/* - * Transfer vector - */ -struct refclock refclock_omega = { - omega_start, omega_shutdown, omega_poll, - omega_control, omega_init, omega_buginfo, NOFLAGS -}; - -/* - * omega_init - initialize internal omega driver data - */ -static void -omega_init() -{ - register int i; - /* - * Just zero the data arrays - */ - memset((char *)omegaunits, 0, sizeof omegaunits); - memset((char *)unitinuse, 0, sizeof unitinuse); - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor1[i].l_ui = 0; - fudgefactor1[i].l_uf = DEFFUDGETIME; - fudgefactor2[i].l_ui = 0; - fudgefactor2[i].l_uf = 0; - stratumtouse[i] = 0; - readonlyclockflag[i] = 0; - memcpy((char *)&refid[i], OMEGAREFID, 4); - } -} - - -/* - * omega_start - open the OMEGA devices and initialize data for processing - */ -static int -omega_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct omegaunit *omega; - register int i; - int fd232; - char omegadev[20]; - - /* - * Check configuration info - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR,"omega_start: unit %d invalid", unit); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "omega_start: unit %d in use", unit); - return 0; - } - - /* - * Open serial port - */ - (void) sprintf(omegadev, OMEGA232, unit); - fd232 = open(omegadev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "omega_start: open of %s: %m", omegadev); - return 0; - } - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TCGETA): %m", omegadev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TCSETA): %m", omegadev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The OMEGACLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The OMEGAPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "omega_start: tcgetattr(%s): %m", omegadev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "omega_start: tcsetattr(%s): %m", omegadev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "omega_start: tcflush(%s): %m", omegadev); - goto screwed; - } - } -#endif /* HAVE_TERMIOS */ -#ifdef STREAM -#if defined(OMEGACLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, I_PUSH, clk): %m", omegadev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, CLK_SETSTR): %m", omegadev); -#endif /* OMEGACLK */ -#if defined(OMEGAPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, I_PUSH, ppsclock): %m", omegadev); - else - fdpps = fd232; -#endif /* OMEGAPPS */ -#endif /* STREAM */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The OMEGACLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(OMEGACLK) - int ldisc = CLKLDISC; -#endif /* OMEGACLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCGETP): %m", omegadev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(OMEGACLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* OMEGACLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCSETP): %m", omegadev); - goto screwed; - } -#if defined(OMEGACLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCSETD): %m",omegadev); - goto screwed; - } -#endif /* OMEGACLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Allocate unit structure - */ - if (omegaunits[unit] != 0) { - omega = omegaunits[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && omegaunits[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - omega = omegaunits[i]; - omegaunits[i] = 0; - } else { - omega = (struct omegaunit *) - emalloc(sizeof(struct omegaunit)); - } - } - memset((char *)omega, 0, sizeof(struct omegaunit)); - omegaunits[unit] = omega; - - /* - * Set up the structures - */ - omega->peer = peer; - omega->unit = (u_char)unit; - omega->timestarted = current_time; - omega->station = STATION_NONE; - - omega->io.clock_recv = omega_receive; - omega->io.srcclock = (caddr_t)omega; - omega->io.datalen = 0; - omega->io.fd = fd232; - if (!io_addclock(&omega->io)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. - */ - peer->precision = OMEGAPRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - return 1; - - /* - * Something broke; abandon ship - */ -screwed: - (void) close(fd232); - return 0; -} - - -/* - * omega_shutdown - shut down a OMEGA clock - */ -static void -omega_shutdown(unit) - int unit; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_shutdown: unit %d invalid", - unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "omega_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - omega = omegaunits[unit]; - io_closeclock(&omega->io); - unitinuse[unit] = 0; -} - - -/* - * omega_report_event - note the occurance of an event - */ -static void -omega_report_event(omega, code) - struct omegaunit *omega; - int code; -{ - struct peer *peer; - - peer = omega->peer; - if (omega->status != (u_char)code) { - omega->status = (u_char)code; - if (code != CEVNT_NOMINAL) - omega->lastevent = (u_char)code; - syslog(LOG_INFO, - "omega clock %s event %x\n", ntoa(&peer->srcadr), code); - } -} - - -/* - * omega_receive - receive data from the serial interface on a - * Kinemetrics OM-DC OMEGA clock. - */ -static void -omega_receive(rbufp) - struct recvbuf *rbufp; -{ - register int i; - register struct omegaunit *omega; - register u_char *dpt; - register char *cp, *cpend; - register u_char *dpend; - l_fp tstmp; - u_fp dispersion, drift; - - /* - * Get the clock this applies to and a pointers to the data - */ - omega = (struct omegaunit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - -#ifndef PEDANTIC - /* - * The OM-DC outputs a timecode every second, but we only want - * a set of NSTAMPS timecodes when polled (every 64 seconds). - * Setting PEDANTIC causes a sanity check on every timecode. - */ - if (!omega->polled) - return; -#endif - - /* - * Edit timecode to remove control chars - */ - dpend = dpt + rbufp->recv_length; - cp = omega->lastcode; - cpend = omega->lastcode + BMAX - 1; - while (dpt < dpend && cp < cpend) { - if ((*cp = 0x7f & *dpt++) >= ' ') cp++; -#ifdef OMEGACLK - else if (*cp == '\r') { - if (dpend - dpt < 8) { - /* short timestamp */ - return; - } - if (!buftvtots(dpt,&omega->lastrec)) { - /* screwy timestamp */ - return; - } - dpt += 8; - } -#endif - } - *cp = '\0'; - omega->lencode = cp - omega->lastcode; - - if (omega->lencode == 0) - return; - else if (omega->lencode != LENOMEGA) { - omega->badformat++; - /* Sometimes get a lot of these, filling the log with noise */ - /* omega_report_event(omega, CEVNT_BADREPLY); */ - return; - } - -#ifndef OMEGACLK - omega->lastrec = rbufp->recv_time; -#endif - -#ifdef DEBUG - if (debug) - printf("omega: timecode %d %s\n", - omega->lencode, omega->lastcode); -#endif - - /* - * We get down to business, check the timecode format - * and decode its contents. - */ - cp = omega->lastcode; - omega->leap = 0; - /* - * Check timecode format. - */ - if (!isdigit(cp[0]) || /* day of year */ - !isdigit(cp[1]) || - !isdigit(cp[2]) || - cp[3] != ':' || /* */ - !isdigit(cp[4]) || /* hours */ - !isdigit(cp[5]) || - cp[6] != ':' || /* : separator */ - !isdigit(cp[7]) || /* minutes */ - !isdigit(cp[8]) || - cp[9] != ':' || /* : separator */ - !isdigit(cp[10]) || /* seconds */ - !isdigit(cp[11])) { - omega->badformat++; - omega_report_event(omega, CEVNT_BADREPLY); - return; - } - - /* - * Convert and check values. - */ - omega->year = 0; /* fake */ - omega->day = cp[0] - '0'; - omega->day = MULBY10(omega->day) + cp[1] - '0'; - omega->day = MULBY10(omega->day) + cp[2] - '0'; - omega->hour = MULBY10(cp[4] - '0') + cp[5] - '0'; - omega->minute = MULBY10(cp[7] - '0') + cp[8] - '0'; - omega->second = MULBY10(cp[10] - '0') + cp[11] - '0'; - omega->msec = 0; - - if (omega->day < 1 || omega->day > 366) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADDATE); - return; - } - if (omega->hour > 23 || omega->minute > 59 || omega->second > 59) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - - /* - * Check quality/station-id flag. The OM-DC should normally stay - * permanently locked to a station, and its time error should be less - * than 1 msec. If it loses lock for any reason, it makes a worst - * case drift estimate based on the internally stored stability figure - * for its reference oscillator. The stability figure can be adjusted - * by the user based on experience. The default value is 1E05, which - * is pretty bad - 2E07 is about right for the unit I have. - * - * The following is arbitrary, change it if you're offended: - * For errors less than 50 msec, just clear the station indicator. - * For errors greater than 50 msec, flag loss of sync and report a - * propagation problem. If the error is greater than 500 msec, - * something is dreadfully wrong - report a clock fault. - * - * In each case, we set a drift estimate which is used below as an - * estimate of measurement accuracy. - */ - omega->quality = cp[12]; - if (cp[12] == '>' || cp[12] == '?') { - /* Error 500 to 5000 msec */ - omega_report_event(omega, CEVNT_FAULT); - omega->leap = LEAP_NOTINSYNC; - omega->station = STATION_NONE; - drift = U_FP5000MS; - } else if (cp[12] == '#') { - /* Error 50 to 500 msec */ - omega_report_event(omega, CEVNT_PROP); - omega->leap = LEAP_NOTINSYNC; - omega->station = STATION_NONE; - drift = U_FP500MS; - } else if (cp[12] == '*') { - /* Error 5 to 50 msec */ - omega->lasttime = current_time; - omega->station = STATION_NONE; - drift = U_FP50MS; - } else if (cp[12] == '.') { - /* Error 1 to 5 msec */ - omega->lasttime = current_time; - omega->station = STATION_NONE; - drift = U_FP5MS; - } else if ('A' <= cp[12] && cp[12] <= 'H') { - /* Error less than 1 msec */ - omega->lasttime = current_time; - omega->station = cp[12] - 'A' + 1; - drift = 0; - } else { - omega->badformat++; - omega_report_event(omega, CEVNT_BADREPLY); - return; - } - -#ifdef PEDANTIC - /* If we haven't been polled, bail out. */ - if (!omega->polled) - return; -#endif - - /* - * Now, compute the reference time value. Use the heavy - * machinery for the seconds and the millisecond field for the - * fraction when present. - * - * this code does not yet know how to do the years - */ - tstmp = omega->lastrec; - if (!clocktime(omega->day, omega->hour, omega->minute, - omega->second, GMT, tstmp.l_ui, - &omega->yearstart, &omega->lastref.l_ui)) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - MSUTOTSF(omega->msec, omega->lastref.l_uf); - - /* - * Adjust the read value by fudgefactor1 to correct RS232 delays. - */ - L_ADD(&omega->lastref, &fudgefactor1[omega->unit]); - - /* Carousel of NSTAMPS offsets. */ - i = omega->coderecv % NSTAMPS; - omega->offset[i] = omega->lastref; - L_SUB(&omega->offset[i], &tstmp); - omega->coderecv++; - - /* If we don't yet have a full set, return. */ - if (omega->coderecv < NSTAMPS) - return; - - /* - * Filter the samples, add the fudge factor and pass the - * offset and dispersion along. We use lastrec as both the - * reference time and receive time in order to avoid being cute, - * like setting the reference time later than the receive time, - * which may cause a paranoid protocol module to chuck out the - * data. If the sample filter chokes because of excessive - * dispersion or whatever, get a new sample (omega->coderecv - * is still >= NSTAMPS) and try again. - */ - if (!omega_process(omega, &tstmp, &dispersion)) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - - /* - * Add accumulated clock drift to the dispersion to get - * a (hopefully) meaningful measurement accuracy estimate. - */ - dispersion += drift; - refclock_receive(omega->peer, &tstmp, GMT, dispersion, - &omega->lastrec, &omega->lastrec, omega->leap); - - /* - * We have succeeded in answering the poll. If the clock - * is locked, we're nominal. - */ - omega->polled = 0; - omega->coderecv = 0; - if (omega->leap != LEAP_NOTINSYNC) - omega_report_event(omega, CEVNT_NOMINAL); -} - - -/* - * omega_send - time to send the clock a signal to cough up a time sample - */ -static void -omega_send(omega,cmd) - struct omegaunit *omega; - char *cmd; -{ - if (!readonlyclockflag[omega->unit]) { - /* - * Send a command to the clock. - */ - if (write(omega->io.fd, cmd, 1) != 1) { - syslog(LOG_ERR, "omega_send: unit %d: %m", omega->unit); - omega_report_event(omega, CEVNT_FAULT); - } - } -} - - -/* - * Compare two l_fp's, used with qsort() - */ -static int -omega_cmpl_fp(p1, p2) - register void *p1, *p2; -{ - - if (!L_ISGEQ((l_fp *)p1, (l_fp *)p2)) - return (-1); - if (L_ISEQU((l_fp *)p1, (l_fp *)p2)) - return (0); - return (1); -} - - -/* - * omega_process - process a pile of samples from the clock - */ -static char -omega_process(omega, offset, dispersion) - struct omegaunit *omega; - l_fp *offset; - u_fp *dispersion; -{ - register int i, n; - register u_long med_ui, med_uf, tmp_ui, tmp_uf; - l_fp off[NSTAMPS]; - u_fp disp; - - /* Copy in offsets and sort into ascending order */ - for (i = 0; i < NSTAMPS; i++) - off[i] = omega->offset[i]; - qsort((char *)off, NSTAMPS, sizeof(l_fp), omega_cmpl_fp); - /* - * Reject the furthest from the median until NSKEEP samples remain - */ - i = 0; - n = NSTAMPS; - while ((n - i) > NSKEEP) { - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - med_ui = off[(n+i)/2].l_ui; - med_uf = off[(n+i)/2].l_uf; - M_SUB(tmp_ui, tmp_uf, med_ui, med_uf); - M_SUB(med_ui, med_uf, off[i].l_ui, off[i].l_uf); - if (M_ISHIS(med_ui, med_uf, tmp_ui, tmp_uf)) { - /* reject low end */ - i++; - } else { - /* reject high end */ - n--; - } - } - - /* - * Compute the dispersion based on the difference between the - * extremes of the remaining offsets. If this is greater than - * the allowed sample set dispersion, bail out. Otherwise, - * return the median offset and the dispersion. - */ - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - M_SUB(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - disp = MFPTOFP(tmp_ui, tmp_uf); - if (disp > OMEGAMAXDISPERSE) - return 0; - *offset = off[(n+1)/2]; - *dispersion = disp; - return 1; -} - - -/* - * omega_poll - called by the transmit procedure - */ -static void -omega_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct omegaunit *omega; - - /* - * You don't need to poll this clock. It puts out timecodes - * once per second. If asked for a timestamp, take note. - * The next time a timecode comes in, it will be fed back. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "omega_poll: unit %d not in use", unit); - return; - } - omega = omegaunits[unit]; - if ((current_time - omega->lasttime) > 150) { - omega->noreply++; - omega_report_event(omegaunits[unit], CEVNT_TIMEOUT); - } - - /* - * polled every 64 seconds. Ask OMEGA_RECEIVE to hand in a timestamp. - */ - omega->polled = 1; - omega->polls++; - /* - * Ensure the clock is running in the correct mode - on-second - * timestamps. - */ - omega_send(omega,"C"); -} - - -/* - * omega_control - set fudge factors, return statistics - */ -static void -omega_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_control: unit %d invalid", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor1[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - fudgefactor2[unit] = in->fudgetime2; - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (in->haveflags & CLK_HAVEFLAG1) - readonlyclockflag[unit] = in->flags & CLK_FLAG1; - if (unitinuse[unit]) { - struct peer *peer; - - peer = omegaunits[unit]->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out != 0) { - out->type = REFCLK_OMEGA_TRUETIME; - out->haveflags = CLK_HAVETIME1 | CLK_HAVETIME2 | CLK_HAVEVAL1 | - CLK_HAVEVAL2| CLK_HAVEFLAG1; - out->clockdesc = OMEGADESCRIPTION; - out->fudgetime1 = fudgefactor1[unit]; - out->fudgetime2 = fudgefactor2[unit]; - out->fudgeval1 = stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->flags = readonlyclockflag[unit]; - if (unitinuse[unit]) { - omega = omegaunits[unit]; - out->flags |= omega->station << 1; - out->lencode = omega->lencode; - out->lastcode = omega->lastcode; - out->timereset = current_time - omega->timestarted; - out->polls = omega->polls; - out->noresponse = omega->noreply; - out->badformat = omega->badformat; - out->baddata = omega->baddata; - out->lastevent = omega->lastevent; - out->currentstatus = omega->status; - } - } -} - - -/* - * omega_buginfo - return clock dependent debugging info - */ -static void -omega_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_buginfo: unit %d invalid", unit); - return; - } - - if (!unitinuse[unit]) - return; - omega = omegaunits[unit]; - - bug->nvalues = 11; - bug->ntimes = 5; - if (omega->lasttime != 0) - bug->values[0] = current_time - omega->lasttime; - else - bug->values[0] = 0; - bug->values[1] = omega->reason; - bug->values[2] = omega->year; - bug->values[3] = omega->day; - bug->values[4] = omega->hour; - bug->values[5] = omega->minute; - bug->values[6] = omega->second; - bug->values[7] = omega->msec; - bug->values[8] = omega->noreply; - bug->values[9] = omega->yearstart; - bug->values[10] = omega->quality; - bug->stimes = 0x1c; - bug->times[0] = omega->lastref; - bug->times[1] = omega->lastrec; - bug->times[2] = omega->offset[0]; - bug->times[3] = omega->offset[1]; - bug->times[4] = omega->offset[2]; -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c b/usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c deleted file mode 100644 index 1b950a9b8e6f..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c +++ /dev/null @@ -1,3617 +0,0 @@ -#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) -/* - * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.59 1994/05/23 16:29:27 kardel Exp - * - * refclock_parse.c,v 3.59 1994/05/23 16:29:27 kardel Exp - * - * generic reference clock driver for receivers - * - * make use of a STREAMS module for input processing where - * available and configured. Currently the STREAMS module - * is only available for Suns running SunOS 4.x and SunOS5.x (new - careful!) - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg - * - * 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. - * - */ - -/* - * Defines: - * REFCLOCK && (PARSE||PARSEPPS) - * - enable this mess - * STREAM - allow for STREAMS modules - * ("parse", "ppsclocd", "ppsclock") - * PARSEPPS - provide PPS information to loopfilter (for - * backward compatibilty only) - * PPS - supply loopfilter with PPS samples (if configured) - * PPSPPS - notify loopfilter of PPS file descriptor - * - * TTY defines: - * HAVE_BSD_TTYS - currently unsupported - * HAVE_SYSV_TTYS - will use termio.h - * HAVE_TERMIOS - will use termios.h - * STREAM - will use streams and implies HAVE_TERMIOS - */ - -/* - * This driver currently provides the support for - * - Meinberg DCF77 receiver DCF77 PZF 535 (TCXO version) (DCF) - * - Meinberg DCF77 receiver DCF77 PZF 535 (OCXO version) (DCF) - * - Meinberg DCF77 receiver U/A 31 (DCF) - * - IGEL CLOCK (DCF) - * - ELV DCF7000 (DCF) - * - Schmid clock (DCF) - * - Conrad DCF77 receiver module (DCF) - * - FAU DCF77 NTP receiver (TimeBrick) (DCF) - * - Meinberg GPS166 (GPS) - * - Trimble SV6 (GPS) - * - */ - -/* - * Meinberg receivers are connected via a 9600 baud serial line - * - * Receivers that do NOT support: - * - leap second indication - * DCF U/A 31 - * DCF PZF535 (stock version) - * - * so... - * - for PZF535 please ask for revision PZFUERL4.6 or higher - * (support for leap second and alternate antenna) - * - * The Meinberg GPS receiver also has a special NTP time stamp - * format. The firmware release is Uni-Erlangen. Only this - * firmware release is supported by xntp3. - * - * Meinberg generic receiver setup: - * output time code every second - * Baud rate 9600 7E2S - */ - -#include "ntpd.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" -#include "ntp_control.h" - -#include -#include -#include - -#include -extern int errno; - -#if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS) -/* #error NEED TO DEFINE ONE OF "STREAM" or "HAVE_SYSV_TTYS" */ -NEED TO DEFINE ONE OF "STREAM", "HAVE_SYSV_TTYS" or "HAVE_TERMIOS" -#endif - -#ifdef STREAM -#include -#include -#ifndef HAVE_TERMIOS -#define HAVE_TERMIOS -#endif -#endif - -#ifdef HAVE_TERMIOS -#include -#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_)) -#define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_)) -#undef HAVE_SYSV_TTYS -#endif - -#ifdef HAVE_SYSV_TTYS -#include -#define TTY_GETATTR(_FD_, _ARG_) ioctl((_FD_), TCGETA, (_ARG_)) -#define TTY_SETATTR(_FD_, _ARG_) ioctl((_FD_), TCSETAW, (_ARG_)) -#endif - -#ifdef HAVE_BSD_TTYS -/* #error CURRENTLY NO BSD TTY SUPPORT */ -CURRENTLY NO BSD TTY SUPPORT -#endif - -#if !defined(O_RDWR) /* XXX SOLARIS */ -#include -#endif /* !def(O_RDWR) */ - -#ifdef PPSPPS -#include -#endif - -#include "ntp_select.h" -#include "ntp_stdlib.h" - -#include "parse.h" - -#if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -static char rcsid[]="refclock_parse.c,v 3.59 1994/05/23 16:29:27 kardel Exp"; -#endif - -/**=========================================================================== - ** external interface to xntp mechanism - **/ - -static void parse_init P((void)); -static int parse_start P((u_int, struct peer *)); -static void parse_shutdown P((int)); -static void parse_poll P((int, struct peer *)); -static void parse_control P((u_int, struct refclockstat *, struct refclockstat *)); - -#define parse_buginfo noentry - -struct refclock refclock_parse = { - parse_start, - parse_shutdown, - parse_poll, - parse_control, - parse_init, - parse_buginfo, - NOFLAGS -}; - -/* - * the unit field selects for one the prototype to be used (lower 4 bits) - * and for the other the clock type in case of different but similar - * receivers (bits 4-6) - * the most significant bit encodes PPS support - * when the most significant bit is set the pps telegrams will be used - * for controlling the local clock (ntp_loopfilter.c) - * receiver specific configration data is kept in the clockinfo field. - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* maximum number of "PARSE" units permitted */ -#define PARSEDEVICE "/dev/refclock-%d" /* device to open %d is unit number */ - -/**=========================================================================== - ** function vector for dynamically binding io handling mechanism - **/ - -typedef struct bind -{ - char *bd_description; /* name of type of binding */ - int (*bd_init)(); /* initialize */ - void (*bd_end)(); /* end */ - int (*bd_setcs)(); /* set character size */ - int (*bd_disable)(); /* disable */ - int (*bd_enable)(); /* enable */ - int (*bd_getfmt)(); /* get format */ - int (*bd_setfmt)(); /* setfmt */ - int (*bd_getstat)(); /* getstat */ - int (*bd_setstat)(); /* setstat */ - int (*bd_timecode)(); /* get time code */ - void (*bd_receive)(); /* receive operation */ - void (*bd_poll)(); /* poll operation */ -} bind_t; - -#define PARSE_END(_X_) (*(_X_)->binding->bd_end)(_X_) -#define PARSE_SETCS(_X_, _CS_) (*(_X_)->binding->bd_setcs)(_X_, _CS_) -#define PARSE_ENABLE(_X_) (*(_X_)->binding->bd_enable)(_X_) -#define PARSE_DISABLE(_X_) (*(_X_)->binding->bd_disable)(_X_) -#define PARSE_GETFMT(_X_, _DCT_) (*(_X_)->binding->bd_getfmt)(_X_, _DCT_) -#define PARSE_SETFMT(_X_, _DCT_) (*(_X_)->binding->bd_setfmt)(_X_, _DCT_) -#define PARSE_GETSTAT(_X_, _DCT_) (*(_X_)->binding->bd_getstat)(_X_, _DCT_) -#define PARSE_SETSTAT(_X_, _DCT_) (*(_X_)->binding->bd_setstat)(_X_, _DCT_) -#define PARSE_GETTIMECODE(_X_, _DCT_) (*(_X_)->binding->bd_timecode)(_X_, _DCT_) -#define PARSE_POLL(_X_) (*(_X_)->binding->bd_poll)(_X_) - -/* - * io modes - */ -#define PARSE_F_NOPOLLONLY 0x0001 /* always do async io (possible PPS support via PARSE) */ -#define PARSE_F_POLLONLY 0x0002 /* never do async io (no PPS support via PARSE) */ -#define PARSE_F_PPSPPS 0x0004 /* use loopfilter PPS code (CIOGETEV) */ -#define PARSE_F_PPSONSECOND 0x0008 /* PPS pulses are on second */ - -/**=========================================================================== - ** refclock instance data - **/ - -struct parseunit -{ - /* - * XNTP management - */ - struct peer *peer; /* backlink to peer structure - refclock inactive if 0 */ - int fd; /* device file descriptor */ - u_char unit; /* encoded unit/type/PPS */ - - /* - * XNTP io - */ - struct refclockio io; /* io system structure (used in PPS mode) */ - bind_t *binding; /* io handling binding */ - - /* - * parse state - */ - parse_t parseio; /* io handling structure (user level parsing) */ - - /* - * type specific parameters - */ - struct clockinfo *parse_type; /* link to clock description */ - - /* - * clock specific configuration - */ - l_fp basedelay; /* clock local phase offset */ - l_fp ppsdelay; /* clock local pps phase offset */ - - /* - * clock state handling/reporting - */ - u_char flags; /* flags (leap_control) */ - u_char status; /* current status */ - u_char lastevent; /* last not NORMAL status */ - u_long lastchange; /* time (xntp) when last state change accured */ - u_long statetime[CEVNT_MAX+1]; /* accumulated time of clock states */ - struct event stattimer; /* statistics timer */ - u_long polls; /* polls from NTP protocol machine */ - u_long noresponse; /* number of expected but not seen datagrams */ - u_long badformat; /* bad format (failed format conversions) */ - u_long baddata; /* usually bad receive length, bad format */ - - u_char pollonly; /* 1 for polling only (no PPS mode) */ - u_char pollneeddata; /* 1 for receive sample expected in PPS mode */ - u_long laststatus; /* last packet status (error indication) */ - u_short lastformat; /* last format used */ - u_long lastsync; /* time (xntp) when clock was last seen fully synchronized */ - u_long timestarted; /* time (xntp) when peer clock was instantiated */ - u_long nosynctime; /* time (xntp) when last nosync message was posted */ - u_long lastmissed; /* time (xntp) when poll didn't get data (powerup heuristic) */ - u_long ppsserial; /* magic cookie for ppsclock serials (avoids stale ppsclock data) */ - parsetime_t time; /* last (parse module) data */ - void *localdata; /* optional local data */ -}; - - -/**=========================================================================== - ** Clockinfo section all parameter for specific clock types - ** includes NTP paramaters, TTY parameters and IO handling parameters - **/ - -static void poll_dpoll P((struct parseunit *)); -static void poll_poll P((struct parseunit *)); -static int poll_init P((struct parseunit *)); -static void poll_end P((struct parseunit *)); - -typedef struct poll_info -{ - u_long rate; /* poll rate - once every "rate" seconds - 0 off */ - char * string; /* string to send for polling */ - u_long count; /* number of charcters in string */ -} poll_info_t; - -#define NO_FLAGS 0 -#define NO_POLL (void (*)())0 -#define NO_INIT (int (*)())0 -#define NO_END (void (*)())0 -#define NO_DATA (void *)0 -#define NO_FORMAT "" -#define NO_PPSDELAY 0 - -#define DCF_ID "DCF" /* generic DCF */ -#define DCF_A_ID "DCFa" /* AM demodulation */ -#define DCF_P_ID "DCFp" /* psuedo random phase shift */ -#define GPS_ID "GPS" /* GPS receiver */ - -#define NOCLOCK_ROOTDELAY 0x00000000 -#define NOCLOCK_BASEDELAY 0x00000000 -#define NOCLOCK_DESCRIPTION ((char *)0) -#define NOCLOCK_MAXUNSYNC 0 -#define NOCLOCK_CFLAG 0 -#define NOCLOCK_IFLAG 0 -#define NOCLOCK_OFLAG 0 -#define NOCLOCK_LFLAG 0 -#define NOCLOCK_ID "TILT" -#define NOCLOCK_POLL NO_POLL -#define NOCLOCK_INIT NO_INIT -#define NOCLOCK_END NO_END -#define NOCLOCK_DATA NO_DATA -#define NOCLOCK_FORMAT NO_FORMAT -#define NOCLOCK_TYPE CTL_SST_TS_UNSPEC - -#define DCF_TYPE CTL_SST_TS_LF -#define GPS_TYPE CTL_SST_TS_UHF - -/* - * receiver specific constants - */ -#define MBG_CFLAG19200 (B19200|CS7|PARENB|CREAD|HUPCL) -#define MBG_CFLAG (B9600|CS7|PARENB|CREAD|HUPCL) -#define MBG_IFLAG (IGNBRK|IGNPAR|ISTRIP) -#define MBG_OFLAG 0 -#define MBG_LFLAG 0 -/* - * Meinberg DCF U/A 31 (AM) receiver - */ -#define DCFUA31_ROOTDELAY 0x00000D00 /* 50.78125ms */ -#define DCFUA31_BASEDELAY 0x02C00000 /* 10.7421875ms: 10 ms (+/- 3 ms) */ -#define DCFUA31_DESCRIPTION "Meinberg DCF U/A 31" -#define DCFUA31_MAXUNSYNC 60*30 /* only trust clock for 1/2 hour */ -#define DCFUA31_CFLAG MBG_CFLAG -#define DCFUA31_IFLAG MBG_IFLAG -#define DCFUA31_OFLAG MBG_OFLAG -#define DCFUA31_LFLAG MBG_LFLAG - -/* - * Meinberg DCF PZF535/TCXO (FM/PZF) receiver - */ -#define DCFPZF535_ROOTDELAY 0x00000034 /* 800us */ -#define DCFPZF535_BASEDELAY 0x00800000 /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define DCFPZF535_DESCRIPTION "Meinberg DCF PZF 535/TCXO" -#define DCFPZF535_MAXUNSYNC 60*60*12 /* only trust clock for 12 hours - * @ 5e-8df/f we have accumulated - * at most 2.16 ms (thus we move to - * NTP synchronisation */ -#define DCFPZF535_CFLAG MBG_CFLAG -#define DCFPZF535_IFLAG MBG_IFLAG -#define DCFPZF535_OFLAG MBG_OFLAG -#define DCFPZF535_LFLAG MBG_LFLAG - - -/* - * Meinberg DCF PZF535/OCXO receiver - */ -#define DCFPZF535OCXO_ROOTDELAY 0x00000034 /* 800us (max error * 10) */ -#define DCFPZF535OCXO_BASEDELAY 0x00800000 /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define DCFPZF535OCXO_DESCRIPTION "Meinberg DCF PZF 535/OCXO" -#define DCFPZF535OCXO_MAXUNSYNC 60*60*96 /* only trust clock for 4 days - * @ 5e-9df/f we have accumulated - * at most an error of 1.73 ms - * (thus we move to NTP synchronisation) */ -#define DCFPZF535OCXO_CFLAG MBG_CFLAG -#define DCFPZF535OCXO_IFLAG MBG_IFLAG -#define DCFPZF535OCXO_OFLAG MBG_OFLAG -#define DCFPZF535OCXO_LFLAG MBG_LFLAG - -/* - * Meinberg GPS166 receiver - */ -#define GPS166_ROOTDELAY 0x00000000 /* nothing here */ -#define GPS166_BASEDELAY 0x00800000 /* XXX to be fixed ! 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define GPS166_DESCRIPTION "Meinberg GPS166 receiver" -#define GPS166_MAXUNSYNC 0 /* this clock is immediately lost */ -#define GPS166_CFLAG MBG_CFLAG -#define GPS166_IFLAG MBG_IFLAG -#define GPS166_OFLAG MBG_OFLAG -#define GPS166_LFLAG MBG_LFLAG -#define GPS166_POLL NO_POLL -#define GPS166_INIT NO_INIT -#define GPS166_END NO_END -#define GPS166_DATA NO_DATA -#define GPS166_ID GPS_ID -#define GPS166_FORMAT NO_FORMAT - -/* - * ELV DCF7000 Wallclock-Receiver/Switching Clock (Kit) - * - * This is really not the hottest clock - but before you have nothing ... - */ -#define DCF7000_ROOTDELAY 0x00000364 /* 13 ms */ -#define DCF7000_BASEDELAY 0x67AE0000 /* 405 ms - slow blow */ -#define DCF7000_DESCRIPTION "ELV DCF7000" -#define DCF7000_MAXUNSYNC (60*5) /* sorry - but it just was not build as a clock */ -#define DCF7000_CFLAG (B9600|CS8|CREAD|PARENB|PARODD|CLOCAL|HUPCL) -#define DCF7000_IFLAG (IGNBRK) -#define DCF7000_OFLAG 0 -#define DCF7000_LFLAG 0 - -/* - * Schmid DCF Receiver Kit - * - * When the WSDCF clock is operating optimally we want the primary clock - * distance to come out at 300 ms. Thus, peer.distance in the WSDCF peer - * structure is set to 290 ms and we compute delays which are at least - * 10 ms long. The following are 290 ms and 10 ms expressed in u_fp format - */ -#define WS_POLLRATE 1 /* every second - watch interdependency with poll routine */ -#define WS_POLLCMD "\163" -#define WS_CMDSIZE 1 - -static poll_info_t wsdcf_pollinfo = { WS_POLLRATE, WS_POLLCMD, WS_CMDSIZE }; - -#define WSDCF_INIT poll_init -#define WSDCF_POLL poll_dpoll -#define WSDCF_END poll_end -#define WSDCF_DATA ((void *)(&wsdcf_pollinfo)) -#define WSDCF_ROOTDELAY 0X00004A3D /* ~ 290ms */ -#define WSDCF_BASEDELAY 0x028F5C29 /* ~ 10ms */ -#define WSDCF_DESCRIPTION "WS/DCF Receiver" -#define WSDCF_FORMAT "Schmid" -#define WSDCF_MAXUNSYNC (60*60) /* assume this beast hold at 1 h better than 2 ms XXX-must verify */ -#define WSDCF_CFLAG (B1200|CS8|CREAD|CLOCAL) -#define WSDCF_IFLAG 0 -#define WSDCF_OFLAG 0 -#define WSDCF_LFLAG 0 - -/* - * RAW DCF77 - input of DCF marks via RS232 - many variants - */ -#define RAWDCF_FLAGS PARSE_F_NOPOLLONLY -#define RAWDCF_ROOTDELAY 0x00000364 /* 13 ms */ -#define RAWDCF_FORMAT "RAW DCF77 Timecode" -#define RAWDCF_MAXUNSYNC (0) /* sorry - its a true receiver - no signal - no time */ -#define RAWDCF_CFLAG (B50|CS8|CREAD|CLOCAL|PARENB) -#define RAWDCF_IFLAG (IGNPAR) -#define RAWDCF_OFLAG 0 -#define RAWDCF_LFLAG 0 - -/* - * RAW DCF variants - */ -/* - * Conrad receiver - * - * simplest (cheapest) DCF clock - e. g. DCF77 receiver by Conrad - * (~40DM - roughly $30 ) followed by a level converter for RS232 - */ -#define CONRAD_BASEDELAY 0x420C49B0 /* ~258 ms - Conrad receiver @ 50 Baud on a Sun */ -#define CONRAD_DESCRIPTION "RAW DCF77 CODE (Conrad DCF77 receiver module)" - -/* - * TimeBrick receiver - */ -#define TIMEBRICK_BASEDELAY 0x35C29000 /* ~210 ms - TimeBrick @ 50 Baud on a Sun */ -#define TIMEBRICK_DESCRIPTION "RAW DCF77 CODE (TimeBrick)" - -/* - * IGEL:clock receiver - */ -#define IGELCLOCK_BASEDELAY 0x420C49B0 /* ~258 ms - IGEL:clock receiver */ -#define IGELCLOCK_DESCRIPTION "RAW DCF77 CODE (IGEL:clock)" -#define IGELCLOCK_CFLAG (B1200|CS8|CREAD|HUPCL|CLOCAL) - -/* - * Trimble SV6 GPS receiver - */ -#ifndef TRIM_POLLRATE -#define TRIM_POLLRATE 0 /* only true direct polling */ -#endif -#define TRIM_POLLCMD ">SRM;FR_FLAG=F<>QTM<" -#define TRIM_CMDSIZE 20 - -static poll_info_t trimble_pollinfo = { TRIM_POLLRATE, TRIM_POLLCMD, TRIM_CMDSIZE }; -static int trimble_init P((struct parseunit *)); - -#define TRIMBLESV6_CFLAG (B4800|CS8|CREAD) -#define TRIMBLESV6_IFLAG (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON) -#define TRIMBLESV6_OFLAG (OPOST|ONLCR) -#define TRIMBLESV6_LFLAG (ICANON|ECHOK) -#define TRIMBLESV6_FLAGS (PARSE_F_PPSPPS|PARSE_F_PPSONSECOND) -#define TRIMBLESV6_POLL poll_dpoll -#define TRIMBLESV6_INIT trimble_init -#define TRIMBLESV6_END poll_end -#define TRIMBLESV6_DATA ((void *)(&trimble_pollinfo)) -#define TRIMBLESV6_ID GPS_ID -#define TRIMBLESV6_FORMAT NO_FORMAT -#define TRIMBLESV6_ROOTDELAY 0x0 -#define TRIMBLESV6_BASEDELAY 0x0 -#define TRIMBLESV6_DESCRIPTION "Trimble SV6 GPS receiver" -#define TRIMBLESV6_MAXUNSYNC 0 -#define TRIMBLESV6_EOL '<' - -static struct clockinfo -{ - u_long cl_flags; /* operation flags (io modes) */ - void (*cl_poll)(); /* active poll routine */ - int (*cl_init)(); /* active poll init routine */ - void (*cl_end)(); /* active poll end routine */ - void *cl_data; /* local data area for "poll" mechanism */ - u_fp cl_rootdelay; /* rootdelay */ - u_long cl_basedelay; /* current offset - unsigned l_fp fractional part */ - u_long cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional part */ - char *cl_id; /* ID code (usually "DCF") */ - char *cl_description; /* device name */ - char *cl_format; /* fixed format */ - u_char cl_type; /* clock type (ntp control) */ - u_long cl_maxunsync; /* time to trust oscillator after loosing synch */ - u_long cl_cflag; /* terminal io flags */ - u_long cl_iflag; /* terminal io flags */ - u_long cl_oflag; /* terminal io flags */ - u_long cl_lflag; /* terminal io flags */ -} clockinfo[] = -{ /* 0. 0.0.128 - base offset for PPS support */ - { /* 127.127.8. */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFPZF535_ROOTDELAY, - DCFPZF535_BASEDELAY, - NO_PPSDELAY, - DCF_P_ID, - DCFPZF535_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFPZF535_MAXUNSYNC, - DCFPZF535_CFLAG, - DCFPZF535_IFLAG, - DCFPZF535_OFLAG, - DCFPZF535_LFLAG - }, - { /* 127.127.8.4+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFPZF535OCXO_ROOTDELAY, - DCFPZF535OCXO_BASEDELAY, - NO_PPSDELAY, - DCF_P_ID, - DCFPZF535OCXO_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFPZF535OCXO_MAXUNSYNC, - DCFPZF535OCXO_CFLAG, - DCFPZF535OCXO_IFLAG, - DCFPZF535OCXO_OFLAG, - DCFPZF535OCXO_LFLAG - }, - { /* 127.127.8.8+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFUA31_ROOTDELAY, - DCFUA31_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - DCFUA31_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFUA31_MAXUNSYNC, - DCFUA31_CFLAG, - DCFUA31_IFLAG, - DCFUA31_OFLAG, - DCFUA31_LFLAG - }, - { /* 127.127.8.12+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCF7000_ROOTDELAY, - DCF7000_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - DCF7000_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCF7000_MAXUNSYNC, - DCF7000_CFLAG, - DCF7000_IFLAG, - DCF7000_OFLAG, - DCF7000_LFLAG - }, - { /* 127.127.8.16+ */ - NO_FLAGS, - WSDCF_POLL, - WSDCF_INIT, - WSDCF_END, - WSDCF_DATA, - WSDCF_ROOTDELAY, - WSDCF_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - WSDCF_DESCRIPTION, - WSDCF_FORMAT, - DCF_TYPE, - WSDCF_MAXUNSYNC, - WSDCF_CFLAG, - WSDCF_IFLAG, - WSDCF_OFLAG, - WSDCF_LFLAG - }, - { /* 127.127.8.20+ */ - RAWDCF_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - RAWDCF_ROOTDELAY, - CONRAD_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - CONRAD_DESCRIPTION, - RAWDCF_FORMAT, - DCF_TYPE, - RAWDCF_MAXUNSYNC, - RAWDCF_CFLAG, - RAWDCF_IFLAG, - RAWDCF_OFLAG, - RAWDCF_LFLAG - }, - { /* 127.127.8.24+ */ - RAWDCF_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - RAWDCF_ROOTDELAY, - TIMEBRICK_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - TIMEBRICK_DESCRIPTION, - RAWDCF_FORMAT, - DCF_TYPE, - RAWDCF_MAXUNSYNC, - RAWDCF_CFLAG, - RAWDCF_IFLAG, - RAWDCF_OFLAG, - RAWDCF_LFLAG - }, - { /* 127.127.8.28+ */ - NO_FLAGS, - GPS166_POLL, - GPS166_INIT, - GPS166_END, - GPS166_DATA, - GPS166_ROOTDELAY, - GPS166_BASEDELAY, - NO_PPSDELAY, - GPS166_ID, - GPS166_DESCRIPTION, - GPS166_FORMAT, - GPS_TYPE, - GPS166_MAXUNSYNC, - GPS166_CFLAG, - GPS166_IFLAG, - GPS166_OFLAG, - GPS166_LFLAG - }, - { /* 127.127.8.32+ */ - TRIMBLESV6_FLAGS, -#if TRIM_POLLRATE /* DHD940515: Allow user config */ - NO_POLL, -#else - TRIMBLESV6_POLL, -#endif - TRIMBLESV6_INIT, - TRIMBLESV6_END, - TRIMBLESV6_DATA, - TRIMBLESV6_ROOTDELAY, - TRIMBLESV6_BASEDELAY, - NO_PPSDELAY, - TRIMBLESV6_ID, - TRIMBLESV6_DESCRIPTION, - TRIMBLESV6_FORMAT, - GPS_TYPE, - TRIMBLESV6_MAXUNSYNC, - TRIMBLESV6_CFLAG, - TRIMBLESV6_IFLAG, - TRIMBLESV6_OFLAG, - TRIMBLESV6_LFLAG - }, - { /* 127.127.8.36+ */ - RAWDCF_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - RAWDCF_ROOTDELAY, - IGELCLOCK_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - IGELCLOCK_DESCRIPTION, - RAWDCF_FORMAT, - DCF_TYPE, - RAWDCF_MAXUNSYNC, - IGELCLOCK_CFLAG, - RAWDCF_IFLAG, - RAWDCF_OFLAG, - RAWDCF_LFLAG - } -}; - -static int ncltypes = sizeof(clockinfo) / sizeof(struct clockinfo); - -#define CL_REALTYPE(x) (((x) >> 2) & 0x1F) -#define CL_TYPE(x) ((CL_REALTYPE(x) >= ncltypes) ? ~0 : CL_REALTYPE(x)) -#define CL_PPS(x) ((x) & 0x80) -#define CL_UNIT(x) ((x) & 0x3) - -/* - * Other constant stuff - */ -#define PARSEHSREFID 0x7f7f08ff /* 127.127.8.255 refid for hi strata */ - -#define PARSENOSYNCREPEAT (10*60) /* mention uninitialized clocks all 10 minutes */ -#define PARSESTATISTICS (60*60) /* output state statistics every hour */ - -static struct parseunit *parseunits[MAXUNITS]; - -extern u_long current_time; -extern s_char sys_precision; -extern struct event timerqueue[]; -#ifdef PPSPPS -extern int fdpps; -#endif - -static int notice = 0; - -#define PARSE_STATETIME(parse, i) ((parse->status == i) ? parse->statetime[i] + current_time - parse->lastchange : parse->statetime[i]) - -static void parse_event P((struct parseunit *, int)); -static void parse_process P((struct parseunit *, parsetime_t *)); - -/**=========================================================================== - ** implementation of i/o handling methods - ** (all STREAM, partial STREAM, user level) - **/ - -/* - * define possible io handling methods - */ -#ifdef STREAM -static int ppsclock_init P((struct parseunit *)); -static int stream_init P((struct parseunit *)); -static void stream_nop P((struct parseunit *)); -static int stream_enable P((struct parseunit *)); -static int stream_disable P((struct parseunit *)); -static int stream_setcs P((struct parseunit *, parsectl_t *)); -static int stream_getfmt P((struct parseunit *, parsectl_t *)); -static int stream_setfmt P((struct parseunit *, parsectl_t *)); -static int stream_getstat P((struct parseunit *, parsectl_t *)); -static int stream_setstat P((struct parseunit *, parsectl_t *)); -static int stream_timecode P((struct parseunit *, parsectl_t *)); -static void stream_receive P((struct recvbuf *)); -static void stream_poll P((struct parseunit *)); -#endif - -static int local_init P((struct parseunit *)); -static void local_end P((struct parseunit *)); -static int local_nop P((struct parseunit *)); -static int local_setcs P((struct parseunit *, parsectl_t *)); -static int local_getfmt P((struct parseunit *, parsectl_t *)); -static int local_setfmt P((struct parseunit *, parsectl_t *)); -static int local_getstat P((struct parseunit *, parsectl_t *)); -static int local_setstat P((struct parseunit *, parsectl_t *)); -static int local_timecode P((struct parseunit *, parsectl_t *)); -static void local_receive P((struct recvbuf *)); -static void local_poll P((struct parseunit *)); - -static bind_t io_bindings[] = -{ -#ifdef STREAM - { - "parse STREAM", - stream_init, - stream_nop, - stream_setcs, - stream_disable, - stream_enable, - stream_getfmt, - stream_setfmt, - stream_getstat, - stream_setstat, - stream_timecode, - stream_receive, - stream_poll - }, - { - "ppsclock STREAM", - ppsclock_init, - local_end, - local_setcs, - local_nop, - local_nop, - local_getfmt, - local_setfmt, - local_getstat, - local_setstat, - local_timecode, - local_receive, - local_poll - }, -#endif - { - "normal", - local_init, - local_end, - local_setcs, - local_nop, - local_nop, - local_getfmt, - local_setfmt, - local_getstat, - local_setstat, - local_timecode, - local_receive, - local_poll - }, - { - (char *)0, - } -}; - -#ifdef STREAM -/*-------------------------------------------------- - * ppsclock STREAM init - */ -static int -ppsclock_init(parse) - struct parseunit *parse; -{ - /* - * now push the parse streams module - * it will ensure exclusive access to the device - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"ppsclocd") == -1 && - ioctl(parse->fd, I_PUSH, (caddr_t)"ppsclock") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: ppsclock_init: ioctl(fd, I_PUSH, \"ppsclock\"): %m", - CL_UNIT(parse->unit)); - return 0; - } - if (!local_init(parse)) - { - (void)ioctl(parse->fd, I_POP, (caddr_t)0); - return 0; - } - - parse->flags |= PARSE_PPSCLOCK; - return 1; -} - -/*-------------------------------------------------- - * parse STREAM init - */ -static int -stream_init(parse) - struct parseunit *parse; -{ - /* - * now push the parse streams module - * to test whether it is there (Oh boy - neat kernel interface) - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"parse") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - while(ioctl(parse->fd, I_POP, (caddr_t)0) == 0) - /* empty loop */; - - /* - * now push it a second time after we have removed all - * module garbage - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"parse") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - return 1; - } - } -} - - /*-------------------------------------------------- - * STREAM setcs - */ -static int -stream_setcs(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETCS; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setcs: ioctl(fd, I_STR, PARSEIOC_SETCS): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM nop - */ -static void -stream_nop(parse) - struct parseunit *parse; -{ -} - -/*-------------------------------------------------- - * STREAM enable - */ -static int -stream_enable(parse) - struct parseunit *parse; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_ENABLE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)0; - strioc.ic_len = 0; - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_enable: ioctl(fd, I_STR, PARSEIOC_ENABLE): %m", CL_UNIT(parse->unit)); - return 0; - } - parse->io.clock_recv = stream_receive; /* ok - parse input in kernel */ - return 1; -} - -/*-------------------------------------------------- - * STREAM disable - */ -static int -stream_disable(parse) - struct parseunit *parse; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_DISABLE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)0; - strioc.ic_len = 0; - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_disable: ioctl(fd, I_STR, PARSEIOC_DISABLE): %m", CL_UNIT(parse->unit)); - return 0; - } - parse->io.clock_recv = local_receive; /* ok - parse input in daemon */ - return 1; -} - -/*-------------------------------------------------- - * STREAM getfmt - */ -static int -stream_getfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_GETFMT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: ioctl(fd, I_STR, PARSEIOC_GETFMT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM setfmt - */ -static int -stream_setfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETFMT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setfmt: ioctl(fd, I_STR, PARSEIOC_SETFMT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM getstat - */ -static int -stream_getstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_GETSTAT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_getstat: ioctl(fd, I_STR, PARSEIOC_GETSTAT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM setstat - */ -static int -stream_setstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETSTAT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setstat: ioctl(fd, I_STR, PARSEIOC_SETSTAT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM timecode - */ -static int -stream_timecode(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_TIMECODE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_process: ioctl(fd, I_STR, PARSEIOC_TIMECODE): %m", CL_UNIT(parse->unit), parse->fd); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM receive - */ -static void -stream_receive(rbufp) - struct recvbuf *rbufp; -{ - struct parseunit *parse = (struct parseunit *)rbufp->recv_srcclock; - parsetime_t parsetime; - - if (rbufp->recv_length != sizeof(parsetime_t)) - { - syslog(LOG_ERR,"PARSE receiver #%d: parse_receive: bad size (got %d expected %d)", - CL_UNIT(parse->unit), rbufp->recv_length, sizeof(parsetime_t)); - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - return; - } - memmove((caddr_t)&parsetime, - (caddr_t)&rbufp->recv_space, - sizeof(parsetime_t)); - - /* - * switch time stamp world - be sure to normalize small usec field - * errors. - */ - -#define fix_ts(_X_) \ - if ((&(_X_))->tv.tv_usec >= 1000000) \ - { \ - (&(_X_))->tv.tv_usec -= 1000000; \ - (&(_X_))->tv.tv_sec += 1; \ - } - -#define cvt_ts(_X_, _Y_) \ - { \ - l_fp ts; \ - \ - fix_ts((_X_)); \ - if (!buftvtots((const char *)&(&(_X_))->tv, &ts)) \ - { \ - syslog(LOG_ERR,"parse: stream_receive: timestamp conversion error (buftvtots) (%s) (%d.%06d) ", (_Y_), (&(_X_))->tv.tv_sec, (&(_X_))->tv.tv_usec);\ - return; \ - } \ - else \ - { \ - (&(_X_))->fp = ts; \ - } \ - } - - if (PARSE_TIMECODE(parsetime.parse_state)) - { - cvt_ts(parsetime.parse_time, "parse_time"); - cvt_ts(parsetime.parse_stime, "parse_stime"); - } - - if (PARSE_PPS(parsetime.parse_state)) - cvt_ts(parsetime.parse_ptime, "parse_ptime"); - - parse_process(parse, &parsetime); -} - -/*-------------------------------------------------- - * STREAM poll - */ -static void -stream_poll(parse) - struct parseunit *parse; -{ - register int fd, i, rtc; - fd_set fdmask; - struct timeval timeout, starttime, curtime, selecttime; - parsetime_t parsetime; - - /* - * now we do the following: - * - read the first packet from the parse module (OLD !!!) - * - read the second packet from the parse module (fresh) - * - compute values for xntp - */ - - FD_ZERO(&fdmask); - fd = parse->fd; - FD_SET(fd, &fdmask); - timeout.tv_sec = 0; - timeout.tv_usec = 500000; /* 0.5 sec */ - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (timercmp(&selecttime, &timeout, >)) - { - /* - * elapsed real time passed timeout value - consider it timed out - */ - break; - } - - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[old] from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[old] from device", CL_UNIT(parse->unit)); - } - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - return; - } - - while (((i = read(fd, (char *)&parsetime, sizeof(parsetime))) < sizeof(parsetime))) - { - /* bad packet */ - if ( i == -1) - { - if (errno == EINTR) - { - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[old] from streams module (read() error: %m)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[old] from streams module (got %d bytes - expected %d bytes)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - - return; - } - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - timeout.tv_sec = 1; - timeout.tv_usec = 500000; /* 1.500 sec */ - FD_ZERO(&fdmask); - FD_SET(fd, &fdmask); - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (timercmp(&selecttime, &timeout, >)) - { - /* - * elapsed real time passed timeout value - consider it timed out - */ - break; - } - - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[new] from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[new] from device", CL_UNIT(parse->unit)); - } - - /* - * we will return here iff we got a good old sample as this would - * be misinterpreted. bad samples are passed on to be logged into the - * state statistics - */ - if ((parsetime.parse_status & CVT_MASK) == CVT_OK) - { - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - return; - } - } - - /* - * we get here either by a possible read() (rtc == 1 - while assertion) - * or by a timeout or a system call error. when a read() is possible we - * get the new data, otherwise we stick with the old - */ - if ((rtc == 1) && ((i = read(fd, (char *)&parsetime, sizeof(parsetime))) < sizeof(parsetime))) - { - /* bad packet */ - if ( i== -1) - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[new] from streams module (read() error: %m)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[new] from streams module (got %d bytes - expected %d bytes)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - - return; - } - - /* - * process what we got - */ - parse_process(parse, &parsetime); -} -#endif - -/*-------------------------------------------------- - * local init - */ -static int -local_init(parse) - struct parseunit *parse; -{ - return parse_ioinit(&parse->parseio); -} - -/*-------------------------------------------------- - * local end - */ -static void -local_end(parse) - struct parseunit *parse; -{ - parse_ioend(&parse->parseio); -} - - -/*-------------------------------------------------- - * local nop - */ -static int -local_nop(parse) - struct parseunit *parse; -{ - return 1; -} - -/*-------------------------------------------------- - * local setcs - */ -static int -local_setcs(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setcs(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local getfmt - */ -static int -local_getfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_getfmt(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local setfmt - */ -static int -local_setfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setfmt(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local getstat - */ -static int -local_getstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_getstat(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local setstat - */ -static int -local_setstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setstat(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local timecode - */ -static int -local_timecode(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_timecode(tcl, &parse->parseio); -} - - -/*-------------------------------------------------- - * local receive - */ -static void -local_receive(rbufp) - struct recvbuf *rbufp; -{ - struct parseunit *parse = (struct parseunit *)rbufp->recv_srcclock; - register int count; - register char *s; - /* - * eat all characters, parsing then and feeding complete samples - */ - count = rbufp->recv_length; - s = rbufp->recv_buffer; - - while (count--) - { - if (parse_ioread(&parse->parseio, *s++, &rbufp->recv_time)) - { - /* - * got something good to eat - */ -#ifdef PPSPPS - if (!PARSE_PPS(parse->parseio.parse_dtime.parse_state) && - (parse->flags & PARSE_PPSCLOCK)) - { - l_fp ts; - struct ppsclockev ev; - - if (ioctl(parse->fd, CIOGETEV, (caddr_t)&ev) == 0) - { - if (ev.serial != parse->ppsserial) - { - /* - * add PPS time stamp if available via ppsclock module - * and not supplied already. - */ - if (!buftvtots((const char *)&ev.tv, &ts)) - { - syslog(LOG_ERR,"parse: local_receive: timestamp conversion error (buftvtots) (ppsclockev.tv)"); - } - else - { - parse->parseio.parse_dtime.parse_ptime.fp = ts; - parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS; - } - } - parse->ppsserial = ev.serial; - } - } -#endif - parse_process(parse, &parse->parseio.parse_dtime); - parse_iodone(&parse->parseio); - } - } -} - -/*-------------------------------------------------- - * local poll - */ -static void -local_poll(parse) - struct parseunit *parse; -{ - register int fd, i, rtc; - fd_set fdmask; - struct timeval timeout, starttime, curtime, selecttime; - static struct timeval null_time = { 0, 0}; - timestamp_t ts; - - FD_ZERO(&fdmask); - fd = parse->fd; - FD_SET(fd, &fdmask); - timeout.tv_sec = 1; - timeout.tv_usec = 500000; /* 1.5 sec */ - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - do - { - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (!timercmp(&selecttime, &timeout, >)) - { - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device", CL_UNIT(parse->unit)); - } - - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - return; - } - - /* - * at least 1 character is available - gobble everthing up that is available - */ - do - { - char inbuf[256]; - - register char *s = inbuf; - - rtc = i = read(fd, inbuf, sizeof(inbuf)); - - get_systime(&ts.fp); - - while (i-- > 0) - { - if (parse_ioread(&parse->parseio, *s++, &ts)) - { - /* - * got something good to eat - */ - parse_process(parse, &parse->parseio.parse_dtime); - parse_iodone(&parse->parseio); - /* - * done if no more characters are available - */ - FD_SET(fd, &fdmask); - if ((i == 0) && - (select(fd + 1, &fdmask, 0, 0, &null_time) == 0)) - return; - } - } - FD_SET(fd, &fdmask); - } while ((rtc = select(fd + 1, &fdmask, 0, 0, &null_time)) == 1); - FD_SET(fd, &fdmask); - } while (1); -} - -/*-------------------------------------------------- - * init_iobinding - find and initialize lower layers - */ -static bind_t * -init_iobinding(parse) - struct parseunit *parse; -{ - register bind_t *b = io_bindings; - - while (b->bd_description != (char *)0) - { - if ((*b->bd_init)(parse)) - { - return b; - } - b++; - } - return (bind_t *)0; -} - -/**=========================================================================== - ** support routines - **/ - -/*-------------------------------------------------- - * convert a flag field to a string - */ -static char * -parsestate(state, buffer) - u_long state; - char *buffer; -{ - static struct bits - { - u_long bit; - char *name; - } flagstrings[] = - { - { PARSEB_ANNOUNCE, "DST SWITCH WARNING" }, - { PARSEB_POWERUP, "NOT SYNCHRONIZED" }, - { PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" }, - { PARSEB_DST, "DST" }, - { PARSEB_UTC, "UTC DISPLAY" }, - { PARSEB_LEAPADD, "LEAP ADD WARNING" }, - { PARSEB_LEAPDEL, "LEAP DELETE WARNING" }, - { PARSEB_LEAPSECOND, "LEAP SECOND" }, - { PARSEB_ALTERNATE,"ALTERNATE ANTENNA" }, - { PARSEB_TIMECODE, "TIME CODE" }, - { PARSEB_PPS, "PPS" }, - { PARSEB_POSITION, "POSITION" }, - { 0 } - }; - - static struct sbits - { - u_long bit; - char *name; - } sflagstrings[] = - { - { PARSEB_S_LEAP, "LEAP INDICATION" }, - { PARSEB_S_PPS, "PPS SIGNAL" }, - { PARSEB_S_ANTENNA, "ANTENNA" }, - { PARSEB_S_POSITION, "POSITION" }, - { 0 } - }; - int i; - - *buffer = '\0'; - - i = 0; - while (flagstrings[i].bit) - { - if (flagstrings[i].bit & state) - { - if (buffer[0]) - strcat(buffer, "; "); - strcat(buffer, flagstrings[i].name); - } - i++; - } - - if (state & (PARSEB_S_LEAP|PARSEB_S_ANTENNA|PARSEB_S_PPS|PARSEB_S_POSITION)) - { - register char *s, *t; - - if (buffer[0]) - strcat(buffer, "; "); - - strcat(buffer, "("); - - t = s = buffer + strlen(buffer); - - i = 0; - while (sflagstrings[i].bit) - { - if (sflagstrings[i].bit & state) - { - if (t != s) - { - strcpy(t, "; "); - t += 2; - } - - strcpy(t, sflagstrings[i].name); - t += strlen(t); - } - i++; - } - strcpy(t, ")"); - } - return buffer; -} - -/*-------------------------------------------------- - * convert a status flag field to a string - */ -static char * -parsestatus(state, buffer) - u_long state; - char *buffer; -{ - static struct bits - { - u_long bit; - char *name; - } flagstrings[] = - { - { CVT_OK, "CONVERSION SUCCESSFUL" }, - { CVT_NONE, "NO CONVERSION" }, - { CVT_FAIL, "CONVERSION FAILED" }, - { CVT_BADFMT, "ILLEGAL FORMAT" }, - { CVT_BADDATE, "DATE ILLEGAL" }, - { CVT_BADTIME, "TIME ILLEGAL" }, - { 0 } - }; - int i; - - *buffer = '\0'; - - i = 0; - while (flagstrings[i].bit) - { - if (flagstrings[i].bit & state) - { - if (buffer[0]) - strcat(buffer, "; "); - strcat(buffer, flagstrings[i].name); - } - i++; - } - - return buffer; -} - -/*-------------------------------------------------- - * convert a clock status flag field to a string - */ -static char * -clockstatus(state) - u_long state; -{ - static char buffer[20]; - static struct status - { - u_long value; - char *name; - } flagstrings[] = - { - { CEVNT_NOMINAL, "NOMINAL" }, - { CEVNT_TIMEOUT, "NO RESPONSE" }, - { CEVNT_BADREPLY,"BAD FORMAT" }, - { CEVNT_FAULT, "FAULT" }, - { CEVNT_PROP, "PROPAGATION DELAY" }, - { CEVNT_BADDATE, "ILLEGAL DATE" }, - { CEVNT_BADTIME, "ILLEGAL TIME" }, - { ~0 } - }; - int i; - - i = 0; - while (flagstrings[i].value != ~0) - { - if (flagstrings[i].value == state) - { - return flagstrings[i].name; - } - i++; - } - - sprintf(buffer, "unknown #%ld", (u_long)state); - - return buffer; -} - -/*-------------------------------------------------- - * mkascii - make a printable ascii string - * assumes (unless defined better) 7-bit ASCII - */ -#ifndef isprint -#define isprint(_X_) (((_X_) > 0x1F) && ((_X_) < 0x7F)) -#endif - -static char * -mkascii(buffer, blen, src, srclen) - register char *buffer; - register long blen; - register char *src; - register long srclen; -{ - register char *b = buffer; - register char *endb = (char *)0; - - if (blen < 4) - return (char *)0; /* don't bother with mini buffers */ - - endb = buffer + blen - 4; - - blen--; /* account for '\0' */ - - while (blen && srclen--) - { - if ((*src != '\\') && isprint(*src)) - { /* printables are easy... */ - *buffer++ = *src++; - blen--; - } - else - { - if (blen < 4) - { - while (blen--) - { - *buffer++ = '.'; - } - *buffer = '\0'; - return b; - } - else - { - if (*src == '\\') - { - strcpy(buffer,"\\\\"); - buffer += 2; - blen -= 2; - } - else - { - sprintf(buffer, "\\x%02x", *src++); - blen -= 4; - buffer += 4; - } - } - } - if (srclen && !blen && endb) /* overflow - set last chars to ... */ - strcpy(endb, "..."); - } - - *buffer = '\0'; - return b; -} - - -/*-------------------------------------------------- - * l_mktime - make representation of a relative time - */ -static char * -l_mktime(delta) - u_long delta; -{ - u_long tmp, m, s; - static char buffer[40]; - - buffer[0] = '\0'; - - if ((tmp = delta / (60*60*24)) != 0) - { - sprintf(buffer, "%ldd+", (u_long)tmp); - delta -= tmp * 60*60*24; - } - - s = delta % 60; - delta /= 60; - m = delta % 60; - delta /= 60; - - sprintf(buffer+strlen(buffer), "%02d:%02d:%02d", - (int)delta, (int)m, (int)s); - - return buffer; -} - - -/*-------------------------------------------------- - * parse_statistics - list summary of clock states - */ -static void -parse_statistics(parse) - register struct parseunit *parse; -{ - register int i; - - syslog(LOG_INFO, "PARSE receiver #%d: running time: %s", - CL_UNIT(parse->unit), - l_mktime(current_time - parse->timestarted)); - - syslog(LOG_INFO, "PARSE receiver #%d: current status: %s", - CL_UNIT(parse->unit), - clockstatus(parse->status)); - - for (i = 0; i <= CEVNT_MAX; i++) - { - register u_long stime; - register u_long percent, div = current_time - parse->timestarted; - - percent = stime = PARSE_STATETIME(parse, i); - - while (((u_long)(~0) / 10000) < percent) - { - percent /= 10; - div /= 10; - } - - if (div) - percent = (percent * 10000) / div; - else - percent = 10000; - - if (stime) - syslog(LOG_INFO, "PARSE receiver #%d: state %18s: %13s (%3d.%02d%%)", - CL_UNIT(parse->unit), - clockstatus(i), - l_mktime(stime), - percent / 100, percent % 100); - } -} - -/*-------------------------------------------------- - * cparse_statistics - wrapper for statistics call - */ -static void -cparse_statistics(peer) - register struct peer *peer; -{ - register struct parseunit *parse = (struct parseunit *)peer; - - parse_statistics(parse); - parse->stattimer.event_time = current_time + PARSESTATISTICS; - TIMER_ENQUEUE(timerqueue, &parse->stattimer); -} - -/**=========================================================================== - ** xntp interface routines - **/ - -/*-------------------------------------------------- - * parse_init - initialize internal parse driver data - */ -static void -parse_init() -{ - memset((caddr_t)parseunits, 0, sizeof parseunits); -} - - -/*-------------------------------------------------- - * parse_shutdown - shut down a PARSE clock - */ -static void -parse_shutdown(unit) - int unit; -{ - register struct parseunit *parse; - - unit = CL_UNIT(unit); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_shutdown: INTERNAL ERROR, unit invalid (max %d)", - unit,MAXUNITS); - return; - } - - parse = parseunits[unit]; - - if (parse && !parse->peer) { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_shutdown: INTERNAL ERROR, unit not in use", unit); - return; - } - - /* - * print statistics a last time and - * stop statistics machine - */ - parse_statistics(parse); - TIMER_DEQUEUE(&parse->stattimer); - -#if PPSPPS - { - /* - * kill possible PPS association - */ - if (fdpps == parse->fd) - fdpps = -1; - } -#endif - - if (parse->parse_type->cl_end) - { - parse->parse_type->cl_end(parse); - } - - if (parse->binding) - PARSE_END(parse); - - /* - * Tell the I/O module to turn us off. We're history. - */ - if (!parse->pollonly) - io_closeclock(&parse->io); - else - (void) close(parse->fd); - - syslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" removed", - CL_UNIT(parse->unit), parse->parse_type->cl_description); - - parse->peer = (struct peer *)0; /* unused now */ -} - -/*-------------------------------------------------- - * parse_start - open the PARSE devices and initialize data for processing - */ -static int -parse_start(sysunit, peer) - u_int sysunit; - struct peer *peer; -{ - u_int unit; - int fd232, i; -#ifdef HAVE_TERMIOS - struct termios tm; /* NEEDED FOR A LONG TIME ! */ -#endif -#ifdef HAVE_SYSV_TTYS - struct termio tm; /* NEEDED FOR A LONG TIME ! */ -#endif - struct parseunit * parse; - char parsedev[sizeof(PARSEDEVICE)+20]; - parsectl_t tmp_ctl; - u_int type; - - type = CL_TYPE(sysunit); - unit = CL_UNIT(sysunit); - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unit number invalid (max %d)", - unit, MAXUNITS-1); - return 0; - } - - if ((type == ~0) || (clockinfo[type].cl_description == (char *)0)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unsupported clock type %d (max %d)", - unit, CL_REALTYPE(sysunit), ncltypes-1); - return 0; - } - - if (parseunits[unit] && parseunits[unit]->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unit in use", unit); - return 0; - } - - /* - * Unit okay, attempt to open the device. - */ - (void) sprintf(parsedev, PARSEDEVICE, unit); - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - - fd232 = open(parsedev, O_RDWR|O_NOCTTY, 0777); - if (fd232 == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: open of %s failed: %m", unit, parsedev); - return 0; - } - - /* - * Looks like this might succeed. Find memory for the structure. - * Look to see if there are any unused ones, if not we malloc() - * one. - */ - if (parseunits[unit]) - { - parse = parseunits[unit]; /* The one we want is okay - and free */ - } - else - { - for (i = 0; i < MAXUNITS; i++) - { - if (parseunits[i] && !parseunits[i]->peer) - break; - } - if (i < MAXUNITS) - { - /* - * Reclaim this one - */ - parse = parseunits[i]; - parseunits[i] = (struct parseunit *)0; - } - else - { - parse = (struct parseunit *) - emalloc(sizeof(struct parseunit)); - } - } - - memset((char *)parse, 0, sizeof(struct parseunit)); - parseunits[unit] = parse; - - /* - * Set up the structures - */ - parse->unit = (u_char)sysunit; - parse->timestarted = current_time; - parse->lastchange = current_time; - /* - * we want to filter input for the sake of - * getting an impression on dispersion - * also we like to average the median range - */ - parse->flags = PARSE_STAT_FILTER|PARSE_STAT_AVG; - parse->pollneeddata = 0; - parse->pollonly = 1; /* go for default polling mode */ - parse->lastformat = ~0; /* assume no format known */ - parse->status = CEVNT_TIMEOUT; /* expect the worst */ - parse->laststatus = ~0; /* be sure to mark initial status change */ - parse->nosynctime = 0; /* assume clock reasonable */ - parse->lastmissed = 0; /* assume got everything */ - parse->ppsserial = 0; - parse->localdata = (void *)0; - - parse->parse_type = &clockinfo[type]; - - parse->basedelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ - parse->basedelay.l_uf = parse->parse_type->cl_basedelay; - - parse->ppsdelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ - parse->ppsdelay.l_uf = parse->parse_type->cl_ppsdelay; - - peer->rootdelay = parse->parse_type->cl_rootdelay; - peer->sstclktype = parse->parse_type->cl_type; - peer->precision = sys_precision; - peer->stratum = STRATUM_REFCLOCK; - if (peer->stratum <= 1) - memmove((char *)&peer->refid, parse->parse_type->cl_id, 4); - else - peer->refid = htonl(PARSEHSREFID); - - parse->fd = fd232; - - parse->peer = peer; /* marks it also as busy */ - - parse->binding = init_iobinding(parse); - - if (parse->binding == (bind_t *)0) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: io sub system initialisation failed."); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - - /* - * configure terminal line - */ - if (TTY_GETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcgetattr(%d, &tm): %m", unit, fd232); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - else - { -#ifndef _PC_VDISABLE - memset((char *)tm.c_cc, 0, sizeof(tm.c_cc)); -#else - int disablec; - errno = 0; /* pathconf can deliver -1 without changing errno ! */ - - disablec = fpathconf(parse->fd, _PC_VDISABLE); - if (disablec == -1 && errno) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: fpathconf(fd, _PC_VDISABLE): %m", CL_UNIT(parse->unit)); - memset((char *)tm.c_cc, 0, sizeof(tm.c_cc)); /* best guess */ - } - else - if (disablec != -1) - memset((char *)tm.c_cc, disablec, sizeof(tm.c_cc)); -#endif - - tm.c_cflag = clockinfo[type].cl_cflag; - tm.c_iflag = clockinfo[type].cl_iflag; - tm.c_oflag = clockinfo[type].cl_oflag; - tm.c_lflag = clockinfo[type].cl_lflag; - - if (TTY_SETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcsetattr(%d, &tm): %m", unit, fd232); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - } - - /* - * as we always(?) get 8 bit chars we want to be - * sure, that the upper bits are zero for less - * than 8 bit I/O - so we pass that information on. - * note that there can be only one bit count format - * per file descriptor - */ - - switch (tm.c_cflag & CSIZE) - { - case CS5: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS5; - break; - - case CS6: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS6; - break; - - case CS7: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS7; - break; - - case CS8: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS8; - break; - } - - if (!PARSE_SETCS(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setcs() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - - strcpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format); - tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer); - - if (!PARSE_SETFMT(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setfmt() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - -#ifdef TCFLSH - /* - * get rid of all IO accumulated so far - */ - { -#ifndef TCIOFLUSH -#define TCIOFLUSH 2 -#endif - int flshcmd = TCIOFLUSH; - - (void) ioctl(parse->fd, TCFLSH, (caddr_t)&flshcmd); - } -#endif - - tmp_ctl.parsestatus.flags = parse->flags & PARSE_STAT_FLAGS; - - if (!PARSE_SETSTAT(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setstat() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - - /* - * try to do any special initializations - */ - if (parse->parse_type->cl_init) - { - if (parse->parse_type->cl_init(parse)) - { - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - } - - if (!(parse->parse_type->cl_flags & PARSE_F_POLLONLY) && - (CL_PPS(parse->unit) || (parse->parse_type->cl_flags & PARSE_F_NOPOLLONLY))) - { - /* - * Insert in async io device list. - */ - parse->io.clock_recv = parse->binding->bd_receive; /* pick correct receive routine */ - parse->io.srcclock = (caddr_t)parse; - parse->io.datalen = 0; - parse->io.fd = parse->fd; /* replicated, but what the heck */ - if (!io_addclock(&parse->io)) - { - if (parse->parse_type->cl_flags & PARSE_F_NOPOLLONLY) - { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_start: addclock %s fails (ABORT - clock type requires async io)", CL_UNIT(parse->unit), parsedev); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - else - { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_start: addclock %s fails (switching to polling mode)", CL_UNIT(parse->unit), parsedev); - } - } - else - { - parse->pollonly = 0; /* - * update at receipt of time_stamp - also - * supports PPS processing - */ - } - } - -#ifdef PPSPPS - if (parse->pollonly && (parse->parse_type->cl_flags & PARSE_F_PPSPPS)) - { - if (fdpps == -1) - { - fdpps = parse->fd; - if (!PARSE_DISABLE(parse)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_disable() FAILED", CL_UNIT(parse->unit)); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - } - else - { - syslog(LOG_NOTICE, "PARSE receiver #%d: parse_start: loopfilter PPS already active - no PPS via CIOGETEV", CL_UNIT(parse->unit)); - } - } -#endif - - /* - * wind up statistics timer - */ - parse->stattimer.peer = (struct peer *)parse; /* we know better, but what the heck */ - parse->stattimer.event_handler = cparse_statistics; - parse->stattimer.event_time = current_time + PARSESTATISTICS; - TIMER_ENQUEUE(timerqueue, &parse->stattimer); - - /* - * get out Copyright information once - */ - if (!notice) - { - syslog(LOG_INFO, "NTP PARSE support: Copyright (c) 1989-1993, Frank Kardel"); - notice = 1; - } - - /* - * print out configuration - */ - syslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" (device %s) added", - CL_UNIT(parse->unit), - parse->parse_type->cl_description, parsedev); - - syslog(LOG_INFO, "PARSE receiver #%d: Stratum %d, %sPPS support, trust time %s, precision %d", - CL_UNIT(parse->unit), - parse->peer->stratum, (parse->pollonly || !CL_PPS(parse->unit)) ? "no " : "", - l_mktime(parse->parse_type->cl_maxunsync), parse->peer->precision); - - syslog(LOG_INFO, "PARSE receiver #%d: rootdelay %s s, phaseadjust %s s, %s IO handling", - CL_UNIT(parse->unit), - ufptoa(parse->parse_type->cl_rootdelay, 6), - lfptoa(&parse->basedelay, 8), - parse->binding->bd_description); - - syslog(LOG_INFO, "PARSE receiver #%d: Format recognition: %s", CL_UNIT(parse->unit), - !(*parse->parse_type->cl_format) ? "" : parse->parse_type->cl_format); - -#ifdef PPSPPS - syslog(LOG_INFO, "PARSE receiver #%d: %sCD PPS support", - CL_UNIT(parse->unit), - (fdpps == parse->fd) ? "" : "NO "); -#endif - - return 1; -} - -/*-------------------------------------------------- - * parse_poll - called by the transmit procedure - */ -static void -parse_poll(unit, peer) - int unit; - struct peer *peer; -{ - register struct parseunit *parse; - - unit = CL_UNIT(unit); - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll: INTERNAL: unit invalid", - unit); - return; - } - - parse = parseunits[unit]; - - if (!parse->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll: INTERNAL: unit unused", - unit); - return; - } - - if (peer != parse->peer) - { - syslog(LOG_ERR, - "PARSE receiver #%d: poll: INTERNAL: peer incorrect", - unit); - return; - } - - /* - * Update clock stat counters - */ - parse->polls++; - - /* - * in PPS mode we just mark that we want the next sample - * for the clock filter - */ - if (!parse->pollonly) - { - if (parse->pollneeddata) - { - /* - * bad news - didn't get a response last time - */ - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device within poll interval", CL_UNIT(parse->unit)); - } - parse->pollneeddata = 1; - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - return; - } - - /* - * the following code is only executed only when polling is used - */ - - PARSE_POLL(parse); -} - -/*-------------------------------------------------- - * parse_leap - called when a leap second occurs - */ - -static void -parse_leap() -{ - /* - * PARSE encodes the LEAP correction direction. - * For timecodes that do not pass on the leap correction direction - * the default PARSEB_LEAPADD must be used. It may then be modified - * with a fudge flag (flag2). - */ -} - - -/*-------------------------------------------------- - * parse_control - set fudge factors, return statistics - */ -static void -parse_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct parseunit *parse; - parsectl_t tmpctl; - u_long type; - static char outstatus[400]; /* status output buffer */ - - type = CL_TYPE(unit); - unit = CL_UNIT(unit); - - if (out) - { - out->lencode = 0; - out->lastcode = 0; - out->polls = out->noresponse = 0; - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; - out->kv_list = (struct ctl_var *)0; - } - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: unit invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - parse = parseunits[unit]; - - if (!parse || !parse->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: unit invalid (UNIT INACTIVE)", - unit); - return; - } - - if (in) - { - if (in->haveflags & CLK_HAVETIME1) - parse->basedelay = in->fudgetime1; - - if (in->haveflags & CLK_HAVETIME2) - { - parse->ppsdelay = in->fudgetime2; - } - - if (in->haveflags & CLK_HAVEVAL1) - { - parse->peer->stratum = (u_char)(in->fudgeval1 & 0xf); - if (parse->peer->stratum <= 1) - memmove((char *)&parse->peer->refid, - parse->parse_type->cl_id, - 4); - else - parse->peer->refid = htonl(PARSEHSREFID); - } - - if (in->haveflags & CLK_HAVEVAL2) - { - parse->peer->refid = in->fudgeval2; - } - - if (in->haveflags & (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4)) - { - parse->flags = (in->flags & (CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)) | - (parse->flags & ~PARSE_STAT_FLAGS); - } - - if (in->haveflags & (CLK_HAVEVAL2|CLK_HAVETIME2|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4)) - { - parsectl_t tmpctl; - tmpctl.parsestatus.flags = parse->flags & PARSE_STAT_FLAGS; - - if (!PARSE_SETSTAT(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_setstat() FAILED", unit); - } - } - } - - if (out) - { - register u_long sum = 0; - register char *t, *tt; - register struct tm *tm; - register short utcoff; - register char sign; - register int i; - time_t tim; - - outstatus[0] = '\0'; - - out->haveflags = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3; - out->clockdesc = parse->parse_type->cl_description; - - out->fudgetime1 = parse->basedelay; - - out->fudgetime2 = parse->ppsdelay; - - out->fudgeval1 = parse->peer->stratum; - - out->fudgeval2 = parse->peer->refid; - - out->flags = parse->flags & PARSE_STAT_FLAGS; - - out->type = REFCLK_PARSE; - - /* - * figure out skew between PPS and RS232 - just for informational - * purposes - returned in time2 value - */ - if (PARSE_SYNC(parse->time.parse_state)) - { - if (PARSE_PPS(parse->time.parse_state) && PARSE_TIMECODE(parse->time.parse_state)) - { - l_fp off; - - /* - * we have a PPS and RS232 signal - calculate the skew - * WARNING: assumes on TIMECODE == PULSE (timecode after pulse) - */ - off = parse->time.parse_stime.fp; - L_SUB(&off, &parse->time.parse_ptime.fp); /* true offset */ - tt = add_var(&out->kv_list, 40, RO); - sprintf(tt, "refclock_ppsskew=%s", lfptoms(&off, 6)); - } - } - - if (PARSE_PPS(parse->time.parse_state)) - { - tt = add_var(&out->kv_list, 80, RO|DEF); - sprintf(tt, "refclock_ppstime=\"%s\"", prettydate(&parse->time.parse_ptime.fp)); - } - - /* - * all this for just finding out the +-xxxx part (there are always - * new and changing fields in the standards 8-(). - * - * but we do it for the human user... - */ - tim = parse->time.parse_time.fp.l_ui - JAN_1970; - tm = gmtime(&tim); - utcoff = tm->tm_hour * 60 + tm->tm_min; - tm = localtime(&tim); - utcoff = tm->tm_hour * 60 + tm->tm_min - utcoff + 12 * 60; - utcoff += 24 * 60; - utcoff %= 24 * 60; - utcoff -= 12 * 60; - if (utcoff < 0) - { - utcoff = -utcoff; - sign = '-'; - } - else - { - sign = '+'; - } - - tt = add_var(&out->kv_list, 128, RO|DEF); - sprintf(tt, "refclock_time=\""); - tt += strlen(tt); - - if (parse->time.parse_time.fp.l_ui == 0) - { - strcpy(tt, "\""); - } - else - { - strcpy(tt, prettydate(&parse->time.parse_time.fp)); - t = tt + strlen(tt); - - sprintf(t, " (%c%02d%02d)\"", sign, utcoff / 60, utcoff % 60); - } - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_timecode() FAILED", unit); - } - else - { - tt = add_var(&out->kv_list, 128, RO|DEF); - sprintf(tt, "refclock_status=\""); - tt += strlen(tt); - - /* - * copy PPS flags from last read transaction (informational only) - */ - tmpctl.parsegettc.parse_state |= parse->time.parse_state & - (PARSEB_PPS|PARSEB_S_PPS); - - (void) parsestate(tmpctl.parsegettc.parse_state, tt); - - strcat(tt, "\""); - - if (tmpctl.parsegettc.parse_count) - mkascii(outstatus+strlen(outstatus), sizeof(outstatus)- strlen(outstatus) - 1, - tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1); - - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - - tmpctl.parseformat.parse_format = tmpctl.parsegettc.parse_format; - - if (!PARSE_GETFMT(parse, &tmpctl)) - { - syslog (LOG_ERR, "PARSE receiver #%d: parse_control: parse_getfmt() FAILED", unit); - } - else - { - tt = add_var(&out->kv_list, 80, RO|DEF); - sprintf(tt, "refclock_format=\""); - - strncat(tt, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count); - strcat(tt,"\""); - } - - /* - * gather state statistics - */ - - tt = add_var(&out->kv_list, 200, RO|DEF); - strcpy(tt, "refclock_states=\""); - tt += strlen(tt); - - for (i = 0; i <= CEVNT_MAX; i++) - { - register u_long stime; - register u_long div = current_time - parse->timestarted; - register u_long percent; - - percent = stime = PARSE_STATETIME(parse, i); - - while (((u_long)(~0) / 10000) < percent) - { - percent /= 10; - div /= 10; - } - - if (div) - percent = (percent * 10000) / div; - else - percent = 10000; - - if (stime) - { - sprintf(tt, "%s%s%s: %s (%d.%02d%%)", - sum ? "; " : "", - (parse->status == i) ? "*" : "", - clockstatus(i), - l_mktime(stime), - (int)(percent / 100), (int)(percent % 100)); - sum += stime; - tt += strlen(tt); - } - } - - sprintf(tt, "; running time: %s\"", l_mktime(sum)); - - tt = add_var(&out->kv_list, 32, RO); - sprintf(tt, "refclock_id=\"%s\"", parse->parse_type->cl_id); - - tt = add_var(&out->kv_list, 80, RO); - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); - sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.59 1994/05/23 16:29:27 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; - out->timereset = parse->timestarted; - out->polls = parse->polls; - out->noresponse = parse->noresponse; - out->badformat = parse->badformat; - out->baddata = parse->baddata; - out->lastevent = parse->lastevent; - out->currentstatus = parse->status; - } -} - -/**=========================================================================== - ** processing routines - **/ - -/*-------------------------------------------------- - * event handling - note that nominal events will also be posted - */ -static void -parse_event(parse, event) - struct parseunit *parse; - int event; -{ - if (parse->status != (u_char) event) - { - parse->statetime[parse->status] += current_time - parse->lastchange; - parse->lastchange = current_time; - - parse->status = (u_char)event; - if (event != CEVNT_NOMINAL) - parse->lastevent = parse->status; - - report_event(EVNT_PEERCLOCK, parse->peer); - } -} - -/*-------------------------------------------------- - * process a PARSE time sample - */ -static void -parse_process(parse, parsetime) - struct parseunit *parse; - parsetime_t *parsetime; -{ - unsigned char leap; - struct timeval usecdisp; - l_fp off, rectime, reftime, dispersion; - - /* - * check for changes in conversion status - * (only one for each new status !) - */ - if (parse->laststatus != parsetime->parse_status) - { - char buffer[200]; - - syslog(LOG_WARNING, "PARSE receiver #%d: conversion status \"%s\"", - CL_UNIT(parse->unit), parsestatus(parsetime->parse_status, buffer)); - - if ((parsetime->parse_status & CVT_MASK) == CVT_FAIL) - { - /* - * tell more about the story - list time code - * there is a slight change for a race condition and - * the time code might be overwritten by the next packet - */ - parsectl_t tmpctl; - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_process: parse_timecode() FAILED", CL_UNIT(parse->unit)); - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: FAILED TIMECODE: \"%s\"", - CL_UNIT(parse->unit), mkascii(buffer, sizeof buffer, tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1)); - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - } - - parse->laststatus = parsetime->parse_status; - } - - /* - * examine status and post appropriate events - */ - if ((parsetime->parse_status & CVT_MASK) != CVT_OK) - { - /* - * got bad data - tell the rest of the system - */ - switch (parsetime->parse_status & CVT_MASK) - { - case CVT_NONE: - break; /* well, still waiting - timeout is handled at higher levels */ - - case CVT_FAIL: - parse->badformat++; - if (parsetime->parse_status & CVT_BADFMT) - { - parse_event(parse, CEVNT_BADREPLY); - } - else - if (parsetime->parse_status & CVT_BADDATE) - { - parse_event(parse, CEVNT_BADDATE); - } - else - if (parsetime->parse_status & CVT_BADTIME) - { - parse_event(parse, CEVNT_BADTIME); - } - else - { - parse_event(parse, CEVNT_BADREPLY); /* for the lack of something better */ - } - } - return; /* skip the rest - useless */ - } - - /* - * check for format changes - * (in case somebody has swapped clocks 8-) - */ - if (parse->lastformat != parsetime->parse_format) - { - parsectl_t tmpctl; - - tmpctl.parseformat.parse_format = parsetime->parse_format; - - if (!PARSE_GETFMT(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_getfmt() FAILED", CL_UNIT(parse->unit)); - } - else - { - syslog(LOG_INFO, "PARSE receiver #%d: new packet format \"%s\"", - CL_UNIT(parse->unit), tmpctl.parseformat.parse_buffer); - } - parse->lastformat = parsetime->parse_format; - } - - /* - * now, any changes ? - */ - if (parse->time.parse_state != parsetime->parse_state) - { - char tmp1[200]; - char tmp2[200]; - /* - * something happend - */ - - (void) parsestate(parsetime->parse_state, tmp1); - (void) parsestate(parse->time.parse_state, tmp2); - - syslog(LOG_INFO,"PARSE receiver #%d: STATE CHANGE: %s -> %s", - CL_UNIT(parse->unit), tmp2, tmp1); - } - - /* - * remember for future - */ - parse->time = *parsetime; - - /* - * check to see, whether the clock did a complete powerup or lost PZF signal - * and post correct events for current condition - */ - if (PARSE_POWERUP(parsetime->parse_state)) - { - /* - * this is bad, as we have completely lost synchronisation - * well this is a problem with the receiver here - * for PARSE U/A 31 the lost synchronisation ist true - * as it is the powerup state and the time is taken - * from a crude real time clock chip - * for the PZF series this is only partly true, as - * PARSE_POWERUP only means that the pseudo random - * phase shift sequence cannot be found. this is only - * bad, if we have never seen the clock in the SYNC - * state, where the PHASE and EPOCH are correct. - * for reporting events the above business does not - * really matter, but we can use the time code - * even in the POWERUP state after having seen - * the clock in the synchronized state (PZF class - * receivers) unless we have had a telegram disruption - * after having seen the clock in the SYNC state. we - * thus require having seen the clock in SYNC state - * *after* having missed telegrams (noresponse) from - * the clock. one problem remains: we might use erroneously - * POWERUP data if the disruption is shorter than 1 polling - * interval. fortunately powerdowns last usually longer than 64 - * seconds and the receiver is at least 2 minutes in the - * POWERUP or NOSYNC state before switching to SYNC - */ - parse_event(parse, CEVNT_FAULT); - if (parse->nosynctime) - { - /* - * repeated POWERUP/NOSYNC state - look whether - * the message should be repeated - */ - if (current_time - parse->nosynctime > PARSENOSYNCREPEAT) - { - syslog(LOG_ERR,"PARSE receiver #%d: *STILL* NOT SYNCHRONIZED (POWERUP or no PZF signal)", - CL_UNIT(parse->unit)); - parse->nosynctime = current_time; - } - } - else - { - syslog(LOG_ERR,"PARSE receiver #%d: NOT SYNCHRONIZED", - CL_UNIT(parse->unit)); - parse->nosynctime = current_time; - } - } - else - { - /* - * we have two states left - * - * SYNC: - * this state means that the EPOCH (timecode) and PHASE - * information has be read correctly (at least two - * successive PARSE timecodes were received correctly) - * this is the best possible state - full trust - * - * NOSYNC: - * The clock should be on phase with respect to the second - * signal, but the timecode has not been received correctly within - * at least the last two minutes. this is a sort of half baked state - * for PARSE U/A 31 this is bad news (clock running without timecode - * confirmation) - * PZF 535 has also no time confirmation, but the phase should be - * very precise as the PZF signal can be decoded - */ - parse->nosynctime = 0; /* current state is better than worst state */ - - if (PARSE_SYNC(parsetime->parse_state)) - { - /* - * currently completely synchronized - best possible state - */ - parse->lastsync = current_time; - /* - * log OK status - */ - parse_event(parse, CEVNT_NOMINAL); - } - else - { - /* - * we have had some problems receiving the time code - */ - parse_event(parse, CEVNT_PROP); - } - } - - if (PARSE_TIMECODE(parsetime->parse_state)) - { - l_fp offset; - - /* - * calculate time offset including systematic delays - * off = PARSE-timestamp + propagation delay - kernel time stamp - */ - offset = parse->basedelay; - - off = parsetime->parse_time.fp; - - reftime = off; - - L_ADD(&off, &offset); - rectime = off; /* this makes org time and xmt time somewhat artificial */ - - L_SUB(&off, &parsetime->parse_stime.fp); - - if ((parse->flags & PARSE_STAT_FILTER) && - (off.l_i > -60) && - (off.l_i < 60)) /* take usec error only if within +- 60 secs */ - { - struct timeval usecerror; - /* - * offset is already calculated - */ - usecerror.tv_sec = parsetime->parse_usecerror / 1000000; - usecerror.tv_usec = parsetime->parse_usecerror % 1000000; - - sTVTOTS(&usecerror, &off); - L_ADD(&off, &offset); - } - } - - if (PARSE_PPS(parsetime->parse_state) && CL_PPS(parse->unit)) - { - l_fp offset; - - /* - * we have a PPS signal - much better than the RS232 stuff (we hope) - */ - offset = parsetime->parse_ptime.fp; - - L_ADD(&offset, &parse->ppsdelay); - - if (PARSE_TIMECODE(parsetime->parse_state)) - { - if (M_ISGEQ(off.l_i, off.l_f, -1, 0x80000000) && - M_ISGEQ(0, 0x7fffffff, off.l_i, off.l_f)) - { - /* - * RS232 offsets within [-0.5..0.5[ - take PPS offsets - */ - - if (parse->parse_type->cl_flags & PARSE_F_PPSONSECOND) - { - reftime = off = offset; - rectime = offset; - /* - * implied on second offset - */ - off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */ - off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */ - } - else - { - /* - * time code describes pulse - */ - off = parsetime->parse_time.fp; - - rectime = reftime = off; /* take reference time - fake rectime */ - - L_SUB(&off, &offset); /* true offset */ - } - } - /* - * take RS232 offset when PPS when out of bounds - */ - } - else - { - /* - * Well, no time code to guide us - assume on second pulse - * and pray, that we are within [-0.5..0.5[ - */ - reftime = off = offset; - rectime = offset; - /* - * implied on second offset - */ - off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */ - off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */ - } - } - else - { - if (!PARSE_TIMECODE(parsetime->parse_state)) - { - /* - * Well, no PPS, no TIMECODE, no more work ... - */ - return; - } - } - - -#if defined(PPS) || defined(PPSCLK) || defined(PPSPPS) || defined(PARSEPPS) - if (CL_PPS(parse->unit) && !parse->pollonly && PARSE_SYNC(parsetime->parse_state)) - { - /* - * only provide PPS information when clock - * is in sync - * thus PHASE and EPOCH are correct and PPS is not - * done via the CIOGETEV loopfilter mechanism - */ -#ifdef PPSPPS - if (fdpps != parse->fd) -#endif - (void) pps_sample(&off); - } -#endif /* PPS || PPSCLK || PPSPPS || PARSEPPS */ - - /* - * ready, unless the machine wants a sample - */ - if (!parse->pollonly && !parse->pollneeddata) - return; - - parse->pollneeddata = 0; - - if (PARSE_PPS(parsetime->parse_state)) - { - L_CLR(&dispersion); - } - else - { - /* - * convert usec dispersion into NTP TS world - */ - - usecdisp.tv_sec = parsetime->parse_usecdisp / 1000000; - usecdisp.tv_usec = parsetime->parse_usecdisp % 1000000; - - TVTOTS(&usecdisp, &dispersion); - } - - /* - * and now stick it into the clock machine - * samples are only valid iff lastsync is not too old and - * we have seen the clock in sync at least once - * after the last time we didn't see an expected data telegram - * see the clock states section above for more reasoning - */ - if (((current_time - parse->lastsync) > parse->parse_type->cl_maxunsync) || - (parse->lastsync <= parse->lastmissed)) - { - leap = LEAP_NOTINSYNC; - } - else - { - if (PARSE_LEAPADD(parsetime->parse_state)) - { - /* - * we pick this state also for time code that pass leap warnings - * without direction information (as earth is currently slowing - * down). - */ - leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND; - } - else - if (PARSE_LEAPDEL(parsetime->parse_state)) - { - leap = LEAP_DELSECOND; - } - else - { - leap = LEAP_NOWARNING; - } - } - - refclock_receive(parse->peer, &off, 0, LFPTOFP(&dispersion), &reftime, &rectime, leap); -} - -/**=========================================================================== - ** clock polling support - **/ - -struct poll_timer -{ - struct event timer; /* we'd like to poll a a higher rate than 1/64s */ -}; - -typedef struct poll_timer poll_timer_t; - -/*-------------------------------------------------- - * direct poll routine - */ -static void -poll_dpoll(parse) - struct parseunit *parse; -{ - register int rtc; - register char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string; - register int ct = ((poll_info_t *)parse->parse_type->cl_data)->count; - - rtc = write(parse->fd, ps, ct); - if (rtc < 0) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd to clock: %m", CL_UNIT(parse->unit)); - } - else - if (rtc != ct) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%d of %d bytes sent)", CL_UNIT(parse->unit), rtc, ct); - } -} - -/*-------------------------------------------------- - * periodic poll routine - */ -static void -poll_poll(parse) - struct parseunit *parse; -{ - register poll_timer_t *pt = (poll_timer_t *)parse->localdata; - - poll_dpoll(parse); - - if (pt != (poll_timer_t *)0) - { - pt->timer.event_time = current_time + ((poll_info_t *)parse->parse_type->cl_data)->rate; - TIMER_ENQUEUE(timerqueue, &pt->timer); - } -} - -/*-------------------------------------------------- - * init routine - setup timer - */ -static int -poll_init(parse) - struct parseunit *parse; -{ - register poll_timer_t *pt; - - if (((poll_info_t *)parse->parse_type->cl_data)->rate) - { - parse->localdata = (void *)malloc(sizeof(poll_timer_t)); - memset((char *)parse->localdata, 0, sizeof(poll_timer_t)); - - pt = (poll_timer_t *)parse->localdata; - - pt->timer.peer = (struct peer *)parse; /* well, only we know what it is */ - pt->timer.event_handler = poll_poll; - poll_poll(parse); - } - else - { - parse->localdata = (void *)0; - } - - return 0; -} - -/*-------------------------------------------------- - * end routine - clean up timer - */ -static void -poll_end(parse) - struct parseunit *parse; -{ - if (parse->localdata != (void *)0) - { - TIMER_DEQUEUE(&((poll_timer_t *)parse->localdata)->timer); - free((char *)parse->localdata); - parse->localdata = (void *)0; - } -} - -/**=========================================================================== - ** special code for special clocks - **/ - -/*-------------------------------------------------- - * trimble init routine - setup EOL and then do poll_init. - */ -static int -trimble_init(parse) - struct parseunit *parse; -{ -#ifdef HAVE_TERMIOS - struct termios tm; -#endif -#ifdef HAVE_SYSV_TTYS - struct termio tm; -#endif - /* - * configure terminal line for trimble receiver - */ - if (TTY_GETATTR(parse->fd, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: trimble_init: tcgetattr(fd, &tm): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - tm.c_cc[VEOL] = TRIMBLESV6_EOL; - - if (TTY_SETATTR(parse->fd, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: trimble_init: tcsetattr(fd, &tm): %m", CL_UNIT(parse->unit)); - return 0; - } - } - return poll_init(parse); -} -#endif /* defined(REFCLOCK) && defined(PARSE) */ - -/* - * History: - * - * refclock_parse.c,v - * Revision 3.59 1994/05/23 16:29:27 kardel - * IGEL clock - Trimble update - * - * Revision 3.58 1994/05/12 21:03:39 kardel - * adhere to new standard that fudgeval2 is refid - * - * Revision 3.57 1994/05/12 12:50:47 kardel - * printf fmt/arg cleanup - * - * Revision 3.56 1994/05/10 21:15:51 kardel - * var reference level bug, kernel disable fix - * - * Revision 3.55 1994/05/02 00:37:01 kardel - * 3.3t reconcilation + bug fixes (PPS simulation - old kpll) - * - * Revision 3.54 1994/04/11 19:34:42 kardel - * longer input characters for DCF77 raw input (8Bit+parity ignored) - * - * Revision 3.53 1994/03/25 13:07:39 kardel - * fixed offset calculation for large (>4 Min) offsets - * - * Revision 3.52 1994/03/03 09:58:00 kardel - * stick -kv in cvs is no fun - * - * Revision 3.49 1994/02/20 13:26:00 kardel - * rcs id cleanup - * - * Revision 3.48 1994/02/20 13:04:56 kardel - * parse add/delete second support - * - * Revision 3.47 1994/02/02 17:44:30 kardel - * rcs ids fixed - * - * Revision 3.45 1994/01/25 19:06:27 kardel - * 94/01/23 reconcilation - * - * Revision 3.44 1994/01/25 17:32:23 kardel - * settable extended variables - * - * Revision 3.43 1994/01/23 16:28:39 kardel - * HAVE_TERMIOS introduced - * - * Revision 3.42 1994/01/22 11:35:04 kardel - * added HAVE_TERMIOS - * - * Revision 3.41 1993/11/27 18:44:37 kardel - * can't trust GPS166 on unsync - * - * Revision 3.40 1993/11/21 18:03:36 kardel - * useless declaration deleted - * - * Revision 3.39 1993/11/21 15:30:15 kardel - * static funcitions may be declared only at outer level - * - * Revision 3.38 1993/11/15 21:26:49 kardel - * conditional define comments fixed - * - * Revision 3.37 1993/11/11 11:20:49 kardel - * declaration fixes - * - * Revision 3.36 1993/11/10 12:17:14 kardel - * #ifdef glitch - * - * Revision 3.35 1993/11/01 21:15:06 kardel - * comments updated - * - * Revision 3.34 1993/11/01 20:01:08 kardel - * parse Solaris support (initial version) - * - * Revision 3.33 1993/10/30 09:44:58 kardel - * conditional compilation flag cleanup - * - * Revision 3.32 1993/10/22 14:28:43 kardel - * Oct. 22nd 1993 reconcilation - * - * Revision 3.31 1993/10/10 21:19:10 kardel - * compilation cleanup - (minimal porting tests) - * - * Revision 3.30 1993/10/09 21:44:35 kardel - * syslog strings fixed - * - * Revision 3.29 1993/10/09 14:40:15 kardel - * default precision setting fixed - * - * Revision 3.28 1993/10/08 14:48:22 kardel - * Changed offset determination logic: - * Take the PPS offset if it is available and the time - * code offset is within [-0.5..0.5[, otherwise stick - * to the time code offset - * - * Revision 3.27 1993/10/08 00:53:17 kardel - * announce also simulated PPS via CIOGETEV in ntpq cl - * - * Revision 3.26 1993/10/07 23:29:35 kardel - * trimble fixes - * - * Revision 3.25 1993/10/06 21:13:35 kardel - * test reversed (CIOGETEV support) - * - * Revision 3.24 1993/10/03 20:18:26 kardel - * Well, values > 999999 in the usec field from uniqtime() timestamps - * can prove harmful. - * - * Revision 3.23 1993/10/03 19:49:54 kardel - * buftvtots where failing on uninitialized time stamps - * - * Revision 3.22 1993/10/03 19:11:09 kardel - * restructured I/O handling - * - * Revision 3.21 1993/09/29 11:30:18 kardel - * special init for trimble to set EOL - * - * Revision 3.20 1993/09/27 22:46:28 kardel - * preserve module stack if I_PUSH parse fails - * - * Revision 3.19 1993/09/27 21:10:11 kardel - * wrong structure member - * - * Revision 3.18 1993/09/27 13:05:06 kardel - * Trimble is true polling only - * - * Revision 3.17 1993/09/27 12:47:10 kardel - * poll string support generalized - * - * Revision 3.16 1993/09/26 23:40:56 kardel - * new parse driver logic - * - * Revision 3.15 1993/09/24 15:00:51 kardel - * Sep 23rd distribution... - * - * Revision 3.14 1993/09/22 18:21:15 kardel - * support ppsclock streams module (-DSTREAM -DPPSPPS -DPARSEPPS -UPARSESTREAM) - * - * Revision 3.13 1993/09/05 15:38:33 kardel - * not every cpp understands #error... - * - * Revision 3.12 1993/09/02 20:04:19 kardel - * TTY cleanup - * - * Revision 3.11 1993/09/01 21:48:47 kardel - * conditional cleanup - * - * Revision 3.10 1993/09/01 11:32:45 kardel - * assuming HAVE_POSIX_TTYS when STREAM defined - * - * Revision 3.9 1993/08/31 22:31:46 kardel - * SINIX-M SysVR4 integration - * - * Revision 3.8 1993/08/27 00:29:50 kardel - * compilation cleanup - * - * Revision 3.7 1993/08/24 22:27:30 kardel - * cleaned up AUTOCONF DCF77 mess 8-) - wasn't too bad - * - * Revision 3.6 1993/08/24 21:36:23 kardel - * casting and ifdefs - * - * Revision 3.5 1993/07/09 23:36:59 kardel - * HAVE_POSIX_TTYS used to produce errors 8-( - BSD driver support still lacking - * - * Revision 3.4 1993/07/09 12:42:29 kardel - * RAW DCF now officially released - * - * Revision 3.3 1993/07/09 11:50:37 kardel - * running GPS also on 960 to be able to switch GPS/DCF77 - * - * Revision 3.2 1993/07/09 11:37:34 kardel - * Initial restructured version + GPS support - * - * Revision 3.1 1993/07/06 10:01:07 kardel - * DCF77 driver goes generic... - * - */ diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c deleted file mode 100644 index 680f104568bf..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * refclock_datum - clock driver for the Datum watchayamacallit - */ -#if defined(REFCLOCK) && (defined(DATUM) || defined(DATUMCLK) || defined(DATUMPPS)) -/* */ -/*...... Include Files .................................................*/ -/* */ - - -#include -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#if defined(STREAM) -#include -#if defined(WWVBCLK) -#include -#endif /* WWVBCLK */ -#endif /* STREAM */ - -#if defined (WWVBPPS) -#include -#endif /* WWVBPPS */ - -#include "ntp_stdlib.h" - -/* -#include "temp.c" -void set_logfile(); -*/ - - -#define DEBUG_DATUM_PTC - - -/* */ -/*...... #defines ......................................................*/ -/* */ - -/* -#define refclock_datum_pts refclock_wwvb -*/ - -#define MAXUNITS 4 -#define PTSPRECISION (-13) /* precision assumed (about 100 us) */ -#define GMT 7 -#define DATUM_MAX_ERROR 0.100 -#define DATUM_MAX_ERROR2 DATUM_MAX_ERROR*DATUM_MAX_ERROR - -/* */ -/*...... externals .....................................................*/ -/* */ - -extern U_LONG current_time; /* current time (s) */ -extern int debug; /* global debug flag */ - - -/* */ -/*...... My structure ..................................................*/ -/* */ - -struct datum_pts_unit { - struct peer *peer; /* peer used by xntp */ - struct refclockio io; /* io structure used by xntp */ - int PTS_fd; /* file descriptor for PTS */ - int PTS_START; /* ? */ - u_int unit; /* id for unit */ - U_LONG timestarted; /* time started */ - int inuse; /* in use flag */ - l_fp lastrec; - l_fp lastref; - int yearstart; - int coderecv; - int day; /* day */ - int hour; /* hour */ - int minute; /* minutes */ - int second; /* seconds */ - int msec; /* miliseconds */ - int usec; /* miliseconds */ - u_char leap; - char retbuf[8]; /* returned time from the datum pts */ - char nbytes; /* number of bytes received from datum pts */ - double sigma2; /* average squared error (roughly) */ -}; - - -/* */ -/*...... pts static constant variables for internal use ................*/ -/* */ - -static char STOP_GENERATOR[6]; -static char START_GENERATOR[6]; -static char TIME_REQUEST[6]; - -static int nunits; -static struct datum_pts_unit **datum_pts_unit; -static u_char stratumtouse[MAXUNITS]; -static l_fp fudgefactor[MAXUNITS]; - -static FILE *logfile; - -/* */ -/*...... callback functions that xntp knows about ......................*/ -/* */ - -static int datum_pts_start P((u_int, struct peer *)); -static void datum_pts_shutdown P((int)); -static void datum_pts_poll P((int, struct peer *)); -static void datum_pts_control P((u_int, struct refclockstat *, - struct refclockstat *)); -static void datum_pts_init P((void)); -static void datum_pts_buginfo P((int, struct refclockbug *)); - -struct refclock refclock_datum = { - datum_pts_start, - datum_pts_shutdown, - datum_pts_poll, - datum_pts_control, - datum_pts_init, - datum_pts_buginfo, - NOFLAGS -}; - -/* -struct refclock refclock_wvvb = { - datum_pts_start, - datum_pts_shutdown, - datum_pts_poll, - datum_pts_control, - datum_pts_init, - datum_pts_buginfo, - NOFLAGS -}; -*/ - -/* */ -/*...... receive callback functions for xntp ..........................*/ -/* */ - -static void datum_pts_receive P((struct recvbuf *)); - - -/*......................................................................*/ -/* datum_pts_start */ -/*......................................................................*/ - -static int datum_pts_start(unit, peer) - u_int unit; - struct peer *peer; -{ - struct datum_pts_unit **temp_datum_pts_unit; - struct datum_pts_unit *datum_pts; - struct termios arg; - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile, "Starting Datum PTS unit %d\n", unit); - fflush(logfile); -#endif - -/* */ -/*...... create the memory for the new unit ............................*/ -/* */ - - temp_datum_pts_unit = (struct datum_pts_unit **) - malloc((nunits+1)*sizeof(struct datum_pts_unit *)); - if (nunits > 0) memcpy(temp_datum_pts_unit, datum_pts_unit, - nunits*sizeof(struct datum_pts_unit *)); - free(datum_pts_unit); - datum_pts_unit = temp_datum_pts_unit; - datum_pts_unit[nunits] = (struct datum_pts_unit *) - malloc(sizeof(struct datum_pts_unit)); - datum_pts = datum_pts_unit[nunits]; - - datum_pts->unit = unit; - datum_pts->yearstart = 0; - datum_pts->sigma2 = 0.0; - -/* */ -/*...... open the datum pts device .....................................*/ -/* */ - - datum_pts->PTS_fd = open("/dev/ttya",O_RDWR); - - fcntl(datum_pts->PTS_fd, F_SETFL, 0); - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Opening RS232 port ttya with file descriptor %d\n", - datum_pts->PTS_fd); - fflush(logfile); -#endif - -/* */ -/*...... set up the RS232 terminal device information ..................*/ -/* */ - - arg.c_iflag = IGNBRK; - arg.c_oflag = 0; - arg.c_cflag = B9600 | CS8 | CREAD | PARENB | CLOCAL; - arg.c_lflag = 0; - arg.c_line = 0; - arg.c_cc[VMIN] = 0; /* start timeout timer right away */ - arg.c_cc[VTIME] = 30; /* this is a 3 second timout on reads */ - - tcsetattr(datum_pts->PTS_fd, TCSANOW, &arg); - -/* */ -/*...... initialize the io structure ...................................*/ -/* */ - - datum_pts->peer = peer; - datum_pts->timestarted = current_time; - - datum_pts->io.clock_recv = datum_pts_receive; - datum_pts->io.srcclock = (caddr_t)datum_pts; - datum_pts->io.datalen = 0; - datum_pts->io.fd = datum_pts->PTS_fd; - - if (!io_addclock(&(datum_pts->io))) { -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Problem adding clock\n"); - fflush(logfile); -#endif - syslog(LOG_ERR, "Datum_PTS: Problem adding clock"); - } - - peer->precision = PTSPRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - -/* */ -/*...... now add one to the number of units ............................*/ -/* */ - - nunits++; - -/* */ -/*...... return successful code ........................................*/ -/* */ - - return 1; - -} - - -/*......................................................................*/ -/* datum_pts_shutdown */ -/*......................................................................*/ - -static void datum_pts_shutdown(unit) - int unit; -{ - int i,j; - struct datum_pts_unit **temp_datum_pts_unit; - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Shutdown Datum PTS\n"); - fflush(logfile); -#endif - syslog(LOG_ERR, "Datum_PTS: Shutdown Datum PTS"); - -/* */ -/*...... loop until the right unit is found ............................*/ -/* */ - - for (i=0; iunit == unit) { - -/* */ -/*...... found it so close the file descriptor and free up memory .....*/ -/* */ - - io_closeclock(&datum_pts_unit[i]->io); - close(datum_pts_unit[i]->PTS_fd); - free(datum_pts_unit[i]); - -/* */ -/*...... clean up the datum_pts_unit array (no holes) ..................*/ -/* */ - - if (nunits > 1) { - - temp_datum_pts_unit = (struct datum_pts_unit **) - malloc((nunits-1)*sizeof(struct datum_pts_unit *)); - if (i!= 0) memcpy(temp_datum_pts_unit, datum_pts_unit, - i*sizeof(struct datum_pts_unit *)); - - for (j=i+1; junit == unit) { - index = i; - datum_pts = datum_pts_unit[i]; - error_code = write(datum_pts->PTS_fd, TIME_REQUEST, 6); - if (error_code != 6) perror("TIME_REQUEST"); - datum_pts->nbytes = 0; - break; - } - } - - if (index == -1) { -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Error, could not poll unit %d\n",unit); - fflush(logfile); -#endif - syslog(LOG_ERR, "Datum_PTS: Could not poll unit %d",unit); - return; - } - -} - - -/*......................................................................*/ -/* datum_pts_control */ -/*......................................................................*/ - -static void datum_pts_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Control Datum PTS\n"); - fflush(logfile); -#endif -} - - -/*......................................................................*/ -/* datum_pts_init */ -/*......................................................................*/ - -static void datum_pts_init() -{ - -#ifdef DEBUG_DATUM_PTC - logfile = fopen("xntpd.log", "w"); - fprintf(logfile,"Init Datum PTS\n"); - fflush(logfile); -#endif - - memcpy(START_GENERATOR, "//kk01",6); - memcpy(STOP_GENERATOR, "//kk00",6); - memcpy(TIME_REQUEST, "//k/mn",6); - - datum_pts_unit = NULL; - nunits = 0; -} - - -/*......................................................................*/ -/* datum_pts_buginfo */ -/*......................................................................*/ - -static void datum_pts_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Buginfo Datum PTS\n"); - fflush(logfile); -#endif -} - - -/*......................................................................*/ -/* datum_pts_receive */ -/*......................................................................*/ - -static void datum_pts_receive(rbufp) - struct recvbuf *rbufp; -{ - int i; - l_fp tstmp, trtmp, tstmp1; - struct datum_pts_unit *datum_pts; - char *dpt; - int dpend; - time_t tim; - struct tm *loctm; - int tzoff; - int timerr; - double ftimerr, abserr; - - datum_pts = (struct datum_pts_unit *)rbufp->recv_srcclock; - dpt = (char *)&rbufp->recv_space; - dpend = rbufp->recv_length; - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Receive Datum PTS: %d bytes\n", dpend); - fflush(logfile); -#endif - - for (i=0; iretbuf[datum_pts->nbytes+i] = dpt[i]; - } - datum_pts->nbytes += dpend; - - if (datum_pts->nbytes != 7) { - return; - } - - -/* */ -/*...... save the ntp system time ......................................*/ -/* */ - - trtmp = rbufp->recv_time; - datum_pts->lastrec = trtmp; - -/* */ -/*...... convert the time from the buffer ..............................*/ -/* */ - - datum_pts->day = 100*(datum_pts->retbuf[0] & 0x0f) + - 10*((datum_pts->retbuf[1] & 0xf0)>>4) + - (datum_pts->retbuf[1] & 0x0f); - - datum_pts->hour = 10*((datum_pts->retbuf[2] & 0x30)>>4) + - (datum_pts->retbuf[2] & 0x0f); - - datum_pts->minute = 10*((datum_pts->retbuf[3] & 0x70)>>4) + - (datum_pts->retbuf[3] & 0x0f); - - datum_pts->second = 10*((datum_pts->retbuf[4] & 0x70)>>4) + - (datum_pts->retbuf[4] & 0x0f); - - datum_pts->msec = 100*((datum_pts->retbuf[5] & 0xf0) >> 4) + - 10*(datum_pts->retbuf[5] & 0x0f) + - ((datum_pts->retbuf[6] & 0xf0)>>4); - - datum_pts->usec = 1000*datum_pts->msec; - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"day %d, hour %d, minute %d, second %d, msec %d\n", - datum_pts->day, - datum_pts->hour, - datum_pts->minute, - datum_pts->second, - datum_pts->msec); - fflush(logfile); -#endif - -/* */ -/*...... get the GMT time zone offset ..................................*/ -/* */ - - tim = trtmp.l_ui - JAN_1970; - loctm = localtime(&tim); - tzoff = -loctm->tm_gmtoff/3600; - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Time Zone = %d, time (sec) since 1970 = %d\n",tzoff, tim); - fflush(logfile); -#endif - -/* */ -/*...... make sure that we have a good time from the Datum PTS .........*/ -/* */ - - if (!clocktime( datum_pts->day, - datum_pts->hour, - datum_pts->minute, - datum_pts->second, - tzoff, - datum_pts->lastrec.l_ui, - &datum_pts->yearstart, - &datum_pts->lastref.l_ui) ) { - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Error: bad clocktime\n"); - fprintf(logfile,"GMT %d, lastrec %d, yearstart %d, lastref %d\n", - tzoff, - datum_pts->lastrec.l_ui, - datum_pts->yearstart, - datum_pts->lastref.l_ui); - fflush(logfile); -#endif - syslog(LOG_ERR, "Datum_PTS: Bad clocktime"); - - return; - - }else{ - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Good clocktime\n"); - fflush(logfile); -#endif - - } - -/* */ -/*...... we have datum_pts->lastref.l_ui set, get useconds now .........*/ -/* */ - - TVUTOTSF(datum_pts->usec, datum_pts->lastref.l_uf); - -/* */ -/*...... pass the new time to xntpd ....................................*/ -/* */ - - tstmp = datum_pts->lastref; - L_SUB(&tstmp, &datum_pts->lastrec); /* tstmp is the time correction */ - datum_pts->coderecv++; - -/* - set_logfile(logfile); -*/ - - refclock_receive( datum_pts->peer, - &tstmp, - tzoff, - 0, - &datum_pts->lastrec, - &datum_pts->lastrec, - datum_pts->leap ); - timerr = tstmp.l_ui<<20; - timerr |= (tstmp.l_uf>>12) & 0x000fffff; - ftimerr = timerr; - ftimerr /= 1024*1024; - abserr = ftimerr; - if (ftimerr < 0.0) abserr = -ftimerr; - - if (datum_pts->sigma2 == 0.0) { - if (abserr < DATUM_MAX_ERROR) { - datum_pts->sigma2 = abserr*abserr; - }else{ - datum_pts->sigma2 = DATUM_MAX_ERROR2; - } - }else{ - if (abserr < DATUM_MAX_ERROR) { - datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*abserr*abserr; - }else{ - datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*DATUM_MAX_ERROR2; - } - } - -#ifdef DEBUG_DATUM_PTC - fprintf(logfile,"Time error = %f seconds, Sigma Squared = %f\n", - ftimerr, datum_pts->sigma2); - fflush(logfile); -#endif - -/* */ -/*...... make sure that we understand the format for xntp time .........*/ -/* */ - -#ifdef DEBUG_DATUM_PTC - tstmp.l_ui = 2; - TVUTOTSF(123456, tstmp.l_uf); - - timerr = tstmp.l_ui<<20; - timerr |= (tstmp.l_uf>>12) & 0x000fffff; - ftimerr = timerr; - ftimerr /= 1024*1024; - fprintf(logfile,"Test1 2.123456 = %f\n",ftimerr); - fflush(logfile); - - tstmp1.l_ui = 3; - TVUTOTSF(223456, tstmp1.l_uf); - timerr = tstmp1.l_ui<<20; - timerr |= (tstmp1.l_uf>>12) & 0x000fffff; - ftimerr = timerr; - ftimerr /= 1024*1024; - fprintf(logfile,"Test2 3.223456 = %f\n",ftimerr); - fflush(logfile); - - L_SUB(&tstmp, &tstmp1); - timerr = tstmp.l_ui<<20; - timerr |= (tstmp.l_uf>>12) & 0x000fffff; - ftimerr = timerr; - ftimerr /= 1024*1024; - fprintf(logfile,"Test3 -1.100000 = %f\n",ftimerr); - fflush(logfile); -#endif - - -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c deleted file mode 100644 index 2e81e52c8dae..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c +++ /dev/null @@ -1,998 +0,0 @@ -/* - * refclock_gpstm - clock driver for the Kinimetrics Truetime GPSTM/TMD rcvr - * Version 1.0 (from Version 2.0 of the GOES driver, as of 03Jan94) - */ - -#if defined(REFCLOCK) && (defined(GPSTM) || defined(GPSTMCLK) \ - || defined(GPSTMPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#ifdef SYS_BSDI -#undef HAVE_BSD_TTYS -#include -#endif - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif - -#if defined(STREAM) -#include -#if defined(GPSTMCLK) -#include -#endif /* GPSTMCLK */ -#endif /* STREAM */ - -#if defined(GPSTMPPS) -#include -#endif /* GPSTMPPS */ - -#include "ntp_stdlib.h" - -/* - * Support for Kinemetrics Truetime GPS-TM/TMD Receiver - * - * Most of this code is copied from refclock_goes.c with thanks. - * - * the time code looks like follows: - * - * ADDD:HH:MM:SSQCL - * A - control A - * Q Quality indication: indicates possible error of - * ? +/- 500 milliseconds # +/- 50 milliseconds - * * +/- 5 milliseconds . +/- 1 millisecond - * space less than 1 millisecond - * C - Carriage return - * L - Line feed - * The carriage return start bit begins on 0 seconds and extends to 1 bit time. - * - * Flag1 set to 1 will silence the clock side of xntpd, just reading the - * clock without trying to write to it. This is usefull if several - * xntpds listen to the same clock. This has not been tested yet... - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* max number of GPSTM units */ -#define GPSTM232 "/dev/gpstm%d" -#define SPEED232 B9600 /* 9600 baud */ - -/* - * Radio interface parameters - */ -#define MAXDISPERSE (FP_SECOND>>1) /* max error for synchronized clock (0.5 s as an u_fp) */ -#define PRECISION (-20) /* precision assumed (about 1 ms) */ -#define REFID "GPS\0" /* reference id */ -#define DESCRIPTION "Kinemetrics GPS-TM/TMD Receiver" /* who we are */ -#define GMT 0 /* hour offset from Greenwich */ -#define NCODES 3 /* stages of median filter */ -#define BMAX 99 /* timecode buffer length */ -#define CODEDIFF 0x20000000 /* 0.125 seconds as an l_fp fraction */ -#define TIMEOUT 180 /* ping the clock if it's silent this long */ - -/* - * used by the state machine - */ -enum gpstm_event {e_Init, e_F18, e_F50, e_F51, e_TS}; -static enum {Base, Start, F18, F50, F51, F08} State[MAXUNITS]; -static time_t Last[MAXUNITS]; -static void gpstm_doevent P((int, enum gpstm_event)); -static void gpstm_initstate P((int)); - -/* - * Hack to avoid excercising the multiplier. I have no pride. - */ -#define MULBY10(x) (((x)<<3) + ((x)<<1)) - -/* - * Imported from the timer module - */ -extern U_LONG current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * GPSTM unit control structure - */ -struct gpstm_unit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ - l_fp offset[NCODES]; /* recent sample offsets */ - char lastcode[BMAX]; /* last timecode received */ - u_short polled; /* Hand in a time sample? */ - u_char lencode; /* length of last timecode */ - U_LONG lasttime; /* last time clock heard from */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char year; /* year of eternity */ - u_short day; /* day of year */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - u_short msec; /* millisecond of second */ - u_char quality; /* quality character */ - U_LONG yearstart; /* start of current year */ - /* - * Status tallies - */ - U_LONG polls; /* polls sent */ - U_LONG noreply; /* no replies to polls */ - U_LONG coderecv; /* timecodes received */ - U_LONG badformat; /* bad format */ - U_LONG baddata; /* bad data */ - U_LONG timestarted; /* time we started this */ -}; - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct gpstm_unit *gpstm_units[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor1[MAXUNITS]; -static l_fp fudgefactor2[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char readonlyclockflag[MAXUNITS]; -static U_LONG refid[MAXUNITS]; - -/* - * Function prototypes - */ -static void gpstm_init P((void)); -static int gpstm_start P((u_int, struct peer *)); -static void gpstm_shutdown P((int)); -static void gpstm_rep_event P((struct gpstm_unit *, int)); -static void gpstm_receive P((struct recvbuf *)); -static char gpstm_process P((struct gpstm_unit *, l_fp *, u_fp *)); -static void gpstm_poll P((int, struct peer *)); -static void gpstm_control P((u_int, struct refclockstat *, - struct refclockstat *)); -static void gpstm_buginfo P((int, struct refclockbug *)); -static void gpstm_send P((struct gpstm_unit *, char *)); - -struct refclock refclock_gpstm = { - gpstm_start, gpstm_shutdown, gpstm_poll, - gpstm_control, gpstm_init, gpstm_buginfo, NOFLAGS -}; - -/* - * gpstm_init - initialize internal driver data - */ -static void -gpstm_init() -{ - register int i; - /* - * Just zero the data arrays - */ - memset((char *)gpstm_units, 0, sizeof gpstm_units); - memset((char *)unitinuse, 0, sizeof unitinuse); - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor1[i].l_ui = 0; - fudgefactor1[i].l_uf = 0; - fudgefactor2[i].l_ui = 0; - fudgefactor2[i].l_uf = 0; - stratumtouse[i] = 0; - readonlyclockflag[i] = 0; - memcpy((char *)&refid[i], REFID, 4); - } -} - - -/* - * gpstm_start - open the device and initialize data for processing - */ -static int -gpstm_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct gpstm_unit *gpstm; - register int i; - int fd232; - char dev[20]; - - /* - * Check configuration info - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_start: unit %d invalid", unit); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_start: unit %d in use", unit); - return 0; - } - - /* - * Open serial port - */ - (void) sprintf(dev, GPSTM232, unit); - fd232 = open(dev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "gpstm_start: open of %s: %m", dev); - return 0; - } - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TCGETA): %m", dev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TCSETA): %m", dev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The GPSTMCLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The GPSTMPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - ttyp = &ttyb; - - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcgetattr(%s): %m", dev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcsetattr(%s): %m", dev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "gpstm_start: tcflush(%s): %m", dev); - goto screwed; - } -#if defined(STREAM) -#if defined(GPSTMCLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, I_PUSH, clk): %m", dev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, CLK_SETSTR): %m", dev); -#endif /* GPSTMCLK */ -#if defined(GPSTMPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, I_PUSH, ppsclock): %m", dev); - else - fdpps = fd232; -#endif /* GPSTMPPS */ -#endif /* STREAM */ - } -#endif /* HAVE_TERMIOS */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The GPSTMCLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(GPSTMCLK) - int ldisc = CLKLDISC; -#endif /* GPSTMCLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCGETP): %m", dev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(GPSTMCLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* GPSTMCLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCSETP): %m", dev); - goto screwed; - } -#if defined(GPSTMCLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "gpstm_start: ioctl(%s, TIOCSETD): %m", dev); - goto screwed; - } -#endif /* GPSTMCLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Allocate unit structure - */ - if (gpstm_units[unit] != 0) { - gpstm = gpstm_units[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && gpstm_units[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - gpstm = gpstm_units[i]; - gpstm_units[i] = 0; - } else { - gpstm = (struct gpstm_unit *) - emalloc(sizeof(struct gpstm_unit)); - } - } - memset((char *)gpstm, 0, sizeof(struct gpstm_unit)); - gpstm_units[unit] = gpstm; - - /* - * Set up the structures - */ - gpstm->peer = peer; - gpstm->unit = (u_char)unit; - gpstm->timestarted = current_time; - - gpstm->io.clock_recv = gpstm_receive; - gpstm->io.srcclock = (caddr_t)gpstm; - gpstm->io.datalen = 0; - gpstm->io.fd = fd232; - if (!io_addclock(&gpstm->io)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. - */ - peer->precision = PRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - gpstm_initstate(unit); - return 1; - - /* - * Something broke; abandon ship - */ -screwed: - (void) close(fd232); - return 0; -} - -/* - * gpstm_shutdown - shut down a clock - */ -static void -gpstm_shutdown(unit) - int unit; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_shutdown: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - gpstm = gpstm_units[unit]; - io_closeclock(&gpstm->io); - unitinuse[unit] = 0; -} - - -/* - * gpstm_rep_event - note the occurance of an event - */ -static void -gpstm_rep_event(gpstm, code) - struct gpstm_unit *gpstm; - int code; -{ - struct peer *peer; - - peer = gpstm->peer; - if (gpstm->status != (u_char)code) { - gpstm->status = (u_char)code; - if (code != CEVNT_NOMINAL) - gpstm->lastevent = (u_char)code; - syslog(LOG_INFO, - "clock %s event %x\n", ntoa(&peer->srcadr), code); -#ifdef DEBUG - if (debug) { - printf("gpstm_rep_event(gpstm%d, code %d)\n", - gpstm->unit, code); - } -#endif - } - if (code == CEVNT_BADREPLY) - gpstm_initstate(gpstm->unit); -} - - -/* - * gpstm_receive - receive data from the serial interface on a clock - */ -static void -gpstm_receive(rbufp) - struct recvbuf *rbufp; -{ - register int i; - register struct gpstm_unit *gpstm; - register u_char *dpt; - register char *cp; - register u_char *dpend; - l_fp tstmp; - u_fp dispersion; - - /* - * Get the clock this applies to and a pointers to the data - */ - gpstm = (struct gpstm_unit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - - /* - * Edit timecode to remove control chars - */ - dpend = dpt + rbufp->recv_length; - cp = gpstm->lastcode; - while (dpt < dpend) { - if ((*cp = 0x7f & *dpt++) >= ' ') cp++; -#ifdef GPSTMCLK - else if (*cp == '\r') { - if (dpend - dpt < 8) { - /* short timestamp */ - return; - } - if (!buftvtots(dpt,&gpstm->lastrec)) { - /* screwy timestamp */ - return; - } - dpt += 8; - } -#endif - } - *cp = '\0'; - gpstm->lencode = cp - gpstm->lastcode; - if (gpstm->lencode == 0) - return; -#ifndef GPSTMCLK - gpstm->lastrec = rbufp->recv_time; -#endif /* GPSTMCLK */ -#if !defined(GPSTMCLK) && !defined(GPSTMPPS) && defined(TIOCMODT) - do { - auto struct timeval cur, now; - register long usec; - - if (ioctl(gpstm->io.fd, TIOCMODT, &cur) < 0) { - syslog(LOG_ERR, "TIOCMODT: %m"); -#ifdef DEBUG - if (debug) perror("TIOCMODT"); - break; -#endif - } - if (cur.tv_sec == 0) { - /* no timestamps yet */ - if (debug) printf("MODT tv_sec == 0\n"); - break; - } - - gettimeofday(&now, NULL); - usec = 1000000 * (now.tv_sec - cur.tv_sec) - + (now.tv_usec - cur.tv_usec); -#ifdef DEBUG - if (debug) printf("lastmodem: delay=%d us\n", usec); -#endif - if (usec < 0 || usec > 10000) { - /* time warp or stale timestamp */ - break; - } - if (!buftvtots((char *)&cur, &gpstm->lastrec)) { - /* screwy timestamp */ - break; - } - } while (0); -#endif /*TIOCMODT*/ - -#ifdef DEBUG - if (debug) - printf("gpstm: timecode %d %s\n", - gpstm->lencode, gpstm->lastcode); -#endif - - cp = gpstm->lastcode; - gpstm->leap = 0; - if ((cp[0] == 'F' && isdigit(cp[1]) && isdigit(cp[2])) - || (cp[0] == ' ' && cp[1] == 'T' && cp[2] == 'R')) { - enum gpstm_event event; - - syslog(LOG_NOTICE, "gpstm%d: \"%s\"", gpstm->unit, cp); - if (cp[1] == '5' && cp[2] == '0') - event = e_F50; - else if (cp[1] == '5' && cp[2] == '1') - event = e_F51; - else if (!strncmp(" TRUETIME Mk III", cp, 16)) - event = e_F18; - else { - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - gpstm_doevent(gpstm->unit, event); - return; - } else if (gpstm->lencode == 13) { - /* - * Check timecode format 0 - */ - if (!isdigit(cp[0]) /* day of year */ - || !isdigit(cp[1]) - || !isdigit(cp[2]) - || cp[3] != ':' /* : separator */ - || !isdigit(cp[4]) /* hours */ - || !isdigit(cp[5]) - || cp[6] != ':' /* : separator */ - || !isdigit(cp[7]) /* minutes */ - || !isdigit(cp[8]) - || cp[9] != ':' /* : separator */ - || !isdigit(cp[10]) /* seconds */ - || !isdigit(cp[11])) - { - gpstm->badformat++; - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - - /* - * Convert format 0 and check values - */ - gpstm->year = 0; /* fake */ - gpstm->day = cp[0] - '0'; - gpstm->day = MULBY10(gpstm->day) + cp[1] - '0'; - gpstm->day = MULBY10(gpstm->day) + cp[2] - '0'; - gpstm->hour = MULBY10(cp[4] - '0') + cp[5] - '0'; - gpstm->minute = MULBY10(cp[7] - '0') + cp[8] - '0'; - gpstm->second = MULBY10(cp[10] - '0') + cp[11] - '0'; - gpstm->msec = 0; - - if (cp[12] != ' ' && cp[12] != '.' && cp[12] != '*') - gpstm->leap = LEAP_NOTINSYNC; - else - gpstm->lasttime = current_time; - - if (gpstm->day < 1 || gpstm->day > 366) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADDATE); - return; - } - if (gpstm->hour > 23 || gpstm->minute > 59 - || gpstm->second > 59) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - gpstm_doevent(gpstm->unit, e_TS); - } else { - gpstm_rep_event(gpstm, CEVNT_BADREPLY); - return; - } - - /* - * The clock will blurt a timecode every second but we only - * want one when polled. If we havn't been polled, bail out. - */ - if (!gpstm->polled) - return; - - /* - * Now, compute the reference time value. Use the heavy - * machinery for the seconds and the millisecond field for the - * fraction when present. - * - * this code does not yet know how to do the years - */ - tstmp = gpstm->lastrec; - if (!clocktime(gpstm->day, gpstm->hour, gpstm->minute, - gpstm->second, GMT, tstmp.l_ui, - &gpstm->yearstart, &gpstm->lastref.l_ui)) - { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - MSUTOTSF(gpstm->msec, gpstm->lastref.l_uf); - - i = ((int)(gpstm->coderecv)) % NCODES; - gpstm->offset[i] = gpstm->lastref; - L_SUB(&gpstm->offset[i], &tstmp); - if (gpstm->coderecv == 0) - for (i = 1; i < NCODES; i++) - gpstm->offset[i] = gpstm->offset[0]; - - gpstm->coderecv++; - - /* - * Process the median filter, and pass the - * offset and dispersion along. We use lastrec as both the - * reference time and receive time in order to avoid being cute, - * like setting the reference time later than the receive time, - * which may cause a paranoid protocol module to chuck out the - * data. - */ - if (!gpstm_process(gpstm, &tstmp, &dispersion)) { - gpstm->baddata++; - gpstm_rep_event(gpstm, CEVNT_BADTIME); - return; - } - refclock_receive(gpstm->peer, &tstmp, GMT, dispersion, - &gpstm->lastrec, &gpstm->lastrec, gpstm->leap); - - /* - * We have succedded in answering the poll. Turn off the flag - */ - gpstm->polled = 0; -} - -/* - * gpstm_send - time to send the clock a signal to cough up a time sample - */ -static void -gpstm_send(gpstm, cmd) - struct gpstm_unit *gpstm; - char *cmd; -{ -#ifdef DEBUG - if (debug) { - printf("gpstm_send(gpstm%d): %s\n", gpstm->unit, cmd); - } -#endif - if (!readonlyclockflag[gpstm->unit]) { - register int len = strlen(cmd); - - if (write(gpstm->io.fd, cmd, len) != len) { - syslog(LOG_ERR, "gpstm_send: unit %d: %m", - gpstm->unit); - gpstm_rep_event(gpstm, CEVNT_FAULT); - } - } -} - -/* - * state machine for initializing the clock - */ - -static void -gpstm_doevent(unit, event) - int unit; - enum gpstm_event event; -{ - struct gpstm_unit *gpstm = gpstm_units[unit]; - -#ifdef DEBUG - if (debug) { - printf("gpstm_doevent(gpstm%d, %d)\n", unit, (int)event); - } -#endif - if (event == e_TS && State[unit] != F51 && State[unit] != F08) { - gpstm_send(gpstm, "\03\r"); - } - - switch (event) { - case e_Init: - gpstm_send(gpstm, "F18\r"); - State[unit] = Start; - break; - case e_F18: - gpstm_send(gpstm, "F50\r"); - State[unit] = F18; - break; - case e_F50: - gpstm_send(gpstm, "F51\r"); - State[unit] = F50; - break; - case e_F51: - gpstm_send(gpstm, "F08\r"); - State[unit] = F51; - break; - case e_TS: - /* nothing to send - we like this mode */ - State[unit] = F08; - break; - } -} - -static void -gpstm_initstate(unit) { - State[unit] = Base; /* just in case */ - gpstm_doevent(unit, e_Init); -} - -/* - * gpstm_process - process a pile of samples from the clock - */ -static char -gpstm_process(gpstm, offset, dispersion) - struct gpstm_unit *gpstm; - l_fp *offset; - u_fp *dispersion; -{ - register int i, j; - register U_LONG tmp_ui, tmp_uf; - int not_median1 = -1; /* XXX correct? */ - int not_median2 = -1; /* XXX correct? */ - int median; - u_fp disp_tmp, disp_tmp2; - - /* - * This code implements a three-stage median filter. First, we - * check if the samples are within 125 ms of each other. If not, - * dump the sample set. We take the median of the three offsets - * and use that as the sample offset. We take the maximum - * difference and use that as the sample dispersion. There - * probably is not much to be gained by a longer filter, since - * the clock filter in ntp_proto should do its thing. - */ - disp_tmp2 = 0; - for (i = 0; i < NCODES-1; i++) { - for (j = i+1; j < NCODES; j++) { - tmp_ui = gpstm->offset[i].l_ui; - tmp_uf = gpstm->offset[i].l_uf; - M_SUB(tmp_ui, tmp_uf, gpstm->offset[j].l_ui, - gpstm->offset[j].l_uf); - if (M_ISNEG(tmp_ui, tmp_uf)) { - M_NEG(tmp_ui, tmp_uf); - } - if (tmp_ui != 0 || tmp_uf > CODEDIFF) { - return 0; - } - disp_tmp = MFPTOFP(0, tmp_uf); - if (disp_tmp > disp_tmp2) { - disp_tmp2 = disp_tmp; - not_median1 = i; - not_median2 = j; - } - } - } - - /* - * It seems as if all are within 125 ms of each other. - * Now to determine the median of the three. Whlie the - * 125 ms check was going on, we also subtly catch the - * dispersion and set-up for a very easy median calculation. - * The largest difference between any two samples constitutes - * the dispersion. The sample not involve in the dispersion is - * the median sample. EASY! - */ - if (gpstm->lasttime == 0 || disp_tmp2 > MAXDISPERSE) - disp_tmp2 = MAXDISPERSE; - if (not_median1 == 0) { - if (not_median2 == 1) - median = 2; - else - median = 1; - } else { - median = 0; - } - *offset = gpstm->offset[median]; - *dispersion = disp_tmp2; - return 1; -} - -/* - * gpstm_poll - called by the transmit procedure - */ -static void -gpstm_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct gpstm_unit *gpstm; - - /* - * You don't need to poll this clock. It puts out timecodes - * once per second. If asked for a timestamp, take note. - * The next time a timecode comes in, it will be fed back. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "gpstm_poll: unit %d not in use", unit); - return; - } - gpstm = gpstm_units[unit]; - if ((current_time - gpstm->lasttime) > 150) { - gpstm->noreply++; - gpstm_rep_event(gpstm_units[unit], CEVNT_TIMEOUT); - gpstm_initstate(gpstm->unit); - } - - /* - * polled every 64 seconds. Ask our receiver to hand in a timestamp. - */ - gpstm->polled = 1; - gpstm->polls++; -} - -/* - * gpstm_control - set fudge factors, return statistics - */ -static void -gpstm_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_control: unit %d invalid", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor1[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - fudgefactor2[unit] = in->fudgetime2; - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (in->haveflags & CLK_HAVEFLAG1) - readonlyclockflag[unit] = in->flags & CLK_FLAG1; - if (unitinuse[unit]) { - struct peer *peer; - - peer = gpstm_units[unit]->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out != 0) { - memset((char *)out, 0, sizeof (struct refclockstat)); - out->type = REFCLK_GPSTM_TRUETIME; - out->haveflags = CLK_HAVETIME1 | CLK_HAVETIME2 | CLK_HAVEVAL1 | - CLK_HAVEVAL2 | CLK_HAVEFLAG1; - out->clockdesc = DESCRIPTION; - out->fudgetime1 = fudgefactor1[unit]; - out->fudgetime2 = fudgefactor2[unit]; - out->fudgeval1 = (LONG)stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->flags = readonlyclockflag[unit]; - if (unitinuse[unit]) { - gpstm = gpstm_units[unit]; - out->lencode = gpstm->lencode; - out->lastcode = gpstm->lastcode; - out->timereset = current_time - gpstm->timestarted; - out->polls = gpstm->polls; - out->noresponse = gpstm->noreply; - out->badformat = gpstm->badformat; - out->baddata = gpstm->baddata; - out->lastevent = gpstm->lastevent; - out->currentstatus = gpstm->status; - } - } -} - -/* - * gpstm_buginfo - return clock dependent debugging info - */ -static void -gpstm_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct gpstm_unit *gpstm; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "gpstm_buginfo: unit %d invalid", unit); - return; - } - - if (!unitinuse[unit]) - return; - gpstm = gpstm_units[unit]; - - bug->nvalues = 11; - bug->ntimes = 5; - if (gpstm->lasttime != 0) - bug->values[0] = current_time - gpstm->lasttime; - else - bug->values[0] = 0; - bug->values[1] = (U_LONG)gpstm->reason; - bug->values[2] = (U_LONG)gpstm->year; - bug->values[3] = (U_LONG)gpstm->day; - bug->values[4] = (U_LONG)gpstm->hour; - bug->values[5] = (U_LONG)gpstm->minute; - bug->values[6] = (U_LONG)gpstm->second; - bug->values[7] = (U_LONG)gpstm->msec; - bug->values[8] = gpstm->noreply; - bug->values[9] = gpstm->yearstart; - bug->values[10] = gpstm->quality; - bug->stimes = 0x1c; - bug->times[0] = gpstm->lastref; - bug->times[1] = gpstm->lastrec; - bug->times[2] = gpstm->offset[0]; - bug->times[3] = gpstm->offset[1]; - bug->times[4] = gpstm->offset[2]; -} - -#endif /*GPSTM et al*/ diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_leitch.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_leitch.c deleted file mode 100644 index 808f65bb4b89..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_leitch.c +++ /dev/null @@ -1,709 +0,0 @@ -/* - * refclock_leitch - clock driver for the Leitch CSD-5300 Master Clock - */ -#if defined(REFCLOCK) && (defined(LEITCH) || defined(LEITCHCLK) || defined(LEITCHPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#ifdef STREAM -#include -#if defined(LEITCHCLK) -#include -#endif /* LEITCHCLK */ -#endif /* STREAM */ - -#if defined (LEITCHPPS) -#include -#endif /* LEITCHPPS */ - -#include "ntp_stdlib.h" - -/* - * Driver for Leitch CSD-5300 Master Clock System - * - * COMMANDS: - * DATE: D - * TIME: T - * STATUS: S - * LOOP: L - * - * FORMAT: - * DATE: YYMMDD - * TIME: /HHMMSS /HHMMSS /HHMMSS / - * second bondaried on the stop bit of the - * second boundaries at '/' above. - * STATUS: G (good), D (diag fail), T (time not provided) or - * P (last phone update failed) - */ -#define MAXUNITS 1 /* max number of LEITCH units */ -#define LEITCHREFID "ATOM" /* reference id */ -#define LEITCH_DESCRIPTION "Leitch: CSD 5300 Master Clock System Driver" -#define LEITCH232 "/dev/leitch%d" /* name of radio device */ -#define SPEED232 B300 /* uart speed (300 baud) */ -#define leitch_send(A,M) \ - if (debug) fprintf(stderr,"write leitch %s\n",M); \ - if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\ - if (debug) \ - fprintf(stderr, "leitch_send: unit %d send failed\n", A->unit); \ - else \ - syslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);} - -#define STATE_IDLE 0 -#define STATE_DATE 1 -#define STATE_TIME1 2 -#define STATE_TIME2 3 -#define STATE_TIME3 4 - -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * LEITCH unit control structure - */ -struct leitchunit { - struct peer *peer; - struct event leitchtimer; - struct refclockio leitchio; - u_char unit; - short year; - short yearday; - short month; - short day; - short hour; - short second; - short minute; - short state; - u_short fudge1; - l_fp reftime1; - l_fp reftime2; - l_fp reftime3; - l_fp codetime1; - l_fp codetime2; - l_fp codetime3; - U_LONG yearstart; -}; - -/* - * Function prototypes - */ -static void leitch_init P((void)); -static int leitch_start P((u_int, struct peer *)); -static void leitch_shutdown P((int)); -static void leitch_poll P((int, struct peer *)); -static void leitch_control P((u_int, struct refclockstat *, struct refclockstat *)); -#define leitch_buginfo noentry -static void leitch_receive P((struct recvbuf *)); -static void leitch_process P((struct leitchunit *)); -static void leitch_timeout P((struct peer *)); -static int leitch_get_date P((struct recvbuf *, struct leitchunit *)); -static int leitch_get_time P((struct recvbuf *, struct leitchunit *, int)); -static int dysize P((int)); - -static struct leitchunit leitchunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static U_LONG refid[MAXUNITS]; - -static char days_in_month [] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - -/* - * Transfer vector - */ -struct refclock refclock_leitch = { - leitch_start, leitch_shutdown, leitch_poll, - leitch_control, leitch_init, leitch_buginfo, NOFLAGS -}; - -/* - * leitch_init - initialize internal leitch driver data - */ -static void -leitch_init() -{ - int i; - - memset((char*)leitchunits, 0, sizeof(leitchunits)); - memset((char*)unitinuse, 0, sizeof(unitinuse)); - for (i = 0; i < MAXUNITS; i++) - memcpy((char *)&refid[i], LEITCHREFID, 4); -} - -/* - * leitch_shutdown - shut down a LEITCH clock - */ -static void -leitch_shutdown(unit) -int unit; -{ -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_shutdown()\n"); -#endif -} - -/* - * leitch_poll - called by the transmit procedure - */ -static void -leitch_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct leitchunit *leitch; - - /* start the state machine rolling */ - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_poll()\n"); -#endif - if (unit > MAXUNITS) { - /* XXXX syslog it */ - return; - } - - leitch = &leitchunits[unit]; - - if (leitch->state != STATE_IDLE) { - /* reset and wait for next poll */ - /* XXXX syslog it */ - leitch->state = STATE_IDLE; - } else { - leitch_send(leitch,"D\r"); - leitch->state = STATE_DATE; - } -} - -static void -leitch_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "leitch_control: unit %d invalid", unit); - return; - } - - if (in) { - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (unitinuse[unit]) { - struct peer *peer; - - peer = (&leitchunits[unit])->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out) { - memset((char *)out, 0, sizeof (struct refclockstat)); - out->type = REFCLK_ATOM_LEITCH; - out->haveflags = CLK_HAVEVAL1 | CLK_HAVEVAL2; - out->fudgeval1 = (LONG)stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->lastcode = ""; - out->clockdesc = LEITCH_DESCRIPTION; - } -} - -/* - * leitch_start - open the LEITCH devices and initialize data for processing - */ -static int -leitch_start(unit, peer) - u_int unit; - struct peer *peer; -{ - struct leitchunit *leitch; - int fd232; - char leitchdev[20]; - - /* - * Check configuration info. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "leitch_start: unit %d invalid", unit); - return (0); - } - - if (unitinuse[unit]) { - syslog(LOG_ERR, "leitch_start: unit %d in use", unit); - return (0); - } - - /* - * Open serial port. - */ - (void) sprintf(leitchdev, LEITCH232, unit); - fd232 = open(leitchdev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, - "leitch_start: open of %s: %m", leitchdev); - return (0); - } - - leitch = &leitchunits[unit]; - memset((char*)leitch, 0, sizeof(*leitch)); - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TCGETA): %m", leitchdev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TCSETA): %m", leitchdev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The LEITCHCLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The LEITCHPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "leitch_start: tcgetattr(%s): %m", leitchdev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "leitch_start: tcsetattr(%s): %m", leitchdev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "leitch_start: tcflush(%s): %m", leitchdev); - goto screwed; - } - } -#endif /* HAVE_TERMIOS */ -#ifdef STREAM -#if defined(LEITCHCLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, I_PUSH, clk): %m", leitchdev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, CLK_SETSTR): %m", leitchdev); -#endif /* LEITCHCLK */ -#if defined(LEITCHPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "leitch_start: ioctl(%s, I_PUSH, ppsclock): %m", leitchdev); - else - fdpps = fd232; -#endif /* LEITCHPPS */ -#endif /* STREAM */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The LEITCHCLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(LEITCHCLK) - int ldisc = CLKLDISC; -#endif /* LEITCHCLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCGETP): %m", leitchdev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(LEITCHCLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* LEITCHCLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCSETP): %m", leitchdev); - goto screwed; - } -#if defined(LEITCHCLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "leitch_start: ioctl(%s, TIOCSETD): %m",leitchdev); - goto screwed; - } -#endif /* LEITCHCLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Set up the structures - */ - leitch->peer = peer; - leitch->unit = unit; - leitch->state = STATE_IDLE; - leitch->fudge1 = 15; /* 15ms */ - - leitch->leitchio.clock_recv = leitch_receive; - leitch->leitchio.srcclock = (caddr_t) leitch; - leitch->leitchio.datalen = 0; - leitch->leitchio.fd = fd232; - if (!io_addclock(&leitch->leitchio)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. Note that root delay and root dispersion are - * always zero for this clock. - */ - peer->precision = 0; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - return(1); - - /* - * Something broke; abandon ship. - */ -screwed: - close(fd232); - return(0); -} - -/* - * leitch_receive - receive data from the serial interface on a leitch - * clock - */ -static void -leitch_receive(rbufp) - struct recvbuf *rbufp; -{ - struct leitchunit *leitch = (struct leitchunit *)rbufp->recv_srcclock; - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_recieve(%*.*s)\n", - rbufp->recv_length, rbufp->recv_length, - rbufp->recv_buffer); -#endif - if (rbufp->recv_length != 7) - return; /* The date is return with a trailing newline, - discard it. */ - - switch (leitch->state) { - case STATE_IDLE: /* unexpected, discard and resync */ - return; - case STATE_DATE: - if (!leitch_get_date(rbufp,leitch)) { - leitch->state = STATE_IDLE; - break; - } - leitch_send(leitch,"T\r"); -#ifdef DEBUG - if (debug) - fprintf(stderr, "%u\n",leitch->yearday); -#endif - leitch->state = STATE_TIME1; - break; - case STATE_TIME1: - if (!leitch_get_time(rbufp,leitch,1)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime1.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%u\n", leitch->reftime1.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime1.l_uf); - leitch->codetime1 = rbufp->recv_time; - leitch->state = STATE_TIME2; - break; - case STATE_TIME2: - if (!leitch_get_time(rbufp,leitch,2)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime2.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%u\n", leitch->reftime2.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime2.l_uf); - leitch->codetime2 = rbufp->recv_time; - leitch->state = STATE_TIME3; - break; - case STATE_TIME3: - if (!leitch_get_time(rbufp,leitch,3)) { - } - if (!clocktime(leitch->yearday,leitch->hour,leitch->minute, - leitch->second, 0, rbufp->recv_time.l_ui, - &leitch->yearstart, &leitch->reftime3.l_ui)) { - leitch->state = STATE_IDLE; - break; - } -#ifdef DEBUG - if (debug) - fprintf(stderr, "%u\n", leitch->reftime3.l_ui); -#endif - MSUTOTSF(leitch->fudge1, leitch->reftime3.l_uf); - leitch->codetime3 = rbufp->recv_time; - leitch_process(leitch); - leitch->state = STATE_IDLE; - break; - default: - syslog(LOG_ERR, - "leitech_receive: invalid state %d unit %d", - leitch->state, leitch->unit); - } -} - -/* - * leitch_process - process a pile of samples from the clock - * - * This routine uses a three-stage median filter to calculate offset and - * dispersion. reduce jitter. The dispersion is calculated as the span - * of the filter (max - min), unless the quality character (format 2) is - * non-blank, in which case the dispersion is calculated on the basis of - * the inherent tolerance of the internal radio oscillator, which is - * +-2e-5 according to the radio specifications. - */ -static void -leitch_process(leitch) - struct leitchunit *leitch; -{ - l_fp off; - s_fp delay; - l_fp codetime; - l_fp tmp_fp; - int isinsync = 1; - u_fp dispersion = 10; - - delay = 20; - - codetime = leitch->codetime3; - - off = leitch->reftime1; - L_SUB(&off,&leitch->codetime1); - -#ifdef DEBUG - if (debug) - fprintf(stderr,"%u %u %u %u %d %d\n", - leitch->codetime1.l_ui, leitch->codetime1.l_uf, - leitch->reftime1.l_ui, leitch->reftime1.l_uf, - off.l_ui, off.l_uf); -#endif - tmp_fp = leitch->reftime2; - L_SUB(&tmp_fp,&leitch->codetime2); - if (L_ISGEQ(&off,&tmp_fp)) - off = tmp_fp; -#ifdef DEBUG - if (debug) - fprintf(stderr,"%u %u %u %u %d %d\n", - leitch->codetime2.l_ui, leitch->codetime2.l_uf, - leitch->reftime2.l_ui, leitch->reftime2.l_uf, - off.l_ui, off.l_uf); -#endif - tmp_fp = leitch->reftime3; - L_SUB(&tmp_fp,&leitch->codetime3); - - if (L_ISGEQ(&off,&tmp_fp)) - off = tmp_fp; - -#ifdef DEBUG - if (debug) - fprintf(stderr,"%u %u %u %u %d %d\n", - leitch->codetime3.l_ui, leitch->codetime3.l_uf, - leitch->reftime3.l_ui, leitch->reftime3.l_uf, - off.l_ui, off.l_uf); -#endif - refclock_receive(leitch->peer, &off, 0, dispersion, &codetime, - &codetime, isinsync); -} - -/* - * leitch_timeout - */ -static void -leitch_timeout(fp) - struct peer *fp; -{ - -#ifdef DEBUG - if (debug) - fprintf(stderr, "leitch_timeout()\n"); -#endif - -#ifdef NOTYET - { struct leitchunit *leitch = (struct leitchunit *)fp; - - switch(leitch->state) { - case STATE_IDLE: - leitch_send(leitch,"D\r"); - leitch->state = STATE_DATE; - break; - case STATE_DATE: - leitch_send(leitch,"T\r"); - leitch->state = STATE_TIME1; - break; - case STATE_TIME1: - case STATE_TIME2: - case STATE_TIME3: - default: - break; - } - - leitch->leitchtimer.event_time += 30; - TIMER_ENQUEUE(timerqueue, &leitch->leitchtimer); - } -#endif /* NOTYET */ -} - -/* - * dysize - */ -static int -dysize(year) -int year; -{ - if (year%4) { /* not a potential leap year */ - return (365); - } else { - if (year % 100) { /* is a leap year */ - return (366); - } else { - if (year % 400) { - return (365); - } else { - return (366); - } - } - } -} - -static int -leitch_get_date(rbufp,leitch) - struct recvbuf *rbufp; - struct leitchunit *leitch; -{ - int i; - - if (rbufp->recv_length < 6) - return(0); -#define BAD(A) (rbufp->recv_buffer[A] < '0') || (rbufp->recv_buffer[A] > '9') - if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5)) - return(0); -#define ATOB(A) ((rbufp->recv_buffer[A])-'0') - leitch->year = ATOB(0)*10 + ATOB(1); - leitch->month = ATOB(2)*10 + ATOB(3); - leitch->day = ATOB(4)*10 + ATOB(5); - - /* sanity checks */ - if (leitch->month > 12) - return(0); - if (leitch->day > days_in_month[leitch->month-1]) - return(0); - - /* calculate yearday */ - i = 0; - leitch->yearday = leitch->day; - - while ( i < (leitch->month-1) ) - leitch->yearday += days_in_month[i++]; - - if ((dysize((leitch->year>90?1900:2000)+leitch->year)==365) && - leitch->month > 2) - leitch->yearday--; - - return(1); -} - -/* - * leitch_get_time - */ -static int -leitch_get_time(rbufp,leitch,which) - struct recvbuf *rbufp; - struct leitchunit *leitch; - int which; -{ - if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5)) - return(0); - leitch->hour = ATOB(0)*10 +ATOB(1); - leitch->minute = ATOB(2)*10 +ATOB(3); - leitch->second = ATOB(4)*10 +ATOB(5); - - if ((leitch->hour > 23) || (leitch->minute > 60) || - (leitch->second > 60)) - return(0); - return(1); -} - -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_msfees.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_msfees.c deleted file mode 100644 index 255d74f285de..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_msfees.c +++ /dev/null @@ -1,1575 +0,0 @@ -/* refclock_ees - clock driver for the EES M201 receiver */ - -#if defined(REFCLOCK) && defined(MSFEESPPS) && defined(STREAM) - -/* Currently REQUIRES STREAM and PPSCD. CLK and CBREAK modes - * were removed as the code was overly hairy, they weren't in use - * (hence probably didn't work). Still in RCS file at cl.cam.ac.uk - */ - -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" -#include "ntp_calendar.h" -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ -#include -#include -#include -#include "ntp_stdlib.h" - - /* - fudgefactor = fudgetime1; - os_delay = fudgetime2; - offset_fudge = os_delay + fudgefactor + inherent_delay; - stratumtouse = fudgeval1 & 0xf - debug = fudgeval2; - sloppyclockflag = flags & CLK_FLAG1; - 1 log smoothing summary when processing sample - 4 dump the buffer from the clock - 8 EIOGETKD the last n uS time stamps - if (flags & CLK_FLAG2 && unitinuse) ees->leaphold = 0; - ees->dump_vals = flags & CLK_FLAG3; - ees->usealldata = flags & CLK_FLAG4; - - - bug->values[0] = (ees->lasttime) ? current_time - ees->lasttime : 0; - bug->values[1] = (ees->clocklastgood)?current_time-ees->clocklastgood:0; - bug->values[2] = (u_long)ees->status; - bug->values[3] = (u_long)ees->lastevent; - bug->values[4] = (u_long)ees->reason; - bug->values[5] = (u_long)ees->nsamples; - bug->values[6] = (u_long)ees->codestate; - bug->values[7] = (u_long)ees->day; - bug->values[8] = (u_long)ees->hour; - bug->values[9] = (u_long)ees->minute; - bug->values[10] = (u_long)ees->second; - bug->values[11] = (u_long)ees->tz; - bug->values[12] = ees->yearstart; - bug->values[13] = (ees->leaphold > current_time) ? - ees->leaphold - current_time : 0; - bug->values[14] = inherent_delay[unit].l_uf; - bug->values[15] = offset_fudge[unit].l_uf; - - bug->times[0] = ees->reftime; - bug->times[1] = ees->arrvtime; - bug->times[2] = ees->lastsampletime; - bug->times[3] = ees->offset; - bug->times[4] = ees->lowoffset; - bug->times[5] = ees->highoffset; - bug->times[6] = inherent_delay[unit]; - bug->times[8] = os_delay[unit]; - bug->times[7] = fudgefactor[unit]; - bug->times[9] = offset_fudge[unit]; - bug->times[10]= ees->yearstart, 0; - */ - -/* This should support the use of an EES M201 receiver with RS232 - * output (modified to transmit time once per second). - * - * For the format of the message sent by the clock, see the EESM_ - * definitions below. - * - * It appears to run free for an integral number of minutes, until the error - * reaches 4mS, at which point it steps at second = 01. - * It appears that sometimes it steps 4mS (say at 7 min interval), - * then the next minute it decides that it was an error, so steps back. - * On the next minute it steps forward again :-( - * This is typically 16.5uS/S then 3975uS at the 4min re-sync, - * or 9.5uS/S then 3990.5uS at a 7min re-sync, - * at which point it may loose the "00" second time stamp. - * I assume that the most accurate time is just AFTER the re-sync. - * Hence remember the last cycle interval, - * - * Can run in any one of: - * - * PPSCD PPS signal sets CD which interupts, and grabs the current TOD - * (sun) *in the interupt code*, so as to avoid problems with - * the STREAMS scheduling. - * - * It appears that it goes 16.5 uS slow each second, then every 4 mins it - * generates no "00" second tick, and gains 3975 uS. Ho Hum ! (93/2/7) - */ - -/* Definitions */ -#ifndef MAXUNITS -#define MAXUNITS 4 /* maximum number of EES units permitted */ -#endif - -#ifndef EES232 -#define EES232 "/dev/ees%d" /* Device to open to read the data */ -#endif - -/* Other constant stuff */ -#ifndef EESPRECISION -#define EESPRECISION (-10) /* what the heck - 2**-10 = 1ms */ -#endif -#ifndef EESREFID -#define EESREFID "MSF\0" /* String to identify the clock */ -#endif -#ifndef EESHSREFID -#define EESHSREFID (0x7f7f0000 | ((REFCLK_MSF_EES) << 8)) /* Numeric refid */ -#endif - -/* Description of clock */ -#define EESDESCRIPTION "EES M201 MSF Receiver" - -/* Speed we run the clock port at. If this is changed the UARTDELAY - * value should be recomputed to suit. - */ -#ifndef SPEED232 -#define SPEED232 B9600 /* 9600 baud */ -#endif - -/* What is the inherent delay for this mode of working, i.e. when is the - * data time stamped. - */ -#define SAFETY_SHIFT 10 /* Split the shift to avoid overflow */ -#define BITS_TO_L_FP(bits, baud) \ - (((((bits)*2 +1) << (FRACTION_PREC-SAFETY_SHIFT)) / (2*baud)) << SAFETY_SHIFT) -#define INH_DELAY_CBREAK BITS_TO_L_FP(119, 9600) -#define INH_DELAY_PPS BITS_TO_L_FP( 0, 9600) - -#ifndef STREAM_PP1 -#define STREAM_PP1 "ppsclocd\0<-- patch space for module name1 -->" -#endif -#ifndef STREAM_PP2 -#define STREAM_PP2 "ppsclock\0<-- patch space for module name2 -->" -#endif - -/* Offsets of the bytes of the serial line code. The clock gives - * local time with a GMT/BST indication. The EESM_ definitions - * give offsets into ees->lastcode. - */ -#define EESM_CSEC 0 /* centiseconds - always zero in our clock */ -#define EESM_SEC 1 /* seconds in BCD */ -#define EESM_MIN 2 /* minutes in BCD */ -#define EESM_HOUR 3 /* hours in BCD */ -#define EESM_DAYWK 4 /* day of week (Sun = 0 etc) */ -#define EESM_DAY 5 /* day of month in BCD */ -#define EESM_MON 6 /* month in BCD */ -#define EESM_YEAR 7 /* year MOD 100 in BCD */ -#define EESM_LEAP 8 /* 0x0f if leap year, otherwise zero */ -#define EESM_BST 9 /* 0x03 if BST, 0x00 if GMT */ -#define EESM_MSFOK 10 /* 0x3f if radio good, otherwise zero */ - /* followed by a frame alignment byte (0xff) / - / which is not put into the lastcode buffer*/ - -/* Length of the serial time code, in characters. The first length - * is less the frame alignment byte. - */ -#define LENEESPRT (EESM_MSFOK+1) -#define LENEESCODE (LENEESPRT+1) - -/* Code state. */ -#define EESCS_WAIT 0 /* waiting for start of timecode */ -#define EESCS_GOTSOME 1 /* have an incomplete time code buffered */ - -/* Default fudge factor and character to receive */ -#define DEFFUDGETIME 0 /* Default user supplied fudge factor */ -#ifndef DEFOSTIME -#define DEFOSTIME 0 /* Default OS delay -- passed by Make ? */ -#endif -#define DEFINHTIME INH_DELAY_PPS /* inherent delay due to sample point*/ - -/* Limits on things. Reduce the number of samples to SAMPLEREDUCE by median - * elimination. If we're running with an accurate clock, chose the BESTSAMPLE - * as the estimated offset, otherwise average the remainder. - */ -#define FULLSHIFT 6 /* NCODES root 2 */ -#define NCODES (1<< FULLSHIFT) /* 64 */ -#define REDUCESHIFT (FULLSHIFT -1) /* SAMPLEREDUCE root 2 */ - -/* Towards the high ( Why ?) end of half */ -#define BESTSAMPLE ((samplereduce * 3) /4) /* 24 */ - -/* Leap hold time. After a leap second the clock will no longer be - * reliable until it resynchronizes. Hope 40 minutes is enough. */ -#define EESLEAPHOLD (40 * 60) - -#define EES_STEP_F (1 << 24) /* the receiver steps in units of about 4ms */ -#define EES_STEP_F_GRACE (EES_STEP_F/8) /*Allow for slop of 1/8 which is .5ms*/ -#define EES_STEP_NOTE (1 << 21)/* Log any unexpected jumps, say .5 ms .... */ -#define EES_STEP_NOTES 50 /* Only do a limited number */ -#define MAX_STEP 16 /* Max number of steps to remember */ - -/* debug is a bit mask of debugging that is wanted */ -#define DB_SYSLOG_SMPLI 0x0001 -#define DB_SYSLOG_SMPLE 0x0002 -#define DB_SYSLOG_SMTHI 0x0004 -#define DB_SYSLOG_NSMTHE 0x0008 -#define DB_SYSLOG_NSMTHI 0x0010 -#define DB_SYSLOG_SMTHE 0x0020 -#define DB_PRINT_EV 0x0040 -#define DB_PRINT_CDT 0x0080 -#define DB_PRINT_CDTC 0x0100 -#define DB_SYSLOG_KEEPD 0x0800 -#define DB_SYSLOG_KEEPE 0x1000 -#define DB_LOG_DELTAS 0x2000 -#define DB_PRINT_DELTAS 0x4000 -#define DB_LOG_AWAITMORE 0x8000 -#define DB_LOG_SAMPLES 0x10000 -#define DB_NO_PPS 0x20000 -#define DB_INC_PPS 0x40000 -#define DB_DUMP_DELTAS 0x80000 - -struct eesunit { /* EES unit control structure. */ - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp reftime; /* reference time */ - l_fp lastsampletime; /* time as in txt from last EES msg */ - l_fp arrvtime; /* Time at which pkt arrived */ - l_fp codeoffsets[NCODES]; /* the time of arrival of 232 codes */ - l_fp offset; /* chosen offset (for clkbug) */ - l_fp lowoffset; /* lowest sample offset (for clkbug) */ - l_fp highoffset; /* highest " " (for clkbug) */ - char lastcode[LENEESCODE+6]; /* last time code we received */ - u_long lasttime; /* last time clock heard from */ - u_long clocklastgood; /* last time good radio seen */ - u_char lencode; /* length of code in buffer */ - u_char nsamples; /* number of samples we've collected */ - u_char codestate; /* state of 232 code reception */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - char tz; /* timezone from clock */ - u_char ttytype; /* method used */ - u_char dump_vals; /* Should clock values be dumped */ - u_char usealldata; /* Use ALL samples */ - u_short day; /* day of year from last code */ - u_long yearstart; /* start of current year */ - u_long leaphold; /* time of leap hold expiry */ - u_long badformat; /* number of bad format codes */ - u_long baddata; /* number of invalid time codes */ - u_long timestarted; /* time we started this */ - long last_pps_no; /* The serial # of the last PPS */ - char fix_pending; /* Is a "sync to time" pending ? */ - /* Fine tuning - compensate for 4 mS ramping .... */ - l_fp last_l; /* last time stamp */ - u_char last_steps[MAX_STEP]; /* Most recent n steps */ - int best_av_step; /* Best guess at average step */ - char best_av_step_count; /* # of steps over used above */ - char this_step; /* Current pos in buffer */ - int last_step_late; /* How late the last step was (0-59) */ - long jump_fsecs; /* # of fractions of a sec last jump */ - u_long last_step; /* time of last step */ - int last_step_secs; /* Number of seconds in last step */ - int using_ramp; /* 1 -> noemal, -1 -> over stepped */ -}; -#define last_sec last_l.l_ui -#define last_sfsec last_l.l_f -#define this_uisec ((ees->arrvtime).l_ui) -#define this_sfsec ((ees->arrvtime).l_f) -#define msec(x) ((x) / (1<<22)) -#define LAST_STEPS (sizeof ees->last_steps / sizeof ees->last_steps[0]) -#define subms(x) ((((((x < 0) ? (-(x)) : (x)) % (1<<22))/2) * 625) / (1<<(22 -5))) - -/* Bitmask for what methods to try to use -- currently only PPS enabled */ -#define T_CBREAK 1 -#define T_PPS 8 -/* macros to test above */ -#define is_cbreak(x) ((x)->ttytype & T_CBREAK) -#define is_pps(x) ((x)->ttytype & T_PPS) -#define is_any(x) ((x)->ttytype) - -#define CODEREASON 20 /* reason codes */ - -/* Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. */ -static struct eesunit *eesunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* Keep the fudge factors separately so they can be set even - * when no clock is configured. */ -static l_fp inherent_delay[MAXUNITS]; /* when time stamp is taken */ -static l_fp fudgefactor[MAXUNITS]; /* fudgetime1 */ -static l_fp os_delay[MAXUNITS]; /* fudgetime2 */ -static l_fp offset_fudge[MAXUNITS]; /* Sum of above */ -static u_char stratumtouse[MAXUNITS]; -static u_char sloppyclockflag[MAXUNITS]; - -static int deltas[60]; - -static l_fp acceptable_slop; /* = { 0, 1 << (FRACTION_PREC -2) }; */ -static l_fp onesec; /* = { 1, 0 }; */ - -/* Imported from the timer module */ -extern u_long current_time; - -#ifdef DEBUG -static int debug; -#endif - -#ifndef DUMP_BUF_SIZE /* Size of buffer to be used by dump_buf */ -#define DUMP_BUF_SIZE 10112 -#endif - -/* ees_reset - reset the count back to zero */ -#define ees_reset(ees) (ees)->nsamples = 0; \ - (ees)->codestate = EESCS_WAIT - -/* ees_event - record and report an event */ -#define ees_event(ees, evcode) if ((ees)->status != (u_char)(evcode)) \ - ees_report_event((ees), (evcode)) - -/* Find the precision of the system clock by reading it */ -#define USECS 1000000 -#define MINSTEP 5 /* some systems increment uS on each call */ -#define MAXLOOPS (USECS/9) -static int ees_get_precision() -{ - struct timeval tp; - struct timezone tzp; - long last; - int i; - long diff; - long val; - gettimeofday(&tp, &tzp); - - last = tp.tv_usec; - for (i=0; i< 100000; i++) { - gettimeofday(&tp, &tzp); - diff = tp.tv_usec - last; - if (diff < 0) diff += USECS; - if (diff > MINSTEP) break; - last = tp.tv_usec; - } - syslog(LOG_INFO, - "I: ees: precision calculation given %duS after %d loop%s", - diff, i, (i==1) ? "" : "s"); - - if (i == 0) return -20 /* assume 1uS */; - if (i >= MAXLOOPS) return EESPRECISION /* Lies ! */; - for (i=0, val=USECS; val > 0; i--, val /= 2) if (diff > val) return i; - return EESPRECISION /* Lies ! */; -} - -static void dump_buf(coffs, from, to, text) -l_fp *coffs; -int from; -int to; -char *text; -{ - char buff[DUMP_BUF_SIZE + 80]; - int i; - register char *ptr = buff; - sprintf(ptr, text); - for (i=from; i DUMP_BUF_SIZE) syslog(LOG_DEBUG, "D: %s", ptr=buff); - sprintf(ptr, " %06d", ((int)coffs[i].l_f) / 4295); - } - syslog(LOG_DEBUG, "D: %s", buff); -} - -/* msfees_init - initialize internal ees driver data */ -static void msfees_init() -{ - register int i; - /* Just zero the data arrays */ - memset((char *)eesunits, 0, sizeof eesunits); - memset((char *)unitinuse, 0, sizeof unitinuse); - - acceptable_slop.l_ui = 0; - acceptable_slop.l_uf = 1 << (FRACTION_PREC -2); - - onesec.l_ui = 1; - onesec.l_uf = 0; - - /* Initialize fudge factors to default. */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor[i].l_ui = 0; - fudgefactor[i].l_uf = DEFFUDGETIME; - os_delay[i].l_ui = 0; - os_delay[i].l_uf = DEFOSTIME; - inherent_delay[i].l_ui = 0; - inherent_delay[i].l_uf = DEFINHTIME; - offset_fudge[i] = os_delay[i]; - L_ADD(&offset_fudge[i], &fudgefactor[i]); - L_ADD(&offset_fudge[i], &inherent_delay[i]); - stratumtouse[i] = 0; - sloppyclockflag[i] = 0; - } -} - - -/* msfees_start - open the EES devices and initialize data for processing */ -static int msfees_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct eesunit *ees; - register int i; - int fd232 = -1; - char eesdev[20]; - struct termios ttyb, *ttyp; - static void ees_receive(); - extern int io_addclock(); - extern void io_closeclock(); - extern char *emalloc(); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit number %d invalid (max %d)", - unit, MAXUNITS-1); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "ees clock: unit number %d in use", unit); - return 0; - } - - /* Unit okay, attempt to open the devices. We do them both at - * once to make sure we can */ - (void) sprintf(eesdev, EES232, unit); - - fd232 = open(eesdev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "ees clock: open of %s failed: %m", eesdev); - return 0; - } - -#ifdef TIOCEXCL - /* Set for exclusive use */ - if (ioctl(fd232, TIOCEXCL, (char *)0) < 0) { - syslog(LOG_ERR, "ees clock: ioctl(%s, TIOCEXCL): %m", eesdev); - goto screwed; - } -#endif - - /* STRIPPED DOWN VERSION: Only PPS CD is supported at the moment */ - - /* Set port characteristics. If we don't have a STREAMS module or - * a clock line discipline, cooked mode is just usable, even though it - * strips the top bit. The only EES byte which uses the top - * bit is the year, and we don't use that anyway. If we do - * have the line discipline, we choose raw mode, and the - * line discipline code will block up the messages. - */ - - /* STIPPED DOWN VERSION: Only PPS CD is supported at the moment */ - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, "msfees_start: tcgetattr(%s): %m", eesdev); - goto screwed; - } - - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_oflag = 0; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, "msfees_start: tcsetattr(%s): %m", eesdev); - goto screwed; - } - - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, "msfees_start: tcflush(%s): %m", eesdev); - goto screwed; - } - - inherent_delay[unit].l_uf = INH_DELAY_PPS; - - /* offset fudge (how *late* the timestamp is) = fudge + os delays */ - offset_fudge[unit] = os_delay[unit]; - L_ADD(&offset_fudge[unit], &fudgefactor[unit]); - L_ADD(&offset_fudge[unit], &inherent_delay[unit]); - - /* Looks like this might succeed. Find memory for the structure. - * Look to see if there are any unused ones, if not we malloc() one. - */ - if (eesunits[unit] != 0) /* The one we want is okay */ - ees = eesunits[unit]; - else { - /* Look for an unused, but allocated struct */ - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && eesunits[i] != 0) - break; - } - - if (i < MAXUNITS) { /* Reclaim this one */ - ees = eesunits[i]; - eesunits[i] = 0; - } /* no spare -- make a new one */ - else ees = (struct eesunit *) emalloc(sizeof(struct eesunit)); - } - memset((char *)ees, 0, sizeof(struct eesunit)); - eesunits[unit] = ees; - - /* Set up the structures */ - ees->peer = peer; - ees->unit = (u_char)unit; - ees->timestarted= current_time; - ees->ttytype = 0; - ees->io.clock_recv= ees_receive; - ees->io.srcclock= (caddr_t)ees; - ees->io.datalen = 0; - ees->io.fd = fd232; - - /* Okay. Push one of the two (linked into the kernel, or dynamically - * loaded) STREAMS module, and give it to the I/O code to start - * receiving stuff. - */ - - { - int rc1; - /* Pop any existing onews first ... */ - while (ioctl(fd232, I_POP, 0 ) >= 0) ; - - /* Now try pushing either of the possible modules */ - if ((rc1=ioctl(fd232, I_PUSH, STREAM_PP1)) < 0 && - ioctl(fd232, I_PUSH, STREAM_PP2) < 0) { - syslog(LOG_ERR, - "ees clock: Push of `%s' and `%s' to %s failed %m", - STREAM_PP1, STREAM_PP2, eesdev); - goto screwed; - } - else { - syslog(LOG_INFO, "I: ees clock: PUSHed %s on %s", - (rc1 >= 0) ? STREAM_PP1 : STREAM_PP2, eesdev); - ees->ttytype |= T_PPS; - } - } - - /* Add the clock */ - if (!io_addclock(&ees->io)) { - /* Oh shit. Just close and return. */ - syslog(LOG_ERR, "ees clock: io_addclock(%s): %m", eesdev); - goto screwed; - } - - - /* All done. Initialize a few random peer variables, then - * return success. */ - peer->precision = ees_get_precision(); - peer->stratum = stratumtouse[unit]; - peer->rootdelay = 0; /* ++++ */ - peer->rootdispersion = 0; /* ++++ */ - if (stratumtouse[unit] <= 1) { - memmove((char *)&peer->refid, EESREFID, 4); - if (unit > 0 && unit < 10) - ((char *)&peer->refid)[3] = '0' + unit; - } else { - peer->refid = htonl(EESHSREFID); - } - unitinuse[unit] = 1; - syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit); - return (1); - -screwed: - if (fd232 != -1) - (void) close(fd232); - return (0); -} - - -/* msfees_shutdown - shut down a EES clock */ -static void msfees_shutdown(unit) - int unit; -{ - register struct eesunit *ees; - extern void io_closeclock(); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "ees clock: INTERNAL ERROR, unit number %d invalid (max %d)", - unit, MAXUNITS); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, - "ees clock: INTERNAL ERROR, unit number %d not in use", unit); - return; - } - - /* Tell the I/O module to turn us off. We're history. */ - ees = eesunits[unit]; - io_closeclock(&ees->io); - unitinuse[unit] = 0; -} - - -/* ees_report_event - note the occurance of an event */ -static void ees_report_event(ees, code) - struct eesunit *ees; - int code; -{ - if (ees->status != (u_char)code) { - ees->status = (u_char)code; - if (code != CEVNT_NOMINAL) - ees->lastevent = (u_char)code; - /* Should report event to trap handler in here. - * Soon... - */ - } -} - - -/* ees_receive - receive data from the serial interface on an EES clock */ -static void ees_receive(rbufp) - struct recvbuf *rbufp; -{ - register int n_sample; - register int day; - register struct eesunit *ees; - register u_char *dpt; /* Data PoinTeR: move along ... */ - register u_char *dpend; /* Points just *after* last data char */ - register char *cp; - l_fp tmp; - static void ees_process(); - int call_pps_sample = 0; - l_fp pps_arrvstamp; - int sincelast; - int pps_step = 0; - int suspect_4ms_step = 0; - struct ppsclockev ppsclockev; - long *ptr = (long *) &ppsclockev; - extern errno; - int rc; - - /* Get the clock this applies to and a pointer to the data */ - ees = (struct eesunit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - dpend = dpt + rbufp->recv_length; - if ((debug & DB_LOG_AWAITMORE) && (rbufp->recv_length != LENEESCODE)) - printf("[%d] ", rbufp->recv_length); - - /* Check out our state and process appropriately */ - switch (ees->codestate) { - case EESCS_WAIT: - /* Set an initial guess at the timestamp as the recv time. - * If just running in CBREAK mode, we can't improve this. - * If we have the CLOCK Line Discipline, PPSCD, or sime such, - * then we will do better later .... - */ - ees->arrvtime = rbufp->recv_time; - ees->codestate = EESCS_GOTSOME; - ees->lencode = 0; - /*FALLSTHROUGH*/ - - case EESCS_GOTSOME: - cp = &(ees->lastcode[ees->lencode]); - - /* Gobble the bytes until the final (possibly stripped) 0xff */ - while (dpt < dpend && (*dpt & 0x7f) != 0x7f) { - *cp++ = (char)*dpt++; - ees->lencode++; - /* Oh dear -- too many bytes .. */ - if (ees->lencode > LENEESPRT) { - syslog(LOG_INFO, -"I: ees clock: %d + %d > %d [%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x]", - ees->lencode, dpend - dpt, LENEESPRT, -#define D(x) (ees->lastcode[x]) - D(0), D(1), D(2), D(3), D(4), D(5), D(6), - D(7), D(8), D(9), D(10), D(11), D(12)); -#undef D - ees->badformat++; - ees->reason = CODEREASON + 1; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - } - /* Gave up because it was end of the buffer, rather than ff */ - if (dpt == dpend) { - /* Incomplete. Wait for more. */ - if (debug & DB_LOG_AWAITMORE) syslog(LOG_INFO, - "I: ees clock %d: %d == %d: await more", - ees->unit, dpt, dpend); - return; - } - - /* This shouldn't happen ... ! */ - if ((*dpt & 0x7f) != 0x7f) { - syslog(LOG_INFO, "I: ees clock: %0x & 0x7f != 0x7f", *dpt); - ees->badformat++; - ees->reason = CODEREASON + 2; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* Skip the 0xff */ - dpt++; - - /* Finally, got a complete buffer. Mainline code will - * continue on. */ - cp = ees->lastcode; - break; - - default: - syslog(LOG_ERR, "ees clock: INTERNAL ERROR: %d state %d", - ees->unit, ees->codestate); - ees->reason = CODEREASON + 5; - ees_event(ees, CEVNT_FAULT); - ees_reset(ees); - return; - } - - /* Boy! After all that crap, the lastcode buffer now contains - * something we hope will be a valid time code. Do length - * checks and sanity checks on constant data. - */ - ees->codestate = EESCS_WAIT; - ees->lasttime = current_time; - if (ees->lencode != LENEESPRT) { - ees->badformat++; - ees->reason = CODEREASON + 6; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - cp = ees->lastcode; - - /* Check that centisecond is zero */ - if (cp[EESM_CSEC] != 0) { - ees->baddata++; - ees->reason = CODEREASON + 7; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* Check flag formats */ - if (cp[EESM_LEAP] != 0 && cp[EESM_LEAP] != 0x0f) { - ees->badformat++; - ees->reason = CODEREASON + 8; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - if (cp[EESM_BST] != 0 && cp[EESM_BST] != 0x03) { - ees->badformat++; - ees->reason = CODEREASON + 9; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - if (cp[EESM_MSFOK] != 0 && cp[EESM_MSFOK] != 0x3f) { - ees->badformat++; - ees->reason = CODEREASON + 10; - ees_event(ees, CEVNT_BADREPLY); - ees_reset(ees); - return; - } - - /* So far, so good. Compute day, hours, minutes, seconds, - * time zone. Do range checks on these. - */ - -#define bcdunpack(val) ( (((val)>>4) & 0x0f) * 10 + ((val) & 0x0f) ) -#define istrue(x) ((x)?1:0) - - ees->second = bcdunpack(cp[EESM_SEC]); /* second */ - ees->minute = bcdunpack(cp[EESM_MIN]); /* minute */ - ees->hour = bcdunpack(cp[EESM_HOUR]); /* hour */ - - day = bcdunpack(cp[EESM_DAY]); /* day of month */ - - switch (bcdunpack(cp[EESM_MON])) { /* month */ - - /* Add in lengths of all previous months. Add one more - if it is a leap year and after February. - */ - case 12: day += NOV; /*FALLSTHROUGH*/ - case 11: day += OCT; /*FALLSTHROUGH*/ - case 10: day += SEP; /*FALLSTHROUGH*/ - case 9: day += AUG; /*FALLSTHROUGH*/ - case 8: day += JUL; /*FALLSTHROUGH*/ - case 7: day += JUN; /*FALLSTHROUGH*/ - case 6: day += MAY; /*FALLSTHROUGH*/ - case 5: day += APR; /*FALLSTHROUGH*/ - case 4: day += MAR; /*FALLSTHROUGH*/ - case 3: day += FEB; - if (istrue(cp[EESM_LEAP])) day++; /*FALLSTHROUGH*/ - case 2: day += JAN; /*FALLSTHROUGH*/ - case 1: break; - default: ees->baddata++; - ees->reason = CODEREASON + 11; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - - ees->day = day; - - /* Get timezone. The clocktime routine wants the number - * of hours to add to the delivered time to get UT. - * Currently -1 if BST flag set, 0 otherwise. This - * is the place to tweak things if double summer time - * ever happens. - */ - ees->tz = istrue(cp[EESM_BST]) ? -1 : 0; - - if (ees->day > 366 || ees->day < 1 || - ees->hour > 23 || ees->minute > 59 || ees->second > 59) { - ees->baddata++; - ees->reason = CODEREASON + 12; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - - n_sample = ees->nsamples; - - /* Now, compute the reference time value: text -> tmp.l_ui */ - if (!clocktime(ees->day, ees->hour, ees->minute, ees->second, - ees->tz, rbufp->recv_time.l_ui, &ees->yearstart, - &tmp.l_ui)) { - ees->baddata++; - ees->reason = CODEREASON + 13; - ees_event(ees, CEVNT_BADDATE); - ees_reset(ees); - return; - } - tmp.l_uf = 0; - - /* DON'T use ees->arrvtime -- it may be < reftime */ - ees->lastsampletime = tmp; - - /* If we are synchronised to the radio, update the reference time. - * Also keep a note of when clock was last good. - */ - if (istrue(cp[EESM_MSFOK])) { - ees->reftime = tmp; - ees->clocklastgood = current_time; - } - - - /* Compute the offset. For the fractional part of the - * offset we use the expected delay for the message. - */ - ees->codeoffsets[n_sample].l_ui = tmp.l_ui; - ees->codeoffsets[n_sample].l_uf = 0; - - /* Number of seconds since the last step */ - sincelast = this_uisec - ees->last_step; - - memset(&ppsclockev, 0, sizeof ppsclockev); - - rc = ioctl(ees->io.fd, CIOGETEV, (char *) &ppsclockev); - if (debug & DB_PRINT_EV) fprintf(stderr, - "[%x] CIOGETEV u%d %d (%x %d) gave %d (%d): %08x %08x %d\n", - DB_PRINT_EV, ees->unit, ees->io.fd, CIOGETEV, is_pps(ees), - rc, errno, ptr[0], ptr[1], ptr[2]); - - /* If we managed to get the time of arrival, process the info */ - if (rc >= 0) { - int conv = -1; - pps_step = ppsclockev.serial - ees->last_pps_no; - - /* Possible that PPS triggered, but text message didn't */ - if (pps_step == 2) syslog(LOG_ERR, "pps step = 2 @ %02d", ees->second); - if (pps_step == 2 && ees->second == 1) suspect_4ms_step |= 1; - if (pps_step == 2 && ees->second == 2) suspect_4ms_step |= 4; - - /* allow for single loss of PPS only */ - if (pps_step != 1 && pps_step != 2) - fprintf(stderr, "PPS step: %d too far off %d (%d)\n", - ppsclockev.serial, ees->last_pps_no, pps_step); - else if (!buftvtots((char *) &(ppsclockev.tv), &pps_arrvstamp)) - fprintf(stderr, "buftvtots failed\n"); - else { /* if ((ABS(time difference) - 0.25) < 0) - * then believe it ... - */ - l_fp diff; - diff = pps_arrvstamp; - conv = 0; - L_SUB(&diff, &ees->arrvtime); -if (debug & DB_PRINT_CDT) printf("[%x] Have %x.%08x and %x.%08x -> %x.%08x @ %s", - DB_PRINT_CDT, ees->arrvtime.l_ui, ees->arrvtime.l_uf, - pps_arrvstamp.l_ui, pps_arrvstamp.l_uf, - diff.l_ui, diff.l_uf, - ctime(&(ppsclockev.tv.tv_sec))); - if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf); - L_SUB(&diff, &acceptable_slop); - if (L_ISNEG(&diff)) { /* AOK -- pps_sample */ - ees->arrvtime = pps_arrvstamp; - conv++; - call_pps_sample++; - } - /* Some loss of some signals around sec = 1 */ - else if (ees->second == 1) { - diff = pps_arrvstamp; - L_ADD(&diff, &onesec); - L_SUB(&diff, &ees->arrvtime); - if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf); - L_SUB(&diff, &acceptable_slop); -syslog(LOG_ERR, "Have sec==1 slip %ds a=%08x-p=%08x -> %x.%08x (u=%d) %s", - pps_arrvstamp.l_ui - ees->arrvtime.l_ui, - pps_arrvstamp.l_uf, - ees->arrvtime.l_uf, - diff.l_ui, diff.l_uf, - ppsclockev.tv.tv_usec, - ctime(&(ppsclockev.tv.tv_sec))); - if (L_ISNEG(&diff)) { /* AOK -- pps_sample */ - suspect_4ms_step |= 2; - ees->arrvtime = pps_arrvstamp; - L_ADD(&ees->arrvtime, &onesec); - conv++; - call_pps_sample++; - } - } - } - ees->last_pps_no = ppsclockev.serial; - if (debug & DB_PRINT_CDTC) printf( - "[%x] %08x %08x %d u%d (%d %d)\n", - DB_PRINT_CDTC, pps_arrvstamp.l_ui, - pps_arrvstamp.l_uf, conv, ees->unit, - call_pps_sample, pps_step); - } - - /* See if there has been a 4ms jump at a minute boundry */ - { l_fp delta; -#define delta_isec delta.l_ui -#define delta_ssec delta.l_i -#define delta_sfsec delta.l_f - long delta_f_abs; - - delta.l_i = ees->arrvtime.l_i; - delta.l_f = ees->arrvtime.l_f; - - L_SUB(&delta, &ees->last_l); - delta_f_abs = delta_sfsec; - if (delta_f_abs < 0) delta_f_abs = -delta_f_abs; - - /* Dump the deltas each minute */ - if (debug & DB_DUMP_DELTAS) - { if (0 <= ees->second && - ees->second < ((sizeof deltas) / (sizeof deltas[0]))) deltas[ees->second] = delta_sfsec; - /* Dump on second 1, as second 0 sometimes missed */ - if (ees->second == 1) { - char text[16 * ((sizeof deltas) / (sizeof deltas[0]))]; - char *ptr=text; - int i; - for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) { - sprintf(ptr, " %d.%04d", - msec(deltas[i]), subms(deltas[i])); - while (*ptr) ptr++; - } - syslog(LOG_ERR, "Deltas: %d.%04d<->%d.%04d: %s", - msec(EES_STEP_F - EES_STEP_F_GRACE), subms(EES_STEP_F - EES_STEP_F_GRACE), - msec(EES_STEP_F + EES_STEP_F_GRACE), subms(EES_STEP_F + EES_STEP_F_GRACE), - text+1); - for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) deltas[i] = 0; - } - } - - /* Lets see if we have a 4 mS step at a minute boundaary */ - if ( ((EES_STEP_F - EES_STEP_F_GRACE) < delta_f_abs) && - (delta_f_abs < (EES_STEP_F + EES_STEP_F_GRACE)) && - (ees->second == 0 || ees->second == 1 || ees->second == 2) && - (sincelast < 0 || sincelast > 122) - ) { /* 4ms jump at min boundry */ - int old_sincelast; - int count=0; - int sum = 0; - /* Yes -- so compute the ramp time */ - if (ees->last_step == 0) sincelast = 0; - old_sincelast = sincelast; - - /* First time in, just set "ees->last_step" */ - if(ees->last_step) { - int other_step = 0; - int third_step = 0; - int this_step = (sincelast + (60 /2)) / 60; - int p_step = ees->this_step; - int p; - ees->last_steps[p_step] = this_step; - p= p_step; - p_step++; - if (p_step >= LAST_STEPS) p_step = 0; - ees->this_step = p_step; - /* Find the "average" interval */ - while (p != p_step) { - int this = ees->last_steps[p]; - if (this == 0) break; - if (this != this_step) { - if (other_step == 0 && ( - this== (this_step +2) || - this== (this_step -2) || - this== (this_step +1) || - this== (this_step -1))) - other_step = this; - if (other_step != this) { - int delta = (this_step - other_step); - if (delta < 0) delta = - delta; - if (third_step == 0 && ( - (delta == 1) ? ( - this == (other_step +1) || - this == (other_step -1) || - this == (this_step +1) || - this == (this_step -1)) - : - ( - this == (this_step + other_step)/2 - ) - )) third_step = this; - if (third_step != this) break; - } - } - sum += this; - p--; - if (p < 0) p += LAST_STEPS; - count++; - } -syslog(LOG_ERR, "MSF%d: %d: This=%d (%d), other=%d/%d, sum=%d, count=%d, pps_step=%d, suspect=%x", ees->unit, p, ees->last_steps[p], this_step, other_step, third_step, sum, count, pps_step, suspect_4ms_step); - if (count != 0) sum = ((sum * 60) + (count /2)) / count; -#define SV(x) (ees->last_steps[(x + p_step) % LAST_STEPS]) -syslog(LOG_ERR, "MSF%d: %x steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", - ees->unit, suspect_4ms_step, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6), - SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15)); -printf("MSF%d: steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", - ees->unit, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6), - SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15)); -#undef SV - ees->jump_fsecs = delta_sfsec; - ees->using_ramp = 1; - if (sincelast > 170) - ees->last_step_late += sincelast - ((sum) ? sum : ees->last_step_secs); - else ees->last_step_late = 30; - if (ees->last_step_late < -60 || ees->last_step_late > 120) ees->last_step_late = 30; - if (ees->last_step_late < 0) ees->last_step_late = 0; - if (ees->last_step_late >= 60) ees->last_step_late = 59; - sincelast = 0; - } - else { /* First time in -- just save info */ - ees->last_step_late = 30; - ees->jump_fsecs = delta_sfsec; - ees->using_ramp = 1; - sum = 4 * 60; - } - ees->last_step = this_uisec; -printf("MSF%d: d=%3d.%04d@%d :%d:%d:$%d:%d:%d\n", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, old_sincelast, ees->last_step_late, count, sum, ees->last_step_secs); -syslog(LOG_ERR, "MSF%d: d=%3d.%04d@%d :%d:%d:%d:%d:%d", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, old_sincelast, ees->last_step_late, count, sum, ees->last_step_secs); - if (sum) ees->last_step_secs = sum; - } - /* OK, so not a 4ms step at a minute boundry */ - else { - if (suspect_4ms_step) syslog(LOG_ERR, - "MSF%d: suspect = %x, but delta of %d.%04d [%d.%04d<%d.%04d<%d.%04d: %d %d]", - ees->unit, suspect_4ms_step, msec(delta_sfsec), subms(delta_sfsec), - msec(EES_STEP_F - EES_STEP_F_GRACE), - subms(EES_STEP_F - EES_STEP_F_GRACE), - msec(delta_f_abs), - subms(delta_f_abs), - msec(EES_STEP_F + EES_STEP_F_GRACE), - subms(EES_STEP_F + EES_STEP_F_GRACE), - ees->second, - sincelast); - if ((delta_f_abs > EES_STEP_NOTE) && ees->last_l.l_i) { - static ees_step_notes = EES_STEP_NOTES; - if (ees_step_notes > 0) { - ees_step_notes--; -printf("MSF%d: D=%3d.%04d@%02d :%d%s\n", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, sincelast, ees_step_notes ? "" : " -- NO MORE !"); -syslog(LOG_ERR, "MSF%d: D=%3d.%04d@%02d :%d%s", -ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, (ees->last_step) ? sincelast : -1, ees_step_notes ? "" : " -- NO MORE !"); - } - } - } - } - ees->last_l = ees->arrvtime; - - /* IF we have found that it's ramping - * && it's within twice the expected ramp period - * && there is a non zero step size (avoid /0 !) - * THEN we twiddle things - */ - if (ees->using_ramp && - sincelast < (ees->last_step_secs)*2 && - ees->last_step_secs) - { long sec_of_ramp = sincelast + ees->last_step_late; - long fsecs; - l_fp inc; - - /* Ramp time may vary, so may ramp for longer than last time */ - if (sec_of_ramp > (ees->last_step_secs + 120)) - sec_of_ramp = ees->last_step_secs; - - /* sec_of_ramp * ees->jump_fsecs may overflow 2**32 */ - fsecs = sec_of_ramp * (ees->jump_fsecs / ees->last_step_secs); - - if (debug & DB_LOG_DELTAS) syslog(LOG_ERR, - "[%x] MSF%d: %3d/%03d -> d=%11d (%d|%d)", - DB_LOG_DELTAS, - ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, - pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); - if (debug & DB_PRINT_DELTAS) printf( - "MSF%d: %3d/%03d -> d=%11d (%d|%d)\n", - ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, - pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); - - /* Must sign extend the result */ - inc.l_i = (fsecs < 0) ? -1 : 0; - inc.l_f = fsecs; - if (debug & DB_INC_PPS) - { L_SUB(&pps_arrvstamp, &inc); - L_SUB(&ees->arrvtime, &inc); - } - else - { L_ADD(&pps_arrvstamp, &inc); - L_ADD(&ees->arrvtime, &inc); - } - } - else { - if (debug & DB_LOG_DELTAS) syslog(LOG_ERR, - "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x", - DB_LOG_DELTAS, - ees->unit, ees->using_ramp, - sincelast, - (ees->last_step_secs)*2, - ees->last_step_secs); - if (debug & DB_PRINT_DELTAS) printf( - "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x\n", - DB_LOG_DELTAS, - ees->unit, ees->using_ramp, - sincelast, - (ees->last_step_secs)*2, - ees->last_step_secs); - } - - L_SUB(&ees->arrvtime, &offset_fudge[ees->unit]); - L_SUB(&pps_arrvstamp, &offset_fudge[ees->unit]); - - if (call_pps_sample && !(debug & DB_NO_PPS)) { - /* Sigh -- it expects its args negated */ - L_NEG(&pps_arrvstamp); - (void) pps_sample(&pps_arrvstamp); - } - - /* Subtract off the local clock time stamp */ - L_SUB(&ees->codeoffsets[n_sample], &ees->arrvtime); - if (debug & DB_LOG_SAMPLES) syslog(LOG_ERR, - "MSF%d: [%x] %d (ees: %d %d) (pps: %d %d)%s", - ees->unit, DB_LOG_DELTAS, n_sample, - ees->codeoffsets[n_sample].l_f, - ees->codeoffsets[n_sample].l_f / 4295, - pps_arrvstamp.l_f, - pps_arrvstamp.l_f /4295, - (debug & DB_NO_PPS) ? " [no PPS]" : ""); - - if (ees->nsamples++ == NCODES-1) ees_process(ees); - - /* Done! */ -} - - -static void set_x(fp_offset) -l_fp *fp_offset; -{ - step_systime_real(fp_offset); -} - - -/* offcompare - auxiliary comparison routine for offset sort */ - -static int -offcompare(a, b) -l_fp *a, *b; -{ - return(L_ISGEQ(a, b) ? (L_ISEQU(a, b) ? 0 : 1) : -1); -} - - -/* ees_process - process a pile of samples from the clock */ -static void ees_process(ees) - struct eesunit *ees; -{ - static last_samples = -1; - register int i, j; - register int noff; - register l_fp *coffs = ees->codeoffsets; - l_fp offset, tmp; - u_fp dispersion; /* ++++ */ - int lostsync, isinsync; - int samples = ees->nsamples; - int samplelog; - int samplereduce = (samples + 1) / 2; - - /* Reset things to zero so we don't have to worry later */ - ees_reset(ees); - - if (sloppyclockflag[ees->unit]) { - samplelog = (samples < 2) ? 0 : - (samples < 5) ? 1 : - (samples < 9) ? 2 : - (samples < 17) ? 3 : - (samples < 33) ? 4 : 5; - samplereduce = (1 << samplelog); - } - - if (samples != last_samples && - ((samples != (last_samples-1)) || samples < 3)) { - syslog(LOG_ERR, "Samples=%d (%d), samplereduce=%d ....", - samples, last_samples, samplereduce); - last_samples = samples; - } - if (samples < 1) return; - - /* If requested, dump the raw data we have in the buffer */ - if (ees->dump_vals) dump_buf(coffs, 0, samples, "Raw data is:"); - - /* Sort the offsets, trim off the extremes, then choose one. */ - qsort((char *) coffs, samples, sizeof(l_fp), offcompare); - - noff = samples; - i = 0; - while ((noff - i) > samplereduce) { - /* Trim off the sample which is further away - * from the median. We work this out by doubling - * the median, subtracting off the end samples, and - * looking at the sign of the answer, using the - * identity (c-b)-(b-a) == 2*b-a-c - */ - tmp = coffs[(noff + i)/2]; - L_ADD(&tmp, &tmp); - L_SUB(&tmp, &coffs[i]); - L_SUB(&tmp, &coffs[noff-1]); - if (L_ISNEG(&tmp)) noff--; else i++; - } - - /* If requested, dump the reduce data we have in the buffer */ - if (ees->dump_vals) dump_buf(coffs, i, noff, "Reduced to:"); - - /* What we do next depends on the setting of the sloppy clock flag. - * If it is on, average the remainder to derive our estimate. - * Otherwise, just pick a representative value from the remaining stuff - */ - if (sloppyclockflag[ees->unit]) { - offset.l_ui = offset.l_uf = 0; - for (j = i; j < noff; j++) - L_ADD(&offset, &coffs[j]); - for (j = samplelog; j > 0; j--) - L_RSHIFTU(&offset); - } - else offset = coffs[i+BESTSAMPLE]; - - /* Compute the dispersion as the difference between the - * lowest and highest offsets that remain in the - * consideration list. - * - * It looks like MOST clocks have MOD (max error), so halve it ! - */ - tmp = coffs[noff-1]; - L_SUB(&tmp, &coffs[i]); -#define FRACT_SEC(n) ((1 << 30) / (n/2)) - dispersion = LFPTOFP(&tmp) / 2; /* ++++ */ - if (debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE)) syslog( - (debug & DB_SYSLOG_SMPLE) ? LOG_ERR : LOG_INFO, - "I: [%x] Offset=%06d (%d), disp=%06d%s [%d], %d %d=%d %d:%d %d=%d %d", - debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE), - offset.l_f / 4295, offset.l_f, - (dispersion * 1526) / 100, - (sloppyclockflag[ees->unit]) ? " by averaging" : "", - FRACT_SEC(10) / 4295, - (coffs[0].l_f) / 4295, - i, - (coffs[i].l_f) / 4295, - (coffs[samples/2].l_f) / 4295, - (coffs[i+BESTSAMPLE].l_f) / 4295, - noff-1, - (coffs[noff-1].l_f) / 4295, - (coffs[samples-1].l_f) / 4295); - - /* Are we playing silly wotsits ? - * If we are using all data, see if there is a "small" delta, - * and if so, blurr this with 3/4 of the delta from the last value - */ - if (ees->usealldata && ees->offset.l_uf) { - long diff = (long) (ees->offset.l_uf - offset.l_uf); - - /* is the delta small enough ? */ - if ((- FRACT_SEC(100)) < diff && diff < FRACT_SEC(100)) { - int samd = (64 * 4) / samples; - long new; - if (samd < 2) samd = 2; - new = offset.l_uf + ((diff * (samd -1)) / samd); - - /* Sign change -> need to fix up int part */ - if ((new & (1 << 31)) != - (((long) offset.l_uf) & ( 1 << 31))) - { syslog(LOG_INFO, "I: %x != %x (%x %x), so add %d", - new & (1 << 31), - ((long) offset.l_uf) & ( 1 << 31), - new, (long) offset.l_uf, - (new < 0) ? -1 : 1); - offset.l_ui += (new < 0) ? -1 : 1; - } - dispersion /= 4; - if (debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE)) syslog( - (debug & DB_SYSLOG_SMTHE) ? LOG_ERR : LOG_INFO, - "I: [%x] Smooth data: %d -> %d, dispersion now %d", - debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE), - ((long) offset.l_uf) / 4295, new / 4295, - (dispersion * 1526) / 100); - offset.l_uf = (unsigned long) new; - } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) syslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, - "[%x] No smooth as delta not %d < %d < %d", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), - - FRACT_SEC(100), diff, FRACT_SEC(100)); - } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) syslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, - "I: [%x] No smooth as flag=%x and old=%x=%d (%d:%d)", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), - ees->usealldata, ees->offset.l_f, ees->offset.l_uf, - offset.l_f, ees->offset.l_f - offset.l_f); - - /* Collect offset info for debugging info */ - ees->offset = offset; - ees->lowoffset = coffs[i]; - ees->highoffset = coffs[noff-1]; - - /* Determine synchronization status. Can be unsync'd either - * by a report from the clock or by a leap hold. - * - * Loss of the radio signal for a short time does not cause - * us to go unsynchronised, since the receiver keeps quite - * good time on its own. The spec says 20ms in 4 hours; the - * observed drift in our clock (Cambridge) is about a second - * a day, but even that keeps us within the inherent tolerance - * of the clock for about 15 minutes. Observation shows that - * the typical "short" outage is 3 minutes, so to allow us - * to ride out those, we will give it 5 minutes. - */ - lostsync = current_time - ees->clocklastgood > 300 ? 1 : 0; - isinsync = (lostsync || ees->leaphold > current_time) ? 0 : 1; - - /* Done. Use time of last good, synchronised code as the - * reference time, and lastsampletime as the receive time. - */ - if (ees->fix_pending) { - syslog(LOG_ERR, "MSF%d: fix_pending=%d -> jump %x.%08x\n", - ees->fix_pending, ees->unit, offset.l_i, offset.l_f); - ees->fix_pending = 0; - set_x(&offset); - L_CLR(&offset); - } - refclock_receive(ees->peer, - &offset, - 0, /* delay */ - dispersion, - &ees->reftime, - &ees->lastsampletime, /* receive time */ - (isinsync) ? 0 : LEAP_NOTINSYNC); - ees_event(ees, lostsync ? CEVNT_PROP : CEVNT_NOMINAL); -} - -/* msfees_poll - called by the transmit procedure */ -static void msfees_poll(unit, peer) - int unit; - char *peer; -{ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d invalid", - unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d unused", - unit); - return; - } - - ees_process(eesunits[unit]); - - if ((current_time - eesunits[unit]->lasttime) > 150) - ees_event(eesunits[unit], CEVNT_FAULT); -} - -/* msfees_leap - called when a leap second occurs */ -static void msfees_leap() -{ - register int i; - - /* This routine should be entered a few seconds after - * midnight UTC when a leap second occurs. To ensure we - * don't believe foolish time from the clock(s) we set a - * 40 minute hold on them. It shouldn't take anywhere - * near this amount of time to adjust if the clock is getTING - * data, but doing anything else is complicated. - */ - for (i = 0; i < MAXUNITS; i++) if (unitinuse[i]) - eesunits[i]->leaphold = current_time + EESLEAPHOLD; -} - -/* msfees_control - set fudge factors, return statistics */ -static void msfees_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct eesunit *ees = eesunits[unit]; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit %d invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - os_delay[unit] = in->fudgetime2; - offset_fudge[unit] = os_delay[unit]; - L_ADD(&offset_fudge[unit], &fudgefactor[unit]); - L_ADD(&offset_fudge[unit], &inherent_delay[unit]); - if (in->haveflags & CLK_HAVEVAL1) { - stratumtouse[unit] = (u_char)(in->fudgeval1 & 0xf); - if (unitinuse[unit]) { - /* Should actually reselect clock, but - * will wait for the next timecode - */ - struct peer *peer = ees->peer; - peer->stratum = stratumtouse[unit]; - if (stratumtouse[unit] <= 1) { - memmove((char *)&peer->refid, - EESREFID, 4); - if (unit>0 && unit<10) - ((char *)&peer->refid)[3] = - '0' + unit; - } - else peer->refid = htonl(EESHSREFID); - } - } - if (in->haveflags & CLK_HAVEVAL2) { - printf("Debug: %x -> %x\n", debug, in->fudgeval2); - syslog(LOG_ERR, "MSF%d: debug %x -> %x", - unit, debug, in->fudgeval2); - debug = in->fudgeval2; - } - if (in->haveflags & CLK_HAVEFLAG1) { - sloppyclockflag[unit] = in->flags & CLK_FLAG1; - } - if (in->haveflags & CLK_HAVEFLAG2) { - ees->fix_pending++; - /* if (in->flags & CLK_FLAG2 && unitinuse[unit]) - ees->leaphold = 0; */ - } - if (in->haveflags & CLK_HAVEFLAG3 && unitinuse[unit]) { - printf("dump_vals: %x -> %x\n", ees->dump_vals, in->flags & CLK_FLAG3); - ees->dump_vals = in->flags & CLK_FLAG3; - } - if (in->haveflags & CLK_HAVEFLAG4 && unitinuse[unit]) { - ees->usealldata = in->flags & CLK_FLAG4; - } - } - - if (out != 0) { - out->type = REFCLK_MSF_EES; - out->haveflags - = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEVAL2|CLK_HAVEFLAG1|CLK_HAVEFLAG3|CLK_HAVEFLAG4; - out->clockdesc = EESDESCRIPTION; - out->fudgetime1 = fudgefactor[unit]; - out->fudgetime2 = os_delay[unit]; - out->fudgeval1 = (long)stratumtouse[unit]; - /*out->fudgeval2= debug*/; - memmove((char *)&out->fudgeval2, EESREFID, 4); - if (unit > 0 && unit < 10) - ((char *)&out->fudgeval2)[3] = '0' + unit; - out->flags = sloppyclockflag[unit]; - if (unitinuse[unit]) { - out->flags |= ees->dump_vals | ees->usealldata; - out->lencode = ees->lencode; - out->lastcode = ees->lastcode; - out->timereset = current_time - ees->timestarted; - out->polls = 0; /* we don't poll */ - out->noresponse = 0; /* ditto */ - out->badformat = ees->badformat; - out->baddata = ees->baddata; - out->lastevent = ees->lastevent; - out->currentstatus = ees->status; - } else { - out->lencode = 0; - out->lastcode = ""; - out->polls = out->noresponse = 0; - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; - } - } -} - - -/* msfees_buginfo - return clock dependent debugging info */ -static void msfees_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct eesunit *ees; - - bug->nvalues = bug->ntimes = 0; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "ees clock: unit %d invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - if (!unitinuse[unit]) - return; - ees = eesunits[unit]; - - bug->nvalues = 16; - bug->svalues = 0x0800; - bug->values[0] = (ees->lasttime) ? current_time - ees->lasttime : 0; - bug->values[1] = (ees->clocklastgood)?current_time-ees->clocklastgood:0; - bug->values[2] = (u_long)ees->status; - bug->values[3] = (u_long)ees->lastevent; - bug->values[4] = (u_long)ees->reason; - bug->values[5] = (u_long)ees->nsamples; - bug->values[6] = (u_long)ees->codestate; - bug->values[7] = (u_long)ees->day; - bug->values[8] = (u_long)ees->hour; - bug->values[9] = (u_long)ees->minute; - bug->values[10] = (u_long)ees->second; - bug->values[11] = (u_long)ees->tz; - bug->values[12] = ees->yearstart; - bug->values[13] = (ees->leaphold > current_time) ? - ees->leaphold - current_time : 0; - bug->values[14] = inherent_delay[unit].l_uf; - bug->values[15] = offset_fudge[unit].l_uf; - - bug->ntimes = 11; - bug->stimes = 0x3f8; - bug->times[0] = ees->reftime; - bug->times[1] = ees->arrvtime; - bug->times[2] = ees->lastsampletime; - bug->times[3] = ees->offset; - bug->times[4] = ees->lowoffset; - bug->times[5] = ees->highoffset; - bug->times[6] = inherent_delay[unit]; - bug->times[8] = os_delay[unit]; - bug->times[7] = fudgefactor[unit]; - bug->times[9] = offset_fudge[unit]; - bug->times[10].l_ui = ees->yearstart; - bug->times[10].l_uf = 0; -} - -struct refclock refclock_msfees = { - msfees_start, msfees_shutdown, msfees_poll, - msfees_control, msfees_init, msfees_buginfo, NOFLAGS -}; -#endif /* defined(REFCLOCK) && defined(MSFEESPPS) && defined(STREAM) */ diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_mx4200.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_mx4200.c deleted file mode 100644 index 7cfa3cf0326b..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_mx4200.c +++ /dev/null @@ -1,1342 +0,0 @@ -/* - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66. - * - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * 4. The name of the University may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(REFCLOCK) && (defined(MX4200) || defined(MX4200CLK) || defined(MX4200PPS)) - -#if !defined(lint) && !defined(__GNUC__) -static char rcsid[] = - "@(#) /src/master/xntp-930612/xntpd/refclock_mx4200.c,v 1.5 1993/06/18 21:19:54 jbj Exp (LBL) "; -#endif - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_calendar.h" -#include "ntp_unixtime.h" - -#if __STDC__ -#include -#else -#include -#endif - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#if defined(STREAM) -#include -#if defined(MX4200CLK) -#include -#endif /* MX4200CLK */ -#endif /* STREAM */ - -#include - -#include "mx4200.h" -#include "ntp_stdlib.h" - -/* - * This driver supports the Magnavox Model MX4200 GPS Receiver. - */ - -/* - * Definitions - */ -#define MAXUNITS 2 /* max number of mx4200 units */ -#define MX4200232 "/dev/gps%d" -#define SPEED232 B4800 /* baud */ - -/* - * The number of raw samples which we acquire to derive a single estimate. - */ -#define NSTAMPS 64 - -/* - * Radio interface parameters - */ -#define MX4200PRECISION (-18) /* precision assumed (about 4 us) */ -#define MX4200REFID "GPS" /* reference id */ -#define MX4200DESCRIPTION "Magnavox MX4200 GPS Receiver" /* who we are */ -#define DEFFUDGETIME 0 /* default fudge time (ms) */ - -/* Leap stuff */ -extern U_LONG leap_hoursfromleap; -extern U_LONG leap_happened; -static int leap_debug; - -/* - * mx4200_reset - reset the count back to zero - */ -#define mx4200_reset(mx4200) \ - do { \ - (mx4200)->nsamples = 0; \ - } while (0) - -/* - * mx4200_event - record and report an event - */ -#define mx4200_event(mx4200, evcode) \ - do { \ - if ((mx4200)->status != (u_char)(evcode)) \ - mx4200_report_event((mx4200), (evcode)); \ - } while (0) - -/* - * Imported from the timer module - */ -extern U_LONG current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * MX4200 unit control structure. - */ -struct mx4200unit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - U_LONG gpssamples[NSTAMPS]; /* the GPS time samples */ - l_fp unixsamples[NSTAMPS]; /* the UNIX time samples */ - - - l_fp lastsampletime; /* time of last estimate */ - u_int lastserial; /* last pps serial number */ -#ifdef notdef - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ -#endif - char lastcode[RX_BUFF_SIZE]; /* last timecode received */ - U_LONG lasttime; /* last time clock heard from */ - u_char nsamples; /* number of samples we've collected */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last abort */ - u_char lencode; /* length of last timecode */ - u_char year; /* year of eternity */ - u_short monthday; /* day of month */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - /* - * Status tallies - */ -#ifdef notdef - U_LONG polls; /* polls sent */ - U_LONG noresponse; /* number of nonresponses */ -#endif - U_LONG badformat; /* bad format */ - U_LONG baddata; /* bad data */ - U_LONG timestarted; /* time we started this */ -}; - -/* - * We demand that consecutive PPS samples are more than 0.995 seconds - * and less than 1.005 seconds apart. - */ -#define PPSLODIFF_UI 0 /* 0.900 as an l_fp */ -#define PPSLODIFF_UF 0xe6666610 - -#define PPSHIDIFF_UI 1 /* 1.100 as an l_fp */ -#define PPSHIDIFF_UF 0x19999990 - -/* - * reason codes - */ -#define PPSREASON 20 -#define CODEREASON 40 -#define PROCREASON 60 - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct mx4200unit *mx4200units[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char sloppyclockflag[MAXUNITS]; -static U_LONG refid[MAXUNITS]; - -static const char pmvxg[] = "PMVXG"; - -/* - * Function prototypes - */ -static void mx4200_init P((void)); -static int mx4200_start P((u_int, struct peer *)); -static void mx4200_shutdown P((int)); -static void mx4200_receive P((struct recvbuf *)); -static void mx4200_process P((struct mx4200unit *)); -static void mx4200_report_event P((struct mx4200unit *, int)); -static void mx4200_poll P((int, struct peer *)); -static void mx4200_control P((u_int, struct refclockstat *, struct refclockstat *)); -static void mx4200_buginfo P((int, struct refclockbug *)); - -static char * mx4200_parse P((char *, struct calendar *, int *, int *)); -static int mx4200_needconf P((char *)); -static void mx4200_config P((struct mx4200unit *)); -static void mx4200_send P((int, const char *, ...)); -static int mx4200_cmpl_fp P((void *, void *)); -static u_char cksum P((char *, u_int)); - -#ifdef DEBUG -static void opendfile P((int)); -static void checkdfile P((void)); -#endif /* DEBUG */ - -/* - * Transfer vector - */ -struct refclock refclock_mx4200 = { - mx4200_start, mx4200_shutdown, mx4200_poll, - mx4200_control, mx4200_init, mx4200_buginfo, NOFLAGS -}; - -/* - * mx4200_init - initialize internal mx4200 driver data - */ -static void -mx4200_init() -{ - register int i; - /* - * Just zero the data arrays - */ - memset((char *)mx4200units, 0, sizeof mx4200units); - memset((char *)unitinuse, 0, sizeof unitinuse); - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor[i].l_ui = 0; - fudgefactor[i].l_uf = DEFFUDGETIME; - stratumtouse[i] = 0; - sloppyclockflag[i] = 0; - memcpy((char *)&refid[i], MX4200REFID, 4); - } -} - -#ifdef DEBUG -static char dfile[] = "/var/tmp/MX4200.debug"; -static FILE *df = NULL; - -static void -opendfile(create) - int create; -{ - if (!create && access(dfile, F_OK) < 0) { - syslog(LOG_ERR, "mx4200: open %s: %m", dfile); - return; - } - df = fopen(dfile, "a"); - if (df == NULL) - syslog(LOG_ERR, "mx4200: open %s: %m", dfile); - else if (setvbuf(df, NULL, _IOLBF, 0) < 0) - syslog(LOG_ERR, "mx4200: setvbuf %s: %m", dfile); -} - -static void -checkdfile() -{ - - if (df == NULL) - return; - - if (access(dfile, F_OK) < 0) { - fclose(df); - opendfile(1); - } -} - -#endif - - -/* - * mx4200_start - open the MX4200 devices and initialize data for processing - */ -static int -mx4200_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct mx4200unit *mx4200; - register int i; - int fd232; - char mx4200dev[20]; - - /* - * Check configuration info - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_start: unit %d invalid", unit); - return (0); - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "mx4200_start: unit %d in use", unit); - return (0); - } - - /* - * Open serial port - */ - (void) sprintf(mx4200dev, MX4200232, unit); - fd232 = open(mx4200dev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, - "mx4200_start: open of %s: %m", mx4200dev); - return (0); - } - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, TCGETA): %m", mx4200dev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, TCSETA): %m", mx4200dev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The MX4200CLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The MX4200PPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "mx4200_start: tcgetattr(%s): %m", mx4200dev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "mx4200_start: tcsetattr(%s): %m", mx4200dev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "mx4200_start: tcflush(%s): %m", mx4200dev); - goto screwed; - } - } -#endif /* HAVE_TERMIOS */ -#ifdef STREAM -#if defined(MX4200CLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, I_PUSH, clk): %m", mx4200dev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, CLK_SETSTR): %m", mx4200dev); -#endif /* MX4200CLK */ -#if defined(MX4200PPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, I_PUSH, ppsclock): %m", mx4200dev); - else - fdpps = fd232; -#endif /* MX4200PPS */ -#endif /* STREAM */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The MX4200CLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(MX4200CLK) - int ldisc = CLKLDISC; -#endif /* MX4200CLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, TIOCGETP): %m", mx4200dev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(MX4200CLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* MX4200CLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, TIOCSETP): %m", mx4200dev); - goto screwed; - } -#if defined(MX4200CLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "mx4200_start: ioctl(%s, TIOCSETD): %m",mx4200dev); - goto screwed; - } -#endif /* MX4200CLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Allocate unit structure - */ - if (mx4200units[unit] != 0) { - mx4200 = mx4200units[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && mx4200units[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - mx4200 = mx4200units[i]; - mx4200units[i] = 0; - } else { - mx4200 = (struct mx4200unit *) - emalloc(sizeof(struct mx4200unit)); - } - } - - memset((char *)mx4200, 0, sizeof(struct mx4200unit)); - mx4200units[unit] = mx4200; - - /* - * Set up the structures - */ - mx4200->peer = peer; - mx4200->unit = (u_char)unit; - mx4200->timestarted = current_time; - - mx4200->io.clock_recv = mx4200_receive; - mx4200->io.srcclock = (caddr_t)mx4200; - mx4200->io.datalen = 0; - mx4200->io.fd = fd232; - if (!io_addclock(&mx4200->io)) - goto screwed; - - /* - * All done. Initialize a few random peer variables, then - * return success. - */ - peer->precision = MX4200PRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - - /* Insure the receiver is properly configured */ - mx4200_config(mx4200); - -#ifdef DEBUG - opendfile(0); -#endif - return (1); - - /* - * Something broke; abandon ship - */ -screwed: - (void) close(fd232); - return (0); -} - -/* - * mx4200_shutdown - shut down a MX4200 clock - */ -static void -mx4200_shutdown(unit) - int unit; -{ - register struct mx4200unit *mx4200; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_shutdown: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "mx4200_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - mx4200 = mx4200units[unit]; - io_closeclock(&mx4200->io); - unitinuse[unit] = 0; -} - -static void -mx4200_config(mx4200) - register struct mx4200unit *mx4200; -{ - register int fd = mx4200->io.fd; - -syslog(LOG_DEBUG, "mx4200_config"); - - /* Zero the output list (do it twice to flush possible junk) */ - mx4200_send(fd, "%s,%03d,,%d,,,,,,", pmvxg, PMVXG_S_PORTCONF, 1); - mx4200_send(fd, "%s,%03d,,%d,,,,,,", pmvxg, PMVXG_S_PORTCONF, 1); - - /* Switch to 2d mode */ - mx4200_send(fd, "%s,%03d,%d,,%.1f,%.1f,,%d,%d,%c,%d", - pmvxg, PMVXG_S_INITMODEB, - 2, /* 2d mode */ - 0.1, /* hor accel fact as per Steve */ - 0.1, /* ver accel fact as per Steve */ - 10, /* hdop limit as per Steve */ - 5, /* elevation limit as per Steve */ - 'U', /* time output mode */ - 0); /* local time offset from gmt */ - - /* Configure time recovery */ - mx4200_send(fd, "%s,%03d,%c,%c,%c,%d,%d,%d,", - pmvxg, PMVXG_S_TRECOVCONF, -#ifdef notdef - 'K', /* known position */ - 'D', /* dynamic position */ -#else - 'S', /* static position */ -#endif - 'U', /* steer clock to gps time */ - 'A', /* always output time pulse */ - 500, /* max time error in ns */ - 0, /* user bias in ns */ - 1); /* output to control port */ -} - -/* - * mx4200_report_event - note the occurrence of an event - */ -static void -mx4200_report_event(mx4200, code) - struct mx4200unit *mx4200; - int code; -{ - struct peer *peer; - - peer = mx4200->peer; - if (mx4200->status != (u_char)code) { - mx4200->status = (u_char)code; - if (code != CEVNT_NOMINAL) - mx4200->lastevent = (u_char)code; - syslog(LOG_INFO, - "mx4200 clock %s event %x", ntoa(&peer->srcadr), code); - } -} - -/* - * mx4200_poll - mx4200 watchdog routine - */ -static void -mx4200_poll(unit, peer) - int unit; - struct peer *peer; -{ - register struct mx4200unit *mx4200; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "mx4200_poll: unit %d not used", unit); - return; - } - - mx4200 = mx4200units[unit]; - if ((current_time - mx4200->lasttime) > 150) { - mx4200_event(mx4200, CEVNT_FAULT); - - /* Request a status message which should trigger a reconfig */ - mx4200_send(mx4200->io.fd, "%s,%03d", "CDGPQ", PMVXG_D_STATUS); - syslog(LOG_DEBUG, "mx4200_poll: request status"); - } -} - -static const char char2hex[] = "0123456789ABCDEF"; - -/* - * mx4200_receive - receive gps data - */ -static void -mx4200_receive(rbufp) - struct recvbuf *rbufp; -{ - register struct mx4200unit *mx4200; - register char *dpt, *cp; - register U_LONG tmp_ui; - register U_LONG tmp_uf; - register U_LONG gpstime; - struct ppsclockev ev; - register struct calendar *jt; - struct calendar sjt; - register int n; - int valid, leapsec; - register u_char ck; - - mx4200 = (struct mx4200unit *)rbufp->recv_srcclock; - -#ifdef DEBUG - if (debug > 3) - printf("mx4200_receive: nsamples = %d\n", mx4200->nsamples); -#endif - - /* Record the time of this event */ - mx4200->lasttime = current_time; - - /* Get the pps value */ - if (ioctl(mx4200->io.fd, CIOGETEV, (char *)&ev) < 0) { - /* XXX Actually, if this fails, we're pretty much screwed */ -#ifdef DEBUG - if (debug) { - fprintf(stderr, "mx4200_receive: "); - perror("CIOGETEV"); - } -#endif - mx4200->reason = PPSREASON + 1; - mx4200_event(mx4200, CEVNT_FAULT); - mx4200_reset(mx4200); - return; - } - tmp_ui = ev.tv.tv_sec + (U_LONG)JAN_1970; - TVUTOTSF(ev.tv.tv_usec, tmp_uf); - - /* Get buffer and length; sock away last timecode */ - n = rbufp->recv_length; - dpt = rbufp->recv_buffer; - if (n <= 1) - return; - mx4200->lencode = n; - memmove(mx4200->lastcode, dpt, n); - - /* - * We expect to see something like: - * - * $PMVXG,830,T,1992,07,09,04:18:34,U,S,-02154,00019,000000,00*1D\n - * - * Reject if any important landmarks are missing. - */ - cp = dpt + n - 4; - if (cp < dpt || *dpt != '$' || cp[0] != '*' || cp[3] != '\n') { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad format\n"); -#endif - mx4200->badformat++; - mx4200->reason = PPSREASON + 2; - mx4200_event(mx4200, CEVNT_BADREPLY); - mx4200_reset(mx4200); - return; - } - - /* Check checksum */ - ck = cksum(&dpt[1], n - 5); - if (char2hex[ck >> 4] != cp[1] || char2hex[ck & 0xf] != cp[2]) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad checksum\n"); -#endif - mx4200->badformat++; - mx4200->reason = PPSREASON + 3; - mx4200_event(mx4200, CEVNT_BADREPLY); - mx4200_reset(mx4200); - return; - } - - /* Truncate checksum (and the buffer for that matter) */ - *cp = '\0'; - - /* Leap second debugging stuff */ - if ((leap_hoursfromleap && !leap_happened) || leap_debug > 0) { - /* generate reports for awhile after leap */ - if (leap_hoursfromleap && !leap_happened) - leap_debug = 3600; - else - --leap_debug; - syslog(LOG_INFO, "mx4200 leap: %s \"%s\"", - umfptoa(tmp_ui, tmp_uf, 6), dpt); - } - - /* Parse time recovery message */ - jt = &sjt; - if ((cp = mx4200_parse(dpt, jt, &valid, &leapsec)) != NULL) { - /* Configure the receiver if necessary */ - if (mx4200_needconf(dpt)) - mx4200_config(mx4200); -#ifdef DEBUG - if (debug) - printf("mx4200_receive: mx4200_parse: %s\n", cp); -#endif - mx4200->badformat++; - mx4200->reason = PPSREASON + 5; - mx4200_event(mx4200, CEVNT_BADREPLY); - mx4200_reset(mx4200); - return; - } - - /* Setup leap second indicator */ - if (leapsec == 0) - mx4200->leap = LEAP_NOWARNING; - else if (leapsec == 1) - mx4200->leap = LEAP_ADDSECOND; - else if (leapsec == -1) - mx4200->leap = LEAP_DELSECOND; - else - mx4200->leap = LEAP_NOTINSYNC; /* shouldn't happen */ - - /* Check parsed time (allow for possible leap seconds) */ - if (jt->second >= 61 || jt->minute >= 60 || jt->hour >= 24) { -#ifdef DEBUG - if (debug) { - printf("mx4200_receive: bad time %d:%02d:%02d", - jt->hour, jt->minute, jt->second); - if (leapsec != 0) - printf(" (leap %+d)", leapsec); - putchar('\n'); - } -#endif - mx4200->baddata++; - mx4200->reason = PPSREASON + 6; - mx4200_event(mx4200, CEVNT_BADTIME); - mx4200_reset(mx4200); - /* Eat the next pulse which the clock claims will be bad */ - mx4200->nsamples = -1; - return; - } - - /* Check parsed date */ - if (jt->monthday > 31 || jt->month > 12 || jt->year < 1900) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: bad date (%d/%d/%d)\n", - jt->monthday, jt->month, jt->year); -#endif - mx4200->baddata++; - mx4200->reason = PPSREASON + 7; - mx4200_event(mx4200, CEVNT_BADDATE); - mx4200_reset(mx4200); - return; - } - - /* Convert to ntp time */ - gpstime = caltontp(jt); - - /* The gps message describes the *next* pulse; pretend it's this one */ - --gpstime; - - /* Debugging */ -#ifdef DEBUG - checkdfile(); - if (df != NULL) { - l_fp t; - - t.l_ui = gpstime; - t.l_uf = 0; - M_SUB(t.l_ui, t.l_uf, tmp_ui, tmp_uf); - fprintf(df, "%s\t%s", - umfptoa(tmp_ui, tmp_uf, 6), mfptoa(t.l_ui, t.l_uf, 6)); - if (debug > 3) - fprintf(df, "\t(gps: %lu)", gpstime); - if (leapsec != 0) - fprintf(df, "\t(leap sec %+d)", leapsec); - if (!valid) - fprintf(df, "\t(pulse not valid)"); - fputc('\n', df); - } -#endif - - /* Check pps serial number against last one */ - if (mx4200->lastserial + 1 != ev.serial && mx4200->lastserial != 0) { -#ifdef DEBUG - if (debug) { - if (ev.serial == mx4200->lastserial) - printf("mx4200_receive: no new pps event\n"); - else - printf("mx4200_receive: missed %d pps events\n", - ev.serial - mx4200->lastserial - 1); - } -#endif - mx4200->reason = PPSREASON + 8; - mx4200_event(mx4200, CEVNT_FAULT); - mx4200_reset(mx4200); - /* fall through and this one collect as first sample */ - } - mx4200->lastserial = ev.serial; - -/* - * XXX - * Since this message is for the next pulse, it's really the next pulse - * that the clock might be telling us will be invalid. - */ - /* Toss if not designated "valid" by the gps */ - if (!valid) { -#ifdef DEBUG - if (debug) - printf("mx4200_receive: pps not valid\n"); -#endif - mx4200->reason = PPSREASON + 9; - mx4200_event(mx4200, CEVNT_BADTIME); - mx4200_reset(mx4200); - return; - } - - /* Copy time into mx4200unit struct */ - /* XXX (why?) */ - mx4200->year = jt->year; - mx4200->monthday = jt->monthday; - mx4200->hour = jt->hour; - mx4200->minute = jt->minute; - mx4200->second = jt->second; - - /* Sock away the GPS and UNIX timesamples */ - n = mx4200->nsamples++; - if (n < 0) - return; /* oops, this pulse is bad */ - mx4200->gpssamples[n] = gpstime; - mx4200->unixsamples[n].l_ui = mx4200->lastsampletime.l_ui = tmp_ui; - mx4200->unixsamples[n].l_uf = mx4200->lastsampletime.l_uf = tmp_uf; - if (mx4200->nsamples >= NSTAMPS) { - /* - * Here we've managed to complete an entire NSTAMPS - * second cycle without major mishap. Process what has - * been received. - */ - mx4200_process(mx4200); - mx4200_reset(mx4200); - } -} - -/* Compare two l_fp's, used with qsort() */ -static int -mx4200_cmpl_fp(p1, p2) - register void *p1, *p2; -{ - - if (!L_ISGEQ((l_fp *)p1, (l_fp *)p2)) - return (-1); - if (L_ISEQU((l_fp *)p1, (l_fp *)p2)) - return (0); - return (1); -} - -/* - * mx4200_process - process a pile of samples from the clock - */ -static void -mx4200_process(mx4200) - struct mx4200unit *mx4200; -{ - register int i, n; - register l_fp *fp, *op; - register U_LONG *lp; - l_fp off[NSTAMPS]; - register U_LONG tmp_ui, tmp_uf; - register U_LONG date_ui, date_uf; - u_fp dispersion; - - /* Compute offsets from the raw data. */ - fp = mx4200->unixsamples; - op = off; - lp = mx4200->gpssamples; - for (i = 0; i < NSTAMPS; ++i, ++lp, ++op, ++fp) { - op->l_ui = *lp; - op->l_uf = 0; - L_SUB(op, fp); - } - - /* Sort offsets into ascending order. */ - qsort((char *)off, NSTAMPS, sizeof(l_fp), mx4200_cmpl_fp); - - /* - * Reject the furthest from the median until 8 samples left - */ - i = 0; - n = NSTAMPS; - while ((n - i) > 8) { - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - date_ui = off[(n+i)/2].l_ui; - date_uf = off[(n+i)/2].l_uf; - M_SUB(tmp_ui, tmp_uf, date_ui, date_uf); - M_SUB(date_ui, date_uf, off[i].l_ui, off[i].l_uf); - if (M_ISHIS(date_ui, date_uf, tmp_ui, tmp_uf)) { - /* - * reject low end - */ - i++; - } else { - /* - * reject high end - */ - n--; - } - } - - /* - * Compute the dispersion based on the difference between the - * extremes of the remaining offsets. - */ - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - M_SUB(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - dispersion = MFPTOFP(tmp_ui, tmp_uf); - - /* - * Now compute the offset estimate. If the sloppy clock - * flag is set, average the remainder, otherwise pick the - * median. - */ - if (sloppyclockflag[mx4200->unit]) { - tmp_ui = tmp_uf = 0; - while (i < n) { - M_ADD(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - i++; - } - M_RSHIFT(tmp_ui, tmp_uf); - M_RSHIFT(tmp_ui, tmp_uf); - M_RSHIFT(tmp_ui, tmp_uf); - i = 0; - off[0].l_ui = tmp_ui; - off[0].l_uf = tmp_uf; - } else { - i = (n + i) / 2; - } - - /* - * Add the default MX4200 QT delay into this. - */ -#ifdef notdef - L_ADDUF(&off[i], MX4200QTFUDGE); -#endif - - /* - * Done. Use lastref as the reference time and lastrec - * as the receive time. ** note this can result in tossing - * out the peer in the protocol module if lastref > lastrec, - * so last rec is used for both values - dlm *** - */ - refclock_receive(mx4200->peer, &off[i], - (s_fp)0, /* delay */ - dispersion, - &mx4200->unixsamples[NSTAMPS-1], /* reftime */ - &mx4200->unixsamples[NSTAMPS-1], /* rectime */ - mx4200->leap); - - mx4200_event(mx4200, CEVNT_NOMINAL); -} - -/* - * mx4200_control - set fudge factors, return statistics - */ -static void -mx4200_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct mx4200unit *mx4200; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_control: unit %d invalid", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (in->haveflags & CLK_HAVEFLAG1) - sloppyclockflag[unit] = in->flags & CLK_FLAG1; - if (unitinuse[unit]) { - struct peer *peer; - - peer = mx4200units[unit]->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out != 0) { - memset((char *)out, 0, sizeof (struct refclockstat)); - out->type = REFCLK_GPS_MX4200; - out->haveflags = CLK_HAVETIME1 | CLK_HAVEVAL1 | CLK_HAVEVAL2 | - CLK_HAVEFLAG1; - out->clockdesc = MX4200DESCRIPTION; - out->fudgetime1 = fudgefactor[unit]; - out->fudgeval1 = (LONG)stratumtouse[unit]; - out->fudgeval2 = refid[unit];; - out->flags = sloppyclockflag[unit]; - if (unitinuse[unit]) { - mx4200 = mx4200units[unit]; - out->lencode = mx4200->lencode; - out->lastcode = mx4200->lastcode; - out->lastevent = mx4200->lastevent; - out->currentstatus = mx4200->status; - - out->polls = 0; /* mx4200->polls; */ - out->noresponse = 0; /* mx4200->noresponse; */ - out->badformat = mx4200->badformat; - out->baddata = mx4200->baddata; - out->timereset = current_time - mx4200->timestarted; - } - } -} - -/* - * mx4200_buginfo - return clock dependent debugging info - */ -static void -mx4200_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct mx4200unit *mx4200; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "mx4200_buginfo: unit %d invalid", unit); - return; - } - - if (!unitinuse[unit]) - return; - mx4200 = mx4200units[unit]; - - memset((char *)bug, 0, sizeof(*bug)); - bug->nvalues = 10; - bug->ntimes = 2; - if (mx4200->lasttime != 0) - bug->values[0] = current_time - mx4200->lasttime; - else - bug->values[0] = 0; - bug->values[1] = (U_LONG)mx4200->reason; - bug->values[2] = (U_LONG)mx4200->year; - bug->values[3] = (U_LONG)mx4200->monthday; - bug->values[4] = (U_LONG)mx4200->hour; - bug->values[5] = (U_LONG)mx4200->minute; - bug->values[6] = (U_LONG)mx4200->second; -#ifdef notdef - bug->values[7] = mx4200->msec; - bug->values[8] = mx4200->noreply; - bug->values[9] = mx4200->yearstart; -#endif - bug->stimes = 0x1c; -#ifdef notdef - bug->times[0] = mx4200->lastref; - bug->times[1] = mx4200->lastrec; -#endif -} - -/* - * Returns true if the this is a status message. We use this as - * an indication that the receiver needs to be initialized. - */ -static int -mx4200_needconf(buf) - char *buf; -{ - register LONG v; - char *cp; - - cp = buf; - - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Record type */ - v = strtol(cp, &cp, 10); - if (v != PMVXG_D_STATUS) - return (0); - /* - * XXX - * Since we configure the receiver to not give us status - * messages and since the receiver outputs status messages by - * default after being reset to factory defaults when sent the - * "$PMVXG,018,C\r\n" message, any status message we get - * indicates the reciever needs to be initialized; thus, it is - * not necessary to decode the status message. - */ -#ifdef notdef - ++cp; - - /* Receiver status */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Number of satellites which should be visible */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Number of satellites being tracked */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Time since last NAV */ - if ((cp = strchr(cp, ',')) == NULL) - return (0); - ++cp; - - /* Initialization status */ - v = strtol(cp, &cp, 10); - if (v == 0) -#endif - return (1); -} - -/* Parse a mx4200 time recovery message. Returns a string if error */ -static char * -mx4200_parse(buf, jt, validp, leapsecp) - register char *buf; - register struct calendar *jt; - register int *validp, *leapsecp; -{ - register LONG v; - char *cp; - - cp = buf; - memset((char *)jt, 0, sizeof(*jt)); - - if ((cp = strchr(cp, ',')) == NULL) - return ("no rec-type"); - ++cp; - - /* Record type */ - v = strtol(cp, &cp, 10); - if (v != PMVXG_D_TRECOVOUT) - return ("wrong rec-type"); - - /* Pulse valid indicator */ - if (*cp++ != ',') - return ("no pulse-valid"); - if (*cp == 'T') - *validp = 1; - else if (*cp == 'F') - *validp = 0; - else - return ("bad pulse-valid"); - ++cp; - - /* Year */ - if (*cp++ != ',') - return ("no year"); - jt->year = strtol(cp, &cp, 10); - - /* Month of year */ - if (*cp++ != ',') - return ("no month"); - jt->month = strtol(cp, &cp, 10); - - /* Day of month */ - if (*cp++ != ',') - return ("no month day"); - jt->monthday = strtol(cp, &cp, 10); - - /* Hour */ - if (*cp++ != ',') - return ("no hour"); - jt->hour = strtol(cp, &cp, 10); - - /* Minute */ - if (*cp++ != ':') - return ("no minute"); - jt->minute = strtol(cp, &cp, 10); - - /* Second */ - if (*cp++ != ':') - return ("no second"); - jt->second = strtol(cp, &cp, 10); - - /* Time indicator */ - if (*cp++ != ',' || *cp++ == '\0') - return ("no time indicator"); - - /* Time recovery mode */ - if (*cp++ != ',' || *cp++ == '\0') - return ("no time mode"); - - /* Oscillator offset */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no osc off"); - ++cp; - - /* Time mark error */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no time mark err"); - ++cp; - - /* User time bias */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no user bias"); - ++cp; - - /* Leap second flag */ - if ((cp = strchr(cp, ',')) == NULL) - return ("no leap"); - ++cp; - *leapsecp = strtol(cp, &cp, 10); - - return (NULL); -} - -/* Calculate the checksum */ -static u_char -cksum(cp, n) - register char *cp; - register u_int n; -{ - register u_char ck; - - for (ck = 0; n-- > 0; ++cp) - ck ^= *cp; - return (ck); -} - -static void -#if __STDC__ -mx4200_send(register int fd, const char *fmt, ...) -#else -mx4200_send(fd, fmt, va_alist) - register int fd; - const char *fmt; - va_dcl -#endif -{ - register char *cp; - register int n, m; - va_list ap; - char buf[1024]; - u_char ck; - -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - cp = buf; - *cp++ = '$'; -#ifdef notdef - /* BSD is rational */ - n = vsnprintf(cp, sizeof(buf) - 1, fmt, ap); -#else - /* SunOS sucks */ - (void)vsprintf(cp, fmt, ap); - n = strlen(cp); -#endif - ck = cksum(cp, n); - cp += n; - ++n; -#ifdef notdef - /* BSD is rational */ - n += snprintf(cp, sizeof(buf) - n - 5, "*%02X\r\n", ck); -#else - /* SunOS sucks */ - sprintf(cp, "*%02X\r\n", ck); - n += strlen(cp); -#endif - - m = write(fd, buf, n); - if (m < 0) - syslog(LOG_ERR, "mx4200_send: write: %m (%s)", buf); - else if (m != n) - syslog(LOG_ERR, "mx4200_send: write: %d != %d (%s)", m, n, buf); - va_end(ap); -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c deleted file mode 100644 index 95a20a0d2c44..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c +++ /dev/null @@ -1,999 +0,0 @@ -/* - * refclock_omega - clock driver for the Kinemetrics Truetime OM-DC OMEGA - * receiver. - * - * Version 1.0 11-Dec-92 Steve Clift (clift@ml.csiro.au) - * Initial version, mostly lifted from refclock_goes.c. - * - * 1.1 03-May-93 Steve Clift - * Tarted up the sample filtering mechanism to give improved - * one-off measurements. Improved measurement dispersion code - * to account for accumulated drift when the clock loses lock. - * - */ - -#if defined(REFCLOCK) && (defined(OMEGA) || defined(OMEGACLK) || defined(OMEGAPPS)) - -#include -#include -#include - -#include "ntpd.h" -#include "ntp_io.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" - -#if defined(HAVE_BSD_TTYS) -#include -#endif /* HAVE_BSD_TTYS */ - -#if defined(HAVE_SYSV_TTYS) -#include -#endif /* HAVE_SYSV_TTYS */ - -#if defined(HAVE_TERMIOS) -#include -#endif -#if defined(STREAM) -#include -#if defined(OMEGACLK) -#include -#endif /* OMEGACLK */ -#endif /* STREAM */ - -#if defined (OMEGAPPS) -#include -#endif /* OMEGAPPS */ - -#include "ntp_stdlib.h" - -/* - * Support for Kinemetrics Truetime OM-DC OMEGA Receiver - * - * Most of this code is copied from refclock_goes.c with thanks. - * - * the time code looks like follows; Send the clock a R or C and once per - * second a timestamp will appear that looks like this: - * ADDD:HH:MM:SSQCL - * A - control A - * Q Quality indication: indicates possible error of - * > >+- 5 seconds - * ? >+/- 500 milliseconds # >+/- 50 milliseconds - * * >+/- 5 milliseconds . >+/- 1 millisecond - * A-H less than 1 millisecond. Character indicates which station - * is being received as follows: - * A = Norway, B = Liberia, C = Hawaii, D = North Dakota, - * E = La Reunion, F = Argentina, G = Australia, H = Japan. - * C - Carriage return - * L - Line feed - * The carriage return start bit begins on 0 seconds and extends to 1 bit time. - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* max number of OMEGA units */ -#define OMEGA232 "/dev/omega%d" -#define SPEED232 B9600 /* 9600 baud */ - -/* - * Radio interface parameters - */ -#define OMEGADESCRIPTION "Kinemetrics OM-DC OMEGA Receiver" /* who we are */ -#define OMEGAMAXDISPERSE (FP_SECOND/32) /* max allowed sample dispersion */ -#define OMEGAPRECISION (-10) /* precision assumed (about 1 ms) */ -#define OMEGAREFID "VLF\0" /* reference id */ -#define LENOMEGA 13 /* length of standard response */ -#define GMT 0 /* hour offset from Greenwich */ -#define NSTAMPS 9 /* samples collected when polled */ -#define NSKEEP 5 /* samples to keep after discards */ -#define BMAX 50 /* timecode buffer length */ - -/* - * The OM-DC puts out the start bit of the on the second, but - * we see the result after the is received, about 2ms later at - * 9600 baud. Use this as the default fudge time, and let the user - * fiddle it to account for driver latency etc. - */ -#define DEFFUDGETIME 0x00830000 /* default fudge time (~2ms) */ - -/* - * Clock drift errors as u_fp values. - */ -#define U_FP5000MS (5*FP_SECOND) /* 5 seconds */ -#define U_FP500MS (FP_SECOND/2) /* 500 msec */ -#define U_FP50MS (FP_SECOND/20) /* 50 msec */ -#define U_FP5MS (FP_SECOND/200) /* 5 msec */ - -/* - * Station codes - */ -#define STATION_NONE 0 -#define STATION_NORWAY 1 -#define STATION_LIBERIA 2 -#define STATION_HAWAII 3 -#define STATION_N_DAKOTA 4 -#define STATION_LA_REUNION 5 -#define STATION_ARGENTINA 6 -#define STATION_AUSTRALIA 7 -#define STATION_JAPAN 8 - -/* - * Hack to avoid excercising the multiplier. I have no pride. - */ -#define MULBY10(x) (((x)<<3) + ((x)<<1)) - -/* - * Imported from the timer module - */ -extern U_LONG current_time; -extern struct event timerqueue[]; - -/* - * Imported from ntp_loopfilter module - */ -extern int fdpps; /* pps file descriptor */ - -/* - * Imported from ntpd module - */ -extern int debug; /* global debug flag */ - -/* - * OMEGA unit control structure - */ -struct omegaunit { - struct peer *peer; /* associated peer structure */ - struct refclockio io; /* given to the I/O handler */ - l_fp lastrec; /* last receive time */ - l_fp lastref; /* last timecode time */ - l_fp offset[NSTAMPS]; /* recent sample offsets */ - char lastcode[BMAX]; /* last timecode received */ - u_short station; /* which station we're locked to */ - u_short polled; /* Hand in a time sample? */ - U_LONG coderecv; /* timecodes received */ - u_char lencode; /* length of last timecode */ - U_LONG lasttime; /* last time clock heard from */ - u_char unit; /* unit number for this guy */ - u_char status; /* clock status */ - u_char lastevent; /* last clock event */ - u_char reason; /* reason for last failure */ - u_char year; /* year of eternity */ - u_short day; /* day of year */ - u_char hour; /* hour of day */ - u_char minute; /* minute of hour */ - u_char second; /* seconds of minute */ - u_char leap; /* leap indicators */ - u_short msec; /* millisecond of second */ - u_char quality; /* quality char from last timecode */ - U_LONG yearstart; /* start of current year */ - /* - * Status tallies - */ - U_LONG polls; /* polls sent */ - U_LONG noreply; /* no replies to polls */ - U_LONG badformat; /* bad format */ - U_LONG baddata; /* bad data */ - U_LONG timestarted; /* time we started this */ -}; - -/* - * Data space for the unit structures. Note that we allocate these on - * the fly, but never give them back. - */ -static struct omegaunit *omegaunits[MAXUNITS]; -static u_char unitinuse[MAXUNITS]; - -/* - * Keep the fudge factors separately so they can be set even - * when no clock is configured. - */ -static l_fp fudgefactor1[MAXUNITS]; -static l_fp fudgefactor2[MAXUNITS]; -static u_char stratumtouse[MAXUNITS]; -static u_char readonlyclockflag[MAXUNITS]; -static U_LONG refid[MAXUNITS]; - -/* - * Function prototypes - */ -static void omega_init P((void)); -static int omega_start P((u_int, struct peer *)); -static void omega_shutdown P((int)); -static void omega_report_event P((struct omegaunit *, int)); -static void omega_receive P((struct recvbuf *)); -static char omega_process P((struct omegaunit *, l_fp *, u_fp *)); -static void omega_poll P((int, struct peer *)); -static void omega_control P((u_int, struct refclockstat *, struct refclockstat *)); -static void omega_buginfo P((int, struct refclockbug *)); -static void omega_send P((struct omegaunit *, char *)); - -/* - * Transfer vector - */ -struct refclock refclock_omega = { - omega_start, omega_shutdown, omega_poll, - omega_control, omega_init, omega_buginfo, NOFLAGS -}; - -/* - * omega_init - initialize internal omega driver data - */ -static void -omega_init() -{ - register int i; - /* - * Just zero the data arrays - */ - memset((char *)omegaunits, 0, sizeof omegaunits); - memset((char *)unitinuse, 0, sizeof unitinuse); - - /* - * Initialize fudge factors to default. - */ - for (i = 0; i < MAXUNITS; i++) { - fudgefactor1[i].l_ui = 0; - fudgefactor1[i].l_uf = DEFFUDGETIME; - fudgefactor2[i].l_ui = 0; - fudgefactor2[i].l_uf = 0; - stratumtouse[i] = 0; - readonlyclockflag[i] = 0; - memcpy((char *)&refid[i], OMEGAREFID, 4); - } -} - - -/* - * omega_start - open the OMEGA devices and initialize data for processing - */ -static int -omega_start(unit, peer) - u_int unit; - struct peer *peer; -{ - register struct omegaunit *omega; - register int i; - int fd232; - char omegadev[20]; - - /* - * Check configuration info - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR,"omega_start: unit %d invalid", unit); - return 0; - } - if (unitinuse[unit]) { - syslog(LOG_ERR, "omega_start: unit %d in use", unit); - return 0; - } - - /* - * Open serial port - */ - (void) sprintf(omegadev, OMEGA232, unit); - fd232 = open(omegadev, O_RDWR, 0777); - if (fd232 == -1) { - syslog(LOG_ERR, "omega_start: open of %s: %m", omegadev); - return 0; - } - -#if defined(HAVE_SYSV_TTYS) - /* - * System V serial line parameters (termio interface) - * - */ - { struct termio ttyb; - if (ioctl(fd232, TCGETA, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TCGETA): %m", omegadev); - goto screwed; - } - ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyb.c_oflag = 0; - ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyb.c_lflag = ICANON; - ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0'; - if (ioctl(fd232, TCSETA, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TCSETA): %m", omegadev); - goto screwed; - } - } -#endif /* HAVE_SYSV_TTYS */ -#if defined(HAVE_TERMIOS) - /* - * POSIX serial line parameters (termios interface) - * - * The OMEGACLK option provides timestamping at the driver level. - * It requires the tty_clk streams module. - * - * The OMEGAPPS option provides timestamping at the driver level. - * It uses a 1-pps signal and level converter (gadget box) and - * requires the ppsclock streams module and SunOS 4.1.1 or - * later. - */ - { struct termios ttyb, *ttyp; - - ttyp = &ttyb; - if (tcgetattr(fd232, ttyp) < 0) { - syslog(LOG_ERR, - "omega_start: tcgetattr(%s): %m", omegadev); - goto screwed; - } - ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL; - ttyp->c_oflag = 0; - ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD; - ttyp->c_lflag = ICANON; - ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0'; - if (tcsetattr(fd232, TCSANOW, ttyp) < 0) { - syslog(LOG_ERR, - "omega_start: tcsetattr(%s): %m", omegadev); - goto screwed; - } - if (tcflush(fd232, TCIOFLUSH) < 0) { - syslog(LOG_ERR, - "omega_start: tcflush(%s): %m", omegadev); - goto screwed; - } - } -#endif /* HAVE_TERMIOS */ -#ifdef STREAM -#if defined(OMEGACLK) - if (ioctl(fd232, I_PUSH, "clk") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, I_PUSH, clk): %m", omegadev); - if (ioctl(fd232, CLK_SETSTR, "\n") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, CLK_SETSTR): %m", omegadev); -#endif /* OMEGACLK */ -#if defined(OMEGAPPS) - if (ioctl(fd232, I_PUSH, "ppsclock") < 0) - syslog(LOG_ERR, - "omega_start: ioctl(%s, I_PUSH, ppsclock): %m", omegadev); - else - fdpps = fd232; -#endif /* OMEGAPPS */ -#endif /* STREAM */ -#if defined(HAVE_BSD_TTYS) - /* - * 4.3bsd serial line parameters (sgttyb interface) - * - * The OMEGACLK option provides timestamping at the driver level. - * It requires the tty_clk line discipline and 4.3bsd or later. - */ - { struct sgttyb ttyb; -#if defined(OMEGACLK) - int ldisc = CLKLDISC; -#endif /* OMEGACLK */ - - if (ioctl(fd232, TIOCGETP, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCGETP): %m", omegadev); - goto screwed; - } - ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232; -#if defined(OMEGACLK) - ttyb.sg_erase = ttyb.sg_kill = '\r'; - ttyb.sg_flags = RAW; -#else - ttyb.sg_erase = ttyb.sg_kill = '\0'; - ttyb.sg_flags = EVENP|ODDP|CRMOD; -#endif /* OMEGACLK */ - if (ioctl(fd232, TIOCSETP, &ttyb) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCSETP): %m", omegadev); - goto screwed; - } -#if defined(OMEGACLK) - if (ioctl(fd232, TIOCSETD, &ldisc) < 0) { - syslog(LOG_ERR, - "omega_start: ioctl(%s, TIOCSETD): %m",omegadev); - goto screwed; - } -#endif /* OMEGACLK */ - } -#endif /* HAVE_BSD_TTYS */ - - /* - * Allocate unit structure - */ - if (omegaunits[unit] != 0) { - omega = omegaunits[unit]; /* The one we want is okay */ - } else { - for (i = 0; i < MAXUNITS; i++) { - if (!unitinuse[i] && omegaunits[i] != 0) - break; - } - if (i < MAXUNITS) { - /* - * Reclaim this one - */ - omega = omegaunits[i]; - omegaunits[i] = 0; - } else { - omega = (struct omegaunit *) - emalloc(sizeof(struct omegaunit)); - } - } - memset((char *)omega, 0, sizeof(struct omegaunit)); - omegaunits[unit] = omega; - - /* - * Set up the structures - */ - omega->peer = peer; - omega->unit = (u_char)unit; - omega->timestarted = current_time; - omega->station = STATION_NONE; - - omega->io.clock_recv = omega_receive; - omega->io.srcclock = (caddr_t)omega; - omega->io.datalen = 0; - omega->io.fd = fd232; - if (!io_addclock(&omega->io)) { - goto screwed; - } - - /* - * All done. Initialize a few random peer variables, then - * return success. - */ - peer->precision = OMEGAPRECISION; - peer->rootdelay = 0; - peer->rootdispersion = 0; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - unitinuse[unit] = 1; - return 1; - - /* - * Something broke; abandon ship - */ -screwed: - (void) close(fd232); - return 0; -} - - -/* - * omega_shutdown - shut down a OMEGA clock - */ -static void -omega_shutdown(unit) - int unit; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_shutdown: unit %d invalid", - unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "omega_shutdown: unit %d not in use", unit); - return; - } - - /* - * Tell the I/O module to turn us off. We're history. - */ - omega = omegaunits[unit]; - io_closeclock(&omega->io); - unitinuse[unit] = 0; -} - - -/* - * omega_report_event - note the occurance of an event - */ -static void -omega_report_event(omega, code) - struct omegaunit *omega; - int code; -{ - struct peer *peer; - - peer = omega->peer; - if (omega->status != (u_char)code) { - omega->status = (u_char)code; - if (code != CEVNT_NOMINAL) - omega->lastevent = (u_char)code; - syslog(LOG_INFO, - "omega clock %s event %x\n", ntoa(&peer->srcadr), code); - } -} - - -/* - * omega_receive - receive data from the serial interface on a - * Kinemetrics OM-DC OMEGA clock. - */ -static void -omega_receive(rbufp) - struct recvbuf *rbufp; -{ - register int i; - register struct omegaunit *omega; - register u_char *dpt; - register char *cp, *cpend; - register u_char *dpend; - l_fp tstmp; - u_fp dispersion, drift; - - /* - * Get the clock this applies to and a pointers to the data - */ - omega = (struct omegaunit *)rbufp->recv_srcclock; - dpt = (u_char *)&rbufp->recv_space; - -#ifndef PEDANTIC - /* - * The OM-DC outputs a timecode every second, but we only want - * a set of NSTAMPS timecodes when polled (every 64 seconds). - * Setting PEDANTIC causes a sanity check on every timecode. - */ - if (!omega->polled) - return; -#endif - - /* - * Edit timecode to remove control chars - */ - dpend = dpt + rbufp->recv_length; - cp = omega->lastcode; - cpend = omega->lastcode + BMAX - 1; - while (dpt < dpend && cp < cpend) { - if ((*cp = 0x7f & *dpt++) >= ' ') cp++; -#ifdef OMEGACLK - else if (*cp == '\r') { - if (dpend - dpt < 8) { - /* short timestamp */ - return; - } - if (!buftvtots(dpt,&omega->lastrec)) { - /* screwy timestamp */ - return; - } - dpt += 8; - } -#endif - } - *cp = '\0'; - omega->lencode = cp - omega->lastcode; - - if (omega->lencode == 0) - return; - else if (omega->lencode != LENOMEGA) { - omega->badformat++; - /* Sometimes get a lot of these, filling the log with noise */ - /* omega_report_event(omega, CEVNT_BADREPLY); */ - return; - } - -#ifndef OMEGACLK - omega->lastrec = rbufp->recv_time; -#endif - -#ifdef DEBUG - if (debug) - printf("omega: timecode %d %s\n", - omega->lencode, omega->lastcode); -#endif - - /* - * We get down to business, check the timecode format - * and decode its contents. - */ - cp = omega->lastcode; - omega->leap = 0; - /* - * Check timecode format. - */ - if (!isdigit(cp[0]) || /* day of year */ - !isdigit(cp[1]) || - !isdigit(cp[2]) || - cp[3] != ':' || /* */ - !isdigit(cp[4]) || /* hours */ - !isdigit(cp[5]) || - cp[6] != ':' || /* : separator */ - !isdigit(cp[7]) || /* minutes */ - !isdigit(cp[8]) || - cp[9] != ':' || /* : separator */ - !isdigit(cp[10]) || /* seconds */ - !isdigit(cp[11])) { - omega->badformat++; - omega_report_event(omega, CEVNT_BADREPLY); - return; - } - - /* - * Convert and check values. - */ - omega->year = 0; /* fake */ - omega->day = cp[0] - '0'; - omega->day = MULBY10(omega->day) + cp[1] - '0'; - omega->day = MULBY10(omega->day) + cp[2] - '0'; - omega->hour = MULBY10(cp[4] - '0') + cp[5] - '0'; - omega->minute = MULBY10(cp[7] - '0') + cp[8] - '0'; - omega->second = MULBY10(cp[10] - '0') + cp[11] - '0'; - omega->msec = 0; - - if (omega->day < 1 || omega->day > 366) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADDATE); - return; - } - if (omega->hour > 23 || omega->minute > 59 || omega->second > 59) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - - /* - * Check quality/station-id flag. The OM-DC should normally stay - * permanently locked to a station, and its time error should be less - * than 1 msec. If it loses lock for any reason, it makes a worst - * case drift estimate based on the internally stored stability figure - * for its reference oscillator. The stability figure can be adjusted - * by the user based on experience. The default value is 1E05, which - * is pretty bad - 2E07 is about right for the unit I have. - * - * The following is arbitrary, change it if you're offended: - * For errors less than 50 msec, just clear the station indicator. - * For errors greater than 50 msec, flag loss of sync and report a - * propagation problem. If the error is greater than 500 msec, - * something is dreadfully wrong - report a clock fault. - * - * In each case, we set a drift estimate which is used below as an - * estimate of measurement accuracy. - */ - omega->quality = cp[12]; - if (cp[12] == '>' || cp[12] == '?') { - /* Error 500 to 5000 msec */ - omega_report_event(omega, CEVNT_FAULT); - omega->leap = LEAP_NOTINSYNC; - omega->station = STATION_NONE; - drift = U_FP5000MS; - } else if (cp[12] == '#') { - /* Error 50 to 500 msec */ - omega_report_event(omega, CEVNT_PROP); - omega->leap = LEAP_NOTINSYNC; - omega->station = STATION_NONE; - drift = U_FP500MS; - } else if (cp[12] == '*') { - /* Error 5 to 50 msec */ - omega->lasttime = current_time; - omega->station = STATION_NONE; - drift = U_FP50MS; - } else if (cp[12] == '.') { - /* Error 1 to 5 msec */ - omega->lasttime = current_time; - omega->station = STATION_NONE; - drift = U_FP5MS; - } else if ('A' <= cp[12] && cp[12] <= 'H') { - /* Error less than 1 msec */ - omega->lasttime = current_time; - omega->station = cp[12] - 'A' + 1; - drift = 0; - } else { - omega->badformat++; - omega_report_event(omega, CEVNT_BADREPLY); - return; - } - -#ifdef PEDANTIC - /* If we haven't been polled, bail out. */ - if (!omega->polled) - return; -#endif - - /* - * Now, compute the reference time value. Use the heavy - * machinery for the seconds and the millisecond field for the - * fraction when present. - * - * this code does not yet know how to do the years - */ - tstmp = omega->lastrec; - if (!clocktime(omega->day, omega->hour, omega->minute, - omega->second, GMT, tstmp.l_ui, - &omega->yearstart, &omega->lastref.l_ui)) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - MSUTOTSF(omega->msec, omega->lastref.l_uf); - - /* - * Adjust the read value by fudgefactor1 to correct RS232 delays. - */ - L_ADD(&omega->lastref, &fudgefactor1[omega->unit]); - - /* Carousel of NSTAMPS offsets. */ - i = omega->coderecv % NSTAMPS; - omega->offset[i] = omega->lastref; - L_SUB(&omega->offset[i], &tstmp); - omega->coderecv++; - - /* If we don't yet have a full set, return. */ - if (omega->coderecv < NSTAMPS) - return; - - /* - * Filter the samples, add the fudge factor and pass the - * offset and dispersion along. We use lastrec as both the - * reference time and receive time in order to avoid being cute, - * like setting the reference time later than the receive time, - * which may cause a paranoid protocol module to chuck out the - * data. If the sample filter chokes because of excessive - * dispersion or whatever, get a new sample (omega->coderecv - * is still >= NSTAMPS) and try again. - */ - if (!omega_process(omega, &tstmp, &dispersion)) { - omega->baddata++; - omega_report_event(omega, CEVNT_BADTIME); - return; - } - - /* - * Add accumulated clock drift to the dispersion to get - * a (hopefully) meaningful measurement accuracy estimate. - */ - dispersion += drift; - refclock_receive(omega->peer, &tstmp, GMT, dispersion, - &omega->lastrec, &omega->lastrec, omega->leap); - - /* - * We have succeeded in answering the poll. If the clock - * is locked, we're nominal. - */ - omega->polled = 0; - omega->coderecv = 0; - if (omega->leap != LEAP_NOTINSYNC) - omega_report_event(omega, CEVNT_NOMINAL); -} - - -/* - * omega_send - time to send the clock a signal to cough up a time sample - */ -static void -omega_send(omega,cmd) - struct omegaunit *omega; - char *cmd; -{ - if (!readonlyclockflag[omega->unit]) { - /* - * Send a command to the clock. - */ - if (write(omega->io.fd, cmd, 1) != 1) { - syslog(LOG_ERR, "omega_send: unit %d: %m", omega->unit); - omega_report_event(omega, CEVNT_FAULT); - } - } -} - - -/* - * Compare two l_fp's, used with qsort() - */ -static int -omega_cmpl_fp(p1, p2) - register void *p1, *p2; -{ - - if (!L_ISGEQ((l_fp *)p1, (l_fp *)p2)) - return (-1); - if (L_ISEQU((l_fp *)p1, (l_fp *)p2)) - return (0); - return (1); -} - - -/* - * omega_process - process a pile of samples from the clock - */ -static char -omega_process(omega, offset, dispersion) - struct omegaunit *omega; - l_fp *offset; - u_fp *dispersion; -{ - register int i, n; - register U_LONG med_ui, med_uf, tmp_ui, tmp_uf; - l_fp off[NSTAMPS]; - u_fp disp; - - /* Copy in offsets and sort into ascending order */ - for (i = 0; i < NSTAMPS; i++) - off[i] = omega->offset[i]; - qsort((char *)off, NSTAMPS, sizeof(l_fp), omega_cmpl_fp); - /* - * Reject the furthest from the median until NSKEEP samples remain - */ - i = 0; - n = NSTAMPS; - while ((n - i) > NSKEEP) { - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - med_ui = off[(n+i)/2].l_ui; - med_uf = off[(n+i)/2].l_uf; - M_SUB(tmp_ui, tmp_uf, med_ui, med_uf); - M_SUB(med_ui, med_uf, off[i].l_ui, off[i].l_uf); - if (M_ISHIS(med_ui, med_uf, tmp_ui, tmp_uf)) { - /* reject low end */ - i++; - } else { - /* reject high end */ - n--; - } - } - - /* - * Compute the dispersion based on the difference between the - * extremes of the remaining offsets. If this is greater than - * the allowed sample set dispersion, bail out. Otherwise, - * return the median offset and the dispersion. - */ - tmp_ui = off[n-1].l_ui; - tmp_uf = off[n-1].l_uf; - M_SUB(tmp_ui, tmp_uf, off[i].l_ui, off[i].l_uf); - disp = MFPTOFP(tmp_ui, tmp_uf); - if (disp > OMEGAMAXDISPERSE) - return 0; - *offset = off[(n+1)/2]; - *dispersion = disp; - return 1; -} - - -/* - * omega_poll - called by the transmit procedure - */ -static void -omega_poll(unit, peer) - int unit; - struct peer *peer; -{ - struct omegaunit *omega; - - /* - * You don't need to poll this clock. It puts out timecodes - * once per second. If asked for a timestamp, take note. - * The next time a timecode comes in, it will be fed back. - */ - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_poll: unit %d invalid", unit); - return; - } - if (!unitinuse[unit]) { - syslog(LOG_ERR, "omega_poll: unit %d not in use", unit); - return; - } - omega = omegaunits[unit]; - if ((current_time - omega->lasttime) > 150) { - omega->noreply++; - omega_report_event(omegaunits[unit], CEVNT_TIMEOUT); - } - - /* - * polled every 64 seconds. Ask OMEGA_RECEIVE to hand in a timestamp. - */ - omega->polled = 1; - omega->polls++; - /* - * Ensure the clock is running in the correct mode - on-second - * timestamps. - */ - omega_send(omega,"C"); -} - - -/* - * omega_control - set fudge factors, return statistics - */ -static void -omega_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_control: unit %d invalid", unit); - return; - } - - if (in != 0) { - if (in->haveflags & CLK_HAVETIME1) - fudgefactor1[unit] = in->fudgetime1; - if (in->haveflags & CLK_HAVETIME2) - fudgefactor2[unit] = in->fudgetime2; - if (in->haveflags & CLK_HAVEVAL1) - stratumtouse[unit] = (u_char)(in->fudgeval1); - if (in->haveflags & CLK_HAVEVAL2) - refid[unit] = in->fudgeval2; - if (in->haveflags & CLK_HAVEFLAG1) - readonlyclockflag[unit] = in->flags & CLK_FLAG1; - if (unitinuse[unit]) { - struct peer *peer; - - peer = omegaunits[unit]->peer; - peer->stratum = stratumtouse[unit]; - peer->refid = refid[unit]; - } - } - - if (out != 0) { - out->type = REFCLK_OMEGA_TRUETIME; - out->haveflags = CLK_HAVETIME1 | CLK_HAVETIME2 | CLK_HAVEVAL1 | - CLK_HAVEVAL2| CLK_HAVEFLAG1; - out->clockdesc = OMEGADESCRIPTION; - out->fudgetime1 = fudgefactor1[unit]; - out->fudgetime2 = fudgefactor2[unit]; - out->fudgeval1 = (LONG)stratumtouse[unit]; - out->fudgeval2 = refid[unit]; - out->flags = readonlyclockflag[unit]; - if (unitinuse[unit]) { - omega = omegaunits[unit]; - out->flags |= omega->station << 1; - out->lencode = omega->lencode; - out->lastcode = omega->lastcode; - out->timereset = current_time - omega->timestarted; - out->polls = omega->polls; - out->noresponse = omega->noreply; - out->badformat = omega->badformat; - out->baddata = omega->baddata; - out->lastevent = omega->lastevent; - out->currentstatus = omega->status; - } - } -} - - -/* - * omega_buginfo - return clock dependent debugging info - */ -static void -omega_buginfo(unit, bug) - int unit; - register struct refclockbug *bug; -{ - register struct omegaunit *omega; - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, "omega_buginfo: unit %d invalid", unit); - return; - } - - if (!unitinuse[unit]) - return; - omega = omegaunits[unit]; - - bug->nvalues = 11; - bug->ntimes = 5; - if (omega->lasttime != 0) - bug->values[0] = current_time - omega->lasttime; - else - bug->values[0] = 0; - bug->values[1] = (U_LONG)omega->reason; - bug->values[2] = (U_LONG)omega->year; - bug->values[3] = (U_LONG)omega->day; - bug->values[4] = (U_LONG)omega->hour; - bug->values[5] = (U_LONG)omega->minute; - bug->values[6] = (U_LONG)omega->second; - bug->values[7] = (U_LONG)omega->msec; - bug->values[8] = omega->noreply; - bug->values[9] = omega->yearstart; - bug->values[10] = omega->quality; - bug->stimes = 0x1c; - bug->times[0] = omega->lastref; - bug->times[1] = omega->lastrec; - bug->times[2] = omega->offset[0]; - bug->times[3] = omega->offset[1]; - bug->times[4] = omega->offset[2]; -} -#endif diff --git a/usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c b/usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c deleted file mode 100644 index 0d95d18908a5..000000000000 --- a/usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c +++ /dev/null @@ -1,3605 +0,0 @@ -#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) -/* - * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp - * - * refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp - * - * generic reference clock driver for receivers - * - * make use of a STREAMS module for input processing where - * available and configured. Currently the STREAMS module - * is only available for Suns running SunOS 4.x and SunOS5.x (new - careful!) - * - * Copyright (c) 1989,1990,1991,1992,1993,1994 - * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg - * - * 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. - * - */ - -/* - * Defines: - * REFCLOCK && (PARSE||PARSEPPS) - * - enable this mess - * STREAM - allow for STREAMS modules - * ("parse", "ppsclocd", "ppsclock") - * PARSEPPS - provide PPS information to loopfilter (for - * backward compatibilty only) - * PPS - supply loopfilter with PPS samples (if configured) - * PPSPPS - notify loopfilter of PPS file descriptor - * - * FREEBSD_CONRAD - Make very cheap "Conrad DCF77 RS-232" gadget work - * with FreeBSD. - * TTY defines: - * HAVE_BSD_TTYS - currently unsupported - * HAVE_SYSV_TTYS - will use termio.h - * HAVE_TERMIOS - will use termios.h - * STREAM - will use streams and implies HAVE_TERMIOS - */ - -/* - * This driver currently provides the support for - * - Meinberg DCF77 receiver DCF77 PZF 535 (TCXO version) (DCF) - * - Meinberg DCF77 receiver DCF77 PZF 535 (OCXO version) (DCF) - * - Meinberg DCF77 receiver U/A 31 (DCF) - * - ELV DCF7000 (DCF) - * - Schmid clock (DCF) - * - Conrad DCF77 receiver module (DCF) - * - FAU DCF77 NTP receiver (TimeBrick) (DCF) - * - Meinberg GPS166 (GPS) - * - Trimble SV6 (GPS) - * - */ - -/* - * Meinberg receivers are connected via a 9600 baud serial line - * - * Receivers that do NOT support: - * - leap second indication - * DCF U/A 31 - * DCF PZF535 (stock version) - * - * so... - * - for PZF535 please ask for revision PZFUERL4.6 or higher - * (support for leap second and alternate antenna) - * - * The Meinberg GPS receiver also has a special NTP time stamp - * format. The firmware release is Uni-Erlangen. Only this - * firmware release is supported by xntp3. - * - * Meinberg generic receiver setup: - * output time code every second - * Baud rate 9600 7E2S - */ - -#include "ntpd.h" -#include "ntp_refclock.h" -#include "ntp_unixtime.h" -#include "ntp_control.h" - -#include -#include -#include - -#include -#ifdef FREEBSD_CONRAD -#include -#endif -extern int errno; - -#if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS) -/* #error NEED TO DEFINE ONE OF "STREAM" or "HAVE_SYSV_TTYS" */ -NEED TO DEFINE ONE OF "STREAM", "HAVE_SYSV_TTYS" or "HAVE_TERMIOS" -#endif - -#ifdef STREAM -#include -#include -#ifndef HAVE_TERMIOS -#define HAVE_TERMIOS -#endif -#endif - -#ifdef HAVE_TERMIOS -#include -#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_)) -#define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_)) -#undef HAVE_SYSV_TTYS -#endif - -#ifdef HAVE_SYSV_TTYS -#include -#define TTY_GETATTR(_FD_, _ARG_) ioctl((_FD_), TCGETA, (_ARG_)) -#define TTY_SETATTR(_FD_, _ARG_) ioctl((_FD_), TCSETAW, (_ARG_)) -#endif - -#ifdef HAVE_BSD_TTYS -/* #error CURRENTLY NO BSD TTY SUPPORT */ -CURRENTLY NO BSD TTY SUPPORT -#endif - -#if !defined(O_RDWR) /* XXX SOLARIS */ -#include -#endif /* !def(O_RDWR) */ - -#ifdef PPSPPS -#include -#endif - -#include "ntp_select.h" -#include "ntp_stdlib.h" - -#include "parse.h" - -#if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__) -static char rcsid[]="refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp"; -#endif - -/**=========================================================================== - ** external interface to xntp mechanism - **/ - -static void parse_init P((void)); -static int parse_start P((u_int, struct peer *)); -static void parse_shutdown P((int)); -static void parse_poll P((int, struct peer *)); -static void parse_control P((u_int, struct refclockstat *, struct refclockstat *)); - -#define parse_buginfo noentry - -struct refclock refclock_parse = { - parse_start, - parse_shutdown, - parse_poll, - parse_control, - parse_init, - parse_buginfo, - NOFLAGS -}; - -/* - * the unit field selects for one the prototype to be used (lower 4 bits) - * and for the other the clock type in case of different but similar - * receivers (bits 4-6) - * the most significant bit encodes PPS support - * when the most significant bit is set the pps telegrams will be used - * for controlling the local clock (ntp_loopfilter.c) - * receiver specific configration data is kept in the clockinfo field. - */ - -/* - * Definitions - */ -#define MAXUNITS 4 /* maximum number of "PARSE" units permitted */ -#define PARSEDEVICE "/dev/refclock-%d" /* device to open %d is unit number */ - -/**=========================================================================== - ** function vector for dynamically binding io handling mechanism - **/ - -typedef struct bind -{ - char *bd_description; /* name of type of binding */ - int (*bd_init)(); /* initialize */ - void (*bd_end)(); /* end */ - int (*bd_setcs)(); /* set character size */ - int (*bd_disable)(); /* disable */ - int (*bd_enable)(); /* enable */ - int (*bd_getfmt)(); /* get format */ - int (*bd_setfmt)(); /* setfmt */ - int (*bd_getstat)(); /* getstat */ - int (*bd_setstat)(); /* setstat */ - int (*bd_timecode)(); /* get time code */ - void (*bd_receive)(); /* receive operation */ - void (*bd_poll)(); /* poll operation */ -} bind_t; - -#define PARSE_END(_X_) (*(_X_)->binding->bd_end)(_X_) -#define PARSE_SETCS(_X_, _CS_) (*(_X_)->binding->bd_setcs)(_X_, _CS_) -#define PARSE_ENABLE(_X_) (*(_X_)->binding->bd_enable)(_X_) -#define PARSE_DISABLE(_X_) (*(_X_)->binding->bd_disable)(_X_) -#define PARSE_GETFMT(_X_, _DCT_) (*(_X_)->binding->bd_getfmt)(_X_, _DCT_) -#define PARSE_SETFMT(_X_, _DCT_) (*(_X_)->binding->bd_setfmt)(_X_, _DCT_) -#define PARSE_GETSTAT(_X_, _DCT_) (*(_X_)->binding->bd_getstat)(_X_, _DCT_) -#define PARSE_SETSTAT(_X_, _DCT_) (*(_X_)->binding->bd_setstat)(_X_, _DCT_) -#define PARSE_GETTIMECODE(_X_, _DCT_) (*(_X_)->binding->bd_timecode)(_X_, _DCT_) -#define PARSE_POLL(_X_) (*(_X_)->binding->bd_poll)(_X_) - -/* - * io modes - */ -#define PARSE_F_NOPOLLONLY 0x0001 /* always do async io (possible PPS support via PARSE) */ -#define PARSE_F_POLLONLY 0x0002 /* never do async io (no PPS support via PARSE) */ -#define PARSE_F_PPSPPS 0x0004 /* use loopfilter PPS code (CIOGETEV) */ -#define PARSE_F_PPSONSECOND 0x0008 /* PPS pulses are on second */ - -/**=========================================================================== - ** refclock instance data - **/ - -struct parseunit -{ - /* - * XNTP management - */ - struct peer *peer; /* backlink to peer structure - refclock inactive if 0 */ - int fd; /* device file descriptor */ - u_char unit; /* encoded unit/type/PPS */ - - /* - * XNTP io - */ - struct refclockio io; /* io system structure (used in PPS mode) */ - bind_t *binding; /* io handling binding */ - - /* - * parse state - */ - parse_t parseio; /* io handling structure (user level parsing) */ - - /* - * type specific parameters - */ - struct clockinfo *parse_type; /* link to clock description */ - - /* - * clock specific configuration - */ - l_fp basedelay; /* clock local phase offset */ - l_fp ppsdelay; /* clock local pps phase offset */ - - /* - * clock state handling/reporting - */ - u_char flags; /* flags (leap_control) */ - u_char status; /* current status */ - u_char lastevent; /* last not NORMAL status */ - U_LONG lastchange; /* time (xntp) when last state change accured */ - U_LONG statetime[CEVNT_MAX+1]; /* accumulated time of clock states */ - struct event stattimer; /* statistics timer */ - U_LONG polls; /* polls from NTP protocol machine */ - U_LONG noresponse; /* number of expected but not seen datagrams */ - U_LONG badformat; /* bad format (failed format conversions) */ - U_LONG baddata; /* usually bad receive length, bad format */ - - u_char pollonly; /* 1 for polling only (no PPS mode) */ - u_char pollneeddata; /* 1 for receive sample expected in PPS mode */ - U_LONG laststatus; /* last packet status (error indication) */ - u_short lastformat; /* last format used */ - U_LONG lastsync; /* time (xntp) when clock was last seen fully synchronized */ - U_LONG timestarted; /* time (xntp) when peer clock was instantiated */ - U_LONG nosynctime; /* time (xntp) when last nosync message was posted */ - U_LONG lastmissed; /* time (xntp) when poll didn't get data (powerup heuristic) */ - U_LONG ppsserial; /* magic cookie for ppsclock serials (avoids stale ppsclock data) */ - parsetime_t time; /* last (parse module) data */ - void *localdata; /* optional local data */ -}; - - -/**=========================================================================== - ** Clockinfo section all parameter for specific clock types - ** includes NTP paramaters, TTY parameters and IO handling parameters - **/ - -static void poll_dpoll P((struct parseunit *)); -static void poll_poll P((struct parseunit *)); -static int poll_init P((struct parseunit *)); -static void poll_end P((struct parseunit *)); - -typedef struct poll_info -{ - U_LONG rate; /* poll rate - once every "rate" seconds - 0 off */ - char * string; /* string to send for polling */ - U_LONG count; /* number of charcters in string */ -} poll_info_t; - -#define NO_FLAGS 0 -#define NO_POLL (void (*)())0 -#define NO_INIT (int (*)())0 -#define NO_END (void (*)())0 -#define NO_DATA (void *)0 -#define NO_FORMAT "" -#define NO_PPSDELAY 0 - -#define DCF_ID "DCF" /* generic DCF */ -#define DCF_A_ID "DCFa" /* AM demodulation */ -#define DCF_P_ID "DCFp" /* psuedo random phase shift */ -#define GPS_ID "GPS" /* GPS receiver */ - -#define NOCLOCK_ROOTDELAY 0x00000000 -#define NOCLOCK_BASEDELAY 0x00000000 -#define NOCLOCK_DESCRIPTION ((char *)0) -#define NOCLOCK_MAXUNSYNC 0 -#define NOCLOCK_CFLAG 0 -#define NOCLOCK_IFLAG 0 -#define NOCLOCK_OFLAG 0 -#define NOCLOCK_LFLAG 0 -#define NOCLOCK_ID "TILT" -#define NOCLOCK_POLL NO_POLL -#define NOCLOCK_INIT NO_INIT -#define NOCLOCK_END NO_END -#define NOCLOCK_DATA NO_DATA -#define NOCLOCK_FORMAT NO_FORMAT -#define NOCLOCK_TYPE CTL_SST_TS_UNSPEC - -#define DCF_TYPE CTL_SST_TS_LF -#define GPS_TYPE CTL_SST_TS_UHF - -/* - * receiver specific constants - */ -#define MBG_CFLAG19200 (B19200|CS7|PARENB|CREAD|HUPCL) -#define MBG_CFLAG (B9600|CS7|PARENB|CREAD|HUPCL) -#define MBG_IFLAG (IGNBRK|IGNPAR|ISTRIP) -#define MBG_OFLAG 0 -#define MBG_LFLAG 0 -/* - * Meinberg DCF U/A 31 (AM) receiver - */ -#define DCFUA31_ROOTDELAY 0x00000D00 /* 50.78125ms */ -#define DCFUA31_BASEDELAY 0x02C00000 /* 10.7421875ms: 10 ms (+/- 3 ms) */ -#define DCFUA31_DESCRIPTION "Meinberg DCF U/A 31" -#define DCFUA31_MAXUNSYNC 60*30 /* only trust clock for 1/2 hour */ -#define DCFUA31_CFLAG MBG_CFLAG -#define DCFUA31_IFLAG MBG_IFLAG -#define DCFUA31_OFLAG MBG_OFLAG -#define DCFUA31_LFLAG MBG_LFLAG - -/* - * Meinberg DCF PZF535/TCXO (FM/PZF) receiver - */ -#define DCFPZF535_ROOTDELAY 0x00000034 /* 800us */ -#define DCFPZF535_BASEDELAY 0x00800000 /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define DCFPZF535_DESCRIPTION "Meinberg DCF PZF 535/TCXO" -#define DCFPZF535_MAXUNSYNC 60*60*12 /* only trust clock for 12 hours - * @ 5e-8df/f we have accumulated - * at most 2.16 ms (thus we move to - * NTP synchronisation */ -#define DCFPZF535_CFLAG MBG_CFLAG -#define DCFPZF535_IFLAG MBG_IFLAG -#define DCFPZF535_OFLAG MBG_OFLAG -#define DCFPZF535_LFLAG MBG_LFLAG - - -/* - * Meinberg DCF PZF535/OCXO receiver - */ -#define DCFPZF535OCXO_ROOTDELAY 0x00000034 /* 800us (max error * 10) */ -#define DCFPZF535OCXO_BASEDELAY 0x00800000 /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define DCFPZF535OCXO_DESCRIPTION "Meinberg DCF PZF 535/OCXO" -#define DCFPZF535OCXO_MAXUNSYNC 60*60*96 /* only trust clock for 4 days - * @ 5e-9df/f we have accumulated - * at most an error of 1.73 ms - * (thus we move to NTP synchronisation) */ -#define DCFPZF535OCXO_CFLAG MBG_CFLAG -#define DCFPZF535OCXO_IFLAG MBG_IFLAG -#define DCFPZF535OCXO_OFLAG MBG_OFLAG -#define DCFPZF535OCXO_LFLAG MBG_LFLAG - -/* - * Meinberg GPS166 receiver - */ -#define GPS166_ROOTDELAY 0x00000000 /* nothing here */ -#define GPS166_BASEDELAY 0x00800000 /* XXX to be fixed ! 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */ -#define GPS166_DESCRIPTION "Meinberg GPS166 receiver" -#define GPS166_MAXUNSYNC 0 /* this clock is immediately lost */ -#define GPS166_CFLAG MBG_CFLAG -#define GPS166_IFLAG MBG_IFLAG -#define GPS166_OFLAG MBG_OFLAG -#define GPS166_LFLAG MBG_LFLAG -#define GPS166_POLL NO_POLL -#define GPS166_INIT NO_INIT -#define GPS166_END NO_END -#define GPS166_DATA NO_DATA -#define GPS166_ID GPS_ID -#define GPS166_FORMAT NO_FORMAT - -/* - * ELV DCF7000 Wallclock-Receiver/Switching Clock (Kit) - * - * This is really not the hottest clock - but before you have nothing ... - */ -#define DCF7000_ROOTDELAY 0x00000364 /* 13 ms */ -#define DCF7000_BASEDELAY 0x67AE0000 /* 405 ms - slow blow */ -#define DCF7000_DESCRIPTION "ELV DCF7000" -#define DCF7000_MAXUNSYNC (60*5) /* sorry - but it just was not build as a clock */ -#define DCF7000_CFLAG (B9600|CS8|CREAD|PARENB|PARODD|CLOCAL|HUPCL) -#define DCF7000_IFLAG (IGNBRK) -#define DCF7000_OFLAG 0 -#define DCF7000_LFLAG 0 - -/* - * Schmid DCF Receiver Kit - * - * When the WSDCF clock is operating optimally we want the primary clock - * distance to come out at 300 ms. Thus, peer.distance in the WSDCF peer - * structure is set to 290 ms and we compute delays which are at least - * 10 ms long. The following are 290 ms and 10 ms expressed in u_fp format - */ -#define WS_POLLRATE 1 /* every second - watch interdependency with poll routine */ -#define WS_POLLCMD "\163" -#define WS_CMDSIZE 1 - -static poll_info_t wsdcf_pollinfo = { WS_POLLRATE, WS_POLLCMD, WS_CMDSIZE }; - -#define WSDCF_INIT poll_init -#define WSDCF_POLL poll_dpoll -#define WSDCF_END poll_end -#define WSDCF_DATA ((void *)(&wsdcf_pollinfo)) -#define WSDCF_ROOTDELAY 0X00004A3D /* ~ 290ms */ -#define WSDCF_BASEDELAY 0x028F5C29 /* ~ 10ms */ -#define WSDCF_DESCRIPTION "WS/DCF Receiver" -#define WSDCF_FORMAT "Schmid" -#define WSDCF_MAXUNSYNC (60*60) /* assume this beast hold at 1 h better than 2 ms XXX-must verify */ -#define WSDCF_CFLAG (B1200|CS8|CREAD|CLOCAL) -#define WSDCF_IFLAG 0 -#define WSDCF_OFLAG 0 -#define WSDCF_LFLAG 0 - -/* - * RAW DCF77 - input of DCF marks via RS232 - many variants - */ -#define RAWDCF_FLAGS PARSE_F_NOPOLLONLY -#define RAWDCF_ROOTDELAY 0x00000364 /* 13 ms */ -#define RAWDCF_FORMAT "RAW DCF77 Timecode" -#define RAWDCF_MAXUNSYNC (0) /* sorry - its a true receiver - no signal - no time */ - -#ifdef FREEBSD_CONRAD -#define RAWDCF_CFLAG (CS8|CREAD|CLOCAL) -#else -#define RAWDCF_CFLAG (B50|CS8|CREAD|CLOCAL) -#endif -#define RAWDCF_IFLAG 0 -#define RAWDCF_OFLAG 0 -#define RAWDCF_LFLAG 0 - -/* - * RAW DCF variants - */ -/* - * Conrad receiver - * - * simplest (cheapest) DCF clock - e. g. DCF77 receiver by Conrad - * (~40DM - roughly $30 ) followed by a level converter for RS232 - */ -#define CONRAD_BASEDELAY 0x420C49B0 /* ~258 ms - Conrad receiver @ 50 Baud on a Sun */ -#define CONRAD_DESCRIPTION "RAW DCF77 CODE (Conrad DCF77 receiver module)" - -/* - * TimeBrick receiver - */ -#define TIMEBRICK_BASEDELAY 0x35C29000 /* ~210 ms - TimeBrick @ 50 Baud on a Sun */ -#define TIMEBRICK_DESCRIPTION "RAW DCF77 CODE (TimeBrick)" - -/* - * Trimble SV6 GPS receiver - */ -#define TRIM_POLLRATE 0 /* only true direct polling */ -#define TRIM_POLLCMD ">QTM<" -#define TRIM_CMDSIZE 5 - -static poll_info_t trimble_pollinfo = { TRIM_POLLRATE, TRIM_POLLCMD, TRIM_CMDSIZE }; -static int trimble_init P((struct parseunit *)); - -#define TRIMBLESV6_CFLAG (B4800|CS8|CREAD) -#define TRIMBLESV6_IFLAG (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON) -#define TRIMBLESV6_OFLAG (OPOST|ONLCR) -#define TRIMBLESV6_LFLAG (ICANON|ECHOK) -#define TRIMBLESV6_FLAGS (PARSE_F_PPSPPS|PARSE_F_PPSONSECOND) -#define TRIMBLESV6_POLL poll_dpoll -#define TRIMBLESV6_INIT trimble_init -#define TRIMBLESV6_END poll_end -#define TRIMBLESV6_DATA ((void *)(&trimble_pollinfo)) -#define TRIMBLESV6_ID GPS_ID -#define TRIMBLESV6_FORMAT NO_FORMAT -#define TRIMBLESV6_ROOTDELAY 0x0 -#define TRIMBLESV6_BASEDELAY 0x0 -#define TRIMBLESV6_DESCRIPTION "Trimble SV6 GPS receiver" -#define TRIMBLESV6_MAXUNSYNC 0 -#define TRIMBLESV6_EOL '<' - -static struct clockinfo -{ - U_LONG cl_flags; /* operation flags (io modes) */ - void (*cl_poll)(); /* active poll routine */ - int (*cl_init)(); /* active poll init routine */ - void (*cl_end)(); /* active poll end routine */ - void *cl_data; /* local data area for "poll" mechanism */ - u_fp cl_rootdelay; /* rootdelay */ - U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional part */ - U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional part */ - char *cl_id; /* ID code (usually "DCF") */ - char *cl_description; /* device name */ - char *cl_format; /* fixed format */ - u_char cl_type; /* clock type (ntp control) */ - U_LONG cl_maxunsync; /* time to trust oscillator after loosing synch */ - U_LONG cl_cflag; /* terminal io flags */ - U_LONG cl_iflag; /* terminal io flags */ - U_LONG cl_oflag; /* terminal io flags */ - U_LONG cl_lflag; /* terminal io flags */ -} clockinfo[] = -{ /* 0. 0.0.128 - base offset for PPS support */ - { /* 127.127.8. */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFPZF535_ROOTDELAY, - DCFPZF535_BASEDELAY, - NO_PPSDELAY, - DCF_P_ID, - DCFPZF535_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFPZF535_MAXUNSYNC, - DCFPZF535_CFLAG, - DCFPZF535_IFLAG, - DCFPZF535_OFLAG, - DCFPZF535_LFLAG - }, - { /* 127.127.8.4+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFPZF535OCXO_ROOTDELAY, - DCFPZF535OCXO_BASEDELAY, - NO_PPSDELAY, - DCF_P_ID, - DCFPZF535OCXO_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFPZF535OCXO_MAXUNSYNC, - DCFPZF535OCXO_CFLAG, - DCFPZF535OCXO_IFLAG, - DCFPZF535OCXO_OFLAG, - DCFPZF535OCXO_LFLAG - }, - { /* 127.127.8.8+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCFUA31_ROOTDELAY, - DCFUA31_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - DCFUA31_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCFUA31_MAXUNSYNC, - DCFUA31_CFLAG, - DCFUA31_IFLAG, - DCFUA31_OFLAG, - DCFUA31_LFLAG - }, - { /* 127.127.8.12+ */ - NO_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - DCF7000_ROOTDELAY, - DCF7000_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - DCF7000_DESCRIPTION, - NO_FORMAT, - DCF_TYPE, - DCF7000_MAXUNSYNC, - DCF7000_CFLAG, - DCF7000_IFLAG, - DCF7000_OFLAG, - DCF7000_LFLAG - }, - { /* 127.127.8.16+ */ - NO_FLAGS, - WSDCF_POLL, - WSDCF_INIT, - WSDCF_END, - WSDCF_DATA, - WSDCF_ROOTDELAY, - WSDCF_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - WSDCF_DESCRIPTION, - WSDCF_FORMAT, - DCF_TYPE, - WSDCF_MAXUNSYNC, - WSDCF_CFLAG, - WSDCF_IFLAG, - WSDCF_OFLAG, - WSDCF_LFLAG - }, - { /* 127.127.8.20+ */ - RAWDCF_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - RAWDCF_ROOTDELAY, - CONRAD_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - CONRAD_DESCRIPTION, - RAWDCF_FORMAT, - DCF_TYPE, - RAWDCF_MAXUNSYNC, - RAWDCF_CFLAG, - RAWDCF_IFLAG, - RAWDCF_OFLAG, - RAWDCF_LFLAG - }, - { /* 127.127.8.24+ */ - RAWDCF_FLAGS, - NO_POLL, - NO_INIT, - NO_END, - NO_DATA, - RAWDCF_ROOTDELAY, - TIMEBRICK_BASEDELAY, - NO_PPSDELAY, - DCF_A_ID, - TIMEBRICK_DESCRIPTION, - RAWDCF_FORMAT, - DCF_TYPE, - RAWDCF_MAXUNSYNC, - RAWDCF_CFLAG, - RAWDCF_IFLAG, - RAWDCF_OFLAG, - RAWDCF_LFLAG - }, - { /* 127.127.8.28+ */ - NO_FLAGS, - GPS166_POLL, - GPS166_INIT, - GPS166_END, - GPS166_DATA, - GPS166_ROOTDELAY, - GPS166_BASEDELAY, - NO_PPSDELAY, - GPS166_ID, - GPS166_DESCRIPTION, - GPS166_FORMAT, - GPS_TYPE, - GPS166_MAXUNSYNC, - GPS166_CFLAG, - GPS166_IFLAG, - GPS166_OFLAG, - GPS166_LFLAG - }, - { /* 127.127.8.32+ */ - TRIMBLESV6_FLAGS, - TRIMBLESV6_POLL, - TRIMBLESV6_INIT, - TRIMBLESV6_END, - TRIMBLESV6_DATA, - TRIMBLESV6_ROOTDELAY, - TRIMBLESV6_BASEDELAY, - NO_PPSDELAY, - TRIMBLESV6_ID, - TRIMBLESV6_DESCRIPTION, - TRIMBLESV6_FORMAT, - GPS_TYPE, - TRIMBLESV6_MAXUNSYNC, - TRIMBLESV6_CFLAG, - TRIMBLESV6_IFLAG, - TRIMBLESV6_OFLAG, - TRIMBLESV6_LFLAG - } -}; - -static int ncltypes = sizeof(clockinfo) / sizeof(struct clockinfo); - -#define CL_REALTYPE(x) (((x) >> 2) & 0x1F) -#define CL_TYPE(x) ((CL_REALTYPE(x) >= ncltypes) ? ~0 : CL_REALTYPE(x)) -#define CL_PPS(x) ((x) & 0x80) -#define CL_UNIT(x) ((x) & 0x3) - -/* - * Other constant stuff - */ -#define PARSEHSREFID 0x7f7f08ff /* 127.127.8.255 refid for hi strata */ - -#define PARSENOSYNCREPEAT (10*60) /* mention uninitialized clocks all 10 minutes */ -#define PARSESTATISTICS (60*60) /* output state statistics every hour */ - -static struct parseunit *parseunits[MAXUNITS]; - -extern U_LONG current_time; -extern s_char sys_precision; -extern struct event timerqueue[]; -#ifdef PPSPPS -extern int fdpps; -#endif - -static int notice = 0; - -#define PARSE_STATETIME(parse, i) ((parse->status == i) ? parse->statetime[i] + current_time - parse->lastchange : parse->statetime[i]) - -static void parse_event P((struct parseunit *, int)); -static void parse_process P((struct parseunit *, parsetime_t *)); - -/**=========================================================================== - ** implementation of i/o handling methods - ** (all STREAM, partial STREAM, user level) - **/ - -/* - * define possible io handling methods - */ -#ifdef STREAM -static int ppsclock_init P((struct parseunit *)); -static int stream_init P((struct parseunit *)); -static void stream_nop P((struct parseunit *)); -static int stream_enable P((struct parseunit *)); -static int stream_disable P((struct parseunit *)); -static int stream_setcs P((struct parseunit *, parsectl_t *)); -static int stream_getfmt P((struct parseunit *, parsectl_t *)); -static int stream_setfmt P((struct parseunit *, parsectl_t *)); -static int stream_getstat P((struct parseunit *, parsectl_t *)); -static int stream_setstat P((struct parseunit *, parsectl_t *)); -static int stream_timecode P((struct parseunit *, parsectl_t *)); -static void stream_receive P((struct recvbuf *)); -static void stream_poll P((struct parseunit *)); -#endif - -static int local_init P((struct parseunit *)); -static void local_end P((struct parseunit *)); -static int local_nop P((struct parseunit *)); -static int local_setcs P((struct parseunit *, parsectl_t *)); -static int local_getfmt P((struct parseunit *, parsectl_t *)); -static int local_setfmt P((struct parseunit *, parsectl_t *)); -static int local_getstat P((struct parseunit *, parsectl_t *)); -static int local_setstat P((struct parseunit *, parsectl_t *)); -static int local_timecode P((struct parseunit *, parsectl_t *)); -static void local_receive P((struct recvbuf *)); -static void local_poll P((struct parseunit *)); - -static bind_t io_bindings[] = -{ -#ifdef STREAM - { - "parse STREAM", - stream_init, - stream_nop, - stream_setcs, - stream_disable, - stream_enable, - stream_getfmt, - stream_setfmt, - stream_getstat, - stream_setstat, - stream_timecode, - stream_receive, - stream_poll - }, - { - "ppsclock STREAM", - ppsclock_init, - local_end, - local_setcs, - local_nop, - local_nop, - local_getfmt, - local_setfmt, - local_getstat, - local_setstat, - local_timecode, - local_receive, - local_poll - }, -#endif - { - "normal", - local_init, - local_end, - local_setcs, - local_nop, - local_nop, - local_getfmt, - local_setfmt, - local_getstat, - local_setstat, - local_timecode, - local_receive, - local_poll - }, - { - (char *)0, - } -}; - -#ifdef STREAM -/*-------------------------------------------------- - * ppsclock STREAM init - */ -static int -ppsclock_init(parse) - struct parseunit *parse; -{ - /* - * now push the parse streams module - * it will ensure exclusive access to the device - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"ppsclocd") == -1 && - ioctl(parse->fd, I_PUSH, (caddr_t)"ppsclock") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: ppsclock_init: ioctl(fd, I_PUSH, \"ppsclock\"): %m", - CL_UNIT(parse->unit)); - return 0; - } - if (!local_init(parse)) - { - (void)ioctl(parse->fd, I_POP, (caddr_t)0); - return 0; - } - - parse->flags |= PARSE_PPSCLOCK; - return 1; -} - -/*-------------------------------------------------- - * parse STREAM init - */ -static int -stream_init(parse) - struct parseunit *parse; -{ - /* - * now push the parse streams module - * to test whether it is there (Oh boy - neat kernel interface) - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"parse") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - while(ioctl(parse->fd, I_POP, (caddr_t)0) == 0) - /* empty loop */; - - /* - * now push it a second time after we have removed all - * module garbage - */ - if (ioctl(parse->fd, I_PUSH, (caddr_t)"parse") == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - return 1; - } - } -} - - /*-------------------------------------------------- - * STREAM setcs - */ -static int -stream_setcs(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETCS; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setcs: ioctl(fd, I_STR, PARSEIOC_SETCS): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM nop - */ -static void -stream_nop(parse) - struct parseunit *parse; -{ -} - -/*-------------------------------------------------- - * STREAM enable - */ -static int -stream_enable(parse) - struct parseunit *parse; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_ENABLE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)0; - strioc.ic_len = 0; - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_enable: ioctl(fd, I_STR, PARSEIOC_ENABLE): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM disable - */ -static int -stream_disable(parse) - struct parseunit *parse; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_DISABLE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)0; - strioc.ic_len = 0; - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_disable: ioctl(fd, I_STR, PARSEIOC_DISABLE): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM getfmt - */ -static int -stream_getfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_GETFMT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: ioctl(fd, I_STR, PARSEIOC_GETFMT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM setfmt - */ -static int -stream_setfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETFMT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setfmt: ioctl(fd, I_STR, PARSEIOC_SETFMT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM getstat - */ -static int -stream_getstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_GETSTAT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_getstat: ioctl(fd, I_STR, PARSEIOC_GETSTAT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM setstat - */ -static int -stream_setstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_SETSTAT; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: stream_setstat: ioctl(fd, I_STR, PARSEIOC_SETSTAT): %m", CL_UNIT(parse->unit)); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM timecode - */ -static int -stream_timecode(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - struct strioctl strioc; - - strioc.ic_cmd = PARSEIOC_TIMECODE; - strioc.ic_timout = 0; - strioc.ic_dp = (char *)tcl; - strioc.ic_len = sizeof (*tcl); - - if (ioctl(parse->fd, I_STR, (caddr_t)&strioc) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_process: ioctl(fd, I_STR, PARSEIOC_TIMECODE): %m", CL_UNIT(parse->unit), parse->fd); - return 0; - } - return 1; -} - -/*-------------------------------------------------- - * STREAM receive - */ -static void -stream_receive(rbufp) - struct recvbuf *rbufp; -{ - struct parseunit *parse = (struct parseunit *)rbufp->recv_srcclock; - parsetime_t parsetime; - - if (rbufp->recv_length != sizeof(parsetime_t)) - { - syslog(LOG_ERR,"PARSE receiver #%d: parse_receive: bad size (got %d expected %d)", - CL_UNIT(parse->unit), rbufp->recv_length, sizeof(parsetime_t)); - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - return; - } - memmove((caddr_t)&parsetime, - (caddr_t)&rbufp->recv_space, - sizeof(parsetime_t)); - - /* - * switch time stamp world - be sure to normalize small usec field - * errors. - */ - -#define fix_ts(_X_) \ - if ((&(_X_))->tv.tv_usec >= 1000000) \ - { \ - (&(_X_))->tv.tv_usec -= 1000000; \ - (&(_X_))->tv.tv_sec += 1; \ - } - -#define cvt_ts(_X_, _Y_) \ - { \ - l_fp ts; \ - \ - fix_ts((_X_)); \ - if (!buftvtots((const char *)&(&(_X_))->tv, &ts)) \ - { \ - syslog(LOG_ERR,"parse: stream_receive: timestamp conversion error (buftvtots) (%s) (%d.%06d) ", (_Y_), (&(_X_))->tv.tv_sec, (&(_X_))->tv.tv_usec);\ - return; \ - } \ - else \ - { \ - (&(_X_))->fp = ts; \ - } \ - } - - if (PARSE_TIMECODE(parsetime.parse_state)) - { - cvt_ts(parsetime.parse_time, "parse_time"); - cvt_ts(parsetime.parse_stime, "parse_stime"); - } - - if (PARSE_PPS(parsetime.parse_state)) - cvt_ts(parsetime.parse_ptime, "parse_ptime"); - - parse_process(parse, &parsetime); -} - -/*-------------------------------------------------- - * STREAM poll - */ -static void -stream_poll(parse) - struct parseunit *parse; -{ - register int fd, i, rtc; - fd_set fdmask; - struct timeval timeout, starttime, curtime, selecttime; - parsetime_t parsetime; - - /* - * now we do the following: - * - read the first packet from the parse module (OLD !!!) - * - read the second packet from the parse module (fresh) - * - compute values for xntp - */ - - FD_ZERO(&fdmask); - fd = parse->fd; - FD_SET(fd, &fdmask); - timeout.tv_sec = 0; - timeout.tv_usec = 500000; /* 0.5 sec */ - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (timercmp(&selecttime, &timeout, >)) - { - /* - * elapsed real time passed timeout value - consider it timed out - */ - break; - } - - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[old] from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[old] from device", CL_UNIT(parse->unit)); - } - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - return; - } - - while (((i = read(fd, (char *)&parsetime, sizeof(parsetime))) < sizeof(parsetime))) - { - /* bad packet */ - if ( i == -1) - { - if (errno == EINTR) - { - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[old] from streams module (read() error: %m)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[old] from streams module (got %d bytes - expected %d bytes)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - - return; - } - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - timeout.tv_sec = 1; - timeout.tv_usec = 500000; /* 1.500 sec */ - FD_ZERO(&fdmask); - FD_SET(fd, &fdmask); - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (timercmp(&selecttime, &timeout, >)) - { - /* - * elapsed real time passed timeout value - consider it timed out - */ - break; - } - - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[new] from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data[new] from device", CL_UNIT(parse->unit)); - } - - /* - * we will return here iff we got a good old sample as this would - * be misinterpreted. bad samples are passed on to be logged into the - * state statistics - */ - if ((parsetime.parse_status & CVT_MASK) == CVT_OK) - { - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - return; - } - } - - /* - * we get here either by a possible read() (rtc == 1 - while assertion) - * or by a timeout or a system call error. when a read() is possible we - * get the new data, otherwise we stick with the old - */ - if ((rtc == 1) && ((i = read(fd, (char *)&parsetime, sizeof(parsetime))) < sizeof(parsetime))) - { - /* bad packet */ - if ( i== -1) - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[new] from streams module (read() error: %m)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: bad read[new] from streams module (got %d bytes - expected %d bytes)", CL_UNIT(parse->unit), i, sizeof(parsetime)); - } - parse->baddata++; - parse_event(parse, CEVNT_BADREPLY); - - return; - } - - /* - * process what we got - */ - parse_process(parse, &parsetime); -} -#endif - -/*-------------------------------------------------- - * local init - */ -static int -local_init(parse) - struct parseunit *parse; -{ - return parse_ioinit(&parse->parseio); -} - -/*-------------------------------------------------- - * local end - */ -static void -local_end(parse) - struct parseunit *parse; -{ - parse_ioend(&parse->parseio); -} - - -/*-------------------------------------------------- - * local nop - */ -static int -local_nop(parse) - struct parseunit *parse; -{ - return 1; -} - -/*-------------------------------------------------- - * local setcs - */ -static int -local_setcs(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setcs(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local getfmt - */ -static int -local_getfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_getfmt(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local setfmt - */ -static int -local_setfmt(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setfmt(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local getstat - */ -static int -local_getstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_getstat(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local setstat - */ -static int -local_setstat(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_setstat(tcl, &parse->parseio); -} - -/*-------------------------------------------------- - * local timecode - */ -static int -local_timecode(parse, tcl) - struct parseunit *parse; - parsectl_t *tcl; -{ - return parse_timecode(tcl, &parse->parseio); -} - - -/*-------------------------------------------------- - * local receive - */ -static void -local_receive(rbufp) - struct recvbuf *rbufp; -{ - struct parseunit *parse = (struct parseunit *)rbufp->recv_srcclock; - register int count; - register char *s; -#ifdef FREEBSD_CONRAD - struct timeval foo; -#endif - - /* - * eat all characters, parsing then and feeding complete samples - */ - count = rbufp->recv_length; - s = rbufp->recv_buffer; -#ifdef FREEBSD_CONRAD - ioctl(parse->fd,TIOCTIMESTAMP,&foo); - TVTOTS(&foo, &rbufp->recv_time); - rbufp->recv_time.l_uf += TS_ROUNDBIT; - rbufp->recv_time.l_ui += JAN_1970; - rbufp->recv_time.l_uf &= TS_MASK; -#endif - - while (count--) - { - if (parse_ioread(&parse->parseio, *s++, &rbufp->recv_time)) - { - /* - * got something good to eat - */ -#ifdef PPSPPS - if (!PARSE_PPS(parse->parseio.parse_dtime.parse_state) && - (parse->flags & PARSE_PPSCLOCK)) - { - l_fp ts; - struct ppsclockev ev; - - if (ioctl(parse->fd, CIOGETEV, (caddr_t)&ev) == 0) - { - if (ev.serial != parse->ppsserial) - { - /* - * add PPS time stamp if available via ppsclock module - * and not supplied already. - */ - if (!buftvtots((const char *)&ev.tv, &ts)) - { - syslog(LOG_ERR,"parse: local_receive: timestamp conversion error (buftvtots) (ppsclockev.tv)"); - } - else - { - parse->parseio.parse_dtime.parse_ptime.fp = ts; - parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS; - } - } - parse->ppsserial = ev.serial; - } - } -#endif - parse_process(parse, &parse->parseio.parse_dtime); - parse_iodone(&parse->parseio); - } - } -} - -/*-------------------------------------------------- - * local poll - */ -static void -local_poll(parse) - struct parseunit *parse; -{ - register int fd, i, rtc; - fd_set fdmask; - struct timeval timeout, starttime, curtime, selecttime; - static struct timeval null_time = { 0, 0}; - timestamp_t ts; - - FD_ZERO(&fdmask); - fd = parse->fd; - FD_SET(fd, &fdmask); - timeout.tv_sec = 1; - timeout.tv_usec = 500000; /* 1.5 sec */ - - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - - if (GETTIMEOFDAY(&starttime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - - selecttime = timeout; - - do - { - while ((rtc = select(fd + 1, &fdmask, 0, 0, &selecttime)) != 1) - { - /* no data from the radio clock */ - - if (rtc == -1) - { - if (errno == EINTR) - { - if (GETTIMEOFDAY(&curtime, 0L) == -1) - { - syslog(LOG_ERR,"gettimeofday failed: %m"); - exit(1); - } - selecttime.tv_sec = curtime.tv_sec - starttime.tv_sec; - if (curtime.tv_usec < starttime.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + curtime.tv_usec - starttime.tv_usec; - } - else - { - selecttime.tv_usec = curtime.tv_usec - starttime.tv_usec; - } - - - if (!timercmp(&selecttime, &timeout, >)) - { - /* - * calculate residual timeout value - */ - selecttime.tv_sec = timeout.tv_sec - selecttime.tv_sec; - - if (selecttime.tv_usec > timeout.tv_usec) - { - selecttime.tv_sec -= 1; - selecttime.tv_usec = 1000000 + timeout.tv_usec - selecttime.tv_usec; - } - else - { - selecttime.tv_usec = timeout.tv_usec - selecttime.tv_usec; - } - - FD_SET(fd, &fdmask); - continue; - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device (select() error: %m)", CL_UNIT(parse->unit)); - } - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device", CL_UNIT(parse->unit)); - } - - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - return; - } - - /* - * at least 1 character is available - gobble everthing up that is available - */ - do - { - char inbuf[256]; - - register char *s = inbuf; - - rtc = i = read(fd, inbuf, sizeof(inbuf)); - - get_systime(&ts.fp); - - while (i-- > 0) - { - if (parse_ioread(&parse->parseio, *s++, ts)) - { - /* - * got something good to eat - */ - parse_process(parse, &parse->parseio.parse_dtime); - parse_iodone(&parse->parseio); - /* - * done if no more characters are available - */ - FD_SET(fd, &fdmask); - if ((i == 0) && - (select(fd + 1, &fdmask, 0, 0, &null_time) == 0)) - return; - } - } - FD_SET(fd, &fdmask); - } while ((rtc = select(fd + 1, &fdmask, 0, 0, &null_time)) == 1); - FD_SET(fd, &fdmask); - } while (1); -} - -/*-------------------------------------------------- - * init_iobinding - find and initialize lower layers - */ -static bind_t * -init_iobinding(parse) - struct parseunit *parse; -{ - register bind_t *b = io_bindings; - - while (b->bd_description != (char *)0) - { - if ((*b->bd_init)(parse)) - { - return b; - } - b++; - } - return (bind_t *)0; -} - -/**=========================================================================== - ** support routines - **/ - -/*-------------------------------------------------- - * convert a flag field to a string - */ -static char * -parsestate(state, buffer) - unsigned LONG state; - char *buffer; -{ - static struct bits - { - unsigned LONG bit; - char *name; - } flagstrings[] = - { - { PARSEB_ANNOUNCE, "DST SWITCH WARNING" }, - { PARSEB_POWERUP, "NOT SYNCHRONIZED" }, - { PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" }, - { PARSEB_DST, "DST" }, - { PARSEB_UTC, "UTC DISPLAY" }, - { PARSEB_LEAPADD, "LEAP ADD WARNING" }, - { PARSEB_LEAPDEL, "LEAP DELETE WARNING" }, - { PARSEB_LEAPSECOND, "LEAP SECOND" }, - { PARSEB_ALTERNATE,"ALTERNATE ANTENNA" }, - { PARSEB_TIMECODE, "TIME CODE" }, - { PARSEB_PPS, "PPS" }, - { PARSEB_POSITION, "POSITION" }, - { 0 } - }; - - static struct sbits - { - unsigned LONG bit; - char *name; - } sflagstrings[] = - { - { PARSEB_S_LEAP, "LEAP INDICATION" }, - { PARSEB_S_PPS, "PPS SIGNAL" }, - { PARSEB_S_ANTENNA, "ANTENNA" }, - { PARSEB_S_POSITION, "POSITION" }, - { 0 } - }; - int i; - - *buffer = '\0'; - - i = 0; - while (flagstrings[i].bit) - { - if (flagstrings[i].bit & state) - { - if (buffer[0]) - strcat(buffer, "; "); - strcat(buffer, flagstrings[i].name); - } - i++; - } - - if (state & (PARSEB_S_LEAP|PARSEB_S_ANTENNA|PARSEB_S_PPS|PARSEB_S_POSITION)) - { - register char *s, *t; - - if (buffer[0]) - strcat(buffer, "; "); - - strcat(buffer, "("); - - t = s = buffer + strlen(buffer); - - i = 0; - while (sflagstrings[i].bit) - { - if (sflagstrings[i].bit & state) - { - if (t != s) - { - strcpy(t, "; "); - t += 2; - } - - strcpy(t, sflagstrings[i].name); - t += strlen(t); - } - i++; - } - strcpy(t, ")"); - } - return buffer; -} - -/*-------------------------------------------------- - * convert a status flag field to a string - */ -static char * -parsestatus(state, buffer) - unsigned LONG state; - char *buffer; -{ - static struct bits - { - unsigned LONG bit; - char *name; - } flagstrings[] = - { - { CVT_OK, "CONVERSION SUCCESSFUL" }, - { CVT_NONE, "NO CONVERSION" }, - { CVT_FAIL, "CONVERSION FAILED" }, - { CVT_BADFMT, "ILLEGAL FORMAT" }, - { CVT_BADDATE, "DATE ILLEGAL" }, - { CVT_BADTIME, "TIME ILLEGAL" }, - { 0 } - }; - int i; - - *buffer = '\0'; - - i = 0; - while (flagstrings[i].bit) - { - if (flagstrings[i].bit & state) - { - if (buffer[0]) - strcat(buffer, "; "); - strcat(buffer, flagstrings[i].name); - } - i++; - } - - return buffer; -} - -/*-------------------------------------------------- - * convert a clock status flag field to a string - */ -static char * -clockstatus(state) - unsigned LONG state; -{ - static char buffer[20]; - static struct status - { - unsigned LONG value; - char *name; - } flagstrings[] = - { - { CEVNT_NOMINAL, "NOMINAL" }, - { CEVNT_TIMEOUT, "NO RESPONSE" }, - { CEVNT_BADREPLY,"BAD FORMAT" }, - { CEVNT_FAULT, "FAULT" }, - { CEVNT_PROP, "PROPAGATION DELAY" }, - { CEVNT_BADDATE, "ILLEGAL DATE" }, - { CEVNT_BADTIME, "ILLEGAL TIME" }, - { ~0 } - }; - int i; - - i = 0; - while (flagstrings[i].value != ~0) - { - if (flagstrings[i].value == state) - { - return flagstrings[i].name; - } - i++; - } - - sprintf(buffer, "unknown #%d", state); - - return buffer; -} - -/*-------------------------------------------------- - * mkascii - make a printable ascii string - * assumes (unless defined better) 7-bit ASCII - */ -#ifndef isprint -#define isprint(_X_) (((_X_) > 0x1F) && ((_X_) < 0x7F)) -#endif - -static char * -mkascii(buffer, blen, src, srclen) - register char *buffer; - register LONG blen; - register char *src; - register LONG srclen; -{ - register char *b = buffer; - register char *endb = (char *)0; - - if (blen < 4) - return (char *)0; /* don't bother with mini buffers */ - - endb = buffer + blen - 4; - - blen--; /* account for '\0' */ - - while (blen && srclen--) - { - if ((*src != '\\') && isprint(*src)) - { /* printables are easy... */ - *buffer++ = *src++; - blen--; - } - else - { - if (blen < 4) - { - while (blen--) - { - *buffer++ = '.'; - } - *buffer = '\0'; - return b; - } - else - { - if (*src == '\\') - { - strcpy(buffer,"\\\\"); - buffer += 2; - blen -= 2; - } - else - { - sprintf(buffer, "\\x%02x", *src++); - blen -= 4; - buffer += 4; - } - } - } - if (srclen && !blen && endb) /* overflow - set last chars to ... */ - strcpy(endb, "..."); - } - - *buffer = '\0'; - return b; -} - - -/*-------------------------------------------------- - * l_mktime - make representation of a relative time - */ -static char * -l_mktime(delta) - unsigned LONG delta; -{ - unsigned LONG tmp, m, s; - static char buffer[40]; - - buffer[0] = '\0'; - - if ((tmp = delta / (60*60*24)) != 0) - { - sprintf(buffer, "%dd+", tmp); - delta -= tmp * 60*60*24; - } - - s = delta % 60; - delta /= 60; - m = delta % 60; - delta /= 60; - - sprintf(buffer+strlen(buffer), "%02d:%02d:%02d", - delta, m, s); - - return buffer; -} - - -/*-------------------------------------------------- - * parse_statistics - list summary of clock states - */ -static void -parse_statistics(parse) - register struct parseunit *parse; -{ - register int i; - - syslog(LOG_INFO, "PARSE receiver #%d: running time: %s", - CL_UNIT(parse->unit), - l_mktime(current_time - parse->timestarted)); - - syslog(LOG_INFO, "PARSE receiver #%d: current status: %s", - CL_UNIT(parse->unit), - clockstatus(parse->status)); - - for (i = 0; i <= CEVNT_MAX; i++) - { - register unsigned LONG stime; - register unsigned LONG percent, div = current_time - parse->timestarted; - - percent = stime = PARSE_STATETIME(parse, i); - - while (((unsigned LONG)(~0) / 10000) < percent) - { - percent /= 10; - div /= 10; - } - - if (div) - percent = (percent * 10000) / div; - else - percent = 10000; - - if (stime) - syslog(LOG_INFO, "PARSE receiver #%d: state %18s: %13s (%3d.%02d%%)", - CL_UNIT(parse->unit), - clockstatus(i), - l_mktime(stime), - percent / 100, percent % 100); - } -} - -/*-------------------------------------------------- - * cparse_statistics - wrapper for statistics call - */ -static void -cparse_statistics(peer) - register struct peer *peer; -{ - register struct parseunit *parse = (struct parseunit *)peer; - - parse_statistics(parse); - parse->stattimer.event_time = current_time + PARSESTATISTICS; - TIMER_ENQUEUE(timerqueue, &parse->stattimer); -} - -/**=========================================================================== - ** xntp interface routines - **/ - -/*-------------------------------------------------- - * parse_init - initialize internal parse driver data - */ -static void -parse_init() -{ - memset((caddr_t)parseunits, 0, sizeof parseunits); -} - - -/*-------------------------------------------------- - * parse_shutdown - shut down a PARSE clock - */ -static void -parse_shutdown(unit) - int unit; -{ - register struct parseunit *parse; - - unit = CL_UNIT(unit); - - if (unit >= MAXUNITS) { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_shutdown: INTERNAL ERROR, unit invalid (max %d)", - unit,MAXUNITS); - return; - } - - parse = parseunits[unit]; - - if (parse && !parse->peer) { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_shutdown: INTERNAL ERROR, unit not in use", unit); - return; - } - - /* - * print statistics a last time and - * stop statistics machine - */ - parse_statistics(parse); - TIMER_DEQUEUE(&parse->stattimer); - -#if PPSPPS - { - /* - * kill possible PPS association - */ - if (fdpps == parse->fd) - fdpps = -1; - } -#endif - - if (parse->parse_type->cl_end) - { - parse->parse_type->cl_end(parse); - } - - if (parse->binding) - PARSE_END(parse); - - /* - * Tell the I/O module to turn us off. We're history. - */ - if (!parse->pollonly) - io_closeclock(&parse->io); - else - (void) close(parse->fd); - - syslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" removed", - CL_UNIT(parse->unit), parse->parse_type->cl_description); - - parse->peer = (struct peer *)0; /* unused now */ -} - -/*-------------------------------------------------- - * parse_start - open the PARSE devices and initialize data for processing - */ -static int -parse_start(sysunit, peer) - u_int sysunit; - struct peer *peer; -{ - u_int unit; - int fd232, i; -#ifdef HAVE_TERMIOS - struct termios tm; /* NEEDED FOR A LONG TIME ! */ -#endif -#ifdef HAVE_SYSV_TTYS - struct termio tm; /* NEEDED FOR A LONG TIME ! */ -#endif - struct parseunit * parse; - char parsedev[sizeof(PARSEDEVICE)+20]; - parsectl_t tmp_ctl; - u_int type; - - type = CL_TYPE(sysunit); - unit = CL_UNIT(sysunit); - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unit number invalid (max %d)", - unit, MAXUNITS-1); - return 0; - } - - if ((type == ~0) || (clockinfo[type].cl_description == (char *)0)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unsupported clock type %d (max %d)", - unit, CL_REALTYPE(sysunit), ncltypes-1); - return 0; - } - - if (parseunits[unit] && parseunits[unit]->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: unit in use", unit); - return 0; - } - - /* - * Unit okay, attempt to open the device. - */ - (void) sprintf(parsedev, PARSEDEVICE, unit); - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - - fd232 = open(parsedev, O_RDWR|O_NOCTTY, 0777); - if (fd232 == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: open of %s failed: %m", unit, parsedev); - return 0; - } - - /* - * Looks like this might succeed. Find memory for the structure. - * Look to see if there are any unused ones, if not we malloc() - * one. - */ - if (parseunits[unit]) - { - parse = parseunits[unit]; /* The one we want is okay - and free */ - } - else - { - for (i = 0; i < MAXUNITS; i++) - { - if (parseunits[i] && !parseunits[i]->peer) - break; - } - if (i < MAXUNITS) - { - /* - * Reclaim this one - */ - parse = parseunits[i]; - parseunits[i] = (struct parseunit *)0; - } - else - { - parse = (struct parseunit *) - emalloc(sizeof(struct parseunit)); - } - } - - memset((char *)parse, 0, sizeof(struct parseunit)); - parseunits[unit] = parse; - - /* - * Set up the structures - */ - parse->unit = (u_char)sysunit; - parse->timestarted = current_time; - parse->lastchange = current_time; - /* - * we want to filter input for the sake of - * getting an impression on dispersion - * also we like to average the median range - */ - parse->flags = PARSE_STAT_FILTER|PARSE_STAT_AVG; - parse->pollneeddata = 0; - parse->pollonly = 1; /* go for default polling mode */ - parse->lastformat = ~0; /* assume no format known */ - parse->status = CEVNT_TIMEOUT; /* expect the worst */ - parse->laststatus = ~0; /* be sure to mark initial status change */ - parse->nosynctime = 0; /* assume clock reasonable */ - parse->lastmissed = 0; /* assume got everything */ - parse->ppsserial = 0; - parse->localdata = (void *)0; - - parse->parse_type = &clockinfo[type]; - - parse->basedelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ - parse->basedelay.l_uf = parse->parse_type->cl_basedelay; - - parse->ppsdelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */ - parse->ppsdelay.l_uf = parse->parse_type->cl_ppsdelay; - - peer->rootdelay = parse->parse_type->cl_rootdelay; - peer->sstclktype = parse->parse_type->cl_type; - peer->precision = sys_precision; - peer->stratum = STRATUM_REFCLOCK; - if (peer->stratum <= 1) - memmove((char *)&peer->refid, parse->parse_type->cl_id, 4); - else - peer->refid = htonl(PARSEHSREFID); - - parse->fd = fd232; - - parse->peer = peer; /* marks it also as busy */ - - parse->binding = init_iobinding(parse); - - if (parse->binding == (bind_t *)0) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: io sub system initialisation failed."); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - - /* - * configure terminal line - */ - if (TTY_GETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcgetattr(%d, &tm): %m", unit, fd232); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - else - { -#ifndef _PC_VDISABLE - memset((char *)tm.c_cc, 0, sizeof(tm.c_cc)); -#else - int disablec; - errno = 0; /* pathconf can deliver -1 without changing errno ! */ - - disablec = fpathconf(parse->fd, _PC_VDISABLE); - if (disablec == -1 && errno) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: fpathconf(fd, _PC_VDISABLE): %m", CL_UNIT(parse->unit)); - memset((char *)tm.c_cc, 0, sizeof(tm.c_cc)); /* best guess */ - } - else - if (disablec != -1) - memset((char *)tm.c_cc, disablec, sizeof(tm.c_cc)); -#endif - - tm.c_cflag = clockinfo[type].cl_cflag; - tm.c_iflag = clockinfo[type].cl_iflag; - tm.c_oflag = clockinfo[type].cl_oflag; - tm.c_lflag = clockinfo[type].cl_lflag; -#ifdef FREEBSD_CONRAD - tm.c_ispeed = 50; - tm.c_ospeed = 50; -#endif - if (TTY_SETATTR(fd232, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcsetattr(%d, &tm): %m", unit, fd232); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - } - - /* - * as we always(?) get 8 bit chars we want to be - * sure, that the upper bits are zero for less - * than 8 bit I/O - so we pass that information on. - * note that there can be only one bit count format - * per file descriptor - */ - - switch (tm.c_cflag & CSIZE) - { - case CS5: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS5; - break; - - case CS6: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS6; - break; - - case CS7: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS7; - break; - - case CS8: - tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS8; - break; - } - - if (!PARSE_SETCS(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setcs() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - -#ifdef FREEBSD_CONRAD - { - int i,j; - struct timeval tv; - ioctl(parse->fd,TIOCTIMESTAMP,&tv); - j = TIOCM_RTS; - i = ioctl(fd232, TIOCMBIC, &j); - if (i < 0) { - syslog(LOG_ERR, - "PARSE receiver #%d: lowrts_poll: failed to lower RTS: %m", - CL_UNIT(parse->unit)); - } - } -#endif - - strcpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format); - tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer); - - if (!PARSE_SETFMT(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setfmt() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - -#ifdef TCFLSH - /* - * get rid of all IO accumulated so far - */ - { -#ifndef TCIOFLUSH -#define TCIOFLUSH 2 -#endif - int flshcmd = TCIOFLUSH; - - (void) ioctl(parse->fd, TCFLSH, (caddr_t)&flshcmd); - } -#endif - - tmp_ctl.parsestatus.flags = parse->flags & PARSE_STAT_FLAGS; - - if (!PARSE_SETSTAT(parse, &tmp_ctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setstat() FAILED.", unit); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - - /* - * try to do any special initializations - */ - if (parse->parse_type->cl_init) - { - if (parse->parse_type->cl_init(parse)) - { - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; /* well, ok - special initialisation broke */ - } - } - - if (!(parse->parse_type->cl_flags & PARSE_F_POLLONLY) && - (CL_PPS(parse->unit) || (parse->parse_type->cl_flags & PARSE_F_NOPOLLONLY))) - { - /* - * Insert in async io device list. - */ - parse->io.clock_recv = parse->binding->bd_receive; /* pick correct receive routine */ - parse->io.srcclock = (caddr_t)parse; - parse->io.datalen = 0; - parse->io.fd = parse->fd; /* replicated, but what the heck */ - if (!io_addclock(&parse->io)) - { - if (parse->parse_type->cl_flags & PARSE_F_NOPOLLONLY) - { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_start: addclock %s fails (ABORT - clock type requires async io)", CL_UNIT(parse->unit), parsedev); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - else - { - syslog(LOG_ERR, - "PARSE receiver #%d: parse_start: addclock %s fails (switching to polling mode)", CL_UNIT(parse->unit), parsedev); - } - } - else - { - parse->pollonly = 0; /* - * update at receipt of time_stamp - also - * supports PPS processing - */ - } - } - -#ifdef PPSPPS - if (parse->pollonly || (parse->parse_type->cl_flags & PARSE_F_PPSPPS)) - { - if (fdpps == -1) - { - fdpps = parse->fd; - if (!PARSE_DISABLE(parse)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_disable() FAILED", CL_UNIT(parse->unit)); - parse_shutdown(parse->unit); /* let our cleaning staff do the work */ - return 0; - } - } - else - { - syslog(LOG_NOTICE, "PARSE receiver #%d: parse_start: loopfilter PPS already active - no PPS via CIOGETEV", CL_UNIT(parse->unit)); - } - } -#endif - - /* - * wind up statistics timer - */ - parse->stattimer.peer = (struct peer *)parse; /* we know better, but what the heck */ - parse->stattimer.event_handler = cparse_statistics; - parse->stattimer.event_time = current_time + PARSESTATISTICS; - TIMER_ENQUEUE(timerqueue, &parse->stattimer); - - /* - * get out Copyright information once - */ - if (!notice) - { - syslog(LOG_INFO, "NTP PARSE support: Copyright (c) 1989-1993, Frank Kardel"); - notice = 1; - } - - /* - * print out configuration - */ - syslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" (device %s) added", - CL_UNIT(parse->unit), - parse->parse_type->cl_description, parsedev); - - syslog(LOG_INFO, "PARSE receiver #%d: Stratum %d, %sPPS support, trust time %s, precision %d", - CL_UNIT(parse->unit), - parse->peer->stratum, (parse->pollonly || !CL_PPS(parse->unit)) ? "no " : "", - l_mktime(parse->parse_type->cl_maxunsync), parse->peer->precision); - - syslog(LOG_INFO, "PARSE receiver #%d: rootdelay %s s, phaseadjust %s s, %s IO handling", - CL_UNIT(parse->unit), - ufptoa(parse->parse_type->cl_rootdelay, 6), - lfptoa(&parse->basedelay, 8), - parse->binding->bd_description); - - syslog(LOG_INFO, "PARSE receiver #%d: Format recognition: %s", CL_UNIT(parse->unit), - !(*parse->parse_type->cl_format) ? "" : parse->parse_type->cl_format); - -#ifdef PPSPPS - syslog(LOG_INFO, "PARSE receiver #%d: %sCD PPS support", - CL_UNIT(parse->unit), - (fdpps == parse->fd) ? "" : "NO "); -#endif - - return 1; -} - -/*-------------------------------------------------- - * parse_poll - called by the transmit procedure - */ -static void -parse_poll(unit, peer) - int unit; - struct peer *peer; -{ - register struct parseunit *parse; - - unit = CL_UNIT(unit); - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll: INTERNAL: unit invalid", - unit); - return; - } - - parse = parseunits[unit]; - - if (!parse->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll: INTERNAL: unit unused", - unit); - return; - } - - if (peer != parse->peer) - { - syslog(LOG_ERR, - "PARSE receiver #%d: poll: INTERNAL: peer incorrect", - unit); - return; - } - - /* - * Update clock stat counters - */ - parse->polls++; - - /* - * in PPS mode we just mark that we want the next sample - * for the clock filter - */ - if (!parse->pollonly) - { - if (parse->pollneeddata) - { - /* - * bad news - didn't get a response last time - */ - parse->noresponse++; - parse->lastmissed = current_time; - parse_event(parse, CEVNT_TIMEOUT); - - syslog(LOG_WARNING, "PARSE receiver #%d: no data from device within poll interval", CL_UNIT(parse->unit)); - } - parse->pollneeddata = 1; - if (parse->parse_type->cl_poll) - { - parse->parse_type->cl_poll(parse); - } - return; - } - - /* - * the following code is only executed only when polling is used - */ - - PARSE_POLL(parse); -} - -/*-------------------------------------------------- - * parse_leap - called when a leap second occurs - */ - -static void -parse_leap() -{ - /* - * PARSE encodes the LEAP correction direction. - * For timecodes that do not pass on the leap correction direction - * the default PARSEB_LEAPADD must be used. It may then be modified - * with a fudge flag (flag2). - */ -} - - -/*-------------------------------------------------- - * parse_control - set fudge factors, return statistics - */ -static void -parse_control(unit, in, out) - u_int unit; - struct refclockstat *in; - struct refclockstat *out; -{ - register struct parseunit *parse; - parsectl_t tmpctl; - unsigned LONG type; - static char outstatus[400]; /* status output buffer */ - - type = CL_TYPE(unit); - unit = CL_UNIT(unit); - - if (out) - { - out->lencode = 0; - out->lastcode = 0; - out->polls = out->noresponse = 0; - out->badformat = out->baddata = 0; - out->timereset = 0; - out->currentstatus = out->lastevent = CEVNT_NOMINAL; - out->kv_list = (struct ctl_var *)0; - } - - if (unit >= MAXUNITS) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: unit invalid (max %d)", - unit, MAXUNITS-1); - return; - } - - parse = parseunits[unit]; - - if (!parse || !parse->peer) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: unit invalid (UNIT INACTIVE)", - unit); - return; - } - - if (in) - { - if (in->haveflags & CLK_HAVETIME1) - parse->basedelay = in->fudgetime1; - - if (in->haveflags & CLK_HAVETIME2) - { - parse->ppsdelay = in->fudgetime2; - } - - if (in->haveflags & CLK_HAVEVAL1) - { - parse->peer->stratum = (u_char)(in->fudgeval1 & 0xf); - if (parse->peer->stratum <= 1) - memmove((char *)&parse->peer->refid, - parse->parse_type->cl_id, - 4); - else - parse->peer->refid = htonl(PARSEHSREFID); - } - - /* - * NOT USED - yet - * - if (in->haveflags & CLK_HAVEVAL2) - { - } - */ - if (in->haveflags & (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4)) - { - parse->flags = (in->flags & (CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)) | - (parse->flags & ~PARSE_STAT_FLAGS); - } - - if (in->haveflags & (CLK_HAVEVAL2|CLK_HAVETIME2|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4)) - { - parsectl_t tmpctl; - tmpctl.parsestatus.flags = parse->flags & PARSE_STAT_FLAGS; - - if (!PARSE_SETSTAT(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_setstat() FAILED", unit); - } - } - } - - if (out) - { - register unsigned LONG sum = 0; - register char *t, *tt; - register struct tm *tm; - register short utcoff; - register char sign; - register int i; - time_t tim; - - outstatus[0] = '\0'; - - out->haveflags = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3; - out->clockdesc = parse->parse_type->cl_description; - - out->fudgetime1 = parse->basedelay; - - out->fudgetime2 = parse->ppsdelay; - - out->fudgeval1 = (LONG)parse->peer->stratum; - - out->fudgeval2 = 0; - - out->flags = parse->flags & PARSE_STAT_FLAGS; - - out->type = REFCLK_PARSE; - - /* - * figure out skew between PPS and RS232 - just for informational - * purposes - returned in time2 value - */ - if (PARSE_SYNC(parse->time.parse_state)) - { - if (PARSE_PPS(parse->time.parse_state) && PARSE_TIMECODE(parse->time.parse_state)) - { - l_fp off; - - /* - * we have a PPS and RS232 signal - calculate the skew - * WARNING: assumes on TIMECODE == PULSE (timecode after pulse) - */ - off = parse->time.parse_stime.fp; - L_SUB(&off, &parse->time.parse_ptime.fp); /* true offset */ - tt = add_var(&out->kv_list, 40, RO); - sprintf(tt, "refclock_ppsskew=%s", lfptoms(&off, 6)); - } - } - - if (PARSE_PPS(parse->time.parse_state)) - { - tt = add_var(&out->kv_list, 80, RO|DEF); - sprintf(tt, "refclock_ppstime=\"%s\"", prettydate(&parse->time.parse_ptime.fp)); - } - - /* - * all this for just finding out the +-xxxx part (there are always - * new and changing fields in the standards 8-(). - * - * but we do it for the human user... - */ - tim = parse->time.parse_time.fp.l_ui - JAN_1970; - tm = gmtime(&tim); - utcoff = tm->tm_hour * 60 + tm->tm_min; - tm = localtime(&tim); - utcoff = tm->tm_hour * 60 + tm->tm_min - utcoff + 12 * 60; - utcoff += 24 * 60; - utcoff %= 24 * 60; - utcoff -= 12 * 60; - if (utcoff < 0) - { - utcoff = -utcoff; - sign = '-'; - } - else - { - sign = '+'; - } - - tt = add_var(&out->kv_list, 128, RO|DEF); - sprintf(tt, "refclock_time=\""); - tt += strlen(tt); - - if (parse->time.parse_time.fp.l_ui == 0) - { - strcpy(tt, "\""); - } - else - { - strcpy(tt, prettydate(&parse->time.parse_time.fp)); - t = tt + strlen(tt); - - sprintf(t, " (%c%02d%02d)\"", sign, utcoff / 60, utcoff % 60); - } - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_timecode() FAILED", unit); - } - else - { - tt = add_var(&out->kv_list, 128, RO|DEF); - sprintf(tt, "refclock_status=\""); - tt += strlen(tt); - - /* - * copy PPS flags from last read transaction (informational only) - */ - tmpctl.parsegettc.parse_state |= parse->time.parse_state & - (PARSEB_PPS|PARSEB_S_PPS); - - (void) parsestate(tmpctl.parsegettc.parse_state, tt); - - strcat(tt, "\""); - - if (tmpctl.parsegettc.parse_count) - mkascii(outstatus+strlen(outstatus), sizeof(outstatus)- strlen(outstatus) - 1, - tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1); - - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - - tmpctl.parseformat.parse_format = tmpctl.parsegettc.parse_format; - - if (!PARSE_GETFMT(parse, &tmpctl)) - { - syslog (LOG_ERR, "PARSE receiver #%d: parse_control: parse_getfmt() FAILED", unit); - } - else - { - tt = add_var(&out->kv_list, 80, RO|DEF); - sprintf(tt, "refclock_format=\""); - - strncat(tt, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count); - strcat(tt,"\""); - } - - /* - * gather state statistics - */ - - tt = add_var(&out->kv_list, 200, RO|DEF); - strcpy(tt, "refclock_states=\""); - tt += strlen(tt); - - for (i = 0; i <= CEVNT_MAX; i++) - { - register unsigned LONG stime; - register unsigned LONG div = current_time - parse->timestarted; - register unsigned LONG percent; - - percent = stime = PARSE_STATETIME(parse, i); - - while (((unsigned LONG)(~0) / 10000) < percent) - { - percent /= 10; - div /= 10; - } - - if (div) - percent = (percent * 10000) / div; - else - percent = 10000; - - if (stime) - { - sprintf(tt, "%s%s%s: %s (%d.%02d%%)", - sum ? "; " : "", - (parse->status == i) ? "*" : "", - clockstatus(i), - l_mktime(stime), - percent / 100, percent % 100); - sum += stime; - tt += strlen(tt); - } - } - - sprintf(tt, "; running time: %s\"", l_mktime(sum)); - - tt = add_var(&out->kv_list, 32, RO); - sprintf(tt, "refclock_id=\"%s\"", parse->parse_type->cl_id); - - tt = add_var(&out->kv_list, 80, RO); - sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description); - - tt = add_var(&out->kv_list, 128, RO); - sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.53 1994/03/25 13:07:39 kardel Exp\""); - - out->lencode = strlen(outstatus); - out->lastcode = outstatus; - out->timereset = parse->timestarted; - out->polls = parse->polls; - out->noresponse = parse->noresponse; - out->badformat = parse->badformat; - out->baddata = parse->baddata; - out->lastevent = parse->lastevent; - out->currentstatus = parse->status; - } -} - -/**=========================================================================== - ** processing routines - **/ - -/*-------------------------------------------------- - * event handling - note that nominal events will also be posted - */ -static void -parse_event(parse, event) - struct parseunit *parse; - int event; -{ - if (parse->status != (u_char) event) - { - parse->statetime[parse->status] += current_time - parse->lastchange; - parse->lastchange = current_time; - - parse->status = (u_char)event; - if (event != CEVNT_NOMINAL) - parse->lastevent = parse->status; - - report_event(EVNT_PEERCLOCK, parse->peer); - } -} - -/*-------------------------------------------------- - * process a PARSE time sample - */ -static void -parse_process(parse, parsetime) - struct parseunit *parse; - parsetime_t *parsetime; -{ - unsigned char leap; - struct timeval usecdisp; - l_fp off, rectime, reftime, dispersion; - - /* - * check for changes in conversion status - * (only one for each new status !) - */ - if (parse->laststatus != parsetime->parse_status) - { - char buffer[200]; - - syslog(LOG_WARNING, "PARSE receiver #%d: conversion status \"%s\"", - CL_UNIT(parse->unit), parsestatus(parsetime->parse_status, buffer)); - - if ((parsetime->parse_status & CVT_MASK) == CVT_FAIL) - { - /* - * tell more about the story - list time code - * there is a slight change for a race condition and - * the time code might be overwritten by the next packet - */ - parsectl_t tmpctl; - - if (!PARSE_GETTIMECODE(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_process: parse_timecode() FAILED", CL_UNIT(parse->unit)); - } - else - { - syslog(LOG_WARNING, "PARSE receiver #%d: FAILED TIMECODE: \"%s\"", - CL_UNIT(parse->unit), mkascii(buffer, sizeof buffer, tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1)); - parse->badformat += tmpctl.parsegettc.parse_badformat; - } - } - - parse->laststatus = parsetime->parse_status; - } - - /* - * examine status and post appropriate events - */ - if ((parsetime->parse_status & CVT_MASK) != CVT_OK) - { - /* - * got bad data - tell the rest of the system - */ - switch (parsetime->parse_status & CVT_MASK) - { - case CVT_NONE: - break; /* well, still waiting - timeout is handled at higher levels */ - - case CVT_FAIL: - parse->badformat++; - if (parsetime->parse_status & CVT_BADFMT) - { - parse_event(parse, CEVNT_BADREPLY); - } - else - if (parsetime->parse_status & CVT_BADDATE) - { - parse_event(parse, CEVNT_BADDATE); - } - else - if (parsetime->parse_status & CVT_BADTIME) - { - parse_event(parse, CEVNT_BADTIME); - } - else - { - parse_event(parse, CEVNT_BADREPLY); /* for the lack of something better */ - } - } - return; /* skip the rest - useless */ - } - - /* - * check for format changes - * (in case somebody has swapped clocks 8-) - */ - if (parse->lastformat != parsetime->parse_format) - { - parsectl_t tmpctl; - - tmpctl.parseformat.parse_format = parsetime->parse_format; - - if (!PARSE_GETFMT(parse, &tmpctl)) - { - syslog(LOG_ERR, "PARSE receiver #%d: parse_getfmt() FAILED", CL_UNIT(parse->unit)); - } - else - { - syslog(LOG_INFO, "PARSE receiver #%d: new packet format \"%s\"", - CL_UNIT(parse->unit), tmpctl.parseformat.parse_buffer); - } - parse->lastformat = parsetime->parse_format; - } - - /* - * now, any changes ? - */ - if (parse->time.parse_state != parsetime->parse_state) - { - char tmp1[200]; - char tmp2[200]; - /* - * something happend - */ - - (void) parsestate(parsetime->parse_state, tmp1); - (void) parsestate(parse->time.parse_state, tmp2); - - syslog(LOG_INFO,"PARSE receiver #%d: STATE CHANGE: %s -> %s", - CL_UNIT(parse->unit), tmp2, tmp1); - } - - /* - * remember for future - */ - parse->time = *parsetime; - - /* - * check to see, whether the clock did a complete powerup or lost PZF signal - * and post correct events for current condition - */ - if (PARSE_POWERUP(parsetime->parse_state)) - { - /* - * this is bad, as we have completely lost synchronisation - * well this is a problem with the receiver here - * for PARSE U/A 31 the lost synchronisation ist true - * as it is the powerup state and the time is taken - * from a crude real time clock chip - * for the PZF series this is only partly true, as - * PARSE_POWERUP only means that the pseudo random - * phase shift sequence cannot be found. this is only - * bad, if we have never seen the clock in the SYNC - * state, where the PHASE and EPOCH are correct. - * for reporting events the above business does not - * really matter, but we can use the time code - * even in the POWERUP state after having seen - * the clock in the synchronized state (PZF class - * receivers) unless we have had a telegram disruption - * after having seen the clock in the SYNC state. we - * thus require having seen the clock in SYNC state - * *after* having missed telegrams (noresponse) from - * the clock. one problem remains: we might use erroneously - * POWERUP data if the disruption is shorter than 1 polling - * interval. fortunately powerdowns last usually longer than 64 - * seconds and the receiver is at least 2 minutes in the - * POWERUP or NOSYNC state before switching to SYNC - */ - parse_event(parse, CEVNT_FAULT); - if (parse->nosynctime) - { - /* - * repeated POWERUP/NOSYNC state - look whether - * the message should be repeated - */ - if (current_time - parse->nosynctime > PARSENOSYNCREPEAT) - { - syslog(LOG_ERR,"PARSE receiver #%d: *STILL* NOT SYNCHRONIZED (POWERUP or no PZF signal)", - CL_UNIT(parse->unit)); - parse->nosynctime = current_time; - } - } - else - { - syslog(LOG_ERR,"PARSE receiver #%d: NOT SYNCHRONIZED", - CL_UNIT(parse->unit)); - parse->nosynctime = current_time; - } - } - else - { - /* - * we have two states left - * - * SYNC: - * this state means that the EPOCH (timecode) and PHASE - * information has be read correctly (at least two - * successive PARSE timecodes were received correctly) - * this is the best possible state - full trust - * - * NOSYNC: - * The clock should be on phase with respect to the second - * signal, but the timecode has not been received correctly within - * at least the last two minutes. this is a sort of half baked state - * for PARSE U/A 31 this is bad news (clock running without timecode - * confirmation) - * PZF 535 has also no time confirmation, but the phase should be - * very precise as the PZF signal can be decoded - */ - parse->nosynctime = 0; /* current state is better than worst state */ - - if (PARSE_SYNC(parsetime->parse_state)) - { - /* - * currently completely synchronized - best possible state - */ - parse->lastsync = current_time; - /* - * log OK status - */ - parse_event(parse, CEVNT_NOMINAL); - } - else - { - /* - * we have had some problems receiving the time code - */ - parse_event(parse, CEVNT_PROP); - } - } - - if (PARSE_TIMECODE(parsetime->parse_state)) - { - l_fp offset; - - /* - * calculate time offset including systematic delays - * off = PARSE-timestamp + propagation delay - kernel time stamp - */ - offset = parse->basedelay; - - off = parsetime->parse_time.fp; - - reftime = off; - - L_ADD(&off, &offset); - rectime = off; /* this makes org time and xmt time somewhat artificial */ - - L_SUB(&off, &parsetime->parse_stime.fp); - - if ((parse->flags & PARSE_STAT_FILTER) && - (off.l_i > -60) && - (off.l_i < 60)) /* take usec error only if within +- 60 secs */ - { - struct timeval usecerror; - /* - * offset is already calculated - */ - usecerror.tv_sec = parsetime->parse_usecerror / 1000000; - usecerror.tv_usec = parsetime->parse_usecerror % 1000000; - - sTVTOTS(&usecerror, &off); - L_ADD(&off, &offset); - } - } - - if (PARSE_PPS(parsetime->parse_state) && CL_PPS(parse->unit)) - { - l_fp offset; - - /* - * we have a PPS signal - much better than the RS232 stuff (we hope) - */ - offset = parsetime->parse_ptime.fp; - - L_ADD(&offset, &parse->ppsdelay); - - if (PARSE_TIMECODE(parsetime->parse_state)) - { - if (M_ISGEQ(off.l_i, off.l_f, -1, 0x80000000) && - M_ISGEQ(0, 0x7fffffff, off.l_i, off.l_f)) - { - /* - * RS232 offsets within [-0.5..0.5[ - take PPS offsets - */ - - if (parse->parse_type->cl_flags & PARSE_F_PPSONSECOND) - { - reftime = off = offset; - rectime = offset; - /* - * implied on second offset - */ - off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */ - off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */ - } - else - { - /* - * time code describes pulse - */ - off = parsetime->parse_time.fp; - - rectime = reftime = off; /* take reference time - fake rectime */ - - L_SUB(&off, &offset); /* true offset */ - } - } - /* - * take RS232 offset when PPS when out of bounds - */ - } - else - { - /* - * Well, no time code to guide us - assume on second pulse - * and pray, that we are within [-0.5..0.5[ - */ - reftime = off = offset; - rectime = offset; - /* - * implied on second offset - */ - off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */ - off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */ - } - } - else - { - if (!PARSE_TIMECODE(parsetime->parse_state)) - { - /* - * Well, no PPS, no TIMECODE, no more work ... - */ - return; - } - } - - -#if defined(PPS) || defined(PPSCLK) || defined(PPSPPS) || defined(PARSEPPS) - if (CL_PPS(parse->unit) && !parse->pollonly && PARSE_SYNC(parsetime->parse_state)) - { - /* - * only provide PPS information when clock - * is in sync - * thus PHASE and EPOCH are correct and PPS is not - * done via the CIOGETEV loopfilter mechanism - */ -#ifdef PPSPPS - if (fdpps != parse->fd) -#endif - (void) pps_sample(&off); - } -#endif /* PPS || PPSCLK || PPSPPS || PARSEPPS */ - - /* - * ready, unless the machine wants a sample - */ - if (!parse->pollonly && !parse->pollneeddata) - return; - - parse->pollneeddata = 0; - - if (PARSE_PPS(parsetime->parse_state)) - { - L_CLR(&dispersion); - } - else - { - /* - * convert usec dispersion into NTP TS world - */ - - usecdisp.tv_sec = parsetime->parse_usecdisp / 1000000; - usecdisp.tv_usec = parsetime->parse_usecdisp % 1000000; - - TVTOTS(&usecdisp, &dispersion); - } - - /* - * and now stick it into the clock machine - * samples are only valid iff lastsync is not too old and - * we have seen the clock in sync at least once - * after the last time we didn't see an expected data telegram - * see the clock states section above for more reasoning - */ - if (((current_time - parse->lastsync) > parse->parse_type->cl_maxunsync) || - (parse->lastsync <= parse->lastmissed)) - { - leap = LEAP_NOTINSYNC; - } - else - { - if (PARSE_LEAPADD(parsetime->parse_state)) - { - /* - * we pick this state also for time code that pass leap warnings - * without direction information (as earth is currently slowing - * down). - */ - leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND; - } - else - if (PARSE_LEAPDEL(parsetime->parse_state)) - { - leap = LEAP_DELSECOND; - } - else - { - leap = LEAP_NOWARNING; - } - } - - refclock_receive(parse->peer, &off, 0, LFPTOFP(&dispersion), &reftime, &rectime, leap); -} - -/**=========================================================================== - ** clock polling support - **/ - -struct poll_timer -{ - struct event timer; /* we'd like to poll a a higher rate than 1/64s */ -}; - -typedef struct poll_timer poll_timer_t; - -/*-------------------------------------------------- - * direct poll routine - */ -static void -poll_dpoll(parse) - struct parseunit *parse; -{ - register int rtc; - register char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string; - register int ct = ((poll_info_t *)parse->parse_type->cl_data)->count; - - rtc = write(parse->fd, ps, ct); - if (rtc < 0) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd to clock: %m", CL_UNIT(parse->unit)); - } - else - if (rtc != ct) - { - syslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%d of %d bytes sent)", CL_UNIT(parse->unit), rtc, ct); - } -} - -/*-------------------------------------------------- - * periodic poll routine - */ -static void -poll_poll(parse) - struct parseunit *parse; -{ - register poll_timer_t *pt = (poll_timer_t *)parse->localdata; - - poll_dpoll(parse); - - if (pt != (poll_timer_t *)0) - { - pt->timer.event_time = current_time + ((poll_info_t *)parse->parse_type->cl_data)->rate; - TIMER_ENQUEUE(timerqueue, &pt->timer); - } -} - -/*-------------------------------------------------- - * init routine - setup timer - */ -static int -poll_init(parse) - struct parseunit *parse; -{ - register poll_timer_t *pt; - - if (((poll_info_t *)parse->parse_type->cl_data)->rate) - { - parse->localdata = (void *)malloc(sizeof(poll_timer_t)); - memset((char *)parse->localdata, 0, sizeof(poll_timer_t)); - - pt = (poll_timer_t *)parse->localdata; - - pt->timer.peer = (struct peer *)parse; /* well, only we know what it is */ - pt->timer.event_handler = poll_poll; - poll_poll(parse); - } - else - { - parse->localdata = (void *)0; - } - - return 0; -} - -/*-------------------------------------------------- - * end routine - clean up timer - */ -static void -poll_end(parse) - struct parseunit *parse; -{ - if (parse->localdata != (void *)0) - { - TIMER_DEQUEUE(&((poll_timer_t *)parse->localdata)->timer); - free((char *)parse->localdata); - parse->localdata = (void *)0; - } -} - -/**=========================================================================== - ** special code for special clocks - **/ - -/*-------------------------------------------------- - * trimble init routine - setup EOL and then do poll_init. - */ -static int -trimble_init(parse) - struct parseunit *parse; -{ -#ifdef HAVE_TERMIOS - struct termios tm; -#endif -#ifdef HAVE_SYSV_TTYS - struct termio tm; -#endif - /* - * configure terminal line for trimble receiver - */ - if (TTY_GETATTR(parse->fd, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: trimble_init: tcgetattr(fd, &tm): %m", CL_UNIT(parse->unit)); - return 0; - } - else - { - tm.c_cc[VEOL] = TRIMBLESV6_EOL; - - if (TTY_SETATTR(parse->fd, &tm) == -1) - { - syslog(LOG_ERR, "PARSE receiver #%d: trimble_init: tcsetattr(fd, &tm): %m", CL_UNIT(parse->unit)); - return 0; - } - } - return poll_init(parse); -} -#endif /* defined(REFCLOCK) && defined(PARSE) */ - -/* - * History: - * - * refclock_parse.c,v - * Revision 3.53 1994/03/25 13:07:39 kardel - * fixed offset calculation for large (>4 Min) offsets - * - * Revision 3.52 1994/03/03 09:58:00 kardel - * stick -kv in cvs is no fun - * - * Revision 3.49 1994/02/20 13:26:00 kardel - * rcs id cleanup - * - * Revision 3.48 1994/02/20 13:04:56 kardel - * parse add/delete second support - * - * Revision 3.47 1994/02/02 17:44:30 kardel - * rcs ids fixed - * - * Revision 3.45 1994/01/25 19:06:27 kardel - * 94/01/23 reconcilation - * - * Revision 3.44 1994/01/25 17:32:23 kardel - * settable extended variables - * - * Revision 3.43 1994/01/23 16:28:39 kardel - * HAVE_TERMIOS introduced - * - * Revision 3.42 1994/01/22 11:35:04 kardel - * added HAVE_TERMIOS - * - * Revision 3.41 1993/11/27 18:44:37 kardel - * can't trust GPS166 on unsync - * - * Revision 3.40 1993/11/21 18:03:36 kardel - * useless declaration deleted - * - * Revision 3.39 1993/11/21 15:30:15 kardel - * static funcitions may be declared only at outer level - * - * Revision 3.38 1993/11/15 21:26:49 kardel - * conditional define comments fixed - * - * Revision 3.37 1993/11/11 11:20:49 kardel - * declaration fixes - * - * Revision 3.36 1993/11/10 12:17:14 kardel - * #ifdef glitch - * - * Revision 3.35 1993/11/01 21:15:06 kardel - * comments updated - * - * Revision 3.34 1993/11/01 20:01:08 kardel - * parse Solaris support (initial version) - * - * Revision 3.33 1993/10/30 09:44:58 kardel - * conditional compilation flag cleanup - * - * Revision 3.32 1993/10/22 14:28:43 kardel - * Oct. 22nd 1993 reconcilation - * - * Revision 3.31 1993/10/10 21:19:10 kardel - * compilation cleanup - (minimal porting tests) - * - * Revision 3.30 1993/10/09 21:44:35 kardel - * syslog strings fixed - * - * Revision 3.29 1993/10/09 14:40:15 kardel - * default precision setting fixed - * - * Revision 3.28 1993/10/08 14:48:22 kardel - * Changed offset determination logic: - * Take the PPS offset if it is available and the time - * code offset is within [-0.5..0.5[, otherwise stick - * to the time code offset - * - * Revision 3.27 1993/10/08 00:53:17 kardel - * announce also simulated PPS via CIOGETEV in ntpq cl - * - * Revision 3.26 1993/10/07 23:29:35 kardel - * trimble fixes - * - * Revision 3.25 1993/10/06 21:13:35 kardel - * test reversed (CIOGETEV support) - * - * Revision 3.24 1993/10/03 20:18:26 kardel - * Well, values > 999999 in the usec field from uniqtime() timestamps - * can prove harmful. - * - * Revision 3.23 1993/10/03 19:49:54 kardel - * buftvtots where failing on uninitialized time stamps - * - * Revision 3.22 1993/10/03 19:11:09 kardel - * restructured I/O handling - * - * Revision 3.21 1993/09/29 11:30:18 kardel - * special init for trimble to set EOL - * - * Revision 3.20 1993/09/27 22:46:28 kardel - * preserve module stack if I_PUSH parse fails - * - * Revision 3.19 1993/09/27 21:10:11 kardel - * wrong structure member - * - * Revision 3.18 1993/09/27 13:05:06 kardel - * Trimble is true polling only - * - * Revision 3.17 1993/09/27 12:47:10 kardel - * poll string support generalized - * - * Revision 3.16 1993/09/26 23:40:56 kardel - * new parse driver logic - * - * Revision 3.15 1993/09/24 15:00:51 kardel - * Sep 23rd distribution... - * - * Revision 3.14 1993/09/22 18:21:15 kardel - * support ppsclock streams module (-DSTREAM -DPPSPPS -DPARSEPPS -UPARSESTREAM) - * - * Revision 3.13 1993/09/05 15:38:33 kardel - * not every cpp understands #error... - * - * Revision 3.12 1993/09/02 20:04:19 kardel - * TTY cleanup - * - * Revision 3.11 1993/09/01 21:48:47 kardel - * conditional cleanup - * - * Revision 3.10 1993/09/01 11:32:45 kardel - * assuming HAVE_POSIX_TTYS when STREAM defined - * - * Revision 3.9 1993/08/31 22:31:46 kardel - * SINIX-M SysVR4 integration - * - * Revision 3.8 1993/08/27 00:29:50 kardel - * compilation cleanup - * - * Revision 3.7 1993/08/24 22:27:30 kardel - * cleaned up AUTOCONF DCF77 mess 8-) - wasn't too bad - * - * Revision 3.6 1993/08/24 21:36:23 kardel - * casting and ifdefs - * - * Revision 3.5 1993/07/09 23:36:59 kardel - * HAVE_POSIX_TTYS used to produce errors 8-( - BSD driver support still lacking - * - * Revision 3.4 1993/07/09 12:42:29 kardel - * RAW DCF now officially released - * - * Revision 3.3 1993/07/09 11:50:37 kardel - * running GPS also on 960 to be able to switch GPS/DCF77 - * - * Revision 3.2 1993/07/09 11:37:34 kardel - * Initial restructured version + GPS support - * - * Revision 3.1 1993/07/06 10:01:07 kardel - * DCF77 driver goes generic... - * - */ diff --git a/usr.sbin/xntpd/xntpdc/Makefile.tmpl b/usr.sbin/xntpd/xntpdc/Makefile.tmpl deleted file mode 100644 index 80c8f93d406b..000000000000 --- a/usr.sbin/xntpd/xntpdc/Makefile.tmpl +++ /dev/null @@ -1,68 +0,0 @@ -# -# Makefile.tmpl -# -PROGRAM= xntpdc -# -# xntpdc - private mode query program for xntp -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -RESLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -OBJS= ntpdc.o ntpdc_ops.o -SOURCE= ntpdc.c ntpdc_ops.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(RESLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak lint.errs .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(DEFS_LOCAL) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version diff --git a/usr.sbin/xntpd/xntpres/Makefile.tmpl b/usr.sbin/xntpd/xntpres/Makefile.tmpl deleted file mode 100644 index 8f0742bd3bbc..000000000000 --- a/usr.sbin/xntpd/xntpres/Makefile.tmpl +++ /dev/null @@ -1,68 +0,0 @@ -# -# Makefile.tmpl,v 3.1 1993/07/06 01:12:07 jbj Exp -# -PROGRAM= xntpres -# -# xntpres - name resolver support for xntpd -# -COMPILER= cc -COPTS= -O -BINDIR= /usr/local -INSTALL= install -DEFS= -DEFS_OPT= -DEFS_LOCAL= -RESLIB= -COMPAT= -# -INCL= -I../include -CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -CC= $(COMPILER) -LIB= ../lib/libntp.a -LINTLIB= ../lib/llib-llibntp.ln -MAKE= make -TOP=../ -# -OBJS= xntpres.o -SOURCE= xntpres.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIB) version.o - $(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(RESLIB) $(COMPAT) - -install: $(BINDIR)/$(PROGRAM) - -$(BINDIR)/$(PROGRAM): $(PROGRAM) - $(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR) - -tags: - ctags *.c *.h - -depend: - mkdep $(CFLAGS) $(SOURCE) - -clean: - -@rm -f $(PROGRAM) *.o *.out tags make.log Makefile.bak lint.errs .version - -distclean: clean - -@rm -f *.orig *.rej .version Makefile - -lint: $(LINTLIB) - lint -x -u $(DEFS) $(DEFS_LOCAL) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs - -../lib/llib-llibntp.ln: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib - -../lib/libntp.a: - cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" - -# -# we want to build the current version string here -# -version.o: ../VERSION - ../scripts/mkversion $(PROGRAM) - $(CC) $(COPTS) $(INCL) -c version.c - -../VERSION: - -@rm -f .version diff --git a/usr.sbin/xntpd/xntpres/README b/usr.sbin/xntpd/xntpres/README deleted file mode 100644 index 06d7266b4f2c..000000000000 --- a/usr.sbin/xntpd/xntpres/README +++ /dev/null @@ -1,6 +0,0 @@ -README file for directory ./xntpres of the NTP Version 3 distribution - -This directory contains the sources for the xntpres utility program. See -the README and RELNOTES files in the parent directory for directions on -how to make and install this program. The current version number of this -program is in the version.c file. diff --git a/usr.sbin/xntpd/xntpres/xntpres.c b/usr.sbin/xntpd/xntpres/xntpres.c deleted file mode 100644 index 47c6eda7dc12..000000000000 --- a/usr.sbin/xntpd/xntpres/xntpres.c +++ /dev/null @@ -1,850 +0,0 @@ -/* xntpres.c,v 3.1 1993/07/06 01:12:09 jbj Exp - * xntpres - process configuration entries which require use of the resolver - * - * This is meant to be run by xntpd on the fly. It is not guaranteed - * to work properly if run by hand. This is actually a quick hack to - * stave off violence from people who hate using numbers in the - * configuration file (at least I hope the rest of the daemon is - * better than this). Also might provide some ideas about how one - * might go about autoconfiguring an NTP distribution network. - * - * Usage is: - * xntpres [-d] [-r] keyid keyfile configuration_data - */ -#include -#include -#include -#include -#include -#include -#include - -#include "ntp_select.h" -#include "ntp_fp.h" -#include "ntp.h" -#include "ntp_io.h" -#include "ntp_malloc.h" -#include "ntp_request.h" -#include "ntp_string.h" -#include "ntp_stdlib.h" -#include "ntp_syslog.h" - -#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) - -/* - * Each item we are to resolve and configure gets one of these - * structures defined for it. - */ -struct conf_entry { - struct conf_entry *ce_next; - char *ce_name; /* name we are trying to resolve */ - struct conf_peer ce_config; /* configuration info for peer */ -}; -#define ce_peeraddr ce_config.peeraddr -#define ce_hmode ce_config.hmode -#define ce_version ce_config.version -#define ce_minpoll ce_config.minpoll -#define ce_maxpoll ce_config.maxpoll -#define ce_flags ce_config.flags -#define ce_ttl ce_config.ttl -#define ce_keyid ce_config.keyid - -/* - * confentries is a pointer to the list of configuration entries - * we have left to do. - */ -struct conf_entry *confentries = NULL; - -/* - * We take an interrupt every thirty seconds, at which time we decrement - * config_timer and resolve_timer. The former is set to 2, so we retry - * unsucessful reconfigurations every minute. The latter is set to - * an exponentially increasing value which starts at 2 and increases to - * 32. When this expires we retry failed name resolutions. - * - * We sleep SLEEPTIME seconds before doing anything, to give the server - * time to arrange itself. - */ -#define MINRESOLVE 2 -#define MAXRESOLVE 32 -#define CONFIG_TIME 2 -#define ALARM_TIME 30 - -#define SLEEPTIME 2 - -int config_timer = 0; -int resolve_timer = 0; - -int resolve_value; /* next value of resolve timer */ - -/* - * Big hack attack - */ -#define LOCALHOST 0x7f000001 /* 127.0.0.1, in hex, of course */ -#define SKEWTIME 0x08000000 /* 0.03125 seconds as a l_fp fraction */ - -/* - * Select time out. Set to 2 seconds. The server is on the local machine, - * after all. - */ -#define TIMEOUT_SEC 2 -#define TIMEOUT_USEC 0 - - -/* - * Input processing. The data on each line in the configuration file - * is supposed to consist of entries in the following order - */ -#define TOK_HOSTNAME 0 -#define TOK_HMODE 1 -#define TOK_VERSION 2 -#define TOK_MINPOLL 3 -#define TOK_MAXPOLL 4 -#define TOK_FLAGS 5 -#define TOK_TTL 6 -#define TOK_KEYID 7 -#define NUMTOK 8 - -#define MAXLINESIZE 512 - - -/* - * File descriptor for ntp request code. - */ -int sockfd = -1; - -/* - * Misc. data from argument processing - */ -int removefile = 0; /* remove configuration file when done */ - -U_LONG req_keyid; /* request keyid */ -char *keyfile; /* file where keys are kept */ -char *conffile; /* name of the file with configuration info */ - -char *progname; -int debug = 0; -extern char *Version; -extern int errno; - -static RETSIGTYPE bong P((int)); -static void checkparent P((void)); -static void removeentry P((struct conf_entry *)); -static void addentry P((char *, int, int, int, int, int, int, U_LONG)); -static int findhostaddr P((struct conf_entry *)); -static void openntp P((void)); -static int request P((struct conf_peer *)); -static char * nexttoken P((char **)); -static void readconf P((FILE *, char *)); -static void doconfigure P((int)); - -/* - * main - parse arguments and handle options - */ -void -main(argc, argv) - int argc; - char *argv[]; -{ - int c; - int errflg = 0; - char *cp; - FILE *in; - extern int ntp_optind; - - progname = argv[0]; - - /* - * Better get syslog open early since stderr messages are likely - * ending up in the twilight zone - */ - cp = strrchr(argv[0], '/'); - if (cp == 0) - cp = argv[0]; - else - cp++; - -#ifndef LOG_DAEMON - openlog(cp, LOG_PID); -#else - -#ifndef LOG_NTP -#define LOG_NTP LOG_DAEMON -#endif - openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP); -#ifdef DEBUG - if (debug) - setlogmask(LOG_UPTO(LOG_DEBUG)); - else -#endif /* DEBUG */ - setlogmask(LOG_UPTO(LOG_INFO)); -#endif /* LOG_DAEMON */ - - syslog(LOG_NOTICE, Version); - - while ((c = ntp_getopt(argc, argv, "dr")) != EOF) - switch (c) { - case 'd': - ++debug; - break; - case 'r': - ++removefile; - break; - default: - errflg++; - break; - } - if (errflg || (ntp_optind + 3) != argc) { - (void) fprintf(stderr, - "usage: %s [-d] [-r] keyid keyfile conffile\n", progname); - syslog(LOG_ERR, "exiting due to usage error"); - exit(2); - } - - if (!atouint(argv[ntp_optind], &req_keyid)) { - syslog(LOG_ERR, "undecodeable keyid %s", argv[ntp_optind]); - exit(1); - } - - keyfile = argv[ntp_optind+1]; - conffile = argv[ntp_optind+2]; - - /* - * Make sure we have the key we need - */ - if (!authreadkeys(keyfile)) - exit(1); - if (!authhavekey(req_keyid)) { - syslog(LOG_ERR, "request keyid %lu not found in %s", - req_keyid, keyfile); - exit(1); - } - - /* - * Read the configuration info - */ - if ((in = fopen(conffile, "r")) == NULL) { - syslog(LOG_ERR, "can't open configuration file %s: %m", - conffile); - exit(1); - } - readconf(in, conffile); - (void) fclose(in); - if (removefile) - (void) unlink(conffile); - - /* - * Sleep a little to make sure the server is completely up - */ - sleep(SLEEPTIME); - - /* - * Make a first cut at resolving the bunch - */ - doconfigure(1); - if (confentries == NULL) - exit(0); /* done that quick */ - - /* - * Here we've got some problem children. Set up the timer - * and wait for it. - */ - resolve_value = resolve_timer = MINRESOLVE; - config_timer = CONFIG_TIME; - (void) signal(SIGALRM, bong); - alarm(ALARM_TIME); - - for (;;) { - if (confentries == NULL) - exit(0); - checkparent(); - if (resolve_timer == 0) { - if (resolve_value < MAXRESOLVE) - resolve_value <<= 1; - resolve_timer = resolve_value; - config_timer = CONFIG_TIME; - doconfigure(1); - continue; - } else if (config_timer == 0) { - config_timer = CONFIG_TIME; - doconfigure(0); - continue; - } - /* - * There is a race in here. Is okay, though, since - * all it does is delay things by 30 seconds. - */ - (void) pause(); - } -} - - -/* - * bong - service and reschedule an alarm() interrupt - */ -static RETSIGTYPE -bong(sig) -int sig; -{ - if (config_timer > 0) - config_timer--; - if (resolve_timer > 0) - resolve_timer--; - alarm(ALARM_TIME); -} - - -/* - * checkparent - see if our parent process is still running - */ -static void -checkparent() -{ - /* - * If our parent (the server) has died we will have been - * inherited by init. If so, exit. - */ - if (getppid() == 1) { - syslog(LOG_INFO, "parent died before we finished, exiting"); - exit(0); - } -} - - -/* - * removeentry - we are done with an entry, remove it from the list - */ -static void -removeentry(entry) - struct conf_entry *entry; -{ - register struct conf_entry *ce; - - ce = confentries; - if (ce == entry) { - confentries = ce->ce_next; - return; - } - - while (ce != NULL) { - if (ce->ce_next == entry) { - ce->ce_next = entry->ce_next; - return; - } - ce = ce->ce_next; - } -} - - -/* - * addentry - add an entry to the configuration list - */ -static void -addentry(name, mode, version, minpoll, maxpoll, flags, ttl, keyid) - char *name; - int mode; - int version; - int minpoll; - int maxpoll; - int flags; - int ttl; - U_LONG keyid; -{ - register char *cp; - register struct conf_entry *ce; - int len; - - len = strlen(name) + 1; - cp = emalloc((unsigned)len); - memmove(cp, name, len); - - ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry)); - ce->ce_name = cp; - ce->ce_peeraddr = 0; - ce->ce_hmode = (u_char)mode; - ce->ce_version = (u_char)version; - ce->ce_minpoll = (u_char)minpoll; - ce->ce_maxpoll = (u_char)maxpoll; - ce->ce_flags = (u_char)flags; - ce->ce_ttl = (u_char)ttl; - ce->ce_keyid = htonl(keyid); - ce->ce_next = NULL; - - if (confentries == NULL) { - confentries = ce; - } else { - register struct conf_entry *cep; - - for (cep = confentries; cep->ce_next != NULL; - cep = cep->ce_next) - /* nothing */; - cep->ce_next = ce; - } -} - - -/* - * findhostaddr - resolve a host name into an address - * - * The routine sticks the address into the entry's ce_peeraddr if it - * gets one. It returns 1 for "success" and 0 for an uncorrectable - * failure. Note that "success" includes try again errors. You can - * tell that you got a try again since ce_peeraddr will still be zero. - */ -static int -findhostaddr(entry) - struct conf_entry *entry; -{ - struct hostent *hp; - - checkparent(); /* make sure our guy is still running */ - - hp = gethostbyname(entry->ce_name); - - if (hp == NULL) { -#ifndef NODNS - /* - * If the resolver is in use, see if the failure is - * temporary. If so, return success. - */ - extern int h_errno; - - if (h_errno == TRY_AGAIN) - return 1; -#endif - return (0); - } - - /* - * Use the first address. We don't have any way to - * tell preferences and older gethostbyname() implementations - * only return one. - */ - memmove((char *)&(entry->ce_peeraddr), - hp->h_addr, - sizeof(struct in_addr)); - return (1); -} - - -/* - * openntp - open a socket to the ntp server - */ -static void -openntp() -{ - struct sockaddr_in saddr; - - if (sockfd >= 0) - return; - - sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - syslog(LOG_ERR, "socket() failed: %m"); - exit(1); - } - - memset((char *)&saddr, 0, sizeof(saddr)); - saddr.sin_family = AF_INET; - saddr.sin_port = htons(NTP_PORT); /* trash */ - saddr.sin_addr.s_addr = htonl(LOCALHOST); /* garbage */ - - - /* - * Make the socket non-blocking. We'll wait with select() - */ -#if defined(O_NONBLOCK) - if (fcntl(sockfd, F_SETFL, O_NONBLOCK) == -1) { - syslog(LOG_ERR, "fcntl(O_NONBLOCK) failed: %m"); - exit(1); - } -#else -#if defined(FNDELAY) - if (fcntl(sockfd, F_SETFL, FNDELAY) == -1) { - syslog(LOG_ERR, "fcntl(FNDELAY) failed: %m"); - exit(1); - } -#else -NEED NON BLOCKING IO -#endif -#endif - - if (connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr)) == -1) { - syslog(LOG_ERR, "connect() failed: %m"); - exit(1); - } -} - - -/* - * request - send a configuration request to the server, wait for a response - */ -static int -request(conf) - struct conf_peer *conf; -{ - fd_set fdset; - struct timeval tvout; - struct req_pkt reqpkt; - l_fp ts; - int n; - - checkparent(); /* make sure our guy is still running */ - - if (sockfd < 0) - openntp(); - - /* - * Try to clear out any previously received traffic so it - * doesn't fool us. Note the socket is nonblocking. - */ - while (read(sockfd, (char *)&reqpkt, REQ_LEN_MAC) > 0) - /* nothing */; - - /* - * Make up a request packet with the configuration info - */ - memset((char *)&reqpkt, 0, sizeof(reqpkt)); - - reqpkt.rm_vn_mode = RM_VN_MODE(0, 0); - reqpkt.auth_seq = AUTH_SEQ(1, 0); /* authenticated, no seq */ - reqpkt.implementation = IMPL_XNTPD; /* local implementation */ - reqpkt.request = REQ_CONFIG; /* configure a new peer */ - reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */ - reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer)); - memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer)); - reqpkt.keyid = htonl(req_keyid); - - auth1crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC); - gettstamp(&ts); - M_ADDUF(ts.l_ui, ts.l_uf, SKEWTIME); - HTONL_FP(&ts, &reqpkt.tstamp); - n = auth2crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC); - - /* - * Done. Send it. - */ - n = write(sockfd, (char *)&reqpkt, REQ_LEN_NOMAC + n); - if (n < 0) { - syslog(LOG_ERR, "send to NTP server failed: %m"); - return 0; /* maybe should exit */ - } - - /* - * Wait for a response. A weakness of the mode 7 protocol used - * is that there is no way to associate a response with a - * particular request, i.e. the response to this configuration - * request is indistinguishable from that to any other. I should - * fix this some day. In any event, the time out is fairly - * pessimistic to make sure that if an answer is coming back - * at all, we get it. - */ - for (;;) { - FD_ZERO(&fdset); - FD_SET(sockfd, &fdset); - tvout.tv_sec = TIMEOUT_SEC; - tvout.tv_usec = TIMEOUT_USEC; - - n = select(sockfd + 1, &fdset, (fd_set *)0, - (fd_set *)0, &tvout); - - if (n <= 0) { - if (n < 0) - syslog(LOG_ERR, "select() fails: %m"); - return 0; - } - - n = read(sockfd, (char *)&reqpkt, REQ_LEN_MAC); - if (n <= 0) { - if (n < 0) { - syslog(LOG_ERR, "read() fails: %m"); - return 0; - } - continue; - } - - /* - * Got one. Check through to make sure it is what - * we expect. - */ - if (n < RESP_HEADER_SIZE) { - syslog(LOG_ERR, "received runt response (%d octets)", - n); - continue; - } - - if (!ISRESPONSE(reqpkt.rm_vn_mode)) { -#ifdef DEBUG - if (debug > 1) - printf("received non-response packet\n"); -#endif - continue; - } - - if (ISMORE(reqpkt.rm_vn_mode)) { -#ifdef DEBUG - if (debug > 1) - printf("received fragmented packet\n"); -#endif - continue; - } - - if (INFO_VERSION(reqpkt.rm_vn_mode) != NTP_VERSION - || INFO_MODE(reqpkt.rm_vn_mode) != MODE_PRIVATE) { -#ifdef DEBUG - if (debug > 1) - printf("version (%d) or mode (%d) incorrect\n", - INFO_VERSION(reqpkt.rm_vn_mode), - INFO_MODE(reqpkt.rm_vn_mode)); -#endif - continue; - } - - if (INFO_SEQ(reqpkt.auth_seq) != 0) { -#ifdef DEBUG - if (debug > 1) - printf("nonzero sequence number (%d)\n", - INFO_SEQ(reqpkt.auth_seq)); -#endif - continue; - } - - if (reqpkt.implementation != IMPL_XNTPD || - reqpkt.request != REQ_CONFIG) { -#ifdef DEBUG - if (debug > 1) - printf( - "implementation (%d) or request (%d) incorrect\n", - reqpkt.implementation, reqpkt.request); -#endif - continue; - } - - if (INFO_NITEMS(reqpkt.err_nitems) != 0 || - INFO_MBZ(reqpkt.mbz_itemsize) != 0 || - INFO_ITEMSIZE(reqpkt.mbz_itemsize != 0)) { -#ifdef DEBUG - if (debug > 1) - printf( - "nitems (%d) mbz (%d) or itemsize (%d) nonzero\n", - INFO_NITEMS(reqpkt.err_nitems), - INFO_MBZ(reqpkt.mbz_itemsize), - INFO_ITEMSIZE(reqpkt.mbz_itemsize)); -#endif - continue; - } - - n = INFO_ERR(reqpkt.err_nitems); - switch (n) { - case INFO_OKAY: - /* success */ - return 1; - - case INFO_ERR_IMPL: - syslog(LOG_ERR, - "server reports implementation mismatch!!"); - return 0; - - case INFO_ERR_REQ: - syslog(LOG_ERR, - "server claims configuration request is unknown"); - return 0; - - case INFO_ERR_FMT: - syslog(LOG_ERR, - "server indicates a format error occured(!!)"); - return 0; - - case INFO_ERR_NODATA: - syslog(LOG_ERR, - "server indicates no data available (shouldn't happen)"); - return 0; - - case INFO_ERR_AUTH: - syslog(LOG_ERR, - "server returns a permission denied error"); - return 0; - - default: - syslog(LOG_ERR, - "server returns unknown error code %d", n); - return 0; - } - } -} - - -/* - * nexttoken - return the next token from a line - */ -static char * -nexttoken(lptr) - char **lptr; -{ - register char *cp; - register char *tstart; - - cp = *lptr; - - /* - * Skip leading white space - */ - while (*cp == ' ' || *cp == '\t') - cp++; - - /* - * If this is the end of the line, return nothing. - */ - if (*cp == '\n' || *cp == '\0') { - *lptr = cp; - return NULL; - } - - /* - * Must be the start of a token. Record the pointer and look - * for the end. - */ - tstart = cp++; - while (*cp != ' ' && *cp != '\t' && *cp != '\n' && *cp != '\0') - cp++; - - /* - * Terminate the token with a \0. If this isn't the end of the - * line, space to the next character. - */ - if (*cp == '\n' || *cp == '\0') - *cp = '\0'; - else - *cp++ = '\0'; - - *lptr = cp; - return tstart; -} - - -/* - * readconf - read the configuration information out of the file we - * were passed. Note that since the file is supposed to be - * machine generated, we bail out at the first sign of trouble. - */ -static void -readconf(fp, name) - FILE *fp; - char *name; -{ - register int i; - char *token[NUMTOK]; - U_LONG intval[NUMTOK]; - int flags; - char buf[MAXLINESIZE]; - char *bp; - - while (fgets(buf, MAXLINESIZE, fp) != NULL) { - - bp = buf; - for (i = 0; i < NUMTOK; i++) { - if ((token[i] = nexttoken(&bp)) == NULL) { - syslog(LOG_ERR, - "tokenizing error in file `%s', quitting", - name); - exit(1); - } - } - - for (i = 1; i < NUMTOK; i++) { - if (!atouint(token[i], &intval[i])) { - syslog(LOG_ERR, - "format error for integer token `%s', file `%s', quitting", - token[i], name); - exit(1); - } - } - - if (intval[TOK_HMODE] != MODE_ACTIVE && - intval[TOK_HMODE] != MODE_CLIENT && - intval[TOK_HMODE] != MODE_BROADCAST) { - syslog(LOG_ERR, "invalid mode (%d) in file %s", - intval[TOK_HMODE], name); - exit(1); - } - - if (intval[TOK_VERSION] > NTP_VERSION || - intval[TOK_VERSION] < NTP_OLDVERSION) { - syslog(LOG_ERR, "invalid version (%d) in file %s", - intval[TOK_VERSION], name); - exit(1); - } - - if (intval[TOK_MINPOLL] < NTP_MINPOLL || - intval[TOK_MINPOLL] > NTP_MAXPOLL) { - syslog(LOG_ERR, "invalid MINPOLL value (%d) in file %s", - intval[TOK_MINPOLL], name); - exit(1); - } - - if (intval[TOK_MAXPOLL] < NTP_MINPOLL || - intval[TOK_MAXPOLL] > NTP_MAXPOLL) { - syslog(LOG_ERR, "invalid MAXPOLL value (%d) in file %s", - intval[TOK_MAXPOLL], name); - exit(1); - } - - if ((intval[TOK_FLAGS] & ~(FLAG_AUTHENABLE|FLAG_PREFER)) - != 0) { - syslog(LOG_ERR, "invalid flags (%d) in file %s", - intval[TOK_FLAGS], name); - exit(1); - } - - flags = 0; - if (intval[TOK_FLAGS] & FLAG_AUTHENABLE) - flags |= CONF_FLAG_AUTHENABLE; - if (intval[TOK_FLAGS] & FLAG_PREFER) - flags |= CONF_FLAG_PREFER; - - /* - * This is as good as we can check it. Add it in. - */ - addentry(token[TOK_HOSTNAME], (int)intval[TOK_HMODE], - (int)intval[TOK_VERSION], (int)intval[TOK_MINPOLL], - (int)intval[TOK_MAXPOLL], flags, (int)intval[TOK_TTL], - intval[TOK_KEYID]); - } -} - - -/* - * doconfigure - attempt to resolve names and configure the server - */ -static void -doconfigure(dores) - int dores; -{ - register struct conf_entry *ce; - register struct conf_entry *ceremove; - - ce = confentries; - while (ce != NULL) { - if (dores && ce->ce_peeraddr == 0) { - if (!findhostaddr(ce)) { - syslog(LOG_ERR, - "couldn't resolve `%s', giving up on it", - ce->ce_name); - ceremove = ce; - ce = ceremove->ce_next; - removeentry(ceremove); - continue; - } - } - - if (ce->ce_peeraddr != 0) { - if (request(&ce->ce_config)) { - ceremove = ce; - ce = ceremove->ce_next; - removeentry(ceremove); - continue; - } - } - ce = ce->ce_next; - } -} -- cgit v1.3