Wild Life  2.30
 All Data Structures Files Functions Variables Typedefs Macros
Functions | Variables
interrupt.c File Reference

handle interrupts etc More...

Go to the source code of this file.

Functions

void interrupt ()
 INTERRUPT() More...
 
void init_interrupt ()
 INIT_INTERRUPT. More...
 
void handle_interrupt ()
 HANDLE_INTERRUPT. More...
 

Variables

long interrupted =FALSE
 

Detailed Description

handle interrupts etc

Definition in file interrupt.c.

Function Documentation

void handle_interrupt ( )

HANDLE_INTERRUPT.

This deals with an eventual interrupt. Return TRUE if execution continues normally, otherwise abort query, toggle trace on or off, or quit Wild_Life (suicide).

Definition at line 52 of file interrupt.c.

References abort_life(), DIGIT, EOLN, exit_life(), FALSE, input_state, interrupted, open_input_file(), prompt, quietflag, read_char(), restore_state(), show_count(), stdin_cleareof(), stepcount, stepflag, steptrace, trace, TRUE, and verbose.

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
long verbose
Definition: def_glob.h:914
#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
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
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
void init_interrupt ( )

INIT_INTERRUPT.

This initialises interrupts by trapping the interrupt signal and sending it to INTERRUPT.

Definition at line 36 of file interrupt.c.

References interrupt().

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 }
void interrupt()
INTERRUPT()
Definition: interrupt.c:21
void interrupt ( )

INTERRUPT()

This routine is called whenever the user types CONTROL C which generates an interrupt. The interrupt is dealt with later, when convenient, or ignored.

Definition at line 21 of file interrupt.c.

References interrupted, and TRUE.

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 }
void interrupt()
INTERRUPT()
Definition: interrupt.c:21
#define TRUE
Standard boolean.
Definition: def_const.h:268
long interrupted
Definition: interrupt.c:12

Variable Documentation

long interrupted =FALSE

Definition at line 12 of file interrupt.c.