home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume24
/
chemtab
/
part02
/
cleanup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-12
|
3KB
|
108 lines
/*
* chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
*
* cleanup.c Cleanup (exit) routine
*/
#include <curses.h>
#include <stdio.h>
#include <signal.h>
#include "windows.h"
#include "variables.h"
#include "tune.h"
/*
* cleanup() - no input
*
* purpose: Handle any quit or ^C signal nicely.
*/
cleanup()
{
char c, str[80]; /* input */
#ifdef PRINTQ
char que[80]; /* print queue */
#endif PRINTQ
#ifdef ReGIS
if (regis) endregis();
#endif ReGIS
if (trans) { /* transcript flag */
l1: mvwaddstr(btm, 0, 0, "Would you like your transcript printed out? ");
wrefresh(btm);
cur = btm;
xp = 44; yp = 0;
noecho();
crmode();
c = getchar();
if (c == 'n') {
wclear(btm);
wrefresh(btm);
} else if (c == '?') {
help(1);
goto l1;
} else { /* else print it out */
wprintw(btm, "yes");
wrefresh(btm);
echo(); nocrmode();
#ifdef PRINTQ
wclear(btm);
mvwaddstr(btm, 0, 0, "Queue to print to: ");
wrefresh(btm);
cur = btm; xp = 21; yp = 0;
gets(que);
sprintf(str, "%s%s %d.chemtab", PRINTER, que, getpid());
#else PRINTQ
sprintf(str, "%s %d.chemtab", PRINTER, getpid());
#endif PRINTQ
fclose(fp);
wclear(btm);
wrefresh(btm);
clear(); refresh();
system(str);
}
}
fclose(fp); /* close things up */
echo();
nocrmode();
clear(); refresh();
endwin(); /* turn off curses */
if (trans) {
printf("A copy of your transcript can be found in the file %d.chemtab\n", getpid());
/* printf("\nYou can pick up your printout at the printer to the left of\n");
printf("The White-Board, labelled Happy. Look for your last name in >><<'s on\n");
printf("the top line of each printout. Good luck with Chemistry.\n");
*/ }
fflush(stdout); /* just make sure.. */
exit(1); /* quit nicely */
}
#ifdef USERSHELL
stop() /* Handle a ^Z */
{
char sh[80];
strcpy(sh, getenv("SHELL"));
if (!strlen(sh))
strcpy(sh, USERSHELL);
#ifdef ReGIS
if (regis) endregis();
#endif ReGIS
clear(); refresh();
signal(SIGTSTP, SIG_DFL);
printf("Type 'exit' to return to chemtab...\n");
system(sh);
clear(); refresh();
signal(SIGTSTP, stop);
if (needsit(stdscr)) { touchwin(stdscr); wrefresh(stdscr); }
if (needsit(graph)) { touchwin(graph); wrefresh(graph); }
if (needsit(mn)) { touchwin(mn); wrefresh(mn); }
if (needsit(srt)) { touchwin(srt); wrefresh(srt); }
if (needsit(btm)) { touchwin(btm); wrefresh(btm); }
if (hlp != NULL) { touchwin(hlp); wrefresh(hlp); }
wmove(cur, yp, xp);
wrefresh(mn);
crmode();
}
#endif USERSHELL