diff --git a/src/sbbs3/scfg/scfgsys.c b/src/sbbs3/scfg/scfgsys.c index e1a6515ba93cbfdb64b4b70a8717529f535bba97..b4fd61405d131f87cf161dc990f8a122e6774913 100644 --- a/src/sbbs3/scfg/scfgsys.c +++ b/src/sbbs3/scfg/scfgsys.c @@ -1631,6 +1631,7 @@ void sys_cfg(void) sprintf(opt[i++],"%-16.16s%s","Logout",cfg.logout_mod); sprintf(opt[i++],"%-16.16s%s","New User",cfg.newuser_mod); sprintf(opt[i++],"%-16.16s%s","Expired User",cfg.expire_mod); + sprintf(opt[i++],"%-16.16s%s","Text Section",cfg.textsec_mod); sprintf(opt[i++],"%-16.16s%s","Read Mail",cfg.readmail_mod); sprintf(opt[i++],"%-16.16s%s","Scan Msgs",cfg.scanposts_mod); sprintf(opt[i++],"%-16.16s%s","Scan Subs",cfg.scansubs_mod); @@ -1651,6 +1652,7 @@ void sys_cfg(void) "`Logout` Executed during terminal logout procedure (offline)\n" "`New User` Executed at end of new terminal user creation process\n" "`Expired User` Executed during daily event when user expires (offline)\n" + "`Text Section` Executed to handle general text file (viewing) section\n" "\n" "Full module command-lines may be used for the operations listed below:\n" "\n" @@ -1698,18 +1700,22 @@ void sys_cfg(void) ,cfg.expire_mod,sizeof(cfg.expire_mod)-1,K_EDIT); break; case 7: + uifc.input(WIN_MID|WIN_SAV,0,0,"Text File Section Module" + ,cfg.textsec_mod,sizeof(cfg.textsec_mod)-1,K_EDIT); + break; + case 8: uifc.input(WIN_MID|WIN_SAV,0,0,"Read Mail Command" ,cfg.readmail_mod,sizeof(cfg.readmail_mod)-1,K_EDIT); break; - case 8: + case 9: uifc.input(WIN_MID|WIN_SAV,0,0,"Scan Msgs Command" ,cfg.scanposts_mod,sizeof(cfg.scanposts_mod)-1,K_EDIT); break; - case 9: + case 10: uifc.input(WIN_MID|WIN_SAV,0,0,"Scan Subs Command" ,cfg.scansubs_mod,sizeof(cfg.scansubs_mod)-1,K_EDIT); break; - case 10: + case 11: uifc.input(WIN_MID|WIN_SAV,0,0,"List Msgs Command" ,cfg.listmsgs_mod,sizeof(cfg.listmsgs_mod)-1,K_EDIT); break; diff --git a/src/sbbs3/scfgdefs.h b/src/sbbs3/scfgdefs.h index 3a872e09112f8770f36507fc3e6a2132c62617bc..a2235f3779142baecb74ea1a512f35489d473906 100644 --- a/src/sbbs3/scfgdefs.h +++ b/src/sbbs3/scfgdefs.h @@ -595,6 +595,7 @@ typedef struct char logout_mod[LEN_MODNAME+1]; /* Logout module */ char sync_mod[LEN_MODNAME+1]; /* Synchronization module */ char expire_mod[LEN_MODNAME+1]; /* User expiration module */ + char textsec_mod[LEN_MODNAME+1]; /* Text section module */ char readmail_mod[LEN_CMD+1]; /* Reading mail module */ char scanposts_mod[LEN_CMD+1]; /* Scanning posts (in a single sub) module */ char scansubs_mod[LEN_CMD+1]; /* Scanning sub-boards module */ diff --git a/src/sbbs3/scfglib1.c b/src/sbbs3/scfglib1.c index b94c2439229c46350cdded3d8e228413e803b1fe..8d7a753e67d184eba34fec601c4cfbb24ab62d98 100644 --- a/src/sbbs3/scfglib1.c +++ b/src/sbbs3/scfglib1.c @@ -305,9 +305,10 @@ BOOL read_main_cfg(scfg_t* cfg, char* error) get_str(cfg->scanposts_mod, instream); get_str(cfg->scansubs_mod, instream); get_str(cfg->listmsgs_mod, instream); + get_str(cfg->textsec_mod,instream); + if(!cfg->textsec_mod[0]) SAFECOPY(cfg->textsec_mod,"text_sec"); - get_int(c,instream); - for(i=0;i<30;i++) /* unused - initialized to NULL */ + for(i=0;i<26;i++) /* unused - initialized to NULL */ get_int(n,instream); for(i=0;i<254;i++) /* unused - initialized to 0xff */ get_int(n,instream); diff --git a/src/sbbs3/scfgsave.c b/src/sbbs3/scfgsave.c index d8d99f54217cf3afc1f2e9f8432c1bd06d449a7f..c0998d206c16ec447b84897b2ed61bc3240b782d 100644 --- a/src/sbbs3/scfgsave.c +++ b/src/sbbs3/scfgsave.c @@ -272,10 +272,10 @@ BOOL DLLCALL write_main_cfg(scfg_t* cfg, int backup_level) put_str(cfg->scanposts_mod, stream); put_str(cfg->scansubs_mod, stream); put_str(cfg->listmsgs_mod, stream); + put_str(cfg->textsec_mod,stream); - put_int(c,stream); n=0; - for(i=0;i<30;i++) + for(i=0;i<26;i++) put_int(n,stream); n=0xffff; for(i=0;i<254;i++) diff --git a/src/sbbs3/text_sec.cpp b/src/sbbs3/text_sec.cpp index 60d062f6322988bd3ec4a76f70aff4657d77ed31..fbfdaea0659b70418f34e42ac752839c844fb806 100644 --- a/src/sbbs3/text_sec.cpp +++ b/src/sbbs3/text_sec.cpp @@ -1,5 +1,3 @@ -/* text_sec.cpp */ - /* Synchronet general text file (g-file) section */ /* $Id$ */ @@ -37,224 +35,15 @@ #include "sbbs.h" -#define MAX_TXTSECS 500 /* Maximum number of text file sections */ -#define MAX_TXTFILES 500 /* Maximum number of text files per section */ - /****************************************************************************/ /* General Text File Section. */ -/* Called from function main_sec */ -/* Returns 1 if no text sections available, 0 otherwise. */ +/* Returns non-zero on error, 0 otherwise. */ /****************************************************************************/ int sbbs_t::text_sec() { - char str[256],usemenu - ,*file[MAX_TXTFILES],addpath[83],addstr[83],*buf,ch; - char tmp[512]; - long i,j,usrsec[MAX_TXTSECS],usrsecs,cursec; - long l,length; - FILE *stream; - - for(i=j=0;i<cfg.total_txtsecs;i++) { - if(!chk_ar(cfg.txtsec[i]->ar,&useron,&client)) - continue; - usrsec[j++]=i; - } - usrsecs=j; - if(!usrsecs) { + if(!cfg.textsec_mod) { bputs(text[NoTextSections]); return(1); } - action=NODE_RTXT; - while(online) { - if(menu_exists("text_sec")) - menu("text_sec"); - else { - bputs(text[TextSectionLstHdr]); - for(i=0;i<usrsecs && !msgabort();i++) { - sprintf(str,text[TextSectionLstFmt],i+1,cfg.txtsec[usrsec[i]]->name); - if(i<9) outchar(' '); - bputs(str); - } - } - ASYNC; - mnemonics(text[WhichTextSection]); - if((cursec=getnum(usrsecs))<1) - break; - cursec--; - while(online) { - sprintf(str,"text%lu",cursec+1); - if(menu_exists(str)) { - menu(str); - usemenu=1; - } - else { - bprintf(text[TextFilesLstHdr],cfg.txtsec[usrsec[cursec]]->name); - 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); - } - 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; - } - strcpy(file[j],str); - fgets(str,81,stream); - if(!usemenu) bprintf(text[TextFilesLstFmt],j+1,str); - j++; - } - fclose(stream); - } - ASYNC; - if(SYSOP) { - strcpy(str,"QARE?"); - mnemonics(text[WhichTextFileSysop]); - } - else { - strcpy(str,"Q?"); - mnemonics(text[WhichTextFile]); - } - i=getkeys(str,j); - if(!(i&0x80000000L)) { /* no file number */ - for(l=0;l<j;l++) - free(file[l]); - if((i=='E' || i=='R') && !j) - continue; - } - if(i=='Q' || !i) - break; - if(i==-1) { /* ctrl-c */ - for(i=0;i<j;i++) - free(file[i]); - return(0); - } - if(i=='?') /* ? means re-list */ - continue; - if(i=='A') { /* Add text file */ - if(j) { - bputs(text[AddTextFileBeforeWhich]); - i=getnum(j+1); - if(i<1) - continue; - i--; /* number of file entries to skip */ } - else - i=0; - bprintf(text[AddTextFilePath] - ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code); - if(!getstr(addpath,80,0)) - continue; - strcat(addpath,crlf); - bputs(text[AddTextFileDesc]); - if(!getstr(addstr,74,0)) - continue; - strcat(addstr,crlf); - sprintf(str,"%stext/%s.ixt" - ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code); - if(i==j) { /* just add to end */ - if((i=nopen(str,O_WRONLY|O_APPEND|O_CREAT))==-1) { - errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_APPEND|O_CREAT); - return(0); - } - write(i,addpath,strlen(addpath)); - write(i,addstr,strlen(addstr)); - close(i); - continue; - } - j=i; /* inserting in middle of file */ - if((stream=fnopen((int *)&i,str,O_RDWR))==NULL) { - errormsg(WHERE,ERR_OPEN,str,O_RDWR); - return(0); - } - length=(long)filelength(i); - for(i=0;i<j;i++) { /* skip two lines for each entry */ - fgets(tmp,81,stream); - fgets(tmp,81,stream); - } - l=(long)ftell(stream); - if((buf=(char *)malloc(length-l))==NULL) { - fclose(stream); - errormsg(WHERE,ERR_ALLOC,str,length-l); - return(0); - } - fread(buf,1,length-l,stream); - fseek(stream,l,SEEK_SET); /* go back to where we need to insert */ - fputs(addpath,stream); - fputs(addstr,stream); - fwrite(buf,1,length-l,stream); - fclose(stream); - free(buf); - continue; - } - if(i=='R' || i=='E') { /* Remove or Edit text file */ - ch=(char)i; - if(ch=='R') - bputs(text[RemoveWhichTextFile]); - else - bputs(text[EditWhichTextFile]); - i=getnum(j); - if(i<1) - continue; - sprintf(str,"%stext/%s.ixt" - ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code); - j=i-1; - if((stream=fnopen(NULL,str,O_RDONLY))==NULL) { - errormsg(WHERE,ERR_OPEN,str,O_RDONLY); - return(0); - } - for(i=0;i<j;i++) { /* skip two lines for each entry */ - fgets(tmp,81,stream); - fgets(tmp,81,stream); - } - fgets(addpath,81,stream); - truncsp(addpath); - fclose(stream); - if(!strchr(addpath,'\\') && !strchr(addpath,'/')) - sprintf(tmp,"%stext/%s/%s" - ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code,addpath); - else - strcpy(tmp,addpath); - if(ch=='R') { /* Remove */ - if(fexist(tmp)) { - sprintf(str,text[DeleteTextFileQ],tmp); - if(!noyes(str)) - if(remove(tmp)) errormsg(WHERE,ERR_REMOVE,tmp,0); - } - sprintf(str,"%stext/%s.ixt" - ,cfg.data_dir,cfg.txtsec[usrsec[cursec]]->code); - removeline(str,addpath,2,0); - } - else { /* Edit */ - strcpy(str,tmp); - 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,"read text file: %s" - ,file[i]); - logline("T-",str); - pause(); - sys_status&=~SS_ABORT; - for(i=0;i<j;i++) - free(file[i]); - } - } - return(0); + return exec_bin(cfg.textsec_mod, &main_csi); } -