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

1.1     ! root        1: /* data_ovl.cpp */
        !             2: 
        !             3: /* Synchronet hi-level data access routines */
        !             4: 
        !             5: /* $Id: data_ovl.cpp,v 1.11 2004/12/17 07:08:53 deuce 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: /* Fills the 'ptr' element of the each element of the cfg.sub[] array of sub_t  */
        !            42: /* and the sub_cfg and sub_ptr global variables                            */
        !            43: /* Called from function main                                                */
        !            44: /****************************************************************************/
        !            45: void sbbs_t::getmsgptrs()
        !            46: {
        !            47:        if(!useron.number)
        !            48:                return;
        !            49:        bputs(text[LoadingMsgPtrs]);
        !            50:        ::getmsgptrs(&cfg,useron.number,subscan);
        !            51:        bputs(text[LoadedMsgPtrs]);
        !            52: }
        !            53: 
        !            54: extern "C" BOOL DLLCALL getmsgptrs(scfg_t* cfg, uint usernumber, subscan_t* subscan)
        !            55: {
        !            56:        char    str[256];
        !            57:        uint    i;
        !            58:        int     file;
        !            59:        long    length;
        !            60:        FILE    *stream;
        !            61: 
        !            62:        /* Initialize to configured defaults */
        !            63:        for(i=0;i<cfg->total_subs;i++) {
        !            64:                subscan[i].ptr=subscan[i].sav_ptr=0;
        !            65:                subscan[i].last=subscan[i].sav_last=0;
        !            66:                subscan[i].cfg=0xff;
        !            67:                if(!(cfg->sub[i]->misc&SUB_NSDEF))
        !            68:                        subscan[i].cfg&=~SUB_CFG_NSCAN;
        !            69:                if(!(cfg->sub[i]->misc&SUB_SSDEF))
        !            70:                        subscan[i].cfg&=~SUB_CFG_SSCAN;
        !            71:                subscan[i].sav_cfg=subscan[i].cfg; 
        !            72:        }
        !            73: 
        !            74:        if(!usernumber)
        !            75:                return(FALSE);
        !            76: 
        !            77:        sprintf(str,"%suser/ptrs/%4.4u.ixb", cfg->data_dir,usernumber);
        !            78:        if((stream=fnopen(&file,str,O_RDONLY))==NULL)
        !            79:                return(TRUE); 
        !            80: 
        !            81:        length=filelength(file);
        !            82:        for(i=0;i<cfg->total_subs;i++) {
        !            83:                if(length>=(cfg->sub[i]->ptridx+1)*10L) {
        !            84:                        fseek(stream,(long)cfg->sub[i]->ptridx*10L,SEEK_SET);
        !            85:                        fread(&subscan[i].ptr,sizeof(subscan[i].ptr),1,stream);
        !            86:                        fread(&subscan[i].last,sizeof(subscan[i].last),1,stream);
        !            87:                        fread(&subscan[i].cfg,sizeof(subscan[i].cfg),1,stream);
        !            88:                }
        !            89:                subscan[i].sav_ptr=subscan[i].ptr;
        !            90:                subscan[i].sav_last=subscan[i].last;
        !            91:                subscan[i].sav_cfg=subscan[i].cfg; 
        !            92:        }
        !            93:        fclose(stream);
        !            94:        return(TRUE);
        !            95: }
        !            96: 
        !            97: void sbbs_t::putmsgptrs()
        !            98: {
        !            99:        ::putmsgptrs(&cfg,useron.number,subscan);
        !           100: }
        !           101: 
        !           102: /****************************************************************************/
        !           103: /* Writes to DATA\USER\PTRS\xxxx.DAB the msgptr array for the current user     */
        !           104: /* Called from functions main and newuser                                   */
        !           105: /****************************************************************************/
        !           106: extern "C" BOOL DLLCALL putmsgptrs(scfg_t* cfg, uint usernumber, subscan_t* subscan)
        !           107: {
        !           108:        char    str[256];
        !           109:        ushort  idx,scancfg;
        !           110:        uint    i,j;
        !           111:        int     file;
        !           112:        ulong   l=0L,length;
        !           113: 
        !           114:        if(!usernumber)
        !           115:                return(FALSE);
        !           116:        sprintf(str,"%suser/ptrs/%4.4u.ixb", cfg->data_dir,usernumber);
        !           117:        if((file=nopen(str,O_WRONLY|O_CREAT))==-1) {
        !           118:                return(FALSE); 
        !           119:        }
        !           120:        length=filelength(file);
        !           121:        for(i=0;i<cfg->total_subs;i++) {
        !           122:                if(subscan[i].sav_ptr==subscan[i].ptr 
        !           123:                        && subscan[i].sav_last==subscan[i].last
        !           124:                        && length>=((cfg->sub[i]->ptridx+1)*10UL)
        !           125:                        && subscan[i].sav_cfg==subscan[i].cfg)
        !           126:                        continue;
        !           127:                while(filelength(file)<(long)(cfg->sub[i]->ptridx)*10) {
        !           128:                        lseek(file,0L,SEEK_END);
        !           129:                        idx=(ushort)(tell(file)/10);
        !           130:                        for(j=0;j<cfg->total_subs;j++)
        !           131:                                if(cfg->sub[j]->ptridx==idx)
        !           132:                                        break;
        !           133:                        write(file,&l,sizeof(l));
        !           134:                        write(file,&l,sizeof(l));
        !           135:                        scancfg=0xff;                                   
        !           136:                        if(j<cfg->total_subs) {
        !           137:                                if(!(cfg->sub[j]->misc&SUB_NSDEF))
        !           138:                                        scancfg&=~SUB_CFG_NSCAN;
        !           139:                                if(!(cfg->sub[j]->misc&SUB_SSDEF))
        !           140:                                        scancfg&=~SUB_CFG_SSCAN; 
        !           141:                        } else  /* default to scan OFF for unknown sub */
        !           142:                                scancfg&=~(SUB_CFG_NSCAN|SUB_CFG_SSCAN);
        !           143:                        write(file,&scancfg,sizeof(scancfg)); 
        !           144:                }
        !           145:                lseek(file,(long)((long)(cfg->sub[i]->ptridx)*10),SEEK_SET);
        !           146:                write(file,&(subscan[i].ptr),sizeof(subscan[i].ptr));
        !           147:                write(file,&(subscan[i].last),sizeof(subscan[i].last));
        !           148:                write(file,&(subscan[i].cfg),sizeof(subscan[i].cfg));
        !           149:        }
        !           150:        close(file);
        !           151:        if(!flength(str))                               /* Don't leave 0 byte files */
        !           152:                remove(str);
        !           153: 
        !           154:        return(TRUE);
        !           155: }
        !           156: 
        !           157: /****************************************************************************/
        !           158: /* Checks for a duplicate user field starting at user record offset         */
        !           159: /* 'offset', reading in 'datlen' chars, comparing to 'str' for each user    */
        !           160: /* except 'usernumber' if it is non-zero. Comparison is NOT case sensitive. */
        !           161: /* 'del' is true if the search is to include deleted/inactive users                    */
        !           162: /* Returns the usernumber of the dupe if found, 0 if not                    */
        !           163: /****************************************************************************/
        !           164: uint sbbs_t::userdatdupe(uint usernumber, uint offset, uint datlen, char *dat
        !           165:     ,bool del)
        !           166: {
        !           167:        bputs(text[SearchingForDupes]);
        !           168:        uint i=::userdatdupe(&cfg, usernumber, offset, datlen, dat, del);
        !           169:        bputs(text[SearchedForDupes]);
        !           170:        return(i);
        !           171: }
        !           172: 
        !           173: 

unix.superglobalmegacorp.com

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