db_mod.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * $Id$
  3. *
  4. * Postgres module interface
  5. *
  6. * Portions Copyright (C) 2001-2003 FhG FOKUS
  7. * Copyright (C) 2003 August.Net Services, LLC
  8. * Portions Copyright (C) 2005 iptelorg GmbH
  9. *
  10. * This file is part of ser, a free SIP server.
  11. *
  12. * ser is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version
  16. *
  17. * For a license to use the ser software under conditions
  18. * other than those described here, or to purchase support for this
  19. * software, please contact iptel.org by e-mail at the following addresses:
  20. * [email protected]
  21. *
  22. * ser is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  30. */
  31. #include <stdio.h>
  32. #include "../../sr_module.h"
  33. #include "dbase.h"
  34. MODULE_VERSION
  35. int connect_timeout = 0; /* Default is unlimited */
  36. int reconnect_attempts = 2; /* How many times should the module try to reconnect if
  37. * the connection is lost. 0 disables reconnecting */
  38. /*
  39. * Postgres database module interface
  40. */
  41. static cmd_export_t cmds[]={
  42. {"db_use_table", (cmd_function)use_table, 2, 0, 0},
  43. {"db_init", (cmd_function)db_init, 1, 0, 0},
  44. {"db_close", (cmd_function)db_close, 2, 0, 0},
  45. {"db_query", (cmd_function)db_query, 2, 0, 0},
  46. {"db_raw_query", (cmd_function)db_raw_query, 2, 0, 0},
  47. {"db_free_result", (cmd_function)db_free_result, 2, 0, 0},
  48. {"db_insert", (cmd_function)db_insert, 2, 0, 0},
  49. {"db_delete", (cmd_function)db_delete, 2, 0, 0},
  50. {"db_update", (cmd_function)db_update, 2, 0, 0},
  51. {0, 0, 0, 0, 0}
  52. };
  53. /*
  54. * Exported parameters
  55. */
  56. static param_export_t params[] = {
  57. {"connect_timeout", INT_PARAM, &connect_timeout },
  58. {"reconnect_attempts", INT_PARAM, &reconnect_attempts},
  59. {0, 0, 0}
  60. };
  61. struct module_exports exports = {
  62. "postgres",
  63. cmds,
  64. 0, /* RPC methods */
  65. params, /* module parameters */
  66. 0, /* module initialization function */
  67. 0, /* response function*/
  68. 0, /* destroy function */
  69. 0, /* oncancel function */
  70. 0 /* per-child init function */
  71. };