aboutsummaryrefslogtreecommitdiff
path: root/src/Config.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2021-11-18 01:17:51 +0100
committerArisotura <thetotalworm@gmail.com>2021-11-18 01:17:51 +0100
commit19ddaee13b5400b14ef3d3a6299474e7f715a948 (patch)
tree3a8b0804e91454109936db361a0ad7a9d5e1d5d5 /src/Config.cpp
parent65c2a844ac0c1d323a67044973860cdc0dcac953 (diff)
finally decouple Config from the core. baahhahahahah
Diffstat (limited to 'src/Config.cpp')
-rw-r--r--src/Config.cpp143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
deleted file mode 100644
index 0565a32..0000000
--- a/src/Config.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- Copyright 2016-2021 Arisotura
-
- This file is part of melonDS.
-
- melonDS 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 3 of the License, or (at your option)
- any later version.
-
- melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "Config.h"
-#include "Platform.h"
-
-
-namespace Config
-{
-
-const char* kConfigFile = "melonDS.ini";
-
-
-int AudioBitrate;
-
-ConfigEntry ConfigFile[] =
-{
-
- {"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
-
- {"", -1, NULL, 0, NULL, 0}
-};
-
-extern ConfigEntry PlatformConfigFile[];
-
-
-void Load()
-{
- ConfigEntry* entry = &ConfigFile[0];
- int c = 0;
- for (;;)
- {
- if (!entry->Value)
- {
- if (c > 0) break;
- entry = &PlatformConfigFile[0];
- if (!entry->Value) break;
- c++;
- }
-
- if (entry->Type == 0)
- *(int*)entry->Value = entry->DefaultInt;
- else
- {
- strncpy((char*)entry->Value, entry->DefaultStr, entry->StrLength);
- ((char*)entry->Value)[entry->StrLength] = '\0';
- }
-
- entry++;
- }
-
- FILE* f = Platform::OpenLocalFile(kConfigFile, "r");
- if (!f) return;
-
- char linebuf[1024];
- char entryname[32];
- char entryval[1024];
- while (!feof(f))
- {
- if (fgets(linebuf, 1024, f) == nullptr)
- break;
-
- int ret = sscanf(linebuf, "%31[A-Za-z_0-9]=%[^\t\r\n]", entryname, entryval);
- entryname[31] = '\0';
- if (ret < 2) continue;
-
- ConfigEntry* entry = &ConfigFile[0];
- c = 0;
- for (;;)
- {
- if (!entry->Value)
- {
- if (c > 0) break;
- entry = &PlatformConfigFile[0];
- if (!entry->Value) break;
- c++;
- }
-
- if (!strncmp(entry->Name, entryname, 32))
- {
- if (entry->Type == 0)
- *(int*)entry->Value = strtol(entryval, NULL, 10);
- else
- strncpy((char*)entry->Value, entryval, entry->StrLength);
-
- break;
- }
-
- entry++;
- }
- }
-
- fclose(f);
-}
-
-void Save()
-{
- FILE* f = Platform::OpenLocalFile(kConfigFile, "w");
- if (!f) return;
-
- ConfigEntry* entry = &ConfigFile[0];
- int c = 0;
- for (;;)
- {
- if (!entry->Value)
- {
- if (c > 0) break;
- entry = &PlatformConfigFile[0];
- if (!entry->Value) break;
- c++;
- }
-
- if (entry->Type == 0)
- fprintf(f, "%s=%d\r\n", entry->Name, *(int*)entry->Value);
- else
- fprintf(f, "%s=%s\r\n", entry->Name, (char*)entry->Value);
-
- entry++;
- }
-
- fclose(f);
-}
-
-
-}