Initial revision
[official-gcc.git] / libf2c / libF77 / s_paus.c
blobee2a0ee6bf5aaa5d33f15b118e4777ddc1e9d93b
1 #include <stdio.h>
2 #include "f2c.h"
3 #define PAUSESIG 15
5 #ifdef KR_headers
6 #define Void /* void */
7 #define Int /* int */
8 #else
9 #define Void void
10 #define Int int
11 #undef abs
12 #undef min
13 #undef max
14 #include <stdlib.h>
15 #include "signal1.h"
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 extern int getpid(void), isatty(int), pause(void);
20 #endif
22 extern VOID f_exit(Void);
24 static VOID
25 waitpause(Int n)
26 { n = n; /* shut up compiler warning */
27 return;
30 static VOID
31 #ifdef KR_headers
32 s_1paus(fin) FILE *fin;
33 #else
34 s_1paus(FILE *fin)
35 #endif
37 fprintf(stderr,
38 "To resume execution, type go. Other input will terminate the job.\n");
39 fflush(stderr);
40 if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
41 fprintf(stderr, "STOP\n");
42 #ifdef NO_ONEXIT
43 f_exit();
44 #endif
45 exit(0);
49 int
50 #ifdef KR_headers
51 s_paus(s, n) char *s; ftnlen n;
52 #else
53 s_paus(char *s, ftnlen n)
54 #endif
56 fprintf(stderr, "PAUSE ");
57 if(n > 0)
58 fprintf(stderr, " %.*s", (int)n, s);
59 fprintf(stderr, " statement executed\n");
60 if( isatty(fileno(stdin)) )
61 s_1paus(stdin);
62 else {
63 #if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
64 FILE *fin;
65 fin = fopen("con", "r");
66 if (!fin) {
67 fprintf(stderr, "s_paus: can't open con!\n");
68 fflush(stderr);
69 exit(1);
71 s_1paus(fin);
72 fclose(fin);
73 #else
74 fprintf(stderr,
75 "To resume execution, execute a kill -%d %d command\n",
76 PAUSESIG, getpid() );
77 signal1(PAUSESIG, waitpause);
78 fflush(stderr);
79 pause();
80 #endif
82 fprintf(stderr, "Execution resumes after PAUSE.\n");
83 fflush(stderr);
84 return 0; /* NOT REACHED */
85 #ifdef __cplusplus
87 #endif