Browse Source

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

Ovidiu Sas 12 years ago
parent
commit
928dab6960

+ 1 - 1
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

+ 0 - 41
modules/db_flatstore/km_flat_mi.c

@@ -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;
-}

+ 0 - 35
modules/db_flatstore/km_flat_mi.h

@@ -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_ */
-

+ 22 - 13
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},
+};
+