mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Move rjsonwriter helper inline functions over to separate file rjson_helpers.h
This commit is contained in:
parent
5b56ff145f
commit
e4bff7c12c
324
core_info.c
324
core_info.c
@ -860,21 +860,21 @@ static bool core_info_cache_write(core_info_cache_list_t *list, const char *info
|
||||
rjsonwriter_set_options(writer, RJSONWRITER_OPTION_SKIP_WHITESPACE);
|
||||
#endif
|
||||
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, CORE_INFO_CACHE_VERSION);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "items");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
for (i = 0; i < list->length; i++)
|
||||
{
|
||||
@ -885,273 +885,291 @@ static bool core_info_cache_write(core_info_cache_list_t *list, const char *info
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "display_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->display_name);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "display_version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->display_version);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "core_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->core_name);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "system_manufacturer");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->system_manufacturer);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "systemname");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->systemname);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "system_id");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->system_id);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "supported_extensions");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->supported_extensions);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "authors");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->authors);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "permissions");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->permissions);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "licenses");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->licenses);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "categories");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->categories);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "databases");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->databases);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "notes");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->notes);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "required_hw_api");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->required_hw_api);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "description");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->description);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
if (info->firmware_count > 0)
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "firmware");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
for (j = 0; j < info->firmware_count; j++)
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 8);
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 10);
|
||||
rjsonwriter_add_string(writer, "path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->firmware[j].path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 10);
|
||||
rjsonwriter_add_string(writer, "desc");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->firmware[j].desc);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 10);
|
||||
rjsonwriter_add_string(writer, "optional");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->firmware[j].optional);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->firmware[j].optional;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 8);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
|
||||
if (j < info->firmware_count - 1)
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "core_file_id");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 8);
|
||||
rjsonwriter_add_string(writer, "str");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, info->core_file_id.str);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 8);
|
||||
rjsonwriter_add_string(writer, "hash");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, info->core_file_id.hash);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", info->core_file_id.hash);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "firmware_count");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, info->firmware_count);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", info->firmware_count);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "savestate_support_level");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, info->savestate_support_level);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", info->savestate_support_level);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "has_info");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->has_info);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->has_info;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "supports_no_game");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->supports_no_game);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->supports_no_game;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "single_purpose");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->single_purpose);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->single_purpose;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "database_match_archive_member");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->database_match_archive_member);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->database_match_archive_member;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "is_experimental");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, info->is_experimental);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = info->is_experimental;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_free(writer);
|
||||
|
||||
RARCH_LOG("[Core Info] Wrote to cache file: %s\n", file_path);
|
||||
|
26
deps/discord-rpc/src/serialization.h
vendored
26
deps/discord-rpc/src/serialization.h
vendored
@ -54,7 +54,8 @@ class JsonWriter
|
||||
{
|
||||
JsonWriter* self = (JsonWriter*)user_data;
|
||||
size_t buf_remain = (self->buf_cap - self->buf_len);
|
||||
if ((size_t)inlen > buf_remain) inlen = (int)buf_remain;
|
||||
if ((size_t)inlen > buf_remain)
|
||||
inlen = (int)buf_remain;
|
||||
memcpy(self->buf + self->buf_len, inbuf, inlen);
|
||||
self->buf_len += inlen;
|
||||
self->buf[self->buf_len - (self->buf_len == self->buf_cap ? 1 : 0)] = '\0';
|
||||
@ -82,32 +83,33 @@ class JsonWriter
|
||||
|
||||
void WriteComma()
|
||||
{
|
||||
if (!need_comma) return;
|
||||
rjsonwriter_add_comma(writer);
|
||||
if (!need_comma)
|
||||
return;
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
need_comma = false;
|
||||
}
|
||||
|
||||
void StartObject()
|
||||
{
|
||||
WriteComma();
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
}
|
||||
|
||||
void StartArray()
|
||||
{
|
||||
WriteComma();
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
}
|
||||
|
||||
void EndObject()
|
||||
{
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
void EndArray()
|
||||
{
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
@ -115,7 +117,7 @@ class JsonWriter
|
||||
{
|
||||
WriteComma();
|
||||
rjsonwriter_add_string(writer, key);
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
}
|
||||
|
||||
void String(const char* val)
|
||||
@ -125,10 +127,10 @@ class JsonWriter
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
void Int(int val)
|
||||
void Int(int value)
|
||||
{
|
||||
WriteComma();
|
||||
rjsonwriter_add_int(writer, val);
|
||||
rjsonwriter_rawf(writer, "%d", value);
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
@ -155,10 +157,10 @@ class JsonWriter
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
void Bool(bool val)
|
||||
void Bool(bool value)
|
||||
{
|
||||
WriteComma();
|
||||
rjsonwriter_add_bool(writer, val);
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
need_comma = true;
|
||||
}
|
||||
};
|
||||
|
@ -370,12 +370,10 @@ bool disk_index_file_save(disk_index_file_t *disk_index_file)
|
||||
file_path);
|
||||
|
||||
/* Attempt to open disk index file */
|
||||
file = filestream_open(
|
||||
if (!(file = filestream_open(
|
||||
file_path,
|
||||
RETRO_VFS_FILE_ACCESS_WRITE,
|
||||
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
RETRO_VFS_FILE_ACCESS_HINT_NONE)))
|
||||
{
|
||||
RARCH_ERR(
|
||||
"[disk index file] Failed to open disk index file: %s\n",
|
||||
@ -384,47 +382,45 @@ bool disk_index_file_save(disk_index_file_t *disk_index_file)
|
||||
}
|
||||
|
||||
/* Initialise JSON writer */
|
||||
writer = rjsonwriter_open_rfile(file);
|
||||
|
||||
if (!writer)
|
||||
if (!(writer = rjsonwriter_open_rfile(file)))
|
||||
{
|
||||
RARCH_ERR("[disk index file] Failed to create JSON writer.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Write output file */
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Version entry */
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, "1.0");
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > image index entry */
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "image_index");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, disk_index_file->image_index);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", disk_index_file->image_index);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > image path entry */
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "image_path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, disk_index_file->image_path);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Finalise */
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* Free JSON writer */
|
||||
if (!rjsonwriter_free(writer))
|
||||
|
@ -24,7 +24,6 @@
|
||||
#define __LIBRETRO_SDK_FORMAT_RJSON_H__
|
||||
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_inline.h> /* INLINE */
|
||||
#include <boolean.h> /* bool */
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
@ -224,50 +223,10 @@ void rjsonwriter_rawf(rjsonwriter_t *writer, const char *fmt, ...);
|
||||
void rjsonwriter_add_string(rjsonwriter_t *writer, const char *value);
|
||||
void rjsonwriter_add_string_len(rjsonwriter_t *writer, const char *value, int len);
|
||||
|
||||
/* Add a signed or unsigned integer or a double number */
|
||||
static INLINE void rjsonwriter_add_int(rjsonwriter_t *writer, int value)
|
||||
{ rjsonwriter_rawf(writer, "%d", value); }
|
||||
|
||||
static INLINE void rjsonwriter_add_unsigned(rjsonwriter_t *writer, unsigned value)
|
||||
{ rjsonwriter_rawf(writer, "%u", value); }
|
||||
|
||||
void rjsonwriter_add_double(rjsonwriter_t *writer, double value);
|
||||
|
||||
/* Functions to add JSON token characters */
|
||||
static INLINE void rjsonwriter_add_start_object(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "{", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_end_object(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "}", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_start_array(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "[", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_end_array(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "]", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_colon(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, ":", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_comma(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, ",", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_bool(rjsonwriter_t *writer, bool value)
|
||||
{ rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5)); }
|
||||
|
||||
/* Functions to add whitespace characters */
|
||||
/* These do nothing with the option RJSONWRITER_OPTION_SKIP_WHITESPACE */
|
||||
static INLINE void rjsonwriter_add_newline(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "\n", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_space(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, " ", 1); }
|
||||
|
||||
void rjsonwriter_add_spaces(rjsonwriter_t *writer, int count);
|
||||
|
||||
static INLINE void rjsonwriter_add_tab(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "\t", 1); }
|
||||
|
||||
void rjsonwriter_add_tabs(rjsonwriter_t *writer, int count);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
76
libretro-common/include/formats/rjson_helpers.h
Normal file
76
libretro-common/include/formats/rjson_helpers.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* Copyright (C) 2010-2020 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (rjson.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __LIBRETRO_SDK_FORMAT_RJSON_HELPERS_H__
|
||||
#define __LIBRETRO_SDK_FORMAT_RJSON_HELPERS_H__
|
||||
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_inline.h> /* INLINE */
|
||||
#include <boolean.h> /* bool */
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
/* Functions to add JSON token characters */
|
||||
static INLINE void rjsonwriter_add_start_object(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "{", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_end_object(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "}", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_start_array(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "[", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_end_array(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "]", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_colon(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, ":", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_comma(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, ",", 1); }
|
||||
|
||||
/* Functions to add whitespace characters */
|
||||
/* These do nothing with the option RJSONWRITER_OPTION_SKIP_WHITESPACE */
|
||||
static INLINE void rjsonwriter_add_newline(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "\n", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_space(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, " ", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_tab(rjsonwriter_t *writer)
|
||||
{ rjsonwriter_raw(writer, "\t", 1); }
|
||||
|
||||
static INLINE void rjsonwriter_add_unsigned(rjsonwriter_t *writer, unsigned value)
|
||||
{ rjsonwriter_rawf(writer, "%u", value); }
|
||||
|
||||
/* Add a signed or unsigned integer or a double number */
|
||||
static INLINE void rjsonwriter_add_int(rjsonwriter_t *writer, int value)
|
||||
{ rjsonwriter_rawf(writer, "%d", value); }
|
||||
|
||||
static INLINE void rjsonwriter_add_bool(rjsonwriter_t *writer, bool value)
|
||||
{ rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5)); }
|
||||
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
399
playlist.c
399
playlist.c
@ -1506,129 +1506,129 @@ void playlist_write_runtime_file(playlist_t *playlist)
|
||||
goto end;
|
||||
}
|
||||
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, "1.0");
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "items");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
for (i = 0, len = RBUF_LEN(playlist->entries); i < len; i++)
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "core_path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].core_path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "runtime_hours");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].runtime_hours);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].runtime_hours);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "runtime_minutes");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].runtime_minutes);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].runtime_minutes);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "runtime_seconds");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].runtime_seconds);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].runtime_seconds);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_year");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_year);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_year);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_month");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_month);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_month);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_day");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_day);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_day);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_hour");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_hour);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_hour);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_minute");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_minute);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_minute);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "last_played_second");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_unsigned(writer, playlist->entries[i].last_played_second);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%u", playlist->entries[i].last_played_second);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
|
||||
if (i < len - 1)
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_free(writer);
|
||||
|
||||
playlist->modified = false;
|
||||
@ -1730,216 +1730,225 @@ void playlist_write_file(playlist_t *playlist)
|
||||
rjsonwriter_set_options(writer, RJSONWRITER_OPTION_SKIP_WHITESPACE);
|
||||
}
|
||||
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, "1.5");
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "default_core_path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->default_core_path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "default_core_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->default_core_name);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
if (!string_is_empty(playlist->base_content_directory))
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "base_content_directory");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->base_content_directory);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "label_display_mode");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_int(writer, (int)playlist->label_display_mode);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%d", (int)playlist->label_display_mode);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "right_thumbnail_mode");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_int(writer, (int)playlist->right_thumbnail_mode);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%d", (int)playlist->right_thumbnail_mode);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "left_thumbnail_mode");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_int(writer, (int)playlist->left_thumbnail_mode);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%d", (int)playlist->left_thumbnail_mode);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "sort_mode");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_int(writer, (int)playlist->sort_mode);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%d", (int)playlist->sort_mode);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
if (!string_is_empty(playlist->scan_record.content_dir))
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_content_dir");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->scan_record.content_dir);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_file_exts");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->scan_record.file_exts);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_dat_file_path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->scan_record.dat_file_path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_search_recursively");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, playlist->scan_record.search_recursively);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = playlist->scan_record.search_recursively;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_search_archives");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, playlist->scan_record.search_archives);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = playlist->scan_record.search_archives;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "scan_filter_dat_content");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_bool(writer, playlist->scan_record.filter_dat_content);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
{
|
||||
bool value = playlist->scan_record.filter_dat_content;
|
||||
rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5));
|
||||
}
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "items");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
for (i = 0, len = RBUF_LEN(playlist->entries); i < len; i++)
|
||||
{
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
if (playlist->entries[i].entry_slot)
|
||||
{
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "entry_slot");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_int(writer, (int)playlist->entries[i].entry_slot);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_rawf(writer, "%d", (int)playlist->entries[i].entry_slot);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "label");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].label);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "core_path");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].core_path);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "core_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].core_name);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "crc32");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].crc32);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "db_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].db_name);
|
||||
|
||||
if (!string_is_empty(playlist->entries[i].subsystem_ident))
|
||||
{
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "subsystem_ident");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].subsystem_ident);
|
||||
}
|
||||
|
||||
if (!string_is_empty(playlist->entries[i].subsystem_name))
|
||||
{
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "subsystem_name");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, playlist->entries[i].subsystem_name);
|
||||
}
|
||||
|
||||
@ -1948,14 +1957,14 @@ void playlist_write_file(playlist_t *playlist)
|
||||
{
|
||||
unsigned j;
|
||||
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_string(writer, "subsystem_roms");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_add_start_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_raw(writer, "[", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
for (j = 0; j < playlist->entries[i].subsystem_roms->size; j++)
|
||||
{
|
||||
@ -1968,32 +1977,32 @@ void playlist_write_file(playlist_t *playlist)
|
||||
|
||||
if (j < playlist->entries[i].subsystem_roms->size - 1)
|
||||
{
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_add_spaces(writer, 6);
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
rjsonwriter_add_spaces(writer, 4);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
|
||||
if (i < len - 1)
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
}
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_end_array(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "]", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
if (!rjsonwriter_free(writer))
|
||||
{
|
||||
|
@ -1216,35 +1216,32 @@ void runtime_log_save(runtime_log_t *runtime_log)
|
||||
RARCH_LOG("[Runtime]: Saving runtime log file: \"%s\".\n", runtime_log->path);
|
||||
|
||||
/* Attempt to open log file */
|
||||
file = filestream_open(runtime_log->path,
|
||||
RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
if (!(file = filestream_open(runtime_log->path,
|
||||
RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE)))
|
||||
{
|
||||
RARCH_ERR("[Runtime]: Failed to open runtime log file: \"%s\".\n", runtime_log->path);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialise JSON writer */
|
||||
writer = rjsonwriter_open_rfile(file);
|
||||
if (!writer)
|
||||
if (!(writer = rjsonwriter_open_rfile(file)))
|
||||
{
|
||||
RARCH_ERR("[Runtime]: Failed to create JSON writer.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Write output file */
|
||||
rjsonwriter_add_start_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "{", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Version entry */
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "version");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, "1.0");
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Runtime entry */
|
||||
snprintf(value_string,
|
||||
@ -1255,11 +1252,11 @@ void runtime_log_save(runtime_log_t *runtime_log)
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "runtime");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, value_string);
|
||||
rjsonwriter_add_comma(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, ",", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Last played entry */
|
||||
value_string[0] = '\0';
|
||||
@ -1272,14 +1269,14 @@ void runtime_log_save(runtime_log_t *runtime_log)
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "last_played");
|
||||
rjsonwriter_add_colon(writer);
|
||||
rjsonwriter_add_space(writer);
|
||||
rjsonwriter_raw(writer, ":", 1);
|
||||
rjsonwriter_raw(writer, " ", 1);
|
||||
rjsonwriter_add_string(writer, value_string);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* > Finalise */
|
||||
rjsonwriter_add_end_object(writer);
|
||||
rjsonwriter_add_newline(writer);
|
||||
rjsonwriter_raw(writer, "}", 1);
|
||||
rjsonwriter_raw(writer, "\n", 1);
|
||||
|
||||
/* Free JSON writer */
|
||||
if (!rjsonwriter_free(writer))
|
||||
|
@ -910,8 +910,7 @@ bool run_translation_service(settings_t *settings, bool paused)
|
||||
else
|
||||
{
|
||||
/* This is a software core, so just change the pixel format to 24-bit. */
|
||||
bit24_image = (uint8_t*)malloc(width * height * 3);
|
||||
if (!bit24_image)
|
||||
if (!(bit24_image = (uint8_t*)malloc(width * height * 3)))
|
||||
goto finish;
|
||||
|
||||
if (video_driver_pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888)
|
||||
@ -961,72 +960,67 @@ bool run_translation_service(settings_t *settings, bool paused)
|
||||
width, height, (signed)-pitch, &buffer_bytes);
|
||||
}
|
||||
|
||||
bmp64_buffer = base64((void *)bmp_buffer,
|
||||
if (!(bmp64_buffer = base64((void *)bmp_buffer,
|
||||
(int)(sizeof(uint8_t) * buffer_bytes),
|
||||
&bmp64_length);
|
||||
|
||||
if (!bmp64_buffer)
|
||||
&bmp64_length)))
|
||||
goto finish;
|
||||
|
||||
jsonwriter = rjsonwriter_open_memory();
|
||||
if (!jsonwriter)
|
||||
if (!(jsonwriter = rjsonwriter_open_memory()))
|
||||
goto finish;
|
||||
|
||||
rjsonwriter_add_start_object(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, "{", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, "image");
|
||||
rjsonwriter_add_colon(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ":", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string_len(jsonwriter, bmp64_buffer, bmp64_length);
|
||||
|
||||
/* Form request... */
|
||||
if (system_label)
|
||||
{
|
||||
rjsonwriter_add_comma(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ",", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, "label");
|
||||
rjsonwriter_add_colon(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ":", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, system_label);
|
||||
}
|
||||
|
||||
rjsonwriter_add_comma(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ",", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, "state");
|
||||
rjsonwriter_add_colon(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_add_start_object(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ":", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_raw(jsonwriter, "{", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, "paused");
|
||||
rjsonwriter_add_colon(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_add_unsigned(jsonwriter, (paused ? 1 : 0));
|
||||
rjsonwriter_raw(jsonwriter, ":", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_rawf(jsonwriter, "%u", (paused ? 1 : 0));
|
||||
{
|
||||
static const char* state_labels[] = { "b", "y", "select", "start", "up", "down", "left", "right", "a", "x", "l", "r", "l2", "r2", "l3", "r3" };
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(state_labels); i++)
|
||||
{
|
||||
rjsonwriter_add_comma(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ",", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_add_string(jsonwriter, state_labels[i]);
|
||||
rjsonwriter_add_colon(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, ":", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
#ifdef HAVE_ACCESSIBILITY
|
||||
rjsonwriter_add_unsigned(jsonwriter,
|
||||
(input_st->ai_gamepad_state[i] ? 1 : 0)
|
||||
);
|
||||
rjsonwriter_rawf(jsonwriter, "%u",
|
||||
(input_st->ai_gamepad_state[i] ? 1 : 0));
|
||||
#else
|
||||
rjsonwriter_add_unsigned(jsonwriter, 0);
|
||||
rjsonwriter_rawf(jsonwriter, "%u", 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_add_end_object(jsonwriter);
|
||||
rjsonwriter_add_space(jsonwriter);
|
||||
rjsonwriter_add_end_object(jsonwriter);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_raw(jsonwriter, "}", 1);
|
||||
rjsonwriter_raw(jsonwriter, " ", 1);
|
||||
rjsonwriter_raw(jsonwriter, "}", 1);
|
||||
|
||||
json_buffer = rjsonwriter_get_memory_buffer(jsonwriter, NULL);
|
||||
if (!json_buffer)
|
||||
if (!(json_buffer = rjsonwriter_get_memory_buffer(jsonwriter, NULL)))
|
||||
goto finish; /* ran out of memory */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
Loading…
x
Reference in New Issue
Block a user