mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-23 04:12:02 +00:00
Merge branch 'master' into emunand_dev
This commit is contained in:
commit
4c4f037361
3 changed files with 21 additions and 30 deletions
|
@ -13,15 +13,10 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdlib>
|
#pragma once
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <atmosphere.h>
|
|
||||||
#include <stratosphere.hpp>
|
|
||||||
|
|
||||||
constexpr u32 BpcMitmPriority = 32;
|
constexpr u32 BpcMitmPriority = 32;
|
||||||
constexpr u32 BpcMitmStackSize = 0x8000;
|
constexpr u32 BpcMitmStackSize = 0x8000;
|
||||||
|
|
|
@ -153,8 +153,8 @@ static Result ParseValue(const char *name, const char *key, const char *val_tup)
|
||||||
if (delimiter == NULL || value_len == 0 || type_len == 0) {
|
if (delimiter == NULL || value_len == 0 || type_len == 0) {
|
||||||
return ResultSettingsItemValueInvalidFormat;
|
return ResultSettingsItemValueInvalidFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string kv = std::string(name) + "!" + std::string(key);
|
std::string kv = std::string(name).append("!").append(key);
|
||||||
SettingsItemValue value;
|
SettingsItemValue value;
|
||||||
|
|
||||||
if (strncasecmp(type, "str", type_len) == 0 || strncasecmp(type, "string", type_len) == 0) {
|
if (strncasecmp(type, "str", type_len) == 0 || strncasecmp(type, "string", type_len) == 0) {
|
||||||
|
@ -242,7 +242,7 @@ static int SettingsItemIniHandler(void *user, const char *name, const char *key,
|
||||||
return R_SUCCEEDED(rc) ? 1 : 0;
|
return R_SUCCEEDED(rc) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsItemManager::LoadConfiguration() {
|
void SettingsItemManager::LoadConfiguration() {
|
||||||
/* Open file. */
|
/* Open file. */
|
||||||
FsFile config_file;
|
FsFile config_file;
|
||||||
Result rc = Utils::OpenSdFile("/atmosphere/system_settings.ini", FS_OPEN_READ, &config_file);
|
Result rc = Utils::OpenSdFile("/atmosphere/system_settings.ini", FS_OPEN_READ, &config_file);
|
||||||
|
@ -252,24 +252,20 @@ void SettingsItemManager::LoadConfiguration() {
|
||||||
ON_SCOPE_EXIT {
|
ON_SCOPE_EXIT {
|
||||||
fsFileClose(&config_file);
|
fsFileClose(&config_file);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Allocate buffer. */
|
/* Allocate buffer. */
|
||||||
char *config_buf = new char[0x10000];
|
std::string config_buf(0xFFFF, '\0');
|
||||||
std::memset(config_buf, 0, 0x10000);
|
|
||||||
ON_SCOPE_EXIT {
|
|
||||||
delete[] config_buf;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Read from file. */
|
/* Read from file. */
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
size_t actual_size;
|
size_t actual_size;
|
||||||
rc = fsFileRead(&config_file, 0, config_buf, 0xFFFF, FS_READOPTION_NONE, &actual_size);
|
rc = fsFileRead(&config_file, 0, config_buf.data(), config_buf.size(), FS_READOPTION_NONE, &actual_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
ini_parse_string(config_buf, SettingsItemIniHandler, &rc);
|
ini_parse_string(config_buf.c_str(), SettingsItemIniHandler, &rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report error if we encountered one. */
|
/* Report error if we encountered one. */
|
||||||
if (R_FAILED(rc) && !g_threw_fatal) {
|
if (R_FAILED(rc) && !g_threw_fatal) {
|
||||||
g_threw_fatal = true;
|
g_threw_fatal = true;
|
||||||
|
@ -279,31 +275,31 @@ void SettingsItemManager::LoadConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64 *out_size) {
|
Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64 *out_size) {
|
||||||
std::string kv = std::string(name) + "!" + std::string(key);
|
const std::string kv = std::string(name).append("!").append(key);
|
||||||
|
|
||||||
auto it = g_settings_items.find(kv);
|
auto it = g_settings_items.find(kv);
|
||||||
if (it == g_settings_items.end()) {
|
if (it == g_settings_items.end()) {
|
||||||
return ResultSettingsItemNotFound;
|
return ResultSettingsItemNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_size = it->second.size;
|
*out_size = it->second.size;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SettingsItemManager::GetValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) {
|
Result SettingsItemManager::GetValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) {
|
||||||
std::string kv = std::string(name) + "!" + std::string(key);
|
const std::string kv = std::string(name).append("!").append(key);
|
||||||
|
|
||||||
auto it = g_settings_items.find(kv);
|
auto it = g_settings_items.find(kv);
|
||||||
if (it == g_settings_items.end()) {
|
if (it == g_settings_items.end()) {
|
||||||
return ResultSettingsItemNotFound;
|
return ResultSettingsItemNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t copy_size = it->second.size;
|
size_t copy_size = it->second.size;
|
||||||
if (max_size < copy_size) {
|
if (max_size < copy_size) {
|
||||||
copy_size = max_size;
|
copy_size = max_size;
|
||||||
}
|
}
|
||||||
*out_size = copy_size;
|
*out_size = copy_size;
|
||||||
|
|
||||||
memcpy(out, it->second.data, copy_size);
|
memcpy(out, it->second.data, copy_size);
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ Result DebugMonitorService::TargetIO_FileRead(InBuffer<u64> hnd, OutBuffer<u8, B
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t read = 0;
|
size_t read = 0;
|
||||||
rc = fsFileRead(&f, offset, out_data.buffer, out_data.num_elements, &read);
|
rc = fsFileRead(&f, offset, out_data.buffer, out_data.num_elements, FS_READOPTION_NONE, &read);
|
||||||
out_read.SetValue(static_cast<u32>(read));
|
out_read.SetValue(static_cast<u32>(read));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ Result DebugMonitorService::TargetIO_FileWrite(InBuffer<u64> hnd, InBuffer<u8, B
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = fsFileWrite(&f, offset, data.buffer, data.num_elements);
|
rc = fsFileWrite(&f, offset, data.buffer, data.num_elements, FS_WRITEOPTION_NONE);
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
out_written.SetValue(data.num_elements);
|
out_written.SetValue(data.num_elements);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue