/*
* Aliasing for network mail.
*/
-int alias(char *name)
-{ /* process alias and routing info for mail */
+int alias(char *name) { /* process alias and routing info for mail */
int a;
char aaa[SIZ];
int at = 0;
}
-char *qp_encode_email_addrs(char *source)
-{
+char *qp_encode_email_addrs(char *source) {
char *user, *node, *name;
const char headerStr[] = "=?UTF-8?Q?";
char *Encoded;
free (AddrPtr), AddrPtr = ptr;
ptr = (long *) malloc(sizeof (long) * nAddrPtrMax * 2);
- memset(&ptr[nAddrPtrMax], 0,
- sizeof (long) * nAddrPtrMax);
+ memset(&ptr[nAddrPtrMax], 0, sizeof (long) * nAddrPtrMax);
memcpy (ptr, AddrUtf8, sizeof (long) * nAddrPtrMax);
free (AddrUtf8), AddrUtf8 = ptr;
nAddrPtrMax *= 2;
}
- if (((unsigned char) source[i] < 32) ||
- ((unsigned char) source[i] > 126)) {
+ if (((unsigned char) source[i] < 32) || ((unsigned char) source[i] > 126)) {
need_to_encode = 1;
AddrUtf8[nColons] = 1;
}
- if (source[i] == '"')
+ if (source[i] == '"') {
InQuotes = !InQuotes;
+ }
if (!InQuotes && source[i] == ',') {
AddrPtr[nColons] = i;
nColons++;
for (i = 0; i < nColons && nPtr != NULL; i++) {
nmax = EncodedMaxLen - (nPtr - Encoded);
if (AddrUtf8[i]) {
- process_rfc822_addr(&source[AddrPtr[i]],
- user,
- node,
- name);
+ process_rfc822_addr(&source[AddrPtr[i]], user, node, name);
/* TODO: libIDN here ! */
if (IsEmptyStr(name)) {
- n = snprintf(nPtr, nmax,
- (i==0)?"%s@%s" : ",%s@%s",
- user, node);
+ n = snprintf(nPtr, nmax, (i==0)?"%s@%s" : ",%s@%s", user, node);
}
else {
EncodedName = rfc2047encode(name, strlen(name));
- n = snprintf(nPtr, nmax,
- (i==0)?"%s <%s@%s>" : ",%s <%s@%s>",
- EncodedName, user, node);
+ n = snprintf(nPtr, nmax, (i==0)?"%s <%s@%s>" : ",%s <%s@%s>", EncodedName, user, node);
free(EncodedName);
}
}
else {
- n = snprintf(nPtr, nmax,
- (i==0)?"%s" : ",%s",
- &source[AddrPtr[i]]);
+ n = snprintf(nPtr, nmax, (i==0)?"%s" : ",%s", &source[AddrPtr[i]]);
}
if (n > 0 )
nPtr += n;
else {
if (*sField=='\"') quote = 1 - quote;
if (!quote) {
- if (isspace(*sField))
- {
+ if (isspace(*sField)) {
*pField = ' ';
pField++;
sField++;
* Split an RFC822-style address into userid, host, and full name
*
*/
-void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
-{
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) {
int a;
strcpy(user, "");
) {
strcpy(node, CtdlGetConfigStr("c_nodename"));
}
-
else {
/* strip anything to the left of a @ */
void listdeliver_do_msg(long msgnum, void *userdata) {
struct lddata *ld = (struct lddata *) userdata;
- ld->msgnum = msgnum;
+ if (!ld) return;
char buf[SIZ];
- struct CtdlMessage *TheMessage = CtdlFetchMessage(msgnum, 1);
+ ld->msgnum = msgnum;
+ if (msgnum <= 0) return;
- int config_lines = num_tokens(ld->netconf, '\n');
- for (int i=0; i<config_lines; ++i) {
- extract_token(buf, ld->netconf, i, '\n', sizeof buf);
- if ( (!strncasecmp(buf, "listrecp|", 9)) || (!strncasecmp(buf, "digestrecp|", 11)) ) {
- syslog(LOG_DEBUG, "\033[32mDeliver %ld to %s\033[0m", msgnum, buf);
- // FIXME
+ struct CtdlMessage *TheMessage = CtdlFetchMessage(msgnum, 1);
+ if (!TheMessage) return;
+
+ char *recipients = malloc(strlen(ld->netconf));
+ if (recipients) {
+ recipients[0] = 0;
+
+ int config_lines = num_tokens(ld->netconf, '\n');
+ for (int i=0; i<config_lines; ++i) {
+ extract_token(buf, ld->netconf, i, '\n', sizeof buf);
+ if (!strncasecmp(buf, "listrecp|", 9)) {
+ if (recipients[0] != 0) {
+ strcat(recipients, ",");
+ }
+ strcat(recipients, &buf[9]);
+ }
+ if (!strncasecmp(buf, "digestrecp|", 11)) {
+ if (recipients[0] != 0) {
+ strcat(recipients, ",");
+ }
+ strcat(recipients, &buf[11]);
+ }
}
+ syslog(LOG_DEBUG, "\033[33m%s\033[0m", recipients);
+ free(recipients);
}
CM_Free(TheMessage);
}