BSD 4_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Sat, 14 May 1983 00:53:20 +0000 (16:53 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Sat, 14 May 1983 00:53:20 +0000 (16:53 -0800)
Work on file usr/src/new/new/spms/src/lib/libslist/test/slappend.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slget.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slprepend.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slpop.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slprint.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsappend.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slrm.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsort.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsplice.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsget.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsprepend.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsprint.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slsrm.a
Work on file usr/src/new/new/spms/src/lib/libslist/test/slssort.a
Work on file usr/src/new/new/spms/src/lib/libslist/src/slssort.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slrm.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slappend.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slprepend.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slinit.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsrm.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsrewind.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsprint.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsprepend.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsinit.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsget.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsappend.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slget.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsort.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slrewind.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slsplice.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slprint.c
Work on file usr/src/new/new/spms/src/lib/libslist/src/slpop.c
Work on file usr/src/new/new/spms/src/lib/libslist/lib/t.Makefile
Work on file usr/src/new/new/spms/src/lib/libtree/test/treerm.a
Work on file usr/src/new/new/spms/src/lib/libtree/test/tree.a
Work on file usr/src/new/new/spms/src/lib/libtree/test/treesearch.a
Work on file usr/src/new/new/spms/src/lib/libtree/src/tree.c
Work on file usr/src/new/new/spms/src/lib/libtree/src/treerm.c
Work on file usr/src/new/new/spms/src/lib/libtree/src/treesearch.c
Work on file usr/src/new/new/spms/src/lib/libtree/lib/t.Makefile
Work on file usr/src/new/new/spms/src/lib/libspms/src/argvtos.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/rm_dir.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pfxcpy.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/chproject.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/fatal.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/diff.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getcpd.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getcwp.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/gethdir.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getshell.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getproject.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getwd.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/mkalias.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/mk_dir.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/optpath.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pathcat.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/mustfopen.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pathhead.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pathtail.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/ppathcat.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/ppathhead.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pdtyp.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/readpath.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pperror.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/readpld.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/strsav.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/strpcpy.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/xorpath.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/yes.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/warn.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pdtparse.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/xppath.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/pdtmatch.c
Work on file usr/src/new/new/spms/src/lib/libspms/src/getpwdir.c
Work on file usr/src/new/new/spms/src/lib/libspms/test/argvtos.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/fatal.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/chproject.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/diff.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/getcpd.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/getcwp.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/gethdir.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/getpwdir.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/getshell.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/getwd.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/mk_dir.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/ispdt.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/mkalias.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/mustfopen.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/optpath.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pathcat.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pathhead.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pathtail.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pdtmatch.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pdtparse.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pdtyp.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pfxcpy.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/ppathcat.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/ppathhead.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/pperror.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/readpld.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/warn.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/xorpath.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/rm_dir.a
Work on file usr/src/new/new/spms/src/lib/libspms/test/yes.a
Work on file usr/src/new/new/spms/src/lib/libspms/lib/...
Work on file usr/src/new/new/spms/src/lib/libhash/src/htlookup.c
Work on file usr/src/new/new/spms/src/lib/libhash/src/hthash.c
Work on file usr/src/new/new/spms/src/lib/libhash/src/htinit.c
Work on file usr/src/new/new/spms/src/lib/libhash/src/htrm.c
Work on file usr/src/new/new/spms/src/lib/libhash/src/htinstall.c
Work on file usr/src/new/new/spms/src/lib/libhash/test/htinstall.a
Work on file usr/src/new/new/spms/src/lib/libhash/test/htrm.a
Work on file usr/src/new/new/spms/src/lib/libhash/lib/t.Makefile
Work on file usr/src/new/new/spms/src/lib/libpdb/test/openpdb.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/closepdb.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/_closepdb.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/paddkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbaddflag.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbaddkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbaddstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbclear.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbchgkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbfndflag.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbgetkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbfndstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbfndkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbgetstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pblenkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbrmflag.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbrmkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbrmstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pfndent.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pbstretch.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/resetpdb.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pchgkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pputflag.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pgetent.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/pputstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/prment.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/prmflag.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/prmstring.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/prmkey.a
Work on file usr/src/new/new/spms/src/lib/libpdb/test/rewindpdb.a
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbaddflag.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbskipfield.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/resetpdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbcpykey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/_closepdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbgetstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/closepdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbaddkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbaddstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbrmkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbfndkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pblenfield.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbchgkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbshrink.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbcmpfield.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pchgkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/openpdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbskipkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/errpdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/paddkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pputent.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pblenkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/prment.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/prmkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/prmflag.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/rewindpdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pputflag.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pputstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbcmpkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pgetent.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbfndstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbrmstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbstretch.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbfndflag.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbrmflag.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbcpyfield.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/prmstring.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pfndent.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbgetkey.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/pbclear.c
Work on file usr/src/new/new/spms/src/lib/libpdb/src/mustopenpdb.c
Work on file usr/src/new/new/spms/src/lib/libpdb/lib/t.Makefile
Work on file usr/src/new/new/spms/src/lib/pgrep/readmf.c
Work on file usr/src/new/new/spms/src/lib/pgrep/pgrep.h
Work on file usr/src/new/new/spms/src/lib/pgrep/grep.c
Work on file usr/src/new/new/spms/src/lib/phelp/phelp.cmd
Work on file usr/src/new/new/spms/src/lib/phelp/phelp.help
Work on file usr/src/new/new/spms/src/lib/x.Makefile/t.Makefile
Work on file usr/src/new/new/spms/src/bin/chproject/chproject.c

Synthesized-from: CSRG/cd1/4.2

192 files changed:
usr/src/new/new/spms/src/bin/chproject/chproject.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/lib/t.Makefile [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/src/hthash.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/src/htinit.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/src/htinstall.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/src/htlookup.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/src/htrm.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/test/htinstall.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libhash/test/htrm.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/lib/t.Makefile [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/_closepdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/closepdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/errpdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/mustopenpdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/openpdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/paddkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbaddflag.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbaddkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbaddstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbchgkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbclear.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbcmpfield.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbcmpkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbcpyfield.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbcpykey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbfndflag.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbfndkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbfndstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbgetkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbgetstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pblenfield.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pblenkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbrmflag.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbrmkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbrmstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbshrink.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbskipfield.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbskipkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pbstretch.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pchgkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pfndent.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pgetent.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pputent.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pputflag.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/pputstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/prment.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/prmflag.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/prmkey.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/prmstring.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/resetpdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/src/rewindpdb.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/_closepdb.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/closepdb.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/openpdb.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/paddkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbaddflag.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbaddkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbaddstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbchgkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbclear.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbfndflag.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbfndkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbfndstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbgetkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbgetstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pblenkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbrmflag.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbrmkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbrmstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pbstretch.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pchgkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pfndent.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pgetent.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pputflag.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/pputstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/prment.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/prmflag.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/prmkey.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/prmstring.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/resetpdb.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libpdb/test/rewindpdb.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/lib/t.Makefile [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slappend.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slget.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slinit.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slpop.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slprepend.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slprint.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slrewind.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slrm.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsappend.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsget.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsinit.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsort.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsplice.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsprepend.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsprint.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsrewind.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slsrm.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/src/slssort.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slappend.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slget.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slpop.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slprepend.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slprint.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slrm.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsappend.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsget.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsort.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsplice.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsprepend.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsprint.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slsrm.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libslist/test/slssort.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/lib/... [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/argvtos.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/chproject.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/diff.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/fatal.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getcpd.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getcwp.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/gethdir.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getproject.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getpwdir.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getshell.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/getwd.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/mk_dir.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/mkalias.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/mustfopen.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/optpath.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pathcat.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pathhead.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pathtail.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pdtmatch.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pdtparse.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pdtyp.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pfxcpy.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/ppathcat.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/ppathhead.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/pperror.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/readpath.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/readpld.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/rm_dir.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/strpcpy.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/strsav.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/warn.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/xorpath.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/xppath.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/src/yes.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/argvtos.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/chproject.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/diff.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/fatal.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/getcpd.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/getcwp.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/gethdir.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/getpwdir.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/getshell.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/getwd.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/ispdt.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/mk_dir.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/mkalias.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/mustfopen.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/optpath.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pathcat.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pathhead.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pathtail.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pdtmatch.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pdtparse.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pdtyp.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pfxcpy.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/ppathcat.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/ppathhead.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/pperror.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/readpld.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/rm_dir.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/warn.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/xorpath.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libspms/test/yes.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/lib/t.Makefile [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/src/tree.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/src/treerm.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/src/treesearch.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/test/tree.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/test/treerm.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/libtree/test/treesearch.a [new file with mode: 0644]
usr/src/new/new/spms/src/lib/pgrep/grep.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/pgrep/pgrep.h [new file with mode: 0644]
usr/src/new/new/spms/src/lib/pgrep/readmf.c [new file with mode: 0644]
usr/src/new/new/spms/src/lib/phelp/phelp.cmd [new file with mode: 0644]
usr/src/new/new/spms/src/lib/phelp/phelp.help [new file with mode: 0644]
usr/src/new/new/spms/src/lib/x.Makefile/t.Makefile [new file with mode: 0644]

diff --git a/usr/src/new/new/spms/src/bin/chproject/chproject.c b/usr/src/new/new/spms/src/bin/chproject/chproject.c
new file mode 100644 (file)
index 0000000..ffdc5d6
--- /dev/null
@@ -0,0 +1,157 @@
+static char *rcsid = "$Header$";
+/*
+ * chproject - change current project
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include "bin.h"
+#include "macro.h"
+#include "path.h"
+#include "pdb.h"
+#include "pld.h"
+#include "spms.h"
+#include "system.h"
+#include "yesno.h"
+
+char *PGN;                             /* program name */
+int CSHELL = 0;                                /* C shell command interpreter flag */
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       extern int PPDEBUG;             /* project pathname debug flag */
+       char *getcwp();                 /* get current working project */
+       char *getshell();               /* get command shell pathname */
+       char *pathtail();               /* remove pathname head */
+       int chproject();                /* change project */
+       int dflag = NO;                 /* project description flag */
+       int fflag = YES;                /* execute PROJECTRC file */
+       int status = 0;                 /* exit status */
+       void mustchdir();               /* must change directory */
+       void printPROJECT();            /* print PROJECT value */
+       void printcd();                 /* print "cd" command */
+       void printdesc();               /* print project description */
+       void printrc();                 /* print PROJECTRC execution request */
+
+       PGN = pathtail(*argv);
+       if (EQUAL(pathtail(getshell()), pathtail(CSH))) CSHELL++;
+
+       {
+       register char *s;               /* option pointer */
+       while (--argc > 0 && **++argv == '-')
+               {
+               for (s = argv[0]+1; *s != '\0'; s++)
+                       switch (*s)
+                               {
+                               case 'D':
+                                       PPDEBUG = YES;
+                                       break;
+                               case 'd':
+                                       dflag = YES;
+                                       break;
+                               case 'f':
+                                       fflag = NO;
+                                       break;
+                               default:
+                                       warn("bad option -%c", *s);
+                                       status = 1;
+                                       goto endfor;
+                               }
+               endfor: continue;
+               }
+       }
+       if (status == 1 || argc != 1)
+               fatal("usage: chproject [-df] projectname");
+       if (chproject(*argv) == NO)
+               exit(1);
+       mustchdir(getcwp());
+       printcd(getcwp());
+       printPROJECT();
+       if (fflag == YES && FILEXIST(PROJECTRC))
+               printrc();
+       if (dflag == YES) printdesc();
+       exit(0);
+}
+
+
+
+/*
+ * mustchdir() must change current working directory or die.
+ */
+void
+mustchdir(pathname)
+       char *pathname;                 /* destination directory */
+{
+       if (!CHDIR(pathname))
+               fatal("permission denied");
+}
+
+
+
+/*
+ * printPROJECT prints PROJECT environment variable value.
+ */
+void
+printPROJECT()
+{
+       char *getcwp();                 /* get current working project */
+
+       if (CSHELL)
+               printf("; setenv PROJECT ");
+       else
+               printf("; export PROJECT; PROJECT=");
+
+       printf("%s", getcwp());
+}
+
+
+
+/*
+ * printcd() prints the "cd" change directory command.
+ */
+void
+printcd(pathname)
+       char *pathname;                 /* pathname of destination directory */
+{
+       printf("cd %s", pathname);
+}
+
+
+
+/*
+ * printrc() prints the PROJECTRC project initialization file execution
+ * request.
+ */
+void
+printrc()
+{
+       if (CSHELL)
+               printf("; source %s", PROJECTRC);
+       else
+               printf("; . %s", PROJECTRC);
+}
+
+
+
+/*
+ * printdesc() prints project description.
+ */
+void
+printdesc()
+{
+       char dirdesc[DIRDESCSIZE];      /* project directory description */
+       char *pbgetstring();            /* get specified string field */
+       int errpdb();                   /* print database error message */
+       int pfndent();                  /* find and load database entry */
+       PDB *openpdb();                 /* open database */
+       PDB *pldp;                      /* project link directory stream */
+
+       if ((pldp = openpdb(PLDNAME, CURDIR, "r")) == NULL)
+               exit(errpdb((PDB *) NULL));
+       if (pfndent(CURPROJECT, pldp) == NO)
+               fatal("can't find %s alias in %s", CURPROJECT, pldp->path);
+       if (*pbgetstring(PDIRDESC, dirdesc) != '\0')
+               fprintf(stderr, "%s\n", dirdesc);
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/lib/t.Makefile b/usr/src/new/new/spms/src/lib/libhash/lib/t.Makefile
new file mode 100644 (file)
index 0000000..0c230ac
--- /dev/null
@@ -0,0 +1,15 @@
+CFLAGS       = -I../../../../include
+
+LDFLAGS              =
+
+LIBS         = ../../../../lib/libhash.a \
+               ../../../../lib/libspms.a
+
+LINKER       = cc
+
+OBJS         =
+
+PROGRAM              =
+
+$(PROGRAM):     $(OBJS) $(LIBS)
+               @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
diff --git a/usr/src/new/new/spms/src/lib/libhash/src/hthash.c b/usr/src/new/new/spms/src/lib/libhash/src/hthash.c
new file mode 100644 (file)
index 0000000..c811e93
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * hthash() returns a hash value for string, s.
+ */
+#include "hash.h"
+
+hthash(s, hash)
+       register char *s;               /* string */
+       HASH *hash;                     /* hash table */
+{
+       register int hashval;           /* hash value for string */
+
+       for (hashval = 0; *s != '\0'; s++)
+               hashval += *s;
+       return(hashval % hash->hashsiz);
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/src/htinit.c b/usr/src/new/new/spms/src/lib/libhash/src/htinit.c
new file mode 100644 (file)
index 0000000..0bb14ae
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * htinit() returns a pointer to a new hash table, or a null pointer if
+ * out of memory.
+ */
+#include "null.h"
+#include "hash.h"
+
+HASH *
+htinit(hashsiz)
+       unsigned int hashsiz;           /* hash table size */
+{
+       char *calloc();                 /* memory allocator + zero init */
+       char *malloc();                 /* memory allocator */
+       HASH *ht;                       /* pointer to hash table struct */
+       HASHBLK **pt;                   /* pointer to hash pointer table */
+
+       if ((ht = (HASH *) malloc(sizeof(HASH))) == NULL ||
+           (pt = (HASHBLK **) calloc(hashsiz, sizeof(HASHBLK *))) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       ht->hashtab = pt;
+       ht->hashsiz = hashsiz;
+       return(ht);
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/src/htinstall.c b/usr/src/new/new/spms/src/lib/libhash/src/htinstall.c
new file mode 100644 (file)
index 0000000..1a189e9
--- /dev/null
@@ -0,0 +1,46 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * htinstall() installs a new entry in a hash table if it doesn't already
+ * exist. If it does, the old definition and value is superseded. Returns
+ * a pointer to the entry, or null if out of memory.
+ */
+#include "null.h"
+#include "hash.h"
+
+HASHBLK *
+htinstall(key, def, val, hash)
+       char *key;                      /* key for hash table entry */
+       char *def;                      /* definition string */
+       int val;                        /* integer value */
+       HASH *hash;                     /* hash table */
+{
+       char *malloc();                 /* memory allocator */
+       char *strsav();                 /* save string somewhere */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int hashval;                    /* hash value for key */
+       int hthash();                   /* calculate hash value */
+
+       if ((htb = htlookup(key, hash)) == NULL)
+               {                       /* not found */
+               if ((htb = (HASHBLK *) malloc(sizeof(HASHBLK))) == NULL)
+                       return(NULL);
+               if ((htb->h_key = strsav(key)) == NULL)
+                       return(NULL);
+               hashval = hthash(key, hash);
+               htb->h_next = (hash->hashtab)[hashval];
+               (hash->hashtab)[hashval] = htb;
+               }
+       else    {                       /* found */
+               free(htb->h_def);       /* free previous definition */
+               }
+       if ((htb->h_def = strsav(def)) == NULL)
+               return(NULL);
+       htb->h_val = val;
+       return(htb);
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/src/htlookup.c b/usr/src/new/new/spms/src/lib/libhash/src/htlookup.c
new file mode 100644 (file)
index 0000000..f29b559
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * htlookup() returns a pointer to a hash table entry if found, otherwise null.
+ */
+#include "null.h"
+#include "hash.h"
+#include "macro.h"
+
+HASHBLK *
+htlookup(key, hash)
+       char *key;                      /* key for hash table entry */
+       HASH *hash;                     /* hash table */
+{
+       HASHBLK *htb;                   /* hash table entry block */
+       int hthash();                   /* calculate hash value */
+
+       for (htb = (hash->hashtab)[hthash(key, hash)]; htb != NULL; htb = htb->h_next)
+               if (EQUAL(htb->h_key, key))
+                       return(htb);    /* found */
+       return(NULL);                   /* not found */
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/src/htrm.c b/usr/src/new/new/spms/src/lib/libhash/src/htrm.c
new file mode 100644 (file)
index 0000000..5e5c8cd
--- /dev/null
@@ -0,0 +1,95 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+#include "null.h"
+#include "hash.h"
+#include "macro.h"
+
+/*
+ * htrm() removes a hash table entry. If key is null, the entire hash
+ * table is removed.
+ */
+void
+htrm(key, hash)
+       char *key;                      /* key for hash table entry */
+       HASH *hash;                     /* hash table */
+{
+       HASHBLK *htbrm();               /* remove hash table block */
+       HASHBLK *htc;                   /* first hash table block in chain */
+       int hashval;                    /* hash value for key */
+       int hthash();                   /* compute hash value */
+       int i;                          /* hash table index */
+
+       if (key == NULL)
+               {
+               for (i = 0; i < hash->hashsiz; i++)
+                       if ((htc = (hash->hashtab)[i]) != NULL)
+                               htc = htbrm(key, htc);
+               free((char *) hash);
+               }
+       else    {
+               hashval = hthash(key, hash);
+               if ((htc = (hash->hashtab)[hashval]) != NULL)
+                       (hash->hashtab)[hashval] = htbrm(key, htc);
+               }
+}
+
+
+
+/*
+ * htbrm() removes a hash table block identified by key. If key is null, the
+ * entire chain is removed. Returns a pointer to the first block in the chain.
+ */
+HASHBLK *
+htbrm(key, htc)
+       char *key;                      /* key string */
+       HASHBLK *htc;                   /* hash table block chain */
+{
+       HASHBLK *curblk;                /* current list block */
+       HASHBLK *nxtblk;                /* next list block */
+       HASHBLK *prvblk;                /* previous list block */
+
+       if (key == NULL)
+               while (htc != NULL)
+                       {
+                       nxtblk = htc->h_next;
+                       free(htc->h_key);
+                       free(htc->h_def);
+                       free((char *) htc);
+                       htc = nxtblk;
+                       }
+       else    {
+               /* first block is a special case */
+               if (EQUAL(htc->h_key, key))
+                       {
+                       nxtblk = htc->h_next;
+                       free(htc->h_key);
+                       free(htc->h_def);
+                       free((char *) htc);
+                       htc = nxtblk;
+                       }
+               else    {
+                       /* remainder of list */
+                       prvblk = htc;
+                       curblk = htc->h_next;
+                       while (curblk != NULL)
+                               if (EQUAL(curblk->h_key, key))
+                                       {
+                                       prvblk->h_next = curblk->h_next;
+                                       free(curblk->h_key);
+                                       free(curblk->h_def);
+                                       free((char *) curblk);
+                                       curblk = prvblk->h_next;
+                                       break;
+                                       }
+                               else    {
+                                       prvblk = curblk;
+                                       curblk = curblk->h_next;
+                                       }
+                       }
+               }
+       return(htc);
+}
diff --git a/usr/src/new/new/spms/src/lib/libhash/test/htinstall.a b/usr/src/new/new/spms/src/lib/libhash/test/htinstall.a
new file mode 100644 (file)
index 0000000..f2b08b1
--- /dev/null
@@ -0,0 +1,99 @@
+!<arch>
+Ihtinstall      418431878   968   27    100644  404       `
+10th   The             1
+1st    Software        2
+2nd    Project         3
+3rd    Management      4
+4th    System          5
+5th    (SPMS)          6
+6th    is              7
+7th    a               8
+8th    system          9
+9th    for             10
+aaa    management      11
+Aaa    of              12
+BBB    medium          13
+bbb    to              14
+Bbb    large           15
+bbb/   software        16
+bb/    systems.        17
+It     has             18
+been   designed        19
+for    users           20
+with   a               21
+wide   range           22
+of     experience      23
+It     experience      24
+been   range           25
+for    a               26
+with   users           27
+wide   designed        28
+of     has             29
+Ohtinstall      418431878   968   27    100644  384       `
+10th The 1
+1st Software 2
+2nd Project 3
+3rd Management 4
+4th System 5
+5th (SPMS) 6
+6th is 7
+7th a 8
+8th system 9
+9th for 10
+aaa management 11
+Aaa of 12
+BBB medium 13
+bbb to 14
+Bbb large 15
+bbb/ software 16
+bb/ systems. 17
+It has 18
+been designed 19
+for users 20
+with a 21
+wide range 22
+of experience 23
+It experience 24
+been range 25
+for a 26
+with users 27
+wide designed 28
+of has 29
+Thtinstall.c    418431878   968   27    100644  843       `
+/*
+ * htinit()
+ * hthash()
+ * htinstall()
+ * htlookup()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "hash.h"
+
+#define HASHTABLESIZE  227
+#define KEYSIZE                10
+#define STRSIZE                128
+
+char *PGN = "Thtinstall";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char string[STRSIZE];           /* string to be added */
+       HASH *hashtable;                /* pointer to hash table */
+       HASH *htinit();                 /* initialize hash table */
+       HASHBLK *htb;                   /* current hash table block */
+       HASHBLK *htinstall();           /* install hash table entry */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int value;                      /* integer value */
+
+       hashtable = htinit(HASHTABLESIZE);
+       while (scanf("%s%s%d", key, string, &value) != EOF)
+               {
+               htinstall(key, string, value, hashtable);
+               htb = htlookup(key, hashtable);
+               printf ("%s %s %d\n", htb->h_key, htb->h_def, htb->h_val);
+               }
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libhash/test/htrm.a b/usr/src/new/new/spms/src/lib/libhash/test/htrm.a
new file mode 100644 (file)
index 0000000..47dab1a
--- /dev/null
@@ -0,0 +1,117 @@
+!<arch>
+Ihtrm           418431886   968   27    100644  526       `
++10th  The             1
++1st   Software        2
++2nd   Project         3
++3rd   Management      4
++4th   System          5
++5th   (SPMS)          6
++6th   is              7
++7th   a               8
++8th   system          9
++9th   for             10
++aaa   management      11
++Aaa   of              12
++BBB   medium          13
++bbb   to              14
++Bbb   large           15
++bbb/  software        16
++bb/   systems.        17
++It    has             18
++been  designed        19
++for   users           20
++with  a               21
++wide  range           22
++of    experience      23
++It    experience      24
++been  range           25
++for   a               26
++with  users           27
++wide  designed        28
++of    has             29
+-3rd   Management      4
+-Bbb   large           15
+-It    experience      24
+-Aaa   of              12
+?for   users           20
+-for   users           20
+Ohtrm           418431886   968   27    100644  467       `
+10th The 1
+1st Software 2
+2nd Project 3
+3rd Management 4
+4th System 5
+5th (SPMS) 6
+6th is 7
+7th a 8
+8th system 9
+9th for 10
+aaa management 11
+Aaa of 12
+BBB medium 13
+bbb to 14
+Bbb large 15
+bbb/ software 16
+bb/ systems. 17
+It has 18
+been designed 19
+for users 20
+with a 21
+wide range 22
+of experience 23
+It experience 24
+been range 25
+for a 26
+with users 27
+wide designed 28
+of has 29
+3rd: Not found
+Bbb: Not found
+It: Not found
+Aaa: Not found
+for a 26
+for: Not found
+
+Thtrm.c         418431886   968   27    100644  1007      `
+/*
+ * htrm()
+ * htbrm()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "hash.h"
+
+#define HASHTABLESIZE  227
+#define KEYSIZE                10
+#define STRSIZE                128
+
+char *PGN = "Thtrm";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char string[STRSIZE];           /* string to be added */
+       HASH *hashtable;                /* pointer to hash table */
+       HASH *htinit();                 /* initialize hash table */
+       HASHBLK *htb;                   /* current hash table block */
+       HASHBLK *htinstall();           /* install hash table entry */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int value;                      /* integer value */
+       void htrm();                    /* remove hash table entry */
+
+       hashtable = htinit(HASHTABLESIZE);
+       while (scanf("%s%s%d", key, string, &value) != EOF)
+               {
+               if (*key == '+')
+                       htinstall(key+1, string, value, hashtable);
+               else if (*key == '-')
+                       htrm(key+1, hashtable);
+               if ((htb = htlookup(key+1, hashtable)) != NULL)
+                       printf("%s %s %d\n", htb->h_key,htb->h_def,htb->h_val);
+               else
+                       printf("%s: Not found\n", key+1);
+               }
+       htrm(NULL, hashtable);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/lib/t.Makefile b/usr/src/new/new/spms/src/lib/libpdb/lib/t.Makefile
new file mode 100644 (file)
index 0000000..df6c06e
--- /dev/null
@@ -0,0 +1,15 @@
+CFLAGS       = -I../../../../include
+
+LDFLAGS              =
+
+LIBS         = ../../../../lib/libpdb.a \
+               ../../../../lib/libspms.a
+
+LINKER       = cc
+
+OBJS         =
+
+PROGRAM              =
+
+$(PROGRAM):     $(OBJS) $(LIBS)
+               @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/_closepdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/_closepdb.c
new file mode 100644 (file)
index 0000000..481f6f8
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * _closepdb() closes a database without updating. Returns 0 normally, 1
+ * if database error.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+_closepdb(pdbp)
+       PDB *pdbp;                      /* database description pointer */
+{
+       int errpdb();                   /* print database error message */
+       int errstat = 0;                /* database error status */
+
+       fclose(pdbp->fp);
+       if ((pdbp->flag&_PACCESS) == (_PREAD|_PWRITE))
+               {
+               fclose(pdbp->tfp);
+               unlink(pdbp->tpath);
+               }
+       else if ((pdbp->flag&(_PWRITE|_PAPPEND)) != 0)
+               unlink(pdbp->tpath);
+       if ((pdbp->flag&_PERR) != 0)
+               {
+               errpdb(pdbp);
+               errstat = 1;
+               }
+       free((char *) pdbp);
+       return(errstat);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/closepdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/closepdb.c
new file mode 100644 (file)
index 0000000..c853db3
--- /dev/null
@@ -0,0 +1,42 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * closepdb() closes a database Returns 0 normally, 1 if database error.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "system.h"
+
+closepdb(pdbp)
+       PDB *pdbp;                      /* database description pointer */
+{
+       int errpdb();                   /* print database error message */
+       int errstat = 0;                /* database error status */
+
+       fclose(pdbp->fp);
+       if ((pdbp->flag&_PACCESS) == (_PREAD|_PWRITE))
+               {
+               fclose(pdbp->tfp);
+               if ((pdbp->flag&_PERR) == 0 && (pdbp->flag&_PUPDATE) != 0)
+                       {
+                       RENAME(pdbp->tpath, pdbp->path);
+                       }
+               else    {
+                       unlink(pdbp->tpath);
+                       }
+               }
+       else if ((pdbp->flag&(_PWRITE|_PAPPEND)) != 0)
+               unlink(pdbp->tpath);
+       if ((pdbp->flag&_PERR) != 0)
+               {
+               errpdb(pdbp);
+               errstat = 1;
+               }
+       free((char *) pdbp);
+       return(errstat);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/errpdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/errpdb.c
new file mode 100644 (file)
index 0000000..8999c98
--- /dev/null
@@ -0,0 +1,37 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * errpdb() prints the error message in pdbp->err, or ERRPDB if pdbp is
+ * null. Clears error message and returns 1.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+errpdb(pdbp)
+       PDB *pdbp;                      /* database stream */
+{
+       extern char PDBERR[];           /* database error message buffer */
+       extern char *PGN;               /* program name */
+
+       if (pdbp == NULL)
+               {
+               if (*PDBERR != '\0')
+                       {
+                       fprintf(stderr, "%s: %s\n", PGN, PDBERR);
+                       *PDBERR = '\0';
+                       }
+               }
+       else    {
+               if (*pdbp->perr != '\0')
+                       {
+                       fprintf(stderr, "%s: %s\n", PGN, pdbp->perr);
+                       *pdbp->perr = '\0';
+                       }
+               }
+       return(1);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/mustopenpdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/mustopenpdb.c
new file mode 100644 (file)
index 0000000..4c33252
--- /dev/null
@@ -0,0 +1,83 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * mustopenpdb() opens a database in the manner of openpdb(). However, if the
+ * database cannot be accessed, exit(1) is called.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "system.h"
+#include "yesno.h"
+
+PDB *
+mustopenpdb(name, path, mode)
+       char *name;                     /* database name */
+       char *path;                     /* directory pathname to database */
+       register char *mode;            /* mode of access */
+{
+       char *malloc();                 /* memory allocator */
+       char *pathcat();                /* pathname concatenation */
+       char *strcat();                 /* string concatenation */
+       char *strcpy();                 /* string copy */
+       char *strncpy();                /* string copy n characters */
+       char tname[15];                 /* temporary database name */
+       FILE *fopen();                  /* open file */
+       PDB *pdbp;                      /* database stream */
+
+       if ((pdbp = (PDB *) malloc(sizeof(PDB))) == NULL)
+               fatal("out of memory");
+       pathcat(pdbp->path, path, name);
+       if (mode[0]=='r' && mode[1]=='\0')
+               {
+               if ((pdbp->fp = fopen(pdbp->path, mode)) == NULL)
+                       {
+                       pperror(pdbp->path);
+                       exit(1);
+                       }
+               }
+       else if (mode[0]=='w' || mode[0]=='a' || (mode[0]=='r' && mode[1]=='w'))
+               {
+               strncpy(tname, name, 8);
+               tname[8] = '\0';
+               strcat(tname, "_temp");
+               pathcat(pdbp->tpath, path, tname);
+               if (FILEXIST(pdbp->tpath))
+                       fatal("%s temporarily unavailable", pdbp->path);
+               if ((pdbp->fp = fopen(pdbp->path, mode)) == NULL)
+                       {
+                       pperror(pdbp->path);
+                       exit(1);
+                       }
+               if ((pdbp->tfp = fopen(pdbp->tpath, "w")) == NULL)
+                       {
+                       pperror(pdbp->path);
+                       exit(1);
+                       }
+               if (mode[0]=='w' || mode[0]=='a')
+                       fclose(pdbp->tfp);
+               }
+       else
+               fatal("bad mode %s opening %s", mode, pdbp->path);
+       pdbp->flag &= ~(_PACCESS|_PSTAT);
+       switch (*mode)
+               {
+               case 'r':
+                       pdbp->flag |= _PREAD;
+                       if (mode[1] != 'w')
+                               break;
+               case 'w':
+                       pdbp->flag |= _PWRITE;
+                       break;
+               case 'a':
+                       pdbp->flag |= _PAPPEND | _PEOF;
+                       break;
+               }
+       strcpy(pdbp->root, path);
+       return(pdbp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/openpdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/openpdb.c
new file mode 100644 (file)
index 0000000..7d62127
--- /dev/null
@@ -0,0 +1,130 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * openpdb() opens a database named by name located in a directory with
+ * name path and associates a database stream with it. Returns a pointer
+ * which identifies the database stream in subsequent operations. A null
+ * pointer is returned if the database cannot be accessed or is already
+ * open for writing or appending. When writing or appending, a temporary
+ * file with name name_temp is created in the same directory as the database.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "system.h"
+#include "yesno.h"
+
+extern int errno;
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+char PDBERR[PDBERRSIZE];               /* database error message buffer */
+
+PDB *
+openpdb(name, path, mode)
+       char *name;                     /* database name */
+       char *path;                     /* directory pathname to database */
+       register char *mode;            /* mode of access */
+{
+       char *malloc();                 /* memory allocator */
+       char *pathcat();                /* pathname concatenation */
+       char *sprintf();                /* print output to string */
+       char *strcat();                 /* string concatenation */
+       char *strcpy();                 /* string copy */
+       char *strncpy();                /* string copy n characters */
+       char tname[15];                 /* temporary database name */
+       FILE *fopen();                  /* open file */
+       PDB *pdbp;                      /* database stream */
+
+       if ((pdbp = (PDB *) malloc(sizeof(PDB))) == NULL)
+               {
+               sprintf(PDBERR, "out of memory");
+               return(NULL);
+               }
+       pathcat(pdbp->path, path, name);
+       if (mode[0]=='r' && mode[1]=='\0')
+               {
+               if ((pdbp->fp = fopen(pdbp->path, mode)) == NULL)
+                       {
+                       if (errno < sys_nerr)
+                               {
+                               sprintf(PDBERR, "%s: %s", pdbp->path,
+                                       sys_errlist[errno]);
+                               }
+                       else    {
+                               sprintf(PDBERR, "can't open %s", pdbp->path);
+                               }
+                       free((char *) pdbp);
+                       return(NULL);
+                       }
+               }
+       else if (mode[0]=='w' || mode[0]=='a' || (mode[0]=='r' && mode[1]=='w'))
+               {
+               strncpy(tname, name, 8);
+               tname[8] = '\0';
+               strcat(tname, "_temp");
+               pathcat(pdbp->tpath, path, tname);
+               if (FILEXIST(pdbp->tpath))
+                       {
+                       sprintf(PDBERR,"%s temporarily unavailable",pdbp->path);
+                       free((char *) pdbp);
+                       return(NULL);
+                       }
+               if ((pdbp->fp = fopen(pdbp->path, mode)) == NULL)
+                       {
+                       if (errno < sys_nerr)
+                               {
+                               sprintf(PDBERR, "%s: %s", pdbp->path,
+                                       sys_errlist[errno]);
+                               }
+                       else    {
+                               sprintf(PDBERR, "can't open %s", pdbp->path);
+                               }
+                       free((char *) pdbp);
+                       return(NULL);
+                       }
+               if ((pdbp->tfp = fopen(pdbp->tpath, "w")) == NULL)
+                       {
+                       if (errno < sys_nerr)
+                               {
+                               sprintf(PDBERR, "%s: %s", pdbp->path,
+                                       sys_errlist[errno]);
+                               }
+                       else    {
+                               sprintf(PDBERR, "can't open %s", pdbp->path);
+                               }
+                       fclose(pdbp->fp);
+                       free((char *) pdbp);
+                       return(NULL);
+                       }
+               if (mode[0]=='w' || mode[0]=='a')
+                       fclose(pdbp->tfp);
+               }
+       else    {
+               sprintf(PDBERR, "bad mode %s opening %s", mode, pdbp->path);
+               free((char *) pdbp);
+               return(NULL);
+               }
+       pdbp->flag &= ~(_PACCESS|_PSTAT);
+       switch (*mode)
+               {
+               case 'r':
+                       pdbp->flag |= _PREAD;
+                       if (mode[1] != 'w')
+                               break;
+               case 'w':
+                       pdbp->flag |= _PWRITE;
+                       break;
+               case 'a':
+                       pdbp->flag |= _PAPPEND | _PEOF;
+                       break;
+               }
+       strcpy(pdbp->root, path);
+       *pdbp->perr = '\0';
+       return(pdbp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/paddkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/paddkey.c
new file mode 100644 (file)
index 0000000..cb7312e
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * paddkey() adds a newkey to each entry corresponding to key. The entry
+ * is not changed if newkey already exists.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+
+void
+paddkey(key, newkey, pdbp)
+       char *key;                      /* key string */
+       char *newkey;                   /* new key string */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int pbaddkey();                 /* add key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       pbaddkey(newkey);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbaddflag.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbaddflag.c
new file mode 100644 (file)
index 0000000..73b7187
--- /dev/null
@@ -0,0 +1,41 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbaddflag() adds a flag to the tail of the buffer. The buffer is not
+ * changed if flag already exists. Returns integer NO if buffer space
+ * exceeded, otherwise YES.
+ */
+#include "pdbuf.h"
+#include "yesno.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+pbaddflag(flag)
+       register char *flag;            /* flag string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+       char *strcpy();                 /* string copy */
+       int pbstretch();                /* stretch buffer */
+
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == flag[0] && bp[1] == flag[1] &&
+                       (bp[2] == _PBFS || bp[2] == '\0'))
+                       return(YES);    /* flag already exists */
+       if (bp == CURPBUF)
+               {
+               *bp++ = _PBFS;          /* prepare virgin buffer */
+               *bp = '\0';
+               }
+       if (pbstretch(bp, 3) == NO)
+               return(NO);
+       bp[0] = flag[0];                /* add flag */
+       bp[1] = flag[1];
+       bp[2] = _PBFS;                  /* add field separator */
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbaddkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbaddkey.c
new file mode 100644 (file)
index 0000000..b86248f
--- /dev/null
@@ -0,0 +1,46 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbaddkey() inserts a key at the head of the buffer. The buffer is not
+ * changed if key already exists. Returns integer NO if buffer exceeded,
+ * otherwise YES.
+ */
+#include "pdbuf.h"
+#include "yesno.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+pbaddkey(key)
+       char *key;                      /* key string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipkey();              /* skip to next key */
+       char *strncpy();                /* copy n characters */
+       int klen;                       /* key string length */
+       int pbcmpkey();                 /* compare keys */
+       int pbstretch();                /* stretch buffer */
+       int strlen();                   /* string length */
+       
+       bp = CURPBUF;
+       while (*bp != _PBFS && *bp != '\0')
+               {
+               if (pbcmpkey(key, bp) == 0)
+                       return(YES);    /* key already exists */
+               bp = pbskipkey(bp);
+               }
+       if (bp == CURPBUF && *bp != _PBFS)
+               {
+               *bp++ = _PBFS;          /* prepare virgin buffer */
+               *bp = '\0';
+               }
+       klen = strlen(key);
+       if (pbstretch(CURPBUF, klen+1) == NO)
+               return(NO);
+       strncpy(CURPBUF, key, klen);    /* insert key */
+       CURPBUF[klen] = _PBKS;          /* add key field separator */
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbaddstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbaddstring.c
new file mode 100644 (file)
index 0000000..d3153ae
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbaddstring() adds an id=string to the tail of the buffer. If id already
+ * exists the corresponding string is replaced. Returns integer NO if
+ * buffer space exceeded, otherwise YES.
+ */
+#include "pdbuf.h"
+#include "yesno.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+pbaddstring(id, string)
+       register char *id;              /* string identifier */
+       char *string;                   /* string argument */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+       char *strcpy();                 /* string copy */
+       char *strncpy();                /* copy n characters */
+       int chgflen;                    /* incremental field length */
+       int flen;                       /* field length */
+       int pbstretch();                /* stretch buffer */
+       int slen;                       /* string length */
+       int strlen();                   /* string length */
+       
+       bp = CURPBUF;
+       slen = strlen(string);
+       chgflen = slen + 4;             /* add id= and field separator */
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == id[0] && bp[1] == id[1] && bp[2] == '=')
+                       {
+                       flen = pblenfield(bp);
+                       chgflen -= (bp[flen]==_PBFS) ? flen+1 : flen;
+                       break;
+                       }
+       if (bp == CURPBUF)
+               {
+               *bp++ = _PBFS;          /* prepare virgin buffer */
+               *bp = '\0';
+               }
+       if (pbstretch(bp, chgflen) == NO)
+               return(NO);
+       bp[0] = id[0];                  /* add id= */
+       bp[1] = id[1];
+       bp[2] = '=';
+       strncpy(bp+3, string, slen);    /* insert string */
+       bp[slen+3] = _PBFS;             /* add field separator */
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbchgkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbchgkey.c
new file mode 100644 (file)
index 0000000..0c9e4e0
--- /dev/null
@@ -0,0 +1,38 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbchgkey() substitutes newkey for oldkey. Returns integer NO if buffer
+ * space exceeded, otherwise YES.
+ */
+#include "null.h"
+#include "pdbuf.h"
+#include "yesno.h"
+
+pbchgkey(oldkey, newkey)
+       char *oldkey;                   /* old key string */
+       char *newkey;                   /* new key string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbfndkey();               /* find key */
+       char *strncpy();                /* copy n characters */
+       int chgklen;                    /* incremental key string length */
+       int newklen;                    /* new key string length */
+       int pbstretch();                /* stretch buffer */
+       int strlen();                   /* string length */
+       
+       if ((bp = pbfndkey(newkey)) != NULL)
+               pbrmkey(oldkey);
+       else if ((bp = pbfndkey(oldkey)) != NULL)
+               {
+               newklen = strlen(newkey);
+               chgklen = newklen - strlen(oldkey);
+               if (pbstretch(bp, chgklen) == NO)
+                       return(NO);
+               strncpy(bp, newkey, newklen);
+               }
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbclear.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbclear.c
new file mode 100644 (file)
index 0000000..5ccc11a
--- /dev/null
@@ -0,0 +1,19 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbclear() clears the current database buffer CURPBUF.
+ */
+extern char *CURPBUF;                  /* current database buffer */
+extern char *FP;                       /* next non-key field */
+extern char *KP;                       /* next key field */
+
+void
+pbclear()
+{
+       CURPBUF[0] = '\0';
+       FP = KP = CURPBUF;
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbcmpfield.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbcmpfield.c
new file mode 100644 (file)
index 0000000..c9c422c
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbcmpfield() compares non-key fields and returns an integer greater than,
+ * equal to, or less than 0, depending on whether field is lexicographically
+ * greater than, equal to, or less than the non-key field pointed to by bp.
+ */
+#include "pdbuf.h"
+
+pbcmpfield(field, bp)
+       register char *field;           /* field string */
+       register char *bp;              /* buffer pointer */
+{
+       for (; *field == *bp && *field != '\0'; field++, bp++)
+               continue;
+       if (*field == '\0' && (*bp == _PBFS || *bp == '\0'))
+               return(0);
+       return(*field - *bp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbcmpkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbcmpkey.c
new file mode 100644 (file)
index 0000000..b6039af
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbcmpkey() compares keys and returns an integer greater than, equal to,
+ * or less than 0, depending on whether key is lexicographically greater
+ * than, equal to, or less than the key field pointed to by bp.
+ */
+#include "pdbuf.h"
+
+pbcmpkey(key, bp)
+       register char *key;             /* key string */
+       register char *bp;              /* buffer pointer */
+{
+       for (; *key == *bp && *key != '\0'; key++, bp++)
+               continue;
+       if (*key == '\0' && (*bp == _PBKS || *bp == _PBFS || *bp == '\0'))
+               return(0);
+       return(*key - *bp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbcpyfield.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbcpyfield.c
new file mode 100644 (file)
index 0000000..a203f3c
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbcpyfield() copies the field pointed to by bp to field. Returns
+ * null-terminated field.
+ */
+#include "pdbuf.h"
+
+char *
+pbcpyfield(field, bp)
+       register char *field;           /* field string */
+       register char *bp;              /* buffer pointer */
+{
+       char *fieldsave;
+
+       fieldsave = field;
+       while (*bp != _PBFS && *bp != '\0')
+               *field++ = *bp++;
+       *field = '\0';
+       return(fieldsave);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbcpykey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbcpykey.c
new file mode 100644 (file)
index 0000000..e93b054
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbcpykey() copies the key field pointed to by bp to key. Returns
+ * null-terminated key.
+ */
+#include "pdbuf.h"
+
+char *
+pbcpykey(key, bp)
+       register char *key;             /* key string */
+       register char *bp;              /* buffer pointer */
+{
+       char *keysave;
+
+       keysave = key;
+       while (*bp != _PBKS && *bp != _PBFS && *bp != '\0')
+               *key++ = *bp++;
+       *key = '\0';
+       return(keysave);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbfndflag.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbfndflag.c
new file mode 100644 (file)
index 0000000..b23b400
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbfndflag() searchs for flag in buffer and returns integer YES if found,
+ * otherwise NO.
+ */
+#include "pdbuf.h"
+#include "yesno.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+pbfndflag(flag)
+       register char *flag;            /* flag string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == flag[0] && bp[1] == flag[1] &&
+                       (bp[2] == _PBFS || bp[2] == '\0'))
+                       return(YES);
+       return(NO);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbfndkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbfndkey.c
new file mode 100644 (file)
index 0000000..1ad53d7
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbfndkey() searchs for key in buffer and returns a pointer to its
+ * location, otherwise null.
+ */
+#include "null.h"
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+char *
+pbfndkey(key)
+       char *key;                      /* key string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipkey();              /* skip to next key */
+       int pbcmpkey();                 /* compare keys */
+       
+       bp = CURPBUF;
+       while (*bp != _PBFS && *bp != '\0')
+               {
+               if (pbcmpkey(key, bp) == 0)
+                       return(bp);
+               bp = pbskipkey(bp);
+               }
+       return(NULL);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbfndstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbfndstring.c
new file mode 100644 (file)
index 0000000..b774058
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbfndstring() searchs for string identified by id in buffer and returns
+ * a pointer to its location, otherwise null.
+ */
+#include "null.h"
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+char *
+pbfndstring(id)
+       register char *id;              /* string identifier */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+       
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == id[0] && bp[1] == id[1] && bp[2] == '=')
+                       return(bp+3);
+       return(NULL);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbgetkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbgetkey.c
new file mode 100644 (file)
index 0000000..6b49cf1
--- /dev/null
@@ -0,0 +1,24 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbgetkey() loads the next key field into key. Returns key or null
+ * character if no more key fields.
+ */
+
+extern char *KP;                       /* next key field */
+
+char *
+pbgetkey(key)
+       char *key;                      /* key string */
+{
+       char *pbcpykey();               /* copy key */
+       char *pbskipkey();              /* skip to next key */
+
+       key = pbcpykey(key, KP);
+       KP = pbskipkey(KP);
+       return(key);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbgetstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbgetstring.c
new file mode 100644 (file)
index 0000000..43f2049
--- /dev/null
@@ -0,0 +1,43 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbgetstring() loads the string identified by id into string. Returns
+ * string or null character if id not found.
+ */
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+char *
+pbgetstring(id, string)
+       register char *id;              /* string identifier */
+       char *string;                   /* string argument */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbcpyfield();             /* copy non-key field */
+
+#ifdef OPTIMIZE
+       for (bp = CURPBUF; *bp != '\0'; bp++)
+               if (*bp == _PBFS)
+                       if (bp[1] == id[0] && bp[2] == id[1] && bp[3] == '=')
+                               {
+                               bp += 4;
+                               break;
+                               }
+#else
+       char *pbskipfield();            /* skip to next non-key field */
+
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == id[0] && bp[1] == id[1] && bp[2] == '=')
+                       {
+                       bp += 3;
+                       break;
+                       }
+#endif
+       return(pbcpyfield(string, bp));
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pblenfield.c b/usr/src/new/new/spms/src/lib/libpdb/src/pblenfield.c
new file mode 100644 (file)
index 0000000..d9e3178
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pblenfield() returns length of field pointed to by buffer pointer bp.
+ */
+#include "pdbuf.h"
+
+pblenfield(bp)
+       register char *bp;              /* buffer pointer */
+{
+       register int n;                 /* length counter */
+
+       for (n = 0; *bp != _PBFS && *bp != '\0'; bp++, n++)
+               continue;
+       return(n);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pblenkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pblenkey.c
new file mode 100644 (file)
index 0000000..75de22f
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pblenkey() returns length of key field pointed to by buffer pointer bp.
+ */
+#include "pdbuf.h"
+
+pblenkey(bp)
+       register char *bp;              /* buffer pointer */
+{
+       register int n;                 /* length counter */
+
+       for (n = 0; *bp != _PBKS && *bp != _PBFS && *bp != '\0'; bp++, n++)
+               continue;
+       return(n);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbrmflag.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbrmflag.c
new file mode 100644 (file)
index 0000000..8dc5166
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbrmflag() removes flag from buffer.
+ */
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+void
+pbrmflag(flag)
+       register char *flag;            /* flag string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+       void pbshrink();                /* shrink buffer */
+
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == flag[0] && bp[1] == flag[1] &&
+                       (bp[2] == ':' || bp[2] == '\0'))
+                       {
+                       if (bp[2] == _PBFS)
+                               pbshrink(bp, 3);
+                       else
+                               pbshrink(bp, 2);
+                       break;
+                       }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbrmkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbrmkey.c
new file mode 100644 (file)
index 0000000..7db2ec4
--- /dev/null
@@ -0,0 +1,38 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbrmkey() removes key from buffer.
+ */
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+void
+pbrmkey(key)
+       char *key;                      /* key string */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipkey();              /* skip key field */
+       int klen;                       /* key string length */
+       int pbcmpkey();                 /* compare keys */
+       int strlen();                   /* string length */
+       void pbshrink();                /* shrink buffer */
+       
+       bp = CURPBUF;
+       klen = strlen(key);
+       while (*bp != _PBFS && *bp != '\0')
+               {
+               if (pbcmpkey(key, bp) == 0)
+                       {
+                       if (bp[klen] == _PBKS)
+                               klen++;
+                       pbshrink(bp, klen);
+                       break;
+                       }
+               bp = pbskipkey(bp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbrmstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbrmstring.c
new file mode 100644 (file)
index 0000000..5879e24
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbrmstring() removes string identified by id from buffer.
+ */
+#include "pdbuf.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+
+void
+pbrmstring(id)
+       register char *id;              /* string identifier */
+{
+       register char *bp;              /* buffer pointer */
+       char *pbskipfield();            /* skip to next non-key field */
+       int flen;                       /* field length */
+       int pblenfield();               /* length of nonm-key field */
+       void pbshrink();                /* shrink buffer */
+       
+       bp = CURPBUF;
+       while (*(bp = pbskipfield(bp)) != '\0')
+               if (bp[0] == id[0] && bp[1] == id[1] && bp[2] == '=')
+                       {
+                       flen = pblenfield(bp);
+                       if (bp[flen] == _PBFS)
+                               flen++;
+                       pbshrink(bp, flen);
+                       break;
+                       }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbshrink.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbshrink.c
new file mode 100644 (file)
index 0000000..953f047
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbshrink() shrinks the buffer by n characters just before the point
+ * marked by buffer pointer bp.
+ */
+void
+pbshrink(bp, n)
+       register char *bp;              /* buffer pointer */
+       int n;                          /* shrink amount */
+{
+       register char *lowerbp;         /* lower roving buffer pointer */
+       register char *upperbp;         /* upper roving buffer pointer */
+       
+       for (upperbp = bp; *upperbp != '\0'; upperbp++)
+               continue;
+       lowerbp = bp + n;
+       if (lowerbp >= upperbp)
+               *bp = '\0';
+       while (lowerbp <= upperbp)
+               *bp++ = *lowerbp++;
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbskipfield.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbskipfield.c
new file mode 100644 (file)
index 0000000..b5c1821
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbskipfield() advances the buffer pointer bp to the next field.
+ */
+#include "pdbuf.h"
+
+char *
+pbskipfield(bp)
+       register char *bp;              /* buffer pointer */
+{
+       while (*bp != _PBFS && *bp != '\0')
+               bp++;
+       if (*bp == _PBFS)
+               bp++;
+       return(bp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbskipkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbskipkey.c
new file mode 100644 (file)
index 0000000..99167c4
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbskipkey() advances the buffer pointer bp to the next key field.
+ */
+#include "pdbuf.h"
+
+char *
+pbskipkey(bp)
+       register char *bp;              /* buffer pointer */
+{
+       while (*bp != _PBKS && *bp != _PBFS && *bp != '\0')
+               bp++;
+       if (*bp == _PBKS)
+               bp++;
+       return(bp);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pbstretch.c b/usr/src/new/new/spms/src/lib/libpdb/src/pbstretch.c
new file mode 100644 (file)
index 0000000..2dc5693
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pbstretch() stretches the buffer by n characters just before the point
+ * marked by buffer pointer bp. Negative n shrinks the buffer by n
+ * characters. Returns integer NO if buffer space exceeded, otherwise YES.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+extern PDB *CURPDB;                    /* current database stream */
+
+pbstretch(bp, n)
+       register char *bp;              /* buffer pointer */
+       int n;                          /* stretch amount */
+{
+       register char *lowerbp;         /* lower roving buffer pointer */
+       register char *upperbp;         /* upper roving buffer pointer */
+       char *sprintf();                /* print output to string */
+       
+       if (n > 0)
+               {
+               for (lowerbp = bp; *lowerbp != '\0'; lowerbp++)
+                       continue;
+               upperbp = lowerbp + n;
+               if (upperbp >= CURPBUF + PBUFSIZE)
+                       {
+                       sprintf(CURPDB->perr, "%s database buffer exceeded",
+                               CURPDB->path);
+                       CURPDB->flag |= _PERR;
+                       return(NO);
+                       }
+               while (lowerbp >= bp)
+                       *upperbp-- = *lowerbp--;
+               }
+       else if (n < 0)
+               {
+               for (upperbp = bp; *upperbp != '\0'; upperbp++)
+                       continue;
+               lowerbp = bp - n;
+               if (lowerbp >= upperbp)
+                       *bp = '\0';
+               while (lowerbp <= upperbp)
+                       *bp++ = *lowerbp++;
+               }
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pchgkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/pchgkey.c
new file mode 100644 (file)
index 0000000..5fc02d5
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pchgkey() substitutes newkey for every occurrence of oldkey in a database.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+void
+pchgkey(oldkey ,newkey, pdbp)
+       char *oldkey;                   /* old key string */
+       char *newkey;                   /* new key string */
+       PDB *pdbp;                      /* database stream */
+{
+       int pbchgkey();                 /* change existing key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               pbchgkey(oldkey, newkey);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pfndent.c b/usr/src/new/new/spms/src/lib/libpdb/src/pfndent.c
new file mode 100644 (file)
index 0000000..93554d9
--- /dev/null
@@ -0,0 +1,40 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pfndent() loads a database entry corresponding to key into the current
+ * working buffer CURPBUF. Database must be open for reading only.
+ * Returns integer YES if key found, otherwise NO.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+pfndent(key, pdbp)
+       char *key;                      /* key string */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       char *sprintf();                /* print output to string */
+       int pgetent();                  /* load next entry into buffer */
+       void rewindpdb();               /* rewind database */
+
+       if ((pdbp->flag&_PERR) != 0)
+               return(NO);
+       if ((pdbp->flag&(_PWRITE|_PAPPEND)) != 0)
+               {
+               sprintf(pdbp->perr, "%s must be read access only", pdbp->path);
+               pdbp->flag |= _PERR;
+               return(NO);
+               }
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               if (pbfndkey(key) != NULL)
+                       return(YES);
+       return(NO);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pgetent.c b/usr/src/new/new/spms/src/lib/libpdb/src/pgetent.c
new file mode 100644 (file)
index 0000000..f30a86f
--- /dev/null
@@ -0,0 +1,41 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pgetent() loads next database entry into buffer pdbp->pbuf. Also resets
+ * buffer pointers and makes pdbp the current working database CURPDB.
+ * Returns length of entry or EOF.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *CURPBUF;                         /* current database buffer */
+char *FP;                              /* next non-key field */
+char *KP;                              /* next key field */
+PDB *CURPDB;                           /* current database stream */
+
+pgetent(pdbp)
+       register PDB *pdbp;             /* database stream */
+{
+       register char *bp;              /* buffer pointer */
+       register int c;                 /* next character */
+
+       if ((pdbp->flag&_PREAD) == 0 || (pdbp->flag&(_PEOF|_PERR)) != 0)
+               return(EOF);
+       CURPDB = pdbp;
+       CURPBUF = FP = KP = bp = pdbp->pbuf;
+       while ((c = getc(pdbp->fp)) != EOF && c != '\n')
+               *bp++ = c;
+       *bp = '\0';
+       if (c == EOF)
+               {
+               pdbp->flag |= _PEOF;
+               return(EOF);
+               }
+       else
+               return(bp - pdbp->pbuf);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pputent.c b/usr/src/new/new/spms/src/lib/libpdb/src/pputent.c
new file mode 100644 (file)
index 0000000..4e17aa4
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pputent() writes buffer pdbp->pbuf to a database. Returns integer NO if
+ * write error or buffer exceeded, otherwise YES.
+ */ 
+#include "stdio.h"
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+pputent(pdbp)
+       register PDB *pdbp;             /* database stream */
+{
+       register char *bp;              /* buffer pointer */
+       register FILE *fp;              /* file stream */
+       register int i;                 /* buffer counter */
+       char *sprintf();                /* print output to string */
+
+       if ((pdbp->flag&_PERR) != 0)
+               return(NO);
+       if ((pdbp->flag&_PACCESS) == (_PREAD|_PWRITE))
+               fp = pdbp->tfp;
+       else if ((pdbp->flag&(_PWRITE|_PAPPEND)) != 0)
+               fp = pdbp->fp;
+       else    {
+               sprintf(pdbp->perr, "%s read access only", pdbp->path);
+               pdbp->flag |= _PERR;
+               return(NO);
+               }
+       i = 0;
+       bp = pdbp->pbuf;
+       pdbp->flag |= _PUPDATE;
+
+       while (i < PBUFSIZE && *bp++ != '\0')
+               putc(pdbp->pbuf[i++], fp);
+       if (putc('\n', fp) == EOF)
+               {
+               sprintf(pdbp->perr, "%s write error", pdbp->path);
+               pdbp->flag |= _PERR;
+               return(NO);
+               }
+       if (i >= PBUFSIZE)
+               {
+               sprintf(pdbp->perr, "%s database buffer exceeded", pdbp->path);
+               pdbp->flag |= _PERR;
+               return(NO);
+               }
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pputflag.c b/usr/src/new/new/spms/src/lib/libpdb/src/pputflag.c
new file mode 100644 (file)
index 0000000..97dc646
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pputflag() adds flag to each entry corresponding to key. The entry is
+ * not changed if flag already exists. If key not found, a new entry
+ * is added to the database.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+void
+pputflag(key, flag, pdbp)
+       char *key;                      /* key string */
+       char *flag;                     /* flag string */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int foundkey;                   /* found key flag */
+       int pbaddflag();                /* add flag field */
+       int pbaddkey();                 /* add key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void pbclear();                 /* clear buffer */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       foundkey = NO;
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       {               /* key exists */
+                       pbaddflag(flag);
+                       foundkey = YES;
+                       }
+               pputent(pdbp);
+               }
+       if (foundkey == NO)
+               {                       /* new entry */
+               pbclear();
+               pbaddkey(key);
+               pbaddflag(flag);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/pputstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/pputstring.c
new file mode 100644 (file)
index 0000000..cfd4f30
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pputstring() adds id=string to each entry corresponding to key. If id
+ * already exists, the corresponding string is replaced by string. If
+ * key not found, a new entry is added to the database.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+void
+pputstring(key, id, string, pdbp)
+       char *key;                      /* key string */
+       char *id;                       /* string identifier */
+       char *string;                   /* string argument */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int foundkey;                   /* found key flag */
+       int pbaddkey();                 /* add key */
+       int pbaddstring();              /* add string field */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void pbclear();                 /* clear buffer */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       foundkey = NO;
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       {               /* key exists */
+                       pbaddstring(id, string);
+                       foundkey = YES;
+                       }
+               pputent(pdbp);
+               }
+       if (foundkey == NO)
+               {                       /* new entry */
+               pbclear();
+               pbaddkey(key);
+               pbaddstring(id, string);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/prment.c b/usr/src/new/new/spms/src/lib/libpdb/src/prment.c
new file mode 100644 (file)
index 0000000..cc13543
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * prment() removes database entries corresponding to key.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+
+void
+prment(key, pdbp)
+       char *key;                      /* key string */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       continue;
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/prmflag.c b/usr/src/new/new/spms/src/lib/libpdb/src/prmflag.c
new file mode 100644 (file)
index 0000000..421a1a7
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * prmflag() removes flag from each entry corresponding to key.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+
+void
+prmflag(key, flag, pdbp)
+       char *key;                      /* key string */
+       char *flag;                     /* flag string */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void pbrmflag();                /* remove flag field */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       pbrmflag(flag);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/prmkey.c b/usr/src/new/new/spms/src/lib/libpdb/src/prmkey.c
new file mode 100644 (file)
index 0000000..2145ec4
--- /dev/null
@@ -0,0 +1,30 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * prmkey() removes each instance of key in a database.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+void
+prmkey(key, pdbp)
+       char *key;                      /* key string */
+       PDB *pdbp;                      /* database stream */
+{
+       int pgetent();                  /* loasd next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void pbrmkey();                 /* remove key */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               pbrmkey(key);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/prmstring.c b/usr/src/new/new/spms/src/lib/libpdb/src/prmstring.c
new file mode 100644 (file)
index 0000000..bcb1a5e
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * prmstring() removes id=string from each entry corresponding to key.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+
+void
+prmstring(key, id, pdbp)
+       char *key;                      /* key string */
+       char *id;                       /* string identifier */
+       PDB *pdbp;                      /* database stream */
+{
+       char *pbfndkey();               /* find key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       void pbrmstring();              /* remove string field */
+       void rewindpdb();               /* rewind database */
+
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               if (pbfndkey(key) != NULL)
+                       pbrmstring(id);
+               pputent(pdbp);
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/resetpdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/resetpdb.c
new file mode 100644 (file)
index 0000000..c71912a
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * resetpdb() resets the current database stream CURPDB to pdbp. Also
+ * resets buffer pointers.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+extern char *FP;                       /* next non-key field */
+extern char *KP;                       /* next key field */
+extern PDB *CURPDB;                    /* current database stream */
+
+void
+resetpdb(pdbp)
+       PDB *pdbp;                      /* database stream */
+{
+       CURPDB = pdbp;
+       CURPBUF = FP = KP = pdbp->pbuf;
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/src/rewindpdb.c b/usr/src/new/new/spms/src/lib/libpdb/src/rewindpdb.c
new file mode 100644 (file)
index 0000000..ae28581
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * rewindpdb() rewinds a database unless it has been opened for writing
+ * or appending only.
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "system.h"
+
+void
+rewindpdb(pdbp)
+       PDB *pdbp;                      /* database stream */
+{
+       FILE *fopen();                  /* open file stream */
+
+       if ((pdbp->flag&_PREAD) == 0 || (pdbp->flag&_PERR) != 0)
+               return;
+       if ((pdbp->flag&_PACCESS) == (_PREAD|_PWRITE) && (pdbp->flag&_PUPDATE) != 0)
+               {
+               fclose(pdbp->fp);
+               fclose(pdbp->tfp);
+               RENAME(pdbp->tpath, pdbp->path);
+               pdbp->fp = fopen(pdbp->path, "r");
+               pdbp->tfp = fopen(pdbp->tpath, "w");
+               }
+       else
+               rewind(pdbp->fp);
+       pdbp->flag &= ~(_PUPDATE|_PEOF);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/_closepdb.a b/usr/src/new/new/spms/src/lib/libpdb/test/_closepdb.a
new file mode 100644 (file)
index 0000000..21bbb7c
--- /dev/null
@@ -0,0 +1,74 @@
+!<arch>
+I_closepdb      418697924   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+O_closepdb      418697924   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+T_closepdb.c    418697926   968   27    100644  713       `
+/*
+ * _closepdb()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "T_closepdb";              /* program name */
+
+main()
+{
+       int _closepdb();                /* close database */
+       int i;                          /* input case counter */
+       int pbaddkey();                 /* add key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       for (i = 1; pgetent(pdbp) != EOF; i++)
+               {
+               switch (i)
+                       {
+                       case 4: pbaddkey("new");
+                               break;
+                       case 7: pbaddkey("new");
+                               break;
+                       }
+               pputent(pdbp);
+               }
+       _closepdb(pdbp);
+       exit(0);
+}
+
+T_closepdb.sh   418870167   968   27    100755  175       `
+#!/bin/csh -f
+#
+# _closepdb()
+#
+cp I_closepdb T_INPUT
+T_closepdb >& ERROR
+cat T_INPUT ERROR | diff - O_closepdb
+set diffstatus = $status
+rm -f T_INPUT ERROR
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/closepdb.a b/usr/src/new/new/spms/src/lib/libpdb/test/closepdb.a
new file mode 100644 (file)
index 0000000..b894679
--- /dev/null
@@ -0,0 +1,88 @@
+!<arch>
+Iclosepdb       418697934   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oclosepdb       418697934   968   27    100644  160       `
+aaa
+bbb|ccc
+ddd|eee:
+new|fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+new|:
+:jjj
+kkk|lll|:lp:lp=andherealso:
+Tclosepdb: ./T_INPUT database buffer exceeded
+Tclosepdb.c     418697937   968   27    100644  1011      `
+/*
+ * closepdb()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tclosepdb";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int i;                          /* input case counter */
+       int keybuf[KEYSIZE];            /* key string buffer */
+       int pbaddkey();                 /* add key */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       /* normal update */
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       for (i = 1; pgetent(pdbp) != EOF; i++)
+               {
+               switch (i)
+                       {
+                       case 4: pbaddkey("new");
+                               break;
+                       case 7: pbaddkey("new");
+                               break;
+                       }
+               pputent(pdbp);
+               }
+       closepdb(pdbp);
+
+       /* update with deliberate error */
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       if (pgetent(pdbp) != EOF)
+               {
+               i = 0;
+               do      {
+                       sprintf(keybuf, "%d", ++i);
+                       } while (pbaddkey(keybuf) == YES);
+               }
+       pputent(pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+
+Tclosepdb.sh    418870169   968   27    100755  171       `
+#!/bin/csh -f
+#
+# closepdb()
+#
+cp Iclosepdb T_INPUT
+Tclosepdb >& ERROR
+cat T_INPUT ERROR | diff - Oclosepdb
+set diffstatus = $status
+rm -f T_INPUT ERROR
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/openpdb.a b/usr/src/new/new/spms/src/lib/libpdb/test/openpdb.a
new file mode 100644 (file)
index 0000000..5fa27e4
--- /dev/null
@@ -0,0 +1,84 @@
+!<arch>
+Iopenpdb        418697949   968   27    100644  0         `
+Oopenpdb        418871194   968   27    100644  240       `
+1
+2
+1
+3
+./Iopenpdb_temp temporary database exists
+Topenpdb: ./Iopenpdb temporarily unavailable
+./Iopenpdb_temp temporary database does not exist
+2
+Topenpdb: ./Iopenpdb temporarily unavailable
+24
+Topenpdb: ./Iopenpdb temporarily unavailable
+Topenpdb.c      418697955   968   27    100644  1735      `
+/*
+ * errpdb()
+ * openpdb()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "system.h"
+#include "yesno.h"
+
+char *PGN = "Topenpdb";                        /* program name */
+char *pdbfile = "Iopenpdb";            /* database */
+
+main()
+{
+       char *strcpy();                 /* string copy */
+       char tempfile[PATHSIZE];        /* temporary database pathname */
+       int errpdb();                   /* print database error message */
+       PDB *openpdb();                 /* open database */
+       PDB *pdbp1;                     /* database stream */
+       PDB *pdbp2;                     /* database stream */
+       PDB *pdbp3;                     /* database stream */
+
+       /* open for reading */
+       if ((pdbp1 = openpdb(pdbfile, ".", "r")) == NULL)
+               errpdb(NULL);
+       printf("%o\n", pdbp1->flag);
+       pdbp2 = openpdb(pdbfile, ".", "w");
+       printf("%o\n", pdbp2->flag);
+       pdbp3 = openpdb(pdbfile, ".", "r");
+       printf("%o\n", pdbp3->flag);
+       closepdb(pdbp1);
+       closepdb(pdbp2);
+       closepdb(pdbp3);
+
+       /* open for updating */
+       if ((pdbp1 = openpdb(pdbfile, ".", "rw")) == NULL)
+               errpdb(NULL);
+       printf("%o\n", pdbp1->flag);
+       strcpy(tempfile, pdbp1->tpath);
+       if (FILEXIST(tempfile) == YES)
+               printf("%s temporary database exists\n", tempfile);
+       fflush(stdout);
+       if ((pdbp2 = openpdb(pdbfile, ".", "rw")) == NULL)
+               errpdb(NULL);
+       closepdb(pdbp1);
+       if (FILEXIST(tempfile) == NO)
+               printf("%s temporary database does not exist\n", tempfile);
+
+       /* open for writing */
+       if ((pdbp1 = openpdb(pdbfile, ".", "w")) == NULL)
+               errpdb(NULL);
+       printf("%o\n", pdbp1->flag);
+       fflush(stdout);
+       if ((pdbp2 = openpdb(pdbfile, ".", "w")) == NULL)
+               errpdb(NULL);
+       closepdb(pdbp1);
+
+       /* open for appending */
+       if ((pdbp1 = openpdb(pdbfile, ".", "a")) == NULL)
+               errpdb(NULL);
+       printf("%o\n", pdbp1->flag);
+       fflush(stdout);
+       if ((pdbp2 = openpdb(pdbfile, ".", "w")) == NULL)
+               errpdb(NULL);
+       closepdb(pdbp1);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/paddkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/paddkey.a
new file mode 100644 (file)
index 0000000..101e334
--- /dev/null
@@ -0,0 +1,58 @@
+!<arch>
+Ipaddkey        418697964   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opaddkey        418697964   968   27    100644  109       `
+aaa
+bbb|ccc
+ddd|eee:
+yyy|fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tpaddkey.c      418697968   968   27    100644  448       `
+/*
+ * paddkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpaddkey";                        /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void paddkey();                 /* add key to specified entries */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       paddkey("fff", "yyy", pdbp);
+       paddkey("zzz", "zzz", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tpaddkey.sh     418870171   968   27    100755  147       `
+#!/bin/csh -f
+#
+# paddkey()
+#
+cp Ipaddkey T_INPUT
+Tpaddkey
+cat T_INPUT |& diff - Opaddkey
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbaddflag.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbaddflag.a
new file mode 100644 (file)
index 0000000..8f71c6a
--- /dev/null
@@ -0,0 +1,49 @@
+!<arch>
+Ipbaddflag      418697979   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbaddflag      418697979   968   27    100644  130       `
+aaalp:
+bbb|ccclp:
+ddd|eee:lp:
+fff:lp=here:id=butnotherelp:
+ggg|lp:
+hhh|iii:lp=andherelp:
+:lp:
+:jjjlp:
+kkk|lll|:lp:lp=andherealso:
+Tpbaddflag.c    418697986   968   27    100644  518       `
+/*
+ * pbaddflag()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbaddflag";              /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pbaddflag();                /* add flag field */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbaddflag", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbaddflag("lp");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbaddkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbaddkey.a
new file mode 100644 (file)
index 0000000..ced4d53
--- /dev/null
@@ -0,0 +1,76 @@
+!<arch>
+Ipbaddkey       418697991   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbaddkey       418697991   968   27    100644  125       `
+aaa
+bbb|ccc
+ddd|eee:
+new|fff:lp=here:id=butnothere
+ggg|
+new|hhh|iii:lp=andhere
+new|:
+jjj|:jjj
+kk|kkk|lll|:lp:lp=andherealso:
+
+Tpbaddkey.c     418697998   968   27    100644  979       `
+/*
+ * pbaddkey()
+ * pbcmpkey()
+ * pbskipkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbaddkey";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int i;                          /* input case counter */
+       int pbaddkey();                 /* add key */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbaddkey", ".", "r");
+       for (i = 1; pgetent(pdbp) != EOF; i++)
+               {
+               switch (i)
+                       {
+                       case 1: pbaddkey("aaa");
+                               break;
+                       case 2: pbaddkey("ccc");
+                               break;
+                       case 3: pbaddkey("eee");
+                               break;
+                       case 4: pbaddkey("new");
+                               break;
+                       case 5: pbaddkey("ggg");
+                               break;
+                       case 6: pbaddkey("hhh");
+                               pbaddkey("new");
+                               pbaddkey("hhh");
+                               break;
+                       case 7: pbaddkey("new");
+                               break;
+                       case 8: pbaddkey("jjj");
+                               break;
+                       case 9: pbaddkey("kk");
+                               break;
+                       }
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbaddstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbaddstring.a
new file mode 100644 (file)
index 0000000..2637081
--- /dev/null
@@ -0,0 +1,52 @@
+!<arch>
+Ipbaddstring    418698004   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbaddstring    418698004   968   27    100644  199       `
+aaalp=new_string:
+bbb|ccclp=new_string:
+ddd|eee:lp=new_string:
+fff:lp=new_string:id=butnothere
+ggg|lp=new_string:
+hhh|iii:lp=new_string:
+:lp=new_string:
+:jjjlp=new_string:
+kkk|lll|:lp:lp=new_string:
+
+Tpbaddstring.c  418698009   968   27    100644  561       `
+/*
+ * pbaddstring()
+ * pbskipfield()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbaddstring";            /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pbaddstring();              /* add string field */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbaddstring", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbaddstring("lp", "new_string");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbchgkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbchgkey.a
new file mode 100644 (file)
index 0000000..d7da60f
--- /dev/null
@@ -0,0 +1,57 @@
+!<arch>
+Ipbchgkey       418698020   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbchgkey       418698020   968   27    100644  101       `
+ccc
+ccc
+eeee|ff:
+hhh:lp=here:id=butnothere
+hhh|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tpbchgkey.c     418698024   968   27    100644  683       `
+/*
+ * pbchgkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbchgkey";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pbchgkey();                 /* change existing key */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbchgkey", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbchgkey("aaa", "bbb");
+               pbchgkey("bbb", "ccc");
+               pbchgkey("ddd", "eeee");
+               pbchgkey("eee", "ff");
+               pbchgkey("fff", "ggg");
+               pbchgkey("ggg", "hhh");
+               pbchgkey("jjj", "kkk");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbclear.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbclear.a
new file mode 100644 (file)
index 0000000..4b795fc
--- /dev/null
@@ -0,0 +1,52 @@
+!<arch>
+Ipbclear        418698031   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbclear        418698031   968   27    100644  80        `
+aaa
+bbb|ccc
+ddd|eee:
+
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+Tpbclear.c      418698037   968   27    100644  571       `
+/*
+ * pbclear()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbclear";                        /* program name */
+
+main()
+{
+       char *pbfndkey();               /* find key */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbclear();                 /* clear buffer */
+       
+       pdbp = mustopenpdb("Ipbclear", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               if(pbfndkey("fff") != NULL)
+                       pbclear();
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbfndflag.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbfndflag.a
new file mode 100644 (file)
index 0000000..a75f948
--- /dev/null
@@ -0,0 +1,42 @@
+!<arch>
+Ipbfndflag      418698044   968   27    100644  111       `
+aaa
+bbb|ccc
+ddd|eee:lp
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere:lp:
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbfndflag      418698044   968   27    100644  62        `
+ddd|eee:lp
+hhh|iii:lp=andhere:lp:
+kkk|lll|:lp:lp=andherealso:
+Tpbfndflag.c    418698050   968   27    100644  542       `
+/*
+ * pbfndflag()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+char *PGN = "Tpbfndflag";              /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pbfndflag();                /* find flag field */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbfndflag", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               if (pbfndflag("lp") == YES)
+                       printf("%s\n", pdbp->pbuf);
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbfndkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbfndkey.a
new file mode 100644 (file)
index 0000000..d786d5a
--- /dev/null
@@ -0,0 +1,40 @@
+!<arch>
+Ipbfndkey       418698058   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbfndkey       418698058   968   27    100644  26        `
+fff:lp=here:id=butnothere
+Tpbfndkey.c     418698066   968   27    100644  515       `
+/*
+ * pbfndkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbfndkey";               /* program name */
+
+main()
+{
+       char *pbfndkey();               /* find key */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbfndkey", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               if (pbfndkey("fff") != NULL)
+                       printf("%s\n", pdbp->pbuf);
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbfndstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbfndstring.a
new file mode 100644 (file)
index 0000000..f4e0cea
--- /dev/null
@@ -0,0 +1,43 @@
+!<arch>
+Ipbfndstring    418698072   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbfndstring    418698072   968   27    100644  40        `
+here:id=butnothere
+andhere
+andherealso:
+Tpbfndstring.c  418698079   968   27    100644  571       `
+/*
+ * pbfndstring()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbfndstring";            /* program name */
+
+main()
+{
+       char *bp;                       /* buffer pointer */
+       char *pbfndstring();            /* find string field */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbfndstring", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               if ((bp = pbfndstring("lp")) != NULL)
+                       printf("%s\n", bp);
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbgetkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbgetkey.a
new file mode 100644 (file)
index 0000000..c161a82
--- /dev/null
@@ -0,0 +1,55 @@
+!<arch>
+Ipbgetkey       418698088   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbgetkey       418698088   968   27    100644  44        `
+aaa
+bbb
+ccc
+ddd
+eee
+fff
+ggg
+hhh
+iii
+kkk
+lll
+Tpbgetkey.c     418698096   968   27    100644  594       `
+/*
+ * pbcpykey()
+ * pbgetkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tpbgetkey";               /* program name */
+
+main()
+{
+       char key[KEYSIZE];              /* key buffer */
+       char *pbgetkey();               /* get next key */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbgetkey", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               while (*pbgetkey(key) != '\0')
+                       printf("%s\n", key);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbgetstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbgetstring.a
new file mode 100644 (file)
index 0000000..366a51e
--- /dev/null
@@ -0,0 +1,46 @@
+!<arch>
+Ipbgetstring    418698105   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbgetstring    418698105   968   27    100644  25        `
+here
+andhere
+andherealso
+
+Tpbgetstring.c  418698120   968   27    100644  648       `
+/*
+ * pbcpyfield()
+ * pbgetstring()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+#define STRINGSIZE PATHSIZE
+
+char *PGN = "Tpbgetstring";            /* program name */
+
+main()
+{
+       char *pbgetstring();            /* get specified string field */
+       char string[STRINGSIZE];        /* receiving string */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipbgetstring", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               if (*(pbgetstring("lp", string)) != '\0')
+                       printf("%s\n", string);
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pblenkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pblenkey.a
new file mode 100644 (file)
index 0000000..999a4e9
--- /dev/null
@@ -0,0 +1,47 @@
+!<arch>
+Ipblenkey       418698128   968   27    100644  103       `
+aaa
+bbb|ccc
+dd|eee:
+fff:lp=here:id=butnothere
+ggg|
+|iii:lp=andhere
+
+:jjj
+kkkkk|lll|:lp:lp=andherealso:
+
+Opblenkey       418698128   968   27    100644  18        `
+3
+3
+2
+3
+3
+0
+0
+0
+5
+Tpblenkey.c     418698135   968   27    100644  497       `
+/*
+ * pblenkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpblenkey";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pblenkey();                 /* length of key */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipblenkey", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               printf("%d\n", pblenkey(pdbp->pbuf));
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbrmflag.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbrmflag.a
new file mode 100644 (file)
index 0000000..94e3c05
--- /dev/null
@@ -0,0 +1,51 @@
+!<arch>
+Ipbrmflag       418698147   968   27    100644  111       `
+aaa
+bbb|ccc
+ddd|eee:lp
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere:lp:
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbrmflag       418698147   968   27    100644  103       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere:
+
+:jjj
+kkk|lll|:lp=andherealso:
+
+Tpbrmflag.c     418698153   968   27    100644  517       `
+/*
+ * pbrmflag()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbrmflag";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbrmflag();                /* remove flag field */
+       
+       pdbp = mustopenpdb("Ipbrmflag", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbrmflag("lp");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbrmkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbrmkey.a
new file mode 100644 (file)
index 0000000..62df82b
--- /dev/null
@@ -0,0 +1,57 @@
+!<arch>
+Ipbrmkey        418698165   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbrmkey        418698166   968   27    100644  91        `
+
+ccc
+ddd|:
+fff:lp=here:id=butnothere
+
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tpbrmkey.c      418698172   968   27    100644  611       `
+/*
+ * pbrmkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbrmkey";                        /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbrmkey();                 /* remove key */
+       
+       pdbp = mustopenpdb("Ipbrmkey", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbrmkey("aaa");
+               pbrmkey("bbb");
+               pbrmkey("eee");
+               pbrmkey("zzz");
+               pbrmkey("ggg");
+               pbrmkey("k");
+               pbrmkey("");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbrmstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbrmstring.a
new file mode 100644 (file)
index 0000000..c5df439
--- /dev/null
@@ -0,0 +1,51 @@
+!<arch>
+Ipbrmstring     418698184   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbrmstring     418698184   968   27    100644  72        `
+aaa
+bbb|ccc
+ddd|eee:
+fff:id=butnothere
+ggg|
+hhh|iii:
+
+:jjj
+kkk|lll|:lp:
+Tpbrmstring.c   418698190   968   27    100644  545       `
+/*
+ * pblenfield()
+ * pbrmstring()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpbrmstring";             /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbrmstring();              /* remove string field */
+       
+       pdbp = mustopenpdb("Ipbrmstring", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbrmstring("lp");
+               printf("%s\n", pdbp->pbuf);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pbstretch.a b/usr/src/new/new/spms/src/lib/libpdb/test/pbstretch.a
new file mode 100644 (file)
index 0000000..0520856
--- /dev/null
@@ -0,0 +1,73 @@
+!<arch>
+Ipbstretch      418698197   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opbstretch      418871361   968   27    100644  260       `
+aaaaaa
+bbbbbb|ccc
+dddddd|eee:
+ffffff:lp=here:id=butnothere
+gggggg|
+hhhhhh|iii:lp=andhere
+
+:jj:jjj
+kkkkkk|lll|:lp:lp=andherealso:
+
+|ccc
+|eee:
+:lp=here:id=butnothere
+|
+|iii:lp=andhere
+
+j
+|lll|:lp:lp=andherealso:
+Tpbstretch: ./Ipbstretch database buffer exceeded
+Tpbstretch.c    418698205   968   27    100644  831       `
+/*
+ * pbshrink()
+ * pbstretch()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+extern char *CURPBUF;                  /* current database buffer */
+char *PGN = "Tpbstretch";              /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pbstretch();                /* stretch buffer */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbshrink();                /* shrink buffer */
+       
+       pdbp = mustopenpdb("Ipbstretch", ".", "r");
+       while (pgetent(pdbp) != EOF)
+               {
+               pbstretch(CURPBUF, 3);
+               printf("%s\n", pdbp->pbuf);
+               }
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               {
+               pbshrink(CURPBUF, 3);
+               printf("%s\n", pdbp->pbuf);
+               }
+       fflush(stdout);
+       rewindpdb(pdbp);
+       if (pgetent(pdbp) != EOF)
+               pbstretch(CURPBUF, 2048);
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pchgkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/pchgkey.a
new file mode 100644 (file)
index 0000000..72d8701
--- /dev/null
@@ -0,0 +1,58 @@
+!<arch>
+Ipchgkey        418698214   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opchgkey        418698215   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+yyy:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tpchgkey.c      418698220   968   27    100644  440       `
+/*
+ * pchgkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpchgkey";                        /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pbchgkey();                /* change specified key */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       pchgkey("fff", "yyy", pdbp);
+       pchgkey("zzz", "zzz", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tpchgkey.sh     418870183   968   27    100755  147       `
+#!/bin/csh -f
+#
+# pchgkey()
+#
+cp Ipchgkey T_INPUT
+Tpchgkey
+cat T_INPUT |& diff - Opchgkey
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pfndent.a b/usr/src/new/new/spms/src/lib/libpdb/test/pfndent.a
new file mode 100644 (file)
index 0000000..cf0eecb
--- /dev/null
@@ -0,0 +1,46 @@
+!<arch>
+Ipfndent        418698232   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opfndent        418871389   968   27    100644  72        `
+fff:lp=here:id=butnothere
+Tpfndent: ./Ipfndent must be read access only
+Tpfndent.c      418698238   968   27    100644  676       `
+/*
+ * pfndent()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+char *PGN = "Tpfndent";                        /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pfndent();                  /* find and load database entry */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       
+       pdbp = mustopenpdb("Ipfndent", ".", "r");
+       if (pfndent("fff", pdbp) == YES)
+               printf("%s\n", pdbp->pbuf);
+       closepdb(pdbp);
+       fflush(stdout);
+       pdbp = mustopenpdb("Ipfndent", ".", "rw");
+       if (pfndent("fff", pdbp) == YES)
+               printf("%s\n", pdbp->pbuf);
+       if (pfndent("fff", pdbp) == YES)
+               printf("%s\n", pdbp->pbuf);
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pgetent.a b/usr/src/new/new/spms/src/lib/libpdb/test/pgetent.a
new file mode 100644 (file)
index 0000000..6dc9d26
--- /dev/null
@@ -0,0 +1,84 @@
+!<arch>
+Ipgetent        418698250   968   27    100644  77        `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+
+Opgetent        418698250   968   27    100644  125       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+1 2
+21 12
+Tpgetent: ./T_OUTPUT read access only
+
+Tpgetent.c      418698256   968   27    100644  1054      `
+/*
+ * mustopenpdb()
+ * pgetent()
+ * pputent()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpgetent";                        /* program name */
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       char *strcpy();                 /* string copy */
+       int closepdb();                 /* close database */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       PDB *mustopenpdb();             /* must open database */
+       PDB *ipdbp;                     /* input database stream */
+       PDB *opdbp;                     /* output database stream */
+
+       ipdbp = mustopenpdb(argv[1], ".", "r");
+       opdbp = mustopenpdb(argv[2], ".", "w");
+       printf("%o %o\n", ipdbp->flag, opdbp->flag);
+       while (pgetent(ipdbp) != EOF) 
+               {
+               strcpy(opdbp->pbuf, ipdbp->pbuf);
+               pputent(opdbp);
+               }
+       printf("%o %o\n", ipdbp->flag, opdbp->flag);
+       fflush(stdout);
+       closepdb(ipdbp);
+       closepdb(opdbp);
+
+       ipdbp = mustopenpdb(argv[1], ".", "r");
+       opdbp = mustopenpdb(argv[2], ".", "r");
+       while (pgetent(ipdbp) != EOF) 
+               {
+               strcpy(opdbp->pbuf, ipdbp->pbuf);
+               pputent(opdbp);
+               }
+       closepdb(ipdbp);
+       closepdb(opdbp);
+       exit(0);
+}
+Tpgetent.sh     418870186   968   27    100755  198       `
+#!/bin/csh -f
+#
+# mustopenpdb()
+# pgetent()
+# pputent()
+#
+Tpgetent Ipgetent T_OUTPUT >& T_ERROR
+cat T_OUTPUT T_ERROR | diff - Opgetent
+set diffstatus = $status
+rm T_ERROR T_OUTPUT
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pputflag.a b/usr/src/new/new/spms/src/lib/libpdb/test/pputflag.a
new file mode 100644 (file)
index 0000000..88080c2
--- /dev/null
@@ -0,0 +1,67 @@
+!<arch>
+Ipputflag       418698266   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opputflag       418698266   968   27    100644  135       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnotherelp:
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+zzz|:lp:
+fff|:lp:
+zzz|:lp:
+
+Tpputflag.c     418698273   968   27    100644  594       `
+/*
+ * pputflag()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpputflag";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pputflag();                /* add or change flags */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       resetpdb(pdbp);
+       pputflag("fff", "lp", pdbp);
+       pputflag("zzz", "lp", pdbp);
+       closepdb(pdbp);
+       pdbp = mustopenpdb("T_OUTPUT", ".", "w");
+       resetpdb(pdbp);
+       pputflag("fff", "lp", pdbp);
+       pputflag("zzz", "lp", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tpputflag.sh    418870189   968   27    100755  169       `
+#!/bin/csh -f
+#
+# pputflag()
+#
+cp Ipputflag T_INPUT
+Tpputflag
+cat T_INPUT T_OUTPUT |& diff - Opputflag
+set diffstatus = $status
+rm -f T_INPUT T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/pputstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/pputstring.a
new file mode 100644 (file)
index 0000000..09c105c
--- /dev/null
@@ -0,0 +1,67 @@
+!<arch>
+Ipputstring     418698288   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Opputstring     418698288   968   27    100644  171       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=new_string:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+zzz|:lp=new_string:
+fff|:lp=new_string:
+zzz|:lp=new_string:
+
+Tpputstring.c   418698295   968   27    100644  666       `
+/*
+ * pputstring()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tpputstring";             /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pputstring();              /* add or change strings */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       resetpdb(pdbp);
+       pputstring("fff", "lp", "new_string", pdbp);
+       pputstring("zzz", "lp", "new_string", pdbp);
+       closepdb(pdbp);
+       pdbp = mustopenpdb("T_OUTPUT", ".", "w");
+       resetpdb(pdbp);
+       pputstring("fff", "lp", "new_string", pdbp);
+       pputstring("zzz", "lp", "new_string", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tpputstring.sh  418870190   968   27    100755  177       `
+#!/bin/csh -f
+#
+# pputstring()
+#
+cp Ipputstring T_INPUT
+Tpputstring
+cat T_INPUT T_OUTPUT |& diff - Opputstring
+set diffstatus = $status
+rm -f T_INPUT T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/prment.a b/usr/src/new/new/spms/src/lib/libpdb/test/prment.a
new file mode 100644 (file)
index 0000000..85b7272
--- /dev/null
@@ -0,0 +1,57 @@
+!<arch>
+Iprment         418698303   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oprment         418698304   968   27    100644  79        `
+aaa
+bbb|ccc
+ddd|eee:
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tprment.c       418698310   968   27    100644  422       `
+/*
+ * prment()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tprment";                 /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void prment();                  /* remove database entry */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       prment("fff", pdbp);
+       prment("fff", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tprment.sh      418870192   968   27    100755  143       `
+#!/bin/csh -f
+#
+# prment()
+#
+cp Iprment T_INPUT
+Tprment
+cat T_INPUT |& diff - Oprment
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/prmflag.a b/usr/src/new/new/spms/src/lib/libpdb/test/prmflag.a
new file mode 100644 (file)
index 0000000..b5ac4ab
--- /dev/null
@@ -0,0 +1,57 @@
+!<arch>
+Iprmflag        418698332   968   27    100644  109       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere:lp:
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oprmflag        418698332   968   27    100644  106       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere:
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+Tprmflag.c      418698340   968   27    100644  430       `
+/*
+ * prmflag()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tprmflag";                        /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void prmflag();                 /* remove flags */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       prmflag("fff", "lp", pdbp);
+       prmflag("fff", "lp", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+Tprmflag.sh     418870194   968   27    100755  147       `
+#!/bin/csh -f
+#
+# prmflag()
+#
+cp Iprmflag T_INPUT
+Tprmflag
+cat T_INPUT |& diff - Oprmflag
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/prmkey.a b/usr/src/new/new/spms/src/lib/libpdb/test/prmkey.a
new file mode 100644 (file)
index 0000000..f38b868
--- /dev/null
@@ -0,0 +1,60 @@
+!<arch>
+Iprmkey         418698360   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oprmkey         418698361   968   27    100644  99        `
+aaa
+bbb|ccc
+ddd|:
+:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tprmkey.c       418698366   968   27    100644  443       `
+/*
+ * prmkey()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tprmkey";                 /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void prmkey();                  /* remove specified key */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       prmkey("eee", pdbp);
+       prmkey("fff", pdbp);
+       prmkey("fff", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+
+Tprmkey.sh      418870196   968   27    100755  143       `
+#!/bin/csh -f
+#
+# prmkey()
+#
+cp Iprmkey T_INPUT
+Tprmkey
+cat T_INPUT |& diff - Oprmkey
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/prmstring.a b/usr/src/new/new/spms/src/lib/libpdb/test/prmstring.a
new file mode 100644 (file)
index 0000000..bf1c220
--- /dev/null
@@ -0,0 +1,59 @@
+!<arch>
+Iprmstring      418698378   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oprmstring      418698378   968   27    100644  97        `
+aaa
+bbb|ccc
+ddd|eee:
+fff:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Tprmstring.c    418698387   968   27    100644  439       `
+/*
+ * prmstring()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Tprmstring";              /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void prmstring();               /* remove string */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       prmstring("fff", "lp", pdbp);
+       prmstring("fff", "lp", pdbp);
+       closepdb(pdbp);
+       exit(0);
+}
+
+Tprmstring.sh   418870198   968   27    100755  155       `
+#!/bin/csh -f
+#
+# prmstring()
+#
+cp Iprmstring T_INPUT
+Tprmstring
+cat T_INPUT |& diff - Oprmstring
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/resetpdb.a b/usr/src/new/new/spms/src/lib/libpdb/test/resetpdb.a
new file mode 100644 (file)
index 0000000..ca71f11
--- /dev/null
@@ -0,0 +1,61 @@
+!<arch>
+Iresetpdb       418698403   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Oresetpdb       418698403   968   27    100644  40        `
+aaa
+bbb
+ddd
+fff
+ggg
+hhh
+iii
+aaa
+hhh
+aaa
+Tresetpdb.c     418698407   968   27    100644  928       `
+/*
+ * resetpdb()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tresetpdb";               /* program name */
+
+main()
+{
+       char keybuf[KEYSIZE];           /* key string buffer */
+       char *pbgetkey();               /* get next key */
+       int closepdb();                 /* close database */
+       int i;                          /* entry counter */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp1;                     /* 1st database stream */
+       PDB *pdbp2;                     /* 2nd database stream */
+       
+       pdbp1 = mustopenpdb("Iresetpdb", ".", "r");
+       pdbp2 = mustopenpdb("Iresetpdb", ".", "r");
+       for (i = 0; i < 6 && pgetent(pdbp1) != EOF; i++)
+               printf("%s\n", pbgetkey(keybuf));
+       printf("%s\n", pbgetkey(keybuf));
+       if (pgetent(pdbp2) != EOF)
+               printf("%s\n", pbgetkey(keybuf));
+       resetpdb(pdbp1);
+       printf("%s\n", pbgetkey(keybuf));
+       resetpdb(pdbp2);
+       printf("%s\n", pbgetkey(keybuf));
+       closepdb(pdbp1);
+       closepdb(pdbp2);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libpdb/test/rewindpdb.a b/usr/src/new/new/spms/src/lib/libpdb/test/rewindpdb.a
new file mode 100644 (file)
index 0000000..3aace3a
--- /dev/null
@@ -0,0 +1,72 @@
+!<arch>
+Irewindpdb      418698411   968   27    100644  105       `
+aaa
+bbb|ccc
+ddd|eee:
+fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+
+:jjj
+kkk|lll|:lp:lp=andherealso:
+
+Orewindpdb      418698411   968   27    100644  114       `
+aaa
+bbb|ccc
+ddd|eee:
+new|fff:lp=here:id=butnothere
+ggg|
+hhh|iii:lp=andhere
+new|:
+:jjj
+kkk|lll|:lp:lp=andherealso:
+Trewindpdb.c    418698416   968   27    100644  778       `
+/*
+ * rewindpdb()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+
+char *PGN = "Trewindpdb";              /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int i;                          /* input case counter */
+       int pgetent();                  /* load next entry into buffer */
+       int pputent();                  /* write buffer to database */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void rewindpdb();               /* rewind database */
+       
+       pdbp = mustopenpdb("T_INPUT", ".", "rw");
+       rewindpdb(pdbp);
+       for (i = 1; pgetent(pdbp) != EOF; i++)
+               {
+               switch (i)
+                       {
+                       case 4: pbaddkey("new");
+                               break;
+                       case 7: pbaddkey("new");
+                               break;
+                       }
+               pputent(pdbp);
+               }
+       rewindpdb(pdbp);
+       while (pgetent(pdbp) != EOF)
+               printf("%s\n", pdbp->pbuf);
+       closepdb(pdbp);
+       exit(0);
+}
+Trewindpdb.sh   418870202   968   27    100755  143       `
+#!/bin/csh -f
+#
+# rewindpdb()
+#
+cp Irewindpdb T_INPUT
+Trewindpdb |& diff - Orewindpdb
+set diffstatus = $status
+rm -f T_INPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/lib/t.Makefile b/usr/src/new/new/spms/src/lib/libslist/lib/t.Makefile
new file mode 100644 (file)
index 0000000..e9b2613
--- /dev/null
@@ -0,0 +1,15 @@
+CFLAGS       = -I../../../../include
+
+LDFLAGS              =
+
+LIBS         = ../../../../lib/libslist.a \
+               ../../../../lib/libspms.a
+
+LINKER       = cc
+
+OBJS         =
+
+PROGRAM              =
+
+$(PROGRAM):     $(OBJS) $(LIBS)
+               @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slappend.c b/usr/src/new/new/spms/src/lib/libslist/src/slappend.c
new file mode 100644 (file)
index 0000000..035c27d
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slappend() saves a null-terminated key string somewhere and inserts a
+ * pointer to the key at the tail of list slist. Returns a pointer to
+ * the somewhere, or a null pointer if out of memory.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+
+char *
+slappend(key, slist)
+       char *key;                      /* key string */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+       SLBLK *slbptr;                  /* pointer to list block */
+       unsigned int klen;              /* key length */
+
+       if (slist == NULL)
+               return(NULL);
+       klen = strlen(key);
+       slist->maxkey = MAX(slist->maxkey, klen);
+       if ((slbptr = (SLBLK *) malloc(sizeof(SLBLK))) == NULL ||
+           (slbptr->key = malloc(klen+1)) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       strcpy(slbptr->key, key);
+       slbptr->next = NULL;
+       if (slist->tail == NULL)
+               slist->head = slist->tail = slbptr;
+       else
+               slist->tail = slist->tail->next = slbptr;
+       slist->nk++;
+       return(slbptr->key);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slget.c b/usr/src/new/new/spms/src/lib/libslist/src/slget.c
new file mode 100644 (file)
index 0000000..da9d5f4
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slget() returns a pointer to the next key in list slist, or null upon
+ * reaching end of list.
+ */
+#include "null.h"
+#include "slist.h"
+
+char *
+slget(slist)
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char *key;                      /* key pointer */
+
+       if (slist->curblk != NULL)
+               {
+               key = slist->curblk->key;       
+               slist->curblk = slist->curblk->next;
+               return(key);
+               }
+       else
+               return(NULL);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slinit.c b/usr/src/new/new/spms/src/lib/libslist/src/slinit.c
new file mode 100644 (file)
index 0000000..8877c79
--- /dev/null
@@ -0,0 +1,29 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slinit() returns a pointer to the head block of a new list, or null
+ * pointer if out of memory.
+ */
+#include "null.h"
+#include "slist.h"
+
+SLIST *
+slinit()
+{
+       char *malloc();                 /* memory allocator */
+       SLIST *slist;                   /* pointer to list head block */
+
+       if ((slist = (SLIST *) malloc(sizeof(SLIST))) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       slist->nk = 0;
+       slist->maxkey = 0;
+       slist->head = slist->curblk = slist->tail = NULL;
+       return(slist);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slpop.c b/usr/src/new/new/spms/src/lib/libslist/src/slpop.c
new file mode 100644 (file)
index 0000000..41875a2
--- /dev/null
@@ -0,0 +1,73 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slpop() removes the (nkey+1)th item from list slist, if item matches key.
+ * If key is null, the item is removed regardless. Keys are numbered
+ * from 0 starting at the head of the list. Integer YES is returned if a
+ * key was popped, otherwise NO.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+slpop(key, nkey, slist)
+       char *key;                      /* key string */
+       int nkey;                       /* number of key to be removed */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       SLBLK *curblk;                  /* current list block */
+       SLBLK *nxtblk;                  /* next list block */
+       SLBLK *prvblk;                  /* previous list block */
+
+       if (nkey < 1)
+               {
+               /* first block is a special case */
+               if (slist->head == NULL)
+                       goto nopop;
+               else if (key != NULL && !EQUAL(slist->head->key, key))
+                       goto nopop;
+               else    {
+                       nxtblk = slist->head->next;
+                       free(slist->head->key);
+                       free((char *) slist->head);
+                       slist->head = nxtblk;
+                       slist->nk--;
+                       }
+               if (slist->head == NULL)
+                       slist->tail = NULL;
+               }
+       else    {
+               /* remainder of list */
+               if (slist->head == NULL)
+                       goto nopop;
+               else    {
+                       prvblk = slist->head;
+                       curblk = slist->head->next;
+                       while (curblk != NULL && --nkey > 0)
+                               {
+                               prvblk = curblk;
+                               curblk = curblk->next;
+                               }
+                       if (curblk == NULL)
+                               goto nopop;
+                       else if (key != NULL && !EQUAL(curblk->key, key))
+                               goto nopop;
+                       else    {
+                               if (curblk == slist->tail)
+                                       slist->tail = prvblk;
+                               prvblk->next = curblk->next;
+                               free(curblk->key);
+                               free((char *) curblk);
+                               slist->nk--;
+                               }
+                       }
+               }
+       return(YES);
+
+nopop: return(NO);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slprepend.c b/usr/src/new/new/spms/src/lib/libslist/src/slprepend.c
new file mode 100644 (file)
index 0000000..60213ed
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slprepend() saves a null-terminated key string somewhere and inserts a
+ * pointer to the key at the head of list slist. Returns a pointer to
+ * the somewhere, or a null pointer if out of memory.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+
+char *
+slprepend(key, slist)
+       char *key;                      /* key string */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+       SLBLK *slbptr;                  /* pointer to list block */
+       unsigned int klen;              /* key length */
+
+       if (slist == NULL)
+               return(NULL);
+       klen = strlen(key);
+       slist->maxkey = MAX(slist->maxkey, klen);
+       if ((slbptr = (SLBLK *) malloc(sizeof(SLBLK))) == NULL ||
+           (slbptr->key = malloc(klen+1)) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       strcpy(slbptr->key, key);
+       if (slist->head == NULL)
+               {
+               slbptr->next = NULL;
+               slist->head = slist->tail = slbptr;
+               }
+       else    {
+               slbptr->next = slist->head;
+               slist->head = slbptr;
+               }
+       slist->nk++;
+       return(slbptr->key);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slprint.c b/usr/src/new/new/spms/src/lib/libslist/src/slprint.c
new file mode 100644 (file)
index 0000000..1a86f20
--- /dev/null
@@ -0,0 +1,92 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slprint() prints a list slist on named output stream. The list is
+ * printed in ncol keys per line with column width colwidth. If tab is
+ * an integer YES, keys will be padded by tabs, otherwise blanks. If
+ * keys are padded by tabs, colwidth should be a multiple of TABSIZE.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+#define TABSIZE 8
+
+static int tabflag;
+
+void
+slprint(ncol, colwidth, tab, stream, slist)
+       int ncol;                       /* number of columns */
+       int colwidth;                   /* maximum column width */
+       int tab;                        /* tab or blank padding */
+       FILE *stream;                   /* output stream */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       int col;                        /* column index */
+       int kc;                         /* key count */
+       int kn;                         /* key number */
+       int lastkn = 1;                 /* last key number */
+       int nlcols;                     /* number of longer columns */
+       int nrows;                      /* maximum number of rows */
+       int row;                        /* row index */
+       SLBLK *curblk;                  /* current list block */
+       void putkey();                  /* put key on stream */
+
+       tabflag = tab;
+
+       nrows = slist->nk/ncol + 1;
+       nlcols = slist->nk % ncol;
+       curblk = slist->head;
+       for (kc=1, row=1; row <= nrows; row++)
+               for (col = 1; col <= ncol && kc <= slist->nk; col++, kc++)
+                       {
+                       if (col <= nlcols)
+                               kn = (nrows*(col-1)) + row;
+                       else
+                               kn = ((nrows-1)*(col-1)) + nlcols + row;
+
+                       if (lastkn > kn)
+                               {
+                               curblk = slist->head;
+                               lastkn = 1;
+                               }
+                       for (; lastkn < kn; lastkn++)
+                               curblk = curblk->next;
+
+                       if (col == ncol || kc == slist->nk)
+                               {
+                               fputs(curblk->key, stream);
+                               putc('\n', stream);
+                               }
+                       else
+                               putkey(curblk->key, colwidth, stream);
+                       }
+}
+
+
+
+/*
+ * Putkey prints a key, left-justified in a field of colwidth characters.
+ * The key is padded on the right by tabs or blanks.
+ */
+static void
+putkey(key, colwidth, stream)
+       char *key;                      /* key string */
+       int colwidth;                   /* maximum column width */
+       FILE *stream;                   /* output stream */
+{
+       while (*key != '\0' && colwidth-- > 0)
+               putc(*key++, stream);
+
+       if (colwidth > 0)
+               if (tabflag == YES)
+                       for (; colwidth > 0; colwidth -= TABSIZE)
+                               putc('\t', stream);
+               else while (colwidth-- > 0)
+                       putc(' ', stream);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slrewind.c b/usr/src/new/new/spms/src/lib/libslist/src/slrewind.c
new file mode 100644 (file)
index 0000000..b398994
--- /dev/null
@@ -0,0 +1,18 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slrewind() resets the current key pointer to the first key in list
+ * slist.
+ */
+#include "slist.h"
+
+void
+slrewind(slist)
+       SLIST *slist;                   /* pointer to list head block */
+{
+       slist->curblk = slist->head;
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slrm.c b/usr/src/new/new/spms/src/lib/libslist/src/slrm.c
new file mode 100644 (file)
index 0000000..01b8773
--- /dev/null
@@ -0,0 +1,72 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slrm() removes all instances of key from list slist. If key is null,
+ * the entire list is removed.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+
+void
+slrm(key, slist)
+       char *key;                      /* key string */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       SLBLK *curblk;                  /* current list block */
+       SLBLK *nxtblk;                  /* next list block */
+       SLBLK *prvblk;                  /* previous list block */
+
+       if (key == NULL)
+               {
+               while (slist->head != NULL)
+                       {
+                       nxtblk = slist->head->next;
+                       free(slist->head->key);
+                       free((char *) slist->head);
+                       slist->head = nxtblk;
+                       }
+               free((char *) slist);
+               }
+       else    {
+               /* first block is a special case */
+               while (slist->head != NULL)
+                       {
+                       if (!EQUAL(slist->head->key, key))
+                               break;
+                       nxtblk = slist->head->next;
+                       free(slist->head->key);
+                       free((char *) slist->head);
+                       slist->head = nxtblk;
+                       slist->nk--;
+                       }
+               if (slist->head == NULL)
+                       slist->tail = NULL;
+
+               /* remainder of list */
+               if (slist->head != NULL)
+                       {
+                       prvblk = slist->head;
+                       curblk = slist->head->next;
+                       while (curblk != NULL)
+                               if (EQUAL(curblk->key, key))
+                                       {
+                                       if (curblk == slist->tail)
+                                               slist->tail = prvblk;
+                                       prvblk->next = curblk->next;
+                                       free(curblk->key);
+                                       free((char *) curblk);
+                                       curblk = prvblk->next;
+                                       slist->nk--;
+                                       }
+                               else    {
+                                       prvblk = curblk;
+                                       curblk = curblk->next;
+                                       }
+                       }
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsappend.c b/usr/src/new/new/spms/src/lib/libslist/src/slsappend.c
new file mode 100644 (file)
index 0000000..d6a6cc5
--- /dev/null
@@ -0,0 +1,51 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsappend() saves null-terminated key + string somewhere and inserts a
+ * pointer to the key at the tail of list slslist. Returns a pointer to
+ * the somewhere, or a null pointer if out of memory.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slslist.h"
+
+char *
+slsappend(key, string, slslist)
+       char *key;                      /* key string */
+       char *string;                   /* non-key string */
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+       SLSBLK *slsbptr;                /* pointer to list block */
+       unsigned int klen;              /* key length */
+       unsigned int slen;              /* string length */
+
+       if (slslist == NULL)
+               return(NULL);
+       klen = strlen(key);
+       slen = strlen(string);
+       slslist->maxkey = MAX(slslist->maxkey, klen);
+       slslist->maxstr = MAX(slslist->maxstr, slen);
+       if ((slsbptr = (SLSBLK *) malloc(sizeof(SLSBLK))) == NULL ||
+           (slsbptr->key = malloc(klen+1)) == NULL ||
+           (slsbptr->string = malloc(slen+1)) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       strcpy(slsbptr->key, key);
+       strcpy(slsbptr->string, string);
+       slsbptr->next = NULL;
+       if (slslist->tail == NULL)
+               slslist->head = slslist->tail = slsbptr;
+       else
+               slslist->tail = slslist->tail->next = slsbptr;
+       slslist->nk++;
+       return(slsbptr->key);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsget.c b/usr/src/new/new/spms/src/lib/libslist/src/slsget.c
new file mode 100644 (file)
index 0000000..b696c64
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsget() returns a pointer to the next block in list slslist, or null
+ * upon reaching end of list.
+ */
+#include "null.h"
+#include "slslist.h"
+
+SLSBLK *
+slsget(slslist)
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       SLSBLK *slsbptr;                /* block pointer */
+
+       if (slslist->curblk != NULL)
+               {
+               slsbptr = slslist->curblk;      
+               slslist->curblk = slslist->curblk->next;
+               return(slsbptr);
+               }
+       else
+               return(NULL);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsinit.c b/usr/src/new/new/spms/src/lib/libslist/src/slsinit.c
new file mode 100644 (file)
index 0000000..852df3a
--- /dev/null
@@ -0,0 +1,29 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsinit() returns a pointer to the head block of a new list, or null
+ * pointer if out of memory.
+ */
+#include "null.h"
+#include "slslist.h"
+
+SLSLIST *
+slsinit()
+{
+       char *malloc();                 /* memory allocator */
+       SLSLIST *slslist;               /* pointer to list head block */
+
+       if ((slslist = (SLSLIST *) malloc(sizeof(SLSLIST))) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       slslist->nk = 0;
+       slslist->maxkey = slslist->maxstr = 0;
+       slslist->head = slslist->curblk = slslist->tail = NULL;
+       return(slslist);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsort.c b/usr/src/new/new/spms/src/lib/libslist/src/slsort.c
new file mode 100644 (file)
index 0000000..d438d88
--- /dev/null
@@ -0,0 +1,62 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsort() sorts list slist according to comparison function compar().
+ * compar() is to be called with two arguments and must return an integer
+ * greater than, equal to, or less than 0, depending on the lexicographic
+ * relationship between the two arguments. Returns integer YES if
+ * successful, otherwise NO if out of memory.
+ */
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+static int (*sscmp)();                 /* string compare function */
+
+slsort(compar, slist)
+       int (*compar)();                /* compare two strings */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char **kp;                      /* pointer to key pointer array */
+       char *malloc();                 /* memory allocator */
+       char **skp;                     /* ptr to start of key ptr array */
+       int comparb();                  /* compare 2 list blocks */
+       SLBLK *curblk;                  /* current list block */
+
+       if (slist->nk <= 0)
+               return(YES);
+       else if ((skp = (char **) malloc((unsigned)slist->nk*sizeof(char *))) == NULL)
+               {
+               warn("out of memory");
+               return(NO);
+               }
+       for (kp = skp, curblk = slist->head; curblk != NULL; kp++, curblk = curblk->next)
+               *kp = curblk->key;
+
+       sscmp = compar;
+       qsort((char *) skp, slist->nk, sizeof(char *), comparb);
+
+       for (kp = skp, curblk = slist->head; curblk != NULL; kp++, curblk = curblk->next)
+               curblk->key = *kp;
+       
+       free((char *) skp);
+       return(YES);
+}
+
+
+
+/*
+ * comparb() compares key strings in 2 list blocks. Returns whatever
+ * sscmp() returns. sscmp() is a string compare function.
+ */
+static int
+comparb(s1, s2)
+       char **s1;                      /* string pointer */
+       char **s2;                      /* string pointer */
+{
+       return(sscmp(*s1, *s2));
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsplice.c b/usr/src/new/new/spms/src/lib/libslist/src/slsplice.c
new file mode 100644 (file)
index 0000000..0f3928b
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+#include "slist.h"
+
+/*
+ * slsplice() splices slist2 to the tail of slist1.
+ */
+void
+slsplice(slist1, slist2)
+       SLIST *slist1;                  /* receiving list */
+       SLIST *slist2;                  /* list to be spliced */
+{
+       if (SLNUM(slist2) > 0)
+               if (SLNUM(slist1) == 0)
+                       {
+                       SLNUM(slist1) = SLNUM(slist2);
+                       slist1->head = slist2->head;
+                       slist1->tail = slist2->tail;
+                       }
+               else    {
+                       SLNUM(slist1) += SLNUM(slist2);
+                       slist1->tail->next = slist2->head;
+                       slist1->tail = slist2->tail;
+                       }
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsprepend.c b/usr/src/new/new/spms/src/lib/libslist/src/slsprepend.c
new file mode 100644 (file)
index 0000000..771119d
--- /dev/null
@@ -0,0 +1,55 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsprepend() saves a null-terminated key + string somewhere and inserts a
+ * pointer to the key at the head of list slslist. Returns a pointer to
+ * the somewhere, or a null pointer if out of memory.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slslist.h"
+
+char *
+slsprepend(key, string, slslist)
+       char *key;                      /* key string */
+       char *string;                   /* non-key string */
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+       SLSBLK *slsbptr;                /* pointer to list block */
+       unsigned int klen;              /* key length */
+       unsigned int slen;              /* string length */
+
+       if (slslist == NULL)
+               return(NULL);
+       klen = strlen(key);
+       slen = strlen(string);
+       slslist->maxkey = MAX(slslist->maxkey, klen);
+       slslist->maxstr = MAX(slslist->maxstr, slen);
+       if ((slsbptr = (SLSBLK *) malloc(sizeof(SLSBLK))) == NULL ||
+           (slsbptr->key = malloc(klen+1)) == NULL ||
+           (slsbptr->string = malloc(slen+1)) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       strcpy(slsbptr->key, key);
+       strcpy(slsbptr->string, string);
+       if (slslist->head == NULL)
+               {
+               slsbptr->next = NULL;
+               slslist->head = slslist->tail = slsbptr;
+               }
+       else    {
+               slsbptr->next = slslist->head;
+               slslist->head = slsbptr;
+               }
+       slslist->nk++;
+       return(slsbptr->key);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsprint.c b/usr/src/new/new/spms/src/lib/libslist/src/slsprint.c
new file mode 100644 (file)
index 0000000..54ae363
--- /dev/null
@@ -0,0 +1,92 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsprint() prints a list slslist on named output stream. The list is
+ * printed in ncol keys per line with column width colwidth. If tab is
+ * an integer YES, keys will be padded by tabs, otherwise blanks. If
+ * keys are padded by tabs, colwidth should be a multiple of TABSIZE.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slslist.h"
+#include "yesno.h"
+
+#define TABSIZE 8
+
+static int tabflag;
+
+void
+slsprint(ncol, colwidth, tab, stream, slslist)
+       int ncol;                       /* number of columns */
+       int colwidth;                   /* maximum column width */
+       int tab;                        /* tab or blank padding */
+       FILE *stream;                   /* output stream */
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       int col;                        /* column index */
+       int kc;                         /* key count */
+       int kn;                         /* key number */
+       int lastkn = 1;                 /* last key number */
+       int nlcols;                     /* number of longer columns */
+       int nrows;                      /* maximum number of rows */
+       int row;                        /* row index */
+       SLSBLK *curblk;                 /* current list block */
+       void putkey();                  /* put key on stream */
+
+       tabflag = tab;
+
+       nrows = slslist->nk/ncol + 1;
+       nlcols = slslist->nk % ncol;
+       curblk = slslist->head;
+       for (kc=1, row=1; row <= nrows; row++)
+               for (col = 1; col <= ncol && kc <= slslist->nk; col++, kc++)
+                       {
+                       if (col <= nlcols)
+                               kn = (nrows*(col-1)) + row;
+                       else
+                               kn = ((nrows-1)*(col-1)) + nlcols + row;
+
+                       if (lastkn > kn)
+                               {
+                               curblk = slslist->head;
+                               lastkn = 1;
+                               }
+                       for (; lastkn < kn; lastkn++)
+                               curblk = curblk->next;
+
+                       if (col == ncol || kc == slslist->nk)
+                               {
+                               fputs(curblk->key, stream);
+                               putc('\n', stream);
+                               }
+                       else
+                               putkey(curblk->key, colwidth, stream);
+                       }
+}
+
+
+
+/*
+ * Putkey prints a key, left-justified in a field of colwidth characters.
+ * The key is padded on the right by tabs or blanks.
+ */
+static void
+putkey(key, colwidth, stream)
+       char *key;                      /* key string */
+       int colwidth;                   /* maximum column width */
+       FILE *stream;                   /* output stream */
+{
+       while (*key != '\0' && colwidth-- > 0)
+               putc(*key++, stream);
+
+       if (colwidth > 0)
+               if (tabflag == YES)
+                       for (; colwidth > 0; colwidth -= TABSIZE)
+                               putc('\t', stream);
+               else while (colwidth-- > 0)
+                       putc(' ', stream);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsrewind.c b/usr/src/new/new/spms/src/lib/libslist/src/slsrewind.c
new file mode 100644 (file)
index 0000000..b686098
--- /dev/null
@@ -0,0 +1,18 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsrewind() resets the current key pointer to the first key in list
+ * slslist.
+ */
+#include "slslist.h"
+
+void
+slsrewind(slslist)
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       slslist->curblk = slslist->head;
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slsrm.c b/usr/src/new/new/spms/src/lib/libslist/src/slsrm.c
new file mode 100644 (file)
index 0000000..2ab86a1
--- /dev/null
@@ -0,0 +1,75 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsrm() removes all instances of key+string from list slslist.
+ * If key is null the entire list is removed.
+ */
+#include "macro.h"
+#include "null.h"
+#include "slslist.h"
+
+void
+slsrm(key, slslist)
+       char *key;                      /* key string */
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       SLSBLK *curblk;                 /* current list block */
+       SLSBLK *nxtblk;                 /* next list block */
+       SLSBLK *prvblk;                 /* previous list block */
+
+       if (key == NULL)
+               {
+               while (slslist->head != NULL)
+                       {
+                       nxtblk = slslist->head->next;
+                       free(slslist->head->key);
+                       free(slslist->head->string);
+                       free((char *) slslist->head);
+                       slslist->head = nxtblk;
+                       }
+               free((char *) slslist);
+               }
+       else    {
+               /* first block is a special case */
+               while (slslist->head != NULL)
+                       {
+                       if (!EQUAL(slslist->head->key, key))
+                               break;
+                       nxtblk = slslist->head->next;
+                       free(slslist->head->key);
+                       free(slslist->head->string);
+                       free((char *) slslist->head);
+                       slslist->head = nxtblk;
+                       slslist->nk--;
+                       }
+               if (slslist->head == NULL)
+                       slslist->tail = NULL;
+
+               /* remainder of list */
+               if (slslist->head != NULL)
+                       {
+                       prvblk = slslist->head;
+                       curblk = slslist->head->next;
+                       while (curblk != NULL)
+                               if (EQUAL(curblk->key, key))
+                                       {
+                                       if (curblk == slslist->tail)
+                                               slslist->tail = prvblk;
+                                       prvblk->next = curblk->next;
+                                       free(curblk->key);
+                                       free(curblk->string);
+                                       free((char *) curblk);
+                                       curblk = prvblk->next;
+                                       slslist->nk--;
+                                       }
+                               else    {
+                                       prvblk = curblk;
+                                       curblk = curblk->next;
+                                       }
+                       }
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/src/slssort.c b/usr/src/new/new/spms/src/lib/libslist/src/slssort.c
new file mode 100644 (file)
index 0000000..6bacc61
--- /dev/null
@@ -0,0 +1,65 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slssort() sorts list slslist according to comparison function compar().
+ * compar() is to be called with two arguments and must return an integer
+ * greater than, equal to, or less than 0, depending on the lexicographic
+ * relationship between the two arguments. Returns integer YES if
+ * successful, otherwise NO if out of memory.
+ */
+#include "null.h"
+#include "slslist.h"
+#include "yesno.h"
+
+static int (*sscmp)();                 /* string compare function */
+
+slssort(compar, slslist)
+       int (*compar)();                /* compare two strings */
+       SLSLIST *slslist;               /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       int bpi;                        /* block pointer array index */
+       int comparb();                  /* compare 2 list blocks */
+       SLSBLK **bp;                    /* pointer to block pointer array */
+       SLSBLK *curblk;                 /* current list block */
+
+       if (slslist->nk <= 0)
+               return(YES);
+       else if ((bp = (SLSBLK **) malloc((unsigned)slslist->nk*sizeof(SLSBLK *)))==NULL)
+               {
+               warn("out of memory");
+               return(NO);
+               }
+       for (bpi=0, curblk=slslist->head; curblk != NULL; bpi++, curblk=curblk->next)
+               bp[bpi] = curblk;
+
+       sscmp = compar;
+       qsort((char *) bp, slslist->nk, sizeof(SLSBLK *), comparb);
+
+       for (bpi=0, curblk=slslist->head=bp[bpi++]; bpi < slslist->nk; bpi++)
+               curblk = curblk->next = bp[bpi];
+       curblk->next = NULL;
+       slslist->tail = curblk;
+       
+       free((char *) bp);
+       return(YES);
+}
+
+
+
+/*
+ * comparb() compares key strings in 2 list blocks. Returns whatever
+ * sscmp() returns. sscmp() is a string compare function.
+ */
+
+static int
+comparb(b1, b2)
+       SLSBLK **b1;                    /* block pointer */
+       SLSBLK **b2;                    /* block pointer */
+{
+       return(sscmp((*b1)->key, (*b2)->key));
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slappend.a b/usr/src/new/new/spms/src/lib/libslist/test/slappend.a
new file mode 100644 (file)
index 0000000..9ab716c
--- /dev/null
@@ -0,0 +1,70 @@
+!<arch>
+Islappend       418431492   968   27    100644  67        `
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+
+
+AAA
+aaa
+Aaa
+BBB
+bbb
+Bbb
+
+Oslappend       418431492   968   27    100644  78        `
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+
+
+AAA
+aaa
+Aaa
+BBB
+bbb
+Bbb
+maxkey = 4
+Tslappend.c     418431492   968   27    100644  604       `
+/*
+ * slappend()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslappend";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slappend();               /* append key */
+       SLBLK *curblk;                  /* current list block */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               slappend(key, slist);
+       for (curblk = slist->head; curblk != NULL; curblk = curblk->next)
+               puts(curblk->key);
+       printf("maxkey = %d\n", slist->maxkey);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slget.a b/usr/src/new/new/spms/src/lib/libslist/test/slget.a
new file mode 100644 (file)
index 0000000..d581279
--- /dev/null
@@ -0,0 +1,73 @@
+!<arch>
+Islget          418431500   968   27    100644  67        `
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+
+
+AAA
+aaa
+Aaa
+BBB
+bbb
+Bbb
+
+Oslget          418431500   968   27    100644  67        `
+Bbb
+bbb
+BBB
+Aaa
+aaa
+AAA
+
+
+9th
+8th
+7th
+6th
+5th
+4th
+3rd
+2nd
+1st
+10th
+
+Tslget.c        418431500   968   27    100644  638       `
+/*
+ * slget()
+ * slrewind()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslget";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *nextkey;                  /* pointer to next key */
+       char *slprepend();              /* prepend key */
+       char *slget();                  /* get next key */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+       void slrewind();                /* rewind list */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               slprepend(key, slist);
+       slrewind(slist);
+       while ((nextkey = slget(slist)) != NULL)
+               puts(nextkey);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slpop.a b/usr/src/new/new/spms/src/lib/libslist/test/slpop.a
new file mode 100644 (file)
index 0000000..449c74f
--- /dev/null
@@ -0,0 +1,131 @@
+!<arch>
+Islpop          418431507   968   27    100644  157       `
+^aaa
+-aaa
+^bbb
+$ccc
+^aaa
+-2*
+-aaa
+-*
+^bbb
+$ccc
+^aaa
+-1*
+-1ccc
+-1*
+-*
+^bbb
+$ccc
+^aaa
+-ccc
+-bbb
+-aaa
+-ccc
+-bbb
+-aaa
+^bbb
+$ccc
+^aaa
+-4ccc
+-0*
+-0bbb
+-1ccc
+-0ccc
+
+Oslpop          418431507   968   27    100644  332       `
+aaa
+empty list
+bbb
+bbb    ccc
+aaa    bbb     ccc
+aaa    bbb
+bbb
+empty list
+bbb
+bbb    ccc
+aaa    bbb     ccc
+aaa    ccc
+aaa
+can't pop
+aaa
+empty list
+bbb
+bbb    ccc
+aaa    bbb     ccc
+can't pop
+aaa    bbb     ccc
+can't pop
+aaa    bbb     ccc
+bbb    ccc
+can't pop
+bbb    ccc
+ccc
+can't pop
+ccc
+bbb    ccc
+bbb    ccc     ccc
+aaa    bbb     ccc     ccc
+can't pop
+aaa    bbb     ccc     ccc
+bbb    ccc     ccc
+ccc    ccc
+ccc
+empty list
+Tslpop.c        418431506   968   27    100644  1180      `
+/*
+ * slpop()
+ */
+#include <ctype.h>
+#include <stdio.h>
+#include "slist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslpop";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *keyp;                     /* pointer to key */
+       char *slappend();               /* append key */
+       char *slprepend();              /* prepend key */
+       int nkey;                       /* key to be popped */
+       int slpop();                    /* pop list item */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+       void slprint();                 /* print list */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               {
+               if (key[0] == '^')
+                       slprepend(key+1, slist);
+               else if (key[0] == '$')
+                       slappend(key+1, slist);
+               else if (key[0] == '-')
+                       {
+                       if (isdigit(key[1]))
+                               {
+                               nkey = key[1] - '0';
+                               keyp = (key[2] == '*') ? NULL : key+2;
+                               if (slpop(keyp, nkey, slist) == NO)
+                                       printf("can't pop\n");
+                               }
+                       else    {
+                               keyp = (key[1] == '*') ? NULL : key+1;
+                               if (slpop(keyp, 0, slist) == NO)
+                                       printf("can't pop\n");
+                               }
+                       }
+               else
+                       fatal("illegal key %s",key);
+               if (slist->nk > 0)
+                       slprint(10, 8, YES, stdout, slist);
+               else
+                       printf("empty list\n");
+               }
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slprepend.a b/usr/src/new/new/spms/src/lib/libslist/test/slprepend.a
new file mode 100644 (file)
index 0000000..a5022b9
--- /dev/null
@@ -0,0 +1,72 @@
+!<arch>
+Islprepend      418431515   968   27    100644  67        `
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+
+
+AAA
+aaa
+Aaa
+BBB
+bbb
+Bbb
+
+Oslprepend      418431515   968   27    100644  78        `
+Bbb
+bbb
+BBB
+Aaa
+aaa
+AAA
+
+
+9th
+8th
+7th
+6th
+5th
+4th
+3rd
+2nd
+1st
+10th
+maxkey = 4
+Tslprepend.c    418431515   968   27    100644  621       `
+/*
+ * slinit()
+ * slprepend()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslprepend";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slprepend();              /* prepend key */
+       SLBLK *curblk;                  /* current list block */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               slprepend(key, slist);
+       for (curblk = slist->head; curblk != NULL; curblk = curblk->next)
+               puts(curblk->key);
+       printf("maxkey = %d\n", slist->maxkey);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slprint.a b/usr/src/new/new/spms/src/lib/libslist/test/slprint.a
new file mode 100644 (file)
index 0000000..6a66383
--- /dev/null
@@ -0,0 +1,59 @@
+!<arch>
+Islprint        418431521   968   27    100644  67        `
+bbb
+aaa
+Bbb
+BBB
+Aaa
+AAA
+9th
+8th
+7th
+6th
+5th
+4th
+3rd
+2nd
+1st
+10th
+
+
+
+Oslprint        418431521   968   27    100644  243       `
+               2nd             6th             AAA             Bbb
+               3rd             7th             Aaa             aaa
+10th           4th             8th             BBB             bbb
+1st            5th             9th
+          1st       4th       6th       8th       AAA       BBB       aaa
+          2nd       5th       7th       9th       Aaa       Bbb       bbb
+10th      3rd
+
+Tslprint.c      418431521   968   27    100644  543       `
+/*
+ * slprint()
+ */
+#include <stdio.h>
+#include "slist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslprint";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slprepend();              /* prepend key */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+       void slprint();                 /* print list */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               slprepend(key, slist);
+       slprint(5, 16, YES, stdout, slist);
+       slprint(8, 10, NO, stdout, slist);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slrm.a b/usr/src/new/new/spms/src/lib/libslist/test/slrm.a
new file mode 100644 (file)
index 0000000..d50736b
--- /dev/null
@@ -0,0 +1,120 @@
+!<arch>
+Islrm           418431530   968   27    100644  155       `
+^aaa
+-aaa
+^bbb
+^aaa
+$ccc
+^aaa
+^bbb
+-aaa
+-ccc
+-bbb
+^aaa
+^bbb
+^bbb
+^aaa
+-aaa
+^aaa
+^aaa
+-bbb
+-aaa
+-aaa
+$ccc
+$ddd
+-ddd
+-ccc
+$ccc
+$ddd
+^aaa
+-ccc
+-ddd
+^aaa
+-aaa
+
+Oslrm           418431530   968   27    100644  294       `
+aaa
+empty list
+bbb
+aaa    bbb
+aaa    bbb     ccc
+aaa    aaa     bbb     ccc
+bbb    aaa     aaa     bbb     ccc
+bbb    bbb     ccc
+bbb    bbb
+empty list
+aaa
+bbb    aaa
+bbb    bbb     aaa
+aaa    bbb     bbb     aaa
+bbb    bbb
+aaa    bbb     bbb
+aaa    aaa     bbb     bbb
+aaa    aaa
+empty list
+empty list
+ccc
+ccc    ddd
+ccc
+empty list
+ccc
+ccc    ddd
+aaa    ccc     ddd
+aaa    ddd
+aaa
+aaa    aaa
+empty list
+Tslrm.c         418431529   968   27    100644  1029      `
+/*
+ * slrm()
+ */
+#include <stdio.h>
+#include "slist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslrm";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slappend();               /* append key */
+       char *slprepend();              /* prepend key */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+       void slprint();                 /* print list */
+       void slrm();                    /* remove list item */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               if (key[0] == '^')
+                       {
+                       slprepend(key+1, slist);
+                       if (slist->nk > 0)
+                               slprint(10, 8, YES, stdout, slist);
+                       else
+                               printf("empty list\n");
+                       }
+               else if (key[0] == '$')
+                       {
+                       slappend(key+1, slist);
+                       if (slist->nk > 0)
+                               slprint(10, 8, YES, stdout, slist);
+                       else
+                               printf("empty list\n");
+                       }
+               else if (key[0] == '-')
+                       {
+                       slrm(key+1, slist);
+                       if (slist->nk > 0)
+                               slprint(10, 8, YES, stdout, slist);
+                       else
+                               printf("empty list\n");
+                       }
+               else
+                       fatal("illegal key %s",key);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsappend.a b/usr/src/new/new/spms/src/lib/libslist/test/slsappend.a
new file mode 100644 (file)
index 0000000..f51ca41
--- /dev/null
@@ -0,0 +1,72 @@
+!<arch>
+Islsappend      418431536   968   27    100644  179       `
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+aaa management
+Aaa of
+BBB medium
+bbb to
+Bbb large
+bbb/ software
+bb/ systems
+
+Oslsappend      418431536   968   27    100644  202       `
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+aaa management
+Aaa of
+BBB medium
+bbb to
+Bbb large
+bbb/ software
+bb/ systems
+maxkey = 4
+maxstr = 10
+Tslsappend.c    418431536   968   27    100644  753       `
+/*
+ * slsappend()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slslist.h"
+
+#define KEYSIZE 10
+#define STRSIZE 128
+
+char *PGN = "Tslsappend";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *slsappend();              /* append key+string */
+       char string[STRSIZE];           /* string to be added */
+       SLSBLK *curblk;                 /* current list block */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+
+       slslist = slsinit();
+       while (scanf("%s%s", key, string) != EOF)
+               slsappend(key, string, slslist);
+       for (curblk = slslist->head; curblk != NULL; curblk = curblk->next)
+               printf("%s %s\n", curblk->key, curblk->string);
+       printf("maxkey = %d\n", slslist->maxkey);
+       printf("maxstr = %d\n", slslist->maxstr);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsget.a b/usr/src/new/new/spms/src/lib/libslist/test/slsget.a
new file mode 100644 (file)
index 0000000..8f937c0
--- /dev/null
@@ -0,0 +1,73 @@
+!<arch>
+Islsget         418431544   968   27    100644  179       `
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+aaa management
+Aaa of
+BBB medium
+bbb to
+Bbb large
+bbb/ software
+bb/ systems
+
+Oslsget         418431544   968   27    100644  179       `
+bb/ systems
+bbb/ software
+Bbb large
+bbb to
+BBB medium
+Aaa of
+aaa management
+9th for
+8th system
+7th a
+6th is
+5th (SPMS)
+4th System
+3rd Management
+2nd Project
+1st Software
+10th The
+
+Tslsget.c       418431544   968   27    100644  771       `
+/*
+ * slsget()
+ * slsrewind()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slslist.h"
+
+#define KEYSIZE 10
+#define STRSIZE 128
+
+char *PGN = "Tslsget";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *slsprepend();             /* prepend key+string */
+       char string[STRSIZE];           /* string to be added */
+       SLSBLK *nextblk;                /* pointer to next block */
+       SLSBLK *slsget();               /* get next key+string block */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+       void slsrewind();               /* rewind list */
+
+       slslist = slsinit();
+       while (scanf("%s%s", key, string) != EOF)
+               slsprepend(key, string, slslist);
+       slsrewind(slslist);
+       while ((nextblk = slsget(slslist)) != NULL)
+               printf("%s %s\n", nextblk->key, nextblk->string);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsort.a b/usr/src/new/new/spms/src/lib/libslist/test/slsort.a
new file mode 100644 (file)
index 0000000..4aa443b
--- /dev/null
@@ -0,0 +1,72 @@
+!<arch>
+Islsort         418431551   968   27    100644  67        `
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+
+
+AAA
+aaa
+Aaa
+BBB
+bbb
+Bbb
+
+Oslsort         418431551   968   27    100644  67        `
+
+
+10th
+1st
+2nd
+3rd
+4th
+5th
+6th
+7th
+8th
+9th
+AAA
+Aaa
+BBB
+Bbb
+aaa
+bbb
+
+Tslsort.c       418431550   968   27    100644  658       `
+/*
+ * slsort()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslsort";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slprepend();              /* prepend key */
+       int slsort();                   /* sort list */
+       int strcmp();                   /* compare strings */
+       SLBLK *curblk;                  /* current list block */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist;                   /* pointer to list head block */
+
+       slist = slinit();
+       while (gets(key) != NULL)
+               slprepend(key, slist);
+       slsort(strcmp, slist);
+       for (curblk = slist->head; curblk != NULL; curblk = curblk->next)
+               puts(curblk->key);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsplice.a b/usr/src/new/new/spms/src/lib/libslist/test/slsplice.a
new file mode 100644 (file)
index 0000000..8877ced
--- /dev/null
@@ -0,0 +1,94 @@
+!<arch>
+Islsplice       418431557   968   27    100644  12        `
+aaa
+bbb
+ccc
+Oslsplice       418431557   968   27    100644  118       `
+aaa    bbb     ccc
+aaa    bbb     ccc
+aaa    bbb     ccc     aaa     bbb     ccc
+aaa    bbb     ccc
+empty list
+aaa    bbb     ccc
+empty list
+aaa    bbb     ccc
+aaa    bbb     ccc
+Tslsplice.c     418431557   968   27    100644  1458      `
+/*
+ * slsplice()
+ */
+#include <stdio.h>
+#include "slist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslsplice";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *gets();                   /* get a line from stdin */
+       char *slappend();               /* append key */
+       SLIST *slinit();                /* initialize list */
+       SLIST *slist1;                  /* pointer to list head block */
+       SLIST *slist2;                  /* pointer to list head block */
+       void print();                   /* print list */
+       void slrm();                    /* remove list item */
+       void slsplice();                /* splice two lists */
+
+       /* both lists not empty */
+       slist1 = slinit();
+       slist2 = slinit();
+       while (gets(key) != NULL)
+               {
+               slappend(key, slist1);
+               slappend(key, slist2);
+               }
+       print(slist1);
+       print(slist2);
+       slsplice(slist1, slist2);
+       print(slist1);
+       slrm(NULL, slist1);
+       slrm(NULL, slist2);
+
+       /* one list empty */
+       rewind(stdin);
+       slist1 = slinit();
+       slist2 = slinit();
+       while (gets(key) != NULL)
+               slappend(key, slist1);
+       print(slist1);
+       print(slist2);
+       slsplice(slist1, slist2);
+       print(slist1);
+       slrm(NULL, slist1);
+       slrm(NULL, slist2);
+
+       /* the other list empty */
+       rewind(stdin);
+       slist1 = slinit();
+       slist2 = slinit();
+       while (gets(key) != NULL)
+               slappend(key, slist2);
+       print(slist1);
+       print(slist2);
+       slsplice(slist1, slist2);
+       print(slist1);
+
+       exit(0);
+}
+
+
+
+void
+print(slist)
+       SLIST *slist;                   /* list to be printed */
+{
+       void slprint();                 /* print list */
+
+       if (SLNUM(slist) > 0)
+               slprint(10, 8, YES, stdout, slist);
+       else
+               printf("empty list\n");
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsprepend.a b/usr/src/new/new/spms/src/lib/libslist/test/slsprepend.a
new file mode 100644 (file)
index 0000000..7c88a53
--- /dev/null
@@ -0,0 +1,73 @@
+!<arch>
+Islsprepend     418431568   968   27    100644  179       `
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+aaa management
+Aaa of
+BBB medium
+bbb to
+Bbb large
+bbb/ software
+bb/ systems
+
+Oslsprepend     418431568   968   27    100644  202       `
+bb/ systems
+bbb/ software
+Bbb large
+bbb to
+BBB medium
+Aaa of
+aaa management
+9th for
+8th system
+7th a
+6th is
+5th (SPMS)
+4th System
+3rd Management
+2nd Project
+1st Software
+10th The
+maxkey = 4
+maxstr = 10
+Tslsprepend.c   418431568   968   27    100644  771       `
+/*
+ * slsinit()
+ * slsprepend()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slslist.h"
+
+#define KEYSIZE 10
+#define STRSIZE 128
+
+char *PGN = "Tslsprepend";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *slsprepend();             /* prepend key+string */
+       char string[STRSIZE];           /* string to be added */
+       SLSBLK *curblk;                 /* current list block */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+
+       slslist = slsinit();
+       while (scanf("%s%s", key, string) != EOF)
+               slsprepend(key, string, slslist);
+       for (curblk = slslist->head; curblk != NULL; curblk = curblk->next)
+               printf("%s %s\n", curblk->key, curblk->string);
+       printf("maxkey = %d\n", slslist->maxkey);
+       printf("maxstr = %d\n", slslist->maxstr);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsprint.a b/usr/src/new/new/spms/src/lib/libslist/test/slsprint.a
new file mode 100644 (file)
index 0000000..37207dd
--- /dev/null
@@ -0,0 +1,57 @@
+!<arch>
+Islsprint       418431575   968   27    100644  179       `
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+aaa management
+Aaa of
+BBB medium
+bbb to
+Bbb large
+bbb/ software
+bb/ systems
+
+Oslsprint       418431575   968   27    100644  236       `
+bb/            BBB             8th             5th             2nd
+bbb/           Aaa             7th             4th             1st
+Bbb            aaa             6th             3rd             10th
+bbb            9th
+bb/       bbb       Aaa       9th       7th       5th       3rd       1st
+bbb/      BBB       aaa       8th       6th       4th       2nd       10th
+Bbb
+Tslsprint.c     418431575   968   27    100644  618       `
+/*
+ * slsprint()
+ */
+#include <stdio.h>
+#include "slslist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+#define STRSIZE 128
+
+char *PGN = "Tslsprint";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *slsprepend();             /* prepend key+string */
+       char string[STRSIZE];           /* key to be added */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+       void slsprint();                /* print list */
+
+       slslist = slsinit();
+       while (scanf("%s%s", key, string) != EOF)
+               slsprepend(key, string, slslist);
+       slsprint(5, 16, YES, stdout, slslist);
+       slsprint(8, 10, NO, stdout, slslist);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slsrm.a b/usr/src/new/new/spms/src/lib/libslist/test/slsrm.a
new file mode 100644 (file)
index 0000000..5cfa551
--- /dev/null
@@ -0,0 +1,120 @@
+!<arch>
+Islsrm          418431582   968   27    100644  155       `
+^aaa
+-aaa
+^bbb
+^aaa
+$ccc
+^aaa
+^bbb
+-aaa
+-ccc
+-bbb
+^aaa
+^bbb
+^bbb
+^aaa
+-aaa
+^aaa
+^aaa
+-bbb
+-aaa
+-aaa
+$ccc
+$ddd
+-ddd
+-ccc
+$ccc
+$ddd
+^aaa
+-ccc
+-ddd
+^aaa
+-aaa
+
+Oslsrm          418431582   968   27    100644  294       `
+aaa
+empty list
+bbb
+aaa    bbb
+aaa    bbb     ccc
+aaa    aaa     bbb     ccc
+bbb    aaa     aaa     bbb     ccc
+bbb    bbb     ccc
+bbb    bbb
+empty list
+aaa
+bbb    aaa
+bbb    bbb     aaa
+aaa    bbb     bbb     aaa
+bbb    bbb
+aaa    bbb     bbb
+aaa    aaa     bbb     bbb
+aaa    aaa
+empty list
+empty list
+ccc
+ccc    ddd
+ccc
+empty list
+ccc
+ccc    ddd
+aaa    ccc     ddd
+aaa    ddd
+aaa
+aaa    aaa
+empty list
+Tslsrm.c        418431582   968   27    100644  1091      `
+/*
+ * slsrm()
+ */
+#include <stdio.h>
+#include "slslist.h"
+#include "yesno.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Tslsrm";
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char key[KEYSIZE];              /* key to be added */
+       char *slsappend();              /* append key+string */
+       char *slsprepend();             /* prepend key+string */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+       void slsprint();                /* print list */
+       void slsrm();                   /* remove list item */
+
+       slslist = slsinit();
+       while (gets(key) != NULL)
+               if (key[0] == '^')
+                       {
+                       slsprepend(key+1, "", slslist);
+                       if (slslist->nk > 0)
+                               slsprint(10, 8, YES, stdout, slslist);
+                       else
+                               printf("empty list\n");
+                       }
+               else if (key[0] == '$')
+                       {
+                       slsappend(key+1, "", slslist);
+                       if (slslist->nk > 0)
+                               slsprint(10, 8, YES, stdout, slslist);
+                       else
+                               printf("empty list\n");
+                       }
+               else if (key[0] == '-')
+                       {
+                       slsrm(key+1, slslist);
+                       if (slslist->nk > 0)
+                               slsprint(10, 8, YES, stdout, slslist);
+                       else
+                               printf("empty list\n");
+                       }
+               else
+                       fatal("illegal key %s",key);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libslist/test/slssort.a b/usr/src/new/new/spms/src/lib/libslist/test/slssort.a
new file mode 100644 (file)
index 0000000..608d138
--- /dev/null
@@ -0,0 +1,83 @@
+!<arch>
+Islssort        418431589   968   27    100644  179       `
+bb/ systems
+bbb/ software
+Bbb large
+bbb to
+BBB medium
+Aaa of
+aaa management
+9th for
+8th system
+7th a
+6th is
+5th (SPMS)
+4th System
+3rd Management
+2nd Project
+1st Software
+10th The
+
+Oslssort        418431589   968   27    100644  345       `
+key_2 prepend key_2 internally after sort
+key_1 prepend key_1 internally after sort
+10th The
+1st Software
+2nd Project
+3rd Management
+4th System
+5th (SPMS)
+6th is
+7th a
+8th system
+9th for
+Aaa of
+BBB medium
+Bbb large
+aaa management
+bb/ systems
+bbb to
+bbb/ software
+key_3 append key_3 internally after sort
+key_4 append key_4 internally after sort
+
+Tslssort.c      418431589   968   27    100644  1098      `
+/*
+ * slssort()
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slslist.h"
+
+#define KEYSIZE 10
+#define STRSIZE 128
+
+char *PGN = "Tslssort";
+
+main()
+{
+       char key[KEYSIZE];              /* key to be added */
+       char *slsappend();              /* append key+string */
+       char *slsprepend();             /* prepend key+string */
+       char string[STRSIZE];           /* string to be added */
+       int slssort();                  /* sort list */
+       int strcmp();                   /* compare strings */
+       SLSBLK *curblk;                 /* current list block */
+       SLSLIST *slsinit();             /* initialize list */
+       SLSLIST *slslist;               /* pointer to list head block */
+
+       slslist = slsinit();
+       while (scanf("%s%s", key, string) != EOF)
+               slsprepend(key, string, slslist);
+       slssort(strcmp, slslist);
+       slsprepend("key_1", "prepend key_1 internally after sort", slslist);
+       slsprepend("key_2", "prepend key_2 internally after sort", slslist);
+       slsappend("key_3", "append key_3 internally after sort", slslist);
+       slsappend("key_4", "append key_4 internally after sort", slslist);
+       for (curblk = slslist->head; curblk != NULL;)
+               {
+               printf("%s %s\n", curblk->key, curblk->string);
+               curblk = curblk->next;
+               }
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/lib/... b/usr/src/new/new/spms/src/lib/libspms/lib/...
new file mode 100644 (file)
index 0000000..38671d6
--- /dev/null
@@ -0,0 +1,2 @@
+...|:^^:dp=.:dt=:dd=:
+....|:^^:dp=../../../../../..:
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/argvtos.c b/usr/src/new/new/spms/src/lib/libspms/src/argvtos.c
new file mode 100644 (file)
index 0000000..52efac7
--- /dev/null
@@ -0,0 +1,63 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * argvtos() copies a list of arguments contained in an array of character
+ * strings to a single dynamically allocated string. Each argument is
+ * separated by one blank space. Returns a pointer to the string or null
+ * if out of memory.
+ */
+#include "null.h"
+
+#define SBUFINCR       1024
+#define SBUFMAX                10240
+
+char *
+argvtos(argc, argv)
+       char **argv;
+       int  argc;
+{
+       register char *s;               /* string pointer */
+       register int  i;                /* string buffer pointer */
+       char *malloc();                 /* memory allocator */
+       char *realloc();                /* increase size of storage */
+       char *sbuf;                     /* string buffer */
+       int nbytes;                     /* bytes of memory required */
+       int nu;                         /* no. of SBUFINCR units required */
+       int sbufsize;                   /* current size of sbuf */
+       int strlen();                   /* string length */
+
+       sbufsize = SBUFINCR;
+       if ((sbuf = malloc((unsigned)sbufsize)) == NULL)
+               {
+               warn("out of memory");
+               return(NULL);
+               }
+       
+       for (i = 0; argc-- > 0; ++argv)
+               {
+               if ((nbytes = (i+strlen(*argv)+1-sbufsize)) > 0)
+                       {
+                       nu = (nbytes+SBUFINCR-1)/SBUFINCR;
+                       sbufsize += nu * SBUFINCR;
+                       if (sbufsize > SBUFMAX)
+                               {
+                               warn("command string too long");
+                               return(NULL);
+                               }
+                       if ((sbuf = realloc(sbuf, (unsigned)sbufsize)) == NULL)
+                               {
+                               warn("out of memory");
+                               return(NULL);
+                               }
+                       }
+               for (s = *argv; *s != '\0'; i++, s++)
+                       sbuf[i] = *s;
+               sbuf[i++] = ' ';
+               }
+       sbuf[--i] = '\0';
+       return(sbuf);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/chproject.c b/usr/src/new/new/spms/src/lib/libspms/src/chproject.c
new file mode 100644 (file)
index 0000000..aa428c6
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * chproject() changes the name of the project root directory pathname.
+ * Returns integer YES if successful, otherwise NO.
+ */
+#include "null.h"
+#include "path.h"
+#include "yesno.h"
+
+chproject(ppathname)
+       char *ppathname;                /* new project pathname */
+{
+       extern char *_PROJECT;          /* project root directory pathname */
+       char *strsav();                 /* save a string somewhere */
+       PATH pathbuf;                   /* pathname buffer */
+
+       if (xppath(ppathname, &pathbuf) == -1)
+               {
+               patherr(ppathname);
+               return(NO);
+               }
+       else    {
+               switch (pathbuf.p_mode & P_IFMT)
+                       {
+                       case P_IFNEW:
+                       case P_IFREG:
+                       case P_IFPDIR:
+                               warn("%s: no such project", ppathname);
+                               return(NO);
+                       case P_IFHOME:
+                       case P_IFPROOT:
+                               if (_PROJECT != NULL)
+                                       free(_PROJECT);
+                               if ((_PROJECT = strsav(pathbuf.p_path)) == NULL)
+                                       {
+                                       warn("out of memory");
+                                       return(NO);
+                                       }
+                               break;
+                       }
+               }
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/diff.c b/usr/src/new/new/spms/src/lib/libspms/src/diff.c
new file mode 100644 (file)
index 0000000..907d699
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * diff() compares files and directories via the diff(1) command. Argv is a
+ * pointer to an an array of character strings which contain the names of
+ * the files and/or directories plus flags for diff. The last argument
+ * must be a null pointer. Returns 0 if no differences, 1 if some, 2 if
+ * trouble.
+ */
+#include <sys/param.h>
+#include "bin.h"
+#include "system.h"
+
+diff(argv)
+       char **argv;
+{
+       int pid;                        /* process identity */
+       int status;                     /* child return status */
+       int w;                          /* a child id */
+
+       if ((pid = FORK()) == 0)
+               {
+               execv(DIFF, argv);
+               _exit(2);
+               }
+       while ((w = wait(&status)) != pid && w != -1)
+               continue;
+       status >>= NBBY;
+       status &=  0xff;
+       return(status);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/fatal.c b/usr/src/new/new/spms/src/lib/libspms/src/fatal.c
new file mode 100644 (file)
index 0000000..32cb6ee
--- /dev/null
@@ -0,0 +1,24 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * fatal() places an error message on the standard error output stream
+ * stderr and terminates the process by calling exit(1).
+ */
+#include <stdio.h>
+
+extern char *PGN;                      /* program name */
+
+/* VARARGS1 */
+fatal(fmt, args)
+       char *fmt;
+{
+       if (*PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       _doprnt(fmt, &args, stderr);
+       putc('\n', stderr);
+       exit(1);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getcpd.c b/usr/src/new/new/spms/src/lib/libspms/src/getcpd.c
new file mode 100644 (file)
index 0000000..0d1a5c1
--- /dev/null
@@ -0,0 +1,77 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getcpd() loads a PATH struct with the attributes of the current working
+ * project directory. Don't bother getting  type or description (too slow
+ * at present). Returns -1 on error, 0 if a regular directory, or 1
+ * if a project directory.
+ */
+#include <stdio.h>
+#include "macro.h"
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "pdbuf.h"
+#include "pld.h"
+#include "yesno.h"
+
+getcpd(pb)
+       PATH *pb;                       /* pathname buffer */
+{
+       char cwd[PATHSIZE];             /* current working directory */
+       char *cwp;                      /* current working  project */
+       char *getcwp();                 /* get current working project */
+       char *getwd();                  /* get current working directory */
+       char *mkalias();                /* construct alias from pathname */
+       char *pbfndstring();            /* find string field */
+       char *pbgetkey();               /* get next key */
+       char *relpath;                  /* relative pathname */
+       char *strcpy();                 /* string copy */
+       char *xorpath();                /* remove subpathname */
+       int closepdb();                 /* close database */
+       int pbcmpfield();               /* compare non-key fields */
+       int pbfndflag();                /* find flag field */
+       int pgetent();                  /* load next entry into buffer */
+       PDB *pldp;                      /* project link directory stream */
+       PDB *openpdb();                 /* open database */
+
+       pb->p_alias = pb->p_buf;
+       getwd(cwd);
+       if ((cwp = getcwp()) == NULL)
+               {
+               pb->p_mode = P_IFREG;
+               strcpy(pb->p_alias, mkalias(cwd));
+               pb->p_path = pb->p_alias + strlen(pb->p_alias) + 1;
+               strcpy(pb->p_path, cwd);
+               return(0);
+               }
+       if (EQUAL(cwd, cwp))            /* we are in project root directory */
+               relpath = CURDIR;
+       else
+               relpath = xorpath(cwp, cwd);
+       if ((pldp = openpdb(PLDNAME, cwp, "r")) == NULL)
+               return(-1);
+       while (pgetent(pldp) != EOF)
+               {
+               if (pbcmpfield(relpath, pbfndstring(PDIRPATH)) == 0)
+                       {
+                       if (pbfndflag(PROOTDIR) == YES)
+                               pb->p_mode = P_IFPROOT;
+                       else
+                               pb->p_mode = P_IFPDIR;
+                       pbgetkey(pb->p_alias);
+                       pb->p_path = pb->p_alias + strlen(pb->p_alias) + 1;
+                       strcpy(pb->p_path, cwd);
+                       closepdb(pldp);
+                       return(1);
+                       }
+               }
+       closepdb(pldp);
+       pb->p_mode = P_IFREG;
+       strcpy(pb->p_path, cwd);
+       return(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getcwp.c b/usr/src/new/new/spms/src/lib/libspms/src/getcwp.c
new file mode 100644 (file)
index 0000000..5adc492
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getcwp() returns the pathname of the current working project. If the
+ * PROJECT environment variable is undefined or a null string, null is
+ * returned.
+ */
+#include "null.h"
+
+char *
+getcwp()
+{
+       extern char *_PROJECT;          /* project root directory pathname */
+       void getproject();              /* get PROJECT environment variable */
+
+       if (_PROJECT == NULL)
+               getproject();
+       return(_PROJECT);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/gethdir.c b/usr/src/new/new/spms/src/lib/libspms/src/gethdir.c
new file mode 100644 (file)
index 0000000..9c360b5
--- /dev/null
@@ -0,0 +1,43 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * gethdir() returns a pointer to a string containing the pathname of the
+ * root project directory belonging to username. If username is null or a
+ * zero length string, the root project directory belonging to the current
+ * user returned. A null pointer is returned on error.
+ */
+#include <stdio.h>
+#include <pwd.h>
+#include "null.h"
+#include "path.h"
+
+char *
+gethdir(username)
+       char *username;                 /* user's login name */
+{
+       char *getenv();                 /* get environment variable */
+       char *hdir;                     /* pointer to home directory pathname */
+       char *strcpy();                 /* string copy */
+       struct passwd *getpwnam();      /* get password file entry by name */
+       struct passwd *getpwuid();      /* get password file entry by uid */
+       struct passwd *pw;              /* passwd struct pointer */
+       
+       if (username == NULL || *username == '\0')
+               {
+               if ((hdir = getenv("ROOTPROJECT")) != NULL)
+                       return(hdir);
+               if ((hdir = getenv("HOME")) != NULL)
+                       return(hdir);
+               pw = getpwuid(getuid());
+               }
+       else if ((pw = getpwnam(username)) == NULL)
+               {
+               warn("unknown user %s", username);
+               return(NULL);
+               }
+       return(pw->pw_dir);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getproject.c b/usr/src/new/new/spms/src/lib/libspms/src/getproject.c
new file mode 100644 (file)
index 0000000..0bca285
--- /dev/null
@@ -0,0 +1,24 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getproject() saves the contents of the PROJECT environment variable.
+ * If the PROJECT variable is undefined or a null string, null is returned.
+ */
+#include "null.h"
+
+char *_PROJECT = NULL;                 /* project root directory pathname */
+
+void
+getproject()
+{
+       register char *pv;              /* ptr to start of PROJECT variable */
+       char *getenv();                 /* get environment variable */
+       char *strsav();                 /* save a string somewhere */
+
+       if ((pv = getenv("PROJECT")) != NULL && *pv != '\0')
+               _PROJECT = strsav(pv);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getpwdir.c b/usr/src/new/new/spms/src/lib/libspms/src/getpwdir.c
new file mode 100644 (file)
index 0000000..d25adb0
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getpwdir() searchs from the beginning of the passwd file until a
+ * matching home directory is found. If found, a pointer is returned
+ * to a passwd struct, otherwise NULL.
+ */
+#include <pwd.h>
+#include "macro.h"
+#include "null.h"
+
+struct passwd *
+getpwdir(dir)
+       char *dir;                      /* directory to be matched */
+{
+       register struct passwd *pw;     /* pointer to current passwd entry */
+       int endpwent();                 /* close passwd file */
+       struct passwd *getpwent();      /* get next passwd entry */
+
+       for (;;)
+               {
+               if ((pw = getpwent()) == NULL)
+                       break;
+               if (EQUAL(dir, pw->pw_dir))
+                       break;
+               }
+       endpwent();
+       return(pw);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getshell.c b/usr/src/new/new/spms/src/lib/libspms/src/getshell.c
new file mode 100644 (file)
index 0000000..75451bf
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getshell() returns the value the SHELL environment variable (usually
+ * the pathname of the user's command interpreter). If SHELL is undefined,
+ * getshell() returns SH (defined in header file bin.h).
+ */
+#include "bin.h"
+#include "null.h"
+
+char *
+getshell()
+{
+       char *shell;                    /* command shell pathname */
+       char *getenv();                 /* get environment variable */
+
+       if ((shell = getenv("SHELL")) == NULL)
+               return(SH);
+       else
+               return(shell);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/getwd.c b/usr/src/new/new/spms/src/lib/libspms/src/getwd.c
new file mode 100644 (file)
index 0000000..bfa28d5
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * getwd() returns the pathname of the current working directory. On error
+ * an error message is copied to pathname and null pointer is returned.
+ *
+ * A version of this function was copied to the standard C library. It is
+ * only included here for compatibility with non-BSD UNIX systems.
+ */
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+#include "null.h"
+#include "path.h"
+
+#define GETWDERR(s)    strcpy(pathname, (s));
+
+char *strcpy();                                /* string copy */
+
+static int pathsize;                   /* pathname length */
+
+char *
+getwd(pathname)
+       char *pathname;
+{
+       char pathbuf[PATHSIZE];         /* temporary pathname buffer */
+       char *pnptr = &pathbuf[(sizeof pathbuf)-1]; /* pathname pointer */
+       char *prepend();                /* prepend dirname to pathname */
+       dev_t rdev;                     /* root device number */
+       DIR *dirp;                      /* directory stream */
+       ino_t rino;                     /* root inode number */
+       struct direct *dir;             /* directory entry struct */
+       struct stat d ,dd;              /* file status struct */
+
+       pathsize = 0;
+       *pnptr = '\0';
+       stat(ROOTDIR, &d);
+       rdev = d.st_dev;
+       rino = d.st_ino;
+       for (;;)
+               {
+               stat(CURDIR, &d);
+               if (d.st_ino == rino && d.st_dev == rdev)
+                       break;          /* reached root directory */
+               if ((dirp = opendir(PARENTDIR)) == NULL)
+                       {
+                       GETWDERR("getwd: can't open ..");
+                       goto fail;
+                       }
+               if (chdir(PARENTDIR) < 0)
+                       {
+                       GETWDERR("getwd: can't chdir to ..");
+                       goto fail;
+                       }
+               fstat(dirp->dd_fd, &dd);
+               if(d.st_dev == dd.st_dev)
+                       {
+                       if(d.st_ino == dd.st_ino)
+                               {       /* reached root directory */
+                               closedir(dirp);
+                               break;
+                               }
+                       do      {
+                               if ((dir = readdir(dirp)) == NULL)
+                                       {
+                                       closedir(dirp);
+                                       GETWDERR("getwd: read error in ..");
+                                       goto fail;
+                                       }
+                               } while (dir->d_ino != d.st_ino);
+                       }
+               else do {
+                       if((dir = readdir(dirp)) == NULL)
+                               {
+                               closedir(dirp);
+                               GETWDERR("getwd: read error in ..");
+                               goto fail;
+                               }
+                       stat(dir->d_name, &dd);
+                       } while(dd.st_ino != d.st_ino || dd.st_dev != d.st_dev);
+               closedir(dirp);
+               pnptr = prepend(PATHSEP, prepend(dir->d_name, pnptr));
+               }
+       if (*pnptr == '\0')
+               {                       /* current dir == root dir */
+               strcpy(pathname, ROOTDIR);
+               }
+       else    {
+               strcpy(pathname, pnptr);
+               if (chdir(pnptr) < 0)
+                       {
+                       GETWDERR("getwd: can't change back to .");
+                       return(NULL);
+                       }
+               }
+       return(pathname);
+
+fail:  chdir(prepend(CURDIR, pnptr));
+       return(NULL);
+}
+
+
+
+/*
+ * prepend() tacks a directory name onto the front of a pathname.
+ */
+static char *
+prepend(dirname, pathname)
+       register char *dirname;
+       register char *pathname;
+{
+       register int i;                 /* directory name size counter */
+
+       for (i = 0; *dirname != '\0'; i++, dirname++)
+               continue;
+       if ((pathsize += i) < PATHSIZE)
+               while (i-- > 0)
+                       *--pathname = *--dirname;
+       return(pathname);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/mk_dir.c b/usr/src/new/new/spms/src/lib/libspms/src/mk_dir.c
new file mode 100644 (file)
index 0000000..8f7dd5f
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * mk_dir() creates a directory named by dirname via the mkdir command.
+ * Returns exit status of mkdir command.
+ */
+#include <sys/param.h>
+#include "bin.h"
+#include "system.h"
+
+mk_dir(dirname)
+       char *dirname;                  /* directory name */
+{
+       int pid;                        /* process identity */
+       int status;                     /* child return status */
+       int w;                          /* a child id */
+
+       if ((pid = FORK()) == 0)
+               {
+               execl(MKDIR, "mkdir", dirname, 0);
+               _exit(1);
+               }
+       while ((w = wait(&status)) != pid && w != -1)
+               continue;
+       status >>= NBBY;
+       status &=  0xff;
+       return(status);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/mkalias.c b/usr/src/new/new/spms/src/lib/libspms/src/mkalias.c
new file mode 100644 (file)
index 0000000..28555ac
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * mkalias() constructs a project directory alias from a pathname.
+ */
+#include "path.h"
+
+char *
+mkalias(pathname)
+       char *pathname;
+{
+       register char *ls;              /* last separator character */
+       register char *p;               /* pathname pointer */
+
+       for (ls = p = pathname; *p != '\0'; p++)
+               if ((*p == _PSC || *p == _PPSC) && p[1] != '\0')
+                       ls = p+1;
+       return(ls);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/mustfopen.c b/usr/src/new/new/spms/src/lib/libspms/src/mustfopen.c
new file mode 100644 (file)
index 0000000..d3f0403
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * mustfopen() opens a file in the manner of fopen(3). However, if the file
+ * cannot be accessed, exit(1) is called.
+ */
+#include <stdio.h>
+
+FILE *
+mustfopen(filename,mode)
+       char *filename;
+       char *mode;
+{
+       FILE *stream;                   /* file stream */
+
+       if ((stream = fopen(filename,mode)) == NULL)
+               fatal("can't open %s",filename);
+       return(stream);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/optpath.c b/usr/src/new/new/spms/src/lib/libspms/src/optpath.c
new file mode 100644 (file)
index 0000000..f4a4b06
--- /dev/null
@@ -0,0 +1,71 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * optpath() condenses a pathname by eliminating adjacent separator
+ * characters, and current and parent directory names. If optpath()
+ * encounters a parent directory, it backtracks to eliminate the
+ * previous directory. If the beginning of the pathname is reached
+ * during backtracking, then if the pathname is absolute, the parent
+ * directory is purged, otherwise it is shifted to the beginning of
+ * pathname. Special care is taken not to clobber a shifted parent
+ * by using a guard pointer. Returns pathname.
+ */
+#include "path.h"
+
+#define absolute_path  (*pathname == _RDIRC)
+
+char *
+optpath(pathname)
+       register char *pathname;        /* pathname to be optimized */
+{
+       register char *bp;              /* back pathname pointer */
+       register char *fp;              /* forward pathname pointer */
+       register char *up;              /* pathname update guard pointer */
+       int strncmp();                  /* compare n characters */
+
+       bp = fp = up = pathname;
+
+       /* elimination of initial "./" causes no harmful side-effects */
+       if (fp[0] == _CDIRC && fp[1] == _PSC) fp += 2;
+
+       while (*fp != '\0')
+               if (fp[0] == _PSC)
+                       if (fp[1] == _PSC || fp[1] == '\0')
+                               fp += 1;        /* "//" or trailing `/' */
+                       else if (fp[1]==_CDIRC && (fp[2]==_PSC || fp[2]=='\0'))
+                               fp += 2;        /* `.' */
+                       else if (strncmp(fp+1,PARENTDIR,2) == 0 &&
+                               (fp[3] == _PSC || fp[3] == '\0'))
+                               {       /* ".." (don't backtrack over a "..") */
+                               if (absolute_path || 
+                                  (bp > up && bp-2 < pathname) ||
+                                  (bp > up && strncmp(bp-2,PARENTDIR,2) != 0))
+                                       {
+                                       while (bp > up && *--bp != _PSC)
+                                               continue;
+                                       }
+                               else    {
+                                       /* don't clobber separator character */
+                                       if (bp[0] == _PSC) bp++;
+                                       bp[0] = fp[1];
+                                       bp[1] = fp[2];
+                                       bp[2] = fp[3];
+                                       up = bp += 2;
+                                       }
+                               fp += 3;
+                               }
+                       else    {
+                               *bp++ = *fp++;
+                               }
+               else    {
+                       *bp++ = *fp++;
+                       }
+       if (bp == pathname && *pathname != '\0')
+               *bp++ = (absolute_path) ? _RDIRC : _CDIRC;
+       *bp = '\0';
+       return(pathname);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pathcat.c b/usr/src/new/new/spms/src/lib/libspms/src/pathcat.c
new file mode 100644 (file)
index 0000000..a3d42e9
--- /dev/null
@@ -0,0 +1,44 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pathcat() concatenates path components p1 and p2 into character buffer
+ * p1_p2. Returns p1_p2.
+ */
+#include <stdio.h>
+#include "path.h"
+
+char *
+pathcat(p1_p2, p1, p2)
+       register char *p1;
+       register char *p2;
+       register char *p1_p2;
+{
+       register int plen;              /* maximum pathname length */
+       char *sp1_p2;                   /* start of p1_p2 */
+
+       sp1_p2 = p1_p2;
+       for (plen = PATHSIZE; plen > 0; plen--, p1_p2++, p1++)
+               if ((*p1_p2 = *p1) == '\0')
+                       break;
+       if (*p2 != '\0' && plen > 0)
+               {
+               if (p1_p2 != sp1_p2 && p1_p2[-1] != _PSC)
+                       {
+                       *p1_p2++ = _PSC;
+                       plen--;
+                       }
+               for (; plen > 0; plen--, p1_p2++, p2++)
+                       if ((*p1_p2 = *p2) == '\0')
+                               break;
+               }
+       if (plen == 0)
+               {
+               *--p1_p2 = '\0';
+               warn("pathname too long");
+               }
+       return(sp1_p2);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pathhead.c b/usr/src/new/new/spms/src/lib/libspms/src/pathhead.c
new file mode 100644 (file)
index 0000000..6e8a084
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pathhead() removes tail of pathname and returns pathname. The tail is
+ * defined as that part of the pathname after the last separator.
+ */
+#include "path.h"
+
+char *
+pathhead(pathname)
+       register char *pathname;
+{
+       register char *ls;              /* last separator character */
+       register char *p;               /* pathname pointer */
+
+       for (p = pathname; *p != '\0'; p++)
+               if (*p == _PSC)
+                       ls = p;
+       *ls = '\0';
+       return(pathname);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pathtail.c b/usr/src/new/new/spms/src/lib/libspms/src/pathtail.c
new file mode 100644 (file)
index 0000000..cfe9eeb
--- /dev/null
@@ -0,0 +1,24 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pathtail() removes head of pathname and returns a pointer to the first
+ * character after the last separator.
+ */
+#include "path.h"
+
+char *
+pathtail(pathname)
+       register char *pathname;
+{
+       register char *ls;              /* last separator character */
+       register char *p;               /* pathname pointer */
+
+       for (ls = p = pathname; *p != '\0'; p++)
+               if (*p == _PSC)
+                       ls = p+1;
+       return(ls);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pdtmatch.c b/usr/src/new/new/spms/src/lib/libspms/src/pdtmatch.c
new file mode 100644 (file)
index 0000000..aaeab56
--- /dev/null
@@ -0,0 +1,53 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pdtmatch() returns YES if the type labels in type label buffer tb
+ * satisfy the boolean postfix type label expression, otherwise NO.
+ */
+#include "null.h"
+#include "pdtyp.h"
+#include "truefalse.h"
+#include "yesno.h"
+
+pdtmatch(postfix, tb)
+       register PDTYP *postfix;        /* postfix expression struct */
+       register char *tb;              /* type label buffer */
+{
+       register int i;                 /* postfix expression index */
+       register int j;                 /* top-of-evaluation stack pointer */
+       char *pdtfind();                /* find type label in buffer */
+
+       j = -1;
+       for (i = 0; i < postfix->pfxsize; i++)
+               switch ((postfix->pfx)[i].p_class)
+                       {
+                       case B_ID:
+                               j++;
+                               (postfix->pfx)[i].p_label =
+                               pdtfind((postfix->pfx)[i].p_id, tb);
+                               (postfix->pfx)[i].p_sw = (postfix->eval)[j] =
+                               (postfix->pfx)[i].p_label != NULL;
+                               break;
+                       case B_OR:
+                               j--;
+                               (postfix->pfx)[i].p_sw = (postfix->eval)[j] =
+                               (postfix->eval)[j] == TRUE ||
+                               (postfix->eval)[j+1] == TRUE;
+                               break;
+                       case B_AND:
+                               j--;
+                               (postfix->pfx)[i].p_sw = (postfix->eval)[j] =
+                               (postfix->eval)[j] == TRUE &&
+                               (postfix->eval)[j+1] == TRUE;
+                               break;
+                       case B_NOT:
+                               (postfix->pfx)[i].p_sw = (postfix->eval)[j] =
+                               !(postfix->eval)[j];
+                               break;
+                       }
+       return(((postfix->eval)[j] == TRUE) ? YES : NO);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pdtparse.c b/usr/src/new/new/spms/src/lib/libspms/src/pdtparse.c
new file mode 100644 (file)
index 0000000..1a08537
--- /dev/null
@@ -0,0 +1,199 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pdtparse() translates an infix project directory boolean type label
+ * expression to postfix, using operator-precedence parsing. An adjacency
+ * matrix augments the parsing method by detecting tokens that must not
+ * be adjacent to one another. Returns NO if syntax error or out of memory,
+ * otherwise YES.
+ *
+ * The maximum size of the input stack used by the parser determines the
+ * size of the postfix expression evaluation stack.
+ */
+#include "null.h"
+#include "macro.h"
+#include "pdtyp.h"
+#include "truefalse.h"
+#include "yesno.h"
+
+#define INCRISTAK      20              /* amount to increase input stack */
+#define MAXISTAK       20              /* initial size of input stack */
+#define INCRPEXP       40              /* amount to increase postfix expr */
+#define MAXPEXP                40              /* initial size of postfix expr */
+#define TOKTABSIZE     256             /* token lookup table size */
+
+static char *type;                     /* current type label */
+static int intok;                      /* current input token */
+static int typlen;                     /* length of current type label */
+static short *istak;                   /* boolean expression input stack */
+static short toktab[TOKTABSIZE];       /* token lookup table */
+
+static short opr[7][7] =               /* operator precedence relations */
+       {
+       /*id   !    &    |    (    )    B_EOS   */
+       { 0 ,  0 , '>', '>',  0 , '>', '>'},    /* id */
+       {'<',  0 , '>', '>', '<', '>', '>'},    /* ! */
+       {'<', '<', '>', '>', '<', '>', '>'},    /* & */
+       {'<', '<', '<', '>', '<', '>', '>'},    /* | */
+       {'<', '<', '<', '<', '<', '=',  0 },    /* ( */
+       { 0 ,  0 , '>', '>',  0 , '>', '>'},    /* ) */
+       {'<', '<', '<', '<', '<',  0 ,  0 },    /* B_EOS */
+       };
+
+static short adj[7][7] =               /* token adjacency matrix */
+       {
+       /*id   !    &    |    (    )    B_EOS   */
+       { NO,  NO, YES, YES,  NO, YES, YES},    /* id */
+       {YES,  NO,  NO,  NO, YES,  NO,  NO},    /* ! */
+       {YES, YES,  NO,  NO, YES,  NO,  NO},    /* & */
+       {YES, YES,  NO,  NO, YES,  NO,  NO},    /* | */
+       {YES, YES,  NO,  NO, YES,  NO,  NO},    /* ( */
+       { NO,  NO, YES, YES,  NO, YES, YES},    /* ) */
+       {YES, YES,  NO,  NO, YES,  NO,  NO},    /* B_EOS */
+       };
+
+pdtparse(typexpr, postfix)
+       char *typexpr;                  /* boolean type expression */
+       PDTYP *postfix;                 /* postfix expression struct */
+{
+       register int lastok;            /* previous input token */
+       register int maxestak;          /* maximum size of evaluation stack */
+       register int poptok;            /* token most recently popped */
+       register int pp;                /* postfix expression pointer */
+       register int toi;               /* top-of-input-stack pointer */
+       register int toitok;            /* topmost token on stack */
+       char *getnextok();              /* get next type expression token */
+       char *malloc();                 /* memory allocator */
+       char *realloc();                /* reallocate memory block */
+       int maxistak;                   /* maximum size of input stack */
+       int maxpexp;                    /* maximum size of postfix expression */
+
+       /* initialize token lookup table */
+       toktab['\0'] = B_EOS;
+       toktab['\t'] = B_WHITE;
+       toktab[' '] = B_WHITE;
+       toktab['&'] = B_AND;
+       toktab['|'] = B_OR;
+       toktab['!'] = B_NOT;
+       toktab['('] = B_LPAREN;
+       toktab[')'] = B_RPAREN;
+       /* the rest of the lookup table is B_ID which is 0 */
+
+       /* initialize boolean type expression input stack */
+       maxistak = MAXISTAK;
+       if ((istak = (short *) malloc((unsigned)maxistak*sizeof(short))) == NULL)
+               goto nomemory;
+       maxestak = toi = 0;
+       istak[toi] = B_EOS;
+
+       /* initialize postfix type expression */
+       maxpexp = MAXPEXP;
+       if ((postfix->pfx = (POSTFIX *) malloc((unsigned)maxpexp*sizeof(POSTFIX))) == NULL)
+               goto nomemory;
+       pp = 0;
+
+       /* get first token */
+       lastok = B_EOS;
+       typexpr = getnextok(typexpr);
+       if (adj[lastok][intok] == NO)
+               goto badsyntax;
+
+       while (TRUE)
+               {
+               if (toi == 0 && intok == B_EOS)
+                       break;  /* ACCEPT */
+               toitok = istak[toi];
+               if (opr[toitok][intok] == '<' || opr[toitok][intok] == '=')
+                       { /* SHIFT current input token onto the stack */
+                       toi++;
+                       maxestak = MAX(maxestak, toi);
+                       if (toi >= maxistak)
+                               { /* increase input stack size */
+                               maxistak += INCRISTAK;
+                               if ((istak = (short *) realloc((char *)istak,
+                                    (unsigned)maxistak*sizeof(short))) == NULL)
+                                       goto nomemory;
+                               }
+                       istak[toi] = lastok = intok;
+                       typexpr = getnextok(typexpr);
+                       if (adj[lastok][intok] == NO)
+                               goto badsyntax;
+                       }
+               else if (opr[toitok][intok] == '>')
+                       do      { /* REDUCE */
+                               if (pp >= maxpexp)
+                                       { /* increase postfix expression size */
+                                       maxpexp += INCRPEXP;
+                                       if ((postfix->pfx = (POSTFIX *)
+                                            realloc((char *)postfix->pfx,
+                                                    (unsigned)maxpexp*sizeof(POSTFIX))) == NULL)
+                                               goto nomemory;
+                                       }
+                               switch (toitok)
+                                       {
+                                       case B_ID:
+                                               type[typlen] = '\0';
+                                               (postfix->pfx)[pp].p_id = type;
+                                       case B_AND:
+                                       case B_OR:
+                                       case B_NOT:
+                                               (postfix->pfx)[pp].p_class = toitok;
+                                               pp++;
+                                               break;
+                                       }
+                               toi--;
+                               poptok = toitok;
+                               toitok = istak[toi];
+                               } while (opr[toitok][poptok] != '<');
+               else    {
+                       goto badsyntax;
+                       }
+               }
+       free((char *)istak);
+       if ((postfix->eval = (short *) malloc((unsigned)(maxestak+1)*sizeof(short))) == NULL)
+               goto nomemory;
+       postfix->pfxsize = pp;
+       return(YES);
+badsyntax:
+       warn("type expression syntax error");
+       free((char *) istak);
+       free((char *) postfix->pfx);
+       return(NO);
+nomemory:
+       warn("out of memory");
+       return(NO);
+}
+
+
+
+/*
+ * getnextok() identifies the next token in the boolean type expression
+ * and returns an updated pointer to the expression. `type' points to
+ * the current type label in the boolean expression.
+ */
+static char *
+getnextok(t)
+       register char *t;               /* current pointer to type expr */
+{
+       register int i;                 /* type label buffer index */
+
+       while (WHITESPACE(*t))
+               t++;
+       intok = toktab[*t];
+       if (intok == B_ID)
+               {
+               type = t;
+               for (i = 0; toktab[*t] == B_ID; i++, t++)
+                       continue;
+               typlen = i;
+               }
+       else if (intok != B_EOS)
+               {
+               t++;
+               }
+       return(t);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pdtyp.c b/usr/src/new/new/spms/src/lib/libspms/src/pdtyp.c
new file mode 100644 (file)
index 0000000..ec88519
--- /dev/null
@@ -0,0 +1,245 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include "null.h"
+#include "path.h"
+#include "yesno.h"
+
+/*
+ * ispdt() returns 1 if project directory type label is legal,
+ * otherwise zero.
+ */
+ispdt(type)
+       char *type;                     /* type label */
+{
+       register char *tp;              /* type label pointer */
+       register int body = NO;         /* does type label have a body? */
+
+       for (tp = type; *tp != '\0' && *tp != '.'; tp++)
+               switch (*tp)
+                       {
+                       case ' ':
+                       case '\t':
+                               continue;
+                       default:
+                               body = YES;
+                               break;
+                       }
+       if (body == NO)
+               return(0);
+       if (*tp == '.')
+               {
+               tp++;
+               if (*tp == '-' || *tp == '+')
+                       tp++;
+               while (isdigit(*tp))
+                       tp++;
+               }
+       return((*tp == '\0') ? 1 : 0);
+}
+
+
+
+/*
+ * pdtcpy() copies a project directory type pointed to by tb, to type.
+ * Returns type.
+ */
+char *
+pdtcpy(type, tb)
+       register char *type;            /* receiving type buffer */
+       register char *tb;              /* type pointer */
+{
+       register int i;                 /* type buffer index */
+
+       for (i = 0; *tb != _PDTSC && *tb != '\0'; i++)
+               type[i] = *tb++;
+       type[i] = '\0';
+       return(type);
+}
+
+
+
+/*
+ * pdtfind() compares project directory type label type with the type
+ * labels stored in type label buffer tb and returns a pointer to the
+ * position of the type label in the buffer if found, otherwise NULL.
+ */
+char *
+pdtfind(type, tb)
+       char *type;                     /* type label */
+       register char *tb;              /* type label buffer */
+{
+       char *tskip();                  /* skip to next type label */
+       int tcmp();                     /* compare type labels */
+
+       for (; *tb != '\0'; tb = tskip(tb))
+               {
+               if (tcmp(type, tb) == 0)
+                       return(tb);
+               }
+       return(NULL);
+}
+
+
+
+/*
+ * pdtinsert() inserts a type in type label buffer tb. The type labels
+ * within tb are assumed to be sorted into ascending order. tb must
+ * be big enough to hold type.
+ */
+void
+pdtinsert(type, tb)
+       register char *type;            /* type label */
+       char *tb;                       /* type label buffer */
+{
+       register char *tp;              /* type label buffer pointer */
+       char *tskip();                  /* skip to next type label */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+       int typlen;                     /* type label length */
+       int tcmp();                     /* compare type labels */
+       void tstretch();                /* stretch type label buffer */
+       
+       for (tp = tb; *tp != '\0'; tp = tskip(tp))
+               if (tcmp(type, tp) < 0)
+                       break;
+       typlen = strlen(type);
+       if (*tp == '\0')                /* append to the buffer */
+               if (tp > tb)
+                       {
+                       tstretch(tp, typlen+1);
+                       *tp = _PDTSC;
+                       strcpy(tp+1, type);
+                       }
+               else    {               /* empty buffer */
+                       tstretch(tp, typlen);
+                       strcpy(tp, type);
+                       }
+       else    {                       /* insert in the buffer */
+               tstretch(tp, typlen+1);
+               strcpy(tp, type);
+               tp[typlen] = _PDTSC;
+               }
+}
+
+
+
+/*
+ * pdtrm() removes type label type from type label buffer tb.
+ */
+void
+pdtrm(type, tb)
+       char *type;                     /* type label to be removed */
+       register char *tb;              /* type label buffer */
+{
+       register char *tp;              /* type label buffer pointer */
+       char *tskip();                  /* skip to next type label */
+       int tcmp();                     /* compare type labels */
+       int tlen();                     /* length of type label */
+       int typlen;                     /* type label length */
+       void tstretch();                /* stretch type label buffer */
+       
+       for (tp = tb; *tp != '\0'; tp = tskip(tp))
+               if (tcmp(type, tp) == 0)
+                       {
+                       typlen = tlen(tp);
+                       if (tp[typlen] == _PDTSC)
+                               tstretch(tp, -(typlen+1));
+                       else
+                               tstretch(tp, -typlen);
+                       if (tp > tb && tp[0] == '\0' && tp[-1] == _PDTSC)
+                               tp[-1] = '\0';
+                       break;
+                       }
+}
+
+
+
+/*
+ * tcmp() compares project directory type labels and returns an integer
+ * greater than, equal to, or less than 0, depending on whether type is
+ * lexicographically greater than, equal to, or less than the type
+ * pointed to by tp.
+ */
+static int
+tcmp(type, tp)
+       register char *type;            /* type label to be compared */
+       register char *tp;              /* type pointer */
+{
+       for (; *tp == *type && *type != '\0'; tp++, type++)
+               continue;
+       if (*type == '\0' && (*tp == _PDTSC || *tp == '.' || *tp == '\0'))
+               return(0);
+       return(*type - *tp);
+}
+
+
+
+/*
+ * tlen() returns the length of the type label pointed to by type label
+ * buffer pointer tp.
+ */
+static int
+tlen(tp)
+       register char *tp;              /* type label buffer pointer */
+{
+       register int n;                 /* length counter */
+
+       for (n = 0; *tp != _PDTSC && *tp != '\0'; tp++, n++)
+               continue;
+       return(n);
+}
+
+
+
+/*
+ * tskip() advances type pointer, tp, to the next project directory type
+ * label.
+ */
+static char *
+tskip(tp)
+       register char *tp;              /* type label pointer */
+{
+       while (*tp != _PDTSC && *tp != '\0')
+               tp++;
+       if (*tp == _PDTSC)
+               tp++;
+       return(tp);
+}
+
+
+
+/*
+ * tstretch() stretches type label buffer by n characters just before the point
+ * marked by type pointer tp. Negative n shrinks buffer by n characters.
+ */
+static void
+tstretch(tp, n)
+       register char *tp;              /* type label buffer pointer */
+       int n;                          /* stretch amount */
+{
+       register char *lowertp;         /* lower roving type label buffer ptr */
+       register char *uppertp;         /* upper roving type label buffer ptr */
+       
+       if (n > 0)
+               {
+               for (lowertp = tp; *lowertp != '\0'; lowertp++)
+                       continue;
+               uppertp = lowertp + n;
+               while (lowertp >= tp)
+                       *uppertp-- = *lowertp--;
+               }
+       else if (n < 0)
+               {
+               for (uppertp = tp; *uppertp != '\0'; uppertp++)
+                       continue;
+               lowertp = tp - n;
+               if (lowertp >= uppertp)
+                       *tp = '\0';
+               while (lowertp <= uppertp)
+                       *tp++ = *lowertp++;
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pfxcpy.c b/usr/src/new/new/spms/src/lib/libspms/src/pfxcpy.c
new file mode 100644 (file)
index 0000000..a09c20d
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pfxcpy() copies the prefix of s2 to s1.
+ */
+char *
+pfxcpy(s1, s2)
+       register char *s1;              /* target string */
+       register char *s2;              /* source string */
+{
+       char *ss1 = s1;                 /* start of s1 */
+
+       while ((*s1 = *s2) && *s2 != '.')
+               s1++, s2++;
+       *s1 = '\0';
+       return(ss1);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/ppathcat.c b/usr/src/new/new/spms/src/lib/libspms/src/ppathcat.c
new file mode 100644 (file)
index 0000000..af46c4f
--- /dev/null
@@ -0,0 +1,43 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * ppathcat() concatenates project pathname components pp1 and pp2 into
+ * character buffer pp1_pp2. Returns pp1_pp2.
+ */
+#include "path.h"
+
+char *
+ppathcat(pp1_pp2, pp1, pp2)
+       register char *pp1;
+       register char *pp2;
+       register char *pp1_pp2;
+{
+       register int pplen;             /* maximum pathname length */
+       char *spp1_pp2;                 /* start of pp1_pp2 */
+
+       spp1_pp2 = pp1_pp2;
+       for (pplen = PPATHSIZE; pplen > 0; pplen--, pp1_pp2++, pp1++)
+               if ((*pp1_pp2 = *pp1) == '\0')
+                       break;
+       if (*pp2 != '\0' && pplen > 0)
+               {
+               if (pp1_pp2 != spp1_pp2 && pp1_pp2[-1] != _PPSC)
+                       {
+                       *pp1_pp2++ = _PPSC;
+                       pplen--;
+                       }
+               for (; pplen > 0; pplen--, pp1_pp2++, pp2++)
+                       if ((*pp1_pp2 = *pp2) == '\0')
+                               break;
+               }
+       if (pplen == 0)
+               {
+               *--pp1_pp2 = '\0';
+               warn("project pathname too long");
+               }
+       return(spp1_pp2);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/ppathhead.c b/usr/src/new/new/spms/src/lib/libspms/src/ppathhead.c
new file mode 100644 (file)
index 0000000..c65080b
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * ppathhead() removes tail of project pathname and returns pathname.
+ * The tail is defined as that part of the pathname after the last separator.
+ */
+#include "path.h"
+
+char *
+ppathhead(ppathname)
+       register char *ppathname;
+{
+       register char *ls;              /* last separator character */
+       register char *p;               /* project pathname pointer */
+
+       for (p = ppathname; *p != '\0'; p++)
+               if (*p == _PPSC)
+                       ls = p;
+       *ls = '\0';
+       return(ppathname);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/pperror.c b/usr/src/new/new/spms/src/lib/libspms/src/pperror.c
new file mode 100644 (file)
index 0000000..523f83e
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pperror() writes a system error message to standard error output,
+ * preceded by the name of the program and message.
+ */
+#include <stdio.h>
+
+pperror(message)
+       char *message;                  /* error message */
+{
+       extern char *PGN;               /* program name */
+
+       fprintf(stderr, "%s: ", PGN);
+       perror(message);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/readpath.c b/usr/src/new/new/spms/src/lib/libspms/src/readpath.c
new file mode 100644 (file)
index 0000000..3d3118d
--- /dev/null
@@ -0,0 +1,69 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * readpath() loads a PATH struct, given a regular or project pathname.
+ * Returns -1 if bad pathname, otherwise 0.
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "pdbuf.h"
+#include "pld.h"
+#include "spms.h"
+#include "yesno.h"
+
+extern char *PATHERR;                  /* current pathname error condition */
+extern char PDBERR[];                  /* project database error message */
+
+readpath(pathname, pb)
+       char *pathname;                 /* regular or project pathname */
+       PATH *pb;                       /* project directory struct buffer */
+{
+       char *pbgetstring();            /* get specified string field */
+       int closepdb();                 /* close database */
+       int errpdb();                   /* print database error message */
+       int pfndent();                  /* find and load database entry */
+       int strlen();                   /* string length */
+       int xppath();                   /* expand project pathname */
+       PDB *openpdb();                 /* open database */
+       PDB *pldp;                      /* project link directory stream */
+
+       if (xppath(pathname, pb) == -1)
+               return(-1);
+       switch (pb->p_mode & P_IFMT)
+               {
+               case P_IFNEW:
+               case P_IFREG:
+                       return(0);
+                       break;
+               case P_IFPDIR:
+                       if ((pldp = openpdb(PLDNAME, pb->p_project, "r")) == NULL)
+                               {
+                               PATHERR = PDBERR;
+                               return(-1);
+                               }
+                       pfndent(pb->p_alias, pldp);
+                       break;
+               case P_IFHOME:
+               case P_IFPROOT:
+                       if ((pldp = openpdb(PLDNAME, pb->p_project, "r")) == NULL)
+                               {
+                               PATHERR = PDBERR;
+                               return(-1);
+                               }
+                       pfndent(CURPROJECT, pldp);
+                       break;
+               }
+       pbgetstring(PDIRTYPE, pb->p_type);
+       pb->p_desc = pb->p_type + strlen(pb->p_type) + 1;
+       pbgetstring(PDIRDESC, pb->p_desc);
+       closepdb(pldp);
+       return(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/readpld.c b/usr/src/new/new/spms/src/lib/libspms/src/readpld.c
new file mode 100644 (file)
index 0000000..285b62a
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * readpld() reads next project link directory entry. Returns a pointer
+ * to a PATH struct, or NULL at EOF.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "pdbuf.h"
+#include "pld.h"
+#include "yesno.h"
+
+PATH *
+readpld(pldp)
+       PDB *pldp;                      /* database stream */
+{
+       static PATH pathbuf;            /* project directory struct */
+       char *optpath();                /* pathname optimization */
+       char pathname[PATHSIZE];        /* pathname buffer */
+       char *pathcat();                /* pathname concatenation */
+       char *pbgetkey();               /* get next key */
+       char *pbgetstring();            /* get specified string field */
+       char *strcpy();                 /* string copy */
+       int pbfndflag();                /* find flag field */
+       int pgetent();                  /* load next entry into buffer */
+       int strlen();                   /* string length */
+
+       if (pgetent(pldp) == EOF)
+               return(NULL);
+       if (pbfndflag(PROOTDIR) == YES)
+               pathbuf.p_mode = P_IFPROOT;
+       else
+               pathbuf.p_mode = P_IFPDIR;
+       pathbuf.p_alias = pathbuf.p_buf;
+       pbgetkey(pathbuf.p_alias);
+       pathbuf.p_path = pathbuf.p_alias + strlen(pathbuf.p_alias) + 1;
+       pbgetstring(PDIRPATH, pathname);
+       if (*pathname == _RDIRC)
+               strcpy(pathbuf.p_path, pathname);
+       else
+               pathcat(pathbuf.p_path, pldp->root, pathname);
+       optpath(pathbuf.p_path);
+       pathbuf.p_type = pathbuf.p_path + strlen(pathbuf.p_path) + 1;
+       pbgetstring(PDIRTYPE, pathbuf.p_type);
+       pathbuf.p_desc = pathbuf.p_type + strlen(pathbuf.p_type) + 1;
+       pbgetstring(PDIRDESC, pathbuf.p_desc);
+       return(&pathbuf);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/rm_dir.c b/usr/src/new/new/spms/src/lib/libspms/src/rm_dir.c
new file mode 100644 (file)
index 0000000..062e8af
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * rm_dir() removes a directory named by dirname via the rmdir command.
+ * Returns exit status of rmdir command.
+ */
+#include <sys/param.h>
+#include "bin.h"
+#include "macro.h"
+#include "system.h"
+
+rm_dir(dirname)
+       char *dirname;                  /* directory name */
+{
+       int pid;                        /* process identity */
+       int status;                     /* child return status */
+       int w;                          /* a child id */
+
+       if ((pid = FORK()) == 0)
+               {
+               execl(RMDIR, "rmdir", dirname, 0);
+               _exit(1);
+               }
+       while ((w = wait(&status)) != pid && w != -1)
+               continue;
+       status >>= NBBY;
+       status &=  0xff;
+       /* check if the directory exists because rmdir is unreliable */
+       if (status == 0 && FILEXIST(dirname))
+               {
+               warn("%s not removed", dirname);
+               status = 1;
+               }
+       return(status);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/strpcpy.c b/usr/src/new/new/spms/src/lib/libspms/src/strpcpy.c
new file mode 100644 (file)
index 0000000..87b7f2a
--- /dev/null
@@ -0,0 +1,19 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * strpcpy() copies string s2 to s1 and returns a pointer to the
+ * next character after s1.
+ */
+char *
+strpcpy(s1, s2)
+       register char *s1;
+       register char *s2;
+{
+       while (*s1++ = *s2++)
+               continue;
+       return(--s1);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/strsav.c b/usr/src/new/new/spms/src/lib/libspms/src/strsav.c
new file mode 100644 (file)
index 0000000..7a399cd
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * strsav() saves a string somewhere and returns a pointer to the somewhere.
+ * Returns NULL on error.
+ */
+#include "null.h"
+
+char *
+strsav(s)
+       char *s;
+{
+       char *sptr;                     /* somewhere string pointer */
+       char *malloc();                 /* memory allocator */
+       char *strcpy();                 /* string copy */
+       int strlen();                   /* string length */
+
+       if ((sptr = malloc((unsigned)(strlen(s)+1))) == NULL)
+               return(NULL);
+       return(strcpy(sptr, s));
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/warn.c b/usr/src/new/new/spms/src/lib/libspms/src/warn.c
new file mode 100644 (file)
index 0000000..b2946ad
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * warn() places an error message on the standard error output stream
+ * stderr.
+ */
+#include <stdio.h>
+
+extern char *PGN;                      /* program name */
+
+/* VARARGS1 */
+warn(fmt, args)
+       char *fmt;
+{
+       if (*PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       _doprnt(fmt, &args, stderr);
+       putc('\n', stderr);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/xorpath.c b/usr/src/new/new/spms/src/lib/libspms/src/xorpath.c
new file mode 100644 (file)
index 0000000..8e0676c
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * xorpath() strips pathname p1 from pathname p2 if p1 is a leading
+ * component of pathname p2. Returns p2.
+ */
+#include "path.h"
+
+char *
+xorpath(p1, p2)
+       register char *p1;              /* subpathname */
+       register char *p2;              /* pathname */
+{
+       char *sp2;                      /* start of pathname */
+
+       sp2 = p2;
+       for (; *p1 == *p2; p1++, p2++)
+               if (*p1 == '\0')
+                       break;
+       if (*p1 == '\0')
+               return((*p2 == _PSC) ? ++p2 : p2);
+       else
+               return(sp2);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/xppath.c b/usr/src/new/new/spms/src/lib/libspms/src/xppath.c
new file mode 100644 (file)
index 0000000..0018f8c
--- /dev/null
@@ -0,0 +1,314 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * xppath() expands project pathname ppathname into regular pathname. Both
+ * the pathname type labels and description are ignored for efficiency.
+ * Returns -1 on error, otherwise zero.
+ */
+#include <pwd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "null.h"
+#include "path.h"
+#include "pdb.h"
+#include "pld.h"
+#include "system.h"
+#include "yesno.h"
+/*
+ * pathname states
+ */
+#define START  0001
+#define HDIR   0002
+#define PDIR1  0004
+#define PDIR2  0010
+#define DIR1   0020
+#define DIR2   0040
+#define EOP    0100
+#define ERROR  0200
+/*
+ * pathname errors
+ */
+#define E_UNKNOWN      0
+#define E_SYNTAX       1
+#define E_NOTPDIR      2
+#define E_NOTDIR       3
+
+extern int errno;
+extern int sys_nerr;
+extern char *sys_errlist[];
+extern char PDBERR[];                  /* project link dir error message */
+
+static char *pp;                       /* project pathname pointer */
+static char *perrlist[] =
+       {
+       "unknown error",
+       "pathname syntax error",
+       "no such project directory",
+       "no such file, directory, or project",
+       };
+
+char *PATHERR;                         /* current pathname error condition */
+int PPDEBUG = NO;                      /* project pathname debug flag */
+
+xppath(ppathname, pb)
+       char *ppathname;                /* project pathname */
+       register PATH *pb;              /* pathname struct pointer */
+{
+       register char *p;               /* regular pathname pointer */
+       register short pstat;           /* pathname state */
+       char *getcwp();                 /* get current project pathname */
+       char *gethdir();                /* get home directory pathname */
+       char *hdir;                     /* home directory pointer */
+       char *mkalias();                /* construct alias from pathname */
+       char *optpath();                /* optimize pathname */
+       char *pathcat();                /* pathname concatenation */
+       char *pbgetstring();            /* get specified string field */
+       char *pdir;                     /* project directory pathname */
+       char pplex();                   /* pathname lexical analyzer */
+       char *strcpy();                 /* string copy */
+       char *strpcpy();                /* copy string to pathname */
+       char token[PATHSIZE];           /* receiving token */
+       int closepdb();                 /* close database */
+       int pbfndflag();                /* find flag field */
+       int pfndent();                  /* find and load database entry */
+       int strlen();                   /* string length */
+       PDB *openpdb();                 /* open database */
+       PDB *pdbp;                      /* database stream */
+       struct passwd *getpwdir();      /* get password file entry for dir */
+       struct stat stbuf;              /* file state buffer */
+
+       PATHERR = perrlist[E_UNKNOWN];
+       pstat = START;
+       pp = ppathname;
+       pb->p_mode = P_IFREG;
+       pb->p_alias = optpath(strcpy(pb->p_buf, mkalias(ppathname)));
+       p = pb->p_path = pb->p_buf + strlen(pb->p_buf) + 1;
+       *pb->p_project = '\0';
+
+       while (pstat != EOP)
+               {
+               switch (pplex(token))
+                       {
+                       case _HDIRC:    /* user's home directory */
+                               if (pstat == START)
+                                       {
+                                       if ((hdir = gethdir(token+1)) != NULL)
+                                               {
+                                               p = strpcpy(p, hdir);
+                                               strcpy(pb->p_project, pb->p_path);
+                                               pb->p_mode = P_IFHOME;
+                                               pstat = HDIR;
+                                               break;
+                                               }
+                                       }
+                               PATHERR = perrlist[E_SYNTAX];
+                               pstat = ERROR;
+                               break;
+                       case _PPSC:     /* project pathname separator char */
+                               if ((pstat&(START|HDIR|PDIR2)) == 0)
+                                       {
+                                       if ((pstat&DIR1) != 0)
+                                               PATHERR = perrlist[E_SYNTAX];
+                                       else
+                                               PATHERR = perrlist[E_NOTDIR];
+                                       pstat = ERROR;
+                                       break;
+                                       }
+                               if (pstat == START)
+                                       {
+                                       pb->p_mode = P_IFHOME;
+                                       p = strpcpy(p, gethdir((char *) NULL));
+                                       strcpy(pb->p_project, pb->p_path);
+                                       }
+                               p = strpcpy(p, PATHSEP);
+                               pstat = PDIR1;
+                               break;
+                       case _PSC:      /* pathname separator character */
+                               if ((pstat&(START|HDIR|PDIR2|DIR2)) == 0)
+                                       {
+                                       PATHERR = perrlist[E_SYNTAX];
+                                       pstat = ERROR;
+                                       break;
+                                       }
+                               if (pstat == START && (pdir = getcwp()) != NULL)
+                                       strcpy(pb->p_project, pdir);
+                               p = strpcpy(p, PATHSEP);
+                               pstat = DIR1;
+                               break;
+                       case '\0':
+                               *p = '\0';
+                               pstat = EOP;
+                               break;
+                       default:
+                               /* project dir, regular dir, or file */
+                               if ((pstat&(START|PDIR1|DIR1)) == 0)
+                                       {
+                                       PATHERR = perrlist[E_SYNTAX];
+                                       pstat = ERROR;
+                                       break;
+                                       }
+                               if (pstat == DIR1)
+                                       {
+                       regdir:         p = strpcpy(p, token);
+                                       pb->p_mode = P_IFREG;
+                                       pstat = DIR2;
+                                       break;
+                                       }
+                               /* initialize pathname */
+                               if (pstat == START)
+                                       {
+                                       if ((pdir = getcwp()) == NULL)
+                                               goto regdir;
+                                       strcpy(pb->p_project, pdir);
+                                       }
+                               else    {
+                                       pdir = pb->p_path;
+                                       }
+                               if ((pdbp = openpdb(PLDNAME, pdir, "r")) == NULL)
+                                       {
+                                       PATHERR = PDBERR;
+                                       pstat = ERROR;
+                                       break;
+                                       }
+                               /* project directory? */
+                               if (pfndent(token, pdbp) == NO)
+                                       {
+                                       closepdb(pdbp);
+                                       if ((pstat&PDIR1) != 0)
+                                               {/* project dir must follow ^ */
+                                               PATHERR = perrlist[E_NOTPDIR];
+                                               pstat = ERROR;
+                                               break;
+                                               }
+                                       goto regdir;
+                                       }
+                               if (pstat == START)
+                                       {
+                                       p = strpcpy(p, pdir);
+                                       p = strpcpy(p, PATHSEP);
+                                       }
+                               if (pbfndflag(PROOTDIR) == YES)
+                                       {
+                                       pb->p_mode = P_IFPROOT;
+                                       pstat = PDIR2;
+                                       }
+                               else    {
+                                       pb->p_mode = P_IFPDIR;
+                                       pstat = DIR2;
+                                       }
+                               /* is new pathname absolute? */
+                               if (*pbgetstring(PDIRPATH, p) == _RDIRC)
+                                       p = strpcpy(pb->p_path, p);
+                               else while (*p != '\0') p++;
+                               closepdb(pdbp);
+                               if (pb->p_mode == P_IFPROOT)
+                                       strcpy(pb->p_project, pb->p_path);
+                               break;
+                       }
+               if (pstat == ERROR)
+                       {
+                       *p = '\0';
+                       break;
+                       }
+               }
+       if (pstat != ERROR)
+               {
+               optpath(pb->p_path);
+               optpath(pb->p_project);
+               if (stat(pb->p_path, &stbuf) == 0)
+                       {
+                       /*
+                        * a regular dir may be a root project directory
+                        * specified as ~user, but expanded by the shell.
+                        */
+                       if (pb->p_mode == P_IFREG &&
+                          (stbuf.st_mode&S_IFMT) == S_IFDIR)
+                               {
+                               char pathbuf[PATHSIZE];
+
+                               pathcat(pathbuf, pb->p_path, PLDNAME);
+                               if (FILEXIST(pathbuf) &&
+                                   getpwdir(pb->p_path) != NULL)
+                                       {
+                                       strcpy(pb->p_project, pb->p_path);
+                                       pb->p_mode = P_IFHOME;
+                                       }
+                               }
+                       pb->p_mode |= (unsigned long) stbuf.st_mode;
+                       }
+               else    {
+                       if(errno < sys_nerr)
+                               PATHERR = sys_errlist[errno];
+                       if (pb->p_mode == P_IFREG)
+                               pb->p_mode = P_IFNEW;
+                       else    {       /* a project directory must exist */
+                               pstat = ERROR;
+                               }
+                       }
+               pb->p_type = pb->p_path + strlen(pb->p_path) + 1;
+               pb->p_desc = pb->p_type + 1;
+               *pb->p_type = *pb->p_desc = '\0';
+               }
+       if (PPDEBUG == YES)
+               warn("%s --> %s", ppathname, pb->p_path);
+       return((pstat == ERROR) ? -1 : 0);
+}
+
+
+
+/*
+ * pplex() gets next token. Returns first character of token.
+ */
+static char
+pplex(token)
+       register char *token;           /* receiving token */
+{
+       register char *rpp;             /* project pathname pointer */
+       char t;                         /* 1st token character */
+
+       rpp = pp;
+       t = *rpp;
+       switch (t)
+               {
+               case _PPSC:
+                       *token++ = *rpp++;
+                       while (*rpp == _PPSC) rpp++;
+                       break;
+               case _PSC:
+                       *token++ = *rpp++;
+                       while (*rpp == _PSC) rpp++;
+                       break;
+               case '\0':
+                       break;
+               default:
+                       while (*rpp != _PPSC && *rpp != _PSC && *rpp != '\0')
+                               *token++ = *rpp++;
+                       break;
+               }
+       *token = '\0';
+       pp = rpp;
+       return(t);
+}
+
+
+
+/*
+ * patherr() prints the error message PATHERR to stderr stream and
+ * returns constant 1.
+ */
+patherr(mesg)
+       char *mesg;                     /* error message */
+{
+       int strlen();                   /* string length */
+
+       if (strlen(mesg) > 0)
+               warn("%s: %s", mesg, PATHERR);
+       else
+               warn("%s", PATHERR);
+       return(1);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/src/yes.c b/usr/src/new/new/spms/src/lib/libspms/src/yes.c
new file mode 100644 (file)
index 0000000..b66b720
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * yes() returns 1 if the user replies with a word starting with `y',
+ * otherwise zero. yes() eats up the rest of the line.
+ */
+#include <stdio.h>
+
+yes()
+{
+       register int c;                 /* current character */
+       int status = 0;                 /* return status */
+
+       while ((c = getchar()) == ' ' || c == '\t')
+               continue;
+       if (c == 'y')
+               status = 1;
+       while (c != '\n')
+               c = getchar();
+       return(status);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/argvtos.a b/usr/src/new/new/spms/src/lib/libspms/test/argvtos.a
new file mode 100644 (file)
index 0000000..2bbfabf
--- /dev/null
@@ -0,0 +1,41 @@
+!<arch>
+Iargvtos        418696250   968   27    100644  0         `
+Oargvtos        418696250   968   27    100644  48        `
+jan feb mar apr may jun jul aug sep oct nov dec
+Targvtos.c      418696253   968   27    100644  419       `
+/*
+ * argvtos()
+ */
+#include "null.h"
+
+char *PGN = "Targvtos";                        /* program name */
+
+static char *argv[] =
+       {
+       "jan",
+       "feb",
+       "mar",
+       "apr",
+       "may",
+       "jun",
+       "jul",
+       "aug",
+       "sep",
+       "oct",
+       "nov",
+       "dec"
+       };
+
+main()
+{
+       char *argvtos();                /* copy argument list to string */
+       char *string;                   /* receiving string */
+
+       if ((string = argvtos(12, argv)) == NULL)
+               exit(1);
+       else    {
+               printf("%s\n", string);
+               exit(0);
+               }
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/chproject.a b/usr/src/new/new/spms/src/lib/libspms/test/chproject.a
new file mode 100644 (file)
index 0000000..60beeec
--- /dev/null
@@ -0,0 +1,47 @@
+!<arch>
+Ochproject      418696255   968   27    100644  192       `
+../../../../src/lib/libspms
+Tchproject: mumble: no such project
+../../../../src/lib/libspms
+Tchproject: mumble: no such project
+../../../../src/lib/libspms
+Tchproject: mumble: no such project
+Tchproject.c    418696257   968   27    100644  362       `
+/*
+ * chproject()
+ */
+#include <stdio.h>
+#include "yesno.h"
+
+char *PGN = "Tchproject";              /* program name */
+
+main()
+{
+       int chproject();                /* change current working project */
+
+       if (chproject("^libspms") == NO)
+               exit(1);
+       printf("%s\n", getcwp());
+       fflush(stdout);
+       if (chproject("mumble") == NO)
+               exit(1);
+       printf("%s\n", getcwp());
+       fflush(stdout);
+       exit(0);
+}
+Tchproject.sh   418870290   968   27    100755  286       `
+#!/bin/csh -f
+#
+# chproject()
+#
+setenv HOME ../../../..
+setenv PROJECT ../../../../src/lib/libtree
+Tchproject >& T_OUTPUT
+unsetenv PROJECT
+Tchproject >>& T_OUTPUT
+setenv PROJECT ""
+Tchproject >>& T_OUTPUT
+diff T_OUTPUT Ochproject
+set diffstatus=$status
+rm -f T_OUTPUT
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/diff.a b/usr/src/new/new/spms/src/lib/libspms/test/diff.a
new file mode 100644 (file)
index 0000000..7887775
--- /dev/null
@@ -0,0 +1,39 @@
+!<arch>
+Idiff           418696263   968   27    100644  10        `
+diff test
+Odiff           418696263   968   27    100644  6         `
+0
+1
+2
+Tdiff.c         418696267   968   27    100644  155       `
+/*
+ * diff()
+ */
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       int diff();                     /* compare files and directories */
+
+       argv[0] = "diff";
+
+       exit(diff(argv));
+}
+
+Tdiff.sh        418870293   968   27    100755  273       `
+#!/bin/csh -f
+#
+# diff()
+#
+Tdiff Idiff Idiff >& /dev/null
+echo $status > T_OUTPUT
+Tdiff Idiff Odiff >& /dev/null
+echo $status >> T_OUTPUT
+Tdiff Idiff MUMBLE >& /dev/null
+echo $status >> T_OUTPUT
+diff T_OUTPUT Odiff
+set diffstatus = $status
+rm -f T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/fatal.a b/usr/src/new/new/spms/src/lib/libspms/test/fatal.a
new file mode 100644 (file)
index 0000000..7743863
--- /dev/null
@@ -0,0 +1,33 @@
+!<arch>
+Ofatal          418696272   968   27    100644  35        `
+Tfatal: ___this___is___test___1___
+
+Tfatal.c        418696275   968   27    100644  223       `
+/*
+ * fatal()
+ */
+
+char *PGN = "Tfatal";
+
+main()
+{
+       char one = '1';
+       char *s1 = "this";
+       char *s2 = "is";
+       char *s3 = "test";
+
+       fatal("___%s___%s___%s___%c___", s1, s2, s3, one);
+       fatal("___%s___%s___%s___", s1, s2, s3);
+}
+
+Tfatal.sh       418870295   968   27    100755  131       `
+#!/bin/csh -f
+#
+# fatal()
+#
+Tfatal >& T_OUTPUT
+cat T_OUTPUT | diff - Ofatal
+set diffstatus = $status
+rm T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/getcpd.a b/usr/src/new/new/spms/src/lib/libspms/test/getcpd.a
new file mode 100644 (file)
index 0000000..f68c443
--- /dev/null
@@ -0,0 +1,43 @@
+!<arch>
+Ogetcpd         418696279   968   27    100644  70        `
+project directory: work
+project root directory: ...
+regular directory
+Tgetcpd.c       418696281   968   27    100644  591       `
+/*
+ * getcpd()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "spms.h"
+
+char *PGN = "Tgetcpd";                 /* program name */
+
+main()
+{
+       int getcpd();                   /* get current working project dir */
+       PATH pb;                        /* project directory struct buffer */
+
+       while (getcpd(&pb) == 1)
+               {
+               if ((pb.p_mode&P_IFMT) == P_IFPROOT)
+                       printf("project root directory: %s\n", pb.p_alias);
+               else if ((pb.p_mode&P_IFMT) == P_IFPDIR)
+                       printf("project directory: %s\n", pb.p_alias);
+               chdir(PARENTDIR);
+               }
+       if ((pb.p_mode&P_IFMT) == P_IFREG)
+               printf("regular directory\n");
+       else
+               printf("bad pathname\n");
+       exit(0);
+}
+
+Tgetcpd.sh      418870296   968   27    100755  69        `
+#!/bin/csh -f
+#
+# getcpd()
+#
+Tgetcpd |& diff - Ogetcpd
+exit($status)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/getcwp.a b/usr/src/new/new/spms/src/lib/libspms/test/getcwp.a
new file mode 100644 (file)
index 0000000..dc21a71
--- /dev/null
@@ -0,0 +1,46 @@
+!<arch>
+Ogetcwp         418696284   968   27    100644  66        `
+a
+Tgetcwp: no project environment
+Tgetcwp: no project environment
+Tgetcwp.c       418696286   968   27    100644  345       `
+/*
+ * getcwp()
+ * getproject()
+ */
+#include <stdio.h>
+#include "null.h"
+
+char *PGN = "Tgetcwp";                 /* program name */
+
+main()
+{
+       char *getcwp();                 /* get current project pathname */
+       char *p;                        /* pathname pointer */
+
+       if ((p = getcwp()) != NULL)
+               {
+               printf("%s\n", p);
+               fflush(stdout);
+               }
+       else
+               warn("no project environment");
+       exit(0);
+}
+
+Tgetcwp.sh      418870298   968   27    100755  236       `
+#!/bin/csh -f
+#
+# getcwp()
+# getproject()
+#
+setenv PROJECT a
+Tgetcwp >& T_OUTPUT
+unsetenv PROJECT
+Tgetcwp >>& T_OUTPUT
+setenv PROJECT ""
+Tgetcwp >>& T_OUTPUT
+diff T_OUTPUT Ogetcwp
+set diffstatus=$status
+rm -f T_OUTPUT
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/gethdir.a b/usr/src/new/new/spms/src/lib/libspms/test/gethdir.a
new file mode 100644 (file)
index 0000000..41f2f51
--- /dev/null
@@ -0,0 +1,53 @@
+!<arch>
+Igethdir        418696290   968   27    100644  8         `
+root
+
+?
+Ogethdir        418974791   968   27    100644  78        `
+/
+../../../..
+Tgethdir: unknown user ?
+/
+../../../..
+Tgethdir: unknown user ?
+Tgethdir.c      418696292   968   27    100644  421       `
+/*
+ * gethdir()
+ */
+#include <stdio.h>
+
+#define NAMESIZE 10
+
+char *PGN = "Tgethdir";                        /* program name */
+
+main()
+{
+       char *gets();                   /* get line from stdin */
+       char *gethdir();                /* get home directory pathname */
+       char login[NAMESIZE];           /* login name */
+       char *pp;                       /* pathname pointer */
+
+       while (gets(login) != NULL)
+               if ((pp = gethdir(login)) != NULL)
+                       {
+                       printf("%s\n", pp);
+                       fflush(stdout);
+                       }
+       exit(0);
+}
+
+
+Tgethdir.sh     418974771   968   27    100755  231       `
+#!/bin/csh -f
+#
+# gethdir()
+#
+setenv ROOTPROJECT ../../../..
+Tgethdir < Igethdir >& T_OUTPUT
+setenv HOME ../../../..
+Tgethdir < Igethdir >>& T_OUTPUT
+diff T_OUTPUT Ogethdir
+set diffstatus = $status
+rm -f T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/getpwdir.a b/usr/src/new/new/spms/src/lib/libspms/test/getpwdir.a
new file mode 100644 (file)
index 0000000..ae5833d
--- /dev/null
@@ -0,0 +1,39 @@
+!<arch>
+Igetpwdir       418696296   968   27    100644  29        `
+/
+/usr/spool/uucppublic
+/etc
+
+Ogetpwdir       418696296   968   27    100644  51        `
+root
+uucp
+can't find /etc directory in /etc/passwd
+
+Tgetpwdir.c     418696298   968   27    100644  530       `
+/*
+ * gethdir()
+ */
+#include <pwd.h>
+#include <stdio.h>
+#include "path.h"
+
+char *PGN = "Tgetpwdir";               /* program name */
+
+main()
+{
+       char *gets();                   /* get line from stdin */
+       char dir[PATHSIZE];             /* home directory */
+       struct passwd *getpwdir();      /* get passwd struct for dir */
+       struct passwd *pw;              /* pointer to passwd struct */
+
+       while (gets(dir) != NULL)
+               {
+               if ((pw = getpwdir(dir)) != NULL)
+                       printf("%s\n", pw->pw_name);
+               else
+                       printf("can't find %s directory in /etc/passwd\n", dir);
+               fflush(stdout);
+               }
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/getshell.a b/usr/src/new/new/spms/src/lib/libspms/test/getshell.a
new file mode 100644 (file)
index 0000000..cf69c93
--- /dev/null
@@ -0,0 +1,46 @@
+!<arch>
+Ogetshell       418696300   968   27    100644  48        `
+C shell
+Bourne shell
+unknown shell
+Bourne shell
+Tgetshell.c     418696303   968   27    100644  408       `
+/*
+ * getshell()
+ */
+#include "bin.h"
+
+char *PGN = "Tgetshell";               /* program name */
+
+main()
+{
+       char *getshell();               /* get command shell pathname */
+       char *sv;                       /* pointer to shell variable */
+       int strcmp();                   /* string comparison */
+
+       sv = getshell();
+       if (strcmp(sv, CSH) == 0)
+               printf("C shell\n");
+       else if (strcmp(sv, SH) == 0)
+               printf("Bourne shell\n");
+       else
+               printf("unknown shell\n");
+       exit(0);
+}
+Tgetshell.sh    418870303   968   27    100755  288       `
+#!/bin/csh -f
+#
+# getshell()
+#
+setenv SHELL /bin/csh
+Tgetshell >& T_OUTPUT
+setenv SHELL /bin/sh
+Tgetshell >>& T_OUTPUT
+setenv SHELL "/usr/ucb/rsh"
+Tgetshell >>& T_OUTPUT
+unsetenv SHELL
+Tgetshell >>& T_OUTPUT
+diff T_OUTPUT Ogetshell
+set diffstatus=$status
+rm -f T_OUTPUT
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/getwd.a b/usr/src/new/new/spms/src/lib/libspms/test/getwd.a
new file mode 100644 (file)
index 0000000..88addb1
--- /dev/null
@@ -0,0 +1,40 @@
+!<arch>
+Igetwd          418696307   968   27    100644  41        `
+/
+/usr/man/man1
+/usr/man
+../lib
+..
+..
+..
+
+Ogetwd          418696307   968   27    100644  43        `
+/
+/usr/man/man1
+/usr/man
+/usr/lib
+/usr
+/
+/
+
+Tgetwd.c        418696309   968   27    100644  336       `
+/*
+ * getwd()
+ */
+#include "null.h"
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char *getwd();                  /* get current working directory */
+       char pathname[PATHSIZE];        /* destination directory */
+
+       while (gets(pathname) != NULL)
+               {
+               chdir(pathname);
+               getwd(pathname);
+               printf("%s\n", pathname);
+               }
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/ispdt.a b/usr/src/new/new/spms/src/lib/libspms/test/ispdt.a
new file mode 100644 (file)
index 0000000..2321db7
--- /dev/null
@@ -0,0 +1,38 @@
+!<arch>
+Iispdt          418696311   968   27    100644  37        `
+src
+print.1
+print.1.1
+print.a
+.1
+.a
+
+
+Oispdt          418696311   968   27    100644  120       `
+src is legal
+print.1 is legal
+print.1.1 is not legal
+print.a is not legal
+.1 is not legal
+.a is not legal
+ is not legal
+Tispdt.c        418696313   968   27    100644  348       `
+/*
+ * ispdt()
+ */
+#include "null.h"
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char type[TYPESIZE];            /* type label buffer */
+       int ispdt();                    /* is project dir type label legal? */
+
+       while (gets(type) != NULL)
+               if (ispdt(type))
+                       printf("%s is legal\n",type);
+               else
+                       printf("%s is not legal\n",type);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/mk_dir.a b/usr/src/new/new/spms/src/lib/libspms/test/mk_dir.a
new file mode 100644 (file)
index 0000000..c0f6ea8
--- /dev/null
@@ -0,0 +1,27 @@
+!<arch>
+Omk_dir         418696316   968   27    100644  29        `
+mkdir: T_OUTPUT: File exists
+
+Tmk_dir.c       418696319   968   27    100644  134       `
+/*
+ * mk_dir()
+ */
+main(argc, argv)
+int argc;
+char **argv;
+{
+       int mk_dir();
+
+       if (mk_dir(argv[1]) != 0)
+               exit(1);
+       else
+               exit(0);
+}
+Tmk_dir.sh      418870306   968   27    100755  113       `
+#!/bin/csh -f
+#
+# Tmk_dir
+#
+(Tmk_dir T_OUTPUT; Tmk_dir T_OUTPUT; rmdir T_OUTPUT) |& diff - Omk_dir
+exit($status)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/mkalias.a b/usr/src/new/new/spms/src/lib/libspms/test/mkalias.a
new file mode 100644 (file)
index 0000000..7746668
--- /dev/null
@@ -0,0 +1,44 @@
+!<arch>
+Imkalias        418696323   968   27    100644  102       `
+^
+/
+^^
+^libspms^test
+^libspms^test/xppath.a
+^libspms
+^libspms^test^work
+^libspms^test
+test
+?
+^libspms
+Omkalias        418696323   968   27    100644  53        `
+^
+/
+^
+test
+xppath.a
+libspms
+work
+test
+test
+?
+libspms
+
+Tmkalias.c      418696326   968   27    100644  315       `
+/*
+ * mkalias()
+ */
+#include <stdio.h>
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char *mkalias();                /* extract project directory alias */
+       char ppathname[PATHSIZE];       /* project pathname input buffer */
+
+       while (gets(ppathname) != NULL)
+               printf("%s\n",mkalias(ppathname));
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/mustfopen.a b/usr/src/new/new/spms/src/lib/libspms/test/mustfopen.a
new file mode 100644 (file)
index 0000000..acdeb79
--- /dev/null
@@ -0,0 +1,31 @@
+!<arch>
+Omustfopen      418696330   968   27    100644  29        `
+Tmustfopen: can't open ?????
+
+Tmustfopen.c    418696334   968   27    100644  222       `
+/*
+ * mustfopen()
+ */
+#include <stdio.h>
+
+char *PGN = "Tmustfopen";              /* program name */
+
+main()
+{
+       FILE *mustfopen();              /* must open file */
+       FILE *stream;                   /* file stream */
+
+       stream = mustfopen("?????","r");
+       exit(0);
+}
+Tmustfopen.sh   418870308   968   27    100755  143       `
+#!/bin/csh -f
+#
+# mustfopen()
+#
+Tmustfopen >& T_OUTPUT
+cat T_OUTPUT | diff - Omustfopen
+set diffstatus = $status
+rm T_OUTPUT
+exit($diffstatus)
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/optpath.a b/usr/src/new/new/spms/src/lib/libspms/test/optpath.a
new file mode 100644 (file)
index 0000000..528a909
--- /dev/null
@@ -0,0 +1,102 @@
+!<arch>
+Ioptpath        418696342   968   27    100644  508       `
+
+/
+/..
+/.
+./
+./..
+../
+../.
+//
+//.
+//..
+.//
+..//
+../..
+../../..
+../../../..
+../../../../
+a/b/..
+a/b/../../..
+a/b//..
+a/b//../../..
+a/b/./..
+a/b/./../../..
+a/b/../
+a/b/../../../c/d/../../..
+a/b/../../../c/d/../../../
+a/b/../../../c/d/../../../e
+a/b/../../../c/d/../../../e/
+a/b/../../../../c/d/../../../../e/
+/a/b/..
+/a/b/../../..
+/a/b//..
+/a/b//../../..
+/a/b/./..
+/a/b/./../../..
+/a/b/../
+/a/b/../../../c/d/../../..
+/a/b/../../../c/d/../../../
+/a/b/../../../c/d/../../../e
+/a/b/../../../../c/d/../../../../e/
+Ooptpath        418696342   968   27    100644  155       `
+
+/
+/
+/
+.
+..
+..
+..
+/
+/
+/
+.
+..
+../..
+../../..
+../../../..
+../../../..
+a
+..
+a
+..
+a
+..
+a
+../..
+../..
+../../e
+../../e
+../../../../e
+/a
+/
+/a
+/
+/a
+/
+/a
+/
+/
+/e
+/e
+
+Toptpath.c      418696345   968   27    100644  289       `
+/*
+ * optpath()
+ */
+#include "null.h"
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char *optpath();                /* optimize pathname */
+       char pathname[PATHSIZE];        /* pathname input buffer */
+
+       while (gets(pathname) != NULL)
+               printf("%s\n",optpath(pathname));
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pathcat.a b/usr/src/new/new/spms/src/lib/libspms/test/pathcat.a
new file mode 100644 (file)
index 0000000..8d92d05
--- /dev/null
@@ -0,0 +1,37 @@
+!<arch>
+Ipathcat        418696347   968   27    100644  335       `
+aaa bbb
+aaa/ bbb
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+Opathcat        418696348   968   27    100644  300       `
+aaa/bbb
+aaa/bbb
+Tpathcat: pathname too long
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+Tpathcat.c      418696350   968   27    100644  494       `
+/*
+ * pathcat()
+ */
+#include <stdio.h>
+#include "path.h"
+
+char *PGN = "Tpathcat";
+
+main()
+{
+       char buf[BUFSIZ];               /* input buffer */
+       char *gets();                   /* get a line from stdin */
+       char p1[PATHSIZE];              /* first pathname */
+       char p1_p2[PATHSIZE];           /* concatenated path */
+       char p2[PATHSIZE];              /* last pathname */
+       char *pathcat();                /* pathname concatenation */
+
+       while (gets(buf) != NULL)
+               {
+               sscanf(buf, "%s%s", p1, p2);
+               printf("%s\n", pathcat(p1_p2, p1, p2));
+               fflush(stdout);
+               }
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pathhead.a b/usr/src/new/new/spms/src/lib/libspms/test/pathhead.a
new file mode 100644 (file)
index 0000000..284f718
--- /dev/null
@@ -0,0 +1,34 @@
+!<arch>
+Ipathhead       418696353   968   27    100644  44        `
+/aaa
+/aaa/
+/aaa/bbb
+/aaa/bbb/
+/aaa/bbb//
+/
+
+Opathhead       418696353   968   27    100644  32        `
+
+/aaa
+/aaa
+/aaa/bbb
+/aaa/bbb/
+
+
+Tpathhead.c     418696358   968   27    100644  296       `
+/*
+ * pathhead()
+ */
+#include <stdio.h>
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char *pathhead();               /* remove pathname tail */
+       char pathname[PATHSIZE];        /* pathname input buffer */
+
+       while (gets(pathname) != NULL)
+               printf("%s\n",pathhead(pathname));
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pathtail.a b/usr/src/new/new/spms/src/lib/libspms/test/pathtail.a
new file mode 100644 (file)
index 0000000..6abedaa
--- /dev/null
@@ -0,0 +1,35 @@
+!<arch>
+Ipathtail       418696361   968   27    100644  44        `
+/aaa
+/aaa/
+/aaa/bbb
+/aaa/bbb/
+/aaa/bbb//
+/
+
+Opathtail       418696361   968   27    100644  13        `
+aaa
+
+bbb
+
+
+
+
+
+Tpathtail.c     418696365   968   27    100644  296       `
+/*
+ * pathtail()
+ */
+#include <stdio.h>
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char pathname[PATHSIZE];        /* pathname input buffer */
+       char *pathtail();               /* remove pathname head */
+
+       while (gets(pathname) != NULL)
+               printf("%s\n",pathtail(pathname));
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pdtmatch.a b/usr/src/new/new/spms/src/lib/libspms/test/pdtmatch.a
new file mode 100644 (file)
index 0000000..f003477
--- /dev/null
@@ -0,0 +1,152 @@
+!<arch>
+Ipdtmatch       418696369   968   27    100644  2311      `
+...|:^^:dp=.:dt=project:dd=SPMS Software Project Management System:
+....|:^^:dp=..:
+include|:dp=include:dt=include/print.1/src/update.1:dd=header files:
+lib|:dp=lib:dt=binary:dd=makefile templates, object code libraries:
+work|:dp=work:dt=workbench:dd=SPMS workbench:
+src|:dp=src:dt=:dd=source:
+binsrc|:dp=src/bin:dt=:dd=command source:
+libsrc|:dp=src/lib:dt=:dd=library source:
+libslist|:^^:dp=src/lib/libslist:
+libspms|:^^:dp=src/lib/libspms:
+libtree|:^^:dp=src/lib/libtree:
+libpdb|:^^:dp=src/lib/libpdb:
+mkmf|:dp=src/bin/mkmf:dt=cmd/print.2/src/update.3:dd=mkmf - makefile editor:
+mkproject|:dp=src/bin/mkproject:dt=cmd/print.2/src/update.3:dd=mkproject - make a project root directory:
+pd|:dp=src/bin/pd:dt=cmd/print.2/src/update.3:dd=pd - change current project directory:
+pmkdir|:dp=src/bin/pmkdir:dt=cmd/print.2/src/update.3:dd=pmkdir - make a project directory:
+pcp|:dp=src/bin/pcp:dt=cmd/print.2/src/update.3:dd=pcp, pcopy - copy files:
+pmv|:dp=src/bin/pmv:dt=cmd/print.2/src/update.3:dd=pmv, pmove - move or rename files:
+ppd|:dp=src/bin/ppd:dt=cmd/print.2/src/update.3:dd=ppd - list project directories:
+chproject|:dp=src/bin/chproject:dt=cmd/print.2/src/update.3:dd=chproject - change current project:
+pwp|:dp=src/bin/pwp:dt=cmd/print.2/src/update.3:dd=pwp - path to working project:
+plog|:dp=src/bin/plog:dt=cmd/print.2/src/update.3:dd=plog - record, edit, print progress of a project:
+pexec|:dp=src/bin/pexec:dt=cmd/print.2/src/update.3:dd=pexec - execute command over project hierarchy:
+man|:dp=man:dt=:dd=manual:
+pfind|:dp=src/bin/pfind:dt=cmd/print.2/src/update.3:dd=pfind - find files in a project:
+pdiff|:dp=src/bin/pdiff:dt=cmd/print.2/src/update.3:dd=pdiff - differential project comparator:
+mtime|:dp=src/bin/mtime:dt=cmd/print.2/src/update.3:dd=mtime - change last-modified file times:
+phelp|:dp=src/bin/phelp:dt=cmd/print.2/src/update.3:dd=phelp - on-line help for a project:
+prmdir|:dp=src/bin/prmdir:dt=cmd/print.2/src/update.3:dd=prmdir - remove a project directory:
+rmproject|:dp=src/bin/rmproject:dt=cmd/print.2/src/update.3:dd=rmproject - remove a project root directory:
+help|:dp=help:dt=:dd=help topics:
+libhash|:^^:dp=src/lib/libhash:
+man1|:dp=man/man1:dt=man.1:dd=command manual:
+man3|:dp=man/man3:dt=man.3:dd=library manual:
+bin|:dp=bin:dt=binary:dd=SPMS maintenance commands:
+
+Opdtmatch       418696369   968   27    100644  305       `
+mkmf
+mkproject
+pd
+pmkdir
+pcp
+pmv
+ppd
+chproject
+pwp
+plog
+pexec
+pfind
+pdiff
+mtime
+phelp
+prmdir
+rmproject
+mkmf
+mkproject
+pd
+pmkdir
+pcp
+pmv
+ppd
+chproject
+pwp
+plog
+pexec
+pfind
+pdiff
+mtime
+phelp
+prmdir
+rmproject
+...
+....
+lib
+work
+src
+binsrc
+libsrc
+libslist
+libspms
+libtree
+libpdb
+man
+help
+libhash
+man1
+man3
+bin
+
+Tpdtmatch.c     418696373   968   27    100644  1583      `
+/*
+ * pdtmatch()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "pdtyp.h"
+#include "pld.h"
+#include "yesno.h"
+
+char *PGN = "Tpdtmatch";               /* program name */
+
+main()
+{
+       int closepdb();                 /* close database */
+       int pdtmatch();                 /* match project dir type label expr */
+       int pdtparse();                 /* parse boolean type label expr */
+       PATH *path;                     /* pathname struct pointer */
+       PATH *readpld();                /* read next alias+pathname */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       PDTYP postfix1;                 /* postfix type expression */
+       PDTYP postfix2;                 /* postfix type expression */
+       PDTYP postfix3;                 /* postfix type expression */
+       void rewindpdb();               /* rewind database */
+       
+       pdbp = mustopenpdb("Ipdtmatch", ".", "r");
+
+       /* print only directories which match `src&(cmd|lib)' labels */
+       if (pdtparse("src&(cmd|lib)", &postfix1) == NO)
+               exit(1);
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               if (pdtmatch(&postfix1, path->p_type) == YES)
+                       printf("%s\n", path->p_alias);
+               }
+
+       /* print only directories which match `print&!include' labels */
+       rewindpdb(pdbp);
+       if (pdtparse("print&!include", &postfix2) == NO)
+               exit(1);
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               if (pdtmatch(&postfix2, path->p_type) == YES)
+                       printf("%s\n", path->p_alias);
+               }
+
+       /* print only directories which do not match `src' labels */
+       rewindpdb(pdbp);
+       if (pdtparse("!src", &postfix3) == NO)
+               exit(1);
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               if (pdtmatch(&postfix3, path->p_type) == YES)
+                       printf("%s\n", path->p_alias);
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pdtparse.a b/usr/src/new/new/spms/src/lib/libspms/test/pdtparse.a
new file mode 100644 (file)
index 0000000..4afaa96
--- /dev/null
@@ -0,0 +1,55 @@
+!<arch>
+Ipdtparse       418696376   968   27    100644  114       `
+(man & cmd) | !(src & include)
+!((man & cmd) & ((src|lib) & V4BSD)) | R3
+((man & cmd) & ((src&lib) & V4BSD)) & R3
+Opdtparse       418696376   968   27    100644  103       `
+man cmd & src include & ! | 
+man cmd & src lib | V4BSD & & ! R3 | 
+man cmd & src lib & V4BSD & & R3 & 
+
+Tpdtparse.c     418696379   968   27    100644  777       `
+/*
+ * pdtparse()
+ */
+#include "stdio.h"
+#include "pdtyp.h"
+
+char *PGN = "Tpdtparse";
+
+main()
+{
+       char buf[BUFSIZ];               /* input buffer */
+       char *gets();                   /* get line from stdin */
+       int i;                          /* postfix expression index */
+       int pdtparse();                 /* parse boolean type expression */
+       PDTYP postfix;                  /* postfix type expression */
+
+       while (gets(buf) != NULL)
+               {
+               pdtparse(buf, &postfix);
+               for (i = 0; i < postfix.pfxsize; i++)
+                       switch ((postfix.pfx)[i].p_class)
+                               {
+                               case B_ID:
+                                       printf("%s ", (postfix.pfx)[i].p_id);
+                                       break;
+                               case B_AND:
+                                       printf("& ");
+                                       break;
+                               case B_OR:
+                                       printf("| ");
+                                       break;
+                               case B_NOT:
+                                       printf("! ");
+                                       break;
+                               default:
+                                       printf("? ");
+                                       break;
+                               }
+               printf("\n");
+               free(postfix.pfx);
+               }
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pdtyp.a b/usr/src/new/new/spms/src/lib/libspms/test/pdtyp.a
new file mode 100644 (file)
index 0000000..91c8d13
--- /dev/null
@@ -0,0 +1,175 @@
+!<arch>
+Ipdtyp          418696382   968   27    100644  663       `
+...|:^^:dp=.:dd=SPMS Software Project Management System:dt=project:
+....|:^^:dp=..:
+bin|:dp=bin:dt=:dd=:
+include|:dp=include:dt=src:dd=:
+lib|:dp=lib:dt=:dd=:
+work|:dp=work:dt=:dd=:
+src|:dp=src:dt=:dd=:
+cmd|:dp=src/cmd:dt=:dd=:
+srclib|:dp=src/lib:dt=:dd=:
+libpdb|:^^:dp=src/lib/libpdb:
+libslist|:^^:dp=src/lib/libslist:
+libspms|:^^:dp=src/lib/libspms:
+libstree|:^^:dp=src/lib/libstree:
+mkmf|:dp=src/cmd/mkmf:dt=src.2:dd=:
+mkproject|:dp=src/cmd/mkproject:dt=src.2:dd=:
+pd|:dp=src/cmd/pd:dt=src.2:dd=change current project directory:
+pmkdir|:dp=src/cmd/pmkdir:dt=src.2:dd=make a project directory:
+pcp|:dp=src/cmd/pcp:dt=src.2:dd=:
+pmv|:dp=src/cmd/pmv:dt=src.2:dd=:
+
+Opdtyp          418696382   968   27    100644  570       `
+include src
+       src
+       cmd/src
+       cmd/program/src
+       cmd/src
+       cmd
+       
+       cmd
+       cmd/src.2
+mkmf src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+mkproject src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+pd src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+pmkdir src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+pcp src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+pmv src.2
+       src.2
+       cmd/src.2
+       cmd/program/src.2
+       cmd/src.2
+       cmd
+       
+       cmd
+       cmd/src.2
+Tpdtyp.c        418696385   968   27    100644  2190      `
+/*
+ * pdtcpy()
+ * pdtfind()
+ * pdtinsert()
+ * pdtrm()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "yesno.h"
+
+char *PGN = "Tpdtyp";                  /* program name */
+
+main()
+{
+       char *pdtcpy();                 /* copy project directory type label */
+       char *pdtfind();                /* find type label in buffer */
+       char *tb;                       /* type label buffer pointer */
+       char type[TYPESIZE];            /* project dir type label buffer */
+       int closepdb();                 /* close database */
+       int pdtinsert();                /* insert project dir type label */
+       PATH *path;                     /* pathname struct pointer */
+       PATH *readpld();                /* read next alias+pathname */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void pdtrm();                   /* remove project dir type label */
+       
+       pdbp = mustopenpdb("Ipdtyp", ".", "r");
+
+       /* operations on `src.*' directories only */
+       while ((path = readpld(pdbp)) != NULL)
+               if ((tb = pdtfind("src", path->p_type)) != NULL)
+                       {
+                       printf("%s %s\n", path->p_alias, path->p_type);
+                       printf("\t%s\n", pdtcpy(type, tb));
+                       fflush(stdout);
+
+                       /* add `cmd' type label */
+                       if (pdtinsert("cmd", path->p_type) == NO)
+                               warn("\tcmd type label exists");
+                       else    {
+                               printf("\t%s\n", path->p_type);
+                               fflush(stdout);
+                               }
+
+                       /* add `program' type label */
+                       if (pdtinsert("program", path->p_type) == NO)
+                               warn("\tprogram type label exists");
+                       else    {
+                               printf("\t%s\n", path->p_type);
+                               fflush(stdout);
+                               }
+                       
+                       /* remove `program' type label */
+                       pdtrm("program", path->p_type);
+                       printf("\t%s\n", path->p_type);
+                       fflush(stdout);
+
+                       /* remove `src.*' type label */
+                       pdtrm("src", path->p_type);
+                       printf("\t%s\n", path->p_type);
+                       fflush(stdout);
+
+                       /* remove `cmd' type label */
+                       pdtrm("cmd", path->p_type);
+                       printf("\t%s\n", path->p_type);
+                       fflush(stdout);
+
+                       /* add `cmd' type label */
+                       if (pdtinsert("cmd", path->p_type) == NO)
+                               warn("\tcmd type label exists");
+                       else    {
+                               printf("\t%s\n", path->p_type);
+                               fflush(stdout);
+                               }
+
+                       /* add `src.2' type label */
+                       if (pdtinsert("src.2", path->p_type) == NO)
+                               warn("\tsrc.2 type label exists");
+                       else    {
+                               printf("\t%s\n", path->p_type);
+                               fflush(stdout);
+                               }
+                       }
+
+       closepdb(pdbp);
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pfxcpy.a b/usr/src/new/new/spms/src/lib/libspms/test/pfxcpy.a
new file mode 100644 (file)
index 0000000..e7ed7c3
--- /dev/null
@@ -0,0 +1,30 @@
+!<arch>
+Ipfxcpy         418696389   968   27    100644  29        `
+src
+src.update
+src.update.1
+
+
+Opfxcpy         418696389   968   27    100644  13        `
+src
+src
+src
+
+
+Tpfxcpy.c       418696392   968   27    100644  304       `
+/*
+ * pfxcpy()
+ */
+#include <stdio.h>
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char inbuf[BUFSIZ];             /* input buffer */
+       char outbuf[BUFSIZ];            /* output buffer */
+       char *pfxcpy();                 /* copy string prefix */
+
+       while (gets(inbuf) != NULL)
+               printf("%s\n", pfxcpy(outbuf, inbuf));
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/ppathcat.a b/usr/src/new/new/spms/src/lib/libspms/test/ppathcat.a
new file mode 100644 (file)
index 0000000..0e36ad4
--- /dev/null
@@ -0,0 +1,37 @@
+!<arch>
+Ippathcat       418696399   968   27    100644  147       `
+aaa bbb
+aaa/ bbb
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+Oppathcat       418696399   968   27    100644  182       `
+aaa^bbb
+aaa/^bbb
+Tppathcat: project pathname too long
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+Tppathcat.c     418696403   968   27    100644  506       `
+/*
+ * ppathcat()
+ */
+#include <stdio.h>
+#include "path.h"
+
+char *PGN = "Tppathcat";
+
+main()
+{
+       char buf[BUFSIZ];               /* input buffer */
+       char *gets();                   /* get a line from stdin */
+       char p1[PATHSIZE];              /* first pathname */
+       char p1_p2[PATHSIZE];           /* concatenated path */
+       char p2[PATHSIZE];              /* last pathname */
+       char *ppathcat();               /* project pathname concatenation */
+
+       while (gets(buf) != NULL)
+               {
+               sscanf(buf, "%s%s", p1, p2);
+               printf("%s\n", ppathcat(p1_p2, p1, p2));
+               fflush(stdout);
+               }
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/ppathhead.a b/usr/src/new/new/spms/src/lib/libspms/test/ppathhead.a
new file mode 100644 (file)
index 0000000..0813f86
--- /dev/null
@@ -0,0 +1,35 @@
+!<arch>
+Ippathhead      418696406   968   27    100644  44        `
+^aaa
+^aaa^
+^aaa^bbb
+^aaa^bbb^
+^aaa^bbb^^
+^
+
+Oppathhead      418696406   968   27    100644  32        `
+
+^aaa
+^aaa
+^aaa^bbb
+^aaa^bbb^
+
+
+Tppathhead.c    418696409   968   27    100644  307       `
+/*
+ * ppathhead()
+ */
+#include <stdio.h>
+#include "path.h"
+
+main()
+{
+       char *gets();                   /* get a line from stdin */
+       char *ppathhead();              /* remove project pathname tail */
+       char pathname[PATHSIZE];        /* pathname input buffer */
+
+       while (gets(pathname) != NULL)
+               printf("%s\n",ppathhead(pathname));
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/pperror.a b/usr/src/new/new/spms/src/lib/libspms/test/pperror.a
new file mode 100644 (file)
index 0000000..da5ccf6
--- /dev/null
@@ -0,0 +1,22 @@
+!<arch>
+Ipperror        418696412   968   27    100644  0         `
+Opperror        418696412   968   27    100644  45        `
+Tpperror: UNKNOWN: No such file or directory
+
+Tpperror.c      418696414   968   27    100644  240       `
+/*
+ * pperror()
+ */
+#include <stdio.h>
+
+char *PGN = "Tpperror";                        /* program name */
+
+main()
+{
+       FILE *fopen();                  /* open a file */
+       FILE *fp;                       /* file stream */
+
+       if ((fp = fopen("UNKNOWN", "r")) == NULL)
+               pperror("UNKNOWN");
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/readpld.a b/usr/src/new/new/spms/src/lib/libspms/test/readpld.a
new file mode 100644 (file)
index 0000000..6a180c8
--- /dev/null
@@ -0,0 +1,180 @@
+!<arch>
+Ireadpld        418696428   968   27    100644  2206      `
+...|:^^:dp=.:dt=project/root:dd=SPMS Software Project Management System:
+....|:^^:dp=..:
+include|:dp=include:dt=include/src:dd=header files:
+lib|:dp=lib:dt=binary:dd=makefile templates, object code libraries:
+work|:dp=work:dt=workbench:dd=SPMS workbench:
+src|:dp=src:dt=:dd=source:
+binsrc|:dp=src/bin:dt=:dd=command source:
+libsrc|:dp=src/lib:dt=:dd=library source:
+libslist|:^^:dp=src/lib/libslist:dt=:
+libspms|:^^:dp=src/lib/libspms:dt=:
+libtree|:^^:dp=src/lib/libtree:dt=:
+libpdb|:^^:dp=src/lib/libpdb:dt=:
+mkmf|:dp=src/bin/mkmf:dt=cmd/make.2/src.cmd:dd=mkmf - makefile editor:
+mkproject|:dp=src/bin/mkproject:dt=cmd/make.2/src.cmd:dd=mkproject - make a project root directory:
+pd|:dp=src/bin/pd:dt=cmd/make.2/src.cmd:dd=pd - change current project directory:
+pmkdir|:dp=src/bin/pmkdir:dt=cmd/make.2/src.cmd:dd=pmkdir - make a project directory:
+pcp|:dp=src/bin/pcp:dt=cmd/make.2/src.cmd:dd=pcp, pcopy - copy files:
+pmv|:dp=src/bin/pmv:dt=cmd/make.2/src.cmd:dd=pmv, pmove - move or rename files:
+ppd|:dp=src/bin/ppd:dt=cmd/make.2/src.cmd:dd=ppd - list project directories:
+chproject|:dp=src/bin/chproject:dt=cmd/make.2/src.cmd:dd=chproject - change current project:
+pwp|:dp=src/bin/pwp:dt=cmd/make.2/src.cmd:dd=pwp - path to working project:
+plog|:dp=src/bin/plog:dt=cmd/make.2/src.cmd:dd=plog - record, edit, print progress of a project:
+pexec|:dp=src/bin/pexec:dt=cmd/src.cmd:dd=pexec - execute command over project hierarchy:
+man|:dp=man:dt=:dd=manual:
+pfind|:dp=src/bin/pfind:dt=cmd/make.2/src.cmd:dd=pfind - find files in a project:
+pdiff|:dp=src/bin/pdiff:dt=cmd/make.2/src.cmd:dd=pdiff - differential project comparator:
+mtime|:dp=src/bin/mtime:dt=cmd/make.2/src.cmd:dd=mtime - change last-modified file times:
+phelp|:dp=src/bin/phelp:dt=cmd/make.2/src.cmd:dd=phelp - on-line help for a project:
+prmdir|:dp=src/bin/prmdir:dt=cmd/make.2/src.cmd:dd=prmdir - remove a project directory:
+rmproject|:dp=src/bin/rmproject:dt=cmd/make.2/src.cmd:dd=rmproject - remove a project root directory:
+help|:dp=help:dt=:dd=help topics:
+libhash|:^^:dp=src/lib/libhash:
+man1|:dp=man/man1:dt=man.1:dd=command manual:
+man3|:dp=man/man3:dt=man.3:dd=library manual:
+bin|:dp=bin:dt=binary:dd=SPMS maintenance commands:
+Oreadpld        418696428   968   27    100644  4342      `
+... ^^ . project/root SPMS Software Project Management System
+.... ^^ ..
+include include include/src header files
+lib lib binary makefile templates, object code libraries
+work work workbench SPMS workbench
+src src source
+binsrc src/bin command source
+libsrc src/lib library source
+libslist ^^ src/lib/libslist
+libspms ^^ src/lib/libspms
+libtree ^^ src/lib/libtree
+libpdb ^^ src/lib/libpdb
+mkmf src/bin/mkmf cmd/make.2/src.cmd mkmf - makefile editor
+mkproject src/bin/mkproject cmd/make.2/src.cmd mkproject - make a project root directory
+pd src/bin/pd cmd/make.2/src.cmd pd - change current project directory
+pmkdir src/bin/pmkdir cmd/make.2/src.cmd pmkdir - make a project directory
+pcp src/bin/pcp cmd/make.2/src.cmd pcp, pcopy - copy files
+pmv src/bin/pmv cmd/make.2/src.cmd pmv, pmove - move or rename files
+ppd src/bin/ppd cmd/make.2/src.cmd ppd - list project directories
+chproject src/bin/chproject cmd/make.2/src.cmd chproject - change current project
+pwp src/bin/pwp cmd/make.2/src.cmd pwp - path to working project
+plog src/bin/plog cmd/make.2/src.cmd plog - record, edit, print progress of a project
+pexec src/bin/pexec cmd/src.cmd pexec - execute command over project hierarchy
+man man manual
+pfind src/bin/pfind cmd/make.2/src.cmd pfind - find files in a project
+pdiff src/bin/pdiff cmd/make.2/src.cmd pdiff - differential project comparator
+mtime src/bin/mtime cmd/make.2/src.cmd mtime - change last-modified file times
+phelp src/bin/phelp cmd/make.2/src.cmd phelp - on-line help for a project
+prmdir src/bin/prmdir cmd/make.2/src.cmd prmdir - remove a project directory
+rmproject src/bin/rmproject cmd/make.2/src.cmd rmproject - remove a project root directory
+help help help topics
+libhash ^^ src/lib/libhash
+man1 man/man1 man.1 command manual
+man3 man/man3 man.3 library manual
+bin bin binary SPMS maintenance commands
+include include include/src header files
+mkmf src/bin/mkmf cmd/make.2/src.cmd mkmf - makefile editor
+mkproject src/bin/mkproject cmd/make.2/src.cmd mkproject - make a project root directory
+pd src/bin/pd cmd/make.2/src.cmd pd - change current project directory
+pmkdir src/bin/pmkdir cmd/make.2/src.cmd pmkdir - make a project directory
+pcp src/bin/pcp cmd/make.2/src.cmd pcp, pcopy - copy files
+pmv src/bin/pmv cmd/make.2/src.cmd pmv, pmove - move or rename files
+ppd src/bin/ppd cmd/make.2/src.cmd ppd - list project directories
+chproject src/bin/chproject cmd/make.2/src.cmd chproject - change current project
+pwp src/bin/pwp cmd/make.2/src.cmd pwp - path to working project
+plog src/bin/plog cmd/make.2/src.cmd plog - record, edit, print progress of a project
+pexec src/bin/pexec cmd/src.cmd pexec - execute command over project hierarchy
+pfind src/bin/pfind cmd/make.2/src.cmd pfind - find files in a project
+pdiff src/bin/pdiff cmd/make.2/src.cmd pdiff - differential project comparator
+mtime src/bin/mtime cmd/make.2/src.cmd mtime - change last-modified file times
+phelp src/bin/phelp cmd/make.2/src.cmd phelp - on-line help for a project
+prmdir src/bin/prmdir cmd/make.2/src.cmd prmdir - remove a project directory
+rmproject src/bin/rmproject cmd/make.2/src.cmd rmproject - remove a project root directory
+mkmf src/bin/mkmf cmd/make.2/src.cmd mkmf - makefile editor
+mkproject src/bin/mkproject cmd/make.2/src.cmd mkproject - make a project root directory
+pd src/bin/pd cmd/make.2/src.cmd pd - change current project directory
+pmkdir src/bin/pmkdir cmd/make.2/src.cmd pmkdir - make a project directory
+pcp src/bin/pcp cmd/make.2/src.cmd pcp, pcopy - copy files
+pmv src/bin/pmv cmd/make.2/src.cmd pmv, pmove - move or rename files
+ppd src/bin/ppd cmd/make.2/src.cmd ppd - list project directories
+chproject src/bin/chproject cmd/make.2/src.cmd chproject - change current project
+pwp src/bin/pwp cmd/make.2/src.cmd pwp - path to working project
+plog src/bin/plog cmd/make.2/src.cmd plog - record, edit, print progress of a project
+pfind src/bin/pfind cmd/make.2/src.cmd pfind - find files in a project
+pdiff src/bin/pdiff cmd/make.2/src.cmd pdiff - differential project comparator
+mtime src/bin/mtime cmd/make.2/src.cmd mtime - change last-modified file times
+phelp src/bin/phelp cmd/make.2/src.cmd phelp - on-line help for a project
+prmdir src/bin/prmdir cmd/make.2/src.cmd prmdir - remove a project directory
+rmproject src/bin/rmproject cmd/make.2/src.cmd rmproject - remove a project root directory
+Treadpld.c      418696431   968   27    100644  1691      `
+/*
+ * readpld()
+ */
+#include <stdio.h>
+#include "path.h"
+#include "pdb.h"
+#include "pld.h"
+#include "yesno.h"
+
+char *PGN = "Treadpld";                        /* program name */
+
+main()
+{
+       char *pdtfind();                /* find type label in buffer */
+       int closepdb();                 /* close database */
+       PATH *path;                     /* pathname struct pointer */
+       PATH *readpld();                /* read next alias+pathname */
+       PDB *mustopenpdb();             /* must open database or die */
+       PDB *pdbp;                      /* database stream */
+       void rewindpdb();               /* rewind database */
+       
+       pdbp = mustopenpdb("Ireadpld", ".", "r");
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               printf("%s", path->p_alias);
+               if (path->p_mode == P_IFPROOT)
+                       printf(" %s", PROOTDIR);
+               printf(" %s", path->p_path);
+               if (*path->p_type != '\0')
+                       printf(" %s", path->p_type);
+               if (*path->p_desc != '\0')
+                       printf(" %s", path->p_desc);
+               printf("\n");
+               }
+
+       /* print only directories with `src.*' labels */
+       rewindpdb(pdbp);
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               if (pdtfind("src", path->p_type) != NULL)
+                       {
+                       printf("%s", path->p_alias);
+                       if (path->p_mode == P_IFPROOT)
+                               printf(" %s", PROOTDIR);
+                       printf(" %s", path->p_path);
+                       printf(" %s", path->p_type);
+                       if (*path->p_desc != '\0')
+                               printf(" %s", path->p_desc);
+                       printf("\n");
+                       }
+               }
+
+       /* print only directories with `make.2' labels */
+       rewindpdb(pdbp);
+       while ((path = readpld(pdbp)) != NULL)
+               {
+               if (pdtfind("make.2", path->p_type) != NULL)
+                       {
+                       printf("%s", path->p_alias);
+                       if (path->p_mode == P_IFPROOT)
+                               printf(" %s", PROOTDIR);
+                       printf(" %s", path->p_path);
+                       printf(" %s", path->p_type);
+                       if (*path->p_desc != '\0')
+                               printf(" %s", path->p_desc);
+                       printf("\n");
+                       }
+               }
+       closepdb(pdbp);
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/rm_dir.a b/usr/src/new/new/spms/src/lib/libspms/test/rm_dir.a
new file mode 100644 (file)
index 0000000..34bdf58
--- /dev/null
@@ -0,0 +1,32 @@
+!<arch>
+Orm_dir         418696434   968   27    100644  43        `
+rmdir: T_OUTPUT: No such file or directory
+
+Trm_dir.c       418696436   968   27    100644  158       `
+/*
+ * rm_dir()
+ */
+
+char *PGN = "rm_dir";
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+       int rm_dir();
+
+       if (rm_dir(argv[1]) != 0)
+               exit(1);
+       else
+               exit(0);
+}
+Trm_dir.sh      418870324   968   27    100755  176       `
+#!/bin/csh -f
+#
+# Trm_dir
+#
+(mkdir T_OUTPUT; Trm_dir T_OUTPUT; Trm_dir T_OUTPUT) >& T_OUTPUT1
+diff T_OUTPUT1 Orm_dir
+set diffstatus = $status
+rm -f T_OUTPUT1
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/warn.a b/usr/src/new/new/spms/src/lib/libspms/test/warn.a
new file mode 100644 (file)
index 0000000..3827f82
--- /dev/null
@@ -0,0 +1,41 @@
+!<arch>
+Owarn           418696446   968   27    100644  124       `
+Twarn: ___this___is___test___1___
+Twarn: ___this___is___test___
+Twarn: ___this___is___
+Twarn: ___this___
+Twarn: ___
+Twarn: 
+Twarn.c         418696448   968   27    100644  309       `
+/*
+ * warn()
+ */
+
+char *PGN = "Twarn";
+
+main()
+{
+       char one = '1';
+       char *s1 = "this";
+       char *s2 = "is";
+       char *s3 = "test";
+
+       warn("___%s___%s___%s___%c___", s1, s2, s3, one);
+       warn("___%s___%s___%s___", s1, s2, s3);
+       warn("___%s___%s___", s1, s2);
+       warn("___%s___", s1);
+       warn("___");
+       warn("");
+       exit(0);
+}
+
+Twarn.sh        418870326   968   27    100755  128       `
+#!/bin/csh -f
+#
+# warn()
+#
+Twarn >& T_OUTPUT
+cat T_OUTPUT | diff - Owarn
+set diffstatus = $status
+rm T_OUTPUT
+exit($diffstatus)
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/xorpath.a b/usr/src/new/new/spms/src/lib/libspms/test/xorpath.a
new file mode 100644 (file)
index 0000000..6aa28c3
--- /dev/null
@@ -0,0 +1,41 @@
+!<arch>
+Ixorpath        418696452   968   27    100644  77        `
+/aaa /aaa
+/aaa /aaa/
+/aaa /aaa/bbb
+/aaa/bbb /aaa
+/aaa /bbb
+/aaa aaa
+/aaa bbb
+
+Oxorpath        418696452   968   27    100644  24        `
+
+
+bbb
+/aaa
+/bbb
+aaa
+bbb
+Txorpath.c      418696456   968   27    100644  433       `
+/*
+ * xorpath()
+ */
+#include <stdio.h>
+#include "path.h"
+
+main()
+{
+       char buf[BUFSIZ];               /* input buffer */
+       char *gets();                   /* get a line from stdin */
+       char path[PATHSIZE];            /* pathname to be checked */
+       char subpath[PATHSIZE];         /* subpathname to be checked */
+       char *xorpath();                /* remove subpathname */
+
+       while (gets(buf) != NULL)
+               {
+               sscanf(buf, "%s%s", subpath, path);
+               printf("%s\n", xorpath(subpath, path));
+               }
+       exit(0);
+}
+
diff --git a/usr/src/new/new/spms/src/lib/libspms/test/yes.a b/usr/src/new/new/spms/src/lib/libspms/test/yes.a
new file mode 100644 (file)
index 0000000..2c8143f
--- /dev/null
@@ -0,0 +1,31 @@
+!<arch>
+Iyes            418696467   968   27    100644  42        `
+yes
+y
+ye
+   yes
+       yes
+       yes     
+       y     
+
+       no      
+Oyes            418696468   968   27    100644  28        `
+yes
+yes
+yes
+yes
+yes
+yes
+yes
+Tyes.c          418696470   968   27    100644  106       `
+/*
+ * yes()
+ */
+main()
+{
+       int yes();                      /* is reply yes? */
+
+       while (yes())
+               printf("yes\n");
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/lib/t.Makefile b/usr/src/new/new/spms/src/lib/libtree/lib/t.Makefile
new file mode 100644 (file)
index 0000000..39cead4
--- /dev/null
@@ -0,0 +1,15 @@
+CFLAGS       = -I../../../../include
+
+LDFLAGS              =
+
+LIBS         = ../../../../lib/libtree.a \
+               ../../../../lib/libspms.a
+
+LINKER       = cc
+
+OBJS         =
+
+PROGRAM              =
+
+$(PROGRAM):     $(OBJS) $(LIBS)
+               @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
diff --git a/usr/src/new/new/spms/src/lib/libtree/src/tree.c b/usr/src/new/new/spms/src/lib/libtree/src/tree.c
new file mode 100644 (file)
index 0000000..140a4be
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * tree() searchs for a key in a binary tree. If the search is
+ * unsuccessful a new node is added to the tree.
+ */
+#include "tree.h"
+#include "null.h"
+
+TREE *
+tree(p, key)
+       TREE *p;                        /* current node pointer */
+       char *key;                      /* pointer to key */
+{
+       TREE *talloc();                 /* allocate a binary tree node */
+       char *strsav();                 /* save a string */
+       int comp;                       /* compare key values */
+       int strcmp();                   /* string comparison */
+
+       if (p == NULL)
+               {                       /* a new key has arrived */
+               if ((p = talloc()) == NULL ||
+                   (p->key = strsav(key)) == NULL)
+                       fatal("out of memory");
+               p->count = 1;
+               p->left = p->right = NULL;
+               }
+       else if ((comp = strcmp(key, p->key)) < 0)
+               p->left = tree(p->left, key);
+       else if (comp > 0)
+               p->right = tree(p->right, key);
+       else if (comp == 0)
+               p->count++;
+       return(p);
+}
+
+
+
+/*
+ * talloc() allocates memory for a binary tree node.
+ */
+static TREE *
+talloc()
+{
+       char *malloc();                 /* memory allocator */
+
+       return((TREE *) malloc(sizeof(TREE)));
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/src/treerm.c b/usr/src/new/new/spms/src/lib/libtree/src/treerm.c
new file mode 100644 (file)
index 0000000..b1ebb43
--- /dev/null
@@ -0,0 +1,82 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * treerm() removes a node from a binary tree. If key is null, the entire
+ * tree is removed.
+ */
+#include "tree.h"
+#include "null.h"
+
+static TREE *q;                                /* node to be deleted */
+
+TREE *
+treerm(p, key)
+       TREE *p;                        /* current node pointer */
+       char *key;                      /* pointer to key */
+{
+       int comp;                       /* compare key values */
+       int strcmp();                   /* string comparison */
+       TREE *rmtl();                   /* delete left subtree rightmost node */
+
+       if (p != NULL)
+               if (key == NULL)
+                       {
+                       /* remove entire tree */
+                       p->left = treerm(p->left, key);
+                       p->right = treerm(p->right, key);
+                       free(p->key);
+                       free((char *) p);
+                       p = NULL;
+                       }
+               else if ((comp = strcmp(key, p->key)) < 0)
+                       {
+                       if (p->left != NULL)
+                               p->left = treerm(p->left, key);
+                       }
+               else if (comp > 0)
+                       {
+                       if (p->right != NULL)
+                               p->right = treerm(p->right, key);
+                       }
+               else    {
+                       q = p;
+                       if (q->right == NULL)
+                               p = q->left;
+                       else if (q->left == NULL)
+                               p = q->right;
+                       else
+                               p->left = rmtl(q->left);
+                       free(q->key);
+                       free((char *) q);
+                       }
+       return(p);
+}
+
+
+
+/*
+ * rmtl() descends along the rightmost branch of the left subtree of the
+ * element q to be deleted, and then it replaces the relevant information
+ * (key and count) in q by the corresponding values of the rightmost
+ * component r of that left subtree, after which r may be removed.
+ */
+TREE *
+rmtl(r)
+       TREE *r;                        /* leaf to be removed */
+{
+       if (r->right != NULL)
+               {
+               r->right = rmtl(r->right);
+               }
+       else    {
+               q->key = r->key;
+               q->count = r->count;
+               q = r;
+               r = r->left;
+               }
+       return(r);
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/src/treesearch.c b/usr/src/new/new/spms/src/lib/libtree/src/treesearch.c
new file mode 100644 (file)
index 0000000..10ff352
--- /dev/null
@@ -0,0 +1,30 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * treesearch() returns the number of occurrences of a key in a binary tree.
+ */
+#include "tree.h"
+#include "null.h"
+
+treesearch(p, key)
+       TREE *p;                        /* current node pointer */
+       char *key;                      /* pointer to key */
+{
+       int comp;                       /* compare key values */
+       int strcmp();                   /* string comparison */
+
+       if (p != NULL)
+               {
+               if ((comp = strcmp(key, p->key)) < 0)
+                       return(treesearch(p->left, key));
+               else if (comp > 0)
+                       return(treesearch(p->right, key));
+               else
+                       return(p->count);
+               }
+       return(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/test/tree.a b/usr/src/new/new/spms/src/lib/libtree/test/tree.a
new file mode 100644 (file)
index 0000000..3f6a559
--- /dev/null
@@ -0,0 +1,185 @@
+!<arch>
+Itree           418431039   968   27    100644  48        `
+mar
+may
+nov
+aug
+apr
+jan
+dec
+jul
+feb
+jun
+oct
+sep
+Otree           418431039   968   27    100644  969       `
+mar
+
+----------------------------------------
+
+       may
+mar
+
+----------------------------------------
+
+               nov
+       may
+mar
+
+----------------------------------------
+
+               nov
+       may
+mar
+       aug
+
+----------------------------------------
+
+               nov
+       may
+mar
+       aug
+               apr
+
+----------------------------------------
+
+               nov
+       may
+mar
+               jan
+       aug
+               apr
+
+----------------------------------------
+
+               nov
+       may
+mar
+               jan
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+               nov
+       may
+mar
+                       jul
+               jan
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+               nov
+       may
+mar
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+               nov
+       may
+mar
+                               jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+                       oct
+               nov
+       may
+mar
+                               jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+                               sep
+                       oct
+               nov
+       may
+mar
+                               jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+
+Ttree.c         418431039   968   27    100644  948       `
+/*
+ * tree()
+ */
+#include <stdio.h>
+#include "tree.h"
+#include "null.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Ttree";                   /* program name */
+int level = 0;                         /* current level in tree */
+
+main()
+{
+       TREE *root;                     /* root of tree */
+       TREE *tree();                   /* binary tree search and insert */
+       char key[KEYSIZE];              /* input key buffer */
+       void inorderprint();            /* print a binary tree inorder */
+
+       root = NULL;
+       while (gets(key) != NULL)
+               {
+               root = tree(root, key);
+               inorderprint(root);
+               printf("\n----------------------------------------\n\n");
+               }
+       exit(0);
+}
+
+
+
+/*
+ * Inorderprint prints a binary tree in inorder.
+ */
+void
+inorderprint(p)
+       TREE *p;                        /* current node pointer */
+{
+       int i;                          /* tree level index */
+       void inorderprint();            /* print tree inorder */
+
+       if (p != NULL)
+               {
+               level++;
+               inorderprint(p->right);
+               level--;
+               for (i = level; i > 0; --i)
+                       putchar('\t');
+               printf("%s\n", p->key);
+               level++;
+               inorderprint(p->left);
+               level--;
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/test/treerm.a b/usr/src/new/new/spms/src/lib/libtree/test/treerm.a
new file mode 100644 (file)
index 0000000..d330f0a
--- /dev/null
@@ -0,0 +1,212 @@
+!<arch>
+Itreerm         418431198   968   27    100644  48        `
+mar
+may
+nov
+aug
+apr
+jan
+dec
+jul
+feb
+jun
+oct
+sep
+Otreerm         418431198   968   27    100644  1033      `
+                               sep
+                       oct
+               nov
+       may
+mar
+                               jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+                               sep
+                       oct
+               nov
+       may
+jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+                       sep
+               oct
+       nov
+jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+               sep
+       oct
+jun
+                       jul
+               jan
+                               feb
+                       dec
+       aug
+               apr
+
+----------------------------------------
+
+               sep
+       oct
+jun
+                       jul
+               jan
+                               feb
+                       dec
+       apr
+
+----------------------------------------
+
+               sep
+       oct
+jun
+               jul
+       jan
+                       feb
+               dec
+
+----------------------------------------
+
+               sep
+       oct
+jun
+               jul
+       feb
+               dec
+
+----------------------------------------
+
+               sep
+       oct
+jun
+               jul
+       feb
+
+----------------------------------------
+
+               sep
+       oct
+jun
+       feb
+
+----------------------------------------
+
+               sep
+       oct
+jun
+
+----------------------------------------
+
+       sep
+oct
+
+----------------------------------------
+
+sep
+
+----------------------------------------
+
+
+----------------------------------------
+
+entire tree removed
+
+Ttreerm.c       418431198   968   27    100644  1428      `
+/*
+ * treerm()
+ */
+#include <stdio.h>
+#include "tree.h"
+#include "null.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Ttreerm";                 /* program name */
+int level = 0;                         /* current level in tree */
+
+main()
+{
+       TREE *root;                     /* root of tree */
+       TREE *tree();                   /* binary tree search and insert */
+       TREE *treerm();                 /* binary tree deletion */
+       char key[KEYSIZE];              /* input key buffer */
+       void inorderprint();            /* print a binary tree inorder */
+
+       root = NULL;
+       /* tree search and insertion */
+       while (gets(key) != NULL)
+               {
+               root = tree(root, key);
+               }
+
+       /* tree deletion */
+       rewind(stdin);
+       inorderprint(root);
+       printf("\n----------------------------------------\n\n");
+       while (gets(key) != NULL)
+               {
+               root = treerm(root, key);
+               inorderprint(root);
+               printf("\n----------------------------------------\n\n");
+               }
+
+       /* tree search and insertion */
+       rewind(stdin);
+       while (gets(key) != NULL)
+               {
+               root = tree(root, key);
+               }
+       
+       /* tree deletion */
+       root = treerm(root, NULL);
+       if (root == NULL)
+               printf("entire tree removed\n");
+       exit(0);
+}
+
+
+
+/*
+ * Inorderprint prints a binary tree in inorder.
+ */
+void
+inorderprint(p)
+       TREE *p;                        /* current node pointer */
+{
+       int i;                          /* tree level index */
+       void inorderprint();            /* print tree inorder */
+
+       if (p != NULL)
+               {
+               level++;
+               inorderprint(p->right);
+               level--;
+               for (i = level; i > 0; --i)
+                       putchar('\t');
+               printf("%s\n", p->key);
+               level++;
+               inorderprint(p->left);
+               level--;
+               }
+}
diff --git a/usr/src/new/new/spms/src/lib/libtree/test/treesearch.a b/usr/src/new/new/spms/src/lib/libtree/test/treesearch.a
new file mode 100644 (file)
index 0000000..1e12cf3
--- /dev/null
@@ -0,0 +1,62 @@
+!<arch>
+Itreesearch     418431203   968   27    100644  48        `
+mar
+may
+nov
+aug
+apr
+jan
+dec
+jul
+feb
+jun
+oct
+sep
+Otreesearch     418431204   968   27    100644  72        `
+mar 1
+may 1
+nov 1
+aug 1
+apr 1
+jan 1
+dec 1
+jul 1
+feb 1
+jun 1
+oct 1
+sep 1
+Ttreesearch.c   418431203   968   27    100644  670       `
+/*
+ * treesearch()
+ */
+#include <stdio.h>
+#include "tree.h"
+#include "null.h"
+
+#define KEYSIZE 10
+
+char *PGN = "Ttreesearch";             /* program name */
+int level = 0;                         /* current level in tree */
+
+main()
+{
+       int treesearch();               /* binary tree search */
+       TREE *root;                     /* root of tree */
+       TREE *tree();                   /* binary tree search and insert */
+       char key[KEYSIZE];              /* input key buffer */
+       void inorderprint();            /* print a binary tree inorder */
+
+       root = NULL;
+       /* tree search and insertion */
+       while (gets(key) != NULL)
+               {
+               root = tree(root, key);
+               }
+
+       /* tree search */
+       rewind(stdin);
+       while (gets(key) != NULL)
+               printf("%s %d\n", key, treesearch(root, key));
+       
+       exit(0);
+}
diff --git a/usr/src/new/new/spms/src/lib/pgrep/grep.c b/usr/src/new/new/spms/src/lib/pgrep/grep.c
new file mode 100644 (file)
index 0000000..47e434e
--- /dev/null
@@ -0,0 +1,135 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+#include <signal.h>
+#include <stdio.h>
+#include <sys/param.h>
+#include "null.h"
+#include "slist.h"
+#include "system.h"
+
+#define MAXNAMLEN      255
+#define READ           0
+#define        WRITE           1
+
+static int popen_pid;                  /* process identity */
+
+/*
+ * closegrep() closes the pipe from the grep command and returns the
+ * the exit status of the grep command.
+ */ 
+closegrep(fp)
+       FILE *fp;                       /* pipe file pointer */
+{
+       register (*hstat)();            /* hangup function pointer */
+       register (*istat)();            /* interrupt function pointer */
+       register (*qstat)();            /* quit function pointer */
+       register int w;                 /* a child id */
+       int status;                     /* child return status */
+
+       fclose(fp);
+
+       istat = signal(SIGINT, SIG_IGN);
+       qstat = signal(SIGQUIT, SIG_IGN);
+       hstat = signal(SIGHUP, SIG_IGN);
+
+       while ((w = wait(&status)) != popen_pid && w != -1)
+               continue;
+
+       signal(SIGINT, istat);
+       signal(SIGQUIT, qstat);
+       signal(SIGHUP, hstat);
+
+       status >>= NBBY;
+       status &=  0xff;
+       return(status);
+}
+
+
+
+/*
+ * grep() returns a singly-linked list of file names from the grep
+ * command. NULL is returned on error.
+ */
+SLIST *
+grep(greppath, grepargv)
+       char *greppath;                 /* grep command path */
+       char **grepargv;                /* grep argv */
+{
+       char filename[MAXNAMLEN + 1];   /* receiving filename buffer */
+       char *readgrep();               /* read input from grep */
+       char *slappend();               /* append key */
+       FILE *fp;                       /* input stream from grep */
+       FILE *opengrep();               /* open pipe to grep */
+       int closegrep();                /* close pipe to grep */
+       SLIST *filelist;                /* list of file names */
+       SLIST *slinit();                /* initialize list */
+
+       if ((fp = opengrep(greppath, grepargv)) == NULL)
+               return(NULL);
+
+       filelist = slinit();
+
+       while (readgrep(filename, fp) != NULL)
+               if (slappend(filename, filelist) == NULL)
+                       return(NULL);
+       
+       if (closegrep(fp) == 2)
+               return(NULL);
+       return(filelist);
+}
+
+
+
+/*
+ * opengrep() opens a pipe to read from the grep command. A file
+ * pointer is returned, or NULL on error.
+ */
+FILE *
+opengrep(greppath, grepargv)
+       char *greppath;                 /* grep command path */
+       char **grepargv;                /* grep argv */
+{
+       FILE *fdopen();                 /* associate stream with file descrip */
+       int p[2];                       /* pipe file descriptors */
+
+       if (pipe(p) < 0)
+               return(NULL);
+       if ((popen_pid = FORK()) == 0)
+               {
+               close(p[READ]);
+               dup2(p[WRITE], WRITE);
+               close(p[WRITE]);
+               execv(greppath, grepargv);
+               _exit(1);
+               }
+       if (popen_pid == -1)
+               return(NULL);
+       close(p[WRITE]);
+       return(fdopen(p[READ], "r"));
+}
+
+
+
+/*
+ * readgrep() reads a line from the grep stream. The newline character
+ * is replaced by a null character. Returns buf, or NULL at EOF.
+ */
+char *
+readgrep(buf, fp)
+       char *buf;                      /* receiving buffer */
+       register FILE *fp;              /* input stream */
+{
+       register char *bp;              /* receiving buffer pointer */
+       register int c;                 /* current character */
+
+       bp = buf;
+       while((c = getc(fp)) != '\n' && c != EOF)
+               *bp++ = c;
+       if (c == EOF && bp == buf)
+               return(NULL);
+       *bp = '\0';
+       return(buf);
+}
diff --git a/usr/src/new/new/spms/src/lib/pgrep/pgrep.h b/usr/src/new/new/spms/src/lib/pgrep/pgrep.h
new file mode 100644 (file)
index 0000000..066f2d8
--- /dev/null
@@ -0,0 +1,18 @@
+/* $Header$ */
+
+/*
+ * Pgrep definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Buffer sizes
+ */
+#define MACRONAMSIZE           32              /* macro definition name size */
+#define MACRODEFSIZE           1024            /* macro definition body size */
+/*
+ * Predefined macro names
+ */
+#define MHEADERS               "HDRS"
+#define MSOURCE                        "SRCS"
diff --git a/usr/src/new/new/spms/src/lib/pgrep/readmf.c b/usr/src/new/new/spms/src/lib/pgrep/readmf.c
new file mode 100644 (file)
index 0000000..e457889
--- /dev/null
@@ -0,0 +1,209 @@
+/* $Header$ */
+
+/*
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include <stdio.h>
+#include "macro.h"
+#include "null.h"
+#include "pgrep.h"
+#include "slist.h"
+#include "yesno.h"
+
+#define DEPENDMARK             "###"
+
+static char Iobuf[BUFSIZ];             /* I/O line buffer */
+static short Continue;                 /* does the line continue? */
+
+/*
+ * dependmark() returns 1 if the current input line begins with a string
+ * marking the beginning of generated dependency lines, otherwise zero.
+ */
+dependmark()
+
+{
+       if (EQUAL(Iobuf, DEPENDMARK))
+               return(1);
+       return(0);
+}
+
+
+
+/*
+ * findmacro() searchs a line for a macro definition. Returns the name,
+ * or null if not found.
+ */
+char *
+findmacro(macroname)
+       char *macroname;                /* macro name receiving buffer */
+{
+       register char *bp;              /* buffer pointer */
+       register char *mp;              /* macro name pointer */
+
+       bp = Iobuf;
+       mp = macroname;
+       while (*bp == ' ')
+               bp++;
+       if (!isalnum(*bp))
+               return(NULL);
+       while(isalnum(*bp))
+               *mp++ = *bp++;
+       *mp = '\0';
+       while(*bp == ' ' || *bp == '\t')
+               bp++;
+       if (*bp != '=')
+               return(NULL);
+       return(macroname);
+}
+       
+
+
+/*
+ * getlin() stores a line from input stream in Iobuf. The string is terminated
+ * by a newline character which is replaced by a null character. getlin()
+ * returns Iobuf, or null pointer upon end of file.
+ */
+char *
+getlin(stream)
+       register FILE *stream;          /* input stream */
+{
+       register int c;                 /* current character */
+       register char *iop;             /* Iobuf pointer */
+
+       iop = Iobuf;
+       while ((c = getc(stream)) != '\n' && c != EOF)
+               *iop++ = c;
+       if (c == EOF && iop == Iobuf)
+               return(NULL);
+       if (iop != Iobuf && iop[-1] == '\\')
+               {
+               iop[-1] = '\0';
+               Continue = YES;
+               }
+       else    {
+               iop[0] = '\0';
+               Continue = NO;
+               }
+       return(Iobuf);
+}
+
+
+
+/*
+ * getmacro() loads the body of a macro definition into slist and returns
+ * a pointer to slist. If the macro definition continues on more than
+ * one line further lines are fetched from the input stream. Returns NO
+ * if out of memory, otherwise YES.
+ */
+getmacro(slist, stream)
+       register SLIST *slist;          /* singly-linked list */
+       register FILE *stream;          /* input stream */
+{
+       register char *bp;              /* buffer pointer */
+       char mdefbuf[MACRODEFSIZE];     /* macro definition buffer */
+       char *getlin();                 /* get a line from input stream */
+       char *gettoken();               /* get next token */
+       char *slappend();               /* append key */
+
+       bp = Iobuf;
+       while (*bp++ != '=')
+               continue;
+       while ((bp = gettoken(mdefbuf, bp)) != NULL)
+               if (slappend(mdefbuf, slist) == NULL)
+                       return(NO);
+       while (Continue == YES)
+               {
+               if (getlin(stream) == NULL)
+                       break;
+               bp = Iobuf;
+               while ((bp = gettoken(mdefbuf, bp)) != NULL)
+                       if (slappend(mdefbuf, slist) == NULL)
+                               return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * gettoken() copies the next token from token buffer to token. Returns a
+ * pointer to the first character after the token, or null upon reaching
+ * the end of the token buffer.
+ */
+char *
+gettoken(token, tp)
+       register char *token;           /* receiving token */
+       register char *tp;              /* token buffer pointer */
+{
+       while (isspace(*tp) && *tp != '\0')
+               tp++;
+       if (*tp == '\0')
+               {
+               *token = '\0';
+               return(NULL);
+               }
+       while (!isspace(*tp) && *tp != '\0')
+               *token++ = *tp++;
+       *token = '\0';
+       return(tp);
+}
+
+
+
+/*
+ * readmf() reads a makefile and loads file names from HEADERS and SOURCE
+ * macros into a singly-linked list. Returns NO on error, otherwise YES.
+ */
+readmf(mfname, filelist)
+       char *mfname;                   /* name of makefile */
+       SLIST *filelist;                /* file name list */
+{
+       char *findmacro();              /* is the line a macro definition? */
+       char *getlin();                 /* get a line from input stream */
+       char macroname[MACRONAMSIZE];   /* macro name buffer */
+       FILE *fopen();                  /* open file */
+       FILE *fp;                       /* file pointer */
+       int dependmark();               /* generated dependency line? */
+       int getmacro();                 /* get macro def from input stream */
+       SLIST *headlist;                /* header file name list */
+       SLIST *slinit();                /* initialize list */
+       SLIST *srclist;                 /* source file name list */
+       void slsplice();                /* splice lists together */
+
+       headlist = slinit();
+       srclist = slinit();
+
+       if ((fp = fopen(mfname, "r")) == NULL)
+               {
+               pperror(mfname);
+               return(NO);
+               }
+       while (getlin(fp) != NULL)
+               {
+               if (dependmark())
+                       break;
+               if (findmacro(macroname) != NULL)
+                       {
+                       if (EQUAL(macroname, MHEADERS))
+                               {
+                               if (getmacro(headlist, fp) == NO)
+                                       return(NO);
+                               }
+                       else if (EQUAL(macroname, MSOURCE))
+                               {
+                               if (getmacro(srclist, fp) == NO)
+                                       return(NO);
+                               }
+                       }
+               }
+       fclose(fp);
+
+       /* splice header files to file list */
+       slsplice(filelist, headlist);
+
+       /* splice source files to file list */
+       slsplice(filelist, srclist);
+
+       return(YES);
+}
diff --git a/usr/src/new/new/spms/src/lib/phelp/phelp.cmd b/usr/src/new/new/spms/src/lib/phelp/phelp.cmd
new file mode 100644 (file)
index 0000000..919d8aa
--- /dev/null
@@ -0,0 +1,12 @@
+Type one of the following commands:
+
+You type:                      Response:
+
+(a topic name)                 Print help information on topic.
+index                          Display list of topics available at this level.
+help                           Display the summary on how to use phelp.
+?                              Display this command summary.
+q                              Exit from phelp.
+P (a project name)             Change to another project.
+~                              Return to the top level of help topics.
+(carriage return only)         Go up one level of help topics.
diff --git a/usr/src/new/new/spms/src/lib/phelp/phelp.help b/usr/src/new/new/spms/src/lib/phelp/phelp.help
new file mode 100644 (file)
index 0000000..681280f
--- /dev/null
@@ -0,0 +1,25 @@
+Phelp provides information about a project. After the `phelp' command
+is typed, it will respond with `???' indicating that it is ready for a
+command. If you type the name of a topic followed by a carriage return
+phelp will print a page of information and then wait until you type a
+space before it continues. The following commands are also recognized:
+
+You type:                      Response:
+
+index                  Display list of topics available at this level.
+help                   Display the summary on how to use phelp.
+?                      Display this command summary.
+q                      Exit from phelp.
+P (a project name)     Change to another project.
+~                      Return to the top level of help topics.
+(carriage return only) Go up one level of help topics.
+
+For example: To find out about topic "news":
+       % phelp
+       (prints this introduction and a list of topics available)
+       ??? news
+       (prints "news")
+       ??? q
+       %
+
+For further information on phelp, see the UNIX Programmer's Manual.
diff --git a/usr/src/new/new/spms/src/lib/x.Makefile/t.Makefile b/usr/src/new/new/spms/src/lib/x.Makefile/t.Makefile
new file mode 100644 (file)
index 0000000..5b72173
--- /dev/null
@@ -0,0 +1,12 @@
+LDFLAGS              =
+
+LIBS         =
+
+LINKER       = cc
+
+OBJS         =
+
+PROGRAM              =
+
+$(PROGRAM):     $(OBJS) $(LIBS)
+               @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)