Wild Life  2.30
 All Data Structures Files Functions Variables Typedefs Macros
interrupt.c
Go to the documentation of this file.
1 
6 /* Copyright 1991 Digital Equipment Corporation.
7 ** All Rights Reserved.
8 *****************************************************************/
9 
10 #include "defs.h"
11 
13 
21 void interrupt()
22 {
23  void (*f)(); /* RM: Apr 7 1993 Weird problem in GCC and C89 */
24 
26  f=interrupt;
27  (void)signal(SIGINT,f);/* RM: Feb 15 1993 */
28 }
29 
37 {
38  void (*f)(); /* RM: Apr 7 1993 Weird problem in GCC and C89 */
39  f=interrupt;
40  if (signal(SIGINT,SIG_IGN)!=SIG_IGN)
41  (void)signal(SIGINT,f);
42 }
43 
53 {
54  ptr_psi_term old_state_loc;
55  char *old_prompt;
56  int old_quiet; /* 21.1 */
57  long c,d; /* 21.12 (prev. char) */
58  long count;
59 
60  if (interrupted) printf("\n");
62  old_prompt=prompt;
63  old_quiet=quietflag; /* 21.1 */
65 
66  /* new_state(&old_state_loc); */
67  old_state_loc=input_state;
68  (void)open_input_file("stdin");
70 
71  StartAgain:
72  do {
73  printf("*** Command ");
74  prompt="(q,c,a,s,t,h)?";
75  quietflag=FALSE; /* 21.1 */
76 
77  do {
78  c=read_char();
79  } while (c!=EOLN && c>0 && c<=32);
80 
81  d=c;
82  count=0;
83  while (DIGIT(d)) { count=count*10+(d-'0'); d=read_char(); }
84 
85  while (d!=EOLN && d!=EOF) d=read_char();
86 
87  if (c=='h' || c=='?') {
88  printf("*** [Quit (q), Continue (c), Abort (a), Step (s,RETURN), Trace (t), Help (h,?)]\n");
89  }
90 
91  } while (c=='h' || c=='?');
92 
93  prompt=old_prompt;
94  quietflag=old_quiet; /* 21.1 */
95 
96  switch (c) {
97  case 'v':
98  case 'V':
99  verbose=TRUE;
100  break;
101  case 'q':
102  case 'Q':
103  case EOF:
104  if (c==EOF) printf("\n");
105  exit_life(FALSE);
106  break;
107  case 'a':
108  case 'A':
109  (void)abort_life(FALSE);
110  show_count();
111  break;
112  case 'c':
113  case 'C':
114  trace=FALSE;
115  stepflag=FALSE;
116  break;
117  case 't':
118  case 'T':
119  trace=TRUE;
120  stepflag=FALSE;
121  break;
122  case 's':
123  case 'S':
124  case EOLN:
125  trace=TRUE;
126  stepflag=TRUE;
127  break;
128  case '0': case '1': case '2': case '3': case '4':
129  case '5': case '6': case '7': case '8': case '9':
130  trace=TRUE;
131  stepflag=TRUE;
132  if (count>0) {
133  stepcount=count;
134  stepflag=FALSE;
135  }
136  break;
137  default:
138  goto StartAgain;
139  }
140  input_state=old_state_loc;
142 }
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
void init_interrupt()
INIT_INTERRUPT.
Definition: interrupt.c:36
long verbose
Definition: def_glob.h:914
includes
#define DIGIT(C)
Definition: def_macro.h:42
long quietflag
Definition: def_glob.h:912
void show_count()
show_count
Definition: login.c:1161
ptr_psi_term input_state
Definition: def_glob.h:856
long steptrace
Definition: def_glob.h:915
void interrupt()
INTERRUPT()
Definition: interrupt.c:21
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
long trace
Definition: def_glob.h:913
long stepcount
Definition: def_glob.h:916
#define EOLN
End of line.
Definition: def_const.h:309
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long stepflag
Definition: def_glob.h:676
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
char * prompt
Definition: def_glob.h:1018
long read_char()
read_char
Definition: token.c:680
void handle_interrupt()
HANDLE_INTERRUPT.
Definition: interrupt.c:52
long interrupted
Definition: interrupt.c:12
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
long open_input_file(char *file)
open_input_file
Definition: token.c:594