Changeset 568aaf7


Ignore:
Timestamp:
2005-12-13T21:39:18Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
703f0f7
Parents:
019c031
Message:

Use the standard data file format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r019c031 r568aaf7  
    247247 * function is here merely because the save/load code still uses
    248248 * ids rather then names */
    249 struct prpl *find_protocol_by_id(int id)
     249static struct prpl *find_protocol_by_id(int id)
    250250{
    251251        switch (id) {
     
    259259}
    260260
     261static int find_protocol_id(const char *name)
     262{
     263        if (!strcmp(name, "oscar")) return 1;
     264        if (!strcmp(name, "msn")) return 4;
     265        if (!strcmp(name, "yahoo")) return 2;
     266        if (!strcmp(name, "jabber")) return 8;
     267
     268        return -1;
     269}
     270
    261271int bitlbee_load( irc_t *irc, char* password )
    262272{
    263273        char s[512];
    264274        char *line;
    265         char proto[20];
     275        int proto;
    266276        char nick[MAX_NICK_LENGTH+1];
    267277        FILE *fp;
     
    298308        fp = fopen( s, "r" );
    299309        if( !fp ) return( 0 );
    300         while( fscanf( fp, "%s %s %s", s, proto, nick ) > 0 )
     310        while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 )
    301311        {
    302312                struct prpl *prpl;
    303313
    304                 prpl = find_protocol(proto);
    305 
    306                 /* Older files saved the protocol number rather then the protocol name */
    307                 if (!prpl && atoi(proto)) {
    308                         prpl = find_protocol_by_id(atoi(proto));
    309                 }
     314                prpl = find_protocol_by_id(proto);
    310315
    311316                if (!prpl)
     
    368373                s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */
    369374                http_encode( s );
    370                 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %s %s", n->proto->name, n->nick );
     375                g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", find_protocol_id(n->proto->name), n->nick );
    371376                if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 )
    372377                {
Note: See TracChangeset for help on using the changeset viewer.