#include <iconv.h>
#if 0
-/* This is the non-define version in case of s.b. needing to debug */
+/* This is the non-define version in case it is needed for debugging */
inline void FindNextEnd (char *bptr, char *end)
{
/* Find the next ?Q? */
char encoding[16];
char istr[1024];
iconv_t ic = (iconv_t)(-1) ;
- char *ibuf; /**< Buffer of characters to be converted */
- char *obuf; /**< Buffer for converted characters */
- size_t ibuflen; /**< Length of input buffer */
- size_t obuflen; /**< Length of output buffer */
- char *isav; /**< Saved pointer to input buffer */
- char *osav; /**< Saved pointer to output buffer */
+ char *ibuf; // Buffer of characters to be converted
+ char *obuf; // Buffer for converted characters
+ size_t ibuflen; // Length of input buffer
+ size_t obuflen; // Length of output buffer
+ char *isav; // Saved pointer to input buffer
+ char *osav; // Saved pointer to output buffer
int passes = 0;
int i, len, delta;
int illegal_non_rfc2047_encoding = 0;
for (i=0; i<len; ++i) {
if ((buf[i] < 32) || (buf[i] > 126)) {
illegal_non_rfc2047_encoding = 1;
- i = len; ///< take a shortcut, it won't be more than one.
+ i = len; // take a shortcut, it won't be more than one.
}
}
if (illegal_non_rfc2047_encoding) {
ibuf = malloc(1024);
isav = ibuf;
- if (!strcasecmp(encoding, "B")) { /**< base64 */
+ if (!strcasecmp(encoding, "B")) { // base64
ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
}
- else if (!strcasecmp(encoding, "Q")) { /**< quoted-printable */
+ else if (!strcasecmp(encoding, "Q")) { // quoted-printable
size_t len;
unsigned long pos;
ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
}
else {
- strcpy(ibuf, istr); /**< unknown encoding */
+ strcpy(ibuf, istr); // unknown encoding
ibuflen = strlen(istr);
}
#endif
-
struct trynamebuf {
char buffer1[SIZ];
char buffer2[SIZ];
};
char *inetcfg = NULL;
-struct spamstrings_t *spamstrings = NULL;
-
/*
* Return nonzero if the supplied name is an alias for this host.
}
-
/*
* Determine whether a given Internet address belongs to the current user
*/
}
-
-
-
/*
* This function is self explanatory.
* (What can I say, I'm in a weird mood today...)
/*
* Aliasing for network mail.
- * (Error messages have been commented out, because this is a server.)
*/
int alias(char *name)
{ /* process alias and routing info for mail */
}
if (strcasecmp(original_name, name)) {
- syslog(LOG_INFO, "%s is being forwarded to %s\n", original_name, name);
+ syslog(LOG_INFO, "internet_addressing: %s is being forwarded to %s", original_name, name);
}
/* Change "user @ xxx" to "user" if xxx is an alias for this host */
if (name[a] == '@') {
if (CtdlHostAlias(&name[a+1]) == hostalias_localhost) {
name[a] = 0;
- syslog(LOG_INFO, "Changed to <%s>\n", name);
+ syslog(LOG_DEBUG, "internet_addressing: changed to <%s>", name);
break;
}
}
}
-
/*
* Validate recipients, count delivery types and errors, and handle aliasing
* FIXME check for dupes!!!!!
striplt(this_recp);
if (IsEmptyStr(this_recp))
break;
- syslog(LOG_DEBUG, "Evaluating recipient #%d: %s\n", num_recps, this_recp);
+ syslog(LOG_DEBUG, "internet_addressing: evaluating recipient #%d: %s", num_recps, this_recp);
++num_recps;
strcpy(org_recp, this_recp);
strcpy(ret->errormsg, "No recipients specified.");
}
- syslog(LOG_DEBUG, "validate_recipients()\n");
- syslog(LOG_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
- syslog(LOG_DEBUG, " room: %d <%s>\n", ret->num_room, ret->recp_room);
- syslog(LOG_DEBUG, " inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
- syslog(LOG_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
- syslog(LOG_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
+ syslog(LOG_DEBUG, "internet_addressing: validate_recipients() = %d local, %d room, %d SMTP, %d IGnet, %d error",
+ ret->num_local, ret->num_room, ret->num_internet, ret->num_ignet, ret->num_error
+ );
free(recipients);
return(ret);
}
if (valid->recptypes_magic != RECPTYPES_MAGIC) {
- syslog(LOG_EMERG, "Attempt to call free_recipients() on some other data type!\n");
+ syslog(LOG_ERR, "internet_addressing: attempt to call free_recipients() on some other data type!");
abort();
}
if (source == NULL) return source;
if (IsEmptyStr(source)) return source;
- syslog(LOG_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
+ syslog(LOG_DEBUG, "internet_addressing: qp_encode_email_addrs <%s>", source);
AddrPtr = malloc (sizeof (long) * nAddrPtrMax);
AddrUtf8 = malloc (sizeof (long) * nAddrPtrMax);
EncodedMaxLen = nColons * (sizeof(headerStr) + 3) + SourceLen * 3;
Encoded = (char*) malloc (EncodedMaxLen);
- for (i = 0; i < nColons; i++)
+ for (i = 0; i < nColons; i++) {
source[AddrPtr[i]++] = '\0';
+ }
/* TODO: if libidn, this might get larger*/
user = malloc(SourceLen + 1);
node = malloc(SourceLen + 1);
}
-/*
- * Return 0 if a given string fuzzy-matches a Citadel user account
- *
- * FIXME ... this needs to be updated to handle aliases.
- */
-int fuzzy_match(struct ctdluser *us, char *matchstring) {
- int a;
- long len;
-
- if ( (!strncasecmp(matchstring, "cit", 3))
- && (atol(&matchstring[3]) == us->usernum)) {
- return 0;
- }
-
- len = strlen(matchstring);
- for (a=0; !IsEmptyStr(&us->fullname[a]); ++a) {
- if (!strncasecmp(&us->fullname[a],
- matchstring, len)) {
- return 0;
- }
- }
- return -1;
-}
-
-
/*
* Unfold a multi-line field into a single line, removing multi-whitespaces
*/
}
-
/*
* Split an RFC822-style address into userid, host, and full name
*
}
-
/*
* convert_field() is a helper function for convert_internet_message().
* Given start/end positions for an rfc822 field, it converts it to a Citadel
else if (!strcasecmp(key, "From")) {
process_rfc822_addr(value, user, node, name);
- syslog(LOG_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
+ syslog(LOG_DEBUG, "internet_addressing: converted to <%s@%s> (%s)", user, node, name);
snprintf(addr, sizeof(addr), "%s@%s", user, node);
if (CM_IsEmpty(msg, eAuthor) && !IsEmptyStr(name))
CM_SetField(msg, eAuthor, name, strlen(name));
else if (!strcasecmp(key, "Message-ID")) {
if (!CM_IsEmpty(msg, emessageId)) {
- syslog(LOG_WARNING, "duplicate message id\n");
+ syslog(LOG_WARNING, "internet_addressing: duplicate message id");
}
else {
char *pValue;
}
-
struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822)
{
struct CtdlMessage *msg;
}
-
/*
* Look for a particular header field in an RFC822 message text. If the
* requested field is found, it is unfolded (if necessary) and returned to
}
-
/*****************************************************************************
* DIRECTORY MANAGEMENT FUNCTIONS *
*****************************************************************************/
}
key[keylen++] = 0;
- syslog(LOG_DEBUG, "Directory key is <%s>\n", key);
+ syslog(LOG_DEBUG, "internet_addressing: directory key is <%s>", key);
}
-
/* Return nonzero if the supplied address is in a domain we keep in
* the directory
*/
/*
* Initialize the directory database (erasing anything already there)
*/
-void CtdlDirectoryInit(void) {
+void CtdlRebuildDirectoryIndex(void) {
cdb_trunc(CDB_DIRECTORY);
}
if (IsDirectory(internet_addr, 0) == 0)
return 0;
- syslog(LOG_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
+ syslog(LOG_DEBUG, "internet_addressing: create directory entry: %s --> %s", internet_addr, citadel_addr);
directory_key(key, internet_addr);
cdb_store(CDB_DIRECTORY, key, strlen(key), citadel_addr, strlen(citadel_addr)+1 );
return 1;
int CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr) {
char key[SIZ];
- syslog(LOG_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
+ syslog(LOG_DEBUG, "internet_addressing: delete directory entry: %s --> %s", internet_addr, citadel_addr);
directory_key(key, internet_addr);
return cdb_delete(CDB_DIRECTORY, key, strlen(key) ) == 0;
}