Changeset e6ef4a8


Ignore:
Timestamp:
2015-03-15T14:41:48Z (9 years ago)
Author:
dequis <dx@…>
Children:
c408298
Parents:
e2bf725
git-author:
dequis <dx@…> (13-03-15 07:50:24)
git-committer:
dequis <dx@…> (15-03-15 14:41:48)
Message:

msn: remove msn_linesplit, use g_strsplit_set instead

Location:
protocols/msn
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    re2bf725 re6ef4a8  
    248248int msn_buddy_list_remove(struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group);
    249249void msn_buddy_ask(bee_user_t *bu);
    250 char **msn_linesplit(char *line);
    251250int msn_handler(struct msn_data *h);
    252251char *msn_p11_challenge(char *challenge);
  • protocols/msn/msn_util.c

    re2bf725 re6ef4a8  
    166166}
    167167
    168 /* *NOT* thread-safe, but that's not a problem for now... */
    169 char **msn_linesplit(char *line)
    170 {
    171         static char **ret = NULL;
    172         static int size = 3;
    173         int i, n = 0;
    174 
    175         if (ret == NULL) {
    176                 ret = g_new0(char*, size);
    177         }
    178 
    179         for (i = 0; line[i] && line[i] == ' '; i++) {
    180                 ;
    181         }
    182         if (line[i]) {
    183                 ret[n++] = line + i;
    184                 for (i++; line[i]; i++) {
    185                         if (line[i] == ' ') {
    186                                 line[i] = 0;
    187                         } else if (line[i] != ' ' && !line[i - 1]) {
    188                                 ret[n++] = line + i;
    189                         }
    190 
    191                         if (n >= size) {
    192                                 ret = g_renew(char*, ret, size += 2);
    193                         }
    194                 }
    195         }
    196         ret[n] = NULL;
    197 
    198         return(ret);
    199 }
    200 
    201168/* This one handles input from a MSN Messenger server. Both the NS and SB servers usually give
    202169   commands, but sometimes they give additional data (payload). This function tries to handle
     
    237204
    238205                                        cmd_text = g_strndup(h->rxq, i);
    239                                         cmd = msn_linesplit(cmd_text);
    240                                         for (count = 0; cmd[count]; count++) {
    241                                                 ;
    242                                         }
     206                                        cmd = g_strsplit_set(cmd_text, " ", -1);
     207                                        count = g_strv_length(cmd);
     208
    243209                                        st = msn_ns_command(h, cmd, count);
     210
     211                                        g_strfreev(cmd);
    244212                                        g_free(cmd_text);
    245213
     
    277245
    278246                        msg = g_strndup(h->rxq, h->msglen);
    279                         cmd = msn_linesplit(h->cmd_text);
    280                         for (count = 0; cmd[count]; count++) {
    281                                 ;
    282                         }
     247
     248                        cmd = g_strsplit_set(h->cmd_text, " ", -1);
     249                        count = g_strv_length(cmd);
    283250
    284251                        st = msn_ns_message(h, msg, h->msglen, cmd, count);
     252
     253                        g_strfreev(cmd);
    285254                        g_free(msg);
    286255                        g_free(h->cmd_text);
Note: See TracChangeset for help on using the changeset viewer.