forked from dinhvh/libetpan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.sgml
15113 lines (12387 loc) · 420 KB
/
API.sgml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
<book id="libetpan-api">
<bookinfo>
<date>2003-12-03</date>
<title>libEtPan! API</title>
<authorgroup>
<author>
<firstname>Viet Hoa</firstname>
<surname>DINH</surname>
</author>
</authorgroup>
<copyright>
<year>2003</year>
<holder>DINH Viet Hoa</holder>
</copyright>
</bookinfo>
<toc></toc>
<!-- Introduction -->
<chapter>
<title>Introduction</title>
<para>
This document will describe the API of libEtPan!
</para>
</chapter>
<!-- Tools -->
<chapter>
<title>Tools and datatypes</title>
<para>
libEtPan! include a collection of datatypes such as lists,
arrays, hash tables and tools such as buffered I/O.
</para>
<!-- Array -->
<sect1>
<title>Array</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
typedef struct carray_s carray;
</programlisting>
<para>
<command>carray</command> is an array of pointers that will
resize automatically in case a new element is added.
</para>
<para>
The <command>carray</command> is implemented with an array
<command>(void **)</command> that can be resized. An array has a
size: this is the number of elements that can be added before
the table is resized. It also has a count of elements: this is
the elements that exist in the array.
</para>
<sect2 id="carray-new">
<title>carray_new and carray_free</title>
<programlisting role="C">
carray * carray_new(unsigned int initsize);
void carray_free(carray * array);
</programlisting>
<para>
<command>carray_new()</command> creates a new array with an
initial size. The array is not resized until the number of
element reach the initial size. It returns
<command>NULL</command> in case of failure.
</para>
<para>
<command>carray_free()</command> releases memory used by the
given array.
</para>
<example>
<title>carray creation</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
#include <stdlib.h>
#define SIZE 50
int main(void)
{
carray * a;
a = carray_new(SIZE);
if (a == NULL)
exit(EXIT_FAILURE);
/* do things here */
carray_free(a);
exit(EXIT_SUCESS);
}
</programlisting>
</example>
</sect2>
<sect2 id="carray-set-size">
<title>carray_set_size</title>
<programlisting role="C">
int carray_set_size(carray * array, uint32_t new_size);
</programlisting>
<para>
<command>carray_set_size()</command> sets the size of the
array. It returns <command>0</command> in case of success,
<command>-1</command> in case of failure.
</para>
<example>
<title>preallocating carray</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
#include <stdlib.h>
#define SIZE 50
#define NEWSIZE 200
int main(void)
{
carray * a;
unsigned int i;
char p[500];
a = carray_new(SIZE);
if (a == NULL)
goto err;
r = carray_set_size(NEWSIZE);
if (r < 0)
goto free;
for(i = 0 ; i < NEWSIZE ; i ++)
carray_set(a, i, &p[i]);
/* do things here */
carray_free(a);
exit(EXIT_SUCESS);
free:
carray_free(a);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<!-- carray_count, carray_add, carray_get and carray_set -->
<sect2 id="carray-count">
<title>carray_count, carray_add, carray_get and carray_set</title>
<programlisting role="C">
int carray_count(carray);
int carray_add(carray * array, void * data, unsigned int * index);
void * carray_get(carray * array, unsigned int indx);
void carray_set(carray * array, unsigned int indx, void * value);
</programlisting>
<para>
<command>carray_count()</command> returns the number of
elements in the <command>carray</command>.
Complexity is O(1).
</para>
<para>
<command>carray_add()</command>adds an element at the end of
the array. The <command>index</command> of the element is
returns in <command>(* index)</command> if
<command>index</command> is not <command>NULL</command>. It
returns <command>0</command> in case of success,
<command>-1</command> in case of failure.
Complexity is O(1).
</para>
<para>
<command>carray_get()</command> returns the elements contained
at the given cell of the table.
Complexity is O(1).
</para>
<para>
<command>carray_set()</command> replace the element at the
given index of table table with the given value.
Complexity is O(1).
</para>
<example>
<title>carray access</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
#include <string.h>
#define SIZE 50
int main(void)
{
carray * a;
int r;
a = carray_new(SIZE);
if (a == NULL)
goto err;
r = carray_add(a, "foo-bar-1", NULL);
if (r < 0)
goto free;
carray_add(a, "foo-bar-2", NULL);
if (r < 0)
goto free;
carray_add(a, "foo-bar-3", NULL);
if (r < 0)
goto free;
for(i = 0 ; i < carray_count(a) ; i ++) {
char * str;
str = carray_get(a, i);
if (strcmp("foo-bar-2", str) == 0)
carray_set(a, i, "foo-bar-2-replacement");
printf("%s\n", str);
}
carray_free(a);
exit(EXIT_SUCESS);
free:
carray_free(a);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<!-- carray_delete -->
<sect2 id="carray-delete">
<title>carray_delete</title>
<programlisting role="C">
int carray_delete(carray * array, uint32_t indx);
int carray_delete_slow(carray * array, uint32_t indx);
int carray_delete_fast(carray * array, uint32_t indx);
</programlisting>
<para>
<command>carray_delete()</command> removes an element of the
table. Order will not be garanteed. The returned result can
be ignored.
Complexity is O(1).
</para>
<para>
<command>carray_delete_slow()</command> removes an element of
the table. Order will be garanteed. The returned result can
be ignored.
Complexity is O(n).
</para>
<para>
<command>carray_delete_fast()</command> the element will just
be replaced with <command>NULL</command>. Order will be kept
but the number of elements will remains the same. The
returned result can be ignored.
Complexity is O(1).
</para>
<example>
<title>deletion in carray</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
#define SIZE 50
carray * build_array(void)
{
carray * a;
a = carray_new(SIZE);
if (a == NULL)
goto err;
r = carray_add(a, "foo-bar-1", NULL);
if (r < 0)
goto free;
carray_add(a, "foo-bar-2", NULL);
if (r < 0)
goto free;
carray_add(a, "foo-bar-3", NULL);
if (r < 0)
goto free;
return a;
free:
carray_free(a);
err:
exit(EXIT_FAILURE);
}
void delete(carray * a)
{
/* deleting foo-bar-1 */
carray_delete(a, 0);
/* resulting size is 2, order of elements is undefined */
}
void delete_slow(carray * a)
{
/* deleting foo-bar-1 */
carray_delete_slow(a, 0);
/* resulting size is 2, order of elements is the same */
}
void delete_fast(carray * a)
{
/* deleting foo-bar-1 */
carray_delete_slow(a, 0);
/*
resulting size is 3,
order of elements is { NULL, foo-bar-2, foo-bar-3 }
*/
}
</programlisting>
</example>
</sect2>
<!-- carray_data -->
<sect2 id="carray-data">
<title>carray_data</title>
<programlisting role="C">
void ** carray_data(carray);
</programlisting>
<para>
<command>carray_data</command>returns the table used for
implementation :
<command>(void **)</command>.
</para>
</sect2>
</sect1>
<!-- List -->
<sect1 id="clist">
<title>List</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
typedef struct clist_s clist;
typedef clistcell clistiter;
</programlisting>
<para>
<command>clist()</command> is a list of cells.
Each cell of the list contains one element. This element is a
pointer. An iterator (<command>clistiter</command>) is a
pointer to an element of the list. With an iterator, we can
get the previous element of the list, the next element of the
list and the content of the element.
</para>
<sect2 id="clist-new">
<title>clist_new and clist_free</title>
<programlisting role="C">
clist * clist_new(void);
void clist_free(clist *);
</programlisting>
<para>
<command>clist_new()</command> allocates a new empty list and
returns it.
</para>
<para>
<command>clist_free()</command> frees the entire list with
its cells.
</para>
<example>
<title>clist creation</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
int main(void)
{
clist * list;
list = clist_new();
if (list == NULL)
goto err;
r = clist_append(list, "foo-bar");
if (r < 0)
clist_free(list);
exit(EXIT_SUCCESS);
free:
clist_free(list);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<sect2 id="clist-count">
<title>clist_isempty and clist_count</title>
<programlisting role="C">
int clist_isempty(clist *);
int clist_count(clist *);
</programlisting>
<para>
<command>clist_isempty()</command> returns 1 if the list is
empty, else it is 0.
Complexity is O(1).
</para>
<para>
<command>clist_count()</command> returns the number of
elements in the list.
Complexity is O(1).
</para>
</sect2>
<sect2 id="clist-begin">
<title>running through clist</title>
<programlisting role="C">
clistiter * clist_begin(clist *);
clistiter * clist_end(clist *);
clistiter * clist_next(clistiter *);
clistiter * clist_previous(clistiter *);
void * clist_content(clistiter *);
void * clist_nth_data(clist * lst, int index);
clistiter * clist_nth(clist * lst, int index);
</programlisting>
<para>
<command>clist_begin()</command> returns an iterator to the
first element of the list.
Complexity is O(1).
</para>
<para>
<command>clist_end()</command> returns an iterator to the last
element of the list.
Complexity is O(1).
</para>
<para>
<command>clist_next()</command> returns an iterator to the
next element of the list.
Complexity is O(1).
</para>
<para>
<command>clist_previous()</command> returns an iterator to the
previous element of the list.
Complexity is O(1).
</para>
<para>
<command>clist_content()</command> returns the element
contained in the cell pointed by the iterator in the list.
Complexity is O(1).
</para>
<para>
<command>clist_nth()</command> returns an iterator on the
<command>index</command>-th element of the list.
Complexity is O(n).
</para>
<para>
<command>clist_nth_data()</command> returns the index-th
element of the list.
Complexity is O(n).
</para>
<example>
<title>displaying content of clist</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
int main(void)
{
clist * list;
clistiter * iter;
list = build_string_list();
if (list == NULL)
goto err;
for(iter = clist_begin(list) ; iter != NULL ; iter =
clist_next(iter)) {
char * str;
str = clist_content(iter);
printf("%s\n", str);
}
clist_free(list);
exit(EXIT_SUCCESS);
free:
clist_free(list);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<sect2 id="clist-append">
<title>clist modification</title>
<programlisting role="C">
int clist_prepend(clist *, void *);
int clist_append(clist *, void *);
int clist_insert_before(clist *, clistiter *, void *);
int clist_insert_after(clist *, clistiter *, void *);
clistiter * clist_delete(clist *, clistiter *);
</programlisting>
<para>
<command>clist_prepend()</command> adds an element at the
beginning of the list. Returns 0 on sucess, -1 on error.
Complexity is O(1).
</para>
<para>
<command>clist_append()</command> adds an element at the end
of the list. Returns 0 on sucess, -1 on error.
Complexity is O(1).
</para>
<para>
<command>clist_insert_before()</command> adds an element
before the element pointed by the given iterator in the
list. Returns 0 on sucess, -1 on error.
Complexity is O(1).
</para>
<para>
<command>clist_insert_after()</command> adds an element after
the element pointed by the given iterator in the list.
Returns 0 on sucess, -1 on error.
Complexity is O(1).
</para>
<para>
<command>clist_delete()</command> the elements pointed by
the given iterator in the list and returns an iterator to
the next element of the list.
Complexity is O(1).
</para>
<example>
<title>deleting elements in a clist</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
voir print_content(void * content, void * user_data)
{
char * str;
str = content;
printf("%s\n", str);
}
int main(void)
{
clist * list;
clistiter * iter;
list = build_string_list();
if (list == NULL)
goto err;
iter = = clist_begin(list);
while (iter != NULL)
char * str;
str = clist_content(iter);
if (strcmp(str, "foo-bar") == 0)
iter = clist_delete(list, cur);
else
iter = clist_next(iter);
}
clist_foreach(list, print_content, NULL);
printf("\n");
clist_free(list);
exit(EXIT_SUCCESS);
free:
clist_free(list);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<sect2 id="clist-foreach">
<title>clist_foreach</title>
<programlisting role="C">
typedef void (* clist_func)(void *, void *);
void clist_foreach(clist * lst, clist_func func, void * data);
</programlisting>
<para>
<command>clist_foreach()</command> apply a fonction to each
element of the list.
Complexity is O(n).
</para>
</sect2>
<sect2 id="clist-concat">
<title>clist_concat</title>
<programlisting role="C">
void clist_concat(clist * dest, clist * src);
</programlisting>
<para>
<command>clist_concat()</command> adds all the elements of src
at the end of dest. Elements are added in the same
order. src is an empty list when the operation is finished.
Complexity is O(1).
</para>
<example>
<title>merging two clists</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
int main(void)
{
clist * list;
clist * list_2;
clistiter * iter;
list = build_string_list();
if (list == NULL)
goto err;
list_2 = build_string_list_2();
if (list == NULL)
goto free_list;
clist_concat(list, list_2);
clist_free(list_2);
for(iter = clist_begin(list) ; iter != NULL ; iter =
clist_next(iter)) {
char * str;
str = clist_content(iter);
printf("%s\n", str);
}
clist_free(list);
exit(EXIT_SUCCESS);
free_list:
clist_free(list);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
</sect1>
<!-- Hash -->
<sect1>
<title>Hash table</title>
<programlisting role="C">
#include <libetpan/libetpan.h>
typedef struct chash chash;
typedef struct chashcell chashiter;
typedef struct {
char * data;
int len;
} chashdatum;
</programlisting>
<para>
<command>chash</command> is a hash table.
<command>chashiter</command> is a pointer to an element of the
hash table.
<command>chashdatum</command> is an element to be placed in
the hash table as a key or a value. It consists in
data and a corresponding length.
</para>
<sect2 id="chash-new">
<title>chash_new and chash_free</title>
<programlisting role="C">
#define CHASH_COPYNONE 0
#define CHASH_COPYKEY 1
#define CHASH_COPYVALUE 2
#define CHASH_COPYALL (CHASH_COPYKEY | CHASH_COPYVALUE)
chash * chash_new(int size, int flags);
void chash_free(chash * hash);
</programlisting>
<para>
<command>chash_new()</command> returns a new empty hash table
or <command>NULL</command> if this
failed. <command>size</command> is the initial size of the
table used for implementation. <command>flags</command> can
be a combinaison of <command>CHASH_COPYKEY</command> and
<command>CHASH_COPYVALUE</command>.
<command>CHASH_COPYKEY</command> enables copy of key, so
that the initial value used for <command>chash_set()</command>
</para>
<para>
<command>chash_free()</command> releases memory used by the
hash table.
</para>
</sect2>
<sect2 id="chash-get">
<title>chash_set and chash_get</title>
<programlisting role="C">
int chash_set(chash * hash,
chashdatum * key, chashdatum * value, chashdatum * oldvalue);
int chash_get(chash * hash,
chashdatum * key, chashdatum * result);
</programlisting>
<para>
<command>chash_set()</command> adds a new element into the
hash table. If a previous element had the same key, it is
returns into oldvalue if <command>oldvalue</command> is
different of NULL.
Medium complexity is O(1).
</para>
<para>
returns -1 if it fails, 0 on success.
</para>
<para>
<command>chash_get()</command>returns the corresponding value
of the given key. If there is no corresponding value, -1 is
returned. 0 on success.
Medium complexity is O(1).
</para>
<example>
<title>chash insert and lookup</title>
<programlisting role="C">
int main(void)
{
chash * hash;
int r;
chashdatum key;
chashdatum value;
char * str1 = "my-data";
char * str2 = "my-data";
hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYNONE);
key.data = "foo";
key.len = strlen("foo");
value.data = str1;
value.data = strlen(str1) + 1;
/* + 1 is needed to get the terminal zero in the returned string */
r = chash_set(hash, &key, &value, NULL);
if (r < 0)
goto free_hash;
key.data = "bar";
key.len = strlen("bar");
value.data = str2;
value.data = strlen(str2) + 1;
if (r < 0)
goto free_hash;
key.data = "foo";
key.len = strlen("foo");
r = chash_get(hash, &key, &value);
if (r < 0) {
printf("element not found\n");
}
else {
char * str;
str = value.data;
printf("found : %s", str);
}
chash_free(hash);
exit(EXIT_SUCCESS);
free_hash:
chash_free(hash);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<sect2 id="chash-delete">
<title>chash_delete</title>
<programlisting role="C">
int chash_delete(chash * hash,
chashdatum * key, chashdatum * oldvalue);
</programlisting>
<para>
deletes the key/value pair given the corresponding key.
The value is returned in old_value.
If there is no corresponding value, -1 is returned. 0 on success.
Medium complexity is O(1).
</para>
<example>
<title>key deletion in a chash</title>
<programlisting role="C">
int main(void)
{
chash * hash;
int r;
chashdatum key;
chashdatum value;
char * str1 = "my-data";
char * str2 = "my-data";
hash = build_hash();
key.data = "foo";
key.len = strlen("foo");
chash_delete(hash, &key, &value);
/* it will never be possible to lookup "foo" */
key.data = "foo";
key.len = strlen("foo");
r = chash_get(hash, &key, &value);
if (r < 0) {
printf("element not found\n");
}
else {
char * str;
str = value.data;
printf("found : %s", str);
}
chash_free(hash);
exit(EXIT_SUCCESS);
free_hash:
chash_free(hash);
err:
exit(EXIT_FAILURE);
}
</programlisting>
</example>
</sect2>
<sect2 id="chash-resize">
<title>chash_resize</title>
<programlisting role="C">
int chash_resize(chash * hash, int size);
</programlisting>
<para>
<command>chash_resize()</command> changes the size of the
table used for implementation of the hash table.
returns 0 on success, -1 on failure.
</para>
</sect2>
<sect2 id="chash-begin">
<title>running through the chash</title>
<programlisting role="C">
chashiter * chash_begin(chash * hash);
chashiter * chash_next(chash * hash, chashiter * iter);
void chash_key(chashiter * iter, chashdatum * result);
void chash_value(chashiter iter, chashdatum * result);
</programlisting>
<para>
<command>chash_begin()</command> returns a pointer to the
first element of the hash table. Returns
<command>NULL</command> if there is no elements in the hash
table.
Complexity is O(n).
</para>
<para>
<command>chash_next()</command> returns a pointer to the next
element of the hash table. Returns <command>NULL</command>
if there is no next element.
Complexity is O(n) but n calls to chash_next() also has
a complexity of O(n).
</para>
<para>
<command>chash_key()</command> returns the key of the given
element of the hash table.
</para>
<para>
<command>chash_value</command> returns the value of the
given element of the hash table.
</para>
<example>
<title>running through a chash</title>
<programlisting role="C">
int main(void)
{
chash * hash;
int r;
chashiter * iter;
hash = build_hash();
/* this will display all the values stored in the hash */
for(iter = chash_begin(hash) ; iter != NULL ; iter =
chash_next(hash, iter)) {
chashdatum key;
chashdatum value;
char * str;