aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-10-28 00:48:14 +0100
committerubq323 <ubq323@ubq323.website>2022-10-28 00:49:31 +0100
commit7a17c3a4ea869a04041ff2568fd02ec676ab8dff (patch)
treea2ff40bfcae165d294344adcb941d03b535b7f90 /common.c
parent705db03ebffa24b993f72ca2694ba0982fa80bde (diff)
large refactor continues
Diffstat (limited to 'common.c')
-rw-r--r--common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/common.c b/common.c
new file mode 100644
index 0000000..f217001
--- /dev/null
+++ b/common.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <string.h>
+
+
+#define SOCKDIR "/run/apionet"
+
+int
+channel_socket_path(char chname[], char out[], size_t lim)
+{
+ if (strlen(chname) > 16) return -1;
+ if (snprintf(out, lim, SOCKDIR "/apionet.%s.sock", chname) >= lim)
+ return -1;
+ return 0;
+}
+
+char *channels[] = {
+ "a","b","robots","jonathan","secret-channel",NULL,
+};
+
+int
+main()
+{
+ char b[200];
+ for (int i = 0; channels[i]; i++) {
+ memset(b,0,200);
+ channel_socket_path(channels[i], b, 200);
+ printf("%s\n",b);
+ }
+ return 0;
+}
+