Changeset cd428e4


Ignore:
Timestamp:
2007-11-17T12:20:51Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
256899f
Parents:
1bf1ae6
Message:

Added (account) set -del.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • doc/user-guide/commands.xml

    r1bf1ae6 rcd428e4  
    134134                        <syntax>account set &lt;account id&gt;/&lt;setting&gt;</syntax>
    135135                        <syntax>account set &lt;account id&gt;/&lt;setting&gt; &lt;value&gt;</syntax>
     136                        <syntax>account set -del &lt;account id&gt;/&lt;setting&gt;</syntax>
    136137
    137138                        <description>
     
    141142                               
    142143                                <para>
    143                                         For more infomation about a setting, see <emphasis>help set &lt;setting&gt;</emphasis>.
     144                                        For more infomation about a setting, see <emphasis>help set &lt;setting&gt;</emphasis>. For details about the syntax of this command, see <emphasis>help set</emphasis>.
    144145                                </para>
    145146                               
     
    246247        <bitlbee-command name="set">
    247248                <short-description>Miscellaneous settings</short-description>
    248                 <syntax>set [&lt;variable&gt; [&lt;value&gt;]]</syntax>
    249 
    250                 <description>
    251 
    252                         <para>
    253                                 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.
     249                <syntax>set</syntax>
     250                <syntax>set &lt;variable&gt;</syntax>
     251                <syntax>set &lt;variable&gt; &lt;value&gt;</syntax>
     252                <syntax>set -del &lt;variable&gt;</syntax>
     253
     254                <description>
     255
     256                        <para>
     257                                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.
    254258                        </para>
    255259
  • root_commands.c

    r1bf1ae6 rcd428e4  
    368368                }
    369369               
    370                 acc_handle = g_strdup( cmd[2] );
     370                if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 )
     371                        acc_handle = g_strdup( cmd[3] );
     372                else
     373                        acc_handle = g_strdup( cmd[2] );
     374               
    371375                if( ( tmp = strchr( acc_handle, '/' ) ) )
    372376                {
     
    374378                        set_name = tmp + 1;
    375379                }
    376                 a = account_get( irc, acc_handle );
    377                
    378                 if( a == NULL )
     380               
     381                if( ( a = account_get( irc, acc_handle ) ) == NULL )
    379382                {
    380383                        g_free( acc_handle );
     
    400403                        }
    401404                       
    402                         set_setstr( &a->set, set_name, cmd[3] );
    403                        
    404405                        if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] )
    405406                                irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" );
     407                        else if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 )
     408                                set_reset( &a->set, set_name );
     409                        else
     410                                set_setstr( &a->set, set_name, cmd[3] );
    406411                }
    407412                if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */
     
    419424                        {
    420425                                if( s->value || s->def )
    421                                         irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def );
     426                                        irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def );
    422427                                else
    423428                                        irc_usermsg( irc, "%s is empty", s->key );
     
    740745static void cmd_set( irc_t *irc, char **cmd )
    741746{
     747        char *set_name;
     748       
    742749        if( cmd[1] && cmd[2] )
    743750        {
    744                 set_setstr( &irc->set, cmd[1], cmd[2] );
    745                
    746751                if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] )
     752                {
    747753                        irc_usermsg( irc, "Warning: Correct syntax: \002set <variable> <value>\002 (without =)" );
     754                        return;
     755                }
     756                else if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 )
     757                {
     758                        set_reset( &irc->set, cmd[2] );
     759                        set_name = cmd[2];
     760                }
     761                else
     762                {
     763                        set_setstr( &irc->set, cmd[1], cmd[2] );
     764                        set_name = cmd[1];
     765                }
    748766        }
    749767        if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */
    750768        {
    751                 char *s = set_getstr( &irc->set, cmd[1] );
    752                 if( s )
    753                         irc_usermsg( irc, "%s = `%s'", cmd[1], s );
    754                 else
    755                         irc_usermsg( irc, "%s is empty", cmd[1] );
     769                char *s = set_getstr( &irc->set, set_name );
     770                if( s )
     771                        irc_usermsg( irc, "%s = `%s'", set_name, s );
     772                else
     773                        irc_usermsg( irc, "%s is empty", set_name );
    756774        }
    757775        else
     
    761779                {
    762780                        if( s->value || s->def )
    763                                 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def );
     781                                irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def );
    764782                        else
    765783                                irc_usermsg( irc, "%s is empty", s->key );
  • set.c

    r1bf1ae6 rcd428e4  
    168168}
    169169
     170void set_reset( set_t **head, char *key )
     171{
     172        set_t *s;
     173       
     174        s = set_find( head, key );
     175        if( s )
     176                set_setstr( head, key, s->def );
     177}
     178
    170179char *set_eval_int( set_t *set, char *value )
    171180{
  • set.h

    r1bf1ae6 rcd428e4  
    8888int set_setint( set_t **head, char *key, int value );
    8989void set_del( set_t **head, char *key );
     90void set_reset( set_t **head, char *key );
    9091
    9192/* Two very useful generic evaluators. */
Note: See TracChangeset for help on using the changeset viewer.