|
|
1.1 root 1: /* scansubs.cpp */
2:
3: /* Synchronet message database scanning routines */
4:
1.1.1.2 ! root 5: /* $Id: scansubs.cpp,v 1.16 2011/07/21 11:19:22 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:
40: /****************************************************************************/
41: /* Used to scan single or multiple sub-boards. 'mode' is the scan type. */
42: /****************************************************************************/
43: void sbbs_t::scansubs(long mode)
44: {
45: char ch,str[256];
46: char tmp[512];
47: uint i=0,found=0;
48: ulong subs_scanned=0;
49:
50: mnemonics(text[SubGroupOrAll]);
51: ch=(char)getkeys("SGA\r",0);
52: if(sys_status&SS_ABORT || ch==CR)
53: return;
54:
55: if(ch!='A' && mode&(SCAN_FIND|SCAN_TOYOU)) {
1.1.1.2 ! root 56: if(text[DisplaySubjectsOnlyQ][0] && yesno(text[DisplaySubjectsOnlyQ])) i=1;
1.1 root 57: if(mode&SCAN_FIND) {
58: bputs(text[SearchStringPrompt]);
59: if(!getstr(str,40,K_LINE|K_UPPER))
60: return;
61: if(i) { /* if titles only */
62: if(ch=='S') {
63: found=listsub(usrsub[curgrp][cursub[curgrp]],SCAN_FIND,0,str);
64: subs_scanned++;
65: } else if(ch=='G')
66: for(i=0;i<usrsubs[curgrp] && !msgabort();i++) {
67: found=listsub(usrsub[curgrp][i],SCAN_FIND,0,str);
68: subs_scanned++;
69: }
70: sprintf(tmp,"%s searched %lu sub-boards for '%s'"
71: ,useron.alias,subs_scanned,str);
72: logline(nulstr,tmp);
73: if(!found)
74: CRLF;
1.1.1.2 ! root 75: return;
! 76: }
! 77: }
1.1 root 78: else if(mode&SCAN_TOYOU && i) {
79: if(ch=='S')
80: found=listsub(usrsub[curgrp][cursub[curgrp]],SCAN_TOYOU,0,NULL);
81: else if(ch=='G')
82: for(i=0;i<usrsubs[curgrp] && !msgabort();i++)
83: found=listsub(usrsub[curgrp][i],SCAN_TOYOU,0,NULL);
84: if(!found)
85: CRLF;
1.1.1.2 ! root 86: return;
! 87: }
! 88: }
1.1 root 89:
90: if(ch=='S') {
91: if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1.1.2 ! root 92: menu("msgscan");
! 93: }
1.1 root 94: i=scanposts(usrsub[curgrp][cursub[curgrp]],mode,str);
95: subs_scanned++;
96: bputs(text[MessageScan]);
97: if(i) bputs(text[MessageScanAborted]);
98: else bprintf(text[MessageScanComplete],subs_scanned);
1.1.1.2 ! root 99: return;
! 100: }
1.1 root 101: if(ch=='G') {
102: if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1.1.2 ! root 103: menu("msgscan");
! 104: }
1.1 root 105: for(i=0;i<usrsubs[curgrp] && !msgabort();i++) {
106: if(((mode&SCAN_NEW &&
107: (subscan[usrsub[curgrp][i]].cfg&SUB_CFG_NSCAN
108: || cfg.sub[usrsub[curgrp][i]]->misc&SUB_FORCED))
109: || (mode&SCAN_TOYOU && subscan[usrsub[curgrp][i]].cfg&SUB_CFG_SSCAN)
110: || mode&SCAN_FIND)) {
111: if(scanposts(usrsub[curgrp][i],mode,str))
112: break;
113: subs_scanned++;
114: }
115: }
116: bputs(text[MessageScan]);
117: if(i==usrsubs[curgrp]) bprintf(text[MessageScanComplete],subs_scanned);
118: else bputs(text[MessageScanAborted]);
1.1.1.2 ! root 119: return;
! 120: }
1.1 root 121:
122: scanallsubs(mode);
123: }
124:
125: /****************************************************************************/
126: /* Performs a new message scan all all sub-boards */
127: /****************************************************************************/
128: void sbbs_t::scanallsubs(long mode)
129: {
130: char str[256];
131: char tmp[512];
132: uint i,j,found=0;
133: ulong subs_scanned=0;
134:
135: if(/* action==NODE_MAIN && */ mode&(SCAN_FIND|SCAN_TOYOU)) {
1.1.1.2 ! root 136: if(text[DisplaySubjectsOnlyQ][0])
! 137: i=yesno(text[DisplaySubjectsOnlyQ]);
! 138: else
! 139: i=0;
1.1 root 140: if(mode&SCAN_FIND) {
141: bputs(text[SearchStringPrompt]);
142: if(!getstr(str,40,K_LINE|K_UPPER))
143: return;
144: if(i) { /* if titles only */
145: for(i=0;i<usrgrps;i++) {
146: for(j=0;j<usrsubs[i] && !msgabort();j++) {
147: found=listsub(usrsub[i][j],SCAN_FIND,0,str);
148: subs_scanned++;
149: }
150: if(j<usrsubs[i])
151: break;
152: }
153: if(!found)
154: CRLF;
155: sprintf(tmp,"%s searched %lu sub-boards for '%s'"
156: ,useron.alias,subs_scanned,str);
157: logline(nulstr,tmp);
1.1.1.2 ! root 158: return;
! 159: }
! 160: }
1.1 root 161: else if(mode&SCAN_TOYOU && i) {
162: for(i=0;i<usrgrps;i++) {
163: for(j=0;j<usrsubs[i] && !msgabort();j++)
164: found=listsub(usrsub[i][j],SCAN_TOYOU,0,NULL);
165: if(j<usrsubs[i])
166: break;
167: }
168: if(!found)
169: CRLF;
170: return;
171: }
172: }
173:
174: if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1.1.2 ! root 175: menu("msgscan");
! 176: }
1.1 root 177: for(i=0;i<usrgrps;i++) {
178: for(j=0;j<usrsubs[i] && !msgabort();j++) {
179: if(((mode&SCAN_NEW && subscan[usrsub[i][j]].cfg&SUB_CFG_NSCAN)
180: || cfg.sub[usrsub[i][j]]->misc&SUB_FORCED
181: || mode&SCAN_FIND
182: || (mode&SCAN_TOYOU && subscan[usrsub[i][j]].cfg&SUB_CFG_SSCAN))) {
183: if(scanposts(usrsub[i][j],mode,str))
184: break;
185: subs_scanned++;
186: }
187: }
188: if(j<usrsubs[i])
189: break;
190: }
191: bputs(text[MessageScan]);
192: if(i<usrgrps) {
193: bputs(text[MessageScanAborted]);
194: return;
195: }
196: bprintf(text[MessageScanComplete],subs_scanned);
197: if(mode&SCAN_NEW && !(mode&(SCAN_BACK|SCAN_TOYOU))
198: && useron.misc&ANFSCAN && !(useron.rest&FLAG('T'))) {
199: xfer_cmds++;
200: scanalldirs(FL_ULTIME);
201: }
202: }
203:
204: void sbbs_t::new_scan_ptr_cfg()
205: {
206: uint i,j;
207: long s;
1.1.1.2 ! root 208: uint32_t l;
1.1 root 209: time_t t;
210:
211: while(online) {
212: bputs(text[CfgGrpLstHdr]);
213: for(i=0;i<usrgrps && !msgabort();i++) {
214: checkline();
215: if(i<9) outchar(' ');
216: if(i<99) outchar(' ');
1.1.1.2 ! root 217: bprintf(text[CfgGrpLstFmt],i+1,cfg.grp[usrgrp[i]]->lname);
! 218: }
1.1 root 219: SYNC;
220: mnemonics(text[WhichOrAll]);
221: s=getkeys("AQ",usrgrps);
222: if(!s || s==-1 || s=='Q')
223: break;
224: if(s=='A') {
225: mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or"
226: " [Last Message]: ");
227: s=getkeys("DLQ",9999);
228: if(s==-1 || s=='Q')
229: continue;
230: if(s=='D') {
231: t=time(NULL);
232: if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
233: bputs(text[LoadingMsgPtrs]);
234: for(i=0;i<usrgrps && online;i++)
235: for(j=0;j<usrsubs[i] && online;j++) {
236: checkline();
1.1.1.2 ! root 237: subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
! 238: }
! 239: }
! 240: continue;
! 241: }
1.1 root 242: if(s=='L')
243: s=0;
244: if(s)
245: s&=~0x80000000L;
246: bputs(text[LoadingMsgPtrs]);
247: for(i=0;i<usrgrps;i++)
248: for(j=0;j<usrsubs[i] && online;j++) {
249: checkline();
250: getlastmsg(usrsub[i][j],&l,0);
251: if(s>(long)l)
252: subscan[usrsub[i][j]].ptr=0;
253: else
1.1.1.2 ! root 254: subscan[usrsub[i][j]].ptr=l-s;
! 255: }
! 256: continue;
! 257: }
1.1 root 258: i=(s&~0x80000000L)-1;
259: while(online) {
260: l=0;
261: bprintf(text[CfgSubLstHdr],cfg.grp[usrgrp[i]]->lname);
262: for(j=0;j<usrsubs[i] && !msgabort();j++) {
263: checkline();
264: if(j<9) outchar(' ');
265: if(j<99) outchar(' ');
266: t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr);
267: if(t>(long)l)
268: l=t;
269: bprintf(text[SubPtrLstFmt],j+1,cfg.sub[usrsub[i][j]]->lname
1.1.1.2 ! root 270: ,timestr(t),nulstr);
! 271: }
1.1 root 272: SYNC;
273: mnemonics(text[WhichOrAll]);
274: s=getkeys("AQ",usrsubs[i]);
275: if(sys_status&SS_ABORT) {
276: lncntr=0;
1.1.1.2 ! root 277: return;
! 278: }
1.1 root 279: if(s==-1 || !s || s=='Q')
280: break;
281: if(s=='A') { /* The entire group */
282: mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or"
283: " [Last Message]: ");
284: s=getkeys("DLQ",9999);
285: if(s==-1 || s=='Q')
286: continue;
287: if(s=='D') {
288: t=l;
289: if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
290: bputs(text[LoadingMsgPtrs]);
291: for(j=0;j<usrsubs[i] && online;j++) {
292: checkline();
1.1.1.2 ! root 293: subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
! 294: }
! 295: }
! 296: continue;
! 297: }
1.1 root 298: if(s=='L')
299: s=0;
300: if(s)
301: s&=~0x80000000L;
302: bputs(text[LoadingMsgPtrs]);
303: for(j=0;j<usrsubs[i] && online;j++) {
304: checkline();
305: getlastmsg(usrsub[i][j],&l,0);
306: if(s>(long)l)
307: subscan[usrsub[i][j]].ptr=0;
308: else
1.1.1.2 ! root 309: subscan[usrsub[i][j]].ptr=l-s;
! 310: }
! 311: continue;
! 312: }
1.1 root 313: else {
314: j=(s&~0x80000000L)-1;
315: mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or"
316: " [Last Message]: ");
317: s=getkeys("DLQ",9999);
318: if(s==-1 || s=='Q')
319: continue;
320: if(s=='D') {
321: t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr);
322: if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
323: bputs(text[LoadingMsgPtrs]);
1.1.1.2 ! root 324: subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
! 325: }
! 326: continue;
! 327: }
1.1 root 328: if(s=='L')
329: s=0;
330: if(s)
331: s&=~0x80000000L;
332: getlastmsg(usrsub[i][j],&l,0);
333: if(s>(long)l)
334: subscan[usrsub[i][j]].ptr=0;
335: else
1.1.1.2 ! root 336: subscan[usrsub[i][j]].ptr=l-s;
! 337: }
! 338: }
! 339: }
1.1 root 340: }
341:
342: void sbbs_t::new_scan_cfg(ulong misc)
343: {
344: long s;
345: ulong i,j;
346: ulong t;
347:
348: while(online) {
349: bputs(text[CfgGrpLstHdr]);
350: for(i=0;i<usrgrps && !msgabort();i++) {
351: checkline();
352: if(i<9) outchar(' ');
353: if(i<99) outchar(' ');
1.1.1.2 ! root 354: bprintf(text[CfgGrpLstFmt],i+1,cfg.grp[usrgrp[i]]->lname);
! 355: }
1.1 root 356: SYNC;
357: if(misc&SUB_CFG_NSCAN)
358: mnemonics(text[NScanCfgWhichGrp]);
359: else
360: mnemonics(text[SScanCfgWhichGrp]);
361: s=getnum(i);
362: if(s<1)
363: break;
364: i=s-1;
365: while(online) {
366: if(misc&SUB_CFG_NSCAN)
367: misc&=~SUB_CFG_YSCAN;
368: bprintf(text[CfgSubLstHdr],cfg.grp[usrgrp[i]]->lname);
369: for(j=0;j<usrsubs[i] && !msgabort();j++) {
370: checkline();
371: if(j<9) outchar(' ');
372: if(j<99) outchar(' ');
373: bprintf(text[CfgSubLstFmt],j+1
374: ,cfg.sub[usrsub[i][j]]->lname
375: ,subscan[usrsub[i][j]].cfg&misc ?
376: (misc&SUB_CFG_NSCAN && subscan[usrsub[i][j]].cfg&SUB_CFG_YSCAN) ?
377: "To You Only" : text[On] : text[Off]);
378: }
379: SYNC;
380: if(misc&SUB_CFG_NSCAN)
381: mnemonics(text[NScanCfgWhichSub]);
382: else
383: mnemonics(text[SScanCfgWhichSub]);
384: s=getkeys("AQ",usrsubs[i]);
385: if(sys_status&SS_ABORT) {
386: lncntr=0;
1.1.1.2 ! root 387: return;
! 388: }
1.1 root 389: if(!s || s==-1 || s=='Q')
390: break;
391: if(s=='A') {
392: t=subscan[usrsub[i][0]].cfg&misc;
393: if(misc&SUB_CFG_NSCAN && !t && !(useron.misc&FLAG('Q')))
394: if(!noyes("Messages to you only"))
395: misc|=SUB_CFG_YSCAN;
396: for(j=0;j<usrsubs[i] && online;j++) {
397: checkline();
398: if(t) subscan[usrsub[i][j]].cfg&=~misc;
399: else {
400: if(misc&SUB_CFG_NSCAN)
401: subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN;
1.1.1.2 ! root 402: subscan[usrsub[i][j]].cfg|=misc;
! 403: }
! 404: }
! 405: continue;
! 406: }
1.1 root 407: j=(s&~0x80000000L)-1;
408: if(misc&SUB_CFG_NSCAN && !(subscan[usrsub[i][j]].cfg&misc)) {
409: if(!(useron.rest&FLAG('Q')) && !noyes("Messages to you only"))
410: subscan[usrsub[i][j]].cfg|=SUB_CFG_YSCAN;
411: else
1.1.1.2 ! root 412: subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN;
! 413: }
! 414: subscan[usrsub[i][j]].cfg^=misc;
! 415: }
! 416: }
1.1 root 417: }
418:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.