km_bdb_mi.c

Go to the documentation of this file.
00001 /*
00002  * $Id:  $
00003  *
00004  * db_berkeley MI functions
00005  *
00006  * Copyright (C) 2007  Cisco Systems
00007  *
00008  * This file is part of SIP-router, a free SIP server.
00009  *
00010  * SIP-router is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * SIP-router is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2007-11-05  created (wiquan)
00027  */
00028 
00037 #include "../../dprint.h"
00038 #include "../../lib/srdb1/db.h"
00039 #include "km_db_berkeley.h"
00040 #include "km_bdb_mi.h"
00041 
00042 
00043 /*
00044  * MI function to reload db table or env
00045  * expects 1 node: the tablename or dbenv name to reload
00046  */
00047 struct mi_root* mi_bdb_reload(struct mi_root *cmd, void *param)
00048 {
00049         struct mi_node *node;
00050         str *db_path;
00051         
00052         node = cmd->node.kids;
00053         if (node && node->next)
00054                 return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
00055         
00056         db_path = &node->value;
00057         
00058         if (!db_path || db_path->len == 0)
00059                 return init_mi_tree( 400, "bdb_reload missing db arg", 21);
00060 
00061         if (bdb_reload(db_path->s) == 0) 
00062         {
00063                 return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
00064         } 
00065         else 
00066         {
00067                 return init_mi_tree( 500, "db_berkeley Reload Failed", 26);
00068         }
00069 }
00070