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

Make the charset (e.g. UTF-8) detection/indication in msg headers more generic

(e.g. applies to email and netmail now too).
parent 697a655b
......@@ -44,6 +44,7 @@ bool sbbs_t::bulkmail(uchar *ar)
char msgpath[MAX_PATH+1];
char* msgbuf;
char* editor=NULL;
char* charset=NULL;
char tmp[512];
int i,j,x;
long msgs=0;
......@@ -69,7 +70,8 @@ bool sbbs_t::bulkmail(uchar *ar)
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
if(!writemsg(msgpath,nulstr,title,wm_mode,INVALID_SUB,"Bulk Mailing"
,/* From: */useron.alias
,&editor)) {
,&editor
,&charset)) {
bputs(text[Aborted]);
return(false);
}
......@@ -111,7 +113,7 @@ bool sbbs_t::bulkmail(uchar *ar)
msg.hdr.when_written.time=time32(NULL);
msg.hdr.when_written.zone=sys_timezone(&cfg);
editor_info_to_msg(&msg, editor);
editor_info_to_msg(&msg, editor, charset);
memset(&smb,0,sizeof(smb));
smb.subnum=INVALID_SUB; /* mail database */
......
......@@ -50,6 +50,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode,
char tmp[512];
char title[LEN_TITLE+1] = "";
char* editor=NULL;
char* charset=NULL;
uint16_t msgattr=0;
uint16_t xlat=XLAT_NONE;
int i,j,x,file;
......@@ -127,7 +128,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, /* subj: */title,WM_EMAIL|mode,INVALID_SUB,/* to: */str2,/* from: */useron.alias, &editor)) {
if(!writemsg(msgpath,top, /* subj: */title,WM_EMAIL|mode,INVALID_SUB,/* to: */str2,/* from: */useron.alias, &editor, &charset)) {
bputs(text[Aborted]);
return(false);
}
......@@ -317,7 +318,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode,
add_msg_ids(&cfg, &smb, &msg, remsg);
editor_info_to_msg(&msg, editor);
editor_info_to_msg(&msg, editor, charset);
smb_dfield(&msg,TEXT_BODY,length);
......
......@@ -109,6 +109,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resm
char msgpath[MAX_PATH+1];
char tmp[512];
char* editor=NULL;
char* charset=NULL;
int file,x;
uint i;
long length,l;
......@@ -240,7 +241,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resm
}
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
if(!writemsg(msgpath,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB, to, from, &editor)) {
if(!writemsg(msgpath,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB, to, from, &editor, &charset)) {
bputs(text[Aborted]);
return(false);
}
......@@ -350,7 +351,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resm
smb_hfield_str(&msg,SUBJECT, subj);
editor_info_to_msg(&msg, editor);
editor_info_to_msg(&msg, editor, charset);
if(cfg.netmail_misc&NMAIL_DIRECT)
msg.hdr.netattr |= MSG_DIRECT;
......
......@@ -49,6 +49,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm
char name[256] = "";
char addr[256] = "";
char* editor=NULL;
char* charset=NULL;
char your_addr[128];
ushort xlat=XLAT_NONE,net=NET_INTERNET;
int i,j,x,file;
......@@ -115,7 +116,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm
}
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,WM_NETMAIL|mode,INVALID_SUB,into,/* from: */your_addr,&editor)) {
if(!writemsg(msgpath,nulstr,title,WM_NETMAIL|mode,INVALID_SUB,into,/* from: */your_addr, &editor, &charset)) {
bputs(text[Aborted]);
return(false);
}
......@@ -279,7 +280,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm
add_msg_ids(&cfg, &smb, &msg, remsg);
editor_info_to_msg(&msg, editor);
editor_info_to_msg(&msg, editor, charset);
smb_dfield(&msg,TEXT_BODY,length);
......@@ -322,6 +323,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
char title[128] = "";
char to[128] = "";
char* editor=NULL;
char* charset=NULL;
ushort xlat=XLAT_NONE,net=NET_QWK,touser;
int i,j,x,file;
ulong length,offset;
......@@ -374,7 +376,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
}
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title, (mode|WM_QWKNET|WM_NETMAIL) ,INVALID_SUB,to,/* from: */useron.alias,&editor)) {
if(!writemsg(msgpath,nulstr,title, (mode|WM_QWKNET|WM_NETMAIL) ,INVALID_SUB,to,/* from: */useron.alias, &editor, &charset)) {
bputs(text[Aborted]);
return(false);
}
......@@ -491,7 +493,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
add_msg_ids(&cfg, &smb, &msg, /* remsg: */NULL);
editor_info_to_msg(&msg, editor);
editor_info_to_msg(&msg, editor, charset);
smb_dfield(&msg,TEXT_BODY,length);
......
......@@ -79,6 +79,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
char from[64];
char tags[64] = "";
char* editor=NULL;
char* charset=NULL;
char* msgbuf=NULL;
uint16_t xlat;
ushort msgattr = 0;
......@@ -88,7 +89,6 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
FILE* fp;
smbmsg_t msg;
uint reason;
bool utf8 = false;
if(remsg) {
SAFECOPY(title, remsg->subj);
......@@ -216,7 +216,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
if(!writemsg(str,top,title,wm_mode,subnum,touser
,/* from: */cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias
,&editor, &utf8)
,&editor, &charset)
|| (length=(long)flength(str))<1) { /* Bugfix Aug-20-2003: Reject negative length */
bputs(text[Aborted]);
smb_close(&smb);
......@@ -291,10 +291,7 @@ bool sbbs_t::postmsg(uint subnum, long wm_mode, smb_t* resmb, smbmsg_t* remsg)
add_msg_ids(&cfg, &smb, &msg, remsg);
editor_info_to_msg(&msg, editor);
if(utf8)
smb_hfield_str(&msg, FIDOCTRL, FIDO_CHARSET_UTF8);
editor_info_to_msg(&msg, editor, charset);
if((cfg.sub[subnum]->misc&SUB_MSGTAGS)
&& (tags[0] || text[TagMessageQ][0] == 0 || !noyes(text[TagMessageQ]))) {
......
......@@ -651,7 +651,7 @@ public:
/* writemsg.cpp */
void automsg(void);
bool writemsg(const char *str, const char *top, char *subj, long mode, uint subnum
,const char *to, const char* from, char** editor=NULL, bool* utf8=NULL);
,const char *to, const char* from, char** editor=NULL, char** charset=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, long org_cols = 0);
......@@ -671,7 +671,7 @@ public:
bool movemsg(smbmsg_t* msg, uint subnum);
int process_edited_text(char* buf, FILE* stream, long mode, unsigned* lines, unsigned maxlines);
int process_edited_file(const char* src, const char* dest, long mode, unsigned* lines, unsigned maxlines);
void editor_info_to_msg(smbmsg_t*, const char* editor);
void editor_info_to_msg(smbmsg_t*, const char* editor, const char* charset);
/* postmsg.cpp */
bool postmsg(uint subnum, long wm_mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL);
......
......@@ -235,7 +235,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 *subj, long mode, uint subnum
,const char *to, const char* from, char** editor, bool* utf8)
,const char *to, const char* from, char** editor, char** charset)
{
char str[256],quote[128],c,*buf,*p,*tp
,useron_level;
......@@ -640,8 +640,10 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
return(false);
}
l=process_edited_text(buf,stream,mode,&lines,cfg.level_linespermsg[useron_level]);
if(utf8 != NULL)
*utf8 = (!str_is_ascii(buf) && utf8_str_is_valid(buf));
if(charset != NULL) {
if(!str_is_ascii(buf) && utf8_str_is_valid(buf))
*charset = FIDO_CHARSET_UTF8;
}
if(!(mode&(WM_EXTDESC|WM_ANON))) {
/* Signature file */
......@@ -683,11 +685,14 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
return(true);
}
void sbbs_t::editor_info_to_msg(smbmsg_t* msg, const char* editor)
void sbbs_t::editor_info_to_msg(smbmsg_t* msg, const char* editor, const char* charset)
{
if(editor != NULL)
smb_hfield_str(msg, SMB_EDITOR, editor);
if(charset != NULL)
smb_hfield_str(msg, FIDOCTRL, charset);
ushort useron_xedit = useron.xedit;
if(useron_xedit > 0 && !chk_ar(cfg.xedit[useron_xedit - 1]->ar, &useron, &client))
......
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