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