Changeset 5ebff60 for storage.c


Ignore:
Timestamp:
2015-02-20T22:50:54Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
0b9daac, 3d45471, 7733b8c
Parents:
af359b4
git-author:
Indent <please@…> (19-02-15 05:47:20)
git-committer:
dequis <dx@…> (20-02-15 22:50:54)
Message:

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage.c

    raf359b4 r5ebff60  
    1   /********************************************************************\
     1/********************************************************************\
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
     
    4646        for (gl = storage_backends; gl; gl = gl->next) {
    4747                st = gl->data;
    48                 if (strcmp(st->name, name) == 0)
     48                if (strcmp(st->name, name) == 0) {
    4949                        break;
    50         }
    51 
    52         if (gl == NULL)
     50                }
     51        }
     52
     53        if (gl == NULL) {
    5354                return NULL;
    54 
    55         if (st->init)
     55        }
     56
     57        if (st->init) {
    5658                st->init();
     59        }
    5760
    5861        return st;
     
    6467        int i;
    6568        storage_t *storage;
    66        
     69
    6770        register_storage_backend(&storage_xml);
    68        
     71
    6972        storage = storage_init_single(primary);
    70         if (storage == NULL && storage->save == NULL)
     73        if (storage == NULL && storage->save == NULL) {
    7174                return NULL;
     75        }
    7276
    7377        ret = g_list_append(ret, storage);
     
    7579        for (i = 0; migrate && migrate[i]; i++) {
    7680                storage = storage_init_single(migrate[i]);
    77        
    78                 if (storage)
     81
     82                if (storage) {
    7983                        ret = g_list_append(ret, storage);
     84                }
    8085        }
    8186
     
    8388}
    8489
    85 storage_status_t storage_check_pass (const char *nick, const char *password)
    86 {
    87         GList *gl;
    88        
     90storage_status_t storage_check_pass(const char *nick, const char *password)
     91{
     92        GList *gl;
     93
    8994        /* Loop until we don't get NO_SUCH_USER */
    9095
     
    9499
    95100                status = st->check_pass(nick, password);
    96                 if (status != STORAGE_NO_SUCH_USER)
     101                if (status != STORAGE_NO_SUCH_USER) {
    97102                        return status;
    98         }
    99        
     103                }
     104        }
     105
    100106        return STORAGE_NO_SUCH_USER;
    101107}
    102108
    103 storage_status_t storage_load (irc_t * irc, const char *password)
    104 {
    105         GList *gl;
    106        
    107         if (irc && irc->status & USTATUS_IDENTIFIED)
     109storage_status_t storage_load(irc_t * irc, const char *password)
     110{
     111        GList *gl;
     112
     113        if (irc && irc->status & USTATUS_IDENTIFIED) {
    108114                return STORAGE_OTHER_ERROR;
    109        
     115        }
     116
    110117        /* Loop until we don't get NO_SUCH_USER */
    111118        for (gl = global.storage; gl; gl = gl->next) {
     
    114121
    115122                status = st->load(irc, password);
    116                 if (status == STORAGE_OK)
    117                 {
     123                if (status == STORAGE_OK) {
    118124                        GSList *l;
    119                         for( l = irc_plugins; l; l = l->next )
    120                         {
     125                        for (l = irc_plugins; l; l = l->next) {
    121126                                irc_plugin_t *p = l->data;
    122                                 if( p->storage_load )
    123                                         p->storage_load( irc );
     127                                if (p->storage_load) {
     128                                        p->storage_load(irc);
     129                                }
    124130                        }
    125131                        return status;
    126132                }
    127                
    128                 if (status != STORAGE_NO_SUCH_USER)
     133
     134                if (status != STORAGE_NO_SUCH_USER) {
    129135                        return status;
    130         }
    131        
     136                }
     137        }
     138
    132139        return STORAGE_NO_SUCH_USER;
    133140}
    134141
    135 storage_status_t storage_save (irc_t *irc, char *password, int overwrite)
     142storage_status_t storage_save(irc_t *irc, char *password, int overwrite)
    136143{
    137144        storage_status_t st;
    138145        GSList *l;
    139        
     146
    140147        if (password != NULL) {
    141148                /* Should only use this in the "register" command. */
    142                 if (irc->password || overwrite)
     149                if (irc->password || overwrite) {
    143150                        return STORAGE_OTHER_ERROR;
    144                
     151                }
     152
    145153                irc_setpass(irc, password);
    146154        } else if ((irc->status & USTATUS_IDENTIFIED) == 0) {
    147155                return STORAGE_NO_SUCH_USER;
    148156        }
    149        
    150         st = ((storage_t *)global.storage->data)->save(irc, overwrite);
    151        
    152         for( l = irc_plugins; l; l = l->next )
    153         {
     157
     158        st = ((storage_t *) global.storage->data)->save(irc, overwrite);
     159
     160        for (l = irc_plugins; l; l = l->next) {
    154161                irc_plugin_t *p = l->data;
    155                 if( p->storage_save )
    156                         p->storage_save( irc );
    157         }
    158        
     162                if (p->storage_save) {
     163                        p->storage_save(irc);
     164                }
     165        }
     166
    159167        if (password != NULL) {
    160168                irc_setpass(irc, NULL);
    161169        }
    162        
     170
    163171        return st;
    164172}
    165173
    166 storage_status_t storage_remove (const char *nick, const char *password)
     174storage_status_t storage_remove(const char *nick, const char *password)
    167175{
    168176        GList *gl;
     
    170178        gboolean ok = FALSE;
    171179        GSList *l;
    172        
    173         /* Remove this account from all storage backends. If this isn't 
    174          * done, the account will still be usable, it'd just be 
     180
     181        /* Remove this account from all storage backends. If this isn't
     182         * done, the account will still be usable, it'd just be
    175183         * loaded from a different backend. */
    176184        for (gl = global.storage; gl; gl = gl->next) {
     
    180188                status = st->remove(nick, password);
    181189                ok |= status == STORAGE_OK;
    182                 if (status != STORAGE_NO_SUCH_USER && status != STORAGE_OK)
     190                if (status != STORAGE_NO_SUCH_USER && status != STORAGE_OK) {
    183191                        ret = status;
    184         }
    185        
     192                }
     193        }
     194
    186195        /* If at least one succeeded, remove plugin data. */
    187         if( ok )
    188                 for( l = irc_plugins; l; l = l->next )
    189                 {
     196        if (ok) {
     197                for (l = irc_plugins; l; l = l->next) {
    190198                        irc_plugin_t *p = l->data;
    191                         if( p->storage_remove )
    192                                 p->storage_remove( nick );
    193                 }
    194        
     199                        if (p->storage_remove) {
     200                                p->storage_remove(nick);
     201                        }
     202                }
     203        }
     204
    195205        return ret;
    196206}
Note: See TracChangeset for help on using the changeset viewer.