aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-17 08:21:26 +1000
committerDavid Walter Seikel2014-05-17 08:21:26 +1000
commit8f67113ada10d14bae784f80ea81a64d1e4bd1a9 (patch)
tree3e7eeded21137728f0596de4afa9893f0dad1932 /src/libraries
parentMove the new pcall stuff to Runnr.c. (diff)
downloadSledjHamr-8f67113ada10d14bae784f80ea81a64d1e4bd1a9.zip
SledjHamr-8f67113ada10d14bae784f80ea81a64d1e4bd1a9.tar.gz
SledjHamr-8f67113ada10d14bae784f80ea81a64d1e4bd1a9.tar.bz2
SledjHamr-8f67113ada10d14bae784f80ea81a64d1e4bd1a9.tar.xz
Rearrange things in the libraries.
Diffstat (limited to 'src/libraries')
-rw-r--r--src/libraries/Runnr.c34
-rw-r--r--src/libraries/Runnr.h4
-rw-r--r--src/libraries/SledjHamr.c57
-rw-r--r--src/libraries/SledjHamr.h7
-rw-r--r--src/libraries/winFang.c35
-rw-r--r--src/libraries/winFang.h2
6 files changed, 67 insertions, 72 deletions
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
index 238bfb2..b775e19 100644
--- a/src/libraries/Runnr.c
+++ b/src/libraries/Runnr.c
@@ -402,37 +402,3 @@ int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em]
402 free(f); 402 free(f);
403 return n; 403 return n;
404} 404}
405
406void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...)
407{
408 va_list args;
409 char buf[PATH_MAX];
410 int length = strlen(SID);
411
412 strncpy(buf, SID, length);
413 buf[length++] = '.';
414 va_start(args, message);
415 length += vsprintf(&buf[length], message, args);
416 va_end(args);
417 buf[length++] = '\n';
418 buf[length++] = '\0';
419 ecore_con_client_send(client, buf, strlen(buf));
420 ecore_con_client_flush(client);
421}
422
423void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...)
424{
425 va_list args;
426 char buf[PATH_MAX];
427 int length = strlen(SID);
428
429 strncpy(buf, SID, length);
430 buf[length++] = '.';
431 va_start(args, message);
432 length += vsprintf(&buf[length], message, args);
433 va_end(args);
434 buf[length++] = '\n';
435 buf[length++] = '\0';
436 ecore_con_server_send(server, buf, strlen(buf));
437 ecore_con_server_flush(server);
438}
diff --git a/src/libraries/Runnr.h b/src/libraries/Runnr.h
index 5e3629d..0e0fc73 100644
--- a/src/libraries/Runnr.h
+++ b/src/libraries/Runnr.h
@@ -4,7 +4,6 @@
4#include <ctype.h> 4#include <ctype.h>
5 5
6#include <Eina.h> 6#include <Eina.h>
7#include <Ecore_Con.h>
8 7
9#include <lua.h> 8#include <lua.h>
10#include <luajit.h> 9#include <luajit.h>
@@ -17,7 +16,4 @@ void doLuaString(lua_State *L, char *string, char *module);
17int pull_lua(lua_State *L, int i, char *params, ...); 16int pull_lua(lua_State *L, int i, char *params, ...);
18int push_lua(lua_State *L, char *params, ...); 17int push_lua(lua_State *L, char *params, ...);
19 18
20void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...);
21void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...);
22
23#endif 19#endif
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c
index 6137199..2d6ed3a 100644
--- a/src/libraries/SledjHamr.c
+++ b/src/libraries/SledjHamr.c
@@ -1,36 +1,35 @@
1#include "SledjHamr.h" 1#include "SledjHamr.h"
2 2
3void HamrTime(void *elm_main, char *domain) 3void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...)
4{ 4{
5 char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; 5 va_list args;
6 char buf[PATH_MAX];
7 int length = strlen(SID);
6 8
7 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 9 strncpy(buf, SID, length);
8 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); 10 buf[length++] = '.';
9 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR); 11 va_start(args, message);
10 elm_app_compile_locale_set(PACKAGE_LOCALE_DIR); 12 length += vsprintf(&buf[length], message, args);
11 // Do this after the above calls, but before changing the working directory, or screwing with argv[0]. 13 va_end(args);
12 // It tries to set up the package paths depending on where the executable is, so things are relocatable. 14 buf[length++] = '\n';
13 // First argument is the elm_main() function that Elementary starts us from. 15 buf[length++] = '\0';
14 // Second argument should be a lower case string used as the "domain", which is different from the log domain. 16 ecore_con_client_send(client, buf, strlen(buf));
15 // It's used lower case as part of the data directory path. 17 ecore_con_client_flush(client);
16 // So, if prefix is /usr/local, then the system data dir is /usr/local/share, 18}
17 // and this apps data dir is /usr/local/share/"domain".
18 // It's used upper case as part of environment variables to override directory paths at run time.
19 // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR
20 // Third argument is the name of a file it can check for to make sure it found the correct path.
21 // This file is looked for in the data dir.
22 elm_app_info_set(elm_main, domain, "checkme.txt");
23 // Once this is all setup, the code can do -
24 // elm_app_prefix_dir_get(); // or bin, lib, data, locale.
25 19
26 getcwd(cwd, PATH_MAX); 20void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...)
27 env = getenv("LUA_CPATH"); 21{
28 if (!env) env = ""; 22 va_list args;
29 sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, elm_app_lib_dir_get(), elm_app_lib_dir_get(), cwd); 23 char buf[PATH_MAX];
30 setenv("LUA_CPATH", temp, 1); 24 int length = strlen(SID);
31 25
32 env = getenv("LUA_PATH"); 26 strncpy(buf, SID, length);
33 if (!env) env = ""; 27 buf[length++] = '.';
34 sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, elm_app_lib_dir_get(), cwd); 28 va_start(args, message);
35 setenv("LUA_PATH", temp, 1); 29 length += vsprintf(&buf[length], message, args);
30 va_end(args);
31 buf[length++] = '\n';
32 buf[length++] = '\0';
33 ecore_con_server_send(server, buf, strlen(buf));
34 ecore_con_server_flush(server);
36} 35}
diff --git a/src/libraries/SledjHamr.h b/src/libraries/SledjHamr.h
index aee845d..548c5e0 100644
--- a/src/libraries/SledjHamr.h
+++ b/src/libraries/SledjHamr.h
@@ -8,15 +8,14 @@
8/* Enable access to unstable EFL EO API. */ 8/* Enable access to unstable EFL EO API. */
9#define EFL_EO_API_SUPPORT 1 9#define EFL_EO_API_SUPPORT 1
10 10
11//#include <ctype.h>
12#include <stdlib.h> 11#include <stdlib.h>
13 12
14#include <Elementary.h> 13#include <Ecore_Con.h>
15 14
16 15
17#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array)) 16#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array))
18 17
19 18void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...);
20void HamrTime(void *elm_main, char *domain); 19void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...);
21 20
22#endif 21#endif
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c
index 5662970..dc5188a 100644
--- a/src/libraries/winFang.c
+++ b/src/libraries/winFang.c
@@ -1,7 +1,40 @@
1#include "winFang.h" 1#include "winFang.h"
2 2
3 3
4 4void HamrTime(void *elm_main, char *domain)
5{
6 char *env, cwd[PATH_MAX], temp[PATH_MAX * 2];
7
8 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
9 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
10 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
11 elm_app_compile_locale_set(PACKAGE_LOCALE_DIR);
12 // Do this after the above calls, but before changing the working directory, or screwing with argv[0].
13 // It tries to set up the package paths depending on where the executable is, so things are relocatable.
14 // First argument is the elm_main() function that Elementary starts us from.
15 // Second argument should be a lower case string used as the "domain", which is different from the log domain.
16 // It's used lower case as part of the data directory path.
17 // So, if prefix is /usr/local, then the system data dir is /usr/local/share,
18 // and this apps data dir is /usr/local/share/"domain".
19 // It's used upper case as part of environment variables to override directory paths at run time.
20 // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR
21 // Third argument is the name of a file it can check for to make sure it found the correct path.
22 // This file is looked for in the data dir.
23 elm_app_info_set(elm_main, domain, "checkme.txt");
24 // Once this is all setup, the code can do -
25 // elm_app_prefix_dir_get(); // or bin, lib, data, locale.
26
27 getcwd(cwd, PATH_MAX);
28 env = getenv("LUA_CPATH");
29 if (!env) env = "";
30 sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, elm_app_lib_dir_get(), elm_app_lib_dir_get(), cwd);
31 setenv("LUA_CPATH", temp, 1);
32
33 env = getenv("LUA_PATH");
34 if (!env) env = "";
35 sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, elm_app_lib_dir_get(), cwd);
36 setenv("LUA_PATH", temp, 1);
37}
5 38
6static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 39static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
7{ 40{
diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h
index 3d721ef..bae3082 100644
--- a/src/libraries/winFang.h
+++ b/src/libraries/winFang.h
@@ -89,6 +89,8 @@ typedef struct _Widget
89 Evas_Smart_Cb on_del; 89 Evas_Smart_Cb on_del;
90} Widget; 90} Widget;
91 91
92void HamrTime(void *elm_main, char *domain);
93
92winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); 94winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world);
93void winFangHide(winFang *win); 95void winFangHide(winFang *win);
94void winFangShow(winFang *win); 96void winFangShow(winFang *win);