- Timestamp:
- 2015-05-31T02:40:04Z (9 years ago)
- Children:
- 95fdf22
- Parents:
- 074c9b6
- git-author:
- dequis <dx@…> (11-04-15 20:17:30)
- git-committer:
- dequis <dx@…> (31-05-15 02:40:04)
- Location:
- protocols/msn
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.h
r074c9b6 rd2411a1 225 225 int msn_ns_send_typing(struct im_connection *ic, struct bee_user *bu); 226 226 int msn_ns_send_message(struct im_connection *ic, struct bee_user *bu, const char *text); 227 int msn_ns_command(struct msn_data *md, char **cmd, int num_parts );227 int msn_ns_command(struct msn_data *md, char **cmd, int num_parts, char *msg, int msglen); 228 228 int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts); 229 229 -
protocols/msn/msn_util.c
r074c9b6 rd2411a1 185 185 } 186 186 187 188 static int msn_handle_command(struct msn_data *h) { 189 char *msg, **cmd; 190 int count, st; 191 192 msg = g_strndup(h->rxq, h->msglen); 193 194 cmd = g_strsplit_set(h->cmd_text, " ", -1); 195 count = g_strv_length(cmd); 196 197 st = msn_ns_command(h, cmd, count, msg, h->msglen); 198 199 g_strfreev(cmd); 200 g_free(msg); 201 202 g_free(h->cmd_text); 203 h->cmd_text = NULL; 204 205 return st; 206 } 207 187 208 /* This one handles input from a MSN Messenger server. Both the NS and SB servers usually give 188 209 commands, but sometimes they give additional data (payload). This function tries to handle … … 203 224 for (i = 0; i < h->rxlen; i++) { 204 225 if (h->rxq[i] == '\r' || h->rxq[i] == '\n') { 205 char *cmd_text, * *cmd;206 int count;226 char *cmd_text, *last_param; 227 guint64 parsed_len; 207 228 208 229 cmd_text = g_strndup(h->rxq, i); 209 cmd = g_strsplit_set(cmd_text, " ", -1); 210 count = g_strv_length(cmd); 211 212 st = msn_ns_command(h, cmd, count); 213 214 g_strfreev(cmd); 215 g_free(cmd_text); 216 217 /* If the connection broke, don't continue. We don't even exist anymore. */ 218 if (!st) { 219 return(0); 230 231 /* find the position of the last parameter from the end */ 232 last_param = cmd_text + i; 233 while (last_param != cmd_text && last_param[-1] != ' ') { 234 last_param--; 220 235 } 221 236 222 if (h->msglen) { 223 h->cmd_text = g_strndup(h->rxq, i); 237 /* that parameter is the payload size */ 238 if (!parse_int64(last_param, 10, &parsed_len)) { 239 return -1; 224 240 } 225 241 226 /* Skip to the next non-emptyline */ 227 while (i < h->rxlen && (h->rxq[i] == '\r' || h->rxq[i] == '\n')) { 228 i++; 242 h->msglen = (int) parsed_len; 243 h->cmd_text = cmd_text; 244 245 /* if there's no payload, handle it right away */ 246 if (parsed_len == 0 && !msn_handle_command(h)) { 247 return 0; 229 248 } 249 250 /* Skip the \r\n */ 251 i += 2; 230 252 231 253 break; … … 239 261 } 240 262 } else { 241 char *msg, **cmd;242 int count;243 263 244 264 /* Do we have the complete message already? */ 245 265 if (h->msglen > h->rxlen) { 246 266 break; 247 } 248 249 msg = g_strndup(h->rxq, h->msglen); 250 251 cmd = g_strsplit_set(h->cmd_text, " ", -1); 252 count = g_strv_length(cmd); 253 254 st = msn_ns_message(h, msg, h->msglen, cmd, count); 255 256 g_strfreev(cmd); 257 g_free(msg); 258 g_free(h->cmd_text); 259 h->cmd_text = NULL; 260 261 if (!st) { 262 return(0); 267 } else if (!msn_handle_command(h)) { 268 return 0; 263 269 } 264 270 -
protocols/msn/ns.c
r074c9b6 rd2411a1 198 198 } 199 199 200 int msn_ns_command(struct msn_data *md, char **cmd, int num_parts )200 int msn_ns_command(struct msn_data *md, char **cmd, int num_parts, char *msg, int msglen) 201 201 { 202 202 struct im_connection *ic = md->ic;
Note: See TracChangeset
for help on using the changeset viewer.