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 b1ecd9b6 authored by rswindell's avatar rswindell

Return to the sbbs v2 behavior of printfile() behavior (sort-of): When

P_OPENCLOSE mode flag is *not* specified, do not malloc()/read() the entire
file and then display. Instead, print one line at a time (so long as that
line is <= 1MB in length), calling putmsg() for each line.

This should allow the viewing of massive text files in SBBS again without
alloc/swap issues.

I left the calls to utf8_normalize_str() in here, but I'm not so sure about
them now. putmsg() will convert UTF-8 to CP437 through print_utf8_as_cp437(),
and that only lacks a couple of conversions that utf8_normalize_str() does
(e.g. ellipsis to "..."), so that might be a good candidate to remove in
the future.
parent 3c4224c6
......@@ -39,6 +39,10 @@
#include "sbbs.h"
#include "utf8.h"
#ifndef PRINTFILE_MAX_LINE_LEN
#define PRINTFILE_MAX_LINE_LEN (1024*1024)
#endif
/****************************************************************************/
/* Prints a file remotely and locally, interpreting ^A sequences, checks */
/* for pauses, aborts and ANSI. 'str' is the path of the file to print */
......@@ -97,6 +101,8 @@ bool sbbs_t::printfile(const char* fname, long mode, long org_cols)
errormsg(WHERE,ERR_CHK,fpath,length);
return false;
}
if(mode&P_OPENCLOSE) {
if((buf=(char*)malloc(length+1L))==NULL) {
fclose(stream);
errormsg(WHERE,ERR_ALLOC,fpath,length+1L);
......@@ -113,6 +119,25 @@ bool sbbs_t::printfile(const char* fname, long mode, long org_cols)
putmsg(buf,mode,org_cols);
}
free(buf);
} else { // Line-at-a-time mode
if(length > PRINTFILE_MAX_LINE_LEN)
length = PRINTFILE_MAX_LINE_LEN;
if((buf=(char*)malloc(length+1L))==NULL) {
fclose(stream);
errormsg(WHERE,ERR_ALLOC,fpath,length+1L);
return false;
}
while(!feof(stream) && !msgabort()) {
if(fgets(buf, length-1, stream) == NULL)
break;
buf[length] = 0;
if((mode&P_UTF8) && !term_supports(UTF8))
utf8_normalize_str(buf);
putmsg(buf, mode, org_cols);
}
free(buf);
fclose(stream);
}
if((mode&P_NOABORT || rip) && online==ON_REMOTE) {
SYNC;
......
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