commit 51e1986236a09dc59ed6da549b2bfe8b3b64332c
parent 55d3010c84310eea0031f7e353eab37ccf833a0b
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Fri, 21 May 2021 21:21:06 -0700
Accept socket path from the environment
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/apcon.c b/apcon.c
@@ -26,11 +26,22 @@
#include "config.h"
#include "sock.h"
+char *
+apcon_getpath(char *path)
+{
+ if (path == NULL) {
+ path = getenv("APSOCK");
+ if (path == NULL)
+ path = "/tmp/aps";
+ }
+ return strdup(path);
+}
+
int
apcon_open(struct apcon *apc, char *path,
int (*init)(int, const struct sockaddr *, socklen_t), int flags)
{
- apc->path = strdup(path ? path : address);
+ apc->path = apcon_getpath(path);
if (apc->path == NULL)
return 1;
diff --git a/config.def.h b/config.def.h
@@ -1,5 +1,3 @@
-static char *address = "/tmp/aps";
-
static char *player[] = {
/* "" = path */
/* prog, arg, ... */