static void salamander_init(char *s, size_t len) { /* normal executable loading path */ bool config_file_exists = false; if (path_file_exists(g_defaults.path.config)) config_file_exists = true; if (config_file_exists) { char tmp_str[PATH_MAX_LENGTH]; config_file_t * conf = (config_file_t*)config_file_new(g_defaults.path.config); if (conf) { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); if (strcmp(tmp_str, "builtin") != 0) strlcpy(s, tmp_str, len); } #ifdef GEKKO /* stupid libfat bug or something; sometimes it says * the file is there when it doesn't. */ else { config_file_exists = false; } #endif } if (!config_file_exists || !strcmp(s, "")) { char executable_name[PATH_MAX_LENGTH]; frontend_driver_get_core_extension( executable_name, sizeof(executable_name)); find_and_set_first_file(s, len, executable_name); } else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", s); if (!config_file_exists) { config_file_t *conf = (config_file_t*)config_file_new(NULL); if (conf) { config_set_string(conf, "libretro_path", s); config_file_write(conf, g_defaults.path.config); config_file_free(conf); } } }
static void salamander_init_settings(void) { char tmp_str[512] = {0}; bool config_file_exists; if(!path_file_exists(default_paths.config_path)) { FILE * f; config_file_exists = false; RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", default_paths.config_path); MAKE_DIR(default_paths.port_dir); f = fopen(default_paths.config_path, "w"); fclose(f); } else config_file_exists = true; //try to find CORE executable char core_executable[1024]; snprintf(core_executable, sizeof(core_executable), "%s/CORE.dol", default_paths.core_dir); if(path_file_exists(core_executable)) { //Start CORE executable snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), core_executable); RARCH_LOG("Start [%s].\n", default_paths.libretro_path); } else { if(config_file_exists) { config_file_t * conf = config_file_new(default_paths.config_path); config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), tmp_str); } if(!config_file_exists || !strcmp(default_paths.libretro_path, "")) find_and_set_first_file(); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path); } if (!config_file_exists) { config_file_t *new_conf = config_file_new(NULL); config_set_string(new_conf, "libretro_path", default_paths.libretro_path); config_file_write(new_conf, default_paths.config_path); config_file_free(new_conf); } } }
bool d3d_init_multipass(void *data) { d3d_video_t *d3d = (d3d_video_t*)data; config_file_t *conf = config_file_new(d3d->cg_shader.c_str()); if (!conf) { RARCH_ERR("Failed to load preset.\n"); return false; } memset(&d3d->shader, 0, sizeof(d3d->shader)); if (!gfx_shader_read_conf_cgp(conf, &d3d->shader)) { config_file_free(conf); RARCH_ERR("Failed to parse CGP file.\n"); return false; } config_file_free(conf); gfx_shader_resolve_relative(&d3d->shader, d3d->cg_shader.c_str()); RARCH_LOG("[D3D9 Meta-Cg] Found %d shaders.\n", d3d->shader.passes); for (unsigned i = 0; i < d3d->shader.passes; i++) { if (!d3d->shader.pass[i].fbo.valid) { d3d->shader.pass[i].fbo.scale_x = d3d->shader.pass[i].fbo.scale_y = 1.0f; d3d->shader.pass[i].fbo.type_x = d3d->shader.pass[i].fbo.type_y = RARCH_SCALE_INPUT; } } bool use_extra_pass = d3d->shader.passes < GFX_MAX_SHADERS && d3d->shader.pass[d3d->shader.passes - 1].fbo.valid; if (use_extra_pass) { d3d->shader.passes++; gfx_shader_pass &dummy_pass = d3d->shader.pass[d3d->shader.passes - 1]; dummy_pass.fbo.scale_x = dummy_pass.fbo.scale_y = 1.0f; dummy_pass.fbo.type_x = dummy_pass.fbo.type_y = RARCH_SCALE_VIEWPORT; dummy_pass.filter = RARCH_FILTER_UNSPEC; } else { gfx_shader_pass &pass = d3d->shader.pass[d3d->shader.passes - 1]; pass.fbo.scale_x = pass.fbo.scale_y = 1.0f; pass.fbo.type_x = pass.fbo.type_y = RARCH_SCALE_VIEWPORT; } return true; }
/** * cheat_manager_save: * @path : Path to cheats file (relative path). * * Saves cheats to file on disk. * * Returns: true (1) if successful, otherwise false (0). **/ bool cheat_manager_save(cheat_manager_t *handle, const char *path) { bool ret; unsigned i; char buf[PATH_MAX_LENGTH]; char cheats_file[PATH_MAX_LENGTH]; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); fill_pathname_join(buf, settings->cheat_database, path, sizeof(buf)); fill_pathname_noext(cheats_file, buf, ".cht", sizeof(cheats_file)); conf = config_file_new(cheats_file); if (!conf) conf = config_file_new(NULL); if (!conf) return false; if (!handle) { config_file_free(conf); return false; } config_set_int(conf, "cheats", handle->size); for (i = 0; i < handle->size; i++) { char key[64], desc_key[256], code_key[256], enable_key[256]; snprintf(key, sizeof(key), "cheat%u", i); snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i); snprintf(code_key, sizeof(code_key), "cheat%u_code", i); snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i); if (handle->cheats[i].desc) config_set_string(conf, desc_key, handle->cheats[i].desc); else config_set_string(conf, desc_key, handle->cheats[i].code); config_set_string(conf, code_key, handle->cheats[i].code); config_set_bool(conf, enable_key, handle->cheats[i].state); } ret = config_file_write(conf, cheats_file); config_file_free(conf); return ret; }
static bool hlsl_load_preset(hlsl_shader_data_t *hlsl, void *data, const char *path) { unsigned i; config_file_t *conf = NULL; if (!hlsl_load_stock(hlsl, data)) return false; RARCH_LOG("Loading Cg meta-shader: %s\n", path); conf = config_file_new(path); if (!conf) goto error; if (!hlsl->cg_shader) hlsl->cg_shader = (struct video_shader*)calloc(1, sizeof(*hlsl->cg_shader)); if (!hlsl->cg_shader) goto error; if (!video_shader_read_conf_cgp(conf, hlsl->cg_shader)) { RARCH_ERR("Failed to parse CGP file.\n"); goto error; } config_file_free(conf); if (hlsl->cg_shader->passes > RARCH_HLSL_MAX_SHADERS - 3) { RARCH_WARN("Too many shaders ... Capping shader amount to %d.\n", RARCH_HLSL_MAX_SHADERS - 3); hlsl->cg_shader->passes = RARCH_HLSL_MAX_SHADERS - 3; } for (i = 0; i < hlsl->cg_shader->passes; i++) { if (!hlsl_load_shader(hlsl, data, path, i)) goto error; } /* TODO - textures / imports */ return true; error: RARCH_ERR("Failed to load preset.\n"); if (conf) config_file_free(conf); conf = NULL; return false; }
static void salamander_init(void) { char tmp_str[512] = {0}; bool config_file_exists; if (path_file_exists(config_path)) config_file_exists = true; //try to find CORE executable char core_executable[1024]; fill_pathname_join(core_executable, default_paths.core_dir, "CORE.dol", sizeof(core_executable)); if(path_file_exists(core_executable)) { //Start CORE executable strlcpy(libretro_path, core_executable, sizeof(libretro_path)); RARCH_LOG("Start [%s].\n", libretro_path); } else { if(config_file_exists) { config_file_t * conf = config_file_new(config_path); if (!conf) // stupid libfat bug or something; somtimes it says the file is there when it doesn't config_file_exists = false; else { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); strlcpy(libretro_path, tmp_str, sizeof(libretro_path)); } } if(!config_file_exists || !strcmp(libretro_path, "")) find_and_set_first_file(); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); } if (!config_file_exists) { config_file_t *new_conf = config_file_new(NULL); config_set_string(new_conf, "libretro_path", libretro_path); config_file_write(new_conf, config_path); config_file_free(new_conf); } } }
/** * core_option_manager_free: * @opt : options manager handle * * Frees core option manager handle. **/ void core_option_manager_free(core_option_manager_t *opt) { size_t i; if (!opt) return; for (i = 0; i < opt->size; i++) { if (opt->opts[i].desc) free(opt->opts[i].desc); if (opt->opts[i].key) free(opt->opts[i].key); if (opt->opts[i].vals) string_list_free(opt->opts[i].vals); opt->opts[i].desc = NULL; opt->opts[i].key = NULL; opt->opts[i].vals = NULL; } if (opt->conf) config_file_free(opt->conf); free(opt->opts); free(opt); }
void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp) { unsigned i; if (!dsp) return; for (i = 0; i < dsp->num_instances; i++) { if (dsp->instances[i].impl_data && dsp->instances[i].impl) dsp->instances[i].impl->free(dsp->instances[i].impl_data); } free(dsp->instances); #ifdef HAVE_DYLIB for (i = 0; i < dsp->num_plugs; i++) { if (dsp->plugs[i].lib) dylib_close(dsp->plugs[i].lib); } free(dsp->plugs); #endif if (dsp->conf) config_file_free(dsp->conf); free(dsp); }
static int deferred_push_cursor_manager_list_deferred(menu_displaylist_info_t *info) { char rdb_path[PATH_MAX_LENGTH]; int ret = -1; char *query = NULL; char *rdb = NULL; settings_t *settings = config_get_ptr(); config_file_t *conf = config_file_new(info->path); if (!conf || !settings) goto end; if (!config_get_string(conf, "query", &query)) goto end; if (!config_get_string(conf, "rdb", &rdb)) goto end; fill_pathname_join(rdb_path, settings->content_database, rdb, sizeof(rdb_path)); strlcpy(info->path_b, info->path, sizeof(info->path_b)); strlcpy(info->path, rdb_path, sizeof(info->path)); strlcpy(info->path_c, query, sizeof(info->path_c)); ret = deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY); end: if (conf) config_file_free(conf); return ret; }
void core_info_list_free(core_info_list_t *core_info_list) { size_t i, j; if (!core_info_list) return; for (i = 0; i < core_info_list->count; i++) { core_info_t *info = (core_info_t*)&core_info_list->list[i]; free(info->path); free(info->display_name); free(info->supported_extensions); free(info->authors); free(info->permissions); free(info->notes); if (info->supported_extensions_list) string_list_free(info->supported_extensions_list); string_list_free(info->authors_list); string_list_free(info->note_list); string_list_free(info->permissions_list); config_file_free(info->data); for (j = 0; j < info->firmware_count; j++) { free(info->firmware[j].path); free(info->firmware[j].desc); } free(info->firmware); } free(core_info_list->all_ext); free(core_info_list->list); free(core_info_list); }
bool core_info_get_display_name(const char *path, char *s, size_t len) { char *core_name = NULL; config_file_t *conf = NULL; if (!path_file_exists(path)) return false; conf = config_file_new(path); if (!conf) goto error; config_get_string(conf, "corename", &core_name); config_file_free(conf); if (!core_name) goto error; if (!conf) return false; strlcpy(s, core_name, len); return true; error: return false; }
int main(int argc, char *argv[]) { parse_input(argc, argv); config_file_t *conf = config_file_new(g_in_path); if (!conf) { fprintf(stderr, "Couldn't open config file ...\n"); return 1; } const char *index_list[] = { "input_player1_joypad_index", "input_player2_joypad_index", "input_player3_joypad_index", "input_player4_joypad_index", "input_player5_joypad_index", "input_player6_joypad_index", "input_player7_joypad_index", "input_player8_joypad_index", }; config_set_int(conf, index_list[g_player - 1], g_joypad); get_binds(conf, g_player - 1, g_joypad); config_file_write(conf, g_out_path); config_file_free(conf); if (g_in_path) free(g_in_path); if (g_out_path) free(g_out_path); return 0; }
void core_info_get_name(const char *path, char *s, size_t len) { size_t i; settings_t *settings = config_get_ptr(); struct string_list *contents = dir_list_new_special( settings->paths.directory_libretro, DIR_LIST_CORES, NULL); const char *path_basedir = !string_is_empty(settings->paths.path_libretro_info) ? settings->paths.path_libretro_info : settings->paths.directory_libretro; if (!contents) return; for (i = 0; i < contents->size; i++) { size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *info_path = NULL; config_file_t *conf = NULL; char *new_core_name = NULL; const char *current_path = contents->elems[i].data; if (!string_is_equal(current_path, path)) continue; info_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); info_path[0] = '\0'; if (!core_info_list_iterate(info_path, path_size, path_basedir, contents, i) && path_is_valid(info_path)) { free(info_path); continue; } conf = config_file_new(info_path); if (!conf) { free(info_path); continue; } if (config_get_string(conf, "corename", &new_core_name)) { strlcpy(s, new_core_name, len); free(new_core_name); } config_file_free(conf); free(info_path); break; } if (contents) dir_list_free(contents); contents = NULL; }
config_file_t *config_file_new_from_string(const char *from_string) { size_t i; struct string_list *lines = NULL; struct config_file *conf = (struct config_file*)malloc(sizeof(*conf)); if (!conf) return NULL; if (!from_string) return conf; conf->path = NULL; conf->entries = NULL; conf->tail = NULL; conf->includes = NULL; conf->include_depth = 0; lines = string_split(from_string, "\n"); if (!lines) return conf; for (i = 0; i < lines->size; i++) { struct config_entry_list *list = (struct config_entry_list*)malloc(sizeof(*list)); char *line = lines->elems[i].data; if (!list) { string_list_free(lines); config_file_free(conf); return NULL; } list->readonly = false; list->key = NULL; list->value = NULL; list->next = NULL; if (line && conf) { if (*line && parse_line(conf, list, line)) { if (conf->entries) conf->tail->next = list; else conf->entries = list; conf->tail = list; } } if (list != conf->tail) free(list); } string_list_free(lines); return conf; }
static bool load_preset(const char *path) { if (!load_stock()) return false; RARCH_LOG("Loading Cg meta-shader: %s\n", path); config_file_t *conf = config_file_new(path); if (!conf) { RARCH_ERR("Failed to load preset.\n"); return false; } if (!cg_shader) cg_shader = (struct gfx_shader*)calloc(1, sizeof(*cg_shader)); if (!cg_shader) return false; if (!gfx_shader_read_conf_cgp(conf, cg_shader)) { RARCH_ERR("Failed to parse CGP file.\n"); config_file_free(conf); return false; } config_file_free(conf); if (cg_shader->passes > RARCH_HLSL_MAX_SHADERS - 3) { RARCH_WARN("Too many shaders ... Capping shader amount to %d.\n", RARCH_HLSL_MAX_SHADERS - 3); cg_shader->passes = RARCH_HLSL_MAX_SHADERS - 3; } for (unsigned i = 0; i < cg_shader->passes; i++) { if (!load_shader(path, i)) { RARCH_ERR("Failed to load shaders ...\n"); return false; } } /* TODO - textures / imports */ return true; }
static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path) { size_t i; bool ret = true; config_file_t *conf = config_file_new(path); if (!conf) { RARCH_ERR("Failed to load config file: %s.\n", path); return false; } unsigned overlays = 0; if (!config_get_uint(conf, "overlays", &overlays)) { RARCH_ERR("overlays variable not defined in config.\n"); ret = false; goto end; } if (!overlays) { ret = false; goto end; } ol->overlays = (struct overlay*)calloc(overlays, sizeof(*ol->overlays)); if (!ol->overlays) { ret = false; goto end; } ol->size = overlays; for (i = 0; i < ol->size; i++) { if (!input_overlay_load_overlay(ol, conf, path, &ol->overlays[i], i)) { RARCH_ERR("[Overlay]: Failed to load overlay #%u.\n", (unsigned)i); ret = false; goto end; } } for (i = 0; i < ol->size; i++) { if (!input_overlay_resolve_targets(ol->overlays, i, ol->size)) { RARCH_ERR("[Overlay]: Failed to resolve next targets.\n"); ret = false; goto end; } } end: config_file_free(conf); return ret; }
int main(int argc, char *argv[]) { config_file_t *conf; config_file_t *auto_conf = NULL; const char *index_list[] = { "input_player1_joypad_index", "input_player2_joypad_index", "input_player3_joypad_index", "input_player4_joypad_index", "input_player5_joypad_index", "input_player6_joypad_index", "input_player7_joypad_index", "input_player8_joypad_index", }; parse_input(argc, argv); conf = config_file_new(g_in_path); if (!conf) { fprintf(stderr, "Couldn't open config file ...\n"); return 1; } config_set_int(conf, index_list[g_player - 1], g_joypad); if (g_auto_path) auto_conf = config_file_new(NULL); get_binds(conf, auto_conf, g_player - 1, g_joypad); config_file_write(conf, g_out_path); config_file_free(conf); if (auto_conf) { fprintf(stderr, "Writing autoconfig profile to: %s.\n", g_auto_path); config_file_write(auto_conf, g_auto_path); config_file_free(auto_conf); } free(g_in_path); free(g_out_path); free(g_auto_path); return 0; }
bool config_file_exists(const char *path) { config_file_t *config = config_file_new(path); if (!config) return false; config_file_free(config); return true; }
void shader_manager_init(rgui_handle_t *rgui) { config_file_t *conf = NULL; char cgp_path[PATH_MAX]; const char *ext = path_get_extension(g_settings.video.shader_path); if (strcmp(ext, "glslp") == 0 || strcmp(ext, "cgp") == 0) { conf = config_file_new(g_settings.video.shader_path); if (conf) { if (gfx_shader_read_conf_cgp(conf, &rgui->shader)) gfx_shader_resolve_relative(&rgui->shader, g_settings.video.shader_path); config_file_free(conf); } } else if (strcmp(ext, "glsl") == 0 || strcmp(ext, "cg") == 0) { strlcpy(rgui->shader.pass[0].source.cg, g_settings.video.shader_path, sizeof(rgui->shader.pass[0].source.cg)); rgui->shader.passes = 1; } else { const char *shader_dir = *g_settings.video.shader_dir ? g_settings.video.shader_dir : g_settings.system_directory; fill_pathname_join(cgp_path, shader_dir, "rgui.glslp", sizeof(cgp_path)); conf = config_file_new(cgp_path); if (!conf) { fill_pathname_join(cgp_path, shader_dir, "rgui.cgp", sizeof(cgp_path)); conf = config_file_new(cgp_path); } if (conf) { if (gfx_shader_read_conf_cgp(conf, &rgui->shader)) gfx_shader_resolve_relative(&rgui->shader, cgp_path); config_file_free(conf); } } }
static void add_sub_conf(config_file_t *conf, char *path, config_file_cb_t *cb, bool no_checks) { char real_path[PATH_MAX_LENGTH]; config_file_t *sub_conf = NULL; struct config_include_list *head = conf->includes; struct config_include_list *node = (struct config_include_list*) malloc(sizeof(*node)); if (node) { node->next = NULL; /* Add include list */ node->path = strdup(path); if (head) { while (head->next) head = head->next; head->next = node; } else conf->includes = node; } real_path[0] = '\0'; #ifdef _WIN32 if (!string_is_empty(conf->path)) fill_pathname_resolve_relative(real_path, conf->path, path, sizeof(real_path)); #else #ifndef __CELLOS_LV2__ if (*path == '~') { const char *home = getenv("HOME"); strlcpy(real_path, home ? home : "", sizeof(real_path)); strlcat(real_path, path + 1, sizeof(real_path)); } else #endif if (!string_is_empty(conf->path)) fill_pathname_resolve_relative(real_path, conf->path, path, sizeof(real_path)); #endif sub_conf = (config_file_t*) config_file_new_internal(real_path, conf->include_depth + 1, cb, no_checks); if (!sub_conf) return; /* Pilfer internal list. */ add_child_list(conf, sub_conf); config_file_free(sub_conf); }
static void salamander_init(char *s, size_t len) { /* normal executable loading path */ bool config_file_exists = false; if (path_file_exists(g_defaults.path.config)) config_file_exists = true; if (config_file_exists) { char tmp_str[PATH_MAX_LENGTH]; config_file_t * conf = (config_file_t*)config_file_new(g_defaults.path.config); if (conf) { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); strlcpy(s, tmp_str, len); } #ifdef GEKKO else /* stupid libfat bug or something; sometimes it says the file is there when it doesn't */ config_file_exists = false; #endif } if (!config_file_exists || !strcmp(s, "")) find_and_set_first_file(s, len, EXT_EXECUTABLES); else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", s); if (!config_file_exists) { config_file_t *conf = (config_file_t*)config_file_new(NULL); if (conf) { config_set_string(conf, "libretro_path", s); config_file_write(conf, g_defaults.path.config); config_file_free(conf); } } }
static void salamander_init(char *libretro_path, size_t sizeof_libretro_path) { //normal executable loading path bool config_file_exists = false; if (path_file_exists(default_paths.config_path)) config_file_exists = true; if (config_file_exists) { char tmp_str[PATH_MAX]; config_file_t * conf = (config_file_t*)config_file_new(default_paths.config_path); if (conf) { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); strlcpy(libretro_path, tmp_str, sizeof_libretro_path); } #ifdef GEKKO else // stupid libfat bug or something; somtimes it says the file is there when it doesn't config_file_exists = false; #endif } if (!config_file_exists || !strcmp(libretro_path, "")) find_and_set_first_file(libretro_path, sizeof_libretro_path, EXT_EXECUTABLES); else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); if (!config_file_exists) { config_file_t *conf = (config_file_t*)config_file_new(NULL); if (conf) { config_set_string(conf, "libretro_path", libretro_path); config_file_write(conf, default_paths.config_path); config_file_free(conf); } } }
bool core_info_get_display_name(const char *path, char *s, size_t len) { char *core_name = NULL; char *display_name = NULL; config_file_t *conf = NULL; if (!path_file_exists(path)) return false; conf = config_file_new(path); if (!conf) return false; config_get_string(conf, "corename", &core_name); config_get_string(conf, "display_name", &display_name); if (!core_name || !display_name) goto error; config_file_free(conf); snprintf(s, len,"%s",display_name); free(core_name); free(display_name); return true; error: config_file_free(conf); if (core_name) free(core_name); if (display_name) free(display_name); return false; }
static int input_autoconfigure_joypad_from_conf( config_file_t *conf, autoconfig_params_t *params, retro_task_t *task) { int ret = input_autoconfigure_joypad_try_from_conf(conf, params); if (ret) input_autoconfigure_joypad_add(conf, params, task); config_file_free(conf); return ret; }
/** * rarch_game_specific_options: * @cmd : Output variable with path to core options file. * * Environment callback function implementation. * * Returns: true (1) if a game specific core options path has been found, * otherwise false (0). **/ static bool rarch_game_specific_options(char **output) { settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); const char *core_name = NULL; const char *game_name = NULL; config_file_t *option_file = NULL; char game_path[PATH_MAX_LENGTH] = {0}; char config_directory[PATH_MAX_LENGTH] = {0}; core_name = system ? system->info.library_name : NULL; game_name = global ? path_basename(global->name.base) : NULL; if (!core_name || !game_name) return false; if (core_name[0] == '\0' || game_name[0] == '\0') return false; RARCH_LOG("Per-Game Options: core name: %s\n", core_name); RARCH_LOG("Per-Game Options: game name: %s\n", game_name); /* Config directory: config_directory. * Try config directory setting first, * fallback to the location of the current configuration file. */ if (settings->menu_config_directory[0] != '\0') strlcpy(config_directory, settings->menu_config_directory, PATH_MAX_LENGTH); else if (global->path.config[0] != '\0') fill_pathname_basedir(config_directory, global->path.config, PATH_MAX_LENGTH); else { RARCH_WARN("Per-Game Options: no config directory set\n"); return false; } /* Concatenate strings into full paths for game_path */ fill_pathname_join(game_path, config_directory, core_name, PATH_MAX_LENGTH); fill_pathname_join(game_path, game_path, game_name, PATH_MAX_LENGTH); strlcat(game_path, ".opt", PATH_MAX_LENGTH); option_file = config_file_new(game_path); if (!option_file) return false; config_file_free(option_file); RARCH_LOG("Per-Game Options: game-specific core options found at %s\n", game_path); *output = strdup(game_path); return true; }
static void ffmpeg_free(void *data) { ffmpeg_t *handle = (ffmpeg_t*)data; if (!handle) return; deinit_thread(handle); deinit_thread_buf(handle); if (handle->audio.codec) { avcodec_close(handle->audio.codec); av_free(handle->audio.codec); } av_free(handle->audio.buffer); if (handle->video.codec) { avcodec_close(handle->video.codec); av_free(handle->video.codec); } av_frame_free(&handle->video.conv_frame); av_free(handle->video.conv_frame_buf); scaler_ctx_gen_reset(&handle->video.scaler); if (handle->video.sws) sws_freeContext(handle->video.sws); if (handle->config.conf) config_file_free(handle->config.conf); if (handle->config.video_opts) av_dict_free(&handle->config.video_opts); if (handle->config.audio_opts) av_dict_free(&handle->config.audio_opts); if (handle->audio.resampler && handle->audio.resampler_data) handle->audio.resampler->free(handle->audio.resampler_data); handle->audio.resampler = NULL; handle->audio.resampler_data = NULL; av_free(handle->audio.float_conv); av_free(handle->audio.resample_out); av_free(handle->audio.fixed_conv); av_free(handle->audio.planar_buf); free(handle); }
static void cheat_manager_load_config(cheat_manager_t *handle, const char *path, const char *sha256) { const char *num; char *str, *save; config_file_t *conf; if (!(*path)) return; conf = (config_file_t*)config_file_new(path); if (!conf) return; str = NULL; if (!config_get_string(conf, sha256, &str)) { config_file_free(conf); return; } save = NULL; num = (const char*)strtok_r(str, ";", &save); while (num) { unsigned index = strtoul(num, NULL, 0); if (index < handle->size) handle->cheats[index].state = true; num = strtok_r(NULL, ";", &save); } free(str); config_file_free(conf); cheat_manager_apply_cheats(handle); }
void secure_free () { config_file_free (secure_config_file); if (secure_hashtable_data) { hashtable_free (secure_hashtable_data); secure_hashtable_data = NULL; } if (secure_hashtable_data_encrypted) { hashtable_free (secure_hashtable_data_encrypted); secure_hashtable_data_encrypted = NULL; } }
bool config_append_file(config_file_t *conf, const char *path) { config_file_t *new_conf = config_file_new(path); if (!new_conf) return false; if (new_conf->tail) { new_conf->tail->next = conf->entries; conf->entries = new_conf->entries; /* Pilfer. */ new_conf->entries = NULL; } config_file_free(new_conf); return true; }
cheat_manager_t *cheat_manager_load(const char *path) { unsigned cheats = 0, i; cheat_manager_t *cheat = NULL; config_file_t *conf = config_file_new(path); if (!conf) return NULL; config_get_uint(conf, "cheats", &cheats); if (cheats == 0) return NULL; cheat = cheat_manager_new(cheats); if (!cheat) return NULL; for (i = 0; i < cheats; i++) { char key[64] = {0}; char desc_key[256] = {0}; char code_key[256] = {0}; char enable_key[256] = {0}; char *tmp = NULL; bool tmp_bool = false; snprintf(key, sizeof(key), "cheat%u", i); snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i); snprintf(code_key, sizeof(code_key), "cheat%u_code", i); snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i); if (config_get_string(conf, desc_key, &tmp)) cheat->cheats[i].desc = strdup(tmp); if (config_get_string(conf, code_key, &tmp)) cheat->cheats[i].code = strdup(tmp); if (config_get_bool(conf, enable_key, &tmp_bool)) cheat->cheats[i].state = tmp_bool; } config_file_free(conf); return cheat; }