void weechat_init (int argc, char *argv[], void (*gui_init_cb)()) { weechat_first_start_time = time (NULL); /* initialize start time */ gettimeofday (&weechat_current_start_timeval, NULL); /* catch signals */ util_catch_signal (SIGINT, SIG_IGN); /* signal ignored */ util_catch_signal (SIGPIPE, SIG_IGN); /* signal ignored */ util_catch_signal (SIGSEGV, &debug_sigsegv); /* crash dump */ util_catch_signal (SIGHUP, &weechat_sighup); /* exit WeeChat */ util_catch_signal (SIGQUIT, &weechat_sigquit); /* exit WeeChat */ util_catch_signal (SIGTERM, &weechat_sigterm); /* exit WeeChat */ hdata_init (); /* initialize hdata */ hook_init (); /* initialize hooks */ debug_init (); /* hook signals for debug */ gui_color_init (); /* initialize colors */ gui_chat_init (); /* initialize chat */ command_init (); /* initialize WeeChat commands */ completion_init (); /* add core completion hooks */ gui_key_init (); /* init keys */ network_init_gcrypt (); /* init gcrypt */ if (!secure_init ()) /* init secured data options (sec.*)*/ weechat_shutdown (EXIT_FAILURE, 0); if (!config_weechat_init ()) /* init WeeChat options (weechat.*) */ weechat_shutdown (EXIT_FAILURE, 0); weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dir (); /* create WeeChat home directory */ log_init (); /* init log file */ plugin_api_init (); /* create some hooks (info,hdata,..)*/ secure_read (); /* read secured data options */ config_weechat_read (); /* read WeeChat options */ network_init_gnutls (); /* init GnuTLS */ if (gui_init_cb) (*gui_init_cb) (); /* init WeeChat interface */ if (weechat_upgrading) { upgrade_weechat_load (); /* upgrade with session file */ weechat_upgrade_count++; /* increase /upgrade count */ } weechat_startup_message (); /* display WeeChat startup message */ gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */ weechat_term_check (); /* warning about wrong $TERM */ weechat_locale_check (); /* warning about wrong locale */ command_startup (0); /* command executed before plugins */ plugin_init (weechat_force_plugin_autoload, /* init plugin interface(s) */ argc, argv); command_startup (1); /* commands executed after plugins */ if (!weechat_upgrading) gui_layout_window_apply (gui_layout_current, -1); if (weechat_upgrading) upgrade_weechat_end (); /* remove .upgrade files + signal */ }
/* This is clearly minimal, we already run tests during initialization */ int main(int argc, char **argv) { secure_init(1); secure_release(); return EXIT_SUCCESS; }
void weechat_init (int argc, char *argv[], void (*gui_init_cb)()) { weechat_first_start_time = time (NULL); /* initialize start time */ gettimeofday (&weechat_current_start_timeval, NULL); weechat_locale_ok = (setlocale (LC_ALL, "") != NULL); /* init gettext */ #ifdef ENABLE_NLS bindtextdomain (PACKAGE, LOCALEDIR); bind_textdomain_codeset (PACKAGE, "UTF-8"); textdomain (PACKAGE); #endif #ifdef HAVE_LANGINFO_CODESET weechat_local_charset = strdup (nl_langinfo (CODESET)); #else weechat_local_charset = strdup (""); #endif utf8_init (); /* catch signals */ util_catch_signal (SIGINT, SIG_IGN); /* signal ignored */ util_catch_signal (SIGQUIT, SIG_IGN); /* signal ignored */ util_catch_signal (SIGPIPE, SIG_IGN); /* signal ignored */ util_catch_signal (SIGSEGV, &debug_sigsegv); /* crash dump */ util_catch_signal (SIGHUP, &weechat_sighup); /* exit WeeChat */ util_catch_signal (SIGQUIT, &weechat_sigquit); /* exit WeeChat */ util_catch_signal (SIGTERM, &weechat_sigterm); /* exit WeeChat */ hdata_init (); /* initialize hdata */ hook_init (); /* initialize hooks */ debug_init (); /* hook signals for debug */ gui_color_init (); /* initialize colors */ gui_chat_init (); /* initialize chat */ command_init (); /* initialize WeeChat commands */ completion_init (); /* add core completion hooks */ gui_key_init (); /* init keys */ network_init_gcrypt (); /* init gcrypt */ if (!secure_init ()) /* init secured data options (sec.*)*/ weechat_shutdown (EXIT_FAILURE, 0); if (!config_weechat_init ()) /* init WeeChat options (weechat.*) */ weechat_shutdown (EXIT_FAILURE, 0); weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dir (); /* create WeeChat home directory */ log_init (); /* init log file */ plugin_api_init (); /* create some hooks (info,hdata,..)*/ secure_read (); /* read secured data options */ config_weechat_read (); /* read WeeChat options */ network_init_gnutls (); /* init GnuTLS */ if (gui_init_cb) (*gui_init_cb) (); /* init WeeChat interface */ if (weechat_upgrading) { upgrade_weechat_load (); /* upgrade with session file */ weechat_upgrade_count++; /* increase /upgrade count */ } weechat_welcome_message (); /* display WeeChat welcome message */ gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */ weechat_term_check (); /* warnings about $TERM (if wrong) */ weechat_locale_check (); /* warning about wrong locale */ command_startup (0); /* command executed before plugins */ plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */ argc, argv); command_startup (1); /* commands executed after plugins */ if (!weechat_upgrading) gui_layout_window_apply (gui_layout_current, -1); if (weechat_upgrading) upgrade_weechat_end (); /* remove .upgrade files + signal */ }
int main (int argc, char *argv[]) { weechat_first_start_time = time (NULL); /* initialize start time */ gettimeofday (&weechat_current_start_timeval, NULL); setlocale (LC_ALL, ""); /* initialize gettext */ #ifdef ENABLE_NLS bindtextdomain (PACKAGE, LOCALEDIR); bind_textdomain_codeset (PACKAGE, "UTF-8"); textdomain (PACKAGE); #endif #ifdef HAVE_LANGINFO_CODESET weechat_local_charset = strdup (nl_langinfo (CODESET)); #else weechat_local_charset = strdup (""); #endif utf8_init (); util_catch_signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */ util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */ util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */ util_catch_signal (SIGSEGV, &debug_sigsegv); /* crash dump for SIGSEGV signal */ hdata_init (); /* initialize hdata */ hook_init (); /* initialize hooks */ debug_init (); /* hook signals for debug */ gui_main_pre_init (&argc, &argv); /* pre-initialize interface */ command_init (); /* initialize WeeChat commands */ completion_init (); /* add core completion hooks */ gui_key_init (); /* init keys */ network_init_gcrypt (); /* init gcrypt */ if (!secure_init ()) /* init secured data options (sec.*)*/ weechat_shutdown (EXIT_FAILURE, 0); if (!config_weechat_init ()) /* init WeeChat options (weechat.*) */ weechat_shutdown (EXIT_FAILURE, 0); weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dir (); /* create WeeChat home directory */ log_init (); /* init log file */ plugin_api_init (); /* create some hooks (info,hdata,..)*/ secure_read (); /* read secured data options */ config_weechat_read (); /* read WeeChat options */ network_init_gnutls (); /* init GnuTLS */ gui_main_init (); /* init WeeChat interface */ if (weechat_upgrading) { upgrade_weechat_load (); /* upgrade with session file */ weechat_upgrade_count++; /* increase /upgrade count */ } weechat_welcome_message (); /* display WeeChat welcome message */ gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */ command_startup (0); /* command executed before plugins */ plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */ argc, argv); command_startup (1); /* commands executed after plugins */ if (!weechat_upgrading) gui_layout_window_apply (gui_layout_current, -1); if (weechat_upgrading) upgrade_weechat_end (); /* remove .upgrade files + signal */ gui_main_loop (); /* WeeChat main loop */ gui_layout_store_on_exit (); /* store layout */ plugin_end (); /* end plugin interface(s) */ if (CONFIG_BOOLEAN(config_look_save_config_on_exit)) (void) config_weechat_write (); /* save WeeChat config file */ (void) secure_write (); /* save secured data */ gui_main_end (1); /* shut down WeeChat GUI */ proxy_free_all (); /* free all proxies */ config_weechat_free (); /* free WeeChat options */ secure_free (); /* free secured data options */ config_file_free_all (); /* free all configuration files */ gui_key_end (); /* remove all keys */ unhook_all (); /* remove all hooks */ hdata_end (); /* end hdata */ secure_end (); /* end secured data */ string_end (); /* end string */ weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ return EXIT_SUCCESS; /* make C compiler happy */ }
long RPC2_Init(const char *VId, /* magic version string */ RPC2_Options *Options, RPC2_PortIdent *Port, /* array of portal ids */ long RetryCount, /* max number of retries before breaking conn*/ struct timeval *KAInterval /* for keeping long RPC requests alive */ ) { char *c; long i; PROCESS ctpid; struct RPC2_addrinfo *rpc2_localaddrs; long rc1 = RPC2_NOCONNECTION, rc2, rc; short port = 0; int verbose; char *env; rpc2_logfile = stderr; rpc2_tracefile = stderr; rpc2_Enter(); say(1, RPC2_DebugLevel, "RPC2_Init()\n"); say(999, RPC2_DebugLevel, "Runtime system version: \"%s\"\n", RPC2_VERSION); if (strcmp(VId, RPC2_VERSION) != 0) { say(-1, RPC2_DebugLevel, "RPC2_Init(): Wrong RPC2 version\n"); rpc2_Quit (RPC2_WRONGVERSION); } /* rpc2_InitConn returns 0 if we're already initialized */ if (rpc2_InitConn() == 0) rpc2_Quit(RPC2_SUCCESS); if (Options && (Options->Flags & RPC2_OPTION_IPV6)) rpc2_ipv6ready = 1; env = getenv("RPC2SEC_KEYSIZE"); if (env) RPC2_Preferred_Keysize = atoi(env); if (RPC2_Preferred_Keysize > 64) RPC2_Preferred_Keysize /= 8; /* Do we accept only secure connections, default is yes. This can be * disabled by setting the RPC2SEC_ONLY to 0, false, no, (nada, forgetit) */ env = getenv("RPC2SEC_ONLY"); RPC2_secure_only = !env || (env && memchr("0fFnN", *env, 5) == NULL); verbose = (Options && (Options->Flags & RPC2_OPTION_VERBOSE_INIT)); secure_init(verbose); rpc2_InitMgrp(); rpc2_InitHost(); rpc2_localaddrs = rpc2_resolve(&rpc2_bindhost, Port); if (!rpc2_localaddrs) { say(-1, RPC2_DebugLevel, "RPC2_Init(): Couldn't get addrinfo for localhost!\n"); rpc2_Quit(RPC2_FAIL); } #ifdef PF_INET6 rc1 = rpc2_CreateIPSocket(PF_INET6, &rpc2_v6RequestSocket, rpc2_localaddrs, &port); #endif rc2 = rpc2_CreateIPSocket(PF_INET, &rpc2_v4RequestSocket, rpc2_localaddrs, &port); RPC2_freeaddrinfo(rpc2_localaddrs); /* rc should probably be the most 'positive' result of the two */ rc = (rc1 > rc2) ? rc1 : rc2; if (rc < RPC2_ELIMIT) { say(-1, RPC2_DebugLevel, "RPC2_Init(): Couldn't create socket\n"); rpc2_Quit(rc); } rpc2_LocalPort.Tag = RPC2_PORTBYINETNUMBER; rpc2_LocalPort.Value.InetPortNumber = port; if (Port) *Port = rpc2_LocalPort; /* Initialize retry parameters */ if (rpc2_InitRetry(RetryCount, KAInterval) != 0) { say(-1, RPC2_DebugLevel,"RPC2_Init(): Failed to init retryintervals\n"); rpc2_Quit(RPC2_FAIL); } IOMGR_Initialize(); TM_Init(&rpc2_TimerQueue); /* Register rpc2 packet handler with rpc2_SocketListener before * initializing the sideeffects */ SL_RegisterHandler(RPC2_PROTOVERSION, rpc2_HandlePacket); /* Call side effect initialization routines */ for (i = 0; i < SE_DefCount; i++) if (SE_DefSpecs[i].SE_Init != NULL) if ((*SE_DefSpecs[i].SE_Init)() < RPC2_ELIMIT) { say(-1, RPC2_DebugLevel, "RPC2_Init(): Failed to init SE\n"); rpc2_Quit(RPC2_SEFAIL2); } c = "SocketListener"; LWP_CreateProcess(rpc2_SocketListener, 32768, LWP_NORMAL_PRIORITY, NULL, c, &rpc2_SocketListenerPID); c = "ClockTick"; LWP_CreateProcess(rpc2_ClockTick, 16384, LWP_NORMAL_PRIORITY, NULL, c, &ctpid); LUA_init(); if (rc != RPC2_SUCCESS) say(-1, RPC2_DebugLevel, "RPC2_Init(): Exiting with error\n"); rpc2_Quit(rc); }