restructure and additions to IPC
This commit is contained in:
parent
cd290f0d2b
commit
58844384f2
2 changed files with 94 additions and 109 deletions
28
terminkey.h
28
terminkey.h
|
|
@ -37,7 +37,6 @@ int ipc_init();
|
|||
int ipc_check_message(uintptr_t buffer_ptr, int max_len);
|
||||
void ipc_send_message(const char* message);
|
||||
void ipc_cleanup();
|
||||
void get_absolute_path(const char* rel_path, uintptr_t abs_path_ptr, int max_len);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
|
@ -195,11 +194,6 @@ void ipc_cleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
void get_absolute_path(const char* rel_path, uintptr_t abs_path_ptr, int max_len) {
|
||||
char* abs_path = (char*)abs_path_ptr;
|
||||
_fullpath(abs_path, rel_path, max_len);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int server_fd = -1;
|
||||
|
|
@ -369,26 +363,4 @@ void ipc_cleanup() {
|
|||
unlink(socket_path);
|
||||
}
|
||||
|
||||
void get_absolute_path(const char* rel_path, uintptr_t abs_path_ptr, int max_len) {
|
||||
char* abs_path = (char*)abs_path_ptr;
|
||||
char resolved[PATH_MAX];
|
||||
if (realpath(rel_path, resolved) != NULL) {
|
||||
strncpy(abs_path, resolved, max_len);
|
||||
abs_path[max_len - 1] = '\0';
|
||||
} else {
|
||||
if (rel_path[0] == '/') {
|
||||
strncpy(abs_path, rel_path, max_len);
|
||||
abs_path[max_len - 1] = '\0';
|
||||
} else {
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
snprintf(abs_path, max_len, "%s/%s", cwd, rel_path);
|
||||
} else {
|
||||
strncpy(abs_path, rel_path, max_len);
|
||||
abs_path[max_len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue