con_postgres.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. char *sqlurl; /* the url we are connected to, all connection memory
  46. parents from this */
  47. PGconn *con; /* this is the postgres connection */
  48. PGresult *res; /* this is the current result */
  49. FILE *fp; /* debug file output */
  50. long tpid; /* record pid of database opener in case one of */
  51. /* the children try to close the database */
  52. };
  53. #define CON_SQLURL(db_con) (((struct con_postgres*)((db_con)->tail))->sqlurl)
  54. #define CON_RESULT(db_con) (((struct con_postgres*)((db_con)->tail))->res)
  55. #define CON_CONNECTION(db_con) (((struct con_postgres*)((db_con)->tail))->con)
  56. #define CON_FP(db_con) (((struct con_postgres*)((db_con)->tail))->fp)
  57. #define CON_PID(db_con) (((struct con_postgres*)((db_con)->tail))->tpid)
  58. #define PLOG(f,s) LOG(L_ERR, "PG[%d] %s %s\n",__LINE__,f,s)
  59. #define DLOG(f,s) LOG(L_INFO, "PG[%d] %s %s\n",__LINE__,f,s)
  60. #endif /* CON_POSTGRES_H */