/* Copyright (c) 2016 Steven Arnow 'fdatac.h' - This file is part of libdangit This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include #include #ifndef __FDATAC_H__ #define __FDATAC_H__ enum DIFDataCEntryType { DI_FDATAC_TYPE_END, DI_FDATAC_TYPE_KEY, DI_FDATAC_TYPE_BINARY, DI_FDATAC_TYPE_STRING, DI_FDATAC_TYPE_UINT32, DI_FDATAC_TYPE_INT32, DI_FDATAC_TYPE_FLOAT, DI_FDATAC_TYPE_UINT32_ARRAY, DI_FDATAC_TYPE_INT32_ARRAY, DI_FDATAC_TYPE_FLOAT_ARRAY, #ifdef _FDATAC_INTERNAL DI_FDATAC_TYPE_UINT8, DI_FDATAC_TYPE_SIZE_SIZE_8 = 0x10, DI_FDATAC_TYPE_SIZE_SIZE_16 = 0x20, DI_FDATAC_TYPE_SIZE_SIZE_32 = 0x30, DI_FDATAC_TYPE_SIZE_SIZE_NONE = 0x0, DI_FDATAC_TYPE_HAS_CHILD = 0x40, #endif }; typedef struct DIFDataCEntry DI_FDATAC_ENTRY; struct DIFDataCEntry { enum DIFDataCEntryType type; int length; union { uint8_t *bin; char *key; char *str; uint32_t u32; int32_t i32; float f32; uint32_t *u32_arr; int32_t *i32_arr; float *f32_arr; } data; struct DIFDataCEntry *next; struct DIFDataCEntry *child; }; #ifndef _FDATAC_INTERNAL bool di_fdatac_write(const char *fname, struct DIFDataCEntry *de); struct DIFDataCEntry *di_fdatac_read(const char *fname); struct DIFDataCEntry *di_fdatac_free(struct DIFDataCEntry *entry); struct DIFDataCEntry *di_fdatac_locate_key(struct DIFDataCEntry *tree, const char *key); const char *di_fdatac_get_key_value(struct DIFDataCEntry *tree, const char *key); bool di_fdatac_verify_keyvalue(struct DIFDataCEntry *tree, const char *key, const char *value); #endif #endif