|
|
1.1 root 1: /* un_rep.cpp */
2:
3: /* Synchronet QWK replay (REP) packet unpacking routine */
4:
1.1.1.2 ! root 5: /* $Id: un_rep.cpp,v 1.54 2011/08/25 07:48:40 rswindell Exp $ */
1.1 root 6:
7: /****************************************************************************
8: * @format.tab-size 4 (Plain Text/Source Code File Header) *
9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
10: * *
1.1.1.2 ! root 11: * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
1.1 root 12: * *
13: * This program is free software; you can redistribute it and/or *
14: * modify it under the terms of the GNU General Public License *
15: * as published by the Free Software Foundation; either version 2 *
16: * of the License, or (at your option) any later version. *
17: * See the GNU General Public License for more details: gpl.txt or *
18: * http://www.fsf.org/copyleft/gpl.html *
19: * *
20: * Anonymous FTP access to the most recent released source is available at *
21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
22: * *
23: * Anonymous CVS access to the development source and modification history *
24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
26: * (just hit return, no password is necessary) *
27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
28: * *
29: * For Synchronet coding style and modification guidelines, see *
30: * http://www.synchro.net/source.html *
31: * *
32: * You are encouraged to submit any modifications (preferably in Unix diff *
33: * format) via e-mail to [email protected] *
34: * *
35: * Note: If this box doesn't appear square, then you need to fix your tabs. *
36: ****************************************************************************/
37:
38: #include "sbbs.h"
39: #include "qwk.h"
40:
41: /****************************************************************************/
1.1.1.2 ! root 42: /* Convert a QWK conference number into a sub-board offset */
! 43: /* Return INVALID_SUB upon failure to convert */
! 44: /****************************************************************************/
! 45: uint sbbs_t::resolve_qwkconf(uint n)
! 46: {
! 47: uint j,k;
! 48:
! 49: for (j=0;j<usrgrps;j++) {
! 50: for(k=0;k<usrsubs[j];k++)
! 51: if(cfg.sub[usrsub[j][k]]->qwkconf==n)
! 52: break;
! 53: if(k<usrsubs[j])
! 54: break;
! 55: }
! 56:
! 57: if(j>=usrgrps) {
! 58: if(n<1000) { /* version 1 method, start at 101 */
! 59: j=n/100;
! 60: k=n-(j*100);
! 61: }
! 62: else { /* version 2 method, start at 1001 */
! 63: j=n/1000;
! 64: k=n-(j*1000);
! 65: }
! 66: j--; /* j is group */
! 67: k--; /* k is sub */
! 68: if(j>=usrgrps || k>=usrsubs[j] || cfg.sub[usrsub[j][k]]->qwkconf)
! 69: return INVALID_SUB;
! 70: }
! 71:
! 72: return usrsub[j][k];
! 73: }
! 74:
! 75: /****************************************************************************/
1.1 root 76: /* Unpacks .REP packet, 'repname' is the path and filename of the packet */
77: /****************************************************************************/
78: bool sbbs_t::unpack_rep(char* repfile)
79: {
1.1.1.2 ! root 80: char str[MAX_PATH+1],fname[MAX_PATH+1];
! 81: char rep_fname[MAX_PATH+1];
! 82: char msg_fname[MAX_PATH+1];
1.1 root 83: char tmp[512];
84: char inbox[MAX_PATH+1];
85: char block[QWK_BLOCK_LEN];
86: int file;
87: uint i,j,k,lastsub=INVALID_SUB;
1.1.1.2 ! root 88: uint blocks;
! 89: uint usernum;
1.1 root 90: long l,size,misc;
91: ulong n;
92: ulong ex;
93: node_t node;
94: FILE* rep;
1.1.1.2 ! root 95: FILE* fp;
1.1 root 96: DIR* dir;
97: DIRENT* dirent;
1.1.1.2 ! root 98: smbmsg_t msg;
! 99: str_list_t headers=NULL;
! 100: str_list_t ip_can=NULL;
! 101: str_list_t host_can=NULL;
! 102: str_list_t subject_can=NULL;
! 103: str_list_t twit_list=NULL;
! 104: const char* hostname;
! 105: const char* AttemptedToUploadREPpacket="Attempted to upload REP packet";
! 106:
! 107: memset(&msg,0,sizeof(msg));
! 108:
! 109: if(repfile!=NULL) {
! 110: delfiles(cfg.temp_dir,ALLFILES);
! 111: SAFECOPY(rep_fname,repfile);
! 112: } else
! 113: SAFEPRINTF2(rep_fname,"%s%s.rep",cfg.temp_dir,cfg.sys_id);
! 114: if(!fexistcase(rep_fname)) {
1.1 root 115: bputs(text[QWKReplyNotReceived]);
1.1.1.2 ! root 116: logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
! 117: logline(LOG_NOTICE,nulstr,"REP file not received");
1.1 root 118: return(false);
119: }
120: for(k=0;k<cfg.total_fextrs;k++)
1.1.1.2 ! root 121: if(!stricmp(cfg.fextr[k]->ext,useron.tmpext) && chk_ar(cfg.fextr[k]->ar,&useron,&client))
1.1 root 122: break;
123: if(k>=cfg.total_fextrs)
124: k=0;
1.1.1.2 ! root 125: ex=EX_STDOUT;
1.1 root 126: if(online!=ON_REMOTE)
127: ex|=EX_OFFLINE;
1.1.1.2 ! root 128: i=external(cmdstr(cfg.fextr[k]->cmd,rep_fname,ALLFILES,NULL),ex);
1.1 root 129: if(i) {
130: bputs(text[QWKExtractionFailed]);
1.1.1.2 ! root 131: logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
! 132: logline(LOG_NOTICE,nulstr,"Extraction failed");
1.1 root 133: return(false);
134: }
1.1.1.2 ! root 135: SAFEPRINTF2(msg_fname,"%s%s.msg",cfg.temp_dir,cfg.sys_id);
! 136: if(!fexistcase(msg_fname)) {
1.1 root 137: bputs(text[QWKReplyNotReceived]);
1.1.1.2 ! root 138: logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
! 139: logline(LOG_NOTICE,nulstr,"MSG file not received");
1.1 root 140: return(false);
141: }
1.1.1.2 ! root 142: if((rep=fnopen(&file,msg_fname,O_RDONLY))==NULL) {
! 143: errormsg(WHERE,ERR_OPEN,msg_fname,O_RDONLY);
1.1 root 144: return(false);
145: }
1.1.1.2 ! root 146: size=(long)filelength(file);
! 147:
! 148: SAFEPRINTF(fname,"%sHEADERS.DAT",cfg.temp_dir);
! 149: if(fexistcase(fname)) {
! 150: FILE* fp;
! 151: set_qwk_flag(QWK_HEADERS);
! 152: if((fp=fopen(fname,"r")) == NULL)
! 153: errormsg(WHERE,ERR_OPEN,fname,0);
! 154: else {
! 155: headers=iniReadFile(fp);
! 156: fclose(fp);
! 157: }
! 158: remove(fname);
! 159: }
! 160:
1.1 root 161: fread(block,QWK_BLOCK_LEN,1,rep);
162: if(strnicmp((char *)block,cfg.sys_id,strlen(cfg.sys_id))) {
1.1.1.2 ! root 163: if(headers!=NULL)
! 164: iniFreeStringList(headers);
1.1 root 165: fclose(rep);
166: bputs(text[QWKReplyNotReceived]);
1.1.1.2 ! root 167: logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
! 168: logline(LOG_NOTICE,nulstr,"Incorrect QWK BBS ID");
1.1 root 169: return(false);
170: }
171: logline("U+","Uploaded REP packet");
172: /********************/
173: /* Process messages */
174: /********************/
175: bputs(text[QWKUnpacking]);
176:
1.1.1.2 ! root 177: ip_can=trashcan_list(&cfg,"ip");
! 178: host_can=trashcan_list(&cfg,"host");
! 179: subject_can=trashcan_list(&cfg,"subject");
! 180:
! 181: SAFEPRINTF(fname,"%stwitlist.cfg",cfg.ctrl_dir);
! 182: if((fp=fopen(fname,"r"))!=NULL) {
! 183: twit_list=strListReadFile(fp,NULL,128);
! 184: fclose(fp);
! 185: }
! 186:
! 187: now=time(NULL);
! 188: for(l=QWK_BLOCK_LEN;l<size;l+=blocks*QWK_BLOCK_LEN) {
1.1 root 189: if(terminated) {
190: bprintf("!Terminated");
191: break;
192: }
193:
194: lncntr=0; /* defeat pause */
195: if(fseek(rep,l,SEEK_SET)!=0) {
1.1.1.2 ! root 196: errormsg(WHERE,ERR_SEEK,msg_fname,l);
1.1 root 197: break;
198: }
199: if(fread(block,1,QWK_BLOCK_LEN,rep)!=QWK_BLOCK_LEN) {
1.1.1.2 ! root 200: errormsg(WHERE,ERR_READ,msg_fname,(long)ftell(rep));
1.1 root 201: break;
202: }
203: sprintf(tmp,"%.6s",block+116);
1.1.1.2 ! root 204: blocks=atoi(tmp); /* i = number of blocks */
! 205: if(blocks<2) {
! 206: SAFEPRINTF3(str,"%s blocks (read '%s' at offset %ld)", msg_fname, tmp, l);
! 207: errormsg(WHERE,ERR_CHK,str,blocks);
! 208: blocks=1;
1.1 root 209: continue;
210: }
1.1.1.2 ! root 211: qwk_new_msg(&msg, block, /* offset: */l, headers, /* parse_sender_hfields: */useron.rest&FLAG('Q') ? true:false);
! 212:
! 213: if(cfg.max_qwkmsgage && msg.hdr.when_written.time < (uint32_t)now
! 214: && (now-msg.hdr.when_written.time)/(24*60*60) > cfg.max_qwkmsgage) {
! 215: SAFEPRINTF2(str,"!Filtering QWK message from %s due to age: %u days"
! 216: ,msg.from
! 217: ,(now-msg.hdr.when_written.time)/(24*60*60));
! 218: logline(LOG_NOTICE,"P!",str);
! 219: continue;
! 220: }
! 221:
! 222: if(findstr_in_list(msg.from_ip,ip_can)) {
! 223: SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked IP: %s"
! 224: ,msg.from
! 225: ,msg.from_ip);
! 226: logline(LOG_NOTICE,"P!",str);
! 227: continue;
! 228: }
! 229:
! 230: hostname = getHostNameByAddr(msg.from_host);
! 231: if(findstr_in_list(hostname,host_can)) {
! 232: SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked hostname: %s"
! 233: ,msg.from
! 234: ,hostname);
! 235: logline(LOG_NOTICE,"P!",str);
! 236: continue;
! 237: }
! 238:
! 239: if(findstr_in_list(msg.subj,subject_can)) {
! 240: SAFEPRINTF2(str,"!Filtering QWK message from %s due to filtered subject: %s"
! 241: ,msg.from
! 242: ,msg.subj);
! 243: logline(LOG_NOTICE,"P!",str);
! 244: continue;
! 245: }
! 246:
1.1 root 247: if(atoi(block+1)==0) { /**********/
248: if(useron.rest&FLAG('E')) { /* E-mail */
249: bputs(text[R_Email]); /**********/
250: continue;
251: }
252:
1.1.1.2 ! root 253: if(msg.to!=NULL) {
! 254: if(stricmp(msg.to,"NETMAIL")==0) { /* QWK to FidoNet NetMail */
! 255: qwktonetmail(rep,block,NULL,0);
! 256: continue;
! 257: }
! 258: if(strchr(msg.to,'@')) {
! 259: qwktonetmail(rep,block,msg.to,0);
! 260: continue;
! 261: }
! 262: if(!stricmp(msg.to,"SBBS")) { /* to SBBS, config stuff */
! 263: qwkcfgline(msg.subj,INVALID_SUB);
! 264: continue;
! 265: }
1.1 root 266: }
267:
1.1.1.2 ! root 268: if(useron.etoday>=cfg.level_emailperday[useron.level] && !(useron.exempt&FLAG('M'))
1.1 root 269: && !(useron.rest&FLAG('Q'))) {
270: bputs(text[TooManyEmailsToday]);
271: continue;
272: }
1.1.1.2 ! root 273: usernum=0;
! 274: if(msg.to!=NULL) {
! 275: usernum=atoi(msg.to);
! 276: if(usernum>lastuser(&cfg))
! 277: usernum=0;
! 278: if(!usernum)
! 279: usernum=matchuser(&cfg,msg.to,TRUE /* sysop_alias */);
! 280: }
! 281: if(!usernum) {
1.1 root 282: bputs(text[UnknownUser]);
283: continue;
284: }
1.1.1.2 ! root 285: if(usernum==1 && useron.rest&FLAG('S')) {
1.1 root 286: bprintf(text[R_Feedback],cfg.sys_op);
287: continue;
288: }
289:
1.1.1.2 ! root 290: getuserrec(&cfg,usernum,U_MISC,8,str);
1.1 root 291: misc=ahtoul(str);
292: if(misc&NETMAIL && cfg.sys_misc&SM_FWDTONET) {
1.1.1.2 ! root 293: getuserrec(&cfg,usernum,U_NETMAIL,LEN_NETMAIL,str);
1.1 root 294: qwktonetmail(rep,block,str,0);
295: continue;
296: }
297:
1.1.1.2 ! root 298: SAFEPRINTF(smb.file,"%smail",cfg.data_dir);
1.1 root 299: smb.retry_time=cfg.smb_retry_time;
300:
301: if(lastsub!=INVALID_SUB) {
302: smb_close(&smb);
303: lastsub=INVALID_SUB;
304: }
305:
306: smb.subnum=INVALID_SUB;
307: if((k=smb_open(&smb))!=0) {
308: errormsg(WHERE,ERR_OPEN,smb.file,k,smb.last_error);
309: continue;
310: }
311:
312: if(!filelength(fileno(smb.shd_fp))) {
313: smb.status.max_crcs=cfg.mail_maxcrcs;
314: smb.status.max_msgs=0;
315: smb.status.max_age=cfg.mail_maxage;
316: smb.status.attr=SMB_EMAIL;
317: if((k=smb_create(&smb))!=0) {
318: smb_close(&smb);
1.1.1.2 ! root 319: errormsg(WHERE,ERR_CREATE,smb.file,k,smb.last_error);
1.1 root 320: continue;
321: }
322: }
323:
324: if((k=smb_locksmbhdr(&smb))!=0) {
325: smb_close(&smb);
1.1.1.2 ! root 326: errormsg(WHERE,ERR_LOCK,smb.file,k,smb.last_error);
1.1 root 327: continue;
328: }
329:
330: if((k=smb_getstatus(&smb))!=0) {
331: smb_close(&smb);
1.1.1.2 ! root 332: errormsg(WHERE,ERR_READ,smb.file,k,smb.last_error);
1.1 root 333: continue;
334: }
335:
336: smb_unlocksmbhdr(&smb);
337:
1.1.1.2 ! root 338: if(qwk_import_msg(rep, block, blocks
! 339: ,/* fromhub: */0,/* subnum: */INVALID_SUB,/* touser: */usernum,&msg)) {
1.1 root 340:
1.1.1.2 ! root 341: if(usernum==1) {
! 342: useron.fbacks++;
! 343: logon_fbacks++;
! 344: putuserrec(&cfg,useron.number,U_FBACKS,5
! 345: ,ultoa(useron.fbacks,tmp,10));
! 346: }
! 347: else {
! 348: useron.emails++;
! 349: logon_emails++;
! 350: putuserrec(&cfg,useron.number,U_EMAILS,5
! 351: ,ultoa(useron.emails,tmp,10));
! 352: }
! 353: useron.etoday++;
! 354: putuserrec(&cfg,useron.number,U_ETODAY,5
! 355: ,ultoa(useron.etoday,tmp,10));
! 356: bprintf(text[Emailed],username(&cfg,usernum,tmp),usernum);
! 357: SAFEPRINTF3(str,"%s sent QWK e-mail to %s #%d"
! 358: ,useron.alias,username(&cfg,usernum,tmp),usernum);
! 359: logline("E+",str);
! 360: if(cfg.node_num) {
! 361: for(k=1;k<=cfg.sys_nodes;k++) { /* Tell user, if online */
! 362: getnodedat(k,&node,0);
! 363: if(node.useron==usernum && !(node.misc&NODE_POFF)
! 364: && (node.status==NODE_INUSE
! 365: || node.status==NODE_QUIET)) {
! 366: SAFEPRINTF2(str,text[EmailNodeMsg]
! 367: ,cfg.node_num,msg.from);
! 368: putnmsg(&cfg,k,str);
! 369: break;
! 370: }
! 371: }
! 372: }
! 373: if(cfg.node_num==0 || k>cfg.sys_nodes) {
! 374: SAFEPRINTF(str,text[UserSentYouMail],msg.from);
! 375: putsmsg(&cfg,usernum,str);
1.1 root 376: }
377: }
1.1.1.2 ! root 378: smb_close(&smb);
1.1 root 379: } /* end of email */
380:
381: /**************************/
382: else { /* message on a sub-board */
383: /**************************/
1.1.1.2 ! root 384: n=resolve_qwkconf(atol((char *)block+1)); /* conference number */
1.1 root 385:
1.1.1.2 ! root 386: if(n==INVALID_SUB) {
! 387: bprintf(text[QWKInvalidConferenceN],n);
! 388: SAFEPRINTF2(str,"%s: Invalid QWK conference number %lu",useron.alias,n);
! 389: logline(LOG_NOTICE,"P!",str);
! 390: continue;
! 391: }
1.1 root 392:
393: /* if posting, add to new-scan config for QWKnet nodes automatically */
394: if(useron.rest&FLAG('Q'))
395: subscan[n].cfg|=SUB_CFG_NSCAN;
396:
1.1.1.2 ! root 397: if(msg.to!=NULL) {
! 398: if(stricmp(msg.to,"SBBS")==0) { /* to SBBS, config stuff */
! 399: qwkcfgline(msg.subj,n);
! 400: continue;
! 401: }
1.1 root 402: }
403:
1.1.1.2 ! root 404: #if 0 /* This stuff isn't really necessary anymore */
1.1 root 405: if(!SYSOP && cfg.sub[n]->misc&SUB_QNET) { /* QWK Netted */
406: sprintf(str,"%-25.25s","DROP"); /* Drop from new-scan? */
407: if(!strnicmp((char *)block+71,str,25)) /* don't allow post */
408: continue;
409: sprintf(str,"%-25.25s","ADD"); /* Add to new-scan? */
410: if(!strnicmp((char *)block+71,str,25)) /* don't allow post */
411: continue;
412: }
1.1.1.2 ! root 413: #endif
1.1 root 414:
415: if(useron.rest&FLAG('Q') && !(cfg.sub[n]->misc&SUB_QNET)) {
416: bputs(text[CantPostOnSub]);
1.1.1.2 ! root 417: logline(LOG_NOTICE,"P!","Attempted to post QWK message on non-QWKnet sub");
1.1 root 418: continue;
419: }
420:
421: if(useron.rest&FLAG('P')) {
422: bputs(text[R_Post]);
1.1.1.2 ! root 423: logline(LOG_NOTICE,"P!","QWK Post attempted");
1.1 root 424: continue;
425: }
426:
427: if(useron.ptoday>=cfg.level_postsperday[useron.level]
428: && !(useron.rest&FLAG('Q'))) {
429: bputs(text[TooManyPostsToday]);
430: continue;
431: }
432:
433: if(useron.rest&FLAG('N')
434: && cfg.sub[n]->misc&(SUB_FIDO|SUB_PNET|SUB_QNET|SUB_INET)) {
435: bputs(text[CantPostOnSub]);
1.1.1.2 ! root 436: logline(LOG_NOTICE,"P!","QWK Networked post attempted");
1.1 root 437: continue;
438: }
439:
1.1.1.2 ! root 440: if(!chk_ar(cfg.sub[n]->post_ar,&useron,&client)) {
1.1 root 441: bputs(text[CantPostOnSub]);
1.1.1.2 ! root 442: logline(LOG_NOTICE,"P!","QWK Post attempted");
1.1 root 443: continue;
444: }
445:
446: if((block[0]=='*' || block[0]=='+')
447: && !(cfg.sub[n]->misc&SUB_PRIV)) {
448: bputs(text[PrivatePostsNotAllowed]);
1.1.1.2 ! root 449: logline(LOG_NOTICE,"P!","QWK Private post attempt");
1.1 root 450: continue;
451: }
452:
453: if(block[0]=='*' || block[0]=='+' /* Private post */
454: || cfg.sub[n]->misc&SUB_PONLY) {
1.1.1.2 ! root 455: if(msg.to==NULL || !msg.to[0]
! 456: || stricmp(msg.to,"All")==0) { /* to blank */
! 457: bputs(text[NoToUser]); /* or all */
1.1 root 458: continue;
459: }
460: }
461:
1.1.1.2 ! root 462: #if 0 /* This stuff isn't really necessary anymore */
1.1 root 463: if(!SYSOP && !(useron.rest&FLAG('Q'))) {
464: sprintf(str,"%-25.25s","SYSOP");
465: if(!strnicmp((char *)block+21,str,25)) {
466: sprintf(str,"%-25.25s",username(&cfg,1,tmp));
467: memcpy((char *)block+21,str,25); /* change from sysop */
468: } /* to user name */
469: }
1.1.1.2 ! root 470: #endif
1.1 root 471:
472: /* TWIT FILTER */
1.1.1.2 ! root 473: if(findstr_in_list(msg.from,twit_list) || findstr_in_list(msg.to,twit_list)) {
! 474: SAFEPRINTF4(str,"!Filtering QWK post from %s to %s on %s %s"
! 475: ,msg.from
! 476: ,msg.to
! 477: ,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname);
! 478: logline(LOG_NOTICE,"P!",str);
! 479: continue;
1.1 root 480: }
481:
482: if(n!=lastsub) {
483: if(lastsub!=INVALID_SUB)
484: smb_close(&smb);
485: lastsub=INVALID_SUB;
1.1.1.2 ! root 486: SAFEPRINTF2(smb.file,"%s%s",cfg.sub[n]->data_dir,cfg.sub[n]->code);
1.1 root 487: smb.retry_time=cfg.smb_retry_time;
488: smb.subnum=n;
489: if((j=smb_open(&smb))!=0) {
490: errormsg(WHERE,ERR_OPEN,smb.file,j,smb.last_error);
491: continue;
492: }
493:
494: if(!filelength(fileno(smb.shd_fp))) {
495: smb.status.max_crcs=cfg.sub[n]->maxcrcs;
496: smb.status.max_msgs=cfg.sub[n]->maxmsgs;
497: smb.status.max_age=cfg.sub[n]->maxage;
498: smb.status.attr=cfg.sub[n]->misc&SUB_HYPER ? SMB_HYPERALLOC:0;
499: if((j=smb_create(&smb))!=0) {
500: smb_close(&smb);
501: lastsub=INVALID_SUB;
1.1.1.2 ! root 502: errormsg(WHERE,ERR_CREATE,smb.file,j,smb.last_error);
1.1 root 503: continue;
504: }
505: }
506:
507: if((j=smb_locksmbhdr(&smb))!=0) {
508: smb_close(&smb);
509: lastsub=INVALID_SUB;
1.1.1.2 ! root 510: errormsg(WHERE,ERR_LOCK,smb.file,j,smb.last_error);
1.1 root 511: continue;
512: }
513: if((j=smb_getstatus(&smb))!=0) {
514: smb_close(&smb);
515: lastsub=INVALID_SUB;
1.1.1.2 ! root 516: errormsg(WHERE,ERR_READ,smb.file,j,smb.last_error);
1.1 root 517: continue;
518: }
519: smb_unlocksmbhdr(&smb);
520: lastsub=n;
521: }
522:
1.1.1.2 ! root 523: if(qwk_import_msg(rep, block, blocks
! 524: ,/* fromhub: */0,/* subnum: */n,/* touser: */0,&msg)) {
! 525: logon_posts++;
! 526: user_posted_msg(&cfg, &useron, 1);
! 527: bprintf(text[Posted],cfg.grp[cfg.sub[n]->grp]->sname
! 528: ,cfg.sub[n]->lname);
! 529: SAFEPRINTF3(str,"%s posted QWK message on %s %s"
! 530: ,useron.alias,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname);
! 531: signal_sub_sem(&cfg,n);
! 532: logline("P+",str);
! 533: if(!(useron.rest&FLAG('Q')))
! 534: user_event(EVENT_POST);
! 535: }
1.1 root 536: } /* end of public message */
537: }
538:
539: update_qwkroute(NULL); /* Write ROUTE.DAT */
540:
1.1.1.2 ! root 541: iniFreeStringList(headers);
! 542:
! 543: strListFree(&ip_can);
! 544: strListFree(&host_can);
! 545: strListFree(&subject_can);
! 546: strListFree(&twit_list);
! 547:
1.1 root 548: if(lastsub!=INVALID_SUB)
549: smb_close(&smb);
550: fclose(rep);
551:
1.1.1.2 ! root 552: /* QWKE support */
! 553: SAFEPRINTF(fname,"%sTODOOR.EXT",cfg.temp_dir);
! 554: if(fexistcase(fname)) {
! 555: useron.qwk|=QWK_EXT;
! 556: FILE* fp=fopen(fname,"r");
! 557: char* p;
! 558: if(fp!=NULL) {
! 559: while(!feof(fp)) {
! 560: if(!fgets(str,sizeof(str)-1,fp))
! 561: break;
! 562: if(strnicmp(str,"AREA ",5)==0) {
! 563: p=str+5;
! 564: SKIP_WHITESPACE(p);
! 565: if((n=resolve_qwkconf(atoi(p))) != INVALID_SUB) {
! 566: FIND_WHITESPACE(p);
! 567: SKIP_WHITESPACE(p);
! 568: if(strchr(p,'D'))
! 569: subscan[n].cfg&=~SUB_CFG_NSCAN;
! 570: else if(strchr(p,'a') || strchr(p,'g'))
! 571: subscan[n].cfg|=SUB_CFG_NSCAN;
! 572: else if(strchr(p,'p'))
! 573: subscan[n].cfg|=SUB_CFG_NSCAN|SUB_CFG_YSCAN;
! 574: }
! 575: continue;
! 576: }
! 577: if(strnicmp(str,"RESET ",6)==0) {
! 578: p=str+6;
! 579: SKIP_WHITESPACE(p);
! 580: if((n=resolve_qwkconf(atoi(p))) != INVALID_SUB) {
! 581: FIND_WHITESPACE(p);
! 582: SKIP_WHITESPACE(p);
! 583: /* If the [#ofmessages] is blank then the pointer should be set back to the start of the message base */
! 584: if(*p==0)
! 585: subscan[n].ptr=0;
! 586: else {
! 587: /* otherwise it should be set back [#ofmessages] back from the end of the message base. */
! 588: uint32_t last=0;
! 589: getlastmsg(n,&last,/* time_t* */NULL);
! 590: l=last-atol(p);
! 591: if(l<0)
! 592: l=0;
! 593: subscan[n].ptr=l;
! 594: }
! 595: }
! 596: }
! 597: }
! 598: fclose(fp);
! 599: }
! 600: }
! 601:
1.1 root 602: if(useron.rest&FLAG('Q')) { /* QWK Net Node */
1.1.1.2 ! root 603: if(fexistcase(msg_fname))
! 604: remove(msg_fname);
! 605: if(fexistcase(rep_fname))
! 606: remove(rep_fname);
! 607: SAFEPRINTF(fname,"%sATTXREF.DAT",cfg.temp_dir);
! 608: if(fexistcase(fname))
! 609: remove(fname);
1.1 root 610:
611: dir=opendir(cfg.temp_dir);
612: while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Extra files */
613: // Move files
1.1.1.2 ! root 614: SAFEPRINTF2(str,"%s%s",cfg.temp_dir,dirent->d_name);
1.1 root 615: if(isdir(str))
616: continue;
617:
618: // Create directory if necessary
1.1.1.2 ! root 619: SAFEPRINTF2(inbox,"%sqnet/%s.in",cfg.data_dir,useron.alias);
1.1 root 620: MKDIR(inbox);
621:
1.1.1.2 ! root 622: SAFEPRINTF2(fname,"%s/%s",inbox,dirent->d_name);
1.1 root 623: mv(str,fname,1);
1.1.1.2 ! root 624: SAFEPRINTF2(str,text[ReceivedFileViaQWK],dirent->d_name,useron.alias);
1.1 root 625: putsmsg(&cfg,1,str);
626: }
627: if(dir!=NULL)
628: closedir(dir);
1.1.1.2 ! root 629: SAFEPRINTF(fname,"%sqnet-rep.now",cfg.data_dir);
! 630: ftouch(fname);
1.1 root 631: }
632:
633: bputs(text[QWKUnpacked]);
634: CRLF;
635: /**********************************************/
636: /* Hang-up now if that's what the user wanted */
637: /**********************************************/
638: autohangup();
639:
640: return(true);
641: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.