ruby_odeum 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/COPYING +504 -0
  2. data/LICENSE +504 -0
  3. data/README +50 -0
  4. data/bin/odeum_mgr +106 -0
  5. data/doc/rdoc/classes/Odeum.html +235 -0
  6. data/doc/rdoc/classes/Odeum.src/M000010.html +25 -0
  7. data/doc/rdoc/classes/Odeum.src/M000011.html +22 -0
  8. data/doc/rdoc/classes/Odeum.src/M000012.html +27 -0
  9. data/doc/rdoc/classes/Odeum.src/M000013.html +27 -0
  10. data/doc/rdoc/classes/Odeum.src/M000014.html +28 -0
  11. data/doc/rdoc/classes/Odeum/Document.html +382 -0
  12. data/doc/rdoc/classes/Odeum/Document.src/M000040.html +25 -0
  13. data/doc/rdoc/classes/Odeum/Document.src/M000041.html +22 -0
  14. data/doc/rdoc/classes/Odeum/Document.src/M000042.html +23 -0
  15. data/doc/rdoc/classes/Odeum/Document.src/M000043.html +23 -0
  16. data/doc/rdoc/classes/Odeum/Document.src/M000044.html +24 -0
  17. data/doc/rdoc/classes/Odeum/Document.src/M000045.html +32 -0
  18. data/doc/rdoc/classes/Odeum/Document.src/M000046.html +22 -0
  19. data/doc/rdoc/classes/Odeum/Document.src/M000047.html +22 -0
  20. data/doc/rdoc/classes/Odeum/Document.src/M000048.html +22 -0
  21. data/doc/rdoc/classes/Odeum/Document.src/M000049.html +22 -0
  22. data/doc/rdoc/classes/Odeum/Document.src/M000050.html +24 -0
  23. data/doc/rdoc/classes/Odeum/Document.src/M000051.html +27 -0
  24. data/doc/rdoc/classes/Odeum/Index.html +662 -0
  25. data/doc/rdoc/classes/Odeum/Index.src/M000015.html +46 -0
  26. data/doc/rdoc/classes/Odeum/Index.src/M000016.html +33 -0
  27. data/doc/rdoc/classes/Odeum/Index.src/M000017.html +35 -0
  28. data/doc/rdoc/classes/Odeum/Index.src/M000018.html +23 -0
  29. data/doc/rdoc/classes/Odeum/Index.src/M000019.html +22 -0
  30. data/doc/rdoc/classes/Odeum/Index.src/M000020.html +22 -0
  31. data/doc/rdoc/classes/Odeum/Index.src/M000021.html +22 -0
  32. data/doc/rdoc/classes/Odeum/Index.src/M000022.html +22 -0
  33. data/doc/rdoc/classes/Odeum/Index.src/M000023.html +22 -0
  34. data/doc/rdoc/classes/Odeum/Index.src/M000024.html +29 -0
  35. data/doc/rdoc/classes/Odeum/Index.src/M000025.html +23 -0
  36. data/doc/rdoc/classes/Odeum/Index.src/M000026.html +24 -0
  37. data/doc/rdoc/classes/Odeum/Index.src/M000027.html +23 -0
  38. data/doc/rdoc/classes/Odeum/Index.src/M000028.html +26 -0
  39. data/doc/rdoc/classes/Odeum/Index.src/M000029.html +24 -0
  40. data/doc/rdoc/classes/Odeum/Index.src/M000030.html +20 -0
  41. data/doc/rdoc/classes/Odeum/Index.src/M000031.html +22 -0
  42. data/doc/rdoc/classes/Odeum/Index.src/M000032.html +22 -0
  43. data/doc/rdoc/classes/Odeum/Index.src/M000033.html +22 -0
  44. data/doc/rdoc/classes/Odeum/Index.src/M000034.html +22 -0
  45. data/doc/rdoc/classes/Odeum/Index.src/M000035.html +20 -0
  46. data/doc/rdoc/classes/Odeum/Index.src/M000036.html +20 -0
  47. data/doc/rdoc/classes/Odeum/Index.src/M000037.html +22 -0
  48. data/doc/rdoc/classes/Odeum/Index.src/M000038.html +22 -0
  49. data/doc/rdoc/classes/Odeum/Index.src/M000039.html +22 -0
  50. data/doc/rdoc/classes/OdeumTest.html +257 -0
  51. data/doc/rdoc/classes/OdeumTest.src/M000001.html +18 -0
  52. data/doc/rdoc/classes/OdeumTest.src/M000002.html +19 -0
  53. data/doc/rdoc/classes/OdeumTest.src/M000003.html +27 -0
  54. data/doc/rdoc/classes/OdeumTest.src/M000004.html +25 -0
  55. data/doc/rdoc/classes/OdeumTest.src/M000005.html +44 -0
  56. data/doc/rdoc/classes/OdeumTest.src/M000006.html +20 -0
  57. data/doc/rdoc/classes/OdeumTest.src/M000007.html +39 -0
  58. data/doc/rdoc/classes/OdeumTest.src/M000008.html +59 -0
  59. data/doc/rdoc/classes/OdeumTest.src/M000009.html +41 -0
  60. data/doc/rdoc/created.rid +1 -0
  61. data/doc/rdoc/files/COPYING.html +756 -0
  62. data/doc/rdoc/files/LICENSE.html +756 -0
  63. data/doc/rdoc/files/README.html +175 -0
  64. data/doc/rdoc/files/ext/odeum_index/odeum_index_c.html +101 -0
  65. data/doc/rdoc/files/test/test_odeum_rb.html +109 -0
  66. data/doc/rdoc/fr_class_index.html +30 -0
  67. data/doc/rdoc/fr_file_index.html +31 -0
  68. data/doc/rdoc/fr_method_index.html +77 -0
  69. data/doc/rdoc/index.html +24 -0
  70. data/doc/rdoc/rdoc-style.css +208 -0
  71. data/ext/odeum_index/cabin.c +2735 -0
  72. data/ext/odeum_index/cabin.h +1040 -0
  73. data/ext/odeum_index/curia.c +1114 -0
  74. data/ext/odeum_index/curia.h +430 -0
  75. data/ext/odeum_index/depot.c +1910 -0
  76. data/ext/odeum_index/depot.h +439 -0
  77. data/ext/odeum_index/extconf.rb +10 -0
  78. data/ext/odeum_index/myconf.c +668 -0
  79. data/ext/odeum_index/myconf.h +523 -0
  80. data/ext/odeum_index/odeum.c +1743 -0
  81. data/ext/odeum_index/odeum.h +541 -0
  82. data/ext/odeum_index/odeum_index.c +991 -0
  83. data/ext/odeum_index/villa.c +1923 -0
  84. data/ext/odeum_index/villa.h +470 -0
  85. data/ext/odeum_index/vista.c +159 -0
  86. data/ext/odeum_index/vista.h +111 -0
  87. data/test/test_odeum.rb +174 -0
  88. metadata +138 -0
