con_postgres.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * $Id$
  3. *
  4. * POSTGRES module, portions of this code were templated using
  5. * the mysql module, thus it's similarity.
  6. *
  7. *
  8. * Copyright (C) 2003 August.Net Services, LLC
  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. * ---
  32. *
  33. * History
  34. * -------
  35. * 2003-04-06 initial code written (Greg Fausak/Andy Fullford)
  36. *
  37. */
  38. #ifndef CON_POSTGRES_H
  39. #define CON_POSTGRES_H
  40. #include "libpq-fe.h"
  41. /*
  42. * Postgres specific connection data
  43. */
  44. struct con_postgres {
  45. int connected;
  46. char *sqlurl; /* the url we are connected to, all connection memory
  47. parents from this */
  48. PGconn *con; /* this is the postgres connection */
  49. PGresult *res; /* this is the current result */
  50. FILE *fp; /* debug file output */
  51. long tpid; /* record pid of database opener in case one of */
  52. /* the children try to close the database */
  53. };
  54. #define CON_SQLURL(db_con) (((struct con_postgres*)((db_con)->tail))->sqlurl)
  55. #define CON_RESULT(db_con) (((struct con_postgres*)((db_con)->tail))->res)
  56. #define CON_CONNECTION(db_con) (((struct con_postgres*)((db_con)->tail))->con)
  57. #define CON_FP(db_con) (((struct con_postgres*)((db_con)->tail))->fp)
  58. #define CON_PID(db_con) (((struct con_postgres*)((db_con)->tail))->tpid)
  59. #define CON_CONNECTED(db_con) (((struct con_postgres*)((db_con)->tail))->connected)
  60. #define PLOG(f,s) LOG(L_ERR, "PG[%d] %s %s\n",__LINE__,f,s)
  61. #define DLOG(f,s) LOG(L_INFO, "PG[%d] %s %s\n",__LINE__,f,s)
  62. #endif /* CON_POSTGRES_H */