ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
platform/agent.h
Go to the documentation of this file.
1#pragma once
2
18#include <stddef.h>
19#include "system.h"
20
21/* ============================================================================
22 * Path Validation Helper Macro
23 * ============================================================================ */
24
35#define VALIDATE_AGENT_PATH(path, path_out, path_size, context) \
36 do { \
37 if (!path || strlen(path) == 0) { \
38 log_debug(context " not set"); \
39 return -1; \
40 } \
41 if (strlen(path) >= path_size) { \
42 log_error(context " path too long"); \
43 return -1; \
44 } \
45 SAFE_STRNCPY(path_out, path, path_size); \
46 return 0; \
47 } while (0)
48
55static inline const char *get_home_or_fallback(const char *env_var, const char *fallback_env) {
56 const char *path = platform_getenv(env_var);
57 if (!path || path[0] == '\0') {
58 path = fallback_env ? platform_getenv(fallback_env) : NULL;
59 }
60 return path;
61}
62
73int platform_get_ssh_agent_socket(char *path_out, size_t path_size);
74
86int platform_get_gpg_agent_socket(char *path_out, size_t path_size);
87
int platform_get_gpg_agent_socket(char *path_out, size_t path_size)
const char * platform_getenv(const char *name)
Get an environment variable value.
Definition wasm/system.c:39
int platform_get_ssh_agent_socket(char *path_out, size_t path_size)
Cross-platform system functions interface for ascii-chat.