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

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1) part 12 of 14
  4. Message-ID: <446@pcbox.UUCP>
  5. Date: 26 Dec 90 20:15:41 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 12 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file utilities.d/libgeti.d/GetInput.3X continued
  12. #
  13. CurArch=12
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file utilities.d/libgeti.d/GetInput.3X"
  24. sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/GetInput.3X
  25. X                This is validated against the file /usr/lib/acct/holidays by default.  Modify GetInput.h to change default.
  26. X    GT_Today        - date must be greater than todays date.
  27. X    GE_Today        - greater than or equal to todays date.
  28. X    LT_Today        - less than todays date.
  29. X    LE_Today        - less than or equal to todays date.
  30. X.fi
  31. X.TP
  32. XTIME
  33. XA time field.
  34. X.br
  35. XValid mask characters:
  36. X.nf
  37. X    HH    hours  (01-12)
  38. X    MM    minutes  (00-59)
  39. X    SS    seconds  (00-59)
  40. X    TT    tenths  (00-99)
  41. X    II    military hours  (00-24)
  42. X.fi
  43. XSome examples:
  44. X.nf
  45. X    HH:MM
  46. X    HH:MM:SS
  47. X    HH:MM:SS:TT
  48. X    II:MM
  49. X    II:MM:SS
  50. X    II:MM:SS:TT
  51. X.fi
  52. X.TP
  53. XSET
  54. XThis field type specifies a set of values that are acceptable in the input 
  55. Xfield.
  56. XThe acceptable values within the set are specified in the \fIFldRange\fP 
  57. Xargument.  
  58. XThe user selects one of the set values specified in the field range by
  59. Xpressing the space bar, which will toggle through the set values,
  60. Xor by pressing the first character in the desired value.
  61. X
  62. XThe format of the FldRange can only be comma separated values 
  63. X(ex. "CA,ID,TX").  
  64. XRange values, such as "1-5", don't work.  You would have to say "1,2,3,4,5".
  65. X.br
  66. XThe FldLength is automatically set to the longest set value in the FldRange.
  67. X.TP
  68. XMENU
  69. XThis field type is similar to the SET type.  The difference is when the user
  70. Xattempts to type something in the field a pop-up menu of available choices
  71. Xare displyed, as specified in field_range.  
  72. XThe user makes a selection by hi-lighting the choice and pressing return.
  73. X.br
  74. XSee SET type for specifying the FldRange.
  75. XThe limit is ten items in the FldRange.
  76. X.TP
  77. XPROTECT
  78. XThis X's out the field so what is typed on the keyboard can not be seen on
  79. Xthe screen.  Useful for password entry.
  80. X.RE
  81. X. \ ---------------------------------
  82. X.TP
  83. XFldAdjust
  84. XIndicates whether to adjust the text right or left within the field
  85. Xand whether or not to zero or blank fill the field.
  86. X.RS 6
  87. X.TP 15
  88. XNOFILL
  89. Xno action.
  90. X.TP
  91. XRTADJ_ZFILL
  92. Xright adjust, zero fill
  93. X.TP
  94. XRTADJ_BFILL
  95. Xright adjust, blank fill
  96. X.TP
  97. XLFADJ_ZFILL
  98. Xleft adjust, zero fill
  99. X.TP
  100. XLFADJ_BFILL
  101. Xleft adjust, blank fill
  102. X.RE
  103. X. \ ---------------------------------
  104. X.TP 6
  105. XFldType
  106. XThis argument describes the memory variable that is to hold
  107. Xthe input data.  The address that you loaded into "&Fld".
  108. X.RS 6
  109. X.TP 10
  110. XCHAR
  111. Xcharacter field
  112. X.TP
  113. XINT
  114. Xinteger
  115. X.TP
  116. XSHORT
  117. Xshort integer
  118. X.TP
  119. XLONG
  120. Xlong integer
  121. X.TP
  122. XDOUBLE
  123. Xdouble
  124. X.TP
  125. XFLOAT
  126. Xfloating point
  127. X.TP
  128. XMONEY
  129. Xdouble which accepts only two decimal positions.
  130. X.RE
  131. X. \ ---------------------------------
  132. X.TP 11
  133. XFldExit
  134. X.RS 6
  135. X.TP 10
  136. XAUTONEXT
  137. XGetInput() will exit, with the value of KEY_RETURN, when the last character 
  138. Xin the field is keyed in.
  139. X.TP
  140. XNOAUTO
  141. XWill not exit field until a accept key (see defining keyboard keys) is pressed.
  142. X.RE
  143. X. \ ---------------------------------
  144. X.TP
  145. XMustEnter
  146. X.RS 6
  147. X.TP 12
  148. XMUSTENTER
  149. XThis is a must enter field and the value of FldMin must be
  150. Xentered before exiting field.
  151. X.TP
  152. XNOMUST
  153. XNot a must enter field.
  154. X.RE
  155. X. \ ---------------------------------
  156. X.RE
  157. X.TP 6
  158. XErrRow
  159. XIndicates what row/column to display an error message if one occurs.
  160. XThe row specified is for stdscr.
  161. XIf a optional column is to be specified on where to start the message, the
  162. Xformat would be for example 2302 where 23 is the row and 02 is the column.
  163. XOtherwise, a default of column zero is used.
  164. XGetInput will do a clrtoeol() before displaying the error message, therefore,
  165. Xthe entire row must be given over to GetInput.
  166. XIf this row is outside the boundary of the window unpredictable results will
  167. Xoccur, for example, winch() will return garbage.
  168. X.TP
  169. XMsgRow
  170. XIndicates what row to display help messages.
  171. XThe row specified is for stdscr.
  172. XIf a optional column is to be specified on where to start the message, the
  173. Xformat would be for example 2202 where 22 is the row and 02 is the column.
  174. XOtherwise, a default of column zero is used.
  175. XGetInput will do a clrtoeol() before displaying the message, therefore,
  176. Xthe entire row must be given over to GetInput.
  177. XIf this row is outside the boundary of the window unpredictable results will
  178. Xoccur, for example, winch() will return garbage.
  179. X.RS 6
  180. X.TP 10
  181. XNULL
  182. XNo active message line.  Only if PromptMsg == NOMSG.
  183. X.RE
  184. X.TP
  185. X*PromptMsg
  186. XPrompt message to be displayed.  The prompt message is always displayed
  187. Xto stdscr, regardless of the win specified.
  188. X.RS 6
  189. X.TP 10
  190. XNOMSG
  191. XNo message to be displayed.
  192. X.RE
  193. X.TP
  194. XHelpFile
  195. XFile name containing on-line help messages.  Current directory
  196. Xis searched first for helpfile and then getenv("HELPDIR") directory is
  197. Xsearched.
  198. X.RS 6
  199. X.TP 10
  200. XNOHELP
  201. XNo help file is available for this field.
  202. X
  203. X.PP
  204. XThe default helpfile (GetInput.hlp) is shown below.  Where this file is
  205. Xinstalled will vary from machine to machine.
  206. X
  207. X.nf
  208. X\fBGETINPUT\fP
  209. X .TITLE GETINPUT Help
  210. XMover Keys:
  211. X        KEY_RETURN  (^m)    Traverse forwards through the fields.
  212. X        KEY_DOWN  (^j)      Traverse forwards through the fields.
  213. X        KEY_UP  (^k)        Traverse backwards through the fields.
  214. X        KEY_TAB  (^i)       Fast forward through the fields.
  215. X        KEY_BTAB            Fast reverse through the fields.
  216. XField Editing Keys:
  217. X        KEY_BEG  (^b)       Place cursor at beginning of field.
  218. X        KEY_END  (^e)       Place cursor at end of input in field.
  219. X        KEY_RIGHT  (^l)     Forward space within the field.
  220. X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
  221. X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
  222. X        KEY_EOL  (^d)       Delete from cursor to end of field.
  223. X        KEY_DL  (^c)        Clear field and home cursor.
  224. X        KEY_DC  (^x)        Delete a character.
  225. X        KEY_IC  (^t)        Toggle between type-over and insert mode.
  226. XOther Keys:
  227. X        KEY_HELP  (?)       Display help screen.
  228. X        KEY_REFRESH  (^r)   Redraw the screen.
  229. X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
  230. X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
  231. X        KEY_SAVE  (^f)      Save screen to a file.
  232. X        KEY_PRINT  (^p)     Print screen to lp.
  233. X\fBGETINPUT\fP
  234. X
  235. X
  236. X
  237. X\fBpopmenu\fP
  238. X.TITLE Pop-Up Menu Help
  239. XSELECTING OPTIONS:
  240. X    To select an option press the "up arrow key",
  241. X    "k", "down arrow key", "j" to place bar on
  242. X    option and press "return".
  243. X
  244. X    KEY_CANCEL (esc)   - Cancel selection.
  245. X\fBpopmenu\fP
  246. X
  247. X
  248. X
  249. X\fBhelp\fP
  250. X.TITLE Using Help
  251. XHelp displays consist of a description displayed in a window.
  252. XIf the description doesn't fit in the window, the Up Arrow and
  253. XDown Arrow keys can be used to view a few more lines of the 
  254. Xdisplay.  Exiting the help system will return the display to 
  255. Xthe state it was in when you asked for help.
  256. X
  257. X   The following keys are active in help:
  258. X        KEY_CANCEL  (esc)   Exit help.
  259. X        KEY_DOWN  (^j)      View a few more lines.
  260. X        KEY_UP  (^k)        View the previous lines.
  261. X        KEY_BEG  (^b)       Display first page.
  262. X        KEY_END  (^e)       Display last page.
  263. X        KEY_TOC  (^t)       Display table of contents.
  264. X\fBhelp\fP
  265. X.fi
  266. X.RE
  267. X.TP
  268. XHelpTag
  269. XTag in help file where messages are to be found.  The tag 
  270. Xsurrounds the help message.  For example:
  271. X.nf
  272. X
  273. Xhelptag
  274. X[ .TITLE  Title line goes here. ]
  275. XI put any help message for the user between the tags.  
  276. XIt can be any length as it will be displayed one screen 
  277. Xat a time.
  278. XThe following screen attributes may be used:
  279. X\\S  =  Standout
  280. X\\B  =  Bold
  281. X\\U  =  Underline
  282. X\\D  =  Dim
  283. X\\R  =  Reverse video
  284. X\\L  =  Blink
  285. X\\N  =  Normal (reset)
  286. X
  287. X\\BThis text is in bold face.  \\NBack in normal mode.
  288. Xhelptag
  289. X
  290. XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
  291. Xis to be contained in the table of contents menu.  The following is the
  292. Xsyntax for this tagname.
  293. XTABLE_OF_CONTENTS
  294. Xhelpfile   tagname   description
  295. XTABLE_OF_CONTENTS
  296. X.fi
  297. X.RS 6
  298. X.TP 10
  299. XNOTAG
  300. XNo tag.  Should only be used if (HelpFile == NOHELP).
  301. X.RE
  302. X.SH EXAMPLE
  303. X.nf
  304. X#include <curses.h>
  305. X#include "GetInput.h"
  306. X
  307. Xmain ()
  308. X{
  309. X    union FldUnion Fld;
  310. X    char    name[20], tempstring[50];
  311. X    int    exitcode;
  312. X
  313. X   initscr ();
  314. X   cbreak ();
  315. X   noecho ();
  316. X   nonl ();
  317. X   keypad (stdscr, TRUE);
  318. X
  319. X   name[0] = '\\0';
  320. X   Fld.strVal = name;
  321. X   exitcode = GetInput (stdscr, 2, 0, &Fld, A_REVERSE, NOMASK, 
  322. X                  NORANGE, 20, 0, UPPER_AN, NOFILL, CHAR, 
  323. X                  NOAUTO, MUSTENTER, 21, 20, 
  324. X                  "Please enter your name.", NOHELP, NOTAG);
  325. X
  326. X   Fld.strVal = tempstring;
  327. X   exitcode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "HH:MM:SS:TT",
  328. X                  NORANGE, 6, 6, TIME, NOFILL, CHAR, AUTONEXT, 
  329. X                  NOMUST, 20, 21, "Time Field HH:MM:SS:TT", 
  330. X                  "myhelpfile", "field2");
  331. X
  332. X   Fld.strVal = tempstring;
  333. X   exitcode = GetInput (stdscr, 8, 0, &Fld, A_NORMAL, 
  334. X                  "(999) 999-9999", NORANGE, 10, 5, NUMERIC, 
  335. X                  RTADJ_ZFILL, CHAR, NOAUTO, MUSTENTER, 20, NULL, 
  336. X                  NOMSG, NOHELP, NOTAG);
  337. X
  338. X   Fld.strVal = tempstring;
  339. X   exitcode = GetInput (stdscr, 9, 1, &Fld, A_REVERSE, NOMASK,
  340. X                  "CA, NV, ID", 2, 2, SET, NOFILL, CHAR, NOAUTO,
  341. X                  NOMUST, 20, 20, "Select your state.", NOHELP, 
  342. X                  NOTAG);
  343. X   endwin ();
  344. X}
  345. X.fi
  346. X.SH AUTHOR
  347. XIrving Griesman  (original author)
  348. X.br
  349. XEnhanced & Maintained by Paul J. Condie
  350. X.br
  351. X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
  352. X
  353. X.SH FILES
  354. XGetInput.hlp    - default GetInput help file.
  355. X
  356. X.SH DIAGNOSTICS
  357. XGetInput returns the the decimal value of the key pressed from the getch()
  358. Xfunction.  If the key pressed has an associated curses key GetInput returns
  359. Xthe value of the curses key.  See Defining keyboard keys.
  360. X
  361. X.SH SEE ALSO
  362. Xmenu(1), curses(3X), popmenu(3).
  363. X
  364. X.SH WARNING
  365. XPutting a field on the same row as your message row or error row may cause
  366. Xunpredictable results.  This is not recommended.
  367. X
  368. X.SH BUGS
  369. XThere is a bug in curses when you call getch() which this routine does.
  370. XWhen in keypad() mode and an ESC character is read, curses 
  371. Xdoes a timed read (1 second) waiting for other characters to appear.  if
  372. Xsome other characters are received within the one second time interval,
  373. Xcurses attempts to match the received string with a caps string defined for the terminal (i.e. ESC[A, ESC[B are arrow keys for a vt100 type terminal)
  374. Xand then returns a #defined int value which can be tested for easily.
  375. XIn some cases untrapped alarm calls occur.  The solution is to trap (ignore)
  376. Xalarm calls.
  377. X.PP
  378. XOn a mustenter field with a fldmin specified a control key (i.e. KEY_DOWN, etc.)
  379. Xwill exit the
  380. Xfield if that is the first key the user presses.  Once the user has tried
  381. Xto input a value in the field even if he clears the field the control key
  382. Xwill not exit until fldmin is inputed.
  383. X
  384. X.nf
  385. XThe following example does not turn the reverse video off when you leave the field on the sun.
  386. Xrc = GetInput (stdscr, 0, 1, &Fld, A_REVERSE, "VVVVVV.VVVVV.VV.VV.V", 
  387. X    NORANGE, 16, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, MUSTENTER, 
  388. X    ERRROW, MSGROW, "Please enter niu location.", "cfgsrn.hlp", NOTAG);
  389. X.fi
  390. X
  391. X.PP
  392. XA core dump of (DisPrmpt at line 37) indicates the string was not null terminated.
  393. SHAR_EOF
  394. echo "File utilities.d/libgeti.d/GetInput.3X is complete"
  395. chmod 0644 utilities.d/libgeti.d/GetInput.3X || echo "restore of utilities.d/libgeti.d/GetInput.3X fails"
  396. echo "x - extracting utilities.d/libgeti.d/RingMenu.3 (Text)"
  397. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/RingMenu.3 &&
  398. X. \ @(#)RingMenu.3    1.1 DeltaDate 1/22/90 ExtrDate 1/22/90 
  399. X.po 6
  400. X.TH RINGMENU 3L
  401. X.SH NAME
  402. XRingMenu \- Produce a Ring Menu.
  403. X
  404. X.SH SYNOPSIS
  405. X.B "int RingMenu ( win, line, optNum, title, optTable )"
  406. X.B "WINDOW *win ;"
  407. X.B "unsigned short line, optNum ;"
  408. X.B "char *title, *optTable[][2] ;"
  409. X
  410. X.SH DESCRIPTION
  411. XRingMenu accepts a two dimensional pointers arrary, optTable, as specification to display a ring 
  412. Xmenu.  OptTable[][0] is the option name, while optTable[][1] is the description for the option.  The 
  413. Xlast pair of entry in OpTable must be NULL to signify the end of the menu.  The optNumth option is 
  414. Xhighlighted, or the first item will be highlighted if optNum is 0.  The ring menu will be displayed on 
  415. Xwindow win on line number line.  Description for option is displayed on the line+1 line.  An option-
  416. Xal title may be displayed to the left of the ring menu or NULL may be passed if no title is desired..
  417. X
  418. XUser may use the arrow keys, or the equivalent control keys to move the highlighted option, and then 
  419. Xhit the RETURN key to select the desired option.  Or a capital letter match may also select a particu-
  420. Xlar option, there is no need to hit RETURN in this case.
  421. X
  422. XRingMenu accepts at most 20 options.
  423. X
  424. X.SH AUTHOR
  425. XSam S. Lok
  426. X
  427. X.SH RETURN VALUES
  428. XThe position number of the selected option.  The first option being 1.
  429. X
  430. X.SH DIAGNOSTICS
  431. XNone.
  432. X
  433. X.SH EXAMPLES
  434. X    short    option = 1 ;
  435. X
  436. X    static    char    *emp_menu[][2] = {    /* The menu */
  437. X        { "Query",    "Query existing employee" },
  438. X        { "Add",    "Add new employee" },
  439. X        { "Change",    "Update existing employee" },
  440. X        { "Delete",    "Delete existing employee" },
  441. X        { "Print",    "Screen dump to printer" },
  442. X        { "Exit",    "Return to menu" },
  443. X        { NULL,    NULL } 
  444. X    } ;
  445. X
  446. X    option = RingMenu( stdscr, ERRLINE, option, "Employee:", emp_menu ) ;
  447. X
  448. X.SH FILES
  449. XNone.
  450. X
  451. X.SH SEE ALSO
  452. Xmenu(1L), popmenu(3L), GetInput(3L).
  453. X
  454. X.SH WARNINGS
  455. XRingMenu ignores options more than 20.
  456. XRingMenu.c makes uses of GetInput(3L)'s GetInput.h, keys.h, ShowHelp() and ScrnPrnt(), other-
  457. Xwise, it is very much self contained.
  458. SHAR_EOF
  459. chmod 0444 utilities.d/libgeti.d/RingMenu.3 || echo "restore of utilities.d/libgeti.d/RingMenu.3 fails"
  460. echo "x - extracting utilities.d/libgeti.d/ShowHelp.3 (Text)"
  461. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.3 &&
  462. X. \ %W% DeltaDate %G% ExtrDate %H% 
  463. X.po 6
  464. X.TH SHOWHELP 3 "libgeti"
  465. X
  466. X.SH NAME
  467. XShowHelp \- creates and displays a help window using curses
  468. X
  469. X.SH SYNOPSIS
  470. X.B "void  ShowHelp (help_file_name, tag, error_row)
  471. X.br
  472. X.B "char    help_file_name[];"
  473. X.br
  474. X.B "char    tag[];"
  475. X.br
  476. X.B "int    error_row;"
  477. X
  478. X.SH \s9DESCRIPTION\s0
  479. X.B ShowHelp
  480. Xsearches the \fIhelp_file_name\fP for the specified \fItag\fP, creates and
  481. Xcenters a curses window on the screen.  Then displays the content of the tag
  482. Xin the window.  The size of the help window is automatically adjusted to the 
  483. Xsize of message to be displayed.
  484. X
  485. X.SS ARGUMENTS
  486. X.TP 6
  487. Xhelp_file_name
  488. XThe unix file name containing the help message to be displayed.
  489. X.TP 6
  490. Xtag
  491. XThe tag in the help file that contains the help message to be displayed.
  492. X.TP 6
  493. Xerror_row
  494. XThe row on the screen (stdscr) to display any error messages.
  495. X
  496. X.SH HELP FILE SYNTAX
  497. XA help file may consist of multiple help tags.  Any text found outside a helptag
  498. Xis ignored.  See the following example.
  499. X
  500. X.nf
  501. X\fBhelptag\fP
  502. X[ .TITLE  A optional Title line goes here. ]
  503. XI put any help message for the user between the tags.  
  504. XIt can be any length as it will be displayed one screen 
  505. Xat a time.
  506. XThe following screen attributes may be used:
  507. X\\S  =  Standout
  508. X\\B  =  Bold
  509. X\\U  =  Underline
  510. X\\D  =  Dim
  511. X\\R  =  Reverse video
  512. X\\L  =  Blink
  513. X\\N  =  Normal (reset)
  514. X
  515. X\\BThis text is in bold face.  \\NBack in normal mode.
  516. X\fBhelptag\fP
  517. X
  518. X
  519. XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
  520. Xis to be contained in the table of contents menu.  The following is the
  521. Xsyntax for this tagname.
  522. XTABLE_OF_CONTENTS
  523. Xhelpfile   tagname   description
  524. XTABLE_OF_CONTENTS
  525. X
  526. X
  527. X\fBhelp\fP
  528. X .TITLE Using Help
  529. XHelp displays consist of a description displayed in a window.
  530. XIf the description doesn't fit in the window, the Up Arrow and
  531. XDown Arrow keys can be used to view a few more lines of the 
  532. Xdisplay.  Exiting the help system will return the display to 
  533. Xthe state it was in when you asked for help.
  534. X
  535. X   The following keys are active in help:
  536. X        KEY_CANCEL  (esc)   Exit help.
  537. X        KEY_DOWN  (^j)      View a few more lines.
  538. X        KEY_UP  (^k)        View the previous lines.
  539. X        KEY_BEG  (^b)       Display first page.
  540. X        KEY_END  (^e)       Display last page.
  541. X        KEY_TOC  (^t)       Display table of contents.
  542. X\fBhelp\fP
  543. X.fi
  544. X
  545. X.SH AUTHOR
  546. XPaul J. Condie         2/89
  547. X.br
  548. X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
  549. X
  550. X.SH SEE ALSO
  551. Xcurses(3X).
  552. SHAR_EOF
  553. chmod 0644 utilities.d/libgeti.d/ShowHelp.3 || echo "restore of utilities.d/libgeti.d/ShowHelp.3 fails"
  554. echo "x - extracting utilities.d/libgeti.d/drawbox.3 (Text)"
  555. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.3 &&
  556. X. \ @(#)drawbox.3    1.2 DeltaDate 1/22/90 ExtrDate 1/22/90 
  557. X.po 6
  558. X.TH DRAWBOX 3 "libgeti"
  559. X
  560. X.SH NAME
  561. Xdrawbox \- draws a box in a curses window
  562. X
  563. X.SH SYNOPSIS
  564. X.B #define    DumbLine    1
  565. X.br
  566. X.B #define    StandoutLine    2
  567. X.br
  568. X.B #define    SingleLine    3    /* alternate character line */
  569. X.br
  570. X.B #define    MosaicLine    4    /* alternate character line */
  571. X.br
  572. X.B #define    DiamondLine    5    /* alternate character line */
  573. X.br
  574. X.B #define    DotLine        6    /* alternate character line */
  575. X.br
  576. X.B #define    PlusLine    7    /* alternate character line */
  577. X
  578. Xextern int    KeyHelp;
  579. X
  580. X.B "void  drawbox (win, from_row, from_col, to_row, to_col, trythis, trythat, vscroll, help\fI, percent\fP)"
  581. X.br
  582. X.B "WINDOW    *win;"
  583. X.br
  584. X.B "int    from_row;"
  585. X.br
  586. X.B "int    from_col;"
  587. X.br
  588. X.B "int    to_row;"
  589. X.br
  590. X.B "int    to_col;"
  591. X.br
  592. X.B "int    trythis;"
  593. X.br
  594. X.B "int    trythat;"
  595. X.br
  596. X.B "int    vscroll;"
  597. X.br
  598. X.B "int    help;"
  599. X.br
  600. X.B "\fIfloat    percent;\fP"
  601. X
  602. X.SH DESCRIPTION
  603. X.B Drawbox
  604. Xdraws a box within a curses window.  This is similar to the box(3X) function
  605. Xin curses, but provides more flexibility in where to draw the box and what
  606. Xthe box should look like.
  607. X
  608. X.SS ARGUMENTS
  609. X.TP 6
  610. Xwin
  611. XThe curses window to draw the box in.
  612. X.TP 6
  613. Xfrom_row, from_col, to_row, to_col
  614. XDimensions of the box.  Upper left corner and lower right corner of the box.
  615. XTo draw a box around the whole window (like box(3) does) 
  616. Xtry: \fI1,1, LINES,COLS\fP as the box dimensions.
  617. X.TP 6
  618. Xtrythis
  619. XWhat line type to try first.  Any one of the #defines shown above.  
  620. XIf the terminal
  621. Xdoes not support alternate character lines then drawbox will \fItrythat\fP line.
  622. X.TP 6
  623. Xtrythat
  624. XWhat line to use if trythis doesn't work.  This should not be a
  625. Xalternate character line.
  626. X.TP 6
  627. Xvscroll
  628. XIf TRUE vertical scroll bars will be drawn in the right side of the box.
  629. X.TP 6
  630. Xhelp
  631. XIf TRUE the help key (KeyHelp) will be displayed in the lower right corner 
  632. Xof the box to indicate help is available.
  633. X.TP 6
  634. Xpercent
  635. XAn optional decimal value between 0.0 and 1.0 to indicate the position of the
  636. Xvertical scroll bars in the right side of the box.  Any other value or an
  637. Xundefined value will put the scoll bar at the bottom.
  638. X
  639. X.SH AUTHOR
  640. XPaul J. Condie         7/87
  641. X.br
  642. X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
  643. X
  644. X.SH EXAMPLE
  645. X.nf
  646. X#include    <curses.h>
  647. X
  648. X
  649. Xmain ()
  650. X{
  651. X    drawbox (stdscr, 1,1, LINES,COLS, SingleLine, StandoutLine, TRUE, TRUE, 0.5);
  652. X}
  653. X.fi
  654. X
  655. X.SH SEE ALSO
  656. Xcurses(3X).
  657. SHAR_EOF
  658. chmod 0644 utilities.d/libgeti.d/drawbox.3 || echo "restore of utilities.d/libgeti.d/drawbox.3 fails"
  659. echo "x - extracting utilities.d/libgeti.d/popmenu.3 (Text)"
  660. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.3 &&
  661. X.po 6
  662. X.TH POPMENU 3 "libgeti"
  663. X
  664. X.SH NAME
  665. Xpopmenu \- runs a popup type menu
  666. X
  667. X.SH SYNOPSIS
  668. X.B #define    NEWMENU        0
  669. X.br
  670. X.B #define    CREATEMENU    -2
  671. X.br
  672. X.B #define    DIMWINDOW    -1
  673. X.br
  674. X.br
  675. X.B extern int    KeyHelp;
  676. X.br
  677. X.B extern int    KeyCancel;
  678. X.br
  679. X.B extern int    KeyUp;
  680. X.br
  681. X.B extern int    KeyDown;
  682. X.br
  683. X
  684. X.B "int  popmenu (menu_id, searchStr)"
  685. X.br
  686. X.B "int        menu_id;"
  687. X.br
  688. X.B "char    *searchStr;"
  689. X
  690. X.SH \s9DESCRIPTION\s0
  691. X.B Popmenu
  692. Xis a generic curses popup menu program.  The synopsis of popmenu will vary
  693. Xdepending on whether you are initializing a new menu or running
  694. Xa previously defined menu.  The above synopsis will run menu (menu_id)
  695. Xthat you have previously defined.
  696. X.PP
  697. XAn optional search string,\fI*searchStr\fP, is needed as the 
  698. Xsecond parameter in order for \fIpopmenu\fP to perform initial start-up
  699. Xsearch.  If (char *)NULL is passed, no start-up search will be done
  700. Xand the first or last selected option will be the default option.
  701. X.PP
  702. XPopmenu will return the number (counting from the top of the menu)
  703. Xof the item selected.  If the user selected the second item in the menu
  704. Xthen \fIpopmenu\fP will return (2).
  705. X.br
  706. XA negative return value indicates the user canceled the selection.
  707. X.PP
  708. XAfter you run a menu you will need to touchwin(stdscr); wrefresh(stdscr);
  709. Xin order to remove the popmenu from the screen.
  710. X.PP
  711. XThe KeyCancel defines the key where the user does not want to make any
  712. Xchoice.  The KeyHelp defines what key is to display the help.  The KeyUp and
  713. XKeyDown inaddition to the curses arrow key move the select bar up and down.
  714. XKeyIC is used to toggle between \fIfull\fP and \fIfirst\fP character matching
  715. Xschemes.
  716. X
  717. X.SH DEFINE NEW MENU
  718. X.B "popmenu (action, menu_id, row, column, title, helpfile, win_size, sizeof( option_base ), option_base, mtype )"
  719. X.br
  720. X.B "int    action;"
  721. X.br
  722. X.B "int    menu_id;"
  723. X.br
  724. X.B "int    row;"
  725. X.br
  726. X.B "int    column;"
  727. X.br
  728. X.B "char    *title;"
  729. X.br
  730. X.B "char    *helpfile;"
  731. X.br
  732. X.B "int    win_size;"
  733. X.br
  734. X.B "char    *option_base;"
  735. X.br
  736. X     or
  737. X.br
  738. X.B "char    **option_base;"
  739. X.br
  740. X.B "int        mtype;"
  741. X
  742. X.SS ARGUMENTS
  743. X.TP 6
  744. Xaction
  745. XNEWMENU - tells popmenu that you want to initialize a new menu.
  746. XIf one already exists for this menu_id it will be deleted and then recreated
  747. Xfrom the new list.
  748. X.br
  749. X
  750. XCREATEMENU - If a menu already exists for this menu_id then this flag has
  751. Xno effect.  Otherwise, it initializes a new menu from the list provided.
  752. X
  753. XDIMWINDOW - Dims the reverse video box around the menu.
  754. X.br
  755. Xpopmenu (DIMWINDOW, menu_id);
  756. X.TP 6
  757. Xmenu_id
  758. XA unique identifier that you chose to be assiciated with a menu.
  759. XYou use this identifier to run the menu.
  760. X.TP 6
  761. Xrow, column
  762. XThe upper left corner of where you want the menu box to popup at.
  763. X.TP 6
  764. Xtitle
  765. XTitle to be centered on the first row of the menu.  If title is null no title
  766. Xwill be displayed.
  767. X.TP 6
  768. Xhelpfile
  769. XThe helpfile name that contains help text to be displayed when the uses presses
  770. Xthe help key.  If a helpfile is supplied a "?" is displayed in the lower
  771. Xright hand corner of the menu.  Set to null if no help file is provided.
  772. X.br
  773. XThe help file should be in a format corresponding to GetInput(3),  see
  774. XGetInput(3X) for more information.  Popmenu is hard-coded to look for
  775. X\fIhelptag\fP "popmenu" in the helpfile.
  776. X.TP 6
  777. Xwin_size
  778. XThe length of the pop-up window.  This may be less than the number of
  779. Xoptions, so that popmenu() will only display
  780. X.I win_size
  781. Xnumber of options on the screen.  A window size of 6 or the number of options,
  782. Xwhichever is less, is used if this field is set to 0.  Note that this field
  783. Xshould not be set to be more than 22, which is the normal screen size (24)
  784. Xminus 2 for the borders.
  785. X.TP 6
  786. Xsizeof( option_base[0] ) or 0
  787. XIs an integer telling popmenu() the size of one option array element.  It can
  788. Xalso be set to
  789. X.I zero(0)
  790. Xif (char **) array is passed as the next argument,
  791. X.I popmenu
  792. Xwill figure out the increment as the size of a char pointer.
  793. X.TP 6
  794. Xoption_base    
  795. XThis is a (char *) to an array which store
  796. Xthe options you want to appear in the menu.  This array can be either a
  797. Xtwo dimensional char array, or a structure array, or even an array of pointers.
  798. XThe first char string in each array element up to the first NULL character is
  799. Xused to be displayed as options.  The rest of the field may just be table
  800. Xlook-up items.  Also, The last element must be NULL to signify the end of the
  801. Xtable.
  802. X.TP 6
  803. Xmtype
  804. X.I mtype
  805. Xis either TRUE or FALSE.  When TRUE, \fIpopmenu\fP performs full length,
  806. Xnon-case-sensitive option matching, otherwise, a first character only
  807. Xmatching scheme will be used.
  808. X.PP
  809. XFor menus that has to be built dynamically during run time,
  810. Xthere are benefit of preparing your option table either way.  With a pre-set
  811. Xchar array storing the menu entries, cpu usage is optimized in the expense of
  812. Xmemory; while using char *array will optimize memory usage but has to allocate
  813. Xmemory on the fly.  Menus built at compiled time are about equal with either
  814. Xmethod.
  815. X
  816. X.SH CREDITS
  817. XPaul J. Condie      7/87    (original author)
  818. X.br
  819. X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
  820. X
  821. XSam S. Lok        enhancements
  822. X
  823. X.SH EXAMPLE
  824. X.nf
  825. X#include    <curses.h>
  826. X
  827. X#define    NEWMENU    0
  828. X
  829. Xint    KeyHelp = 23;        /* control w */
  830. Xint    KeyCancel = 27;        /* ESC */
  831. Xint    KeyDown;
  832. Xint    KeyUp;
  833. X
  834. Xmain ()
  835. X{
  836. X    int    option;        /* the option the user selected */
  837. X    static char    mymenu[][7] = {
  838. X        "QUERY", "ADD", "DELETE", (char *)NULL };
  839. X    static char    *yourmenu[] = {
  840. X        "QUERY", "ADD", "DELETE", (char *)NULL };
  841. X
  842. X
  843. X    /* define a new menu */
  844. X    popmenu(NEWMENU, 1, 5,10, "Title", "", 3, sizeof( mymenu[0] ), mymenu, TRUE );
  845. X    popmenu(NEWMENU, 2, 7,15, "Title", "", 0, 0, yourmenu, TRUE );
  846. X
  847. X    /* run the menu */
  848. X    option = popmenu (1, "c");
  849. X    option = popmenu (2, (char *)NULL);
  850. X
  851. X    /* remove the menu from the screen */
  852. X    touchwin (stdscr);
  853. X    wrefresh (stdscr);
  854. X}
  855. X.fi
  856. X
  857. X.SH SEE ALSO
  858. Xcurses(3X), GetInput(3X).
  859. SHAR_EOF
  860. chmod 0644 utilities.d/libgeti.d/popmenu.3 || echo "restore of utilities.d/libgeti.d/popmenu.3 fails"
  861. echo "x - extracting utilities.d/libgeti.d/GetInput.hlp (Text)"
  862. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.hlp &&
  863. XGETINPUT
  864. X.TITLE GETINPUT Help
  865. XMover Keys:
  866. X        KEY_RETURN  (^m)    Traverse forwards through the fields.
  867. X        KEY_DOWN  (^j)      Traverse forwards through the fields.
  868. X        KEY_UP  (^k)        Traverse backwards through the fields.
  869. X        KEY_TAB  (^i)       Fast forward through the fields.
  870. X        KEY_BTAB            Fast reverse through the fields.
  871. XField Editing Keys:
  872. X        KEY_BEG  (^b)       Place cursor at beginning of field.
  873. X        KEY_END  (^e)       Place cursor at end of input in field.
  874. X        KEY_RIGHT  (^l)     Forward space within the field.
  875. X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
  876. X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
  877. X        KEY_EOL  (^d)       Delete from cursor to end of field.
  878. X        KEY_DL  (^c)        Clear field and home cursor.
  879. X        KEY_DC  (^x)        Delete a character.
  880. X        KEY_IC  (^t)        Toggle between type-over and insert mode.
  881. XOther Keys:
  882. X        KEY_HELP  (?)       Display help screen.
  883. X        KEY_REFRESH  (^r)   Redraw the screen.
  884. X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
  885. X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
  886. X        KEY_SAVE  (^f)      Save screen to a file.
  887. X        KEY_PRINT  (^p)     Print screen to lp.
  888. XGETINPUT
  889. X
  890. X
  891. X
  892. Xpopmenu
  893. X.TITLE Pop-Up Menu Help
  894. XSELECTING OPTIONS:
  895. X    Press the "up arrow key", "^k", "down arrow key", "^j" 
  896. X    to place bar on option and press "return".
  897. X
  898. X    or
  899. X
  900. X    Enter the first character of the option you
  901. X    wish to select and press "return".
  902. X
  903. X    KEY_CANCEL (esc)   - Cancel selection.
  904. Xpopmenu
  905. X
  906. X
  907. X
  908. Xhelp
  909. X.TITLE Using Help
  910. XHelp displays consist of a description displayed in a window.
  911. XIf the description doesn't fit in the window, the Up Arrow and
  912. XDown Arrow keys can be used to view a few more lines of the 
  913. Xdisplay.  Exiting the help system will return the display to 
  914. Xthe state it was in when you asked for help.
  915. X
  916. X   The following keys are active in help:
  917. X        KEY_CANCEL  (esc)   Exit help.
  918. X        KEY_DOWN  (^j)      View a few more lines.
  919. X        KEY_UP  (^k)        View the previous lines.
  920. X        KEY_BEG  (^b)       Display first page.
  921. X        KEY_END  (^e)       Display last page.
  922. Xhelp
  923. SHAR_EOF
  924. chmod 0444 utilities.d/libgeti.d/GetInput.hlp || echo "restore of utilities.d/libgeti.d/GetInput.hlp fails"
  925. echo "x - extracting utilities.d/checkpass.d/checkpass.1 (Text)"
  926. sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.1 &&
  927. X. \ %W% DeltaDate %G% ExtrDate %H% 
  928. X.po 6
  929. X.TH CHECKPASS 1 "" "Menu Utility"
  930. X
  931. X.SH \s9NAME\s0
  932. Xcheckpass \- find matching passwd in /etc/passwd file for a specified login.
  933. X
  934. X.SH SYNOPSIS
  935. Xcheckpass login passwd 
  936. X
  937. X.SH DESCRIPTION
  938. X.I Checkpass 
  939. Xfinds the \fIlogin\fP password in the /etc/passwd file, encrypts the
  940. X\fIpasswd\fP and does a comparison. 
  941. X.SH FILES
  942. X/etc/passwd
  943. X
  944. X.SH AUTHOR
  945. XVickie C. Chui
  946. X
  947. X.SH DIAGNOSTICS
  948. XCheckpass returns exit code zero if it was successful, otherwise, it
  949. Xreturns a 4.
  950. SHAR_EOF
  951. chmod 0644 utilities.d/checkpass.d/checkpass.1 || echo "restore of utilities.d/checkpass.d/checkpass.1 fails"
  952. echo "x - extracting utilities.d/checkpass.d/checkpass.c (Text)"
  953. sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.c &&
  954. X/*
  955. X *    checkpass.c:  encrypt entered passwd and comparing it against 
  956. X *         the /etc/passwd.
  957. X *    
  958. X *    Inputs:     argv[1] - login
  959. X *         argv[2] - passwd
  960. X *    
  961. X *    Return Values: 4 failure
  962. X *        0 - matched passwd found
  963. X */
  964. X
  965. X#include <pwd.h>
  966. X
  967. Xmain(argc, argv)
  968. Xint argc;
  969. Xchar *argv[];
  970. X{
  971. X    struct     passwd *getpwnam(), *pwentry;
  972. X    char     salt[2], 
  973. X        *crypt(),
  974. X        *encryptedpw;
  975. X
  976. X
  977. X    /* check number of arguments */
  978. X    if(argc != 3) {
  979. X        printf("Usage:  checkpass login passwd\n");
  980. X        exit(4);
  981. X    }
  982. X    
  983. X    /* get passwd for login from /etc/passwd file */
  984. X    if((pwentry=getpwnam(argv[1])) == (struct passwd *) 0) 
  985. X        exit(4);
  986. X
  987. X    salt[0] = *(pwentry->pw_passwd);
  988. X    salt[1] = *(pwentry->pw_passwd +1);
  989. X
  990. X    /* encrypt entered passwd */
  991. X    encryptedpw = crypt(argv[2], salt);
  992. X
  993. X    /* compare passwd in /etc/passwd with the encrypted passwd */
  994. X    if(strcmp(encryptedpw, pwentry->pw_passwd) )
  995. X        exit(4);
  996. X    exit(0);
  997. X}
  998. SHAR_EOF
  999. chmod 0644 utilities.d/checkpass.d/checkpass.c || echo "restore of utilities.d/checkpass.d/checkpass.c fails"
  1000. echo "x - extracting utilities.d/lock.d/junk (Text)"
  1001. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/junk &&
  1002. X                lockfd = open(diallock, O_WRONLY|O_CREAT|O_EXCL,
  1003. X                        0444) ;
  1004. X                if (lockfd < 0) 
  1005. X                {
  1006. X                    if (debug & D_DEVICE) 
  1007. X                    {
  1008. X                        dialmsg("%s: %s\n", errstring(),
  1009. X                            diallock) ;
  1010. X                    }
  1011. X                    continue ;
  1012. X                }
  1013. X                else
  1014. X                {
  1015. X                    /* pjc */
  1016. X                    /* write process id to lock file */
  1017. X                    sprintf (tmpstr, "%d", getpid());
  1018. X                    sprintf (spid, "%10.10s", tmpstr);
  1019. X                    write (lockfd, spid, strlen(spid));
  1020. X                }
  1021. X
  1022. X                (void) close(lockfd) ;
  1023. SHAR_EOF
  1024. chmod 0644 utilities.d/lock.d/junk || echo "restore of utilities.d/lock.d/junk fails"
  1025. echo "x - extracting utilities.d/lock.d/lock.1 (Text)"
  1026. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.1 &&
  1027. X. \ %W% DeltaDate %G% ExtrDate %H% 
  1028. X.po 6
  1029. X.TH LOCK 1 "" "Menu Utility"
  1030. X
  1031. X.SH \s9NAME\s0
  1032. Xlock \- does a lock on a file
  1033. X
  1034. X.SH SYNOPSIS
  1035. X.B lock  filename
  1036. X
  1037. X.SH DESCRIPTION
  1038. X.B LOCK
  1039. Xis designed to be a utility program to be used in conjunction with the menu(1)
  1040. Xprogram.  Lock does a lock on a file.  When used with the menu(1)
  1041. Xprogram the filename should probably be the program name.  A "LCK.." is 
  1042. Xprepended
  1043. Xto the filename to indicate that this is a lock file.  This is in keeping
  1044. Xwith uucp lock file syntax.  If the \fILCK..filename\fP
  1045. Xdoes not exist it will be created.  The lock file is created/looked for in
  1046. Xgetenv("LOCKDIR").
  1047. X
  1048. X
  1049. X.SH EXAMPLE
  1050. X.nf
  1051. Xlock program_name
  1052. Xif [ $? -eq 0 ]
  1053. X   then    program_name
  1054. X        unlock program_name
  1055. Xfi
  1056. X.fi
  1057. X
  1058. X.SH FILES
  1059. X\fI$LOCKDIR/LCK..filename\fP    the lock file
  1060. X
  1061. X.SH AUTHOR
  1062. XPaul J. Condie       10/88
  1063. X.br
  1064. X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
  1065. X
  1066. X.SH SEE ALSO
  1067. Xmenu(1), unlock(1).
  1068. X
  1069. X.SH DIAGNOSTICS
  1070. XLock returns a zero if the lock was successfully created,
  1071. X99 no file specified on command line,
  1072. Xotherwise, it returns \fIerrno\fP.  See errno description in manual.
  1073. SHAR_EOF
  1074. chmod 0644 utilities.d/lock.d/lock.1 || echo "restore of utilities.d/lock.d/lock.1 fails"
  1075. echo "x - extracting utilities.d/lock.d/lock.c (Text)"
  1076. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.c &&
  1077. X/*
  1078. X** Returns:
  1079. X**    0    lock successful
  1080. X**    99    no file on command line
  1081. X**    otherwise    errno
  1082. X*/
  1083. X
  1084. X#include    <stdio.h>
  1085. X#include    <fcntl.h>
  1086. X#include    <errno.h>
  1087. X
  1088. Xmain (argc, argv)
  1089. X    int    argc;
  1090. X    char    *argv[];
  1091. X{
  1092. X    char        *getenv();
  1093. X    int        fd;            /* file descriptor */
  1094. X    char        file[40];
  1095. X
  1096. X    if (argc != 2)
  1097. X        exit (1);
  1098. X
  1099. X    if (getenv("LOCKDIR") != (char *)NULL)
  1100. X        sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
  1101. X    else
  1102. X        sprintf (file, "LCK..%s", argv[1]);
  1103. X
  1104. X    if ((fd = open (file, O_WRONLY|O_CREAT|O_EXCL, 0444)) < 0)
  1105. X    {
  1106. X        /* check to see if process is still running */
  1107. X        exit (errno);
  1108. X    }
  1109. X
  1110. X    /* write process id to lock file */
  1111. X    /*
  1112. X    sprintf (tmpstr, "%d", getpid());
  1113. X    sprintf (spid, "%10.10s", tmpstr);
  1114. X    write (lockfd, spid, strlen(spid));
  1115. X    */
  1116. X
  1117. X    close (fd);
  1118. X    exit (0);
  1119. X}
  1120. X/* Paul J. Condie  8-89 */
  1121. SHAR_EOF
  1122. chmod 0644 utilities.d/lock.d/lock.c || echo "restore of utilities.d/lock.d/lock.c fails"
  1123. echo "x - extracting utilities.d/lock.d/unlock.1 (Text)"
  1124. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.1 &&
  1125. X. \ %W% DeltaDate %G% ExtrDate %H% 
  1126. X.po 6
  1127. X.TH UNLOCK 1 "" "Menu Utility"
  1128. X
  1129. X.SH \s9NAME\s0
  1130. Xunlock \- unlocks a semaphore lock on a file
  1131. X
  1132. X.SH SYNOPSIS
  1133. Xlock  filename
  1134. X
  1135. X.SH DESCRIPTION
  1136. X.B UNLOCK
  1137. Xis designed to be a utility program to be used in conjunction with the menu(1)
  1138. Xprogram.  Unlock does a semaphore unlock on a file then unlinks the filename.  
  1139. XThe filename should have been previously locked using lock(1).
  1140. XA "LCK.." is prepended
  1141. Xto the filename to indicate that this is a lock file.
  1142. XThe lock file is looked for in getenv("LOCKDIR").
  1143. X
  1144. X.PP
  1145. XThe important thing for unlock is to make sure it runs regardless of how
  1146. Xthe program exits.  Examples of how insure that this happens is illustrated
  1147. Xbelow:
  1148. X.br
  1149. Xtrap 'unlock pgm; trap 2' 2; (pgm; unlock pgm); trap 2
  1150. X.br
  1151. X(nohup pgm; nohup unlock)&
  1152. X
  1153. X.SH FILES
  1154. X\fI$LOCKDIR/LCK..filename\fP    the lock file
  1155. X
  1156. X.SH AUTHOR
  1157. XPaul J. Condie          10/88
  1158. X.br
  1159. X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
  1160. X
  1161. X.SH SEE ALSO
  1162. Xmenu(1), lock(1).
  1163. X
  1164. X.SH DIAGNOSTICS
  1165. XUnlock returns exit code zero if the unlock was successful, otherwise, it
  1166. Xreturns a non-zero.
  1167. SHAR_EOF
  1168. chmod 0644 utilities.d/lock.d/unlock.1 || echo "restore of utilities.d/lock.d/unlock.1 fails"
  1169. echo "x - extracting utilities.d/lock.d/unlock.c (Text)"
  1170. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.c &&
  1171. X/*
  1172. X** Name:    unlock(1)
  1173. X** Returns:
  1174. X**    0    unlock successful
  1175. X**    99    no file on command line
  1176. X**    otherwise    errno
  1177. X*/
  1178. X
  1179. X#include    <stdio.h>
  1180. X#include    <errno.h>
  1181. X
  1182. Xmain (argc, argv)
  1183. X    int    argc;
  1184. X    char    *argv[];
  1185. X{
  1186. X    char        *getenv();
  1187. X    char        file[40];
  1188. X
  1189. X    if (argc != 2)
  1190. X        exit (99);
  1191. X
  1192. X    if (getenv("LOCKDIR") != (char *)NULL)
  1193. X        sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
  1194. X    else
  1195. X        sprintf (file, "LCK..%s", argv[1]);
  1196. X
  1197. X    if (unlink (file) < 0)
  1198. X        exit (errno);
  1199. X
  1200. X    exit (0);
  1201. X}
  1202. X/* Paul J. Condie  8-89 */
  1203. SHAR_EOF
  1204. chmod 0644 utilities.d/lock.d/unlock.c || echo "restore of utilities.d/lock.d/unlock.c fails"
  1205. echo "x - extracting utilities.d/lock.d/uulock.c (Text)"
  1206. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/uulock.c &&
  1207. X/*
  1208. X
  1209. X  Lock a tty and then run a program.  Blow away old locks.
  1210. X
  1211. X  Written for Sys V with HDB style locks.
  1212. X  Written by Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us)
  1213. X  This program placed in the public domain.
  1214. X
  1215. X*/
  1216. X
  1217. X#include <stdio.h>
  1218. X#include <sys/types.h>
  1219. X#include <sys/stat.h>
  1220. X#include <signal.h>
  1221. X#include <fcntl.h>
  1222. X#include <termio.h>
  1223. X#include <sys/errno.h>
  1224. X
  1225. Xchar *strcpy();
  1226. Xchar *strcat();
  1227. Xunsigned sleep();
  1228. Xunsigned alarm();
  1229. Xvoid exit();
  1230. Xint pid;
  1231. X
  1232. XFILE *lock;
  1233. Xchar tty_lock[100];
  1234. X
  1235. Xmain(argc,argv)
  1236. Xint argc;
  1237. Xchar **argv;
  1238. X{
  1239. X
  1240. X        if (argc < 3) {
  1241. X           fprintf(stderr,"Usage: uulock tty command args\n");
  1242. X           exit(1);
  1243. X        }
  1244. X    /* create a hdb style lock file */
  1245. X
  1246. X        strcpy(tty_lock,"/usr/spool/locks/LCK..");
  1247. X        strcat(tty_lock,argv[1]);
  1248. X
  1249. X        check_lock(tty_lock);
  1250. X        umask(022);
  1251. X
  1252. X    lock = fopen(tty_lock,"w");
  1253. X    if (lock) {
  1254. X        fprintf(lock,"%10.10d\n",(int)getpid());
  1255. X        fclose(lock);
  1256. X
  1257. X                if (pid = fork()) {
  1258. X          int w;
  1259. X                  while ((w = wait((int *)0)) != pid && w != -1);
  1260. X                  unlink(tty_lock);
  1261. X                } else {
  1262. X                   execvp(argv[2],&argv[2]);
  1263. X           printf("Can't exec that program\n");
  1264. X           exit(2);
  1265. X                } 
  1266. X    } else {
  1267. X          fprintf(stderr,"tty port in use\n");
  1268. X          return 2;
  1269. X        }
  1270. X
  1271. X   return 0;
  1272. X}
  1273. X
  1274. X/* remove a lock file if the process is no longer there */
  1275. X
  1276. Xcheck_lock(file_name)
  1277. Xchar *file_name;
  1278. X{
  1279. X
  1280. X    int fd;
  1281. X        char lock_pid[11];
  1282. X    extern int errno;
  1283. X
  1284. X    if ((fd = open(file_name, O_RDONLY)) == -1) {
  1285. X           unlink(file_name);
  1286. X           return 0;
  1287. X        }
  1288. X
  1289. X    read(fd,lock_pid, 10);
  1290. X    close(fd);
  1291. X
  1292. X    if ((kill(atoi(lock_pid), 0)) == 0 || errno == EPERM) 
  1293. X           return 1;    /* process is active */
  1294. X
  1295. X        unlink(file_name);
  1296. X        return 0;
  1297. X}
  1298. SHAR_EOF
  1299. chmod 0644 utilities.d/lock.d/uulock.c || echo "restore of utilities.d/lock.d/uulock.c fails"
  1300. echo "x - extracting utilities.d/m.d/adduser (Text)"
  1301. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser &&
  1302. X#! /bin/ksh
  1303. X# %W%   DeltaDate %G%   ExtrDate %H%
  1304. X
  1305. X###  adduser
  1306. X###    Add a new user login to the system.
  1307. X###    This script is designed to be run from the menu(1) program.
  1308. X###    Menu script file is sadmin.m
  1309. X###    This script needs to be run with a set uid to root.
  1310. X###
  1311. X###  Arguments:
  1312. X###    $1 = login ID
  1313. X###    $2 = encrypted password
  1314. X###    $3 = numerical user ID
  1315. X###    $4 = numerical group ID
  1316. X###    $5 = Text (Users Read Name)
  1317. X###    $6 = directory to create users home directory in
  1318. X###    $7 = program to use as Shell
  1319. X###    $8 = default .profile for user
  1320. X###    $9 = default printer
  1321. X###    $10 =    password file
  1322. X###    $11 =    group file
  1323. X###
  1324. X###  Note:
  1325. X###      In order to get chgrp to work you need to chown to $LOGNAME first.
  1326. X###      The setuid does not work for chgrp ????
  1327. X###
  1328. X
  1329. X###    Validate argument count
  1330. Xif [ $# -ne 11 ]
  1331. X   then    echo "[$0] Incorrect argument count."
  1332. X    exit 1
  1333. Xfi
  1334. X
  1335. XLOGNAME=$1
  1336. XPASSWD=$2
  1337. XUID=$3
  1338. XGID=$4
  1339. XNAME=$5
  1340. XHOMEDIR=$6
  1341. XLOGSHELL=$7
  1342. XDPROFILE=$8
  1343. XPRINTER=$9
  1344. Xshift; shift
  1345. XPWDFILE=$8
  1346. XGROUPFILE=$9
  1347. X
  1348. X###    Validate must enter arguments.
  1349. Xif [ -z "$LOGNAME" ]
  1350. X   then    echo "No Login specified.  Aborting adduser."
  1351. X    exit 1
  1352. Xfi
  1353. Xif [ -z "$UID" ]
  1354. X   then    echo "No User ID specified.  Aborting adduser."
  1355. X    exit 1
  1356. Xfi
  1357. Xif [ -z "$GID" ]
  1358. X   then    echo "No Group ID specified.  Aborting adduser."
  1359. X    exit 1
  1360. Xfi
  1361. Xif [ -z "$HOMEDIR" ]
  1362. X   then    echo "No Home Directory specified.  Aborting adduser."
  1363. X    exit 1
  1364. Xfi
  1365. Xif [ -z "$LOGSHELL" ]
  1366. X   then    echo "No Login Shell specified.  Aborting adduser."
  1367. X    exit 1
  1368. Xfi
  1369. Xif [ -z "$PWDFILE" ]
  1370. X   then    echo "No Password File specified.  Aborting adduser."
  1371. X    exit 1
  1372. Xfi
  1373. Xif [ -z "$GROUPFILE" ]
  1374. X   then    echo "No Group File specified.  Aborting adduser."
  1375. X    exit 1
  1376. Xfi
  1377. X
  1378. X
  1379. X
  1380. X# Prompt for conformation
  1381. Xreply=`MenuPrompt \`tput lines\` 0 "Are You Sure (y/n) ? "`
  1382. Xif [ "$reply" != "y" ]
  1383. X   then    echo "$LOGNAME not added."
  1384. X    exit 1
  1385. Xfi
  1386. X
  1387. Xtrap "MenuMsg `tput lines` 0 'Too late to abort adduser!'" 2 3 15
  1388. X
  1389. X
  1390. X
  1391. X
  1392. X###    Make home directory
  1393. XMenuMsg `tput lines` 0 "Making a home directory."
  1394. XMAKEDIR=yes
  1395. Xif [ -s "$HOMEDIR" ]
  1396. X   then    reply=`MenuPrompt \`tput lines\` 0 "Warning: $HOMEDIR already exists.  Okay to use it. (y/n) ?  "`
  1397. X    if [ "$reply" = "y" ]
  1398. X       then MAKEDIR=no
  1399. X    fi
  1400. Xfi
  1401. Xif [ "$MAKEDIR" = "yes" ]
  1402. X   then    mkdir $HOMEDIR
  1403. X    rcde=$?
  1404. X    if [ $rcde -ne 0 ]
  1405. X       then echo "[$rcde]  Could not create $HOMEDIR."
  1406. X        exit 1
  1407. X    fi
  1408. Xfi
  1409. X###    The home directory will be chown'd after we add entry to password file.
  1410. SHAR_EOF
  1411. echo "End of part 12"
  1412. echo "File utilities.d/m.d/adduser is continued in part 13"
  1413. echo "13" > s2_seq_.tmp
  1414. exit 0
  1415.