Add Irssi::command_parse_options function to parse options for a command which

have been set with Irssi::command_set_options.


git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4896 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2008-11-11 23:33:47 +00:00 committed by exg
commit f0647439a9
2 changed files with 44 additions and 0 deletions

View file

@ -57,6 +57,14 @@ static void handle_command_bind(int priority, int items, SV *p0, SV *p1, SV *p2)
}
}
static void add_tuple(gpointer key_, gpointer value_, gpointer user_data)
{
HV *hash = user_data;
char *key = key_;
char *value = value_;
hv_store(hash, key, strlen(key), new_pv(value), 0);
}
MODULE = Irssi::Core PACKAGE = Irssi
PROTOTYPES: ENABLE
@ -552,6 +560,28 @@ command_set_options(cmd, options)
char *cmd
char *options
void
command_parse_options(cmd, data)
char *cmd
char *data
PREINIT:
HV *hash;
GHashTable *optlist;
void *free_arg;
char *ptr;
PPCODE:
if (cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
cmd, &optlist, &ptr)) {
hash = newHV();
g_hash_table_foreach(optlist, add_tuple, hash);
XPUSHs(sv_2mortal(newRV_noinc((SV*)hash)));
XPUSHs(sv_2mortal(new_pv(ptr)));
cmd_params_free(free_arg);
} else {
XPUSHs(&PL_sv_undef);
XPUSHs(&PL_sv_undef);
}
void
pidwait_add(pid)
int pid