wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 6cf39df87b6904b9aa35678fc00cf48d18a5c5af
parent 9fb1c4379c0bc7f6338d4014733fe308d20833e4
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Sat, 21 Jan 2006 19:37:01 +0200

now we use the P9-alike address syntax, ie 'unix!/tmp/bar' for a unix socket file


Diffstat:
libixp2/socket.c | 44++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/libixp2/socket.c b/libixp2/socket.c @@ -16,8 +16,8 @@ #include "cext.h" #include "ixp.h" -int -ixp_connect_sock(char *sockfile) +static int +connect_unix_sock(char *sockfile) { int fd = 0; struct sockaddr_un addr = { 0 }; @@ -38,6 +38,23 @@ ixp_connect_sock(char *sockfile) } int +ixp_connect_sock(char *sockfile) +{ + char *p = strchr(sockfile, '!'); + char *file, *type; + + if(!p) + return -1; + *p = 0; + file = &p[1]; + type = sockfile; /* unix, tcp */ + + if(strncmp(type, "unix", 5)) + return connect_unix_sock(file); + return -1; +} + +int ixp_accept_sock(int fd) { socklen_t su_len; @@ -47,8 +64,8 @@ ixp_accept_sock(int fd) return accept(fd, (struct sockaddr *) &addr, &su_len); } -int -ixp_create_sock(char *sockfile, char **errstr) +static int +create_unix_sock(char *sockfile, char **errstr) { int fd; int yes = 1; @@ -84,3 +101,22 @@ ixp_create_sock(char *sockfile, char **errstr) } return fd; } + +int +ixp_create_sock(char *sockfile, char **errstr) +{ + char *p = strchr(sockfile, '!'); + char *file, *type; + + if(!p) { + *errstr = "no socket type defined"; + return -1; + } + *p = 0; + file = &p[1]; + type = sockfile; /* unix, tcp */ + + if(!strncmp(type, "unix", 5)) + return create_unix_sock(file, errstr); + return -1; +}