Changeset 5ebff60 for irc_util.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
  • irc_util.c

    raf359b4 r5ebff60  
    1   /********************************************************************\
     1/********************************************************************\
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
     
    2626#include "bitlbee.h"
    2727
    28 char *set_eval_timezone( set_t *set, char *value )
     28char *set_eval_timezone(set_t *set, char *value)
    2929{
    3030        char *s;
    31        
    32         if( strcmp( value, "local" ) == 0 ||
    33             strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 )
     31
     32        if (strcmp(value, "local") == 0 ||
     33            strcmp(value, "gmt") == 0 || strcmp(value, "utc") == 0) {
    3434                return value;
    35        
     35        }
     36
    3637        /* Otherwise: +/- at the beginning optional, then one or more numbers,
    3738           possibly followed by a colon and more numbers. Don't bother bound-
    3839           checking them since users are free to shoot themselves in the foot. */
    3940        s = value;
    40         if( *s == '+' || *s == '-' )
    41                 s ++;
    42        
     41        if (*s == '+' || *s == '-') {
     42                s++;
     43        }
     44
    4345        /* \d+ */
    44         if( !g_ascii_isdigit( *s ) )
     46        if (!g_ascii_isdigit(*s)) {
    4547                return SET_INVALID;
    46         while( *s && g_ascii_isdigit( *s ) ) s ++;
    47        
     48        }
     49        while (*s && g_ascii_isdigit(*s)) {
     50                s++;
     51        }
     52
    4853        /* EOS? */
    49         if( *s == '\0' )
     54        if (*s == '\0') {
    5055                return value;
    51        
     56        }
     57
    5258        /* Otherwise, colon */
    53         if( *s != ':' )
     59        if (*s != ':') {
    5460                return SET_INVALID;
    55         s ++;
    56        
     61        }
     62        s++;
     63
    5764        /* \d+ */
    58         if( !g_ascii_isdigit( *s ) )
     65        if (!g_ascii_isdigit(*s)) {
    5966                return SET_INVALID;
    60         while( *s && g_ascii_isdigit( *s ) ) s ++;
    61        
     67        }
     68        while (*s && g_ascii_isdigit(*s)) {
     69                s++;
     70        }
     71
    6272        /* EOS */
    6373        return *s == '\0' ? value : SET_INVALID;
    6474}
    6575
    66 char *irc_format_timestamp( irc_t *irc, time_t msg_ts )
     76char *irc_format_timestamp(irc_t *irc, time_t msg_ts)
    6777{
    68         time_t now_ts = time( NULL );
     78        time_t now_ts = time(NULL);
    6979        struct tm now, msg;
    7080        char *set;
    71        
     81
    7282        /* If the timestamp is <= 0 or less than a minute ago, discard it as
    7383           it doesn't seem to add to much useful info and/or might be noise. */
    74         if( msg_ts <= 0 || msg_ts > now_ts - 60 )
     84        if (msg_ts <= 0 || msg_ts > now_ts - 60) {
    7585                return NULL;
    76        
    77         set = set_getstr( &irc->b->set, "timezone" );
    78         if( strcmp( set, "local" ) == 0 )
    79         {
    80                 localtime_r( &now_ts, &now );
    81                 localtime_r( &msg_ts, &msg );
    8286        }
    83         else
    84         {
     87
     88        set = set_getstr(&irc->b->set, "timezone");
     89        if (strcmp(set, "local") == 0) {
     90                localtime_r(&now_ts, &now);
     91                localtime_r(&msg_ts, &msg);
     92        } else {
    8593                int hr, min = 0, sign = 60;
    86                
    87                 if( set[0] == '-' )
    88                 {
     94
     95                if (set[0] == '-') {
    8996                        sign *= -1;
    90                         set ++;
     97                        set++;
     98                } else if (set[0] == '+') {
     99                        set++;
    91100                }
    92                 else if( set[0] == '+' )
    93                 {
    94                         set ++;
     101
     102                if (sscanf(set, "%d:%d", &hr, &min) >= 1) {
     103                        msg_ts += sign * (hr * 60 + min);
     104                        now_ts += sign * (hr * 60 + min);
    95105                }
    96                
    97                 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 )
    98                 {
    99                         msg_ts += sign * ( hr * 60 + min );
    100                         now_ts += sign * ( hr * 60 + min );
    101                 }
    102                
    103                 gmtime_r( &now_ts, &now );
    104                 gmtime_r( &msg_ts, &msg );
     106
     107                gmtime_r(&now_ts, &now);
     108                gmtime_r(&msg_ts, &msg);
    105109        }
    106        
    107         if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday )
    108                 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ",
    109                                         msg.tm_hour, msg.tm_min, msg.tm_sec );
    110         else
    111                 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d "
    112                                         "%02d:%02d:%02d\x02]\x02 ",
    113                                         msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday,
    114                                         msg.tm_hour, msg.tm_min, msg.tm_sec );
     110
     111        if (msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday) {
     112                return g_strdup_printf("\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ",
     113                                       msg.tm_hour, msg.tm_min, msg.tm_sec);
     114        } else {
     115                return g_strdup_printf("\x02[\x02\x02\x02%04d-%02d-%02d "
     116                                       "%02d:%02d:%02d\x02]\x02 ",
     117                                       msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday,
     118                                       msg.tm_hour, msg.tm_min, msg.tm_sec);
     119        }
    115120}
Note: See TracChangeset for help on using the changeset viewer.