2
0

flat_con.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2004 FhG FOKUS
  5. * Copyright (C) 2008 iptelorg GmbH
  6. * Written by Jan Janak <[email protected]>
  7. *
  8. * This file is part of SER, a free SIP server.
  9. *
  10. * SER is free software; you can redistribute it and/or modify it under the
  11. * terms of the GNU General Public License as published by the Free Software
  12. * Foundation; either version 2 of the License, or (at your option) any later
  13. * version.
  14. *
  15. * SER is distributed in the hope that it will be useful, but WITHOUT ANY
  16. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #ifndef _FLAT_CON_H
  25. #define _FLAT_CON_H
  26. /** \addtogroup flatstore
  27. * @{
  28. */
  29. /** \file
  30. * Inmplementation of flatstore "connections".
  31. */
  32. #include "../../lib/srdb2/db_pool.h"
  33. #include "../../lib/srdb2/db_con.h"
  34. #include "../../lib/srdb2/db_uri.h"
  35. #include <stdio.h>
  36. /**
  37. * Per-connection flags for flatstore connections.
  38. */
  39. enum flat_con_flags {
  40. FLAT_OPENED = (1 << 0), /**< Handle opened successfully */
  41. };
  42. struct flat_file {
  43. char* filename; /**< Name of file within the directory */
  44. str table; /**< Table name the file belongs to */
  45. FILE* f; /**< File handle of the file */
  46. };
  47. /** A structure representing flatstore virtual connections.
  48. * Flatstore module is writing data to files on a local filesystem only so
  49. * there is no concept of real database connections. In flatstore module a
  50. * connection is related with a directory on the filesystem and it contains
  51. * file handles to files in that directory. The file handles are then used
  52. * from commands to write data in them.
  53. */
  54. struct flat_con {
  55. db_pool_entry_t gen; /**< Generic part of the structure */
  56. struct flat_file* file;
  57. int n; /**< Size of the file array */
  58. unsigned int flags; /**< Flags */
  59. };
  60. /** Create a new flat_con structure.
  61. * This function creates a new flat_con structure and attachs the structure to
  62. * the generic db_con structure in the parameter.
  63. * @param con A generic db_con structure to be extended with flatstore payload
  64. * @retval 0 on success
  65. * @retval A negative number on error
  66. */
  67. int flat_con(db_con_t* con);
  68. int flat_con_connect(db_con_t* con);
  69. void flat_con_disconnect(db_con_t* con);
  70. int flat_open_table(int *idx, db_con_t* con, str* name);
  71. /** @} */
  72. #endif /* _FLAT_CON_H */