fix for endianness

This commit is contained in:
Andrew Pamment 2018-05-26 22:31:57 +10:00
parent ec09e7a251
commit e8a7fac9b2
2 changed files with 6 additions and 4 deletions

View File

@ -317,6 +317,7 @@ int export_messages(int area) {
}
if (areas[area]->hub == mynode) {
msg_to_nl(&msg);
for (n = 0; n < areas[area]->link_count; n++) {
if (imhub) {
snprintf(buffer, PATH_MAX, "%s/%d/", baseoutdir, areas[area]->links[n]);
@ -334,14 +335,14 @@ int export_messages(int area) {
} else {
snprintf(buffer, PATH_MAX, "%s/%d/%d-%s.message", baseoutdir, hubnode, areas[area]->links[n], msgid);
}
msg.daddr = areas[area]->links[n];
msg.daddr = htonl(areas[area]->links[n]);
fptr = fopen(buffer, "wb");
if (fptr == NULL) {
fprintf(stderr, "Error creating file %s\n", buffer);
continue;
}
msg_to_nl(&msg);
fwrite(&msg, sizeof(struct msg_t), 1, fptr);
fwrite(body, strlen(body), 1, fptr);

View File

@ -297,6 +297,7 @@ int export_messages(int area) {
msg.area = areas[area]->id;
msg.type = 0;
if (areas[area]->hub == mynode) {
msg_to_nl(&msg);
for (n = 0; n < areas[area]->link_count; n++) {
if (imhub) {
snprintf(buffer, PATH_MAX, "%s/%d/", baseoutdir, areas[area]->links[n]);
@ -314,14 +315,14 @@ int export_messages(int area) {
} else {
snprintf(buffer, PATH_MAX, "%s/%d/%d-%s.message", baseoutdir, hubnode, areas[area]->links[n], msgid);
}
msg.daddr = areas[area]->links[n];
msg.daddr = htonl(areas[area]->links[n]);
fptr = fopen(buffer, "wb");
if (fptr == NULL) {
fprintf(stderr, "Error creating file %s\n", buffer);
continue;
}
msg_to_nl(&msg);
fwrite(&msg, sizeof(struct msg_t), 1, fptr);
fwrite(body, strlen(body), 1, fptr);