]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/smtp_util.c
Removed the logging facility from citserver, use syslog instead
[citadel.git] / citadel / modules / smtp / smtp_util.c
index 103362f15bc8e41b5380ac1c62db95ce01e85e94..9e215c07455176cc298a52d337239f9c5d6c4262 100644 (file)
@@ -103,7 +103,8 @@ const char *smtp_get_Recipients(void)
  * instructions for "5" codes (permanent fatal errors) and produce/deliver
  * a "bounce" message (delivery status notification).
  */
-void smtp_do_bounce(char *instr) {
+void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) 
+{
        int i;
        int lines;
        int status;
@@ -125,7 +126,7 @@ void smtp_do_bounce(char *instr) {
        StrBuf *BounceMB;
        long omsgid = (-1);
 
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
+       syslog(LOG_DEBUG, "smtp_do_bounce() called\n");
        strcpy(bounceto, "");
        boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
        StrBufAppendPrintf(boundary, "%s_%04x%04x", config.c_fqdn, getpid(), ++seq);
@@ -194,8 +195,8 @@ void smtp_do_bounce(char *instr) {
                dsnlen = extract_token(dsn, buf, 3, '|', sizeof dsn);
                bounce_this = 0;
 
-               CtdlLogPrintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
-                       key, addr, status, dsn);
+               syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
+                      key, addr, status, dsn);
 
                if (!strcasecmp(key, "bounceto")) {
                        strcpy(bounceto, addr);
@@ -234,10 +235,15 @@ void smtp_do_bounce(char *instr) {
                StrBufAppendBufPlain(BounceMB, HKEY("Content-Disposition: inline\r\n"), 0);
                StrBufAppendBufPlain(BounceMB, HKEY("\r\n"), 0);
        
-               CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
-               CtdlOutputMsg(omsgid, MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0);
-               StrBufAppendBuf(BounceMB, CC->redirect_buffer, 0);
-               FreeStrBuf(&CC->redirect_buffer);
+               if (OMsgTxt == NULL) {
+                       CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
+                       CtdlOutputMsg(omsgid, MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0);
+                       StrBufAppendBuf(BounceMB, CC->redirect_buffer, 0);
+                       FreeStrBuf(&CC->redirect_buffer);
+               }
+               else {
+                       StrBufAppendBuf(BounceMB, OMsgTxt, 0);
+               }
        }
 
        /* Close the multipart MIME scope */
@@ -248,13 +254,13 @@ void smtp_do_bounce(char *instr) {
                free(bmsg->cm_fields['A']);
        bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
        /* Deliver the bounce if there's anything worth mentioning */
-       CtdlLogPrintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
+       syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
        if (num_bounces > 0) {
 
                /* First try the user who sent the message */
-               CtdlLogPrintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto);
+               syslog(LOG_DEBUG, "bounce to user? <%s>\n", bounceto);
                if (IsEmptyStr(bounceto)) {
-                       CtdlLogPrintf(CTDL_ERR, "No bounce address specified\n");
+                       syslog(LOG_ERR, "No bounce address specified\n");
                        bounce_msgid = (-1L);
                }
 
@@ -279,5 +285,5 @@ void smtp_do_bounce(char *instr) {
        }
        FreeStrBuf(&boundary);
        CtdlFreeMessage(bmsg);
-       CtdlLogPrintf(CTDL_DEBUG, "Done processing bounces\n");
+       syslog(LOG_DEBUG, "Done processing bounces\n");
 }