From f4aef7c706890f1a10a9972adf4c32eb734c614e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 13 Feb 2001 19:26:43 +0000 Subject: [PATCH] Added PROCESS_REC to fe-exec.h and perl support for it. "exec new" and "exec remove" sends PROCESS_REC as first argument. Added "exec input" signal to perl. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1212 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/fe-exec.c | 43 +++------------------------------- src/fe-common/core/fe-exec.h | 45 ++++++++++++++++++++++++++++++++++++ src/perl/get-signals.pl | 1 + src/perl/perl-common.c | 21 +++++++++++++++++ 4 files changed, 70 insertions(+), 40 deletions(-) create mode 100644 src/fe-common/core/fe-exec.h diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c index 520530aa..bc8f4691 100644 --- a/src/fe-common/core/fe-exec.c +++ b/src/fe-common/core/fe-exec.c @@ -28,48 +28,13 @@ #include "levels.h" #include "printtext.h" +#include "fe-exec.h" #include "fe-windows.h" #include "window-items.h" #include #include -#define EXEC_WI(query) \ - MODULE_CHECK_CAST_MODULE(query, EXEC_WI_REC, type, \ - "WINDOW ITEM TYPE", "EXEC") - -#define IS_EXEC_WI(query) \ - (EXEC_WI(query) ? TRUE : FALSE) - -typedef struct PROCESS_REC PROCESS_REC; - -#define STRUCT_SERVER_REC void -typedef struct { -#include "window-item-rec.h" - PROCESS_REC *process; - unsigned int destroying:1; -} EXEC_WI_REC; - -struct PROCESS_REC { - int id; - char *name; - char *args; - - int pid; - GIOChannel *in; - NET_SENDBUF_REC *out; - LINEBUF_REC *databuf; - int read_tag; - - char *target; /* send text with /msg ... */ - WINDOW_REC *target_win; /* print text to this window */ - EXEC_WI_REC *target_item; /* print text to this exec window item */ - - unsigned int shell:1; /* start the program via /bin/sh */ - unsigned int notice:1; /* send text with /notice, not /msg if target is set */ - unsigned int silent:1; /* don't print "process exited with level xx" */ -}; - static GSList *processes; static int signal_exec_input; @@ -198,8 +163,7 @@ static void process_destroy(PROCESS_REC *rec, int status) { processes = g_slist_remove(processes, rec); - signal_emit("exec remove", 4, GINT_TO_POINTER(rec->id), rec->name, - GINT_TO_POINTER(rec->pid), GINT_TO_POINTER(status)); + signal_emit("exec remove", 2, rec, GINT_TO_POINTER(status)); if (rec->read_tag != -1) g_source_remove(rec->read_tag); @@ -535,8 +499,7 @@ static void handle_exec(const char *args, GHashTable *optlist, if (rec->target == NULL && interactive) rec->target_item = exec_wi_create(active_win, rec); - signal_emit("exec new", 4, GINT_TO_POINTER(rec->id), rec->name, - GINT_TO_POINTER(rec->pid), rec->args); + signal_emit("exec new", 1, rec); } /* SYNTAX: EXEC [-] [-nosh] [-out | -msg | -notice ] diff --git a/src/fe-common/core/fe-exec.h b/src/fe-common/core/fe-exec.h new file mode 100644 index 00000000..7f569ece --- /dev/null +++ b/src/fe-common/core/fe-exec.h @@ -0,0 +1,45 @@ +#ifndef __FE_EXEC_H +#define __FE_EXEC_H + +#include "fe-windows.h" + +#define EXEC_WI(query) \ + MODULE_CHECK_CAST_MODULE(query, EXEC_WI_REC, type, \ + "WINDOW ITEM TYPE", "EXEC") + +#define IS_EXEC_WI(query) \ + (EXEC_WI(query) ? TRUE : FALSE) + +typedef struct PROCESS_REC PROCESS_REC; + +#define STRUCT_SERVER_REC void +typedef struct { +#include "window-item-rec.h" + PROCESS_REC *process; + unsigned int destroying:1; +} EXEC_WI_REC; + +struct PROCESS_REC { + int id; + char *name; + char *args; + + int pid; + GIOChannel *in; + NET_SENDBUF_REC *out; + LINEBUF_REC *databuf; + int read_tag; + + char *target; /* send text with /msg ... */ + WINDOW_REC *target_win; /* print text to this window */ + EXEC_WI_REC *target_item; /* print text to this exec window item */ + + unsigned int shell:1; /* start the program via /bin/sh */ + unsigned int notice:1; /* send text with /notice, not /msg if target is set */ + unsigned int silent:1; /* don't print "process exited with level xx" */ +}; + +void fe_exec_init(void); +void fe_exec_deinit(void); + +#endif diff --git a/src/perl/get-signals.pl b/src/perl/get-signals.pl index 29ec7e5e..70263d08 100755 --- a/src/perl/get-signals.pl +++ b/src/perl/get-signals.pl @@ -43,6 +43,7 @@ while () { # fe-common s/THEME_REC[^,]*/Irssi::Theme/g; s/KEYINFO_REC[^,]*/Irssi::Keyinfo/g; + s/PROCESS_REC[^,]*/Irssi::Process/g; s/WINDOW_REC[^,]*/Irssi::Window/g; s/WI_ITEM_REC[^,]*/iobject/g; diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index de5e2453..7d53446b 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -38,6 +38,7 @@ #include "perl-common.h" +#include "fe-common/core/fe-exec.h" #include "fe-common/core/formats.h" #include "fe-common/core/printtext.h" @@ -390,6 +391,25 @@ void perl_reconnect_fill_hash(HV *hv, RECONNECT_REC *reconnect) hv_store(hv, "next_connect", 12, newSViv(reconnect->next_connect), 0); } +void perl_process_fill_hash(HV *hv, PROCESS_REC *process) +{ + HV *stash; + + hv_store(hv, "id", 2, newSViv(process->id), 0); + hv_store(hv, "name", 4, new_pv(process->name), 0); + hv_store(hv, "args", 4, new_pv(process->args), 0); + + hv_store(hv, "pid", 3, newSViv(process->pid), 0); + hv_store(hv, "target", 6, new_pv(process->target), 0); + if (process->target_win != NULL) { + stash = gv_stashpv("Irssi::Window", 0); + hv_store(hv, "target_win", 10, sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(process->target_win))), stash), 0); + } + hv_store(hv, "shell", 5, newSViv(process->shell), 0); + hv_store(hv, "notice", 6, newSViv(process->notice), 0); + hv_store(hv, "silent", 6, newSViv(process->silent), 0); +} + void perl_window_fill_hash(HV *hv, WINDOW_REC *window) { hv_store(hv, "refnum", 6, newSViv(window->refnum), 0); @@ -567,6 +587,7 @@ void perl_common_init(void) { "Irssi::Logitem", (PERL_OBJECT_FUNC) perl_log_item_fill_hash }, { "Irssi::Rawlog", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash }, { "Irssi::Reconnect", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash }, + { "Irssi::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash }, { "Irssi::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash }, { NULL, NULL }