//---------------------------------------------------------------------------- // SAXParsor::start //---------------------------------------------------------------------------- void SAXParsor::start(const std::string& document_path, INodeAnalyser* pRootAnalyser) { CDMA_STATIC_FUNCTION_TRACE("SAXParsor::start"); static bool sbLibXmlInit = false; yat::log_info("cfg", "Loading XML file %s", PSZ(document_path)); if( false == sbLibXmlInit ) { // this initialize the library and check potential API mismatches // between the version it was compiled for and the actual shared // library used. // Since we can't initialize the library more than once // use a static bool to ensure this LIBXML_TEST_VERSION sbLibXmlInit = true; // Initialize threads stuff xmlInitThreads(); // To ensure that library will work in a multithreaded program xmlInitParser(); } // Read xml file and build document in memory xmlDoc *pDoc = xmlReadFile(PSZ(document_path), NULL, 0); if( NULL == pDoc ) { THROW_LIBXML2_EXCEPTION("Error while loading document", "SAXParsor::Start"); } // Apply xinclude subsitution int iRc = xmlXIncludeProcess(pDoc); if( iRc >= 0 ) { xmlErrorPtr ptrError = xmlGetLastError(); if( ptrError && ptrError->level > 1 ) { THROW_LIBXML2_EXCEPTION(yat::String::str_format("Error while parsing xml document: %s", ptrError->message), "SAXParsor::Start"); } // Retreive root element xmlNode *pRootNode = xmlDocGetRootElement(pDoc); // Start parsing giving a ConfigAnalyser as nodes interpretor yat::log_info("cfg", "Parsing configuration"); instance().parse_node(pRootNode, pRootAnalyser); } // Free the document xmlFreeDoc(pDoc); if( iRc < 0 ) // Error occured when applying xinclude subsitution THROW_LIBXML2_EXCEPTION("Error while applying xinclude subsitution", "SAXParsor::Start"); }
/** * Start engine. * */ engine_type * engine_start(const char* cfgfile, int cmdline_verbosity, int daemonize, int info) { engine_type* engine = NULL; int use_syslog = 0; ods_status status = ODS_STATUS_OK; ods_log_assert(cfgfile); ods_log_init(NULL, use_syslog, cmdline_verbosity); ods_log_verbose("[%s] starting enforcer", engine_str); /* initialize */ xmlInitGlobals(); xmlInitParser(); xmlInitThreads(); engine = engine_create(); if (!engine) { ods_fatal_exit("[%s] create failed", engine_str); return NULL; } engine->daemonize = daemonize; /* config */ engine->config = engine_config(engine->allocator, cfgfile, cmdline_verbosity); status = engine_config_check(engine->config); if (status != ODS_STATUS_OK) { ods_log_error("[%s] cfgfile %s has errors", engine_str, cfgfile); engine_stop(engine); return NULL; } if (info) { engine_config_print(stdout, engine->config); /* for debugging */ engine_stop(engine); return NULL; } /* open log */ ods_log_init(engine->config->log_filename, engine->config->use_syslog, engine->config->verbosity); /* setup */ tzset(); /* for portability */ /* initialize protobuf and protobuf-orm */ ods_protobuf_initialize(); ods_orm_initialize(); return engine; }
/** * Start engine. * */ void engine_start(const char* cfgfile, int cmdline_verbosity, int daemonize, int info, int single_run) { engine_type* engine = NULL; int use_syslog = 0; ods_status zl_changed = ODS_STATUS_UNCHANGED; ods_status status = ODS_STATUS_OK; int close_hsm = 0; ods_log_assert(cfgfile); ods_log_init(NULL, use_syslog, cmdline_verbosity); ods_log_verbose("[%s] starting signer", engine_str); /* initialize */ xmlInitGlobals(); xmlInitParser(); xmlInitThreads(); engine = engine_create(); if (!engine) { ods_fatal_exit("[%s] create failed", engine_str); return; } engine->daemonize = daemonize; /* config */ engine->config = engine_config(engine->allocator, cfgfile, cmdline_verbosity); status = engine_config_check(engine->config); if (status != ODS_STATUS_OK) { ods_log_error("[%s] cfgfile %s has errors", engine_str, cfgfile); goto earlyexit; } if (info) { engine_config_print(stdout, engine->config); /* for debugging */ goto earlyexit; } /* check pidfile */ if (!util_check_pidfile(engine->config->pid_filename)) { exit(1); } /* open log */ ods_log_init(engine->config->log_filename, engine->config->use_syslog, engine->config->verbosity); /* setup */ tzset(); /* for portability */ status = engine_setup(engine); if (status != ODS_STATUS_OK) { ods_log_error("[%s] setup failed: %s", engine_str, ods_status2str(status)); engine->need_to_exit = 1; if (status != ODS_STATUS_WRITE_PIDFILE_ERR) { /* command handler had not yet been started */ engine->cmdhandler_done = 1; } } else { /* setup ok, mark hsm open */ close_hsm = 1; } /* run */ while (engine->need_to_exit == 0) { /* update zone list */ lock_basic_lock(&engine->zonelist->zl_lock); zl_changed = zonelist_update(engine->zonelist, engine->config->zonelist_filename); engine->zonelist->just_removed = 0; engine->zonelist->just_added = 0; engine->zonelist->just_updated = 0; lock_basic_unlock(&engine->zonelist->zl_lock); /* start/reload */ if (engine->need_to_reload) { ods_log_info("[%s] signer reloading", engine_str); engine->need_to_reload = 0; } else { ods_log_info("[%s] signer started", engine_str); zl_changed = engine_recover(engine); } if (zl_changed == ODS_STATUS_OK || zl_changed == ODS_STATUS_UNCHANGED) { engine_update_zones(engine, zl_changed); } engine_run(engine, single_run); } /* shutdown */ ods_log_info("[%s] signer shutdown", engine_str); if (close_hsm) { ods_log_verbose("[%s] close hsm", engine_str); hsm_close(); } if (!engine->cmdhandler_done) { engine_stop_xfrhandler(engine); engine_stop_dnshandler(engine); engine_stop_cmdhandler(engine); } earlyexit: if (engine && engine->config) { if (engine->config->pid_filename) { (void)unlink(engine->config->pid_filename); } if (engine->config->clisock_filename) { (void)unlink(engine->config->clisock_filename); } } tsig_handler_cleanup(); engine_cleanup(engine); engine = NULL; ods_log_close(); xmlCleanupParser(); xmlCleanupGlobals(); xmlCleanupThreads(); return; }
/* point-of-entry */ int main(int argc, char **argv) { int ret = -1, c, index, action = ACTION_NONE, tmp; char *action_param = NULL; processor_config_t *config = 0, *config2 = 0; char *conf_file = 0; int load_autoreg = 0; int flag_quiet = 0; int log_to_file = 0; int console_only = 0; int do_test = 0; // do whatever the test of the day is xmlInitParser(); xmlInitThreads(); //initGenericErrorDefaultFunc((xmlGenericErrorFunc *)xml_error_func); /* the getopt values */ static struct option long_options[] = { {"verbose", no_argument, 0, 0}, {"iface", required_argument, 0, 0}, {"threads", required_argument, 0, 0}, {"help", no_argument, 0, 0}, {"version", no_argument, 0, 0}, {"console", no_argument, 0, 0}, #ifdef CONFIG_PYTHON_ENABLED {"shell", no_argument, 0, 0}, {"run", required_argument, 0, 0}, {"no-scripts", no_argument, 0, 0}, #endif #ifdef CONFIG_SIP_ENABLED {"proxy-iface", required_argument, 0, 0}, {"no-mp", no_argument, 0, 0}, {"tunnel-mp", no_argument, 0, 0}, {"force-mp", no_argument, 0, 0}, {"allow-unknown", no_argument, 0, 0}, {"allow-untrusted", no_argument, 0, 0}, #endif {"list-ca", no_argument, 0, 0}, {"import-ca", required_argument, 0, 0}, {"remove-ca", required_argument, 0, 0}, {"list", no_argument, 0, 0}, {"import", required_argument, 0, 0}, {"remove", required_argument, 0, 0}, {"idents", required_argument, 0, 0}, {"log", required_argument, 0, 0}, #ifdef CONFIG_BROADCAST_ENABLED {"bc-addr", required_argument, 0, 0}, #endif #ifdef CONFIG_WEBCONF_ENABLED {"webconf", required_argument, 0, 0}, #endif #ifdef CONFIG_OPENDHT_ENABLED {"opendht", required_argument, 0, 0}, #endif #ifdef CONFIG_HIP_ENABLED {"list-hits", no_argument, 0, 0}, {"rvs", required_argument, 0, 0}, {"provide-rvs", no_argument, 0, 0}, #endif {0, 0, 0, 0} }; #ifdef LOCK_DEBUG debug2_init(); #endif #ifdef REF_DEBUG2 ship_debug_initref(); #endif if (!(config = processor_config_new()) || !(config2 = processor_config_new())) { USER_ERROR("Error loading application\n"); goto err; } if (processor_config_load_defaults(config2)) { USER_ERROR("Error loading default configurations\n"); goto err; } processor_config_get_string(config2, P2PSHIP_CONF_CONF_FILE, &conf_file); opterr = 0; while ((c = getopt_long(argc, argv, "LqvhDVs:c:p:i:Rr:kKt", long_options, &index)) != -1) { if (!c) { if (!strcmp(long_options[index].name, "threads")) { processor_config_set_int(config, P2PSHIP_CONF_WORKER_THREADS, atoi(optarg)); } else if (!strcmp(long_options[index].name, "help")) { c = '?'; } else if (!strcmp(long_options[index].name, "version")) { c = 'V'; } else if (!strcmp(long_options[index].name, "verbose")) { c = 'v'; } else if (!strcmp(long_options[index].name, "iface")) { c = 'i'; } else if (!strcmp(long_options[index].name, "console")) { console_only = 1; #ifdef CONFIG_PYTHON_ENABLED } else if (!strcmp(long_options[index].name, "shell")) { processor_config_set_true(config, P2PSHIP_CONF_START_SHELL); } else if (!strcmp(long_options[index].name, "run")) { processor_config_set_string(config, P2PSHIP_CONF_RUN_SCRIPT, optarg); } else if (!strcmp(long_options[index].name, "no-scripts")) { processor_config_set_false(config, P2PSHIP_CONF_STARTUP_SCRIPTS); #endif #ifdef CONFIG_SIP_ENABLED } else if (!strcmp(long_options[index].name, "proxy-iface")) { processor_config_set_string(config, P2PSHIP_CONF_SIPP_PROXY_IFACES, optarg); } else if (!strcmp(long_options[index].name, "no-mp")) { processor_config_set_string(config, P2PSHIP_CONF_SIPP_MEDIA_PROXY, "no"); } else if (!strcmp(long_options[index].name, "tunnel-mp")) { processor_config_set_string(config, P2PSHIP_CONF_SIPP_TUNNEL_PROXY, "yes"); } else if (!strcmp(long_options[index].name, "force-mp")) { processor_config_set_string(config, P2PSHIP_CONF_SIPP_FORCE_PROXY, "yes"); } else if (!strcmp(long_options[index].name, "allow-unknown")) { processor_config_set_string(config, P2PSHIP_CONF_IDENT_ALLOW_UNKNOWN_REGISTRATIONS, "yes"); } else if (!strcmp(long_options[index].name, "allow-untrusted")) { processor_config_set_string(config, P2PSHIP_CONF_IDENT_ALLOW_UNTRUSTED, "yes"); #endif } else if (!action && !strcmp(long_options[index].name, "list-ca")) { action = ACTION_LIST_CA; } else if (!action && !strcmp(long_options[index].name, "remove-ca")) { action = ACTION_REMOVE_CA; if (!action_param) action_param = strdup(optarg); } else if (!action && !strcmp(long_options[index].name, "import-ca")) { action = ACTION_IMPORT_CA; if (!action_param) action_param = strdup(optarg); } else if (!action && !strcmp(long_options[index].name, "list")) { action = ACTION_LIST; } else if (!action && !strcmp(long_options[index].name, "remove")) { action = ACTION_REMOVE; if (!action_param) action_param = strdup(optarg); } else if (!action && !strcmp(long_options[index].name, "import")) { action = ACTION_IMPORT; if (!action_param) action_param = strdup(optarg); } else if (!strcmp(long_options[index].name, "idents")) { processor_config_set_string(config, P2PSHIP_CONF_IDENTS_FILE, optarg); } else if (!strcmp(long_options[index].name, "log")) { processor_config_set_string(config, P2PSHIP_CONF_LOG_FILE, optarg); #ifdef CONFIG_BROADCAST_ENABLED } else if (!strcmp(long_options[index].name, "bc-addr")) { processor_config_set_string(config, P2PSHIP_CONF_BC_ADDR, optarg); #endif #ifdef CONFIG_OPENDHT_ENABLED } else if (!strcmp(long_options[index].name, "opendht")) { processor_config_set_string(config, P2PSHIP_CONF_OPENDHT_PROXY, optarg); #endif #ifdef CONFIG_HIP_ENABLED } else if (!strcmp(long_options[index].name, "list-hits")) { action = ACTION_LIST_HITS; } else if (!strcmp(long_options[index].name, "rvs")) { processor_config_set_string(config, P2PSHIP_CONF_RVS, optarg); } else if (!strcmp(long_options[index].name, "provide-rvs")) { processor_config_set_string(config, P2PSHIP_CONF_PROVIDE_RVS, "yes"); #endif #ifdef CONFIG_WEBCONF_ENABLED } else if (!strcmp(long_options[index].name, "webconf")) { processor_config_set_string(config, P2PSHIP_CONF_WEBCONF_SS, optarg); #endif } else { c = '?'; } } switch (c) { case 0: /* already processed */ break; case 'v': if (p2pship_log_level > -1) p2pship_log_level++; break; case 'q': flag_quiet = 1; p2pship_log_level = -1; break; case 'D': log_to_file = 1; processor_config_set_string(config, P2PSHIP_CONF_DAEMON, "yes"); break; case 'c': conf_file = optarg; processor_config_set_string(config, P2PSHIP_CONF_CONF_FILE, conf_file); break; case 'i': processor_config_set_string(config, P2PSHIP_CONF_IFACES, optarg); break; #ifdef CONFIG_SIP_ENABLED case 'p': if (sscanf(optarg, "%u", &tmp) != 1) { USER_ERROR("Invalid port %s\n", optarg); return 1; } else { processor_config_set_int(config, P2PSHIP_CONF_SIPP_PROXY_PORT, tmp); } break; #endif case 's': if (sscanf(optarg, "%u", &tmp) != 1) { USER_ERROR("Invalid port %s\n", optarg); return 1; } else { processor_config_set_int(config, P2PSHIP_CONF_SHIP_PORT, tmp); } break; case 'V': print_version(); return 0; case 'R': load_autoreg = 1; break; case 'r': processor_config_set_string(config, P2PSHIP_CONF_AUTOREG_FILE, optarg); break; case 'L': log_to_file = 1; break; case 'k': processor_kill_existing_pid(); break; case 'K': processor_kill_all_existing(); break; case 't': do_test = 1; break; case 'h': case '?': default: print_version(); print_usage(); return 1; } } if (!flag_quiet) print_version(); /* 1. load the defaults (done already), 2. load the conf file, 3. put on the manual overrides */ /* ensure that we have a config file! */ if (ship_ensure_file(conf_file, "# Autocreated\n\n") || processor_config_load(config2, conf_file)) { USER_ERROR("Error processing config file %s\n", conf_file); goto err; } if (processor_config_transfer(config2, config)) { USER_ERROR("Error processing configs\n"); goto err; } /* transfer */ processor_config_free(config); config = config2; config2 = NULL; /* ok, ready to rock! */ processor_config_ensure_configs(config); if (log_to_file) { p2pship_log_file = processor_config_string(config, P2PSHIP_CONF_LOG_FILE); } #ifdef CONFIG_START_GLIB_MAIN_LOOP if (!g_thread_supported()) g_thread_init(NULL); #endif #ifdef CONFIG_START_GTK gdk_threads_init(); gdk_threads_enter(); gtk_init(&argc, &argv); #endif #ifdef CALL_DEBUG calldebug_init(); #endif /* mark starttime for uptime calcs */ time(&p2pship_start); /* register each modules */ ASSERT_ZERO(processor_init(config), err); #ifdef CONFIG_HIP_ENABLED hipapi_register(); #endif #ifdef CONFIG_SIP_ENABLED sipp_register(); #endif ident_addr_register(); ident_register(); #ifdef CONFIG_WEBCONF_ENABLED webconf_register(); #endif #ifdef CONFIG_EXTAPI_ENABLED extapi_register(); #endif #ifdef CONFIG_WEBCACHE_ENABLED webcache_register(); #endif resourceman_register(); olclient_register(); conn_register(); netio_register(); netio_events_register(); netio_ff_register(); netio_man_register(); netio_http_register(); ui_register(); ui_stdin_register(); processor_init_module("ui_stdin", config); #ifdef CONFIG_DBUS_ENABLED dbus_register(); #endif if (!console_only) { #ifdef CONFIG_GTKUI_ENABLED ui_gtk_register(); processor_init_module("ui_gtk", config); #endif } addrbook_register(); #ifdef CONFIG_PYTHON_ENABLED pymod_register(); #endif #ifdef CONFIG_MEDIA_ENABLED media_register(); #endif /* check what we actually should do */ switch (action) { case ACTION_LIST_CA: { /* list ca */ if (processor_init_module("ident", config)) { USER_ERROR("Error initializing system\n"); } else { ident_data_print_cas(ident_get_cas()); } break; } case ACTION_REMOVE_CA: { /* remove ca */ if (processor_init_module("ident", config)) { USER_ERROR("Error initializing system\n"); } else { ident_remove_ca(action_param); } break; } case ACTION_LIST: { /* list */ if (processor_init_module("ident", config)) { USER_ERROR("Error initializing system\n"); } else { ident_data_print_idents(ident_get_identities()); } break; } case ACTION_REMOVE: { /* remove */ if (processor_init_module("ident", config)) { USER_ERROR("Error initializing system\n"); } else { ident_remove_ident(action_param); } break; } case ACTION_IMPORT: /* import */ case ACTION_IMPORT_CA: { /* import ca */ if (processor_init_module("ident", config)) { USER_ERROR("Error initializing system\n"); } else { if (ident_import_file(action_param, 1)) { USER_ERROR("Error loading processing file %s\n", action_param); } } break; } #ifdef CONFIG_HIP_ENABLED case ACTION_LIST_HITS: { if (processor_init_module("hipapi", config)) { USER_ERROR("Error initializing system\n"); } else { hipapi_list_hits(); } break; } #endif case ACTION_NONE: default: { struct rlimit rl; int result; #ifdef CONFIG_PYTHON_ENABLED if (processor_config_is_true(config, P2PSHIP_CONF_START_SHELL)) processor_config_set_false(config, P2PSHIP_CONF_DAEMON); #endif /* go daemon (..whee!) */ if (processor_config_is_true(config, P2PSHIP_CONF_DAEMON)) { if (fork()) goto err; } /* check the stack size */ if (!(result = getrlimit(RLIMIT_STACK, &rl))) { const rlim_t stacksize = 32L * 1024L * 1024L; if (rl.rlim_cur < stacksize) { LOG_INFO("increasing stack size to %d\n", stacksize); rl.rlim_cur = stacksize; if (setrlimit(RLIMIT_STACK, &rl)) { LOG_ERROR("could not set new stack size!\n"); } } } else { LOG_ERROR("error checking stack size\n"); } if (processor_init_modules(config) || (load_autoreg && ident_autoreg_load())) { USER_ERROR("Error initializing system\n"); } else { #ifdef REMOTE_DEBUG ship_remote_debug_init(config); #endif /* start the main loop, blocks */ #ifdef REF_DEBUG2 // processor_tasks_add_periodic(ship_debug_reportref, 10000); #endif if (do_test) { LOG_DEBUG("Run tests..\n"); } processor_run(); } } } ret = 0; err: #ifdef REF_DEBUG2 ship_debug_reportref(); #endif processor_close(); freez(action_param); processor_config_free(config); processor_config_free(config2); #ifdef LOCK_DEBUG debug2_close(); #endif #ifdef REF_DEBUG2 ship_debug_closeref(); #endif xmlCleanupThreads(); if (!ret && !flag_quiet) USER_ERROR("ending ok\n"); processor_cleanup_pid(); return ret; }
int main(int argc, char* argv[]) { ods_status status; engineconfig_type* cfg; int c; int options_index = 0; const char* cfgfile = ODS_SE_CFGFILE; static struct option long_options[] = { {"config", required_argument, 0, 'c'}, {"help", no_argument, 0, 'h'}, {"verbose", no_argument, 0, 'v'}, { 0, 0, 0, 0} }; argv0 = argv[0]; /* parse the commandline */ while ((c=getopt_long(argc, argv, "c:hv", long_options, &options_index)) != -1) { switch (c) { case 'c': cfgfile = optarg; break; case 'h': usage(); exit(0); case 'v': ++verbosity; break; default: usage(); exit(1); } } argc -= optind; argv += optind; if (argc != 0) { usage(); exit(1); } ods_log_init("ods-migrate", 0, NULL, verbosity); xmlInitGlobals(); xmlInitParser(); xmlInitThreads(); tzset(); /* for portability */ /* Parse config file */ cfg = engine_config(cfgfile, verbosity, NULL); cfg->verbosity = verbosity; /* does it make sense? */ if (engine_config_check(cfg) != ODS_STATUS_OK) { abort(); /* TODO give some error, abort */ } status = hsm_open2(parse_conf_repositories(cfgfile), hsm_prompt_pin); if (status != HSM_OK) { char* errorstr = hsm_get_error(NULL); if (errorstr != NULL) { fprintf(stderr, "%s", errorstr); free(errorstr); abort(); /* FIXME */ } else { fprintf(stderr,"error opening libhsm (errno %i)\n", status); } return 1; } dblayer_initialize(); switch (cfg->db_type) { case ENFORCER_DATABASE_TYPE_SQLITE: #ifdef HAVE_SQLITE3 dblayer_sqlite3_open(cfg->datastore); #else fprintf(stderr, "Database SQLite3 not available during compile-time.\n"); #endif break; case ENFORCER_DATABASE_TYPE_MYSQL: #ifdef HAVE_MYSQL dblayer_mysql_open(cfg->db_host, cfg->db_username, cfg->db_password, cfg->datastore, cfg->db_port, NULL); #else fprintf(stderr, "Database MySQL not available during compile-time.\n"); #endif break; case ENFORCER_DATABASE_TYPE_NONE: default: fprintf(stderr, "No database defined\n"); } dblayer_foreach(listQueryStr, updateQueryStr, &compute); hsm_close(); engine_config_cleanup(cfg); /* dblayer_foreach for each frees something dblayer_close uses * We better just let it leak. */ /* dblayer_close(); */ dblayer_finalize(); ods_log_close(); xmlCleanupParser(); xmlCleanupGlobals(); return 0; }
void init(int argc, char **argv) { unsigned int i, j; int help = 0; int threads = 2; int archive_type = -1; FILE* totest; char test[300]; xmlInitThreads(); pwdMutex = xmlNewMutex(); finishedMutex = xmlNewMutex(); if (argc == 1) { printf("USAGE: rarcrack encrypted_archive.ext [--threads NUM] [--type rar|zip|7z]\n"); printf(" For more information please run \"rarcrack --help\"\n"); help = 1; } else { for (i = 1; i < argc; i++) { if (strcmp(argv[i],"--help") == 0) { printf("Usage: rarcrack encrypted_archive.ext [--threads NUM] [--type rar|zip|7z]\n\n"); printf("Options: --help: show this screen.\n"); printf(" --type: you can specify the archive program, this needed when\n"); printf(" the program couldn't detect the proper file type\n"); printf(" --threads: you can specify how many threads\n"); printf(" will be run, maximum 12 (default: 2)\n\n"); printf("Info: This program supports only RAR, ZIP and 7Z encrypted archives.\n"); printf(" RarCrack! usually detects the archive type.\n\n"); help = 1; break; } else if (strcmp(argv[i],"--threads") == 0) { if ((i + 1) < argc) { sscanf(argv[++i], "%d", &threads); if (threads < 1) threads = 1; if (threads > 12) { printf("INFO: number of threads adjusted to 12\n"); threads = 12; } } else { printf("ERROR: missing parameter for option: --threads!\n"); help = 1; } } else if (strcmp(argv[i],"--type") == 0) { if ((i + 1) < argc) { sscanf(argv[++i], "%s", &test); for (j = 0; strcmp(TYPE[j], "") != 0; j++) { if (strcmp(TYPE[j], test) == 0) { strcpy(finalcmd, CMD[j]); archive_type = j; break; } } if (archive_type < 0) { printf("WARNING: invalid parameter --type %s!\n", argv[i]); finalcmd[0] = '\0'; } } else { printf("ERROR: missing parameter for option: --type!\n"); help = 1; } } else { strcpy((char*)&filename, argv[i]); } } } if (help == 1) return; sprintf((char*)&statname,"%s.xml",(char*)&filename); totest = fopen(filename,"r"); if (totest == NULL) { printf("ERROR: The specified file (%s) is not exists or \n", filename); printf(" you don't have a right permissions!\n"); return; } else fclose(totest); if (finalcmd[0] == '\0') { //when we specify the file type, the programm will skip the test sprintf((char*)&test, CMD_DETECT, filename); totest = popen(test,"r"); fscanf(totest,"%s",(char*)&test); pclose(totest); for (i = 0; strcmp(MIME[i],"") != 0; i++) { if (strcmp(MIME[i],test) == 0) { strcpy(finalcmd,CMD[i]); archive_type = i; break; } } printf("INFO: detected file type: %s\n", TYPE[archive_type]); } else printf("INFO: the specified archive type: %s\n", TYPE[archive_type]); if (finalcmd[0] == '\0') { printf("ERROR: Couldn't detect archive type\n"); return; } /*else printf("DEBUG: the unpack command is: '%s'\n", finalcmd);*/ printf("INFO: cracking %s, status file: %s\n", filename, statname); if (loadstatus() == 1) { printf("ERROR: The status file (%s) is corrupted!\n", statname); return; } ABCLEN = strlen(ABC); if (password[0] == '\0') password[0] = ABC[0]; crack_start(threads); return; }