void get_savestate_filename_noshot(u32 slot, u8 *name_buffer) { u8 savestate_ext[16]; sprintf(savestate_ext, "%d.svs", slot); change_ext(gamepak_filename, name_buffer, savestate_ext); }
s32 save_game_config_file() { u8 game_config_filename[512]; u32 i; change_ext(gamepak_filename, game_config_filename, ".cfg"); FILE_OPEN(game_config_file, game_config_filename, write); if(FILE_CHECK_VALID(game_config_file)) { u32 file_options[14]; file_options[0] = current_frameskip_type; file_options[1] = frameskip_value; file_options[2] = random_skip; file_options[3] = clock_speed; for(i = 0; i < 10; i++) { file_options[4 + i] = cheats[i].cheat_active; } FILE_WRITE_ARRAY(game_config_file, file_options); FILE_CLOSE(game_config_file); return 0; } return -1; }
s32 save_game_config_file() { u8 game_config_filename[512]; u32 i; change_ext(gamepak_filename, game_config_filename, ".cfg"); file_open(game_config_file, game_config_filename, write); if(file_check_valid(game_config_file)) { u32 file_options[14]; file_options[0] = current_frameskip_type; file_options[1] = frameskip_value; file_options[2] = random_skip; file_options[3] = clock_speed; for(i = 0; i < 10; i++) { file_options[4 + i] = cheats[i].cheat_active; } file_write_array(game_config_file, file_options); file_close(game_config_file); return 0; } return -1; }
static int get_pth_filename(wchar_t *spbuffer, _PyPathConfig *config) { if (config->dll_path[0]) { if (!change_ext(spbuffer, config->dll_path, L"._pth") && exists(spbuffer)) { return 1; } } if (config->program_full_path[0]) { if (!change_ext(spbuffer, config->program_full_path, L"._pth") && exists(spbuffer)) { return 1; } } return 0; }
s32 load_game_config_file() { u8 game_config_filename[512]; u32 file_loaded = 0; u32 i; change_ext(gamepak_filename, game_config_filename, ".cfg"); file_open(game_config_file, game_config_filename, read); if(file_check_valid(game_config_file)) { u32 file_size = file_length(game_config_filename, game_config_file); // Sanity check: File size must be the right size if(file_size == 56) { u32 file_options[file_size / 4]; file_read_array(game_config_file, file_options); current_frameskip_type = file_options[0] % 3; frameskip_value = file_options[1]; random_skip = file_options[2] & 1; clock_speed = global_cycles_per_instruction = file_options[3]; if(frameskip_value < 0) frameskip_value = 0; if(frameskip_value > 99) frameskip_value = 99; file_close(game_config_file); file_loaded = 1; } } if(file_loaded) return 0; current_frameskip_type = auto_frameskip; frameskip_value = 0; random_skip = 0; clock_speed = 4; for(i = 0; i < 10; i++) { cheats[i].cheat_active = 0; } return -1; }
output_thingy *new_output(char *source_file) { output_thingy *out = (output_thingy *) malloc(sizeof *out); out->source_file = source_file; out->output_file = change_ext(source_file, out_ext); out->source_lines = 0; out->output_bytes = 0; out->data = NULL; out->output_pos = 0; return out; }
static _PyInitError calculate_path_impl(const _PyCoreConfig *core_config, PyCalculatePath *calculate, _PyPathConfig *config) { _PyInitError err; err = get_dll_path(calculate, config); if (_Py_INIT_FAILED(err)) { return err; } err = get_program_full_path(core_config, calculate, config); if (_Py_INIT_FAILED(err)) { return err; } /* program_full_path guaranteed \0 terminated in MAXPATH+1 bytes. */ wcscpy_s(calculate->argv0_path, MAXPATHLEN+1, config->program_full_path); reduce(calculate->argv0_path); wchar_t prefix[MAXPATHLEN+1]; memset(prefix, 0, sizeof(prefix)); /* Search for a sys.path file */ if (calculate_pth_file(config, prefix)) { goto done; } calculate_pyvenv_file(calculate); /* Calculate zip archive path from DLL or exe path */ change_ext(calculate->zip_path, config->dll_path[0] ? config->dll_path : config->program_full_path, L".zip"); calculate_home_prefix(calculate, prefix); err = calculate_module_search_path(core_config, calculate, config, prefix); if (_Py_INIT_FAILED(err)) { return err; } done: config->prefix = _PyMem_RawWcsdup(prefix); if (config->prefix == NULL) { return _Py_INIT_NO_MEMORY(); } return _Py_INIT_OK(); }
int options (char **argv, int *argc) { register int c; char *cp; char pid_string[30]; /* used with -x */ while ((c = getopt(argc, argv)) != -1) { switch (c) { case 'a': about(); break; case 'b': flags |= f_blunt; break; case 'c': flags |= f_compiler; break; case 'i': flags |= f_icmake; /* flag icmake taken literally */ if (!(source_name = getoptval(argc, argv))) error("-i requires source-filename"); return getoptindex(); /* and return the index of args */ /* to icm-exec */ case 'p': flags |= f_preprocessor; break; case 'q': flags |= f_quiet; /* no banner */ break; case 't': flags |= f_tmpbim | f_icmake; /* flag use temporary bimfile */ if (!(cp = getoptval(argc, argv))) error("-t requires temporary bim-filename"); while (*cp == ' ') /* skip initial blanks in optval*/ cp++; /* build pid-string */ sprintf(pid_string, "%d", getpid()); /* destination with pid-extension */ dest_name = xstrdup(change_ext(cp, pid_string)); strcat(pid_string, "a"); /* temp. pim-file extension */ temporary = xstrdup(change_ext(cp, pid_string)); source_name = argv[1]; return getoptindex() + 1; /* index of remaining args */ /* + 1 for the extra arg on the */ /* #!/...-x... line */ case '-': return getoptindex(); /* return index of args to icm-exec */ } } return *argc; /* return index of args to icm-exec */ }
void analyse_param_cds( int argc, char *argv[], long long* s, double *e, char *input, char *output_file) { int i; int g_data = -1; int g_e = 0; int g_s = 0; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { // seed case 's': i++; if (argc == i || argv[i][0] == '-') print_error_cds("cmd","s (seed number)"); *s = atoi(argv[i]); g_s = 1; break; // percentage of masked genotype case 'r': i++; if (argc == i || argv[i][0] == '-') print_error_cds("cmd","r (percentage of masked data)"); *e = (double) atof(argv[i]); if (*e < 0) *e = 0; if (*e > 1) *e = 1; g_e = 1; break; // help case 'h': print_help_cds(); exit(1); break; // licence case 'l': print_licence_snmf(); exit(1); break; // input file case 'x': i++; if (argc == i || argv[i][0] == '-') print_error_cds("cmd","x (genotype file)"); g_data = 0; strcpy(input,argv[i]); break; // output file case 'o': i++; if (argc == i || argv[i][0] == '-') print_error_cds("cmd","o (genotype file with masked genotypes)"); strcpy(output_file,argv[i]); break; default: print_error_cds("basic",NULL); } } else { print_error_cds("basic",NULL); } } // no data file if (g_data == -1) print_error_cds("option","-x genotype_file"); // no seed if (g_s && *s <= 0) *s = -1; // percentage not in [0,1] if (g_e && (*e <= 0 || *e >= 1)) print_error_cds("missing",""); // write output file name change_ext(input, output_file, "_I.geno"); }
static void calculate_path(void) { wchar_t argv0_path[MAXPATHLEN+1]; wchar_t *buf; size_t bufsz; wchar_t *pythonhome = Py_GetPythonHome(); wchar_t *envpath = NULL; int skiphome, skipdefault; wchar_t *machinepath = NULL; wchar_t *userpath = NULL; wchar_t zip_path[MAXPATHLEN+1]; if (!Py_IgnoreEnvironmentFlag) { envpath = _wgetenv(L"PYTHONPATH"); } get_progpath(); /* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */ wcscpy_s(argv0_path, MAXPATHLEN+1, progpath); reduce(argv0_path); /* Search for a sys.path file */ { wchar_t spbuffer[MAXPATHLEN+1]; if ((dllpath[0] && !change_ext(spbuffer, dllpath, L"._pth") && exists(spbuffer)) || (progpath[0] && !change_ext(spbuffer, progpath, L"._pth") && exists(spbuffer))) { if (!read_pth_file(spbuffer, prefix, &Py_IsolatedFlag, &Py_NoSiteFlag)) { return; } } } /* Search for an environment configuration file, first in the executable's directory and then in the parent directory. If found, open it for use when searching for prefixes. */ { wchar_t envbuffer[MAXPATHLEN+1]; wchar_t tmpbuffer[MAXPATHLEN+1]; const wchar_t *env_cfg = L"pyvenv.cfg"; FILE * env_file = NULL; wcscpy_s(envbuffer, MAXPATHLEN+1, argv0_path); join(envbuffer, env_cfg); env_file = _Py_wfopen(envbuffer, L"r"); if (env_file == NULL) { errno = 0; reduce(envbuffer); reduce(envbuffer); join(envbuffer, env_cfg); env_file = _Py_wfopen(envbuffer, L"r"); if (env_file == NULL) { errno = 0; } } if (env_file != NULL) { /* Look for a 'home' variable and set argv0_path to it, if found */ if (find_env_config_value(env_file, L"home", tmpbuffer)) { wcscpy_s(argv0_path, MAXPATHLEN+1, tmpbuffer); } fclose(env_file); env_file = NULL; } } /* Calculate zip archive path from DLL or exe path */ change_ext(zip_path, dllpath[0] ? dllpath : progpath, L".zip"); if (pythonhome == NULL || *pythonhome == '\0') { if (zip_path[0] && exists(zip_path)) { wcscpy_s(prefix, MAXPATHLEN+1, zip_path); reduce(prefix); pythonhome = prefix; } else if (search_for_prefix(argv0_path, LANDMARK)) pythonhome = prefix; else pythonhome = NULL; } else wcscpy_s(prefix, MAXPATHLEN+1, pythonhome); if (envpath && *envpath == '\0') envpath = NULL; skiphome = pythonhome==NULL ? 0 : 1; #ifdef Py_ENABLE_SHARED machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome); #endif /* We only use the default relative PYTHONPATH if we havent anything better to use! */ skipdefault = envpath!=NULL || pythonhome!=NULL || \ machinepath!=NULL || userpath!=NULL; /* We need to construct a path from the following parts. (1) the PYTHONPATH environment variable, if set; (2) for Win32, the zip archive file path; (3) for Win32, the machinepath and userpath, if set; (4) the PYTHONPATH config macro, with the leading "." of each component replaced with pythonhome, if set; (5) the directory containing the executable (argv0_path). The length calculation calculates #4 first. Extra rules: - If PYTHONHOME is set (in any way) item (3) is ignored. - If registry values are used, (4) and (5) are ignored. */ /* Calculate size of return buffer */ if (pythonhome != NULL) { wchar_t *p; bufsz = 1; for (p = PYTHONPATH; *p; p++) { if (*p == DELIM) bufsz++; /* number of DELIM plus one */ } bufsz *= wcslen(pythonhome); } else bufsz = 0; bufsz += wcslen(PYTHONPATH) + 1; bufsz += wcslen(argv0_path) + 1; if (userpath) bufsz += wcslen(userpath) + 1; if (machinepath) bufsz += wcslen(machinepath) + 1; bufsz += wcslen(zip_path) + 1; if (envpath != NULL) bufsz += wcslen(envpath) + 1; module_search_path = buf = PyMem_RawMalloc(bufsz*sizeof(wchar_t)); if (buf == NULL) { /* We can't exit, so print a warning and limp along */ fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); if (envpath) { fprintf(stderr, "Using environment $PYTHONPATH.\n"); module_search_path = envpath; } else { fprintf(stderr, "Using default static path.\n"); module_search_path = PYTHONPATH; } PyMem_RawFree(machinepath); PyMem_RawFree(userpath); return; } if (envpath) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), envpath)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); *buf++ = DELIM; } if (zip_path[0]) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), zip_path)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); *buf++ = DELIM; } if (userpath) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), userpath)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); *buf++ = DELIM; PyMem_RawFree(userpath); } if (machinepath) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), machinepath)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); *buf++ = DELIM; PyMem_RawFree(machinepath); } if (pythonhome == NULL) { if (!skipdefault) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), PYTHONPATH)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); *buf++ = DELIM; } } else { wchar_t *p = PYTHONPATH; wchar_t *q; size_t n; for (;;) { q = wcschr(p, DELIM); if (q == NULL) n = wcslen(p); else n = q-p; if (p[0] == '.' && is_sep(p[1])) { if (wcscpy_s(buf, bufsz - (buf - module_search_path), pythonhome)) Py_FatalError("buffer overflow in getpathp.c's calculate_path()"); buf = wcschr(buf, L'\0'); p++; n--; } wcsncpy(buf, p, n); buf += n; *buf++ = DELIM; if (q == NULL) break; p = q+1; } } if (argv0_path) { wcscpy(buf, argv0_path); buf = wcschr(buf, L'\0'); *buf++ = DELIM; } *(buf - 1) = L'\0'; /* Now to pull one last hack/trick. If sys.prefix is empty, then try and find it somewhere on the paths we calculated. We scan backwards, as our general policy is that Python core directories are at the *end* of sys.path. We assume that our "lib" directory is on the path, and that our 'prefix' directory is the parent of that. */ if (*prefix==L'\0') { wchar_t lookBuf[MAXPATHLEN+1]; wchar_t *look = buf - 1; /* 'buf' is at the end of the buffer */ while (1) { Py_ssize_t nchars; wchar_t *lookEnd = look; /* 'look' will end up one character before the start of the path in question - even if this is one character before the start of the buffer */ while (look >= module_search_path && *look != DELIM) look--; nchars = lookEnd-look; wcsncpy(lookBuf, look+1, nchars); lookBuf[nchars] = L'\0'; /* Up one level to the parent */ reduce(lookBuf); if (search_for_prefix(lookBuf, LANDMARK)) { break; } /* If we are out of paths to search - give up */ if (look < module_search_path) break; look--; } } }
//自動フィールドシフトが、動きを検出できない部分では正しく設定できないこともある static AUO_RESULT adjust_keyframe_as_afs_24fps(std::vector<int> &keyframe_list, const std::set<int> &keyframe_set, const OUTPUT_INFO *oip) { AUO_RESULT ret = AUO_RESULT_SUCCESS; #if 0 //デバッグ用 { const char * const MES_AFS_DEBUG = "Aviutl afs検出中…"; set_window_title(MES_AFS_DEBUG, PROGRESSBAR_CONTINUOUS); DWORD tm = 0, tm_prev = 0; char afs_csv_file[MAX_PATH_LEN] = { 0 }; strcpy_s(afs_csv_file, _countof(afs_csv_file), oip->savefile); change_ext(afs_csv_file, _countof(afs_csv_file), "x264guiEx_afs_log.csv"); FILE *fp_log = NULL; if (fopen_s(&fp_log, afs_csv_file, "wb") || fp_log == NULL) { write_log_auo_line(LOG_WARNING, "x264guiEx_afsログファイルを開けませんでした。"); } else { int drop = FALSE, next_jitter = 0; for (int i = 0; i < oip->n; i++) { afs_get_video((OUTPUT_INFO *)oip, i, &drop, &next_jitter); fprintf(fp_log, "%d\r\n%d,%d,", drop, next_jitter, 4*(i+1) + next_jitter); //進捗表示 (自動24fps化などしていると時間がかかる) if ((tm = timeGetTime()) - tm_prev > LOG_UPDATE_INTERVAL * 5) { set_log_progress(i / (double)oip->n); log_process_events(); tm_prev = tm; } } fclose(fp_log); } set_window_title(MES_AFS_DEBUG, PROGRESSBAR_DISABLED); } #endif //24fps化を仮定して設定し直す keyframe_list.clear(); const char * const MES_CHAPTER_AFS_ADJUST = "チャプター 補正計算中(afs 24fps化)..."; set_window_title(MES_CHAPTER_AFS_ADJUST, PROGRESSBAR_CONTINUOUS); int last_chapter = 0; for (auto keyframe : keyframe_set) { DWORD tm = 0, tm_prev = 0; const int check_start = (std::max)(0, ((keyframe - 300) / 5) * 5); int drop_count = 0; for (int i_frame = check_start, drop = FALSE, next_jitter = 0; i_frame < (std::min)(keyframe, oip->n); i_frame++) { afs_get_video((OUTPUT_INFO *)oip, i_frame, &drop, &next_jitter); drop_count += !!drop; //中断 if (oip->func_is_abort()) { ret |= AUO_RESULT_ABORT; write_log_auo_line(LOG_INFO, "Aviutl キーフレーム検出を中断しました。"); break; } //進捗表示 if ((tm = timeGetTime()) - tm_prev > LOG_UPDATE_INTERVAL * 5) { double progress_current_chapter = (i_frame - check_start) / (double)(keyframe - check_start); set_log_progress((last_chapter + progress_current_chapter * (keyframe - last_chapter)) / (double)oip->n); log_process_events(); tm_prev = tm; } } last_chapter = keyframe; keyframe_list.push_back(4*check_start/5 + (keyframe - check_start) - drop_count); } set_window_title(MES_CHAPTER_AFS_ADJUST, PROGRESSBAR_DISABLED); write_log_auo_line(LOG_INFO, "チャプター 補正計算(afs 24fps化)が完了しました。"); return ret; }
void fun_c_ext () { reg = *stringConstructor_cP( change_ext(stringStr(top()), stringStr(top() - 1)) ); }