ze-filter  (ze-filter-0.8.0-develop-180218)
zeBTree.new.c
Go to the documentation of this file.
1 /*
2  *
3  * ze-filter - Mail Server Filter for sendmail
4  *
5  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
6  *
7  * Auteur : Jose Marcio Martins da Cruz
8  * jose.marcio.mc@gmail.org
9  *
10  * Historique :
11  * Creation : janvier 2002
12  *
13  * This program is free software, but with restricted license :
14  *
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  * More details about ze-filter license can be found at ze-filter
21  * web site : http://foss.jose-marcio.org
22  */
23 
24 #include <ze-sys.h>
25 
26 #include <zeBTree.h>
27 
28 #include "ze-libze.h"
29 
30 
31 /* ****************************************************************************
32  * *
33  * *
34  **************************************************************************** */
35 #ifndef RECURSIVE_TREE
36 # define RECURSIVE_TREE 1
37 #endif
38 
39 #define DSTACK 0x100
40 
41 #ifndef AVL_BTREE
42 #define AVL_BTREE 1
43 #endif
44 
45 #define _DB_LH -1
46 #define _DB_EH 0
47 #define _DB_RH 1
48 
49 struct ZEBTREC_T
50 {
51  ZEBTREC_T *left;
53  int balance;
54  void *data;
55 };
56 
57 static bool zeBTree_Destroy_tree(ZEBTREC_T *);
58 
59 static bool zeBTree_Add_node(ZEBT_T *, void *, ZEBTREC_T **, bool *);
60 
61 static ZEBTREC_T *zeBTree_Del_node(ZEBT_T *, void *, ZEBTREC_T *, bool *);
62 
63 static ZEBTREC_T *zeBTree_Get_node(ZEBT_T *, void *, ZEBTREC_T *);
64 
65 static int zeBTree_Browse_tree(ZEBT_T *, JBT_BROWSE_T, ZEBTREC_T *, void *);
66 static bool zeBTree_Cpy_tree(ZEBT_T *, ZEBTREC_T *, JBT_SEL_T, void *);
67 
68 static ZEBTREC_T *zeBTree_Node_Alloc(ZEBT_T *, void *);
69 
70 static ZEBTREC_T *zeBTree_Rotate_Left(ZEBTREC_T *);
71 static ZEBTREC_T *zeBTree_Rotate_Right(ZEBTREC_T *);
72 
73 static ZEBTREC_T *zeBTree_Left_Balance(ZEBTREC_T *);
74 static ZEBTREC_T *zeBTree_Right_Balance(ZEBTREC_T *);
75 
76 static int jlog2(int);
77 
79 
80 /* ****************************************************************************
81  * *
82  * *
83  **************************************************************************** */
84 
85 #define JBT_LOCK(mutex) MUTEX_LOCK(mutex)
86 #define JBT_UNLOCK(mutex) MUTEX_UNLOCK(mutex)
87 
88 #define JBT_ZERO(jbth) \
89  do { \
90  jbth->signature = SIGNATURE; \
91  jbth->count = 0; \
92  jbth->size = 0; \
93  jbth->reccmp = NULL; \
94  jbth->root = NULL; \
95  jbth->chkCount = FALSE; \
96  jbth->maxCount = MAX_BTNODES; \
97  jbth->nbErr = 0; \
98  } while (0)
99 
100 
101 /* ****************************************************************************
102  * *
103  * *
104  **************************************************************************** */
105 bool
106 zeBTree_Init(jdbh, size, reccmp)
107  ZEBT_T *jdbh;
108  size_t size;
109  JBT_CMP_T reccmp;
110 {
111  if (jdbh == NULL)
112  return FALSE;
113 
114  if (size <= 0)
115  return FALSE;
116 
117  if (reccmp == NULL)
118  return FALSE;
119 
120  JBT_LOCK(&jdbh->mutex);
121 
122  if (jdbh->signature == SIGNATURE)
123  zeBTree_Destroy(jdbh);
124 
125 #if 1
126  JBT_ZERO(jdbh);
127 #else
128  jdbh->signature = SIGNATURE;
129  jdbh->count = 0;
130  jdbh->size = 0;
131  jdbh->reccmp = NULL;
132  jdbh->root = NULL;
133  jdbh->chkCount = FALSE;
134  jdbh->maxCount = MAX_BTNODES;
135 #endif
136 
137  jdbh->size = size;
138  jdbh->reccmp = reccmp;
139 
140  JBT_UNLOCK(&jdbh->mutex);
141 
142  return TRUE;
143 }
144 
145 /* ****************************************************************************
146  * *
147  * *
148  **************************************************************************** */
149 bool
150 zeBTree_Set_BTree_Size(jdbh, chkCount, maxCount)
151  ZEBT_T *jdbh;
152  bool chkCount;
153  int maxCount;
154 {
155  bool result = FALSE;
156 
157  if (jdbh == NULL)
158  return FALSE;
159 
160  JBT_LOCK(&jdbh->mutex);
161 
162  if (jdbh->signature != SIGNATURE)
163  goto fin;
164 
165  jdbh->chkCount = chkCount;
166  jdbh->maxCount = maxCount;
167 
168  result = TRUE;
169 
170  fin:
171  JBT_UNLOCK(&jdbh->mutex);
172 
173  return result;
174 }
175 
176 /* ****************************************************************************
177  * *
178  * *
179  **************************************************************************** */
180 bool
182  ZEBT_T *jdbh;
183 {
184 
185  if (jdbh == NULL)
186  return FALSE;
187 
188  if (jdbh->signature != SIGNATURE)
189  return FALSE;
190 
191  (void) zeBTree_Destroy_tree(jdbh->root);
192 
193 #if 1
194  JBT_ZERO(jdbh);
195 #else
196  jdbh->size = 0;
197  jdbh->count = 0;
198  jdbh->reccmp = NULL;
199  jdbh->root = NULL;
200 
201  memset(jdbh, 0, sizeof (ZEBT_T));
202 
203  jdbh->chkCount = FALSE;
204  jdbh->maxCount = MAX_BTNODES;
205 #endif
206 
207  return TRUE;
208 }
209 
210 /* ****************************************************************************
211  * *
212  * *
213  **************************************************************************** */
214 bool
216  ZEBT_T *jdbh;
217 {
218  bool result = FALSE;
219 
220  if (jdbh == NULL)
221  return FALSE;
222 
223  JBT_LOCK(&jdbh->mutex);
224 
225  if (jdbh->signature != SIGNATURE)
226  goto fin;
227 
228  (void) zeBTree_Destroy_tree(jdbh->root);
229 
230  jdbh->count = 0;
231  jdbh->root = NULL;
232 
233  result = TRUE;
234 
235  fin:
236  JBT_UNLOCK(&jdbh->mutex);
237 
238  return result;
239 }
240 
241 /* ****************************************************************************
242  * *
243  * *
244  **************************************************************************** */
245 int
247  ZEBT_T *jdbh;
248 {
249  int res = 0;
250 
251  if (jdbh == NULL)
252  return res;
253 
254  JBT_LOCK(&jdbh->mutex);
255 
256  if (jdbh->signature != SIGNATURE)
257  goto fin;
258 
259  res = jdbh->count;
260 
261  fin:
262  JBT_UNLOCK(&jdbh->mutex);
263 
264  return res;
265 }
266 
267 /* ****************************************************************************
268  * *
269  * *
270  **************************************************************************** */
271 int
272 zeBTree_Browse(jdbh, func, data)
273  ZEBT_T *jdbh;
274  JBT_BROWSE_T func;
275  void *data;
276 {
277  int result = 0;
278 
279  if (jdbh == NULL)
280  return 0;
281 
282  JBT_LOCK(&jdbh->mutex);
283 
284  if (jdbh->signature != SIGNATURE)
285  goto fin;
286 
287  result = zeBTree_Browse_tree(jdbh, func, jdbh->root, data);
288 
289  fin:
290  JBT_UNLOCK(&jdbh->mutex);
291 
292  return result;
293 }
294 
295 /* ****************************************************************************
296  * *
297  * *
298  **************************************************************************** */
299 void *
301  ZEBT_T *jdbh;
302  void *data;
303 {
304  ZEBTREC_T *node;
305  void *result = NULL;
306 
307  if (jdbh == NULL)
308  return NULL;
309  if (data == NULL)
310  return NULL;
311 
312  JBT_LOCK(&jdbh->mutex);
313 
314  if (jdbh->signature != SIGNATURE)
315  goto fin;
316 
317  node = zeBTree_Get_node(jdbh, data, jdbh->root);
318  if (node != NULL)
319  result = node->data;
320 
321  fin:
322  JBT_UNLOCK(&jdbh->mutex);
323 
324  return result;
325 }
326 
327 /* ****************************************************************************
328  * *
329  * *
330  **************************************************************************** */
331 #define MAX_BTERR 16
332 
333 bool
335  ZEBT_T *jdbh;
336  void *data;
337 {
338  bool ok = FALSE;
339 
340  if (jdbh == NULL)
341  return FALSE;
342  if (data == NULL)
343  return FALSE;
344 
345 #if BUGGY_AVLTREE
346  return TRUE;
347 #endif
348 
349  JBT_LOCK(&jdbh->mutex);
350 
351  if (jdbh->signature != SIGNATURE)
352  goto fin;
353 
354  if (jdbh->chkCount && (jdbh->count >= MAX_BTNODES))
355  {
356  if (jdbh->nbErr < MAX_BTERR)
357  ZE_LogMsgError(0, "Too much nodes in btree : %ld", (long) jdbh->count);
358  jdbh->nbErr++;
359 
360  goto fin;
361  }
362  jdbh->nbErr = 0;
363 
364  ZE_MessageInfo(19, " Adding...");
365 
366  {
367  bool taller = FALSE;
368 
369  ok = zeBTree_Add_node(jdbh, data, &(jdbh->root), &taller);
370  if (!ok)
371  ZE_LogMsgNotice(0, "zeBTree_Add_node returned NULL...");
372  }
373 
374  ZE_MessageInfo(19, " OK ... %d", jdbh->count);
375 
376  fin:
377  JBT_UNLOCK(&jdbh->mutex);
378 
379  return ok;
380 }
381 
382 /* ****************************************************************************
383  * *
384  * *
385  **************************************************************************** */
386 bool
388  ZEBT_T *jdbh;
389  void *data;
390 {
391  ZEBTREC_T *root = NULL;
392  bool shorter = FALSE;
393 
394  if (jdbh == NULL)
395  return FALSE;
396 
397  if (jdbh->signature != SIGNATURE)
398  return FALSE;
399 
400  root = zeBTree_Del_node(jdbh, data, jdbh->root, &shorter);
401 
402  return TRUE;
403 }
404 
405 /* ****************************************************************************
406  * *
407  * *
408  **************************************************************************** */
409 static bool
410 zeBTree_Destroy_tree(root)
411  ZEBTREC_T *root;
412 {
413  if (root == NULL)
414  return TRUE;
415 
416  zeBTree_Destroy_tree(root->left);
417  root->left = NULL;
418 
419  FREE(root->data);
420 
421  zeBTree_Destroy_tree(root->right);
422  root->right = NULL;
423  FREE(root);
424 
425  return TRUE;
426 }
427 
428 /* ****************************************************************************
429  * *
430  * TO DO *** *
431  **************************************************************************** */
432 static ZEBTREC_T *
433 zeBTree_Del_node(jdbh, data, root, shorter)
434  ZEBT_T *jdbh;
435  void *data;
436  ZEBTREC_T *root;
437  bool *shorter;
438 {
439  int cmp;
440  ZEBTREC_T *res = root;
441 
442  if (jdbh == NULL)
443  {
444  /* JOE - ERROR */
445  return NULL;
446  }
447  if (data == NULL)
448  {
449  /* JOE - ERROR */
450  return NULL;
451  }
452 
453  if (root == NULL)
454  {
455  /* XXX */
456  return root;
457  }
458 
459  if ((cmp = (*jdbh->reccmp) (data, root->data)) == 0)
460  {
461  /* XXX */
462  return NULL;
463  }
464  if (cmp < 0)
465  {
466  }
467  if (cmp > 0)
468  {
469  }
470  return res;
471 }
472 
473 /* ****************************************************************************
474  * *
475  * *
476  **************************************************************************** */
477 static ZEBTREC_T *
478 zeBTree_Get_node(jdbh, data, root)
479  ZEBT_T *jdbh;
480  void *data;
481  ZEBTREC_T *root;
482 {
483  int res = 0;
484 
485  if (jdbh == NULL)
486  return NULL;
487  if (data == NULL)
488  return NULL;
489  if (root == NULL)
490  return NULL;
491 
492  if (root->data == NULL)
493  {
494  ZE_LogMsgWarning(0, "root not NULL but root->data is NULL...");
495  return NULL;
496  }
497 
498  res = jdbh->reccmp(data, root->data);
499 
500  if (res == 0)
501  return root;
502  if (res < 0)
503  return zeBTree_Get_node(jdbh, data, root->left);
504  if (res > 0)
505  return zeBTree_Get_node(jdbh, data, root->right);
506 
507  return NULL;
508 }
509 
510 /* ****************************************************************************
511  * *
512  * *
513  **************************************************************************** */
514 static int
515 zeBTree_Browse_tree(jdbh, func, root, data)
516  ZEBT_T *jdbh;
517  JBT_BROWSE_T func;
518  ZEBTREC_T *root;
519  void *data;
520 {
521  int n = 0;
522 
523  if (jdbh == NULL)
524  return 0;
525 
526  if (root == NULL)
527  return 0;
528 
529  if (jdbh->signature != SIGNATURE)
530  goto fin;
531 
532  if (root->left != NULL)
533  n += zeBTree_Browse_tree(jdbh, func, root->left, data);
534 
535  if (func != NULL)
536  n += func(root->data, data);
537 
538  if (root->right != NULL)
539  n += zeBTree_Browse_tree(jdbh, func, root->right, data);
540 
541  fin:
542 
543  return n;
544 }
545 
546 /* ****************************************************************************
547  * *
548  * *
549  **************************************************************************** */
550 bool
551 zeBTree_Cpy(dst, org, getit, arg)
552  ZEBT_T *dst;
553  ZEBT_T *org;
554  JBT_SEL_T getit;
555  void *arg;
556 {
557  bool result = FALSE;
558 
559  if (dst == NULL || org == NULL)
560  return FALSE;
561 
562  if (dst->signature != SIGNATURE || org->signature != SIGNATURE)
563  goto fin;
564 
565  result = zeBTree_Cpy_tree(dst, org->root, getit, arg);
566 
567  fin:
568 
569  return result;
570 }
571 
572 /* ****************************************************************************
573  * *
574  * *
575  **************************************************************************** */
576 static bool
577 zeBTree_Cpy_tree(jdbh, root, getit, arg)
578  ZEBT_T *jdbh;
579  ZEBTREC_T *root;
580  JBT_SEL_T getit;
581  void *arg;
582 {
583  if (root == NULL)
584  return FALSE;
585 
586  (void) zeBTree_Cpy_tree(jdbh, root->left, getit, arg);
587  if (root->data != NULL)
588  {
589  if (getit(root->data, arg))
590  {
591  if (!zeBTree_Add(jdbh, root->data))
592  ;
593  }
594  } else;
595 
596  (void) zeBTree_Cpy_tree(jdbh, root->right, getit, arg);
597 
598  return TRUE;
599 }
600 
601 /* ****************************************************************************
602  * *
603  * *
604  **************************************************************************** */
605 bool
606 zeBTree_Cleanup(jdbh, getit, arg)
607  ZEBT_T *jdbh;
608  JBT_SEL_T getit;
609  void *arg;
610 {
611  ZEBTREC_T *oroot = NULL;
612 
613  if (jdbh == NULL)
614  return FALSE;
615 
616  if (jdbh->signature != SIGNATURE)
617  return FALSE;
618 
619  oroot = jdbh->root;
620  jdbh->root = NULL;
621  jdbh->count = 0;
622 
623  if (zeBTree_Cpy_tree(jdbh, oroot, getit, arg))
624  zeBTree_Destroy_tree(oroot);
625 
626  return TRUE;
627 }
628 
629 
630 /* ****************************************************************************
631  * *
632  * *
633  **************************************************************************** */
634 static ZEBTREC_T *
635 zeBTree_Rotate_Left(root)
636  ZEBTREC_T *root;
637 {
638  ZEBTREC_T *tmp;
639 
640  if (root == NULL)
641  return NULL;
642 
643  if (root->right == NULL)
644  return root;
645 
646  tmp = root->right;
647  root->right = tmp->left;
648  tmp->left = root;
649  root = tmp;
650 
651  return root;
652 }
653 
654 /* ****************************************************************************
655  * *
656  * *
657  **************************************************************************** */
658 static ZEBTREC_T *
659 zeBTree_Rotate_Right(root)
660  ZEBTREC_T *root;
661 {
662  ZEBTREC_T *tmp;
663 
664  if (root == NULL)
665  return NULL;
666 
667  if (root->left == NULL)
668  return root;
669 
670  tmp = root->left;
671  root->left = tmp->right;
672  tmp->right = root;
673  root = tmp;
674 
675  return root;
676 }
677 
678 /* ****************************************************************************
679  * *
680  * *
681  **************************************************************************** */
682 static ZEBTREC_T *
683 zeBTree_Right_Balance(root)
684  ZEBTREC_T *root;
685 {
686  ZEBTREC_T *x, *w;
687 
688  x = root->right;
689 
690  switch (x->balance)
691  {
692  case _DB_RH:
693  root->balance = _DB_EH;
694  x->balance = _DB_EH;
695  root = zeBTree_Rotate_Left(root);
696  break;
697  case _DB_EH:
698  ZE_MessageWarning(10, "zeBTree_Right_Balance x->balance == _DB_EH ???");
699  break;
700  case _DB_LH:
701  w = x->left;
702  switch (w->balance)
703  {
704  case _DB_EH:
705  root->balance = _DB_EH;
706  x->balance = _DB_EH;
707  break;
708  case _DB_LH:
709  root->balance = _DB_EH;
710  x->balance = _DB_RH;
711  break;
712  case _DB_RH:
713  root->balance = _DB_LH;
714  x->balance = _DB_EH;
715  break;
716  }
717  w->balance = _DB_EH;
718  x = zeBTree_Rotate_Right(x);
719  root->right = x;
720  root = zeBTree_Rotate_Left(root);
721  break;
722  }
723 
724  return root;
725 }
726 
727 /* ****************************************************************************
728  * *
729  * *
730  **************************************************************************** */
731 static ZEBTREC_T *
732 zeBTree_Left_Balance(root)
733  ZEBTREC_T *root;
734 {
735  ZEBTREC_T *x, *w;
736 
737  x = root->left;
738 
739  switch (x->balance)
740  {
741  case _DB_LH:
742  root->balance = _DB_EH;
743  x->balance = _DB_EH;
744  root = zeBTree_Rotate_Right(root);
745  break;
746  case _DB_EH:
747  ZE_MessageWarning(10, "zeBTree_Left_Balance x->balance == _DB_EH ???");
748  break;
749  case _DB_RH:
750  w = x->right;
751  switch (w->balance)
752  {
753  case _DB_EH:
754  root->balance = _DB_EH;
755  x->balance = _DB_EH;
756  break;
757  case _DB_RH:
758  root->balance = _DB_EH;
759  /* R -> L */
760  x->balance = _DB_LH;
761  break;
762  case _DB_LH:
763  root->balance = _DB_RH;
764  x->balance = _DB_EH;
765  break;
766  }
767  w->balance = _DB_EH;
768  x = zeBTree_Rotate_Left(x);
769  root->left = x;
770  root = zeBTree_Rotate_Right(root);
771  break;
772  }
773 
774  return root;
775 }
776 
777 
778 /* ****************************************************************************
779  * *
780  * *
781  **************************************************************************** */
782 static ZEBTREC_T *
783 zeBTree_Node_Alloc(jdbh, data)
784  ZEBT_T *jdbh;
785  void *data;
786 {
787  ZEBTREC_T *rec;
788 
789  rec = (ZEBTREC_T *) malloc(sizeof (ZEBTREC_T));
790  if (rec == NULL)
791  {
792  ZE_LogSysError("malloc jbtrec");
793  return NULL;
794  }
795 
796  memset(rec, 0, sizeof (ZEBTREC_T));
797 
798  rec->data = malloc(jdbh->size);
799  if (rec->data == NULL)
800  {
801  ZE_LogSysError("malloc data");
802  free(rec);
803  return NULL;
804  }
805  rec->left = NULL;
806  rec->right = NULL;
807  rec->balance = _DB_EH;
808 
809  memcpy(rec->data, data, jdbh->size);
810  return rec;
811 }
812 
813 /* ****************************************************************************
814  * *
815  * *
816  **************************************************************************** */
817 static bool
818 zeBTree_Add_node(jdbh, data, root, taller)
819  ZEBT_T *jdbh;
820  void *data;
821  ZEBTREC_T **root;
822  bool *taller;
823 {
824  if (root == NULL)
825  return FALSE;
826 
827  if (*root == NULL)
828  {
829  ZEBTREC_T *node = NULL;
830 
831  ZE_MessageInfo(19, "Empty tree ...");
832  node = zeBTree_Node_Alloc(jdbh, data);
833  if (node != NULL)
834  {
835  if (taller != NULL)
836  *taller = TRUE;
837  node->balance = _DB_EH;
838  jdbh->count++;
839  *root = node;
840  }
841  return (node != NULL);;
842  }
843 
844  {
845  int r;
846  ZEBTREC_T *troot = NULL;
847 
848  bool ok = TRUE;
849 
850  troot = *root;
851 
852  r = (*jdbh->reccmp) (data, troot->data);
853 
854  if (r == 0)
855  {
856  ZE_LogMsgNotice(0, "Node already on the tree...");
857  return FALSE;
858  }
859 
860  if (r < 0)
861  {
862  ok = zeBTree_Add_node(jdbh, data, &(troot->left), taller);
863 
864  if (ok && (taller != NULL) && *taller)
865  {
866  switch (troot->balance)
867  {
868  case _DB_LH:
869  {
870  ZEBTREC_T *node = NULL;
871 
872  node = zeBTree_Left_Balance(troot);
873  *taller = FALSE;
874  if (node == NULL)
875  {
876  ZE_LogMsgWarning(0, "zeBTree_Left_Balance returned NULL...");
877  return FALSE;
878  }
879  troot = node;
880  }
881  break;
882  case _DB_EH:
883  troot->balance = _DB_LH;
884  *taller = TRUE;
885  break;
886  case _DB_RH:
887  troot->balance = _DB_EH;
888  *taller = FALSE;
889  break;
890  default:
891  /* error */
892  break;
893  }
894  }
895  *root = troot;
896  return ok;
897  }
898 
899  if (r > 0)
900  {
901  ok = zeBTree_Add_node(jdbh, data, &(troot->right), taller);
902 
903  if (ok && (taller != NULL) && *taller)
904  {
905  switch (troot->balance)
906  {
907  case _DB_LH:
908  troot->balance = _DB_EH;
909  *taller = FALSE;
910  break;
911  case _DB_EH:
912  troot->balance = _DB_RH;
913  *taller = TRUE;
914  break;
915  case _DB_RH:
916  {
917  ZEBTREC_T *node = NULL;
918 
919  node = zeBTree_Right_Balance(troot);
920  *taller = FALSE;
921  if (node == NULL)
922  {
923  ZE_LogMsgWarning(0, "zeBTree_Right_Balance returned NULL...");
924  return FALSE;
925  }
926  troot = node;
927  }
928  break;
929  default:
930  /* error */
931  break;
932  }
933 
934  }
935  *root = troot;
936  return ok;
937  }
938  }
939 
940  return TRUE;
941 }
942 
943 /* ****************************************************************************
944  * *
945  * *
946  **************************************************************************** */
947 static int
948 jlog2(x)
949  int x;
950 {
951  int n = 0;
952 
953  for (x /= 2; x != 0; x /= 2)
954  n++;
955 
956  return n;
957 }
958 
959 int
961  ZEBT_T *jdbh;
962 {
963 
964  if (jdbh == NULL)
965  return FALSE;
966 
967  if (jdbh->signature != SIGNATURE)
968  return FALSE;
969 
970  return 2 * jlog2(jdbh->count);
971 }
bool zeBTree_Set_BTree_Size(ZEBT_T *jdbh, bool chkCount, int maxCount)
Definition: zeBTree.new.c:150
bool zeBTree_Del(ZEBT_T *jdbh, void *data)
Definition: zeBTree.new.c:387
#define JBT_UNLOCK(mutex)
Definition: zeBTree.new.c:86
#define _DB_LH
Definition: zeBTree.new.c:45
uint32_t signature
Definition: zeBTree.h:74
int count
Definition: zeBTree.h:75
void * zeBTree_Get(ZEBT_T *jdbh, void *data)
Definition: zeBTree.new.c:300
ZEBTREC_T * left
Definition: zeBTree.c:42
#define _DB_EH
Definition: zeBTree.new.c:46
#define FREE(x)
Definition: macros.h:37
#define JBT_LOCK(mutex)
Definition: zeBTree.new.c:85
int zeBTree_Max_Height(ZEBT_T *)
Definition: zeBTree.new.c:960
bool ok
Definition: ze-connopen.c:59
bool chkCount
Definition: zeBTree.h:79
bool zeBTree_Add(ZEBT_T *jdbh, void *data)
Definition: zeBTree.new.c:334
#define FALSE
Definition: macros.h:160
#define ZE_LogMsgError(level,...)
Definition: zeSyslog.h:113
bool zeBTree_Cleanup(ZEBT_T *jdbh, JBT_SEL_T getit, void *arg)
Definition: zeBTree.new.c:606
ZEBTREC_T * right
Definition: zeBTree.c:43
bool zeBTree_Destroy(ZEBT_T *jdbh)
Definition: zeBTree.new.c:181
#define ZE_LogMsgNotice(level,...)
Definition: zeSyslog.h:111
int zeBTree_Browse(ZEBT_T *jdbh, JBT_BROWSE_T func, void *data)
Definition: zeBTree.new.c:272
#define _DB_RH
Definition: zeBTree.new.c:47
#define JBT_ZERO(jbth)
Definition: zeBTree.new.c:88
int balance
Definition: zeBTree.c:44
pthread_mutex_t mutex
Definition: zeBTree.h:82
int zeBTree_Count(ZEBT_T *jdbh)
Definition: zeBTree.new.c:246
bool zeBTree_Clear(ZEBT_T *jdbh)
Definition: zeBTree.new.c:215
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
#define TRUE
Definition: macros.h:157
#define ZE_MessageWarning(level,...)
Definition: zeSyslog.h:92
#define memcpy(d, s, n)
Definition: ze-sys.h:224
#define ZE_LogSysError(...)
Definition: zeSyslog.h:129
#define MAX_BTNODES
Definition: zeBTree.h:66
void * data
Definition: zeBTree.c:45
#define ZE_LogMsgWarning(level,...)
Definition: zeSyslog.h:112
ZEBT_CMP_F reccmp
Definition: zeBTree.h:78
size_t size
Definition: zeBTree.h:76
#define MAX_BTERR
Definition: zeBTree.new.c:331
int maxCount
Definition: zeBTree.h:80
int nbErr
Definition: zeBTree.h:81
#define SIGNATURE
Definition: ze-libjc.h:75
bool zeBTree_Init(ZEBT_T *jdbh, size_t size, JBT_CMP_T reccmp)
Definition: zeBTree.new.c:106
ZEBTREC_T * root
Definition: zeBTree.h:77
Definition: zeBTree.h:73
bool zeBTree_Cpy(ZEBT_T *dst, ZEBT_T *org, JBT_SEL_T getit, void *arg)
Definition: zeBTree.new.c:551