Files
nunuhara_xsystem4/include/system4/ex.h
T
Nunuhara Cabbage 38048ea9e6 Add exdump utility
Add tool for dumping the contents of .ex files, which contain various
structured data used by the game (tables, lists, trees).

The dump format uses a C-like syntax which should be relatively easy to
parse back in.
2020-02-17 19:51:25 -08:00

106 lines
2.0 KiB
C

/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
#ifndef SYSTEM4_EX_H
#define SYSTEM4_EX_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
enum ex_value_type {
EX_INT = 1,
EX_FLOAT = 2,
EX_STRING = 3,
EX_TABLE = 4,
EX_LIST = 5,
EX_TREE = 6
};
struct ex_value {
enum ex_value_type type;
union {
int32_t i;
float f;
struct string *s;
struct ex_table *t;
struct ex_list *list;
struct ex_tree *tree;
};
};
struct ex_field {
enum ex_value_type type;
struct string *name;
int32_t uk0;
int32_t uk1;
int32_t uk2;
uint32_t nr_subfields;
struct ex_field *subfields;
};
struct ex_table {
uint32_t nr_fields;
struct ex_field *fields;
uint32_t nr_columns;
uint32_t nr_rows;
struct ex_value **rows;
};
struct ex_list_item {
uint32_t size;
struct ex_value value;
};
struct ex_list {
uint32_t nr_items;
struct ex_list_item *items;
};
struct ex_leaf {
uint32_t size;
struct string *name;
struct ex_value value;
};
struct ex_tree {
struct string *name;
bool is_leaf;
union {
struct {
uint32_t nr_children;
struct ex_tree *children;
};
struct ex_leaf leaf;
};
};
struct ex_block {
size_t size;
struct string *name;
struct ex_value val;
};
struct ex {
uint32_t nr_blocks;
struct ex_block *blocks;
};
struct ex *ex_read(const char *path);
void ex_free(struct ex *ex);
#endif /* SYSTE4_EX_H */