+const char *zebra_index_type_lookup_str(zebra_index_types_t types,
+ const char *id)
+{
+ zebra_index_type_t t = zebra_index_type_get(types, id);
+ if (t)
+ return t->id;
+ return 0;
+}
+
+int zebra_index_type_is_index(zebra_index_type_t type)
+{
+ return type->index_flag;
+}
+
+int zebra_index_type_is_sort(zebra_index_type_t type)
+{
+ return type->sort_flag;
+}
+
+int zebra_index_type_is_staticrank(zebra_index_type_t type)
+{
+ return type->staticrank_flag;
+}
+
+#define SE_CHARS ";,.()-/?<> \r\n\t"
+
+int tokenize_simple(zebra_index_type_t type,
+ const char **result_buf, size_t *result_len)
+{
+ char *buf = wrbuf_buf(type->simple_buf);
+ size_t len = wrbuf_len(type->simple_buf);
+ size_t i = type->simple_off;
+ size_t start;
+
+ while (i < len && strchr(SE_CHARS, buf[i]))
+ i++;
+ start = i;
+ while (i < len && !strchr(SE_CHARS, buf[i]))
+ {
+ if (buf[i] > 32 && buf[i] < 127)
+ buf[i] = tolower(buf[i]);
+ i++;
+ }
+
+ type->simple_off = i;
+ if (start != i)
+ {
+ *result_buf = buf + start;
+ *result_len = i - start;
+ return 1;
+ }
+ return 0;
+ }
+
+int zebra_index_type_tokenize(zebra_index_type_t type,
+ const char *buf, size_t len,
+ const char **result_buf, size_t *result_len)
+{
+ if (type->simple_chain)
+ {
+ if (buf)
+ {
+ wrbuf_rewind(type->simple_buf);
+ wrbuf_write(type->simple_buf, buf, len);
+ type->simple_off = 0;
+ }
+ return tokenize_simple(type, result_buf, result_len);
+ }
+ return 0;
+}
+