diff options
| -rw-r--r-- | doc/user-guide/commands.xml | 10 | ||||
| -rw-r--r-- | root_commands.c | 44 | ||||
| -rw-r--r-- | set.c | 9 | ||||
| -rw-r--r-- | set.h | 1 | 
4 files changed, 48 insertions, 16 deletions
| diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index b7af2027..05b9abea 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -133,6 +133,7 @@  			<syntax>account set <account id></syntax>  			<syntax>account set <account id>/<setting></syntax>  			<syntax>account set <account id>/<setting> <value></syntax> +			<syntax>account set -del <account id>/<setting></syntax>  			<description>  				<para> @@ -140,7 +141,7 @@  				</para>  				<para> -					For more infomation about a setting, see <emphasis>help set <setting></emphasis>. +					For more infomation about a setting, see <emphasis>help set <setting></emphasis>. For details about the syntax of this command, see <emphasis>help set</emphasis>.  				</para>  				<para> @@ -245,12 +246,15 @@  	<bitlbee-command name="set">  		<short-description>Miscellaneous settings</short-description> -		<syntax>set [<variable> [<value>]]</syntax> +		<syntax>set</syntax> +		<syntax>set <variable></syntax> +		<syntax>set <variable> <value></syntax> +		<syntax>set -del <variable></syntax>  		<description>  			<para> -				Without any arguments, this command lists all the set variables. You can also specify a single argument, a variable name, to get that variable's value. To change this value, specify the new value as the second argument. +				Without any arguments, this command lists all the set variables. You can also specify a single argument, a variable name, to get that variable's value. To change this value, specify the new value as the second argument. With <emphasis>-del</emphasis> you can reset a setting to its default value.  			</para>  			<para> diff --git a/root_commands.c b/root_commands.c index baaf3354..59852de6 100644 --- a/root_commands.c +++ b/root_commands.c @@ -367,15 +367,18 @@ static void cmd_account( irc_t *irc, char **cmd )  			return;  		} -		acc_handle = g_strdup( cmd[2] ); +		if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) +			acc_handle = g_strdup( cmd[3] ); +		else +			acc_handle = g_strdup( cmd[2] ); +		  		if( ( tmp = strchr( acc_handle, '/' ) ) )  		{  			*tmp = 0;  			set_name = tmp + 1;  		} -		a = account_get( irc, acc_handle ); -		if( a == NULL ) +		if( ( a = account_get( irc, acc_handle ) ) == NULL )  		{  			g_free( acc_handle );  			irc_usermsg( irc, "Invalid account" ); @@ -399,10 +402,12 @@ static void cmd_account( irc_t *irc, char **cmd )  				return;  			} -			set_setstr( &a->set, set_name, cmd[3] ); -			  			if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] )  				irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" ); +			else if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) +				set_reset( &a->set, set_name ); +			else +				set_setstr( &a->set, set_name, cmd[3] );  		}  		if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */  		{ @@ -418,7 +423,7 @@ static void cmd_account( irc_t *irc, char **cmd )  			while( s )  			{  				if( s->value || s->def ) -					irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); +					irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def );  				else  					irc_usermsg( irc, "%s is empty", s->key );  				s = s->next; @@ -739,20 +744,33 @@ static void cmd_yesno( irc_t *irc, char **cmd )  static void cmd_set( irc_t *irc, char **cmd )  { +	char *set_name; +	  	if( cmd[1] && cmd[2] )  	{ -		set_setstr( &irc->set, cmd[1], cmd[2] ); -		  		if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) +		{  			irc_usermsg( irc, "Warning: Correct syntax: \002set <variable> <value>\002 (without =)" ); +			return; +		} +		else if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) +		{ +			set_reset( &irc->set, cmd[2] ); +			set_name = cmd[2]; +		} +		else +		{ +			set_setstr( &irc->set, cmd[1], cmd[2] ); +			set_name = cmd[1]; +		}  	}  	if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */  	{ -		char *s = set_getstr( &irc->set, cmd[1] ); -		if( s ) -			irc_usermsg( irc, "%s = `%s'", cmd[1], s ); +		char *s = set_getstr( &irc->set, set_name ); + 		if( s ) +			irc_usermsg( irc, "%s = `%s'", set_name, s );  		else -			irc_usermsg( irc, "%s is empty", cmd[1] ); +			irc_usermsg( irc, "%s is empty", set_name );  	}  	else  	{ @@ -760,7 +778,7 @@ static void cmd_set( irc_t *irc, char **cmd )  		while( s )  		{  			if( s->value || s->def ) -				irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); +				irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def );  			else  				irc_usermsg( irc, "%s is empty", s->key );  			s = s->next; @@ -167,6 +167,15 @@ void set_del( set_t **head, char *key )  	}  } +void set_reset( set_t **head, char *key ) +{ +	set_t *s; +	 +	s = set_find( head, key ); +	if( s ) +		set_setstr( head, key, s->def ); +} +  char *set_eval_int( set_t *set, char *value )  {  	char *s = value; @@ -87,6 +87,7 @@ G_MODULE_EXPORT int set_getbool( set_t **head, char *key );  int set_setstr( set_t **head, char *key, char *value );  int set_setint( set_t **head, char *key, int value );  void set_del( set_t **head, char *key ); +void set_reset( set_t **head, char *key );  /* Two very useful generic evaluators. */  char *set_eval_int( set_t *set, char *value ); | 
