Add a config.h parameter for base TMPDIR

This commit is contained in:
augustin64 2023-11-28 10:00:29 +01:00
parent fec4fd0e22
commit 6ebadf1d23
2 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,11 @@
#ifndef DEF_CONFIG_H #ifndef DEF_CONFIG_H
#define DEF_CONFIG_H #define DEF_CONFIG_H
#define VERSION "1.3.4" #define VERSION "1.3.5"
#define MAX_TASK_ID 10000 // max is set to MAX_TASK_ID-1 #define MAX_TASK_ID 10000 // max is set to MAX_TASK_ID-1
#define NEW_TASK_ID_MAX_RETRIES 10000 // number of retries before giving up #define NEW_TASK_ID_MAX_RETRIES 10000 // number of retries before giving up
#define TMPDIR "/tmp" // Some Unix systems don't use /tmp as tmp dir (eg Android)
#endif #endif

View File

@ -19,9 +19,12 @@ char* get_socket_path() {
return socket_path; return socket_path;
} else { } else {
char* base_path = "/tmp/takl"; char* base_path = TMPDIR "/takl";
char* username = getenv("USER"); char* username = getenv("USER");
if (!username)
username = getenv("USERNAME");
assert(username != NULL); assert(username != NULL);
char* socket_path = malloc(sizeof(char)*(strlen(base_path)+strlen(username)+1)); char* socket_path = malloc(sizeof(char)*(strlen(base_path)+strlen(username)+1));