This commit is contained in:
biglyderv 2025-03-24 20:12:37 -04:00
parent af961dd144
commit 8740f23c0a
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
6 changed files with 104 additions and 80 deletions

29
src/loader.c Normal file
View file

@ -0,0 +1,29 @@
#include "map.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_FILE_SIZE 1024 * 16
void load_elements(hashmap *m, char *table) {
FILE *fptr;
fptr = fopen(table, "r");
char *str;
while (1) {
str = calloc(MAX_FILE_SIZE, sizeof(char));
if (!fgets(str, MAX_FILE_SIZE, fptr))
break;
char *combo = strstr(str, ";");
combo[0] = '\0';
combo++;
hashmap_set(m, combo, strlen(combo) - 1, (uintptr_t)str);
}
// todo: properly free this
}