int main(int argc, char** argv) { command_t cmd; command_init(&cmd, "dhcore-test", "1.0"); command_option_pos(&cmd, "test", "Choose unit test", TRUE, cmd_gettest); command_parse(&cmd, argc, argv, NULL); if (IS_FAIL(core_init(CORE_INIT_ALL))) { printf("core init error.\n"); return -1; } log_outputconsole(TRUE); if (g_testidx == -1) g_testidx = show_help(); if (g_testidx != -1) g_tests[g_testidx].test_fn(); #if defined(_DEBUG_) core_release(TRUE); #else core_release(FALSE); #endif return 1; }
int main(int argc, char** argv) { struct paki_args args; // read arguments memset(&args, 0x00, sizeof(args)); args.compress_mode = COMPRESS_NORMAL; command_t cmd; command_init(&cmd, argv[0], VERSION); command_option_pos(&cmd, "pakfile", "pakfile (.pak)", 0, cmdline_pakfile); command_option_pos(&cmd, "path", "path to input directory (for compress mode) or" " path to a file in pakfile (for extract mode)", 1, cmdline_path); command_option(&cmd, "-v", "--verbose", "enable verbose mode", cmdline_verbose); command_option(&cmd, "-l", "--list", "list files in pak", cmdline_list); command_option(&cmd, "-x", "--extract", "extract a file from pak", cmdline_extract); command_option(&cmd, "-c", "--compress", "compress a directory into pak", cmdline_compress); command_option(&cmd, "-z", "--zmode <mode>", "define compression mode, " "compression modes are (none, normal, best, fast)", cmdline_compressmode); cmd.data = &args; command_parse(&cmd, argc, argv, NULL); command_free(&cmd); core_init(CORE_INIT_ALL); log_outputconsole(TRUE); /* check for arguments validity */ if (args.pakfile[0] == 0 || ((BIT_CHECK(args.usage, PAKI_USAGE_EXTRACT) + BIT_CHECK(args.usage, PAKI_USAGE_COMPRESS) + BIT_CHECK(args.usage, PAKI_USAGE_LIST)) != 1)) { printf(TERM_BOLDRED "Invalid arguments\n" TERM_RESET); core_release(FALSE); return -1; } if (BIT_CHECK(args.usage, PAKI_USAGE_EXTRACT) || BIT_CHECK(args.usage, PAKI_USAGE_COMPRESS)) { if (str_isempty(args.path)) { printf(TERM_BOLDRED "'path' argument is not provided\n" TERM_RESET); core_release(FALSE); return -1; } } /* creating archive (-c flag) */ if (BIT_CHECK(args.usage, PAKI_USAGE_COMPRESS)) { save_pak(&args); } else if(BIT_CHECK(args.usage, PAKI_USAGE_EXTRACT)) { load_pak(&args); } else if(BIT_CHECK(args.usage, PAKI_USAGE_LIST)) { list_pak(&args); } #if defined(_DEBUG_) core_release(TRUE); #else core_release(FALSE); #endif return 0; }
int main(int argc, char** argv) { result_t r; memset(g_obj_barrels, 0x00, sizeof(g_obj_barrels)); /* Init core library */ r = core_init(CORE_INIT_ALL); /* After core init, you can set logging options */ log_outputconsole(TRUE); set_logfile(); /* load config file (json) */ init_params* params = app_config_default(); if (params == NULL) { err_sendtolog(FALSE); core_release(FALSE); return -1; } /* Add our stuff to init params * Engine's data directory must be changed */ params->flags |= (ENG_FLAG_CONSOLE | ENG_FLAG_DEV); /* Initialize application (graphics device and rendering window) * Application name will also, be the name of the main window */ r = app_init(APP_NAME, params); if (IS_FAIL(r)) { err_sendtolog(FALSE); core_release(FALSE); app_config_unload(params); return -1; } /* Initialize engine */ r = eng_init(params); /* init params isn't needed anymore */ app_config_unload(params); if (IS_FAIL(r)) { err_sendtolog(FALSE); eng_release(); app_release(); core_release(TRUE); return -1; } if (!init_scene()) { err_sendtolog(FALSE); eng_release(); app_release(); core_release(TRUE); return -1; } /* Set application callbacks */ app_window_setupdatefn(update_callback); app_window_setkeypressfn(keypress_callback); app_window_setactivefn(activate_callback); app_window_setresizefn(resize_callback); gfx_set_debug_renderfunc(debug_view_callback); /* Initialize ok: show the main window */ app_window_show(); /* Enter message loop and update engine */ app_window_run(); /* cleanup */ release_scene(); eng_release(); app_release(); core_release(TRUE); return 0; }