On 6/27/22 01:28, Waldek Hebisch wrote:
I was thinking more in direction of having something like:
union {
#if defined(HAVE_SOCK_UN)
struct sockaddr_un u_addr;
#endif
struct sockaddr_in i_addr;
and similar in other places using sockaddr_un. And of course
we would need test in 'configure.ac'.
See branch at https://github.com/oldk1331/fricas/commits/fix-socket-unix
Or the following diff.
There can be further refinement, such as adjust "fricas_host_has_socket"
in configure.ac.
- Qian
===================
diff --git a/config/fricas_c_macros.h.in b/config/fricas_c_macros.h.in
index 6fbbd172..04ec5cf8 100644
--- a/config/fricas_c_macros.h.in
+++ b/config/fricas_c_macros.h.in
@@ -115,6 +115,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
+/* Define to 1 if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
+
/* Define to 1 if you have the <sys/wait.h> header file. */
#undef HAVE_SYS_WAIT_H
diff --git a/configure b/configure
index 16d4948f..3704f569 100755
--- a/configure
+++ b/configure
@@ -5089,12 +5089,13 @@ done
fricas_c_runtime_extra="-lwsock32"
;;
*)
- for ac_header in sys/socket.h
+ for ac_header in sys/socket.h sys/un.h
do :
- ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h"
"ac_cv_header_sys_socket_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_socket_h" = xyes; then :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header"
"$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_SOCKET_H 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fricas_host_has_socket=yes
fi
diff --git a/configure.ac b/configure.ac
index 46225a66..bae4b673 100644
--- a/configure.ac
+++ b/configure.ac
@@ -555,7 +555,7 @@ case $host in
fricas_c_runtime_extra="-lwsock32"
;;
*)
- AC_CHECK_HEADERS([sys/socket.h],
+ AC_CHECK_HEADERS([sys/socket.h sys/un.h],
[fricas_host_has_socket=yes],
[])
;;
diff --git a/src/include/com.h b/src/include/com.h
index 465e3a49..0f8f9911 100644
--- a/src/include/com.h
+++ b/src/include/com.h
@@ -69,7 +69,9 @@ typedef struct {
int frame; /* spad interpreter frame (for interpreter
windows) */
fricas_socket remote; /* file descriptor of remote socket */
union {
+ #ifdef HAVE_SYS_UN_H
struct sockaddr_un u_addr;
+ #endif
struct sockaddr_in i_addr;
} addr;
char *host_name; /* name of foreign host if type == AF_INET */
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 2f6a5edb..47f809a0 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -751,6 +751,9 @@ connect_to_local_server(char *server_name, int
purpose, int time_out)
free(sock);
return NULL;
}
+#ifndef HAVE_SYS_UN_H
+ return NULL;
+#else
/* connect socket using name specified in command line */
struct sockaddr_un *uaddr = &(sock->addr.u_addr);
uaddr->sun_family = FRICAS_AF_LOCAL;
@@ -783,6 +786,7 @@ connect_to_local_server(char *server_name, int
purpose, int time_out)
/* fprintf(stderr, "Got int form socket\n"); */
sock->remote = get_int(sock);
return sock;
+#endif
}
/* act as terminal session for sock connected to stdin and stdout of
another
@@ -915,6 +919,10 @@ open_server(char *server_name)
listen(server[0].socket,5);
} */
/* Next create the local domain socket */
+#ifndef HAVE_SYS_UN_H
+ server[1].socket = 0;
+ return -1;
+#else
server[1].socket = fricas_communication_link(FRICAS_AF_LOCAL);
if (is_invalid_socket(&server[1])) {
perror("opening local server socket");
@@ -946,6 +954,7 @@ open_server(char *server_name)
return -1;
}
return 0;
+#endif
}
int
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/0d806c99-3a2c-9fc5-974f-701d152247f1%40gmail.com.