IDZEBRA  2.2.7
zebramap.c
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <assert.h>
24 #include <stdlib.h>
25 #include <ctype.h>
26 
27 #include <charmap.h>
28 #include <attrfind.h>
29 #include <yaz/yaz-util.h>
30 #include <yaz/snprintf.h>
31 
32 #if YAZ_HAVE_ICU
33 #include <yaz/icu.h>
34 #endif
35 #include <zebramap.h>
36 
37 #define ZEBRA_MAP_TYPE_SORT 1
38 #define ZEBRA_MAP_TYPE_INDEX 2
39 #define ZEBRA_MAP_TYPE_STATICRANK 3
40 
41 #define ZEBRA_REPLACE_ANY 300
42 
43 struct zebra_map {
44  const char *id;
49  int type;
50  int use_chain;
51  int debug;
52  union {
53  struct {
55  } sort;
56  } u;
58  const char *maptab_name;
60 #if YAZ_HAVE_XML2
61  xmlDocPtr doc;
62 #endif
63 #if YAZ_HAVE_ICU
64  struct icu_chain *icu_chain;
65 #endif
66  WRBUF input_str;
67  WRBUF print_str;
68  size_t simple_off;
69  struct zebra_map *next;
70 };
71 
72 struct zebra_maps_s {
73  char *tabpath;
74  char *tabroot;
75  NMEM nmem;
76  char temp_map_str[2];
77  const char *temp_map_ptr[2];
78  WRBUF wrbuf_1;
82 };
83 
85 {
86  struct zebra_map *zm = zms->map_list;
87  while (zm)
88  {
89  if (zm->maptab)
91 #if YAZ_HAVE_ICU
92  if (zm->icu_chain)
93  icu_chain_destroy(zm->icu_chain);
94 #endif
95 #if YAZ_HAVE_XML2
96  xmlFreeDoc(zm->doc);
97 #endif
98  wrbuf_destroy(zm->input_str);
99  wrbuf_destroy(zm->print_str);
100  zm = zm->next;
101  }
102  wrbuf_destroy(zms->wrbuf_1);
103  nmem_destroy(zms->nmem);
104  xfree(zms);
105 }
106 
107 zebra_map_t zebra_add_map(zebra_maps_t zms, const char *index_type,
108  int map_type)
109 {
110  zebra_map_t zm = (zebra_map_t) nmem_malloc(zms->nmem, sizeof(*zm));
111 
112  zm->zebra_maps = zms;
113  zm->id = nmem_strdup(zms->nmem, index_type);
114  zm->maptab_name = 0;
115  zm->use_chain = 0;
116  zm->debug = 0;
117  zm->maptab = 0;
118  zm->type = map_type;
119  zm->completeness = 0;
120  zm->positioned = 0;
121  zm->alwaysmatches = 0;
122  zm->first_in_field = 0;
123 
124  if (zms->last_map)
125  zms->last_map->next = zm;
126  else
127  zms->map_list = zm;
128  zms->last_map = zm;
129  zm->next = 0;
130 #if YAZ_HAVE_ICU
131  zm->icu_chain = 0;
132 #endif
133 #if YAZ_HAVE_XML2
134  zm->doc = 0;
135 #endif
136  zm->input_str = wrbuf_alloc();
137  zm->print_str = wrbuf_alloc();
138  return zm;
139 }
140 
141 static int parse_command(zebra_maps_t zms, int argc, char **argv,
142  const char *fname, int lineno)
143 {
144  zebra_map_t zm = zms->last_map;
145  if (argc == 1)
146  {
147  yaz_log(YLOG_WARN, "%s:%d: Missing arguments for '%s'",
148  fname, lineno, argv[0]);
149  return -1;
150  }
151  if (argc > 2)
152  {
153  yaz_log(YLOG_WARN, "%s:%d: Too many arguments for '%s'",
154  fname, lineno, argv[0]);
155  return -1;
156  }
157  if (!yaz_matchstr(argv[0], "index"))
158  {
159  zm = zebra_add_map(zms, argv[1], ZEBRA_MAP_TYPE_INDEX);
160  zm->positioned = 1;
161  }
162  else if (!yaz_matchstr(argv[0], "sort"))
163  {
164  zm = zebra_add_map(zms, argv[1], ZEBRA_MAP_TYPE_SORT);
165  zm->u.sort.entry_size = 80;
166  }
167  else if (!yaz_matchstr(argv[0], "staticrank"))
168  {
169  zm = zebra_add_map(zms, argv[1], ZEBRA_MAP_TYPE_STATICRANK);
170  zm->completeness = 1;
171  }
172  else if (!zm)
173  {
174  yaz_log(YLOG_WARN, "%s:%d: Missing sort/index before '%s'",
175  fname, lineno, argv[0]);
176  return -1;
177  }
178  else if (!yaz_matchstr(argv[0], "charmap") && argc == 2)
179  {
180  if (zm->type != ZEBRA_MAP_TYPE_STATICRANK)
181  zm->maptab_name = nmem_strdup(zms->nmem, argv[1]);
182  else
183  {
184  yaz_log(YLOG_WARN|YLOG_FATAL, "%s:%d: charmap for "
185  "staticrank is invalid", fname, lineno);
186  yaz_log(YLOG_LOG, "Type is %d", zm->type);
187  return -1;
188  }
189  }
190  else if (!yaz_matchstr(argv[0], "completeness") && argc == 2)
191  {
192  zm->completeness = atoi(argv[1]);
193  }
194  else if (!yaz_matchstr(argv[0], "position") && argc == 2)
195  {
196  zm->positioned = atoi(argv[1]);
197  }
198  else if (!yaz_matchstr(argv[0], "alwaysmatches") && argc == 2)
199  {
200  if (zm->type != ZEBRA_MAP_TYPE_STATICRANK)
201  zm->alwaysmatches = atoi(argv[1]);
202  else
203  {
204  yaz_log(YLOG_WARN|YLOG_FATAL, "%s:%d: alwaysmatches for "
205  "staticrank is invalid", fname, lineno);
206  return -1;
207  }
208  }
209  else if (!yaz_matchstr(argv[0], "firstinfield") && argc == 2)
210  {
211  zm->first_in_field = atoi(argv[1]);
212  }
213  else if (!yaz_matchstr(argv[0], "entrysize") && argc == 2)
214  {
215  if (zm->type == ZEBRA_MAP_TYPE_SORT)
216  zm->u.sort.entry_size = atoi(argv[1]);
217  else
218  {
219  yaz_log(YLOG_WARN,
220  "%s:%d: entrysize only valid in sort section",
221  fname, lineno);
222  return -1;
223  }
224  }
225  else if (!yaz_matchstr(argv[0], "simplechain"))
226  {
227  zm->use_chain = 1;
228 #if YAZ_HAVE_ICU
229  zm->icu_chain = 0;
230 #endif
231  }
232  else if (!yaz_matchstr(argv[0], "icuchain"))
233  {
234  char full_path[1024];
235  if (!yaz_filepath_resolve(argv[1], zms->tabpath, zms->tabroot,
236  full_path))
237  {
238  yaz_log(YLOG_WARN, "%s:%d: Could not locate icuchain config '%s'",
239  fname, lineno, argv[1]);
240  return -1;
241  }
242 #if YAZ_HAVE_XML2
243  zm->doc = xmlParseFile(full_path);
244  if (!zm->doc)
245  {
246  yaz_log(YLOG_WARN, "%s:%d: Could not load icuchain config '%s'",
247  fname, lineno, argv[1]);
248  return -1;
249  }
250  else
251  {
252 #if YAZ_HAVE_ICU
253  UErrorCode status;
254  xmlNode *xml_node = xmlDocGetRootElement(zm->doc);
255  zm->icu_chain =
256  icu_chain_xml_config(xml_node,
257 /* not sure about sort for this function yet.. */
258 #if 1
259  1,
260 #else
261  zm->type == ZEBRA_MAP_TYPE_SORT,
262 #endif
263  &status);
264  if (!zm->icu_chain)
265  {
266  yaz_log(YLOG_WARN, "%s:%d: Failed to load ICU chain %s",
267  fname, lineno, argv[1]);
268  }
269  zm->use_chain = 1;
270 #else
271  yaz_log(YLOG_WARN, "%s:%d: ICU support unavailable",
272  fname, lineno);
273  return -1;
274 #endif
275  }
276 #else
277  yaz_log(YLOG_WARN, "%s:%d: XML support unavailable",
278  fname, lineno);
279  return -1;
280 #endif
281  }
282  else if (!yaz_matchstr(argv[0], "debug") && argc == 2)
283  {
284  zm->debug = atoi(argv[1]);
285  }
286  else
287  {
288  yaz_log(YLOG_WARN, "%s:%d: Unrecognized directive '%s'",
289  fname, lineno, argv[0]);
290  return -1;
291  }
292  return 0;
293 }
294 
296 {
297  FILE *f;
298  char line[512];
299  char *argv[10];
300  int argc;
301  int lineno = 0;
302  int failures = 0;
303 
304  if (!(f = yaz_fopen(zms->tabpath, fname, "r", zms->tabroot)))
305  {
306  yaz_log(YLOG_ERRNO|YLOG_FATAL, "%s", fname);
307  return ZEBRA_FAIL;
308  }
309  while ((argc = readconf_line(f, &lineno, line, 512, argv, 10)))
310  {
311  int r = parse_command(zms, argc, argv, fname, lineno);
312  if (r)
313  failures++;
314  }
315  yaz_fclose(f);
316 
317  if (failures)
318  return ZEBRA_FAIL;
319 
320  (zms->no_files_read)++;
321  return ZEBRA_OK;
322 }
323 
324 zebra_maps_t zebra_maps_open(Res res, const char *base_path,
325  const char *profile_path)
326 {
327  zebra_maps_t zms = (zebra_maps_t) xmalloc(sizeof(*zms));
328 
329  zms->nmem = nmem_create();
330  zms->tabpath = profile_path ? nmem_strdup(zms->nmem, profile_path) : 0;
331  zms->tabroot = 0;
332  if (base_path)
333  zms->tabroot = nmem_strdup(zms->nmem, base_path);
334  zms->map_list = 0;
335  zms->last_map = 0;
336 
337  zms->temp_map_str[0] = '\0';
338  zms->temp_map_str[1] = '\0';
339 
340  zms->temp_map_ptr[0] = zms->temp_map_str;
341  zms->temp_map_ptr[1] = NULL;
342 
343  zms->wrbuf_1 = wrbuf_alloc();
344 
345  zms->no_files_read = 0;
346  return zms;
347 }
348 
350 {
352  zm->u.sort.entry_size = 80;
353 }
354 
356 {
357  zebra_map_t zm;
358  for (zm = zms->map_list; zm; zm = zm->next)
359  if (!strcmp(zm->id, id))
360  break;
361  return zm;
362 }
363 
365 {
366  struct zebra_map *zm = zebra_map_get(zms, id);
367  if (!zm)
368  {
369  zm = zebra_add_map(zms, id, ZEBRA_MAP_TYPE_INDEX);
370 
371  /* no reason to warn if no maps are read from file */
372  if (zms->no_files_read)
373  yaz_log(YLOG_WARN, "Unknown register type: %s", id);
374 
375  zm->maptab_name = nmem_strdup(zms->nmem, "@");
376  zm->completeness = 0;
377  zm->positioned = 1;
378  }
379  return zm;
380 }
381 
383 {
384  if (!zm->maptab)
385  {
386  if (!zm->maptab_name || !yaz_matchstr(zm->maptab_name, "@"))
387  return NULL;
388  if (!(zm->maptab = chrmaptab_create(zm->zebra_maps->tabpath,
389  zm->maptab_name,
390  zm->zebra_maps->tabroot)))
391  yaz_log(YLOG_WARN, "Failed to read character table %s",
392  zm->maptab_name);
393  else
394  yaz_log(YLOG_DEBUG, "Read character table %s", zm->maptab_name);
395  }
396  return zm->maptab;
397 }
398 
400  const char **from, int len, int first)
401 {
403  if (maptab)
404  return chr_map_input(maptab, from, len, first);
405 
406  zm->zebra_maps->temp_map_str[0] = **from;
407 
408  (*from)++;
409  return zm->zebra_maps->temp_map_ptr;
410 }
411 
413  const char **from, int len, int *q_map_match)
414 {
416 
417  *q_map_match = 0;
419  if (maptab)
420  {
421  const char **map;
422  map = chr_map_q_input(maptab, from, len, 0);
423  if (map && map[0])
424  {
425  *q_map_match = 1;
426  return map;
427  }
428  map = chr_map_input(maptab, from, len, 0);
429  if (map)
430  return map;
431  }
432  zm->zebra_maps->temp_map_str[0] = **from;
433 
434  (*from)++;
435  return zm->zebra_maps->temp_map_ptr;
436 }
437 
439  const char **from)
440 {
442  if (!maptab)
443  return 0;
444  return chr_map_output(maptab, from, 1);
445 }
446 
447 
448 /* ------------------------------------ */
449 
451 {
452  if (zm)
453  return zm->completeness;
454  return 0;
455 }
456 
458 {
459  if (zm)
460  return zm->positioned;
461  return 0;
462 }
463 
465 {
466  if (zm)
467  return zm->type == ZEBRA_MAP_TYPE_INDEX;
468  return 0;
469 }
470 
472 {
473  if (zm)
474  return zm->type == ZEBRA_MAP_TYPE_STATICRANK;
475  return 0;
476 }
477 
479 {
480  if (zm)
481  return zm->type == ZEBRA_MAP_TYPE_SORT;
482  return 0;
483 }
484 
486 {
487  if (zm)
488  return zm->alwaysmatches;
489  return 0;
490 }
491 
493 {
494  if (zm)
495  return zm->first_in_field;
496  return 0;
497 }
498 
499 int zebra_maps_sort(zebra_maps_t zms, Z_SortAttributes *sortAttributes,
500  int *numerical)
501 {
502  AttrType use;
503  AttrType structure;
504  int structure_value;
505  attr_init_AttrList(&use, sortAttributes->list, 1);
506  attr_init_AttrList(&structure, sortAttributes->list, 4);
507 
508  *numerical = 0;
509  structure_value = attr_find(&structure, 0);
510  if (structure_value == 109)
511  *numerical = 1;
512  return attr_find(&use, NULL);
513 }
514 
515 int zebra_maps_attr(zebra_maps_t zms, Z_AttributesPlusTerm *zapt,
516  const char **index_type, char **search_type, char *rank_type,
517  int *complete_flag, int *sort_flag)
518 {
520  AttrType structure;
521  AttrType relation;
522  AttrType sort_relation;
523  AttrType weight;
524  AttrType use;
525  int completeness_value;
526  int structure_value;
527  const char *structure_str = 0;
528  int relation_value;
529  int sort_relation_value;
530  int weight_value;
531  int use_value;
532 
533  attr_init_APT(&structure, zapt, 4);
534  attr_init_APT(&completeness, zapt, 6);
535  attr_init_APT(&relation, zapt, 2);
536  attr_init_APT(&sort_relation, zapt, 7);
537  attr_init_APT(&weight, zapt, 9);
538  attr_init_APT(&use, zapt, 1);
539 
540  completeness_value = attr_find(&completeness, NULL);
541  structure_value = attr_find_ex(&structure, NULL, &structure_str);
542  relation_value = attr_find(&relation, NULL);
543  sort_relation_value = attr_find(&sort_relation, NULL);
544  weight_value = attr_find(&weight, NULL);
545  use_value = attr_find(&use, NULL);
546 
547  if (completeness_value == 2 || completeness_value == 3)
548  *complete_flag = 1;
549  else
550  *complete_flag = 0;
551  *index_type = 0;
552 
553  *sort_flag =(sort_relation_value > 0) ? 1 : 0;
554  *search_type = "phrase";
555  strcpy(rank_type, "void");
556  if (relation_value == 102)
557  {
558  if (weight_value == -1)
559  weight_value = 34;
560  yaz_snprintf(rank_type, 128, "rank,w=%d,u=%d", weight_value, use_value);
561  }
562  if (*complete_flag)
563  *index_type = "p";
564  else
565  *index_type = "w";
566  switch (structure_value)
567  {
568  case 6: /* word list */
569  *search_type = "and-list";
570  break;
571  case 105: /* free-form-text */
572  *search_type = "or-list";
573  break;
574  case 106: /* document-text */
575  *search_type = "or-list";
576  break;
577  case -1:
578  case 1: /* phrase */
579  case 2: /* word */
580  case 108: /* string */
581  *search_type = "phrase";
582  break;
583  case 107: /* local-number */
584  *search_type = "local";
585  *index_type = 0;
586  break;
587  case 109: /* numeric string */
588  *index_type = "n";
589  *search_type = "numeric";
590  break;
591  case 104: /* urx */
592  *index_type = "u";
593  *search_type = "phrase";
594  break;
595  case 3: /* key */
596  *index_type = "0";
597  *search_type = "phrase";
598  break;
599  case 4: /* year */
600  *index_type = "y";
601  *search_type = "phrase";
602  break;
603  case 5: /* date */
604  *index_type = "d";
605  *search_type = "phrase";
606  break;
607  case -2:
608  if (structure_str && *structure_str)
609  *index_type = structure_str;
610  else
611  return -1;
612  break;
613  default:
614  return -1;
615  }
616  return 0;
617 }
618 
619 WRBUF zebra_replace(zebra_map_t zm, const char *ex_list,
620  const char *input_str, int input_len)
621 {
622  wrbuf_rewind(zm->zebra_maps->wrbuf_1);
623  wrbuf_write(zm->zebra_maps->wrbuf_1, input_str, input_len);
624  return zm->zebra_maps->wrbuf_1;
625 }
626 
627 #define SE_CHARS ";,.()-/?<> \r\n\t"
628 
630  const char **result_buf, size_t *result_len)
631 {
632  char *buf = wrbuf_buf(zm->input_str);
633  size_t len = wrbuf_len(zm->input_str);
634  size_t i = zm->simple_off;
635  size_t start;
636 
637  while (i < len && strchr(SE_CHARS, buf[i]))
638  i++;
639  start = i;
640  while (i < len && !strchr(SE_CHARS, buf[i]))
641  {
642  if (buf[i] > 32 && buf[i] < 127)
643  buf[i] = tolower(buf[i]);
644  i++;
645  }
646 
647  zm->simple_off = i;
648  if (start != i)
649  {
650  *result_buf = buf + start;
651  *result_len = i - start;
652  return 1;
653  }
654  return 0;
655  }
656 
657 
659  const char **result_buf, size_t *result_len,
660  const char **display_buf, size_t *display_len)
661 {
662  assert(zm->use_chain);
663 
664 #if YAZ_HAVE_ICU
665  if (!zm->icu_chain)
666  return tokenize_simple(zm, result_buf, result_len);
667  else
668  {
669  UErrorCode status;
670  while (icu_chain_next_token(zm->icu_chain, &status))
671  {
672  if (!U_SUCCESS(status))
673  return 0;
674  *result_buf = icu_chain_token_sortkey(zm->icu_chain);
675  assert(*result_buf);
676 
677  *result_len = strlen(*result_buf);
678 
679  if (display_buf)
680  {
681  *display_buf = icu_chain_token_display(zm->icu_chain);
682  if (display_len)
683  *display_len = strlen(*display_buf);
684  }
685  if (zm->debug)
686  {
687  wrbuf_rewind(zm->print_str);
688  wrbuf_write_escaped(zm->print_str, *result_buf, *result_len);
689  yaz_log(YLOG_LOG, "output %s", wrbuf_cstr(zm->print_str));
690  }
691 
692  if (**result_buf != '\0')
693  return 1;
694  }
695  }
696  return 0;
697 #else
698  return tokenize_simple(zm, result_buf, result_len);
699 #endif
700 }
701 
703  const char *buf, size_t len)
704 {
705 #if YAZ_HAVE_ICU
706  int ret;
707 #endif
708  assert(zm->use_chain);
709 
710  wrbuf_rewind(zm->input_str);
711  wrbuf_write(zm->input_str, buf, len);
712  zm->simple_off = 0;
713 #if YAZ_HAVE_ICU
714  if (zm->icu_chain)
715  {
716  UErrorCode status;
717  if (zm->debug)
718  {
719  wrbuf_rewind(zm->print_str);
720  wrbuf_write_escaped(zm->print_str, wrbuf_buf(zm->input_str),
721  wrbuf_len(zm->input_str));
722 
723  yaz_log(YLOG_LOG, "input %s",
724  wrbuf_cstr(zm->print_str));
725  }
726  ret = icu_chain_assign_cstr(zm->icu_chain,
727  wrbuf_cstr(zm->input_str), &status);
728  if (!ret && !U_SUCCESS(status))
729  {
730  if (zm->debug)
731  {
732  yaz_log(YLOG_WARN, "bad encoding for input");
733  }
734  return -1;
735  }
736  }
737 #endif
738  return 0;
739 }
740 
742 {
743  assert(zm);
744 #if YAZ_HAVE_ICU
745  return zm->use_chain;
746 #else
747  return 0;
748 #endif
749 }
750 
751 
752 /*
753  * Local variables:
754  * c-basic-offset: 4
755  * c-file-style: "Stroustrup"
756  * indent-tabs-mode: nil
757  * End:
758  * vim: shiftwidth=4 tabstop=8 expandtab
759  */
760 
int attr_find(AttrType *src, const Odr_oid **attribute_set_oid)
Definition: attrfind.c:99
void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
Definition: attrfind.c:27
void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
Definition: attrfind.c:36
int attr_find_ex(AttrType *src, const Odr_oid **attribute_set_oid, const char **string_value)
Definition: attrfind.c:45
void chrmaptab_destroy(chrmaptab tab)
Definition: charmap.c:748
const char ** chr_map_q_input(chrmaptab maptab, const char **from, int len, int first)
Definition: charmap.c:207
const char ** chr_map_input(chrmaptab t, const char **from, int len, int first)
Definition: charmap.c:194
const char * chr_map_output(chrmaptab t, const char **from, int len)
Definition: charmap.c:221
chrmaptab chrmaptab_create(const char *tabpath, const char *name, const char *tabroot)
Definition: charmap.c:513
Definition: res.c:46
int debug
Definition: zebramap.c:51
const char * maptab_name
Definition: zebramap.c:58
int use_chain
Definition: zebramap.c:50
int alwaysmatches
Definition: zebramap.c:47
int completeness
Definition: zebramap.c:45
WRBUF print_str
Definition: zebramap.c:67
int entry_size
Definition: zebramap.c:54
WRBUF input_str
Definition: zebramap.c:66
const char * id
Definition: zebramap.c:44
size_t simple_off
Definition: zebramap.c:68
struct zebra_map::@11::@12 sort
int positioned
Definition: zebramap.c:46
struct zebra_map * next
Definition: zebramap.c:69
zebra_maps_t zebra_maps
Definition: zebramap.c:59
chrmaptab maptab
Definition: zebramap.c:57
int first_in_field
Definition: zebramap.c:48
union zebra_map::@11 u
int type
Definition: zebramap.c:49
const char * temp_map_ptr[2]
Definition: zebramap.c:77
zebra_map_t last_map
Definition: zebramap.c:81
NMEM nmem
Definition: zebramap.c:75
char * tabroot
Definition: zebramap.c:74
char * tabpath
Definition: zebramap.c:73
zebra_map_t map_list
Definition: zebramap.c:80
char temp_map_str[2]
Definition: zebramap.c:76
WRBUF wrbuf_1
Definition: zebramap.c:78
int no_files_read
Definition: zebramap.c:79
#define ZEBRA_FAIL
Definition: util.h:81
#define ZEBRA_OK
Definition: util.h:82
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80
int zebra_maps_is_index(zebra_map_t zm)
Definition: zebramap.c:464
zebra_map_t zebra_map_get(zebra_maps_t zms, const char *id)
Definition: zebramap.c:355
static int parse_command(zebra_maps_t zms, int argc, char **argv, const char *fname, int lineno)
Definition: zebramap.c:141
zebra_map_t zebra_add_map(zebra_maps_t zms, const char *index_type, int map_type)
Definition: zebramap.c:107
int zebra_maps_is_alwaysmatches(zebra_map_t zm)
Definition: zebramap.c:485
int zebra_maps_is_first_in_field(zebra_map_t zm)
Definition: zebramap.c:492
int zebra_map_tokenize_next(zebra_map_t zm, const char **result_buf, size_t *result_len, const char **display_buf, size_t *display_len)
Definition: zebramap.c:658
void zebra_maps_define_default_sort(zebra_maps_t zms)
Definition: zebramap.c:349
chrmaptab zebra_charmap_get(zebra_map_t zm)
Definition: zebramap.c:382
#define ZEBRA_MAP_TYPE_INDEX
Definition: zebramap.c:38
int zebra_maps_is_sort(zebra_map_t zm)
Definition: zebramap.c:478
void zebra_maps_close(zebra_maps_t zms)
Definition: zebramap.c:84
int zebra_maps_is_staticrank(zebra_map_t zm)
Definition: zebramap.c:471
int zebra_maps_is_positioned(zebra_map_t zm)
Definition: zebramap.c:457
#define ZEBRA_MAP_TYPE_SORT
Definition: zebramap.c:37
int zebra_maps_is_icu(zebra_map_t zm)
Definition: zebramap.c:741
#define ZEBRA_MAP_TYPE_STATICRANK
Definition: zebramap.c:39
int zebra_map_tokenize_start(zebra_map_t zm, const char *buf, size_t len)
Definition: zebramap.c:702
const char * zebra_maps_output(zebra_map_t zm, const char **from)
Definition: zebramap.c:438
int zebra_maps_sort(zebra_maps_t zms, Z_SortAttributes *sortAttributes, int *numerical)
Definition: zebramap.c:499
const char ** zebra_maps_search(zebra_map_t zm, const char **from, int len, int *q_map_match)
Definition: zebramap.c:412
int zebra_maps_is_complete(zebra_map_t zm)
Definition: zebramap.c:450
#define SE_CHARS
Definition: zebramap.c:627
ZEBRA_RES zebra_maps_read_file(zebra_maps_t zms, const char *fname)
Definition: zebramap.c:295
WRBUF zebra_replace(zebra_map_t zm, const char *ex_list, const char *input_str, int input_len)
Definition: zebramap.c:619
int zebra_maps_attr(zebra_maps_t zms, Z_AttributesPlusTerm *zapt, const char **index_type, char **search_type, char *rank_type, int *complete_flag, int *sort_flag)
Definition: zebramap.c:515
zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, const char *id)
Definition: zebramap.c:364
static int tokenize_simple(zebra_map_t zm, const char **result_buf, size_t *result_len)
Definition: zebramap.c:629
const char ** zebra_maps_input(zebra_map_t zm, const char **from, int len, int first)
Definition: zebramap.c:399
zebra_maps_t zebra_maps_open(Res res, const char *base_path, const char *profile_path)
Definition: zebramap.c:324
struct zebra_map * zebra_map_t
Definition: zebramap.h:29
struct zebra_maps_s * zebra_maps_t
Definition: zebramap.h:28