forked from PsychoticNinja/irssi
Added PARAM_FLAG_OPTCHAN_NAME which is like PARAM_FLAG_OPTCHAN, but doesn't
allow using "*" to specify active channel. Used with /OP, /DEOP, /VOICE and /DEVOICE so you can do /OP * again :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2380 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
78542cb0f7
commit
aa544dec32
@ -640,7 +640,8 @@ typedef struct {
|
|||||||
GHashTable *options;
|
GHashTable *options;
|
||||||
} CMD_TEMP_REC;
|
} CMD_TEMP_REC;
|
||||||
|
|
||||||
static char *get_optional_channel(WI_ITEM_REC *active_item, char **data)
|
static char *get_optional_channel(WI_ITEM_REC *active_item, char **data,
|
||||||
|
int require_name)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
CHANNEL_REC *chanrec;
|
||||||
char *tmp, *origtmp, *channel, *ret;
|
char *tmp, *origtmp, *channel, *ret;
|
||||||
@ -653,7 +654,7 @@ static char *get_optional_channel(WI_ITEM_REC *active_item, char **data)
|
|||||||
origtmp = tmp = g_strdup(*data);
|
origtmp = tmp = g_strdup(*data);
|
||||||
channel = cmd_get_param(&tmp);
|
channel = cmd_get_param(&tmp);
|
||||||
|
|
||||||
if (strcmp(channel, "*") == 0) {
|
if (strcmp(channel, "*") == 0 && !require_name) {
|
||||||
/* "*" means active channel */
|
/* "*" means active channel */
|
||||||
cmd_get_param(data);
|
cmd_get_param(data);
|
||||||
ret = active_item->name;
|
ret = active_item->name;
|
||||||
@ -680,7 +681,7 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
|
|||||||
GHashTable **opthash;
|
GHashTable **opthash;
|
||||||
char **str, *arg, *datad;
|
char **str, *arg, *datad;
|
||||||
va_list args;
|
va_list args;
|
||||||
int cnt, error, ignore_unknown;
|
int cnt, error, ignore_unknown, require_name;
|
||||||
|
|
||||||
g_return_val_if_fail(data != NULL, FALSE);
|
g_return_val_if_fail(data != NULL, FALSE);
|
||||||
|
|
||||||
@ -714,7 +715,8 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
|
|||||||
cnt = PARAM_WITHOUT_FLAGS(count);
|
cnt = PARAM_WITHOUT_FLAGS(count);
|
||||||
if (count & PARAM_FLAG_OPTCHAN) {
|
if (count & PARAM_FLAG_OPTCHAN) {
|
||||||
/* optional channel as first parameter */
|
/* optional channel as first parameter */
|
||||||
arg = get_optional_channel(item, &datad);
|
require_name = (count & PARAM_FLAG_OPTCHAN_NAME);
|
||||||
|
arg = get_optional_channel(item, &datad, require_name);
|
||||||
|
|
||||||
str = (char **) va_arg(args, char **);
|
str = (char **) va_arg(args, char **);
|
||||||
if (str != NULL) *str = arg;
|
if (str != NULL) *str = arg;
|
||||||
|
@ -135,6 +135,8 @@ int command_have_option(const char *cmd, const char *option);
|
|||||||
#define PARAM_FLAG_UNKNOWN_OPTIONS 0x00008000
|
#define PARAM_FLAG_UNKNOWN_OPTIONS 0x00008000
|
||||||
/* optional channel in first argument */
|
/* optional channel in first argument */
|
||||||
#define PARAM_FLAG_OPTCHAN 0x00010000
|
#define PARAM_FLAG_OPTCHAN 0x00010000
|
||||||
|
/* optional channel in first argument, but don't treat "*" as current channel */
|
||||||
|
#define PARAM_FLAG_OPTCHAN_NAME 0x00030000
|
||||||
|
|
||||||
char *cmd_get_param(char **data);
|
char *cmd_get_param(char **data);
|
||||||
/* get parameters from command - you should point free_me somewhere and
|
/* get parameters from command - you should point free_me somewhere and
|
||||||
|
@ -591,7 +591,7 @@ static char *get_nicks(IRC_SERVER_REC *server, WI_ITEM_REC *item,
|
|||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
||||||
PARAM_FLAG_OPTCHAN, item, &channame, &nicks))
|
PARAM_FLAG_OPTCHAN_NAME, item, &channame, &nicks))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (*nicks == '\0')
|
if (*nicks == '\0')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user