Mercurial > pidgin
comparison libpurple/protocols/msn/command.c @ 20767:d91c76c76da8
Sanity checking and minor cleanup.
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Thu, 04 Oct 2007 01:09:10 +0000 |
| parents | 723b5a2f91ce |
| children | ef03d2f7a5a7 |
comparison
equal
deleted
inserted
replaced
| 20766:5beeb2e546c2 | 20767:d91c76c76da8 |
|---|---|
| 23 */ | 23 */ |
| 24 #include "msn.h" | 24 #include "msn.h" |
| 25 #include "command.h" | 25 #include "command.h" |
| 26 | 26 |
| 27 static gboolean | 27 static gboolean |
| 28 is_num(char *str) | 28 is_num(const char *str) |
| 29 { | 29 { |
| 30 char *c; | 30 const char *c; |
| 31 for (c = str; *c; c++) { | 31 for (c = str; *c; c++) { |
| 32 if (!(g_ascii_isdigit(*c))) | 32 if (!(g_ascii_isdigit(*c))) |
| 33 return FALSE; | 33 return FALSE; |
| 34 } | 34 } |
| 35 | 35 |
| 40 * check the command is the command with payload content | 40 * check the command is the command with payload content |
| 41 * if it is return TRUE | 41 * if it is return TRUE |
| 42 * else return FALSE | 42 * else return FALSE |
| 43 */ | 43 */ |
| 44 static gboolean | 44 static gboolean |
| 45 msn_check_payload_cmd(char *str) | 45 msn_check_payload_cmd(const char *str) |
| 46 { | 46 { |
| 47 if( (!strcmp(str,"ADL")) || | 47 g_return_val_if_fail(str != NULL, FALSE); |
| 48 | |
| 49 if((!strcmp(str,"ADL")) || | |
| 48 (!strcmp(str,"GCF")) || | 50 (!strcmp(str,"GCF")) || |
| 49 (!strcmp(str,"SG")) || | 51 (!strcmp(str,"SG")) || |
| 50 (!strcmp(str,"MSG")) || | 52 (!strcmp(str,"MSG")) || |
| 51 (!strcmp(str,"RML")) || | 53 (!strcmp(str,"RML")) || |
| 52 (!strcmp(str,"UBX")) || | 54 (!strcmp(str,"UBX")) || |
| 82 | 84 |
| 83 MsnCommand * | 85 MsnCommand * |
| 84 msn_command_from_string(const char *string) | 86 msn_command_from_string(const char *string) |
| 85 { | 87 { |
| 86 MsnCommand *cmd; | 88 MsnCommand *cmd; |
| 87 char *tmp; | |
| 88 char *param_start; | 89 char *param_start; |
| 89 | 90 |
| 90 g_return_val_if_fail(string != NULL, NULL); | 91 g_return_val_if_fail(string != NULL, NULL); |
| 91 | 92 |
| 92 tmp = g_strdup(string); | |
| 93 param_start = strchr(tmp, ' '); | |
| 94 | |
| 95 cmd = g_new0(MsnCommand, 1); | 93 cmd = g_new0(MsnCommand, 1); |
| 96 cmd->command = tmp; | 94 cmd->command = g_strdup(string); |
| 95 param_start = strchr(cmd->command, ' '); | |
| 97 | 96 |
| 98 if (param_start) | 97 if (param_start) |
| 99 { | 98 { |
| 100 *param_start++ = '\0'; | 99 *param_start++ = '\0'; |
| 101 cmd->params = g_strsplit(param_start, " ", 0); | 100 cmd->params = g_strsplit(param_start, " ", 0); |
