summaryrefslogtreecommitdiffstats
path: root/net_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net_rx.c')
-rw-r--r--net_rx.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/net_rx.c b/net_rx.c
index 15e181b..7bcc01e 100644
--- a/net_rx.c
+++ b/net_rx.c
@@ -10,13 +10,14 @@
#include "util.h"
#include "sia.h"
-extern int new_block (int fd, SIA_Block *b, int log, const char *email);
+extern int new_block (int fd, SIA_Block *b, int log, const char *email, const char *state_file, const char *mqtt_host);
extern void periodic_task (void);
+extern void dump_state (const char *);
static int usage (const char *name)
{
fprintf (stderr, "Usage:\n");
- fprintf (stderr, "%s [ -l ] [ -p listen_port ] [ -m email address]\n\n", name);
+ fprintf (stderr, "%s [ -l ] [ -p listen_port ] [ -e email address] [ -s state_file ] [ -m mqtt_host ]\n\n", name);
fprintf (stderr, "listen_port defaults to 10002\n");
return 1;
@@ -39,9 +40,11 @@ int main (int argc, char *argv[])
unsigned ptr = 0;
const char *email = NULL;
+ const char *state_file = NULL;
+ const char *mqtt_host = NULL;
- while ((opt = getopt (argc, argv, "p:lm:")) != -1) {
+ while ((opt = getopt (argc, argv, "p:le:s:m:")) != -1) {
switch (opt) {
case 'p':
port = atoi (optarg);
@@ -51,10 +54,18 @@ int main (int argc, char *argv[])
log++;
break;
- case 'm':
+ case 'e':
email = optarg;
break;
+ case 's':
+ state_file = optarg;
+ break;
+
+ case 'm':
+ mqtt_host = optarg;
+ break;
+
default: /* '?' */
return usage (argv[0]);
}
@@ -72,6 +83,8 @@ int main (int argc, char *argv[])
set_blocking (fd);
+ if (state_file)
+ dump_state (state_file);
// Epically budget TCP server
@@ -123,7 +136,7 @@ int main (int argc, char *argv[])
break;
default: /*Valid block */
- new_block (afd, &b, log, email);
+ new_block (afd, &b, log, email, state_file, mqtt_host);
ptr = 0;
break;
}