Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake, sa: enable unix sockets, if HAVE_UNIXSOCK is undefined #636

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmake/re-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ endif()

if(USE_UNIXSOCK)
list(APPEND RE_DEFINITIONS
-DHAVE_UNIXSOCK
-DHAVE_UNIXSOCK=1
)
else()
list(APPEND RE_DEFINITIONS
-DHAVE_UNIXSOCK=0
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion include/re_sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct sa {
union {
struct sockaddr sa;
struct sockaddr_in in;
#ifdef HAVE_UNIXSOCK
#if !defined(HAVE_UNIXSOCK) || HAVE_UNIXSOCK == 1
struct sockaddr_un un;
#endif
#ifdef HAVE_INET6
Expand Down
10 changes: 5 additions & 5 deletions src/sa/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int sa_pton(const char *addr, struct sa *sa)
if (inet_pton(AF_INET, addr, &sa->u.in.sin_addr) > 0) {
sa->u.in.sin_family = AF_INET;
}
#ifdef HAVE_UNIXSOCK
#if HAVE_UNIXSOCK == 1
else if (!strncmp(addr, "unix:", 5)) {
sa->u.un.sun_family = AF_UNIX;
str_ncpy(sa->u.un.sun_path, addr + 5,
Expand Down Expand Up @@ -161,7 +161,7 @@ int sa_set_str(struct sa *sa, const char *addr, uint16_t port)

switch (sa->u.sa.sa_family) {

#ifdef HAVE_UNIXSOCK
#if HAVE_UNIXSOCK == 1
case AF_UNIX:
sa->len = sizeof(struct sockaddr_un);
break;
Expand Down Expand Up @@ -416,7 +416,7 @@ int sa_ntop(const struct sa *sa, char *buf, int size)
return EINVAL;

switch (sa->u.sa.sa_family) {
#ifdef HAVE_UNIXSOCK
#if HAVE_UNIXSOCK == 1
case AF_UNIX:
str_ncpy(buf, sa->u.un.sun_path, size);
ret = buf;
Expand Down Expand Up @@ -487,7 +487,7 @@ bool sa_isset(const struct sa *sa, int flag)

switch (sa->u.sa.sa_family) {

#ifdef HAVE_UNIXSOCK
#if HAVE_UNIXSOCK == 1
case AF_UNIX:
return str_isset(sa->u.un.sun_path);
break;
Expand Down Expand Up @@ -602,7 +602,7 @@ bool sa_cmp(const struct sa *l, const struct sa *r, int flag)

switch (l->u.sa.sa_family) {

#ifdef HAVE_UNIXSOCK
#if HAVE_UNIXSOCK == 1
case AF_UNIX:
if (0 == str_cmp(l->u.un.sun_path, r->u.un.sun_path))
return true;
Expand Down