diff --git a/Makefile.am b/Makefile.am index ce7f92bdd2d856b5de59f60b4aa7a0df0a2a711d..28a04bb83a99847fc18e405d3ae7f0184eff6f6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,3 +10,4 @@ EXTRA_DIST=scripts/kernel-doc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libwebsockets.pc + diff --git a/changelog b/changelog index c865021e0175014bc10aeeead90b38394ccccb54..8e559c13b1cafbd4f3e8654aca7fc926f9583ab9 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,17 @@ Changelog --------- +(development since 1.1....) + +User api additions +------------------ + + - lws_get_library_version() returns a const char * with a string like + "1.1 9e7f737", representing the library version from configure.ac + and the git HEAD hash the library was built from + + + v1.1-chrome26-firefox18 ======================= diff --git a/configure.ac b/configure.ac index a96bd28dd4727d13fcadaa5a1abda769933c778c..175ea873c41e8941130db7db22f46b664d5baa56 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.61]) -AC_INIT(libwebsockets, 1.1, andy@warmcat.com) +AC_INIT(libwebsockets, 1.1, andy@warmcat.com, libwebsockets, http://libwebsockets.org) AC_CONFIG_SRCDIR([test-server/test-server.c]) AC_CONFIG_HEADERS([config.h]) @@ -18,6 +18,10 @@ AC_PROG_INSTALL AC_PROG_MAKE_SET AC_CONFIG_MACRO_DIR([m4]) +applyhash='CFLAGS+= -DLWS_LIBRARY_VERSION=\"$(PACKAGE_VERSION)\" -DLWS_BUILD_HASH=\"${shell git log -n 1 --pretty=%h}\"' +AC_SUBST([applyhash]) +AM_SUBST_NOTMAKE([applyhash]) + # # # diff --git a/lib/Makefile.am b/lib/Makefile.am index f5cdf3c36402378e4a6db697d670fe3f31699423..3a51c1accb3f95c9454bef503f1838773cade8a9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,3 +1,5 @@ +@applyhash@ + lib_LTLIBRARIES=libwebsockets.la include_HEADERS=libwebsockets.h dist_libwebsockets_la_SOURCES=libwebsockets.c \ @@ -42,7 +44,7 @@ else dist_libwebsockets_la_SOURCES += sha-1.c endif -libwebsockets_la_CFLAGS=-Wall -std=gnu99 -pedantic -g +libwebsockets_la_CFLAGS=-Wall -std=gnu99 -pedantic libwebsockets_la_LDFLAGS= if DISABLE_DEBUG diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 75302d0d4c5ddeade33aa324c08b42bf53619fb7..4ed528a33fe3ca01bd17acfbfde43d161c368026 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -48,11 +48,16 @@ int openssl_websocket_private_data_index; #endif #endif +#ifndef LWS_BUILD_HASH +#define LWS_BUILD_HASH "unknown-build-hash" +#endif static int log_level = LLL_ERR | LLL_WARN | LLL_NOTICE; static void lwsl_emit_stderr(int level, const char *line); static void (*lwsl_emit)(int level, const char *line) = lwsl_emit_stderr; +static const char *library_version = LWS_LIBRARY_VERSION " " LWS_BUILD_HASH; + static const char *log_level_names[] = { "ERR", "WARN", @@ -66,6 +71,20 @@ static const char *log_level_names[] = { "LATENCY", }; +/** + * lws_get_library_version: get version and git hash library built from + * + * returns a const char * to a string like "1.1 178d78c" + * representing the library version followed by the git head hash it + * was built from + */ + +const char * +lws_get_library_version(void) +{ + return library_version; +} + int insert_wsi_socket_into_fds(struct libwebsocket_context *context, struct libwebsocket *wsi) { @@ -1492,6 +1511,7 @@ libwebsocket_create_context(int port, const char *interf, #endif lwsl_notice("Initial logging level %d\n", log_level); + lwsl_notice("Library version: %s\n", library_version); lwsl_info(" LWS_MAX_HEADER_NAME_LENGTH: %u\n", LWS_MAX_HEADER_NAME_LENGTH); lwsl_info(" LWS_MAX_HEADER_LEN: %u\n", LWS_MAX_HEADER_LEN); lwsl_info(" LWS_INITIAL_HDR_ALLOC: %u\n", LWS_INITIAL_HDR_ALLOC); diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 4acabcd1fc53ce8597248770f5ff4c23470a6522..f5544b194e791dd5efe413774bc5ff8f8f294c99 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1,7 +1,7 @@ /* * libwebsockets - small server side websockets and web server implementation * - * Copyright (C) 2010 Andy Green <andy@warmcat.com> + * Copyright (C) 2010-2013 Andy Green <andy@warmcat.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -868,6 +868,9 @@ lws_b64_encode_string(const char *in, int in_len, char *out, int out_size); LWS_EXTERN int lws_b64_decode_string(const char *in, char *out, int out_size); +LWS_EXTERN const char * +lws_get_library_version(void); + /* * Note: this is not normally needed as a user api. It's provided in case it is * useful when integrating with other app poll loop service code. diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 46fe49acf6f60161be691c32e00e32bdae2437e2..e6b424fccb9ef8f90282c52bfb79bf1720f7b973 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -85,6 +85,23 @@ protocol supported, or the specific protocol ordinal This function creates a connection to a remote server </blockquote> <hr> +<h2>lws_get_library_version - </h2> +<i>const char *</i> +<b>lws_get_library_version</b> +(<i></i> <b>void</b>) +<h3>Arguments</h3> +<dl> +<dt><b>void</b> +<dd>no arguments +</dl> +<h3>Description</h3> +<blockquote> +<p> +returns a const char * to a string like "1.1 178d78c" +representing the library version followed by the git head hash it +was built from +</blockquote> +<hr> <h2>libwebsockets_hangup_on_client - Server calls to terminate client connection</h2> <i>void</i> <b>libwebsockets_hangup_on_client</b>