#ifdef HAVE_ICONV
#include <iconv.h>
-/*
- * Wrapper around iconv_open()
- * Our version adds aliases for non-standard Microsoft charsets
- * such as 'MS950', aliasing them to names like 'CP950'
- *
- * tocode Target encoding
- * fromcode Source encoding
- */
-iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode)
+#if 0
+/* This is the non-define version in case of s.b. needing to debug */
+inline void FindNextEnd (char *bptr, char *end)
{
- iconv_t ic = (iconv_t)(-1) ;
- ic = iconv_open(tocode, fromcode);
- if (ic == (iconv_t)(-1) ) {
- char alias_fromcode[64];
- if ( (strlen(fromcode) == 5) && (!strncasecmp(fromcode, "MS", 2)) ) {
- safestrncpy(alias_fromcode, fromcode, sizeof alias_fromcode);
- alias_fromcode[0] = 'C';
- alias_fromcode[1] = 'P';
- ic = iconv_open(tocode, alias_fromcode);
- }
- }
- return(ic);
-}
-
-
-
-inline char *FindNextEnd (char *bptr)
-{
- char * end;
/* Find the next ?Q? */
end = strchr(bptr + 2, '?');
if (end == NULL) return NULL;
else
/* sort of half valid encoding, try to find an end. */
end = strstr(bptr, "?=");
- return end;
+}
+#endif
+
+#define FindNextEnd(bptr, end) { \
+ end = strchr(bptr + 2, '?'); \
+ if (end != NULL) { \
+ if (((*(end + 1) == 'B') || (*(end + 1) == 'Q')) && (*(end + 2) == '?')) { \
+ end = strstr(end + 3, "?="); \
+ } else end = strstr(bptr, "?="); \
+ } \
}
/*
if (illegal_non_rfc2047_encoding) {
const char *default_header_charset = "iso-8859-1";
if ( (strcasecmp(default_header_charset, "UTF-8")) && (strcasecmp(default_header_charset, "us-ascii")) ) {
- ic = ctdl_iconv_open("UTF-8", default_header_charset);
+ ctdl_iconv_open("UTF-8", default_header_charset, &ic);
if (ic != (iconv_t)(-1) ) {
ibuf = malloc(1024);
isav = ibuf;
len = strlen(buf);
start = strstr(buf, "=?");
if (start != NULL)
- end = FindNextEnd (start);
+ FindNextEnd (start, end);
while ((start != NULL) && (end != NULL))
{
next = strstr(end, "=?");
if (next != NULL)
- nextend = FindNextEnd(next);
+ FindNextEnd(next, nextend);
if (nextend == NULL)
next = NULL;
/* Now we handle foreign character sets properly encoded
* in RFC2047 format.
*/
- while (start=strstr(buf, "=?"), end=FindNextEnd((start != NULL)? start : buf),
- ((start != NULL) && (end != NULL) && (end > start)) )
+ start = strstr(buf, "=?");
+ FindNextEnd((start != NULL)? start : buf, end);
+ while (start != NULL && end != NULL && end > start)
{
extract_token(charset, start, 1, '?', sizeof charset);
extract_token(encoding, start, 2, '?', sizeof encoding);
ibuflen = strlen(istr);
}
- ic = ctdl_iconv_open("UTF-8", charset);
+ ctdl_iconv_open("UTF-8", charset, &ic);
if (ic != (iconv_t)(-1) ) {
obuflen = 1024;
obuf = (char *) malloc(obuflen);
*/
++passes;
if (passes > 20) return;
+
+ start = strstr(buf, "=?");
+ FindNextEnd((start != NULL)? start : buf, end);
}
}
int i;
char buf[256];
char host[256], type[256];
+ int found = 0;
if (fqdn == NULL) return(hostalias_nomatch);
if (IsEmptyStr(fqdn)) return(hostalias_nomatch);
extract_token(host, buf, 0, '|', sizeof host);
extract_token(type, buf, 1, '|', sizeof type);
- if ( (!strcasecmp(type, "localhost"))
- && (!strcasecmp(fqdn, host)))
- return(hostalias_localhost);
+ found = 0;
- if ( (!strcasecmp(type, "directory"))
- && (!strcasecmp(fqdn, host)))
- return(hostalias_directory);
+ /* Process these in a specific order, in case there are multiple matches.
+ * We want directory to override masq, for example.
+ */
- if ( (!strcasecmp(type, "masqdomain"))
- && (!strcasecmp(fqdn, host)))
- return(hostalias_masq);
+ if ( (!strcasecmp(type, "masqdomain")) && (!strcasecmp(fqdn, host))) {
+ found = hostalias_masq;
+ }
+ if ( (!strcasecmp(type, "localhost")) && (!strcasecmp(fqdn, host))) {
+ found = hostalias_localhost;
+ }
+ if ( (!strcasecmp(type, "directory")) && (!strcasecmp(fqdn, host))) {
+ found = hostalias_directory;
+ }
+ if (found) return(found);
}
return(hostalias_nomatch);
processed = 1;
}
+ else if (!strcasecmp(key, "List-ID")) {
+ if (msg->cm_fields['L'] == NULL)
+ msg->cm_fields['L'] = strdup(value);
+ processed = 1;
+ }
+
else if (!strcasecmp(key, "To")) {
if (msg->cm_fields['R'] == NULL)
msg->cm_fields['R'] = strdup(value);
void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
char key[SIZ];
- CtdlLogPrintf(CTDL_DEBUG, "Dir: %s --> %s\n",
- internet_addr, citadel_addr);
if (IsDirectory(internet_addr, 0) == 0) return;
-
+ CtdlLogPrintf(CTDL_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
directory_key(key, internet_addr);
-
- cdb_store(CDB_DIRECTORY, key, strlen(key),
- citadel_addr, strlen(citadel_addr)+1 );
+ cdb_store(CDB_DIRECTORY, key, strlen(key), citadel_addr, strlen(citadel_addr)+1 );
}
void CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr) {
char key[SIZ];
+ CtdlLogPrintf(CTDL_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
directory_key(key, internet_addr);
cdb_delete(CDB_DIRECTORY, key, strlen(key) );
}
if (msg->cm_fields[field] != NULL) {
for (j=0; j<num_tokens(msg->cm_fields[field], ','); ++j) {
extract_token(addr, msg->cm_fields[field], j, ',', sizeof addr);
- utf8ify_rfc822_string(addr);
+ if (strstr(addr, "=?") != NULL)
+ utf8ify_rfc822_string(addr);
process_rfc822_addr(addr, user, node, name);
h = CtdlHostAlias(node);
if ( (h != hostalias_localhost) && (h != hostalias_directory) ) {