diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-23 22:46:48 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-23 22:46:48 +0200 |
commit | 59c6f7d3f5b4d62be569c5bddc6a9306cba0627d (patch) | |
tree | e9bb9be52f60cfaec9e2ca975a09675391abc6a0 | |
parent | a2cca6c09f4661e86ec27d6e9525eb1e02a973e9 (diff) |
Handle multiple commands in the command service.
-rw-r--r-- | command_service.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/command_service.c b/command_service.c index 562c7f4..5d357da 100644 --- a/command_service.c +++ b/command_service.c @@ -25,17 +25,16 @@ static gboolean service_incoming(GSocketService *service, g_debug("size == %ld", size); g_debug(buffer); - gchar *pos = g_strstr_len(buffer, size, "\r"); - if(pos == NULL) { - pos = g_strstr_len(buffer, size, "\n"); - } - if(pos == NULL) { - g_warning("EOL not found"); - return FALSE; - } - *pos = '\0'; + gchar *pos, *eol; + pos = buffer; + while((eol = g_strstr_len(pos, size, "\n")) != NULL || (eol = g_strstr_len(pos, size, "\r")) != NULL) { + *eol = '\0'; - commands_handle(connection, buffer); + commands_handle(connection, pos); + + size -= eol - pos + 1; + pos = eol + 1; + } } return FALSE; |