Autodetect if unregister_reply_handler is present
authorMyhailo Danylenko <isbear@ukrpost.net>
Sun, 17 Jan 2010 02:58:44 +0200
changeset 31 afcdbbce5002
parent 30 21547232c875
child 32 493d5d5198c8
Autodetect if unregister_reply_handler is present
CMakeLists.txt
config.h.in
lm_connection.c
--- a/CMakeLists.txt	Sun Jan 17 02:16:30 2010 +0200
+++ b/CMakeLists.txt	Sun Jan 17 02:58:44 2010 +0200
@@ -69,6 +69,7 @@
 set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS})
 set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES})
 check_function_exists(lm_connection_get_keep_alive_rate HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE)
+check_function_exists(lm_connection_unregister_reply_handler HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
 find_package(Perl)
 
 ## Set up compiler
--- a/config.h.in	Sun Jan 17 02:16:30 2010 +0200
+++ b/config.h.in	Sun Jan 17 02:58:44 2010 +0200
@@ -25,6 +25,9 @@
 // define this, if your loudmouth have lm_connection_get_keep_alive_rate ()
 #cmakedefine HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE
 
+// define this, if your loudmouth have lm_connection_unregister_reply_handler ()
+#cmakedefine HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER
+
 #ifdef DEBUG
 #  include <glib.h>
 
--- a/lm_connection.c	Sun Jan 17 02:16:30 2010 +0200
+++ b/lm_connection.c	Sun Jan 17 02:58:44 2010 +0200
@@ -429,13 +429,14 @@
 		}
 		lua_pop (L, 1);
 	} else { // Unregister reply handler
-#if 0
+#ifdef HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER
 		llm_handler_t *handler = luaL_checklm_handler (L, 2);
 		lm_connection_unregister_reply_handler (object -> connection,
 		                                        handler -> handler);
 #else
+		W ("Sorry, your loudmouth have no unregister_reply_handler ()");
 		lua_pushnil (L);
-		lua_pushliteral (L, "Sorry, lm_connection_unregister_reply_handler is not yet supported");
+		lua_pushliteral (L, "Sorry, your loudmouth have no unregister_reply_handler ()");
 		return 2;
 #endif
 	}