1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Separate irssi-dummy binary was a bit stupid idea, now it can be started with -d command line parameter.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2264 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-12-17 18:41:06 +00:00 committed by cras
parent 475aa27588
commit 35d363136f
3 changed files with 63 additions and 160 deletions

View File

@ -8,24 +8,18 @@ INCLUDES = \
$(CURSES_INCLUDEDIR) \ $(CURSES_INCLUDEDIR) \
-DLOCALEDIR=\""$(datadir)/locale"\" -DLOCALEDIR=\""$(datadir)/locale"\"
IRSSIDEPS = \ irssi_DEPENDENCIES = \
@COMMON_LIBS@ \ @COMMON_LIBS@ \
@PERL_LINK_LIBS@ \ @PERL_LINK_LIBS@ \
@PERL_FE_LINK_LIBS@ @PERL_FE_LINK_LIBS@
irssi_DEPENDENCIES = $(IRSSIDEPS) irssi_LDADD = \
irssi_dummy_DEPENDENCIES = $(IRSSIDEPS)
IRSSILINK = \
@COMMON_LIBS@ \ @COMMON_LIBS@ \
@PERL_LINK_LIBS@ \ @PERL_LINK_LIBS@ \
@PERL_FE_LINK_LIBS@ \ @PERL_FE_LINK_LIBS@ \
@PERL_LINK_FLAGS@ \ @PERL_LINK_FLAGS@ \
@PROG_LIBS@ @PROG_LIBS@
irssi_LDADD = $(IRSSILINK)
irssi_dummy_LDADD = $(IRSSILINK)
tparm_sources = \ tparm_sources = \
tparm.c tparm.c
@ -46,9 +40,6 @@ else
use_term_sources = $(terminfo_sources) use_term_sources = $(terminfo_sources)
endif endif
irssi_dummy_SOURCES = \
irssi-dummy.c
irssi_SOURCES = \ irssi_SOURCES = \
gui-entry.c \ gui-entry.c \
gui-expandos.c \ gui-expandos.c \
@ -63,6 +54,7 @@ irssi_SOURCES = \
statusbar-config.c \ statusbar-config.c \
statusbar-items.c \ statusbar-items.c \
term.c \ term.c \
term-dummy.c \
$(use_tparm_sources) \ $(use_tparm_sources) \
$(use_term_sources) \ $(use_term_sources) \
textbuffer.c \ textbuffer.c \

View File

