summaryrefslogtreecommitdiff
path: root/lib/ZGetWGPort.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ZGetWGPort.c')
-rw-r--r--lib/ZGetWGPort.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/ZGetWGPort.c b/lib/ZGetWGPort.c
new file mode 100644
index 0000000..fbbff1f
--- /dev/null
+++ b/lib/ZGetWGPort.c
@@ -0,0 +1,40 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains source for the ZGetWGPort function.
+ *
+ * Created by: Robert French
+ *
+ * $Source$
+ * $Author$
+ *
+ * Copyright (c) 1987 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * "mit-copyright.h".
+ */
+/* $Header$ */
+
+#ifndef lint
+static char rcsid_ZGetWGPort_c[] = "$Header$";
+#endif lint
+
+#include <zephyr/mit-copyright.h>
+
+#include <zephyr/zephyr_internal.h>
+
+int ZGetWGPort()
+{
+ char *envptr,name[128];
+ FILE *fp;
+ int wgport;
+
+ envptr = (char *)getenv("WGFILE");
+ if (!envptr) {
+ sprintf(name,"/tmp/wg.%d",getuid());
+ envptr = name;
+ }
+ if (!(fp = fopen(envptr,"r")))
+ return (-1);
+ fscanf(fp,"%d",&wgport);
+ fclose(fp);
+
+ return (wgport);
+}