Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 73134a2c authored by rswindell's avatar rswindell

The Big Commit:

* Parses/consumes QWK headers.dat files
  - No more to/from/subj length limits
  - Extensive header details transferred for each message
  - IP/hostname filters (.can files) are applied to appropriate header fields
  - Code cleanup in the QWK functions
* New functions to read/parse/search filter (.can) files as string lists
  - Performance boost - no need to open/read/close .can file for each message
* More thread-safe Message-ID retrieval/generation (ftn_msgid and get_msgid)
* Better Message-ID generation for misconfigured systems (e.g. no hostname)
! These changes require the latest smblib and xpdev libraries !
parent b8401ebd
......@@ -781,7 +781,7 @@ static JSBool js_get_msg_header_resolve(JSContext *cx, JSObject *obj, jsval id)
if(smb_getmsgidx(&(p->p->smb), &remsg))
sprintf(reply_id,"<%s>",p->p->smb.last_error);
else
SAFECOPY(reply_id,get_msgid(scfg,p->p->smb.subnum,&remsg));
get_msgid(scfg,p->p->smb.subnum,&remsg,reply_id,sizeof(reply_id));
}
val=reply_id;
}
......@@ -799,7 +799,7 @@ static JSBool js_get_msg_header_resolve(JSContext *cx, JSObject *obj, jsval id)
/* Message-ID */
if(name==NULL || strcmp(name,"id")==0) {
if(p->expand_fields || (p->msg).id!=NULL) {
SAFECOPY(msg_id,get_msgid(scfg,p->p->smb.subnum,&(p->msg)));
get_msgid(scfg,p->p->smb.subnum,&(p->msg),msg_id,sizeof(msg_id));
val=msg_id;
if((js_str=JS_NewStringCopyZ(cx,truncsp(val)))!=NULL) {
JS_DefineProperty(cx, obj, "id"
......
......@@ -415,6 +415,7 @@ static ulong sockmimetext(SOCKET socket, smbmsg_t* msg, char* msgtxt, ulong maxl
char toaddr[256]="";
char fromaddr[256]="";
char fromhost[256];
char msgid[256];
char date[64];
char* p;
char* tp;
......@@ -483,7 +484,7 @@ static ulong sockmimetext(SOCKET socket, smbmsg_t* msg, char* msgtxt, ulong maxl
s=sockprintf(socket,"Reply-To: %s",p); /* use original RFC822 header field */
if(!s)
return(0);
if(!sockprintf(socket,"Message-ID: %s",get_msgid(&scfg,INVALID_SUB,msg)))
if(!sockprintf(socket,"Message-ID: %s",get_msgid(&scfg,INVALID_SUB,msg,msgid,sizeof(msgid))))
return(0);
if(msg->reply_id!=NULL)
if(!sockprintf(socket,"In-Reply-To: %s",msg->reply_id))
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -59,14 +59,14 @@ static ulong msgid_serialno(smbmsg_t* msg)
/****************************************************************************/
/* Returns a FidoNet (FTS-9) message-ID */
/****************************************************************************/
char* DLLCALL ftn_msgid(sub_t *sub, smbmsg_t* msg)
char* DLLCALL ftn_msgid(sub_t *sub, smbmsg_t* msg, char* msgid, size_t maxlen)
{
static char msgid[256];
if(msg->ftn_msgid!=NULL && *msg->ftn_msgid!=0)
if(msg->ftn_msgid!=NULL && *msg->ftn_msgid!=0) {
strncpy(msgid,msg->ftn_msgid,maxlen);
return(msg->ftn_msgid);
}
snprintf(msgid,sizeof(msgid)
safe_snprintf(msgid,maxlen
,"%lu.%s@%s %08lx"
,msg_number(msg)
,sub->code
......@@ -80,26 +80,40 @@ char* DLLCALL ftn_msgid(sub_t *sub, smbmsg_t* msg)
/****************************************************************************/
/* Return a general purpose (RFC-822) message-ID */
/****************************************************************************/
char* DLLCALL get_msgid(scfg_t* cfg, uint subnum, smbmsg_t* msg)
char* DLLCALL get_msgid(scfg_t* cfg, uint subnum, smbmsg_t* msg, char* msgid, size_t maxlen)
{
static char msgid[256];
char* host;
if(msg->id!=NULL && *msg->id!=0)
if(msg->id!=NULL && *msg->id!=0) {
strncpy(msgid,msg->id,maxlen);
return(msg->id);
}
/* Try *really* hard to get a hostname from the configuration data */
host=cfg->sys_inetaddr;
if(!host[0]) {
host=cfg->sys_id;
if(!host[0]) {
host=cfg->sys_name;
if(!host[0]) {
host=cfg->sys_op;
}
}
}
if(subnum>=cfg->total_subs)
snprintf(msgid,sizeof(msgid)
safe_snprintf(msgid,maxlen
,"<%08lX.%lu@%s>"
,msg_time(msg)
,msg_number(msg)
,cfg->sys_inetaddr);
,host);
else
snprintf(msgid,sizeof(msgid)
safe_snprintf(msgid,maxlen
,"<%08lX.%lu.%s@%s>"
,msg_time(msg)
,msg_number(msg)
,cfg->sub[subnum]->code
,cfg->sys_inetaddr);
,host);
return(msgid);
}
......@@ -48,6 +48,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
, int conf, FILE* hdrs)
{
char str[512],from[512],to[512],ch=0,tear=0,tearwatch=0,*buf,*p;
char msgid[256];
char tmp[512];
long l,size=0,offset;
int i;
......@@ -61,7 +62,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
fprintf(hdrs,"[%x]\n",offset);
/* Message-IDs */
fprintf(hdrs,"Message-ID: %s\n",get_msgid(&cfg,subnum,msg));
fprintf(hdrs,"Message-ID: %s\n",get_msgid(&cfg,subnum,msg,msgid,sizeof(msgid)));
if(msg->reply_id!=NULL)
fprintf(hdrs,"In-Reply-To: %s\n",msg->reply_id);
......@@ -80,6 +81,18 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
,str,sizeof(str))
,msg->hdr.when_imported.zone
);
fprintf(hdrs,"WhenExported: %-20s %04hx\n"
,xpDateTime_to_isoDateTimeStr(
xpDateTime_now()
,/* separators: */"","","", /* precision: */0
,str,sizeof(str))
,sys_timezone(&cfg)
);
fprintf(hdrs,"ExportedFrom: %s %s %lu\n"
,cfg.sys_id
,subnum==INVALID_SUB ? "mail":cfg.sub[subnum]->code
,msg->hdr.number
);
/* SENDER */
fprintf(hdrs,"%s: %s\n",smb_hfieldtype(SENDER),msg->from);
......@@ -93,6 +106,8 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
fprintf(hdrs,"%s: %s\n",smb_hfieldtype(hfield_type),p);
if(msg->from_org!=NULL)
fprintf(hdrs,"Organization: %s\n",msg->from_org);
else if(msg->from_net.type==NET_NONE)
fprintf(hdrs,"Organization: %s\n",cfg.sys_name);
/* Reply-To */
if((p=(char*)smb_get_hfield(msg,RFC822REPLYTO,NULL))==NULL) {
......@@ -139,7 +154,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
/* RFC822 header fields: */
for(i=0;i<msg->total_hfields;i++)
if(msg->hfield[i].type==RFC822HEADER)
fprintf(hdrs,"%s\n",msg->hfield_dat[i]);
fprintf(hdrs,"%s\n",truncsp_lines((char*)msg->hfield_dat[i]));
/* Blank line: */
fprintf(hdrs,"\n");
......@@ -153,7 +168,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
else if(msg->from_net.type==NET_FIDO)
sprintf(from,"%.128s@%.128s"
,msg->from,smb_faddrtoa((faddr_t *)msg->from_net.addr,tmp));
else if(msg->from_net.type==NET_INTERNET)
else if(msg->from_net.type==NET_INTERNET || strchr((char*)msg->from_net.addr,'@')!=NULL)
sprintf(from,"%.128s",(char*)msg->from_net.addr);
else
sprintf(from,"%.128s@%.128s",msg->from,(char*)msg->from_net.addr);
......@@ -204,7 +219,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
if(mode&QM_MSGID && (uint)subnum!=INVALID_SUB) {
size+=fprintf(qwk_fp,"@MSGID: %s%c"
,get_msgid(&cfg,subnum,msg),QWK_NEWLINE);
,get_msgid(&cfg,subnum,msg,msgid,sizeof(msgid)),QWK_NEWLINE);
if(msg->reply_id) {
SAFECOPY(tmp,msg->reply_id);
......@@ -218,7 +233,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
size+=fprintf(qwk_fp,"@REPLY: <%s>%c",smb.last_error,QWK_NEWLINE);
else
size+=fprintf(qwk_fp,"@REPLY: %s%c"
,get_msgid(&cfg,subnum,&remsg)
,get_msgid(&cfg,subnum,&remsg,msgid,sizeof(msgid))
,QWK_NEWLINE);
}
}
......
......@@ -304,12 +304,12 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
smb_hfield_str(&msg,FIDOPID,program_id(pid));
/* Generate default (RFC822) message-id (always) */
SAFECOPY(msg_id,get_msgid(&cfg,subnum,&msg));
get_msgid(&cfg,subnum,&msg,msg_id,sizeof(msg_id));
smb_hfield_str(&msg,RFC822MSGID,msg_id);
/* Generate FTN (FTS-9) MSGID */
if(cfg.sub[subnum]->misc&SUB_FIDO) {
SAFECOPY(msg_id,ftn_msgid(cfg.sub[subnum],&msg));
ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id));
smb_hfield_str(&msg,FIDOMSGID,msg_id);
}
if(remsg) {
......@@ -506,14 +506,14 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
/* Generate RFC-822 Message-id */
if(msg->id==NULL) {
SAFECOPY(msg_id,get_msgid(cfg,smb->subnum,msg));
get_msgid(cfg,smb->subnum,msg,msg_id,sizeof(msg_id));
smb_hfield_str(msg,RFC822MSGID,msg_id);
}
/* Generate FidoNet MSGID (for FidoNet sub-boards) */
if(smb->subnum!=INVALID_SUB && cfg->sub[smb->subnum]->misc&SUB_FIDO
&& msg->ftn_msgid==NULL) {
SAFECOPY(msg_id,ftn_msgid(cfg->sub[smb->subnum],msg));
ftn_msgid(cfg->sub[smb->subnum],msg,msg_id,sizeof(msg_id));
smb_hfield_str(msg,FIDOMSGID,msg_id);
}
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -38,75 +38,202 @@
#include "sbbs.h"
#include "qwk.h"
static void qwk_parse_header_list(smbmsg_t* msg, str_list_t* headers)
{
char* p;
char zone[32];
char value[INI_MAX_VALUE_LEN+1];
int i;
uint16_t net_type;
uint16_t hfield_type;
if((p=iniPopKey(headers,ROOT_SECTION,"WhenWritten",value))!=NULL) {
xpDateTime_t dt=isoDateTimeStr_parse(p);
msg->hdr.when_written.time=xpDateTime_to_time(dt);
msg->hdr.when_written.zone=dt.zone;
sscanf(p,"%*s %s",zone);
if(zone[0])
msg->hdr.when_written.zone=(ushort)strtoul(zone,NULL,16);
}
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=RECIPIENT),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
/* Recipient net address and type */
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=RECIPIENTNETADDR),value))!=NULL) {
net_type=NET_UNKNOWN;
smb_hfield_netaddr(msg,hfield_type,p,&net_type);
smb_hfield_bin(msg,RECIPIENTNETTYPE,net_type);
}
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SUBJECT),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SENDER),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SENDERNETADDR),value))!=NULL) {
smb_hfield_str(msg,hfield_type,p);
net_type=NET_UNKNOWN;
smb_hfield_netaddr(msg,hfield_type,p,&net_type);
smb_hfield_bin(msg,SENDERNETTYPE,net_type);
}
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=RFC822MSGID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=RFC822REPLYID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
if((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=RFC822REPLYTO),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
/* Trace header fields */
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SENDERIPADDR),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SENDERHOSTNAME),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SENDERPROTOCOL),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,"Organization",value))!=NULL)
smb_hfield_str(msg,SENDERORG,p);
/* FidoNet header fields */
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOAREA),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOSEENBY),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOPATH),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOMSGID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOREPLYID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOPID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOFLAGS),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOTID),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOCTRL),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
/* USENET */
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=USENETPATH),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=USENETNEWSGROUPS),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
/* Others (RFC-822) */
for(i=0;(*headers)[i]!=NULL;i++)
if((*headers)[i][0])
smb_hfield_str(msg,RFC822HEADER,(*headers)[i]);
}
void sbbs_t::qwk_new_msg(smbmsg_t* msg, char* hdrblk, long offset, str_list_t all_headers)
{
char str[128];
str_list_t msg_headers;
smb_freemsgmem(msg);
sprintf(str,"%lx",offset);
msg_headers=iniGetSection(all_headers,str);
memset(msg,0,sizeof(smbmsg_t)); /* Initialize message header */
msg->hdr.version=smb_ver();
if(msg_headers!=NULL)
qwk_parse_header_list(msg, &msg_headers);
/* Parse the QWK message header: */
if(msg->hdr.when_written.time==0) {
struct tm tm;
memset(&tm,0,sizeof(tm));
tm.tm_mon = ((hdrblk[8]&0xf)*10)+(hdrblk[9]&0xf);
tm.tm_mday=((hdrblk[11]&0xf)*10)+(hdrblk[12]&0xf);
tm.tm_year=((hdrblk[14]&0xf)*10)+(hdrblk[15]&0xf);
if(tm.tm_year<Y2K_2DIGIT_WINDOW)
tm.tm_year+=100;
tm.tm_hour=((hdrblk[16]&0xf)*10)+(hdrblk[17]&0xf);
tm.tm_min=((hdrblk[19]&0xf)*10)+(hdrblk[20]&0xf);
msg->hdr.when_written.time=sane_mktime(&tm);
}
if(msg->to==NULL) {
sprintf(str,"%25.25s",(char *)hdrblk+21); /* To user */
truncsp(str);
smb_hfield_str(msg,RECIPIENT,str);
}
if(msg->from==NULL) {
sprintf(str,"%25.25s",hdrblk+46);
truncsp(str);
smb_hfield_str(msg,SENDER,str);
}
if(msg->subj==NULL) {
sprintf(str,"%25.25s",hdrblk+71); /* Subject */
truncsp(str);
smb_hfield_str(msg,SUBJECT,str);
}
iniFreeStringList(msg_headers);
}
/****************************************************************************/
/* Converts a QWK message packet into a message. */
/* Does *not* free the msgmem */
/****************************************************************************/
bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
, uint touser)
bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
,char fromhub, uint subnum
,uint touser, smbmsg_t* msg)
{
char* body;
char* tail;
char* header;
char str[256],col=0,lastch=0,*p,qwkbuf[QWK_BLOCK_LEN+1];
uint i,j,k,lzh=0,skip=0;
char from[128];
uint i,k,lzh=0,skip=0;
long bodylen,taillen;
bool header_cont=false;
bool success=false;
ulong block,blocks;
smbmsg_t msg;
struct tm tm;
ulong block;
uint16_t net_type;
ushort xlat=XLAT_NONE;
int storage=SMB_SELFPACK;
long dupechk_hashes=SMB_HASH_SOURCE_ALL;
memset(&msg,0,sizeof(smbmsg_t)); /* Initialize message header */
msg.hdr.version=smb_ver();
blocks=atol(hdrblk+116);
if(blocks<2) {
errormsg(WHERE,ERR_CHK,"QWK packet header blocks",blocks);
return(false);
}
if(subnum!=INVALID_SUB
&& (hdrblk[0]=='*' || hdrblk[0]=='+' || cfg.sub[subnum]->misc&SUB_PONLY))
msg.hdr.attr|=MSG_PRIVATE;
msg->hdr.attr|=MSG_PRIVATE;
if(subnum!=INVALID_SUB && cfg.sub[subnum]->misc&SUB_AONLY)
msg.hdr.attr|=MSG_ANONYMOUS;
msg->hdr.attr|=MSG_ANONYMOUS;
if(subnum==INVALID_SUB && cfg.sys_misc&SM_DELREADM)
msg.hdr.attr|=MSG_KILLREAD;
msg->hdr.attr|=MSG_KILLREAD;
if((fromhub || useron.rest&FLAG('Q')) &&
(hdrblk[0]=='*' || hdrblk[0]=='-' || hdrblk[0]=='`'))
msg.hdr.attr|=MSG_READ;
msg->hdr.attr|=MSG_READ;
if(subnum!=INVALID_SUB && !fromhub && cfg.sub[subnum]->mod_ar[0]
&& chk_ar(cfg.sub[subnum]->mod_ar,&useron))
msg.hdr.attr|=MSG_MODERATED;
msg->hdr.attr|=MSG_MODERATED;
if(subnum!=INVALID_SUB && !fromhub && cfg.sub[subnum]->misc&SUB_SYSPERM
&& sub_op(subnum))
msg.hdr.attr|=MSG_PERMANENT;
memset(&tm,0,sizeof(tm));
tm.tm_mon = ((hdrblk[8]&0xf)*10)+(hdrblk[9]&0xf);
if(tm.tm_mon>0) tm.tm_mon--; /* zero based */
tm.tm_mday=((hdrblk[11]&0xf)*10)+(hdrblk[12]&0xf);
tm.tm_year=((hdrblk[14]&0xf)*10)+(hdrblk[15]&0xf);
if(tm.tm_year<Y2K_2DIGIT_WINDOW)
tm.tm_year+=100;
tm.tm_hour=((hdrblk[16]&0xf)*10)+(hdrblk[17]&0xf);
tm.tm_min=((hdrblk[19]&0xf)*10)+(hdrblk[20]&0xf);
tm.tm_sec=0;
tm.tm_isdst=-1; /* Do not adjust for DST */
msg.hdr.when_written.time=mktime(&tm);
if(!(useron.rest&FLAG('Q')) && !fromhub)
msg.hdr.when_written.zone=sys_timezone(&cfg);
msg.hdr.when_imported.time=time(NULL);
msg.hdr.when_imported.zone=sys_timezone(&cfg);
msg->hdr.attr|=MSG_PERMANENT;
if(!(useron.rest&FLAG('Q')) && !fromhub && msg->hdr.when_written.zone==0)
msg->hdr.when_written.zone=sys_timezone(&cfg);
msg->hdr.when_imported.time=time(NULL);
msg->hdr.when_imported.zone=sys_timezone(&cfg);
hdrblk[116]=0; // don't include number of blocks in "re: msg number"
if(!(useron.rest&FLAG('Q')) && !fromhub)
msg.hdr.thread_back=atol((char *)hdrblk+108);
msg->hdr.thread_back=atol((char *)hdrblk+108);
if(subnum==INVALID_SUB) { /* E-mail */
if(cfg.sys_misc&SM_FASTMAIL)
......@@ -115,10 +242,8 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
/* duplicate message-IDs must be allowed in mail database */
dupechk_hashes&=~(1<<SMB_HASH_SOURCE_MSG_ID);
username(&cfg,touser,str);
smb_hfield_str(&msg,RECIPIENT,str);
sprintf(str,"%u",touser);
smb_hfield_str(&msg,RECIPIENTEXT,str);
smb_hfield_str(msg,RECIPIENTEXT,str);
} else {
if(cfg.sub[subnum]->misc&SUB_HYPER)
storage = SMB_HYPERALLOC;
......@@ -127,27 +252,13 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
if(cfg.sub[subnum]->misc&SUB_LZH)
xlat=XLAT_LZH;
sprintf(str,"%25.25s",(char *)hdrblk+21); /* To user */
truncsp(str);
smb_hfield_str(&msg,RECIPIENT,str);
if(cfg.sub[subnum]->misc&SUB_LZH)
xlat=XLAT_LZH;
}
sprintf(str,"%25.25s",hdrblk+71); /* Subject */
truncsp(str);
if(::trashcan(&cfg,str,"subject"))
return false;
smb_hfield_str(&msg,SUBJECT,str);
/********************************/
/* Convert the QWK message text */
/********************************/
if((header=(char *)calloc((blocks-1L)*QWK_BLOCK_LEN*2L,sizeof(char)))==NULL) {
smb_freemsgmem(&msg);
errormsg(WHERE,ERR_ALLOC,"QWK msg header",(blocks-1L)*QWK_BLOCK_LEN*2L);
return(false);
}
......@@ -155,7 +266,6 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
bodylen=0;
if((body=(char *)malloc((blocks-1L)*QWK_BLOCK_LEN*2L))==NULL) {
free(header);
smb_freemsgmem(&msg);
errormsg(WHERE,ERR_ALLOC,"QWK msg body",(blocks-1L)*QWK_BLOCK_LEN*2L);
return(false);
}
......@@ -164,7 +274,6 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
if((tail=(char *)malloc((blocks-1L)*QWK_BLOCK_LEN*2L))==NULL) {
free(header);
free(body);
smb_freemsgmem(&msg);
errormsg(WHERE,ERR_ALLOC,"QWK msg tail",(blocks-1L)*QWK_BLOCK_LEN*2L);
return(false);
}
......@@ -194,7 +303,7 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
&& body[bodylen-3]=='-' && body[bodylen-2]=='-'
&& body[bodylen-1]=='-') {
bodylen-=3;
strcpy(tail,"--- ");
SAFECOPY(tail,"--- ");
taillen=4;
col++;
continue;
......@@ -203,7 +312,7 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
if(!taillen && col==3 && bodylen>=3 && body[bodylen-3]=='-'
&& body[bodylen-2]=='-' && body[bodylen-1]=='-') {
bodylen-=3;
strcpy(tail,"---");
SAFECOPY(tail,"---");
taillen=3;
}
col=0;
......@@ -260,9 +369,8 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
p=header+5; /* Skip "@VIA:" */
while(*p && *p<=' ') p++; /* Skip any spaces */
if(route_circ(p,cfg.sys_id)) {
smb_freemsgmem(&msg);
bprintf("\r\nCircular message path: %s\r\n",p);
sprintf(str,"Circular message path: %s from %s"
SAFEPRINTF2(str,"Circular message path: %s from %s"
,p,fromhub ? cfg.qhub[fromhub-1]->id:useron.alias);
errorlog(str);
free(header);
......@@ -270,32 +378,32 @@ bool sbbs_t::qwktomsg(FILE *qwk_fp, char *hdrblk, char fromhub, uint subnum
free(tail);
return(false);
}
sprintf(str,"%s/%s"
SAFEPRINTF2(str,"%s/%s"
,fromhub ? cfg.qhub[fromhub-1]->id : useron.alias,p);
strupr(str);
update_qwkroute(str);
}
else {
if(fromhub)
strcpy(str,cfg.qhub[fromhub-1]->id);
SAFECOPY(str,cfg.qhub[fromhub-1]->id);
else
strcpy(str,useron.alias);
SAFECOPY(str,useron.alias);
}
/* From network type & address: */
strupr(str);
j=NET_QWK;
smb_hfield(&msg,SENDERNETTYPE,2,&j);
smb_hfield_str(&msg,SENDERNETADDR,str);
sprintf(str,"%25.25s",hdrblk+46); /* From user */
truncsp(str);
net_type=NET_QWK;
smb_hfield_netaddr(msg, SENDERNETADDR, str, &net_type);
smb_hfield_bin(msg,SENDERNETTYPE,net_type);
} else {
sprintf(str,"%u",useron.number);
smb_hfield_str(&msg,SENDEREXT,str);
smb_hfield_str(msg,SENDEREXT,str);
if((uint)subnum!=INVALID_SUB && cfg.sub[subnum]->misc&SUB_NAME)
strcpy(str,useron.name);
SAFECOPY(from,useron.name);
else