Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v47i140: dmsh - General Purpose UNIX Menu Engine, Part01/01

38 views
Skip to first unread message

Pete Schmitt

unread,
Apr 16, 1995, 3:00:00 AM4/16/95
to
Submitted-by: pe...@coos.dartmouth.edu (Pete Schmitt)
Posting-number: Volume 47, Issue 140
Archive-name: dmsh/part01
Environment: UNIX, curses

dmsh version 0.8 is a curses-based menu generator.

It has the ability to run programs and access additional menu files.
The default menu file is called main.mnu in the current working
directory if a path to a menu file is not given.

It has been run under AIX, A/UX, HP/UX, Linux, OSF1 and Ultrix.

Just type make to make the dmsh binary. There are some example
menu files in the examples subdirectory.

Typing 'make install' will install the binary in /usr/local/bin. If
you want it somewhere else, edit the Makefile prior to the install.

Please contact the author, peter....@dartmouth.edu, with problems,
suggestions or enhancements.
---------------------------------------------------------------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then feed it
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# Contents: dmsh-0.8 dmsh-0.8/Makefile dmsh-0.8/README dmsh-0.8/dmsh.1
# dmsh-0.8/dmsh.ps dmsh-0.8/examples dmsh-0.8/examples/main.mnu
# dmsh-0.8/examples/sub1.mnu dmsh-0.8/examples/sub2.mnu
# dmsh-0.8/main.c dmsh-0.8/menu.c dmsh-0.8/menu.h dmsh-0.8/misc.c
# Wrapped by kent@ftp on Sun Apr 16 18:03:11 1995
PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 1 (of 1)."'
if test ! -d 'dmsh-0.8' ; then
echo shar: Creating directory \"'dmsh-0.8'\"
mkdir 'dmsh-0.8'
fi
if test -f 'dmsh-0.8/Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/Makefile'\"
else
echo shar: Extracting \"'dmsh-0.8/Makefile'\" \(585 characters\)
sed "s/^X//" >'dmsh-0.8/Makefile' <<'END_OF_FILE'
X#
X# Makefile for the Dartmouth Menu Shell (dmsh)
X#
X
XCC = cc
XCFLAGS = -O
XLIBS = -lcurses -ltermcap
X
XBINDEST = /usr/local/bin
XINSTALL = install
X
XHDRS = menu.h
X
XOBJ = main.o menu.o misc.o
X
XSRCS = main.c menu.c misc.c
X
Xdmsh: $(OBJ)
X $(CC) $(CFLAGS) $(OBJ) $(LIBS) -o dmsh
X
Xall: dmsh
X
Xclean:; rm -f $(OBJ) core dmsh
X
Xindex:; ctags -wx $(HDRS) $(SRCS)
X
Xinstall: dmsh
X $(INSTALL) -m 755 dmsh $(BINDEST)
X
Xlpr: $(HDRS) $(SRCS)
X lpr -p $(HDRS) $(SRCS)
X
Xtags: $(HDRS) $(SRCS); ctags $(HDRS) $(SRCS)
X
Xlint: $(SRCS)
X lint $(SRCS)
END_OF_FILE
if test 585 -ne `wc -c <'dmsh-0.8/Makefile'`; then
echo shar: \"'dmsh-0.8/Makefile'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/Makefile'
fi
if test -f 'dmsh-0.8/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/README'\"
else
echo shar: Extracting \"'dmsh-0.8/README'\" \(643 characters\)
sed "s/^X//" >'dmsh-0.8/README' <<'END_OF_FILE'
Xdmsh version 0.8 is a curses-based menu generator.
XIt has the ability to run programs and access additional menu files.
XThe default menu file is called main.mnu in the current working
Xdirectory if a path to a menu file is not given.
X
XIt has been run under AIX, A/UX, HP/UX, Linux, OSF1 and Ultrix.
X
XJust type make to make the dmsh binary. There are some example
Xmenu files in the examples subdirectory.
X
XTyping 'make install' will install the binary in /usr/local/bin. If
Xyou want it somewhere else, edit the Makefile prior to the install.
X
XPlease contact the author, peter....@dartmouth.edu, with problems,
Xsuggestions or enhancements.
END_OF_FILE
if test 643 -ne `wc -c <'dmsh-0.8/README'`; then
echo shar: \"'dmsh-0.8/README'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/README'
fi
if test -f 'dmsh-0.8/dmsh.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/dmsh.1'\"
else
echo shar: Extracting \"'dmsh-0.8/dmsh.1'\" \(3040 characters\)
sed "s/^X//" >'dmsh-0.8/dmsh.1' <<'END_OF_FILE'
X.TH dmsh 1 "March 14, 1995" "Dartmouth College" "MENU"
X.AT 3
X.SH NAME
X.B dmsh
X\- Dartmouth Menu Shell
X.SH SYNTAX
X.B dmsh <menu/file/path>
X.SH PROGRAM DESCRIPTION
X\fBdmsh\fR is a curses-based menu generator.
XIt has the ability to run programs and access additional menu files.
XThe default menu file is called \fBmain.mnu\fR in the current working
Xdirectory if a path to a menu file is not given.
X.SH MENU FILE DESCRIPTION
XSome examples of menu files are given in the \fBexamples\fR subdirectory
Xin the source directory. Below is the contents of \fBexamples/main.mnu\fR
X.nf
X\fC
XMain Menu:T:noop
XInternet Tools:M:sub1.mnu
XToday's Date:p:clear;date
XWho's On:p:clear;finger|sort
XCompile a Program:*:noop
XShell:N:clear;echo "Type exit to return";PS1='$ ';export PS1;$SHELL
XDirectory Listing:p:clear;ls -lA
X\fI<this empty line will show as dashes>
X
X.fi
X.SS Fields
X\fRThe 3 fields in a menu file are delimited by the colon character.
XThe 1st field is the description that will show up as a menu selection.
X.sp
XThe 2nd field is a one character field that is either a 'P', 'N', 'M' or '*'.
XThe 2nd field is case-sensitive.
XAny other characters in that field will be ignored but the description
Xwill still show up.
XIf the 2nd field is an '*', the the string
X``(unavailable)'' will be appended to the description.
X.sp
XThe 3rd field is an executable program or script
Xto be run if the 2nd field is a 'P' or 'N'. \fIThe difference between
X'P' and 'N' is that for former will cause the program to pause and ask
Xfor a [RETURN] to be pressed prior to re-displaying the menu. The
Xlater will not pause, meaning that when the selected program is
Xfinished running the menu is re-displayed without a pause.\fR
XThe program can be a series of commands, shell assignments and programs
Xdelimited by the semi-colon. The 3rd field is a menu file (submenu)
Xif the 2nd field is an 'M'. Also the string ``(menu)'' will be appended
Xto the description.
X.SS Records
XThe first record in the menu file is reserved for the title of the menu.
XAlthough the other two fields aren't used, they still need something in
Xthem in this version of the program.
XIf a record is empty the program will put a series of dashes in that
Xposition. This make a nice divider for menu groups.
X.SS Selections
XEach selection is given a letter starting with [a].
XThe [q] selection is generated by the program, not the menu file.
XIf the current menu is the top-level menu the the description for
X[q] will be \fBQuit\fR. If the current menu is a submenu, [q] will
Xdisplay \fBReturn to previous menu\fR.
X.bp
X.SH MENU FILE DISPLAY
X\fRIf the program is invoked with the above file as the argument, the display
Xappears as follows:
X.nf
X\fB
X Dartmouth Menu Shell, version: 0.8 Tue Mar 31 15:50:09 1995
X
X Main Menu
X\fR
X [a] Internet Tools (menu)
X [b] Today's Date
X [c] Who's On
X [d] Compile a Program (unavailable)
X [e] Shell
X [f] Directory Listing
X ---------------
X [q] Quit
X
X Select Value:
X
X\fB
X MESSAGES: Enter a letter or [q] to quit
X.fi
X
X\fR
END_OF_FILE
if test 3040 -ne `wc -c <'dmsh-0.8/dmsh.1'`; then
echo shar: \"'dmsh-0.8/dmsh.1'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/dmsh.1'
fi
if test -f 'dmsh-0.8/dmsh.ps' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/dmsh.ps'\"
else
echo shar: Extracting \"'dmsh-0.8/dmsh.ps'\" \(10800 characters\)
sed "s/^X//" >'dmsh-0.8/dmsh.ps' <<'END_OF_FILE'
X%!PS-Adobe-3.0
X%%Creator: groff version 1.09
X%%CreationDate: Fri Mar 31 06:09:35 1995
X%%DocumentNeededResources: font Times-Roman
X%%+ font Times-Bold
X%%+ font Courier
X%%+ font Times-Italic
X%%DocumentSuppliedResources: procset grops 1.09 0
X%%Pages: 2
X%%PageOrder: Ascend
X%%Orientation: Portrait
X%%EndComments
X%%BeginProlog
X%%BeginResource: procset grops 1.09 0
X/setpacking where{
Xpop
Xcurrentpacking
Xtrue setpacking
X}if
X/grops 120 dict dup begin
X/SC 32 def
X/A/show load def
X/B{0 SC 3 -1 roll widthshow}bind def
X/C{0 exch ashow}bind def
X/D{0 exch 0 SC 5 2 roll awidthshow}bind def
X/E{0 rmoveto show}bind def
X/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
X/G{0 rmoveto 0 exch ashow}bind def
X/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
X/I{0 exch rmoveto show}bind def
X/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
X/K{0 exch rmoveto 0 exch ashow}bind def
X/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
X/M{rmoveto show}bind def
X/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
X/O{rmoveto 0 exch ashow}bind def
X/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
X/Q{moveto show}bind def
X/R{moveto 0 SC 3 -1 roll widthshow}bind def
X/S{moveto 0 exch ashow}bind def
X/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
X/SF{
Xfindfont exch
X[exch dup 0 exch 0 exch neg 0 0]makefont
Xdup setfont
X[exch/setfont cvx]cvx bind def
X}bind def
X/MF{
Xfindfont
X[5 2 roll
X0 3 1 roll
Xneg 0 0]makefont
Xdup setfont
X[exch/setfont cvx]cvx bind def
X}bind def
X/level0 0 def
X/RES 0 def
X/PL 0 def
X/LS 0 def
X/PLG{
Xgsave newpath clippath pathbbox grestore
Xexch pop add exch pop
X}bind def
X/BP{
X/level0 save def
X1 setlinecap
X1 setlinejoin
X72 RES div dup scale
XLS{
X90 rotate
X}{
X0 PL translate
X}ifelse
X1 -1 scale
X}bind def
X/EP{
Xlevel0 restore
Xshowpage
X}bind def
X/DA{
Xnewpath arcn stroke
X}bind def
X/SN{
Xtransform
X.25 sub exch .25 sub exch
Xround .25 add exch round .25 add exch
Xitransform
X}bind def
X/DL{
XSN
Xmoveto
XSN
Xlineto stroke
X}bind def
X/DC{
Xnewpath 0 360 arc closepath
X}bind def
X/TM matrix def
X/DE{
XTM currentmatrix pop
Xtranslate scale newpath 0 0 .5 0 360 arc closepath
XTM setmatrix
X}bind def
X/RC/rcurveto load def
X/RL/rlineto load def
X/ST/stroke load def
X/MT/moveto load def
X/CL/closepath load def
X/FL{
Xcurrentgray exch setgray fill setgray
X}bind def
X/BL/fill load def
X/LW/setlinewidth load def
X/RE{
Xfindfont
Xdup maxlength 1 index/FontName known not{1 add}if dict begin
X{
X1 index/FID ne{def}{pop pop}ifelse
X}forall
X/Encoding exch def
Xdup/FontName exch def
Xcurrentdict end definefont pop
X}bind def
X/DEFS 0 def
X/EBEGIN{
Xmoveto
XDEFS begin
X}bind def
X/EEND/end load def
X/CNT 0 def
X/level1 0 def
X/PBEGIN{
X/level1 save def
Xtranslate
Xdiv 3 1 roll div exch scale
Xneg exch neg exch translate
X0 setgray
X0 setlinecap
X1 setlinewidth
X0 setlinejoin
X10 setmiterlimit
X[]0 setdash
X/setstrokeadjust where{
Xpop
Xfalse setstrokeadjust
X}if
X/setoverprint where{
Xpop
Xfalse setoverprint
X}if
Xnewpath
X/CNT countdictstack def
Xuserdict begin
X/showpage{}def
X}bind def
X/PEND{
Xclear
Xcountdictstack CNT sub{end}repeat
Xlevel1 restore
X}bind def
Xend def
X/setpacking where{
Xpop
Xsetpacking
X}if
X%%EndResource
X%%IncludeResource: font Times-Roman
X%%IncludeResource: font Times-Bold
X%%IncludeResource: font Courier
X%%IncludeResource: font Times-Italic
Xgrops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
Xdef/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
X/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
X/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
X/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
X/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
X/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
X/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
X/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
X/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
X/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
X/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
X/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
X/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
X/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
X/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
X/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
X/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
X/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
X/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
X/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
X/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
X/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
X/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
X/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
X/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
X/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
X/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
X/Times-Italic@0 ENC0/Times-Italic RE/Courier@0 ENC0/Courier RE
X/Times-Bold@0 ENC0/Times-Bold RE/Times-Roman@0 ENC0/Times-Roman RE
X%%EndProlog
X%%Page: 1 1
X%%BeginPageSetup
XBP
X%%EndPageSetup
X/F0 10/Times-Roman@0 SF 183.45(dmsh\(1\) MENU dmsh\(1\))72 48 R/F1 9
X/Times-Bold@0 SF -.18(NA)72 84 S(ME).18 E/F2 10/Times-Bold@0 SF(dmsh)108
X96 Q F0 2.5<ad44>2.5 G(artmouth Menu Shell)-2.5 E F1(SYNT)72 112.8 Q(AX)
X-.81 E F2(dmsh <menu/\214le/path>)108 124.8 Q F1(PR)72 141.6 Q
X(OGRAM DESCRIPTION)-.27 E F2(dmsh)108 153.6 Q F0 .122
X(is a curses-based menu generator)2.622 F 5.121(.I)-.55 G 2.621(th)
X-5.121 G .121
X(as the ability to run programs and access additional menu \214les.)
X-2.621 F .876(The def)108 165.6 R .876(ault menu \214le is called)-.1 F
XF2(main.mnu)3.376 E F0 .876(in the current w)3.376 F .876
X(orking directory if a path to a menu \214le is not)-.1 F(gi)108 177.6 Q
X-.15(ve)-.25 G(n.).15 E F1(MENU FILE DESCRIPTION)72 194.4 Q F0 .419
X(Some e)108 206.4 R .419(xamples of menu \214les are gi)-.15 F -.15(ve)
X-.25 G 2.919(ni).15 G 2.919(nt)-2.919 G(he)-2.919 E F2(examples)2.919 E
XF0 .419(subdirectory in the source directory)2.919 F 5.418(.B)-.65 G
X(elo)-5.418 E 2.918(wi)-.25 G 2.918(st)-2.918 G(he)-2.918 E(contents of)
X108 218.4 Q F2(examples/main.mnu)2.5 E/F3 10/Courier@0 SF
X(Main Menu:T:noop)108 242.4 Q(Internet Tools:M:sub1.mnu)108 254.4 Q
X(Today's Date:p:clear;date)108 266.4 Q(Who's On:p:clear;finger|sort)108
X278.4 Q(Compile a Program:*:noop)108 290.4 Q
X(Shell:N:clear;echo "Type exit to return";PS1='$ ';export PS1;$SHELL)108
X302.4 Q(Directory Listing:p:clear;ls -lA)108 314.4 Q/F4 10
X/Times-Italic@0 SF(<this empty line will show as dashes>)108 326.4 Q F2
X(Fields)87 355.2 Q F0 .907
X(The 3 \214elds in a menu \214le are delimited by the colon character)
X108 367.2 R 5.908(.T)-.55 G .908
X(he 1st \214eld is the description that will)-5.908 F(sho)108 379.2 Q
X2.5(wu)-.25 G 2.5(pa)-2.5 G 2.5(sam)-2.5 G(enu selection.)-2.5 E .859(T\
Xhe 2nd \214eld is a one character \214eld that is either a 'P', 'N', 'M\
X' or '*'.)108 403.2 R .859(The 2nd \214eld is case-sensiti)5.859 F -.15
X(ve)-.25 G(.).15 E(An)108 415.2 Q 2.585(yo)-.15 G .085
X(ther characters in that \214eld will be ignored b)-2.585 F .086
X(ut the description will still sho)-.2 F 2.586(wu)-.25 G 2.586(p. If)
X-2.586 F .086(the 2nd \214eld is an)2.586 F('*', the the string `)108
X427.2 Q(`\(una)-.74 E -.25(va)-.2 G(ilable\)').25 E 2.5('w)-.74 G
X(ill be appended to the description.)-2.5 E .941
X(The 3rd \214eld is an e)108 451.2 R -.15(xe)-.15 G .941(cutable progra\
Xm or script to be run if the 2nd \214eld is a 'P' or 'N'.).15 F F4 .94
X(The dif)5.94 F(fer)-.18 E(ence)-.37 E .298
X(between for a [RETURN] to be pr)108 463.2 R .298(essed prior to r)-.37
XF .298(e-displaying the menu.)-.37 F .299(The later will not pause)5.298
XF 2.799(,m)-.1 G(eaning)-2.799 E .273(that when the selected pr)108
X475.2 R -.1(og)-.45 G -.15(ra).1 G 2.773(mi).15 G 2.773<738c>-2.773 G
X.272(nished running the menu is r)-2.773 F .272
X(e-displayed without a pause)-.37 F(.)-.15 E F0 .272(The program)5.272 F
X.268(can be a series of commands, shell assignments and programs delimi\
Xted by the semi-colon. The 3rd \214eld is)108 487.2 R 2.719(am)108 499.2
XS .219
X(enu \214le \(submenu\) if the 2nd \214eld is an 'M'. Also the string `)
X-2.719 F(`\(menu\)')-.74 E 2.719('w)-.74 G .219
X(ill be appended to the descrip-)-2.719 F(tion.)108 511.2 Q F2(Records)
X87 528 Q F0 .624(The \214rst record in the menu \214le is reserv)108 540
XR .625(ed for the title of the menu.)-.15 F .625(Although the other tw)
X5.625 F 3.125<6f8c>-.1 G .625(elds aren')-3.125 F(t)-.18 E .943
X(used, the)108 552 R 3.443(ys)-.15 G .942
X(till need something in them in this v)-3.443 F .942
X(ersion of the program.)-.15 F .942(If a record is empty the program)
X5.942 F(will put a series of dashes in that position.)108 564 Q
X(This mak)5 E 2.5(ean)-.1 G(ice di)-2.5 E(vider for menu groups.)-.25 E
XF2(Selections)87 580.8 Q F0 1.233(Each selection is gi)108 592.8 R -.15
X(ve)-.25 G 3.733(nal).15 G 1.233(etter starting with [a].)-3.733 F 1.234
X(The [q] selection is generated by the program, not the)6.233 F .499
X(menu \214le.)108 604.8 R .499(If the current menu is the top-le)5.499 F
X-.15(ve)-.25 G 2.999(lm).15 G .498
X(enu the the description for [q] will be)-2.999 F F2(Quit)2.998 E F0
X2.998(.I)C 2.998(ft)-2.998 G .498(he current)-2.998 F
X(menu is a submenu, [q] will display)108 616.8 Q F2(Retur)2.5 E 2.5(nt)
X-.15 G 2.5(op)-2.5 G -2.29 -.18(re v)-2.5 H(ious menu).18 E F0(.)A
X(Dartmouth Colle)72 768 Q 122.91(ge March)-.15 F(14, 1995)2.5 E(1)197.2
XE EP
X%%Page: 2 2
X%%BeginPageSetup
XBP
X%%EndPageSetup
X/F0 10/Times-Roman@0 SF 183.45(dmsh\(1\) MENU dmsh\(1\))72 48 R/F1 9
X/Times-Bold@0 SF(MENU FILE DISPLA)72 84 Q(Y)-.9 E F0
X(If the program is in)108 96 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(dw).1 G
X(ith the abo)-2.5 E .3 -.15(ve \214)-.15 H(le as the ar).15 E
X(gument, the display appears as follo)-.18 E(ws:)-.25 E/F2 10
X/Times-Bold@0 SF(Dartmouth Menu Shell, v)115.5 120 Q(ersion: 0.8)-.1 E
X-.92(Tu)7.5 G 2.5(eM).92 G(ar 31 15:50:09 1995)-2.5 E(Main Menu)128 144
XQ F0 2.5([a] Internet)118 168 R -.8(To)2.5 G(ols \(menu\)).8 E 2.5
X([b] T)118 180 R(oday')-.8 E 2.5(sD)-.55 G(ate)-2.5 E 2.5([c] Who')118
X192 R 2.5(sO)-.55 G(n)-2.5 E 2.5([d] Compile)118 204 R 2.5(aP)2.5 G
X(rogram \(una)-2.5 E -.25(va)-.2 G(ilable\)).25 E 2.5([e] Shell)118 216
XR 2.5([f] Directory)118 228 R(Listing)2.5 E(---------------)120.5 240 Q
X2.5([q] Quit)118 252 R(Select V)113 276 Q(alue:)-1.11 E F2(MESSA)110.5
X312 Q 5(GES: Enter)-.55 F 2.5(al)2.5 G(etter or [q] to quit)-2.5 E F0
X(Dartmouth Colle)72 768 Q 122.91(ge March)-.15 F(14, 1995)2.5 E(2)197.2
XE EP
X%%Trailer
Xend
X%%EOF
END_OF_FILE
if test 10800 -ne `wc -c <'dmsh-0.8/dmsh.ps'`; then
echo shar: \"'dmsh-0.8/dmsh.ps'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/dmsh.ps'
fi
if test ! -d 'dmsh-0.8/examples' ; then
echo shar: Creating directory \"'dmsh-0.8/examples'\"
mkdir 'dmsh-0.8/examples'
fi
if test -f 'dmsh-0.8/examples/main.mnu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/examples/main.mnu'\"
else
echo shar: Extracting \"'dmsh-0.8/examples/main.mnu'\" \(246 characters\)
sed "s/^X//" >'dmsh-0.8/examples/main.mnu' <<'END_OF_FILE'
XMain Menu:T:noop
XInternet Tools:M:sub1.mnu
XToday's Date:p:clear;date
XWho's On:p:clear;finger|sort|more
XCompile a Program:*:noop
XShell:N:clear;echo "Type exit to return to menu";sleep 2;PS1='$ ';export PS1;$SHELL
XDirectory Listing:p:clear;ls -lA
X
END_OF_FILE
if test 246 -ne `wc -c <'dmsh-0.8/examples/main.mnu'`; then
echo shar: \"'dmsh-0.8/examples/main.mnu'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/examples/main.mnu'
fi
if test -f 'dmsh-0.8/examples/sub1.mnu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/examples/sub1.mnu'\"
else
echo shar: Extracting \"'dmsh-0.8/examples/sub1.mnu'\" \(141 characters\)
sed "s/^X//" >'dmsh-0.8/examples/sub1.mnu' <<'END_OF_FILE'
XInternet Tools:T:noop
XElectronic Mail:N:pine
XUseNet News:N:tin -r
XGopher:N:gopher gopher.dartmouth.edu
XWWW (lynx):N:lynx
XEditors:m:sub2.mnu
X
END_OF_FILE
if test 141 -ne `wc -c <'dmsh-0.8/examples/sub1.mnu'`; then
echo shar: \"'dmsh-0.8/examples/sub1.mnu'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/examples/sub1.mnu'
fi
if test -f 'dmsh-0.8/examples/sub2.mnu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/examples/sub2.mnu'\"
else
echo shar: Extracting \"'dmsh-0.8/examples/sub2.mnu'\" \(63 characters\)
sed "s/^X//" >'dmsh-0.8/examples/sub2.mnu' <<'END_OF_FILE'
XEditors:T:noop
XEmacs:N:emacs -nw
XPico:N:pico
XVi:N:vi
XJoe:N:joe
END_OF_FILE
if test 63 -ne `wc -c <'dmsh-0.8/examples/sub2.mnu'`; then
echo shar: \"'dmsh-0.8/examples/sub2.mnu'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/examples/sub2.mnu'
fi
if test -f 'dmsh-0.8/main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/main.c'\"
else
echo shar: Extracting \"'dmsh-0.8/main.c'\" \(2786 characters\)
sed "s/^X//" >'dmsh-0.8/main.c' <<'END_OF_FILE'
X/**********************************************************************
X
X Copyright (c) 1995 by the Trustees of Dartmouth College.
X
X Permission to use, copy, modify and distribute these programs and
X their documentation for any purpose and without fee is hereby
X granted, provided that this copyright notice and permission ap-
X pear on all copies and supporting documentation. The name of the
X Trustees of Dartmouth College may not be used in advertising or
X publicity relating to distribution of these programs without
X specific prior permission. Neither the Trustees of Dartmouth
X College nor the author make representations about the suitability
X of this software for any purpose. It is provided "as is" without
X expressed or implied warranty.
X
X************************************************************************/
X
X#include "menu.h"
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int die();
X char menufile[MAXLINE];
X/*
X chdir(WORKDIR);
X openlog("admin",LOG_PID,LOG_LOCAL0);
X syslog(LOG_INFO,"MENU version %s Login Starting",VERSION);
X*/
X signal(SIGINT, (void *)die);
X
X if (argc < 2)
X strcpy(menufile,"main.mnu");
X else
X strcpy(menufile,argv[1]);
X
X initscr();
X initinput();
X wrap(menufile);
X die();
X}
X/******************************************************************************
X * INITINPUT - Set up curses
X *****************************************************************************/
Xinitinput()
X{
X raw();
X echo();
X nonl();
X}
X/******************************************************************************
X * DIE - This function is where to end entire program
X *****************************************************************************/
Xdie()
X{
X FILE *fp;
X signal(SIGINT, SIG_IGN);
X mvcur(0, COLS-1, LINES-1, 0);
X endwin();
X exit(0);
X}
X/******************************************************************************
X * WRAP - This wraps up the whole program.
X *****************************************************************************/
Xwrap(menufile)
Xchar menufile[];
X{
X intro(VERSION);
X menu(menufile);
X return;
X}
X/******************************************************************************
X * INTRO - This prints the program name, version and current time at the top
X * of the display.
X *****************************************************************************/
Xintro(version)
Xchar version[];
X{
X int x1, x2, y;
X char *tp, *get_time();
X
X /* box(stdscr, ' ', '='); */
X move(1,2);
X standout();
X addstr(" Dartmouth Menu Shell, version: ");
X getyx(stdscr, y, x1);
X printw("%s", version);
X getyx(stdscr, y, x2);
X while (x2++ - x1 < 6)
X addch(' ');
X tp = (char *)get_time();
X stripcrlf(tp);
X addstr(tp);
X addstr(" ");
X standend();
X move(MESSAGE,1);
X addstr("MESSAGES:");
X clrtobot();
X move(0,0);
X refresh();
X}
END_OF_FILE
if test 2786 -ne `wc -c <'dmsh-0.8/main.c'`; then
echo shar: \"'dmsh-0.8/main.c'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/main.c'
fi
if test -f 'dmsh-0.8/menu.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/menu.c'\"
else
echo shar: Extracting \"'dmsh-0.8/menu.c'\" \(4396 characters\)
sed "s/^X//" >'dmsh-0.8/menu.c' <<'END_OF_FILE'
X/**********************************************************************
X
X Copyright (c) 1995 by the Trustees of Dartmouth College.
X
X Permission to use, copy, modify and distribute these programs and
X their documentation for any purpose and without fee is hereby
X granted, provided that this copyright notice and permission ap-
X pear on all copies and supporting documentation. The name of the
X Trustees of Dartmouth College may not be used in advertising or
X publicity relating to distribution of these programs without
X specific prior permission. Neither the Trustees of Dartmouth
X College nor the author make representations about the suitability
X of this software for any purpose. It is provided "as is" without
X expressed or implied warranty.
X
X************************************************************************/
X#include "menu.h"
X/*****************************************************************************/
Xmenu(file)
Xchar file[];
X{
X FILE *menufd;
X MENU *item;
X int recnum = 0, i;
X char line[MAXLINE];
X void parse(), display(), runprog();
X static int stat = 0; /* used to determine which is top menu */
X int select();
X
X stat++;
X /* open the menu file if it exists */
X if ((menufd = fopen(file,"r")) == NULL)
X {
X sprintf(command,"Unable to open menu %s",file);
X prtmsg(command,0);
X sleep(2);
X return;
X }
X
X /* count number of records in the menu file */
X while(fgetline(menufd,line,MAXLINE) != 0)
X recnum++;
X rewind(menufd);
X
X /* get enough memory to hold file dynamically */
X item = (MENU *)malloc(recnum*sizeof(MENU));
X
X for(i = 0; i < recnum; i++) /* read file into malloc'd memory */
X {
X fgetline(menufd,line,MAXLINE);
X stripcrlf(line);
X parse(line,item+i); /* parse the fields into structure */
X }
X
X do
X {
X display(item,recnum,stat);
X }
X while(select(item,recnum));
X free(item);
X stat--;
X return;
X}
X/*****************************************************************************/
Xvoid
Xparse(line, item)
Xchar line[];
XMENU *item;
X{
X char *loc;
X
X if((loc = strchr(line,':')) == NULL)
X {
X strcpy(item->desc,"---------------");
X item->todo = 'E';
X strcpy(item->object,"");
X return;
X }
X
X *loc = '\0';
X strcpy(item->desc,line); /* get first string field */
X ++loc;
X item->todo = *loc; /* get second char field */
X loc += 2;
X strcpy(item->object,loc); /* get third string field */
X}
X/*****************************************************************************/
Xvoid
Xdisplay(item,num,stat)
XMENU *item;
Xint num;
Xint stat;
X{
X int i;
X
X clrworkarea();
X move(3,4);standout();
X printw(" %s ",item->desc); /* menu title */
X standend();
X
X for(i = 1; i < num; i++)
X {
X move(i+4,4);
X if((item+i)->todo == '*')
X printw("[%c] %s (unavailable)",i+0140,(item+i)->desc);
X else if((item+i)->todo == 'M' || (item+i)->todo == 'm')
X printw("[%c] %s (menu)",i+0140,(item+i)->desc);
X else if((item+i)->todo == 'E')
X printw(" %s ","--------------");
X else
X printw("[%c] %s",i+0140,(item+i)->desc);
X }
X if (stat == 1)
X {
X mvaddstr(i+4,4, "[q] Quit");
X prtmsg("Enter a letter or [q] to quit",0);
X }
X else
X {
X mvaddstr(i+4,4, "[q] Return to previous menu");
X prtmsg("Enter a letter or [q] to return",0);
X }
X mvaddstr(i+6,2, "Select Value: ");
X move(i+6,16);
X refresh();
X}
X/*****************************************************************************/
Xint
Xselect(item,num)
XMENU *item;
Xint num;
X{
X int c,i;
X c = getch();
X
X i = c - 0140; /* turn ascii into number */
X if(i >= 1 && i < num)
X {
X switch((item+i)->todo)
X {
X case 'M':
X case 'm':
X menu((item+i)->object);
X break;
X case 'N':
X case 'n':
X runprog((item+i)->object,0);
X break;
X case 'P':
X case 'p':
X runprog((item+i)->object,1);
X break;
X }
X }
X else if (c == 'q' || c == 'Q')
X return 0;
X else
X {
X prtmsg("Invalid Entry, try again!",0);
X sleep(2);
X clrmsg(0);
X }
X return 1;
X}
X/*****************************************************************************/
Xvoid
Xrunprog(program, pause)
Xchar program[];
Xint pause;
X{
X int c;
X
X clear();
X refresh();
X move(1,1);
X endwin(); /* kill curses */
X
X system(program); /* run the program */
X
X if(pause)
X {
X printf("\n\nPress [RETURN] to continue: ");
X c = getchar();
X }
X
X initscr(); /* restart curses */
X intro(VERSION);
X initinput();
X}
X/*****************************************************************************/
END_OF_FILE
if test 4396 -ne `wc -c <'dmsh-0.8/menu.c'`; then
echo shar: \"'dmsh-0.8/menu.c'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/menu.c'
fi
if test -f 'dmsh-0.8/menu.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/menu.h'\"
else
echo shar: Extracting \"'dmsh-0.8/menu.h'\" \(453 characters\)
sed "s/^X//" >'dmsh-0.8/menu.h' <<'END_OF_FILE'
X#include <stdio.h>
X#include <strings.h>
X#include <ctype.h>
X#include <curses.h>
X#include <signal.h>
X#include <sys/file.h>
X#include <sys/time.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <syslog.h>
X#include <errno.h>
X#include <stdlib.h>
X#include <malloc.h>
X
X#define MAXLINE 250
X#define VERSION "0.8"
X#define MESSAGE 19
X
Xchar *get_time(), *tp;
Xchar command[MAXLINE];
X
Xtypedef struct menu
X{
X char desc[50];
X char todo;
X char object[256];
X}MENU;
END_OF_FILE
if test 453 -ne `wc -c <'dmsh-0.8/menu.h'`; then
echo shar: \"'dmsh-0.8/menu.h'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/menu.h'
fi
if test -f 'dmsh-0.8/misc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dmsh-0.8/misc.c'\"
else
echo shar: Extracting \"'dmsh-0.8/misc.c'\" \(5512 characters\)
sed "s/^X//" >'dmsh-0.8/misc.c' <<'END_OF_FILE'
X/**********************************************************************
X
X Copyright (c) 1995 by the Trustees of Dartmouth College.
X
X Permission to use, copy, modify and distribute these programs and
X their documentation for any purpose and without fee is hereby
X granted, provided that this copyright notice and permission ap-
X pear on all copies and supporting documentation. The name of the
X Trustees of Dartmouth College may not be used in advertising or
X publicity relating to distribution of these programs without
X specific prior permission. Neither the Trustees of Dartmouth
X College nor the author make representations about the suitability
X of this software for any purpose. It is provided "as is" without
X expressed or implied warranty.
X
X************************************************************************/
X#include "menu.h"
X/******************************************************************************
X * CLRMSG - This clears the message line selected
X *****************************************************************************/
Xclrmsg(offset)
X{
X move(MESSAGE+offset,10);
X clrtoeol();
X move(0,0);
X refresh();
X}
X/******************************************************************************
X * CLRWORKAREA - This clears the window between line 3 and MESSAGE line.
X *****************************************************************************/
Xclrworkarea()
X{
X int i;
X
X for(i = 3; i < MESSAGE; i++)
X {
X move(i,0);
X clrtoeol();
X }
X refresh();
X}
Xxclrworkarea()
X{
X int i;
X
X for(i = 3; i < MESSAGE; i++)
X {
X move(i,5);
X clrtoeol();
X }
X}
X/******************************************************************************
X * PRTMSG - This will print highlighted messages from the MESSAGE line on down.
X * The offset argument determines which line from the MESSAGE line to
X * print the message.
X *****************************************************************************/
Xprtmsg(message,offset)
Xchar *message;
Xint offset;
X{
X clrmsg(offset);
X move(MESSAGE+offset,12);
X standout();
X printw(" %s ",message);
X standend();
X fflush(stdout);
X refresh();
X return;
X}
X/******************************************************************************
X * GET_TIME - returns today's date and time followed by a '\n'
X *****************************************************************************/
Xchar *
Xget_time()
X{
X extern char *ctime();
X static double Tstart;
X static struct timeval start;
X
X
X (void) gettimeofday(&start, (struct timezone *)NULL);
X Tstart = (double) start.tv_sec + ((double)start.tv_usec)/1000000.0;
X return(ctime(&start.tv_sec));
X}
X/******************************************************************************
X * GET_INPUT - This routine takes string input in curses and allows for
X * backspaces that are interpreted correctly
X *****************************************************************************/
Xget_input(string)
Xchar string[];
X{
X char c;
X int i = 0, y, x, Y, X;
X
X noecho();
X getyx(stdscr,Y,X);
X while((c = getch()) != '\r')
X {
X if (c == '\010' || c == '\177')
X {
X i -= 1;
X if (i < 0)
X {
X i = 0;
X move(Y,X);
X }
X else
X {
X getyx(stdscr,y,x);
X move(y,x-1);
X delch();
X }
X refresh();
X }
X else
X {
X addch(c);
X refresh();
X string[i++] = c;
X }
X }
X string[i] = '\0';
X return;
X}
X/******************************************************************************
X * STRIPCRLF - Strip CR-LF from inputted strings here.
X *****************************************************************************/
Xvoid
Xstripcrlf(s)
Xchar s[];
X{
X char *cp;
X
X cp = s + strlen(s) - 1;
X while (cp >= s && (*cp == '\n' || *cp == '\r'))
X *cp-- = '\0';
X return;
X}
X/******************************************************************************
X * FGETLINE - to get a line of text from stdin
X * borrowed from page 118 of "C! Programming and Practices"
X * by M.Tim Grady who borrowed it from the K&R white book
X *
X * 6/27/90: Added file i/o instead of just stdin and
X * renamed from getline to fgetline
X *****************************************************************************/
Xint fgetline(fd, s, lim)
XFILE *fd;
Xchar s[];
Xint lim;
X{
X int c = 0, i = 0;
X
X while (--lim > 0 && (c=fgetc(fd)) != EOF && c != '\n')
X s[i++] = c;
X
X if (c == '\n')
X s[i++] = c;
X
X s[i] = '\0';
X
X return(i);
X}
X/******************************************************************************
X * GET_HIDDEN - This routine takes string input in curses and allows for
X * backspaces that are interpreted correctly.
X * All input is hidden and '*' are output instead.
X *****************************************************************************/
Xget_hidden(string)
Xchar string[];
X{
X int c;
X int i = 0, y, x, Y, X;
X
X noecho();
X getyx(stdscr,Y,X);
X while((c = getch()) != '\r')
X {
X if (c == '\010' || c == '\177')
X {
X i -= 1;
X if (i < 0)
X {
X i = 0;
X move(Y,X);
X }
X else
X {
X getyx(stdscr,y,x);
X move(y,x-1);
X echo();
X delch();
X noecho();
X }
X refresh();
X }
X else
X {
X addch('*');
X refresh();
X string[i++] = c;
X }
X }
X string[i] = '\0';
X echo();
X return;
X}
X
END_OF_FILE
if test 5512 -ne `wc -c <'dmsh-0.8/misc.c'`; then
echo shar: \"'dmsh-0.8/misc.c'\" unpacked with wrong size!
fi
# end of 'dmsh-0.8/misc.c'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have the archive.
rm -f ark[1-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...

0 new messages