home *** CD-ROM | disk | FTP | other *** search
- From: pjc@pcbox.UUCP (Paul J. Condie)
- Newsgroups: alt.sources
- Subject: menu(1) part 4 of 14
- Message-ID: <438@pcbox.UUCP>
- Date: 26 Dec 90 20:06:34 GMT
-
-
- #!/bin/sh
- # this is part 4 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file rundriver.c continued
- #
- CurArch=4
- if test ! -r s2_seq_.tmp
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < s2_seq_.tmp || exit 1
- echo "x - Continuing file rundriver.c"
- sed 's/^X//' << 'SHAR_EOF' >> rundriver.c
- X ++(*option);
- X break;
- X
- X case KEY_BTAB:
- X /* A back tab will hop backward 4 options at a time. */
- X if (menu.optioncount > 4)
- X {
- X *option -= 4;
- X if (*option < 0)
- X *option = menu.optioncount - abs(*option);
- X }
- X else
- X *option = *option <= 1 ? menu.optioncount:--(*option);
- X break;
- X
- X /*
- X ** This section is to highlight the selected option
- X ** before the user presses the return_key to select it.
- X */
- X case '0':
- X case '1':
- X case '2':
- X case '3':
- X case '4':
- X case '5':
- X case '6':
- X case '7':
- X case '8':
- X case '9':
- X sprintf (select, "%s%c", select, exitkey);
- X if (matoi (select) < 1 ||
- X matoi (select) > lastopnumber)
- X {
- X /* Invalid Option */
- X attrset (A_REVERSE);
- X mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
- X attrset (A_NORMAL);
- X select[0] = '\0';
- X }
- X else
- X {
- X /* find the element cooresponding to opnumber */
- X for (i = 0; i < menu.optioncount; i++)
- X if (matoi(select) == menu.option[i]->opnumber)
- X {
- X *option = i+1;
- X break;
- X }
- X }
- X break;
- X
- X case 'A':
- X case 'B':
- X case 'C':
- X case 'D':
- X case 'E':
- X case 'F':
- X case 'G':
- X case 'H':
- X case 'I':
- X case 'J':
- X case 'K':
- X case 'L':
- X case 'M':
- X case 'N':
- X case 'O':
- X case 'P':
- X case 'Q':
- X case 'R':
- X case 'S':
- X case 'T':
- X case 'U':
- X case 'V':
- X case 'W':
- X case 'X':
- X case 'Y':
- X case 'Z':
- X case ' ':
- X /* character matching */
- X sprintf (matchstr, "%s%c", matchstr, exitkey);
- X MATCHED = FALSE;
- X for (i = 0; i < menu.optioncount; i++)
- X {
- X strcpy (command, menu.option[i]->description);
- X upper (command);
- X if (strncmp (command, matchstr,
- X strlen(matchstr)) == 0)
- X {
- X MATCHED = TRUE;
- X sprintf (select, "%d",
- X menu.option[i]->opnumber);
- X *option = i + 1;
- X break;
- X }
- X }
- X if (!MATCHED)
- X strcpy (matchstr, "");
- X break;
- X
- X case KEY_EXITMENU:
- X /* check if we have a .EXIT option */
- X for (i = 0; i < menu.optioncount; i++)
- X if (strcmp (menu.option[i]->keyword, ".EXIT") == 0)
- X RunExit (&menu, i, KeyWord, ParseKey, ShowKey,
- X RunKey, gnames, gfiles, gindex);
- X return (QUIT);
- X
- X case KEY_MAINMENU:
- X return (MAINMENU);
- X
- X case KEY_PREVMENU:
- X return (PREVIOUSMENU);
- X
- X case '!':
- X /*
- X ** Shell Option.
- X ** Prompt user for a command to be executed within a
- X ** shell (system(1)).
- X */
- X select[0] = '\0';
- X mvaddch (ErrRow, 0, '!');
- X move (ErrRow, 1);
- X echo ();
- X refresh ();
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X getstr (select);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X noecho ();
- X sprintf (command, "%s;runrealid \"%s\";%s;%s",
- X#if BSD || SUN
- X "clear",
- X#else
- X "tput clear",
- X#endif
- X select,
- X "echo \"\\n[Press return to continue]\\c\"",
- X "read reply");
- X reset_shell_mode ();
- X signal (SIGINT, shutdown);
- X signal (SIGQUIT, shutdown);
- X system (command);
- X if (trapsigs)
- X {
- X signal (SIGINT, SIG_IGN);
- X signal (SIGQUIT, SIG_IGN);
- X }
- X reset_prog_mode ();
- X keypad (stdscr, TRUE);
- X move (ErrRow,0);
- X clrtoeol ();
- X select[0] = '\0';
- X matchstr[0] = '\0';
- X clearok (stdscr, TRUE);
- X break;
- X
- X case KEY_HELP:
- X /*
- X ** Show Help Screen Option.
- X ** Search directories for a menu.hlp file.
- X ** If found display to screen.
- X */
- X strcpy (command, findfile ("menu.hlp", ".",
- X getenv("HELPDIR"), getenv("MENUDIR"),
- X ""));
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X ShowHelp (command, "menu", ErrRow);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X clearok (stdscr, TRUE);
- X select[0] ='\0';
- X matchstr[0] ='\0';
- X break;
- X
- X case KEY_GNAME:
- X /*
- X ** Goto Menu option
- X ** Prompt user for the Gname (goto menu name)
- X ** that the user wants to go to.
- X ** And then return GNAMEOFFSET + gindex to main.
- X ** The > GNAMEOFFSET indicates a goto menu option.
- X */
- X select[0] = '\0';
- X echo ();
- X mvprintw (ErrRow, 0, "Goto ");
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X getstr (select);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X noecho ();
- X for (i = 0; i < gindex; i++)
- X {
- X if (strcmp (select, gnames[i]) == 0)
- X return (GNAMEOFFSET + i);
- X }
- X BEEP;
- X attrset (A_REVERSE);
- X mvprintw (ErrRow, 0, "[%s] not found.", select);
- X attrset (A_NORMAL);
- X select[0] = '\0';
- X matchstr[0] ='\0';
- X break;
- X
- X case KEY_RETURN:
- X case KEY_LINEFEED:
- X /*
- X ** We now take an action based upon what is in
- X ** select - that which the user typed in.
- X */
- X if (select[0] == KeyExitMenu)
- X {
- X /* check if we have a .EXIT option */
- X for (i = 0; i < menu.optioncount; i++)
- X if (strcmp (menu.option[i]->keyword,
- X ".EXIT") == 0)
- X {
- X RunExit (&menu, i, KeyWord,
- X ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex);
- X break;
- X }
- X return (QUIT);
- X }
- X if (select[0] == KeyMainMenu) return (MAINMENU);
- X if (select[0] == KeyPrevMenu) return (PREVIOUSMENU);
- X
- X /*
- X ** Goto Menu option
- X ** Prompt user for the Gname (goto menu name)
- X ** that the user wants to go to.
- X ** And then return GNAMEOFFSET + gindex to main.
- X ** The > GNAMEOFFSET indicates a goto menu option.
- X */
- X if (select[0] == KeyGname)
- X {
- X select[0] = '\0';
- X echo ();
- X mvprintw (ErrRow, 0, "Goto ");
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X getstr (select);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X noecho ();
- X for (i = 0; i < gindex; i++)
- X {
- X if (strcmp (select, gnames[i]) == 0)
- X return (GNAMEOFFSET + i);
- X }
- X BEEP;
- X attrset (A_REVERSE);
- X mvprintw (ErrRow, 0, "[%s] not found.", select);
- X attrset (A_NORMAL);
- X select[0] = '\0';
- X matchstr[0] ='\0';
- X break;
- X }
- X
- X /*
- X ** Show Help Screen Option.
- X ** Search directories for a menu.hlp file.
- X ** If found display to screen.
- X */
- X if (select[0] == KeyHelp)
- X {
- X strcpy (command, findfile ("menu.hlp",
- X ".", getenv("HELPDIR"),
- X getenv("MENUDIR"), ""));
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X ShowHelp (command, "menu", ErrRow);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X clearok (stdscr, TRUE);
- X select[0] ='\0';
- X matchstr[0] ='\0';
- X break;
- X }
- X
- X
- X /*
- X ** The user has manually typed in a option to be
- X ** executed. Execute the appropriate option.
- X */
- X if (strlen (select) > 0)
- X {
- X index = matoi (select);
- X if (index < 1 || index > lastopnumber)
- X {
- X /* Invalid Option */
- X attrset (A_REVERSE);
- X mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
- X attrset (A_NORMAL);
- X select[0] = '\0';
- X break;
- X }
- X /* find the element cooresponding to opnumber */
- X for (i = 0; i < menu.optioncount; i++)
- X if (index == menu.option[i]->opnumber)
- X {
- X *option = i+1;
- X break;
- X }
- X }
- X
- X /*
- X ** Run the option the user selected.
- X */
- X for (i = 1; i <= MAXKEYS; i++)
- X if (strcmp (menu.option[*option-1]->keyword,
- X KeyWord[i]) == 0)
- X {
- X if (RunKey[i] != NULL)
- X {
- X#ifdef ALARM
- X alarm (0); /* turn off mail */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X exitkey = (*RunKey[i]) (&menu, *option-1, KeyWord,
- X ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex);
- X /* .MENU is a special case */
- X if (exitkey == SUBMENU)
- X return (*option-1);
- X if (exitkey == MAINMENU)
- X return (MAINMENU);
- X if (exitkey == PREVIOUSMENU)
- X return (PREVIOUSMENU);
- X if (exitkey == QUIT)
- X return (QUIT);
- X if (exitkey == REPARSE)
- X return (REPARSE);
- X if (exitkey >= GNAMEOFFSET &&
- X exitkey <= GNAMEOFFSET + gindex)
- X return (exitkey);
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X }
- X break;
- X }
- X select[0] = '\0';
- X matchstr[0] = '\0';
- X break;
- X
- X default:
- X if (exitkey == KeyPopGname && gindex > 0)
- X {
- X /*
- X ** Popup menu for goto names.
- X */
- X#ifdef ALARM
- X alarm (0); /* turn off mail check */
- X signal (SIGALRM, SIG_IGN);
- X#endif
- X popmenu (INITMENU, GOTOMENU, gotorow, gotocol,
- X "GOTO MENU", HELPFILE, LINES-2,
- X sizeof(gnames[0]), gnames);
- X
- X move (ErrRow,0);
- X clrtoeol ();
- X BEEP;
- X mvprintw (ErrRow, 0, "Goto what menu ?");
- X refresh ();
- X exitkey = popmenu (GOTOMENU, (char *)NULL);
- X touchwin (stdscr);
- X refresh ();
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X if (exitkey >= 1 && exitkey <= gindex)
- X return (GNAMEOFFSET + exitkey-1);
- X }
- X
- X move (ErrRow,0);
- X clrtoeol ();
- X mvprintw (ErrRow, 0, "Say What.");
- X select[0] = '\0';
- X matchstr[0] = '\0';
- X break;
- X }
- X }
- X}
- X
- X
- X
- X/*
- X** My ascii to integer
- X** Return -1 if string contains more than digits.
- X*/
- Xmatoi (s)
- X char *s;
- X{
- X int value;
- X
- X value = atoi (s);
- X while (*s)
- X {
- X if (*s < '0' || *s > '9')
- X return (-1);
- X s++;
- X }
- X return (value);
- X}
- X
- X
- X
- Xsetoption (row, col)
- X int row;
- X int col;
- X{
- X static int *saveoption;
- X int newoption;
- X int rc;
- X int j;
- X int ch;
- X int found;
- X
- X /* find the option associated with this row/col */
- X found = FALSE;
- X for (newoption = 0; newoption < menu.optioncount; newoption++)
- X {
- X if (row == menu.option[newoption]->row &&
- X (col >= menu.option[newoption]->col &&
- X col <= (menu.option[newoption]->col +
- X strlen(menu.option[newoption]->description))))
- X {
- X found = TRUE;
- X break;
- X }
- X }
- X newoption++; /* base 1 */
- X if (debug)
- X {
- X fprintf (stderr, "\n[%s] newoption %d, %s, row %d, col %d",
- X __FILE__,
- X newoption, menu.option[newoption]->description,
- X row, col);
- X fflush (stderr);
- X }
- X if (!found || newoption == tmpoption)
- X return;
- X
- X
- X
- X /* unhighlight current option */
- X#ifdef BSD
- X standend ();
- X#else
- X attrset (A_NORMAL);
- X#endif
- X if (ShowKey[ckik] != NULL)
- X {
- X mvaddch (menu.option[(tmpoption)-1]->row,
- X menu.option[(tmpoption)-1]->col-1, ' ');
- X strcat (menu.option[(tmpoption)-1]->description, " ");
- X (*ShowKey[ckik]) (&menu, tmpoption-1);
- X menu.option[(tmpoption)-1]->description[strlen(menu.option[(tmpoption)-1]->description)-1] = '\0';
- X }
- X
- X
- X tmpoption = newoption;
- X /* highlight new option */
- X for (ckik = 1; ckik <= MAXKEYS && KeyWord[ckik] != NULL;
- X ckik++)
- X {
- X if (strcmp (menu.option[(tmpoption)-1]->keyword,
- X KeyWord[ckik]) == 0)
- X {
- X if (ShowKey[ckik] != NULL)
- X {
- X /* display option */
- X (*ShowKey[ckik]) (&menu, (tmpoption)-1);
- X mvaddch (menu.option[(tmpoption)-1]->row,
- X menu.option[(tmpoption)-1]->col-1, ' ');
- X /*
- X ** turn on reverse video
- X ** maintaining current attributes
- X */
- X rc = slength(menu.option[(tmpoption)-1]->description) + menu.option[(tmpoption)-1]->col + 5;
- X for (j = menu.option[(tmpoption)-1]->col-1; j <= rc; j++)
- X {
- X ch = mvinch (menu.option[(tmpoption)-1]->row, j);
- X ch |= A_REVERSE;
- X mvaddch (menu.option[(tmpoption)-1]->row, j, ch);
- X }
- X
- X }
- X break;
- X } /* end if */
- X }
- X
- X#ifdef BSD
- X standend ();
- X#else
- X attrset (A_NORMAL);
- X#endif
- X refresh ();
- X}
- SHAR_EOF
- echo "File rundriver.c is complete"
- chmod 0644 rundriver.c || echo "restore of rundriver.c fails"
- echo "x - extracting ParseOpton.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseOpton.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseOption()
- X** This function parses user selectable options.
- X** ARGS: keyword the keyword found
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- Xextern int swin, ewin, longest;
- Xextern int debug;
- X
- X
- XParseOption (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- Xgindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X struct OptionInfo *malloc();
- X char *getval();
- X char *fgets(), line[MAXLEN+100];
- X int i = 0;
- X int j;
- X char *ws;
- X
- X
- X if (menu->optioncount >= MAXOPTION)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0, "Exceeded maximum allowable options.");
- X shutdown ();
- X }
- X menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
- X if (menu->option[menu->optioncount] == NULL)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0, "Unable to allocate memory for option.");
- X shutdown ();
- X }
- X
- X strcpy (menu->option[menu->optioncount]->keyword, keyword);
- X
- X /*
- X ** Read in option command
- X ** strcat continuation lines
- X */
- X fgets (line, sizeof(line)-1, menufile);
- X line[strlen(line)-1] = '\0'; /* get rid of \n */
- X while (line[strlen(line)-1] == '\\')
- X {
- X if (strlen(line) >= MAXLEN)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0,
- X "Option command is too long. Max = %d",MAXLEN);
- X shutdown ();
- X }
- X line[strlen(line)-1] = '\n'; /* replace \ with \n */
- X fgets (line+strlen(line), sizeof(line)-1, menufile);
- X line[strlen(line)-1] = '\0'; /* get rid of \n */
- X }
- X menu->option[menu->optioncount]->command =
- X (char *) malloc (strlen(line)+5);
- X strcpy (menu->option[menu->optioncount]->command, line);
- X if (debug)
- X {
- X fprintf (stderr, "\n[ParseOpton] <%s> command=:%s:",
- X keyword, menu->option[menu->optioncount]->command);
- X fflush (stderr);
- X }
- X
- X /*
- X ** Read in option description
- X */
- X fgets (line, BUFSIZE+1, menufile);
- X line[strlen(line)-1] = '\0';
- X for (j = 0, i = 0; i < strlen (line); j++, i++)
- X if (line[i] == '$')
- X {
- X char *sptr, *b4ptr;
- X
- X sptr = b4ptr = line+i;
- X strcpy (menu->option[menu->optioncount]->description+j,
- X getval (&sptr, '$'));
- X i += (int)(sptr - b4ptr);
- X j += strlen (menu->option[menu->optioncount]->description+j) - 1;
- X i--;
- X }
- X else
- X {
- X menu->option[menu->optioncount]->description[j] = line[i];
- X }
- X menu->option[menu->optioncount]->description[j] = '\0';
- X
- X
- X /*
- X ** Determine length of longest option
- X */
- X if (slength (menu->option[menu->optioncount]->description) > longest)
- X longest = slength(menu->option[menu->optioncount]->description);
- X
- X /* set option number 2b displayed */
- X (*opnumber)++;
- X menu->option[menu->optioncount]->opnumber = *opnumber;
- X
- X menu->optioncount++;
- X ewin++;
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParseOpton.c || echo "restore of ParseOpton.c fails"
- echo "x - extracting ParseBaner.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseBaner.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseBanner()
- X** Parses the "BANNER" keyword.
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X
- XParseBanner (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X static int onetime = FALSE; /* show only 1 time */
- X int row, col, rstart, rstop, cstart, cstop;
- X int ulc=0, llc=0, linecount, increment;
- X char flag[5], tophalf[4][30], lower[4][30];
- X
- X
- X fscanf (menufile, "%d", &linecount);
- X
- X/*
- X** Load the input banner text into tophalf and lower arrays.
- X*/
- X
- X for (row = 1; row <= linecount; row++)
- X {
- X fscanf (menufile, "%s", flag);
- X if (strncmp (flag, ".U", 2) == 0)
- X {
- X fgets (tophalf[ulc], 80, menufile);
- X tophalf[ulc][strlen(tophalf[ulc])-1] = '\0';
- X ulc++;
- X }
- X else
- X {
- X fgets (lower[llc], 80, menufile);
- X lower[llc][strlen(lower[llc])-1] = '\0';
- X llc++;
- X }
- X }
- X
- X if (onetime)
- X return (0);
- X onetime++;
- X
- X#ifdef BSD
- X standout ();
- X#else
- X attrset (A_STANDOUT);
- X#endif
- X for (rstart = 24/2-1, rstop = 24/2+1,
- X cstart = COLS/2-2, cstop = COLS/2+1;
- X rstart >= 0 && rstop <= 23 && cstart >= 0 && cstop <= COLS-1;
- X rstart--, rstop++, cstart-=3, cstop+=3)
- X {
- X for (row = rstart; row <= rstop; row++)
- X {
- X if (row == rstart || row == rstop)
- X {
- X for (col = cstart; col <= cstop; col++)
- X mvaddch (row, col, BORDERCHAR);
- X }
- X else
- X {
- X mvaddch (row, cstart, BORDERCHAR);
- X mvaddch (row, cstop, BORDERCHAR);
- X }
- X }
- X refresh ();
- X }
- X
- X increment = 2;
- X for (rstart = rstart+3, rstop=rstop-2, cstart = cstart+1, cstop = cstop-1;
- X cstart >= 0 && cstop <= COLS-1;
- X rstart++, rstop--, cstart-=increment, cstop+=increment)
- X {
- X for (row = 1; row <= 23; row++)
- X {
- X if (row < rstart || row > rstop)
- X {
- X for (col = cstart; col <= cstart+increment; col++)
- X mvaddch (row, col, BORDERCHAR);
- X for (col = cstop-increment; col <= cstop; col++)
- X mvaddch (row, col, BORDERCHAR);
- X }
- X else
- X {
- X mvaddch (row, cstart, BORDERCHAR);
- X mvaddch (row, cstop, BORDERCHAR);
- X }
- X }
- X refresh ();
- X }
- X
- X#ifdef BSD
- X standout ();
- X#else
- X attrset (A_REVERSE);
- X#endif
- X for (row = 0; ulc > 0; row++, ulc--)
- X mvprintw (row+4, COLS/2-strlen(tophalf[row])/2-1, "%s", tophalf[row]);
- X for (row = 0; llc > 0; row++, llc--)
- X mvprintw (row+17, COLS/2-strlen(lower[row])/2-1, "%s", lower[row]);
- X
- X mvprintw (23, 27, "Press return to continue");
- X move (23,0);
- X getch ();
- X refresh ();
- X#ifdef BSD
- X standend ();
- X#else
- X attrset (A_NORMAL);
- X#endif
- X move (0,0); clrtobot ();
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParseBaner.c || echo "restore of ParseBaner.c fails"
- echo "x - extracting ParseTitle.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseTitle.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseTitle()
- X** Parses keyword "TITLE".
- X** ARGS: keyword the keyword "TITLE"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X
- Xextern int MAILCALL;
- Xextern int mailrow;
- Xextern int mailcol;
- X
- X
- XParseTitle (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets(), line[201];
- X char *getenv();
- X char *getval();
- X char section[3][201]; /* section[0] = left justified */
- X /* section[1] = centered */
- X /* section[2] = right justified */
- X int i = 0; /* index into line */
- X int j; /* index into section */
- X int k, row, col;
- X char *ws;
- X int mailsection=999; /* section $MAIL was found */
- X /* we set to 999 so sub menus */
- X /* that don't have a $MAIL wont */
- X /* recalculate mailcol */
- X
- X
- X
- X fgets (line, 200, menufile);
- X
- X/*
- X** Get title line
- X*/
- X fgets (line, 200, menufile);
- X line[strlen(line)-1] = '\0';
- X
- X section[0][0] = section[1][0] = section[2][0] = '\0';
- X
- X/*
- X** Now we break input line into left, center, and right sections
- X** Loop through each section.
- X*/
- X
- X for (k = 0; k <= 2; k++)
- X {
- X /* Loop through each character of line until we find next section */
- X for (j = 0; i < strlen (line) && strncmp (line+i, "...", 3) != 0;
- X i++, j++)
- X {
- X if (strncmp (line+i, "$DATE", 5) == 0)
- X {
- X sysdate (section[k]+j, "mm/dd/yy");
- X j += 7;
- X i += 4;
- X }
- X else
- X if (strncmp (line+i, "$TIME", 5) == 0)
- X {
- X systime (section[k]+j, "HH:MM zz");
- X j += 7;
- X i += 4;
- X }
- X else
- X if (strncmp (line+i, "$MAIL", 5) == 0)
- X {
- X /*
- X ** User wants 2b notified when mail arrives.
- X ** The mailfile is located in enviroment $MAIL
- X ** if the mailfile exists and size is greater than zero
- X ** mailfile = getenv("$MAIL")
- X ** We need to process entire line b4 we find mailcol
- X */
- X MAILCALL = TRUE;
- X strcpy (section[k]+j, "mAiL"); /* unique ? */
- X mailrow = menu->titlecount;
- X mailsection = k;
- X i += 4; /* get past $MAIL */
- X j += 3; /* for "MAIL" */
- X }
- X else
- X /*
- X ** A environment variable
- X */
- X if (line[i] == '$')
- X {
- X char *sptr, *b4ptr;
- X
- X sptr = b4ptr = line+i;
- X strcpy (section[k]+j, getval (&sptr, '$'));
- X i += (int)(sptr - b4ptr);
- X j += strlen (section[k]+j) - 1;
- X i--;
- X }
- X else
- X section[k][j] = line[i];
- X }
- X section[k][j] = '\0';
- X i += 3;
- X }
- X
- X if (menu->titlecount >= MAXTITLE)
- X {
- X BEEP;
- X mvprintw (ErrRow, 0, "Number of Title lines exceed the maximim.");
- X shutdown ();
- X }
- X (menu->titlecount)++;
- X (menu->wfrow)++; /* reduce window size to center in */
- X
- X
- X/*
- X** Now we display the three sections to the screen
- X*/
- X
- X for (k = 0; k <= 2; k++)
- X {
- X/*
- X** First we must find out what column to start displaying on.
- X** Taking into account the terminal attribute characters.
- X*/
- X switch (k)
- X {
- X case 0:
- X /* left justified */
- X row = menu->titlecount - 1;
- X col = 0;
- X break;
- X case 1:
- X /* center */
- X for (i = 0, j = 0; section[k][i] != '\0'; i++)
- X if (section[k][i] == '\\') j++;
- X col = COLS/2-(strlen(section[k])-j*2)/2;
- X col -= (((strlen(section[k])-j*2) % 2) == 0) ? 0 : 1;
- X row = menu->titlecount - 1;
- X move (menu->titlecount-1, i);
- X break;
- X case 2:
- X /* right justify */
- X for (i = 0, j = 0; section[k][i] != '\0'; i++)
- X if (section[k][i] == '\\') j++;
- X row = menu->titlecount - 1;
- X col = COLS-strlen(section[k])+j*2;
- X break;
- X } /* end switch */
- X
- X if (MAILCALL && mailsection == k)
- X {
- X /* find mailcol - remember the attributes */
- X for (i = 0, j = 0; section[k][i] != '\0' &&
- X strncmp (section[k]+i, "mAiL", 4) != 0; i++)
- X if (section[k][i] == '\\') j++;
- X mailcol = i - j*2 + col; /* for \R */
- X memcpy (section[k]+i, " ", 4); /* get rid of mAiL */
- X }
- X
- X displaytext (stdscr, row, col, section[k]);
- X } /* end for loop */
- X#ifdef ALARM
- X if (MAILCALL)
- X checkmail ();
- X#endif
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParseTitle.c || echo "restore of ParseTitle.c fails"
- echo "x - extracting ParseBox.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseBox.c &&
- Xstatic char Sccsid[] = "@(#)ParseBox.c 1.7 DeltaDate 1/22/90 ExtrDate 1/22/90";
- X
- X/* FUNCTION: ParseBox()
- X** Parses keyword ".BOX".
- X** ARGS: keyword the keyword "BOX"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- XParseBox (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets(), line[BUFSIZE+1];
- X char boxtype[30];
- X char *sptr;
- X
- X /* Default Values */
- X menu->boxtype = StandoutLine;
- X menu->boxtype = menu->boxtype | (DumbLine << 9);
- X
- X fgets (line, BUFSIZE, menufile);
- X sptr = line;
- X SKIPJUNK(sptr);
- X
- X /* get border type for active menu */
- X sscanf (sptr, "%s", boxtype);
- X sptr += strlen(boxtype);
- X if (strcmp (boxtype, "DumbLine") == 0)
- X menu->boxtype = DumbLine;
- X else if (strcmp (boxtype, "StandoutLine") == 0)
- X menu->boxtype = StandoutLine;
- X else if (strcmp (boxtype, "SingleLine") == 0 ||
- X strcmp (boxtype, "DrawLine") == 0)
- X menu->boxtype = SingleLine;
- X else if (strcmp (boxtype, "MosaicLine") == 0)
- X menu->boxtype = MosaicLine;
- X else if (strcmp (boxtype, "DiamondLine") == 0)
- X menu->boxtype = DiamondLine;
- X else if (strcmp (boxtype, "DotLine") == 0)
- X menu->boxtype = DotLine;
- X else if (strcmp (boxtype, "PlusLine") == 0)
- X menu->boxtype = PlusLine;
- X
- X /* get border type for inactive menu - dim (high 8 bits) */
- X sscanf (sptr, "%s", boxtype);
- X sptr += strlen(boxtype);
- X if (strcmp (boxtype, "DumbLine") == 0)
- X menu->boxtype = menu->boxtype | (DumbLine << 9);
- X else if (strcmp (boxtype, "StandoutLine") == 0)
- X menu->boxtype = menu->boxtype | (DumbLine << 9);
- X else if (strcmp (boxtype, "SingleLine") == 0 ||
- X strcmp (boxtype, "DrawLine") == 0)
- X menu->boxtype = menu->boxtype | (SingleLine << 9);
- X else if (strcmp (boxtype, "MosaicLine") == 0)
- X menu->boxtype = menu->boxtype | (MosaicLine << 9);
- X else if (strcmp (boxtype, "DiamondLine") == 0)
- X menu->boxtype = menu->boxtype | (DiamondLine << 9);
- X else if (strcmp (boxtype, "DotLine") == 0)
- X menu->boxtype = menu->boxtype | (DotLine << 9);
- X else if (strcmp (boxtype, "PlusLine") == 0)
- X menu->boxtype = menu->boxtype | (PlusLine << 9);
- X
- X drawbox (stdscr, 1,1, LINES-1,COLS, menu->boxtype & 0777, StandoutLine,
- X FALSE, FALSE);
- X return (0);
- X}
- SHAR_EOF
- chmod 0444 ParseBox.c || echo "restore of ParseBox.c fails"
- echo "x - extracting ParseWindo.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseWindo.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseWindow()
- X** Parses keyword ".WINDOW".
- X** ARGS: keyword the keyword "WINDOW"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- Xextern int swin, ewin, longest;
- X
- XParseWindow (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X int i, j, row, col;
- X char line[BUFSIZE];
- X
- X
- X EndWindow (menu);
- X
- X fscanf (menufile, "%d", &menu->wfrow);
- X if (menu->wfrow < 0) menu->wfrow = 0;
- X if (menu->wfrow < menu->titlecount) menu->wfrow = menu->titlecount;
- X if (menu->wfrow > LINES-1) menu->wfrow = LINES-1;
- X fscanf (menufile, "%d", &menu->wlrow);
- X if (menu->wlrow < 0) menu->wlrow = 0;
- X if (menu->wlrow > LINES-1) menu->wlrow = LINES-1;
- X fscanf (menufile, "%d", &menu->wfcol);
- X if (menu->wfcol < 0) menu->wfcol = 0;
- X if (menu->wfcol > COLS-1) menu->wfcol = COLS-1;
- X fscanf (menufile, "%d", &menu->wlcol);
- X if (menu->wlcol < 0) menu->wlcol = 0;
- X if (menu->wlcol > COLS-1) menu->wlcol = COLS-1;
- X
- X/*
- X** Now lets read in the window heading.
- X*/
- X fgets (line, BUFSIZE+1, menufile);
- X line[strlen(line)-1] = '\0';
- X
- X/*
- X** Determine where to display heading.
- X*/
- X for (i = 0, j = 0; line[i] != '\0'; i++)
- X if (line[i] == '\\') j++;
- X row = menu->wfrow - 1;
- X col = (menu->wlcol - menu->wfcol)/2-(strlen(line)-1-j*2)/2 + menu->wfcol;
- X col -= (((strlen(line)-1-j*2) % 2) == 0) ? 0 : 1;
- X if (strlen(line) > 0) displaytext (stdscr, row, col, line+1);
- X
- X longest = 0;
- X swin = ewin;
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParseWindo.c || echo "restore of ParseWindo.c fails"
- echo "x - extracting ParseLine.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseLine.c &&
- Xstatic char Sccsid[] = "@(#)ParseLine.c 1.6 DeltaDate 1/22/90 ExtrDate 1/22/90";
- X
- X/* FUNCTION: ParseLine()
- X** Parses keyword "LINE".
- X** ARGS: keyword the keyword "LINE"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- X
- XParseLine (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X int col;
- X char *fgets(), line[BUFSIZE+1];
- X char linetype[30];
- X char *sptr;
- X
- X
- X /* default values */
- X menu->linetype = StandoutLine;
- X menu->linetype = menu->linetype | (DumbLine << 9);
- X
- X fgets (line, BUFSIZE, menufile);
- X sptr = line;
- X SKIPJUNK(sptr);
- X
- X /* get border type for active menu */
- X sscanf (sptr, "%s", linetype);
- X sptr += strlen(linetype);
- X if (strcmp (linetype, "DumbLine") == 0)
- X menu->linetype = DumbLine;
- X else if (strcmp (linetype, "StandoutLine") == 0)
- X menu->linetype = StandoutLine;
- X else if (strcmp (linetype, "SingleLine") == 0 ||
- X strcmp (linetype, "DrawLine") == 0)
- X menu->linetype = SingleLine;
- X else if (strcmp (linetype, "MosaicLine") == 0)
- X menu->linetype = MosaicLine;
- X else if (strcmp (linetype, "DiamondLine") == 0)
- X menu->linetype = DiamondLine;
- X else if (strcmp (linetype, "DotLine") == 0)
- X menu->linetype = DotLine;
- X else if (strcmp (linetype, "PlusLine") == 0)
- X menu->linetype = PlusLine;
- X
- X /* get border type for inactive menu - dim (high 8 bits) */
- X sscanf (sptr, "%s", linetype);
- X sptr += strlen(linetype);
- X if (strcmp (linetype, "DumbLine") == 0)
- X menu->linetype = menu->linetype | (DumbLine << 9);
- X else if (strcmp (linetype, "StandoutLine") == 0)
- X menu->linetype = menu->linetype | (DumbLine << 9);
- X else if (strcmp (linetype, "SingleLine") == 0 ||
- X strcmp (linetype, "DrawLine") == 0)
- X menu->linetype = menu->linetype | (SingleLine << 9);
- X else if (strcmp (linetype, "MosaicLine") == 0)
- X menu->linetype = menu->linetype | (MosaicLine << 9);
- X else if (strcmp (linetype, "DiamondLine") == 0)
- X menu->linetype = menu->linetype | (DiamondLine << 9);
- X else if (strcmp (linetype, "DotLine") == 0)
- X menu->linetype = menu->linetype | (DotLine << 9);
- X else if (strcmp (linetype, "PlusLine") == 0)
- X menu->linetype = menu->linetype | (PlusLine << 9);
- X
- X drawline (stdscr, menu->titlecount, menu->linetype&0777, StandoutLine,
- X menu->boxtype);
- X
- X menu->titlecount++;
- X return (0);
- X}
- SHAR_EOF
- chmod 0444 ParseLine.c || echo "restore of ParseLine.c fails"
- echo "x - extracting ParseComnt.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseComnt.c &&
- Xstatic char Sccsid[] = "@(#)ParseComnt.c 1.5 DeltaDate 11/13/88 ExtrDate 1/22/90";
- X
- X/* FUNCTION: ParseComnt()
- X** Parses keyword "###".
- X## A comment line.
- X** ARGS: keyword the keyword "###"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X
- XParseComnt (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets(), line[BUFSIZE+1];
- X
- X
- X fgets (line, BUFSIZE, menufile);
- X return (0);
- X}
- SHAR_EOF
- chmod 0444 ParseComnt.c || echo "restore of ParseComnt.c fails"
- echo "x - extracting ParseUnix.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseUnix.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseUnix()
- X** Parses keyword ".unix".
- X** ARGS: keyword the keyword "unix"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include <signal.h>
- X#include "menu.h"
- X
- Xextern int debug;
- Xextern int trapsigs;
- X
- X
- X
- XParseUnix (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X int shutdown();
- X char command[MAXLEN+1];
- X int rc;
- X char *comptr;
- X char tmpstr[80];
- X int redrawflag = FALSE;
- X
- X
- X
- X /*
- X ** Read in option command
- X ** strcat continuation lines
- X */
- X fgets (command, sizeof(command)-1, menufile);
- X command[strlen(command)-1] = '\0'; /* get rid of \n */
- X while (command[strlen(command)-1] == '\\')
- X {
- X if (strlen(command) > MAXLEN)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0,
- X ".UNIX command is too long. Max = %d",MAXLEN);
- X shutdown ();
- X }
- X command[strlen(command)-1] = '\n'; /* replace \ with \n */
- X fgets (command+strlen(command), sizeof(command)-1, menufile);
- X command[strlen(command)-1] = '\0'; /* get rid of \n */
- X }
- X
- X comptr = command;
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", tmpstr); /* do we have a REDRAW */
- X if (strcmp (tmpstr, "REDRAW") == 0)
- X {
- X redrawflag = TRUE;
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", tmpstr); /* do we have a GETINPUT */
- X }
- X
- X if (strcmp (tmpstr, "GETINPUT") == 0)
- X {
- X /* get screen name */
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", tmpstr); /* screen name */
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr); /* sitting at system(3) */
- X rc = runscreen (tmpstr, menu, *opnumber);
- X if (rc == KEY_CANCEL)
- X return (0);
- X }
- X
- X reset_shell_mode ();
- X signal (SIGINT, shutdown);
- X signal (SIGQUIT, shutdown);
- X rc = system (comptr);
- X if (trapsigs)
- X {
- X signal (SIGINT, SIG_IGN);
- X signal (SIGQUIT, SIG_IGN);
- X }
- X reset_prog_mode ();
- X keypad (stdscr, TRUE);
- X
- X /*
- X ** Going from a shell return code (char) to a c return code (int)
- X ** the shell return code gets put in the high byte. So we will
- X ** shift the int right 8 bytes.
- X */
- X rc = rc >> 8; /* to get shell rc */
- X if (debug)
- X {
- X fprintf (stderr, "\n[%s] <%s> rc=%d command=%s",
- X __FILE__, keyword, rc, comptr);
- X fflush (stderr);
- X }
- X
- X /*
- X ** Shell can't handle negative return codes so we will convert
- X ** the return code to negative so menu can use it.
- X ** -1 = QUIT
- X ** -2 = MAINMENU
- X ** -3 = PREVMENU
- X ** -4 = NOWAYJOSE
- X ** 100+offset = GNAME
- X */
- X if (rc < GNAMEOFFSET)
- X rc -= rc * 2; /* make negative */
- X
- X if (redrawflag)
- X clearok (stdscr, TRUE);
- X
- X return (rc);
- X}
- X/* Paul J. Condie 12/88 */
- SHAR_EOF
- chmod 0644 ParseUnix.c || echo "restore of ParseUnix.c fails"
- echo "x - extracting ParseGname.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseGname.c &&
- Xstatic char Sccsid[] = "@(#)ParseGname.c 1.5 DeltaDate 11/13/88 ExtrDate 1/22/90";
- X
- X/* FUNCTION: ParseGname()
- X** Parses keyword ".GNAME".
- X** ARGS: keyword the keyword "GNAME"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X
- X
- XParseGname (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char name[BUFSIZE+1];
- X char file[BUFSIZE+1];
- X int i;
- X int NameFound;
- X
- X
- X if (*gindex >= MAXGNAME)
- X {
- X BEEP;
- X mvprintw (20, 0,
- X "Exceeded maximum (%d) number of goto menu names",
- X MAXGNAME-1);
- X shutdown ();
- X }
- X fscanf (menufile, "%s %s", name, file);
- X if (strlen(name) >= 15 || strlen(file) >= 15)
- X {
- X BEEP;
- X mvprintw (20, 0,
- X "The goto menu name and the goto menu file is limited to 14 characters");
- X shutdown ();
- X }
- X
- X /* Check if we already have this menu name */
- X NameFound = FALSE;
- X for (i = 0; i < *gindex; i++)
- X {
- X if (strcmp (name, gnames[i]) == 0)
- X {
- X NameFound = TRUE;
- X strcpy (gfiles[i], file); /* new menu file */
- X }
- X }
- X if (!NameFound)
- X {
- X /* a new name */
- X strcpy (gnames[*gindex], name);
- X strcpy (gfiles[*gindex], file);
- X (*gindex)++;
- X strcpy (gnames[*gindex], ""); /* null last one */
- X }
- X fgets (name, BUFSIZE, menufile); /* junk rest of line */
- X return (0);
- X}
- SHAR_EOF
- chmod 0444 ParseGname.c || echo "restore of ParseGname.c fails"
- echo "x - extracting ParseAuthr.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseAuthr.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseAuthr()
- X** Parses keyword "AUTHORIZE".
- X** This function determines whether you are authorized
- X** to run this menu or not.
- X** ARGS: keyword the keyword "AUTHORIZE"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0 you are authorized
- X** NOWAYJOSE nowayjose
- X*/
- X
- X#include <curses.h>
- X#include <pwd.h>
- X#include "menu.h"
- X
- X
- X
- XParseAuthr (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *strchr();
- X char line[MAXLEN+100], *lptr, word[15];
- X char user[15];
- X int OKflag;
- X struct passwd *getpwuid();
- X struct passwd *pw; /* password entry */
- X
- X
- X pw = getpwuid (getuid()); /* get real uid */
- X strcpy (user, pw->pw_name);
- X
- X /*
- X ** Read in option command
- X ** strcat continuation lines
- X */
- X fgets (line, sizeof(line)-1, menufile);
- X line[strlen(line)-1] = '\0'; /* get rid of \n */
- X while (line[strlen(line)-1] == '\\')
- X {
- X if (strlen(line) >= MAXLEN)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0,
- X "Option command is too long. Max = %d",MAXLEN);
- X shutdown ();
- X }
- X line[strlen(line)-1] = '\0'; /* junk \ */
- X fgets (line+strlen(line), sizeof(line)-1, menufile);
- X line[strlen(line)-1] = '\0'; /* get rid of \n */
- X }
- X
- X lptr = line;
- X OKflag = FALSE;
- X while (lptr && (sscanf (lptr, "%s", word) == 1))
- X {
- SHAR_EOF
- echo "End of part 4"
- echo "File ParseAuthr.c is continued in part 5"
- echo "5" > s2_seq_.tmp
- exit 0
-