diff src/context.h @ 311:f5547e7b3a09

enable smtp verify logging
author Carl Byington <carl@five-ten-sg.com>
date Mon, 19 Sep 2016 09:11:30 -0700
parents 802e2b779ed1
children e27c24c1974a
line wrap: on
line diff
--- a/src/context.h	Sun Sep 18 18:32:37 2016 -0700
+++ b/src/context.h	Mon Sep 19 09:11:30 2016 -0700
@@ -50,23 +50,24 @@
 
 class SMTP {
     static const int maxlen = 1000;
+    static const int qlen = 20;
     int     fd;
     bool    error;
     time_t  stamp;
     char    efrom[maxlen];  // last envelope from sent on this socket
     int     pending;        // unread bytes in buffer, not including the null terminator
     char    buffer[maxlen];
-    const char  *queueid;   // last queueid for logging
+    char    queueid[qlen];  // last queueid for logging
 public:
-    SMTP(int f)             {fd = f; error = false; now(); efrom[0] = '\0'; init();};
+    SMTP(int f)             {fd = f; error = false; now(); efrom[0] = '\0'; queueid[0] = '\0'; init();};
     ~SMTP()                 {if (!error) quit(); closefd();};
-    void    init()          {pending = 0; buffer[0] = '\0'; queueid = NULL;};
+    void    init()          {pending = 0; buffer[0] = '\0';};
     void    append(const char *c)   {strncat(buffer, c, max(0, maxlen-1-(int)strlen(c)));};
     bool    err()           {return error;};
     void    now()           {stamp = time(NULL);};
     time_t  get_stamp()     {return stamp;};
     int     get_fd()        {return fd;};
-    void    set_id(const char *id)  {queueid = id;};
+    void    set_id(const char *id)  {strncpy(queueid, id, qlen); queueid[qlen-1] = '\0';};
     int     writer();
     int     reader();
     int     read_line();
@@ -79,10 +80,8 @@
     int     rcpt(const char *t);
     int     quit();
     void    closefd();
-#ifdef VERIFY_DEBUG
     void log(const char *m, int v);
     void log(const char *m, const char *v);
-#endif
 };
 
 class VERIFY {
@@ -93,7 +92,7 @@
 public:
     VERIFY(const char *h);
     void    closer();           // if the oldest socket is ancient, close it
-    SMTP    *get_connection();
+    SMTP    *get_connection(const char *queueid);
     void    put_connection(SMTP *conn);
     bool    ok(const char *queueid, const char *from, const char *to);
 };