diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_test.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c index f49a9f5..8faa041 100644 --- a/LuaSL/src/LuaSL_test.c +++ b/LuaSL/src/LuaSL_test.c | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | #include "LuaSL.h" | 2 | #include "LuaSL.h" |
3 | 3 | ||
4 | static Eina_Strbuf *clientStream; | ||
4 | 5 | ||
5 | static const char *names[] = | 6 | static const char *names[] = |
6 | { | 7 | { |
@@ -128,6 +129,44 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D | |||
128 | { | 129 | { |
129 | gameGlobals *game = data; | 130 | gameGlobals *game = data; |
130 | 131 | ||
132 | char buf[PATH_MAX]; | ||
133 | char SID[PATH_MAX]; | ||
134 | const char *command; | ||
135 | char *ext; | ||
136 | |||
137 | eina_strbuf_append_length(clientStream, ev->data, ev->size); | ||
138 | command = eina_strbuf_string_get(clientStream); | ||
139 | while ((ext = index(command, '\n'))) | ||
140 | { | ||
141 | int length = ext - command; | ||
142 | |||
143 | strncpy(SID, command, length + 1); | ||
144 | SID[length] = '\0'; | ||
145 | eina_strbuf_remove(clientStream, 0, length + 1); | ||
146 | ext = rindex(SID, '.'); | ||
147 | if (ext) | ||
148 | { | ||
149 | ext[0] = '\0'; | ||
150 | command = ext + 1; | ||
151 | if (0 == strcmp(command, "compiled(false)")) | ||
152 | PE("The compile of %s failed!", SID); | ||
153 | else if (0 == strcmp(command, "compiled(true)")) | ||
154 | { | ||
155 | PD("The compile of %s worked, running it now.", SID); | ||
156 | snprintf(buf, sizeof(buf), "%s.lua.out.start()\n", SID); | ||
157 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
158 | ecore_con_server_flush(game->server); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | PI("Command %s from script %s", command, SID); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | // Get the next blob to check it. | ||
167 | command = eina_strbuf_string_get(clientStream); | ||
168 | } | ||
169 | |||
131 | return ECORE_CALLBACK_RENEW; | 170 | return ECORE_CALLBACK_RENEW; |
132 | } | 171 | } |
133 | 172 | ||
@@ -167,6 +206,7 @@ int main(int argc, char **argv) | |||
167 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game); | 206 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game); |
168 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game); | 207 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game); |
169 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game); | 208 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game); |
209 | clientStream = eina_strbuf_new(); | ||
170 | 210 | ||
171 | if (ecore_evas_init()) | 211 | if (ecore_evas_init()) |
172 | { | 212 | { |