|
Archeus 0.0.0
A C library and game engine that focuses on documentation
|
#include "arc/std/config.h"#include "arc/std/errno.h"#include "arc/std/hashtable.h"#include "arc/std/io.h"#include "arc/std/string.h"#include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | ARC_Config |
| struct | ARC_ConfigKey |
| struct | ARC_ConfigTypeTemplate |
| struct | ARC_ConfigDeleteKeyArgs |
Typedefs | |
| typedef struct ARC_ConfigKey | ARC_ConfigKey |
| typedef struct ARC_ConfigTypeTemplate | ARC_ConfigTypeTemplate |
| typedef struct ARC_ConfigDeleteKeyArgs | ARC_ConfigDeleteKeyArgs |
Functions | |
| int8_t | ARC_Config_KeyComp (void *key1, size_t *key1size, void *key2, size_t *key2size) |
| void | ARC_Config_CreateGroup (ARC_Config *config, ARC_String *name) |
| void | ARC_Config_DestroyGroup (ARC_HashtableNode *group, void *userdata) |
| void | ARC_Config_DestroyGroupNode (ARC_HashtableNode *node, void *userdata) |
| void | ARC_Config_RemoveKey (ARC_HashtableNode *node, void *userdata) |
| void | ARC_Config_AddKey (ARC_Config *config, ARC_String *type, ARC_ConfigKeyRead keyRead, ARC_ConfigKeyDelete keyDelete) |
| adds a usable key to ARC_Config | |
| void | ARC_Config_AddKeyCString (ARC_Config *config, const char *type, uint64_t length, ARC_ConfigKeyRead keyRead, ARC_ConfigKeyDelete keyDelete) |
| adds a key from a cstring | |
| void | ARC_Config_Create (ARC_Config **config) |
| creates ARC_Config type | |
| void | ARC_Config_Destroy (ARC_Config *config) |
| destroys ARC_Config type | |
| void | ARC_Config_SetGroup (ARC_Config *config, ARC_String *groupname) |
| sets current group in config | |
| void | ARC_Config_Get (ARC_Config *config, ARC_String *keyname, void **value) |
| get a value from a given keyname | |
| void | ARC_Config_Recurse (ARC_Config *config, ARC_String **data, ARC_String *groupstr, uint8_t *command) |
| void | ARC_Config_SetKeyGroup (ARC_Config *config, ARC_String **data, uint8_t *command) |
| void | ARC_Config_LoadFromKey (ARC_Config *config, ARC_String *keyType, ARC_String *name, ARC_String *value) |
| void | ARC_Config_UnloadFromKey (ARC_Config *config, ARC_String *keyType, ARC_String *name, ARC_String *value) |
| void | ARC_Config_GetNameAndValue (ARC_String *data, ARC_String **name, ARC_String **value) |
| void | ARC_Config_StripComment (ARC_String *original, ARC_String **stripped, ARC_String *lineStart, ARC_String *lineEnd) |
| void | ARC_Config_RemoveComments (ARC_String *original, ARC_String **commentRemoved) |
| void | ARC_Config_RunCommand (ARC_Config *config, ARC_String *command) |
| void | ARC_Config_RemoveAndRunCommands (ARC_Config *config, ARC_String *original, ARC_String **commandRemoved) |
| void | ARC_Config_FileIO (ARC_Config *config, ARC_String *path, uint8_t command) |
| handles file io for ARC_Config Type | |
| typedef struct ARC_ConfigDeleteKeyArgs ARC_ConfigDeleteKeyArgs |
| typedef struct ARC_ConfigKey ARC_ConfigKey |
| typedef struct ARC_ConfigTypeTemplate ARC_ConfigTypeTemplate |
| void ARC_Config_AddKey | ( | ARC_Config * | config, |
| ARC_String * | type, | ||
| ARC_ConfigKeyRead | keyRead, | ||
| ARC_ConfigKeyDelete | keyDelete ) |
adds a usable key to ARC_Config
| config | ARC_Config to add keys to |
| type | string of key type |
| keyRead | function for reading/creating key from string |
| keyDelete | function for deleting stored key |
Definition at line 45 of file config.c.
References ARC_Hashtable_Add(), ARC_String::data, ARC_ConfigKey::Delete, ARC_Config::keys, ARC_String::length, and ARC_ConfigKey::Read.
| void ARC_Config_AddKeyCString | ( | ARC_Config * | config, |
| const char * | type, | ||
| uint64_t | length, | ||
| ARC_ConfigKeyRead | keyRead, | ||
| ARC_ConfigKeyDelete | keyDelete ) |
adds a key from a cstring
| config | ARC_Config to add keys to |
| type | cstring of key type |
| length | length of cstring |
| keyRead | function for reading/creating key from string |
| keyDelete | function for deleting stored key |
Definition at line 55 of file config.c.
References ARC_Hashtable_Add(), ARC_ConfigKey::Delete, ARC_Config::keys, and ARC_ConfigKey::Read.
Referenced by ARC_AudioConfig_Init(), ARC_GraphicsConfig_Init(), and ARC_MathConfig_Init().
| void ARC_Config_Create | ( | ARC_Config ** | config | ) |
creates ARC_Config type
| config | ARC_Config to initialize |
Definition at line 65 of file config.c.
References ARC_Config_CreateGroup(), ARC_Config_KeyComp(), ARC_Defaults_ConfigKey_Create(), ARC_GROUP_BUCKET_SIZE, ARC_Hashtable_Create(), ARC_KEY_BUCKET_SIZE, and ARC_Config::currgroup.
| void ARC_Config_CreateGroup | ( | ARC_Config * | config, |
| ARC_String * | name ) |
Definition at line 565 of file config.c.
References ARC_Config_KeyComp(), ARC_GROUP_DATA_BUCKET_SIZE, ARC_Hashtable_Add(), ARC_Hashtable_Create(), ARC_String::data, ARC_Config::groups, and ARC_String::length.
Referenced by ARC_Config_Create(), and ARC_Config_SetGroup().
| void ARC_Config_Destroy | ( | ARC_Config * | config | ) |
destroys ARC_Config type
Definition at line 83 of file config.c.
References ARC_Config_DestroyGroup(), ARC_Config_RemoveKey(), ARC_Hashtable_Destroy(), ARC_Config::groups, and ARC_Config::keys.
| void ARC_Config_DestroyGroup | ( | ARC_HashtableNode * | group, |
| void * | userdata ) |
Definition at line 581 of file config.c.
References ARC_Config_DestroyGroupNode(), ARC_Hashtable_Destroy(), ARC_HashtableNode::data, and ARC_HashtableNode::key.
Referenced by ARC_Config_Destroy().
| void ARC_Config_DestroyGroupNode | ( | ARC_HashtableNode * | node, |
| void * | userdata ) |
Definition at line 586 of file config.c.
References ARC_ConfigDeleteKeyArgs::config, ARC_ConfigTypeTemplate::data, ARC_HashtableNode::data, ARC_ConfigTypeTemplate::Delete, ARC_HashtableNode::key, and ARC_ConfigDeleteKeyArgs::string.
Referenced by ARC_Config_DestroyGroup(), and ARC_Config_UnloadFromKey().
| void ARC_Config_FileIO | ( | ARC_Config * | config, |
| ARC_String * | path, | ||
| uint8_t | command ) |
handles file io for ARC_Config Type
| config | ARC_Config where io operations will take place |
| path | file path for io |
Definition at line 528 of file config.c.
References ARC_Config_Recurse(), ARC_Config_RemoveAndRunCommands(), ARC_Config_RemoveComments(), ARC_DEBUG_LOG_ERROR_WITH_VARIABLES, arc_errno, ARC_IO_FileToStr(), ARC_String_AppendCStringWithStrlen(), ARC_String_Destroy(), ARC_String_StripEndsWhitespace(), and ARC_String::data.
Referenced by ARC_Config_RunCommand().
| void ARC_Config_Get | ( | ARC_Config * | config, |
| ARC_String * | keyname, | ||
| void ** | value ) |
get a value from a given keyname
| config | ARC_Config to get value from |
| keyname | name of key to get from config |
| value | data retrieved from config |
Definition at line 124 of file config.c.
References ARC_Config_SetGroup(), ARC_DEBUG_LOG_ERROR, arc_errno, ARC_Hashtable_Get(), ARC_String_CopySubstring(), ARC_String_Destroy(), ARC_String_FindCString(), ARC_Config::currgroup, ARC_ConfigTypeTemplate::data, ARC_String::data, and ARC_String::length.
Referenced by ARC_Audio_Read(), ARC_Point_Read(), ARC_Rect_Read(), ARC_RectArray_Read(), ARC_RectArray_ReadRect(), ARC_SDL_Texture_Read(), ARC_Sprite_Delete(), ARC_Sprite_Read(), ARC_Spritesheet_Delete(), ARC_Spritesheet_Read(), and ARC_Spritesheet_ReadTexture().
| void ARC_Config_GetNameAndValue | ( | ARC_String * | data, |
| ARC_String ** | name, | ||
| ARC_String ** | value ) |
Definition at line 251 of file config.c.
References arc_errno, ARC_String_CopySubstring(), ARC_String_Destroy(), ARC_String_FindCString(), ARC_String_StripEndsWhitespace(), and ARC_String::length.
Referenced by ARC_Config_Recurse().
| int8_t ARC_Config_KeyComp | ( | void * | key1, |
| size_t * | key1size, | ||
| void * | key2, | ||
| size_t * | key2size ) |
Definition at line 557 of file config.c.
Referenced by ARC_Config_Create(), and ARC_Config_CreateGroup().
| void ARC_Config_LoadFromKey | ( | ARC_Config * | config, |
| ARC_String * | keyType, | ||
| ARC_String * | name, | ||
| ARC_String * | value ) |
Definition at line 211 of file config.c.
References ARC_DEBUG_LOG_ERROR_WITH_VARIABLES, arc_errno, ARC_ERRNO_DATA, ARC_Hashtable_Add(), ARC_Hashtable_Get(), ARC_Config::currgroup, ARC_ConfigTypeTemplate::data, ARC_String::data, ARC_ConfigKey::Delete, ARC_ConfigTypeTemplate::Delete, ARC_Config::keys, ARC_String::length, and ARC_ConfigKey::Read.
Referenced by ARC_Config_Recurse().
| void ARC_Config_Recurse | ( | ARC_Config * | config, |
| ARC_String ** | data, | ||
| ARC_String * | groupstr, | ||
| uint8_t * | command ) |
Definition at line 271 of file config.c.
References ARC_CONFIG_FILE_IO_LOAD, ARC_CONFIG_FILE_IO_UNLOAD, ARC_Config_GetNameAndValue(), ARC_Config_LoadFromKey(), ARC_Config_SetGroup(), ARC_Config_SetKeyGroup(), ARC_Config_UnloadFromKey(), arc_errno, ARC_ERRNO_DATA, ARC_String_CopySubstring(), ARC_String_Destroy(), ARC_String_EqualsCString(), ARC_String_FindCString(), ARC_String_StripEndsWhitespace(), ARC_Config::currgroup, and ARC_String::length.
Referenced by ARC_Config_FileIO(), and ARC_Config_SetKeyGroup().
| void ARC_Config_RemoveAndRunCommands | ( | ARC_Config * | config, |
| ARC_String * | original, | ||
| ARC_String ** | commandRemoved ) |
Definition at line 491 of file config.c.
References ARC_Config_RunCommand(), arc_errno, ARC_ERRNO_DATA, ARC_String_Copy(), ARC_String_CopySubstring(), ARC_String_Create(), ARC_String_Destroy(), ARC_String_Find(), ARC_String_RemoveSubstring(), and ARC_String::length.
Referenced by ARC_Config_FileIO().
| void ARC_Config_RemoveComments | ( | ARC_String * | original, |
| ARC_String ** | commentRemoved ) |
Definition at line 428 of file config.c.
References ARC_Config_StripComment(), arc_errno, ARC_String_Create(), and ARC_String_Destroy().
Referenced by ARC_Config_FileIO().
| void ARC_Config_RemoveKey | ( | ARC_HashtableNode * | node, |
| void * | userdata ) |
Definition at line 600 of file config.c.
References arc_errno, ARC_ERRNO_NULL, ARC_HashtableNode::data, and ARC_HashtableNode::key.
Referenced by ARC_Config_Destroy().
| void ARC_Config_RunCommand | ( | ARC_Config * | config, |
| ARC_String * | command ) |
Definition at line 457 of file config.c.
References ARC_CONFIG_FILE_IO_LOAD, ARC_CONFIG_FILE_IO_UNLOAD, ARC_Config_FileIO(), arc_errno, ARC_ERRNO_DATA, ARC_String_CopySubstring(), ARC_String_Create(), ARC_String_Destroy(), ARC_String_EqualsCString(), ARC_String_Find(), ARC_String_StripWhitespace(), and ARC_String::length.
Referenced by ARC_Config_RemoveAndRunCommands().
| void ARC_Config_SetGroup | ( | ARC_Config * | config, |
| ARC_String * | groupname ) |
sets current group in config
| config | ARC_Config we are setting current group in |
| groupname | name of group that will be set |
Definition at line 95 of file config.c.
References ARC_Config_CreateGroup(), arc_errno, ARC_Hashtable_Get(), ARC_Config::currgroup, ARC_String::data, ARC_Config::groups, and ARC_String::length.
Referenced by ARC_Config_Get(), and ARC_Config_Recurse().
| void ARC_Config_SetKeyGroup | ( | ARC_Config * | config, |
| ARC_String ** | data, | ||
| uint8_t * | command ) |
Definition at line 187 of file config.c.
References ARC_Config_Recurse(), arc_errno, ARC_ERRNO_DATA, ARC_String_CopySubstring(), ARC_String_Destroy(), ARC_String_FindCString(), ARC_String_StripEndsWhitespace(), and ARC_String::length.
Referenced by ARC_Config_Recurse().
| void ARC_Config_StripComment | ( | ARC_String * | original, |
| ARC_String ** | stripped, | ||
| ARC_String * | lineStart, | ||
| ARC_String * | lineEnd ) |
Definition at line 399 of file config.c.
References ARC_DEBUG_LOG_ERROR, arc_errno, ARC_ERRNO_DATA, ARC_String_Copy(), ARC_String_CopySubstring(), ARC_String_Destroy(), ARC_String_Find(), ARC_String_RemoveSection(), and ARC_String::length.
Referenced by ARC_Config_RemoveComments().
| void ARC_Config_UnloadFromKey | ( | ARC_Config * | config, |
| ARC_String * | keyType, | ||
| ARC_String * | name, | ||
| ARC_String * | value ) |
Definition at line 242 of file config.c.
References ARC_Config_DestroyGroupNode(), ARC_Hashtable_Remove(), ARC_Config::currgroup, ARC_String::data, and ARC_String::length.
Referenced by ARC_Config_Recurse().