ferret 0.11.6 → 0.11.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README +10 -22
  2. data/RELEASE_CHANGES +137 -0
  3. data/RELEASE_NOTES +60 -0
  4. data/Rakefile +379 -274
  5. data/TODO +100 -8
  6. data/bin/ferret-browser +0 -0
  7. data/ext/BZLIB_blocksort.c +1094 -0
  8. data/ext/BZLIB_bzlib.c +1578 -0
  9. data/ext/BZLIB_compress.c +672 -0
  10. data/ext/BZLIB_crctable.c +104 -0
  11. data/ext/BZLIB_decompress.c +626 -0
  12. data/ext/BZLIB_huffman.c +205 -0
  13. data/ext/BZLIB_randtable.c +84 -0
  14. data/ext/{api.c → STEMMER_api.c} +7 -10
  15. data/ext/{libstemmer.c → STEMMER_libstemmer.c} +3 -2
  16. data/ext/{stem_ISO_8859_1_danish.c → STEMMER_stem_ISO_8859_1_danish.c} +123 -124
  17. data/ext/{stem_ISO_8859_1_dutch.c → STEMMER_stem_ISO_8859_1_dutch.c} +177 -188
  18. data/ext/STEMMER_stem_ISO_8859_1_english.c +1117 -0
  19. data/ext/{stem_ISO_8859_1_finnish.c → STEMMER_stem_ISO_8859_1_finnish.c} +276 -306
  20. data/ext/STEMMER_stem_ISO_8859_1_french.c +1246 -0
  21. data/ext/{stem_ISO_8859_1_german.c → STEMMER_stem_ISO_8859_1_german.c} +161 -170
  22. data/ext/STEMMER_stem_ISO_8859_1_hungarian.c +1230 -0
  23. data/ext/STEMMER_stem_ISO_8859_1_italian.c +1065 -0
  24. data/ext/STEMMER_stem_ISO_8859_1_norwegian.c +297 -0
  25. data/ext/{stem_ISO_8859_1_porter.c → STEMMER_stem_ISO_8859_1_porter.c} +263 -290
  26. data/ext/{stem_ISO_8859_1_portuguese.c → STEMMER_stem_ISO_8859_1_portuguese.c} +362 -380
  27. data/ext/STEMMER_stem_ISO_8859_1_spanish.c +1093 -0
  28. data/ext/STEMMER_stem_ISO_8859_1_swedish.c +307 -0
  29. data/ext/STEMMER_stem_ISO_8859_2_romanian.c +998 -0
  30. data/ext/{stem_KOI8_R_russian.c → STEMMER_stem_KOI8_R_russian.c} +244 -245
  31. data/ext/STEMMER_stem_UTF_8_danish.c +339 -0
  32. data/ext/{stem_UTF_8_dutch.c → STEMMER_stem_UTF_8_dutch.c} +192 -211
  33. data/ext/STEMMER_stem_UTF_8_english.c +1125 -0
  34. data/ext/{stem_UTF_8_finnish.c → STEMMER_stem_UTF_8_finnish.c} +284 -324
  35. data/ext/STEMMER_stem_UTF_8_french.c +1256 -0
  36. data/ext/{stem_UTF_8_german.c → STEMMER_stem_UTF_8_german.c} +170 -187
  37. data/ext/STEMMER_stem_UTF_8_hungarian.c +1234 -0
  38. data/ext/STEMMER_stem_UTF_8_italian.c +1073 -0
  39. data/ext/STEMMER_stem_UTF_8_norwegian.c +299 -0
  40. data/ext/{stem_UTF_8_porter.c → STEMMER_stem_UTF_8_porter.c} +271 -310
  41. data/ext/STEMMER_stem_UTF_8_portuguese.c +1023 -0
  42. data/ext/STEMMER_stem_UTF_8_romanian.c +1004 -0
  43. data/ext/STEMMER_stem_UTF_8_russian.c +694 -0
  44. data/ext/STEMMER_stem_UTF_8_spanish.c +1097 -0
  45. data/ext/STEMMER_stem_UTF_8_swedish.c +309 -0
  46. data/ext/STEMMER_stem_UTF_8_turkish.c +2205 -0
  47. data/ext/{utilities.c → STEMMER_utilities.c} +100 -68
  48. data/ext/analysis.c +276 -121
  49. data/ext/analysis.h +190 -143
  50. data/ext/api.h +3 -4
  51. data/ext/array.c +5 -3
  52. data/ext/array.h +52 -43
  53. data/ext/bitvector.c +38 -482
  54. data/ext/bitvector.h +446 -124
  55. data/ext/bzlib.h +282 -0
  56. data/ext/bzlib_private.h +503 -0
  57. data/ext/compound_io.c +23 -22
  58. data/ext/config.h +21 -11
  59. data/ext/document.c +43 -40
  60. data/ext/document.h +31 -21
  61. data/ext/except.c +20 -38
  62. data/ext/except.h +89 -76
  63. data/ext/extconf.rb +3 -2
  64. data/ext/ferret.c +49 -35
  65. data/ext/ferret.h +14 -11
  66. data/ext/field_index.c +262 -0
  67. data/ext/field_index.h +52 -0
  68. data/ext/filter.c +11 -10
  69. data/ext/fs_store.c +65 -47
  70. data/ext/global.c +245 -165
  71. data/ext/global.h +252 -54
  72. data/ext/hash.c +200 -243
  73. data/ext/hash.h +205 -163
  74. data/ext/hashset.c +118 -96
  75. data/ext/hashset.h +110 -82
  76. data/ext/header.h +19 -19
  77. data/ext/helper.c +11 -10
  78. data/ext/helper.h +14 -6
  79. data/ext/index.c +745 -366
  80. data/ext/index.h +503 -529
  81. data/ext/internal.h +1020 -0
  82. data/ext/lang.c +10 -0
  83. data/ext/lang.h +35 -15
  84. data/ext/mempool.c +5 -4
  85. data/ext/mempool.h +30 -22
  86. data/ext/modules.h +35 -7
  87. data/ext/multimapper.c +43 -2
  88. data/ext/multimapper.h +32 -23
  89. data/ext/posh.c +0 -0
  90. data/ext/posh.h +4 -38
  91. data/ext/priorityqueue.c +10 -12
  92. data/ext/priorityqueue.h +33 -21
  93. data/ext/q_boolean.c +22 -9
  94. data/ext/q_const_score.c +3 -2
  95. data/ext/q_filtered_query.c +15 -12
  96. data/ext/q_fuzzy.c +147 -135
  97. data/ext/q_match_all.c +3 -2
  98. data/ext/q_multi_term.c +28 -32
  99. data/ext/q_parser.c +451 -173
  100. data/ext/q_phrase.c +158 -79
  101. data/ext/q_prefix.c +16 -18
  102. data/ext/q_range.c +363 -31
  103. data/ext/q_span.c +130 -141
  104. data/ext/q_term.c +21 -21
  105. data/ext/q_wildcard.c +19 -23
  106. data/ext/r_analysis.c +369 -242
  107. data/ext/r_index.c +421 -434
  108. data/ext/r_qparser.c +142 -92
  109. data/ext/r_search.c +790 -407
  110. data/ext/r_store.c +44 -44
  111. data/ext/r_utils.c +264 -96
  112. data/ext/ram_store.c +29 -23
  113. data/ext/scanner.c +895 -0
  114. data/ext/scanner.h +36 -0
  115. data/ext/scanner_mb.c +6701 -0
  116. data/ext/scanner_utf8.c +4415 -0
  117. data/ext/search.c +210 -87
  118. data/ext/search.h +556 -488
  119. data/ext/similarity.c +17 -16
  120. data/ext/similarity.h +51 -44
  121. data/ext/sort.c +157 -354
  122. data/ext/stem_ISO_8859_1_hungarian.h +16 -0
  123. data/ext/stem_ISO_8859_2_romanian.h +16 -0
  124. data/ext/stem_UTF_8_hungarian.h +16 -0
  125. data/ext/stem_UTF_8_romanian.h +16 -0
  126. data/ext/stem_UTF_8_turkish.h +16 -0
  127. data/ext/stopwords.c +287 -278
  128. data/ext/store.c +57 -51
  129. data/ext/store.h +308 -286
  130. data/ext/symbol.c +10 -0
  131. data/ext/symbol.h +23 -0
  132. data/ext/term_vectors.c +14 -293
  133. data/ext/threading.h +22 -22
  134. data/ext/win32.h +12 -4
  135. data/lib/ferret.rb +2 -1
  136. data/lib/ferret/browser.rb +1 -1
  137. data/lib/ferret/field_symbol.rb +94 -0
  138. data/lib/ferret/index.rb +221 -34
  139. data/lib/ferret/number_tools.rb +6 -6
  140. data/lib/ferret/version.rb +3 -0
  141. data/test/{unit → long_running}/largefile/tc_largefile.rb +1 -1
  142. data/test/test_helper.rb +7 -2
  143. data/test/test_installed.rb +1 -0
  144. data/test/threading/thread_safety_index_test.rb +10 -1
  145. data/test/threading/thread_safety_read_write_test.rb +4 -7
  146. data/test/threading/thread_safety_test.rb +0 -0
  147. data/test/unit/analysis/tc_analyzer.rb +29 -27
  148. data/test/unit/analysis/tc_token_stream.rb +23 -16
  149. data/test/unit/index/tc_index.rb +116 -11
  150. data/test/unit/index/tc_index_reader.rb +27 -27
  151. data/test/unit/index/tc_index_writer.rb +10 -0
  152. data/test/unit/index/th_doc.rb +38 -21
  153. data/test/unit/search/tc_filter.rb +31 -10
  154. data/test/unit/search/tc_index_searcher.rb +6 -0
  155. data/test/unit/search/tm_searcher.rb +53 -1
  156. data/test/unit/store/tc_fs_store.rb +40 -2
  157. data/test/unit/store/tc_ram_store.rb +0 -0
  158. data/test/unit/store/tm_store.rb +0 -0
  159. data/test/unit/store/tm_store_lock.rb +7 -6
  160. data/test/unit/tc_field_symbol.rb +26 -0
  161. data/test/unit/ts_analysis.rb +0 -0
  162. data/test/unit/ts_index.rb +0 -0
  163. data/test/unit/ts_store.rb +0 -0
  164. data/test/unit/ts_utils.rb +0 -0
  165. data/test/unit/utils/tc_number_tools.rb +0 -0
  166. data/test/utils/content_generator.rb +226 -0
  167. metadata +262 -221
  168. data/ext/inc/lang.h +0 -48
  169. data/ext/inc/threading.h +0 -31
  170. data/ext/stem_ISO_8859_1_english.c +0 -1156
  171. data/ext/stem_ISO_8859_1_french.c +0 -1276
  172. data/ext/stem_ISO_8859_1_italian.c +0 -1091
  173. data/ext/stem_ISO_8859_1_norwegian.c +0 -296
  174. data/ext/stem_ISO_8859_1_spanish.c +0 -1119
  175. data/ext/stem_ISO_8859_1_swedish.c +0 -307
  176. data/ext/stem_UTF_8_danish.c +0 -344
  177. data/ext/stem_UTF_8_english.c +0 -1176
  178. data/ext/stem_UTF_8_french.c +0 -1296
  179. data/ext/stem_UTF_8_italian.c +0 -1113
  180. data/ext/stem_UTF_8_norwegian.c +0 -302
  181. data/ext/stem_UTF_8_portuguese.c +0 -1055
  182. data/ext/stem_UTF_8_russian.c +0 -709
  183. data/ext/stem_UTF_8_spanish.c +0 -1137
  184. data/ext/stem_UTF_8_swedish.c +0 -313
  185. data/lib/ferret_version.rb +0 -3
