Skip to content
Snippets Groups Projects
Commit 20092293 authored by rswindell's avatar rswindell
Browse files

ALL ctrl-keys (built-ins and hot-key events) use same the recursion-protection

mechanism now limiting them to a total maximum depth of 2.
parent a83bc82c
No related branches found
No related tags found
No related merge requests found
...@@ -78,8 +78,12 @@ char sbbs_t::inkey(long mode) ...@@ -78,8 +78,12 @@ char sbbs_t::inkey(long mode)
sys_status|=SS_ABORT; sys_status|=SS_ABORT;
if(mode&K_SPIN) /* back space once if on spinning cursor */ if(mode&K_SPIN) /* back space once if on spinning cursor */
bputs("\b \b"); bputs("\b \b");
return(0); } return(0);
}
if(ch==CTRL_Z && action!=NODE_PCHT) { /* Ctrl-Z toggle raw input mode */ if(ch==CTRL_Z && action!=NODE_PCHT) { /* Ctrl-Z toggle raw input mode */
if(hotkey_inside>1) /* only allow so much recursion */
return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
SAVELINE; SAVELINE;
...@@ -95,9 +99,11 @@ char sbbs_t::inkey(long mode) ...@@ -95,9 +99,11 @@ char sbbs_t::inkey(long mode)
CRLF; CRLF;
RESTORELINE; RESTORELINE;
lncntr=0; lncntr=0;
hotkey_inside--;
if(action!=NODE_MAIN && action!=NODE_XFER) if(action!=NODE_MAIN && action!=NODE_XFER)
return(26); return(CTRL_Z);
return(0); } return(0);
}
if(mode&K_UPPER) if(mode&K_UPPER)
ch=toupper(ch); ch=toupper(ch);
...@@ -106,7 +112,7 @@ char sbbs_t::inkey(long mode) ...@@ -106,7 +112,7 @@ char sbbs_t::inkey(long mode)
return(ch); return(ch);
if(ch<SP) { /* Control chars */ if(ch<SP) { /* Control chars */
if(ch==LF) /* ignore LF's in not in raw mode */ if(ch==LF) /* ignore LF's if not in raw mode */
return(0); return(0);
for(i=0;i<cfg.total_hotkeys;i++) for(i=0;i<cfg.total_hotkeys;i++)
if(cfg.hotkey[i]->key==ch) if(cfg.hotkey[i]->key==ch)
...@@ -114,6 +120,7 @@ char sbbs_t::inkey(long mode) ...@@ -114,6 +120,7 @@ char sbbs_t::inkey(long mode)
if(i<cfg.total_hotkeys) { if(i<cfg.total_hotkeys) {
if(hotkey_inside>1) /* only allow so much recursion */ if(hotkey_inside>1) /* only allow so much recursion */
return(0); return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
if(!(sys_status&SS_SPLITP)) { if(!(sys_status&SS_SPLITP)) {
...@@ -121,22 +128,25 @@ char sbbs_t::inkey(long mode) ...@@ -121,22 +128,25 @@ char sbbs_t::inkey(long mode)
attr(LIGHTGRAY); attr(LIGHTGRAY);
CRLF; CRLF;
} }
hotkey_inside++;
external(cmdstr(cfg.hotkey[i]->cmd,nulstr,nulstr,NULL),0); external(cmdstr(cfg.hotkey[i]->cmd,nulstr,nulstr,NULL),0);
hotkey_inside--;
if(!(sys_status&SS_SPLITP)) { if(!(sys_status&SS_SPLITP)) {
CRLF; CRLF;
RESTORELINE; RESTORELINE;
} }
lncntr=0; lncntr=0;
hotkey_inside--;
return(0); return(0);
} }
if(ch==CTRL_O) { /* Ctrl-O toggles pause temporarily */ if(ch==CTRL_O) { /* Ctrl-O toggles pause temporarily */
useron.misc^=UPAUSE; useron.misc^=UPAUSE;
return(0); } return(0);
}
if(ch==CTRL_P) { /* Ctrl-P Private node-node comm */ if(ch==CTRL_P) { /* Ctrl-P Private node-node comm */
if(!(sys_status&SS_USERON)) if(!(sys_status&SS_USERON))
return(0); /* keep from being recursive */ return(0); /* keep from being recursive */
if(hotkey_inside>1) /* only allow so much recursion */
return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
if(!(sys_status&SS_SPLITP)) { if(!(sys_status&SS_SPLITP)) {
...@@ -152,11 +162,17 @@ char sbbs_t::inkey(long mode) ...@@ -152,11 +162,17 @@ char sbbs_t::inkey(long mode)
RESTORELINE; RESTORELINE;
} }
lncntr=0; lncntr=0;
return(0); } hotkey_inside--;
return(0);
}
if(ch==CTRL_U) { /* Ctrl-U Users online */ if(ch==CTRL_U) { /* Ctrl-U Users online */
/* needs recursion checking */
if(!(sys_status&SS_USERON)) if(!(sys_status&SS_USERON))
return(0); return(0);
if(hotkey_inside>1) /* only allow so much recursion */
return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
if(!(sys_status&SS_SPLITP)) { if(!(sys_status&SS_SPLITP)) {
...@@ -171,10 +187,15 @@ char sbbs_t::inkey(long mode) ...@@ -171,10 +187,15 @@ char sbbs_t::inkey(long mode)
RESTORELINE; RESTORELINE;
} }
lncntr=0; lncntr=0;
return(0); } hotkey_inside--;
return(0);
}
if(ch==CTRL_T && !(sys_status&SS_SPLITP)) { /* Ctrl-T Time information */ if(ch==CTRL_T && !(sys_status&SS_SPLITP)) { /* Ctrl-T Time information */
if(!(sys_status&SS_USERON)) if(!(sys_status&SS_USERON))
return(0); return(0);
if(hotkey_inside>1) /* only allow so much recursion */
return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
SAVELINE; SAVELINE;
...@@ -189,10 +210,15 @@ char sbbs_t::inkey(long mode) ...@@ -189,10 +210,15 @@ char sbbs_t::inkey(long mode)
SYNC; SYNC;
RESTORELINE; RESTORELINE;
lncntr=0; lncntr=0;
return(0); } hotkey_inside--;
return(0);
}
if(ch==CTRL_K && !(sys_status&SS_SPLITP)) { /* Ctrl-k Control key menu */ if(ch==CTRL_K && !(sys_status&SS_SPLITP)) { /* Ctrl-k Control key menu */
if(!(sys_status&SS_USERON)) if(!(sys_status&SS_USERON))
return(0); return(0);
if(hotkey_inside>1) /* only allow so much recursion */
return(0);
hotkey_inside++;
if(mode&K_SPIN) if(mode&K_SPIN)
bputs("\b "); bputs("\b ");
SAVELINE; SAVELINE;
...@@ -202,7 +228,9 @@ char sbbs_t::inkey(long mode) ...@@ -202,7 +228,9 @@ char sbbs_t::inkey(long mode)
ASYNC; ASYNC;
RESTORELINE; RESTORELINE;
lncntr=0; lncntr=0;
return(0); } hotkey_inside--;
return(0);
}
if(ch==ESC && console&CON_R_INPUT) { if(ch==ESC && console&CON_R_INPUT) {
if(mode&K_GETSTR) if(mode&K_GETSTR)
...@@ -217,13 +245,15 @@ char sbbs_t::inkey(long mode) ...@@ -217,13 +245,15 @@ char sbbs_t::inkey(long mode)
if(ch!='[') { if(ch!='[') {
ungetkey(ESC); ungetkey(ESC);
ungetkey(ch); ungetkey(ch);
return(0); } return(0);
}
i=j=0; i=j=0;
autoterm|=ANSI; /* <ESC>[x means they have ANSI */ autoterm|=ANSI; /* <ESC>[x means they have ANSI */
if(!(useron.misc&ANSI) && useron.misc&AUTOTERM && sys_status&SS_USERON if(!(useron.misc&ANSI) && useron.misc&AUTOTERM && sys_status&SS_USERON
&& useron.number) { && useron.number) {
useron.misc|=ANSI; useron.misc|=ANSI;
putuserrec(&cfg,useron.number,U_MISC,8,ultoa(useron.misc,str,16)); } putuserrec(&cfg,useron.number,U_MISC,8,ultoa(useron.misc,str,16));
}
while(i<10 && j<30) { /* up to 3 seconds */ while(i<10 && j<30) { /* up to 3 seconds */
if(rioctl(RXBC)) { if(rioctl(RXBC)) {
ch=incom(); ch=incom();
...@@ -234,40 +264,46 @@ char sbbs_t::inkey(long mode) ...@@ -234,40 +264,46 @@ char sbbs_t::inkey(long mode)
case 'B': case 'B':
return(LF); /* ctrl-j (dn arrow) */ return(LF); /* ctrl-j (dn arrow) */
case 'C': case 'C':
return(0x6); /* ctrl-f (rt arrow) */ return(CTRL_F); /* ctrl-f (rt arrow) */
case 'D': case 'D':
return(0x1d); /* ctrl-] (lf arrow) */ return(0x1d); /* ctrl-] (lf arrow) */
case 'H': case 'H':
return(0x2); /* ctrl-b (beg line) */ return(CTRL_B); /* ctrl-b (beg line) */
case 'K': case 'K':
return(0x5); /* ctrl-e (end line) */ return(CTRL_E); /* ctrl-e (end line) */
} }
ungetkey(ESC); ungetkey(ESC);
ungetkey('['); ungetkey('[');
for(j=0;j<i;j++) for(j=0;j<i;j++)
ungetkey(str[j]); ungetkey(str[j]);
ungetkey(ch); ungetkey(ch);
return(0); } return(0);
}
if(ch=='R') { /* cursor position report */ if(ch=='R') { /* cursor position report */
if(i && !(useron.rows)) { /* auto-detect rows */ if(i && !(useron.rows)) { /* auto-detect rows */
str[i]=0; str[i]=0;
rows=atoi(str); rows=atoi(str);
lprintf("Node %d ANSI cursor position report: %u rows" lprintf("Node %d ANSI cursor position report: %u rows"
,cfg.node_num, rows); ,cfg.node_num, rows);
if(rows<10 || rows>99) rows=24; } if(rows<10 || rows>99) rows=24;
return(0); } }
str[i++]=ch; } return(0);
else { }
str[i++]=ch;
} else {
mswait(100); mswait(100);
j++; } } j++;
}
}
ungetkey(ESC); /* should only get here if time-out */ ungetkey(ESC); /* should only get here if time-out */
ungetkey('['); ungetkey('[');
for(j=0;j<i;j++) for(j=0;j<i;j++)
ungetkey(str[j]); ungetkey(str[j]);
return(0); } return(0);
}
} /* end of control chars */ } /* end of control chars */
return(ch); return(ch);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment