mirror of
https://github.com/0intro/wmii
synced 2025-01-20 17:19:21 +03:00
now we use the P9-alike address syntax, ie 'unix!/tmp/bar' for a unix socket file
This commit is contained in:
parent
9fb1c4379c
commit
6cf39df87b
@ -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 };
|
||||
@ -37,6 +37,23 @@ ixp_connect_sock(char *sockfile)
|
||||
return fd;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user