@@ -1,5 +1,6 @@
1
1
  #include "store.h"
2
2
  #include <string.h>
3
+ #include "internal.h"
3
4
 
4
5
  #define VINT_MAX_LEN 10
5
6
  #define VINT_END BUFFER_SIZE - VINT_MAX_LEN
@@ -10,7 +11,7 @@
10
11
  void with_lock(Lock *lock, void (*func)(void *arg), void *arg)
11
12
  {
12
13
  if (!lock->obtain(lock)) {
13
- RAISE(IO_ERROR, "couldn't obtain lock \"%s\"", lock->name);
14
+ RAISE(LOCK_ERROR, "couldn't obtain lock \"%s\"", lock->name);
14
15
  }
15
16
  func(arg);
16
17
  lock->release(lock);
@@ -19,7 +20,7 @@ void with_lock(Lock *lock, void (*func)(void *arg), void *arg)
19
20
  /*
20
21
  * TODO: add try finally
21
22
  */
22
- void with_lock_name(Store *store, char *lock_name,
23
+ void with_lock_name(Store *store, const char *lock_name,
23
24
  void (*func)(void *arg), void *arg)
24
25
  {
25
26
  Lock *lock = store->open_lock_i(store, lock_name);
@@ -42,7 +43,7 @@ void store_deref(Store *store)
42
43
  }
43
44
  }
44
45
 
45
- Lock *open_lock(Store *store, char *lockname)
46
+ Lock *open_lock(Store *store, const char *lockname)
46
47
  {
47
48
  Lock *lock = store->open_lock_i(store, lockname);
48
49
  hs_add(store->locks, lock);
@@ -54,7 +55,7 @@ void close_lock(Lock *lock)
54
55
  hs_del(lock->store->locks, lock);
55
56
  }
56
57
 
57
- void close_lock_i(Lock *lock)
58
+ static void close_lock_i(Lock *lock)
58
59
  {
59
60
  lock->store->close_lock_i(lock);
60
61
  }
@@ -68,7 +69,7 @@ Store *store_new()
68
69
  store->ref_cnt = 1;
69
70
  mutex_init(&store->mutex_i, NULL);
70
71
  mutex_init(&store->mutex, NULL);
71
- store->locks = hs_new(ptr_hash, ptr_eq, (free_ft)&close_lock_i);
72
+ store->locks = hs_new_ptr((free_ft)&close_lock_i);
72
73
  return store;
73
74
  }
74
75
 
@@ -151,7 +152,7 @@ INLINE void os_write_byte(OutStream *os, uchar b)
151
152
  write_byte(os, b);
152
153
  }
153
154
 
