Merge branch 'collectd-5.8'
[collectd.git] / src / notify_email.c
index c1ce2f8..6b32ad9 100644 (file)
@@ -38,19 +38,19 @@ static const char *config_keys[] = {"SMTPServer",   "SMTPPort", "SMTPUser",
 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
 
 static char **recipients;
-static int recipients_len = 0;
+static int recipients_len;
 
 static smtp_session_t session;
 static pthread_mutex_t session_lock = PTHREAD_MUTEX_INITIALIZER;
 static smtp_message_t message;
-static auth_context_t authctx = NULL;
+static auth_context_t authctx;
 
 static int smtp_port = 25;
-static char *smtp_host = NULL;
-static char *smtp_user = NULL;
-static char *smtp_password = NULL;
-static char *email_from = NULL;
-static char *email_subject = NULL;
+static char *smtp_host;
+static char *smtp_user;
+static char *smtp_password;
+static char *email_from;
+static char *email_subject;
 
 #define DEFAULT_SMTP_HOST "localhost"
 #define DEFAULT_SMTP_FROM "root@localhost"
@@ -104,8 +104,8 @@ static void monitor_cb(const char *buf, int buflen, int writing,
 static int notify_email_init(void) {
   char server[MAXSTRING];
 
-  ssnprintf(server, sizeof(server), "%s:%i",
-            (smtp_host == NULL) ? DEFAULT_SMTP_HOST : smtp_host, smtp_port);
+  snprintf(server, sizeof(server), "%s:%i",
+           (smtp_host == NULL) ? DEFAULT_SMTP_HOST : smtp_host, smtp_port);
 
   pthread_mutex_lock(&session_lock);
 
@@ -214,16 +214,16 @@ static int notify_email_notification(const notification_t *n,
   int buf_len = sizeof(buf);
   int i;
 
-  ssnprintf(severity, sizeof(severity), "%s",
-            (n->severity == NOTIF_FAILURE)
-                ? "FAILURE"
-                : ((n->severity == NOTIF_WARNING)
-                       ? "WARNING"
-                       : ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN")));
+  snprintf(severity, sizeof(severity), "%s",
+           (n->severity == NOTIF_FAILURE)
+               ? "FAILURE"
+               : ((n->severity == NOTIF_WARNING)
+                      ? "WARNING"
+                      : ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN")));
 
-  ssnprintf(subject, sizeof(subject),
-            (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject,
-            severity, n->host);
+  snprintf(subject, sizeof(subject),
+           (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject,
+           severity, n->host);
 
   localtime_r(&CDTIME_T_TO_TIME_T(n->time), &timestamp_tm);
   strftime(timestamp_str, sizeof(timestamp_str), "%Y-%m-%d %H:%M:%S",
@@ -231,15 +231,15 @@ static int notify_email_notification(const notification_t *n,
   timestamp_str[sizeof(timestamp_str) - 1] = '\0';
 
   /* Let's make RFC822 message text with \r\n EOLs */
-  ssnprintf(buf, buf_len, "MIME-Version: 1.0\r\n"
-                          "Content-Type: text/plain; charset=\"US-ASCII\"\r\n"
-                          "Content-Transfer-Encoding: 8bit\r\n"
-                          "Subject: %s\r\n"
-                          "\r\n"
-                          "%s - %s@%s\r\n"
-                          "\r\n"
-                          "Message: %s",
-            subject, timestamp_str, severity, n->host, n->message);
+  snprintf(buf, buf_len, "MIME-Version: 1.0\r\n"
+                         "Content-Type: text/plain; charset=\"US-ASCII\"\r\n"
+                         "Content-Transfer-Encoding: 8bit\r\n"
+                         "Subject: %s\r\n"
+                         "\r\n"
+                         "%s - %s@%s\r\n"
+                         "\r\n"
+                         "Message: %s",
+           subject, timestamp_str, severity, n->host, n->message);
 
   pthread_mutex_lock(&session_lock);