Commit 6b39f6f3 authored by rswindell's avatar rswindell
Browse files

Bug-fix: pass the 'from' name to writemsg() and editor_inf() so that the drop

files and editors have the correct sender name in all situations (not just
when posting on "real name only" sub-boards).
"ANONYMOUS" postings work too, but mainly Internet & FidoNet Netmail were fixed.
Use removecase() for NETMAIL.MSG (in case there's a lowercase version).
Use subj in place of title and to in place of dest in argument names.
Some constification of argument types.
parent f2c39ffa
......@@ -64,7 +64,9 @@ 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",&editor)) {
if(!writemsg(msgpath,nulstr,title,WM_EMAIL,INVALID_SUB,"Bulk Mailing"
,/* From: */msg.hdr.attr&MSG_ANONYMOUS ? text[Anonymous] : useron.alias
,&editor)) {
bputs(text[Aborted]);
return(false);
}
......
......@@ -115,7 +115,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,&editor)) {
if(!writemsg(msgpath,top, /* subj: */title,mode,INVALID_SUB,/* to: */str2,/* from: */useron.alias, &editor)) {
bputs(text[Aborted]);
return(false);
}
......
......@@ -162,7 +162,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
truncsp(to); /* Truncate off space */
memset(&hdr,0,sizeof(hdr)); /* Initialize header to null */
strcpy(hdr.from,cfg.netmail_misc&NMAIL_ALIAS ? useron.alias : useron.name);
SAFECOPY(hdr.from, cfg.netmail_misc&NMAIL_ALIAS ? useron.alias : useron.name);
SAFECOPY(hdr.to,to);
/* Look-up in nodelist? */
......@@ -214,9 +214,9 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
if(mode&WM_FILE) hdr.attr|=FIDO_FILE;
sprintf(str,"%sNETMAIL.MSG", cfg.node_dir);
remove(str); /* Just incase it's already there */
removecase(str); /* Just incase it's already there */
// mode&=~WM_FILE;
if(!writemsg(str,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB,into)) {
if(!writemsg(str,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB,into,hdr.from)) {
bputs(text[Aborted]);
return(false);
}
......
......@@ -97,7 +97,9 @@ 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,&editor)) {
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into
,/* from: */cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name
,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -351,7 +353,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,&editor)) {
if(!writemsg(msgpath,nulstr,title,mode|WM_QWKNET,INVALID_SUB,to,/* from: */useron.alias,&editor)) {
bputs(text[Aborted]);
return(false);
}
......
......@@ -228,12 +228,13 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
if(msgattr&MSG_ANONYMOUS)
bputs(text[PostingAnonymously]);
if(cfg.sub[subnum]->misc&SUB_NAME)
else if(cfg.sub[subnum]->misc&SUB_NAME)
bputs(text[UsingRealName]);
msg_tmp_fname(useron.xedit, str, sizeof(str));
if(!writemsg(str,top,title,wm_mode,subnum,touser,&editor)
if(!writemsg(str,top,title,wm_mode,subnum,touser
,/* from: */msgattr&MSG_ANONYMOUS ? text[Anonymous] : cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias
,&editor)
|| (length=(long)flength(str))<1) { /* Bugfix Aug-20-2003: Reject negative length */
bputs(text[Aborted]);
return(false);
......
......@@ -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 2015 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 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 *
......@@ -611,8 +611,8 @@ public:
/* writemsg.cpp */
void automsg(void);
bool writemsg(const char *str, const char *top, char *title, long mode, uint subnum
,const char *dest, char** editor=NULL);
bool writemsg(const char *str, const char *top, char *subj, long mode, uint subnum
,const char *to, const char* from, 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);
......@@ -625,7 +625,7 @@ public:
ushort chmsgattr(ushort attr);
void quotemsg(smbmsg_t* msg, int tails);
void editmsg(smbmsg_t* msg, uint subnum);
void editor_inf(int xeditnum, const char *dest, const char *title, long mode
void editor_inf(int xeditnum, const char *to, const char* from, const char *subj, long mode
,uint subnum, const char* tagfile);
void copyfattach(uint to, uint from, char *title);
bool movemsg(smbmsg_t* msg, uint subnum);
......@@ -854,7 +854,7 @@ public:
/* xtrn_sec.cpp */
int xtrn_sec(void); /* The external program section */
void xtrndat(char* name, char* dropdir, uchar type, ulong tleft
void xtrndat(const char* name, const char* dropdir, uchar type, ulong tleft
,ulong misc);
bool exec_xtrn(uint xtrnnum); /* Executes online external program */
bool user_event(user_event_t); /* Executes user event(s) */
......
......@@ -198,8 +198,8 @@ int sbbs_t::process_edited_file(const char* src, const char* dest, long mode, un
/* message and 'title' is the title (70chars max) for the message. */
/* '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, uint subnum
,const char *dest, char** editor)
bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode, uint subnum
,const char *to, const char* from, char** editor)
{
char str[256],quote[128],c,*buf,*p,*tp
,useron_level;
......@@ -401,20 +401,20 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
max_title_len=cols-column-1;
if(max_title_len > LEN_TITLE)
max_title_len = LEN_TITLE;
if(!getstr(title,max_title_len,mode&WM_FILE ? K_LINE : K_LINE|K_EDIT|K_AUTODEL)
if(!getstr(subj,max_title_len,mode&WM_FILE ? K_LINE : K_LINE|K_EDIT|K_AUTODEL)
&& useron_level && useron.logons) {
free(buf);
return(false);
}
if((mode&WM_FILE) && !checkfname(title)) {
if((mode&WM_FILE) && !checkfname(subj)) {
free(buf);
bputs(text[BadFilename]);
return(false);
}
if(!(mode&(WM_EMAIL|WM_NETMAIL)) && cfg.sub[subnum]->misc&SUB_QNET
&& !SYSOP
&& (!stricmp(title,"DROP") || !stricmp(title,"ADD")
|| !strnicmp(dest,"SBBS",4))) {
&& (!stricmp(subj,"DROP") || !stricmp(subj,"ADD")
|| !strnicmp(to,"SBBS",4))) {
free(buf); /* Users can't post DROP or ADD in QWK netted subs */
return(false); /* or messages to "SBBS" */
}
......@@ -463,10 +463,10 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
if(editor!=NULL)
*editor=cfg.xedit[useron_xedit-1]->name;
editor_inf(useron_xedit,dest,title,mode,subnum,tagfile);
editor_inf(useron_xedit,to,from,subj,mode,subnum,tagfile);
if(cfg.xedit[useron_xedit-1]->type) {
gettimeleft();
xtrndat(useron.alias,cfg.node_dir,cfg.xedit[useron_xedit-1]->type
xtrndat(from,cfg.node_dir,cfg.xedit[useron_xedit-1]->type
,timeleft,cfg.xedit[useron_xedit-1]->misc);
}
......@@ -506,7 +506,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
fgets(str,sizeof(str),fp);
fgets(str,sizeof(str),fp);
truncsp(str);
safe_snprintf(title,LEN_TITLE,"%s",str);
safe_snprintf(subj,LEN_TITLE,"%s",str);
fclose(fp);
}
}
......@@ -544,7 +544,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
// remove(msgtmp);
}
}
if(!(msgeditor((char *)buf,mode&WM_NOTOP ? nulstr : top,title))) {
if(!(msgeditor((char *)buf,mode&WM_NOTOP ? nulstr : top, subj))) {
free(buf); /* Assertion here Dec-17-2003, think I fixed in block above (rev 1.52) */
return(false);
}
......@@ -609,7 +609,7 @@ void quotestr(char *str)
/****************************************************************************/
/****************************************************************************/
void sbbs_t::editor_inf(int xeditnum, const char *dest, const char *title, long mode
void sbbs_t::editor_inf(int xeditnum, const char *to, const char* from, const char *subj, long mode
,uint subnum, const char* tagfile)
{
char path[MAX_PATH+1];
......@@ -628,13 +628,11 @@ void sbbs_t::editor_inf(int xeditnum, const char *dest, const char *title, long
return;
}
fprintf(fp,"%s\r\n%s\r\n%s\r\n%u\r\n%s\r\n%s\r\n"
,(subnum!=INVALID_SUB && cfg.sub[subnum]->misc&SUB_NAME) ? useron.name
: useron.alias
,dest,title,1
,mode&WM_NETMAIL ? "NetMail"
,from,to,subj,1
,mode&WM_NETMAIL ? "NetMail"
:mode&WM_EMAIL ? "Electronic Mail"
:subnum==INVALID_SUB ? nulstr
:cfg.sub[subnum]->sname
:subnum==INVALID_SUB ? nulstr
:cfg.sub[subnum]->sname
,mode&WM_PRIVATE ? "YES":"NO");
/* the 7th line (the tag-line file) is a Synchronet extension, for SlyEdit */
if((mode&WM_EXTDESC)==0 && tagfile!=NULL)
......@@ -654,10 +652,12 @@ void sbbs_t::editor_inf(int xeditnum, const char *dest, const char *title, long
return;
}
fprintf(fp,"%s\r\n%s\r\n%u\r\n%s\r\n%s\r\n%u\r\n"
,title,dest,useron.number
,(subnum!=INVALID_SUB && cfg.sub[subnum]->misc&SUB_NAME) ? useron.name
: useron.alias
,useron.name,useron.level);
,subj
,to
,useron.number
,from
,useron.name
,useron.level);
fclose(fp);
}
}
......@@ -1051,7 +1051,7 @@ bool sbbs_t::editfile(char *fname, bool msg)
fcopy(path, msgtmp);
}
editor_inf(useron_xedit,fname,nulstr,0,INVALID_SUB,/* tagfile: */NULL);
editor_inf(useron_xedit,/* to: */fname,/* from: */nulstr,/* subj: */nulstr,0,INVALID_SUB,/* tagfile: */NULL);
if(cfg.xedit[useron_xedit-1]->misc&XTRN_NATIVE)
mode|=EX_NATIVE;
if(cfg.xedit[useron_xedit-1]->misc&XTRN_SH)
......
......@@ -198,7 +198,7 @@ const char *hungupstr="\1n\1h%s\1n hung up on \1h%s\1n %s\r\n";
/****************************************************************************/
/* Convert C string to pascal string */
/****************************************************************************/
void str2pas(char *instr, char *outstr)
void str2pas(const char *instr, char *outstr)
{
int i;
......@@ -294,7 +294,7 @@ static void lfexpand(char *str, ulong misc)
/****************************************************************************/
/* Creates various types of xtrn (Doors, Chains, etc.) data (drop) files. */
/****************************************************************************/
void sbbs_t::xtrndat(char *name, char *dropdir, uchar type, ulong tleft
void sbbs_t::xtrndat(const char *name, const char *dropdir, uchar type, ulong tleft
,ulong misc)
{
char str[1024],tmp2[128],c,*p;
......
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