Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
s_paus.c
Go to the documentation of this file.00001 #include "stdlib.h"
00002 #include "stdio.h"
00003 #include "f2c.h"
00004 #define PAUSESIG 15
00005
00006 #ifdef KR_headers
00007 #define Void
00008 #define Int
00009 #else
00010 #define Void void
00011 #define Int int
00012 #undef abs
00013 #undef min
00014 #undef max
00015 #include "stdlib.h"
00016 #include "signal.h"
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 extern int getpid(void), isatty(int), pause(void);
00021 #endif
00022
00023 extern VOID f_exit(Void);
00024
00025 static VOID
00026 waitpause(Int n)
00027 { n = n;
00028 return;
00029 }
00030
00031 static VOID
00032 #ifdef KR_headers
00033 s_1paus(fin) FILE *fin;
00034 #else
00035 s_1paus(FILE *fin)
00036 #endif
00037 {
00038 fprintf(stderr,
00039 "To resume execution, type go. Other input will terminate the job.\n");
00040 fflush(stderr);
00041 if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
00042 fprintf(stderr, "STOP\n");
00043 #ifdef NO_ONEXIT
00044 f_exit();
00045 #endif
00046 exit(0);
00047 }
00048 }
00049
00050 int
00051 #ifdef KR_headers
00052 s_paus(s, n) char *s; ftnlen n;
00053 #else
00054 s_paus(char *s, ftnlen n)
00055 #endif
00056 {
00057 fprintf(stderr, "PAUSE ");
00058 if(n > 0)
00059 fprintf(stderr, " %.*s", (int)n, s);
00060 fprintf(stderr, " statement executed\n");
00061 if( isatty(fileno(stdin)) )
00062 s_1paus(stdin);
00063 else {
00064 #ifdef MSDOS
00065 FILE *fin;
00066 fin = fopen("con", "r");
00067 if (!fin) {
00068 fprintf(stderr, "s_paus: can't open con!\n");
00069 fflush(stderr);
00070 exit(1);
00071 }
00072 s_1paus(fin);
00073 fclose(fin);
00074 #else
00075 fprintf(stderr,
00076 "To resume execution, execute a kill -%d %d command\n",
00077 PAUSESIG, getpid() );
00078 signal(PAUSESIG, waitpause);
00079 fflush(stderr);
00080 pause();
00081 #endif
00082 }
00083 fprintf(stderr, "Execution resumes after PAUSE.\n");
00084 fflush(stderr);
00085 return 0;
00086 #ifdef __cplusplus
00087 }
00088 #endif
00089 }