Attempt to fix origin line

This commit is contained in:
Andrew Pamment 2018-05-24 18:53:13 +10:00
parent d03cc0b023
commit f5193b6616

View File

@ -261,14 +261,11 @@ int parse_config_file(char *filename) {
} }
int isdupe(struct msg_t *msg, char *uuid) { int isdupe(struct msg_t *msg, char *uuid) {
s_JamBase *jb;
s_JamBaseHeader jbh;
s_JamMsgHeader jmh;
s_JamSubPacket* jsp;
int areaid; int areaid;
int i; int i;
int z; int z;
char buffer[PATH_MAX];
FILE *fptr;
for (i=0;i<area_count;i++) { for (i=0;i<area_count;i++) {
if (msg->area == areas[i]->id) { if (msg->area == areas[i]->id) {
@ -277,33 +274,24 @@ int isdupe(struct msg_t *msg, char *uuid) {
} }
} }
jb = open_jam_base(areas[areaid]->basedir); snprintf(buffer, PATH_MAX, "%s.msgids", areas[areaid]->basedir);
if (!jb) {
return -1;
}
JAM_ReadMBHeader(jb, &jbh);
if (jbh.ActiveMsgs > 0) {
for (i=0;i<jbh.ActiveMsgs;i++) {
memset(&jmh, 0, sizeof(s_JamMsgHeader));
z = JAM_ReadMsgHeader(jb, i, &jmh, &jsp);
if (z != 0) { fptr = fopen(buffer, "r");
continue; if (!fptr) {
return 0;
} }
for (z=0;z<jsp->NumFields;z++) {
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) { fgets(buffer, 1024, fptr);
if (strncasecmp(uuid, jsp->Fields[z]->Buffer, 36) == 0) {
JAM_DelSubPacket(jsp); while (!feof(fptr)) {
JAM_CloseMB(jb); if (strncasecmp(buffer, uuid, 36) == 0) {
free(jb); fclose(fptr);
return 1; return 1;
} }
fgets(buffer, 1024, fptr);
} }
}
} fclose(fptr);
}
JAM_CloseMB(jb);
free(jb);
return 0; return 0;
} }
@ -387,9 +375,9 @@ int import(char *filename) {
fread(&msg, sizeof(struct msg_t), 1, fptr); 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); 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); JAM_ClearMsgHeader(&jmh);
jmh.DateWritten = msg.timedate; jmh.DateWritten = msg.timedate;
jmh.Attribute |= JAM_MSG_TYPEECHO; jmh.Attribute |= JAM_MSG_TYPEECHO;