diff options
author | David Walter Seikel | 2012-02-12 00:08:53 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-12 00:08:53 +1000 |
commit | f43dc63f9820ba0d3ff30efd2c45bf6dc5d2af51 (patch) | |
tree | b971c5d251b27136bd95022a6e4a493b8b9448e5 /LuaSL | |
parent | SID is now full path to the LSL file. Still need to change it to the UUID of... (diff) | |
download | SledjHamr-f43dc63f9820ba0d3ff30efd2c45bf6dc5d2af51.zip SledjHamr-f43dc63f9820ba0d3ff30efd2c45bf6dc5d2af51.tar.gz SledjHamr-f43dc63f9820ba0d3ff30efd2c45bf6dc5d2af51.tar.bz2 SledjHamr-f43dc63f9820ba0d3ff30efd2c45bf6dc5d2af51.tar.xz |
New sendBack and sendForth global functions.
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL.h | 2 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_main.c | 8 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_test.c | 16 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_utilities.c | 18 |
4 files changed, 23 insertions, 21 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h index 6c672e5..723f00d 100644 --- a/LuaSL/src/LuaSL.h +++ b/LuaSL/src/LuaSL.h | |||
@@ -64,6 +64,8 @@ typedef struct | |||
64 | 64 | ||
65 | void loggingStartup(gameGlobals *game); | 65 | void loggingStartup(gameGlobals *game); |
66 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); | 66 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); |
67 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message); | ||
68 | void sendForth(gameGlobals *game, const char *SID, const char *message); | ||
67 | float timeDiff(struct timeval *now, struct timeval *then); | 69 | float timeDiff(struct timeval *now, struct timeval *then); |
68 | 70 | ||
69 | #include "LuaSL_LSL_tree.h" | 71 | #include "LuaSL_LSL_tree.h" |
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c index e209023..41fa45a 100644 --- a/LuaSL/src/LuaSL_main.c +++ b/LuaSL/src/LuaSL_main.c | |||
@@ -5,14 +5,6 @@ | |||
5 | static int CPUs = 4; | 5 | static int CPUs = 4; |
6 | static Eina_Strbuf *clientStream; | 6 | static Eina_Strbuf *clientStream; |
7 | 7 | ||
8 | static void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message) | ||
9 | { | ||
10 | char buf[PATH_MAX]; | ||
11 | |||
12 | sprintf(buf, "%s.%s\n", SID, message); | ||
13 | ecore_con_client_send(client, buf, strlen(buf)); | ||
14 | ecore_con_client_flush(client); | ||
15 | } | ||
16 | 8 | ||
17 | static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev) | 9 | static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev) |
18 | { | 10 | { |
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c index 90dc5ac..2ca9792 100644 --- a/LuaSL/src/LuaSL_test.c +++ b/LuaSL/src/LuaSL_test.c | |||
@@ -89,7 +89,6 @@ static void dirList_compile(const char *name, const char *path, void *data) | |||
89 | { | 89 | { |
90 | gameGlobals *game = data; | 90 | gameGlobals *game = data; |
91 | 91 | ||
92 | char buf[PATH_MAX]; | ||
93 | char *ext = rindex(name, '.'); | 92 | char *ext = rindex(name, '.'); |
94 | 93 | ||
95 | if (ext) | 94 | if (ext) |
@@ -103,9 +102,7 @@ static void dirList_compile(const char *name, const char *path, void *data) | |||
103 | snprintf(me->SID, sizeof(me->SID), "%s/%s", path, name); | 102 | snprintf(me->SID, sizeof(me->SID), "%s/%s", path, name); |
104 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); | 103 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); |
105 | eina_hash_add(game->scripts, me->SID, me); | 104 | eina_hash_add(game->scripts, me->SID, me); |
106 | snprintf(buf, sizeof(buf), "%s/%s.compile()\n", path, name); | 105 | sendForth(game, me->SID, "compile()"); |
107 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
108 | ecore_con_server_flush(game->server); | ||
109 | } | 106 | } |
110 | } | 107 | } |
111 | } | 108 | } |
@@ -119,11 +116,7 @@ static Eina_Bool _quit_timer_cb(void *data) | |||
119 | scripts = eina_hash_iterator_data_new(game->scripts); | 116 | scripts = eina_hash_iterator_data_new(game->scripts); |
120 | while(eina_iterator_next(scripts, (void **) &me)) | 117 | while(eina_iterator_next(scripts, (void **) &me)) |
121 | { | 118 | { |
122 | char buf[PATH_MAX]; | 119 | sendForth(game, me->SID, "quit()"); |
123 | |||
124 | snprintf(buf, sizeof(buf), "%s.lua.out.quit()\n", me->SID); | ||
125 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
126 | ecore_con_server_flush(game->server); | ||
127 | } | 120 | } |
128 | 121 | ||
129 | ecore_con_server_send(game->server, ".exit()\n", 8); | 122 | ecore_con_server_send(game->server, ".exit()\n", 8); |
@@ -151,7 +144,6 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D | |||
151 | { | 144 | { |
152 | gameGlobals *game = data; | 145 | gameGlobals *game = data; |
153 | 146 | ||
154 | char buf[PATH_MAX]; | ||
155 | char SID[PATH_MAX]; | 147 | char SID[PATH_MAX]; |
156 | const char *command; | 148 | const char *command; |
157 | char *ext; | 149 | char *ext; |
@@ -191,9 +183,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D | |||
191 | } | 183 | } |
192 | } | 184 | } |
193 | PD("The compile of %s worked, running it now.", SID); | 185 | PD("The compile of %s worked, running it now.", SID); |
194 | snprintf(buf, sizeof(buf), "%s.lua.out.start()\n", SID); | 186 | sendForth(game, SID, "start()"); |
195 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
196 | ecore_con_server_flush(game->server); | ||
197 | } | 187 | } |
198 | else | 188 | else |
199 | { | 189 | { |
diff --git a/LuaSL/src/LuaSL_utilities.c b/LuaSL/src/LuaSL_utilities.c index d73c06d..ab4ea65 100644 --- a/LuaSL/src/LuaSL_utilities.c +++ b/LuaSL/src/LuaSL_utilities.c | |||
@@ -66,6 +66,24 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) | |||
66 | return (dateTime); | 66 | return (dateTime); |
67 | } | 67 | } |
68 | 68 | ||
69 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message) | ||
70 | { | ||
71 | char buf[PATH_MAX]; | ||
72 | |||
73 | sprintf(buf, "%s.%s\n", SID, message); | ||
74 | ecore_con_client_send(client, buf, strlen(buf)); | ||
75 | ecore_con_client_flush(client); | ||
76 | } | ||
77 | |||
78 | void sendForth(gameGlobals *game, const char *SID, const char *message) | ||
79 | { | ||
80 | char buf[PATH_MAX]; | ||
81 | |||
82 | snprintf(buf, sizeof(buf), "%s.%s\n", SID, message); | ||
83 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
84 | ecore_con_server_flush(game->server); | ||
85 | } | ||
86 | |||
69 | float timeDiff(struct timeval *now, struct timeval *then) | 87 | float timeDiff(struct timeval *now, struct timeval *then) |
70 | { | 88 | { |
71 | if (0 == gettimeofday(now, 0)) | 89 | if (0 == gettimeofday(now, 0)) |