Some work on qwk tossing
This commit is contained in:
parent
63438cea6d
commit
26f1e850e2
@ -15,6 +15,17 @@ char *inbound_path;
|
||||
char *message_base_path;
|
||||
char *temp_dir;
|
||||
char *unpack_cmd;
|
||||
char *config_file;
|
||||
|
||||
int bases_exists = 0;
|
||||
|
||||
struct msg_bases {
|
||||
int baseno;
|
||||
char *path;
|
||||
};
|
||||
|
||||
struct msg_bases **msgbases;
|
||||
int msgbasecount = 0;
|
||||
|
||||
int recursive_delete(const char *dir) {
|
||||
int ret = 0;
|
||||
@ -102,7 +113,20 @@ static int handler(void* user, const char* section, const char* name,
|
||||
} else if (strcasecmp(name, "unpack command") == 0) {
|
||||
unpack_cmd = strdup(value);
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(section, "bases") == 0) {
|
||||
bases_exists = 1;
|
||||
if (msgbasecount == 0) {
|
||||
msgbases = (struct msg_bases **)malloc(sizeof(struct msg_bases *));
|
||||
} else {
|
||||
msgbases = (struct msg_bases **)realloc(msgbases, sizeof(struct msg_bases *) * (msgbasecount + 1));
|
||||
}
|
||||
|
||||
msgbases[msgbasecount] = (struct msg_bases *)malloc(sizeof(struct msg_bases));
|
||||
|
||||
msgbases[msgbasecount]->baseno = atoi(name);
|
||||
msgbases[msgbasecount]->path = strdup(value);
|
||||
msgbasecount++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -130,6 +154,7 @@ size_t trimwhitespace(char *out, size_t len, const char *str) {
|
||||
|
||||
int process_msgs_dat(char *msgsdat) {
|
||||
FILE *fptr;
|
||||
FILE *cfgfptr;
|
||||
char buffer[PATH_MAX];
|
||||
struct QwkHeader qhdr;
|
||||
int msgrecs;
|
||||
@ -148,7 +173,8 @@ int process_msgs_dat(char *msgsdat) {
|
||||
s_JamSubPacket* jsp;
|
||||
s_JamSubfield jsf;
|
||||
int z;
|
||||
|
||||
int basefound = 0;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", temp_dir, msgsdat);
|
||||
|
||||
fptr = fopen(buffer, "rb");
|
||||
@ -212,7 +238,40 @@ int process_msgs_dat(char *msgsdat) {
|
||||
|
||||
msgconf = ((qhdr.Msgareahi & 0xff) << 8) | qhdr.Msgarealo;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%d", message_base_path, msgconf);
|
||||
basefound = 0;
|
||||
for (i=0;i<msgbasecount;i++) {
|
||||
if (msgbases[i]->baseno == msgconf) {
|
||||
basefound = 1;
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", message_base_path, msgbases[i]->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!basefound) {
|
||||
|
||||
|
||||
cfgfptr = fopen(config_file, "a");
|
||||
|
||||
if (!bases_exists) {
|
||||
fprintf(cfgfptr, "[bases]\n");
|
||||
}
|
||||
|
||||
fprintf(cfgfptr, "%d = %d\n", msgconf, msgconf);
|
||||
fclose(cfgfptr);
|
||||
|
||||
if (msgbasecount == 0) {
|
||||
msgbases = (struct msg_bases **)malloc(sizeof(struct msg_bases *));
|
||||
} else {
|
||||
msgbases = (struct msg_bases **)realloc(msgbases, sizeof(struct msg_bases *) * (msgbasecount + 1));
|
||||
}
|
||||
|
||||
msgbases[msgbasecount] = (struct msg_bases *)malloc(sizeof(struct msg_bases));
|
||||
msgbases[msgbasecount]->baseno = msgconf;
|
||||
snprintf(buffer, PATH_MAX, "%d", msgconf);
|
||||
msgbases[msgbasecount]->path = strdup(buffer);
|
||||
msgbasecount++;
|
||||
snprintf(buffer, PATH_MAX, "%s/%d", message_base_path, msgconf);
|
||||
}
|
||||
|
||||
jb = open_jam_base(buffer);
|
||||
if (!jb) {
|
||||
@ -358,8 +417,10 @@ int main(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ini_parse(argv[1], handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", argv[1]);
|
||||
config_file = argv[1];
|
||||
|
||||
if (ini_parse(config_file, handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", config_file);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -391,4 +452,4 @@ int main(int argc, char **argv) {
|
||||
closedir(inb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user