Annotation of sbbs/src/sbbs3/postmsg.cpp, revision 1.1.1.2

1.1       root        1: /* postmsg.cpp */
                      2: 
                      3: /* Synchronet user create/post public message routine */
                      4: 
1.1.1.2 ! root        5: /* $Id: postmsg.cpp,v 1.85 2011/08/30 22:51:21 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: 
1.1.1.2 ! root       40: /****************************************************************************/
        !            41: /****************************************************************************/
        !            42: extern "C" char* DLLCALL msg_program_id(char* pid)
1.1       root       43: {
                     44:        char compiler[64];
                     45: 
                     46:        DESCRIBE_COMPILER(compiler);
                     47:        sprintf(pid,"%.10s %s%c-%s%s%s %s %s"
                     48:                ,VERSION_NOTICE,VERSION,REVISION,PLATFORM_DESC
                     49:                ,beta_version
                     50: #ifdef _DEBUG
                     51:                ," Debug"
                     52: #else
                     53:                ,""
                     54: #endif
                     55:                ,__DATE__,compiler);
                     56:        return(pid);
                     57: }
                     58: 
                     59: /****************************************************************************/
                     60: /* Posts a message on subboard number sub, with 'top' as top of message.    */
                     61: /* Returns 1 if posted, 0 if not.                                           */
                     62: /****************************************************************************/
                     63: bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
                     64: {
                     65:        char    str[256],title[LEN_TITLE+1],buf[SDT_BLOCK_LEN],top[256];
                     66:        char    msg_id[256];
                     67:        char    touser[64];
                     68:        char    from[64];
                     69:        char    pid[128];
1.1.1.2 ! root       70:        char*   editor=NULL;
        !            71:        uint16_t xlat;
        !            72:        ushort  msgattr;
1.1       root       73:        int     i,j,x,file,storage;
                     74:        ulong   length,offset,crc=0xffffffff;
                     75:        FILE*   instream;
                     76:        smbmsg_t msg;
1.1.1.2 ! root       77:        uint    reason;
1.1       root       78: 
                     79:        if(remsg) {
                     80:                sprintf(title,"%.*s",LEN_TITLE,remsg->subj);
                     81:                if(remsg->hdr.attr&MSG_ANONYMOUS)
                     82:                        SAFECOPY(from,text[Anonymous]);
                     83:                else
                     84:                        SAFECOPY(from,remsg->from);
                     85:                // If user posted this message, reply to the original recipient again
                     86:                if((remsg->from_ext!=NULL && atoi(remsg->from_ext)==useron.number)
                     87:                        || stricmp(useron.alias,remsg->from)==0 || stricmp(useron.name,remsg->from)==0)
                     88:                        SAFECOPY(touser,remsg->to);
                     89:                else
                     90:                        SAFECOPY(touser,from);
                     91:                msgattr=(ushort)(remsg->hdr.attr&MSG_PRIVATE);
                     92:                sprintf(top,text[RegardingByToOn],title,from,remsg->to
1.1.1.2 ! root       93:                        ,timestr(remsg->hdr.when_written.time)
1.1       root       94:                        ,smb_zonestr(remsg->hdr.when_written.zone,NULL)); 
                     95:        } else {
                     96:                title[0]=0;
                     97:                touser[0]=0;
                     98:                top[0]=0;
                     99:                msgattr=0; 
                    100:        }
                    101: 
                    102:        /* Security checks */
1.1.1.2 ! root      103:        if(!can_user_post(&cfg,subnum,&useron,&client,&reason)) {
        !           104:                bputs(text[reason]);
        !           105:                return false;
1.1       root      106:        }
                    107: 
                    108:        bprintf(text[Posting],cfg.grp[cfg.sub[subnum]->grp]->sname,cfg.sub[subnum]->lname);
                    109:        action=NODE_PMSG;
                    110:        nodesync();
                    111: 
                    112:        if(!(msgattr&MSG_PRIVATE) && (cfg.sub[subnum]->misc&SUB_PONLY
                    113:                || (cfg.sub[subnum]->misc&SUB_PRIV && !noyes(text[PrivatePostQ]))))
                    114:                msgattr|=MSG_PRIVATE;
                    115: 
                    116:        if(sys_status&SS_ABORT)
                    117:                return(false);
                    118: 
                    119:        if(
                    120: #if 0  /* we *do* support internet posts to specific people July-11-2002 */
                    121:                !(cfg.sub[subnum]->misc&SUB_INET) &&    // Prompt for TO: user
                    122: #endif
                    123:                (cfg.sub[subnum]->misc&SUB_TOUSER || msgattr&MSG_PRIVATE || touser[0])) {
                    124:                if(!touser[0] && !(msgattr&MSG_PRIVATE))
                    125:                        SAFECOPY(touser,"All");
                    126:                bputs(text[PostTo]);
                    127:                i=LEN_ALIAS;
                    128:                if(cfg.sub[subnum]->misc&SUB_QNET)
                    129:                        i=25;
                    130:                if(cfg.sub[subnum]->misc&SUB_FIDO)
                    131:                        i=FIDO_NAME_LEN-1;
                    132:                if(cfg.sub[subnum]->misc&(SUB_PNET|SUB_INET))
                    133:                        i=60;
                    134:                getstr(touser,i,K_UPRLWR|K_LINE|K_EDIT|K_AUTODEL);
                    135:                if(stricmp(touser,"ALL")
                    136:                && !(cfg.sub[subnum]->misc&(SUB_PNET|SUB_FIDO|SUB_QNET|SUB_INET|SUB_ANON))) {
                    137:                        if(cfg.sub[subnum]->misc&SUB_NAME) {
1.1.1.2 ! root      138:                                if(!userdatdupe(useron.number,U_NAME,LEN_NAME,touser)) {
1.1       root      139:                                        bputs(text[UnknownUser]);
                    140:                                        return(false); 
                    141:                                } 
                    142:                        }
                    143:                        else {
                    144:                                if((i=finduser(touser))==0)
                    145:                                        return(false);
                    146:                                username(&cfg,i,touser); 
                    147:                        } 
                    148:                }
                    149:                if(sys_status&SS_ABORT)
                    150:                        return(false); 
                    151:        }
                    152: 
                    153:        if(!touser[0])
                    154:                SAFECOPY(touser,"All");       // Default to ALL
                    155: 
                    156:        if(!stricmp(touser,"SYSOP") && !SYSOP)  // Change SYSOP to user #1
                    157:                username(&cfg,1,touser);
                    158: 
                    159:        if(msgattr&MSG_PRIVATE && !stricmp(touser,"ALL")) {
                    160:                bputs(text[NoToUser]);
                    161:                return(false); 
                    162:        }
                    163:        if(msgattr&MSG_PRIVATE)
                    164:                wm_mode|=WM_PRIVATE;
                    165: 
                    166:        if(cfg.sub[subnum]->misc&SUB_AONLY
                    167:                || (cfg.sub[subnum]->misc&SUB_ANON && useron.exempt&FLAG('A')
                    168:                        && !noyes(text[AnonymousQ])))
                    169:                msgattr|=MSG_ANONYMOUS;
                    170: 
1.1.1.2 ! root      171:        if(cfg.sub[subnum]->mod_ar[0] && chk_ar(cfg.sub[subnum]->mod_ar,&useron,&client))
1.1       root      172:                msgattr|=MSG_MODERATED;
                    173: 
                    174:        if(cfg.sub[subnum]->misc&SUB_SYSPERM && sub_op(subnum))
                    175:                msgattr|=MSG_PERMANENT;
                    176: 
                    177:        if(msgattr&MSG_PRIVATE)
                    178:                bputs(text[PostingPrivately]);
                    179: 
                    180:        if(msgattr&MSG_ANONYMOUS)
                    181:                bputs(text[PostingAnonymously]);
                    182: 
                    183:        if(cfg.sub[subnum]->misc&SUB_NAME)
                    184:                bputs(text[UsingRealName]);
                    185: 
                    186:        msg_tmp_fname(useron.xedit, str, sizeof(str));
1.1.1.2 ! root      187:        if(!writemsg(str,top,title,wm_mode,subnum,touser,&editor)
        !           188:                || (long)(length=(long)flength(str))<1) {       /* Bugfix Aug-20-2003: Reject negative length */
1.1       root      189:                bputs(text[Aborted]);
                    190:                return(false); 
                    191:        }
                    192: 
                    193:        bputs(text[WritingIndx]);
                    194: 
                    195:        if((i=smb_stack(&smb,SMB_STACK_PUSH))!=SMB_SUCCESS) {
                    196:                errormsg(WHERE,ERR_OPEN,cfg.sub[subnum]->code,i,smb.last_error);
                    197:                return(false); 
                    198:        }
                    199: 
                    200:        sprintf(smb.file,"%s%s",cfg.sub[subnum]->data_dir,cfg.sub[subnum]->code);
                    201:        smb.retry_time=cfg.smb_retry_time;
                    202:        smb.subnum=subnum;
                    203:        if((i=smb_open(&smb))!=SMB_SUCCESS) {
                    204:                errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
                    205:                smb_stack(&smb,SMB_STACK_POP);
                    206:                return(false); 
                    207:        }
                    208: 
                    209:        if(filelength(fileno(smb.shd_fp))<1) {   /* Create it if it doesn't exist */
                    210:                smb.status.max_crcs=cfg.sub[subnum]->maxcrcs;
                    211:                smb.status.max_msgs=cfg.sub[subnum]->maxmsgs;
                    212:                smb.status.max_age=cfg.sub[subnum]->maxage;
                    213:                smb.status.attr=cfg.sub[subnum]->misc&SUB_HYPER ? SMB_HYPERALLOC : 0;
                    214:                if((i=smb_create(&smb))!=SMB_SUCCESS) {
                    215:                        smb_close(&smb);
                    216:                        errormsg(WHERE,ERR_CREATE,smb.file,i,smb.last_error);
                    217:                        smb_stack(&smb,SMB_STACK_POP);
                    218:                        return(false); 
                    219:                } 
                    220:        }
                    221: 
                    222:        if((i=smb_locksmbhdr(&smb))!=SMB_SUCCESS) {
                    223:                smb_close(&smb);
                    224:                errormsg(WHERE,ERR_LOCK,smb.file,i,smb.last_error);
                    225:                smb_stack(&smb,SMB_STACK_POP);
                    226:                return(false); 
                    227:        }
                    228: 
                    229:        if((i=smb_getstatus(&smb))!=SMB_SUCCESS) {
                    230:                smb_close(&smb);
                    231:                errormsg(WHERE,ERR_READ,smb.file,i,smb.last_error);
                    232:                smb_stack(&smb,SMB_STACK_POP);
                    233:                return(false); 
                    234:        }
                    235: 
                    236:        length+=sizeof(xlat);    /* +2 for translation string */
                    237: 
                    238:        if(length&0xfff00000UL) {
                    239:                smb_close(&smb);
                    240:                errormsg(WHERE,ERR_LEN,str,length,smb.last_error);
                    241:                smb_stack(&smb,SMB_STACK_POP);
                    242:                return(false); 
                    243:        }
                    244: 
                    245:        if(smb.status.attr&SMB_HYPERALLOC) {
                    246:                offset=smb_hallocdat(&smb);
                    247:                storage=SMB_HYPERALLOC; 
                    248:        }
                    249:        else {
                    250:                if((i=smb_open_da(&smb))!=SMB_SUCCESS) {
                    251:                        smb_close(&smb);
                    252:                        errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
                    253:                        smb_stack(&smb,SMB_STACK_POP);
                    254:                        return(false); 
                    255:                }
                    256:                if(cfg.sub[subnum]->misc&SUB_FAST) {
                    257:                        offset=smb_fallocdat(&smb,length,1);
                    258:                        storage=SMB_FASTALLOC; 
                    259:                }
                    260:                else {
                    261:                        offset=smb_allocdat(&smb,length,1);
                    262:                        storage=SMB_SELFPACK; 
                    263:                }
                    264:                smb_close_da(&smb); 
                    265:        }
                    266: 
                    267:        if((file=open(str,O_RDONLY|O_BINARY))==-1
                    268:                || (instream=fdopen(file,"rb"))==NULL) {
                    269:                smb_freemsgdat(&smb,offset,length,1);
                    270:                smb_close(&smb);
                    271:                errormsg(WHERE,ERR_OPEN,str,O_RDONLY|O_BINARY);
                    272:                smb_stack(&smb,SMB_STACK_POP);
                    273:                return(false); 
                    274:        }
                    275: 
                    276:        setvbuf(instream,NULL,_IOFBF,2*1024);
                    277:        fseek(smb.sdt_fp,offset,SEEK_SET);
                    278:        xlat=XLAT_NONE;
                    279:        fwrite(&xlat,2,1,smb.sdt_fp);
                    280:        x=SDT_BLOCK_LEN-2;                              /* Don't read/write more than 255 */
                    281:        while(!feof(instream)) {
                    282:                memset(buf,0,x);
                    283:                j=fread(buf,1,x,instream);
                    284:                if(j<1)
                    285:                        break;
                    286:                if(j>1 && (j!=x || feof(instream)) && buf[j-1]==LF && buf[j-2]==CR)
                    287:                        buf[j-1]=buf[j-2]=0;    /* Convert to NULL */
                    288:                if(cfg.sub[subnum]->maxcrcs) {
                    289:                        for(i=0;i<j;i++)
                    290:                                crc=ucrc32(buf[i],crc); 
                    291:                }
                    292:                fwrite(buf,j,1,smb.sdt_fp);
                    293:                x=SDT_BLOCK_LEN; 
                    294:        }
                    295:        fflush(smb.sdt_fp);
                    296:        fclose(instream);
                    297:        crc=~crc;
                    298: 
1.1.1.2 ! root      299:        if(cfg.sub[subnum]->maxcrcs) {
        !           300:                i=smb_addcrc(&smb,crc);
        !           301:                if(i) {
        !           302:                        smb_freemsgdat(&smb,offset,length,1);
        !           303:                        smb_close(&smb);
        !           304:                        smb_stack(&smb,SMB_STACK_POP);
        !           305:                        attr(cfg.color[clr_err]);
        !           306:                        bputs(text[CantPostMsg]);
        !           307:                        return(false); 
        !           308:                } 
        !           309:        }
        !           310: 
1.1       root      311:        memset(&msg,0,sizeof(smbmsg_t));
                    312:        msg.hdr.version=smb_ver();
                    313:        msg.hdr.attr=msgattr;
                    314:        msg.hdr.when_written.time=msg.hdr.when_imported.time=time(NULL);
                    315:        msg.hdr.when_written.zone=msg.hdr.when_imported.zone=sys_timezone(&cfg);
                    316: 
                    317:        msg.hdr.number=smb.status.last_msg+1; /* this *should* be the new message number */
                    318: 
                    319:        if(remsg) {
                    320: 
                    321:                msg.hdr.thread_back=remsg->hdr.number;  /* needed for threading backward */
                    322: 
                    323:                /* Add RFC-822 Reply-ID (generate if necessary) */
                    324:                if(remsg->id!=NULL)
                    325:                        smb_hfield_str(&msg,RFC822REPLYID,remsg->id);
                    326: 
                    327:                /* Add FidoNet Reply if original message has FidoNet MSGID */
                    328:                if(remsg->ftn_msgid!=NULL)
                    329:                        smb_hfield_str(&msg,FIDOREPLYID,remsg->ftn_msgid);
                    330: 
                    331:                if((i=smb_updatethread(&smb, remsg, smb.status.last_msg+1))!=SMB_SUCCESS)
1.1.1.2 ! root      332:                        errormsg(WHERE,"updating thread",smb.file,i,smb.last_error); 
1.1       root      333:        }
                    334: 
                    335:        msg.hdr.offset=offset;
                    336: 
                    337:        smb_hfield_str(&msg,RECIPIENT,touser);
                    338: 
                    339:        SAFECOPY(str,cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias);
                    340:        smb_hfield_str(&msg,SENDER,str);
                    341: 
                    342:        sprintf(str,"%u",useron.number);
                    343:        smb_hfield_str(&msg,SENDEREXT,str);
                    344: 
                    345:        /* Security logging */
                    346:        msg_client_hfields(&msg,&client);
1.1.1.2 ! root      347:        smb_hfield_str(&msg,SENDERSERVER,startup->host_name);
1.1       root      348: 
                    349:        smb_hfield_str(&msg,SUBJECT,title);
                    350: 
1.1.1.2 ! root      351:        /* Generate default (RFC822) message-id (always) */
        !           352:        get_msgid(&cfg,subnum,&msg,msg_id,sizeof(msg_id));
        !           353:        smb_hfield_str(&msg,RFC822MSGID,msg_id);
        !           354: 
        !           355:        /* Generate FTN (FTS-9) MSGID */
        !           356:        if(cfg.sub[subnum]->misc&SUB_FIDO) {
        !           357:                ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id));
        !           358:                smb_hfield_str(&msg,FIDOMSGID,msg_id);
        !           359:        }
        !           360: 
        !           361:        /* Generate FidoNet Program Identifier */
        !           362:        smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
        !           363: 
        !           364:        if(editor!=NULL)
        !           365:                smb_hfield_str(&msg,SMB_EDITOR,editor);
        !           366: 
