Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • set.c

    r88eaf4b r06b5893  
    2929char *SET_INVALID = "nee";
    3030
    31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data )
     31set_t *set_add( set_t **head, const char *key, const char *def, set_eval eval, void *data )
    3232{
    3333        set_t *s = set_find( head, key );
     
    6363}
    6464
    65 set_t *set_find( set_t **head, char *key )
     65set_t *set_find( set_t **head, const char *key )
    6666{
    6767        set_t *s = *head;
     
    7878}
    7979
    80 char *set_getstr( set_t **head, char *key )
     80char *set_getstr( set_t **head, const char *key )
    8181{
    8282        set_t *s = set_find( head, key );
     
    8888}
    8989
    90 int set_getint( set_t **head, char *key )
     90int set_getint( set_t **head, const char *key )
    9191{
    9292        char *s = set_getstr( head, key );
     
    102102}
    103103
    104 int set_getbool( set_t **head, char *key )
     104int set_getbool( set_t **head, const char *key )
    105105{
    106106        char *s = set_getstr( head, key );
     
    112112}
    113113
    114 int set_setstr( set_t **head, char *key, char *value )
     114int set_isvisible( set_t *set )
     115{
     116        /* the default value is not stored in value, only in def */
     117        return !( ( set->flags & SET_HIDDEN ) ||
     118                  ( ( set->flags & SET_HIDDEN_DEFAULT ) &&
     119                    ( set->value == NULL ) ) );
     120}
     121
     122int set_setstr( set_t **head, const char *key, char *value )
    115123{
    116124        set_t *s = set_find( head, key );
     
    151159}
    152160
    153 int set_setint( set_t **head, char *key, int value )
     161int set_setint( set_t **head, const char *key, int value )
    154162{
    155163        char s[24];     /* Not quite 128-bit clean eh? ;-) */
     
    159167}
    160168
    161 void set_del( set_t **head, char *key )
     169void set_del( set_t **head, const char *key )
    162170{
    163171        set_t *s = *head, *t = NULL;
     
    184192}
    185193
    186 int set_reset( set_t **head, char *key )
     194int set_reset( set_t **head, const char *key )
    187195{
    188196        set_t *s;
     
    213221{
    214222        return is_bool( value ) ? value : SET_INVALID;
     223}
     224
     225char *set_eval_list( set_t *set, char *value )
     226{
     227        GSList *options = set->eval_data, *opt;
     228       
     229        for( opt = options; opt; opt = opt->next )
     230                if( strcmp( value, opt->data ) == 0 )
     231                        return value;
     232       
     233        /* TODO: It'd be nice to show the user a list of allowed values,
     234                 but we don't have enough context here to do that. May
     235                 want to fix that. */
     236       
     237        return NULL;
    215238}
    216239
Note: See TracChangeset for help on using the changeset viewer.