home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2194 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  60.1 KB

  1. From: kirkenda@eecs.cs.pdx.edu (Steve Kirkendall)
  2. Newsgroups: alt.sources
  3. Subject: Elvis 1.4, part 3 of 8
  4. Message-ID: <827@pdxgate.UUCP>
  5. Date: 3 Dec 90 21:29:59 GMT
  6.  
  7.  
  8. # --------------------------- cut here ----------------------------
  9. # This is a shar archive.  To unpack it, save it to a file, and delete
  10. # anything above the "cut here" line.  Then run sh on the file.
  11. #
  12. # -rw-r--r--  1 kirkenda      341 Dec  2 17:56 Elvis.lnk
  13. # -rw-r--r--  1 kirkenda     2237 Dec  2 17:56 Elvis.mak
  14. # -rw-r--r--  1 kirkenda      162 Dec  2 17:56 Elvis.prj
  15. # -rw-r--r--  1 kirkenda    12152 Dec  2 17:56 Makefile.mix
  16. # -rw-r--r--  1 kirkenda     2032 Dec  2 17:56 alias.c
  17. # -rw-r--r--  1 kirkenda     1437 Dec  2 17:56 atari.c
  18. # -rw-r--r--  1 kirkenda     7855 Dec  2 17:56 ctags.c
  19. # -rw-r--r--  1 kirkenda        0 Dec  2 17:57 date.c
  20. # -rw-r--r--  1 kirkenda     4392 Dec  2 17:57 osk.c
  21. # -rw-r--r--  1 kirkenda      377 Dec  2 17:57 osk.h
  22. # -rw-r--r--  1 kirkenda     5512 Dec  2 17:57 pc.c
  23. # -rw-r--r--  1 kirkenda       30 Dec  2 17:57 profile.sh
  24. # -rw-r--r--  1 kirkenda     2872 Dec  2 17:57 ref.c
  25. # -rw-r--r--  1 kirkenda     3981 Dec  2 17:57 shell.c
  26. # -rw-r--r--  1 kirkenda     3438 Dec  2 17:57 sysdos.c
  27. # -rw-r--r--  1 kirkenda     4780 Dec  2 17:57 virec.c
  28. # -rw-r--r--  1 kirkenda     2424 Dec  2 17:57 wildcard.c
  29. #
  30.  
  31. if test -f Elvis.lnk -a "$1" != -f
  32. then
  33. echo Will not overwrite Elvis.lnk
  34. else
  35. echo Extracting Elvis.lnk
  36. sed 's/^X//' >Elvis.lnk <<\eof
  37. Xblk.obj cmd1.obj cmd2.obj curses.obj cut.obj +
  38. Xex.obj input.obj main.obj misc.obj modify.obj +
  39. Xmove1.obj move2.obj move3.obj move4.obj move5.obj +
  40. Xopts.obj recycle.obj redraw.obj regexp.obj +
  41. Xregsub.obj system.obj tio.obj tmp.obj vars.obj +
  42. Xvcmd.obj vi.obj pc.obj sysdos.obj tinytcap.obj /co /noi /map +
  43. X/pac /far /stack:0x4000 
  44. Xelvis.exe; 
  45. eof
  46. if test `wc -c <Elvis.lnk` -ne 341
  47. then
  48. echo Elvis.lnk damaged!
  49. fi
  50. fi
  51.  
  52. if test -f Elvis.mak -a "$1" != -f
  53. then
  54. echo Will not overwrite Elvis.mak
  55. else
  56. echo Extracting Elvis.mak
  57. sed 's/^X//' >Elvis.mak <<\eof
  58. X# Makefile for MSC - if you don't have NDmake, use this one,
  59. X# but don't expect to be happy.
  60. X# And don't expect to do anything but making the executables, either.
  61. X
  62. XOBJS=    blk.obj cmd1.obj cmd2.obj curses.obj cut.obj ex.obj input.obj \
  63. X    main.obj misc.obj modify.obj move1.obj move2.obj move3.obj move4.obj \
  64. X    move5.obj opts.obj recycle.obj redraw.obj regexp.obj regsub.obj \
  65. X    system.obj tio.obj tmp.obj vars.obj vcmd.obj vi.obj \
  66. X    pc.obj sysdos.obj tinytcap.obj
  67. X
  68. XCFLAGS=    -DCS_IBMPC -DCS_SPECIAL
  69. XCC=    cl -AM
  70. X    
  71. Xblk.obj:    blk.c
  72. X    $(CC) $(CFLAGS) -c blk.c
  73. X
  74. Xcmd1.obj:    cmd1.c
  75. X    $(CC) $(CFLAGS) -c cmd1.c
  76. X
  77. Xcmd2.obj:    cmd2.c
  78. X    $(CC) $(CFLAGS) -c cmd2.c
  79. X
  80. Xcurses.obj:    curses.c
  81. X    $(CC) $(CFLAGS) -c curses.c
  82. X
  83. Xcut.obj:    cut.c
  84. X    $(CC) $(CFLAGS) -c cut.c
  85. X
  86. Xex.obj:        ex.c
  87. X    $(CC) $(CFLAGS) -c ex.c
  88. X
  89. Xinput.obj:    input.c
  90. X    $(CC) $(CFLAGS) -c input.c
  91. X
  92. Xmain.obj:    main.c
  93. X    $(CC) $(CFLAGS) -c main.c
  94. X
  95. Xmisc.obj:    misc.c
  96. X    $(CC) $(CFLAGS) -c misc.c
  97. X
  98. Xmodify.obj:    modify.c
  99. X    $(CC) $(CFLAGS) -c modify.c
  100. X
  101. Xmove1.obj:    move1.c
  102. X    $(CC) $(CFLAGS) -c move1.c
  103. X
  104. Xmove2.obj:    move2.c
  105. X    $(CC) $(CFLAGS) -c move2.c
  106. X
  107. Xmove3.obj:    move3.c
  108. X    $(CC) $(CFLAGS) -c move3.c
  109. X
  110. Xmove4.obj:    move4.c
  111. X    $(CC) $(CFLAGS) -c move4.c
  112. X
  113. Xmove5.obj:    move5.c
  114. X    $(CC) $(CFLAGS) -c move5.c
  115. X
  116. Xopts.obj:    opts.c
  117. X    $(CC) $(CFLAGS) -c opts.c
  118. X
  119. Xrecycle.obj:    recycle.c
  120. X    $(CC) $(CFLAGS) -c recycle.c
  121. X
  122. Xredraw.obj:    redraw.c
  123. X    $(CC) $(CFLAGS) -c redraw.c
  124. X
  125. Xregexp.obj:    regexp.c
  126. X    $(CC) $(CFLAGS) -c regexp.c
  127. X
  128. Xregsub.obj:    regsub.c
  129. X    $(CC) $(CFLAGS) -c regsub.c
  130. X
  131. Xsystem.obj:    system.c
  132. X    $(CC) $(CFLAGS) -c system.c
  133. X
  134. Xtio.obj:    tio.c
  135. X    $(CC) $(CFLAGS) -c tio.c
  136. X
  137. Xtmp.obj:    tmp.c
  138. X    $(CC) $(CFLAGS) -c tmp.c
  139. X
  140. Xvars.obj:    vars.c
  141. X    $(CC) $(CFLAGS) -c vars.c
  142. X
  143. Xvcmd.obj:    vcmd.c
  144. X    $(CC) $(CFLAGS) -c vcmd.c
  145. X
  146. Xvi.obj:        vi.c
  147. X    $(CC) $(CFLAGS) -c vi.c
  148. X
  149. Xpc.obj:        pc.c
  150. X    $(CC) $(CFLAGS) -c pc.c
  151. X
  152. Xsysdos.obj:    sysdos.c
  153. X    $(CC) $(CFLAGS) -c sysdos.c
  154. X
  155. Xtinytcap.obj:    tinytcap.c
  156. X    $(CC) $(CFLAGS) -c tinytcap.c
  157. X
  158. Xelvis.exe: $(OBJS)
  159. X    link @elvis.lnk
  160. X
  161. Xctags.exe: ctags.c wildcard.c
  162. X    $(CC) ctags.c -o ctags.exe
  163. X
  164. Xref.exe: ref.c
  165. X    $(CC) ref.c -o ref.exe
  166. X
  167. Xvirec.exe: virec.c wildcard.c
  168. X    $(CC) virec.c -o virec.exe
  169. X
  170. Xwildcard.exe: wildcard.c
  171. X    $(CC) wildcard.c -o wildcard.exe
  172. X
  173. Xex.exe: alias.c
  174. X    $(CC) alias.c -o ex.exe
  175. X
  176. Xvi.exe: ex.exe
  177. X    copy ex.exe vi.exe
  178. X
  179. Xview.exe: ex.exe
  180. X    copy ex.exe view.exe
  181. eof
  182. if test `wc -c <Elvis.mak` -ne 2237
  183. then
  184. echo Elvis.mak damaged!
  185. fi
  186. fi
  187.  
  188. if test -f Elvis.prj -a "$1" != -f
  189. then
  190. echo Will not overwrite Elvis.prj
  191. else
  192. echo Extracting Elvis.prj
  193. sed 's/^X//' >Elvis.prj <<\eof
  194. Xblk
  195. Xcmd1
  196. Xcmd2
  197. Xcurses
  198. Xcut
  199. Xex
  200. Xinput
  201. Xmain
  202. Xmisc
  203. Xmodify
  204. Xmove1
  205. Xmove2
  206. Xmove3
  207. Xmove4
  208. Xmove5
  209. Xopts
  210. Xrecycle
  211. Xredraw
  212. Xregexp
  213. Xregsub
  214. Xsystem
  215. Xtio
  216. Xtmp
  217. Xvars
  218. Xvcmd
  219. Xvi
  220. Xpc
  221. Xsysdos
  222. Xtinytcap
  223. eof
  224. if test `wc -c <Elvis.prj` -ne 162
  225. then
  226. echo Elvis.prj damaged!
  227. fi
  228. fi
  229.  
  230. if test -f Makefile.mix -a "$1" != -f
  231. then
  232. echo Will not overwrite Makefile.mix
  233. else
  234. echo Extracting Makefile.mix
  235. sed 's/^X//' >Makefile.mix <<\eof
  236. X# combined Makefile for ELVIS - a clone of `vi`
  237. X#
  238. X# After editing this Makefile as described below, you should...
  239. X#
  240. X# Use `make` to compile all programs
  241. X# Use `make install` to copy the programs to the BIN directory
  242. X# Use `make clean` to remove all object files
  243. X# Use `make clobber` to remove everything except source & documentation
  244. X# Use `make tags` to build new "tags" and "refs" files
  245. X# Use `make uue` to produce uuencoded compressed tar archives of the source
  246. X# Use `make sh` to produce shar archives of the source
  247. X# Use `make print` to print the Elvis documentation
  248. X#
  249. X# Several groups of Makefile settings are included below.  Choose *ONE* group
  250. X# of settings for your particular system, and leave the others commented out.
  251. X# The meanings of these settings are:
  252. X#    O    the filename extension for unlinked object files -- usually .o
  253. X#    E    the filename extension for executable files -- usually null
  254. X#    EXTRA    version-specific object files used in elvis
  255. X#    EXTRA2    version-specific object files used in elvis, virec, & refont
  256. X#    LIBS    any special libraries, such as "-ltermcap"
  257. X#    BIN    directory where executables should be installed
  258. X#    CC    the C compiler command, possibly with "memory model" flags
  259. X#    CFLAGS    compiler flags used to select compile-time options
  260. X#    OF    link flag to control the output file's name -- usually -o<space>
  261. X#    RF    flag used to denote "compile but don't link" -- usually -c
  262. X#    DATE    a "cc" flag that defines "DATE".  e.g. DATE=-DDATE=\"7/4/76\"
  263. X#    EVAL    the word "eval", if DATE requires it
  264. X#    PROGS    the list of all programs
  265. X#    CHMEM    any extra commands to be run after ELVIS is linked
  266. X#    SORT    if the "tags" file must be sorted, then SORT=-DSORT
  267. X#    INST    installation method: inst.dos, inst.tos, inst.os9, or inst.unix
  268. X#    RM    the name of a program that deletes files
  269. X#    PR1    used to print documentation -- typically "refont -c"
  270. X#    PR2    used to send text to printer -- typically "| lpr"
  271. X#    DUMMY    usually nothing, but OS9 needs "dummy"
  272. X#    DOC    name of "doc" directory, with a trailing slash
  273. X
  274. X#---- These settings are recommended for System-V UNIX and SCO XENIX-386 ----
  275. X#O=    .o
  276. X#E=
  277. X#EXTRA=
  278. X#EXTRA2=
  279. X#LIBS=    -ltermcap
  280. X#BIN=    /usr/local/bin
  281. X#CFLAGS=    -DM_SYSV -O
  282. X#OF=    -o 
  283. X#RF=    -c
  284. X#DATE=    -DDATE=\'\"`date`\"\'
  285. X#EVAL=    eval 
  286. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  287. X#CHMEM=    
  288. X#SORT=    -DSORT
  289. X#INST=    inst.unix
  290. X#RM=    rm -f
  291. X#PR1=    refont -c
  292. X#PR2=    | lp
  293. X#DUMMY=
  294. X#DOC=    doc/
  295. X
  296. X#---- These settings are recommended for SCO XENIX-286 ----
  297. X#O=    .o
  298. X#E=
  299. X#EXTRA=
  300. X#EXTRA2=
  301. X#LIBS=    -ltermcap
  302. X#BIN=    /usr/local/bin
  303. X#CC=    cc -M2s -i
  304. X#CFLAGS=    -DM_SYSV -Ox -DCS_IBMPC
  305. X#OF=    -o 
  306. X#RF=    -c
  307. X#DATE=    -DDATE=\'\"`date`\"\'
  308. X#EVAL=    eval 
  309. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  310. X#CHMEM=    
  311. X#SORT=    -DSORT
  312. X#INST=    inst.unix
  313. X#RM=    rm -f
  314. X#PR1=    refont -c
  315. X#PR2=    | lp
  316. X#DUMMY=
  317. X#DOC=    doc/
  318. X
  319. X#---- These settings are recommended for BSD 4.3 UNIX ----
  320. X#O=    .o
  321. X#E=
  322. X#EXTRA=
  323. X#EXTRA2=
  324. X#LIBS=    -ltermcap
  325. X#BIN=    /usr/local/bin
  326. X#CFLAGS=    -Dbsd -O
  327. X#OF=    -o 
  328. X#RF=    -c
  329. X#DATE=    -DDATE=\'\"`date`\"\'
  330. X#EVAL=    eval 
  331. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  332. X#CHMEM=    
  333. X#SORT=    -DSORT
  334. X#INST=    inst.unix
  335. X#RM=    rm -f
  336. X#PR1=    refont -c
  337. X#PR2=    | lpr
  338. X#DUMMY=
  339. X#DOC=    doc/
  340. X
  341. X#---- These settings are recommended for Coherent ----
  342. X#O=.o
  343. X#E=
  344. X#EXTRA=
  345. X#EXTRA2=
  346. X#LIBS=    -lterm
  347. X#BIN=    /usr/bin
  348. X#CC=    cc 
  349. X#CFLAGS=    -O -DCOHERENT -DCRUNCH -DNO_CHARATTR -DNO_CURSORSHAPE \
  350. X#    -DNO_DIGRAPH -DNO_MKEXRC -VSUVAR
  351. X#OF=    -o 
  352. X#RF=    -c
  353. X#DATE=    -DDATE=\'\"`date`\"\'
  354. X#EVAL=    eval
  355. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  356. X#CHMEM=    fixstack 2000 elvis$E
  357. X#SORT=
  358. X#INST=    inst.unix
  359. X#RM=    rm -f
  360. X#PR1=    refont -b
  361. X#PR2=    | lpr
  362. X#DUMMY=
  363. X#DOC=    doc/
  364. X
  365. X#---- These settings are recommended for Minix-ST ----
  366. X#O=    .o
  367. X#E=
  368. X#EXTRA=
  369. X#EXTRA2=
  370. X#LIBS=
  371. X#BIN=    /usr/bin
  372. X#CC=    cc
  373. X#CFLAGS=
  374. X#OF=    -o 
  375. X#RF=    -c
  376. X#DATE=    -DDATE=\'\"`date`\"\'
  377. X#EVAL=    eval 
  378. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  379. X#CHMEM=    chmem =18000 elvis
  380. X#SORT=
  381. X#INST=    inst.unix
  382. X#RM=    rm -f
  383. X#PR1=    lpr
  384. X#PR2=
  385. X#DUMMY=
  386. X#DOC=    doc/
  387. X
  388. X#---- These settings are recommended for Minix-PC ----
  389. X#O=    .s
  390. X#E=
  391. X#EXTRA=    tinytcap$O
  392. X#EXTRA2=
  393. X#LIBS=
  394. X#BIN=    /usr/bin
  395. X#CC=    cc -i
  396. X#CFLAGS=    -O -DCRUNCH -DNO_MKEXRC -DNO_CURSORSHAPE -DNO_CHARATTR \
  397. X#    -DNO_SHOWMODE -DNO_MODELINE -DNO_OPTCOLS -DNO_DIGRAPH -DNO_ABBR \
  398. X#    -DNO_AT -DNO_SENTENCE -DNO_ERRLIST
  399. X#### (all but -DNO_EXTENSIONS, -DNO_RECYCLE, -DNO_MAGIC, and -DNO_CHARSEARCH)
  400. X#OF=    -o 
  401. X#RF=    -c
  402. X#DATE=    -DDATE=\'\"`date`\"\'
  403. X#EVAL=    eval 
  404. X#PROGS=    elvis$E ctags$E ref$E virec$E refont$E
  405. X#CHMEM=
  406. X#SORT=
  407. X#INST=    inst.unix
  408. X#RM=    rm -f
  409. X#PR1=    lpr
  410. X#PR2=    
  411. X#DUMMY=
  412. X#DOC=    doc/
  413. X
  414. X#---- These settings are recommended for MS-DOS + MS-C + NDMAKE ----
  415. X#O=    .obj
  416. X#E=    .exe
  417. X#EXTRA=    pc$O sysdos$O tinytcap$O
  418. X#EXTRA2=
  419. X#LIBS=
  420. X#BIN=    c:\dos
  421. X#CC=    cl /AM
  422. X#CFLAGS=    -O -DCS_IBMPC -DCS_SPECIAL
  423. X#OF=    -o 
  424. X#RF=    -c
  425. X#DATE=
  426. X#EVAL=
  427. X#PROGS=    elvis$E ex$E ctags$E ref$E virec$E wildcard$E refont$E
  428. X#CHMEM=    
  429. X#SORT=
  430. X#INST=    inst.dos
  431. X#RM=    del
  432. X#PR1=    refont -c
  433. X#PR2=    >PRN
  434. X#DUMMY=
  435. X#DOC=    doc\
  436. X
  437. X#---- These settings are recommended for Atari TOS + Mark Williams C ----
  438. X#O=.o
  439. X#E=.ttp
  440. X#EXTRA=    sysdos$O tinytcap$O
  441. X#EXTRA2=    atari$O
  442. X#LIBS=
  443. X#BIN=    c:\
  444. X#CC=    cc -VPEEP
  445. X#CFLAGS=    -O -DCS_IBMPC -DCS_SPECIAL
  446. X#OF=    -o 
  447. X#RF=    -c
  448. X#DATE=
  449. X#EVAL=
  450. X#PROGS=    elvis$E ctags$E ref$E virec$E wildcard$E shell$E refont$E
  451. X#CHMEM=
  452. X#SORT=
  453. X#INST=    inst.tos
  454. X#RM=    rm -f
  455. X#PR1=    refont -e
  456. X#PR2=    >PRT:
  457. X#DUMMY=
  458. X#DOC=    'doc\'
  459. X
  460. X#---- These settings are recommended for OS-9/68K V2.3 ----
  461. X#O=    .r
  462. X#E=
  463. X#EXTRA=    date$O
  464. X#EXTRA2=    osk$O 
  465. X#LIBS=    -l=/dd/lib/termlib.l
  466. X#BIN=    /dd/usr/cmds
  467. X#CC=    cc
  468. X#ODIR=    /dd/usr/src/elvis
  469. X#CFLAGS=    -gq -m=2
  470. X#OF=    -f=$(ODIR)/
  471. X#RF=    -r
  472. X#DATE=
  473. X#EVAL=
  474. X#PROGS=    elvis$E vi$E view$E input$E ctags$E ref$E virec$E refont$E
  475. X#CHMEM=    touch date.r
  476. X#SORT=
  477. X#INST=    inst.os9
  478. X#RM=    del *.stb *.dbg
  479. X#PR1=    refont -b
  480. X#PR2=    >/p
  481. X#DUMMY=    dummy
  482. X#DOC=    doc/
  483. X
  484. X###########################################################################
  485. X###########################################################################
  486. X###                                                                     ###
  487. X###     The rest of this Makefile contains no user-servicable parts     ###
  488. X###                                                                     ###
  489. X###########################################################################
  490. X###########################################################################
  491. X
  492. XOBJS=    blk$O cmd1$O cmd2$O curses$O cut$O ex$O input$O main$O misc$O \
  493. X    modify$O move1$O move2$O move3$O move4$O move5$O opts$O recycle$O \
  494. X    redraw$O regexp$O regsub$O system$O tio$O tmp$O vars$O vcmd$O vi$O
  495. X
  496. XALIAS=    alias$O
  497. X
  498. XDOCS=    $(DOC)index.doc $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \
  499. X    $(DOC)regexp.doc $(DOC)options.doc $(DOC)cutbufs.doc $(DOC)differ.doc \
  500. X    $(DOC)internal.doc $(DOC)cflags.doc $(DOC)termcap.doc \
  501. X    $(DOC)environ.doc $(DOC)versions.doc
  502. X
  503. XSRC1=    README KNOWN.BUGS $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \
  504. X    $(DOC)versions.doc $(DOC)cflags.doc $(DOC)differ.doc
  505. XSRC2=    $(DOC)cutbufs.doc $(DOC)options.doc $(DOC)environ.doc $(DOC)regexp.doc \
  506. X    $(DOC)internal.doc $(DOC)termcap.doc $(DOC)index.doc $(DOC)ctags.man \
  507. X    $(DOC)elvis.man $(DOC)ref.man $(DOC)refont.man $(DOC)virec.man
  508. XSRC3=    Elvis.lnk Elvis.mak Elvis.prj Makefile.mix alias.c atari.c \
  509. X    ctags.c pc.c ref.c shell.c sysdos.c virec.c wildcard.c \
  510. X    profile.sh osk.c osk.h date.c
  511. XSRC4=    blk.c cmd1.c cmd2.c config.h curses.c
  512. XSRC5=    curses.h cut.c ex.c input.c main.c misc.c
  513. XSRC6=    modify.c move1.c move2.c move3.c move4.c move5.c opts.c recycle.c \
  514. X    redraw.c 
  515. XSRC7=    regexp.c regexp.h regsub.c system.c tinytcap.c tio.c tmp.c 
  516. XSRC8=    vars.c vcmd.c vi.c vi.h refont.c
  517. X
  518. X###########################################################################
  519. X
  520. Xall: $(PROGS)
  521. X    @echo done.
  522. X
  523. Xelvis$E: $(OBJS) $(EXTRA) $(EXTRA2)
  524. X    $(CC) $(CFLAGS) $(OF)elvis$E $(OBJS) $(EXTRA) $(EXTRA2) $(LIBS)
  525. X    $(CHMEM)
  526. X
  527. Xctags$E: ctags.c
  528. X    $(CC) $(CFLAGS) $(SORT) $(OF)ctags$E ctags.c
  529. X
  530. Xref$E: ref.c
  531. X    $(CC) $(CFLAGS) $(OF)ref$E ref.c
  532. X
  533. Xvirec$E: virec.c
  534. X    $(CC) $(CFLAGS) $(OF)virec$E virec.c $(EXTRA2)
  535. X
  536. Xview$E: $(ALIAS)
  537. X    $(CC) $(CFLAGS) $(OF)view$E $(ALIAS)
  538. X
  539. Xex$E: $(ALIAS)
  540. X    $(CC) $(CFLAGS) $(OF)ex$E $(ALIAS)
  541. X
  542. Xvi$E: $(ALIAS)
  543. X    $(CC) $(CFLAGS) $(OF)vi$E $(ALIAS)
  544. X
  545. Xinput$E: $(ALIAS)
  546. X    $(CC) $(CFLAGS) $(OF)input$E $(ALIAS)
  547. X
  548. Xshell$E: shell.c
  549. X    $(CC) $(CFLAGS) $(OF)shell$E shell.c
  550. X
  551. Xwildcard$E: wildcard.c
  552. X    $(CC) $(CFLAGS) $(OF)wildcard$E wildcard.c
  553. X
  554. Xrefont$E: refont.c
  555. X    $(CC) $(CFLAGS) $(OF)refont$E refont.c $(EXTRA2)
  556. X
  557. X##############################################################################
  558. X
  559. X# The file cmd1.c is compiled with the extra flag -DDATE="today's date".
  560. Xcmd1$O: cmd1.c vi.h config.h
  561. X    $(EVAL) $(CC) $(CFLAGS) $(RF) $(DATE) cmd1.c
  562. X
  563. X# "It all depends..."
  564. X$(OBJS): vi.h curses.h config.h
  565. X
  566. X# OS9 must create a custom date.c file, and compile it.
  567. Xdate$O: $(OBJS)
  568. X    @echo '/* compilation date of elvis */' >-date.c
  569. X    @echo -r 'char date[] = "' >+date.c
  570. X    @echo -r 'echo -r ' >-/dd/tmp/date.c
  571. X    @date >+/dd/tmp/date.c
  572. X    @shell /dd/tmp/date.c >+date.c
  573. X    @echo '";' >+date.c
  574. X    @del /dd/tmp/date.c
  575. X    $(CC) $(CFLAGS) $(RF) date.c
  576. X
  577. X##############################################################################
  578. Xinstall: $(INST)
  579. X    @echo Installation complete.
  580. X
  581. Xinst.unix: $(DUMMY)
  582. X    cp $(PROGS) $(BIN)
  583. X    (cd $(BIN); chmod 755 $(PROGS))
  584. X    (cd $(BIN); chown bin $(PROGS))
  585. X    -ln $(BIN)/elvis $(BIN)/vi
  586. X    -ln $(BIN)/elvis $(BIN)/ex
  587. X    -ln $(BIN)/elvis $(BIN)/view
  588. X    -ln $(BIN)/elvis $(BIN)/input
  589. X
  590. Xinst.dos: $(DUMMY)
  591. X    copy $(PROGS) $(BIN)
  592. X    copy $(BIN)/ex$E $(BIN)/vi$E
  593. X    copy $(BIN)/ex$E $(BIN)/view$E
  594. X    copy $(BIN)/ex$E $(BIN)/input$E
  595. X
  596. Xinst.tos: $(DUMMY)
  597. X    copy $(PROGS) $(BIN)
  598. X
  599. Xinst.os9: $(DUMMY)
  600. X    copy $(PROGS) -rw=$(BIN)
  601. X    chd $(BIN); attr -epenprnpw $(PROGS)
  602. X
  603. X##############################################################################
  604. Xclean: $(DUMMY)
  605. X    $(RM) *$O $(DOC)*.1 elvis?.uue elvis?.sh core
  606. X
  607. Xclobber: clean
  608. X    $(RM) tags refs $(PROGS)
  609. X
  610. X##############################################################################
  611. Xprint: refont$E
  612. X    $(PR1) $(DOCS) $(PR2)
  613. X
  614. Xtags refs: ctags$E
  615. X    ctags -r *.c *.h
  616. X
  617. X##############################################################################
  618. Xuue: elvis1.uue elvis2.uue elvis3.uue elvis4.uue elvis5.uue \
  619. X    elvis6.uue elvis7.uue elvis8.uue
  620. X
  621. Xelvis1.uue: $(SRC1)
  622. X    tar cf elvis1.tar $(SRC1)
  623. X    compress -b13 elvis1.tar
  624. X    cp README elvis1.uue
  625. X    uue elvis1.tar.Z - >>elvis1.uue
  626. X    $(RM) elvis1.tar*
  627. X
  628. Xelvis2.uue: $(SRC2)
  629. X    tar cf elvis2.tar $(SRC2)
  630. X    compress -b13 elvis2.tar
  631. X    uue elvis2.tar.Z
  632. X    $(RM) elvis2.tar*
  633. X
  634. Xelvis3.uue: $(SRC3)
  635. X    tar cf elvis3.tar $(SRC3)
  636. X    compress -b13 elvis3.tar
  637. X    uuencode elvis3.tar.Z <elvis3.tar.Z >elvis3.uue
  638. X    $(RM) elvis3.tar*
  639. X
  640. Xelvis4.uue: $(SRC4)
  641. X    tar cf elvis4.tar $(SRC4)
  642. X    compress -b13 elvis4.tar
  643. X    uuencode elvis4.tar.Z <elvis4.tar.Z >elvis4.uue
  644. X    $(RM) elvis4.tar*
  645. X
  646. Xelvis5.uue: $(SRC5)
  647. X    tar cf elvis5.tar $(SRC5)
  648. X    compress -b13 elvis5.tar
  649. X    uuencode elvis5.tar.Z <elvis5.tar.Z >elvis5.uue
  650. X    $(RM) elvis5.tar*
  651. X
  652. Xelvis6.uue: $(SRC6)
  653. X    tar cf elvis6.tar $(SRC6)
  654. X    compress -b13 elvis6.tar
  655. X    uuencode elvis6.tar.Z <elvis6.tar.Z >elvis6.uue
  656. X    $(RM) elvis6.tar*
  657. X
  658. Xelvis7.uue: $(SRC7)
  659. X    tar cf elvis7.tar $(SRC7)
  660. X    compress -b13 elvis7.tar
  661. X    uuencode elvis7.tar.Z <elvis7.tar.Z >elvis7.uue
  662. X    $(RM) elvis7.tar*
  663. X
  664. Xelvis8.uue: $(SRC8)
  665. X    tar cf elvis8.tar $(SRC8)
  666. X    compress -b13 elvis8.tar
  667. X    uuencode elvis8.tar.Z <elvis8.tar.Z >elvis8.uue
  668. X    $(RM) elvis8.tar*
  669. X
  670. X##############################################################################
  671. Xsh: elvis1.sh elvis2.sh elvis3.sh elvis4.sh elvis5.sh elvis6.sh \
  672. X    elvis7.sh elvis8.sh
  673. X
  674. Xelvis1.sh: $(SRC1)
  675. X    cat   >elvis1.sh README
  676. X    echo >>elvis1.sh ': ------------------------ CUT HERE --------------------'
  677. X    echo >>elvis1.sh 'test -d doc || mkdir doc || exit 2'
  678. X    shar >>elvis1.sh -h $(SRC1)
  679. X
  680. Xelvis2.sh: $(SRC2)
  681. X    echo  >elvis2.sh ': ------------------------ CUT HERE --------------------'
  682. X    echo >>elvis2.sh 'test -d doc || mkdir doc || exit 2'
  683. X    shar >>elvis2.sh -h $(SRC2)
  684. X
  685. Xelvis3.sh: $(SRC3)
  686. X    shar $(SRC3) >elvis3.sh
  687. X
  688. Xelvis4.sh: $(SRC4)
  689. X    shar $(SRC4) >elvis4.sh
  690. X
  691. Xelvis5.sh: $(SRC5)
  692. X    shar $(SRC5) >elvis5.sh
  693. X
  694. Xelvis6.sh: $(SRC6)
  695. X    shar $(SRC6) >elvis6.sh
  696. X
  697. Xelvis7.sh: $(SRC7)
  698. X    shar $(SRC7) >elvis7.sh
  699. X
  700. Xelvis8.sh: $(SRC8)
  701. X    shar $(SRC8) >elvis8.sh
  702. X
  703. X##############################################################################
  704. X
  705. X# Under XENIX only!  This stores all sources on a 3.5" 720k floppy disk.
  706. Xfloppy: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
  707. X    tar c5v $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
  708. eof
  709. if test `wc -c <Makefile.mix` -ne 12152
  710. then
  711. echo Makefile.mix damaged!
  712. fi
  713. fi
  714.  
  715. if test -f alias.c -a "$1" != -f
  716. then
  717. echo Will not overwrite alias.c
  718. else
  719. echo Extracting alias.c
  720. sed 's/^X//' >alias.c <<\eof
  721. X/* alias.c */
  722. X
  723. X/* Author:
  724. X *        Peter Reinig
  725. X *        Universitaet Kaiserslautern
  726. X *        Postfach 3049
  727. X *        7650 Kaiserslautern
  728. X *        W. Germany
  729. X *        reinig@physik.uni-kl.de
  730. X */
  731. X
  732. X/* This tiny program executes elvis with the flags that are appropriate
  733. X * for a given command name.  This program is used only on systems that
  734. X * don't allow UNIX-style file links.
  735. X *
  736. X * The benefit of this program is: instead of having 5 copies of elvis
  737. X * on your disk, you only need one copy of elvis and 4 copies of this
  738. X * little program.
  739. X */
  740. X
  741. X#include <stdio.h>
  742. X#include "config.h"
  743. X
  744. X#if OSK
  745. X#define ELVIS    "/dd/usr/cmds/elvis"
  746. X#else
  747. X#define ELVIS    "elvis"
  748. X#endif
  749. X
  750. Xextern char **environ;
  751. Xextern int errno;
  752. Xextern char *malloc();
  753. X
  754. Xmain(argc, argv)
  755. X    int    argc;
  756. X    char    *argv[];
  757. X{
  758. X    int    pid, i, j;
  759. X    int    letter;
  760. X    char    **argblk;
  761. X#if OSK
  762. X    extern int chainc();
  763. X#endif
  764. X
  765. X    /* allocate enough space for a copy of the argument list, plus a
  766. X     * terminating NULL, plus maybe an added flag.
  767. X     */
  768. X    argblk = (char **) malloc((argc + 2) * sizeof(char *));
  769. X    if (!argblk)
  770. X    {
  771. X#if OSK
  772. X        _errmsg(errno, "Can't get enough memory\n");
  773. X#else
  774. X        perror(argv[0]);
  775. X#endif
  776. X        exit(2);
  777. X    }
  778. X
  779. X    /* find the last letter in the invocation name of this program */
  780. X    i = strlen(argv[0]);
  781. X#if MSDOS || TOS
  782. X    /* we almost certainly must bypass ".EXE" or ".TTP" from argv[0] */
  783. X    if (i > 4 && argv[0][i - 4] == '.')
  784. X        i -= 4;
  785. X#endif
  786. X    letter = argv[0][i - 1];
  787. X
  788. X    /* copy argv to argblk, possibly inserting a flag such as "-R" */
  789. X    argblk[0] = ELVIS;
  790. X    i = j = 1;
  791. X    switch (letter)
  792. X    {
  793. X      case 'w':            /* "view" */
  794. X      case 'W':
  795. X        argblk[i++] = "-R";
  796. X        break;
  797. X#if !OSK
  798. X      case 'x':            /* "ex" */
  799. X      case 'X':
  800. X        argblk[i++] = "-e";
  801. X        break;
  802. X#endif
  803. X      case 't':            /* "input" */
  804. X      case 'T':
  805. X        argblk[i++] = "-i";
  806. X        break;
  807. X    }
  808. X    while (j < argc)
  809. X    {
  810. X        argblk[i++] = argv[j++];
  811. X    }
  812. X    argblk[i] = (char *)0;
  813. X
  814. X    /* execute the real ELVIS program */
  815. X#if OSK
  816. X    pid = os9exec(chainc, argblk[0], argblk, environ, 0, 0, 3);
  817. X    fprintf(stderr, "%s: cannot execute\n", argblk[0]);
  818. X#else
  819. X    (void)execvp(argblk[0], argblk);
  820. X    perror(ELVIS);
  821. X#endif
  822. X}
  823. eof
  824. if test `wc -c <alias.c` -ne 2032
  825. then
  826. echo alias.c damaged!
  827. fi
  828. fi
  829.  
  830. if test -f atari.c -a "$1" != -f
  831. then
  832. echo Will not overwrite atari.c
  833. else
  834. echo Extracting atari.c
  835. sed 's/^X//' >atari.c <<\eof
  836. X/* atari.c */
  837. X
  838. X/* Author:
  839. X *    Guntram Blohm
  840. X *    Buchenstrasse 19
  841. X *    7904 Erbach, West Germany
  842. X *    Tel. ++49-7305-6997
  843. X *    sorry - no regular network connection
  844. X */
  845. X
  846. X/*
  847. X * This file contains the 'standard' functions which are not supported
  848. X * by Atari/Mark Williams, and some other TOS-only requirements.
  849. X */
  850. X#include "config.h"
  851. X#include "vi.h"
  852. X
  853. X#if TOS
  854. X#include <osbind.h>
  855. X
  856. X/* vi uses mode==0 only ... */
  857. Xint access(file, mode)
  858. X    char *file;
  859. X{
  860. X    int fd=Fopen(file, 0);
  861. X    if (fd<0)
  862. X        return -1;
  863. X    Fclose(fd);
  864. X    return 0;
  865. X}
  866. X
  867. Xchar *mktemp(template)
  868. X    char *template;
  869. X{
  870. X    return template;
  871. X}
  872. X
  873. X/* read -- text mode, compress \r\n to \n
  874. X * warning: might fail when maxlen==1 and at eol
  875. X */
  876. X
  877. Xint tread(fd, buf, maxlen)
  878. X    int fd;
  879. X    char *buf;
  880. X    int maxlen;
  881. X{
  882. X    int i, j, nread=read(fd, buf, (unsigned)maxlen);
  883. X
  884. X    if (nread && buf[nread-1]=='\r')
  885. X    {    nread--;
  886. X        lseek(fd, -1l, 1);
  887. X    }
  888. X    for (i=j=0; j<nread; i++,j++)
  889. X    {    if (buf[j]=='\r' && buf[j+1]=='\n')
  890. X            j++;
  891. X        buf[i]=buf[j];
  892. X    }
  893. X    return i;
  894. X}
  895. X
  896. Xint twrite(fd, buf, maxlen)
  897. X    int fd;
  898. X    char *buf;
  899. X    int maxlen;
  900. X{
  901. X    int i, j, nwritten=0, hadnl=0;
  902. X    char writbuf[BLKSIZE];
  903. X
  904. X    for (i=j=0; j<maxlen; )
  905. X    {
  906. X        if ((writbuf[i++]=buf[j++])=='\n')
  907. X        {    writbuf[i-1]='\r';
  908. X            if (i<BLKSIZE)
  909. X                writbuf[i++]='\n';
  910. X            else
  911. X                hadnl=1;
  912. X        }
  913. X        if (i==BLKSIZE)
  914. X        {
  915. X            write(fd, writbuf, (unsigned)i);
  916. X            i=0;
  917. X        }
  918. X        if (hadnl)
  919. X        {
  920. X            writbuf[i++]='\n';
  921. X            hadnl=0;
  922. X        }
  923. X    }
  924. X    if (i)
  925. X        write(fd, writbuf, (unsigned)i);
  926. X    return j;
  927. X}
  928. X#endif
  929. eof
  930. if test `wc -c <atari.c` -ne 1437
  931. then
  932. echo atari.c damaged!
  933. fi
  934. fi
  935.  
  936. if test -f ctags.c -a "$1" != -f
  937. then
  938. echo Will not overwrite ctags.c
  939. else
  940. echo Extracting ctags.c
  941. sed 's/^X//' >ctags.c <<\eof
  942. X/* ctags.c */
  943. X
  944. X/* Author:
  945. X *    Steve Kirkendall
  946. X *    14407 SW Teal Blvd. #C
  947. X *    Beaverton, OR 97005
  948. X *    kirkenda@cs.pdx.edu
  949. X */
  950. X
  951. X
  952. X/* This file contains the complete source to the ctags program. */
  953. X
  954. X/* Special abilities:
  955. X * Can also make a "refs" file for use by the "ref" program.
  956. X */
  957. X
  958. X/* Limitations:
  959. X * This version of ctags always writes its output to the file "tags".
  960. X * It assumes that every command-line argument (but "-r") is a C source file.
  961. X * It does not sort the list of tags, unless CFLAGS=-DSORT.
  962. X * It does not recognize duplicate definitions.
  963. X * It does not try to handle "static" functions in a clever way.
  964. X * It probably won't scan ANSI-C source code very well.
  965. X */
  966. X
  967. X/* Implementation:
  968. X * Lines are scanned one-at-a-time.
  969. X * The context of lines is tracked via a finite state machine.
  970. X * Contexts are:
  971. X *    EXPECTFN - we're looking for a function name.
  972. X *    ARGS     - between function name and its opening {
  973. X *    BODY     - we found a function name, skip to end of body.
  974. X *
  975. X * Function tags are referenced by a search string, so that lines may be
  976. X * inserted or deleted without mucking up the tag search.
  977. X *
  978. X * Macro tags are referenced by their line number, because 1) they usually
  979. X * occur near the top of a file, so their line# won't change much; 2)  They
  980. X * often contain characters that are hard to search for; and 3)  Their #define
  981. X * line is likely to be altered.
  982. X *
  983. X * Each line of the resulting "tags" file describes one tag.  Lines begin with
  984. X * the tag name, then a tab, then the file name, then a tab, and then either
  985. X * a line number or a slash-delimited search string.
  986. X */
  987. X
  988. X#include <ctype.h>
  989. X#include <stdio.h>
  990. X#include "config.h"
  991. X
  992. X#define REFS    "refs"
  993. X
  994. X#if OSK
  995. X#define NUMFMT    "%%.%ds\t%%s\t%%ld\n"
  996. X#define SRCHFMT    "%%.%ds\t%%s\t/^%%s$/\n"
  997. X#define MAINFMT    "M%%.%ds\t%%s\t/^%%s$/\n"
  998. Xstatic char fmt[256];
  999. X#else
  1000. X#define NUMFMT    "%.*s\t%s\t%ld\n"
  1001. X#define SRCHFMT    "%.*s\t%s\t/^%s$/\n"
  1002. X#define MAINFMT    "M%.*s\t%s\t/^%s$/\n"
  1003. X#endif
  1004. X
  1005. X#ifdef VERBOSE
  1006. X# define SAY(x)    fprintf(stderr, "%s\n", x);
  1007. X#else
  1008. X# define SAY(x)
  1009. X#endif
  1010. X
  1011. X#define EXPECTFN 1
  1012. X#define    ARGS     2
  1013. X#define BODY     3
  1014. X
  1015. Xextern char    *fgets();
  1016. X
  1017. Xchar        *progname;    /* argv[0], used for diagnostic output */
  1018. X
  1019. Xmain(argc, argv)
  1020. X    int    argc;
  1021. X    char    **argv;
  1022. X{
  1023. X    FILE    *fp;
  1024. X    int    i;
  1025. X    FILE    *refs;    /* used to write to the refs file */
  1026. X
  1027. X#if MSDOS || TOS
  1028. X    char **wildexpand();
  1029. X    argv=wildexpand(&argc, argv);
  1030. X#endif
  1031. X    /* notice the program name */
  1032. X    progname = argv[0];
  1033. X
  1034. X    /* create the "refs" file if first arg is "-r" */
  1035. X    if (argc > 1 && !strcmp(argv[1], "-r"))
  1036. X    {
  1037. X        /* delete the "-r" flag from the args list */
  1038. X        argc--;
  1039. X        argv++;
  1040. X
  1041. X        /* open the "refs" file for writing */
  1042. X        refs = fopen(REFS, "w");
  1043. X        if (!refs)
  1044. X        {
  1045. X            fprintf(stderr, "%s: could not create \"%s\"\n", progname, REFS);
  1046. X            exit(2);
  1047. X        }
  1048. X    }
  1049. X    else
  1050. X    {
  1051. X        refs = (FILE *)0;
  1052. X    }
  1053. X
  1054. X    /* process each file named on the command line, or complain if none */
  1055. X    if (argc > 1)
  1056. X    {
  1057. X        /* redirect stdout to go to the "tags" file */
  1058. X        if (!freopen("tags", "w", stdout))
  1059. X        {
  1060. X            fprintf(stderr, "%s: could not create \"%s\"\n", progname, TAGS);
  1061. X            exit(2);
  1062. X        }
  1063. X
  1064. X        for (i = 1; i < argc; i++)
  1065. X        {
  1066. X            /* process this named file */
  1067. X            fp = fopen(argv[i], "r");
  1068. X            if (!fp)
  1069. X            {
  1070. X                fprintf(stderr, "%s: could not read \"%s\"\n", progname, argv[i]);
  1071. X                continue;
  1072. X            }
  1073. X            ctags(fp, argv[i], refs);
  1074. X            fclose(fp);
  1075. X        }
  1076. X#ifdef SORT
  1077. X        /* This is a hack which will sort the tags list.   It should
  1078. X         * on UNIX and Minix.  You may have trouble with csh.   Note
  1079. X         * that the tags list only has to be sorted if you intend to
  1080. X         * use it with the real vi;  elvis permits unsorted tags.
  1081. X         */
  1082. X        fflush(stdout);
  1083. X#if OSK
  1084. X        fclose(stdout);
  1085. X        system("qsort tags >-_tags; -nx; del tags; rename _tags tags");
  1086. X#else    
  1087. X        system("sort tags >_tags$$; mv _tags$$ tags");
  1088. X#endif
  1089. X#endif
  1090. X        exit(0);
  1091. X    }
  1092. X    else
  1093. X    {
  1094. X        fprintf(stderr, "usage: %s *.[ch]\n", progname);
  1095. X        exit(2);
  1096. X    }
  1097. X}
  1098. X
  1099. X
  1100. X/* this function finds all tags in a given file */
  1101. Xctags(fp, name, refs)
  1102. X    FILE    *fp;        /* stream of the file to scan */
  1103. X    char    *name;        /* name of the file being scanned */
  1104. X    FILE    *refs;        /* NULL, or where to write refs lines */
  1105. X{
  1106. X    int    context;    /* context - either EXPECTFN, ARGS, or BODY */
  1107. X    long    lnum;        /* line number */
  1108. X    char    text[1000];    /* a line of text from the file */
  1109. X    char    *scan;        /* used for searching through text */
  1110. X    int    len;        /* length of the line */
  1111. X
  1112. X    /* for each line of the file... */
  1113. X    for (context = EXPECTFN, lnum = 1; fgets(text, sizeof text, fp); lnum++)
  1114. X    {
  1115. X#ifdef VERBOSE
  1116. X        switch(context)
  1117. X        {
  1118. X          case EXPECTFN:    scan = "EXPECTFN";    break;
  1119. X          case ARGS:        scan = "ARGS    ";    break;
  1120. X          case BODY:        scan = "BODY    ";    break;
  1121. X          default:        scan = "context?";
  1122. X        }
  1123. X        fprintf(stderr, "%s:%s", scan, text);
  1124. X#endif
  1125. X
  1126. X        /* start of body? */
  1127. X        if (text[0] == '{')
  1128. X        {
  1129. X            context = BODY;
  1130. X            SAY("Start of BODY");
  1131. X            continue;
  1132. X        }
  1133. X
  1134. X        /* argument line, to be written to "refs" ? */
  1135. X        if (refs && context == ARGS)
  1136. X        {
  1137. X            if (text[0] != '\t')
  1138. X            {
  1139. X                putc('\t', refs);
  1140. X            }
  1141. X            fputs(text, refs);
  1142. X            SAY("Argument line");
  1143. X            continue;
  1144. X        }
  1145. X
  1146. X        /* ignore empty or indented lines */
  1147. X        if (text[0] <= ' ')
  1148. X        {
  1149. X            SAY("Empty or indented");
  1150. X            continue;
  1151. X        }
  1152. X
  1153. X        /* end of body? */
  1154. X        if (text[0] == '}')
  1155. X        {
  1156. X            context = EXPECTFN;
  1157. X            SAY("End of BODY");
  1158. X            continue;
  1159. X        }
  1160. X
  1161. X        /* ignore lines in the body of a function */
  1162. X        if (context != EXPECTFN)
  1163. X        {
  1164. X            SAY("BODY or ARGS");
  1165. X            continue;
  1166. X        }
  1167. X
  1168. X        /* strip the newline */
  1169. X        len = strlen(text);
  1170. X        text[--len] = '\0';
  1171. X
  1172. X        /* a preprocessor line? */
  1173. X        if (text[0] == '#')
  1174. X        {
  1175. X            /* find the preprocessor directive */
  1176. X            for (scan = &text[1]; isspace(*scan); scan++)
  1177. X            {
  1178. X            }
  1179. X
  1180. X            /* if it's a #define, make a tag out of it */
  1181. X            if (!strncmp(scan, "define", 6))
  1182. X            {
  1183. X                /* find the start of the symbol name */
  1184. X                for (scan += 6; isspace(*scan); scan++)
  1185. X                {
  1186. X                }
  1187. X
  1188. X                /* find the length of the symbol name */
  1189. X                for (len = 1;
  1190. X                     isalnum(scan[len]) || scan[len] == '_';
  1191. X                     len++)
  1192. X                {
  1193. X                }
  1194. X#if OSK
  1195. X                sprintf(fmt, NUMFMT, len);
  1196. X                printf(fmt, scan, name, lnum);
  1197. X#else            
  1198. X                printf(NUMFMT, len, scan, name, lnum);
  1199. X#endif
  1200. X            }
  1201. X            SAY("Preprocessor line");
  1202. X            continue;
  1203. X        }
  1204. X
  1205. X        /* an extern or static declaration? */
  1206. X        if (text[len - 1] == ';'
  1207. X         || !strncmp(text, "extern", 6)
  1208. X         || !strncmp(text, "EXTERN", 6)
  1209. X         || !strncmp(text, "static", 6)
  1210. X         || !strncmp(text, "PRIVATE", 7))
  1211. X        {
  1212. X            SAY("Extern or static");
  1213. X            continue;
  1214. X        }
  1215. X
  1216. X        /* if we get here & the first punctuation other than "*" is
  1217. X         * a "(" which is immediately preceded by a name, then
  1218. X         * assume the name is that of a function.
  1219. X         */
  1220. X        for (scan = text; *scan; scan++)
  1221. X        {
  1222. X            if (ispunct(*scan)
  1223. X             && !isspace(*scan) /* in BSD, spaces are punctuation?*/
  1224. X             && *scan != '*' && *scan != '_' && *scan != '(')
  1225. X            {
  1226. X                SAY("Funny punctuation");
  1227. X                goto ContinueContinue;
  1228. X            }
  1229. X
  1230. X            if (*scan == '(')
  1231. X            {
  1232. X                /* permit 0 or 1 spaces between name & '(' */
  1233. X                if (scan > text && scan[-1] == ' ')
  1234. X                {
  1235. X                    scan--;
  1236. X                }
  1237. X
  1238. X                /* find the start & length of the name */
  1239. X                for (len = 0, scan--;
  1240. X                     scan >= text && (isalnum(*scan) || *scan == '_');
  1241. X                     scan--, len++)
  1242. X                {
  1243. X                }
  1244. X                scan++;
  1245. X
  1246. X                /* did we find a function? */
  1247. X                if (len > 0)
  1248. X                {
  1249. X                    /* found a function! */
  1250. X                    if (len == 4 && !strncmp(scan, "main", 4))
  1251. X                    {
  1252. X#if OSK
  1253. X                        sprintf(fmt, MAINFMT, strlen(name) - 2);
  1254. X                        printf(fmt, name, name, text);
  1255. X#else            
  1256. X                        printf(MAINFMT, strlen(name) - 2, name, name, text);
  1257. X#endif
  1258. X                    }
  1259. X#if OSK
  1260. X                    sprintf(fmt, SRCHFMT, len);
  1261. X                    printf(fmt, scan, name, text);
  1262. X#else                
  1263. X                    printf(SRCHFMT, len, scan, name, text);
  1264. X#endif
  1265. X                    context = ARGS;
  1266. X
  1267. X                    /* add a line to refs, if needed */
  1268. X                    if (refs)
  1269. X                    {
  1270. X                        fputs(text, refs);
  1271. X                        putc('\n', refs);
  1272. X                    }
  1273. X
  1274. X                    goto ContinueContinue;
  1275. X                }
  1276. X            }
  1277. X            else
  1278. X            {
  1279. X                SAY("No parenthesis");
  1280. X            }
  1281. X        }
  1282. X        SAY("No punctuation");
  1283. X
  1284. XContinueContinue:;
  1285. X    }
  1286. X}
  1287. X
  1288. X#if MSDOS || TOS
  1289. X#define        WILDCARD_NO_MAIN
  1290. X#include    "wildcard.c"
  1291. X#endif
  1292. eof
  1293. if test `wc -c <ctags.c` -ne 7855
  1294. then
  1295. echo ctags.c damaged!
  1296. fi
  1297. fi
  1298.  
  1299. if test -f pc.c -a "$1" != -f
  1300. then
  1301. echo Will not overwrite pc.c
  1302. else
  1303. echo Extracting pc.c
  1304. sed 's/^X//' >pc.c <<\eof
  1305. X/* pc.c */
  1306. X
  1307. X/* Author:
  1308. X *    Guntram Blohm
  1309. X *    Buchenstrasse 19
  1310. X *    7904 Erbach, West Germany
  1311. X *    Tel. ++49-7305-6997
  1312. X *    sorry - no regular network connection
  1313. X */
  1314. X
  1315. X/* This file implements the ibm pc bios interface. See IBM documentation
  1316. X * for details.
  1317. X * If TERM is set upon invocation of elvis, this code is ignored completely,
  1318. X * and the standard termcap functions are used, thus, even not-so-close
  1319. X * compatibles can run elvis. For close compatibles however, bios output
  1320. X * is much faster (and permits reverse scrolling, adding and deleting lines,
  1321. X * and much more ansi.sys isn't capable of). GB.
  1322. X */
  1323. X
  1324. X#include "config.h"
  1325. X#include "vi.h"
  1326. X
  1327. X#if MSDOS
  1328. X
  1329. X#include <dos.h>
  1330. X
  1331. Xstatic void video();
  1332. X
  1333. X/* vmode contains the screen attribute index and is set by attrset.*/
  1334. X
  1335. Xint vmode;
  1336. X
  1337. X/* The following array contains attribute definitions for
  1338. X * color/monochrome attributes. Screen selects one of the sets.
  1339. X * Maybe i'll put them into elvis options one day.
  1340. X */
  1341. X
  1342. Xstatic int screen;
  1343. Xstatic char attr[2][5] =
  1344. X{
  1345. X    /*    :se:    :so:    :VB:    :ul:    :as:    */
  1346. X    {    0x1f,    0x1d,    0x1e,    0x1a,    0x1c,    },    /* color */
  1347. X    {    0x07,    0x70,    0x0f,    0x01,    0x0f,    },    /* monochrome */
  1348. X};
  1349. X
  1350. X/*
  1351. X * bios interface functions for elvis - pc version
  1352. X */
  1353. X
  1354. X/* cursor up: determine current position, decrement row, set position */
  1355. X
  1356. Xvoid v_up()
  1357. X{
  1358. X    int dx;
  1359. X    video(0x300,(int *)0,&dx);
  1360. X    dx-=0x100;
  1361. X    video(0x200,(int *)0,&dx);
  1362. X}
  1363. X
  1364. X#ifndef NO_CURSORSHAPE
  1365. X/* cursor big: set begin scan to end scan - 4 */
  1366. Xvoid v_cb()
  1367. X{
  1368. X    int cx;
  1369. X    video(0x300, &cx, (int *)0);
  1370. X    cx=((cx&0xff)|(((cx&0xff)-4)<<8));
  1371. X    video(0x100, &cx, (int *)0);
  1372. X}
  1373. X
  1374. X/* cursor small: set begin scan to end scan - 1 */
  1375. Xvoid v_cs()
  1376. X{
  1377. X    int cx;
  1378. X    video(0x300, &cx, (int *)0);
  1379. X    cx=((cx&0xff)|(((cx&0xff)-1)<<8));
  1380. X    video(0x100, &cx, (int *)0);
  1381. X}
  1382. X#endif
  1383. X
  1384. X/* clear to end: get cursor position and emit the aproppriate number
  1385. X * of spaces, without moving cursor.
  1386. X */
  1387. Xvoid v_ce()
  1388. X{
  1389. X    int cx, dx;
  1390. X    video(0x300,(int *)0,&dx);
  1391. X    cx=COLS-(dx&0xff);
  1392. X    video(0x920,&cx,(int *)0);
  1393. X}
  1394. X
  1395. X/* clear screen: clear all and set cursor home */
  1396. X
  1397. Xvoid v_cl()
  1398. X{
  1399. X    int cx=0, dx=((LINES-1)<<8)+COLS-1;
  1400. X    video(0x0600,&cx,&dx);
  1401. X    dx=0;
  1402. X    video(0x0200,&cx,&dx);
  1403. X}
  1404. X
  1405. X/* clear to bottom: get position, clear to eol, clear next line to end */
  1406. X
  1407. Xvoid v_cd()
  1408. X{
  1409. X    int cx, dx, dxtmp;
  1410. X    video(0x0300,(int *)0,&dx);
  1411. X    dxtmp=(dx&0xff00)|(COLS-1);
  1412. X    cx=dx;
  1413. X    video(0x0600,&cx,&dxtmp);
  1414. X    cx=(dx&0xff00)+0x100;
  1415. X    dx=((LINES-1)<<8)+COLS-1;
  1416. X    video(0x600,&cx,&dx);
  1417. X}
  1418. X
  1419. X/* add line: scroll rest of screen down */
  1420. X
  1421. Xvoid v_al()
  1422. X{
  1423. X    int cx,dx;
  1424. X    video(0x0300,(int *)0,&dx);
  1425. X    cx=(dx&0xff00);
  1426. X    dx=((LINES-1)<<8)+COLS-1;
  1427. X    video(0x701,&cx,&dx);
  1428. X}
  1429. X
  1430. X/* delete line: scroll rest up */
  1431. X
  1432. Xvoid v_dl()
  1433. X{
  1434. X    int cx,dx;
  1435. X    video(0x0300,(int *)0,&dx);
  1436. X    cx=(dx&0xff00)/*+0x100*/;
  1437. X    dx=((LINES-1)<<8)+COLS-1;
  1438. X    video(0x601,&cx,&dx);
  1439. X}
  1440. X
  1441. X/* scroll reverse: scroll whole screen */
  1442. X
  1443. Xvoid v_sr()
  1444. X{
  1445. X    int cx=0, dx=((LINES-1)<<8)+COLS-1;
  1446. X    video(0x0701,&cx,&dx);
  1447. X}
  1448. X
  1449. X/* set cursor */
  1450. X
  1451. Xvoid v_move(x,y)
  1452. X    int x, y;
  1453. X{
  1454. X    int dx=(y<<8)+x;
  1455. X    video(0x200,(int *)0,&dx);
  1456. X}
  1457. X
  1458. X/* put character: set attribute first, then execute char.
  1459. X * Also remember if current line has changed.
  1460. X */
  1461. X
  1462. Xint v_put(ch)
  1463. X    int ch;
  1464. X{
  1465. X    int cx=1;
  1466. X    ch&=0xff;
  1467. X    if (ch>=' ')
  1468. X        video(0x900|ch,&cx,(int *)0);
  1469. X    video(0xe00|ch,(int *)0, (int *)0);
  1470. X    if (ch=='\n')
  1471. X    {    exwrote = TRUE;
  1472. X        video(0xe0d, (int *)0, (int *)0);
  1473. X    }
  1474. X    return ch;
  1475. X}
  1476. X
  1477. X/* determine number of screen columns. Also set attrset according
  1478. X * to monochrome/color screen.
  1479. X */
  1480. X
  1481. Xint v_cols()
  1482. X{
  1483. X    union REGS regs;
  1484. X    regs.h.ah=0x0f;
  1485. X    int86(0x10, ®s, ®s);
  1486. X    if (regs.h.al==7)            /* monochrome mode ? */
  1487. X        screen=1;
  1488. X    else
  1489. X        screen=0;
  1490. X    return regs.h.ah;
  1491. X}
  1492. X
  1493. X/* Getting the number of rows is hard. Most screens support 25 only,
  1494. X * EGA/VGA also support 43/50 lines, and some OEM's even more.
  1495. X * Unfortunately, there is no standard bios variable for the number
  1496. X * of lines, and the bios screen memory size is always rounded up
  1497. X * to 0x1000. So, we'll really have to cheat.
  1498. X * When using the screen memory size, keep in mind that each character
  1499. X * byte has an associated attribute byte.
  1500. X *
  1501. X * uses:    word at 40:4c contains    memory size
  1502. X *        byte at 40:84         # of rows-1 (sometimes)
  1503. X *        byte at    40:4a        # of columns
  1504. X */
  1505. X
  1506. Xint v_rows()
  1507. X{
  1508. X    int line, oldline;
  1509. X
  1510. X    /* screen size less then 4K? then we have 25 lines only */
  1511. X
  1512. X    if (*(int far *)(0x0040004cl)<=4096)
  1513. X        return 25;
  1514. X
  1515. X    /* VEGA vga uses the bios byte at 0x40:0x84 for # of rows.
  1516. X     * Use that byte, if it makes sense together with memory size.
  1517. X     */
  1518. X
  1519. X    if ((((*(unsigned char far *)(0x0040004aL)*2*
  1520. X        (*(unsigned char far *)(0x00400084L)+1))+0xfff)&(~0xfff))==
  1521. X        *(unsigned int far *)(0x0040004cL))
  1522. X            return *(unsigned char far *)(0x00400084L)+1;
  1523. X
  1524. X    /* uh oh. Emit '\n's until screen starts scrolling. */
  1525. X
  1526. X    v_move(oldline=0, 0);
  1527. X    for (;;)
  1528. X    {
  1529. X        video(0xe0a,(int *)0,(int *)0);
  1530. X        video(0x300,(int *)0,&line);
  1531. X        line>>=8;
  1532. X        if (oldline==line)
  1533. X            return line+1;
  1534. X        oldline=line;    
  1535. X    }
  1536. X}
  1537. X
  1538. X/* the REAL bios interface -- used internally only. */
  1539. X
  1540. Xstatic void video(ax, cx, dx)
  1541. X    int ax, *cx, *dx;
  1542. X{
  1543. X    union REGS regs;
  1544. X
  1545. X    regs.x.ax=ax;
  1546. X    if ((ax&0xff00)==0x600 || (ax&0xff00)==0x700)
  1547. X        regs.h.bh=attr[screen][vmode];
  1548. X    else
  1549. X    {
  1550. X        regs.h.bh=0;
  1551. X        regs.h.bl=attr[screen][vmode];
  1552. X    }
  1553. X    if (cx) regs.x.cx=*cx;
  1554. X    if (dx) regs.x.dx=*dx;
  1555. X    int86(0x10, ®s, ®s);
  1556. X    if (dx) *dx=regs.x.dx;
  1557. X    if (cx) *cx=regs.x.cx;
  1558. X}
  1559. X
  1560. X/* The following function determines which character is used for
  1561. X * commandline-options by command.com. This system call is undocumented
  1562. X * and valid for versions < 4.00 only.
  1563. X */
  1564. Xint switchar()
  1565. X{
  1566. X    union REGS regs;
  1567. X    regs.x.ax=0x3700;
  1568. X    int86(0x21, ®s, ®s);
  1569. X    return regs.h.dl;
  1570. X}
  1571. X
  1572. X#endif
  1573. eof
  1574. if test `wc -c <pc.c` -ne 5512
  1575. then
  1576. echo pc.c damaged!
  1577. fi
  1578. fi
  1579.  
  1580. if test -f ref.c -a "$1" != -f
  1581. then
  1582. echo Will not overwrite ref.c
  1583. else
  1584. echo Extracting ref.c
  1585. sed 's/^X//' >ref.c <<\eof
  1586. X/* ref.c */
  1587. X
  1588. X/* Author:
  1589. X *    Steve Kirkendall
  1590. X *    14407 SW Teal Blvd. #C
  1591. X *    Beaverton, OR 97005
  1592. X *    kirkenda@cs.pdx.edu
  1593. X */
  1594. X
  1595. X
  1596. X/* This program looks up the declarations of library functions. */
  1597. X
  1598. X#include <stdio.h>
  1599. X
  1600. X/* This is the list of files that are searched. */
  1601. X#ifdef OSK
  1602. Xchar *refslist[] = {
  1603. X    "refs",
  1604. X    "/dd/usr/src/lib/refs",
  1605. X    "../lib/refs",
  1606. X    "/dd/usr/local/lib/refs",
  1607. X};
  1608. X#else
  1609. Xchar *refslist[] = {
  1610. X    "refs",
  1611. X    "/usr/src/lib/refs",
  1612. X    "../lib/refs",
  1613. X    "/usr/local/lib/refs"
  1614. X};
  1615. X#endif
  1616. X#define NREFS    (sizeof refslist / sizeof(char *))
  1617. X
  1618. Xmain(argc, argv)
  1619. X    int    argc;
  1620. X    char    **argv;
  1621. X{
  1622. X    int    i;    /* used to step through the refslist */
  1623. X
  1624. X    /* make sure our arguments are OK */
  1625. X    if (argc != 2)
  1626. X    {
  1627. X        fprintf(stderr, "usage: %s function_name\n", *argv);
  1628. X        exit(2);
  1629. X    }
  1630. X
  1631. X    /* check for the function in each database */
  1632. X    for (i = 0; i < NREFS; i++)
  1633. X    {
  1634. X        if (lookinfor(refslist[i], argv[1]))
  1635. X        {
  1636. X            exit(0);
  1637. X        }
  1638. X    }
  1639. X
  1640. X    fprintf(stderr, "%s: don't know about %s\n", argv[0], argv[1]);
  1641. X    exit(2);
  1642. X}
  1643. X
  1644. X
  1645. X/* This function checks a single file for the function.  Returns 1 if found */
  1646. Xint lookinfor(filename, func)
  1647. X    char    *filename;    /* name of file to look in */
  1648. X    char    *func;        /* name of function to look for */
  1649. X{
  1650. X    FILE    *fp;    /* stream used to access the database */
  1651. X    char    linebuf[300];
  1652. X        /* NOTE: in actual use, the first character of linebuf is */
  1653. X        /* set to ' ' and then we use all EXCEPT the 1st character */
  1654. X        /* everywhere in this function.  This is because the func */
  1655. X        /* which examines the linebuf could, in some circumstances */
  1656. X        /* examine the character before the used part of linebuf; */
  1657. X        /* we need to control what happens then.           */
  1658. X
  1659. X
  1660. X    /* open the database file */
  1661. X    fp = fopen(filename, "r");
  1662. X    if (!fp)
  1663. X    {
  1664. X        return 0;
  1665. X    }
  1666. X
  1667. X    /* find the desired entry */
  1668. X    *linebuf = ' ';
  1669. X    do
  1670. X    {
  1671. X        if (!fgets(linebuf + 1, (sizeof linebuf) - 1, fp))
  1672. X        {
  1673. X            fclose(fp);
  1674. X            return 0;
  1675. X        }
  1676. X    } while (!desired(linebuf + 1, func));
  1677. X
  1678. X    /* print it */
  1679. X    do
  1680. X    {
  1681. X        fputs(linebuf + 1, stdout);
  1682. X    } while (fgets(linebuf + 1, sizeof linebuf, fp) && linebuf[1] == '\t');
  1683. X
  1684. X    /* cleanup & exit */
  1685. X    fclose(fp);
  1686. X    return 1;
  1687. X}
  1688. X
  1689. X
  1690. X/* This function checks to see if a given line is the first line of the */
  1691. X/* entry the user wants to see.  If it is, return non-0 else return 0   */
  1692. Xdesired(line, word)
  1693. X    char    *line;    /* the line buffer */
  1694. X    char    *word;    /* the string it should contain */
  1695. X{
  1696. X    static    wlen = -1;/* length of the "word" variable's value */
  1697. X    register char *scan;
  1698. X
  1699. X    /* if this line starts with a tab, it couldn't be desired */
  1700. X    if (*line == '\t')
  1701. X    {
  1702. X        return 0;
  1703. X    }
  1704. X
  1705. X    /* if we haven't found word's length yet, do so */
  1706. X    if (wlen < 0)
  1707. X    {
  1708. X        wlen = strlen(word);
  1709. X    }
  1710. X
  1711. X    /* search for the word in the line */
  1712. X    for (scan = line; *scan != '('; scan++)
  1713. X    {
  1714. X    }
  1715. X    while (*--scan == ' ')
  1716. X    {
  1717. X    }
  1718. X    scan -= wlen;
  1719. X    if (scan < line - 1 || *scan != ' ' && *scan != '\t' && *scan != '*')
  1720. X    {
  1721. X        return 0;
  1722. X    }
  1723. X    scan++;
  1724. X    return !strncmp(scan, word, wlen);
  1725. X}
  1726. eof
  1727. if test `wc -c <ref.c` -ne 2872
  1728. then
  1729. echo ref.c damaged!
  1730. fi
  1731. fi
  1732.  
  1733. if test -f shell.c -a "$1" != -f
  1734. then
  1735. echo Will not overwrite shell.c
  1736. else
  1737. echo Extracting shell.c
  1738. sed 's/^X//' >shell.c <<\eof
  1739. X/* shell.c */
  1740. X
  1741. X/* Author:
  1742. X *    Guntram Blohm
  1743. X *    Buchenstrasse 19
  1744. X *    7904 Erbach, West Germany
  1745. X *    Tel. ++49-7305-6997
  1746. X *    sorry - no regular network connection
  1747. X */
  1748. X
  1749. X/*
  1750. X * This file contains a minimal version of a shell for TOS. It allows the
  1751. X * setting of an environment, calling programs, and exiting.
  1752. X * If you don't have another one, this might be sufficient, but you should 
  1753. X * prefer *any* other shell.
  1754. X * You may, however, want to set your SHELL environment variable to this
  1755. X * shell: it implements the -c switch, which is required by Elvis, and
  1756. X * not supported by most other atari shells.
  1757. X */
  1758. X#include <stdio.h>
  1759. X#include <string.h>
  1760. X#include <osbind.h>
  1761. Xextern char *getenv(), *malloc();
  1762. Xextern char **environ;
  1763. Xlong _stksize=16384;
  1764. X
  1765. X#define    MAXENV    50
  1766. X
  1767. Xstruct
  1768. X{
  1769. X    char *name;
  1770. X    char *value;
  1771. X} myenv[MAXENV];
  1772. X
  1773. Xint cmd_set(), cmd_exit();
  1774. X
  1775. Xstruct buildins
  1776. X{
  1777. X    char *name;
  1778. X    int (*func)();
  1779. X} buildins[]=
  1780. X{    "exit", cmd_exit,
  1781. X    "set", cmd_set,
  1782. X    0,
  1783. X};
  1784. X
  1785. Xmain(argc, argv)
  1786. X    int argc;
  1787. X    char **argv;
  1788. X{
  1789. X    char buf[128];
  1790. X    int i;
  1791. X
  1792. X    for (i=0; environ[i] && strncmp(environ[i],"ARGV=",5); i++)
  1793. X        cmd_set(environ[i]);
  1794. X    script("profile.sh");
  1795. X
  1796. X    if (argc>1 && !strcmp(argv[1], "-c"))
  1797. X    {
  1798. X        buf[0]='\0';
  1799. X        for (i=2; i<argc; i++)
  1800. X        {    if (i>2)
  1801. X                strcat(buf, " ");
  1802. X            strcat(buf, argv[i]);
  1803. X        }
  1804. X        execute(buf);
  1805. X    }
  1806. X    else
  1807. X        while (fputs("$ ", stdout), gets(buf))
  1808. X            execute(buf);
  1809. X}
  1810. X
  1811. Xexecute(buf)
  1812. X    char *buf;
  1813. X{
  1814. X    char *scan=buf;
  1815. X    char cmd[80];
  1816. X    char line[128];
  1817. X    char env[4096], *ep=env;
  1818. X    int i;
  1819. X
  1820. X    while (*scan==' ')
  1821. X        scan++;
  1822. X    if (!*scan)
  1823. X        return;
  1824. X    while (*scan && *scan!=' ')
  1825. X        scan++;
  1826. X    if (*scan)
  1827. X        *scan++='\0';
  1828. X
  1829. X    for (i=0; buildins[i].name; i++)
  1830. X        if (!strcmp(buf, buildins[i].name))
  1831. X            return (*buildins[i].func)(scan);
  1832. X
  1833. X    if (!searchpath(buf, cmd))
  1834. X    {    printf("%s: not found\n", buf);
  1835. X        return -1;
  1836. X    }
  1837. X
  1838. X    strcpy(line+1, scan);
  1839. X    line[0]=strlen(scan);
  1840. X    for (i=0; i<MAXENV && myenv[i].name; i++)
  1841. X    {    strcpy(ep, myenv[i].name);
  1842. X        strcat(ep, "=");
  1843. X        strcat(ep, myenv[i].value);
  1844. X        ep+=strlen(ep)+1;
  1845. X    }
  1846. X    
  1847. X    *ep='\0';
  1848. X
  1849. X    return Pexec(0, cmd, line, env);
  1850. X}
  1851. X
  1852. Xsearchpath(from, to)
  1853. X    char *from, *to;
  1854. X{
  1855. X    char *path="";
  1856. X    char *scan;
  1857. X    char *end;
  1858. X    char *q;
  1859. X    int i;
  1860. X
  1861. X    for (i=0; i<MAXENV && myenv[i].name; i++)
  1862. X        if (!strcmp(myenv[i].name,"PATH"))
  1863. X            path=myenv[i].value;
  1864. X    for (scan=from; *scan; scan++)
  1865. X        if (*scan==':' || *scan=='\\')
  1866. X        {    path=0;
  1867. X            break;
  1868. X        }
  1869. X    if (!path)
  1870. X    {    strcpy(to, from);
  1871. X        end=to+strlen(to);
  1872. X        strcpy(end, ".prg"); if (try(to)) return 1;
  1873. X        strcpy(end, ".ttp"); if (try(to)) return 1;
  1874. X        strcpy(end, ".tos"); if (try(to)) return 1;
  1875. X        *to='\0'; return 0;
  1876. X    }
  1877. X    for (scan=path; *scan; )
  1878. X    {
  1879. X        for (q=to; *scan && *scan!=';' && *scan!=','; scan++)
  1880. X            *q++=*scan;
  1881. X        if (*scan==';' || *scan==',')
  1882. X            scan++;
  1883. X        *q++='\\';
  1884. X        *q='\0';
  1885. X        strcpy(q, from);
  1886. X        end=q+strlen(q);
  1887. X        strcpy(end, ".prg"); if (try(to)) return 1;
  1888. X        strcpy(end, ".ttp"); if (try(to)) return 1;
  1889. X        strcpy(end, ".tos"); if (try(to)) return 1;
  1890. X    }
  1891. X    *to='\0';
  1892. X    return 0;
  1893. X}
  1894. X
  1895. Xtry(name)
  1896. X    char *name;
  1897. X{
  1898. X    if (Fattrib(name, 0, 0) < 0)
  1899. X        return 0;
  1900. X    return 1;
  1901. X}
  1902. X
  1903. Xcmd_exit()
  1904. X{
  1905. X    exit(0);
  1906. X}
  1907. X
  1908. Xcmd_set(line)
  1909. X    char *line;
  1910. X{
  1911. X    char *value;
  1912. X    int i;
  1913. X
  1914. X    if (!*line)
  1915. X    {
  1916. X        for (i=0; i<MAXENV && myenv[i].name; i++)
  1917. X            printf("%s=%s\n", myenv[i].name, myenv[i].value);
  1918. X        return 0;
  1919. X    }
  1920. X
  1921. X    for (value=line; *value && *value!='='; value++)
  1922. X        ;
  1923. X    if (!*value)
  1924. X    {    printf("Usage: set name=var\n");
  1925. X        return -1;
  1926. X    }
  1927. X    *value++='\0';
  1928. X    doset(line, value);
  1929. X}
  1930. X
  1931. Xdoset(line, value)
  1932. X    char *line, *value;
  1933. X{
  1934. X    int i;
  1935. X
  1936. X    for (i=0; i<MAXENV && myenv[i].name && strcmp(myenv[i].name, line); i++)
  1937. X        ;
  1938. X    if (i==MAXENV)
  1939. X    {    printf("No Space\n");
  1940. X        return -1;
  1941. X    }
  1942. X    if (!myenv[i].name)
  1943. X    {    myenv[i].name=malloc(strlen(line)+1);
  1944. X        strcpy(myenv[i].name, line);
  1945. X    }
  1946. X    if (myenv[i].value)
  1947. X        free(myenv[i].value);
  1948. X    myenv[i].value=malloc(strlen(value)+1);
  1949. X    strcpy(myenv[i].value, value);
  1950. X    return 0;
  1951. X}
  1952. X
  1953. Xscript(name)
  1954. X    char *name;
  1955. X{
  1956. X    FILE *fp;
  1957. X    char buf[128], *p;
  1958. X
  1959. X    if ((fp=fopen(name, "r"))==0)
  1960. X        return;
  1961. X    while (fgets(buf, sizeof buf, fp))
  1962. X    {
  1963. X        if ((p=strchr(buf, '\n'))!=0)
  1964. X            *p='\0';
  1965. X        execute(buf);
  1966. X    }
  1967. X    fclose(fp);
  1968. X}
  1969. eof
  1970. if test `wc -c <shell.c` -ne 3981
  1971. then
  1972. echo shell.c damaged!
  1973. fi
  1974. fi
  1975.  
  1976. if test -f sysdos.c -a "$1" != -f
  1977. then
  1978. echo Will not overwrite sysdos.c
  1979. else
  1980. echo Extracting sysdos.c
  1981. sed 's/^X//' >sysdos.c <<\eof
  1982. X/* sysdos.c  -- DOS version of system.c */
  1983. X
  1984. X/* Author:
  1985. X *    Guntram Blohm
  1986. X *    Buchenstrasse 19
  1987. X *    7904 Erbach, West Germany
  1988. X *    Tel. ++49-7305-6997
  1989. X *    sorry - no regular network connection
  1990. X */
  1991. X
  1992. X
  1993. X/* This file is derived from Steve Kirkendall's system.c.
  1994. X *
  1995. X * Entry points are:
  1996. X *    system(cmd)    - run a single shell command
  1997. X *    wildcard(names)    - expand wildcard characters in filanames
  1998. X *
  1999. X * This file is for use with DOS and TOS. For OS/2, slight modifications
  2000. X * might be sufficient. For UNIX, use system.c. For Amiga, completely
  2001. X * rewrite this stuff.
  2002. X *
  2003. X * Another system function, filter, is the same on DOS and UNIX and thus
  2004. X * can be found in the original system.c.
  2005. X */
  2006. X
  2007. X#include "config.h"
  2008. X#include "vi.h"
  2009. Xextern char **environ;
  2010. X
  2011. X
  2012. X#if MSDOS
  2013. X#include <process.h>
  2014. Xextern unsigned char _osmajor;
  2015. X#endif
  2016. X#if TOS
  2017. X#include <osbind.h>
  2018. X#endif
  2019. X
  2020. X
  2021. X#if MSDOS || TOS
  2022. X#include <string.h>
  2023. X
  2024. X/*
  2025. X * Calling command is a bit nasty because of the undocumented yet sometimes
  2026. X * used feature to change the option char to something else than /.
  2027. X * Versions 2.x and 3.x support this, 4.x doesn't.
  2028. X *
  2029. X * For Atari, some shells define a shortcut entry which is faster than
  2030. X * shell -c. Also, Mark Williams uses a special ARGV environment variable
  2031. X * to pass more than 128 chars to a called command.
  2032. X * We try to support all of these features here.
  2033. X */
  2034. X
  2035. Xint system(cmd)
  2036. X    const char    *cmd;
  2037. X{
  2038. X#if MSDOS
  2039. X    char *cmdswitch="/c";
  2040. X    if (_osmajor<4)
  2041. X        cmdswitch[0]=switchar();
  2042. X    return spawnle(P_WAIT, o_shell, o_shell, cmdswitch, cmd, (char *)0, environ);
  2043. X#else
  2044. X    long    ssp;
  2045. X    int    (*shell)();
  2046. X    char    line[130];
  2047. X    char    env[4096], *ep=env;
  2048. X    int    i;
  2049. X
  2050. X/* does our shell have a shortcut, that we can use? */
  2051. X
  2052. X    ssp = Super(0L);
  2053. X    shell = *((int (**)())0x4F6);
  2054. X    Super(ssp);
  2055. X    if (shell)
  2056. X        return (*shell)(cmd);
  2057. X
  2058. X/* else we'll have to call a shell ... */
  2059. X
  2060. X    for (i=0; environ[i] && strncmp(environ[i], "ARGV=", 5); i++)
  2061. X    {    strcpy(ep, environ[i]);
  2062. X        ep+=strlen(ep)+1;
  2063. X    }
  2064. X    if (environ[i])
  2065. X    {
  2066. X        strcpy(ep, environ[i]); ep+=strlen(ep)+1;
  2067. X        strcpy(ep, o_shell); ep+=strlen(ep)+1;
  2068. X        strcpy(ep, "-c"); ep+=3;
  2069. X        strcpy(ep, cmd); ep+=strlen(ep)+1;
  2070. X    }
  2071. X    *ep='\0';
  2072. X    strcpy(line+1, "-c ");
  2073. X    strncat(line+1, cmd, 126);
  2074. X    line[0]=strlen(line+1);
  2075. X    return Pexec(0, o_shell, line, env);
  2076. X#endif
  2077. X}
  2078. X
  2079. X/* This private function opens a pipe from a filter.  It is similar to the
  2080. X * system() function above, and to popen(cmd, "r").
  2081. X * sorry - i cant use cmdstate until rpclose, but get it from spawnle.
  2082. X */
  2083. X
  2084. Xstatic int cmdstate;
  2085. Xstatic char output[80];
  2086. X
  2087. Xint rpipe(cmd, in)
  2088. X    char    *cmd;    /* the filter command to use */
  2089. X    int    in;    /* the fd to use for stdin */
  2090. X{
  2091. X    int    fd, old0, old1, old2;
  2092. X
  2093. X    /* create the file that will collect the filter's output */
  2094. X    strcpy(output, o_directory);
  2095. X    if ((fd=strlen(output)) && !strchr("/\\:", output[fd-1]))
  2096. X        output[fd++]=SLASH;
  2097. X    strcpy(output+fd, SCRATCHIN+3);
  2098. X    mktemp(output);
  2099. X    close(creat(output, 0666));
  2100. X    if ((fd=open(output, O_RDWR))==-1)
  2101. X    {
  2102. X        unlink(output);
  2103. X        return -1;
  2104. X    }
  2105. X
  2106. X    /* save and redirect stdin, stdout, and stderr */
  2107. X    old0=dup(0);
  2108. X    old1=dup(1);
  2109. X    if (in)
  2110. X    {
  2111. X        dup2(in, 0);
  2112. X        close(in);
  2113. X    }
  2114. X    dup2(fd, 1);
  2115. X
  2116. X    /* call command */
  2117. X    cmdstate=system(cmd);
  2118. X
  2119. X    /* restore old std... */
  2120. X    dup2(old0, 0); close(old0);
  2121. X    dup2(old1, 1); close(old1);
  2122. X
  2123. X    /* rewind command output */
  2124. X    lseek(fd, 0L, 0);
  2125. X    return fd;
  2126. X}
  2127. X
  2128. X/* This function closes the pipe opened by rpipe(), and returns 0 for success */
  2129. Xint rpclose(fd)
  2130. X    int    fd;
  2131. X{
  2132. X    int    status;
  2133. X
  2134. X    close(fd);
  2135. X    unlink(output);
  2136. X    return cmdstate;
  2137. X}
  2138. X
  2139. X#endif
  2140. eof
  2141. if test `wc -c <sysdos.c` -ne 3438
  2142. then
  2143. echo sysdos.c damaged!
  2144. fi
  2145. fi
  2146.  
  2147. if test -f virec.c -a "$1" != -f
  2148. then
  2149. echo Will not overwrite virec.c
  2150. else
  2151. echo Extracting virec.c
  2152. sed 's/^X//' >virec.c <<\eof
  2153. X/* virec.c */
  2154. X
  2155. X/* Author:
  2156. X *    Steve Kirkendall
  2157. X *    14407 SW Teal Blvd. #C
  2158. X *    Beaverton, OR 97005
  2159. X *    kirkenda@cs.pdx.edu
  2160. X */
  2161. X
  2162. X/* This file contains the file recovery program */
  2163. X
  2164. X
  2165. X#include "config.h"
  2166. X#include <stdio.h>
  2167. X#include <ctype.h>
  2168. X#include "vi.h"
  2169. X#if TOS
  2170. X# include <stat.h>
  2171. X#else
  2172. X# if OSK
  2173. X#  include "osk.h"
  2174. X# else
  2175. X#  include <sys/stat.h>
  2176. X# endif
  2177. X#endif
  2178. X
  2179. Xextern char    *getenv();
  2180. Xstruct stat    stbuf;
  2181. XBLK        hdr;
  2182. XBLK        text;
  2183. X
  2184. X/* the name of the directory where tmp files are stored. */
  2185. Xchar o_directory[30] = TMPDIR;
  2186. X
  2187. Xchar    *progname;
  2188. X
  2189. Xmain(argc, argv)
  2190. X    int    argc;
  2191. X    char    **argv;
  2192. X{
  2193. X    char    *tmp;
  2194. X    void recover();
  2195. X#if MSDOS || TOS
  2196. X    char **wildexpand();
  2197. X    argv = wildexpand(&argc, argv);
  2198. X#endif
  2199. X    progname = argv[0];
  2200. X    /* set the o_directory variable */
  2201. X    if ((tmp = getenv("TMP"))    /* yes, ASSIGNMENT! */
  2202. X     || (tmp = getenv("TEMP")))    /* yes, ASSIGNMENT! */
  2203. X    {
  2204. X        strcpy(o_directory, tmp);
  2205. X    }
  2206. X    if (argc >= 3 && !strcmp(argv[1], "-d"))
  2207. X    {
  2208. X        strcpy(o_directory, argv[2]);
  2209. X        argc -= 2;
  2210. X        argv += 2;
  2211. X    }
  2212. X    /* process the arguments */
  2213. X    if (argc < 2)
  2214. X    {
  2215. X        /* maybe stdin comes from a file? */
  2216. X        if (isatty(0))
  2217. X        {
  2218. X            fprintf(stderr, "usage: %s [-d tmpdir] lostfile...\n", progname);
  2219. X        }
  2220. X        else if (read(0, &hdr, (unsigned)BLKSIZE) != BLKSIZE)
  2221. X        {
  2222. X            fprintf(stderr, "couldn't get header\n");
  2223. X        }
  2224. X        else
  2225. X        {
  2226. X            copytext(0, stdout);
  2227. X        }
  2228. X    }
  2229. X    else
  2230. X    {
  2231. X        while (--argc > 0)
  2232. X        {
  2233. X            recover(*++argv);
  2234. X        }
  2235. X    }
  2236. X    exit(0);
  2237. X}
  2238. X
  2239. X
  2240. X/* This function recovers a single file */
  2241. Xvoid recover(filename)
  2242. X    char    *filename;
  2243. X{
  2244. X    char        tmpname[100];
  2245. X    int        tmpfd;
  2246. X    FILE        *fp;
  2247. X    long        mtime;
  2248. X    int        i, j;
  2249. X    int        sum;    /* used for calculating a checksum for this */
  2250. X    char        *scan;
  2251. X
  2252. X    /* get the file's status info */
  2253. X    if (stat(filename, &stbuf) < 0)
  2254. X    {
  2255. X        /* if serious error, give up on this file */
  2256. X        if (errno != ENOENT)
  2257. X        {
  2258. X            perror(filename);
  2259. X            return;
  2260. X        }
  2261. X
  2262. X        /* else fake it for a new file */
  2263. X        stat(".", &stbuf);
  2264. X#if OSK
  2265. X        stbuf.st_mode = S_IREAD;
  2266. X#else
  2267. X        stbuf.st_mode = S_IFREG;
  2268. X#endif
  2269. X        stbuf.st_mtime = 0L;
  2270. X    }
  2271. X
  2272. X    /* generate a checksum from the file's name */
  2273. X    for (sum = 0, scan = filename + strlen(filename);
  2274. X         --scan >= filename && (isascii(*scan) && isalnum(*scan) || *scan == '.');
  2275. X         sum = sum + *scan)
  2276. X    {
  2277. X    }
  2278. X    sum &= 0xf;
  2279. X
  2280. X    /* find the tmp file */
  2281. X#if MSDOS || TOS
  2282. X    /* MS-Dos doesn't allow multiple slashes, but supports drives
  2283. X     * with current directories.
  2284. X     * This relies on TMPNAME beginning with "%s\\"!!!!
  2285. X     */
  2286. X    strcpy(tmpname, o_directory);
  2287. X    if ((i = strlen(tmpname)) && !strchr(":/\\", tmpname[i-1]))
  2288. X        tmpname[i++]=SLASH;
  2289. X    sprintf(tmpname+i, TMPNAME+3, sum, stbuf.st_ino, stbuf.st_dev);
  2290. X#else
  2291. X    sprintf(tmpname, TMPNAME, o_directory, sum, stbuf.st_ino, stbuf.st_dev);
  2292. X#endif
  2293. X    tmpfd = open(tmpname, O_RDONLY | O_BINARY);
  2294. X    if (tmpfd < 0)
  2295. X    {
  2296. X        perror(tmpname);
  2297. X        return;
  2298. X    }
  2299. X
  2300. X    /* make sure the file hasn't been modified more recently */
  2301. X    mtime = stbuf.st_mtime;
  2302. X    fstat(tmpfd, &stbuf);
  2303. X    if (stbuf.st_mtime < mtime)
  2304. X    {
  2305. X        printf("\"%s\" has been modified more recently than its recoverable version\n", filename);
  2306. X        puts("Do you still want to recover it?\n");
  2307. X        puts("\ty - Yes, discard the current version and recover it.\n");
  2308. X        puts("\tn - No, discard the recoverable version and keep the current version\n");
  2309. X        puts("\tq - Quit without doing anything for this file.\n");
  2310. X        puts("Enter y, n, or q --> ");
  2311. X        fflush(stdout);
  2312. X        for (;;)
  2313. X        {
  2314. X            switch (getchar())
  2315. X            {
  2316. X              case 'y':
  2317. X              case 'Y':
  2318. X                goto BreakBreak;
  2319. X
  2320. X              case 'n':
  2321. X              case 'N':
  2322. X                close(tmpfd);
  2323. X                unlink(tmpname);
  2324. X                return;
  2325. X
  2326. X              case 'q':
  2327. X              case 'Q':
  2328. X                close(tmpfd);
  2329. X                return;
  2330. X            }
  2331. X        }
  2332. XBreakBreak:;
  2333. X    }
  2334. X
  2335. X    /* make sure this tmp file is intact */
  2336. X    if (read(tmpfd, &hdr, (unsigned)BLKSIZE) != BLKSIZE)
  2337. X    {
  2338. X        fprintf(stderr, "%s: bad header in tmp file\n", filename);
  2339. X        close(tmpfd);
  2340. X        unlink(tmpname);
  2341. X        return;
  2342. X    }
  2343. X    for (i = j = 1; i < MAXBLKS && hdr.n[i]; i++)
  2344. X    {
  2345. X        if (hdr.n[i] > j)
  2346. X        {
  2347. X            j = hdr.n[i];
  2348. X        }
  2349. X    }
  2350. X    lseek(tmpfd, (long)j * (long)BLKSIZE, 0);
  2351. X    if (read(tmpfd, &text, (unsigned)BLKSIZE) != BLKSIZE)
  2352. X    {
  2353. X        fprintf(stderr, "%s: bad data block in tmp file\n", filename);
  2354. X        close(tmpfd);
  2355. X        unlink(tmpname);
  2356. X        return;
  2357. X    }
  2358. X
  2359. X    /* open the normal text file for writing */
  2360. X    fp = fopen(filename, "w");
  2361. X    if (!fp)
  2362. X    {
  2363. X        perror(filename);
  2364. X        close(tmpfd);
  2365. X        return;
  2366. X    }
  2367. X
  2368. X    /* copy the text */
  2369. X    copytext(tmpfd, fp);
  2370. X
  2371. X    /* cleanup */
  2372. X    close(tmpfd);
  2373. X    fclose(fp);
  2374. X    unlink(tmpname);
  2375. X}
  2376. X
  2377. X
  2378. X/* This function moves text from the tmp file to the normal file */
  2379. Xcopytext(tmpfd, fp)
  2380. X    int    tmpfd;    /* fd of the tmp file */
  2381. X    FILE    *fp;    /* the stream to write it to */
  2382. X{
  2383. X    int    i;
  2384. X
  2385. X    /* write the data blocks to the normal text file */
  2386. X    for (i = 1; i < MAXBLKS && hdr.n[i]; i++)
  2387. X    {
  2388. X        lseek(tmpfd, (long)hdr.n[i] * (long)BLKSIZE, 0);
  2389. X        read(tmpfd, &text, (unsigned)BLKSIZE);
  2390. X        fputs(text.c, fp);
  2391. X    }
  2392. X}
  2393. X
  2394. X#if MSDOS || TOS
  2395. X#define        WILDCARD_NO_MAIN
  2396. X#include    "wildcard.c"
  2397. X#endif
  2398. eof
  2399. if test `wc -c <virec.c` -ne 4780
  2400. then
  2401. echo virec.c damaged!
  2402. fi
  2403. fi
  2404.  
  2405. if test -f wildcard.c -a "$1" != -f
  2406. then
  2407. echo Will not overwrite wildcard.c
  2408. else
  2409. echo Extracting wildcard.c
  2410. sed 's/^X//' >wildcard.c <<\eof
  2411. X/* wildcard.c */
  2412. X
  2413. X/* Author:
  2414. X *    Guntram Blohm
  2415. X *    Buchenstrasse 19
  2416. X *    7904 Erbach, West Germany
  2417. X *    Tel. ++49-7305-6997
  2418. X *    sorry - no regular network connection
  2419. X */
  2420. X
  2421. X/* this program implements wildcard expansion for elvis/dos. It works
  2422. X * like UNIX echo, but uses the dos wildcard conventions
  2423. X * (*.* matches all files, * matches files without extension only,
  2424. X * filespecs may contain drive letters, wildcards not allowed in directory
  2425. X * names).
  2426. X *
  2427. X * It is also #included into ctags.c, ref.c, ...; in this case,
  2428. X * we don't want a main function here.
  2429. X */
  2430. X
  2431. X#include <stdio.h>
  2432. X#include <ctype.h>
  2433. X#ifdef    __TURBOC__
  2434. X#include <dir.h>
  2435. X#endif
  2436. X#ifdef    M_I86
  2437. X#define    findfirst(a,b,c)    _dos_findfirst(a,c,b)
  2438. X#define    findnext        _dos_findnext
  2439. X#define    ffblk            find_t
  2440. X#define    ff_name            name
  2441. X#include <dos.h>
  2442. X#endif
  2443. X#ifdef    M68000
  2444. X#include <stat.h>
  2445. X#include <osbind.h>
  2446. X#define    findfirst(a,b,c)    (Fsetdta(b), (Fsfirst(a,c)))
  2447. X#define    findnext(x)        (Fsnext())
  2448. X#define    ff_name    d_fname
  2449. X#endif
  2450. X#define    MAXFILES    1000
  2451. X
  2452. Xint pstrcmp();
  2453. Xextern char *calloc();
  2454. X
  2455. Xchar *files[MAXFILES];
  2456. Xint nfiles;
  2457. X
  2458. X#ifndef    WILDCARD_NO_MAIN
  2459. X
  2460. Xmain(argc, argv)
  2461. X    char **argv;
  2462. X{
  2463. X    int i;
  2464. X
  2465. X    for (i=1; i<argc; i++)
  2466. X        expand(argv[i]);
  2467. X    if (nfiles)
  2468. X        printf("%s", files[0]);
  2469. X    for (i=1; i<nfiles; i++)
  2470. X    {
  2471. X        printf(" %s", files[i]);
  2472. X    }
  2473. X    putchar('\n');
  2474. X    return 0;
  2475. X}
  2476. X
  2477. X#else
  2478. Xchar **wildexpand(argc, argv)
  2479. X    int *argc;
  2480. X    char **argv;
  2481. X{
  2482. X    int i;
  2483. X    
  2484. X    for (i=0; i<*argc; i++)
  2485. X        expand(argv[i]);
  2486. X    *argc=nfiles;
  2487. X    return files;
  2488. X}    
  2489. X#endif
  2490. X
  2491. Xexpand(name)
  2492. X    char *name;
  2493. X{
  2494. X    char *filespec;
  2495. X    int wildcard=0;
  2496. X#ifdef    M68000
  2497. X    DMABUFFER findbuf;
  2498. X#else
  2499. X    struct ffblk findbuf;
  2500. X#endif
  2501. X    int err;
  2502. X    char buf[80];
  2503. X    int lastn;
  2504. X
  2505. X    strcpy(buf, name);
  2506. X    for (filespec=buf; *filespec; filespec++)
  2507. X        ;
  2508. X
  2509. X    while (--filespec>=buf)
  2510. X    {    if (*filespec=='?' || *filespec=='*')
  2511. X            wildcard=1;
  2512. X        if (*filespec=='/' || *filespec=='\\' || *filespec==':')
  2513. X            break;
  2514. X    }
  2515. X    if (!wildcard)
  2516. X        addfile(buf);
  2517. X    else
  2518. X    {
  2519. X        lastn=nfiles;
  2520. X        filespec++;
  2521. X        if ((err=findfirst(buf, &findbuf, 0))!=0)
  2522. X            addfile(buf);
  2523. X        while (!err)
  2524. X        {
  2525. X            strcpy(filespec, findbuf.ff_name);
  2526. X            addfile(buf);
  2527. X            err=findnext(&findbuf);
  2528. X        }
  2529. X        if (lastn!=nfiles)
  2530. X            qsort(files+lastn, nfiles-lastn, sizeof(char *), pstrcmp);
  2531. X    }
  2532. X}
  2533. X
  2534. Xaddfile(buf)
  2535. X    char *buf;
  2536. X{
  2537. X    char *p;
  2538. X
  2539. X    for (p=buf; *p; p++)
  2540. X        *p=tolower(*p);
  2541. X
  2542. X    if (nfiles<MAXFILES && (files[nfiles]=calloc(strlen(buf)+1, 1))!=0)
  2543. X        strcpy(files[nfiles++], buf);
  2544. X}
  2545. X
  2546. Xint pstrcmp(a, b)
  2547. X    char **a, **b;
  2548. X{
  2549. X    return strcmp(*a, *b);
  2550. X}
  2551. eof
  2552. if test `wc -c <wildcard.c` -ne 2424
  2553. then
  2554. echo wildcard.c damaged!
  2555. fi
  2556. fi
  2557.  
  2558. if test -f profile.sh -a "$1" != -f
  2559. then
  2560. echo Will not overwrite profile.sh
  2561. else
  2562. echo Extracting profile.sh
  2563. sed 's/^X//' >profile.sh <<\eof
  2564. Xset TERM=vt52
  2565. Xset SHELL=shell
  2566. eof
  2567. if test `wc -c <profile.sh` -ne 30
  2568. then
  2569. echo profile.sh damaged!
  2570. fi
  2571. fi
  2572.  
  2573. if test -f osk.c -a "$1" != -f
  2574. then
  2575. echo Will not overwrite osk.c
  2576. else
  2577. echo Extracting osk.c
  2578. sed 's/^X//' >osk.c <<\eof
  2579. X/* osk.c */
  2580. X
  2581. X/* ------------------------------------------------------------------- *
  2582. X |
  2583. X | OS9Lib:  stat(), fstat()
  2584. X |
  2585. X |
  2586. X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
  2587. X |                           Ulli Dessauer, Germering and
  2588. X |                           Reimer Mellin, Muenchen
  2589. X |                           (W-Germany)
  2590. X |
  2591. X |  This  programm can  be  copied and  distributed freely  for any
  2592. X |  non-commercial  purposes.   It can only  be  incorporated  into
  2593. X |  commercial software with the written permission of the authors.
  2594. X |
  2595. X |  If you should modify this program, the authors would appreciate
  2596. X |  a notice about the changes. Please send a (context) diff or the
  2597. X |  complete source to:
  2598. X |
  2599. X |  address:     Wolfgang Ocker
  2600. X |               Lochhauserstrasse 35a
  2601. X |               D-8039 Puchheim
  2602. X |               West Germany
  2603. X |
  2604. X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
  2605. X |               pyramid!tmpmbx!recco!weo
  2606. X |               pyramid!tmpmbx!nitmar!ud
  2607. X |               pyramid!tmpmbx!ramsys!ram
  2608. X |
  2609. X * ----------------------------------------------------------------- */
  2610. X
  2611. X#ifdef OSK
  2612. X
  2613. X#define PATCHLEVEL 1
  2614. X
  2615. X#ifndef VIREC
  2616. X#include <stdio.h>
  2617. X#include "osk.h"
  2618. X#include <modes.h>
  2619. X#include <errno.h>
  2620. X#endif
  2621. X#include <signal.h>
  2622. X#include <sgstat.h>
  2623. X#include <sg_codes.h>
  2624. X#include <direct.h>
  2625. X
  2626. X/*
  2627. X * f s t a t
  2628. X */
  2629. Xint fstat(fd, buff)
  2630. X  int         fd;
  2631. X  struct stat *buff;
  2632. X{
  2633. X  struct fildes ftmp;
  2634. X  struct tm     ttmp;
  2635. X  struct _sgr   fopt;
  2636. X
  2637. X  if (_gs_gfd(fd, &ftmp, 16) < 0) /* 16 insteat of sizeof(struct fildes)   */
  2638. X    return(-1);                   /* used due to a bug in stupid os9net */
  2639. X
  2640. X  if (_gs_opt(fd, &fopt) < 0)
  2641. X    return(-1);
  2642. X
  2643. X  ttmp.tm_year  = (int) ftmp.fd_date[0];
  2644. X  ttmp.tm_mon   = (int) ftmp.fd_date[1] - 1;
  2645. X  ttmp.tm_mday  = (int) ftmp.fd_date[2];    
  2646. X  ttmp.tm_hour  = (int) ftmp.fd_date[3];
  2647. X  ttmp.tm_min   = (int) ftmp.fd_date[4];
  2648. X  ttmp.tm_sec   = 0;
  2649. X  ttmp.tm_isdst = -1;
  2650. X
  2651. X  buff->st_atime = buff->st_mtime = mktime(&ttmp);
  2652. X
  2653. X  ttmp.tm_year  = (int) ftmp.fd_dcr[0];
  2654. X  ttmp.tm_mon   = (int) ftmp.fd_dcr[1] - 1;
  2655. X  ttmp.tm_mday  = (int) ftmp.fd_dcr[2];    
  2656. X  ttmp.tm_hour  = ttmp.tm_min = ttmp.tm_sec = 0;
  2657. X  ttmp.tm_isdst = -1;
  2658. X  
  2659. X  buff->st_ctime = mktime(&ttmp);
  2660. X
  2661. X  memcpy(&(buff->st_size), ftmp.fd_fsize, sizeof(long));  /* misalignment! */
  2662. X  buff->st_uid   = ftmp.fd_own[1];
  2663. X  buff->st_gid   = ftmp.fd_own[0];
  2664. X  buff->st_mode  = ftmp.fd_att;
  2665. X  buff->st_nlink = ftmp.fd_link;
  2666. X
  2667. X  buff->st_ino   = fopt._sgr_fdpsn;
  2668. X  buff->st_dev   = fopt._sgr_dvt;
  2669. X
  2670. X  return(0);
  2671. X}
  2672. X
  2673. X/*
  2674. X * s t a t
  2675. X */    
  2676. Xint stat(filename, buff)
  2677. X  char        *filename;
  2678. X  struct stat *buff;
  2679. X{
  2680. X  register int i, ret;
  2681. X
  2682. X  if ((i = open(filename, S_IREAD)) < 0)
  2683. X    if ((i = open(filename, S_IFDIR | S_IREAD)) < 0)
  2684. X      return(-1);
  2685. X
  2686. X  ret = fstat(i, buff);
  2687. X  close(i);
  2688. X
  2689. X  return(ret);
  2690. X}
  2691. X
  2692. X/*
  2693. X    unix library functions mist in OSK
  2694. X    Author: Peter Reinig
  2695. X*/
  2696. X
  2697. X/* NOTE: this version of link() is only capable of renaming files, not true
  2698. X * UNIX-style linking.  That's okay, though, because elvis only uses it for
  2699. X * renaming.
  2700. X */
  2701. Xlink(from,to)
  2702. Xchar *from,*to;
  2703. X{
  2704. X    char *buffer;
  2705. X    int status;
  2706. X    char *malloc();
  2707. X
  2708. X    if ((buffer = malloc(strlen(from) + strlen(to) + 12)) == NULL)
  2709. X        return -1;
  2710. X    sprintf(buffer,"rename %s %s\n",from,to);
  2711. X    status = system(buffer);
  2712. X    free(buffer);
  2713. X    return status;
  2714. X}
  2715. X
  2716. Xtypedef (*procref)();
  2717. X#define MAX_SIGNAL 10
  2718. X
  2719. Xextern exit();
  2720. X
  2721. Xstatic int (*sig_table[MAX_SIGNAL])();
  2722. Xstatic int _sig_install = 0;
  2723. X
  2724. Xsig_handler(sig)
  2725. Xint sig;
  2726. X{
  2727. X    if ((int) sig_table[sig] > MAX_SIGNAL)
  2728. X        sig_table[sig](sig);
  2729. X}
  2730. X
  2731. Xprocref signal(sig,func)
  2732. Xint sig;
  2733. Xint (*func)();
  2734. X{
  2735. X    int i, (*sav)();
  2736. X
  2737. X    if (!_sig_install) {
  2738. X        for (i=0; i < MAX_SIGNAL; i++)
  2739. X            sig_table[i] = exit;
  2740. X        _sig_install = 1;
  2741. X        intercept(sig_handler);
  2742. X    }    
  2743. X    sav = sig_table[sig];
  2744. X    switch ((int) func) {
  2745. X        case SIG_DFL : sig_table[sig] = exit;
  2746. X                       break;
  2747. X        case SIG_IGN : sig_table[sig] = 0;
  2748. X                       break;
  2749. X        default      : sig_table[sig] = func;
  2750. X                       break;
  2751. X    }
  2752. X    return sav;
  2753. X}
  2754. X
  2755. Xperror(str)
  2756. Xchar *str;
  2757. X{
  2758. X    static int path = 0;
  2759. X    if (!path && (path = open("/dd/sys/Errmsg", S_IREAD)) == -1) {
  2760. X        fprintf(stderr,"Can\'t open error message file\n");
  2761. X        path = 0;
  2762. X    }
  2763. X    if (str && *str) {
  2764. X        fprintf(stderr,"%s: ",str);
  2765. X        fflush(stderr);
  2766. X    }
  2767. X    prerr(path,(short) errno);
  2768. X}
  2769. X
  2770. Xisatty(fd)
  2771. Xint fd;
  2772. X{
  2773. X    struct sgbuf buffer;
  2774. X    char type;
  2775. X
  2776. X    _gs_opt(fd,&buffer);
  2777. X    type = buffer.sg_class;
  2778. X    if (type == DT_SCF)
  2779. X        return 1;
  2780. X    else
  2781. X        return 0;
  2782. X}
  2783. X#endif /* OSK */
  2784. eof
  2785. if test `wc -c <osk.c` -ne 4392
  2786. then
  2787. echo osk.c damaged!
  2788. fi
  2789. fi
  2790.  
  2791. if test -f osk.h -a "$1" != -f
  2792. then
  2793. echo Will not overwrite osk.h
  2794. else
  2795. echo Extracting osk.h
  2796. sed 's/^X//' >osk.h <<\eof
  2797. X/*
  2798. X * OS9 stat : @(#)stat.h    1.2 87/19/12
  2799. X */
  2800. X/* @(#)stat.h    6.1 */
  2801. X/*
  2802. X * Structure of the result of stat
  2803. X */
  2804. X
  2805. X#ifndef CLK_TCK
  2806. X#include <time.h>
  2807. X#endif
  2808. X
  2809. Xstruct    stat
  2810. X{
  2811. X    int    st_dev;
  2812. X    long    st_ino;
  2813. X    unsigned short    st_mode;
  2814. X    unsigned short    st_nlink;
  2815. X    unsigned short    st_uid;
  2816. X    unsigned short    st_gid;
  2817. X    int    st_rdev;
  2818. X    long    st_size;
  2819. X    time_t    st_atime;
  2820. X    time_t    st_mtime;
  2821. X    time_t    st_ctime;
  2822. X};
  2823. eof
  2824. if test `wc -c <osk.h` -ne 377
  2825. then
  2826. echo osk.h damaged!
  2827. fi
  2828. fi
  2829.  
  2830. if test -f date.c -a "$1" != -f
  2831. then
  2832. echo Will not overwrite date.c
  2833. else
  2834. echo Extracting date.c
  2835. sed 's/^X//' >date.c <<\eof
  2836. eof
  2837. if test `wc -c <date.c` -ne 0
  2838. then
  2839. echo date.c damaged!
  2840. fi
  2841. fi
  2842.  
  2843. exit 0
  2844. -------------------------------------------------------------------------------
  2845. Steve Kirkendall     kirkenda@cs.pdx.edu      Grad student at Portland State U.
  2846.