1.1       root      367:        smb_dfield(&msg,TEXT_BODY,length);
                    368: 
                    369:        i=smb_addmsghdr(&smb,&msg,storage);     // calls smb_unlocksmbhdr() 
                    370:        smb_close(&smb);
                    371:        smb_stack(&smb,SMB_STACK_POP);
                    372: 
                    373:        smb_freemsgmem(&msg);
                    374:        if(i!=SMB_SUCCESS) {
                    375:                errormsg(WHERE,ERR_WRITE,smb.file,i,smb.last_error);
                    376:                smb_freemsgdat(&smb,offset,length,1);
                    377:                return(false); 
                    378:        }
                    379: 
                    380:        logon_posts++;
                    381:        user_posted_msg(&cfg, &useron, 1);
                    382:        bprintf(text[Posted],cfg.grp[cfg.sub[subnum]->grp]->sname
                    383:                ,cfg.sub[subnum]->lname);
                    384:        sprintf(str,"%s posted on %s %s"
                    385:                ,useron.alias,cfg.grp[cfg.sub[subnum]->grp]->sname,cfg.sub[subnum]->lname);
                    386:        logline("P+",str);
                    387: 
                    388:        signal_sub_sem(&cfg,subnum);
                    389: 
                    390:        user_event(EVENT_POST);
                    391: 
                    392:        return(true);
                    393: }
                    394: 
                    395: extern "C" void DLLCALL signal_sub_sem(scfg_t* cfg, uint subnum)
                    396: {
                    397:        char str[MAX_PATH+1];
                    398: 
                    399:        if(subnum==INVALID_SUB || subnum>=cfg->total_subs)      /* e-mail? */
                    400:                return;
                    401: 
                    402:        /* signal semaphore files */
                    403:        if(cfg->sub[subnum]->misc&SUB_FIDO && cfg->echomail_sem[0])             
                    404:                ftouch(cmdstr(cfg,NULL,cfg->echomail_sem,nulstr,nulstr,str));
                    405:        if(cfg->sub[subnum]->post_sem[0]) 
                    406:                ftouch(cmdstr(cfg,NULL,cfg->sub[subnum]->post_sem,nulstr,nulstr,str));
                    407: }
                    408: 
                    409: extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client)
                    410: {
1.1.1.2 ! root      411:        int             i;
        !           412:        char    port[16];
        !           413:        char    date[64];
1.1       root      414: 
                    415:        if(client==NULL)
                    416:                return(-1);
                    417: 
1.1.1.2 ! root      418:        if(client->user!=NULL && (i=smb_hfield_str(msg,SENDERUSERID,client->user))!=SMB_SUCCESS)
        !           419:                return(i);
        !           420:        if((i=smb_hfield_str(msg,SENDERTIME,xpDateTime_to_isoDateTimeStr(gmtime_to_xpDateTime(client->time)
        !           421:                ,/* separators: */"","","", /* precision: */0
        !           422:                ,date,sizeof(date))))!=SMB_SUCCESS)
        !           423:                return(i);
1.1       root      424:        if((i=smb_hfield_str(msg,SENDERIPADDR,client->addr))!=SMB_SUCCESS)
                    425:                return(i);
                    426:        if((i=smb_hfield_str(msg,SENDERHOSTNAME,client->host))!=SMB_SUCCESS)
                    427:                return(i);
1.1.1.2 ! root      428:        if(client->protocol!=NULL && (i=smb_hfield_str(msg,SENDERPROTOCOL,client->protocol))!=SMB_SUCCESS)
1.1       root      429:                return(i);
1.1.1.2 ! root      430:        SAFEPRINTF(port,"%u",client->port);
        !           431:        return smb_hfield_str(msg,SENDERPORT,port);
1.1       root      432: }
                    433: 
