summaryrefslogtreecommitdiff
path: root/zwgc/browser.c
diff options
context:
space:
mode:
authorGravatar Marc Horowitz <marc@mit.edu>1989-11-01 20:02:01 +0000
committerGravatar Marc Horowitz <marc@mit.edu>1989-11-01 20:02:01 +0000
commitd13d8a046838ce3d0e2643bb5b49f2ff77d679ca (patch)
tree05737bc11e3461836ce817939b9129ed58545ac7 /zwgc/browser.c
parentfd994e4099ad66fb3bf26cd636ca5d5cae72da68 (diff)
Initial revision
Diffstat (limited to 'zwgc/browser.c')
-rw-r--r--zwgc/browser.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/zwgc/browser.c b/zwgc/browser.c
new file mode 100644
index 0000000..c490906
--- /dev/null
+++ b/zwgc/browser.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include "zwgc.h"
+
+static int browser_fd;
+struct sockaddr_un sun;
+
+int BOpenSocket()
+{
+ int fd,len;
+ char *temp;
+
+ if ((fd=socket(PF_UNIX,SOCK_STREAM,0)) == -1)
+ return(-1);
+
+ sun.sun_family=AF_UNIX;
+ if (temp=getenv("WGSOCK"))
+ strncpy(sun.sunpath,temp,sizeof(sun.sunpath));
+ else
+ sprintf(sun.sun_path,"/tmp/.zwgc.%d",getuid());
+ if (bind(fd,(struct sockaddr *) &sun,
+ (len=strlen(sun.sunpath)) > sizeof(sun.sunpath)?
+ sizeof(sun.sunpath):len) == -1) {
+ close(fd);
+ return(-1);
+ }
+
+ if (listen(fd,5) == -1) {
+ unlink(sun.sunpath);
+ close(fd);
+ return(-1);
+ }
+
+ return(fd);
+}