diff options
Diffstat (limited to '')
-rw-r--r-- | src/libraries/SledjHamr.c | 57 |
1 files changed, 28 insertions, 29 deletions
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 | ||
3 | void HamrTime(void *elm_main, char *domain) | 3 | void 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); | 20 | void 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 | } |