Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 68e52292 authored by rswindell's avatar rswindell

Update display/menu file selection logic based current terminal capabilities.

Newly supported files: text/menu/*.msg (higher priority than .asc when the
terminal supports IBM extened ASCII, aka CP437). These are the same format
as .asc files (and supported more readily by PabloDraw).
Newly supported files: text/menu/*.seq - native PETSCII files for PETSCII
terminals only. Support in the underlying putmsg() function is still
pending.
Also, the text/*.msg files now supports alternative file formats for
RIP/ANSI/PETSCII, if the files exist.
WIP menu support removal.
The new menu/display file selection priority will be detailed on
wiki.synchro.net, but rest assured, it's backwards compatible with
the previous/old priority with the exception of the removal of WIP support
and HTML support.
parent d3b4fd09
......@@ -271,9 +271,12 @@ bool sbbs_t::answer()
/* Detect terminal type */
mswait(200); // Allow some time for Telnet negotiation
rioctl(IOFI); /* flush input buffer */
if(autoterm&PETSCII)
safe_snprintf(str, sizeof(str), "%s %s", VERSION_NOTICE, COPYRIGHT_NOTICE);
if(autoterm&PETSCII) {
SAFECOPY(terminal, "PETSCII");
else { /* ANSI+ terminal detection */
outchar(FF);
center(str);
} else { /* ANSI+ terminal detection */
putcom( "\r\n" /* locate cursor at column 1 */
"\x1b[s" /* save cursor position (necessary for HyperTerm auto-ANSI) */
"\x1b[0c" /* Request CTerm version */
......@@ -295,8 +298,6 @@ bool sbbs_t::answer()
i=l=0;
tos=1;
lncntr=0;
safe_snprintf(str, sizeof(str), "%s %s", VERSION_NOTICE, COPYRIGHT_NOTICE);
strip_ctrl(str, str);
center(str);
while(i++<50 && l<(int)sizeof(str)-1) { /* wait up to 5 seconds for response */
......@@ -362,9 +363,12 @@ bool sbbs_t::answer()
rioctl(IOFI); /* flush left-over or late response chars */
if(!autoterm && str[0]) {
c_escape_str(str,tmp,sizeof(tmp)-1,TRUE);
lprintf(LOG_NOTICE,"terminal auto-detection failed, response: '%s'", tmp);
if(!autoterm) {
autoterm |= NO_EXASCII;
if(str[0]) {
c_escape_str(str,tmp,sizeof(tmp)-1,TRUE);
lprintf(LOG_NOTICE,"terminal auto-detection failed, response: '%s'", tmp);
}
}
if(terminal[0])
lprintf(LOG_DEBUG, "auto-detected terminal type: %lux%lu %s", cols, rows, terminal);
......@@ -455,25 +459,7 @@ bool sbbs_t::answer()
/* Display ANSWER screen */
rioctl(IOSM|PAUSE);
sys_status|=SS_PAUSEON;
SAFEPRINTF(str,"%sanswer",cfg.text_dir);
SAFEPRINTF(path,"%s.rip",str);
if((autoterm&RIP) && fexistcase(path))
printfile(path,P_NOABORT);
else {
SAFEPRINTF(path,"%s.html",str);
if((autoterm&HTML) && fexistcase(path))
printfile(path,P_NOABORT);
else {
SAFEPRINTF(path,"%s.ans",str);
if((autoterm&ANSI) && fexistcase(path))
printfile(path,P_NOABORT);
else {
SAFEPRINTF(path,"%s.asc",str);
if(fexistcase(path))
printfile(path, P_NOABORT);
}
}
}
menu("../answer"); // Should use P_NOABORT ?
sys_status&=~SS_PAUSEON;
exec_bin(cfg.login_mod,&main_csi);
} else /* auto logon here */
......
......@@ -186,52 +186,64 @@ void sbbs_t::printtail(char *str, int lines, long mode)
/****************************************************************************/
/* Displays a menu file (e.g. from the text/menu directory) */
/****************************************************************************/
void sbbs_t::menu(const char *code)
void sbbs_t::menu(const char *code, long mode)
{
char str[MAX_PATH-5],path[MAX_PATH+1];
char path[MAX_PATH+1];
const char *next= "msg";
const char *last = "asc";
sys_status&=~SS_ABORT;
if(menu_file[0])
SAFECOPY(path,menu_file);
else {
if(isfullpath(code))
SAFECOPY(str, code);
else {
backslash(menu_dir);
SAFEPRINTF3(str, "%smenu/%s%s", cfg.text_dir, menu_dir, code);
}
long term = term_supports();
sprintf(path,"%s.%s",str, (term&WIP) ? "wip": (term&RIP) ? "rip" : "html");
if(!(term&(RIP|WIP|HTML)) || !fexistcase(path)) {
SAFEPRINTF(path, "%s.mon", str);
if((term&(COLOR|ANSI))!=ANSI || !fexistcase(path)) {
SAFEPRINTF(path, "%s.ans", str);
if(!(term&ANSI) || !fexistcase(path)) {
SAFEPRINTF2(path, "%s.%ucol.asc", str, cols);
if(!fexistcase(path))
SAFEPRINTF(path, "%s.asc", str);
}
do {
if((term&RIP) && menu_exists(code, "rip", path))
break;
if((term&(ANSI|COLOR)) == ANSI && menu_exists(code, "mon", path))
break;
if((term&ANSI) && menu_exists(code, "ans", path))
break;
if((term&PETSCII) && menu_exists(code, "seq", path))
break;
if(term&NO_EXASCII) {
next = "asc";
last = "msg";
}
}
if(menu_exists(code, next, path))
break;
menu_exists(code, last, path);
} while(0);
}
long mode = P_OPENCLOSE | P_CPM_EOF;
mode |= P_OPENCLOSE | P_CPM_EOF;
if(column == 0)
mode |= P_NOCRLF;
printfile(path, mode);
}
bool sbbs_t::menu_exists(const char *code)
bool sbbs_t::menu_exists(const char *code, const char* ext, char* path)
{
char path[MAX_PATH+1];
char pathbuf[MAX_PATH+1];
if(path == NULL)
path = pathbuf;
if(menu_file[0])
return fexistcase(menu_file) ? true : false;
if(menu_file[0]) {
strncpy(path, menu_file, MAX_PATH);
return fexistcase(path) ? true : false;
}
/* Either <menu>.asc or <menu>.msg is required */
if(ext == NULL)
return menu_exists(code, "asc", path)
|| menu_exists(code, "msg", path);
backslash(menu_dir);
SAFEPRINTF4(path, "%smenu/%s%s.%ucol.asc", cfg.text_dir, menu_dir, code, cols);
safe_snprintf(path, MAX_PATH, "%smenu/%s%s.%ucol.%s"
,cfg.text_dir, menu_dir, code, cols, ext);
if(fexistcase(path))
return true;
SAFEPRINTF3(path, "%smenu/%s%s.asc", cfg.text_dir, menu_dir, code);
safe_snprintf(path, MAX_PATH, "%smenu/%s%s.%s"
,cfg.text_dir, menu_dir, code, ext);
return fexistcase(path) ? true : false;
}
......@@ -746,8 +746,8 @@ public:
/* prntfile.cpp */
void printfile(char *str, long mode);
void printtail(char *str, int lines, long mode);
void menu(const char *code);
bool menu_exists(const char *code);
void menu(const char *code, long mode = 0);
bool menu_exists(const char *code, const char* ext=NULL, char* realpath=NULL);
int uselect(int add, uint n, const char *title, const char *item, const uchar *ar);
uint uselect_total, uselect_num[500];
......
......@@ -855,7 +855,6 @@ char* sbbs_t::datestr(time_t t)
void sbbs_t::sys_info()
{
char tmp[128];
char path[MAX_PATH+1];
uint i;
stats_t stats;
......@@ -881,15 +880,15 @@ void sbbs_t::sys_info()
bprintf(text[SiTotalTime],ultoac(stats.timeon,tmp));
bprintf(text[SiTimeToday],ultoac(stats.ttoday,tmp));
ver();
SAFEPRINTF(path, "%ssystem.msg", cfg.text_dir);
if(fexistcase(path) && text[ViewSysInfoFileQ][0] && yesno(text[ViewSysInfoFileQ])) {
const char* fname = "../system";
if(menu_exists(fname) && text[ViewSysInfoFileQ][0] && yesno(text[ViewSysInfoFileQ])) {
CLS;
printfile(path,0);
menu(fname);
}
SAFEPRINTF(path, "%smenu/logon.asc", cfg.text_dir);
if(fexistcase(path) && text[ViewLogonMsgQ][0] && yesno(text[ViewLogonMsgQ])) {
fname = "logon";
if(menu_exists(fname) && text[ViewLogonMsgQ][0] && yesno(text[ViewLogonMsgQ])) {
CLS;
menu("logon");
menu(fname);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment