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

Define some new SMB hfield types:

- REPLYTOLIST (a mime-decoded version of RFC822REPLYTO)
- RECIPIENTLIST (a mime-decoded version of RC822TO)
- RFC822CC (a mime-encoded version of SMB_CARBONCOPY)
- RFC822ORG (a mime-encoded version of SMB_ORGANIZATION)
- RFC822SUBJECT (a mime-encoded version of SUBJECT)

The RFC822* hfields are only created when necessary: there was a MIME-encoded
hfield value received (e.g. by the mailsrvr) for the corresponding hfield.

The to_list and replyto_list convenience pointers now point to the MIME-decoded
(plain text) version of these header fields, since that's what everyone
normally wants to see and use.

The MIME-encoded flavors (RFC822*) are stored for relaying via SMTP or POP3
and retaining all data (no normalization or decoding).

A new auxattr bit has been defined: MSG_HFIELDS_UTF8 (happens to be the same
as P_UTF8 - snicker). This bit will be set in msg.hdr.auxattr when one or more
hfield values are in UTF-8 format. When this flag is not set, all hfield values
are assumed to be CP437 for backwards compatibility.
Since we are using a single flag, all header fields have to use the same
encoding (either CP437 or UTF-8). When the hfield values are all plain ASCII,
there's no difference between CP437 and UTF-8 and the MSG_HFIELDS_UTF8 flag
is not expected to be set, though setting it shouldn't hurt. The RFC822* hfield
values should also include US-ASCII text (using MIME-encoding for any 8-bit
charsets).

smb_get_hfield() function prototype change: the 3rd argument changed from
an hfield_t* to an hfield_t**, so that the caller can actually change the
hfield type (in memory) if they wish. Nobody seemed to be passing any non-NULL
3rd argument value, so this changed appeared safe to make.
parent 6c8526f0
......@@ -188,6 +188,7 @@
#define REPLYTOEXT 0x24
#define REPLYTOPOS 0x25
#define REPLYTOORG 0x26
#define REPLYTOLIST 0x27
#define RECIPIENT 0x30
#define RECIPIENTAGENT 0x31
......@@ -196,6 +197,7 @@
#define RECIPIENTEXT 0x34
#define RECIPIENTPOS 0x35
#define RECIPIENTORG 0x36
#define RECIPIENTLIST 0x37
#define FORWARDED 0x48
......@@ -223,12 +225,17 @@
#define FIDOTID 0xa8
#define FIDOCHARSET 0xa9 // CHRS or CHARSET control line
// RFC822* header field values are strings of US-ASCII chars, but potentially MIME-encoded (RFC2047)
// (i.e. base64 or Q-encoded UTF-8, ISO-8859-1, etc.)
#define RFC822HEADER 0xb0
#define RFC822MSGID 0xb1
#define RFC822REPLYID 0xb2
#define RFC822TO 0xb3 // Comma-separated list of recipients, RFC822-style
#define RFC822FROM 0xb4 // Original, unparsed/modified RFC822 header "From" value
#define RFC822REPLYTO 0xb5 // Comma-separated list of recipients, RFC822-style
#define RFC822CC 0xb6
#define RFC822ORG 0xb7
#define RFC822SUBJECT 0xb8
#define USENETPATH 0xc0
#define USENETNEWSGROUPS 0xc1
......@@ -284,6 +291,7 @@
#define MSG_RECEIPTREQ (1<<4) /* Return receipt requested */
#define MSG_CONFIRMREQ (1<<5) /* Confirmation receipt requested */
#define MSG_NODISP (1<<6) /* Msg may not be displayed to user */
#define MSG_HFIELDS_UTF8 (1<<13) /* Message header fields are UTF-8 encoded */
#define POLL_CLOSED (1<<24) /* Closed to voting */
#define POLL_RESULTS_MASK (3U<<30) /* 4 possible values: */
#define POLL_RESULTS_SECRET (3U<<30) /* No one but pollster can see results */
......
......@@ -767,7 +767,7 @@ static void set_convenience_ptr(smbmsg_t* msg, uint16_t hfield_type, void* hfiel
case REPLYTO:
msg->replyto=(char*)hfield_dat;
break;
case RFC822REPLYTO:
case REPLYTOLIST:
msg->replyto_list = (char*)hfield_dat;
break;
case REPLYTOEXT:
......@@ -785,7 +785,7 @@ static void set_convenience_ptr(smbmsg_t* msg, uint16_t hfield_type, void* hfiel
case RECIPIENT:
msg->to=(char*)hfield_dat;
break;
case RFC822TO:
case RECIPIENTLIST:
msg->to_list = (char*)hfield_dat;
break;
case RECIPIENTEXT:
......@@ -1382,14 +1382,14 @@ int SMBCALL smb_hfield_replace_str(smbmsg_t* msg, uint16_t type, const char* str
/****************************************************************************/
/* Searches for a specific header field (by type) and returns it */
/****************************************************************************/
void* SMBCALL smb_get_hfield(smbmsg_t* msg, uint16_t type, hfield_t* hfield)
void* SMBCALL smb_get_hfield(smbmsg_t* msg, uint16_t type, hfield_t** hfield)
{
int i;
for(i=0;i<msg->total_hfields;i++)
if(msg->hfield[i].type == type) {
if(hfield != NULL)
*hfield = msg->hfield[i];
*hfield = &msg->hfield[i];
return(msg->hfield_dat[i]);
}
......
......@@ -167,7 +167,7 @@ SMBEXPORT int SMBCALL smb_hfield_add_netaddr(smbmsg_t* msg, uint16_t type, cons
#define smb_hfield_netaddr(msg, type, str, nettype) smb_hfield_add_netaddr(msg, type, str, nettype, /* insert: */FALSE)
SMBEXPORT int SMBCALL smb_dfield(smbmsg_t* msg, uint16_t type, ulong length);
SMBEXPORT void* SMBCALL smb_get_hfield(smbmsg_t* msg, uint16_t type, hfield_t* hfield);
SMBEXPORT void* SMBCALL smb_get_hfield(smbmsg_t* msg, uint16_t type, hfield_t** hfield);
SMBEXPORT int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage);
SMBEXPORT int SMBCALL smb_putmsg(smb_t* smb, smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_putmsgidx(smb_t* smb, smbmsg_t* msg);
......
......@@ -63,12 +63,14 @@ char* SMBCALL smb_hfieldtype(uint16_t type)
case REPLYTONETTYPE: return("Reply-ToNetType");
case REPLYTONETADDR: return("Reply-ToNetAddr");
case REPLYTOEXT: return("Reply-ToExt");
case REPLYTOLIST: return("Reply-ToList");
case RECIPIENT: return("To"); /* RFC-compliant */
case RECIPIENTAGENT: return("ToAgent");
case RECIPIENTNETTYPE: return("ToNetType");
case RECIPIENTNETADDR: return("ToNetAddr");
case RECIPIENTEXT: return("ToExt");
case RECIPIENTLIST: return("ToList");
case SUBJECT: return("Subject"); /* RFC-compliant */
case SMB_SUMMARY: return("Summary");
......@@ -101,6 +103,9 @@ char* SMBCALL smb_hfieldtype(uint16_t type)
case RFC822TO: return("RFC822To");
case RFC822FROM: return("RFC822From");
case RFC822REPLYTO: return("RFC822ReplyTo");
case RFC822CC: return("RFC822Cc");
case RFC822ORG: return("RFC822Org");
case RFC822SUBJECT: return("RFC822Subject");
case USENETPATH: return("Path"); /* RFC-compliant */
case USENETNEWSGROUPS: return("Newsgroups"); /* RFC-compliant */
......
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