Path: utzoo!utgpu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!pdxgate!eecs.cs.pdx.edu!kirkenda From: kirkenda@eecs.cs.pdx.edu (Steve Kirkendall) Newsgroups: alt.sources Subject: Elvis 1.4, part 3 of 8 Message-ID: <827@pdxgate.UUCP> Date: 3 Dec 90 21:29:59 GMT Sender: news@pdxgate.UUCP Reply-To: kirkenda@eecs.cs.pdx.edu (Steve Kirkendall) Organization: Portland State University, Portland, OR Lines: 2843 # --------------------------- cut here ---------------------------- # This is a shar archive. To unpack it, save it to a file, and delete # anything above the "cut here" line. Then run sh on the file. # # -rw-r--r-- 1 kirkenda 341 Dec 2 17:56 Elvis.lnk # -rw-r--r-- 1 kirkenda 2237 Dec 2 17:56 Elvis.mak # -rw-r--r-- 1 kirkenda 162 Dec 2 17:56 Elvis.prj # -rw-r--r-- 1 kirkenda 12152 Dec 2 17:56 Makefile.mix # -rw-r--r-- 1 kirkenda 2032 Dec 2 17:56 alias.c # -rw-r--r-- 1 kirkenda 1437 Dec 2 17:56 atari.c # -rw-r--r-- 1 kirkenda 7855 Dec 2 17:56 ctags.c # -rw-r--r-- 1 kirkenda 0 Dec 2 17:57 date.c # -rw-r--r-- 1 kirkenda 4392 Dec 2 17:57 osk.c # -rw-r--r-- 1 kirkenda 377 Dec 2 17:57 osk.h # -rw-r--r-- 1 kirkenda 5512 Dec 2 17:57 pc.c # -rw-r--r-- 1 kirkenda 30 Dec 2 17:57 profile.sh # -rw-r--r-- 1 kirkenda 2872 Dec 2 17:57 ref.c # -rw-r--r-- 1 kirkenda 3981 Dec 2 17:57 shell.c # -rw-r--r-- 1 kirkenda 3438 Dec 2 17:57 sysdos.c # -rw-r--r-- 1 kirkenda 4780 Dec 2 17:57 virec.c # -rw-r--r-- 1 kirkenda 2424 Dec 2 17:57 wildcard.c # if test -f Elvis.lnk -a "$1" != -f then echo Will not overwrite Elvis.lnk else echo Extracting Elvis.lnk sed 's/^X//' >Elvis.lnk <<\eof Xblk.obj cmd1.obj cmd2.obj curses.obj cut.obj + Xex.obj input.obj main.obj misc.obj modify.obj + Xmove1.obj move2.obj move3.obj move4.obj move5.obj + Xopts.obj recycle.obj redraw.obj regexp.obj + Xregsub.obj system.obj tio.obj tmp.obj vars.obj + Xvcmd.obj vi.obj pc.obj sysdos.obj tinytcap.obj /co /noi /map + X/pac /far /stack:0x4000 Xelvis.exe; eof if test `wc -c Elvis.mak <<\eof X# Makefile for MSC - if you don't have NDmake, use this one, X# but don't expect to be happy. X# And don't expect to do anything but making the executables, either. X XOBJS= blk.obj cmd1.obj cmd2.obj curses.obj cut.obj ex.obj input.obj \ X main.obj misc.obj modify.obj move1.obj move2.obj move3.obj move4.obj \ X move5.obj opts.obj recycle.obj redraw.obj regexp.obj regsub.obj \ X system.obj tio.obj tmp.obj vars.obj vcmd.obj vi.obj \ X pc.obj sysdos.obj tinytcap.obj X XCFLAGS= -DCS_IBMPC -DCS_SPECIAL XCC= cl -AM X Xblk.obj: blk.c X $(CC) $(CFLAGS) -c blk.c X Xcmd1.obj: cmd1.c X $(CC) $(CFLAGS) -c cmd1.c X Xcmd2.obj: cmd2.c X $(CC) $(CFLAGS) -c cmd2.c X Xcurses.obj: curses.c X $(CC) $(CFLAGS) -c curses.c X Xcut.obj: cut.c X $(CC) $(CFLAGS) -c cut.c X Xex.obj: ex.c X $(CC) $(CFLAGS) -c ex.c X Xinput.obj: input.c X $(CC) $(CFLAGS) -c input.c X Xmain.obj: main.c X $(CC) $(CFLAGS) -c main.c X Xmisc.obj: misc.c X $(CC) $(CFLAGS) -c misc.c X Xmodify.obj: modify.c X $(CC) $(CFLAGS) -c modify.c X Xmove1.obj: move1.c X $(CC) $(CFLAGS) -c move1.c X Xmove2.obj: move2.c X $(CC) $(CFLAGS) -c move2.c X Xmove3.obj: move3.c X $(CC) $(CFLAGS) -c move3.c X Xmove4.obj: move4.c X $(CC) $(CFLAGS) -c move4.c X Xmove5.obj: move5.c X $(CC) $(CFLAGS) -c move5.c X Xopts.obj: opts.c X $(CC) $(CFLAGS) -c opts.c X Xrecycle.obj: recycle.c X $(CC) $(CFLAGS) -c recycle.c X Xredraw.obj: redraw.c X $(CC) $(CFLAGS) -c redraw.c X Xregexp.obj: regexp.c X $(CC) $(CFLAGS) -c regexp.c X Xregsub.obj: regsub.c X $(CC) $(CFLAGS) -c regsub.c X Xsystem.obj: system.c X $(CC) $(CFLAGS) -c system.c X Xtio.obj: tio.c X $(CC) $(CFLAGS) -c tio.c X Xtmp.obj: tmp.c X $(CC) $(CFLAGS) -c tmp.c X Xvars.obj: vars.c X $(CC) $(CFLAGS) -c vars.c X Xvcmd.obj: vcmd.c X $(CC) $(CFLAGS) -c vcmd.c X Xvi.obj: vi.c X $(CC) $(CFLAGS) -c vi.c X Xpc.obj: pc.c X $(CC) $(CFLAGS) -c pc.c X Xsysdos.obj: sysdos.c X $(CC) $(CFLAGS) -c sysdos.c X Xtinytcap.obj: tinytcap.c X $(CC) $(CFLAGS) -c tinytcap.c X Xelvis.exe: $(OBJS) X link @elvis.lnk X Xctags.exe: ctags.c wildcard.c X $(CC) ctags.c -o ctags.exe X Xref.exe: ref.c X $(CC) ref.c -o ref.exe X Xvirec.exe: virec.c wildcard.c X $(CC) virec.c -o virec.exe X Xwildcard.exe: wildcard.c X $(CC) wildcard.c -o wildcard.exe X Xex.exe: alias.c X $(CC) alias.c -o ex.exe X Xvi.exe: ex.exe X copy ex.exe vi.exe X Xview.exe: ex.exe X copy ex.exe view.exe eof if test `wc -c Elvis.prj <<\eof Xblk Xcmd1 Xcmd2 Xcurses Xcut Xex Xinput Xmain Xmisc Xmodify Xmove1 Xmove2 Xmove3 Xmove4 Xmove5 Xopts Xrecycle Xredraw Xregexp Xregsub Xsystem Xtio Xtmp Xvars Xvcmd Xvi Xpc Xsysdos Xtinytcap eof if test `wc -c Makefile.mix <<\eof X# combined Makefile for ELVIS - a clone of `vi` X# X# After editing this Makefile as described below, you should... X# X# Use `make` to compile all programs X# Use `make install` to copy the programs to the BIN directory X# Use `make clean` to remove all object files X# Use `make clobber` to remove everything except source & documentation X# Use `make tags` to build new "tags" and "refs" files X# Use `make uue` to produce uuencoded compressed tar archives of the source X# Use `make sh` to produce shar archives of the source X# Use `make print` to print the Elvis documentation X# X# Several groups of Makefile settings are included below. Choose *ONE* group X# of settings for your particular system, and leave the others commented out. X# The meanings of these settings are: X# O the filename extension for unlinked object files -- usually .o X# E the filename extension for executable files -- usually null X# EXTRA version-specific object files used in elvis X# EXTRA2 version-specific object files used in elvis, virec, & refont X# LIBS any special libraries, such as "-ltermcap" X# BIN directory where executables should be installed X# CC the C compiler command, possibly with "memory model" flags X# CFLAGS compiler flags used to select compile-time options X# OF link flag to control the output file's name -- usually -o X# RF flag used to denote "compile but don't link" -- usually -c X# DATE a "cc" flag that defines "DATE". e.g. DATE=-DDATE=\"7/4/76\" X# EVAL the word "eval", if DATE requires it X# PROGS the list of all programs X# CHMEM any extra commands to be run after ELVIS is linked X# SORT if the "tags" file must be sorted, then SORT=-DSORT X# INST installation method: inst.dos, inst.tos, inst.os9, or inst.unix X# RM the name of a program that deletes files X# PR1 used to print documentation -- typically "refont -c" X# PR2 used to send text to printer -- typically "| lpr" X# DUMMY usually nothing, but OS9 needs "dummy" X# DOC name of "doc" directory, with a trailing slash X X#---- These settings are recommended for System-V UNIX and SCO XENIX-386 ---- X#O= .o X#E= X#EXTRA= X#EXTRA2= X#LIBS= -ltermcap X#BIN= /usr/local/bin X#CFLAGS= -DM_SYSV -O X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= X#SORT= -DSORT X#INST= inst.unix X#RM= rm -f X#PR1= refont -c X#PR2= | lp X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for SCO XENIX-286 ---- X#O= .o X#E= X#EXTRA= X#EXTRA2= X#LIBS= -ltermcap X#BIN= /usr/local/bin X#CC= cc -M2s -i X#CFLAGS= -DM_SYSV -Ox -DCS_IBMPC X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= X#SORT= -DSORT X#INST= inst.unix X#RM= rm -f X#PR1= refont -c X#PR2= | lp X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for BSD 4.3 UNIX ---- X#O= .o X#E= X#EXTRA= X#EXTRA2= X#LIBS= -ltermcap X#BIN= /usr/local/bin X#CFLAGS= -Dbsd -O X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= X#SORT= -DSORT X#INST= inst.unix X#RM= rm -f X#PR1= refont -c X#PR2= | lpr X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for Coherent ---- X#O=.o X#E= X#EXTRA= X#EXTRA2= X#LIBS= -lterm X#BIN= /usr/bin X#CC= cc X#CFLAGS= -O -DCOHERENT -DCRUNCH -DNO_CHARATTR -DNO_CURSORSHAPE \ X# -DNO_DIGRAPH -DNO_MKEXRC -VSUVAR X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= fixstack 2000 elvis$E X#SORT= X#INST= inst.unix X#RM= rm -f X#PR1= refont -b X#PR2= | lpr X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for Minix-ST ---- X#O= .o X#E= X#EXTRA= X#EXTRA2= X#LIBS= X#BIN= /usr/bin X#CC= cc X#CFLAGS= X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= chmem =18000 elvis X#SORT= X#INST= inst.unix X#RM= rm -f X#PR1= lpr X#PR2= X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for Minix-PC ---- X#O= .s X#E= X#EXTRA= tinytcap$O X#EXTRA2= X#LIBS= X#BIN= /usr/bin X#CC= cc -i X#CFLAGS= -O -DCRUNCH -DNO_MKEXRC -DNO_CURSORSHAPE -DNO_CHARATTR \ X# -DNO_SHOWMODE -DNO_MODELINE -DNO_OPTCOLS -DNO_DIGRAPH -DNO_ABBR \ X# -DNO_AT -DNO_SENTENCE -DNO_ERRLIST X#### (all but -DNO_EXTENSIONS, -DNO_RECYCLE, -DNO_MAGIC, and -DNO_CHARSEARCH) X#OF= -o X#RF= -c X#DATE= -DDATE=\'\"`date`\"\' X#EVAL= eval X#PROGS= elvis$E ctags$E ref$E virec$E refont$E X#CHMEM= X#SORT= X#INST= inst.unix X#RM= rm -f X#PR1= lpr X#PR2= X#DUMMY= X#DOC= doc/ X X#---- These settings are recommended for MS-DOS + MS-C + NDMAKE ---- X#O= .obj X#E= .exe X#EXTRA= pc$O sysdos$O tinytcap$O X#EXTRA2= X#LIBS= X#BIN= c:\dos X#CC= cl /AM X#CFLAGS= -O -DCS_IBMPC -DCS_SPECIAL X#OF= -o X#RF= -c X#DATE= X#EVAL= X#PROGS= elvis$E ex$E ctags$E ref$E virec$E wildcard$E refont$E X#CHMEM= X#SORT= X#INST= inst.dos X#RM= del X#PR1= refont -c X#PR2= >PRN X#DUMMY= X#DOC= doc\ X X#---- These settings are recommended for Atari TOS + Mark Williams C ---- X#O=.o X#E=.ttp X#EXTRA= sysdos$O tinytcap$O X#EXTRA2= atari$O X#LIBS= X#BIN= c:\ X#CC= cc -VPEEP X#CFLAGS= -O -DCS_IBMPC -DCS_SPECIAL X#OF= -o X#RF= -c X#DATE= X#EVAL= X#PROGS= elvis$E ctags$E ref$E virec$E wildcard$E shell$E refont$E X#CHMEM= X#SORT= X#INST= inst.tos X#RM= rm -f X#PR1= refont -e X#PR2= >PRT: X#DUMMY= X#DOC= 'doc\' X X#---- These settings are recommended for OS-9/68K V2.3 ---- X#O= .r X#E= X#EXTRA= date$O X#EXTRA2= osk$O X#LIBS= -l=/dd/lib/termlib.l X#BIN= /dd/usr/cmds X#CC= cc X#ODIR= /dd/usr/src/elvis X#CFLAGS= -gq -m=2 X#OF= -f=$(ODIR)/ X#RF= -r X#DATE= X#EVAL= X#PROGS= elvis$E vi$E view$E input$E ctags$E ref$E virec$E refont$E X#CHMEM= touch date.r X#SORT= X#INST= inst.os9 X#RM= del *.stb *.dbg X#PR1= refont -b X#PR2= >/p X#DUMMY= dummy X#DOC= doc/ X X########################################################################### X########################################################################### X### ### X### The rest of this Makefile contains no user-servicable parts ### X### ### X########################################################################### X########################################################################### X XOBJS= blk$O cmd1$O cmd2$O curses$O cut$O ex$O input$O main$O misc$O \ X modify$O move1$O move2$O move3$O move4$O move5$O opts$O recycle$O \ X redraw$O regexp$O regsub$O system$O tio$O tmp$O vars$O vcmd$O vi$O X XALIAS= alias$O X XDOCS= $(DOC)index.doc $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \ X $(DOC)regexp.doc $(DOC)options.doc $(DOC)cutbufs.doc $(DOC)differ.doc \ X $(DOC)internal.doc $(DOC)cflags.doc $(DOC)termcap.doc \ X $(DOC)environ.doc $(DOC)versions.doc X XSRC1= README KNOWN.BUGS $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \ X $(DOC)versions.doc $(DOC)cflags.doc $(DOC)differ.doc XSRC2= $(DOC)cutbufs.doc $(DOC)options.doc $(DOC)environ.doc $(DOC)regexp.doc \ X $(DOC)internal.doc $(DOC)termcap.doc $(DOC)index.doc $(DOC)ctags.man \ X $(DOC)elvis.man $(DOC)ref.man $(DOC)refont.man $(DOC)virec.man XSRC3= Elvis.lnk Elvis.mak Elvis.prj Makefile.mix alias.c atari.c \ X ctags.c pc.c ref.c shell.c sysdos.c virec.c wildcard.c \ X profile.sh osk.c osk.h date.c XSRC4= blk.c cmd1.c cmd2.c config.h curses.c XSRC5= curses.h cut.c ex.c input.c main.c misc.c XSRC6= modify.c move1.c move2.c move3.c move4.c move5.c opts.c recycle.c \ X redraw.c XSRC7= regexp.c regexp.h regsub.c system.c tinytcap.c tio.c tmp.c XSRC8= vars.c vcmd.c vi.c vi.h refont.c X X########################################################################### X Xall: $(PROGS) X @echo done. X Xelvis$E: $(OBJS) $(EXTRA) $(EXTRA2) X $(CC) $(CFLAGS) $(OF)elvis$E $(OBJS) $(EXTRA) $(EXTRA2) $(LIBS) X $(CHMEM) X Xctags$E: ctags.c X $(CC) $(CFLAGS) $(SORT) $(OF)ctags$E ctags.c X Xref$E: ref.c X $(CC) $(CFLAGS) $(OF)ref$E ref.c X Xvirec$E: virec.c X $(CC) $(CFLAGS) $(OF)virec$E virec.c $(EXTRA2) X Xview$E: $(ALIAS) X $(CC) $(CFLAGS) $(OF)view$E $(ALIAS) X Xex$E: $(ALIAS) X $(CC) $(CFLAGS) $(OF)ex$E $(ALIAS) X Xvi$E: $(ALIAS) X $(CC) $(CFLAGS) $(OF)vi$E $(ALIAS) X Xinput$E: $(ALIAS) X $(CC) $(CFLAGS) $(OF)input$E $(ALIAS) X Xshell$E: shell.c X $(CC) $(CFLAGS) $(OF)shell$E shell.c X Xwildcard$E: wildcard.c X $(CC) $(CFLAGS) $(OF)wildcard$E wildcard.c X Xrefont$E: refont.c X $(CC) $(CFLAGS) $(OF)refont$E refont.c $(EXTRA2) X X############################################################################## X X# The file cmd1.c is compiled with the extra flag -DDATE="today's date". Xcmd1$O: cmd1.c vi.h config.h X $(EVAL) $(CC) $(CFLAGS) $(RF) $(DATE) cmd1.c X X# "It all depends..." X$(OBJS): vi.h curses.h config.h X X# OS9 must create a custom date.c file, and compile it. Xdate$O: $(OBJS) X @echo '/* compilation date of elvis */' >-date.c X @echo -r 'char date[] = "' >+date.c X @echo -r 'echo -r ' >-/dd/tmp/date.c X @date >+/dd/tmp/date.c X @shell /dd/tmp/date.c >+date.c X @echo '";' >+date.c X @del /dd/tmp/date.c X $(CC) $(CFLAGS) $(RF) date.c X X############################################################################## Xinstall: $(INST) X @echo Installation complete. X Xinst.unix: $(DUMMY) X cp $(PROGS) $(BIN) X (cd $(BIN); chmod 755 $(PROGS)) X (cd $(BIN); chown bin $(PROGS)) X -ln $(BIN)/elvis $(BIN)/vi X -ln $(BIN)/elvis $(BIN)/ex X -ln $(BIN)/elvis $(BIN)/view X -ln $(BIN)/elvis $(BIN)/input X Xinst.dos: $(DUMMY) X copy $(PROGS) $(BIN) X copy $(BIN)/ex$E $(BIN)/vi$E X copy $(BIN)/ex$E $(BIN)/view$E X copy $(BIN)/ex$E $(BIN)/input$E X Xinst.tos: $(DUMMY) X copy $(PROGS) $(BIN) X Xinst.os9: $(DUMMY) X copy $(PROGS) -rw=$(BIN) X chd $(BIN); attr -epenprnpw $(PROGS) X X############################################################################## Xclean: $(DUMMY) X $(RM) *$O $(DOC)*.1 elvis?.uue elvis?.sh core X Xclobber: clean X $(RM) tags refs $(PROGS) X X############################################################################## Xprint: refont$E X $(PR1) $(DOCS) $(PR2) X Xtags refs: ctags$E X ctags -r *.c *.h X X############################################################################## Xuue: elvis1.uue elvis2.uue elvis3.uue elvis4.uue elvis5.uue \ X elvis6.uue elvis7.uue elvis8.uue X Xelvis1.uue: $(SRC1) X tar cf elvis1.tar $(SRC1) X compress -b13 elvis1.tar X cp README elvis1.uue X uue elvis1.tar.Z - >>elvis1.uue X $(RM) elvis1.tar* X Xelvis2.uue: $(SRC2) X tar cf elvis2.tar $(SRC2) X compress -b13 elvis2.tar X uue elvis2.tar.Z X $(RM) elvis2.tar* X Xelvis3.uue: $(SRC3) X tar cf elvis3.tar $(SRC3) X compress -b13 elvis3.tar X uuencode elvis3.tar.Z elvis3.uue X $(RM) elvis3.tar* X Xelvis4.uue: $(SRC4) X tar cf elvis4.tar $(SRC4) X compress -b13 elvis4.tar X uuencode elvis4.tar.Z elvis4.uue X $(RM) elvis4.tar* X Xelvis5.uue: $(SRC5) X tar cf elvis5.tar $(SRC5) X compress -b13 elvis5.tar X uuencode elvis5.tar.Z elvis5.uue X $(RM) elvis5.tar* X Xelvis6.uue: $(SRC6) X tar cf elvis6.tar $(SRC6) X compress -b13 elvis6.tar X uuencode elvis6.tar.Z elvis6.uue X $(RM) elvis6.tar* X Xelvis7.uue: $(SRC7) X tar cf elvis7.tar $(SRC7) X compress -b13 elvis7.tar X uuencode elvis7.tar.Z elvis7.uue X $(RM) elvis7.tar* X Xelvis8.uue: $(SRC8) X tar cf elvis8.tar $(SRC8) X compress -b13 elvis8.tar X uuencode elvis8.tar.Z elvis8.uue X $(RM) elvis8.tar* X X############################################################################## Xsh: elvis1.sh elvis2.sh elvis3.sh elvis4.sh elvis5.sh elvis6.sh \ X elvis7.sh elvis8.sh X Xelvis1.sh: $(SRC1) X cat >elvis1.sh README X echo >>elvis1.sh ': ------------------------ CUT HERE --------------------' X echo >>elvis1.sh 'test -d doc || mkdir doc || exit 2' X shar >>elvis1.sh -h $(SRC1) X Xelvis2.sh: $(SRC2) X echo >elvis2.sh ': ------------------------ CUT HERE --------------------' X echo >>elvis2.sh 'test -d doc || mkdir doc || exit 2' X shar >>elvis2.sh -h $(SRC2) X Xelvis3.sh: $(SRC3) X shar $(SRC3) >elvis3.sh X Xelvis4.sh: $(SRC4) X shar $(SRC4) >elvis4.sh X Xelvis5.sh: $(SRC5) X shar $(SRC5) >elvis5.sh X Xelvis6.sh: $(SRC6) X shar $(SRC6) >elvis6.sh X Xelvis7.sh: $(SRC7) X shar $(SRC7) >elvis7.sh X Xelvis8.sh: $(SRC8) X shar $(SRC8) >elvis8.sh X X############################################################################## X X# Under XENIX only! This stores all sources on a 3.5" 720k floppy disk. Xfloppy: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) X tar c5v $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) eof if test `wc -c alias.c <<\eof X/* alias.c */ X X/* Author: X * Peter Reinig X * Universitaet Kaiserslautern X * Postfach 3049 X * 7650 Kaiserslautern X * W. Germany X * reinig@physik.uni-kl.de X */ X X/* This tiny program executes elvis with the flags that are appropriate X * for a given command name. This program is used only on systems that X * don't allow UNIX-style file links. X * X * The benefit of this program is: instead of having 5 copies of elvis X * on your disk, you only need one copy of elvis and 4 copies of this X * little program. X */ X X#include X#include "config.h" X X#if OSK X#define ELVIS "/dd/usr/cmds/elvis" X#else X#define ELVIS "elvis" X#endif X Xextern char **environ; Xextern int errno; Xextern char *malloc(); X Xmain(argc, argv) X int argc; X char *argv[]; X{ X int pid, i, j; X int letter; X char **argblk; X#if OSK X extern int chainc(); X#endif X X /* allocate enough space for a copy of the argument list, plus a X * terminating NULL, plus maybe an added flag. X */ X argblk = (char **) malloc((argc + 2) * sizeof(char *)); X if (!argblk) X { X#if OSK X _errmsg(errno, "Can't get enough memory\n"); X#else X perror(argv[0]); X#endif X exit(2); X } X X /* find the last letter in the invocation name of this program */ X i = strlen(argv[0]); X#if MSDOS || TOS X /* we almost certainly must bypass ".EXE" or ".TTP" from argv[0] */ X if (i > 4 && argv[0][i - 4] == '.') X i -= 4; X#endif X letter = argv[0][i - 1]; X X /* copy argv to argblk, possibly inserting a flag such as "-R" */ X argblk[0] = ELVIS; X i = j = 1; X switch (letter) X { X case 'w': /* "view" */ X case 'W': X argblk[i++] = "-R"; X break; X#if !OSK X case 'x': /* "ex" */ X case 'X': X argblk[i++] = "-e"; X break; X#endif X case 't': /* "input" */ X case 'T': X argblk[i++] = "-i"; X break; X } X while (j < argc) X { X argblk[i++] = argv[j++]; X } X argblk[i] = (char *)0; X X /* execute the real ELVIS program */ X#if OSK X pid = os9exec(chainc, argblk[0], argblk, environ, 0, 0, 3); X fprintf(stderr, "%s: cannot execute\n", argblk[0]); X#else X (void)execvp(argblk[0], argblk); X perror(ELVIS); X#endif X} eof if test `wc -c atari.c <<\eof X/* atari.c */ X X/* Author: X * Guntram Blohm X * Buchenstrasse 19 X * 7904 Erbach, West Germany X * Tel. ++49-7305-6997 X * sorry - no regular network connection X */ X X/* X * This file contains the 'standard' functions which are not supported X * by Atari/Mark Williams, and some other TOS-only requirements. X */ X X#include "config.h" X#include "vi.h" X X#if TOS X#include X X/* vi uses mode==0 only ... */ Xint access(file, mode) X char *file; X{ X int fd=Fopen(file, 0); X if (fd<0) X return -1; X Fclose(fd); X return 0; X} X Xchar *mktemp(template) X char *template; X{ X return template; X} X X/* read -- text mode, compress \r\n to \n X * warning: might fail when maxlen==1 and at eol X */ X Xint tread(fd, buf, maxlen) X int fd; X char *buf; X int maxlen; X{ X int i, j, nread=read(fd, buf, (unsigned)maxlen); X X if (nread && buf[nread-1]=='\r') X { nread--; X lseek(fd, -1l, 1); X } X for (i=j=0; jctags.c <<\eof X/* ctags.c */ X X/* Author: X * Steve Kirkendall X * 14407 SW Teal Blvd. #C X * Beaverton, OR 97005 X * kirkenda@cs.pdx.edu X */ X X X/* This file contains the complete source to the ctags program. */ X X/* Special abilities: X * Can also make a "refs" file for use by the "ref" program. X */ X X/* Limitations: X * This version of ctags always writes its output to the file "tags". X * It assumes that every command-line argument (but "-r") is a C source file. X * It does not sort the list of tags, unless CFLAGS=-DSORT. X * It does not recognize duplicate definitions. X * It does not try to handle "static" functions in a clever way. X * It probably won't scan ANSI-C source code very well. X */ X X/* Implementation: X * Lines are scanned one-at-a-time. X * The context of lines is tracked via a finite state machine. X * Contexts are: X * EXPECTFN - we're looking for a function name. X * ARGS - between function name and its opening { X * BODY - we found a function name, skip to end of body. X * X * Function tags are referenced by a search string, so that lines may be X * inserted or deleted without mucking up the tag search. X * X * Macro tags are referenced by their line number, because 1) they usually X * occur near the top of a file, so their line# won't change much; 2) They X * often contain characters that are hard to search for; and 3) Their #define X * line is likely to be altered. X * X * Each line of the resulting "tags" file describes one tag. Lines begin with X * the tag name, then a tab, then the file name, then a tab, and then either X * a line number or a slash-delimited search string. X */ X X#include X#include X#include "config.h" X X#define REFS "refs" X X#if OSK X#define NUMFMT "%%.%ds\t%%s\t%%ld\n" X#define SRCHFMT "%%.%ds\t%%s\t/^%%s$/\n" X#define MAINFMT "M%%.%ds\t%%s\t/^%%s$/\n" Xstatic char fmt[256]; X#else X#define NUMFMT "%.*s\t%s\t%ld\n" X#define SRCHFMT "%.*s\t%s\t/^%s$/\n" X#define MAINFMT "M%.*s\t%s\t/^%s$/\n" X#endif X X#ifdef VERBOSE X# define SAY(x) fprintf(stderr, "%s\n", x); X#else X# define SAY(x) X#endif X X#define EXPECTFN 1 X#define ARGS 2 X#define BODY 3 X Xextern char *fgets(); X Xchar *progname; /* argv[0], used for diagnostic output */ X Xmain(argc, argv) X int argc; X char **argv; X{ X FILE *fp; X int i; X FILE *refs; /* used to write to the refs file */ X X#if MSDOS || TOS X char **wildexpand(); X argv=wildexpand(&argc, argv); X#endif X /* notice the program name */ X progname = argv[0]; X X /* create the "refs" file if first arg is "-r" */ X if (argc > 1 && !strcmp(argv[1], "-r")) X { X /* delete the "-r" flag from the args list */ X argc--; X argv++; X X /* open the "refs" file for writing */ X refs = fopen(REFS, "w"); X if (!refs) X { X fprintf(stderr, "%s: could not create \"%s\"\n", progname, REFS); X exit(2); X } X } X else X { X refs = (FILE *)0; X } X X /* process each file named on the command line, or complain if none */ X if (argc > 1) X { X /* redirect stdout to go to the "tags" file */ X if (!freopen("tags", "w", stdout)) X { X fprintf(stderr, "%s: could not create \"%s\"\n", progname, TAGS); X exit(2); X } X X for (i = 1; i < argc; i++) X { X /* process this named file */ X fp = fopen(argv[i], "r"); X if (!fp) X { X fprintf(stderr, "%s: could not read \"%s\"\n", progname, argv[i]); X continue; X } X ctags(fp, argv[i], refs); X fclose(fp); X } X#ifdef SORT X /* This is a hack which will sort the tags list. It should X * on UNIX and Minix. You may have trouble with csh. Note X * that the tags list only has to be sorted if you intend to X * use it with the real vi; elvis permits unsorted tags. X */ X fflush(stdout); X#if OSK X fclose(stdout); X system("qsort tags >-_tags; -nx; del tags; rename _tags tags"); X#else X system("sort tags >_tags$$; mv _tags$$ tags"); X#endif X#endif X exit(0); X } X else X { X fprintf(stderr, "usage: %s *.[ch]\n", progname); X exit(2); X } X} X X X/* this function finds all tags in a given file */ Xctags(fp, name, refs) X FILE *fp; /* stream of the file to scan */ X char *name; /* name of the file being scanned */ X FILE *refs; /* NULL, or where to write refs lines */ X{ X int context; /* context - either EXPECTFN, ARGS, or BODY */ X long lnum; /* line number */ X char text[1000]; /* a line of text from the file */ X char *scan; /* used for searching through text */ X int len; /* length of the line */ X X /* for each line of the file... */ X for (context = EXPECTFN, lnum = 1; fgets(text, sizeof text, fp); lnum++) X { X#ifdef VERBOSE X switch(context) X { X case EXPECTFN: scan = "EXPECTFN"; break; X case ARGS: scan = "ARGS "; break; X case BODY: scan = "BODY "; break; X default: scan = "context?"; X } X fprintf(stderr, "%s:%s", scan, text); X#endif X X /* start of body? */ X if (text[0] == '{') X { X context = BODY; X SAY("Start of BODY"); X continue; X } X X /* argument line, to be written to "refs" ? */ X if (refs && context == ARGS) X { X if (text[0] != '\t') X { X putc('\t', refs); X } X fputs(text, refs); X SAY("Argument line"); X continue; X } X X /* ignore empty or indented lines */ X if (text[0] <= ' ') X { X SAY("Empty or indented"); X continue; X } X X /* end of body? */ X if (text[0] == '}') X { X context = EXPECTFN; X SAY("End of BODY"); X continue; X } X X /* ignore lines in the body of a function */ X if (context != EXPECTFN) X { X SAY("BODY or ARGS"); X continue; X } X X /* strip the newline */ X len = strlen(text); X text[--len] = '\0'; X X /* a preprocessor line? */ X if (text[0] == '#') X { X /* find the preprocessor directive */ X for (scan = &text[1]; isspace(*scan); scan++) X { X } X X /* if it's a #define, make a tag out of it */ X if (!strncmp(scan, "define", 6)) X { X /* find the start of the symbol name */ X for (scan += 6; isspace(*scan); scan++) X { X } X X /* find the length of the symbol name */ X for (len = 1; X isalnum(scan[len]) || scan[len] == '_'; X len++) X { X } X#if OSK X sprintf(fmt, NUMFMT, len); X printf(fmt, scan, name, lnum); X#else X printf(NUMFMT, len, scan, name, lnum); X#endif X } X SAY("Preprocessor line"); X continue; X } X X /* an extern or static declaration? */ X if (text[len - 1] == ';' X || !strncmp(text, "extern", 6) X || !strncmp(text, "EXTERN", 6) X || !strncmp(text, "static", 6) X || !strncmp(text, "PRIVATE", 7)) X { X SAY("Extern or static"); X continue; X } X X /* if we get here & the first punctuation other than "*" is X * a "(" which is immediately preceded by a name, then X * assume the name is that of a function. X */ X for (scan = text; *scan; scan++) X { X if (ispunct(*scan) X && !isspace(*scan) /* in BSD, spaces are punctuation?*/ X && *scan != '*' && *scan != '_' && *scan != '(') X { X SAY("Funny punctuation"); X goto ContinueContinue; X } X X if (*scan == '(') X { X /* permit 0 or 1 spaces between name & '(' */ X if (scan > text && scan[-1] == ' ') X { X scan--; X } X X /* find the start & length of the name */ X for (len = 0, scan--; X scan >= text && (isalnum(*scan) || *scan == '_'); X scan--, len++) X { X } X scan++; X X /* did we find a function? */ X if (len > 0) X { X /* found a function! */ X if (len == 4 && !strncmp(scan, "main", 4)) X { X#if OSK X sprintf(fmt, MAINFMT, strlen(name) - 2); X printf(fmt, name, name, text); X#else X printf(MAINFMT, strlen(name) - 2, name, name, text); X#endif X } X#if OSK X sprintf(fmt, SRCHFMT, len); X printf(fmt, scan, name, text); X#else X printf(SRCHFMT, len, scan, name, text); X#endif X context = ARGS; X X /* add a line to refs, if needed */ X if (refs) X { X fputs(text, refs); X putc('\n', refs); X } X X goto ContinueContinue; X } X } X else X { X SAY("No parenthesis"); X } X } X SAY("No punctuation"); X XContinueContinue:; X } X} X X#if MSDOS || TOS X#define WILDCARD_NO_MAIN X#include "wildcard.c" X#endif eof if test `wc -c pc.c <<\eof X/* pc.c */ X X/* Author: X * Guntram Blohm X * Buchenstrasse 19 X * 7904 Erbach, West Germany X * Tel. ++49-7305-6997 X * sorry - no regular network connection X */ X X/* This file implements the ibm pc bios interface. See IBM documentation X * for details. X * If TERM is set upon invocation of elvis, this code is ignored completely, X * and the standard termcap functions are used, thus, even not-so-close X * compatibles can run elvis. For close compatibles however, bios output X * is much faster (and permits reverse scrolling, adding and deleting lines, X * and much more ansi.sys isn't capable of). GB. X */ X X#include "config.h" X#include "vi.h" X X#if MSDOS X X#include X Xstatic void video(); X X/* vmode contains the screen attribute index and is set by attrset.*/ X Xint vmode; X X/* The following array contains attribute definitions for X * color/monochrome attributes. Screen selects one of the sets. X * Maybe i'll put them into elvis options one day. X */ X Xstatic int screen; Xstatic char attr[2][5] = X{ X /* :se: :so: :VB: :ul: :as: */ X { 0x1f, 0x1d, 0x1e, 0x1a, 0x1c, }, /* color */ X { 0x07, 0x70, 0x0f, 0x01, 0x0f, }, /* monochrome */ X}; X X/* X * bios interface functions for elvis - pc version X */ X X/* cursor up: determine current position, decrement row, set position */ X Xvoid v_up() X{ X int dx; X video(0x300,(int *)0,&dx); X dx-=0x100; X video(0x200,(int *)0,&dx); X} X X#ifndef NO_CURSORSHAPE X/* cursor big: set begin scan to end scan - 4 */ Xvoid v_cb() X{ X int cx; X video(0x300, &cx, (int *)0); X cx=((cx&0xff)|(((cx&0xff)-4)<<8)); X video(0x100, &cx, (int *)0); X} X X/* cursor small: set begin scan to end scan - 1 */ Xvoid v_cs() X{ X int cx; X video(0x300, &cx, (int *)0); X cx=((cx&0xff)|(((cx&0xff)-1)<<8)); X video(0x100, &cx, (int *)0); X} X#endif X X/* clear to end: get cursor position and emit the aproppriate number X * of spaces, without moving cursor. X */ X Xvoid v_ce() X{ X int cx, dx; X video(0x300,(int *)0,&dx); X cx=COLS-(dx&0xff); X video(0x920,&cx,(int *)0); X} X X/* clear screen: clear all and set cursor home */ X Xvoid v_cl() X{ X int cx=0, dx=((LINES-1)<<8)+COLS-1; X video(0x0600,&cx,&dx); X dx=0; X video(0x0200,&cx,&dx); X} X X/* clear to bottom: get position, clear to eol, clear next line to end */ X Xvoid v_cd() X{ X int cx, dx, dxtmp; X video(0x0300,(int *)0,&dx); X dxtmp=(dx&0xff00)|(COLS-1); X cx=dx; X video(0x0600,&cx,&dxtmp); X cx=(dx&0xff00)+0x100; X dx=((LINES-1)<<8)+COLS-1; X video(0x600,&cx,&dx); X} X X/* add line: scroll rest of screen down */ X Xvoid v_al() X{ X int cx,dx; X video(0x0300,(int *)0,&dx); X cx=(dx&0xff00); X dx=((LINES-1)<<8)+COLS-1; X video(0x701,&cx,&dx); X} X X/* delete line: scroll rest up */ X Xvoid v_dl() X{ X int cx,dx; X video(0x0300,(int *)0,&dx); X cx=(dx&0xff00)/*+0x100*/; X dx=((LINES-1)<<8)+COLS-1; X video(0x601,&cx,&dx); X} X X/* scroll reverse: scroll whole screen */ X Xvoid v_sr() X{ X int cx=0, dx=((LINES-1)<<8)+COLS-1; X video(0x0701,&cx,&dx); X} X X/* set cursor */ X Xvoid v_move(x,y) X int x, y; X{ X int dx=(y<<8)+x; X video(0x200,(int *)0,&dx); X} X X/* put character: set attribute first, then execute char. X * Also remember if current line has changed. X */ X Xint v_put(ch) X int ch; X{ X int cx=1; X ch&=0xff; X if (ch>=' ') X video(0x900|ch,&cx,(int *)0); X video(0xe00|ch,(int *)0, (int *)0); X if (ch=='\n') X { exwrote = TRUE; X video(0xe0d, (int *)0, (int *)0); X } X return ch; X} X X/* determine number of screen columns. Also set attrset according X * to monochrome/color screen. X */ X Xint v_cols() X{ X union REGS regs; X regs.h.ah=0x0f; X int86(0x10, ®s, ®s); X if (regs.h.al==7) /* monochrome mode ? */ X screen=1; X else X screen=0; X return regs.h.ah; X} X X/* Getting the number of rows is hard. Most screens support 25 only, X * EGA/VGA also support 43/50 lines, and some OEM's even more. X * Unfortunately, there is no standard bios variable for the number X * of lines, and the bios screen memory size is always rounded up X * to 0x1000. So, we'll really have to cheat. X * When using the screen memory size, keep in mind that each character X * byte has an associated attribute byte. X * X * uses: word at 40:4c contains memory size X * byte at 40:84 # of rows-1 (sometimes) X * byte at 40:4a # of columns X */ X Xint v_rows() X{ X int line, oldline; X X /* screen size less then 4K? then we have 25 lines only */ X X if (*(int far *)(0x0040004cl)<=4096) X return 25; X X /* VEGA vga uses the bios byte at 0x40:0x84 for # of rows. X * Use that byte, if it makes sense together with memory size. X */ X X if ((((*(unsigned char far *)(0x0040004aL)*2* X (*(unsigned char far *)(0x00400084L)+1))+0xfff)&(~0xfff))== X *(unsigned int far *)(0x0040004cL)) X return *(unsigned char far *)(0x00400084L)+1; X X /* uh oh. Emit '\n's until screen starts scrolling. */ X X v_move(oldline=0, 0); X for (;;) X { X video(0xe0a,(int *)0,(int *)0); X video(0x300,(int *)0,&line); X line>>=8; X if (oldline==line) X return line+1; X oldline=line; X } X} X X/* the REAL bios interface -- used internally only. */ X Xstatic void video(ax, cx, dx) X int ax, *cx, *dx; X{ X union REGS regs; X X regs.x.ax=ax; X if ((ax&0xff00)==0x600 || (ax&0xff00)==0x700) X regs.h.bh=attr[screen][vmode]; X else X { X regs.h.bh=0; X regs.h.bl=attr[screen][vmode]; X } X if (cx) regs.x.cx=*cx; X if (dx) regs.x.dx=*dx; X int86(0x10, ®s, ®s); X if (dx) *dx=regs.x.dx; X if (cx) *cx=regs.x.cx; X} X X/* The following function determines which character is used for X * commandline-options by command.com. This system call is undocumented X * and valid for versions < 4.00 only. X */ X Xint switchar() X{ X union REGS regs; X regs.x.ax=0x3700; X int86(0x21, ®s, ®s); X return regs.h.dl; X} X X#endif eof if test `wc -c ref.c <<\eof X/* ref.c */ X X/* Author: X * Steve Kirkendall X * 14407 SW Teal Blvd. #C X * Beaverton, OR 97005 X * kirkenda@cs.pdx.edu X */ X X X/* This program looks up the declarations of library functions. */ X X#include X X/* This is the list of files that are searched. */ X#ifdef OSK Xchar *refslist[] = { X "refs", X "/dd/usr/src/lib/refs", X "../lib/refs", X "/dd/usr/local/lib/refs", X}; X#else Xchar *refslist[] = { X "refs", X "/usr/src/lib/refs", X "../lib/refs", X "/usr/local/lib/refs" X}; X#endif X#define NREFS (sizeof refslist / sizeof(char *)) X Xmain(argc, argv) X int argc; X char **argv; X{ X int i; /* used to step through the refslist */ X X /* make sure our arguments are OK */ X if (argc != 2) X { X fprintf(stderr, "usage: %s function_name\n", *argv); X exit(2); X } X X /* check for the function in each database */ X for (i = 0; i < NREFS; i++) X { X if (lookinfor(refslist[i], argv[1])) X { X exit(0); X } X } X X fprintf(stderr, "%s: don't know about %s\n", argv[0], argv[1]); X exit(2); X} X X X/* This function checks a single file for the function. Returns 1 if found */ Xint lookinfor(filename, func) X char *filename; /* name of file to look in */ X char *func; /* name of function to look for */ X{ X FILE *fp; /* stream used to access the database */ X char linebuf[300]; X /* NOTE: in actual use, the first character of linebuf is */ X /* set to ' ' and then we use all EXCEPT the 1st character */ X /* everywhere in this function. This is because the func */ X /* which examines the linebuf could, in some circumstances */ X /* examine the character before the used part of linebuf; */ X /* we need to control what happens then. */ X X X /* open the database file */ X fp = fopen(filename, "r"); X if (!fp) X { X return 0; X } X X /* find the desired entry */ X *linebuf = ' '; X do X { X if (!fgets(linebuf + 1, (sizeof linebuf) - 1, fp)) X { X fclose(fp); X return 0; X } X } while (!desired(linebuf + 1, func)); X X /* print it */ X do X { X fputs(linebuf + 1, stdout); X } while (fgets(linebuf + 1, sizeof linebuf, fp) && linebuf[1] == '\t'); X X /* cleanup & exit */ X fclose(fp); X return 1; X} X X X/* This function checks to see if a given line is the first line of the */ X/* entry the user wants to see. If it is, return non-0 else return 0 */ Xdesired(line, word) X char *line; /* the line buffer */ X char *word; /* the string it should contain */ X{ X static wlen = -1;/* length of the "word" variable's value */ X register char *scan; X X /* if this line starts with a tab, it couldn't be desired */ X if (*line == '\t') X { X return 0; X } X X /* if we haven't found word's length yet, do so */ X if (wlen < 0) X { X wlen = strlen(word); X } X X /* search for the word in the line */ X for (scan = line; *scan != '('; scan++) X { X } X while (*--scan == ' ') X { X } X scan -= wlen; X if (scan < line - 1 || *scan != ' ' && *scan != '\t' && *scan != '*') X { X return 0; X } X scan++; X return !strncmp(scan, word, wlen); X} eof if test `wc -c shell.c <<\eof X/* shell.c */ X X/* Author: X * Guntram Blohm X * Buchenstrasse 19 X * 7904 Erbach, West Germany X * Tel. ++49-7305-6997 X * sorry - no regular network connection X */ X X/* X * This file contains a minimal version of a shell for TOS. It allows the X * setting of an environment, calling programs, and exiting. X * If you don't have another one, this might be sufficient, but you should X * prefer *any* other shell. X * You may, however, want to set your SHELL environment variable to this X * shell: it implements the -c switch, which is required by Elvis, and X * not supported by most other atari shells. X */ X X#include X#include X#include Xextern char *getenv(), *malloc(); Xextern char **environ; Xlong _stksize=16384; X X#define MAXENV 50 X Xstruct X{ X char *name; X char *value; X} myenv[MAXENV]; X Xint cmd_set(), cmd_exit(); X Xstruct buildins X{ X char *name; X int (*func)(); X} buildins[]= X{ "exit", cmd_exit, X "set", cmd_set, X 0, X}; X Xmain(argc, argv) X int argc; X char **argv; X{ X char buf[128]; X int i; X X for (i=0; environ[i] && strncmp(environ[i],"ARGV=",5); i++) X cmd_set(environ[i]); X script("profile.sh"); X X if (argc>1 && !strcmp(argv[1], "-c")) X { X buf[0]='\0'; X for (i=2; i2) X strcat(buf, " "); X strcat(buf, argv[i]); X } X execute(buf); X } X else X while (fputs("$ ", stdout), gets(buf)) X execute(buf); X} X Xexecute(buf) X char *buf; X{ X char *scan=buf; X char cmd[80]; X char line[128]; X char env[4096], *ep=env; X int i; X X while (*scan==' ') X scan++; X if (!*scan) X return; X while (*scan && *scan!=' ') X scan++; X if (*scan) X *scan++='\0'; X X for (i=0; buildins[i].name; i++) X if (!strcmp(buf, buildins[i].name)) X return (*buildins[i].func)(scan); X X if (!searchpath(buf, cmd)) X { printf("%s: not found\n", buf); X return -1; X } X X strcpy(line+1, scan); X line[0]=strlen(scan); X for (i=0; isysdos.c <<\eof X/* sysdos.c -- DOS version of system.c */ X X/* Author: X * Guntram Blohm X * Buchenstrasse 19 X * 7904 Erbach, West Germany X * Tel. ++49-7305-6997 X * sorry - no regular network connection X */ X X X/* This file is derived from Steve Kirkendall's system.c. X * X * Entry points are: X * system(cmd) - run a single shell command X * wildcard(names) - expand wildcard characters in filanames X * X * This file is for use with DOS and TOS. For OS/2, slight modifications X * might be sufficient. For UNIX, use system.c. For Amiga, completely X * rewrite this stuff. X * X * Another system function, filter, is the same on DOS and UNIX and thus X * can be found in the original system.c. X */ X X#include "config.h" X#include "vi.h" Xextern char **environ; X X X#if MSDOS X#include Xextern unsigned char _osmajor; X#endif X#if TOS X#include X#endif X X X#if MSDOS || TOS X#include X X/* X * Calling command is a bit nasty because of the undocumented yet sometimes X * used feature to change the option char to something else than /. X * Versions 2.x and 3.x support this, 4.x doesn't. X * X * For Atari, some shells define a shortcut entry which is faster than X * shell -c. Also, Mark Williams uses a special ARGV environment variable X * to pass more than 128 chars to a called command. X * We try to support all of these features here. X */ X Xint system(cmd) X const char *cmd; X{ X#if MSDOS X char *cmdswitch="/c"; X if (_osmajor<4) X cmdswitch[0]=switchar(); X return spawnle(P_WAIT, o_shell, o_shell, cmdswitch, cmd, (char *)0, environ); X#else X long ssp; X int (*shell)(); X char line[130]; X char env[4096], *ep=env; X int i; X X/* does our shell have a shortcut, that we can use? */ X X ssp = Super(0L); X shell = *((int (**)())0x4F6); X Super(ssp); X if (shell) X return (*shell)(cmd); X X/* else we'll have to call a shell ... */ X X for (i=0; environ[i] && strncmp(environ[i], "ARGV=", 5); i++) X { strcpy(ep, environ[i]); X ep+=strlen(ep)+1; X } X if (environ[i]) X { X strcpy(ep, environ[i]); ep+=strlen(ep)+1; X strcpy(ep, o_shell); ep+=strlen(ep)+1; X strcpy(ep, "-c"); ep+=3; X strcpy(ep, cmd); ep+=strlen(ep)+1; X } X *ep='\0'; X strcpy(line+1, "-c "); X strncat(line+1, cmd, 126); X line[0]=strlen(line+1); X return Pexec(0, o_shell, line, env); X#endif X} X X/* This private function opens a pipe from a filter. It is similar to the X * system() function above, and to popen(cmd, "r"). X * sorry - i cant use cmdstate until rpclose, but get it from spawnle. X */ X Xstatic int cmdstate; Xstatic char output[80]; X Xint rpipe(cmd, in) X char *cmd; /* the filter command to use */ X int in; /* the fd to use for stdin */ X{ X int fd, old0, old1, old2; X X /* create the file that will collect the filter's output */ X strcpy(output, o_directory); X if ((fd=strlen(output)) && !strchr("/\\:", output[fd-1])) X output[fd++]=SLASH; X strcpy(output+fd, SCRATCHIN+3); X mktemp(output); X close(creat(output, 0666)); X if ((fd=open(output, O_RDWR))==-1) X { X unlink(output); X return -1; X } X X /* save and redirect stdin, stdout, and stderr */ X old0=dup(0); X old1=dup(1); X if (in) X { X dup2(in, 0); X close(in); X } X dup2(fd, 1); X X /* call command */ X cmdstate=system(cmd); X X /* restore old std... */ X dup2(old0, 0); close(old0); X dup2(old1, 1); close(old1); X X /* rewind command output */ X lseek(fd, 0L, 0); X return fd; X} X X/* This function closes the pipe opened by rpipe(), and returns 0 for success */ Xint rpclose(fd) X int fd; X{ X int status; X X close(fd); X unlink(output); X return cmdstate; X} X X#endif eof if test `wc -c virec.c <<\eof X/* virec.c */ X X/* Author: X * Steve Kirkendall X * 14407 SW Teal Blvd. #C X * Beaverton, OR 97005 X * kirkenda@cs.pdx.edu X */ X X/* This file contains the file recovery program */ X X X#include "config.h" X#include X#include X#include "vi.h" X#if TOS X# include X#else X# if OSK X# include "osk.h" X# else X# include X# endif X#endif X Xextern char *getenv(); Xstruct stat stbuf; XBLK hdr; XBLK text; X X/* the name of the directory where tmp files are stored. */ Xchar o_directory[30] = TMPDIR; X Xchar *progname; X Xmain(argc, argv) X int argc; X char **argv; X{ X char *tmp; X void recover(); X#if MSDOS || TOS X char **wildexpand(); X argv = wildexpand(&argc, argv); X#endif X progname = argv[0]; X /* set the o_directory variable */ X if ((tmp = getenv("TMP")) /* yes, ASSIGNMENT! */ X || (tmp = getenv("TEMP"))) /* yes, ASSIGNMENT! */ X { X strcpy(o_directory, tmp); X } X if (argc >= 3 && !strcmp(argv[1], "-d")) X { X strcpy(o_directory, argv[2]); X argc -= 2; X argv += 2; X } X /* process the arguments */ X if (argc < 2) X { X /* maybe stdin comes from a file? */ X if (isatty(0)) X { X fprintf(stderr, "usage: %s [-d tmpdir] lostfile...\n", progname); X } X else if (read(0, &hdr, (unsigned)BLKSIZE) != BLKSIZE) X { X fprintf(stderr, "couldn't get header\n"); X } X else X { X copytext(0, stdout); X } X } X else X { X while (--argc > 0) X { X recover(*++argv); X } X } X exit(0); X} X X X/* This function recovers a single file */ Xvoid recover(filename) X char *filename; X{ X char tmpname[100]; X int tmpfd; X FILE *fp; X long mtime; X int i, j; X int sum; /* used for calculating a checksum for this */ X char *scan; X X /* get the file's status info */ X if (stat(filename, &stbuf) < 0) X { X /* if serious error, give up on this file */ X if (errno != ENOENT) X { X perror(filename); X return; X } X X /* else fake it for a new file */ X stat(".", &stbuf); X#if OSK X stbuf.st_mode = S_IREAD; X#else X stbuf.st_mode = S_IFREG; X#endif X stbuf.st_mtime = 0L; X } X X /* generate a checksum from the file's name */ X for (sum = 0, scan = filename + strlen(filename); X --scan >= filename && (isascii(*scan) && isalnum(*scan) || *scan == '.'); X sum = sum + *scan) X { X } X sum &= 0xf; X X /* find the tmp file */ X#if MSDOS || TOS X /* MS-Dos doesn't allow multiple slashes, but supports drives X * with current directories. X * This relies on TMPNAME beginning with "%s\\"!!!! X */ X strcpy(tmpname, o_directory); X if ((i = strlen(tmpname)) && !strchr(":/\\", tmpname[i-1])) X tmpname[i++]=SLASH; X sprintf(tmpname+i, TMPNAME+3, sum, stbuf.st_ino, stbuf.st_dev); X#else X sprintf(tmpname, TMPNAME, o_directory, sum, stbuf.st_ino, stbuf.st_dev); X#endif X tmpfd = open(tmpname, O_RDONLY | O_BINARY); X if (tmpfd < 0) X { X perror(tmpname); X return; X } X X /* make sure the file hasn't been modified more recently */ X mtime = stbuf.st_mtime; X fstat(tmpfd, &stbuf); X if (stbuf.st_mtime < mtime) X { X printf("\"%s\" has been modified more recently than its recoverable version\n", filename); X puts("Do you still want to recover it?\n"); X puts("\ty - Yes, discard the current version and recover it.\n"); X puts("\tn - No, discard the recoverable version and keep the current version\n"); X puts("\tq - Quit without doing anything for this file.\n"); X puts("Enter y, n, or q --> "); X fflush(stdout); X for (;;) X { X switch (getchar()) X { X case 'y': X case 'Y': X goto BreakBreak; X X case 'n': X case 'N': X close(tmpfd); X unlink(tmpname); X return; X X case 'q': X case 'Q': X close(tmpfd); X return; X } X } XBreakBreak:; X } X X /* make sure this tmp file is intact */ X if (read(tmpfd, &hdr, (unsigned)BLKSIZE) != BLKSIZE) X { X fprintf(stderr, "%s: bad header in tmp file\n", filename); X close(tmpfd); X unlink(tmpname); X return; X } X for (i = j = 1; i < MAXBLKS && hdr.n[i]; i++) X { X if (hdr.n[i] > j) X { X j = hdr.n[i]; X } X } X lseek(tmpfd, (long)j * (long)BLKSIZE, 0); X if (read(tmpfd, &text, (unsigned)BLKSIZE) != BLKSIZE) X { X fprintf(stderr, "%s: bad data block in tmp file\n", filename); X close(tmpfd); X unlink(tmpname); X return; X } X X /* open the normal text file for writing */ X fp = fopen(filename, "w"); X if (!fp) X { X perror(filename); X close(tmpfd); X return; X } X X /* copy the text */ X copytext(tmpfd, fp); X X /* cleanup */ X close(tmpfd); X fclose(fp); X unlink(tmpname); X} X X X/* This function moves text from the tmp file to the normal file */ Xcopytext(tmpfd, fp) X int tmpfd; /* fd of the tmp file */ X FILE *fp; /* the stream to write it to */ X{ X int i; X X /* write the data blocks to the normal text file */ X for (i = 1; i < MAXBLKS && hdr.n[i]; i++) X { X lseek(tmpfd, (long)hdr.n[i] * (long)BLKSIZE, 0); X read(tmpfd, &text, (unsigned)BLKSIZE); X fputs(text.c, fp); X } X} X X#if MSDOS || TOS X#define WILDCARD_NO_MAIN X#include "wildcard.c" X#endif eof if test `wc -c wildcard.c <<\eof X/* wildcard.c */ X X/* Author: X * Guntram Blohm X * Buchenstrasse 19 X * 7904 Erbach, West Germany X * Tel. ++49-7305-6997 X * sorry - no regular network connection X */ X X/* this program implements wildcard expansion for elvis/dos. It works X * like UNIX echo, but uses the dos wildcard conventions X * (*.* matches all files, * matches files without extension only, X * filespecs may contain drive letters, wildcards not allowed in directory X * names). X * X * It is also #included into ctags.c, ref.c, ...; in this case, X * we don't want a main function here. X */ X X#include X#include X#ifdef __TURBOC__ X#include X#endif X#ifdef M_I86 X#define findfirst(a,b,c) _dos_findfirst(a,c,b) X#define findnext _dos_findnext X#define ffblk find_t X#define ff_name name X#include X#endif X#ifdef M68000 X#include X#include X#define findfirst(a,b,c) (Fsetdta(b), (Fsfirst(a,c))) X#define findnext(x) (Fsnext()) X#define ff_name d_fname X#endif X#define MAXFILES 1000 X Xint pstrcmp(); Xextern char *calloc(); X Xchar *files[MAXFILES]; Xint nfiles; X X#ifndef WILDCARD_NO_MAIN X Xmain(argc, argv) X char **argv; X{ X int i; X X for (i=1; i=buf) X { if (*filespec=='?' || *filespec=='*') X wildcard=1; X if (*filespec=='/' || *filespec=='\\' || *filespec==':') X break; X } X if (!wildcard) X addfile(buf); X else X { X lastn=nfiles; X filespec++; X if ((err=findfirst(buf, &findbuf, 0))!=0) X addfile(buf); X while (!err) X { X strcpy(filespec, findbuf.ff_name); X addfile(buf); X err=findnext(&findbuf); X } X if (lastn!=nfiles) X qsort(files+lastn, nfiles-lastn, sizeof(char *), pstrcmp); X } X} X Xaddfile(buf) X char *buf; X{ X char *p; X X for (p=buf; *p; p++) X *p=tolower(*p); X X if (nfilesprofile.sh <<\eof Xset TERM=vt52 Xset SHELL=shell eof if test `wc -c osk.c <<\eof X/* osk.c */ X X/* ------------------------------------------------------------------- * X | X | OS9Lib: stat(), fstat() X | X | X | Copyright (c) 1988 by Wolfgang Ocker, Puchheim, X | Ulli Dessauer, Germering and X | Reimer Mellin, Muenchen X | (W-Germany) X | X | This programm can be copied and distributed freely for any X | non-commercial purposes. It can only be incorporated into X | commercial software with the written permission of the authors. X | X | If you should modify this program, the authors would appreciate X | a notice about the changes. Please send a (context) diff or the X | complete source to: X | X | address: Wolfgang Ocker X | Lochhauserstrasse 35a X | D-8039 Puchheim X | West Germany X | X | e-mail: weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP X | pyramid!tmpmbx!recco!weo X | pyramid!tmpmbx!nitmar!ud X | pyramid!tmpmbx!ramsys!ram X | X * ----------------------------------------------------------------- */ X X#ifdef OSK X X#define PATCHLEVEL 1 X X#ifndef VIREC X#include X#include "osk.h" X#include X#include X#endif X#include X#include X#include X#include X X/* X * f s t a t X */ Xint fstat(fd, buff) X int fd; X struct stat *buff; X{ X struct fildes ftmp; X struct tm ttmp; X struct _sgr fopt; X X if (_gs_gfd(fd, &ftmp, 16) < 0) /* 16 insteat of sizeof(struct fildes) */ X return(-1); /* used due to a bug in stupid os9net */ X X if (_gs_opt(fd, &fopt) < 0) X return(-1); X X ttmp.tm_year = (int) ftmp.fd_date[0]; X ttmp.tm_mon = (int) ftmp.fd_date[1] - 1; X ttmp.tm_mday = (int) ftmp.fd_date[2]; X ttmp.tm_hour = (int) ftmp.fd_date[3]; X ttmp.tm_min = (int) ftmp.fd_date[4]; X ttmp.tm_sec = 0; X ttmp.tm_isdst = -1; X X buff->st_atime = buff->st_mtime = mktime(&ttmp); X X ttmp.tm_year = (int) ftmp.fd_dcr[0]; X ttmp.tm_mon = (int) ftmp.fd_dcr[1] - 1; X ttmp.tm_mday = (int) ftmp.fd_dcr[2]; X ttmp.tm_hour = ttmp.tm_min = ttmp.tm_sec = 0; X ttmp.tm_isdst = -1; X X buff->st_ctime = mktime(&ttmp); X X memcpy(&(buff->st_size), ftmp.fd_fsize, sizeof(long)); /* misalignment! */ X buff->st_uid = ftmp.fd_own[1]; X buff->st_gid = ftmp.fd_own[0]; X buff->st_mode = ftmp.fd_att; X buff->st_nlink = ftmp.fd_link; X X buff->st_ino = fopt._sgr_fdpsn; X buff->st_dev = fopt._sgr_dvt; X X return(0); X} X X/* X * s t a t X */ Xint stat(filename, buff) X char *filename; X struct stat *buff; X{ X register int i, ret; X X if ((i = open(filename, S_IREAD)) < 0) X if ((i = open(filename, S_IFDIR | S_IREAD)) < 0) X return(-1); X X ret = fstat(i, buff); X close(i); X X return(ret); X} X X/* X unix library functions mist in OSK X Author: Peter Reinig X*/ X X/* NOTE: this version of link() is only capable of renaming files, not true X * UNIX-style linking. That's okay, though, because elvis only uses it for X * renaming. X */ Xlink(from,to) Xchar *from,*to; X{ X char *buffer; X int status; X char *malloc(); X X if ((buffer = malloc(strlen(from) + strlen(to) + 12)) == NULL) X return -1; X sprintf(buffer,"rename %s %s\n",from,to); X status = system(buffer); X free(buffer); X return status; X} X Xtypedef (*procref)(); X#define MAX_SIGNAL 10 X Xextern exit(); X Xstatic int (*sig_table[MAX_SIGNAL])(); Xstatic int _sig_install = 0; X Xsig_handler(sig) Xint sig; X{ X if ((int) sig_table[sig] > MAX_SIGNAL) X sig_table[sig](sig); X} X Xprocref signal(sig,func) Xint sig; Xint (*func)(); X{ X int i, (*sav)(); X X if (!_sig_install) { X for (i=0; i < MAX_SIGNAL; i++) X sig_table[i] = exit; X _sig_install = 1; X intercept(sig_handler); X } X sav = sig_table[sig]; X switch ((int) func) { X case SIG_DFL : sig_table[sig] = exit; X break; X case SIG_IGN : sig_table[sig] = 0; X break; X default : sig_table[sig] = func; X break; X } X return sav; X} X Xperror(str) Xchar *str; X{ X static int path = 0; X if (!path && (path = open("/dd/sys/Errmsg", S_IREAD)) == -1) { X fprintf(stderr,"Can\'t open error message file\n"); X path = 0; X } X if (str && *str) { X fprintf(stderr,"%s: ",str); X fflush(stderr); X } X prerr(path,(short) errno); X} X Xisatty(fd) Xint fd; X{ X struct sgbuf buffer; X char type; X X _gs_opt(fd,&buffer); X type = buffer.sg_class; X if (type == DT_SCF) X return 1; X else X return 0; X} X#endif /* OSK */ eof if test `wc -c osk.h <<\eof X/* X * OS9 stat : @(#)stat.h 1.2 87/19/12 X */ X/* @(#)stat.h 6.1 */ X/* X * Structure of the result of stat X */ X X#ifndef CLK_TCK X#include X#endif X Xstruct stat X{ X int st_dev; X long st_ino; X unsigned short st_mode; X unsigned short st_nlink; X unsigned short st_uid; X unsigned short st_gid; X int st_rdev; X long st_size; X time_t st_atime; X time_t st_mtime; X time_t st_ctime; X}; eof if test `wc -c date.c <<\eof eof if test `wc -c