static void menu_content_environment_get(int *argc, char *argv[], void *args, void *params_data) { struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data; if (!wrap_args) return; wrap_args->no_content = menu_driver_ctl( RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_VERBOSITY, NULL)) wrap_args->verbose = verbosity_is_enabled(); wrap_args->touched = true; wrap_args->config_path = NULL; wrap_args->sram_path = NULL; wrap_args->state_path = NULL; wrap_args->content_path = NULL; if (!path_is_empty(RARCH_PATH_CONFIG)) wrap_args->config_path = path_get(RARCH_PATH_CONFIG); if (!dir_is_empty(RARCH_DIR_SAVEFILE)) wrap_args->sram_path = dir_get(RARCH_DIR_SAVEFILE); if (!dir_is_empty(RARCH_DIR_SAVESTATE)) wrap_args->state_path = dir_get(RARCH_DIR_SAVESTATE); if (!path_is_empty(RARCH_PATH_CONTENT)) wrap_args->content_path = path_get(RARCH_PATH_CONTENT); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO, NULL)) wrap_args->libretro_path = string_is_empty(path_get(RARCH_PATH_CORE)) ? NULL : path_get(RARCH_PATH_CORE); }
void find_record_driver(void) { int i; driver_ctx_info_t drv; settings_t *settings = config_get_ptr(); drv.label = "record_driver"; drv.s = settings->arrays.record_driver; driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); i = (int)drv.len; if (i >= 0) recording_driver = (const record_driver_t*)record_driver_find_handle(i); else { if (verbosity_is_enabled()) { unsigned d; RARCH_ERR("Couldn't find any record driver named \"%s\"\n", settings->arrays.record_driver); RARCH_LOG_OUTPUT("Available record drivers are:\n"); for (d = 0; record_driver_find_handle(d); d++) RARCH_LOG_OUTPUT("\t%s\n", record_driver_find_ident(d)); RARCH_WARN("Going to default to first record driver...\n"); } recording_driver = (const record_driver_t*)record_driver_find_handle(0); if (!recording_driver) retroarch_fail(1, "find_record_driver()"); } }
void RARCH_LOG(const char *fmt, ...) { va_list ap; if (!verbosity_is_enabled()) return; va_start(ap, fmt); RARCH_LOG_V("[INFO]", fmt, ap); va_end(ap); }
void RARCH_LOG(const char *fmt, ...) { va_list ap; if (!verbosity_is_enabled()) return; va_start(ap, fmt); RARCH_LOG_V(file_path_str(FILE_PATH_LOG_INFO), fmt, ap); va_end(ap); }
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) { #if TARGET_OS_IPHONE static int asl_inited = 0; #if !TARGET_IPHONE_SIMULATOR static aslclient asl_client; #endif #endif if (!verbosity_is_enabled()) return; #if TARGET_OS_IPHONE #if TARGET_IPHONE_SIMULATOR vprintf(fmt, ap); #else if (!asl_inited) { asl_client = asl_open("RetroArch", "com.apple.console", ASL_OPT_STDERR | ASL_OPT_NO_DELAY); asl_inited = 1; } aslmsg msg = asl_new(ASL_TYPE_MSG); asl_set(msg, ASL_KEY_READ_UID, "-1"); if (tag) asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag); asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap); asl_free(msg); #endif #elif defined(_XBOX1) /* FIXME: Using arbitrary string as fmt argument is unsafe. */ char msg_new[1024], buffer[1024]; snprintf(msg_new, sizeof(msg_new), "%s: %s %s", PROGRAM_NAME, tag ? tag : "", fmt); wvsprintf(buffer, msg_new, ap); OutputDebugStringA(buffer); #elif defined(ANDROID) int prio = ANDROID_LOG_INFO; if (tag) { if (string_is_equal("[WARN]", tag)) prio = ANDROID_LOG_WARN; else if (string_is_equal("[ERROR]", tag)) prio = ANDROID_LOG_ERROR; } __android_log_vprint(prio, PROGRAM_NAME, fmt, ap); #else fprintf(LOG_FILE, "%s %s :: ", PROGRAM_NAME, tag ? tag : "[INFO]"); vfprintf(LOG_FILE, fmt, ap); fflush(LOG_FILE); #endif }
static void frontend_ps3_exec(const char *path, bool should_load_game) { #ifndef IS_SALAMANDER char *fullpath = NULL; bool original_verbose = verbosity_is_enabled(); verbosity_enable(); #endif (void)should_load_game; RARCH_LOG("Attempt to load executable: [%s].\n", path); #ifndef IS_SALAMANDER runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (should_load_game && !string_is_empty(fullpath)) { char game_path[256]; strlcpy(game_path, fullpath, sizeof(game_path)); const char * const spawn_argv[] = { game_path, NULL }; frontend_ps3_exec_exitspawn(path, (const char** const)spawn_argv, NULL); } else #endif { frontend_ps3_exec_exitspawn(path, NULL, NULL); } sceNpTerm(); sys_net_finalize_network(); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) { #ifdef HAVE_RARCH_EXEC bool should_load_game = false; #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); verbosity_enable(); if (ps3_fork_mode == FRONTEND_FORK_NONE) { frontend_ctx_driver_t *frontend = frontend_get_ptr(); if (frontend) frontend->shutdown = frontend_ps3_shutdown; return; } switch (ps3_fork_mode) { case FRONTEND_FORK_CORE_WITH_ARGS: should_load_game = true; break; case FRONTEND_FORK_NONE: default: break; } #endif frontend_ps3_exec(core_path, should_load_game); #ifdef IS_SALAMANDER cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); #endif #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif #endif }
static void frontend_xdk_exec(const char *path, bool should_load_game) { #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); #endif #if defined(_XBOX1) LAUNCH_DATA ptr; #elif defined(_XBOX360) char game_path[1024] = {0}; #endif (void)should_load_game; #ifdef IS_SALAMANDER if (!string_is_empty(path)) XLaunchNewImage(path, NULL); #else #if defined(_XBOX1) memset(&ptr, 0, sizeof(ptr)); if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", path_get(RARCH_PATH_CONTENT)); if (!string_is_empty(path)) XLaunchNewImage(path, !string_is_empty((const char*)ptr.Data) ? &ptr : NULL); #elif defined(_XBOX360) if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) { strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE); } if (!string_is_empty(path)) XLaunchNewImage(path, 0); #endif #endif #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
static void frontend_ps3_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); verbosity_enable(); #endif (void)args; #ifndef IS_SALAMANDER #if defined(HAVE_LOGGER) logger_init(); #elif defined(HAVE_FILE_LOGGER) retro_main_log_file_init("/retroarch-log.txt"); #endif #endif int ret; unsigned int get_type; unsigned int get_attributes; CellGameContentSize size; char dirName[CELL_GAME_DIRNAME_SIZE] = {0}; #ifdef HAVE_MULTIMAN /* not launched from external launcher, set default path */ // second param is multiMAN SELF file if(path_file_exists(argv[2]) && *argc > 1 && (string_is_equal(argv[2], EMULATOR_CONTENT_DIR))) { multiman_detected = true; RARCH_LOG("Started from multiMAN, auto-game start enabled.\n"); } else #endif #ifndef IS_SALAMANDER if (*argc > 1 && !string_is_empty(argv[1])) { static char path[PATH_MAX_LENGTH] = {0}; struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; if (args) { strlcpy(path, argv[1], sizeof(path)); args->touched = true; args->no_content = false; args->verbose = false; args->config_path = NULL; args->sram_path = NULL; args->state_path = NULL; args->content_path = path; args->libretro_path = NULL; RARCH_LOG("argv[0]: %s\n", argv[0]); RARCH_LOG("argv[1]: %s\n", argv[1]); RARCH_LOG("argv[2]: %s\n", argv[2]); RARCH_LOG("Auto-start game %s.\n", argv[1]); } } else RARCH_WARN("Started from Salamander, auto-game start disabled.\n"); #endif memset(&size, 0x00, sizeof(CellGameContentSize)); ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName); if(ret < 0) { RARCH_ERR("cellGameBootCheck() Error: 0x%x.\n", ret); } else { char content_info_path[PATH_MAX_LENGTH] = {0}; RARCH_LOG("cellGameBootCheck() OK.\n"); RARCH_LOG("Directory name: [%s].\n", dirName); RARCH_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB); switch(get_type) { case CELL_GAME_GAMETYPE_DISC: RARCH_LOG("RetroArch was launched on Optical Disc Drive.\n"); break; case CELL_GAME_GAMETYPE_HDD: RARCH_LOG("RetroArch was launched on HDD.\n"); break; } if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); ret = cellGameContentPermit(content_info_path, g_defaults.dir.port); #ifdef HAVE_MULTIMAN if (multiman_detected) { fill_pathname_join(content_info_path, "/dev_hdd0/game/", EMULATOR_CONTENT_DIR, sizeof(content_info_path)); fill_pathname_join(g_defaults.dir.port, content_info_path, "USRDIR", sizeof(g_defaults.dir.port)); } #endif if(ret < 0) RARCH_ERR("cellGameContentPermit() Error: 0x%x\n", ret); else { RARCH_LOG("cellGameContentPermit() OK.\n"); RARCH_LOG("content_info_path : [%s].\n", content_info_path); RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dir.port); } strlcpy(g_defaults.dir.content_history, g_defaults.dir.port, sizeof(g_defaults.dir.content_history)); fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, "cores", sizeof(g_defaults.dir.core)); fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, "info", sizeof(g_defaults.dir.core_info)); fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, "savestates", sizeof(g_defaults.dir.savestate)); fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, "savefiles", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, "system", sizeof(g_defaults.dir.system)); fill_pathname_join(g_defaults.dir.shader, g_defaults.dir.core, "shaders_cg", sizeof(g_defaults.dir.shader)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core, "overlays", sizeof(g_defaults.dir.overlay)); fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.core, "assets", sizeof(g_defaults.dir.assets)); fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.core, "database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_join(g_defaults.dir.database, g_defaults.dir.core, "database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, "playlists", sizeof(g_defaults.dir.playlist)); } #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
/* WARNING: after we move any data * into EXECUTE_ADDR, we can no longer use any * heap memory and are restricted to the stack only. */ void system_exec_wii(const char *_path, bool should_load_game) { size_t size, booter_size; FILE *fp = NULL; void *dol = NULL; char path[PATH_MAX_LENGTH] = {0}; char game_path[PATH_MAX_LENGTH] = {0}; #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); #endif /* copy heap info into stack so it survives * us moving the .dol into MEM2. */ strlcpy(path, _path, sizeof(path)); if (should_load_game) { #ifdef IS_SALAMANDER strlcpy(game_path, gx_rom_path, sizeof(game_path)); #else strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); #endif } RARCH_LOG("Attempt to load executable: [%s]\n", path); fp = fopen(path, "rb"); if (fp == NULL) { RARCH_ERR("Could not open DOL file %s.\n", path); goto exit; } fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); /* try to allocate a buffer for it. if we can't, fail. */ dol = malloc(size); if (!dol) { RARCH_ERR("Could not execute DOL file %s.\n", path); fclose(fp); goto exit; } fread(dol, 1, size, fp); fclose(fp); fatUnmount("carda:"); fatUnmount("cardb:"); fatUnmount("sd:"); fatUnmount("usb:"); __io_wiisd.shutdown(); __io_usbstorage.shutdown(); /* don't use memcpy, there might be an overlap. */ memmove(EXECUTE_ADDR, dol, size); DCFlushRange(EXECUTE_ADDR, size); dol_copy_argv_path(path, should_load_game ? game_path : NULL); booter_size = booter_end - booter_start; memcpy(BOOTER_ADDR, booter_start, booter_size); DCFlushRange(BOOTER_ADDR, booter_size); RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR); SYS_ResetSystem(SYS_SHUTDOWN,0,0); __lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR); exit: (void)0; #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) { #if TARGET_OS_IPHONE static int asl_initialized = 0; #if !TARGET_IPHONE_SIMULATOR static aslclient asl_client; #endif #else FILE *fp = NULL; (void)fp; #endif if (!verbosity_is_enabled()) return; #if TARGET_OS_IPHONE #if TARGET_IPHONE_SIMULATOR vprintf(fmt, ap); #else if (!asl_initialized) { asl_client = asl_open(file_path_str(FILE_PATH_PROGRAM_NAME), "com.apple.console", ASL_OPT_STDERR | ASL_OPT_NO_DELAY); asl_initialized = 1; } aslmsg msg = asl_new(ASL_TYPE_MSG); asl_set(msg, ASL_KEY_READ_UID, "-1"); if (tag) asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag); asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap); asl_free(msg); #endif #elif defined(_XBOX1) /* FIXME: Using arbitrary string as fmt argument is unsafe. */ char msg_new[1024]; char buffer[1024]; msg_new[0] = buffer[0] = '\0'; snprintf(msg_new, sizeof(msg_new), "%s: %s %s", file_path_str(FILE_PATH_PROGRAM_NAME), tag ? tag : "", fmt); wvsprintf(buffer, msg_new, ap); OutputDebugStringA(buffer); #elif defined(ANDROID) int prio = ANDROID_LOG_INFO; if (tag) { if (string_is_equal(file_path_str(FILE_PATH_LOG_WARN), tag)) prio = ANDROID_LOG_WARN; else if (string_is_equal(file_path_str(FILE_PATH_LOG_ERROR), tag)) prio = ANDROID_LOG_ERROR; } __android_log_vprint(prio, file_path_str(FILE_PATH_PROGRAM_NAME), fmt, ap); #else #ifdef HAVE_FILE_LOGGER fp = (FILE*)retro_main_log_file(); #else fp = stderr; #endif fprintf(fp, "%s %s :: ", file_path_str(FILE_PATH_PROGRAM_NAME), tag ? tag : file_path_str(FILE_PATH_LOG_INFO)); vfprintf(fp, fmt, ap); fflush(fp); #endif }
static void frontend_xdk_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { HRESULT ret; #ifdef _XBOX360 unsigned long license_mask; DWORD volume_device_type; #endif #ifndef IS_SALAMANDER static char path[PATH_MAX_LENGTH] = {0}; #if defined(_XBOX1) LAUNCH_DATA ptr; DWORD launch_type; #elif defined(_XBOX360) DWORD dwLaunchDataSize; #endif #endif #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); #endif (void)ret; #ifndef IS_SALAMANDER #if defined(HAVE_LOGGER) logger_init(); #elif defined(HAVE_FILE_LOGGER) retro_main_log_file_init("/retroarch-log.txt"); #endif #endif #ifdef _XBOX360 /* Detect install environment. */ if (XContentGetLicenseMask(&license_mask, NULL) == ERROR_SUCCESS) { XContentQueryVolumeDeviceType("GAME",&volume_device_type, NULL); switch(volume_device_type) { case XCONTENTDEVICETYPE_HDD: /* Launched from content package on HDD */ case XCONTENTDEVICETYPE_MU: /* Launched from content package on USB/Memory Unit. */ case XCONTENTDEVICETYPE_ODD: /* Launched from content package on Optial Disc Drive. */ default: /* Launched from content package on unknown device. */ break; } } #endif #if defined(_XBOX1) strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], "D:", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_CORE], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], g_defaults.dirs[DEFAULT_DIR_CORE], "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], g_defaults.dirs[DEFAULT_DIR_CORE], "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], g_defaults.dirs[DEFAULT_DIR_CORE], "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], g_defaults.dirs[DEFAULT_DIR_CORE], "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); #elif defined(_XBOX360) strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], "game:", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); strlcpy(g_defaults.path.config, "game:\\retroarch.cfg", sizeof(g_defaults.path.config)); strlcpy(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], "game:", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); strlcpy(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], "game:\\savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); strlcpy(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], "game:\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); strlcpy(g_defaults.dirs[DEFAULT_DIR_SRAM], "game:\\savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM], "game:\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); #endif fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); #ifndef IS_SALAMANDER #if defined(_XBOX1) if (XGetLaunchInfo(&launch_type, &ptr) == ERROR_SUCCESS) { char *extracted_path = NULL; if (launch_type == LDT_FROM_DEBUGGER_CMDLINE) goto exit; extracted_path = (char*)&ptr.Data; if ( !string_is_empty(extracted_path) && (strstr(extracted_path, "Pool") == NULL) /* Hack. Unknown problem */) { /* Auto-start game */ strlcpy(path, extracted_path, sizeof(path)); } } #elif defined(_XBOX360) if (XGetLaunchDataSize(&dwLaunchDataSize) == ERROR_SUCCESS) { char *extracted_path = (char*)calloc(dwLaunchDataSize, sizeof(char)); BYTE* pLaunchData = (BYTE*)calloc(dwLaunchDataSize, sizeof(BYTE)); XGetLaunchData(pLaunchData, dwLaunchDataSize); memset(extracted_path, 0, dwLaunchDataSize); strlcpy(extracted_path, pLaunchData, dwLaunchDataSize); /* Auto-start game */ if (!string_is_empty(extracted_path)) strlcpy(path, extracted_path, sizeof(path)); if (pLaunchData) free(pLaunchData); } #endif if (!string_is_empty(path)) { struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; if (args) { /* Auto-start game. */ args->touched = true; args->no_content = false; args->verbose = false; args->config_path = NULL; args->sram_path = NULL; args->state_path = NULL; args->content_path = path; args->libretro_path = NULL; } } #endif #ifndef IS_SALAMANDER #ifdef _XBOX1 exit: if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif #endif }