Fixes for hubs

This commit is contained in:
Andrew Pamment 2018-05-23 15:38:00 +10:00
parent b5e5f8705b
commit 539291b54d
2 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,7 @@
MYNODE 1 MYNODE 1
IMHUB TRUE
INDIR /home/andrew/MagickaBBS/mnet/in INDIR /home/andrew/MagickaBBS/mnet/in
OUTDIR /home/andrew/MagickaBBS/mnet/out OUTDIR /home/andrew/MagickaBBS/mnet/out

View File

@ -10,6 +10,8 @@
char *baseindir = NULL; char *baseindir = NULL;
char *baseoutdir = NULL; char *baseoutdir = NULL;
int imhub = 0;
struct msgarea_t { struct msgarea_t {
int id; int id;
char *basedir; char *basedir;
@ -133,8 +135,12 @@ int parse_config_file(char *filename) {
if (buffer[0] != ';') { if (buffer[0] != ';') {
if (buffer[strlen(buffer) - 1] == '\n'){ if (buffer[strlen(buffer) - 1] == '\n'){
buffer[strlen(buffer) - 1] = '\0'; buffer[strlen(buffer) - 1] = '\0';
if (strncasecmp(buffer, "IMHUB", 5) == 0) {
if (strncasecmp(buffer, "INDIR", 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]); trimwhitespace(bufferw, 256, &buffer[6]);
baseindir = strdup(bufferw); baseindir = strdup(bufferw);
} else if (strncasecmp(buffer, "OUTDIR", 6) == 0) { } else if (strncasecmp(buffer, "OUTDIR", 6) == 0) {
@ -290,21 +296,23 @@ int import(char *filename) {
} }
} }
for (i=0;i<areas[areaid]->link_count;i++) { if (imhub) {
if (areas[areaid]->links[i] == msg.oaddr) { for (i=0;i<areas[areaid]->link_count;i++) {
continue; if (areas[areaid]->links[i] == msg.oaddr) {
}
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; 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); ret = isdupe(&msg, uuid);
if (ret == -1) { if (ret == -1) {
free(body); free(body);