From 022ec48aa446dce7fb97023a206d0f1479e63d82 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 19 Jan 2016 02:40:23 +1000 Subject: Clean up LSL command and argument passing. --- src/LuaSL/LuaSL_main.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/LuaSL/LuaSL_main.c') diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index b72a155..d7223f9 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c @@ -69,7 +69,7 @@ static script *findThem(gameGlobals *ourGlobals, const char *base, const char *t return eina_hash_find(ourGlobals->names, name); } -void send2server(script *me, const char *message) +static void send2server(script *me, const char *message) { gameGlobals *ourGlobals = me->data; @@ -224,13 +224,13 @@ static Eina_Bool parser(void *data, Connection *connection, char *SID, char *com char buf[PATH_MAX]; //PD("PARSE COMMAND - %s", command); - if (0 == strncmp(command, "compile(", 8)) + if (0 == strcmp(command, "compile")) { char *temp; char *file; LuaCompiler *compiler; - strcpy(buf, &command[8]); + strcpy(buf, arguments); temp = buf; file = temp; while (')' != temp[0]) @@ -242,13 +242,13 @@ static Eina_Bool parser(void *data, Connection *connection, char *SID, char *com PI("Compiling script %s", file); compileScript(compiler, TRUE); } - else if (0 == strncmp(command, "run(", 4)) + else if (0 == strcmp(command, "run")) { char *temp; char *file; script *me; - strcpy(buf, &command[4]); + strcpy(buf, arguments); temp = buf; file = temp; while (')' != temp[0]) @@ -268,15 +268,19 @@ static Eina_Bool parser(void *data, Connection *connection, char *SID, char *com else PE("Failed to run script %s", me->fileName); } - else if (0 == strcmp(command, "exit()")) + else if (0 == strcmp(command, "exit")) { PI("Told to exit."); ecore_main_loop_quit(); } else { -//PD("Sending -> script %s : %s", SID, command); - send2script(SID, command); + if (0 == strcmp("return", command)) + snprintf(buf, sizeof(buf), "%s %s", command, arguments); + else + snprintf(buf, sizeof(buf), "%s(%s", command, arguments); +//PD("Sending -> script %s : %s", SID, buf); + send2script(SID, buf); } return ECORE_CALLBACK_RENEW; -- cgit v1.1