Annotation of sbbs/sbbs3/scansubs.cpp, revision 1.1.1.2

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.10 2004/05/30 06:47:53 deuce 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:  *                                                                                                                                                     *
                     11:  * Copyright 2000 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;
1.1.1.2 ! root       48:        ulong   subs_scanned=0;
1.1       root       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(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 */
1.1.1.2 ! root       62:                                if(ch=='S') {
1.1       root       63:                                        found=searchsub(usrsub[curgrp][cursub[curgrp]],str);
1.1.1.2 ! root       64:                                        subs_scanned++;
        !            65:                                } else if(ch=='G')
        !            66:                                        for(i=0;i<usrsubs[curgrp] && !msgabort();i++) {
1.1       root       67:                                                found=searchsub(usrsub[curgrp][i],str);
1.1.1.2 ! root       68:                                                subs_scanned++;
        !            69:                                        }
        !            70:                                sprintf(tmp,"%s searched %lu sub-boards for '%s'"
        !            71:                                        ,useron.alias,subs_scanned,str);
1.1       root       72:                                logline(nulstr,tmp);
                     73:                                if(!found)
                     74:                                        CRLF;
                     75:                                return; } }
                     76:                else if(mode&SCAN_TOYOU && i) {
                     77:                        if(ch=='S')
                     78:                                found=searchsub_toyou(usrsub[curgrp][cursub[curgrp]]);
                     79:                        else if(ch=='G')
                     80:                                for(i=0;i<usrsubs[curgrp] && !msgabort();i++)
                     81:                                        found=searchsub_toyou(usrsub[curgrp][i]);
                     82:                        if(!found)
                     83:                                CRLF;
                     84:                        return; } }
                     85: 
                     86:        if(ch=='S') {
1.1.1.2 ! root       87:                if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1       root       88:                        menu("msgscan"); }
                     89:                i=scanposts(usrsub[curgrp][cursub[curgrp]],mode,str);
1.1.1.2 ! root       90:                subs_scanned++;
1.1       root       91:                bputs(text[MessageScan]);
                     92:                if(i) bputs(text[MessageScanAborted]);
1.1.1.2 ! root       93:                else bprintf(text[MessageScanComplete],subs_scanned);
1.1       root       94:                return; }
                     95:        if(ch=='G') {
1.1.1.2 ! root       96:                if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1       root       97:                        menu("msgscan"); }
1.1.1.2 ! root       98:                for(i=0;i<usrsubs[curgrp] && !msgabort();i++) {
1.1       root       99:                        if(((mode&SCAN_NEW &&
1.1.1.2 ! root      100:                                (subscan[usrsub[curgrp][i]].cfg&SUB_CFG_NSCAN
1.1       root      101:                                        || cfg.sub[usrsub[curgrp][i]]->misc&SUB_FORCED))
1.1.1.2 ! root      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:                }
1.1       root      109:                bputs(text[MessageScan]);
1.1.1.2 ! root      110:                if(i==usrsubs[curgrp]) bprintf(text[MessageScanComplete],subs_scanned);
1.1       root      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;
1.1.1.2 ! root      125:        ulong   subs_scanned=0;
1.1       root      126: 
                    127:        if(/* action==NODE_MAIN && */ mode&(SCAN_FIND|SCAN_TOYOU)) {
1.1.1.2 ! root      128:                i=yesno(text[DisplaySubjectsOnlyQ]);
1.1       root      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++) {
1.1.1.2 ! root      135:                                        for(j=0;j<usrsubs[i] && !msgabort();j++) {
1.1       root      136:                                                found=searchsub(usrsub[i][j],str);
1.1.1.2 ! root      137:                                                subs_scanned++;
        !           138:                                        }
1.1       root      139:                                        if(j<usrsubs[i])
1.1.1.2 ! root      140:                                                break; 
        !           141:                                }
1.1       root      142:                                if(!found)
                    143:                                        CRLF;
1.1.1.2 ! root      144:                                sprintf(tmp,"%s searched %lu sub-boards for '%s'"
        !           145:                                        ,useron.alias,subs_scanned,str);
1.1       root      146:                                logline(nulstr,tmp);
                    147:                                return; } }
                    148:                else if(mode&SCAN_TOYOU && i) {
                    149:                        for(i=0;i<usrgrps;i++) {
1.1.1.2 ! root      150:                                for(j=0;j<usrsubs[i] && !msgabort();j++) 
1.1       root      151:                                        found=searchsub_toyou(usrsub[i][j]);
                    152:                                if(j<usrsubs[i])
1.1.1.2 ! root      153:                                        break; 
        !           154:                        }
1.1       root      155:                        if(!found)
                    156:                                CRLF;
1.1.1.2 ! root      157:                        return; 
        !           158:                } 
        !           159:        }
