From 539291b54d687f9714eb5139e55608f9cf76cfd6 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 23 May 2018 15:38:00 +1000 Subject: [PATCH] Fixes for hubs --- dist/config/mnet.cfg.example | 2 ++ utils/mnettoss/mnettoss.c | 34 +++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dist/config/mnet.cfg.example b/dist/config/mnet.cfg.example index a052d8c..2dce938 100644 --- a/dist/config/mnet.cfg.example +++ b/dist/config/mnet.cfg.example @@ -1,5 +1,7 @@ MYNODE 1 +IMHUB TRUE + INDIR /home/andrew/MagickaBBS/mnet/in OUTDIR /home/andrew/MagickaBBS/mnet/out diff --git a/utils/mnettoss/mnettoss.c b/utils/mnettoss/mnettoss.c index 31eadc3..df0e977 100644 --- a/utils/mnettoss/mnettoss.c +++ b/utils/mnettoss/mnettoss.c @@ -10,6 +10,8 @@ char *baseindir = NULL; char *baseoutdir = NULL; +int imhub = 0; + struct msgarea_t { int id; char *basedir; @@ -133,8 +135,12 @@ int parse_config_file(char *filename) { if (buffer[0] != ';') { if (buffer[strlen(buffer) - 1] == '\n'){ buffer[strlen(buffer) - 1] = '\0'; - - if (strncasecmp(buffer, "INDIR", 5) == 0) { + if (strncasecmp(buffer, "IMHUB", 5) == 0) { + trimwhitespace(bufferw, 256, &buffer[6]); + if (strcasecmp(bufferw, "TRUE") == 0) { + imhub = 1; + } + } else if (strncasecmp(buffer, "INDIR", 5) == 0) { trimwhitespace(bufferw, 256, &buffer[6]); baseindir = strdup(bufferw); } else if (strncasecmp(buffer, "OUTDIR", 6) == 0) { @@ -290,21 +296,23 @@ int import(char *filename) { } } - for (i=0;ilink_count;i++) { - if (areas[areaid]->links[i] == msg.oaddr) { - continue; - } - snprintf(buffer2, PATH_MAX, "%s/%d/", baseoutdir, areas[areaid]->links[i]); - if (stat(buffer2, &st) != 0) { - if (mkdir(buffer2, 0755) != 0) { - fprintf(stderr, "Error making directory %s\n", buffer2); + if (imhub) { + for (i=0;ilink_count;i++) { + if (areas[areaid]->links[i] == msg.oaddr) { continue; } + snprintf(buffer2, PATH_MAX, "%s/%d/", baseoutdir, areas[areaid]->links[i]); + if (stat(buffer2, &st) != 0) { + if (mkdir(buffer2, 0755) != 0) { + fprintf(stderr, "Error making directory %s\n", buffer2); + continue; + } + } + snprintf(buffer2, PATH_MAX, "%s/%d/%s", baseoutdir, areas[areaid]->links[i], filename); + copy_file(buffer, buffer2); } - snprintf(buffer2, PATH_MAX, "%s/%d/%s", baseoutdir, areas[areaid]->links[i], filename); - copy_file(buffer, buffer2); } - + ret = isdupe(&msg, uuid); if (ret == -1) { free(body);