[sr-dev] git:master: modules/db_flatstore: replace mi command flat_rotate with rpc command flatstore.k_rotate

Ovidiu Sas osas at voipembedded.com
Mon Dec 17 21:13:52 CET 2012


Module: sip-router
Branch: master
Commit: 928dab69601e1bb56e3abbc81a1ed55d77e8b298
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=928dab69601e1bb56e3abbc81a1ed55d77e8b298

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Mon Dec 17 15:06:49 2012 -0500

modules/db_flatstore: replace mi command flat_rotate with rpc command flatstore.k_rotate

---

 modules/db_flatstore/Makefile           |    2 +-
 modules/db_flatstore/km_flat_mi.c       |   41 -------------------------------
 modules/db_flatstore/km_flat_mi.h       |   35 --------------------------
 modules/db_flatstore/km_flatstore_mod.c |   35 ++++++++++++++++----------
 4 files changed, 23 insertions(+), 90 deletions(-)

diff --git a/modules/db_flatstore/Makefile b/modules/db_flatstore/Makefile
index 5b063bc..6b008b2 100644
--- a/modules/db_flatstore/Makefile
+++ b/modules/db_flatstore/Makefile
@@ -10,6 +10,6 @@ LIBS=
 DEFS += -DSER_MOD_INTERFACE
 
 SERLIBPATH=../../lib
-SER_LIBS=$(SERLIBPATH)/srdb2/srdb2 $(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kmi/kmi
+SER_LIBS=$(SERLIBPATH)/srdb2/srdb2 $(SERLIBPATH)/srdb1/srdb1
 
 include ../../Makefile.modules
diff --git a/modules/db_flatstore/km_flat_mi.c b/modules/db_flatstore/km_flat_mi.c
deleted file mode 100644
index 2200148..0000000
--- a/modules/db_flatstore/km_flat_mi.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* 
- * $Id$ 
- *
- * Flatstore module MI interface
- *
- * Copyright (C) 2006 Voice Sistem SRL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "flatstore_mod.h"
-#include "km_flatstore_mod.h"
-#include "km_flat_mi.h"
-
-
-struct mi_root*  mi_flat_rotate_cmd(struct mi_root* cmd_tree, void* param)
-{
-	struct mi_root *rpl_tree;
-
-	rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
-	if(rpl_tree == NULL)
-		return rpl_tree;
-
-	*km_flat_rotate = time(0);
-
-	return rpl_tree;
-}
diff --git a/modules/db_flatstore/km_flat_mi.h b/modules/db_flatstore/km_flat_mi.h
deleted file mode 100644
index 6dbfc33..0000000
--- a/modules/db_flatstore/km_flat_mi.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * $Id$ 
- *
- * Flatstore module MI interface
- *
- * Copyright (C) 2006 Voice Sistem RL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _KM_FLAT_MI_H_
-#define _KM_FLAT_MI_H_
-
-#include "../../lib/kmi/mi.h"
-
-#define MI_FLAT_ROTATE "flat_rotate"
-
-struct mi_root*  mi_flat_rotate_cmd(struct mi_root* cmd, void* param);
-
-#endif /* _KM_FLAT_MI_H_ */
-
diff --git a/modules/db_flatstore/km_flatstore_mod.c b/modules/db_flatstore/km_flatstore_mod.c
index 5f377a0..41b6775 100644
--- a/modules/db_flatstore/km_flatstore_mod.c
+++ b/modules/db_flatstore/km_flatstore_mod.c
@@ -30,8 +30,8 @@
 #include "../../sr_module.h"
 #include "../../mem/shm_mem.h"
 #include "../../lib/srdb1/db.h"
+#include "../../rpc_lookup.h"
 #include "km_flatstore.h"
-#include "km_flat_mi.h"
 #include "km_flatstore_mod.h"
 #include "flatstore_mod.h"
 
@@ -74,14 +74,7 @@ static param_export_t params[] = {
 	{0, 0, 0}
 };
 
-
-/*
- * Exported parameters
- */
-static mi_export_t mi_cmds[] = {
-	{ MI_FLAT_ROTATE, mi_flat_rotate_cmd,   MI_NO_INPUT_FLAG,  0,  0 },
-	{ 0, 0, 0, 0, 0}
-};
+static rpc_export_t k_rpc_methods[];
 
 struct kam_module_exports km_exports = {
 	"db_flatstore",
@@ -89,7 +82,7 @@ struct kam_module_exports km_exports = {
 	cmds,
 	params,      /*  module parameters */
 	0,           /* exported statistics */
-	mi_cmds,     /* exported MI functions */
+	NULL,       /* exported MI functions */
 	0,           /* exported pseudo-variables */
 	0,           /* extra processes */
 	km_mod_init,    /* module initialization function */
@@ -101,9 +94,8 @@ struct kam_module_exports km_exports = {
 
 int km_mod_init(void)
 {
-	if(register_mi_mod(km_exports.name, mi_cmds)!=0)
-	{
-		LM_ERR("failed to register MI commands\n");
+	if (rpc_register_array(k_rpc_methods)!=0) {
+		LM_ERR("failed to register RPC commands\n");
 		return -1;
 	}
 
@@ -156,3 +148,20 @@ int db_flat_bind_api(db_func_t *dbb)
 	return 0;
 }
 
+/* rpc function documentation */
+static const char *rpc_k_rotate_doc[2] = {
+	"Close and reopen flatrotate files during log rotation.", 0
+};
+
+/* rpc function implementations */
+static void rpc_k_rotate(rpc_t *rpc, void *c)
+{
+	*km_flat_rotate = time(0);
+	return;
+}
+
+static rpc_export_t k_rpc_methods[] = {
+	{"flatstore.k_rotate", rpc_k_rotate, rpc_k_rotate_doc, 0},
+	{0, 0, 0, 0},
+};
+




More information about the sr-dev mailing list