Annotation of sbbs/src/sbbs3/scandirs.cpp, revision 1.1

1.1     ! root        1: /* scandirs.cpp */
        !             2: 
        !             3: /* Synchronet file database scanning routines */
        !             4: 
        !             5: /* $Id: scandirs.cpp,v 1.2 2000/12/11 23:21:12 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 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 directories. 'mode' is the scan type.    */
        !            42: /****************************************************************************/
        !            43: void sbbs_t::scandirs(long mode)
        !            44: {
        !            45:        char    ch,str[256];
        !            46:        char    tmp[512];
        !            47:        int             s;
        !            48:        uint    i,k;
        !            49: 
        !            50:        if(!usrlibs) return;
        !            51:        mnemonics(text[DirLibOrAll]);
        !            52:        ch=(char)getkeys("DLA\r",0);
        !            53:        if(sys_status&SS_ABORT || ch==CR) {
        !            54:                lncntr=0;
        !            55:                return; }
        !            56:        if(ch!='A') {
        !            57:                if(mode&FL_ULTIME) {                    /* New file scan */
        !            58:                        bprintf(text[NScanHdr],timestr(&ns_time));
        !            59:                        str[0]=0; }
        !            60:                else if(mode==FL_NO_HDR) {              /* Search for a string */
        !            61:                        if(!getfilespec(tmp))
        !            62:                                return;
        !            63:                        padfname(tmp,str); }
        !            64:                else if(mode==FL_FINDDESC) {    /* Find text in description */
        !            65:                        if(!noyes(text[SearchExtendedQ]))
        !            66:                                mode=FL_EXFIND;
        !            67:                        if(sys_status&SS_ABORT) {
        !            68:                                lncntr=0;
        !            69:                                return; }
        !            70:                        bputs(text[SearchStringPrompt]);
        !            71:                        if(!getstr(str,40,K_LINE|K_UPPER)) {
        !            72:                                lncntr=0;
        !            73:                                return; } } }
        !            74:        if(ch=='D') {
        !            75:                if((s=listfiles(usrdir[curlib][curdir[curlib]],str,0,mode))==-1)
        !            76:                        return;
        !            77:                bputs("\r\1>");
        !            78:                if(s>1)
        !            79:                        bprintf(text[NFilesListed],s);
        !            80:                else if(!s && !(mode&FL_ULTIME))
        !            81:                        bputs(text[FileNotFound]);
        !            82:                return; }
        !            83:        if(ch=='L') {
        !            84:                k=0;
        !            85:                for(i=0;i<usrdirs[curlib] && !msgabort();i++) {
        !            86:                        attr(LIGHTGRAY);
        !            87:                        outchar('.');
        !            88:                        if(i && !(i%5))
        !            89:                                bputs("\b\b\b\b\b     \b\b\b\b\b");
        !            90:                        if(mode&FL_ULTIME       /* New-scan */
        !            91:                                && (cfg.lib[usrlib[curlib]]->offline_dir==usrdir[curlib][i]
        !            92:                                || cfg.dir[usrdir[curlib][i]]->misc&DIR_NOSCAN))
        !            93:                                continue;
        !            94:                        else if((s=listfiles(usrdir[curlib][i],str,0,mode))==-1)
        !            95:                                return;
        !            96:                        else k+=s; }
        !            97:                bputs("\r\1>");
        !            98:                if(k>1)
        !            99:                        bprintf(text[NFilesListed],k);
        !           100:                else if(!k && !(mode&FL_ULTIME))
        !           101:                        bputs(text[FileNotFound]);
        !           102:                return; }
        !           103: 
        !           104:        scanalldirs(mode);
        !           105: }
        !           106: 
        !           107: /****************************************************************************/
        !           108: /* Scan all directories in all libraries for files                                                     */
        !           109: /****************************************************************************/
        !           110: void sbbs_t::scanalldirs(long mode)
        !           111: {
        !           112:        char    str[256];
        !           113:        char    tmp[512];
        !           114:        int             s;
        !           115:        uint    i,j,k,d;
        !           116: 
        !           117:        if(!usrlibs) return;
        !           118:        k=0;
        !           119:        if(mode&FL_ULTIME) {                    /* New file scan */
        !           120:                bprintf(text[NScanHdr],timestr(&ns_time));
        !           121:                str[0]=0; }
        !           122:        else if(mode==FL_NO_HDR) {              /* Search for a string */
        !           123:                if(!getfilespec(tmp))
        !           124:                        return;
        !           125:                padfname(tmp,str); }
        !           126:        else if(mode==FL_FINDDESC) {    /* Find text in description */
        !           127:                if(!noyes(text[SearchExtendedQ]))
        !           128:                        mode=FL_EXFIND;
        !           129:                if(sys_status&SS_ABORT) {
        !           130:                        lncntr=0;
        !           131:                        return; }
        !           132:                bputs(text[SearchStringPrompt]);
        !           133:                if(!getstr(str,40,K_LINE|K_UPPER)) {
        !           134:                        lncntr=0;
        !           135:                        return; } }
        !           136:        for(i=d=0;i<usrlibs;i++) {
        !           137:                for(j=0;j<usrdirs[i] && !msgabort();j++,d++) {
        !           138:                        attr(LIGHTGRAY);
        !           139:                        outchar('.');
        !           140:                        if(d && !(d%5))
        !           141:                                bputs("\b\b\b\b\b     \b\b\b\b\b");
        !           142:                        if(mode&FL_ULTIME /* New-scan */
        !           143:                                && (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
        !           144:                                || cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
        !           145:                                continue;
        !           146:                        else if((s=listfiles(usrdir[i][j],str,0,mode))==-1)
        !           147:                                return;
        !           148:                        else k+=s; }
        !           149:                if(j<usrdirs[i])   /* aborted */
        !           150:                        break; }
        !           151:        bputs("\r\1>");
        !           152:        if(k>1)
        !           153:                bprintf(text[NFilesListed],k);
        !           154:        else if(!k && !(mode&FL_ULTIME))
        !           155:                bputs(text[FileNotFound]);
        !           156: }
        !           157: 

unix.superglobalmegacorp.com

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