From f5193b661697636247f172ff7bcbf4f8db33812a Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Thu, 24 May 2018 18:53:13 +1000 Subject: [PATCH] Attempt to fix origin line --- utils/mnetftn/mnettoftn.c | 66 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/utils/mnetftn/mnettoftn.c b/utils/mnetftn/mnettoftn.c index e62d391..2b0b639 100644 --- a/utils/mnetftn/mnettoftn.c +++ b/utils/mnetftn/mnettoftn.c @@ -261,14 +261,11 @@ int parse_config_file(char *filename) { } int isdupe(struct msg_t *msg, char *uuid) { - s_JamBase *jb; - s_JamBaseHeader jbh; - s_JamMsgHeader jmh; - s_JamSubPacket* jsp; - int areaid; int i; int z; + char buffer[PATH_MAX]; + FILE *fptr; for (i=0;iarea == areas[i]->id) { @@ -277,35 +274,26 @@ int isdupe(struct msg_t *msg, char *uuid) { } } - jb = open_jam_base(areas[areaid]->basedir); - if (!jb) { - return -1; - } - JAM_ReadMBHeader(jb, &jbh); - if (jbh.ActiveMsgs > 0) { - for (i=0;ibasedir); - if (z != 0) { - continue; - } - for (z=0;zNumFields;z++) { - if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) { - if (strncasecmp(uuid, jsp->Fields[z]->Buffer, 36) == 0) { - JAM_DelSubPacket(jsp); - JAM_CloseMB(jb); - free(jb); - return 1; - } - } - } - } + fptr = fopen(buffer, "r"); + if (!fptr) { + return 0; } - JAM_CloseMB(jb); - free(jb); - return 0; + fgets(buffer, 1024, fptr); + + while (!feof(fptr)) { + if (strncasecmp(buffer, uuid, 36) == 0) { + fclose(fptr); + return 1; + } + fgets(buffer, 1024, fptr); + } + + fclose(fptr); + + return 0; } void update_config_file_area(int areaid) { @@ -387,9 +375,9 @@ int import(char *filename) { fread(&msg, sizeof(struct msg_t), 1, fptr); - body = malloc(st.st_size - sizeof(struct msg_t) + 1); + body = malloc(st.st_size - sizeof(struct msg_t) + 1 + strlen(fido_addr)); - memset(body, 0, st.st_size - sizeof(struct msg_t) + 1); + memset(body, 0, st.st_size - sizeof(struct msg_t) + 1 + strlen(fido_addr)); fread(body, st.st_size - sizeof(struct msg_t), 1, fptr); @@ -496,6 +484,18 @@ int import(char *filename) { } + for (i=strlen(body) -2; i > 0; i--) { + if (body[i] == '(') { + sprintf(&body[i], "(%s)\r", fido_addr); + break; + } if (body[i] == '\r') { + sprintf(buffer, "\r---\r * Origin: Origin Line Missing... (%s)", fido_addr); + body = realloc(body, strlen(body) + strlen(buffer) + 1); + strcat(body, buffer); + } + } + + JAM_ClearMsgHeader(&jmh); jmh.DateWritten = msg.timedate; jmh.Attribute |= JAM_MSG_TYPEECHO;