@@ -0,0 +1,1040 @@
1
+ /*************************************************************************************************
2
+ * The utitlity API of QDBM
3
+ * Copyright (C) 2000-2005 Mikio Hirabayashi
4
+ * This file is part of QDBM, Quick Database Manager.
5
+ * QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
6
+ * Lesser General Public License as published by the Free Software Foundation; either version
7
+ * 2.1 of the License or any later version. QDBM is distributed in the hope that it will be
8
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10
+ * details.
11
+ * You should have received a copy of the GNU Lesser General Public License along with QDBM; if
12
+ * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
13
+ * 02111-1307 USA.
14
+ *************************************************************************************************/
15
+
16
+
17
+ #ifndef _CABIN_H /* duplication check */
18
+ #define _CABIN_H
19
+
20
+ #if defined(__cplusplus) /* export for C++ */
21
+ extern "C" {
22
+ #endif
23
+
24
+
25
+ #include <stdlib.h>
26
+ #include <time.h>
27
+
28
+
29
+
30
+ /*************************************************************************************************
31
+ * API
32
+ *************************************************************************************************/
33
+
34
+
35
+ typedef struct { /* type of structure for a basic datum */
36
+ char *dptr; /* pointer to the region */
37
+ int dsize; /* size of the region */
38
+ int asize; /* size of the allocated region */
39
+ } CBDATUM;
40
+
41
+ typedef struct { /* type of structure for an element of a list */
42
+ char *dptr; /* pointer to the region */
43
+ int dsize; /* size of the effective region */
44
+ } CBLISTDATUM;
45
+
46
+ typedef struct { /* type of structure for a list */
47
+ CBLISTDATUM *array; /* array of data */
48
+ int anum; /* number of the elements of the array */
49
+ int start; /* start index of using elements */
50
+ int num; /* number of using elements */
51
+ } CBLIST;
52
+
53
+ typedef struct { /* type of structure for an element of a map */
54
+ char *kbuf; /* pointer to the region of the key */
55
+ int ksiz; /* size of the region of the key */
56
+ char *vbuf; /* pointer to the region of the value */
57
+ int vsiz; /* size of the region of the value */
58
+ int hash; /* second hash value */
59
+ char *left; /* pointer to the left child */
60
+ char *right; /* pointer to the right child */
61
+ char *prev; /* pointer to the previous element */
62
+ char *next; /* pointer to the next element */
63
+ } CBMAPDATUM;
64
+
65
+ typedef struct { /* type of structure for a map */
66
+ CBMAPDATUM **buckets; /* bucket array */
67
+ CBMAPDATUM *first; /* pointer to the first element */
68
+ CBMAPDATUM *last; /* pointer to the last element */
69
+ CBMAPDATUM *cur; /* pointer to the current element */
70
+ int bnum; /* number of buckets */
71
+ int rnum; /* number of records */
72
+ } CBMAP;
73
+
74
+
75
+ /* Call back function for handling a fatal error.
76
+ The argument specifies the error message. The initial value of this variable is `NULL'.
77
+ If the value is `NULL', the default function is called when a fatal error occurs. A fatal
78
+ error occurs when memory allocation is failed. */
79
+ extern void (*cbfatalfunc)(const char *);
80
+
81
+
82
+ /* Allocate a region on memory.
83
+ `size' specifies the size of the region.
84
+ The return value is the pointer to the allocated region.
85
+ Because the region of the return value is allocated with the `malloc' call, it should be
86
+ released with the `free' call if it is no longer in use. */
87
+ void *cbmalloc(size_t size);
88
+
89
+
90
+ /* Re-allocate a region on memory.
91
+ `ptr' specifies the pointer to a region.
92
+ `size' specifies the size of the region.
93
+ The return value is the pointer to the re-allocated region.
94
+ Because the region of the return value is allocated with the `realloc' call, it should be
95
+ released with the `free' call if it is no longer in use. */
96
+ void *cbrealloc(void *ptr, size_t size);
97
+
98
+
99
+ /* Duplicate a region on memory.
100
+ `ptr' specifies the pointer to a region.
101
+ `size' specifies the size of the region. If it is negative, the size is assigned with
102
+ `strlen(ptr)'.
103
+ The return value is the pointer to the allocated region of the duplicate.
104
+ Because an additional zero code is appended at the end of the region of the return value,
105
+ the return value can be treated as a character string. Because the region of the return
106
+ value is allocated with the `malloc' call, it should be released with the `free' call if
107
+ it is no longer in use. */
108
+ char *cbmemdup(const char *ptr, int size);
109
+
110
+
111
+ /* Register the pointer or handle of an object to the global garbage collector.
112
+ `ptr' specifies the pointer or handle of an object.
113
+ `func' specifies the pointer to a function to release resources of the object. Its argument
114
+ is the pointer or handle of the object to release.
115
+ This function assures that resources of an object are released when the process exits
116
+ normally by returning from the `main' function or calling the `exit' function. */
117
+ void cbglobalgc(void *ptr, void (*func)(void *));
118
+
119
+
120
+ /* Exercise the global garbage collector explicitly.
121
+ Note that you should not use objects registered to the global garbage collector any longer
122
+ after calling this function. Because the global garbage collecter is initialized and you
123
+ can register new objects into it. */
124
+ void cbggcsweep(void);
125
+
126
+
127
+ /* Sort an array using insert sort.
128
+ `base' spacifies the pointer to an array.
129
+ `nmemb' specifies the number of elements of the array.
130
+ `size' specifies the size of each element.
131
+ `compar' specifies the pointer to comparing function. The two arguments specify the pointers
132
+ of elements. The comparing function should returns positive if the former is big, negative
133
+ if the latter is big, 0 if both are equal.
134
+ Insert sort is useful only if most elements have been sorted already. */
135
+ void cbisort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
136
+
137
+
138
+ /* Sort an array using shell sort.
139
+ `base' spacifies the pointer to an array.
140
+ `nmemb' specifies the number of elements of the array.
141
+ `size' specifies the size of each element.
142
+ `compar' specifies the pointer to comparing function. The two arguments specify the pointers
143
+ of elements. The comparing function should returns positive if the former is big, negative
144
+ if the latter is big, 0 if both are equal.
145
+ If most elements have been sorted, shell sort may be faster than heap sort or quick sort. */
146
+ void cbssort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
147
+
148
+
149
+ /* Sort an array using heap sort.
150
+ `base' spacifies the pointer to an array.
151
+ `nmemb' specifies the number of elements of the array.
152
+ `size' specifies the size of each element.
153
+ `compar' specifies the pointer to comparing function. The two arguments specify the pointers
154
+ of elements. The comparing function should returns positive if the former is big, negative
155
+ if the latter is big, 0 if both are equal.
156
+ Although heap sort is robust against bias of input, quick sort is faster in most cases. */
157
+ void cbhsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
158
+
159
+
160
+ /* Sort an array using quick sort.
161
+ `base' spacifies the pointer to an array.
162
+ `nmemb' specifies the number of elements of the array.
163
+ `size' specifies the size of each element.
164
+ `compar' specifies the pointer to comparing function. The two arguments specify the pointers
165
+ of elements. The comparing function should returns positive if the former is big, negative
166
+ if the latter is big, 0 if both are equal.
167
+ Being sensitive to bias of input, quick sort is the fastest sorting algorithm. */
168
+ void cbqsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
169
+
170
+
171
+ /* Compare two strings with case insensitive evaluation.
172
+ `astr' specifies the pointer of one string.
173
+ `astr' specifies the pointer of the other string.
174
+ The return value is positive if the former is big, negative if the latter is big, 0 if both
175
+ are equivalent.
176
+ Upper cases and lower cases of alphabets in ASCII code are not distinguished. */
177
+ int cbstricmp(const char *astr, const char *bstr);
178
+
179
+
180
+ /* Check whether a string begins with a key.
181
+ `str' specifies the pointer of a target string.
182
+ `key' specifies the pointer of a forward matching key string.
183
+ The return value is true if the target string begins with the key, else, it is false. */
184
+ int cbstrfwmatch(const char *str, const char *key);
185
+
186
+
187
+ /* Check whether a string begins with a key, with case insensitive evaluation.
188
+ `str' specifies the pointer of a target string.
189
+ `key' specifies the pointer of a forward matching key string.
190
+ The return value is true if the target string begins with the key, else, it is false.
191
+ Upper cases and lower cases of alphabets in ASCII code are not distinguished. */
192
+ int cbstrfwimatch(const char *str, const char *key);
193
+
194
+
195
+ /* Check whether a string ends with a key.
196
+ `str' specifies the pointer of a target string.
197
+ `key' specifies the pointer of a backward matching key string.
198
+ The return value is true if the target string ends with the key, else, it is false. */
199
+ int cbstrbwmatch(const char *str, const char *key);
200
+
201
+
202
+ /* Check whether a string ends with a key, with case insensitive evaluation.
203
+ `str' specifies the pointer of a target string.
204
+ `key' specifies the pointer of a backward matching key string.
205
+ The return value is true if the target string ends with the key, else, it is false.
206
+ Upper cases and lower cases of alphabets in ASCII code are not distinguished. */
207
+ int cbstrbwimatch(const char *str, const char *key);
208
+
209
+
210
+ /* Convert the letters of a string to upper case.
211
+ `str' specifies the pointer of a string to convert.
212
+ The return value is the pointer to the string. */
213
+ char *cbstrtoupper(char *str);
214
+
215
+
216
+ /* Convert the letters of a string to lower case.
217
+ `str' specifies the pointer of a string to convert.
218
+ The return value is the pointer to the string. */
219
+ char *cbstrtolower(char *str);
220
+
221
+
222
+ /* Cut the space characters at head or tail of a string.
223
+ `str' specifies the pointer of a string to convert.
224
+ The return value is the pointer to the string. */
225
+ char *cbstrtrim(char *str);
226
+
227
+
228
+ /* Get a datum handle.
229
+ `ptr' specifies the pointer to the region of the initial content. If it is `NULL', an empty
230
+ datum is created.
231
+ `size' specifies the size of the region. If it is negative, the size is assigned with
232
+ `strlen(ptr)'.
233
+ The return value is a datum handle. */
234
+ CBDATUM *cbdatumopen(const char *ptr, int size);
235
+
236
+
237
+ /* Copy a datum.
238
+ `datum' specifies a datum handle.
239
+ The return value is a new datum handle. */
240
+ CBDATUM *cbdatumdup(const CBDATUM *datum);
241
+
242
+
243
+ /* Free a datum handle.
244
+ `datum' specifies a datum handle.
245
+ Because the region of a closed handle is released, it becomes impossible to use the handle. */
246
+ void cbdatumclose(CBDATUM *datum);
247
+
248
+
249
+ /* Concatenate a datum and a region.
250
+ `datum' specifies a datum handle.
251
+ `ptr' specifies the pointer to the region to be appended.
252
+ `size' specifies the size of the region. If it is negative, the size is assigned with
253
+ `strlen(ptr)'. */
254
+ void cbdatumcat(CBDATUM *datum, const char *ptr, int size);
255
+
256
+
257
+ /* Get the pointer of the region of a datum.
258
+ `datum' specifies a datum handle.
259
+ The return value is the pointer of the region of a datum.
260
+ Because an additional zero code is appended at the end of the region of the return value,
261
+ the return value can be treated as a character string. */
262
+ const char *cbdatumptr(const CBDATUM *datum);
263
+
264
+
265
+ /* Get the size of the region of a datum.
266
+ `datum' specifies a datum handle.
267
+ The return value is the size of the region of a datum. */
268
+ int cbdatumsize(const CBDATUM *datum);
269
+
270
+
271
+ /* Change the size of the region of a datum.
272
+ `datum' specifies a datum handle.
273
+ `size' specifies the new size of the region.
274
+ If the new size is bigger than the one of old, the surplus region is filled with zero codes. */
275
+ void cbdatumsetsize(CBDATUM *datum, int size);
276
+
277
+
278
+ /* Convert a datum to an allocated region.
279
+ `datum' specifies a datum handle.
280
+ `sp' specifies the pointer to a variable to which the size of the region of the return
281
+ value is assigned. If it is `NULL', it is not used.
282
+ The return value is the pointer to the region of the datum.
283
+ Because an additional zero code is appended at the end of the region of the return value,
284
+ the return value can be treated as a character string. Because the region of the return
285
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
286
+ is no longer in use. Because the region of the original datam is released, it should not be
287
+ released again. */
288
+ char *cbdatumtomalloc(CBDATUM *datum, int *sp);
289
+
290
+
291
+ /* Get a list handle.
292
+ The return value is a list handle. */
293
+ CBLIST *cblistopen(void);
294
+
295
+
296
+ /* Copy a list.
297
+ `list' specifies a list handle.
298
+ The return value is a new list handle. */
299
+ CBLIST *cblistdup(const CBLIST *list);
300
+
301
+
302
+ /* Close a list handle.
303
+ `list' specifies a list handle.
304
+ Because the region of a closed handle is released, it becomes impossible to use the handle. */
305
+ void cblistclose(CBLIST *list);
306
+
307
+
308
+ /* Get the number of elements of a list.
309
+ `list' specifies a list handle.
310
+ The return value is the number of elements of the list. */
311
+ int cblistnum(const CBLIST *list);
312
+
313
+
314
+ /* Get the pointer to the region of an element.
315
+ `list' specifies a list handle.
316
+ `index' specifies the index of an element.
317
+ `sp' specifies the pointer to a variable to which the size of the region of the return
318
+ value is assigned. If it is `NULL', it is not used.
319
+ The return value is the pointer to the region of the value.
320
+ Because an additional zero code is appended at the end of the region of the return value,
321
+ the return value can be treated as a character string. If `index' is equal to or more than
322
+ the number of elements, the return value is `NULL'. */
323
+ const char *cblistval(const CBLIST *list, int index, int *sp);
324
+
325
+
326
+ /* Add an element at the end of a list.
327
+ `list' specifies a list handle.
328
+ `ptr' specifies the pointer to the region of an element.
329
+ `size' specifies the size of the region. If it is negative, the size is assigned with
330
+ `strlen(ptr)'. */
331
+ void cblistpush(CBLIST *list, const char *ptr, int size);
332
+
333
+
334
+ /* Remove an element of the end of a list.
335
+ `list' specifies a list handle.
336
+ `sp' specifies the pointer to a variable to which the size of the region of the return
337
+ value is assigned. If it is `NULL', it is not used.
338
+ The return value is the pointer to the region of the value.
339
+ Because an additional zero code is appended at the end of the region of the return value,
340
+ the return value can be treated as a character string. Because the region of the return
341
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
342
+ is no longer in use. If the list is empty, the return value is `NULL'. */
343
+ char *cblistpop(CBLIST *list, int *sp);
344
+
345
+
346
+ /* Add an element at the top of a list.
347
+ `list' specifies a list handle.
348
+ `ptr' specifies the pointer to the region of an element.
349
+ `size' specifies the size of the region. If it is negative, the size is assigned with
350
+ `strlen(ptr)'. */
351
+ void cblistunshift(CBLIST *list, const char *ptr, int size);
352
+
353
+
354
+ /* Remove an element of the top of a list.
355
+ `list' specifies a list handle.
356
+ `sp' specifies the pointer to a variable to which the size of the region of the return
357
+ value is assigned. If it is `NULL', it is not used.
358
+ The return value is the pointer to the region of the value.
359
+ Because an additional zero code is appended at the end of the region of the return value,
360
+ the return value can be treated as a character string. Because the region of the return
361
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
362
+ is no longer in use. If the list is empty, the return value is `NULL'. */
363
+ char *cblistshift(CBLIST *list, int *sp);
364
+
365
+
366
+ /* Add an element at the specified location of a list.
367
+ `list' specifies a list handle.
368
+ `index' specifies the index of an element.
369
+ `ptr' specifies the pointer to the region of the element.
370
+ `size' specifies the size of the region. If it is negative, the size is assigned with
371
+ `strlen(ptr)'. */
372
+ void cblistinsert(CBLIST *list, int index, const char *ptr, int size);
373
+
374
+
375
+ /* Remove an element at the specified location of a list.
376
+ `list' specifies a list handle.
377
+ `index' specifies the index of an element.
378
+ `sp' specifies the pointer to a variable to which the size of the region of the return
379
+ value is assigned. If it is `NULL', it is not used.
380
+ The return value is the pointer to the region of the value.
381
+ Because an additional zero code is appended at the end of the region of the return value,
382
+ the return value can be treated as a character string. Because the region of the return
383
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
384
+ is no longer in use. If `index' is equal to or more than the number of elements, no element
385
+ is removed and the return value is `NULL'. */
386
+ char *cblistremove(CBLIST *list, int index, int *sp);
387
+
388
+
389
+ /* Overwrite an element at the specified location of a list.
390
+ `list' specifies a list handle.
391
+ `index' specifies the index of an element.
392
+ `ptr' specifies the pointer to the region of the new content.
393
+ `size' specifies the size of the new content. If it is negative, the size is assigned with
394
+ `strlen(ptr)'.
395
+ If `index' is equal to or more than the number of elements, this function has no effect. */
396
+ void cblistover(CBLIST *list, int index, const char *ptr, int size);
397
+
398
+
399
+ /* Sort elements of a list in lexical order.
400
+ `list' specifies a list handle.
401
+ Quick sort is used for sorting. */
402
+ void cblistsort(CBLIST *list);
403
+
404
+
405
+ /* Search a list for an element using liner search.
406
+ `list' specifies a list handle.
407
+ `ptr' specifies the pointer to the region of a key.
408
+ `size' specifies the size of the region. If it is negative, the size is assigned with
409
+ `strlen(ptr)'.
410
+ The return value is the index of a corresponding element or -1 if there is no corresponding
411
+ element. If two or more elements corresponds, the former returns. */
412
+ int cblistlsearch(const CBLIST *list, const char *ptr, int size);
413
+
414
+
415
+ /* Search a list for an element using binary search.
416
+ `list' specifies a list handle. It should be sorted in lexical order.
417
+ `ptr' specifies the pointer to the region of a key.
418
+ `size' specifies the size of the region. If it is negative, the size is assigned with
419
+ `strlen(ptr)'.
420
+ The return value is the index of a corresponding element or -1 if there is no corresponding
421
+ element. If two or more elements corresponds, which returns is not defined. */
422
+ int cblistbsearch(const CBLIST *list, const char *ptr, int size);
423
+
424
+
425
+ /* Serialize a list into a byte array.
426
+ `list' specifies a list handle.
427
+ `sp' specifies the pointer to a variable to which the size of the region of the return
428
+ value is assigned.
429
+ The return value is the pointer to the region of the result serial region.
430
+ Because the region of the return value is allocated with the `malloc' call, it should be
431
+ released with the `free' call if it is no longer in use. */
432
+ char *cblistdump(const CBLIST *list, int *sp);
433
+
434
+
435
+ /* Redintegrate a serialized list.
436
+ `ptr' specifies the pointer to a byte array.
437
+ `size' specifies the size of the region.
438
+ The return value is a new list handle. */
439
+ CBLIST *cblistload(const char *ptr, int size);
440
+
441
+
442
+ /* Get a map handle.
443
+ The return value is a map handle. */
444
+ CBMAP *cbmapopen(void);
445
+
446
+
447
+ /* Copy a map.
448
+ `map' specifies a map handle.
449
+ The return value is a new map handle.
450
+ The iterator of the source map is initialized. */
451
+ CBMAP *cbmapdup(CBMAP *map);
452
+
453
+
454
+ /* Close a map handle.
455
+ `map' specifies a map handle.
456
+ Because the region of a closed handle is released, it becomes impossible to use the handle. */
457
+ void cbmapclose(CBMAP *map);
458
+
459
+
460
+ /* Store a record.
461
+ `map' specifies a map handle.
462
+ `kbuf' specifies the pointer to the region of a key.
463
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
464
+ with `strlen(kbuf)'.
465
+ `vbuf' specifies the pointer to the region of a value.
466
+ `vsiz' specifies the size of the region of the value. If it is negative, the size is
467
+ assigned with `strlen(vbuf)'.
468
+ `over' specifies whether the value of the duplicated record is overwritten or not.
469
+ If `over' is false and the key is duplicated, the return value is false, else, it is true. */
470
+ int cbmapput(CBMAP *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int over);
471
+
472
+
473
+ /* Concatenate a value at the end of the value of the existing record.
474
+ `map' specifies a map handle.
475
+ `kbuf' specifies the pointer to the region of a key.
476
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
477
+ with `strlen(kbuf)'.
478
+ `vbuf' specifies the pointer to the region of a value.
479
+ `vsiz' specifies the size of the region of the value. If it is negative, the size is
480
+ assigned with `strlen(vbuf)'.
481
+ If there is no corresponding record, a new record is created. */
482
+ void cbmapputcat(CBMAP *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz);
483
+
484
+
485
+ /* Delete a record.
486
+ `map' specifies a map handle.
487
+ `kbuf' specifies the pointer to the region of a key.
488
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
489
+ with `strlen(kbuf)'.
490
+ If successful, the return value is true. False is returned when no record corresponds to
491
+ the specified key. */
492
+ int cbmapout(CBMAP *map, const char *kbuf, int ksiz);
493
+
494
+
495
+ /* Retrieve a record.
496
+ `map' specifies a map handle.
497
+ `kbuf' specifies the pointer to the region of a key.
498
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
499
+ with `strlen(kbuf)'.
500
+ `sp' specifies the pointer to a variable to which the size of the region of the return
501
+ value is assigned. If it is `NULL', it is not used.
502
+ If successful, the return value is the pointer to the region of the value of the
503
+ corresponding record. `NULL' is returned when no record corresponds.
504
+ Because an additional zero code is appended at the end of the region of the return value,
505
+ the return value can be treated as a character string. */
506
+ const char *cbmapget(const CBMAP *map, const char *kbuf, int ksiz, int *sp);
507
+
508
+
509
+ /* Move a record to the edge.
510
+ `map' specifies a map handle.
511
+ `kbuf' specifies the pointer to the region of a key.
512
+ `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned
513
+ with `strlen(kbuf)'.
514
+ `head' specifies the destination which is head if it is true or tail if else.
515
+ If successful, the return value is true. False is returned when no record corresponds to
516
+ the specified key. */
517
+ int cbmapmove(CBMAP *map, const char *kbuf, int ksiz, int head);
518
+
519
+
520
+ /* Initialize the iterator of a map handle.
521
+ `map' specifies a map handle.
522
+ The iterator is used in order to access the key of every record stored in a map. */
523
+ void cbmapiterinit(CBMAP *map);
524
+
525
+
526
+ /* Get the next key of the iterator.
527
+ `map' specifies a map handle.
528
+ `sp' specifies the pointer to a variable to which the size of the region of the return
529
+ value is assigned. If it is `NULL', it is not used.
530
+ If successful, the return value is the pointer to the region of the next key, else, it is
531
+ `NULL'. `NULL' is returned when no record is to be get out of the iterator.
532
+ Because an additional zero code is appended at the end of the region of the return value,
533
+ the return value can be treated as a character string. The order of iteration is assured
534
+ to be the same of the one of storing. */
535
+ const char *cbmapiternext(CBMAP *map, int *sp);
536
+
537
+
538
+ /* Get the number of the records stored in a map.
539
+ `map' specifies a map handle.
540
+ The return value is the number of the records stored in the map. */
541
+ int cbmaprnum(const CBMAP *map);
542
+
543
+
544
+ /* Get the list handle contains all keys in a map.
545
+ `map' specifies a map handle.
546
+ The return value is the list handle contains all keys in the map.
547
+ Because the handle of the return value is opened with the function `cblistopen', it should
548
+ be closed with the function `cblistclose' if it is no longer in use. */
549
+ CBLIST *cbmapkeys(CBMAP *map);
550
+
551
+
552
+ /* Get the list handle contains all values in a map.
553
+ `map' specifies a map handle.
554
+ The return value is the list handle contains all values in the map.
555
+ Because the handle of the return value is opened with the function `cblistopen', it should
556
+ be closed with the function `cblistclose' if it is no longer in use. */
557
+ CBLIST *cbmapvals(CBMAP *map);
558
+
559
+
560
+ /* Serialize a map into a byte array.
561
+ `map' specifies a map handle.
562
+ `sp' specifies the pointer to a variable to which the size of the region of the return
563
+ value is assigned.
564
+ The return value is the pointer to the region of the result serial region.
565
+ Because the region of the return value is allocated with the `malloc' call, it should be
566
+ released with the `free' call if it is no longer in use. */
567
+ char *cbmapdump(CBMAP *map, int *sp);
568
+
569
+
570
+ /* Redintegrate a serialized map.
571
+ `ptr' specifies the pointer to a byte array.
572
+ `size' specifies the size of the region.
573
+ The return value is a new map handle. */
574
+ CBMAP *cbmapload(const char *ptr, int size);
575
+
576
+
577
+ /* Allocate a formatted string on memory.
578
+ `format' specifies a printf-like format string. The conversion character `%' can be used
579
+ with such flag characters as `d', `o', `u', `x', `X', `e', `E', `f', `g', `G', `c', `s', and
580
+ `%'. Specifiers of the field length and the precision can be put between the conversion
581
+ characters and the flag characters. The specifiers consist of decimal characters, `.', `+',
582
+ `-', and the space character.
583
+ The other arguments are used according to the format string.
584
+ The return value is the pointer to the allocated region of the result string. Because the
585
+ region of the return value is allocated with the `malloc' call, it should be released with
586
+ the `free' call if it is no longer in use. */
587
+ char *cbsprintf(const char *format, ...);
588
+
589
+
590
+ /* Replace some patterns in a string.
591
+ `str' specifies the pointer to a source string.
592
+ `pairs' specifies the handle of a map composed of pairs of replacement. The key of each pair
593
+ specifies a pattern before replacement and its value specifies the pattern after replacement.
594
+ The return value is the pointer to the allocated region of the result string.
595
+ Because the region of the return value is allocated with the `malloc' call, it should be
596
+ released with the `free' call if it is no longer in use. */
597
+ char *cbreplace(const char *str, CBMAP *pairs);
598
+
599
+
600
+ /* Make a list by splitting a serial datum.
601
+ `ptr' specifies the pointer to the region of the source content.
602
+ `size' specifies the size of the region. If it is negative, the size is assigned with
603
+ `strlen(ptr)'.
604
+ `delim' specifies a string containing delimiting characters. If it is `NULL', zero code is
605
+ used as a delimiter.
606
+ The return value is a list handle.
607
+ If two delimiters are successive, it is assumed that an empty element is between the two.
608
+ Because the handle of the return value is opened with the function `cblistopen', it should
609
+ be closed with the function `cblistclose'. */
610
+ CBLIST *cbsplit(const char *ptr, int size, const char *delim);
611
+
612
+
613
+ /* Read whole data of a file.
614
+ `name' specifies the name of a file. If it is `NULL', the standard input is specified.
615
+ `sp' specifies the pointer to a variable to which the size of the region of the return
616
+ value is assigned. If it is `NULL', it is not used.
617
+ The return value is the pointer to the allocated region of the read data. Because an
618
+ additional zero code is appended at the end of the region of the return value, the return
619
+ value can be treated as a character string. Because the region of the return value is
620
+ allocated with the `malloc' call, it should be released with the `free' call if it is no
621
+ longer in use. */
622
+ char *cbreadfile(const char *name, int *sp);
623
+
624
+
625
+ /* Write a serial datum into a file.
626
+ `name specifies the name of a file. If it is `NULL', the standard output is specified.
627
+ `ptr' specifies the pointer to the region of the source content.
628
+ `size' specifies the size of the region. If it is negative, the size is assigned with
629
+ `strlen(ptr)'.
630
+ If successful, the return value is true, else, it is false.
631
+ If the file exists, it is overwritten. Else, a new file is created. */
632
+ int cbwritefile(const char *name, const char *ptr, int size);
633
+
634
+
635
+ /* Read every line of a file.
636
+ `name' specifies the name of a file. If it is `NULL', the standard input is specified.
637
+ The return value is a list handle of the lines if successful, else it is NULL. Line
638
+ separators are cut out. Because the handle of the return value is opened with the function
639
+ `cblistopen', it should be closed with the function `cblistclose' if it is no longer in use. */
640
+ CBLIST *cbreadlines(const char *name);
641
+
642
+
643
+ /* Read names of files in a directory.
644
+ `name' specifies the name of a directory.
645
+ The return value is a list handle of names if successful, else it is NULL.
646
+ Because the handle of the return value is opened with the function `cblistopen', it should
647
+ be closed with the function `cblistclose' if it is no longer in use. */
648
+ CBLIST *cbdirlist(const char *name);
649
+
650
+
651
+ /* Get the status of a file or a directory.
652
+ `name' specifies the name of a file or a directory.
653
+ `dirp' specifies the pointer to a variable to which whether the file is a directory is
654
+ assigned. If it is `NULL', it is not used.
655
+ `sizep' specifies the pointer to a variable to which the size of the file is assigned. If it
656
+ is `NULL', it is not used.
657
+ `mtimep' specifies the pointer to a variable to which the last modified time of the file is
658
+ assigned. If it is `NULL', it is not used.
659
+ If successful, the return value is true, else, false. False is returned when the file does
660
+ not exist or the permission is denied. */
661
+ int cbfilestat(const char *name, int *isdirp, int *sizep, int *mtimep);
662
+
663
+
664
+ /* Break up a URL into elements.
665
+ `str' specifies the pointer to a string of URL.
666
+ The return value is a map handle. Each key of the map is the name of an element. The key
667
+ "self" specifies the URL itself. The key "scheme" specifies the scheme. The key "host"
668
+ specifies the host of the server. The key "port" specifies the port number of the server.
669
+ The key "authority" specifies the authority information. The key "path" specifies the path
670
+ of the resource. The key "file" specifies the file name without the directory section. The
671
+ key "query" specifies the query string. The key "fragment" specifies the fragment string.
672
+ Supported schema are HTTP, HTTPS, FTP, and FILE. Absolute URL and relative URL are supported.
673
+ Because the handle of the return value is opened with the function `cbmapopen', it should
674
+ be closed with the function `cbmapclose' if it is no longer in use. */
675
+ CBMAP *cburlbreak(const char *str);
676
+
677
+
678
+ /* Encode a serial object with URL encoding.
679
+ `ptr' specifies the pointer to a region.
680
+ `size' specifies the size of the region. If it is negative, the size is assigned with
681
+ `strlen(ptr)'.
682
+ The return value is the pointer to the result string.
683
+ Because the region of the return value is allocated with the `malloc' call, it should be
684
+ released with the `free' call if it is no longer in use. */
685
+ char *cburlencode(const char *ptr, int size);
686
+
687
+
688
+ /* Decode a string encoded with URL encoding.
689
+ `str' specifies the pointer to an encoded string.
690
+ `sp' specifies the pointer to a variable to which the size of the region of the return
691
+ value is assigned. If it is `NULL', it is not used.
692
+ The return value is the pointer to the region of the result.
693
+ Because an additional zero code is appended at the end of the region of the return value,
694
+ the return value can be treated as a character string. Because the region of the return
695
+ value is allocated with the `malloc' call, it should be released with the `free' call if
696
+ it is no longer in use. */
697
+ char *cburldecode(const char *str, int *sp);
698
+
699
+
700
+ /* Encode a serial object with Base64 encoding.
701
+ `ptr' specifies the pointer to a region.
702
+ `size' specifies the size of the region. If it is negative, the size is assigned with
703
+ `strlen(ptr)'.
704
+ The return value is the pointer to the result string.
705
+ Because the region of the return value is allocated with the `malloc' call, it should be
706
+ released with the `free' call if it is no longer in use. */
707
+ char *cbbaseencode(const char *ptr, int size);
708
+
709
+
710
+ /* Decode a string encoded with Base64 encoding.
711
+ `str' specifies the pointer to an encoded string.
712
+ `sp' specifies the pointer to a variable to which the size of the region of the return
713
+ value is assigned. If it is `NULL', it is not used.
714
+ The return value is the pointer to the region of the result.
715
+ Because an additional zero code is appended at the end of the region of the return value,
716
+ the return value can be treated as a character string. Because the region of the return
717
+ value is allocated with the `malloc' call, it should be released with the `free' call if
718
+ it is no longer in use. */
719
+ char *cbbasedecode(const char *str, int *sp);
720
+
721
+
722
+ /* Encode a serial object with quoted-printable encoding.
723
+ `ptr' specifies the pointer to a region.
724
+ `size' specifies the size of the region. If it is negative, the size is assigned with
725
+ `strlen(ptr)'.
726
+ The return value is the pointer to the result string.
727
+ Because the region of the return value is allocated with the `malloc' call, it should be
728
+ released with the `free' call if it is no longer in use. */
729
+ char *cbquoteencode(const char *ptr, int size);
730
+
731
+
732
+ /* Decode a string encoded with quoted-printable encoding.
733
+ `str' specifies the pointer to an encoded string.
734
+ `sp' specifies the pointer to a variable to which the size of the region of the return
735
+ value is assigned. If it is `NULL', it is not used.
736
+ The return value is the pointer to the region of the result.
737
+ Because an additional zero code is appended at the end of the region of the return value,
738
+ the return value can be treated as a character string. Because the region of the return
739
+ value is allocated with the `malloc' call, it should be released with the `free' call if
740
+ it is no longer in use. */
741
+ char *cbquotedecode(const char *str, int *sp);
742
+
743
+
744
+ /* Split a string of MIME into headers and the body.
745
+ `ptr' specifies the pointer to the region of MIME data.
746
+ `size' specifies the size of the region. If it is negative, the size is assigned with
747
+ `strlen(ptr)'.
748
+ `attrs' specifies a map handle to store attributes. If it is `NULL', it is not used. Each
749
+ key of the map is an attribute name uncapitalized.
750
+ `sp' specifies the pointer to a variable to which the size of the region of the return
751
+ value is assigned. If it is `NULL', it is not used.
752
+ The return value is the pointer of the body data.
753
+ If the content type is defined, the attribute map has the key "TYPE" specifying the type. If
754
+ the character encoding is defined, the key "CHARSET" specifies the encoding name. If the
755
+ boundary string of multipart is defined, the key "BOUNDARY" specifies the string. If the
756
+ content disposition is defined, the key "DISPOSITION" specifies the direction. If the file
757
+ name is defined, the key "FILENAME" specifies the name. If the attribute name is defined,
758
+ the key "NAME" specifies the name. Because the region of the return value is allocated with
759
+ the `malloc' call, it should be released with the `free' call if it is no longer in use. */
760
+ char *cbmimebreak(const char *ptr, int size, CBMAP *attrs, int *sp);
761
+
762
+
763
+ /* Split multipart data of MIME into its parts.
764
+ `ptr' specifies the pointer to the region of multipart data of MIME.
765
+ `size' specifies the size of the region. If it is negative, the size is assigned with
766
+ `strlen(ptr)'.
767
+ `boundary' specifies the pointer to the region of the boundary string.
768
+ The return value is a list handle. Each element of the list is the string of a part.
769
+ Because the handle of the return value is opened with the function `cblistopen', it should
770
+ be closed with the function `cblistclose' if it is no longer in use. */
771
+ CBLIST *cbmimeparts(const char *ptr, int size, const char *boundary);
772
+
773
+
774
+ /* Encode a string with MIME encoding.
775
+ `str' specifies the pointer to a string.
776
+ `encname' specifies a string of the name of the character encoding.
777
+ The return value is the pointer to the result string.
778
+ `base' specifies whether to use Base64 encoding. If it is false, quoted-printable is used.
779
+ Because the region of the return value is allocated with the `malloc' call, it should be
780
+ released with the `free' call if it is no longer in use. */
781
+ char *cbmimeencode(const char *str, const char *encname, int base);
782
+
783
+
784
+ /* Decode a string encoded with MIME encoding.
785
+ `str' specifies the pointer to an encoded string.
786
+ `enp' specifies the pointer to a region into which the name of encoding is written. If it is
787
+ `NULL', it is not used. The size of the buffer should be equal to or more than 32 bytes.
788
+ The return value is the pointer to the result string.
789
+ Because the region of the return value is allocated with the `malloc' call, it should be
790
+ released with the `free' call if it is no longer in use. */
791
+ char *cbmimedecode(const char *str, char *enp);
792
+
793
+
794
+ /* Split a string of CSV into rows.
795
+ `str' specifies the pointer to the region of an CSV string.
796
+ The return value is a list handle. Each element of the list is a string of a row.
797
+ Because the handle of the return value is opened with the function `cblistopen', it should
798
+ be closed with the function `cblistclose' if it is no longer in use. The character encoding
799
+ of the input string should be US-ASCII, UTF-8, ISO-8859-*, EUC-*, or Shift_JIS. Being
800
+ compatible with MS-Excel, these functions for CSV can handle cells including such meta
801
+ characters as comma, between double quotation marks. */
802
+ CBLIST *cbcsvrows(const char *str);
803
+
804
+
805
+ /* Split the string of a row of CSV into cells.
806
+ `str' specifies the pointer to the region of a row of CSV.
807
+ The return value is a list handle. Each element of the list is the unescaped string of a
808
+ cell of the row.
809
+ Because the handle of the return value is opened with the function `cblistopen', it should
810
+ be closed with the function `cblistclose' if it is no longer in use. */
811
+ CBLIST *cbcsvcells(const char *str);
812
+
813
+
814
+ /* Escape a string with the meta characters of CSV.
815
+ `str' specifies the pointer to the region of a string.
816
+ The return value is the pointer to the escaped string sanitized of meta characters.
817
+ Because the region of the return value is allocated with the `malloc' call, it should be
818
+ released with the `free' call if it is no longer in use. */
819
+ char *cbcsvescape(const char *str);
820
+
821
+
822
+ /* Unescape a string with the escaped meta characters of CSV.
823
+ `str' specifies the pointer to the region of a string with meta characters.
824
+ The return value is the pointer to the unescaped string.
825
+ Because the region of the return value is allocated with the `malloc' call, it should be
826
+ released with the `free' call if it is no longer in use. */
827
+ char *cbcsvunescape(const char *str);
828
+
829
+
830
+ /* Split a string of XML into tags and text sections.
831
+ `str' specifies the pointer to the region of an XML string.
832
+ `cr' specifies whether to remove comments.
833
+ The return value is a list handle. Each element of the list is the string of a tag or a
834
+ text section.
835
+ Because the handle of the return value is opened with the function `cblistopen', it should
836
+ be closed with the function `cblistclose' if it is no longer in use. The character encoding
837
+ of the input string should be US-ASCII, UTF-8, ISO-8859-*, EUC-*, or Shift_JIS. Because
838
+ these functions for XML are not XML parser with validation check, it can handle also HTML
839
+ and SGML. */
840
+ CBLIST *cbxmlbreak(const char *str, int cr);
841
+
842
+
843
+ /* Get the map of attributes of an XML tag.
844
+ `str' specifies the pointer to the region of a tag string.
845
+ The return value is a map handle. Each key of the map is the name of an attribute. Each
846
+ value is unescaped. You can get the name of the tag with the key of an empty string.
847
+ Because the handle of the return value is opened with the function `cbmapopen', it should
848
+ be closed with the function `cbmapclose' if it is no longer in use. */
849
+ CBMAP *cbxmlattrs(const char *str);
850
+
851
+
852
+ /* Escape a string with the meta characters of XML.
853
+ `str' specifies the pointer to the region of a string.
854
+ The return value is the pointer to the escaped string sanitized of meta characters.
855
+ This function converts only `&', `<', `>', and `"'. Because the region of the return value
856
+ is allocated with the `malloc' call, it should be released with the `free' call if it is no
857
+ longer in use. */
858
+ char *cbxmlescape(const char *str);
859
+
860
+
861
+ /* Unescape a string with the entity references of XML.
862
+ `str' specifies the pointer to the region of a string with meta characters.
863
+ The return value is the pointer to the unescaped string.
864
+ This function restores only `&amp;', `&lt;', `&gt;', and `&quot;'. Because the region of the
865
+ return value is allocated with the `malloc' call, it should be released with the `free' call
866
+ if it is no longer in use. */
867
+ char *cbxmlunescape(const char *str);
868
+
869
+
870
+ /* Compress a serial object with ZLIB.
871
+ `ptr' specifies the pointer to a region.
872
+ `size' specifies the size of the region. If it is negative, the size is assigned with
873
+ `strlen(ptr)'.
874
+ `sp' specifies the pointer to a variable to which the size of the region of the return
875
+ value is assigned.
876
+ If successful, the return value is the pointer to the result object, else, it is `NULL'.
877
+ Because the region of the return value is allocated with the `malloc' call, it should be
878
+ released with the `free' call if it is no longer in use. This function is available only if
879
+ QDBM was built with ZLIB enabled. */
880
+ char *cbdeflate(const char *ptr, int size, int *sp);
881
+
882
+
883
+ /* Decompress a serial object compressed with ZLIB.
884
+ `ptr' specifies the pointer to a region.
885
+ `size' specifies the size of the region.
886
+ `sp' specifies the pointer to a variable to which the size of the region of the return
887
+ value is assigned. If it is `NULL', it is not used.
888
+ If successful, the return value is the pointer to the result object, else, it is `NULL'.
889
+ Because an additional zero code is appended at the end of the region of the return value,
890
+ the return value can be treated as a character string. Because the region of the return
891
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
892
+ is no longer in use. This function is available only if QDBM was built with ZLIB enabled. */
893
+ char *cbinflate(const char *ptr, int size, int *sp);
894
+
895
+
896
+ /* Get the CRC32 checksum of a serial object.
897
+ `ptr' specifies the pointer to a region.
898
+ `size' specifies the size of the region. If it is negative, the size is assigned with
899
+ `strlen(ptr)'.
900
+ The return value is the CRC32 checksum of the object.
901
+ This function is available only if QDBM was built with ZLIB enabled. */
902
+ unsigned int cbgetcrc(const char *ptr, int size);
903
+
904
+
905
+ /* Convert the character encoding of a string.
906
+ `ptr' specifies the pointer to a region.
907
+ `size' specifies the size of the region. If it is negative, the size is assigned with
908
+ `strlen(ptr)'.
909
+ `icode' specifies the name of encoding of the input string.
910
+ `ocode' specifies the name of encoding of the output string.
911
+ `sp' specifies the pointer to a variable to which the size of the region of the return
912
+ value is assigned. If it is `NULL', it is not used.
913
+ `mp' specifies the pointer to a variable to which the number of missing characters by failure
914
+ of conversion is assigned. If it is `NULL', it is not used.
915
+ If successful, the return value is the pointer to the result object, else, it is `NULL'.
916
+ Because an additional zero code is appended at the end of the region of the return value,
917
+ the return value can be treated as a character string. Because the region of the return
918
+ value is allocated with the `malloc' call, it should be released with the `free' call if it
919
+ is no longer in use. This function is available only if QDBM was built with ICONV enabled. */
920
+ char *cbiconv(const char *ptr, int size, const char *icode, const char *ocode, int *sp, int *mp);
921
+
922
+
923
+ /* Detect the encoding of a string automatically.
924
+ `ptr' specifies the pointer to a region.
925
+ `size' specifies the size of the region. If it is negative, the size is assigned with
926
+ `strlen(ptr)'.
927
+ The return value is the string of the encoding name of the string.
928
+ As it stands, US-ASCII, ISO-2022-JP, Shift_JIS, CP932, EUC-JP, UTF-8, UTF-16, UTF-16BE,
929
+ and UTF-16LE are supported. If none of them matches, ISO-8859-1 is selected. This function
930
+ is available only if QDBM was built with ICONV enabled. */
931
+ const char *cbencname(const char *ptr, int size);
932
+
933
+
934
+ /* Get the jet lag of the local time in seconds.
935
+ The return value is the jet lag of the local time in seconds. */
936
+ int cbjetlag(void);
937
+
938
+
939
+ /* Get the Gregorian calendar of a time.
940
+ `t' specifies a source time. If it is negative, the current time is specified.
941
+ `jl' specifies the jet lag of a location in seconds.
942
+ `yearp' specifies the pointer to a variable to which the year is assigned. If it is `NULL',
943
+ it is not used.
944
+ `monp' specifies the pointer to a variable to which the month is assigned. If it is `NULL',
945
+ it is not used. 1 means January and 12 means December.
946
+ `dayp' specifies the pointer to a variable to which the day of the month is assigned. If it
947
+ is `NULL', it is not used.
948
+ `hourp' specifies the pointer to a variable to which the hours is assigned. If it is `NULL',
949
+ it is not used.
950
+ `minp' specifies the pointer to a variable to which the minutes is assigned. If it is `NULL',
951
+ it is not used.
952
+ `secp' specifies the pointer to a variable to which the seconds is assigned. If it is `NULL',
953
+ it is not used. */
954
+ void cbcalendar(time_t t, int jl, int *yearp, int *monp, int *dayp,
955
+ int *hourp, int *minp, int *secp);
956
+
957
+
958
+ /* Get the day of week of a date.
959
+ `year' specifies the year of a date.
960
+ `mon' specifies the month of the date.
961
+ `day' specifies the day of the date.
962
+ The return value is the day of week of the date. 0 means Sunday and 6 means Saturday. */
963
+ int cbdayofweek(int year, int mon, int day);
964
+
965
+
966
+ /* Get the string for a date in W3CDTF.
967
+ `t' specifies a source time. If it is negative, the current time is specified.
968
+ `jl' specifies the jet lag of a location in seconds.
969
+ The return value is the string of the date in W3CDTF (YYYY-MM-DDThh:mm:ddTZD).
970
+ Because the region of the return value is allocated with the `malloc' call, it should be
971
+ released with the `free' call if it is no longer in use. */
972
+ char *cbdatestrwww(time_t t, int jl);
973
+
974
+
975
+ /* Get the string for a date in RFC 1123 format.
976
+ `t' specifies a source time. If it is negative, the current time is specified.
977
+ `jl' specifies the jet lag of a location in seconds.
978
+ The return value is the string of the date in RFC 1123 format (Wdy, DD-Mon-YYYY hh:mm:dd TZD).
979
+ Because the region of the return value is allocated with the `malloc' call, it should be
980
+ released with the `free' call if it is no longer in use. */
981
+ char *cbdatestrhttp(time_t t, int jl);
982
+
983
+
984
+ /* Get the time value of a date string in decimal, W3CDTF, or RFC 1123.
985
+ `str' specifies a date string in decimal, W3CDTF, or RFC 1123.
986
+ The return value is the time value of the date or -1 if the format is invalid. */
987
+ time_t cbstrmktime(const char *str);
988
+
989
+
990
+ /* Get user and system processing times.
991
+ `usrp' specifies the pointer to a variable to which the user processing time is assigned.
992
+ If it is `NULL', it is not used. The unit of time is seconds.
993
+ `sysp' specifies the pointer to a variable to which the system processing time is assigned.
994
+ If it is `NULL', it is not used. The unit of time is seconds. */
995
+ void cbproctime(double *usrp, double *sysp);
996
+
997
+
998
+ /* Ensure that the standard I/O is binary mode.
999
+ This function is useful for applications on dosish file systems. */
1000
+ void cbstdiobin(void);
1001
+
1002
+
1003
+
1004
+ /*************************************************************************************************
1005
+ * features for experts
1006
+ *************************************************************************************************/
1007
+
1008
+
1009
+ /* Get a map handle with specifying the number of buckets.
1010
+ `bnum' specifies the number of buckets.
1011
+ The return value is a map handle. */
1012
+ CBMAP *cbmapopenex(int bnum);
1013
+
1014
+
1015
+ /* Alias of `cbdatumptr'. */
1016
+ #define CB_DATUMPTR(datum) ((const char *)(datum->dptr))
1017
+
1018
+
1019
+ /* Alias of `cbdatumsize'. */
1020
+ #define CB_DATUMSIZE(datum) ((int)(datum->dsize))
1021
+
1022
+
1023
+ /* Alias of `cblistnum'. */
1024
+ #define CB_LISTNUM(list) ((int)(list->num))
1025
+
1026
+
1027
+ /* Alias of `cblistval'.
1028
+ However, `sp' is ignored. */
1029
+ #define CB_LISTVAL(list,index,sp) ((const char *)(list->array[list->start+index].dptr))
1030
+
1031
+
1032
+
1033
+ #if defined(__cplusplus) /* export for C++ */
1034
+ }
1035
+ #endif
1036
+
1037
+ #endif /* duplication check */
1038
+
1039
+
1040
+ /* END OF FILE */