freebsd-dev/contrib/libf2c/libF77/s_paus.c

72 lines
1.4 KiB
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
#include <stdio.h>
#include "f2c.h"
#define PAUSESIG 15
#include "signal1.h"
#undef abs
#undef min
#undef max
#include <stdlib.h>
2003-07-11 03:42:19 +00:00
extern int getpid (void), isatty (int), pause (void);
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
extern void f_exit (void);
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
static void
waitpause (Sigarg)
{
Use_Sigarg;
return;
}
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
static void
s_1paus (FILE * fin)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
fprintf (stderr,
"To resume execution, type go. Other input will terminate the job.\n");
fflush (stderr);
if (getc (fin) != 'g' || getc (fin) != 'o' || getc (fin) != '\n')
{
fprintf (stderr, "STOP\n");
1999-09-18 10:51:31 +00:00
#ifdef NO_ONEXIT
2003-07-11 03:42:19 +00:00
f_exit ();
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
exit (0);
}
}
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
int
s_paus (char *s, ftnlen n)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
fprintf (stderr, "PAUSE ");
if (n > 0)
fprintf (stderr, " %.*s", (int) n, s);
fprintf (stderr, " statement executed\n");
if (isatty (fileno (stdin)))
s_1paus (stdin);
else
{
1999-09-18 10:51:31 +00:00
#if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
2003-07-11 03:42:19 +00:00
FILE *fin;
fin = fopen ("con", "r");
if (!fin)
{
fprintf (stderr, "s_paus: can't open con!\n");
fflush (stderr);
exit (1);
1999-09-18 10:51:31 +00:00
}
2003-07-11 03:42:19 +00:00
s_1paus (fin);
fclose (fin);
#else
fprintf (stderr,
"To resume execution, execute a kill -%d %d command\n",
PAUSESIG, getpid ());
signal1 (PAUSESIG, waitpause);
fflush (stderr);
pause ();
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
}
fprintf (stderr, "Execution resumes after PAUSE.\n");
fflush (stderr);
return 0; /* NOT REACHED */
1999-09-18 10:51:31 +00:00
}