home *** CD-ROM | disk | FTP | other *** search
- /*
- * Display the welcome screen and find the pcomm files. Returns a
- * pointer to the STATUS structure. All errors are fatal.
- */
-
- #define DEFAULT "/usr/local/lib/pcomm"
- #define VERSION "1.0"
-
- #include <stdio.h>
- #include <curses.h>
- #include "misc.h"
- #include "status.h"
-
- struct STATUS *
- init(extra, file)
- char *extra, *file;
- {
- char *ans, *findfile(), *strdup(), *mktemp();
- static struct STATUS s;
- void s_error_win(), free_ptr();
- extern char *null_ptr;
- /* find the support files */
- if ((ans = findfile(extra, "pcomm.param")) == NULL)
- s_error_win("Can't find pcomm.param file");
- s.p_path = strdup(ans);
-
- if ((ans = findfile(extra, "pcomm.dial_dir")) == NULL)
- s_error_win("Can't find pcomm.dial_dir file");
- s.d_path = strdup(ans);
-
- if ((ans = findfile(extra, "pcomm.modem")) == NULL)
- s_error_win("Can't find pcomm.modem file");
- s.m_path = strdup(ans);
- /* some defaults */
- s.lock_path = null_ptr;
- s.vs_path = mktemp("/tmp/pcommXXXXXX");
- s.log_path = strdup("NOT_DEFINED");
- s.fd = -1;
- s.log = 0;
- s.print = 0;
- s.msg = 0;
- s.pid = -1;
- /* display herald if no short-cut */
- if (file == NULL) {
-
- mvaddstr(2, 18, "PPPPPP CCCC OOOO MM MM MM MM");
- mvaddstr(3, 18, "P P C O O M M M M M M M M");
- mvaddstr(4, 18, "PPPPPP C O O M M M M M M");
- mvaddstr(5, 18, "P C O O M M M M");
- mvaddstr(6, 18, "P CCCC OOOO M M M M");
-
- mvprintw(10, 26, ">>> Pcomm Version %s <<<", VERSION);
- mvaddstr(13, 14, "A public domain telecommunication program for Unix");
- mvaddstr(14, 8, "designed to operate similar to the popular MSDOS program, ProComm.");
- mvaddstr(15, 11, "ProComm (TM) is copyrighted by Datastorm Technologies, Inc.");
- mvaddstr(19, 45, "Emmet P. Gray");
- mvaddstr(20, 45, "...!ihnp4!uiucuxc!fthood!egray");
- move(LINES-1, COLS-1);
- refresh();
- /* Delay so you can read the herald */
- wait_key(stdscr, 5);
- }
- erase();
- refresh();
- free_ptr(extra);
- return(&s);
- }
-
- /*
- * Search the extra directory (supplied on the command line), then the
- * directory in the PCOMM environmental variable, then the current directory,
- * and lastly, the default directory.
- */
-
- char *
- findfile(extra, name)
- char *extra, *name;
- {
- int i;
- static char temp[200];
- char *pcomm, *getenv(), *path, pbuf[200], *getcwd();
-
- /* see if PCOMM variable is set */
- pcomm = getenv("PCOMM");
- if (pcomm == NULL || *pcomm == NULL)
- pcomm = NULL;
- else {
- /* zap the trailing separator */
- if (pcomm[strlen(pcomm)-1] == '/')
- pcomm[strlen(pcomm)-1] = NULL;
- }
-
- for (i=0; i<4; i++) {
- /* directory search order */
- switch(i) {
- case 0:
- path = extra;
- break;
- case 1:
- path = pcomm;
- break;
- case 2:
- path = getcwd(pbuf, 200);
- break;
- case 3:
- path = DEFAULT;
- break;
- }
- sprintf(temp, "%s/%s", path, name);
- /* read permission checked */
- if (!access(temp, 4))
- return(temp);
- }
- return(NULL);
- }
-
- /*
- * Handle fatal errors, similar to error_win() but we can't rely on
- * the status structure (since it hasn't been created yet!).
- */
-
- void
- s_error_win(str)
- char *str;
- {
- WINDOW *se_win, *newwin();
- void exit();
-
- se_win = newwin(7, 70, 9, 5);
- /* display the nasty note */
- mvwaddstr(se_win, 2, 4, str);
- mvwattrstr(se_win, 5, 24, A_BLINK, "Press any key to exit");
- box(se_win, '|', '-');
- beep();
- wrefresh(se_win);
-
- wgetch(se_win);
- delwin(se_win);
- /* erase the window we made */
- touchwin(stdscr);
- erase();
- refresh();
- endwin();
- exit(1);
- }
-