db_res.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 Fhg Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #ifndef DB_RES_H
  28. #define DB_RES_H
  29. #include "db_row.h"
  30. #include "db_key.h"
  31. #include "db_val.h"
  32. #include "db_con.h"
  33. struct db_row;
  34. typedef struct db_res {
  35. struct {
  36. db_key_t* names; /* Column names */
  37. db_type_t* types; /* Column types */
  38. int n; /* Number of columns */
  39. } col;
  40. struct db_row* rows; /* Rows */
  41. int n; /* Number of rows */
  42. } db_res_t;
  43. #define RES_NAMES(re) ((re)->col.names)
  44. #define RES_TYPES(re) ((re)->col.types)
  45. #define RES_COL_N(re) ((re)->col.n)
  46. #define RES_ROWS(re) ((re)->rows)
  47. #define RES_ROW_N(re) ((re)->n)
  48. /*
  49. * Create a new result structure
  50. */
  51. db_res_t* new_result(void);
  52. /*
  53. * Fill the structure with data from database
  54. */
  55. int convert_result(db_con_t* _h, db_res_t* _r);
  56. /*
  57. * Free all memory allocated by the structure
  58. */
  59. int free_result(db_res_t* _r);
  60. #endif /* DB_RES_H */