int main(int argc, char **argv) { char infile[MAX_FILENAME]; struct tailq queue; struct tailq_node *node; if (argc == 1) { file_add(&queue, "index.html"); } else if (argc == 2) { strncpy(infile, argv[1], MAX_FILENAME-1); extract_files(&queue, infile); } else { printf("usage: ./cr [in file]\n"); exit(-1); } node = queue.head; for (int i = 0; node; i++) { if (!populate_ref(&queue, node)) tailq_remove(&queue, node); node = node->next; } print_results(&queue); getchar(); printf("Bye!\n"); return 0; }
/* Summary: Extracts all important binaries and files from a disc to a given directory. Parameters: disc: Path to the disc to read from outpath: Directory to extract files to */ void extract(std::string disc, std::string outpath) { // Store the directories where files will be extracted std::string syspath = outpath + "/sys/"; std::string filepath = outpath + "/files/"; // Create the directories required boost::filesystem::create_directories(outpath); boost::filesystem::create_directories(syspath); boost::filesystem::create_directories(filepath); // Read the raw header and bi2 data std::vector<uint8_t> headerbin = util::read_file(disc, 0x440); std::vector<uint8_t> bi2bin = util::read_file(disc, 0x2000, 0x440); // Write out the header and bi2 data util::write_file(syspath + "header.bin", headerbin); util::write_file(syspath + "bi2.bin", bi2bin); // Extract each section of non-file data out extract_app(disc, syspath); extract_fst(disc, syspath); extract_dol(disc, syspath); // Extract the files extract_files(disc, filepath); }
/** * Extract metadata from files. * * @param item entry we are processing * @return GNUNET_OK on success, GNUNET_SYSERR on fatal errors */ static int extract_files (struct ScanTreeNode *item) { struct GNUNET_CONTAINER_MetaData *meta; ssize_t size; size_t slen; if (GNUNET_YES == item->is_directory) { /* for directories, we simply only descent, no extraction, no progress reporting */ struct ScanTreeNode *pos; for (pos = item->children_head; NULL != pos; pos = pos->next) if (GNUNET_OK != extract_files (pos)) return GNUNET_SYSERR; return GNUNET_OK; } /* this is the expensive operation, *afterwards* we'll check for aborts */ meta = GNUNET_CONTAINER_meta_data_create (); if (NULL != plugins) EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); slen = strlen (item->filename) + 1; size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); if (-1 == size) { /* no meta data */ GNUNET_CONTAINER_meta_data_destroy (meta); if (GNUNET_OK != write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, item->filename, slen)) return GNUNET_SYSERR; return GNUNET_OK; } { char buf[size + slen]; char *dst = &buf[slen]; memcpy (buf, item->filename, slen); size = GNUNET_CONTAINER_meta_data_serialize (meta, &dst, size, GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); if (size < 0) { GNUNET_break (0); size = 0; } GNUNET_CONTAINER_meta_data_destroy (meta); if (GNUNET_OK != write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, buf, slen + size)) return GNUNET_SYSERR; } return GNUNET_OK; }
/** Extracts the images in a cgCompress file to a directory with the same * name. Directory must not exist beforehand. * * \param [in] filename File path to cgCompress file * \param [in] format The format for the extracted files */ void extract_cgcompress( QString filename, Format format ){ QFileInfo file( filename ); QDir current( file.dir() ); if( !current.mkdir( file.baseName() ) ){ qWarning( "Could not create directory for extracting" ); return; } current.cd( file.baseName() ); for( auto file2 : extract_files( filename ) ) format.save( file2.second, current.absolutePath() + "/" + file.baseName() + file2.first + "." + file.suffix() ); }
ProjectCollector::ProjectCollector( const path& p, const std::string& configuration_name ) : m_path( p ), m_configuration_name( configuration_name ) { std::cout << m_path.string() << std::endl; m_current_path = m_path.parent_path(); m_str = Utility::get_string_from_file( m_path ); //std::cout << m_current_path.string() << std::endl; if ( false == m_str.empty() ) { extract_files(); extract_additional_include_directories(); } }
int main(int argc, char *argv[]) { if(argc > 1){ FILE * fp; fp = fopen(argv[1], "r"); if(fp == NULL) { printf("File does not exist!\n"); exit(EXIT_FAILURE); } read_files(fp); print_file_data(); extract_files(); fclose(fp); exit(EXIT_SUCCESS); } else { printf("Usage: ./tar filename\n"); exit(EXIT_FAILURE); } }
static int extract_run (void) { TrackerVerbosity verbosity_level = TRACKER_VERBOSITY_ERRORS; if (verbosity) { if (g_ascii_strcasecmp (verbosity, "debug") == 0) { verbosity_level = TRACKER_VERBOSITY_DEBUG; } else if (g_ascii_strcasecmp (verbosity, "detailed") == 0) { verbosity_level = TRACKER_VERBOSITY_DETAILED; } else if (g_ascii_strcasecmp (verbosity, "minimal") == 0) { verbosity_level = TRACKER_VERBOSITY_MINIMAL; } else if (g_ascii_strcasecmp (verbosity, "errors") == 0) { verbosity_level = TRACKER_VERBOSITY_ERRORS; } else { g_printerr ("%s\n", _("Invalid log verbosity, try “debug”, “detailed”, “minimal” or “errors”")); return EXIT_FAILURE; } } return extract_files (verbosity_level, output_format); }
jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative (JNIEnv* env, jobject clazz, jstring dataDir, jstring cacheDir, jstring apkFile) { struct stat st; int fd; const char *dataDirPath; const char *cacheDirPath; const char *apkFilePath; const char program_dir[] = "/program"; size_t data_dir_len; (void) clazz; dataDirPath = (*env)->GetStringUTFChars(env, dataDir, NULL); data_dir = strdup(dataDirPath); (*env)->ReleaseStringUTFChars(env, dataDir, dataDirPath); cacheDirPath = (*env)->GetStringUTFChars(env, cacheDir, NULL); cache_dir = strdup(cacheDirPath); (*env)->ReleaseStringUTFChars(env, cacheDir, cacheDirPath); apkFilePath = (*env)->GetStringUTFChars(env, apkFile, NULL); fd = open(apkFilePath, O_RDONLY); if (fd == -1) { LOGE("Could not open %s", apkFilePath); (*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath); return JNI_FALSE; } if (fstat(fd, &st) == -1) { LOGE("Could not fstat %s", apkFilePath); close(fd); (*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath); return JNI_FALSE; } apk_file = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); close(fd); if (apk_file == MAP_FAILED) { LOGE("Could not mmap %s", apkFilePath); (*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath); return JNI_FALSE; } apk_file_size = st.st_size; (*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath); if (!setup_cdir()) { LOGE("setup_cdir failed"); return JNI_FALSE; } if (!setup_assets_tree()) { LOGE("setup_assets_tree failed"); return JNI_FALSE; } // Extract files from the .apk that can't be used mmapped directly from it extract_files(UNPACK_TREE, UNPACK_TREE, 0); extract_files(UNPACK_TREE_GZ, UNPACK_TREE_GZ, 1); // LibreOfficeKit expects a path to the program/ directory free(full_program_dir); data_dir_len = strlen(data_dir); full_program_dir = malloc(data_dir_len + sizeof(program_dir)); strncpy(full_program_dir, data_dir, data_dir_len); strncpy(full_program_dir + data_dir_len, program_dir, sizeof(program_dir)); // Initialize LibreOfficeKit if (!libreofficekit_hook(full_program_dir)) { LOGE("libreofficekit_hook returned null"); return JNI_FALSE; } LOGI("LibreOfficeKit successfully initialized"); return JNI_TRUE; }
/** * Main function of the helper process to extract meta data. * * @param argc should be 3 * @param argv [0] our binary name * [1] name of the file or directory to process * [2] "-" to disable extraction, NULL for defaults, * otherwise custom plugins to load from LE * @return 0 on success */ int main (int argc, char *const *argv) { const char *filename_expanded; const char *ex; struct ScanTreeNode *root; #if WINDOWS /* We're using stdout to communicate binary data back to the parent; use * binary mode. */ _setmode (1, _O_BINARY); /* Get utf-8-encoded arguments */ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) return 5; output_stream = 1; /* stdout */ #else ignore_sigpipe (); /* move stdout to some other FD for IPC, bind stdout/stderr to /dev/null */ output_stream = dup (1); make_dev_zero (1, O_WRONLY); make_dev_zero (2, O_WRONLY); #endif /* parse command line */ if ( (3 != argc) && (2 != argc) ) { FPRINTF (stderr, "%s", "gnunet-helper-fs-publish needs exactly one or two arguments\n"); #if WINDOWS GNUNET_free ((void*) argv); #endif return 1; } filename_expanded = argv[1]; ex = argv[2]; if ( (NULL == ex) || (0 != strcmp (ex, "-")) ) { #if HAVE_LIBEXTRACTOR plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); if (NULL != ex) plugins = EXTRACTOR_plugin_add_config (plugins, ex, EXTRACTOR_OPTION_DEFAULT_POLICY); #endif } /* scan tree to find out how much work there is to be done */ if (GNUNET_OK != preprocess_file (filename_expanded, &root)) { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); #if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); #endif #if WINDOWS GNUNET_free ((void*) argv); #endif return 2; } /* signal that we're done counting files, so that a percentage of progress can now be calculated */ if (GNUNET_OK != write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) { #if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); #endif #if WINDOWS GNUNET_free ((void*) argv); #endif return 3; } if (NULL != root) { if (GNUNET_OK != extract_files (root)) { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); free_tree (root); #if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); #endif #if WINDOWS GNUNET_free ((void*) argv); #endif return 4; } free_tree (root); } /* enable "clean" shutdown by telling parent that we are done */ (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); #if HAVE_LIBEXTRACTOR EXTRACTOR_plugin_remove_all (plugins); #endif #if WINDOWS GNUNET_free ((void*) argv); #endif return 0; }
/** * Main function of the helper process to extract meta data. * * @param argc should be 3 * @param argv [0] our binary name * [1] name of the file or directory to process * [2] "-" to disable extraction, NULL for defaults, * otherwise custom plugins to load from LE * @return 0 on success */ int main(int argc, char **argv) { const char *filename_expanded; const char *ex; struct ScanTreeNode *root; #if WINDOWS /* We're using stdout to communicate binary data back to the parent; use * binary mode. */ _setmode (1, _O_BINARY); #endif /* parse command line */ if ( (3 != argc) && (2 != argc) ) { FPRINTF (stderr, "%s", "gnunet-helper-fs-publish needs exactly one or two arguments\n"); return 1; } filename_expanded = argv[1]; ex = argv[2]; if ( (NULL == ex) || (0 != strcmp (ex, "-")) ) { plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); if (NULL != ex) plugins = EXTRACTOR_plugin_add_config (plugins, ex, EXTRACTOR_OPTION_DEFAULT_POLICY); } /* scan tree to find out how much work there is to be done */ if (GNUNET_OK != preprocess_file (filename_expanded, &root)) { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); return 2; } /* signal that we're done counting files, so that a percentage of progress can now be calculated */ if (GNUNET_OK != write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) return 3; if (NULL != root) { if (GNUNET_OK != extract_files (root)) { (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); free_tree (root); return 4; } free_tree (root); } /* enable "clean" shutdown by telling parent that we are done */ (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); if (NULL != plugins) EXTRACTOR_plugin_remove_all (plugins); return 0; }
static int install_package(char *pkgname, struct pkgdb *db, int options) { char url[STRLEN]; FILE *f; int rc; char inffile[STRLEN]; struct section *manifest; struct section *dep; struct section *build; struct pkg *pkg; char *description; int time; // Check if package is already installed if (!(options & FROM_FILE)) { pkg = find_package(db, pkgname); if (pkg) { if (options & UPGRADE) { if (pkg->time == pkg->avail) return 0; } else if (options & DEPENDENCY) { return 0; } else if (options & UPDATE) { if (options & VERBOSE) printf("updating package %s\n", pkgname); } else { printf("package %s is already installed\n", pkgname); return 0; } } } // Open package file printf("Fetching %s\n", pkgname); if (options & FROM_FILE) { snprintf(url, sizeof(url), "file:///%s", pkgname); } else { snprintf(url, sizeof(url), "%s/%s.pkg", db->repo, pkgname); } if (options & VERBOSE) printf("fetching package %s from %s\n", pkgname, url); f = open_url(url, "pkg"); if (!f) return 1; // Extract file from package file time = 0; rc = extract_files(url, f, inffile, options & VERBOSE, &time); fclose(f); if (rc != 0) return rc; // Read manifest if (options & VERBOSE) printf("reading manifest from %s\n", inffile); manifest = read_properties(inffile); if (!manifest) { fprintf(stderr, "%s: unable to read manifest\n", inffile); return 1; } // Add package to package database pkgname = get_property(manifest, "package", "name", pkgname); description = get_property(manifest, "package", "description", NULL); pkg = find_package(db, pkgname); if (pkg) { if (options & VERBOSE) printf("updating package %s in database\n", pkgname); if (description) { free(pkg->description); pkg->description = strdup(description); db->dirty = 1; } if (pkg->manifest) free_properties(pkg->manifest); free(pkg->inffile); } else { if (options & VERBOSE) printf("adding package %s to database\n", pkgname); pkg = add_package(db, pkgname, description); } pkg->inffile = strdup(inffile); pkg->manifest = manifest; if (time != pkg->time) { pkg->time = time; db->dirty = 1; } // Install package dependencies dep = find_section(manifest, "dependencies"); if (dep) { struct property *p; for (p = dep->properties; p; p = p->next) { if (options & VERBOSE) printf("package %s depends on %s\n", pkgname, p->name); rc = install_package(p->name, db, options | DEPENDENCY); if (rc != 0) return rc; } } if ((options & ONLY_FETCH) && !(options & DEPENDENCY)) return 0; // Run package build/installation commands if (!(options & ONLY_FETCH) || (options & DEPENDENCY)) { build = find_section(manifest, (options & ONLY_BUILD) && !(options & DEPENDENCY) ? "build" : "install"); if (build) { struct property *p; printf((options & ONLY_BUILD) && !(options & DEPENDENCY) ? "Building %s\n" : "Installing %s\n", pkgname); for (p = build->properties; p; p = p->next) { if (options & VERBOSE) printf("%s\n", p->name); rc = system(p->name); if (rc != 0) { fprintf(stderr, "%s: build failed\n", pkgname); return rc; } } } } return 0; }
int main (int argc, char **argv) { /* Program requires >= 4 arguments */ if(argc < 3) usage(stderr, argv[0], "Insufficient arguments", 1); /* Variable to hold flag currently * being ready by getopt() */ int c; int operation_alters_arch = 0; unsigned int timeout = 0; /* Struct for use with GNU getopt_long() */ struct option longopts[] = { { "quick", no_argument, 0, 'q' }, { "extract", no_argument, 0, 'x' }, { "contents", no_argument, 0, 't' }, { "verbose", no_argument, 0, 'v' }, { "delete", no_argument, 0, 'd' }, { "append", no_argument, 0, 'A' }, { "when", required_argument, 0, 'w' }, { 0, 0, 0, 0 } }; int opt_index = 0; /* * Loop adapted from example given at * http://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html * * Loop through command line arguments, incrementing * 'seen' when we encounter a mandatory argument. * * All options besides '-v' require an argument. */ while((c = getopt_long(argc, argv, "qxtvdAw:", longopts, &opt_index)) != -1) { switch(c) { case 'q': case 'x': case 't': case 'v': case 'd': case 'A': case 'w': if(operation != none) { fprintf(stderr, "two different operation options specified\n"); exit(EXIT_FAILURE); } break; } switch(c) { case 'q': operation_alters_arch = 1; operation = append; break; case 'x': operation = extract; break; case 't': operation = contents; break; case 'v': operation = verbose; break; case 'd': operation_alters_arch = 1; operation = delete; break; case 'A': operation_alters_arch = 1; operation = append_all; break; case 'w': operation_alters_arch = 1; operation = append_all; timeout = strtoul(optarg, 0, 10); break; case('?'): default: usage(stderr, argv[0], "unrecognized option", 1); break; } } /* Print usage and exit if no operation * was given */ if(operation == none) usage(stderr, argv[0], "'none' operation specified", 1); /* Array for remaining arguments. * Assumes remaining arguments * are filepaths. */ int count = argc - optind - 1; char *archname = argv[optind++]; if(archname == NULL) usage(stderr, argv[0], "no archive file specified", 1); int arch; /* Temporarily set umask to 0000 in order to * create file with permissions 0666 using * DFLTMODE */ umask(0000); if((operation == append || operation == append_all) && access(archname, R_OK | W_OK) == -1) { printf("%s: creating %s\n", argv[0], archname); arch = open(archname, O_CREAT | O_RDWR, DFLTMODE); } else { arch = open(archname, O_RDWR, DFLTMODE); } umask(DFLTUMASK); if(arch == -1) { fprintf(stderr, "error opening archive\n"); perror("open"); exit(EXIT_FAILURE); } if(isempty(archname)) write_armag(arch); char *files[count]; int i; for(i = 0; optind < argc; i++, optind++) files[i] = argv[optind]; switch(operation) { case append: append_files(arch, archname, files, count); break; case append_all: if(count != 0 && timeout == 0) usage(stderr, argv[0], "-A option takes no arguments", 1); else if(count != 0) usage(stderr, argv[0], "-w option takes no arguments", 1); append_all_files(arch, archname, timeout, &is_reg_file); break; case extract: extract_files(arch, files, count); break; case contents: map_over_members(arch, &print_member_concise, files, count, -1); break; case verbose: map_over_members(arch, &print_member_verbose, files, count, -1); break; case delete: delete_files(arch, archname, files, count); break; case none: default: usage(stderr, argv[0], "no operation option specified", 1); } if(operation_alters_arch != 1) { if(close(arch) == -1) { fprintf(stderr, "failed to close archive %s\n", archname); perror("close"); exit(EXIT_FAILURE); } } return 0; }
/****************************************************************************** * extract_files_app: create window * * @param hInstance * @param hPrevInstance * @param nCmdShow ******************************************************************************/ static int WINAPI extract_files_app (HINSTANCE hInstance, HINSTANCE hPrevInstance, int nCmdShow) { WNDCLASSEX wc; const char szClassName[] = "MentorExtractorWinClass"; MSG Msg; HWND hwnd; unsigned int threadID; int return_value; if (g_console_install == TRUE || g_nosplash == TRUE) { /* Separate thread not created when a window isn't created */ return_value = extract_files(NULL); fclose(g_logFile); log_message("Successfully exiting extraction app\n"); log_message("------------------------------------\n\n"); return(return_value); } else { //Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = splash_wnd_proc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); log_message("Error: Window Registration Failed!"); fclose(g_logFile); return -1; } /* Get BMP information from bitmap header */ g_image_buffer = splash_bmp + *((unsigned int *)(splash_bmp + BMP_IMAGE_DATA_OFFSET)); g_bitmap_width = *((unsigned int *)(splash_bmp + BMP_IMAGE_WIDTH_OFFSET)); g_bitmap_height = *((unsigned int *)(splash_bmp + BMP_IMAGE_HEIGHT_OFFSET)); /* Create the Window */ hwnd = CreateWindowEx( 0, szClassName, "P2 Installer extracting files ...", WS_POPUP|WS_VISIBLE|WS_SYSMENU, /* WS_VISIBLE, */ GetSystemMetrics(SM_CXSCREEN)/2-g_bitmap_width/2, GetSystemMetrics(SM_CYSCREEN)/2-g_bitmap_height/2, g_bitmap_width - 1, g_bitmap_height - 1, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "P2 Extraction Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); log_message("Error: Window Creation Failed!\n"); fclose(g_logFile); return -1; } ShowWindow(hwnd, nCmdShow); return_value = UpdateWindow(hwnd); if (return_value == 0) { log_message("Error: UpdateWindow failed"); fclose(g_logFile); return -1; } /* Create thread to extract files */ return_value = _beginthreadex(NULL, STACK_SIZE, (unsigned (__stdcall *)( void * ))extract_files, (void *)hwnd, 0, &threadID); if (return_value == 0) { log_message("Error: Unable to start thread. Errno value: %d\n", strerror (errno)); fclose(g_logFile); return -1; } // The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } log_message("Successfully exiting extraction app\n"); log_message("------------------------------------\n\n"); fclose(g_logFile); return Msg.wParam; } }
void pre_main(void) { #ifdef DEBUG_LOG char debug_fname[1024]; retro_create_path_string(debug_fname, sizeof(debug_fname), g_dir, "debug.txt"); SetLogFilename(debug_fname); #endif // start up inputs first thing because settings_load may remap them input_init(); // load settings, or at least get the defaults, // so we know the initial screen resolution. settings_load(); char filename[1024]; FILE *fp; NX_LOG("= Extracting Files =\n"); retro_create_path_string(filename, sizeof(filename), g_dir, "Doukutsu.exe"); fp = fopen(filename, "rb"); extract_files(fp); if (sound_init()) { fatal("Failed to initialize sound."); error = 1; return; } extract_stages(fp); fclose(fp); settings->files_extracted = true; settings_save(); if (Graphics::init(settings->resolution)) { NX_ERR("Failed to initialize graphics.\n"); error = 1; return; } if (font_init()) { NX_ERR("Failed to load font.\n"); error = 1; return; } //return; if (check_data_exists()) { error = 1; return; } //Graphics::ShowLoadingScreen(); if (trig_init()) { fatal("Failed trig module init."); error = 1; return; } if (tsc_init()) { fatal("Failed to initialize script engine."); error = 1; return; } if (textbox.Init()) { fatal("Failed to initialize textboxes."); error = 1; return; } if (Carets::init()) { fatal("Failed to initialize carets."); error = 1; return; } if (game.init()) { error = 1; return; } game.setmode(GM_NORMAL); // set null stage just to have something to do while we go to intro game.switchstage.mapno = 0; //#define REPLAY #ifdef REPLAY game.switchstage.mapno = START_REPLAY; //Replay::set_ffwd(6000); //Replay::set_stopat(3500); game.switchstage.param = 1; #else //game.switchstage.mapno = LOAD_GAME; //game.pause(GP_OPTIONS); if (settings->skip_intro && file_exists(GetProfileName(settings->last_save_slot))) game.switchstage.mapno = LOAD_GAME; else game.setmode(GM_INTRO); #endif // for debug if (game.paused) { game.switchstage.mapno = 0; game.switchstage.eventonentry = 0; } if (game.switchstage.mapno == LOAD_GAME) inhibit_loadfade = true; game.running = true; freshstart = true; NX_LOG("Entering main loop...\n"); //return; }
/* * A small programm to extract a Quake II pak file. * The pak file is given as the first an only * argument. */ int main(int argc, char *argv[]) { directory *d = NULL; FILE *fd = NULL; const char* filename = NULL; int list_only = 0; int i = 0; int num_entries = 0; /* Correct usage? */ if (argc < 2) { printUsage(argv[0]); exit(-1); } const char* out_dir = NULL; for(i=1; i<argc; ++i) { const char* arg = argv[i]; if(strcmp(arg, "-l") == 0) list_only = 1; else if(strcmp(arg, "-dk") == 0) dk_pak_mode = 1; else if(strcmp(arg, "-o") == 0) { ++i; // go to next argument (should be out_dir) if(i == argc || argv[i][0] == '-') // no further argument/next argument option? { fprintf(stderr, "!! -o must be followed by output dir !!\n"); printUsage(argv[0]); exit(-1); } out_dir = argv[i]; } else { if(filename != NULL) // we already set a filename, wtf { fprintf(stderr, "!! Illegal argument '%s' (or too many filenames) !!\n", arg); printUsage(argv[0]); exit(-1); } filename = arg; } } if(filename == NULL) { fprintf(stderr, "!! No filename given !!\n"); printUsage(argv[0]); exit(-1); } /* Open the pak file */ fd = fopen(filename, "r"); if (fd == NULL) { fprintf(stderr, "Could not open the pak file '%s': %s\n", filename, strerror(errno)); exit(-1); } /* Read the header */ if (!read_header(fd)) { fclose(fd); exit(-1); } /* Read the directory */ d = read_directory(fd, list_only, &num_entries); if (d == NULL) { fclose(fd); exit(-1); } if (out_dir != NULL) { if (chdir(out_dir) != 0) { perror("Could not cd to output dir"); exit(-1); } } if (!list_only) { /* And now extract the files */ extract_files(fd, d, num_entries); } /* cleanup */ fclose(fd); free(d); return 0; }