--- sbbs/src/sbbs3/text_sec.cpp 2018/04/24 16:41:23 1.1.1.1 +++ sbbs/src/sbbs3/text_sec.cpp 2018/04/24 16:43:25 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet general text file (g-file) section */ -/* $Id: text_sec.cpp,v 1.1.1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: text_sec.cpp,v 1.1.1.2 2018/04/24 16:43:25 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -55,13 +55,15 @@ int sbbs_t::text_sec() FILE *stream; for(i=j=0;iar,&useron)) + if(!chk_ar(cfg.txtsec[i]->ar,&useron,&client)) continue; - usrsec[j++]=i; } + usrsec[j++]=i; + } usrsecs=j; if(!usrsecs) { bputs(text[NoTextSections]); - return(1); } + return(1); + } action=NODE_RTXT; while(online) { sprintf(str,"%smenu/text_sec.*",cfg.text_dir); @@ -72,7 +74,9 @@ int sbbs_t::text_sec() for(i=0;iname); if(i<9) outchar(' '); - bputs(str); } } + bputs(str); + } + } ASYNC; mnemonics(text[WhichTextSection]); if((cursec=getnum(usrsecs))<1) @@ -83,47 +87,57 @@ int sbbs_t::text_sec() if(fexist(str)) { sprintf(str,"text%lu",cursec+1); menu(str); - usemenu=1; } + usemenu=1; + } else { bprintf(text[TextFilesLstHdr],cfg.txtsec[usrsec[cursec]]->name); - usemenu=0; } + usemenu=0; + } sprintf(str,"%stext/%s.ixt",cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code); j=0; if(fexist(str)) { if((stream=fnopen((int *)&i,str,O_RDONLY))==NULL) { errormsg(WHERE,ERR_OPEN,str,O_RDONLY); - return(0); } + return(0); + } while(!ferror(stream) && !msgabort()) { /* file open too long */ if(!fgets(str,81,stream)) break; str[strlen(str)-2]=0; /* chop off CRLF */ if((file[j]=(char *)malloc(strlen(str)+1))==NULL) { errormsg(WHERE,ERR_ALLOC,nulstr,strlen(str)+1); - continue; } + continue; + } strcpy(file[j],str); fgets(str,81,stream); if(!usemenu) bprintf(text[TextFilesLstFmt],j+1,str); - j++; } - fclose(stream); } + j++; + } + fclose(stream); + } ASYNC; if(SYSOP) { strcpy(str,"QARE?"); - mnemonics(text[WhichTextFileSysop]); } + mnemonics(text[WhichTextFileSysop]); + } else { strcpy(str,"Q?"); - mnemonics(text[WhichTextFile]); } + mnemonics(text[WhichTextFile]); + } i=getkeys(str,j); if(!(i&0x80000000L)) { /* no file number */ for(l=0;lcode); - removeline(str,addpath,2,0); } + removeline(str,addpath,2,0); + } else { /* Edit */ strcpy(str,tmp); - editfile(str); } - continue; } + editfile(str); + } + continue; + } i=(i&~0x80000000L)-1; if(!strchr(file[i],'\\') && !strchr(file[i],'/')) sprintf(str,"%stext/%s/%s" ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code,file[i]); else strcpy(str,file[i]); + fexistcase(str); attr(LIGHTGRAY); printfile(str,0); sprintf(str,"%s read text file: %s" @@ -227,7 +254,9 @@ int sbbs_t::text_sec() pause(); sys_status&=~SS_ABORT; for(i=0;i