154
- void os_write_bytes(OutStream *os, uchar *buf, int len)
155
+ void os_write_bytes(OutStream *os, const uchar *buf, int len)
155
156
  {
156
157
  if (os->buf.pos > 0) { /* flush buffer */
157
158
  os_flush(os);
@@ -200,7 +201,7 @@ InStream *is_new()
200
201
  * @raise IO_ERROR if there is a error reading from the filesystem
201
202
  * @raise EOF_ERROR if there is an attempt to read past the end of the file
202
203
  */
203
- void is_refill(InStream *is)
204
+ static void is_refill(InStream *is)
204
205
  {
205
206
  off_t start = is->buf.start + is->buf.pos;
206
207
  off_t last = start + BUFFER_SIZE;
@@ -212,8 +213,8 @@ void is_refill(InStream *is)
212
213
 
213
214
  is->buf.len = last - start;
214
215
  if (is->buf.len <= 0) {
215
- RAISE(EOF_ERROR, "current pos = %"F_OFF_T_PFX"d, "
216
- "file length = %"F_OFF_T_PFX"d", start, flen);
216
+ RAISE(EOF_ERROR, "current pos = %"OFF_T_PFX"d, "
217
+ "file length = %"OFF_T_PFX"d", start, flen);
217
218
  }
218
219
 
219
220
  is->m->read_i(is, is->buf.buf, is->buf.len);
@@ -303,44 +304,44 @@ InStream *is_clone(InStream *is)
303
304
  return new_index_i;
304
305
  }
305
306
 
306
- f_i32 is_read_i32(InStream *is)
307
+ i32 is_read_i32(InStream *is)
307
308
  {
308
- return ((f_i32)is_read_byte(is) << 24) |
309
- ((f_i32)is_read_byte(is) << 16) |
310
- ((f_i32)is_read_byte(is) << 8) |
311
- ((f_i32)is_read_byte(is));
309
+ return ((i32)is_read_byte(is) << 24) |
310
+ ((i32)is_read_byte(is) << 16) |
311
+ ((i32)is_read_byte(is) << 8) |
312
+ ((i32)is_read_byte(is));
312
313
  }
313
314
 
314
- f_i64 is_read_i64(InStream *is)
315
+ i64 is_read_i64(InStream *is)
315
316
  {
316
- return ((f_i64)is_read_byte(is) << 56) |
317
- ((f_i64)is_read_byte(is) << 48) |
318
- ((f_i64)is_read_byte(is) << 40) |
319
- ((f_i64)is_read_byte(is) << 32) |
320
- ((f_i64)is_read_byte(is) << 24) |
321
- ((f_i64)is_read_byte(is) << 16) |
322
- ((f_i64)is_read_byte(is) << 8) |
323
- ((f_i64)is_read_byte(is));
317
+ return ((i64)is_read_byte(is) << 56) |
318
+ ((i64)is_read_byte(is) << 48) |
319
+ ((i64)is_read_byte(is) << 40) |
320
+ ((i64)is_read_byte(is) << 32) |
321
+ ((i64)is_read_byte(is) << 24) |
322
+ ((i64)is_read_byte(is) << 16) |
323
+ ((i64)is_read_byte(is) << 8) |
324
+ ((i64)is_read_byte(is));
324
325
  }
325
326
 
326
- f_u32 is_read_u32(InStream *is)
327
+ u32 is_read_u32(InStream *is)
327
328
  {
328
- return ((f_u32)is_read_byte(is) << 24) |
329
- ((f_u32)is_read_byte(is) << 16) |
330
- ((f_u32)is_read_byte(is) << 8) |
331
- ((f_u32)is_read_byte(is));
329
+ return ((u32)is_read_byte(is) << 24) |
330
+ ((u32)is_read_byte(is) << 16) |
331
+ ((u32)is_read_byte(is) << 8) |
332
+ ((u32)is_read_byte(is));
332
333
  }
333
334
 
334
- f_u64 is_read_u64(InStream *is)
335
+ u64 is_read_u64(InStream *is)
335
336
  {
336
- return ((f_u64)is_read_byte(is) << 56) |
337
- ((f_u64)is_read_byte(is) << 48) |
338
- ((f_u64)is_read_byte(is) << 40) |
339
- ((f_u64)is_read_byte(is) << 32) |
340
- ((f_u64)is_read_byte(is) << 24) |
341
- ((f_u64)is_read_byte(is) << 16) |
342
- ((f_u64)is_read_byte(is) << 8) |
343
- ((f_u64)is_read_byte(is));
337
+ return ((u64)is_read_byte(is) << 56) |
338
+ ((u64)is_read_byte(is) << 48) |
339
+ ((u64)is_read_byte(is) << 40) |
340
+ ((u64)is_read_byte(is) << 32) |
341
+ ((u64)is_read_byte(is) << 24) |
342
+ ((u64)is_read_byte(is) << 16) |
343
+ ((u64)is_read_byte(is) << 8) |
344
+ ((u64)is_read_byte(is));
344
345
  }
345
346
 
346
347
  /* optimized to use unchecked read_byte if there is definitely space */
@@ -404,9 +405,9 @@ INLINE off_t is_read_voff_t(InStream *is)
404
405
  }
405
406
 
406
407
  /* optimized to use unchecked read_byte if there is definitely space */
407
- INLINE unsigned long long is_read_vll(InStream *is)
408
+ INLINE u64 is_read_vll(InStream *is)
408
409
  {
409
- register unsigned long long res, b;
410
+ register u64 res, b;
410
411
  register int shift = 7;
411
412
 
412
413
  if (is->buf.pos > (is->buf.len - VINT_MAX_LEN)) {
@@ -441,8 +442,10 @@ INLINE void is_skip_vints(InStream *is, register int cnt)
441
442
  }
442
443
  }
443
444
 
444
- INLINE void is_read_chars(InStream *is, char *buffer,
445
- int off, int len)
445
+ /*
446
+ * FIXME: Not used. Do we need/want this?
447
+ static INLINE void is_read_chars(InStream *is, char *buffer,
448
+ int off, int len)
446
449
  {
447
450
  int end, i;
448
451
 
@@ -452,6 +455,7 @@ INLINE void is_read_chars(InStream *is, char *buffer,
452
455
  buffer[i] = is_read_byte(is);
453
456
  }
454
457
  }
458
+ */
455
459
 
456
460
  char *is_read_string(InStream *is)
457
461
  {
@@ -497,7 +501,7 @@ char *is_read_string_safe(InStream *is)
497
501
  return str;
498
502
  }
499
503
 
500
- void os_write_i32(OutStream *os, f_i32 num)
504
+ void os_write_i32(OutStream *os, i32 num)
501
505
  {
502
506
  os_write_byte(os, (uchar)((num >> 24) & 0xFF));
503
507
  os_write_byte(os, (uchar)((num >> 16) & 0xFF));
@@ -505,7 +509,7 @@ void os_write_i32(OutStream *os, f_i32 num)
505
509
  os_write_byte(os, (uchar)(num & 0xFF));
506
510
  }
507
511
 
508
- void os_write_i64(OutStream *os, f_i64 num)
512
+ void os_write_i64(OutStream *os, i64 num)
509
513
  {
510
514
  os_write_byte(os, (uchar)((num >> 56) & 0xFF));
511
515
  os_write_byte(os, (uchar)((num >> 48) & 0xFF));
@@ -517,7 +521,7 @@ void os_write_i64(OutStream *os, f_i64 num)
517
521
  os_write_byte(os, (uchar)(num & 0xFF));
518
522
  }
519
523
 
520
- void os_write_u32(OutStream *os, f_u32 num)
524
+ void os_write_u32(OutStream *os, u32 num)
521
525
  {
522
526
  os_write_byte(os, (uchar)((num >> 24) & 0xFF));
523
527
  os_write_byte(os, (uchar)((num >> 16) & 0xFF));
@@ -525,7 +529,7 @@ void os_write_u32(OutStream *os, f_u32 num)
525
529
  os_write_byte(os, (uchar)(num & 0xFF));
526
530
  }
527
531
 
528
- void os_write_u64(OutStream *os, f_u64 num)
532
+ void os_write_u64(OutStream *os, u64 num)
529
533
  {
530
534
  os_write_byte(os, (uchar)((num >> 56) & 0xFF));
531
535
  os_write_byte(os, (uchar)((num >> 48) & 0xFF));
@@ -576,7 +580,7 @@ INLINE void os_write_voff_t(OutStream *os, register off_t num)
576
580
  }
577
581
 
578
582
  /* optimized to use an unchecked write if there is space */
579
- INLINE void os_write_vll(OutStream *os, register unsigned long long num)
583
+ INLINE void os_write_vll(OutStream *os, register u64 num)
580
584
  {
581
585
  if (os->buf.pos > VINT_END) {
582
586
  while (num > 127) {
@@ -594,13 +598,15 @@ INLINE void os_write_vll(OutStream *os, register unsigned long long num)
594
598
  }
595
599
  }
596
600
 
597
- void os_write_string(OutStream *os, char *str)
601
+ INLINE void os_write_string_len(OutStream *os, const char *str, int len)
598
602
  {
599
- int len = (int)strlen(str);
600
603
  os_write_vint(os, len);
601
-
602
604
  os_write_bytes(os, (uchar *)str, len);
603
605
  }
606
+ void os_write_string(OutStream *os, const char *str)
607
+ {
608
+ os_write_string_len(os, str, (int)strlen(str));
609
+ }
604
610
 
605
611
  /**
606
612
  * Determine if the filename is the name of a lock file. Return 1 if it is, 0
@@ -609,7 +615,7 @@ void os_write_string(OutStream *os, char *str)
609
615
  * @param filename the name of the file to check
610
616
  * @return 1 (true) if the file is a lock file, 0 (false) otherwise
611
617
  */
612
- int file_is_lock(char *filename)
618
+ int file_is_lock(const char *filename)
613
619
  {
614
620
  int start = (int) strlen(filename) - 4;
615
621
  return ((start > 0) && (strcmp(LOCK_EXT, &filename[start]) == 0));
@@ -652,7 +658,7 @@ struct FileNameListArg
652
658
  /**
653
659
  * Test function used to test store->each function
654
660
  */
655
- static void add_file_name(char *fname, void *arg)
661
+ static void add_file_name(const char *fname, void *arg)
656
662
  {
657
663
  struct FileNameListArg *fnl = (struct FileNameListArg *)arg;
658
664
  if (fnl->count >= fnl->size) {
@@ -7,78 +7,74 @@
7
7
  #include "hashset.h"
8
8
  #include "threading.h"
9
9
 
10
- #define BUFFER_SIZE 1024
11
- #define LOCK_PREFIX "ferret-"
12
- #define LOCK_EXT ".lck"
10
+ #define FRT_LOCK_PREFIX "ferret-"
11
+ #define FRT_LOCK_EXT ".lck"
13
12
 
14
- #define VINT_MAX_LEN 10
15
- #define VINT_END BUFFER_SIZE - VINT_MAX_LEN
16
-
17
- typedef struct Buffer
13
+ typedef struct FrtBuffer
18
14
  {
19
- uchar buf[BUFFER_SIZE];
15
+ frt_uchar buf[FRT_BUFFER_SIZE];
20
16
  off_t start;
21
17
  off_t pos;
22
18
  off_t len;
23
- } Buffer;
19
+ } FrtBuffer;
24
20
 
25
- typedef struct OutStream OutStream;
26
- struct OutStreamMethods {
27
- /* internal functions for the InStream */
21
+ typedef struct FrtOutStream FrtOutStream;
22
+ struct FrtOutStreamMethods {
23
+ /* internal functions for the FrtInStream */
28
24
  /**
29
25
  * Flush +len+ characters from +src+ to the output stream +os+
30
26
  *
31
27
  * @param os self
32
28
  * @param src the characters to write to the output stream
33
29
  * @param len the number of characters to write
34
- * @raise IO_ERROR if there is an error writing the characters
30
+ * @raise FRT_IO_ERROR if there is an error writing the characters
35
31
  */
36
- void (*flush_i)(struct OutStream *os, uchar *buf, int len);
32
+ void (*flush_i)(struct FrtOutStream *os, const frt_uchar *buf, int len);
37
33
 
38
34
  /**
39
35
  * Seek +pos+ in the output stream
40
36
  *
41
37
  * @param os self
42
38
  * @param pos the position to seek in the stream
43
- * @raise IO_ERROR if there is an error seeking in the output stream
39
+ * @raise FRT_IO_ERROR if there is an error seeking in the output stream
44
40
  */
45
- void (*seek_i)(struct OutStream *os, off_t pos);
41
+ void (*seek_i)(struct FrtOutStream *os, off_t pos);
46
42
 
47
43
  /**
48
44
  * Close any resources used by the output stream +os+
49
45
  *
50
46
  * @param os self
51
- * @raise IO_ERROR if there is an closing the file
47
+ * @raise FRT_IO_ERROR if there is an closing the file
52
48
  */
53
- void (*close_i)(struct OutStream *os);
49
+ void (*close_i)(struct FrtOutStream *os);
54
50
  };
55
51
 
56
- typedef struct RAMFile
52
+ typedef struct FrtRAMFile
57
53
  {
58
54
  char *name;
59
- uchar **buffers;
55
+ frt_uchar **buffers;
60
56
  int bufcnt;
61
57
  off_t len;
62
58
  int ref_cnt;
63
- } RAMFile;
59
+ } FrtRAMFile;
64
60
 
65
- struct OutStream
61
+ struct FrtOutStream
66
62
  {
67
- Buffer buf;
63
+ FrtBuffer buf;
68
64
  union
69
65
  {
70
66
  int fd;
71
- RAMFile *rf;
67
+ FrtRAMFile *rf;
72
68
  } file;
73
69
  off_t pointer; /* only used by RAMOut */
74
- const struct OutStreamMethods *m;
70
+ const struct FrtOutStreamMethods *m;
75
71
  };
76
72
 
77
- typedef struct CompoundInStream CompoundInStream;
73
+ typedef struct FrtCompoundInStream FrtCompoundInStream;
78
74
 
79
- typedef struct InStream InStream;
75
+ typedef struct FrtInStream FrtInStream;
80
76
 
81
- struct InStreamMethods
77
+ struct FrtInStreamMethods
82
78
  {
83
79
  /**
84
80
  * Read +len+ characters from the input stream into the +offset+ position in
@@ -88,92 +84,92 @@ struct InStreamMethods
88
84
  * @param buf an array of characters which must be allocated with at least
89
85
  * +offset+ + +len+ bytes
90
86
  * @param len the number of bytes to read
91
- * @raise IO_ERROR if there is an error reading from the input stream
87
+ * @raise FRT_IO_ERROR if there is an error reading from the input stream
92
88
  */
93
- void (*read_i)(struct InStream *is, uchar *buf, int len);
89
+ void (*read_i)(struct FrtInStream *is, frt_uchar *buf, int len);
94
90
 
95
91
  /**
96
92
  * Seek position +pos+ in input stream +is+
97
93
  *
98
94
  * @param is self
99
95
  * @param pos the position to seek
100
- * @raise IO_ERROR if the seek fails
96
+ * @raise FRT_IO_ERROR if the seek fails
101
97
  */
102
- void (*seek_i)(struct InStream *is, off_t pos);
98
+ void (*seek_i)(struct FrtInStream *is, off_t pos);
103
99
 
104
100
  /**
105
101
  * Returns the length of the input stream +is+
106
102
  *
107
103
  * @param is self
108
- * @raise IO_ERROR if there is an error getting the file length
104
+ * @raise FRT_IO_ERROR if there is an error getting the file length
109
105
  */
110
- off_t (*length_i)(struct InStream *is);
111
-
106
+ off_t (*length_i)(struct FrtInStream *is);
107
+
112
108
  /**
113
109
  * Close the resources allocated to the inputstream +is+
114
110
  *
115
111
  * @param is self
116
- * @raise IO_ERROR if the close fails
112
+ * @raise FRT_IO_ERROR if the close fails
117
113
  */
118
- void (*close_i)(struct InStream *is);
114
+ void (*close_i)(struct FrtInStream *is);
119
115
  };
120
116
 
121
- struct InStream
117
+ struct FrtInStream
122
118
  {
123
- Buffer buf;
119
+ FrtBuffer buf;
124
120
  union
125
121
  {
126
122
  int fd;
127
- RAMFile *rf;
123
+ FrtRAMFile *rf;
128
124
  } file;
129
125
  union
130
126
  {
131
- off_t pointer; /* only used by RAMIn */
127
+ off_t pointer; /* only used by RAMIn */
132
128
  char *path; /* only used by FSIn */
133
- CompoundInStream *cis;
129
+ FrtCompoundInStream *cis;
134
130
  } d;
135
131
  int *ref_cnt_ptr;
136
- const struct InStreamMethods *m;
132
+ const struct FrtInStreamMethods *m;
137
133
  };
138
134
 
139
- struct CompoundInStream
135
+ struct FrtCompoundInStream
140
136
  {
141
- InStream *sub;
137
+ FrtInStream *sub;
142
138
  off_t offset;
143
139
  off_t length;
144
140
  };
145
141
 
146
142
  #define is_length(mis) mis->m->length_i(mis)
147
143
 
148
- typedef struct Store Store;
149
- typedef struct Lock Lock;
150
- struct Lock
144
+ typedef struct FrtStore FrtStore;
145
+ typedef struct FrtLock FrtLock;
146
+ struct FrtLock
151
147
  {
152
148
  char *name;
153
- Store *store;
154
- int (*obtain)(Lock *lock);
155
- int (*is_locked)(Lock *lock);
156
- void (*release)(Lock *lock);
149
+ FrtStore *store;
150
+ int (*obtain)(FrtLock *lock);
151
+ int (*is_locked)(FrtLock *lock);
152
+ void (*release)(FrtLock *lock);
157
153
  };
158
154
 
159
- typedef struct CompoundStore
155
+ typedef struct FrtCompoundStore
160
156
  {
161
- Store *store;
157
+ FrtStore *store;
162
158
  const char *name;
163
- HashTable *entries;
164
- InStream *stream;
165
- } CompoundStore;
159
+ FrtHash *entries;
160
+ FrtInStream *stream;
161
+ } FrtCompoundStore;
166
162
 
167
- struct Store
163
+ struct FrtStore
168
164
  {
169
165
  int ref_cnt; /* for fs_store only */
170
- mutex_t mutex_i; /* for internal use only */
171
- mutex_t mutex; /* external mutex for use outside */
166
+ frt_mutex_t mutex_i; /* for internal use only */
167
+ frt_mutex_t mutex; /* external mutex for use outside */
172
168
  union
173
169
  {
174
170
  char *path; /* for fs_store only */
175
- HashTable *ht; /* for ram_store only */
176
- CompoundStore *cmpd; /* for compound_store only */
171
+ FrtHash *ht; /* for ram_store only */
172
+ FrtCompoundStore *cmpd; /* for compound_store only */
177
173
  } dir;
178
174
 
179
175
  #ifdef POSH_OS_WIN32
@@ -181,16 +177,16 @@ struct Store
181
177
  #else
182
178
  mode_t file_mode;
183
179
  #endif
184
- HashSet *locks;
180
+ FrtHashSet *locks;
185
181
 
186
182
  /**
187
183
  * Create the file +filename+ in the +store+.
188
184
  *
189
185
  * @param store self
190
186
  * @param filename the name of the file to create
191
- * @raise IO_ERROR if the file cannot be created
187
+ * @raise FRT_IO_ERROR if the file cannot be created
192
188
  */
193
- void (*touch)(Store *store, char *filename);
189
+ void (*touch)(FrtStore *store, const char *filename);
194
190
 
195
191
  /**
196
192
  * Return true if a file of name +filename+ exists in +store+.
@@ -198,9 +194,9 @@ struct Store
198
194
  * @param store self
199
195
  * @param filename the name of the file to check for
200
196
  * @returns true if the file exists
201
- * @raise IO_ERROR if there is an error checking for the files existance
197
+ * @raise FRT_IO_ERROR if there is an error checking for the files existance
202
198
  */
203
- int (*exists)(Store *store, char *filename);
199
+ int (*exists)(FrtStore *store, const char *filename);
204
200
 
205
201
  /**
206
202
  * Remove the file +filename+ from the +store+
@@ -210,7 +206,7 @@ struct Store
210
206
  * @returns On success, zero is returned. On error, -1 is returned, and errno
211
207
  * is set appropriately.
212
208
  */
213
- int (*remove)(Store *store, char *filename);
209
+ int (*remove)(FrtStore *store, const char *filename);
214
210
 
215
211
  /**
216
212
  * Rename the file in the +store+ from the name +from+ to the name +to+.
@@ -218,18 +214,18 @@ struct Store
218
214
  * @param store self
219
215
  * @param from the name of the file to rename
220
216
  * @param to the new name of the file
221
- * @raise IO_ERROR if there is an error renaming the file
217
+ * @raise FRT_IO_ERROR if there is an error renaming the file
222
218
  */
223
- void (*rename)(Store *store, char *from, char *to);
219
+ void (*rename)(FrtStore *store, const char *from, const char *to);
224
220
 
225
221
  /**
226
222
  * Returns the number of files in the store.
227
223
  *
228
224
  * @param store self
229
225
  * @return the number of files in the store
230
- * @raise IO_ERROR if there is an error opening the directory
226
+ * @raise FRT_IO_ERROR if there is an error opening the directory
231
227
  */
232
- int (*count)(Store *store);
228
+ int (*count)(FrtStore *store);
233
229
 
234
230
  /**
235
231
  * Call the function +func+ with each filename in the store and the arg
@@ -241,34 +237,34 @@ struct Store
241
237
  * @param func the function to call with each files name and the +arg+
242
238
  * passed
243
239
  * @param arg the argument to pass to the function
244
- * @raise IO_ERROR if there is an error opening the directory
240
+ * @raise FRT_IO_ERROR if there is an error opening the directory
245
241
  */
246
- void (*each)(Store *store, void (*func)(char *fname, void *arg),
242
+ void (*each)(FrtStore *store, void (*func)(const char *fname, void *arg),
247
243
  void *arg);
248
244
 
249
245
  /**
250
246
  * Clear all the locks in the store.
251
247
  *
252
248
  * @param store self
253
- * @raise IO_ERROR if there is an error opening the directory
249
+ * @raise FRT_IO_ERROR if there is an error opening the directory
254
250
  */
255
- void (*clear_locks)(Store *store);
251
+ void (*clear_locks)(FrtStore *store);
256
252
 
257
253
  /**
258
254
  * Clear all files from the store except the lock files.
259
255
  *
260
256
  * @param store self
261
- * @raise IO_ERROR if there is an error deleting the files
257
+ * @raise FRT_IO_ERROR if there is an error deleting the files
262
258
  */
263
- void (*clear)(Store *store);
259
+ void (*clear)(FrtStore *store);
264
260
 
265
261
  /**
266
262
  * Clear all files from the store including the lock files.
267
263
  *
268
264
  * @param store self
269
- * @raise IO_ERROR if there is an error deleting the files
265
+ * @raise FRT_IO_ERROR if there is an error deleting the files
270
266
  */
271
- void (*clear_all)(Store *store);
267
+ void (*clear_all)(FrtStore *store);
272
268
 
273
269
  /**
274
270
  * Return the length of the file +filename+ in +store+
@@ -276,9 +272,9 @@ struct Store
276
272
  * @param store self
277
273
  * @param the name of the file to check the length of
278
274
  * @return the length of the file in bytes
279
- * @raise IO_ERROR if there is an error checking the file length
275
+ * @raise FRT_IO_ERROR if there is an error checking the file length
280
276
  */
281
- off_t (*length)(Store *store, char *filename);
277
+ off_t (*length)(FrtStore *store, const char *filename);
282
278
 
283
279
  /**
284
280
  * Allocate the resources needed for the output stream in the +store+ with
@@ -287,19 +283,19 @@ struct Store
287
283
  * @param store self
288
284
  * @param filename the name of the output stream
289
285
  * @return a newly allocated filestream
290
- * @raise IO_ERROR if there is an error opening the output stream
286
+ * @raise FRT_IO_ERROR if there is an error opening the output stream
291
287
  * resources
292
288
  */
293
- OutStream *(*new_output)(Store *store, const char *filename);
289
+ FrtOutStream *(*new_output)(FrtStore *store, const char *filename);
294
290
 
295
291
  /**
296
292
  * Open an input stream in the +store+ with the name +filename+
297
293
  *
298
294
  * @param store self
299
295
  * @param filename the name of the input stream
300
- * @raise FILE_NOT_FOUND_ERROR if the input stream cannot be opened
296
+ * @raise FRT_FILE_NOT_FOUND_ERROR if the input stream cannot be opened
301
297
  */
302
- InStream *(*open_input)(Store *store, const char *filename);
298
+ FrtInStream *(*open_input)(FrtStore *store, const char *filename);
303
299
 
304
300
  /**
305
301
  * Obtain a lock on the lock +lock+
@@ -307,15 +303,15 @@ struct Store
307
303
  * @param store self
308
304
  * @param lock the lock to obtain
309
305
  */
310
- Lock *(*open_lock_i)(Store *store, char *lockname);
306
+ FrtLock *(*open_lock_i)(FrtStore *store, const char *lockname);
311
307
 
312
308
  /**
313
309
  * Returns true if +lock+ is locked. To test if the file is locked:wq
314
310
  *
315
311
  * @param lock the lock to test
316
- * @raise IO_ERROR if there is an error detecting the lock status
312
+ * @raise FRT_IO_ERROR if there is an error detecting the lock status
317
313
  */
318
- void (*close_lock_i)(Lock *lock);
314
+ void (*close_lock_i)(FrtLock *lock);
319
315
 
320
316
  /**
321
317
  * Internal function to close the store freeing implementation specific
@@ -323,27 +319,27 @@ struct Store
323
319
  *
324
320
  * @param store self
325
321
  */
326
- void (*close_i)(Store *store);
322
+ void (*close_i)(FrtStore *store);
327
323
  };
328
324
 
329
325
  /**
330
- * Create a newly allocated file-system Store at the pathname designated. The
326
+ * Create a newly allocated file-system FrtStore at the pathname designated. The
331
327
  * pathname must be the name of an existing directory.
332
328
  *
333
329
  * @param pathname the pathname of the directory to be used by the index
334
- * @return a newly allocated file-system Store.
330
+ * @return a newly allocated file-system FrtStore.
335
331
  */
336
- extern Store *open_fs_store(const char *pathname);
332
+ extern FrtStore *frt_open_fs_store(const char *pathname);
337
333
 
338
334
  /**
339
- * Create a newly allocated in-memory or RAM Store.
335
+ * Create a newly allocated in-memory or RAM FrtStore.
340
336
  *
341
- * @return a newly allocated RAM Store.
337
+ * @return a newly allocated RAM FrtStore.
342
338
  */
343
- extern Store *open_ram_store();
339
+ extern FrtStore *frt_open_ram_store();
344
340
 
345
341
  /**
346
- * Create a newly allocated in-memory or RAM Store. Copy the contents of
342
+ * Create a newly allocated in-memory or RAM FrtStore. Copy the contents of
347
343
  * another store into this store. Then close the other store if required. This
348
344
  * method would be used for example to read an index into memory for faster
349
345
  * searching.
@@ -351,9 +347,9 @@ extern Store *open_ram_store();
351
347
  * @param store the whose contents will be copied into the newly allocated RAM
352
348
  * store
353
349
  * @param close_store close the store whose contents where copied
354
- * @return a newly allocated RAM Store.
350
+ * @return a newly allocated RAM FrtStore.
355
351
  */
356
- extern Store *open_ram_store_and_copy(Store *store, bool close_store);
352
+ extern FrtStore *frt_open_ram_store_and_copy(FrtStore *store, bool close_store);
357
353
 
358
354
  /**
359
355
  * Open a compound store. This is basically store which is stored within a
@@ -362,86 +358,86 @@ extern Store *open_ram_store_and_copy(Store *store, bool close_store);
362
358
  *
363
359
  * @param store the store within which this compound store will be stored
364
360
  * @param filename the name of the file in which to store the compound store
365
- * @return a newly allocated Compound Store.
361
+ * @return a newly allocated Compound FrtStore.
366
362
  */
367
- extern Store *open_cmpd_store(Store *store, const char *filename);
363
+ extern FrtStore *frt_open_cmpd_store(FrtStore *store, const char *filename);
368
364
 
369
- /*
365
+ /*
370
366
  * == RamStore functions ==
371
367
  *
372
368
  * These functions or optimizations to be used when you know you are using a
373
- * Ram OutStream.
369
+ * Ram FrtOutStream.
374
370
  */
375
371
 
376
372
  /**
377
- * Return the length of the OutStream in bytes.
373
+ * Return the length of the FrtOutStream in bytes.
378
374
  *
379
- * @param os the OutStream who's length you want
375
+ * @param os the FrtOutStream who's length you want
380
376
  * @return the length of +os+ in bytes
381
377
  */
382
- extern off_t ramo_length(OutStream *os);
378
+ extern off_t frt_ramo_length(FrtOutStream *os);
383
379
 
384
380
  /**
385
- * Reset the OutStream removing any data written to it. Since it is a RAM
381
+ * Reset the FrtOutStream removing any data written to it. Since it is a RAM
386
382
  * file, all that needs to be done is set the length to 0.
387
383
  *
388
- * @param os the OutStream to reset
384
+ * @param os the FrtOutStream to reset
389
385
  */
390
- extern void ramo_reset(OutStream *os);
386
+ extern void frt_ramo_reset(FrtOutStream *os);
391
387
 
392
388
  /**
393
- * Write the contents of a RAM OutStream to another OutStream.
389
+ * Write the contents of a RAM FrtOutStream to another FrtOutStream.
394
390
  *
395
- * @param from_os the OutStream to write from
396
- * @param to_os the OutStream to write to
391
+ * @param from_os the FrtOutStream to write from
392
+ * @param to_os the FrtOutStream to write to
397
393
  */
398
- extern void ramo_write_to(OutStream *from_os, OutStream *to_os);
394
+ extern void frt_ramo_write_to(FrtOutStream *from_os, FrtOutStream *to_os);
399
395
 
400
396
  /**
401
- * Create a buffer RAM OutStream which is unassociated with any RAM Store.
402
- * This OutStream can be used to write temporary data too. When the time
403
- * comes, this data can be written to another OutStream (which might possibly
404
- * be a file-system OutStream) using ramo_write_to.
397
+ * Create a buffer RAM FrtOutStream which is unassociated with any RAM FrtStore.
398
+ * This FrtOutStream can be used to write temporary data too. When the time
399
+ * comes, this data can be written to another FrtOutStream (which might possibly
400
+ * be a file-system FrtOutStream) using frt_ramo_write_to.
405
401
  *
406
- * @return A newly allocated RAM OutStream
402
+ * @return A newly allocated RAM FrtOutStream
407
403
  */
408
- extern OutStream *ram_new_buffer();
404
+ extern FrtOutStream *frt_ram_new_buffer();
409
405
 
410
406
  /**
411
- * Destroy a RAM OutStream which is unassociated with any RAM Store, freeing
407
+ * Destroy a RAM FrtOutStream which is unassociated with any RAM FrtStore, freeing
412
408
  * all resources allocated to it.
413
409
  *
414
- * @param os the OutStream to destroy
410
+ * @param os the FrtOutStream to destroy
415
411
  */
416
- extern void ram_destroy_buffer(OutStream *os);
412
+ extern void frt_ram_destroy_buffer(FrtOutStream *os);
417
413
 
418
414
  /**
419
415
  * Call the function +func+ with the +lock+ locked. The argument +arg+ will be
420
416
  * passed to +func+. If you need to pass more than one argument you should use
421
417
  * a struct. When the function is finished, release the lock.
422
- *
418
+ *
423
419
  * @param lock lock to be locked while func is called
424
420
  * @param func function to call with the lock locked
425
421
  * @param arg argument to pass to the function
426
- * @raise IO_ERROR if the lock is already locked
427
- * @see with_lock_name
422
+ * @raise FRT_IO_ERROR if the lock is already locked
423
+ * @see frt_with_lock_name
428
424
  */
429
- extern void with_lock(Lock *lock, void (*func)(void *arg), void *arg);
425
+ extern void frt_with_lock(FrtLock *lock, void (*func)(void *arg), void *arg);
430
426
 
431
427
  /**
432
428
  * Create a lock in the +store+ with the name +lock_name+. Call the function
433
429
  * +func+ with the lock locked. The argument +arg+ will be passed to +func+.
434
430
  * If you need to pass more than one argument you should use a struct. When
435
431
  * the function is finished, release and destroy the lock.
436
- *
432
+ *
437
433
  * @param store store to open the lock in
438
434
  * @param lock_name name of the lock to open
439
435
  * @param func function to call with the lock locked
440
436
  * @param arg argument to pass to the function
441
- * @raise IO_ERROR if the lock is already locked
442
- * @see with_lock
437
+ * @raise FRT_IO_ERROR if the lock is already locked
438
+ * @see frt_with_lock
443
439
  */
444
- extern void with_lock_name(Store *store, char *lock_name,
440
+ extern void frt_with_lock_name(FrtStore *store, const char *lock_name,
445
441
  void (*func)(void *arg), void *arg);
446
442
 
447
443
  /**
@@ -450,328 +446,354 @@ extern void with_lock_name(Store *store, char *lock_name,
450
446
  *
451
447
  * @param store the store to be dereferenced
452
448
  */
453
- extern void store_deref(Store *store);
449
+ extern void frt_store_deref(FrtStore *store);
454
450
 
455
451
  /**
456
- * Flush the buffered contents of the OutStream to the store.
452
+ * Flush the buffered contents of the FrtOutStream to the store.
457
453
  *
458
- * @param os the OutStream to flush
454
+ * @param os the FrtOutStream to flush
459
455
  */
460
- extern void os_flush(OutStream *os);
456
+ extern void frt_os_flush(FrtOutStream *os);
461
457
 
462
458
  /**
463
- * Close the OutStream after flushing the buffers, also freeing all allocated
459
+ * Close the FrtOutStream after flushing the buffers, also freeing all allocated
464
460
  * resources.
465
461
  *
466
- * @param os the OutStream to close
462
+ * @param os the FrtOutStream to close
467
463
  */
468
- extern void os_close(OutStream *os);
464
+ extern void frt_os_close(FrtOutStream *os);
469
465
 
470
466
  /**
471
- * Return the current position of OutStream +os+.
467
+ * Return the current position of FrtOutStream +os+.
472
468
  *
473
- * @param os the OutStream to get the position from
474
- * @return the current position in OutStream +os+
469
+ * @param os the FrtOutStream to get the position from
470
+ * @return the current position in FrtOutStream +os+
475
471
  */
476
- extern off_t os_pos(OutStream *os);
472
+ extern off_t frt_os_pos(FrtOutStream *os);
477
473
 
478
474
  /**
479
- * Set the current position in OutStream +os+.
475
+ * Set the current position in FrtOutStream +os+.
480
476
  *
481
- * @param os the OutStream to set the position in
482
- * @param pos the new position in the OutStream
483
- * @raise IO_ERROR if there is a file-system IO error seeking the file
477
+ * @param os the FrtOutStream to set the position in
478
+ * @param pos the new position in the FrtOutStream
479
+ * @raise FRT_IO_ERROR if there is a file-system IO error seeking the file
484
480
  */
485
- extern void os_seek(OutStream *os, off_t new_pos);
481
+ extern void frt_os_seek(FrtOutStream *os, off_t new_pos);
486
482
 
487
483
  /**
488
- * Write a single byte +b+ to the OutStream +os+
484
+ * Write a single byte +b+ to the FrtOutStream +os+
489
485
  *
490
- * @param os the OutStream to write to @param b the byte to write @raise
491
- * IO_ERROR if there is an IO error writing to the file-system
486
+ * @param os the FrtOutStream to write to @param b the byte to write @raise
487
+ * FRT_IO_ERROR if there is an IO error writing to the file-system
492
488
  */
493
- extern void os_write_byte(OutStream *os, uchar b);
489
+ extern void frt_os_write_byte(FrtOutStream *os, frt_uchar b);
494
490
  /**
495
- * Write +len+ bytes from buffer +buf+ to the OutStream +os+.
491
+ * Write +len+ bytes from buffer +buf+ to the FrtOutStream +os+.
496
492
  *
497
- * @param os the OutStream to write to
493
+ * @param os the FrtOutStream to write to
498
494
  * @param len the number of bytes to write
499
495
  * @param buf the buffer from which to get the bytes to write.
500
- * @raise IO_ERROR if there is an IO error writing to the file-system
496
+ * @raise FRT_IO_ERROR if there is an IO error writing to the file-system
501
497
  */
502
- extern void os_write_bytes(OutStream *os, uchar *buf, int len);
498
+ extern void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len);
503
499
 
504
500
  /**
505
- * Write a 32-bit signed integer to the OutStream
501
+ * Write a 32-bit signed integer to the FrtOutStream
506
502
  *
507
- * @param os OutStream to write to
503
+ * @param os FrtOutStream to write to
508
504
  * @param num the 32-bit signed integer to write
509
- * @raise IO_ERROR if there is an error writing to the file-system
505
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
510
506
  */
511
- extern void os_write_i32(OutStream *os, f_i32 num);
507
+ extern void frt_os_write_i32(FrtOutStream *os, frt_i32 num);
512
508
 
513
509
  /**
514
- * Write a 64-bit signed integer to the OutStream
510
+ * Write a 64-bit signed integer to the FrtOutStream
515
511
  *
516
512
  *
517
- * @param os OutStream to write to
513
+ * @param os FrtOutStream to write to
518
514
  * @param num the 64-bit signed integer to write
519
- * @raise IO_ERROR if there is an error writing to the file-system
515
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
520
516
  */
521
- extern void os_write_i64(OutStream *os, f_i64 num);
517
+ extern void frt_os_write_i64(FrtOutStream *os, frt_i64 num);
522
518
 
523
519
  /**
524
- * Write a 32-bit unsigned integer to the OutStream
520
+ * Write a 32-bit unsigned integer to the FrtOutStream
525
521
  *
526
- * @param os OutStream to write to
522
+ * @param os FrtOutStream to write to
527
523
  * @param num the 32-bit unsigned integer to write
528
- * @raise IO_ERROR if there is an error writing to the file-system
524
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
529
525
  */
530
- extern void os_write_u32(OutStream *os, f_u32 num);
526
+ extern void frt_os_write_u32(FrtOutStream *os, frt_u32 num);
531
527
 
532
528
  /**
533
- * Write a 64-bit unsigned integer to the OutStream
529
+ * Write a 64-bit unsigned integer to the FrtOutStream
534
530
  *
535
- * @param os OutStream to write to
531
+ * @param os FrtOutStream to write to
536
532
  * @param num the 64-bit unsigned integer to write
537
- * @raise IO_ERROR if there is an error writing to the file-system
533
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
538
534
  */
539
- extern void os_write_u64(OutStream *os, f_u64 num);
535
+ extern void frt_os_write_u64(FrtOutStream *os, frt_u64 num);
540
536
 
541
537
  /**
542
- * Write an unsigned integer to OutStream in compressed VINT format.
538
+ * Write an unsigned integer to FrtOutStream in compressed VINT format.
543
539
  * TODO: describe VINT format
544
540
  *
545
- * @param os OutStream to write to
541
+ * @param os FrtOutStream to write to
546
542
  * @param num the integer to write
547
- * @raise IO_ERROR if there is an error writing to the file-system
543
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
548
544
  */
549
- extern void os_write_vint(OutStream *os, register unsigned int num);
545
+ extern void frt_os_write_vint(FrtOutStream *os, register unsigned int num);
550
546
 
551
547
  /**
552
- * Write an unsigned off_t to OutStream in compressed VINT format.
548
+ * Write an unsigned off_t to FrtOutStream in compressed VINT format.
553
549
  * TODO: describe VINT format
554
550
  *
555
- * @param os OutStream to write to
551
+ * @param os FrtOutStream to write to
556
552
  * @param num the off_t to write
557
- * @raise IO_ERROR if there is an error writing to the file-system
553
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
558
554
  */
559
- extern void os_write_voff_t(OutStream *os, register off_t num);
555
+ extern void frt_os_write_voff_t(FrtOutStream *os, register off_t num);
560
556
 
561
557
  /**
562
- * Write an unsigned long long to OutStream in compressed VINT format.
558
+ * Write an unsigned 64bit int to FrtOutStream in compressed VINT format.
563
559
  * TODO: describe VINT format
564
560
  *
565
- * @param os OutStream to write to
566
- * @param num the long long to write
567
- * @raise IO_ERROR if there is an error writing to the file-system
561
+ * @param os FrtOutStream to write to
562
+ * @param num the 64bit int to write
563
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
564
+ */
565
+ extern void frt_os_write_vll(FrtOutStream *os, register frt_u64 num);
566
+
567
+ /**
568
+ * Write a string with known length to the FrtOutStream. A string is an
569
+ * integer +length+ in VINT format (see frt_os_write_vint) followed by
570
+ * +length+ bytes. The string can then be read using frt_is_read_string.
571
+ *
572
+ * @param os FrtOutStream to write to
573
+ * @param str the string to write
574
+ * @param len the length of the string to write
575
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
568
576
  */
569
- extern void os_write_vll(OutStream *os, register unsigned long long num);
577
+ extern FRT_INLINE void frt_os_write_string_len(FrtOutStream *os,
578
+ const char *str,
579
+ int len);
570
580
 
571
581
  /**
572
- * Write a string to the OutStream. A string is an integer +length+ in VINT
573
- * format (see os_write_vint) followed by +length+ bytes. The string can then
574
- * be read using is_read_string.
582
+ * Write a string to the FrtOutStream. A string is an integer +length+ in VINT
583
+ * format (see frt_os_write_vint) followed by +length+ bytes. The string can then
584
+ * be read using frt_is_read_string.
575
585
  *
576
- * @param os OutStream to write to
586
+ * @param os FrtOutStream to write to
577
587
  * @param str the string to write
578
- * @raise IO_ERROR if there is an error writing to the file-system
588
+ * @raise FRT_IO_ERROR if there is an error writing to the file-system
579
589
  */
580
- extern void os_write_string(OutStream *os, char *str);
590
+ extern void frt_os_write_string(FrtOutStream *os, const char *str);
591
+
581
592
  /**
582
- * Get the current position within an InStream.
593
+ * Get the current position within an FrtInStream.
583
594
  *
584
- * @param is the InStream to get the current position from
585
- * @return the current position within the InStream +is+
595
+ * @param is the FrtInStream to get the current position from
596
+ * @return the current position within the FrtInStream +is+
586
597
  */
587
- extern off_t is_pos(InStream *is);
598
+ extern off_t frt_is_pos(FrtInStream *is);
588
599
 
589
600
  /**
590
- * Set the current position in InStream +is+ to +pos+.
601
+ * Set the current position in FrtInStream +is+ to +pos+.
591
602
  *
592
- * @param is the InStream to set the current position in
593
- * @param pos the position in InStream to seek
594
- * @raise IO_ERROR if there is a error seeking from the file-system
595
- * @raise EOF_ERROR if there is an attempt to seek past the end of the file
603
+ * @param is the FrtInStream to set the current position in
604
+ * @param pos the position in FrtInStream to seek
605
+ * @raise FRT_IO_ERROR if there is a error seeking from the file-system
606
+ * @raise FRT_EOF_ERROR if there is an attempt to seek past the end of the file
596
607
  */
597
- extern void is_seek(InStream *is, off_t pos);
608
+ extern void frt_is_seek(FrtInStream *is, off_t pos);
598
609
 
599
610
  /**
600
- * Close the InStream freeing all allocated resources.
611
+ * Close the FrtInStream freeing all allocated resources.
601
612
  *
602
- * @param is the InStream to close
603
- * @raise IO_ERROR if there is an error closing the associated file
613
+ * @param is the FrtInStream to close
614
+ * @raise FRT_IO_ERROR if there is an error closing the associated file
604
615
  */
605
- extern void is_close(InStream *is);
616
+ extern void frt_is_close(FrtInStream *is);
606
617
 
607
618
  /**
608
- * Clone the InStream allocating a new InStream structure
619
+ * Clone the FrtInStream allocating a new FrtInStream structure
609
620
  *
610
- * @param is the InStream to clone
611
- * @return a newly allocated InStream which is a clone of +is+
621
+ * @param is the FrtInStream to clone
622
+ * @return a newly allocated FrtInStream which is a clone of +is+
612
623
  */
613
- extern InStream *is_clone(InStream *is);
624
+ extern FrtInStream *frt_is_clone(FrtInStream *is);
614
625
 
615
626
  /**
616
- * Read a singly byte (unsigned char) from the InStream +is+.
627
+ * Read a singly byte (unsigned char) from the FrtInStream +is+.
617
628
  *
618
629
  * @param is the Instream to read from
619
- * @return a single unsigned char read from the InStream +is+
620
- * @raise IO_ERROR if there is a error reading from the file-system
621
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
630
+ * @return a single unsigned char read from the FrtInStream +is+
631
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
632
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
622
633
  */
623
- extern INLINE uchar is_read_byte(InStream *is);
634
+ extern FRT_INLINE frt_uchar frt_is_read_byte(FrtInStream *is);
624
635
 
625
636
  /**
626
- * Read +len+ bytes from InStream +is+ and write them to buffer +buf+
637
+ * Read +len+ bytes from FrtInStream +is+ and write them to buffer +buf+
627
638
  *
628
- * @param is the InStream to read from
639
+ * @param is the FrtInStream to read from
629
640
  * @param buf the buffer to read into, that is copy the bytes read to
630
641
  * @param len the number of bytes to read
631
642
  * @return the resultant buffer +buf+
632
- * @raise IO_ERROR if there is a error reading from the file-system
633
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
643
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
644
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
634
645
  */
635
- extern uchar *is_read_bytes(InStream *is, uchar *buf, int len);
646
+ extern frt_uchar *frt_is_read_bytes(FrtInStream *is, frt_uchar *buf, int len);
636
647
 
637
648
  /**
638
- * Read a 32-bit unsigned integer from the InStream.
649
+ * Read a 32-bit unsigned integer from the FrtInStream.
639
650
  *
640
- * @param is the InStream to read from
651
+ * @param is the FrtInStream to read from
641
652
  * @return a 32-bit unsigned integer
642
- * @raise IO_ERROR if there is a error reading from the file-system
643
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
653
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
654
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
644
655
  */
645
- extern f_i32 is_read_i32(InStream *is);
656
+ extern frt_i32 frt_is_read_i32(FrtInStream *is);
646
657
 
647
658
  /**
648
- * Read a 64-bit unsigned integer from the InStream.
659
+ * Read a 64-bit unsigned integer from the FrtInStream.
649
660
  *
650
- * @param is the InStream to read from
661
+ * @param is the FrtInStream to read from
651
662
  * @return a 64-bit unsigned integer
652
- * @raise IO_ERROR if there is a error reading from the file-system
653
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
663
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
664
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
654
665
  */
655
- extern f_i64 is_read_i64(InStream *is);
666
+ extern frt_i64 frt_is_read_i64(FrtInStream *is);
656
667
 
657
668
  /**
658
- * Read a 32-bit signed integer from the InStream.
669
+ * Read a 32-bit signed integer from the FrtInStream.
659
670
  *
660
- * @param is the InStream to read from
671
+ * @param is the FrtInStream to read from
661
672
  * @return a 32-bit signed integer
662
- * @raise IO_ERROR if there is a error reading from the file-system
663
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
673
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
674
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
664
675
  */
665
- extern f_u32 is_read_u32(InStream *is);
676
+ extern frt_u32 frt_is_read_u32(FrtInStream *is);
666
677
 
667
678
  /**
668
- * Read a 64-bit signed integer from the InStream.
679
+ * Read a 64-bit signed integer from the FrtInStream.
669
680
  *
670
- * @param is the InStream to read from
681
+ * @param is the FrtInStream to read from
671
682
  * @return a 64-bit signed integer
672
- * @raise IO_ERROR if there is a error reading from the file-system
673
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
683
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
684
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
674
685
  */
675
- extern f_u64 is_read_u64(InStream *is);
686
+ extern frt_u64 frt_is_read_u64(FrtInStream *is);
676
687
 
677
688
  /**
678
- * Read a compressed (VINT) unsigned integer from the InStream.
689
+ * Read a compressed (VINT) unsigned integer from the FrtInStream.
679
690
  * TODO: describe VINT format
680
691
  *
681
- * @param is the InStream to read from
692
+ * @param is the FrtInStream to read from
682
693
  * @return an int
683
- * @raise IO_ERROR if there is a error reading from the file-system
684
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
694
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
695
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
685
696
  */
686
- extern INLINE unsigned int is_read_vint(InStream *is);
697
+ extern FRT_INLINE unsigned int frt_is_read_vint(FrtInStream *is);
687
698
 
688
699
  /**
689
700
  * Skip _cnt_ vints. This is a convenience method used for performance reasons
690
701
  * to skip large numbers of vints. It is mostly used by TermDocEnums. When
691
702
  * skipping positions os the proximity index file.
692
703
  *
693
- * @param is the InStream to read from
704
+ * @param is the FrtInStream to read from
694
705
  * @param cnt the number of vints to skip
695
- * @raise IO_ERROR if there is a error reading from the file-system
696
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
706
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
707
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
697
708
  */
698
- extern INLINE void is_skip_vints(InStream *is, register int cnt);
709
+ extern FRT_INLINE void frt_is_skip_vints(FrtInStream *is, register int cnt);
699
710
 
700
711
  /**
701
- * Read a compressed (VINT) unsigned off_t from the InStream.
712
+ * Read a compressed (VINT) unsigned off_t from the FrtInStream.
702
713
  * TODO: describe VINT format
703
714
  *
704
- * @param is the InStream to read from
715
+ * @param is the FrtInStream to read from
705
716
  * @return a off_t
706
- * @raise IO_ERROR if there is a error reading from the file-system
707
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
717
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
718
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
708
719
  */
709
- extern INLINE off_t is_read_voff_t(InStream *is);
720
+ extern FRT_INLINE off_t frt_is_read_voff_t(FrtInStream *is);
710
721
 
711
722
  /**
712
- * Read a compressed (VINT) unsigned long long from the InStream.
723
+ * Read a compressed (VINT) unsigned 64bit int from the FrtInStream.
713
724
  * TODO: describe VINT format
714
725
  *
715
- * @param is the InStream to read from
716
- * @return a long long
717
- * @raise IO_ERROR if there is a error reading from the file-system
718
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
726
+ * @param is the FrtInStream to read from
727
+ * @return a 64bit int
728
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
729
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
719
730
  */
720
- extern INLINE unsigned long long is_read_vll(InStream *is);
731
+ extern FRT_INLINE frt_u64 frt_is_read_vll(FrtInStream *is);
721
732
 
722
733
  /**
723
- * Read a string from the InStream. A string is an integer +length+ in vint
724
- * format (see is_read_vint) followed by +length+ bytes. This is the format
725
- * used by os_write_string.
734
+ * Read a string from the FrtInStream. A string is an integer +length+ in vint
735
+ * format (see frt_is_read_vint) followed by +length+ bytes. This is the format
736
+ * used by frt_os_write_string.
726
737
  *
727
- * @param is the InStream to read from
738
+ * @param is the FrtInStream to read from
728
739
  * @return a null byte delimited string
729
- * @raise IO_ERROR if there is a error reading from the file-system
730
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
740
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
741
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
731
742
  */
732
- extern char *is_read_string(InStream *is);
743
+ extern char *frt_is_read_string(FrtInStream *is);
733
744
 
734
745
  /**
735
- * Read a string from the InStream. A string is an integer +length+ in vint
736
- * format (see is_read_vint) followed by +length+ bytes. This is the format
737
- * used by os_write_string. This method is similar to +is_read_string+ except
746
+ * Read a string from the FrtInStream. A string is an integer +length+ in vint
747
+ * format (see frt_is_read_vint) followed by +length+ bytes. This is the format
748
+ * used by frt_os_write_string. This method is similar to +frt_is_read_string+ except
738
749
  * that it will safely free all memory if there is an error reading the
739
750
  * string.
740
751
  *
741
- * @param is the InStream to read from
752
+ * @param is the FrtInStream to read from
742
753
  * @return a null byte delimited string
743
- * @raise IO_ERROR if there is a error reading from the file-system
744
- * @raise EOF_ERROR if there is an attempt to read past the end of the file
754
+ * @raise FRT_IO_ERROR if there is a error reading from the file-system
755
+ * @raise FRT_EOF_ERROR if there is an attempt to read past the end of the file
745
756
  */
746
- extern char *is_read_string_safe(InStream *is);
757
+ extern char *frt_is_read_string_safe(FrtInStream *is);
747
758
 
748
759
  /**
749
- * Copy cnt bytes from Instream _is_ to OutStream _os_.
760
+ * Copy cnt bytes from Instream _is_ to FrtOutStream _os_.
750
761
  *
751
- * @param is the InStream to read from
752
- * @param os the OutStream to write to
753
- * @raise IO_ERROR
754
- * @raise EOF_ERROR
762
+ * @param is the FrtInStream to read from
763
+ * @param os the FrtOutStream to write to
764
+ * @raise FRT_IO_ERROR
765
+ * @raise FRT_EOF_ERROR
755
766
  */
756
- extern void is2os_copy_bytes(InStream *is, OutStream *os, int cnt);
767
+ extern void frt_is2os_copy_bytes(FrtInStream *is, FrtOutStream *os, int cnt);
757
768
 
758
769
  /**
759
- * Copy cnt vints from Instream _is_ to OutStream _os_.
770
+ * Copy cnt vints from Instream _is_ to FrtOutStream _os_.
760
771
  *
761
- * @param is the InStream to read from
762
- * @param os the OutStream to write to
763
- * @raise IO_ERROR
764
- * @raise EOF_ERROR
772
+ * @param is the FrtInStream to read from
773
+ * @param os the FrtOutStream to write to
774
+ * @raise FRT_IO_ERROR
775
+ * @raise FRT_EOF_ERROR
765
776
  */
766
- extern void is2os_copy_vints(InStream *is, OutStream *os, int cnt);
777
+ extern void frt_is2os_copy_vints(FrtInStream *is, FrtOutStream *os, int cnt);
767
778
 
768
779
  /**
769
780
  * Print the filenames in a store to a buffer.
770
781
  *
771
782
  * @param store the store to get the filenames from
772
783
  */
773
- extern char *store_to_s(Store *store);
784
+ extern char *frt_store_to_s(FrtStore *store);
785
+
786
+ extern FrtLock *frt_open_lock(FrtStore *store, const char *lockname);
787
+ extern void frt_close_lock(FrtLock *lock);
788
+
789
+ /* required by submodules
790
+ * FIXME document. Perhaps include in different header?? */
791
+ extern FrtStore *frt_store_new();
792
+ extern void frt_store_destroy(FrtStore *store);
793
+ extern FrtOutStream *frt_os_new();
794
+ extern FrtInStream *frt_is_new();
795
+ extern int frt_file_is_lock(const char *filename);
796
+ extern bool frt_file_name_filter_is_index_file(const char *file_name,
797
+ bool include_locks);
774
798
 
775
- extern Lock *open_lock(Store *store, char *lockname);
776
- extern void close_lock(Lock *lock);
777
799
  #endif