diff options
author | David Walter Seikel | 2016-01-03 00:09:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-01-03 00:09:39 +1000 |
commit | 6402f137f1ce086badf6b6554f7ec34cb1996f43 (patch) | |
tree | e56bd51bc1c81fadf1d803994af2c8bfa03a6e0d | |
parent | Delay some of the Extantz startup to make things prettier. (diff) | |
download | SledjHamr-6402f137f1ce086badf6b6554f7ec34cb1996f43.zip SledjHamr-6402f137f1ce086badf6b6554f7ec34cb1996f43.tar.gz SledjHamr-6402f137f1ce086badf6b6554f7ec34cb1996f43.tar.bz2 SledjHamr-6402f137f1ce086badf6b6554f7ec34cb1996f43.tar.xz |
Left overs from previous commits.
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 166 | ||||
-rw-r--r-- | src/love/love.c | 1 |
2 files changed, 56 insertions, 111 deletions
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index d13db3d..a412027 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -34,7 +34,6 @@ servers. | |||
34 | 34 | ||
35 | 35 | ||
36 | int logDom = -1; // Our logging domain. | 36 | int logDom = -1; // Our logging domain. |
37 | static Eina_Strbuf *clientStream; | ||
38 | 37 | ||
39 | 38 | ||
40 | static Eina_Bool _sleep_timer_cb(void *data) | 39 | static Eina_Bool _sleep_timer_cb(void *data) |
@@ -174,12 +173,6 @@ void send2server(script *me, const char *message) | |||
174 | } | 173 | } |
175 | } | 174 | } |
176 | 175 | ||
177 | static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev) | ||
178 | { | ||
179 | ecore_con_client_timeout_set(ev->client, 0); | ||
180 | return ECORE_CALLBACK_RENEW; | ||
181 | } | ||
182 | |||
183 | static void _compileCb(LuaCompiler *compiler) | 176 | static void _compileCb(LuaCompiler *compiler) |
184 | { | 177 | { |
185 | compileMessage *message = NULL, *safe = NULL; | 178 | compileMessage *message = NULL, *safe = NULL; |
@@ -196,6 +189,7 @@ static void _compileCb(LuaCompiler *compiler) | |||
196 | free(message); | 189 | free(message); |
197 | } | 190 | } |
198 | 191 | ||
192 | //PD("Compiled %s, bug count %d", compiler->file, compiler->bugCount); | ||
199 | if (0 == compiler->bugCount) | 193 | if (0 == compiler->bugCount) |
200 | sendBack(compiler->client, compiler->SID, "compiled(true)"); | 194 | sendBack(compiler->client, compiler->SID, "compiled(true)"); |
201 | else | 195 | else |
@@ -224,107 +218,69 @@ static void _compileCbSingle(LuaCompiler *compiler) | |||
224 | printf("Compile of %s failed!\n", compiler->file); | 218 | printf("Compile of %s failed!\n", compiler->file); |
225 | } | 219 | } |
226 | 220 | ||
227 | static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) | 221 | static Eina_Bool parser(void *data, Connection *connection, char *SID, char *command, char *arguments) |
228 | { | 222 | { |
229 | gameGlobals *ourGlobals = data; | 223 | gameGlobals *ourGlobals = data; |
230 | char buf[PATH_MAX]; | 224 | char buf[PATH_MAX]; |
231 | char SID[PATH_MAX]; | 225 | |
232 | const char *command; | 226 | PW("COMMAND - %s", command); |
233 | char *ext; | 227 | if (0 == strncmp(command, "compile(", 8)) |
234 | 228 | { | |
235 | eina_strbuf_append_length(clientStream, ev->data, ev->size); | 229 | char *temp; |
236 | command = eina_strbuf_string_get(clientStream); | 230 | char *file; |
237 | while ((ext = index(command, '\n'))) | 231 | LuaCompiler *compiler = calloc(1, sizeof(LuaCompiler)); |
232 | |||
233 | strcpy(buf, &command[8]); | ||
234 | temp = buf; | ||
235 | file = temp; | ||
236 | while (')' != temp[0]) | ||
237 | temp++; | ||
238 | temp[0] = '\0'; | ||
239 | |||
240 | eina_clist_init(&(compiler->messages)); | ||
241 | compiler->file = strdup(file); | ||
242 | compiler->SID = strdup(SID); | ||
243 | compiler->client = connection; | ||
244 | compiler->doConstants = FALSE; | ||
245 | compiler->parser = (compileCb) compileLSL; | ||
246 | compiler->cb = _compileCb; | ||
247 | PI("Compiling script %s", file); | ||
248 | compileScript(compiler, COMPILE_THREADED); | ||
249 | } | ||
250 | else if (0 == strncmp(command, "run(", 4)) | ||
238 | { | 251 | { |
239 | int length = ext - command; | 252 | char *temp; |
253 | char *file; | ||
254 | script *me; | ||
255 | |||
256 | strcpy(buf, &command[4]); | ||
257 | temp = buf; | ||
258 | file = temp; | ||
259 | while (')' != temp[0]) | ||
260 | temp++; | ||
261 | temp[0] = '\0'; | ||
262 | me = scriptAdd(file, SID, send2server, ourGlobals); | ||
240 | 263 | ||
241 | strncpy(SID, command, length + 1); | 264 | me->client = connection; |
242 | SID[length] = '\0'; | 265 | eina_hash_add(ourGlobals->names, me->fileName, me); |
243 | eina_strbuf_remove(clientStream, 0, length + 1); | 266 | me = getScript(SID); |
244 | ext = index(SID, '.'); | 267 | if (me) |
245 | if (ext) | ||
246 | { | 268 | { |
247 | ext[0] = '\0'; | 269 | PI("Running script %s", me->fileName); |
248 | command = ext + 1; | 270 | runScript(me); |
249 | if (0 == strncmp(command, "compile(", 8)) | 271 | releaseScript(me); |
250 | { | ||
251 | char *temp; | ||
252 | char *file; | ||
253 | LuaCompiler *compiler = calloc(1, sizeof(LuaCompiler)); | ||
254 | |||
255 | strcpy(buf, &command[8]); | ||
256 | temp = buf; | ||
257 | file = temp; | ||
258 | while (')' != temp[0]) | ||
259 | temp++; | ||
260 | temp[0] = '\0'; | ||
261 | |||
262 | eina_clist_init(&(compiler->messages)); | ||
263 | compiler->file = strdup(file); | ||
264 | compiler->SID = strdup(SID); | ||
265 | compiler->client = ev->client; | ||
266 | compiler->doConstants = FALSE; | ||
267 | compiler->parser = (compileCb) compileLSL; | ||
268 | compiler->cb = _compileCb; | ||
269 | compileScript(compiler, COMPILE_THREADED); | ||
270 | } | ||
271 | else if (0 == strncmp(command, "run(", 4)) | ||
272 | { | ||
273 | char *temp; | ||
274 | char *file; | ||
275 | script *me; | ||
276 | |||
277 | strcpy(buf, &command[4]); | ||
278 | temp = buf; | ||
279 | file = temp; | ||
280 | while (')' != temp[0]) | ||
281 | temp++; | ||
282 | temp[0] = '\0'; | ||
283 | me = scriptAdd(file, SID, send2server, ourGlobals); | ||
284 | |||
285 | me->client = ev->client; | ||
286 | eina_hash_add(ourGlobals->names, me->fileName, me); | ||
287 | me = getScript(SID); | ||
288 | if (me) | ||
289 | { | ||
290 | runScript(me); | ||
291 | releaseScript(me); | ||
292 | } | ||
293 | } | ||
294 | else if (0 == strcmp(command, "exit()")) | ||
295 | { | ||
296 | PD("Told to exit."); | ||
297 | ecore_main_loop_quit(); | ||
298 | } | ||
299 | else | ||
300 | send2script(SID, command); | ||
301 | } | 272 | } |
302 | |||
303 | // Get the next blob to check it. | ||
304 | command = eina_strbuf_string_get(clientStream); | ||
305 | } | 273 | } |
306 | 274 | else if (0 == strcmp(command, "exit()")) | |
307 | return ECORE_CALLBACK_RENEW; | ||
308 | } | ||
309 | |||
310 | static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Del *ev) | ||
311 | { | ||
312 | // gameGlobals *ourGlobals = data; | ||
313 | |||
314 | if (ev->client) | ||
315 | { | 275 | { |
316 | PD("No more clients, exiting."); | 276 | PD("Told to exit."); |
317 | ecore_con_client_del(ev->client); | ||
318 | ecore_main_loop_quit(); | 277 | ecore_main_loop_quit(); |
319 | } | 278 | } |
320 | return ECORE_CALLBACK_RENEW; | 279 | else |
321 | } | 280 | send2script(SID, command); |
322 | 281 | ||
323 | //static Eina_Bool _statusTimer(void *data) | 282 | return ECORE_CALLBACK_RENEW; |
324 | //{ | 283 | } |
325 | // printScriptsStatus(); | ||
326 | // return ECORE_CALLBACK_RENEW; | ||
327 | //} | ||
328 | 284 | ||
329 | int main(int argc, char **argv) | 285 | int main(int argc, char **argv) |
330 | { | 286 | { |
@@ -363,21 +319,12 @@ int main(int argc, char **argv) | |||
363 | } | 319 | } |
364 | else if (ecore_con_init()) | 320 | else if (ecore_con_init()) |
365 | { | 321 | { |
366 | if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) | 322 | PD("LuaSL is about to try creating a LuaSL server."); |
323 | if (openArms("LuaSL", ourGlobals.address, ourGlobals.port, &ourGlobals, NULL, NULL, NULL, parser)) | ||
367 | { | 324 | { |
368 | // int i; | ||
369 | Eina_Iterator *scripts; | 325 | Eina_Iterator *scripts; |
370 | script *me; | 326 | script *me; |
371 | 327 | ||
372 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); | ||
373 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); | ||
374 | ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); | ||
375 | ecore_con_server_timeout_set(ourGlobals.server, 0); | ||
376 | ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); | ||
377 | // ecore_con_server_timeout_set(ourGlobals.server, 10); | ||
378 | // ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); | ||
379 | clientStream = eina_strbuf_new(); | ||
380 | |||
381 | result = 0; | 328 | result = 0; |
382 | compilerSetup(&ourGlobals); | 329 | compilerSetup(&ourGlobals); |
383 | 330 | ||
@@ -410,7 +357,6 @@ int main(int argc, char **argv) | |||
410 | else | 357 | else |
411 | fprintf(stderr, "Failed to init eina!"); | 358 | fprintf(stderr, "Failed to init eina!"); |
412 | 359 | ||
413 | // printf("Falling out of main()\n"); | ||
414 | return result; | 360 | return result; |
415 | } | 361 | } |
416 | 362 | ||
diff --git a/src/love/love.c b/src/love/love.c index 372141d..d8972d1 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -719,6 +719,5 @@ int main(int argc, char **argv) | |||
719 | else | 719 | else |
720 | fprintf(stderr, "Failed to init eina!"); | 720 | fprintf(stderr, "Failed to init eina!"); |
721 | 721 | ||
722 | PD("Falling out of main()"); | ||
723 | return result; | 722 | return result; |
724 | } | 723 | } |