]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/libf2c/libF77/s_paus.c
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / libf2c / libF77 / s_paus.c
1 #include <stdio.h>
2 #include "f2c.h"
3 #define PAUSESIG 15
4
5 #include "signal1.h"
6 #undef abs
7 #undef min
8 #undef max
9 #include <stdlib.h>
10 extern int getpid (void), isatty (int), pause (void);
11
12 extern void f_exit (void);
13
14 static void
15 waitpause (Sigarg)
16 {
17   Use_Sigarg;
18   return;
19 }
20
21 static void
22 s_1paus (FILE * fin)
23 {
24   fprintf (stderr,
25            "To resume execution, type go.  Other input will terminate the job.\n");
26   fflush (stderr);
27   if (getc (fin) != 'g' || getc (fin) != 'o' || getc (fin) != '\n')
28     {
29       fprintf (stderr, "STOP\n");
30 #ifdef NO_ONEXIT
31       f_exit ();
32 #endif
33       exit (0);
34     }
35 }
36
37 int
38 s_paus (char *s, ftnlen n)
39 {
40   fprintf (stderr, "PAUSE ");
41   if (n > 0)
42     fprintf (stderr, " %.*s", (int) n, s);
43   fprintf (stderr, " statement executed\n");
44   if (isatty (fileno (stdin)))
45     s_1paus (stdin);
46   else
47     {
48 #if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
49       FILE *fin;
50       fin = fopen ("con", "r");
51       if (!fin)
52         {
53           fprintf (stderr, "s_paus: can't open con!\n");
54           fflush (stderr);
55           exit (1);
56         }
57       s_1paus (fin);
58       fclose (fin);
59 #else
60       fprintf (stderr,
61                "To resume execution, execute a   kill -%d %d   command\n",
62                PAUSESIG, getpid ());
63       signal1 (PAUSESIG, waitpause);
64       fflush (stderr);
65       pause ();
66 #endif
67     }
68   fprintf (stderr, "Execution resumes after PAUSE.\n");
69   fflush (stderr);
70   return 0;                     /* NOT REACHED */
71 }