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 d2382ebb authored by rswindell's avatar rswindell

Created message header field to track editor used to create message text.

Added FTN PID header field to all messages created by sbbs.
parent 58024392
......@@ -43,6 +43,7 @@ bool sbbs_t::bulkmail(uchar *ar)
char str[256],title[LEN_TITLE+1];
char msgpath[MAX_PATH+1];
char* msgbuf;
char* editor=NULL;
char tmp[512];
int i,j,x;
long msgs=0;
......@@ -63,7 +64,7 @@ bool sbbs_t::bulkmail(uchar *ar)
msg.hdr.attr|=MSG_ANONYMOUS;
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
if(!writemsg(msgpath,nulstr,title,WM_EMAIL,INVALID_SUB,"Bulk Mailing")) {
if(!writemsg(msgpath,nulstr,title,WM_EMAIL,INVALID_SUB,"Bulk Mailing",&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -104,6 +105,9 @@ bool sbbs_t::bulkmail(uchar *ar)
msg.hdr.when_written.time=time(NULL);
msg.hdr.when_written.zone=sys_timezone(&cfg);
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
memset(&smb,0,sizeof(smb));
smb.subnum=INVALID_SUB; /* mail database */
i=savemsg(&cfg, &smb, &msg, &client, msgbuf);
......
......@@ -48,6 +48,8 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
char str[256],str2[256],msgpath[256],title[LEN_TITLE+1],ch
,buf[SDT_BLOCK_LEN];
char tmp[512];
char pid[128];
char* editor=NULL;
ushort msgattr=0;
uint16_t xlat=XLAT_NONE;
ushort nettype;
......@@ -111,7 +113,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
username(&cfg,usernumber,str2);
if(!writemsg(msgpath,top,title,mode,INVALID_SUB,str2)) {
if(!writemsg(msgpath,top,title,mode,INVALID_SUB,str2,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -305,6 +307,12 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_dfield(&msg,TEXT_BODY,length);
i=smb_addmsghdr(&smb,&msg,SMB_SELFPACK); // calls smb_unlocksmbhdr()
......
......@@ -146,6 +146,10 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
if((p=(char*)smb_get_hfield(msg,hfield_type=FIDOTID,NULL))!=NULL)
fprintf(hdrs,"%s: %s\n", smb_hfieldtype(hfield_type), p);
/* Synchronet */
if((p=(char*)smb_get_hfield(msg,hfield_type=SMB_EDITOR,NULL))!=NULL)
fprintf(hdrs,"%s: %s\n", smb_hfieldtype(hfield_type), p);
/* USENET */
if((p=(char*)smb_get_hfield(msg,hfield_type=USENETPATH,NULL))!=NULL)
fprintf(hdrs,"%s: %s\n", smb_hfieldtype(hfield_type), p);
......
......@@ -45,6 +45,8 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
char str[256],str2[256],msgpath[256],title[256],name[256],ch
,buf[SDT_BLOCK_LEN],*p,addr[256];
char tmp[512];
char pid[128];
char* editor=NULL;
char your_addr[128];
ushort xlat=XLAT_NONE,net=NET_INTERNET;
int i,j,x,file;
......@@ -95,7 +97,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
nodesync();
sprintf(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into)) {
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -256,7 +258,12 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
msg_client_hfields(&msg,&client);
smb_hfield_str(&msg,SUBJECT,title);
SAFECOPY(str,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_dfield(&msg,TEXT_BODY,length);
......@@ -297,6 +304,8 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
char str[256],msgpath[128],title[128],to[128],fulladdr[128]
,buf[SDT_BLOCK_LEN],*addr;
char tmp[512];
char pid[128];
char* editor=NULL;
ushort xlat=XLAT_NONE,net=NET_QWK,touser;
int i,j,x,file;
ulong length,offset;
......@@ -342,7 +351,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
nodesync();
sprintf(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode|WM_QWKNET,INVALID_SUB,to)) {
if(!writemsg(msgpath,nulstr,title,mode|WM_QWKNET,INVALID_SUB,to,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -457,6 +466,12 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_dfield(&msg,TEXT_BODY,length);
i=smb_addmsghdr(&smb,&msg,SMB_SELFPACK); // calls smb_unlocksmbhdr()
......
......@@ -37,7 +37,9 @@
#include "sbbs.h"
static char* program_id(char* pid)
/****************************************************************************/
/****************************************************************************/
extern "C" char* DLLCALL msg_program_id(char* pid)
{
char compiler[64];
......@@ -65,6 +67,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
char touser[64];
char from[64];
char pid[128];
char* editor=NULL;
uint16_t xlat;
ushort msgattr;
int i,j,x,file,storage;
......@@ -181,7 +184,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
bputs(text[UsingRealName]);
msg_tmp_fname(useron.xedit, str, sizeof(str));
if(!writemsg(str,top,title,wm_mode,subnum,touser)
if(!writemsg(str,top,title,wm_mode,subnum,touser,&editor)
|| (long)(length=flength(str))<1) { /* Bugfix Aug-20-2003: Reject negative length */
bputs(text[Aborted]);
return(false);
......@@ -293,6 +296,18 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
fclose(instream);
crc=~crc;
if(cfg.sub[subnum]->maxcrcs) {
i=smb_addcrc(&smb,crc);
if(i) {
smb_freemsgdat(&smb,offset,length,1);
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
attr(cfg.color[clr_err]);
bputs(text[CantPostMsg]);
return(false);
}
}
memset(&msg,0,sizeof(smbmsg_t));
msg.hdr.version=smb_ver();
msg.hdr.attr=msgattr;
......@@ -301,17 +316,6 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
msg.hdr.number=smb.status.last_msg+1; /* this *should* be the new message number */
smb_hfield_str(&msg,FIDOPID,program_id(pid));
/* Generate default (RFC822) message-id (always) */
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) {
ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id));
smb_hfield_str(&msg,FIDOMSGID,msg_id);
}
if(remsg) {
msg.hdr.thread_back=remsg->hdr.number; /* needed for threading backward */
......@@ -328,27 +332,12 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
errormsg(WHERE,"updating thread",smb.file,i,smb.last_error);
}
if(cfg.sub[subnum]->maxcrcs) {
i=smb_addcrc(&smb,crc);
if(i) {
smb_freemsgdat(&smb,offset,length,1);
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
attr(cfg.color[clr_err]);
bputs(text[CantPostMsg]);
return(false);
}
}
msg.hdr.offset=offset;
smb_hfield_str(&msg,RECIPIENT,touser);
strlwr(touser);
SAFECOPY(str,cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias);
smb_hfield_str(&msg,SENDER,str);
strlwr(str);
sprintf(str,"%u",useron.number);
smb_hfield_str(&msg,SENDEREXT,str);
......@@ -358,6 +347,22 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
smb_hfield_str(&msg,SUBJECT,title);
/* Generate default (RFC822) message-id (always) */
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) {
ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id));
smb_hfield_str(&msg,FIDOMSGID,msg_id);
}
/* Generate FidoNet Program Identifier */
smb_hfield_str(&msg,FIDOPID,msg_program_id(pid));
if(editor!=NULL)
smb_hfield_str(&msg,SMB_EDITOR,editor);
smb_dfield(&msg,TEXT_BODY,length);
i=smb_addmsghdr(&smb,&msg,storage); // calls smb_unlocksmbhdr()
......@@ -500,10 +505,6 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
if(client!=NULL)
msg_client_hfields(msg,client);
/* Generate FidoNet Program Identifier */
if(msg->ftn_pid==NULL)
smb_hfield_str(msg,FIDOPID,program_id(pid));
/* Generate RFC-822 Message-id */
if(msg->id==NULL) {
get_msgid(cfg,smb->subnum,msg,msg_id,sizeof(msg_id));
......@@ -517,6 +518,10 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
smb_hfield_str(msg,FIDOMSGID,msg_id);
}
/* Generate FidoNet Program Identifier */
if(msg->ftn_pid==NULL)
smb_hfield_str(msg,FIDOPID,msg_program_id(pid));
if((i=smb_addmsg(smb,msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf,NULL))==SMB_SUCCESS
&& msg->to!=NULL /* no recipient means no header created at this stage */)
signal_sub_sem(cfg,smb->subnum);
......
......@@ -135,6 +135,10 @@ static void qwk_parse_header_list(smbmsg_t* msg, str_list_t* headers, bool parse
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=FIDOCTRL),value))!=NULL)
smb_hfield_str(msg,hfield_type,p);
/* Synchronet */
while((p=iniPopKey(headers,ROOT_SECTION,smb_hfieldtype(hfield_type=SMB_EDITOR),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);
......
......@@ -469,7 +469,7 @@ public:
/* writemsg.cpp */
void automsg(void);
bool writemsg(const char *str, const char *top, char *title, long mode, int subnum
,const char *dest);
,const char *dest, char** editor=NULL);
char* quotes_fname(int xedit, char* buf, size_t len);
char* msg_tmp_fname(int xedit, char* fname, size_t len);
char putmsg(const char *str, long mode);
......@@ -835,6 +835,7 @@ extern "C" {
DLLEXPORT int DLLCALL savemsg(scfg_t*, smb_t*, smbmsg_t*, client_t*, char* msgbuf);
DLLEXPORT void DLLCALL signal_sub_sem(scfg_t*, uint subnum);
DLLEXPORT int DLLCALL msg_client_hfields(smbmsg_t*, client_t*);
DLLEXPORT char* DLLCALL msg_program_id(char* pid);
/* filedat.c */
DLLEXPORT BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f);
......
......@@ -166,7 +166,7 @@ int sbbs_t::process_edited_file(const char* src, const char* dest, long mode, un
/* 'dest' contains a text description of where the message is going. */
/****************************************************************************/
bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode, int subnum
,const char *dest)
,const char *dest, char** editor)
{
char str[256],quote[128],c,*buf,*p,*tp
,useron_level;
......@@ -182,6 +182,9 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
useron_level=useron.level;
if(editor!=NULL)
*editor=NULL;
if((buf=(char*)malloc(cfg.level_linespermsg[useron_level]*MAX_LINE_LEN))
==NULL) {
errormsg(WHERE,ERR_ALLOC,fname
......@@ -416,6 +419,9 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
else if(useron.xedit) {
if(editor!=NULL)
*editor=cfg.xedit[useron.xedit-1]->name;
editor_inf(useron.xedit,dest,title,mode,subnum);
if(cfg.xedit[useron.xedit-1]->type) {
gettimeleft();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment