Changeset 3b09b38


Ignore:
Timestamp:
2015-04-10T17:10:40Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
a4be2f6
Parents:
cfeadc3
git-author:
dequis <dx@…> (13-03-15 07:50:24)
git-committer:
dequis <dx@…> (10-04-15 17:10:40)
Message:

msn: remove msn_linesplit, use g_strsplit_set instead

Location:
protocols/msn
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    rcfeadc3 r3b09b38  
    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

    rcfeadc3 r3b09b38  
    172172}
    173173
    174 /* *NOT* thread-safe, but that's not a problem for now... */
    175 char **msn_linesplit(char *line)
    176 {
    177         static char **ret = NULL;
    178         static int size = 3;
    179         int i, n = 0;
    180 
    181         if (ret == NULL) {
    182                 ret = g_new0(char*, size);
    183         }
    184 
    185         for (i = 0; line[i] && line[i] == ' '; i++) {
    186                 ;
    187         }
    188         if (line[i]) {
    189                 ret[n++] = line + i;
    190                 for (i++; line[i]; i++) {
    191                         if (line[i] == ' ') {
    192                                 line[i] = 0;
    193                         } else if (line[i] != ' ' && !line[i - 1]) {
    194                                 ret[n++] = line + i;
    195                         }
    196 
    197                         if (n >= size) {
    198                                 ret = g_renew(char*, ret, size += 2);
    199                         }
    200                 }
    201         }
    202         ret[n] = NULL;
    203 
    204         return(ret);
    205 }
    206 
    207174/* This one handles input from a MSN Messenger server. Both the NS and SB servers usually give
    208175   commands, but sometimes they give additional data (payload). This function tries to handle
     
    243210
    244211                                        cmd_text = g_strndup(h->rxq, i);
    245                                         cmd = msn_linesplit(cmd_text);
    246                                         for (count = 0; cmd[count]; count++) {
    247                                                 ;
    248                                         }
     212                                        cmd = g_strsplit_set(cmd_text, " ", -1);
     213                                        count = g_strv_length(cmd);
     214
    249215                                        st = msn_ns_command(h, cmd, count);
     216
     217                                        g_strfreev(cmd);
    250218                                        g_free(cmd_text);
    251219
     
    283251
    284252                        msg = g_strndup(h->rxq, h->msglen);
    285                         cmd = msn_linesplit(h->cmd_text);
    286                         for (count = 0; cmd[count]; count++) {
    287                                 ;
    288                         }
     253
     254                        cmd = g_strsplit_set(h->cmd_text, " ", -1);
     255                        count = g_strv_length(cmd);
    289256
    290257                        st = msn_ns_message(h, msg, h->msglen, cmd, count);
     258
     259                        g_strfreev(cmd);
    291260                        g_free(msg);
    292261                        g_free(h->cmd_text);
Note: See TracChangeset for help on using the changeset viewer.