Changes in / [1065dd4:eb4ad8d]


Ignore:
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • configure

    r1065dd4 reb4ad8d  
    5656
    5757echo BitlBee configure
     58
     59# Cygwin and Darwin don't support PIC/PIE
     60case "$arch" in
     61    CYGWIN* )
     62        pie=0;;
     63    Darwin )
     64        pie=0;;
     65esac
    5866
    5967while [ -n "$1" ]; do
  • ipc.c

    r1065dd4 reb4ad8d  
    463463        {
    464464                GSList *l;
    465                 irc_t *old;
     465                irc_t *old = NULL;
    466466                char *to_init[] = { "TAKEOVER", "INIT", NULL };
    467467               
     
    477477                                break;
    478478                }
    479                 if( l == NULL ||
     479                if( l == NULL || old == NULL ||
    480480                    !set_getbool( &irc->b->set, "allow_takeover" ) ||
    481481                    !set_getbool( &old->b->set, "allow_takeover" ) )
     
    524524                {
    525525                        /* There is no typo in this line: */
    526                         for( j = 1; cmd[j]; j ++ ); j --;
     526                        for( j = 1; cmd[j]; j ++ )
     527                                ;
     528                        j--;
    527529                       
    528530                        if( j < commands[i].required_parameters )
  • irc_channel.c

    r1065dd4 reb4ad8d  
    432432                        char *acc_s;
    433433                       
    434                         if( !aj && !( ic->flags & IRC_CHANNEL_JOINED ) )
     434                        if( !aj || ( ic->flags & IRC_CHANNEL_JOINED ) )
    435435                                /* Only continue if this one's marked as auto_join
    436436                                   or if we're in it already. (Possible if the
  • irc_commands.c

    r1065dd4 reb4ad8d  
    770770                {
    771771                        /* There should be no typo in the next line: */
    772                         for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --;
     772                        for( n_arg = 0; cmd[n_arg]; n_arg ++ )
     773                                ;
     774                        n_arg--;
    773775                       
    774776                        if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN )
  • irc_im.c

    r1065dd4 reb4ad8d  
    911911                c->ic->acc->prpl->chat_leave( c );
    912912       
    913         /* Remove references in both directions now. We don't need each other anymore. */
     913        /* Remove the reference. We don't need it anymore. */
    914914        ic->data = NULL;
    915         if( c )
    916                 c->ui_data = NULL;
    917915       
    918916        return TRUE;
  • lib/misc.c

    r1065dd4 reb4ad8d  
    780780        return NULL;
    781781}
     782
     783/* Takes a string, truncates it where it's safe, returns the new length */
     784int truncate_utf8( char *string, int maxlen )
     785{
     786        char *end;
     787        g_utf8_validate( (const gchar *) string, maxlen, (const gchar **) &end );
     788        *end = '\0';
     789        return end - string;
     790}
  • lib/misc.h

    r1065dd4 reb4ad8d  
    150150G_MODULE_EXPORT char **split_command_parts( char *command, int limit );
    151151G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len );
     152G_MODULE_EXPORT int truncate_utf8( char *string, int maxlen );
    152153
    153154#endif
  • lib/ns_parse.c

    r1065dd4 reb4ad8d  
    1919
    2020#ifndef lint
    21 static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $";
     21//static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $";
    2222#endif
    2323
  • lib/proxy.c

    r1065dd4 reb4ad8d  
    6666{
    6767        struct PHB *phb = data;
    68         unsigned int len;
     68        socklen_t len;
    6969        int error = ETIMEDOUT;
    7070        len = sizeof(error);
     
    8686                closesocket(source);
    8787                b_event_remove(phb->inpa);
     88                phb->inpa = 0;
    8889                if( phb->proxy_func )
    8990                        phb->proxy_func(phb->proxy_data, -1, B_EV_IO_READ);
     
    9798        sock_make_blocking(source);
    9899        b_event_remove(phb->inpa);
     100        phb->inpa = 0;
    99101        if( phb->proxy_func )
    100102                phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ);
     
    174176/* Connecting to HTTP proxies */
    175177
    176 #define HTTP_GOODSTRING "HTTP/1.0 200 Connection established"
    177 #define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established"
     178#define HTTP_GOODSTRING "HTTP/1.0 200"
     179#define HTTP_GOODSTRING2 "HTTP/1.1 200"
    178180
    179181static gboolean http_canread(gpointer data, gint source, b_input_condition cond)
     
    214216        char cmd[384];
    215217        struct PHB *phb = data;
    216         unsigned int len;
     218        socklen_t len;
    217219        int error = ETIMEDOUT;
    218220        if (phb->inpa > 0)
     
    309311        struct hostent *hp;
    310312        struct PHB *phb = data;
    311         unsigned int len;
     313        socklen_t len;
    312314        int error = ETIMEDOUT;
    313315        if (phb->inpa > 0)
     
    501503        int i;
    502504        struct PHB *phb = data;
    503         unsigned int len;
     505        socklen_t len;
    504506        int error = ETIMEDOUT;
    505507        if (phb->inpa > 0)
  • nick.c

    r1065dd4 reb4ad8d  
    227227        {
    228228                nick_strip( irc, rets );
    229                 rets[MAX_NICK_LENGTH] = '\0';
     229                truncate_utf8( rets, MAX_NICK_LENGTH );
    230230                return rets;
    231231        }
     
    252252                else
    253253                {
    254                         nick[0] ++;
     254                        /* We've got no more space for underscores,
     255                           so truncate it and replace the last three
     256                           chars with a random "_XX" suffix */
     257                        int len = truncate_utf8( nick, MAX_NICK_LENGTH - 3 );
     258                        nick[len] = '_';
     259                        g_snprintf(nick + len + 1, 3, "%2x", rand() );
    255260                }
    256261               
     
    400405                if( strlen( down ) > strlen( nick ) )
    401406                {
    402                         /* Well crap. Corrupt it if we have to. */
    403                         down[strlen(nick)] = '\0';
     407                        truncate_utf8( down, strlen( nick ) );
    404408                }
    405409                strcpy( nick, down );
  • otr.c

    r1065dd4 reb4ad8d  
    11171117void cmd_otr_keygen(irc_t *irc, char **args)
    11181118{
    1119         int i, n;
    11201119        account_t *a;
    11211120       
    1122         n = atoi(args[1]);
    1123         if(n<0 || (!n && strcmp(args[1], "0"))) {
    1124                 irc_rootmsg(irc, "%s: invalid account number", args[1]);
     1121        if ((a = account_get(irc->b, args[1])) == NULL) {
     1122                irc_rootmsg(irc, "Could not find account `%s'.", args[1]);
    11251123                return;
    11261124        }
    11271125       
    1128         a = irc->b->accounts;
    1129         for(i=0; i<n && a; i++, a=a->next);
    1130         if(!a) {
    1131                 irc_rootmsg(irc, "%s: no such account", args[1]);
     1126        if(keygen_in_progress(irc, a->user, a->prpl->name)) {
     1127                irc_rootmsg(irc, "keygen for account `%s' already in progress", a->tag);
    11321128                return;
    11331129        }
    11341130       
    1135         if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    1136                 irc_rootmsg(irc, "keygen for account %d already in progress", n);
    1137                 return;
    1138         }
    1139        
    11401131        if(otrl_privkey_find(irc->otr->us, a->user, a->prpl->name)) {
    1141                 char *s = g_strdup_printf("account %d already has a key, replace it?", n);
     1132                char *s = g_strdup_printf("account `%s' already has a key, replace it?", a->tag);
    11421133                query_add(irc, NULL, s, yes_keygen, NULL, NULL, a);
    11431134                g_free(s);
  • protocols/bee_chat.c

    r1065dd4 reb4ad8d  
    8585        bee_t *bee = ic->bee;
    8686        bee_user_t *bu;
     87        gboolean temp;
    8788        char *s;
    8889       
     
    9293       
    9394        bu = bee_user_by_handle( bee, ic, who );
     95        temp = ( bu == NULL );
     96       
     97        if( temp )
     98                bu = bee_user_new( bee, ic, who, BEE_USER_ONLINE );
    9499       
    95100        s = set_getstr( &ic->bee->set, "strip_html" );
     
    98103                strip_html( msg );
    99104       
    100         if( bu && bee->ui->chat_msg )
     105        if( bee->ui->chat_msg )
    101106                bee->ui->chat_msg( bee, c, bu, msg, sent_at );
    102         else
    103                 imcb_chat_log( c, "Message from unknown participant %s: %s", who, msg );
     107       
     108        if( temp )
     109                bee_user_free( bee, bu );
    104110}
    105111
  • protocols/jabber/jabber_util.c

    r1065dd4 reb4ad8d  
    330330}
    331331
    332 /* Returns a new string. Don't leak it! */
     332/* The /resource part is case sensitive. This stops once we see a slash.
     333   Returns a new string. Don't leak it! */
    333334char *jabber_normalize( const char *orig )
    334335{
    335         int len, i;
    336         char *new;
    337        
    338         len = strlen( orig );
    339         new = g_new( char, len + 1 );
    340        
    341         /* So it turns out the /resource part is case sensitive. Yeah, and
    342            it's Unicode but feck Unicode. :-P So stop once we see a slash. */
    343         for( i = 0; i < len && orig[i] != '/' ; i ++ )
    344                 new[i] = g_ascii_tolower( orig[i] );
    345         for( ; orig[i]; i ++ )
    346                 new[i] = orig[i];
    347        
    348         new[i] = 0;
     336        char *lower, *new, *s;
     337
     338        if ( ! ( s = strchr( orig, '/' ) ) )
     339                return g_utf8_strdown( orig, -1 );
     340
     341        lower = g_utf8_strdown( orig, (s - orig) );  /* stop in s */
     342        new = g_strconcat( lower, s, NULL );
     343        g_free( lower );
     344        return new;
     345}
     346
     347/* Similar to jabber_normalize, but works with addresses in the form
     348 * resource=chatroom@example.com */
     349char *jabber_normalize_ext( const char *orig )
     350{
     351        char *lower, *new, *s;
     352
     353        if ( ! ( s = strchr( orig, '=' ) ) )
     354                return g_utf8_strdown( orig, -1 );
     355
     356        lower = g_utf8_strdown( s, -1 ); /* start in s */
     357
     358        *s = 0;
     359        new = g_strconcat( orig, lower, NULL );
     360        *s = '=';
     361
     362        g_free( lower );
    349363        return new;
    350364}
     
    556570        char *s, *jid;
    557571       
    558         jid = jabber_normalize( jid_ );
     572        jid = jabber_normalize_ext( jid_ );
    559573       
    560574        if( ( s = strchr( jid, '=' ) ) == NULL )
  • protocols/msn/ns.c

    r1065dd4 reb4ad8d  
    881881        struct msn_buddy_data *bd = bu->data;
    882882        struct msn_data *md = bu->ic->proto_data;
    883         char handle[strlen(bu->handle)];
     883        char handle[strlen(bu->handle) + 1];
    884884        char *domain;
    885885        char l[4];
  • protocols/oscar/conn.c

    r1065dd4 reb4ad8d  
    571571
    572572        if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
    573                 unsigned int len = sizeof(error);
     573                socklen_t len = sizeof(error);
    574574
    575575                if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
  • protocols/twitter/twitter.c

    r1065dd4 reb4ad8d  
    5151        struct twitter_data *td = ic->proto_data;
    5252
     53        char *last_tweet = set_getstr(&ic->acc->set, "_last_tweet");
     54        if (last_tweet)
     55                td->timeline_id = g_ascii_strtoull(last_tweet, NULL, 0);
     56
    5357        /* Create the room now that we "logged in". */
    5458        if (td->flags & TWITTER_MODE_CHAT)
     
    327331        s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc);
    328332       
     333        s = set_add(&acc->set, "_last_tweet", "0", NULL, acc);
     334        s->flags |= SET_HIDDEN | SET_NOSAVE;
     335
    329336        if (strcmp(acc->prpl->name, "twitter") == 0) {
    330337                s = set_add(&acc->set, "stream", "true", set_eval_bool, acc);
  • protocols/twitter/twitter_lib.c

    r1065dd4 reb4ad8d  
    234234void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor)
    235235{
    236         // Primitive, but hey! It works...     
     236        // Primitive, but hey! It works...
    237237        char *args[2];
    238238        args[0] = "cursor";
    239         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     239        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    240240        twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2);
    241241
     
    721721{
    722722        struct twitter_data *td = ic->proto_data;
     723        char *last_id_str;
    723724       
    724725        if (status->user == NULL || status->text == NULL)
     
    738739        // we won't pick up the updates already in the list.
    739740        td->timeline_id = MAX(td->timeline_id, status->rt_id);
     741
     742        last_id_str = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
     743        set_setstr(&ic->acc->set, "last_tweet", last_id_str);
     744        g_free(last_id_str);
    740745}
    741746
     
    9971002        char *args[6];
    9981003        args[0] = "cursor";
    999         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     1004        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    10001005        args[2] = "include_entities";
    10011006        args[3] = "true";
    10021007        if (td->timeline_id) {
    10031008                args[4] = "since_id";
    1004                 args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id);
     1009                args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
    10051010        }
    10061011
     
    10331038        char *args[6];
    10341039        args[0] = "cursor";
    1035         args[1] = g_strdup_printf("%lld", (long long) next_cursor);
     1040        args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor);
    10361041        args[2] = "include_entities";
    10371042        args[3] = "true";
    10381043        if (td->timeline_id) {
    10391044                args[4] = "since_id";
    1040                 args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id);
     1045                args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id);
    10411046        } else {
    10421047                args[4] = "count";
     
    11671172                "status", msg,
    11681173                "in_reply_to_status_id",
    1169                 g_strdup_printf("%llu", (unsigned long long) in_reply_to)
     1174                g_strdup_printf("%" G_GUINT64_FORMAT, in_reply_to)
    11701175        };
    11711176        twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1,
     
    12011206{
    12021207        char *url;
    1203         url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL,
    1204                               (unsigned long long) id, ".json");
     1208        url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s",
     1209                              TWITTER_STATUS_DESTROY_URL, id, ".json");
    12051210        twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0,
    12061211                       TWITTER_HTTP_USER_ACK);
     
    12111216{
    12121217        char *url;
    1213         url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_RETWEET_URL,
    1214                               (unsigned long long) id, ".json");
     1218        url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s",
     1219                              TWITTER_STATUS_RETWEET_URL, id, ".json");
    12151220        twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0,
    12161221                       TWITTER_HTTP_USER_ACK);
     
    12411246                NULL,
    12421247        };
    1243         args[1] = g_strdup_printf("%llu", (unsigned long long) id);
     1248        args[1] = g_strdup_printf("%" G_GUINT64_FORMAT, id);
    12441249        twitter_http_f(ic, TWITTER_FAVORITE_CREATE_URL, twitter_http_post,
    12451250                       ic, 1, args, 2, TWITTER_HTTP_USER_ACK);
  • protocols/yahoo/libyahoo2.c

    r1065dd4 reb4ad8d  
    974974                        msg = pair->value;
    975975
    976                 if (pair->key == 13) ;
     976                if (pair->key == 13)
     977                        ;
    977978                if (pair->key == 16)    /* error */
    978979                        msg = pair->value;
     
    17951796        switch (code)
    17961797        {
    1797                 case 1212: return YAHOO_LOGIN_PASSWD;
    1798                 case 1213: return YAHOO_LOGIN_LOCK;
    1799                 case 1235: return YAHOO_LOGIN_UNAME;
     1798                case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD;
     1799                case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK;
     1800                case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME;
    18001801                default: return (enum yahoo_status) code;
    18011802        }
     
    36103611        yd = yid->yd;
    36113612
    3612         pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE,
     3613        pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, (enum ypacket_status) YAHOO_STATUS_OFFLINE,
    36133614                yd->session_id);
    36143615
     
    36773678        if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
    36783679                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3679                         YAHOO_STATUS_AVAILABLE, 0);
     3680                        (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    36803681                yahoo_packet_hash(pkt, 13, "2");
    36813682                yahoo_send_packet(yid, pkt, 0);
     
    36963697        if (old_status == YAHOO_STATUS_INVISIBLE) {
    36973698                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3698                         YAHOO_STATUS_AVAILABLE, 0);
     3699                        (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    36993700                yahoo_packet_hash(pkt, 13, "1");
    37003701                yahoo_send_packet(yid, pkt, 0);
  • protocols/yahoo/yahoo_util.h

    r1065dd4 reb4ad8d  
    4848
    4949# define snprintf       g_snprintf
     50#ifdef vsnprintf
     51#undef vsnprintf
     52#endif
    5053# define vsnprintf      g_vsnprintf
    5154
  • set.c

    r1065dd4 reb4ad8d  
    175175int set_setint( set_t **head, const char *key, int value )
    176176{
    177         char s[24];     /* Not quite 128-bit clean eh? ;-) */
    178        
    179         g_snprintf( s, sizeof( s ), "%d", value );
    180         return set_setstr( head, key, s );
     177        char *s = g_strdup_printf( "%d", value );
     178        int retval = set_setstr( head, key, s );
     179        g_free( s );
     180        return retval;
    181181}
    182182
  • tests/check_arc.c

    r1065dd4 reb4ad8d  
    8888                                  &decrypted, password );
    8989               
     90                fail_if( len == -1,
     91                 "`%s' didn't decrypt properly", decrypt_tests[i].decrypted );
    9092                fail_if( strcmp( decrypt_tests[i].decrypted, decrypted ) != 0,
    9193                         "`%s' didn't decrypt properly", decrypt_tests[i].decrypted );
  • tests/check_irc.c

    r1065dd4 reb4ad8d  
    2828        GIOChannel *ch1, *ch2;
    2929        irc_t *irc;
    30         GError *error = NULL;
    3130        char *raw;
    3231        fail_unless(g_io_channel_pair(&ch1, &ch2));
  • tests/check_jabber_sasl.c

    r1065dd4 reb4ad8d  
    8787                tcase_fn_start( get_part_tests[i].key, __FILE__, i );
    8888                char *res;
    89                 int len;
    9089               
    9190                res = sasl_get_part( get_part_tests[i].challenge,
Note: See TracChangeset for help on using the changeset viewer.