2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.3 KiB

  1. #include "IZ_repo.h"
  2. static IZ_ConfigItem repo_config_items[] = {
  3. {
  4. IZ_CONFIG_TYPE_STRING,
  5. sizeof(char) * 64,
  6. "Database",
  7. "Path",
  8. "-d",
  9. &IZ_REPO_DEFAULT_STATE.config.path,
  10. NULL,
  11. {
  12. .serialize = NULL,
  13. .deserialize = NULL,
  14. },
  15. NULL,
  16. },
  17. IZ_CONFIG_ITEM_NULL,
  18. };
  19. void IZ_RepoBindStateToConfig(IZ_RepoState* state, IZ_ConfigItem config_items[]) {
  20. config_items[0].dest = &state->config.path;
  21. }
  22. IZ_ProcedureResult IZ_RepoSaveConfig(IZ_RepoState* state, const char* config_path) {
  23. IZ_RepoBindStateToConfig(state, repo_config_items);
  24. return IZ_ConfigSave(repo_config_items, config_path);
  25. }
  26. IZ_ProcedureResult IZ_RepoInitializeConfig(IZ_RepoState* state, const char* config_path, u8 argc, const char* argv[]) {
  27. IZ_RepoBindStateToConfig(state, repo_config_items);
  28. if (IZ_ConfigInitialize(repo_config_items, config_path, argc, argv) < 0) {
  29. return -1;
  30. }
  31. return 0;
  32. }
  33. IZ_ProcedureResult IZ_RepoInitialize(IZ_RepoState* state, const char* config_path, u8 argc, const char* argv[]) {
  34. memcpy_s(state, sizeof(IZ_RepoState), &IZ_REPO_DEFAULT_STATE, sizeof(IZ_RepoState));
  35. if (IZ_RepoInitializeConfig(state, config_path, argc, argv) < 0) {
  36. return -2;
  37. }
  38. sqlite3_open_v2(state->config.path, &state->db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
  39. return 0;
  40. }
  41. void IZ_RepoTeardown(IZ_RepoState* state) {
  42. sqlite3_close_v2(state->db);
  43. }