keyboard interrupts. Replaced with a non-blocking check for keyboard input
which sets the global variable 'sigcaught' if either key was pressed.
fmout() and pprintf() switch to 'drain mode' if sigcaught is set.
This closes Bug #18.
+ Revision 572.12 2000/07/09 02:27:02 ajc
+ * Eliminated the whole SIGINT/SIGQUIT based handling of Ctrl-O and Ctrl-C
+ keyboard interrupts. Replaced with a non-blocking check for keyboard input
+ which sets the global variable 'sigcaught' if either key was pressed.
+ fmout() and pprintf() switch to 'drain mode' if sigcaught is set.
+ This closes Bug #18.
+
Revision 572.11 2000/07/06 20:26:36 ajc
* updated .Help SUMMARY
Revision 572.11 2000/07/06 20:26:36 ajc
* updated .Help SUMMARY
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-/*
- * We handle "next" and "stop" much differently than in earlier versions.
- * The signal catching routine simply sets a flag and returns.
- */
-void sighandler(int which_sig)
-{
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- sigcaught = which_sig;
- return;
-}
-
-
/*
* signal catching function for hangups...
*/
/*
* signal catching function for hangups...
*/
pprintf("%s\n", &buf[4]);
return;
}
pprintf("%s\n", &buf[4]);
return;
}
- sigcaught = 0;
- sttybbs(SB_YES_INTR);
pprintf(" User Name Num L LastCall Calls Posts\n");
pprintf("------------------------- ----- - ---------- ----- -----\n");
while (serv_gets(buf), strcmp(buf, "000")) {
pprintf(" User Name Num L LastCall Calls Posts\n");
pprintf("------------------------- ----- - ---------- ----- -----\n");
while (serv_gets(buf), strcmp(buf, "000")) {
+/*
+ * If an interesting key has been pressed, return its value, otherwise 0
+ */
+char was_a_key_pressed(void) {
+ fd_set rfds;
+ struct timeval tv;
+ int the_character;
+ int retval;
+
+ FD_ZERO(&rfds);
+ FD_SET(0, &rfds);
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ retval = select(1, &rfds, NULL, NULL, &tv);
+
+ if (FD_ISSET(0, &rfds)) {
+ the_character = inkey();
+ }
+ else {
+ the_character = 0;
+ }
+ return(the_character);
+}
+
+
+
+
/*
* Check to see if we need to pause at the end of a screen.
/*
* Check to see if we need to pause at the end of a screen.
*/
int checkpagin(int lp, int pagin, int height)
{
*/
int checkpagin(int lp, int pagin, int height)
{
+ int thekey;
+
+ if (sigcaught) return(lp);
+ thekey = was_a_key_pressed();
+ if ( (thekey == NEXT_KEY) || (thekey == STOP_KEY)) sigcaught = thekey;
+ if (sigcaught) return(lp);
+
if (!pagin) return(0);
if (lp>=(height-1)) {
set_keepalives(KA_NO);
if (!pagin) return(0);
if (lp>=(height-1)) {
set_keepalives(KA_NO);
va_list arg_ptr;
static char buf[4096]; /* static for performance, change if needed */
int i;
va_list arg_ptr;
static char buf[4096]; /* static for performance, change if needed */
int i;
+
+ /* If sigcaught is nonzero, a keypress has interrupted this and we
+ * should just drain output.
+ */
+ if (sigcaught) return;
+
+ /* Otherwise, start spewing... */
va_start(arg_ptr, format);
vsprintf(buf, format, arg_ptr);
va_end(arg_ptr);
va_start(arg_ptr, format);
vsprintf(buf, format, arg_ptr);
va_end(arg_ptr);
int this_lazy_cmd;
struct citcmd *cptr;
int this_lazy_cmd;
struct citcmd *cptr;
+ /*
+ * Starting a new command now, so set sigcaught to 0. This variable
+ * is set to nonzero (usually NEXT_KEY or STOP_KEY) if a command has
+ * been interrupted by a keypress.
+ */
+ sigcaught = 0;
+
/* Switch color support on or off if we're in user mode */
if (rc_ansi_color == 3) {
if (userflags & US_COLOR)
/* Switch color support on or off if we're in user mode */
if (rc_ansi_color == 3) {
if (userflags & US_COLOR)
/*
* set tty modes. commands are:
*
/*
* set tty modes. commands are:
*
- * 0 - set to bbs mode, intr/quit disabled
- * 1 - set to bbs mode, intr/quit enabled
* 2 - save current settings for later restoral
* 3 - restore saved settings
*/
* 2 - save current settings for later restoral
* 3 - restore saved settings
*/
live.c_oflag = OPOST | ONLCR;
live.c_lflag = ISIG | NOFLSH;
live.c_oflag = OPOST | ONLCR;
live.c_lflag = ISIG | NOFLSH;
- if (cmd == SB_YES_INTR) {
- live.c_cc[VINTR] = NEXT_KEY;
- live.c_cc[VQUIT] = STOP_KEY;
- signal(SIGINT, *sighandler);
- signal(SIGQUIT, *sighandler);
- } else {
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- live.c_cc[VINTR] = (-1);
- live.c_cc[VQUIT] = (-1);
- }
+ live.c_cc[VINTR] = (-1);
+ live.c_cc[VQUIT] = (-1);
/* do we even need this stuff anymore? */
/* live.c_line=0; */
/* do we even need this stuff anymore? */
/* live.c_line=0; */
/*
* fmout() - Citadel text formatter and paginator
*/
/*
* fmout() - Citadel text formatter and paginator
*/
-int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char subst)
- /* screen width to use */
- /* file to read from, or NULL to read from server */
- /* nonzero if we should use the paginator */
- /* screen height to use */
- /* starting value for lines_printed, -1 for global */
- /* nonzero if we should use hypertext mode */
+int fmout(
+ int width, /* screen width to use */
+ FILE *fp, /* file to read from, or NULL to read from server */
+ char pagin, /* nonzero if we should use the paginator */
+ int height, /* screen height to use */
+ int starting_lp,/* starting value for lines_printed, -1 for global */
+ char subst) /* nonzero if we should use hypertext mode */
{
int a, b, c, d, old;
int real = (-1);
{
int a, b, c, d, old;
int real = (-1);
strcpy(buffer, "");
c = 1; /* c is the current pos */
strcpy(buffer, "");
c = 1; /* c is the current pos */
- sigcaught = 0;
- sttybbs(1);
-
FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) {
FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) {
-
- if (sigcaught)
- goto OOPS;
if (fp != NULL) { /* read from file */
if (feof(fp))
eof_flag = 1;
if (fp != NULL) { /* read from file */
if (feof(fp))
eof_flag = 1;
c = 1;
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
c = 1;
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
+ if (sigcaught) goto OOPS;
strcpy(aaa, "");
goto FMTA;
}
goto FMTA;
strcpy(aaa, "");
goto FMTA;
}
goto FMTA;
- /* signal caught; drain the server */
- OOPS:do {
+ /* keypress caught; drain the server */
+OOPS: do {
serv_gets(aaa);
} while (strcmp(aaa, "000"));
serv_gets(aaa);
} while (strcmp(aaa, "000"));
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
return (sigcaught);
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
return (sigcaught);
void async_ka_start(void);
void async_ka_end(void);
int checkpagin(int lp, int pagin, int height);
void async_ka_start(void);
void async_ka_end(void);
int checkpagin(int lp, int pagin, int height);
+char was_a_key_pressed(void);
void pprintf(const char *format, ...);
void pprintf(const char *format, ...);
- sigcaught = 0;
- sttybbs(SB_YES_INTR);
room_tree_list(NULL);
room_tree_list(rl);
color(DIM_WHITE);
room_tree_list(NULL);
room_tree_list(rl);
color(DIM_WHITE);
- sttybbs(SB_NO_INTR);
- }
void list_other_floors(void) {
void list_other_floors(void) {
if (buf[0]!='1') {
pprintf("%s\n",&buf[5]);
return;
if (buf[0]!='1') {
pprintf("%s\n",&buf[5]);
return;
- }
- sigcaught = 0;
- sttybbs(SB_YES_INTR);
while (serv_gets(buf), strncmp(buf,"000",3)) {
if (sigcaught==0) pprintf("%s\n",buf);
while (serv_gets(buf), strncmp(buf,"000",3)) {
if (sigcaught==0) pprintf("%s\n",buf);
- }
- sttybbs(SB_NO_INTR);
void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
sttybbs(1);
if (b==NEXT_KEY) sigcaught = SIGINT;
if (b==STOP_KEY) sigcaught = SIGQUIT;
sttybbs(1);
if (b==NEXT_KEY) sigcaught = SIGINT;
if (b==STOP_KEY) sigcaught = SIGQUIT;
/*
* change a user's access level
/*
* change a user's access level