km_bdb_mi.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * $Id: $
  3. *
  4. * db_berkeley MI functions
  5. *
  6. * Copyright (C) 2007 Cisco Systems
  7. *
  8. * This file is part of SIP-router, a free SIP server.
  9. *
  10. * SIP-router is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * SIP-router is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * History:
  25. * --------
  26. * 2007-11-05 created (wiquan)
  27. */
  28. /*! \file
  29. * Berkeley DB : Management interface
  30. *
  31. * \ingroup database
  32. */
  33. #include "../../dprint.h"
  34. #include "../../lib/srdb1/db.h"
  35. #include "km_db_berkeley.h"
  36. #include "km_bdb_mi.h"
  37. /*
  38. * MI function to reload db table or env
  39. * expects 1 node: the tablename or dbenv name to reload
  40. */
  41. struct mi_root* mi_bdb_reload(struct mi_root *cmd, void *param)
  42. {
  43. struct mi_node *node;
  44. str *db_path;
  45. node = cmd->node.kids;
  46. if (node && node->next)
  47. return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
  48. db_path = &node->value;
  49. if (!db_path || db_path->len == 0)
  50. return init_mi_tree( 400, "bdb_reload missing db arg", 21);
  51. if (bdb_reload(db_path->s) == 0)
  52. {
  53. return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
  54. }
  55. else
  56. {
  57. return init_mi_tree( 500, "db_berkeley Reload Failed", 26);
  58. }
  59. }