aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/libraries/LumbrJack.c2
-rw-r--r--src/libraries/Runnr.c60
-rw-r--r--src/libraries/SledjHamr.c68
3 files changed, 63 insertions, 67 deletions
diff --git a/src/libraries/LumbrJack.c b/src/libraries/LumbrJack.c
index 8683357..3bb67e9 100644
--- a/src/libraries/LumbrJack.c
+++ b/src/libraries/LumbrJack.c
@@ -19,7 +19,7 @@ int HamrTime(char *argv0, void *main, int logDom)
19 19
20 if (!eina_init()) 20 if (!eina_init())
21 { 21 {
22 printf("Can't load eina library, nothing else will work!\n"); 22 fprintf(stderr, "Can't load eina library, nothing else will work!\n");
23 exit(0); 23 exit(0);
24 } 24 }
25 25
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
index 5ec5a9c..04547b4 100644
--- a/src/libraries/Runnr.c
+++ b/src/libraries/Runnr.c
@@ -60,12 +60,12 @@ static int traceBack(lua_State *L)
60 lua_Debug ar; 60 lua_Debug ar;
61 int i, top = lua_gettop(L), b = 1; 61 int i, top = lua_gettop(L), b = 1;
62 62
63// printf("Stack is %d deep\n", top); 63// PI("Stack is %d deep", top);
64// for (i = 1; i <= top; i++) 64// for (i = 1; i <= top; i++)
65// dumpStack(L, i); 65// dumpStack(L, i);
66 66
67 if (top) 67 if (top)
68 printf("Lua error - %s\n", lua_tostring(L, 1)); 68 PE("Lua error - %s", lua_tostring(L, 1));
69 69
70 i = 0; 70 i = 0;
71 while (lua_getstack(L, i++, &ar)) 71 while (lua_getstack(L, i++, &ar))
@@ -74,15 +74,15 @@ static int traceBack(lua_State *L)
74 { 74 {
75 if (NULL == ar.name) 75 if (NULL == ar.name)
76 ar.name = "DUNNO"; 76 ar.name = "DUNNO";
77 printf(" Lua backtrace %d - %s %s %s @ %s : %d\n", i, ar.what, ar.namewhat, ar.name, ar.short_src, ar.currentline); 77 PE(" Lua backtrace %d - %s %s %s @ %s : %d", i, ar.what, ar.namewhat, ar.name, ar.short_src, ar.currentline);
78 b = 0; 78 b = 0;
79 } 79 }
80 else 80 else
81 printf(" Failed to get trace line!\n"); 81 PE(" Failed to get trace line!");
82 } 82 }
83 83
84 if (b) 84 if (b)
85 printf(" NO BACKTRACE!\n"); 85 PE(" NO BACKTRACE!");
86 86
87 return 0; 87 return 0;
88} 88}
@@ -99,7 +99,7 @@ static void printLuaError(int err, char *string, lua_State *L)
99 case LUA_ERRERR: err_type = "error handler"; break; 99 case LUA_ERRERR: err_type = "error handler"; break;
100 default: err_type = "unknown"; break; 100 default: err_type = "unknown"; break;
101 } 101 }
102 printf("Error running - %s, \n %s - %s\n", string, err_type, lua_tostring(L, -1)); 102 PW("Error running - %s, \n %s - %s", string, err_type, lua_tostring(L, -1));
103} 103}
104 104
105static int panics = 0; 105static int panics = 0;
@@ -109,9 +109,9 @@ static int _panic(lua_State *L) // Stack usage [-0, +0, m]
109 // of memory in the following lua_tostring() call. 109 // of memory in the following lua_tostring() call.
110 panics++; 110 panics++;
111 if (panics) 111 if (panics)
112 printf("Lua PANICS!!!!!"); 112 PE("Lua PANICS!!!!!");
113 else 113 else
114 printf("Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m] 114 PE("Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m]
115 // The docs say that this will cause an exit(EXIT_FAILURE) if we return, 115 // The docs say that this will cause an exit(EXIT_FAILURE) if we return,
116 // and that we we should long jump some where to avoid that. This is only 116 // and that we we should long jump some where to avoid that. This is only
117 // called for things not called from a protected environment. We always 117 // called for things not called from a protected environment. We always
@@ -147,7 +147,7 @@ void doLuaString(lua_State *L, char *string, char *module)
147 { 147 {
148 const char *err = lua_tostring(L, 1); 148 const char *err = lua_tostring(L, 1);
149 149
150 printf("Error parsing - %s, ERROR %s", string, err); 150 PE("Error parsing - %s, ERROR %s", string, err);
151 } 151 }
152 else 152 else
153 { 153 {
@@ -159,12 +159,12 @@ void doLuaString(lua_State *L, char *string, char *module)
159 // Consistancy would be good, just sayin'. 159 // Consistancy would be good, just sayin'.
160 if (0 == lua_setfenv(L, _A)) 160 if (0 == lua_setfenv(L, _A))
161 { 161 {
162 printf("Error setting environment for - %s", string); 162 PE("Error setting environment for - %s", string);
163 return; 163 return;
164 } 164 }
165 } 165 }
166 166
167//printf("doLuaString(%s)\n", string); 167//PD("doLuaString(%s)\", string);
168 if ((err = lua_pcall(L, 0, LUA_MULTRET, _T))) 168 if ((err = lua_pcall(L, 0, LUA_MULTRET, _T)))
169 printLuaError(err, string, L); 169 printLuaError(err, string, L);
170 } 170 }
@@ -174,7 +174,7 @@ static void _stopScript(script *s)
174{ 174{
175 scriptMessage *sm0, *sm1; 175 scriptMessage *sm0, *sm1;
176 176
177//printf("^^^^^^^^^^^^^^^^^^^_stop(, %s)\n", s->name); 177//PD("^^^^^^^^^^^^^^^^^^^_stop(, %s)", s->name);
178 if (s->L) lua_close(s->L); s->L = NULL; 178 if (s->L) lua_close(s->L); s->L = NULL;
179 if (s->timer) ecore_timer_del(s->timer); s->timer = NULL; 179 if (s->timer) ecore_timer_del(s->timer); s->timer = NULL;
180 EINA_CLIST_FOR_EACH_ENTRY_SAFE(sm0, sm1, &(s->messages), scriptMessage, node) 180 EINA_CLIST_FOR_EACH_ENTRY_SAFE(sm0, sm1, &(s->messages), scriptMessage, node)
@@ -210,7 +210,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
210 210
211 if (RUNNR_READY == s->status) 211 if (RUNNR_READY == s->status)
212 { 212 {
213//printf("_workerFunction() READY %s\n", s->name); 213//PD("_workerFunction() READY %s", s->name);
214 if ((msg = (scriptMessage *) eina_clist_head(&(s->messages)))) 214 if ((msg = (scriptMessage *) eina_clist_head(&(s->messages))))
215 { 215 {
216 eina_clist_remove(&(msg->node)); 216 eina_clist_remove(&(msg->node));
@@ -226,7 +226,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
226 { 226 {
227 int err; 227 int err;
228 228
229//printf("_workerFunction() STARTING %s\n", s->name); 229//PD("_workerFunction() STARTING %s", s->name);
230 s->status = RUNNR_RUNNING; 230 s->status = RUNNR_RUNNING;
231 s->L = luaL_newstate(); // Sets a standard allocator and panic function. 231 s->L = luaL_newstate(); // Sets a standard allocator and panic function.
232 232
@@ -243,7 +243,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
243 if (err != 0) 243 if (err != 0)
244 { 244 {
245 s->status = RUNNR_FINISHED; 245 s->status = RUNNR_FINISHED;
246 printf("Error loading compiled Lua %s.", s->binName); 246 PE("Error loading compiled Lua %s.", s->binName);
247 } 247 }
248 gettimeofday(&s->startTime, NULL); 248 gettimeofday(&s->startTime, NULL);
249 } 249 }
@@ -254,7 +254,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
254 { 254 {
255 int stat; 255 int stat;
256 256
257//printf("_workerFunction() RUNNING %s %s\n", s->name, message); 257//PD("_workerFunction() RUNNING %s %s", s->name, message);
258 // Resume running the script. 258 // Resume running the script.
259 // lua_resume() needs a Lua thread, and the initial Lua state is a thread. 259 // lua_resume() needs a Lua thread, and the initial Lua state is a thread.
260 // Other Lua threads have their own state, but share the environment with the initial state. 260 // Other Lua threads have their own state, but share the environment with the initial state.
@@ -270,7 +270,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
270 s->status = RUNNR_FINISHED; 270 s->status = RUNNR_FINISHED;
271 else if (stat != LUA_YIELD) 271 else if (stat != LUA_YIELD)
272 { 272 {
273 printf("lua_resume error at %s\n", s->name); 273 PE("lua_resume error at %s", s->name);
274 printLuaError(stat, s->name, s->L); 274 printLuaError(stat, s->name, s->L);
275 s->status = RUNNR_FINISHED; 275 s->status = RUNNR_FINISHED;
276 } 276 }
@@ -288,7 +288,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
288 // Start again from the top when Ecore_Thread has a spare thread ready, unless the script finished. 288 // Start again from the top when Ecore_Thread has a spare thread ready, unless the script finished.
289 if (RUNNR_FINISHED == s->status) 289 if (RUNNR_FINISHED == s->status)
290 { 290 {
291//printf("_workerFunction() FINISHED %s\n", s->name); 291//PD("_workerFunction() FINISHED %s", s->name);
292#if THREADIT 292#if THREADIT
293 ecore_thread_cancel(thread); 293 ecore_thread_cancel(thread);
294#else 294#else
@@ -297,7 +297,7 @@ static void _workerFunction(void *data, Ecore_Thread *thread)
297 } 297 }
298 else if (RUNNR_WAIT == s->status) 298 else if (RUNNR_WAIT == s->status)
299 { 299 {
300;//printf("_workerFunction() WAIT %s\n", s->name); 300;//PD("_workerFunction() WAIT %s", s->name);
301 } 301 }
302#if THREADIT 302#if THREADIT
303 else if (RUNNR_READY == s->status) 303 else if (RUNNR_READY == s->status)
@@ -323,7 +323,7 @@ static void _cancel(void *data, Ecore_Thread *thread)
323 s->status = RUNNR_FINISHED; 323 s->status = RUNNR_FINISHED;
324 eina_clist_remove(&(s->node)); 324 eina_clist_remove(&(s->node));
325 if (s->SID[0]) ecore_thread_global_data_del(s->SID); s->SID[0] = 0; 325 if (s->SID[0]) ecore_thread_global_data_del(s->SID); s->SID[0] = 0;
326//printf("^^^^^^^^^^^^^^^^^^^_del(, %s)\n", s->name); 326//PD("^^^^^^^^^^^^^^^^^^^_del(, %s)", s->name);
327 // TODO - Perhaps have our own deletion callback to pass back? 327 // TODO - Perhaps have our own deletion callback to pass back?
328 releaseScript(s); 328 releaseScript(s);
329#if THREADIT 329#if THREADIT
@@ -444,11 +444,11 @@ static void _compileThread(void *data, Ecore_Thread *thread)
444 compiler->bugCount++; 444 compiler->bugCount++;
445#if COMPILE_OUTPUT 445#if COMPILE_OUTPUT
446 if (LUA_ERRSYNTAX == err) 446 if (LUA_ERRSYNTAX == err)
447 printf("Lua syntax error in %s: %s\n", name, lua_tostring(L, -1)); 447 PI("Lua syntax error in %s: %s", name, lua_tostring(L, -1));
448 else if (LUA_ERRFILE == err) 448 else if (LUA_ERRFILE == err)
449 printf("Lua compile file error in %s: %s\n", name, lua_tostring(L, -1)); 449 PE("Lua compile file error in %s: %s", name, lua_tostring(L, -1));
450 else if (LUA_ERRMEM == err) 450 else if (LUA_ERRMEM == err)
451 printf("Lua compile memory allocation error in %s: %s\n", name, lua_tostring(L, -1)); 451 PC("Lua compile memory allocation error in %s: %s", name, lua_tostring(L, -1));
452#endif 452#endif
453 } 453 }
454 else 454 else
@@ -462,28 +462,28 @@ static void _compileThread(void *data, Ecore_Thread *thread)
462 if (err) 462 if (err)
463 { 463 {
464 compiler->bugCount++; 464 compiler->bugCount++;
465 printf("Lua compile file error writing to %s\n", name); 465 PE("Lua compile file error writing to %s", name);
466 } 466 }
467 fclose(out); 467 fclose(out);
468 } 468 }
469 else 469 else
470 { 470 {
471 compiler->bugCount++; 471 compiler->bugCount++;
472 printf("CRITICAL! Unable to open file %s for writing!\n", name); 472 PE("CRITICAL! Unable to open file %s for writing!", name);
473 } 473 }
474 } 474 }
475 } 475 }
476 else if (!compiler->doConstants) 476 else if (!compiler->doConstants)
477 { 477 {
478 compiler->bugCount++; 478 compiler->bugCount++;
479 printf("Can't create a new Lua state!\n"); 479 PC("Can't create a new Lua state!");
480 } 480 }
481 } 481 }
482 else 482 else
483 { 483 {
484 compiler->bugCount++; 484 compiler->bugCount++;
485#if COMPILE_OUTPUT 485#if COMPILE_OUTPUT
486 printf("Nothing for Lua to compile!\n"); 486 PW("Nothing for Lua to compile!");
487#endif 487#endif
488 } 488 }
489} 489}
@@ -544,8 +544,8 @@ void takeScript(script *s)
544{ 544{
545#if THREADIT 545#if THREADIT
546 Eina_Lock_Result result = eina_lock_take(&s->mutex); 546 Eina_Lock_Result result = eina_lock_take(&s->mutex);
547 if (EINA_LOCK_DEADLOCK == result) printf("Script %s IS DEADLOCKED!\n", s->name); 547 if (EINA_LOCK_DEADLOCK == result) PE("Script %s IS DEADLOCKED!", s->name);
548 if (EINA_LOCK_FAIL == result) printf("Script %s LOCK FAILED!\n", s->name); 548 if (EINA_LOCK_FAIL == result) PE("Script %s LOCK FAILED!", s->name);
549#endif 549#endif
550} 550}
551 551
@@ -861,7 +861,7 @@ int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em]
861 { 861 {
862 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m] 862 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
863 char *t = va_arg(vl, char *); 863 char *t = va_arg(vl, char *);
864//printf("push_lua %s string %s\n", p, t); 864//PD("push_lua %s string %s", p, t);
865 lua_pushstring(L, t); // Stack usage [-0, +1, m] 865 lua_pushstring(L, t); // Stack usage [-0, +1, m]
866 break; 866 break;
867 } 867 }
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c
index 10eeca5..2fb9019 100644
--- a/src/libraries/SledjHamr.c
+++ b/src/libraries/SledjHamr.c
@@ -38,7 +38,7 @@ static boolean checkConnection(Connection *conn, char *func, connType wanted, bo
38 if ((conn->type != CT_CLIENT) && (conn->type != CT_SERVER)) 38 if ((conn->type != CT_CLIENT) && (conn->type != CT_SERVER))
39 { 39 {
40 result = FALSE; 40 result = FALSE;
41 printf("CONNECTION OBJECT in %s() is of unknown type %d\n", func, (int) conn->type); 41 PE("CONNECTION OBJECT in %s() is of unknown type %d", func, (int) conn->type);
42 } 42 }
43 else if (conn->type != wanted) 43 else if (conn->type != wanted)
44 { 44 {
@@ -47,43 +47,43 @@ static boolean checkConnection(Connection *conn, char *func, connType wanted, bo
47 { 47 {
48 case CT_CLIENT : 48 case CT_CLIENT :
49 if (conn->type == CT_SERVER) 49 if (conn->type == CT_SERVER)
50 printf("INVALID CONNECTION OBJECT in %s(), it might be a server object!\n", func); 50 PE("INVALID CONNECTION OBJECT in %s(), it might be a server object!", func);
51 else 51 else
52 printf("INVALID CONNECTION OBJECT in %s(), type is %d!\n", func, (int) conn->type); 52 PE("INVALID CONNECTION OBJECT in %s(), type is %d!", func, (int) conn->type);
53 if (conn->conn.client.myServer == NULL) 53 if (conn->conn.client.myServer == NULL)
54 printf("CONNECTION OBJECT in %s() is a local client, but should be a remote client mirror!\n", func); 54 PE("CONNECTION OBJECT in %s() is a local client, but should be a remote client mirror!", func);
55 break; 55 break;
56 56
57 case CT_SERVER : 57 case CT_SERVER :
58 if (conn->type == CT_CLIENT) 58 if (conn->type == CT_CLIENT)
59 printf("INVALID CONNECTION OBJECT in %s(), it might be a client object!\n", func); 59 PE("INVALID CONNECTION OBJECT in %s(), it might be a client object!", func);
60 else 60 else
61 printf("INVALID CONNECTION OBJECT in %s(), type is %d!\n", func, (int) conn->type); 61 PE("INVALID CONNECTION OBJECT in %s(), type is %d!", func, (int) conn->type);
62 if (isLocal) 62 if (isLocal)
63 { 63 {
64 if (conn->conn.server.clients == NULL) 64 if (conn->conn.server.clients == NULL)
65 printf("CONNECTION OBJECT in %s() is a remote server mirror, but should be a local server!\n", func); 65 PE("CONNECTION OBJECT in %s() is a remote server mirror, but should be a local server!", func);
66 } 66 }
67 else 67 else
68 { 68 {
69 if (conn->conn.server.clients != NULL) 69 if (conn->conn.server.clients != NULL)
70 printf("CONNECTION OBJECT in %s() is a local server, but should be a remote server mirror!\n", func); 70 PE("CONNECTION OBJECT in %s() is a local server, but should be a remote server mirror!", func);
71 } 71 }
72 break; 72 break;
73 73
74 default : 74 default :
75 printf("CONNECTION OBJECT in %s(), silly coder asked for an unknown type!""\n", func); 75 PE("CONNECTION OBJECT in %s(), silly coder asked for an unknown type!", func);
76 break; 76 break;
77 } 77 }
78 78
79 if (NULL == conn->name) 79 if (NULL == conn->name)
80 { 80 {
81 result = FALSE; 81 result = FALSE;
82 printf("CONNECTION OBJECT in %s() has no name!\n", func); 82 PE("CONNECTION OBJECT in %s() has no name!", func);
83 } 83 }
84 } 84 }
85 85
86//if (result) printf("%s(\"%s\")\n", func, conn->name); 86//if (result) PD("%s(\"%s\")", func, conn->name);
87 87
88 return result; 88 return result;
89} 89}
@@ -102,11 +102,11 @@ void sendBack(Connection *conn, const char *SID, const char *message, ...)
102 va_end(args); 102 va_end(args);
103 buf[length++] = '\n'; 103 buf[length++] = '\n';
104 buf[length] = '\0'; 104 buf[length] = '\0';
105// printf("sendBack(%s", buf); 105// PD("sendBack(%s", buf);
106// ecore_con_client_send(client, buf, length); 106// ecore_con_client_send(client, buf, length);
107// ecore_con_client_flush(client); 107// ecore_con_client_flush(client);
108//Connection *conn = ecore_con_client_data_get(client); 108//Connection *conn = ecore_con_client_data_get(client);
109if (conn) send2(conn, SID, buf); else printf("sendBack() can't find Connection!\n"); 109if (conn) send2(conn, SID, buf); else PE("sendBack() can't find Connection!");
110} 110}
111 111
112void sendForth(Connection *conn, const char *SID, const char *message, ...) 112void sendForth(Connection *conn, const char *SID, const char *message, ...)
@@ -123,11 +123,11 @@ void sendForth(Connection *conn, const char *SID, const char *message, ...)
123 va_end(args); 123 va_end(args);
124 buf[length++] = '\n'; 124 buf[length++] = '\n';
125 buf[length] = '\0'; 125 buf[length] = '\0';
126// printf("sendForth(%s", buf); 126// PD("sendForth(%s", buf);
127// ecore_con_server_send(server, buf, length); 127// ecore_con_server_send(server, buf, length);
128// ecore_con_server_flush(server); 128// ecore_con_server_flush(server);
129//Connection *conn = ecore_con_server_data_get(server); 129//Connection *conn = ecore_con_server_data_get(server);
130if (conn) send2(conn, SID, buf); else printf("sendForth() can't find Connection!\n"); 130if (conn) send2(conn, SID, buf); else PE("sendForth() can't find Connection!");
131} 131}
132 132
133void send2(Connection *conn, const char *SID, const char *message, ...) 133void send2(Connection *conn, const char *SID, const char *message, ...)
@@ -153,24 +153,24 @@ length = strlen(buf);
153 switch (conn->type) 153 switch (conn->type)
154 { 154 {
155 case CT_CLIENT : 155 case CT_CLIENT :
156// printf("vvv send2(%*s", length, buf); 156// PD("vvv send2(%*s", length, buf);
157 ecore_con_client_send(conn->conn.client.client, strndup(buf, length), length); 157 ecore_con_client_send(conn->conn.client.client, strndup(buf, length), length);
158 ecore_con_client_flush(conn->conn.client.client); 158 ecore_con_client_flush(conn->conn.client.client);
159 break; 159 break;
160 160
161 case CT_SERVER : 161 case CT_SERVER :
162// printf("^^^ send2(%*s", length, buf); 162// PD("^^^ send2(%*s", length, buf);
163 ecore_con_server_send(conn->conn.server.server, strndup(buf, length), length); 163 ecore_con_server_send(conn->conn.server.server, strndup(buf, length), length);
164 ecore_con_server_flush(conn->conn.server.server); 164 ecore_con_server_flush(conn->conn.server.server);
165 break; 165 break;
166 166
167 default : 167 default :
168 printf("send2() unable to send to partially bogus Connection object!\n"); 168 PE("send2() unable to send to partially bogus Connection object!");
169 break; 169 break;
170 } 170 }
171 } 171 }
172 else 172 else
173 printf("send2() unable to send to bogus Connection object!\n"); 173 PE("send2() unable to send to bogus Connection object!");
174} 174}
175 175
176static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, void *ev) 176static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, void *ev)
@@ -180,7 +180,6 @@ static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, voi
180 const char *command; 180 const char *command;
181 char *ext; 181 char *ext;
182 182
183//printf("parseStream(%s, \"%*s\")\n", conn->name, evSize, (char *) evData);
184 if (NULL == conn->stream) 183 if (NULL == conn->stream)
185 conn->stream = eina_strbuf_new(); 184 conn->stream = eina_strbuf_new();
186 185
@@ -202,7 +201,6 @@ static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, voi
202 if (ext) 201 if (ext)
203 { 202 {
204 streamParser func = eina_hash_find(conn->commands, command); 203 streamParser func = eina_hash_find(conn->commands, command);
205//printf("parseStream(%s>> %s\"\n", conn->name, command);
206 204
207// ext[0] = '\0'; 205// ext[0] = '\0';
208 // Need a callback if we can't find the command. 206 // Need a callback if we can't find the command.
@@ -211,7 +209,7 @@ static Eina_Bool parseStream(void *data, int type, void *evData, int evSize, voi
211 if (func) 209 if (func)
212 func(conn->pointer, conn, SID, (char *) command, ext + 1); 210 func(conn->pointer, conn, SID, (char *) command, ext + 1);
213 else 211 else
214 printf("parseStream() No function found for command %s!\n", command); 212 PE("parseStream() No function found for command %s!", command);
215 } 213 }
216 } 214 }
217 215
@@ -297,9 +295,9 @@ static Eina_Bool clientDel(void *data, int type, Ecore_Con_Event_Client_Del *ev)
297 // The "- 1" is coz this server is still counted. 295 // The "- 1" is coz this server is still counted.
298 clients = ecore_con_server_clients_get(conn->conn.server.server) - 1; 296 clients = ecore_con_server_clients_get(conn->conn.server.server) - 1;
299 if (0 == eina_list_count(clients)) 297 if (0 == eina_list_count(clients))
300 printf("No more clients for %s, exiting.\n", conn->name); 298 PI("No more clients for %s, exiting.", conn->name);
301 else 299 else
302 printf("Some (%d) more clients for %s, exiting anyway.\n", eina_list_count(clients), conn->name); 300 PW("Some (%d) more clients for %s, exiting anyway.", eina_list_count(clients), conn->name);
303 301
304 // TODO - the Connection free function should take care of all of this, and we should call it here. ish. 302 // TODO - the Connection free function should take care of all of this, and we should call it here. ish.
305 eina_clist_remove(conn->conn.client.server); 303 eina_clist_remove(conn->conn.client.server);
@@ -345,7 +343,7 @@ Connection *openArms(char *name, const char *address, int port, void *data, Ecor
345 ecore_con_server_client_limit_set(server, -1, 0); 343 ecore_con_server_client_limit_set(server, -1, 0);
346// ecore_con_server_timeout_set(server, 10); 344// ecore_con_server_timeout_set(server, 10);
347// ecore_con_server_client_limit_set(server, 3, 0); 345// ecore_con_server_client_limit_set(server, 3, 0);
348 printf("ACTUALLY created the %s server %s:%d.\n", name, address, port); 346 PI("ACTUALLY created the %s server %s:%d.", name, address, port);
349 } 347 }
350 else 348 else
351 { 349 {
@@ -368,9 +366,9 @@ static Eina_Bool serverAdd(void *data, int type, Ecore_Con_Event_Server_Add *ev)
368 conn->stage++; 366 conn->stage++;
369 367
370 if (conn->name) 368 if (conn->name)
371 printf("serverAdd()^^^^^^^^^^^^^^^^^^^^^^^Connected to %s server.\n", conn->name); 369 PI("serverAdd()^^^^^^^^^^^^^^^^^^^^^^^Connected to %s server.", conn->name);
372 else 370 else
373 printf("serverAdd()^^^^^^^^^^^^^^^^^^^^^^^Connected to UNKNOWN server.\n"); 371 PW("serverAdd()^^^^^^^^^^^^^^^^^^^^^^^Connected to UNKNOWN server.");
374 372
375 // In case the server crashed, clear out any waiting data. 373 // In case the server crashed, clear out any waiting data.
376 if (conn->stream) 374 if (conn->stream)
@@ -421,18 +419,16 @@ static Eina_Bool _reachOutTimer(void *data)
421 { 419 {
422 // TODO - Seems Ecore_con now has trouble with my try first, then start method, so start first, then try. Fix this, or do something else. 420 // TODO - Seems Ecore_con now has trouble with my try first, then start method, so start first, then try. Fix this, or do something else.
423 case -3 : 421 case -3 :
424 printf("Failed to connect to a %s server, starting our own.\n", conn->name); 422 PW("Failed to connect to a %s server, starting our own.", conn->name);
425 conn->conn.server.serverHandle = ecore_exe_pipe_run(conn->conn.server.serverCommand, ECORE_EXE_NONE /*| ECORE_EXE_TERM_WITH_PARENT*/, conn); 423 conn->conn.server.serverHandle = ecore_exe_pipe_run(conn->conn.server.serverCommand, ECORE_EXE_NONE /*| ECORE_EXE_TERM_WITH_PARENT*/, conn);
426 if (conn->conn.server.serverHandle) 424 if (conn->conn.server.serverHandle)
427 { 425 {
428 conn->conn.server.pid = ecore_exe_pid_get(conn->conn.server.serverHandle); 426 conn->conn.server.pid = ecore_exe_pid_get(conn->conn.server.serverHandle);
429 if (conn->conn.server.pid == -1) 427 if (conn->conn.server.pid == -1)
430 fprintf(stderr, "Could not retrive the PID!\n"); 428 PE("Could not retrive the PID!");
431 else
432 fprintf(stdout, "The child process has PID:%u\n", (unsigned int)conn->conn.server.pid);
433 } 429 }
434 else 430 else
435 fprintf(stderr, "Could not create server process %s!\n", conn->conn.server.serverCommand); 431 PE("Could not create server process %s!", conn->conn.server.serverCommand);
436 432
437 // TODO - There's also the question of what to do if the connection failed. 433 // TODO - There's also the question of what to do if the connection failed.
438 // Did the server crash, or was it just the connection? 434 // Did the server crash, or was it just the connection?
@@ -448,20 +444,20 @@ static Eina_Bool _reachOutTimer(void *data)
448 case -1 : // Give the server some time to start up. 444 case -1 : // Give the server some time to start up.
449 // Check if the server is still running here, if not, reset stage to previous -3 (taking into account the increment at the end). 445 // Check if the server is still running here, if not, reset stage to previous -3 (taking into account the increment at the end).
450 if (conn->conn.server.pid) 446 if (conn->conn.server.pid)
451 printf("Waiting for %s server to start from command \"%s\"\n", conn->name, conn->conn.server.serverCommand); 447 PI("Waiting for %s server to start from command \"%s\"", conn->name, conn->conn.server.serverCommand);
452 else 448 else
453 conn->stage = -4; 449 conn->stage = -4;
454 break; 450 break;
455 451
456 case 0 : 452 case 0 :
457 printf("Attempting to connect to the %s server %s:%d.\n", conn->name, conn->address, conn->port); 453 PI("Attempting to connect to the %s server %s:%d.", conn->name, conn->address, conn->port);
458 // This should only return NULL if something goes wrong with the setup, 454 // This should only return NULL if something goes wrong with the setup,
459 // you wont know if the connection worked until you get the add callback, 455 // you wont know if the connection worked until you get the add callback,
460 // or you get the del calback if it failed. 456 // or you get the del calback if it failed.
461 if ((server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, conn->address, conn->port, conn))) 457 if ((server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, conn->address, conn->port, conn)))
462 printf("MAYBE connecting to the %s server %s:%d.\n", conn->name, conn->address, conn->port); 458 PD("MAYBE connecting to the %s server %s:%d.", conn->name, conn->address, conn->port);
463 else 459 else
464 printf("FAILED to create the connection to the %s server %s:%d!\n", conn->name, conn->address, conn->port); 460 PE("FAILED to create the connection to the %s server %s:%d!", conn->name, conn->address, conn->port);
465 conn->conn.server.server = server; 461 conn->conn.server.server = server;
466 break; 462 break;
467 463