From 16ffc14082970177cd14efa86a6e03eded062d1e Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Thu, 5 Dec 2024 16:43:45 -0800 Subject: [PATCH] Add "Printing file" and "Printing tail" debug-level log messages In printfile() and printtail() which are used by menu() and many other functions. These should be helpful to sysops that just want to know what file is being displayed under what conditions (e.g. for trouble-shooting or customization reasons). --- src/sbbs3/prntfile.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/sbbs3/prntfile.cpp b/src/sbbs3/prntfile.cpp index 3a72c2b101..1c420a92b8 100644 --- a/src/sbbs3/prntfile.cpp +++ b/src/sbbs3/prntfile.cpp @@ -62,9 +62,9 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) if(mode&P_NOABORT || rip) { if(online==ON_REMOTE && console&CON_R_ECHO) { rioctl(IOCM|ABORT); - rioctl(IOCS|ABORT); + rioctl(IOCS|ABORT); } - sys_status&=~SS_ABORT; + sys_status&=~SS_ABORT; } if((stream=fnopen(&file,fpath,O_RDONLY|O_DENYNONE))==NULL) { @@ -75,7 +75,7 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) if(SYSOP) bputs(fpath); CRLF; } - return false; + return false; } length=(int)filelength(file); @@ -88,6 +88,7 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) return true; } + lprintf(LOG_DEBUG, "Printing file: %s", fpath); if(!(mode&P_NOCRLF) && row > 0 && !rip) { newline(); } @@ -96,7 +97,7 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) if((buf=(char*)malloc(length+1L))==NULL) { fclose(stream); errormsg(WHERE,ERR_ALLOC,fpath,length+1L); - return false; + return false; } l=read(file,buf,length); fclose(stream); @@ -125,7 +126,7 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) if((buf=(char*)malloc(length+1L))==NULL) { fclose(stream); errormsg(WHERE,ERR_ALLOC,fpath,length+1L); - return false; + return false; } uint rainbow_sav[LEN_RAINBOW + 1]; memcpy(rainbow_sav, rainbow, sizeof rainbow_sav); @@ -160,7 +161,7 @@ bool sbbs_t::printfile(const char* fname, int mode, int org_cols, JSObject* obj) if((mode&P_NOABORT || rip) && online==ON_REMOTE) { sync(); - rioctl(IOSM|ABORT); + rioctl(IOSM|ABORT); } if(rip) ansi_getdims(); @@ -183,9 +184,9 @@ bool sbbs_t::printtail(const char* fname, int lines, int mode, int org_cols, JSO if(mode&P_NOABORT) { if(online==ON_REMOTE) { rioctl(IOCM|ABORT); - rioctl(IOCS|ABORT); + rioctl(IOCS|ABORT); } - sys_status&=~SS_ABORT; + sys_status&=~SS_ABORT; } if((fp=fnopen(&file,fpath,O_RDONLY|O_DENYNONE))==NULL) { if(!(mode&P_NOERROR)) { @@ -195,10 +196,7 @@ bool sbbs_t::printtail(const char* fname, int lines, int mode, int org_cols, JSO if(SYSOP) bputs(fpath); CRLF; } - return false; - } - if(!(mode&P_NOCRLF) && row > 0) { - newline(); + return false; } length=(int)filelength(file); if(length<0) { @@ -206,14 +204,20 @@ bool sbbs_t::printtail(const char* fname, int lines, int mode, int org_cols, JSO errormsg(WHERE,ERR_CHK,fpath,length); return false; } + + lprintf(LOG_DEBUG, "Printing tail: %s", fpath); + if(!(mode&P_NOCRLF) && row > 0) { + newline(); + } + if(length > lines * PRINTFILE_MAX_LINE_LEN) { - length = lines * PRINTFILE_MAX_LINE_LEN; + length = lines * PRINTFILE_MAX_LINE_LEN; (void)fseek(fp, -length, SEEK_END); } if((buf=(char*)malloc(length+1L))==NULL) { fclose(fp); errormsg(WHERE,ERR_ALLOC,fpath,length+1L); - return false; + return false; } l=fread(buf, sizeof(char), length, fp); fclose(fp); @@ -228,15 +232,15 @@ bool sbbs_t::printtail(const char* fname, int lines, int mode, int org_cols, JSO cur++; if(cur>=lines) { p++; - break; + break; } - p--; + p--; } putmsg(p,mode,org_cols, obj); } if(mode&P_NOABORT && online==ON_REMOTE) { sync(); - rioctl(IOSM|ABORT); + rioctl(IOSM|ABORT); } free(buf); return true; -- GitLab