#include #include #include #include "util.h" #include "user.h" #include "universe.h" #include "realm.h" Realm* create_realm(char* name) { Realm* self; char path[64]; scat(path, "realms/"); scat(path, name); if (create(path, OREAD, 0755) < 0) { return nil; } else { self = malloc(sizeof(Realm)); scpy(name, self->name, 32); self->max = 4; self->password = 0; self->universe = create_universe(); return self; } } Realm* parse_realm(char* name) { Realm* self; FILE* f; char path[64]; char file[64]; char buf[256]; scat(path, "realms/"); scat(path, name); scpy(path, file, 64); scat(file, "/realm"); f = fopen(file, "r"); if (fgets(buf, 256, f)) { self = malloc(sizeof(Realm)); sscanf(buf, "%hu %llu", &(self->max), &(self->password)); fclose(f); } else { return nil; } scpy(path, file, 64); scat(file, "/universe"); self->universe = parse_universe(path); return self; } Realm* find_realm(UserInfo* table, char* name) { UserInfo* u = table; int i; for (i = 0; i < 64; i++) { if (slen(u->name) > 0 && u->realm != nil && scmp(u->realm->name, name)) return u->realm; u++; } } void save_realm(Realm* self) {}