int main(int argc, char ** argv) { memory::initialize(0); bool do_display_usage = false; parse_cmd_line_args(argc, argv, do_display_usage); TST_ARGV(grobner); TST(random); TST(vector); TST(symbol_table); TST(region); TST(symbol); TST(heap); TST(hashtable); TST_ARGV(smtparser); TST(rational); TST(inf_rational); TST(ast); TST(optional); TST(bit_vector); TST(ast_pp); TST(ast_smt_pp); TST_ARGV(expr_delta); TST(string_buffer); TST(map); TST(diff_logic); TST(uint_set); TST_ARGV(expr_rand); TST(expr_context_simplifier); TST(ini_file); TST(expr_pattern_match); TST(list); TST(small_object_allocator); TST(timeout); TST(splay_tree); TST(fvi); TST(proof_checker); TST(simplifier); TST(bv_simplifier_plugin); TST(bit_blaster); TST(var_subst); TST(simple_parser); TST(symmetry); TST_ARGV(symmetry_parse); TST_ARGV(symmetry_prove); TST(api); TST(old_interval); TST(interval_skip_list); TST(no_overflow); TST(memory); TST(parallel); TST(get_implied_equalities); TST(arith_simplifier_plugin); TST(quant_elim); TST(matcher); TST(datalog_parser); TST(dl_rule_set); TST_ARGV(datalog_parser_file); TST(object_allocator); TST(mpz); TST(mpq); TST(mpf); TST(total_order); TST(dl_table); TST(dl_context); TST(dl_smt_relation); TST(dl_query); TST(dl_util); TST(dl_product_relation); TST(dl_relation); TST(imdd); TST(array_property_expander); TST(parray); TST(stack); TST(escaped); TST(buffer); TST(chashtable); TST(ex); TST(nlarith_util); TST(api_bug); TST(arith_rewriter); TST(check_assumptions); TST(smt_context); TST(theory_dl); TST(model_retrieval); TST(factor_rewriter); TST(smt2print_parse); TST(substitution); TST(polynomial); TST(upolynomial); TST(algebraic); TST(polynomial_factorization); TST(prime_generator); TST(permutation); TST(nlsat); TST(qe_defs); TST(ext_numeral); TST(interval); TST(quant_solve); TST(f2n); TST(hwf); TST(trigo); TST(bits); TST(mpbq); TST(mpfx); TST(mpff); TST(horn_subsume_model_converter); TST(model2expr); }
int main(int argc, char ** argv) { memory::initialize(0); bool do_display_usage = false; bool test_all = false; parse_cmd_line_args(argc, argv, do_display_usage, test_all); TST(random); TST(vector); TST(symbol_table); TST(region); TST(symbol); TST(heap); TST(hashtable); TST(rational); TST(inf_rational); TST(ast); TST(optional); TST(bit_vector); TST(fixed_bit_vector); TST(tbv); TST(doc); TST(udoc_relation); TST(string_buffer); TST(map); TST(diff_logic); TST(uint_set); TST_ARGV(expr_rand); TST(list); TST(small_object_allocator); TST(timeout); TST(proof_checker); TST(simplifier); TST(bv_simplifier_plugin); TST(bit_blaster); TST(var_subst); TST(simple_parser); TST(api); TST(old_interval); TST(get_implied_equalities); TST(arith_simplifier_plugin); TST(matcher); TST(object_allocator); TST(mpz); TST(mpq); TST(mpf); TST(total_order); TST(dl_table); TST(dl_context); TST(dl_util); TST(dl_product_relation); TST(dl_relation); TST(parray); TST(stack); TST(escaped); TST(buffer); TST(chashtable); TST(ex); TST(nlarith_util); TST(api_bug); TST(arith_rewriter); TST(check_assumptions); TST(smt_context); TST(theory_dl); TST(model_retrieval); TST(model_based_opt); TST(factor_rewriter); TST(smt2print_parse); TST(substitution); TST(polynomial); TST(upolynomial); TST(algebraic); TST(polynomial_factorization); TST(prime_generator); TST(permutation); TST(nlsat); TST(ext_numeral); TST(interval); TST(f2n); TST(hwf); TST(trigo); TST(bits); TST(mpbq); TST(mpfx); TST(mpff); TST(horn_subsume_model_converter); TST(model2expr); TST(hilbert_basis); TST(heap_trie); TST(karr); TST(no_overflow); TST(memory); TST(datalog_parser); TST_ARGV(datalog_parser_file); TST(dl_query); TST(quant_solve); TST(rcf); TST(polynorm); TST(qe_arith); TST(expr_substitution); TST(sorting_network); TST(theory_pb); TST(simplex); TST(sat_user_scope); TST(pdr); TST_ARGV(ddnf); TST(model_evaluator); //TST_ARGV(hs); }
int main(int argc, char **argv) { // Initialize syslog setup_syslog(); // Parse the command line char *config_file = NULL; int parse_res = parse_cmd_line_args(argc, argv, &config_file); if (parse_res) return 1; // Parse the config file statsite_proxy_config *config = calloc(1, sizeof(statsite_proxy_config)); int config_res = config_from_filename(config_file, config); if (config_res != 0) { syslog(LOG_ERR, "Failed to read the configuration file!"); return 1; } // Validate the config file int validate_res = validate_config(config); if (validate_res != 0) { syslog(LOG_ERR, "Invalid configuration!"); return 1; } // Set the syslog mask setlogmask(config->syslog_log_level); // Daemonize if (config->daemonize) { pid_t pid, sid; syslog(LOG_INFO, "Daemonizing."); pid = fork(); // Exit if we failed to fork if (pid < 0) { syslog(LOG_ERR, "Failed to fork() daemon!"); return 1; } // Parent process returns if (pid) return 0; // Create a new session sid = setsid(); if (sid < 0) { syslog(LOG_ERR, "Failed to set daemon SID!"); return 1; } int write_pidfile_res = write_pidfile(config->pid_file, sid); if (write_pidfile_res) { syslog(LOG_ERR, "Failed to write pidfile. Terminating."); return 1; } close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); } // Log that we are starting up syslog(LOG_INFO, "Starting statsite-proxy."); syslog(LOG_INFO, "Loaded Servers config: %s", config->servers); // Initialize proxy proxy *proxy = NULL; int proxy_res = proxy_init(&proxy, config->servers); if (proxy_res != 0) { syslog(LOG_ERR, "Failed to initialize proxy!"); return 1; } // Initialize the networking statsite_proxy_networking *netconf = NULL; int net_res = init_networking(config, &netconf, proxy); if (net_res != 0) { syslog(LOG_ERR, "Failed to initialize networking!"); return 1; } // Start the network workers pthread_t thread; pthread_create(&thread, NULL, (void*(*)(void*))start_networking_worker, netconf); /** * Loop forever, until we get a signal that * indicates we should shutdown. */ signal(SIGPIPE, SIG_IGN); // Ignore SIG_IGN signal(SIGHUP, SIG_IGN); // Ignore SIG_IGN signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); while (SHOULD_RUN) { sleep(1); } // Begin the shutdown/cleanup shutdown_networking(netconf); // If daemonized, remove the pid file if (config->daemonize && unlink(config->pid_file)) { syslog(LOG_ERR, "Failed to delete pid file!"); } // Free our memory proxy_destroy(proxy); free(config); // Done return 0; }
int main(int argc, char ** argv) { try{ unsigned return_value = 0; memory::initialize(0); memory::exit_when_out_of_memory(true, "ERROR: out of memory"); parse_cmd_line_args(argc, argv); env_params::updt_params(); if (g_input_file && g_standard_input) { error("using standard input to read formula."); } if (!g_input_file && !g_standard_input) { error("input file was not specified."); } if (g_input_kind == IN_UNSPECIFIED) { g_input_kind = IN_SMTLIB; char const * ext = get_extension(g_input_file); if (ext) { if (strcmp(ext, "datalog") == 0 || strcmp(ext, "dl") == 0) { g_input_kind = IN_DATALOG; } else if (strcmp(ext, "dimacs") == 0 || strcmp(ext, "cnf") == 0) { g_input_kind = IN_DIMACS; } else if (strcmp(ext, "log") == 0) { g_input_kind = IN_Z3_LOG; } else if (strcmp(ext, "smt2") == 0) { g_input_kind = IN_SMTLIB_2; } else if (strcmp(ext, "smt") == 0) { g_input_kind = IN_SMTLIB; } } } switch (g_input_kind) { case IN_SMTLIB: return_value = read_smtlib_file(g_input_file); break; case IN_SMTLIB_2: memory::exit_when_out_of_memory(true, "(error \"out of memory\")"); return_value = read_smtlib2_commands(g_input_file); break; case IN_DIMACS: return_value = read_dimacs(g_input_file); break; case IN_DATALOG: read_datalog(g_input_file); break; case IN_Z3_LOG: replay_z3_log(g_input_file); break; default: UNREACHABLE(); } #ifdef _WINDOWS _CrtDumpMemoryLeaks(); #endif return return_value; } catch (z3_exception & ex) { // unhandled exception std::cerr << "ERROR: " << ex.msg() << "\n"; if (ex.has_error_code()) return ex.error_code(); else return ERR_INTERNAL_FATAL; } }
/* * ----- main - Device identification inquiry. * Given -p path command line arguments, parse serial numbers, devid, * wwn, scsi target lun, and robot data transport info. Calling routine * puts the tape drives in the robots. */ int /* 0 is for success. */ main( int argc, /* C program argument count. */ char **argv) /* argument strings. */ { int return_code; devdata_t devdata; /* * Parse command line arguments. */ if ((return_code = parse_cmd_line_args(argc, argv, &devdata)) != 0) return (return_code); /* * Open logical tape drive "/dev/rmt/cbn" or * library /dev/samst/c* path. */ if ((devdata.fd = open(devdata.logdevpath, O_RDONLY| O_NDELAY)) == -1) { printf("%s\n", strerror(errno)); return (1); } /* * Get standard inquiry page. */ if ((return_code = standard_inquiry(&devdata)) != 0) { close(devdata.fd); return (return_code); } /* * Get inquiry unit serial number page. */ if ((return_code = usn_inquiry(&devdata)) != 0) { close(devdata.fd); return (return_code); } /* * Get inquiry device identification page. */ (void) devid_inquiry(&devdata); /* * If SCSI-3 media changer device type, get robot installed * tape drive unit serial number from read element status * device identification data. * * If SCSI-2 media changer device type, get robot installed * tape drive parallel SCSI target and lun. */ if (devdata.devtype == MC_INQ_DEVTYPE) { return_code = query_mc_dt(&devdata); } close(devdata.fd); /* * Return 0 for success and non-zero for failure. */ return (return_code); }
int main(int argc, char **argv) { // Initialize syslog setup_syslog(); // Parse the command line char *config_file = NULL; int parse_res = parse_cmd_line_args(argc, argv, &config_file); if (parse_res) return 1; // Parse the config file statsite_config *config = calloc(1, sizeof(statsite_config)); int config_res = config_from_filename(config_file, config); if (config_res != 0) { syslog(LOG_ERR, "Failed to read the configuration file!"); return 1; } // Validate the config file if (validate_config(config)) { syslog(LOG_ERR, "Invalid configuration!"); return 1; } // Set prefixes for each message type if (prepare_prefixes(config)) { syslog(LOG_ERR, "Failed to get prefixes!"); return 1; } // Build the prefix tree if (build_prefix_tree(config)) { syslog(LOG_ERR, "Failed to build prefix tree!"); return 1; } // Set the syslog mask setlogmask(config->syslog_log_level); // Daemonize if (config->daemonize) { pid_t pid, sid; int fd; syslog(LOG_INFO, "Daemonizing."); pid = fork(); // Exit if we failed to fork if (pid < 0) { syslog(LOG_ERR, "Failed to fork() daemon!"); return 1; } // Parent process returns if (pid) return 0; // Create a new session sid = setsid(); if (sid < 0) { syslog(LOG_ERR, "Failed to set daemon SID!"); return 1; } int write_pidfile_res = write_pidfile(config->pid_file, sid); if (write_pidfile_res) { syslog(LOG_ERR, "Failed to write pidfile. Terminating."); return 1; } if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); if (fd > STDERR_FILENO) close(fd); } } // Log that we are starting up syslog(LOG_INFO, "Starting statsite."); // Initialize the networking statsite_networking *netconf = NULL; int net_res = init_networking(config, &netconf); if (net_res != 0) { syslog(LOG_ERR, "Failed to initialize networking!"); return 1; } // Setup signal handlers signal(SIGPIPE, SIG_IGN); // Ignore SIG_IGN signal(SIGHUP, SIG_IGN); // Ignore SIG_IGN signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); // Join the networking loop, blocks until exit enter_networking_loop(netconf, &SHOULD_RUN); // Begin the shutdown/cleanup shutdown_networking(netconf); // Do the final flush final_flush(); // If daemonized, remove the pid file if (config->daemonize && unlink(config->pid_file)) { syslog(LOG_ERR, "Failed to delete pid file!"); } // Free our memory free(config); // Done return 0; }
int main(int argc, char **argv) { // temporarily set the syslog facilty to main and init it setup_syslog(LOG_USER, 0); // Parse the command line char *config_file = NULL; int parse_res = parse_cmd_line_args(argc, argv, &config_file); if (parse_res) return 1; // Parse the config file statsite_config *config = alloc_config(); int config_res = config_from_filename(config_file, config); if (config_res != 0) { syslog(LOG_ERR, "Failed to read the configuration file!"); return 1; } // Validate the config file if (validate_config(config)) { syslog(LOG_ERR, "Invalid configuration!"); return 1; } // close the initial syslog closelog(); // Initialize syslog with configured facility setup_syslog(config->syslog_log_facility, config->daemonize); // Set prefixes for each message type if (prepare_prefixes(config)) { syslog(LOG_ERR, "Failed to get prefixes!"); return 1; } // Build the prefix tree if (build_prefix_tree(config)) { syslog(LOG_ERR, "Failed to build prefix tree!"); return 1; } // Set the syslog mask setlogmask(config->syslog_log_level); // Initialize libcurl curl_global_init(CURL_GLOBAL_DEFAULT); // Daemonize if (config->daemonize) { pid_t pid, sid; int fd; syslog(LOG_INFO, "Daemonizing."); pid = fork(); // Exit if we failed to fork if (pid < 0) { syslog(LOG_ERR, "Failed to fork() daemon!"); return 1; } // Parent process returns if (pid) return 0; // Create a new session sid = setsid(); if (sid < 0) { syslog(LOG_ERR, "Failed to set daemon SID!"); return 1; } int write_pidfile_res = write_pidfile(config->pid_file, sid); if (write_pidfile_res) { syslog(LOG_ERR, "Failed to write pidfile. Terminating."); return 1; } if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); if (fd > STDERR_FILENO) close(fd); } } // Log that we are starting up syslog(LOG_INFO, "Starting statsite."); // Build the sinks sink* sinks = NULL; init_sinks(&sinks, config); // Initialize the networking statsite_networking *netconf = NULL; int net_res = init_networking(config, &netconf, sinks); if (net_res != 0) { syslog(LOG_ERR, "Failed to initialize networking!"); return 1; } // Setup signal handlers signal(SIGPIPE, SIG_IGN); // Ignore SIG_IGN signal(SIGHUP, SIG_IGN); // Ignore SIG_IGN signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); // Join the networking loop, blocks until exit enter_networking_loop(netconf, &SIGNUM); if (SIGNUM != 0) { syslog(LOG_WARNING, "Received signal [%s]! Exiting...", strsignal(SIGNUM)); } // Begin the shutdown/cleanup shutdown_networking(netconf); // Do the final flush final_flush(sinks); // If daemonized, remove the pid file if (config->daemonize && unlink(config->pid_file)) { syslog(LOG_ERR, "Failed to delete pid file!"); } // Free our memory free_config(config); // Tear down libcurl curl_global_cleanup(); // Done return 0; }