Skip to content

Commit

Permalink
header length can now be read from header
Browse files Browse the repository at this point in the history
  • Loading branch information
ksteensig committed Jul 21, 2017
1 parent 21265cd commit 7e0af5d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/vm.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "vm.h"

void dlvm_parse_header(dlvm_module_t *module) {
uint64_t file_size;
uint8_t header_size;
uint64_t file_size = 0;
uint8_t header_size = 0;

FILE *mf = fopen(module->path->utf8.str, "rb");

Expand All @@ -14,21 +14,27 @@ void dlvm_parse_header(dlvm_module_t *module) {
return;
}

uint8_t temp_file_size[8];
fread(temp_file_size, sizeof(uint8_t), 8, mf);
module->module_size = file_size;

uint8_t temp_header_size[8];
fread(temp_header_size, sizeof(uint8_t), 8, mf);

//file_size = (uint64_t) temp_
/*
for (uint8_t i = 0; i < 7; i++) {
header_size = file_size | temp_file_size[0];

for (uint8_t i = 1; i < 8; i++) {
header_size = file_size << 8;
header_size = file_size | temp_file_size[i];
}
*/


}

dlvm_module_t *dlvm_module_init(uint8_t *path) {
dlvm_module_t *module = malloc(sizeof(dlvm_module_t));
module->path = convert_to_utf8(path, strlen(path) + 1);

dlvm_parse_header(module);

return module;
}

Expand Down

0 comments on commit 7e0af5d

Please sign in to comment.