From 8f67113ada10d14bae784f80ea81a64d1e4bd1a9 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 17 May 2014 08:21:26 +1000 Subject: Rearrange things in the libraries. --- src/libraries/Runnr.c | 34 ---------------------------- src/libraries/Runnr.h | 4 ---- src/libraries/SledjHamr.c | 57 +++++++++++++++++++++++------------------------ src/libraries/SledjHamr.h | 7 +++--- src/libraries/winFang.c | 35 ++++++++++++++++++++++++++++- src/libraries/winFang.h | 2 ++ 6 files changed, 67 insertions(+), 72 deletions(-) (limited to 'src/libraries') 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] free(f); return n; } - -void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...) -{ - va_list args; - char buf[PATH_MAX]; - int length = strlen(SID); - - strncpy(buf, SID, length); - buf[length++] = '.'; - va_start(args, message); - length += vsprintf(&buf[length], message, args); - va_end(args); - buf[length++] = '\n'; - buf[length++] = '\0'; - ecore_con_client_send(client, buf, strlen(buf)); - ecore_con_client_flush(client); -} - -void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...) -{ - va_list args; - char buf[PATH_MAX]; - int length = strlen(SID); - - strncpy(buf, SID, length); - buf[length++] = '.'; - va_start(args, message); - length += vsprintf(&buf[length], message, args); - va_end(args); - buf[length++] = '\n'; - buf[length++] = '\0'; - ecore_con_server_send(server, buf, strlen(buf)); - ecore_con_server_flush(server); -} 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 @@ #include #include -#include #include #include @@ -17,7 +16,4 @@ void doLuaString(lua_State *L, char *string, char *module); int pull_lua(lua_State *L, int i, char *params, ...); int push_lua(lua_State *L, char *params, ...); -void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...); -void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...); - #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 @@ #include "SledjHamr.h" -void HamrTime(void *elm_main, char *domain) +void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...) { - char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; + va_list args; + char buf[PATH_MAX]; + int length = strlen(SID); - elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); - elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); - elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR); - elm_app_compile_locale_set(PACKAGE_LOCALE_DIR); - // Do this after the above calls, but before changing the working directory, or screwing with argv[0]. - // It tries to set up the package paths depending on where the executable is, so things are relocatable. - // First argument is the elm_main() function that Elementary starts us from. - // Second argument should be a lower case string used as the "domain", which is different from the log domain. - // It's used lower case as part of the data directory path. - // So, if prefix is /usr/local, then the system data dir is /usr/local/share, - // and this apps data dir is /usr/local/share/"domain". - // It's used upper case as part of environment variables to override directory paths at run time. - // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR - // Third argument is the name of a file it can check for to make sure it found the correct path. - // This file is looked for in the data dir. - elm_app_info_set(elm_main, domain, "checkme.txt"); - // Once this is all setup, the code can do - - // elm_app_prefix_dir_get(); // or bin, lib, data, locale. + strncpy(buf, SID, length); + buf[length++] = '.'; + va_start(args, message); + length += vsprintf(&buf[length], message, args); + va_end(args); + buf[length++] = '\n'; + buf[length++] = '\0'; + ecore_con_client_send(client, buf, strlen(buf)); + ecore_con_client_flush(client); +} - getcwd(cwd, PATH_MAX); - env = getenv("LUA_CPATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, elm_app_lib_dir_get(), elm_app_lib_dir_get(), cwd); - setenv("LUA_CPATH", temp, 1); +void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...) +{ + va_list args; + char buf[PATH_MAX]; + int length = strlen(SID); - env = getenv("LUA_PATH"); - if (!env) env = ""; - sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, elm_app_lib_dir_get(), cwd); - setenv("LUA_PATH", temp, 1); + strncpy(buf, SID, length); + buf[length++] = '.'; + va_start(args, message); + length += vsprintf(&buf[length], message, args); + va_end(args); + buf[length++] = '\n'; + buf[length++] = '\0'; + ecore_con_server_send(server, buf, strlen(buf)); + ecore_con_server_flush(server); } 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 @@ /* Enable access to unstable EFL EO API. */ #define EFL_EO_API_SUPPORT 1 -//#include #include -#include +#include #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*array)) - -void HamrTime(void *elm_main, char *domain); +void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...); +void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...); #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 @@ #include "winFang.h" - +void HamrTime(void *elm_main, char *domain) +{ + char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; + + elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); + elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); + elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR); + elm_app_compile_locale_set(PACKAGE_LOCALE_DIR); + // Do this after the above calls, but before changing the working directory, or screwing with argv[0]. + // It tries to set up the package paths depending on where the executable is, so things are relocatable. + // First argument is the elm_main() function that Elementary starts us from. + // Second argument should be a lower case string used as the "domain", which is different from the log domain. + // It's used lower case as part of the data directory path. + // So, if prefix is /usr/local, then the system data dir is /usr/local/share, + // and this apps data dir is /usr/local/share/"domain". + // It's used upper case as part of environment variables to override directory paths at run time. + // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR + // Third argument is the name of a file it can check for to make sure it found the correct path. + // This file is looked for in the data dir. + elm_app_info_set(elm_main, domain, "checkme.txt"); + // Once this is all setup, the code can do - + // elm_app_prefix_dir_get(); // or bin, lib, data, locale. + + getcwd(cwd, PATH_MAX); + env = getenv("LUA_CPATH"); + if (!env) env = ""; + sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, elm_app_lib_dir_get(), elm_app_lib_dir_get(), cwd); + setenv("LUA_CPATH", temp, 1); + + env = getenv("LUA_PATH"); + if (!env) env = ""; + sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, elm_app_lib_dir_get(), cwd); + setenv("LUA_PATH", temp, 1); +} static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { 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 Evas_Smart_Cb on_del; } Widget; +void HamrTime(void *elm_main, char *domain); + winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); void winFangHide(winFang *win); void winFangShow(winFang *win); -- cgit v1.1