[Domterm-discuss] Installing on Macos possible?

Per Bothner per at bothner.com
Tue Jun 26 13:07:45 PDT 2018


On 06/26/2018 12:40 PM, hak wrote:

> 
> protocol.c:391:17: warning: implicit declaration of function 'execvpe' is invalid in C99 [-Wimplicit-function-declaration]
>              if (execvpe(argv[0], argv, nenv) < 0) {
>                  ^
> protocol.c:497:27: error: use of undeclared identifier 'HOST_NAME_MAX'
>                  char hbuf[HOST_NAME_MAX+1];
>                            ^
> protocol.c:1082:32: warning: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
>               && lws_write(wsi, p0, written, LWS_WRITE_BINARY) != written)
>                                 ^~
> /usr/local/Cellar/libwebsockets/2.4.2_2/include/libwebsockets.h:4185:43: note: passing argument to parameter 'buf' here
> lws_write(struct lws *wsi, unsigned char *buf, size_t len,
>                                            ^
> protocol.c:1437:26: warning: implicit declaration of function 'accept4' is invalid in C99 [-Wimplicit-function-declaration]
>              int sockfd = accept4(socket, &sa, &slen, SOCK_CLOEXEC);
>                           ^
> protocol.c:1437:54: error: use of undeclared identifier 'SOCK_CLOEXEC'
>              int sockfd = accept4(socket, &sa, &slen, SOCK_CLOEXEC);
>                                                       ^
> 3 warnings and 2 errors generated.
> make[2]: *** [ldomterm-protocol.o] Error 1

The attached patch should hopefully fix the errors.

(I'm looking into an alternate for for missing HOST_MAX_LEN.)

After everything compiles, I expect we may linker errors,
if for example execvpe is truly missing.

-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/
-------------- next part --------------
diff --git a/lws-term/protocol.c b/lws-term/protocol.c
index d7204c6..a0e2c3a 100644
--- a/lws-term/protocol.c
+++ b/lws-term/protocol.c
@@ -494,6 +494,9 @@ check_template(const char *template, json_object *obj)
                 && strncmp(filename+2, localhost_localdomain, fhlen) == 0)
                 filename = filename + 2 + fhlen;
             else {
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 128
+#endif
                 char hbuf[HOST_NAME_MAX+1];
                 int r = gethostname(hbuf, sizeof(hbuf));
                 if (r != 0)
@@ -1434,7 +1437,11 @@ callback_cmd(struct lws *wsi, enum lws_callback_reasons reason,
             struct sockaddr sa;
             socklen_t slen = sizeof sa;
             //int sockfd = accept(socket, &sa, &slen);
+#ifdef SOCK_CLOEXEC
             int sockfd = accept4(socket, &sa, &slen, SOCK_CLOEXEC);
+#else
+            int sockfd = accept(socket, &sa, &slen);
+#endif
             size_t jblen = 512;
             char *jbuf = xmalloc(jblen);
             int jpos = 0;


More information about the Domterm-discuss mailing list