diff options
author | James <31272717+gpd-pocket-hacker@users.noreply.github.com> | 2020-11-09 16:10:37 +0000 |
---|---|---|
committer | James <31272717+gpd-pocket-hacker@users.noreply.github.com> | 2020-11-09 16:24:06 +0000 |
commit | bfac22dc79164bab10185188e12cee313ab96de9 (patch) | |
tree | 4cee4dd9631304042982ddb0a248a541d9b6af12 /rx.c | |
parent | 6a27a521f99c7babc9d000465b661f66b54ee101 (diff) | |
download | galaxy_sia-bfac22dc79164bab10185188e12cee313ab96de9.tar.gz galaxy_sia-bfac22dc79164bab10185188e12cee313ab96de9.tar.bz2 galaxy_sia-bfac22dc79164bab10185188e12cee313ab96de9.zip |
add email support
Diffstat (limited to 'rx.c')
-rw-r--r-- | rx.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -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; } |