close Warning: Failed to sync with repository "(default)": [Errno 12] Cannot allocate memory; repository information may be out of date. Look in the Trac log for more information including mitigation strategies.

Ticket #485: prettyprint.patch

File prettyprint.patch, 6.3 KB (added by Ramkumar Ramachandra <artagnon@…>, at 2010-01-08T07:43:15Z)

[PATCH] Introduce print verbosity option

  • bitlbee.conf

    === modified file 'bitlbee.conf'
    old new  
    1616##    child processes. This should be pretty safe and reliable to use instead
    1717##    of inetd mode.
    1818##
    19 # RunMode = Inetd
     19RunMode = Daemon
    2020
    2121## User:
    2222##
    2323## If BitlBee is started by root as a daemon, it can drop root privileges,
    2424## and change to the specified user.
    2525##
    26 # User = bitlbee
     26User = bitlbee
    2727
    2828## DaemonPort/DaemonInterface:
    2929##
     
    119119## Proxy = http://john:doe@proxy.localnet.com:8080
    120120## Proxy = socks4://socksproxy.localnet.com
    121121## Proxy = socks5://socksproxy.localnet.com
     122Proxy = http://144.16.192.245:8080
     123
     124## Print format
     125## Allowed values: 0 and 1. 0 is verbose, 1 is terse
     126PrintFormat = 0
    122127
    123128
    124129[defaults]
  • conf.c

    === modified file 'conf.c'
    old new  
    305305                                g_free( conf->user );
    306306                                conf->user = g_strdup( ini->value );
    307307                        }
     308                        else if( g_strcasecmp( ini->key, "printformat" ) == 0 )
     309                        {
     310                                if( sscanf( ini->value, "%d", &i ) != 1 )
     311                                {
     312                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
     313                                        return 0;
     314                                }
     315                                conf->print_format = i;
     316                        }
    308317                        else
    309318                        {
    310319                                fprintf( stderr, "Error: Unknown setting `%s` in configuration file (line %d).\n", ini->key, ini->line );
  • conf.h

    === modified file 'conf.h'
    old new  
    4949        int ping_interval;
    5050        int ping_timeout;
    5151        char *user;
     52        int print_format;
    5253} conf_t;
    5354
    5455G_GNUC_MALLOC conf_t *conf_load( int argc, char *argv[] );
  • protocols/msn/msn_util.c

    === modified file 'protocols/msn/msn_util.c'
    old new  
    373373        g_slist_free( *list );
    374374        *list = NULL;
    375375       
    376         imcb_log( ic, ret->str );
     376        imcb_log( ic, "%s", ret->str );
    377377        g_string_free( ret, TRUE );
    378378}
  • protocols/yahoo/libyahoo2.c

    === modified file 'protocols/yahoo/libyahoo2.c'
    old new  
    15291529                case 7:
    15301530                        newbud = y_new0(struct yahoo_buddy, 1);
    15311531                        newbud->id = strdup(pair->value);
    1532                         if(cur_group)
     1532                        if (cur_group) {
    15331533                                newbud->group = strdup(cur_group);
    1534                         else {
    1535                                 struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth(
    1536                                                                 yd->buddies, y_list_length(yd->buddies)-1)->data;
    1537                                 newbud->group = strdup(lastbud->group);
     1534                        } else {
     1535                                YList *last;
     1536                                struct yahoo_buddy *lastbud;
     1537                               
     1538                                for (last = yd->buddies; last && last->next; last = last->next);
     1539                                if (last) {
     1540                                        lastbud = last->data;
     1541                                        newbud->group = strdup(lastbud->group);
     1542                                } else {
     1543                                        newbud->group = strdup("Buddies");
     1544                                }
    15381545                        }
    15391546
    15401547                        yd->buddies = y_list_append(yd->buddies, newbud);
     
    23922399static void yahoo_https_auth_token_finish(struct http_request *req)
    23932400{
    23942401        struct yahoo_https_auth_data *had = req->data;
    2395         struct yahoo_input_data *yid = had->yid;
    2396         struct yahoo_data *yd = yid->yd;
     2402        struct yahoo_input_data *yid;
     2403        struct yahoo_data *yd;
    23972404        int st;
    23982405       
     2406        if (y_list_find(inputs, had->yid) == NULL)
     2407                return;
     2408       
     2409        yid = had->yid;
     2410        yd = yid->yd;
     2411       
    23992412        if (req->status_code != 200) {
    24002413                YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL);
    24012414                goto fail;
     
    24352448static void yahoo_https_auth_finish(struct http_request *req)
    24362449{
    24372450        struct yahoo_https_auth_data *had = req->data;
    2438         struct yahoo_input_data *yid = had->yid;
    2439         struct yahoo_data *yd = yid->yd;
     2451        struct yahoo_input_data *yid;
     2452        struct yahoo_data *yd;
    24402453        struct yahoo_packet *pack;
    2441         char *crumb;
     2454        char *crumb = NULL;
    24422455        int st;
    24432456       
     2457        if (y_list_find(inputs, had->yid) == NULL)
     2458                return;
     2459       
     2460        yid = had->yid;
     2461        yd = yid->yd;
     2462       
    24442463        md5_byte_t result[16];
    24452464        md5_state_t ctx;
    24462465       
  • root_commands.c

    === modified file 'root_commands.c'
    old new  
    907907        else if( cmd[1] && g_strcasecmp( cmd[1], "online" ) == 0 )
    908908                online = 1;
    909909        else
    910                 online =  away = 1;
     910                online = away = 1;
    911911       
    912912        if( strchr( irc->umode, 'b' ) != NULL )
    913913                format = "%s\t%s\t%s";
    914914        else
    915915                format = "%-16.16s  %-40.40s  %s";
    916        
    917         irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" );
     916
     917        if ( global.conf->print_format )
     918                format = "%-20.20s %3.3s";
     919        else
     920                irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" );
    918921       
    919922        for( u = irc->users; u; u = u->next ) if( u->ic && u->online && !u->away )
    920923        {
    921924                if( online == 1 )
    922925                {
    923                         g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    924                         irc_usermsg( irc, format, u->nick, s, "Online" );
     926                        if ( global.conf->print_format )
     927                                irc_usermsg( irc, format, u->nick, "ol" );
     928                        else {
     929                                g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
     930                                irc_usermsg( irc, format, u->nick, s, "Online" );
     931                        }
    925932                }
    926933               
    927934                n_online ++;
     
    931938        {
    932939                if( away == 1 )
    933940                {
    934                         g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    935                         irc_usermsg( irc, format, u->nick, s, u->away );
     941                        if ( global.conf->print_format )
     942                                irc_usermsg( irc, format, u->nick, "idl" );
     943                        else {
     944                                g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
     945                                irc_usermsg( irc, format, u->nick, s, u->away );
     946                        }
    936947                }
    937948                n_away ++;
    938949        }
     
    941952        {
    942953                if( offline == 1 )
    943954                {
    944                         g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    945                         irc_usermsg( irc, format, u->nick, s, "Offline" );
     955                        if ( global.conf->print_format )
     956                                irc_usermsg( irc, format, u->nick, "of" );
     957                        else {
     958                                g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
     959                                irc_usermsg( irc, format, u->nick, s, "Offline" );
     960                        }
    946961                }
    947962                n_offline ++;
    948963        }
    949        
    950         irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline );
     964        if ( !global.conf->print_format )
     965                irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline );
    951966}
    952967
    953968static void cmd_nick( irc_t *irc, char **cmd )