| 1 | #ifndef ARBDB_H |
|---|
| 2 | #define ARBDB_H |
|---|
| 3 | |
|---|
| 4 | #ifndef _STDINT_H |
|---|
| 5 | #include <stdint.h> |
|---|
| 6 | #endif |
|---|
| 7 | |
|---|
| 8 | #ifndef ARBDB_BASE_H |
|---|
| 9 | #include <arbdb_base.h> |
|---|
| 10 | #endif |
|---|
| 11 | |
|---|
| 12 | #ifndef ARB_ASSERT_H |
|---|
| 13 | #include <arb_assert.h> |
|---|
| 14 | #endif |
|---|
| 15 | #define gb_assert(bed) arb_assert(bed) |
|---|
| 16 | |
|---|
| 17 | #define NOT4PERL |
|---|
| 18 | /* function definitions starting with NOT4PERL are not included into the ARB-perl-interface */ |
|---|
| 19 | |
|---|
| 20 | #define GB_PATH_MAX 1024 |
|---|
| 21 | #define GBS_GLOBAL_STRING_SIZE 64000 |
|---|
| 22 | |
|---|
| 23 | #define GB_KEY_LEN_MAX 64 /* max. length of a key (a whole key path may be longer) */ |
|---|
| 24 | #define GB_KEY_LEN_MIN 2 |
|---|
| 25 | |
|---|
| 26 | #define GBUSE(a) a=a |
|---|
| 27 | |
|---|
| 28 | typedef char *MALLOC_T; |
|---|
| 29 | |
|---|
| 30 | typedef unsigned long GB_ULONG; |
|---|
| 31 | |
|---|
| 32 | /* 4 Bytes */ |
|---|
| 33 | typedef unsigned int GB_UINT4; |
|---|
| 34 | typedef const unsigned int GB_CUINT4; |
|---|
| 35 | typedef const float GB_CFLOAT; |
|---|
| 36 | |
|---|
| 37 | /* ---------------------------------------- need some stuff if adlocal.h is not included */ |
|---|
| 38 | |
|---|
| 39 | #ifndef ADLOCAL_H |
|---|
| 40 | |
|---|
| 41 | typedef void (*GB_CB)(GBDATA *,int *clientdata, GB_CB_TYPE gbtype); |
|---|
| 42 | |
|---|
| 43 | #if defined(DEBUG) |
|---|
| 44 | #define MEMORY_TEST 1 |
|---|
| 45 | #else |
|---|
| 46 | #define MEMORY_TEST 0 |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | #if (MEMORY_TEST==1) |
|---|
| 51 | |
|---|
| 52 | typedef char *GB_REL_STRING; |
|---|
| 53 | typedef struct gb_data_base_type *GB_REL_GBDATA; |
|---|
| 54 | typedef struct gb_data_base_type2 *GB_REL_CONTAINER; |
|---|
| 55 | |
|---|
| 56 | #else |
|---|
| 57 | |
|---|
| 58 | typedef long GB_REL_STRING; /* relative address */ |
|---|
| 59 | typedef long GB_REL_GBDATA; /* relative address */ |
|---|
| 60 | typedef long GB_REL_CONTAINER; /* relative address */ |
|---|
| 61 | |
|---|
| 62 | #endif /*MEMORY_TEST==1*/ |
|---|
| 63 | |
|---|
| 64 | struct gb_main_type; |
|---|
| 65 | typedef struct gb_main_type *GB_MAIN_TYPE; |
|---|
| 66 | |
|---|
| 67 | typedef struct gbs_hash_struct GB_HASH; |
|---|
| 68 | typedef struct gbs_hashi_struct GB_HASHI; |
|---|
| 69 | |
|---|
| 70 | struct GBS_regex; |
|---|
| 71 | struct GBS_string_matcher; |
|---|
| 72 | |
|---|
| 73 | typedef struct GBS_regex GBS_REGEX; |
|---|
| 74 | typedef struct GBS_string_matcher GBS_MATCHER; |
|---|
| 75 | |
|---|
| 76 | struct gb_flag_types { /* public flags */ |
|---|
| 77 | unsigned int type:4; |
|---|
| 78 | unsigned int security_delete:3; |
|---|
| 79 | unsigned int security_write:3; |
|---|
| 80 | unsigned int security_read:3; |
|---|
| 81 | unsigned int compressed_data: 1; |
|---|
| 82 | unsigned int unused: 1; /* last bit saved */ |
|---|
| 83 | unsigned int user_flags:8; |
|---|
| 84 | unsigned int temporary:1; /* ==1 -> don't save entry */ |
|---|
| 85 | unsigned int saved_flags:8; |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | struct gb_flag_types2 { /* private flags */ |
|---|
| 89 | unsigned int intern0: 16; |
|---|
| 90 | unsigned int intern1: 16; |
|---|
| 91 | }; |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | /********************* public ******************/ |
|---|
| 96 | |
|---|
| 97 | struct GBS_strstruct; |
|---|
| 98 | struct DictData; |
|---|
| 99 | |
|---|
| 100 | typedef int GBQUARK; |
|---|
| 101 | |
|---|
| 102 | /*********** Undo ***********/ |
|---|
| 103 | typedef enum { |
|---|
| 104 | GB_UNDO_NONE, /* no undo */ |
|---|
| 105 | GB_UNDO_KILL, /* no undo and delete all old undos */ |
|---|
| 106 | GB_UNDO_UNDO, /* normal undo -> deleted all redoes */ |
|---|
| 107 | GB_UNDO_REDO, /* moves to UNDO_REDO */ |
|---|
| 108 | GB_UNDO_UNDO_REDO /* internal makes undo redoable */ |
|---|
| 109 | } GB_UNDO_TYPE; |
|---|
| 110 | |
|---|
| 111 | typedef enum { GB_IGNORE_CASE = 0 , GB_MIND_CASE = 1, GB_CASE_UNDEFINED = 2 } GB_CASE; |
|---|
| 112 | |
|---|
| 113 | struct gb_transaction_save; |
|---|
| 114 | |
|---|
| 115 | #endif /*ADLOCAL_H*/ |
|---|
| 116 | |
|---|
| 117 | // -------------------------------------------------------------------------------- |
|---|
| 118 | |
|---|
| 119 | typedef int GB_COMPRESSION_MASK; |
|---|
| 120 | |
|---|
| 121 | typedef enum gb_key_types { |
|---|
| 122 | GB_NONE = 0, |
|---|
| 123 | GB_BIT = 1, |
|---|
| 124 | GB_BYTE = 2, |
|---|
| 125 | GB_INT = 3, |
|---|
| 126 | GB_FLOAT = 4, |
|---|
| 127 | GB_POINTER = 5, // not savable! only allowed in temporary entries |
|---|
| 128 | GB_BITS = 6, |
|---|
| 129 | // 7 is unused |
|---|
| 130 | GB_BYTES = 8, |
|---|
| 131 | GB_INTS = 9, |
|---|
| 132 | GB_FLOATS = 10, |
|---|
| 133 | GB_LINK = 11, |
|---|
| 134 | GB_STRING = 12, |
|---|
| 135 | GB_STRING_SHRT = 13, /* used automatically during save */ |
|---|
| 136 | // 14 is unused |
|---|
| 137 | GB_DB = 15, |
|---|
| 138 | |
|---|
| 139 | // keep GB_TYPES consistent with AW_VARIABLE_TYPE |
|---|
| 140 | // see ../WINDOW/aw_root.hxx@sync_GB_TYPES_AW_VARIABLE_TYPE |
|---|
| 141 | |
|---|
| 142 | GB_TYPE_MAX = 16 |
|---|
| 143 | |
|---|
| 144 | } GB_TYPES; |
|---|
| 145 | |
|---|
| 146 | enum gb_search_enum { |
|---|
| 147 | GB_FIND = 0, |
|---|
| 148 | GB_CREATE_CONTAINER = GB_DB /* create other types: use GB_TYPES */ |
|---|
| 149 | }; |
|---|
| 150 | |
|---|
| 151 | #define GB_TYPE_2_CHAR "-bcif-B-CIFlSS-%" |
|---|
| 152 | |
|---|
| 153 | enum gb_search_types { |
|---|
| 154 | this_level = 1, |
|---|
| 155 | down_level = 2, |
|---|
| 156 | down_2_level = 4, |
|---|
| 157 | search_next = 8 /* search after item : this_level,down_level*/ |
|---|
| 158 | }; |
|---|
| 159 | /********************* public end ******************/ |
|---|
| 160 | |
|---|
| 161 | /********************* client/server ******************/ |
|---|
| 162 | struct gbcmc_comm { |
|---|
| 163 | int socket; |
|---|
| 164 | char *unix_name; |
|---|
| 165 | char *error; |
|---|
| 166 | }; |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | /********************* database ******************/ |
|---|
| 170 | |
|---|
| 171 | #define SIZOFINTERN 10 |
|---|
| 172 | |
|---|
| 173 | struct gb_extern_data { |
|---|
| 174 | GB_REL_STRING rel_data; /* Typ: (char *) */ |
|---|
| 175 | long memsize; |
|---|
| 176 | long size; |
|---|
| 177 | }; |
|---|
| 178 | |
|---|
| 179 | struct GB_INTern_strings { |
|---|
| 180 | char data[SIZOFINTERN]; |
|---|
| 181 | unsigned char memsize; |
|---|
| 182 | unsigned char size; |
|---|
| 183 | }; |
|---|
| 184 | |
|---|
| 185 | struct GB_INTern { |
|---|
| 186 | char data[SIZOFINTERN]; |
|---|
| 187 | }; |
|---|
| 188 | |
|---|
| 189 | union gb_data_base_type_union { |
|---|
| 190 | int32_t i; |
|---|
| 191 | void *ptr; |
|---|
| 192 | struct GB_INTern_strings istr; |
|---|
| 193 | struct GB_INTern in; |
|---|
| 194 | struct gb_extern_data ex; |
|---|
| 195 | }; |
|---|
| 196 | |
|---|
| 197 | struct gb_callback; |
|---|
| 198 | struct gb_db_extended { |
|---|
| 199 | long creation_date; |
|---|
| 200 | long update_date; |
|---|
| 201 | struct gb_callback *callback; |
|---|
| 202 | struct gb_transaction_save *old; |
|---|
| 203 | }; |
|---|
| 204 | |
|---|
| 205 | struct gb_data_base_type { |
|---|
| 206 | long server_id; |
|---|
| 207 | GB_REL_CONTAINER rel_father; /* Typ: (struct gb_data_base_type2 *) */ |
|---|
| 208 | struct gb_db_extended *ext; |
|---|
| 209 | long index; |
|---|
| 210 | struct gb_flag_types flags; |
|---|
| 211 | struct gb_flag_types2 flags2; |
|---|
| 212 | union gb_data_base_type_union info; |
|---|
| 213 | int cache_index; /* should be a member of gb_db_extended */ |
|---|
| 214 | }; |
|---|
| 215 | |
|---|
| 216 | /*********** Alignment ***********/ |
|---|
| 217 | |
|---|
| 218 | typedef enum |
|---|
| 219 | { |
|---|
| 220 | GB_AT_UNKNOWN, |
|---|
| 221 | GB_AT_RNA, /* Nucleotide sequence (U) */ |
|---|
| 222 | GB_AT_DNA, /* Nucleotide sequence (T) */ |
|---|
| 223 | GB_AT_AA, /* AminoAcid */ |
|---|
| 224 | |
|---|
| 225 | } GB_alignment_type; |
|---|
| 226 | |
|---|
| 227 | /*********** Sort ***********/ |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | #ifdef __cplusplus |
|---|
| 231 | extern "C" { |
|---|
| 232 | #endif |
|---|
| 233 | |
|---|
| 234 | typedef long (*GB_MERGE_SORT)(void *, void *, char *cd); |
|---|
| 235 | /*#define GB_MERGE_SORT long (*)(void *, void *, char *cd )*/ |
|---|
| 236 | |
|---|
| 237 | #ifdef __cplusplus |
|---|
| 238 | } |
|---|
| 239 | #endif |
|---|
| 240 | |
|---|
| 241 | struct GBL_command_table; |
|---|
| 242 | |
|---|
| 243 | #ifdef __cplusplus |
|---|
| 244 | extern "C" { |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | typedef GBDATA* (*GB_Link_Follower)(GBDATA *GB_root,GBDATA *GB_elem,const char *link); |
|---|
| 248 | typedef int (*gbs_hash_compare_function) (const char *key0, long val0, const char *key1, long val1); |
|---|
| 249 | typedef int (*gb_compare_function)(const void *p0, const void *p1, void *client_data); |
|---|
| 250 | typedef long (*gb_hash_loop_type)(const char *key, long val, void *client_data); |
|---|
| 251 | typedef void (*gb_warning_func_type)(const char *msg); |
|---|
| 252 | typedef void (*gb_information_func_type)(const char *msg); |
|---|
| 253 | typedef int (*gb_status_func_type)(double val); |
|---|
| 254 | typedef int (*gb_status_func2_type)(const char *val); |
|---|
| 255 | typedef void (*gb_error_handler_type)(const char *msg); |
|---|
| 256 | typedef const char* (*gb_export_sequence_cb)(GBDATA *gb_species, size_t *seq_len, GB_ERROR *error); |
|---|
| 257 | |
|---|
| 258 | #ifdef __cplusplus |
|---|
| 259 | } |
|---|
| 260 | #endif |
|---|
| 261 | |
|---|
| 262 | #if defined(__GNUG__) || defined(__cplusplus) |
|---|
| 263 | extern "C" { |
|---|
| 264 | #endif |
|---|
| 265 | |
|---|
| 266 | # define P_(s) s |
|---|
| 267 | |
|---|
| 268 | #include <ad_prot.h> |
|---|
| 269 | #ifdef ADLOCAL_H |
|---|
| 270 | #include <ad_lpro.h> |
|---|
| 271 | #endif /*ADLOCAL_H*/ |
|---|
| 272 | |
|---|
| 273 | #undef P_ |
|---|
| 274 | |
|---|
| 275 | #if defined(__GNUG__) || defined(__cplusplus) |
|---|
| 276 | } |
|---|
| 277 | #endif |
|---|
| 278 | |
|---|
| 279 | #ifdef __cplusplus |
|---|
| 280 | |
|---|
| 281 | #ifndef ARBTOOLS_H |
|---|
| 282 | #include <arbtools.h> |
|---|
| 283 | #endif |
|---|
| 284 | |
|---|
| 285 | // -------------------------------------------------------------------------------- |
|---|
| 286 | // some const wrappers: |
|---|
| 287 | |
|---|
| 288 | inline char *GBS_find_string(char *str, GB_CSTR key, int match_mode) { |
|---|
| 289 | return const_cast<char*>(GBS_find_string(const_cast<GB_CSTR>(str), key, match_mode)); |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | // -------------------------------------------------------------------------------- |
|---|
| 293 | |
|---|
| 294 | struct gb_data_base_type2; |
|---|
| 295 | class GB_transaction : Noncopyable { |
|---|
| 296 | GBDATA *ta_main; |
|---|
| 297 | bool ta_open; // is transaction open ? |
|---|
| 298 | GB_ERROR ta_err; |
|---|
| 299 | |
|---|
| 300 | public: |
|---|
| 301 | GB_transaction(GBDATA *gb_main); |
|---|
| 302 | ~GB_transaction(); |
|---|
| 303 | |
|---|
| 304 | bool ok() const { return ta_open && !ta_err; } // ready to work on DB? |
|---|
| 305 | GB_ERROR close(GB_ERROR error); // abort transaction if error (e.g.: 'return ta.close(error);') |
|---|
| 306 | }; |
|---|
| 307 | |
|---|
| 308 | int GB_info(struct gb_data_base_type2 *gbd); |
|---|
| 309 | |
|---|
| 310 | #endif /*__cplusplus*/ |
|---|
| 311 | |
|---|
| 312 | #define GB_INLINE inline |
|---|
| 313 | |
|---|
| 314 | #else |
|---|
| 315 | #error "arbdb.h included twice" |
|---|
| 316 | #endif /*ARBDB_H*/ |
|---|