1.1.1.2 ! root      434: extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf)
1.1       root      435: {
                    436:        char    pid[128];
                    437:        char    msg_id[256];
                    438:        ushort  xlat=XLAT_NONE;
                    439:        int     i;
                    440:        int             storage=SMB_SELFPACK;
1.1.1.2 ! root      441:        long    dupechk_hashes=SMB_HASH_SOURCE_DUPE;
1.1       root      442: 
                    443:        if(msg==NULL)
                    444:                return(SMB_FAILURE);
                    445: 
                    446:        if(!SMB_IS_OPEN(smb)) {
                    447:                if(smb->subnum==INVALID_SUB)
                    448:                        sprintf(smb->file,"%smail",cfg->data_dir);
                    449:                else
                    450:                        sprintf(smb->file,"%s%s",cfg->sub[smb->subnum]->data_dir,cfg->sub[smb->subnum]->code);
                    451:                smb->retry_time=cfg->smb_retry_time;
                    452:                if((i=smb_open(smb))!=SMB_SUCCESS)
                    453:                        return(i);
                    454:        }
                    455: 
                    456:        /* Lock the msgbase early to preserve our message number (used in MSG-IDs) */
                    457:        if(!smb->locked && smb_locksmbhdr(smb)!=SMB_SUCCESS)
                    458:                return(SMB_ERR_LOCK);
                    459: 
                    460:        if(filelength(fileno(smb->shd_fp))>0 && (i=smb_getstatus(smb))!=SMB_SUCCESS) {
                    461:                if(smb->locked)
                    462:                        smb_unlocksmbhdr(smb);
                    463:                return(i);
                    464:        }
                    465: 
                    466:        if(smb->subnum==INVALID_SUB) {  /* e-mail */
                    467: 
1.1.1.2 ! root      468:                /* exception here during recycle:
        !           469: 
        !           470:        sbbs.dll!savemsg(scfg_t * cfg, smb_t * smb, smbmsg_t * msg, client_t * client, char * msgbuf)  Line 473 + 0xf bytes     C++
        !           471:        sbbs.dll!js_save_msg(JSContext * cx, JSObject * obj, unsigned int argc, long * argv, long * rval)  Line 1519 + 0x25 bytes       C
        !           472:        js32.dll!js_Invoke(JSContext * cx, unsigned int argc, unsigned int flags)  Line 1375 + 0x17 bytes       C
        !           473:        js32.dll!js_Interpret(JSContext * cx, unsigned char * pc, long * result)  Line 3944 + 0xf bytes C
        !           474:        js32.dll!js_Execute(JSContext * cx, JSObject * chain, JSScript * script, JSStackFrame * down, unsigned int flags, long * result)  Line 1633 + 0x13 bytes        C
        !           475:        js32.dll!JS_ExecuteScript(JSContext * cx, JSObject * obj, JSScript * script, long * rval)  Line 4188 + 0x19 bytes       C
        !           476:        sbbs.dll!sbbs_t::js_execfile(const char * cmd, const char * startup_dir)  Line 686 + 0x27 bytes C++
        !           477:        sbbs.dll!sbbs_t::external(const char * cmdline, long mode, const char * startup_dir)  Line 413 + 0x1e bytes     C++
        !           478:        sbbs.dll!event_thread(void * arg)  Line 2745 + 0x71 bytes       C++
        !           479: 
        !           480:        apparently the event_thread is sharing an scfg_t* with another thread! */
        !           481: 
        !           482: 
1.1       root      483:                smb->status.max_crcs=cfg->mail_maxcrcs;
                    484:                smb->status.max_age=cfg->mail_maxage;
                    485:                smb->status.max_msgs=0; /* unlimited */
                    486:                smb->status.attr=SMB_EMAIL;
                    487: 
                    488:                if(cfg->sys_misc&SM_FASTMAIL)
                    489:                        storage=SMB_FASTALLOC;
                    490: 
                    491:                /* duplicate message-IDs must be allowed in mail database */
                    492:                dupechk_hashes&=~(1<<SMB_HASH_SOURCE_MSG_ID);
                    493: 
                    494:        } else {        /* sub-board */
                    495: 
                    496:                smb->status.max_crcs=cfg->sub[smb->subnum]->maxcrcs;
                    497:                smb->status.max_msgs=cfg->sub[smb->subnum]->maxmsgs;
                    498:                smb->status.max_age=cfg->sub[smb->subnum]->maxage;
                    499:                smb->status.attr=0;
                    500: 
                    501:                if(cfg->sub[smb->subnum]->misc&SUB_HYPER)
                    502:                        storage = smb->status.attr = SMB_HYPERALLOC;
                    503:                else if(cfg->sub[smb->subnum]->misc&SUB_FAST)
                    504:                        storage = SMB_FASTALLOC;
                    505: 
                    506:                if(cfg->sub[smb->subnum]->misc&SUB_LZH)
                    507:                        xlat=XLAT_LZH;
                    508: 
                    509:                /* enforce anonymous/private posts only */
                    510:                if(cfg->sub[smb->subnum]->misc&SUB_PONLY)
                    511:                        msg->hdr.attr|=MSG_PRIVATE;
                    512:                if(cfg->sub[smb->subnum]->misc&SUB_AONLY)
                    513:                        msg->hdr.attr|=MSG_ANONYMOUS;
                    514:        }
                    515: 
                    516:        if(msg->hdr.when_imported.time==0) {
                    517:                msg->hdr.when_imported.time=time(NULL);
                    518:                msg->hdr.when_imported.zone=sys_timezone(cfg);
                    519:        }
                    520:        if(msg->hdr.when_written.time==0)       /* Uninitialized */
                    521:                msg->hdr.when_written = msg->hdr.when_imported;
                    522: 
                    523:        msg->hdr.number=smb->status.last_msg+1;         /* needed for MSG-ID generation */
                    524: 
                    525:        if(smb->status.max_crcs==0)     /* no CRC checking means no body text dupe checking */
                    526:                dupechk_hashes&=~(1<<SMB_HASH_SOURCE_BODY);
                    527: 
                    528:        if(client!=NULL)
                    529:                msg_client_hfields(msg,client);
1.1.1.2 ! root      530:        if(server!=NULL)
        !           531:                smb_hfield_str(msg,SENDERSERVER,server);
1.1       root      532:  
                    533:        /* Generate RFC-822 Message-id  */
                    534:        if(msg->id==NULL) {
1.1.1.2 ! root      535:                get_msgid(cfg,smb->subnum,msg,msg_id,sizeof(msg_id));
1.1       root      536:                smb_hfield_str(msg,RFC822MSGID,msg_id);
                    537:        }
                    538:  
                    539:        /* Generate FidoNet MSGID (for FidoNet sub-boards) */
                    540:        if(smb->subnum!=INVALID_SUB && cfg->sub[smb->subnum]->misc&SUB_FIDO 
                    541:                && msg->ftn_msgid==NULL) {
1.1.1.2 ! root      542:                ftn_msgid(cfg->sub[smb->subnum],msg,msg_id,sizeof(msg_id));
1.1       root      543:                smb_hfield_str(msg,FIDOMSGID,msg_id);
                    544:        }
                    545: 
1.1.1.2 ! root      546:        /* Generate FidoNet Program Identifier */
        !           547:        if(msg->ftn_pid==NULL)  
        !           548:                smb_hfield_str(msg,FIDOPID,msg_program_id(pid));
        !           549: 
        !           550:        if((i=smb_addmsg(smb,msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf,NULL))==SMB_SUCCESS
        !           551:                && msg->to!=NULL        /* no recipient means no header created at this stage */)
1.1       root      552:                signal_sub_sem(cfg,smb->subnum);
                    553: 
                    554:        return(i);
                    555: }
                    556: 

unix.superglobalmegacorp.com

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