1.1       root      160: 
1.1.1.2 ! root      161:        if(useron.misc&(RIP|WIP|HTML) && !(useron.misc&EXPERT)) {
1.1       root      162:                menu("msgscan"); }
                    163:        for(i=0;i<usrgrps;i++) {
1.1.1.2 ! root      164:                for(j=0;j<usrsubs[i] && !msgabort();j++) {
        !           165:                        if(((mode&SCAN_NEW && subscan[usrsub[i][j]].cfg&SUB_CFG_NSCAN)
1.1       root      166:                                || cfg.sub[usrsub[i][j]]->misc&SUB_FORCED
                    167:                                || mode&SCAN_FIND
1.1.1.2 ! root      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:                }
1.1       root      174:                if(j<usrsubs[i])
1.1.1.2 ! root      175:                        break; 
        !           176:        }
1.1       root      177:        bputs(text[MessageScan]);
                    178:        if(i<usrgrps) {
                    179:                bputs(text[MessageScanAborted]);
1.1.1.2 ! root      180:                return; 
        !           181:        }
        !           182:        bprintf(text[MessageScanComplete],subs_scanned);
1.1       root      183:        if(mode&SCAN_NEW && !(mode&(SCAN_BACK|SCAN_TOYOU))
                    184:                && useron.misc&ANFSCAN && !(useron.rest&FLAG('T'))) {
                    185:                xfer_cmds++;
1.1.1.2 ! root      186:                scanalldirs(FL_ULTIME); 
        !           187:        }
1.1       root      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();
1.1.1.2 ! root      201:                        if(i<9) outchar(' ');
        !           202:                        if(i<99) outchar(' ');
1.1       root      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();
1.1.1.2 ! root      222:                                                        subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); } }
1.1       root      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)
1.1.1.2 ! root      234:                                                subscan[usrsub[i][j]].ptr=0;
1.1       root      235:                                        else
1.1.1.2 ! root      236:                                                subscan[usrsub[i][j]].ptr=l-s; }
1.1       root      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();
1.1.1.2 ! root      244:                                if(j<9) outchar(' ');
        !           245:                                if(j<99) outchar(' ');
        !           246:                                t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr);
1.1       root      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();
1.1.1.2 ! root      271:                                                        subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); } }
1.1       root      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)
1.1.1.2 ! root      282:                                                subscan[usrsub[i][j]].ptr=0;
1.1       root      283:                                        else
1.1.1.2 ! root      284:                                                subscan[usrsub[i][j]].ptr=l-s; }
1.1       root      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') {
1.1.1.2 ! root      294:                                        t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr);
1.1       root      295:                                        if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
                    296:                                                bputs(text[LoadingMsgPtrs]);
1.1.1.2 ! root      297:                                                subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); }
1.1       root      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)
1.1.1.2 ! root      305:                                        subscan[usrsub[i][j]].ptr=0;
1.1       root      306:                                else
1.1.1.2 ! root      307:                                        subscan[usrsub[i][j]].ptr=l-s; }
1.1       root      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();
1.1.1.2 ! root      321:                        if(i<9) outchar(' ');
        !           322:                        if(i<99) outchar(' ');
1.1       root      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();
1.1.1.2 ! root      339:                                if(j<9) outchar(' ');
        !           340:                                if(j<99) outchar(' ');
1.1       root      341:                                bprintf(text[CfgSubLstFmt],j+1
                    342:                                        ,cfg.sub[usrsub[i][j]]->lname
1.1.1.2 ! root      343:                                        ,subscan[usrsub[i][j]].cfg&misc ?
        !           344:                                                (misc&SUB_CFG_NSCAN && subscan[usrsub[i][j]].cfg&SUB_CFG_YSCAN) ?
1.1       root      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') {
1.1.1.2 ! root      359:                                t=subscan[usrsub[i][0]].cfg&misc;
1.1       root      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();
1.1.1.2 ! root      365:                                        if(t) subscan[usrsub[i][j]].cfg&=~misc;
1.1       root      366:                                        else  {
                    367:                                                if(misc&SUB_CFG_NSCAN)
1.1.1.2 ! root      368:                                                        subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN;
        !           369:                                                subscan[usrsub[i][j]].cfg|=misc; } }
1.1       root      370:                                continue; }
                    371:                        j=(s&~0x80000000L)-1;
1.1.1.2 ! root      372:                        if(misc&SUB_CFG_NSCAN && !(subscan[usrsub[i][j]].cfg&misc)) {
1.1       root      373:                                if(!(useron.misc&FLAG('Q')) && !noyes("Messages to you only"))
1.1.1.2 ! root      374:                                        subscan[usrsub[i][j]].cfg|=SUB_CFG_YSCAN;
1.1       root      375:                                else
1.1.1.2 ! root      376:                                        subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN; }
        !           377:                        subscan[usrsub[i][j]].cfg^=misc; } }
1.1       root      378: }
                    379: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.