Changeset d5ccd83


Ignore:
Timestamp:
2006-08-13T19:15:23Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
08cdb93
Parents:
846cec61
Message:

Extra comments in set.h and now properly using set_getbool() instead of
set_getint().

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r846cec61 rd5ccd83  
    213213        log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
    214214       
    215         if( irc->status & USTATUS_IDENTIFIED && set_getint( &irc->set, "save_on_quit" ) )
     215        if( irc->status & USTATUS_IDENTIFIED && set_getbool( &irc->set, "save_on_quit" ) )
    216216                if( storage_save( irc, TRUE ) != STORAGE_OK )
    217217                        irc_usermsg( irc, "Error while saving settings!" );
     
    10581058        if( !u || !u->gc ) return;
    10591059       
    1060         if( set_getint( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 )
     1060        if( set_getbool( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 )
    10611061        {
    10621062                int delay;
  • protocols/nogaim.c

    r846cec61 rd5ccd83  
    208208
    209209        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    210             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )
     210            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    211211                strip_html( text );
    212212       
     
    353353        irc_t *irc = gc->irc;
    354354       
    355         if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */
     355        if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
    356356                serv_got_crap( gc, "Receiving user add from handle: %s", handle );
    357357       
    358358        if( user_findhandle( gc, handle ) )
    359359        {
    360                 if( set_getint( &irc->set, "debug" ) )
     360                if( set_getbool( &irc->set, "debug" ) )
    361361                        serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );
    362362               
     
    446446                u->realname = g_strdup( realname );
    447447               
    448                 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) )
     448                if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )
    449449                        serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );
    450450        }
     
    509509                else
    510510                {
    511                         if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )
     511                        if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )
    512512                        {
    513513                                serv_got_crap( gc, "serv_got_update() for handle %s:", handle );
     
    568568       
    569569        /* LISPy... */
    570         if( ( set_getint( &gc->irc->set, "away_devoice" ) ) &&          /* Don't do a thing when user doesn't want it */
     570        if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    571571            ( u->online ) &&                                            /* Don't touch offline people */
    572572            ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     
    591591                if( g_strcasecmp( h, "ignore" ) == 0 )
    592592                {
    593                         if( set_getint( &irc->set, "debug" ) )
     593                        if( set_getbool( &irc->set, "debug" ) )
    594594                                serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );
    595595                       
     
    598598                else if( g_strncasecmp( h, "add", 3 ) == 0 )
    599599                {
    600                         int private = set_getint( &irc->set, "private" );
     600                        int private = set_getbool( &irc->set, "private" );
    601601                       
    602602                        if( h[3] )
     
    620620       
    621621        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    622             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )
     622            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    623623                strip_html( msg );
    624624
     
    660660        user_t *u;
    661661       
    662         if( !set_getint( &gc->irc->set, "typing_notice" ) )
     662        if( !set_getbool( &gc->irc->set, "typing_notice" ) )
    663663                return;
    664664       
     
    682682        GList *ir;
    683683       
    684         if( set_getint( &gc->irc->set, "debug" ) )
     684        if( set_getbool( &gc->irc->set, "debug" ) )
    685685                serv_got_crap( gc, "You were removed from conversation %d", (int) id );
    686686       
     
    728728       
    729729        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
    730             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) )
     730            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    731731                strip_html( msg );
    732732       
     
    761761        g_free( s );
    762762       
    763         if( set_getint( &gc->irc->set, "debug" ) )
     763        if( set_getbool( &gc->irc->set, "debug" ) )
    764764                serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle );
    765765       
     
    775775        int me = 0;
    776776       
    777         if( set_getint( &b->gc->irc->set, "debug" ) )
     777        if( set_getbool( &b->gc->irc->set, "debug" ) )
    778778                serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id );
    779779       
     
    809809        int me = 0;
    810810       
    811         if( set_getint( &b->gc->irc->set, "debug" ) )
     811        if( set_getbool( &b->gc->irc->set, "debug" ) )
    812812                serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" );
    813813       
     
    887887        /* Horror.... */
    888888       
    889         if( st != set_getint( &irc->set, "away_devoice" ) )
     889        if( st != set_getbool( &irc->set, "away_devoice" ) )
    890890        {
    891891                char list[80] = "";
     
    10071007                {
    10081008                        gc->acc->prpl->set_away( gc, s, away );
    1009                         if( set_getint( &gc->irc->set, "debug" ) )
     1009                        if( set_getbool( &gc->irc->set, "debug" ) )
    10101010                                serv_got_crap( gc, "Setting away state to %s", s );
    10111011                }
  • protocols/oscar/oscar.c

    r846cec61 rd5ccd83  
    12511251        channel = va_arg(ap, int);
    12521252        userinfo = va_arg(ap, aim_userinfo_t *);
    1253 
    1254     if (set_getint(sess->aux_data, "debug")) {
    1255         serv_got_crap(sess->aux_data, "channel %i called", channel);
    1256     }
    12571253
    12581254        switch (channel) {
  • protocols/oscar/rxhandlers.c

    r846cec61 rd5ccd83  
    112112                /* Following SNAC will be related */
    113113        }
    114 
    115     if (set_getint(sess->aux_data, "debug")) {
    116         serv_got_crap(sess->aux_data, "snac %x/%x received", snac.family, snac.subtype);
    117     }
    118114
    119115        for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
  • root_commands.c

    r846cec61 rd5ccd83  
    144144                irc_usermsg( irc, "Password accepted, settings and accounts loaded" );
    145145                irc_umode_set( irc, "+R", 1 );
    146                 if( set_getint( &irc->set, "auto_connect" ) )
     146                if( set_getbool( &irc->set, "auto_connect" ) )
    147147                        cmd_account( irc, account_on );
    148148                break;
  • set.h

    r846cec61 rd5ccd83  
    2424*/
    2525
     26/* This used to be specific to irc_t structures, but it's more generic now
     27   (so it can also be used for account_t structs). It's pretty simple, but
     28   so far pretty useful.
     29   
     30   In short, it just keeps a linked list of settings/variables and it also
     31   remembers a default value for every setting. And to prevent the user
     32   from setting invalid values, you can write an evaluator function for
     33   every setting, which can check a new value and block it by returning
     34   NULL, or replace it by returning a new value. See struct set.eval. */
     35
    2636typedef struct set
    2737{
    28         void *data;
     38        void *data;     /* Here you can save a pointer to the
     39                           object this settings belongs to. */
    2940       
    3041        char *key;
    3142        char *value;
    32         char *def;      /* Default */
     43        char *def;      /* Default value. If the set_setstr() function
     44                           notices a new value is exactly the same as
     45                           the default, value gets set to NULL. So when
     46                           you read a setting, don't forget about this! */
    3347       
    34         int flags;
     48        int flags;      /* See account.h, for example. set.c doesn't use
     49                           this (yet?). */
    3550       
    3651        /* Eval: Returns NULL if the value is incorrect or exactly the
     
    4156} set_t;
    4257
     58/* Should be pretty clear. */
    4359set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data );
     60
     61/* Returns the raw set_t. Might be useful sometimes. */
    4462set_t *set_find( set_t **head, char *key );
     63
     64/* Returns a pointer to the string value of this setting. Don't modify the
     65   returned string, and don't free() it! */
    4566G_MODULE_EXPORT char *set_getstr( set_t **head, char *key );
     67
     68/* Get an integer. Right now this also converts true/false/on/off/etc to
     69   numbers, but this is for historical reasons, please use set_getbool()
     70   for booleans instead. */
    4671G_MODULE_EXPORT int set_getint( set_t **head, char *key );
    4772G_MODULE_EXPORT int set_getbool( set_t **head, char *key );
     73
     74/* set_setstr() strdup()s the given value, so after using this function
     75   you can free() it, if you want. */
    4876int set_setstr( set_t **head, char *key, char *value );
    4977int set_setint( set_t **head, char *key, int value );
    5078void set_del( set_t **head, char *key );
    5179
     80/* Two very useful generic evaluators. */
    5281char *set_eval_int( set_t *set, char *value );
    5382char *set_eval_bool( set_t *set, char *value );
    5483
     84/* Some not very generic evaluators that really shouldn't be here... */
    5585char *set_eval_to_char( set_t *set, char *value );
    5686char *set_eval_ops( set_t *set, char *value );
  • user.c

    r846cec61 rd5ccd83  
    6767       
    6868        u->user = u->realname = u->host = u->nick = g_strdup( nick );
    69         u->is_private = set_getint( &irc->set, "private" );
     69        u->is_private = set_getbool( &irc->set, "private" );
    7070       
    7171        key = g_strdup( nick );
Note: See TracChangeset for help on using the changeset viewer.