New module loading scheme
authorMyhailo Danylenko <isbear@ukrpost.net>
Thu, 04 Mar 2010 19:54:57 +0200
changeset 5 c403a516dc04
parent 4 b4b586665a8f
child 6 2cc481d6b686
New module loading scheme
CMakeLists.txt
TODO
templatecmd.c
templatecmd.rc
--- a/CMakeLists.txt	Mon Feb 15 19:24:10 2010 +0200
+++ b/CMakeLists.txt	Thu Mar 04 19:54:57 2010 +0200
@@ -22,10 +22,8 @@
 ## Check for build dependencies
 find_package(PkgConfig REQUIRED) 
 pkg_check_modules(GLIB REQUIRED glib-2.0) 
-pkg_check_modules(GMODULE REQUIRED gmodule-2.0) 
 pkg_check_modules(MCABBER REQUIRED mcabber)
 link_directories(${GLIB_LIBRARY_DIRS}
-				 ${GMODULE_LIBRARY_DIRS}
 				 ${MCABBER_LIBRARY_DIRS})
 
 ## Target definitions
@@ -33,10 +31,8 @@
 
 ## Compiler setup
 include_directories(SYSTEM ${GLIB_INCLUDE_DIRS} 
-                    ${GMODULE_INCLUDE_DIRS}
                     ${MCABBER_INCLUDE_DIRS})
 target_link_libraries(templatecmd ${GLIB_LIBRARIES} 
-                      ${GMODULE_LIBRARIES}
 					  ${MCABBER_LIBRARIES})
 include_directories(${templatecmd_SOURCE_DIR} 
                     ${templatecmd_BINARY_DIR})
--- a/TODO	Mon Feb 15 19:24:10 2010 +0200
+++ b/TODO	Thu Mar 04 19:54:57 2010 +0200
@@ -1,3 +1,4 @@
 
 some way to set up commands at startup
+double-free lurks in module uninitialization
 
--- a/templatecmd.c	Mon Feb 15 19:24:10 2010 +0200
+++ b/templatecmd.c	Thu Mar 04 19:54:57 2010 +0200
@@ -17,7 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <glib.h>
-#include <gmodule.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -25,6 +24,17 @@
 #include <mcabber/commands.h>
 #include <mcabber/utils.h>
 #include <mcabber/logprint.h>
+#include <mcabber/modules.h>
+
+static void tcmd_init (void);
+static void tcmd_uninit (void);
+
+module_info_t info_templatecmd = {
+	.mcabber_version = "0.10.0",
+	.requires        = NULL,
+	.init            = tcmd_init,
+	.uninit          = tcmd_uninit,
+};
 
 typedef struct {
 	gchar    *name;
@@ -187,14 +197,12 @@
 }
 
 
-const gchar *g_module_check_init (GModule *module)
+static void tcmd_init (void)
 {
 	cmd_add ("templatecmd", "", COMPL_CMD, COMPL_CMD, do_templatecmd, NULL);
-
-	return NULL;
 }
 
-void g_module_unload (GModule *module)
+static void tcmd_uninit (void)
 {
 	GSList *tel;
 
--- a/templatecmd.rc	Mon Feb 15 19:24:10 2010 +0200
+++ b/templatecmd.rc	Thu Mar 04 19:54:57 2010 +0200
@@ -1,3 +1,3 @@
 
-load templatecmd
+module load templatecmd