int main(int argc, char *argv[]) { int ch; if(argc > 1 && strcasecmp(argv[1], "help") == 0) { usage(); exit(0); } while(argc > 1 && (ch = getopt(argc, argv, "p:r:o:d"))!= -1) { switch(ch) { case 'p': port = atoi(optarg); break; case 'r': servicepath = optarg; break; case 'd': is_debug = 1; break; case 'o': output_file = optarg; break; default: printf("Unrecognized option!\n"); exit(0); } } initialize_logging(); if(eventlistener_init(port, servicepath, 1, is_debug)) exit(-1); eventlistener_register_event_processor(print_events, NULL); eventlistener_start(); return 0; }
void SimplicityApplication::initialize(string sDisplay) { set_display_name(sDisplay); initialize_logging(); initialize_x_connection(); }
nova_renderer::nova_renderer() : gui_renderer_instance(tex_manager, shader_manager, ubo_manager) { initialize_logging(); // Oh wow this line is gross. I guess this is why everyone hates CPP? game_window = std::unique_ptr<iwindow>(static_cast<iwindow *>(new glfw_gl_window())); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); }
int main(void) { initialize_logging("test.log"); int number_failed; SRunner *sr = srunner_create(tag_precompute_suite()); srunner_run_all(sr, CK_NORMAL); number_failed = srunner_ntests_failed(sr); srunner_free(sr); close_log(); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
astra_status_t context_impl::initialize() { if (m_initialized) return ASTRA_STATUS_SUCCESS; #if __ANDROID__ std::string appPath = environment::application_path(); std::string logPath = filesystem::combine_paths(appPath, "astra.log"); std::string configPath = filesystem::combine_paths(appPath, "astra.toml"); #else std::string logPath = "astra.log"; std::string configPath = filesystem::combine_paths(environment::lib_path(), "astra.toml"); #endif std::unique_ptr<configuration> config(configuration::load_from_file(configPath.c_str())); initialize_logging(logPath.c_str(), config->severityLevel()); LOG_WARN("context", "Hold on to yer butts"); LOG_INFO("context", "configuration path: %s", configPath.c_str()); LOG_INFO("context", "log file path: %s", logPath.c_str()); pluginManager_ = std::make_unique<plugin_manager>(m_setCatalog); #if !__ANDROID__ std::string pluginsPath = filesystem::combine_paths(environment::lib_path(), filesystem::append_path_separator(config->pluginsPath())); LOG_INFO("context", "plugin path: %s", pluginsPath.c_str()); pluginManager_->load_plugins(pluginsPath); #else pluginManager_->load_plugin("libopenni_sensor.so"); pluginManager_->load_plugin("liborbbec_hand.so"); pluginManager_->load_plugin("liborbbec_xs.so"); #endif if (pluginManager_->plugin_count() == 0) { LOG_WARN("context", "Astra found no plugins. Is there a Plugins folder? Is the working directory correct?"); } m_initialized = true; return ASTRA_STATUS_SUCCESS; }
/* @brief Initialize the configuration * * Given the root of the Ganesha configuration structure, initialize * the FSAL parameters. * * @param[in] fsal_hdl The FSAL module * @param[in] config_struct Parsed ganesha configuration file * * @return FSAL status. */ static fsal_status_t init_config(struct fsal_module *fsal_hdl, config_file_t /*config_struct*/) { struct this_fsal_module *module_me = container_of(fsal_hdl, struct this_fsal_module, fsal); /* Get a copy of the defaults */ module_me->fs_info = default_ovs_info; display_fsinfo(&module_me->fs_info); try { initialize_logging(); } CATCH_STD_ALL_EWHAT({ std::stringstream ss; ss << EWHAT; LogMajor(COMPONENT_FSAL, const_cast<char*>("VFS FSAL: failed to initialize logging: %s"), ss.str().c_str()); return fsalstat(ERR_FSAL_BAD_INIT, 0); });
int main(int argc, char **argv) { int num; int i; char retval = 0; u_error_t *error = NULL; u_option_entry_t opt[] = { {"debug", 'd', U_OPTION_ARG_INT, &debug_level, "Set the verbosity of debugging output.", "1-6"} }; u_option_context_t *opt_ctx; opt_ctx = u_option_context_new(""); u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify"); retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); u_option_context_free(opt_ctx); if (error) { if (error->message) printf("%s\n", error->message); u_error_free(error); return 1; } u_error_free(error); if (debug_level) { initialize_logging(); wsman_debug_set_level(debug_level); } if (argc == 1) { // execute all example1(); example2(); example3(); example4(); example5(); example6(); example7(); example8(); example9(); example10(); example11(); example12(); example13(); example14(); return 0; } for (i = 1; i < argc; i++) { num = atoi(argv[i]); switch (num) { case 1: example1(); break; case 2: example2(); break; case 3: example3(); break; case 4: example4(); break; case 5: example5(); break; case 6: example6(); break; case 7: example7(); break; case 8: example8(); break; case 9: example9(); break; case 10: example10(); break; case 11: example11(); break; case 12: example12(); break; case 13: example13(); break; case 14: example14(); break; default: printf("\n No example%d()\n", num); break; } } return 0; }
int main(int argc, char** argv) { int i; WsManClient *cl; WsXmlDocH docp; client_opt_t *options = NULL; char *enumContext = NULL; //unsigned int id = 0; //wsman_debug_set_level(DEBUG_LEVEL_DEBUG); initialize_logging(); //wsmc_add_handler(wsmc_handler, NULL); for (i = 0; i < ntests; i++) { printf ("Test %d: %s:", i + 1, tests[i].explanation); //printf ("------------------------------------------------\n"); cl = wsmc_create( sd[0].server, sd[0].port, sd[0].path, sd[0].scheme, sd[0].username, sd[0].password); wsmc_transport_init(cl, NULL); options = wsmc_options_init(); options->flags = tests[i].flags; options->max_elements = tests[i].max_elements; if (tests[i].selectors != NULL) wsmc_add_selectors_from_str (options, tests[i].selectors); WsXmlDocH enum_response = wsmc_action_enumerate(cl, (char *)tests[i].resource_uri , options, NULL); if (!enum_response) { printf("\t\t\033[22;31mUNRESOLVED\033[m\n"); goto CONTINUE; } //wsman_output(enum_response); if ((char *)tests[i].expected_value != NULL) { char *xp = ws_xml_get_xpath_value(enum_response, (char *)tests[i].xpath_expression); if (xp) { if (strcmp(xp,(char *)tests[i].expected_value ) == 0) printf("\t\t\033[22;32mPASSED\033[m\n"); else printf("\t\t\033[22;31mFAILED\033[m\n"); u_free(xp); } } wsmc_free_enum_context(enumContext); enumContext = wsmc_get_enum_context(enum_response); ws_xml_destroy_doc(enum_response); while (enumContext != NULL) { docp = wsmc_action_pull(cl, (char *)tests[i].resource_uri, options, NULL, enumContext); if (!docp) { printf("\t\t\033[22;31mUNRESOLVED\033[m\n"); goto CONTINUE; } wsman_output(docp); wsmc_free_enum_context(enumContext); enumContext = wsmc_get_enum_context(docp); ws_xml_destroy_doc(docp); } CONTINUE: wsmc_options_destroy(options); wsmc_release(cl); } return 0; }
int main(int ac, char *av[]) { char *p = NULL; kern_return_t kr = KERN_FAILURE; long n; int ch; mach_msg_header_t hdr; while ((ch = getopt(ac, av, "dt:")) != -1) switch (ch) { case 'd': opt_debug = 1; break; case 't': n = strtol(optarg, &p, 0); if ('\0' == optarg[0] || '\0' != *p || n > LONG_MAX || n < 0) { fprintf(stderr, "Invalid idle timeout: %s\n", optarg); exit(EXIT_FAILURE); } maxidle = n; break; case '?': default: fprintf(stderr, "Usage: mDNSResponderHelper [-d] [-t maxidle]\n"); exit(EXIT_FAILURE); } ac -= optind; av += optind; (void)ac; // Unused (void)av; // Unused initialize_logging(); helplog(ASL_LEVEL_INFO, "Starting"); initialize_id(); #ifndef NO_SECURITYFRAMEWORK // We should normally be running as a system daemon. However, that might not be the case in some scenarios (e.g. debugging). // Explicitly ensure that our Keychain operations utilize the system domain. if (opt_debug) SecKeychainSetPreferenceDomain(kSecPreferencesDomainSystem); #endif gPort = register_service(kmDNSHelperServiceName); if (!gPort) exit(EXIT_FAILURE); if (maxidle) actualidle = maxidle; signal(SIGTERM, handle_sigterm); if (initialize_timer()) exit(EXIT_FAILURE); for (n=0; n<100000; n++) if (!gRunLoop) usleep(100); if (!gRunLoop) { helplog(ASL_LEVEL_ERR, "gRunLoop not set after waiting"); exit(EXIT_FAILURE); } for(;;) { hdr.msgh_bits = 0; hdr.msgh_local_port = gPort; hdr.msgh_remote_port = MACH_PORT_NULL; hdr.msgh_size = sizeof(hdr); hdr.msgh_id = 0; kr = mach_msg(&hdr, MACH_RCV_LARGE | MACH_RCV_MSG, 0, hdr.msgh_size, gPort, 0, 0); if (MACH_RCV_TOO_LARGE != kr) helplog(ASL_LEVEL_ERR, "main MACH_RCV_MSG error: %d %X %s", kr, kr, mach_error_string(kr)); kr = mach_msg_server_once(helper_server, MAX_MSG_SIZE, gPort, MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT) | MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)); if (KERN_SUCCESS != kr) { helplog(ASL_LEVEL_ERR, "mach_msg_server: %d %X %s", kr, kr, mach_error_string(kr)); exit(EXIT_FAILURE); } } exit(EXIT_SUCCESS); }
int main (int argc, const char **argv) { GMainLoop *main_loop; struct sigaction sig_action; const char *config_file; char *python_path; g_thread_init (NULL); g_type_init (); rcd_executable_name = g_strdup (argv[0]); rcd_options_parse (argc, argv); if (rcd_options_get_show_version ()) { g_print ("%s\n", rcd_about_name ()); g_print ("%s\n\n", rcd_about_copyright ()); exit (0); } config_file = rcd_options_get_config_file (); if (config_file && !g_file_test (config_file, G_FILE_TEST_EXISTS)) { g_printerr ("Unable to find config file '%s'\n", config_file); g_printerr ("rcd aborting\n"); exit (-1); } root_check (); if (!rcd_options_get_late_background ()) daemonize (); /* Set up SIGTERM and SIGQUIT handlers */ sig_action.sa_handler = signal_handler; sigemptyset (&sig_action.sa_mask); sig_action.sa_flags = 0; sigaction (SIGINT, &sig_action, NULL); sigaction (SIGTERM, &sig_action, NULL); sigaction (SIGQUIT, &sig_action, NULL); /* Set up SIGHUP handler. */ sig_action.sa_handler = sighup_handler; sigemptyset (&sig_action.sa_mask); sig_action.sa_flags = 0; sigaction (SIGHUP, &sig_action, NULL); /* If it looks like rcd-buddy is in the right place, set up handlers for crashes */ python_path = g_find_program_in_path ("python"); if (python_path != NULL && g_file_test (SHAREDIR "/rcd-buddy", G_FILE_TEST_EXISTS)) { sig_action.sa_handler = crash_handler; sigaction (SIGSEGV, &sig_action, NULL); sigaction (SIGFPE, &sig_action, NULL); sigaction (SIGBUS, &sig_action, NULL); sigaction (SIGABRT, &sig_action, NULL); } g_free (python_path); rcd_privileges_init (); initialize_logging (); /* Check to see if the password file is secure. If it isn't, a big warning will go out to the log file. */ rcd_identity_password_file_is_secure (); /* Set the GPG keyring for package verification */ rc_verification_set_keyring (SHAREDIR "/rcd.gpg"); /* Create mid and secret */ if (!g_file_test (SYSCONFDIR "/mcookie", G_FILE_TEST_EXISTS)) rcd_create_uuid (SYSCONFDIR "/mcookie"); if (!g_file_test (SYSCONFDIR "/partnernet", G_FILE_TEST_EXISTS)) rcd_create_uuid (SYSCONFDIR "/partnernet"); /* Add memory usage watcher */ rcd_heartbeat_register_func (heartbeat_memory_monitor, NULL); initialize_rc_packman (); initialize_rc_services (); initialize_rc_world (); initialize_rpc (); if (!rcd_options_get_no_modules_flag ()) rcd_module_init (); /* We can't daemonize any later than this, so hopefully module initialization won't be slow. */ if (rcd_options_get_late_background ()) { rc_debug (RC_DEBUG_LEVEL_ALWAYS, "Running daemon in background."); daemonize (); /* We need to reinit logging, since the file descriptor gets closed when we daemonize. */ rcd_log_reinit (); /* Say hello again, so it gets stored in the log file. */ hello (); } rcd_rpc_local_server_start (); if (rcd_prefs_get_remote_server_enabled ()) { if (!rcd_rpc_remote_server_start ()) exit (-1); } initialize_data (); /* No heartbeat if we have initialized from a dump file. */ if (rcd_options_get_dump_file () == NULL) rcd_heartbeat_start (); main_loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (main_loop); /* * We'll never reach here, because we'll exit() out in * rcd-shutdown.c. */ g_assert_not_reached (); return 0; } /* main */