aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-02-05 21:23:50 +1000
committerDavid Walter Seikel2016-02-05 21:23:50 +1000
commite4d4a5657c36231f3fc02b9def6ebb193cf95f15 (patch)
tree44e5c326e9436133815e6da658716dba51d63d7d
parentA little bit of clean up of the Lua network messaging TODO. (diff)
downloadSledjHamr-e4d4a5657c36231f3fc02b9def6ebb193cf95f15.zip
SledjHamr-e4d4a5657c36231f3fc02b9def6ebb193cf95f15.tar.gz
SledjHamr-e4d4a5657c36231f3fc02b9def6ebb193cf95f15.tar.bz2
SledjHamr-e4d4a5657c36231f3fc02b9def6ebb193cf95f15.tar.xz
More Lua network messages clean ups.
Highlights - Properly deal with ( and ). "return x" -> "return(x)". No more special casing.
-rw-r--r--lib/LSL.lua8
-rw-r--r--src/LuaSL/LuaSL_main.c103
-rw-r--r--src/extantz/extantz.c6
-rw-r--r--src/libraries/SledjHamr.c169
-rw-r--r--src/love/love.c88
5 files changed, 202 insertions, 172 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua
index 58620e7..434113d 100644
--- a/lib/LSL.lua
+++ b/lib/LSL.lua
@@ -1957,7 +1957,7 @@ function LSL.stateChange(x)
1957 Notably, it's not actually legal to do a state change from a function, only from handlers. 1957 Notably, it's not actually legal to do a state change from a function, only from handlers.
1958 There is a hack though, but it's unsupported, so I don't have to worry about it so much. 1958 There is a hack though, but it's unsupported, so I don't have to worry about it so much.
1959 1959
1960 Write out "state new;" as "return _LSL.stateChange(newState);", with stateChange() returning new.state_entry()) which will force two tail calls. 1960 Write out "state new;" as "return(_LSL.stateChange(newState));", with stateChange() returning new.state_entry()) which will force two tail calls.
1961 1961
1962 The caller of stateChange() might be a function rather than an event handler. 1962 The caller of stateChange() might be a function rather than an event handler.
1963 Which will return to the event handler (possibly via other nested function calls) as if the state never changed. 1963 Which will return to the event handler (possibly via other nested function calls) as if the state never changed.
@@ -2003,7 +2003,7 @@ function waitAndProcess(returnWanted, name, ...)
2003 while running do 2003 while running do
2004 local message = Runnr.receive() 2004 local message = Runnr.receive()
2005 if message then 2005 if message then
2006--print(" " .. SID .. "_" .. scriptName .. ' GOT MESSAGE - "' .. message .. '"') 2006-- print(" " .. SID .. "_" .. scriptName .. ' GOT MESSAGE - "' .. message .. '"')
2007 -- TODO - should we be discarding return values while paused? I don't think so, so we need to process those, 2007 -- TODO - should we be discarding return values while paused? I don't think so, so we need to process those,
2008 if paused then 2008 if paused then
2009 if "start()" == message then paused = false end 2009 if "start()" == message then paused = false end
@@ -2027,7 +2027,7 @@ function waitAndProcess(returnWanted, name, ...)
2027 print(text) 2027 print(text)
2028 elseif result1 then 2028 elseif result1 then
2029 -- Check if we are waiting for a return, and got it. 2029 -- Check if we are waiting for a return, and got it.
2030 if returnWanted and string.match(message, "^return ") then 2030 if returnWanted and string.match(message, "^return%(") then
2031-- print("<" .. SID .. "_" .. scriptName, " - RETURNING " .. type(result1) .. " " .. message .. " TO " .. name) 2031-- print("<" .. SID .. "_" .. scriptName, " - RETURNING " .. type(result1) .. " " .. message .. " TO " .. name)
2032 return result1 2032 return result1
2033 else 2033 else
@@ -2040,7 +2040,7 @@ function waitAndProcess(returnWanted, name, ...)
2040-- msg("Error sending results from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) 2040-- msg("Error sending results from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg)
2041-- end 2041-- end
2042 else 2042 else
2043 if string.match(message, "^return ") then 2043 if string.match(message, "^return%(") then
2044 print("!" .. SID .. "_" .. scriptName, " - IN AN ODD PLACE!!!!!" .. message) 2044 print("!" .. SID .. "_" .. scriptName, " - IN AN ODD PLACE!!!!!" .. message)
2045 else 2045 else
2046-- print("!" .. SID .. "_" .. scriptName, " - " .. message) 2046-- print("!" .. SID .. "_" .. scriptName, " - " .. message)
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index cf3c946..9a0f32f 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -41,7 +41,7 @@ static Eina_Bool _sleep_timer_cb(void *data)
41 script *script = data; 41 script *script = data;
42 42
43// PD("Waking up %s", script->name); 43// PD("Waking up %s", script->name);
44 send2script(script->SID, "return 0.0"); 44 send2script(script->SID, "return(0.0)");
45 return ECORE_CALLBACK_CANCEL; 45 return ECORE_CALLBACK_CANCEL;
46} 46}
47 47
@@ -89,28 +89,28 @@ static boolean send2parser(void *data, Connection *connection, char *SID, char *
89 return FALSE; 89 return FALSE;
90 } 90 }
91 91
92 sprintf(buf, "%s(%s", command, arguments); 92 sprintf(buf, "%s(%s)", command, arguments);
93 93
94//PD("GOT MESSAGE from script %s - '%s'", me->name, buf); 94//PD("GOT MESSAGE from script %s - '%s'", me->name, buf);
95 95
96 if (0 == strncmp(buf, "llSleep(", 8)) 96 if (0 == strcmp(command, "llSleep"))
97 ecore_timer_add(atof(&(buf)[8]), _sleep_timer_cb, me); 97 ecore_timer_add(atof(arguments), _sleep_timer_cb, me);
98 else if (0 == strncmp(buf, "llResetTime(", 12)) 98 else if (0 == strcmp(command, "llResetTime"))
99 { 99 {
100 takeScript(me); 100 takeScript(me);
101 gettimeofday(&me->startTime, NULL); 101 gettimeofday(&me->startTime, NULL);
102 releaseScript(me); 102 releaseScript(me);
103 } 103 }
104 else if (0 == strncmp(buf, "llGetTime(", 10)) 104 else if (0 == strcmp(command, "llGetTime"))
105 { 105 {
106 struct timeval now; 106 struct timeval now;
107 float time = timeDiff(&now, &me->startTime); 107 float time = timeDiff(&now, &me->startTime);
108 char result[128]; 108 char result[128];
109 109
110 snprintf(result, sizeof(result), "return %f", time); 110 snprintf(result, sizeof(result), "return(%f)", time);
111 send2script(me->SID, result); 111 send2script(me->SID, result);
112 } 112 }
113 else if (0 == strncmp(buf, "llGetAndResetTime(", 18)) 113 else if (0 == strcmp(command, "llGetAndResetTime"))
114 { 114 {
115 struct timeval now; 115 struct timeval now;
116 float time = timeDiff(&now, &me->startTime); 116 float time = timeDiff(&now, &me->startTime);
@@ -120,13 +120,13 @@ static boolean send2parser(void *data, Connection *connection, char *SID, char *
120 // Reset it before doing anything else once the result is known. 120 // Reset it before doing anything else once the result is known.
121 gettimeofday(&me->startTime, NULL); 121 gettimeofday(&me->startTime, NULL);
122 releaseScript(me); 122 releaseScript(me);
123 snprintf(result, sizeof(result), "return %f", time); 123 snprintf(result, sizeof(result), "return(%f)", time);
124 send2script(me->SID, result); 124 send2script(me->SID, result);
125 } 125 }
126 else if (0 == strncmp(buf, "llSetTimerEvent(", 16)) 126 else if (0 == strcmp(command, "llSetTimerEvent"))
127 { 127 {
128 takeScript(me); 128 takeScript(me);
129 me->timerTime = atof(&(buf)[16]); 129 me->timerTime = atof(arguments);
130 if (0.0 == me->timerTime) 130 if (0.0 == me->timerTime)
131 { 131 {
132 if (me->timer) 132 if (me->timer)
@@ -137,14 +137,24 @@ static boolean send2parser(void *data, Connection *connection, char *SID, char *
137 me->timer = ecore_timer_add(me->timerTime, _timer_timer_cb, me); 137 me->timer = ecore_timer_add(me->timerTime, _timer_timer_cb, me);
138 releaseScript(me); 138 releaseScript(me);
139 } 139 }
140 else if (0 == strncmp(buf, "llSetScriptState(", 17)) 140 else if (0 == strcmp(command, "llSetScriptState"))
141 { 141 {
142 script *them; 142 script *them;
143 char *temp = rindex(arguments, '"'), *ext = NULL;
143 144
144 if ((them = findThem(ourGlobals, me->fileName, &(buf[18])))) 145 if (temp)
145 { 146 {
146 char *temp = rindex(&(buf[18]), ','); 147 *temp = '\0';
148 ext = temp + 1;
149 }
150
151 temp = arguments;
152 if ('"' == temp[0])
153 temp = &temp[1];
147 154
155 if ((them = findThem(ourGlobals, me->fileName, temp)))
156 {
157 temp = rindex(ext, ',');
148 if (temp) 158 if (temp)
149 { 159 {
150 temp++; 160 temp++;
@@ -154,31 +164,39 @@ static boolean send2parser(void *data, Connection *connection, char *SID, char *
154 send2script(them->SID, "start()"); 164 send2script(them->SID, "start()");
155 else 165 else
156 send2script(them->SID, "stop()"); 166 send2script(them->SID, "stop()");
157// PD("Stopped %s", them->name); 167// PD("Started / stopped %s", them->name);
158 } 168 }
159 else 169 else
160 PE("Missing script state in llSetScriptState(%s, )", them->name); 170 PE("Missing script state in llSetScriptState(%s, )", them->name);
161 } 171 }
162 else 172 else
163 { 173 PE("Can't start / stop script, can't find %s", temp);
164 char *temp = rindex(&(buf[18]), '"');
165
166 if (temp)
167 *temp = '\0';
168 PE("Can't stop script, can't find %s", &(buf[18]));
169 }
170 } 174 }
171 else if (0 == strncmp(buf, "llResetOtherScript(", 19)) 175 else if (0 == strcmp(command, "llResetOtherScript"))
172 { 176 {
173 script *them; 177 script *them;
178 char *temp = rindex(arguments, '"') ;//, *ext = NULL;
174 179
175 if ((them = findThem(ourGlobals, me->fileName, &(buf[20])))) 180 if (temp)
181 {
182 *temp = '\0';
183// ext = temp + 1;
184 }
185
186 temp = arguments;
187 if ('"' == temp[0])
188 temp = &temp[1];
189
190
191 if ((them = findThem(ourGlobals, me->fileName, temp)))
176 { 192 {
177 PD("RESETTING OTHER %s", them->name); 193 PD("RESETTING OTHER %s", them->name);
178 resetScript(them); 194 resetScript(them);
179 } 195 }
196 else
197 PE("Can't reset script, can't find %s", temp);
180 } 198 }
181 else if (0 == strncmp(buf, "llResetScript(", 14)) 199 else if (0 == strcmp(command, "llResetScript"))
182 { 200 {
183 PD("RESETTING %s", me->name); 201 PD("RESETTING %s", me->name);
184 resetScript(me); 202 resetScript(me);
@@ -239,38 +257,19 @@ static boolean parser(void *data, Connection *connection, char *SID, char *comma
239 gameGlobals *ourGlobals = data; 257 gameGlobals *ourGlobals = data;
240 char buf[PATH_MAX]; 258 char buf[PATH_MAX];
241 259
242//PD("PARSE COMMAND %s - '%s' (%s", SID, command, arguments); 260//PD("PARSE COMMAND %s - %s (%s)", SID, command, arguments);
243 if (0 == strcmp(command, "compile")) 261 if (0 == strcmp(command, "compile"))
244 { 262 {
245 char *temp;
246 char *file;
247 LuaCompiler *compiler; 263 LuaCompiler *compiler;
248 264
249 strcpy(buf, arguments); 265 compiler = createCompiler(SID, arguments, (compileCb) compileLSL, _compileCb);
250 temp = buf;
251 file = temp;
252 while (')' != temp[0])
253 temp++;
254 temp[0] = '\0';
255
256 compiler = createCompiler(SID, file, (compileCb) compileLSL, _compileCb);
257 compiler->client = connection; 266 compiler->client = connection;
258 PI("Compiling script %s", file); 267 PI("Compiling script %s", arguments);
259 compileScript(compiler, TRUE); 268 compileScript(compiler, TRUE);
260 } 269 }
261 else if (0 == strcmp(command, "run")) 270 else if (0 == strcmp(command, "run"))
262 { 271 {
263 char *temp; 272 script *me = scriptAdd(arguments, SID, send2server, ourGlobals);
264 char *file;
265 script *me;
266
267 strcpy(buf, arguments);
268 temp = buf;
269 file = temp;
270 while (')' != temp[0])
271 temp++;
272 temp[0] = '\0';
273 me = scriptAdd(file, SID, send2server, ourGlobals);
274 273
275 me->client = connection; 274 me->client = connection;
276 eina_hash_add(ourGlobals->names, me->fileName, me); 275 eina_hash_add(ourGlobals->names, me->fileName, me);
@@ -293,10 +292,10 @@ static boolean parser(void *data, Connection *connection, char *SID, char *comma
293 { 292 {
294 // TODO - Even after moving the above into the command hash, this bit might still remain, unless script.return() can make it go away. 293 // TODO - Even after moving the above into the command hash, this bit might still remain, unless script.return() can make it go away.
295 // Though perhaps the "else" part stays? 294 // Though perhaps the "else" part stays?
296 if (0 == strcmp("return", command)) 295// if (0 == strcmp("return", command))
297 snprintf(buf, sizeof(buf), "%s %s", command, arguments); 296// snprintf(buf, sizeof(buf), "%s(%s)", command, arguments);
298 else 297// else
299 snprintf(buf, sizeof(buf), "%s(%s", command, arguments); 298 snprintf(buf, sizeof(buf), "%s(%s)", command, arguments);
300//PD("Sending -> script %s : %s", SID, buf); 299//PD("Sending -> script %s : %s", SID, buf);
301 send2script(SID, buf); 300 send2script(SID, buf);
302 } 301 }
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 089cc41..f2c0a43 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -43,7 +43,7 @@ static boolean clientParser(void *data, Connection *connection, char *SID, char
43 || (0 == strcmp(command, "llSay")) 43 || (0 == strcmp(command, "llSay"))
44 || (0 == strcmp(command, "llShout"))) 44 || (0 == strcmp(command, "llShout")))
45 { 45 {
46 sprintf(buf, "%s: %s(%s", SID, command, arguments); 46 sprintf(buf, "%s: %s(%s)", SID, command, arguments);
47 if (ourGlobals->purkle) 47 if (ourGlobals->purkle)
48 { 48 {
49 int _P; 49 int _P;
@@ -65,11 +65,11 @@ static boolean clientParser(void *data, Connection *connection, char *SID, char
65 _M = lua_gettop(ourGlobals->LSLGuiMess->L); 65 _M = lua_gettop(ourGlobals->LSLGuiMess->L);
66 66
67 // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that. 67 // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that.
68 sprintf(buf, "%s(%s", command, arguments); 68 sprintf(buf, "%s(%s)", command, arguments);
69 push_lua(ourGlobals->LSLGuiMess->L, "@ ( $ )", _M, "doLua", buf, 0); 69 push_lua(ourGlobals->LSLGuiMess->L, "@ ( $ )", _M, "doLua", buf, 0);
70 } 70 }
71 else 71 else
72 PE("No LSLGuiMess to send - %s(%s", command, arguments); 72 PE("No LSLGuiMess to send - %s(%s)", command, arguments);
73 } 73 }
74 else if (0 == strcmp(command, "loadSim")) 74 else if (0 == strcmp(command, "loadSim"))
75 { 75 {
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c
index 7092c10..1fae167 100644
--- a/src/libraries/SledjHamr.c
+++ b/src/libraries/SledjHamr.c
@@ -91,81 +91,122 @@ static boolean checkConnection(Connection *conn, char *func, connType wanted, bo
91 91
92typedef boolean (* notFoundCb)(Connection *conn, char *command, int len); 92typedef boolean (* notFoundCb)(Connection *conn, char *command, int len);
93 93
94/* TODO -
95 It should loop through all lines, looking for the closing ) before dealing with it.
96 If we get to the end, and there's left over open ( or something, then return the length.
97 Bitch and move on if it's not well formed.
98*/
99static int _checkForCommand(Connection *conn, char *commands, notFoundCb notFound, boolean in) 94static int _checkForCommand(Connection *conn, char *commands, notFoundCb notFound, boolean in)
100{ 95{
101 int result = 0; 96 int result = 0;
102 boolean handled = FALSE; 97 boolean handled = FALSE;
103 char *ext, *ext2; 98 char *ext = NULL, *ext1 = NULL, *ext2 = NULL, *ext3 = NULL;
104 99
105 while ((ext = index(commands, '\n')))
106 {
107 char SID[PATH_MAX * 3];
108 int length = ext - commands;
109 100
110 strncpy(SID, commands, length + 1); 101 char *p = commands, name[64], command[32], arguments[PATH_MAX * 3];
111 102
112 SID[length] = '\0'; 103 name[0] = 0;
104 command[0] = 0;
105 arguments[0] = 0;
106 ext = p;
113 107
114 ext = index(SID, '.'); 108 while (*p)
115 if (ext) 109 {
110 switch (*p)
116 { 111 {
117 char *command = ext + 1; 112 case '.' :
113 if (NULL == ext1)
114 {
115 *p = 0;
116 strncpy(name, ext, sizeof(name));
117 name[sizeof(name) - 1] = 0;
118 *p = '.';
119 ext1 = p + 1;
120 }
121 break;
118 122
119 ext[0] = '\0'; 123 case '(' :
120 ext2 = index(command, '('); 124 if ((NULL != ext1) && (NULL == ext2))
121 if (NULL == ext2) 125 {
122 ext2 = index(command, ' '); 126 *p = 0;
123 if (ext2) 127 strncpy(command, ext1, sizeof(command));
124 { 128 command[sizeof(command) - 1] = 0;
125 ext2[0] = '\0'; 129 *p = '(';
126 // TODO - Currently SID.command(arguments), should change that to nameSpace.command(arguments) 130 ext2 = p + 1;
127 // Not sure what to do with SID, but there maybe some common parameters we can shift around differently. 131 }
128 // - First check if the connection has a hashtable of conn->commands. 132 break;
129 //* Next check if "nameSpace.command(arguments)" runs as Lua.
130 // or even the return values from returnWanted calls like -
131 // SID, "return 1"
132 // SID, "result + 5"
133 // SID, "script.SID.return(1)"
134 // Finally pass it to conn->unknownCommand()
135 // * The Lua check can live in unknownCommand().
136 // else bitch.
137
138 // Check if it's in the connections hash table.
139 streamParser func = eina_hash_find(conn->commands, command);
140
141 if (NULL == func)
142 {
143 // Check if the connection has a function for handling it.
144 if (in)
145 func = conn->unknownInCommand;
146 else
147 func = conn->unknownOutCommand;
148 }
149 133
150 // Try it out if we have a function. 134 case ')' :
151 if (func) 135 if (NULL != ext2) // Keep scanning until we get the last one.
152 { 136 {
153 handled = func(conn->pointer, conn, SID, command, ext2 + 1); 137 *p = 0;
154 if (handled) 138 strncpy(arguments, ext2, sizeof(arguments));
155 notFound = NULL; 139 arguments[sizeof(arguments) - 1] = 0;
156 } 140 *p = ')';
141 ext3 = p + 1;
142 }
143 break;
157 144
158 // Last resort, let the caller deal with it. 145 case '\n' :
159 if (notFound) 146 if ((NULL != ext3) && (0 != name[0]) && (0 != command[0]))
160 handled = notFound(conn, commands, length + 1); 147 {
161 if (!handled) 148 int length = p - ext + 1;
162 PE("No function found for command %s(%s!", command, ext2 + 1); 149//PD("name: %s command: %s arguments %s|", name, command, arguments);
150 // TODO - Currently SID.command(arguments), should change that to nameSpace.command(arguments)
151 // Not sure what to do with SID, but there maybe some common parameters we can shift around differently.
152 // - First check if the connection has a hashtable of conn->commands.
153 //* Next check if "nameSpace.command(arguments)" runs as Lua.
154 // or even the return values from returnWanted calls like -
155 // SID, "return(1)"
156 // SID, "result + 5"
157 // SID, "script.SID.return(1)"
158 // Finally pass it to conn->unknownCommand()
159 // * The Lua check can live in unknownCommand().
160 // else bitch.
161
162 // Check if it's in the connections hash table.
163 streamParser func = eina_hash_find(conn->commands, command);
164
165 if (NULL == func)
166 {
167 // Check if the connection has a function for handling it.
168 if (in)
169 func = conn->unknownInCommand;
170 else
171 func = conn->unknownOutCommand;
172 }
173
174 // Try it out if we have a function.
175 if (func)
176 {
177 handled = func(conn->pointer, conn, name, command, arguments);
178 if (handled)
179 notFound = NULL;
180 }
181
182 // Last resort, let the caller deal with it.
183 if (notFound)
184 handled = notFound(conn, commands, length);
185 if (!handled)
186 PE("No function found for command %s.%s(%s)!", name, command, arguments);
187
188 result += length;
189
190 name[0] = 0;
191 command[0] = 0;
192 arguments[0] = 0;
193 ext = p + 1;
194 ext1 = NULL;
195 ext2 = NULL;
196 ext3 = NULL;
197 }
198 else if ((p != ext))
199 {
200 *p = 0;
201 PE("ERROR scanning |%s|", ext);
202 *p = '\n';
203 }
204 break;
163 205
164 result += length; 206 default :
165 } 207 break;
166 } 208 }
167 209 p++;
168 commands = &commands[length + 1];
169 } 210 }
170 211
171 return result; 212 return result;
@@ -178,13 +219,13 @@ static boolean _actuallySendIt(Connection *conn, char *command, int len)
178 switch (conn->type) 219 switch (conn->type)
179 { 220 {
180 case CT_CLIENT : 221 case CT_CLIENT :
181// PD("vvv send2(%*s", len, command); 222//PD("vvv send2(%*s", len, command);
182 ecore_con_client_send(conn->conn.client.client, strndup(command, len), len); 223 ecore_con_client_send(conn->conn.client.client, strndup(command, len), len);
183 ecore_con_client_flush(conn->conn.client.client); 224 ecore_con_client_flush(conn->conn.client.client);
184 return TRUE; 225 return TRUE;
185 226
186 case CT_SERVER : 227 case CT_SERVER :
187// PD("^^^ send2(%*s", len, command); 228//PD("^^^ send2(%*s", len, command);
188 ecore_con_server_send(conn->conn.server.server, strndup(command, len), len); 229 ecore_con_server_send(conn->conn.server.server, strndup(command, len), len);
189 ecore_con_server_flush(conn->conn.server.server); 230 ecore_con_server_flush(conn->conn.server.server);
190 return TRUE; 231 return TRUE;
@@ -227,7 +268,7 @@ static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, voi
227 conn->stream = eina_strbuf_new(); 268 conn->stream = eina_strbuf_new();
228 269
229 eina_strbuf_append_length(conn->stream, evData, evSize); 270 eina_strbuf_append_length(conn->stream, evData, evSize);
230//PD("%s", (char *) eina_strbuf_string_get(conn->stream)); 271//PD("****** %s", (char *) eina_strbuf_string_get(conn->stream));
231 eina_strbuf_remove(conn->stream, 0, _checkForCommand(conn, (char *) eina_strbuf_string_get(conn->stream), NULL, TRUE)); 272 eina_strbuf_remove(conn->stream, 0, _checkForCommand(conn, (char *) eina_strbuf_string_get(conn->stream), NULL, TRUE));
232 273
233 if (conn->_data) 274 if (conn->_data)
diff --git a/src/love/love.c b/src/love/love.c
index 8d1bcd4..5549f54 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -217,9 +217,6 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
217 temp++; 217 temp++;
218 temp[0] = '\0'; 218 temp[0] = '\0';
219 text = ++temp; 219 text = ++temp;
220 while (')' != temp[0])
221 temp++;
222 temp[0] = '\0';
223 PW("%s @ line %s, column %s.", text, line, column); 220 PW("%s @ line %s, column %s.", text, line, column);
224 if (me) 221 if (me)
225 me->warnings++; 222 me->warnings++;
@@ -242,9 +239,6 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
242 temp++; 239 temp++;
243 temp[0] = '\0'; 240 temp[0] = '\0';
244 text = ++temp; 241 text = ++temp;
245 while (')' != temp[0])
246 temp++;
247 temp[0] = '\0';
248 PE("%s @ line %s, column %s.", text, line, column); 242 PE("%s @ line %s, column %s.", text, line, column);
249 if (me) 243 if (me)
250 me->bugs++; 244 me->bugs++;
@@ -276,55 +270,52 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
276//PD("FAKING (maybe) %s", command); 270//PD("FAKING (maybe) %s", command);
277 // Send back some random or fixed values for testing. 271 // Send back some random or fixed values for testing.
278 if (0 == strcmp(command, "llGetKey")) 272 if (0 == strcmp(command, "llGetKey"))
279 send2(ourGlobals->serverLuaSL, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 273 send2(ourGlobals->serverLuaSL, SID, "return(\"%08lx-%04lx-%04lx-%04lx-%012lx\")", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
280 else if (0 == strcmp(command, "llGetOwner")) 274 else if (0 == strcmp(command, "llGetOwner"))
281 send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); 275 send2(ourGlobals->serverLuaSL, SID, "return(\"%s\")", ownerKey);
282 else if (0 == strcmp(command, "llGetPermissionsKey")) 276 else if (0 == strcmp(command, "llGetPermissionsKey"))
283 send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); 277 send2(ourGlobals->serverLuaSL, SID, "return(\"%s\")", ownerKey);
284 else if (0 == strcmp(command, "llRequestPermissions")) 278 else if (0 == strcmp(command, "llRequestPermissions"))
285 PI("Faked %s(%s", command, arguments); 279 PI("Faked %s(%s)", command, arguments);
286 else if (0 == strcmp(command, "llGetPos")) 280 else if (0 == strcmp(command, "llGetPos"))
287 send2(ourGlobals->serverLuaSL, SID, "return {x=128.0, y=128.0, z=128.0}"); 281 send2(ourGlobals->serverLuaSL, SID, "return({x=128.0, y=128.0, z=128.0})");
288 else if (0 == strcmp(command, "llGetRot")) 282 else if (0 == strcmp(command, "llGetRot"))
289 send2(ourGlobals->serverLuaSL, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); 283 send2(ourGlobals->serverLuaSL, SID, "return({x=0.0, y=0.0, z=0.0, s=1.0})");
290 else if (0 == strcmp(command, "llGetFreeMemory")) 284 else if (0 == strcmp(command, "llGetFreeMemory"))
291 send2(ourGlobals->serverLuaSL, SID, "return 654321"); 285 send2(ourGlobals->serverLuaSL, SID, "return(654321)");
292 else if (0 == strcmp(command, "llGetObjectDesc")) 286 else if (0 == strcmp(command, "llGetObjectDesc"))
293 send2(ourGlobals->serverLuaSL, SID, "return \"\""); 287 send2(ourGlobals->serverLuaSL, SID, "return(\"\")");
294 else if (0 == strcmp(command, "llGetAlpha")) 288 else if (0 == strcmp(command, "llGetAlpha"))
295 send2(ourGlobals->serverLuaSL, SID, "return 1.0"); 289 send2(ourGlobals->serverLuaSL, SID, "return(1.0)");
296 else if (0 == strcmp(command, "llGetInventoryNumber") && (0 == strcmp(arguments, "7)"))) 290 else if (0 == strcmp(command, "llGetInventoryNumber") && (0 == strcmp(arguments, "7")))
297 send2(ourGlobals->serverLuaSL, SID, "return 3"); 291 send2(ourGlobals->serverLuaSL, SID, "return(3)");
298 else if (0 == strcmp(command, "llGetLinkNumber")) 292 else if (0 == strcmp(command, "llGetLinkNumber"))
299 send2(ourGlobals->serverLuaSL, SID, "return 1"); 293 send2(ourGlobals->serverLuaSL, SID, "return(1)");
300 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 2)"))) 294 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 2")))
301 send2(ourGlobals->serverLuaSL, SID, "return \".readme\""); 295 send2(ourGlobals->serverLuaSL, SID, "return(\".readme\")");
302 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 1)"))) 296 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 1")))
303 send2(ourGlobals->serverLuaSL, SID, "return \".POSITIONS\""); 297 send2(ourGlobals->serverLuaSL, SID, "return(\".POSITIONS\")");
304 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 0)"))) 298 else if (0 == strcmp(command, "llGetInventoryName") && (0 == strcmp(arguments, "7, 0")))
305 send2(ourGlobals->serverLuaSL, SID, "return \".MENUITEMS\""); 299 send2(ourGlobals->serverLuaSL, SID, "return(\".MENUITEMS\")");
306 else if (0 == strcmp(command, "llListen")) 300 else if (0 == strcmp(command, "llListen"))
307 { 301 {
308 PI("Faked %s(%s", command, arguments); 302 PI("Faked %s(%s)", command, arguments);
309 send2(ourGlobals->serverLuaSL, SID, "return %d", random()); 303 send2(ourGlobals->serverLuaSL, SID, "return(%d)", random());
310 } 304 }
311 else if (0 == strcmp(command, "llSameGroup")) 305 else if (0 == strcmp(command, "llSameGroup"))
312 send2(ourGlobals->serverLuaSL, SID, "return true"); 306 send2(ourGlobals->serverLuaSL, SID, "return(true)");
313 else if (0 == strcmp(command, "llKey2Name")) 307 else if (0 == strcmp(command, "llKey2Name"))
314 { 308 {
315 char *temp; 309 char *temp;
316 310
317 strcpy(buf, arguments); 311 strcpy(buf, arguments);
318 temp = buf; 312 temp = buf;
319 while (')' != temp[0])
320 temp++;
321 temp[0] = '\0';
322 if (0 == strcmp(buf, ownerKey)) 313 if (0 == strcmp(buf, ownerKey))
323 temp = ownerName; 314 temp = ownerName;
324 else 315 else
325 temp = "Unknown User"; 316 temp = "Unknown User";
326 // TODO - Sanitize the name, no telling what weird shit people put in their names. 317 // TODO - Sanitize the name, no telling what weird shit people put in their names.
327 snprintf(buf, sizeof(buf), "return \"%s\"", temp); 318 snprintf(buf, sizeof(buf), "return(\"%s\")", temp);
328 send2(ourGlobals->serverLuaSL, SID, buf); 319 send2(ourGlobals->serverLuaSL, SID, buf);
329 } 320 }
330 // Send "back" stuff on to the one and only client. 321 // Send "back" stuff on to the one and only client.
@@ -335,34 +326,34 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
335 // Dialogs, notifications, and other stuff goes through some other functions. 326 // Dialogs, notifications, and other stuff goes through some other functions.
336 else if (0 == strcmp(command, "llOwnerSay")) 327 else if (0 == strcmp(command, "llOwnerSay"))
337 { 328 {
338 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 329 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
339 else PW("No where to send %s(%s", command, arguments); 330 else PW("No where to send %s(%s)", command, arguments);
340 } 331 }
341 else if (0 == strcmp(command, "llWhisper")) 332 else if (0 == strcmp(command, "llWhisper"))
342 { 333 {
343 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 334 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
344 else PW("No where to send %s(%s", command, arguments); 335 else PW("No where to send %s(%s)", command, arguments);
345 } 336 }
346 else if (0 == strcmp(command, "llRegionSay")) 337 else if (0 == strcmp(command, "llRegionSay"))
347 { 338 {
348 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 339 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
349 else PW("No where to send %s(%s", command, arguments); 340 else PW("No where to send %s(%s)", command, arguments);
350 } 341 }
351 else if (0 == strcmp(command, "llSay")) 342 else if (0 == strcmp(command, "llSay"))
352 { 343 {
353 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 344 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
354 else PW("No where to send %s(%s", command, arguments); 345 else PW("No where to send %s(%s)", command, arguments);
355 } 346 }
356 else if (0 == strcmp(command, "llShout")) 347 else if (0 == strcmp(command, "llShout"))
357 { 348 {
358 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 349 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
359 else PW("No where to send %s(%s", command, arguments); 350 else PW("No where to send %s(%s)", command, arguments);
360 // TODO - Temporary so we have a place to log stuff from LSL. 351 // TODO - Temporary so we have a place to log stuff from LSL.
361 PD("SHOUTING %s", command); 352 PD("SHOUTING %s", command);
362 } 353 }
363 else if (0 == strcmp(command, "llDialog")) 354 else if (0 == strcmp(command, "llDialog"))
364 { 355 {
365 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s", command, arguments); 356 if (ourGlobals->client) send2(ourGlobals->client, SID, "%s(%s)", command, arguments);
366 } 357 }
367 else if (0 == strcmp(command, "llMessageLinked")) 358 else if (0 == strcmp(command, "llMessageLinked"))
368 { 359 {
@@ -372,7 +363,7 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
372 scripts = eina_hash_iterator_data_new(ourGlobals->scripts); 363 scripts = eina_hash_iterator_data_new(ourGlobals->scripts);
373 while(eina_iterator_next(scripts, (void **) &me)) 364 while(eina_iterator_next(scripts, (void **) &me))
374 { 365 {
375 send2(ourGlobals->serverLuaSL, me->SID, "events.link_message(%s", arguments); 366 send2(ourGlobals->serverLuaSL, me->SID, "events.link_message(%s)", arguments);
376 } 367 }
377 eina_iterator_free(scripts); 368 eina_iterator_free(scripts);
378 } 369 }
@@ -392,11 +383,9 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
392 while (' ' != temp[0]) 383 while (' ' != temp[0])
393 temp++; 384 temp++;
394 line = temp; 385 line = temp;
395 while (')' != temp[0])
396 temp++;
397 temp[0] = '\0';
398 lineNo = atoi(line); 386 lineNo = atoi(line);
399 snprintf(key, sizeof(key), "%s/Test%%20sim/onefang%%27s%%20test%%20bed/%s", prefix_data_get(), notecard); 387 snprintf(key, sizeof(key), "%s/Test%%20sim/onefang%%27s%%20test%%20bed/%s", prefix_data_get(), notecard);
388//PD("%s -> %s == %d, %s", notecard, line, lineNo, key);
400 389
401 fd = open(key, O_RDONLY); 390 fd = open(key, O_RDONLY);
402 if (-1 != fd) 391 if (-1 != fd)
@@ -418,7 +407,7 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
418 } while (temp && (0 < lineNo--)); 407 } while (temp && (0 < lineNo--));
419 408
420 sprintf(key, FAKE_UUID); 409 sprintf(key, FAKE_UUID);
421 send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", key); 410 send2(ourGlobals->serverLuaSL, SID, "return(\"%s\")", key);
422 411
423 // TODO - For now, just send it to everyone. 412 // TODO - For now, just send it to everyone.
424 scripts = eina_hash_iterator_data_new(ourGlobals->scripts); 413 scripts = eina_hash_iterator_data_new(ourGlobals->scripts);
@@ -438,7 +427,8 @@ static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *comman
438 buf2[j++] = '\\'; 427 buf2[j++] = '\\';
439 buf2[j++] = temp[i]; 428 buf2[j++] = temp[i];
440 } 429 }
441 send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", '%s')", key, buf2); 430//PE("events.dataserver(\"%s\", \'%s\')", key, buf2);
431 send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \'%s\')", key, buf2);
442 } 432 }
443 else 433 else
444 send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"EndOfFuckingAround\")", key); 434 send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"EndOfFuckingAround\")", key);
@@ -513,7 +503,7 @@ static boolean clientParser(void *data, Connection *conn, char *SID, char *comma
513 char buf[PATH_MAX]; 503 char buf[PATH_MAX];
514 504
515 // TODO - For now, just send it to everyone. 505 // TODO - For now, just send it to everyone.
516 sprintf(buf, "%s(%s", command, arguments); 506 sprintf(buf, "%s(%s)", command, arguments);
517 scripts = eina_hash_iterator_data_new(ourGlobals->scripts); 507 scripts = eina_hash_iterator_data_new(ourGlobals->scripts);
518 while(eina_iterator_next(scripts, (void **) &me)) 508 while(eina_iterator_next(scripts, (void **) &me))
519 { 509 {