Changeset 5100caa for lib/misc.c


Ignore:
Timestamp:
2006-07-01T15:52:05Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fef6116
Parents:
0a3c243
Message:

Added "account set" command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    r0a3c243 r5100caa  
    486486        }
    487487}
     488
     489int is_bool( char *value )
     490{
     491        if( *value == 0 )
     492                return 0;
     493       
     494        if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) )
     495                return 1;
     496        if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) )
     497                return 1;
     498       
     499        while( *value )
     500                if( !isdigit( *value ) )
     501                        return 0;
     502                else
     503                        value ++;
     504       
     505        return 1;
     506}
     507
     508int bool2int( char *value )
     509{
     510        int i;
     511       
     512        if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) )
     513                return 1;
     514        if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) )
     515                return 0;
     516       
     517        if( sscanf( value, "%d", &i ) == 1 )
     518                return i;
     519       
     520        return 0;
     521}
Note: See TracChangeset for help on using the changeset viewer.