Fix argument-handling for the /hostname (/irchost) command - now you can do
/hostname 2 instead of /hostname #2. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@75 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -2948,21 +2948,31 @@ BUILT_IN_COMMAND(e_hostname)
|
|||||||
{
|
{
|
||||||
int norev = 0;
|
int norev = 0;
|
||||||
char *newhost = NULL;
|
char *newhost = NULL;
|
||||||
|
char *arg = next_arg(args, &args);
|
||||||
|
|
||||||
if (args && !strcasecmp(args, "-norev"))
|
if (arg && !strcasecmp(arg, "-norev"))
|
||||||
{
|
{
|
||||||
norev = 1;
|
norev = 1;
|
||||||
next_arg(args, &args);
|
arg = next_arg(args, &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args && *args && *args != '#')
|
if (arg && *arg && *arg != '#' && !is_number(arg))
|
||||||
{
|
{
|
||||||
malloc_strcpy(&newhost, args);
|
malloc_strcpy(&newhost, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Virtuals *virtuals, *new;
|
Virtuals *virtuals, *new;
|
||||||
int i;
|
int i;
|
||||||
|
int switch_to = 0;
|
||||||
|
|
||||||
|
if (arg)
|
||||||
|
{
|
||||||
|
if (*arg == '#')
|
||||||
|
arg++;
|
||||||
|
|
||||||
|
switch_to = my_atol(arg);
|
||||||
|
}
|
||||||
|
|
||||||
get_local_addrs(&virtuals, norev);
|
get_local_addrs(&virtuals, norev);
|
||||||
|
|
||||||
@@ -2974,14 +2984,11 @@ BUILT_IN_COMMAND(e_hostname)
|
|||||||
put_it("%s", convert_output_format("$G Current hostnames available", NULL, NULL));
|
put_it("%s", convert_output_format("$G Current hostnames available", NULL, NULL));
|
||||||
|
|
||||||
put_it("%s", convert_output_format("%K[%W$[3]0%K] %B$1", "%d %s", i, new->hostname));
|
put_it("%s", convert_output_format("%K[%W$[3]0%K] %B$1", "%d %s", i, new->hostname));
|
||||||
if (args && *args)
|
if (i == switch_to)
|
||||||
{
|
newhost = new->hostname;
|
||||||
if (*args == '#') args++;
|
else
|
||||||
if (args && *args && (i == my_atol(args)))
|
new_free(&new->hostname);
|
||||||
malloc_strcpy(&newhost, new->hostname);
|
|
||||||
}
|
|
||||||
new_free(&new->address);
|
new_free(&new->address);
|
||||||
new_free(&new->hostname);
|
|
||||||
new_free(&new);
|
new_free(&new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user