29 #include <yaz/tpath.h>
30 #include <yaz/snprintf.h>
38 #if MAJOR_VERSION >= 8
39 #define HAVE_TCL_OBJECTS
45 #define F_WIN_EOF 2000000000
49 #define REGX_PATTERN 1
54 #define REGX_CONTEXT 6
117 Tcl_Interp *tcl_interp;
151 if (off >= 0 && end_pos <= spec->
f_win_end)
153 *size = end_pos - start_pos;
156 if (off < 0 || start_pos >= spec->
f_win_end)
167 if (*size > end_pos - start_pos)
168 *size = end_pos - start_pos;
171 for (i = 0; i<spec->
f_win_end - start_pos; i++)
179 if (*size > end_pos - start_pos)
180 *size = end_pos - start_pos;
193 buf =
f_win_get (spec, *pos, *pos+1, &size);
210 Tcl_DecrRefCount (p->tcl_obj);
222 p = (
struct regxCode *) xmalloc (
sizeof(*p));
223 p->
str = (
char *) xmalloc (len+1);
224 memcpy (p->
str, buf, len);
227 p->tcl_obj = Tcl_NewStringObj ((
char *) buf, len);
229 Tcl_IncrRefCount (p->tcl_obj);
249 for (ra = *rap; ra; ra = ra1)
289 for (rp = p->
rules; rp; rp = rp1)
307 p = (
struct lexSpec *) xmalloc (
sizeof(*p));
308 p->
name = (
char *) xmalloc (strlen(
name)+1);
358 Tcl_DeleteInterp (p->tcl_interp);
370 const char *cp = *cpp;
374 while (*cp ==
' ' || *cp ==
'\t' || *cp ==
'\n' || *cp ==
'\r')
403 if (*cp >=
'a' && *cp <=
'z')
405 else if (*cp >=
'A' && *cp <=
'Z')
406 cmd[i] = *cp +
'a' -
'A';
409 if (i < (
int)
sizeof(cmd)-2)
416 yaz_log (YLOG_WARN,
"bad character %d %c", *cp, *cp);
418 while (*cp && *cp !=
' ' && *cp !=
'\t' &&
419 *cp !=
'\n' && *cp !=
'\r')
425 if (!strcmp (cmd,
"begin"))
427 else if (!strcmp (cmd,
"end"))
429 else if (!strcmp (cmd,
"body"))
431 else if (!strcmp (cmd,
"context"))
433 else if (!strcmp (cmd,
"init"))
437 yaz_log (YLOG_WARN,
"bad command %s", cmd);
466 (*ap)->u.pattern.body = bodyMark;
470 r =
dfa_parse ((*ap)->u.pattern.dfa, &s);
476 yaz_log(YLOG_WARN,
"regular expression error '%.*s'", pos, s0);
483 printf(
"pattern: %.*s\n", pos, s0);
489 yaz_log (YLOG_WARN,
"cannot use BEGIN here");
492 yaz_log (YLOG_WARN,
"cannot use INIT here");
514 char context_name[32];
518 yaz_log (YLOG_WARN,
"missing name after CONTEXT keyword");
523 memcpy (context_name, s, len);
524 context_name[len] =
'\0';
554 yaz_log (YLOG_WARN,
"regular expression error. r=%d", r);
559 yaz_log (YLOG_WARN,
"expects / at end of pattern. got %c", *s);
563 rp = (
struct lexRule *) xmalloc (
sizeof(*rp));
575 int c, i, errors = 0;
581 if (spec->tcl_interp)
583 yaz_snprintf(fname,
sizeof(fname),
"%s.tflt", spec->
name);
589 yaz_snprintf(fname,
sizeof(fname),
"%s.flt", spec->
name);
594 yaz_log(YLOG_ERRNO|YLOG_WARN,
"cannot read spec file %s", spec->
name);
597 yaz_log(YLOG_LOG,
"reading regx filter %s", fname);
599 if (spec->tcl_interp)
600 yaz_log(YLOG_LOG,
"Tcl enabled");
610 lineBuf = wrbuf_alloc();
615 wrbuf_rewind (lineBuf);
616 if (c ==
'#' || c ==
'\n' || c ==
' ' || c ==
'\t' || c ==
'\r')
618 while (c !=
'\n' && c != EOF)
631 wrbuf_putc(lineBuf, c);
639 if (c !=
' ' && c !=
'\t')
644 wrbuf_putc(lineBuf,
'\0');
650 wrbuf_destroy(lineBuf);
657 for (i = 0; i < lc->
ruleNo; i++)
670 static struct lexSpec *curLexSpec = NULL;
674 const char *ebuf,
int elen,
int formatted_text,
675 const char *attribute_str,
int attribute_len)
684 yaz_log (YLOG_LOG,
"data(%d bytes) %.40s ... %.*s", elen,
685 ebuf, 40, ebuf + elen-40);
686 else if (elen == 1 && ebuf[0] ==
'\n')
688 yaz_log (YLOG_LOG,
"data(new line)");
691 yaz_log (YLOG_LOG,
"data(%d bytes) %.*s", elen, elen, ebuf);
693 yaz_log (YLOG_LOG,
"data(%d bytes)", elen);
709 for (ap = &res->
u.
tag.attributes; *ap; ap = &(*ap)->
next)
710 if (strlen((*ap)->name) == attribute_len &&
711 !memcmp((*ap)->name, attribute_str, attribute_len))
716 *ap = nmem_malloc(spec->
m,
sizeof(**ap));
718 (*ap)->name = nmem_malloc(spec->
m, attribute_len+1);
719 memcpy((*ap)->name, attribute_str, attribute_len);
720 (*ap)->name[attribute_len] =
'\0';
722 (*ap)->value = nmem_malloc(spec->
m, elen+1);
723 memcpy((*ap)->value, ebuf, elen);
724 (*ap)->value[elen] =
'\0';
730 char *nv = nmem_malloc(spec->
m, elen + 1 + strlen((*ap)->value));
731 strcpy(nv, (*ap)->value);
732 memcpy (nv + strlen(nv), ebuf, elen);
733 nv[strlen(nv)+elen] =
'\0';
741 org_len = res->
u.
data.len;
750 res->
u.
data.data = 0;
758 char *old_buf, *new_buf;
764 memcpy (new_buf, old_buf, org_len);
770 res->
u.
data.len += elen;
788 assert (!res->
u.
data.data);
789 assert (res->
u.
data.len > 0);
791 res->
u.
data.data = (
char *) nmem_malloc (spec->
m, res->
u.
data.len);
800 const char *class_str,
int class_len,
801 const char *type_str,
int type_len,
802 const char *value_str,
int value_len)
812 yaz_log (YLOG_WARN,
"in variant begin. No record type defined");
817 memcpy (tclass, class_str, class_len);
818 tclass[class_len] =
'\0';
822 memcpy (ttype, type_str, type_len);
823 ttype[type_len] =
'\0';
826 yaz_log (YLOG_LOG,
"variant begin(%s,%s,%d)", tclass, ttype,
851 yaz_log (YLOG_LOG,
"variant node(%d)", spec->
d1_level);
859 memcpy (res->
lbuf, value_str, value_len);
860 res->
lbuf[value_len] =
'\0';
874 for (i = *
len; i > 0 && isspace((*
tag)[i-1]); --i)
877 for (i = 0; i < *
len && isspace((*
tag)[i]); i++)
888 yaz_log (YLOG_WARN,
"in element begin. No record type defined");
896 yaz_log (YLOG_LOG,
"begin tag(%.*s, %d)",
len,
tag, spec->
d1_level);
922 yaz_log (YLOG_LOG,
"end tag(%d)", spec->
d1_level);
928 struct DFA *dfa,
int greedy)
933 unsigned char c_prev = 0;
935 int start_ptr = *pptr;
948 if (dfa->
states[0] == state)
986 else if (c >= t->
ch[0] && c <= t->
ch[1])
989 if (state->
rule_no && c_prev ==
'\n')
1008 const char **tokBuf,
int *tokLen)
1010 const char *s = *src;
1012 while (*s ==
' ' || *s ==
'\t')
1016 if (*s ==
'$' && s[1] >=
'0' && s[1] <=
'9')
1020 while (*s >=
'0' && *s <=
'9')
1021 n = n*10 + (*s++ -
'0');
1035 else if (*s ==
'\"')
1038 while (*s && *s !=
'\"')
1040 *tokLen = s - *tokBuf;
1045 else if (*s ==
'\n' || *s ==
';')
1053 while (*s && *s !=
' ' && *s !=
'\t' && *s !=
'\n' && *s !=
'\r' &&
1056 *tokLen = s - *tokBuf;
1063 while (*s && *s !=
' ' && *s !=
'\t' && *s !=
'\n' && *s !=
'\r' &&
1066 *tokLen = s - *tokBuf;
1072 static char *
regxStrz (
const char *src,
int len,
char *str)
1076 memcpy (str, src, len);
1082 static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp,
1083 int argc,
const char **argv)
1088 if (!strcmp(argv[1],
"record") && argc == 3)
1090 const char *absynName = argv[2];
1094 yaz_log (YLOG_LOG,
"begin record %s", absynName);
1108 else if (!strcmp(argv[1],
"element") && argc == 3)
1110 tagBegin (spec, argv[2], strlen(argv[2]));
1112 else if (!strcmp (argv[1],
"variant") && argc == 5)
1115 argv[3], strlen(argv[3]),
1116 argv[4], strlen(argv[4]));
1118 else if (!strcmp (argv[1],
"context") && argc == 3)
1122 yaz_log (YLOG_LOG,
"begin context %s",argv[2]);
1124 while (lc && strcmp (argv[2], lc->
name))
1131 yaz_log (YLOG_WARN,
"unknown context %s", argv[2]);
1138 static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp,
1139 int argc,
const char **argv)
1145 if (!strcmp (argv[1],
"record"))
1153 yaz_log (YLOG_LOG,
"end record");
1157 else if (!strcmp (argv[1],
"element"))
1160 const char *element = 0;
1161 if (argc >= 3 && !strcmp(argv[2],
"-record"))
1170 tagEnd (spec, min_level, element, (element ? strlen(element) : 0));
1174 yaz_log (YLOG_LOG,
"end element end records");
1179 else if (!strcmp (argv[1],
"context"))
1182 yaz_log (YLOG_LOG,
"end context");
1192 static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp,
1193 int argc,
const char **argv)
1197 const char *element = 0;
1198 const char *attribute = 0;
1203 if (!strcmp(
"-text", argv[argi]))
1208 else if (!strcmp(
"-element", argv[argi]))
1212 element = argv[argi++];
1214 else if (!strcmp(
"-attribute", argv[argi]))
1218 attribute = argv[argi++];
1224 tagBegin (spec, element, strlen(element));
1228 #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
1230 char *native = Tcl_UtfToExternalDString(0, argv[argi], -1, &ds);
1231 execData (spec, native, strlen(native), textFlag, attribute,
1232 attribute ? strlen(attribute) : 0);
1233 Tcl_DStringFree (&ds);
1235 execData (spec, argv[argi], strlen(argv[argi]), textFlag, attribute,
1236 attribute ? strlen(attribute) : 0);
1241 tagEnd (spec, 2, NULL, 0);
1245 static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp,
1246 int argc,
const char **argv)
1255 if (!strcmp(
"-offset", argv[argi]))
1260 offset = atoi(argv[argi]);
1269 no = atoi(argv[argi]);
1280 for (i = 0; i < spec->
arg_no; i++)
1282 char var_name[10], *var_buf;
1285 yaz_snprintf(var_name,
sizeof(var_name),
"%d", i);
1290 ch = var_buf[var_len];
1291 var_buf[var_len] =
'\0';
1292 Tcl_SetVar (spec->tcl_interp, var_name, var_buf, 0);
1293 var_buf[var_len] = ch;
1296 #if HAVE_TCL_OBJECTS
1297 ret = Tcl_GlobalEvalObj(spec->tcl_interp, code->tcl_obj);
1299 ret = Tcl_GlobalEval (spec->tcl_interp, code->
str);
1303 const char *err = Tcl_GetVar(spec->tcl_interp,
"errorInfo", 0);
1304 yaz_log(YLOG_FATAL,
"Tcl error, line=%d, \"%s\"\n%s",
1305 #
if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 5
1306 spec->tcl_interp->errorLine,
1307 spec->tcl_interp->result,
1309 Tcl_GetErrorLine(spec->tcl_interp),
1310 Tcl_GetStringResult(spec->tcl_interp),
1312 err ? err :
"[NO ERRORINFO]");
1320 const char *s = code->
str;
1322 const char *cmd_str;
1324 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1331 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1334 p =
regxStrz (cmd_str, cmd_len, ptmp);
1335 if (!strcmp (p,
"begin"))
1337 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1340 yaz_log (YLOG_WARN,
"missing keyword after 'begin'");
1343 p =
regxStrz (cmd_str, cmd_len, ptmp);
1344 if (!strcmp (p,
"record"))
1346 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1351 static char absynName[64];
1356 memcpy (absynName, cmd_str, cmd_len);
1357 absynName[cmd_len] =
'\0';
1359 yaz_log (YLOG_LOG,
"begin record %s", absynName);
1373 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1375 else if (!strcmp (p,
"element"))
1377 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1381 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1383 else if (!strcmp (p,
"variant"))
1386 const char *class_str = NULL;
1388 const char *type_str = NULL;
1390 const char *value_str = NULL;
1391 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1394 class_str = cmd_str;
1395 class_len = cmd_len;
1396 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1402 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1405 value_str = cmd_str;
1406 value_len = cmd_len;
1409 type_str, type_len, value_str, value_len);
1412 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1414 else if (!strcmp (p,
"context"))
1419 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1420 p =
regxStrz (cmd_str, cmd_len, ptmp);
1422 yaz_log (YLOG_LOG,
"begin context %s", p);
1424 while (lc && strcmp (p, lc->
name))
1429 yaz_log (YLOG_WARN,
"unknown context %s", p);
1432 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1436 yaz_log (YLOG_WARN,
"bad keyword '%s' after begin", p);
1439 else if (!strcmp (p,
"end"))
1441 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1444 yaz_log (YLOG_WARN,
"missing keyword after 'end'");
1447 p =
regxStrz (cmd_str, cmd_len, ptmp);
1448 if (!strcmp (p,
"record"))
1455 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1457 yaz_log (YLOG_LOG,
"end record");
1461 else if (!strcmp (p,
"element"))
1464 while ((r =
execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
1466 if (cmd_len==7 && !memcmp (
"-record", cmd_str, cmd_len))
1471 tagEnd (spec, min_level, cmd_str, cmd_len);
1472 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1475 tagEnd (spec, min_level, NULL, 0);
1479 yaz_log (YLOG_LOG,
"end element end records");
1485 else if (!strcmp (p,
"context"))
1488 yaz_log (YLOG_LOG,
"end context");
1492 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1495 yaz_log (YLOG_WARN,
"bad keyword '%s' after end", p);
1497 else if (!strcmp (p,
"data"))
1501 const char *element_str = NULL;
1503 const char *attribute_str = NULL;
1505 while ((r =
execTok (spec, &s, &cmd_str, &cmd_len)) == 3)
1507 if (cmd_len==5 && !memcmp (
"-text", cmd_str, cmd_len))
1509 else if (cmd_len==8 && !memcmp (
"-element", cmd_str, cmd_len))
1511 r =
execTok (spec, &s, &element_str, &element_len);
1515 else if (cmd_len==10 && !memcmp (
"-attribute", cmd_str,
1518 r =
execTok (spec, &s, &attribute_str, &attribute_len);
1523 yaz_log (YLOG_WARN,
"bad data option: %.*s",
1528 yaz_log (YLOG_WARN,
"missing data item after data");
1532 tagBegin (spec, element_str, element_len);
1535 execData (spec, cmd_str, cmd_len, textFlag,
1536 attribute_str, attribute_len);
1537 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1540 tagEnd (spec, 2, NULL, 0);
1542 else if (!strcmp (p,
"unread"))
1545 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1546 if (r==3 && cmd_len == 7 && !memcmp (
"-offset", cmd_str, cmd_len))
1548 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1551 yaz_log (YLOG_WARN,
"missing number after -offset");
1554 p =
regxStrz (cmd_str, cmd_len, ptmp);
1556 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1562 yaz_log (YLOG_WARN,
"missing index after unread command");
1565 if (cmd_len != 1 || *cmd_str < '0' || *cmd_str >
'9')
1567 yaz_log (YLOG_WARN,
"bad index after unread command");
1572 no = *cmd_str -
'0';
1577 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1579 else if (!strcmp (p,
"context"))
1584 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1585 p =
regxStrz (cmd_str, cmd_len, ptmp);
1587 while (lc && strcmp (p, lc->
name))
1592 yaz_log (YLOG_WARN,
"unknown context %s", p);
1595 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1599 yaz_log (YLOG_WARN,
"unknown code command '%.*s'", cmd_len, cmd_str);
1600 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1605 yaz_log (YLOG_WARN,
"ignoring token %.*s", cmd_len, cmd_str);
1607 r =
execTok (spec, &s, &cmd_str, &cmd_len);
1615 int start_ptr,
int *pptr)
1624 arg_start[0] = start_ptr;
1636 arg_start[arg_no] = *pptr;
1643 yaz_log(YLOG_DEBUG,
"Pattern match rest of record");
1648 arg_end[arg_no] = sptr;
1650 arg_start[arg_no] = sptr;
1651 arg_end[arg_no] = *pptr;
1656 arg_start[arg_no] = *pptr;
1659 if (sptr != arg_start[arg_no])
1661 arg_end[arg_no] = *pptr;
1669 if (spec->tcl_interp)
1670 execTcl(spec, ap->
u.
code);
1681 arg_start[arg_no] = *pptr;
1692 int ruleNo,
int start_ptr,
int *pptr)
1695 yaz_log (YLOG_LOG,
"exec rule %d",
ruleNo);
1707 unsigned char c_prev =
'\n';
1710 int last_ptr = *ptr;
1711 int start_ptr = *ptr;
1712 int skip_ptr = *ptr;
1724 if (skip_ptr < start_ptr)
1729 buf =
f_win_get (spec, skip_ptr, start_ptr, &size);
1735 if (!
execRule (spec, context, last_rule, start_ptr, ptr))
1741 else if (skip_ptr < *ptr)
1746 buf =
f_win_get (spec, skip_ptr, *ptr, &size);
1760 if (skip_ptr < start_ptr)
1765 buf =
f_win_get (spec, skip_ptr, start_ptr, &size);
1770 if (!
execRule (spec, context, last_rule, start_ptr, ptr))
1774 off_t end_offset = *ptr;
1776 yaz_log (YLOG_LOG,
"regx: endf ptr=%d", *ptr);
1785 last_ptr = start_ptr = *ptr;
1800 else if (c >= t->
ch[0] && c <= t->
ch[1])
1826 const char *context_name)
1837 if (!strcmp (lt->
name, context_name))
1843 yaz_log (YLOG_WARN,
"cannot find context %s", context_name);
1883 strcpy(specs->
type,
"");
1891 if (strlen(args) <
sizeof(specs->
type))
1892 strcpy(specs->
type, args);
1904 yaz_log (YLOG_LOG,
"grs_read_regx");
1906 if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->
type))
1918 (*curLexSpec)->dh = p->
dh;
1920 if (start_offset == 0)
1922 (*curLexSpec)->f_win_start = 0;
1923 (*curLexSpec)->f_win_end = 0;
1926 (*curLexSpec)->stream = p->
stream;
1928 (*curLexSpec)->f_win_size = 500000;
1930 (*curLexSpec)->m = p->
mem;
1931 return lexRoot (*curLexSpec, start_offset,
"main");
1964 yaz_log (YLOG_LOG,
"grs_read_tcl");
1966 if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->
type))
1968 Tcl_Interp *tcl_interp;
1972 Tcl_FindExecutable(
"");
1973 tcl_interp = (*curLexSpec)->tcl_interp = Tcl_CreateInterp();
1974 Tcl_Init(tcl_interp);
1975 Tcl_CreateCommand (tcl_interp,
"begin", cmd_tcl_begin, *curLexSpec, 0);
1976 Tcl_CreateCommand (tcl_interp,
"end", cmd_tcl_end, *curLexSpec, 0);
1977 Tcl_CreateCommand (tcl_interp,
"data", cmd_tcl_data, *curLexSpec, 0);
1978 Tcl_CreateCommand (tcl_interp,
"unread", cmd_tcl_unread,
1987 (*curLexSpec)->dh = p->
dh;
1989 if (start_offset == 0)
1991 (*curLexSpec)->f_win_start = 0;
1992 (*curLexSpec)->f_win_end = 0;
1995 (*curLexSpec)->stream = p->
stream;
1997 (*curLexSpec)->f_win_size = 500000;
1999 (*curLexSpec)->m = p->
mem;
2000 return lexRoot (*curLexSpec, start_offset,
"main");
2003 static int extract_tcl(
void *clientData,
struct recExtractCtrl *ctrl)
2008 static int retrieve_tcl(
void *clientData,
struct recRetrieveCtrl *ctrl)
2013 static struct recType tcl_type = {
2026 #if IDZEBRA_STATIC_GRS_REGX
2027 idzebra_filter_grs_regx
data1_node * data1_mk_tag(data1_handle dh, NMEM nmem, const char *tag, const char **attr, data1_node *at)
data1_node * data1_mk_root(data1_handle dh, NMEM nmem, const char *name)
FILE * data1_path_fopen(data1_handle dh, const char *file, const char *mode)
data1_node * data1_mk_tag_n(data1_handle dh, NMEM nmem, const char *tag, size_t len, const char **attr, data1_node *at)
data1_node * data1_mk_node2(data1_handle dh, NMEM m, int type, data1_node *parent)
data1_vartype * data1_getvartypeby_absyn(data1_handle dh, data1_absyn *absyn, char *zclass, char *type)
void dfa_parse_cmap_add(struct DFA *d, int from, int to)
void dfa_parse_cmap_del(struct DFA *d, int from)
int dfa_parse(struct DFA *, const char **)
void dfa_mkstate(struct DFA *)
void dfa_delete(struct DFA **)
struct DFA * dfa_init(void)
static void tagEnd(struct lexSpec *spec, int min_level, const char *tag, int len)
static void lexContextDestroy(struct lexContext *p)
static void execData(struct lexSpec *spec, const char *ebuf, int elen, int formatted_text, const char *attribute_str, int attribute_len)
static int execRule(struct lexSpec *spec, struct lexContext *context, int ruleNo, int start_ptr, int *pptr)
static int extract_regx(void *clientData, struct recExtractCtrl *ctrl)
static void lexSpecDestroy(struct lexSpec **pp)
static char * f_win_get(struct lexSpec *spec, off_t start_pos, off_t end_pos, int *size)
static int readParseToken(const char **cpp, int *len)
static int execTok(struct lexSpec *spec, const char **src, const char **tokBuf, int *tokLen)
static void tagDataRelease(struct lexSpec *spec)
static struct lexContext * lexContextCreate(const char *name)
static int execAction(struct lexSpec *spec, struct lexRuleAction *ap, int start_ptr, int *pptr)
static struct DFA * lexSpecDFA(void)
static void variantBegin(struct lexSpec *spec, const char *class_str, int class_len, const char *type_str, int type_len, const char *value_str, int value_len)
static int f_win_advance(struct lexSpec *spec, int *pos)
static void regxCodeDel(struct regxCode **pp)
static void actionListDel(struct lexRuleAction **rap)
static data1_node * lexRoot(struct lexSpec *spec, off_t offset, const char *context_name)
static void tagStrip(const char **tag, int *len)
static int actionListMk(struct lexSpec *spec, const char *s, struct lexRuleAction **ap)
static struct lexSpec * lexSpecCreate(const char *name, data1_handle dh)
int readFileSpec(struct lexSpec *spec)
static void execCode(struct lexSpec *spec, struct regxCode *code)
static void tagBegin(struct lexSpec *spec, const char *tag, int len)
static void regxCodeMk(struct regxCode **pp, const char *buf, int len)
ZEBRA_RES grs_config(void *clientData, Res res, const char *args)
int readOneSpec(struct lexSpec *spec, const char *s)
static void execDataP(struct lexSpec *spec, const char *ebuf, int elen, int formatted_text)
int lexNode(struct lexSpec *spec, int *ptr)
void grs_destroy(void *clientData)
static int tryMatch(struct lexSpec *spec, int *pptr, int *mptr, struct DFA *dfa, int greedy)
void * grs_init(Res res, RecType recType)
static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl)
data1_node * grs_read_regx(struct grs_read_info *p)
static struct recType regx_type
static char * regxStrz(const char *src, int len, char *str)
int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, data1_node *(*grs_read)(struct grs_read_info *))
int zebra_grs_extract(void *clientData, struct recExtractCtrl *p, data1_node *(*grs_read)(struct grs_read_info *))
struct DFA_state ** states
off_t(* seekf)(struct ZebraRecStream *s, off_t offset)
seek function
off_t(* endf)(struct ZebraRecStream *s, off_t *offset)
set and get of record position
int(* readf)(struct ZebraRecStream *s, char *buf, size_t count)
read function
off_t(* tellf)(struct ZebraRecStream *s)
tell function
char lbuf[DATA1_LOCALDATA]
struct data1_node::@2::@3 root
struct data1_node * parent
struct data1_node::@2::@6 variant
struct data1_xattr * next
struct ZebraRecStream * stream
struct lexRuleAction * endActionList
struct lexRuleInfo ** fastRule
struct lexRuleAction * beginActionList
struct lexRuleAction * initActionList
struct lexRuleAction::@22::@23 pattern
struct lexRuleAction * next
union lexRuleAction::@22 u
struct lexRuleAction * actionList
off_t(* f_win_ef)(struct ZebraRecStream *s, off_t *)
struct lexContext * context
off_t(* f_win_sf)(struct ZebraRecStream *, off_t)
struct ZebraRecStream * stream
struct lexContext ** context_stack
int(* f_win_rf)(struct ZebraRecStream *, char *, size_t)
struct lexConcatBuf * concatBuf
short ZEBRA_RES
Common return type for Zebra API.