summaryrefslogtreecommitdiffstats
path: root/rx.c
diff options
context:
space:
mode:
authorJames <31272717+gpd-pocket-hacker@users.noreply.github.com>2020-11-09 16:10:37 +0000
committerJames <31272717+gpd-pocket-hacker@users.noreply.github.com>2020-11-09 16:24:06 +0000
commitbfac22dc79164bab10185188e12cee313ab96de9 (patch)
tree4cee4dd9631304042982ddb0a248a541d9b6af12 /rx.c
parent6a27a521f99c7babc9d000465b661f66b54ee101 (diff)
downloadgalaxy_tools-bfac22dc79164bab10185188e12cee313ab96de9.tar.gz
galaxy_tools-bfac22dc79164bab10185188e12cee313ab96de9.tar.bz2
galaxy_tools-bfac22dc79164bab10185188e12cee313ab96de9.zip
add email support
Diffstat (limited to 'rx.c')
-rw-r--r--rx.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/rx.c b/rx.c
index 09d969f..2087f99 100644
--- a/rx.c
+++ b/rx.c
@@ -5,17 +5,34 @@
#include <syslog.h>
#include "sia.h"
+#include "email.h"
-static void msg (char *account, char *event, char *ascii, int log)
+static void msg (char *account, char *event, char *ascii, int log, const char *email)
{
+ char body[256];
+ char subject[256];
+
+
+ snprintf (body, sizeof (body) - 1, "%s %64s %s", account, event, ascii);
+ body[sizeof (body) - 1] = 0;
+
if (log)
- syslog (LOG_WARNING, "SIA: %s %64s %s", account, event, ascii);
+ syslog (LOG_WARNING, "SIA: %s", body);
+
+ printf ("%s\n", body);
+
+
+ if (!email) return;
+
+ if (strstr (body, "HEARTBT")) return;
+
+ snprintf (subject, sizeof (subject) - 1, "Galaxy SIA from %s", account);
- printf ("%s %64s %s\n", account, event, ascii);
+ send_email (email, subject, body);
}
-int new_block (int fd, SIA_Block *b, int log)
+int new_block (int fd, SIA_Block *b, int log, const char *email)
{
static int have_ascii_messages = 0; /*SIA level 3 doesn't have ascii, SIA level 4 does */
@@ -39,7 +56,7 @@ int new_block (int fd, SIA_Block *b, int log)
memcpy (event, b->data, len);
event[len] = 0;
- if (!have_ascii_messages) msg (account, event, "", log);
+ if (!have_ascii_messages) msg (account, event, "", log, email);
break;
@@ -48,7 +65,7 @@ int new_block (int fd, SIA_Block *b, int log)
memcpy (ascii, b->data, len);
ascii[len] = 0;
- msg (account, event, ascii, log);
+ msg (account, event, ascii, log, email);
break;
}