source: tags/initial/ARBDB/arbdb.h

Last change on this file was 2, checked in by oldcode, 24 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1#ifndef arbdb_h_included
2#define arbdb_h_included
3
4#ifndef NDEBUG
5# define gb_assert(bed) do { if (!(bed)) *(int *)0=0; } while (0)
6# ifndef DEBUG
7#  error DEBUG is NOT defined - but it has to!
8# endif
9#else
10# ifdef DEBUG
11#  error DEBUG is defined - but it should not!
12# endif
13# define gb_assert(bed)
14#endif /* NDEBUG */
15
16typedef const char *GB_CSTR;            /* local memory mgrment */
17typedef const char *GB_ERROR;           /* memory management is controlled by the ARBDB lib */
18typedef char    *GB_CPNTR;              /* points into a piece of mem */
19
20#define GB_PATH_MAX 1024
21#define GBS_GLOBAL_STRING_SIZE 64000
22
23
24#ifndef GB_INCLUDED
25#define GB_INCLUDED
26
27#define GB_CORE *(long *)0 =0
28#define GB_KEY_LEN_MAX  64
29#define GB_KEY_LEN_MIN  2
30
31/* ---------------------------------------- need some stuff if adlocal.h is not included */
32
33#ifndef GBL_INCLUDED
34typedef enum gb_call_back_type {
35    GB_CB_DELETE = 1,
36    GB_CB_CHANGED = 2,
37    GB_CB_SON_CREATED = 4,
38    GB_CB_ALL  = 7
39} GB_CB_TYPE;
40
41typedef struct gb_data_base_type GBDATA;
42typedef void (*GB_CB)(GBDATA *,int *clientdata, GB_CB_TYPE gbtype);
43/*#define  GB_CB void (*)(GBDATA *,int *clientdata, GB_CB_TYPE gbtype)*/
44
45#endif /*GBL_INCLUDED*/
46
47
48#define GBUSE(a) a=a
49
50typedef char *MALLOC_T;
51
52typedef unsigned long GB_ULONG;
53
54/* 4 Bytes */
55typedef unsigned int GB_UINT4;
56typedef const unsigned int GB_CUINT4;
57typedef const float GB_CFLOAT;
58
59/* ---------------------------------------- if adlocal.h not included */
60
61#ifndef GBL_INCLUDED
62
63#if defined(DEBUG)
64#define MEMORY_TEST 1
65#else
66#define MEMORY_TEST 0
67#endif
68
69
70#if (MEMORY_TEST==1)
71
72typedef char                                    *GB_REL_STRING;
73typedef struct gb_data_base_type        *GB_REL_GBDATA;
74typedef struct gb_data_base_type2       *GB_REL_CONTAINER;
75
76#else
77
78typedef long    GB_REL_STRING;          /* relative adress */
79typedef long    GB_REL_GBDATA;          /* relative adress */
80typedef long    GB_REL_CONTAINER;               /* relative adress */
81
82#endif /*MEMORY_TEST==1*/
83
84typedef void GB_MAIN_TYPE;
85typedef struct gbs_hash_struct GB_HASH;
86
87struct gb_flag_types {          /* public flags */
88    unsigned int                type:4;
89    unsigned int                security_delete:3;
90    unsigned int                security_write:3;
91    unsigned int                security_read:3;
92    unsigned int                compressed_data: 1;
93    unsigned int                unused: 1;      /* last bit saved */
94    unsigned int                user_flags:8;
95    unsigned int                temporary:1;    /* ==1 -> dont save entry */
96    unsigned int                saved_flags:8;
97};
98
99struct gb_flag_types2 {         /* private flags */
100    unsigned int                intern0: 16;
101    unsigned int                intern1: 16;
102};
103
104
105
106/********************* public ******************/
107
108
109typedef int GBQUARK;
110
111/*********** Undo ***********/
112typedef enum {
113    GB_UNDO_NONE,       /* no undo */
114    GB_UNDO_KILL,       /* no undo and delete all old undos */
115    GB_UNDO_UNDO,       /* normal undo -> deleted all redoes */
116    GB_UNDO_REDO,       /* moves to UNDO_REDO */
117    GB_UNDO_UNDO_REDO   /* internal makes undo redoable */
118}       GB_UNDO_TYPE;
119
120
121struct gb_transaction_save;
122
123#endif /*GBL_INCLUDED*/ 
124
125enum {GB_FALSE = 0 , GB_TRUE = 1 };
126
127typedef char GB_BOOL;
128typedef int GB_COMPRESSION_MASK;
129
130typedef enum gb_key_types {
131    GB_NONE             = 0,
132    GB_BIT              = 1,
133    GB_BYTE             = 2,
134    GB_INT              = 3,
135    GB_FLOAT    = 4,
136    GB_BITS             = 6,
137    GB_BYTES    = 8,
138    GB_INTS             = 9,
139    GB_FLOATS   = 10,
140    GB_LINK             = 11,
141    GB_STRING   = 12,
142    GB_STRING_SHRT      = 13,
143    GB_DB               = 15,
144    GB_TYPE_MAX = 16
145} GB_TYPES;
146
147enum gb_search_enum {
148    GB_FIND = 0,
149    GB_CREATE_CONTAINER = GB_DB /* create other types: use GB_TYPES */
150};
151
152#define GB_TYPE_2_CHAR "-bcif-B-CIFlSS-%"
153
154enum gb_search_types {
155    this_level = 1,
156    down_level = 2,
157    down_2_level = 4,
158    search_next = 8     /* search after item : this_level,down_level*/
159};
160/********************* public end ******************/
161
162/********************* client/server ******************/
163struct gbcmc_comm {
164    int socket;
165    char        *unix_name;
166    char        *error;
167};
168
169
170/********************* database ******************/
171#define SIZOFINTERN 10
172
173struct gb_extern_data {
174       
175    GB_REL_STRING rel_data;     /* Typ: (char *) */
176    long        memsize;
177    long        size;
178};
179
180struct GB_INTern_strings {
181    char        data[SIZOFINTERN];
182    unsigned char memsize;
183    unsigned char size;
184};
185
186struct GB_INTern {
187    char        data[SIZOFINTERN];
188};
189
190union gb_data_base_type_union {
191    long        i;
192    struct GB_INTern_strings istr;
193    struct GB_INTern    in;
194    struct gb_extern_data       ex;
195};
196
197struct gb_callback;
198struct gb_db_extended {
199    long        creation_date;
200    long        update_date;
201    struct gb_callback          *callback;
202    struct gb_transaction_save  *old;
203};
204
205struct 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
218typedef enum
219{
220    GB_AT_UNKNOWN,
221    GB_AT_RNA,          /* Nucleotide sequence (U) */
222    GB_AT_DNA,          /* Nucleotide sequence (T) */
223    GB_AT_AMI,          /* AminoAcid */
224    GB_AT_PRO           /* Protein */
225   
226} GB_alignment_type;
227       
228/*********** Sort ***********/
229
230
231#ifdef __cplusplus
232extern "C" {
233#endif
234
235    typedef long (*GB_MERGE_SORT)(void *, void *, char *cd);
236    /*#define GB_MERGE_SORT long (*)(void *, void *, char *cd )*/   
237   
238#ifdef __cplusplus   
239}
240#endif
241   
242extern long GB_NOVICE;
243
244        /*********** Commands ***********/
245#define GBL_MAX_ARGUMENTS       50
246
247/*
248#define GBL_COMMAND GB_ERROR (*)(GBDATA *gb_ref, char *com, int argcinput, GBL *argvinput, \
249                int argcparam,GBL *argvparam, \
250                int *argcout, GBL **argvout)
251
252#define GBL_COMMAND_DECL(x) GB_ERROR (*x)(GBDATA *gb_ref, char *com, int argcinput, GBL *argvinput, \
253                int argcparam,GBL *argvparam, \
254                int *argcout, GBL **argvout)
255*/             
256
257typedef struct gbl_struct {
258    char *str;
259} GBL;
260
261#ifdef __cplusplus
262extern "C" {
263#endif
264   
265    typedef GB_ERROR (*GBL_COMMAND)(GBDATA *gb_ref, char *com, int argcinput, GBL *argvinput, 
266                                    int argcparam,GBL *argvparam, 
267                                    int *argcout, GBL **argvout);
268   
269#ifdef __cplusplus   
270}
271#endif
272   
273struct GBL_command_table {
274    const char *command_identifier;
275    GBL_COMMAND function;
276};
277
278typedef struct GBDATA_SET_STRUCT {
279    long nitems;
280    long malloced_items;
281    GBDATA **items;
282} GBDATA_SET;
283
284#ifdef __cplusplus
285extern "C" {
286#endif
287
288    typedef GBDATA* (*GB_Link_Follower)(GBDATA *GB_root,GBDATA *GB_elem,const char *link); 
289    typedef long (*gbs_hash_sort_func_type)(const char *key0,long val0,const char *key1,long val1);
290    typedef long (*gb_compare_two_items_type)(void *p0,void *p1,char *cd);
291    typedef long (*gb_hash_loop_type)(const char *key, long val);
292    typedef long (*gb_hash_loop_type2)(const char *key, long val, void *parameter);
293    typedef void (*gb_warning_func_type)(const char *msg);
294    typedef int (*gb_status_func_type)(double val);
295    typedef int (*gb_status_func2_type)(const char *val); 
296    typedef void (*gb_error_handler_type)(const char *msg);
297   
298#ifdef __cplusplus
299}
300#endif
301   
302#if defined(__GNUG__) || defined(__cplusplus)
303extern "C" {   
304#endif   
305   
306# define P_(s) s
307
308#include <stdio.h>   
309#include <ad_prot.h>
310#ifdef GBL_INCLUDED
311#include <ad_lpro.h>
312#endif /*GBL_INCLUDED*/
313   
314#undef P_
315
316#if defined(__GNUG__) || defined(__cplusplus)
317}
318#endif
319
320#endif /*GB_INCLUDED*/
321
322#define GB_INLINE
323
324#ifdef __cplusplus
325
326struct gb_data_base_type2;
327class GB_transaction {
328    GBDATA *gbd;
329public:
330    GB_transaction(GBDATA *gb_main);
331    ~GB_transaction();
332};
333
334int GB_info(struct gb_data_base_type2 *gbd);
335
336# ifndef NO_INLINE
337#  undef GB_INLINE
338#  define GB_INLINE inline
339# endif /*NO_INLINE*/
340#endif /*__cplusplus*/
341
342#endif /*arbdb_h_included*/
Note: See TracBrowser for help on using the repository browser.