Debian Codegraph @

debian/external_deps/fetk/punc/src/vf2c/s_paus.c

raw
1 #include "stdio.h"
2 #include "f2c.h"
3 #define PAUSESIG 15
4
5 #ifdef _WIN32
6 #include <io.h> /* for isatty() */
7 #endif
8
9 #include "signal1.h"
10 #ifdef KR_headers
11 #define Void /* void */
12 #define Int /* int */
13 #else
14 #define Void void
15 #define Int int
16 #undef abs
17 #undef min
18 #undef max
19 #include "stdlib.h"
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 extern int getpid(void);
27 #ifndef _WIN32
28 extern int isatty(int);
29 #endif
30 extern int pause(void);
31 #endif /* KR_headers */
32
33 extern VOID f_exit(Void);
34
35 #ifndef MSDOS
36 static VOID
37 waitpause(Sigarg)
38 { Use_Sigarg;
39 return;
40 }
41 #endif
42
43 static VOID
44 #ifdef KR_headers
45 s_1paus(fin) FILE *fin;
46 #else
47 s_1paus(FILE *fin)
48 #endif
49 {
50 fprintf(stderr,
51 "To resume execution, type go. Other input will terminate the job.\n");
52 fflush(stderr);
53 if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
54 fprintf(stderr, "STOP\n");
55 #ifdef NO_ONEXIT
56 f_exit();
57 #endif
58 exit(0);
59 }
60 }
61
62 int
63 #ifdef KR_headers
64 s_paus(s, n) char *s; ftnlen n;
65 #else
66 s_paus(char *s, ftnlen n)
67 #endif
68 {
69 fprintf(stderr, "PAUSE ");
70 if(n > 0)
71 fprintf(stderr, " %.*s", (int)n, s);
72 fprintf(stderr, " statement executed\n");
73 if( isatty(fileno(stdin)) )
74 s_1paus(stdin);
75 else {
76 #ifdef MSDOS
77 FILE *fin;
78 fin = fopen("con", "r");
79 if (!fin) {
80 fprintf(stderr, "s_paus: can't open con!\n");
81 fflush(stderr);
82 exit(1);
83 }
84 s_1paus(fin);
85 fclose(fin);
86 #else
87 fprintf(stderr,
88 "To resume execution, execute a kill -%d %d command\n",
89 PAUSESIG, getpid() );
90 signal1(PAUSESIG, waitpause);
91 fflush(stderr);
92 pause();
93 #endif
94 }
95 fprintf(stderr, "Execution resumes after PAUSE.\n");
96 fflush(stderr);
97 return 0; /* NOT REACHED */
98 #ifdef __cplusplus
99 }
100 #endif
101 }
102 #ifdef __cplusplus
103 }
104 #endif