endianness...

This commit is contained in:
Andrew Pamment
2018-05-25 12:44:25 +10:00
parent 4068cd4315
commit 11233fa4d7
4 changed files with 56 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <arpa/inet.h>
#include "jamlib/jam.h"
char *baseindir = NULL;
@@ -23,14 +24,14 @@ struct msgarea_t {
};
struct msg_t {
int area;
uint32_t area;
char from[32];
char to[32];
char subject[64];
uint32_t timedate;
int oaddr;
int daddr;
int type;
uint32_t oaddr;
uint32_t daddr;
uint32_t type;
char reply[36];
} __attribute__ ((packed));
@@ -39,6 +40,14 @@ int area_count;
int mynode = 0;
int hubnode = 0;
void msg_to_hl(struct msg_t *msg) {
msg->area = ntohl(msg->area);
msg->timedate = ntohl(msg->timedate);
msg->oaddr = ntohl(msg->oaddr);
msg->daddr = ntohl(msg->daddr);
msg->type = ntohl(msg->type);
}
int copy_file(char *src, char *dest) {
FILE *src_file;
FILE *dest_file;
@@ -339,6 +348,8 @@ int import(char *filename) {
}
fread(&msg, sizeof(struct msg_t), 1, fptr);
msg_to_hl(&msg);
body = malloc(st.st_size - sizeof(struct msg_t) + 1);