/* (Triforce, 11-24) The arguments a supervisor of the preparation gives a --prepare-shaders run (gpu/vk/prepare_journal.h; the supervisor itself is not in Triforce yet). Each takes one value and reaches the renderer as a switch, as the renderer is handed no command line: --prepare-journal HOOKSHOT_PREPARE_JOURNAL a line before and after each driver compile call (gpu/vk/prepare_journal.h) --prepare-from HOOKSHOT_PREPARE_FROM started again past entry n: numbers go on from n + 1, and the run before is not counted against the steps' crash markers --prepare-skip HOOKSHOT_PREPARE_SKIP the programs left out ("skip ") and the suspects built one at a time ("alone ") --prepare-entry-limit HOOKSHOT_PREPARE_ENTRY_S seconds one entry gets inside the driver before the run ends itself with exit status 6 Paths are UTF-8, as every path of the game (the exe's manifest on Windows). */ #ifndef HOS_PREPARE_ARGS_H #define HOS_PREPARE_ARGS_H #include #include #include /* The switch an argument sets with its value, or NULL: not one of these */ static inline const char *hos_prepare_arg_switch(const char *arg) { if (!strcmp(arg, "--prepare-journal")) return "HOOKSHOT_PREPARE_JOURNAL"; if (!strcmp(arg, "--prepare-from")) return "HOOKSHOT_PREPARE_FROM"; if (!strcmp(arg, "--prepare-skip")) return "HOOKSHOT_PREPARE_SKIP"; if (!strcmp(arg, "--prepare-entry-limit")) return "HOOKSHOT_PREPARE_ENTRY_S"; return NULL; } /* Every such argument of the command line set as its switch, wherever it stands (before the renderer is loaded) */ static inline void hos_prepare_args_env(int argc, char **argv) { for (int i = 1; i + 1 < argc; i++) { const char *name = hos_prepare_arg_switch(argv[i]); if (!name) continue; const char *value = argv[++i]; #ifdef _WIN32 const size_t size = strlen(name) + strlen(value) + 2; char *set = (char *)malloc(size); if (!set) continue; snprintf(set, size, "%s=%s", name, value); _putenv(set); /* (copied by the C runtime) */ free(set); #else setenv(name, value, 1); #endif } } #endif