]> git.0d.be Git - jackwsmeter.git/commitdiff
build and run against libwebsockets 1.3
authorFrédéric Péters <fpeters@0d.be>
Mon, 14 Jul 2014 11:43:08 +0000 (13:43 +0200)
committerFrédéric Péters <fpeters@0d.be>
Mon, 14 Jul 2014 11:43:08 +0000 (13:43 +0200)
NEWS
configure.ac
jackwsmeter.c

diff --git a/NEWS b/NEWS
index 952a52611bacf3f9b4c06c6747bd6578d0bf481e..1e20d916602547a28c5075df098a48e7ee18083a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
 =========
-Version 1
+Version 2 (unreleased)
+=========
+
+ - Build and run against libwebsockets 1.3
+
+=========
+Version 1 (2014-07-05)
 =========
 
 Initial release.
index afefd5435eb31623fe7fbbf653746f5ec1b9f710..1e4bafbe531bea8c69fcdafecc928581dc46a6ee 100644 (file)
@@ -13,6 +13,9 @@ PKG_CHECK_MODULES(WEBSOCKETS, libwebsockets)
 AC_CHECK_LIB(websockets, lws_daemonize, [true], [AC_DEFINE(LWS_NO_DAEMONIZE)])
 AC_CHECK_LIB(websockets, libwebsocket_get_internal_extensions, [true], [AC_DEFINE(LWS_NO_EXTENSIONS)])
 
+PKG_CHECK_EXISTS(libwebsockets >= 1.2, [AC_DEFINE(LWS_12)], [])
+PKG_CHECK_EXISTS(libwebsockets >= 1.3, [AC_DEFINE(LWS_13)], [])
+
 PKG_CHECK_MODULES(JACK, jack >= 0.100.0)
 AC_SUBST(JACK_CFLAGS)
 AC_SUBST(JACK_LIBS)
index 4be8556055840d84fbe5f5d7716bab79990646eb..7b728d602327ddadf874c55ca2de55a53fd5d077 100644 (file)
@@ -77,8 +77,12 @@ static int callback_http(struct libwebsocket_context *context,
                                                           void *in, size_t len)
 {
        int m;
-       int fd = (int)(long)user;
        char *html_filepath;
+#ifdef LWS_13
+       struct libwebsocket_pollargs *pa = (struct libwebsocket_pollargs *)in;
+#else
+       int fd = (int)(long)user;
+#endif
 
        switch (reason) {
        case LWS_CALLBACK_HTTP:
@@ -89,7 +93,11 @@ static int callback_http(struct libwebsocket_context *context,
                         * on the current directory. */
                        strcpy(html_filepath, "jackwsmeter.html");
                }
+#ifdef LWS_13
+               if (libwebsockets_serve_http_file(context, wsi, html_filepath, "text/html", NULL)) {
+#else
                if (libwebsockets_serve_http_file(context, wsi, html_filepath, "text/html")) {
+#endif
                        free(html_filepath);
                        return 1; /* through completion or error, close the socket */
                }
@@ -107,21 +115,36 @@ static int callback_http(struct libwebsocket_context *context,
                        return 1;
                }
 
+#ifdef LWS_13
+               fd_lookup[pa->fd] = count_pollfds;
+               pollfds[count_pollfds].fd = pa->fd;
+               pollfds[count_pollfds].events = pa->events;
+#else
                fd_lookup[fd] = count_pollfds;
                pollfds[count_pollfds].fd = fd;
                pollfds[count_pollfds].events = (int)(long)len;
+#endif
                pollfds[count_pollfds++].revents = 0;
                break;
 
        case LWS_CALLBACK_DEL_POLL_FD:
                if (!--count_pollfds)
                        break;
+#ifdef LWS_13
+               m = fd_lookup[pa->fd];
+#else
                m = fd_lookup[fd];
+#endif
                /* have the last guy take up the vacant slot */
                pollfds[m] = pollfds[count_pollfds];
                fd_lookup[pollfds[count_pollfds].fd] = m;
                break;
 
+#ifdef LWS_13
+       case LWS_CALLBACK_CHANGE_MODE_POLL_FD:
+               pollfds[fd_lookup[pa->fd]].events = pa->events;
+               break;
+#else
        case LWS_CALLBACK_SET_MODE_POLL_FD:
                pollfds[fd_lookup[fd]].events |= (int)(long)len;
                break;
@@ -129,6 +152,7 @@ static int callback_http(struct libwebsocket_context *context,
        case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
                pollfds[fd_lookup[fd]].events &= ~(int)(long)len;
                break;
+#endif
 
        default:
                break;