2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
irssi.c : irssi
|
|
|
|
|
|
|
|
Copyright (C) 1999-2000 Timo Sirainen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2007-05-08 14:41:10 -04:00
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2000-04-26 04:03:38 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
2019-05-01 10:33:47 -04:00
|
|
|
#include <irssi/src/core/modules.h>
|
|
|
|
#include <irssi/src/core/modules-load.h>
|
|
|
|
#include <irssi/src/core/args.h>
|
|
|
|
#include <irssi/src/core/signals.h>
|
2021-03-27 06:05:54 -04:00
|
|
|
#include <irssi/src/core/settings.h>
|
2019-05-01 10:33:47 -04:00
|
|
|
#include <irssi/src/core/core.h>
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
static GMainLoop *main_loop;
|
|
|
|
static char *autoload_module;
|
|
|
|
static int reload;
|
2022-07-19 10:29:03 -04:00
|
|
|
static int quitting;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
static void sig_exit(void)
|
|
|
|
{
|
2022-07-19 10:29:03 -04:00
|
|
|
quitting = TRUE;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sig_reload(void)
|
|
|
|
{
|
|
|
|
reload = TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-27 06:05:54 -04:00
|
|
|
static void autoload_modules(void)
|
|
|
|
{
|
|
|
|
char **list, **module;
|
|
|
|
list = g_strsplit_set(settings_get_str("autoload_modules"), " ,", -1);
|
|
|
|
for (module = list; *module != NULL; module++) {
|
|
|
|
char *tmp;
|
|
|
|
if ((tmp = strchr(*module, ':')) != NULL) {
|
|
|
|
*tmp = '\0';
|
|
|
|
tmp++;
|
|
|
|
module_load_sub(*module, tmp, NULL);
|
|
|
|
} else {
|
|
|
|
module_load(*module, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_strfreev(list);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void noui_init(void)
|
|
|
|
{
|
2006-03-26 03:42:34 -05:00
|
|
|
srand(time(NULL));
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
irssi_gui = IRSSI_GUI_NONE;
|
|
|
|
core_init();
|
|
|
|
|
2001-08-13 20:43:50 -04:00
|
|
|
module_register("core", "fe-none");
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_add("reload", (SIGNAL_FUNC) sig_reload);
|
|
|
|
signal_add("gui exit", (SIGNAL_FUNC) sig_exit);
|
2000-10-14 11:19:56 -04:00
|
|
|
|
2021-03-27 06:05:54 -04:00
|
|
|
autoload_modules();
|
|
|
|
|
2001-10-21 05:25:29 -04:00
|
|
|
signal_emit("irssi init finished", 0);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void noui_deinit(void)
|
|
|
|
{
|
|
|
|
signal_remove("reload", (SIGNAL_FUNC) sig_reload);
|
|
|
|
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
|
|
|
|
core_deinit();
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2008-02-03 11:48:02 -05:00
|
|
|
static GOptionEntry options[] = {
|
|
|
|
{ "load", 'l', 0, G_OPTION_ARG_STRING, &autoload_module, "Module to load (default = bot)", "MODULE" },
|
|
|
|
{ NULL }
|
2007-05-29 04:19:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
autoload_module = NULL;
|
|
|
|
core_register_options();
|
|
|
|
args_register(options);
|
|
|
|
args_execute(argc, argv);
|
|
|
|
core_preinit(argv[0]);
|
2001-07-14 20:39:48 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
noui_init();
|
|
|
|
|
|
|
|
if (autoload_module == NULL)
|
|
|
|
autoload_module = "bot";
|
|
|
|
|
|
|
|
do {
|
|
|
|
reload = FALSE;
|
2001-03-30 20:54:53 -05:00
|
|
|
module_load(autoload_module, NULL);
|
2019-10-31 18:49:40 -04:00
|
|
|
main_loop = g_main_loop_new(NULL, TRUE);
|
2022-07-19 10:29:03 -04:00
|
|
|
while (!quitting && !reload) {
|
|
|
|
if (sigterm_received) {
|
|
|
|
sigterm_received = FALSE;
|
|
|
|
signal_emit("gui exit", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_main_context_iteration(NULL, TRUE);
|
|
|
|
}
|
2019-10-31 18:49:40 -04:00
|
|
|
g_main_loop_unref(main_loop);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
while (reload);
|
|
|
|
noui_deinit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|