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
IMHUB TRUE
INDIR /home/andrew/MagickaBBS/mnet/in
OUTDIR /home/andrew/MagickaBBS/mnet/out

View File

@ -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,19 +296,21 @@ int import(char *filename) {
}
}
for (i=0;i<areas[areaid]->link_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;i<areas[areaid]->link_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);