lejp bring into lws

lejp is already in lws as part of lwsws.  However it's too generally useful
to just put directly in lwsws, it will lead to multiple copies of the source
in differet subprojects.

This moves it directly into lws, lwsws now gets it from there.

Like lwsws, by default at cmake it is disabled.  Selecting LWS_WITH_LWSWS now
selects LWS_WITH_LEJP and you can set that at cmake individually as well.

Signed-off-by: Andy Green <andy@warmcat.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf1465b..658b0fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,6 +97,7 @@
 option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions" OFF)
 option(LWS_WITH_ACCESS_LOG "Support generating Apache-compatible access logs" OFF)
 option(LWS_WITH_SERVER_STATUS "Support json + jscript server monitoring" OFF)
+option(LWS_WITH_LEJP "With the Lightweight JSON Parser" OFF)
 
 if (LWS_WITH_LWSWS)
  message(STATUS "LWS_WITH_LWSWS --> Enabling LWS_WITH_PLUGINS and LWS_WITH_LIBUV")
@@ -104,6 +105,7 @@
  set(LWS_WITH_LIBUV 1)
  set(LWS_WITH_ACCESS_LOG 1)
  set(LWS_WITH_SERVER_STATUS 1)
+ set(LWS_WITH_LEJP 1)
 endif()
 
 if (LWS_WITH_PLUGINS AND NOT LWS_WITH_LIBUV)
@@ -576,6 +578,13 @@
 		lib/libuv.c)
 endif()
 
+if (LWS_WITH_LEJP)
+	list(APPEND SOURCES
+		lib/lejp.c)
+	list(APPEND HDR_PUBLIC
+		lib/lejp.h)
+endif()	
+
 # Add helper files for Windows.
 if (WIN32)
 	set(WIN32_HELPERS_PATH win32port/win32helpers)
@@ -1249,7 +1258,6 @@
 if (LWS_WITH_LWSWS)
 		list(APPEND LWSWS_SRCS
 			"lwsws/main.c"
-			"lwsws/lejp.c"
 			"lwsws/conf.c"
 			"lwsws/http.c"
 		)
@@ -1495,6 +1503,7 @@
 message(" PLUGINS = ${PLUGINS_LIST}")
 message(" LWS_WITH_ACCESS_LOG = ${LWS_WITH_ACCESS_LOG}")
 message(" LWS_WITH_SERVER_STATUS = ${LWS_WITH_SERVER_STATUS}")
+message(" LWS_WITH_LEJP = ${LWS_WITH_LEJP}")
 message("---------------------------------------------------------------------")
 
 # These will be available to parent projects including libwebsockets using add_subdirectory()
diff --git a/lwsws/lejp.c b/lib/lejp.c
similarity index 100%
rename from lwsws/lejp.c
rename to lib/lejp.c
diff --git a/lwsws/lejp.h b/lib/lejp.h
similarity index 97%
rename from lwsws/lejp.h
rename to lib/lejp.h
index bbed300..f46acb2 100644
--- a/lwsws/lejp.h
+++ b/lib/lejp.h
@@ -1,4 +1,4 @@
-
+#include "libwebsockets.h"
 struct lejp_ctx;
 
 #ifndef ARRAY_SIZE
@@ -213,20 +213,20 @@
 	unsigned char wildcount;
 };
 
-extern void
+LWS_VISIBLE void
 lejp_construct(struct lejp_ctx *ctx,
 	       char (*callback)(struct lejp_ctx *ctx, char reason), void *user,
 	       const char * const *paths, unsigned char paths_count);
 
-extern void
+LWS_VISIBLE void
 lejp_destruct(struct lejp_ctx *ctx);
 
-extern int
+LWS_VISIBLE int
 lejp_parse(struct lejp_ctx *ctx, const unsigned char *json, int len);
 
-extern void
+LWS_VISIBLE void
 lejp_change_callback(struct lejp_ctx *ctx,
 		       char (*callback)(struct lejp_ctx *ctx, char reason));
 
-extern int
+LWS_VISIBLE int
 lejp_get_wildcard(struct lejp_ctx *ctx, int wildcard, char *dest, int len);
diff --git a/lws_config.h.in b/lws_config.h.in
index 87a0c6d..598969c 100644
--- a/lws_config.h.in
+++ b/lws_config.h.in
@@ -99,4 +99,7 @@
 /* Maximum supported service threads */
 #define LWS_MAX_SMP ${LWS_MAX_SMP}
 
+/* Lightweight JSON Parser */
+#cmakedefine LWS_WITH_LEJP
+
 ${LWS_SIZEOFPTR_CODE}