dbt_lib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * $Id$
  3. *
  4. * DBText library
  5. *
  6. * Copyright (C) 2001-2003 FhG Fokus
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * History:
  25. * --------
  26. * 2003-01-30 created by Daniel
  27. *
  28. */
  29. #ifndef _DBT_LIB_H_
  30. #define _DBT_LIB_H_
  31. #include "../../str.h"
  32. #include "../../lib/srdb1/db_val.h"
  33. #include "../../locking.h"
  34. #define DBT_FLAG_UNSET 0
  35. #define DBT_FLAG_NULL 1
  36. #define DBT_FLAG_AUTO 2
  37. #define DBT_TBFL_ZERO 0
  38. #define DBT_TBFL_MODI 1
  39. #define DBT_FL_IGN -1
  40. #define DBT_FL_SET 0
  41. #define DBT_FL_UNSET 1
  42. #define DBT_DELIM ':'
  43. #define DBT_DELIM_C ' '
  44. #define DBT_DELIM_R '\n'
  45. /*
  46. * * Module parameters variables
  47. * */
  48. extern int db_mode; /* Database usage mode: 0 = no cache, 1 = cache */
  49. typedef db_val_t dbt_val_t, *dbt_val_p;
  50. typedef struct _dbt_row
  51. {
  52. dbt_val_p fields;
  53. struct _dbt_row *prev;
  54. struct _dbt_row *next;
  55. } dbt_row_t, *dbt_row_p;
  56. typedef struct _dbt_column
  57. {
  58. str name;
  59. int type;
  60. int flag;
  61. struct _dbt_column *prev;
  62. struct _dbt_column *next;
  63. } dbt_column_t, *dbt_column_p;
  64. typedef struct _dbt_table
  65. {
  66. str dbname;
  67. str name;
  68. int hash;
  69. int mark;
  70. int flag;
  71. int auto_col;
  72. int auto_val;
  73. int nrcols;
  74. dbt_column_p cols;
  75. dbt_column_p *colv;
  76. int nrrows;
  77. dbt_row_p rows;
  78. time_t mt;
  79. struct _dbt_table *next;
  80. struct _dbt_table *prev;
  81. } dbt_table_t, *dbt_table_p;
  82. typedef struct _dbt_tbl_cachel
  83. {
  84. gen_lock_t sem;
  85. dbt_table_p dtp;
  86. } dbt_tbl_cachel_t, *dbt_tbl_cachel_p;
  87. typedef struct _dbt_cache
  88. {
  89. str name;
  90. int flags;
  91. struct _dbt_cache *next;
  92. } dbt_cache_t, *dbt_cache_p;
  93. int dbt_init_cache(void);
  94. int dbt_cache_destroy(void);
  95. int dbt_cache_print(int);
  96. dbt_cache_p dbt_cache_get_db(str*);
  97. int dbt_cache_check_db(str*);
  98. int dbt_cache_del_db(str*);
  99. dbt_table_p dbt_db_get_table(dbt_cache_p, const str*);
  100. int dbt_release_table(dbt_cache_p, const str*);
  101. int dbt_cache_free(dbt_cache_p);
  102. dbt_column_p dbt_column_new(char*, int);
  103. dbt_row_p dbt_row_new(int);
  104. dbt_table_p dbt_table_new(const str*, const str*, const char*);
  105. int dbt_row_free(dbt_table_p, dbt_row_p);
  106. int dbt_column_free(dbt_column_p);
  107. int dbt_table_free_rows(dbt_table_p);
  108. int dbt_table_free(dbt_table_p);
  109. int dbt_row_set_val(dbt_row_p, dbt_val_p, int, int);
  110. int dbt_row_update_val(dbt_row_p, dbt_val_p, int, int);
  111. int dbt_table_add_row(dbt_table_p, dbt_row_p);
  112. int dbt_table_check_row(dbt_table_p, dbt_row_p);
  113. int dbt_table_update_flags(dbt_table_p, int, int, int);
  114. int dbt_check_mtime(const str *, const str *, time_t *);
  115. dbt_table_p dbt_load_file(const str *, const str *);
  116. int dbt_print_table(dbt_table_p, str *);
  117. int dbt_is_neq_type(db_type_t _t0, db_type_t _t1);
  118. #endif