home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume38 / menushll / part01 < prev    next >
Encoding:
Text File  |  1993-07-30  |  60.7 KB  |  2,301 lines

  1. Newsgroups: comp.sources.misc
  2. From: aburt@du.edu (Andrew Burt)
  3. Subject: v38i066:  menushell - A Unix Menuing Shell, Part01/03
  4. Message-ID: <csm-v38i066=menushell.142311@sparky.Sterling.COM>
  5. X-Md4-Signature: cb60de66a2f7124280c392ce76691a21
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 30 Jul 1993 19:23:39 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: aburt@du.edu (Andrew Burt)
  12. Posting-number: Volume 38, Issue 66
  13. Archive-name: menushell/part01
  14. Environment: BSD, with untested SVR4 diffs
  15.  
  16. This is the net release of Mshell, a Unix menuing shell.  Mshell was designed
  17. to be easy for users to use and easy for admins to write menus for; menus
  18. can be in any format and can execute any code your shell can.  For example,
  19. a simple menu file would be:
  20.  
  21.     who    Who's on the system        l    list your files
  22.     <1>    Send e-mail            <2>    Games menu
  23.     *****
  24.     who    who | sort
  25.     l    ls -l | more
  26.     1    mail prompt=To_whom help=/how/to/send/mail
  27.     2    menu games
  28.  
  29. Users see the top part, key in the choice, which runs the code at the bottom.
  30. Top part is shown to users verbatim, bottom part has lots of flexibility
  31. in forming command lines and specifying help/man files.
  32.  
  33. This program is released "as is", but remains owned by myself and the
  34. University of Denver.  You're welcome to use mshell, and I'd like to
  35. hear about any bugs, and get copies of improvements, but neither I nor
  36. DU support this software.  I'm only releasing it since so many folks
  37. have asked for a copy.
  38.  
  39. Mshell was written to shield Nyx users (and other non-Unix gurus, like
  40. mathematicians and secretaries in the department) from "raw" Unix.  It
  41. is as flexible as you can get (supports full shell capabilties like
  42. pipes, etc. inside the menu commands) but simple to write menus for.
  43.  
  44. See mshell.1 for information on writing menus & using it.
  45. A sample menu and some more complex menu options are in the "sample.men" file.
  46. More can be found on Nyx, where this has been in service for many years.
  47.  
  48. Nyx (rhymes with Unix of course) is a free, public access Unix system. 
  49. We charge no fees, so all improvements have to come from donations of
  50. money and equipment.  All labor is volunteer (I run Nyx on my own time,
  51. others help, etc.).
  52.  
  53. If you use mshell, a donation to the Nyx project would be kindly appreciated
  54. although not required.  Such donations go toward improving Nyx.  Send to:
  55.  
  56.     Prof. Andrew Burt
  57.     Department of Mathematics and Computer Science
  58.     John Green Hall
  59.     University of Denver
  60.     Denver, CO  80208
  61.  
  62.     Make check payable to "University of Denver", and write "For Nyx" on it.
  63.  
  64. Indeed, you're welcome to try Nyx -- log into Nyx as:
  65.  
  66.     - telnet to nyx.cs.du.edu (130.253.192.68), user 'new'.
  67.     - call 303-871-3324
  68.  
  69. History:
  70.  
  71. I wrote the first version of mshell as a Bourne shell script.  A student,
  72. Dinesh Punjabi, was desperate for a project, so he rewrote the script
  73. into C.  As with most student labor :-) it was minimally functional, so
  74. I've hacked it a bunch over the years.  It still has much of Dinesh's
  75. style, though my style creeps in every so often (i.e., the code is no longer
  76. entirely consistent looking!).  I've used it at various sites, one of
  77. which required conversion to SVR2.  The SVR2 code hasn't been tested
  78. since; however, in sysvdiffs.mar93 is a set of diffs purported to make it
  79. work with SVR4 -- I haven't tested them so they're not incorprated into
  80. the main logic.  The BSD code is 4.2ish (rather, Pyramid OSx 4.1's clone
  81. of BSD 4.2+).  #ifdef'd updates are certainly welcome!
  82. -------------------------
  83. #! /bin/sh
  84. # This is a shell archive.  Remove anything before this line, then feed it
  85. # into a shell via "sh file" or similar.  To overwrite existing files,
  86. # type "sh file -c".
  87. # Contents:  README mshell.man setenv.c sysvdiffs.B
  88. # Wrapped by kent@sparky on Mon Jul 26 16:41:39 1993
  89. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  90. echo If this archive is complete, you will see the following message:
  91. echo '          "shar: End of archive 1 (of 3)."'
  92. if test -f 'README' -a "${1}" != "-c" ; then 
  93.   echo shar: Will not clobber existing file \"'README'\"
  94. else
  95.   echo shar: Extracting \"'README'\" \(3065 characters\)
  96.   sed "s/^X//" >'README' <<'END_OF_FILE'
  97. XDate: July 15, 1993
  98. XFrom: Andrew Burt <aburt@du.edu>
  99. XSubject:  Menu shell
  100. XArchive-name: menushell
  101. XEnvironment: BSD, with untested SVR4 diffs
  102. X
  103. XThis is the net release of Mshell, a Unix menuing shell.  Mshell was designed
  104. Xto be easy for users to use and easy for admins to write menus for; menus
  105. Xcan be in any format and can execute any code your shell can.  For example,
  106. Xa simple menu file would be:
  107. X
  108. X    who    Who's on the system        l    list your files
  109. X    <1>    Send e-mail            <2>    Games menu
  110. X    *****
  111. X    who    who | sort
  112. X    l    ls -l | more
  113. X    1    mail prompt=To_whom help=/how/to/send/mail
  114. X    2    menu games
  115. X
  116. XUsers see the top part, key in the choice, which runs the code at the bottom.
  117. XTop part is shown to users verbatim, bottom part has lots of flexibility
  118. Xin forming command lines and specifying help/man files.
  119. X
  120. XThis program is released "as is", but remains owned by myself and the
  121. XUniversity of Denver.  You're welcome to use mshell, and I'd like to
  122. Xhear about any bugs, and get copies of improvements, but neither I nor
  123. XDU support this software.  I'm only releasing it since so many folks
  124. Xhave asked for a copy.
  125. X
  126. XIf you use mshell, a donation to the Nyx project would be kindly appreciated.
  127. XSuch donations go toward improving Nyx.  Send to:
  128. X
  129. X    Prof. Andrew Burt
  130. X    Department of Mathematics and Computer Science
  131. X    John Green Hall
  132. X    University of Denver
  133. X    Denver, CO  80208
  134. X
  135. X    Make check payable to "University of Denver", and write "For Nyx" on it.
  136. X
  137. XIndeed, you're welcome to try Nyx -- log into Nyx as:
  138. X
  139. X    - telnet to nyx.cs.du.edu (130.253.192.68), user 'new'.
  140. X    - call 303-871-3324
  141. X
  142. XNyx (rhymes with Unix of course) is a free, public access Unix system. 
  143. XWe charge no fees, so all improvements have to come from donations of
  144. Xmoney and equipment.  All labor is volunteer (I run Nyx on my own time,
  145. Xothers help, etc.).
  146. X
  147. XMshell was written to shield Nyx users (and other non-Unix gurus, like
  148. Xmathematicians and secretaries in the department) from "raw" Unix.  It
  149. Xis as flexible as you can get (supports full shell capabilties like
  150. Xpipes, etc. inside the menu commands) but simple to write menus for.
  151. X
  152. XSee mshell.1 for information on writing menus & using it.
  153. XA sample menu and some more complex menu options are in the "sample.men" file.
  154. XMore can be found on Nyx, where this has been in service for many years.
  155. X
  156. XHistory:
  157. X
  158. XI wrote the first version of mshell as a Bourne shell script.  A student,
  159. XDinesh Punjabi, was desperate for a project, so he rewrote the script
  160. Xinto C.  As with most student labor :-) it was minimally functional, so
  161. XI've hacked it a bunch over the years.  It still has much of Dinesh's
  162. Xstyle, though my style creeps in every so often (i.e., the code is no longer
  163. Xentirely consistent looking!).  I've used it at various sites, one of
  164. Xwhich required conversion to SVR2.  The SVR2 code hasn't been tested
  165. Xsince; however, in sysvdiffs.mar93 is a set of diffs purported to make it
  166. Xwork with SVR4 -- I haven't tested them so they're not incorprated into
  167. Xthe main logic.  The BSD code is 4.2ish (rather, Pyramid OSx 4.1's clone
  168. Xof BSD 4.2+).  #ifdef'd updates are certainly welcome!
  169. END_OF_FILE
  170.   if test 3065 -ne `wc -c <'README'`; then
  171.     echo shar: \"'README'\" unpacked with wrong size!
  172.   fi
  173.   # end of 'README'
  174. fi
  175. if test -f 'mshell.man' -a "${1}" != "-c" ; then 
  176.   echo shar: Will not clobber existing file \"'mshell.man'\"
  177. else
  178.   echo shar: Extracting \"'mshell.man'\" \(12707 characters\)
  179.   sed "s/^X//" >'mshell.man' <<'END_OF_FILE'
  180. X
  181. X
  182. X
  183. XMshell(1)                USER COMMANDS                  Mshell(1)
  184. X
  185. X
  186. X
  187. XNAME
  188. X     mshell - menu oriented shell
  189. X
  190. XSYNOPSIS
  191. X     mshell [-r] [-s] initial-menu
  192. X
  193. XDESCRIPTION
  194. X     mshell is a menuing program designed to be used as  a  login
  195. X     shell  or  as  the primary program in a wrapper shell script
  196. X     (to set environment, etc.).  Menus are intended to be simple
  197. X     to create without sacrificing flexibility.
  198. X
  199. XOPTIONS
  200. X     -r   mshell runs in "restricted" mode, where  only  commands
  201. X          found  in  a  command-list file can be executed.  I.e.,
  202. X          some users may have full access  to  all  menu  options
  203. X          while  others  run under restriction.  The command-list
  204. X          file  is  currently  hardwired  via  the   COMMAND_LIST
  205. X          #define  in the source, but could easily be turned into
  206. X          a command line parameter.  Further,  -r  inhibits  user
  207. X          replies to prompts even for options that are active (to
  208. X          prevent users from entering  metacharacters  which  may
  209. X          allow   unintended   access).    Commands   must  match
  210. X          *exactly*  the  way  they  are  listed  in  the  menu's
  211. X          "cmd=..."  line, e.g., full path or no path.  See below
  212. X          for additional thoughts on security.
  213. X
  214. X     -s   Prevents the execution of !command at the  menu  prompt
  215. X          and prevents users from typing shell meta-characters in
  216. X          their replies to prompts.   See  below  for  additional
  217. X          thoughts on security.
  218. X
  219. X     initial-menu
  220. X          The name or path to the initial menu: If the name has a
  221. X          / in it, that is used as the path to the starting menu;
  222. X          if no /, then  $MENUDIR/initial-menu  is  used  as  the
  223. X          menu.
  224. X
  225. XNOTES
  226. X  Startup files
  227. X     If the file .mshellrc exists in $HOME, it is run  via  "sh".
  228. X     Useful  to run some intro commands (e.g., personal stty set-
  229. X     tings), but note it cannot be used to set variables or other
  230. X     internal state elements.
  231. X
  232. X  Logging
  233. X     If you define LOGDIR (in Makefile) to an existing dir,  then
  234. X     user  activity will be logged.  (I suggest the dir should be
  235. X     mode 733 so users can't poke around as easily).  Every  menu
  236. X     pick  a  user  makes  is appended to a file named with their
  237. X     username; these  files  grows  without  bound  and  must  be
  238. X     cleaned up manually.
  239. X
  240. X
  241. X
  242. XSun Release 4.1     Last change: 13 July 1993                   1
  243. X
  244. X
  245. X
  246. X
  247. X
  248. X
  249. XMshell(1)                USER COMMANDS                  Mshell(1)
  250. X
  251. X
  252. X
  253. X  Environment variables
  254. X     Work inside menu values (as $VAR), as does ~ for home dir.
  255. X
  256. X  Built-in commands
  257. X     cd and setenv are built in.   The  built-in  command  'menu'
  258. X     invokes mshell recursively (i.e., does not create a new pro-
  259. X     cess for submenus).
  260. X
  261. X  Security
  262. X     Take great care if you  want  to  use  mshell  in  a  secure
  263. X     environment.   It  can  be an experiment in futility.  Using
  264. X     the -s and -r options you can control  what  programs  users
  265. X     may  run;  however,  note that with just -s users can likely
  266. X     find clever ways to subvert the security and  get  a  shell.
  267. X     Even  with  both  -r  and -s in effect, many of the programs
  268. X     you're likely to allow users to run may have  ways  to  gain
  269. X     unintended  access.   For  example,  'more'  allows users to
  270. X     invoke the shell ('!' command) or vi (e.g. the 'v' command),
  271. X     from which they can gain instant shell access.  Monitor what
  272. X     commands you allow in -r very carefully.  Even the  simplest
  273. X     shell scripts may be subvertible!
  274. X
  275. X     It helps to set the SHELL environment variable to  something
  276. X     like  /bin/true,  or  better yet, a command that echoes "You
  277. X     can't have a shell, sorry."  This still won't foil a  deter-
  278. X     mined attack, of course.
  279. X
  280. X     Consider a wrapper around the menu that  removes  .mshellrc,
  281. X     for example.
  282. X
  283. X     Note that even with all this, mshell  shouldn't  be  trusted
  284. X     for  genuine security, since it's nearly impossible to elim-
  285. X     inate the ways one can get a shell (I gave it a good  whack,
  286. X     modifying  binaries  of  various programs, hacking on source
  287. X     for others, etc.; it's too much hassle and still can be cir-
  288. X     cumvented).
  289. X
  290. X  Multiple commands
  291. X     If the user types pick1,pick2,pick3 then each will  be  exe-
  292. X     cuted  as  if  the  ',' were newlines.  Use 'top,...' to get
  293. X     "absolute" picks, starting at the top of the menu tree.
  294. X
  295. X  Macros
  296. X     A file named $HOME/.mshellmac is read at startup for macros.
  297. X     Macros look like:
  298. X          name=commands
  299. X     For example:
  300. X          hist=top,i,h,x
  301. X     which on Nyx means <top, info menu, 'h' for history, 'x'  to
  302. X     exit menu back to main>.  Execute macros as
  303. X          #name
  304. X     such as
  305. X
  306. X
  307. X
  308. XSun Release 4.1     Last change: 13 July 1993                   2
  309. X
  310. X
  311. X
  312. X
  313. X
  314. X
  315. XMshell(1)                USER COMMANDS                  Mshell(1)
  316. X
  317. X
  318. X
  319. X          #hist
  320. X     Macros may be execute inside multi-command lines, as in
  321. X          foo,#hist,bar
  322. X     and inside other macros, like
  323. X          foo=a,#hist,b,c
  324. X
  325. X  Online help
  326. X     If a menu item has help=filename  in  the  definition,  that
  327. X     filename  is  printed  prior  to  execution or prompt input.
  328. X     Users can do 'help o' for an option 'o', in which  case,  if
  329. X     man=xxx  is  set,  "man  xxx"  is  invoked.   Failing  that,
  330. X     "cmd=zzz" causes "man zzz" to be run.  Thus one may let  the
  331. X     cmd=  setting  default  except  where this invokes the wrong
  332. X     manual page or one wants to  specific  a  non-man(1)  manual
  333. X     page.
  334. X
  335. XMENU DEFINITION
  336. X     Format of menu file:
  337. X
  338. X          screen layout
  339. X          *****
  340. X          keyword <tab> action_description
  341. X
  342. X     The top part of the screen is what the users sees --  it  is
  343. X     just text, put whatever you want there; there is no specific
  344. X     format rules, just make it look good.  The bottom  describes
  345. X     what  commands have what action.  The bottom is comprised of
  346. X     two tab-separated columns: a keyword and an action  descrip-
  347. X     tion.   The keyword can be any string (without a tab in it),
  348. X     usually  alpha-numeric.   Presumably  these   keywords   are
  349. X     displayed  in the layout portion so users know what to type,
  350. X     but that's up to you to ensure.  (That is, there is no mark-
  351. X     ing  of  items  in  the  top  unless  you want to for visual
  352. X     effect.  Further, you can have "invisible" menu  options  by
  353. X     listing  them in the bottom but not the top; the drawback is
  354. X     that you could have inoperative options  if  you  list  them
  355. X     above and forget to list them below.)
  356. X
  357. X     The simplest action description is just a shell command,  as
  358. X     in
  359. X          w    who | sort
  360. X     which would execute "who|sort" when a user selects 'w'  from
  361. X     the menu.  The actions can be any shell code.
  362. X
  363. X     The action descriptions can be built using keywords as  fol-
  364. X     lows:
  365. X
  366. X     cmd=name_of_command
  367. X          like arg=, but  no  _  translation.   In  addition,  it
  368. X          specifies  this  this  as  the command to run 'man' for
  369. X          help.
  370. X
  371. X
  372. X
  373. X
  374. XSun Release 4.1     Last change: 13 July 1993                   3
  375. X
  376. X
  377. X
  378. X
  379. X
  380. X
  381. XMshell(1)                USER COMMANDS                  Mshell(1)
  382. X
  383. X
  384. X
  385. X     prompt=prompt_to_print
  386. X          Prints prompt (will be followed by  colon  and  space).
  387. X          The user's response is interpolated as the next parame-
  388. X          ter.
  389. X
  390. X     arg=literal
  391. X          Argument  is  included  at  this  position  in  command
  392. X          string.   This  is  also  the default if no keyword= is
  393. X          given.
  394. X
  395. X     aarg=literal_to_append
  396. X          Like arg=, but no space put before it; e.g., to  append
  397. X          a filename extension after a prompted value.
  398. X
  399. X     aprompt=prompt_to_append
  400. X          Prompts and  appends  to  previous  argument  (e.g.,  a
  401. X          literal value).
  402. X
  403. X     help=name_of_helpfile
  404. X          Prints said helpfile (printed immediately, i.e., before
  405. X          input or execution of command).
  406. X
  407. X     man=name_of_manual
  408. X          Specifies manual entry to use  for  'help';  useful  if
  409. X          cmd=  isn't  set  to  something  you want a 'man' on or
  410. X          there isn't anything interesting to set cmd= to.
  411. X
  412. X     Notice that no <type>= is the same as "arg=".
  413. X
  414. X     In [a]prompt= and [a]arg=, underscores will be translated to
  415. X     spaces  on  output  and  are mandatory in multi-word strings
  416. X     (i.e., if you have "prompt=foo bar" the prompt will  be  foo
  417. X     and  bar  will  be  looked on as the next action description
  418. X     word; instead do "prompt=foo_bar").  Tabs in  strings  don't
  419. X     work (could be handled similar to _ for space, but aren't at
  420. X     present).
  421. X
  422. X     The result is put  into  a  string;  if  it  has  any  meta-
  423. X     characters  that  should  be  handled  by  a shell, then the
  424. X     result is fed to system() so the shell (csh  in  particular)
  425. X     can  deal  with  it.  Otherwise, mshell executes the command
  426. X     directly.
  427. X
  428. X     If the first keyword listed in the  description  section  is
  429. X     "_init",  this  command will be executed upon entry into the
  430. X     menu (before any selection).
  431. X
  432. X     At "Enter choice" prompt, a response beginning with ! causes
  433. X     the  remainder  of the line to be executed verbatim.  (E.g.,
  434. X     !who will run a who.)  (Assuming this has not been  disabled
  435. X     by -s.)
  436. X
  437. X
  438. X
  439. X
  440. XSun Release 4.1     Last change: 13 July 1993                   4
  441. X
  442. X
  443. X
  444. X
  445. X
  446. X
  447. XMshell(1)                USER COMMANDS                  Mshell(1)
  448. X
  449. X
  450. X
  451. X     All menus respond to certain built-in options, namely 'x' to
  452. X     exit  the menu, menu), and 'help xxx' to invoke the help for
  453. X     option xxx.
  454. X
  455. X     A sample menu file might be:
  456. X                              Main menu
  457. X                              =========
  458. X
  459. X          f    Upload/Download file menu     i    Information...
  460. X          s    Status/options/users menu     u    Unix file access menu
  461. X
  462. X          c    Communications menu -- bulletins, NetNews, mail, chat
  463. X
  464. X          p    Programming menu
  465. X          e    Education menu           w    Word processing menu
  466. X          g    Games menu               gr   Graphics menu
  467. X          faq  Frequently Asked Questions    o    Organization menus
  468. X
  469. X          in      Introduce yourself to other Nyx users
  470. X
  471. X          fund Info on the "fund drive" to speed up ol' Nyx
  472. X
  473. X          fb   Send feedback to sysop (comments, questions, etc.)
  474. X          *****
  475. X          u    cmd=menu arg=$mendir/file.men
  476. X          c    cmd=menu $mendir/comm.men
  477. X          w    cmd=menu $mendir/wp.men
  478. X          p    cmd=menu $mendir/prog.men
  479. X          g    cmd=menu $mendir/games.men
  480. X          s    cmd=menu $mendir/stat.men
  481. X          gr   cmd=menu $mendir/graphics.men
  482. X          i    cmd=menu $mendir/info.men
  483. X          f    cmd=menu $mendir/updownload.men
  484. X          e    cmd=menu $mendir/edu.men
  485. X          o    cmd=menu $mendir/org.men
  486. X          fb   /u5/bin/comment
  487. X          in   /u5/bin/introduction
  488. X          fund cmd=more -d $mendir/info/fund.drive
  489. X          faq  cmd=more -d $mendir/info/faq
  490. X
  491. X          Some other random example commands:
  492. X
  493. X          _init     cmd=cd $downloaddir
  494. X          used cmd=du -s $HOME
  495. X          s    cmd=fgrep prompt=String_to_find prompt=Files_to_search_(sep._by_spaces)
  496. X          fn   cmd=find $HOME_-name prompt=File -print
  497. X          co   echo 'lines____words____chars'; cmd=wc prompt=File
  498. X          ec   cmd=crypt prompt=Input_file > prompt=Output_file
  499. X          a    cd $dldir/.areas/ aprompt=Area# help=$dldir/.areas/.list
  500. X          l    (echo -n "Current area: ";pwd;sort .catalog)|lineup|more
  501. X          s    mail prompt=To help=$mendir/facmain.help
  502. X
  503. X
  504. X
  505. X
  506. XSun Release 4.1     Last change: 13 July 1993                   5
  507. X
  508. X
  509. X
  510. X
  511. X
  512. X
  513. XMshell(1)                USER COMMANDS                  Mshell(1)
  514. X
  515. X
  516. X
  517. XRECOMMENDATIONS
  518. X  Use full pathnames for filenames.
  519. X  Use multiple main menus for different
  520. X  You'll need various script files as
  521. X  Look on Nyx (nyx.cs.du.edu, login as
  522. XAUTHOR
  523. X     Original shell script version by Andrew Burt of the  Univer-
  524. X     sity  of  Denver  department  of  math and computer science.
  525. X     Initially coded in C by Dinesh Punjabi (yes,  as  a  student
  526. X     project).   Subsequent hacks and maintenance by Andrew Burt,
  527. X     reachable as aburt@du.edu.
  528. X
  529. XBUGS
  530. X     No doubt.  I've heard tales of occasional glitches where the
  531. X     menus get very hosed up, but haven't searched for causes.  I
  532. X     suspect there are some memory leaks lurking around  as  well
  533. X     in  some  of  the  older  code.   The reliance on fixed size
  534. X     strings stems from the original,  and  should  be  replaced.
  535. X     The  original  System V code has not been tested in ages and
  536. X     may no longer even compile; the  newer  diffs  haven't  been
  537. X     tested.
  538. X
  539. X
  540. X
  541. X
  542. X
  543. X
  544. X
  545. X
  546. X
  547. X
  548. X
  549. X
  550. X
  551. X
  552. X
  553. X
  554. X
  555. X
  556. X
  557. X
  558. X
  559. X
  560. X
  561. X
  562. X
  563. X
  564. X
  565. X
  566. X
  567. X
  568. X
  569. X
  570. X
  571. X
  572. XSun Release 4.1     Last change: 13 July 1993                   6
  573. X
  574. X
  575. X
  576. END_OF_FILE
  577.   if test 12707 -ne `wc -c <'mshell.man'`; then
  578.     echo shar: \"'mshell.man'\" unpacked with wrong size!
  579.   fi
  580.   # end of 'mshell.man'
  581. fi
  582. if test -f 'setenv.c' -a "${1}" != "-c" ; then 
  583.   echo shar: Will not clobber existing file \"'setenv.c'\"
  584. else
  585.   echo shar: Extracting \"'setenv.c'\" \(1717 characters\)
  586.   sed "s/^X//" >'setenv.c' <<'END_OF_FILE'
  587. X/*   setenv.c   */
  588. X#include "mshell.h"
  589. X
  590. Xextern char **environ;
  591. X
  592. X#define NULL    0
  593. X#define NO_ROOM    (-1)
  594. X#define O_K    0
  595. X
  596. Xsetenv(var, value)
  597. Xregister char *var, *value;
  598. X{
  599. X    char **env = environ;
  600. X    char **newenv, **newenv_base;
  601. X    char *entry;        /* pointer to the new, malloc'd entry */
  602. X    char *getenv(), *malloc(), *calloc();
  603. X    int var_len;
  604. X
  605. X    var_len = strlen(var);    /* used often (maybe) */
  606. X
  607. X    /* make room for the new entry */
  608. X
  609. X    entry = malloc(var_len+strlen(value)+2);
  610. X    if (entry == NULL)
  611. X        return(NO_ROOM);
  612. X
  613. X    /* copy in the entry */
  614. X
  615. X    sprintf(entry, "%s=%s", var, value);
  616. X
  617. X    /* see where to put it now */
  618. X
  619. X    if (getenv(var) != NULL)    /* if it has a value, change it */
  620. X        for (; *env != NULL; env++) {
  621. X            if (strncmp(*env, var, var_len) == 0) {
  622. X                *env =  entry;
  623. X                break;    /* for */
  624. X            }
  625. X        }
  626. X    else {                /* remake the whole list, and add it */
  627. X        newenv = (char **) calloc(sarsize(env)+2, sizeof(char *));
  628. X        if (newenv == NULL)
  629. X            return(NO_ROOM);
  630. X        newenv_base = newenv;
  631. X
  632. X        while (*newenv++ = *env++)
  633. X            ;            /* copy table */
  634. X        *--newenv = entry;        /* add new one at end */
  635. X        *++newenv = NULL;        /* end list */
  636. X        environ = newenv_base;        /* and make it final */
  637. X    }
  638. X
  639. X    return(O_K);
  640. X
  641. X} /* setenv */
  642. X
  643. X
  644. X/*
  645. X * sarsize(sar) -- determine size of
  646. X * NULL terminated string array ("sar"),
  647. X * such as argv or envp.
  648. X * Returned value is akin to argc:
  649. X * sar[returned_val] == NULL.
  650. X */
  651. X
  652. Xsarsize(sar)
  653. Xregister char **sar;
  654. X{
  655. X    register size = 0;
  656. X
  657. X    if (sar == NULL)    /* if no array to begin with, return 0 */
  658. X        return(0);
  659. X
  660. X    while (sar[size] != NULL)
  661. X        size++;
  662. X
  663. X    return(size);
  664. X
  665. X} /* sarsize */
  666. X
  667. X
  668. Xprintenv()
  669. X{
  670. X    char **env = environ;
  671. X
  672. X    printf("--------------------\n");
  673. X    while (*env != NULL)
  674. X        printf("%s\n", *env++);
  675. X    printf("--------------------\n");
  676. X
  677. X
  678. X}
  679. END_OF_FILE
  680.   if test 1717 -ne `wc -c <'setenv.c'`; then
  681.     echo shar: \"'setenv.c'\" unpacked with wrong size!
  682.   fi
  683.   # end of 'setenv.c'
  684. fi
  685. if test -f 'sysvdiffs.B' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'sysvdiffs.B'\"
  687. else
  688.   echo shar: Extracting \"'sysvdiffs.B'\" \(36374 characters\)
  689.   sed "s/^X//" >'sysvdiffs.B' <<'END_OF_FILE'
  690. Xdiff -rc msh/macro.c msh.orig/macro.c
  691. X*** msh/macro.c    Sun Mar 14 11:32:17 1993
  692. X--- msh.orig/macro.c    Mon Mar 15 23:26:29 1993
  693. X***************
  694. X*** 1,7 ****
  695. X  #include "mshell.h"
  696. X  
  697. X- static char macro_rcsid[] = "$Header: /usr3/src/msh/RCS/macro.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  698. X- 
  699. X  struct macro {
  700. X      DL_NODE n;
  701. X      char *name;
  702. X--- 1,5 ----
  703. X***************
  704. X*** 10,16 ****
  705. X  
  706. X  static DLIST macrolist;
  707. X  
  708. X! char *mac_lookup(char *name)
  709. X  {
  710. X      struct macro *m;
  711. X  
  712. X--- 8,16 ----
  713. X  
  714. X  static DLIST macrolist;
  715. X  
  716. X! char *
  717. X! mac_lookup(name)
  718. X! char *name;
  719. X  {
  720. X      struct macro *m;
  721. X  
  722. X***************
  723. X*** 21,34 ****
  724. X  
  725. X      /* note: could do a help/list macro here as builtin */
  726. X  
  727. X!     printw("No definition for macro %s\n", name);
  728. X      return("");
  729. X  }
  730. X  
  731. X! load_macrofile(char *f)
  732. X  {
  733. X      FILE *fp;
  734. X!     char line[MAXLEN], name[MAXLEN], def[MAXLEN], *strsave(char *);
  735. X      struct macro *m;
  736. X  
  737. X      if ((fp = fopen(f, "r")) == NULL)
  738. X--- 21,35 ----
  739. X  
  740. X      /* note: could do a help/list macro here as builtin */
  741. X  
  742. X!     printf("No definition for macro %s\n", name);
  743. X      return("");
  744. X  }
  745. X  
  746. X! load_macrofile(f)
  747. X! char *f;
  748. X  {
  749. X      FILE *fp;
  750. X!     char line[MAXLEN], name[MAXLEN], def[MAXLEN];
  751. X      struct macro *m;
  752. X  
  753. X      if ((fp = fopen(f, "r")) == NULL)
  754. X***************
  755. X*** 40,46 ****
  756. X      while (fgets(line, MAXLEN, fp))
  757. X          if (
  758. X              sscanf(line, "%[^=]=%[^\n]\n", name, def) == 2 &&
  759. X!             (m = (struct macro *)getnode(sizeof(*m))) &&
  760. X              (m->name = strsave(name)) &&
  761. X              (m->def = strsave(def))
  762. X          )
  763. X--- 41,47 ----
  764. X      while (fgets(line, MAXLEN, fp))
  765. X          if (
  766. X              sscanf(line, "%[^=]=%[^\n]\n", name, def) == 2 &&
  767. X!             (m = getnode(sizeof(*m))) &&
  768. X              (m->name = strsave(name)) &&
  769. X              (m->def = strsave(def))
  770. X          )
  771. Xdiff -rc msh/mail.c msh.orig/mail.c
  772. X*** msh/mail.c    Sun Mar 14 11:32:17 1993
  773. X--- msh.orig/mail.c    Mon Mar 15 23:26:27 1993
  774. X***************
  775. X*** 1,11 ****
  776. X  #include "mshell.h"
  777. X  
  778. X- static char mail_rcsid[] = "$Header: /usr3/src/msh/RCS/mail.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  779. X  
  780. X- #ifdef SYSV
  781. X- #include <string.h>
  782. X- #endif
  783. X- 
  784. X  extern char     G_homevar      [];
  785. X  extern char     G_uservar      [];
  786. X  extern char     G_termvar      [];
  787. X--- 1,6 ----
  788. X***************
  789. X*** 14,29 ****
  790. X  extern int      G_mailsize; 
  791. X  extern struct   stat G_st;
  792. X  
  793. X! void check_for_new_mail(char *message)
  794. X  {
  795. X      off_t new_mail_size;
  796. X  
  797. X!     stat(G_mailfile, &G_st);
  798. X  
  799. X      new_mail_size = G_st.st_size;
  800. X  
  801. X      if ( new_mail_size > G_mailsize )
  802. X!         strcpy( message, MAIL_MESSAGE );
  803. X  
  804. X      G_mailsize = new_mail_size;
  805. X  }
  806. X--- 9,25 ----
  807. X  extern int      G_mailsize; 
  808. X  extern struct   stat G_st;
  809. X  
  810. X! check_for_new_mail (message)
  811. X! char * message;
  812. X  {
  813. X      off_t new_mail_size;
  814. X  
  815. X!     stat (G_mailfile, &G_st);
  816. X  
  817. X      new_mail_size = G_st.st_size;
  818. X  
  819. X      if ( new_mail_size > G_mailsize )
  820. X!         strcpy ( message, MAIL_MESSAGE );
  821. X  
  822. X      G_mailsize = new_mail_size;
  823. X  }
  824. Xdiff -rc msh/main.c msh.orig/main.c
  825. X*** msh/main.c    Sun Mar 14 11:32:18 1993
  826. X--- msh.orig/main.c    Mon Mar 15 23:26:27 1993
  827. X***************
  828. X*** 7,20 ****
  829. X   */
  830. X  #include "mshell.h"
  831. X  
  832. X- static char main_rcsid[] = "$Header: /usr3/src/msh/RCS/main.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  833. X- 
  834. X  char     G_homevar      [] = { "$HOME" };
  835. X- #ifdef SYSV
  836. X- char     G_uservar      [] = { "$LOGNAME" };
  837. X- #else
  838. X  char     G_uservar      [] = { "$USER" };
  839. X- #endif
  840. X  char      G_termvar      [] = { "$TERM" };
  841. X  char     G_mailfile     [WORDLEN];
  842. X  char     G_mail_message [WORDLEN];
  843. X--- 7,14 ----
  844. X***************
  845. X*** 23,29 ****
  846. X  int     G_shell_ok;
  847. X  int     G_limited = FALSE;
  848. X  
  849. X! main(int argc, char **argv)
  850. X  {
  851. X      char menu[WORDLEN];
  852. X      char menuname[WORDLEN];
  853. X--- 17,26 ----
  854. X  int     G_shell_ok;
  855. X  int     G_limited = FALSE;
  856. X  
  857. X! main (argc, argv)
  858. X! int     argc;
  859. X! char ** argv;
  860. X! 
  861. X  {
  862. X      char menu[WORDLEN];
  863. X      char menuname[WORDLEN];
  864. X***************
  865. X*** 30,42 ****
  866. X      char *progname = argv[0];
  867. X  
  868. X      G_shell_ok = TRUE;
  869. X-     /* -s secure -- !commands not allowed */
  870. X      if ( argc > 1 && strcmp(argv[1], "-s") == 0 ) {
  871. X          G_shell_ok = FALSE;
  872. X          argc--;
  873. X          argv++;
  874. X      }
  875. X-     /* -r restricted -- only commands in #define COMMAND_LIST allowed */
  876. X      else if ( argc > 1 && strcmp(argv[1], "-r") == 0 ) {
  877. X          G_limited = TRUE;
  878. X          G_shell_ok = FALSE;
  879. X--- 27,37 ----
  880. X***************
  881. X*** 45,51 ****
  882. X      }
  883. X  
  884. X      if ( argc < 2 ) {
  885. X!         printf("Usage: %s <primary menu name>\n", progname);
  886. X          exit (1);
  887. X      }
  888. X  
  889. X--- 40,46 ----
  890. X      }
  891. X  
  892. X      if ( argc < 2 ) {
  893. X!         printf ("Usage: %s <primary menu name>\n", progname);
  894. X          exit (1);
  895. X      }
  896. X  
  897. X***************
  898. X*** 64,70 ****
  899. X      if ( getppid() == 1 )            /* Mshell is login shell */
  900. X  #endif
  901. X          set_terminal_attributes();
  902. X-     clear_screen();
  903. X      set_resource_limits();
  904. X  
  905. X      rc();
  906. X--- 59,64 ----
  907. X***************
  908. X*** 72,82 ****
  909. X      load_macrofile(GLOBAL_MACRO_FILE);
  910. X      load_macrofile(".mshellmac");
  911. X  
  912. X!     M_Shell(argv[1]);
  913. X      bye(0);
  914. X  }
  915. X  
  916. X! void rc()
  917. X  {
  918. X      if (!G_shell_ok)
  919. X          return;
  920. X--- 66,76 ----
  921. X      load_macrofile(GLOBAL_MACRO_FILE);
  922. X      load_macrofile(".mshellmac");
  923. X  
  924. X!     M_Shell (argv[1]);
  925. X      bye(0);
  926. X  }
  927. X  
  928. X! rc()
  929. X  {
  930. X      if (!G_shell_ok)
  931. X          return;
  932. X***************
  933. X*** 88,110 ****
  934. X  }
  935. X  
  936. X  #ifndef LOGDIR
  937. X! #define LOGDIR "/usr/local/mshell/logs"
  938. X  #endif
  939. X  
  940. X  FILE *logfp;
  941. X! 
  942. X! void openlog()
  943. X  {
  944. X      struct passwd *pw;
  945. X!     char fn[80];
  946. X  
  947. X!     if ((pw = getpwuid(getuid())) == NULL) return;
  948. X      sprintf(fn, "%s/%s", LOGDIR, pw->pw_name);
  949. X      logfp = fopen(fn, "a");
  950. X      chmod(fn, 0600);
  951. X  }
  952. X  
  953. X! void log(char *s1, char *s2)
  954. X  {
  955. X!     if (logfp) fprintf(logfp, "%s %s\n", s1, s2);
  956. X  }
  957. X--- 82,106 ----
  958. X  }
  959. X  
  960. X  #ifndef LOGDIR
  961. X! #define LOGDIR "/u1/logs"
  962. X  #endif
  963. X  
  964. X  FILE *logfp;
  965. X! openlog()
  966. X  {
  967. X      struct passwd *pw;
  968. X!     char fn[32];
  969. X  
  970. X!     if ((pw = getpwuid(getuid())) == NULL)
  971. X!         return;
  972. X      sprintf(fn, "%s/%s", LOGDIR, pw->pw_name);
  973. X      logfp = fopen(fn, "a");
  974. X      chmod(fn, 0600);
  975. X  }
  976. X  
  977. X! log(s1, s2)
  978. X! char *s1, *s2;
  979. X  {
  980. X!     if (logfp)
  981. X!         fprintf(logfp, "%s %s\n", s1, s2);
  982. X  }
  983. Xdiff -rc msh/menulogin msh.orig/menulogin
  984. X*** msh/menulogin    Sun Mar 14 21:19:49 1993
  985. X--- msh.orig/menulogin    Mon Mar 15 23:26:30 1993
  986. X***************
  987. X*** 1,45 ****
  988. X  #!/bin/sh
  989. X- # $Header: /usr3/src/msh/RCS/menulogin,v 1.2 1993/03/15 05:19:30 root Exp root $:
  990. X  
  991. X! PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:.
  992. X  
  993. X! # Initialized vars
  994. X! MAX_DISKALLOWED=100        # in 1KB increment
  995. X! HOME_LOWWARN=20000        # qed
  996. X! HOME_LOWMARK=5000        # qed
  997. X  
  998. X! mendir=/usr/local/mshell/menus
  999. X! dldir=$HOME/download
  1000. X  
  1001. X! /bin/echo "Configuring..."
  1002. X! 
  1003. X! set `du -s $HOME`
  1004. X! /bin/echo "FYI, your disk usage is: $1 K."
  1005. X! if [ "$1" -gt $MAX_DISKALLOWED ]; then
  1006. X!     /bin/echo "Reminder, please keep your home dirs small (under 100 K)."
  1007. X!     /bin/echo "There's plenty of temp space elsewhere."
  1008. X! 
  1009. X!     free=`df -k /home | tail -1 | awk '{ print $4 }'`
  1010. X!     if [ "$free" -lt $HOME_LOWWARN ]; then
  1011. X!         /bin/echo "Note that free space (for EVERYONE) is tight: only $free K."
  1012. X!         /bin/echo "(And you are using more than 100 K -- hint hint.)"
  1013. X!         /bin/echo "Use the 'du2' option on the status menu for more info."
  1014. X!         if [ "$free" -lt $HOME_LOWMARK ]; then
  1015. X!             /bin/echo "***Indeed, with so little space, consider it imperative -- clean up immediately!"
  1016. X          fi
  1017. X      fi
  1018. X  fi
  1019. X  
  1020. X! if [ -r $HOME/.termrc ]; then
  1021. X!     . $HOME/.termrc
  1022. X  else
  1023. X      TERM=vt100
  1024. X      TERMCAP=/etc/termcap
  1025. X  fi
  1026. X  if [ -r $HOME/.editor ]; then
  1027. X      EDITOR=$HOME/.editor
  1028. X  else
  1029. X!     EDITOR=/usr/local/bin/e
  1030. X  fi
  1031. X  if [ -f $HOME/.biffy ]; then
  1032. X      biff y
  1033. X--- 1,43 ----
  1034. X  #!/bin/sh
  1035. X  
  1036. X! # Sample login wrapper -- name as /.../menulogin or /.../menuloginsh
  1037. X! # and it'll allow shell or not as it ends with ...sh.  Could also be
  1038. X! # modified to enable -r for some naming scheme.
  1039. X! # This junk is pretty Nyx specific, and outdated, but the idea's the thing.
  1040. X  
  1041. X! echo "Configuring..."
  1042. X  
  1043. X! set `du -s .`
  1044. X! echo "FYI, your disk usage is: $1 K."
  1045. X! if [ "$1" -gt 100 ]; then
  1046. X!     echo "Reminder, please keep your home dirs small (under 100 K)."
  1047. X!     echo "There's plenty of temp space elsewhere."
  1048. X  
  1049. X!     free=`/u1/bin/pdf`
  1050. X!     if [ "$free" -lt 20000 ]; then
  1051. X!         echo "Note that free space (for EVERYONE) is tight: only $free K."
  1052. X!         echo "(And you are using more than 100 K -- hint hint.)"
  1053. X!         echo "Use the 'du2' option on the status menu for more info."
  1054. X!         if [ "$free" -lt 5000 ]; then
  1055. X!             echo "***Indeed, with so little space, consider it imperative -- clean up immediately!"
  1056. X          fi
  1057. X      fi
  1058. X  fi
  1059. X  
  1060. X! mendir=/u5/lib/menus
  1061. X! dldir=/u3/lib/download
  1062. X! if [ -r $HOME/.termtype ]; then
  1063. X!     . $HOME/.termtype
  1064. X  else
  1065. X+ #    TERM=dw1
  1066. X      TERM=vt100
  1067. X      TERMCAP=/etc/termcap
  1068. X  fi
  1069. X+ PATH=/u1/bin:/u5/bin:/usr/ucb:/bin:/usr/bin:.
  1070. X  if [ -r $HOME/.editor ]; then
  1071. X      EDITOR=$HOME/.editor
  1072. X  else
  1073. X!     EDITOR=/u5/bin/smile
  1074. X  fi
  1075. X  if [ -f $HOME/.biffy ]; then
  1076. X      biff y
  1077. X***************
  1078. X*** 53,64 ****
  1079. X  case $0 in
  1080. X      *sh)
  1081. X          # shell is ok
  1082. X!         SHELL=/bin/sh
  1083. X          opt=""
  1084. X          ;;
  1085. X      *)
  1086. X          # shell is not allowed
  1087. X!         SHELL=/usr/local/bin/noshell
  1088. X          opt="-s"
  1089. X          ;;
  1090. X  esac
  1091. X--- 51,62 ----
  1092. X  case $0 in
  1093. X      *sh)
  1094. X          # shell is ok
  1095. X!         SHELL=/bin/csh
  1096. X          opt=""
  1097. X          ;;
  1098. X      *)
  1099. X          # shell is not allowed
  1100. X!         SHELL=/u1/bin/noshell
  1101. X          opt="-s"
  1102. X          ;;
  1103. X  esac
  1104. X***************
  1105. X*** 75,82 ****
  1106. X      RNINIT=$HOME/.rninit
  1107. X      export RNINIT
  1108. X  fi
  1109. X! 
  1110. X! #/usr/ucb/stty -tabs crt erase '^h' kill '^u' intr '^c'
  1111. X! /bin/echo -n "Hit ENTER to continue..."
  1112. X  read xxx
  1113. X! exec /usr/local/bin/mshell $opt main
  1114. X--- 73,79 ----
  1115. X      RNINIT=$HOME/.rninit
  1116. X      export RNINIT
  1117. X  fi
  1118. X! stty -tabs crt susp undef dsusp undef -nohang erase '^h' kill '^u' intr '^c'
  1119. X! echo "Hit ENTER to continue...\c"
  1120. X  read xxx
  1121. X! exec /u5/bin/mshell $opt main
  1122. Xdiff -rc msh/mshell.c msh.orig/mshell.c
  1123. X*** msh/mshell.c    Sun Mar 14 11:32:18 1993
  1124. X--- msh.orig/mshell.c    Mon Mar 15 23:26:28 1993
  1125. X***************
  1126. X*** 1,24 ****
  1127. X  #include "mshell.h"
  1128. X- 
  1129. X- static char mshell_rcsid[] = "$Header: /usr3/src/msh/RCS/mshell.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  1130. X- 
  1131. X  #include <setjmp.h>
  1132. X! #ifdef SYSV
  1133. X! #include <string.h>
  1134. X! #endif
  1135. X  
  1136. X  extern char     G_homevar      [];
  1137. X  extern char     G_uservar      [];
  1138. X  extern char     G_termvar      [];
  1139. X! extern char     G_mailfile     [];
  1140. X! extern char     G_mail_message [];
  1141. X  extern int      G_mailsize; 
  1142. X  extern int      G_shell_ok; 
  1143. X  extern struct   stat G_st;
  1144. X  
  1145. X  /* ================== */
  1146. X! void M_Shell(char *m)
  1147. X  /* ================== */
  1148. X  {
  1149. X      char opt           [WORDLEN],
  1150. X           opt1          [OPTLEN],
  1151. X--- 1,23 ----
  1152. X  #include "mshell.h"
  1153. X  #include <setjmp.h>
  1154. X! char * index ();
  1155. X  
  1156. X+ 
  1157. X  extern char     G_homevar      [];
  1158. X  extern char     G_uservar      [];
  1159. X  extern char     G_termvar      [];
  1160. X! extern char     G_mailfile     [WORDLEN];
  1161. X! extern char     G_mail_message [WORDLEN];
  1162. X  extern int      G_mailsize; 
  1163. X  extern int      G_shell_ok; 
  1164. X  extern struct   stat G_st;
  1165. X  
  1166. X  /* ================== */
  1167. X! M_Shell (m)
  1168. X  /* ================== */
  1169. X+ 
  1170. X+ char *m;
  1171. X+ 
  1172. X  {
  1173. X      char opt           [WORDLEN],
  1174. X           opt1          [OPTLEN],
  1175. X***************
  1176. X*** 43,54 ****
  1177. X      static int topenvset;
  1178. X  
  1179. X      menu_flag = FALSE;
  1180. X!     signal(SIGHUP,  exit);
  1181. X!     signal(SIGINT,  SIG_IGN);    /* ignore all ^C interrupts */
  1182. X!     signal(SIGQUIT, SIG_IGN);    /* ignore all ^\ interrupts */
  1183. X!     signal(SIGTSTP, SIG_IGN);    /* ignore all ^Z interrupts */
  1184. X!     signal(SIGPIPE, SIG_IGN);    /* ignore dead pipes */
  1185. X!     log("M_Shell: enter", m);
  1186. X  
  1187. X      while TRUE {
  1188. X  
  1189. X--- 42,53 ----
  1190. X      static int topenvset;
  1191. X  
  1192. X      menu_flag = FALSE;
  1193. X!     signal (SIGHUP,  exit);
  1194. X!     signal (SIGINT,  SIG_IGN);    /* ignore all ^C interrupts */
  1195. X!     signal (SIGQUIT, SIG_IGN);    /* ignore all ^\ interrupts */
  1196. X!     signal (SIGTSTP, SIG_IGN);    /* ignore all ^Z interrupts */
  1197. X!     signal (SIGPIPE, SIG_IGN);    /* ignore dead pipes */
  1198. X!     log("enter", m);
  1199. X  
  1200. X      while TRUE {
  1201. X  
  1202. X***************
  1203. X*** 67,80 ****
  1204. X  
  1205. X              if ( firsttime ) {
  1206. X                  firsttime = FALSE;
  1207. X!                 search_menu_array(menu_array, idx, "_init",
  1208. X                      action_string, &invalid_option);
  1209. X                  if (!invalid_option) {
  1210. X                      while (substitute(action_string))
  1211. X                          ;
  1212. X!                     get_actions(action_string,
  1213. X                          exec_string, args);
  1214. X!                     execute_command(exec_string, args);
  1215. X                  }
  1216. X                  else    
  1217. X                      invalid_option = FALSE;
  1218. X--- 66,79 ----
  1219. X  
  1220. X              if ( firsttime ) {
  1221. X                  firsttime = FALSE;
  1222. X!                 search_menu_array (menu_array, idx, "_init",
  1223. X                      action_string, &invalid_option);
  1224. X                  if (!invalid_option) {
  1225. X                      while (substitute(action_string))
  1226. X                          ;
  1227. X!                     get_actions (action_string,
  1228. X                          exec_string, args);
  1229. X!                     execute_command (exec_string, args);
  1230. X                  }
  1231. X                  else    
  1232. X                      invalid_option = FALSE;
  1233. X***************
  1234. X*** 81,97 ****
  1235. X              }
  1236. X  
  1237. X              if ( invalid_option )
  1238. X!                 printw("No such choice as '%s'.", opt);
  1239. X  
  1240. X              if (!moreinput())
  1241. X!                 printw("\tSelect choice [or help, x, top, bye]: ");
  1242. X!             refresh();
  1243. X! 
  1244. X              opt[0] = 0;
  1245. X!             read_input_line(opt);
  1246. X              log("    ", opt);
  1247. X              invalid_option = FALSE;
  1248. X!             addch('\n');
  1249. X  
  1250. X              /* if first character of option is an "!"    *
  1251. X               * character then invoke the remaining line  *
  1252. X--- 80,94 ----
  1253. X              }
  1254. X  
  1255. X              if ( invalid_option )
  1256. X!                 printf ("No such choice as '%s'.", opt);
  1257. X  
  1258. X              if (!moreinput())
  1259. X!                 printf ("\tSelect choice [or help, x, top, bye]: ");
  1260. X              opt[0] = 0;
  1261. X!             read_input_line (opt);
  1262. X              log("    ", opt);
  1263. X              invalid_option = FALSE;
  1264. X!             putchar('\n');
  1265. X  
  1266. X              /* if first character of option is an "!"    *
  1267. X               * character then invoke the remaining line  *
  1268. X***************
  1269. X*** 101,114 ****
  1270. X              if ( !opt[0] )
  1271. X                  continue;
  1272. X              else if ( opt[0] == EXCLAIM && G_shell_ok ) {
  1273. X-                 endwin();
  1274. X                  system(opt+1);
  1275. X                  unix_flag = TRUE;
  1276. X!                 refresh();
  1277. X!                 wait_for_user();
  1278. X              }
  1279. X              else {
  1280. X!                 search_menu_array(menu_array, idx, opt,
  1281. X                      action_string, &invalid_option);
  1282. X              }
  1283. X          }
  1284. X--- 98,109 ----
  1285. X              if ( !opt[0] )
  1286. X                  continue;
  1287. X              else if ( opt[0] == EXCLAIM && G_shell_ok ) {
  1288. X                  system(opt+1);
  1289. X                  unix_flag = TRUE;
  1290. X!                 wait_for_user ();
  1291. X              }
  1292. X              else {
  1293. X!                 search_menu_array (menu_array, idx, opt,
  1294. X                      action_string, &invalid_option);
  1295. X              }
  1296. X          }
  1297. X***************
  1298. X*** 126,132 ****
  1299. X  
  1300. X      /* remove actual values of commands and arguments from action-string */
  1301. X      /* ================================================================= */
  1302. X!         get_actions(action_string, exec_string, args);
  1303. X  
  1304. X      /* display any prompt and get values if specified in the command line */
  1305. X      /* ================================================================== */
  1306. X--- 121,127 ----
  1307. X  
  1308. X      /* remove actual values of commands and arguments from action-string */
  1309. X      /* ================================================================= */
  1310. X!         get_actions (action_string, exec_string, args);
  1311. X  
  1312. X      /* display any prompt and get values if specified in the command line */
  1313. X      /* ================================================================== */
  1314. X***************
  1315. X*** 133,160 ****
  1316. X          opt1[0] = EOS;
  1317. X          opt2[0] = EOS;
  1318. X  
  1319. X!         if ( index(opt, BLANK) != NULL )
  1320. X!             sscanf(opt, "%s %s", opt1, opt2);
  1321. X          else
  1322. X!             strcpy(opt1, opt);
  1323. X  
  1324. X!         if ( strcmp(opt1, HELP) == 0 ) {
  1325. X!             if ( strcmp(opt2, NULLSTR) == 0 )
  1326. X                  strcpy(opt2, prompt("Help on which choice"));
  1327. X  
  1328. X!             search_menu_array(menu_array, idx, opt2,
  1329. X                     action_string, &invalid_option);
  1330. X  
  1331. X!             if ( strcmp(action_string, NULLSTR) == 0 ) {
  1332. X                  invalid_option = TRUE;
  1333. X!                 printw("\tNo such help option name as: %s!!!\n", opt2);
  1334. X!                 refresh();
  1335. X              }
  1336. X              else {
  1337. X                  tmpword[0] = EOS;
  1338. X!                 extract_action_word(action_string, MAN, tmpword, 0);
  1339. X!                 if ( strcmp(tmpword, NULLSTR) == 0 ) 
  1340. X!                     extract_action_word(action_string, CMDVAL, tmpword, 0);
  1341. X                  if (strcmp(tmpword, NULLSTR) != 0)
  1342. X                      do_man(tmpword);
  1343. X              }
  1344. X--- 128,154 ----
  1345. X          opt1[0] = EOS;
  1346. X          opt2[0] = EOS;
  1347. X  
  1348. X!         if ( index (opt, BLANK) != NULL )
  1349. X!             sscanf (opt, "%s %s", opt1, opt2);
  1350. X          else
  1351. X!             strcpy (opt1, opt);
  1352. X  
  1353. X!         if ( strcmp (opt1, HELP) == 0 ) {
  1354. X!             if ( strcmp (opt2, NULLSTR) == 0 )
  1355. X                  strcpy(opt2, prompt("Help on which choice"));
  1356. X  
  1357. X!             search_menu_array (menu_array, idx, opt2,
  1358. X                     action_string, &invalid_option);
  1359. X  
  1360. X!             if ( strcmp (action_string, NULLSTR) == 0 ) {
  1361. X                  invalid_option = TRUE;
  1362. X!                 printf ("\tNo such help option name as: %s\!\!\n", opt2);
  1363. X              }
  1364. X              else {
  1365. X                  tmpword[0] = EOS;
  1366. X!                 extract_action_word (action_string, MAN, tmpword, 0);
  1367. X!                 if ( strcmp (tmpword, NULLSTR) == 0 ) 
  1368. X!                     extract_action_word (action_string, CMDVAL, tmpword, 0);
  1369. X                  if (strcmp(tmpword, NULLSTR) != 0)
  1370. X                      do_man(tmpword);
  1371. X              }
  1372. X***************
  1373. X*** 161,167 ****
  1374. X  
  1375. X  /*            if ( invalid_option ) {*/
  1376. X                  invalid_option = FALSE;
  1377. X!                 wait_for_user();
  1378. X  /*            }*/
  1379. X              continue;
  1380. X          }
  1381. X--- 155,161 ----
  1382. X  
  1383. X  /*            if ( invalid_option ) {*/
  1384. X                  invalid_option = FALSE;
  1385. X!                 wait_for_user ();
  1386. X  /*            }*/
  1387. X              continue;
  1388. X          }
  1389. X***************
  1390. X*** 184,219 ****
  1391. X              for (i = 0; i < LINES; i++)
  1392. X                  if (menu_array[i])
  1393. X                      free(menu_array[i]);
  1394. X-             menu_flag = FALSE;
  1395. X              longjmp(topenv, 1);
  1396. X          }
  1397. X!         else if (strcmp(args[0], "menu") == 0 )
  1398. X!             M_Shell(args[1]);
  1399. X          else {
  1400. X!             execute_command(exec_string, args);
  1401. X              wait_for_user();
  1402. X          }
  1403. X      }
  1404. X  }
  1405. X  
  1406. X! do_man(char *entry)
  1407. X  {
  1408. X!     char cmd[WORDLEN], *p;
  1409. X  
  1410. X      if (p = rindex(entry, '/'))
  1411. X          entry = p+1;
  1412. X  
  1413. X      sprintf(cmd, "man %s", entry);
  1414. X-     refresh();
  1415. X-     endwin();
  1416. X      system(cmd);
  1417. X-     refresh();
  1418. X  }
  1419. X  
  1420. X! bye(int status)
  1421. X  {
  1422. X!     printw("\nLogging out -- come back again soon...\n\n");
  1423. X!     refresh();
  1424. X!     endwin();
  1425. X      exit(status);
  1426. X  }
  1427. X--- 178,209 ----
  1428. X              for (i = 0; i < LINES; i++)
  1429. X                  if (menu_array[i])
  1430. X                      free(menu_array[i]);
  1431. X              longjmp(topenv, 1);
  1432. X          }
  1433. X!         else if ( strcmp(args[0], "menu") == 0 )
  1434. X!             M_Shell (args[1]);
  1435. X          else {
  1436. X!             execute_command (exec_string, args);
  1437. X              wait_for_user();
  1438. X          }
  1439. X      }
  1440. X  }
  1441. X  
  1442. X! do_man(entry)
  1443. X! char *entry;
  1444. X  {
  1445. X!     char cmd[WORDLEN], *p, *rindex();
  1446. X  
  1447. X      if (p = rindex(entry, '/'))
  1448. X          entry = p+1;
  1449. X  
  1450. X      sprintf(cmd, "man %s", entry);
  1451. X      system(cmd);
  1452. X  }
  1453. X  
  1454. X! bye(status)
  1455. X! int status;
  1456. X  {
  1457. X!     printf("\nLogging out -- come back again soon...\n\n");
  1458. X      exit(status);
  1459. X  }
  1460. Xdiff -rc msh/mshell.h msh.orig/mshell.h
  1461. X*** msh/mshell.h    Sun Mar 14 11:32:18 1993
  1462. X--- msh.orig/mshell.h    Mon Mar 15 23:26:29 1993
  1463. X***************
  1464. X*** 1,24 ****
  1465. X- #ifndef _MSHELL_H
  1466. X- #define _MSHELL_H
  1467. X- 
  1468. X  #include <stdio.h>
  1469. X  #include <curses.h>
  1470. X  #include <pwd.h>
  1471. X  #include <sys/types.h>
  1472. X- #include <sys/signal.h>
  1473. X  #include <sys/stat.h>
  1474. X- 
  1475. X  #ifdef BSD
  1476. X  #include <sys/dir.h>        /* accessing the directory structure    */
  1477. X  #include <sgtty.h>        /* struct for terminal attributes       */
  1478. X! #else
  1479. X  #ifdef SYSV
  1480. X  #define index    strchr
  1481. X  #define rindex    strrchr
  1482. X  /* #include <termio.h>        /* do this if curses.h doesn't */
  1483. X  #endif
  1484. X- #endif
  1485. X- 
  1486. X  #include "dl.h"
  1487. X  
  1488. X  #define  BLANK           ' '
  1489. X--- 1,18 ----
  1490. X  #include <stdio.h>
  1491. X  #include <curses.h>
  1492. X+ #include <sys/signal.h>
  1493. X  #include <pwd.h>
  1494. X  #include <sys/types.h>
  1495. X  #include <sys/stat.h>
  1496. X  #ifdef BSD
  1497. X  #include <sys/dir.h>        /* accessing the directory structure    */
  1498. X  #include <sgtty.h>        /* struct for terminal attributes       */
  1499. X! #endif
  1500. X  #ifdef SYSV
  1501. X  #define index    strchr
  1502. X  #define rindex    strrchr
  1503. X  /* #include <termio.h>        /* do this if curses.h doesn't */
  1504. X  #endif
  1505. X  #include "dl.h"
  1506. X  
  1507. X  #define  BLANK           ' '
  1508. X***************
  1509. X*** 54,69 ****
  1510. X  #define  SETENV         "setenv"
  1511. X  
  1512. X  #ifndef  MAILDIR
  1513. X! #define  MAILDIR         "/var/mail"
  1514. X  #endif
  1515. X  #ifndef  MENUDIR
  1516. X  #define  MENUDIR         "/nyx/lib/menus"
  1517. X  #endif
  1518. X  #ifndef  GLOBAL_MACRO_FILE
  1519. X! #define  GLOBAL_MACRO_FILE         "/usr/local/mshell/menus/macros"
  1520. X  #endif
  1521. X  #ifndef  COMMAND_LIST
  1522. X! #define  COMMAND_LIST         "/usr/local/mshell/menus/commands"
  1523. X  #endif
  1524. X  
  1525. X  #ifndef TRUE    /* curses.h may #define */
  1526. X--- 48,63 ----
  1527. X  #define  SETENV         "setenv"
  1528. X  
  1529. X  #ifndef  MAILDIR
  1530. X! #define  MAILDIR         "/usr/spool/mail/"
  1531. X  #endif
  1532. X  #ifndef  MENUDIR
  1533. X  #define  MENUDIR         "/nyx/lib/menus"
  1534. X  #endif
  1535. X  #ifndef  GLOBAL_MACRO_FILE
  1536. X! #define  GLOBAL_MACRO_FILE         "/nyx/lib/menus/macros"
  1537. X  #endif
  1538. X  #ifndef  COMMAND_LIST
  1539. X! #define  COMMAND_LIST         "/nyx/lib/menus/commands"
  1540. X  #endif
  1541. X  
  1542. X  #ifndef TRUE    /* curses.h may #define */
  1543. X***************
  1544. X*** 76,114 ****
  1545. X      char prev [WORDLEN];
  1546. X  };
  1547. X  
  1548. X- #ifndef __STDC__
  1549. X  #define void    int
  1550. X! #endif
  1551. X! 
  1552. X! int     all_blanks();
  1553. X  void    change_directory();
  1554. X! void    check_for_new_mail(char *);
  1555. X! void     helpfile_display();
  1556. X! int    display_menu (char *menu_name, char *menu_array[],
  1557. X!             int *menu_flag, int *idx);
  1558. X! void     display_prompts();
  1559. X! void     execute_command(char *, char *args[]);
  1560. X! void     extract_actions();
  1561. X! void     extract_action_word();
  1562. X  void    filter_leading_trailing_blanks_tabs ();
  1563. X! char     *find_string(char [], char []);
  1564. X! void    find_user_details();
  1565. X! char    *in_string();
  1566. X  void    initialize ();
  1567. X! void     insert_string(char [], char [], int);
  1568. X  void    invoke_unix_system ();
  1569. X! void     M_Shell(char *);
  1570. X! void     read_input_line(char *);
  1571. X! void     remove_string(char [], int, int);
  1572. X! int     replace_string(char [], char [], char []);
  1573. X  void     search_menu_array ();
  1574. X! int     strsearch();
  1575. X  void     set_terminal_attributes ();
  1576. X! int        setenv();
  1577. X! void     wait_for_user();
  1578. X! void    rc();
  1579. X! void    openlog();
  1580. X! void    clear_screen();
  1581. X! char    *strsave(char *);
  1582. X! 
  1583. X! #endif /* _MSHELL_H */
  1584. X--- 70,98 ----
  1585. X      char prev [WORDLEN];
  1586. X  };
  1587. X  
  1588. X  #define void    int
  1589. X! int     all_blanks ();
  1590. X  void    change_directory();
  1591. X! void    check_for_new_mail ();
  1592. X! void     helpfile_display ();
  1593. X! void     display_menu ();
  1594. X! void     display_prompts ();
  1595. X! void     execute_command ();
  1596. X! void     extract_actions ();
  1597. X! void     extract_action_word ();
  1598. X  void    filter_leading_trailing_blanks_tabs ();
  1599. X! char *     find_string ();
  1600. X! void    find_user_details ();
  1601. X! char *  in_string ();
  1602. X  void    initialize ();
  1603. X! void     insert_string ();
  1604. X  void    invoke_unix_system ();
  1605. X! void     M_Shell ();
  1606. X! void     read_input_line ();
  1607. X! void     remove_string ();
  1608. X! int     replace_string ();
  1609. X  void     search_menu_array ();
  1610. X! int     strsearch ();
  1611. X  void     set_terminal_attributes ();
  1612. X! int        setenv ();
  1613. X! void     wait_for_user ();
  1614. Xdiff -rc msh/setenv.c msh.orig/setenv.c
  1615. X*** msh/setenv.c    Sun Mar 14 11:32:19 1993
  1616. X--- msh.orig/setenv.c    Mon Mar 15 23:26:28 1993
  1617. X***************
  1618. X*** 1,13 ****
  1619. X  /*   setenv.c   */
  1620. X  #include "mshell.h"
  1621. X  
  1622. X- static char setenv_rcsid[] = "$Header: /usr3/src/msh/RCS/setenv.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  1623. X- 
  1624. X- #ifdef SYSV
  1625. X- #include <stdlib.h>
  1626. X- #include <string.h>
  1627. X- #endif
  1628. X- 
  1629. X  extern char **environ;
  1630. X  
  1631. X  #define NULL    0
  1632. X--- 1,6 ----
  1633. X***************
  1634. X*** 14,27 ****
  1635. X  #define NO_ROOM    (-1)
  1636. X  #define O_K    0
  1637. X  
  1638. X! setenv(register char *var, register char *value)
  1639. X  {
  1640. X      char **env = environ;
  1641. X      char **newenv, **newenv_base;
  1642. X      char *entry;        /* pointer to the new, malloc'd entry */
  1643. X- #ifndef SYSV
  1644. X      char *getenv(), *malloc(), *calloc();
  1645. X- #endif
  1646. X      int var_len;
  1647. X  
  1648. X      var_len = strlen(var);    /* used often (maybe) */
  1649. X--- 7,19 ----
  1650. X  #define NO_ROOM    (-1)
  1651. X  #define O_K    0
  1652. X  
  1653. X! setenv(var, value)
  1654. X! register char *var, *value;
  1655. X  {
  1656. X      char **env = environ;
  1657. X      char **newenv, **newenv_base;
  1658. X      char *entry;        /* pointer to the new, malloc'd entry */
  1659. X      char *getenv(), *malloc(), *calloc();
  1660. X      int var_len;
  1661. X  
  1662. X      var_len = strlen(var);    /* used often (maybe) */
  1663. X***************
  1664. X*** 71,77 ****
  1665. X   * sar[returned_val] == NULL.
  1666. X   */
  1667. X  
  1668. X! sarsize(register char **sar)
  1669. X  {
  1670. X      register size = 0;
  1671. X  
  1672. X--- 63,70 ----
  1673. X   * sar[returned_val] == NULL.
  1674. X   */
  1675. X  
  1676. X! sarsize(sar)
  1677. X! register char **sar;
  1678. X  {
  1679. X      register size = 0;
  1680. X  
  1681. X***************
  1682. X*** 90,97 ****
  1683. X  {
  1684. X      char **env = environ;
  1685. X  
  1686. X!     printw("--------------------\n");
  1687. X      while (*env != NULL)
  1688. X!         printw("%s\n", *env++);
  1689. X!     printw("--------------------\n");
  1690. X  }
  1691. X--- 83,92 ----
  1692. X  {
  1693. X      char **env = environ;
  1694. X  
  1695. X!     printf("--------------------\n");
  1696. X      while (*env != NULL)
  1697. X!         printf("%s\n", *env++);
  1698. X!     printf("--------------------\n");
  1699. X! 
  1700. X! 
  1701. X  }
  1702. Xdiff -rc msh/settatr.c msh.orig/settatr.c
  1703. X*** msh/settatr.c    Sun Mar 14 11:32:19 1993
  1704. X--- msh.orig/settatr.c    Mon Mar 15 23:26:28 1993
  1705. X***************
  1706. X*** 2,10 ****
  1707. X  #include <sys/time.h>
  1708. X  #include <sys/resource.h>
  1709. X  
  1710. X! static char settatr_rcsid[] = "$Header: /usr3/src/msh/RCS/settatr.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  1711. X! 
  1712. X! void set_terminal_attributes()
  1713. X  {
  1714. X  #ifdef BSD
  1715. X      struct sgttyb  sg;
  1716. X--- 2,8 ----
  1717. X  #include <sys/time.h>
  1718. X  #include <sys/resource.h>
  1719. X  
  1720. X! set_terminal_attributes()
  1721. X  {
  1722. X  #ifdef BSD
  1723. X      struct sgttyb  sg;
  1724. X***************
  1725. X*** 51,58 ****
  1726. X      ioctl ( 0, TCSETA, &t );
  1727. X  #endif
  1728. X  }
  1729. X! 
  1730. X! void set_resource_limits()
  1731. X  {
  1732. X      struct rlimit lim;
  1733. X  
  1734. X--- 49,55 ----
  1735. X      ioctl ( 0, TCSETA, &t );
  1736. X  #endif
  1737. X  }
  1738. X! set_resource_limits()
  1739. X  {
  1740. X      struct rlimit lim;
  1741. X  
  1742. Xdiff -rc msh/string.c msh.orig/string.c
  1743. X*** msh/string.c    Sun Mar 14 11:32:19 1993
  1744. X--- msh.orig/string.c    Mon Mar 15 23:26:28 1993
  1745. X***************
  1746. X*** 1,17 ****
  1747. X  #include "mshell.h"
  1748. X  
  1749. X! #ifdef SYSV
  1750. X! #include <string.h>
  1751. X! #include <stdlib.h>
  1752. X  #endif
  1753. X- #include <ctype.h>
  1754. X  
  1755. X- static char string_rcsid[] = "$Header: /usr3/src/msh/RCS/string.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  1756. X  
  1757. X  /* function to find the position of sub_string in main_string 
  1758. X   * ---------------------------------------------------------- */
  1759. X  
  1760. X! strsearch(char main_string[], char sub_string[])
  1761. X  {
  1762. X      int start_mstring = 0, start_sstring = 0, 
  1763. X          factor = 0, answer, main_pos = 0;
  1764. X--- 1,15 ----
  1765. X  #include "mshell.h"
  1766. X  
  1767. X! #ifdef BSD
  1768. X! #define strchr    index
  1769. X  #endif
  1770. X  
  1771. X  
  1772. X  /* function to find the position of sub_string in main_string 
  1773. X   * ---------------------------------------------------------- */
  1774. X  
  1775. X! strsearch (main_string, sub_string)
  1776. X! char main_string[], sub_string[];
  1777. X  {
  1778. X      int start_mstring = 0, start_sstring = 0, 
  1779. X          factor = 0, answer, main_pos = 0;
  1780. X***************
  1781. X*** 47,53 ****
  1782. X  
  1783. X  /* function to remove string starting at a specified position  
  1784. X   * ----------------------------------------------------------  */
  1785. X! void remove_string(char main_string[], int start_index, int no_of_bytes)
  1786. X  {
  1787. X      int index, offset;
  1788. X  
  1789. X--- 45,55 ----
  1790. X  
  1791. X  /* function to remove string starting at a specified position  
  1792. X   * ----------------------------------------------------------  */
  1793. X! 
  1794. X! remove_string (main_string, start_index, no_of_bytes )
  1795. X! char main_string[];
  1796. X! int  start_index, no_of_bytes;
  1797. X! 
  1798. X  {
  1799. X      int index, offset;
  1800. X  
  1801. X***************
  1802. X*** 60,70 ****
  1803. X          main_string [index] = main_string [index + no_of_bytes];
  1804. X  
  1805. X      main_string[index] = EOS;
  1806. X  }                /* end of function remove_string */
  1807. X  
  1808. X  /* replace string function 
  1809. X   * ----------------------- */
  1810. X! int replace_string(char main_string[], char old_string[], char new_string[])
  1811. X  {
  1812. X      int  pos;
  1813. X  
  1814. X--- 62,76 ----
  1815. X          main_string [index] = main_string [index + no_of_bytes];
  1816. X  
  1817. X      main_string[index] = EOS;
  1818. X+ 
  1819. X  }                /* end of function remove_string */
  1820. X  
  1821. X  /* replace string function 
  1822. X   * ----------------------- */
  1823. X! 
  1824. X! int replace_string (main_string, old_string, new_string)
  1825. X! char main_string[256], old_string[256], new_string[256]; 
  1826. X! 
  1827. X  {
  1828. X      int  pos;
  1829. X  
  1830. X***************
  1831. X*** 82,88 ****
  1832. X  
  1833. X  /* function to find insert sub-string in main-string at a specific position
  1834. X   * ------------------------------------------------------------------------ */
  1835. X! void insert_string(char main_string[], char sub_string[], int position)
  1836. X  {
  1837. X      int i, j, offset;
  1838. X  
  1839. X--- 88,98 ----
  1840. X  
  1841. X  /* function to find insert sub-string in main-string at a specific position
  1842. X   * ------------------------------------------------------------------------ */
  1843. X! 
  1844. X! insert_string ( main_string, sub_string, position )
  1845. X! char main_string [], sub_string [];
  1846. X! int  position;
  1847. X! 
  1848. X  {
  1849. X      int i, j, offset;
  1850. X  
  1851. X***************
  1852. X*** 100,109 ****
  1853. X      }
  1854. X  }
  1855. X  
  1856. X  #define NULL    0
  1857. X  #define STRLEN    256
  1858. X  
  1859. X! char *findvar(char *s)
  1860. X  {
  1861. X      static char var[STRLEN];
  1862. X      char *p, *v = var, *strchr();
  1863. X--- 110,123 ----
  1864. X      }
  1865. X  }
  1866. X  
  1867. X+ #include <ctype.h>
  1868. X+ 
  1869. X  #define NULL    0
  1870. X  #define STRLEN    256
  1871. X  
  1872. X! char *
  1873. X! findvar(s)
  1874. X! char *s;
  1875. X  {
  1876. X      static char var[STRLEN];
  1877. X      char *p, *v = var, *strchr();
  1878. X***************
  1879. X*** 121,127 ****
  1880. X      return(var);
  1881. X  }
  1882. X  
  1883. X! substitute(char *s)
  1884. X  {
  1885. X      char var[STRLEN], *v_in_s, *getenv();
  1886. X  
  1887. X--- 135,142 ----
  1888. X      return(var);
  1889. X  }
  1890. X  
  1891. X! substitute(s)
  1892. X! char *s;
  1893. X  {
  1894. X      char var[STRLEN], *v_in_s, *getenv();
  1895. X  
  1896. X***************
  1897. X*** 139,153 ****
  1898. X      char s[STRLEN];
  1899. X  
  1900. X      while (1) {
  1901. X!         printw("s-> ");
  1902. X!         getstr(s);
  1903. X          substitute(s);
  1904. X!         printw("--> %s\n", s);
  1905. X      }
  1906. X  }
  1907. X  #endif
  1908. X  
  1909. X! all_blanks(char *string)
  1910. X  {
  1911. X      for ( ; ((*string == BLANK) && (*string != EOS)) ; ++string);
  1912. X  
  1913. X--- 154,169 ----
  1914. X      char s[STRLEN];
  1915. X  
  1916. X      while (1) {
  1917. X!         printf("s-> ");
  1918. X!         gets(s);
  1919. X          substitute(s);
  1920. X!         printf("--> %s\n", s);
  1921. X      }
  1922. X  }
  1923. X  #endif
  1924. X  
  1925. X! all_blanks (string)
  1926. X! char * string;
  1927. X  {
  1928. X      for ( ; ((*string == BLANK) && (*string != EOS)) ; ++string);
  1929. X  
  1930. X***************
  1931. X*** 159,167 ****
  1932. X  
  1933. X  /* function to find position  of sub string in a main string 
  1934. X   * ---------------------------------------------------------- */
  1935. X  /* ========================================= */
  1936. X! char *find_string(char main_string[], char sub_string[])
  1937. X  /* ========================================= */
  1938. X  {
  1939. X      int start_mstring = 0, start_sstring = 0, 
  1940. X          factor = 0, answer, main_pos = 0;
  1941. X--- 175,185 ----
  1942. X  
  1943. X  /* function to find position  of sub string in a main string 
  1944. X   * ---------------------------------------------------------- */
  1945. X+ 
  1946. X  /* ========================================= */
  1947. X! char * find_string (main_string, sub_string)
  1948. X  /* ========================================= */
  1949. X+ char main_string[], sub_string[];
  1950. X  {
  1951. X      int start_mstring = 0, start_sstring = 0, 
  1952. X          factor = 0, answer, main_pos = 0;
  1953. X***************
  1954. X*** 201,206 ****
  1955. X--- 219,226 ----
  1956. X   * reads a line of input string from the terminal and keeps doing so until    *
  1957. X   * input string contains no colons                                            *
  1958. X   *****************************************************************************/
  1959. X+ 
  1960. X+ 
  1961. X  struct inp_link {
  1962. X      DL_NODE n;
  1963. X      char *input;
  1964. X***************
  1965. X*** 207,213 ****
  1966. X  };
  1967. X  static DLIST inputstack;
  1968. X  
  1969. X! void read_input_line(char *string)
  1970. X  {
  1971. X      extern int G_shell_ok;
  1972. X      char *p;
  1973. X--- 227,234 ----
  1974. X  };
  1975. X  static DLIST inputstack;
  1976. X  
  1977. X! read_input_line(string)
  1978. X! char *string;
  1979. X  {
  1980. X      extern int G_shell_ok;
  1981. X      char *p;
  1982. X***************
  1983. X*** 214,220 ****
  1984. X  
  1985. X      if (string == NULL) {    /* just read and trash line */
  1986. X          int c;
  1987. X!         while ((c = getch()) != '\n' && c != EOF)
  1988. X              ;
  1989. X          return;
  1990. X      }
  1991. X--- 235,241 ----
  1992. X  
  1993. X      if (string == NULL) {    /* just read and trash line */
  1994. X          int c;
  1995. X!         while ((c = getchar()) != '\n' && c != EOF)
  1996. X              ;
  1997. X          return;
  1998. X      }
  1999. X***************
  2000. X*** 231,239 ****
  2001. X              free(l->input);
  2002. X              dl_delete(inputstack);
  2003. X          } /* ... else get some new input */
  2004. X!         else if (wgetnstr(stdscr, string, OPTLEN) == ERR) {
  2005. X!             printw("End of input -- quitting...\n");
  2006. X!             refresh();
  2007. X              exit(1);
  2008. X          }
  2009. X  
  2010. X--- 252,259 ----
  2011. X              free(l->input);
  2012. X              dl_delete(inputstack);
  2013. X          } /* ... else get some new input */
  2014. X!         else if (gets(string) == NULL) {
  2015. X!             printf("End of input -- quitting...\n");
  2016. X              exit(1);
  2017. X          }
  2018. X  
  2019. X***************
  2020. X*** 240,254 ****
  2021. X          /* if it has a multi-command delim, save rest for next time */
  2022. X  #define MULTI_CMD_DELIM ','
  2023. X          if (p = index(string, MULTI_CMD_DELIM)) {
  2024. X              struct inp_link *l;
  2025. X              *p++ = EOS;
  2026. X!             if ((l = (struct inp_link *)getnode(
  2027. X!                         sizeof(struct inp_link))) &&
  2028. X!                         (l->input=strsave(p)))
  2029. X                  dl_prepend(inputstack, l);
  2030. X          }
  2031. X  
  2032. X!         filter_leading_trailing_blanks_tabs(string);
  2033. X  
  2034. X          /* if macro, then expand & push definition on stack */
  2035. X  #define MACRO_DELIM '#'
  2036. X--- 260,273 ----
  2037. X          /* if it has a multi-command delim, save rest for next time */
  2038. X  #define MULTI_CMD_DELIM ','
  2039. X          if (p = index(string, MULTI_CMD_DELIM)) {
  2040. X+             char *strsave();
  2041. X              struct inp_link *l;
  2042. X              *p++ = EOS;
  2043. X!             if ((l=getnode(sizeof(*l))) && (l->input=strsave(p)))
  2044. X                  dl_prepend(inputstack, l);
  2045. X          }
  2046. X  
  2047. X!         filter_leading_trailing_blanks_tabs (string);
  2048. X  
  2049. X          /* if macro, then expand & push definition on stack */
  2050. X  #define MACRO_DELIM '#'
  2051. X***************
  2052. X*** 256,263 ****
  2053. X              char *mac_lookup();
  2054. X              char *def = mac_lookup(string+1);
  2055. X              struct inp_link *l;
  2056. X!             if (def && (l = (struct inp_link *)getnode(
  2057. X!                         sizeof(struct inp_link))) &&
  2058. X                          (l->input = strsave(def)))
  2059. X                  dl_prepend(inputstack, l);
  2060. X          }
  2061. X--- 275,281 ----
  2062. X              char *mac_lookup();
  2063. X              char *def = mac_lookup(string+1);
  2064. X              struct inp_link *l;
  2065. X!             if (def && (l = getnode(sizeof(*l))) &&
  2066. X                          (l->input = strsave(def)))
  2067. X                  dl_prepend(inputstack, l);
  2068. X          }
  2069. X***************
  2070. X*** 265,271 ****
  2071. X  
  2072. X      /* if not allowing shell, then chop off at funny chars */
  2073. X      if (! G_shell_ok)
  2074. X!         truncate_at_invalid_chars(string);
  2075. X  }  /* end function read_input_line */
  2076. X  
  2077. X  int moreinput()
  2078. X--- 283,290 ----
  2079. X  
  2080. X      /* if not allowing shell, then chop off at funny chars */
  2081. X      if (! G_shell_ok)
  2082. X!         truncate_at_invalid_chars (string);
  2083. X! 
  2084. X  }  /* end function read_input_line */
  2085. X  
  2086. X  int moreinput()
  2087. X***************
  2088. X*** 279,309 ****
  2089. X   * Takes a character string as a parameter                                  *
  2090. X   ****************************************************************************/
  2091. X  
  2092. X! void filter_leading_trailing_blanks_tabs(register char *string)
  2093. X  {
  2094. X      int i, j ;
  2095. X  
  2096. X!     for (i = 0 ; ((string[i] != EOS) && isspace(string[i])); ++i )
  2097. X          ;
  2098. X!     for (j = 0; (string[i] != EOS); j++, i++ ) 
  2099. X!         string[j] = string[i];
  2100. X  
  2101. X      string[j] = EOS;
  2102. X  
  2103. X!     for (i = strlen(string) - 1; (i >= 0 ); i--)
  2104. X!         if ( !isspace(string[i]) )
  2105. X              break;
  2106. X  
  2107. X      string[i+1] = EOS; 
  2108. X  
  2109. X!     return;
  2110. X  }
  2111. X  
  2112. X! char *strsave(char *s)
  2113. X  {
  2114. X!     char *p;
  2115. X! 
  2116. X!     if (s == NULL || (p=(char *)malloc(strlen(s)+1)) == NULL)
  2117. X          return(NULL);
  2118. X      strcpy(p, s);
  2119. X  
  2120. X--- 298,331 ----
  2121. X   * Takes a character string as a parameter                                  *
  2122. X   ****************************************************************************/
  2123. X  
  2124. X! void filter_leading_trailing_blanks_tabs ( string )
  2125. X! char * string;
  2126. X  {
  2127. X      int i, j ;
  2128. X  
  2129. X!     for ( i = 0 ; (( string[i] != EOS ) && (( string[i] == BLANK )
  2130. X!                         ||  ( string[i] == TAB   )) ); ++i )
  2131. X          ;
  2132. X!     for ( j = 0 ; ( string[j] != EOS ) ; ++j ) 
  2133. X!         string[j] = string[j + i];
  2134. X  
  2135. X      string[j] = EOS;
  2136. X  
  2137. X!     for ( i = strlen(string) - 1 ; ( i >= 0 ) ; --i )
  2138. X!         if (( string[i] != BLANK ) && ( string[i] != TAB ))
  2139. X              break;
  2140. X  
  2141. X      string[i+1] = EOS; 
  2142. X  
  2143. X!     return ;
  2144. X  }
  2145. X  
  2146. X! char *
  2147. X! strsave(s)
  2148. X! char *s;
  2149. X  {
  2150. X!     char *p, *malloc();
  2151. X!     if (s == NULL || (p=malloc(strlen(s)+1)) == NULL)
  2152. X          return(NULL);
  2153. X      strcpy(p, s);
  2154. X  
  2155. X***************
  2156. X*** 311,319 ****
  2157. X  }
  2158. X  
  2159. X  /* assumes d was malloc'd -- then makes large enough to cat s onto it */
  2160. X! char *strcatsave(char *d, char *s)
  2161. X  {
  2162. X!     if (d && (d = realloc(d, strlen(d)+strlen(s)+1)))
  2163. X          strcat(d, s);
  2164. X  
  2165. X      return(d);
  2166. X--- 333,345 ----
  2167. X  }
  2168. X  
  2169. X  /* assumes d was malloc'd -- then makes large enough to cat s onto it */
  2170. X! char *
  2171. X! strcatsave(d, s)
  2172. X! char *d, *s;
  2173. X  {
  2174. X!     char *realloc();
  2175. X! 
  2176. X!     if (d && (d = realloc(d, strlen(d)+strlen(s)+2)))
  2177. X          strcat(d, s);
  2178. X  
  2179. X      return(d);
  2180. X***************
  2181. X*** 320,335 ****
  2182. X  }
  2183. X  
  2184. X  /* replace _ with space */
  2185. X! char *ufix(char *s)
  2186. X  {
  2187. X!     register char *p;
  2188. X!     for (p=s; p && *p; p++)
  2189. X          if (*p == '_')
  2190. X              *p = ' ';
  2191. X      return(s);
  2192. X  }
  2193. X  
  2194. X! strcontains(char *s, char *chars)
  2195. X  {
  2196. X      while (*chars)
  2197. X          if (index(s, *chars++))
  2198. X--- 346,364 ----
  2199. X  }
  2200. X  
  2201. X  /* replace _ with space */
  2202. X! char *
  2203. X! ufix(s)
  2204. X! char *s;
  2205. X  {
  2206. X!     char *p;
  2207. X!     for (p = s; p && *p; p++)
  2208. X          if (*p == '_')
  2209. X              *p = ' ';
  2210. X      return(s);
  2211. X  }
  2212. X  
  2213. X! strcontains(s, chars)
  2214. X! char *s, *chars;
  2215. X  {
  2216. X      while (*chars)
  2217. X          if (index(s, *chars++))
  2218. X***************
  2219. X*** 338,344 ****
  2220. X  }
  2221. X  
  2222. X  /* remove string from no-no chars on */
  2223. X! truncate_at_invalid_chars(char *string)
  2224. X  {
  2225. X      char *p, *index();
  2226. X      /* XXX - update to use strpbrk */
  2227. X--- 367,374 ----
  2228. X  }
  2229. X  
  2230. X  /* remove string from no-no chars on */
  2231. X! truncate_at_invalid_chars (string)
  2232. X! char *string;
  2233. X  {
  2234. X      char *p, *index();
  2235. X      /* XXX - update to use strpbrk */
  2236. Xdiff -rc msh/xsystem.c msh.orig/xsystem.c
  2237. X*** msh/xsystem.c    Sun Mar 14 11:32:20 1993
  2238. X--- msh.orig/xsystem.c    Mon Mar 15 23:26:29 1993
  2239. X***************
  2240. X*** 5,18 ****
  2241. X  static char sccsid[] = "@(#)system.c    5.2 (Berkeley) 3/9/86";
  2242. X  #endif LIBC_SCCS and not lint
  2243. X  
  2244. X- static char xsystem_rcsid[] = "$Header: /usr3/src/msh/RCS/xsystem.c,v 1.1 1993/03/14 19:32:07 root Exp root $";
  2245. X- 
  2246. X  #include    <signal.h>
  2247. X  
  2248. X! system(char *s)
  2249. X  {
  2250. X      int status, pid, w;
  2251. X!     register void (*istat)(int), (*qstat)(int);
  2252. X  
  2253. X      if ((pid = vfork()) == 0) {
  2254. X          execl("/bin/csh", "csh", "-fc", s, 0);
  2255. X--- 5,17 ----
  2256. X  static char sccsid[] = "@(#)system.c    5.2 (Berkeley) 3/9/86";
  2257. X  #endif LIBC_SCCS and not lint
  2258. X  
  2259. X  #include    <signal.h>
  2260. X  
  2261. X! system(s)
  2262. X! char *s;
  2263. X  {
  2264. X      int status, pid, w;
  2265. X!     register int (*istat)(), (*qstat)();
  2266. X  
  2267. X      if ((pid = vfork()) == 0) {
  2268. X          execl("/bin/csh", "csh", "-fc", s, 0);
  2269. X
  2270. END_OF_FILE
  2271.   if test 36374 -ne `wc -c <'sysvdiffs.B'`; then
  2272.     echo shar: \"'sysvdiffs.B'\" unpacked with wrong size!
  2273.   elif test -f 'sysvdiffs.A' ; then
  2274.     echo shar: Combining  \"'sysvdiffs.mar93'\" \(61693 characters\)
  2275.     cat 'sysvdiffs.A' 'sysvdiffs.B' > 'sysvdiffs.mar93'
  2276.     if test 61693 -ne `wc -c <'sysvdiffs.mar93'`; then
  2277.       echo shar: \"'sysvdiffs.mar93'\" combined with wrong size!
  2278.     else
  2279.       rm sysvdiffs.A sysvdiffs.B 
  2280.     fi
  2281.   fi
  2282.   # end of 'sysvdiffs.B'
  2283. fi
  2284. echo shar: End of archive 1 \(of 3\).
  2285. cp /dev/null ark1isdone
  2286. MISSING=""
  2287. for I in 1 2 3 ; do
  2288.     if test ! -f ark${I}isdone ; then
  2289.     MISSING="${MISSING} ${I}"
  2290.     fi
  2291. done
  2292. if test "${MISSING}" = "" ; then
  2293.     echo You have unpacked all 3 archives.
  2294.     rm -f ark[1-9]isdone
  2295. else
  2296.     echo You still must unpack the following archives:
  2297.     echo "        " ${MISSING}
  2298. fi
  2299. exit 0
  2300. exit 0 # Just in case...
  2301.