@ -72,7 +72,10 @@ void mainwindow_activity_deinit(void);
void mainwindows_layout_init(void); void mainwindows_layout_init(void);
void mainwindows_layout_deinit(void); void mainwindows_layout_deinit(void);
static int dirty, full_redraw; void term_dummy_init(void);
void term_dummy_deinit(void);
static int dirty, full_redraw, dummy;
static GMainLoop *main_loop; static GMainLoop *main_loop;
int quitting; int quitting;
@ -107,7 +110,7 @@ void irssi_set_dirty(void)
static void dirty_check(void) static void dirty_check(void)
{ {
if (!dirty) if (!dirty || dummy)
return; return;
term_resize_dirty(); term_resize_dirty();
@ -147,6 +150,9 @@ static void textui_finish_init(void)
{ {
quitting = FALSE; quitting = FALSE;
if (dummy)
term_dummy_init();
else {
term_refresh_freeze(); term_refresh_freeze();
textbuffer_init(); textbuffer_init();
textbuffer_view_init(); textbuffer_view_init();
@ -162,6 +168,7 @@ static void textui_finish_init(void)
gui_windows_init(); gui_windows_init();
statusbar_init(); statusbar_init();
term_refresh_thaw(); term_refresh_thaw();
}
settings_check(); settings_check();
module_register("core", "fe-text"); module_register("core", "fe-text");
@ -198,6 +205,9 @@ static void textui_deinit(void)
dirty_check(); /* one last time to print any quit messages */ dirty_check(); /* one last time to print any quit messages */
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit); signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
if (dummy)
term_dummy_deinit();
else {
lastlog_deinit(); lastlog_deinit();
statusbar_deinit(); statusbar_deinit();
gui_printtext_deinit(); gui_printtext_deinit();
@ -214,6 +224,7 @@ static void textui_deinit(void)
term_refresh_thaw(); term_refresh_thaw();
term_deinit(); term_deinit();
}
theme_unregister(); theme_unregister();
@ -288,6 +299,12 @@ static void winsock_init(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
static struct poptOption options[] = {
{ "dummy", 'd', POPT_ARG_NONE, &dummy, 0, "Use the dummy terminal mode", NULL },
{ NULL, '\0', 0, NULL }
};
dummy = FALSE;
quitting = FALSE; quitting = FALSE;
core_init_paths(argc, argv); core_init_paths(argc, argv);
@ -305,10 +322,14 @@ int main(int argc, char **argv)
#endif #endif
textui_init(); textui_init();
args_register(options);
args_execute(argc, argv); args_execute(argc, argv);
if (!term_init()) if (!dummy && !term_init()) {
g_error("Can't initialize screen handling, quitting.\n"); fprintf(stderr, "Can't initialize screen handling, quitting.\n");
fprintf(stderr, "You can still use the dummy mode with -d parameter\n");
return 1;
}
textui_finish_init(); textui_finish_init();
main_loop = g_main_new(TRUE); main_loop = g_main_new(TRUE);

View File

@ -1,7 +1,7 @@
/* /*
irssi-dummy.c : irssi term-dummy.c : irssi
Copyright (C) 1999-2001 Timo Sirainen Copyright (C) 2001 Timo Sirainen
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -19,47 +19,16 @@
*/ */
#include "module.h" #include "module.h"
#include "module-formats.h"
#include "modules-load.h"
#include "args.h"
#include "signals.h" #include "signals.h"
#include "levels.h"
#include "core.h"
#include "settings.h"
#include "session.h"
#include "printtext.h"
#include "fe-common-core.h"
#include "fe-windows.h" #include "fe-windows.h"
#include <signal.h>
#ifdef HAVE_STATIC_PERL
void perl_core_init(void);
void perl_core_deinit(void);
void fe_perl_init(void);
void fe_perl_deinit(void);
#endif
void irc_init(void);
void irc_deinit(void);
void fe_common_irc_init(void);
void fe_common_irc_deinit(void);
static GMainLoop *main_loop;
static int newline; static int newline;
static GIOChannel *stdin_channel; static GIOChannel *stdin_channel;
static int readtag; static int readtag;
static GString *input; static GString *input;
static void sig_exit(void)
{
g_main_quit(main_loop);
}
static void sig_gui_printtext(WINDOW_REC *window, void *fgcolor, static void sig_gui_printtext(WINDOW_REC *window, void *fgcolor,
void *bgcolor, void *pflags, void *bgcolor, void *pflags,
char *str, void *level) char *str, void *level)
@ -84,16 +53,6 @@ static void sig_window_created(WINDOW_REC *window)
window->height = 25; window->height = 25;
} }
static void dummyui_init(void)
{
irssi_gui = IRSSI_GUI_TEXT;
core_init();
irc_init();
fe_common_core_init();
fe_common_irc_init();
}
static void readline(void) static void readline(void)
{ {
unsigned char buffer[128]; unsigned char buffer[128];
@ -120,97 +79,28 @@ static void readline(void)
} }
} }
static void dummyui_finish_init(void) void term_dummy_init(void)
{ {
settings_check();
module_register("core", "fe-text");
#ifdef HAVE_STATIC_PERL
perl_core_init();
fe_perl_init();
#endif
newline = TRUE; newline = TRUE;
input = g_string_new(NULL);
signal_add("gui print text", (SIGNAL_FUNC) sig_gui_printtext); signal_add("gui print text", (SIGNAL_FUNC) sig_gui_printtext);
signal_add("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); signal_add("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished);
signal_add("window created", (SIGNAL_FUNC) sig_window_created); signal_add("window created", (SIGNAL_FUNC) sig_window_created);
signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit);
input = g_string_new(NULL);
stdin_channel = g_io_channel_unix_new(0); stdin_channel = g_io_channel_unix_new(0);
readtag = g_input_add_full(stdin_channel, readtag = g_input_add_full(stdin_channel,
G_PRIORITY_HIGH, G_INPUT_READ, G_PRIORITY_HIGH, G_INPUT_READ,
(GInputFunction) readline, NULL); (GInputFunction) readline, NULL);
g_io_channel_unref(stdin_channel); g_io_channel_unref(stdin_channel);
fe_common_core_finish_init();
signal_emit("irssi init finished", 0);
} }
static void dummyui_deinit(void) void term_dummy_deinit(void)
{ {
signal(SIGINT, SIG_DFL);
while (modules != NULL)
module_unload(modules->data);
#ifdef HAVE_STATIC_PERL
perl_core_deinit();
fe_perl_deinit();
#endif
signal_remove("gui print text", (SIGNAL_FUNC) sig_gui_printtext); signal_remove("gui print text", (SIGNAL_FUNC) sig_gui_printtext);
signal_remove("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); signal_remove("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished);
signal_remove("window created", (SIGNAL_FUNC) sig_window_created); signal_remove("window created", (SIGNAL_FUNC) sig_window_created);
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
g_source_remove(readtag); g_source_remove(readtag);
g_string_free(input, TRUE); g_string_free(input, TRUE);
fe_common_irc_deinit();
fe_common_core_deinit();
irc_deinit();
core_deinit();
}
#ifdef WIN32
static void winsock_init(void)
{
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(2, 2);
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
printf("Error initializing winsock\n");
exit(1);
}
}
#endif
int main(int argc, char **argv)
{
core_init_paths(argc, argv);
#ifdef WIN32
winsock_init();
#endif
#ifdef HAVE_SOCKS
SOCKSinit(argv[0]);
#endif
dummyui_init();
args_execute(argc, argv);
dummyui_finish_init();
main_loop = g_main_new(TRUE);
g_main_run(main_loop);
g_main_destroy(main_loop);
dummyui_deinit();
session_upgrade(); /* if we /UPGRADEd, start the new process */
return 0;
} }